Skip to content

Commit b8a8a96

Browse files
authored
Revert "LoongArch: Improve detection of valid TripleABI (#147952)"
This reverts commit 9ed8816.
1 parent 2e2a899 commit b8a8a96

File tree

2 files changed

+13
-7
lines changed

2 files changed

+13
-7
lines changed

llvm/lib/Target/LoongArch/MCTargetDesc/LoongArchBaseInfo.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,6 @@ static ABI getTripleABI(const Triple &TT) {
5252
bool Is64Bit = TT.isArch64Bit();
5353
ABI TripleABI;
5454
switch (TT.getEnvironment()) {
55-
case llvm::Triple::EnvironmentType::UnknownEnvironment:
56-
TripleABI = ABI_Unknown;
57-
break;
5855
case llvm::Triple::EnvironmentType::GNUSF:
5956
case llvm::Triple::EnvironmentType::MuslSF:
6057
TripleABI = Is64Bit ? ABI_LP64S : ABI_ILP32S;
@@ -99,7 +96,7 @@ ABI computeTargetABI(const Triple &TT, const FeatureBitset &FeatureBits,
9996

10097
// 1. If the '-target-abi' is valid, use it.
10198
if (IsABIValidForFeature(ArgProvidedABI)) {
102-
if (IsABIValidForFeature(TripleABI) && ArgProvidedABI != TripleABI)
99+
if (TT.hasEnvironment() && ArgProvidedABI != TripleABI)
103100
errs()
104101
<< "warning: triple-implied ABI conflicts with provided target-abi '"
105102
<< ABIName << "', using target-abi\n";
@@ -167,7 +164,10 @@ ABI computeTargetABI(const Triple &TT, const FeatureBitset &FeatureBits,
167164
return Is64Bit ? ABI_LP64F : ABI_ILP32F;
168165
return Is64Bit ? ABI_LP64S : ABI_ILP32S;
169166
};
170-
if (!ABIName.empty())
167+
if (ABIName.empty())
168+
errs() << "warning: the triple-implied ABI is invalid, ignoring and using "
169+
"feature-implied ABI\n";
170+
else
171171
errs() << "warning: both target-abi and the triple-implied ABI are "
172172
"invalid, ignoring and using feature-implied ABI\n";
173173
return checkABIStandardized(GetFeatureABI());

llvm/test/CodeGen/LoongArch/target-abi-from-triple-edge-cases.ll

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,9 @@
2424
; NO-WARNING-NOT: warning: triple-implied ABI conflicts with provided target-abi 'lp64d', using target-abi
2525

2626
;; Check that ILP32-on-LA64 and LP64-on-LA32 combinations are handled properly.
27-
; RUN: llc --mtriple=loongarch64-linux-gnu --target-abi=ilp32d --mattr=+d < %s 2>&1 \
27+
; RUN: llc --mtriple=loongarch64 --target-abi=ilp32d --mattr=+d < %s 2>&1 \
2828
; RUN: | FileCheck %s --check-prefixes=LP64D,32ON64
29-
; RUN: llc --mtriple=loongarch32-linux-gnu --target-abi=lp64d --mattr=+d < %s 2>&1 \
29+
; RUN: llc --mtriple=loongarch32 --target-abi=lp64d --mattr=+d < %s 2>&1 \
3030
; RUN: | FileCheck %s --check-prefixes=ILP32D,64ON32
3131

3232
; 32ON64: warning: 32-bit ABIs are not supported for 64-bit targets, ignoring and using triple-implied ABI
@@ -49,6 +49,12 @@
4949

5050
; LP64D-LP64F-NOF: warning: both target-abi and the triple-implied ABI are invalid, ignoring and using feature-implied ABI
5151

52+
;; Check that triple-implied ABI are invalid, use feature-implied ABI
53+
; RUN: llc --mtriple=loongarch64 --mattr=-f < %s 2>&1 \
54+
; RUN: | FileCheck %s --check-prefixes=LP64S,LP64D-NONE-NOF
55+
56+
; LP64D-NONE-NOF: warning: the triple-implied ABI is invalid, ignoring and using feature-implied ABI
57+
5258
define float @f(float %a) {
5359
; ILP32D-LABEL: f:
5460
; ILP32D: # %bb.0:

0 commit comments

Comments
 (0)