xref: /llvm-project/llvm/test/Transforms/MetaRenamer/metarenamer.ll (revision 2e0a829da880db00e7e6b49cf50e95792dfb2be8)
1321986feSArthur Eubanks; RUN: opt -passes=metarenamer -S < %s | FileCheck %s
2cee313d2SEric Christopher
3cee313d2SEric Christopher; CHECK: target triple {{.*}}
4cee313d2SEric Christopher; CHECK-NOT: {{^x*}}xxx{{^x*}}
5cee313d2SEric Christopher; CHECK: ret i32 6
6cee313d2SEric Christopher
7cee313d2SEric Christophertarget triple = "x86_64-pc-linux-gnu"
8cee313d2SEric Christopher
9cee313d2SEric Christopher%struct.bar_xxx = type { i32, double }
10cee313d2SEric Christopher%struct.foo_xxx = type { i32, float, %struct.bar_xxx }
11cee313d2SEric Christopher
12cee313d2SEric Christopher@func_5_xxx.static_local_3_xxx = internal global i32 3, align 4
13cee313d2SEric Christopher@global_3_xxx = common global i32 0, align 4
14cee313d2SEric Christopher
15*2e0a829dSNikita Popov@func_7_xxx = weak alias i32 (...), ptr @aliased_func_7_xxx
16cee313d2SEric Christopher
17cee313d2SEric Christopherdefine i32 @aliased_func_7_xxx(...) {
18cee313d2SEric Christopher  ret i32 0
19cee313d2SEric Christopher}
20cee313d2SEric Christopher
21cee313d2SEric Christopherdefine i32 @func_3_xxx() nounwind uwtable ssp {
22cee313d2SEric Christopher  ret i32 3
23cee313d2SEric Christopher}
24cee313d2SEric Christopher
25*2e0a829dSNikita Popovdefine void @func_4_xxx(ptr sret(%struct.foo_xxx) %agg.result) nounwind uwtable ssp {
26cee313d2SEric Christopher  %1 = alloca %struct.foo_xxx, align 8
27*2e0a829dSNikita Popov  store i32 1, ptr %1, align 4
28*2e0a829dSNikita Popov  %2 = getelementptr inbounds %struct.foo_xxx, ptr %1, i32 0, i32 1
29*2e0a829dSNikita Popov  store float 2.000000e+00, ptr %2, align 4
30*2e0a829dSNikita Popov  %3 = getelementptr inbounds %struct.foo_xxx, ptr %1, i32 0, i32 2
31*2e0a829dSNikita Popov  store i32 3, ptr %3, align 4
32*2e0a829dSNikita Popov  %4 = getelementptr inbounds %struct.bar_xxx, ptr %3, i32 0, i32 1
33*2e0a829dSNikita Popov  store double 4.000000e+00, ptr %4, align 8
34*2e0a829dSNikita Popov  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %agg.result, ptr align 8 %1, i64 24, i1 false)
35cee313d2SEric Christopher  ret void
36cee313d2SEric Christopher}
37cee313d2SEric Christopher
38*2e0a829dSNikita Popovdeclare void @llvm.memcpy.p0.p0.i64(ptr nocapture, ptr nocapture, i64, i1) nounwind
39cee313d2SEric Christopher
40cee313d2SEric Christopherdefine i32 @func_5_xxx(i32 %arg_1_xxx, i32 %arg_2_xxx, i32 %arg_3_xxx, i32 %arg_4_xxx) nounwind uwtable ssp {
41cee313d2SEric Christopher  %1 = alloca i32, align 4
42cee313d2SEric Christopher  %2 = alloca i32, align 4
43cee313d2SEric Christopher  %3 = alloca i32, align 4
44cee313d2SEric Christopher  %4 = alloca i32, align 4
45cee313d2SEric Christopher  %local_1_xxx = alloca i32, align 4
46cee313d2SEric Christopher  %local_2_xxx = alloca i32, align 4
47cee313d2SEric Christopher  %i = alloca i32, align 4
48*2e0a829dSNikita Popov  store i32 %arg_1_xxx, ptr %1, align 4
49*2e0a829dSNikita Popov  store i32 %arg_2_xxx, ptr %2, align 4
50*2e0a829dSNikita Popov  store i32 %arg_3_xxx, ptr %3, align 4
51*2e0a829dSNikita Popov  store i32 %arg_4_xxx, ptr %4, align 4
52*2e0a829dSNikita Popov  store i32 1, ptr %local_1_xxx, align 4
53*2e0a829dSNikita Popov  store i32 2, ptr %local_2_xxx, align 4
54*2e0a829dSNikita Popov  store i32 0, ptr %i, align 4
55cee313d2SEric Christopher  br label %5
56cee313d2SEric Christopher
57cee313d2SEric Christopher; <label>:5                                       ; preds = %9, %0
58*2e0a829dSNikita Popov  %6 = load i32, ptr %i, align 4
59cee313d2SEric Christopher  %7 = icmp slt i32 %6, 10
60cee313d2SEric Christopher  br i1 %7, label %8, label %12
61cee313d2SEric Christopher
62cee313d2SEric Christopher; <label>:8                                       ; preds = %5
63cee313d2SEric Christopher  br label %9
64cee313d2SEric Christopher
65cee313d2SEric Christopher; <label>:9                                       ; preds = %8
66*2e0a829dSNikita Popov  %10 = load i32, ptr %i, align 4
67cee313d2SEric Christopher  %11 = add nsw i32 %10, 1
68*2e0a829dSNikita Popov  store i32 %11, ptr %i, align 4
69cee313d2SEric Christopher  br label %5
70cee313d2SEric Christopher
71cee313d2SEric Christopher; <label>:12                                      ; preds = %5
72*2e0a829dSNikita Popov  %13 = load i32, ptr %local_1_xxx, align 4
73*2e0a829dSNikita Popov  %14 = load i32, ptr %1, align 4
74cee313d2SEric Christopher  %15 = add nsw i32 %13, %14
75*2e0a829dSNikita Popov  %16 = load i32, ptr %local_2_xxx, align 4
76cee313d2SEric Christopher  %17 = add nsw i32 %15, %16
77*2e0a829dSNikita Popov  %18 = load i32, ptr %2, align 4
78cee313d2SEric Christopher  %19 = add nsw i32 %17, %18
79*2e0a829dSNikita Popov  %20 = load i32, ptr @func_5_xxx.static_local_3_xxx, align 4
80cee313d2SEric Christopher  %21 = add nsw i32 %19, %20
81*2e0a829dSNikita Popov  %22 = load i32, ptr %3, align 4
82cee313d2SEric Christopher  %23 = add nsw i32 %21, %22
83*2e0a829dSNikita Popov  %24 = load i32, ptr %4, align 4
84cee313d2SEric Christopher  %25 = add nsw i32 %23, %24
85cee313d2SEric Christopher  ret i32 %25
86cee313d2SEric Christopher}
87cee313d2SEric Christopher
88cee313d2SEric Christopherdefine i32 @varargs_func_6_xxx(i32 %arg_1_xxx, i32 %arg_2_xxx, ...) nounwind uwtable ssp {
89cee313d2SEric Christopher  %1 = alloca i32, align 4
90cee313d2SEric Christopher  %2 = alloca i32, align 4
91*2e0a829dSNikita Popov  store i32 %arg_1_xxx, ptr %1, align 4
92*2e0a829dSNikita Popov  store i32 %arg_2_xxx, ptr %2, align 4
93cee313d2SEric Christopher  ret i32 6
94cee313d2SEric Christopher}
95cee313d2SEric Christopher
96*2e0a829dSNikita Popovdeclare noalias ptr @malloc(i64)
97*2e0a829dSNikita Popovdeclare void @free(ptr nocapture)
98cee313d2SEric Christopher
99cee313d2SEric Christopherdefine void @dont_rename_lib_funcs() {
100cee313d2SEric Christopher; CHECK-LABEL: @foo(
101cee313d2SEric Christopher; CHECK-NEXT:  bb:
102*2e0a829dSNikita Popov; CHECK-NEXT:    [[TMP:%.*]] = call ptr @malloc(i64 23)
103*2e0a829dSNikita Popov; CHECK-NEXT:    call void @free(ptr [[TMP]])
104cee313d2SEric Christopher; CHECK-NEXT:    ret void
105cee313d2SEric Christopher;
106*2e0a829dSNikita Popov  %x = call ptr @malloc(i64 23)
107*2e0a829dSNikita Popov  call void @free(ptr %x)
108cee313d2SEric Christopher  ret void
109cee313d2SEric Christopher}
110