[llvm-dev] [LLVM] New Dead Code Elimination
Daniel Berlin via llvm-dev
llvm-dev at lists.llvm.org
Mon Aug 1 12:29:57 PDT 2016
On Mon, Aug 1, 2016 at 12:14 PM, David Majnemer via llvm-dev <
llvm-dev at lists.llvm.org> wrote:
> On Mon, Aug 1, 2016 at 11:08 AM, Nadav Rotem via llvm-dev <
> llvm-dev at lists.llvm.org> wrote:
>> Hi David,
>> Thanks for working on this. I’d like to help reviewing your work!
>> How much code from the original patch are you leaving around? If you are
>> reusing a lot of code from the original pass then you can refactor, clean
>> and add new functionality. But if you are not keeping much then maybe it
>> would be useful to develop a new pass (with small incremental reviewable
>> changes), and when the work is done flip the switch and start using the new
>> pass. What do you prefer?
>> I think that introducing the new flag that allows the removal of infinite
>> loops is a great idea. LLVM is used for compilation of non-C languages,
>> like Swift, Java, Python, etc, and these languages may benefit from the new
> LLVM doesn't handle "infinite loops are a side effect" in a principled way:
> - The LLVM IR corresponding to an infinite loop doesn't contain side
> effects which means that the loop itself doesn't have side effects. Calls
> to functions which merely infinite loop can (and will) be removed by LLVM
> (because they are readnone, nounwind, etc.).
> A proper design for "infinite loops are a side effect" would likely be a
> function attribute which indicates what behavior the optimizer may assume
> when it sees a loop with unknown bound in a function.
True. FWIW, at least the previous versions of the pass are entirely based
on control flow.
That is, they are variants of the traditional control-dependence based DCE
removal. They will remove output-free infinite loops, regardless of bound.
They will not detect loops whose bound is infinite.
Essentially, it will remove any loop it is not necessary to go through to
get to an instruction that is not dead.
> While this doesn't mean that the pass shouldn't contain logic for leaving
> infinite loops alone, it likely means that parameterizing the pass on a
> flag is wrong.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the llvm-dev