Add comment.
[oota-llvm.git] / lib / VMCore / Globals.cpp
index 41a9adda079b4a4b1f2f090cf2ab1a6cff87a64d..dae22e48aea1294ed49da7c65de9f02c93ab20ac 100644 (file)
@@ -2,8 +2,8 @@
 //
 //                     The LLVM Compiler Infrastructure
 //
-// This file was developed by the LLVM research group and is distributed under
-// the University of Illinois Open Source License. See LICENSE.TXT for details.
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
 //
 //===----------------------------------------------------------------------===//
 //
@@ -85,8 +85,9 @@ void GlobalValue::destroyConstant() {
 
 GlobalVariable::GlobalVariable(const Type *Ty, bool constant, LinkageTypes Link,
                                Constant *InitVal, const std::string &Name,
-                               Module *ParentModule, bool ThreadLocal)
-  : GlobalValue(PointerType::get(Ty), Value::GlobalVariableVal,
+                               Module *ParentModule, bool ThreadLocal, 
+                               unsigned AddressSpace)
+  : GlobalValue(PointerType::get(Ty, AddressSpace), Value::GlobalVariableVal,
                 &Initializer, InitVal != 0, Link, Name),
     isConstantGlobal(constant), isThreadLocalSymbol(ThreadLocal) {
   if (InitVal) {
@@ -105,8 +106,9 @@ GlobalVariable::GlobalVariable(const Type *Ty, bool constant, LinkageTypes Link,
 
 GlobalVariable::GlobalVariable(const Type *Ty, bool constant, LinkageTypes Link,
                                Constant *InitVal, const std::string &Name,
-                               GlobalVariable *Before, bool ThreadLocal)
-  : GlobalValue(PointerType::get(Ty), Value::GlobalVariableVal,
+                               GlobalVariable *Before, bool ThreadLocal,
+                               unsigned AddressSpace)
+  : GlobalValue(PointerType::get(Ty, AddressSpace), Value::GlobalVariableVal,
                 &Initializer, InitVal != 0, Link, Name), 
     isConstantGlobal(constant), isThreadLocalSymbol(ThreadLocal) {
   if (InitVal) {
@@ -210,7 +212,7 @@ void GlobalAlias::setAliasee(Constant *Aliasee)
   setOperand(0, Aliasee);
 }
 
-const GlobalValue *GlobalAlias::getAliasedGlobal() const  {
+const GlobalValue *GlobalAlias::getAliasedGlobal() const {
   const Constant *C = getAliasee();
   if (C) {
     if (const GlobalValue *GV = dyn_cast<GlobalValue>(C))
@@ -218,12 +220,13 @@ const GlobalValue *GlobalAlias::getAliasedGlobal() const  {
     else {
       const ConstantExpr *CE = 0;
       if ((CE = dyn_cast<ConstantExpr>(C)) &&
-          (CE->getOpcode() == Instruction::BitCast))
-        return cast<GlobalValue>(CE->getOperand(0));
+          (CE->getOpcode() == Instruction::BitCast || 
+           CE->getOpcode() == Instruction::GetElementPtr))
+        return dyn_cast<GlobalValue>(CE->getOperand(0));
       else
         assert(0 && "Unsupported aliasee");
     }
-  } else
-    return 0;
+  }
+  return 0;
 }