123 lines · plain
1# RUN: llc -mtriple=x86_64-unknown-unknown -start-after=peephole-opt -stop-before=detect-dead-lanes -o - %s | FileCheck %s2 3# Test that the optimize LEA pass can remove a redundant LEA even when it is4# also used by a DBG_VALUE. Check that the uses of the replaced LEA are updated5# correctly.6 7--- |8 target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"9 10 %struct.A = type { i32, i32, i32 }11 12 @c = common local_unnamed_addr global ptr null, align 813 @a = common local_unnamed_addr global i32 0, align 414 @d = common local_unnamed_addr global i32 0, align 415 @b = common local_unnamed_addr global i32 0, align 416 17 define i32 @fn1() local_unnamed_addr !dbg !8 {18 %1 = load ptr, ptr @c, align 8, !dbg !1319 %2 = load i32, ptr @a, align 4, !dbg !1320 %3 = sext i32 %2 to i64, !dbg !1321 %4 = getelementptr inbounds %struct.A, ptr %1, i64 %3, !dbg !1322 %5 = ptrtoint ptr %4 to i64, !dbg !1323 %6 = trunc i64 %5 to i32, !dbg !1324 store i32 %6, ptr @d, align 4, !dbg !1325 %7 = getelementptr inbounds %struct.A, ptr %1, i64 %3, i32 2, !dbg !1426 tail call void @llvm.dbg.value(metadata ptr %7, i64 0, metadata !11, metadata !DIExpression()), !dbg !1527 br label %8, !dbg !1628 29 ; <label>:8: ; preds = %8, %030 %9 = load i32, ptr %7, align 4, !dbg !1731 store i32 %9, ptr @d, align 4, !dbg !1732 br label %8, !dbg !1833 }34 35 ; Function Attrs: nounwind readnone36 declare void @llvm.dbg.value(metadata, i64, metadata, metadata) #037 38 attributes #0 = { nounwind readnone }39 40 !llvm.dbg.cu = !{!0}41 !llvm.module.flags = !{!5, !6, !7}42 43 !0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, retainedTypes: !3, globals: !2)44 !1 = !DIFile(filename: "test.c", directory: "")45 !2 = !{}46 !3 = !{!4}47 !4 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)48 !5 = !{i32 2, !"Dwarf Version", i32 4}49 !6 = !{i32 2, !"Debug Info Version", i32 3}50 !7 = !{i32 1, !"PIC Level", i32 2}51 !8 = distinct !DISubprogram(name: "fn1", scope: !1, file: !1, line: 7, type: !9, isLocal: false, isDefinition: true, scopeLine: 7, isOptimized: true, unit: !0, retainedNodes: !10)52 !9 = !DISubroutineType(types: !3)53 !10 = !{!11}54 !11 = !DILocalVariable(name: "e", scope: !8, file: !1, line: 8, type: !12)55 !12 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !4, size: 64)56 !13 = !DILocation(line: 9, scope: !8)57 !14 = !DILocation(line: 10, scope: !8)58 !15 = !DILocation(line: 8, scope: !8)59 !16 = !DILocation(line: 11, scope: !8)60 !17 = !DILocation(line: 13, scope: !8)61 !18 = !DILocation(line: 14, scope: !8)62 63...64---65name: fn166alignment: 1667exposesReturnsTwice: false68legalized: false69regBankSelected: false70selected: false71tracksRegLiveness: true72registers:73 - { id: 0, class: gr64 }74 - { id: 1, class: gr64 }75 - { id: 2, class: gr64_nosp }76 - { id: 3, class: gr64_nosp }77 - { id: 4, class: gr64 }78 - { id: 5, class: gr32 }79 - { id: 6, class: gr32 }80frameInfo:81 isFrameAddressTaken: false82 isReturnAddressTaken: false83 hasStackMap: false84 hasPatchPoint: false85 stackSize: 086 offsetAdjustment: 087 maxAlignment: 088 adjustsStack: false89 hasCalls: false90 maxCallFrameSize: 091 hasOpaqueSPAdjustment: false92 hasVAStart: false93 hasMustTailInVarArgFunc: false94body: |95 bb.0 (%ir-block.0):96 successors: %bb.1(0x80000000)97 98 ; CHECK: %3:gr64_nosp = LEA64r %2, 2, %2, 0, $noreg, debug-location !1399 ; CHECK-NEXT: %4:gr64 = LEA64r %1, 4, %3, 0, $noreg, debug-location !13100 ; CHECK-NOT: %0:gr64 = LEA64r %1, 4, %3, 8, $noreg, debug-location !14101 ; CHECK: DBG_VALUE %4, $noreg, !11, !DIExpression(DW_OP_plus_uconst, 8, DW_OP_stack_value), debug-location !15102 103 %1 = MOV64rm $rip, 1, $noreg, @c, $noreg, debug-location !13 :: (dereferenceable load (s64) from @c)104 %2 = MOVSX64rm32 $rip, 1, $noreg, @a, $noreg, debug-location !13 :: (dereferenceable load (s32) from @a)105 %3 = LEA64r %2, 2, %2, 0, $noreg, debug-location !13106 %4 = LEA64r %1, 4, %3, 0, $noreg, debug-location !13107 %5 = COPY %4.sub_32bit, debug-location !13108 MOV32mr $rip, 1, $noreg, @d, $noreg, killed %5, debug-location !13 :: (store (s32) into @d)109 %0 = LEA64r %1, 4, %3, 8, $noreg, debug-location !14110 DBG_VALUE %0, $noreg, !11, !DIExpression(), debug-location !15111 112 ; CHECK-LABEL: bb.1 (%ir-block.8):113 ; CHECK: %6:gr32 = MOV32rm %4, 1, $noreg, 8, $noreg, debug-location !17 :: (load (s32) from %ir.7)114 115 bb.1 (%ir-block.8):116 successors: %bb.1(0x80000000)117 118 %6 = MOV32rm %0, 1, $noreg, 0, $noreg, debug-location !17 :: (load (s32) from %ir.7)119 MOV32mr $rip, 1, $noreg, @d, $noreg, killed %6, debug-location !17 :: (store (s32) into @d)120 JMP_1 %bb.1, debug-location !18121 122...123