brintos

brintos / llvm-project-archived public Read only

0
0
Text · 2.5 KiB · 8210970 Raw
71 lines · plain
1; REQUIRES: x86-registered-target2 3; RUN: opt < %s -S -asan-instrumentation-with-call-threshold=0 -passes=asan -asan-use-stack-safety=0 -o - | FileCheck %s --implicit-check-not="call {{.*}} @__asan_{{load|store|stack}}" --check-prefixes=CHECK,NOSAFETY4; RUN: opt < %s -S -asan-instrumentation-with-call-threshold=0 -passes=asan | FileCheck %s --implicit-check-not="call {{.*}} @__asan_{{load|store|stack}}"5 6; CHECK-LABEL: define i32 @load7define i32 @load() sanitize_address {8  %buf = alloca [10 x i8], align 19  ; NOSAFETY: call i64 @__asan_stack_malloc10  %1 = load i8, ptr %buf, align 111  ; NOSAFETY: call void @__asan_load112  ret i32 013}14 15; CHECK-LABEL: define i32 @store16define i32 @store() sanitize_address {17  %buf = alloca [10 x i8], align 118  ; NOSAFETY: call i64 @__asan_stack_malloc19  store i8 0, ptr %buf20  ; NOSAFETY: call void @__asan_store121  ret i32 022}23 24; CHECK-LABEL: define i32 @unsafe_alloca25define i32 @unsafe_alloca(i32 %i) sanitize_address {26  %buf.sroa.0 = alloca [10 x i8], align 427  ; CHECK: call i64 @__asan_stack_malloc28  %ptr = getelementptr [10 x i8], ptr %buf.sroa.0, i32 %i, i32 029  store volatile i8 0, ptr %ptr, align 430  ; CHECK: call void @__asan_store131  store volatile i8 0, ptr %buf.sroa.0, align 432  ; NOSAFETY: call void @__asan_store133  ret i32 034}35 36; CHECK-LABEL: define void @atomicrmw37define void @atomicrmw() sanitize_address {38  %buf = alloca [10 x i8], align 139  ; NOSAFETY: call i64 @__asan_stack_malloc40  %1 = atomicrmw add ptr %buf, i8 1 seq_cst41  ; NOSAFETY: call void @__asan_store142  ret void43}44 45; CHECK-LABEL: define void @cmpxchg46define void @cmpxchg(i8 %compare_to, i8 %new_value) sanitize_address {47  %buf = alloca [10 x i8], align 148  ; NOSAFETY: call i64 @__asan_stack_malloc49  %1 = cmpxchg ptr %buf, i8 %compare_to, i8 %new_value seq_cst seq_cst50  ; NOSAFETY: call void @__asan_store151  ret void52}53 54%struct.S = type { i32, i32 }55 56; CHECK-LABEL: define %struct.S @exchange(57; NOSAFETY: call i64 @__asan_stack_malloc58; CHECK:    call ptr @__asan_memcpy(59; CHECK:    call ptr @__asan_memcpy(60; NOSAFETY: call void @__asan_loadN(61define %struct.S @exchange(ptr %a, ptr %b) sanitize_address {62entry:63  %tmp = alloca %struct.S, align 464  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %tmp, ptr align 4 %a, i64 8, i1 false)65  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %a, ptr align 4 %b, i64 8, i1 false)66  %ret = load %struct.S, ptr %tmp67  ret %struct.S %ret68}69 70declare void @llvm.memcpy.p0.p0.i64(ptr nocapture, ptr nocapture readonly, i64, i1) nounwind71