[clang] 0bc0209 - [clang] Upstream `clang::CodeGen::getConstantSignedPointer` (#154453)
via cfe-commits
cfe-commits at lists.llvm.org
Thu Aug 21 17:56:01 PDT 2025
Author: Anthony Latsis
Date: 2025-08-21T17:55:57-07:00
New Revision: 0bc02096f692da5b2f6b50fa82395af930314bcb
URL: https://github.com/llvm/llvm-project/commit/0bc02096f692da5b2f6b50fa82395af930314bcb
DIFF: https://github.com/llvm/llvm-project/commit/0bc02096f692da5b2f6b50fa82395af930314bcb.diff
LOG: [clang] Upstream `clang::CodeGen::getConstantSignedPointer` (#154453)
This function was introduced to Swift's fork in
https://github.com/swiftlang/llvm-project/commit/a9dd959e60c32#diff-db27b2738ad84e3f1093f9174710710478f853804d995a6de2816d1caaad30d1.
The Swift compiler cannot use `CodeGenModule::getConstantSignedPointer`,
to which it forwards, because that is a private interface.
Added:
Modified:
clang/include/clang/CodeGen/CodeGenABITypes.h
clang/lib/CodeGen/CGPointerAuth.cpp
Removed:
################################################################################
diff --git a/clang/include/clang/CodeGen/CodeGenABITypes.h b/clang/include/clang/CodeGen/CodeGenABITypes.h
index 836fdd75477c7..16f39b991a273 100644
--- a/clang/include/clang/CodeGen/CodeGenABITypes.h
+++ b/clang/include/clang/CodeGen/CodeGenABITypes.h
@@ -32,6 +32,7 @@
namespace llvm {
class AttrBuilder;
class Constant;
+class ConstantInt;
class Function;
class FunctionType;
class Type;
@@ -126,6 +127,12 @@ uint16_t getPointerAuthDeclDiscriminator(CodeGenModule &CGM, GlobalDecl GD);
uint16_t getPointerAuthTypeDiscriminator(CodeGenModule &CGM,
QualType FunctionType);
+/// Return a signed constant pointer.
+llvm::Constant *getConstantSignedPointer(CodeGenModule &CGM,
+ llvm::Constant *Pointer, unsigned Key,
+ llvm::Constant *StorageAddress,
+ llvm::ConstantInt *OtherDiscriminator);
+
/// Given the language and code-generation options that Clang was configured
/// with, set the default LLVM IR attributes for a function definition.
/// The attributes set here are mostly global target-configuration and
diff --git a/clang/lib/CodeGen/CGPointerAuth.cpp b/clang/lib/CodeGen/CGPointerAuth.cpp
index 1a5ffb5eb33f8..375f87a68ee6d 100644
--- a/clang/lib/CodeGen/CGPointerAuth.cpp
+++ b/clang/lib/CodeGen/CGPointerAuth.cpp
@@ -466,6 +466,14 @@ llvm::Constant *CodeGenModule::getConstantSignedPointer(
OtherDiscriminator);
}
+llvm::Constant *
+CodeGen::getConstantSignedPointer(CodeGenModule &CGM, llvm::Constant *Pointer,
+ unsigned Key, llvm::Constant *StorageAddress,
+ llvm::ConstantInt *OtherDiscriminator) {
+ return CGM.getConstantSignedPointer(Pointer, Key, StorageAddress,
+ OtherDiscriminator);
+}
+
/// If applicable, sign a given constant function pointer with the ABI rules for
/// functionType.
llvm::Constant *CodeGenModule::getFunctionPointer(llvm::Constant *Pointer,
More information about the cfe-commits
mailing list