-
Notifications
You must be signed in to change notification settings - Fork 10.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Clang][Driver] Fix
--save-temps
for OpenCL AoT compilation (#78333)
We can directly call `clang -c -x cl -target amdgcn -mcpu=gfx90a test.cl -o test.o` to compile an OpenCL kernel file. However, when `--save-temps` is enabled, it doesn't work because the preprocessed file (`.i` file) is taken as C source file when it is fed to the front end, thus causing compilation error because those OpenCL keywords can't be recognized. This patch fixes the issue.
- Loading branch information
Showing
3 changed files
with
26 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} |