Skip to content

Commit 210ecfd

Browse files
authored
[NFC] test interaction between array-bounds and hwaddress (#128218)
we want the stack safety analysis to be able to skip array accesses that are already checked by array-bounds.
1 parent 3fad640 commit 210ecfd

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
// REQUIRES: aarch64-registered-target
2+
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,SAFETY
4+
// 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,NOSAFETY
5+
6+
// Make sure that HWAsan does not re-check what has been validated by array-bounds
7+
8+
void f(char*);
9+
10+
int foo(unsigned int idx) {
11+
char buf[10];
12+
f(buf);
13+
return buf[idx];
14+
// CHECK-LABEL: {{.*}}foo
15+
// NOSAFETY: call void @llvm.hwasan.check.memaccess.shortgranules
16+
// SAFETY-NOT: call void @llvm.hwasan.check.memaccess.shortgranules
17+
}
18+
19+
int bar(int idx) {
20+
char buf[10];
21+
f(buf);
22+
return buf[idx];
23+
// CHECK-LABEL: {{.*}}bar
24+
// NOSAFETY: call void @llvm.hwasan.check.memaccess.shortgranules
25+
// SAFETY-NOT: call void @llvm.hwasan.check.memaccess.shortgranules
26+
}

0 commit comments

Comments
 (0)