| 1 |
// RUN: %clang_cc1 -triple i386-unknown-unknown -mregparm 4 %s -emit-llvm -o - | FileCheck %s |
| 2 |
// RUN: %clang_cc1 -triple i386-unknown-unknown -fsanitize=array-bounds %s -emit-llvm -o - | FileCheck %s --check-prefix=RUNTIME0 |
| 3 |
// RUN: %clang_cc1 -triple i386-unknown-unknown -mregparm 1 -fsanitize=array-bounds %s -emit-llvm -o - | FileCheck %s --check-prefix=RUNTIME1 |
| 4 |
// RUN: %clang_cc1 -triple i386-unknown-unknown -mregparm 2 -fsanitize=array-bounds %s -emit-llvm -o - | FileCheck %s --check-prefix=RUNTIME2 |
| 5 |
// RUN: %clang_cc1 -triple i386-unknown-unknown -mregparm 3 -fsanitize=array-bounds %s -emit-llvm -o - | FileCheck %s --check-prefix=RUNTIME2 |
| 6 |
|
| 7 |
void f1(int a, int b, int c, int d, |
| 8 |
int e, int f, int g, int h); |
| 9 |
|
| 10 |
void f2(int a, int b) __attribute((regparm(0))); |
| 11 |
|
| 12 |
void f0(void) { |
| 13 |
// CHECK: call void @f1(i32 inreg noundef 1, i32 inreg noundef 2, i32 inreg noundef 3, i32 inreg noundef 4, |
| 14 |
// CHECK: i32 noundef 5, i32 noundef 6, i32 noundef 7, i32 noundef 8) |
| 15 |
f1(1, 2, 3, 4, 5, 6, 7, 8); |
| 16 |
// CHECK: call void @f2(i32 noundef 1, i32 noundef 2) |
| 17 |
f2(1, 2); |
| 18 |
} |
| 19 |
|
| 20 |
struct has_array { |
| 21 |
int a; |
| 22 |
int b[4]; |
| 23 |
int c; |
| 24 |
}; |
| 25 |
|
| 26 |
int access(struct has_array *p, int index) |
| 27 |
{ |
| 28 |
return p->b[index]; |
| 29 |
} |
| 30 |
|
| 31 |
// CHECK: declare void @f1(i32 inreg noundef, i32 inreg noundef, i32 inreg noundef, i32 inreg noundef, |
| 32 |
// CHECK: i32 noundef, i32 noundef, i32 noundef, i32 noundef) |
| 33 |
// CHECK: declare void @f2(i32 noundef, i32 noundef) |
| 34 |
|
| 35 |
// RUNTIME0: declare void @__ubsan_handle_out_of_bounds_abort(ptr, i32) |
| 36 |
// RUNTIME1: declare void @__ubsan_handle_out_of_bounds_abort(ptr inreg, i32) |
| 37 |
// RUNTIME2: declare void @__ubsan_handle_out_of_bounds_abort(ptr inreg, i32 inreg) |