Skip to content

Commit 8db3653

Browse files
committed
Switch to Schema addSignedPointer API, remove the exploded version, and add more tests
1 parent 6454572 commit 8db3653

File tree

4 files changed

+7
-26
lines changed

4 files changed

+7
-26
lines changed

clang/include/clang/CodeGen/ConstantInitBuilder.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -206,9 +206,6 @@ class ConstantAggregateBuilderBase {
206206
void addSignedPointer(llvm::Constant *Pointer,
207207
const PointerAuthSchema &Schema, GlobalDecl CalleeDecl,
208208
QualType CalleeType);
209-
void addSignedPointer(llvm::Constant *Pointer, unsigned Key,
210-
bool UseAddressDiscrimination,
211-
llvm::ConstantInt *OtherDiscriminator);
212209

213210
/// Add a null pointer of a specific type.
214211
void addNullPointer(llvm::PointerType *ptrTy) {

clang/lib/CodeGen/CGObjCMac.cpp

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7684,15 +7684,9 @@ CGObjCNonFragileABIMac::GetInterfaceEHType(const ObjCInterfaceDecl *ID,
76847684

76857685
if (auto &Schema =
76867686
CGM.getCodeGenOpts().PointerAuth.CXXTypeInfoVTablePointer) {
7687-
uint32_t discrimination = 0;
7688-
if (Schema.hasOtherDiscrimination()) {
7689-
assert(Schema.getOtherDiscrimination() ==
7690-
PointerAuthSchema::Discrimination::Constant);
7691-
discrimination = Schema.getConstantDiscrimination();
7692-
}
7693-
values.addSignedPointer(
7694-
VTablePtr, Schema.getKey(), Schema.isAddressDiscriminated(),
7695-
llvm::ConstantInt::get(CGM.IntPtrTy, discrimination));
7687+
assert(!Schema.hasOtherDiscrimination() ||
7688+
Schema.getOtherDiscrimination() == PointerAuthSchema::Discrimination::Constant);
7689+
values.addSignedPointer(VTablePtr, Schema, GlobalDecl(), QualType());
76967690
} else {
76977691
values.add(VTablePtr);
76987692
}

clang/lib/CodeGen/ConstantInitBuilder.cpp

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -314,15 +314,3 @@ void ConstantAggregateBuilderBase::addSignedPointer(
314314
Pointer, Schema, StorageAddress, CalleeDecl, CalleeType);
315315
add(SignedPointer);
316316
}
317-
318-
void ConstantAggregateBuilderBase::addSignedPointer(
319-
llvm::Constant *Pointer, unsigned Key, bool UseAddressDiscrimination,
320-
llvm::ConstantInt *OtherDiscriminator) {
321-
llvm::Constant *StorageAddress = nullptr;
322-
if (UseAddressDiscrimination)
323-
StorageAddress = getAddrOfCurrentPosition(Pointer->getType());
324-
325-
llvm::Constant *SignedPointer = Builder.CGM.getConstantSignedPointer(
326-
Pointer, Key, StorageAddress, OtherDiscriminator);
327-
add(SignedPointer);
328-
}

clang/test/CodeGenObjC/ptrauth-attr-exception.m

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
// RUN: %clang_cc1 -triple arm64-apple-ios -fptrauth-calls -emit-llvm -fexceptions -fobjc-exceptions -o - %s | FileCheck %s
1+
// RUN: %clang_cc1 -triple arm64-apple-ios -fptrauth-calls -emit-llvm -fexceptions -fobjc-exceptions -o - %s | FileCheck %s
2+
// RUN: %clang_cc1 -triple arm64-apple-ios -fptrauth-type-info-vtable-pointer-discrimination -fptrauth-calls -emit-llvm -fexceptions -fobjc-exceptions -o - %s | FileCheck --check-prefix=TYPEDISC_TYPEINFO %s
23

34
__attribute__((objc_root_class))
45
@interface Root {
@@ -13,4 +14,5 @@ @interface A : Root
1314
@implementation A
1415
@end
1516

16-
// CHECK: @"OBJC_EHTYPE_$_A" = global {{%.*}} { ptr ptrauth (ptr getelementptr inbounds (ptr, ptr @objc_ehtype_vtable, i32 2), i32 2),
17+
// CHECK: @"OBJC_EHTYPE_$_A" = global {{%.*}} { ptr ptrauth (ptr getelementptr inbounds (ptr, ptr @objc_ehtype_vtable, i32 2), i32 2),
18+
// TYPEDISC_TYPEINFO: @"OBJC_EHTYPE_$_A" = global {{%.*}} { ptr ptrauth (ptr getelementptr inbounds (ptr, ptr @objc_ehtype_vtable, i32 2), i32 2, i64 45546, ptr @"OBJC_EHTYPE_$_A"),

0 commit comments

Comments
 (0)