[llvm] r195349 - [msan] Propagate condition origin in select instruction.
Evgeniy Stepanov
eugeni.stepanov at gmail.com
Thu Nov 21 04:00:24 PST 2013
Author: eugenis
Date: Thu Nov 21 06:00:24 2013
New Revision: 195349
URL: http://llvm.org/viewvc/llvm-project?rev=195349&view=rev
Log:
[msan] Propagate condition origin in select instruction.
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=195349&r1=195348&r2=195349&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Instrumentation/MemorySanitizer.cpp (original)
+++ llvm/trunk/lib/Transforms/Instrumentation/MemorySanitizer.cpp Thu Nov 21 06:00:24 2013
@@ -2082,13 +2082,20 @@ struct MemorySanitizerVisitor : public I
// Origins are always i32, so any vector conditions must be flattened.
// FIXME: consider tracking vector origins for app vectors?
Value *Cond = I.getCondition();
+ Value *CondShadow = getShadow(Cond);
if (Cond->getType()->isVectorTy()) {
- Value *ConvertedShadow = convertToShadowTyNoVec(Cond, IRB);
- Cond = IRB.CreateICmpNE(ConvertedShadow,
- getCleanShadow(ConvertedShadow), "_mso_select");
+ Type *FlatTy = getShadowTyNoVec(Cond->getType());
+ Cond = IRB.CreateICmpNE(IRB.CreateBitCast(Cond, FlatTy),
+ ConstantInt::getNullValue(FlatTy));
+ CondShadow = IRB.CreateICmpNE(IRB.CreateBitCast(CondShadow, FlatTy),
+ ConstantInt::getNullValue(FlatTy));
}
- setOrigin(&I, IRB.CreateSelect(Cond,
- getOrigin(I.getTrueValue()), getOrigin(I.getFalseValue())));
+ // a = select b, c, d
+ // Oa = Sb ? Ob : (b ? Oc : Od)
+ setOrigin(&I, IRB.CreateSelect(
+ CondShadow, getOrigin(I.getCondition()),
+ IRB.CreateSelect(Cond, getOrigin(I.getTrueValue()),
+ getOrigin(I.getFalseValue()))));
}
}
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=195349&r1=195348&r2=195349&view=diff
==============================================================================
--- llvm/trunk/test/Instrumentation/MemorySanitizer/msan_basic.ll (original)
+++ llvm/trunk/test/Instrumentation/MemorySanitizer/msan_basic.ll Thu Nov 21 06:00:24 2013
@@ -255,6 +255,7 @@ entry:
; CHECK-NEXT: select
; CHECK-ORIGINS: select
; CHECK-ORIGINS: select
+; CHECK: select
; CHECK: ret i32
@@ -274,6 +275,9 @@ entry:
; CHECK-NEXT: or <8 x i16>
; CHECK-ORIGINS: bitcast <8 x i1> {{.*}} to i8
; CHECK-ORIGINS: icmp ne i8 {{.*}}, 0
+; CHECK-ORIGINS: bitcast <8 x i1> {{.*}} to i8
+; CHECK-ORIGINS: icmp ne i8 {{.*}}, 0
+; CHECK-ORIGINS: select i1
; CHECK-ORIGINS: select i1
; CHECK: select <8 x i1>
; CHECK: ret <8 x i16>
@@ -295,6 +299,8 @@ entry:
; CHECK: sext i1 {{.*}} to i128
; CHECK: bitcast i128 {{.*}} to <8 x i16>
; CHECK: or <8 x i16>
+; CHECK-ORIGINS: select i1
+; CHECK-ORIGINS: select i1
; CHECK: select i1
; CHECK: ret <8 x i16>
@@ -309,6 +315,7 @@ entry:
; CHECK: select i1 {{.*}}, { i64, i64 }
; CHECK-NEXT: select i1 {{.*}}, { i64, i64 } { i64 -1, i64 -1 }, { i64, i64 }
; CHECK-ORIGINS: select i1
+; CHECK-ORIGINS: select i1
; CHECK-NEXT: select i1 {{.*}}, { i64, i64 }
; CHECK: ret { i64, i64 }
More information about the llvm-commits
mailing list