forked from OSchip/llvm-project
simplify and comment some code better. Make BindRuntimeGlobals
more optimistic that it will work (optimizing for the common case). llvm-svn: 67438
This commit is contained in:
parent
3637652ab3
commit
0c5e3132aa
|
@ -29,6 +29,7 @@ using namespace CodeGen;
|
||||||
/// block.
|
/// block.
|
||||||
llvm::AllocaInst *CodeGenFunction::CreateTempAlloca(const llvm::Type *Ty,
|
llvm::AllocaInst *CodeGenFunction::CreateTempAlloca(const llvm::Type *Ty,
|
||||||
const char *Name) {
|
const char *Name) {
|
||||||
|
// FIXME: Should not pass name if names are disabled in IRBuilder.
|
||||||
return new llvm::AllocaInst(Ty, 0, Name, AllocaInsertPt);
|
return new llvm::AllocaInst(Ty, 0, Name, AllocaInsertPt);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -81,9 +81,16 @@ void CodeGenModule::BindRuntimeGlobals() {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
// See if there is a conflict against a function.
|
// See if there is a conflict against a function by setting the name and
|
||||||
|
// seeing if we got the desired name.
|
||||||
|
GV->setName(Name);
|
||||||
|
if (GV->isName(Name.c_str()))
|
||||||
|
continue; // Yep, it worked!
|
||||||
|
|
||||||
|
GV->setName(""); // Zap the bogus name until we work out the conflict.
|
||||||
llvm::GlobalValue *Conflict = TheModule.getNamedValue(Name);
|
llvm::GlobalValue *Conflict = TheModule.getNamedValue(Name);
|
||||||
if (Conflict) {
|
assert(Conflict && "Must have conflicted!");
|
||||||
|
|
||||||
// Decide which version to take. If the conflict is a definition
|
// Decide which version to take. If the conflict is a definition
|
||||||
// we are forced to take that, otherwise assume the runtime
|
// we are forced to take that, otherwise assume the runtime
|
||||||
// knows best.
|
// knows best.
|
||||||
|
@ -105,8 +112,6 @@ void CodeGenModule::BindRuntimeGlobals() {
|
||||||
Conflict->replaceAllUsesWith(Casted);
|
Conflict->replaceAllUsesWith(Casted);
|
||||||
Conflict->eraseFromParent();
|
Conflict->eraseFromParent();
|
||||||
}
|
}
|
||||||
} else
|
|
||||||
GV->setName(Name);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -94,7 +94,7 @@ class CodeGenModule : public BlockModule {
|
||||||
/// emitted. Note that the entries in this map are the actual
|
/// emitted. Note that the entries in this map are the actual
|
||||||
/// globals and therefore may not be of the same type as the decl,
|
/// globals and therefore may not be of the same type as the decl,
|
||||||
/// they should be bitcasted on retrieval. Also note that the
|
/// they should be bitcasted on retrieval. Also note that the
|
||||||
/// globals are keyed on their source name, not the global name
|
/// globals are keyed on their source mangled name, not the global name
|
||||||
/// (which may change with attributes such as asm-labels). This key
|
/// (which may change with attributes such as asm-labels). This key
|
||||||
/// to this map should be generated using getMangledName().
|
/// to this map should be generated using getMangledName().
|
||||||
llvm::DenseMap<const char*, llvm::GlobalValue*> GlobalDeclMap;
|
llvm::DenseMap<const char*, llvm::GlobalValue*> GlobalDeclMap;
|
||||||
|
@ -141,6 +141,9 @@ class CodeGenModule : public BlockModule {
|
||||||
/// strings. This value has type int * but is actually an Obj-C class pointer.
|
/// strings. This value has type int * but is actually an Obj-C class pointer.
|
||||||
llvm::Constant *CFConstantStringClassRef;
|
llvm::Constant *CFConstantStringClassRef;
|
||||||
|
|
||||||
|
/// BuiltinFunctions - This is the cached set of Function*'s that have been
|
||||||
|
/// created for each builtin, indexed by the Builtin ID. This is null if the
|
||||||
|
/// Function* has not yet been created.
|
||||||
std::vector<llvm::Value *> BuiltinFunctions;
|
std::vector<llvm::Value *> BuiltinFunctions;
|
||||||
public:
|
public:
|
||||||
CodeGenModule(ASTContext &C, const LangOptions &Features, llvm::Module &M,
|
CodeGenModule(ASTContext &C, const LangOptions &Features, llvm::Module &M,
|
||||||
|
|
Loading…
Reference in New Issue