aboutsummaryrefslogtreecommitdiffstats
path: root/lib/Transforms/Instrumentation
diff options
context:
space:
mode:
authorEvgeniy Stepanov <eugeni.stepanov@gmail.com>2013-09-03 13:05:29 +0000
committerEvgeniy Stepanov <eugeni.stepanov@gmail.com>2013-09-03 13:05:29 +0000
commit69086b2962b16a9e78aea0605202c5ea126049ae (patch)
tree87dfaa7100223b1367a300b44928ea63f24e9e4c /lib/Transforms/Instrumentation
parent6a9b29ec9b42e792732659e510a655449a41b661 (diff)
downloadexternal_llvm-69086b2962b16a9e78aea0605202c5ea126049ae.zip
external_llvm-69086b2962b16a9e78aea0605202c5ea126049ae.tar.gz
external_llvm-69086b2962b16a9e78aea0605202c5ea126049ae.tar.bz2
[msan] Fix handling of select with struct arguments.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@189796 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms/Instrumentation')
-rw-r--r--lib/Transforms/Instrumentation/MemorySanitizer.cpp17
1 files changed, 14 insertions, 3 deletions
diff --git a/lib/Transforms/Instrumentation/MemorySanitizer.cpp b/lib/Transforms/Instrumentation/MemorySanitizer.cpp
index f2cf7a7..e9b78ac 100644
--- a/lib/Transforms/Instrumentation/MemorySanitizer.cpp
+++ b/lib/Transforms/Instrumentation/MemorySanitizer.cpp
@@ -1744,11 +1744,22 @@ struct MemorySanitizerVisitor : public InstVisitor<MemorySanitizerVisitor> {
void visitSelectInst(SelectInst& I) {
IRBuilder<> IRB(&I);
// 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 (I.getType()->isAggregateType()) {
+ // To avoid "sign extending" i1 to an arbitrary aggregate type, we just do
+ // an extra "select". This results in much more compact IR.
+ // Sa = select Sb, poisoned, (select b, Sc, Sd)
+ S = IRB.CreateSelect(getShadow(I.getCondition()),
+ getPoisonedShadow(getShadowTy(I.getType())), S,
+ "_msprop_select_agg");
+ } else {
+ // Sa = (sext Sb) | (select b, Sc, Sd)
+ S = IRB.CreateOr(
+ S, IRB.CreateSExt(getShadow(I.getCondition()), S->getType()),
+ "_msprop_select");
+ }
+ setShadow(&I, S);
if (MS.TrackOrigins) {
// Origins are always i32, so any vector conditions must be flattened.
// FIXME: consider tracking vector origins for app vectors?