[clang] [Clang] Add fake use emission to Clang with -fextend-lifetimes (PR #110102)
Stephen Tozer via cfe-commits
cfe-commits at lists.llvm.org
Fri Nov 29 10:14:44 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;
----------------
SLTozer wrote:
Yes - that's how it originally worked, and the choice being moved to here is an accidental hangover from some earlier attempts at modifications I made; specifically I tried to make it so that fake uses would only be applied if the specific function did not have `optnone`, but the decision-making that applies `optnone` to functions happens after we finalize fake uses. I'm currently considering whether it's a good idea to just enable `-fextend-lifetimes` at O0, in which case this behaviour can be removed outright, otherwise it could be moved back to the driver as you've suggested.
https://github.com/llvm/llvm-project/pull/110102
More information about the cfe-commits
mailing list