diff options
author | Evgeniy Stepanov <eugeni.stepanov@gmail.com> | 2013-09-03 10:04:11 +0000 |
---|---|---|
committer | Evgeniy Stepanov <eugeni.stepanov@gmail.com> | 2013-09-03 10:04:11 +0000 |
commit | 6a9b29ec9b42e792732659e510a655449a41b661 (patch) | |
tree | 60a3a3a27a3ad139999b51dce96eb521c2cd417a /lib | |
parent | fdb6a38913cc54e9523b1ee1aab2cc3be27ea4f7 (diff) | |
download | external_llvm-6a9b29ec9b42e792732659e510a655449a41b661.zip external_llvm-6a9b29ec9b42e792732659e510a655449a41b661.tar.gz external_llvm-6a9b29ec9b42e792732659e510a655449a41b661.tar.bz2 |
[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.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@189785 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r-- | lib/Transforms/Instrumentation/MemorySanitizer.cpp | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/lib/Transforms/Instrumentation/MemorySanitizer.cpp b/lib/Transforms/Instrumentation/MemorySanitizer.cpp index ae73a2e..f2cf7a7 100644 --- a/lib/Transforms/Instrumentation/MemorySanitizer.cpp +++ b/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? |