[clang] 3b34d69 - Revert "For #64088: mark vtable as used if we might emit a reference to it."

Dmitry Chernenkov via cfe-commits cfe-commits at lists.llvm.org
Fri Jul 28 03:50:06 PDT 2023


Author: Dmitry Chernenkov
Date: 2023-07-28T10:49:53Z
New Revision: 3b34d69ac7a643742364be3591b324ddd14ef9aa

URL: https://github.com/llvm/llvm-project/commit/3b34d69ac7a643742364be3591b324ddd14ef9aa
DIFF: https://github.com/llvm/llvm-project/commit/3b34d69ac7a643742364be3591b324ddd14ef9aa.diff

LOG: Revert "For #64088: mark vtable as used if we might emit a reference to it."

This reverts commit b6847edfc235829b37dd6d734ef5bbfa0a58b6fc.

Added: 
    

Modified: 
    clang/lib/Sema/SemaCast.cpp
    clang/test/CodeGenCXX/dynamic-cast-exact.cpp

Removed: 
    


################################################################################
diff  --git a/clang/lib/Sema/SemaCast.cpp b/clang/lib/Sema/SemaCast.cpp
index b338d601db7397..d65ecf52c52310 100644
--- a/clang/lib/Sema/SemaCast.cpp
+++ b/clang/lib/Sema/SemaCast.cpp
@@ -935,14 +935,6 @@ void CastOperation::CheckDynamicCast() {
           << isClangCL;
   }
 
-  // For a dynamic_cast to a final type, IR generation might emit a reference
-  // to the vtable.
-  if (DestRecord) {
-    auto *DestDecl = DestRecord->getAsCXXRecordDecl();
-    if (DestDecl->isEffectivelyFinal())
-      Self.MarkVTableUsed(OpRange.getBegin(), DestDecl);
-  }
-
   // Done. Everything else is run-time checks.
   Kind = CK_Dynamic;
 }

diff  --git a/clang/test/CodeGenCXX/dynamic-cast-exact.cpp b/clang/test/CodeGenCXX/dynamic-cast-exact.cpp
index bd283e85101b4b..676aa975a72686 100644
--- a/clang/test/CodeGenCXX/dynamic-cast-exact.cpp
+++ b/clang/test/CodeGenCXX/dynamic-cast-exact.cpp
@@ -76,12 +76,3 @@ H *exact_multi(A *a) {
   // CHECK: phi ptr [ %[[RESULT]], %[[LABEL_NOTNULL]] ], [ null, %[[LABEL_FAILED]] ]
   return dynamic_cast<H*>(a);
 }
-
-namespace GH64088 {
-  // Ensure we mark the B vtable as used here, because we're going to emit a
-  // reference to it.
-  // CHECK: define {{.*}} @_ZN7GH640881BD0
-  struct A { virtual ~A(); };
-  struct B final : A { virtual ~B() = default; };
-  B *cast(A *p) { return dynamic_cast<B*>(p); }
-}


        


More information about the cfe-commits mailing list