[llvm] 4ae23bc - [NVPTX] Correct the condition to print "\t}\n" for DWARF sections
Fangrui Song via llvm-commits
llvm-commits at lists.llvm.org
Fri Jun 28 14:15:41 PDT 2024
Author: Fangrui Song
Date: 2024-06-28T14:15:36-07:00
New Revision: 4ae23bcca144b542f16d45acc8f270e156e2fa4e
URL: https://github.com/llvm/llvm-project/commit/4ae23bcca144b542f16d45acc8f270e156e2fa4e
DIFF: https://github.com/llvm/llvm-project/commit/4ae23bcca144b542f16d45acc8f270e156e2fa4e.diff
LOG: [NVPTX] Correct the condition to print "\t}\n" for DWARF sections
`NVPTXTargetStreamer::changeSection` needs `CurSection` to properly
print "\t}\n" for DWARF sections.
db48f1a1764023f8efeb055e343b967d1eb37d19 added
`MCStreamer::changeSection` before `TS->changeSection`,
making `CurSection == Section` when `getCurrentSectionOnly` switches to
`CurFrag` (626eef5ecf92e98cbfccfa6134e0a760e7592813).
cf311a1131b9aef3e66b2a20ad49cfc77212754b did fix the bug, but the
mechanism is confusing. Fix it using nullable getCurrentSectionOnly().
Added:
Modified:
llvm/lib/MC/MCAsmStreamer.cpp
llvm/lib/Target/NVPTX/MCTargetDesc/NVPTXTargetStreamer.cpp
llvm/lib/Target/NVPTX/MCTargetDesc/NVPTXTargetStreamer.h
Removed:
################################################################################
diff --git a/llvm/lib/MC/MCAsmStreamer.cpp b/llvm/lib/MC/MCAsmStreamer.cpp
index 038217e023d44..df5cedb27b8f6 100644
--- a/llvm/lib/MC/MCAsmStreamer.cpp
+++ b/llvm/lib/MC/MCAsmStreamer.cpp
@@ -511,13 +511,13 @@ void MCAsmStreamer::emitExplicitComments() {
}
void MCAsmStreamer::changeSection(MCSection *Section, uint32_t Subsection) {
- MCStreamer::changeSection(Section, Subsection);
if (MCTargetStreamer *TS = getTargetStreamer()) {
- TS->changeSection(getCurrentSectionOnly(), Section, Subsection, OS);
+ TS->changeSection(getCurrentSection().first, Section, Subsection, OS);
} else {
Section->printSwitchToSection(*MAI, getContext().getTargetTriple(), OS,
Subsection);
}
+ MCStreamer::changeSection(Section, Subsection);
}
void MCAsmStreamer::emitELFSymverDirective(const MCSymbol *OriginalSym,
diff --git a/llvm/lib/Target/NVPTX/MCTargetDesc/NVPTXTargetStreamer.cpp b/llvm/lib/Target/NVPTX/MCTargetDesc/NVPTXTargetStreamer.cpp
index 50bc4742e1891..fc207b1a8871a 100644
--- a/llvm/lib/Target/NVPTX/MCTargetDesc/NVPTXTargetStreamer.cpp
+++ b/llvm/lib/Target/NVPTX/MCTargetDesc/NVPTXTargetStreamer.cpp
@@ -88,10 +88,8 @@ 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) && HasDWARFSections) {
- HasDWARFSections = false;
+ if (isDwarfSection(FI, CurSection))
OS << "\t}\n";
- }
if (isDwarfSection(FI, Section)) {
// Emit DWARF .file directives in the outermost scope.
outputDwarfFileDirectives();
@@ -102,7 +100,6 @@ 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 5a23f37e2dd5d..ca0d84ee2079a 100644
--- a/llvm/lib/Target/NVPTX/MCTargetDesc/NVPTXTargetStreamer.h
+++ b/llvm/lib/Target/NVPTX/MCTargetDesc/NVPTXTargetStreamer.h
@@ -19,7 +19,6 @@ class NVPTXTargetStreamer : public MCTargetStreamer {
private:
SmallVector<std::string, 4> DwarfFiles;
bool HasSections = false;
- bool HasDWARFSections = false;
public:
NVPTXTargetStreamer(MCStreamer &S);
More information about the llvm-commits
mailing list