[PATCH] D122001: [NVPTX] Avoid a crash when 'llc' is called with '-filetype=null'

Igor Kudrin via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Mar 22 05:50:00 PDT 2022


This revision was automatically updated to reflect the committed changes.
Closed by commit rGd7681d9f77e0: [NVPTX] Avoid a crash when 'llc' is called with '-filetype=null' (authored by ikudrin).

Changed prior to commit:
  https://reviews.llvm.org/D122001?vs=416467&id=417259#toc

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D122001/new/

https://reviews.llvm.org/D122001

Files:
  llvm/lib/Target/NVPTX/NVPTXAsmPrinter.cpp
  llvm/test/CodeGen/NVPTX/filetype-null.ll


Index: llvm/test/CodeGen/NVPTX/filetype-null.ll
===================================================================
--- /dev/null
+++ llvm/test/CodeGen/NVPTX/filetype-null.ll
@@ -0,0 +1,4 @@
+; Check that 'llc' does not crash if '-filetype=null' is used.
+
+; RUN: llc %s -filetype=null -march=nvptx -o -
+; RUN: llc %s -filetype=null -march=nvptx64 -o -
Index: llvm/lib/Target/NVPTX/NVPTXAsmPrinter.cpp
===================================================================
--- llvm/lib/Target/NVPTX/NVPTXAsmPrinter.cpp
+++ llvm/lib/Target/NVPTX/NVPTXAsmPrinter.cpp
@@ -888,17 +888,18 @@
 
   clearAnnotationCache(&M);
 
-  // Close the last emitted section
-  if (HasDebugInfo) {
-    static_cast<NVPTXTargetStreamer *>(OutStreamer->getTargetStreamer())
-        ->closeLastSection();
-    // Emit empty .debug_loc section for better support of the empty files.
-    OutStreamer->emitRawText("\t.section\t.debug_loc\t{\t}");
-  }
+  if (auto *TS = static_cast<NVPTXTargetStreamer *>(
+          OutStreamer->getTargetStreamer())) {
+    // Close the last emitted section
+    if (HasDebugInfo) {
+      TS->closeLastSection();
+      // Emit empty .debug_loc section for better support of the empty files.
+      OutStreamer->emitRawText("\t.section\t.debug_loc\t{\t}");
+    }
 
-  // Output last DWARF .file directives, if any.
-  static_cast<NVPTXTargetStreamer *>(OutStreamer->getTargetStreamer())
-      ->outputDwarfFileDirectives();
+    // Output last DWARF .file directives, if any.
+    TS->outputDwarfFileDirectives();
+  }
 
   return ret;
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D122001.417259.patch
Type: text/x-patch
Size: 1553 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220322/940ca951/attachment.bin>


More information about the llvm-commits mailing list