brintos

brintos / llvm-project-archived public Read only

0
0
Text · 2.1 KiB · a576d9a Raw
79 lines · plain
1; RUN:  opt -S --passes=ipsccp,deadargelim --force-specialization                       < %s | FileCheck %s --check-prefix=NO-GLOBALS2; RUN:  opt -S --passes=ipsccp,deadargelim --force-specialization --funcspec-on-address < %s | FileCheck %s --check-prefix=GLOBALS3@G = global [10 x i32] zeroinitializer, align 44 5define internal i32 @f(ptr %p) noinline {6entry:7  %0 = load i32, ptr %p, align 48  store i32 0, ptr %p, align 49  ret i32 %010}11 12define internal i32 @g(i32 %x, i32 %y, ptr %p) noinline {13entry:14  %cmp = icmp sgt i32 %x, %y15  br i1 %cmp, label %if.then, label %if.else16 17if.then:18  br label %if.end19 20if.else:21  br label %if.end22 23if.end:24  %x.addr.0 = phi i32 [ %x, %if.then ], [ 11, %if.else ]25  %p.addr.0 = phi ptr [ @G, %if.then ], [ %p, %if.else ]26  %call = call i32 @f(ptr %p.addr.0)27  %add = add nsw i32 %call, %x.addr.028  ret i32 %add29}30 31define i32 @h0(ptr %p) {32entry:33  %call = call i32 @g(i32 2, i32 1, ptr %p)34  ret i32 %call35}36 37define i32 @h1() {38entry:39  %call = call i32 @f(ptr @G)40  ret i32 %call41}42 43define i32 @h2() {44entry:45  %call = call i32 @f(ptr getelementptr inbounds (i32, ptr @G, i64 1))46  ret i32 %call47}48 49; Check if specialisation on the address of a non-const global variable50; is not allowed, then it is not performed.51 52; NO-GLOBALS-LABEL: define internal range(i32 -2147483646, -2147483648) i32 @g()53; NO-GLOBALS: call i32 @f(ptr @G)54 55; NO-GLOBALS-LABEL: define range(i32 -2147483646, -2147483648) i32 @h0(ptr %p)56; NO-GLOBALS:call i32 @g()57 58; NO-GLOBALS-LABEL: define i32 @h1()59; NO-GLOBALS: call i32 @f(ptr @G)60 61; NO-GLOBALS-LABEL: define i32 @h2()62; NO-GLOBALS: call i32 @f(ptr getelementptr inbounds (i32, ptr @G, i64 1))63 64; Check if specialisation on the address of a non-const global variable65; is allowed, then it is performed where possible.66 67; GLOBALS-LABEL: define internal range(i32 -2147483646, -2147483648) i32 @g()68; GLOBALS: call i32 @f.specialized.2()69 70; GLOBALS-LABEL: define range(i32 -2147483646, -2147483648) i32 @h0(ptr %p)71; GLOBALS: call i32 @g()72 73; GLOBALS-LABEL: define i32 @h1()74; GLOBALS: call i32 @f.specialized.2()75 76; GLOBALS-LABEL: define i32 @h2()77; GLOBALS: call i32 @f.specialized.1()78 79