<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="/rss.xsl.xml"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/">
<channel>
    <title>Changes in devirt_split_unit_localize.ll</title>
    <description></description>
    <language>en</language>
    <copyright>Copyright 2015</copyright>
    <generator>Java</generator><item>
        <title>2f651660 - [lld:elf] Weaken the requirement for a computed binding to be STB_LOCAL</title>
        <link>http://172.16.0.5:8080/history/llvm-project-15.0.7/lld/test/ELF/lto/devirt_split_unit_localize.ll#2f651660</link>
        <description>[lld:elf] Weaken the requirement for a computed binding to be STB_LOCALGiven the following scenario:```// Cat.cppstruct Animal { virtual void makeNoise() const = 0; };struct Cat : Animal { void makeNoise() const override; };extern &quot;C&quot; int puts(char const *);void Cat::makeNoise() const { puts(&quot;Meow&quot;); }void doThingWithCat(Animal *a) { static_cast&lt;Cat *&gt;(a)-&gt;makeNoise(); }// CatUser.cppstruct Animal { virtual void makeNoise() const = 0; };struct Cat : Animal { void makeNoise() const override; };void doThingWithCat(Animal *a);void useDoThingWithCat() {  Cat *d = new Cat;  doThingWithCat(d);}// cat.ver{  global: _Z17useDoThingWithCatv;  local: *;};$ clang++ Cat.cpp CatUser.cpp -fpic -flto=thin -fwhole-program-vtables-shared -O3 -fuse-ld=lld -Wl,--lto-whole-program-visibility-Wl,--version-script,cat.ver```We cannot devirtualize `Cat::makeNoise`. The issue is complex:Due to `-fsplit-lto-unit` and usage of type metadata, we place the Catvtable declaration into module 0 and the Cat vtable definition with typemetadata into module 1, causing duplicate entries (Undefined followed byDefined) in the `lto::InputFile::symbols()` output.In `BitcodeFile::parse`, after processing the `Undefined` then the`Defined`, the final state is `Defined`.In `BitcodeCompiler::add`, for the first symbol, `computeBinding`returns `STB_LOCAL`, then we reset it to `Undefined` because it isprevailing (`versionId` is `preserved`). For the second symbol, becausethe state is now `Undefined`, `computeBinding` returns `STB_GLOBAL`,causing `ExportDynamic` to be true and suppressing devirtualization.In D77280, the `computeBinding` change used a stricter `isDefined()`condition to make weak``Lazy` symbol work.This patch relaxes the condition to weaker `!isLazy()` to keep itworking while making the devirtualization work as well.Differential Revision: https://reviews.llvm.org/D98686

            List of files:
            /llvm-project-15.0.7/lld/test/ELF/lto/devirt_split_unit_localize.ll</description>
        <pubDate>Tue, 16 Mar 2021 08:33:50 +0000</pubDate>
        <dc:creator>Nathan Lanza &lt;nathan@lanza.io&gt;</dc:creator>
    </item>
</channel>
</rss>
