Orlando Cazalet-Hyams 140e1894f2
[KeyInstr] Add DISubprogram::keyInstructions bit (#144107)
Patch 1/4 adding bitcode support.

Store whether or not a function is using Key Instructions in its DISubprogram so
that we don't need to rely on the -mllvm flag -dwarf-use-key-instructions to
determine whether or not to interpret Key Instructions metadata to decide
is_stmt placement at DWARF emission time. This makes bitcode support simple and
enables well defined mixing of non-key-instructions and key-instructions
functions in an LTO context.

This patch adds the bit (using DISubprogram::SubclassData1).

PR 144104 and 144103 use it during DWARF emission.
PR 44102 adds bitcode
support.

See pull request for overview of alternative attempts.
2025-06-30 08:01:55 +01:00

46 lines
1.6 KiB
LLVM

; RUN: opt %s -passes=inline -S -o - | FileCheck %s
;; $ cat test.cpp
;; int g;
;; [[clang::always_inline, gnu::nodebug]] void a() { g = 1; }
;; void b() { a(); }
;;
;; Check the inlined instructions don't inherit the call's atom info.
;; FIXME: Perhaps we want to do actually do that, to preserve existing
;; behaviour? Unclear what's best.
; CHECK: _Z1bv()
; CHECK: store i32 1, ptr @g, align 4, !dbg [[DBG:!.*]]
; CHECK: distinct !DISubprogram(name: "b", {{.*}}keyInstructions: true)
; CHECK: [[DBG]] = !DILocation(line: 3, scope: ![[#]])
@g = hidden global i32 0, align 4
define hidden void @_Z1av() {
entry:
store i32 1, ptr @g, align 4
ret void
}
define hidden void @_Z1bv() !dbg !15 {
entry:
call void @_Z1av(), !dbg !18
ret void, !dbg !19
}
!llvm.dbg.cu = !{!0}
!llvm.module.flags = !{!2, !3}
!llvm.ident = !{!10}
!0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus_17, file: !1, producer: "clang version 19.0.0", isOptimized: true, runtimeVersion: 0, emissionKind: LineTablesOnly, splitDebugInlining: false, nameTableKind: None)
!1 = !DIFile(filename: "test.cpp", directory: "/")
!2 = !{i32 7, !"Dwarf Version", i32 5}
!3 = !{i32 2, !"Debug Info Version", i32 3}
!10 = !{!"clang version 19.0.0"}
!15 = distinct !DISubprogram(name: "b", scope: !1, file: !1, line: 3, type: !16, scopeLine: 3, flags: DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, keyInstructions: true)
!16 = !DISubroutineType(types: !17)
!17 = !{}
!18 = !DILocation(line: 3, scope: !15, atomGroup: 1, atomRank: 1)
!19 = !DILocation(line: 3, scope: !15, atomGroup: 2, atomRank: 1)