summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp
diff options
context:
space:
mode:
authorEvgeniy Stepanov <eugeni.stepanov@gmail.com>2013-09-03 10:04:11 +0000
committerEvgeniy Stepanov <eugeni.stepanov@gmail.com>2013-09-03 10:04:11 +0000
commit566f591404ee38a19be1e007a4e88776b82a0128 (patch)
treea953da94ca38b3315524b06bc23e409cc7323a3f /llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp
parentd9be5b2fdc22a8edf5b5687fcf7cba584735c7e7 (diff)
downloadbcm5719-llvm-566f591404ee38a19be1e007a4e88776b82a0128.tar.gz
bcm5719-llvm-566f591404ee38a19be1e007a4e88776b82a0128.zip
[msan] Fix select instrumentation.
Select condition shadow was being ignored resulting in false negatives. This change OR-s sign-extended condition shadow into the result shadow. llvm-svn: 189785
Diffstat (limited to 'llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp')
-rw-r--r--llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp9
1 files changed, 6 insertions, 3 deletions
diff --git a/llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp b/llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp
index ae73a2e9c9e..f2cf7a76e54 100644
--- a/llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp
+++ b/llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp
@@ -1743,9 +1743,12 @@ struct MemorySanitizerVisitor : public InstVisitor<MemorySanitizerVisitor> {
void visitSelectInst(SelectInst& I) {
IRBuilder<> IRB(&I);
- setShadow(&I, IRB.CreateSelect(I.getCondition(),
- getShadow(I.getTrueValue()), getShadow(I.getFalseValue()),
- "_msprop"));
+ // a = select b, c, d
+ // Sa = (sext Sb) | (select b, Sc, Sd)
+ Value *S = IRB.CreateSelect(I.getCondition(), getShadow(I.getTrueValue()),
+ getShadow(I.getFalseValue()));
+ Value *S2 = IRB.CreateSExt(getShadow(I.getCondition()), S->getType());
+ setShadow(&I, IRB.CreateOr(S, S2, "_msprop"));
if (MS.TrackOrigins) {
// Origins are always i32, so any vector conditions must be flattened.
// FIXME: consider tracking vector origins for app vectors?
OpenPOWER on IntegriCloud