diff options
author | Stephen Tozer <stephen.tozer@sony.com> | 2024-08-29 17:53:32 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-08-29 17:53:32 +0100 |
commit | 3d08ade7bd32f0296e0ca3a13640cc95fa89229a (patch) | |
tree | 215a84046ff8a15cfa8e80c475fbdbe7ef2acc05 /llvm/lib/CodeGen/CodeGen.cpp | |
parent | e5e38ddf1b8043324175868831da21e941c00aff (diff) | |
download | llvm-3d08ade7bd32f0296e0ca3a13640cc95fa89229a.zip llvm-3d08ade7bd32f0296e0ca3a13640cc95fa89229a.tar.gz llvm-3d08ade7bd32f0296e0ca3a13640cc95fa89229a.tar.bz2 |
[ExtendLifetimes] Implement llvm.fake.use to extend variable lifetimes (#86149)
This patch is part of a set of patches that add an `-fextend-lifetimes`
flag to clang, which extends the lifetimes of local variables and
parameters for improved debuggability. In addition to that flag, the
patch series adds a pragma to selectively disable `-fextend-lifetimes`,
and an `-fextend-this-ptr` flag which functions as `-fextend-lifetimes`
for this pointers only. All changes and tests in these patches were
written by Wolfgang Pieb (@wolfy1961), while Stephen Tozer (@SLTozer)
has handled review and merging. The extend lifetimes flag is intended to
eventually be set on by `-Og`, as discussed in the RFC
here:
https://discourse.llvm.org/t/rfc-redefine-og-o1-and-add-a-new-level-of-og/72850
This patch implements a new intrinsic instruction in LLVM,
`llvm.fake.use` in IR and `FAKE_USE` in MIR, that takes a single operand
and has no effect other than "using" its operand, to ensure that its
operand remains live until after the fake use. This patch does not emit
fake uses anywhere; the next patch in this sequence causes them to be
emitted from the clang frontend, such that for each variable (or this) a
fake.use operand is inserted at the end of that variable's scope, using
that variable's value. This patch covers everything post-frontend, which
is largely just the basic plumbing for a new intrinsic/instruction,
along with a few steps to preserve the fake uses through optimizations
(such as moving them ahead of a tail call or translating them through
SROA).
Co-authored-by: Stephen Tozer <stephen.tozer@sony.com>
Diffstat (limited to 'llvm/lib/CodeGen/CodeGen.cpp')
-rw-r--r-- | llvm/lib/CodeGen/CodeGen.cpp | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/llvm/lib/CodeGen/CodeGen.cpp b/llvm/lib/CodeGen/CodeGen.cpp index 31fa4c1..1777020 100644 --- a/llvm/lib/CodeGen/CodeGen.cpp +++ b/llvm/lib/CodeGen/CodeGen.cpp @@ -116,6 +116,7 @@ void llvm::initializeCodeGen(PassRegistry &Registry) { initializeRegUsageInfoCollectorPass(Registry); initializeRegUsageInfoPropagationPass(Registry); initializeRegisterCoalescerPass(Registry); + initializeRemoveLoadsIntoFakeUsesPass(Registry); initializeRemoveRedundantDebugValuesPass(Registry); initializeRenameIndependentSubregsPass(Registry); initializeSafeStackLegacyPassPass(Registry); |