Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit ac36289

Browse filesBrowse files
committed
Add testcase with indirect gotos
Additional testcase for #76295
1 parent 6aa723d commit ac36289
Copy full SHA for ac36289

File tree

Expand file treeCollapse file tree

1 file changed

+83
-0
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+83
-0
lines changed
+83Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
; RUN: opt -S -passes=ipsccp < %s | FileCheck %s
2+
; CHECK: switch i32 [[X]], label [[DEFAULT_UNREACHABLE:%.*]] [
3+
; CHECK: default.unreachable:
4+
; CHECK-NEXT: unreachable
5+
6+
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"
7+
target triple = "x86_64-unknown-linux-gnu"
8+
9+
@.str = private unnamed_addr constant [23 x i8] c"OP_1:(instruction=%d)\0A\00", align 1
10+
@.str.1 = private unnamed_addr constant [28 x i8] c"TERMINATE:(instruction=%d)\0A\00", align 1
11+
12+
; Function Attrs: mustprogress norecurse uwtable
13+
define dso_local noundef i32 @main() #0 {
14+
entry:
15+
%bytecode = alloca [2 x ptr], align 16
16+
store ptr blockaddress(@main, %VM__OP_1), ptr %bytecode, align 16, !tbaa !5
17+
%arrayidx1 = getelementptr inbounds [2 x ptr], ptr %bytecode, i64 0, i64 1
18+
store ptr blockaddress(@main, %VM__TERMINATE), ptr %arrayidx1, align 8, !tbaa !5
19+
br label %while.body
20+
21+
while.body: ; preds = %entry, %sw.epilog
22+
%state.0 = phi i32 [ 0, %entry ], [ %state.1, %sw.epilog ]
23+
%index.0 = phi i32 [ 0, %entry ], [ %index.2, %sw.epilog ]
24+
switch i32 %state.0, label %sw.epilog [
25+
i32 0, label %sw.bb
26+
i32 1, label %VM__OP_1
27+
i32 2, label %sw.bb4
28+
]
29+
30+
sw.bb: ; preds = %while.body
31+
%idxprom = sext i32 %index.0 to i64
32+
%arrayidx2 = getelementptr inbounds [2 x ptr], ptr %bytecode, i64 0, i64 %idxprom
33+
%0 = load ptr, ptr %arrayidx2, align 8, !tbaa !5
34+
br label %indirectgoto
35+
36+
VM__OP_1: ; preds = %while.body, %indirectgoto
37+
%index.1 = phi i32 [ %index.3, %indirectgoto ], [ %index.0, %while.body ]
38+
br label %sw.epilog
39+
40+
sw.bb4: ; preds = %while.body
41+
%call = call i32 (ptr, ...) @printf(ptr noundef @.str, i32 noundef %index.0)
42+
%inc = add nsw i32 %index.0, 1
43+
%idxprom5 = sext i32 %inc to i64
44+
%arrayidx6 = getelementptr inbounds [2 x ptr], ptr %bytecode, i64 0, i64 %idxprom5
45+
%1 = load ptr, ptr %arrayidx6, align 8, !tbaa !5
46+
br label %indirectgoto
47+
48+
sw.epilog: ; preds = %while.body, %VM__OP_1
49+
%state.1 = phi i32 [ %state.0, %while.body ], [ 2, %VM__OP_1 ]
50+
%index.2 = phi i32 [ %index.0, %while.body ], [ %index.1, %VM__OP_1 ]
51+
br label %while.body, !llvm.loop !9
52+
53+
VM__TERMINATE: ; preds = %indirectgoto
54+
%call7 = call i32 (ptr, ...) @printf(ptr noundef @.str.1, i32 noundef %index.3)
55+
ret i32 0
56+
57+
indirectgoto: ; preds = %sw.bb4, %sw.bb
58+
%index.3 = phi i32 [ %inc, %sw.bb4 ], [ %index.0, %sw.bb ]
59+
%indirect.goto.dest = phi ptr [ %0, %sw.bb ], [ %1, %sw.bb4 ]
60+
indirectbr ptr %indirect.goto.dest, [label %VM__OP_1, label %VM__TERMINATE]
61+
}
62+
63+
; Function Attrs: nofree nounwind
64+
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) #1
65+
66+
attributes #0 = { mustprogress norecurse uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
67+
attributes #1 = { nofree nounwind "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
68+
69+
!llvm.module.flags = !{!0, !1, !2, !3}
70+
!llvm.ident = !{!4}
71+
72+
!0 = !{i32 1, !"wchar_size", i32 4}
73+
!1 = !{i32 8, !"PIC Level", i32 2}
74+
!2 = !{i32 7, !"PIE Level", i32 2}
75+
!3 = !{i32 7, !"uwtable", i32 2}
76+
!4 = !{!"clang version 18.0.0git (https://github.com/llvm/llvm-project.git 67782d2de5ea9c8653b8f0110237a3c355291c0e)"}
77+
!5 = !{!6, !6, i64 0}
78+
!6 = !{!"any pointer", !7, i64 0}
79+
!7 = !{!"omnipotent char", !8, i64 0}
80+
!8 = !{!"Simple C++ TBAA"}
81+
!9 = distinct !{!9, !10, !11}
82+
!10 = !{!"llvm.loop.mustprogress"}
83+
!11 = !{!"llvm.loop.unroll.disable"}

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.