diff options
author | Owen Anderson <resistor@mac.com> | 2008-02-25 00:40:41 +0000 |
---|---|---|
committer | Owen Anderson <resistor@mac.com> | 2008-02-25 00:40:41 +0000 |
commit | 40dca46ddbcd20847c5dc7adc079e85717d5895d (patch) | |
tree | 8a74e2e78e1315ab6431bc490cdec7a97776dbc5 /llvm/lib/Transforms/Scalar/GVN.cpp | |
parent | 5329e7e5ed18bddedd02c02701a1560f95c9d66c (diff) | |
download | bcm5719-llvm-40dca46ddbcd20847c5dc7adc079e85717d5895d.tar.gz bcm5719-llvm-40dca46ddbcd20847c5dc7adc079e85717d5895d.zip |
Fix an issue where GVN would try to use an instruction before its definition when performing return slot optimization.
llvm-svn: 47541
Diffstat (limited to 'llvm/lib/Transforms/Scalar/GVN.cpp')
-rw-r--r-- | llvm/lib/Transforms/Scalar/GVN.cpp | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/llvm/lib/Transforms/Scalar/GVN.cpp b/llvm/lib/Transforms/Scalar/GVN.cpp index 5ad9cbbb2f1..650612144ad 100644 --- a/llvm/lib/Transforms/Scalar/GVN.cpp +++ b/llvm/lib/Transforms/Scalar/GVN.cpp @@ -1099,6 +1099,13 @@ bool GVN::performReturnSlotOptzn(MemCpyInst* cpy, CallInst* C, !CS.paramHasAttr(1, ParamAttr::NoAlias | ParamAttr::StructRet)) return false; + // Since we're changing the parameter to the callsite, we need to make sure + // that what would be the new parameter dominates the callsite. + DominatorTree& DT = getAnalysis<DominatorTree>(); + if (Instruction* cpyDestInst = dyn_cast<Instruction>(cpyDest)) + if (!DT.dominates(cpyDestInst, C)) + return false; + // Check that something sneaky is not happening involving casting // return slot types around. if (CS.getArgument(0)->getType() != cpyDest->getType()) |