Skip to content

[Clang][Driver] Fix --save-temps for OpenCL AoT compilation #78333

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
Jan 23, 2024
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
6 changes: 4 additions & 2 deletions clang/include/clang/Driver/Types.def
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,10 @@
// C family source language (with and without preprocessing).
TYPE("cpp-output", PP_C, INVALID, "i", phases::Compile, phases::Backend, phases::Assemble, phases::Link)
TYPE("c", C, PP_C, "c", phases::Preprocess, phases::Compile, phases::Backend, phases::Assemble, phases::Link)
TYPE("cl", CL, PP_C, "cl", phases::Preprocess, phases::Compile, phases::Backend, phases::Assemble, phases::Link)
TYPE("clcpp", CLCXX, PP_CXX, "clcpp", phases::Preprocess, phases::Compile, phases::Backend, phases::Assemble, phases::Link)
TYPE("cl", CL, PP_CL, "cl", phases::Preprocess, phases::Compile, phases::Backend, phases::Assemble, phases::Link)
TYPE("cl-cpp-output", PP_CL, INVALID, "cli", phases::Compile, phases::Backend, phases::Assemble, phases::Link)
TYPE("clcpp", CLCXX, PP_CLCXX, "clcpp", phases::Preprocess, phases::Compile, phases::Backend, phases::Assemble, phases::Link)
TYPE("clcpp-cpp-output", PP_CLCXX, INVALID, "clii", phases::Compile, phases::Backend, phases::Assemble, phases::Link)
TYPE("cuda-cpp-output", PP_CUDA, INVALID, "cui", phases::Compile, phases::Backend, phases::Assemble, phases::Link)
TYPE("cuda", CUDA, PP_CUDA, "cu", phases::Preprocess, phases::Compile, phases::Backend, phases::Assemble, phases::Link)
TYPE("cuda", CUDA_DEVICE, PP_CUDA, "cu", phases::Preprocess, phases::Compile, phases::Backend, phases::Assemble, phases::Link)
Expand Down
7 changes: 6 additions & 1 deletion clang/lib/Driver/Types.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ bool types::isAcceptedByClang(ID Id) {

case TY_Asm:
case TY_C: case TY_PP_C:
case TY_CL: case TY_CLCXX:
case TY_CL: case TY_PP_CL: case TY_CLCXX: case TY_PP_CLCXX:
case TY_CUDA: case TY_PP_CUDA:
case TY_CUDA_DEVICE:
case TY_HIP:
Expand Down Expand Up @@ -181,7 +181,9 @@ bool types::isDerivedFromC(ID Id) {
case TY_PP_C:
case TY_C:
case TY_CL:
case TY_PP_CL:
case TY_CLCXX:
case TY_PP_CLCXX:
case TY_PP_CUDA:
case TY_CUDA:
case TY_CUDA_DEVICE:
Expand Down Expand Up @@ -241,6 +243,7 @@ bool types::isCXX(ID Id) {
case TY_PP_CXXHeaderUnit:
case TY_ObjCXXHeader: case TY_PP_ObjCXXHeader:
case TY_CXXModule: case TY_PP_CXXModule:
case TY_PP_CLCXX:
case TY_CUDA: case TY_PP_CUDA: case TY_CUDA_DEVICE:
case TY_HIP:
case TY_PP_HIP:
Expand Down Expand Up @@ -310,7 +313,9 @@ types::ID types::lookupTypeForExtension(llvm::StringRef Ext) {
.Case("cc", TY_CXX)
.Case("CC", TY_CXX)
.Case("cl", TY_CL)
.Case("cli", TY_PP_CL)
.Case("clcpp", TY_CLCXX)
.Case("clii", TY_PP_CLCXX)
.Case("cp", TY_CXX)
.Case("cu", TY_CUDA)
.Case("hh", TY_CXXHeader)
Expand Down
16 changes: 16 additions & 0 deletions clang/test/Driver/opencl_aot_save_temps.cl
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// RUN: %clang -x cl --save-temps -c -### %s 2>&1 | FileCheck %s
// RUN: %clang -x cl -ccc-print-phases -c %s 2>&1 | FileCheck %s -check-prefix=CHECK-PHASES

// CHECK: "-o" "[[CLI_NAME:.+]].cli" "-x" "cl"
// CHECK-NEXT: "-o" "[[CLI_NAME]].bc" "-x" "cl-cpp-output"{{.*}}"[[CLI_NAME:.+]].cli"

// CHECK-PHASES: 0: input, {{.*}}, cl
// CHECK-PHASES: 1: preprocessor, {0}, cl-cpp-output
// CHECK-PHASES: 2: compiler, {1}, ir

uint3 add(uint3 a, uint3 b) {
ulong x = a.x + (ulong)b.x;
ulong y = a.y + (ulong)b.y + (x >> 32);
uint z = a.z + b.z + (y >> 32);
return (uint3)(x, y, z);
}