-
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
Changes from all commits
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 |
---|---|---|
|
@@ -10084,12 +10084,12 @@ void OffloadWrapper::ConstructJob(Compilation &C, const JobAction &JA, | |
ArgStringList WrapperArgs; | ||
|
||
const auto &WrapperJob = *llvm::dyn_cast<OffloadWrapperJobAction>(&JA); | ||
bool LlcCompileEnabled = WrapperJob.getCompileStep(); | ||
bool WrapperCompileEnabled = WrapperJob.getCompileStep(); | ||
SmallString<128> OutOpt("-o="); | ||
std::string OutTmpName = C.getDriver().GetTemporaryPath("wrapper", "bc"); | ||
const char *WrapperFileName = | ||
C.addTempFile(C.getArgs().MakeArgString(OutTmpName)); | ||
OutOpt += LlcCompileEnabled ? WrapperFileName : Output.getFilename(); | ||
OutOpt += WrapperCompileEnabled ? WrapperFileName : Output.getFilename(); | ||
WrapperArgs.push_back(C.getArgs().MakeArgString(OutOpt)); | ||
|
||
SmallString<128> HostTripleOpt("-host="); | ||
|
@@ -10187,28 +10187,30 @@ void OffloadWrapper::ConstructJob(Compilation &C, const JobAction &JA, | |
WrapperArgs, std::nullopt); | ||
C.addCommand(std::move(Cmd)); | ||
|
||
if (LlcCompileEnabled) { | ||
// Construct llc command. | ||
// The output is an object file | ||
ArgStringList LlcArgs{"-filetype=obj", "-o", Output.getFilename(), | ||
WrapperFileName}; | ||
if (WrapperCompileEnabled) { | ||
// TODO Use TC.SelectTool(). | ||
ArgStringList ClangArgs{ | ||
TCArgs.MakeArgString("--target=" + TC.getAuxTriple()->str()), "-c", | ||
"-o", Output.getFilename(), WrapperFileName}; | ||
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()) | ||
ClangArgs.push_back("-fPIC"); | ||
} | ||
if (Arg *A = C.getArgs().getLastArg(options::OPT_mcmodel_EQ)) | ||
LlcArgs.push_back( | ||
TCArgs.MakeArgString(Twine("--code-model=") + A->getValue())); | ||
|
||
SmallString<128> LlcPath(C.getDriver().Dir); | ||
llvm::sys::path::append(LlcPath, "llc"); | ||
const char *Llc = C.getArgs().MakeArgString(LlcPath); | ||
C.addCommand(std::make_unique<Command>( | ||
JA, *this, ResponseFileSupport::None(), Llc, LlcArgs, std::nullopt)); | ||
ClangArgs.push_back( | ||
TCArgs.MakeArgString(Twine("-mcmodel=") + A->getValue())); | ||
|
||
SmallString<128> ClangPath(C.getDriver().Dir); | ||
llvm::sys::path::append(ClangPath, "clang"); | ||
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 commentThe 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 commentThe 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 |
||
} | ||
return; | ||
} // end of SYCL flavor of offload wrapper command creation | ||
|
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'".