CodeGen-Windows: Only emit _fltused if a VarArg function is called with floating...
authorMichael J. Spencer <bigcheesegs@gmail.com>
Thu, 21 Oct 2010 00:08:21 +0000 (00:08 +0000)
committerMichael J. Spencer <bigcheesegs@gmail.com>
Thu, 21 Oct 2010 00:08:21 +0000 (00:08 +0000)
This should be the minimum set of functions that could possibly need it.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@116978 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/CodeGen/MachineModuleInfo.h
lib/CodeGen/MachineModuleInfo.cpp
lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
lib/Target/X86/X86AsmPrinter.cpp

index 4376478ec2e7bdfe3fba3cd4711fd0f619c8324f..43405c0937642cdfb088064805ac252f1f6b25e1 100644 (file)
@@ -157,10 +157,9 @@ class MachineModuleInfo : public ImmutablePass {
   /// in this module.
   bool DbgInfoAvailable;
 
-  /// True if this module calls an external function with floating point
-  /// arguments. This is used to emit an undefined reference to fltused on
-  /// Windows targets.
-  bool CallsExternalFunctionWithFloatingPointArguments;
+  /// True if this module calls VarArg function with floating point arguments.
+  /// This is used to emit an undefined reference to fltused on Windows targets.
+  bool CallsExternalVAFunctionWithFloatingPointArguments;
 
 public:
   static char ID; // Pass identification, replacement for typeid
@@ -217,12 +216,12 @@ public:
   bool callsUnwindInit() const { return CallsUnwindInit; }
   void setCallsUnwindInit(bool b) { CallsUnwindInit = b; }
 
-  bool callsExternalFunctionWithFloatingPointArguments() const {
-    return CallsExternalFunctionWithFloatingPointArguments;
+  bool callsExternalVAFunctionWithFloatingPointArguments() const {
+    return CallsExternalVAFunctionWithFloatingPointArguments;
   }
 
-  void setCallsExternalFunctionWithFloatingPointArguments(bool b) {
-    CallsExternalFunctionWithFloatingPointArguments = b;
+  void setCallsExternalVAFunctionWithFloatingPointArguments(bool b) {
+    CallsExternalVAFunctionWithFloatingPointArguments = b;
   }
 
   /// getFrameMoves - Returns a reference to a list of moves done in the current
index 5c8b37315cd524aa98a4adbe94d2dab8613ac044..79622e8df3eda4131b690834155377b90e869da2 100644 (file)
@@ -257,7 +257,7 @@ MachineModuleInfo::MachineModuleInfo(const MCAsmInfo &MAI)
 : ImmutablePass(ID), Context(MAI),
   ObjFileMMI(0),
   CurCallSite(0), CallsEHReturn(0), CallsUnwindInit(0), DbgInfoAvailable(false),
-  CallsExternalFunctionWithFloatingPointArguments(false) {
+  CallsExternalVAFunctionWithFloatingPointArguments(false) {
   initializeMachineModuleInfoPass(*PassRegistry::getPassRegistry());
   // Always emit some info, by default "no personality" info.
   Personalities.push_back(NULL);
index a68b7b0f947de8870f4132566cce540be5dbca36..4be2525cfa181b106babd838995584e26dd8d5d4 100644 (file)
@@ -5030,16 +5030,16 @@ void SelectionDAGBuilder::visitCall(const CallInst &I) {
     // See if any floating point values are being passed to this external
     // function. This is used to emit an undefined reference to fltused on
     // Windows.
-    if (!F->hasLocalLinkage() && F->hasName()) {
-      MachineModuleInfo &MMI = DAG.getMachineFunction().getMMI();
-      for (unsigned i = 0, e = I.getNumArgOperands(); i != e &&
-                  !MMI.callsExternalFunctionWithFloatingPointArguments(); ++i) {
+    MachineModuleInfo &MMI = DAG.getMachineFunction().getMMI();
+    if (F->isVarArg() &&
+        !MMI.callsExternalVAFunctionWithFloatingPointArguments()) {
+      for (unsigned i = 0, e = I.getNumArgOperands(); i != e; ++i) {
         const Type* T = I.getArgOperand(i)->getType();
         for (po_iterator<const Type*> i = po_begin(T),
                                       e = po_end(T);
                                       i != e; ++i) {
           if (i->isFloatingPointTy()) {
-            MMI.setCallsExternalFunctionWithFloatingPointArguments(true);
+            MMI.setCallsExternalVAFunctionWithFloatingPointArguments(true);
             break;
           }
         }
index c4fd7298b576e48e09a3d6a0b37e5e7532603967..f7cb9e71f67167b584d7c887276d474919d23c0e 100644 (file)
@@ -582,7 +582,7 @@ void X86AsmPrinter::EmitEndOfAsmFile(Module &M) {
 
   if (Subtarget->isTargetWindows()
    && !Subtarget->isTargetCygMing()
-   && MMI->callsExternalFunctionWithFloatingPointArguments()) {
+   && MMI->callsExternalVAFunctionWithFloatingPointArguments()) {
     MCSymbol *S = MMI->getContext().GetOrCreateSymbol(StringRef("__fltused"));
     OutStreamer.EmitSymbolAttribute(S, MCSA_Global);
   }