27 lines · c
1// REQUIRES: aarch64-registered-target2 3// RUN: %clang -fsanitize-trap=undefined -fsanitize=hwaddress,array-bounds -target aarch64-linux-gnu -S -emit-llvm -mllvm -hwasan-use-stack-safety=true -mllvm -hwasan-generate-tags-with-calls -O2 %s -o - | FileCheck %s --check-prefixes=CHECK,SAFETY4// RUN: %clang -fsanitize-trap=undefined -fsanitize=hwaddress,array-bounds -target aarch64-linux-gnu -S -emit-llvm -mllvm -hwasan-use-stack-safety=false -mllvm -hwasan-generate-tags-with-calls -O2 %s -o - | FileCheck %s --check-prefixes=CHECK,NOSAFETY5 6// Make sure that HWAsan does not re-check what has been validated by array-bounds7 8void f(char*);9 10int foo(unsigned int idx) {11 char buf[10];12 f(buf);13 return buf[idx];14 // CHECK-LABEL: {{.*}}foo15 // NOSAFETY: call void @llvm.hwasan.check.memaccess.shortgranules16 // SAFETY-NOT: call void @llvm.hwasan.check.memaccess.shortgranules17}18 19int bar(int idx) {20 char buf[10];21 f(buf);22 return buf[idx];23 // CHECK-LABEL: {{.*}}bar24 // NOSAFETY: call void @llvm.hwasan.check.memaccess.shortgranules25 // SAFETY-NOT: call void @llvm.hwasan.check.memaccess.shortgranules26}27