[clang] [Clang] Add fake use emission to Clang with -fextend-lifetimes (PR #110102)
Jeremy Morse via cfe-commits
cfe-commits at lists.llvm.org
Fri Nov 29 10:04:05 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;
----------------
jmorse wrote:
Hmmmmm. It feels a bit wrong to bake this kind of high level decision this deep into the code. Would it be better to instead have the clang driver decide whether to enable fextend-lifetimes depending on the optimisation mode, then pass the flag to cc1, and not have this kind of check?
This would reduce our testing matrix in the future to separate "cc1 does fextend lifetimes correctly" from "when should fextend-lifetimes be done".
https://github.com/llvm/llvm-project/pull/110102
More information about the cfe-commits
mailing list