[LLVMdev] Removing instanceof tests

Alysson aishofpf at gmail.com
Thu Nov 19 08:59:25 PST 2009


Hi all,

    I wrote you some days ago about one project that I want to do on vmkit:
I want to remove redundant instanceof tests. I am right now looking at the
LLVM code that vmkit produces for java files, but I am finding it very
difficult to identify the code that is produced by each instanceof. Would it
be possible for you guys to give me some pointers on how to attack this
problem? Should I focus on the vmkit front-end, or should I perform this
type of optimization directly in LLVM, as a function pass?

Just to give you context, the optimization that I want to perform is to
remove redundant instanceof's that are inserted by vmkit to ensure that the
code does not do unsafe casts at runtime. For instance, if I code the
program:

if (o instanceof String)
  String s = (String)o;

then vmkit will most likely insert a second test in the code, like this:

if (o instanceof String) {
  if (!o instanceof String)
    throw ClassCastException
  String s = (String)o;
}

Thanks in advance,

Alysson
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20091119/201370a4/attachment.html>


More information about the llvm-dev mailing list