[llvm] Reapply "[aarch64][win] Add support for import call optimization (equivalent to MSVC /d2ImportCallOptimization) (#121516)" (PR #122777)
via llvm-commits
llvm-commits at lists.llvm.org
Mon Jan 13 11:51:51 PST 2025
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-backend-aarch64
Author: Daniel Paoliello (dpaoliello)
<details>
<summary>Changes</summary>
This reverts commit 2f7ade4b5e399962e18f5f9a0ab0b7335deece51.
Fix is available in #<!-- -->122762
---
Patch is 47.51 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/122777.diff
25 Files Affected:
- (modified) llvm/include/llvm/CodeGen/MIRYamlMapping.h (+35-10)
- (modified) llvm/include/llvm/CodeGen/MachineFunction.h (+25)
- (modified) llvm/include/llvm/CodeGen/SelectionDAG.h (+14)
- (modified) llvm/include/llvm/MC/MCObjectFileInfo.h (+5)
- (modified) llvm/include/llvm/MC/MCStreamer.h (+8)
- (modified) llvm/include/llvm/MC/MCWinCOFFObjectWriter.h (+1)
- (modified) llvm/include/llvm/MC/MCWinCOFFStreamer.h (+2)
- (modified) llvm/lib/CodeGen/MIRParser/MIRParser.cpp (+62-12)
- (modified) llvm/lib/CodeGen/MIRPrinter.cpp (+32-1)
- (modified) llvm/lib/CodeGen/SelectionDAG/ScheduleDAGSDNodes.cpp (+4)
- (modified) llvm/lib/MC/MCAsmStreamer.cpp (+14)
- (modified) llvm/lib/MC/MCObjectFileInfo.cpp (+5)
- (modified) llvm/lib/MC/MCParser/COFFAsmParser.cpp (+34)
- (modified) llvm/lib/MC/MCStreamer.cpp (+4)
- (modified) llvm/lib/MC/MCWinCOFFStreamer.cpp (+114)
- (modified) llvm/lib/MC/WinCOFFObjectWriter.cpp (+18-9)
- (modified) llvm/lib/Target/AArch64/AArch64AsmPrinter.cpp (+72)
- (modified) llvm/lib/Target/AArch64/AArch64ISelLowering.cpp (+10-4)
- (added) llvm/test/CodeGen/AArch64/win-import-call-optimization-nocalls.ll (+18)
- (added) llvm/test/CodeGen/AArch64/win-import-call-optimization.ll (+48)
- (added) llvm/test/CodeGen/MIR/AArch64/called-globals.mir (+61)
- (modified) llvm/test/CodeGen/MIR/X86/call-site-info-error1.mir (+1-1)
- (modified) llvm/test/CodeGen/MIR/X86/call-site-info-error2.mir (+1-1)
- (added) llvm/test/MC/AArch64/win-import-call-optimization.s (+72)
- (added) llvm/test/MC/COFF/bad-parse.s (+13)
``````````diff
diff --git a/llvm/include/llvm/CodeGen/MIRYamlMapping.h b/llvm/include/llvm/CodeGen/MIRYamlMapping.h
index 09a6ca936fe1f4..dbad3469d047d2 100644
--- a/llvm/include/llvm/CodeGen/MIRYamlMapping.h
+++ b/llvm/include/llvm/CodeGen/MIRYamlMapping.h
@@ -457,6 +457,16 @@ template <> struct ScalarTraits<FrameIndex> {
static QuotingType mustQuote(StringRef S) { return needsQuotes(S); }
};
+/// Identifies call instruction location in machine function.
+struct MachineInstrLoc {
+ unsigned BlockNum;
+ unsigned Offset;
+
+ bool operator==(const MachineInstrLoc &Other) const {
+ return BlockNum == Other.BlockNum && Offset == Other.Offset;
+ }
+};
+
/// Serializable representation of CallSiteInfo.
struct CallSiteInfo {
// Representation of call argument and register which is used to
@@ -470,16 +480,6 @@ struct CallSiteInfo {
}
};
- /// Identifies call instruction location in machine function.
- struct MachineInstrLoc {
- unsigned BlockNum;
- unsigned Offset;
-
- bool operator==(const MachineInstrLoc &Other) const {
- return BlockNum == Other.BlockNum && Offset == Other.Offset;
- }
- };
-
MachineInstrLoc CallLocation;
std::vector<ArgRegPair> ArgForwardingRegs;
@@ -595,6 +595,26 @@ template <> struct MappingTraits<MachineJumpTable::Entry> {
}
};
+struct CalledGlobal {
+ MachineInstrLoc CallSite;
+ StringValue Callee;
+ unsigned Flags;
+
+ bool operator==(const CalledGlobal &Other) const {
+ return CallSite == Other.CallSite && Callee == Other.Callee &&
+ Flags == Other.Flags;
+ }
+};
+
+template <> struct MappingTraits<CalledGlobal> {
+ static void mapping(IO &YamlIO, CalledGlobal &CG) {
+ YamlIO.mapRequired("bb", CG.CallSite.BlockNum);
+ YamlIO.mapRequired("offset", CG.CallSite.Offset);
+ YamlIO.mapRequired("callee", CG.Callee);
+ YamlIO.mapRequired("flags", CG.Flags);
+ }
+};
+
} // end namespace yaml
} // end namespace llvm
@@ -606,6 +626,7 @@ LLVM_YAML_IS_SEQUENCE_VECTOR(llvm::yaml::FixedMachineStackObject)
LLVM_YAML_IS_SEQUENCE_VECTOR(llvm::yaml::CallSiteInfo)
LLVM_YAML_IS_SEQUENCE_VECTOR(llvm::yaml::MachineConstantPoolValue)
LLVM_YAML_IS_SEQUENCE_VECTOR(llvm::yaml::MachineJumpTable::Entry)
+LLVM_YAML_IS_SEQUENCE_VECTOR(llvm::yaml::CalledGlobal)
namespace llvm {
namespace yaml {
@@ -764,6 +785,7 @@ struct MachineFunction {
std::vector<DebugValueSubstitution> DebugValueSubstitutions;
MachineJumpTable JumpTableInfo;
std::vector<StringValue> MachineMetadataNodes;
+ std::vector<CalledGlobal> CalledGlobals;
BlockStringValue Body;
};
@@ -822,6 +844,9 @@ template <> struct MappingTraits<MachineFunction> {
if (!YamlIO.outputting() || !MF.MachineMetadataNodes.empty())
YamlIO.mapOptional("machineMetadataNodes", MF.MachineMetadataNodes,
std::vector<StringValue>());
+ if (!YamlIO.outputting() || !MF.CalledGlobals.empty())
+ YamlIO.mapOptional("calledGlobals", MF.CalledGlobals,
+ std::vector<CalledGlobal>());
YamlIO.mapOptional("body", MF.Body, BlockStringValue());
}
};
diff --git a/llvm/include/llvm/CodeGen/MachineFunction.h b/llvm/include/llvm/CodeGen/MachineFunction.h
index d696add8a1af53..282aee2a69c4d9 100644
--- a/llvm/include/llvm/CodeGen/MachineFunction.h
+++ b/llvm/include/llvm/CodeGen/MachineFunction.h
@@ -354,6 +354,11 @@ class LLVM_ABI MachineFunction {
/// a table of valid targets for Windows EHCont Guard.
std::vector<MCSymbol *> CatchretTargets;
+ /// Mapping of call instruction to the global value and target flags that it
+ /// calls, if applicable.
+ DenseMap<const MachineInstr *, std::pair<const GlobalValue *, unsigned>>
+ CalledGlobalsMap;
+
/// \name Exception Handling
/// \{
@@ -1182,6 +1187,26 @@ class LLVM_ABI MachineFunction {
CatchretTargets.push_back(Target);
}
+ /// Tries to get the global and target flags for a call site, if the
+ /// instruction is a call to a global.
+ std::pair<const GlobalValue *, unsigned>
+ tryGetCalledGlobal(const MachineInstr *MI) const {
+ return CalledGlobalsMap.lookup(MI);
+ }
+
+ /// Notes the global and target flags for a call site.
+ void addCalledGlobal(const MachineInstr *MI,
+ std::pair<const GlobalValue *, unsigned> Details) {
+ assert(MI && "MI must not be null");
+ assert(Details.first && "Global must not be null");
+ CalledGlobalsMap.insert({MI, Details});
+ }
+
+ /// Iterates over the full set of call sites and their associated globals.
+ auto getCalledGlobals() const {
+ return llvm::make_range(CalledGlobalsMap.begin(), CalledGlobalsMap.end());
+ }
+
/// \name Exception Handling
/// \{
diff --git a/llvm/include/llvm/CodeGen/SelectionDAG.h b/llvm/include/llvm/CodeGen/SelectionDAG.h
index ff7caec41855fd..b31ad11c3ee0ee 100644
--- a/llvm/include/llvm/CodeGen/SelectionDAG.h
+++ b/llvm/include/llvm/CodeGen/SelectionDAG.h
@@ -293,6 +293,7 @@ class SelectionDAG {
MDNode *HeapAllocSite = nullptr;
MDNode *PCSections = nullptr;
MDNode *MMRA = nullptr;
+ std::pair<const GlobalValue *, unsigned> CalledGlobal{};
bool NoMerge = false;
};
/// Out-of-line extra information for SDNodes.
@@ -2373,6 +2374,19 @@ class SelectionDAG {
auto It = SDEI.find(Node);
return It != SDEI.end() ? It->second.MMRA : nullptr;
}
+ /// Set CalledGlobal to be associated with Node.
+ void addCalledGlobal(const SDNode *Node, const GlobalValue *GV,
+ unsigned OpFlags) {
+ SDEI[Node].CalledGlobal = {GV, OpFlags};
+ }
+ /// Return CalledGlobal associated with Node, or a nullopt if none exists.
+ std::optional<std::pair<const GlobalValue *, unsigned>>
+ getCalledGlobal(const SDNode *Node) {
+ auto I = SDEI.find(Node);
+ return I != SDEI.end()
+ ? std::make_optional(std::move(I->second).CalledGlobal)
+ : std::nullopt;
+ }
/// Set NoMergeSiteInfo to be associated with Node if NoMerge is true.
void addNoMergeSiteInfo(const SDNode *Node, bool NoMerge) {
if (NoMerge)
diff --git a/llvm/include/llvm/MC/MCObjectFileInfo.h b/llvm/include/llvm/MC/MCObjectFileInfo.h
index e2a2c84e47910b..fb575fe721015c 100644
--- a/llvm/include/llvm/MC/MCObjectFileInfo.h
+++ b/llvm/include/llvm/MC/MCObjectFileInfo.h
@@ -73,6 +73,10 @@ class MCObjectFileInfo {
/// to emit them into.
MCSection *CompactUnwindSection = nullptr;
+ /// If import call optimization is supported by the target, this is the
+ /// section to emit import call data to.
+ MCSection *ImportCallSection = nullptr;
+
// Dwarf sections for debug info. If a target supports debug info, these must
// be set.
MCSection *DwarfAbbrevSection = nullptr;
@@ -269,6 +273,7 @@ class MCObjectFileInfo {
MCSection *getBSSSection() const { return BSSSection; }
MCSection *getReadOnlySection() const { return ReadOnlySection; }
MCSection *getLSDASection() const { return LSDASection; }
+ MCSection *getImportCallSection() const { return ImportCallSection; }
MCSection *getCompactUnwindSection() const { return CompactUnwindSection; }
MCSection *getDwarfAbbrevSection() const { return DwarfAbbrevSection; }
MCSection *getDwarfInfoSection() const { return DwarfInfoSection; }
diff --git a/llvm/include/llvm/MC/MCStreamer.h b/llvm/include/llvm/MC/MCStreamer.h
index 21da4dac4872b4..558b14cebfd3d1 100644
--- a/llvm/include/llvm/MC/MCStreamer.h
+++ b/llvm/include/llvm/MC/MCStreamer.h
@@ -569,6 +569,14 @@ class MCStreamer {
/// \param Symbol - Symbol the image relative relocation should point to.
virtual void emitCOFFImgRel32(MCSymbol const *Symbol, int64_t Offset);
+ /// Emits the physical number of the section containing the given symbol as
+ /// assigned during object writing (i.e., this is not a runtime relocation).
+ virtual void emitCOFFSecNumber(MCSymbol const *Symbol);
+
+ /// Emits the offset of the symbol from the beginning of the section during
+ /// object writing (i.e., this is not a runtime relocation).
+ virtual void emitCOFFSecOffset(MCSymbol const *Symbol);
+
/// Emits an lcomm directive with XCOFF csect information.
///
/// \param LabelSym - Label on the block of storage.
diff --git a/llvm/include/llvm/MC/MCWinCOFFObjectWriter.h b/llvm/include/llvm/MC/MCWinCOFFObjectWriter.h
index a4ede61e45099d..13d8c7d060c9ef 100644
--- a/llvm/include/llvm/MC/MCWinCOFFObjectWriter.h
+++ b/llvm/include/llvm/MC/MCWinCOFFObjectWriter.h
@@ -72,6 +72,7 @@ class WinCOFFObjectWriter final : public MCObjectWriter {
const MCFixup &Fixup, MCValue Target,
uint64_t &FixedValue) override;
uint64_t writeObject(MCAssembler &Asm) override;
+ int getSectionNumber(const MCSection &Section) const;
};
/// Construct a new Win COFF writer instance.
diff --git a/llvm/include/llvm/MC/MCWinCOFFStreamer.h b/llvm/include/llvm/MC/MCWinCOFFStreamer.h
index 5c39d80538944b..2425abe51e6dd9 100644
--- a/llvm/include/llvm/MC/MCWinCOFFStreamer.h
+++ b/llvm/include/llvm/MC/MCWinCOFFStreamer.h
@@ -58,6 +58,8 @@ class MCWinCOFFStreamer : public MCObjectStreamer {
void emitCOFFSectionIndex(MCSymbol const *Symbol) override;
void emitCOFFSecRel32(MCSymbol const *Symbol, uint64_t Offset) override;
void emitCOFFImgRel32(MCSymbol const *Symbol, int64_t Offset) override;
+ void emitCOFFSecNumber(MCSymbol const *Symbol) override;
+ void emitCOFFSecOffset(MCSymbol const *Symbol) override;
void emitCommonSymbol(MCSymbol *Symbol, uint64_t Size,
Align ByteAlignment) override;
void emitLocalCommonSymbol(MCSymbol *Symbol, uint64_t Size,
diff --git a/llvm/lib/CodeGen/MIRParser/MIRParser.cpp b/llvm/lib/CodeGen/MIRParser/MIRParser.cpp
index e2543f883f91ce..de2fe925c2d5c9 100644
--- a/llvm/lib/CodeGen/MIRParser/MIRParser.cpp
+++ b/llvm/lib/CodeGen/MIRParser/MIRParser.cpp
@@ -158,6 +158,9 @@ class MIRParserImpl {
MachineFunction &MF,
const yaml::MachineFunction &YMF);
+ bool parseCalledGlobals(PerFunctionMIParsingState &PFS, MachineFunction &MF,
+ const yaml::MachineFunction &YMF);
+
private:
bool parseMDNode(PerFunctionMIParsingState &PFS, MDNode *&Node,
const yaml::StringValue &Source);
@@ -183,6 +186,9 @@ class MIRParserImpl {
void setupDebugValueTracking(MachineFunction &MF,
PerFunctionMIParsingState &PFS, const yaml::MachineFunction &YamlMF);
+
+ bool parseMachineInst(MachineFunction &MF, yaml::MachineInstrLoc MILoc,
+ MachineInstr const *&MI);
};
} // end namespace llvm
@@ -457,24 +463,34 @@ bool MIRParserImpl::computeFunctionProperties(
return false;
}
+bool MIRParserImpl::parseMachineInst(MachineFunction &MF,
+ yaml::MachineInstrLoc MILoc,
+ MachineInstr const *&MI) {
+ if (MILoc.BlockNum >= MF.size()) {
+ return error(Twine(MF.getName()) +
+ Twine(" instruction block out of range.") +
+ " Unable to reference bb:" + Twine(MILoc.BlockNum));
+ }
+ auto BB = std::next(MF.begin(), MILoc.BlockNum);
+ if (MILoc.Offset >= BB->size())
+ return error(
+ Twine(MF.getName()) + Twine(" instruction offset out of range.") +
+ " Unable to reference instruction at bb: " + Twine(MILoc.BlockNum) +
+ " at offset:" + Twine(MILoc.Offset));
+ MI = &*std::next(BB->instr_begin(), MILoc.Offset);
+ return false;
+}
+
bool MIRParserImpl::initializeCallSiteInfo(
PerFunctionMIParsingState &PFS, const yaml::MachineFunction &YamlMF) {
MachineFunction &MF = PFS.MF;
SMDiagnostic Error;
const TargetMachine &TM = MF.getTarget();
for (auto &YamlCSInfo : YamlMF.CallSitesInfo) {
- yaml::CallSiteInfo::MachineInstrLoc MILoc = YamlCSInfo.CallLocation;
- if (MILoc.BlockNum >= MF.size())
- return error(Twine(MF.getName()) +
- Twine(" call instruction block out of range.") +
- " Unable to reference bb:" + Twine(MILoc.BlockNum));
- auto CallB = std::next(MF.begin(), MILoc.BlockNum);
- if (MILoc.Offset >= CallB->size())
- return error(Twine(MF.getName()) +
- Twine(" call instruction offset out of range.") +
- " Unable to reference instruction at bb: " +
- Twine(MILoc.BlockNum) + " at offset:" + Twine(MILoc.Offset));
- auto CallI = std::next(CallB->instr_begin(), MILoc.Offset);
+ yaml::MachineInstrLoc MILoc = YamlCSInfo.CallLocation;
+ const MachineInstr *CallI;
+ if (parseMachineInst(MF, MILoc, CallI))
+ return true;
if (!CallI->isCall(MachineInstr::IgnoreBundle))
return error(Twine(MF.getName()) +
Twine(" call site info should reference call "
@@ -641,6 +657,9 @@ MIRParserImpl::initializeMachineFunction(const yaml::MachineFunction &YamlMF,
if (initializeCallSiteInfo(PFS, YamlMF))
return true;
+ if (parseCalledGlobals(PFS, MF, YamlMF))
+ return true;
+
setupDebugValueTracking(MF, PFS, YamlMF);
MF.getSubtarget().mirFileLoaded(MF);
@@ -1111,6 +1130,37 @@ bool MIRParserImpl::parseMachineMetadataNodes(
return false;
}
+bool MIRParserImpl::parseCalledGlobals(PerFunctionMIParsingState &PFS,
+ MachineFunction &MF,
+ const yaml::MachineFunction &YMF) {
+ Function &F = MF.getFunction();
+ for (const auto &YamlCG : YMF.CalledGlobals) {
+ yaml::MachineInstrLoc MILoc = YamlCG.CallSite;
+ const MachineInstr *CallI;
+ if (parseMachineInst(MF, MILoc, CallI))
+ return true;
+ if (!CallI->isCall(MachineInstr::IgnoreBundle))
+ return error(Twine(MF.getName()) +
+ Twine(" called global should reference call "
+ "instruction. Instruction at bb:") +
+ Twine(MILoc.BlockNum) + " at offset:" + Twine(MILoc.Offset) +
+ " is not a call instruction");
+
+ auto Callee =
+ F.getParent()->getValueSymbolTable().lookup(YamlCG.Callee.Value);
+ if (!Callee)
+ return error(YamlCG.Callee.SourceRange.Start,
+ "use of undefined global '" + YamlCG.Callee.Value + "'");
+ if (!isa<GlobalValue>(Callee))
+ return error(YamlCG.Callee.SourceRange.Start,
+ "use of non-global value '" + YamlCG.Callee.Value + "'");
+
+ MF.addCalledGlobal(CallI, {cast<GlobalValue>(Callee), YamlCG.Flags});
+ }
+
+ return false;
+}
+
SMDiagnostic MIRParserImpl::diagFromMIStringDiag(const SMDiagnostic &Error,
SMRange SourceRange) {
assert(SourceRange.isValid() && "Invalid source range");
diff --git a/llvm/lib/CodeGen/MIRPrinter.cpp b/llvm/lib/CodeGen/MIRPrinter.cpp
index c8f6341c1224d2..b6da495590fe11 100644
--- a/llvm/lib/CodeGen/MIRPrinter.cpp
+++ b/llvm/lib/CodeGen/MIRPrinter.cpp
@@ -133,6 +133,9 @@ class MIRPrinter {
void convertMachineMetadataNodes(yaml::MachineFunction &YMF,
const MachineFunction &MF,
MachineModuleSlotTracker &MST);
+ void convertCalledGlobals(yaml::MachineFunction &YMF,
+ const MachineFunction &MF,
+ MachineModuleSlotTracker &MST);
private:
void initRegisterMaskIds(const MachineFunction &MF);
@@ -269,6 +272,8 @@ void MIRPrinter::print(const MachineFunction &MF) {
// function.
convertMachineMetadataNodes(YamlMF, MF, MST);
+ convertCalledGlobals(YamlMF, MF, MST);
+
yaml::Output Out(OS);
if (!SimplifyMIR)
Out.setWriteDefaultValues(true);
@@ -555,7 +560,7 @@ void MIRPrinter::convertCallSiteObjects(yaml::MachineFunction &YMF,
const auto *TRI = MF.getSubtarget().getRegisterInfo();
for (auto CSInfo : MF.getCallSitesInfo()) {
yaml::CallSiteInfo YmlCS;
- yaml::CallSiteInfo::MachineInstrLoc CallLocation;
+ yaml::MachineInstrLoc CallLocation;
// Prepare instruction position.
MachineBasicBlock::const_instr_iterator CallI = CSInfo.first->getIterator();
@@ -596,6 +601,32 @@ void MIRPrinter::convertMachineMetadataNodes(yaml::MachineFunction &YMF,
}
}
+void MIRPrinter::convertCalledGlobals(yaml::MachineFunction &YMF,
+ const MachineFunction &MF,
+ MachineModuleSlotTracker &MST) {
+ for (const auto &[CallInst, CG] : MF.getCalledGlobals()) {
+ // If the call instruction was dropped, then we don't need to print it.
+ auto BB = CallInst->getParent();
+ if (BB) {
+ yaml::MachineInstrLoc CallSite;
+ CallSite.BlockNum = CallInst->getParent()->getNumber();
+ CallSite.Offset = std::distance(CallInst->getParent()->instr_begin(),
+ CallInst->getIterator());
+
+ yaml::CalledGlobal YamlCG{CallSite, CG.first->getName().str(), CG.second};
+ YMF.CalledGlobals.push_back(YamlCG);
+ }
+ }
+
+ // Sort by position of call instructions.
+ llvm::sort(YMF.CalledGlobals.begin(), YMF.CalledGlobals.end(),
+ [](yaml::CalledGlobal A, yaml::CalledGlobal B) {
+ if (A.CallSite.BlockNum == B.CallSite.BlockNum)
+ return A.CallSite.Offset < B.CallSite.Offset;
+ return A.CallSite.BlockNum < B.CallSite.BlockNum;
+ });
+}
+
void MIRPrinter::convert(yaml::MachineFunction &MF,
const MachineConstantPool &ConstantPool) {
unsigned ID = 0;
diff --git a/llvm/lib/CodeGen/SelectionDAG/ScheduleDAGSDNodes.cpp b/llvm/lib/CodeGen/SelectionDAG/ScheduleDAGSDNodes.cpp
index dff7243b0a99c9..bafe26ff7d6b76 100644
--- a/llvm/lib/CodeGen/SelectionDAG/ScheduleDAGSDNodes.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/ScheduleDAGSDNodes.cpp
@@ -908,6 +908,10 @@ EmitSchedule(MachineBasicBlock::iterator &InsertPos) {
It->setMMRAMetadata(MF, MMRA);
}
+ if (auto CalledGlobal = DAG->getCalledGlobal(Node))
+ if (CalledGlobal->first)
+ MF.addCalledGlobal(MI, *CalledGlobal);
+
return MI;
};
diff --git a/llvm/lib/MC/MCAsmStreamer.cpp b/llvm/lib/MC/MCAsmStreamer.cpp
index 01fe11ed205017..dd8058c6d5cd80 100644
--- a/llvm/lib/MC/MCAsmStreamer.cpp
+++ b/llvm/lib/MC/MCAsmStreamer.cpp
@@ -209,6 +209,8 @@ class MCAsmStreamer final : public MCStreamer {
void emitCOFFSectionIndex(MCSymbol const *Symbol) override;
void emitCOFFSecRel32(MCSymbol const *Symbol, uint64_t Offset) override;
void emitCOFFImgRel32(MCSymbol const *Symbol, int64_t Offset) override;
+ void emitCOFFSecNumber(MCSymbol const *Symbol) override;
+ void emitCOFFSecOffset(MCSymbol const *Symbol) override;
void emitXCOFFLocalCommonSymbol(MCSymbol *LabelSym, uint64_t Size,
MCSymbol *CsectSym, Align Alignment) override;
void emitXCOFFSymbolLinkageWithVisibility(MCSymbol *Symbol,
@@ -893,6 +895,18 @@ void MCAsmStreamer::emitCOFFImgRel32(MCSymbol const *Symbol, int64_t Offset) {
EmitEOL();
}
+void MCAsmStreamer::emitCOFFSecNumber(MCSymbol const *Symbol) {
+ OS << "\t.secnum\t";
+ Symbol->print(OS, MAI);
+ EmitEOL();
+}
+
+void MCAsmStreamer::emitCOFFSecOffset(MCSymbol const *Symbol) {
+ OS << "\t.secoffset\t";
+ Symbol->print(OS, MAI);
+ EmitEOL();
+}
+
// We need an XCOFF-specific version of this directive as the AIX syntax
// requires a QualName argument identifying the csect name and storage mapping
// class to appear before the alignment if we are specifying it.
diff --git a/llvm/lib/MC/MCObjectFileInfo.cpp b/llvm/lib/MC/MCObjectFileInfo.cpp
index f37e138edc36b1..150e38a94db6a6 100644
--- a/llvm/lib/MC/MCObjectFileInfo.cpp
+++ b/llvm/lib/MC/MCObjectFileInfo.cpp
@@ -596,6 +596,11 @@ void MCObjectFileInfo::initCOFFMCObjectFileInfo(const Triple &T) {
COFF::IMAGE_SCN_MEM_READ);
}
+ if (T.getArch() == Triple::aarch64) {
+ ImportCallSection =
+ Ctx->getCOFFSection(".impcall", COFF::IMAGE_SCN_LNK_INFO);
+ }
+
// Debug info.
COFFDebugSymbolsSection =
Ctx->getCOFFSection(".debug$S", (COFF::IMAGE_SCN_MEM_DISCARDABLE |
diff --git a/llvm/lib/MC/MCParser/COFFAsmParser.cpp b/llvm/lib/MC/MCParser/COFFAsmParser.cpp
index 4d95a720852835..dd5ce9964a194c 100644
--- a/llvm/lib/MC/MCParser/COFFAsmParser.cpp
+++ b/llvm/lib/MC/MCParser/COFFAsmParser.cpp
@@ -70,6 +70,8 @@ class COFFAsmParser : public MCAsmParserEx...
[truncated]
``````````
</details>
https://github.com/llvm/llvm-project/pull/122777
More information about the llvm-commits
mailing list