<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/57616>57616</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            [WPD] Miscompile with -fno-split-lto-unit
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            new issue
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          aeubanks
      </td>
    </tr>
</table>

<pre>
    ```
$ cat y.cc

struct B {
  virtual void f() {}
};

struct D1 : B {
  void f() override {}
};

struct D2 : B {
  void f() override {}
};

B *b1();
B *b2();

int main(int argc, char **argv) {
  if (argc) {
    static_cast<D1 *>(b1())->f();
  } else {
    static_cast<D2 *>(b2())->f();
  }
}

$ cat z.cc

struct B {
  virtual void f() {}
};

struct D1 : B {
  void f() override {}
};

struct D2 : B {
  void f() override {}
};

B *b1() { return new D1; }

B *b2() { return new D2; }

$ ./build/rel/bin/clang++ -o a.out y.cc z.cc -flto=thin -O3 -fuse-ld=lld -fwhole-program-vtables -mllvm -import-instr-limit=0 -Wl,--thinlto-jobs=1 -fno-rtti -fno-split-lto-unit -fvisibility=hidden && ./a.out
# a.out crashes
```

With opaque pointers, the `assume(typetest)`s in the if/else become `assume(phi(typetest1,typetest2))`, causing WPD to miss them. But the miscompile is that LowerTypeTests comes along and thinks that the type tests don't have any satisfying virtual functions, even though the IR contains the corresponding metadata entries. The import summary seems to be missing entries for the type ids.

Where should we be adding the type id entries in the import summary for the -fno-split-lto-unit case?

@teresajohnson @pcc 
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzlVU2P6jYU_TVhcxUUHEhgkcUwFKlSq1bVSLOsnOSGeOrEqe0wor--xwFmgI7aLt7uSVZw7se5X-eG0tSnIsqSy0l2UfIUiSVV0tNpXlUXyfR03o6Vpy1F-fYsIToq60ep6WhUTU0k1pHYTPp8d3HFJd1-AbNbUJQ-Pa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