[llvm] LoongArch: Improve detection of valid TripleABI (PR #147952)

via llvm-commits llvm-commits at lists.llvm.org
Thu Jul 10 05:41:05 PDT 2025


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-backend-loongarch

Author: None (mintsuki)

<details>
<summary>Changes</summary>

Addresses issue #<!-- -->147665


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


1 Files Affected:

- (modified) llvm/lib/Target/LoongArch/MCTargetDesc/LoongArchBaseInfo.cpp (+4-2) 


``````````diff
diff --git a/llvm/lib/Target/LoongArch/MCTargetDesc/LoongArchBaseInfo.cpp b/llvm/lib/Target/LoongArch/MCTargetDesc/LoongArchBaseInfo.cpp
index 03ce004ed33a5..d21c996704544 100644
--- a/llvm/lib/Target/LoongArch/MCTargetDesc/LoongArchBaseInfo.cpp
+++ b/llvm/lib/Target/LoongArch/MCTargetDesc/LoongArchBaseInfo.cpp
@@ -62,9 +62,11 @@ static ABI getTripleABI(const Triple &TT) {
     break;
   // Let the fallback case behave like {ILP32,LP64}D.
   case llvm::Triple::EnvironmentType::GNUF64:
-  default:
     TripleABI = Is64Bit ? ABI_LP64D : ABI_ILP32D;
     break;
+  default:
+    TripleABI = ABI_Unknown;
+    break;
   }
   return TripleABI;
 }
@@ -96,7 +98,7 @@ ABI computeTargetABI(const Triple &TT, const FeatureBitset &FeatureBits,
 
   // 1. If the '-target-abi' is valid, use it.
   if (IsABIValidForFeature(ArgProvidedABI)) {
-    if (TT.hasEnvironment() && ArgProvidedABI != TripleABI)
+    if (IsABIValidForFeature(TripleABI) && ArgProvidedABI != TripleABI)
       errs()
           << "warning: triple-implied ABI conflicts with provided target-abi '"
           << ABIName << "', using target-abi\n";

``````````

</details>


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


More information about the llvm-commits mailing list