[PATCH] D157618: [Clang][ExtendLifetimes][4/4] Add extend_lifetimes pragma to Clang to selectively disable -fextend-lifetimes for functions
Stephen Tozer via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Thu Aug 10 06:50:51 PDT 2023
StephenTozer created this revision.
StephenTozer added reviewers: dblaikie, aprantl, echristo.
StephenTozer added a project: debug-info.
Herald added a reviewer: aaron.ballman.
Herald added a project: All.
StephenTozer requested review of this revision.
Herald added subscribers: cfe-commits, wangpc.
Herald added a project: clang.
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 new function attribute to disable the post-RA scheduler (which is applied by `-fextend-lifetimes`), 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 @wolfgangp, though I will be managing these reviews and addressing any comments raised. Discussion on the approach of this patch series as a whole should be directed to the 3rd patch, D157613 <https://reviews.llvm.org/D157613>, in order to simplify review.
---
This particular patch adds a new pragma, `pragma clang extend_lifetimes disable/enable` that can be used to toggle `-fextend-lifetimes` for subsequent functions:
It may be useful for developers to keep certain functions (e.g. very hot function that do not need debugging) from having their variable lifetimes extended (which will hurt performance). The way to do this is to add `#pragma clang extend_lifetimes disable` prior to those functions, and `#pragma clang extend_lifetimes enable` afterwards. This is helpful during developer builds where the intention is to repeatedly edit-compile-debug, but the developer likely does not want `#pragma clang extend_lifetimes enable` to be extending variable lifetimes during Release builds. Therefore these pragmas will only have an effect when `-fextend-lifetimes` is passed.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D157618
Files:
clang/include/clang/Basic/AttrDocs.td
clang/include/clang/Basic/DiagnosticParseKinds.td
clang/include/clang/Parse/Parser.h
clang/include/clang/Sema/Sema.h
clang/lib/CodeGen/CGDecl.cpp
clang/lib/Parse/ParsePragma.cpp
clang/lib/Sema/SemaAttr.cpp
clang/lib/Sema/SemaDecl.cpp
clang/lib/Sema/SemaLambda.cpp
clang/test/CodeGen/pragma-extend-lifetimes.cpp
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D157618.549020.patch
Type: text/x-patch
Size: 15023 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20230810/758faa35/attachment.bin>
More information about the cfe-commits
mailing list