mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-08-17 05:29:24 +00:00
Don't try to create a mask when we don't need one. Fixes a crash.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@58075 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
2efe3fd79a
commit
04aa2c3520
@ -368,10 +368,12 @@ Constant *llvm::ConstantFoldInstOperands(unsigned Opcode, const Type *DestTy,
|
|||||||
if (TD && CE->getOpcode() == Instruction::IntToPtr) {
|
if (TD && CE->getOpcode() == Instruction::IntToPtr) {
|
||||||
Constant *Input = CE->getOperand(0);
|
Constant *Input = CE->getOperand(0);
|
||||||
unsigned InWidth = Input->getType()->getPrimitiveSizeInBits();
|
unsigned InWidth = Input->getType()->getPrimitiveSizeInBits();
|
||||||
|
if (TD->getPointerSizeInBits() < InWidth) {
|
||||||
Constant *Mask =
|
Constant *Mask =
|
||||||
ConstantInt::get(APInt::getLowBitsSet(InWidth,
|
ConstantInt::get(APInt::getLowBitsSet(InWidth,
|
||||||
TD->getPointerSizeInBits()));
|
TD->getPointerSizeInBits()));
|
||||||
Input = ConstantExpr::getAnd(Input, Mask);
|
Input = ConstantExpr::getAnd(Input, Mask);
|
||||||
|
}
|
||||||
// Do a zext or trunc to get to the dest size.
|
// Do a zext or trunc to get to the dest size.
|
||||||
return ConstantExpr::getIntegerCast(Input, DestTy, false);
|
return ConstantExpr::getIntegerCast(Input, DestTy, false);
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,8 @@
|
|||||||
|
; RUN: llvm-as < %s | opt -instcombine
|
||||||
|
; PR2940
|
||||||
|
|
||||||
|
define i32 @tstid() {
|
||||||
|
%var0 = inttoptr i32 1 to i8* ; <i8*> [#uses=1]
|
||||||
|
%var2 = ptrtoint i8* %var0 to i32 ; <i32> [#uses=1]
|
||||||
|
ret i32 %var2
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user