[RewriteStatepointsForGC] Fix a relocation bug w.r.t values defined by invoke instruc...
authorPhilip Reames <listmail@philipreames.com>
Wed, 4 Mar 2015 00:13:52 +0000 (00:13 +0000)
committerPhilip Reames <listmail@philipreames.com>
Wed, 4 Mar 2015 00:13:52 +0000 (00:13 +0000)
commit9f3ecd086a20c3f93ab445297e9fe77cd00dc259
treec7f8def7c55f9ff782fae48f079c443179cdc685
parente49da9aff1b90aeb8a84f2179f1c2c6eb8dcf274
[RewriteStatepointsForGC] Fix a relocation bug w.r.t values defined by invoke instructions

RewriteStatepointsForGC pass emits an alloca for each GC pointer which will be relocated. It then inserts stores after def and all relocations, and inserts loads before each use as well. In the end, mem2reg is used to update IR with relocations in SSA form.

However, there is a problem with inserting stores for values defined by invoke instructions. The code didn't expect a def was a terminator instruction, and inserting instructions after these terminators resulted in malformed IR.

This patch fixes this problem by handling invoke instructions as a special case. If the def is an invoke instruction, the store will be inserted at the beginning of the normal destination block. Since return value from invoke instruction does not dominate the unwind destination block, no action is needed there.

Patch by: Chen Li
Differential Revision: http://reviews.llvm.org/D7923

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@231183 91177308-0d34-0410-b5e6-96231b3b80d8
lib/Transforms/Scalar/RewriteStatepointsForGC.cpp
test/Transforms/RewriteStatepointsForGC/relocate_invoke_result.ll [new file with mode: 0644]