diff options
author | Derek Schuff <dschuff@google.com> | 2013-06-13 19:51:17 +0000 |
---|---|---|
committer | Derek Schuff <dschuff@google.com> | 2013-06-13 19:51:17 +0000 |
commit | c06e5cf2e3724762a6c9830a00395736ec07d81a (patch) | |
tree | 096aea2893f2d7ea5541aa6f27b5d19d16acd54f /test/Transforms | |
parent | 6585b388cb7bfc623adb9e4dd910423f838e5d96 (diff) | |
download | external_llvm-c06e5cf2e3724762a6c9830a00395736ec07d81a.zip external_llvm-c06e5cf2e3724762a6c9830a00395736ec07d81a.tar.gz external_llvm-c06e5cf2e3724762a6c9830a00395736ec07d81a.tar.bz2 |
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
Diffstat (limited to 'test/Transforms')
-rw-r--r-- | test/Transforms/DeadArgElim/2013-05-17-VarargsAndBlockAddress.ll | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/test/Transforms/DeadArgElim/2013-05-17-VarargsAndBlockAddress.ll b/test/Transforms/DeadArgElim/2013-05-17-VarargsAndBlockAddress.ll new file mode 100644 index 0000000..2321603 --- /dev/null +++ b/test/Transforms/DeadArgElim/2013-05-17-VarargsAndBlockAddress.ll @@ -0,0 +1,25 @@ +; RUN: opt %s -deadargelim -S | FileCheck %s + + +@block_addr = global i8* blockaddress(@varargs_func, %l1) +; CHECK: @block_addr = global i8* blockaddress(@varargs_func, %l1) + + +; This function is referenced by a "blockaddress" constant but it is +; not address-taken, so the pass should be able to remove its unused +; varargs. + +define internal i32 @varargs_func(i8* %addr, ...) { + indirectbr i8* %addr, [ label %l1, label %l2 ] +l1: + ret i32 1 +l2: + ret i32 2 +} +; CHECK: define internal i32 @varargs_func(i8* %addr) { + +define i32 @caller(i8* %addr) { + %r = call i32 (i8*, ...)* @varargs_func(i8* %addr) + ret i32 %r +} +; CHECK: %r = call i32 @varargs_func(i8* %addr) |