-
Notifications
You must be signed in to change notification settings - Fork 13.3k
[COFF] Preserve UniqueID used to create MCSectionCOFF #123869
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
This UniqueID can be used later to create associative section. e.g. A .pseudo_probe associated to the section of the corresponding function.
@llvm/pr-subscribers-backend-x86 @llvm/pr-subscribers-mc Author: Haohai Wen (HaohaiWen) ChangesThis UniqueID can be used later to create associative section. Full diff: https://github.com/llvm/llvm-project/pull/123869.diff 2 Files Affected:
diff --git a/llvm/include/llvm/MC/MCSectionCOFF.h b/llvm/include/llvm/MC/MCSectionCOFF.h
index 97540d985dbd1d..9c79c27f2a9152 100644
--- a/llvm/include/llvm/MC/MCSectionCOFF.h
+++ b/llvm/include/llvm/MC/MCSectionCOFF.h
@@ -47,16 +47,19 @@ class MCSectionCOFF final : public MCSection {
/// section (Characteristics & IMAGE_SCN_LNK_COMDAT) != 0
mutable int Selection;
+ unsigned UniqueID;
+
private:
friend class MCContext;
// The storage of Name is owned by MCContext's COFFUniquingMap.
MCSectionCOFF(StringRef Name, unsigned Characteristics,
- MCSymbol *COMDATSymbol, int Selection, MCSymbol *Begin)
+ MCSymbol *COMDATSymbol, int Selection, unsigned UniqueID,
+ MCSymbol *Begin)
: MCSection(SV_COFF, Name, Characteristics & COFF::IMAGE_SCN_CNT_CODE,
Characteristics & COFF::IMAGE_SCN_CNT_UNINITIALIZED_DATA,
Begin),
Characteristics(Characteristics), COMDATSymbol(COMDATSymbol),
- Selection(Selection) {
+ Selection(Selection), UniqueID(UniqueID) {
assert((Characteristics & 0x00F00000) == 0 &&
"alignment must not be set upon section creation");
}
@@ -72,6 +75,8 @@ class MCSectionCOFF final : public MCSection {
void setSelection(int Selection) const;
+ unsigned getUniqueID() const { return UniqueID; }
+
void printSwitchToSection(const MCAsmInfo &MAI, const Triple &T,
raw_ostream &OS,
uint32_t Subsection) const override;
diff --git a/llvm/lib/MC/MCContext.cpp b/llvm/lib/MC/MCContext.cpp
index 46222fcaa5b152..56aba5de4445e4 100644
--- a/llvm/lib/MC/MCContext.cpp
+++ b/llvm/lib/MC/MCContext.cpp
@@ -718,7 +718,7 @@ MCSectionCOFF *MCContext::getCOFFSection(StringRef Section,
StringRef CachedName = Iter->first.SectionName;
MCSymbol *Begin = getOrCreateSectionSymbol<MCSymbolCOFF>(Section);
MCSectionCOFF *Result = new (COFFAllocator.Allocate()) MCSectionCOFF(
- CachedName, Characteristics, COMDATSymbol, Selection, Begin);
+ CachedName, Characteristics, COMDATSymbol, Selection, UniqueID, Begin);
Iter->second = Result;
auto *F = allocInitialFragment(*Result);
Begin->setFragment(F);
|
Best to add @mstorsjo might be interested in ensuring gas compatibility. |
Is there any specification about COFF .section directive? |
Let's revive this PR. Any comments? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM.
This UniqueID can be used later to create associative section.
e.g. A .pseudo_probe associated to the section of the corresponding
function.