Index: llvm/include/llvm/CodeGen/MachineModuleInfo.h =================================================================== --- llvm/include/llvm/CodeGen/MachineModuleInfo.h +++ llvm/include/llvm/CodeGen/MachineModuleInfo.h @@ -119,10 +119,6 @@ /// True if debugging information is available in this module. bool DbgInfoAvailable; - /// True if this module is being built for windows/msvc, and uses floating - /// point. This is used to emit an undefined reference to _fltused. - bool UsesMSVCFloatingPoint; - /// True if the module calls the __morestack function indirectly, as is /// required under the large code model on x86. This is used to emit /// a definition of a symbol, __morestack_addr, containing the address. See @@ -202,10 +198,6 @@ bool hasDebugInfo() const { return DbgInfoAvailable; } void setDebugInfoAvailability(bool avail) { DbgInfoAvailable = avail; } - bool usesMSVCFloatingPoint() const { return UsesMSVCFloatingPoint; } - - void setUsesMSVCFloatingPoint(bool b) { UsesMSVCFloatingPoint = b; } - bool usesMorestackAddr() const { return UsesMorestackAddr; } Index: llvm/lib/CodeGen/MachineModuleInfo.cpp =================================================================== --- llvm/lib/CodeGen/MachineModuleInfo.cpp +++ llvm/lib/CodeGen/MachineModuleInfo.cpp @@ -193,7 +193,7 @@ ObjFileMMI = nullptr; CurCallSite = 0; NextFnNum = 0; - UsesMSVCFloatingPoint = UsesMorestackAddr = false; + UsesMorestackAddr = false; HasSplitStack = HasNosplitStack = false; AddrLabelSymbols = nullptr; } @@ -220,7 +220,6 @@ Context.setObjectFileInfo(MMI.TM.getObjFileLowering()); ObjFileMMI = MMI.ObjFileMMI; CurCallSite = MMI.CurCallSite; - UsesMSVCFloatingPoint = MMI.UsesMSVCFloatingPoint; UsesMorestackAddr = MMI.UsesMorestackAddr; HasSplitStack = MMI.HasSplitStack; HasNosplitStack = MMI.HasNosplitStack; Index: llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp =================================================================== --- llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp +++ llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp @@ -386,30 +386,6 @@ } } -static void computeUsesMSVCFloatingPoint(const Triple &TT, const Function &F, - MachineModuleInfo &MMI) { - // Only needed for MSVC - if (!TT.isWindowsMSVCEnvironment()) - return; - - // If it's already set, nothing to do. - if (MMI.usesMSVCFloatingPoint()) - return; - - for (const Instruction &I : instructions(F)) { - if (I.getType()->isFPOrFPVectorTy()) { - MMI.setUsesMSVCFloatingPoint(true); - return; - } - for (const auto &Op : I.operands()) { - if (Op->getType()->isFPOrFPVectorTy()) { - MMI.setUsesMSVCFloatingPoint(true); - return; - } - } - } -} - bool SelectionDAGISel::runOnMachineFunction(MachineFunction &mf) { // If we already selected that function, we do not need to run SDISel. if (mf.getProperties().hasProperty( @@ -680,9 +656,6 @@ // Determine if there is a call to setjmp in the machine function. MF->setExposesReturnsTwice(Fn.callsFunctionThatReturnsTwice()); - // Determine if floating point is used for msvc - computeUsesMSVCFloatingPoint(TM.getTargetTriple(), Fn, MF->getMMI()); - // Release function-specific state. SDB and CurDAG are already cleared // at this point. FuncInfo->clear(); Index: llvm/lib/Target/X86/X86AsmPrinter.cpp =================================================================== --- llvm/lib/Target/X86/X86AsmPrinter.cpp +++ llvm/lib/Target/X86/X86AsmPrinter.cpp @@ -26,6 +26,7 @@ #include "llvm/CodeGen/TargetLoweringObjectFileImpl.h" #include "llvm/IR/DerivedTypes.h" #include "llvm/IR/InlineAsm.h" +#include "llvm/IR/InstIterator.h" #include "llvm/IR/Mangler.h" #include "llvm/IR/Module.h" #include "llvm/IR/Type.h" @@ -759,6 +760,28 @@ } } +/// True if this module is being built for windows/msvc, and uses floating +/// point. This is used to emit an undefined reference to _fltused. +static bool usesMSVCFloatingPoint(const Triple &TT, const Module &M) { + // Only needed for MSVC + if (!TT.isWindowsMSVCEnvironment()) + return false; + + for (const Function &F : M) { + for (const Instruction &I : instructions(F)) { + if (I.getType()->isFPOrFPVectorTy()) + return true; + + for (const auto &Op : I.operands()) { + if (Op->getType()->isFPOrFPVectorTy()) + return true; + } + } + } + + return false; +} + void X86AsmPrinter::emitEndOfAsmFile(Module &M) { const Triple &TT = TM.getTargetTriple(); @@ -778,7 +801,7 @@ // safe to set. OutStreamer->emitAssemblerFlag(MCAF_SubsectionsViaSymbols); } else if (TT.isOSBinFormatCOFF()) { - if (MMI->usesMSVCFloatingPoint()) { + if (usesMSVCFloatingPoint(TT, M)) { // In Windows' libcmt.lib, there is a file which is linked in only if the // symbol _fltused is referenced. Linking this in causes some // side-effects: