From 1438102576b94d6dac9bb18e8df291c4d632572d Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Wed, 31 Mar 2004 02:58:28 +0000 Subject: [PATCH] Fix linking of constant expr casts due to type resolution changes. With this and the other patches 253.perlbmk links again. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12565 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Linker/LinkModules.cpp | 8 ++++++++ lib/Transforms/Utils/Linker.cpp | 8 ++++++++ lib/VMCore/Linker.cpp | 8 ++++++++ 3 files changed, 24 insertions(+) diff --git a/lib/Linker/LinkModules.cpp b/lib/Linker/LinkModules.cpp index 529fb771489..c113ca1a0ff 100644 --- a/lib/Linker/LinkModules.cpp +++ b/lib/Linker/LinkModules.cpp @@ -325,6 +325,14 @@ static Value *RemapOperand(const Value *In, assert(CE->getOpcode() == Instruction::Cast); Value *V = RemapOperand(CE->getOperand(0), LocalMap, GlobalMap); Result = ConstantExpr::getCast(cast(V), CE->getType()); + } else if (CE->getNumOperands() == 3) { + // Select instruction + assert(CE->getOpcode() == Instruction::Select); + Value *V1 = RemapOperand(CE->getOperand(0), LocalMap, GlobalMap); + Value *V2 = RemapOperand(CE->getOperand(1), LocalMap, GlobalMap); + Value *V3 = RemapOperand(CE->getOperand(2), LocalMap, GlobalMap); + Result = ConstantExpr::getSelect(cast(V1), cast(V2), + cast(V3)); } else if (CE->getNumOperands() == 2) { // Binary operator... Value *V1 = RemapOperand(CE->getOperand(0), LocalMap, GlobalMap); diff --git a/lib/Transforms/Utils/Linker.cpp b/lib/Transforms/Utils/Linker.cpp index 529fb771489..c113ca1a0ff 100644 --- a/lib/Transforms/Utils/Linker.cpp +++ b/lib/Transforms/Utils/Linker.cpp @@ -325,6 +325,14 @@ static Value *RemapOperand(const Value *In, assert(CE->getOpcode() == Instruction::Cast); Value *V = RemapOperand(CE->getOperand(0), LocalMap, GlobalMap); Result = ConstantExpr::getCast(cast(V), CE->getType()); + } else if (CE->getNumOperands() == 3) { + // Select instruction + assert(CE->getOpcode() == Instruction::Select); + Value *V1 = RemapOperand(CE->getOperand(0), LocalMap, GlobalMap); + Value *V2 = RemapOperand(CE->getOperand(1), LocalMap, GlobalMap); + Value *V3 = RemapOperand(CE->getOperand(2), LocalMap, GlobalMap); + Result = ConstantExpr::getSelect(cast(V1), cast(V2), + cast(V3)); } else if (CE->getNumOperands() == 2) { // Binary operator... Value *V1 = RemapOperand(CE->getOperand(0), LocalMap, GlobalMap); diff --git a/lib/VMCore/Linker.cpp b/lib/VMCore/Linker.cpp index 529fb771489..c113ca1a0ff 100644 --- a/lib/VMCore/Linker.cpp +++ b/lib/VMCore/Linker.cpp @@ -325,6 +325,14 @@ static Value *RemapOperand(const Value *In, assert(CE->getOpcode() == Instruction::Cast); Value *V = RemapOperand(CE->getOperand(0), LocalMap, GlobalMap); Result = ConstantExpr::getCast(cast(V), CE->getType()); + } else if (CE->getNumOperands() == 3) { + // Select instruction + assert(CE->getOpcode() == Instruction::Select); + Value *V1 = RemapOperand(CE->getOperand(0), LocalMap, GlobalMap); + Value *V2 = RemapOperand(CE->getOperand(1), LocalMap, GlobalMap); + Value *V3 = RemapOperand(CE->getOperand(2), LocalMap, GlobalMap); + Result = ConstantExpr::getSelect(cast(V1), cast(V2), + cast(V3)); } else if (CE->getNumOperands() == 2) { // Binary operator... Value *V1 = RemapOperand(CE->getOperand(0), LocalMap, GlobalMap);