1 ; Test basic address sanitizer instrumentation. 2 ; 3 ; RUN: opt -asan -asan-module -S < %s | FileCheck %s 4 5 target triple = "x86_64-pc-windows-msvc" 6 ; CHECK: @llvm.global_ctors = {{.*}}@asan.module_ctor 7 8 define i32 @test_load(i32* %a) sanitize_address { 9 ; First instrumentation in the function must be to load the dynamic shadow 10 ; address into a local variable. 11 ; CHECK-LABEL: @test_load 12 ; CHECK: entry: 13 ; CHECK-NEXT: %[[SHADOW:[^ ]*]] = load i64, i64* @__asan_shadow_memory_dynamic_address 14 15 ; Shadow address is loaded and added into the whole offset computation. 16 ; CHECK add i64 %{{.*}}, %[[SHADOW] ] 17 18 entry: 19 %tmp1 = load i32, i32* %a, align 4 20 ret i32 %tmp1 21 } 22 23 define i32 @__asan_options(i32* %a) sanitize_address { 24 ; Asan functions are not instrumented. Asan function may be called by 25 ; __asan_init before the shadow initialisation, which may lead to incorrect 26 ; behavior of the instrumented code. 27 ; CHECK-LABEL: @__asan_options 28 ; CHECK: entry: 29 ; CHECK-NEXT: %tmp1 = load i32, i32* %a, align 4 30 ; CHECK-NEXT: ret i32 %tmp1 31 32 entry: 33 %tmp1 = load i32, i32* %a, align 4 34 ret i32 %tmp1 35 } 36