https://github.com/AnthonyLatsis updated 
https://github.com/llvm/llvm-project/pull/154453

>From 720fe06f7fb13eef51d7bfbfbef9022fa995dc62 Mon Sep 17 00:00:00 2001
From: Anthony Latsis <alat...@apple.com>
Date: Mon, 21 Apr 2025 21:15:59 +0100
Subject: [PATCH] [clang] Upstream `clang::CodeGen::getConstantSignedPointer`

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.
---
 clang/include/clang/CodeGen/CodeGenABITypes.h | 7 +++++++
 clang/lib/CodeGen/CGPointerAuth.cpp           | 8 ++++++++
 2 files changed, 15 insertions(+)

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 dcef01a5eb6d3..193dd81a68d37 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,

_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to