532324 Commits

Author SHA1 Message Date
Orlando Cazalet-Hyams
eeee08d6d9 [KeyInstr][Clang] Switch stmt atom
This patch is part of a stack that teaches Clang to generate Key Instructions
metadata for C and C++.

The Key Instructions project is introduced, including a "quick summary" section
at the top which adds context for this PR, here:
https://discourse.llvm.org/t/rfc-improving-is-stmt-placement-for-better-interactive-debugging/82668

The feature is only functional in LLVM if LLVM is built with CMake flag
LLVM_EXPERIMENTAL_KEY_INSTRUCTIONs. Eventually that flag will be removed.

The Clang-side work is demoed here:
https://github.com/llvm/llvm-project/pull/130943
2025-04-07 14:17:34 +01:00
Orlando Cazalet-Hyams
98ea64f7a1 [KeyInstr][Clang] If stmt atom
This patch is part of a stack that teaches Clang to generate Key Instructions
metadata for C and C++.

The Key Instructions project is introduced, including a "quick summary" section
at the top which adds context for this PR, here:
https://discourse.llvm.org/t/rfc-improving-is-stmt-placement-for-better-interactive-debugging/82668

The feature is only functional in LLVM if LLVM is built with CMake flag
LLVM_EXPERIMENTAL_KEY_INSTRUCTIONs. Eventually that flag will be removed.

The Clang-side work is demoed here:
https://github.com/llvm/llvm-project/pull/130943
2025-04-07 14:17:34 +01:00
Orlando Cazalet-Hyams
638b319d13 [KeyInstr][Clang] Catch variable init atom
This patch is part of a stack that teaches Clang to generate Key Instructions
metadata for C and C++.

The Key Instructions project is introduced, including a "quick summary" section
at the top which adds context for this PR, here:
https://discourse.llvm.org/t/rfc-improving-is-stmt-placement-for-better-interactive-debugging/82668

The feature is only functional in LLVM if LLVM is built with CMake flag
LLVM_EXPERIMENTAL_KEY_INSTRUCTIONs. Eventually that flag will be removed.

The Clang-side work is demoed here:
https://github.com/llvm/llvm-project/pull/130943
2025-04-07 14:17:34 +01:00
Orlando Cazalet-Hyams
c25359bdeb [KeyInstr][Clang] Member initalization atom
This patch is part of a stack that teaches Clang to generate Key Instructions
metadata for C and C++.

The Key Instructions project is introduced, including a "quick summary" section
at the top which adds context for this PR, here:
https://discourse.llvm.org/t/rfc-improving-is-stmt-placement-for-better-interactive-debugging/82668

The feature is only functional in LLVM if LLVM is built with CMake flag
LLVM_EXPERIMENTAL_KEY_INSTRUCTIONs. Eventually that flag will be removed.

The Clang-side work is demoed here:
https://github.com/llvm/llvm-project/pull/130943
2025-04-07 14:17:34 +01:00
Orlando Cazalet-Hyams
77f91f53a7 [KeyInstr][Clang] Agg copy atom 2025-04-07 14:17:33 +01:00
Orlando Cazalet-Hyams
c1ec75f22a [KeyInstr][Clang] Aggregate init + copy
This patch is part of a stack that teaches Clang to generate Key Instructions
metadata for C and C++.

The Key Instructions project is introduced, including a "quick summary" section
at the top which adds context for this PR, here:
https://discourse.llvm.org/t/rfc-improving-is-stmt-placement-for-better-interactive-debugging/82668

The feature is only functional in LLVM if LLVM is built with CMake flag
LLVM_EXPERIMENTAL_KEY_INSTRUCTIONs. Eventually that flag will be removed.

The Clang-side work is demoed here:
https://github.com/llvm/llvm-project/pull/130943
2025-04-07 14:17:33 +01:00
Orlando Cazalet-Hyams
8ce070ebdd [KeyInstr] Complex assignment atoms
This patch is part of a stack that teaches Clang to generate Key Instructions
metadata for C and C++.

The Key Instructions project is introduced, including a "quick summary" section
at the top which adds context for this PR, here:
https://discourse.llvm.org/t/rfc-improving-is-stmt-placement-for-better-interactive-debugging/82668

The feature is only functional in LLVM if LLVM is built with CMake flag
LLVM_EXPERIMENTAL_KEY_INSTRUCTIONs. Eventually that flag will be removed.

The Clang-side work is demoed here:
https://github.com/llvm/llvm-project/pull/130943
2025-04-07 14:17:33 +01:00
Orlando Cazalet-Hyams
678876993d Rename test & run C & C++ 2025-04-07 14:17:33 +01:00
Orlando Cazalet-Hyams
800fde97f2 Pre/Post Inc/Dec 2025-04-07 14:17:32 +01:00
Orlando Cazalet-Hyams
e92a5d1b0f Compound assign 2025-04-07 14:17:32 +01:00
Orlando Cazalet-Hyams
b6f42ab8be [KeyInstr][Clang] Multiple assignment (x = y = z) 2025-04-07 14:17:32 +01:00
Orlando Cazalet-Hyams
cdf3eef4a2 [KeyInstr][Clang] Assignment atom group
This patch is part of a stack that teaches Clang to generate Key Instructions
metadata for C and C++.

The Key Instructions project is introduced, including a "quick summary" section
at the top which adds context for this PR, here:
https://discourse.llvm.org/t/rfc-improving-is-stmt-placement-for-better-interactive-debugging/82668

The feature is only functional in LLVM if LLVM is built with CMake flag
LLVM_EXPERIMENTAL_KEY_INSTRUCTIONs. Eventually that flag will be removed.

The Clang-side work is demoed here:
https://github.com/llvm/llvm-project/pull/130943
2025-04-07 14:17:31 +01:00
Orlando Cazalet-Hyams
a92afbf589 [KeyInstr][Clang] Static variable init atom
This patch is part of a stack that teaches Clang to generate Key Instructions
metadata for C and C++.

The Key Instructions project is introduced, including a "quick summary" section
at the top which adds context for this PR, here:
https://discourse.llvm.org/t/rfc-improving-is-stmt-placement-for-better-interactive-debugging/82668

The feature is only functional in LLVM if LLVM is built with CMake flag
LLVM_EXPERIMENTAL_KEY_INSTRUCTIONs. Eventually that flag will be removed.

The Clang-side work is demoed here:
https://github.com/llvm/llvm-project/pull/130943
2025-04-07 14:17:31 +01:00
Orlando Cazalet-Hyams
eef73d31b6 [KeyInstr][Clang] Init pattern atom 2025-04-07 14:17:31 +01:00
Orlando Cazalet-Hyams
3eae9188c3 [KeyInstr] init-agg pattern 2025-04-07 14:17:31 +01:00
Orlando Cazalet-Hyams
1f1f1d5d88 shouldUseBZeroPlusStoresToInitialize 2025-04-07 14:17:30 +01:00
Orlando Cazalet-Hyams
06b9688ecb [KeyInstr][Clang] Agg init atom
This patch is part of a stack that teaches Clang to generate Key Instructions
metadata for C and C++.

The Key Instructions project is introduced, including a "quick summary" section
at the top which adds context for this PR, here:
https://discourse.llvm.org/t/rfc-improving-is-stmt-placement-for-better-interactive-debugging/82668

The feature is only functional in LLVM if LLVM is built with CMake flag
LLVM_EXPERIMENTAL_KEY_INSTRUCTIONs. Eventually that flag will be removed.

The Clang-side work is demoed here:
https://github.com/llvm/llvm-project/pull/130943
2025-04-07 14:17:30 +01:00
Orlando Cazalet-Hyams
a644c795b1 [Clang][NFC] Move some static functions into CodeGenFunction
The next patch in the stack needs to access CGF in these functions. 2
CGF fields are passed to these functions already; at this point it
felt natural to promote them to CGF methods.
2025-04-07 14:17:30 +01:00
Orlando Cazalet-Hyams
29d5428307 [KeyInstr][Clang] Scalar init atom
This patch is part of a stack that teaches Clang to generate Key Instructions
metadata for C and C++.

The Key Instructions project is introduced, including a "quick summary" section
at the top which adds context for this PR, here:
https://discourse.llvm.org/t/rfc-improving-is-stmt-placement-for-better-interactive-debugging/82668

The feature is only functional in LLVM if LLVM is built with CMake flag
LLVM_EXPERIMENTAL_KEY_INSTRUCTIONs. Eventually that flag will be removed.

The Clang-side work is demoed here:
https://github.com/llvm/llvm-project/pull/130943
2025-04-07 14:17:30 +01:00
Orlando Cazalet-Hyams
856f99ea6b [KeyInstr][Clang] Add ApplyAtomGroup
This is a scoped helper similar to ApplyDebugLocation that creates a new source
atom group which instructions can be added to.

A source atom is a source construct that is "interesting" for debug stepping
purposes. We use an atom group number to track the instruction(s) that implement
the functionality for the atom, plus backup instructions/source locations.

---

This patch is part of a stack that teaches Clang to generate Key Instructions
metadata for C and C++.

The Key Instructions project is introduced, including a "quick summary" section
at the top which adds context for this PR, here:
https://discourse.llvm.org/t/rfc-improving-is-stmt-placement-for-better-interactive-debugging/82668

The feature is only functional in LLVM if LLVM is built with CMake flag
LLVM_EXPERIMENTAL_KEY_INSTRUCTIONs. Eventually that flag will be removed.

The Clang-side work is demoed here:
https://github.com/llvm/llvm-project/pull/130943
2025-04-07 14:17:29 +01:00
Orlando Cazalet-Hyams
7132dd30a1 [KeyInstr][Clang] Add Clang option -g[no-]key-instructions
This needs to be driver level to pass an -mllvm flag to LLVM.

Keep the flag help-hidden as the feature is under development.

---

This patch is part of a stack that teaches Clang to generate Key Instructions
metadata for C and C++.

The Key Instructions project is introduced, including a "quick summary" section
at the top which adds context for this PR, here:
https://discourse.llvm.org/t/rfc-improving-is-stmt-placement-for-better-interactive-debugging/82668

The feature is only functional in LLVM if LLVM is built with CMake flag
LLVM_EXPERIMENTAL_KEY_INSTRUCTIONs. Eventually that flag will be removed.

The Clang-side work is demoed here:
https://github.com/llvm/llvm-project/pull/130943
2025-04-07 14:17:29 +01:00
Orlando Cazalet-Hyams
0b206ae056 [KeyInstr][DwarfDebug] Add is_stmt emission support
Interpret Key Instructions metadata to determine is_stmt placement.

The lowest rank (highest precedent) instructions in each {InlinedAt, atomGroup}
set are candidates for is_stmt. Only the last instruction in each set in a given
block gets is_stmt. Calls always get is_stmt.
2025-03-28 17:07:05 +00:00
Orlando Cazalet-Hyams
b49eb510a9 [KeyInstr] Add MIR parser support 2025-03-28 17:07:05 +00:00
Orlando Cazalet-Hyams
7926adb4d3 [KeyInstr] Remap cloned PHIs in BreakCriticalEdges 2025-03-28 17:07:05 +00:00
Orlando Cazalet-Hyams
4e4a75dd53 Propagate DebugLocs on phis in BreakCriticalEdges 2025-03-28 17:07:05 +00:00
Orlando Cazalet-Hyams
1f03a5db32 [KeyInstr][LoopUnswitch] Remap cloned instructions' atoms 2025-03-28 17:07:04 +00:00
Orlando Cazalet-Hyams
20a853373f [KeyInstr][LoopRotate] Remap atoms of duplicated instructions 2025-03-28 17:07:04 +00:00
Orlando Cazalet-Hyams
fc36dec27c [KeyInstr][LoopUnroll] Remap atoms while unrolling 2025-03-28 17:07:04 +00:00
Orlando Cazalet-Hyams
6488f4bca6 [KeyInstr][JumpThreading] Remap atoms duping bb with cond br on phi into pred
See test for details.
2025-03-28 17:07:04 +00:00
Orlando Cazalet-Hyams
272f806606 [KeyInstr][JumpThreading] Remap atoms after threading 2025-03-28 17:07:04 +00:00
Orlando Cazalet-Hyams
3cc84e5c3d [KeyInstr][JumpThreading] Remap atoms in blocks duplicated for threading 2025-03-28 17:07:04 +00:00
Orlando Cazalet-Hyams
637b5b4ae3 [KeyInstr][Inline] Don't propagate atoms to inlined nodebug instructions 2025-03-28 17:07:04 +00:00
Orlando Cazalet-Hyams
e2d5b6ee48 [KeyInstr][SimplifyCFG] Remap atoms after duplication for threading
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`.
2025-03-28 17:07:04 +00:00
Orlando Cazalet-Hyams
b848c42133 [KeyInstr][debugify] Add --debugify-atoms to add key instructions metadata 2025-03-28 17:07:03 +00:00
Orlando Cazalet-Hyams
eeb24e30bb [KeyInstr][SimplifyCFG] Remap atoms when folding br to common succ into pred
SimplifyCFG folds `b` into `a`.

            +-----------+
            |           v
  --> a --> b --> c --> d -->
      |                 ^
      +-----------------+

Remap source atoms in `b` so that the duplicated instructions are analysed
independently to determine is_stmt positions. This is necessary as the
contents of `b` may be folded into multiple preds in this way.

Add multi-pred test.
2025-03-28 17:07:03 +00:00
Orlando Cazalet-Hyams
a6f7a923dd [KeyInstr] Inline atom info
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.
2025-03-28 17:07:03 +00:00
Orlando Cazalet-Hyams
0335154ef8 [KeyInstr] Merge atoms in DILocation::getMergedLocation
NFC for builds with LLVM_EXPERIMENTAL_KEY_INSTRUCTIONS=OFF (default).

In an ideal world we would be able to track that the merged location is used in
multiple source atoms. We can't do this though, so instead we arbitrarily but
deterministically pick one.

In cases where the InlinedAt field is unchanged we keep the atom with the
lowest non-zero rank (highest precedence). If the ranks are equal we choose
the smaller non-zero group number (arbitrary choice).

In cases where the InlinedAt field is adjusted we generate a new atom group.
Keeping the group wouldn't make sense (a source atom is identified by the
group number and InlinedAt pair) but discarding the atom info could result
in missed is_stmts.

Add unittest in MetadataTest.cpp.
2025-03-28 17:07:03 +00:00
Orlando Cazalet-Hyams
07f9c1f2f8 [NFC][KeyInstr] Add Atom Group (re)mapping
Add:
   mapAtomInstance - map the atom group number to a new group.
   RemapSourceAtom - apply the mapped atom group number to this instruction.

Modify:
  CloneBasicBlock - Call mapAtomInstance on cloned instruction's DebugLocs
                    if MapAtoms is true (default). Setting to false could
		    lead to a degraded debugging experience. See code comment.

Optimisations like loop unroll that duplicate instructions need to remap source
atom groups so that each duplicated source construct instance is considered
distinct when determining is_stmt locations.

This commit adds the remapping functionality and a unittest.
2025-03-28 17:07:03 +00:00
Orlando Cazalet-Hyams
d12e993d5e [KeyInstr] Add Atom Group waterline to LLVMContext
The waterline is managed through DILocation creation,
LLVMContext::incNextAtomGroup, and LLVMContext::updateAtomGroupWaterline.

Add unittest.
2025-03-28 17:07:03 +00:00
Orlando Cazalet-Hyams
a124bd2afc [KeyInstr] Add fields to DILocation behind compile time flag
The definition EXPERIMENTAL_KEY_INSTRUCTIONS 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.
2025-03-28 17:07:03 +00:00
Matt Arsenault
133c1afa8e
llvm-reduce: Filter function based on uses before removing arguments (#133412)
Invokes and others are not handled, so this was leaving broken callsites
behind for anything other than CallInst
2025-03-29 00:01:14 +07:00
Matt Arsenault
44e3735ac1
llvm-reduce: Preserve original callsite calling conv when removing arguments (#133411)
In undefined mismatch cases, this was fixing the callsite to use the calling
convention of the new function. Preserve the original wrong callsite's calling
convention.
2025-03-28 23:51:09 +07:00
LU-JOHN
827f2ad643
AMDGPU: Convert vector 64-bit shl to 32-bit if shift amt >= 32 (#132964)
Convert vector 64-bit shl to 32-bit if shift amt is known to be >= 32.

---------

Signed-off-by: John Lu <John.Lu@amd.com>
2025-03-28 23:46:35 +07:00
Matt Arsenault
6b1acdb818
llvm-reduce: Fix losing operand bundles when removing arguments (#133410) 2025-03-28 23:41:47 +07:00
Jan Svoboda
277ab85d1c [clang] Make PreprocessorOptions reference const 2025-03-28 09:34:19 -07:00
Matt Arsenault
115a77df9d
llvm-reduce: Fix losing metadata when removing arguments (#133409) 2025-03-28 23:28:03 +07:00
Matt Arsenault
688df34634
llvm-reduce: Fix losing fast math flags when removing arguments (#133408) 2025-03-28 23:24:49 +07:00
Matt Arsenault
1b86867ab3
llvm-reduce: Fix losing callsite attributes when removing arguments (#133407)
The attribute APIs make this cumbersome. There seem to be missing
overloads using AttrBuilder for the function attrs. Plus there doesn't
seem to be a direct way to set the function attrs on the call.
2025-03-28 23:20:56 +07:00
Jonas Devlieghere
ea8573aca5
[lldb] Add statusline to the release notes (#133281)
Add a release note for the LLDB statusline: #121860
2025-03-28 09:16:55 -07:00
Joseph Huber
4abe47c6fc
[libc] Enable 'mktime' for the GPU (#133437)
Summary:
This is a dependency on `strftime` which we provide, so we should have
this.
2025-03-28 11:14:51 -05:00