Sink the return instruction collection until after we're done deleting
authorChandler Carruth <chandlerc@gmail.com>
Fri, 6 Apr 2012 01:11:52 +0000 (01:11 +0000)
committerChandler Carruth <chandlerc@gmail.com>
Fri, 6 Apr 2012 01:11:52 +0000 (01:11 +0000)
commit6bbab86af959a8819ddadfe8909bcfa5aa53ce9f
treee13e9adda7545aa316f8d62d9cf0a203ba9fd2ee
parentf16936e5923156863906c915de657b134db4fb16
Sink the return instruction collection until after we're done deleting
dead code, including dead return instructions in some cases. Otherwise,
we end up having a bogus poniter to a return instruction that blows up
much further down the road.

It turns out that this pattern is both simpler to code, easier to update
in the face of enhancements to the inliner cleanup, and likely cheaper
given that it won't add dead instructions to the list.

Thanks to John Regehr's numerous test cases for teasing this out.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@154157 91177308-0d34-0410-b5e6-96231b3b80d8
lib/Transforms/Utils/CloneFunction.cpp
test/Transforms/Inline/inline_cleanup.ll