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

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


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

Addresses issue #147665


>From a481cb3ad5cd49448089af6f0cc41cd7b3bb1e90 Mon Sep 17 00:00:00 2001
From: Mintsuki <mintsuki at protonmail.com>
Date: Thu, 10 Jul 2025 14:37:07 +0200
Subject: [PATCH] LoongArch: Improve detection of valid TripleABI

Addresses issue #147665
---
 .../lib/Target/LoongArch/MCTargetDesc/LoongArchBaseInfo.cpp | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

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";



More information about the llvm-commits mailing list