Add a PPCCTRLoops verification pass
authorHal Finkel <hfinkel@anl.gov>
Mon, 20 May 2013 16:08:17 +0000 (16:08 +0000)
committerHal Finkel <hfinkel@anl.gov>
Mon, 20 May 2013 16:08:17 +0000 (16:08 +0000)
commite50c8c1f81a38f0ecebafa5dc60a163814a9713a
tree72598230886735251f39b614515b975a95fd85b0
parentd54bf7ceefd2d6ba89fd800700a5ff201861861c
Add a PPCCTRLoops verification pass

When asserts are enabled, this adds a verification pass for PPC counter-loop
formation. Unfortunately, without sacrificing code quality, there is no better
way of forming counter-based loops except at the (late) IR level. This means
that we need to recognize, at the IR level, anything which might turn into a
function call (or indirect branch). Because this is currently a finite set of
things, and because SelectionDAG lowering is basic-block local, this can be
done. Nevertheless, it is fragile, and failure results in a miscompile. This
verification pass checks that all (reachable) counter-based branches are
dominated by a loop mtctr instruction, and that no instructions in between
clobber the counter register. If these conditions are not satisfied, then an
ICE will be triggered.

In short, this is to help us sleep better at night.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@182295 91177308-0d34-0410-b5e6-96231b3b80d8
lib/Target/PowerPC/PPC.h
lib/Target/PowerPC/PPCCTRLoops.cpp
lib/Target/PowerPC/PPCTargetMachine.cpp