diff options
author | Chris Lattner <sabre@nondot.org> | 2002-08-20 19:35:11 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2002-08-20 19:35:11 +0000 |
commit | b319faff77a5bb12e753c45662f6c532b77f0b91 (patch) | |
tree | 3cbe50ceaf14f277c7d40adc1cae52050608d1e2 /lib/Linker | |
parent | f2b6b0288bdad4a7d0d4d075a967ffd8ba07467f (diff) | |
download | external_llvm-b319faff77a5bb12e753c45662f6c532b77f0b91.zip external_llvm-b319faff77a5bb12e753c45662f6c532b77f0b91.tar.gz external_llvm-b319faff77a5bb12e753c45662f6c532b77f0b91.tar.bz2 |
fixed bug: test/Regression/Linker/2002-08-20-ConstantExpr.ll
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@3412 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Linker')
-rw-r--r-- | lib/Linker/LinkModules.cpp | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/lib/Linker/LinkModules.cpp b/lib/Linker/LinkModules.cpp index 21e25b4..beab3d5 100644 --- a/lib/Linker/LinkModules.cpp +++ b/lib/Linker/LinkModules.cpp @@ -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 { |