Detect when a value is undefined on an edge to a landing pad.
authorJakob Stoklund Olesen <stoklund@2pi.dk>
Wed, 11 Jan 2012 02:07:05 +0000 (02:07 +0000)
committerJakob Stoklund Olesen <stoklund@2pi.dk>
Wed, 11 Jan 2012 02:07:05 +0000 (02:07 +0000)
commit2aad2f6e601328d15033944ea51ad6f66a7f3c0a
treeba91d33c867b6cfd1849d601b80ce9912dc4ee31
parent74c4f97a466513e45e66e04469973fdcd5865300
Detect when a value is undefined on an edge to a landing pad.

Consider this code:

int h() {
  int x;
  try {
    x = f();
    g();
  } catch (...) {
    return x+1;
  }
  return x;
}

The variable x is undefined on the first edge to the landing pad, but it
has the f() return value on the second edge to the landing pad.

SplitAnalysis::getLastSplitPoint() would assume that the return value
from f() was live into the landing pad when f() throws, which is of
course impossible.

Detect these cases, and treat them as if the landing pad wasn't there.
This allows spill code to be inserted after the function call to f().

<rdar://problem/10664933>

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@147912 91177308-0d34-0410-b5e6-96231b3b80d8
include/llvm/CodeGen/SlotIndexes.h
lib/CodeGen/SplitKit.cpp
test/CodeGen/X86/2012-01-10-UndefExceptionEdge.ll [new file with mode: 0644]