[CodeGen] Keep track of eagerly emitted globals
authorJonas Hahnfeld <jonas.hahnfeld@cern.ch>
Fri, 28 Jul 2023 13:43:11 +0000 (15:43 +0200)
committerTobias Hieta <tobias@hieta.se>
Mon, 21 Aug 2023 08:05:22 +0000 (10:05 +0200)
commit1f669d35fc1f93f48fda419801034248c6412205
treefaf5714ff546568065f13794acecbb4b852dfba0
parent0a3a9197247edbd33803a3691efa513ac228860f
[CodeGen] Keep track of eagerly emitted globals

An inline virtual function must be emitted, but we need to remember
it and emit the same definition again in the future in case later
LLVM optimizations stripped it from the Module. The added test case
shows the problem; before this patch, it would fail with:
    Symbols not found: [ _ZN1AD0Ev, _ZN1AD1Ev ]

This reapplies commit f8dadefd4a, reverted in commit 0e17372b38, but
disables RTTI in the test to avoid problems on Windows.

Differential Revision: https://reviews.llvm.org/D156537

(cherry picked from commit c861d32d7c2791bdc058d9d9fbaecc1c2f07b8c7)
clang/lib/CodeGen/CodeGenModule.cpp
clang/test/Interpreter/inline-virtual.cpp [new file with mode: 0644]