; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 4 ; RUN: opt -passes='sroa' -S < %s | FileCheck %s source_filename = "test/Transforms/SROA/heterogeneous-poison.ll" target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128" %struct.pair = type { i32, i32 } define i32 @t1() !dbg !9 { ; CHECK-LABEL: define i32 @t1( ; CHECK-SAME: ) !dbg [[DBG9:![0-9]+]] { ; CHECK-NEXT: #dbg_value(i32 2, [[META13:![0-9]+]], !DIExpression(DIOpArg(0, i32)), [[META15:![0-9]+]]) ; CHECK-NEXT: ret i32 2 ; %local = alloca i32, align 4 #dbg_declare(ptr %local, !13, !DIExpression(DIOpArg(0, ptr addrspace(5)), DIOpDeref(i32)), !15) store i32 2, ptr %local, align 4 %read = load i32, ptr %local, align 4 ret i32 %read } define i32 @t2(i1 %cond) !dbg !16 { ; CHECK-LABEL: define i32 @t2( ; CHECK-SAME: i1 [[COND:%.*]]) !dbg [[DBG16:![0-9]+]] { ; CHECK-NEXT: br i1 [[COND]], label [[THEN:%.*]], label [[ELSE:%.*]] ; CHECK: then: ; CHECK-NEXT: #dbg_value(i32 42, [[META18:![0-9]+]], !DIExpression(DIOpArg(0, i32)), [[META19:![0-9]+]]) ; CHECK-NEXT: br label [[JOIN:%.*]] ; CHECK: else: ; CHECK-NEXT: #dbg_value(i32 2, [[META18]], !DIExpression(DIOpArg(0, i32)), [[META19]]) ; CHECK-NEXT: br label [[JOIN]] ; CHECK: join: ; CHECK-NEXT: [[LOCAL_0:%.*]] = phi i32 [ 42, [[THEN]] ], [ 2, [[ELSE]] ] ; CHECK-NEXT: #dbg_value(i32 [[LOCAL_0]], [[META18]], !DIExpression(DIOpArg(0, i32)), [[META19]]) ; CHECK-NEXT: ret i32 [[LOCAL_0]] ; %local = alloca i32, align 4 #dbg_declare(ptr %local, !17, !DIExpression(DIOpArg(0, ptr addrspace(5)), DIOpDeref(i32)), !18) br i1 %cond, label %then, label %else then: ; preds = %0 store i32 42, ptr %local, align 4 br label %join else: ; preds = %0 store i32 2, ptr %local, align 4 br label %join join: ; preds = %else, %then %retval = load i32, ptr %local, align 4 ret i32 %retval } define void @t3() !dbg !19 { ; CHECK-LABEL: define void @t3( ; CHECK-SAME: ) !dbg [[DBG20:![0-9]+]] { ; CHECK-NEXT: #dbg_value(i32 42, [[META22:![0-9]+]], !DIExpression(DIOpArg(0, i32), DIOpFragment(0, 32)), [[META27:![0-9]+]]) ; CHECK-NEXT: #dbg_value(i32 43, [[META22]], !DIExpression(DIOpArg(0, i32), DIOpFragment(32, 32)), [[META27]]) ; CHECK-NEXT: ret void ; %local = alloca %struct.pair, align 4 #dbg_declare(ptr %local, !20, !DIExpression(DIOpArg(0, ptr addrspace(5)), DIOpDeref(%struct.pair)), !25) %first = getelementptr inbounds %struct.pair, ptr %local, i32 0, i32 0 store i32 42, ptr %first, align 4 %second = getelementptr inbounds %struct.pair, ptr %local, i32 0, i32 1 store i32 43, ptr %second, align 4 ret void } define i32 @t4() !dbg !26 { ;; FIXME(diexpression-poison): We could probably preserve debug info for the dbg.value here if ;; necessary. Check that we at least do something sensible with it for now. ; CHECK-LABEL: define i32 @t4( ; CHECK-SAME: ) !dbg [[DBG28:![0-9]+]] { ; CHECK-NEXT: #dbg_value(ptr poison, [[META30:![0-9]+]], !DIExpression(DIOpArg(0, ptr addrspace(5)), DIOpDeref(i32)), [[META31:![0-9]+]]) ; CHECK-NEXT: ret i32 42 ; %local = alloca i32, align 4 #dbg_value(ptr %local, !27, !DIExpression(DIOpArg(0, ptr addrspace(5)), DIOpDeref(i32)), !28) store i32 42, ptr %local, align 4 %loaded = load i32, ptr %local, align 4 ret i32 %loaded } define i16 @t5(i1 %cond) !dbg !29 { ;; Verify that we still convert if the new value doesn't cover the entire size ;; of the variable !30. This is something that old-style DIExpressions don't ;; support. ; CHECK-LABEL: define i16 @t5( ; CHECK-SAME: i1 [[COND:%.*]]) !dbg [[DBG32:![0-9]+]] { ; CHECK-NEXT: br i1 [[COND]], label [[THEN:%.*]], label [[ELSE:%.*]] ; CHECK: then: ; CHECK-NEXT: #dbg_value(i16 42, [[META34:![0-9]+]], !DIExpression(DIOpArg(0, i16), DIOpSExt(i32)), [[META35:![0-9]+]]) ; CHECK-NEXT: br label [[JOIN:%.*]] ; CHECK: else: ; CHECK-NEXT: #dbg_value(i16 43, [[META34]], !DIExpression(DIOpArg(0, i16), DIOpSExt(i32)), [[META35]]) ; CHECK-NEXT: br label [[JOIN]] ; CHECK: join: ; CHECK-NEXT: [[LOCAL_0:%.*]] = phi i16 [ 42, [[THEN]] ], [ 43, [[ELSE]] ] ; CHECK-NEXT: #dbg_value(i16 [[LOCAL_0]], [[META34]], !DIExpression(DIOpArg(0, i16), DIOpSExt(i32)), [[META35]]) ; CHECK-NEXT: ret i16 [[LOCAL_0]] ; %local = alloca i16, align 4 #dbg_declare(ptr %local, !30, !DIExpression(DIOpArg(0, ptr addrspace(5)), DIOpDeref(i16), DIOpSExt(i32)), !31) br i1 %cond, label %then, label %else then: ; preds = %0 store i16 42, ptr %local, align 4 br label %join else: ; preds = %0 store i16 43, ptr %local, align 4 br label %join join: ; preds = %else, %then %loaded = load i16, ptr %local, align 4 ret i16 %loaded } %struct.pair.pair = type { %struct.pair, %struct.pair } define void @t6() !dbg !32 { ; CHECK-LABEL: define void @t6( ; CHECK-SAME: ) !dbg [[DBG36:![0-9]+]] { ; CHECK-NEXT: #dbg_value(i32 0, [[META38:![0-9]+]], !DIExpression(DIOpArg(0, i32), DIOpFragment(0, 32)), [[META43:![0-9]+]]) ; CHECK-NEXT: #dbg_value(i32 1, [[META38]], !DIExpression(DIOpArg(0, i32), DIOpFragment(32, 32)), [[META43]]) ; CHECK-NEXT: #dbg_value(i32 2, [[META38]], !DIExpression(DIOpArg(0, i32), DIOpFragment(64, 32)), [[META43]]) ; CHECK-NEXT: #dbg_value(i32 3, [[META38]], !DIExpression(DIOpArg(0, i32), DIOpFragment(96, 32)), [[META43]]) ; CHECK-NEXT: ret void ; %first = alloca %struct.pair, align 4 %second = alloca %struct.pair, align 4 #dbg_declare(ptr %first, !37, !DIExpression(DIOpArg(0, ptr), DIOpDeref(%struct.pair), DIOpFragment(0, 64)), !38) #dbg_declare(ptr %second, !37, !DIExpression(DIOpArg(0, ptr), DIOpDeref(%struct.pair), DIOpFragment(64, 64)), !38) %f0_ptr = getelementptr inbounds %struct.pair, ptr %first, i32 0, i32 0 store i32 0, ptr %f0_ptr, align 4 %f1_ptr = getelementptr inbounds %struct.pair, ptr %first, i32 0, i32 1 store i32 1, ptr %f1_ptr, align 4 %f2_ptr = getelementptr inbounds %struct.pair, ptr %second, i32 0, i32 0 store i32 2, ptr %f2_ptr, align 4 %f3_ptr = getelementptr inbounds %struct.pair, ptr %second, i32 0, i32 1 store i32 3, ptr %f3_ptr, align 4 ret void } ; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none) declare void @llvm.dbg.declare(metadata, metadata, metadata) #0 ; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none) declare void @llvm.dbg.value(metadata, metadata, metadata) #0 attributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) } !llvm.dbg.cu = !{!0} !llvm.module.flags = !{!2, !3, !4, !5, !6, !7} !llvm.ident = !{!8} !0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus_14, file: !1, producer: "clang 19", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, splitDebugInlining: false, nameTableKind: None) !1 = !DIFile(filename: "t.cpp", directory: "/") !2 = !{i32 7, !"Dwarf Version", i32 5} !3 = !{i32 2, !"Debug Info Version", i32 3} !4 = !{i32 1, !"wchar_size", i32 4} !5 = !{i32 8, !"PIC Level", i32 2} !6 = !{i32 7, !"PIE Level", i32 2} !7 = !{i32 7, !"uwtable", i32 2} !8 = !{!"clang 19"} !9 = distinct !DISubprogram(name: "t1", linkageName: "t1", scope: !1, file: !1, line: 7, type: !10, scopeLine: 7, flags: DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !12) !10 = !DISubroutineType(types: !11) !11 = !{null} !12 = !{!13} !13 = !DILocalVariable(name: "local", scope: !9, file: !1, line: 8, type: !14) !14 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed) !15 = !DILocation(line: 8, column: 3, scope: !9) !16 = distinct !DISubprogram(name: "t2", linkageName: "t2", scope: !1, file: !1, line: 7, type: !10, scopeLine: 7, flags: DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !39) !17 = !DILocalVariable(name: "local", scope: !16, file: !1, line: 1, type: !14) !18 = !DILocation(line: 1, column: 1, scope: !16) !19 = distinct !DISubprogram(name: "t3", linkageName: "t3", scope: !1, file: !1, line: 7, type: !10, scopeLine: 7, flags: DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !40) !20 = !DILocalVariable(name: "local", scope: !19, file: !1, line: 1, type: !21) !21 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "pair", file: !1, line: 2, size: 64, flags: DIFlagTypePassByValue, elements: !22, identifier: "pair") !22 = !{!23, !24} !23 = !DIDerivedType(tag: DW_TAG_member, name: "s1", scope: !21, file: !1, line: 3, baseType: !14, size: 32) !24 = !DIDerivedType(tag: DW_TAG_member, name: "s2", scope: !21, file: !1, line: 4, baseType: !14, size: 32, offset: 32) !25 = !DILocation(line: 1, column: 1, scope: !19) !26 = distinct !DISubprogram(name: "t4", linkageName: "t4", scope: !1, file: !1, line: 7, type: !10, scopeLine: 7, flags: DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !41) !27 = !DILocalVariable(name: "local", scope: !26, file: !1, line: 1, type: !14) !28 = !DILocation(line: 1, column: 1, scope: !26) !29 = distinct !DISubprogram(name: "t5", linkageName: "t5", scope: !1, file: !1, line: 7, type: !10, scopeLine: 7, flags: DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !42) !30 = !DILocalVariable(name: "local_i16", scope: !29, file: !1, line: 1, type: !14) !31 = !DILocation(line: 1, column: 1, scope: !29) !32 = distinct !DISubprogram(name: "t6", linkageName: "t56", scope: !1, file: !1, line: 7, type: !10, scopeLine: 7, flags: DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !43) !33 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "pair_pair", file: !1, line: 2, size: 128, flags: DIFlagTypePassByValue, elements: !36, identifier: "pair_pair") !34 = !DIDerivedType(tag: DW_TAG_member, name: "s1", scope: !33, file: !1, line: 3, baseType: !21, size: 64) !35 = !DIDerivedType(tag: DW_TAG_member, name: "s2", scope: !33, file: !1, line: 4, baseType: !21, size: 64, offset: 64) !36 = !{!34, !35} !37 = !DILocalVariable(name: "local", scope: !32, file: !1, line: 1, type: !33) !38 = !DILocation(line: 1, column: 1, scope: !32) !39 = !{!17} !40 = !{!20} !41 = !{!27} !42 = !{!30} !43 = !{!37} ;. ; CHECK: [[META0:![0-9]+]] = distinct !DICompileUnit(language: DW_LANG_C_plus_plus_14, file: [[META1:![0-9]+]], producer: "clang 19", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, splitDebugInlining: false, nameTableKind: None) ; CHECK: [[META1]] = !DIFile(filename: "{{.*}}t.cpp", directory: {{.*}}) ; CHECK: [[DBG9]] = distinct !DISubprogram(name: "t1", linkageName: "t1", scope: [[META1]], file: [[META1]], line: 7, type: [[META10:![0-9]+]], scopeLine: 7, flags: DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: [[META0]], retainedNodes: [[META12:![0-9]+]]) ; CHECK: [[META10]] = !DISubroutineType(types: [[META11:![0-9]+]]) ; CHECK: [[META11]] = !{null} ; CHECK: [[META12]] = !{[[META13]]} ; CHECK: [[META13]] = !DILocalVariable(name: "local", scope: [[DBG9]], file: [[META1]], line: 8, type: [[META14:![0-9]+]]) ; CHECK: [[META14]] = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed) ; CHECK: [[META15]] = !DILocation(line: 0, scope: [[DBG9]]) ; CHECK: [[DBG16]] = distinct !DISubprogram(name: "t2", linkageName: "t2", scope: [[META1]], file: [[META1]], line: 7, type: [[META10]], scopeLine: 7, flags: DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: [[META0]], retainedNodes: [[META17:![0-9]+]]) ; CHECK: [[META17]] = !{[[META18]]} ; CHECK: [[META18]] = !DILocalVariable(name: "local", scope: [[DBG16]], file: [[META1]], line: 1, type: [[META14]]) ; CHECK: [[META19]] = !DILocation(line: 0, scope: [[DBG16]]) ; CHECK: [[DBG20]] = distinct !DISubprogram(name: "t3", linkageName: "t3", scope: [[META1]], file: [[META1]], line: 7, type: [[META10]], scopeLine: 7, flags: DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: [[META0]], retainedNodes: [[META21:![0-9]+]]) ; CHECK: [[META21]] = !{[[META22]]} ; CHECK: [[META22]] = !DILocalVariable(name: "local", scope: [[DBG20]], file: [[META1]], line: 1, type: [[META23:![0-9]+]]) ; CHECK: [[META23]] = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "pair", file: [[META1]], line: 2, size: 64, flags: DIFlagTypePassByValue, elements: [[META24:![0-9]+]], identifier: "pair") ; CHECK: [[META24]] = !{[[META25:![0-9]+]], [[META26:![0-9]+]]} ; CHECK: [[META25]] = !DIDerivedType(tag: DW_TAG_member, name: "s1", scope: [[META23]], file: [[META1]], line: 3, baseType: [[META14]], size: 32) ; CHECK: [[META26]] = !DIDerivedType(tag: DW_TAG_member, name: "s2", scope: [[META23]], file: [[META1]], line: 4, baseType: [[META14]], size: 32, offset: 32) ; CHECK: [[META27]] = !DILocation(line: 0, scope: [[DBG20]]) ; CHECK: [[DBG28]] = distinct !DISubprogram(name: "t4", linkageName: "t4", scope: [[META1]], file: [[META1]], line: 7, type: [[META10]], scopeLine: 7, flags: DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: [[META0]], retainedNodes: [[META29:![0-9]+]]) ; CHECK: [[META29]] = !{[[META30]]} ; CHECK: [[META30]] = !DILocalVariable(name: "local", scope: [[DBG28]], file: [[META1]], line: 1, type: [[META14]]) ; CHECK: [[META31]] = !DILocation(line: 1, column: 1, scope: [[DBG28]]) ; CHECK: [[DBG32]] = distinct !DISubprogram(name: "t5", linkageName: "t5", scope: [[META1]], file: [[META1]], line: 7, type: [[META10]], scopeLine: 7, flags: DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: [[META0]], retainedNodes: [[META33:![0-9]+]]) ; CHECK: [[META33]] = !{[[META34]]} ; CHECK: [[META34]] = !DILocalVariable(name: "local_i16", scope: [[DBG32]], file: [[META1]], line: 1, type: [[META14]]) ; CHECK: [[META35]] = !DILocation(line: 0, scope: [[DBG32]]) ; CHECK: [[DBG36]] = distinct !DISubprogram(name: "t6", linkageName: "t56", scope: [[META1]], file: [[META1]], line: 7, type: [[META10]], scopeLine: 7, flags: DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: [[META0]], retainedNodes: [[META37:![0-9]+]]) ; CHECK: [[META37]] = !{[[META38]]} ; CHECK: [[META38]] = !DILocalVariable(name: "local", scope: [[DBG36]], file: [[META1]], line: 1, type: [[META39:![0-9]+]]) ; CHECK: [[META39]] = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "pair_pair", file: [[META1]], line: 2, size: 128, flags: DIFlagTypePassByValue, elements: [[META40:![0-9]+]], identifier: "pair_pair") ; CHECK: [[META40]] = !{[[META41:![0-9]+]], [[META42:![0-9]+]]} ; CHECK: [[META41]] = !DIDerivedType(tag: DW_TAG_member, name: "s1", scope: [[META39]], file: [[META1]], line: 3, baseType: [[META23]], size: 64) ; CHECK: [[META42]] = !DIDerivedType(tag: DW_TAG_member, name: "s2", scope: [[META39]], file: [[META1]], line: 4, baseType: [[META23]], size: 64, offset: 64) ; CHECK: [[META43]] = !DILocation(line: 0, scope: [[DBG36]]) ;.