Fix a bug in DemoteRegToStack where a reload instruction was inserted into the
authorAkira Hatanaka <ahatanaka@apple.com>
Mon, 9 Feb 2015 06:38:23 +0000 (06:38 +0000)
committerAkira Hatanaka <ahatanaka@apple.com>
Mon, 9 Feb 2015 06:38:23 +0000 (06:38 +0000)
commit522cf235e9fb150526a8422a5916a5dd378eef2e
tree72d88ed92af63801138572473d6221a27736e652
parent3c1b9d53d0d254d18ed95a9a85e95da3c3f37a49
Fix a bug in DemoteRegToStack where a reload instruction was inserted into the
wrong basic block.

This would happen when the result of an invoke was used by a phi instruction
in the invoke's normal destination block. An instruction to reload the invoke's
value would get inserted before the critical edge was split and a new basic
block (which is the correct insertion point for the reload) was created. This
commit fixes the bug by splitting the critical edge before all the reload
instructions are inserted.

Also, hoist up the code which computes the insertion point to the only place
that need that computation.

rdar://problem/15978721

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@228566 91177308-0d34-0410-b5e6-96231b3b80d8
lib/Transforms/Utils/DemoteRegToStack.cpp
test/CodeGen/ARM/sjlj-prepare-critical-edge.ll