fixed bug: test/Regression/Linker/2002-08-20-ConstantExpr.ll
authorChris Lattner <sabre@nondot.org>
Tue, 20 Aug 2002 19:35:11 +0000 (19:35 +0000)
committerChris Lattner <sabre@nondot.org>
Tue, 20 Aug 2002 19:35:11 +0000 (19:35 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@3412 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Linker/LinkModules.cpp
lib/Transforms/Utils/Linker.cpp
lib/VMCore/Linker.cpp

index 21e25b444a1d7f321bfbca1d0f637264fe611e4f..beab3d5a847eab8a0ae010552fc2982fcf1529f7 100644 (file)
@@ -118,7 +118,16 @@ static Value *RemapOperand(const Value *In, map<const Value*, Value*> &LocalMap,
       Value *V = RemapOperand(CPR->getValue(), LocalMap, GlobalMap);
       Result = ConstantPointerRef::get(cast<GlobalValue>(V));
     } else if (const ConstantExpr *CE = dyn_cast<ConstantExpr>(CPV)) {
-      if (CE->getNumOperands() == 1) {
+      if (CE->getOpcode() == Instruction::GetElementPtr) {
+        Value *Ptr = RemapOperand(CE->getOperand(0), LocalMap, GlobalMap);
+        std::vector<Constant*> Indices;
+        Indices.reserve(CE->getNumOperands()-1);
+        for (unsigned i = 1, e = CE->getNumOperands(); i != e; ++i)
+          Indices.push_back(cast<Constant>(RemapOperand(CE->getOperand(i),
+                                                        LocalMap, GlobalMap)));
+
+        Result = ConstantExpr::getGetElementPtr(cast<Constant>(Ptr), Indices);
+      } else if (CE->getNumOperands() == 1) {
         // Cast instruction
         assert(CE->getOpcode() == Instruction::Cast);
         Value *V = RemapOperand(CE->getOperand(0), LocalMap, GlobalMap);
@@ -131,16 +140,7 @@ static Value *RemapOperand(const Value *In, map<const Value*, Value*> &LocalMap,
         Result = ConstantExpr::get(CE->getOpcode(), cast<Constant>(V1),
                                    cast<Constant>(V2));        
       } else {
-        // GetElementPtr Expression
-        assert(CE->getOpcode() == Instruction::GetElementPtr);
-        Value *Ptr = RemapOperand(CE->getOperand(0), LocalMap, GlobalMap);
-        std::vector<Constant*> Indices;
-        Indices.reserve(CE->getNumOperands()-1);
-        for (unsigned i = 1, e = CE->getNumOperands(); i != e; ++i)
-          Indices.push_back(cast<Constant>(RemapOperand(CE->getOperand(i),
-                                                        LocalMap, GlobalMap)));
-
-        Result = ConstantExpr::getGetElementPtr(cast<Constant>(Ptr), Indices);
+        assert(0 && "Unknown constant expr type!");
       }
 
     } else {
index 21e25b444a1d7f321bfbca1d0f637264fe611e4f..beab3d5a847eab8a0ae010552fc2982fcf1529f7 100644 (file)
@@ -118,7 +118,16 @@ static Value *RemapOperand(const Value *In, map<const Value*, Value*> &LocalMap,
       Value *V = RemapOperand(CPR->getValue(), LocalMap, GlobalMap);
       Result = ConstantPointerRef::get(cast<GlobalValue>(V));
     } else if (const ConstantExpr *CE = dyn_cast<ConstantExpr>(CPV)) {
-      if (CE->getNumOperands() == 1) {
+      if (CE->getOpcode() == Instruction::GetElementPtr) {
+        Value *Ptr = RemapOperand(CE->getOperand(0), LocalMap, GlobalMap);
+        std::vector<Constant*> Indices;
+        Indices.reserve(CE->getNumOperands()-1);
+        for (unsigned i = 1, e = CE->getNumOperands(); i != e; ++i)
+          Indices.push_back(cast<Constant>(RemapOperand(CE->getOperand(i),
+                                                        LocalMap, GlobalMap)));
+
+        Result = ConstantExpr::getGetElementPtr(cast<Constant>(Ptr), Indices);
+      } else if (CE->getNumOperands() == 1) {
         // Cast instruction
         assert(CE->getOpcode() == Instruction::Cast);
         Value *V = RemapOperand(CE->getOperand(0), LocalMap, GlobalMap);
@@ -131,16 +140,7 @@ static Value *RemapOperand(const Value *In, map<const Value*, Value*> &LocalMap,
         Result = ConstantExpr::get(CE->getOpcode(), cast<Constant>(V1),
                                    cast<Constant>(V2));        
       } else {
-        // GetElementPtr Expression
-        assert(CE->getOpcode() == Instruction::GetElementPtr);
-        Value *Ptr = RemapOperand(CE->getOperand(0), LocalMap, GlobalMap);
-        std::vector<Constant*> Indices;
-        Indices.reserve(CE->getNumOperands()-1);
-        for (unsigned i = 1, e = CE->getNumOperands(); i != e; ++i)
-          Indices.push_back(cast<Constant>(RemapOperand(CE->getOperand(i),
-                                                        LocalMap, GlobalMap)));
-
-        Result = ConstantExpr::getGetElementPtr(cast<Constant>(Ptr), Indices);
+        assert(0 && "Unknown constant expr type!");
       }
 
     } else {
index 21e25b444a1d7f321bfbca1d0f637264fe611e4f..beab3d5a847eab8a0ae010552fc2982fcf1529f7 100644 (file)
@@ -118,7 +118,16 @@ static Value *RemapOperand(const Value *In, map<const Value*, Value*> &LocalMap,
       Value *V = RemapOperand(CPR->getValue(), LocalMap, GlobalMap);
       Result = ConstantPointerRef::get(cast<GlobalValue>(V));
     } else if (const ConstantExpr *CE = dyn_cast<ConstantExpr>(CPV)) {
-      if (CE->getNumOperands() == 1) {
+      if (CE->getOpcode() == Instruction::GetElementPtr) {
+        Value *Ptr = RemapOperand(CE->getOperand(0), LocalMap, GlobalMap);
+        std::vector<Constant*> Indices;
+        Indices.reserve(CE->getNumOperands()-1);
+        for (unsigned i = 1, e = CE->getNumOperands(); i != e; ++i)
+          Indices.push_back(cast<Constant>(RemapOperand(CE->getOperand(i),
+                                                        LocalMap, GlobalMap)));
+
+        Result = ConstantExpr::getGetElementPtr(cast<Constant>(Ptr), Indices);
+      } else if (CE->getNumOperands() == 1) {
         // Cast instruction
         assert(CE->getOpcode() == Instruction::Cast);
         Value *V = RemapOperand(CE->getOperand(0), LocalMap, GlobalMap);
@@ -131,16 +140,7 @@ static Value *RemapOperand(const Value *In, map<const Value*, Value*> &LocalMap,
         Result = ConstantExpr::get(CE->getOpcode(), cast<Constant>(V1),
                                    cast<Constant>(V2));        
       } else {
-        // GetElementPtr Expression
-        assert(CE->getOpcode() == Instruction::GetElementPtr);
-        Value *Ptr = RemapOperand(CE->getOperand(0), LocalMap, GlobalMap);
-        std::vector<Constant*> Indices;
-        Indices.reserve(CE->getNumOperands()-1);
-        for (unsigned i = 1, e = CE->getNumOperands(); i != e; ++i)
-          Indices.push_back(cast<Constant>(RemapOperand(CE->getOperand(i),
-                                                        LocalMap, GlobalMap)));
-
-        Result = ConstantExpr::getGetElementPtr(cast<Constant>(Ptr), Indices);
+        assert(0 && "Unknown constant expr type!");
       }
 
     } else {