[LLVMdev] Removing redundant type checks from Java

Nicolas Geoffray nicolas.geoffray at lip6.fr
Mon Sep 21 22:49:02 PDT 2009


Hi Alysson,

Alysson wrote:
> Hi, LLVMers,
>
>     I am a CS student in my final year, and I would like to use LLVM 
> in my final course project. So, I just download LLVM and VMKit, and I 
> have been playing with both. I can produce llvm bytecodes from java 
> programs, and now my idea is to remove redundant type checks from the 
> code. For instance, if we consider a program like this:
>
> if (o instanceof A) {
>   A a = (A) o;
>   // do something with a
> }
>
> we see that Java will put a type test before the cast, but this test 
> is unnecessary, as we already know that we have passed the instanceof 
> test. So, as my project I would like to remove these redundant tests.

OK.

> My questions:
>
> 1) Has this already been done by some of the VMKit optimizing passes?

I believe it must be done if you run the -gvn pass on the llvm bytecode. 
You can for example give the "-std-compile-opts" command line argument 
to vmjc.

> 2) If not, is this feasible?

If the -gvn pass does not remove it, you can write your own optimization 
pass on the llvm bytecode and detect the redundant checks. Then use the 
opt tool to load your pass and apply it to your llvm bytecode.

> 3) Is this the right list to ask questions about VMKit?
>

These kinds of questions, I believe yes :)

Cheers,
Nicolas

> All the best,
>
> Alysson
> ------------------------------------------------------------------------
>
> _______________________________________________
> LLVM Developers mailing list
> LLVMdev at cs.uiuc.edu         http://llvm.cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
>   




More information about the llvm-dev mailing list