Fixes for Microsoft Visual Studio 2010, from Steven Watanabe!
authorDouglas Gregor <dgregor@apple.com>
Tue, 11 May 2010 06:17:44 +0000 (06:17 +0000)
committerDouglas Gregor <dgregor@apple.com>
Tue, 11 May 2010 06:17:44 +0000 (06:17 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@103457 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/ADT/EquivalenceClasses.h
lib/CodeGen/IntrinsicLowering.cpp
lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
lib/CodeGen/SelectionDAG/TargetLowering.cpp
lib/CodeGen/Spiller.cpp
lib/Transforms/Scalar/LoopStrengthReduce.cpp
lib/Transforms/Utils/PromoteMemoryToRegister.cpp
utils/TableGen/IntrinsicEmitter.cpp
utils/TableGen/IntrinsicEmitter.h

index 5f89823e8ba1f8508e2a54b36a6aba8a78f5ecdd..91a14294516ec9bd173471dc1f8f182ce085547e 100644 (file)
@@ -191,7 +191,7 @@ public:
   /// insert - Insert a new value into the union/find set, ignoring the request
   /// if the value already exists.
   iterator insert(const ElemTy &Data) {
-    return TheMapping.insert(Data).first;
+    return TheMapping.insert(ECValue(Data)).first;
   }
 
   /// findLeader - Given a value in the set, return a member iterator for the
index e1c52f72ac42bb8862802a86d60c0d170de751d2..63bb5f21f8f158ac64f865ce9bc66269daf8f245 100644 (file)
@@ -83,6 +83,12 @@ static CallInst *ReplaceCallWith(const char *NewFn, CallInst *CI,
   return NewCI;
 }
 
+// VisualStudio defines setjmp as _setjmp
+#if defined(_MSC_VER) && defined(setjmp)
+#define setjmp_undefined_for_visual_studio
+#undef setjmp
+#endif
+
 void IntrinsicLowering::AddPrototypes(Module &M) {
   LLVMContext &Context = M.getContext();
   for (Module::iterator I = M.begin(), E = M.end(); I != E; ++I)
index 1d87e79aa84c3d18d25f3f26200f33e5db193b55..695b7913b4895166138a5e9136061b3fc1113f53 100644 (file)
@@ -3726,6 +3726,12 @@ SelectionDAGBuilder::EmitFuncArgumentDbgValue(const DbgValueInst &DI,
   return true;
 }
 
+// VisualStudio defines setjmp as _setjmp
+#if defined(_MSC_VER) && defined(setjmp)
+#define setjmp_undefined_for_visual_studio
+#undef setjmp
+#endif
+
 /// visitIntrinsicCall - Lower the call to the specified intrinsic function.  If
 /// we want to emit this as a call to a named external function, return the name
 /// otherwise lower it and return null.
index 8a4a1b1726080cbcdb1a88f42912cfe9444e3eec..4642310abdf1664bfd26179fa0b044ac6131d821 100644 (file)
@@ -2417,7 +2417,7 @@ std::pair<unsigned, const TargetRegisterClass*> TargetLowering::
 getRegForInlineAsmConstraint(const std::string &Constraint,
                              EVT VT) const {
   if (Constraint[0] != '{')
-    return std::pair<unsigned, const TargetRegisterClass*>(0, 0);
+    return std::make_pair(0u, static_cast<TargetRegisterClass*>(0));
   assert(*(Constraint.end()-1) == '}' && "Not a brace enclosed constraint?");
 
   // Remove the braces from around the name.
@@ -2449,7 +2449,7 @@ getRegForInlineAsmConstraint(const std::string &Constraint,
     }
   }
   
-  return std::pair<unsigned, const TargetRegisterClass*>(0, 0);
+  return std::make_pair(0u, static_cast<const TargetRegisterClass*>(0));
 }
 
 //===----------------------------------------------------------------------===//
index 735ca316fa4323ad39b7892bf9659abff1c51194..a7b2efe118252ff8cfc998eae7c93d6b1453b486 100644 (file)
@@ -451,9 +451,9 @@ private:
         // reg.
         MachineBasicBlock *useMBB = useInst->getParent();
         MachineBasicBlock::iterator useItr(useInst);
-        tii->copyRegToReg(*useMBB, next(useItr), li->reg, newVReg, trc, trc,
+        tii->copyRegToReg(*useMBB, llvm::next(useItr), li->reg, newVReg, trc, trc,
                           DebugLoc());
-        MachineInstr *copyMI = next(useItr);
+        MachineInstr *copyMI = llvm::next(useItr);
         copyMI->addRegisterKilled(newVReg, tri);
         SlotIndex copyIdx = lis->InsertMachineInstrInMaps(copyMI);
 
index 61966f52f51c6508e587551eef873b136d2d07c6..2c6d27c76609aa6a96d8355c46280f793ab1cf15 100644 (file)
@@ -2899,7 +2899,7 @@ LSRInstance::HoistInsertPosition(BasicBlock::iterator IP,
       // instead of at the end, so that it can be used for other expansions.
       if (IDom == Inst->getParent() &&
           (!BetterPos || DT.dominates(BetterPos, Inst)))
-        BetterPos = next(BasicBlock::iterator(Inst));
+        BetterPos = llvm::next(BasicBlock::iterator(Inst));
     }
     if (!AllDominate)
       break;
index a769a3603ebd6d08028443cff9f1579b725b6f0b..13f0a28141ddebd65673ed43d0186b297d9721a7 100644 (file)
@@ -861,7 +861,7 @@ void PromoteMem2Reg::PromoteSingleBlockAlloca(AllocaInst *AI, AllocaInfo &Info,
     // Find the nearest store that has a lower than this load. 
     StoresByIndexTy::iterator I = 
       std::lower_bound(StoresByIndex.begin(), StoresByIndex.end(),
-                       std::pair<unsigned, StoreInst*>(LoadIdx, 0),
+                       std::pair<unsigned, StoreInst*>(LoadIdx, static_cast<StoreInst*>(0)),
                        StoreIndexSearchPredicate());
     
     // If there is no store before this load, then we can't promote this load.
index 417aca7cb37b1f9cf4204f80065292d6b5574f9f..d7a90513df33d8b62563afcd18ad4fc067dd6f46 100644 (file)
@@ -30,6 +30,8 @@ void IntrinsicEmitter::run(raw_ostream &OS) {
   if (TargetOnly && !Ints.empty())
     TargetPrefix = Ints[0].TargetPrefix;
 
+  EmitPrefix(OS);
+
   // Emit the enum information.
   EmitEnumInfo(Ints, OS);
 
@@ -59,6 +61,23 @@ void IntrinsicEmitter::run(raw_ostream &OS) {
 
   // Emit code to translate GCC builtins into LLVM intrinsics.
   EmitIntrinsicToGCCBuiltinMap(Ints, OS);
+
+  EmitSuffix(OS);
+}
+
+void IntrinsicEmitter::EmitPrefix(raw_ostream &OS) {
+  OS << "// VisualStudio defines setjmp as _setjmp\n"
+        "#if defined(_MSC_VER) && defined(setjmp)\n"
+        "#define setjmp_undefined_for_visual_studio\n"
+        "#undef setjmp\n"
+        "#endif\n\n";
+}
+
+void IntrinsicEmitter::EmitSuffix(raw_ostream &OS) {
+  OS << "#if defined(_MSC_VER) && defined(setjmp_undefined_for_visual_studio)\n"
+        "// let's return it to _setjmp state\n"
+        "#define setjmp _setjmp\n"
+        "#endif\n\n";
 }
 
 void IntrinsicEmitter::EmitEnumInfo(const std::vector<CodeGenIntrinsic> &Ints,
index c3c92bcc569415ea7bfd9a5a6b22c28ac6d259c2..b1efecb92eea386614a26fe998ebf7d10a7f01e1 100644 (file)
@@ -28,6 +28,8 @@ namespace llvm {
       : Records(R), TargetOnly(T) {}
 
     void run(raw_ostream &OS);
+
+    void EmitPrefix(raw_ostream &OS);
     
     void EmitEnumInfo(const std::vector<CodeGenIntrinsic> &Ints, 
                       raw_ostream &OS);
@@ -50,6 +52,7 @@ namespace llvm {
                             raw_ostream &OS);
     void EmitIntrinsicToGCCBuiltinMap(const std::vector<CodeGenIntrinsic> &Ints, 
                                       raw_ostream &OS);
+    void EmitSuffix(raw_ostream &OS);
   };
 
 } // End llvm namespace