Skip to content

Commit 778fb76

Browse files
authored
[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.
1 parent 22c9236 commit 778fb76

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
@@ -737,14 +737,18 @@ void MipsAsmPrinter::emitStartOfAsmFile(Module &M) {
737737
if (FS.empty() && M.size() && F->hasFnAttribute("target-features"))
738738
FS = F->getFnAttribute("target-features").getValueAsString();
739739

740+
std::string strFS = FS.str();
741+
if (M.size() && F->getFnAttribute("use-soft-float").getValueAsBool())
742+
strFS += strFS.empty() ? "+soft-float" : ",+soft-float";
743+
740744
// Compute MIPS architecture attributes based on the default subtarget
741745
// that we'd have constructed.
742746
// FIXME: For ifunc related functions we could iterate over and look
743747
// for a feature string that doesn't match the default one.
744748
StringRef CPU = MIPS_MC::selectMipsCPU(TT, TM.getTargetCPU());
745749
const MipsTargetMachine &MTM = static_cast<const MipsTargetMachine &>(TM);
746-
const MipsSubtarget STI(TT, CPU, FS, MTM.isLittleEndian(), MTM,
747-
std::nullopt);
750+
const MipsSubtarget STI(TT, CPU, StringRef(strFS), MTM.isLittleEndian(),
751+
MTM, std::nullopt);
748752

749753
bool IsABICalls = STI.isABICalls();
750754
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)