brintos

brintos / llvm-project-archived public Read only

0
0
Text · 3.2 KiB · 99b4563 Raw
81 lines · plain
1; RUN: opt -passes=inline %s -S -o - \2; RUN: | FileCheck %s3 4;; Hand modified from:5;; $ cat test.c6;; int g = 5;7;; static int callee() {8;;   int local = g;9;;   return local;10;; }11;;12;; int fun() {13;;   return callee();14;; }15;;16;; IR grabbed before inlining in:17;;     $ clang++ -O2 -g18;; Then modified (see comment in body).19 20;; NOTE: Although this reproducer is contrived, this has been observed in real21;; builds with assignment tracking (dbg.assign intrinsics) - in fact, it caused22;; verifier failures in some cases using assignment tracking (good). This is23;; the simplest test I could write.24 25;; use-before-defs in debug intrinsics should be preserved through inlining,26;; or at the very least should be converted to undefs. The previous behaviour27;; was to replace the use-before-def operand with empty metadata, which signals28;; cleanup passes that it's okay to remove the debug intrinsic (bad). Check29;; that this no longer happens.30 31; CHECK: define dso_local i32 @fun()32; CHECK-NEXT: entry33; CHECK-NEXT: #dbg_value(i32 %034 35@g = dso_local local_unnamed_addr global i32 5, align 4, !dbg !036 37define dso_local i32 @fun() local_unnamed_addr #0 !dbg !11 {38entry:39  %call = call fastcc i32 @callee(), !dbg !1440  ret i32 %call, !dbg !1541}42 43define internal fastcc i32 @callee() unnamed_addr #1 !dbg !16 {44entry:45  ;; dbg.value moved here from after %0 def.46  call void @llvm.dbg.value(metadata i32 %0, metadata !18, metadata !DIExpression()), !dbg !2447  %0 = load i32, ptr @g, align 4, !dbg !1948  ret i32 %0, !dbg !2549}50 51declare void @llvm.dbg.value(metadata, metadata, metadata) #252 53 54!llvm.dbg.cu = !{!2}55!llvm.module.flags = !{!7, !8, !9, !1000}56!llvm.ident = !{!10}57 58!0 = !DIGlobalVariableExpression(var: !1, expr: !DIExpression())59!1 = distinct !DIGlobalVariable(name: "g", scope: !2, file: !3, line: 1, type: !6, isLocal: false, isDefinition: true)60!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)61!3 = !DIFile(filename: "test.c", directory: "/")62!4 = !{}63!5 = !{!0}64!6 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)65!7 = !{i32 7, !"Dwarf Version", i32 4}66!8 = !{i32 2, !"Debug Info Version", i32 3}67!9 = !{i32 1, !"wchar_size", i32 4}68!10 = !{!"clang version 12.0.0"}69!11 = distinct !DISubprogram(name: "fun", scope: !3, file: !3, line: 7, type: !12, scopeLine: 7, flags: DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !2, retainedNodes: !4)70!12 = !DISubroutineType(types: !13)71!13 = !{!6}72!14 = !DILocation(line: 8, column: 10, scope: !11)73!15 = !DILocation(line: 8, column: 3, scope: !11)74!16 = distinct !DISubprogram(name: "callee", scope: !3, file: !3, line: 2, type: !12, scopeLine: 2, flags: DIFlagAllCallsDescribed, spFlags: DISPFlagLocalToUnit | DISPFlagDefinition | DISPFlagOptimized, unit: !2, retainedNodes: !17)75!17 = !{!18}76!18 = !DILocalVariable(name: "local", scope: !16, file: !3, line: 3, type: !6)77!19 = !DILocation(line: 3, column: 15, scope: !16)78!24 = !DILocation(line: 0, scope: !16)79!25 = !DILocation(line: 4, column: 3, scope: !16)80!1000 = !{i32 7, !"debug-info-assignment-tracking", i1 true}81