brintos

brintos / llvm-project-archived public Read only

0
0
Text · 7.8 KiB · 5ea3ae4 Raw
139 lines · plain
1; RUN: opt -passes=sroa,verify -S %s -o - \2; RUN: | FileCheck %s --implicit-check-not="#dbg_"3 4; Check that the new slices of an alloca and memset intructions get dbg.assign5; intrinsics with the correct fragment info. Ensure that only the6; value-expression gets fragment info; that the address-expression remains7; untouched.8 9;; $ cat test.cpp10;; void do_something();11;; struct LargeStruct {12;;   int A, B, C;13;;   int Var;14;;   int D, E, F;15;; };16;; int Glob;17;; bool Cond;18;; int use(LargeStruct);19;; int example() {20;;   LargeStruct S = {0};21;;   S.Var = Glob;22;;   use(S);23;;   return S.Var;24;; }25;; $ clang test.cpp -Xclang -disable-llvm-passes -O2 -g -c -S -emit-llvm -o - \26;;   | opt -passes=declare-to-assign -S -o -27 28; CHECK: entry:29; CHECK-NEXT:   %S.sroa.0 = alloca { i32, i32, i32 }, align 8, !DIAssignID ![[ID_1:[0-9]+]]30; CHECK-NEXT:   #dbg_assign(i1 undef, ![[VAR:[0-9]+]], !DIExpression(DW_OP_LLVM_fragment, 0, 96), ![[ID_1]], ptr %S.sroa.0, !DIExpression(),31 32; CHECK-NEXT:   %S.sroa.4 = alloca { i32, i32, i32 }, align 8, !DIAssignID ![[ID_3:[0-9]+]]33; CHECK-NEXT:   #dbg_assign(i1 undef, ![[VAR]], !DIExpression(DW_OP_LLVM_fragment, 128, 96), ![[ID_3]], ptr %S.sroa.4, !DIExpression(),34 35;; The memset has been split into [0, 96)[96, 128)[128, 224) bit slices. The36;; memset for the middle slice has been removed.37; CHECK: call void @llvm.memset{{.*}}(ptr align 8 %S.sroa.0, i8 0, i64 12, i1 false), !dbg !{{.+}}, !DIAssignID ![[ID_4:[0-9]+]]38; CHECK-NEXT: call void @llvm.memset{{.*}}(ptr align 8 %S.sroa.4, i8 0, i64 12, i1 false), !dbg !{{.+}}, !DIAssignID ![[ID_5:[0-9]+]]39 40; CHECK-NEXT: #dbg_assign(i8 0, ![[VAR]], !DIExpression(DW_OP_LLVM_fragment, 0, 96), ![[ID_4]], ptr %S.sroa.0, !DIExpression(),41;; This is the one we care about most in this test: check that a memset->store42;; gets a correct dbg.assign.43; CHECK-NEXT: #dbg_value(i32 0, ![[VAR]], !DIExpression(DW_OP_LLVM_fragment, 96, 32),44; CHECK-NEXT: #dbg_assign(i8 0, ![[VAR]], !DIExpression(DW_OP_LLVM_fragment, 128, 96), ![[ID_5]], ptr %S.sroa.4, !DIExpression(),45 46;; The load from global+store becomes a load.47;; FIXME: In reality it is actually stored again later on.48; CHECK-NEXT: %0 = load i32, ptr @Glob, align 4, !dbg !{{.+}}49; CHECK-NEXT: #dbg_value(i32 %0, ![[VAR]], !DIExpression(DW_OP_LLVM_fragment, 96, 32),50 51 52target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"53 54%struct.LargeStruct = type { i32, i32, i32, i32, i32, i32, i32 }55 56@Glob = dso_local global i32 0, align 4, !dbg !057@Cond = dso_local global i8 0, align 1, !dbg !658 59; Function Attrs: uwtable mustprogress60define dso_local i32 @_Z7examplev() #0 !dbg !14 {61entry:62  %S = alloca %struct.LargeStruct, align 4, !DIAssignID !2863  call void @llvm.dbg.assign(metadata i1 undef, metadata !18, metadata !DIExpression(), metadata !28, metadata ptr %S, metadata !DIExpression()), !dbg !2964  %agg.tmp = alloca %struct.LargeStruct, align 865  %0 = bitcast ptr %S to ptr, !dbg !3066  %1 = bitcast ptr %S to ptr, !dbg !3167  call void @llvm.memset.p0.i64(ptr align 4 %1, i8 0, i64 28, i1 false), !dbg !31, !DIAssignID !3268  call void @llvm.dbg.assign(metadata i8 0, metadata !18, metadata !DIExpression(), metadata !32, metadata ptr %1, metadata !DIExpression()), !dbg !3169  %2 = load i32, ptr @Glob, align 4, !dbg !3370  %Var = getelementptr inbounds %struct.LargeStruct, ptr %S, i32 0, i32 3, !dbg !3871  store i32 %2, ptr %Var, align 4, !dbg !39, !DIAssignID !4272  call void @llvm.dbg.assign(metadata i32 %2, metadata !18, metadata !DIExpression(DW_OP_LLVM_fragment, 96, 32), metadata !42, metadata ptr %Var, metadata !DIExpression()), !dbg !3973  %3 = bitcast ptr %agg.tmp to ptr, !dbg !4374  %4 = bitcast ptr %S to ptr, !dbg !4375  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %3, ptr align 4 %4, i64 28, i1 false), !dbg !4376  %call = call i32 @_Z3use11LargeStruct(ptr byval(%struct.LargeStruct) align 8 %agg.tmp), !dbg !4577  %Var1 = getelementptr inbounds %struct.LargeStruct, ptr %S, i32 0, i32 3, !dbg !4678  %5 = load i32, ptr %Var1, align 4, !dbg !4679  %6 = bitcast ptr %S to ptr, !dbg !4780  ret i32 %5, !dbg !4881}82 83 84declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #285declare !dbg !49 dso_local i32 @_Z3use11LargeStruct(ptr byval(%struct.LargeStruct) align 8) #386declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #187declare void @llvm.dbg.assign(metadata, metadata, metadata, metadata, metadata, metadata) #488 89!llvm.dbg.cu = !{!2}90!llvm.module.flags = !{!10, !11, !12, !1000}91!llvm.ident = !{!13}92 93!0 = !DIGlobalVariableExpression(var: !1, expr: !DIExpression())94!1 = distinct !DIGlobalVariable(name: "Glob", scope: !2, file: !3, line: 7, type: !9, isLocal: false, isDefinition: true)95!2 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus_14, file: !3, producer: "clang version 12.0.0", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !4, globals: !5, splitDebugInlining: false, nameTableKind: None)96!3 = !DIFile(filename: "test.cpp", directory: "/")97!4 = !{}98!5 = !{!0, !6}99!6 = !DIGlobalVariableExpression(var: !7, expr: !DIExpression())100!7 = distinct !DIGlobalVariable(name: "Cond", scope: !2, file: !3, line: 8, type: !8, isLocal: false, isDefinition: true)101!8 = !DIBasicType(name: "bool", size: 8, encoding: DW_ATE_boolean)102!9 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)103!10 = !{i32 7, !"Dwarf Version", i32 4}104!11 = !{i32 2, !"Debug Info Version", i32 3}105!12 = !{i32 1, !"wchar_size", i32 4}106!13 = !{!"clang version 12.0.0"}107!14 = distinct !DISubprogram(name: "example", linkageName: "_Z7examplev", scope: !3, file: !3, line: 10, type: !15, scopeLine: 10, flags: DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !2, retainedNodes: !17)108!15 = !DISubroutineType(types: !16)109!16 = !{!9}110!17 = !{!18}111!18 = !DILocalVariable(name: "S", scope: !14, file: !3, line: 11, type: !19)112!19 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "LargeStruct", file: !3, line: 2, size: 224, flags: DIFlagTypePassByValue, elements: !20, identifier: "_ZTS11LargeStruct")113!20 = !{!21, !22, !23, !24, !25, !26, !27}114!21 = !DIDerivedType(tag: DW_TAG_member, name: "A", scope: !19, file: !3, line: 3, baseType: !9, size: 32)115!22 = !DIDerivedType(tag: DW_TAG_member, name: "B", scope: !19, file: !3, line: 3, baseType: !9, size: 32, offset: 32)116!23 = !DIDerivedType(tag: DW_TAG_member, name: "C", scope: !19, file: !3, line: 3, baseType: !9, size: 32, offset: 64)117!24 = !DIDerivedType(tag: DW_TAG_member, name: "Var", scope: !19, file: !3, line: 4, baseType: !9, size: 32, offset: 96)118!25 = !DIDerivedType(tag: DW_TAG_member, name: "D", scope: !19, file: !3, line: 5, baseType: !9, size: 32, offset: 128)119!26 = !DIDerivedType(tag: DW_TAG_member, name: "E", scope: !19, file: !3, line: 5, baseType: !9, size: 32, offset: 160)120!27 = !DIDerivedType(tag: DW_TAG_member, name: "F", scope: !19, file: !3, line: 5, baseType: !9, size: 32, offset: 192)121!28 = distinct !DIAssignID()122!29 = !DILocation(line: 0, scope: !14)123!30 = !DILocation(line: 11, column: 3, scope: !14)124!31 = !DILocation(line: 11, column: 15, scope: !14)125!32 = distinct !DIAssignID()126!33 = !DILocation(line: 12, column: 11, scope: !14)127!38 = !DILocation(line: 12, column: 5, scope: !14)128!39 = !DILocation(line: 12, column: 9, scope: !14)129!42 = distinct !DIAssignID()130!43 = !DILocation(line: 13, column: 7, scope: !14)131!45 = !DILocation(line: 13, column: 3, scope: !14)132!46 = !DILocation(line: 14, column: 12, scope: !14)133!47 = !DILocation(line: 15, column: 1, scope: !14)134!48 = !DILocation(line: 14, column: 3, scope: !14)135!49 = !DISubprogram(name: "use", linkageName: "_Z3use11LargeStruct", scope: !3, file: !3, line: 9, type: !50, flags: DIFlagPrototyped, spFlags: DISPFlagOptimized, retainedNodes: !4)136!50 = !DISubroutineType(types: !51)137!51 = !{!9, !19}138!1000 = !{i32 7, !"debug-info-assignment-tracking", i1 true}139