[PATCH] Optionally extend alloca lifetimes to allow for callslot optimization to happen

Björn Steinbrink bsteinbr at gmail.com
Wed Mar 4 02:18:11 PST 2015


================
Comment at: lib/Transforms/Scalar/MemCpyOptimizer.cpp:894
@@ +893,3 @@
+
+  // If the destination just started its lifetime, pretend that the lifetime
+  // start isn't present, try the callslot optimization and if it succeeds,
----------------
reames wrote:
> I'm not clear I understand the problem here.  Is the issue that MD->getDependency is returning the lifetime_start as the dependency but MD->getPointerDependency(Src) is not?  
> 
> Also, would it be *correct* to always use the source pointer dependency here?  Or do you need to consider both source and dest dependencies when considering the callSlotOpt?  Depending on the implementation of the callSlotOpt, I could see that going either way.
Yes, MD->getDependency returns the lifetime_start as the dependency.

It would be incorrect to always use the source pointer dependency here, because we would then apply the call slot optimization to cases like this:

```
memset(%src, 0, 1000)
memset(%dst, 1, 1000)
foo(dst)
memcpy(%dst, %src, 1000)
foo(dst)
```

transforming it to

```
memset(%dst, 0, 1000)
memset(%dst, 1, 1000)
foo(dst)
foo(dst)
```

Unfortunately the same is true for this patch when %dst has multiple lifetime ranges like this:

```
memset(%src, 0, 1000)
lifetime_start(1000, %dst)
memset(%dst, 1, 1000)
foo(dst)
lifetime_end(1000, %dst)
lifetime_start(1000, %dst)
memcpy(%dst, %src, 1000)
foo(dst)
lifetime_end(1000, %dst)
```

I'll have to rethink this.

http://reviews.llvm.org/D7984

EMAIL PREFERENCES
  http://reviews.llvm.org/settings/panel/emailpreferences/






More information about the llvm-commits mailing list