[PATCH] D94123: [NVPTX] Strip debugging symbols for optimized NVPTX targets.

Joseph Huber via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Jan 5 14:33:12 PST 2021


jhuber6 created this revision.
jhuber6 added a reviewer: jdoerfert.
jhuber6 added a project: LLVM.
Herald added subscribers: hiraditya, jholewinski.
jhuber6 requested review of this revision.
Herald added a subscriber: llvm-commits.

Optimized debugging is not supported by ptxas. If the user requests an optimized build with debugging symbols present it will cause a crash in the compiler pipeline. Strip debug symbols unconditionally if optimization is requested. This solves https://bugs.llvm.org/show_bug.cgi?id=48153.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D94123

Files:
  llvm/lib/Target/NVPTX/NVPTXTargetMachine.cpp


Index: llvm/lib/Target/NVPTX/NVPTXTargetMachine.cpp
===================================================================
--- llvm/lib/Target/NVPTX/NVPTXTargetMachine.cpp
+++ llvm/lib/Target/NVPTX/NVPTXTargetMachine.cpp
@@ -28,6 +28,7 @@
 #include "llvm/Support/TargetRegistry.h"
 #include "llvm/Target/TargetMachine.h"
 #include "llvm/Target/TargetOptions.h"
+#include "llvm/Transforms/IPO.h"
 #include "llvm/Transforms/IPO/PassManagerBuilder.h"
 #include "llvm/Transforms/Scalar.h"
 #include "llvm/Transforms/Scalar/GVN.h"
@@ -203,6 +204,15 @@
       PM.add(createNVVMReflectPass(Subtarget.getSmVersion()));
       PM.add(createNVVMIntrRangePass(Subtarget.getSmVersion()));
     });
+
+  // Optimized debugging is not supported by ptxas. Strip all debugging
+  // information in the IR if optimizations are set.
+  Builder.addGlobalExtension(
+      PassManagerBuilder::EP_CGSCCOptimizerLate,
+      [&](const PassManagerBuilder &PMB, legacy::PassManagerBase &PM) {
+        if (PMB.OptLevel > 0)
+          PM.add(createStripSymbolsPass(/*OnlyDebugInfo*/ true));
+      });
 }
 
 TargetTransformInfo


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D94123.314723.patch
Type: text/x-patch
Size: 1101 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210105/4998fe0d/attachment.bin>


More information about the llvm-commits mailing list