xref: /llvm-project/llvm/test/Transforms/FunctionSpecialization/function-specialization-nodup.ll (revision e15d72adac66790a78a51a3087b56b2bde6b778a)
1; RUN: opt -passes="ipsccp<func-spec>" -force-specialization -S < %s | FileCheck %s
2
3; Function @foo has function attribute 'noduplicate', so check that we don't
4; specialize it:
5
6; CHECK-NOT: @foo.specialized.1(
7; CHECK-NOT: @foo.specialized.2(
8
9target datalayout = "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128"
10
11@A = external dso_local constant i32, align 4
12@B = external dso_local constant i32, align 4
13
14define dso_local i32 @bar(i32 %x, i32 %y) {
15entry:
16  %tobool = icmp ne i32 %x, 0
17  br i1 %tobool, label %if.then, label %if.else
18
19if.then:
20  %call = call i32 @foo(i32 %x, ptr @A)
21  br label %return
22
23if.else:
24  %call1 = call i32 @foo(i32 %y, ptr @B)
25  br label %return
26
27return:
28  %retval.0 = phi i32 [ %call, %if.then ], [ %call1, %if.else ]
29  ret i32 %retval.0
30}
31
32define internal i32 @foo(i32 %x, ptr %b) #0 {
33entry:
34  %0 = load i32, ptr %b, align 4
35  %add = add nsw i32 %x, %0
36  ret i32 %add
37}
38
39attributes #0 = { noduplicate }
40