From 2b5cfe8be8b7e0d9fce498c57bab52d9a175f8f3 Mon Sep 17 00:00:00 2001
From: Reid Spencer <rspencer@reidspencer.com>
Date: Mon, 18 Oct 2004 14:38:48 +0000
Subject: [PATCH] Correction to allow compilation with Visual C++.

Patch contributed by Morten Ofstad. Thanks Morten!

llvm-svn: 17123
---
 .../Instrumentation/ProfilePaths/GraphAuxiliary.cpp           | 4 ++--
 lib/Transforms/Scalar/LoopUnroll.cpp                          | 2 ++
 lib/Transforms/Scalar/LowerGC.cpp                             | 4 ++--
 lib/Transforms/Utils/PromoteMemoryToRegister.cpp              | 4 ++--
 4 files changed, 8 insertions(+), 6 deletions(-)

diff --git a/lib/Transforms/Instrumentation/ProfilePaths/GraphAuxiliary.cpp b/lib/Transforms/Instrumentation/ProfilePaths/GraphAuxiliary.cpp
index 10ef440b4f8..bd1fa51621e 100644
--- a/lib/Transforms/Instrumentation/ProfilePaths/GraphAuxiliary.cpp
+++ b/lib/Transforms/Instrumentation/ProfilePaths/GraphAuxiliary.cpp
@@ -638,7 +638,7 @@ void processGraph(Graph &g,
 #ifdef DEBUG_PATH_PROFILES
   //debugging info
   cerr<<"After moving dummy code\n";
-  for(map<Edge, getEdgeCode *>::iterator cd_i=codeInsertions.begin(), 
+  for(map<Edge, getEdgeCode *,EdgeCompare2>::iterator cd_i=codeInsertions.begin(), 
 	cd_e=codeInsertions.end(); cd_i != cd_e; ++cd_i){
     printEdge(cd_i->first);
     cerr<<cd_i->second->getCond()<<":"
@@ -650,7 +650,7 @@ void processGraph(Graph &g,
 
   //see what it looks like...
   //now insert code along edges which have codes on them
-  for(map<Edge, getEdgeCode *>::iterator MI=codeInsertions.begin(), 
+  for(map<Edge, getEdgeCode *,EdgeCompare2>::iterator MI=codeInsertions.begin(), 
 	ME=codeInsertions.end(); MI!=ME; ++MI){
     Edge ed=MI->first;
     insertBB(ed, MI->second, rInst, countInst, numPaths, MethNo, threshold);
diff --git a/lib/Transforms/Scalar/LoopUnroll.cpp b/lib/Transforms/Scalar/LoopUnroll.cpp
index 17fc35d6a32..f87b2cae933 100644
--- a/lib/Transforms/Scalar/LoopUnroll.cpp
+++ b/lib/Transforms/Scalar/LoopUnroll.cpp
@@ -30,6 +30,8 @@
 #include "llvm/ADT/STLExtras.h"
 #include <cstdio>
 #include <set>
+#include <algorithm>
+
 using namespace llvm;
 
 namespace {
diff --git a/lib/Transforms/Scalar/LowerGC.cpp b/lib/Transforms/Scalar/LowerGC.cpp
index 2e03807ed24..ee31688f946 100644
--- a/lib/Transforms/Scalar/LowerGC.cpp
+++ b/lib/Transforms/Scalar/LowerGC.cpp
@@ -143,8 +143,8 @@ static void Coerce(Instruction *I, unsigned OpNum, Type *Ty) {
     if (Constant *C = dyn_cast<Constant>(I->getOperand(OpNum))) 
       I->setOperand(OpNum, ConstantExpr::getCast(C, Ty));
     else {
-      CastInst *C = new CastInst(I->getOperand(OpNum), Ty, "", I);
-      I->setOperand(OpNum, C);
+      CastInst *CI = new CastInst(I->getOperand(OpNum), Ty, "", I);
+      I->setOperand(OpNum, CI);
     }
   }
 }
diff --git a/lib/Transforms/Utils/PromoteMemoryToRegister.cpp b/lib/Transforms/Utils/PromoteMemoryToRegister.cpp
index 3311bd1c20b..213b3d742f4 100644
--- a/lib/Transforms/Utils/PromoteMemoryToRegister.cpp
+++ b/lib/Transforms/Utils/PromoteMemoryToRegister.cpp
@@ -220,8 +220,8 @@ void PromoteMem2Reg::run() {
         // (unspecified) ordering of basic blocks in the dominance frontier,
         // which would give PHI nodes non-determinstic subscripts.  Fix this by
         // processing blocks in order of the occurance in the function.
-        for (DominanceFrontier::DomSetType::iterator P = S.begin(),PE = S.end();
-             P != PE; ++P)
+        for (DominanceFrontier::DomSetType::const_iterator P = S.begin(),
+             PE = S.end(); P != PE; ++P)
           DFBlocks.push_back(BBNumbers.getNumber(*P));
 
         // Sort by which the block ordering in the function.