[Beignet] [Patch V2] Fix a random assert caused by scalarize pass.
Zhigang Gong
zhigang.gong at linux.intel.com
Fri May 31 00:23:25 PDT 2013
This version is much better and it works fine. Will push it soon.
Thanks.
> -----Original Message-----
> From: beignet-bounces+zhigang.gong=linux.intel.com at lists.freedesktop.org
>
[mailto:beignet-bounces+zhigang.gong=linux.intel.com at lists.freedesktop.org]
> On Behalf Of Yang Rong
> Sent: Friday, May 31, 2013 3:19 PM
> To: beignet at lists.freedesktop.org
> Cc: Yang Rong
> Subject: [Beignet] [Patch V2] Fix a random assert caused by scalarize
pass.
>
> Revome the dead values in unit.valueMap at each begin of pass to avoid the
> new value have some address.
> Also fix a typo
>
> Signed-off-by: Yang Rong <rong.r.yang at intel.com>
> ---
> backend/src/ir/unit.cpp | 10 +++++++++-
> backend/src/ir/unit.hpp | 2 ++
> backend/src/llvm/llvm_gen_backend.cpp | 1 +
> backend/src/llvm/llvm_scalarize.cpp | 12 ++++++------
> 4 files changed, 18 insertions(+), 7 deletions(-)
>
> diff --git a/backend/src/ir/unit.cpp b/backend/src/ir/unit.cpp index
> 1e98afa..44cec3c 100644
> --- a/backend/src/ir/unit.cpp
> +++ b/backend/src/ir/unit.cpp
> @@ -21,6 +21,7 @@
> * \file unit.cpp
> * \author Benjamin Segovia <benjamin.segovia at intel.com>
> */
> +#include "llvm/Instructions.h"
> #include "ir/unit.hpp"
> #include "ir/function.hpp"
>
> @@ -53,10 +54,17 @@ namespace ir {
> constantSet.append(data, name, size, alignment);
> }
>
> + void Unit::removeDeadValues()
> + {
> + for(auto &it : valueMap) {
> + llvm::Instruction* I =
llvm::dyn_cast<llvm::Instruction>(it.first.first);
> //fake value
> + if((I == NULL) || (I->getParent() == NULL))
> + valueMap.erase(it.first);
> + }
> + }
> std::ostream &operator<< (std::ostream &out, const Unit &unit) {
> unit.apply([&out] (const Function &fn) { out << fn << std::endl; });
> return out;
> }
> } /* namespace ir */
> } /* namespace gbe */
> -
> diff --git a/backend/src/ir/unit.hpp b/backend/src/ir/unit.hpp index
> 3b293f5..f19fd7e 100644
> --- a/backend/src/ir/unit.hpp
> +++ b/backend/src/ir/unit.hpp
> @@ -88,6 +88,8 @@ namespace ir {
> GBE_ASSERT(valueMap.find(key) == valueMap.end()); // Do not insert
> twice
> valueMap[key] = value;
> }
> + /* remove fake values that removed by other pass */
> + void removeDeadValues(void);
> /*! Return the value map */
> const map<ValueIndex, ValueIndex>& getValueMap(void) const { return
> valueMap; }
> private:
> diff --git a/backend/src/llvm/llvm_gen_backend.cpp
> b/backend/src/llvm/llvm_gen_backend.cpp
> index 3fe0cbf..131d7a6 100644
> --- a/backend/src/llvm/llvm_gen_backend.cpp
> +++ b/backend/src/llvm/llvm_gen_backend.cpp
> @@ -1140,6 +1140,7 @@ namespace gbe
> }
>
> ctx.startFunction(F.getName());
> + unit.removeDeadValues();
> this->regTranslator.clear();
> this->regTranslator.initValueMap(unit.getValueMap());
> this->labelMap.clear();
> diff --git a/backend/src/llvm/llvm_scalarize.cpp
> b/backend/src/llvm/llvm_scalarize.cpp
> index bc66549..c24e575 100644
> --- a/backend/src/llvm/llvm_scalarize.cpp
> +++ b/backend/src/llvm/llvm_scalarize.cpp
> @@ -182,7 +182,7 @@ namespace gbe {
> bool IsPerComponentOp(const Value* value);
>
> //these function used to add extract and insert instructions when
> load/store etc.
> - void extractFromeVector(Value* insn);
> + void extractFromVector(Value* insn);
> Value* InsertToVector(Value* insn, Value* vecValue);
>
> Type* GetBasicType(Value* value) {
> @@ -581,7 +581,7 @@ namespace gbe {
> return true;
> }
>
> - void Scalarize::extractFromeVector(Value* insn) {
> + void Scalarize::extractFromVector(Value* insn) {
> VectorValues& vVals = vectorVals[insn];
>
> for (int i = 0; i < GetComponentCount(insn); ++i) { @@ -645,7 +645,7
@@
> namespace gbe {
> case GEN_OCL_GET_IMAGE_WIDTH:
> case GEN_OCL_GET_IMAGE_HEIGHT:
> {
> - extractFromeVector(call);
> + extractFromVector(call);
> break;
> }
> case GEN_OCL_WRITE_IMAGE10:
> @@ -673,7 +673,7 @@ namespace gbe {
>
> bool Scalarize::scalarizeLoad(LoadInst* ld)
> {
> - extractFromeVector(ld);
> + extractFromVector(ld);
> return false;
> }
>
> @@ -738,7 +738,7 @@ namespace gbe {
> Type *type = I->getType();
>
> if(type->isVectorTy())
> - extractFromeVector(I);
> + extractFromVector(I);
> }
> return;
> }
> @@ -758,9 +758,9 @@ namespace gbe {
> intTy = IntegerType::get(module->getContext(), 32);
> floatTy = Type::getFloatTy(module->getContext());
> builder = new IRBuilder<>(module->getContext());
> + unit.removeDeadValues();
>
> scalarizeArgs(F);
> -
> typedef ReversePostOrderTraversal<Function*> RPOTType;
> RPOTType rpot(&F);
> for (RPOTType::rpo_iterator bbI = rpot.begin(), bbE = rpot.end(); bbI
!=
> bbE; ++bbI) {
> --
> 1.7.9.5
>
> _______________________________________________
> Beignet mailing list
> Beignet at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/beignet
More information about the Beignet
mailing list