xref: /llvm-project/llvm/test/Transforms/FunctionSpecialization/bug55000-read-uninitialized-value.ll (revision 1ca64c5fb74270661ca2f9ebd821f47dcb3152b4)
1; RUN: opt -passes="ipsccp<func-spec>" -force-specialization -funcspec-max-iters=2 -funcspec-max-clones=1 -funcspec-for-literal-constant=true -S < %s | FileCheck %s
2
3declare hidden i1 @compare(ptr) align 2
4declare hidden { i8, ptr } @getType(ptr) align 2
5
6; CHECK-LABEL: @foo
7; CHECK-LABEL: @foo.specialized.1
8; CHECK-LABEL: @foo.specialized.2
9
10define internal void @foo(ptr %TLI, ptr %DL, ptr %Ty, ptr %ValueVTs, ptr %Offsets, i64 %StartingOffset, i1 %arg) {
11entry:
12  %VT = alloca i64, align 8
13  br i1 false, label %if.then, label %if.end4
14
15if.then:                                          ; preds = %entry
16  ret void
17
18if.end4:                                          ; preds = %entry
19  %cmp = call zeroext i1 @compare(ptr undef)
20  br i1 %cmp, label %for.body, label %for.cond16
21
22for.body:                                         ; preds = %if.end4
23  %add13 = add i64 %StartingOffset, undef
24  call void @foo(ptr %TLI, ptr %DL, ptr undef, ptr %ValueVTs, ptr %Offsets, i64 %add13, i1 %arg)
25  unreachable
26
27for.cond16:                                       ; preds = %for.cond34, %if.end4
28  %call27 = call { i8, ptr } @getType(ptr %VT)
29  br label %for.cond34
30
31for.cond34:                                       ; preds = %for.body37, %for.cond16
32  br i1 %arg, label %for.body37, label %for.cond16
33
34for.body37:                                       ; preds = %for.cond34
35  %tobool39 = icmp ne ptr %Offsets, null
36  br label %for.cond34
37}
38
39define hidden { ptr, i32 } @bar(ptr %this, i1 %arg) {
40entry:
41  %Offsets = alloca i64, align 8
42  %cmp26 = call zeroext i1 @compare(ptr undef)
43  br i1 %cmp26, label %for.body28, label %for.cond.cleanup27
44
45for.cond.cleanup27:                               ; preds = %entry
46  ret { ptr, i32 } undef
47
48for.body28:                                       ; preds = %entry
49  %call33 = call zeroext i1 @compare(ptr undef)
50  br i1 %call33, label %if.then34, label %if.end106
51
52if.then34:                                        ; preds = %for.body28
53  call void @foo(ptr %this, ptr undef, ptr undef, ptr undef, ptr null, i64 0, i1 %arg)
54  unreachable
55
56if.end106:                                        ; preds = %for.body28
57  call void @foo(ptr %this, ptr undef, ptr undef, ptr undef, ptr %Offsets, i64 0, i1 %arg)
58  unreachable
59}
60
61