[PATCH] D16984: Don't delete empty preheaders in CodeGenPrepare if it would create a critical edge
Thomas Jablin via llvm-commits
llvm-commits at lists.llvm.org
Mon Feb 8 06:49:51 PST 2016
tjablin created this revision.
tjablin added reviewers: dsanders, hfinkel, kbarton, cycheng, george.burgess.iv.
tjablin added a subscriber: llvm-commits.
Herald added a reviewer: vkalintiris.
Herald added a subscriber: dsanders.
Presently, CodeGenPrepare deletes all nearly empty (only phi and branch) basic blocks. This pass can delete loop preheaders which frequently creates critical edges. A preheader can be a convenient place to spill registers to the stack. If the entrance to a loop body is a critical edge, then spills may occur in the loop body rather than immediately before it. This patch protects loop preheaders from deletion in CodeGenPrepare even if they are nearly empty.
Since the patch alters the CFG, it affects a large number of test cases. In most cases, the changes are merely cosmetic (basic blocks have different names or instruction orders change slightly). I am somewhat concerned about the test/CodeGen/Mips/brdelayslot.ll test case. If the loop preheader is not deleted, then the MIPS backend does not take advantage of a branch delay slot. Consequently, I would like some close review by a MIPS expert.
The patch also partially subsumes D16893 from George Burgess IV. George correctly notes that CodeGenPrepare does not actually preserve the dominator tree. I think the dominator tree was usually not valid when CodeGenPrepare ran, but I am using LoopInfo to mark preheaders, so the dominator tree is now always valid before CodeGenPrepare.
http://reviews.llvm.org/D16984
Files:
lib/CodeGen/CodeGenPrepare.cpp
test/CodeGen/AArch64/arm64-shrink-wrapping.ll
test/CodeGen/ARM/code-placement.ll
test/CodeGen/ARM/sjlj-prepare-critical-edge.ll
test/CodeGen/Generic/dont-remove-empty-preheader.ll
test/CodeGen/Mips/brdelayslot.ll
test/CodeGen/Mips/prevent-hoisting.ll
test/CodeGen/X86/block-placement.ll
test/CodeGen/X86/break-false-dep.ll
test/CodeGen/X86/lsr-static-addr.ll
test/CodeGen/X86/phi-immediate-factoring.ll
test/CodeGen/X86/phys_subreg_coalesce-2.ll
test/CodeGen/X86/pr2659.ll
test/CodeGen/X86/setcc-lowering.ll
test/CodeGen/X86/sink-blockfreq.ll
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D16984.47188.patch
Type: text/x-patch
Size: 13987 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160208/0f86fa7b/attachment.bin>
More information about the llvm-commits
mailing list