xref: /llvm-project/llvm/test/CodeGen/X86/lifetime-alias.ll (revision f0dd12ec5c0169ba5b4363b62d59511181cf954a)
1; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2; RUN: llc < %s -mtriple=x86_64-unknown-linux-gnu  | FileCheck %s -check-prefix=CHECK
3
4source_filename = "test_case.cc"
5target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
6target triple = "x86_64-unknown-linux-gnu"
7
8%"class.std::__3::basic_string" = type { %"class.std::__3::__compressed_pair" }
9%"class.std::__3::__compressed_pair" = type { %"struct.std::__3::__compressed_pair_elem" }
10%"struct.std::__3::__compressed_pair_elem" = type { %"struct.std::__3::basic_string<char, std::__3::char_traits<char>, std::__3::allocator<char> >::__rep" }
11%"struct.std::__3::basic_string<char, std::__3::char_traits<char>, std::__3::allocator<char> >::__rep" = type { %union.anon }
12%union.anon = type { %"struct.std::__3::basic_string<char, std::__3::char_traits<char>, std::__3::allocator<char> >::__long" }
13%"struct.std::__3::basic_string<char, std::__3::char_traits<char>, std::__3::allocator<char> >::__long" = type { ptr, i64, i64 }
14%struct.Agg = type { %"class.std::__3::basic_string", %"class.std::__3::basic_string" }
15%"struct.std::__3::basic_string<char, std::__3::char_traits<char>, std::__3::allocator<char> >::__short" = type { [23 x i8], %struct.anon }
16%struct.anon = type { i8 }
17
18@do_not_optimize = dso_local global ptr null, align 8
19@.str = private unnamed_addr constant [12 x i8] c"The Culture\00", align 1
20@.str.1 = private unnamed_addr constant [22 x i8] c"FunnyItWorkedLastTime\00", align 1
21@.str.2 = private unnamed_addr constant [19 x i8] c"agg.a2_[16] == 't'\00", align 1
22@.str.3 = private unnamed_addr constant [13 x i8] c"test_case.cc\00", align 1
23@__PRETTY_FUNCTION__.main = private unnamed_addr constant [11 x i8] c"int main()\00", align 1
24
25; Function Attrs: norecurse uwtable
26define i8 @main() local_unnamed_addr #0 personality ptr @__gxx_personality_v0 {
27; CHECK-LABEL: main:
28; CHECK:       # %bb.0: # %_ZNSt3__312basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEED2Ev.exit50
29; CHECK-NEXT:    pushq %rax
30; CHECK-NEXT:    .cfi_def_cfa_offset 16
31; CHECK-NEXT:    movaps {{.*#+}} xmm0 = [97,97,97,97,97,97,97,97,97,97,97,97,97,97,97,97]
32; CHECK-NEXT:    movaps %xmm0, -{{[0-9]+}}(%rsp)
33; CHECK-NEXT:    movabsq $7016996765293437281, %rax # imm = 0x6161616161616161
34; CHECK-NEXT:    movq %rax, -{{[0-9]+}}(%rsp)
35; CHECK-NEXT:    movw $5632, {{[0-9]+}}(%rsp) # imm = 0x1600
36; CHECK-NEXT:    xorps %xmm0, %xmm0
37; CHECK-NEXT:    movaps %xmm0, -{{[0-9]+}}(%rsp)
38; CHECK-NEXT:    movq $0, -{{[0-9]+}}(%rsp)
39; CHECK-NEXT:    movb $11, -{{[0-9]+}}(%rsp)
40; CHECK-NEXT:    movabsq $8389209137051166804, %rax # imm = 0x746C754320656854
41; CHECK-NEXT:    movq %rax, -{{[0-9]+}}(%rsp)
42; CHECK-NEXT:    movl $1701999988, -{{[0-9]+}}(%rsp) # imm = 0x65727574
43; CHECK-NEXT:    movb $0, -{{[0-9]+}}(%rsp)
44; CHECK-NEXT:    movaps %xmm0, -{{[0-9]+}}(%rsp)
45; CHECK-NEXT:    movq $0, -{{[0-9]+}}(%rsp)
46; CHECK-NEXT:    movb $21, -{{[0-9]+}}(%rsp)
47; CHECK-NEXT:    movabsq $7308613581744070988, %rax # imm = 0x656D69547473614C
48; CHECK-NEXT:    movq %rax, -{{[0-9]+}}(%rsp)
49; CHECK-NEXT:    movups .L.str.1(%rip), %xmm1
50; CHECK-NEXT:    movaps %xmm1, -{{[0-9]+}}(%rsp)
51; CHECK-NEXT:    movb $0, -{{[0-9]+}}(%rsp)
52; CHECK-NEXT:    movq -{{[0-9]+}}(%rsp), %rax
53; CHECK-NEXT:    movq %rax, -{{[0-9]+}}(%rsp)
54; CHECK-NEXT:    movq -{{[0-9]+}}(%rsp), %rax
55; CHECK-NEXT:    movq %rax, -{{[0-9]+}}(%rsp)
56; CHECK-NEXT:    movzwl -{{[0-9]+}}(%rsp), %eax
57; CHECK-NEXT:    movw %ax, -{{[0-9]+}}(%rsp)
58; CHECK-NEXT:    movzbl -{{[0-9]+}}(%rsp), %eax
59; CHECK-NEXT:    movb %al, -{{[0-9]+}}(%rsp)
60; CHECK-NEXT:    movzbl -{{[0-9]+}}(%rsp), %eax
61; CHECK-NEXT:    movb %al, -{{[0-9]+}}(%rsp)
62; CHECK-NEXT:    movl -{{[0-9]+}}(%rsp), %eax
63; CHECK-NEXT:    movl %eax, -{{[0-9]+}}(%rsp)
64; CHECK-NEXT:    movaps %xmm0, -{{[0-9]+}}(%rsp)
65; CHECK-NEXT:    movq $0, -{{[0-9]+}}(%rsp)
66; CHECK-NEXT:    movq -{{[0-9]+}}(%rsp), %rax
67; CHECK-NEXT:    movq %rax, -{{[0-9]+}}(%rsp)
68; CHECK-NEXT:    movaps -{{[0-9]+}}(%rsp), %xmm1
69; CHECK-NEXT:    movups %xmm1, -{{[0-9]+}}(%rsp)
70; CHECK-NEXT:    movaps %xmm0, -{{[0-9]+}}(%rsp)
71; CHECK-NEXT:    movq $0, -{{[0-9]+}}(%rsp)
72; CHECK-NEXT:    leaq -{{[0-9]+}}(%rsp), %rax
73; CHECK-NEXT:    movq %rax, do_not_optimize(%rip)
74; CHECK-NEXT:    leaq -{{[0-9]+}}(%rsp), %rax
75; CHECK-NEXT:    movq %rax, do_not_optimize(%rip)
76; CHECK-NEXT:    cmpb $0, -{{[0-9]+}}(%rsp)
77; CHECK-NEXT:    jns .LBB0_1
78; CHECK-NEXT:  # %bb.2: # %_ZNSt3__312basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEED2Ev.exit50
79; CHECK-NEXT:    movq -{{[0-9]+}}(%rsp), %rax
80; CHECK-NEXT:    jmp .LBB0_3
81; CHECK-NEXT:  .LBB0_1:
82; CHECK-NEXT:    leaq -{{[0-9]+}}(%rsp), %rax
83; CHECK-NEXT:  .LBB0_3: # %_ZNSt3__312basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEED2Ev.exit50
84; CHECK-NEXT:    movzbl 16(%rax), %eax
85; CHECK-NEXT:    popq %rcx
86; CHECK-NEXT:    .cfi_def_cfa_offset 8
87; CHECK-NEXT:    retq
88_ZNSt3__312basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEED2Ev.exit50:
89  %padding = alloca %"class.std::__3::basic_string", align 8
90  %agg = alloca %struct.Agg, align 8
91  %agg.tmp = alloca %"class.std::__3::basic_string", align 8
92  %agg.tmp1 = alloca %"class.std::__3::basic_string", align 8
93  call void @llvm.lifetime.start.p0(i64 24, ptr nonnull %padding) #4
94  %__size_.i23.i.i = getelementptr inbounds %"struct.std::__3::basic_string<char, std::__3::char_traits<char>, std::__3::allocator<char> >::__short", ptr %padding, i64 0, i32 1, i32 0
95  store i8 22, ptr %__size_.i23.i.i, align 1, !tbaa !2
96  call void @llvm.memset.p0.i64(ptr nonnull align 8 %padding, i8 97, i64 22, i1 false) #4
97  %arrayidx.i.i = getelementptr inbounds i8, ptr %padding, i64 22
98  store i8 0, ptr %arrayidx.i.i, align 2, !tbaa !2
99  call void @llvm.lifetime.start.p0(i64 48, ptr nonnull %agg) #4
100  call void @llvm.memset.p0.i64(ptr nonnull align 8 %agg.tmp, i8 0, i64 24, i1 false) #4
101  %__size_.i23.i.i11 = getelementptr inbounds %"struct.std::__3::basic_string<char, std::__3::char_traits<char>, std::__3::allocator<char> >::__short", ptr %agg.tmp, i64 0, i32 1, i32 0
102  store i8 11, ptr %__size_.i23.i.i11, align 1, !tbaa !2
103  call void @llvm.memcpy.p0.p0.i64(ptr nonnull align 8 %agg.tmp, ptr align 1 @.str, i64 11, i1 false) #4
104  %arrayidx.i.i12 = getelementptr inbounds i8, ptr %agg.tmp, i64 11
105  store i8 0, ptr %arrayidx.i.i12, align 1, !tbaa !2
106  call void @llvm.memset.p0.i64(ptr nonnull align 8 %agg.tmp1, i8 0, i64 24, i1 false) #4
107  %__size_.i23.i.i28 = getelementptr inbounds %"struct.std::__3::basic_string<char, std::__3::char_traits<char>, std::__3::allocator<char> >::__short", ptr %agg.tmp1, i64 0, i32 1, i32 0
108  store i8 21, ptr %__size_.i23.i.i28, align 1, !tbaa !2
109  call void @llvm.memcpy.p0.p0.i64(ptr nonnull align 8 %agg.tmp1, ptr align 1 @.str.1, i64 21, i1 false) #4
110  %arrayidx.i.i34 = getelementptr inbounds i8, ptr %agg.tmp1, i64 21
111  store i8 0, ptr %arrayidx.i.i34, align 1, !tbaa !2
112  call void @llvm.memcpy.p0.p0.i64(ptr nonnull align 8 %agg, ptr nonnull align 8 %agg.tmp, i64 24, i1 false) #4
113  call void @llvm.memset.p0.i64(ptr nonnull align 8 %agg.tmp, i8 0, i64 24, i1 false) #4
114  %a2_.i = getelementptr inbounds %struct.Agg, ptr %agg, i64 0, i32 1
115  call void @llvm.memcpy.p0.p0.i64(ptr nonnull align 8 %a2_.i, ptr nonnull align 8 %agg.tmp1, i64 24, i1 false) #4
116  call void @llvm.memset.p0.i64(ptr nonnull align 8 %agg.tmp1, i8 0, i64 24, i1 false) #4
117  store volatile ptr %padding, ptr @do_not_optimize, align 8, !tbaa !5
118  store volatile ptr %agg, ptr @do_not_optimize, align 8, !tbaa !5
119  %__size_.i.i.i51 = getelementptr inbounds %"struct.std::__3::basic_string<char, std::__3::char_traits<char>, std::__3::allocator<char> >::__short", ptr %a2_.i, i64 0, i32 1, i32 0
120  %0 = load i8, ptr %__size_.i.i.i51, align 1, !tbaa !2
121  %tobool.i.i.i = icmp slt i8 %0, 0
122  %1 = load ptr, ptr %a2_.i, align 8
123  %cond.i.i = select i1 %tobool.i.i.i, ptr %1, ptr %a2_.i
124  %add.ptr.i = getelementptr inbounds i8, ptr %cond.i.i, i64 16
125  %2 = load i8, ptr %add.ptr.i, align 1, !tbaa !2
126  ret i8 %2
127}
128
129; Function Attrs: argmemonly nounwind
130declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #1
131
132declare dso_local i32 @__gxx_personality_v0(...)
133
134; Function Attrs: argmemonly nounwind
135declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1
136
137; Function Attrs: argmemonly nounwind
138declare void @llvm.memcpy.p0.p0.i64(ptr nocapture writeonly, ptr nocapture readonly, i64, i1 immarg) #1
139
140; Function Attrs: argmemonly nounwind
141declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #1
142
143attributes #0 = { norecurse uwtable "correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false" "less-precise-fpmad"="false" "min-legal-vector-width"="0" "frame-pointer"="none" "no-infs-fp-math"="false" "no-jump-tables"="false" "no-nans-fp-math"="false" "no-signed-zeros-fp-math"="false" "no-trapping-math"="false" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "unsafe-fp-math"="false" "use-soft-float"="false" }
144attributes #1 = { argmemonly nounwind }
145attributes #2 = { noreturn nounwind "correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false" "less-precise-fpmad"="false" "frame-pointer"="none" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "no-signed-zeros-fp-math"="false" "no-trapping-math"="false" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "unsafe-fp-math"="false" "use-soft-float"="false" }
146attributes #3 = { nobuiltin nounwind "correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false" "less-precise-fpmad"="false" "frame-pointer"="none" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "no-signed-zeros-fp-math"="false" "no-trapping-math"="false" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "unsafe-fp-math"="false" "use-soft-float"="false" }
147attributes #4 = { nounwind }
148attributes #5 = { noreturn nounwind }
149attributes #6 = { builtin nounwind }
150
151!llvm.module.flags = !{!0}
152!llvm.ident = !{!1}
153
154!0 = !{i32 1, !"wchar_size", i32 4}
155!1 = !{!"clang version 9.0.0 (https://git.llvm.org/git/clang.git 6bb42abb270b5879a3acd289ca42341115a3cb46) (https://git.llvm.org/git/llvm.git ab39cf6afa9acdc108d16e7194a0d82619b044d6)"}
156!2 = !{!3, !3, i64 0}
157!3 = !{!"omnipotent char", !4, i64 0}
158!4 = !{!"Simple C++ TBAA"}
159!5 = !{!6, !6, i64 0}
160!6 = !{!"any pointer", !3, i64 0}
161