71 lines
3.1 KiB
LLVM
71 lines
3.1 KiB
LLVM
; Test DBG_LABEL MachineInstr under optimization.
|
|
; The test case is generated by clang with -O2 is on.
|
|
; REQUIRES: asserts
|
|
; RUN: llc -debug-only=isel %s -o /dev/null 2> %t.debug
|
|
; RUN: cat %t.debug | FileCheck %s --check-prefix=CHECKMI
|
|
;
|
|
; CHECKMI: DBG_LABEL "end_sum", debug-location !17
|
|
; CHECKMI: DBG_LABEL "end", debug-location !19
|
|
source_filename = "debug-label-opt.c"
|
|
|
|
define i32 @foo(ptr nocapture readonly %a, i32 %n) local_unnamed_addr !dbg !7 {
|
|
entry:
|
|
call void @llvm.dbg.value(metadata ptr %a, metadata !13, metadata !DIExpression()), !dbg !6
|
|
call void @llvm.dbg.value(metadata i32 %n, metadata !14, metadata !DIExpression()), !dbg !6
|
|
switch i32 %n, label %end_sum [
|
|
i32 2, label %end_sum.sink.split
|
|
i32 3, label %if.then3
|
|
], !dbg !6
|
|
|
|
if.then3: ; preds = %entry
|
|
%arrayidx4 = getelementptr inbounds i32, ptr %a, i64 1, !dbg !6
|
|
br label %end_sum.sink.split, !dbg !6
|
|
|
|
end_sum.sink.split: ; preds = %entry, %if.then3
|
|
%a.sink = phi ptr [ %arrayidx4, %if.then3 ], [ %a, %entry ]
|
|
%.sink = phi i64 [ 2, %if.then3 ], [ 1, %entry ]
|
|
%0 = load i32, ptr %a.sink, align 4
|
|
%arrayidx1 = getelementptr inbounds i32, ptr %a, i64 %.sink
|
|
%1 = load i32, ptr %arrayidx1, align 4
|
|
%add = add nsw i32 %1, %0
|
|
br label %end_sum, !dbg !6
|
|
|
|
end_sum: ; preds = %end_sum.sink.split, %entry
|
|
%sum.0 = phi i32 [ 0, %entry ], [ %add, %end_sum.sink.split ]
|
|
call void @llvm.dbg.label(metadata !15), !dbg !17
|
|
%2 = load i32, ptr %a, align 4, !dbg !6
|
|
%mul = mul nsw i32 %2, %sum.0, !dbg !18
|
|
call void @llvm.dbg.label(metadata !16), !dbg !19
|
|
ret i32 %mul, !dbg !6
|
|
}
|
|
|
|
; Function Attrs: nounwind readnone speculatable
|
|
declare void @llvm.dbg.label(metadata)
|
|
|
|
; Function Attrs: nounwind readnone speculatable
|
|
declare void @llvm.dbg.value(metadata, metadata, metadata)
|
|
|
|
!llvm.dbg.cu = !{!0}
|
|
!llvm.module.flags = !{!3, !4, !5}
|
|
|
|
!0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2)
|
|
!1 = !DIFile(filename: "debug-label-opt.c", directory: "./")
|
|
!2 = !{}
|
|
!3 = !{i32 2, !"Dwarf Version", i32 4}
|
|
!4 = !{i32 2, !"Debug Info Version", i32 3}
|
|
!5 = !{i32 1, !"wchar_size", i32 4}
|
|
!6 = !DILocation(line: 1, column: 14, scope: !7)
|
|
!7 = distinct !DISubprogram(name: "foo", scope: !1, file: !1, line: 1, type: !8, isLocal: false, isDefinition: true, scopeLine: 2, flags: DIFlagPrototyped, isOptimized: true, unit: !0, retainedNodes: !12)
|
|
!8 = !DISubroutineType(types: !9)
|
|
!9 = !{!10, !11, !10}
|
|
!10 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
|
|
!11 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !10, size: 64)
|
|
!12 = !{!13, !14, !15, !16}
|
|
!13 = !DILocalVariable(name: "a", arg: 1, scope: !7, file: !1, line: 1, type: !11)
|
|
!14 = !DILocalVariable(name: "n", arg: 2, scope: !7, file: !1, line: 1, type: !10)
|
|
!15 = !DILabel(scope: !7, name: "end_sum", file: !1, line: 10)
|
|
!16 = !DILabel(scope: !7, name: "end", file: !1, line: 13)
|
|
!17 = !DILocation(line: 10, column: 1, scope: !7)
|
|
!18 = !DILocation(line: 11, column: 7, scope: !7)
|
|
!19 = !DILocation(line: 13, column: 1, scope: !7)
|