Internalize: internalize comdat members as a group, and drop comdat on such members.
authorPeter Collingbourne <peter@pcc.me.uk>
Thu, 16 Jul 2015 17:42:21 +0000 (17:42 +0000)
committerPeter Collingbourne <peter@pcc.me.uk>
Thu, 16 Jul 2015 17:42:21 +0000 (17:42 +0000)
commit4a6d99b0a96d4eb27d89c22e33981ff0344c5737
treeb815b0b3fb73dd0b5673280a45d7eb6837c03e5e
parentfc0d94c8ec0d273c7a85fc0c142f3e0312411879
Internalize: internalize comdat members as a group, and drop comdat on such members.

Internalizing an individual comdat group member without also internalizing
the other members of the comdat can break comdat semantics. For example,
if a module contains a reference to an internalized comdat member, and the
linker chooses a comdat group from a different object file, this will break
the reference to the internalized member.

This change causes the internalizer to only internalize comdat members if all
other members of the comdat are not externally visible. Once a comdat group
has been fully internalized, there is no need to apply comdat rules to its
members; later optimization passes (e.g. globaldce) can legally drop individual
members of the comdat. So we drop the comdat attribute from all comdat members.

Differential Revision: http://reviews.llvm.org/D10679

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@242423 91177308-0d34-0410-b5e6-96231b3b80d8
lib/Transforms/IPO/Internalize.cpp
test/Transforms/Internalize/comdat.ll [new file with mode: 0644]