[PATCH] D74622: [AsmPrinter] Use the McASMInfo to determine if we need descriptors.

Sean Fertile via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Feb 14 08:41:25 PST 2020


sfertile created this revision.
sfertile added a reviewer: daltenty.
Herald added a subscriber: hiraditya.
Herald added a project: LLVM.
sfertile edited the summary of this revision.

In https://reviews.llvm.org/rG8b737688c21a9755cae14cb9343930e0882164ab I switched the condition gating the creation of the descriptor symbol from
checking the MCAsmInfo if we need to support descriptors, to if the OS was AIX. Technically the 2 should be interchangeable: if we are
targeting AIX then we need to emit XCOFF object files, and the MCAsmInfo must return true for needing function descriptors.

This doesn't account for lit test with runsteps that only set the arch. Eg: test/CodeGen/XCore/section-name.ll
which when run natively on AIX we end up with a target `xcore-ibm-aix` and needFunctionDescriptors is false.

This patch reverts to using the MCAsmInfo and adds an assert that the  target OS must be AIX since that is the only target using the descriptor hook.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D74622

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
@@ -1705,13 +1705,16 @@
   const Function &F = MF.getFunction();
 
   // Get the function symbol.
-  if (TM.getTargetTriple().isOSAIX()) {
+  if (!MAI->needsFunctionDescriptors()) {
+    CurrentFnSym = getSymbol(&MF.getFunction());
+  } else {
+    assert(TM.getTargetTriple().isOSAIX() &&
+           "Only AIX uses the function descriptor hooks.");
     // 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 function's
     // C-linkage name.
-    assert(MAI->needsFunctionDescriptors() && "AIX ABI is descriptor based.");
     assert(CurrentFnDescSym && "The function descriptor symbol needs to be"
-		                           " initalized first.");
+                               " initalized first.");
 
     // Get the function entry point symbol.
     CurrentFnSym =
@@ -1721,8 +1724,6 @@
     MCSectionXCOFF *FnEntryPointSec =
         cast<MCSectionXCOFF>(getObjFileLowering().SectionForGlobal(&F, TM));
     cast<MCSymbolXCOFF>(CurrentFnSym)->setContainingCsect(FnEntryPointSec);
-  } else {
-    CurrentFnSym = getSymbol(&MF.getFunction());
   }
 
   CurrentFnSymForSize = CurrentFnSym;


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D74622.244682.patch
Type: text/x-patch
Size: 1392 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200214/039677c8/attachment-0001.bin>


More information about the llvm-commits mailing list