summaryrefslogtreecommitdiffstats
path: root/clang/test/CodeGen/vla.c
diff options
context:
space:
mode:
authorManoj Gupta <manojgupta@google.com>2018-07-19 00:44:52 +0000
committerManoj Gupta <manojgupta@google.com>2018-07-19 00:44:52 +0000
commitda08f6ac16b6a53ab25ecb56e1be800c5f0095d9 (patch)
tree658722ff7c2b281d8d6dd58b9d1e149f48f51d25 /clang/test/CodeGen/vla.c
parentac1f9263d13eb8e96681d13777a9638e4672feb3 (diff)
downloadbcm5719-llvm-da08f6ac16b6a53ab25ecb56e1be800c5f0095d9.tar.gz
bcm5719-llvm-da08f6ac16b6a53ab25ecb56e1be800c5f0095d9.zip
[clang]: Add support for "-fno-delete-null-pointer-checks"
Summary: Support for this option is needed for building Linux kernel. This is a very frequently requested feature by kernel developers. More details : https://lkml.org/lkml/2018/4/4/601 GCC option description for -fdelete-null-pointer-checks: This Assume that programs cannot safely dereference null pointers, and that no code or data element resides at address zero. -fno-delete-null-pointer-checks is the inverse of this implying that null pointer dereferencing is not undefined. This feature is implemented in as the function attribute "null-pointer-is-valid"="true". This CL only adds the attribute on the function. It also strips "nonnull" attributes from function arguments but keeps the related warnings unchanged. Corresponding LLVM change rL336613 already updated the optimizations to not treat null pointer dereferencing as undefined if the attribute is present. Reviewers: t.p.northover, efriedma, jyknight, chandlerc, rnk, srhines, void, george.burgess.iv Reviewed By: jyknight Subscribers: drinkcat, xbolva00, cfe-commits Differential Revision: https://reviews.llvm.org/D47894 llvm-svn: 337433
Diffstat (limited to 'clang/test/CodeGen/vla.c')
-rw-r--r--clang/test/CodeGen/vla.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/clang/test/CodeGen/vla.c b/clang/test/CodeGen/vla.c
index 0f2e2cdc669..37243cd1729 100644
--- a/clang/test/CodeGen/vla.c
+++ b/clang/test/CodeGen/vla.c
@@ -1,4 +1,5 @@
-// RUN: %clang_cc1 -triple i386-unknown-unknown %s -emit-llvm -o - | FileCheck %s
+// RUN: %clang_cc1 -triple i386-unknown-unknown %s -emit-llvm -o - | FileCheck %s -check-prefixes=CHECK,NULL-INVALID
+// RUN: %clang_cc1 -triple i386-unknown-unknown %s -emit-llvm -fno-delete-null-pointer-checks -o - | FileCheck %s -check-prefixes=CHECK,NULL-VALID
int b(char* x);
@@ -202,5 +203,6 @@ void test8(int a[static 3]) { }
// CHECK: define void @test8(i32* dereferenceable(12) %a)
void test9(int n, int a[static n]) { }
-// CHECK: define void @test9(i32 %n, i32* nonnull %a)
+// NULL-INVALID: define void @test9(i32 %n, i32* nonnull %a)
+// NULL-VALID: define void @test9(i32 %n, i32* %a)
OpenPOWER on IntegriCloud