82 lines · plain
1; RUN: opt -S %s -o - -passes=sroa | FileCheck %s2 3;; SROA splits the alloca into two. Each slice already has a 32-bit variable4;; associated with it (the structured binding variables). Check SROA doesn't5;; mistakenly create 32 bit fragments for them.6 7;; NOTE: The upper 32 bits are currently8;; not tracked with assignment tracking (due to the dbg.declare containing an9;; expression).10;; The dbg intrinsics for the unnamed aggregate variable have been commented11;; out to reduce test clutter.12 13;; From C++ source:14;; class two {public:int a; int b;}15;; two get();16;; int fun() {17;; auto [a, b] = get();18;; return a;19;; }20 21; CHECK: #dbg_value(i32 %.sroa.2.0.extract.trunc, ![[B:[0-9]+]], !DIExpression(),22; CHECK: #dbg_value(i32 %.sroa.0.0.extract.trunc, ![[A:[0-9]+]], !DIExpression(),23; CHECK: ![[A]] = !DILocalVariable(name: "a",24; CHECK: ![[B]] = !DILocalVariable(name: "b",25 26%class.two = type { i32, i32 }27 28define dso_local noundef i32 @_Z3funv() #0 !dbg !10 {29entry:30 %0 = alloca %class.two, align 4, !DIAssignID !2331 ;;call void @llvm.dbg.assign(metadata i1 undef, metadata !17, metadata !DIExpression(), metadata !23, metadata ptr %0, metadata !DIExpression()), !dbg !2432 call void @llvm.dbg.assign(metadata i1 undef, metadata !15, metadata !DIExpression(), metadata !23, metadata ptr %0, metadata !DIExpression()), !dbg !2433 call void @llvm.dbg.declare(metadata ptr %0, metadata !16, metadata !DIExpression(DW_OP_plus_uconst, 4)), !dbg !2634 %call = call i64 @_Z3getv()35 store i64 %call, ptr %0, align 4, !DIAssignID !2836 ;;call void @llvm.dbg.assign(metadata i64 %call, metadata !17, metadata !DIExpression(), metadata !28, metadata ptr %0, metadata !DIExpression()), !dbg !2437 call void @llvm.dbg.assign(metadata i64 %call, metadata !15, metadata !DIExpression(), metadata !28, metadata ptr %0, metadata !DIExpression()), !dbg !2438 %a = getelementptr inbounds %class.two, ptr %0, i32 0, i32 039 %1 = load i32, ptr %a, align 440 ret i32 %141}42 43declare void @llvm.dbg.declare(metadata, metadata, metadata) #244declare !dbg !38 i64 @_Z3getv() #345declare void @llvm.dbg.assign(metadata, metadata, metadata, metadata, metadata, metadata) #246 47!llvm.dbg.cu = !{!0}48!llvm.module.flags = !{!2, !3, !4, !5, !6, !7, !8}49!llvm.ident = !{!9}50 51!0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus_14, file: !1, producer: "clang version 17.0.0", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, splitDebugInlining: false, nameTableKind: None)52!1 = !DIFile(filename: "test.cpp", directory: "h")53!2 = !{i32 7, !"Dwarf Version", i32 5}54!3 = !{i32 2, !"Debug Info Version", i32 3}55!4 = !{i32 1, !"wchar_size", i32 4}56!5 = !{i32 8, !"PIC Level", i32 2}57!6 = !{i32 7, !"PIE Level", i32 2}58!7 = !{i32 7, !"uwtable", i32 2}59!8 = !{i32 7, !"debug-info-assignment-tracking", i1 true}60!9 = !{!"clang version 17.0.0"}61!10 = distinct !DISubprogram(name: "fun", linkageName: "_Z3funv", scope: !1, file: !1, line: 3, type: !11, scopeLine: 3, flags: DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !14)62!11 = !DISubroutineType(types: !12)63!12 = !{!13}64!13 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)65!14 = !{!15, !16, !17}66!15 = !DILocalVariable(name: "a", scope: !10, file: !1, line: 4, type: !13)67!16 = !DILocalVariable(name: "b", scope: !10, file: !1, line: 4, type: !13)68!17 = !DILocalVariable(scope: !10, file: !1, line: 4, type: !18)69!18 = distinct !DICompositeType(tag: DW_TAG_class_type, name: "two", file: !19, line: 1, size: 64, flags: DIFlagTypePassByValue, elements: !20, identifier: "_ZTS3two")70!19 = !DIFile(filename: "./include.h", directory: "/")71!20 = !{!21, !22}72!21 = !DIDerivedType(tag: DW_TAG_member, name: "a", scope: !18, file: !19, line: 1, baseType: !13, size: 32, flags: DIFlagPublic)73!22 = !DIDerivedType(tag: DW_TAG_member, name: "b", scope: !18, file: !19, line: 1, baseType: !13, size: 32, offset: 32, flags: DIFlagPublic)74!23 = distinct !DIAssignID()75!24 = !DILocation(line: 0, scope: !10)76!26 = !DILocation(line: 4, column: 12, scope: !10)77!28 = distinct !DIAssignID()78!38 = !DISubprogram(name: "get", linkageName: "_Z3getv", scope: !1, file: !1, line: 2, type: !39, flags: DIFlagPrototyped, spFlags: DISPFlagOptimized, retainedNodes: !41)79!39 = !DISubroutineType(types: !40)80!40 = !{!18}81!41 = !{}82