diff options
author | Chris Lattner <sabre@nondot.org> | 2004-03-18 04:12:05 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2004-03-18 04:12:05 +0000 |
commit | 04229c192bc153210e8ee8a18eb28d7f1ec21bfe (patch) | |
tree | 6c1aac6f74f9a3afef25119419f33fb21d1547d9 /lib/Transforms/Utils/CodeExtractor.cpp | |
parent | 959754e70c7b3c771d9a0529a75e16c356c0ece9 (diff) |
Fix CodeExtractor/2004-03-17-OutputMismatch.ll
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12486 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms/Utils/CodeExtractor.cpp')
-rw-r--r-- | lib/Transforms/Utils/CodeExtractor.cpp | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/lib/Transforms/Utils/CodeExtractor.cpp b/lib/Transforms/Utils/CodeExtractor.cpp index 59f9876df5..694f06bdc6 100644 --- a/lib/Transforms/Utils/CodeExtractor.cpp +++ b/lib/Transforms/Utils/CodeExtractor.cpp @@ -347,6 +347,10 @@ CodeExtractor::emitCallAndSwitchStatement(Function *newFunction, // just plain inputs for non-scalars std::vector<Value*> params(inputs); + // Get an iterator to the first output argument. + Function::aiterator OutputArgBegin = newFunction->abegin(); + std::advance(OutputArgBegin, inputs.size()); + for (unsigned i = 0, e = outputs.size(); i != e; ++i) { Value *Output = outputs[i]; // Create allocas for scalar outputs @@ -401,12 +405,12 @@ CodeExtractor::emitCallAndSwitchStatement(Function *newFunction, // Restore values just before we exit // FIXME: Use a GetElementPtr to bunch the outputs in a struct - for (unsigned out = 0, e = outputs.size(); out != e; ++out) + Function::aiterator OAI = OutputArgBegin; + for (unsigned out = 0, e = outputs.size(); out != e; ++out, ++OAI) if (!DS || DS->dominates(cast<Instruction>(outputs[out])->getParent(), TI->getParent())) - new StoreInst(outputs[out], getFunctionArg(newFunction, out), - NTRet); + new StoreInst(outputs[out], OAI, NTRet); } // rewrite the original branch instruction with this new target |