<html>
<head>
<meta content="text/html; charset=ISO-8859-1"
http-equiv="Content-Type">
</head>
<body bgcolor="#FFFFFF" text="#000000">
<div class="moz-cite-prefix">On 3/11/13 6:32 AM, Mikael Lepistö
wrote:<br>
</div>
<blockquote
cite="mid:CAP5fpJHFuUr2HQMBQjXxk=Q8TqWrxr4fqDrWJaxGYBFby6dKkw@mail.gmail.com"
type="cite">
<meta http-equiv="Content-Type" content="text/html;
charset=ISO-8859-1">
<div dir="ltr">Hi,
<div><br>
</div>
<div style="">I'm doing llvm pass for OpenCL code which does
some memory checking to verify that code does not access
memory outside of the programs own statically allocated areas.</div>
</div>
</blockquote>
<br>
If you're looking to see if your program only accesses in-bounds
memory, SAFECode and Address Sanitizer may be able to do this for
you already. If you use SAFECode, I'd recommend hacking it to use
complete checks.<br>
<br>
If you're wanting to know that a piece of code accesses only certain
types of memory (e.g., globals and stack but not heap), then you
either need to write something yourself or modify the aforementioned
tools.<br>
<br>
<blockquote
cite="mid:CAP5fpJHFuUr2HQMBQjXxk=Q8TqWrxr4fqDrWJaxGYBFby6dKkw@mail.gmail.com"
type="cite">
<div dir="ltr">
<div style="">
<br>
</div>
<div style="">To make dynamic check generation easier, I would
like to collect all allocas and global variable definitions
and create one big memory structure (for each global, local
and private) containing all the allocated memory
as contiguous form to be able to just to add checks to
loads/sotres that address is inside that memory structure.</div>
</div>
</blockquote>
<br>
No, I don't believe such a transform exists, but it should be pretty
easy to write. Just be forewarned that you can't safely promote
allocas to global variables when they're used in loops or in
functions that can be called recursively. You must either check for
these conditions or assume a priori that you code does not do these
things.<br>
<br>
-- John T.<br>
<br>
<blockquote
cite="mid:CAP5fpJHFuUr2HQMBQjXxk=Q8TqWrxr4fqDrWJaxGYBFby6dKkw@mail.gmail.com"
type="cite">
<div dir="ltr">
<div style=""><br>
</div>
<div style="">Does anyone know if there already exist some pass
which does something like this (collects static allocations)
or should I write this from the scratch ? Does the idea sound
reasonable at all ? </div>
<div style=""><br>
</div>
<div style="">Cheers, Mikael Lepistö</div>
</div>
<br>
<fieldset class="mimeAttachmentHeader"></fieldset>
<br>
<pre wrap="">_______________________________________________
LLVM Developers mailing list
<a class="moz-txt-link-abbreviated" href="mailto:LLVMdev@cs.uiuc.edu">LLVMdev@cs.uiuc.edu</a> <a class="moz-txt-link-freetext" href="http://llvm.cs.uiuc.edu">http://llvm.cs.uiuc.edu</a>
<a class="moz-txt-link-freetext" href="http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev">http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev</a>
</pre>
</blockquote>
<br>
</body>
</html>