Fix DeleteDeadVarargs not to crash on functions referenced by BlockAddresses
authorDerek Schuff <dschuff@google.com>
Thu, 13 Jun 2013 19:51:17 +0000 (19:51 +0000)
committerDerek Schuff <dschuff@google.com>
Thu, 13 Jun 2013 19:51:17 +0000 (19:51 +0000)
commitc06e5cf2e3724762a6c9830a00395736ec07d81a
tree096aea2893f2d7ea5541aa6f27b5d19d16acd54f
parent6585b388cb7bfc623adb9e4dd910423f838e5d96
Fix DeleteDeadVarargs not to crash on functions referenced by BlockAddresses

This pass was assuming that if hasAddressTaken() returns false for a
function, the function's only uses are call sites.  That's not true
because there can be references by BlockAddresses too.

Fix the pass to handle this case.  Fix
BlockAddress::replaceUsesOfWithOnConstant() to allow a function's type
to be changed by RAUW'ing the function with a bitcast of the recreated
function.

Patch by Mark Seaborn.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@183933 91177308-0d34-0410-b5e6-96231b3b80d8
lib/IR/Constants.cpp
lib/Transforms/IPO/DeadArgumentElimination.cpp
test/Transforms/DeadArgElim/2013-05-17-VarargsAndBlockAddress.ll [new file with mode: 0644]