[llvm] cf311a1 - [NVPTX] Fix DWARF section printing
via llvm-commits
llvm-commits at lists.llvm.org
Fri Jun 28 10:56:25 PDT 2024
Author: Mogball
Date: 2024-06-28T17:56:16Z
New Revision: cf311a1131b9aef3e66b2a20ad49cfc77212754b
URL: https://github.com/llvm/llvm-project/commit/cf311a1131b9aef3e66b2a20ad49cfc77212754b
DIFF: https://github.com/llvm/llvm-project/commit/cf311a1131b9aef3e66b2a20ad49cfc77212754b.diff
LOG: [NVPTX] Fix DWARF section printing
There was a lot of changes to MC recently, so I'm no longer sure what is
the root cause here, but the NVPTX DWARF printing was printing an
extra closing brace, causing the PTX to be invalid. This should fix it
by only printing the closing brace when the printer has already seen an
opening brace for a DWARF section.
Added:
Modified:
llvm/lib/Target/NVPTX/MCTargetDesc/NVPTXTargetStreamer.cpp
llvm/lib/Target/NVPTX/MCTargetDesc/NVPTXTargetStreamer.h
llvm/test/DebugInfo/NVPTX/cu-range-hole.ll
Removed:
################################################################################
diff --git a/llvm/lib/Target/NVPTX/MCTargetDesc/NVPTXTargetStreamer.cpp b/llvm/lib/Target/NVPTX/MCTargetDesc/NVPTXTargetStreamer.cpp
index fc207b1a8871a..50bc4742e1891 100644
--- a/llvm/lib/Target/NVPTX/MCTargetDesc/NVPTXTargetStreamer.cpp
+++ b/llvm/lib/Target/NVPTX/MCTargetDesc/NVPTXTargetStreamer.cpp
@@ -88,8 +88,10 @@ void NVPTXTargetStreamer::changeSection(const MCSection *CurSection,
assert(!SubSection && "SubSection is not null!");
const MCObjectFileInfo *FI = getStreamer().getContext().getObjectFileInfo();
// Emit closing brace for DWARF sections only.
- if (isDwarfSection(FI, CurSection))
+ if (isDwarfSection(FI, CurSection) && HasDWARFSections) {
+ HasDWARFSections = false;
OS << "\t}\n";
+ }
if (isDwarfSection(FI, Section)) {
// Emit DWARF .file directives in the outermost scope.
outputDwarfFileDirectives();
@@ -100,6 +102,7 @@ void NVPTXTargetStreamer::changeSection(const MCSection *CurSection,
// DWARF sections are enclosed into braces - emit the open one.
OS << "\t{\n";
HasSections = true;
+ HasDWARFSections = true;
}
}
diff --git a/llvm/lib/Target/NVPTX/MCTargetDesc/NVPTXTargetStreamer.h b/llvm/lib/Target/NVPTX/MCTargetDesc/NVPTXTargetStreamer.h
index ca0d84ee2079a..5a23f37e2dd5d 100644
--- a/llvm/lib/Target/NVPTX/MCTargetDesc/NVPTXTargetStreamer.h
+++ b/llvm/lib/Target/NVPTX/MCTargetDesc/NVPTXTargetStreamer.h
@@ -19,6 +19,7 @@ class NVPTXTargetStreamer : public MCTargetStreamer {
private:
SmallVector<std::string, 4> DwarfFiles;
bool HasSections = false;
+ bool HasDWARFSections = false;
public:
NVPTXTargetStreamer(MCStreamer &S);
diff --git a/llvm/test/DebugInfo/NVPTX/cu-range-hole.ll b/llvm/test/DebugInfo/NVPTX/cu-range-hole.ll
index 76b6a47e885d9..4ae0b78f160c8 100644
--- a/llvm/test/DebugInfo/NVPTX/cu-range-hole.ll
+++ b/llvm/test/DebugInfo/NVPTX/cu-range-hole.ll
@@ -36,7 +36,7 @@
; CHECK: $L__func_end2:
; CHECK: }
-; CHECK: .file 1 "{{.*}}b.c"
+; CHECK-NEXT: .file 1 "{{.*}}b.c"
; Function Attrs: nounwind uwtable
define i32 @b(i32 %c) #0 !dbg !5 {
More information about the llvm-commits
mailing list