llvm-project/llvm/test/Transforms/FunctionAttrs/misc.ll

77 lines
2.9 KiB
LLVM

; 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 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)
call void %fp(i8* bitcast (void (i32*)* @foo to i8*))
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)
%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
}
declare void @callback1(void (i32*)*)
declare void @callback2(void (i8*)*)