1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --check-attributes --check-globals all --version 5
2 ; This test checks in the second run, function is not instrumented again.
3 ; RUN: opt < %s -passes=asan,asan -S | FileCheck %s
5 target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
6 target triple = "x86_64-unknown-linux-gnu"
8 ; Function with sanitize_address is instrumented.
9 ; Function Attrs: nounwind uwtable
11 ; CHECK: @___asan_globals_registered = common hidden global i64 0
12 ; CHECK: @__start_asan_globals = extern_weak hidden global i64
13 ; CHECK: @__stop_asan_globals = extern_weak hidden global i64
15 define void @instr_sa(ptr %a) sanitize_address {
16 ; CHECK: Function Attrs: sanitize_address
17 ; CHECK-LABEL: define void @instr_sa(
18 ; CHECK-SAME: ptr [[A:%.*]]) #[[ATTR0:[0-9]+]] {
19 ; CHECK-NEXT: [[ENTRY:.*:]]
20 ; CHECK-NEXT: [[TMP0:%.*]] = ptrtoint ptr [[A]] to i64
21 ; CHECK-NEXT: [[TMP1:%.*]] = lshr i64 [[TMP0]], 3
22 ; CHECK-NEXT: [[TMP2:%.*]] = add i64 [[TMP1]], 2147450880
23 ; CHECK-NEXT: [[TMP3:%.*]] = inttoptr i64 [[TMP2]] to ptr
24 ; CHECK-NEXT: [[TMP4:%.*]] = load i8, ptr [[TMP3]], align 1
25 ; CHECK-NEXT: [[TMP5:%.*]] = icmp ne i8 [[TMP4]], 0
26 ; CHECK-NEXT: br i1 [[TMP5]], label %[[BB6:.*]], label %[[BB12:.*]], !prof [[PROF1:![0-9]+]]
28 ; CHECK-NEXT: [[TMP7:%.*]] = and i64 [[TMP0]], 7
29 ; CHECK-NEXT: [[TMP8:%.*]] = add i64 [[TMP7]], 3
30 ; CHECK-NEXT: [[TMP9:%.*]] = trunc i64 [[TMP8]] to i8
31 ; CHECK-NEXT: [[TMP10:%.*]] = icmp sge i8 [[TMP9]], [[TMP4]]
32 ; CHECK-NEXT: br i1 [[TMP10]], label %[[BB11:.*]], label %[[BB12]]
34 ; CHECK-NEXT: call void @__asan_report_load4(i64 [[TMP0]]) #[[ATTR2:[0-9]+]]
35 ; CHECK-NEXT: unreachable
37 ; CHECK-NEXT: [[TMP1:%.*]] = load i32, ptr [[A]], align 4
38 ; CHECK-NEXT: [[TMP2:%.*]] = add i32 [[TMP1]], 1
39 ; CHECK-NEXT: store i32 [[TMP2]], ptr [[A]], align 4
40 ; CHECK-NEXT: ret void
43 %tmp1 = load i32, ptr %a, align 4
44 %tmp2 = add i32 %tmp1, 1
45 store i32 %tmp2, ptr %a, align 4
49 ; CHECK: attributes #[[ATTR0]] = { sanitize_address }
50 ; CHECK: attributes #[[ATTR1:[0-9]+]] = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
51 ; CHECK: attributes #[[ATTR2]] = { nomerge }
53 ; CHECK: [[META0:![0-9]+]] = !{i32 4, !"nosanitize_address", i32 1}
54 ; CHECK: [[PROF1]] = !{!"branch_weights", i32 1, i32 1048575}