[all-commits] [llvm/llvm-project] fb7caa: [AsmPrinter] Reject ptrtoint to larger size in low...

Nikita Popov via All-commits all-commits at lists.llvm.org
Mon Jul 25 01:18:45 PDT 2022

  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: fb7caa3c7b53a4362139afe0158f297a891cc17b
  Author: Nikita Popov <npopov at redhat.com>
  Date:   2022-07-25 (Mon, 25 Jul 2022)

  Changed paths:
    M llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
    A llvm/test/CodeGen/X86/ptrtoint-constexpr-invalid.ll
    M llvm/test/CodeGen/X86/ptrtoint-constexpr.ll

  Log Message:
  [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

More information about the All-commits mailing list