Skip to content

[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

Merged
merged 1 commit into from
Apr 17, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion clang/test/CodeGenOpenCL/spir32_target.cl
Original file line number Diff line number Diff line change
@@ -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

Copy link
Collaborator

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.

Copy link
Member Author

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 :)

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;

// CHECK: target triple = "spir-unknown-unknown"

Expand Down
2 changes: 1 addition & 1 deletion clang/test/CodeGenOpenCL/spir64_target.cl
Original file line number Diff line number Diff line change
@@ -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"

Expand Down
4 changes: 2 additions & 2 deletions clang/test/CodeGenOpenCL/spirv_target.cl
Original file line number Diff line number Diff line change
@@ -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"
Expand Down
Loading