[PATCH] D140270: MIPS: emit .module and .nan directives only for first function
YunQiang Su via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Sun Dec 18 08:30:55 PST 2022
wzssyqa created this revision.
wzssyqa added reviewers: MaskRay, nathanchance.
Herald added subscribers: StephenFan, atanasyan, jrtc27, hiraditya, arichardson, sdardis.
Herald added a project: All.
wzssyqa requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
If we emit `. module` or `.nan` for all functions in a single build unit,
GNU as complains: .module is not permitted after generating code.
So we should only emit them for the first function in `emitFunctionEntryLabel`
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D140270
Files:
llvm/lib/Target/Mips/MipsAsmPrinter.cpp
llvm/lib/Target/Mips/MipsAsmPrinter.h
Index: llvm/lib/Target/Mips/MipsAsmPrinter.h
===================================================================
--- llvm/lib/Target/Mips/MipsAsmPrinter.h
+++ llvm/lib/Target/Mips/MipsAsmPrinter.h
@@ -63,6 +63,11 @@
/// pool entries so we can properly mark them as data regions.
bool InConstantPool = false;
+ /// isFirstFunction - Is it the first function in this build unit?
+ /// GNU as complains: .module is not permitted after generating code,
+ /// if we emit some directives after the entry of first function.
+ bool isFirstFunction = true;
+
std::map<const char *, const Mips16HardFloatInfo::FuncSignature *>
StubsNeeded;
Index: llvm/lib/Target/Mips/MipsAsmPrinter.cpp
===================================================================
--- llvm/lib/Target/Mips/MipsAsmPrinter.cpp
+++ llvm/lib/Target/Mips/MipsAsmPrinter.cpp
@@ -402,11 +402,16 @@
bool IsO32 = (static_cast<const MipsTargetMachine &>(TM)).getABI().IsO32();
TS.updateABIInfo(*Subtarget);
- if (Subtarget->isNaN2008())
- TS.emitDirectiveNaN2008();
- if ((IsO32 && (Subtarget->isABI_FPXX() || Subtarget->isFP64bit())) ||
- Subtarget->useSoftFloat())
- TS.emitDirectiveModuleFP();
+ // GNU as complains: .module is not permitted after generating code.
+ // So we can only emit them for the first function.
+ if (isFirstFunction) {
+ isFirstFunction = false;
+ if (Subtarget->isNaN2008())
+ TS.emitDirectiveNaN2008();
+ if ((IsO32 && (Subtarget->isABI_FPXX() || Subtarget->isFP64bit())) ||
+ Subtarget->useSoftFloat())
+ TS.emitDirectiveModuleFP();
+ }
// NaCl sandboxing requires that indirect call instructions are masked.
// This means that function entry points should be bundle-aligned.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D140270.483823.patch
Type: text/x-patch
Size: 1744 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20221218/38869f39/attachment.bin>
More information about the llvm-commits
mailing list