summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms/Scalar
diff options
context:
space:
mode:
authorDale Johannesen <dalej@apple.com>2010-09-16 18:30:55 +0000
committerDale Johannesen <dalej@apple.com>2010-09-16 18:30:55 +0000
commitf95f59a0c295771928bafba0fe72f24aa3683d73 (patch)
treee175f3f829f01e0714d4beea5b6a4dad1df2cb45 /llvm/lib/Transforms/Scalar
parent140296f5c02a35b1812abb5d868eecbd198e29a2 (diff)
downloadbcm5719-llvm-f95f59a0c295771928bafba0fe72f24aa3683d73.tar.gz
bcm5719-llvm-f95f59a0c295771928bafba0fe72f24aa3683d73.zip
When substituting sunkaddrs into indirect arguments an asm, we were
walking the asm arguments once and stashing their Values. This is wrong because the same memory location can be in the list twice, and if the first one has a sunkaddr substituted, the stashed value for the second one will be wrong (use-after-free). PR 8154. llvm-svn: 114104
Diffstat (limited to 'llvm/lib/Transforms/Scalar')
-rw-r--r--llvm/lib/Transforms/Scalar/CodeGenPrepare.cpp6
1 files changed, 4 insertions, 2 deletions
diff --git a/llvm/lib/Transforms/Scalar/CodeGenPrepare.cpp b/llvm/lib/Transforms/Scalar/CodeGenPrepare.cpp
index 02282820fc9..437de38131c 100644
--- a/llvm/lib/Transforms/Scalar/CodeGenPrepare.cpp
+++ b/llvm/lib/Transforms/Scalar/CodeGenPrepare.cpp
@@ -738,6 +738,7 @@ bool CodeGenPrepare::OptimizeInlineAsmInst(Instruction *I, CallSite CS,
bool MadeChange = false;
std::vector<TargetLowering::AsmOperandInfo> TargetConstraints = TLI->ParseConstraints(CS);
+ unsigned ArgNo = 0;
for (unsigned i = 0, e = TargetConstraints.size(); i != e; ++i) {
TargetLowering::AsmOperandInfo &OpInfo = TargetConstraints[i];
@@ -746,9 +747,10 @@ bool CodeGenPrepare::OptimizeInlineAsmInst(Instruction *I, CallSite CS,
if (OpInfo.ConstraintType == TargetLowering::C_Memory &&
OpInfo.isIndirect) {
- Value *OpVal = OpInfo.CallOperandVal;
+ Value *OpVal = const_cast<Value *>(CS.getArgument(ArgNo++));
MadeChange |= OptimizeMemoryInst(I, OpVal, OpVal->getType(), SunkAddrs);
- }
+ } else if (OpInfo.Type == InlineAsm::isInput)
+ ArgNo++;
}
return MadeChange;
OpenPOWER on IntegriCloud