Skip to content

[Mips] Fix wrong ELF FP ABI info when inline asm was empty #146457

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions llvm/lib/Target/Mips/MipsAsmPrinter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -745,14 +745,18 @@ void MipsAsmPrinter::emitStartOfAsmFile(Module &M) {
if (FS.empty() && M.size() && F->hasFnAttribute("target-features"))
FS = F->getFnAttribute("target-features").getValueAsString();

std::string strFS = FS.str();
if (M.size() && F->getFnAttribute("use-soft-float").getValueAsBool())
strFS += strFS.empty() ? "+soft-float" : ",+soft-float";

// Compute MIPS architecture attributes based on the default subtarget
// that we'd have constructed.
// FIXME: For ifunc related functions we could iterate over and look
// for a feature string that doesn't match the default one.
StringRef CPU = MIPS_MC::selectMipsCPU(TT, TM.getTargetCPU());
const MipsTargetMachine &MTM = static_cast<const MipsTargetMachine &>(TM);
const MipsSubtarget STI(TT, CPU, FS, MTM.isLittleEndian(), MTM,
std::nullopt);
const MipsSubtarget STI(TT, CPU, StringRef(strFS), MTM.isLittleEndian(),
MTM, std::nullopt);

bool IsABICalls = STI.isABICalls();
const MipsABIInfo &ABI = MTM.getABI();
Expand Down
12 changes: 12 additions & 0 deletions llvm/test/CodeGen/Mips/abiflags-soft-float.ll
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
; RUN: llc -filetype=obj -mtriple mipsel-unknown-linux -mcpu=mips32 %s -o tmp.o
; RUN: llvm-readobj -A tmp.o | FileCheck %s -check-prefix=OBJ
; RUN: llc -filetype=asm -mtriple mipsel-unknown-linux -mcpu=mips32 %s -o - | \
; RUN: FileCheck %s -check-prefix=ASM

; OBJ: FP ABI: Soft float
; ASM: .module softfloat

define dso_local void @asm_is_null() "use-soft-float"="true" {
call void asm sideeffect "", ""()
ret void
}
Loading