[clang] [Clang] Add fake use emission to Clang with -fextend-lifetimes (PR #110102)
Paul T Robinson via cfe-commits
cfe-commits at lists.llvm.org
Tue Dec 3 07:40:20 PST 2024
================
@@ -1353,6 +1353,19 @@ void CodeGenFunction::EmitLifetimeEnd(llvm::Value *Size, llvm::Value *Addr) {
C->setDoesNotThrow();
}
+void CodeGenFunction::EmitFakeUse(Address Addr) {
+ // We do not emit a fake use if we want to apply optnone to this function,
+ // even if we might not apply it anyway due to minsize or similar attributes.
+ if (!CGM.getCodeGenOpts().DisableO0ImplyOptNone &&
+ CGM.getCodeGenOpts().OptimizationLevel == 0)
+ return;
----------------
pogo59 wrote:
There's no value to enabling `-fextend-lifetimes` at O0, because we only emit stack-home locations at O0, which are valid for the entire function. However, I don't remember whether that decision is a blanket decision based on opt level or per-function based on optnone. If it's based on opt level, then adding fake-uses to an optnone function (at O1 and up) might actually be the right thing to do.
https://github.com/llvm/llvm-project/pull/110102
More information about the cfe-commits
mailing list