Skip to content

Commit 9cc6817

Browse files
Merge pull request #10842 from AnthonyLatsis/stable/20250601
Revert "[clang] Remove unused CodeGen:: ptrauth helpers. NFCI."
2 parents 1468247 + 3200405 commit 9cc6817

File tree

2 files changed

+33
-0
lines changed

2 files changed

+33
-0
lines changed

clang/include/clang/CodeGen/CodeGenABITypes.h

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,20 @@ llvm::Type *convertTypeForMemory(CodeGenModule &CGM, QualType T);
120120
unsigned getLLVMFieldNumber(CodeGenModule &CGM,
121121
const RecordDecl *RD, const FieldDecl *FD);
122122

123+
/// Return a declaration discriminator for the given global decl.
124+
uint16_t getPointerAuthDeclDiscriminator(CodeGenModule &CGM, GlobalDecl GD);
125+
126+
/// Return a type discriminator for the given function type.
127+
uint16_t getPointerAuthTypeDiscriminator(CodeGenModule &CGM,
128+
QualType FunctionType);
129+
130+
/// Return a signed constant pointer.
131+
llvm::Constant *getConstantSignedPointer(CodeGenModule &CGM,
132+
llvm::Constant *pointer,
133+
unsigned key,
134+
llvm::Constant *storageAddress,
135+
llvm::ConstantInt *otherDiscriminator);
136+
123137
/// Given the language and code-generation options that Clang was configured
124138
/// with, set the default LLVM IR attributes for a function definition.
125139
/// The attributes set here are mostly global target-configuration and

clang/lib/CodeGen/CGPointerAuth.cpp

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,16 @@ llvm::ConstantInt *CodeGenModule::getPointerAuthOtherDiscriminator(
5252
llvm_unreachable("bad discrimination kind");
5353
}
5454

55+
uint16_t CodeGen::getPointerAuthTypeDiscriminator(CodeGenModule &CGM,
56+
QualType FunctionType) {
57+
return CGM.getContext().getPointerAuthTypeDiscriminator(FunctionType);
58+
}
59+
60+
uint16_t CodeGen::getPointerAuthDeclDiscriminator(CodeGenModule &CGM,
61+
GlobalDecl Declaration) {
62+
return CGM.getPointerAuthDeclDiscriminator(Declaration);
63+
}
64+
5565
/// Return the "other" decl-specific discriminator for the given decl.
5666
uint16_t
5767
CodeGenModule::getPointerAuthDeclDiscriminator(GlobalDecl Declaration) {
@@ -587,6 +597,15 @@ llvm::Constant *CodeGenModule::getConstantSignedPointer(
587597
OtherDiscriminator);
588598
}
589599

600+
llvm::Constant *
601+
CodeGen::getConstantSignedPointer(CodeGenModule &CGM,
602+
llvm::Constant *pointer, unsigned key,
603+
llvm::Constant *storageAddress,
604+
llvm::ConstantInt *otherDiscriminator) {
605+
return CGM.getConstantSignedPointer(pointer, key, storageAddress,
606+
otherDiscriminator);
607+
}
608+
590609
void CodeGenModule::destroyConstantSignedPointerCaches() {
591610
destroyCache<ByConstantCacheTy>(ConstantSignedPointersByConstant);
592611
destroyCache<ByDeclCacheTy>(ConstantSignedPointersByDecl);

0 commit comments

Comments
 (0)