[cfe-users] Machine code footprint

Marcel Keller via cfe-users cfe-users at lists.llvm.org
Tue Jan 5 07:04:48 PST 2021


Hi,

When I compile the attached code, I find that one instantiation of 
vector::_M_fill_insert is double the size of the other even though the 
semantics should be the same:

$ clang++ -O3 -g -c insert.cpp
$ nm insert.o  --size-sort -Ctd
0000000000000079 W std::vector<A, std::allocator<A> > f<A>()
0000000000000079 W std::vector<long, std::allocator<long> > f<long>()
0000000000001765 W std::vector<long, std::allocator<long> 
 >::_M_fill_insert(__gnu_cxx::__normal_iterator<long*, std::vector<long, 
std::allocator<long> > >, unsigned long, long const&)
0000000000003638 W std::vector<A, std::allocator<A> 
 >::_M_fill_insert(__gnu_cxx::__normal_iterator<A*, std::vector<A, 
std::allocator<A> > >, unsigned long, A const&)

What is the reason for this? I would expect that a class trivially 
containing one member would be treated the same as just the member.

I'm using clang 10 on Ubuntu 20.04.

Best regards,
Marcel

-------------- next part --------------
A non-text attachment was scrubbed...
Name: insert.cpp
Type: text/x-c++src
Size: 234 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-users/attachments/20210106/67d1cb52/attachment.cpp>


More information about the cfe-users mailing list