[llvm-dev] Type discrepancies in LLVM Bitcode

Yaron Keren via llvm-dev llvm-dev at lists.llvm.org
Tue Jun 14 14:57:30 PDT 2016


What happens if built with -O0 ?

2016-06-15 0:53 GMT+03:00 George Balatsouras via llvm-dev <
llvm-dev at lists.llvm.org>:

> Hi everyone,
>
> I've encountered some strange bitcode translation of a dynamic library
> which uses boost. The library is compiled to LLVM bitcode with clang 3.7.
> The LLVM type for class boost::bad_lexical_cast is represented as follows:
>
> %"class.boost::bad_lexical_cast" = type { *%"class.std::bad_alloc"*,
> %"class.std::type_info"**​*, %*"class.std::type_info"***​* }
>
> So, it looks like boost::bad_lexical_cast inherits from std::bad_alloc.
> However, the associated type info for this class (contained in the same
> bitcode file) suggests that the primary base class is std::bad_cast
>  instead:
>
> @_ZTIN5boost16bad_lexical_castE = linkonce_odr constant { i8*, i8*, i8* } {
>    i8* bitcast (i8** getelementptr inbounds (i8*, i8**
> @_ZTVN10__cxxabiv120__si_class_type_infoE, i64 2) to i8*),
>    i8* getelementptr inbounds ([27 x i8], [27 x i8]*
> @_ZTSN5boost16bad_lexical_castE, i32 0, i32 0),
>    i8* bitcast (i8** *@_ZTISt8bad_cast* to i8*)
> }, comdat
>
> $ echo '_ZTISt8bad_cast' | c++filt
> typeinfo for std::bad_cast
>
> This seems more reasonable and in accordance to boost source code (
> http://www.boost.org/doc/libs/1_58_0/boost/lexical_cast/bad_lexical_cast.hpp
> ).
> Even so, the LLVM type for bad_alloc looks even stranger:
>
> %"class.std::bad_alloc" = type { %"class.boost::system::error_category" }
>
> How can a class from standard library inherit something from boost, and
> why is the layout of some class types different from what their typeinfo
> objects suggest? Is this a bug, or some obscure effect from an optimization
> pass?
>
> Thanks,
> George
>
> _______________________________________________
> LLVM Developers mailing list
> llvm-dev at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20160615/3ad06fd8/attachment.html>


More information about the llvm-dev mailing list