[llvm-commits] Two patches: some VStudio compiler errors and an interpreter multi-use crash

Reid Spencer rspencer at reidspencer.com
Fri Jul 27 10:04:56 PDT 2007


Chuck,

Looks okay to me.  Some feedback for you ..

Reid.

On Fri, 2007-07-27 at 09:31 -0700, Chuck Rose III wrote:

> 
> Index: ExecutionEngine/Interpreter/ExternalFunctions.cpp
> ===================================================================
> --- ExecutionEngine/Interpreter/ExternalFunctions.cpp   (revision
> 40471)
> +++ ExecutionEngine/Interpreter/ExternalFunctions.cpp   (working copy)
> @@ -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;

Why not make FuncNames a ManagedStatic as well?

>  
>  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";
> Index: Transforms/Scalar/LoopUnswitch.cpp
> ===================================================================
> --- Transforms/Scalar/LoopUnswitch.cpp  (revision 40471)
> +++ Transforms/Scalar/LoopUnswitch.cpp  (working copy)
> @@ -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));

I assume this is because of a VC++ error/warning on the redefinition of
I ?

>          else
>            NewDFSet.insert(BB);
>        }
> 


> Index: TableGen/RegisterInfoEmitter.cpp
> ===================================================================
> --- TableGen/RegisterInfoEmitter.cpp    (revision 40471)
> +++ TableGen/RegisterInfoEmitter.cpp    (working copy)
> @@ -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