-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[Clang][CodeGen][OpenCL] Add -fno-delete-null-pointer-checks
to avoid UB. NFC.
#135602
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
@llvm/pr-subscribers-clang Author: Yingwei Zheng (dtcxzyw) ChangesNeeded by #130742. Full diff: https://github.com/llvm/llvm-project/pull/135602.diff 3 Files Affected:
diff --git a/clang/test/CodeGenOpenCL/spir32_target.cl b/clang/test/CodeGenOpenCL/spir32_target.cl
index 924b2c12f5537..cccdf3635ea63 100644
--- a/clang/test/CodeGenOpenCL/spir32_target.cl
+++ b/clang/test/CodeGenOpenCL/spir32_target.cl
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 %s -triple "spir-unknown-unknown" -emit-llvm -o - | FileCheck %s
+// RUN: %clang_cc1 %s -triple "spir-unknown-unknown" -fno-delete-null-pointer-checks -emit-llvm -o - | FileCheck %s
// CHECK: target triple = "spir-unknown-unknown"
diff --git a/clang/test/CodeGenOpenCL/spir64_target.cl b/clang/test/CodeGenOpenCL/spir64_target.cl
index ba4a66d7158fd..67880f47adb34 100644
--- a/clang/test/CodeGenOpenCL/spir64_target.cl
+++ b/clang/test/CodeGenOpenCL/spir64_target.cl
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 %s -triple "spir64-unknown-unknown" -emit-llvm -o - | FileCheck %s
+// RUN: %clang_cc1 %s -triple "spir64-unknown-unknown" -emit-llvm -fno-delete-null-pointer-checks -o - | FileCheck %s
// CHECK: target triple = "spir64-unknown-unknown"
diff --git a/clang/test/CodeGenOpenCL/spirv_target.cl b/clang/test/CodeGenOpenCL/spirv_target.cl
index 2aeed195449a8..f9e92a79d5617 100644
--- a/clang/test/CodeGenOpenCL/spirv_target.cl
+++ b/clang/test/CodeGenOpenCL/spirv_target.cl
@@ -1,5 +1,5 @@
-// RUN: %clang_cc1 %s -triple "spirv32-unknown-unknown" -verify -emit-llvm -o - | FileCheck %s -check-prefix=SPIRV32
-// RUN: %clang_cc1 %s -triple "spirv64-unknown-unknown" -verify -emit-llvm -o - | FileCheck %s -check-prefix=SPIRV64
+// RUN: %clang_cc1 %s -triple "spirv32-unknown-unknown" -fno-delete-null-pointer-checks -verify -emit-llvm -o - | FileCheck %s -check-prefix=SPIRV32
+// RUN: %clang_cc1 %s -triple "spirv64-unknown-unknown" -fno-delete-null-pointer-checks -verify -emit-llvm -o - | FileCheck %s -check-prefix=SPIRV64
// SPIRV32: target triple = "spirv32-unknown-unknown"
// SPIRV64: target triple = "spirv64-unknown-unknown"
|
@@ -1,4 +1,4 @@ | |||
// RUN: %clang_cc1 %s -triple "spir-unknown-unknown" -emit-llvm -o - | FileCheck %s | |||
// RUN: %clang_cc1 %s -triple "spir-unknown-unknown" -fno-delete-null-pointer-checks -emit-llvm -o - | FileCheck %s |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't see any optimization flags here... is this somehow running the optimizer by default?
If it is, this change is fine, I guess.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The default optimization level for opencl frontend is O2 :)
llvm-project/clang/lib/Frontend/CompilerInvocation.cpp
Lines 717 to 723 in 83344da
static unsigned getOptimizationLevel(ArgList &Args, InputKind IK, | |
DiagnosticsEngine &Diags) { | |
unsigned DefaultOpt = 0; | |
if ((IK.getLanguage() == Language::OpenCL || | |
IK.getLanguage() == Language::OpenCLCXX) && | |
!Args.hasArg(OPT_cl_opt_disable)) | |
DefaultOpt = 2; |
…id UB. NFC. (llvm#135602) Needed by llvm#130742.
Needed by #130742.