[OpenMP] Fix bug regarding cubin integration into host binary

when a BindArchAction is used.

This is not a functional change.

Original Diff: D29654

llvm-svn: 310433
This commit is contained in:
Gheorghe-Teodor Bercea 2017-08-09 01:02:19 +00:00
parent 7030354744
commit 5289843597
3 changed files with 25 additions and 3 deletions

View File

@ -579,7 +579,7 @@ void Driver::CreateOffloadingDeviceToolChains(Compilation &C,
C.getSingleOffloadToolChain<Action::OFK_Host>();
assert(HostTC && "Host toolchain should be always defined.");
auto &CudaTC =
ToolChains[TT.str() + "/" + HostTC->getTriple().str()];
ToolChains[TT.str() + "/" + HostTC->getTriple().normalize()];
if (!CudaTC)
CudaTC = llvm::make_unique<toolchains::CudaToolChain>(
*this, TT, *HostTC, C.getInputArgs(), Action::OFK_OpenMP);
@ -3407,7 +3407,7 @@ InputInfo Driver::BuildJobsForActionNoCache(
// Get the unique string identifier for this dependence and cache the
// result.
CachedResults[{A, GetTriplePlusArchString(
UI.DependentToolChain, UI.DependentBoundArch,
UI.DependentToolChain, BoundArch,
UI.DependentOffloadKind)}] = CurI;
}

View File

@ -802,6 +802,7 @@ ToolChain::TranslateOpenMPTargetArgs(const llvm::opt::DerivedArgList &Args,
if (DeviceOffloadKind == Action::OFK_OpenMP) {
DerivedArgList *DAL = new DerivedArgList(Args.getBaseArgs());
const OptTable &Opts = getDriver().getOpts();
bool NewArgAdded = false;
// Handle -Xopenmp-target flags
for (Arg *A : Args) {
@ -850,9 +851,10 @@ ToolChain::TranslateOpenMPTargetArgs(const llvm::opt::DerivedArgList &Args,
XOpenMPTargetArg->setBaseArg(A);
A = XOpenMPTargetArg.release();
DAL->append(A);
NewArgAdded = true;
}
return DAL;
return NewArgAdded ? DAL : nullptr;
}
return nullptr;

View File

@ -660,6 +660,16 @@
/// ###########################################################################
/// Check cubin file generation and usage by nvlink when toolchain has BindArchAction
// RUN: %clang -### -no-canonical-prefixes -target x86_64-apple-darwin17.0.0 -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda -save-temps -no-canonical-prefixes %s 2>&1 \
// RUN: | FileCheck -check-prefix=CHK-CUBIN-DARWIN %s
// CHK-CUBIN-DARWIN: clang{{.*}}" "-o" "{{.*}}-openmp-nvptx64-nvidia-cuda.s"
// CHK-CUBIN-DARWIN-NEXT: ptxas{{.*}}" "--output-file" "{{.*}}-openmp-nvptx64-nvidia-cuda.cubin" "{{.*}}-openmp-nvptx64-nvidia-cuda.s"
// CHK-CUBIN-DARWIN-NEXT: nvlink" "-o" "{{.*}}-openmp-nvptx64-nvidia-cuda" {{.*}} "openmp-offload-openmp-nvptx64-nvidia-cuda.cubin"
/// ###########################################################################
/// Check cubin file generation and usage by nvlink
// RUN: touch %t1.o
// RUN: touch %t2.o
@ -667,3 +677,13 @@
// RUN: | FileCheck -check-prefix=CHK-TWOCUBIN %s
// CHK-TWOCUBIN: nvlink"{{.*}}"openmp-offload-{{.*}}.cubin" "openmp-offload-{{.*}}.cubin"
/// ###########################################################################
/// Check cubin file generation and usage by nvlink when toolchain has BindArchAction
// RUN: touch %t1.o
// RUN: touch %t2.o
// RUN: %clang -### -no-canonical-prefixes -target x86_64-apple-darwin17.0.0 -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda %t1.o %t2.o 2>&1 \
// RUN: | FileCheck -check-prefix=CHK-TWOCUBIN-DARWIN %s
// CHK-TWOCUBIN-DARWIN: nvlink"{{.*}}"openmp-offload-{{.*}}.cubin" "openmp-offload-{{.*}}.cubin"