1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; FIXME: Add -attributor-max-iterations-verify -attributor-max-iterations below.
3 ; This flag was removed because max iterations is 2 in most cases, but in windows it is 1.
4 ; RUN: opt -S -passes=attributor -aa-pipeline='basic-aa' -attributor-disable=false < %s | FileCheck %s
5 ; ModuleID = 'callback_simple.c'
6 target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
10 ; Make sure we propagate information from the caller to the callback callee but
11 ; only for arguments that are mapped through the callback metadata. Here, the
12 ; first two arguments of the call and the callback callee do not correspond to
13 ; each other but argument 3-5 of the transitive call site in the caller match
14 ; arguments 2-4 of the callback callee. Here we should see information and value
15 ; transfer in both directions.
16 ; FIXME: The callee -> call site direction is not working yet.
18 define void @t0_caller(i32* %a) {
19 ; CHECK-LABEL: @t0_caller(
21 ; CHECK-NEXT: [[B:%.*]] = alloca i32, align 32
22 ; CHECK-NEXT: [[C:%.*]] = alloca i32*, align 64
23 ; CHECK-NEXT: [[PTR:%.*]] = alloca i32, align 128
24 ; CHECK-NEXT: [[TMP0:%.*]] = bitcast i32* [[B]] to i8*
25 ; CHECK-NEXT: store i32 42, i32* [[B]], align 32
26 ; CHECK-NEXT: store i32* [[B]], i32** [[C]], align 64
27 ; CHECK-NEXT: call void (i32*, i32*, void (i32*, i32*, ...)*, ...) @t0_callback_broker(i32* noalias null, i32* nonnull align 128 dereferenceable(4) [[PTR]], void (i32*, i32*, ...)* nonnull bitcast (void (i32*, i32*, i32*, i64, i32**)* @t0_callback_callee to void (i32*, i32*, ...)*), i32* [[A:%.*]], i64 99, i32** nonnull align 64 dereferenceable(8) [[C]])
28 ; CHECK-NEXT: ret void
31 %b = alloca i32, align 32
32 %c = alloca i32*, align 64
33 %ptr = alloca i32, align 128
34 %0 = bitcast i32* %b to i8*
35 store i32 42, i32* %b, align 4
36 store i32* %b, i32** %c, align 8
37 call void (i32*, i32*, void (i32*, i32*, ...)*, ...) @t0_callback_broker(i32* null, i32* %ptr, void (i32*, i32*, ...)* bitcast (void (i32*, i32*, i32*, i64, i32**)* @t0_callback_callee to void (i32*, i32*, ...)*), i32* %a, i64 99, i32** %c)
41 ; Note that the first two arguments are provided by the callback_broker according to the callback in !1 below!
42 ; The others are annotated with alignment information, amongst others, or even replaced by the constants passed to the call.
43 define internal void @t0_callback_callee(i32* %is_not_null, i32* %ptr, i32* %a, i64 %b, i32** %c) {
44 ; CHECK-LABEL: @t0_callback_callee(
46 ; CHECK-NEXT: [[PTR_VAL:%.*]] = load i32, i32* [[PTR:%.*]], align 8
47 ; CHECK-NEXT: store i32 [[PTR_VAL]], i32* [[IS_NOT_NULL:%.*]]
48 ; CHECK-NEXT: [[TMP0:%.*]] = load i32*, i32** [[C:%.*]], align 64
49 ; CHECK-NEXT: tail call void @t0_check(i32* align 256 [[A:%.*]], i64 99, i32* [[TMP0]])
50 ; CHECK-NEXT: ret void
53 %ptr_val = load i32, i32* %ptr, align 8
54 store i32 %ptr_val, i32* %is_not_null
55 %0 = load i32*, i32** %c, align 8
56 tail call void @t0_check(i32* %a, i64 %b, i32* %0)
60 declare void @t0_check(i32* align 256, i64, i32*)
62 declare !callback !0 void @t0_callback_broker(i32*, i32*, void (i32*, i32*, ...)*, ...)
65 !1 = !{i64 2, i64 -1, i64 -1, i1 true}