Skip to content

Commit 4ae23bc

Browse files
committed
[NVPTX] Correct the condition to print "\t}\n" for DWARF sections
`NVPTXTargetStreamer::changeSection` needs `CurSection` to properly print "\t}\n" for DWARF sections. db48f1a added `MCStreamer::changeSection` before `TS->changeSection`, making `CurSection == Section` when `getCurrentSectionOnly` switches to `CurFrag` (626eef5). cf311a1 did fix the bug, but the mechanism is confusing. Fix it using nullable getCurrentSectionOnly().
1 parent a8b7227 commit 4ae23bc

File tree

3 files changed

+3
-7
lines changed

3 files changed

+3
-7
lines changed

llvm/lib/MC/MCAsmStreamer.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -511,13 +511,13 @@ void MCAsmStreamer::emitExplicitComments() {
511511
}
512512

513513
void MCAsmStreamer::changeSection(MCSection *Section, uint32_t Subsection) {
514-
MCStreamer::changeSection(Section, Subsection);
515514
if (MCTargetStreamer *TS = getTargetStreamer()) {
516-
TS->changeSection(getCurrentSectionOnly(), Section, Subsection, OS);
515+
TS->changeSection(getCurrentSection().first, Section, Subsection, OS);
517516
} else {
518517
Section->printSwitchToSection(*MAI, getContext().getTargetTriple(), OS,
519518
Subsection);
520519
}
520+
MCStreamer::changeSection(Section, Subsection);
521521
}
522522

523523
void MCAsmStreamer::emitELFSymverDirective(const MCSymbol *OriginalSym,

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

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -88,10 +88,8 @@ 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) && HasDWARFSections) {
92-
HasDWARFSections = false;
91+
if (isDwarfSection(FI, CurSection))
9392
OS << "\t}\n";
94-
}
9593
if (isDwarfSection(FI, Section)) {
9694
// Emit DWARF .file directives in the outermost scope.
9795
outputDwarfFileDirectives();
@@ -102,7 +100,6 @@ void NVPTXTargetStreamer::changeSection(const MCSection *CurSection,
102100
// DWARF sections are enclosed into braces - emit the open one.
103101
OS << "\t{\n";
104102
HasSections = true;
105-
HasDWARFSections = true;
106103
}
107104
}
108105

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

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

2423
public:
2524
NVPTXTargetStreamer(MCStreamer &S);

0 commit comments

Comments
 (0)