Use IRBuilder, preserve line numbers.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@132578 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Devang Patel 2011-06-03 19:46:19 +00:00
parent 578229cada
commit abb2512205

View File

@ -1840,9 +1840,10 @@ void SROA::RewriteForScalarRepl(Instruction *I, AllocaInst *AI, uint64_t Offset,
// %insert = insertvalue { i32, i32 } %insert.0, i32 %load.1, 1
// (Also works for arrays instead of structs)
Value *Insert = UndefValue::get(LIType);
IRBuilder<> Builder(LI);
for (unsigned i = 0, e = NewElts.size(); i != e; ++i) {
Value *Load = new LoadInst(NewElts[i], "load", LI);
Insert = InsertValueInst::Create(Insert, Load, i, "insert", LI);
Value *Load = Builder.CreateLoad(NewElts[i], "load");
Insert = Builder.CreateInsertValue(Insert, Load, i, "insert");
}
LI->replaceAllUsesWith(Insert);
DeadInsts.push_back(LI);
@ -1867,9 +1868,10 @@ void SROA::RewriteForScalarRepl(Instruction *I, AllocaInst *AI, uint64_t Offset,
// %val.1 = extractvalue { i32, i32 } %val, 1
// store i32 %val.1, i32* %alloc.1
// (Also works for arrays instead of structs)
IRBuilder<> Builder(SI);
for (unsigned i = 0, e = NewElts.size(); i != e; ++i) {
Value *Extract = ExtractValueInst::Create(Val, i, Val->getName(), SI);
new StoreInst(Extract, NewElts[i], SI);
Value *Extract = Builder.CreateExtractValue(Val, i, Val->getName());
Builder.CreateStore(Extract, NewElts[i]);
}
DeadInsts.push_back(SI);
} else if (SIType->isIntegerTy() &&