[LLVMdev] ConstantExpr refactoring

Eli Friedman eli.friedman at gmail.com
Fri Jun 29 15:34:45 PDT 2012


On Fri, Jun 29, 2012 at 3:10 PM, Renato Golin <rengolin at systemcall.org> wrote:
> Hi all,
>
> It's been a long time, and I'm probably going to kill myself, but I
> want to try it anyway.
>
> Bug 10368 [1] tells me that ConstantExpr shouldn't automatically fold,
> and that this is source of many problems (most notably with traps) and
> code duplication.
>
> However, I'm a bit lost... There seem to be constant folding in many places like
>
> ConstantExpr::get*() uses
> lib/Analysis/ConstantFolding.cpp, that uses
> lib/VMCore/ConstantFold.cpp
>
> InstCombine also has some instruction simplification (duh), but it
> mostly deal with variables, so it only returns a semantically and
> simpler equivalent operation, rather than go all the way to fold if
> both arguments are constants (I guess).
>
> So, is the idea to transform ConstantFolding into a new function pass,
> or to recode another pass (like InstCombine) to deal with such things?

No new passes; the idea is that all constant folding should be done by
InstSimplify.

-Eli



More information about the llvm-dev mailing list