xref: /llvm-project/llvm/test/Instrumentation/MemorySanitizer/disambiguate-origin.ll (revision 21c3df4b858476bbc9b2b5af96cfef41f5715715)
11cf5c7feSVitaly Buka; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
21cf5c7feSVitaly Buka; RUN: opt < %s -msan-track-origins=2 -msan-eager-checks=1 -S -passes=msan 2>&1 | FileCheck %s --implicit-check-not="call void @__msan_"
31cf5c7feSVitaly Buka
41cf5c7feSVitaly Bukatarget datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64-S128"
51cf5c7feSVitaly Bukatarget triple = "x86_64-unknown-linux-gnu"
61cf5c7feSVitaly Buka
71cf5c7feSVitaly Buka!llvm.module.flags = !{!0}
81cf5c7feSVitaly Buka
91cf5c7feSVitaly Buka!0 = !{i32 2, !"Debug Info Version", i32 3}
101cf5c7feSVitaly Buka!2 = distinct !DISubprogram(name: "t", scope: !3, file: !3, line: 4, type: !4, spFlags: DISPFlagDefinition, unit: !6)
111cf5c7feSVitaly Buka!3 = !DIFile(filename: "tmp/noundef.cpp", directory: "/")
121cf5c7feSVitaly Buka!4 = !DISubroutineType(types: !5)
131cf5c7feSVitaly Buka!5 = !{}
141cf5c7feSVitaly Buka!6 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus_14, file: !3, isOptimized: false, runtimeVersion: 0, emissionKind: NoDebug)
151cf5c7feSVitaly Buka!10 = !DILocation(line: 9, column: 0, scope: !2)
161cf5c7feSVitaly Buka!11 = !DILocation(line: 9, column: 1, scope: !2)
171cf5c7feSVitaly Buka!12 = !DILocation(line: 9, column: 2, scope: !2)
181cf5c7feSVitaly Buka!13 = !DILocation(line: 9, column: 3, scope: !2)
191cf5c7feSVitaly Buka
201cf5c7feSVitaly Bukadeclare void @OneArg(i32 noundef %a) nounwind uwtable sanitize_memory;
211cf5c7feSVitaly Bukadeclare void @ManyArgs(i32 noundef %a, i32 noundef %b, i32 noundef %c) nounwind uwtable sanitize_memory;
221cf5c7feSVitaly Buka
23*21c3df4bSMatt Arsenaultdefine void @TestOne(ptr noundef %a)  nounwind uwtable sanitize_memory {
241cf5c7feSVitaly Buka; CHECK-LABEL: @TestOne(
251cf5c7feSVitaly Buka; CHECK-NEXT:  entry:
261cf5c7feSVitaly Buka; CHECK-NEXT:    call void @llvm.donothing(), !dbg [[DBG1:![0-9]+]]
27*21c3df4bSMatt Arsenault; CHECK-NEXT:    [[V:%.*]] = load i32, ptr [[A:%.*]], align 4, !dbg [[DBG1]]
28*21c3df4bSMatt Arsenault; CHECK-NEXT:    [[TMP0:%.*]] = ptrtoint ptr [[A]] to i64, !dbg [[DBG1]]
29a38e5a4bSVitaly Buka; CHECK-NEXT:    [[TMP1:%.*]] = xor i64 [[TMP0]], 87960930222080, !dbg [[DBG1]]
30*21c3df4bSMatt Arsenault; CHECK-NEXT:    [[TMP2:%.*]] = inttoptr i64 [[TMP1]] to ptr, !dbg [[DBG1]]
31a38e5a4bSVitaly Buka; CHECK-NEXT:    [[TMP3:%.*]] = add i64 [[TMP1]], 17592186044416, !dbg [[DBG1]]
32*21c3df4bSMatt Arsenault; CHECK-NEXT:    [[TMP4:%.*]] = inttoptr i64 [[TMP3]] to ptr, !dbg [[DBG1]]
33*21c3df4bSMatt Arsenault; CHECK-NEXT:    [[_MSLD:%.*]] = load i32, ptr [[TMP2]], align 4, !dbg [[DBG1]]
34*21c3df4bSMatt Arsenault; CHECK-NEXT:    [[TMP5:%.*]] = load i32, ptr [[TMP4]], align 4, !dbg [[DBG1]]
35a38e5a4bSVitaly Buka; CHECK-NEXT:    [[_MSCMP:%.*]] = icmp ne i32 [[_MSLD]], 0, !dbg [[DBG7:![0-9]+]]
36a38e5a4bSVitaly Buka; CHECK-NEXT:    br i1 [[_MSCMP]], label [[TMP6:%.*]], label [[TMP7:%.*]], !dbg [[DBG7]], !prof [[PROF8:![0-9]+]]
37a38e5a4bSVitaly Buka; CHECK:       6:
38a38e5a4bSVitaly Buka; CHECK-NEXT:    call void @__msan_warning_with_origin_noreturn(i32 [[TMP5]]) #[[ATTR3:[0-9]+]], !dbg [[DBG7]]
39a38e5a4bSVitaly Buka; CHECK-NEXT:    unreachable, !dbg [[DBG7]]
40a38e5a4bSVitaly Buka; CHECK:       7:
41a38e5a4bSVitaly Buka; CHECK-NEXT:    call void @OneArg(i32 noundef [[V]]), !dbg [[DBG7]]
42a38e5a4bSVitaly Buka; CHECK-NEXT:    ret void
431cf5c7feSVitaly Buka;
441cf5c7feSVitaly Bukaentry:
45*21c3df4bSMatt Arsenault  %v = load i32, ptr %a, !dbg !11
461cf5c7feSVitaly Buka  call void @OneArg(i32 noundef %v), !dbg !10
471cf5c7feSVitaly Buka  ret void
481cf5c7feSVitaly Buka}
491cf5c7feSVitaly Buka
50*21c3df4bSMatt Arsenaultdefine void @TestMany(ptr noundef %a)  nounwind uwtable sanitize_memory {
511cf5c7feSVitaly Buka; CHECK-LABEL: @TestMany(
521cf5c7feSVitaly Buka; CHECK-NEXT:  entry:
531cf5c7feSVitaly Buka; CHECK-NEXT:    call void @llvm.donothing(), !dbg [[DBG1]]
54*21c3df4bSMatt Arsenault; CHECK-NEXT:    [[X:%.*]] = load i32, ptr [[A:%.*]], align 4, !dbg [[DBG1]]
55*21c3df4bSMatt Arsenault; CHECK-NEXT:    [[TMP0:%.*]] = ptrtoint ptr [[A]] to i64, !dbg [[DBG1]]
56a38e5a4bSVitaly Buka; CHECK-NEXT:    [[TMP1:%.*]] = xor i64 [[TMP0]], 87960930222080, !dbg [[DBG1]]
57*21c3df4bSMatt Arsenault; CHECK-NEXT:    [[TMP2:%.*]] = inttoptr i64 [[TMP1]] to ptr, !dbg [[DBG1]]
58a38e5a4bSVitaly Buka; CHECK-NEXT:    [[TMP3:%.*]] = add i64 [[TMP1]], 17592186044416, !dbg [[DBG1]]
59*21c3df4bSMatt Arsenault; CHECK-NEXT:    [[TMP4:%.*]] = inttoptr i64 [[TMP3]] to ptr, !dbg [[DBG1]]
60*21c3df4bSMatt Arsenault; CHECK-NEXT:    [[_MSLD:%.*]] = load i32, ptr [[TMP2]], align 4, !dbg [[DBG1]]
61*21c3df4bSMatt Arsenault; CHECK-NEXT:    [[TMP5:%.*]] = load i32, ptr [[TMP4]], align 4, !dbg [[DBG1]]
62*21c3df4bSMatt Arsenault; CHECK-NEXT:    [[Y:%.*]] = load i32, ptr [[A]], align 4, !dbg [[DBG9:![0-9]+]]
63*21c3df4bSMatt Arsenault; CHECK-NEXT:    [[TMP6:%.*]] = ptrtoint ptr [[A]] to i64, !dbg [[DBG9]]
64a38e5a4bSVitaly Buka; CHECK-NEXT:    [[TMP7:%.*]] = xor i64 [[TMP6]], 87960930222080, !dbg [[DBG9]]
65*21c3df4bSMatt Arsenault; CHECK-NEXT:    [[TMP8:%.*]] = inttoptr i64 [[TMP7]] to ptr, !dbg [[DBG9]]
66a38e5a4bSVitaly Buka; CHECK-NEXT:    [[TMP9:%.*]] = add i64 [[TMP7]], 17592186044416, !dbg [[DBG9]]
67*21c3df4bSMatt Arsenault; CHECK-NEXT:    [[TMP10:%.*]] = inttoptr i64 [[TMP9]] to ptr, !dbg [[DBG9]]
68*21c3df4bSMatt Arsenault; CHECK-NEXT:    [[_MSLD1:%.*]] = load i32, ptr [[TMP8]], align 4, !dbg [[DBG9]]
69*21c3df4bSMatt Arsenault; CHECK-NEXT:    [[TMP11:%.*]] = load i32, ptr [[TMP10]], align 4, !dbg [[DBG9]]
70*21c3df4bSMatt Arsenault; CHECK-NEXT:    [[Z:%.*]] = load i32, ptr [[A]], align 4, !dbg [[DBG10:![0-9]+]]
71*21c3df4bSMatt Arsenault; CHECK-NEXT:    [[TMP12:%.*]] = ptrtoint ptr [[A]] to i64, !dbg [[DBG10]]
72a38e5a4bSVitaly Buka; CHECK-NEXT:    [[TMP13:%.*]] = xor i64 [[TMP12]], 87960930222080, !dbg [[DBG10]]
73*21c3df4bSMatt Arsenault; CHECK-NEXT:    [[TMP14:%.*]] = inttoptr i64 [[TMP13]] to ptr, !dbg [[DBG10]]
74a38e5a4bSVitaly Buka; CHECK-NEXT:    [[TMP15:%.*]] = add i64 [[TMP13]], 17592186044416, !dbg [[DBG10]]
75*21c3df4bSMatt Arsenault; CHECK-NEXT:    [[TMP16:%.*]] = inttoptr i64 [[TMP15]] to ptr, !dbg [[DBG10]]
76*21c3df4bSMatt Arsenault; CHECK-NEXT:    [[_MSLD2:%.*]] = load i32, ptr [[TMP14]], align 4, !dbg [[DBG10]]
77*21c3df4bSMatt Arsenault; CHECK-NEXT:    [[TMP17:%.*]] = load i32, ptr [[TMP16]], align 4, !dbg [[DBG10]]
78a38e5a4bSVitaly Buka; CHECK-NEXT:    [[_MSCMP:%.*]] = icmp ne i32 [[_MSLD]], 0, !dbg [[DBG7]]
79a38e5a4bSVitaly Buka; CHECK-NEXT:    br i1 [[_MSCMP]], label [[TMP18:%.*]], label [[TMP20:%.*]], !dbg [[DBG7]], !prof [[PROF8]]
80a38e5a4bSVitaly Buka; CHECK:       18:
81a38e5a4bSVitaly Buka; CHECK-NEXT:    [[TMP19:%.*]] = call i32 @__msan_chain_origin(i32 [[TMP5]]), !dbg [[DBG1]]
82a38e5a4bSVitaly Buka; CHECK-NEXT:    call void @__msan_warning_with_origin_noreturn(i32 [[TMP19]]) #[[ATTR3]], !dbg [[DBG7]]
83a38e5a4bSVitaly Buka; CHECK-NEXT:    unreachable, !dbg [[DBG7]]
84a38e5a4bSVitaly Buka; CHECK:       20:
85a38e5a4bSVitaly Buka; CHECK-NEXT:    [[_MSCMP3:%.*]] = icmp ne i32 [[_MSLD1]], 0, !dbg [[DBG7]]
86a38e5a4bSVitaly Buka; CHECK-NEXT:    br i1 [[_MSCMP3]], label [[TMP21:%.*]], label [[TMP23:%.*]], !dbg [[DBG7]], !prof [[PROF8]]
87a38e5a4bSVitaly Buka; CHECK:       21:
88a38e5a4bSVitaly Buka; CHECK-NEXT:    [[TMP22:%.*]] = call i32 @__msan_chain_origin(i32 [[TMP11]]), !dbg [[DBG9]]
89a38e5a4bSVitaly Buka; CHECK-NEXT:    call void @__msan_warning_with_origin_noreturn(i32 [[TMP22]]) #[[ATTR3]], !dbg [[DBG7]]
90a38e5a4bSVitaly Buka; CHECK-NEXT:    unreachable, !dbg [[DBG7]]
91a38e5a4bSVitaly Buka; CHECK:       23:
92a38e5a4bSVitaly Buka; CHECK-NEXT:    [[_MSCMP4:%.*]] = icmp ne i32 [[_MSLD2]], 0, !dbg [[DBG7]]
93a38e5a4bSVitaly Buka; CHECK-NEXT:    br i1 [[_MSCMP4]], label [[TMP24:%.*]], label [[TMP26:%.*]], !dbg [[DBG7]], !prof [[PROF8]]
94a38e5a4bSVitaly Buka; CHECK:       24:
95a38e5a4bSVitaly Buka; CHECK-NEXT:    [[TMP25:%.*]] = call i32 @__msan_chain_origin(i32 [[TMP17]]), !dbg [[DBG10]]
96a38e5a4bSVitaly Buka; CHECK-NEXT:    call void @__msan_warning_with_origin_noreturn(i32 [[TMP25]]) #[[ATTR3]], !dbg [[DBG7]]
97a38e5a4bSVitaly Buka; CHECK-NEXT:    unreachable, !dbg [[DBG7]]
98a38e5a4bSVitaly Buka; CHECK:       26:
99a38e5a4bSVitaly Buka; CHECK-NEXT:    call void @ManyArgs(i32 noundef [[X]], i32 noundef [[Y]], i32 noundef [[Z]]), !dbg [[DBG7]]
100a38e5a4bSVitaly Buka; CHECK-NEXT:    ret void
1011cf5c7feSVitaly Buka;
1021cf5c7feSVitaly Bukaentry:
103*21c3df4bSMatt Arsenault  %x = load i32, ptr %a, !dbg !11
104*21c3df4bSMatt Arsenault  %y = load i32, ptr %a, !dbg !12
105*21c3df4bSMatt Arsenault  %z = load i32, ptr %a, !dbg !13
1061cf5c7feSVitaly Buka  call void @ManyArgs(i32 noundef %x, i32 noundef %y, i32 noundef %z), !dbg !10
1071cf5c7feSVitaly Buka  ret void
1081cf5c7feSVitaly Buka}
1091cf5c7feSVitaly Buka
1101cf5c7feSVitaly Buka; CHECK-LABEL: define internal void @msan.module_ctor()
1111cf5c7feSVitaly Buka; CHECK:         call void @__msan_init()
112