[PATCH] This patch introduces MemorySSA, a virtual SSA form for memory.Details on what it looks like are in MemorySSA.h

James Molloy James.Molloy at arm.com
Wed Feb 25 11:42:44 PST 2015


That makes perfect sense, thanks Daniel.



On 25 Feb 2015, at 19:32, Daniel Berlin <dberlin at dberlin.org<mailto:dberlin at dberlin.org>> wrote:



On Wed, Feb 25, 2015 at 11:31 AM, Daniel Berlin <dberlin at dberlin.org<mailto:dberlin at dberlin.org>> wrote:


On Wed, Feb 25, 2015 at 11:05 AM, James Molloy <james.molloy at arm.com<mailto:james.molloy at arm.com>> wrote:
Hi Daniel,

One inline comment about the design. Sorry for the naiveity.

Cheers,

James


================
Comment at: include/llvm/Transforms/Utils/MemorySSA.h:150
@@ +149,3 @@
+// All defs also have a use
+class MemoryDef : public MemoryUse {
+public:
----------------
I don't understand this: Firstly, why must all defs have a use?

So let me first give the theoretical answer:

MemorySSA is, abstractly about heap versions.
Every store generates a new heap version.
Every use is associated with a give heap version
In order to be able to know what the heap version was prior to a given store, the def is also a use.

It is intended
         ^ not

to perfectly represent the semantics of the actual memory operations, but give a way to have factored use-def chains over memory operations that you can disambiguate without needing to walk back through all instructions in the CFG to find clobbers.


Practically:

Because you need some way to link def-def, or else you have nowhere to walk if the current store is a "false def" for a given load.

IE given

store @a, %c
store @b, %d
load @a

MemorySSA for this will be:

; 1 = MemoryDef(0)
store @a, %c
;2 = MemoryDef(1)
store @b, %d
;MemoryUse(2)
%e = load @a

When you walk from the load at %e, you  get to the store at  2= MemoryDef(1), say "does this really alias my load", get "no", and want to keep going.  You can do this, because there is a def-def chain, so you go from 2 = MemoryDef(1) to 1 = MemoryDef(0), ask the same question, get "yes", and stop.

If def's did not have uses, it would look like this instead:

; 1 = MemoryDef()
store @a, %c
;2 = MemoryDef()
store @b, %d
;MemoryUse(2)
%e = load @a


Now you do the same walk.
You get to the store at 2 = MemoryDef(), query whether it is a real alias, get "no", and you are stuck, because you have no chain that leads back to the next store :)




We can store without loading the resulting value back.

Secondly, you've used inheritance which is an "is-a" relationship. Is there something fundamental I'm missing here?


All memorydefs are in fact, memoryuses as well.



-- IMPORTANT NOTICE: The contents of this email and any attachments are confidential and may also be privileged. If you are not the intended recipient, please notify the sender immediately and do not disclose the contents to any other person, use it for any purpose, or store or copy the information in any medium. Thank you.

ARM Limited, Registered office 110 Fulbourn Road, Cambridge CB1 9NJ, Registered in England & Wales, Company No: 2557590
ARM Holdings plc, Registered office 110 Fulbourn Road, Cambridge CB1 9NJ, Registered in England & Wales, Company No: 2548782
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20150225/06a13de8/attachment.html>


More information about the llvm-commits mailing list