summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEvgeniy Stepanov <eugeni.stepanov@gmail.com>2014-07-07 13:28:31 +0000
committerEvgeniy Stepanov <eugeni.stepanov@gmail.com>2014-07-07 13:28:31 +0000
commitd948a5f3c34e7868ce8fec07b0e2d267db351258 (patch)
tree92f69a1351995bd62e541956a3f69d062b51ddb5
parent4acb859fbdad4b5bc9208d3bfaea6847a682e26f (diff)
downloadbcm5719-llvm-d948a5f3c34e7868ce8fec07b0e2d267db351258.tar.gz
bcm5719-llvm-d948a5f3c34e7868ce8fec07b0e2d267db351258.zip
[msan] Fix handling of phi in blacklisted functions.
llvm-svn: 212454
-rw-r--r--llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp7
-rw-r--r--llvm/test/Instrumentation/MemorySanitizer/msan_basic.ll23
2 files changed, 28 insertions, 2 deletions
diff --git a/llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp b/llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp
index 9b595d83f17..496ab4877e0 100644
--- a/llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp
+++ b/llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp
@@ -716,8 +716,6 @@ struct MemorySanitizerVisitor : public InstVisitor<MemorySanitizerVisitor> {
// Finalize PHI nodes.
for (PHINode *PN : ShadowPHINodes) {
- Value *S = getShadow(PN);
- if (isa<Constant>(S)) continue;
PHINode *PNS = cast<PHINode>(getShadow(PN));
PHINode *PNO = MS.TrackOrigins ? cast<PHINode>(getOrigin(PN)) : nullptr;
size_t NumValues = PN->getNumIncomingValues();
@@ -2396,6 +2394,11 @@ struct MemorySanitizerVisitor : public InstVisitor<MemorySanitizerVisitor> {
void visitPHINode(PHINode &I) {
IRBuilder<> IRB(&I);
+ if (!PropagateShadow) {
+ setShadow(&I, getCleanShadow(&I));
+ return;
+ }
+
ShadowPHINodes.push_back(&I);
setShadow(&I, IRB.CreatePHI(getShadowTy(&I), I.getNumIncomingValues(),
"_msphi_s"));
diff --git a/llvm/test/Instrumentation/MemorySanitizer/msan_basic.ll b/llvm/test/Instrumentation/MemorySanitizer/msan_basic.ll
index 5814f787902..51693cdd567 100644
--- a/llvm/test/Instrumentation/MemorySanitizer/msan_basic.ll
+++ b/llvm/test/Instrumentation/MemorySanitizer/msan_basic.ll
@@ -743,6 +743,29 @@ declare i32 @NoSanitizeMemoryUndefHelper(i32 %x)
; CHECK: ret i32
+; Test PHINode instrumentation in blacklisted functions
+
+define i32 @NoSanitizeMemoryPHI(i32 %x) {
+entry:
+ %tobool = icmp ne i32 %x, 0
+ br i1 %tobool, label %cond.true, label %cond.false
+
+cond.true: ; preds = %entry
+ br label %cond.end
+
+cond.false: ; preds = %entry
+ br label %cond.end
+
+cond.end: ; preds = %cond.false, %cond.true
+ %cond = phi i32 [ undef, %cond.true ], [ undef, %cond.false ]
+ ret i32 %cond
+}
+
+; CHECK: [[A:%.*]] = phi i32 [ undef, %cond.true ], [ undef, %cond.false ]
+; CHECK: store i32 0, i32* bitcast {{.*}} @__msan_retval_tls
+; CHECK: ret i32 [[A]]
+
+
; Test argument shadow alignment
define <2 x i64> @ArgumentShadowAlignment(i64 %a, <2 x i64> %b) sanitize_memory {
OpenPOWER on IntegriCloud