-
Notifications
You must be signed in to change notification settings - Fork 787
[SYCL] Call clang instead of llc. #15259
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
Conversation
Previously, OffloadWrapper::ConstructJob would call llc to convert LLVM IR into machine code. With this change, it calls clang instead. This should be mostly NFC for x86, there may be some small changes in exactly which passes run, but they are intended to be roughly the same, and enables future changes passing along more clang options. For other targets, this is a bugfix. Specifically, for RISC-V, llc and clang disagree on which subtarget features to enable by default, resulting in linker errors due to subtarget feature mismatches between the llc-compiled wrapper and other clang-compiled object files.
const char *Clang = C.getArgs().MakeArgString(ClangPath); | ||
C.addCommand(std::make_unique<Command>(JA, *this, | ||
ResponseFileSupport::None(), Clang, | ||
ClangArgs, std::nullopt)); |
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.
I think ideally, this should be handled outside of the wrapper call, where we call the wrapper, then create a new job that calls the compiler backend to create the object. But as we are moving away from the old offload model in the near future that work may be wasted effort.
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.
I agree it should not be in this function directly, though I had a slightly different idea there, that is what the // TODO Use TC.SelectTool().
comment is about. I was concerned it would be too big a change to go that route right away, and I would have that same concern with your idea. But if you say this whole approach is going away anyway, then definitely it sounds like it is not worth the extra work.
llvm::Reloc::Model RelocationModel; | ||
unsigned PICLevel; | ||
bool IsPIE; | ||
std::tie(RelocationModel, PICLevel, IsPIE) = | ||
ParsePICArgs(getToolChain(), TCArgs); | ||
if (PICLevel > 0 || TCArgs.hasArg(options::OPT_shared)) { | ||
LlcArgs.push_back("-relocation-model=pic"); | ||
if (!TC.getAuxTriple()->isOSWindows()) |
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.
Can you explain why we need this restriction?
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.
Windows does not support (or need) -fPIC
, it results in "clang: error: unsupported option '-fPIC' for target 'x86_64-pc-windows-msvc'".
ping |
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 - LGTM.
@hvdijk, @mdtoguchi, is |
@bader Yes, it is being used in the
|
Looking at that, probably that would benefit from the same change; if so, would you prefer that I update this PR to do so or would you prefer that as a later followup PR? |
Eventually, we will switch to the new offloading model, so I would do the change sooner rather than later, but I don't have a strong opinion about the form. I leave this decision to you. |
- Update clang-offload-wrapper too. - Remove unused SYCL::Linker::constructLlcCommand.
Updated to modify I did not modify |
Hi @hvdijk Thanks so much for updating the clang-linker-wrapper. w.r.t the use of llc for SPIR-V code generation, it is a temporary workaround I added to test the SPIR-V backend. I will be removing that work-around soon and will remove the llc dependency for sycl toolchain at that point. 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.
LGTM. Thanks
@intel/llvm-gatekeepers this looks ready to merge, thank you |
Previously, OffloadWrapper::ConstructJob would call llc to convert LLVM IR into machine code. With this change, it calls clang instead.
This should be mostly NFC for x86, there may be some small changes in exactly which passes run, but they are intended to be roughly the same, and enables future changes passing along more clang options.
For other targets, this is a bugfix. Specifically, for RISC-V, llc and clang disagree on which subtarget features to enable by default, resulting in linker errors due to subtarget feature mismatches between the llc-compiled wrapper and other clang-compiled object files.