Add code to RemapOperand() to handle Instruction::ExtractElement and
authorEvan Cheng <evan.cheng@apple.com>
Fri, 7 Apr 2006 01:27:42 +0000 (01:27 +0000)
committerEvan Cheng <evan.cheng@apple.com>
Fri, 7 Apr 2006 01:27:42 +0000 (01:27 +0000)
Instruction::InsertElement.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@27477 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Linker/LinkModules.cpp

index aeef9e65e0235a57753b02601d28c6d06a763b40..c8ea03898e348a0568b93d9811377a57f3e0a4de 100644 (file)
@@ -305,6 +305,18 @@ static Value *RemapOperand(const Value *In,
                                                         ValueMap)));
 
         Result = ConstantExpr::getGetElementPtr(cast<Constant>(Ptr), Indices);
+      } else if (CE->getOpcode() == Instruction::ExtractElement) {
+        Value *Ptr = RemapOperand(CE->getOperand(0), ValueMap);
+        Value *Idx = RemapOperand(CE->getOperand(1), ValueMap);
+        Result = ConstantExpr::getExtractElement(cast<Constant>(Ptr),
+                                                 cast<Constant>(Idx));
+      } else if (CE->getOpcode() == Instruction::InsertElement) {
+        Value *Ptr = RemapOperand(CE->getOperand(0), ValueMap);
+        Value *Elt = RemapOperand(CE->getOperand(1), ValueMap);
+        Value *Idx = RemapOperand(CE->getOperand(2), ValueMap);
+        Result = ConstantExpr::getInsertElement(cast<Constant>(Ptr),
+                                                cast<Constant>(Elt),
+                                                cast<Constant>(Idx));
       } else if (CE->getNumOperands() == 1) {
         // Cast instruction
         assert(CE->getOpcode() == Instruction::Cast);