diff options
| author | Johannes Doerfert <johannes@jdoerfert.de> | 2019-10-13 03:08:18 -0500 |
|---|---|---|
| committer | Johannes Doerfert <johannes@jdoerfert.de> | 2019-10-31 00:16:36 -0500 |
| commit | cd4aab4a8ac43dd661f132fd940bc80828788fda (patch) | |
| tree | 47160a7facd4707a772977971eb4838e39e523b3 /llvm/test/Transforms/FunctionAttrs/misc.ll | |
| parent | 5e442a51bce73f3e69eef022674acfb28224619d (diff) | |
| download | bcm5719-llvm-cd4aab4a8ac43dd661f132fd940bc80828788fda.tar.gz bcm5719-llvm-cd4aab4a8ac43dd661f132fd940bc80828788fda.zip | |
[Attributor] Liveness for values
Summary:
This patch introduces liveness (AAIsDead) for all positions, thus for
all kinds of values. For now, we say an instruction is dead if it would
be removed assuming all users are dead. A call site return is different
as we just look at the users. If all call site returns have been
eliminated, the return values can return undef instead of their original
value, eliminating uses.
We try to recursively delete dead instructions now and we introduce a
simple check interface for use-traversal.
This is the idea tried out in D68626 but implemented in the right way.
Reviewers: uenoku, sstefan1
Subscribers: hiraditya, bollu, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D68925
Diffstat (limited to 'llvm/test/Transforms/FunctionAttrs/misc.ll')
| -rw-r--r-- | llvm/test/Transforms/FunctionAttrs/misc.ll | 61 |
1 files changed, 57 insertions, 4 deletions
diff --git a/llvm/test/Transforms/FunctionAttrs/misc.ll b/llvm/test/Transforms/FunctionAttrs/misc.ll index 96ceb8743fd..ea4a5046fd0 100644 --- a/llvm/test/Transforms/FunctionAttrs/misc.ll +++ b/llvm/test/Transforms/FunctionAttrs/misc.ll @@ -1,20 +1,73 @@ +; NOTE: Assertions have been autogenerated by utils/update_test_checks.py ; RUN: opt -S -attributor -attributor-disable=false < %s | FileCheck %s +; RUN: opt -S -aa-pipeline='basic-aa' -passes=attributor -attributor-disable=false < %s | FileCheck %s +; +; Mostly check we do not crash on these uses -define void @external() { +define internal void @internal(void (i8*)* %fp) { +; CHECK-LABEL: define {{[^@]+}}@internal +; CHECK-SAME: (void (i8*)* [[FP:%.*]]) +; CHECK-NEXT: entry: +; CHECK-NEXT: [[A:%.*]] = alloca i32, align 4 +; CHECK-NEXT: [[TMP:%.*]] = bitcast i32* [[A]] to i8* +; CHECK-NEXT: call void @foo(i32* nocapture nonnull align 4 dereferenceable(4) undef) +; CHECK-NEXT: call void [[FP:%.*]](i8* bitcast (void (i32*)* @foo to i8*)) +; CHECK-NEXT: call void @callback1(void (i32*)* nonnull @foo) +; CHECK-NEXT: call void @callback2(void (i8*)* nonnull bitcast (void (i32*)* @foo to void (i8*)*)) +; CHECK-NEXT: call void @callback2(void (i8*)* [[FP]]) +; CHECK-NEXT: [[TMP1:%.*]] = bitcast i32* [[A]] to i8* +; CHECK-NEXT: call void [[FP]](i8* [[TMP1]]) +; CHECK-NEXT: ret void +; entry: %a = alloca i32, align 4 %tmp = bitcast i32* %a to i8* call void @foo(i32* nonnull %a) -; Check we do not crash on these uses -; CHECK: call void @callback1(void (i32*)* nonnull @foo) + call void %fp(i8* bitcast (void (i32*)* @foo to i8*)) call void @callback1(void (i32*)* nonnull @foo) -; CHECK: call void @callback2(void (i8*)* nonnull bitcast (void (i32*)* @foo to void (i8*)*)) call void @callback2(void (i8*)* bitcast (void (i32*)* @foo to void (i8*)*)) + call void @callback2(void (i8*)* %fp) %tmp1 = bitcast i32* %a to i8* + call void %fp(i8* %tmp1) + ret void +} + +define void @external(void (i8*)* %fp) { +; CHECK-LABEL: define {{[^@]+}}@external +; CHECK-SAME: (void (i8*)* [[FP:%.*]]) +; CHECK-NEXT: entry: +; CHECK-NEXT: [[A:%.*]] = alloca i32, align 4 +; CHECK-NEXT: [[TMP:%.*]] = bitcast i32* [[A]] to i8* +; CHECK-NEXT: call void @foo(i32* nocapture nonnull align 4 dereferenceable(4) undef) +; CHECK-NEXT: call void @callback1(void (i32*)* nonnull @foo) +; CHECK-NEXT: call void @callback2(void (i8*)* nonnull bitcast (void (i32*)* @foo to void (i8*)*)) +; CHECK-NEXT: call void @callback2(void (i8*)* [[FP:%.*]]) +; CHECK-NEXT: call void [[FP]](i8* bitcast (void (i32*)* @foo to i8*)) +; CHECK-NEXT: [[TMP1:%.*]] = bitcast i32* [[A]] to i8* +; CHECK-NEXT: call void [[FP]](i8* [[TMP1]]) +; CHECK-NEXT: call void @internal(void (i8*)* [[FP]]) +; CHECK-NEXT: ret void +; +entry: + %a = alloca i32, align 4 + %tmp = bitcast i32* %a to i8* + call void @foo(i32* nonnull %a) + call void @callback1(void (i32*)* nonnull @foo) + call void @callback2(void (i8*)* bitcast (void (i32*)* @foo to void (i8*)*)) + call void @callback2(void (i8*)* %fp) + call void %fp(i8* bitcast (void (i32*)* @foo to i8*)) + %tmp1 = bitcast i32* %a to i8* + call void %fp(i8* %tmp1) + call void @internal(void (i8*)* %fp) ret void } define internal void @foo(i32* %a) { +; CHECK-LABEL: define {{[^@]+}}@foo +; CHECK-SAME: (i32* nocapture readnone [[A:%.*]]) +; CHECK-NEXT: entry: +; CHECK-NEXT: ret void +; entry: ret void } |

