Skip to content

Commit cd72b50

Browse files
yingopqtru
authored andcommitted
[Mips] Fix wrong ELF FP ABI info when inline asm was empty (#146457)
When Mips process emitStartOfAsmFile and updateABIInfo, it did not know the real value of IsSoftFloat and STI.useSoftFloat(). And when inline asm instruction was empty, Mips did not process asm parser, so it would not do TS.updateABIInfo(STI) again and at this time the value of IsSoftFloat is correct. Fix #135283. (cherry picked from commit 778fb76)
1 parent b00e0d2 commit cd72b50

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed

llvm/lib/Target/Mips/MipsAsmPrinter.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -747,14 +747,18 @@ void MipsAsmPrinter::emitStartOfAsmFile(Module &M) {
747747
if (FS.empty() && M.size() && F->hasFnAttribute("target-features"))
748748
FS = F->getFnAttribute("target-features").getValueAsString();
749749

750+
std::string strFS = FS.str();
751+
if (M.size() && F->getFnAttribute("use-soft-float").getValueAsBool())
752+
strFS += strFS.empty() ? "+soft-float" : ",+soft-float";
753+
750754
// Compute MIPS architecture attributes based on the default subtarget
751755
// that we'd have constructed.
752756
// FIXME: For ifunc related functions we could iterate over and look
753757
// for a feature string that doesn't match the default one.
754758
StringRef CPU = MIPS_MC::selectMipsCPU(TT, TM.getTargetCPU());
755759
const MipsTargetMachine &MTM = static_cast<const MipsTargetMachine &>(TM);
756-
const MipsSubtarget STI(TT, CPU, FS, MTM.isLittleEndian(), MTM,
757-
std::nullopt);
760+
const MipsSubtarget STI(TT, CPU, StringRef(strFS), MTM.isLittleEndian(),
761+
MTM, std::nullopt);
758762

759763
bool IsABICalls = STI.isABICalls();
760764
const MipsABIInfo &ABI = MTM.getABI();
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
; RUN: llc -filetype=obj -mtriple mipsel-unknown-linux -mcpu=mips32 %s -o tmp.o
2+
; RUN: llvm-readobj -A tmp.o | FileCheck %s -check-prefix=OBJ
3+
; RUN: llc -filetype=asm -mtriple mipsel-unknown-linux -mcpu=mips32 %s -o - | \
4+
; RUN: FileCheck %s -check-prefix=ASM
5+
6+
; OBJ: FP ABI: Soft float
7+
; ASM: .module softfloat
8+
9+
define dso_local void @asm_is_null() "use-soft-float"="true" {
10+
call void asm sideeffect "", ""()
11+
ret void
12+
}

0 commit comments

Comments
 (0)