[cfe-dev] Smart Pointer Lifetime Optimizations
Johannes Doerfert via cfe-dev
cfe-dev at lists.llvm.org
Wed Jun 10 08:11:58 PDT 2020
On 6/8/20 8:13 PM, Richard Smith via cfe-dev wrote
>> You wouldn’t be the first person to be surprised by the result of this sort
>> of analysis, but I’m afraid it’s what we’re working with.
>> Unfortunately, there’s really no way to eliminate this one without either
>> interprocedural information or language changes. trivial_abi eliminates
>> the other one because it changes the convention for passing by value, but
>> pass an “immutably borrowed” value in C++ we have to pass by reference,
>> allows the reference to be escaped and accessed (and even mutated, if the
>> original object wasn’t declared const) as long as those accesses happen
>> before destruction.
> Perhaps we should expose LLVM's nocapture attribute to the source level?
Yes please ;)
There was an RFC (I think) and a prototype patch to expose LLVM-IR
attributes via clang. We can limit the ones allowed if we want.
See https://c.wsmoses.com/presentations/HTO_Presentation.pdf for
another motivation :)
More information about the cfe-dev