diff options
Diffstat (limited to 'lib/CodeGen/AsmPrinter.cpp')
-rw-r--r-- | lib/CodeGen/AsmPrinter.cpp | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/lib/CodeGen/AsmPrinter.cpp b/lib/CodeGen/AsmPrinter.cpp index 4caa2c1be1..498339c014 100644 --- a/lib/CodeGen/AsmPrinter.cpp +++ b/lib/CodeGen/AsmPrinter.cpp @@ -446,7 +446,11 @@ void AsmPrinter::EmitConstantValueOnly(const Constant *CV) { // integer type. This promotes constant folding and simplifies this code. if (isa<PointerType>(Ty)) { const Type *IntPtrTy = TD->getIntPtrType(); - Op = ConstantExpr::getCast(Op, IntPtrTy); + Instruction::CastOps opcode = Instruction::CastOps(CE->getOpcode()); + if (opcode == Instruction::IntToPtr) + Op = ConstantExpr::getIntegerCast(Op, IntPtrTy, false /*ZExt*/); + else + Op = ConstantExpr::getCast(Instruction::PtrToInt, Op, IntPtrTy); return EmitConstantValueOnly(Op); } |