summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms
diff options
context:
space:
mode:
authorReid Kleckner <reid@kleckner.net>2014-08-12 00:12:43 +0000
committerReid Kleckner <reid@kleckner.net>2014-08-12 00:12:43 +0000
commit3ae6e1528a29a0c717d2f2c6a63e9dcb67731cd7 (patch)
tree641dea30c8c0278721461fb2288e247035028540 /llvm/lib/Transforms
parent981a64c380bea01b35d3426e194c8f8f5f7ec709 (diff)
downloadbcm5719-llvm-3ae6e1528a29a0c717d2f2c6a63e9dcb67731cd7.tar.gz
bcm5719-llvm-3ae6e1528a29a0c717d2f2c6a63e9dcb67731cd7.zip
msan: Handle musttail calls
First, avoid calling setTailCall(false) on musttail calls. The funciton prototypes should be "congruent", so the shadow layout should be exactly the same. Second, avoid inserting instrumentation after a musttail call to propagate the return value shadow. We don't need to propagate the result of a tail call, it should already be in the right place. Reviewed By: eugenis Differential Revision: http://reviews.llvm.org/D4331 llvm-svn: 215415
Diffstat (limited to 'llvm/lib/Transforms')
-rw-r--r--llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp10
1 files changed, 10 insertions, 0 deletions
diff --git a/llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp b/llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp
index 3df1d157412..643faacc700 100644
--- a/llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp
+++ b/llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp
@@ -2356,6 +2356,12 @@ struct MemorySanitizerVisitor : public InstVisitor<MemorySanitizerVisitor> {
VAHelper->visitCallSite(CS, IRB);
}
+ // If this is a musttail call site, we can't insert propagation code here.
+ // The return type of the caller must match the callee, so the shadow should
+ // already be set up for an immediate return.
+ if (CS.isMustTailCall())
+ return;
+
// Now, get the shadow for the RetVal.
if (!I.getType()->isSized()) return;
IRBuilder<> IRBBefore(&I);
@@ -2389,6 +2395,10 @@ struct MemorySanitizerVisitor : public InstVisitor<MemorySanitizerVisitor> {
}
void visitReturnInst(ReturnInst &I) {
+ // Don't propagate shadow between musttail calls and the return.
+ if (I.getParent()->getTerminatingMustTailCall())
+ return;
+
IRBuilder<> IRB(&I);
Value *RetVal = I.getReturnValue();
if (!RetVal) return;
OpenPOWER on IntegriCloud