summaryrefslogtreecommitdiffstats
path: root/lib/Transforms/Utils
diff options
context:
space:
mode:
authorDavid Greene <greened@obbligato.org>2007-09-04 15:46:09 +0000
committerDavid Greene <greened@obbligato.org>2007-09-04 15:46:09 +0000
commitb8f74793b9d161bc666fe27fc92fe112b6ec169b (patch)
tree3e79ac89138858c59c1f73af09b64527778ad944 /lib/Transforms/Utils
parent382526239944023e435833ce759f536fec4e6225 (diff)
downloadexternal_llvm-b8f74793b9d161bc666fe27fc92fe112b6ec169b.zip
external_llvm-b8f74793b9d161bc666fe27fc92fe112b6ec169b.tar.gz
external_llvm-b8f74793b9d161bc666fe27fc92fe112b6ec169b.tar.bz2
Update GEP constructors to use an iterator interface to fix
GLIBCXX_DEBUG issues. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@41697 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms/Utils')
-rw-r--r--lib/Transforms/Utils/CodeExtractor.cpp28
-rw-r--r--lib/Transforms/Utils/LowerInvoke.cpp9
2 files changed, 21 insertions, 16 deletions
diff --git a/lib/Transforms/Utils/CodeExtractor.cpp b/lib/Transforms/Utils/CodeExtractor.cpp
index 90642f1..c42d5e1 100644
--- a/lib/Transforms/Utils/CodeExtractor.cpp
+++ b/lib/Transforms/Utils/CodeExtractor.cpp
@@ -294,11 +294,12 @@ Function *CodeExtractor::constructFunction(const Values &inputs,
for (unsigned i = 0, e = inputs.size(); i != e; ++i) {
Value *RewriteVal;
if (AggregateArgs) {
- Value *Idx0 = Constant::getNullValue(Type::Int32Ty);
- Value *Idx1 = ConstantInt::get(Type::Int32Ty, i);
+ Value *Idx[2];
+ Idx[0] = Constant::getNullValue(Type::Int32Ty);
+ Idx[1] = ConstantInt::get(Type::Int32Ty, i);
std::string GEPname = "gep_" + inputs[i]->getName();
TerminatorInst *TI = newFunction->begin()->getTerminator();
- GetElementPtrInst *GEP = new GetElementPtrInst(AI, Idx0, Idx1,
+ GetElementPtrInst *GEP = new GetElementPtrInst(AI, Idx, Idx+2,
GEPname, TI);
RewriteVal = new LoadInst(GEP, "load" + GEPname, TI);
} else
@@ -381,10 +382,11 @@ emitCallAndSwitchStatement(Function *newFunction, BasicBlock *codeReplacer,
params.push_back(Struct);
for (unsigned i = 0, e = inputs.size(); i != e; ++i) {
- Value *Idx0 = Constant::getNullValue(Type::Int32Ty);
- Value *Idx1 = ConstantInt::get(Type::Int32Ty, i);
+ Value *Idx[2];
+ Idx[0] = Constant::getNullValue(Type::Int32Ty);
+ Idx[1] = ConstantInt::get(Type::Int32Ty, i);
GetElementPtrInst *GEP =
- new GetElementPtrInst(Struct, Idx0, Idx1,
+ new GetElementPtrInst(Struct, Idx, Idx + 2,
"gep_" + StructValues[i]->getName());
codeReplacer->getInstList().push_back(GEP);
StoreInst *SI = new StoreInst(StructValues[i], GEP);
@@ -406,10 +408,11 @@ emitCallAndSwitchStatement(Function *newFunction, BasicBlock *codeReplacer,
for (unsigned i = 0, e = outputs.size(); i != e; ++i) {
Value *Output = 0;
if (AggregateArgs) {
- Value *Idx0 = Constant::getNullValue(Type::Int32Ty);
- Value *Idx1 = ConstantInt::get(Type::Int32Ty, FirstOut + i);
+ Value *Idx[2];
+ Idx[0] = Constant::getNullValue(Type::Int32Ty);
+ Idx[1] = ConstantInt::get(Type::Int32Ty, FirstOut + i);
GetElementPtrInst *GEP
- = new GetElementPtrInst(Struct, Idx0, Idx1,
+ = new GetElementPtrInst(Struct, Idx, Idx + 2,
"gep_reload_" + outputs[i]->getName());
codeReplacer->getInstList().push_back(GEP);
Output = GEP;
@@ -506,10 +509,11 @@ emitCallAndSwitchStatement(Function *newFunction, BasicBlock *codeReplacer,
if (DominatesDef) {
if (AggregateArgs) {
- Value *Idx0 = Constant::getNullValue(Type::Int32Ty);
- Value *Idx1 = ConstantInt::get(Type::Int32Ty,FirstOut+out);
+ Value *Idx[2];
+ Idx[0] = Constant::getNullValue(Type::Int32Ty);
+ Idx[1] = ConstantInt::get(Type::Int32Ty,FirstOut+out);
GetElementPtrInst *GEP =
- new GetElementPtrInst(OAI, Idx0, Idx1,
+ new GetElementPtrInst(OAI, Idx, Idx + 2,
"gep_" + outputs[out]->getName(),
NTRet);
new StoreInst(outputs[out], GEP, NTRet);
diff --git a/lib/Transforms/Utils/LowerInvoke.cpp b/lib/Transforms/Utils/LowerInvoke.cpp
index ba03635..acb2b52 100644
--- a/lib/Transforms/Utils/LowerInvoke.cpp
+++ b/lib/Transforms/Utils/LowerInvoke.cpp
@@ -450,8 +450,8 @@ bool LowerInvoke::insertExpensiveEHSupport(Function &F) {
std::vector<Value*> Idx;
Idx.push_back(Constant::getNullValue(Type::Int32Ty));
Idx.push_back(ConstantInt::get(Type::Int32Ty, 1));
- OldJmpBufPtr = new GetElementPtrInst(JmpBuf, &Idx[0], 2, "OldBuf",
- EntryBB->getTerminator());
+ OldJmpBufPtr = new GetElementPtrInst(JmpBuf, Idx.begin(), Idx.end(),
+ "OldBuf", EntryBB->getTerminator());
// Copy the JBListHead to the alloca.
Value *OldBuf = new LoadInst(JBListHead, "oldjmpbufptr", true,
@@ -489,7 +489,7 @@ bool LowerInvoke::insertExpensiveEHSupport(Function &F) {
"setjmp.cont");
Idx[1] = ConstantInt::get(Type::Int32Ty, 0);
- Value *JmpBufPtr = new GetElementPtrInst(JmpBuf, &Idx[0], Idx.size(),
+ Value *JmpBufPtr = new GetElementPtrInst(JmpBuf, Idx.begin(), Idx.end(),
"TheJmpBuf",
EntryBB->getTerminator());
Value *SJRet = new CallInst(SetJmpFn, JmpBufPtr, "sjret",
@@ -540,7 +540,8 @@ bool LowerInvoke::insertExpensiveEHSupport(Function &F) {
std::vector<Value*> Idx;
Idx.push_back(Constant::getNullValue(Type::Int32Ty));
Idx.push_back(ConstantInt::get(Type::Int32Ty, 0));
- Idx[0] = new GetElementPtrInst(BufPtr, &Idx[0], 2, "JmpBuf", UnwindBlock);
+ Idx[0] = new GetElementPtrInst(BufPtr, Idx.begin(), Idx.end(), "JmpBuf",
+ UnwindBlock);
Idx[1] = ConstantInt::get(Type::Int32Ty, 1);
new CallInst(LongJmpFn, Idx.begin(), Idx.end(), "", UnwindBlock);
new UnreachableInst(UnwindBlock);