* \file unit.cpp
* \author Benjamin Segovia <benjamin.segovia@intel.com>
*/
+#include "llvm/Instructions.h"
#include "ir/unit.hpp"
#include "ir/function.hpp"
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 */
-
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:
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) {
return true;
}
- void Scalarize::extractFromeVector(Value* insn) {
+ void Scalarize::extractFromVector(Value* insn) {
VectorValues& vVals = vectorVals[insn];
for (int i = 0; i < GetComponentCount(insn); ++i) {
case GEN_OCL_GET_IMAGE_WIDTH:
case GEN_OCL_GET_IMAGE_HEIGHT:
{
- extractFromeVector(call);
+ extractFromVector(call);
break;
}
case GEN_OCL_WRITE_IMAGE10:
bool Scalarize::scalarizeLoad(LoadInst* ld)
{
- extractFromeVector(ld);
+ extractFromVector(ld);
return false;
}
Type *type = I->getType();
if(type->isVectorTy())
- extractFromeVector(I);
+ extractFromVector(I);
}
return;
}
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) {