Index: llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp =================================================================== --- llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp +++ llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp @@ -2795,12 +2795,7 @@ DL.getTypeAllocSize(Op->getType()).getFixedSize()) return OpExpr; - // Otherwise the pointer is smaller than the resultant integer, mask off - // the high bits so we are sure to get a proper truncation if the input is - // a constant expr. - unsigned InBits = DL.getTypeAllocSizeInBits(Op->getType()); - const MCExpr *MaskExpr = MCConstantExpr::create(~0ULL >> (64-InBits), Ctx); - return MCBinaryExpr::createAnd(OpExpr, MaskExpr, Ctx); + break; // Error } case Instruction::Sub: { Index: llvm/test/CodeGen/X86/ptrtoint-constexpr-invalid.ll =================================================================== --- /dev/null +++ llvm/test/CodeGen/X86/ptrtoint-constexpr-invalid.ll @@ -0,0 +1,5 @@ +; RUN: not --crash llc < %s -mtriple=i386-linux 2>&1 | FileCheck %s + +; CHECK: LLVM ERROR: Unsupported expression in static initializer: ptrtoint (ptr @r to i64) + +@r = global i64 ptrtoint (ptr @r to i64) Index: llvm/test/CodeGen/X86/ptrtoint-constexpr.ll =================================================================== --- llvm/test/CodeGen/X86/ptrtoint-constexpr.ll +++ llvm/test/CodeGen/X86/ptrtoint-constexpr.ll @@ -1,11 +1,11 @@ ; RUN: llc < %s -mtriple=i386-linux | FileCheck %s - %union.x = type { i64 } + %union.x = type { i32 } ; CHECK: .globl r ; CHECK: r: -; CHECK: .quad r&4294967295 +; CHECK: .long r -@r = global %union.x { i64 ptrtoint (ptr @r to i64) }, align 4 +@r = global %union.x { i32 ptrtoint (ptr @r to i32) }, align 4 ; CHECK: .globl x ; CHECK: x: