1; RUN: llc %s -o - | FileCheck %s 2 3;; This test has had source-locations removed from the prologue, to simulate 4;; heavily-optimised scenarios where a lot of debug-info gets dropped. Check 5;; that we can pick a "worst-case" prologue_end position, of the first 6;; instruction that does any meaningful computation (the add). It's better to 7;; put the prologue_end flag here rather than deeper into the loop, past the 8;; early-exit check. 9;; 10;; Generated from this code at -O2 -g in clang, with source locations then 11;; deleted. 12;; 13;; int glob = 0; 14;; int foo(int arg, int sum) { 15;; arg += sum; 16;; while (arg) { 17;; glob--; 18;; arg %= glob; 19;; } 20;; return 0; 21;; } 22 23; CHECK-LABEL: foo: 24;; Scope-line location: 25; CHECK: .loc 0 2 0 26;; Entry block: 27; CHECK: movl %edi, %edx 28; CHECK-NEXT: .loc 0 2 0 prologue_end 29; CHECK-NEXT: addl %esi, %edx 30; CHECK-NEXT: je .LBB0_4 31; CHECK-LABEL: # %bb.1: 32 33target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128" 34target triple = "x86_64-unknown-linux-gnu" 35 36@glob = dso_local local_unnamed_addr global i32 0, align 4, !dbg !0 37 38define dso_local noundef i32 @foo(i32 noundef %arg, i32 noundef %sum) local_unnamed_addr !dbg !9 { 39entry: 40 %add = add nsw i32 %sum, %arg 41 %tobool.not4 = icmp eq i32 %add, 0 42 br i1 %tobool.not4, label %while.end, label %while.body.preheader 43 44while.body.preheader: 45 %glob.promoted = load i32, ptr @glob, align 4 46 br label %while.body, !dbg !14 47 48while.body: 49 %arg.addr.06 = phi i32 [ %rem, %while.body ], [ %add, %while.body.preheader ] 50 %dec35 = phi i32 [ %dec, %while.body ], [ %glob.promoted, %while.body.preheader ] 51 %dec = add nsw i32 %dec35, -1, !dbg !15 52 %rem = srem i32 %arg.addr.06, %dec, !dbg !17 53 %tobool.not = icmp eq i32 %rem, 0, !dbg !14 54 br i1 %tobool.not, label %while.cond.while.end_crit_edge, label %while.body, !dbg !14 55 56while.cond.while.end_crit_edge: 57 store i32 %dec, ptr @glob, align 4, !dbg !15 58 br label %while.end, !dbg !14 59 60while.end: 61 ret i32 0, !dbg !18 62} 63 64!llvm.dbg.cu = !{!2} 65!llvm.module.flags = !{!6, !7} 66!llvm.ident = !{!8} 67 68!0 = !DIGlobalVariableExpression(var: !1, expr: !DIExpression()) 69!1 = distinct !DIGlobalVariable(name: "glob", scope: !2, file: !3, line: 1, type: !5, isLocal: false, isDefinition: true) 70!2 = distinct !DICompileUnit(language: DW_LANG_C11, file: !3, producer: "clang", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, globals: !4, splitDebugInlining: false, nameTableKind: None) 71!3 = !DIFile(filename: "foo.c", directory: "") 72!4 = !{!0} 73!5 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed) 74!6 = !{i32 7, !"Dwarf Version", i32 5} 75!7 = !{i32 2, !"Debug Info Version", i32 3} 76!8 = !{!"clang"} 77!9 = distinct !DISubprogram(name: "foo", scope: !3, file: !3, line: 2, type: !10, scopeLine: 2, flags: DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !2, retainedNodes: !12) 78!10 = !DISubroutineType(types: !11) 79!11 = !{!5, !5, !5} 80!12 = !{} 81!13 = !DILocation(line: 3, column: 7, scope: !9) 82!14 = !DILocation(line: 4, column: 3, scope: !9) 83!15 = !DILocation(line: 5, column: 9, scope: !16) 84!16 = distinct !DILexicalBlock(scope: !9, file: !3, line: 4, column: 15) 85!17 = !DILocation(line: 6, column: 9, scope: !16) 86!18 = !DILocation(line: 8, column: 3, scope: !9) 87