[llvm] [llvm] Support IFuncs on Darwin platforms (PR #73686)

via llvm-commits llvm-commits at lists.llvm.org
Tue Nov 28 10:42:39 PST 2023


github-actions[bot] wrote:

<!--LLVM CODE FORMAT COMMENT: {clang-format}-->


:warning: C/C++ code formatter, clang-format found issues in your code. :warning:

<details>
<summary>
You can test this locally with the following command:
</summary>

``````````bash
git-clang-format --diff badec9b7bfb6fb27d8be42d1b71bea7a3cd37da6 bc152095691b32d1ad8539dfd60f5089df5eed8d -- llvm/include/llvm/CodeGen/AsmPrinter.h llvm/lib/CodeGen/GlobalISel/CallLowering.cpp llvm/lib/IR/Verifier.cpp llvm/lib/Target/AArch64/AArch64AsmPrinter.cpp llvm/lib/Target/X86/X86AsmPrinter.cpp llvm/lib/Target/X86/X86AsmPrinter.h
``````````

</details>

<details>
<summary>
View the diff from clang-format here.
</summary>

``````````diff
diff --git a/llvm/include/llvm/CodeGen/AsmPrinter.h b/llvm/include/llvm/CodeGen/AsmPrinter.h
index 48fa6c4784..07b92871a0 100644
--- a/llvm/include/llvm/CodeGen/AsmPrinter.h
+++ b/llvm/include/llvm/CodeGen/AsmPrinter.h
@@ -887,7 +887,6 @@ protected:
   virtual void emitGlobalIFunc(Module &M, const GlobalIFunc &GI);
 
 private:
-
   /// This method decides whether the specified basic block requires a label.
   bool shouldEmitLabelForBasicBlock(const MachineBasicBlock &MBB) const;
 
diff --git a/llvm/lib/IR/Verifier.cpp b/llvm/lib/IR/Verifier.cpp
index 94e76a43bf..bd90047a41 100644
--- a/llvm/lib/IR/Verifier.cpp
+++ b/llvm/lib/IR/Verifier.cpp
@@ -959,7 +959,6 @@ void Verifier::visitGlobalIFunc(const GlobalIFunc &GI) {
       GlobalIFunc::getResolverFunctionType(GI.getValueType());
   Check(ResolverTy == ResolverFuncTy->getPointerTo(GI.getAddressSpace()),
         "IFunc resolver has incorrect type", &GI);
-
 }
 
 void Verifier::visitNamedMDNode(const NamedMDNode &NMD) {
@@ -2240,7 +2239,8 @@ void Verifier::verifyFunctionAttrs(FunctionType *FT, AttributeList Attrs,
   }
 
   // Check EVEX512 feature.
-  if (MaxParameterWidth >= 512 && Attrs.hasFnAttr("target-features") && TT.isX86()) {
+  if (MaxParameterWidth >= 512 && Attrs.hasFnAttr("target-features") &&
+      TT.isX86()) {
     StringRef TF = Attrs.getFnAttr("target-features").getValueAsString();
     Check(!TF.contains("+avx512f") || !TF.contains("-evex512"),
           "512-bit vector arguments require 'evex512' for AVX512", V);
diff --git a/llvm/lib/Target/AArch64/AArch64AsmPrinter.cpp b/llvm/lib/Target/AArch64/AArch64AsmPrinter.cpp
index 2dab8e126c..f412833200 100644
--- a/llvm/lib/Target/AArch64/AArch64AsmPrinter.cpp
+++ b/llvm/lib/Target/AArch64/AArch64AsmPrinter.cpp
@@ -71,10 +71,15 @@ using namespace llvm;
 
 namespace {
 
-enum class IFuncLowering { SymbolResolverIfSupported, SymbolResolverAlways, SymbolResolverNever };
+enum class IFuncLowering {
+  SymbolResolverIfSupported,
+  SymbolResolverAlways,
+  SymbolResolverNever
+};
 
 static cl::opt<IFuncLowering> PreferredIFuncLowering(
-    "arm64-darwin-ifunc-symbol_resolver", cl::init(IFuncLowering::SymbolResolverNever),
+    "arm64-darwin-ifunc-symbol_resolver",
+    cl::init(IFuncLowering::SymbolResolverNever),
     cl::desc("Pick the lowering for ifuncs on darwin platforms"), cl::Hidden,
     cl::values(
         clEnumValN(
@@ -1853,8 +1858,8 @@ void AArch64AsmPrinter::emitLinkerSymbolResolver(Module &M,
   OutStreamer->emitSymbolAttribute(Name, MCSA_SymbolResolver);
   emitVisibility(Name, GI.getVisibility());
 
-  // ld-prime does not seem to support aliases of symbol resolvers, so we have to
-  // tail call the resolver manually.
+  // ld-prime does not seem to support aliases of symbol resolvers, so we have
+  // to tail call the resolver manually.
   OutStreamer->emitInstruction(
       MCInstBuilder(AArch64::B)
           .addOperand(MCOperand::createExpr(lowerConstant(GI.getResolver()))),
@@ -1887,8 +1892,9 @@ void AArch64AsmPrinter::emitManualSymbolResolver(Module &M,
       assert(GI.hasLocalLinkage() && "Invalid ifunc linkage");
   };
 
-  MCSymbol *LazyPointer = TM.getObjFileLowering()->getContext().getOrCreateSymbol(
-      "_" + GI.getName() + ".lazy_pointer");
+  MCSymbol *LazyPointer =
+      TM.getObjFileLowering()->getContext().getOrCreateSymbol(
+          "_" + GI.getName() + ".lazy_pointer");
   MCSymbol *StubHelper =
       TM.getObjFileLowering()->getContext().getOrCreateSymbol(
           "_" + GI.getName() + ".stub_helper");
@@ -1943,9 +1949,10 @@ void AArch64AsmPrinter::emitManualSymbolResolver(Module &M,
   }
 
   OutStreamer->emitInstruction(MCInstBuilder(AArch64::LDRXui)
-    .addReg(AArch64::X16)
-    .addReg(AArch64::X16)
-    .addImm(0), *STI);
+                                   .addReg(AArch64::X16)
+                                   .addReg(AArch64::X16)
+                                   .addImm(0),
+                               *STI);
 
   OutStreamer->emitInstruction(MCInstBuilder(TM.getTargetTriple().isArm64e()
                                                  ? AArch64::BRAAZ

``````````

</details>


https://github.com/llvm/llvm-project/pull/73686


More information about the llvm-commits mailing list