[PATCH] D29011: [IR] Add Freeze instruction

Juneyoung Lee via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Nov 5 23:56:20 PST 2019


aqjune added a comment.

In D29011#1735007 <https://reviews.llvm.org/D29011#1735007>, @craig.topper wrote:

> Does a ConstantExpr freeze really make sense? ConstantExprs are uniqued by the LLVMContext. So every constantexpr that has the same input ends up being the same object. Do we want that behavior do we need each freeze to be distinct?


Both semantics make sense, but I was thinking of returning the same value for same expression of freeze, because it explains copy of an instruction that has freeze constexpr as an operand.
Conceptually, we can say that freeze constexpr is evaluated at the beginning of a program, and the evaluated value is globally used inside the module.
Using this semantics, freeze constexprs should be carefully optimized, so the same freeze constexprs don't diverge into different expressions.
This is the difference from other constexprs, but I guess binary operator also has a similar diverged case, which is udiv/sdiv constexpr (that made constexpr may trap), but I have to say that having such difference isn't said to be a good idea.
What do you think?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D29011/new/

https://reviews.llvm.org/D29011





More information about the llvm-commits mailing list