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."); }
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."); }
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits