[PATCH] D21041: [GVN] PRE can't hoist loads across calls in general.

Eli Friedman via llvm-commits llvm-commits at lists.llvm.org
Mon Jun 6 16:06:46 PDT 2016


eli.friedman added a comment.

It probably doesn't make sense to turn every `call` instruction into an `invoke` or equivalent; that would cause the size of the IR to explode, and make the IR more difficult to use for passes which don't actually care about "trivial" edges (including most of GVN itself).

It might be possible to add some sort of sub-block abstraction over basic blocks... for example:

  block:
    call void @a() ; sub-block 0
    %y = add i32 %x, 1 ; sub-block 1
    call void @b() ; sub-block 1
    ret i32 %y ; sub-block 2

Then we provide some sort of sub-block tree that includes edges to trivial unwind blocks.

Assuming we have such a thing, the PRE algorithm can iterate over it to behave correctly.  (I'm assuming MemoryDependenceAnalysis itself wouldn't use it because of the overhead involved.)

The question, of course, is how exactly you would implement this.  If you try to compute it on the fly, it boils down to exactly the same loop I've already written.  If you try to maintain it as a side-table, you now have a gigantic hashtable containing every instruction in the function, and modifying the IR requires special sub-block-aware methods to insert, remove, or move instructions.  Attaching it to the IR itself adds an overhead of at least one pointer per Instruction, plus extra overhead for passes which don't care.


http://reviews.llvm.org/D21041





More information about the llvm-commits mailing list