[PATCH] D16783: [LICM] Store promotion when memory is thread local

Philip Reames via llvm-commits llvm-commits at lists.llvm.org
Mon Feb 1 12:37:52 PST 2016

reames created this revision.
reames added reviewers: chandlerc, hfinkel, sanjoy, grosser, eli.friedman, majnemer, jfb.
reames added a subscriber: llvm-commits.
Herald added a subscriber: mcrosier.

This patch teaches LICM's implementation of store promotion to exploit the fact that the memory location being accessed might be provable thread local.  The fact it's thread local weakens the requirements for where we can insert stores since no other thread can observe the write.  This allows us perform store promotion even in cases where the store is not guaranteed to execute in the loop.

Two key assumption worth drawing out is that this assumes a) no-capture is strong enough to imply no-escape, and b) standard allocation functions like malloc, calloc, and operator new return values which can be assumed not to have previously escaped.  

In future work, it would be nice to generalize this so that it works without directly seeing the allocation site.  I believe that the nocapture return attribute should be suitable for this purpose, but haven't investigated carefully.  It's also likely that we could support unescaped allocas with similar reasoning, but since SROA and Mem2Reg should destroy those, they're less interesting than they first might seem.  



-------------- next part --------------
A non-text attachment was scrubbed...
Name: D16783.46568.patch
Type: text/x-patch
Size: 11686 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160201/5f9aa268/attachment.bin>

More information about the llvm-commits mailing list