117 lines · plain
1--- | 2 ; RUN: llc -run-pass=early-machinelicm -o - %s | FileCheck %s3 ; RUN: llc -passes=early-machinelicm -o - %s | FileCheck %s4 ; Line numbers should not be retained when loop invariant instructions are hoisted.5 ; Doing so causes poor stepping bevavior.6 ;7 ; Created from:8 ; int x;9 ; void Process(const unsigned int *p)10 ; {11 ; while (1)12 ; x = *p++;13 ; }14 ;15 ; with clang -emit-llvm -S -O2 -g -o t.ll t.c16 ; llc -relocation-model=pic -stop-after=machine-combine -O2 t.ll -o t.mir17 ;18 ; We check that when the machine loop invariant pass hoists instructions19 ; out of a loop the debug information is not retained.20 ;21 ; CHECK-LABEL: bb.0.entry:22 ; CHECK: MOV64rm $rip, 1, $noreg, target-flags(x86-gotpcrel) @x, $noreg :: (load (s64) from got)23 ; CHECK-LABEL: bb.1.while.body:24 ;25 ; ModuleID = 'tx.ll'26 source_filename = "t.c"27 target triple = "x86_64-unknown-linux-gnu"28 29 @x = common local_unnamed_addr global i32 0, align 4, !dbg !030 31 ; Function Attrs: noreturn nounwind uwtable32 define void @Process(ptr nocapture readonly %p) local_unnamed_addr !dbg !9 {33 entry:34 tail call void @llvm.dbg.value(metadata ptr %p, i64 0, metadata !16, metadata !17), !dbg !1835 br label %while.body, !dbg !1936 37 while.body: ; preds = %while.body, %entry38 %p.addr.0 = phi ptr [ %p, %entry ], [ %incdec.ptr, %while.body ]39 tail call void @llvm.dbg.value(metadata ptr %p.addr.0, i64 0, metadata !16, metadata !17), !dbg !1840 %incdec.ptr = getelementptr inbounds i32, ptr %p.addr.0, i64 1, !dbg !2041 tail call void @llvm.dbg.value(metadata ptr %incdec.ptr, i64 0, metadata !16, metadata !17), !dbg !1842 %0 = load i32, ptr %p.addr.0, align 4, !dbg !21, !tbaa !2243 store i32 %0, ptr @x, align 4, !dbg !26, !tbaa !2244 br label %while.body, !dbg !27, !llvm.loop !2945 }46 47 ; Function Attrs: nounwind readnone48 declare void @llvm.dbg.value(metadata, i64, metadata, metadata)49 50 !llvm.dbg.cu = !{!1}51 !llvm.module.flags = !{!6, !7}52 !llvm.ident = !{!8}53 54 !0 = !DIGlobalVariableExpression(var: !DIGlobalVariable(name: "x", scope: !1, file: !2, line: 1, type: !5, isLocal: false, isDefinition: true), expr: !DIExpression())55 !1 = distinct !DICompileUnit(language: DW_LANG_C99, file: !2, producer: "clang version 4.0.0 ", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !3, globals: !4)56 !2 = !DIFile(filename: "t.c", directory: "/home/test")57 !3 = !{}58 !4 = !{!0}59 !5 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)60 !6 = !{i32 2, !"Dwarf Version", i32 4}61 !7 = !{i32 2, !"Debug Info Version", i32 3}62 !8 = !{!"clang version 4.0.0 "}63 !9 = distinct !DISubprogram(name: "Process", scope: !2, file: !2, line: 2, type: !10, isLocal: false, isDefinition: true, scopeLine: 3, flags: DIFlagPrototyped, isOptimized: true, unit: !1, retainedNodes: !15)64 !10 = !DISubroutineType(types: !11)65 !11 = !{null, !12}66 !12 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !13, size: 64)67 !13 = !DIDerivedType(tag: DW_TAG_const_type, baseType: !14)68 !14 = !DIBasicType(name: "unsigned int", size: 32, encoding: DW_ATE_unsigned)69 !15 = !{!16}70 !16 = !DILocalVariable(name: "p", arg: 1, scope: !9, file: !2, line: 2, type: !12)71 !17 = !DIExpression()72 !18 = !DILocation(line: 2, column: 34, scope: !9)73 !19 = !DILocation(line: 4, column: 3, scope: !9)74 !20 = !DILocation(line: 5, column: 11, scope: !9)75 !21 = !DILocation(line: 5, column: 9, scope: !9)76 !22 = !{!23, !23, i64 0}77 !23 = !{!"int", !24, i64 0}78 !24 = !{!"omnipotent char", !25, i64 0}79 !25 = !{!"C++"}80 !26 = !DILocation(line: 5, column: 7, scope: !9)81 !27 = !DILocation(line: 4, column: 3, scope: !28)82 !28 = !DILexicalBlockFile(scope: !9, file: !2, discriminator: 1)83 !29 = distinct !{!29, !19, !20}84 85...86---87name: Process88tracksRegLiveness: true89registers:90 - { id: 0, class: gr64 }91 - { id: 1, class: gr64 }92 - { id: 2, class: gr64 }93 - { id: 3, class: gr32 }94 - { id: 4, class: gr64 }95body: |96 bb.0.entry:97 successors: %bb.1.while.body(0x80000000)98 liveins: $rdi99 100 DBG_VALUE $rdi, _, !16, !17, debug-location !18101 %2 = COPY $rdi102 DBG_VALUE %2, _, !16, !17, debug-location !18103 104 bb.1.while.body:105 successors: %bb.1.while.body(0x80000000)106 107 %0 = PHI %2, %bb.0.entry, %1, %bb.1.while.body108 DBG_VALUE %0, _, !16, !17, debug-location !18109 %1 = ADD64ri8 %0, 4, implicit-def dead $eflags, debug-location !20110 DBG_VALUE %1, _, !16, !17, debug-location !18111 %3 = MOV32rm %0, 1, _, 0, _, debug-location !21 :: (load (s32) from %ir.p.addr.0, !tbaa !22)112 %4 = MOV64rm $rip, 1, _, target-flags(x86-gotpcrel) @x, _, debug-location !26 :: (load (s64) from got)113 MOV32mr killed %4, 1, _, 0, _, killed %3, debug-location !26 :: (store (s32) into @x, !tbaa !22)114 JMP_1 %bb.1.while.body, debug-location !27115 116...117