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 | 0f7ea1ab106ffb3c8e23a87c0687f85132d93ca1 (patch) | |
tree | ab14394d9e8ef2f822a17cec1e7b5757aa7a3e11 /lib/Transforms | |
parent | 14fd63cae875b8e41c70f4408b2185abf82d1d60 (diff) |
Fix an issue where GVN would try to use an instruction before its definition when performing return slot optimization.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@47541 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms')
-rw-r--r-- | lib/Transforms/Scalar/GVN.cpp | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/lib/Transforms/Scalar/GVN.cpp b/lib/Transforms/Scalar/GVN.cpp index 5ad9cbbb2f..650612144a 100644 --- a/lib/Transforms/Scalar/GVN.cpp +++ b/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()) |