OSDN Git Service

[LoopUnroll+LoopUnswitch] do not transform loops containing callbr
authorNick Desaulniers <ndesaulniers@google.com>
Mon, 15 Jul 2019 21:16:29 +0000 (21:16 +0000)
committerNick Desaulniers <ndesaulniers@google.com>
Mon, 15 Jul 2019 21:16:29 +0000 (21:16 +0000)
commit243b4a424c79471745d045d8f060463a523389c2
tree889da6c0cf163f3b17ce026533cd8156fceab192
parent59e121a7ce9a7ab790bf2484f98e261afeb8ab08
[LoopUnroll+LoopUnswitch] do not transform loops containing callbr

Summary:
There is currently a correctness issue when unrolling loops containing
callbr's where their indirect targets are being updated correctly to the
newly created labels, but their operands are not.  This manifests in
unrolled loops where the second and subsequent copies of callbr
instructions have blockaddresses of the label from the first instance of
the unrolled loop, which would result in nonsensical runtime control
flow.

For now, conservatively do not unroll the loop.  In the future, I think
we can pursue unrolling such loops provided we transform the cloned
callbr's operands correctly.

Such a transform and its legalities are being discussed in:
https://reviews.llvm.org/D64101

Link: https://bugs.llvm.org/show_bug.cgi?id=42489
Link: https://groups.google.com/forum/#!topic/clang-built-linux/z-hRWP9KqPI
Reviewers: fhahn, hfinkel, efriedma

Reviewed By: fhahn, hfinkel, efriedma

Subscribers: efriedma, hiraditya, zzheng, dmgreen, llvm-commits, pirama, kees, nathanchance, E5ten, craig.topper, chandlerc, glider, void, srhines

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D64368

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@366130 91177308-0d34-0410-b5e6-96231b3b80d8
lib/Analysis/LoopInfo.cpp
test/Transforms/LoopUnroll/callbr.ll [new file with mode: 0644]
test/Transforms/LoopUnswitch/callbr.ll [new file with mode: 0644]