[llvm-commits] [llvm] r40558 - in /llvm/trunk: lib/ExecutionEngine/Interpreter/ExternalFunctions.cpp lib/Transforms/Scalar/LoopUnswitch.cpp utils/TableGen/RegisterInfoEmitter.cpp

Chuck Rose III cfr at adobe.com
Fri Jul 27 11:26:35 PDT 2007


Author: cfr
Date: Fri Jul 27 13:26:35 2007
New Revision: 40558

URL: http://llvm.org/viewvc/llvm-project?rev=40558&view=rev
Log:
VStudio compiler errors and placing Function*->ExFunc map under ManagedStatic control.

This commit fixes two things.  One is a pair of VStudio compiler errors stemming from variables
which defined within the for loop statement and also within the body of the for loop.  I fixed these 
by renaming one of the two variables.  Additionally, I've made the Function*->ExFunc map in 
ExternalFunctions.cpp a ManagedStatic object, so that cleanup will be done on llvm_shutdown.  In repeated
uses of the interpreter, where the same Function* address may get used for completely differnet functions,
this was causing a crash.

Modified:
    llvm/trunk/lib/ExecutionEngine/Interpreter/ExternalFunctions.cpp
    llvm/trunk/lib/Transforms/Scalar/LoopUnswitch.cpp
    llvm/trunk/utils/TableGen/RegisterInfoEmitter.cpp

Modified: llvm/trunk/lib/ExecutionEngine/Interpreter/ExternalFunctions.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ExecutionEngine/Interpreter/ExternalFunctions.cpp?rev=40558&r1=40557&r2=40558&view=diff

==============================================================================
--- llvm/trunk/lib/ExecutionEngine/Interpreter/ExternalFunctions.cpp (original)
+++ llvm/trunk/lib/ExecutionEngine/Interpreter/ExternalFunctions.cpp Fri Jul 27 13:26:35 2007
@@ -25,6 +25,7 @@
 #include "llvm/Support/Streams.h"
 #include "llvm/System/DynamicLibrary.h"
 #include "llvm/Target/TargetData.h"
+#include "llvm/Support/ManagedStatic.h"
 #include <csignal>
 #include <map>
 #include <cmath>
@@ -33,7 +34,7 @@
 using namespace llvm;
 
 typedef GenericValue (*ExFunc)(FunctionType *, const vector<GenericValue> &);
-static std::map<const Function *, ExFunc> Functions;
+static ManagedStatic<std::map<const Function *, ExFunc> > Functions;
 static std::map<std::string, ExFunc> FuncNames;
 
 static Interpreter *TheInterpreter;
@@ -80,7 +81,7 @@
     FnPtr = (ExFunc)(intptr_t)
       sys::DynamicLibrary::SearchForAddressOfSymbol(F->getName());
   if (FnPtr != 0)
-    Functions.insert(std::make_pair(F, FnPtr));  // Cache for later
+    Functions->insert(std::make_pair(F, FnPtr));  // Cache for later
   return FnPtr;
 }
 
@@ -90,8 +91,8 @@
 
   // Do a lookup to see if the function is in our cache... this should just be a
   // deferred annotation!
-  std::map<const Function *, ExFunc>::iterator FI = Functions.find(F);
-  ExFunc Fn = (FI == Functions.end()) ? lookupFunction(F) : FI->second;
+  std::map<const Function *, ExFunc>::iterator FI = Functions->find(F);
+  ExFunc Fn = (FI == Functions->end()) ? lookupFunction(F) : FI->second;
   if (Fn == 0) {
     cerr << "Tried to execute an unknown external function: "
          << F->getType()->getDescription() << " " << F->getName() << "\n";

Modified: llvm/trunk/lib/Transforms/Scalar/LoopUnswitch.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/LoopUnswitch.cpp?rev=40558&r1=40557&r2=40558&view=diff

==============================================================================
--- llvm/trunk/lib/Transforms/Scalar/LoopUnswitch.cpp (original)
+++ llvm/trunk/lib/Transforms/Scalar/LoopUnswitch.cpp Fri Jul 27 13:26:35 2007
@@ -482,9 +482,9 @@
       for (DominanceFrontier::DomSetType::iterator I = S.begin(), E = S.end();
            I != E; ++I) {
         BasicBlock *BB = *I;
-        DenseMap<const Value*, Value*>::iterator I = VM.find(BB);
-        if (I != VM.end())
-          NewDFSet.insert(cast<BasicBlock>(I->second));
+        DenseMap<const Value*, Value*>::iterator IDM = VM.find(BB);
+        if (IDM != VM.end())
+          NewDFSet.insert(cast<BasicBlock>(IDM->second));
         else
           NewDFSet.insert(BB);
       }

Modified: llvm/trunk/utils/TableGen/RegisterInfoEmitter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/RegisterInfoEmitter.cpp?rev=40558&r1=40557&r2=40558&view=diff

==============================================================================
--- llvm/trunk/utils/TableGen/RegisterInfoEmitter.cpp (original)
+++ llvm/trunk/utils/TableGen/RegisterInfoEmitter.cpp Fri Jul 27 13:26:35 2007
@@ -240,8 +240,8 @@
 
       bool Empty = true;
       
-      for (unsigned subrc = 0, e2 = RC.SubRegClasses.size();
-            subrc != e2; ++subrc) {
+      for (unsigned subrc = 0, subrcMax = RC.SubRegClasses.size();
+            subrc != subrcMax; ++subrc) {
         unsigned rc2 = 0, e2 = RegisterClasses.size();
         for (; rc2 != e2; ++rc2) {
           const CodeGenRegisterClass &RC2 =  RegisterClasses[rc2];





More information about the llvm-commits mailing list