-
Notifications
You must be signed in to change notification settings - Fork 795
[SYCL] Don't print the header and footer in the preprocessed output. #15634
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
Changes from 8 commits
d8b91f9
a87ef5d
bf359e9
e4d04d1
19806c1
6eadb5a
eda1496
10d54cc
09f735e
82c3d86
be076b4
83794f6
7fe537c
8d48644
e408c27
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -5734,7 +5734,8 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA, | |
| // action to determine this. | ||
| if (types::getPreprocessedType(Input.getType()) != types::TY_INVALID && | ||
| !Header.empty()) { | ||
| CmdArgs.push_back("-include"); | ||
| // Add the -include-header option to add the integration header | ||
mdtoguchi marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| CmdArgs.push_back("-include-internal-header"); | ||
| CmdArgs.push_back(Args.MakeArgString(Header)); | ||
| // When creating dependency information, filter out the generated | ||
| // header file. | ||
|
|
@@ -5746,11 +5747,11 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA, | |
| CmdArgs.push_back("-fsycl-enable-int-header-diags"); | ||
| } | ||
|
|
||
| // Add the -include-footer option to add the integration footer | ||
| // Add the -include-internal-footer option to add the integration footer | ||
|
||
| StringRef Footer = D.getIntegrationFooter(Input.getBaseInput()); | ||
| if (types::getPreprocessedType(Input.getType()) != types::TY_INVALID && | ||
| !Args.hasArg(options::OPT_fno_sycl_use_footer) && !Footer.empty()) { | ||
| CmdArgs.push_back("-include-footer"); | ||
| CmdArgs.push_back("-include-internal-footer"); | ||
| CmdArgs.push_back(Args.MakeArgString(Footer)); | ||
| // When creating dependency information, filter out the generated | ||
| // integration footer file. | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1663,6 +1663,13 @@ void clang::InitializePreprocessor(Preprocessor &PP, | |
| AddImplicitInclude(Builder, Path); | ||
| } | ||
|
|
||
| // Process -include-internal-header directive. | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this comment accurate? Is the 'processing' happening inside the function call? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes. A |
||
| if (!LangOpts.SYCLIsDevice) { | ||
| if (!InitOpts.IncludeHeader.empty()) { | ||
| AddImplicitInclude(Builder, InitOpts.IncludeHeader); | ||
| } | ||
| } | ||
|
|
||
| // Instruct the preprocessor to skip the preamble. | ||
| PP.setSkipMainFilePreamble(InitOpts.PrecompiledPreambleBytes.first, | ||
| InitOpts.PrecompiledPreambleBytes.second); | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -265,29 +265,54 @@ void PrintPPOutputPPCallbacks::WriteFooterContent(StringRef CodeFooter) { | |||||||||
| *OS << '\n'; | ||||||||||
| } | ||||||||||
|
|
||||||||||
| static bool is_separator(char value) { | ||||||||||
| if (value == '\\') | ||||||||||
| return true; | ||||||||||
| return false; | ||||||||||
|
||||||||||
| if (value == '\\') | |
| return true; | |
| return false; | |
| return value == '\\'; |
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.
May be comment should be moved a bit down?
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,86 @@ | ||
| /// Check compilation tool steps when using the integration footer | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Test name is |
||
| // RUN: %clangxx -fsycl --offload-new-driver -I cmdline/dir -include dummy.h %/s -### 2>&1 \ | ||
| // RUN: | FileCheck -check-prefix FOOTER %s -DSRCDIR=%/S -DCMDDIR=cmdline/dir | ||
|
|
||
| // FOOTER: clang{{.*}} "-fsycl-is-device"{{.*}} "-fsycl-int-header=[[INTHEADER:.+\.h]]" "-fsycl-int-footer=[[INTFOOTER:.+\h]]" "-sycl-std={{.*}}"{{.*}} "-include" "dummy.h" | ||
| // FOOTER: clang{{.*}} "-include-internal-header" "[[INTHEADER]]" | ||
| // FOOTER: "-fsycl-is-host" {{.*}} "-include" "dummy.h"{{.*}} "-I" "cmdline/dir" | ||
|
|
||
| /// Preprocessed file creation with integration footer | ||
| // RUN: %clangxx -fsycl --offload-new-driver -E %/s -### 2>&1 \ | ||
| // RUN: | FileCheck -check-prefix FOOTER_PREPROC_GEN %s | ||
| // FOOTER_PREPROC_GEN: clang{{.*}} "-fsycl-is-device"{{.*}} "-fsycl-int-header=[[INTHEADER:.+\.h]]" "-fsycl-int-footer=[[INTFOOTER:.+\h]]" "-sycl-std={{.*}}" "-o" "[[PREPROC_DEVICE:.+\.ii]]" | ||
| // FOOTER_PREPROC_GEN: clang{{.*}} "-include-internal-header" "[[INTHEADER]]" | ||
| // FOOTER_PREPROC_GEN-SAME: "-include-internal-footer" "[[INTFOOTER]]" | ||
| // FOOTER_PREPROC_GEN-SAME: "-fsycl-is-host"{{.*}} "-E"{{.*}} "-o" "-" | ||
|
|
||
| /// Preprocessed file use with integration footer | ||
| // RUN: touch %t.ii | ||
| // RUN: %clangxx -fsycl --offload-new-driver %t.ii -### 2>&1 \ | ||
| // RUN: | FileCheck -check-prefix FOOTER_PREPROC_USE %s | ||
| // FOOTER_PREPROC_USE: clang{{.*}} "-fsycl-is-host" | ||
|
|
||
| /// Check that integration footer can be disabled | ||
| // RUN: %clangxx -fsycl --offload-new-driver -fno-sycl-use-footer %s -### 2>&1 \ | ||
| // RUN: | FileCheck -check-prefix NO-FOOTER --implicit-check-not "-fsycl-int-footer" %s | ||
| // NO-FOOTER: clang{{.*}} "-fsycl-is-device"{{.*}} "-fsycl-int-header=[[INTHEADER:.+\.h]]" "-sycl-std={{.*}}" | ||
| // NO-FOOTER: clang{{.*}} "-include-internal-header" "[[INTHEADER]]"{{.*}} "-fsycl-is-host"{{.*}} "-o" | ||
|
|
||
| /// Check phases without integration footer | ||
| // RUN: %clangxx -fsycl --offload-new-driver -fno-sycl-instrument-device-code -fno-sycl-device-lib=all -fno-sycl-use-footer -target x86_64-unknown-linux-gnu %s -ccc-print-phases 2>&1 \ | ||
| // RUN: | FileCheck -check-prefix NO-FOOTER-PHASES %s | ||
| // NO-FOOTER-PHASES: 0: input, "{{.*}}", c++, (host-sycl) | ||
| // NO-FOOTER-PHASES: 1: preprocessor, {0}, c++-cpp-output, (host-sycl) | ||
| // NO-FOOTER-PHASES: [[#HOST_IR:]]: compiler, {1}, ir, (host-sycl) | ||
| // NO-FOOTER-PHASES: 3: input, "{{.*}}", c++, (device-sycl) | ||
| // NO-FOOTER-PHASES: 4: preprocessor, {3}, c++-cpp-output, (device-sycl) | ||
| // NO-FOOTER-PHASES: [[#DEVICE_IR:]]: compiler, {4}, ir, (device-sycl) | ||
|
|
||
| /// Check phases with integration footer | ||
| // RUN: %clangxx -fsycl --offload-new-driver -fno-sycl-instrument-device-code -fno-sycl-device-lib=all -target x86_64-unknown-linux-gnu %s -ccc-print-phases 2>&1 \ | ||
| // RUN: | FileCheck -check-prefix FOOTER-PHASES -check-prefix COMMON-PHASES %s | ||
| // FOOTER-PHASES: 0: input, "{{.*}}", c++, (host-sycl) | ||
| // FOOTER-PHASES: 1: preprocessor, {0}, c++-cpp-output, (host-sycl) | ||
| // FOOTER-PHASES: [[#HOST_IR:]]: compiler, {1}, ir, (host-sycl) | ||
| // FOOTER-PHASES: 3: input, "{{.*}}", c++, (device-sycl) | ||
| // FOOTER-PHASES: 4: preprocessor, {3}, c++-cpp-output, (device-sycl) | ||
| // FOOTER-PHASES: [[#DEVICE_IR:]]: compiler, {4}, ir, (device-sycl) | ||
| // COMMON-PHASES: [[#OFFLOAD:]]: backend, {[[#DEVICE_IR]]}, ir, (device-sycl) | ||
| // COMMON-PHASES: [[#OFFLOAD+1]]: offload, "device-sycl (spir64-unknown-unknown)" {[[#OFFLOAD]]}, ir | ||
| // COMMON-PHASES: [[#OFFLOAD+2]]: clang-offload-packager, {[[#OFFLOAD+1]]}, image, (device-sycl) | ||
| // COMMON-PHASES: [[#OFFLOAD+3]]: offload, "host-sycl (x86_64-unknown-linux-gnu)" {[[#HOST_IR]]}, "device-sycl (x86_64-unknown-linux-gnu)" {[[#OFFLOAD+2]]}, ir | ||
| // COMMON-PHASES: [[#OFFLOAD+4]]: backend, {[[#OFFLOAD+3]]}, assembler, (host-sycl) | ||
| // COMMON-PHASES: [[#OFFLOAD+5]]: assembler, {[[#OFFLOAD+4]]}, object, (host-sycl) | ||
| // COMMON-PHASES: [[#OFFLOAD+6]]: clang-linker-wrapper, {[[#OFFLOAD+5]]}, image, (host-sycl) | ||
|
|
||
| /// Check behaviors for dependency generation | ||
| // RUN: %clangxx -fsycl --offload-new-driver -MD -c %s -### 2>&1 \ | ||
| // RUN: | FileCheck -check-prefix DEP_GEN %s | ||
| // DEP_GEN: clang{{.*}} "-fsycl-is-device" | ||
| // DEP_GEN-SAME: "-dependency-file" "[[DEPFILE:.+\.d]]" | ||
| // DEP_GEN-SAME: "-MT" | ||
| // DEP_GEN-SAME: "-internal-isystem" "{{.*}}{{[/\\]+}}include{{[/\\]+}}sycl{{[/\\]+}}stl_wrappers" | ||
| // DEP_GEN-SAME: "-x" "c++" "[[INPUTFILE:.+\.cpp]]" | ||
| // DEP_GEN: clang{{.*}} "-fsycl-is-host" | ||
| // DEP_GEN-SAME: "-dependency-file" "[[DEPFILE]]" | ||
|
|
||
| /// Dependency generation phases | ||
| // RUN: %clangxx -target x86_64-unknown-linux-gnu -fsycl --offload-new-driver -MD -c %s -ccc-print-phases 2>&1 \ | ||
| // RUN: | FileCheck -check-prefix DEP_GEN_PHASES %s | ||
| // DEP_GEN_PHASES: 0: input, "[[INPUTFILE:.+\.cpp]]", c++, (host-sycl) | ||
| // DEP_GEN_PHASES: 1: preprocessor, {0}, c++-cpp-output, (host-sycl) | ||
| // DEP_GEN_PHASES: 2: compiler, {1}, ir, (host-sycl) | ||
| // DEP_GEN_PHASES: 3: input, "[[INPUTFILE]]", c++, (device-sycl) | ||
| // DEP_GEN_PHASES: 4: preprocessor, {3}, c++-cpp-output, (device-sycl) | ||
| // DEP_GEN_PHASES: 5: compiler, {4}, ir, (device-sycl) | ||
| // DEP_GEN_PHASES: 6: backend, {5}, ir, (device-sycl) | ||
| // DEP_GEN_PHASES: 7: offload, "device-sycl (spir64-unknown-unknown)" {6}, ir | ||
| // DEP_GEN_PHASES: 8: clang-offload-packager, {7}, image, (device-sycl) | ||
| // DEP_GEN_PHASES: 9: offload, "host-sycl (x86_64-unknown-linux-gnu)" {2}, "device-sycl (x86_64-unknown-linux-gnu)" {8}, ir | ||
| // DEP_GEN_PHASES: 10: backend, {9}, assembler, (host-sycl) | ||
| // DEP_GEN_PHASES: 11: assembler, {10}, object, (host-sycl) | ||
|
|
||
| /// Allow for -o and preprocessing | ||
| // RUN: %clangxx -fsycl --offload-new-driver -MD -c %s -o dummy -### 2>&1 \ | ||
| // RUN: | FileCheck -check-prefix DEP_GEN_OUT_ERROR %s | ||
| // DEP_GEN_OUT_ERROR-NOT: cannot specify -o when generating multiple output files | ||
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.
Is there a possibility where we want to include header and not footer...or the other way around? Just wondering if we need two options here.
Thanks
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.
Good question. @premanandrao What do you think?
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 behavior of
-include-internal-headerand-include-internal-footeris more than just the ability to pass in a file to be included, it also designates where in the preprocessing the file is expanded, so we need to have 2 options.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.
Thanks Mike!