luken-google marked an inline comment as done.
luken-google added inline comments.


================
Comment at: clang/lib/CodeGen/CGDebugInfo.cpp:1761
 
-  if (Method->isVirtual()) {
+  if (Method->isVirtual() && !Method->isConsteval()) {
     if (Method->isPure())
----------------
shafik wrote:
> It is not clear to me if this is the core issue or not. Can you explain this 
> a little better.
Thanks for the feedback!

Sure, here's what I'm thinking. This code calls 
ItaniumVTableContext::getMethodVTableIndex(GlobalDecl) on line 1771 below. That 
method asserts in VTableBuilder.cpp:2281 because it tries to look up a vtable 
entry for the consteval method and fails to do so. Any consteval methods are 
prevented from gaining vtable entries by the logic in 
VTableContextBase::hasVtableSlot(const CXXMethodDecl *MD):

```
bool VTableContextBase::hasVtableSlot(const CXXMethodDecl *MD) {
  return MD->isVirtual() && !MD->isConsteval();
}
```

This call is peppered throughout the VTableBuilder code, but the relevant call 
for our purposes is in ItaniumVTableBuilder::AddMethods() in 
VTableBuilder.cpp:1492, which causes any consteval method to be skipped when 
the code is iterating through all virtual member functions and adding them to 
the vtable.

My fix mirrors the logic in VTableContextBase::hasVtableSlot here, because the 
code assumes that if the method is virtual it has a vtable index, which 
consteval functions don't. Writing this, I've convinced myself it's better to 
just call that method directly, so I've refactored the code to avoid the 
duplicate logic.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D132874/new/

https://reviews.llvm.org/D132874

_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to