[llvm-dev] Structurizing multi-exit regions

Daniel Berlin via llvm-dev llvm-dev at lists.llvm.org
Wed Mar 1 18:31:37 PST 2017


On Wed, Mar 1, 2017 at 5:39 PM, Matt Arsenault via llvm-dev <
llvm-dev at lists.llvm.org> wrote:

> Hi,
>
> I'm trying to solve a problem from StructurizeCFG not actually handling
> regions with multiple exits.


SEME or MEME or both?


> Sample IR attached.
>

This is an example that just exhibits undefined behavior.
Is there one that doesn't?
IE if i change the unreachables to ret something, is that still an example
of something you care about?

>
> StructurizeCFG doesn't touch this function, exiting early on the
> isTopLevelRegion check.


FWIW: I'm not sure it should care whether it's a top level region, only
whether it's SESE, SEME, etc.


> SIAnnotateControlFlow then gets confused and ends up inserting an if into
> one of the blocks, and the matching end.cf into one of the
> return/unreachable blocks. The input to the end.cf is then not dominated
> by the condition which fails the verifier.
>
> I'm not sure exactly about how to go about fixing this. I see a few
> options:
>
> - Try to make the annotator aware of multi exit regions and insert the
> necessary phis for the input mask values for the end.cf calls. This seems
> undesirable and I'm not sure works in all cases.
>

It's possible to always find a unique entering/exiting condition for any of
the multiple-entrance/exit, and to transform it into a bunch of SESE
regions.
see, e.g,
https://net.cs.uni-bonn.de/fileadmin/ag/martini/Staff/yakdan/dream_ndss2015.pdf



>
> - Make StructurizeCFG duplicate blocks to get simple regions. Is there
> already code to do this somewhere? CodeExtractor seems to do something
> similar, but not quite the same. Can this be done in the region pass, or
> does StructurizeCFG need to be converted to a function pass? RegionInfo
> mentions support for "extended" regions with multiple exits, but I don't
> think this helps any here.


This also would work.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20170301/29a492c4/attachment-0001.html>


More information about the llvm-dev mailing list