[all-commits] [llvm/llvm-project] d8a36b: [ABI] [C++20] [Modules] Don't generate vtable if t...

Chuanqi Xu via All-commits all-commits at lists.llvm.org
Tue Jun 13 22:02:43 PDT 2023


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: d8a36b00d198fdc2ea866ea5da449628db07070f
      https://github.com/llvm/llvm-project/commit/d8a36b00d198fdc2ea866ea5da449628db07070f
  Author: Chuanqi Xu <yedeng.yd at linux.alibaba.com>
  Date:   2023-06-14 (Wed, 14 Jun 2023)

  Changed paths:
    M clang/lib/CodeGen/CGVTables.cpp
    A clang/test/CodeGenCXX/modules-vtable.cppm

  Log Message:
  -----------
  [ABI] [C++20] [Modules] Don't generate vtable if the class is defined in other module unit

Close https://github.com/llvm/llvm-project/issues/61940.

The root cause is that clang will generate vtable as strong symbol now
even if the corresponding class is defined in other module units. After
I check the wording in Itanium ABI, I find this is not inconsistent.
Itanium ABI 5.2.3
(https://itanium-cxx-abi.github.io/cxx-abi/abi.html#vague-vtable) says:

> The virtual table for a class is emitted in the same object containing
> the definition of its key function, i.e. the first non-pure virtual
> function that is not inline at the point of class definition.

So the current behavior is incorrect. This patch tries to address this.
Also I think we need to do a similar change for MSVC ABI. But I don't
find the formal wording. So I don't address this in this patch.

Reviewed By: rjmccall, iains, dblaikie

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




More information about the All-commits mailing list