+/// ParseGlobalVariable - Handle parsing of a global. If Initializer is null,
+/// this is a declaration, otherwise it is a definition.
+static void ParseGlobalVariable(char *NameStr,GlobalValue::LinkageTypes Linkage,
+ bool isConstantGlobal, const Type *Ty,
+ Constant *Initializer) {
+ // Global declarations appear in Constant Pool
+ GlobalVariable *GV = new GlobalVariable(Ty, isConstantGlobal, Linkage,
+ Initializer);
+ if (!setValueNameMergingDuplicates(GV, NameStr)) { // If not redefining...
+ CurModule.CurrentModule->getGlobalList().push_back(GV);
+ int Slot = InsertValue(GV, CurModule.Values);
+
+ if (Slot != -1) {
+ CurModule.DeclareNewGlobalValue(GV, ValID::create(Slot));
+ } else {
+ CurModule.DeclareNewGlobalValue(GV,
+ ValID::create((char*)GV->getName().c_str()));
+ }
+ }
+}