[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
Fri Mar 18 05:25:31 PDT 2022
ikudrin created this revision.
ikudrin added reviewers: jholewinski, MaskRay, ABataev, echristo.
ikudrin added a project: LLVM.
Herald added a subscriber: hiraditya.
Herald added a project: All.
ikudrin requested review of this revision.
For `-filetype=null`, `NVPTXTargetStreamer` is not created, so the return value of `OutStreamer->getTargetStreamer()` should be checked before calling the methods.
This fixes a crash in `llvm/test/tools/llc/binutils-version.ll` when LLVM is built with `nvptx64-nvidia-cuda` as a default target.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D122001
Files:
llvm/lib/Target/NVPTX/NVPTXAsmPrinter.cpp
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.416467.patch
Type: text/x-patch
Size: 1198 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220318/febbab12/attachment.bin>
More information about the llvm-commits
mailing list