[PATCH] D73115: [AIX] Minor cleanup in AsmPrinter. [NFC]

Sean Fertile via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Jan 21 09:00:51 PST 2020


sfertile created this revision.
sfertile added reviewers: MaskRay, Xiangling_L.
Herald added a subscriber: hiraditya.
Herald added a project: LLVM.

- Extends the comments related to function descriptors, noting how they are only used on AIX.

- Changes the condition used to gate the creation of the current function symbol in `AsmPrinter::SetupMachineFunction` to reflect being AIX specific. The creation of the symbol is different because of AIXs linkage conventions, not because AIX uses function descriptors.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D73115

Files:
  llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp


Index: llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
===================================================================
--- llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
+++ llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
@@ -667,6 +667,8 @@
   OutStreamer->SwitchSection(getObjFileLowering().SectionForGlobal(&F, TM));
   EmitVisibility(CurrentFnSym, F.getVisibility());
 
+  // If the functions linkage is not internal then the function descriptor
+  // symbol must have same linkage as the function symbol.
   if (MAI->needsFunctionDescriptors() &&
       F.getLinkage() != GlobalValue::InternalLinkage)
     EmitLinkage(&F, CurrentFnDescSym);
@@ -707,7 +709,9 @@
   }
 
   // Emit the function descriptor. This is a virtual function to allow targets
-  // to emit their specific function descriptor.
+  // to emit their specific function descriptor. Right now it is only used by
+  // the AIX target. The PowerPC 64-bit V1 ELF target also uses function
+  // descriptors and should be converted to use this hook as well.
   if (MAI->needsFunctionDescriptors())
     EmitFunctionDescriptor();
 
@@ -1655,9 +1659,11 @@
   const Function &F = MF.getFunction();
 
   // Get the function symbol.
-  if (MAI->needsFunctionDescriptors()) {
-    assert(TM.getTargetTriple().isOSAIX() && "Function descriptor is only"
-                                             " supported on AIX.");
+  if (TM.getTargetTriple().isOSAIX()) {
+    // AIX is unique here in that the name of the symbol emitted for the
+    // function body does not have the same name as the source functions
+    // C-linkage name.
+    assert(MAI->needsFunctionDescriptors() && "AIX ABI is descriptor based.");
     assert(CurrentFnDescSym && "The function descriptor symbol needs to be"
 		                           " initalized first.");
 
@@ -1665,9 +1671,9 @@
     CurrentFnSym =
         OutContext.getOrCreateSymbol("." + CurrentFnDescSym->getName());
 
+    // Set the containing csect.
     MCSectionXCOFF *FnEntryPointSec =
         cast<MCSectionXCOFF>(getObjFileLowering().SectionForGlobal(&F, TM));
-    // Set the containing csect.
     cast<MCSymbolXCOFF>(CurrentFnSym)->setContainingCsect(FnEntryPointSec);
   } else {
     CurrentFnSym = getSymbol(&MF.getFunction());


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D73115.239336.patch
Type: text/x-patch
Size: 2239 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200121/72779e63/attachment.bin>


More information about the llvm-commits mailing list