brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.7 KiB · a0c0e9f Raw
43 lines · plain
1; RUN: opt < %s -S -passes=memcpyopt | FileCheck --match-full-lines %s2 3declare void @use(ptr)4 5; Make sure callslot optimization merges alias.scope metadata correctly when it merges instructions.6; Merging here naively generates:7;  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %dst, ptr align 8 %src, i64 1, i1 false), !alias.scope !38;  call void @llvm.lifetime.end.p0(ptr nonnull %src), !noalias !09;   ...10;  !0 = !{!1}11;  !1 = distinct !{!1, !2, !"callee1: %a"}12;  !2 = distinct !{!2, !"callee1"}13;  !3 = !{!1, !4}14;  !4 = distinct !{!4, !5, !"callee0: %a"}15;  !5 = distinct !{!5, !"callee0"}16; Which is incorrect because the lifetime.end of %src will now "noalias" the above memcpy.17define i8 @test(i8 %input) {18  %tmp = alloca i819  %dst = alloca i820  %src = alloca i821; NOTE: we're matching the full line and looking for the lack of !alias.scope here22; CHECK:   call void @llvm.memcpy.p0.p0.i64(ptr align 8 %dst, ptr align 8 %src, i64 1, i1 false)23  call void @llvm.lifetime.start.p0(ptr nonnull %src), !noalias !324  store i8 %input, ptr %src25  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %tmp, ptr align 8 %src, i64 1, i1 false), !alias.scope !026  call void @llvm.lifetime.end.p0(ptr nonnull %src), !noalias !327  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %dst, ptr align 8 %tmp, i64 1, i1 false), !alias.scope !328  %ret_value = load i8, ptr %dst29  call void @use(ptr %src)30  ret i8 %ret_value31}32 33declare void @llvm.lifetime.start.p0(ptr nocapture)34declare void @llvm.lifetime.end.p0(ptr nocapture)35declare void @llvm.memcpy.p0.p0.i64(ptr, ptr, i64, i1)36 37!0 = !{!1}38!1 = distinct !{!1, !2, !"callee0: %a"}39!2 = distinct !{!2, !"callee0"}40!3 = !{!4}41!4 = distinct !{!4, !5, !"callee1: %a"}42!5 = distinct !{!5, !"callee1"}43