Skip to content

Commit db429d7

Browse files
committed
CodeGen: Remove UsesMSVCFloatingPoint from MachineModuleInfo
This is only used by x86 and only used in the AsmPrinter module pass. I think implementing this by looking at the underlying IR types instead of the selected instructions is a pretty horrifying implementation, but it's still available in the AsmPrinter. This is https://reviews.llvm.org/D123933 resurrected. I still don't know what the point of emitting _fltused is, but this approach of looking at the IR types probably isn't the right way to do this in the first place. If the intent is report any FP instructions, this will miss any implicitly introduced ones during codegen. Also don't know why just unconditionally emitting it isn't an option. The last review mentioned the ARMs might want to emit this, but I'm not going to go fix that. If someone wants to emit this on ARM, they can move this to a common helper or analysis somewhere.
1 parent 63d088c commit db429d7

File tree

4 files changed

+24
-37
lines changed

4 files changed

+24
-37
lines changed

llvm/include/llvm/CodeGen/MachineModuleInfo.h

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -116,10 +116,6 @@ class MachineModuleInfo {
116116
/// True if debugging information is available in this module.
117117
bool DbgInfoAvailable = false;
118118

119-
/// True if this module is being built for windows/msvc, and uses floating
120-
/// point. This is used to emit an undefined reference to _fltused.
121-
bool UsesMSVCFloatingPoint = false;
122-
123119
/// Maps IR Functions to their corresponding MachineFunctions.
124120
DenseMap<const Function*, std::unique_ptr<MachineFunction>> MachineFunctions;
125121
/// Next unique number available for a MachineFunction.
@@ -189,10 +185,6 @@ class MachineModuleInfo {
189185
/// Returns true if valid debug info is present.
190186
bool hasDebugInfo() const { return DbgInfoAvailable; }
191187

192-
bool usesMSVCFloatingPoint() const { return UsesMSVCFloatingPoint; }
193-
194-
void setUsesMSVCFloatingPoint(bool b) { UsesMSVCFloatingPoint = b; }
195-
196188
/// \name Exception Handling
197189
/// \{
198190

llvm/lib/CodeGen/MachineModuleInfo.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ void MachineModuleInfo::initialize() {
2828
ObjFileMMI = nullptr;
2929
CurCallSite = 0;
3030
NextFnNum = 0;
31-
UsesMSVCFloatingPoint = false;
3231
DbgInfoAvailable = false;
3332
}
3433

llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -417,30 +417,6 @@ void SelectionDAGISelLegacy::getAnalysisUsage(AnalysisUsage &AU) const {
417417
MachineFunctionPass::getAnalysisUsage(AU);
418418
}
419419

420-
static void computeUsesMSVCFloatingPoint(const Triple &TT, const Function &F,
421-
MachineModuleInfo &MMI) {
422-
// Only needed for MSVC
423-
if (!TT.isWindowsMSVCEnvironment())
424-
return;
425-
426-
// If it's already set, nothing to do.
427-
if (MMI.usesMSVCFloatingPoint())
428-
return;
429-
430-
for (const Instruction &I : instructions(F)) {
431-
if (I.getType()->isFPOrFPVectorTy()) {
432-
MMI.setUsesMSVCFloatingPoint(true);
433-
return;
434-
}
435-
for (const auto &Op : I.operands()) {
436-
if (Op->getType()->isFPOrFPVectorTy()) {
437-
MMI.setUsesMSVCFloatingPoint(true);
438-
return;
439-
}
440-
}
441-
}
442-
}
443-
444420
PreservedAnalyses
445421
SelectionDAGISelPass::run(MachineFunction &MF,
446422
MachineFunctionAnalysisManager &MFAM) {
@@ -802,9 +778,6 @@ bool SelectionDAGISel::runOnMachineFunction(MachineFunction &mf) {
802778
}
803779
}
804780

805-
// Determine if floating point is used for msvc
806-
computeUsesMSVCFloatingPoint(TM.getTargetTriple(), Fn, *CurDAG->getMMI());
807-
808781
// Release function-specific state. SDB and CurDAG are already cleared
809782
// at this point.
810783
FuncInfo->clear();

llvm/lib/Target/X86/X86AsmPrinter.cpp

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
#include "llvm/CodeGenTypes/MachineValueType.h"
2929
#include "llvm/IR/DerivedTypes.h"
3030
#include "llvm/IR/InlineAsm.h"
31+
#include "llvm/IR/InstIterator.h"
3132
#include "llvm/IR/Mangler.h"
3233
#include "llvm/IR/Module.h"
3334
#include "llvm/IR/Type.h"
@@ -975,6 +976,28 @@ static void emitNonLazyStubs(MachineModuleInfo *MMI, MCStreamer &OutStreamer) {
975976
}
976977
}
977978

979+
/// True if this module is being built for windows/msvc, and uses floating
980+
/// point. This is used to emit an undefined reference to _fltused.
981+
static bool usesMSVCFloatingPoint(const Triple &TT, const Module &M) {
982+
// Only needed for MSVC
983+
if (!TT.isWindowsMSVCEnvironment())
984+
return false;
985+
986+
for (const Function &F : M) {
987+
for (const Instruction &I : instructions(F)) {
988+
if (I.getType()->isFPOrFPVectorTy())
989+
return true;
990+
991+
for (const auto &Op : I.operands()) {
992+
if (Op->getType()->isFPOrFPVectorTy())
993+
return true;
994+
}
995+
}
996+
}
997+
998+
return false;
999+
}
1000+
9781001
void X86AsmPrinter::emitEndOfAsmFile(Module &M) {
9791002
const Triple &TT = TM.getTargetTriple();
9801003

@@ -993,7 +1016,7 @@ void X86AsmPrinter::emitEndOfAsmFile(Module &M) {
9931016
// safe to set.
9941017
OutStreamer->emitAssemblerFlag(MCAF_SubsectionsViaSymbols);
9951018
} else if (TT.isOSBinFormatCOFF()) {
996-
if (MMI->usesMSVCFloatingPoint()) {
1019+
if (usesMSVCFloatingPoint(TT, M)) {
9971020
// In Windows' libcmt.lib, there is a file which is linked in only if the
9981021
// symbol _fltused is referenced. Linking this in causes some
9991022
// side-effects:

0 commit comments

Comments
 (0)