summaryrefslogtreecommitdiffstats
path: root/clang/test/CodeGen/catch-undef-behavior.c
diff options
context:
space:
mode:
authorRichard Smith <richard-llvm@metafoo.co.uk>2012-11-01 07:22:08 +0000
committerRichard Smith <richard-llvm@metafoo.co.uk>2012-11-01 07:22:08 +0000
commit2d8b294b3c49628b22d0607ea98c42964f597415 (patch)
tree329610eae7761df0fbcb8045805f4369d3f97fd7 /clang/test/CodeGen/catch-undef-behavior.c
parentc89e75e93e24613fe95a72df4007dff5b97a1beb (diff)
downloadbcm5719-llvm-2d8b294b3c49628b22d0607ea98c42964f597415.tar.gz
bcm5719-llvm-2d8b294b3c49628b22d0607ea98c42964f597415.zip
-fcatch-undefined-behavior: Start checking loads and stores for null pointers.
We want the diagnostic, and if the load is optimized away, we still want to trap it. Stop checking non-default address spaces; that doesn't work in general. llvm-svn: 167219
Diffstat (limited to 'clang/test/CodeGen/catch-undef-behavior.c')
-rw-r--r--clang/test/CodeGen/catch-undef-behavior.c16
1 files changed, 13 insertions, 3 deletions
diff --git a/clang/test/CodeGen/catch-undef-behavior.c b/clang/test/CodeGen/catch-undef-behavior.c
index a90206e46c4..5283b3ba51e 100644
--- a/clang/test/CodeGen/catch-undef-behavior.c
+++ b/clang/test/CodeGen/catch-undef-behavior.c
@@ -21,14 +21,18 @@
// CHECK: @foo
void foo() {
union { int i; } u;
- // CHECK: %[[SIZE:.*]] = call i64 @llvm.objectsize.i64({{.*}} %[[PTR:.*]], i1 false)
+ // CHECK: %[[CHECK0:.*]] = icmp ne {{.*}}* %[[PTR:.*]], null
+
+ // CHECK: %[[I8PTR:.*]] = bitcast i32* %[[PTR]] to i8*
+ // CHECK-NEXT: %[[SIZE:.*]] = call i64 @llvm.objectsize.i64(i8* %[[I8PTR]], i1 false)
// CHECK-NEXT: %[[CHECK1:.*]] = icmp uge i64 %[[SIZE]], 4
+ // CHECK-NEXT: %[[CHECK01:.*]] = and i1 %[[CHECK0]], %[[CHECK1]]
- // CHECK: %[[PTRTOINT:.*]] = ptrtoint {{.*}} %[[PTR]] to i64
+ // CHECK: %[[PTRTOINT:.*]] = ptrtoint {{.*}}* %[[PTR]] to i64
// CHECK-NEXT: %[[MISALIGN:.*]] = and i64 %[[PTRTOINT]], 3
// CHECK-NEXT: %[[CHECK2:.*]] = icmp eq i64 %[[MISALIGN]], 0
- // CHECK: %[[OK:.*]] = and i1 %[[CHECK1]], %[[CHECK2]]
+ // CHECK: %[[OK:.*]] = and i1 %[[CHECK01]], %[[CHECK2]]
// CHECK-NEXT: br i1 %[[OK]]
// CHECK: %[[ARG:.*]] = ptrtoint {{.*}} %[[PTR]] to i64
@@ -52,6 +56,12 @@ int bar(int *a) {
return *a;
}
+// CHECK: @addr_space
+int addr_space(int __attribute__((address_space(256))) *a) {
+ // CHECK-NOT: __ubsan
+ return *a;
+}
+
// CHECK: @lsh_overflow
int lsh_overflow(int a, int b) {
// CHECK: %[[INBOUNDS:.*]] = icmp ule i32 %[[RHS:.*]], 31
OpenPOWER on IntegriCloud