1 ; RUN: opt -attributor --attributor-disable=false -S < %s | FileCheck %s --check-prefixes=ATTRIBUTOR
5 ; take mininimum of return values
7 define i32* @test1(i32* dereferenceable(4) %0, double* dereferenceable(8) %1, i1 zeroext %2) local_unnamed_addr {
8 ; ATTRIBUTOR: define nonnull dereferenceable(4) i32* @test1(i32* nonnull dereferenceable(4) %0, double* nonnull dereferenceable(8) %1, i1 zeroext %2)
9 %4 = bitcast double* %1 to i32*
10 %5 = select i1 %2, i32* %0, i32* %4
15 define i32* @test2(i32* dereferenceable_or_null(4) %0, double* dereferenceable(8) %1, i1 zeroext %2) local_unnamed_addr {
16 ; ATTRIBUTOR: define dereferenceable_or_null(4) i32* @test2(i32* dereferenceable_or_null(4) %0, double* nonnull dereferenceable(8) %1, i1 zeroext %2)
17 %4 = bitcast double* %1 to i32*
18 %5 = select i1 %2, i32* %0, i32* %4
24 define i32* @test3_1(i32* dereferenceable(8) %0) local_unnamed_addr {
25 ; ATTRIBUTOR: define nonnull dereferenceable(4) i32* @test3_1(i32* nonnull dereferenceable(8) %0)
26 %ret = getelementptr inbounds i32, i32* %0, i64 1
30 define i32* @test3_2(i32* dereferenceable_or_null(32) %0) local_unnamed_addr {
31 ; FIXME: Argument should be mark dereferenceable because of GEP `inbounds`.
32 ; ATTRIBUTOR: define nonnull dereferenceable(16) i32* @test3_2(i32* dereferenceable_or_null(32) %0)
33 %ret = getelementptr inbounds i32, i32* %0, i64 4
37 define i32* @test3_3(i32* dereferenceable(8) %0, i32* dereferenceable(16) %1, i1 %2) local_unnamed_addr {
38 ; ATTRIBUTOR: define nonnull dereferenceable(4) i32* @test3_3(i32* nonnull dereferenceable(8) %0, i32* nonnull dereferenceable(16) %1, i1 %2) local_unnamed_addr
39 %ret1 = getelementptr inbounds i32, i32* %0, i64 1
40 %ret2 = getelementptr inbounds i32, i32* %1, i64 2
41 %ret = select i1 %2, i32* %ret1, i32* %ret2
46 ; Better than known in IR.
48 define dereferenceable(4) i32* @test4(i32* dereferenceable(8) %0) local_unnamed_addr {
49 ; ATTRIBUTOR: define nonnull dereferenceable(8) i32* @test4(i32* nonnull returned dereferenceable(8) %0)