From 4590b8c090dade63d6cb1ba39109331607036f4d Mon Sep 17 00:00:00 2001 From: Evgeniy Stepanov Date: Mon, 11 Nov 2013 13:37:10 +0000 Subject: [PATCH] [msan] Propagate origin for insertvalue, extractvalue. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@194374 91177308-0d34-0410-b5e6-96231b3b80d8 --- .../Instrumentation/MemorySanitizer.cpp | 4 +-- .../MemorySanitizer/msan_basic.ll | 26 +++++++++++++++++++ 2 files changed, 28 insertions(+), 2 deletions(-) diff --git a/lib/Transforms/Instrumentation/MemorySanitizer.cpp b/lib/Transforms/Instrumentation/MemorySanitizer.cpp index 5ce88a9d895..512b8092afb 100644 --- a/lib/Transforms/Instrumentation/MemorySanitizer.cpp +++ b/lib/Transforms/Instrumentation/MemorySanitizer.cpp @@ -2059,7 +2059,7 @@ struct MemorySanitizerVisitor : public InstVisitor { Value *ResShadow = IRB.CreateExtractValue(AggShadow, I.getIndices()); DEBUG(dbgs() << " ResShadow: " << *ResShadow << "\n"); setShadow(&I, ResShadow); - setOrigin(&I, getCleanOrigin()); + setOriginForNaryOp(I); } void visitInsertValueInst(InsertValueInst &I) { @@ -2072,7 +2072,7 @@ struct MemorySanitizerVisitor : public InstVisitor { Value *Res = IRB.CreateInsertValue(AggShadow, InsShadow, I.getIndices()); DEBUG(dbgs() << " Res: " << *Res << "\n"); setShadow(&I, Res); - setOrigin(&I, getCleanOrigin()); + setOriginForNaryOp(I); } void dumpInst(Instruction &I) { diff --git a/test/Instrumentation/MemorySanitizer/msan_basic.ll b/test/Instrumentation/MemorySanitizer/msan_basic.ll index ad9c5d7df3d..72a992dd590 100644 --- a/test/Instrumentation/MemorySanitizer/msan_basic.ll +++ b/test/Instrumentation/MemorySanitizer/msan_basic.ll @@ -775,3 +775,29 @@ entry: ; CHECK-AA: call void @llvm.memcpy.p0i8.p0i8.i64(i8* {{.*}}, i8* {{.*}}, i64 2, i32 2, i1 false) ; CHECK-AA: ret i16 + +; Test origin propagation for insertvalue + +define { i64, i32 } @make_pair_64_32(i64 %x, i32 %y) sanitize_memory { +entry: + %a = insertvalue { i64, i32 } undef, i64 %x, 0 + %b = insertvalue { i64, i32 } %a, i32 %y, 1 + ret { i64, i32 } %b +} + +; CHECK-ORIGINS: @make_pair_64_32 +; First element shadow +; CHECK-ORIGINS: insertvalue { i64, i32 } { i64 -1, i32 -1 }, i64 {{.*}}, 0 +; First element origin +; CHECK-ORIGINS: icmp ne i64 +; CHECK-ORIGINS: select i1 +; First element app value +; CHECK-ORIGINS: insertvalue { i64, i32 } undef, i64 {{.*}}, 0 +; Second element shadow +; CHECK-ORIGINS: insertvalue { i64, i32 } {{.*}}, i32 {{.*}}, 1 +; Second element origin +; CHECK-ORIGINS: icmp ne i32 +; CHECK-ORIGINS: select i1 +; Second element app value +; CHECK-ORIGINS: insertvalue { i64, i32 } {{.*}}, i32 {{.*}}, 1 +; CHECK-ORIGINS: ret { i64, i32 }