brintos

brintos / llvm-project-archived public Read only

0
0
Text · 3.0 KiB · 0c851e7 Raw
70 lines · plain
1; RUN: opt -passes='require<memoryssa>,adce' -o - -S -debug-pass-manager < %s 2>&1 | FileCheck %s2 3; ADCE should remove the dbg.declare in test1, but it should preserve4; MemorySSA since it only removed a debug instruction.5 6; Invalidating MemorySSA when only removing debug instructions may lead7; to different code with/without debug info present.8; In9;  https://github.com/llvm/llvm-project/issues/5828510; we saw how ADCE removed a dbg.declare, invalidated all analyses, and later11; DSE behaved in some way. Without the dbg.declare in the input ADCE kept12; analysis info, and DSE behaved differently.13 14; CHECK: Running analysis: MemorySSAAnalysis on test115; CHECK: Running pass: ADCEPass on test1 (1 instruction)16; CHECK-NOT: Invalidating analysis: MemorySSAAnalysis on test117 18; In test2 ADCE also removes an instruction, but since we remove a non-debug19; instruction as well we invalidate several analyses, including MemorySSA.20 21; CHECK: Running analysis: MemorySSAAnalysis on test222; CHECK: Running pass: ADCEPass on test2 (2 instructions)23; CHECK: Invalidating analysis: MemorySSAAnalysis on test224; CHECK: Running pass: PrintModulePass25 26; CHECK-LABEL: @test1(27; CHECK-NEXT:  entry:28; CHECK-NEXT:    ret i16 029 30; CHECK-LABEL: @test2(31; CHECK-NEXT:  entry:32; CHECK-NEXT:    ret i16 033 34define i16 @test1() {35entry:36  call void @llvm.dbg.declare(metadata ptr poison, metadata !4, metadata !DIExpression()), !dbg !1637  ret i16 038}39 40define i16 @test2() {41entry:42  %dead = add i16 1, 243  ret i16 044}45 46; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)47declare void @llvm.dbg.declare(metadata, metadata, metadata) #048 49attributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }50 51!llvm.dbg.cu = !{}52!llvm.module.flags = !{!0, !1, !2, !3}53 54!0 = !{i32 7, !"Dwarf Version", i32 4}55!1 = !{i32 2, !"Debug Info Version", i32 3}56!2 = !{i32 1, !"wchar_size", i32 1}57!3 = !{i32 7, !"frame-pointer", i32 2}58!4 = !DILocalVariable(name: "w", scope: !5, file: !6, line: 18, type: !11)59!5 = distinct !DILexicalBlock(scope: !7, file: !6, line: 18, column: 8)60!6 = !DIFile(filename: "foo2.c", directory: "/llvm")61!7 = distinct !DISubprogram(name: "test1", scope: !6, file: !6, line: 14, type: !8, scopeLine: 14, flags: DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !10)62!8 = !DISubroutineType(types: !9)63!9 = !{}64!10 = distinct !DICompileUnit(language: DW_LANG_C99, file: !6, producer: "clang version 16.0.0", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, globals: !9, splitDebugInlining: false, nameTableKind: None)65!11 = !DIDerivedType(tag: DW_TAG_typedef, name: "uint64_t", file: !12, line: 60, baseType: !13)66!12 = !DIFile(filename: "/include/sys/_stdint.h", directory: "")67!13 = !DIDerivedType(tag: DW_TAG_typedef, name: "__uint64_t", file: !14, line: 108, baseType: !15)68!14 = !DIFile(filename: "/include/machine/_default_types.h", directory: "")69!15 = !DIBasicType(name: "unsigned long long", size: 64, encoding: DW_ATE_unsigned)70!16 = !DILocation(line: 18, column: 8, scope: !5)