aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/Driver/Tools.cpp
diff options
context:
space:
mode:
authorArtem Belevich <tra@google.com>2016-02-16 22:03:20 +0000
committerArtem Belevich <tra@google.com>2016-02-16 22:03:20 +0000
commit0a0e54c194f68a56521048f82b530a1989a3cda7 (patch)
tree7c602aa2581952da145421bcca10b4f2341d9532 /clang/lib/Driver/Tools.cpp
parent25628d3362b76b066d7baf7e68205e746db1d5f4 (diff)
downloadllvm-0a0e54c194f68a56521048f82b530a1989a3cda7.zip
llvm-0a0e54c194f68a56521048f82b530a1989a3cda7.tar.gz
llvm-0a0e54c194f68a56521048f82b530a1989a3cda7.tar.bz2
[CUDA] pass debug options to ptxas.
ptxas optimizations are disabled if we need to generate debug info as ptxas does not accept '-g' otherwise. Differential Revision: http://reviews.llvm.org/D17111 llvm-svn: 261018
Diffstat (limited to 'clang/lib/Driver/Tools.cpp')
-rw-r--r--clang/lib/Driver/Tools.cpp20
1 files changed, 11 insertions, 9 deletions
diff --git a/clang/lib/Driver/Tools.cpp b/clang/lib/Driver/Tools.cpp
index 44d6b84..1599367 100644
--- a/clang/lib/Driver/Tools.cpp
+++ b/clang/lib/Driver/Tools.cpp
@@ -10691,15 +10691,20 @@ void NVPTX::Assembler::ConstructJob(Compilation &C, const JobAction &JA,
assert(gpu_archs.size() == 1 && "Exactly one GPU Arch required for ptxas.");
const std::string& gpu_arch = gpu_archs[0];
-
ArgStringList CmdArgs;
CmdArgs.push_back(TC.getTriple().isArch64Bit() ? "-m64" : "-m32");
+ if (Args.getLastArg(options::OPT_cuda_noopt_device_debug)) {
+ // ptxas does not accept -g option if optimization is enabled, so
+ // we ignore the compiler's -O* options if we want debug info.
+ CmdArgs.push_back("-g");
+ CmdArgs.push_back("--dont-merge-basicblocks");
+ CmdArgs.push_back("--return-at-end");
+ } else if (Arg *A = Args.getLastArg(options::OPT_O_Group)) {
+ // Map the -O we received to -O{0,1,2,3}.
+ //
+ // TODO: Perhaps we should map host -O2 to ptxas -O3. -O3 is ptxas's
+ // default, so it may correspond more closely to the spirit of clang -O2.
- // Map the -O we received to -O{0,1,2,3}.
- //
- // TODO: Perhaps we should map host -O2 to ptxas -O3. -O3 is ptxas's default,
- // so it may correspond more closely to the spirit of clang -O2.
- if (Arg *A = Args.getLastArg(options::OPT_O_Group)) {
// -O3 seems like the least-bad option when -Osomething is specified to
// clang but it isn't handled below.
StringRef OOpt = "3";
@@ -10725,9 +10730,6 @@ void NVPTX::Assembler::ConstructJob(Compilation &C, const JobAction &JA,
CmdArgs.push_back("-O0");
}
- // Don't bother passing -g to ptxas: It's enabled by default at -O0, and
- // not supported at other optimization levels.
-
CmdArgs.push_back("--gpu-name");
CmdArgs.push_back(Args.MakeArgString(gpu_arch));
CmdArgs.push_back("--output-file");