From: Yaxun Liu Date: Fri, 11 May 2018 19:02:18 +0000 (+0000) Subject: [HIP] Let clang-offload-bundler support HIP X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=49edfed6d975a27cbbcd515f458f22d978791d53;p=clang [HIP] Let clang-offload-bundler support HIP When bundle/unbundle intermediate files for HIP, there may be multiple sub archs, therefore BoundArch needs to be included in the target and output file names for clang-offload-bundler. Differential Revision: https://reviews.llvm.org/D46473 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@332121 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Driver/Driver.cpp b/lib/Driver/Driver.cpp index f84decfecb..6bedfbff72 100644 --- a/lib/Driver/Driver.cpp +++ b/lib/Driver/Driver.cpp @@ -3736,9 +3736,12 @@ InputInfo Driver::BuildJobsForActionNoCache( UI.DependentToolChain->getTriple().normalize(), /*CreatePrefixForHost=*/true); auto CurI = InputInfo( - UA, GetNamedOutputPath(C, *UA, BaseInput, UI.DependentBoundArch, - /*AtTopLevel=*/false, MultipleArchs, - OffloadingPrefix), + UA, + GetNamedOutputPath(C, *UA, BaseInput, UI.DependentBoundArch, + /*AtTopLevel=*/false, + MultipleArchs || + UI.DependentOffloadKind == Action::OFK_HIP, + OffloadingPrefix), BaseInput); // Save the unbundling result. UnbundlingResults.push_back(CurI); diff --git a/lib/Driver/ToolChains/Clang.cpp b/lib/Driver/ToolChains/Clang.cpp index cc26b5e04e..2b4bdfa438 100644 --- a/lib/Driver/ToolChains/Clang.cpp +++ b/lib/Driver/ToolChains/Clang.cpp @@ -5542,6 +5542,10 @@ void OffloadBundler::ConstructJob(Compilation &C, const JobAction &JA, Triples += Action::GetOffloadKindName(CurKind); Triples += '-'; Triples += CurTC->getTriple().normalize(); + if (CurKind == Action::OFK_HIP && CurDep->getOffloadingArch()) { + Triples += '-'; + Triples += CurDep->getOffloadingArch(); + } } CmdArgs.push_back(TCArgs.MakeArgString(Triples)); @@ -5611,6 +5615,11 @@ void OffloadBundler::ConstructJobMultipleOutputs( Triples += Action::GetOffloadKindName(Dep.DependentOffloadKind); Triples += '-'; Triples += Dep.DependentToolChain->getTriple().normalize(); + if (Dep.DependentOffloadKind == Action::OFK_HIP && + !Dep.DependentBoundArch.empty()) { + Triples += '-'; + Triples += Dep.DependentBoundArch; + } } CmdArgs.push_back(TCArgs.MakeArgString(Triples)); diff --git a/tools/clang-offload-bundler/ClangOffloadBundler.cpp b/tools/clang-offload-bundler/ClangOffloadBundler.cpp index 259a3e830c..d9fb3898b5 100644 --- a/tools/clang-offload-bundler/ClangOffloadBundler.cpp +++ b/tools/clang-offload-bundler/ClangOffloadBundler.cpp @@ -969,11 +969,11 @@ int main(int argc, const char **argv) { getOffloadKindAndTriple(Target, Kind, Triple); bool KindIsValid = !Kind.empty(); - KindIsValid = KindIsValid && - StringSwitch(Kind) - .Case("host", true) - .Case("openmp", true) - .Default(false); + KindIsValid = KindIsValid && StringSwitch(Kind) + .Case("host", true) + .Case("openmp", true) + .Case("hip", true) + .Default(false); bool TripleIsValid = !Triple.empty(); llvm::Triple T(Triple);