[llvm] 8d9ff23 - [NFC][XCOFF][AIX] Return function entry point symbol with dedicate function
via llvm-commits
llvm-commits at lists.llvm.org
Wed May 27 10:54:53 PDT 2020
Author: jasonliu
Date: 2020-05-27T17:54:22Z
New Revision: 8d9ff2318530d91be04ccced107c3ef04ba2255f
URL: https://github.com/llvm/llvm-project/commit/8d9ff2318530d91be04ccced107c3ef04ba2255f
DIFF: https://github.com/llvm/llvm-project/commit/8d9ff2318530d91be04ccced107c3ef04ba2255f.diff
LOG: [NFC][XCOFF][AIX] Return function entry point symbol with dedicate function
Use getFunctionEntryPointSymbol whenever possible to enclose the
implementation detail and reduce duplicate logic.
Differential Revision: https://reviews.llvm.org/D80402
Added:
Modified:
llvm/include/llvm/CodeGen/TargetLoweringObjectFileImpl.h
llvm/include/llvm/Target/TargetLoweringObjectFile.h
llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
Removed:
################################################################################
diff --git a/llvm/include/llvm/CodeGen/TargetLoweringObjectFileImpl.h b/llvm/include/llvm/CodeGen/TargetLoweringObjectFileImpl.h
index 21a4635ca0ce..6e2c0973e354 100644
--- a/llvm/include/llvm/CodeGen/TargetLoweringObjectFileImpl.h
+++ b/llvm/include/llvm/CodeGen/TargetLoweringObjectFileImpl.h
@@ -262,6 +262,9 @@ class TargetLoweringObjectFileXCOFF : public TargetLoweringObjectFile {
/// For functions, this will always return a function descriptor symbol.
MCSymbol *getTargetSymbol(const GlobalValue *GV,
const TargetMachine &TM) const override;
+
+ MCSymbol *getFunctionEntryPointSymbol(const Function *F,
+ const TargetMachine &TM) const override;
};
} // end namespace llvm
diff --git a/llvm/include/llvm/Target/TargetLoweringObjectFile.h b/llvm/include/llvm/Target/TargetLoweringObjectFile.h
index 774b4470ca46..cc6c93b6ee2b 100644
--- a/llvm/include/llvm/Target/TargetLoweringObjectFile.h
+++ b/llvm/include/llvm/Target/TargetLoweringObjectFile.h
@@ -245,6 +245,13 @@ class TargetLoweringObjectFile : public MCObjectFileInfo {
return nullptr;
}
+ /// If supported, return the function entry point symbol.
+ /// Otherwise, returns nulltpr.
+ virtual MCSymbol *getFunctionEntryPointSymbol(const Function *F,
+ const TargetMachine &TM) const {
+ return nullptr;
+ }
+
protected:
virtual MCSection *SelectSectionForGlobal(const GlobalObject *GO,
SectionKind Kind,
diff --git a/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp b/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
index 1a2b3761b3a7..3be48935f2ab 100644
--- a/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
+++ b/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
@@ -1503,6 +1503,8 @@ bool AsmPrinter::doFinalization(Module &M) {
// Emit remaining GOT equivalent globals.
emitGlobalGOTEquivs();
+ const TargetLoweringObjectFile &TLOF = getObjFileLowering();
+
// Emit linkage(XCOFF) and visibility info for declarations
for (const Function &F : M) {
if (!F.isDeclarationForLinker())
@@ -1513,8 +1515,7 @@ bool AsmPrinter::doFinalization(Module &M) {
if (TM.getTargetTriple().isOSBinFormatXCOFF() && !F.isIntrinsic()) {
// Get the function entry point symbol.
- MCSymbol *FnEntryPointSym = OutContext.getOrCreateSymbol(
- "." + cast<MCSymbolXCOFF>(Name)->getUnqualifiedName());
+ MCSymbol *FnEntryPointSym = TLOF.getFunctionEntryPointSymbol(&F, TM);
if (cast<MCSymbolXCOFF>(FnEntryPointSym)->hasRepresentedCsectSet())
// Emit linkage for the function entry point.
emitLinkage(&F, FnEntryPointSym);
@@ -1536,8 +1537,6 @@ bool AsmPrinter::doFinalization(Module &M) {
if (remarks::RemarkStreamer *RS = M.getContext().getMainRemarkStreamer())
emitRemarksSection(*RS);
- const TargetLoweringObjectFile &TLOF = getObjFileLowering();
-
TLOF.emitModuleMetadata(*OutStreamer, M);
if (TM.getTargetTriple().isOSBinFormatELF()) {
@@ -1786,8 +1785,7 @@ void AsmPrinter::SetupMachineFunction(MachineFunction &MF) {
" initalized first.");
// Get the function entry point symbol.
- CurrentFnSym = OutContext.getOrCreateSymbol(
- "." + cast<MCSymbolXCOFF>(CurrentFnDescSym)->getUnqualifiedName());
+ CurrentFnSym = getObjFileLowering().getFunctionEntryPointSymbol(&F, TM);
}
CurrentFnSymForSize = CurrentFnSym;
diff --git a/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp b/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
index 38a0223688ba..586de4fd97f0 100644
--- a/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
+++ b/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
@@ -2150,6 +2150,14 @@ XCOFF::StorageClass TargetLoweringObjectFileXCOFF::getStorageClassForGlobal(
llvm_unreachable("Unknown linkage type!");
}
+MCSymbol *TargetLoweringObjectFileXCOFF::getFunctionEntryPointSymbol(
+ const Function *F, const TargetMachine &TM) const {
+ SmallString<128> NameStr;
+ NameStr.push_back('.');
+ getNameWithPrefix(NameStr, F, TM);
+ return getContext().getOrCreateSymbol(NameStr);
+}
+
MCSection *TargetLoweringObjectFileXCOFF::getSectionForFunctionDescriptor(
const Function *F, const TargetMachine &TM) const {
SmallString<128> NameStr;
More information about the llvm-commits
mailing list