brintos

brintos / llvm-project-archived public Read only

0
0
Text · 6.4 KiB · 16312da Raw
144 lines · plain
1; RUN: opt %s -S -passes=instcombine -o - \2; RUN: | FileCheck %s3 4;; Check that when instcombine sinks an instruction used by a dbg.assign, the5;; usual debug intrinsic updating doesn't take place (i.e. do not6;; clone-and-sink a dbg.assign). Assignment tracking should be able to handle7;; this gracefully for variables that still have a stack home. For fully8;; promoted variables we may need to revisit this.9 10;; $ cat test.c11;; struct a {12;;   char *b;13;; } c() __attribute__((noreturn));14;; int d;15;; int e();16;; int f() {17;;   if (e())18;;     return d;19;;   c();20;; }21;; void g();22;; void h() {23;;   struct a i;24;;   i.b = 0;25;;   f();26;;   i.b = 0;27;;   g(&i);28;; }29;; $ clang -O2 -g -Xclang -fexperimental-assignment-tracking30 31; CHECK: f.exit:32; CHECK-NEXT: store ptr null, ptr %i, align 8,{{.+}}, !DIAssignID ![[ID:[0-9]+]]33; CHECK-NEXT: #dbg_assign({{.+}}, {{.+}}, {{.+}}, ![[ID]], ptr %i, {{.+}}, 34 35%struct.a = type { ptr }36 37@d = dso_local local_unnamed_addr global i32 0, align 4, !dbg !038 39; Function Attrs: nounwind uwtable40define dso_local i32 @f() local_unnamed_addr #0 !dbg !11 {41entry:42  %call = tail call i32 (...) @e() #5, !dbg !1443  %tobool.not = icmp eq i32 %call, 0, !dbg !1444  br i1 %tobool.not, label %if.end, label %if.then, !dbg !1645 46if.then:                                          ; preds = %entry47  %0 = load i32, ptr @d, align 4, !dbg !1748  ret i32 %0, !dbg !2249 50if.end:                                           ; preds = %entry51  %call1 = tail call ptr (...) @c() #6, !dbg !2352  unreachable, !dbg !2353}54 55declare !dbg !24 dso_local i32 @e(...) local_unnamed_addr #156 57; Function Attrs: noreturn58declare !dbg !27 dso_local ptr @c(...) local_unnamed_addr #259 60; Function Attrs: nounwind uwtable61define dso_local void @h() local_unnamed_addr #0 !dbg !35 {62entry:63  %i = alloca %struct.a, align 8, !DIAssignID !4064  call void @llvm.dbg.assign(metadata i1 undef, metadata !39, metadata !DIExpression(), metadata !40, metadata ptr %i, metadata !DIExpression()), !dbg !4165  %0 = bitcast ptr %i to ptr, !dbg !4266  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %0) #5, !dbg !4267  %b = getelementptr inbounds %struct.a, ptr %i, i64 0, i32 0, !dbg !4368  call void @llvm.dbg.assign(metadata ptr null, metadata !39, metadata !DIExpression(), metadata !44, metadata ptr %b, metadata !DIExpression()), !dbg !4169  %call.i = tail call i32 (...) @e() #5, !dbg !4570  %tobool.not.i = icmp eq i32 %call.i, 0, !dbg !4571  br i1 %tobool.not.i, label %if.end.i, label %f.exit, !dbg !4772 73if.end.i:                                         ; preds = %entry74  %call1.i = tail call ptr (...) @c() #6, !dbg !4875  unreachable, !dbg !4876 77f.exit:                                           ; preds = %entry78  store ptr null, ptr %b, align 8, !dbg !49, !DIAssignID !5379  call void @llvm.dbg.assign(metadata ptr null, metadata !39, metadata !DIExpression(), metadata !53, metadata ptr %b, metadata !DIExpression()), !dbg !4180  call void @g(ptr nonnull %i) #5, !dbg !5481  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %0) #5, !dbg !5582  ret void, !dbg !5583}84 85declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #386declare dso_local void @g(...) local_unnamed_addr #187declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #388declare void @llvm.dbg.assign(metadata, metadata, metadata, metadata, metadata, metadata) #489 90!llvm.dbg.cu = !{!2}91!llvm.module.flags = !{!7, !8, !9, !1000}92!llvm.ident = !{!10}93 94!0 = !DIGlobalVariableExpression(var: !1, expr: !DIExpression())95!1 = distinct !DIGlobalVariable(name: "d", scope: !2, file: !3, line: 4, type: !6, isLocal: false, isDefinition: true)96!2 = distinct !DICompileUnit(language: DW_LANG_C99, file: !3, producer: "clang version 12.0.0", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !4, globals: !5, splitDebugInlining: false, nameTableKind: None)97!3 = !DIFile(filename: "test.c", directory: "/")98!4 = !{}99!5 = !{!0}100!6 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)101!7 = !{i32 7, !"Dwarf Version", i32 4}102!8 = !{i32 2, !"Debug Info Version", i32 3}103!9 = !{i32 1, !"wchar_size", i32 4}104!10 = !{!"clang version 12.0.0"}105!11 = distinct !DISubprogram(name: "f", scope: !3, file: !3, line: 6, type: !12, scopeLine: 6, flags: DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !2, retainedNodes: !4)106!12 = !DISubroutineType(types: !13)107!13 = !{!6}108!14 = !DILocation(line: 7, column: 7, scope: !15)109!15 = distinct !DILexicalBlock(scope: !11, file: !3, line: 7, column: 7)110!16 = !DILocation(line: 7, column: 7, scope: !11)111!17 = !DILocation(line: 8, column: 12, scope: !15)112!22 = !DILocation(line: 8, column: 5, scope: !15)113!23 = !DILocation(line: 9, column: 3, scope: !11)114!24 = !DISubprogram(name: "e", scope: !3, file: !3, line: 5, type: !25, spFlags: DISPFlagOptimized, retainedNodes: !4)115!25 = !DISubroutineType(types: !26)116!26 = !{!6, null}117!27 = !DISubprogram(name: "c", scope: !3, file: !3, line: 3, type: !28, flags: DIFlagNoReturn, spFlags: DISPFlagOptimized, retainedNodes: !4)118!28 = !DISubroutineType(types: !29)119!29 = !{!30, null}120!30 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "a", file: !3, line: 1, size: 64, elements: !31)121!31 = !{!32}122!32 = !DIDerivedType(tag: DW_TAG_member, name: "b", scope: !30, file: !3, line: 2, baseType: !33, size: 64)123!33 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !34, size: 64)124!34 = !DIBasicType(name: "char", size: 8, encoding: DW_ATE_signed_char)125!35 = distinct !DISubprogram(name: "h", scope: !3, file: !3, line: 12, type: !36, scopeLine: 12, flags: DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !2, retainedNodes: !38)126!36 = !DISubroutineType(types: !37)127!37 = !{null}128!38 = !{!39}129!39 = !DILocalVariable(name: "i", scope: !35, file: !3, line: 13, type: !30)130!40 = distinct !DIAssignID()131!41 = !DILocation(line: 0, scope: !35)132!42 = !DILocation(line: 13, column: 3, scope: !35)133!43 = !DILocation(line: 14, column: 5, scope: !35)134!44 = distinct !DIAssignID()135!45 = !DILocation(line: 7, column: 7, scope: !15, inlinedAt: !46)136!46 = distinct !DILocation(line: 15, column: 3, scope: !35)137!47 = !DILocation(line: 7, column: 7, scope: !11, inlinedAt: !46)138!48 = !DILocation(line: 9, column: 3, scope: !11, inlinedAt: !46)139!49 = !DILocation(line: 16, column: 7, scope: !35)140!53 = distinct !DIAssignID()141!54 = !DILocation(line: 17, column: 3, scope: !35)142!55 = !DILocation(line: 18, column: 1, scope: !35)143!1000 = !{i32 7, !"debug-info-assignment-tracking", i1 true}144