brintos

brintos / llvm-project-archived public Read only

0
0
Text · 4.1 KiB · b780155 Raw
88 lines · plain
1; RUN: opt -passes=simplifycfg %s -S  \2; RUN: | FileCheck %s3 4;; Ensure that we correctly update the value component of dbg.assign intrinsics5;; after merging a conditional block with a store its the predecessor. The6;; value stored is still conditional, but the store itself is now7;; unconditionally run, so we must be sure that any linked dbg.assign intrinsics8;; are tracking the new stored value (the result of the select). If we don't,9;; and the store were to be removed by another pass (e.g. DSE), then we'd10;; eventually end up emitting a location describing the conditional value,11;; unconditionally.12 13;; Created from the following source and command, with dbg.assign and DIAssignID14;; metadata added and some other metadata removed by hand:15;; $ cat test.c16;; int a;17;; void b() {18;;   int c = 0;19;;   if (a)20;;      c = 1;21;; }22;; $ clang -O2 -g -emit-llvm -S test.c -Xclang -fexperimental-assignment-tracking23 24; CHECK: %[[SELECT:.*]] = select i1 %tobool25; CHECK-NEXT: store i32 %[[SELECT]], ptr %c{{.*}}, !DIAssignID ![[ID:[0-9]+]]26; CHECK-NEXT: #dbg_assign(i32 %[[SELECT]], ![[VAR_C:[0-9]+]], !DIExpression(), ![[ID]], ptr %c, !DIExpression(),27; CHECK: ![[VAR_C]] = !DILocalVariable(name: "c",28 29@a = dso_local global i32 0, align 4, !dbg !030 31define dso_local void @b() !dbg !11 {32entry:33  %c = alloca i32, align 434  %0 = bitcast ptr %c to ptr, !dbg !1635  call void @llvm.lifetime.start.p0(i64 4, ptr %0), !dbg !1636  store i32 0, ptr %c, align 4, !dbg !17, !DIAssignID !3637  call void @llvm.dbg.assign(metadata i32 0, metadata !15, metadata !DIExpression(), metadata !36, metadata ptr %c, metadata !DIExpression()), !dbg !1738  %1 = load i32, ptr @a, align 4, !dbg !2239  %tobool = icmp ne i32 %1, 0, !dbg !2240  br i1 %tobool, label %if.then, label %if.end, !dbg !2441 42if.then:                                          ; preds = %entry43  store i32 1, ptr %c, align 4, !dbg !25, !DIAssignID !3744  call void @llvm.dbg.assign(metadata i32 1, metadata !15, metadata !DIExpression(), metadata !37, metadata ptr %c, metadata !DIExpression()), !dbg !1745  br label %if.end, !dbg !2646 47if.end:                                           ; preds = %if.then, %entry48  %2 = bitcast ptr %c to ptr, !dbg !2749  call void @llvm.lifetime.end.p0(i64 4, ptr %2), !dbg !2750  ret void, !dbg !2751}52 53declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture)54declare void @llvm.dbg.assign(metadata, metadata, metadata, metadata, metadata, metadata)55declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture)56 57!llvm.dbg.cu = !{!2}58!llvm.module.flags = !{!7, !8, !9, !1000}59!llvm.ident = !{!10}60 61!0 = !DIGlobalVariableExpression(var: !1, expr: !DIExpression())62!1 = distinct !DIGlobalVariable(name: "a", scope: !2, file: !3, line: 1, type: !6, isLocal: false, isDefinition: true)63!2 = distinct !DICompileUnit(language: DW_LANG_C99, file: !3, producer: "clang version 14.0.0", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !4, globals: !5, splitDebugInlining: false, nameTableKind: None)64!3 = !DIFile(filename: "test.c", directory: "/")65!4 = !{}66!5 = !{!0}67!6 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)68!7 = !{i32 7, !"Dwarf Version", i32 4}69!8 = !{i32 2, !"Debug Info Version", i32 3}70!9 = !{i32 1, !"wchar_size", i32 4}71!10 = !{!"clang version 12.0.0"}72!11 = distinct !DISubprogram(name: "b", scope: !3, file: !3, line: 2, type: !12, scopeLine: 2, flags: DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !2, retainedNodes: !14)73!12 = !DISubroutineType(types: !13)74!13 = !{null}75!14 = !{!15}76!15 = !DILocalVariable(name: "c", scope: !11, file: !3, line: 3, type: !6)77!16 = !DILocation(line: 3, column: 3, scope: !11)78!17 = !DILocation(line: 3, column: 7, scope: !11)79!22 = !DILocation(line: 4, column: 7, scope: !23)80!23 = distinct !DILexicalBlock(scope: !11, file: !3, line: 4, column: 7)81!24 = !DILocation(line: 4, column: 7, scope: !11)82!25 = !DILocation(line: 5, column: 7, scope: !23)83!26 = !DILocation(line: 5, column: 5, scope: !23)84!27 = !DILocation(line: 6, column: 1, scope: !11)85!36 = distinct !DIAssignID()86!37 = distinct !DIAssignID()87!1000 = !{i32 7, !"debug-info-assignment-tracking", i1 true}88