Skip to content

Commit cf311a1

Browse files
author
Mogball
committed
[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.
1 parent dac3661 commit cf311a1

File tree

3 files changed

+6
-2
lines changed

3 files changed

+6
-2
lines changed

llvm/lib/Target/NVPTX/MCTargetDesc/NVPTXTargetStreamer.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,10 @@ void NVPTXTargetStreamer::changeSection(const MCSection *CurSection,
8888
assert(!SubSection && "SubSection is not null!");
8989
const MCObjectFileInfo *FI = getStreamer().getContext().getObjectFileInfo();
9090
// Emit closing brace for DWARF sections only.
91-
if (isDwarfSection(FI, CurSection))
91+
if (isDwarfSection(FI, CurSection) && HasDWARFSections) {
92+
HasDWARFSections = false;
9293
OS << "\t}\n";
94+
}
9395
if (isDwarfSection(FI, Section)) {
9496
// Emit DWARF .file directives in the outermost scope.
9597
outputDwarfFileDirectives();
@@ -100,6 +102,7 @@ void NVPTXTargetStreamer::changeSection(const MCSection *CurSection,
100102
// DWARF sections are enclosed into braces - emit the open one.
101103
OS << "\t{\n";
102104
HasSections = true;
105+
HasDWARFSections = true;
103106
}
104107
}
105108

llvm/lib/Target/NVPTX/MCTargetDesc/NVPTXTargetStreamer.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ class NVPTXTargetStreamer : public MCTargetStreamer {
1919
private:
2020
SmallVector<std::string, 4> DwarfFiles;
2121
bool HasSections = false;
22+
bool HasDWARFSections = false;
2223

2324
public:
2425
NVPTXTargetStreamer(MCStreamer &S);

llvm/test/DebugInfo/NVPTX/cu-range-hole.ll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
; CHECK: $L__func_end2:
3737
; CHECK: }
3838

39-
; CHECK: .file 1 "{{.*}}b.c"
39+
; CHECK-NEXT: .file 1 "{{.*}}b.c"
4040

4141
; Function Attrs: nounwind uwtable
4242
define i32 @b(i32 %c) #0 !dbg !5 {

0 commit comments

Comments
 (0)