aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
diff options
context:
space:
mode:
authorAhmed Bougacha <ahmed@bougacha.org>2024-05-28 16:39:09 -0700
committerGitHub <noreply@github.com>2024-05-28 16:39:09 -0700
commit0edc97f119f3ac3ff96b11183fe5c001a48a9a8d (patch)
tree381f97ed82e28f48672f05e138ba9bb17104beff /llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
parent60bce6eab4d734b86f49b7638856eb8899bc89e8 (diff)
downloadllvm-0edc97f119f3ac3ff96b11183fe5c001a48a9a8d.zip
llvm-0edc97f119f3ac3ff96b11183fe5c001a48a9a8d.tar.gz
llvm-0edc97f119f3ac3ff96b11183fe5c001a48a9a8d.tar.bz2
[IR][AArch64][PAC] Add "ptrauth(...)" Constant to represent signed pointers. (#85738)
This defines a new kind of IR Constant that represents a ptrauth signed pointer, as used in AArch64 PAuth. It allows representing most kinds of signed pointer constants used thus far in the llvm ptrauth implementations, notably those used in the Darwin and ELF ABIs being implemented for c/c++. These signed pointer constants are then lowered to ELF/MachO relocations. These can be simply thought of as a constant `llvm.ptrauth.sign`, with the interesting addition of discriminator computation: the `ptrauth` constant can also represent a combined blend, when both address and integer discriminator operands are used. Both operands are otherwise optional, with default values 0/null.
Diffstat (limited to 'llvm/lib/Bitcode/Writer/BitcodeWriter.cpp')
-rw-r--r--llvm/lib/Bitcode/Writer/BitcodeWriter.cpp6
1 files changed, 6 insertions, 0 deletions
diff --git a/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp b/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
index 3d653fe..046dad5 100644
--- a/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
+++ b/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
@@ -2848,6 +2848,12 @@ void ModuleBitcodeWriter::writeConstants(unsigned FirstVal, unsigned LastVal,
Code = bitc::CST_CODE_NO_CFI_VALUE;
Record.push_back(VE.getTypeID(NC->getGlobalValue()->getType()));
Record.push_back(VE.getValueID(NC->getGlobalValue()));
+ } else if (const auto *CPA = dyn_cast<ConstantPtrAuth>(C)) {
+ Code = bitc::CST_CODE_PTRAUTH;
+ Record.push_back(VE.getValueID(CPA->getPointer()));
+ Record.push_back(VE.getValueID(CPA->getKey()));
+ Record.push_back(VE.getValueID(CPA->getDiscriminator()));
+ Record.push_back(VE.getValueID(CPA->getAddrDiscriminator()));
} else {
#ifndef NDEBUG
C->dump();