[PATCH] Emit lifetime.start / lifetime.end markers for unnamed temporary objects

Reid Kleckner rnk at google.com
Thu Jul 17 15:12:00 PDT 2014


Looks good with a small change.  I'm surprised we previously only did this
for named variables.

+namespace {
+/// A cleanup to call @llvm.lifetime.end.
+class CallLifetimeEndForUnnamed : public EHScopeStack::Cleanup {
+  llvm::Value *Addr;
+  llvm::Value *Size;
+
+public:
+  CallLifetimeEndForUnnamed(llvm::Value *addr, llvm::Value *size)
+      : Addr(addr), Size(size) {}
+
+  void Emit(CodeGenFunction &CGF, Flags flags) override {
+    CGF.EmitLifetimeEnd(Size, Addr);
+  }
+};
+}

Can we avoid this duplication by adding and using
CGF::pushLifetimeEndCleanup?


On Thu, Jul 17, 2014 at 2:14 PM, Arnaud A. de Grandmaison <
arnaud.degrandmaison at arm.com> wrote:

> This will improve stack slot reuse in the LLVM optimizers, especially with
> C++ where it is so easy to have lots of those unnamed temporaries, with
> small live ranges.
>
>
>
> The lifetime markers are only inserted if the temporaries are big enough,
> using the same value than for named objects (32 bytes).  In a second step,
> I plan to play with this value to see where we stand with respect to
> performances & compile time.
>
>
>
> Could someone familiar with CodeGen have a look at this patch ?
>
>
>
> Cheers,
>
> --
>
> Arnaud A. de Grandmaison
>
>
>
> _______________________________________________
> cfe-commits mailing list
> cfe-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20140717/e13b3d80/attachment.html>


More information about the cfe-commits mailing list