Files
clang-p2996/llvm/test/CodeGen/X86/ptrtoint-constexpr-invalid.ll
Nikita Popov fb7caa3c7b [AsmPrinter] Reject ptrtoint to larger size in lowerConstant()
When using a ptrtoint to a size larger than the pointer width in a
global initializer, we currently create a ptr & low_bit_mask style
MCExpr, which will later result in a relocation error during object
file emission.

This patch rejects the constant expression already during
lowerConstant(), which results in a much clearer error message
that references the constant expression at fault.

This fixes https://github.com/llvm/llvm-project/issues/56400,
for certain definitions of "fix".

Differential Revision: https://reviews.llvm.org/D130366
2022-07-25 10:18:27 +02:00

11 lines
463 B
LLVM

; RUN: not --crash llc < %s -mtriple=i386-linux 2>&1 | FileCheck %s
; ptrtoint expressions that cast to a wider integer type are not supported.
; A frontend can achieve a similar result by casting to the correct integer
; type and explicitly zeroing any additional bytes.
; { i32, i32 } { i32 ptrtoint (ptr @r to i32), i32 0 }
; CHECK: LLVM ERROR: Unsupported expression in static initializer: ptrtoint (ptr @r to i64)
@r = global i64 ptrtoint (ptr @r to i64)