[LLVMdev] Re: llvm -> array bound checking at compile time

John Criswell criswell at cs.uiuc.edu
Fri Apr 2 08:50:02 PST 2004


Dear Boris,

I managed to see your question and rescue it from the llvm-announce 
mailing list filter.  I'm forwarding your question to the 
llvmdev at cs.uiuc.edu mailing list; that list is used for questions and 
answers about LLVM.

For future reference, the llvm-announce list is used to send 
announcements regarding LLVM releases.  The llvmdev list is for general 
discussion.

Now, on to your question:

LLVM does not provide static or runtime checks of array bounds (unlike 
the Java Virtual Machine, which performs run-time checks) nor is there 
an instruction to do so.  This allows LLVM to compile arbitrary 
programs, regardless of whether the program is safe or not.

That said, a compiler can always insert these checks when compiling into 
LLVM bytecode.  So, if you wrote a Java to LLVM compiler, the checks 
would be there.

It may also be possible to write analysis and transformation passes to 
do this, although I imagine that this would be non-trivial for 
type-unsafe code.

Regards,

-- John T.

 > Hello,

 > does there exist an explicit instruction in the llvm-IR for performing =
 > checks on array bounds? Or is array bound checking done implicitly at =
 > run-time?


-- 
*********************************************************************
* John T. Criswell                         Email: criswell at uiuc.edu *
* Research Programmer                                               *
* University of Illinois at Urbana-Champaign                        *
*                                                                   *
* "It's today!" said Piglet. "My favorite day," said Pooh.          *
*********************************************************************





More information about the llvm-dev mailing list