[LLVMdev] isa and friends as an alternative to dynamic cast?

Reid Spencer reid at x10sys.com
Thu Apr 21 19:43:21 PDT 2005


In case it wasn't obvious from Misha's answer, the main reason for doing
this is speed. RTTI is not very quick. Since LLVM is well contained,
there are no IR classes that LLVM doesn't know about it. Using
dynamic_cast is really only warranted when blending libraries together
that have inheritance relationships between them that aren't known in
one or more of the libraries. Since we don't have that situation in
LLVM, using the various Casting.h facilities allows all that "dynamic"
casting to actually be done statically, hence no runtime performance

If you wonder why LLVM is fast .. this is just one of the many reasons.


On Thu, 2005-04-21 at 21:34 -0400, Evan Jones wrote:

> I see a bunch of definitions scattered throughout LLVM, and I could not
> find good documentation on them. I don't understand why they exist when
> LLVM is being compiled with RTTI enabled. It seems to me that:
> isa<T>(x) is a substitute for (dynamic_cast<T>(x) != NULL)
> and there are some other similar casting tools defined in Casting.h. Why
> should I use these instead of C++'s built-in features?
> Evan Jones
> _______________________________________________
> LLVM Developers mailing list
> LLVMdev at cs.uiuc.edu         http://llvm.cs.uiuc.edu
> http://mail.cs.uiuc.edu/mailman/listinfo/llvmdev
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20050421/303632f8/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20050421/303632f8/attachment.sig>

More information about the llvm-dev mailing list