brintos

brintos / llvm-project-archived public Read only

0
0
Text · 5.9 KiB · c5a47f7 Raw
105 lines · plain
1; RUN: opt -S -passes=sroa -sroa-skip-mem2reg %s \2; RUN: | FileCheck %s --implicit-check-not="#dbg_"3 4;; NOTE: This is the same as split-pre-fragmented-store.ll except the base5;; alloca's dbg.assign has been altered to contain a fragment of the full6;; variable - the variable's size has been modified from 64 to 96 bits.7;; This version of the test ensures that the behaviour being tested is still8;; correct when the base alloca doesn't hold an entire variable.9 10;; IR hand-modified, originally generated from:11;; struct Pair { int a; int b; };12;; Pair getVar();13;; int fun() {14;;   Pair var;15;;   var = getVar();16;;   return var.b;17;; }18;; Modification: split the dbg.assign linked the the memcpy(64 bits) into two,19;; each describing a 32 bit fragment.20;;21;; Check that assignment tracking updates in SROA work when the store being22;; split is described with one dbg.assign (covering different fragments). The23;; store may have been already split and then merged again at some point.24 25;; Alloca for var.a and associated dbg.assign:26; CHECK: %var.sroa.0 = alloca i32, align 4, !DIAssignID ![[id_1:[0-9]+]]27; CHECK-NEXT: #dbg_assign(i1 undef, ![[var:[0-9]+]], !DIExpression(DW_OP_LLVM_fragment, 32, 32), ![[id_1]], ptr %var.sroa.0, !DIExpression(),28 29;; Alloca for var.b and associated dbg.assign:30; CHECK-NEXT: %var.sroa.1 = alloca i32, align 4, !DIAssignID ![[id_2:[0-9]+]]31; CHECK-NEXT: #dbg_assign(i1 undef, ![[var]], !DIExpression(DW_OP_LLVM_fragment, 64, 32), ![[id_2]], ptr %var.sroa.1, !DIExpression(),32 33;; Store to var.b (split from store to var) and associated dbg.assigns. The34;; dbg.assign for the fragment covering the (pre-split) assignment to var.a35;; should not be linked to the store.36; CHECK: store i32 %[[v:.*]], ptr %var.sroa.1,{{.*}}!DIAssignID ![[id_3:[0-9]+]]37; CHECK-NEXT: #dbg_assign(i32 %{{.*var\.sroa\.0.*}}, ![[var]], !DIExpression(DW_OP_LLVM_fragment, 32, 32), ![[id_4:[0-9]+]], ptr %var.sroa.0, !DIExpression(),38; CHECK-NEXT: #dbg_assign(i32 %[[v]], ![[var]], !DIExpression(DW_OP_LLVM_fragment, 64, 32), ![[id_3]], ptr %var.sroa.1, !DIExpression(),39 40; CHECK-DAG: ![[id_1]] = distinct !DIAssignID()41; CHECK-DAG: ![[id_2]] = distinct !DIAssignID()42; CHECK-DAG: ![[id_3]] = distinct !DIAssignID()43; CHECK-DAG: ![[id_4]] = distinct !DIAssignID()44 45%struct.Tuple = type { i32, i32, i32 }46 47define dso_local noundef i32 @_Z3funv() !dbg !9 {48entry:49  %var = alloca [2 x i32], align 4, !DIAssignID !1950  call void @llvm.dbg.assign(metadata i1 undef, metadata !14, metadata !DIExpression(DW_OP_LLVM_fragment, 32, 64), metadata !19, metadata ptr %var, metadata !DIExpression()), !dbg !2051  %ref.tmp = alloca %struct.Tuple, align 452  %call = call i64 @_Z6getVarv(), !dbg !2253  store i64 %call, ptr %ref.tmp, align 4, !dbg !2254  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %var, ptr align 4 %ref.tmp, i64 8, i1 false), !dbg !23, !DIAssignID !2955  call void @llvm.dbg.assign(metadata i1 undef, metadata !14, metadata !DIExpression(DW_OP_LLVM_fragment, 32, 32), metadata !29, metadata ptr %var, metadata !DIExpression()), !dbg !2056  call void @llvm.dbg.assign(metadata i1 undef, metadata !14, metadata !DIExpression(DW_OP_LLVM_fragment, 64, 32), metadata !29, metadata ptr %var, metadata !DIExpression(DW_OP_plus, DW_OP_constu, 4)), !dbg !2057  %b = getelementptr inbounds %struct.Tuple, ptr %var, i32 0, i32 1, !dbg !3158  %0 = load i32, ptr %b, align 4, !dbg !3159  ret i32 %0, !dbg !3560}61 62declare !dbg !36 i64 @_Z6getVarv()63declare void @llvm.dbg.declare(metadata, metadata, metadata)64declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg)65declare void @llvm.dbg.assign(metadata, metadata, metadata, metadata, metadata, metadata)66 67!llvm.dbg.cu = !{!0}68!llvm.module.flags = !{!2, !3, !4, !5, !6, !7}69!llvm.ident = !{!8}70 71!0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus_14, file: !1, producer: "clang version 16.0.0", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, splitDebugInlining: false, nameTableKind: None)72!1 = !DIFile(filename: "test.cpp", directory: "/")73!2 = !{i32 7, !"Dwarf Version", i32 5}74!3 = !{i32 2, !"Debug Info Version", i32 3}75!4 = !{i32 1, !"wchar_size", i32 4}76!5 = !{i32 8, !"PIC Level", i32 2}77!6 = !{i32 7, !"PIE Level", i32 2}78!7 = !{i32 7, !"uwtable", i32 2}79!8 = !{!"clang version 16.0.0"}80!9 = distinct !DISubprogram(name: "fun", linkageName: "_Z3funv", scope: !1, file: !1, line: 3, type: !10, scopeLine: 3, flags: DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !13)81!10 = !DISubroutineType(types: !11)82!11 = !{!12}83!12 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)84!13 = !{!14}85!14 = !DILocalVariable(name: "var", scope: !9, file: !1, line: 4, type: !15)86!15 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "Tuple", file: !1, line: 1, size: 96, flags: DIFlagTypePassByValue, elements: !16, identifier: "_ZTS4Pair")87!16 = !{!17, !18, !40}88!17 = !DIDerivedType(tag: DW_TAG_member, name: "a", scope: !15, file: !1, line: 1, baseType: !12, size: 32)89!18 = !DIDerivedType(tag: DW_TAG_member, name: "b", scope: !15, file: !1, line: 1, baseType: !12, size: 32, offset: 32)90!19 = distinct !DIAssignID()91!20 = !DILocation(line: 0, scope: !9)92!21 = !DILocation(line: 4, column: 3, scope: !9)93!22 = !DILocation(line: 5, column: 9, scope: !9)94!23 = !DILocation(line: 5, column: 7, scope: !9)95!29 = distinct !DIAssignID()96!30 = !DILocation(line: 5, column: 3, scope: !9)97!31 = !DILocation(line: 6, column: 14, scope: !9)98!34 = !DILocation(line: 7, column: 1, scope: !9)99!35 = !DILocation(line: 6, column: 3, scope: !9)100!36 = !DISubprogram(name: "getVar", linkageName: "_Z6getVarv", scope: !1, file: !1, line: 2, type: !37, flags: DIFlagPrototyped, spFlags: DISPFlagOptimized, retainedNodes: !39)101!37 = !DISubroutineType(types: !38)102!38 = !{!15}103!39 = !{}104!40 = !DIDerivedType(tag: DW_TAG_member, name: "c", scope: !15, file: !1, line: 1, baseType: !12, size: 32, offset: 64)105