[PATCH] D142022: [Clang][OpenMP] Fix handling of -mcode-object-version for OpenMP
Saiyedul Islam via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Wed Jan 18 07:29:38 PST 2023
saiislam created this revision.
saiislam added reviewers: jhuber6, yaxunl.
Herald added subscribers: kosarev, kerbowa, guansong, tpr, jvesely.
Herald added a project: All.
saiislam requested review of this revision.
Herald added subscribers: cfe-commits, sstefan1, MaskRay.
Herald added a reviewer: jdoerfert.
Herald added a project: clang.
Code object version flag for AMDGPU was not being honored by the
driver. It was required to be passed as derived arg so that correct
bitcode library can be linked.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D142022
Files:
clang/lib/Driver/Driver.cpp
clang/lib/Driver/ToolChains/AMDGPUOpenMP.cpp
clang/lib/Driver/ToolChains/AMDGPUOpenMP.h
clang/lib/Driver/ToolChains/Clang.cpp
Index: clang/lib/Driver/ToolChains/Clang.cpp
===================================================================
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -7113,7 +7113,7 @@
}
if (Triple.isAMDGPU()) {
- handleAMDGPUCodeObjectVersionOptions(D, Args, CmdArgs);
+ handleAMDGPUCodeObjectVersionOptions(D, C.getArgs(), CmdArgs);
Args.addOptInFlag(CmdArgs, options::OPT_munsafe_fp_atomics,
options::OPT_mno_unsafe_fp_atomics);
@@ -8087,7 +8087,8 @@
}
if (Triple.isAMDGPU())
- handleAMDGPUCodeObjectVersionOptions(D, Args, CmdArgs, /*IsCC1As=*/true);
+ handleAMDGPUCodeObjectVersionOptions(D, C.getArgs(), CmdArgs,
+ /*IsCC1As=*/true);
assert(Input.isFilename() && "Invalid input.");
CmdArgs.push_back(Input.getFilename());
Index: clang/lib/Driver/ToolChains/AMDGPUOpenMP.h
===================================================================
--- clang/lib/Driver/ToolChains/AMDGPUOpenMP.h
+++ clang/lib/Driver/ToolChains/AMDGPUOpenMP.h
@@ -26,8 +26,8 @@
: public ROCMToolChain {
public:
AMDGPUOpenMPToolChain(const Driver &D, const llvm::Triple &Triple,
- const ToolChain &HostTC,
- const llvm::opt::ArgList &Args);
+ const ToolChain &HostTC, const llvm::opt::ArgList &Args,
+ const llvm::opt::DerivedArgList &DerivedArgs);
const llvm::Triple *getAuxTriple() const override {
return &HostTC.getTriple();
@@ -58,6 +58,7 @@
getDeviceLibs(const llvm::opt::ArgList &Args) const override;
const ToolChain &HostTC;
+ const llvm::opt::DerivedArgList &DerivedArgs;
};
} // end namespace toolchains
Index: clang/lib/Driver/ToolChains/AMDGPUOpenMP.cpp
===================================================================
--- clang/lib/Driver/ToolChains/AMDGPUOpenMP.cpp
+++ clang/lib/Driver/ToolChains/AMDGPUOpenMP.cpp
@@ -58,8 +58,9 @@
AMDGPUOpenMPToolChain::AMDGPUOpenMPToolChain(const Driver &D,
const llvm::Triple &Triple,
const ToolChain &HostTC,
- const ArgList &Args)
- : ROCMToolChain(D, Triple, Args), HostTC(HostTC) {
+ const ArgList &Args,
+ const DerivedArgList &DerivedArgs)
+ : ROCMToolChain(D, Triple, Args), HostTC(HostTC), DerivedArgs(DerivedArgs) {
// Lookup binaries into the driver directory, this is used to
// discover the clang-offload-bundler executable.
getProgramPaths().push_back(getDriver().Dir);
@@ -190,7 +191,7 @@
getTriple(), Args.getLastArgValue(options::OPT_march_EQ));
SmallVector<BitCodeLibraryInfo, 12> BCLibs;
- for (auto BCLib : getCommonDeviceLibNames(Args, GpuArch.str(),
+ for (auto BCLib : getCommonDeviceLibNames(DerivedArgs, GpuArch.str(),
/*IsOpenMP=*/true))
BCLibs.emplace_back(BCLib);
Index: clang/lib/Driver/Driver.cpp
===================================================================
--- clang/lib/Driver/Driver.cpp
+++ clang/lib/Driver/Driver.cpp
@@ -872,7 +872,7 @@
}
if (AMDTriple) {
auto TempTC = std::make_unique<toolchains::AMDGPUOpenMPToolChain>(
- *this, *AMDTriple, *HostTC, C.getInputArgs());
+ *this, *AMDTriple, *HostTC, C.getInputArgs(), C.getArgs());
for (StringRef Arch : getOffloadArchs(
C, C.getArgs(), Action::OFK_OpenMP, &*TempTC, true))
Archs.insert(Arch);
@@ -943,7 +943,7 @@
*this, TT, *HostTC, C.getInputArgs());
else if (TT.isAMDGCN())
DeviceTC = std::make_unique<toolchains::AMDGPUOpenMPToolChain>(
- *this, TT, *HostTC, C.getInputArgs());
+ *this, TT, *HostTC, C.getInputArgs(), C.getArgs());
else
assert(DeviceTC && "Device toolchain not defined.");
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D142022.490152.patch
Type: text/x-patch
Size: 4097 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20230118/fd518d39/attachment-0001.bin>
More information about the cfe-commits
mailing list