1 // RUN: %clang_cc1 -emit-llvm -triple x86_64-unknown-linux-gnu -O2 -o - %s | FileCheck -check-prefix=NULL-POINTER-INVALID %s
2 // RUN: %clang_cc1 -emit-llvm -triple x86_64-unknown-linux-gnu -O2 -o - %s -fno-delete-null-pointer-checks | FileCheck -check-prefix=NULL-POINTER-VALID %s
4 // Test that clang does not remove the null pointer check with
5 // -fno-delete-null-pointer-checks.
6 int null_check(int *P
) {
7 // NULL-POINTER-VALID: %[[TOBOOL:.*]] = icmp eq ptr %P, null
8 // NULL-POINTER-INVALID-NOT: icmp eq
9 // NULL-POINTER-VALID: %[[SEL:.*]] = select i1 %[[TOBOOL:.*]], ptr null, ptr
10 // NULL-POINTER-INVALID-NOT: select i1
11 // NULL-POINTER-VALID: load i32, ptr %[[SEL:.*]]
19 // NULL-POINTER-INVALID-NOT: attributes #0 = {{.*}} null_pointer_is_valid
20 // NULL-POINTER-VALID: attributes #0 = {{.*}} null_pointer_is_valid