14 Commits

Author SHA1 Message Date
Orlando Cazalet-Hyams
653872f782
[KeyInstr] Fix verifier check (#149043)
The verifier check was in the wrong place, meaning it wasn't actually
checking many instructions.

Fixing that causes a test failure (coro-dwarf-key-instrs.cpp) because
coros turn off the feature but still annotate instructions with the
metadata (which is a supported situation, but the verifier doesn't like
it, and it's hard to teach the verifier to like it).

Fix that by avoiding emitting any key instruction metadata if the
DISubprogram has opted out of key instructions.
2025-07-16 10:43:09 +01:00
Jeremy Morse
c995c50355
[KeyInstr] Add bitcode support (#147260)
Serialise key-instruction fields of DILocations and DISubprograms into
and outof bitcode, add tests. debug-info bitcode sizes grow, but it
balances out given an earlier size optimisation in 51f4e2c.

Co-authored-by: Orlando Cazalet-Hyams <orlando.hyams@sony.com>
2025-07-07 11:57:46 +01:00
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
Orlando Cazalet-Hyams
fb7d114efb
[KeyInstr][LoopUnswitch] Remap cloned instructions' atoms (#133491)
RFC: https://discourse.llvm.org/t/rfc-improving-is-stmt-placement-for-better-interactive-debugging/82668
2025-05-09 15:24:47 +01:00
Orlando Cazalet-Hyams
40ac25e309
[KeyInstr][JumpThreading] Remap atoms after threading (#133487)
RFC: https://discourse.llvm.org/t/rfc-improving-is-stmt-placement-for-better-interactive-debugging/82668
2025-05-09 13:48:23 +01:00
Orlando Cazalet-Hyams
c453da7b7c
[KeyInstr][LoopUnroll] Remap atoms while unrolling (#133489)
RFC: https://discourse.llvm.org/t/rfc-improving-is-stmt-placement-for-better-interactive-debugging/82668
2025-05-09 13:47:16 +01:00
Orlando Cazalet-Hyams
6a1f52150a
[KeyInstr][LoopRotate] Remap atoms of duplicated instructions (#133490)
RFC: https://discourse.llvm.org/t/rfc-improving-is-stmt-placement-for-better-interactive-debugging/82668
2025-05-07 17:10:30 +01:00
Orlando Cazalet-Hyams
960221623f
[KeyInstr][JumpThreading] Remap atoms duping bb with cond br on phi into pred (#133488)
See test for details.
2025-05-07 16:01:53 +01:00
Orlando Cazalet-Hyams
a061998a14
[KeyInstr][JumpThreading] Remap atoms in blocks duplicated for threading (#133486) 2025-05-07 14:54:04 +01:00
Orlando Cazalet-Hyams
5be080edf7
[KeyInstr][Inline] Don't propagate atoms to inlined nodebug instructions (#133485)
RFC: https://discourse.llvm.org/t/rfc-improving-is-stmt-placement-for-better-interactive-debugging/82668
2025-05-07 11:54:57 +01:00
Orlando Cazalet-Hyams
74c3025dd5
[KeyInstr][SimplifyCFG] Remap atoms after duplication for threading (#133484)
Given the same branch condition in `a` and `c` SimplifyCFG converts:

        +> b -+
        |     v
    --> a --> c --> e -->
              |     ^
              +> d -+
into:

        +--> bcd ---+
        |           v
    --> a --> c --> e -->

Remap source atoms on instructions duplicated from `c` into `bcd`.

RFC:
https://discourse.llvm.org/t/rfc-improving-is-stmt-placement-for-better-interactive-debugging/82668
2025-05-07 09:56:30 +01:00
Orlando Cazalet-Hyams
f8de1618cc
[KeyInstr][SimplifyCFG] Remap atoms when folding br to common succ into pred (#133482)
SimplifyCFG folds `d` into preds `b` and `c`.

              +---------------+
              |               |
         +--> b --+           |
         |        v           v
     --> a        d --> e --> f -->
         |        ^           ^
         +--> c --+           |
              |               |
              +---------------+
    
Remap source atoms so that the duplicated instructions are analysed
independently to determine is_stmt positions.

The pull request contains a discussion covering various edge cases here:
https://github.com/llvm/llvm-project/pull/133482/files#r2039519348

The summary of the discussion is that we could avoid remapping when there's a
single pred, but we decided that it's still a trade off, and not worth the
additional complexity right now.

RFC:
https://discourse.llvm.org/t/rfc-improving-is-stmt-placement-for-better-interactive-debugging/82668
2025-05-06 15:03:20 +01:00
Orlando Cazalet-Hyams
73a7a3dc00
[KeyInstr] Inline atom info (#133481)
Source atom groups are identified by an atom group number and inlined-at pair,
so we simply can copy the atom numbers into the caller when inlining.

RFC:
https://discourse.llvm.org/t/rfc-improving-is-stmt-placement-for-better-interactive-debugging/82668
2025-05-06 14:38:41 +01:00
Orlando Cazalet-Hyams
0c7c82af23
[KeyInstr] Add fields to DILocation behind compile time flag (#133477)
Add AtomGroup and AtomRank to DILocation behind compile time flag
EXPERIMENTAL_KEY_INSTRUCTIONS which is controlled by cmake flag
LLVM_EXPERIMENTAL_KEY_INSTRUCTIONS.

Add IR read-write roundtrip test in a directory that is unsupported unless the
CMake flag is enabled.

RFC: https://discourse.llvm.org/t/rfc-improving-is-stmt-placement-for-better-interactive-debugging/82668
2025-05-01 15:40:39 +01:00