Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[ADCE] Only remove debug intrinsics if non debug instructions are rem…
…oved We now limit ADCE to only remove debug intrinsics if it does something else that would invalidate cached analyses anyway. As we've seen in #58285 throwing away cached analysis info when only debug instructions are removed can lead to different code when debug info is present or not present. Differential Revision: https://reviews.llvm.org/D145051
- Loading branch information
1 parent
5783363
commit 8aa9ab3
Showing
4 changed files
with
95 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py | ||
; RUN: opt -passes=adce -S < %s | FileCheck %s | ||
|
||
; ADCE can remove the dbg.declare in remove_dbg_declare_and_other as it is also | ||
; removing a non-debug instruction. | ||
|
||
define i16 @remove_dbg_declare_and_other() { | ||
; CHECK-LABEL: @remove_dbg_declare_and_other( | ||
; CHECK-NEXT: entry: | ||
; CHECK-NEXT: ret i16 0 | ||
; | ||
entry: | ||
call void @llvm.dbg.declare(metadata ptr undef, metadata !4, metadata !DIExpression()), !dbg !16 | ||
%dead = add i8 0, 0 | ||
ret i16 0 | ||
} | ||
|
||
; In dont_remove_only_dbg_declare we must leave the dbg.declare since we're not | ||
; removing any non-debug instructions. | ||
|
||
define i16 @dont_remove_only_dbg_declare() { | ||
; CHECK-LABEL: @dont_remove_only_dbg_declare( | ||
; CHECK-NEXT: entry: | ||
; CHECK-NEXT: call void @llvm.dbg.declare(metadata ptr undef, metadata [[META4:![0-9]+]], metadata !DIExpression()), !dbg [[DBG16:![0-9]+]] | ||
; CHECK-NEXT: ret i16 0 | ||
; | ||
entry: | ||
call void @llvm.dbg.declare(metadata ptr undef, metadata !4, metadata !DIExpression()), !dbg !16 | ||
ret i16 0 | ||
} | ||
|
||
; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none) | ||
declare void @llvm.dbg.declare(metadata, metadata, metadata) #0 | ||
|
||
attributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) } | ||
|
||
!llvm.dbg.cu = !{} | ||
!llvm.module.flags = !{!0, !1, !2, !3} | ||
|
||
!0 = !{i32 7, !"Dwarf Version", i32 4} | ||
!1 = !{i32 2, !"Debug Info Version", i32 3} | ||
!2 = !{i32 1, !"wchar_size", i32 1} | ||
!3 = !{i32 7, !"frame-pointer", i32 2} | ||
!4 = !DILocalVariable(name: "w", scope: !5, file: !6, line: 18, type: !11) | ||
!5 = distinct !DILexicalBlock(scope: !7, file: !6, line: 18, column: 8) | ||
!6 = !DIFile(filename: "foo2.c", directory: "/llvm") | ||
!7 = distinct !DISubprogram(name: "test1", scope: !6, file: !6, line: 14, type: !8, scopeLine: 14, flags: DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !10) | ||
!8 = !DISubroutineType(types: !9) | ||
!9 = !{} | ||
!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) | ||
!11 = !DIDerivedType(tag: DW_TAG_typedef, name: "uint64_t", file: !12, line: 60, baseType: !13) | ||
!12 = !DIFile(filename: "/include/sys/_stdint.h", directory: "") | ||
!13 = !DIDerivedType(tag: DW_TAG_typedef, name: "__uint64_t", file: !14, line: 108, baseType: !15) | ||
!14 = !DIFile(filename: "/include/machine/_default_types.h", directory: "") | ||
!15 = !DIBasicType(name: "unsigned long long", size: 64, encoding: DW_ATE_unsigned) | ||
!16 = !DILocation(line: 18, column: 8, scope: !5) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters