Skip to content

RuntimeLibcalls: Pass in ABI name from MCOptions #144894

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 23, 2025

Conversation

arsenm
Copy link
Contributor

@arsenm arsenm commented Jun 19, 2025

ARM needs this to compute the available libcalls.

ARM needs this to compute the available libcalls.
Copy link
Contributor Author

arsenm commented Jun 19, 2025

This stack of pull requests is managed by Graphite. Learn more about stacking.

@llvmbot
Copy link
Member

llvmbot commented Jun 19, 2025

@llvm/pr-subscribers-llvm-ir

Author: Matt Arsenault (arsenm)

Changes

ARM needs this to compute the available libcalls.


Full diff: https://github.com/llvm/llvm-project/pull/144894.diff

3 Files Affected:

  • (modified) llvm/include/llvm/IR/RuntimeLibcalls.h (+4-3)
  • (modified) llvm/lib/CodeGen/TargetLoweringBase.cpp (+2-1)
  • (modified) llvm/lib/IR/RuntimeLibcalls.cpp (+1-1)
diff --git a/llvm/include/llvm/IR/RuntimeLibcalls.h b/llvm/include/llvm/IR/RuntimeLibcalls.h
index 71f38bedf17e0..ada1648b102f2 100644
--- a/llvm/include/llvm/IR/RuntimeLibcalls.h
+++ b/llvm/include/llvm/IR/RuntimeLibcalls.h
@@ -58,8 +58,8 @@ struct RuntimeLibcallsInfo {
       const Triple &TT,
       ExceptionHandling ExceptionModel = ExceptionHandling::None,
       FloatABI::ABIType FloatABI = FloatABI::Default,
-      EABI EABIVersion = EABI::Default) {
-    initLibcalls(TT, ExceptionModel, FloatABI, EABIVersion);
+      EABI EABIVersion = EABI::Default, StringRef ABIName = "") {
+    initLibcalls(TT, ExceptionModel, FloatABI, EABIVersion, ABIName);
   }
 
   /// Rename the default libcall routine name for the specified libcall.
@@ -150,7 +150,8 @@ struct RuntimeLibcallsInfo {
   /// Set default libcall names. If a target wants to opt-out of a libcall it
   /// should be placed here.
   LLVM_ABI void initLibcalls(const Triple &TT, ExceptionHandling ExceptionModel,
-                             FloatABI::ABIType FloatABI, EABI ABIType);
+                             FloatABI::ABIType FloatABI, EABI ABIType,
+                             StringRef ABIName);
 };
 
 } // namespace RTLIB
diff --git a/llvm/lib/CodeGen/TargetLoweringBase.cpp b/llvm/lib/CodeGen/TargetLoweringBase.cpp
index 41e73b8530937..cda41a91a372f 100644
--- a/llvm/lib/CodeGen/TargetLoweringBase.cpp
+++ b/llvm/lib/CodeGen/TargetLoweringBase.cpp
@@ -633,7 +633,8 @@ void RTLIB::initCmpLibcallCCs(ISD::CondCode *CmpLibcallCCs) {
 /// NOTE: The TargetMachine owns TLOF.
 TargetLoweringBase::TargetLoweringBase(const TargetMachine &tm)
     : TM(tm), Libcalls(TM.getTargetTriple(), TM.Options.ExceptionModel,
-                       TM.Options.FloatABIType, TM.Options.EABIVersion) {
+                       TM.Options.FloatABIType, TM.Options.EABIVersion,
+                       TM.Options.MCOptions.getABIName()) {
   initActions();
 
   // Perform these initializations only once.
diff --git a/llvm/lib/IR/RuntimeLibcalls.cpp b/llvm/lib/IR/RuntimeLibcalls.cpp
index ad2904d6d2ea6..4837207cc53b0 100644
--- a/llvm/lib/IR/RuntimeLibcalls.cpp
+++ b/llvm/lib/IR/RuntimeLibcalls.cpp
@@ -359,7 +359,7 @@ static void setLongDoubleIsF128Libm(RuntimeLibcallsInfo &Info,
 void RuntimeLibcallsInfo::initLibcalls(const Triple &TT,
                                        ExceptionHandling ExceptionModel,
                                        FloatABI::ABIType FloatABI,
-                                       EABI EABIVersion) {
+                                       EABI EABIVersion, StringRef ABIName) {
   initSoftFloatCmpLibcallPredicates();
 
   initSoftFloatCmpLibcallPredicates();

@dpaoliello
Copy link
Contributor

I'd like to see how this will actually be used. Do you have a branch you can point to? Or at least some example functions that you're going to be conditionalizing?

@arsenm
Copy link
Contributor Author

arsenm commented Jun 20, 2025

I'd like to see how this will actually be used. Do you have a branch you can point to? Or at least some example functions that you're going to be conditionalizing?

This is for all of these isAAPCS_ABI checks here and here.

I guess this corresponds to using the "-target-abi" cl::opt, which unfortunately it does seem clang sets. This fall into the category of global state not captured in the IR that either shouldn't exist, should be directly in the triple, or be a module flag in the IR. It would be good if it's possible to just delete this and only derive this from the existing triples.

The existence of computeDefaultTargetABI suggests it might be possible to drop the cl::opt if it's only really needed in tests.

I also think this case was a pain but I don't see why now.

@arsenm arsenm merged commit 58987d2 into main Jun 23, 2025
12 checks passed
@arsenm arsenm deleted the users/arsenm/runtime-libcalls/pass-in-abi-name branch June 23, 2025 13:14
miguelcsx pushed a commit to miguelcsx/llvm-project that referenced this pull request Jun 23, 2025
ARM needs this to compute the available libcalls.
Jaddyen pushed a commit to Jaddyen/llvm-project that referenced this pull request Jun 23, 2025
ARM needs this to compute the available libcalls.
anthonyhatran pushed a commit to anthonyhatran/llvm-project that referenced this pull request Jun 26, 2025
ARM needs this to compute the available libcalls.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants