[llvm-branch-commits] [llvm-branch] r134504 - in /llvm/branches/type-system-rewrite: include/llvm/Constants.h lib/Transforms/Utils/ValueMapper.cpp lib/VMCore/Constants.cpp
Chris Lattner
sabre at nondot.org
Wed Jul 6 10:41:36 PDT 2011
Author: lattner
Date: Wed Jul 6 12:41:36 2011
New Revision: 134504
URL: http://llvm.org/viewvc/llvm-project?rev=134504&view=rev
Log:
add a new ConstantExpr::getWithOperands method that allows specifying
the result type. This allows us to remap the type of a bitcast constant
expr when mapping it over, fixing test/Linker/PR8300.ll.
Modified:
llvm/branches/type-system-rewrite/include/llvm/Constants.h
llvm/branches/type-system-rewrite/lib/Transforms/Utils/ValueMapper.cpp
llvm/branches/type-system-rewrite/lib/VMCore/Constants.cpp
Modified: llvm/branches/type-system-rewrite/include/llvm/Constants.h
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/type-system-rewrite/include/llvm/Constants.h?rev=134504&r1=134503&r2=134504&view=diff
==============================================================================
--- llvm/branches/type-system-rewrite/include/llvm/Constants.h (original)
+++ llvm/branches/type-system-rewrite/include/llvm/Constants.h Wed Jul 6 12:41:36 2011
@@ -914,8 +914,16 @@
/// getWithOperands - This returns the current constant expression with the
/// operands replaced with the specified values. The specified array must
/// have the same number of operands as our current one.
- Constant *getWithOperands(ArrayRef<Constant*> Ops) const;
-
+ Constant *getWithOperands(ArrayRef<Constant*> Ops) const {
+ return getWithOperands(Ops, getType());
+ }
+
+ /// getWithOperands - This returns the current constant expression with the
+ /// operands replaced with the specified values and with the specified result
+ /// type. The specified array must have the same number of operands as our
+ /// current one.
+ Constant *getWithOperands(ArrayRef<Constant*> Ops, const Type *Ty) const;
+
virtual void destroyConstant();
virtual void replaceUsesOfWithOnConstant(Value *From, Value *To, Use *U);
Modified: llvm/branches/type-system-rewrite/lib/Transforms/Utils/ValueMapper.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/type-system-rewrite/lib/Transforms/Utils/ValueMapper.cpp?rev=134504&r1=134503&r2=134504&view=diff
==============================================================================
--- llvm/branches/type-system-rewrite/lib/Transforms/Utils/ValueMapper.cpp (original)
+++ llvm/branches/type-system-rewrite/lib/Transforms/Utils/ValueMapper.cpp Wed Jul 6 12:41:36 2011
@@ -122,7 +122,7 @@
}
if (ConstantExpr *CE = dyn_cast<ConstantExpr>(C))
- return VM[V] = CE->getWithOperands(Ops);
+ return VM[V] = CE->getWithOperands(Ops, NewTy);
if (isa<ConstantArray>(C))
return VM[V] = ConstantArray::get(cast<ArrayType>(NewTy), Ops);
if (isa<ConstantStruct>(C))
Modified: llvm/branches/type-system-rewrite/lib/VMCore/Constants.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/type-system-rewrite/lib/VMCore/Constants.cpp?rev=134504&r1=134503&r2=134504&view=diff
==============================================================================
--- llvm/branches/type-system-rewrite/lib/VMCore/Constants.cpp (original)
+++ llvm/branches/type-system-rewrite/lib/VMCore/Constants.cpp Wed Jul 6 12:41:36 2011
@@ -842,7 +842,7 @@
/// operands replaced with the specified values. The specified array must
/// have the same number of operands as our current one.
Constant *ConstantExpr::
-getWithOperands(ArrayRef<Constant*> Ops) const {
+getWithOperands(ArrayRef<Constant*> Ops, const Type *Ty) const {
assert(Ops.size() == getNumOperands() && "Operand count mismatch!");
bool AnyChange = false;
for (unsigned i = 0; i != Ops.size(); ++i)
@@ -864,7 +864,7 @@
case Instruction::PtrToInt:
case Instruction::IntToPtr:
case Instruction::BitCast:
- return ConstantExpr::getCast(getOpcode(), Ops[0], getType());
+ return ConstantExpr::getCast(getOpcode(), Ops[0], Ty);
case Instruction::Select:
return ConstantExpr::getSelect(Ops[0], Ops[1], Ops[2]);
case Instruction::InsertElement:
More information about the llvm-branch-commits
mailing list