Skip to content
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

[Driver][SYCL] warning emitted when compiling wrapped object #16397

Merged
merged 4 commits into from
Jan 3, 2025
Merged
Show file tree
Hide file tree
Changes from 2 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
11 changes: 9 additions & 2 deletions clang/lib/Driver/ToolChains/Clang.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10344,9 +10344,16 @@ void OffloadWrapper::ConstructJob(Compilation &C, const JobAction &JA,

if (WrapperCompileEnabled) {
// TODO Use TC.SelectTool().
// Pass -Wno-override-module to the compilation to restrict the warning
// that is emitted due to the target in the generated IR from the wrapping
// step.
Copy link
Contributor

Choose a reason for hiding this comment

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

due to the target in the generated IR from the wrapping step.

Can you elaborate this sentence?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The clang-offload-wrapper will wrap the device object in an IR file that needs to be compiled. The -host setting sets up the target triple. I did some additional experimentation and I believe we may be able to fix this by providing a more complete -host value.

Copy link
Contributor

Choose a reason for hiding this comment

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

The -host setting sets up the target triple. I did some additional experimentation and I believe we may be able to fix this by providing a more complete -host value.

Can you clarify which -host setting is being referred here?

Also, the example warning mentioned in the description (x86_64-pc-windows-msvc) specifies a windows target triple.
Will this change based on the --target value?

Can a test be added to verify if the warning is not thrown when -Wno-override-module is passed?

Lastly, why do we need to suppress this warning?

Copy link
Contributor Author

@mdtoguchi mdtoguchi Dec 20, 2024

Choose a reason for hiding this comment

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

I'm referring to the -host option that is used during the clang-offload-wrapper call. This information is used when generating the IR for the wrapped binary. Having the -host value for the clang-offload-wrapper call match the --target value for the clang call should prevent the diagnostic from being emitted.

The changes I am working on shouldn't require the -Wno-override-module option anymore.

As for a test, a driver specific test probably isn't ideal here, as the warning is only emitted during the device linking stage. What is interesting here, is that the diagnostic is emitted from an internal call to 'clang' and there is no way to disable it.

ArgStringList ClangArgs{
TCArgs.MakeArgString("--target=" + TC.getAuxTriple()->str()), "-c",
"-o", Output.getFilename(), WrapperFileName};
TCArgs.MakeArgString("--target=" + TC.getAuxTriple()->str()),
"-Wno-override-module",
Copy link
Contributor

Choose a reason for hiding this comment

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

Can a test be added to verify that the warning no longer occurs?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This will require a non-driver LIT test to verify (some kind of E2E test that allows for full compilation). OK to add later?

"-c",
"-o",
Output.getFilename(),
WrapperFileName};
llvm::Reloc::Model RelocationModel;
unsigned PICLevel;
bool IsPIE;
Expand Down
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 @@ -156,7 +156,7 @@
// CHK-TOOLS-FPGA: clang-offload-wrapper{{.*}} "-o=[[OUTPUT5:.+\.bc]]" "-host=x86_64-unknown-linux-gnu" "-target=spir64_fpga{{.*}}" "-kind=sycl" "-batch" "[[OUTPUT4]]"
// CHK-TOOLS-GEN: clang-offload-wrapper{{.*}} "-o=[[OUTPUT5:.+\.bc]]" "-host=x86_64-unknown-linux-gnu" "-target=spir64_gen{{.*}}" "-kind=sycl" "-batch" "[[OUTPUT4]]"
// CHK-TOOLS-CPU: clang-offload-wrapper{{.*}} "-o=[[OUTPUT5:.+\.bc]]" "-host=x86_64-unknown-linux-gnu" "-target=spir64_x86_64{{.*}}" "-kind=sycl" "-batch" "[[OUTPUT4]]"
// CHK-TOOLS-AOT: clang{{.*}} "-c" "-o" "[[OUTPUT6:.+\.o]]" "[[OUTPUT5]]"
// CHK-TOOLS-AOT: clang{{.*}} "-Wno-override-module" "-c" "-o" "[[OUTPUT6:.+\.o]]" "[[OUTPUT5]]"
// CHK-TOOLS-AOT: ld{{.*}} "[[OUTPUT7]]" "[[OUTPUT6]]" {{.*}} "-lsycl"

// Check to be sure that for windows, the 'exe' tools are called
Expand Down
2 changes: 1 addition & 1 deletion clang/test/Driver/sycl-offload-with-split-old-model.c
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@
// CHK-TOOLS-FPGA: clang-offload-wrapper{{.*}} "-o=[[OUTPUT8:.+\.bc]]" "-host=x86_64-unknown-linux-gnu" "-target=spir64_fpga" "-kind=sycl" "-batch" "[[OUTPUT7]]"
// CHK-TOOLS-GEN: clang-offload-wrapper{{.*}} "-o=[[OUTPUT8:.+\.bc]]" "-host=x86_64-unknown-linux-gnu" "-target=spir64_gen" "-kind=sycl" "-batch" "[[OUTPUT7]]"
// CHK-TOOLS-CPU: clang-offload-wrapper{{.*}} "-o=[[OUTPUT8:.+\.bc]]" "-host=x86_64-unknown-linux-gnu" "-target=spir64_x86_64" "-kind=sycl" "-batch" "[[OUTPUT7]]"
// CHK-TOOLS-AOT: clang{{.*}} "-c" "-o" "[[OUTPUT9:.+\.o]]" "[[OUTPUT8]]"
// CHK-TOOLS-AOT: clang{{.*}} "-Wno-override-module" "-c" "-o" "[[OUTPUT9:.+\.o]]" "[[OUTPUT8]]"
// CHK-TOOLS-AOT: ld{{.*}} "[[OUTPUT10]]" "[[OUTPUT9]]" {{.*}} "-lsycl"

/// ###########################################################################
Expand Down
Loading