[LLVMdev] Safe loads

Andrew Trick atrick at apple.com
Tue Jan 24 19:38:48 PST 2012


On Jan 24, 2012, at 2:00 PM, Roman Leshchinskiy <rl at cse.unsw.edu.au> wrote:
>> 
>> I think that marking the load with metadata would make sense.  Is it safe to load the pointer *anywhere*, or just "ahead of the loop"?  If it is safe to move it anywhere (e.g. because it is a load from constant memory, the optimizer just doesn't know it) then using metadata makes sense.  If it is a region where it is safe, then we'd need to implement something like this:
>> http://nondot.org/sabre/LLVMNotes/MemoryUseMarkers.txt
> 
> For the code that GHC generates, it is safe to load the pointer anywhere in the function that contains the load and those functions don't get inlined. But that's probably too specific to GHC, a general-purpose mechanism would make more sense.
> 
> I looked at llvm.lifetime.start before but it has two problems. Firstly, isDeferenceablePointer doesn't seem to take it into account so marking the memory block in question has no effect on the loads. Secondly, the memory block is quite alive when the function is entered and we definitely don't want to replace those loads with undefs. We'd want to be able to mark memory blocks as "alive here" rather than "alive from now on and dead before" and we'd want isDereferenceablePointer to use this information. Alas, this seems somewhat more difficult to implement for someone who has never done any LLVM hacking before.
> 
> Roman

That's right. Invariance and lifetime are definitely distinct from safety/side effects. The currently proposed memory use markers don't address the later, yet.

-Andy
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20120124/941569b6/attachment.html>


More information about the llvm-dev mailing list