[llvm] r189785 - [msan] Fix select instrumentation.
Evgeniy Stepanov
eugeni.stepanov at gmail.com
Tue Sep 3 03:04:11 PDT 2013
Author: eugenis
Date: Tue Sep 3 05:04:11 2013
New Revision: 189785
URL: http://llvm.org/viewvc/llvm-project?rev=189785&view=rev
Log:
[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.
Modified:
llvm/trunk/lib/Transforms/Instrumentation/MemorySanitizer.cpp
llvm/trunk/test/Instrumentation/MemorySanitizer/msan_basic.ll
Modified: llvm/trunk/lib/Transforms/Instrumentation/MemorySanitizer.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Instrumentation/MemorySanitizer.cpp?rev=189785&r1=189784&r2=189785&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Instrumentation/MemorySanitizer.cpp (original)
+++ llvm/trunk/lib/Transforms/Instrumentation/MemorySanitizer.cpp Tue Sep 3 05:04:11 2013
@@ -1743,9 +1743,12 @@ struct MemorySanitizerVisitor : public I
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?
Modified: llvm/trunk/test/Instrumentation/MemorySanitizer/msan_basic.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Instrumentation/MemorySanitizer/msan_basic.ll?rev=189785&r1=189784&r2=189785&view=diff
==============================================================================
--- llvm/trunk/test/Instrumentation/MemorySanitizer/msan_basic.ll (original)
+++ llvm/trunk/test/Instrumentation/MemorySanitizer/msan_basic.ll Tue Sep 3 05:04:11 2013
@@ -260,6 +260,8 @@ entry:
; CHECK: @Select
; CHECK: select
+; CHECK-NEXT: sext i1 {{.*}} to i32
+; CHECK-NEXT: or i32
; CHECK-NEXT: select
; CHECK: ret i32
@@ -274,6 +276,13 @@ entry:
ret <8 x i16> %cond
}
+; CHECK: @SelectVector
+; CHECK: select <8 x i1>
+; CHECK-NEXT: sext <8 x i1> {{.*}} to <8 x i16>
+; CHECK-NEXT: or <8 x i16>
+; CHECK-NEXT: select <8 x i1>
+; CHECK: ret <8 x i16>
+
; CHECK-ORIGINS: @SelectVector
; CHECK-ORIGINS: bitcast <8 x i1> {{.*}} to i8
; CHECK-ORIGINS: icmp ne i8
More information about the llvm-commits
mailing list