Skip to content

Commit 01bfd14

Browse files
committed
[clang][PAC] Fix PAC codegen for final class dynamic_cast optimization (#152227)
The codegen for the final class dynamic_cast optimization fails to consider pointer authentication. This change resolves this be simply disabling the optimization when pointer authentication enabled.
1 parent 3d6fb12 commit 01bfd14

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

clang/lib/CodeGen/CGExprCXX.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2313,7 +2313,8 @@ llvm::Value *CodeGenFunction::EmitDynamicCast(Address ThisAddr,
23132313
bool IsExact = !IsDynamicCastToVoid &&
23142314
CGM.getCodeGenOpts().OptimizationLevel > 0 &&
23152315
DestRecordTy->getAsCXXRecordDecl()->isEffectivelyFinal() &&
2316-
CGM.getCXXABI().shouldEmitExactDynamicCast(DestRecordTy);
2316+
CGM.getCXXABI().shouldEmitExactDynamicCast(DestRecordTy) &&
2317+
!getLangOpts().PointerAuthCalls;
23172318

23182319
// C++ [expr.dynamic.cast]p4:
23192320
// If the value of v is a null pointer value in the pointer case, the result

clang/test/CodeGenCXX/dynamic-cast-exact-disabled.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
// RUN: %clang_cc1 -I%S %s -triple x86_64-apple-darwin10 -O1 -fvisibility=hidden -emit-llvm -std=c++11 -o - | FileCheck %s --check-prefixes=CHECK,INEXACT
44
// RUN: %clang_cc1 -I%S %s -triple x86_64-apple-darwin10 -O1 -fapple-kext -emit-llvm -std=c++11 -o - | FileCheck %s --check-prefixes=CHECK,INEXACT
55
// RUN: %clang_cc1 -I%S %s -triple x86_64-apple-darwin10 -O1 -fno-assume-unique-vtables -emit-llvm -std=c++11 -o - | FileCheck %s --check-prefixes=CHECK,INEXACT
6+
// RUN: %clang_cc1 -I%S %s -triple arm64e-apple-darwin10 -O1 -fptrauth-calls -emit-llvm -std=c++11 -o - | FileCheck %s --check-prefixes=CHECK,INEXACT
67

78
struct A { virtual ~A(); };
89
struct B final : A { };

0 commit comments

Comments
 (0)