[all-commits] [llvm/llvm-project] 89c6fa: [llubi] Add support for constant inttoptr/ptrtoint...

Yingwei Zheng via All-commits all-commits at lists.llvm.org
Wed Jul 8 08:08:15 PDT 2026


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 89c6fa58bbcca9f64a48104eb0e6bf3a616558e8
      https://github.com/llvm/llvm-project/commit/89c6fa58bbcca9f64a48104eb0e6bf3a616558e8
  Author: Yingwei Zheng <dtcxzyw2333 at gmail.com>
  Date:   2026-07-08 (Wed, 08 Jul 2026)

  Changed paths:
    A llvm/test/tools/llubi/inttoptr_ptrtoint_constantexpr.ll
    M llvm/tools/llubi/lib/Context.cpp

  Log Message:
  -----------
  [llubi] Add support for constant inttoptr/ptrtoint expressions (#207028)

This patch adds support for constant inttoptr/ptrtoint expressions to
unblock the running of csmith-generated programs.
The test doesn't cover all the behaviours, as they have been tested by
previous tests.

This patch treats constant inttoptr/ptrtoint expressions as if they are
executed just before the user. However, since ptrtoint exposes the
pointer provenance and inttoptr relies on the current set of exposed
provenances, it is incorrect. Imagine that we have an inttoptr in a gep
instruction and a ptrtoint in an add instruction. They can be freely
DCEd/reordered. In addition, the behaviour also depends on the
initialization order of globals. That is terrible. Nikita's proposal
also mentioned this issue but left it as an open question:
https://hackmd.io/@nikic/SJBt4mFCll#Constant-expressions

>From my perspective, constant expressions are allowed to execute at any
point in the program (before their users). Moving ptrtoint forward or
inttoptr backward will not make the program more undefined. So we can
evaluate all constant expressions before the program entry (i.e., all
globals involved with ptrtoint will be exposed at the start). The only
remaining concern is the use of `ConstantExpr::getAsInstruction`,
because it will convert CEs back into instruction sequences :(



To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list