diff options
author | Wolfgang Pieb <wolfgang.pieb@sony.com> | 2024-09-25 16:55:39 +0100 |
---|---|---|
committer | Stephen Tozer <Stephen.Tozer@sony.com> | 2025-01-28 12:30:31 +0000 |
commit | 4424c44c8c4ec8e071f5c5999fba216d36fb92c9 (patch) | |
tree | bf43c91b05431d770e363a25875a2da33b9791b4 /clang/lib/CodeGen/CodeGenModule.h | |
parent | 500a1834d92d701fea914ab5de10d82d6c90dbd9 (diff) | |
download | llvm-4424c44c8c4ec8e071f5c5999fba216d36fb92c9.zip llvm-4424c44c8c4ec8e071f5c5999fba216d36fb92c9.tar.gz llvm-4424c44c8c4ec8e071f5c5999fba216d36fb92c9.tar.bz2 |
[Clang] Add fake use emission to Clang with -fextend-lifetimes (#110102)
Following the previous patch which adds the "extend lifetimes" flag
without (almost) any functionality, this patch adds the real feature by
allowing Clang to emit fake uses. These are emitted as a new form of cleanup,
set for variable addresses, which just emits a fake use intrinsic when the
variable falls out of scope. The code for achieving this is simple, with most
of the logic centered on determining whether to emit a fake use for a given
address, and on ensuring that fake uses are ignored in a few cases.
Co-authored-by: Stephen Tozer <stephen.tozer@sony.com>
Diffstat (limited to 'clang/lib/CodeGen/CodeGenModule.h')
-rw-r--r-- | clang/lib/CodeGen/CodeGenModule.h | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/clang/lib/CodeGen/CodeGenModule.h b/clang/lib/CodeGen/CodeGenModule.h index 1aa5d48..0956296 100644 --- a/clang/lib/CodeGen/CodeGenModule.h +++ b/clang/lib/CodeGen/CodeGenModule.h @@ -647,6 +647,9 @@ private: /// void @llvm.lifetime.end(i64 %size, i8* nocapture <ptr>) llvm::Function *LifetimeEndFn = nullptr; + /// void @llvm.fake.use(...) + llvm::Function *FakeUseFn = nullptr; + std::unique_ptr<SanitizerMetadata> SanitizerMD; llvm::MapVector<const Decl *, bool> DeferredEmptyCoverageMappingDecls; @@ -1326,6 +1329,7 @@ public: llvm::Function *getLLVMLifetimeStartFn(); llvm::Function *getLLVMLifetimeEndFn(); + llvm::Function *getLLVMFakeUseFn(); // Make sure that this type is translated. void UpdateCompletedType(const TagDecl *TD); |