[opaque pointer type] Pass explicit type to Load instruction creation in AutoUpgrade

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@237838 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
David Blaikie committed 2015-05-20 21:46:30 +00:00
1 parent e677c7bd22
commit 14a714f727
5 files changed
+24 -13

No files matched your search

+3
View File
@@ -993,6 +993,9 @@ public:
LoadInst *CreateLoad(Value *Ptr, const Twine &Name = "") { LoadInst *CreateLoad(Value *Ptr, const Twine &Name = "") {
return Insert(new LoadInst(Ptr), Name); return Insert(new LoadInst(Ptr), Name);
} }
LoadInst *CreateLoad(Type *Ty, Value *Ptr, const Twine &Name = "") {
return Insert(new LoadInst(Ty, Ptr), Name);
}
LoadInst *CreateLoad(Value *Ptr, bool isVolatile, const Twine &Name = "") { LoadInst *CreateLoad(Value *Ptr, bool isVolatile, const Twine &Name = "") {
return Insert(new LoadInst(Ptr, nullptr, isVolatile), Name); return Insert(new LoadInst(Ptr, nullptr, isVolatile), Name);
} }
+10 -2
View File
@@ -177,8 +177,12 @@ protected:
public: public:
LoadInst(Value *Ptr, const Twine &NameStr, Instruction *InsertBefore); LoadInst(Value *Ptr, const Twine &NameStr, Instruction *InsertBefore);
LoadInst(Value *Ptr, const Twine &NameStr, BasicBlock *InsertAtEnd); LoadInst(Value *Ptr, const Twine &NameStr, BasicBlock *InsertAtEnd);
LoadInst(Value *Ptr, const Twine &NameStr, bool isVolatile = false, LoadInst(Type *Ty, Value *Ptr, const Twine &NameStr, bool isVolatile = false,
Instruction *InsertBefore = nullptr); Instruction *InsertBefore = nullptr);
LoadInst(Value *Ptr, const Twine &NameStr, bool isVolatile = false,
Instruction *InsertBefore = nullptr)
: LoadInst(cast<PointerType>(Ptr->getType())->getElementType(), Ptr,
NameStr, isVolatile, InsertBefore) {}
LoadInst(Value *Ptr, const Twine &NameStr, bool isVolatile, LoadInst(Value *Ptr, const Twine &NameStr, bool isVolatile,
BasicBlock *InsertAtEnd); BasicBlock *InsertAtEnd);
LoadInst(Value *Ptr, const Twine &NameStr, bool isVolatile, unsigned Align, LoadInst(Value *Ptr, const Twine &NameStr, bool isVolatile, unsigned Align,
@@ -205,9 +209,13 @@ public:
LoadInst(Value *Ptr, const char *NameStr, Instruction *InsertBefore); LoadInst(Value *Ptr, const char *NameStr, Instruction *InsertBefore);
LoadInst(Value *Ptr, const char *NameStr, BasicBlock *InsertAtEnd); LoadInst(Value *Ptr, const char *NameStr, BasicBlock *InsertAtEnd);
LoadInst(Type *Ty, Value *Ptr, const char *NameStr = nullptr,
bool isVolatile = false, Instruction *InsertBefore = nullptr);
explicit LoadInst(Value *Ptr, const char *NameStr = nullptr, explicit LoadInst(Value *Ptr, const char *NameStr = nullptr,
bool isVolatile = false, bool isVolatile = false,
Instruction *InsertBefore = nullptr); Instruction *InsertBefore = nullptr)
: LoadInst(cast<PointerType>(Ptr->getType())->getElementType(), Ptr,
NameStr, isVolatile, InsertBefore) {}
LoadInst(Value *Ptr, const char *NameStr, bool isVolatile, LoadInst(Value *Ptr, const char *NameStr, bool isVolatile,
BasicBlock *InsertAtEnd); BasicBlock *InsertAtEnd);
+5 -5
View File
@@ -431,7 +431,7 @@ void llvm::UpgradeIntrinsicCall(CallInst *CI, Function *NewFn) {
unsigned EltNum = VecTy->getVectorNumElements(); unsigned EltNum = VecTy->getVectorNumElements();
Value *Cast = Builder.CreateBitCast(CI->getArgOperand(0), Value *Cast = Builder.CreateBitCast(CI->getArgOperand(0),
EltTy->getPointerTo()); EltTy->getPointerTo());
Value *Load = Builder.CreateLoad(Cast); Value *Load = Builder.CreateLoad(EltTy, Cast);
Type *I32Ty = Type::getInt32Ty(C); Type *I32Ty = Type::getInt32Ty(C);
Rep = UndefValue::get(VecTy); Rep = UndefValue::get(VecTy);
for (unsigned I = 0; I < EltNum; ++I) for (unsigned I = 0; I < EltNum; ++I)
@@ -439,10 +439,10 @@ void llvm::UpgradeIntrinsicCall(CallInst *CI, Function *NewFn) {
ConstantInt::get(I32Ty, I)); ConstantInt::get(I32Ty, I));
} else if (Name == "llvm.x86.avx2.vbroadcasti128") { } else if (Name == "llvm.x86.avx2.vbroadcasti128") {
// Replace vbroadcasts with a vector shuffle. // Replace vbroadcasts with a vector shuffle.
Value *Op = Builder.CreatePointerCast( Type *VT = VectorType::get(Type::getInt64Ty(C), 2);
CI->getArgOperand(0), Value *Op = Builder.CreatePointerCast(CI->getArgOperand(0),
PointerType::getUnqual(VectorType::get(Type::getInt64Ty(C), 2))); PointerType::getUnqual(VT));
Value *Load = Builder.CreateLoad(Op); Value *Load = Builder.CreateLoad(VT, Op);
const int Idxs[4] = { 0, 1, 0, 1 }; const int Idxs[4] = { 0, 1, 0, 1 };
Rep = Builder.CreateShuffleVector(Load, UndefValue::get(Load->getType()), Rep = Builder.CreateShuffleVector(Load, UndefValue::get(Load->getType()),
Idxs); Idxs);
+5 -5
View File
@@ -931,9 +931,9 @@ LoadInst::LoadInst(Value *Ptr, const Twine &Name, Instruction *InsertBef)
LoadInst::LoadInst(Value *Ptr, const Twine &Name, BasicBlock *InsertAE) LoadInst::LoadInst(Value *Ptr, const Twine &Name, BasicBlock *InsertAE)
: LoadInst(Ptr, Name, /*isVolatile=*/false, InsertAE) {} : LoadInst(Ptr, Name, /*isVolatile=*/false, InsertAE) {}
LoadInst::LoadInst(Value *Ptr, const Twine &Name, bool isVolatile, LoadInst::LoadInst(Type *Ty, Value *Ptr, const Twine &Name, bool isVolatile,
Instruction *InsertBef) Instruction *InsertBef)
: LoadInst(Ptr, Name, isVolatile, /*Align=*/0, InsertBef) {} : LoadInst(Ty, Ptr, Name, isVolatile, /*Align=*/0, InsertBef) {}
LoadInst::LoadInst(Value *Ptr, const Twine &Name, bool isVolatile, LoadInst::LoadInst(Value *Ptr, const Twine &Name, bool isVolatile,
BasicBlock *InsertAE) BasicBlock *InsertAE)
@@ -994,10 +994,10 @@ LoadInst::LoadInst(Value *Ptr, const char *Name, BasicBlock *InsertAE)
if (Name && Name[0]) setName(Name); if (Name && Name[0]) setName(Name);
} }
LoadInst::LoadInst(Value *Ptr, const char *Name, bool isVolatile, LoadInst::LoadInst(Type *Ty, Value *Ptr, const char *Name, bool isVolatile,
Instruction *InsertBef) Instruction *InsertBef)
: UnaryInstruction(cast<PointerType>(Ptr->getType())->getElementType(), : UnaryInstruction(Ty, Load, Ptr, InsertBef) {
Load, Ptr, InsertBef) { assert(Ty == cast<PointerType>(Ptr->getType())->getElementType());
setVolatile(isVolatile); setVolatile(isVolatile);
setAlignment(0); setAlignment(0);
setAtomic(NotAtomic); setAtomic(NotAtomic);
+1 -1
View File
@@ -494,7 +494,7 @@ void Verifier::visitGlobalVariable(const GlobalVariable &GV) {
GV.getName() == "llvm.compiler.used")) { GV.getName() == "llvm.compiler.used")) {
Assert(!GV.hasInitializer() || GV.hasAppendingLinkage(), Assert(!GV.hasInitializer() || GV.hasAppendingLinkage(),
"invalid linkage for intrinsic global variable", &GV); "invalid linkage for intrinsic global variable", &GV);
Type *GVType = GV.getType()->getElementType(); Type *GVType = GV.getValueType();
if (ArrayType *ATy = dyn_cast<ArrayType>(GVType)) { if (ArrayType *ATy = dyn_cast<ArrayType>(GVType)) {
PointerType *PTy = dyn_cast<PointerType>(ATy->getElementType()); PointerType *PTy = dyn_cast<PointerType>(ATy->getElementType());
Assert(PTy, "wrong type for intrinsic global variable", &GV); Assert(PTy, "wrong type for intrinsic global variable", &GV);