Skip to content
Merged
6 changes: 5 additions & 1 deletion clang/include/clang/Driver/Options.td
Original file line number Diff line number Diff line change
Expand Up @@ -4638,10 +4638,14 @@ def image__base : Separate<["-"], "image_base">;
def include_ : JoinedOrSeparate<["-", "--"], "include">, Group<clang_i_Group>, EnumName<"include">,
MetaVarName<"<file>">, HelpText<"Include file before parsing">,
Visibility<[ClangOption, CC1Option]>;
def include_footer : Separate<["-"], "include-footer">, Group<clang_i_Group>,
def include_internal_footer : Separate<["-"], "include-internal-footer">, Group<clang_i_Group>,
Copy link
Contributor

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

Copy link
Contributor Author

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?

Copy link
Contributor

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-header and -include-internal-footer is 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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks Mike!

Visibility<[CC1Option]>,
HelpText<"Name of the footer integration file">, MetaVarName<"<file>">,
MarshallingInfoString<PreprocessorOpts<"IncludeFooter">>;
def include_internal_header : Separate<["-"], "include-internal-header">, Group<clang_i_Group>,
Visibility<[CC1Option]>,
HelpText<"Name of the header integration file">, MetaVarName<"<file>">,
MarshallingInfoString<PreprocessorOpts<"IncludeHeader">>;
def include_pch : Separate<["-"], "include-pch">, Group<clang_i_Group>,
Visibility<[ClangOption, CC1Option]>,
HelpText<"Include precompiled header file">, MetaVarName<"<file>">,
Expand Down
1 change: 1 addition & 0 deletions clang/include/clang/Lex/PreprocessorOptions.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ class PreprocessorOptions {
std::vector<std::pair<std::string, bool/*isUndef*/>> Macros;
std::vector<std::string> Includes;
std::string IncludeFooter;
std::string IncludeHeader;
std::vector<std::string> MacroIncludes;

/// Perform extra checks when loading PCM files for mutable file systems.
Expand Down
7 changes: 4 additions & 3 deletions clang/lib/Driver/ToolChains/Clang.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
CmdArgs.push_back("-include-internal-header");
CmdArgs.push_back(Args.MakeArgString(Header));
// When creating dependency information, filter out the generated
// header file.
Expand All @@ -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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: Add the comment inside the 'if' construct so that it reads similar to the
'header' option?

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.
Expand Down
7 changes: 7 additions & 0 deletions clang/lib/Frontend/InitPreprocessor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1663,6 +1663,13 @@ void clang::InitializePreprocessor(Preprocessor &PP,
AddImplicitInclude(Builder, Path);
}

// Process -include-internal-header directive.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this comment accurate? Is the 'processing' happening inside the function call?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. A #include header.h is added to the stream.

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);
Expand Down
66 changes: 40 additions & 26 deletions clang/lib/Frontend/PrintPreprocessedOutput.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -265,29 +265,54 @@ void PrintPPOutputPPCallbacks::WriteFooterContent(StringRef CodeFooter) {
*OS << '\n';
}

static bool is_separator(char value) {
if (value == '\\')
return true;
return false;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if (value == '\\')
return true;
return false;
return value == '\\';

}

static StringRef remove_leading_dotbackslah(StringRef Path) {
// Remove leading ".\" (or ".\\" or ".\.\" etc.)
while (Path.size() > 2 && Path[0] == '.' && is_separator(Path[1])) {
Path = Path.substr(2);
while (Path.size() > 0 && is_separator(Path[0]))
Path = Path.substr(1);
}
return Path;
}

void PrintPPOutputPPCallbacks::WriteLineInfo(unsigned LineNo,
const char *Extra,
unsigned ExtraLen) {
startNewLineIfNeeded();

// Emit #line directives or GNU line markers depending on what mode we're in.
Copy link
Contributor

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?

if (UseLineDirectives) {
*OS << "#line" << ' ' << LineNo << ' ' << '"';
OS->write_escaped(CurFilename);
*OS << '"';
} else {
*OS << '#' << ' ' << LineNo << ' ' << '"';
OS->write_escaped(CurFilename);
*OS << '"';
StringRef CurFilenameWithNoLeaningDotSlash =
remove_leading_dotbackslah(CurFilename.str());
if ((CurFilenameWithNoLeaningDotSlash ==
PP.getPreprocessorOpts().IncludeFooter) ||
CurFilenameWithNoLeaningDotSlash ==
PP.getPreprocessorOpts().IncludeHeader) {
CurFilename = "<uninit>";
}
if (UseLineDirectives) {
*OS << "#line" << ' ' << LineNo << ' ' << '"';
OS->write_escaped(CurFilename);
*OS << '"';
} else {
*OS << '#' << ' ' << LineNo << ' ' << '"';
OS->write_escaped(CurFilename);
*OS << '"';

if (ExtraLen)
OS->write(Extra, ExtraLen);
if (ExtraLen)
OS->write(Extra, ExtraLen);

if (FileType == SrcMgr::C_System)
OS->write(" 3", 2);
else if (FileType == SrcMgr::C_ExternCSystem)
OS->write(" 3 4", 4);
}

if (FileType == SrcMgr::C_System)
OS->write(" 3", 2);
else if (FileType == SrcMgr::C_ExternCSystem)
OS->write(" 3 4", 4);
}
*OS << '\n';
}

Expand Down Expand Up @@ -913,8 +938,6 @@ static void PrintIncludeFooter(Preprocessor &PP, SourceLocation Loc,
return;
FileID FooterFileID = SourceMgr.ComputeValidFooterFileID(Footer);
StringRef FooterContentBuffer = SourceMgr.getBufferData(FooterFileID);
// print out the name of the integration footer.
Callbacks->WriteFooterInfo(Footer);
SmallVector<StringRef, 8> FooterContentArr;
FooterContentBuffer.split(FooterContentArr, '\r');
// print out the content of the integration footer.
Expand Down Expand Up @@ -1185,15 +1208,6 @@ void clang::DoPrintPreprocessedInput(Preprocessor &PP, raw_ostream *OS,
PrintPreprocessedTokens(PP, Tok, Callbacks);
*OS << '\n';

if (!PP.getPreprocessorOpts().IncludeFooter.empty() &&
!PP.IncludeFooterProcessed) {
assert(PP.getLangOpts().SYCLIsHost &&
"The 'include-footer' is expected in host compilation only");
SourceLocation Loc = Tok.getLocation();
PrintIncludeFooter(PP, Loc, PP.getPreprocessorOpts().IncludeFooter,
Callbacks);
}

// Remove the handlers we just added to leave the preprocessor in a sane state
// so that it can be reused (for example by a clang::Parser instance).
PP.RemovePragmaHandler(MicrosoftExtHandler.get());
Expand Down
4 changes: 2 additions & 2 deletions clang/test/CodeGenSYCL/debug-info-file-checksum.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
// COMP1-SAME: checksumkind: CSK_MD5, checksum: "259269f735d83ec32c46a11352458493")

// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fsycl-is-host \
// RUN: -include %t.header.h -dependency-filter %t.header.h \
// RUN: -include-footer %t.footer.h -dependency-filter %t.footer.h \
// RUN: -include-internal-header %t.header.h -dependency-filter %t.header.h \
// RUN: -include-internal-footer %t.footer.h -dependency-filter %t.footer.h \
// RUN: -main-file-name %S/Inputs/checksum.cpp \
// RUN: -gcodeview -debug-info-kind=limited -emit-llvm -O0 -o - \
// RUN: "%S/Inputs/checksum.cpp" \
Expand Down
14 changes: 6 additions & 8 deletions clang/test/Driver/sycl-int-footer-old-model.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,17 @@
// RUN: %clangxx -fsycl --no-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" "[[INTHEADER]]"
// FOOTER: clang{{.*}} "-include-internal-header" "[[INTHEADER]]"
// FOOTER-SAME: "-dependency-filter" "[[INTHEADER]]"
// FOOTER-SAME: "-include-footer" "[[INTFOOTER]]"
// FOOTER-SAME: "-dependency-filter" "[[INTFOOTER]]"
// FOOTER-SAME: "-fsycl-is-host"{{.*}} "-main-file-name" "[[SRCFILE:.+\cpp]]" {{.*}} "-include" "dummy.h"{{.*}} "-I" "cmdline/dir"

/// Preprocessed file creation with integration footer
// RUN: %clangxx -fsycl --no-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" "[[INTHEADER]]"
// FOOTER_PREPROC_GEN: "-dependency-filter" "[[INTHEADER]]"
// FOOTER_PREPROC_GEN-SAME: "-include-footer" "[[INTFOOTER]]"
// FOOTER_PREPROC_GEN: clang{{.*}} "-include-internal-header" "[[INTHEADER]]"
// FOOTER_PREPROC_GEN-SAME: "-dependency-filter" "[[INTHEADER]]"
// FOOTER_PREPROC_GEN-SAME: "-include-internal-footer" "[[INTFOOTER]]"
// FOOTER_PREPROC_GEN-SAME: "-dependency-filter" "[[INTFOOTER]]"
// FOOTER_PREPROC_GEN-SAME: "-fsycl-is-host"{{.*}} "-E"{{.*}} "-o" "[[PREPROC_HOST:.+\.ii]]"

Expand All @@ -31,7 +29,7 @@
// 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-NOT: append-file
// NO-FOOTER: clang{{.*}} "-include" "[[INTHEADER]]"{{.*}} "-fsycl-is-host"
// NO-FOOTER: clang{{.*}} "-include-internal-header" "[[INTHEADER]]"{{.*}} "-fsycl-is-host"

/// Check phases without integration footer
// RUN: %clangxx -fsycl --no-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 \
Expand Down Expand Up @@ -69,7 +67,7 @@
// RUN: | FileCheck -check-prefix FOOTER_PATH %s
// FOOTER_PATH: clang{{.*}} "-fsycl-is-device"
// FOOTER_PATH-SAME: "-fsycl-int-footer=dummy_dir{{(/|\\\\)}}{{.*}}-footer-{{.*}}.h"
// FOOTER_PATH: clang{{.*}} "-include-footer" "dummy_dir{{(/|\\\\)}}{{.*}}-footer-{{.*}}.h"
// FOOTER_PATH: clang{{.*}} "-include-internal-footer" "dummy_dir{{(/|\\\\)}}{{.*}}-footer-{{.*}}.h"


/// Check behaviors for dependency generation
Expand Down
14 changes: 8 additions & 6 deletions clang/test/Driver/sycl-int-footer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,18 @@
// 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" "[[INTHEADER]]"
// FOOTER: clang{{.*}} "-include-internal-header" "[[INTHEADER]]"
// FOOTER-SAME: "-fsycl-is-host"{{.*}} "-include" "dummy.h"{{.*}} "-I" "cmdline/dir"
// FOOTER-NOT: "-include" "[[INTHEADER]]"
// FOOTER-NOT: "-include-internal-header" "[[INTHEADER]]"

/// 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" "[[INTHEADER]]"
// FOOTER_PREPROC_GEN-SAME: "-include-footer" "[[INTFOOTER]]"
// FOOTER_PREPROC_GEN: clang{{.*}} "-include-internal-header" "[[INTHEADER]]"
// FOOTER_PREPROC_GEN-SAME: "-dependency-filter" "[[INTHEADER]]"
// FOOTER_PREPROC_GEN-SAME: "-include-internal-footer" "[[INTFOOTER]]"
// FOOTER_PREPROC_GEN-SAME: "-dependency-filter" "[[INTFOOTER]]"
// FOOTER_PREPROC_GEN-SAME: "-fsycl-is-host"{{.*}} "-E"{{.*}} "-o" "-"

/// Preprocessed file use with integration footer
Expand All @@ -24,7 +26,7 @@
// 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" "[[INTHEADER]]"{{.*}} "-fsycl-is-host"{{.*}} "-o"
// 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 \
Expand Down Expand Up @@ -58,7 +60,7 @@
// RUN: | FileCheck -check-prefix FOOTER_PATH %s
// FOOTER_PATH: clang{{.*}} "-fsycl-is-device"
// FOOTER_PATH-SAME: "-fsycl-int-footer=dummy_dir{{(/|\\\\)}}{{.*}}-footer-{{.*}}.h"
// FOOTER_PATH: clang{{.*}} "-include-footer" "dummy_dir{{(/|\\\\)}}{{.*}}-footer-{{.*}}.h"
// FOOTER_PATH: clang{{.*}} "-include-internal-footer" "dummy_dir{{(/|\\\\)}}{{.*}}-footer-{{.*}}.h"

/// Check behaviors for dependency generation
// RUN: %clangxx -fsycl --offload-new-driver -MD -c %s -### 2>&1 \
Expand Down
86 changes: 86 additions & 0 deletions clang/test/Driver/sycl-int-header.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
/// Check compilation tool steps when using the integration footer
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Test name is sycl-int-header.cpp but comments in the test are checking for the footer, but the tests themselves are checking for both. Can this ben cleaned up?

// 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
2 changes: 1 addition & 1 deletion clang/test/Driver/sycl-offload-aot.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@
// CHK-TOOLS-GEN: clang{{.*}} "-triple" "spir64_gen-unknown-unknown"
// CHK-TOOLS-CPU: clang{{.*}} "-triple" "spir64_x86_64-unknown-unknown"
// CHK-TOOLS-AOT: "-fsycl-is-device"{{.*}} "-fsycl-int-header=[[INPUT1:.+\-header.+\.h]]" "-fsycl-int-footer={{.*}}"{{.*}} "-o" "[[OUTPUT1:.+\.bc]]"
// CHK-TOOLS-AOT: clang{{.*}} "-triple" "x86_64-unknown-linux-gnu" {{.*}} "-include" "[[INPUT1]]" {{.*}} "-o" "[[OUTPUT7:.+\.o]]
// CHK-TOOLS-AOT: clang{{.*}} "-triple" "x86_64-unknown-linux-gnu" {{.*}} "-include-internal-header" "[[INPUT1]]" {{.*}} "-o" "[[OUTPUT7:.+\.o]]
// CHK-TOOLS-AOT: llvm-link{{.*}} "[[OUTPUT1]]" "-o" "[[OUTPUT2:.+\.bc]]"
// CHK-TOOLS-FPGA: sycl-post-link{{.*}} "-o" "[[OUTPUT2_T:.+\.table]]" "[[OUTPUT2]]"
// CHK-TOOLS-GEN: sycl-post-link{{.*}} "-o" "[[OUTPUT2_T:.+\.table]]" "[[OUTPUT2]]"
Expand Down
4 changes: 2 additions & 2 deletions clang/test/Driver/sycl-offload-header-check.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,5 @@
// RUN: FileCheck --check-prefix=CHECK-HEADER %s
// CHECK-HEADER: clang{{.*}} "-fsycl-int-header=[[HEADER:.+\.h]]"
// CHECK-HEADER: {{.*}} "-internal-isystem" "{{.*}}bin{{[/\\]+}}..{{[/\\]+}}include{{[/\\]+}}sycl{{[/\\]+}}stl_wrappers"
// CHECK-HEADER-NOT: clang{{.*}} "-include" "[[HEADER]]"
// CHECK-HEADER: clang{{.*}} "-include" "{{.*}}_dirname{{.+}}.h"
// CHECK-HEADER-NOT: clang{{.*}} "-include-internal-header" "[[HEADER]]"
// CHECK-HEADER: clang{{.*}} "-include-internal-header" "{{.*}}_dirname{{.+}}.h"
Loading
Loading