From 53a6590721c0c4f9ff4ac9a74abf68f32d8c260c Mon Sep 17 00:00:00 2001 From: Anatoly Trosinenko Date: Tue, 21 Oct 2025 17:38:39 +0300 Subject: [PATCH 01/40] Update the docs --- llvm/docs/LangRef.rst | 10 +- llvm/docs/PointerAuth.md | 210 +++++++++++++++++++-------------------- 2 files changed, 107 insertions(+), 113 deletions(-) diff --git a/llvm/docs/LangRef.rst b/llvm/docs/LangRef.rst index 02865f8a29c67..f01c6bcb1b759 100644 --- a/llvm/docs/LangRef.rst +++ b/llvm/docs/LangRef.rst @@ -5309,8 +5309,7 @@ authentication signature embedded into some bits, as described in the `Pointer Authentication `__ document. A '``ptrauth``' constant is simply a constant equivalent to the -``llvm.ptrauth.sign`` intrinsic, potentially fed by a discriminator -``llvm.ptrauth.blend`` if needed. +``llvm.ptrauth.sign`` intrinsic. Its type is the same as the first argument. An integer constant discriminator and an address discriminator may be optionally specified. Otherwise, they have @@ -5320,16 +5319,15 @@ If the address discriminator is ``null`` then the expression is equivalent to .. code-block:: llvm - %tmp = call i64 @llvm.ptrauth.sign(i64 ptrtoint (ptr CST to i64), i32 KEY, i64 DISC) + %tmp = call i64 @llvm.ptrauth.sign(i64 ptrtoint (ptr CST to i64)) [ "ptrauth"(i32 KEY, i64 DISC) ] %val = inttoptr i64 %tmp to ptr Otherwise, the expression is equivalent to: .. code-block:: llvm - %tmp1 = call i64 @llvm.ptrauth.blend(i64 ptrtoint (ptr ADDRDISC to i64), i64 DISC) - %tmp2 = call i64 @llvm.ptrauth.sign(i64 ptrtoint (ptr CST to i64), i32 KEY, i64 %tmp1) - %val = inttoptr i64 %tmp2 to ptr + %tmp = call i64 @llvm.ptrauth.sign(i64 ptrtoint (ptr CST to i64)) [ "ptrauth"(i32 KEY, i64 ptrtoint (ptr ADDRDISC to i64), i64 DISC) ] + %val = inttoptr i64 %tmp to ptr If the deactivation symbol operand ``DS`` has a non-null value, the semantics are as if a :ref:`deactivation-symbol operand bundle diff --git a/llvm/docs/PointerAuth.md b/llvm/docs/PointerAuth.md index 84e0af7577c7d..7981f91e0ed02 100644 --- a/llvm/docs/PointerAuth.md +++ b/llvm/docs/PointerAuth.md @@ -15,9 +15,9 @@ For more details, see the clang documentation page for At the IR level, it is represented using: +* a [call operand bundle](#operand-bundle) (to authenticate called pointers) * a [set of intrinsics](#intrinsics) (to sign/authenticate pointers) * a [signed pointer constant](#constant) (to sign globals) -* a [call operand bundle](#operand-bundle) (to authenticate called pointers) * a [set of function attributes](#function-attributes) (to describe what pointers are signed and how, to control implicit codegen in the backend, as well as preserve invariants in the mid-level optimizer) @@ -31,6 +31,54 @@ This support is used to implement the Darwin arm64e ABI, as well as the ## LLVM IR Representation +### Operand Bundle + +Most pointer authentication intrinsics, as well as authenticated indirect calls, +are parameterized by signing schema description expressed by a `ptrauth` call +operand bundle. A `ptrauth` call operand bundle has one or more `i64` operands, +whose interpretation is target-dependent: `"ptrauth"(i64 op1, i64 op2, ...)`. +A particular target may require some of the operands to be integer constants. + +#### Authenticated indirect calls + +Function pointers used as indirect call targets can be signed when materialized, +and authenticated before calls. This can be accomplished with the +[`llvm.ptrauth.auth`](#llvm-ptrauth-auth) intrinsic, feeding its result to +an indirect call. + +However, that exposes the intermediate, unauthenticated pointer, e.g., if it +gets spilled to the stack. An attacker can then overwrite the pointer in +memory, negating the security benefit provided by pointer authentication. +To prevent that, the `ptrauth` operand bundle may be used: it guarantees that +the intermediate call target is kept in a register and never stored to memory. +This hardening benefit is similar to that provided by +[`llvm.ptrauth.resign`](#llvm-ptrauth-resign)). + +Concretely: + +```llvm +define void @f(ptr %fp) { + call void %fp() [ "ptrauth"(i64 , i64 , ...) ] + ret void +} +``` + +is functionally equivalent to: + +```llvm +define void @f(ptr %fp) { + %fp_i = ptrtoint ptr %fp to i64 + %fp_auth = call i64 @llvm.ptrauth.auth(i64 %fp_i) [ "ptrauth"(i64 , i64 , ...) ] + %fp_auth_p = inttoptr i64 %fp_auth to ptr + call void %fp_auth_p() + ret void +} +``` + +but with the added guarantee that `%fp_i`, `%fp_auth`, and `%fp_auth_p` +are not stored to (and reloaded from) memory. + + ### Intrinsics These intrinsics are provided by LLVM to expose pointer authentication @@ -42,7 +90,7 @@ operations. ##### Syntax: ```llvm -declare i64 @llvm.ptrauth.sign(i64 , i32 , i64 ) +declare i64 @llvm.ptrauth.sign(i64 ) [ "ptrauth"(...) ] ``` ##### Overview: @@ -53,10 +101,9 @@ The '`llvm.ptrauth.sign`' intrinsic signs a raw pointer. ##### Arguments: The `value` argument is the raw pointer value to be signed. -The `key` argument is the identifier of the key to be used to generate the -signed value. -The `discriminator` argument is the additional diversity data to be used as a -discriminator (an integer, an address, or a blend of the two). + +The `ptrauth` call operand bundle describes the signing schema in a +target-specific way. ##### Semantics: @@ -65,8 +112,8 @@ It returns a signed value. If `value` is already a signed value, the behavior is undefined. -If `value` is not a pointer value for which `key` is appropriate, the -behavior is undefined. +If `value` is not a pointer value for which the chosen signing schema is +appropriate, the behavior is undefined. #### '`llvm.ptrauth.auth`' @@ -74,7 +121,7 @@ behavior is undefined. ##### Syntax: ```llvm -declare i64 @llvm.ptrauth.auth(i64 , i32 , i64 ) +declare i64 @llvm.ptrauth.auth(i64 ) [ "ptrauth"(...) ] ``` ##### Overview: @@ -84,16 +131,15 @@ The '`llvm.ptrauth.auth`' intrinsic authenticates a signed pointer. ##### Arguments: The `value` argument is the signed pointer value to be authenticated. -The `key` argument is the identifier of the key that was used to generate -the signed value. -The `discriminator` argument is the additional diversity data to be used as a -discriminator. + +The `ptrauth` call operand bundle describes the signing schema that was used +to generate the signed value in a target-specific way.. ##### Semantics: The '`llvm.ptrauth.auth`' intrinsic implements the `auth`_ operation. It returns a raw pointer value. -If `value` does not have a correct signature for `key` and `discriminator`, +If `value` does not have a correct signature for the signing schema, the intrinsic traps in a target-specific way. @@ -102,7 +148,7 @@ the intrinsic traps in a target-specific way. ##### Syntax: ```llvm -declare i64 @llvm.ptrauth.strip(i64 , i32 ) +declare i64 @llvm.ptrauth.strip(i64 ) [ "ptrauth"(...) ] ``` ##### Overview: @@ -114,8 +160,9 @@ possibly-signed pointer. ##### Arguments: The `value` argument is the signed pointer value to be stripped. -The `key` argument is the identifier of the key that was used to generate -the signed value. + +The `ptrauth` call operand bundle describes the signing schema that was used +to generate the signed value in a target-specific way. ##### Semantics: @@ -123,18 +170,18 @@ The '`llvm.ptrauth.strip`' intrinsic implements the `strip`_ operation. It returns a raw pointer value. It does **not** check that the signature is valid. -`key` should identify a key that is appropriate for `value`, as defined -by the target-specific [keys](#keys)). +The signing schema should be appropriate for `value`, as defined by the +particular target. -If `value` is a raw pointer value, it is returned as-is (provided the `key` +If `value` is a raw pointer value, it is returned as-is (provided the schema is appropriate for the pointer). -If `value` is not a pointer value for which `key` is appropriate, the +If `value` is not a pointer value for which the schema is appropriate, the behavior is target-specific. -If `value` is a signed pointer value, but `key` does not identify the -same key that was used to generate `value`, the behavior is -target-specific. +If `value` is a signed pointer value, but the signing schema described by the +`ptrauth` bundle passed to this call is not compatible with the schema that was +used to generate `value`, the behavior is target-specific. #### '`llvm.ptrauth.resign`' @@ -142,35 +189,31 @@ target-specific. ##### Syntax: ```llvm -declare i64 @llvm.ptrauth.resign(i64 , - i32 , i64 , - i32 , i64 ) +declare i64 @llvm.ptrauth.resign(i64 ) [ "ptrauth"(), "ptrauth"() ] ``` ##### Overview: The '`llvm.ptrauth.resign`' intrinsic re-signs a signed pointer using -a different key and diversity data. +a different signing schema. ##### Arguments: The `value` argument is the signed pointer value to be authenticated. -The `old key` argument is the identifier of the key that was used to generate -the signed value. -The `old discriminator` argument is the additional diversity data to be used -as a discriminator in the auth operation. -The `new key` argument is the identifier of the key to use to generate the + +The first `ptrauth` bundle specifies the signing schema that was used to +generate the signed value. + +The second `ptrauth` bundle specifies the signing schema to use to generate the resigned value. -The `new discriminator` argument is the additional diversity data to be used -as a discriminator in the sign operation. ##### Semantics: -The '`llvm.ptrauth.resign`' intrinsic performs a combined `auth`_ and `sign`_ +The '`llvm.ptrauth.resign`' intrinsic performs a combined `auth` and `sign` operation, without exposing the intermediate raw pointer. It returns a signed pointer value. -If `value` does not have a correct signature for `old key` and -`old discriminator`, the intrinsic traps in a target-specific way. +If `value` does not have a correct signature for the original signing schema, +the intrinsic traps in a target-specific way. #### '`llvm.ptrauth.sign_generic`' @@ -203,32 +246,6 @@ As opposed to [`llvm.ptrauth.sign`](#llvm-ptrauth-sign), it does not interpret `value` as a pointer value. Instead, it is an arbitrary data value. -#### '`llvm.ptrauth.blend`' - -##### Syntax: - -```llvm -declare i64 @llvm.ptrauth.blend(i64
, i64 ) -``` - -##### Overview: - -The '`llvm.ptrauth.blend`' intrinsic blends a pointer address discriminator -with a small integer discriminator to produce a new "blended" discriminator. - -##### Arguments: - -The `address discriminator` argument is a pointer value. -The `integer discriminator` argument is a small integer, as specified by the -target. - -##### Semantics: - -The '`llvm.ptrauth.blend`' intrinsic combines a small integer discriminator -with a pointer address discriminator, in a way that is specified by the target -implementation. - - ### Constant [Intrinsics](#intrinsics) can be used to produce signed pointers dynamically, @@ -250,45 +267,6 @@ is equivalent to: %signedval = call i64 @llvm.ptrauth.sign(ptr CST, i32 KEY, i64 %disc) ``` -### Operand Bundle - -Function pointers used as indirect call targets can be signed when materialized, -and authenticated before calls. This can be accomplished with the -[`llvm.ptrauth.auth`](#llvm-ptrauth-auth) intrinsic, feeding its result to -an indirect call. - -However, that exposes the intermediate, unauthenticated pointer, e.g., if it -gets spilled to the stack. An attacker can then overwrite the pointer in -memory, negating the security benefit provided by pointer authentication. -To prevent that, the `ptrauth` operand bundle may be used: it guarantees that -the intermediate call target is kept in a register and never stored to memory. -This hardening benefit is similar to that provided by -[`llvm.ptrauth.resign`](#llvm-ptrauth-resign)). - -Concretely: - -```llvm -define void @f(void ()* %fp) { - call void %fp() [ "ptrauth"(i32 , i64 ) ] - ret void -} -``` - -is functionally equivalent to: - -```llvm -define void @f(void ()* %fp) { - %fp_i = ptrtoint void ()* %fp to i64 - %fp_auth = call i64 @llvm.ptrauth.auth(i64 %fp_i, i32 , i64 ) - %fp_auth_p = inttoptr i64 %fp_auth to void ()* - call void %fp_auth_p() - ret void -} -``` - -but with the added guarantee that `%fp_i`, `%fp_auth`, and `%fp_auth_p` -are not stored to (and reloaded from) memory. - ### Function Attributes @@ -321,6 +299,21 @@ authentication primitives, based on Armv8.3-A instructions. The Armv8.3-A architecture extension defines the PAuth feature, which provides support for instructions that manipulate Pointer Authentication Codes (PAC). +Sign and auth operations are parameterized by a constant key identifier and +a 64-bit discriminator value. + +On AArch64, `ptrauth` bundle may have from one to three operands, the former +always being constant integer denoting the [key](#keys) identifier and the rest +operands describing the *modifier* being used: +* `"ptrauth"(i64 )`: the operation uses the key `` and modifier is + not applicable. Only used by `@llvm.ptrauth.strip` intrinsic. +* `"ptrauth"(i64 , i64 raw_discr)`: the 64-bit discriminator value is + passed as-is, either constant or not. If constant value is passed, and it + fits in 16 bits, it is safely materialized right before its usage. +* `"ptrauth"(i64 , i64 %addr_modif, i64 )`: the modifier to + be used is computed by [blending](#blend-operation) an integer modifier into + an address modifier. + #### Keys 5 keys are supported by the PAuth feature. @@ -334,6 +327,13 @@ constructs: used implicitly, to implement the [`llvm.ptrauth.sign_generic`](#llvm-ptrauth-sign-generic) intrinsic. +#### Blend operation + +The semantics of the blend operation are specified by the ABI. In both the +ELF PAuth ABI Extension and arm64e, it's a `MOVK` into the high 16 bits. +Consequently, this limits the width of the integer discriminator used in blends +to 16 bits. + #### Instructions The IR [Intrinsics](#intrinsics) described above map onto these @@ -341,10 +341,6 @@ instructions as such: * [`llvm.ptrauth.sign`](#llvm-ptrauth-sign): `PAC{I,D}{A,B}{Z,SP,}` * [`llvm.ptrauth.auth`](#llvm-ptrauth-auth): `AUT{I,D}{A,B}{Z,SP,}` * [`llvm.ptrauth.strip`](#llvm-ptrauth-strip): `XPAC{I,D}` -* [`llvm.ptrauth.blend`](#llvm-ptrauth-blend): The semantics of the blend - operation are specified by the ABI. In both the ELF PAuth ABI Extension and - arm64e, it's a `MOVK` into the high 16 bits. Consequently, this limits - the width of the integer discriminator used in blends to 16 bits. * [`llvm.ptrauth.sign_generic`](#llvm-ptrauth-sign-generic): `PACGA` * [`llvm.ptrauth.resign`](#llvm-ptrauth-resign): `AUT*+PAC*`. These are represented as a single pseudo-instruction in the backend to guarantee that From d5c907b90c7c427546203e8626975f11f53c4ce5 Mon Sep 17 00:00:00 2001 From: Anatoly Trosinenko Date: Fri, 10 Oct 2025 21:48:42 +0300 Subject: [PATCH 02/40] Support three-operand call bundle as an option * Three-operand bundle always implies blend (OK) * Two-operand bundle has three modes: - immediate integer only (OK) - raw value (OK) - result of llvm.ptrauth.blend (compatibility, will be removed later) At ISel time this means PtrAuthInfo-style structs are converted from Key+Discr to homogenous vectors of `Register`s or `SDValue`s with the second operation mode added at the instruction legalization site. --- .../llvm/CodeGen/GlobalISel/CallLowering.h | 3 +- llvm/include/llvm/CodeGen/TargetLowering.h | 3 +- llvm/include/llvm/IR/Constants.h | 7 +++ llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp | 11 ++-- .../SelectionDAG/SelectionDAGBuilder.cpp | 18 +++---- llvm/lib/IR/Constants.cpp | 51 +++++++++++++++++++ llvm/lib/IR/Verifier.cpp | 29 ++++++----- .../Target/AArch64/AArch64ISelLowering.cpp | 21 +++++--- llvm/lib/Target/AArch64/AArch64InstrInfo.td | 8 +-- .../AArch64/GISel/AArch64CallLowering.cpp | 19 +++---- .../AArch64/GISel/AArch64GlobalISelUtils.cpp | 11 +++- .../AArch64/GISel/AArch64GlobalISelUtils.h | 2 +- .../GISel/AArch64InstructionSelector.cpp | 6 +-- .../lib/Transforms/IPO/WholeProgramDevirt.cpp | 1 + .../InstCombine/InstCombineCalls.cpp | 5 +- llvm/test/CodeGen/AArch64/ptrauth-call.ll | 16 ++++++ 16 files changed, 147 insertions(+), 64 deletions(-) diff --git a/llvm/include/llvm/CodeGen/GlobalISel/CallLowering.h b/llvm/include/llvm/CodeGen/GlobalISel/CallLowering.h index fea900f37ec74..205aba89bc4aa 100644 --- a/llvm/include/llvm/CodeGen/GlobalISel/CallLowering.h +++ b/llvm/include/llvm/CodeGen/GlobalISel/CallLowering.h @@ -98,8 +98,7 @@ class LLVM_ABI CallLowering { }; struct PtrAuthInfo { - uint64_t Key; - Register Discriminator; + SmallVector Operands; }; struct CallLoweringInfo { diff --git a/llvm/include/llvm/CodeGen/TargetLowering.h b/llvm/include/llvm/CodeGen/TargetLowering.h index 149366c69bdcc..e8392a3b18e9e 100644 --- a/llvm/include/llvm/CodeGen/TargetLowering.h +++ b/llvm/include/llvm/CodeGen/TargetLowering.h @@ -4720,8 +4720,7 @@ class LLVM_ABI TargetLowering : public TargetLoweringBase { /// pointer-authenticating indirect calls. It is equivalent to the "ptrauth" /// operand bundle found on the call instruction, if any. struct PtrAuthInfo { - uint64_t Key; - SDValue Discriminator; + SmallVector Operands; }; /// This structure contains all information that is necessary for lowering diff --git a/llvm/include/llvm/IR/Constants.h b/llvm/include/llvm/IR/Constants.h index e3f2eb9fa44b8..514fbfa3d48e8 100644 --- a/llvm/include/llvm/IR/Constants.h +++ b/llvm/include/llvm/IR/Constants.h @@ -1103,6 +1103,13 @@ class ConstantPtrAuth final : public Constant { const Value *Discriminator, const DataLayout &DL) const; + bool isKnownCompatibleWith(const Value *Key, + const Value *AddrDisc, + const Value *IntDisc, + const DataLayout &DL) const; + bool isKnownCompatibleWith(ArrayRef BundleOperands, + const DataLayout &DL) const; + /// Methods for support type inquiry through isa, cast, and dyn_cast: static bool classof(const Value *V) { return V->getValueID() == ConstantPtrAuthVal; diff --git a/llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp b/llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp index 63ed7d598455f..4267012c3777f 100644 --- a/llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp +++ b/llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp @@ -2751,19 +2751,18 @@ bool IRTranslator::translateCallBase(const CallBase &CB, // Functions should never be ptrauth-called directly. assert(!CB.getCalledFunction() && "invalid direct ptrauth call"); - const Value *Key = Bundle->Inputs[0]; - const Value *Discriminator = Bundle->Inputs[1]; + assert(!isa(CB)); // Look through ptrauth constants to try to eliminate the matching bundle // and turn this into a direct call with no ptrauth. // CallLowering will use the raw pointer if it doesn't find the PAI. const auto *CalleeCPA = dyn_cast(CB.getCalledOperand()); if (!CalleeCPA || !isa(CalleeCPA->getPointer()) || - !CalleeCPA->isKnownCompatibleWith(Key, Discriminator, *DL)) { + !CalleeCPA->isKnownCompatibleWith(Bundle->Inputs, *DL)) { // If we can't make it direct, package the bundle into PAI. - Register DiscReg = getOrCreateVReg(*Discriminator); - PAI = CallLowering::PtrAuthInfo{cast(Key)->getZExtValue(), - DiscReg}; + PAI = CallLowering::PtrAuthInfo(); + for (const Value *V : Bundle->Inputs) + PAI->Operands.push_back(getOrCreateVReg(*V)); } } diff --git a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp index 2caf847370383..32b3ad7c3a903 100644 --- a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp +++ b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp @@ -9770,20 +9770,12 @@ void SelectionDAGBuilder::LowerCallSiteWithPtrAuthBundle( auto PAB = CB.getOperandBundle("ptrauth"); const Value *CalleeV = CB.getCalledOperand(); - // Gather the call ptrauth data from the operand bundle: - // [ i32 , i64 ] - const auto *Key = cast(PAB->Inputs[0]); - const Value *Discriminator = PAB->Inputs[1]; - - assert(Key->getType()->isIntegerTy(32) && "Invalid ptrauth key"); - assert(Discriminator->getType()->isIntegerTy(64) && - "Invalid ptrauth discriminator"); + assert(!isa(CB)); // Look through ptrauth constants to find the raw callee. // Do a direct unauthenticated call if we found it and everything matches. if (const auto *CalleeCPA = dyn_cast(CalleeV)) - if (CalleeCPA->isKnownCompatibleWith(Key, Discriminator, - DAG.getDataLayout())) + if (CalleeCPA->isKnownCompatibleWith(PAB->Inputs, DAG.getDataLayout())) return LowerCallTo(CB, getValue(CalleeCPA->getPointer()), CB.isTailCall(), CB.isMustTailCall(), EHPadBB); @@ -9791,8 +9783,10 @@ void SelectionDAGBuilder::LowerCallSiteWithPtrAuthBundle( assert(!isa(CalleeV) && "invalid direct ptrauth call"); // Otherwise, do an authenticated indirect call. - TargetLowering::PtrAuthInfo PAI = {Key->getZExtValue(), - getValue(Discriminator)}; + + TargetLowering::PtrAuthInfo PAI; + for (const Value *V : PAB->Inputs) + PAI.Operands.push_back(getValue(V)); LowerCallTo(CB, getValue(CalleeV), CB.isTailCall(), CB.isMustTailCall(), EHPadBB, &PAI); diff --git a/llvm/lib/IR/Constants.cpp b/llvm/lib/IR/Constants.cpp index 6b82da140256f..185eeb922f30e 100644 --- a/llvm/lib/IR/Constants.cpp +++ b/llvm/lib/IR/Constants.cpp @@ -2152,6 +2152,48 @@ bool ConstantPtrAuth::hasSpecialAddressDiscriminator(uint64_t Value) const { return IntVal->getValue() == Value; } +// For now, this method is to be called for three-operand bundles only! +bool ConstantPtrAuth::isKnownCompatibleWith(const Value *Key, + const Value *AddrDiscriminator, + const Value *IntDisc, + const DataLayout &DL) const { + + if (getKey() != Key) + return false; + + // Three-operand bundle implies blend! + if (!hasAddressDiscriminator()) + return false; + + if (getDiscriminator() != IntDisc) + return false; + + // FIXME: Copied from the original method: + + // Discriminators are i64, so the provided addr disc may be a ptrtoint. + if (auto *Cast = dyn_cast(AddrDiscriminator)) + AddrDiscriminator = Cast->getPointerOperand(); + + // Beyond that, we're only interested in compatible pointers. + if (getAddrDiscriminator()->getType() != AddrDiscriminator->getType()) + return false; + + // These are often the same constant GEP, making them trivially equivalent. + if (getAddrDiscriminator() == AddrDiscriminator) + return true; + + // Finally, they may be equivalent base+offset expressions. + APInt Off1(DL.getIndexTypeSizeInBits(getAddrDiscriminator()->getType()), 0); + auto *Base1 = getAddrDiscriminator()->stripAndAccumulateConstantOffsets( + DL, Off1, /*AllowNonInbounds=*/true); + + APInt Off2(DL.getIndexTypeSizeInBits(AddrDiscriminator->getType()), 0); + auto *Base2 = AddrDiscriminator->stripAndAccumulateConstantOffsets( + DL, Off2, /*AllowNonInbounds=*/true); + + return Base1 == Base2 && Off1 == Off2; +} + bool ConstantPtrAuth::isKnownCompatibleWith(const Value *Key, const Value *Discriminator, const DataLayout &DL) const { @@ -2217,6 +2259,15 @@ bool ConstantPtrAuth::isKnownCompatibleWith(const Value *Key, return Base1 == Base2 && Off1 == Off2; } +bool ConstantPtrAuth::isKnownCompatibleWith(ArrayRef BundleOperands, + const DataLayout &DL) const { + if (BundleOperands.size() == 3) + return isKnownCompatibleWith(BundleOperands[0], BundleOperands[1], + BundleOperands[2], DL); + return isKnownCompatibleWith(BundleOperands[0], BundleOperands[1], DL); +} + + //---- ConstantExpr::get() implementations. // diff --git a/llvm/lib/IR/Verifier.cpp b/llvm/lib/IR/Verifier.cpp index a1e14d8f25bf7..4809d75843523 100644 --- a/llvm/lib/IR/Verifier.cpp +++ b/llvm/lib/IR/Verifier.cpp @@ -3971,8 +3971,8 @@ void Verifier::visitCallBase(CallBase &Call) { bool FoundDeoptBundle = false, FoundFuncletBundle = false, FoundGCTransitionBundle = false, FoundCFGuardTargetBundle = false, FoundPreallocatedBundle = false, FoundGCLiveBundle = false, - FoundPtrauthBundle = false, FoundKCFIBundle = false, - FoundAttachedCallBundle = false; + FoundKCFIBundle = false, FoundAttachedCallBundle = false; + unsigned NumPtrauthBundles = 0; for (unsigned i = 0, e = Call.getNumOperandBundles(); i < e; ++i) { OperandBundleUse BU = Call.getOperandBundleAt(i); uint32_t Tag = BU.getTagID(); @@ -3998,15 +3998,11 @@ void Verifier::visitCallBase(CallBase &Call) { Check(BU.Inputs.size() == 1, "Expected exactly one cfguardtarget bundle operand", Call); } else if (Tag == LLVMContext::OB_ptrauth) { - Check(!FoundPtrauthBundle, "Multiple ptrauth operand bundles", Call); - FoundPtrauthBundle = true; - Check(BU.Inputs.size() == 2, - "Expected exactly two ptrauth bundle operands", Call); - Check(isa(BU.Inputs[0]) && - BU.Inputs[0]->getType()->isIntegerTy(32), - "Ptrauth bundle key operand must be an i32 constant", Call); - Check(BU.Inputs[1]->getType()->isIntegerTy(64), - "Ptrauth bundle discriminator operand must be an i64", Call); + ++NumPtrauthBundles; + Check(!BU.Inputs.empty(), "Expected non-empty ptrauth bundle", Call); + for (Value *V : BU.Inputs) + Check(V->getType()->isIntegerTy(32) || V->getType()->isIntegerTy(64), + "Ptrauth bundle must only contain i32 or i64 operands", Call); } else if (Tag == LLVMContext::OB_kcfi) { Check(!FoundKCFIBundle, "Multiple kcfi operand bundles", Call); FoundKCFIBundle = true; @@ -4039,8 +4035,17 @@ void Verifier::visitCallBase(CallBase &Call) { } // Verify that callee and callsite agree on whether to use pointer auth. - Check(!(Call.getCalledFunction() && FoundPtrauthBundle), + Check(!(Call.getCalledFunction() && NumPtrauthBundles), "Direct call cannot have a ptrauth bundle", Call); + switch (Call.getIntrinsicID()) { + case Intrinsic::not_intrinsic: + Check(NumPtrauthBundles <= 1, + "Multiple ptrauth operand bundles on a function call", Call); + break; + default: + Check(NumPtrauthBundles == 0, "Unexpected ptrauth bundle", Call); + break; + } // Verify that each inlinable callsite of a debug-info-bearing function in a // debug-info-bearing function has a debug location attached to it. Failure to diff --git a/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp b/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp index a83185d6ade20..03e500d9d794a 100644 --- a/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp +++ b/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp @@ -352,11 +352,17 @@ static bool isZeroingInactiveLanes(SDValue Op) { } static std::tuple -extractPtrauthBlendDiscriminators(SDValue Disc, SelectionDAG *DAG) { - SDLoc DL(Disc); +extractPtrauthBlendDiscriminators(SmallVector Operands, SelectionDAG *DAG) { SDValue AddrDisc; SDValue ConstDisc; + if (Operands.size() == 3) + return {Operands[2], Operands[1]}; + + // Stay fully compatible for now. + SDValue Disc = Operands[1]; + SDLoc DL(Disc); + // If this is a blend, remember the constant and address discriminators. // Otherwise, it's either a constant discriminator, or a non-blended // address discriminator. @@ -10157,20 +10163,19 @@ AArch64TargetLowering::LowerCall(CallLoweringInfo &CLI, } if (CLI.PAI) { - const uint64_t Key = CLI.PAI->Key; - assert((Key == AArch64PACKey::IA || Key == AArch64PACKey::IB) && - "Invalid auth call key"); + // assert((Key == AArch64PACKey::IA || Key == AArch64PACKey::IB) && + // "Invalid auth call key"); // Split the discriminator into address/integer components. SDValue AddrDisc, IntDisc; std::tie(IntDisc, AddrDisc) = - extractPtrauthBlendDiscriminators(CLI.PAI->Discriminator, &DAG); + extractPtrauthBlendDiscriminators(CLI.PAI->Operands, &DAG); if (Opc == AArch64ISD::CALL_RVMARKER) Opc = AArch64ISD::AUTH_CALL_RVMARKER; else Opc = IsTailCall ? AArch64ISD::AUTH_TC_RETURN : AArch64ISD::AUTH_CALL; - Ops.push_back(DAG.getTargetConstant(Key, DL, MVT::i32)); + Ops.push_back(CLI.PAI->Operands[0]); Ops.push_back(IntDisc); Ops.push_back(AddrDisc); } @@ -10674,7 +10679,7 @@ AArch64TargetLowering::LowerDarwinGlobalTLSAddress(SDValue Op, // With ptrauth-calls, the tlv access thunk pointer is authenticated (IA, 0). if (DAG.getMachineFunction().getFunction().hasFnAttribute("ptrauth-calls")) { Opcode = AArch64ISD::AUTH_CALL; - Ops.push_back(DAG.getTargetConstant(AArch64PACKey::IA, DL, MVT::i32)); + Ops.push_back(DAG.getConstant(AArch64PACKey::IA, DL, MVT::i32)); Ops.push_back(DAG.getTargetConstant(0, DL, MVT::i64)); // Integer Disc. Ops.push_back(DAG.getRegister(AArch64::NoRegister, MVT::i64)); // Addr Disc. } diff --git a/llvm/lib/Target/AArch64/AArch64InstrInfo.td b/llvm/lib/Target/AArch64/AArch64InstrInfo.td index da93a2b13fc11..6ebc6557aebfa 100644 --- a/llvm/lib/Target/AArch64/AArch64InstrInfo.td +++ b/llvm/lib/Target/AArch64/AArch64InstrInfo.td @@ -2127,7 +2127,7 @@ let Predicates = [HasPAuth] in { // the kernel, notably on Darwin. def BLRA : Pseudo<(outs), (ins GPR64noip:$Rn, i32imm:$Key, i64imm:$Disc, GPR64:$AddrDisc), - [(AArch64authcall GPR64noip:$Rn, timm:$Key, timm:$Disc, + [(AArch64authcall GPR64noip:$Rn, imm:$Key, timm:$Disc, GPR64:$AddrDisc)]>, Sched<[]> { let isCodeGenOnly = 1; let hasSideEffects = 1; @@ -2143,7 +2143,7 @@ let Predicates = [HasPAuth] in { (outs), (ins i64imm:$rvfunc, i32imm:$withmarker, GPR64noip:$Rn, i32imm:$Key, i64imm:$Disc, GPR64:$AddrDisc), [(AArch64authcall_rvmarker tglobaladdr:$rvfunc, timm:$withmarker, - GPR64noip:$Rn, timm:$Key, timm:$Disc, + GPR64noip:$Rn, imm:$Key, timm:$Disc, GPR64:$AddrDisc)]>, Sched<[]> { let isCodeGenOnly = 1; let isCall = 1; @@ -2304,14 +2304,14 @@ let Predicates = [HasPAuth] in { } let Predicates = [TailCallAny] in - def : Pat<(AArch64authtcret tcGPRnotx16x17:$dst, (i32 timm:$FPDiff), (i32 timm:$Key), + def : Pat<(AArch64authtcret tcGPRnotx16x17:$dst, (i32 timm:$FPDiff), (i32 imm:$Key), (i64 timm:$Disc), tcGPR64:$AddrDisc), (AUTH_TCRETURN tcGPRnotx16x17:$dst, imm:$FPDiff, imm:$Key, imm:$Disc, tcGPR64:$AddrDisc)>; let Predicates = [TailCallX16X17] in def : Pat<(AArch64authtcret tcGPRx16x17:$dst, (i32 timm:$FPDiff), - (i32 timm:$Key), (i64 timm:$Disc), + (i32 imm:$Key), (i64 timm:$Disc), tcGPRnotx16x17:$AddrDisc), (AUTH_TCRETURN_BTI tcGPRx16x17:$dst, imm:$FPDiff, imm:$Key, imm:$Disc, tcGPRnotx16x17:$AddrDisc)>; diff --git a/llvm/lib/Target/AArch64/GISel/AArch64CallLowering.cpp b/llvm/lib/Target/AArch64/GISel/AArch64CallLowering.cpp index 7907a3c283624..8ea16b1e5c02c 100644 --- a/llvm/lib/Target/AArch64/GISel/AArch64CallLowering.cpp +++ b/llvm/lib/Target/AArch64/GISel/AArch64CallLowering.cpp @@ -1079,7 +1079,8 @@ static unsigned getCallOpcode(const MachineFunction &CallerF, bool IsIndirect, return IsIndirect ? getBLRCallOpcode(CallerF) : (unsigned)AArch64::BL; assert(IsIndirect && "Direct call should not be authenticated"); - assert((PAI->Key == AArch64PACKey::IA || PAI->Key == AArch64PACKey::IB) && + const unsigned Key = getIConstantVRegVal(PAI->Operands[0], MRI)->getZExtValue(); + assert((Key == AArch64PACKey::IA || Key == AArch64PACKey::IB) && "Invalid auth call key"); return AArch64::BLRA; } @@ -1165,15 +1166,15 @@ bool AArch64CallLowering::lowerTailCall( // Authenticated tail calls always take key/discriminator arguments. if (Opc == AArch64::AUTH_TCRETURN || Opc == AArch64::AUTH_TCRETURN_BTI) { - assert((Info.PAI->Key == AArch64PACKey::IA || - Info.PAI->Key == AArch64PACKey::IB) && + const unsigned Key = getIConstantVRegVal(Info.PAI->Operands[0], MRI)->getZExtValue(); + assert((Key == AArch64PACKey::IA || Key == AArch64PACKey::IB) && "Invalid auth call key"); - MIB.addImm(Info.PAI->Key); + MIB.addImm(Key); Register AddrDisc = 0; uint16_t IntDisc = 0; std::tie(IntDisc, AddrDisc) = - extractPtrauthBlendDiscriminators(Info.PAI->Discriminator, MRI); + extractPtrauthBlendDiscriminators(Info.PAI->Operands, MRI); MIB.addImm(IntDisc); MIB.addUse(AddrDisc); @@ -1440,15 +1441,15 @@ bool AArch64CallLowering::lowerCall(MachineIRBuilder &MIRBuilder, Mask = getMaskForArgs(OutArgs, Info, *TRI, MF); if (Opc == AArch64::BLRA || Opc == AArch64::BLRA_RVMARKER) { - assert((Info.PAI->Key == AArch64PACKey::IA || - Info.PAI->Key == AArch64PACKey::IB) && + const unsigned Key = getIConstantVRegVal(Info.PAI->Operands[0], MRI)->getZExtValue(); + assert((Key == AArch64PACKey::IA || Key == AArch64PACKey::IB) && "Invalid auth call key"); - MIB.addImm(Info.PAI->Key); + MIB.addImm(Key); Register AddrDisc = 0; uint16_t IntDisc = 0; std::tie(IntDisc, AddrDisc) = - extractPtrauthBlendDiscriminators(Info.PAI->Discriminator, MRI); + extractPtrauthBlendDiscriminators(Info.PAI->Operands, MRI); MIB.addImm(IntDisc); MIB.addUse(AddrDisc); diff --git a/llvm/lib/Target/AArch64/GISel/AArch64GlobalISelUtils.cpp b/llvm/lib/Target/AArch64/GISel/AArch64GlobalISelUtils.cpp index 1a1507512c899..8ea2844b69fcc 100644 --- a/llvm/lib/Target/AArch64/GISel/AArch64GlobalISelUtils.cpp +++ b/llvm/lib/Target/AArch64/GISel/AArch64GlobalISelUtils.cpp @@ -97,8 +97,17 @@ bool AArch64GISelUtils::tryEmitBZero(MachineInstr &MI, } std::tuple -AArch64GISelUtils::extractPtrauthBlendDiscriminators(Register Disc, +AArch64GISelUtils::extractPtrauthBlendDiscriminators(SmallVector Operands, MachineRegisterInfo &MRI) { + if (Operands.size() == 3) { + uint64_t ConstDiscVal = getIConstantVRegVal(Operands[2], MRI)->getZExtValue(); + assert(isUInt<16>(ConstDiscVal)); + return { ConstDiscVal, Operands[1] }; + } + + // Stay fully compatible for now. + Register Disc = Operands[1]; + Register AddrDisc = Disc; uint16_t ConstDisc = 0; diff --git a/llvm/lib/Target/AArch64/GISel/AArch64GlobalISelUtils.h b/llvm/lib/Target/AArch64/GISel/AArch64GlobalISelUtils.h index 9ef833f0fc0ca..285d904a3f54a 100644 --- a/llvm/lib/Target/AArch64/GISel/AArch64GlobalISelUtils.h +++ b/llvm/lib/Target/AArch64/GISel/AArch64GlobalISelUtils.h @@ -57,7 +57,7 @@ bool tryEmitBZero(MachineInstr &MI, MachineIRBuilder &MIRBuilder, bool MinSize); /// and address parts, cracking a ptrauth_blend intrinsic if there is one. /// \returns integer/address disc. parts, with NoRegister if no address disc. std::tuple -extractPtrauthBlendDiscriminators(Register Disc, MachineRegisterInfo &MRI); +extractPtrauthBlendDiscriminators(SmallVector Operands, MachineRegisterInfo &MRI); /// Find the AArch64 condition codes necessary to represent \p P for a scalar /// floating point comparison. diff --git a/llvm/lib/Target/AArch64/GISel/AArch64InstructionSelector.cpp b/llvm/lib/Target/AArch64/GISel/AArch64InstructionSelector.cpp index f9db39e5f8622..8c1751e874e9c 100644 --- a/llvm/lib/Target/AArch64/GISel/AArch64InstructionSelector.cpp +++ b/llvm/lib/Target/AArch64/GISel/AArch64InstructionSelector.cpp @@ -6626,12 +6626,12 @@ bool AArch64InstructionSelector::selectIntrinsic(MachineInstr &I, Register AUTAddrDisc = AUTDisc; uint16_t AUTConstDiscC = 0; std::tie(AUTConstDiscC, AUTAddrDisc) = - extractPtrauthBlendDiscriminators(AUTDisc, MRI); + extractPtrauthBlendDiscriminators({0, AUTDisc}, MRI); Register PACAddrDisc = PACDisc; uint16_t PACConstDiscC = 0; std::tie(PACConstDiscC, PACAddrDisc) = - extractPtrauthBlendDiscriminators(PACDisc, MRI); + extractPtrauthBlendDiscriminators({0, PACDisc}, MRI); MIB.buildCopy({AArch64::X16}, {ValReg}); MIB.buildInstr(TargetOpcode::IMPLICIT_DEF, {AArch64::X17}, {}); @@ -6658,7 +6658,7 @@ bool AArch64InstructionSelector::selectIntrinsic(MachineInstr &I, Register AUTAddrDisc = AUTDisc; uint16_t AUTConstDiscC = 0; std::tie(AUTConstDiscC, AUTAddrDisc) = - extractPtrauthBlendDiscriminators(AUTDisc, MRI); + extractPtrauthBlendDiscriminators({0, AUTDisc}, MRI); if (STI.isX16X17Safer()) { MIB.buildCopy({AArch64::X16}, {ValReg}); diff --git a/llvm/lib/Transforms/IPO/WholeProgramDevirt.cpp b/llvm/lib/Transforms/IPO/WholeProgramDevirt.cpp index 4642da0abdc13..e71f9000a9c87 100644 --- a/llvm/lib/Transforms/IPO/WholeProgramDevirt.cpp +++ b/llvm/lib/Transforms/IPO/WholeProgramDevirt.cpp @@ -1270,6 +1270,7 @@ void DevirtModule::applySingleImplDevirt(VTableSlotInfo &SlotInfo, CB.setMetadata(LLVMContext::MD_callees, nullptr); if (CB.getCalledOperand() && CB.getOperandBundle(LLVMContext::OB_ptrauth)) { + assert(!isa(CB)); auto *NewCS = CallBase::removeOperandBundle( &CB, LLVMContext::OB_ptrauth, CB.getIterator()); CB.replaceAllUsesWith(NewCS); diff --git a/llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp b/llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp index 743c4f574e131..a39782317edc5 100644 --- a/llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp +++ b/llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp @@ -4385,11 +4385,8 @@ Instruction *InstCombinerImpl::foldPtrAuthConstantCallee(CallBase &Call) { if (!PAB) return nullptr; - auto *Key = cast(PAB->Inputs[0]); - Value *Discriminator = PAB->Inputs[1]; - // If the bundle doesn't match, this is probably going to fail to auth. - if (!CPA->isKnownCompatibleWith(Key, Discriminator, DL)) + if (!CPA->isKnownCompatibleWith(PAB->Inputs, DL)) return nullptr; // If the bundle matches the constant, proceed in making this a direct call. diff --git a/llvm/test/CodeGen/AArch64/ptrauth-call.ll b/llvm/test/CodeGen/AArch64/ptrauth-call.ll index fc555a882be2c..e0b29c6a0f62d 100644 --- a/llvm/test/CodeGen/AArch64/ptrauth-call.ll +++ b/llvm/test/CodeGen/AArch64/ptrauth-call.ll @@ -514,6 +514,22 @@ define i32 @test_direct_call_addr_blend() #0 { ret i32 %tmp1 } +define i32 @test_direct_call_addr_blending_bundle() #0 { +; DARWIN-LABEL: test_direct_call_addr_blending_bundle: +; DARWIN-NEXT: stp x29, x30, [sp, #-16]! +; DARWIN-NEXT: bl _f +; DARWIN-NEXT: ldp x29, x30, [sp], #16 +; DARWIN-NEXT: ret +; +; ELF-LABEL: test_direct_call_addr_blending_bundle: +; ELF-NEXT: str x30, [sp, #-16]! +; ELF-NEXT: bl f +; ELF-NEXT: ldr x30, [sp], #16 +; ELF-NEXT: ret + %tmp1 = call i32 ptrauth(ptr @f, i32 1, i64 42, ptr @f.ref.ib.42.addr)() [ "ptrauth"(i32 1, i64 ptrtoint (ptr @f.ref.ib.42.addr to i64), i64 42) ] + ret i32 %tmp1 +} + define i32 @test_direct_call_addr_gep_different_index_types() #0 { ; DARWIN-LABEL: test_direct_call_addr_gep_different_index_types: ; DARWIN-NEXT: stp x29, x30, [sp, #-16]! From 9f7b13f473f6c922cb248e2f3f456af2612fba38 Mon Sep 17 00:00:00 2001 From: Anatoly Trosinenko Date: Tue, 21 Oct 2025 19:25:24 +0300 Subject: [PATCH 03/40] Support D-keys in auth call pseudos --- llvm/lib/Target/AArch64/AArch64AsmPrinter.cpp | 41 ++++++- .../Target/AArch64/AArch64ISelLowering.cpp | 3 - .../AArch64/GISel/AArch64CallLowering.cpp | 7 -- .../InstCombine/InstCombineCalls.cpp | 5 - llvm/test/CodeGen/AArch64/ptrauth-call.ll | 110 ++++++++++++++++++ .../InstCombine/ptrauth-intrinsics-call.ll | 5 +- 6 files changed, 147 insertions(+), 24 deletions(-) diff --git a/llvm/lib/Target/AArch64/AArch64AsmPrinter.cpp b/llvm/lib/Target/AArch64/AArch64AsmPrinter.cpp index 8267414e78955..bcd2aae224502 100644 --- a/llvm/lib/Target/AArch64/AArch64AsmPrinter.cpp +++ b/llvm/lib/Target/AArch64/AArch64AsmPrinter.cpp @@ -2280,8 +2280,6 @@ void AArch64AsmPrinter::emitPtrauthBranch(const MachineInstr *MI) { unsigned BrTarget = MI->getOperand(0).getReg(); auto Key = (AArch64PACKey::ID)MI->getOperand(1).getImm(); - assert((Key == AArch64PACKey::IA || Key == AArch64PACKey::IB) && - "Invalid auth call key"); uint64_t Disc = MI->getOperand(2).getImm(); assert(isUInt<16>(Disc)); @@ -2315,6 +2313,23 @@ void AArch64AsmPrinter::emitPtrauthBranch(const MachineInstr *MI) { AddrDiscIsImplicitDef); bool IsZeroDisc = DiscReg == AArch64::XZR; + if (Key == AArch64PACKey::DA || Key == AArch64PACKey::DB) { + // Have to emit separate auth and branch instructions for D-key. + MCInst AUTInst; + AUTInst.setOpcode(getAUTOpcodeForKey(Key, IsZeroDisc)); + AUTInst.addOperand(MCOperand::createReg(BrTarget)); + AUTInst.addOperand(MCOperand::createReg(BrTarget)); + if (!IsZeroDisc) + AUTInst.addOperand(MCOperand::createReg(DiscReg)); + EmitToStreamer(AUTInst); + + MCInst BranchInst; + BranchInst.setOpcode(IsCall ? AArch64::BLR : AArch64::BR); + BranchInst.addOperand(MCOperand::createReg(BrTarget)); + EmitToStreamer(BranchInst); + return; + } + unsigned Opc; if (IsCall) { if (Key == AArch64PACKey::IA) @@ -3258,9 +3273,7 @@ void AArch64AsmPrinter::emitInstruction(const MachineInstr *MI) { case AArch64::AUTH_TCRETURN: case AArch64::AUTH_TCRETURN_BTI: { Register Callee = MI->getOperand(0).getReg(); - const uint64_t Key = MI->getOperand(2).getImm(); - assert((Key == AArch64PACKey::IA || Key == AArch64PACKey::IB) && - "Invalid auth key for tail-call return"); + const auto Key = (AArch64PACKey::ID)MI->getOperand(2).getImm(); const uint64_t Disc = MI->getOperand(3).getImm(); assert(isUInt<16>(Disc) && "Integer discriminator is too wide"); @@ -3285,6 +3298,24 @@ void AArch64AsmPrinter::emitInstruction(const MachineInstr *MI) { AddrDiscIsImplicitDef); const bool IsZero = DiscReg == AArch64::XZR; + + if (Key == AArch64PACKey::DA || Key == AArch64PACKey::DB) { + // Have to emit separate auth and branch instructions for D-key. + MCInst AUTInst; + AUTInst.setOpcode(getAUTOpcodeForKey(Key, IsZero)); + AUTInst.addOperand(MCOperand::createReg(Callee)); + AUTInst.addOperand(MCOperand::createReg(Callee)); + if (!IsZero) + AUTInst.addOperand(MCOperand::createReg(DiscReg)); + EmitToStreamer(AUTInst); + + MCInst BranchInst; + BranchInst.setOpcode(AArch64::BR); + BranchInst.addOperand(MCOperand::createReg(Callee)); + EmitToStreamer(BranchInst); + return; + } + const unsigned Opcodes[2][2] = {{AArch64::BRAA, AArch64::BRAAZ}, {AArch64::BRAB, AArch64::BRABZ}}; diff --git a/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp b/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp index 03e500d9d794a..b5527a99c6fe6 100644 --- a/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp +++ b/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp @@ -10163,9 +10163,6 @@ AArch64TargetLowering::LowerCall(CallLoweringInfo &CLI, } if (CLI.PAI) { - // assert((Key == AArch64PACKey::IA || Key == AArch64PACKey::IB) && - // "Invalid auth call key"); - // Split the discriminator into address/integer components. SDValue AddrDisc, IntDisc; std::tie(IntDisc, AddrDisc) = diff --git a/llvm/lib/Target/AArch64/GISel/AArch64CallLowering.cpp b/llvm/lib/Target/AArch64/GISel/AArch64CallLowering.cpp index 8ea16b1e5c02c..57bce3584110d 100644 --- a/llvm/lib/Target/AArch64/GISel/AArch64CallLowering.cpp +++ b/llvm/lib/Target/AArch64/GISel/AArch64CallLowering.cpp @@ -1079,9 +1079,6 @@ static unsigned getCallOpcode(const MachineFunction &CallerF, bool IsIndirect, return IsIndirect ? getBLRCallOpcode(CallerF) : (unsigned)AArch64::BL; assert(IsIndirect && "Direct call should not be authenticated"); - const unsigned Key = getIConstantVRegVal(PAI->Operands[0], MRI)->getZExtValue(); - assert((Key == AArch64PACKey::IA || Key == AArch64PACKey::IB) && - "Invalid auth call key"); return AArch64::BLRA; } @@ -1167,8 +1164,6 @@ bool AArch64CallLowering::lowerTailCall( // Authenticated tail calls always take key/discriminator arguments. if (Opc == AArch64::AUTH_TCRETURN || Opc == AArch64::AUTH_TCRETURN_BTI) { const unsigned Key = getIConstantVRegVal(Info.PAI->Operands[0], MRI)->getZExtValue(); - assert((Key == AArch64PACKey::IA || Key == AArch64PACKey::IB) && - "Invalid auth call key"); MIB.addImm(Key); Register AddrDisc = 0; @@ -1442,8 +1437,6 @@ bool AArch64CallLowering::lowerCall(MachineIRBuilder &MIRBuilder, if (Opc == AArch64::BLRA || Opc == AArch64::BLRA_RVMARKER) { const unsigned Key = getIConstantVRegVal(Info.PAI->Operands[0], MRI)->getZExtValue(); - assert((Key == AArch64PACKey::IA || Key == AArch64PACKey::IB) && - "Invalid auth call key"); MIB.addImm(Key); Register AddrDisc = 0; diff --git a/llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp b/llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp index a39782317edc5..07fe253e75a4a 100644 --- a/llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp +++ b/llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp @@ -4333,11 +4333,6 @@ Instruction *InstCombinerImpl::foldPtrAuthIntrinsicCallee(CallBase &Call) { if (II->getOperand(4) != PtrAuthBundleOrNone->Inputs[1]) return nullptr; - // Resign input (auth) key should also match: we can't change the key on - // the new call we're generating, because we don't know what keys are valid. - if (II->getOperand(1) != PtrAuthBundleOrNone->Inputs[0]) - return nullptr; - Value *NewBundleOps[] = {II->getOperand(1), II->getOperand(2)}; NewBundles.emplace_back("ptrauth", NewBundleOps); NewCallee = II->getOperand(0); diff --git a/llvm/test/CodeGen/AArch64/ptrauth-call.ll b/llvm/test/CodeGen/AArch64/ptrauth-call.ll index e0b29c6a0f62d..29081566d836e 100644 --- a/llvm/test/CodeGen/AArch64/ptrauth-call.ll +++ b/llvm/test/CodeGen/AArch64/ptrauth-call.ll @@ -167,6 +167,116 @@ define i32 @test_tailcall_ib_var(ptr %arg0, ptr %arg1) #0 { ret i32 %tmp1 } +define i32 @test_call_da_0(ptr %arg0) #0 { +; DARWIN-LABEL: test_call_da_0: +; DARWIN-NEXT: stp x29, x30, [sp, #-16]! +; DARWIN-NEXT: autdza x0 +; DARWIN-NEXT: blr x0 +; DARWIN-NEXT: ldp x29, x30, [sp], #16 +; DARWIN-NEXT: ret +; +; ELF-LABEL: test_call_da_0: +; ELF-NEXT: str x30, [sp, #-16]! +; ELF-NEXT: autdza x0 +; ELF-NEXT: blr x0 +; ELF-NEXT: ldr x30, [sp], #16 +; ELF-NEXT: ret + %tmp0 = call i32 %arg0() [ "ptrauth"(i32 2, i64 0) ] + ret i32 %tmp0 +} + +define i32 @test_call_db_0(ptr %arg0) #0 { +; DARWIN-LABEL: test_call_db_0: +; DARWIN-NEXT: stp x29, x30, [sp, #-16]! +; DARWIN-NEXT: autdzb x0 +; DARWIN-NEXT: blr x0 +; DARWIN-NEXT: ldp x29, x30, [sp], #16 +; DARWIN-NEXT: ret +; +; ELF-LABEL: test_call_db_0: +; ELF-NEXT: str x30, [sp, #-16]! +; ELF-NEXT: autdzb x0 +; ELF-NEXT: blr x0 +; ELF-NEXT: ldr x30, [sp], #16 +; ELF-NEXT: ret + %tmp0 = call i32 %arg0() [ "ptrauth"(i32 3, i64 0) ] + ret i32 %tmp0 +} + +define i32 @test_call_da_imm(ptr %arg0) #0 { +; DARWIN-LABEL: test_call_da_imm: +; DARWIN-NEXT: stp x29, x30, [sp, #-16]! +; DARWIN-NEXT: mov x17, #42 +; DARWIN-NEXT: autda x0, x17 +; DARWIN-NEXT: blr x0 +; DARWIN-NEXT: ldp x29, x30, [sp], #16 +; DARWIN-NEXT: ret +; +; ELF-LABEL: test_call_da_imm: +; ELF-NEXT: str x30, [sp, #-16]! +; ELF-NEXT: mov x17, #42 +; ELF-NEXT: autda x0, x17 +; ELF-NEXT: blr x0 +; ELF-NEXT: ldr x30, [sp], #16 +; ELF-NEXT: ret + %tmp0 = call i32 %arg0() [ "ptrauth"(i32 2, i64 42) ] + ret i32 %tmp0 +} + +define i32 @test_call_db_imm(ptr %arg0) #0 { +; DARWIN-LABEL: test_call_db_imm: +; DARWIN-NEXT: stp x29, x30, [sp, #-16]! +; DARWIN-NEXT: mov x17, #42 +; DARWIN-NEXT: autdb x0, x17 +; DARWIN-NEXT: blr x0 +; DARWIN-NEXT: ldp x29, x30, [sp], #16 +; DARWIN-NEXT: ret +; +; ELF-LABEL: test_call_db_imm: +; ELF-NEXT: str x30, [sp, #-16]! +; ELF-NEXT: mov x17, #42 +; ELF-NEXT: autdb x0, x17 +; ELF-NEXT: blr x0 +; ELF-NEXT: ldr x30, [sp], #16 +; ELF-NEXT: ret + %tmp0 = call i32 %arg0() [ "ptrauth"(i32 3, i64 42) ] + ret i32 %tmp0 +} + +define i32 @test_tailcall_da_0(ptr %arg0) #0 { +; CHECK-LABEL: test_tailcall_da_0: +; CHECK-NEXT: autdza x0 +; CHECK-NEXT: br x0 + %tmp0 = tail call i32 %arg0() [ "ptrauth"(i32 2, i64 0) ] + ret i32 %tmp0 +} + +define i32 @test_tailcall_db_0(ptr %arg0) #0 { +; CHECK-LABEL: test_tailcall_db_0: +; CHECK-NEXT: autdzb x0 +; CHECK-NEXT: br x0 + %tmp0 = tail call i32 %arg0() [ "ptrauth"(i32 3, i64 0) ] + ret i32 %tmp0 +} + +define i32 @test_tailcall_da_imm(ptr %arg0) #0 { +; CHECK-LABEL: test_tailcall_da_imm: +; CHECK-NEXT: mov x16, #42 +; CHECK-NEXT: autda x0, x16 +; CHECK-NEXT: br x0 + %tmp0 = tail call i32 %arg0() [ "ptrauth"(i32 2, i64 42) ] + ret i32 %tmp0 +} + +define i32 @test_tailcall_db_imm(ptr %arg0) #0 { +; CHECK-LABEL: test_tailcall_db_imm: +; CHECK-NEXT: mov x16, #42 +; CHECK-NEXT: autdb x0, x16 +; CHECK-NEXT: br x0 + %tmp0 = tail call i32 %arg0() [ "ptrauth"(i32 3, i64 42) ] + ret i32 %tmp0 +} + define void @test_tailcall_omit_mov_x16_x16(ptr %objptr) #0 { ; CHECK-LABEL: test_tailcall_omit_mov_x16_x16: ; DARWIN-NEXT: ldr x16, [x0] diff --git a/llvm/test/Transforms/InstCombine/ptrauth-intrinsics-call.ll b/llvm/test/Transforms/InstCombine/ptrauth-intrinsics-call.ll index 5e597c9155f40..4ef78353ae1e2 100644 --- a/llvm/test/Transforms/InstCombine/ptrauth-intrinsics-call.ll +++ b/llvm/test/Transforms/InstCombine/ptrauth-intrinsics-call.ll @@ -124,10 +124,7 @@ define i32 @test_ptrauth_call_resign_mismatch_blend(ptr %pp) { define i32 @test_ptrauth_call_resign_changing_call_key(ptr %p) { ; CHECK-LABEL: @test_ptrauth_call_resign_changing_call_key( -; CHECK-NEXT: [[V0:%.*]] = ptrtoint ptr [[P:%.*]] to i64 -; CHECK-NEXT: [[V1:%.*]] = call i64 @llvm.ptrauth.resign(i64 [[V0]], i32 2, i64 1234, i32 1, i64 5678) -; CHECK-NEXT: [[V2:%.*]] = inttoptr i64 [[V1]] to ptr -; CHECK-NEXT: [[V3:%.*]] = call i32 [[V2]]() [ "ptrauth"(i32 1, i64 5678) ] +; CHECK-NEXT: [[V3:%.*]] = call i32 [[P:%.*]]() [ "ptrauth"(i32 2, i64 1234) ] ; CHECK-NEXT: ret i32 [[V3]] ; %v0 = ptrtoint ptr %p to i64 From dd6dc2544daf86351082e9a8db448443d1a0053e Mon Sep 17 00:00:00 2001 From: Anatoly Trosinenko Date: Wed, 22 Oct 2025 21:44:34 +0300 Subject: [PATCH 04/40] Switch ptrauth_strip to bundles --- clang/lib/CodeGen/CGBuiltin.cpp | 8 +++++++- clang/lib/CodeGen/CGCall.cpp | 13 ++++++++++++- clang/lib/CodeGen/CodeGenFunction.cpp | 18 +++++++++--------- clang/lib/CodeGen/CodeGenFunction.h | 6 ++++++ clang/test/CodeGen/ptrauth-intrinsics.c | 2 +- .../CodeGenCXX/ptrauth-dynamic-cast-exact.cpp | 2 +- clang/test/CodeGenCXX/ubsan-vtable-checks.cpp | 6 +++--- llvm/include/llvm/CodeGen/ISDOpcodes.h | 9 +++++++++ llvm/include/llvm/IR/Intrinsics.td | 6 +++--- llvm/include/llvm/Support/TargetOpcodes.def | 9 +++++++++ llvm/include/llvm/Target/GenericOpcodes.td | 13 +++++++++++++ .../Target/GlobalISel/SelectionDAGCompat.td | 3 +++ .../include/llvm/Target/TargetSelectionDAG.td | 12 ++++++++++++ llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp | 19 +++++++++++++++++++ .../SelectionDAG/SelectionDAGBuilder.cpp | 15 +++++++++++++++ .../SelectionDAG/SelectionDAGDumper.cpp | 2 ++ llvm/lib/IR/Verifier.cpp | 7 +++++-- llvm/lib/Target/AArch64/AArch64InstrInfo.td | 8 ++++---- .../AArch64/GISel/AArch64LegalizerInfo.cpp | 3 +++ .../GlobalISel/legalizer-info-validation.mir | 8 ++++++++ .../AArch64/ptrauth-intrinsic-strip.ll | 10 ++++------ .../Inputs/reference_x86_vocab_print.txt | 2 ++ .../reference_x86_vocab_wo=0.5_print.txt | 2 ++ .../match-table-cxx.td | 2 +- .../GlobalISelEmitter/GlobalISelEmitter.td | 2 +- llvm/test/TableGen/get-named-operand-idx.td | 2 +- .../GlobalISel/GlobalISelMatchTable.cpp | 3 +++ 27 files changed, 158 insertions(+), 34 deletions(-) diff --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp index da72a43643a54..4fe5d35b4cd19 100644 --- a/clang/lib/CodeGen/CGBuiltin.cpp +++ b/clang/lib/CodeGen/CGBuiltin.cpp @@ -5630,6 +5630,7 @@ RValue CodeGenFunction::EmitBuiltinExpr(const GlobalDecl GD, unsigned BuiltinID, case Builtin::BI__builtin_ptrauth_strip: { // Emit the arguments. SmallVector Args; + SmallVector OBs; for (auto argExpr : E->arguments()) Args.push_back(EmitScalarExpr(argExpr)); @@ -5656,7 +5657,12 @@ RValue CodeGenFunction::EmitBuiltinExpr(const GlobalDecl GD, unsigned BuiltinID, break; case Builtin::BI__builtin_ptrauth_blend_discriminator: + break; + case Builtin::BI__builtin_ptrauth_strip: + // FIXME i32 -> i64 + OBs.emplace_back("ptrauth", ArrayRef({Args[1]})); + Args.pop_back(); break; } @@ -5679,7 +5685,7 @@ RValue CodeGenFunction::EmitBuiltinExpr(const GlobalDecl GD, unsigned BuiltinID, llvm_unreachable("bad ptrauth intrinsic"); }(); auto Intrinsic = CGM.getIntrinsic(IntrinsicID); - llvm::Value *Result = EmitRuntimeCall(Intrinsic, Args); + llvm::Value *Result = EmitRuntimeCall(Intrinsic, Args, OBs); if (BuiltinID != Builtin::BI__builtin_ptrauth_sign_generic_data && BuiltinID != Builtin::BI__builtin_ptrauth_blend_discriminator && diff --git a/clang/lib/CodeGen/CGCall.cpp b/clang/lib/CodeGen/CGCall.cpp index efacb3cc04c01..4dad5e528a0c4 100644 --- a/clang/lib/CodeGen/CGCall.cpp +++ b/clang/lib/CodeGen/CGCall.cpp @@ -5039,10 +5039,21 @@ CodeGenFunction::getBundlesForFunclet(llvm::Value *Callee) { llvm::CallInst *CodeGenFunction::EmitRuntimeCall(llvm::FunctionCallee callee, ArrayRef args, const llvm::Twine &name) { + return EmitRuntimeCall(callee, args, {}, name); +} + +llvm::CallInst *CodeGenFunction::EmitRuntimeCall( + llvm::FunctionCallee callee, ArrayRef args, + ArrayRef extraBundles, const Twine &name) { + SmallVector allBundles; + llvm::append_range(allBundles, getBundlesForFunclet(callee.getCallee())); + llvm::append_range(allBundles, extraBundles); llvm::CallInst *call = Builder.CreateCall( - callee, args, getBundlesForFunclet(callee.getCallee()), name); + callee, args, allBundles, name); call->setCallingConv(getRuntimeCC()); + // FIXME Attach "convergencectrl" bundle right away instead of re-creating + // the call instruction. if (CGM.shouldEmitConvergenceTokens() && call->isConvergent()) return cast(addConvergenceControlToken(call)); return call; diff --git a/clang/lib/CodeGen/CodeGenFunction.cpp b/clang/lib/CodeGen/CodeGenFunction.cpp index ac25bd95f0463..59db5732fdda5 100644 --- a/clang/lib/CodeGen/CodeGenFunction.cpp +++ b/clang/lib/CodeGen/CodeGenFunction.cpp @@ -3354,24 +3354,24 @@ CodeGenFunction::EmitPointerAuthSign(const CGPointerAuthInfo &PointerAuth, llvm::Intrinsic::ptrauth_sign); } -static llvm::Value *EmitStrip(CodeGenFunction &CGF, - const CGPointerAuthInfo &PointerAuth, - llvm::Value *Pointer) { - auto StripIntrinsic = CGF.CGM.getIntrinsic(llvm::Intrinsic::ptrauth_strip); +llvm::Value *CodeGenFunction::emitStrip(const CGPointerAuthInfo &PointerAuth, + llvm::Value *Pointer) { + auto StripIntrinsic = CGM.getIntrinsic(llvm::Intrinsic::ptrauth_strip); - auto Key = CGF.Builder.getInt32(PointerAuth.getKey()); + auto Key = Builder.getInt64(PointerAuth.getKey()); // Convert the pointer to intptr_t before signing it. auto OrigType = Pointer->getType(); - Pointer = CGF.EmitRuntimeCall( - StripIntrinsic, {CGF.Builder.CreatePtrToInt(Pointer, CGF.IntPtrTy), Key}); - return CGF.Builder.CreateIntToPtr(Pointer, OrigType); + llvm::OperandBundleDef OB("ptrauth", ArrayRef({Key})); + Pointer = EmitRuntimeCall( + StripIntrinsic, {Builder.CreatePtrToInt(Pointer, IntPtrTy)}, {OB}); + return Builder.CreateIntToPtr(Pointer, OrigType); } llvm::Value * CodeGenFunction::EmitPointerAuthAuth(const CGPointerAuthInfo &PointerAuth, llvm::Value *Pointer) { if (PointerAuth.shouldStrip()) { - return EmitStrip(*this, PointerAuth, Pointer); + return emitStrip(PointerAuth, Pointer); } if (!PointerAuth.shouldAuth()) { return Pointer; diff --git a/clang/lib/CodeGen/CodeGenFunction.h b/clang/lib/CodeGen/CodeGenFunction.h index 8c4c1c8c2dc95..6ed6495f6b976 100644 --- a/clang/lib/CodeGen/CodeGenFunction.h +++ b/clang/lib/CodeGen/CodeGenFunction.h @@ -4553,6 +4553,10 @@ class CodeGenFunction : public CodeGenTypeCache { llvm::CallInst *EmitRuntimeCall(llvm::FunctionCallee callee, ArrayRef args, const Twine &name = ""); + llvm::CallInst *EmitRuntimeCall(llvm::FunctionCallee callee, + ArrayRef args, + ArrayRef extraBundles, + const Twine &name = ""); llvm::CallInst *EmitNounwindRuntimeCall(llvm::FunctionCallee callee, const Twine &name = ""); llvm::CallInst *EmitNounwindRuntimeCall(llvm::FunctionCallee callee, @@ -4608,6 +4612,8 @@ class CodeGenFunction : public CodeGenTypeCache { llvm::Value *emitPointerAuthResignCall(llvm::Value *Pointer, const CGPointerAuthInfo &CurInfo, const CGPointerAuthInfo &NewInfo); + llvm::Value *emitStrip(const CGPointerAuthInfo &PointerAuth, + llvm::Value *Pointer); void EmitPointerAuthOperandBundle( const CGPointerAuthInfo &Info, diff --git a/clang/test/CodeGen/ptrauth-intrinsics.c b/clang/test/CodeGen/ptrauth-intrinsics.c index 50bf1898e4b37..06313c83b4963 100644 --- a/clang/test/CodeGen/ptrauth-intrinsics.c +++ b/clang/test/CodeGen/ptrauth-intrinsics.c @@ -25,7 +25,7 @@ void test_auth() { void test_strip() { // CHECK: [[PTR:%.*]] = load ptr, ptr @fnptr, // CHECK-NEXT: [[T0:%.*]] = ptrtoint ptr [[PTR]] to i64 - // CHECK-NEXT: [[T1:%.*]] = call i64 @llvm.ptrauth.strip(i64 [[T0]], i32 0) + // CHECK-NEXT: [[T1:%.*]] = call i64 @llvm.ptrauth.strip(i64 [[T0]]) [ "ptrauth"(i32 0) ] // CHECK-NEXT: [[RESULT:%.*]] = inttoptr i64 [[T1]] to ptr // CHECK-NEXT: store ptr [[RESULT]], ptr @fnptr, fnptr = __builtin_ptrauth_strip(fnptr, 0); diff --git a/clang/test/CodeGenCXX/ptrauth-dynamic-cast-exact.cpp b/clang/test/CodeGenCXX/ptrauth-dynamic-cast-exact.cpp index 1710ca5563380..2e51f1507e310 100644 --- a/clang/test/CodeGenCXX/ptrauth-dynamic-cast-exact.cpp +++ b/clang/test/CodeGenCXX/ptrauth-dynamic-cast-exact.cpp @@ -101,7 +101,7 @@ L *exact_multi(E *e) { // CHECK: [[ADJUSTED_THIS:%.*]] = getelementptr inbounds i8, ptr %e, i64 %offset.to.top // CHECK: [[ADJUSTED_THIS_VTABLE:%.*]] = load ptr, ptr [[ADJUSTED_THIS]] // CHECK: [[ADJUSTED_THIS_VTABLEI:%.*]] = ptrtoint ptr [[ADJUSTED_THIS_VTABLE]] to i64 - // CHECK: [[ADJUSTED_THIS_STRIPPED_VTABLEI:%.*]] = tail call i64 @llvm.ptrauth.strip(i64 [[ADJUSTED_THIS_VTABLEI]], i32 0) + // CHECK: [[ADJUSTED_THIS_STRIPPED_VTABLEI:%.*]] = tail call i64 @llvm.ptrauth.strip(i64 [[ADJUSTED_THIS_VTABLEI]]) [ "ptrauth"(i64 0) ] // CHECK: [[SUCCESS:%.*]] = icmp eq i64 [[ADJUSTED_THIS_STRIPPED_VTABLEI]], ptrtoint (ptr getelementptr inbounds nuw inrange(-24, 16) (i8, ptr @_ZTV1L, i64 24) to i64) // CHECK: br i1 [[SUCCESS]], label %dynamic_cast.postauth.success, label %dynamic_cast.postauth.complete // CHECK: dynamic_cast.postauth.success: diff --git a/clang/test/CodeGenCXX/ubsan-vtable-checks.cpp b/clang/test/CodeGenCXX/ubsan-vtable-checks.cpp index c891ff0a4fa42..23e96b5cca3b3 100644 --- a/clang/test/CodeGenCXX/ubsan-vtable-checks.cpp +++ b/clang/test/CodeGenCXX/ubsan-vtable-checks.cpp @@ -31,7 +31,7 @@ int get_v(T* t) { // CHECK-NULL: load ptr, ptr {{.*}} // CHECK-PTRAUTH: [[CAST_VTABLE:%.*]] = ptrtoint ptr %vtable to i64 - // CHECK-PTRAUTH: [[STRIPPED_VTABLE:%.*]] = call i64 @llvm.ptrauth.strip(i64 [[CAST_VTABLE]], i32 0), !nosanitize + // CHECK-PTRAUTH: [[STRIPPED_VTABLE:%.*]] = call i64 @llvm.ptrauth.strip(i64 [[CAST_VTABLE]]) [ "ptrauth"(i64 0) ], !nosanitize // CHECK-PTRAUTH: [[STRIPPED_PTR:%.*]] = inttoptr i64 [[STRIPPED_VTABLE]] to ptr // CHECK-PTRAUTH: [[STRIPPED_INT:%.*]] = ptrtoint ptr [[STRIPPED_PTR]] to i64 // Make sure authed vtable pointer feeds into hashing @@ -58,7 +58,7 @@ void delete_it(T *t) { // First, we check that vtable is not loaded before a type check. // CHECK-PTRAUTH: ptrtoint ptr {{%.*}} to i64 // CHECK-PTRAUTH: [[CAST_VTABLE:%.*]] = ptrtoint ptr [[VTABLE:%.*]] to i64 - // CHECK-PTRAUTH: [[STRIPPED_VTABLE:%.*]] = call i64 @llvm.ptrauth.strip(i64 [[CAST_VTABLE]], i32 0) + // CHECK-PTRAUTH: [[STRIPPED_VTABLE:%.*]] = call i64 @llvm.ptrauth.strip(i64 [[CAST_VTABLE]]) [ "ptrauth"(i64 0) ] // CHECK-PTRAUTH: [[STRIPPED_PTR:%.*]] = inttoptr i64 [[STRIPPED_VTABLE]] to ptr // CHECK-PTRAUTH: [[STRIPPED_INT:%.*]] = ptrtoint ptr [[STRIPPED_PTR]] to i64 // CHECK-PTRAUTH: {{%.*}} = mul i64 [[STRIPPED_INT]], {{.*}} @@ -84,7 +84,7 @@ U* dyncast(T *t) { // CHECK-PTRAUTH: [[V0:%.*]] = ptrtoint ptr {{%.*}} to i64 // CHECK-PTRAUTH: [[BLENDED:%.*]] = call i64 @llvm.ptrauth.blend(i64 [[V0]], i64 17113) // CHECK-PTRAUTH: [[CAST_VTABLE:%.*]] = ptrtoint ptr {{%.*}} to i64 - // CHECK-PTRAUTH: [[STRIPPED_VTABLE:%.*]] = call i64 @llvm.ptrauth.strip(i64 [[CAST_VTABLE]], i32 0) + // CHECK-PTRAUTH: [[STRIPPED_VTABLE:%.*]] = call i64 @llvm.ptrauth.strip(i64 [[CAST_VTABLE]]) [ "ptrauth"(i64 0) ] // CHECK-PTRAUTH: [[STRIPPED_PTR:%.*]] = inttoptr i64 [[STRIPPED_VTABLE]] to ptr // CHECK-PTRAUTH: [[STRIPPED_INT:%.*]] = ptrtoint ptr [[STRIPPED_PTR]] to i64 // CHECK-PTRAUTH: {{%.*}} = mul i64 [[STRIPPED_INT]], {{.*}} diff --git a/llvm/include/llvm/CodeGen/ISDOpcodes.h b/llvm/include/llvm/CodeGen/ISDOpcodes.h index b32f3dacbb3a4..a6bc2721f4486 100644 --- a/llvm/include/llvm/CodeGen/ISDOpcodes.h +++ b/llvm/include/llvm/CodeGen/ISDOpcodes.h @@ -99,6 +99,15 @@ enum NodeType { /// a constant global address signed using address-diversification, in code. PtrAuthGlobalAddress, + /// A temporary node representing the operands of "ptrauth" bundle in the + /// original LLVM IR. + /// It has target-dependent number of i64 operands and produces a token value + /// passed as input operand to one of PtrAuth(Auth|Sign|Resign|Strip) nodes. + PtrAuthBundle, + + /// Various PtrAuth operations. + PtrAuthStrip, + /// The address of the GOT GLOBAL_OFFSET_TABLE, diff --git a/llvm/include/llvm/IR/Intrinsics.td b/llvm/include/llvm/IR/Intrinsics.td index 8f3cc54747074..f99dcdbfec4f6 100644 --- a/llvm/include/llvm/IR/Intrinsics.td +++ b/llvm/include/llvm/IR/Intrinsics.td @@ -2886,12 +2886,12 @@ def int_ptrauth_resign : Intrinsic<[llvm_i64_ty], ImmArg>]>; // Strip the embedded signature out of a signed pointer. -// The second argument specifies the key. +// Requires exactly one "ptrauth" call operand bundle carrying a +// target-specific information required to remove the signature. // This behaves like @llvm.ptrauth.auth, but doesn't require the signature to // be valid. def int_ptrauth_strip : - DefaultAttrsIntrinsic<[llvm_i64_ty], [llvm_i64_ty, llvm_i32_ty], - [IntrNoMem, ImmArg>]>; + DefaultAttrsIntrinsic<[llvm_i64_ty], [llvm_i64_ty], [IntrNoMem]>; // Blend a small integer discriminator with an address discriminator, producing // a new discriminator value. diff --git a/llvm/include/llvm/Support/TargetOpcodes.def b/llvm/include/llvm/Support/TargetOpcodes.def index 0d92f50a09d38..ff82b22c7fd68 100644 --- a/llvm/include/llvm/Support/TargetOpcodes.def +++ b/llvm/include/llvm/Support/TargetOpcodes.def @@ -331,6 +331,15 @@ HANDLE_TARGET_OPCODE(G_GLOBAL_VALUE) /// Generic ptrauth-signed reference to global value. HANDLE_TARGET_OPCODE(G_PTRAUTH_GLOBAL_VALUE) +/// A temporary instruction representing the operands of "ptrauth" bundle in +/// the original LLVM IR. +/// It has target-dependent number of i64 operands and produces a token value +/// passed as input operand to one of G_PTRAUTH_* instructions. +HANDLE_TARGET_OPCODE(G_PTRAUTH_BUNDLE) + +/// Various PtrAuth operations. +HANDLE_TARGET_OPCODE(G_PTRAUTH_STRIP) + /// Generic instruction to materialize the address of an object in the constant /// pool. HANDLE_TARGET_OPCODE(G_CONSTANT_POOL) diff --git a/llvm/include/llvm/Target/GenericOpcodes.td b/llvm/include/llvm/Target/GenericOpcodes.td index 1b65b8b73527d..68ed3c91f4668 100644 --- a/llvm/include/llvm/Target/GenericOpcodes.td +++ b/llvm/include/llvm/Target/GenericOpcodes.td @@ -137,6 +137,19 @@ def G_PTRAUTH_GLOBAL_VALUE : GenericInstruction { let hasSideEffects = 0; } +def G_PTRAUTH_BUNDLE : GenericInstruction { + let OutOperandList = (outs untyped_imm_0:$dst); + let InOperandList = (ins type0:$op1, variable_ops); + let hasSideEffects = 0; + let variadicOpsType = type0; +} + +def G_PTRAUTH_STRIP : GenericInstruction { + let OutOperandList = (outs type0:$dst); + let InOperandList = (ins type0:$value, untyped_imm_0:$schema); + let hasSideEffects = 0; +} + def G_CONSTANT_POOL : GenericInstruction { let OutOperandList = (outs type0:$dst); let InOperandList = (ins unknown:$src); diff --git a/llvm/include/llvm/Target/GlobalISel/SelectionDAGCompat.td b/llvm/include/llvm/Target/GlobalISel/SelectionDAGCompat.td index a69e089779315..b1f247b724d27 100644 --- a/llvm/include/llvm/Target/GlobalISel/SelectionDAGCompat.td +++ b/llvm/include/llvm/Target/GlobalISel/SelectionDAGCompat.td @@ -224,6 +224,9 @@ def : GINodeEquiv; def : GINodeEquiv; def : GINodeEquiv; +def : GINodeEquiv; +def : GINodeEquiv; + // Broadly speaking G_LOAD is equivalent to ISD::LOAD but there are some // complications that tablegen must take care of. For example, Predicates such // as isSignExtLoad require that this is not a perfect 1:1 mapping since a diff --git a/llvm/include/llvm/Target/TargetSelectionDAG.td b/llvm/include/llvm/Target/TargetSelectionDAG.td index a9750a5ab03f9..685f4c566f657 100644 --- a/llvm/include/llvm/Target/TargetSelectionDAG.td +++ b/llvm/include/llvm/Target/TargetSelectionDAG.td @@ -911,6 +911,18 @@ def convergencectrl_loop : SDNode<"ISD::CONVERGENCECTRL_LOOP", def convergencectrl_glue : SDNode<"ISD::CONVERGENCECTRL_GLUE", SDTypeProfile<0, 1, [SDTCisVT<0, untyped>]>>; +// Pointer Authentication operations. + +def SDTPtrAuthBundle : SDTypeProfile<1, -1, [ + SDTCisVT<0, untyped> +]>; +def SDTPtrAuthOneSchema : SDTypeProfile<1, 2, [ // auth, sign, strip + SDTCisVT<0, i64>, SDTCisVT<1, i64>, SDTCisVT<2, untyped> +]>; + +def ptrauth_bundle : SDNode<"ISD::PtrAuthBundle", SDTPtrAuthBundle, []>; +def ptrauth_strip : SDNode<"ISD::PtrAuthStrip", SDTPtrAuthOneSchema, []>; + //===----------------------------------------------------------------------===// // Selection DAG Condition Codes diff --git a/llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp b/llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp index 4267012c3777f..4f59e52f81b46 100644 --- a/llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp +++ b/llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp @@ -2204,9 +2204,28 @@ bool IRTranslator::translateKnownIntrinsic(const CallInst &CI, Intrinsic::ID ID, if (translateSimpleIntrinsic(CI, ID, MIRBuilder)) return true; + auto TranslatePtrAuthBundle = [&](unsigned Index) { + auto Bundle = CI.getOperandBundleAt(Index); + assert(Bundle.getTagID() == LLVMContext::OB_ptrauth); + Register Res = MRI->createGenericVirtualRegister(LLT::token()); + auto Builder = MIRBuilder.buildInstr(TargetOpcode::G_PTRAUTH_BUNDLE); + Builder.addDef(Res); + for (Value *Operand : Bundle.Inputs) + Builder.addUse(getOrCreateVReg(*Operand)); + return Res; + }; + switch (ID) { default: break; + case Intrinsic::ptrauth_strip: { + Register Dst = getOrCreateVReg(CI); + Register V = getOrCreateVReg(*CI.getArgOperand(0)); + Register Bundle = TranslatePtrAuthBundle(0); + + MIRBuilder.buildInstr(TargetOpcode::G_PTRAUTH_STRIP, {Dst}, {V, Bundle}); + return true; + } case Intrinsic::lifetime_start: case Intrinsic::lifetime_end: { // No stack colouring in O0, discard region information. diff --git a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp index 32b3ad7c3a903..f8f92b596a43f 100644 --- a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp +++ b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp @@ -6555,11 +6555,26 @@ void SelectionDAGBuilder::visitIntrinsicCall(const CallInst &I, if (auto *FPOp = dyn_cast(&I)) Flags.copyFMF(*FPOp); + auto CreatePtrAuthBundle = [&](unsigned Index) { + auto Bundle = I.getOperandBundleAt(Index); + assert(Bundle.getTagID() == LLVMContext::OB_ptrauth); + SmallVector Ops; + for (Value *Operand : Bundle.Inputs) + Ops.push_back(getValue(Operand)); + return DAG.getNode(ISD::PtrAuthBundle, getCurSDLoc(), MVT::Other, Ops); + }; + switch (Intrinsic) { default: // By default, turn this into a target intrinsic node. visitTargetIntrinsic(I, Intrinsic); return; + case Intrinsic::ptrauth_strip: { + setValue(&I, DAG.getNode(ISD::PtrAuthStrip, sdl, MVT::i64, + getValue(I.getArgOperand(0)), + CreatePtrAuthBundle(0))); + return; + } case Intrinsic::vscale: { EVT VT = TLI.getValueType(DAG.getDataLayout(), I.getType()); setValue(&I, DAG.getVScale(sdl, VT, APInt(VT.getSizeInBits(), 1))); diff --git a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGDumper.cpp b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGDumper.cpp index ec5edd5f13978..31941c77ed942 100644 --- a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGDumper.cpp +++ b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGDumper.cpp @@ -139,6 +139,8 @@ std::string SDNode::getOperationName(const SelectionDAG *G) const { case ISD::GlobalAddress: return "GlobalAddress"; case ISD::GlobalTLSAddress: return "GlobalTLSAddress"; case ISD::PtrAuthGlobalAddress: return "PtrAuthGlobalAddress"; + case ISD::PtrAuthBundle: return "PtrAuthBundle"; + case ISD::PtrAuthStrip: return "PtrAuthStrip"; case ISD::FrameIndex: return "FrameIndex"; case ISD::JumpTable: return "JumpTable"; case ISD::JUMP_TABLE_DEBUG_INFO: diff --git a/llvm/lib/IR/Verifier.cpp b/llvm/lib/IR/Verifier.cpp index 4809d75843523..309fa9109c8a9 100644 --- a/llvm/lib/IR/Verifier.cpp +++ b/llvm/lib/IR/Verifier.cpp @@ -4035,13 +4035,16 @@ void Verifier::visitCallBase(CallBase &Call) { } // Verify that callee and callsite agree on whether to use pointer auth. - Check(!(Call.getCalledFunction() && NumPtrauthBundles), - "Direct call cannot have a ptrauth bundle", Call); switch (Call.getIntrinsicID()) { case Intrinsic::not_intrinsic: + Check(!(Call.getCalledFunction() && NumPtrauthBundles), + "Direct call cannot have a ptrauth bundle", Call); Check(NumPtrauthBundles <= 1, "Multiple ptrauth operand bundles on a function call", Call); break; + case Intrinsic::ptrauth_strip: + Check(NumPtrauthBundles == 1, "Expected exactly one ptrauth bundle", Call); + break; default: Check(NumPtrauthBundles == 0, "Unexpected ptrauth bundle", Call); break; diff --git a/llvm/lib/Target/AArch64/AArch64InstrInfo.td b/llvm/lib/Target/AArch64/AArch64InstrInfo.td index 6ebc6557aebfa..ffb7656831ef7 100644 --- a/llvm/lib/Target/AArch64/AArch64InstrInfo.td +++ b/llvm/lib/Target/AArch64/AArch64InstrInfo.td @@ -2091,12 +2091,12 @@ let Predicates = [HasPAuth] in { defm AUT : SignAuth<0b001, 0b011, "aut", null_frag>; def XPACI : ClearAuth<0, "xpaci">; - def : Pat<(int_ptrauth_strip GPR64:$Rd, 0), (XPACI GPR64:$Rd)>; - def : Pat<(int_ptrauth_strip GPR64:$Rd, 1), (XPACI GPR64:$Rd)>; + def : Pat<(ptrauth_strip GPR64:$Rd, (ptrauth_bundle (i64 0))), (XPACI GPR64:$Rd)>; + def : Pat<(ptrauth_strip GPR64:$Rd, (ptrauth_bundle (i64 1))), (XPACI GPR64:$Rd)>; def XPACD : ClearAuth<1, "xpacd">; - def : Pat<(int_ptrauth_strip GPR64:$Rd, 2), (XPACD GPR64:$Rd)>; - def : Pat<(int_ptrauth_strip GPR64:$Rd, 3), (XPACD GPR64:$Rd)>; + def : Pat<(ptrauth_strip GPR64:$Rd, (ptrauth_bundle (i64 2))), (XPACD GPR64:$Rd)>; + def : Pat<(ptrauth_strip GPR64:$Rd, (ptrauth_bundle (i64 3))), (XPACD GPR64:$Rd)>; def PACGA : SignAuthTwoOperand<0b1100, "pacga", int_ptrauth_sign_generic>; diff --git a/llvm/lib/Target/AArch64/GISel/AArch64LegalizerInfo.cpp b/llvm/lib/Target/AArch64/GISel/AArch64LegalizerInfo.cpp index 1025b2502211a..83f188d1d9ab3 100644 --- a/llvm/lib/Target/AArch64/GISel/AArch64LegalizerInfo.cpp +++ b/llvm/lib/Target/AArch64/GISel/AArch64LegalizerInfo.cpp @@ -1020,6 +1020,9 @@ AArch64LegalizerInfo::AArch64LegalizerInfo(const AArch64Subtarget &ST) getActionDefinitionsBuilder(G_PTRAUTH_GLOBAL_VALUE) .legalIf(all(typeIs(0, p0), typeIs(1, p0))); + getActionDefinitionsBuilder(G_PTRAUTH_BUNDLE).legalForTypeWithAnyImm({s64}); + getActionDefinitionsBuilder(G_PTRAUTH_STRIP).legalForTypeWithAnyImm({s64}); + getActionDefinitionsBuilder(G_PTRTOINT) .legalFor({{s64, p0}, {v2s64, v2p0}}) .widenScalarToNextPow2(0, 64) diff --git a/llvm/test/CodeGen/AArch64/GlobalISel/legalizer-info-validation.mir b/llvm/test/CodeGen/AArch64/GlobalISel/legalizer-info-validation.mir index e68278dadc4b8..933323828cc83 100644 --- a/llvm/test/CodeGen/AArch64/GlobalISel/legalizer-info-validation.mir +++ b/llvm/test/CodeGen/AArch64/GlobalISel/legalizer-info-validation.mir @@ -119,6 +119,14 @@ # DEBUG-NEXT: .. type index coverage check SKIPPED: user-defined predicate detected # DEBUG-NEXT: .. imm index coverage check SKIPPED: user-defined predicate detected # +# DEBUG-NEXT: G_PTRAUTH_BUNDLE (opcode {{[0-9]+}}): 1 type index, 1 imm index +# DEBUG-NEXT: .. type index coverage check SKIPPED: user-defined predicate detected +# DEBUG-NEXT: .. imm index coverage check SKIPPED: user-defined predicate detected +# +# DEBUG-NEXT: G_PTRAUTH_STRIP (opcode {{[0-9]+}}): 1 type index, 1 imm index +# DEBUG-NEXT: .. type index coverage check SKIPPED: user-defined predicate detected +# DEBUG-NEXT: .. imm index coverage check SKIPPED: user-defined predicate detected +# # DEBUG-NEXT: G_CONSTANT_POOL (opcode {{[0-9]+}}): 1 type index, 0 imm indices # DEBUG-NEXT: .. type index coverage check SKIPPED: no rules defined # DEBUG-NEXT: .. imm index coverage check SKIPPED: no rules defined diff --git a/llvm/test/CodeGen/AArch64/ptrauth-intrinsic-strip.ll b/llvm/test/CodeGen/AArch64/ptrauth-intrinsic-strip.ll index 1aeff7aec2ee4..81e5416f2fa9b 100644 --- a/llvm/test/CodeGen/AArch64/ptrauth-intrinsic-strip.ll +++ b/llvm/test/CodeGen/AArch64/ptrauth-intrinsic-strip.ll @@ -9,7 +9,7 @@ define i64 @test_strip_ia(i64 %arg) { ; CHECK: %bb.0: ; CHECK-NEXT: xpaci x0 ; CHECK-NEXT: ret - %tmp = call i64 @llvm.ptrauth.strip(i64 %arg, i32 0) + %tmp = call i64 @llvm.ptrauth.strip(i64 %arg) [ "ptrauth"(i64 0) ] ret i64 %tmp } @@ -18,7 +18,7 @@ define i64 @test_strip_ib(i64 %arg) { ; CHECK: %bb.0: ; CHECK-NEXT: xpaci x0 ; CHECK-NEXT: ret - %tmp = call i64 @llvm.ptrauth.strip(i64 %arg, i32 1) + %tmp = call i64 @llvm.ptrauth.strip(i64 %arg) [ "ptrauth"(i64 1) ] ret i64 %tmp } @@ -27,7 +27,7 @@ define i64 @test_strip_da(i64 %arg) { ; CHECK: %bb.0: ; CHECK-NEXT: xpacd x0 ; CHECK-NEXT: ret - %tmp = call i64 @llvm.ptrauth.strip(i64 %arg, i32 2) + %tmp = call i64 @llvm.ptrauth.strip(i64 %arg) [ "ptrauth"(i64 2) ] ret i64 %tmp } @@ -36,8 +36,6 @@ define i64 @test_strip_db(i64 %arg) { ; CHECK: %bb.0: ; CHECK-NEXT: xpacd x0 ; CHECK-NEXT: ret - %tmp = call i64 @llvm.ptrauth.strip(i64 %arg, i32 3) + %tmp = call i64 @llvm.ptrauth.strip(i64 %arg) [ "ptrauth"(i64 3) ] ret i64 %tmp } - -declare i64 @llvm.ptrauth.strip(i64, i32) diff --git a/llvm/test/CodeGen/MIR2Vec/Inputs/reference_x86_vocab_print.txt b/llvm/test/CodeGen/MIR2Vec/Inputs/reference_x86_vocab_print.txt index 62e07445ad12e..25c401884748e 100644 --- a/llvm/test/CodeGen/MIR2Vec/Inputs/reference_x86_vocab_print.txt +++ b/llvm/test/CodeGen/MIR2Vec/Inputs/reference_x86_vocab_print.txt @@ -477,7 +477,9 @@ Key: G_MUL: [ 0.00 0.00 ] Key: G_OR: [ 0.00 0.00 ] Key: G_PHI: [ 0.00 0.00 ] Key: G_PREFETCH: [ 0.00 0.00 ] +Key: G_PTRAUTH_BUNDLE: [ 0.00 0.00 ] Key: G_PTRAUTH_GLOBAL_VALUE: [ 0.00 0.00 ] +Key: G_PTRAUTH_STRIP: [ 0.00 0.00 ] Key: G_PTRMASK: [ 0.00 0.00 ] Key: G_PTRTOINT: [ 0.00 0.00 ] Key: G_PTR_ADD: [ 0.00 0.00 ] diff --git a/llvm/test/CodeGen/MIR2Vec/Inputs/reference_x86_vocab_wo=0.5_print.txt b/llvm/test/CodeGen/MIR2Vec/Inputs/reference_x86_vocab_wo=0.5_print.txt index 03a3fafc6b801..9eaf8554ad305 100644 --- a/llvm/test/CodeGen/MIR2Vec/Inputs/reference_x86_vocab_wo=0.5_print.txt +++ b/llvm/test/CodeGen/MIR2Vec/Inputs/reference_x86_vocab_wo=0.5_print.txt @@ -477,7 +477,9 @@ Key: G_MUL: [ 0.00 0.00 ] Key: G_OR: [ 0.00 0.00 ] Key: G_PHI: [ 0.00 0.00 ] Key: G_PREFETCH: [ 0.00 0.00 ] +Key: G_PTRAUTH_BUNDLE: [ 0.00 0.00 ] Key: G_PTRAUTH_GLOBAL_VALUE: [ 0.00 0.00 ] +Key: G_PTRAUTH_STRIP: [ 0.00 0.00 ] Key: G_PTRMASK: [ 0.00 0.00 ] Key: G_PTRTOINT: [ 0.00 0.00 ] Key: G_PTR_ADD: [ 0.00 0.00 ] diff --git a/llvm/test/TableGen/GlobalISelCombinerEmitter/match-table-cxx.td b/llvm/test/TableGen/GlobalISelCombinerEmitter/match-table-cxx.td index 28017700a0448..d36e7edc439e9 100644 --- a/llvm/test/TableGen/GlobalISelCombinerEmitter/match-table-cxx.td +++ b/llvm/test/TableGen/GlobalISelCombinerEmitter/match-table-cxx.td @@ -96,7 +96,7 @@ def MyCombiner: GICombiner<"GenMyCombiner", [ // CHECK: const uint8_t *GenMyCombiner::getMatchTable() const { // CHECK-NEXT: constexpr static uint8_t MatchTable0[] = { -// CHECK-NEXT: /* 0 */ GIM_SwitchOpcode, /*MI*/0, /*[*/GIMT_Encode2(105), GIMT_Encode2(217), /*)*//*default:*//*Label 5*/ GIMT_Encode4(524), +// CHECK-NEXT: /* 0 */ GIM_SwitchOpcode, /*MI*/0, /*[*/GIMT_Encode2(107), GIMT_Encode2(219), /*)*//*default:*//*Label 5*/ GIMT_Encode4(524), // CHECK-NEXT: /* 10 */ /*TargetOpcode::G_STORE*//*Label 0*/ GIMT_Encode4(458), GIMT_Encode4(0), GIMT_Encode4(0), GIMT_Encode4(0), GIMT_Encode4(0), GIMT_Encode4(0), GIMT_Encode4(0), GIMT_Encode4(0), GIMT_Encode4(0), GIMT_Encode4(0), GIMT_Encode4(0), GIMT_Encode4(0), GIMT_Encode4(0), GIMT_Encode4(0), GIMT_Encode4(0), GIMT_Encode4(0), GIMT_Encode4(0), GIMT_Encode4(0), GIMT_Encode4(0), GIMT_Encode4(0), GIMT_Encode4(0), GIMT_Encode4(0), GIMT_Encode4(0), GIMT_Encode4(0), GIMT_Encode4(0), GIMT_Encode4(0), GIMT_Encode4(0), GIMT_Encode4(0), GIMT_Encode4(0), GIMT_Encode4(0), GIMT_Encode4(0), GIMT_Encode4(0), GIMT_Encode4(0), GIMT_Encode4(0), GIMT_Encode4(0), GIMT_Encode4(0), GIMT_Encode4(0), GIMT_Encode4(0), GIMT_Encode4(0), GIMT_Encode4(0), GIMT_Encode4(0), GIMT_Encode4(0), GIMT_Encode4(0), // CHECK-NEXT: /* 182 */ /*TargetOpcode::G_SEXT*//*Label 1*/ GIMT_Encode4(476), GIMT_Encode4(0), // CHECK-NEXT: /* 190 */ /*TargetOpcode::G_ZEXT*//*Label 2*/ GIMT_Encode4(488), GIMT_Encode4(0), GIMT_Encode4(0), GIMT_Encode4(0), GIMT_Encode4(0), GIMT_Encode4(0), GIMT_Encode4(0), GIMT_Encode4(0), GIMT_Encode4(0), GIMT_Encode4(0), GIMT_Encode4(0), GIMT_Encode4(0), GIMT_Encode4(0), GIMT_Encode4(0), GIMT_Encode4(0), GIMT_Encode4(0), GIMT_Encode4(0), GIMT_Encode4(0), GIMT_Encode4(0), GIMT_Encode4(0), GIMT_Encode4(0), GIMT_Encode4(0), GIMT_Encode4(0), GIMT_Encode4(0), GIMT_Encode4(0), GIMT_Encode4(0), GIMT_Encode4(0), GIMT_Encode4(0), GIMT_Encode4(0), GIMT_Encode4(0), GIMT_Encode4(0), GIMT_Encode4(0), GIMT_Encode4(0), GIMT_Encode4(0), GIMT_Encode4(0), GIMT_Encode4(0), GIMT_Encode4(0), GIMT_Encode4(0), GIMT_Encode4(0), GIMT_Encode4(0), GIMT_Encode4(0), GIMT_Encode4(0), GIMT_Encode4(0), GIMT_Encode4(0), GIMT_Encode4(0), GIMT_Encode4(0), GIMT_Encode4(0), GIMT_Encode4(0), GIMT_Encode4(0), GIMT_Encode4(0), GIMT_Encode4(0), GIMT_Encode4(0), GIMT_Encode4(0), GIMT_Encode4(0), GIMT_Encode4(0), GIMT_Encode4(0), diff --git a/llvm/test/TableGen/GlobalISelEmitter/GlobalISelEmitter.td b/llvm/test/TableGen/GlobalISelEmitter/GlobalISelEmitter.td index 64ca63da3b6f0..c686e0d1519b0 100644 --- a/llvm/test/TableGen/GlobalISelEmitter/GlobalISelEmitter.td +++ b/llvm/test/TableGen/GlobalISelEmitter/GlobalISelEmitter.td @@ -535,7 +535,7 @@ def : Pat<(frag GPR32:$src1, complex:$src2, complex:$src3), // R00O-NEXT: GIM_Reject, // R00O: // Label [[DEFAULT_NUM]]: @[[DEFAULT]] // R00O-NEXT: GIM_Reject, -// R00O-NEXT: }; // Size: 1918 bytes +// R00O-NEXT: }; // Size: 1926 bytes def INSNBOB : I<(outs GPR32:$dst), (ins GPR32:$src1, GPR32:$src2, GPR32:$src3, GPR32:$src4), [(set GPR32:$dst, diff --git a/llvm/test/TableGen/get-named-operand-idx.td b/llvm/test/TableGen/get-named-operand-idx.td index 7982822c0a895..06ec001852e17 100644 --- a/llvm/test/TableGen/get-named-operand-idx.td +++ b/llvm/test/TableGen/get-named-operand-idx.td @@ -98,7 +98,7 @@ defm : RemapAllTargetPseudoPointerOperands; // CHECK-NEXT: 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // CHECK-NEXT: 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // CHECK-NEXT: 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -// CHECK-NEXT: 1, 2, 2, 0, +// CHECK-NEXT: 0, 0, 1, 2, 2, 0, // CHECK-NEXT: }; // CHECK-NEXT: return InstructionIndex[Opcode]; // CHECK-NEXT: } diff --git a/llvm/utils/TableGen/Common/GlobalISel/GlobalISelMatchTable.cpp b/llvm/utils/TableGen/Common/GlobalISel/GlobalISelMatchTable.cpp index 8540faed34e5d..18b05a259f302 100644 --- a/llvm/utils/TableGen/Common/GlobalISel/GlobalISelMatchTable.cpp +++ b/llvm/utils/TableGen/Common/GlobalISel/GlobalISelMatchTable.cpp @@ -1472,6 +1472,9 @@ Error OperandMatcher::addTypeCheckPredicate(const TypeSetByHwMode &VTy, return Error::success(); } + if (VTy.getMachineValueType() == MVT::Untyped) + return Error::success(); + auto OpTyOrNone = MVTToLLT(VTy.getMachineValueType().SimpleTy); if (!OpTyOrNone) return failUnsupported("unsupported type"); From 280fe0ff175882971530b6e211fde5136b24921c Mon Sep 17 00:00:00 2001 From: Anatoly Trosinenko Date: Fri, 24 Oct 2025 17:01:48 +0300 Subject: [PATCH 05/40] --> deactivation-symbol Switch auth/sign/resign to bundles --- clang/lib/CodeGen/CGBuiltin.cpp | 22 ++- clang/lib/CodeGen/CGPointerAuth.cpp | 15 +- clang/lib/CodeGen/CodeGenFunction.cpp | 8 +- .../ptrauth-function-lvalue-cast-disc.c | 8 +- ...ptrauth-function-type-discriminator-cast.c | 12 +- clang/test/CodeGen/ptrauth-in-c-struct.c | 8 +- clang/test/CodeGen/ptrauth-intrinsics.c | 6 +- clang/test/CodeGen/ptrauth-qualifier-blocks.c | 14 +- .../test/CodeGen/ptrauth-qualifier-function.c | 16 +- .../CodeGen/ptrauth-qualifier-loadstore.c | 112 +++++++------- .../ptrauth-restricted-intptr-qualifier.c | 48 +++--- clang/test/CodeGen/ubsan-function.cpp | 2 +- .../CodeGenCXX/builtin-get-vtable-pointer.cpp | 102 ++++++------- .../ptrauth-apple-kext-indirect-call-2.cpp | 2 +- .../CodeGenCXX/ptrauth-dynamic-cast-exact.cpp | 10 +- ...trauth-explicit-vtable-pointer-control.cpp | 144 +++++++++--------- .../ptrauth-member-function-pointer.cpp | 22 +-- .../CodeGenCXX/ptrauth-qualifier-struct.cpp | 8 +- clang/test/CodeGenCXX/ptrauth-thunks.cpp | 2 +- .../CodeGenCXX/ptrauth-type-info-vtable.cpp | 4 +- .../CodeGenCXX/ptrauth-virtual-function.cpp | 66 ++++---- ...rauth-vtable-virtual-inheritance-thunk.cpp | 16 +- clang/test/CodeGenCXX/ubsan-vtable-checks.cpp | 6 +- .../ptrauth-block-descriptor-pointer.m | 2 +- clang/test/CodeGenObjC/ptrauth-block-isa.m | 4 +- clang/test/CodeGenObjC/ptrauth-class.m | 10 +- .../ptrauth-objc-interface-selector.m | 30 ++-- .../CodeGenObjC/ptrauth-property-backing.m | 16 +- .../ptrauth-objc-interface-selector.mm | 10 +- llvm/include/llvm/CodeGen/ISDOpcodes.h | 3 + llvm/include/llvm/IR/Intrinsics.td | 31 ++-- llvm/include/llvm/Support/TargetOpcodes.def | 3 + llvm/include/llvm/Target/GenericOpcodes.td | 18 +++ .../Target/GlobalISel/SelectionDAGCompat.td | 3 + .../include/llvm/Target/TargetSelectionDAG.td | 8 +- llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp | 25 +++ .../SelectionDAG/SelectionDAGBuilder.cpp | 18 +++ .../SelectionDAG/SelectionDAGDumper.cpp | 3 + llvm/lib/IR/Constants.cpp | 10 +- llvm/lib/IR/Verifier.cpp | 5 + .../Target/AArch64/AArch64ISelDAGToDAG.cpp | 78 +++++----- llvm/lib/Target/AArch64/AArch64InstrInfo.td | 6 +- .../AArch64/GISel/AArch64CallLowering.cpp | 17 +-- .../AArch64/GISel/AArch64GlobalISelUtils.cpp | 11 +- .../AArch64/GISel/AArch64GlobalISelUtils.h | 2 +- .../GISel/AArch64InstructionSelector.cpp | 139 +++++++++-------- .../AArch64/GISel/AArch64LegalizerInfo.cpp | 3 + .../InstCombine/InstCombineCalls.cpp | 110 ++++++++----- .../GlobalISel/legalizer-info-validation.mir | 12 ++ llvm/test/CodeGen/AArch64/ptrauth-call.ll | 7 +- llvm/test/CodeGen/AArch64/ptrauth-fpac.ll | 39 +++-- ...trauth-intrinsic-auth-resign-with-blend.ll | 13 +- .../AArch64/ptrauth-intrinsic-auth-resign.ll | 43 +++--- .../CodeGen/AArch64/ptrauth-intrinsic-sign.ll | 18 +-- llvm/test/CodeGen/AArch64/ptrauth-isel.ll | 14 +- .../MIR/AArch64/deactivation-symbols.mir | 2 +- .../Inputs/reference_x86_vocab_print.txt | 3 + .../reference_x86_vocab_wo=0.5_print.txt | 3 + .../match-table-cxx.td | 2 +- .../GlobalISelEmitter/GlobalISelEmitter.td | 2 +- llvm/test/TableGen/get-named-operand-idx.td | 2 +- .../InstCombine/ptrauth-intrinsics-call.ll | 60 ++++---- .../InstCombine/ptrauth-intrinsics.ll | 93 ++++++----- 63 files changed, 820 insertions(+), 711 deletions(-) diff --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp index 4fe5d35b4cd19..65a37ffd4d38f 100644 --- a/clang/lib/CodeGen/CGBuiltin.cpp +++ b/clang/lib/CodeGen/CGBuiltin.cpp @@ -5634,6 +5634,12 @@ RValue CodeGenFunction::EmitBuiltinExpr(const GlobalDecl GD, unsigned BuiltinID, for (auto argExpr : E->arguments()) Args.push_back(EmitScalarExpr(argExpr)); + auto ConvertToIntPtr = [&](Value *V) { + if (V->getType()->isPointerTy()) + return Builder.CreatePtrToInt(V, IntPtrTy); + return Builder.CreateZExt(V, IntPtrTy); + }; + // Cast the value to intptr_t, saving its original type. llvm::Type *OrigValueType = Args[0]->getType(); if (OrigValueType->isPointerTy()) @@ -5641,14 +5647,20 @@ RValue CodeGenFunction::EmitBuiltinExpr(const GlobalDecl GD, unsigned BuiltinID, switch (BuiltinID) { case Builtin::BI__builtin_ptrauth_auth_and_resign: - if (Args[4]->getType()->isPointerTy()) - Args[4] = Builder.CreatePtrToInt(Args[4], IntPtrTy); - [[fallthrough]]; + OBs.emplace_back("ptrauth", ArrayRef({ ConvertToIntPtr(Args[1]), + ConvertToIntPtr(Args[2]) })); + OBs.emplace_back("ptrauth", ArrayRef({ ConvertToIntPtr(Args[3]), + ConvertToIntPtr(Args[4]) })); + + Args.resize(1); + break; case Builtin::BI__builtin_ptrauth_auth: case Builtin::BI__builtin_ptrauth_sign_unauthenticated: - if (Args[2]->getType()->isPointerTy()) - Args[2] = Builder.CreatePtrToInt(Args[2], IntPtrTy); + OBs.emplace_back("ptrauth", ArrayRef({ ConvertToIntPtr(Args[1]), + ConvertToIntPtr(Args[2]) })); + + Args.resize(1); break; case Builtin::BI__builtin_ptrauth_sign_generic_data: diff --git a/clang/lib/CodeGen/CGPointerAuth.cpp b/clang/lib/CodeGen/CGPointerAuth.cpp index a49a0c91681fe..90c4160985f72 100644 --- a/clang/lib/CodeGen/CGPointerAuth.cpp +++ b/clang/lib/CodeGen/CGPointerAuth.cpp @@ -321,18 +321,19 @@ CodeGenFunction::emitPointerAuthResignCall(llvm::Value *Value, auto *OrigType = Value->getType(); Value = Builder.CreatePtrToInt(Value, IntPtrTy); - auto *CurKey = Builder.getInt32(CurAuth.getKey()); - auto *NewKey = Builder.getInt32(NewAuth.getKey()); + llvm::Value *CurKey = Builder.getInt64(CurAuth.getKey()); + llvm::Value *NewKey = Builder.getInt64(NewAuth.getKey()); llvm::Value *CurDiscriminator = getDiscriminatorOrZero(CurAuth, Builder); llvm::Value *NewDiscriminator = getDiscriminatorOrZero(NewAuth, Builder); - // call i64 @llvm.ptrauth.resign(i64 %pointer, - // i32 %curKey, i64 %curDiscriminator, - // i32 %newKey, i64 %newDiscriminator) + llvm::OperandBundleDef CurSchema("ptrauth", ArrayRef({CurKey, CurDiscriminator})); + llvm::OperandBundleDef NewSchema("ptrauth", ArrayRef({NewKey, NewDiscriminator})); + + // call i64 @llvm.ptrauth.resign(i64 %pointer) [ "ptrauth"(), + // "ptrauth"() ] auto *Intrinsic = CGM.getIntrinsic(llvm::Intrinsic::ptrauth_resign); - Value = EmitRuntimeCall( - Intrinsic, {Value, CurKey, CurDiscriminator, NewKey, NewDiscriminator}); + Value = EmitRuntimeCall(Intrinsic, {Value}, {CurSchema, NewSchema}); // Convert back to the original type. Value = Builder.CreateIntToPtr(Value, OrigType); diff --git a/clang/lib/CodeGen/CodeGenFunction.cpp b/clang/lib/CodeGen/CodeGenFunction.cpp index 59db5732fdda5..ae1c605031b3b 100644 --- a/clang/lib/CodeGen/CodeGenFunction.cpp +++ b/clang/lib/CodeGen/CodeGenFunction.cpp @@ -3325,20 +3325,22 @@ static llvm::Value *EmitPointerAuthCommon(CodeGenFunction &CGF, if (!PointerAuth) return Pointer; - auto Key = CGF.Builder.getInt32(PointerAuth.getKey()); + llvm::Value *Key = CGF.Builder.getInt64(PointerAuth.getKey()); llvm::Value *Discriminator = PointerAuth.getDiscriminator(); if (!Discriminator) { Discriminator = CGF.Builder.getSize(0); } + llvm::OperandBundleDef OB("ptrauth", ArrayRef({Key, Discriminator})); + // Convert the pointer to intptr_t before signing it. auto OrigType = Pointer->getType(); Pointer = CGF.Builder.CreatePtrToInt(Pointer, CGF.IntPtrTy); - // call i64 @llvm.ptrauth.sign.i64(i64 %pointer, i32 %key, i64 %discriminator) + // call i64 @llvm.ptrauth.(i64 %pointer) [ "ptrauth"()] auto Intrinsic = CGF.CGM.getIntrinsic(IntrinsicID); - Pointer = CGF.EmitRuntimeCall(Intrinsic, {Pointer, Key, Discriminator}); + Pointer = CGF.EmitRuntimeCall(Intrinsic, {Pointer}, {OB}); // Convert back to the original type. Pointer = CGF.Builder.CreateIntToPtr(Pointer, OrigType); diff --git a/clang/test/CodeGen/ptrauth-function-lvalue-cast-disc.c b/clang/test/CodeGen/ptrauth-function-lvalue-cast-disc.c index 40bba99478192..75bf6d6a1ba10 100644 --- a/clang/test/CodeGen/ptrauth-function-lvalue-cast-disc.c +++ b/clang/test/CodeGen/ptrauth-function-lvalue-cast-disc.c @@ -12,7 +12,7 @@ void (*fptr)(void); void test1() { // TYPE: [[LOAD:%.*]] = load ptr, ptr @cptr // TYPE: [[TOINT:%.*]] = ptrtoint ptr [[LOAD]] to i64 - // TYPE: call i64 @llvm.ptrauth.resign(i64 [[TOINT]], i32 0, i64 0, i32 0, i64 18983) + // TYPE: call i64 @llvm.ptrauth.resign(i64 [[TOINT]]) [ "ptrauth"(i64 0, i64 0), "ptrauth"(i64 0, i64 18983) ] // TYPE: call void {{.*}}() [ "ptrauth"(i32 0, i64 18983) ] // ZERO-NOT: @llvm.ptrauth.resign @@ -29,7 +29,7 @@ char test2() { // TYPE: [[NONNULL]]: // TYPE: [[TOINT:%.*]] = ptrtoint ptr [[LOAD]] to i64 - // TYPE: [[CALL:%.*]] = call i64 @llvm.ptrauth.resign(i64 [[TOINT]], i32 0, i64 18983, i32 0, i64 0) + // TYPE: [[CALL:%.*]] = call i64 @llvm.ptrauth.resign(i64 [[TOINT]]) [ "ptrauth"(i64 0, i64 18983), "ptrauth"(i64 0, i64 0) ] // TYPE: [[TOPTR:%.*]] = inttoptr i64 [[CALL]] to ptr // TYPE: [[CONT]]: @@ -43,7 +43,7 @@ void test4() { // CHECK: [[LOAD:%.*]] = load ptr, ptr @cptr // TYPE-NEXT: [[CAST4:%.*]] = ptrtoint ptr [[LOAD]] to i64 - // TYPE-NEXT: [[RESIGN:%.*]] = call i64 @llvm.ptrauth.resign(i64 [[CAST4]], i32 0, i64 0, i32 0, i64 18983) + // TYPE-NEXT: [[RESIGN:%.*]] = call i64 @llvm.ptrauth.resign(i64 [[CAST4]]) [ "ptrauth"(i64 0, i64 0), "ptrauth"(i64 0, i64 18983) ] // TYPE-NEXT: [[CAST5:%.*]] = inttoptr i64 [[RESIGN]] to ptr // TYPE-NEXT: call void [[CAST5]]() [ "ptrauth"(i32 0, i64 18983) ] // ZERO-NOT: @llvm.ptrauth.resign @@ -60,7 +60,7 @@ void test5() { // TYPE-NEXT: br i1 [[CMP]], label %[[NONNULL:.*]], label %[[CONT:.*]] // TYPE: [[NONNULL]]: - // TYPE: [[RESIGN:%.*]] = call i64 @llvm.ptrauth.resign(i64 {{.*}}, i32 0, i64 18983, i32 0, i64 0) + // TYPE: [[RESIGN:%.*]] = call i64 @llvm.ptrauth.resign(i64 {{.*}}) [ "ptrauth"(i64 0, i64 18983), "ptrauth"(i64 0, i64 0) ] // TYPE: [[CAST:%.*]] = inttoptr i64 [[RESIGN]] to ptr // TYPE: [[CONT]]: diff --git a/clang/test/CodeGen/ptrauth-function-type-discriminator-cast.c b/clang/test/CodeGen/ptrauth-function-type-discriminator-cast.c index 1a1dce6f4a66e..021bb3e38b74c 100644 --- a/clang/test/CodeGen/ptrauth-function-type-discriminator-cast.c +++ b/clang/test/CodeGen/ptrauth-function-type-discriminator-cast.c @@ -34,7 +34,7 @@ ptr_member pm; void (*test_member)() = (void (*)())pm.fptr_; // CHECKCXX-LABEL: define{{.*}} internal void @__cxx_global_var_init -// TYPECXX: call i64 @llvm.ptrauth.resign(i64 {{.*}}, i32 0, i64 2712, i32 0, i64 18983) +// TYPECXX: call i64 @llvm.ptrauth.resign(i64 {{.*}}) [ "ptrauth"(i64 0, i64 2712), "ptrauth"(i64 0, i64 18983) ] #endif @@ -42,7 +42,7 @@ void (*test_member)() = (void (*)())pm.fptr_; void test_cast_to_opaque() { opaque = (void *)f; - // TYPE: [[RESIGN_VAL:%.*]] = call i64 @llvm.ptrauth.resign(i64 ptrtoint (ptr ptrauth (ptr @f, i32 0, i64 18983) to i64), i32 0, i64 18983, i32 0, i64 0) + // TYPE: [[RESIGN_VAL:%.*]] = call i64 @llvm.ptrauth.resign(i64 ptrtoint (ptr ptrauth (ptr @f, i32 0, i64 18983) to i64)) [ "ptrauth"(i64 0, i64 18983), "ptrauth"(i64 0, i64 0) ] // TYPE: [[RESIGN_PTR:%.*]] = inttoptr i64 [[RESIGN_VAL]] to ptr // ZERO-NOT: @llvm.ptrauth.resign } @@ -57,7 +57,7 @@ void test_cast_from_opaque() { // TYPE: [[RESIGN_LAB]]: // TYPE: [[INT:%.*]] = ptrtoint ptr [[LOAD]] to i64 - // TYPE: [[RESIGN_INT:%.*]] = call i64 @llvm.ptrauth.resign(i64 [[INT]], i32 0, i64 0, i32 0, i64 18983) + // TYPE: [[RESIGN_INT:%.*]] = call i64 @llvm.ptrauth.resign(i64 [[INT]]) [ "ptrauth"(i64 0, i64 0), "ptrauth"(i64 0, i64 18983) ] // ZERO-NOT: @llvm.ptrauth.resign } @@ -73,7 +73,7 @@ void test_cast_to_intptr() { // TYPE: [[RESIGN_LAB]]: // TYPE: [[INT:%.*]] = ptrtoint ptr [[LOAD]] to i64 - // TYPE: [[RESIGN_INT:%.*]] = call i64 @llvm.ptrauth.resign(i64 [[INT]], i32 0, i64 18983, i32 0, i64 0) + // TYPE: [[RESIGN_INT:%.*]] = call i64 @llvm.ptrauth.resign(i64 [[INT]]) [ "ptrauth"(i64 0, i64 18983), "ptrauth"(i64 0, i64 0) ] // TYPE: [[RESIGN:%.*]] = inttoptr i64 [[RESIGN_INT]] to ptr // TYPE: br label %[[RESIGN_CONT]] @@ -86,7 +86,7 @@ void test_cast_to_intptr() { // CHECK-LABEL: define{{.*}} void @test_function_to_function_cast void test_function_to_function_cast() { void (*fptr2)(int) = (void (*)(int))fptr; - // TYPE: call i64 @llvm.ptrauth.resign(i64 {{.*}}, i32 0, i64 18983, i32 0, i64 2712) + // TYPE: call i64 @llvm.ptrauth.resign(i64 {{.*}}) [ "ptrauth"(i64 0, i64 18983), "ptrauth"(i64 0, i64 2712) ] // ZERO-NOT: @llvm.ptrauth.resign } @@ -95,7 +95,7 @@ void test_call_lvalue_cast() { (*(void (*)(int))f)(42); // TYPE: entry: - // TYPE-NEXT: [[RESIGN:%.*]] = call i64 @llvm.ptrauth.resign(i64 ptrtoint (ptr ptrauth (ptr @f, i32 0, i64 18983) to i64), i32 0, i64 18983, i32 0, i64 2712) + // TYPE-NEXT: [[RESIGN:%.*]] = call i64 @llvm.ptrauth.resign(i64 ptrtoint (ptr ptrauth (ptr @f, i32 0, i64 18983) to i64)) [ "ptrauth"(i64 0, i64 18983), "ptrauth"(i64 0, i64 2712) ] // TYPE-NEXT: [[RESIGN_INT:%.*]] = inttoptr i64 [[RESIGN]] to ptr // TYPE-NEXT: call void [[RESIGN_INT]](i32 noundef 42) [ "ptrauth"(i32 0, i64 2712) ] // ZERO-NOT: @llvm.ptrauth.resign diff --git a/clang/test/CodeGen/ptrauth-in-c-struct.c b/clang/test/CodeGen/ptrauth-in-c-struct.c index c74be17b4c837..f21ce51eb3f04 100644 --- a/clang/test/CodeGen/ptrauth-in-c-struct.c +++ b/clang/test/CodeGen/ptrauth-in-c-struct.c @@ -59,7 +59,7 @@ int g0; // CHECK: %[[V14:.*]] = ptrtoint ptr %[[V6]] to i64 // CHECK: %[[V15:.*]] = call i64 @llvm.ptrauth.blend(i64 %[[V14]], i64 50) // CHECK: %[[V17:.*]] = ptrtoint ptr %[[V11]] to i64 -// CHECK: %[[V18:.*]] = call i64 @llvm.ptrauth.resign(i64 %[[V17]], i32 1, i64 %[[V13]], i32 1, i64 %[[V15]]) +// CHECK: %[[V18:.*]] = call i64 @llvm.ptrauth.resign(i64 %[[V17]]) [ "ptrauth"(i64 1, i64 %[[V13]]), "ptrauth"(i64 1, i64 %[[V15]]) ] void test_copy_constructor_SA(SA *s) { SA t = *s; @@ -83,7 +83,7 @@ void test_copy_constructor_SA(SA *s) { // CHECK: %[[V14:.*]] = ptrtoint ptr %[[V6]] to i64 // CHECK: %[[V15:.*]] = call i64 @llvm.ptrauth.blend(i64 %[[V14]], i64 30) // CHECK: %[[V17:.*]] = ptrtoint ptr %[[V11]] to i64 -// CHECK: %[[V18:.*]] = call i64 @llvm.ptrauth.resign(i64 %[[V17]], i32 2, i64 %[[V13]], i32 2, i64 %[[V15]]) +// CHECK: %[[V18:.*]] = call i64 @llvm.ptrauth.resign(i64 %[[V17]]) [ "ptrauth"(i64 2, i64 %[[V13]]), "ptrauth"(i64 2, i64 %[[V15]]) ] void test_copy_constructor_SA2(SA2 *s) { SA2 t = *s; @@ -169,13 +169,13 @@ void test_parameter_SI(SI a) { // CHECK: %[[F1:.*]] = getelementptr inbounds nuw %[[STRUCT_SA]], ptr %{{.*}}, i32 0, i32 1 // CHECK: %[[V0:.*]] = ptrtoint ptr %[[F1]] to i64 // CHECK: %[[V1:.*]] = call i64 @llvm.ptrauth.blend(i64 %[[V0]], i64 50) -// CHECK: %[[V2:.*]] = call i64 @llvm.ptrauth.sign(i64 ptrtoint (ptr @g0 to i64), i32 1, i64 %[[V1]]) +// CHECK: %[[V2:.*]] = call i64 @llvm.ptrauth.sign(i64 ptrtoint (ptr @g0 to i64)) [ "ptrauth"(i64 1, i64 %[[V1]]) ] // CHECK: %[[V3:.*]] = inttoptr i64 %[[V2]] to ptr // CHECK: store ptr %[[V3]], ptr %[[F1]], align 8 // CHECK: %[[F12:.*]] = getelementptr inbounds nuw %[[STRUCT_SA]], ptr %{{.*}}, i32 0, i32 1 // CHECK: %[[V4:.*]] = ptrtoint ptr %[[F12]] to i64 // CHECK: %[[V5:.*]] = call i64 @llvm.ptrauth.blend(i64 %[[V4]], i64 50) -// CHECK: %[[V6:.*]] = call i64 @llvm.ptrauth.sign(i64 ptrtoint (ptr @g0 to i64), i32 1, i64 %[[V5]]) +// CHECK: %[[V6:.*]] = call i64 @llvm.ptrauth.sign(i64 ptrtoint (ptr @g0 to i64)) [ "ptrauth"(i64 1, i64 %[[V5]]) ] // CHECK: %[[V7:.*]] = inttoptr i64 %[[V6]] to ptr // CHECK: store ptr %[[V7]], ptr %[[F12]], align 8 diff --git a/clang/test/CodeGen/ptrauth-intrinsics.c b/clang/test/CodeGen/ptrauth-intrinsics.c index 06313c83b4963..116739e67a146 100644 --- a/clang/test/CodeGen/ptrauth-intrinsics.c +++ b/clang/test/CodeGen/ptrauth-intrinsics.c @@ -15,7 +15,7 @@ void test_auth() { // CHECK-NEXT: [[DISC0:%.*]] = load ptr, ptr @ptr_discriminator, // CHECK-NEXT: [[T0:%.*]] = ptrtoint ptr [[PTR]] to i64 // CHECK-NEXT: [[DISC:%.*]] = ptrtoint ptr [[DISC0]] to i64 - // CHECK-NEXT: [[T1:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[T0]], i32 0, i64 [[DISC]]) + // CHECK-NEXT: [[T1:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[T0]]) [ "ptrauth"(i64 0, i64 [[DISC]]) ] // CHECK-NEXT: [[RESULT:%.*]] = inttoptr i64 [[T1]] to ptr // CHECK-NEXT: store ptr [[RESULT]], ptr @fnptr, fnptr = __builtin_ptrauth_auth(fnptr, 0, ptr_discriminator); @@ -37,7 +37,7 @@ void test_sign_unauthenticated() { // CHECK-NEXT: [[DISC0:%.*]] = load ptr, ptr @ptr_discriminator, // CHECK-NEXT: [[T0:%.*]] = ptrtoint ptr [[PTR]] to i64 // CHECK-NEXT: [[DISC:%.*]] = ptrtoint ptr [[DISC0]] to i64 - // CHECK-NEXT: [[T1:%.*]] = call i64 @llvm.ptrauth.sign(i64 [[T0]], i32 0, i64 [[DISC]]) + // CHECK-NEXT: [[T1:%.*]] = call i64 @llvm.ptrauth.sign(i64 [[T0]]) [ "ptrauth"(i64 0, i64 [[DISC]]) ] // CHECK-NEXT: [[RESULT:%.*]] = inttoptr i64 [[T1]] to ptr // CHECK-NEXT: store ptr [[RESULT]], ptr @fnptr, fnptr = __builtin_ptrauth_sign_unauthenticated(fnptr, 0, ptr_discriminator); @@ -49,7 +49,7 @@ void test_auth_and_resign() { // CHECK-NEXT: [[DISC0:%.*]] = load ptr, ptr @ptr_discriminator, // CHECK-NEXT: [[T0:%.*]] = ptrtoint ptr [[PTR]] to i64 // CHECK-NEXT: [[DISC:%.*]] = ptrtoint ptr [[DISC0]] to i64 - // CHECK-NEXT: [[T1:%.*]] = call i64 @llvm.ptrauth.resign(i64 [[T0]], i32 0, i64 [[DISC]], i32 3, i64 15) + // CHECK-NEXT: [[T1:%.*]] = call i64 @llvm.ptrauth.resign(i64 [[T0]]) [ "ptrauth"(i64 0, i64 [[DISC]]), "ptrauth"(i64 3, i64 15) ] // CHECK-NEXT: [[RESULT:%.*]] = inttoptr i64 [[T1]] to ptr // CHECK-NEXT: store ptr [[RESULT]], ptr @fnptr, fnptr = __builtin_ptrauth_auth_and_resign(fnptr, 0, ptr_discriminator, 3, 15); diff --git a/clang/test/CodeGen/ptrauth-qualifier-blocks.c b/clang/test/CodeGen/ptrauth-qualifier-blocks.c index f460da205cac7..1b9dc749e63d3 100644 --- a/clang/test/CodeGen/ptrauth-qualifier-blocks.c +++ b/clang/test/CodeGen/ptrauth-qualifier-blocks.c @@ -20,7 +20,7 @@ void test_block_nonaddress_capture() { use_block(^{ return ptr->value; }); } // CHECK-LABEL: define internal i32 @__test_block_nonaddress_capture_block_invoke -// CHECK: call i64 @llvm.ptrauth.auth(i64 {{%.*}}, i32 1, i64 15) +// CHECK: call i64 @llvm.ptrauth.auth(i64 {{%.*}}) [ "ptrauth"(i64 1, i64 15) ] // CHECK-LABEL: define void @test_block_address_capture( void test_block_address_capture() { @@ -37,7 +37,7 @@ void test_block_address_capture() { // CHECK: [[T0:%.*]] = icmp ne ptr [[LOAD]], null // CHECK: br i1 [[T0]] // CHECK: [[T0:%.*]] = ptrtoint ptr [[LOAD]] to i64 - // CHECK: [[T1:%.*]] = call i64 @llvm.ptrauth.resign(i64 [[T0]], i32 1, i64 [[OLDDISC]], i32 1, i64 [[NEWDISC]]) + // CHECK: [[T1:%.*]] = call i64 @llvm.ptrauth.resign(i64 [[T0]]) [ "ptrauth"(i64 1, i64 [[OLDDISC]]), "ptrauth"(i64 1, i64 [[NEWDISC]]) ] // CHECK: [[T2:%.*]] = inttoptr i64 [[T1]] to ptr // CHECK: [[T0:%.*]] = phi // CHECK: store ptr [[T0]], ptr [[CAPTURE]] @@ -45,7 +45,7 @@ void test_block_address_capture() { use_block(^{ return ptr->value; }); } // CHECK-LABEL: define internal i32 @__test_block_address_capture_block_invoke -// CHECK: call i64 @llvm.ptrauth.auth(i64 {{%.*}}, i32 1, i64 {{%.*}}) +// CHECK: call i64 @llvm.ptrauth.auth(i64 {{%.*}}) [ "ptrauth"(i64 1, i64 {{%.*}}) ] // CHECK: linkonce_odr hidden void @__copy_helper_block_8_32p1d30( // CHECK: [[OLDSLOT:%.*]] = getelementptr inbounds {{.*}} {{.*}}, i32 0, i32 5 @@ -58,7 +58,7 @@ void test_block_address_capture() { // CHECK: [[T0:%.*]] = icmp ne ptr [[LOAD]], null // CHECK: br i1 [[T0]] // CHECK: [[T0:%.*]] = ptrtoint ptr [[LOAD]] to i64 -// CHECK: [[T1:%.*]] = call i64 @llvm.ptrauth.resign(i64 [[T0]], i32 1, i64 [[OLDDISC]], i32 1, i64 [[NEWDISC]]) +// CHECK: [[T1:%.*]] = call i64 @llvm.ptrauth.resign(i64 [[T0]]) [ "ptrauth"(i64 1, i64 [[OLDDISC]]), "ptrauth"(i64 1, i64 [[NEWDISC]]) ] // CHECK: [[T2:%.*]] = inttoptr i64 [[T1]] to ptr // CHECK: [[T0:%.*]] = phi // CHECK: store ptr [[T0]], ptr [[NEWSLOT]] @@ -83,12 +83,12 @@ void test_block_address_byref_capture() { // CHECK: store i32 48, // CHECK: [[COPY_HELPER_FIELD:%.*]] = getelementptr inbounds nuw [[BYREF_T]], ptr [[BYREF]], i32 0, i32 4 // CHECK: [[T0:%.*]] = ptrtoint ptr [[COPY_HELPER_FIELD]] to i64 - // CHECK: [[T1:%.*]] = call i64 @llvm.ptrauth.sign(i64 ptrtoint (ptr @__Block_byref_object_copy_ to i64), i32 0, i64 [[T0]]) + // CHECK: [[T1:%.*]] = call i64 @llvm.ptrauth.sign(i64 ptrtoint (ptr @__Block_byref_object_copy_ to i64)) [ "ptrauth"(i64 0, i64 [[T0]]) ] // CHECK: [[T2:%.*]] = inttoptr i64 [[T1]] to ptr // CHECK: store ptr [[T2]], ptr [[COPY_HELPER_FIELD]], align // CHECK: [[DISPOSE_HELPER_FIELD:%.*]] = getelementptr inbounds nuw [[BYREF_T]], ptr [[BYREF]], i32 0, i32 5 // CHECK: [[T0:%.*]] = ptrtoint ptr [[DISPOSE_HELPER_FIELD]] to i64 - // CHECK: [[T1:%.*]] = call i64 @llvm.ptrauth.sign(i64 ptrtoint (ptr @__Block_byref_object_dispose_ to i64), i32 0, i64 [[T0]]) + // CHECK: [[T1:%.*]] = call i64 @llvm.ptrauth.sign(i64 ptrtoint (ptr @__Block_byref_object_dispose_ to i64)) [ "ptrauth"(i64 0, i64 [[T0]]) ] // CHECK: [[T2:%.*]] = inttoptr i64 [[T1]] to ptr // CHECK: store ptr [[T2]], ptr [[DISPOSE_HELPER_FIELD]], align // flags - copy/dispose required @@ -107,7 +107,7 @@ void test_block_address_byref_capture() { // CHECK: [[T0:%.*]] = icmp ne ptr [[LOAD]], null // CHECK: br i1 [[T0]] // CHECK: [[T0:%.*]] = ptrtoint ptr [[LOAD]] to i64 -// CHECK: [[T1:%.*]] = call i64 @llvm.ptrauth.resign(i64 [[T0]], i32 1, i64 [[OLDDISC]], i32 1, i64 [[NEWDISC]]) +// CHECK: [[T1:%.*]] = call i64 @llvm.ptrauth.resign(i64 [[T0]]) [ "ptrauth"(i64 1, i64 [[OLDDISC]]), "ptrauth"(i64 1, i64 [[NEWDISC]]) ] // CHECK: [[T2:%.*]] = inttoptr i64 [[T1]] to ptr // CHECK: [[T0:%.*]] = phi // CHECK: store ptr [[T0]], ptr [[NEWSLOT]] diff --git a/clang/test/CodeGen/ptrauth-qualifier-function.c b/clang/test/CodeGen/ptrauth-qualifier-function.c index cd25b77a01548..f21ad5ab9b7c2 100644 --- a/clang/test/CodeGen/ptrauth-qualifier-function.c +++ b/clang/test/CodeGen/ptrauth-qualifier-function.c @@ -26,7 +26,7 @@ void test_assign_to_qualified() { // TYPE: [[RESIGN1]]: // TYPE-NEXT: [[FPTR2:%.*]] = ptrtoint ptr [[FPTR]] to i64 - // TYPE-NEXT: [[FPTR4:%.*]] = call i64 @llvm.ptrauth.resign(i64 [[FPTR2]], i32 0, i64 18983, i32 0, i64 2712) + // TYPE-NEXT: [[FPTR4:%.*]] = call i64 @llvm.ptrauth.resign(i64 [[FPTR2]]) [ "ptrauth"(i64 0, i64 18983), "ptrauth"(i64 0, i64 2712) ] // TYPE-NEXT: [[FPTR5:%.*]] = inttoptr i64 [[FPTR4]] to ptr // TYPE-NEXT: br label %[[JOIN1]] @@ -37,9 +37,9 @@ void test_assign_to_qualified() { // CHECK: [[RESIGN2]]: // TYPE-NEXT: [[FPTR7:%.*]] = ptrtoint ptr [[FPTR6]] to i64 - // TYPE-NEXT: [[FPTR8:%.*]] = call i64 @llvm.ptrauth.resign(i64 [[FPTR7]], i32 0, i64 2712, i32 0, i64 42) + // TYPE-NEXT: [[FPTR8:%.*]] = call i64 @llvm.ptrauth.resign(i64 [[FPTR7]]) [ "ptrauth"(i64 0, i64 2712), "ptrauth"(i64 0, i64 42) ] // ZERO-NEXT: [[FPTR7:%.*]] = ptrtoint ptr [[FPTR]] to i64 - // ZERO-NEXT: [[FPTR8:%.*]] = call i64 @llvm.ptrauth.resign(i64 [[FPTR7]], i32 0, i64 0, i32 0, i64 42) + // ZERO-NEXT: [[FPTR8:%.*]] = call i64 @llvm.ptrauth.resign(i64 [[FPTR7]]) [ "ptrauth"(i64 0, i64 0), "ptrauth"(i64 0, i64 42) ] // CHECK-NEXT: [[FPTR9:%.*]] = inttoptr i64 [[FPTR8]] to ptr // CHECK-NEXT: br label %[[JOIN2]] @@ -61,7 +61,7 @@ void test_assign_from_qualified() { // TYPE: [[RESIGN1]]: // TYPE-NEXT: [[FPTR1:%.*]] = ptrtoint ptr [[FPTR]] to i64 - // TYPE-NEXT: [[FPTR2:%.*]] = call i64 @llvm.ptrauth.resign(i64 [[FPTR1]], i32 0, i64 42, i32 0, i64 2712) + // TYPE-NEXT: [[FPTR2:%.*]] = call i64 @llvm.ptrauth.resign(i64 [[FPTR1]]) [ "ptrauth"(i64 0, i64 42), "ptrauth"(i64 0, i64 2712) ] // TYPE-NEXT: [[FPTR3:%.*]] = inttoptr i64 [[FPTR2]] to ptr // TYPE-NEXT: br label %[[JOIN1]] @@ -72,9 +72,9 @@ void test_assign_from_qualified() { // CHECK: [[RESIGN2]]: // TYPE-NEXT: [[FPTR6:%.*]] = ptrtoint ptr [[FPTR4]] to i64 - // TYPE-NEXT: [[FPTR7:%.*]] = call i64 @llvm.ptrauth.resign(i64 [[FPTR6]], i32 0, i64 2712, i32 0, i64 18983) + // TYPE-NEXT: [[FPTR7:%.*]] = call i64 @llvm.ptrauth.resign(i64 [[FPTR6]]) [ "ptrauth"(i64 0, i64 2712), "ptrauth"(i64 0, i64 18983) ] // ZERO-NEXT: [[FPTR6:%.*]] = ptrtoint ptr [[FPTR]] to i64 - // ZERO-NEXT: [[FPTR7:%.*]] = call i64 @llvm.ptrauth.resign(i64 [[FPTR6]], i32 0, i64 42, i32 0, i64 0) + // ZERO-NEXT: [[FPTR7:%.*]] = call i64 @llvm.ptrauth.resign(i64 [[FPTR6]]) [ "ptrauth"(i64 0, i64 42), "ptrauth"(i64 0, i64 0) ] // CHECK-NEXT: [[FPTR8:%.*]] = inttoptr i64 [[FPTR7]] to ptr // CHECK-NEXT: br label %[[JOIN2]] @@ -105,7 +105,7 @@ void (* const __ptrauth(0, 1, 43) &f_ref)(int) = f_const_ptr2; // CHECK-CXX: [[RESIGN_NONNULL]]: // CHECK-CXX: %[[V1:.*]] = ptrtoint ptr %[[CALL]] to i64 -// CHECK-CXX: %[[V2:.*]] = call i64 @llvm.ptrauth.resign(i64 %[[V1]], i32 0, i64 2712, i32 0, i64 42) +// CHECK-CXX: %[[V2:.*]] = call i64 @llvm.ptrauth.resign(i64 %[[V1]]) [ "ptrauth"(i64 0, i64 2712), "ptrauth"(i64 0, i64 42) ] // CHECK-CXX: %[[V3:.*]] = inttoptr i64 %[[V2]] to ptr // CHECK-CXX: br label %[[RESIGN_CONT]] @@ -122,7 +122,7 @@ void (* const __ptrauth(0, 1, 43) &f_ref)(int) = f_const_ptr2; // CHECK-CXX: [[RESIGN_NONNULL]]: // CHECK-CXX: %[[V3:.*]] = ptrtoint ptr %[[V0]] to i64 -// CHECK-CXX: %[[V4:.*]] = call i64 @llvm.ptrauth.resign(i64 %[[V3]], i32 0, i64 42, i32 0, i64 %[[V1]]) +// CHECK-CXX: %[[V4:.*]] = call i64 @llvm.ptrauth.resign(i64 %[[V3]]) [ "ptrauth"(i64 0, i64 42), "ptrauth"(i64 0, i64 %[[V1]]) ] // CHECK-CXX: %[[V5:.*]] = inttoptr i64 %[[V4]] to ptr // CHECK-CXX: br label %[[RESIGN_CONT]] diff --git a/clang/test/CodeGen/ptrauth-qualifier-loadstore.c b/clang/test/CodeGen/ptrauth-qualifier-loadstore.c index db259ed950fec..f8348ce43ce74 100644 --- a/clang/test/CodeGen/ptrauth-qualifier-loadstore.c +++ b/clang/test/CodeGen/ptrauth-qualifier-loadstore.c @@ -26,11 +26,11 @@ extern void use_upf(func_t *ptr); // CHECK-LABEL: define {{.*}}void @test_store_data_i_constant() void test_store_data_i_constant() { // CHECK: [[V:%.*]] = alloca ptr, -// CHECK-NEXT: [[SIGN:%.*]] = call i64 @llvm.ptrauth.sign(i64 ptrtoint (ptr @external_int to i64), i32 1, i64 50) +// CHECK-NEXT: [[SIGN:%.*]] = call i64 @llvm.ptrauth.sign(i64 ptrtoint (ptr @external_int to i64)) [ "ptrauth"(i64 1, i64 50) ] // CHECK-NEXT: [[T0:%.*]] = inttoptr i64 [[SIGN]] to ptr // CHECK-NEXT: store ptr [[T0]], ptr [[V]], int * IQ iqpi = &external_int; -// CHECK-NEXT: [[T0:%.*]] = call i64 @llvm.ptrauth.sign(i64 ptrtoint (ptr @external_int to i64), i32 1, i64 50) +// CHECK-NEXT: [[T0:%.*]] = call i64 @llvm.ptrauth.sign(i64 ptrtoint (ptr @external_int to i64)) [ "ptrauth"(i64 1, i64 50) ] // CHECK-NEXT: [[SIGNED:%.*]] = inttoptr i64 [[T0]] to ptr // CHECK-NEXT: store ptr [[SIGNED]], ptr [[V]], // CHECK-NEXT: ret void @@ -44,7 +44,7 @@ void test_store_data_iu() { // CHECK-NEXT: [[T0:%.*]] = icmp ne ptr [[LOAD]], null // CHECK-NEXT: br i1 [[T0]], // CHECK: [[T0:%.*]] = ptrtoint ptr [[LOAD]] to i64 -// CHECK-NEXT: [[T1:%.*]] = call i64 @llvm.ptrauth.sign(i64 [[T0]], i32 1, i64 50) +// CHECK-NEXT: [[T1:%.*]] = call i64 @llvm.ptrauth.sign(i64 [[T0]]) [ "ptrauth"(i64 1, i64 50) ] // CHECK-NEXT: [[SIGNED:%.*]] = inttoptr i64 [[T1]] to ptr // CHECK-NEXT: br label // CHECK: [[T0:%.*]] = phi ptr [ null, {{.*}} ], [ [[SIGNED]], {{.*}} ] @@ -54,7 +54,7 @@ void test_store_data_iu() { // CHECK-NEXT: [[T0:%.*]] = icmp ne ptr [[LOAD]], null // CHECK-NEXT: br i1 [[T0]], // CHECK: [[T0:%.*]] = ptrtoint ptr [[LOAD]] to i64 -// CHECK-NEXT: [[T1:%.*]] = call i64 @llvm.ptrauth.sign(i64 [[T0]], i32 1, i64 50) +// CHECK-NEXT: [[T1:%.*]] = call i64 @llvm.ptrauth.sign(i64 [[T0]]) [ "ptrauth"(i64 1, i64 50) ] // CHECK-NEXT: [[SIGNED:%.*]] = inttoptr i64 [[T1]] to ptr // CHECK-NEXT: br label // CHECK: [[T0:%.*]] = phi ptr [ null, {{.*}} ], [ [[SIGNED]], {{.*}} ] @@ -70,7 +70,7 @@ void test_store_data_ia() { // CHECK-NEXT: [[T0:%.*]] = icmp ne ptr [[LOAD]], null // CHECK-NEXT: br i1 [[T0]], // CHECK: [[T0:%.*]] = ptrtoint ptr [[LOAD]] to i64 -// CHECK-NEXT: [[T1:%.*]] = call i64 @llvm.ptrauth.resign(i64 [[T0]], i32 1, i64 [[OLDDISC]], i32 1, i64 50) +// CHECK-NEXT: [[T1:%.*]] = call i64 @llvm.ptrauth.resign(i64 [[T0]]) [ "ptrauth"(i64 1, i64 [[OLDDISC]]), "ptrauth"(i64 1, i64 50) ] // CHECK-NEXT: [[SIGNED:%.*]] = inttoptr i64 [[T1]] to ptr // CHECK-NEXT: br label // CHECK: [[T0:%.*]] = phi ptr [ null, {{.*}} ], [ [[SIGNED]], {{.*}} ] @@ -81,7 +81,7 @@ void test_store_data_ia() { // CHECK-NEXT: [[T0:%.*]] = icmp ne ptr [[LOAD]], null // CHECK-NEXT: br i1 [[T0]], // CHECK: [[T0:%.*]] = ptrtoint ptr [[LOAD]] to i64 -// CHECK-NEXT: [[T1:%.*]] = call i64 @llvm.ptrauth.resign(i64 [[T0]], i32 1, i64 [[OLDDISC]], i32 1, i64 50) +// CHECK-NEXT: [[T1:%.*]] = call i64 @llvm.ptrauth.resign(i64 [[T0]]) [ "ptrauth"(i64 1, i64 [[OLDDISC]]), "ptrauth"(i64 1, i64 50) ] // CHECK-NEXT: [[SIGNED:%.*]] = inttoptr i64 [[T1]] to ptr // CHECK-NEXT: br label // CHECK: [[T0:%.*]] = phi ptr [ null, {{.*}} ], [ [[SIGNED]], {{.*}} ] @@ -92,7 +92,7 @@ void test_store_data_ia() { // CHECK-NEXT: [[T0:%.*]] = icmp ne ptr [[LOAD]], null // CHECK-NEXT: br i1 [[T0]], // CHECK: [[T0:%.*]] = ptrtoint ptr [[LOAD]] to i64 -// CHECK-NEXT: [[T1:%.*]] = call i64 @llvm.ptrauth.resign(i64 [[T0]], i32 1, i64 [[OLDDISC]], i32 1, i64 50) +// CHECK-NEXT: [[T1:%.*]] = call i64 @llvm.ptrauth.resign(i64 [[T0]]) [ "ptrauth"(i64 1, i64 [[OLDDISC]]), "ptrauth"(i64 1, i64 50) ] // CHECK-NEXT: [[SIGNED:%.*]] = inttoptr i64 [[T1]] to ptr // CHECK-NEXT: br label // CHECK: [[RESULT:%.*]] = phi ptr [ null, {{.*}} ], [ [[SIGNED]], {{.*}} ] @@ -100,7 +100,7 @@ void test_store_data_ia() { // CHECK-NEXT: [[T0:%.*]] = icmp ne ptr [[RESULT]], null // CHECK-NEXT: br i1 [[T0]], // CHECK: [[T0:%.*]] = ptrtoint ptr [[RESULT]] to i64 -// CHECK-NEXT: [[T1:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[T0]], i32 1, i64 50) +// CHECK-NEXT: [[T1:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[T0]]) [ "ptrauth"(i64 1, i64 50) ] // CHECK-NEXT: [[AUTHED:%.*]] = inttoptr i64 [[T1]] to ptr // CHECK-NEXT: br label // CHECK: [[RESULT:%.*]] = phi ptr [ null, {{.*}} ], [ [[AUTHED]], {{.*}} ] @@ -126,7 +126,7 @@ void test_store_data_ii_different() { // CHECK-NEXT: [[T0:%.*]] = icmp ne ptr [[LOAD]], null // CHECK-NEXT: br i1 [[T0]], // CHECK: [[T0:%.*]] = ptrtoint ptr [[LOAD]] to i64 -// CHECK-NEXT: [[T1:%.*]] = call i64 @llvm.ptrauth.resign(i64 [[T0]], i32 1, i64 50, i32 1, i64 100) +// CHECK-NEXT: [[T1:%.*]] = call i64 @llvm.ptrauth.resign(i64 [[T0]]) [ "ptrauth"(i64 1, i64 50), "ptrauth"(i64 1, i64 100) ] // CHECK-NEXT: [[SIGNED:%.*]] = inttoptr i64 [[T1]] to ptr // CHECK-NEXT: br label // CHECK: [[T0:%.*]] = phi ptr [ null, {{.*}} ], [ [[SIGNED]], {{.*}} ] @@ -136,7 +136,7 @@ void test_store_data_ii_different() { // CHECK-NEXT: [[T0:%.*]] = icmp ne ptr [[LOAD]], null // CHECK-NEXT: br i1 [[T0]], // CHECK: [[T0:%.*]] = ptrtoint ptr [[LOAD]] to i64 -// CHECK-NEXT: [[T1:%.*]] = call i64 @llvm.ptrauth.resign(i64 [[T0]], i32 1, i64 50, i32 1, i64 100) +// CHECK-NEXT: [[T1:%.*]] = call i64 @llvm.ptrauth.resign(i64 [[T0]]) [ "ptrauth"(i64 1, i64 50), "ptrauth"(i64 1, i64 100) ] // CHECK-NEXT: [[SIGNED:%.*]] = inttoptr i64 [[T1]] to ptr // CHECK-NEXT: br label // CHECK: [[T0:%.*]] = phi ptr [ null, {{.*}} ], [ [[SIGNED]], {{.*}} ] @@ -151,7 +151,7 @@ void test_store_data_ii_zero() { // CHECK-NEXT: [[T0:%.*]] = icmp ne ptr [[LOAD]], null // CHECK-NEXT: br i1 [[T0]], // CHECK: [[T0:%.*]] = ptrtoint ptr [[LOAD]] to i64 -// CHECK-NEXT: [[T1:%.*]] = call i64 @llvm.ptrauth.resign(i64 [[T0]], i32 1, i64 50, i32 1, i64 0) +// CHECK-NEXT: [[T1:%.*]] = call i64 @llvm.ptrauth.resign(i64 [[T0]]) [ "ptrauth"(i64 1, i64 50), "ptrauth"(i64 1, i64 0) ] // CHECK-NEXT: [[SIGNED:%.*]] = inttoptr i64 [[T1]] to ptr // CHECK-NEXT: br label // CHECK: [[T0:%.*]] = phi ptr [ null, {{.*}} ], [ [[SIGNED]], {{.*}} ] @@ -161,7 +161,7 @@ void test_store_data_ii_zero() { // CHECK-NEXT: [[T0:%.*]] = icmp ne ptr [[LOAD]], null // CHECK-NEXT: br i1 [[T0]], // CHECK: [[T0:%.*]] = ptrtoint ptr [[LOAD]] to i64 -// CHECK-NEXT: [[T1:%.*]] = call i64 @llvm.ptrauth.resign(i64 [[T0]], i32 1, i64 0, i32 1, i64 50) +// CHECK-NEXT: [[T1:%.*]] = call i64 @llvm.ptrauth.resign(i64 [[T0]]) [ "ptrauth"(i64 1, i64 0), "ptrauth"(i64 1, i64 50) ] // CHECK-NEXT: [[SIGNED:%.*]] = inttoptr i64 [[T1]] to ptr // CHECK-NEXT: br label // CHECK: [[T0:%.*]] = phi ptr [ null, {{.*}} ], [ [[SIGNED]], {{.*}} ] @@ -176,7 +176,7 @@ void test_load_data_i() { // CHECK-NEXT: [[T0:%.*]] = icmp ne ptr [[LOAD]], null // CHECK-NEXT: br i1 [[T0]], // CHECK: [[T0:%.*]] = ptrtoint ptr [[LOAD]] to i64 -// CHECK-NEXT: [[T1:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[T0]], i32 1, i64 50) +// CHECK-NEXT: [[T1:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[T0]]) [ "ptrauth"(i64 1, i64 50) ] // CHECK-NEXT: [[AUTHED:%.*]] = inttoptr i64 [[T1]] to ptr // CHECK-NEXT: br label // CHECK: [[T0:%.*]] = phi ptr [ null, {{.*}} ], [ [[AUTHED]], {{.*}} ] @@ -186,7 +186,7 @@ void test_load_data_i() { // CHECK-NEXT: [[T0:%.*]] = icmp ne ptr [[LOAD]], null // CHECK-NEXT: br i1 [[T0]], // CHECK: [[T0:%.*]] = ptrtoint ptr [[LOAD]] to i64 -// CHECK-NEXT: [[T1:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[T0]], i32 1, i64 50) +// CHECK-NEXT: [[T1:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[T0]]) [ "ptrauth"(i64 1, i64 50) ] // CHECK-NEXT: [[AUTHED:%.*]] = inttoptr i64 [[T1]] to ptr // CHECK-NEXT: br label // CHECK: [[T0:%.*]] = phi ptr [ null, {{.*}} ], [ [[AUTHED]], {{.*}} ] @@ -196,7 +196,7 @@ void test_load_data_i() { // CHECK-NEXT: [[T0:%.*]] = icmp ne ptr [[LOAD]], null // CHECK-NEXT: br i1 [[T0]], // CHECK: [[T0:%.*]] = ptrtoint ptr [[LOAD]] to i64 -// CHECK-NEXT: [[T1:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[T0]], i32 1, i64 50) +// CHECK-NEXT: [[T1:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[T0]]) [ "ptrauth"(i64 1, i64 50) ] // CHECK-NEXT: [[AUTHED:%.*]] = inttoptr i64 [[T1]] to ptr // CHECK-NEXT: br label // CHECK: [[T0:%.*]] = phi ptr [ null, {{.*}} ], [ [[AUTHED]], {{.*}} ] @@ -211,13 +211,13 @@ void test_store_data_a_constant() { // CHECK: [[V:%.*]] = alloca ptr, // CHECK-NEXT: [[T0:%.*]] = ptrtoint ptr [[V]] to i64 // CHECK-NEXT: [[NEWDISC:%.*]] = call i64 @llvm.ptrauth.blend(i64 [[T0]], i64 50) -// CHECK-NEXT: [[SIGN:%.*]] = call i64 @llvm.ptrauth.sign(i64 ptrtoint (ptr @external_int to i64), i32 1, i64 [[NEWDISC]]) +// CHECK-NEXT: [[SIGN:%.*]] = call i64 @llvm.ptrauth.sign(i64 ptrtoint (ptr @external_int to i64)) [ "ptrauth"(i64 1, i64 [[NEWDISC]]) ] // CHECK-NEXT: [[T0:%.*]] = inttoptr i64 [[SIGN]] to ptr // CHECK-NEXT: store ptr [[T0]], ptr [[V]], int * AQ aqpi = &external_int; // CHECK-NEXT: [[T0:%.*]] = ptrtoint ptr [[V]] to i64 // CHECK-NEXT: [[NEWDISC:%.*]] = call i64 @llvm.ptrauth.blend(i64 [[T0]], i64 50) -// CHECK-NEXT: [[SIGN:%.*]] = call i64 @llvm.ptrauth.sign(i64 ptrtoint (ptr @external_int to i64), i32 1, i64 [[NEWDISC]]) +// CHECK-NEXT: [[SIGN:%.*]] = call i64 @llvm.ptrauth.sign(i64 ptrtoint (ptr @external_int to i64)) [ "ptrauth"(i64 1, i64 [[NEWDISC]]) ] // CHECK-NEXT: [[T0:%.*]] = inttoptr i64 [[SIGN]] to ptr // CHECK-NEXT: store ptr [[T0]], ptr [[V]], aqpi = &external_int; @@ -232,7 +232,7 @@ void test_store_data_au() { // CHECK-NEXT: [[T0:%.*]] = icmp ne ptr [[LOAD]], null // CHECK-NEXT: br i1 [[T0]], // CHECK: [[T0:%.*]] = ptrtoint ptr [[LOAD]] to i64 -// CHECK-NEXT: [[T1:%.*]] = call i64 @llvm.ptrauth.sign(i64 [[T0]], i32 1, i64 [[NEWDISC]]) +// CHECK-NEXT: [[T1:%.*]] = call i64 @llvm.ptrauth.sign(i64 [[T0]]) [ "ptrauth"(i64 1, i64 [[NEWDISC]]) ] // CHECK-NEXT: [[SIGNED:%.*]] = inttoptr i64 [[T1]] to ptr // CHECK-NEXT: br label // CHECK: [[T0:%.*]] = phi ptr [ null, {{.*}} ], [ [[SIGNED]], {{.*}} ] @@ -244,7 +244,7 @@ void test_store_data_au() { // CHECK-NEXT: [[T0:%.*]] = icmp ne ptr [[LOAD]], null // CHECK-NEXT: br i1 [[T0]], // CHECK: [[T0:%.*]] = ptrtoint ptr [[LOAD]] to i64 -// CHECK-NEXT: [[T1:%.*]] = call i64 @llvm.ptrauth.sign(i64 [[T0]], i32 1, i64 [[NEWDISC]]) +// CHECK-NEXT: [[T1:%.*]] = call i64 @llvm.ptrauth.sign(i64 [[T0]]) [ "ptrauth"(i64 1, i64 [[NEWDISC]]) ] // CHECK-NEXT: [[SIGNED:%.*]] = inttoptr i64 [[T1]] to ptr // CHECK-NEXT: br label // CHECK: [[T0:%.*]] = phi ptr [ null, {{.*}} ], [ [[SIGNED]], {{.*}} ] @@ -261,7 +261,7 @@ void test_store_data_ai() { // CHECK-NEXT: [[T0:%.*]] = icmp ne ptr [[LOAD]], null // CHECK-NEXT: br i1 [[T0]], // CHECK: [[T0:%.*]] = ptrtoint ptr [[LOAD]] to i64 -// CHECK-NEXT: [[T1:%.*]] = call i64 @llvm.ptrauth.resign(i64 [[T0]], i32 1, i64 50, i32 1, i64 [[NEWDISC]]) +// CHECK-NEXT: [[T1:%.*]] = call i64 @llvm.ptrauth.resign(i64 [[T0]]) [ "ptrauth"(i64 1, i64 50), "ptrauth"(i64 1, i64 [[NEWDISC]]) ] // CHECK-NEXT: [[SIGNED:%.*]] = inttoptr i64 [[T1]] to ptr // CHECK-NEXT: br label // CHECK: [[T0:%.*]] = phi ptr [ null, {{.*}} ], [ [[SIGNED]], {{.*}} ] @@ -273,7 +273,7 @@ void test_store_data_ai() { // CHECK-NEXT: [[T0:%.*]] = icmp ne ptr [[LOAD]], null // CHECK-NEXT: br i1 [[T0]], // CHECK: [[T0:%.*]] = ptrtoint ptr [[LOAD]] to i64 -// CHECK-NEXT: [[T1:%.*]] = call i64 @llvm.ptrauth.resign(i64 [[T0]], i32 1, i64 50, i32 1, i64 [[NEWDISC]]) +// CHECK-NEXT: [[T1:%.*]] = call i64 @llvm.ptrauth.resign(i64 [[T0]]) [ "ptrauth"(i64 1, i64 50), "ptrauth"(i64 1, i64 [[NEWDISC]]) ] // CHECK-NEXT: [[SIGNED:%.*]] = inttoptr i64 [[T1]] to ptr // CHECK-NEXT: br label // CHECK: [[T0:%.*]] = phi ptr [ null, {{.*}} ], [ [[SIGNED]], {{.*}} ] @@ -291,7 +291,7 @@ void test_store_data_aa_same() { // CHECK-NEXT: [[T0:%.*]] = icmp ne ptr [[LOAD]], null // CHECK-NEXT: br i1 [[T0]], // CHECK: [[T0:%.*]] = ptrtoint ptr [[LOAD]] to i64 -// CHECK-NEXT: [[T1:%.*]] = call i64 @llvm.ptrauth.resign(i64 [[T0]], i32 1, i64 [[OLDDISC]], i32 1, i64 [[NEWDISC]]) +// CHECK-NEXT: [[T1:%.*]] = call i64 @llvm.ptrauth.resign(i64 [[T0]]) [ "ptrauth"(i64 1, i64 [[OLDDISC]]), "ptrauth"(i64 1, i64 [[NEWDISC]]) ] // CHECK-NEXT: [[SIGNED:%.*]] = inttoptr i64 [[T1]] to ptr // CHECK-NEXT: br label // CHECK: [[T0:%.*]] = phi ptr [ null, {{.*}} ], [ [[SIGNED]], {{.*}} ] @@ -304,7 +304,7 @@ void test_store_data_aa_same() { // CHECK-NEXT: [[T0:%.*]] = icmp ne ptr [[LOAD]], null // CHECK-NEXT: br i1 [[T0]], // CHECK: [[T0:%.*]] = ptrtoint ptr [[LOAD]] to i64 -// CHECK-NEXT: [[T1:%.*]] = call i64 @llvm.ptrauth.resign(i64 [[T0]], i32 1, i64 [[OLDDISC]], i32 1, i64 [[NEWDISC]]) +// CHECK-NEXT: [[T1:%.*]] = call i64 @llvm.ptrauth.resign(i64 [[T0]]) [ "ptrauth"(i64 1, i64 [[OLDDISC]]), "ptrauth"(i64 1, i64 [[NEWDISC]]) ] // CHECK-NEXT: [[SIGNED:%.*]] = inttoptr i64 [[T1]] to ptr // CHECK-NEXT: br label // CHECK: [[T0:%.*]] = phi ptr [ null, {{.*}} ], [ [[SIGNED]], {{.*}} ] @@ -322,7 +322,7 @@ void test_store_data_aa_different() { // CHECK-NEXT: [[T0:%.*]] = icmp ne ptr [[LOAD]], null // CHECK-NEXT: br i1 [[T0]], // CHECK: [[T0:%.*]] = ptrtoint ptr [[LOAD]] to i64 -// CHECK-NEXT: [[T1:%.*]] = call i64 @llvm.ptrauth.resign(i64 [[T0]], i32 1, i64 [[OLDDISC]], i32 1, i64 [[NEWDISC]]) +// CHECK-NEXT: [[T1:%.*]] = call i64 @llvm.ptrauth.resign(i64 [[T0]]) [ "ptrauth"(i64 1, i64 [[OLDDISC]]), "ptrauth"(i64 1, i64 [[NEWDISC]]) ] // CHECK-NEXT: [[SIGNED:%.*]] = inttoptr i64 [[T1]] to ptr // CHECK-NEXT: br label // CHECK: [[T0:%.*]] = phi ptr [ null, {{.*}} ], [ [[SIGNED]], {{.*}} ] @@ -335,7 +335,7 @@ void test_store_data_aa_different() { // CHECK-NEXT: [[T0:%.*]] = icmp ne ptr [[LOAD]], null // CHECK-NEXT: br i1 [[T0]], // CHECK: [[T0:%.*]] = ptrtoint ptr [[LOAD]] to i64 -// CHECK-NEXT: [[T1:%.*]] = call i64 @llvm.ptrauth.resign(i64 [[T0]], i32 1, i64 [[OLDDISC]], i32 1, i64 [[NEWDISC]]) +// CHECK-NEXT: [[T1:%.*]] = call i64 @llvm.ptrauth.resign(i64 [[T0]]) [ "ptrauth"(i64 1, i64 [[OLDDISC]]), "ptrauth"(i64 1, i64 [[NEWDISC]]) ] // CHECK-NEXT: [[SIGNED:%.*]] = inttoptr i64 [[T1]] to ptr // CHECK-NEXT: br label // CHECK: [[T0:%.*]] = phi ptr [ null, {{.*}} ], [ [[SIGNED]], {{.*}} ] @@ -352,7 +352,7 @@ void test_store_data_aa_zero() { // CHECK-NEXT: [[T0:%.*]] = icmp ne ptr [[LOAD]], null // CHECK-NEXT: br i1 [[T0]], // CHECK: [[T0:%.*]] = ptrtoint ptr [[LOAD]] to i64 -// CHECK-NEXT: [[T1:%.*]] = call i64 @llvm.ptrauth.resign(i64 [[T0]], i32 1, i64 [[OLDDISC]], i32 1, i64 [[NEWDISC]]) +// CHECK-NEXT: [[T1:%.*]] = call i64 @llvm.ptrauth.resign(i64 [[T0]]) [ "ptrauth"(i64 1, i64 [[OLDDISC]]), "ptrauth"(i64 1, i64 [[NEWDISC]]) ] // CHECK-NEXT: [[SIGNED:%.*]] = inttoptr i64 [[T1]] to ptr // CHECK-NEXT: br label // CHECK: [[T0:%.*]] = phi ptr [ null, {{.*}} ], [ [[SIGNED]], {{.*}} ] @@ -364,7 +364,7 @@ void test_store_data_aa_zero() { // CHECK-NEXT: [[T0:%.*]] = icmp ne ptr [[LOAD]], null // CHECK-NEXT: br i1 [[T0]], // CHECK: [[T0:%.*]] = ptrtoint ptr [[LOAD]] to i64 -// CHECK-NEXT: [[T1:%.*]] = call i64 @llvm.ptrauth.resign(i64 [[T0]], i32 1, i64 [[OLDDISC]], i32 1, i64 [[NEWDISC]]) +// CHECK-NEXT: [[T1:%.*]] = call i64 @llvm.ptrauth.resign(i64 [[T0]]) [ "ptrauth"(i64 1, i64 [[OLDDISC]]), "ptrauth"(i64 1, i64 [[NEWDISC]]) ] // CHECK-NEXT: [[SIGNED:%.*]] = inttoptr i64 [[T1]] to ptr // CHECK-NEXT: br label // CHECK: [[T0:%.*]] = phi ptr [ null, {{.*}} ], [ [[SIGNED]], {{.*}} ] @@ -380,7 +380,7 @@ void test_load_data_a() { // CHECK-NEXT: [[T0:%.*]] = icmp ne ptr [[LOAD]], null // CHECK-NEXT: br i1 [[T0]], // CHECK: [[T0:%.*]] = ptrtoint ptr [[LOAD]] to i64 -// CHECK-NEXT: [[T1:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[T0]], i32 1, i64 [[OLDDISC]]) +// CHECK-NEXT: [[T1:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[T0]]) [ "ptrauth"(i64 1, i64 [[OLDDISC]]) ] // CHECK-NEXT: [[AUTHED:%.*]] = inttoptr i64 [[T1]] to ptr // CHECK-NEXT: br label // CHECK: [[T0:%.*]] = phi ptr [ null, {{.*}} ], [ [[AUTHED]], {{.*}} ] @@ -391,7 +391,7 @@ void test_load_data_a() { // CHECK-NEXT: [[T0:%.*]] = icmp ne ptr [[LOAD]], null // CHECK-NEXT: br i1 [[T0]], // CHECK: [[T0:%.*]] = ptrtoint ptr [[LOAD]] to i64 -// CHECK-NEXT: [[T1:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[T0]], i32 1, i64 [[OLDDISC]]) +// CHECK-NEXT: [[T1:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[T0]]) [ "ptrauth"(i64 1, i64 [[OLDDISC]]) ] // CHECK-NEXT: [[AUTHED:%.*]] = inttoptr i64 [[T1]] to ptr // CHECK-NEXT: br label // CHECK: [[T0:%.*]] = phi ptr [ null, {{.*}} ], [ [[AUTHED]], {{.*}} ] @@ -402,7 +402,7 @@ void test_load_data_a() { // CHECK-NEXT: [[T0:%.*]] = icmp ne ptr [[LOAD]], null // CHECK-NEXT: br i1 [[T0]], // CHECK: [[T0:%.*]] = ptrtoint ptr [[LOAD]] to i64 -// CHECK-NEXT: [[T1:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[T0]], i32 1, i64 [[OLDDISC]]) +// CHECK-NEXT: [[T1:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[T0]]) [ "ptrauth"(i64 1, i64 [[OLDDISC]]) ] // CHECK-NEXT: [[AUTHED:%.*]] = inttoptr i64 [[T1]] to ptr // CHECK-NEXT: br label // CHECK: [[T0:%.*]] = phi ptr [ null, {{.*}} ], [ [[AUTHED]], {{.*}} ] @@ -415,11 +415,11 @@ void test_load_data_a() { // CHECK-LABEL: define {{.*}}void @test_store_function_i_constant() void test_store_function_i_constant() { // CHECK: [[V:%.*]] = alloca ptr, -// CHECK-NEXT: [[SIGN:%.*]] = call i64 @llvm.ptrauth.resign(i64 ptrtoint (ptr ptrauth (ptr @external_func, i32 0, i64 18983) to i64), i32 0, i64 18983, i32 1, i64 50) +// CHECK-NEXT: [[SIGN:%.*]] = call i64 @llvm.ptrauth.resign(i64 ptrtoint (ptr ptrauth (ptr @external_func, i32 0, i64 18983) to i64)) [ "ptrauth"(i64 0, i64 18983), "ptrauth"(i64 1, i64 50) ] // CHECK-NEXT: [[T0:%.*]] = inttoptr i64 [[SIGN]] to ptr // CHECK-NEXT: store ptr [[T0]], ptr [[V]], func_t * IQ iqpf = &external_func; -// CHECK-NEXT: [[SIGN:%.*]] = call i64 @llvm.ptrauth.resign(i64 ptrtoint (ptr ptrauth (ptr @external_func, i32 0, i64 18983) to i64), i32 0, i64 18983, i32 1, i64 50) +// CHECK-NEXT: [[SIGN:%.*]] = call i64 @llvm.ptrauth.resign(i64 ptrtoint (ptr ptrauth (ptr @external_func, i32 0, i64 18983) to i64)) [ "ptrauth"(i64 0, i64 18983), "ptrauth"(i64 1, i64 50) ] // CHECK-NEXT: [[T0:%.*]] = inttoptr i64 [[SIGN]] to ptr // CHECK-NEXT: store ptr [[T0]], ptr [[V]], iqpf = &external_func; @@ -432,7 +432,7 @@ void test_store_function_iu() { // CHECK-NEXT: [[T0:%.*]] = icmp ne ptr [[LOAD]], null // CHECK-NEXT: br i1 [[T0]], // CHECK: [[T0:%.*]] = ptrtoint ptr [[LOAD]] to i64 -// CHECK-NEXT: [[T1:%.*]] = call i64 @llvm.ptrauth.resign(i64 [[T0]], i32 0, i64 18983, i32 1, i64 50) +// CHECK-NEXT: [[T1:%.*]] = call i64 @llvm.ptrauth.resign(i64 [[T0]]) [ "ptrauth"(i64 0, i64 18983), "ptrauth"(i64 1, i64 50) ] // CHECK-NEXT: [[SIGNED:%.*]] = inttoptr i64 [[T1]] to ptr // CHECK-NEXT: br label // CHECK: [[T0:%.*]] = phi ptr [ null, {{.*}} ], [ [[SIGNED]], {{.*}} ] @@ -442,7 +442,7 @@ void test_store_function_iu() { // CHECK-NEXT: [[T0:%.*]] = icmp ne ptr [[LOAD]], null // CHECK-NEXT: br i1 [[T0]], // CHECK: [[T0:%.*]] = ptrtoint ptr [[LOAD]] to i64 -// CHECK-NEXT: [[T1:%.*]] = call i64 @llvm.ptrauth.resign(i64 [[T0]], i32 0, i64 18983, i32 1, i64 50) +// CHECK-NEXT: [[T1:%.*]] = call i64 @llvm.ptrauth.resign(i64 [[T0]]) [ "ptrauth"(i64 0, i64 18983), "ptrauth"(i64 1, i64 50) ] // CHECK-NEXT: [[SIGNED:%.*]] = inttoptr i64 [[T1]] to ptr // CHECK-NEXT: br label // CHECK: [[T0:%.*]] = phi ptr [ null, {{.*}} ], [ [[SIGNED]], {{.*}} ] @@ -458,7 +458,7 @@ void test_store_function_ia() { // CHECK-NEXT: [[T0:%.*]] = icmp ne ptr [[LOAD]], null // CHECK-NEXT: br i1 [[T0]], // CHECK: [[T0:%.*]] = ptrtoint ptr [[LOAD]] to i64 -// CHECK-NEXT: [[T1:%.*]] = call i64 @llvm.ptrauth.resign(i64 [[T0]], i32 1, i64 [[OLDDISC]], i32 1, i64 50) +// CHECK-NEXT: [[T1:%.*]] = call i64 @llvm.ptrauth.resign(i64 [[T0]]) [ "ptrauth"(i64 1, i64 [[OLDDISC]]), "ptrauth"(i64 1, i64 50) ] // CHECK-NEXT: [[SIGNED:%.*]] = inttoptr i64 [[T1]] to ptr // CHECK-NEXT: br label // CHECK: [[T0:%.*]] = phi ptr [ null, {{.*}} ], [ [[SIGNED]], {{.*}} ] @@ -469,7 +469,7 @@ void test_store_function_ia() { // CHECK-NEXT: [[T0:%.*]] = icmp ne ptr [[LOAD]], null // CHECK-NEXT: br i1 [[T0]], // CHECK: [[T0:%.*]] = ptrtoint ptr [[LOAD]] to i64 -// CHECK-NEXT: [[T1:%.*]] = call i64 @llvm.ptrauth.resign(i64 [[T0]], i32 1, i64 [[OLDDISC]], i32 1, i64 50) +// CHECK-NEXT: [[T1:%.*]] = call i64 @llvm.ptrauth.resign(i64 [[T0]]) [ "ptrauth"(i64 1, i64 [[OLDDISC]]), "ptrauth"(i64 1, i64 50) ] // CHECK-NEXT: [[SIGNED:%.*]] = inttoptr i64 [[T1]] to ptr // CHECK-NEXT: br label // CHECK: [[T0:%.*]] = phi ptr [ null, {{.*}} ], [ [[SIGNED]], {{.*}} ] @@ -480,7 +480,7 @@ void test_store_function_ia() { // CHECK-NEXT: [[T0:%.*]] = icmp ne ptr [[LOAD]], null // CHECK-NEXT: br i1 [[T0]], // CHECK: [[T0:%.*]] = ptrtoint ptr [[LOAD]] to i64 -// CHECK-NEXT: [[T1:%.*]] = call i64 @llvm.ptrauth.resign(i64 [[T0]], i32 1, i64 [[OLDDISC]], i32 1, i64 50) +// CHECK-NEXT: [[T1:%.*]] = call i64 @llvm.ptrauth.resign(i64 [[T0]]) [ "ptrauth"(i64 1, i64 [[OLDDISC]]), "ptrauth"(i64 1, i64 50) ] // CHECK-NEXT: [[SIGNED:%.*]] = inttoptr i64 [[T1]] to ptr // CHECK-NEXT: br label // CHECK: [[RESULT:%.*]] = phi ptr [ null, {{.*}} ], [ [[SIGNED]], {{.*}} ] @@ -488,7 +488,7 @@ void test_store_function_ia() { // CHECK-NEXT: [[T0:%.*]] = icmp ne ptr [[RESULT]], null // CHECK-NEXT: br i1 [[T0]], // CHECK: [[T0:%.*]] = ptrtoint ptr [[RESULT]] to i64 -// CHECK-NEXT: [[T1:%.*]] = call i64 @llvm.ptrauth.resign(i64 [[T0]], i32 1, i64 50, i32 0, i64 18983) +// CHECK-NEXT: [[T1:%.*]] = call i64 @llvm.ptrauth.resign(i64 [[T0]]) [ "ptrauth"(i64 1, i64 50), "ptrauth"(i64 0, i64 18983) ] // CHECK-NEXT: [[SIGNED:%.*]] = inttoptr i64 [[T1]] to ptr // CHECK-NEXT: br label // CHECK: [[T0:%.*]] = phi ptr [ null, {{.*}} ], [ [[SIGNED]], {{.*}} ] @@ -514,7 +514,7 @@ void test_store_function_ii_different() { // CHECK-NEXT: [[T0:%.*]] = icmp ne ptr [[LOAD]], null // CHECK-NEXT: br i1 [[T0]], // CHECK: [[T0:%.*]] = ptrtoint ptr [[LOAD]] to i64 -// CHECK-NEXT: [[T1:%.*]] = call i64 @llvm.ptrauth.resign(i64 [[T0]], i32 1, i64 50, i32 1, i64 100) +// CHECK-NEXT: [[T1:%.*]] = call i64 @llvm.ptrauth.resign(i64 [[T0]]) [ "ptrauth"(i64 1, i64 50), "ptrauth"(i64 1, i64 100) ] // CHECK-NEXT: [[SIGNED:%.*]] = inttoptr i64 [[T1]] to ptr // CHECK-NEXT: br label // CHECK: [[T0:%.*]] = phi ptr [ null, {{.*}} ], [ [[SIGNED]], {{.*}} ] @@ -524,7 +524,7 @@ void test_store_function_ii_different() { // CHECK-NEXT: [[T0:%.*]] = icmp ne ptr [[LOAD]], null // CHECK-NEXT: br i1 [[T0]], // CHECK: [[T0:%.*]] = ptrtoint ptr [[LOAD]] to i64 -// CHECK-NEXT: [[T1:%.*]] = call i64 @llvm.ptrauth.resign(i64 [[T0]], i32 1, i64 50, i32 1, i64 100) +// CHECK-NEXT: [[T1:%.*]] = call i64 @llvm.ptrauth.resign(i64 [[T0]]) [ "ptrauth"(i64 1, i64 50), "ptrauth"(i64 1, i64 100) ] // CHECK-NEXT: [[SIGNED:%.*]] = inttoptr i64 [[T1]] to ptr // CHECK-NEXT: br label // CHECK: [[T0:%.*]] = phi ptr [ null, {{.*}} ], [ [[SIGNED]], {{.*}} ] @@ -539,7 +539,7 @@ void test_load_function_i() { // CHECK-NEXT: [[T0:%.*]] = icmp ne ptr [[LOAD]], null // CHECK-NEXT: br i1 [[T0]], // CHECK: [[T0:%.*]] = ptrtoint ptr [[LOAD]] to i64 -// CHECK-NEXT: [[T1:%.*]] = call i64 @llvm.ptrauth.resign(i64 [[T0]], i32 1, i64 50, i32 0, i64 18983) +// CHECK-NEXT: [[T1:%.*]] = call i64 @llvm.ptrauth.resign(i64 [[T0]]) [ "ptrauth"(i64 1, i64 50), "ptrauth"(i64 0, i64 18983) ] // CHECK-NEXT: [[SIGNED:%.*]] = inttoptr i64 [[T1]] to ptr // CHECK-NEXT: br label // CHECK: [[T0:%.*]] = phi ptr [ null, {{.*}} ], [ [[SIGNED]], {{.*}} ] @@ -549,7 +549,7 @@ void test_load_function_i() { // CHECK-NEXT: [[T0:%.*]] = icmp ne ptr [[LOAD]], null // CHECK-NEXT: br i1 [[T0]], // CHECK: [[T0:%.*]] = ptrtoint ptr [[LOAD]] to i64 -// CHECK-NEXT: [[T1:%.*]] = call i64 @llvm.ptrauth.resign(i64 [[T0]], i32 1, i64 50, i32 0, i64 18983) +// CHECK-NEXT: [[T1:%.*]] = call i64 @llvm.ptrauth.resign(i64 [[T0]]) [ "ptrauth"(i64 1, i64 50), "ptrauth"(i64 0, i64 18983) ] // CHECK-NEXT: [[SIGNED:%.*]] = inttoptr i64 [[T1]] to ptr // CHECK-NEXT: br label // CHECK: [[T0:%.*]] = phi ptr [ null, {{.*}} ], [ [[SIGNED]], {{.*}} ] @@ -559,7 +559,7 @@ void test_load_function_i() { // CHECK-NEXT: [[T0:%.*]] = icmp ne ptr [[LOAD]], null // CHECK-NEXT: br i1 [[T0]], // CHECK: [[T0:%.*]] = ptrtoint ptr [[LOAD]] to i64 -// CHECK-NEXT: [[T1:%.*]] = call i64 @llvm.ptrauth.resign(i64 [[T0]], i32 1, i64 50, i32 0, i64 18983) +// CHECK-NEXT: [[T1:%.*]] = call i64 @llvm.ptrauth.resign(i64 [[T0]]) [ "ptrauth"(i64 1, i64 50), "ptrauth"(i64 0, i64 18983) ] // CHECK-NEXT: [[SIGNED:%.*]] = inttoptr i64 [[T1]] to ptr // CHECK-NEXT: br label // CHECK: [[T0:%.*]] = phi ptr [ null, {{.*}} ], [ [[SIGNED]], {{.*}} ] @@ -574,13 +574,13 @@ void test_store_function_a_constant() { // CHECK: [[V:%.*]] = alloca ptr, // CHECK-NEXT: [[T0:%.*]] = ptrtoint ptr [[V]] to i64 // CHECK-NEXT: [[NEWDISC:%.*]] = call i64 @llvm.ptrauth.blend(i64 [[T0]], i64 50) -// CHECK-NEXT: [[SIGN:%.*]] = call i64 @llvm.ptrauth.resign(i64 ptrtoint (ptr ptrauth (ptr @external_func, i32 0, i64 18983) to i64), i32 0, i64 18983, i32 1, i64 [[NEWDISC]]) +// CHECK-NEXT: [[SIGN:%.*]] = call i64 @llvm.ptrauth.resign(i64 ptrtoint (ptr ptrauth (ptr @external_func, i32 0, i64 18983) to i64)) [ "ptrauth"(i64 0, i64 18983), "ptrauth"(i64 1, i64 [[NEWDISC]]) ] // CHECK-NEXT: [[T0:%.*]] = inttoptr i64 [[SIGN]] to ptr // CHECK-NEXT: store ptr [[T0]], ptr [[V]], func_t * AQ aqpf = &external_func; // CHECK-NEXT: [[T0:%.*]] = ptrtoint ptr [[V]] to i64 // CHECK-NEXT: [[NEWDISC:%.*]] = call i64 @llvm.ptrauth.blend(i64 [[T0]], i64 50) -// CHECK-NEXT: [[SIGN:%.*]] = call i64 @llvm.ptrauth.resign(i64 ptrtoint (ptr ptrauth (ptr @external_func, i32 0, i64 18983) to i64), i32 0, i64 18983, i32 1, i64 [[NEWDISC]]) +// CHECK-NEXT: [[SIGN:%.*]] = call i64 @llvm.ptrauth.resign(i64 ptrtoint (ptr ptrauth (ptr @external_func, i32 0, i64 18983) to i64)) [ "ptrauth"(i64 0, i64 18983), "ptrauth"(i64 1, i64 [[NEWDISC]]) ] // CHECK-NEXT: [[T0:%.*]] = inttoptr i64 [[SIGN]] to ptr // CHECK-NEXT: store ptr [[T0]], ptr [[V]], aqpf = &external_func; @@ -595,7 +595,7 @@ void test_store_function_au() { // CHECK-NEXT: [[T0:%.*]] = icmp ne ptr [[LOAD]], null // CHECK-NEXT: br i1 [[T0]], // CHECK: [[T0:%.*]] = ptrtoint ptr [[LOAD]] to i64 -// CHECK-NEXT: [[T1:%.*]] = call i64 @llvm.ptrauth.resign(i64 [[T0]], i32 0, i64 18983, i32 1, i64 [[NEWDISC]]) +// CHECK-NEXT: [[T1:%.*]] = call i64 @llvm.ptrauth.resign(i64 [[T0]]) [ "ptrauth"(i64 0, i64 18983), "ptrauth"(i64 1, i64 [[NEWDISC]]) ] // CHECK-NEXT: [[SIGNED:%.*]] = inttoptr i64 [[T1]] to ptr // CHECK-NEXT: br label // CHECK: [[T0:%.*]] = phi ptr [ null, {{.*}} ], [ [[SIGNED]], {{.*}} ] @@ -607,7 +607,7 @@ void test_store_function_au() { // CHECK-NEXT: [[T0:%.*]] = icmp ne ptr [[LOAD]], null // CHECK-NEXT: br i1 [[T0]], // CHECK: [[T0:%.*]] = ptrtoint ptr [[LOAD]] to i64 -// CHECK-NEXT: [[T1:%.*]] = call i64 @llvm.ptrauth.resign(i64 [[T0]], i32 0, i64 18983, i32 1, i64 [[NEWDISC]]) +// CHECK-NEXT: [[T1:%.*]] = call i64 @llvm.ptrauth.resign(i64 [[T0]]) [ "ptrauth"(i64 0, i64 18983), "ptrauth"(i64 1, i64 [[NEWDISC]]) ] // CHECK-NEXT: [[SIGNED:%.*]] = inttoptr i64 [[T1]] to ptr // CHECK-NEXT: br label // CHECK: [[T0:%.*]] = phi ptr [ null, {{.*}} ], [ [[SIGNED]], {{.*}} ] @@ -624,7 +624,7 @@ void test_store_function_ai() { // CHECK-NEXT: [[T0:%.*]] = icmp ne ptr [[LOAD]], null // CHECK-NEXT: br i1 [[T0]], // CHECK: [[T0:%.*]] = ptrtoint ptr [[LOAD]] to i64 -// CHECK-NEXT: [[T1:%.*]] = call i64 @llvm.ptrauth.resign(i64 [[T0]], i32 1, i64 50, i32 1, i64 [[NEWDISC]]) +// CHECK-NEXT: [[T1:%.*]] = call i64 @llvm.ptrauth.resign(i64 [[T0]]) [ "ptrauth"(i64 1, i64 50), "ptrauth"(i64 1, i64 [[NEWDISC]]) ] // CHECK-NEXT: [[SIGNED:%.*]] = inttoptr i64 [[T1]] to ptr // CHECK-NEXT: br label // CHECK: [[T0:%.*]] = phi ptr [ null, {{.*}} ], [ [[SIGNED]], {{.*}} ] @@ -636,7 +636,7 @@ void test_store_function_ai() { // CHECK-NEXT: [[T0:%.*]] = icmp ne ptr [[LOAD]], null // CHECK-NEXT: br i1 [[T0]], // CHECK: [[T0:%.*]] = ptrtoint ptr [[LOAD]] to i64 -// CHECK-NEXT: [[T1:%.*]] = call i64 @llvm.ptrauth.resign(i64 [[T0]], i32 1, i64 50, i32 1, i64 [[NEWDISC]]) +// CHECK-NEXT: [[T1:%.*]] = call i64 @llvm.ptrauth.resign(i64 [[T0]]) [ "ptrauth"(i64 1, i64 50), "ptrauth"(i64 1, i64 [[NEWDISC]]) ] // CHECK-NEXT: [[SIGNED:%.*]] = inttoptr i64 [[T1]] to ptr // CHECK-NEXT: br label // CHECK: [[T0:%.*]] = phi ptr [ null, {{.*}} ], [ [[SIGNED]], {{.*}} ] @@ -654,7 +654,7 @@ void test_store_function_aa_same() { // CHECK-NEXT: [[T0:%.*]] = icmp ne ptr [[LOAD]], null // CHECK-NEXT: br i1 [[T0]], // CHECK: [[T0:%.*]] = ptrtoint ptr [[LOAD]] to i64 -// CHECK-NEXT: [[T1:%.*]] = call i64 @llvm.ptrauth.resign(i64 [[T0]], i32 1, i64 [[OLDDISC]], i32 1, i64 [[NEWDISC]]) +// CHECK-NEXT: [[T1:%.*]] = call i64 @llvm.ptrauth.resign(i64 [[T0]]) [ "ptrauth"(i64 1, i64 [[OLDDISC]]), "ptrauth"(i64 1, i64 [[NEWDISC]]) ] // CHECK-NEXT: [[SIGNED:%.*]] = inttoptr i64 [[T1]] to ptr // CHECK-NEXT: br label // CHECK: [[T0:%.*]] = phi ptr [ null, {{.*}} ], [ [[SIGNED]], {{.*}} ] @@ -667,7 +667,7 @@ void test_store_function_aa_same() { // CHECK-NEXT: [[T0:%.*]] = icmp ne ptr [[LOAD]], null // CHECK-NEXT: br i1 [[T0]], // CHECK: [[T0:%.*]] = ptrtoint ptr [[LOAD]] to i64 -// CHECK-NEXT: [[T1:%.*]] = call i64 @llvm.ptrauth.resign(i64 [[T0]], i32 1, i64 [[OLDDISC]], i32 1, i64 [[NEWDISC]]) +// CHECK-NEXT: [[T1:%.*]] = call i64 @llvm.ptrauth.resign(i64 [[T0]]) [ "ptrauth"(i64 1, i64 [[OLDDISC]]), "ptrauth"(i64 1, i64 [[NEWDISC]]) ] // CHECK-NEXT: [[SIGNED:%.*]] = inttoptr i64 [[T1]] to ptr // CHECK-NEXT: br label // CHECK: [[T0:%.*]] = phi ptr [ null, {{.*}} ], [ [[SIGNED]], {{.*}} ] @@ -685,7 +685,7 @@ void test_store_function_aa_different() { // CHECK-NEXT: [[T0:%.*]] = icmp ne ptr [[LOAD]], null // CHECK-NEXT: br i1 [[T0]], // CHECK: [[T0:%.*]] = ptrtoint ptr [[LOAD]] to i64 -// CHECK-NEXT: [[T1:%.*]] = call i64 @llvm.ptrauth.resign(i64 [[T0]], i32 1, i64 [[OLDDISC]], i32 1, i64 [[NEWDISC]]) +// CHECK-NEXT: [[T1:%.*]] = call i64 @llvm.ptrauth.resign(i64 [[T0]]) [ "ptrauth"(i64 1, i64 [[OLDDISC]]), "ptrauth"(i64 1, i64 [[NEWDISC]]) ] // CHECK-NEXT: [[SIGNED:%.*]] = inttoptr i64 [[T1]] to ptr // CHECK-NEXT: br label // CHECK: [[T0:%.*]] = phi ptr [ null, {{.*}} ], [ [[SIGNED]], {{.*}} ] @@ -698,7 +698,7 @@ void test_store_function_aa_different() { // CHECK-NEXT: [[T0:%.*]] = icmp ne ptr [[LOAD]], null // CHECK-NEXT: br i1 [[T0]], // CHECK: [[T0:%.*]] = ptrtoint ptr [[LOAD]] to i64 -// CHECK-NEXT: [[T1:%.*]] = call i64 @llvm.ptrauth.resign(i64 [[T0]], i32 1, i64 [[OLDDISC]], i32 1, i64 [[NEWDISC]]) +// CHECK-NEXT: [[T1:%.*]] = call i64 @llvm.ptrauth.resign(i64 [[T0]]) [ "ptrauth"(i64 1, i64 [[OLDDISC]]), "ptrauth"(i64 1, i64 [[NEWDISC]]) ] // CHECK-NEXT: [[SIGNED:%.*]] = inttoptr i64 [[T1]] to ptr // CHECK-NEXT: br label // CHECK: [[T0:%.*]] = phi ptr [ null, {{.*}} ], [ [[SIGNED]], {{.*}} ] @@ -714,7 +714,7 @@ void test_load_function_a() { // CHECK-NEXT: [[T0:%.*]] = icmp ne ptr [[LOAD]], null // CHECK-NEXT: br i1 [[T0]], // CHECK: [[T0:%.*]] = ptrtoint ptr [[LOAD]] to i64 -// CHECK-NEXT: [[T1:%.*]] = call i64 @llvm.ptrauth.resign(i64 [[T0]], i32 1, i64 [[OLDDISC]], i32 0, i64 18983) +// CHECK-NEXT: [[T1:%.*]] = call i64 @llvm.ptrauth.resign(i64 [[T0]]) [ "ptrauth"(i64 1, i64 [[OLDDISC]]), "ptrauth"(i64 0, i64 18983) ] // CHECK-NEXT: [[SIGNED:%.*]] = inttoptr i64 [[T1]] to ptr // CHECK-NEXT: br label // CHECK: [[T0:%.*]] = phi ptr [ null, {{.*}} ], [ [[SIGNED]], {{.*}} ] @@ -725,7 +725,7 @@ void test_load_function_a() { // CHECK-NEXT: [[T0:%.*]] = icmp ne ptr [[LOAD]], null // CHECK-NEXT: br i1 [[T0]], // CHECK: [[T0:%.*]] = ptrtoint ptr [[LOAD]] to i64 -// CHECK-NEXT: [[T1:%.*]] = call i64 @llvm.ptrauth.resign(i64 [[T0]], i32 1, i64 [[OLDDISC]], i32 0, i64 18983) +// CHECK-NEXT: [[T1:%.*]] = call i64 @llvm.ptrauth.resign(i64 [[T0]]) [ "ptrauth"(i64 1, i64 [[OLDDISC]]), "ptrauth"(i64 0, i64 18983) ] // CHECK-NEXT: [[SIGNED:%.*]] = inttoptr i64 [[T1]] to ptr // CHECK-NEXT: br label // CHECK: [[T0:%.*]] = phi ptr [ null, {{.*}} ], [ [[SIGNED]], {{.*}} ] @@ -736,7 +736,7 @@ void test_load_function_a() { // CHECK-NEXT: [[T0:%.*]] = icmp ne ptr [[LOAD]], null // CHECK-NEXT: br i1 [[T0]], // CHECK: [[T0:%.*]] = ptrtoint ptr [[LOAD]] to i64 -// CHECK-NEXT: [[T1:%.*]] = call i64 @llvm.ptrauth.resign(i64 [[T0]], i32 1, i64 [[OLDDISC]], i32 0, i64 18983) +// CHECK-NEXT: [[T1:%.*]] = call i64 @llvm.ptrauth.resign(i64 [[T0]]) [ "ptrauth"(i64 1, i64 [[OLDDISC]]), "ptrauth"(i64 0, i64 18983) ] // CHECK-NEXT: [[SIGNED:%.*]] = inttoptr i64 [[T1]] to ptr // CHECK-NEXT: br label // CHECK: [[T0:%.*]] = phi ptr [ null, {{.*}} ], [ [[SIGNED]], {{.*}} ] diff --git a/clang/test/CodeGen/ptrauth-restricted-intptr-qualifier.c b/clang/test/CodeGen/ptrauth-restricted-intptr-qualifier.c index dcce5764e2217..9a5886b6c82be 100644 --- a/clang/test/CodeGen/ptrauth-restricted-intptr-qualifier.c +++ b/clang/test/CodeGen/ptrauth-restricted-intptr-qualifier.c @@ -37,13 +37,13 @@ struct B gs2 = {0, 0, (__UINTPTR_TYPE__)&test_int}; __INTPTR_TYPE__ test_read_globals() { __INTPTR_TYPE__ result = g1 + g2 + g3; // CHECK: [[A:%.*]] = load i64, ptr @g1 - // CHECK: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[A]], i32 1, i64 56) + // CHECK: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[A]]) [ "ptrauth"(i64 1, i64 56) ] // CHECK: [[B:%.*]] = load i64, ptr @g2 // CHECK: [[BLENDED:%.*]] = call i64 @llvm.ptrauth.blend(i64 ptrtoint (ptr @g2 to i64), i64 1272) - // CHECK: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[B]], i32 1, i64 [[BLENDED]]) + // CHECK: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[B]]) [ "ptrauth"(i64 1, i64 [[BLENDED]]) ] // CHECK: [[VALUE:%.*]] = load i64, ptr @g3 // CHECK: [[BLENDED:%.*]] = call i64 @llvm.ptrauth.blend(i64 ptrtoint (ptr @g3 to i64), i64 23) - // CHECK: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VALUE]], i32 3, i64 [[BLENDED]]) + // CHECK: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VALUE]]) [ "ptrauth"(i64 3, i64 [[BLENDED]]) ] for (int i = 0; i < 3; i++) { result += ga[i]; @@ -59,24 +59,24 @@ __INTPTR_TYPE__ test_read_globals() { // CHECK: [[CASTIDX:%.*]] = ptrtoint ptr [[ARRAYIDX]] to i64 // CHECK: [[BLENDED:%.*]] = call i64 @llvm.ptrauth.blend(i64 [[CASTIDX]], i64 712) // CHECK: resign.nonnull6: - // CHECK: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VALUE]], i32 1, i64 [[BLENDED]]) + // CHECK: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VALUE]]) [ "ptrauth"(i64 1, i64 [[BLENDED]]) ] // CHECK: resign.cont7 result += gs1.f0 + gs1.f1 + gs1.f2; // CHECK: resign.cont10: // CHECK: [[ADDR:%.*]] = load i64, ptr getelementptr inbounds nuw (%struct.A, ptr @gs1, i32 0, i32 1 // CHECK: resign.nonnull11: - // CHECK: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[ADDR]], i32 1, i64 9182) + // CHECK: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[ADDR]]) [ "ptrauth"(i64 1, i64 9182) ] // CHECK: resign.cont12: // CHECK: [[ADDR:%.*]] = load i64, ptr getelementptr inbounds nuw (%struct.A, ptr @gs1, i32 0, i32 2) - // CHECK: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[ADDR]], i32 1, i64 783) + // CHECK: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[ADDR]]) [ "ptrauth"(i64 1, i64 783) ] result += gs2.f0 + gs2.f1 + gs2.f2; // CHECK: [[ADDR:%.*]] = load i64, ptr @gs2 // CHECK: [[BLENDED:%.*]] = call i64 @llvm.ptrauth.blend(i64 ptrtoint (ptr @gs2 to i64), i64 1276) - // CHECK: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[ADDR]], i32 1, i64 [[BLENDED]]) + // CHECK: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[ADDR]]) [ "ptrauth"(i64 1, i64 [[BLENDED]]) ] // CHECK: [[ADDR:%.*]] = load i64, ptr getelementptr inbounds nuw (%struct.B, ptr @gs2, i32 0, i32 1) // CHECK: [[BLENDED:%.*]] = call i64 @llvm.ptrauth.blend(i64 ptrtoint (ptr getelementptr inbounds nuw (%struct.B, ptr @gs2, i32 0, i32 1) to i64), i64 23674) - // CHECK: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[ADDR]], i32 1, i64 [[BLENDED]]) + // CHECK: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[ADDR]]) [ "ptrauth"(i64 1, i64 [[BLENDED]]) ] // CHECK: [[ADDR:%.*]] = load i64, ptr getelementptr inbounds nuw (%struct.B, ptr @gs2, i32 0, i32 2) // CHECK: [[BLENDED:%.*]] = call i64 @llvm.ptrauth.blend(i64 ptrtoint (ptr getelementptr inbounds nuw (%struct.B, ptr @gs2, i32 0, i32 2) to i64), i64 163) @@ -103,11 +103,11 @@ void test_write_globals(int i, __INTPTR_TYPE__ j) { void test_set_A(struct A *a, __INTPTR_TYPE__ x, int y) { a->f0 = x; // CHECK: [[XADDR:%.*]] = load i64, ptr %x.addr - // CHECK: [[SIGNED_X:%.*]] = call i64 @llvm.ptrauth.sign(i64 [[XADDR]], i32 1, i64 431) + // CHECK: [[SIGNED_X:%.*]] = call i64 @llvm.ptrauth.sign(i64 [[XADDR]]) [ "ptrauth"(i64 1, i64 431) ] a->f1 = y; // CHECK: [[Y:%.*]] = load i32, ptr %y.addr // CHECK: [[CONV:%.*]] = sext i32 [[Y]] to i64 - // CHECK: [[SIGNED:%.*]] = call i64 @llvm.ptrauth.sign(i64 [[CONV]], i32 1, i64 9182) + // CHECK: [[SIGNED:%.*]] = call i64 @llvm.ptrauth.sign(i64 [[CONV]]) [ "ptrauth"(i64 1, i64 9182) ] a->f2 = 0; // CHECK: [[A:%.*]] = load ptr, ptr %a.addr // CHECK: [[F2:%.*]] = getelementptr inbounds nuw %struct.A, ptr [[A]], i32 0, i32 2 @@ -120,7 +120,7 @@ void test_set_B(struct B *b, __INTPTR_TYPE__ x, int y) { // CHECK: [[X:%.*]] = load i64, ptr %x.addr // CHECK: [[F0_ADDR:%.*]] = ptrtoint ptr %f0 to i64 // CHECK: [[BLENDED:%.*]] = call i64 @llvm.ptrauth.blend(i64 [[F0_ADDR]], i64 1276) - // CHECK: [[SIGNED:%.*]] = call i64 @llvm.ptrauth.sign(i64 [[X]], i32 1, i64 [[BLENDED]]) + // CHECK: [[SIGNED:%.*]] = call i64 @llvm.ptrauth.sign(i64 [[X]]) [ "ptrauth"(i64 1, i64 [[BLENDED]]) ] b->f1 = y; // CHECK: [[B:%.*]] = load ptr, ptr %b.addr // CHECK: [[F1_ADDR:%.*]] = getelementptr inbounds nuw %struct.B, ptr [[B]], i32 0, i32 1 @@ -128,7 +128,7 @@ void test_set_B(struct B *b, __INTPTR_TYPE__ x, int y) { // CHECK: [[CONV:%.*]] = sext i32 [[Y]] to i64 // CHECK: [[CAST_ADDR:%.*]] = ptrtoint ptr [[F1_ADDR]] to i64 // CHECK: [[BLENDED:%.*]] = call i64 @llvm.ptrauth.blend(i64 [[CAST_ADDR]], i64 23674) - // CHECK: [[SIGNED:%.*]] = call i64 @llvm.ptrauth.sign(i64 [[CONV]], i32 1, i64 [[BLENDED]]) + // CHECK: [[SIGNED:%.*]] = call i64 @llvm.ptrauth.sign(i64 [[CONV]]) [ "ptrauth"(i64 1, i64 [[BLENDED]]) ] b->f2 = 0; // CHECK: [[B:%.*]] = load ptr, ptr %b.addr // CHECK: [[F2_ADDR:%.*]] = getelementptr inbounds nuw %struct.B, ptr [[B]], i32 0, i32 2 @@ -141,15 +141,15 @@ __INTPTR_TYPE__ test_get_A(struct A *a) { // CHECK: [[A:%.*]] = load ptr, ptr %a.addr // CHECK: [[F0_ADDR:%.*]] = getelementptr inbounds nuw %struct.A, ptr [[A]], i32 0, i32 0 // CHECK: [[F0:%.*]] = load i64, ptr [[F0_ADDR]] - // CHECK: [[AUTH:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[F0]], i32 1, i64 431) + // CHECK: [[AUTH:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[F0]]) [ "ptrauth"(i64 1, i64 431) ] // CHECK: [[A:%.*]] = load ptr, ptr %a.addr // CHECK: [[F1_ADDR:%.*]] = getelementptr inbounds nuw %struct.A, ptr [[A]], i32 0, i32 1 // CHECK: [[F1:%.*]] = load i64, ptr [[F1_ADDR]] - // CHECK: [[AUTH:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[F1]], i32 1, i64 9182) + // CHECK: [[AUTH:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[F1]]) [ "ptrauth"(i64 1, i64 9182) ] // CHECK: [[A:%.*]] = load ptr, ptr %a.addr // CHECK: [[F2_ADDR:%.*]] = getelementptr inbounds nuw %struct.A, ptr [[A]], i32 0, i32 2 // CHECK: [[F2:%.*]] = load i64, ptr [[F2_ADDR]] - // CHECK: [[AUTH:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[F2]], i32 1, i64 783) + // CHECK: [[AUTH:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[F2]]) [ "ptrauth"(i64 1, i64 783) ] } // CHECK-LABEL: define i64 @test_get_B @@ -160,19 +160,19 @@ __INTPTR_TYPE__ test_get_B(struct B *b) { // CHECK: [[VALUE:%.*]] = load i64, ptr [[F0]] // CHECK: [[CASTF0:%.*]] = ptrtoint ptr %f0 to i64 // CHECK: [[BLENDED:%.*]] = call i64 @llvm.ptrauth.blend(i64 [[CASTF0]], i64 1276) - // CHECK: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VALUE]], i32 1, i64 [[BLENDED]]) + // CHECK: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VALUE]]) [ "ptrauth"(i64 1, i64 [[BLENDED]]) ] // CHECK: [[B:%.*]] = load ptr, ptr %b.addr // CHECK: [[ADDR:%.*]] = getelementptr inbounds nuw %struct.B, ptr [[B]], i32 0, i32 1 // CHECK: [[VALUE:%.*]] = load i64, ptr [[ADDR]] // CHECK: [[CAST_ADDR:%.*]] = ptrtoint ptr [[ADDR]] to i64 // CHECK: [[BLENDED:%.*]] = call i64 @llvm.ptrauth.blend(i64 [[CAST_ADDR]], i64 23674) - // CHECK: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VALUE]], i32 1, i64 [[BLENDED]]) + // CHECK: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VALUE]]) [ "ptrauth"(i64 1, i64 [[BLENDED]]) ] // CHECK: [[B:%.*]] = load ptr, ptr %b.addr // CHECK: [[ADDR:%.*]] = getelementptr inbounds nuw %struct.B, ptr [[B]], i32 0, i32 2 // CHECK: [[VALUE:%.*]] = load i64, ptr [[ADDR]] // CHECK: [[CAST_ADDR:%.*]] = ptrtoint ptr [[ADDR]] to i64 // CHECK: [[BLENDED:%.*]] = call i64 @llvm.ptrauth.blend(i64 [[CAST_ADDR]], i64 163) - // CHECK: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VALUE]], i32 1, i64 [[BLENDED]]) + // CHECK: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VALUE]]) [ "ptrauth"(i64 1, i64 [[BLENDED]]) ] } // CHECK-LABEL: define void @test_resign @@ -185,7 +185,7 @@ void test_resign(struct A* a, const struct B *b) { // CHECK: [[F01VALUE:%.*]] = load i64, ptr [[F01]] // CHECK: [[CASTF01:%.*]] = ptrtoint ptr %f01 to i64 // CHECK: [[BLENDED:%.*]] = call i64 @llvm.ptrauth.blend(i64 [[CASTF01]], i64 1276) - // CHECK: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.resign(i64 [[F01VALUE]], i32 1, i64 [[BLENDED]], i32 1, i64 431) + // CHECK: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.resign(i64 [[F01VALUE]]) [ "ptrauth"(i64 1, i64 [[BLENDED]]), "ptrauth"(i64 1, i64 431) ] } // CHECK-LABEL: define i64 @other_test @@ -196,24 +196,24 @@ __INTPTR_TYPE__ other_test(__INTPTR_TYPE__ i) { __INTPTR_TYPE__ __ptrauth(1, 1, 43) k = 1234; // CHECK: [[ADDR:%.*]] = ptrtoint ptr %k to i64 // CHECK: [[JBLENDED:%.*]] = call i64 @llvm.ptrauth.blend(i64 [[ADDR]], i64 43) - // CHECK: [[SIGNED:%.*]] = call i64 @llvm.ptrauth.sign(i64 1234, i32 1, i64 [[JBLENDED]]) + // CHECK: [[SIGNED:%.*]] = call i64 @llvm.ptrauth.sign(i64 1234) [ "ptrauth"(i64 1, i64 [[JBLENDED]]) ] __INTPTR_TYPE__ __ptrauth(1, 1, 44) l = i; // CHECK: [[I:%.*]] = load i64, ptr %i.addr // CHECK: [[ADDR:%.*]] = ptrtoint ptr %l to i64 // CHECK: [[LBLENDED:%.*]] = call i64 @llvm.ptrauth.blend(i64 [[ADDR]], i64 44) - // CHECK: [[SIGNED:%.*]] = call i64 @llvm.ptrauth.sign(i64 [[I]], i32 1, i64 [[LBLENDED]]) + // CHECK: [[SIGNED:%.*]] = call i64 @llvm.ptrauth.sign(i64 [[I]]) [ "ptrauth"(i64 1, i64 [[LBLENDED]]) ] asm volatile ("" ::: "memory"); return j + k + l; // CHECK: [[VALUE:%.*]] = load i64, ptr %j // CHECK: [[CAST_ADDR:%.*]] = ptrtoint ptr %j to i64 // CHECK: [[BLENDED:%.*]] = call i64 @llvm.ptrauth.blend(i64 [[CAST_ADDR]], i64 42) - // CHECK: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VALUE]], i32 1, i64 [[BLENDED]]) + // CHECK: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VALUE]]) [ "ptrauth"(i64 1, i64 [[BLENDED]]) ] // CHECK: [[VALUE:%.*]] = load i64, ptr %k // CHECK: [[CASTK:%.*]] = ptrtoint ptr %k to i64 // CHECK: [[BLENDED:%.*]] = call i64 @llvm.ptrauth.blend(i64 [[CASTK]], i64 43) - // CHECK: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VALUE]], i32 1, i64 [[BLENDED]]) + // CHECK: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VALUE]]) [ "ptrauth"(i64 1, i64 [[BLENDED]]) ] // CHECK: [[VALUE:%.*]] = load i64, ptr %l // CHECK: [[CASTL:%.*]] = ptrtoint ptr %l to i64 // CHECK: [[BLENDED:%.*]] = call i64 @llvm.ptrauth.blend(i64 [[CASTL]], i64 44) - // CHECK: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VALUE]], i32 1, i64 [[BLENDED]]) + // CHECK: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VALUE]]) [ "ptrauth"(i64 1, i64 [[BLENDED]]) ] } diff --git a/clang/test/CodeGen/ubsan-function.cpp b/clang/test/CodeGen/ubsan-function.cpp index 76d4237383f83..d4f1956496d86 100644 --- a/clang/test/CodeGen/ubsan-function.cpp +++ b/clang/test/CodeGen/ubsan-function.cpp @@ -17,7 +17,7 @@ void fun() {} // ARM: and i32 {{.*}}, -2, !nosanitize !5 // ARM: inttoptr i32 {{.*}} to ptr, !nosanitize !5 // AUTH: %[[STRIPPED:.*]] = ptrtoint ptr {{.*}} to i64, !nosanitize -// AUTH: call i64 @llvm.ptrauth.auth(i64 %[[STRIPPED]], i32 0, i64 0), !nosanitize +// AUTH: call i64 @llvm.ptrauth.auth(i64 %[[STRIPPED]]) [ "ptrauth"(i64 0, i64 0) ], !nosanitize // CHECK: getelementptr <{ i32, i32 }>, ptr {{.*}}, i32 -1, i32 0, !nosanitize // CHECK: load i32, ptr {{.*}}, align {{.*}}, !nosanitize // CHECK: icmp eq i32 {{.*}}, -1056584962, !nosanitize diff --git a/clang/test/CodeGenCXX/builtin-get-vtable-pointer.cpp b/clang/test/CodeGenCXX/builtin-get-vtable-pointer.cpp index 0bde63496f4cb..c7a7340d95cbf 100644 --- a/clang/test/CodeGenCXX/builtin-get-vtable-pointer.cpp +++ b/clang/test/CodeGenCXX/builtin-get-vtable-pointer.cpp @@ -53,7 +53,7 @@ template struct same_type { // CHECK-TYPEAUTH-NEXT: [[TMP0:%.*]] = load ptr, ptr [[O_ADDR]], align 8, !tbaa [[TBAA6]] // CHECK-TYPEAUTH-NEXT: [[VTABLE:%.*]] = load ptr, ptr [[TMP0]], align 8, !tbaa [[TBAA9:![0-9]+]] // CHECK-TYPEAUTH-NEXT: [[TMP1:%.*]] = ptrtoint ptr [[VTABLE]] to i64 -// CHECK-TYPEAUTH-NEXT: [[TMP2:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[TMP1]], i32 2, i64 48388) +// CHECK-TYPEAUTH-NEXT: [[TMP2:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[TMP1]]) [ "ptrauth"(i64 2, i64 48388) ] // CHECK-TYPEAUTH-NEXT: [[TMP3:%.*]] = inttoptr i64 [[TMP2]] to ptr // CHECK-TYPEAUTH-NEXT: [[TMP4:%.*]] = load volatile i8, ptr [[TMP3]], align 8 // CHECK-TYPEAUTH-NEXT: ret ptr [[TMP3]] @@ -67,7 +67,7 @@ template struct same_type { // CHECK-ADDRESSAUTH-NEXT: [[VTABLE:%.*]] = load ptr, ptr [[TMP0]], align 8, !tbaa [[TBAA9:![0-9]+]] // CHECK-ADDRESSAUTH-NEXT: [[TMP1:%.*]] = ptrtoint ptr [[TMP0]] to i64 // CHECK-ADDRESSAUTH-NEXT: [[TMP2:%.*]] = ptrtoint ptr [[VTABLE]] to i64 -// CHECK-ADDRESSAUTH-NEXT: [[TMP3:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[TMP2]], i32 2, i64 [[TMP1]]) +// CHECK-ADDRESSAUTH-NEXT: [[TMP3:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[TMP2]]) [ "ptrauth"(i64 2, i64 [[TMP1]]) ] // CHECK-ADDRESSAUTH-NEXT: [[TMP4:%.*]] = inttoptr i64 [[TMP3]] to ptr // CHECK-ADDRESSAUTH-NEXT: [[TMP5:%.*]] = load volatile i8, ptr [[TMP4]], align 8 // CHECK-ADDRESSAUTH-NEXT: ret ptr [[TMP4]] @@ -82,7 +82,7 @@ template struct same_type { // CHECK-BOTHAUTH-NEXT: [[TMP1:%.*]] = ptrtoint ptr [[TMP0]] to i64 // CHECK-BOTHAUTH-NEXT: [[TMP2:%.*]] = call i64 @llvm.ptrauth.blend(i64 [[TMP1]], i64 48388) // CHECK-BOTHAUTH-NEXT: [[TMP3:%.*]] = ptrtoint ptr [[VTABLE]] to i64 -// CHECK-BOTHAUTH-NEXT: [[TMP4:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[TMP3]], i32 2, i64 [[TMP2]]) +// CHECK-BOTHAUTH-NEXT: [[TMP4:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[TMP3]]) [ "ptrauth"(i64 2, i64 [[TMP2]]) ] // CHECK-BOTHAUTH-NEXT: [[TMP5:%.*]] = inttoptr i64 [[TMP4]] to ptr // CHECK-BOTHAUTH-NEXT: [[TMP6:%.*]] = load volatile i8, ptr [[TMP5]], align 8 // CHECK-BOTHAUTH-NEXT: ret ptr [[TMP5]] @@ -109,7 +109,7 @@ const void *a(A *o) { // CHECK-TYPEAUTH-NEXT: [[TMP0:%.*]] = load ptr, ptr [[O_ADDR]], align 8, !tbaa [[TBAA11]] // CHECK-TYPEAUTH-NEXT: [[VTABLE:%.*]] = load ptr, ptr [[TMP0]], align 8, !tbaa [[TBAA9]] // CHECK-TYPEAUTH-NEXT: [[TMP1:%.*]] = ptrtoint ptr [[VTABLE]] to i64 -// CHECK-TYPEAUTH-NEXT: [[TMP2:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[TMP1]], i32 2, i64 48388) +// CHECK-TYPEAUTH-NEXT: [[TMP2:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[TMP1]]) [ "ptrauth"(i64 2, i64 48388) ] // CHECK-TYPEAUTH-NEXT: [[TMP3:%.*]] = inttoptr i64 [[TMP2]] to ptr // CHECK-TYPEAUTH-NEXT: [[TMP4:%.*]] = load volatile i8, ptr [[TMP3]], align 8 // CHECK-TYPEAUTH-NEXT: ret ptr [[TMP3]] @@ -123,7 +123,7 @@ const void *a(A *o) { // CHECK-ADDRESSAUTH-NEXT: [[VTABLE:%.*]] = load ptr, ptr [[TMP0]], align 8, !tbaa [[TBAA9]] // CHECK-ADDRESSAUTH-NEXT: [[TMP1:%.*]] = ptrtoint ptr [[TMP0]] to i64 // CHECK-ADDRESSAUTH-NEXT: [[TMP2:%.*]] = ptrtoint ptr [[VTABLE]] to i64 -// CHECK-ADDRESSAUTH-NEXT: [[TMP3:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[TMP2]], i32 2, i64 [[TMP1]]) +// CHECK-ADDRESSAUTH-NEXT: [[TMP3:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[TMP2]]) [ "ptrauth"(i64 2, i64 [[TMP1]]) ] // CHECK-ADDRESSAUTH-NEXT: [[TMP4:%.*]] = inttoptr i64 [[TMP3]] to ptr // CHECK-ADDRESSAUTH-NEXT: [[TMP5:%.*]] = load volatile i8, ptr [[TMP4]], align 8 // CHECK-ADDRESSAUTH-NEXT: ret ptr [[TMP4]] @@ -138,7 +138,7 @@ const void *a(A *o) { // CHECK-BOTHAUTH-NEXT: [[TMP1:%.*]] = ptrtoint ptr [[TMP0]] to i64 // CHECK-BOTHAUTH-NEXT: [[TMP2:%.*]] = call i64 @llvm.ptrauth.blend(i64 [[TMP1]], i64 48388) // CHECK-BOTHAUTH-NEXT: [[TMP3:%.*]] = ptrtoint ptr [[VTABLE]] to i64 -// CHECK-BOTHAUTH-NEXT: [[TMP4:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[TMP3]], i32 2, i64 [[TMP2]]) +// CHECK-BOTHAUTH-NEXT: [[TMP4:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[TMP3]]) [ "ptrauth"(i64 2, i64 [[TMP2]]) ] // CHECK-BOTHAUTH-NEXT: [[TMP5:%.*]] = inttoptr i64 [[TMP4]] to ptr // CHECK-BOTHAUTH-NEXT: [[TMP6:%.*]] = load volatile i8, ptr [[TMP5]], align 8 // CHECK-BOTHAUTH-NEXT: ret ptr [[TMP5]] @@ -165,7 +165,7 @@ const void *b(B *o) { // CHECK-TYPEAUTH-NEXT: [[TMP0:%.*]] = load ptr, ptr [[O_ADDR]], align 8, !tbaa [[TBAA11]] // CHECK-TYPEAUTH-NEXT: [[VTABLE:%.*]] = load ptr, ptr [[TMP0]], align 8, !tbaa [[TBAA9]] // CHECK-TYPEAUTH-NEXT: [[TMP1:%.*]] = ptrtoint ptr [[VTABLE]] to i64 -// CHECK-TYPEAUTH-NEXT: [[TMP2:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[TMP1]], i32 2, i64 48388) +// CHECK-TYPEAUTH-NEXT: [[TMP2:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[TMP1]]) [ "ptrauth"(i64 2, i64 48388) ] // CHECK-TYPEAUTH-NEXT: [[TMP3:%.*]] = inttoptr i64 [[TMP2]] to ptr // CHECK-TYPEAUTH-NEXT: [[TMP4:%.*]] = load volatile i8, ptr [[TMP3]], align 8 // CHECK-TYPEAUTH-NEXT: ret ptr [[TMP3]] @@ -179,7 +179,7 @@ const void *b(B *o) { // CHECK-ADDRESSAUTH-NEXT: [[VTABLE:%.*]] = load ptr, ptr [[TMP0]], align 8, !tbaa [[TBAA9]] // CHECK-ADDRESSAUTH-NEXT: [[TMP1:%.*]] = ptrtoint ptr [[TMP0]] to i64 // CHECK-ADDRESSAUTH-NEXT: [[TMP2:%.*]] = ptrtoint ptr [[VTABLE]] to i64 -// CHECK-ADDRESSAUTH-NEXT: [[TMP3:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[TMP2]], i32 2, i64 [[TMP1]]) +// CHECK-ADDRESSAUTH-NEXT: [[TMP3:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[TMP2]]) [ "ptrauth"(i64 2, i64 [[TMP1]]) ] // CHECK-ADDRESSAUTH-NEXT: [[TMP4:%.*]] = inttoptr i64 [[TMP3]] to ptr // CHECK-ADDRESSAUTH-NEXT: [[TMP5:%.*]] = load volatile i8, ptr [[TMP4]], align 8 // CHECK-ADDRESSAUTH-NEXT: ret ptr [[TMP4]] @@ -194,7 +194,7 @@ const void *b(B *o) { // CHECK-BOTHAUTH-NEXT: [[TMP1:%.*]] = ptrtoint ptr [[TMP0]] to i64 // CHECK-BOTHAUTH-NEXT: [[TMP2:%.*]] = call i64 @llvm.ptrauth.blend(i64 [[TMP1]], i64 48388) // CHECK-BOTHAUTH-NEXT: [[TMP3:%.*]] = ptrtoint ptr [[VTABLE]] to i64 -// CHECK-BOTHAUTH-NEXT: [[TMP4:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[TMP3]], i32 2, i64 [[TMP2]]) +// CHECK-BOTHAUTH-NEXT: [[TMP4:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[TMP3]]) [ "ptrauth"(i64 2, i64 [[TMP2]]) ] // CHECK-BOTHAUTH-NEXT: [[TMP5:%.*]] = inttoptr i64 [[TMP4]] to ptr // CHECK-BOTHAUTH-NEXT: [[TMP6:%.*]] = load volatile i8, ptr [[TMP5]], align 8 // CHECK-BOTHAUTH-NEXT: ret ptr [[TMP5]] @@ -221,7 +221,7 @@ const void *b_as_A(B *o) { // CHECK-TYPEAUTH-NEXT: [[TMP0:%.*]] = load ptr, ptr [[O_ADDR]], align 8, !tbaa [[TBAA13]] // CHECK-TYPEAUTH-NEXT: [[VTABLE:%.*]] = load ptr, ptr [[TMP0]], align 8, !tbaa [[TBAA9]] // CHECK-TYPEAUTH-NEXT: [[TMP1:%.*]] = ptrtoint ptr [[VTABLE]] to i64 -// CHECK-TYPEAUTH-NEXT: [[TMP2:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[TMP1]], i32 2, i64 48388) +// CHECK-TYPEAUTH-NEXT: [[TMP2:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[TMP1]]) [ "ptrauth"(i64 2, i64 48388) ] // CHECK-TYPEAUTH-NEXT: [[TMP3:%.*]] = inttoptr i64 [[TMP2]] to ptr // CHECK-TYPEAUTH-NEXT: [[TMP4:%.*]] = load volatile i8, ptr [[TMP3]], align 8 // CHECK-TYPEAUTH-NEXT: ret ptr [[TMP3]] @@ -235,7 +235,7 @@ const void *b_as_A(B *o) { // CHECK-ADDRESSAUTH-NEXT: [[VTABLE:%.*]] = load ptr, ptr [[TMP0]], align 8, !tbaa [[TBAA9]] // CHECK-ADDRESSAUTH-NEXT: [[TMP1:%.*]] = ptrtoint ptr [[TMP0]] to i64 // CHECK-ADDRESSAUTH-NEXT: [[TMP2:%.*]] = ptrtoint ptr [[VTABLE]] to i64 -// CHECK-ADDRESSAUTH-NEXT: [[TMP3:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[TMP2]], i32 2, i64 [[TMP1]]) +// CHECK-ADDRESSAUTH-NEXT: [[TMP3:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[TMP2]]) [ "ptrauth"(i64 2, i64 [[TMP1]]) ] // CHECK-ADDRESSAUTH-NEXT: [[TMP4:%.*]] = inttoptr i64 [[TMP3]] to ptr // CHECK-ADDRESSAUTH-NEXT: [[TMP5:%.*]] = load volatile i8, ptr [[TMP4]], align 8 // CHECK-ADDRESSAUTH-NEXT: ret ptr [[TMP4]] @@ -250,7 +250,7 @@ const void *b_as_A(B *o) { // CHECK-BOTHAUTH-NEXT: [[TMP1:%.*]] = ptrtoint ptr [[TMP0]] to i64 // CHECK-BOTHAUTH-NEXT: [[TMP2:%.*]] = call i64 @llvm.ptrauth.blend(i64 [[TMP1]], i64 48388) // CHECK-BOTHAUTH-NEXT: [[TMP3:%.*]] = ptrtoint ptr [[VTABLE]] to i64 -// CHECK-BOTHAUTH-NEXT: [[TMP4:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[TMP3]], i32 2, i64 [[TMP2]]) +// CHECK-BOTHAUTH-NEXT: [[TMP4:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[TMP3]]) [ "ptrauth"(i64 2, i64 [[TMP2]]) ] // CHECK-BOTHAUTH-NEXT: [[TMP5:%.*]] = inttoptr i64 [[TMP4]] to ptr // CHECK-BOTHAUTH-NEXT: [[TMP6:%.*]] = load volatile i8, ptr [[TMP5]], align 8 // CHECK-BOTHAUTH-NEXT: ret ptr [[TMP5]] @@ -277,7 +277,7 @@ const void *c(C *o) { // CHECK-TYPEAUTH-NEXT: [[TMP0:%.*]] = load ptr, ptr [[O_ADDR]], align 8, !tbaa [[TBAA13]] // CHECK-TYPEAUTH-NEXT: [[VTABLE:%.*]] = load ptr, ptr [[TMP0]], align 8, !tbaa [[TBAA9]] // CHECK-TYPEAUTH-NEXT: [[TMP1:%.*]] = ptrtoint ptr [[VTABLE]] to i64 -// CHECK-TYPEAUTH-NEXT: [[TMP2:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[TMP1]], i32 2, i64 48388) +// CHECK-TYPEAUTH-NEXT: [[TMP2:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[TMP1]]) [ "ptrauth"(i64 2, i64 48388) ] // CHECK-TYPEAUTH-NEXT: [[TMP3:%.*]] = inttoptr i64 [[TMP2]] to ptr // CHECK-TYPEAUTH-NEXT: [[TMP4:%.*]] = load volatile i8, ptr [[TMP3]], align 8 // CHECK-TYPEAUTH-NEXT: ret ptr [[TMP3]] @@ -291,7 +291,7 @@ const void *c(C *o) { // CHECK-ADDRESSAUTH-NEXT: [[VTABLE:%.*]] = load ptr, ptr [[TMP0]], align 8, !tbaa [[TBAA9]] // CHECK-ADDRESSAUTH-NEXT: [[TMP1:%.*]] = ptrtoint ptr [[TMP0]] to i64 // CHECK-ADDRESSAUTH-NEXT: [[TMP2:%.*]] = ptrtoint ptr [[VTABLE]] to i64 -// CHECK-ADDRESSAUTH-NEXT: [[TMP3:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[TMP2]], i32 2, i64 [[TMP1]]) +// CHECK-ADDRESSAUTH-NEXT: [[TMP3:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[TMP2]]) [ "ptrauth"(i64 2, i64 [[TMP1]]) ] // CHECK-ADDRESSAUTH-NEXT: [[TMP4:%.*]] = inttoptr i64 [[TMP3]] to ptr // CHECK-ADDRESSAUTH-NEXT: [[TMP5:%.*]] = load volatile i8, ptr [[TMP4]], align 8 // CHECK-ADDRESSAUTH-NEXT: ret ptr [[TMP4]] @@ -306,7 +306,7 @@ const void *c(C *o) { // CHECK-BOTHAUTH-NEXT: [[TMP1:%.*]] = ptrtoint ptr [[TMP0]] to i64 // CHECK-BOTHAUTH-NEXT: [[TMP2:%.*]] = call i64 @llvm.ptrauth.blend(i64 [[TMP1]], i64 48388) // CHECK-BOTHAUTH-NEXT: [[TMP3:%.*]] = ptrtoint ptr [[VTABLE]] to i64 -// CHECK-BOTHAUTH-NEXT: [[TMP4:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[TMP3]], i32 2, i64 [[TMP2]]) +// CHECK-BOTHAUTH-NEXT: [[TMP4:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[TMP3]]) [ "ptrauth"(i64 2, i64 [[TMP2]]) ] // CHECK-BOTHAUTH-NEXT: [[TMP5:%.*]] = inttoptr i64 [[TMP4]] to ptr // CHECK-BOTHAUTH-NEXT: [[TMP6:%.*]] = load volatile i8, ptr [[TMP5]], align 8 // CHECK-BOTHAUTH-NEXT: ret ptr [[TMP5]] @@ -347,7 +347,7 @@ const void *c_as_Z(C *o) { // CHECK-TYPEAUTH-NEXT: [[CAST_RESULT:%.*]] = phi ptr [ [[ADD_PTR]], %[[CAST_NOTNULL]] ], [ null, %[[ENTRY]] ] // CHECK-TYPEAUTH-NEXT: [[VTABLE:%.*]] = load ptr, ptr [[CAST_RESULT]], align 8, !tbaa [[TBAA9]] // CHECK-TYPEAUTH-NEXT: [[TMP2:%.*]] = ptrtoint ptr [[VTABLE]] to i64 -// CHECK-TYPEAUTH-NEXT: [[TMP3:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[TMP2]], i32 2, i64 48388) +// CHECK-TYPEAUTH-NEXT: [[TMP3:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[TMP2]]) [ "ptrauth"(i64 2, i64 48388) ] // CHECK-TYPEAUTH-NEXT: [[TMP4:%.*]] = inttoptr i64 [[TMP3]] to ptr // CHECK-TYPEAUTH-NEXT: [[TMP5:%.*]] = load volatile i8, ptr [[TMP4]], align 8 // CHECK-TYPEAUTH-NEXT: ret ptr [[TMP4]] @@ -368,7 +368,7 @@ const void *c_as_Z(C *o) { // CHECK-ADDRESSAUTH-NEXT: [[VTABLE:%.*]] = load ptr, ptr [[CAST_RESULT]], align 8, !tbaa [[TBAA9]] // CHECK-ADDRESSAUTH-NEXT: [[TMP2:%.*]] = ptrtoint ptr [[CAST_RESULT]] to i64 // CHECK-ADDRESSAUTH-NEXT: [[TMP3:%.*]] = ptrtoint ptr [[VTABLE]] to i64 -// CHECK-ADDRESSAUTH-NEXT: [[TMP4:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[TMP3]], i32 2, i64 [[TMP2]]) +// CHECK-ADDRESSAUTH-NEXT: [[TMP4:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[TMP3]]) [ "ptrauth"(i64 2, i64 [[TMP2]]) ] // CHECK-ADDRESSAUTH-NEXT: [[TMP5:%.*]] = inttoptr i64 [[TMP4]] to ptr // CHECK-ADDRESSAUTH-NEXT: [[TMP6:%.*]] = load volatile i8, ptr [[TMP5]], align 8 // CHECK-ADDRESSAUTH-NEXT: ret ptr [[TMP5]] @@ -390,7 +390,7 @@ const void *c_as_Z(C *o) { // CHECK-BOTHAUTH-NEXT: [[TMP2:%.*]] = ptrtoint ptr [[CAST_RESULT]] to i64 // CHECK-BOTHAUTH-NEXT: [[TMP3:%.*]] = call i64 @llvm.ptrauth.blend(i64 [[TMP2]], i64 48388) // CHECK-BOTHAUTH-NEXT: [[TMP4:%.*]] = ptrtoint ptr [[VTABLE]] to i64 -// CHECK-BOTHAUTH-NEXT: [[TMP5:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[TMP4]], i32 2, i64 [[TMP3]]) +// CHECK-BOTHAUTH-NEXT: [[TMP5:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[TMP4]]) [ "ptrauth"(i64 2, i64 [[TMP3]]) ] // CHECK-BOTHAUTH-NEXT: [[TMP6:%.*]] = inttoptr i64 [[TMP5]] to ptr // CHECK-BOTHAUTH-NEXT: [[TMP7:%.*]] = load volatile i8, ptr [[TMP6]], align 8 // CHECK-BOTHAUTH-NEXT: ret ptr [[TMP6]] @@ -417,7 +417,7 @@ const void *c_as_B(C *o) { // CHECK-TYPEAUTH-NEXT: [[TMP0:%.*]] = load ptr, ptr [[O_ADDR]], align 8, !tbaa [[TBAA15]] // CHECK-TYPEAUTH-NEXT: [[VTABLE:%.*]] = load ptr, ptr [[TMP0]], align 8, !tbaa [[TBAA9]] // CHECK-TYPEAUTH-NEXT: [[TMP1:%.*]] = ptrtoint ptr [[VTABLE]] to i64 -// CHECK-TYPEAUTH-NEXT: [[TMP2:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[TMP1]], i32 2, i64 48388) +// CHECK-TYPEAUTH-NEXT: [[TMP2:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[TMP1]]) [ "ptrauth"(i64 2, i64 48388) ] // CHECK-TYPEAUTH-NEXT: [[TMP3:%.*]] = inttoptr i64 [[TMP2]] to ptr // CHECK-TYPEAUTH-NEXT: [[TMP4:%.*]] = load volatile i8, ptr [[TMP3]], align 8 // CHECK-TYPEAUTH-NEXT: ret ptr [[TMP3]] @@ -431,7 +431,7 @@ const void *c_as_B(C *o) { // CHECK-ADDRESSAUTH-NEXT: [[VTABLE:%.*]] = load ptr, ptr [[TMP0]], align 8, !tbaa [[TBAA9]] // CHECK-ADDRESSAUTH-NEXT: [[TMP1:%.*]] = ptrtoint ptr [[TMP0]] to i64 // CHECK-ADDRESSAUTH-NEXT: [[TMP2:%.*]] = ptrtoint ptr [[VTABLE]] to i64 -// CHECK-ADDRESSAUTH-NEXT: [[TMP3:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[TMP2]], i32 2, i64 [[TMP1]]) +// CHECK-ADDRESSAUTH-NEXT: [[TMP3:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[TMP2]]) [ "ptrauth"(i64 2, i64 [[TMP1]]) ] // CHECK-ADDRESSAUTH-NEXT: [[TMP4:%.*]] = inttoptr i64 [[TMP3]] to ptr // CHECK-ADDRESSAUTH-NEXT: [[TMP5:%.*]] = load volatile i8, ptr [[TMP4]], align 8 // CHECK-ADDRESSAUTH-NEXT: ret ptr [[TMP4]] @@ -446,7 +446,7 @@ const void *c_as_B(C *o) { // CHECK-BOTHAUTH-NEXT: [[TMP1:%.*]] = ptrtoint ptr [[TMP0]] to i64 // CHECK-BOTHAUTH-NEXT: [[TMP2:%.*]] = call i64 @llvm.ptrauth.blend(i64 [[TMP1]], i64 48388) // CHECK-BOTHAUTH-NEXT: [[TMP3:%.*]] = ptrtoint ptr [[VTABLE]] to i64 -// CHECK-BOTHAUTH-NEXT: [[TMP4:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[TMP3]], i32 2, i64 [[TMP2]]) +// CHECK-BOTHAUTH-NEXT: [[TMP4:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[TMP3]]) [ "ptrauth"(i64 2, i64 [[TMP2]]) ] // CHECK-BOTHAUTH-NEXT: [[TMP5:%.*]] = inttoptr i64 [[TMP4]] to ptr // CHECK-BOTHAUTH-NEXT: [[TMP6:%.*]] = load volatile i8, ptr [[TMP5]], align 8 // CHECK-BOTHAUTH-NEXT: ret ptr [[TMP5]] @@ -486,7 +486,7 @@ const void *d(D *o) { // CHECK-TYPEAUTH: [[CAST_NOTNULL]]: // CHECK-TYPEAUTH-NEXT: [[VTABLE:%.*]] = load ptr, ptr [[TMP0]], align 8, !tbaa [[TBAA9]] // CHECK-TYPEAUTH-NEXT: [[TMP2:%.*]] = ptrtoint ptr [[VTABLE]] to i64 -// CHECK-TYPEAUTH-NEXT: [[TMP3:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[TMP2]], i32 2, i64 48388) +// CHECK-TYPEAUTH-NEXT: [[TMP3:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[TMP2]]) [ "ptrauth"(i64 2, i64 48388) ] // CHECK-TYPEAUTH-NEXT: [[TMP4:%.*]] = inttoptr i64 [[TMP3]] to ptr // CHECK-TYPEAUTH-NEXT: [[VBASE_OFFSET_PTR:%.*]] = getelementptr i8, ptr [[TMP4]], i64 -32 // CHECK-TYPEAUTH-NEXT: [[VBASE_OFFSET:%.*]] = load i64, ptr [[VBASE_OFFSET_PTR]], align 8 @@ -496,7 +496,7 @@ const void *d(D *o) { // CHECK-TYPEAUTH-NEXT: [[CAST_RESULT:%.*]] = phi ptr [ [[ADD_PTR]], %[[CAST_NOTNULL]] ], [ null, %[[ENTRY]] ] // CHECK-TYPEAUTH-NEXT: [[VTABLE1:%.*]] = load ptr, ptr [[CAST_RESULT]], align 8, !tbaa [[TBAA9]] // CHECK-TYPEAUTH-NEXT: [[TMP5:%.*]] = ptrtoint ptr [[VTABLE1]] to i64 -// CHECK-TYPEAUTH-NEXT: [[TMP6:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[TMP5]], i32 2, i64 48388) +// CHECK-TYPEAUTH-NEXT: [[TMP6:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[TMP5]]) [ "ptrauth"(i64 2, i64 48388) ] // CHECK-TYPEAUTH-NEXT: [[TMP7:%.*]] = inttoptr i64 [[TMP6]] to ptr // CHECK-TYPEAUTH-NEXT: [[TMP8:%.*]] = load volatile i8, ptr [[TMP7]], align 8 // CHECK-TYPEAUTH-NEXT: ret ptr [[TMP7]] @@ -513,7 +513,7 @@ const void *d(D *o) { // CHECK-ADDRESSAUTH-NEXT: [[VTABLE:%.*]] = load ptr, ptr [[TMP0]], align 8, !tbaa [[TBAA9]] // CHECK-ADDRESSAUTH-NEXT: [[TMP2:%.*]] = ptrtoint ptr [[TMP0]] to i64 // CHECK-ADDRESSAUTH-NEXT: [[TMP3:%.*]] = ptrtoint ptr [[VTABLE]] to i64 -// CHECK-ADDRESSAUTH-NEXT: [[TMP4:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[TMP3]], i32 2, i64 [[TMP2]]) +// CHECK-ADDRESSAUTH-NEXT: [[TMP4:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[TMP3]]) [ "ptrauth"(i64 2, i64 [[TMP2]]) ] // CHECK-ADDRESSAUTH-NEXT: [[TMP5:%.*]] = inttoptr i64 [[TMP4]] to ptr // CHECK-ADDRESSAUTH-NEXT: [[VBASE_OFFSET_PTR:%.*]] = getelementptr i8, ptr [[TMP5]], i64 -32 // CHECK-ADDRESSAUTH-NEXT: [[VBASE_OFFSET:%.*]] = load i64, ptr [[VBASE_OFFSET_PTR]], align 8 @@ -524,7 +524,7 @@ const void *d(D *o) { // CHECK-ADDRESSAUTH-NEXT: [[VTABLE1:%.*]] = load ptr, ptr [[CAST_RESULT]], align 8, !tbaa [[TBAA9]] // CHECK-ADDRESSAUTH-NEXT: [[TMP6:%.*]] = ptrtoint ptr [[CAST_RESULT]] to i64 // CHECK-ADDRESSAUTH-NEXT: [[TMP7:%.*]] = ptrtoint ptr [[VTABLE1]] to i64 -// CHECK-ADDRESSAUTH-NEXT: [[TMP8:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[TMP7]], i32 2, i64 [[TMP6]]) +// CHECK-ADDRESSAUTH-NEXT: [[TMP8:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[TMP7]]) [ "ptrauth"(i64 2, i64 [[TMP6]]) ] // CHECK-ADDRESSAUTH-NEXT: [[TMP9:%.*]] = inttoptr i64 [[TMP8]] to ptr // CHECK-ADDRESSAUTH-NEXT: [[TMP10:%.*]] = load volatile i8, ptr [[TMP9]], align 8 // CHECK-ADDRESSAUTH-NEXT: ret ptr [[TMP9]] @@ -542,7 +542,7 @@ const void *d(D *o) { // CHECK-BOTHAUTH-NEXT: [[TMP2:%.*]] = ptrtoint ptr [[TMP0]] to i64 // CHECK-BOTHAUTH-NEXT: [[TMP3:%.*]] = call i64 @llvm.ptrauth.blend(i64 [[TMP2]], i64 48388) // CHECK-BOTHAUTH-NEXT: [[TMP4:%.*]] = ptrtoint ptr [[VTABLE]] to i64 -// CHECK-BOTHAUTH-NEXT: [[TMP5:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[TMP4]], i32 2, i64 [[TMP3]]) +// CHECK-BOTHAUTH-NEXT: [[TMP5:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[TMP4]]) [ "ptrauth"(i64 2, i64 [[TMP3]]) ] // CHECK-BOTHAUTH-NEXT: [[TMP6:%.*]] = inttoptr i64 [[TMP5]] to ptr // CHECK-BOTHAUTH-NEXT: [[VBASE_OFFSET_PTR:%.*]] = getelementptr i8, ptr [[TMP6]], i64 -32 // CHECK-BOTHAUTH-NEXT: [[VBASE_OFFSET:%.*]] = load i64, ptr [[VBASE_OFFSET_PTR]], align 8 @@ -554,7 +554,7 @@ const void *d(D *o) { // CHECK-BOTHAUTH-NEXT: [[TMP7:%.*]] = ptrtoint ptr [[CAST_RESULT]] to i64 // CHECK-BOTHAUTH-NEXT: [[TMP8:%.*]] = call i64 @llvm.ptrauth.blend(i64 [[TMP7]], i64 48388) // CHECK-BOTHAUTH-NEXT: [[TMP9:%.*]] = ptrtoint ptr [[VTABLE1]] to i64 -// CHECK-BOTHAUTH-NEXT: [[TMP10:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[TMP9]], i32 2, i64 [[TMP8]]) +// CHECK-BOTHAUTH-NEXT: [[TMP10:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[TMP9]]) [ "ptrauth"(i64 2, i64 [[TMP8]]) ] // CHECK-BOTHAUTH-NEXT: [[TMP11:%.*]] = inttoptr i64 [[TMP10]] to ptr // CHECK-BOTHAUTH-NEXT: [[TMP12:%.*]] = load volatile i8, ptr [[TMP11]], align 8 // CHECK-BOTHAUTH-NEXT: ret ptr [[TMP11]] @@ -581,7 +581,7 @@ const void *d_as_A(D *o) { // CHECK-TYPEAUTH-NEXT: [[TMP0:%.*]] = load ptr, ptr [[O_ADDR]], align 8, !tbaa [[TBAA17]] // CHECK-TYPEAUTH-NEXT: [[VTABLE:%.*]] = load ptr, ptr [[TMP0]], align 8, !tbaa [[TBAA9]] // CHECK-TYPEAUTH-NEXT: [[TMP1:%.*]] = ptrtoint ptr [[VTABLE]] to i64 -// CHECK-TYPEAUTH-NEXT: [[TMP2:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[TMP1]], i32 2, i64 48388) +// CHECK-TYPEAUTH-NEXT: [[TMP2:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[TMP1]]) [ "ptrauth"(i64 2, i64 48388) ] // CHECK-TYPEAUTH-NEXT: [[TMP3:%.*]] = inttoptr i64 [[TMP2]] to ptr // CHECK-TYPEAUTH-NEXT: [[TMP4:%.*]] = load volatile i8, ptr [[TMP3]], align 8 // CHECK-TYPEAUTH-NEXT: ret ptr [[TMP3]] @@ -595,7 +595,7 @@ const void *d_as_A(D *o) { // CHECK-ADDRESSAUTH-NEXT: [[VTABLE:%.*]] = load ptr, ptr [[TMP0]], align 8, !tbaa [[TBAA9]] // CHECK-ADDRESSAUTH-NEXT: [[TMP1:%.*]] = ptrtoint ptr [[TMP0]] to i64 // CHECK-ADDRESSAUTH-NEXT: [[TMP2:%.*]] = ptrtoint ptr [[VTABLE]] to i64 -// CHECK-ADDRESSAUTH-NEXT: [[TMP3:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[TMP2]], i32 2, i64 [[TMP1]]) +// CHECK-ADDRESSAUTH-NEXT: [[TMP3:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[TMP2]]) [ "ptrauth"(i64 2, i64 [[TMP1]]) ] // CHECK-ADDRESSAUTH-NEXT: [[TMP4:%.*]] = inttoptr i64 [[TMP3]] to ptr // CHECK-ADDRESSAUTH-NEXT: [[TMP5:%.*]] = load volatile i8, ptr [[TMP4]], align 8 // CHECK-ADDRESSAUTH-NEXT: ret ptr [[TMP4]] @@ -610,7 +610,7 @@ const void *d_as_A(D *o) { // CHECK-BOTHAUTH-NEXT: [[TMP1:%.*]] = ptrtoint ptr [[TMP0]] to i64 // CHECK-BOTHAUTH-NEXT: [[TMP2:%.*]] = call i64 @llvm.ptrauth.blend(i64 [[TMP1]], i64 48388) // CHECK-BOTHAUTH-NEXT: [[TMP3:%.*]] = ptrtoint ptr [[VTABLE]] to i64 -// CHECK-BOTHAUTH-NEXT: [[TMP4:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[TMP3]], i32 2, i64 [[TMP2]]) +// CHECK-BOTHAUTH-NEXT: [[TMP4:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[TMP3]]) [ "ptrauth"(i64 2, i64 [[TMP2]]) ] // CHECK-BOTHAUTH-NEXT: [[TMP5:%.*]] = inttoptr i64 [[TMP4]] to ptr // CHECK-BOTHAUTH-NEXT: [[TMP6:%.*]] = load volatile i8, ptr [[TMP5]], align 8 // CHECK-BOTHAUTH-NEXT: ret ptr [[TMP5]] @@ -651,7 +651,7 @@ const void *e(E *o) { // CHECK-TYPEAUTH-NEXT: [[CAST_RESULT:%.*]] = phi ptr [ [[ADD_PTR]], %[[CAST_NOTNULL]] ], [ null, %[[ENTRY]] ] // CHECK-TYPEAUTH-NEXT: [[VTABLE:%.*]] = load ptr, ptr [[CAST_RESULT]], align 8, !tbaa [[TBAA9]] // CHECK-TYPEAUTH-NEXT: [[TMP2:%.*]] = ptrtoint ptr [[VTABLE]] to i64 -// CHECK-TYPEAUTH-NEXT: [[TMP3:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[TMP2]], i32 2, i64 48388) +// CHECK-TYPEAUTH-NEXT: [[TMP3:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[TMP2]]) [ "ptrauth"(i64 2, i64 48388) ] // CHECK-TYPEAUTH-NEXT: [[TMP4:%.*]] = inttoptr i64 [[TMP3]] to ptr // CHECK-TYPEAUTH-NEXT: [[TMP5:%.*]] = load volatile i8, ptr [[TMP4]], align 8 // CHECK-TYPEAUTH-NEXT: ret ptr [[TMP4]] @@ -672,7 +672,7 @@ const void *e(E *o) { // CHECK-ADDRESSAUTH-NEXT: [[VTABLE:%.*]] = load ptr, ptr [[CAST_RESULT]], align 8, !tbaa [[TBAA9]] // CHECK-ADDRESSAUTH-NEXT: [[TMP2:%.*]] = ptrtoint ptr [[CAST_RESULT]] to i64 // CHECK-ADDRESSAUTH-NEXT: [[TMP3:%.*]] = ptrtoint ptr [[VTABLE]] to i64 -// CHECK-ADDRESSAUTH-NEXT: [[TMP4:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[TMP3]], i32 2, i64 [[TMP2]]) +// CHECK-ADDRESSAUTH-NEXT: [[TMP4:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[TMP3]]) [ "ptrauth"(i64 2, i64 [[TMP2]]) ] // CHECK-ADDRESSAUTH-NEXT: [[TMP5:%.*]] = inttoptr i64 [[TMP4]] to ptr // CHECK-ADDRESSAUTH-NEXT: [[TMP6:%.*]] = load volatile i8, ptr [[TMP5]], align 8 // CHECK-ADDRESSAUTH-NEXT: ret ptr [[TMP5]] @@ -694,7 +694,7 @@ const void *e(E *o) { // CHECK-BOTHAUTH-NEXT: [[TMP2:%.*]] = ptrtoint ptr [[CAST_RESULT]] to i64 // CHECK-BOTHAUTH-NEXT: [[TMP3:%.*]] = call i64 @llvm.ptrauth.blend(i64 [[TMP2]], i64 48388) // CHECK-BOTHAUTH-NEXT: [[TMP4:%.*]] = ptrtoint ptr [[VTABLE]] to i64 -// CHECK-BOTHAUTH-NEXT: [[TMP5:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[TMP4]], i32 2, i64 [[TMP3]]) +// CHECK-BOTHAUTH-NEXT: [[TMP5:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[TMP4]]) [ "ptrauth"(i64 2, i64 [[TMP3]]) ] // CHECK-BOTHAUTH-NEXT: [[TMP6:%.*]] = inttoptr i64 [[TMP5]] to ptr // CHECK-BOTHAUTH-NEXT: [[TMP7:%.*]] = load volatile i8, ptr [[TMP6]], align 8 // CHECK-BOTHAUTH-NEXT: ret ptr [[TMP6]] @@ -721,7 +721,7 @@ const void *e_as_B(E *o) { // CHECK-TYPEAUTH-NEXT: [[TMP0:%.*]] = load ptr, ptr [[O_ADDR]], align 8, !tbaa [[TBAA17]] // CHECK-TYPEAUTH-NEXT: [[VTABLE:%.*]] = load ptr, ptr [[TMP0]], align 8, !tbaa [[TBAA9]] // CHECK-TYPEAUTH-NEXT: [[TMP1:%.*]] = ptrtoint ptr [[VTABLE]] to i64 -// CHECK-TYPEAUTH-NEXT: [[TMP2:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[TMP1]], i32 2, i64 48388) +// CHECK-TYPEAUTH-NEXT: [[TMP2:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[TMP1]]) [ "ptrauth"(i64 2, i64 48388) ] // CHECK-TYPEAUTH-NEXT: [[TMP3:%.*]] = inttoptr i64 [[TMP2]] to ptr // CHECK-TYPEAUTH-NEXT: [[TMP4:%.*]] = load volatile i8, ptr [[TMP3]], align 8 // CHECK-TYPEAUTH-NEXT: ret ptr [[TMP3]] @@ -735,7 +735,7 @@ const void *e_as_B(E *o) { // CHECK-ADDRESSAUTH-NEXT: [[VTABLE:%.*]] = load ptr, ptr [[TMP0]], align 8, !tbaa [[TBAA9]] // CHECK-ADDRESSAUTH-NEXT: [[TMP1:%.*]] = ptrtoint ptr [[TMP0]] to i64 // CHECK-ADDRESSAUTH-NEXT: [[TMP2:%.*]] = ptrtoint ptr [[VTABLE]] to i64 -// CHECK-ADDRESSAUTH-NEXT: [[TMP3:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[TMP2]], i32 2, i64 [[TMP1]]) +// CHECK-ADDRESSAUTH-NEXT: [[TMP3:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[TMP2]]) [ "ptrauth"(i64 2, i64 [[TMP1]]) ] // CHECK-ADDRESSAUTH-NEXT: [[TMP4:%.*]] = inttoptr i64 [[TMP3]] to ptr // CHECK-ADDRESSAUTH-NEXT: [[TMP5:%.*]] = load volatile i8, ptr [[TMP4]], align 8 // CHECK-ADDRESSAUTH-NEXT: ret ptr [[TMP4]] @@ -750,7 +750,7 @@ const void *e_as_B(E *o) { // CHECK-BOTHAUTH-NEXT: [[TMP1:%.*]] = ptrtoint ptr [[TMP0]] to i64 // CHECK-BOTHAUTH-NEXT: [[TMP2:%.*]] = call i64 @llvm.ptrauth.blend(i64 [[TMP1]], i64 48388) // CHECK-BOTHAUTH-NEXT: [[TMP3:%.*]] = ptrtoint ptr [[VTABLE]] to i64 -// CHECK-BOTHAUTH-NEXT: [[TMP4:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[TMP3]], i32 2, i64 [[TMP2]]) +// CHECK-BOTHAUTH-NEXT: [[TMP4:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[TMP3]]) [ "ptrauth"(i64 2, i64 [[TMP2]]) ] // CHECK-BOTHAUTH-NEXT: [[TMP5:%.*]] = inttoptr i64 [[TMP4]] to ptr // CHECK-BOTHAUTH-NEXT: [[TMP6:%.*]] = load volatile i8, ptr [[TMP5]], align 8 // CHECK-BOTHAUTH-NEXT: ret ptr [[TMP5]] @@ -777,7 +777,7 @@ const void *e_as_D(E *o) { // CHECK-TYPEAUTH-NEXT: [[TMP0:%.*]] = load ptr, ptr [[AARRAY_ADDR]], align 8, !tbaa [[TBAA6]] // CHECK-TYPEAUTH-NEXT: [[VTABLE:%.*]] = load ptr, ptr [[TMP0]], align 8, !tbaa [[TBAA9]] // CHECK-TYPEAUTH-NEXT: [[TMP1:%.*]] = ptrtoint ptr [[VTABLE]] to i64 -// CHECK-TYPEAUTH-NEXT: [[TMP2:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[TMP1]], i32 2, i64 48388) +// CHECK-TYPEAUTH-NEXT: [[TMP2:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[TMP1]]) [ "ptrauth"(i64 2, i64 48388) ] // CHECK-TYPEAUTH-NEXT: [[TMP3:%.*]] = inttoptr i64 [[TMP2]] to ptr // CHECK-TYPEAUTH-NEXT: [[TMP4:%.*]] = load volatile i8, ptr [[TMP3]], align 8 // CHECK-TYPEAUTH-NEXT: ret ptr [[TMP3]] @@ -791,7 +791,7 @@ const void *e_as_D(E *o) { // CHECK-ADDRESSAUTH-NEXT: [[VTABLE:%.*]] = load ptr, ptr [[TMP0]], align 8, !tbaa [[TBAA9]] // CHECK-ADDRESSAUTH-NEXT: [[TMP1:%.*]] = ptrtoint ptr [[TMP0]] to i64 // CHECK-ADDRESSAUTH-NEXT: [[TMP2:%.*]] = ptrtoint ptr [[VTABLE]] to i64 -// CHECK-ADDRESSAUTH-NEXT: [[TMP3:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[TMP2]], i32 2, i64 [[TMP1]]) +// CHECK-ADDRESSAUTH-NEXT: [[TMP3:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[TMP2]]) [ "ptrauth"(i64 2, i64 [[TMP1]]) ] // CHECK-ADDRESSAUTH-NEXT: [[TMP4:%.*]] = inttoptr i64 [[TMP3]] to ptr // CHECK-ADDRESSAUTH-NEXT: [[TMP5:%.*]] = load volatile i8, ptr [[TMP4]], align 8 // CHECK-ADDRESSAUTH-NEXT: ret ptr [[TMP4]] @@ -806,7 +806,7 @@ const void *e_as_D(E *o) { // CHECK-BOTHAUTH-NEXT: [[TMP1:%.*]] = ptrtoint ptr [[TMP0]] to i64 // CHECK-BOTHAUTH-NEXT: [[TMP2:%.*]] = call i64 @llvm.ptrauth.blend(i64 [[TMP1]], i64 48388) // CHECK-BOTHAUTH-NEXT: [[TMP3:%.*]] = ptrtoint ptr [[VTABLE]] to i64 -// CHECK-BOTHAUTH-NEXT: [[TMP4:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[TMP3]], i32 2, i64 [[TMP2]]) +// CHECK-BOTHAUTH-NEXT: [[TMP4:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[TMP3]]) [ "ptrauth"(i64 2, i64 [[TMP2]]) ] // CHECK-BOTHAUTH-NEXT: [[TMP5:%.*]] = inttoptr i64 [[TMP4]] to ptr // CHECK-BOTHAUTH-NEXT: [[TMP6:%.*]] = load volatile i8, ptr [[TMP5]], align 8 // CHECK-BOTHAUTH-NEXT: ret ptr [[TMP5]] @@ -836,7 +836,7 @@ extern "C" const void *aArrayParameter(A aArray[]) { // CHECK-TYPEAUTH-NEXT: [[ARRAYDECAY:%.*]] = getelementptr inbounds [1 x %"struct.test1::A"], ptr [[ARRAY]], i64 0, i64 0 // CHECK-TYPEAUTH-NEXT: [[VTABLE:%.*]] = load ptr, ptr [[ARRAYDECAY]], align 8, !tbaa [[TBAA9]] // CHECK-TYPEAUTH-NEXT: [[TMP0:%.*]] = ptrtoint ptr [[VTABLE]] to i64 -// CHECK-TYPEAUTH-NEXT: [[TMP1:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[TMP0]], i32 2, i64 48388) +// CHECK-TYPEAUTH-NEXT: [[TMP1:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[TMP0]]) [ "ptrauth"(i64 2, i64 48388) ] // CHECK-TYPEAUTH-NEXT: [[TMP2:%.*]] = inttoptr i64 [[TMP1]] to ptr // CHECK-TYPEAUTH-NEXT: [[TMP3:%.*]] = load volatile i8, ptr [[TMP2]], align 8 // CHECK-TYPEAUTH-NEXT: call void @llvm.lifetime.end.p0(ptr [[ARRAY]]) #[[ATTR7]] @@ -852,7 +852,7 @@ extern "C" const void *aArrayParameter(A aArray[]) { // CHECK-ADDRESSAUTH-NEXT: [[VTABLE:%.*]] = load ptr, ptr [[ARRAYDECAY]], align 8, !tbaa [[TBAA9]] // CHECK-ADDRESSAUTH-NEXT: [[TMP0:%.*]] = ptrtoint ptr [[ARRAYDECAY]] to i64 // CHECK-ADDRESSAUTH-NEXT: [[TMP1:%.*]] = ptrtoint ptr [[VTABLE]] to i64 -// CHECK-ADDRESSAUTH-NEXT: [[TMP2:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[TMP1]], i32 2, i64 [[TMP0]]) +// CHECK-ADDRESSAUTH-NEXT: [[TMP2:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[TMP1]]) [ "ptrauth"(i64 2, i64 [[TMP0]]) ] // CHECK-ADDRESSAUTH-NEXT: [[TMP3:%.*]] = inttoptr i64 [[TMP2]] to ptr // CHECK-ADDRESSAUTH-NEXT: [[TMP4:%.*]] = load volatile i8, ptr [[TMP3]], align 8 // CHECK-ADDRESSAUTH-NEXT: call void @llvm.lifetime.end.p0(ptr [[ARRAY]]) #[[ATTR7]] @@ -869,7 +869,7 @@ extern "C" const void *aArrayParameter(A aArray[]) { // CHECK-BOTHAUTH-NEXT: [[TMP0:%.*]] = ptrtoint ptr [[ARRAYDECAY]] to i64 // CHECK-BOTHAUTH-NEXT: [[TMP1:%.*]] = call i64 @llvm.ptrauth.blend(i64 [[TMP0]], i64 48388) // CHECK-BOTHAUTH-NEXT: [[TMP2:%.*]] = ptrtoint ptr [[VTABLE]] to i64 -// CHECK-BOTHAUTH-NEXT: [[TMP3:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[TMP2]], i32 2, i64 [[TMP1]]) +// CHECK-BOTHAUTH-NEXT: [[TMP3:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[TMP2]]) [ "ptrauth"(i64 2, i64 [[TMP1]]) ] // CHECK-BOTHAUTH-NEXT: [[TMP4:%.*]] = inttoptr i64 [[TMP3]] to ptr // CHECK-BOTHAUTH-NEXT: [[TMP5:%.*]] = load volatile i8, ptr [[TMP4]], align 8 // CHECK-BOTHAUTH-NEXT: call void @llvm.lifetime.end.p0(ptr [[ARRAY]]) #[[ATTR7]] @@ -1018,7 +1018,7 @@ extern "C" const void *aArrayLocal() { // CHECK-TYPEAUTH: [[CAST_NOTNULL9]]: // CHECK-TYPEAUTH-NEXT: [[VTABLE:%.*]] = load ptr, ptr [[DINSTANCE]], align 8, !tbaa [[TBAA9]] // CHECK-TYPEAUTH-NEXT: [[TMP2:%.*]] = ptrtoint ptr [[VTABLE]] to i64 -// CHECK-TYPEAUTH-NEXT: [[TMP3:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[TMP2]], i32 2, i64 48388) +// CHECK-TYPEAUTH-NEXT: [[TMP3:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[TMP2]]) [ "ptrauth"(i64 2, i64 48388) ] // CHECK-TYPEAUTH-NEXT: [[TMP4:%.*]] = inttoptr i64 [[TMP3]] to ptr // CHECK-TYPEAUTH-NEXT: [[VBASE_OFFSET_PTR:%.*]] = getelementptr i8, ptr [[TMP4]], i64 -32 // CHECK-TYPEAUTH-NEXT: [[VBASE_OFFSET:%.*]] = load i64, ptr [[VBASE_OFFSET_PTR]], align 8 @@ -1032,7 +1032,7 @@ extern "C" const void *aArrayLocal() { // CHECK-TYPEAUTH: [[CAST_NOTNULL14]]: // CHECK-TYPEAUTH-NEXT: [[VTABLE15:%.*]] = load ptr, ptr [[EINSTANCE]], align 8, !tbaa [[TBAA9]] // CHECK-TYPEAUTH-NEXT: [[TMP6:%.*]] = ptrtoint ptr [[VTABLE15]] to i64 -// CHECK-TYPEAUTH-NEXT: [[TMP7:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[TMP6]], i32 2, i64 48388) +// CHECK-TYPEAUTH-NEXT: [[TMP7:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[TMP6]]) [ "ptrauth"(i64 2, i64 48388) ] // CHECK-TYPEAUTH-NEXT: [[TMP8:%.*]] = inttoptr i64 [[TMP7]] to ptr // CHECK-TYPEAUTH-NEXT: [[VBASE_OFFSET_PTR16:%.*]] = getelementptr i8, ptr [[TMP8]], i64 -32 // CHECK-TYPEAUTH-NEXT: [[VBASE_OFFSET17:%.*]] = load i64, ptr [[VBASE_OFFSET_PTR16]], align 8 @@ -1080,7 +1080,7 @@ extern "C" const void *aArrayLocal() { // CHECK-TYPEAUTH-NEXT: [[ARRAYDECAY:%.*]] = getelementptr inbounds [1 x %"struct.test1::E"], ptr [[EARRAY]], i64 0, i64 0 // CHECK-TYPEAUTH-NEXT: [[VTABLE49:%.*]] = load ptr, ptr [[ARRAYDECAY]], align 8, !tbaa [[TBAA9]] // CHECK-TYPEAUTH-NEXT: [[TMP12:%.*]] = ptrtoint ptr [[VTABLE49]] to i64 -// CHECK-TYPEAUTH-NEXT: [[TMP13:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[TMP12]], i32 2, i64 48388) +// CHECK-TYPEAUTH-NEXT: [[TMP13:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[TMP12]]) [ "ptrauth"(i64 2, i64 48388) ] // CHECK-TYPEAUTH-NEXT: [[TMP14:%.*]] = inttoptr i64 [[TMP13]] to ptr // CHECK-TYPEAUTH-NEXT: [[TMP15:%.*]] = load volatile i8, ptr [[TMP14]], align 8 // CHECK-TYPEAUTH-NEXT: call void @llvm.lifetime.end.p0(ptr [[EARRAY]]) #[[ATTR7]] @@ -1129,7 +1129,7 @@ extern "C" const void *aArrayLocal() { // CHECK-ADDRESSAUTH-NEXT: [[VTABLE:%.*]] = load ptr, ptr [[DINSTANCE]], align 8, !tbaa [[TBAA9]] // CHECK-ADDRESSAUTH-NEXT: [[TMP2:%.*]] = ptrtoint ptr [[DINSTANCE]] to i64 // CHECK-ADDRESSAUTH-NEXT: [[TMP3:%.*]] = ptrtoint ptr [[VTABLE]] to i64 -// CHECK-ADDRESSAUTH-NEXT: [[TMP4:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[TMP3]], i32 2, i64 [[TMP2]]) +// CHECK-ADDRESSAUTH-NEXT: [[TMP4:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[TMP3]]) [ "ptrauth"(i64 2, i64 [[TMP2]]) ] // CHECK-ADDRESSAUTH-NEXT: [[TMP5:%.*]] = inttoptr i64 [[TMP4]] to ptr // CHECK-ADDRESSAUTH-NEXT: [[VBASE_OFFSET_PTR:%.*]] = getelementptr i8, ptr [[TMP5]], i64 -32 // CHECK-ADDRESSAUTH-NEXT: [[VBASE_OFFSET:%.*]] = load i64, ptr [[VBASE_OFFSET_PTR]], align 8 @@ -1144,7 +1144,7 @@ extern "C" const void *aArrayLocal() { // CHECK-ADDRESSAUTH-NEXT: [[VTABLE15:%.*]] = load ptr, ptr [[EINSTANCE]], align 8, !tbaa [[TBAA9]] // CHECK-ADDRESSAUTH-NEXT: [[TMP7:%.*]] = ptrtoint ptr [[EINSTANCE]] to i64 // CHECK-ADDRESSAUTH-NEXT: [[TMP8:%.*]] = ptrtoint ptr [[VTABLE15]] to i64 -// CHECK-ADDRESSAUTH-NEXT: [[TMP9:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[TMP8]], i32 2, i64 [[TMP7]]) +// CHECK-ADDRESSAUTH-NEXT: [[TMP9:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[TMP8]]) [ "ptrauth"(i64 2, i64 [[TMP7]]) ] // CHECK-ADDRESSAUTH-NEXT: [[TMP10:%.*]] = inttoptr i64 [[TMP9]] to ptr // CHECK-ADDRESSAUTH-NEXT: [[VBASE_OFFSET_PTR16:%.*]] = getelementptr i8, ptr [[TMP10]], i64 -32 // CHECK-ADDRESSAUTH-NEXT: [[VBASE_OFFSET17:%.*]] = load i64, ptr [[VBASE_OFFSET_PTR16]], align 8 @@ -1193,7 +1193,7 @@ extern "C" const void *aArrayLocal() { // CHECK-ADDRESSAUTH-NEXT: [[VTABLE49:%.*]] = load ptr, ptr [[ARRAYDECAY]], align 8, !tbaa [[TBAA9]] // CHECK-ADDRESSAUTH-NEXT: [[TMP14:%.*]] = ptrtoint ptr [[ARRAYDECAY]] to i64 // CHECK-ADDRESSAUTH-NEXT: [[TMP15:%.*]] = ptrtoint ptr [[VTABLE49]] to i64 -// CHECK-ADDRESSAUTH-NEXT: [[TMP16:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[TMP15]], i32 2, i64 [[TMP14]]) +// CHECK-ADDRESSAUTH-NEXT: [[TMP16:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[TMP15]]) [ "ptrauth"(i64 2, i64 [[TMP14]]) ] // CHECK-ADDRESSAUTH-NEXT: [[TMP17:%.*]] = inttoptr i64 [[TMP16]] to ptr // CHECK-ADDRESSAUTH-NEXT: [[TMP18:%.*]] = load volatile i8, ptr [[TMP17]], align 8 // CHECK-ADDRESSAUTH-NEXT: call void @llvm.lifetime.end.p0(ptr [[EARRAY]]) #[[ATTR7]] @@ -1243,7 +1243,7 @@ extern "C" const void *aArrayLocal() { // CHECK-BOTHAUTH-NEXT: [[TMP2:%.*]] = ptrtoint ptr [[DINSTANCE]] to i64 // CHECK-BOTHAUTH-NEXT: [[TMP3:%.*]] = call i64 @llvm.ptrauth.blend(i64 [[TMP2]], i64 48388) // CHECK-BOTHAUTH-NEXT: [[TMP4:%.*]] = ptrtoint ptr [[VTABLE]] to i64 -// CHECK-BOTHAUTH-NEXT: [[TMP5:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[TMP4]], i32 2, i64 [[TMP3]]) +// CHECK-BOTHAUTH-NEXT: [[TMP5:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[TMP4]]) [ "ptrauth"(i64 2, i64 [[TMP3]]) ] // CHECK-BOTHAUTH-NEXT: [[TMP6:%.*]] = inttoptr i64 [[TMP5]] to ptr // CHECK-BOTHAUTH-NEXT: [[VBASE_OFFSET_PTR:%.*]] = getelementptr i8, ptr [[TMP6]], i64 -32 // CHECK-BOTHAUTH-NEXT: [[VBASE_OFFSET:%.*]] = load i64, ptr [[VBASE_OFFSET_PTR]], align 8 @@ -1259,7 +1259,7 @@ extern "C" const void *aArrayLocal() { // CHECK-BOTHAUTH-NEXT: [[TMP8:%.*]] = ptrtoint ptr [[EINSTANCE]] to i64 // CHECK-BOTHAUTH-NEXT: [[TMP9:%.*]] = call i64 @llvm.ptrauth.blend(i64 [[TMP8]], i64 48388) // CHECK-BOTHAUTH-NEXT: [[TMP10:%.*]] = ptrtoint ptr [[VTABLE15]] to i64 -// CHECK-BOTHAUTH-NEXT: [[TMP11:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[TMP10]], i32 2, i64 [[TMP9]]) +// CHECK-BOTHAUTH-NEXT: [[TMP11:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[TMP10]]) [ "ptrauth"(i64 2, i64 [[TMP9]]) ] // CHECK-BOTHAUTH-NEXT: [[TMP12:%.*]] = inttoptr i64 [[TMP11]] to ptr // CHECK-BOTHAUTH-NEXT: [[VBASE_OFFSET_PTR16:%.*]] = getelementptr i8, ptr [[TMP12]], i64 -32 // CHECK-BOTHAUTH-NEXT: [[VBASE_OFFSET17:%.*]] = load i64, ptr [[VBASE_OFFSET_PTR16]], align 8 @@ -1309,7 +1309,7 @@ extern "C" const void *aArrayLocal() { // CHECK-BOTHAUTH-NEXT: [[TMP16:%.*]] = ptrtoint ptr [[ARRAYDECAY]] to i64 // CHECK-BOTHAUTH-NEXT: [[TMP17:%.*]] = call i64 @llvm.ptrauth.blend(i64 [[TMP16]], i64 48388) // CHECK-BOTHAUTH-NEXT: [[TMP18:%.*]] = ptrtoint ptr [[VTABLE49]] to i64 -// CHECK-BOTHAUTH-NEXT: [[TMP19:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[TMP18]], i32 2, i64 [[TMP17]]) +// CHECK-BOTHAUTH-NEXT: [[TMP19:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[TMP18]]) [ "ptrauth"(i64 2, i64 [[TMP17]]) ] // CHECK-BOTHAUTH-NEXT: [[TMP20:%.*]] = inttoptr i64 [[TMP19]] to ptr // CHECK-BOTHAUTH-NEXT: [[TMP21:%.*]] = load volatile i8, ptr [[TMP20]], align 8 // CHECK-BOTHAUTH-NEXT: call void @llvm.lifetime.end.p0(ptr [[EARRAY]]) #[[ATTR7]] diff --git a/clang/test/CodeGenCXX/ptrauth-apple-kext-indirect-call-2.cpp b/clang/test/CodeGenCXX/ptrauth-apple-kext-indirect-call-2.cpp index c2f20d56b0a6b..fd6f543ffe18b 100644 --- a/clang/test/CodeGenCXX/ptrauth-apple-kext-indirect-call-2.cpp +++ b/clang/test/CodeGenCXX/ptrauth-apple-kext-indirect-call-2.cpp @@ -94,7 +94,7 @@ void Derived4::abc() {} void FUNC4(Derived4* p) { // CHECK: %[[VTABLE:[a-z]+]] = load ptr, ptr %{{.*}} // CHECK: %[[T0:[0-9]+]] = ptrtoint ptr %[[VTABLE]] to i64 -// CHECK: %[[T3:[0-9]+]] = call i64 @llvm.ptrauth.auth(i64 %[[T0]], i32 2, i64 0) +// CHECK: %[[T3:[0-9]+]] = call i64 @llvm.ptrauth.auth(i64 %[[T0]]) [ "ptrauth"(i64 2, i64 0) ] // CHECK: %[[T4:[0-9]+]] = inttoptr i64 %[[T3]] to ptr // CHECK: %[[VFN:[a-z]+]] = getelementptr inbounds ptr, ptr %[[T4]], i64 0 // CHECK: %[[T5:[0-9]+]] = load ptr, ptr %[[VFN]] diff --git a/clang/test/CodeGenCXX/ptrauth-dynamic-cast-exact.cpp b/clang/test/CodeGenCXX/ptrauth-dynamic-cast-exact.cpp index 2e51f1507e310..ef34aa4c649c7 100644 --- a/clang/test/CodeGenCXX/ptrauth-dynamic-cast-exact.cpp +++ b/clang/test/CodeGenCXX/ptrauth-dynamic-cast-exact.cpp @@ -49,7 +49,7 @@ C *exact_to_C(A *a) { // CHECK: [[VPTR_ADDRI:%.*]] = ptrtoint ptr %a to i64 // CHECK: [[VPTR_ADDR_DISC:%.*]] = tail call i64 @llvm.ptrauth.blend(i64 [[VPTR_ADDRI]], i64 62866) // CHECK: [[UNAUTHED_VPTRI:%.*]] = ptrtoint ptr [[UNAUTHED_VPTR]] to i64 - // CHECK: [[AUTHED_VPTRI:%.*]] = tail call i64 @llvm.ptrauth.auth(i64 [[UNAUTHED_VPTRI]], i32 2, i64 [[VPTR_ADDR_DISC]]) + // CHECK: [[AUTHED_VPTRI:%.*]] = tail call i64 @llvm.ptrauth.auth(i64 [[UNAUTHED_VPTRI]]) [ "ptrauth"(i64 2, i64 [[VPTR_ADDR_DISC]]) ] // CHECK: [[IS_EXPECTED:%.*]] = icmp eq i64 [[AUTHED_VPTRI]], ptrtoint (ptr getelementptr inbounds nuw inrange(-16, 24) (i8, ptr @_ZTV1C, i64 16) to i64) // CHECK: br i1 [[IS_EXPECTED]], label %dynamic_cast.end, label %dynamic_cast.null // CHECK: [[NULL_CHECKED_RESULT:%.*]] = phi ptr [ %a, %dynamic_cast.notnull ], [ null, %dynamic_cast.null ] @@ -64,7 +64,7 @@ D *exact_t_D(A *a) { // CHECK: [[SRC_VPTR_ADDRI:%.*]] = ptrtoint ptr %a to i64 // CHECK: [[SRC_VPTR_DISC:%.*]] = tail call i64 @llvm.ptrauth.blend(i64 [[SRC_VPTR_ADDRI]], i64 62866) // CHECK: [[SRC_UNAUTHED_VPTRI:%.*]] = ptrtoint ptr [[SRC_UNAUTHED_VPTR]] to i64 - // CHECK: [[SRC_AUTHED_VPTRI:%.*]] = tail call i64 @llvm.ptrauth.auth(i64 [[SRC_UNAUTHED_VPTRI]], i32 2, i64 [[SRC_VPTR_DISC]]) + // CHECK: [[SRC_AUTHED_VPTRI:%.*]] = tail call i64 @llvm.ptrauth.auth(i64 [[SRC_UNAUTHED_VPTRI]]) [ "ptrauth"(i64 2, i64 [[SRC_VPTR_DISC]]) ] // CHECK: [[SUCCESS:%.*]] = icmp eq i64 [[SRC_AUTHED_VPTRI]], ptrtoint (ptr getelementptr inbounds nuw inrange(-16, 16) (i8, ptr @_ZTV1D, i64 56) to i64) // CHECK: br i1 [[SUCCESS]], label %dynamic_cast.postauth.success, label %dynamic_cast.postauth.complete // CHECK: dynamic_cast.postauth.success: @@ -73,7 +73,7 @@ D *exact_t_D(A *a) { // CHECK: [[ADJUSTED_VPTR_ADDRI:%.*]] = ptrtoint ptr [[ADJUSTED_THIS]] to i64 // CHECK: [[ADJUSTED_VPTR_DISC:%.*]] = tail call i64 @llvm.ptrauth.blend(i64 [[ADJUSTED_VPTR_ADDRI]], i64 28965) // CHECK: [[ADJUSTED_UNAUTHED_VPTRI:%.*]] = ptrtoint ptr [[ADJUSTED_UNAUTHED_VPTR]] to i64 - // CHECK: [[ADJUSTED_AUTHED_VPTRI:%.*]] = tail call i64 @llvm.ptrauth.auth(i64 [[ADJUSTED_UNAUTHED_VPTRI]], i32 2, i64 [[ADJUSTED_VPTR_DISC]]) + // CHECK: [[ADJUSTED_AUTHED_VPTRI:%.*]] = tail call i64 @llvm.ptrauth.auth(i64 [[ADJUSTED_UNAUTHED_VPTRI]]) [ "ptrauth"(i64 2, i64 [[ADJUSTED_VPTR_DISC]]) ] // CHECK: [[ADJUSTED_AUTHED_VPTR:%.*]] = inttoptr i64 [[ADJUSTED_AUTHED_VPTRI]] to ptr // CHECK: br label %dynamic_cast.postauth.complete // CHECK: dynamic_cast.postauth.complete: @@ -94,7 +94,7 @@ L *exact_multi(E *e) { // CHECK: [[THIS_ADDRI:%.*]] = ptrtoint ptr %e to i64 // CHECK: [[VTABLE_DISC:%.*]] = tail call i64 @llvm.ptrauth.blend(i64 [[THIS_ADDRI]], i64 12810) // CHECK: [[VTABLE_ADDRI:%.*]] = ptrtoint ptr [[VTABLE_ADDR]] to i64 - // CHECK: [[AUTHED_VTABLEI:%.*]] = tail call i64 @llvm.ptrauth.auth(i64 [[VTABLE_ADDRI]], i32 2, i64 [[VTABLE_DISC]]) + // CHECK: [[AUTHED_VTABLEI:%.*]] = tail call i64 @llvm.ptrauth.auth(i64 [[VTABLE_ADDRI]]) [ "ptrauth"(i64 2, i64 [[VTABLE_DISC]]) ] // CHECK: [[AUTHED_VTABLE:%.*]] = inttoptr i64 [[AUTHED_VTABLEI]] to ptr // CHECK: [[PRIMARY_BASE_OFFSET:%.*]] = getelementptr inbounds i8, ptr [[AUTHED_VTABLE]], i64 -16 // CHECK: %offset.to.top = load i64, ptr [[PRIMARY_BASE_OFFSET]] @@ -107,7 +107,7 @@ L *exact_multi(E *e) { // CHECK: dynamic_cast.postauth.success: // CHECK: [[ADJUSTED_THISI:%.*]] = ptrtoint ptr [[ADJUSTED_THIS]] to i64 // CHECK: [[DEST_DISC:%.*]] = tail call i64 @llvm.ptrauth.blend(i64 [[ADJUSTED_THISI]], i64 41434) - // CHECK: tail call i64 @llvm.ptrauth.auth(i64 [[ADJUSTED_THIS_VTABLEI]], i32 2, i64 [[DEST_DISC]]) + // CHECK: tail call i64 @llvm.ptrauth.auth(i64 [[ADJUSTED_THIS_VTABLEI]]) [ "ptrauth"(i64 2, i64 [[DEST_DISC]]) ] // CHECK: br label %dynamic_cast.postauth.complete // CHECK: dynamic_cast.postauth.complete: // CHECK: [[AUTHED_ADJUSTED_THIS:%.*]] = phi ptr [ [[ADJUSTED_THIS]], %dynamic_cast.postauth.success ], [ null, %dynamic_cast.notnull ] diff --git a/clang/test/CodeGenCXX/ptrauth-explicit-vtable-pointer-control.cpp b/clang/test/CodeGenCXX/ptrauth-explicit-vtable-pointer-control.cpp index e33525c1ec0f9..19b726d8f2386 100644 --- a/clang/test/CodeGenCXX/ptrauth-explicit-vtable-pointer-control.cpp +++ b/clang/test/CodeGenCXX/ptrauth-explicit-vtable-pointer-control.cpp @@ -153,19 +153,19 @@ int TVDisc_ExplicitTypeDiscrimination = ptrauth_string_discriminator("_ZTVN5test // CHECK: [[VTABLE:%.*]] = load ptr, ptr [[VTADDR]], align 8 // // NODISC: [[VTABLEI64:%.*]] = ptrtoint ptr [[VTABLE]] to i64 -// NODISC: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VTABLEI64]], i32 2, i64 0) +// NODISC: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VTABLEI64]]) [ "ptrauth"(i64 2, i64 0) ] // // TYPE: [[VTABLEI64:%.*]] = ptrtoint ptr [[VTABLE]] to i64 -// TYPE: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VTABLEI64]], i32 2, i64 [[DISC_DEFAULT]]) +// TYPE: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VTABLEI64]]) [ "ptrauth"(i64 2, i64 [[DISC_DEFAULT]]) ] // // ADDR: [[VTADDRI64:%.*]] = ptrtoint ptr [[VTADDR]] to i64 // ADDR: [[VTABLEI64:%.*]] = ptrtoint ptr [[VTABLE]] to i64 -// ADDR: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VTABLEI64]], i32 2, i64 [[VTADDRI64]]) +// ADDR: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VTABLEI64]]) [ "ptrauth"(i64 2, i64 [[VTADDRI64]]) ] // // BOTH: [[VTADDRI64:%.*]] = ptrtoint ptr [[VTADDR]] to i64 // BOTH: [[BLEND:%.*]] = call i64 @llvm.ptrauth.blend(i64 [[VTADDRI64]], i64 [[DISC_DEFAULT]]) // BOTH: [[VTABLEI64:%.*]] = ptrtoint ptr [[VTABLE]] to i64 -// BOTH: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VTABLEI64]], i32 2, i64 [[BLEND]]) +// BOTH: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VTABLEI64]]) [ "ptrauth"(i64 2, i64 [[BLEND]]) ] void test_default(NoExplicitAuth *a) { a->f(); } @@ -184,21 +184,21 @@ void test_disabled(ExplicitlyDisableAuth *a) { // // NODISC: [[VTADDRI64:%.*]] = ptrtoint ptr [[VTADDR]] to i64 // NODISC: [[VTABLEI64:%.*]] = ptrtoint ptr [[VTABLE]] to i64 -// NODISC: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VTABLEI64]], i32 2, i64 [[VTADDRI64]]) +// NODISC: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VTABLEI64]]) [ "ptrauth"(i64 2, i64 [[VTADDRI64]]) ] // // TYPE: [[VTADDRI64:%.*]] = ptrtoint ptr [[VTADDR]] to i64 // TYPE: [[BLEND:%.*]] = call i64 @llvm.ptrauth.blend(i64 [[VTADDRI64]], i64 [[DISC_ADDR]]) // TYPE: [[VTABLEI64:%.*]] = ptrtoint ptr [[VTABLE]] to i64 -// TYPE: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VTABLEI64]], i32 2, i64 [[BLEND]]) +// TYPE: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VTABLEI64]]) [ "ptrauth"(i64 2, i64 [[BLEND]]) ] // // ADDR: [[VTADDRI64:%.*]] = ptrtoint ptr [[VTADDR]] to i64 // ADDR: [[VTABLEI64:%.*]] = ptrtoint ptr [[VTABLE]] to i64 -// ADDR: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VTABLEI64]], i32 2, i64 [[VTADDRI64]]) +// ADDR: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VTABLEI64]]) [ "ptrauth"(i64 2, i64 [[VTADDRI64]]) ] // // BOTH: [[VTADDRI64:%.*]] = ptrtoint ptr [[VTADDR]] to i64 // BOTH: [[BLEND:%.*]] = call i64 @llvm.ptrauth.blend(i64 [[VTADDRI64]], i64 [[DISC_ADDR]]) // BOTH: [[VTABLEI64:%.*]] = ptrtoint ptr [[VTABLE]] to i64 -// BOTH: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VTABLEI64]], i32 2, i64 [[BLEND]]) +// BOTH: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VTABLEI64]]) [ "ptrauth"(i64 2, i64 [[BLEND]]) ] void test_addr_disc(ExplicitAddressDiscrimination *a) { a->f(); } @@ -208,16 +208,16 @@ void test_addr_disc(ExplicitAddressDiscrimination *a) { // CHECK: [[VTABLE:%.*]] = load ptr, ptr [[VTADDR]], align 8 // // NODISC: [[VTABLEI64:%.*]] = ptrtoint ptr [[VTABLE]] to i64 -// NODISC: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VTABLEI64]], i32 2, i64 0) +// NODISC: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VTABLEI64]]) [ "ptrauth"(i64 2, i64 0) ] // // TYPE: [[VTABLEI64:%.*]] = ptrtoint ptr [[VTABLE]] to i64 -// TYPE: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VTABLEI64]], i32 2, i64 [[DISC_NO_ADDR]]) +// TYPE: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VTABLEI64]]) [ "ptrauth"(i64 2, i64 [[DISC_NO_ADDR]]) ] // // ADDR: [[VTABLEI64:%.*]] = ptrtoint ptr [[VTABLE]] to i64 -// ADDR: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VTABLEI64]], i32 2, i64 0) +// ADDR: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VTABLEI64]]) [ "ptrauth"(i64 2, i64 0) ] // // BOTH: [[VTABLEI64:%.*]] = ptrtoint ptr [[VTABLE]] to i64 -// BOTH: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VTABLEI64]], i32 2, i64 [[DISC_NO_ADDR]]) +// BOTH: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VTABLEI64]]) [ "ptrauth"(i64 2, i64 [[DISC_NO_ADDR]]) ] void test_no_addr_disc(ExplicitNoAddressDiscrimination *a) { a->f(); } @@ -227,18 +227,18 @@ void test_no_addr_disc(ExplicitNoAddressDiscrimination *a) { // CHECK: [[VTABLE:%.*]] = load ptr, ptr [[VTADDR]], align 8 // // NODISC: [[VTABLEI64:%.*]] = ptrtoint ptr [[VTABLE]] to i64 -// NODISC: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VTABLEI64]], i32 2, i64 0) +// NODISC: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VTABLEI64]]) [ "ptrauth"(i64 2, i64 0) ] // // TYPE: [[VTABLEI64:%.*]] = ptrtoint ptr [[VTABLE]] to i64 -// TYPE: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VTABLEI64]], i32 2, i64 0) +// TYPE: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VTABLEI64]]) [ "ptrauth"(i64 2, i64 0) ] // // ADDR: [[VTADDRI64:%.*]] = ptrtoint ptr [[VTADDR]] to i64 // ADDR: [[VTABLEI64:%.*]] = ptrtoint ptr [[VTABLE]] to i64 -// ADDR: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VTABLEI64]], i32 2, i64 [[VTADDRI64]]) +// ADDR: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VTABLEI64]]) [ "ptrauth"(i64 2, i64 [[VTADDRI64]]) ] // // BOTH: [[VTADDRI64:%.*]] = ptrtoint ptr [[VTADDR]] to i64 // BOTH: [[VTABLEI64:%.*]] = ptrtoint ptr [[VTABLE]] to i64 -// BOTH: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VTABLEI64]], i32 2, i64 [[VTADDRI64]]) +// BOTH: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VTABLEI64]]) [ "ptrauth"(i64 2, i64 [[VTADDRI64]]) ] void test_no_extra_disc(ExplicitNoExtraDiscrimination *a) { a->f(); } @@ -248,20 +248,20 @@ void test_no_extra_disc(ExplicitNoExtraDiscrimination *a) { // CHECK: [[VTABLE:%.*]] = load ptr, ptr [[VTADDR]], align 8 // // NODISC: [[VTABLEI64:%.*]] = ptrtoint ptr [[VTABLE]] to i64 -// NODISC: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VTABLEI64]], i32 2, i64 [[DISC_TYPE]]) +// NODISC: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VTABLEI64]]) [ "ptrauth"(i64 2, i64 [[DISC_TYPE]]) ] // // TYPE: [[VTABLEI64:%.*]] = ptrtoint ptr [[VTABLE]] to i64 -// TYPE: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VTABLEI64]], i32 2, i64 [[DISC_TYPE]]) +// TYPE: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VTABLEI64]]) [ "ptrauth"(i64 2, i64 [[DISC_TYPE]]) ] // // ADDR: [[VTADDRI64:%.*]] = ptrtoint ptr [[VTADDR]] to i64 // ADDR: [[BLEND:%.*]] = call i64 @llvm.ptrauth.blend(i64 [[VTADDRI64]], i64 [[DISC_TYPE]]) // ADDR: [[VTABLEI64:%.*]] = ptrtoint ptr [[VTABLE]] to i64 -// ADDR: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VTABLEI64]], i32 2, i64 [[BLEND]]) +// ADDR: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VTABLEI64]]) [ "ptrauth"(i64 2, i64 [[BLEND]]) ] // // BOTH: [[VTADDRI64:%.*]] = ptrtoint ptr [[VTADDR]] to i64 // BOTH: [[BLEND:%.*]] = call i64 @llvm.ptrauth.blend(i64 [[VTADDRI64]], i64 [[DISC_TYPE]]) // BOTH: [[VTABLEI64:%.*]] = ptrtoint ptr [[VTABLE]] to i64 -// BOTH: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VTABLEI64]], i32 2, i64 [[BLEND]]) +// BOTH: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VTABLEI64]]) [ "ptrauth"(i64 2, i64 [[BLEND]]) ] void test_type_disc(ExplicitTypeDiscrimination *a) { a->f(); } @@ -271,20 +271,20 @@ void test_type_disc(ExplicitTypeDiscrimination *a) { // CHECK: [[VTABLE:%.*]] = load ptr, ptr [[VTADDR]], align 8 // // NODISC: [[VTABLEI64:%.*]] = ptrtoint ptr [[VTABLE]] to i64 -// NODISC: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VTABLEI64]], i32 2, i64 42424) +// NODISC: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VTABLEI64]]) [ "ptrauth"(i64 2, i64 42424) ] // // TYPE: [[VTABLEI64:%.*]] = ptrtoint ptr [[VTABLE]] to i64 -// TYPE: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VTABLEI64]], i32 2, i64 42424) +// TYPE: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VTABLEI64]]) [ "ptrauth"(i64 2, i64 42424) ] // // ADDR: [[VTADDRI64:%.*]] = ptrtoint ptr [[VTADDR]] to i64 // ADDR: [[BLEND:%.*]] = call i64 @llvm.ptrauth.blend(i64 [[VTADDRI64]], i64 42424) // ADDR: [[VTABLEI64:%.*]] = ptrtoint ptr [[VTABLE]] to i64 -// ADDR: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VTABLEI64]], i32 2, i64 [[BLEND]]) +// ADDR: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VTABLEI64]]) [ "ptrauth"(i64 2, i64 [[BLEND]]) ] // // BOTH: [[VTADDRI64:%.*]] = ptrtoint ptr [[VTADDR]] to i64 // BOTH: [[BLEND:%.*]] = call i64 @llvm.ptrauth.blend(i64 [[VTADDRI64]], i64 42424) // BOTH: [[VTABLEI64:%.*]] = ptrtoint ptr [[VTABLE]] to i64 -// BOTH: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VTABLEI64]], i32 2, i64 [[BLEND]]) +// BOTH: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VTABLEI64]]) [ "ptrauth"(i64 2, i64 [[BLEND]]) ] void test_custom_disc(ExplicitCustomDiscrimination *a) { a->f(); } @@ -299,19 +299,19 @@ void test_custom_disc(ExplicitCustomDiscrimination *a) { // CHECK: [[VTABLE:%.*]] = load ptr, ptr [[VTADDR]], align 8 // // NODISC: [[VTABLEI64:%.*]] = ptrtoint ptr [[VTABLE]] to i64 -// NODISC: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VTABLEI64]], i32 2, i64 0) +// NODISC: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VTABLEI64]]) [ "ptrauth"(i64 2, i64 0) ] // // TYPE: [[VTABLEI64:%.*]] = ptrtoint ptr [[VTABLE]] to i64 -// TYPE: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VTABLEI64]], i32 2, i64 [[DISC_DEFAULT]]) +// TYPE: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VTABLEI64]]) [ "ptrauth"(i64 2, i64 [[DISC_DEFAULT]]) ] // // ADDR: [[VTADDRI64:%.*]] = ptrtoint ptr [[VTADDR]] to i64 // ADDR: [[VTABLEI64:%.*]] = ptrtoint ptr [[VTABLE]] to i64 -// ADDR: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VTABLEI64]], i32 2, i64 [[VTADDRI64]]) +// ADDR: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VTABLEI64]]) [ "ptrauth"(i64 2, i64 [[VTADDRI64]]) ] // // BOTH: [[VTADDRI64:%.*]] = ptrtoint ptr [[VTADDR]] to i64 // BOTH: [[BLEND:%.*]] = call i64 @llvm.ptrauth.blend(i64 [[VTADDRI64]], i64 [[DISC_DEFAULT]]) // BOTH: [[VTABLEI64:%.*]] = ptrtoint ptr [[VTABLE]] to i64 -// BOTH: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VTABLEI64]], i32 2, i64 [[BLEND]]) +// BOTH: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VTABLEI64]]) [ "ptrauth"(i64 2, i64 [[BLEND]]) ] void test_subclass_default(NoExplicitAuth *a) { make_subclass(a)->f(); } @@ -330,21 +330,21 @@ void test_subclass_disabled(ExplicitlyDisableAuth *a) { // // NODISC: [[VTADDRI64:%.*]] = ptrtoint ptr [[VTADDR]] to i64 // NODISC: [[VTABLEI64:%.*]] = ptrtoint ptr [[VTABLE]] to i64 -// NODISC: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VTABLEI64]], i32 2, i64 [[VTADDRI64]]) +// NODISC: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VTABLEI64]]) [ "ptrauth"(i64 2, i64 [[VTADDRI64]]) ] // // TYPE: [[VTADDRI64:%.*]] = ptrtoint ptr [[VTADDR]] to i64 // TYPE: [[BLEND:%.*]] = call i64 @llvm.ptrauth.blend(i64 [[VTADDRI64]], i64 [[DISC_ADDR]]) // TYPE: [[VTABLEI64:%.*]] = ptrtoint ptr [[VTABLE]] to i64 -// TYPE: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VTABLEI64]], i32 2, i64 [[BLEND]]) +// TYPE: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VTABLEI64]]) [ "ptrauth"(i64 2, i64 [[BLEND]]) ] // // ADDR: [[VTADDRI64:%.*]] = ptrtoint ptr [[VTADDR]] to i64 // ADDR: [[VTABLEI64:%.*]] = ptrtoint ptr [[VTABLE]] to i64 -// ADDR: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VTABLEI64]], i32 2, i64 [[VTADDRI64]]) +// ADDR: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VTABLEI64]]) [ "ptrauth"(i64 2, i64 [[VTADDRI64]]) ] // // BOTH: [[VTADDRI64:%.*]] = ptrtoint ptr [[VTADDR]] to i64 // BOTH: [[BLEND:%.*]] = call i64 @llvm.ptrauth.blend(i64 [[VTADDRI64]], i64 [[DISC_ADDR]]) // BOTH: [[VTABLEI64:%.*]] = ptrtoint ptr [[VTABLE]] to i64 -// BOTH: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VTABLEI64]], i32 2, i64 [[BLEND]]) +// BOTH: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VTABLEI64]]) [ "ptrauth"(i64 2, i64 [[BLEND]]) ] void test_subclass_addr_disc(ExplicitAddressDiscrimination *a) { make_subclass(a)->f(); } @@ -354,16 +354,16 @@ void test_subclass_addr_disc(ExplicitAddressDiscrimination *a) { // CHECK: [[VTABLE:%.*]] = load ptr, ptr [[VTADDR]], align 8 // // NODISC: [[VTABLEI64:%.*]] = ptrtoint ptr [[VTABLE]] to i64 -// NODISC: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VTABLEI64]], i32 2, i64 0) +// NODISC: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VTABLEI64]]) [ "ptrauth"(i64 2, i64 0) ] // // TYPE: [[VTABLEI64:%.*]] = ptrtoint ptr [[VTABLE]] to i64 -// TYPE: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VTABLEI64]], i32 2, i64 [[DISC_NO_ADDR]]) +// TYPE: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VTABLEI64]]) [ "ptrauth"(i64 2, i64 [[DISC_NO_ADDR]]) ] // // ADDR: [[VTABLEI64:%.*]] = ptrtoint ptr [[VTABLE]] to i64 -// ADDR: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VTABLEI64]], i32 2, i64 0) +// ADDR: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VTABLEI64]]) [ "ptrauth"(i64 2, i64 0) ] // // BOTH: [[VTABLEI64:%.*]] = ptrtoint ptr [[VTABLE]] to i64 -// BOTH: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VTABLEI64]], i32 2, i64 [[DISC_NO_ADDR]]) +// BOTH: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VTABLEI64]]) [ "ptrauth"(i64 2, i64 [[DISC_NO_ADDR]]) ] void test_subclass_no_addr_disc(ExplicitNoAddressDiscrimination *a) { make_subclass(a)->f(); } @@ -373,18 +373,18 @@ void test_subclass_no_addr_disc(ExplicitNoAddressDiscrimination *a) { // CHECK: [[VTABLE:%.*]] = load ptr, ptr [[VTADDR]], align 8 // // NODISC: [[VTABLEI64:%.*]] = ptrtoint ptr [[VTABLE]] to i64 -// NODISC: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VTABLEI64]], i32 2, i64 0) +// NODISC: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VTABLEI64]]) [ "ptrauth"(i64 2, i64 0) ] // // TYPE: [[VTABLEI64:%.*]] = ptrtoint ptr [[VTABLE]] to i64 -// TYPE: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VTABLEI64]], i32 2, i64 0) +// TYPE: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VTABLEI64]]) [ "ptrauth"(i64 2, i64 0) ] // // ADDR: [[VTADDRI64:%.*]] = ptrtoint ptr [[VTADDR]] to i64 // ADDR: [[VTABLEI64:%.*]] = ptrtoint ptr [[VTABLE]] to i64 -// ADDR: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VTABLEI64]], i32 2, i64 [[VTADDRI64]]) +// ADDR: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VTABLEI64]]) [ "ptrauth"(i64 2, i64 [[VTADDRI64]]) ] // // BOTH: [[VTADDRI64:%.*]] = ptrtoint ptr [[VTADDR]] to i64 // BOTH: [[VTABLEI64:%.*]] = ptrtoint ptr [[VTABLE]] to i64 -// BOTH: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VTABLEI64]], i32 2, i64 [[VTADDRI64]]) +// BOTH: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VTABLEI64]]) [ "ptrauth"(i64 2, i64 [[VTADDRI64]]) ] void test_subclass_no_extra_disc(ExplicitNoExtraDiscrimination *a) { make_subclass(a)->f(); } @@ -394,20 +394,20 @@ void test_subclass_no_extra_disc(ExplicitNoExtraDiscrimination *a) { // CHECK: [[VTABLE:%.*]] = load ptr, ptr [[VTADDR]], align 8 // // NODISC: [[VTABLEI64:%.*]] = ptrtoint ptr [[VTABLE]] to i64 -// NODISC: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VTABLEI64]], i32 2, i64 [[DISC_TYPE]]) +// NODISC: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VTABLEI64]]) [ "ptrauth"(i64 2, i64 [[DISC_TYPE]]) ] // // TYPE: [[VTABLEI64:%.*]] = ptrtoint ptr [[VTABLE]] to i64 -// TYPE: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VTABLEI64]], i32 2, i64 [[DISC_TYPE]]) +// TYPE: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VTABLEI64]]) [ "ptrauth"(i64 2, i64 [[DISC_TYPE]]) ] // // ADDR: [[VTADDRI64:%.*]] = ptrtoint ptr [[VTADDR]] to i64 // ADDR: [[BLEND:%.*]] = call i64 @llvm.ptrauth.blend(i64 [[VTADDRI64]], i64 [[DISC_TYPE]]) // ADDR: [[VTABLEI64:%.*]] = ptrtoint ptr [[VTABLE]] to i64 -// ADDR: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VTABLEI64]], i32 2, i64 [[BLEND]]) +// ADDR: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VTABLEI64]]) [ "ptrauth"(i64 2, i64 [[BLEND]]) ] // // BOTH: [[VTADDRI64:%.*]] = ptrtoint ptr [[VTADDR]] to i64 // BOTH: [[BLEND:%.*]] = call i64 @llvm.ptrauth.blend(i64 [[VTADDRI64]], i64 [[DISC_TYPE]]) // BOTH: [[VTABLEI64:%.*]] = ptrtoint ptr [[VTABLE]] to i64 -// BOTH: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VTABLEI64]], i32 2, i64 [[BLEND]]) +// BOTH: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VTABLEI64]]) [ "ptrauth"(i64 2, i64 [[BLEND]]) ] void test_subclass_type_disc(ExplicitTypeDiscrimination *a) { make_subclass(a)->f(); } @@ -417,20 +417,20 @@ void test_subclass_type_disc(ExplicitTypeDiscrimination *a) { // CHECK: [[VTABLE:%.*]] = load ptr, ptr [[VTADDR]], align 8 // // NODISC: [[VTABLEI64:%.*]] = ptrtoint ptr [[VTABLE]] to i64 -// NODISC: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VTABLEI64]], i32 2, i64 42424) +// NODISC: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VTABLEI64]]) [ "ptrauth"(i64 2, i64 42424) ] // // TYPE: [[VTABLEI64:%.*]] = ptrtoint ptr [[VTABLE]] to i64 -// TYPE: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VTABLEI64]], i32 2, i64 42424) +// TYPE: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VTABLEI64]]) [ "ptrauth"(i64 2, i64 42424) ] // // ADDR: [[VTADDRI64:%.*]] = ptrtoint ptr [[VTADDR]] to i64 // ADDR: [[BLEND:%.*]] = call i64 @llvm.ptrauth.blend(i64 [[VTADDRI64]], i64 42424) // ADDR: [[VTABLEI64:%.*]] = ptrtoint ptr [[VTABLE]] to i64 -// ADDR: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VTABLEI64]], i32 2, i64 [[BLEND]]) +// ADDR: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VTABLEI64]]) [ "ptrauth"(i64 2, i64 [[BLEND]]) ] // // BOTH: [[VTADDRI64:%.*]] = ptrtoint ptr [[VTADDR]] to i64 // BOTH: [[BLEND:%.*]] = call i64 @llvm.ptrauth.blend(i64 [[VTADDRI64]], i64 42424) // BOTH: [[VTABLEI64:%.*]] = ptrtoint ptr [[VTABLE]] to i64 -// BOTH: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VTABLEI64]], i32 2, i64 [[BLEND]]) +// BOTH: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VTABLEI64]]) [ "ptrauth"(i64 2, i64 [[BLEND]]) ] void test_subclass_custom_disc(ExplicitCustomDiscrimination *a) { make_subclass(a)->f(); } @@ -447,19 +447,19 @@ void test_subclass_custom_disc(ExplicitCustomDiscrimination *a) { // CHECK: [[VTABLE:%.*]] = load ptr, ptr [[VTADDR]], align 8 // // NODISC: [[VTABLEI64:%.*]] = ptrtoint ptr [[VTABLE]] to i64 -// NODISC: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VTABLEI64]], i32 2, i64 0) +// NODISC: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VTABLEI64]]) [ "ptrauth"(i64 2, i64 0) ] // // TYPE: [[VTABLEI64:%.*]] = ptrtoint ptr [[VTABLE]] to i64 -// TYPE: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VTABLEI64]], i32 2, i64 [[DISC_DEFAULT]]) +// TYPE: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VTABLEI64]]) [ "ptrauth"(i64 2, i64 [[DISC_DEFAULT]]) ] // // ADDR: [[VTADDRI64:%.*]] = ptrtoint ptr [[VTADDR]] to i64 // ADDR: [[VTABLEI64:%.*]] = ptrtoint ptr [[VTABLE]] to i64 -// ADDR: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VTABLEI64]], i32 2, i64 [[VTADDRI64]]) +// ADDR: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VTABLEI64]]) [ "ptrauth"(i64 2, i64 [[VTADDRI64]]) ] // // BOTH: [[VTADDRI64:%.*]] = ptrtoint ptr [[VTADDR]] to i64 // BOTH: [[BLEND:%.*]] = call i64 @llvm.ptrauth.blend(i64 [[VTADDRI64]], i64 [[DISC_DEFAULT]]) // BOTH: [[VTABLEI64:%.*]] = ptrtoint ptr [[VTABLE]] to i64 -// BOTH: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VTABLEI64]], i32 2, i64 [[BLEND]]) +// BOTH: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VTABLEI64]]) [ "ptrauth"(i64 2, i64 [[BLEND]]) ] void test_multiple_default(NoExplicitAuth *a) { make_multiple_primary(a)->f(); } @@ -479,20 +479,20 @@ void test_multiple_disabled(ExplicitlyDisableAuth *a) { // CHECK: [[VTABLE:%.*]] = load ptr, ptr [[VTADDR]], align 8 // // NODISC: [[VTABLEI64:%.*]] = ptrtoint ptr [[VTABLE]] to i64 -// NODISC: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VTABLEI64]], i32 2, i64 42424) +// NODISC: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VTABLEI64]]) [ "ptrauth"(i64 2, i64 42424) ] // // TYPE: [[VTABLEI64:%.*]] = ptrtoint ptr [[VTABLE]] to i64 -// TYPE: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VTABLEI64]], i32 2, i64 42424) +// TYPE: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VTABLEI64]]) [ "ptrauth"(i64 2, i64 42424) ] // // ADDR: [[VTADDRI64:%.*]] = ptrtoint ptr [[VTADDR]] to i64 // ADDR: [[BLEND:%.*]] = call i64 @llvm.ptrauth.blend(i64 [[VTADDRI64]], i64 42424) // ADDR: [[VTABLEI64:%.*]] = ptrtoint ptr [[VTABLE]] to i64 -// ADDR: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VTABLEI64]], i32 2, i64 [[BLEND]]) +// ADDR: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VTABLEI64]]) [ "ptrauth"(i64 2, i64 [[BLEND]]) ] // // BOTH: [[VTADDRI64:%.*]] = ptrtoint ptr [[VTADDR]] to i64 // BOTH: [[BLEND:%.*]] = call i64 @llvm.ptrauth.blend(i64 [[VTADDRI64]], i64 42424) // BOTH: [[VTABLEI64:%.*]] = ptrtoint ptr [[VTABLE]] to i64 -// BOTH: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VTABLEI64]], i32 2, i64 [[BLEND]]) +// BOTH: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VTABLEI64]]) [ "ptrauth"(i64 2, i64 [[BLEND]]) ] void test_multiple_custom_disc(ExplicitCustomDiscrimination *a) { make_multiple_primary(a)->f(); } @@ -508,19 +508,19 @@ void test_multiple_custom_disc(ExplicitCustomDiscrimination *a) { // CHECK: [[VTTABLE:%.*]] = load ptr, ptr [[VTTADDR]], align 8 // // NODISC: [[VTTABLEI64:%.*]] = ptrtoint ptr [[VTTABLE]] to i64 -// NODISC: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VTTABLEI64]], i32 2, i64 0) +// NODISC: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VTTABLEI64]]) [ "ptrauth"(i64 2, i64 0) ] // // TYPE: [[VTTABLEI64:%.*]] = ptrtoint ptr [[VTTABLE]] to i64 -// TYPE: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VTTABLEI64]], i32 2, i64 [[DISC_DEFAULT]]) +// TYPE: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VTTABLEI64]]) [ "ptrauth"(i64 2, i64 [[DISC_DEFAULT]]) ] // // ADDR: [[VTTADDRI64:%.*]] = ptrtoint ptr [[VTTADDR]] to i64 // ADDR: [[VTTABLEI64:%.*]] = ptrtoint ptr [[VTTABLE]] to i64 -// ADDR: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VTTABLEI64]], i32 2, i64 [[VTTADDRI64]]) +// ADDR: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VTTABLEI64]]) [ "ptrauth"(i64 2, i64 [[VTTADDRI64]]) ] // // BOTH: [[VTTADDRI64:%.*]] = ptrtoint ptr [[VTTADDR]] to i64 // BOTH: [[BLEND:%.*]] = call i64 @llvm.ptrauth.blend(i64 [[VTTADDRI64]], i64 [[DISC_DEFAULT]]) // BOTH: [[VTTABLEI64:%.*]] = ptrtoint ptr [[VTTABLE]] to i64 -// BOTH: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VTTABLEI64]], i32 2, i64 [[BLEND]]) +// BOTH: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VTTABLEI64]]) [ "ptrauth"(i64 2, i64 [[BLEND]]) ] // CHECK: [[AUTHEDPTR:%.*]] = inttoptr i64 [[AUTHED]] to ptr // CHECK: [[VBOFFPTR:%.*]] = getelementptr i8, ptr [[AUTHEDPTR]], i64 -48 @@ -529,19 +529,19 @@ void test_multiple_custom_disc(ExplicitCustomDiscrimination *a) { // CHECK: [[VTABLE:%.*]] = load ptr, ptr [[VTADDR]], align 8 // // NODISC: [[VTABLEI64:%.*]] = ptrtoint ptr [[VTABLE]] to i64 -// NODISC: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VTABLEI64]], i32 2, i64 0) +// NODISC: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VTABLEI64]]) [ "ptrauth"(i64 2, i64 0) ] // // TYPE: [[VTABLEI64:%.*]] = ptrtoint ptr [[VTABLE]] to i64 -// TYPE: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VTABLEI64]], i32 2, i64 [[DISC_DEFAULT]]) +// TYPE: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VTABLEI64]]) [ "ptrauth"(i64 2, i64 [[DISC_DEFAULT]]) ] // // ADDR: [[VTADDRI64:%.*]] = ptrtoint ptr [[VTADDR]] to i64 // ADDR: [[VTABLEI64:%.*]] = ptrtoint ptr [[VTABLE]] to i64 -// ADDR: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VTABLEI64]], i32 2, i64 [[VTADDRI64]]) +// ADDR: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VTABLEI64]]) [ "ptrauth"(i64 2, i64 [[VTADDRI64]]) ] // // BOTH: [[VTADDRI64:%.*]] = ptrtoint ptr [[VTADDR]] to i64 // BOTH: [[BLEND:%.*]] = call i64 @llvm.ptrauth.blend(i64 [[VTADDRI64]], i64 [[DISC_DEFAULT]]) // BOTH: [[VTABLEI64:%.*]] = ptrtoint ptr [[VTABLE]] to i64 -// BOTH: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VTABLEI64]], i32 2, i64 [[BLEND]]) +// BOTH: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VTABLEI64]]) [ "ptrauth"(i64 2, i64 [[BLEND]]) ] void test_virtual_default(NoExplicitAuth *a) { make_virtual_primary(a)->f(); } @@ -557,20 +557,20 @@ void test_virtual_disabled(ExplicitlyDisableAuth *a) { // CHECK: [[VTTABLE:%.*]] = load ptr, ptr [[VTTADDR]], align 8 // // NODISC: [[VTTABLEI64:%.*]] = ptrtoint ptr [[VTTABLE]] to i64 -// NODISC: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VTTABLEI64]], i32 2, i64 42424) +// NODISC: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VTTABLEI64]]) [ "ptrauth"(i64 2, i64 42424) ] // // TYPE: [[VTTABLEI64:%.*]] = ptrtoint ptr [[VTTABLE]] to i64 -// TYPE: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VTTABLEI64]], i32 2, i64 42424) +// TYPE: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VTTABLEI64]]) [ "ptrauth"(i64 2, i64 42424) ] // // ADDR: [[VTTADDRI64:%.*]] = ptrtoint ptr [[VTTADDR]] to i64 // ADDR: [[BLEND:%.*]] = call i64 @llvm.ptrauth.blend(i64 [[VTTADDRI64]], i64 42424) // ADDR: [[VTTABLEI64:%.*]] = ptrtoint ptr [[VTTABLE]] to i64 -// ADDR: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VTTABLEI64]], i32 2, i64 [[BLEND]]) +// ADDR: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VTTABLEI64]]) [ "ptrauth"(i64 2, i64 [[BLEND]]) ] // // BOTH: [[VTTADDRI64:%.*]] = ptrtoint ptr [[VTTADDR]] to i64 // BOTH: [[BLEND:%.*]] = call i64 @llvm.ptrauth.blend(i64 [[VTTADDRI64]], i64 42424) // BOTH: [[VTTABLEI64:%.*]] = ptrtoint ptr [[VTTABLE]] to i64 -// BOTH: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VTTABLEI64]], i32 2, i64 [[BLEND]]) +// BOTH: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VTTABLEI64]]) [ "ptrauth"(i64 2, i64 [[BLEND]]) ] // CHECK: [[AUTHEDPTR:%.*]] = inttoptr i64 [[AUTHED]] to ptr // CHECK: [[VBOFFPTR:%.*]] = getelementptr i8, ptr [[AUTHEDPTR]], i64 -48 @@ -579,20 +579,20 @@ void test_virtual_disabled(ExplicitlyDisableAuth *a) { // CHECK: [[VTABLE:%.*]] = load ptr, ptr [[VTADDR]], align 8 // // NODISC: [[VTABLEI64:%.*]] = ptrtoint ptr [[VTABLE]] to i64 -// NODISC: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VTABLEI64]], i32 2, i64 42424) +// NODISC: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VTABLEI64]]) [ "ptrauth"(i64 2, i64 42424) ] // // TYPE: [[VTABLEI64:%.*]] = ptrtoint ptr [[VTABLE]] to i64 -// TYPE: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VTABLEI64]], i32 2, i64 42424) +// TYPE: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VTABLEI64]]) [ "ptrauth"(i64 2, i64 42424) ] // // ADDR: [[VTADDRI64:%.*]] = ptrtoint ptr [[VTADDR]] to i64 // ADDR: [[BLEND:%.*]] = call i64 @llvm.ptrauth.blend(i64 [[VTADDRI64]], i64 42424) // ADDR: [[VTABLEI64:%.*]] = ptrtoint ptr [[VTABLE]] to i64 -// ADDR: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VTABLEI64]], i32 2, i64 [[BLEND]]) +// ADDR: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VTABLEI64]]) [ "ptrauth"(i64 2, i64 [[BLEND]]) ] // // BOTH: [[VTADDRI64:%.*]] = ptrtoint ptr [[VTADDR]] to i64 // BOTH: [[BLEND:%.*]] = call i64 @llvm.ptrauth.blend(i64 [[VTADDRI64]], i64 42424) // BOTH: [[VTABLEI64:%.*]] = ptrtoint ptr [[VTABLE]] to i64 -// BOTH: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VTABLEI64]], i32 2, i64 [[BLEND]]) +// BOTH: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VTABLEI64]]) [ "ptrauth"(i64 2, i64 [[BLEND]]) ] void test_virtual_custom_disc(ExplicitCustomDiscrimination *a) { make_virtual_primary(a)->f(); } diff --git a/clang/test/CodeGenCXX/ptrauth-member-function-pointer.cpp b/clang/test/CodeGenCXX/ptrauth-member-function-pointer.cpp index e9436f11b5106..4a5d32179e171 100644 --- a/clang/test/CodeGenCXX/ptrauth-member-function-pointer.cpp +++ b/clang/test/CodeGenCXX/ptrauth-member-function-pointer.cpp @@ -128,7 +128,7 @@ struct Class0 { // CHECK-NEXT: %[[V0:.*]] = load ptr, ptr %[[THIS_ADDR]], align 8 // CHECK-NEXT: %[[VTABLE:.*]] = load ptr, ptr %[[THIS1]], align 8 // CHECK-NEXT: %[[V2:.*]] = ptrtoint ptr %[[VTABLE]] to i64 -// CHECK-NEXT: %[[V3:.*]] = call i64 @llvm.ptrauth.auth(i64 %[[V2]], i32 2, i64 0) +// CHECK-NEXT: %[[V3:.*]] = call i64 @llvm.ptrauth.auth(i64 %[[V2]]) [ "ptrauth"(i64 2, i64 0) ] // CHECK-NEXT: %[[V4:.*]] = inttoptr i64 %[[V3]] to ptr // CHECK-NEXT: %[[VFN:.*]] = getelementptr inbounds ptr, ptr %[[V4]], i64 0 // CHECK-NEXT: %[[V5:.*]] = load ptr, ptr %[[VFN]], align 8 @@ -142,7 +142,7 @@ struct Class0 { // CHECK: load ptr, ptr %{{.*}}, align 8 // CHECK: %[[VTABLE:.*]] = load ptr, ptr %{{.*}}, align 8 // CHECK: %[[V2:.*]] = ptrtoint ptr %[[VTABLE]] to i64 -// CHECK: %[[V3:.*]] = call i64 @llvm.ptrauth.auth(i64 %[[V2]], i32 2, i64 0) +// CHECK: %[[V3:.*]] = call i64 @llvm.ptrauth.auth(i64 %[[V2]]) [ "ptrauth"(i64 2, i64 0) ] // CHECK: %[[V4:.*]] = inttoptr i64 %[[V3]] to ptr // CHECK: getelementptr inbounds ptr, ptr %[[V4]], i64 1 // CHECK: call i64 @llvm.ptrauth.blend(i64 %{{.*}}, i64 53007) @@ -157,7 +157,7 @@ struct Class0 { // CHECK-NEXT: %[[V2:.*]] = load i32, ptr %[[_ADDR]], align 4 // CHECK-NEXT: %[[VTABLE:.*]] = load ptr, ptr %[[THIS1]], align 8 // CHECK-NEXT: %[[V4:.*]] = ptrtoint ptr %[[VTABLE]] to i64 -// CHECK-NEXT: %[[V5:.*]] = call i64 @llvm.ptrauth.auth(i64 %[[V4]], i32 2, i64 0) +// CHECK-NEXT: %[[V5:.*]] = call i64 @llvm.ptrauth.auth(i64 %[[V4]]) [ "ptrauth"(i64 2, i64 0) ] // CHECK-NEXT: %[[V6:.*]] = inttoptr i64 %[[V5]] to ptr // CHECK-NEXT: %[[VFN:.*]] = getelementptr inbounds ptr, ptr %[[V6]], i64 2 // CHECK-NEXT: %[[V7:.*]] = load ptr, ptr %[[VFN]], align 8 @@ -173,7 +173,7 @@ struct Class0 { // CHECK: %[[V0:.*]] = load ptr, ptr %[[THIS_ADDR]], align 8 // CHECK: %[[VTABLE:.*]] = load ptr, ptr %[[THIS1]], align 8 // CHECK: %[[V1:.*]] = ptrtoint ptr %[[VTABLE]] to i64 -// CHECK: %[[V2:.*]] = call i64 @llvm.ptrauth.auth(i64 %[[V1]], i32 2, i64 0) +// CHECK: %[[V2:.*]] = call i64 @llvm.ptrauth.auth(i64 %[[V1]]) [ "ptrauth"(i64 2, i64 0) ] // CHECK: %[[V3:.*]] = inttoptr i64 %[[V2]] to ptr // CHECK: %[[VFN:.*]] = getelementptr inbounds ptr, ptr %[[V3]], i64 3 // CHECK: %[[V5:.*]] = ptrtoint ptr %[[VFN]] to i64 @@ -211,7 +211,7 @@ struct Class0 { // CHECK: %[[V0:.*]] = load ptr, ptr %[[THIS_ADDR]], align 8 // CHECK: %[[VTABLE:.*]] = load ptr, ptr %[[THIS1]], align 8 // CHECK: %[[V1:.*]] = ptrtoint ptr %[[VTABLE]] to i64 -// CHECK: %[[V2:.*]] = call i64 @llvm.ptrauth.auth(i64 %[[V1]], i32 2, i64 0) +// CHECK: %[[V2:.*]] = call i64 @llvm.ptrauth.auth(i64 %[[V1]]) [ "ptrauth"(i64 2, i64 0) ] // CHECK: %[[V3:.*]] = inttoptr i64 %[[V2]] to ptr // CHECK: getelementptr inbounds ptr, ptr %[[V3]], i64 0 @@ -222,7 +222,7 @@ struct Class0 { // CHECK: load ptr, ptr %[[THIS_ADDR]], align 8 // CHECK: %[[VTABLE:.*]] = load ptr, ptr %[[THIS1]], align 8 // CHECK: %[[V1:.*]] = ptrtoint ptr %[[VTABLE]] to i64 -// CHECK: %[[V2:.*]] = call i64 @llvm.ptrauth.auth(i64 %[[V1]], i32 2, i64 0) +// CHECK: %[[V2:.*]] = call i64 @llvm.ptrauth.auth(i64 %[[V1]]) [ "ptrauth"(i64 2, i64 0) ] // CHECK: %[[V3:.*]] = inttoptr i64 %[[V2]] to ptr // CHECK: getelementptr inbounds ptr, ptr %[[V3]], i64 3 @@ -281,7 +281,7 @@ void test0() { // CHECK: %[[VTABLE:.*]] = load ptr, ptr %[[V4]], align 8 // CHECK: %[[V7:.*]] = ptrtoint ptr %[[VTABLE]] to i64 -// CHECK: %[[V8:.*]] = call i64 @llvm.ptrauth.auth(i64 %[[V7]], i32 2, i64 0) +// CHECK: %[[V8:.*]] = call i64 @llvm.ptrauth.auth(i64 %[[V7]]) [ "ptrauth"(i64 2, i64 0) ] // CHECK: %[[V9:.*]] = inttoptr i64 %[[V8]] to ptr // DARWIN: %[[V10:.*]] = trunc i64 %[[MEMPTR_PTR]] to i32 // DARWIN: %[[V11:.*]] = zext i32 %[[V10]] to i64 @@ -335,7 +335,7 @@ void test1_noexcept(Base0 *a0, NoExceptMethodTy0 a1) { // CHECK: br i1 %[[V5]] // CHECK: %[[V6:.*]] = ptrtoint ptr %[[V4]] to i64 -// CHECK: %[[V7:.*]] = call i64 @llvm.ptrauth.resign(i64 %[[V6]], i32 0, i64 [[TYPEDISC0]], i32 0, i64 [[TYPEDISC1]]) +// CHECK: %[[V7:.*]] = call i64 @llvm.ptrauth.resign(i64 %[[V6]]) [ "ptrauth"(i64 0, i64 [[TYPEDISC0]]), "ptrauth"(i64 0, i64 [[TYPEDISC1]]) ] // CHECK: %[[V8:.*]] = inttoptr i64 %[[V7]] to ptr // CHECK: br @@ -353,21 +353,21 @@ void testConversion0(MethodTy0 method0, MethodTy1 method1) { } // CHECK: define{{.*}} void @_Z15testConversion1M5Base0FvvE( -// CHECK: call i64 @llvm.ptrauth.resign(i64 %{{.*}}, i32 0, i64 [[TYPEDISC0]], i32 0, i64 [[TYPEDISC1]]) +// CHECK: call i64 @llvm.ptrauth.resign(i64 %{{.*}}) [ "ptrauth"(i64 0, i64 [[TYPEDISC0]]), "ptrauth"(i64 0, i64 [[TYPEDISC1]]) ] void testConversion1(MethodTy0 method0) { MethodTy1 method1 = reinterpret_cast(method0); } // CHECK: define{{.*}} void @_Z15testConversion2M8Derived0FvvE( -// CHECK: call i64 @llvm.ptrauth.resign(i64 %{{.*}}, i32 0, i64 [[TYPEDISC1]], i32 0, i64 [[TYPEDISC0]]) +// CHECK: call i64 @llvm.ptrauth.resign(i64 %{{.*}}) [ "ptrauth"(i64 0, i64 [[TYPEDISC1]]), "ptrauth"(i64 0, i64 [[TYPEDISC0]]) ] void testConversion2(MethodTy1 method1) { MethodTy0 method0 = static_cast(method1); } // CHECK: define{{.*}} void @_Z15testConversion3M8Derived0FvvE( -// CHECK: call i64 @llvm.ptrauth.resign(i64 %{{.*}}, i32 0, i64 [[TYPEDISC1]], i32 0, i64 [[TYPEDISC0]]) +// CHECK: call i64 @llvm.ptrauth.resign(i64 %{{.*}}) [ "ptrauth"(i64 0, i64 [[TYPEDISC1]]), "ptrauth"(i64 0, i64 [[TYPEDISC0]]) ] void testConversion3(MethodTy1 method1) { MethodTy0 method0 = reinterpret_cast(method1); diff --git a/clang/test/CodeGenCXX/ptrauth-qualifier-struct.cpp b/clang/test/CodeGenCXX/ptrauth-qualifier-struct.cpp index 0310535362e3d..4f99db32537d6 100644 --- a/clang/test/CodeGenCXX/ptrauth-qualifier-struct.cpp +++ b/clang/test/CodeGenCXX/ptrauth-qualifier-struct.cpp @@ -67,7 +67,7 @@ void testMoveConstructor(SA a) { // CHECK: %[[V5:.*]] = ptrtoint ptr %[[M0]] to i64 // CHECK: %[[V6:.*]] = call i64 @llvm.ptrauth.blend(i64 %[[V5]], i64 50) // CHECK: %[[V8:.*]] = ptrtoint ptr %[[V2]] to i64 -// CHECK: %[[V9:.*]] = call i64 @llvm.ptrauth.resign(i64 %[[V8]], i32 1, i64 %[[V4]], i32 1, i64 %[[V6]]) +// CHECK: %[[V9:.*]] = call i64 @llvm.ptrauth.resign(i64 %[[V8]]) [ "ptrauth"(i64 1, i64 %[[V4]]), "ptrauth"(i64 1, i64 %[[V6]]) ] void testCopyAssignment(SA a) { SA t; @@ -92,7 +92,7 @@ void testCopyAssignment(SA a) { // CHECK: %[[V5:.*]] = ptrtoint ptr %[[M0]] to i64 // CHECK: %[[V6:.*]] = call i64 @llvm.ptrauth.blend(i64 %[[V5]], i64 50) // CHECK: %[[V8:.*]] = ptrtoint ptr %[[V2]] to i64 -// CHECK: %[[V9:.*]] = call i64 @llvm.ptrauth.resign(i64 %[[V8]], i32 1, i64 %[[V4]], i32 1, i64 %[[V6]]) +// CHECK: %[[V9:.*]] = call i64 @llvm.ptrauth.resign(i64 %[[V8]]) [ "ptrauth"(i64 1, i64 %[[V4]]), "ptrauth"(i64 1, i64 %[[V6]]) ] void testMoveAssignment(SA a) { SA t; @@ -146,7 +146,7 @@ void testMoveAssignment(SI a) { // CHECK: %[[V5:.*]] = ptrtoint ptr %[[M0]] to i64 // CHECK: %[[V6:.*]] = call i64 @llvm.ptrauth.blend(i64 %[[V5]], i64 50) // CHECK: %[[V8:.*]] = ptrtoint ptr %[[V2]] to i64 -// CHECK: %[[V9:.*]] = call i64 @llvm.ptrauth.resign(i64 %[[V8]], i32 1, i64 %[[V4]], i32 1, i64 %[[V6]]) +// CHECK: %[[V9:.*]] = call i64 @llvm.ptrauth.resign(i64 %[[V8]]) [ "ptrauth"(i64 1, i64 %[[V4]]), "ptrauth"(i64 1, i64 %[[V6]]) ] // CHECK: define linkonce_odr {{.*}}@_ZN2SAC2EOS_(ptr noundef nonnull align 8 dereferenceable(16) %[[THIS:.*]], ptr noundef nonnull align 8 dereferenceable(16) %0) // IOS: %[[RETVAL:.*]] = alloca ptr, align 8 @@ -165,4 +165,4 @@ void testMoveAssignment(SI a) { // CHECK: %[[V5:.*]] = ptrtoint ptr %[[M0]] to i64 // CHECK: %[[V6:.*]] = call i64 @llvm.ptrauth.blend(i64 %[[V5]], i64 50) // CHECK: %[[V8:.*]] = ptrtoint ptr %[[V2]] to i64 -// CHECK: %[[V9:.*]] = call i64 @llvm.ptrauth.resign(i64 %[[V8]], i32 1, i64 %[[V4]], i32 1, i64 %[[V6]]) +// CHECK: %[[V9:.*]] = call i64 @llvm.ptrauth.resign(i64 %[[V8]]) [ "ptrauth"(i64 1, i64 %[[V4]]), "ptrauth"(i64 1, i64 %[[V6]]) ] diff --git a/clang/test/CodeGenCXX/ptrauth-thunks.cpp b/clang/test/CodeGenCXX/ptrauth-thunks.cpp index f4491a3aab7ab..7c08ec3e5bbba 100644 --- a/clang/test/CodeGenCXX/ptrauth-thunks.cpp +++ b/clang/test/CodeGenCXX/ptrauth-thunks.cpp @@ -26,4 +26,4 @@ namespace Test1 { // CHECK: %[[This:.*]] = load ptr // CHECK: %[[SignedVTable:.*]] = load ptr, ptr %[[This]], align 8 // CHECK: %[[SignedVTableAsInt:.*]] = ptrtoint ptr %[[SignedVTable]] to i64 -// CHECK: %[[VTable:.*]] = call i64 @llvm.ptrauth.auth(i64 %[[SignedVTableAsInt]], i32 2, i64 0) +// CHECK: %[[VTable:.*]] = call i64 @llvm.ptrauth.auth(i64 %[[SignedVTableAsInt]]) [ "ptrauth"(i64 2, i64 0) ] diff --git a/clang/test/CodeGenCXX/ptrauth-type-info-vtable.cpp b/clang/test/CodeGenCXX/ptrauth-type-info-vtable.cpp index f4396e4027039..73bab580019aa 100644 --- a/clang/test/CodeGenCXX/ptrauth-type-info-vtable.cpp +++ b/clang/test/CodeGenCXX/ptrauth-type-info-vtable.cpp @@ -84,7 +84,7 @@ extern "C" void test_vtable(std::type_info* t) { // NODISC: [[T:%.*]] = load ptr, ptr [[T_ADDR]], align 8 // NODISC: [[VPTR:%.*]] = load ptr, ptr [[T]], align 8 // NODISC: [[CAST_VPTR:%.*]] = ptrtoint ptr [[VPTR]] to i64 -// NODISC: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[CAST_VPTR]], i32 2, i64 0) +// NODISC: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[CAST_VPTR]]) [ "ptrauth"(i64 2, i64 0) ] // DISC: define{{.*}} void @test_vtable(ptr noundef %t) // DISC: [[T_ADDR:%.*]] = alloca ptr, align 8 @@ -94,7 +94,7 @@ extern "C" void test_vtable(std::type_info* t) { // DISC: [[ADDR:%.*]] = ptrtoint ptr [[T]] to i64 // DISC: [[DISCRIMINATOR:%.*]] = call i64 @llvm.ptrauth.blend(i64 [[ADDR]], i64 [[STDTYPEINFO_DISC]]) // DISC: [[VPTRI:%.*]] = ptrtoint ptr [[VPTR]] to i64 -// DISC: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VPTRI]], i32 2, i64 [[DISCRIMINATOR]]) +// DISC: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VPTRI]]) [ "ptrauth"(i64 2, i64 [[DISCRIMINATOR]]) ] extern "C" const void *ensure_typeinfo() { return new TestStruct; diff --git a/clang/test/CodeGenCXX/ptrauth-virtual-function.cpp b/clang/test/CodeGenCXX/ptrauth-virtual-function.cpp index 4aa24738d8ce3..a13dc235b2ef2 100644 --- a/clang/test/CodeGenCXX/ptrauth-virtual-function.cpp +++ b/clang/test/CodeGenCXX/ptrauth-virtual-function.cpp @@ -188,17 +188,17 @@ V1::~V1() { // CHECK: %[[THIS1:.*]] = load ptr, ptr %{{.*}} // CHECK: %[[T0:[0-9]+]] = load ptr, ptr %{{.*}} // CHECK: %[[T1:[0-9]+]] = ptrtoint ptr %[[T0]] to i64 -// CHECK: %[[T2:[0-9]+]] = call i64 @llvm.ptrauth.auth(i64 %[[T1]], i32 2, i64 0) +// CHECK: %[[T2:[0-9]+]] = call i64 @llvm.ptrauth.auth(i64 %[[T1]]) [ "ptrauth"(i64 2, i64 0) ] // CHECK: %[[T3:[0-9]+]] = inttoptr i64 %[[T2]] to ptr // CHECK: %[[T6:[0-9]+]] = ptrtoint ptr %[[T3]] to i64 -// CHECK: %[[T7:[0-9]+]] = call i64 @llvm.ptrauth.sign(i64 %[[T6]], i32 2, i64 0) +// CHECK: %[[T7:[0-9]+]] = call i64 @llvm.ptrauth.sign(i64 %[[T6]]) [ "ptrauth"(i64 2, i64 0) ] // CHECK: %[[SIGNED_VTADDR:[0-9]+]] = inttoptr i64 %[[T7]] to ptr // CHECK: store ptr %[[SIGNED_VTADDR]], ptr %[[THIS1]] // CHECK-LABEL: define{{.*}} void @_Z8testB0m0P2B0( // CHECK: %[[VTABLE:[a-z]+]] = load ptr, ptr %{{.*}} // CHECK: %[[T0:[0-9]+]] = ptrtoint ptr %[[VTABLE]] to i64 -// CHECK: %[[T3:[0-9]+]] = call i64 @llvm.ptrauth.auth(i64 %[[T0]], i32 2, i64 0) +// CHECK: %[[T3:[0-9]+]] = call i64 @llvm.ptrauth.auth(i64 %[[T0]]) [ "ptrauth"(i64 2, i64 0) ] // CHECK: %[[T4:[0-9]+]] = inttoptr i64 %[[T3]] to ptr // CHECK: %[[VFN:[a-z]+]] = getelementptr inbounds ptr, ptr %[[T4]], i64 0 // CHECK: %[[T5:[0-9]+]] = load ptr, ptr %[[VFN]] @@ -213,7 +213,7 @@ void testB0m0(B0 *a) { // CHECK-LABEL: define{{.*}} void @_Z8testB0m1P2B0( // CHECK: %[[VTABLE:[a-z]+]] = load ptr, ptr %{{.*}} // CHECK: %[[T0:[0-9]+]] = ptrtoint ptr %[[VTABLE]] to i64 -// CHECK: %[[T3:[0-9]+]] = call i64 @llvm.ptrauth.auth(i64 %[[T0]], i32 2, i64 0) +// CHECK: %[[T3:[0-9]+]] = call i64 @llvm.ptrauth.auth(i64 %[[T0]]) [ "ptrauth"(i64 2, i64 0) ] // CHECK: %[[T4:[0-9]+]] = inttoptr i64 %[[T3]] to ptr // CHECK: %[[VFN:[a-z]+]] = getelementptr inbounds ptr, ptr %[[T4]], i64 1 // CHECK: %[[T5:[0-9]+]] = load ptr, ptr %[[VFN]] @@ -228,7 +228,7 @@ void testB0m1(B0 *a) { // CHECK-LABEL: define{{.*}} void @_Z8testB0m2P2B0( // CHECK: %[[VTABLE:[a-z]+]] = load ptr, ptr %{{.*}} // CHECK: %[[T0:[0-9]+]] = ptrtoint ptr %[[VTABLE]] to i64 -// CHECK: %[[T3:[0-9]+]] = call i64 @llvm.ptrauth.auth(i64 %[[T0]], i32 2, i64 0) +// CHECK: %[[T3:[0-9]+]] = call i64 @llvm.ptrauth.auth(i64 %[[T0]]) [ "ptrauth"(i64 2, i64 0) ] // CHECK: %[[T4:[0-9]+]] = inttoptr i64 %[[T3]] to ptr // CHECK: %[[VFN:[a-z]+]] = getelementptr inbounds ptr, ptr %[[T4]], i64 2 // CHECK: %[[T5:[0-9]+]] = load ptr, ptr %[[VFN]] @@ -243,7 +243,7 @@ void testB0m2(B0 *a) { // CHECK-LABEL: define{{.*}} void @_Z8testD0m0P2D0( // CHECK: %[[VTABLE:[a-z]+]] = load ptr, ptr %{{.*}} // CHECK: %[[T0:[0-9]+]] = ptrtoint ptr %[[VTABLE]] to i64 -// CHECK: %[[T3:[0-9]+]] = call i64 @llvm.ptrauth.auth(i64 %[[T0]], i32 2, i64 0) +// CHECK: %[[T3:[0-9]+]] = call i64 @llvm.ptrauth.auth(i64 %[[T0]]) [ "ptrauth"(i64 2, i64 0) ] // CHECK: %[[T4:[0-9]+]] = inttoptr i64 %[[T3]] to ptr // CHECK: %[[VFN:[a-z]+]] = getelementptr inbounds ptr, ptr %[[T4]], i64 0 // CHECK: %[[T5:[0-9]+]] = load ptr, ptr %[[VFN]] @@ -258,7 +258,7 @@ void testD0m0(D0 *a) { // CHECK-LABEL: define{{.*}} void @_Z8testD0m1P2D0( // CHECK: %[[VTABLE:[a-z]+]] = load ptr, ptr %{{.*}} // CHECK: %[[T0:[0-9]+]] = ptrtoint ptr %[[VTABLE]] to i64 -// CHECK: %[[T3:[0-9]+]] = call i64 @llvm.ptrauth.auth(i64 %[[T0]], i32 2, i64 0) +// CHECK: %[[T3:[0-9]+]] = call i64 @llvm.ptrauth.auth(i64 %[[T0]]) [ "ptrauth"(i64 2, i64 0) ] // CHECK: %[[T4:[0-9]+]] = inttoptr i64 %[[T3]] to ptr // CHECK: %[[VFN:[a-z]+]] = getelementptr inbounds ptr, ptr %[[T4]], i64 5 // CHECK: %[[T5:[0-9]+]] = load ptr, ptr %[[VFN]] @@ -273,7 +273,7 @@ void testD0m1(D0 *a) { // CHECK-LABEL: define{{.*}} void @_Z8testD0m2P2D0( // CHECK: %[[VTABLE:[a-z]+]] = load ptr, ptr %{{.*}} // CHECK: %[[T0:[0-9]+]] = ptrtoint ptr %[[VTABLE]] to i64 -// CHECK: %[[T3:[0-9]+]] = call i64 @llvm.ptrauth.auth(i64 %[[T0]], i32 2, i64 0) +// CHECK: %[[T3:[0-9]+]] = call i64 @llvm.ptrauth.auth(i64 %[[T0]]) [ "ptrauth"(i64 2, i64 0) ] // CHECK: %[[T4:[0-9]+]] = inttoptr i64 %[[T3]] to ptr // CHECK: %[[VFN:[a-z]+]] = getelementptr inbounds ptr, ptr %[[T4]], i64 2 // CHECK: %[[T5:[0-9]+]] = load ptr, ptr %[[VFN]] @@ -288,7 +288,7 @@ void testD0m2(D0 *a) { // CHECK-LABEL: define{{.*}} void @_Z8testD0m3P2D0( // CHECK: %[[VTABLE:[a-z]+]] = load ptr, ptr %{{.*}} // CHECK: %[[T0:[0-9]+]] = ptrtoint ptr %[[VTABLE]] to i64 -// CHECK: %[[T3:[0-9]+]] = call i64 @llvm.ptrauth.auth(i64 %[[T0]], i32 2, i64 0) +// CHECK: %[[T3:[0-9]+]] = call i64 @llvm.ptrauth.auth(i64 %[[T0]]) [ "ptrauth"(i64 2, i64 0) ] // CHECK: %[[T4:[0-9]+]] = inttoptr i64 %[[T3]] to ptr // CHECK: %[[VFN:[a-z]+]] = getelementptr inbounds ptr, ptr %[[T4]], i64 6 // CHECK: %[[T5:[0-9]+]] = load ptr, ptr %[[VFN]] @@ -304,7 +304,7 @@ void testD0m3(D0 *a) { // CHECK-LABEL: define{{.*}} void @_Z8testD1m0P2D1( // CHECK: %[[VTABLE:[a-z]+]] = load ptr, ptr %{{.*}} // CHECK: %[[T0:[0-9]+]] = ptrtoint ptr %[[VTABLE]] to i64 -// CHECK: %[[T3:[0-9]+]] = call i64 @llvm.ptrauth.auth(i64 %[[T0]], i32 2, i64 0) +// CHECK: %[[T3:[0-9]+]] = call i64 @llvm.ptrauth.auth(i64 %[[T0]]) [ "ptrauth"(i64 2, i64 0) ] // CHECK: %[[T4:[0-9]+]] = inttoptr i64 %[[T3]] to ptr // CHECK: %[[VFN:[a-z]+]] = getelementptr inbounds ptr, ptr %[[T4]], i64 0 // CHECK: %[[T5:[0-9]+]] = load ptr, ptr %[[VFN]] @@ -319,7 +319,7 @@ void testD1m0(D1 *a) { // CHECK-LABEL: define{{.*}} void @_Z8testD1m1P2D1( // CHECK: %[[VTABLE:[a-z]+]] = load ptr, ptr %{{.*}} // CHECK: %[[T0:[0-9]+]] = ptrtoint ptr %[[VTABLE]] to i64 -// CHECK: %[[T3:[0-9]+]] = call i64 @llvm.ptrauth.auth(i64 %[[T0]], i32 2, i64 0) +// CHECK: %[[T3:[0-9]+]] = call i64 @llvm.ptrauth.auth(i64 %[[T0]]) [ "ptrauth"(i64 2, i64 0) ] // CHECK: %[[T4:[0-9]+]] = inttoptr i64 %[[T3]] to ptr // CHECK: %[[VFN:[a-z]+]] = getelementptr inbounds ptr, ptr %[[T4]], i64 5 // CHECK: %[[T5:[0-9]+]] = load ptr, ptr %[[VFN]] @@ -334,7 +334,7 @@ void testD1m1(D1 *a) { // CHECK-LABEL: define{{.*}} void @_Z8testD1m2P2D1( // CHECK: %[[VTABLE:[a-z]+]] = load ptr, ptr %{{.*}} // CHECK: %[[T0:[0-9]+]] = ptrtoint ptr %[[VTABLE]] to i64 -// CHECK: %[[T3:[0-9]+]] = call i64 @llvm.ptrauth.auth(i64 %[[T0]], i32 2, i64 0) +// CHECK: %[[T3:[0-9]+]] = call i64 @llvm.ptrauth.auth(i64 %[[T0]]) [ "ptrauth"(i64 2, i64 0) ] // CHECK: %[[T4:[0-9]+]] = inttoptr i64 %[[T3]] to ptr // CHECK: %[[VFN:[a-z]+]] = getelementptr inbounds ptr, ptr %[[T4]], i64 2 // CHECK: %[[T5:[0-9]+]] = load ptr, ptr %[[VFN]] @@ -350,7 +350,7 @@ void testD1m2(D1 *a) { // CHECK-LABEL: define{{.*}} void @_Z8testD2m0P2D2( // CHECK: %[[VTABLE:[a-z]+]] = load ptr, ptr %{{.*}} // CHECK: %[[T0:[0-9]+]] = ptrtoint ptr %[[VTABLE]] to i64 -// CHECK: %[[T3:[0-9]+]] = call i64 @llvm.ptrauth.auth(i64 %[[T0]], i32 2, i64 0) +// CHECK: %[[T3:[0-9]+]] = call i64 @llvm.ptrauth.auth(i64 %[[T0]]) [ "ptrauth"(i64 2, i64 0) ] // CHECK: %[[T4:[0-9]+]] = inttoptr i64 %[[T3]] to ptr // CHECK: %[[VFN:[a-z]+]] = getelementptr inbounds ptr, ptr %[[T4]], i64 0 // CHECK: %[[T5:[0-9]+]] = load ptr, ptr %[[VFN]] @@ -365,7 +365,7 @@ void testD2m0(D2 *a) { // CHECK-LABEL: define{{.*}} void @_Z8testD2m1P2D2( // CHECK: %[[VTABLE:[a-z]+]] = load ptr, ptr %{{.*}} // CHECK: %[[T0:[0-9]+]] = ptrtoint ptr %[[VTABLE]] to i64 -// CHECK: %[[T3:[0-9]+]] = call i64 @llvm.ptrauth.auth(i64 %[[T0]], i32 2, i64 0) +// CHECK: %[[T3:[0-9]+]] = call i64 @llvm.ptrauth.auth(i64 %[[T0]]) [ "ptrauth"(i64 2, i64 0) ] // CHECK: %[[T4:[0-9]+]] = inttoptr i64 %[[T3]] to ptr // CHECK: %[[VFN:[a-z]+]] = getelementptr inbounds ptr, ptr %[[T4]], i64 5 // CHECK: %[[T5:[0-9]+]] = load ptr, ptr %[[VFN]] @@ -394,7 +394,7 @@ void testD2m2D1(D2 *a) { // CHECK-LABEL: define{{.*}} void @_Z8testD2m3P2D2( // CHECK: %[[VTABLE:[a-z]+]] = load ptr, ptr %{{.*}} // CHECK: %[[T0:[0-9]+]] = ptrtoint ptr %[[VTABLE]] to i64 -// CHECK: %[[T3:[0-9]+]] = call i64 @llvm.ptrauth.auth(i64 %[[T0]], i32 2, i64 0) +// CHECK: %[[T3:[0-9]+]] = call i64 @llvm.ptrauth.auth(i64 %[[T0]]) [ "ptrauth"(i64 2, i64 0) ] // CHECK: %[[T4:[0-9]+]] = inttoptr i64 %[[T3]] to ptr // CHECK: %[[VFN:[a-z]+]] = getelementptr inbounds ptr, ptr %[[T4]], i64 6 // CHECK: %[[T5:[0-9]+]] = load ptr, ptr %[[VFN]] @@ -409,7 +409,7 @@ void testD2m3(D2 *a) { // CHECK-LABEL: define{{.*}} void @_Z8testD3m0P2D3( // CHECK: %[[VTABLE:[a-z]+]] = load ptr, ptr %{{.*}} // CHECK: %[[T0:[0-9]+]] = ptrtoint ptr %[[VTABLE]] to i64 -// CHECK: %[[T3:[0-9]+]] = call i64 @llvm.ptrauth.auth(i64 %[[T0]], i32 2, i64 0) +// CHECK: %[[T3:[0-9]+]] = call i64 @llvm.ptrauth.auth(i64 %[[T0]]) [ "ptrauth"(i64 2, i64 0) ] // CHECK: %[[T4:[0-9]+]] = inttoptr i64 %[[T3]] to ptr // CHECK: %[[VFN:[a-z]+]] = getelementptr inbounds ptr, ptr %[[T4]], i64 0 // CHECK: %[[T5:[0-9]+]] = load ptr, ptr %[[VFN]] @@ -424,7 +424,7 @@ void testD3m0(D3 *a) { // CHECK-LABEL: define{{.*}} void @_Z8testD3m1P2D3( // CHECK: %[[VTABLE:[a-z]+]] = load ptr, ptr %{{.*}} // CHECK: %[[T0:[0-9]+]] = ptrtoint ptr %[[VTABLE]] to i64 -// CHECK: %[[T3:[0-9]+]] = call i64 @llvm.ptrauth.auth(i64 %[[T0]], i32 2, i64 0) +// CHECK: %[[T3:[0-9]+]] = call i64 @llvm.ptrauth.auth(i64 %[[T0]]) [ "ptrauth"(i64 2, i64 0) ] // CHECK: %[[T4:[0-9]+]] = inttoptr i64 %[[T3]] to ptr // CHECK: %[[VFN:[a-z]+]] = getelementptr inbounds ptr, ptr %[[T4]], i64 1 // CHECK: %[[T5:[0-9]+]] = load ptr, ptr %[[VFN]] @@ -442,14 +442,14 @@ void testD3m1(D3 *a) { // CHECK: %[[V0:.*]] = load ptr, ptr %[[A_ADDR]], align 8 // CHECK: %[[VTABLE:.*]] = load ptr, ptr %[[V0]], align 8 // CHECK: %[[V1:.*]] = ptrtoint ptr %[[VTABLE]] to i64 -// CHECK: %[[V2:.*]] = call i64 @llvm.ptrauth.auth(i64 %[[V1]], i32 2, i64 0) +// CHECK: %[[V2:.*]] = call i64 @llvm.ptrauth.auth(i64 %[[V1]]) [ "ptrauth"(i64 2, i64 0) ] // CHECK: %[[V3:.*]] = inttoptr i64 %[[V2]] to ptr // CHECK: %[[VBASE_OFFSET_PTR:.*]] = getelementptr i8, ptr %[[V3]], i64 -24 // CHECK: %[[VBASE_OFFSET:.*]] = load i64, ptr %[[VBASE_OFFSET_PTR]], align 8 // CHECK: %[[ADD_PTR:.*]] = getelementptr inbounds i8, ptr %[[V0]], i64 %[[VBASE_OFFSET]] // CHECK: %[[VTABLE1:.*]] = load ptr, ptr %[[ADD_PTR]], align 8 // CHECK: %[[V4:.*]] = ptrtoint ptr %[[VTABLE1]] to i64 -// CHECK: %[[V5:.*]] = call i64 @llvm.ptrauth.auth(i64 %[[V4]], i32 2, i64 0) +// CHECK: %[[V5:.*]] = call i64 @llvm.ptrauth.auth(i64 %[[V4]]) [ "ptrauth"(i64 2, i64 0) ] // CHECK: %[[V6:.*]] = inttoptr i64 %[[V5]] to ptr // CHECK: %[[VFN:.*]] = getelementptr inbounds ptr, ptr %[[V6]], i64 2 // CHECK: %[[V7:.*]] = load ptr, ptr %[[VFN]], align 8 @@ -465,7 +465,7 @@ void testD3m2(D3 *a) { // CHECK: load ptr, ptr // CHECK: %[[VTABLE:.*]] = load ptr, ptr %{{.*}} // CHECK: %[[T2:[0-9]+]] = ptrtoint ptr %[[VTABLE]] to i64 -// CHECK: %[[T3:[0-9]+]] = call i64 @llvm.ptrauth.auth(i64 %[[T2]], i32 2, i64 0) +// CHECK: %[[T3:[0-9]+]] = call i64 @llvm.ptrauth.auth(i64 %[[T2]]) [ "ptrauth"(i64 2, i64 0) ] // CHECK: %[[T4:[0-9]+]] = inttoptr i64 %[[T3]] to ptr // CHECK: %[[VFN:[a-z]+]] = getelementptr inbounds ptr, ptr %[[T4]], i64 3 // CHECK: %[[T5:[0-9]+]] = load ptr, ptr %[[VFN]] @@ -481,14 +481,14 @@ void testD3Destructor0(D3 *a) { // CHECK: %[[T6:.*]] = load ptr, ptr % // CHECK: %[[VTABLE0:[a-z0-9]+]] = load ptr, ptr % // CHECK: %[[T2:[0-9]+]] = ptrtoint ptr %[[VTABLE0]] to i64 -// CHECK: %[[T3:[0-9]+]] = call i64 @llvm.ptrauth.auth(i64 %[[T2]], i32 2, i64 0) +// CHECK: %[[T3:[0-9]+]] = call i64 @llvm.ptrauth.auth(i64 %[[T2]]) [ "ptrauth"(i64 2, i64 0) ] // CHECK: %[[T4:[0-9]+]] = inttoptr i64 %[[T3]] to ptr // CHECK: %[[COMPLETE_OFFSET_PTR:.*]] = getelementptr inbounds i64, ptr %[[T4]], i64 -2 // CHECK: %[[T5:[0-9]+]] = load i64, ptr %[[COMPLETE_OFFSET_PTR]] // CHECK: %[[T7:[0-9]+]] = getelementptr inbounds i8, ptr %[[T6]], i64 %[[T5]] // CHECK: %[[VTABLE1:[a-z0-9]+]] = load ptr, ptr %[[T6]] // CHECK: %[[T9:[0-9]+]] = ptrtoint ptr %[[VTABLE1]] to i64 -// CHECK: %[[T10:[0-9]+]] = call i64 @llvm.ptrauth.auth(i64 %[[T9]], i32 2, i64 0) +// CHECK: %[[T10:[0-9]+]] = call i64 @llvm.ptrauth.auth(i64 %[[T9]]) [ "ptrauth"(i64 2, i64 0) ] // CHECK: %[[T11:[0-9]+]] = inttoptr i64 %[[T10]] to ptr // CHECK: %[[VFN:[a-z0-9]+]] = getelementptr inbounds ptr, ptr %[[T11]], i64 2 // CHECK: %[[T12:[0-9]+]] = load ptr, ptr %[[VFN]] @@ -506,7 +506,7 @@ void testD3Destructor1(D3 *a) { // CHECK: load ptr, ptr // CHECK: %[[VTABLE:.*]] = load ptr, ptr % // CHECK: %[[T2:.*]] = ptrtoint ptr %[[VTABLE]] to i64 -// CHECK: %[[T3:.*]] = call i64 @llvm.ptrauth.auth(i64 %[[T2]], i32 2, i64 0) +// CHECK: %[[T3:.*]] = call i64 @llvm.ptrauth.auth(i64 %[[T2]]) [ "ptrauth"(i64 2, i64 0) ] // CHECK: %[[T4:.*]] = inttoptr i64 %[[T3]] to ptr // CHECK: %[[VFN:.*]] = getelementptr inbounds ptr, ptr %[[T4]], i64 2 // CHECK: %[[T5:.*]] = load ptr, ptr %[[VFN]] @@ -533,30 +533,30 @@ void materializeConstructors() { // DARWIN-LABEL: define linkonce_odr noundef ptr @_ZN2B0C2Ev( // ELF-LABEL: define linkonce_odr void @_ZN2B0C2Ev( // CHECK: %[[THIS:.*]] = load ptr, ptr % -// CHECK: %[[T0:[0-9]+]] = call i64 @llvm.ptrauth.sign(i64 ptrtoint (ptr getelementptr inbounds inrange(-16, 40) ({ [7 x ptr] }, ptr @_ZTV2B0, i32 0, i32 0, i32 2) to i64), i32 2, i64 0) +// CHECK: %[[T0:[0-9]+]] = call i64 @llvm.ptrauth.sign(i64 ptrtoint (ptr getelementptr inbounds inrange(-16, 40) ({ [7 x ptr] }, ptr @_ZTV2B0, i32 0, i32 0, i32 2) to i64)) [ "ptrauth"(i64 2, i64 0) ] // CHECK: %[[SIGNED_VTADDR:[0-9]+]] = inttoptr i64 %[[T0]] to ptr // CHECK: store ptr %[[SIGNED_VTADDR]], ptr %[[THIS]] // DARWIN-LABEL: define linkonce_odr noundef ptr @_ZN2D0C2Ev( // ELF-LABEL: define linkonce_odr void @_ZN2D0C2Ev( -// CHECK: %[[T0:[0-9]+]] = call i64 @llvm.ptrauth.sign(i64 ptrtoint (ptr getelementptr inbounds inrange(-16, 56) ({ [9 x ptr] }, ptr @_ZTV2D0, i32 0, i32 0, i32 2) to i64), i32 2, i64 0) +// CHECK: %[[T0:[0-9]+]] = call i64 @llvm.ptrauth.sign(i64 ptrtoint (ptr getelementptr inbounds inrange(-16, 56) ({ [9 x ptr] }, ptr @_ZTV2D0, i32 0, i32 0, i32 2) to i64)) [ "ptrauth"(i64 2, i64 0) ] // CHECK: %[[SIGNED_VTADDR:[0-9]+]] = inttoptr i64 %[[T0]] to ptr // CHECK: store ptr %[[SIGNED_VTADDR]], ptr %[[THIS]] // DARWIN-LABEL: define linkonce_odr noundef ptr @_ZN2D1C2Ev( // ELF-LABEL: define linkonce_odr void @_ZN2D1C2Ev( -// CHECK: %[[T0:[0-9]+]] = call i64 @llvm.ptrauth.sign(i64 ptrtoint (ptr getelementptr inbounds inrange(-16, 48) ({ [8 x ptr] }, ptr @_ZTV2D1, i32 0, i32 0, i32 2) to i64), i32 2, i64 0) +// CHECK: %[[T0:[0-9]+]] = call i64 @llvm.ptrauth.sign(i64 ptrtoint (ptr getelementptr inbounds inrange(-16, 48) ({ [8 x ptr] }, ptr @_ZTV2D1, i32 0, i32 0, i32 2) to i64)) [ "ptrauth"(i64 2, i64 0) ] // CHECK: %[[SIGNED_VTADDR:[0-9]+]] = inttoptr i64 %[[T0]] to ptr // CHECK: store ptr %[[SIGNED_VTADDR]], ptr %[[THIS]] // DARWIN-LABEL: define linkonce_odr noundef ptr @_ZN2D2C2Ev( // ELF-LABEL: define linkonce_odr void @_ZN2D2C2Ev( // CHECK: %[[SLOT0:.*]] = load ptr, ptr -// CHECK: %[[SIGN_VTADDR0:[0-9]+]] = call i64 @llvm.ptrauth.sign(i64 ptrtoint (ptr getelementptr inbounds inrange(-16, 56) ({ [9 x ptr], [8 x ptr] }, ptr @_ZTV2D2, i32 0, i32 0, i32 2) to i64), i32 2, i64 0) +// CHECK: %[[SIGN_VTADDR0:[0-9]+]] = call i64 @llvm.ptrauth.sign(i64 ptrtoint (ptr getelementptr inbounds inrange(-16, 56) ({ [9 x ptr], [8 x ptr] }, ptr @_ZTV2D2, i32 0, i32 0, i32 2) to i64)) [ "ptrauth"(i64 2, i64 0) ] // CHECK: %[[T1:[0-9]+]] = inttoptr i64 %[[SIGN_VTADDR0]] to ptr // CHECK: store ptr %[[T1]], ptr %[[SLOT0]] // CHECK: %[[T3:[a-z0-9.]+]] = getelementptr inbounds i8, ptr %[[SLOT0]], i64 16 -// CHECK: %[[SIGN_VTADDR1:[0-9]+]] = call i64 @llvm.ptrauth.sign(i64 ptrtoint (ptr getelementptr inbounds inrange(-16, 48) ({ [9 x ptr], [8 x ptr] }, ptr @_ZTV2D2, i32 0, i32 1, i32 2) to i64), i32 2, i64 0) +// CHECK: %[[SIGN_VTADDR1:[0-9]+]] = call i64 @llvm.ptrauth.sign(i64 ptrtoint (ptr getelementptr inbounds inrange(-16, 48) ({ [9 x ptr], [8 x ptr] }, ptr @_ZTV2D2, i32 0, i32 1, i32 2) to i64)) [ "ptrauth"(i64 2, i64 0) ] // CHECK: %[[T5:[0-9]+]] = inttoptr i64 %[[SIGN_VTADDR1]] to ptr // CHECK: store ptr %[[T5]], ptr %[[T3]] @@ -566,25 +566,25 @@ void materializeConstructors() { // CHECK: %[[VTT:[a-z0-9]+]] = load ptr, ptr %{{.*}} // CHECK: %[[T0:[0-9]+]] = load ptr, ptr %[[VTT]] // CHECK: %[[T1:[0-9]+]] = ptrtoint ptr %[[T0]] to i64 -// CHECK: %[[T2:[0-9]+]] = call i64 @llvm.ptrauth.auth(i64 %[[T1]], i32 2, i64 0) +// CHECK: %[[T2:[0-9]+]] = call i64 @llvm.ptrauth.auth(i64 %[[T1]]) [ "ptrauth"(i64 2, i64 0) ] // CHECK: %[[T3:[0-9]+]] = inttoptr i64 %[[T2]] to ptr // CHECK: %[[VTADDR0:[0-9]+]] = ptrtoint ptr %[[T3]] to i64 -// CHECK: %[[T7:[0-9]+]] = call i64 @llvm.ptrauth.sign(i64 %[[VTADDR0]], i32 2, i64 0) +// CHECK: %[[T7:[0-9]+]] = call i64 @llvm.ptrauth.sign(i64 %[[VTADDR0]]) [ "ptrauth"(i64 2, i64 0) ] // CHECK: %[[SIGN_VTADDR0:[0-9]+]] = inttoptr i64 %[[T7]] to ptr // CHECK: store ptr %[[SIGN_VTADDR0]], ptr %[[SLOT0]] // CHECK: %[[T9:[0-9]+]] = getelementptr inbounds ptr, ptr %[[VTT]], i64 1 // CHECK: %[[T10:[0-9]+]] = load ptr, ptr %[[T9]] // CHECK: %[[T11:[0-9]+]] = ptrtoint ptr %[[T10]] to i64 -// CHECK: %[[T12:[0-9]+]] = call i64 @llvm.ptrauth.auth(i64 %[[T11]], i32 2, i64 0) +// CHECK: %[[T12:[0-9]+]] = call i64 @llvm.ptrauth.auth(i64 %[[T11]]) [ "ptrauth"(i64 2, i64 0) ] // CHECK: %[[T13:[0-9]+]] = inttoptr i64 %[[T12]] to ptr // CHECK: %[[VTABLE:[a-z]+]] = load ptr, ptr %[[THIS1]] // CHECK: %[[T15:[0-9]+]] = ptrtoint ptr %[[VTABLE]] to i64 -// CHECK: %[[T16:[0-9]+]] = call i64 @llvm.ptrauth.auth(i64 %[[T15]], i32 2, i64 0) +// CHECK: %[[T16:[0-9]+]] = call i64 @llvm.ptrauth.auth(i64 %[[T15]]) [ "ptrauth"(i64 2, i64 0) ] // CHECK: %[[T17:[0-9]+]] = inttoptr i64 %[[T16]] to ptr // CHECK: %[[VBASE_OFFSET_PTR:[a-z.]+]] = getelementptr i8, ptr %[[T17]], i64 -24 // CHECK: %[[VBASE_OFFSET:[a-z.]+]] = load i64, ptr %[[VBASE_OFFSET_PTR]] // CHECK: %[[T20:[a-z.]+]] = getelementptr inbounds i8, ptr %[[THIS1]], i64 %[[VBASE_OFFSET]] // CHECK: %[[VTADDR1:[0-9]+]] = ptrtoint ptr %[[T13]] to i64 -// CHECK: %[[T23:[0-9]+]] = call i64 @llvm.ptrauth.sign(i64 %[[VTADDR1]], i32 2, i64 0) +// CHECK: %[[T23:[0-9]+]] = call i64 @llvm.ptrauth.sign(i64 %[[VTADDR1]]) [ "ptrauth"(i64 2, i64 0) ] // CHECK: %[[SIGN_VTADDR1:[0-9]+]] = inttoptr i64 %[[T23]] to ptr // CHECK: store ptr %[[SIGN_VTADDR1]], ptr %[[T20]] diff --git a/clang/test/CodeGenCXX/ptrauth-vtable-virtual-inheritance-thunk.cpp b/clang/test/CodeGenCXX/ptrauth-vtable-virtual-inheritance-thunk.cpp index b5c15a29eb6b9..ce1c258cb8730 100644 --- a/clang/test/CodeGenCXX/ptrauth-vtable-virtual-inheritance-thunk.cpp +++ b/clang/test/CodeGenCXX/ptrauth-vtable-virtual-inheritance-thunk.cpp @@ -292,26 +292,26 @@ int main() { // And check the thunks // DARWIN: ptr @_ZTv0_n48_N1CD1Ev(ptr noundef %this) // ELF: void @_ZTv0_n48_N1CD1Ev(ptr noundef %this) -// CHECK: [[TEMP:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[TEMP:%.*]], i32 2, i64 62866) +// CHECK: [[TEMP:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[TEMP:%.*]]) [ "ptrauth"(i64 2, i64 62866) ] // CHECK: void @_ZTv0_n48_N1CD0Ev(ptr noundef %this) -// CHECK: [[TEMP:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[TEMP:%.*]], i32 2, i64 62866) +// CHECK: [[TEMP:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[TEMP:%.*]]) [ "ptrauth"(i64 2, i64 62866) ] // DARWIN: ptr @_ZTv0_n48_N1DD1Ev(ptr noundef %this) // ELF: void @_ZTv0_n48_N1DD1Ev(ptr noundef %this) -// CHECK: [[TEMP:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[TEMP:%.*]], i32 2, i64 62866) +// CHECK: [[TEMP:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[TEMP:%.*]]) [ "ptrauth"(i64 2, i64 62866) ] // CHECK: void @_ZTv0_n48_N1DD0Ev(ptr noundef %this) -// CHECK: [[TEMP:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[TEMP:%.*]], i32 2, i64 62866) +// CHECK: [[TEMP:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[TEMP:%.*]]) [ "ptrauth"(i64 2, i64 62866) ] // CHECK: void @_ZTv0_n48_N1FD0EvU11__vtptrauthILj0Lb0Lj62866E(ptr noundef %this) -// CHECK: [[TEMP:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[TEMP:%.*]], i32 2, i64 62866) +// CHECK: [[TEMP:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[TEMP:%.*]]) [ "ptrauth"(i64 2, i64 62866) ] // CHECK: void @_ZTv0_n48_N1FD0Ev(ptr noundef %this) -// CHECK: [[TEMP:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[TEMP:%.*]], i32 2, i64 12810) +// CHECK: [[TEMP:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[TEMP:%.*]]) [ "ptrauth"(i64 2, i64 12810) ] // CHECK: void @_ZTv0_n48_N1GD0Ev(ptr noundef %this) -// CHECK: [[TEMP:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[TEMP:%.*]], i32 2, i64 12810) +// CHECK: [[TEMP:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[TEMP:%.*]]) [ "ptrauth"(i64 2, i64 12810) ] // CHECK: void @_ZTv0_n48_N1GD0EvU11__vtptrauthILj0Lb0Lj62866E(ptr noundef %this) -// CHECK: [[TEMP:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[TEMP:%.*]], i32 2, i64 62866) +// CHECK: [[TEMP:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[TEMP:%.*]]) [ "ptrauth"(i64 2, i64 62866) ] diff --git a/clang/test/CodeGenCXX/ubsan-vtable-checks.cpp b/clang/test/CodeGenCXX/ubsan-vtable-checks.cpp index 23e96b5cca3b3..202f4891b5e56 100644 --- a/clang/test/CodeGenCXX/ubsan-vtable-checks.cpp +++ b/clang/test/CodeGenCXX/ubsan-vtable-checks.cpp @@ -40,7 +40,7 @@ int get_v(T* t) { // Verify that we authenticate for the actual vcall // CHECK-PTRAUTH: [[BLENDED:%.*]] = call i64 @llvm.ptrauth.blend(i64 {{%.*}}, i64 17113) // CHECK-PTRAUTH: [[CAST_VTABLE:%.*]] = ptrtoint ptr %vtable2 to i64 - // CHECK-PTRAUTH: [[AUTHED_INT:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[CAST_VTABLE]], i32 2, i64 [[BLENDED]]) + // CHECK-PTRAUTH: [[AUTHED_INT:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[CAST_VTABLE]]) [ "ptrauth"(i64 2, i64 [[BLENDED]]) ] // CHECK-PTRAUTH: [[AUTHED_PTR:%.*]] = inttoptr i64 [[AUTHED_INT]] to ptr // CHECK-PTRAUTH: {{%.*}} = getelementptr inbounds ptr, ptr [[AUTHED_PTR]], i64 2 return t->v(); @@ -68,7 +68,7 @@ void delete_it(T *t) { // CHECK-PTRAUTH: [[VTABLE2:%.*]] = load ptr, ptr {{.*}} // CHECK-PTRAUTH: [[BLENDED:%.*]] = call i64 @llvm.ptrauth.blend(i64 %{{.*}}, i64 17113) // CHECK-PTRAUTH: [[CAST_VTABLE:%.*]] = ptrtoint ptr [[VTABLE2]] to i64 - // CHECK-PTRAUTH: [[AUTHED_INT:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[CAST_VTABLE]], i32 2, i64 [[BLENDED]]) + // CHECK-PTRAUTH: [[AUTHED_INT:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[CAST_VTABLE]]) [ "ptrauth"(i64 2, i64 [[BLENDED]]) ] // CHECK-PTRAUTH: [[AUTHED_PTR:%.*]] = inttoptr i64 [[AUTHED_INT]] to ptr // CHECK-PTRAUTH: getelementptr inbounds ptr, ptr // CHECK-PTRAUTH {{%.*}} = getelementptr inbounds ptr, ptr [[AUTHED_PTR]], i64 1 @@ -91,7 +91,7 @@ U* dyncast(T *t) { // CHECK-VPTR: call void @__ubsan_handle_dynamic_type_cache_miss_abort // CHECK-PTRAUTH: [[BLENDED:%.*]] = call i64 @llvm.ptrauth.blend(i64 {{%.*}}, i64 17113) // CHECK-PTRAUTH: [[CAST_VTABLE:%.*]] = ptrtoint ptr %vtable1 to i64 - // CHECK-PTRAUTH: [[AUTHED_INT:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[CAST_VTABLE]], i32 2, i64 [[BLENDED]]) + // CHECK-PTRAUTH: [[AUTHED_INT:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[CAST_VTABLE]]) [ "ptrauth"(i64 2, i64 [[BLENDED]]) ] // CHECK-PTRAUTH: [[AUTHED_PTR:%.*]] = inttoptr i64 [[AUTHED_INT]] to ptr // CHECK-PTRAUTH: {{%.*}} = load volatile i8, ptr [[AUTHED_PTR]], align 8 // Second, we check that dynamic_cast is actually called once the type check is done. diff --git a/clang/test/CodeGenObjC/ptrauth-block-descriptor-pointer.m b/clang/test/CodeGenObjC/ptrauth-block-descriptor-pointer.m index b51670fd6459a..32cba9ff77034 100644 --- a/clang/test/CodeGenObjC/ptrauth-block-descriptor-pointer.m +++ b/clang/test/CodeGenObjC/ptrauth-block-descriptor-pointer.m @@ -29,7 +29,7 @@ void b(int p) { // CHECK: [[BLOCK_DESCRIPTOR_REF:%.*]] = getelementptr inbounds nuw <{ {{.*}} }>, ptr [[BLOCK]], i32 0, i32 4 // CHECK: [[BLOCK_DESCRIPTOR_REF_INT:%.*]] = ptrtoint ptr [[BLOCK_DESCRIPTOR_REF]] to i64 // CHECK: [[BLENDED:%.*]] = call i64 @llvm.ptrauth.blend(i64 [[BLOCK_DESCRIPTOR_REF_INT]], i64 49339) - // CHECK: [[SIGNED_REF:%.*]] = call i64 @llvm.ptrauth.sign(i64 ptrtoint (ptr @"__block_descriptor_36_e5_v8\01?0l" to i64), i32 2, i64 [[BLENDED]]) + // CHECK: [[SIGNED_REF:%.*]] = call i64 @llvm.ptrauth.sign(i64 ptrtoint (ptr @"__block_descriptor_36_e5_v8\01?0l" to i64)) [ "ptrauth"(i64 2, i64 [[BLENDED]]) ] // CHECK: [[SIGNED_REF_PTR:%.*]] = inttoptr i64 [[SIGNED_REF]] to ptr // CHECK: store ptr [[SIGNED_REF_PTR]], ptr [[BLOCK_DESCRIPTOR_REF]] diff --git a/clang/test/CodeGenObjC/ptrauth-block-isa.m b/clang/test/CodeGenObjC/ptrauth-block-isa.m index 248e57769ba1e..7904274300c09 100644 --- a/clang/test/CodeGenObjC/ptrauth-block-isa.m +++ b/clang/test/CodeGenObjC/ptrauth-block-isa.m @@ -17,7 +17,7 @@ void test_block_literal(int i) { // CHECK: [[ISAPTRADDR:%.*]] = getelementptr inbounds nuw [[BLOCK_T]], ptr [[BLOCK]], i32 0, i32 0 // CHECK-NEXT: [[ISAPTRADDR_I:%.*]] = ptrtoint ptr [[ISAPTRADDR]] to i64 // CHECK-NEXT: [[ISADISCRIMINATOR:%.*]] = call i64 @llvm.ptrauth.blend(i64 [[ISAPTRADDR_I]], i64 27361) - // CHECK-NEXT: [[SIGNEDISA:%.*]] = call i64 @llvm.ptrauth.sign(i64 ptrtoint (ptr @_NSConcreteStackBlock to i64), i32 2, i64 [[ISADISCRIMINATOR]]) + // CHECK-NEXT: [[SIGNEDISA:%.*]] = call i64 @llvm.ptrauth.sign(i64 ptrtoint (ptr @_NSConcreteStackBlock to i64)) [ "ptrauth"(i64 2, i64 [[ISADISCRIMINATOR]]) ] // CHECK-NEXT: [[SIGNEDISAPTR:%.*]] = inttoptr i64 [[SIGNEDISA]] to ptr // CHECK-NEXT: store ptr [[SIGNEDISAPTR]], ptr [[ISAPTRADDR]] use_block(^{return i;}); @@ -32,7 +32,7 @@ void test_conversion(id a) { // CHECK: [[ISAPTRADDR:%.*]] = getelementptr inbounds nuw [[BLOCK_T]], ptr [[BLOCK]], i32 0, i32 0 // CHECK-NEXT: [[ISAPTRADDR_I:%.*]] = ptrtoint ptr [[ISAPTRADDR]] to i64 // CHECK-NEXT: [[ISADISCRIMINATOR:%.*]] = call i64 @llvm.ptrauth.blend(i64 [[ISAPTRADDR_I]], i64 27361) - // CHECK-NEXT: [[SIGNEDISA:%.*]] = call i64 @llvm.ptrauth.sign(i64 ptrtoint (ptr @_NSConcreteStackBlock to i64), i32 2, i64 [[ISADISCRIMINATOR]]) + // CHECK-NEXT: [[SIGNEDISA:%.*]] = call i64 @llvm.ptrauth.sign(i64 ptrtoint (ptr @_NSConcreteStackBlock to i64)) [ "ptrauth"(i64 2, i64 [[ISADISCRIMINATOR]]) ] // CHECK-NEXT: [[SIGNEDISAPTR:%.*]] = inttoptr i64 [[SIGNEDISA]] to ptr // CHECK-NEXT: store ptr [[SIGNEDISAPTR]], ptr [[ISAPTRADDR]] test_conversion_helper(^{ diff --git a/clang/test/CodeGenObjC/ptrauth-class.m b/clang/test/CodeGenObjC/ptrauth-class.m index c5ad03665f2a7..78315159c7318 100644 --- a/clang/test/CodeGenObjC/ptrauth-class.m +++ b/clang/test/CodeGenObjC/ptrauth-class.m @@ -34,7 +34,7 @@ void setTestStructIsa(struct TestStruct *t, Class c) { // CHECK: [[CAST_ISA_SLOT:%.*]] = ptrtoint ptr [[ISA_SLOT]] to i64 // CHECK: [[BLENDED_VALUE:%.*]] = call i64 @llvm.ptrauth.blend(i64 [[CAST_ISA_SLOT]], i64 1234) // CHECK: [[CAST_C:%.*]] = ptrtoint ptr [[C]] to i64 - // CHECK: [[AUTHENTICATED:%.*]] = call i64 @llvm.ptrauth.sign(i64 [[CAST_C]], i32 2, i64 [[BLENDED_VALUE]]) + // CHECK: [[AUTHENTICATED:%.*]] = call i64 @llvm.ptrauth.sign(i64 [[CAST_C]]) [ "ptrauth"(i64 2, i64 [[BLENDED_VALUE]]) ] } // CHECK-LABEL: define void @setTestClassIsa(ptr %t, ptr %c) #0 { @@ -51,7 +51,7 @@ void setTestClassIsa(TestClass *t, Class c) { // CHECK: [[CAST_ISA_SLOT:%.*]] = ptrtoint ptr [[ADDED_PTR]] to i64 // CHECK: [[BLENDED_VALUE:%.*]] = call i64 @llvm.ptrauth.blend(i64 [[CAST_ISA_SLOT]], i64 1234) // CHECK: [[CAST_C_VALUE:%.*]] = ptrtoint ptr [[C_VALUE]] to i64 - // CHECK: [[SIGNED:%.*]] = call i64 @llvm.ptrauth.sign(i64 [[CAST_C_VALUE]], i32 2, i64 [[BLENDED_VALUE]]) + // CHECK: [[SIGNED:%.*]] = call i64 @llvm.ptrauth.sign(i64 [[CAST_C_VALUE]]) [ "ptrauth"(i64 2, i64 [[BLENDED_VALUE]]) ] } // CHECK-LABEL: define ptr @getTestStructIsa(ptr %t) #0 { @@ -64,7 +64,7 @@ Class getTestStructIsa(struct TestStruct *t) { // CHECK: [[CAST_ISA_SLOT:%.*]] = ptrtoint ptr %isa to i64 // CHECK: [[BLENDED_VALUE:%.*]] = call i64 @llvm.ptrauth.blend(i64 [[CAST_ISA_SLOT]], i64 1234) // CHECK: [[CAST_ISA_VALUE:%.*]] = ptrtoint ptr [[ISA_VALUE]] to i64 - // CHECK: [[SIGNED_VALUE:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[CAST_ISA_VALUE]], i32 2, i64 [[BLENDED_VALUE]]) + // CHECK: [[SIGNED_VALUE:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[CAST_ISA_VALUE]]) [ "ptrauth"(i64 2, i64 [[BLENDED_VALUE]]) ] } // CHECK-LABEL: define ptr @getTestClassIsa(ptr %t) #0 { @@ -80,7 +80,7 @@ Class getTestClassIsa(TestClass *t) { // CHECK: [[BLENDED_VALUE:%.*]] = call i64 @llvm.ptrauth.blend(i64 [[INT_VALUE]], i64 1234) // CHECK: [[NULL_CHECK:%.*]] = icmp ne ptr [[LOADED_VALUE]], null // CHECK: [[CAST_VALUE:%.*]] = ptrtoint ptr [[LOADED_VALUE]] to i64 - // CHECK: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[CAST_VALUE]], i32 2, i64 [[BLENDED_VALUE]]) + // CHECK: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[CAST_VALUE]]) [ "ptrauth"(i64 2, i64 [[BLENDED_VALUE]]) ] } // Just enough to verify we do actually authenticate qualified Class @@ -97,7 +97,7 @@ Class getTestConstClassIsa(TestConstClass *t) { // CHECK: [[BLENDED_VALUE:%.*]] = call i64 @llvm.ptrauth.blend(i64 [[INT_VALUE]], i64 1234) // CHECK: [[NULL_CHECK:%.*]] = icmp ne ptr [[LOADED_VALUE]], null // CHECK: [[CAST_VALUE:%.*]] = ptrtoint ptr [[LOADED_VALUE]] to i64 - // CHECK: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[CAST_VALUE]], i32 2, i64 [[BLENDED_VALUE]]) + // CHECK: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[CAST_VALUE]]) [ "ptrauth"(i64 2, i64 [[BLENDED_VALUE]]) ] } #endif diff --git a/clang/test/CodeGenObjC/ptrauth-objc-interface-selector.m b/clang/test/CodeGenObjC/ptrauth-objc-interface-selector.m index 15f7d03a0ba2d..f6b64b6f27df5 100644 --- a/clang/test/CodeGenObjC/ptrauth-objc-interface-selector.m +++ b/clang/test/CodeGenObjC/ptrauth-objc-interface-selector.m @@ -33,42 +33,42 @@ @interface Test { // CHECK-AUTHENTICATED-SEL-LABEL: define internal ptr @"\01-[Test test:]" // CHECK-AUTHENTICATED-SEL: {{%.*}} = call i64 @llvm.ptrauth.blend(i64 {{%.*}}, i64 22466) // CHECK-AUTHENTICATED-SEL: {{%.*}} = call i64 @llvm.ptrauth.blend(i64 {{%.*}}, i64 22466) -// CHECK-AUTHENTICATED-SEL: {{%.*}} = call i64 @llvm.ptrauth.resign(i64 {{%.*}}, i32 3, i64 {{%.*}}, i32 3, i64 {{%.*}}) +// CHECK-AUTHENTICATED-SEL: {{%.*}} = call i64 @llvm.ptrauth.resign(i64 {{%.*}}) [ "ptrauth"(i64 3, i64 {{%.*}}), "ptrauth"(i64 3, i64 {{%.*}}) ] // CHECK-AUTHENTICATED-SEL: {{%.*}} = load volatile ptr, ptr {{%.*}}, align 8 // CHECK-AUTHENTICATED-SEL: {{%.*}} = call i64 @llvm.ptrauth.blend(i64 {{%.*}}, i64 22466) // CHECK-AUTHENTICATED-SEL: {{%.*}} = call i64 @llvm.ptrauth.blend(i64 {{%.*}}, i64 22466) -// CHECK-AUTHENTICATED-SEL: {{%.*}} = call i64 @llvm.ptrauth.resign(i64 {{%.*}}, i32 3, i64 {{%.*}}, i32 3, i64 {{%.*}}) +// CHECK-AUTHENTICATED-SEL: {{%.*}} = call i64 @llvm.ptrauth.resign(i64 {{%.*}}) [ "ptrauth"(i64 3, i64 {{%.*}}), "ptrauth"(i64 3, i64 {{%.*}}) ] // CHECK-AUTHENTICATED-SEL: {{%.*}} = call i64 @llvm.ptrauth.blend(i64 {{%.*}}, i64 22467) // CHECK-AUTHENTICATED-SEL: {{%.*}} = ptrtoint ptr {{%.*}} to i64 // CHECK-AUTHENTICATED-SEL: {{%.*}} = call i64 @llvm.ptrauth.blend(i64 {{%.*}}, i64 22467) // CHECK-AUTHENTICATED-SEL: {{%.*}} = ptrtoint ptr {{%.*}} to i64 -// CHECK-AUTHENTICATED-SEL: {{%.*}} = call i64 @llvm.ptrauth.resign(i64 {{%.*}}, i32 3, i64 {{%.*}}, i32 3, i64 {{%.*}}) +// CHECK-AUTHENTICATED-SEL: {{%.*}} = call i64 @llvm.ptrauth.resign(i64 {{%.*}}) [ "ptrauth"(i64 3, i64 {{%.*}}), "ptrauth"(i64 3, i64 {{%.*}}) ] // CHECK-AUTHENTICATED-SEL: {{%.*}} = call i64 @llvm.ptrauth.blend(i64 {{%.*}}, i64 22466) -// CHECK-AUTHENTICATED-SEL: {{%.*}} = call i64 @llvm.ptrauth.auth(i64 {{%.*}}, i32 3, i64 {{%.*}}) +// CHECK-AUTHENTICATED-SEL: {{%.*}} = call i64 @llvm.ptrauth.auth(i64 {{%.*}}) [ "ptrauth"(i64 3, i64 {{%.*}}) ] // CHECK-AUTHENTICATED-SEL-LABEL: define internal ptr @"\01-[Test auto_sel_property]" // CHECK-AUTHENTICATED-SEL: {{%.*}} = call i64 @llvm.ptrauth.blend(i64 {{%.*}}, i64 22466) -// CHECK-AUTHENTICATED-SEL: {{%.*}} = call i64 @llvm.ptrauth.auth(i64 {{%.*}}, i32 3, i64 {{%.*}}) +// CHECK-AUTHENTICATED-SEL: {{%.*}} = call i64 @llvm.ptrauth.auth(i64 {{%.*}}) [ "ptrauth"(i64 3, i64 {{%.*}}) ] // CHECK-AUTHENTICATED-SEL-LABEL: define internal void @"\01-[Test setAuto_sel_property:]" // CHECK-AUTHENTICATED-SEL: {{%.*}} = call i64 @llvm.ptrauth.blend(i64 {{%.*}}, i64 22466) -// CHECK-AUTHENTICATED-SEL: {{%.*}} = call i64 @llvm.ptrauth.sign(i64 {{%.*}}, i32 3, i64 {{%.*}}) +// CHECK-AUTHENTICATED-SEL: {{%.*}} = call i64 @llvm.ptrauth.sign(i64 {{%.*}}) [ "ptrauth"(i64 3, i64 {{%.*}}) ] // CHECK-AUTHENTICATED-SEL-LABEL: define internal ptr @"\01-[Test const_auto_sel_property]" // CHECK-AUTHENTICATED-SEL: {{%.*}} = call i64 @llvm.ptrauth.blend(i64 {{%.*}}, i64 22466) -// CHECK-AUTHENTICATED-SEL: {{%.*}} = call i64 @llvm.ptrauth.auth(i64 {{%.*}}, i32 3, i64 {{%.*}}) +// CHECK-AUTHENTICATED-SEL: {{%.*}} = call i64 @llvm.ptrauth.auth(i64 {{%.*}}) [ "ptrauth"(i64 3, i64 {{%.*}}) ] // CHECK-AUTHENTICATED-SEL-LABEL: define internal void @"\01-[Test setConst_auto_sel_property:]" // CHECK-AUTHENTICATED-SEL: {{%.*}} = call i64 @llvm.ptrauth.blend(i64 {{%.*}}, i64 22466) -// CHECK-AUTHENTICATED-SEL: {{%.*}} = call i64 @llvm.ptrauth.sign(i64 {{%.*}}, i32 3, i64 {{%.*}}) +// CHECK-AUTHENTICATED-SEL: {{%.*}} = call i64 @llvm.ptrauth.sign(i64 {{%.*}}) [ "ptrauth"(i64 3, i64 {{%.*}}) ] // CHECK-AUTHENTICATED-SEL-LABEL: define internal ptr @"\01-[Test volatile_auto_sel_property]" // CHECK-AUTHENTICATED-SEL: {{%.*}} = call i64 @llvm.ptrauth.blend(i64 {{%.*}}, i64 22466) -// CHECK-AUTHENTICATED-SEL: {{%.*}} = call i64 @llvm.ptrauth.auth(i64 {{%.*}}, i32 3, i64 {{%.*}}) +// CHECK-AUTHENTICATED-SEL: {{%.*}} = call i64 @llvm.ptrauth.auth(i64 {{%.*}}) [ "ptrauth"(i64 3, i64 {{%.*}}) ] // CHECK-AUTHENTICATED-SEL-LABEL: define internal void @"\01-[Test setVolatile_auto_sel_property:]" // CHECK-AUTHENTICATED-SEL: {{%.*}} = call i64 @llvm.ptrauth.blend(i64 {{%.*}}, i64 22466) -// CHECK-AUTHENTICATED-SEL: {{%.*}} = call i64 @llvm.ptrauth.sign(i64 {{%.*}}, i32 3, i64 {{%.*}}) +// CHECK-AUTHENTICATED-SEL: {{%.*}} = call i64 @llvm.ptrauth.sign(i64 {{%.*}}) [ "ptrauth"(i64 3, i64 {{%.*}}) ] @implementation Test - (SEL)test:(Test *)in { @@ -87,7 +87,7 @@ void auto_sel(Test *out, Test *in) { // CHECK-AUTHENTICATED-SEL: [[CAST_SRC_ADDR:%.*]] = ptrtoint ptr [[SRC_ADDR:%.*]] to i64 // CHECK-AUTHENTICATED-SEL: [[SRC_DESCRIMINATOR:%.*]] = call i64 @llvm.ptrauth.blend(i64 [[CAST_SRC_ADDR]], i64 22466) // CHECK-AUTHENTICATED-SEL: [[SRC_SEL:%.*]] = ptrtoint ptr [[SRC_SEL_ADDR:%.*]] to i64 -// CHECK-AUTHENTICATED-SEL: {{%.*}} = call i64 @llvm.ptrauth.resign(i64 [[SRC_SEL]], i32 3, i64 [[DST_DESCRIMINATOR]], i32 3, i64 [[SRC_DESCRIMINATOR]]) +// CHECK-AUTHENTICATED-SEL: {{%.*}} = call i64 @llvm.ptrauth.resign(i64 [[SRC_SEL]]) [ "ptrauth"(i64 3, i64 [[DST_DESCRIMINATOR]]), "ptrauth"(i64 3, i64 [[SRC_DESCRIMINATOR]]) ] // CHECK-UNAUTHENTICATED-SEL-LABEL: define void @auto_sel SEL const_auto_sel(Test *in) { @@ -97,7 +97,7 @@ SEL const_auto_sel(Test *in) { // CHECK-AUTHENTICATED-SEL-LABEL: define ptr @const_auto_sel // CHECK-AUTHENTICATED-SEL: {{%.*}} = call i64 @llvm.ptrauth.blend(i64 {{%.*}}, i64 22466) // CHECK-AUTHENTICATED-SEL: {{%.*}} = ptrtoint ptr {{%.*}} to i64 -// CHECK-AUTHENTICATED-SEL: [[AUTHENTICATED:%.*]] = call i64 @llvm.ptrauth.auth(i64 {{%.*}}, i32 3, i64 {{%.*}}) +// CHECK-AUTHENTICATED-SEL: [[AUTHENTICATED:%.*]] = call i64 @llvm.ptrauth.auth(i64 {{%.*}}) [ "ptrauth"(i64 3, i64 {{%.*}}) ] // CHECK-AUTHENTICATED-SEL: [[RESULT:%.*]] = inttoptr i64 [[AUTHENTICATED]] to ptr void volatile_auto_sel(Test *out, Test *in) { @@ -109,7 +109,7 @@ void volatile_auto_sel(Test *out, Test *in) { // CHECK-AUTHENTICATED-SEL: [[CAST_SRC_ADDR:%.*]] = ptrtoint ptr [[SRC_ADDR:%.*]] to i64 // CHECK-AUTHENTICATED-SEL: [[SRC_DESCRIMINATOR:%.*]] = call i64 @llvm.ptrauth.blend(i64 [[CAST_SRC_ADDR]], i64 22466) // CHECK-AUTHENTICATED-SEL: [[SRC_SEL:%.*]] = ptrtoint ptr [[SRC_SEL_ADDR:%.*]] to i64 -// CHECK-AUTHENTICATED-SEL: {{%.*}} = call i64 @llvm.ptrauth.resign(i64 [[SRC_SEL]], i32 3, i64 [[DST_DESCRIMINATOR]], i32 3, i64 [[SRC_DESCRIMINATOR]]) +// CHECK-AUTHENTICATED-SEL: {{%.*}} = call i64 @llvm.ptrauth.resign(i64 [[SRC_SEL]]) [ "ptrauth"(i64 3, i64 [[DST_DESCRIMINATOR]]), "ptrauth"(i64 3, i64 [[SRC_DESCRIMINATOR]]) ] void manual(Test *out, Test *in) { out->manual = in->manual; @@ -120,11 +120,11 @@ void manual(Test *out, Test *in) { // CHECK-AUTHENTICATED-SEL: [[CAST_SRC_ADDR:%.*]] = ptrtoint ptr [[SRC_ADDR:%.*]] to i64 // CHECK-AUTHENTICATED-SEL: [[SRC_DESCRIMINATOR:%.*]] = call i64 @llvm.ptrauth.blend(i64 [[CAST_SRC_ADDR]], i64 22467) // CHECK-AUTHENTICATED-SEL: [[SRC_SEL:%.*]] = ptrtoint ptr [[SRC_SEL_ADDR:%.*]] to i64 -// CHECK-AUTHENTICATED-SEL: {{%.*}} = call i64 @llvm.ptrauth.resign(i64 [[SRC_SEL]], i32 3, i64 [[DST_DESCRIMINATOR]], i32 3, i64 [[SRC_DESCRIMINATOR]]) +// CHECK-AUTHENTICATED-SEL: {{%.*}} = call i64 @llvm.ptrauth.resign(i64 [[SRC_SEL]]) [ "ptrauth"(i64 3, i64 [[DST_DESCRIMINATOR]]), "ptrauth"(i64 3, i64 [[SRC_DESCRIMINATOR]]) ] // CHECK-UNAUTHENTICATED-SEL-LABEL: define void @manual // CHECK-UNAUTHENTICATED-SEL: [[DST_DESCRIMINATOR:%.*]] = call i64 @llvm.ptrauth.blend(i64 [[CAST_DST_ADDR:%.*]], i64 22467) // CHECK-UNAUTHENTICATED-SEL: [[CAST_SRC_ADDR:%.*]] = ptrtoint ptr [[SRC_ADDR:%.*]] to i64 // CHECK-UNAUTHENTICATED-SEL: [[SRC_DESCRIMINATOR:%.*]] = call i64 @llvm.ptrauth.blend(i64 [[CAST_SRC_ADDR]], i64 22467) // CHECK-UNAUTHENTICATED-SEL: [[SRC_SEL:%.*]] = ptrtoint ptr [[SRC_SEL_ADDR:%.*]] to i64 -// CHECK-UNAUTHENTICATED-SEL: {{%.*}} = call i64 @llvm.ptrauth.resign(i64 [[SRC_SEL]], i32 3, i64 [[DST_DESCRIMINATOR]], i32 3, i64 [[SRC_DESCRIMINATOR]]) +// CHECK-UNAUTHENTICATED-SEL: {{%.*}} = call i64 @llvm.ptrauth.resign(i64 [[SRC_SEL]]) [ "ptrauth"(i64 3, i64 [[DST_DESCRIMINATOR]]), "ptrauth"(i64 3, i64 [[SRC_DESCRIMINATOR]]) ] diff --git a/clang/test/CodeGenObjC/ptrauth-property-backing.m b/clang/test/CodeGenObjC/ptrauth-property-backing.m index 8c6bcb45e7446..dd873411c9f5a 100644 --- a/clang/test/CodeGenObjC/ptrauth-property-backing.m +++ b/clang/test/CodeGenObjC/ptrauth-property-backing.m @@ -24,12 +24,12 @@ @implementation Root // CHECK: [[LOAD:%.*]] = load atomic i64, ptr [[ADDR:%.*]] unordered // CHECK: [[CAST_ADDR:%.*]] = ptrtoint ptr [[ADDR]] to i64 // CHECK: [[BLEND:%.*]] = call i64 @llvm.ptrauth.blend(i64 [[CAST_ADDR]], i64 1) -// CHECK: [[RESULT:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[LOAD]], i32 1, i64 [[BLEND]]) +// CHECK: [[RESULT:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[LOAD]]) [ "ptrauth"(i64 1, i64 [[BLEND]]) ] // CHECK-LABEL: define internal void @"\01-[Root setField1:]" // CHECK: [[CAST_ADDR:%.*]] = ptrtoint ptr [[ADDR:%.*]] to i64 // CHECK: [[BLEND:%.*]] = call i64 @llvm.ptrauth.blend(i64 [[CAST_ADDR]], i64 1) -// CHECK: [[RESULT:%.*]] = call i64 @llvm.ptrauth.sign(i64 [[VALUE:%.*]], i32 1, i64 [[BLEND]]) +// CHECK: [[RESULT:%.*]] = call i64 @llvm.ptrauth.sign(i64 [[VALUE:%.*]]) [ "ptrauth"(i64 1, i64 [[BLEND]]) ] // CHECK: [[PHI:%.*]] = phi i64 [ 0, {{%.*}} ], [ [[RESULT]], {{%.*}} ] // CHECK: store atomic i64 [[PHI]], ptr [[ADDR]] unordered @@ -39,13 +39,13 @@ @implementation Root // CHECK: [[CAST_ADDR:%.*]] = ptrtoint ptr [[ADDR]] to i64 // CHECK: [[BLEND:%.*]] = call i64 @llvm.ptrauth.blend(i64 [[CAST_ADDR:%.*]], i64 1) // CHECK: [[VALUE:%.*]] = ptrtoint ptr [[LOAD]] to i64 -// CHECK: [[RESULT:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VALUE]], i32 1, i64 [[BLEND]]) +// CHECK: [[RESULT:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VALUE]]) [ "ptrauth"(i64 1, i64 [[BLEND]]) ] // CHECK-LABEL: define internal void @"\01-[Root setField2:]" // CHECK: [[CAST_ADDR:%.*]] = ptrtoint ptr [[ADDR:%.*]] to i64 // CHECK: [[BLEND:%.*]] = call i64 @llvm.ptrauth.blend(i64 [[CAST_ADDR]], i64 1) // CHECK: [[CAST_VALUE:%.*]] = ptrtoint ptr [[VALUE:%.*]] to i64 -// CHECK: [[SIGNED:%.*]] = call i64 @llvm.ptrauth.sign(i64 [[CAST_VALUE]], i32 1, i64 [[BLEND]]) +// CHECK: [[SIGNED:%.*]] = call i64 @llvm.ptrauth.sign(i64 [[CAST_VALUE]]) [ "ptrauth"(i64 1, i64 [[BLEND]]) ] // CHECK: [[RESULT:%.*]] = inttoptr i64 [[SIGNED]] to ptr // CHECK: [[PHI:%.*]] = phi ptr [ null, {{%.*}} ], [ [[RESULT]], {{%.*}} ] // CHECK: store ptr [[PHI]], ptr [[ADDR]] @@ -54,13 +54,13 @@ @implementation Root // CHECK: [[VALUE:%.*]] = load atomic i64, ptr [[ADDR:%.*]] unordered, align 8 // CHECK: [[CASTED_ADDR:%.*]] = ptrtoint ptr [[ADDR]] to i64 // CHECK: [[BLENDED:%.*]] = call i64 @llvm.ptrauth.blend(i64 [[CASTED_ADDR]], i64 1) -// CHECK: {{%.*}} = call i64 @llvm.ptrauth.resign(i64 [[VALUE]], i32 1, i64 [[BLENDED]], i32 0, i64 0 +// CHECK: {{%.*}} = call i64 @llvm.ptrauth.resign(i64 [[VALUE]]) [ "ptrauth"(i64 1, i64 [[BLENDED]]), "ptrauth"(i64 0, i64 0) ] // CHECK-LABEL: define internal void @"\01-[Root setField3:]" // CHECK: [[VALUE:%.*]] = load i64, ptr {{%.*}}, align 8 // CHECK: [[CASTED_ADDR:%.*]] = ptrtoint ptr {{%.*}} to i64 // CHECK: [[BLENDED:%.*]] = call i64 @llvm.ptrauth.blend(i64 [[CASTED_ADDR]], i64 1) -// CHECK: {{%.*}} = call i64 @llvm.ptrauth.resign(i64 [[VALUE]], i32 0, i64 0, i32 1, i64 [[BLENDED]]) +// CHECK: {{%.*}} = call i64 @llvm.ptrauth.resign(i64 [[VALUE]]) [ "ptrauth"(i64 0, i64 0), "ptrauth"(i64 1, i64 [[BLENDED]]) ] // CHECK: store atomic i64 // CHECK-LABEL: define internal ptr @"\01-[Root field4]" @@ -69,12 +69,12 @@ @implementation Root // CHECK: [[CASTED_ADDR:%.*]] = ptrtoint ptr [[ADDR]] to i64 // CHECK: [[BLENDED:%.*]] = call i64 @llvm.ptrauth.blend(i64 [[CASTED_ADDR]], i64 123) // CHECK: [[CAST_VALUE:%.*]] = ptrtoint ptr [[VALUE]] to i64 -// CHECK: {{%.*}} = call i64 @llvm.ptrauth.resign(i64 [[CAST_VALUE]], i32 1, i64 [[BLENDED]], i32 0, i64 0) +// CHECK: {{%.*}} = call i64 @llvm.ptrauth.resign(i64 [[CAST_VALUE]]) [ "ptrauth"(i64 1, i64 [[BLENDED]]), "ptrauth"(i64 0, i64 0) ] // CHECK-LABEL: define internal void @"\01-[Root setField4:]" // CHECK: [[CAST_ADDR:%.*]] = ptrtoint ptr {{%.*}} to i64 // CHECK: [[BLENDED:%.*]] = call i64 @llvm.ptrauth.blend(i64 [[CAST_ADDR]], i64 123) // CHECK: resign.nonnull: // CHECK: [[VALUE:%.*]] = ptrtoint ptr %1 to i64 -// CHECK: {{%.*}} = call i64 @llvm.ptrauth.resign(i64 [[VALUE]], i32 0, i64 0, i32 1, i64 [[BLENDED]]) +// CHECK: {{%.*}} = call i64 @llvm.ptrauth.resign(i64 [[VALUE]]) [ "ptrauth"(i64 0, i64 0), "ptrauth"(i64 1, i64 [[BLENDED]]) ] diff --git a/clang/test/CodeGenObjCXX/ptrauth-objc-interface-selector.mm b/clang/test/CodeGenObjCXX/ptrauth-objc-interface-selector.mm index fc90f5ffcbcf6..588538f25de44 100644 --- a/clang/test/CodeGenObjCXX/ptrauth-objc-interface-selector.mm +++ b/clang/test/CodeGenObjCXX/ptrauth-objc-interface-selector.mm @@ -43,7 +43,7 @@ void auto_sel(Test *out, Test *in) { // CHECK-AUTHENTICATED-SEL: [[CAST_SRC_ADDR:%.*]] = ptrtoint ptr [[SRC_ADDR:%.*]] to i64 // CHECK-AUTHENTICATED-SEL: [[SRC_DESCRIMINATOR:%.*]] = call i64 @llvm.ptrauth.blend(i64 [[CAST_SRC_ADDR]], i64 22466) // CHECK-AUTHENTICATED-SEL: [[SRC_SEL:%.*]] = ptrtoint ptr [[SRC_SEL_ADDR:%.*]] to i64 -// CHECK-AUTHENTICATED-SEL: {{%.*}} = call i64 @llvm.ptrauth.resign(i64 [[SRC_SEL]], i32 3, i64 [[DST_DESCRIMINATOR]], i32 3, i64 [[SRC_DESCRIMINATOR]]) +// CHECK-AUTHENTICATED-SEL: {{%.*}} = call i64 @llvm.ptrauth.resign(i64 [[SRC_SEL]]) [ "ptrauth"(i64 3, i64 [[DST_DESCRIMINATOR]]), "ptrauth"(i64 3, i64 [[SRC_DESCRIMINATOR]]) ] // CHECK-UNAUTHENTICATED-SEL: define void @auto_sel SEL const_auto_sel(Test *in) { @@ -54,7 +54,7 @@ SEL const_auto_sel(Test *in) { // CHECK-AUTHENTICATED-SEL: define ptr @const_auto_sel // CHECK-AUTHENTICATED-SEL: {{%.*}} = call i64 @llvm.ptrauth.blend(i64 {{%.*}}, i64 22466) // CHECK-AUTHENTICATED-SEL: {{%.*}} = ptrtoint ptr {{%.*}} to i64 -// CHECK-AUTHENTICATED-SEL: [[AUTHENTICATED:%.*]] = call i64 @llvm.ptrauth.auth(i64 {{%.*}}, i32 3, i64 {{%.*}}) +// CHECK-AUTHENTICATED-SEL: [[AUTHENTICATED:%.*]] = call i64 @llvm.ptrauth.auth(i64 {{%.*}}) [ "ptrauth"(i64 3, i64 {{%.*}}) ] // CHECK-AUTHENTICATED-SEL: [[RESULT:%.*]] = inttoptr i64 [[AUTHENTICATED]] to ptr void volatile_auto_sel(Test *out, Test *in) { @@ -67,7 +67,7 @@ void volatile_auto_sel(Test *out, Test *in) { // CHECK-AUTHENTICATED-SEL: [[CAST_SRC_ADDR:%.*]] = ptrtoint ptr [[SRC_ADDR:%.*]] to i64 // CHECK-AUTHENTICATED-SEL: [[SRC_DESCRIMINATOR:%.*]] = call i64 @llvm.ptrauth.blend(i64 [[CAST_SRC_ADDR]], i64 22466) // CHECK-AUTHENTICATED-SEL: [[SRC_SEL:%.*]] = ptrtoint ptr [[SRC_SEL_ADDR:%.*]] to i64 -// CHECK-AUTHENTICATED-SEL: {{%.*}} = call i64 @llvm.ptrauth.resign(i64 [[SRC_SEL]], i32 3, i64 [[DST_DESCRIMINATOR]], i32 3, i64 [[SRC_DESCRIMINATOR]]) +// CHECK-AUTHENTICATED-SEL: {{%.*}} = call i64 @llvm.ptrauth.resign(i64 [[SRC_SEL]]) [ "ptrauth"(i64 3, i64 [[DST_DESCRIMINATOR]]), "ptrauth"(i64 3, i64 [[SRC_DESCRIMINATOR]]) ] void manual(Test *out, Test *in) { out->manual = in->manual; @@ -78,13 +78,13 @@ void manual(Test *out, Test *in) { // CHECK-AUTHENTICATED-SEL: [[CAST_SRC_ADDR:%.*]] = ptrtoint ptr [[SRC_ADDR:%.*]] to i64 // CHECK-AUTHENTICATED-SEL: [[SRC_DESCRIMINATOR:%.*]] = call i64 @llvm.ptrauth.blend(i64 [[CAST_SRC_ADDR]], i64 22467) // CHECK-AUTHENTICATED-SEL: [[SRC_SEL:%.*]] = ptrtoint ptr [[SRC_SEL_ADDR:%.*]] to i64 -// CHECK-AUTHENTICATED-SEL: {{%.*}} = call i64 @llvm.ptrauth.resign(i64 [[SRC_SEL]], i32 3, i64 [[DST_DESCRIMINATOR]], i32 3, i64 [[SRC_DESCRIMINATOR]]) +// CHECK-AUTHENTICATED-SEL: {{%.*}} = call i64 @llvm.ptrauth.resign(i64 [[SRC_SEL]]) [ "ptrauth"(i64 3, i64 [[DST_DESCRIMINATOR]]), "ptrauth"(i64 3, i64 [[SRC_DESCRIMINATOR]]) ] // CHECK-UNAUTHENTICATED-SEL: define void @manual // CHECK-UNAUTHENTICATED-SEL: [[DST_DESCRIMINATOR:%.*]] = call i64 @llvm.ptrauth.blend(i64 [[CAST_DST_ADDR:%.*]], i64 22467) // CHECK-UNAUTHENTICATED-SEL: [[CAST_SRC_ADDR:%.*]] = ptrtoint ptr [[SRC_ADDR:%.*]] to i64 // CHECK-UNAUTHENTICATED-SEL: [[SRC_DESCRIMINATOR:%.*]] = call i64 @llvm.ptrauth.blend(i64 [[CAST_SRC_ADDR]], i64 22467) // CHECK-UNAUTHENTICATED-SEL: [[SRC_SEL:%.*]] = ptrtoint ptr [[SRC_SEL_ADDR:%.*]] to i64 -// CHECK-UNAUTHENTICATED-SEL: {{%.*}} = call i64 @llvm.ptrauth.resign(i64 [[SRC_SEL]], i32 3, i64 [[DST_DESCRIMINATOR]], i32 3, i64 [[SRC_DESCRIMINATOR]]) +// CHECK-UNAUTHENTICATED-SEL: {{%.*}} = call i64 @llvm.ptrauth.resign(i64 [[SRC_SEL]]) [ "ptrauth"(i64 3, i64 [[DST_DESCRIMINATOR]]), "ptrauth"(i64 3, i64 [[SRC_DESCRIMINATOR]]) ] } diff --git a/llvm/include/llvm/CodeGen/ISDOpcodes.h b/llvm/include/llvm/CodeGen/ISDOpcodes.h index a6bc2721f4486..9cc9a4d20320c 100644 --- a/llvm/include/llvm/CodeGen/ISDOpcodes.h +++ b/llvm/include/llvm/CodeGen/ISDOpcodes.h @@ -106,6 +106,9 @@ enum NodeType { PtrAuthBundle, /// Various PtrAuth operations. + PtrAuthAuth, + PtrAuthSign, + PtrAuthResign, PtrAuthStrip, /// The address of the GOT diff --git a/llvm/include/llvm/IR/Intrinsics.td b/llvm/include/llvm/IR/Intrinsics.td index f99dcdbfec4f6..b1e49aa61bfd4 100644 --- a/llvm/include/llvm/IR/Intrinsics.td +++ b/llvm/include/llvm/IR/Intrinsics.td @@ -2858,32 +2858,27 @@ def int_vector_partial_reduce_fadd : DefaultAttrsIntrinsic<[LLVMMatchType<0>], //===----------------- Pointer Authentication Intrinsics ------------------===// // -// Sign an unauthenticated pointer using the specified key and discriminator, -// passed in that order. -// Returns the first argument, with some known bits replaced with a signature. +// Sign an unauthenticated pointer using the specified signing schema. +// Requires exactly one "ptrauth" call operand bundle specifying the schema. +// Returns the first argument, with embedded signature. def int_ptrauth_sign : - DefaultAttrsIntrinsic<[llvm_i64_ty], [llvm_i64_ty, llvm_i32_ty, llvm_i64_ty], - [IntrNoMem, ImmArg>]>; + DefaultAttrsIntrinsic<[llvm_i64_ty], [llvm_i64_ty], [IntrNoMem]>; -// Authenticate a signed pointer, using the specified key and discriminator. -// Returns the first argument, with the signature bits removed. +// Authenticate a signed pointer, using the specified signing schema. +// Requires exactly one "ptrauth" call operand bundle specifying the schema. +// Returns the first argument, with the signature removed. // The signature must be valid. -def int_ptrauth_auth : Intrinsic<[llvm_i64_ty], - [llvm_i64_ty, llvm_i32_ty, llvm_i64_ty], - [IntrNoMem,ImmArg>]>; +def int_ptrauth_auth : Intrinsic<[llvm_i64_ty], [llvm_i64_ty], [IntrNoMem]>; // Authenticate a signed pointer and resign it. -// The second (key) and third (discriminator) arguments specify the signing -// schema used for authenticating. -// The fourth and fifth arguments specify the schema used for signing. +// Requires exactly two "ptrauth" call operand bundles specifying the signing +// schemas. +// The first operand bundle specifies the schema used for authenticating. +// The second operand bundle specifies the schema used for signing. // The signature must be valid. // This is a combined form of @llvm.ptrauth.sign and @llvm.ptrauth.auth, with // an additional integrity guarantee on the intermediate value. -def int_ptrauth_resign : Intrinsic<[llvm_i64_ty], - [llvm_i64_ty, llvm_i32_ty, llvm_i64_ty, - llvm_i32_ty, llvm_i64_ty], - [IntrNoMem, ImmArg>, - ImmArg>]>; +def int_ptrauth_resign : Intrinsic<[llvm_i64_ty], [llvm_i64_ty], [IntrNoMem]>; // Strip the embedded signature out of a signed pointer. // Requires exactly one "ptrauth" call operand bundle carrying a diff --git a/llvm/include/llvm/Support/TargetOpcodes.def b/llvm/include/llvm/Support/TargetOpcodes.def index ff82b22c7fd68..9431d2320dbb1 100644 --- a/llvm/include/llvm/Support/TargetOpcodes.def +++ b/llvm/include/llvm/Support/TargetOpcodes.def @@ -338,6 +338,9 @@ HANDLE_TARGET_OPCODE(G_PTRAUTH_GLOBAL_VALUE) HANDLE_TARGET_OPCODE(G_PTRAUTH_BUNDLE) /// Various PtrAuth operations. +HANDLE_TARGET_OPCODE(G_PTRAUTH_AUTH) +HANDLE_TARGET_OPCODE(G_PTRAUTH_SIGN) +HANDLE_TARGET_OPCODE(G_PTRAUTH_RESIGN) HANDLE_TARGET_OPCODE(G_PTRAUTH_STRIP) /// Generic instruction to materialize the address of an object in the constant diff --git a/llvm/include/llvm/Target/GenericOpcodes.td b/llvm/include/llvm/Target/GenericOpcodes.td index 68ed3c91f4668..1d423faa2acd8 100644 --- a/llvm/include/llvm/Target/GenericOpcodes.td +++ b/llvm/include/llvm/Target/GenericOpcodes.td @@ -144,6 +144,24 @@ def G_PTRAUTH_BUNDLE : GenericInstruction { let variadicOpsType = type0; } +def G_PTRAUTH_AUTH : GenericInstruction { + let OutOperandList = (outs type0:$dst); + let InOperandList = (ins type0:$value, untyped_imm_0:$schema); + let hasSideEffects = 0; +} + +def G_PTRAUTH_SIGN : GenericInstruction { + let OutOperandList = (outs type0:$dst); + let InOperandList = (ins type0:$value, untyped_imm_0:$schema); + let hasSideEffects = 0; +} + +def G_PTRAUTH_RESIGN : GenericInstruction { + let OutOperandList = (outs type0:$dst); + let InOperandList = (ins type0:$value, untyped_imm_0:$old_schema, untyped_imm_0:$new_schema); + let hasSideEffects = 0; +} + def G_PTRAUTH_STRIP : GenericInstruction { let OutOperandList = (outs type0:$dst); let InOperandList = (ins type0:$value, untyped_imm_0:$schema); diff --git a/llvm/include/llvm/Target/GlobalISel/SelectionDAGCompat.td b/llvm/include/llvm/Target/GlobalISel/SelectionDAGCompat.td index b1f247b724d27..4d000ce1c393e 100644 --- a/llvm/include/llvm/Target/GlobalISel/SelectionDAGCompat.td +++ b/llvm/include/llvm/Target/GlobalISel/SelectionDAGCompat.td @@ -225,6 +225,9 @@ def : GINodeEquiv; def : GINodeEquiv; def : GINodeEquiv; +def : GINodeEquiv; +def : GINodeEquiv; +def : GINodeEquiv; def : GINodeEquiv; // Broadly speaking G_LOAD is equivalent to ISD::LOAD but there are some diff --git a/llvm/include/llvm/Target/TargetSelectionDAG.td b/llvm/include/llvm/Target/TargetSelectionDAG.td index 685f4c566f657..06dfcd5769b04 100644 --- a/llvm/include/llvm/Target/TargetSelectionDAG.td +++ b/llvm/include/llvm/Target/TargetSelectionDAG.td @@ -919,9 +919,15 @@ def SDTPtrAuthBundle : SDTypeProfile<1, -1, [ def SDTPtrAuthOneSchema : SDTypeProfile<1, 2, [ // auth, sign, strip SDTCisVT<0, i64>, SDTCisVT<1, i64>, SDTCisVT<2, untyped> ]>; +def SDTPtrAuthTwoSchemas : SDTypeProfile<1, 3, [ // resign + SDTCisVT<0, i64>, SDTCisVT<1, i64>, SDTCisVT<2, untyped>, SDTCisVT<3, untyped> +]>; def ptrauth_bundle : SDNode<"ISD::PtrAuthBundle", SDTPtrAuthBundle, []>; -def ptrauth_strip : SDNode<"ISD::PtrAuthStrip", SDTPtrAuthOneSchema, []>; +def ptrauth_auth : SDNode<"ISD::PtrAuthAuth", SDTPtrAuthOneSchema, []>; +def ptrauth_sign : SDNode<"ISD::PtrAuthSign", SDTPtrAuthOneSchema, []>; +def ptrauth_strip : SDNode<"ISD::PtrAuthStrip", SDTPtrAuthOneSchema, []>; +def ptrauth_resign : SDNode<"ISD::PtrAuthResign", SDTPtrAuthTwoSchemas, []>; //===----------------------------------------------------------------------===// // Selection DAG Condition Codes diff --git a/llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp b/llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp index 4f59e52f81b46..15af106eed497 100644 --- a/llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp +++ b/llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp @@ -2218,6 +2218,31 @@ bool IRTranslator::translateKnownIntrinsic(const CallInst &CI, Intrinsic::ID ID, switch (ID) { default: break; + case Intrinsic::ptrauth_auth: { + Register Dst = getOrCreateVReg(CI); + Register V = getOrCreateVReg(*CI.getArgOperand(0)); + Register Bundle = TranslatePtrAuthBundle(0); + + MIRBuilder.buildInstr(TargetOpcode::G_PTRAUTH_AUTH, {Dst}, {V, Bundle}); + return true; + } + case Intrinsic::ptrauth_sign: { + Register Dst = getOrCreateVReg(CI); + Register V = getOrCreateVReg(*CI.getArgOperand(0)); + Register Bundle = TranslatePtrAuthBundle(0); + + MIRBuilder.buildInstr(TargetOpcode::G_PTRAUTH_SIGN, {Dst}, {V, Bundle}); + return true; + } + case Intrinsic::ptrauth_resign: { + Register Dst = getOrCreateVReg(CI); + Register V = getOrCreateVReg(*CI.getArgOperand(0)); + Register OldBundle = TranslatePtrAuthBundle(0); + Register NewBundle = TranslatePtrAuthBundle(1); + + MIRBuilder.buildInstr(TargetOpcode::G_PTRAUTH_RESIGN, {Dst}, {V, OldBundle, NewBundle}); + return true; + } case Intrinsic::ptrauth_strip: { Register Dst = getOrCreateVReg(CI); Register V = getOrCreateVReg(*CI.getArgOperand(0)); diff --git a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp index f8f92b596a43f..2b3c00405ed51 100644 --- a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp +++ b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp @@ -6569,6 +6569,24 @@ void SelectionDAGBuilder::visitIntrinsicCall(const CallInst &I, // By default, turn this into a target intrinsic node. visitTargetIntrinsic(I, Intrinsic); return; + case Intrinsic::ptrauth_auth: { + setValue(&I, DAG.getNode(ISD::PtrAuthAuth, sdl, MVT::i64, + getValue(I.getArgOperand(0)), + CreatePtrAuthBundle(0))); + return; + } + case Intrinsic::ptrauth_sign: { + setValue(&I, DAG.getNode(ISD::PtrAuthSign, sdl, MVT::i64, + getValue(I.getArgOperand(0)), + CreatePtrAuthBundle(0))); + return; + } + case Intrinsic::ptrauth_resign: { + setValue(&I, DAG.getNode(ISD::PtrAuthResign, sdl, MVT::i64, + getValue(I.getArgOperand(0)), + CreatePtrAuthBundle(0), CreatePtrAuthBundle(1))); + return; + } case Intrinsic::ptrauth_strip: { setValue(&I, DAG.getNode(ISD::PtrAuthStrip, sdl, MVT::i64, getValue(I.getArgOperand(0)), diff --git a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGDumper.cpp b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGDumper.cpp index 31941c77ed942..0546a2bf4568f 100644 --- a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGDumper.cpp +++ b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGDumper.cpp @@ -140,6 +140,9 @@ std::string SDNode::getOperationName(const SelectionDAG *G) const { case ISD::GlobalTLSAddress: return "GlobalTLSAddress"; case ISD::PtrAuthGlobalAddress: return "PtrAuthGlobalAddress"; case ISD::PtrAuthBundle: return "PtrAuthBundle"; + case ISD::PtrAuthAuth: return "PtrAuthAuth"; + case ISD::PtrAuthSign: return "PtrAuthSign"; + case ISD::PtrAuthResign: return "PtrAuthResign"; case ISD::PtrAuthStrip: return "PtrAuthStrip"; case ISD::FrameIndex: return "FrameIndex"; case ISD::JumpTable: return "JumpTable"; diff --git a/llvm/lib/IR/Constants.cpp b/llvm/lib/IR/Constants.cpp index 185eeb922f30e..8ee5567b6cc23 100644 --- a/llvm/lib/IR/Constants.cpp +++ b/llvm/lib/IR/Constants.cpp @@ -2083,6 +2083,9 @@ Value *NoCFIValue::handleOperandChangeImpl(Value *From, Value *To) { ConstantPtrAuth *ConstantPtrAuth::get(Constant *Ptr, ConstantInt *Key, ConstantInt *Disc, Constant *AddrDisc, Constant *DeactivationSymbol) { + // FIXME Should we simply enforce i64 instead? + if (Key->getBitWidth() != 32) + Key = ConstantInt::get(Key->getContext(), APInt(32, Key->getZExtValue())); Constant *ArgVec[] = {Ptr, Key, Disc, AddrDisc, DeactivationSymbol}; ConstantPtrAuthKeyType MapKey(ArgVec); LLVMContextImpl *pImpl = Ptr->getContext().pImpl; @@ -2203,7 +2206,8 @@ bool ConstantPtrAuth::isKnownCompatibleWith(const Value *Key, return false; // If the keys are different, there's no chance for this to be compatible. - if (getKey() != Key) + // FIXME: Should we enforce i64 everywhere? + if (getKey()->getZExtValue() != cast(Key)->getZExtValue()) return false; // We can have 3 kinds of discriminators: @@ -2264,7 +2268,9 @@ bool ConstantPtrAuth::isKnownCompatibleWith(ArrayRef BundleOperands, if (BundleOperands.size() == 3) return isKnownCompatibleWith(BundleOperands[0], BundleOperands[1], BundleOperands[2], DL); - return isKnownCompatibleWith(BundleOperands[0], BundleOperands[1], DL); + if (BundleOperands.size() == 2) + return isKnownCompatibleWith(BundleOperands[0], BundleOperands[1], DL); + return false; } diff --git a/llvm/lib/IR/Verifier.cpp b/llvm/lib/IR/Verifier.cpp index 309fa9109c8a9..93e78fdf46654 100644 --- a/llvm/lib/IR/Verifier.cpp +++ b/llvm/lib/IR/Verifier.cpp @@ -4042,9 +4042,14 @@ void Verifier::visitCallBase(CallBase &Call) { Check(NumPtrauthBundles <= 1, "Multiple ptrauth operand bundles on a function call", Call); break; + case Intrinsic::ptrauth_auth: + case Intrinsic::ptrauth_sign: case Intrinsic::ptrauth_strip: Check(NumPtrauthBundles == 1, "Expected exactly one ptrauth bundle", Call); break; + case Intrinsic::ptrauth_resign: + Check(NumPtrauthBundles == 2, "Expected exactly one ptrauth bundle", Call); + break; default: Check(NumPtrauthBundles == 0, "Unexpected ptrauth bundle", Call); break; diff --git a/llvm/lib/Target/AArch64/AArch64ISelDAGToDAG.cpp b/llvm/lib/Target/AArch64/AArch64ISelDAGToDAG.cpp index b721c1f533726..5137ac97b06b0 100644 --- a/llvm/lib/Target/AArch64/AArch64ISelDAGToDAG.cpp +++ b/llvm/lib/Target/AArch64/AArch64ISelDAGToDAG.cpp @@ -1509,12 +1509,23 @@ void AArch64DAGToDAGISel::SelectTable(SDNode *N, unsigned NumVecs, unsigned Opc, ReplaceNode(N, CurDAG->getMachineNode(Opc, dl, VT, Ops)); } -static std::tuple -extractPtrauthBlendDiscriminators(SDValue Disc, SelectionDAG *DAG) { - SDLoc DL(Disc); +static std::tuple +extractPtrauthBlendDiscriminators(SDValue Bundle, SelectionDAG *DAG) { + SDLoc DL(Bundle); SDValue AddrDisc; SDValue ConstDisc; + assert(Bundle->getOpcode() == ISD::PtrAuthBundle); + unsigned KeyC = cast(Bundle->getOperand(0))->getZExtValue(); + SDValue Key = DAG->getTargetConstant(KeyC, DL, MVT::i64); + + if (Bundle->getNumOperands() == 3) + return std::make_tuple(Key, Bundle->getOperand(1), Bundle->getOperand(2)); + + // Be compatible for now. + assert(Bundle->getNumOperands() == 2); + SDValue Disc = Bundle->getOperand(1); + // If this is a blend, remember the constant and address discriminators. // Otherwise, it's either a constant discriminator, or a non-blended // address discriminator. @@ -1531,30 +1542,26 @@ extractPtrauthBlendDiscriminators(SDValue Disc, SelectionDAG *DAG) { // discriminator be computed separately. auto *ConstDiscN = dyn_cast(ConstDisc); if (!ConstDiscN || !isUInt<16>(ConstDiscN->getZExtValue())) - return std::make_tuple(DAG->getTargetConstant(0, DL, MVT::i64), Disc); + return std::make_tuple(Key, DAG->getTargetConstant(0, DL, MVT::i64), Disc); // If there's no address discriminator, use XZR directly. if (!AddrDisc) AddrDisc = DAG->getRegister(AArch64::XZR, MVT::i64); return std::make_tuple( + Key, DAG->getTargetConstant(ConstDiscN->getZExtValue(), DL, MVT::i64), AddrDisc); } void AArch64DAGToDAGISel::SelectPtrauthAuth(SDNode *N) { SDLoc DL(N); - // IntrinsicID is operand #0 - SDValue Val = N->getOperand(1); - SDValue AUTKey = N->getOperand(2); - SDValue AUTDisc = N->getOperand(3); - - unsigned AUTKeyC = cast(AUTKey)->getZExtValue(); - AUTKey = CurDAG->getTargetConstant(AUTKeyC, DL, MVT::i64); + assert(N->getOpcode() == ISD::PtrAuthAuth); + SDValue Val = N->getOperand(0); + SDValue AUTSchema = N->getOperand(1); - SDValue AUTAddrDisc, AUTConstDisc; - std::tie(AUTConstDisc, AUTAddrDisc) = - extractPtrauthBlendDiscriminators(AUTDisc, CurDAG); + auto [AUTKey, AUTConstDisc, AUTAddrDisc] = + extractPtrauthBlendDiscriminators(AUTSchema, CurDAG); if (!Subtarget->isX16X17Safer()) { std::vector Ops = {Val, AUTKey, AUTConstDisc, AUTAddrDisc}; @@ -1577,26 +1584,15 @@ void AArch64DAGToDAGISel::SelectPtrauthAuth(SDNode *N) { void AArch64DAGToDAGISel::SelectPtrauthResign(SDNode *N) { SDLoc DL(N); - // IntrinsicID is operand #0 - SDValue Val = N->getOperand(1); - SDValue AUTKey = N->getOperand(2); - SDValue AUTDisc = N->getOperand(3); - SDValue PACKey = N->getOperand(4); - SDValue PACDisc = N->getOperand(5); + assert(N->getOpcode() == ISD::PtrAuthResign); + SDValue Val = N->getOperand(0); + SDValue AUTSchema = N->getOperand(1); + SDValue PACSchema = N->getOperand(2); - unsigned AUTKeyC = cast(AUTKey)->getZExtValue(); - unsigned PACKeyC = cast(PACKey)->getZExtValue(); - - AUTKey = CurDAG->getTargetConstant(AUTKeyC, DL, MVT::i64); - PACKey = CurDAG->getTargetConstant(PACKeyC, DL, MVT::i64); - - SDValue AUTAddrDisc, AUTConstDisc; - std::tie(AUTConstDisc, AUTAddrDisc) = - extractPtrauthBlendDiscriminators(AUTDisc, CurDAG); - - SDValue PACAddrDisc, PACConstDisc; - std::tie(PACConstDisc, PACAddrDisc) = - extractPtrauthBlendDiscriminators(PACDisc, CurDAG); + auto [AUTKey, AUTConstDisc, AUTAddrDisc] = + extractPtrauthBlendDiscriminators(AUTSchema, CurDAG); + auto [PACKey, PACConstDisc, PACAddrDisc] = + extractPtrauthBlendDiscriminators(PACSchema, CurDAG); SDValue X16Copy = CurDAG->getCopyToReg(CurDAG->getEntryNode(), DL, AArch64::X16, Val, SDValue()); @@ -4818,6 +4814,14 @@ void AArch64DAGToDAGISel::Select(SDNode *Node) { default: break; + case ISD::PtrAuthAuth: + SelectPtrauthAuth(Node); + return; + + case ISD::PtrAuthResign: + SelectPtrauthResign(Node); + return; + case ISD::ATOMIC_CMP_SWAP: if (SelectCMP_SWAP(Node)) return; @@ -5799,14 +5803,6 @@ void AArch64DAGToDAGISel::Select(SDNode *Node) { SelectTagP(Node); return; - case Intrinsic::ptrauth_auth: - SelectPtrauthAuth(Node); - return; - - case Intrinsic::ptrauth_resign: - SelectPtrauthResign(Node); - return; - case Intrinsic::aarch64_neon_tbl2: SelectTable(Node, 2, VT == MVT::v8i8 ? AArch64::TBLv8i8Two : AArch64::TBLv16i8Two, diff --git a/llvm/lib/Target/AArch64/AArch64InstrInfo.td b/llvm/lib/Target/AArch64/AArch64InstrInfo.td index ffb7656831ef7..16d14f6ea8f1d 100644 --- a/llvm/lib/Target/AArch64/AArch64InstrInfo.td +++ b/llvm/lib/Target/AArch64/AArch64InstrInfo.td @@ -2212,7 +2212,7 @@ let Predicates = [HasPAuth] in { // This enforces the expected immediate modifier is used for signing, even // if an attacker is able to substitute AddrDisc. def PAC : Pseudo<(outs GPR64:$SignedVal), - (ins GPR64:$Val, i32imm:$Key, i64imm:$Disc, GPR64noip:$AddrDisc), + (ins GPR64:$Val, i64imm:$Key, i64imm:$Disc, GPR64noip:$AddrDisc), [], "$SignedVal = $Val">, Sched<[WriteI, ReadI]> { let isCodeGenOnly = 1; let hasSideEffects = 0; @@ -2225,8 +2225,8 @@ let Predicates = [HasPAuth] in { } // A standalone pattern is used, so that literal 0 can be passed as $Disc. - def : Pat<(int_ptrauth_sign GPR64:$Val, timm:$Key, GPR64noip:$AddrDisc), - (PAC GPR64:$Val, $Key, 0, GPR64noip:$AddrDisc)>; + def : Pat<(ptrauth_sign GPR64:$Val, (ptrauth_bundle (i64 imm:$Key), GPR64noip:$AddrDisc)), + (PAC GPR64:$Val, imm:$Key, 0, GPR64noip:$AddrDisc)>; // AUT and re-PAC a value, using different keys/data. // This directly manipulates x16/x17, which are the only registers that diff --git a/llvm/lib/Target/AArch64/GISel/AArch64CallLowering.cpp b/llvm/lib/Target/AArch64/GISel/AArch64CallLowering.cpp index 57bce3584110d..a339d2c161b8c 100644 --- a/llvm/lib/Target/AArch64/GISel/AArch64CallLowering.cpp +++ b/llvm/lib/Target/AArch64/GISel/AArch64CallLowering.cpp @@ -1163,14 +1163,10 @@ bool AArch64CallLowering::lowerTailCall( // Authenticated tail calls always take key/discriminator arguments. if (Opc == AArch64::AUTH_TCRETURN || Opc == AArch64::AUTH_TCRETURN_BTI) { - const unsigned Key = getIConstantVRegVal(Info.PAI->Operands[0], MRI)->getZExtValue(); - MIB.addImm(Key); - - Register AddrDisc = 0; - uint16_t IntDisc = 0; - std::tie(IntDisc, AddrDisc) = + auto [Key, IntDisc, AddrDisc] = extractPtrauthBlendDiscriminators(Info.PAI->Operands, MRI); + MIB.addImm(Key); MIB.addImm(IntDisc); MIB.addUse(AddrDisc); if (AddrDisc != AArch64::NoRegister) { @@ -1436,14 +1432,9 @@ bool AArch64CallLowering::lowerCall(MachineIRBuilder &MIRBuilder, Mask = getMaskForArgs(OutArgs, Info, *TRI, MF); if (Opc == AArch64::BLRA || Opc == AArch64::BLRA_RVMARKER) { - const unsigned Key = getIConstantVRegVal(Info.PAI->Operands[0], MRI)->getZExtValue(); - MIB.addImm(Key); - - Register AddrDisc = 0; - uint16_t IntDisc = 0; - std::tie(IntDisc, AddrDisc) = + auto [Key, IntDisc, AddrDisc] = extractPtrauthBlendDiscriminators(Info.PAI->Operands, MRI); - + MIB.addImm(Key); MIB.addImm(IntDisc); MIB.addUse(AddrDisc); if (AddrDisc != AArch64::NoRegister) { diff --git a/llvm/lib/Target/AArch64/GISel/AArch64GlobalISelUtils.cpp b/llvm/lib/Target/AArch64/GISel/AArch64GlobalISelUtils.cpp index 8ea2844b69fcc..0f409543e9ab5 100644 --- a/llvm/lib/Target/AArch64/GISel/AArch64GlobalISelUtils.cpp +++ b/llvm/lib/Target/AArch64/GISel/AArch64GlobalISelUtils.cpp @@ -96,13 +96,14 @@ bool AArch64GISelUtils::tryEmitBZero(MachineInstr &MI, return true; } -std::tuple +std::tuple AArch64GISelUtils::extractPtrauthBlendDiscriminators(SmallVector Operands, MachineRegisterInfo &MRI) { + uint64_t KeyVal = getIConstantVRegVal(Operands[0], MRI)->getZExtValue(); if (Operands.size() == 3) { uint64_t ConstDiscVal = getIConstantVRegVal(Operands[2], MRI)->getZExtValue(); assert(isUInt<16>(ConstDiscVal)); - return { ConstDiscVal, Operands[1] }; + return { KeyVal, ConstDiscVal, Operands[1] }; } // Stay fully compatible for now. @@ -116,13 +117,13 @@ AArch64GISelUtils::extractPtrauthBlendDiscriminators(SmallVector Opera ConstDisc = ConstDiscVal->getZExtValue(); AddrDisc = AArch64::NoRegister; } - return std::make_tuple(ConstDisc, AddrDisc); + return std::make_tuple(KeyVal, ConstDisc, AddrDisc); } const MachineInstr *DiscMI = MRI.getVRegDef(Disc); if (!DiscMI || DiscMI->getOpcode() != TargetOpcode::G_INTRINSIC || DiscMI->getOperand(1).getIntrinsicID() != Intrinsic::ptrauth_blend) - return std::make_tuple(ConstDisc, AddrDisc); + return std::make_tuple(KeyVal, ConstDisc, AddrDisc); if (auto ConstDiscVal = getIConstantVRegVal(DiscMI->getOperand(3).getReg(), MRI)) { @@ -131,7 +132,7 @@ AArch64GISelUtils::extractPtrauthBlendDiscriminators(SmallVector Opera AddrDisc = DiscMI->getOperand(2).getReg(); } } - return std::make_tuple(ConstDisc, AddrDisc); + return std::make_tuple(KeyVal, ConstDisc, AddrDisc); } void AArch64GISelUtils::changeFCMPPredToAArch64CC( diff --git a/llvm/lib/Target/AArch64/GISel/AArch64GlobalISelUtils.h b/llvm/lib/Target/AArch64/GISel/AArch64GlobalISelUtils.h index 285d904a3f54a..4153300fdca3e 100644 --- a/llvm/lib/Target/AArch64/GISel/AArch64GlobalISelUtils.h +++ b/llvm/lib/Target/AArch64/GISel/AArch64GlobalISelUtils.h @@ -56,7 +56,7 @@ bool tryEmitBZero(MachineInstr &MI, MachineIRBuilder &MIRBuilder, bool MinSize); /// Analyze a ptrauth discriminator value to try to find the constant integer /// and address parts, cracking a ptrauth_blend intrinsic if there is one. /// \returns integer/address disc. parts, with NoRegister if no address disc. -std::tuple +std::tuple extractPtrauthBlendDiscriminators(SmallVector Operands, MachineRegisterInfo &MRI); /// Find the AArch64 condition codes necessary to represent \p P for a scalar diff --git a/llvm/lib/Target/AArch64/GISel/AArch64InstructionSelector.cpp b/llvm/lib/Target/AArch64/GISel/AArch64InstructionSelector.cpp index 8c1751e874e9c..853568ab08241 100644 --- a/llvm/lib/Target/AArch64/GISel/AArch64InstructionSelector.cpp +++ b/llvm/lib/Target/AArch64/GISel/AArch64InstructionSelector.cpp @@ -2592,7 +2592,75 @@ bool AArch64InstructionSelector::select(MachineInstr &I) { LLT Ty = I.getOperand(0).isReg() ? MRI.getType(I.getOperand(0).getReg()) : LLT{}; + auto ParsePtrAuthBundle = [&MRI](Register Schema) { + assert(MRI.getType(Schema).isToken()); + const MachineInstr *Bundle = MRI.getVRegDef(Schema); + assert(Bundle->getOpcode() == TargetOpcode::G_PTRAUTH_BUNDLE); + SmallVector Ops; + for (auto &Op : Bundle->uses()) + Ops.push_back(Op.getReg()); + return extractPtrauthBlendDiscriminators(Ops, MRI); + }; + switch (Opcode) { + case TargetOpcode::G_PTRAUTH_AUTH: { + Register DstReg = I.getOperand(0).getReg(); + Register ValReg = I.getOperand(1).getReg(); + Register Schema = I.getOperand(2).getReg(); + + auto [AUTKey, AUTConstDiscC, AUTAddrDisc] = ParsePtrAuthBundle(Schema); + + if (STI.isX16X17Safer()) { + MIB.buildCopy({AArch64::X16}, {ValReg}); + MIB.buildInstr(TargetOpcode::IMPLICIT_DEF, {AArch64::X17}, {}); + MIB.buildInstr(AArch64::AUTx16x17) + .addImm(AUTKey) + .addImm(AUTConstDiscC) + .addUse(AUTAddrDisc) + .constrainAllUses(TII, TRI, RBI); + MIB.buildCopy({DstReg}, Register(AArch64::X16)); + } else { + Register ScratchReg = + MRI.createVirtualRegister(&AArch64::GPR64commonRegClass); + MIB.buildInstr(AArch64::AUTxMxN) + .addDef(DstReg) + .addDef(ScratchReg) + .addUse(ValReg) + .addImm(AUTKey) + .addImm(AUTConstDiscC) + .addUse(AUTAddrDisc) + .constrainAllUses(TII, TRI, RBI); + } + + RBI.constrainGenericRegister(DstReg, AArch64::GPR64RegClass, MRI); + I.eraseFromParent(); + return true; + } + case TargetOpcode::G_PTRAUTH_RESIGN: { + Register DstReg = I.getOperand(0).getReg(); + Register ValReg = I.getOperand(1).getReg(); + Register AUTSchema = I.getOperand(2).getReg(); + Register PACSchema = I.getOperand(3).getReg(); + + auto [AUTKey, AUTConstDiscC, AUTAddrDisc] = ParsePtrAuthBundle(AUTSchema); + auto [PACKey, PACConstDiscC, PACAddrDisc] = ParsePtrAuthBundle(PACSchema); + + MIB.buildCopy({AArch64::X16}, {ValReg}); + MIB.buildInstr(TargetOpcode::IMPLICIT_DEF, {AArch64::X17}, {}); + MIB.buildInstr(AArch64::AUTPAC) + .addImm(AUTKey) + .addImm(AUTConstDiscC) + .addUse(AUTAddrDisc) + .addImm(PACKey) + .addImm(PACConstDiscC) + .addUse(PACAddrDisc) + .constrainAllUses(TII, TRI, RBI); + MIB.buildCopy({DstReg}, Register(AArch64::X16)); + + RBI.constrainGenericRegister(DstReg, AArch64::GPR64RegClass, MRI); + I.eraseFromParent(); + return true; + } case TargetOpcode::G_SBFX: case TargetOpcode::G_UBFX: { static const unsigned OpcTable[2][2] = { @@ -6615,77 +6683,6 @@ bool AArch64InstructionSelector::selectIntrinsic(MachineInstr &I, switch (IntrinID) { default: break; - case Intrinsic::ptrauth_resign: { - Register DstReg = I.getOperand(0).getReg(); - Register ValReg = I.getOperand(2).getReg(); - uint64_t AUTKey = I.getOperand(3).getImm(); - Register AUTDisc = I.getOperand(4).getReg(); - uint64_t PACKey = I.getOperand(5).getImm(); - Register PACDisc = I.getOperand(6).getReg(); - - Register AUTAddrDisc = AUTDisc; - uint16_t AUTConstDiscC = 0; - std::tie(AUTConstDiscC, AUTAddrDisc) = - extractPtrauthBlendDiscriminators({0, AUTDisc}, MRI); - - Register PACAddrDisc = PACDisc; - uint16_t PACConstDiscC = 0; - std::tie(PACConstDiscC, PACAddrDisc) = - extractPtrauthBlendDiscriminators({0, PACDisc}, MRI); - - MIB.buildCopy({AArch64::X16}, {ValReg}); - MIB.buildInstr(TargetOpcode::IMPLICIT_DEF, {AArch64::X17}, {}); - MIB.buildInstr(AArch64::AUTPAC) - .addImm(AUTKey) - .addImm(AUTConstDiscC) - .addUse(AUTAddrDisc) - .addImm(PACKey) - .addImm(PACConstDiscC) - .addUse(PACAddrDisc) - .constrainAllUses(TII, TRI, RBI); - MIB.buildCopy({DstReg}, Register(AArch64::X16)); - - RBI.constrainGenericRegister(DstReg, AArch64::GPR64RegClass, MRI); - I.eraseFromParent(); - return true; - } - case Intrinsic::ptrauth_auth: { - Register DstReg = I.getOperand(0).getReg(); - Register ValReg = I.getOperand(2).getReg(); - uint64_t AUTKey = I.getOperand(3).getImm(); - Register AUTDisc = I.getOperand(4).getReg(); - - Register AUTAddrDisc = AUTDisc; - uint16_t AUTConstDiscC = 0; - std::tie(AUTConstDiscC, AUTAddrDisc) = - extractPtrauthBlendDiscriminators({0, AUTDisc}, MRI); - - if (STI.isX16X17Safer()) { - MIB.buildCopy({AArch64::X16}, {ValReg}); - MIB.buildInstr(TargetOpcode::IMPLICIT_DEF, {AArch64::X17}, {}); - MIB.buildInstr(AArch64::AUTx16x17) - .addImm(AUTKey) - .addImm(AUTConstDiscC) - .addUse(AUTAddrDisc) - .constrainAllUses(TII, TRI, RBI); - MIB.buildCopy({DstReg}, Register(AArch64::X16)); - } else { - Register ScratchReg = - MRI.createVirtualRegister(&AArch64::GPR64commonRegClass); - MIB.buildInstr(AArch64::AUTxMxN) - .addDef(DstReg) - .addDef(ScratchReg) - .addUse(ValReg) - .addImm(AUTKey) - .addImm(AUTConstDiscC) - .addUse(AUTAddrDisc) - .constrainAllUses(TII, TRI, RBI); - } - - RBI.constrainGenericRegister(DstReg, AArch64::GPR64RegClass, MRI); - I.eraseFromParent(); - return true; - } case Intrinsic::frameaddress: case Intrinsic::returnaddress: { MachineFunction &MF = *I.getParent()->getParent(); diff --git a/llvm/lib/Target/AArch64/GISel/AArch64LegalizerInfo.cpp b/llvm/lib/Target/AArch64/GISel/AArch64LegalizerInfo.cpp index 83f188d1d9ab3..001d8edcd613c 100644 --- a/llvm/lib/Target/AArch64/GISel/AArch64LegalizerInfo.cpp +++ b/llvm/lib/Target/AArch64/GISel/AArch64LegalizerInfo.cpp @@ -1021,6 +1021,9 @@ AArch64LegalizerInfo::AArch64LegalizerInfo(const AArch64Subtarget &ST) .legalIf(all(typeIs(0, p0), typeIs(1, p0))); getActionDefinitionsBuilder(G_PTRAUTH_BUNDLE).legalForTypeWithAnyImm({s64}); + getActionDefinitionsBuilder(G_PTRAUTH_AUTH).legalForTypeWithAnyImm({s64}); + getActionDefinitionsBuilder(G_PTRAUTH_SIGN).legalForTypeWithAnyImm({s64}); + getActionDefinitionsBuilder(G_PTRAUTH_RESIGN).legalForTypeWithAnyImm({s64}); getActionDefinitionsBuilder(G_PTRAUTH_STRIP).legalForTypeWithAnyImm({s64}); getActionDefinitionsBuilder(G_PTRTOINT) diff --git a/llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp b/llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp index 07fe253e75a4a..41cd1b666f67d 100644 --- a/llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp +++ b/llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp @@ -1730,6 +1730,24 @@ foldIntrinsicUsingDistributiveLaws(IntrinsicInst *II, return NewBinop; } +static bool areCompatiblePtrAuthBundles(OperandBundleUse LHS, + OperandBundleUse RHS) { + if (LHS.Inputs.size() != RHS.Inputs.size()) + return false; + for (auto [A, B] : llvm::zip(LHS.Inputs, RHS.Inputs)) { + auto *ConstA = dyn_cast(A); + auto *ConstB = dyn_cast(B); + // This handles the same key ids being specified either as i32 or i64. + // FIXME: Should we simply enforce i64 everywhere? + if (ConstA && ConstB && ConstA->getZExtValue() == ConstB->getZExtValue()) + continue; + + if (A != B) + return false; + } + return true; +} + /// CallInst simplification. This mostly only handles folding of intrinsic /// instructions. For normal calls, it allows visitCallBase to do the heavy /// lifting. @@ -3079,54 +3097,57 @@ Instruction *InstCombinerImpl::visitCallInst(CallInst &CI) { case Intrinsic::ptrauth_resign: { // We don't support this optimization on intrinsic calls with deactivation // symbols, which are represented using operand bundles. - if (II->hasOperandBundles()) + if (II->countOperandBundlesOfType(LLVMContext::OB_deactivation_symbol)) break; // (sign|resign) + (auth|resign) can be folded by omitting the middle // sign+auth component if the key and discriminator match. bool NeedSign = II->getIntrinsicID() == Intrinsic::ptrauth_resign; Value *Ptr = II->getArgOperand(0); - Value *Key = II->getArgOperand(1); - Value *Disc = II->getArgOperand(2); + auto ThisAutSchema = II->getOperandBundleAt(0); // AuthKey will be the key we need to end up authenticating against in // whatever we replace this sequence with. - Value *AuthKey = nullptr, *AuthDisc = nullptr, *BasePtr; + std::optional NewAutSchema; + Value *BasePtr = nullptr; if (const auto *CI = dyn_cast(Ptr)) { // We don't support this optimization on intrinsic calls with deactivation // symbols, which are represented using operand bundles. - if (CI->hasOperandBundles()) + if (CI->countOperandBundlesOfType(LLVMContext::OB_deactivation_symbol)) break; BasePtr = CI->getArgOperand(0); if (CI->getIntrinsicID() == Intrinsic::ptrauth_sign) { - if (CI->getArgOperand(1) != Key || CI->getArgOperand(2) != Disc) + if (!areCompatiblePtrAuthBundles(ThisAutSchema, CI->getOperandBundleAt(0))) break; } else if (CI->getIntrinsicID() == Intrinsic::ptrauth_resign) { - if (CI->getArgOperand(3) != Key || CI->getArgOperand(4) != Disc) + if (!areCompatiblePtrAuthBundles(ThisAutSchema, CI->getOperandBundleAt(1))) break; - AuthKey = CI->getArgOperand(1); - AuthDisc = CI->getArgOperand(2); + NewAutSchema = CI->getOperandBundleAt(0); } else break; } else if (const auto *PtrToInt = dyn_cast(Ptr)) { // ptrauth constants are equivalent to a call to @llvm.ptrauth.sign for // our purposes, so check for that too. const auto *CPA = dyn_cast(PtrToInt->getOperand(0)); - if (!CPA || !CPA->isKnownCompatibleWith(Key, Disc, DL)) + if (!CPA || !CPA->isKnownCompatibleWith(ThisAutSchema.Inputs, DL)) break; - // resign(ptrauth(p,ks,ds),ks,ds,kr,dr) -> ptrauth(p,kr,dr) - if (NeedSign && isa(II->getArgOperand(4))) { - auto *SignKey = cast(II->getArgOperand(3)); - auto *SignDisc = cast(II->getArgOperand(4)); - auto *Null = ConstantPointerNull::get(Builder.getPtrTy()); - auto *NewCPA = ConstantPtrAuth::get(CPA->getPointer(), SignKey, - SignDisc, /*AddrDisc=*/Null, - /*DeactivationSymbol=*/Null); - replaceInstUsesWith( - *II, ConstantExpr::getPointerCast(NewCPA, II->getType())); - return eraseInstFromFunction(*II); + if (NeedSign) { + auto ThisSignSchema = II->getOperandBundleAt(1); + // resign(ptrauth(p,ks,ds),ks,ds,kr,dr) -> ptrauth(p,kr,dr) + if (ThisSignSchema.Inputs.size() == 2 && + isa(ThisSignSchema.Inputs[1])) { + auto *SignKey = cast(ThisSignSchema.Inputs[0]); + auto *SignDisc = cast(ThisSignSchema.Inputs[1]); + auto *Null = ConstantPointerNull::get(Builder.getPtrTy()); + auto *NewCPA = ConstantPtrAuth::get(CPA->getPointer(), SignKey, + SignDisc, /*AddrDisc=*/Null, + /*DeactivationSymbol=*/Null); + replaceInstUsesWith( + *II, ConstantExpr::getPointerCast(NewCPA, II->getType())); + return eraseInstFromFunction(*II); + } } // auth(ptrauth(p,k,d),k,d) -> p @@ -3135,10 +3156,10 @@ Instruction *InstCombinerImpl::visitCallInst(CallInst &CI) { break; unsigned NewIntrin; - if (AuthKey && NeedSign) { + if (NewAutSchema && NeedSign) { // resign(0,1) + resign(1,2) = resign(0, 2) NewIntrin = Intrinsic::ptrauth_resign; - } else if (AuthKey) { + } else if (NewAutSchema) { // resign(0,1) + auth(1) = auth(0) NewIntrin = Intrinsic::ptrauth_auth; } else if (NeedSign) { @@ -3150,21 +3171,26 @@ Instruction *InstCombinerImpl::visitCallInst(CallInst &CI) { return eraseInstFromFunction(*II); } - SmallVector CallArgs; - CallArgs.push_back(BasePtr); - if (AuthKey) { - CallArgs.push_back(AuthKey); - CallArgs.push_back(AuthDisc); + SmallVector OBs; + + if (NewAutSchema) { + SmallVector Ops; + for (auto &U : NewAutSchema->Inputs) + Ops.push_back(U); + OBs.emplace_back("ptrauth", Ops); } if (NeedSign) { - CallArgs.push_back(II->getArgOperand(3)); - CallArgs.push_back(II->getArgOperand(4)); + SmallVector Ops; + for (auto &U : II->getOperandBundleAt(1).Inputs) + Ops.push_back(U); + OBs.emplace_back("ptrauth", Ops); } + Function *NewFn = Intrinsic::getOrInsertDeclaration(II->getModule(), NewIntrin); - return CallInst::Create(NewFn, CallArgs); + return CallInst::Create(NewFn, {BasePtr}, OBs); } case Intrinsic::arm_neon_vtbl1: case Intrinsic::aarch64_neon_tbl1: @@ -4294,6 +4320,10 @@ static IntrinsicInst *findInitTrampoline(Value *Callee) { } Instruction *InstCombinerImpl::foldPtrAuthIntrinsicCallee(CallBase &Call) { + // "ptrauth" bundles have different semantic on intrinsics. + if (isa(Call)) + return nullptr; + const Value *Callee = Call.getCalledOperand(); const auto *IPC = dyn_cast(Callee); if (!IPC || !IPC->isNoopCast(DL)) @@ -4326,14 +4356,13 @@ Instruction *InstCombinerImpl::foldPtrAuthIntrinsicCallee(CallBase &Call) { // call(ptrauth.resign(p)), ["ptrauth"()] -> call p, ["ptrauth"()] // assuming the call bundle and the sign operands match. case Intrinsic::ptrauth_resign: { - // Resign result key should match bundle. - if (II->getOperand(3) != PtrAuthBundleOrNone->Inputs[0]) - return nullptr; - // Resign result discriminator should match bundle. - if (II->getOperand(4) != PtrAuthBundleOrNone->Inputs[1]) + if (!areCompatiblePtrAuthBundles(II->getOperandBundleAt(1), + *PtrAuthBundleOrNone)) return nullptr; - Value *NewBundleOps[] = {II->getOperand(1), II->getOperand(2)}; + SmallVector NewBundleOps; + for (auto &Op : II->getOperandBundleAt(0).Inputs) + NewBundleOps.push_back(Op); NewBundles.emplace_back("ptrauth", NewBundleOps); NewCallee = II->getOperand(0); break; @@ -4343,11 +4372,8 @@ Instruction *InstCombinerImpl::foldPtrAuthIntrinsicCallee(CallBase &Call) { // assuming the call bundle and the sign operands match. // Non-ptrauth indirect calls are undesirable, but so is ptrauth.sign. case Intrinsic::ptrauth_sign: { - // Sign key should match bundle. - if (II->getOperand(1) != PtrAuthBundleOrNone->Inputs[0]) - return nullptr; - // Sign discriminator should match bundle. - if (II->getOperand(2) != PtrAuthBundleOrNone->Inputs[1]) + if (!areCompatiblePtrAuthBundles(II->getOperandBundleAt(0), + *PtrAuthBundleOrNone)) return nullptr; NewCallee = II->getOperand(0); break; diff --git a/llvm/test/CodeGen/AArch64/GlobalISel/legalizer-info-validation.mir b/llvm/test/CodeGen/AArch64/GlobalISel/legalizer-info-validation.mir index 933323828cc83..672b837d35764 100644 --- a/llvm/test/CodeGen/AArch64/GlobalISel/legalizer-info-validation.mir +++ b/llvm/test/CodeGen/AArch64/GlobalISel/legalizer-info-validation.mir @@ -123,6 +123,18 @@ # DEBUG-NEXT: .. type index coverage check SKIPPED: user-defined predicate detected # DEBUG-NEXT: .. imm index coverage check SKIPPED: user-defined predicate detected # +# DEBUG-NEXT: G_PTRAUTH_AUTH (opcode {{[0-9]+}}): 1 type index, 1 imm index +# DEBUG-NEXT: .. type index coverage check SKIPPED: user-defined predicate detected +# DEBUG-NEXT: .. imm index coverage check SKIPPED: user-defined predicate detected +# +# DEBUG-NEXT: G_PTRAUTH_SIGN (opcode {{[0-9]+}}): 1 type index, 1 imm index +# DEBUG-NEXT: .. type index coverage check SKIPPED: user-defined predicate detected +# DEBUG-NEXT: .. imm index coverage check SKIPPED: user-defined predicate detected +# +# DEBUG-NEXT: G_PTRAUTH_RESIGN (opcode {{[0-9]+}}): 1 type index, 1 imm index +# DEBUG-NEXT: .. type index coverage check SKIPPED: user-defined predicate detected +# DEBUG-NEXT: .. imm index coverage check SKIPPED: user-defined predicate detected +# # DEBUG-NEXT: G_PTRAUTH_STRIP (opcode {{[0-9]+}}): 1 type index, 1 imm index # DEBUG-NEXT: .. type index coverage check SKIPPED: user-defined predicate detected # DEBUG-NEXT: .. imm index coverage check SKIPPED: user-defined predicate detected diff --git a/llvm/test/CodeGen/AArch64/ptrauth-call.ll b/llvm/test/CodeGen/AArch64/ptrauth-call.ll index 29081566d836e..921ad7a632ef2 100644 --- a/llvm/test/CodeGen/AArch64/ptrauth-call.ll +++ b/llvm/test/CodeGen/AArch64/ptrauth-call.ll @@ -298,7 +298,7 @@ define void @test_tailcall_omit_mov_x16_x16(ptr %objptr) #0 { %objptr.int = ptrtoint ptr %objptr to i64 %vtable.discr = tail call i64 @llvm.ptrauth.blend(i64 %objptr.int, i64 6503) %vtable.signed.int = ptrtoint ptr %vtable.signed to i64 - %vtable.unsigned.int = tail call i64 @llvm.ptrauth.auth(i64 %vtable.signed.int, i32 2, i64 %vtable.discr) + %vtable.unsigned.int = tail call i64 @llvm.ptrauth.auth(i64 %vtable.signed.int) [ "ptrauth"(i64 2, i64 %vtable.discr) ] %vtable.unsigned = inttoptr i64 %vtable.unsigned.int to ptr %virt.func.signed = load ptr, ptr %vtable.unsigned, align 8 %virt.func.discr = tail call i64 @llvm.ptrauth.blend(i64 %vtable.unsigned.int, i64 54167) @@ -334,7 +334,7 @@ define i32 @test_call_omit_extra_moves(ptr %objptr) #0 { %objptr.int = ptrtoint ptr %objptr to i64 %vtable.discr = tail call i64 @llvm.ptrauth.blend(i64 %objptr.int, i64 6503) %vtable.signed.int = ptrtoint ptr %vtable.signed to i64 - %vtable.int = tail call i64 @llvm.ptrauth.auth(i64 %vtable.signed.int, i32 2, i64 %vtable.discr) + %vtable.int = tail call i64 @llvm.ptrauth.auth(i64 %vtable.signed.int) [ "ptrauth"(i64 2, i64 %vtable.discr) ] %vtable = inttoptr i64 %vtable.int to ptr %callee.signed = load ptr, ptr %vtable %callee.discr = tail call i64 @llvm.ptrauth.blend(i64 %vtable.int, i64 34646) @@ -680,7 +680,4 @@ define i32 @test_direct_call_addr_blend_gep_different_index_types() #0 { declare void @f() -declare i64 @llvm.ptrauth.auth(i64, i32, i64) -declare i64 @llvm.ptrauth.blend(i64, i64) - attributes #0 = { nounwind } diff --git a/llvm/test/CodeGen/AArch64/ptrauth-fpac.ll b/llvm/test/CodeGen/AArch64/ptrauth-fpac.ll index 787b8886c917b..9f93b00bb582f 100644 --- a/llvm/test/CodeGen/AArch64/ptrauth-fpac.ll +++ b/llvm/test/CodeGen/AArch64/ptrauth-fpac.ll @@ -18,7 +18,7 @@ define i64 @test_auth_ia(i64 %arg, i64 %arg1) { ; ELF: // %bb.0: ; ELF-NEXT: autia x0, x1 ; ELF-NEXT: ret - %tmp = call i64 @llvm.ptrauth.auth(i64 %arg, i32 0, i64 %arg1) + %tmp = call i64 @llvm.ptrauth.auth(i64 %arg) [ "ptrauth"(i64 0, i64 %arg1) ] ret i64 %tmp } @@ -34,7 +34,7 @@ define i64 @test_auth_ia_zero(i64 %arg) { ; ELF: // %bb.0: ; ELF-NEXT: autiza x0 ; ELF-NEXT: ret - %tmp = call i64 @llvm.ptrauth.auth(i64 %arg, i32 0, i64 0) + %tmp = call i64 @llvm.ptrauth.auth(i64 %arg) [ "ptrauth"(i64 0, i64 0) ] ret i64 %tmp } @@ -50,7 +50,7 @@ define i64 @test_auth_ib(i64 %arg, i64 %arg1) { ; ELF: // %bb.0: ; ELF-NEXT: autib x0, x1 ; ELF-NEXT: ret - %tmp = call i64 @llvm.ptrauth.auth(i64 %arg, i32 1, i64 %arg1) + %tmp = call i64 @llvm.ptrauth.auth(i64 %arg) [ "ptrauth"(i64 1, i64 %arg1) ] ret i64 %tmp } @@ -66,7 +66,7 @@ define i64 @test_auth_ib_zero(i64 %arg) { ; ELF: // %bb.0: ; ELF-NEXT: autizb x0 ; ELF-NEXT: ret - %tmp = call i64 @llvm.ptrauth.auth(i64 %arg, i32 1, i64 0) + %tmp = call i64 @llvm.ptrauth.auth(i64 %arg) [ "ptrauth"(i64 1, i64 0) ] ret i64 %tmp } @@ -82,7 +82,7 @@ define i64 @test_auth_da(i64 %arg, i64 %arg1) { ; ELF: // %bb.0: ; ELF-NEXT: autda x0, x1 ; ELF-NEXT: ret - %tmp = call i64 @llvm.ptrauth.auth(i64 %arg, i32 2, i64 %arg1) + %tmp = call i64 @llvm.ptrauth.auth(i64 %arg) [ "ptrauth"(i64 2, i64 %arg1) ] ret i64 %tmp } @@ -98,7 +98,7 @@ define i64 @test_auth_da_zero(i64 %arg) { ; ELF: // %bb.0: ; ELF-NEXT: autdza x0 ; ELF-NEXT: ret - %tmp = call i64 @llvm.ptrauth.auth(i64 %arg, i32 2, i64 0) + %tmp = call i64 @llvm.ptrauth.auth(i64 %arg) [ "ptrauth"(i64 2, i64 0) ] ret i64 %tmp } @@ -114,7 +114,7 @@ define i64 @test_auth_db(i64 %arg, i64 %arg1) { ; ELF: // %bb.0: ; ELF-NEXT: autdb x0, x1 ; ELF-NEXT: ret - %tmp = call i64 @llvm.ptrauth.auth(i64 %arg, i32 3, i64 %arg1) + %tmp = call i64 @llvm.ptrauth.auth(i64 %arg) [ "ptrauth"(i64 3, i64 %arg1) ] ret i64 %tmp } @@ -130,7 +130,7 @@ define i64 @test_auth_db_zero(i64 %arg) { ; ELF: // %bb.0: ; ELF-NEXT: autdzb x0 ; ELF-NEXT: ret - %tmp = call i64 @llvm.ptrauth.auth(i64 %arg, i32 3, i64 0) + %tmp = call i64 @llvm.ptrauth.auth(i64 %arg) [ "ptrauth"(i64 3, i64 0) ] ret i64 %tmp } @@ -160,7 +160,7 @@ define i64 @test_resign_ia_ia(i64 %arg, i64 %arg1, i64 %arg2) { ; FPAC-NEXT: pacia x16, x2 ; FPAC-NEXT: mov x0, x16 ; FPAC-NEXT: ret - %tmp = call i64 @llvm.ptrauth.resign(i64 %arg, i32 0, i64 %arg1, i32 0, i64 %arg2) + %tmp = call i64 @llvm.ptrauth.resign(i64 %arg) [ "ptrauth"(i64 0, i64 %arg1), "ptrauth"(i64 0, i64 %arg2) ] ret i64 %tmp } @@ -188,7 +188,7 @@ define i64 @test_resign_ib_ia(i64 %arg, i64 %arg1, i64 %arg2) { ; FPAC-NEXT: pacia x16, x2 ; FPAC-NEXT: mov x0, x16 ; FPAC-NEXT: ret - %tmp = call i64 @llvm.ptrauth.resign(i64 %arg, i32 1, i64 %arg1, i32 0, i64 %arg2) + %tmp = call i64 @llvm.ptrauth.resign(i64 %arg) [ "ptrauth"(i64 1, i64 %arg1), "ptrauth"(i64 0, i64 %arg2) ] ret i64 %tmp } @@ -216,7 +216,7 @@ define i64 @test_resign_da_ia(i64 %arg, i64 %arg1, i64 %arg2) { ; FPAC-NEXT: pacia x16, x2 ; FPAC-NEXT: mov x0, x16 ; FPAC-NEXT: ret - %tmp = call i64 @llvm.ptrauth.resign(i64 %arg, i32 2, i64 %arg1, i32 0, i64 %arg2) + %tmp = call i64 @llvm.ptrauth.resign(i64 %arg) [ "ptrauth"(i64 2, i64 %arg1), "ptrauth"(i64 0, i64 %arg2) ] ret i64 %tmp } @@ -244,7 +244,7 @@ define i64 @test_resign_db_ia(i64 %arg, i64 %arg1, i64 %arg2) { ; FPAC-NEXT: pacia x16, x2 ; FPAC-NEXT: mov x0, x16 ; FPAC-NEXT: ret - %tmp = call i64 @llvm.ptrauth.resign(i64 %arg, i32 3, i64 %arg1, i32 0, i64 %arg2) + %tmp = call i64 @llvm.ptrauth.resign(i64 %arg) [ "ptrauth"(i64 3, i64 %arg1), "ptrauth"(i64 0, i64 %arg2) ] ret i64 %tmp } @@ -272,7 +272,7 @@ define i64 @test_resign_db_ib(i64 %arg, i64 %arg1, i64 %arg2) { ; FPAC-NEXT: pacib x16, x2 ; FPAC-NEXT: mov x0, x16 ; FPAC-NEXT: ret - %tmp = call i64 @llvm.ptrauth.resign(i64 %arg, i32 3, i64 %arg1, i32 1, i64 %arg2) + %tmp = call i64 @llvm.ptrauth.resign(i64 %arg) [ "ptrauth"(i64 3, i64 %arg1), "ptrauth"(i64 1, i64 %arg2) ] ret i64 %tmp } @@ -300,7 +300,7 @@ define i64 @test_resign_db_da(i64 %arg, i64 %arg1, i64 %arg2) { ; FPAC-NEXT: pacda x16, x2 ; FPAC-NEXT: mov x0, x16 ; FPAC-NEXT: ret - %tmp = call i64 @llvm.ptrauth.resign(i64 %arg, i32 3, i64 %arg1, i32 2, i64 %arg2) + %tmp = call i64 @llvm.ptrauth.resign(i64 %arg) [ "ptrauth"(i64 3, i64 %arg1), "ptrauth"(i64 2, i64 %arg2) ] ret i64 %tmp } @@ -328,7 +328,7 @@ define i64 @test_resign_db_db(i64 %arg, i64 %arg1, i64 %arg2) { ; FPAC-NEXT: pacdb x16, x2 ; FPAC-NEXT: mov x0, x16 ; FPAC-NEXT: ret - %tmp = call i64 @llvm.ptrauth.resign(i64 %arg, i32 3, i64 %arg1, i32 3, i64 %arg2) + %tmp = call i64 @llvm.ptrauth.resign(i64 %arg) [ "ptrauth"(i64 3, i64 %arg1), "ptrauth"(i64 3, i64 %arg2) ] ret i64 %tmp } @@ -356,7 +356,7 @@ define i64 @test_resign_iza_db(i64 %arg, i64 %arg1, i64 %arg2) { ; FPAC-NEXT: pacdb x16, x2 ; FPAC-NEXT: mov x0, x16 ; FPAC-NEXT: ret - %tmp = call i64 @llvm.ptrauth.resign(i64 %arg, i32 0, i64 0, i32 3, i64 %arg2) + %tmp = call i64 @llvm.ptrauth.resign(i64 %arg) [ "ptrauth"(i64 0, i64 0), "ptrauth"(i64 3, i64 %arg2) ] ret i64 %tmp } @@ -384,7 +384,7 @@ define i64 @test_resign_da_dzb(i64 %arg, i64 %arg1, i64 %arg2) { ; FPAC-NEXT: pacdzb x16 ; FPAC-NEXT: mov x0, x16 ; FPAC-NEXT: ret - %tmp = call i64 @llvm.ptrauth.resign(i64 %arg, i32 2, i64 %arg1, i32 3, i64 0) + %tmp = call i64 @llvm.ptrauth.resign(i64 %arg) [ "ptrauth"(i64 2, i64 %arg1), "ptrauth"(i64 3, i64 0) ] ret i64 %tmp } @@ -421,9 +421,6 @@ define i64 @test_auth_trap_attribute(i64 %arg, i64 %arg1) "ptrauth-auth-traps" { ; ELF-FPAC: %bb.0: ; ELF-FPAC-NEXT: autia x0, x1 ; ELF-FPAC-NEXT: ret - %tmp = call i64 @llvm.ptrauth.auth(i64 %arg, i32 0, i64 %arg1) + %tmp = call i64 @llvm.ptrauth.auth(i64 %arg) [ "ptrauth"(i64 0, i64 %arg1) ] ret i64 %tmp } - -declare i64 @llvm.ptrauth.auth(i64, i32, i64) -declare i64 @llvm.ptrauth.resign(i64, i32, i64, i32, i64) diff --git a/llvm/test/CodeGen/AArch64/ptrauth-intrinsic-auth-resign-with-blend.ll b/llvm/test/CodeGen/AArch64/ptrauth-intrinsic-auth-resign-with-blend.ll index e2aea6df78250..a4c1b2b13eab0 100644 --- a/llvm/test/CodeGen/AArch64/ptrauth-intrinsic-auth-resign-with-blend.ll +++ b/llvm/test/CodeGen/AArch64/ptrauth-intrinsic-auth-resign-with-blend.ll @@ -74,7 +74,7 @@ define i64 @test_auth_blend(i64 %arg, i64 %arg1) { ; TRAP-DARWIN-NEXT: mov x0, x16 ; TRAP-NEXT: ret %tmp0 = call i64 @llvm.ptrauth.blend(i64 %arg1, i64 65535) - %tmp1 = call i64 @llvm.ptrauth.auth(i64 %arg, i32 2, i64 %tmp0) + %tmp1 = call i64 @llvm.ptrauth.auth(i64 %arg) [ "ptrauth"(i64 2, i64 %tmp0) ] ret i64 %tmp1 } @@ -136,7 +136,7 @@ define i64 @test_resign_blend(i64 %arg, i64 %arg1, i64 %arg2) { ; TRAP-NEXT: ret %tmp0 = call i64 @llvm.ptrauth.blend(i64 %arg1, i64 12345) %tmp1 = call i64 @llvm.ptrauth.blend(i64 %arg2, i64 56789) - %tmp2 = call i64 @llvm.ptrauth.resign(i64 %arg, i32 2, i64 %tmp0, i32 3, i64 %tmp1) + %tmp2 = call i64 @llvm.ptrauth.resign(i64 %arg) [ "ptrauth"(i64 2, i64 %tmp0), "ptrauth"(i64 3, i64 %tmp1) ] ret i64 %tmp2 } @@ -194,7 +194,7 @@ define i64 @test_resign_blend_and_const(i64 %arg, i64 %arg1) { ; TRAP-NEXT: mov x0, x16 ; TRAP-NEXT: ret %tmp0 = call i64 @llvm.ptrauth.blend(i64 %arg1, i64 12345) - %tmp1 = call i64 @llvm.ptrauth.resign(i64 %arg, i32 2, i64 %tmp0, i32 3, i64 56789) + %tmp1 = call i64 @llvm.ptrauth.resign(i64 %arg) [ "ptrauth"(i64 2, i64 %tmp0), "ptrauth"(i64 3, i64 56789) ] ret i64 %tmp1 } @@ -249,7 +249,7 @@ define i64 @test_resign_blend_and_addr(i64 %arg, i64 %arg1, i64 %arg2) { ; TRAP-NEXT: mov x0, x16 ; TRAP-NEXT: ret %tmp0 = call i64 @llvm.ptrauth.blend(i64 %arg1, i64 12345) - %tmp1 = call i64 @llvm.ptrauth.resign(i64 %arg, i32 2, i64 %tmp0, i32 3, i64 %arg2) + %tmp1 = call i64 @llvm.ptrauth.resign(i64 %arg) [ "ptrauth"(i64 2, i64 %tmp0), "ptrauth"(i64 3, i64 %arg2) ] ret i64 %tmp1 } @@ -295,10 +295,7 @@ define i64 @test_auth_too_large_discriminator(i64 %arg, i64 %arg1) { ; TRAP-DARWIN-NEXT: mov x0, x16 ; TRAP-NEXT: ret %tmp0 = call i64 @llvm.ptrauth.blend(i64 %arg1, i64 65536) - %tmp1 = call i64 @llvm.ptrauth.auth(i64 %arg, i32 2, i64 %tmp0) + %tmp1 = call i64 @llvm.ptrauth.auth(i64 %arg) [ "ptrauth"(i64 2, i64 %tmp0) ] ret i64 %tmp1 } -declare i64 @llvm.ptrauth.auth(i64, i32, i64) -declare i64 @llvm.ptrauth.resign(i64, i32, i64, i32, i64) -declare i64 @llvm.ptrauth.blend(i64, i64) diff --git a/llvm/test/CodeGen/AArch64/ptrauth-intrinsic-auth-resign.ll b/llvm/test/CodeGen/AArch64/ptrauth-intrinsic-auth-resign.ll index 52b38a5632005..6fdae6e6e183e 100644 --- a/llvm/test/CodeGen/AArch64/ptrauth-intrinsic-auth-resign.ll +++ b/llvm/test/CodeGen/AArch64/ptrauth-intrinsic-auth-resign.ll @@ -64,7 +64,7 @@ define i64 @test_auth_ia(i64 %arg, i64 %arg1) { ; TRAP-NEXT: Lauth_success_0: ; TRAP-DARWIN-NEXT: mov x0, x16 ; TRAP-NEXT: ret - %tmp = call i64 @llvm.ptrauth.auth(i64 %arg, i32 0, i64 %arg1) + %tmp = call i64 @llvm.ptrauth.auth(i64 %arg) [ "ptrauth"(i64 0, i64 %arg1) ] ret i64 %tmp } @@ -101,7 +101,7 @@ define i64 @test_auth_ia_zero(i64 %arg) { ; TRAP-NEXT: Lauth_success_1: ; TRAP-DARWIN-NEXT: mov x0, x16 ; TRAP-NEXT: ret - %tmp = call i64 @llvm.ptrauth.auth(i64 %arg, i32 0, i64 0) + %tmp = call i64 @llvm.ptrauth.auth(i64 %arg) [ "ptrauth"(i64 0, i64 0) ] ret i64 %tmp } @@ -138,7 +138,7 @@ define i64 @test_auth_ib(i64 %arg, i64 %arg1) { ; TRAP-NEXT: Lauth_success_2: ; TRAP-DARWIN-NEXT: mov x0, x16 ; TRAP-NEXT: ret - %tmp = call i64 @llvm.ptrauth.auth(i64 %arg, i32 1, i64 %arg1) + %tmp = call i64 @llvm.ptrauth.auth(i64 %arg) [ "ptrauth"(i64 1, i64 %arg1) ] ret i64 %tmp } @@ -175,7 +175,7 @@ define i64 @test_auth_ib_zero(i64 %arg) { ; TRAP-NEXT: Lauth_success_3: ; TRAP-DARWIN-NEXT: mov x0, x16 ; TRAP-NEXT: ret - %tmp = call i64 @llvm.ptrauth.auth(i64 %arg, i32 1, i64 0) + %tmp = call i64 @llvm.ptrauth.auth(i64 %arg) [ "ptrauth"(i64 1, i64 0) ] ret i64 %tmp } @@ -212,7 +212,7 @@ define i64 @test_auth_da(i64 %arg, i64 %arg1) { ; TRAP-NEXT: Lauth_success_4: ; TRAP-DARWIN-NEXT: mov x0, x16 ; TRAP-NEXT: ret - %tmp = call i64 @llvm.ptrauth.auth(i64 %arg, i32 2, i64 %arg1) + %tmp = call i64 @llvm.ptrauth.auth(i64 %arg) [ "ptrauth"(i64 2, i64 %arg1) ] ret i64 %tmp } @@ -249,7 +249,7 @@ define i64 @test_auth_da_zero(i64 %arg) { ; TRAP-NEXT: Lauth_success_5: ; TRAP-DARWIN-NEXT: mov x0, x16 ; TRAP-NEXT: ret - %tmp = call i64 @llvm.ptrauth.auth(i64 %arg, i32 2, i64 0) + %tmp = call i64 @llvm.ptrauth.auth(i64 %arg) [ "ptrauth"(i64 2, i64 0) ] ret i64 %tmp } @@ -286,7 +286,7 @@ define i64 @test_auth_db(i64 %arg, i64 %arg1) { ; TRAP-NEXT: Lauth_success_6: ; TRAP-DARWIN-NEXT: mov x0, x16 ; TRAP-NEXT: ret - %tmp = call i64 @llvm.ptrauth.auth(i64 %arg, i32 3, i64 %arg1) + %tmp = call i64 @llvm.ptrauth.auth(i64 %arg) [ "ptrauth"(i64 3, i64 %arg1) ] ret i64 %tmp } @@ -323,7 +323,7 @@ define i64 @test_auth_db_zero(i64 %arg) { ; TRAP-NEXT: Lauth_success_7: ; TRAP-DARWIN-NEXT: mov x0, x16 ; TRAP-NEXT: ret - %tmp = call i64 @llvm.ptrauth.auth(i64 %arg, i32 3, i64 0) + %tmp = call i64 @llvm.ptrauth.auth(i64 %arg) [ "ptrauth"(i64 3, i64 0) ] ret i64 %tmp } @@ -367,7 +367,7 @@ define i64 @test_resign_ia_ia(i64 %arg, i64 %arg1, i64 %arg2) { ; TRAP-NEXT: pacia x16, x2 ; TRAP-NEXT: mov x0, x16 ; TRAP-NEXT: ret - %tmp = call i64 @llvm.ptrauth.resign(i64 %arg, i32 0, i64 %arg1, i32 0, i64 %arg2) + %tmp = call i64 @llvm.ptrauth.resign(i64 %arg) [ "ptrauth"(i64 0, i64 %arg1), "ptrauth"(i64 0, i64 %arg2) ] ret i64 %tmp } @@ -409,7 +409,7 @@ define i64 @test_resign_ib_ia(i64 %arg, i64 %arg1, i64 %arg2) { ; TRAP-NEXT: pacia x16, x2 ; TRAP-NEXT: mov x0, x16 ; TRAP-NEXT: ret - %tmp = call i64 @llvm.ptrauth.resign(i64 %arg, i32 1, i64 %arg1, i32 0, i64 %arg2) + %tmp = call i64 @llvm.ptrauth.resign(i64 %arg) [ "ptrauth"(i64 1, i64 %arg1), "ptrauth"(i64 0, i64 %arg2) ] ret i64 %tmp } @@ -451,7 +451,7 @@ define i64 @test_resign_da_ia(i64 %arg, i64 %arg1, i64 %arg2) { ; TRAP-NEXT: pacia x16, x2 ; TRAP-NEXT: mov x0, x16 ; TRAP-NEXT: ret - %tmp = call i64 @llvm.ptrauth.resign(i64 %arg, i32 2, i64 %arg1, i32 0, i64 %arg2) + %tmp = call i64 @llvm.ptrauth.resign(i64 %arg) [ "ptrauth"(i64 2, i64 %arg1), "ptrauth"(i64 0, i64 %arg2) ] ret i64 %tmp } @@ -493,7 +493,7 @@ define i64 @test_resign_db_da(i64 %arg, i64 %arg1, i64 %arg2) { ; TRAP-NEXT: pacda x16, x2 ; TRAP-NEXT: mov x0, x16 ; TRAP-NEXT: ret - %tmp = call i64 @llvm.ptrauth.resign(i64 %arg, i32 3, i64 %arg1, i32 2, i64 %arg2) + %tmp = call i64 @llvm.ptrauth.resign(i64 %arg) [ "ptrauth"(i64 3, i64 %arg1), "ptrauth"(i64 2, i64 %arg2) ] ret i64 %tmp } @@ -535,7 +535,7 @@ define i64 @test_resign_iza_db(i64 %arg, i64 %arg1, i64 %arg2) { ; TRAP-NEXT: pacdb x16, x2 ; TRAP-NEXT: mov x0, x16 ; TRAP-NEXT: ret - %tmp = call i64 @llvm.ptrauth.resign(i64 %arg, i32 0, i64 0, i32 3, i64 %arg2) + %tmp = call i64 @llvm.ptrauth.resign(i64 %arg) [ "ptrauth"(i64 0, i64 0), "ptrauth"(i64 3, i64 %arg2) ] ret i64 %tmp } @@ -577,7 +577,7 @@ define i64 @test_resign_da_dzb(i64 %arg, i64 %arg1, i64 %arg2) { ; TRAP-NEXT: pacdzb x16 ; TRAP-NEXT: mov x0, x16 ; TRAP-NEXT: ret - %tmp = call i64 @llvm.ptrauth.resign(i64 %arg, i32 2, i64 %arg1, i32 3, i64 0) + %tmp = call i64 @llvm.ptrauth.resign(i64 %arg) [ "ptrauth"(i64 2, i64 %arg1), "ptrauth"(i64 3, i64 0) ] ret i64 %tmp } @@ -623,7 +623,7 @@ define i64 @test_auth_trap_attribute(i64 %arg, i64 %arg1) "ptrauth-auth-traps" { ; TRAP-NEXT: Lauth_success_14: ; TRAP-DARWIN-NEXT: mov x0, x16 ; TRAP-NEXT: ret - %tmp = call i64 @llvm.ptrauth.auth(i64 %arg, i32 0, i64 %arg1) + %tmp = call i64 @llvm.ptrauth.auth(i64 %arg) [ "ptrauth"(i64 0, i64 %arg1) ] ret i64 %tmp } @@ -666,7 +666,7 @@ define i64 @test_auth_ia_constdisc(i64 %arg) { ; TRAP-NEXT: Lauth_success_15: ; TRAP-DARWIN-NEXT: mov x0, x16 ; TRAP-NEXT: ret - %tmp = call i64 @llvm.ptrauth.auth(i64 %arg, i32 0, i64 256) + %tmp = call i64 @llvm.ptrauth.auth(i64 %arg) [ "ptrauth"(i64 0, i64 256) ] ret i64 %tmp } @@ -711,7 +711,7 @@ define i64 @test_resign_da_constdisc(i64 %arg, i64 %arg1) { ; TRAP-NEXT: pacda x16, x17 ; TRAP-NEXT: mov x0, x16 ; TRAP-NEXT: ret - %tmp = call i64 @llvm.ptrauth.resign(i64 %arg, i32 2, i64 %arg1, i32 2, i64 256) + %tmp = call i64 @llvm.ptrauth.resign(i64 %arg) [ "ptrauth"(i64 2, i64 %arg1), "ptrauth"(i64 2, i64 256) ] ret i64 %tmp } @@ -751,7 +751,7 @@ define i64 @test_auth_ia_swapped(i64 %arg, i64 %arg1) { ; TRAP-DARWIN-NEXT: mov x0, x16 ; TRAP-ELF-NEXT: mov x0, x1 ; TRAP-NEXT: ret - %tmp = call i64 @llvm.ptrauth.auth(i64 %arg1, i32 0, i64 %arg) + %tmp = call i64 @llvm.ptrauth.auth(i64 %arg1) [ "ptrauth"(i64 0, i64 %arg) ] ret i64 %tmp } @@ -858,11 +858,11 @@ entry: br i1 %cond, label %if.then, label %if.else if.then: - %auted.then = tail call i64 @llvm.ptrauth.auth(i64 %signed, i32 2, i64 0) + %auted.then = tail call i64 @llvm.ptrauth.auth(i64 %signed) [ "ptrauth"(i64 2, i64 0) ] br label %return if.else: - %auted.else = tail call i64 @llvm.ptrauth.auth(i64 %signed, i32 3, i64 0) + %auted.else = tail call i64 @llvm.ptrauth.auth(i64 %signed) [ "ptrauth"(i64 3, i64 0) ] br label %return return: @@ -877,6 +877,3 @@ return: %ptr.4 = load ptr, ptr %ptr.3 ret ptr %ptr.4 } - -declare i64 @llvm.ptrauth.auth(i64, i32, i64) -declare i64 @llvm.ptrauth.resign(i64, i32, i64, i32, i64) diff --git a/llvm/test/CodeGen/AArch64/ptrauth-intrinsic-sign.ll b/llvm/test/CodeGen/AArch64/ptrauth-intrinsic-sign.ll index 01fdc05a5aa09..cbe4c0bacfbf9 100644 --- a/llvm/test/CodeGen/AArch64/ptrauth-intrinsic-sign.ll +++ b/llvm/test/CodeGen/AArch64/ptrauth-intrinsic-sign.ll @@ -9,7 +9,7 @@ define i64 @test_sign_ia(i64 %arg, i64 %arg1) { ; CHECK: %bb.0: ; CHECK-NEXT: pacia x0, x1 ; CHECK-NEXT: ret - %tmp = call i64 @llvm.ptrauth.sign(i64 %arg, i32 0, i64 %arg1) + %tmp = call i64 @llvm.ptrauth.sign(i64 %arg) [ "ptrauth"(i64 0, i64 %arg1) ] ret i64 %tmp } @@ -18,7 +18,7 @@ define i64 @test_sign_ia_zero(i64 %arg) { ; CHECK: %bb.0: ; CHECK-NEXT: paciza x0 ; CHECK-NEXT: ret - %tmp = call i64 @llvm.ptrauth.sign(i64 %arg, i32 0, i64 0) + %tmp = call i64 @llvm.ptrauth.sign(i64 %arg) [ "ptrauth"(i64 0, i64 0) ] ret i64 %tmp } @@ -27,7 +27,7 @@ define i64 @test_sign_ib(i64 %arg, i64 %arg1) { ; CHECK: %bb.0: ; CHECK-NEXT: pacib x0, x1 ; CHECK-NEXT: ret - %tmp = call i64 @llvm.ptrauth.sign(i64 %arg, i32 1, i64 %arg1) + %tmp = call i64 @llvm.ptrauth.sign(i64 %arg) [ "ptrauth"(i64 1, i64 %arg1) ] ret i64 %tmp } @@ -36,7 +36,7 @@ define i64 @test_sign_ib_zero(i64 %arg) { ; CHECK: %bb.0: ; CHECK-NEXT: pacizb x0 ; CHECK-NEXT: ret - %tmp = call i64 @llvm.ptrauth.sign(i64 %arg, i32 1, i64 0) + %tmp = call i64 @llvm.ptrauth.sign(i64 %arg) [ "ptrauth"(i64 1, i64 0) ] ret i64 %tmp } @@ -45,7 +45,7 @@ define i64 @test_sign_da(i64 %arg, i64 %arg1) { ; CHECK: %bb.0: ; CHECK-NEXT: pacda x0, x1 ; CHECK-NEXT: ret - %tmp = call i64 @llvm.ptrauth.sign(i64 %arg, i32 2, i64 %arg1) + %tmp = call i64 @llvm.ptrauth.sign(i64 %arg) [ "ptrauth"(i64 2, i64 %arg1) ] ret i64 %tmp } @@ -54,7 +54,7 @@ define i64 @test_sign_da_zero(i64 %arg) { ; CHECK: %bb.0: ; CHECK-NEXT: pacdza x0 ; CHECK-NEXT: ret - %tmp = call i64 @llvm.ptrauth.sign(i64 %arg, i32 2, i64 0) + %tmp = call i64 @llvm.ptrauth.sign(i64 %arg) [ "ptrauth"(i64 2, i64 0) ] ret i64 %tmp } @@ -63,7 +63,7 @@ define i64 @test_sign_db(i64 %arg, i64 %arg1) { ; CHECK: %bb.0: ; CHECK-NEXT: pacdb x0, x1 ; CHECK-NEXT: ret - %tmp = call i64 @llvm.ptrauth.sign(i64 %arg, i32 3, i64 %arg1) + %tmp = call i64 @llvm.ptrauth.sign(i64 %arg) [ "ptrauth"(i64 3, i64 %arg1) ] ret i64 %tmp } @@ -72,8 +72,6 @@ define i64 @test_sign_db_zero(i64 %arg) { ; CHECK: %bb.0: ; CHECK-NEXT: pacdzb x0 ; CHECK-NEXT: ret - %tmp = call i64 @llvm.ptrauth.sign(i64 %arg, i32 3, i64 0) + %tmp = call i64 @llvm.ptrauth.sign(i64 %arg) [ "ptrauth"(i64 3, i64 0) ] ret i64 %tmp } - -declare i64 @llvm.ptrauth.sign(i64, i32, i64) diff --git a/llvm/test/CodeGen/AArch64/ptrauth-isel.ll b/llvm/test/CodeGen/AArch64/ptrauth-isel.ll index 7011b946aad74..3f47685b2ec4d 100644 --- a/llvm/test/CodeGen/AArch64/ptrauth-isel.ll +++ b/llvm/test/CodeGen/AArch64/ptrauth-isel.ll @@ -45,7 +45,7 @@ define i64 @small_imm_disc_optimized(i64 %addr) { ; GISEL-NEXT: $x0 = COPY [[PAC]] ; GISEL-NEXT: RET_ReallyLR implicit $x0 entry: - %signed = call i64 @llvm.ptrauth.sign(i64 %addr, i32 2, i64 42) + %signed = call i64 @llvm.ptrauth.sign(i64 %addr) [ "ptrauth"(i64 2, i64 42) ] ret i64 %signed } @@ -74,7 +74,7 @@ define i64 @small_imm_disc_non_optimized(i64 %addr) noinline optnone { ; GISEL-NEXT: $x0 = COPY [[PAC]] ; GISEL-NEXT: RET_ReallyLR implicit $x0 entry: - %signed = call i64 @llvm.ptrauth.sign(i64 %addr, i32 2, i64 42) + %signed = call i64 @llvm.ptrauth.sign(i64 %addr) [ "ptrauth"(i64 2, i64 42) ] ret i64 %signed } @@ -101,7 +101,7 @@ define i64 @large_imm_disc_wreg(i64 %addr) { ; GISEL-NEXT: $x0 = COPY [[PAC]] ; GISEL-NEXT: RET_ReallyLR implicit $x0 entry: - %signed = call i64 @llvm.ptrauth.sign(i64 %addr, i32 2, i64 12345678) + %signed = call i64 @llvm.ptrauth.sign(i64 %addr) [ "ptrauth"(i64 2, i64 12345678) ] ret i64 %signed } @@ -126,7 +126,7 @@ define i64 @large_imm_disc_xreg(i64 %addr) { ; GISEL-NEXT: $x0 = COPY [[PAC]] ; GISEL-NEXT: RET_ReallyLR implicit $x0 entry: - %signed = call i64 @llvm.ptrauth.sign(i64 %addr, i32 2, i64 123456789012345) + %signed = call i64 @llvm.ptrauth.sign(i64 %addr) [ "ptrauth"(i64 2, i64 123456789012345) ] ret i64 %signed } @@ -161,7 +161,7 @@ define i64 @blended_disc_non_optimized(i64 %addr, i64 %addrdisc) noinline optnon ; GISEL-NEXT: RET_ReallyLR implicit $x0 entry: %disc = call i64 @llvm.ptrauth.blend(i64 %addrdisc, i64 42) - %signed = call i64 @llvm.ptrauth.sign(i64 %addr, i32 2, i64 %disc) + %signed = call i64 @llvm.ptrauth.sign(i64 %addr) [ "ptrauth"(i64 2, i64 %disc) ] ret i64 %signed } @@ -194,7 +194,7 @@ define i64 @blend_and_sign_same_bb(i64 %addr) { entry: %addrdisc = load i64, ptr @discvar %disc = call i64 @llvm.ptrauth.blend(i64 %addrdisc, i64 42) - %signed = call i64 @llvm.ptrauth.sign(i64 %addr, i32 2, i64 %disc) + %signed = call i64 @llvm.ptrauth.sign(i64 %addr) [ "ptrauth"(i64 2, i64 %disc) ] ret i64 %signed } @@ -264,6 +264,6 @@ next: br label %exit exit: - %signed = call i64 @llvm.ptrauth.sign(i64 %addr, i32 2, i64 %disc) + %signed = call i64 @llvm.ptrauth.sign(i64 %addr) [ "ptrauth"(i64 2, i64 %disc) ] ret i64 %signed } diff --git a/llvm/test/CodeGen/MIR/AArch64/deactivation-symbols.mir b/llvm/test/CodeGen/MIR/AArch64/deactivation-symbols.mir index 6542508ede116..8e0ab43274311 100644 --- a/llvm/test/CodeGen/MIR/AArch64/deactivation-symbols.mir +++ b/llvm/test/CodeGen/MIR/AArch64/deactivation-symbols.mir @@ -6,7 +6,7 @@ define i64 @pauth_sign_zero(i64 %p) { ; CHECK: G_INTRINSIC intrinsic(@llvm.ptrauth.sign), %0(s64), 0, %2(s64), deactivation-symbol @ds - %signed = call i64 @llvm.ptrauth.sign(i64 %p, i32 0, i64 0) [ "deactivation-symbol"(ptr @ds) ] + %signed = call i64 @llvm.ptrauth.sign(i64 %p) [ "ptrauth"(i64 0, i64 0), "deactivation-symbol"(ptr @ds) ] ret i64 %signed } ... diff --git a/llvm/test/CodeGen/MIR2Vec/Inputs/reference_x86_vocab_print.txt b/llvm/test/CodeGen/MIR2Vec/Inputs/reference_x86_vocab_print.txt index 25c401884748e..810e9676a33a0 100644 --- a/llvm/test/CodeGen/MIR2Vec/Inputs/reference_x86_vocab_print.txt +++ b/llvm/test/CodeGen/MIR2Vec/Inputs/reference_x86_vocab_print.txt @@ -477,8 +477,11 @@ Key: G_MUL: [ 0.00 0.00 ] Key: G_OR: [ 0.00 0.00 ] Key: G_PHI: [ 0.00 0.00 ] Key: G_PREFETCH: [ 0.00 0.00 ] +Key: G_PTRAUTH_AUTH: [ 0.00 0.00 ] Key: G_PTRAUTH_BUNDLE: [ 0.00 0.00 ] Key: G_PTRAUTH_GLOBAL_VALUE: [ 0.00 0.00 ] +Key: G_PTRAUTH_RESIGN: [ 0.00 0.00 ] +Key: G_PTRAUTH_SIGN: [ 0.00 0.00 ] Key: G_PTRAUTH_STRIP: [ 0.00 0.00 ] Key: G_PTRMASK: [ 0.00 0.00 ] Key: G_PTRTOINT: [ 0.00 0.00 ] diff --git a/llvm/test/CodeGen/MIR2Vec/Inputs/reference_x86_vocab_wo=0.5_print.txt b/llvm/test/CodeGen/MIR2Vec/Inputs/reference_x86_vocab_wo=0.5_print.txt index 9eaf8554ad305..cf0288ddf5418 100644 --- a/llvm/test/CodeGen/MIR2Vec/Inputs/reference_x86_vocab_wo=0.5_print.txt +++ b/llvm/test/CodeGen/MIR2Vec/Inputs/reference_x86_vocab_wo=0.5_print.txt @@ -477,8 +477,11 @@ Key: G_MUL: [ 0.00 0.00 ] Key: G_OR: [ 0.00 0.00 ] Key: G_PHI: [ 0.00 0.00 ] Key: G_PREFETCH: [ 0.00 0.00 ] +Key: G_PTRAUTH_AUTH: [ 0.00 0.00 ] Key: G_PTRAUTH_BUNDLE: [ 0.00 0.00 ] Key: G_PTRAUTH_GLOBAL_VALUE: [ 0.00 0.00 ] +Key: G_PTRAUTH_RESIGN: [ 0.00 0.00 ] +Key: G_PTRAUTH_SIGN: [ 0.00 0.00 ] Key: G_PTRAUTH_STRIP: [ 0.00 0.00 ] Key: G_PTRMASK: [ 0.00 0.00 ] Key: G_PTRTOINT: [ 0.00 0.00 ] diff --git a/llvm/test/TableGen/GlobalISelCombinerEmitter/match-table-cxx.td b/llvm/test/TableGen/GlobalISelCombinerEmitter/match-table-cxx.td index d36e7edc439e9..8257da322038b 100644 --- a/llvm/test/TableGen/GlobalISelCombinerEmitter/match-table-cxx.td +++ b/llvm/test/TableGen/GlobalISelCombinerEmitter/match-table-cxx.td @@ -96,7 +96,7 @@ def MyCombiner: GICombiner<"GenMyCombiner", [ // CHECK: const uint8_t *GenMyCombiner::getMatchTable() const { // CHECK-NEXT: constexpr static uint8_t MatchTable0[] = { -// CHECK-NEXT: /* 0 */ GIM_SwitchOpcode, /*MI*/0, /*[*/GIMT_Encode2(107), GIMT_Encode2(219), /*)*//*default:*//*Label 5*/ GIMT_Encode4(524), +// CHECK-NEXT: /* 0 */ GIM_SwitchOpcode, /*MI*/0, /*[*/GIMT_Encode2(110), GIMT_Encode2(222), /*)*//*default:*//*Label 5*/ GIMT_Encode4(524), // CHECK-NEXT: /* 10 */ /*TargetOpcode::G_STORE*//*Label 0*/ GIMT_Encode4(458), GIMT_Encode4(0), GIMT_Encode4(0), GIMT_Encode4(0), GIMT_Encode4(0), GIMT_Encode4(0), GIMT_Encode4(0), GIMT_Encode4(0), GIMT_Encode4(0), GIMT_Encode4(0), GIMT_Encode4(0), GIMT_Encode4(0), GIMT_Encode4(0), GIMT_Encode4(0), GIMT_Encode4(0), GIMT_Encode4(0), GIMT_Encode4(0), GIMT_Encode4(0), GIMT_Encode4(0), GIMT_Encode4(0), GIMT_Encode4(0), GIMT_Encode4(0), GIMT_Encode4(0), GIMT_Encode4(0), GIMT_Encode4(0), GIMT_Encode4(0), GIMT_Encode4(0), GIMT_Encode4(0), GIMT_Encode4(0), GIMT_Encode4(0), GIMT_Encode4(0), GIMT_Encode4(0), GIMT_Encode4(0), GIMT_Encode4(0), GIMT_Encode4(0), GIMT_Encode4(0), GIMT_Encode4(0), GIMT_Encode4(0), GIMT_Encode4(0), GIMT_Encode4(0), GIMT_Encode4(0), GIMT_Encode4(0), GIMT_Encode4(0), // CHECK-NEXT: /* 182 */ /*TargetOpcode::G_SEXT*//*Label 1*/ GIMT_Encode4(476), GIMT_Encode4(0), // CHECK-NEXT: /* 190 */ /*TargetOpcode::G_ZEXT*//*Label 2*/ GIMT_Encode4(488), GIMT_Encode4(0), GIMT_Encode4(0), GIMT_Encode4(0), GIMT_Encode4(0), GIMT_Encode4(0), GIMT_Encode4(0), GIMT_Encode4(0), GIMT_Encode4(0), GIMT_Encode4(0), GIMT_Encode4(0), GIMT_Encode4(0), GIMT_Encode4(0), GIMT_Encode4(0), GIMT_Encode4(0), GIMT_Encode4(0), GIMT_Encode4(0), GIMT_Encode4(0), GIMT_Encode4(0), GIMT_Encode4(0), GIMT_Encode4(0), GIMT_Encode4(0), GIMT_Encode4(0), GIMT_Encode4(0), GIMT_Encode4(0), GIMT_Encode4(0), GIMT_Encode4(0), GIMT_Encode4(0), GIMT_Encode4(0), GIMT_Encode4(0), GIMT_Encode4(0), GIMT_Encode4(0), GIMT_Encode4(0), GIMT_Encode4(0), GIMT_Encode4(0), GIMT_Encode4(0), GIMT_Encode4(0), GIMT_Encode4(0), GIMT_Encode4(0), GIMT_Encode4(0), GIMT_Encode4(0), GIMT_Encode4(0), GIMT_Encode4(0), GIMT_Encode4(0), GIMT_Encode4(0), GIMT_Encode4(0), GIMT_Encode4(0), GIMT_Encode4(0), GIMT_Encode4(0), GIMT_Encode4(0), GIMT_Encode4(0), GIMT_Encode4(0), GIMT_Encode4(0), GIMT_Encode4(0), GIMT_Encode4(0), GIMT_Encode4(0), diff --git a/llvm/test/TableGen/GlobalISelEmitter/GlobalISelEmitter.td b/llvm/test/TableGen/GlobalISelEmitter/GlobalISelEmitter.td index c686e0d1519b0..b0b5746c32ad4 100644 --- a/llvm/test/TableGen/GlobalISelEmitter/GlobalISelEmitter.td +++ b/llvm/test/TableGen/GlobalISelEmitter/GlobalISelEmitter.td @@ -535,7 +535,7 @@ def : Pat<(frag GPR32:$src1, complex:$src2, complex:$src3), // R00O-NEXT: GIM_Reject, // R00O: // Label [[DEFAULT_NUM]]: @[[DEFAULT]] // R00O-NEXT: GIM_Reject, -// R00O-NEXT: }; // Size: 1926 bytes +// R00O-NEXT: }; // Size: 1938 bytes def INSNBOB : I<(outs GPR32:$dst), (ins GPR32:$src1, GPR32:$src2, GPR32:$src3, GPR32:$src4), [(set GPR32:$dst, diff --git a/llvm/test/TableGen/get-named-operand-idx.td b/llvm/test/TableGen/get-named-operand-idx.td index 06ec001852e17..9bba98a62f10b 100644 --- a/llvm/test/TableGen/get-named-operand-idx.td +++ b/llvm/test/TableGen/get-named-operand-idx.td @@ -98,7 +98,7 @@ defm : RemapAllTargetPseudoPointerOperands; // CHECK-NEXT: 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // CHECK-NEXT: 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // CHECK-NEXT: 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -// CHECK-NEXT: 0, 0, 1, 2, 2, 0, +// CHECK-NEXT: 0, 0, 0, 0, 1, 2, 2, 0, // CHECK-NEXT: }; // CHECK-NEXT: return InstructionIndex[Opcode]; // CHECK-NEXT: } diff --git a/llvm/test/Transforms/InstCombine/ptrauth-intrinsics-call.ll b/llvm/test/Transforms/InstCombine/ptrauth-intrinsics-call.ll index 4ef78353ae1e2..f7a4ad981a6cf 100644 --- a/llvm/test/Transforms/InstCombine/ptrauth-intrinsics-call.ll +++ b/llvm/test/Transforms/InstCombine/ptrauth-intrinsics-call.ll @@ -7,9 +7,9 @@ define i32 @test_ptrauth_call_sign(ptr %p) { ; CHECK-NEXT: ret i32 [[V3]] ; %v0 = ptrtoint ptr %p to i64 - %v1 = call i64 @llvm.ptrauth.sign(i64 %v0, i32 2, i64 5678) + %v1 = call i64 @llvm.ptrauth.sign(i64 %v0) [ "ptrauth"(i64 2, i64 5678) ] %v2 = inttoptr i64 %v1 to ptr - %v3 = call i32 %v2() [ "ptrauth"(i32 2, i64 5678) ] + %v3 = call i32 %v2() [ "ptrauth"(i64 2, i64 5678) ] ret i32 %v3 } @@ -19,37 +19,37 @@ define i32 @test_ptrauth_call_sign_otherbundle(ptr %p) { ; CHECK-NEXT: ret i32 [[V3]] ; %v0 = ptrtoint ptr %p to i64 - %v1 = call i64 @llvm.ptrauth.sign(i64 %v0, i32 2, i64 5678) + %v1 = call i64 @llvm.ptrauth.sign(i64 %v0) [ "ptrauth"(i64 2, i64 5678) ] %v2 = inttoptr i64 %v1 to ptr - %v3 = call i32 %v2() [ "somebundle"(ptr null), "ptrauth"(i32 2, i64 5678), "otherbundle"(i64 0) ] + %v3 = call i32 %v2() [ "somebundle"(ptr null), "ptrauth"(i64 2, i64 5678), "otherbundle"(i64 0) ] ret i32 %v3 } define i32 @test_ptrauth_call_resign(ptr %p) { ; CHECK-LABEL: @test_ptrauth_call_resign( -; CHECK-NEXT: [[V3:%.*]] = call i32 [[P:%.*]]() [ "ptrauth"(i32 1, i64 1234) ] +; CHECK-NEXT: [[V3:%.*]] = call i32 [[P:%.*]]() [ "ptrauth"(i64 1, i64 1234) ] ; CHECK-NEXT: ret i32 [[V3]] ; %v0 = ptrtoint ptr %p to i64 - %v1 = call i64 @llvm.ptrauth.resign(i64 %v0, i32 1, i64 1234, i32 1, i64 5678) + %v1 = call i64 @llvm.ptrauth.resign(i64 %v0) [ "ptrauth"(i64 1, i64 1234), "ptrauth"(i64 1, i64 5678) ] %v2 = inttoptr i64 %v1 to ptr - %v3 = call i32 %v2() [ "ptrauth"(i32 1, i64 5678) ] + %v3 = call i32 %v2() [ "ptrauth"(i64 1, i64 5678) ] ret i32 %v3 } define i32 @test_ptrauth_call_resign_blend(ptr %pp) { ; CHECK-LABEL: @test_ptrauth_call_resign_blend( ; CHECK-NEXT: [[V01:%.*]] = load ptr, ptr [[PP:%.*]], align 8 -; CHECK-NEXT: [[V6:%.*]] = call i32 [[V01]]() [ "ptrauth"(i32 1, i64 1234) ] +; CHECK-NEXT: [[V6:%.*]] = call i32 [[V01]]() [ "ptrauth"(i64 1, i64 1234) ] ; CHECK-NEXT: ret i32 [[V6]] ; %v0 = load ptr, ptr %pp, align 8 %v1 = ptrtoint ptr %pp to i64 %v2 = ptrtoint ptr %v0 to i64 %v3 = call i64 @llvm.ptrauth.blend(i64 %v1, i64 5678) - %v4 = call i64 @llvm.ptrauth.resign(i64 %v2, i32 1, i64 1234, i32 1, i64 %v3) + %v4 = call i64 @llvm.ptrauth.resign(i64 %v2) [ "ptrauth"(i64 1, i64 1234), "ptrauth"(i64 1, i64 %v3) ] %v5 = inttoptr i64 %v4 to ptr - %v6 = call i32 %v5() [ "ptrauth"(i32 1, i64 %v3) ] + %v6 = call i32 %v5() [ "ptrauth"(i64 1, i64 %v3) ] ret i32 %v6 } @@ -58,46 +58,46 @@ define i32 @test_ptrauth_call_resign_blend_2(ptr %pp) { ; CHECK-NEXT: [[V01:%.*]] = load ptr, ptr [[PP:%.*]], align 8 ; CHECK-NEXT: [[V1:%.*]] = ptrtoint ptr [[PP]] to i64 ; CHECK-NEXT: [[V3:%.*]] = call i64 @llvm.ptrauth.blend(i64 [[V1]], i64 5678) -; CHECK-NEXT: [[V6:%.*]] = call i32 [[V01]]() [ "ptrauth"(i32 0, i64 [[V3]]) ] +; CHECK-NEXT: [[V6:%.*]] = call i32 [[V01]]() [ "ptrauth"(i64 0, i64 [[V3]]) ] ; CHECK-NEXT: ret i32 [[V6]] ; %v0 = load ptr, ptr %pp, align 8 %v1 = ptrtoint ptr %pp to i64 %v2 = ptrtoint ptr %v0 to i64 %v3 = call i64 @llvm.ptrauth.blend(i64 %v1, i64 5678) - %v4 = call i64 @llvm.ptrauth.resign(i64 %v2, i32 0, i64 %v3, i32 0, i64 1234) + %v4 = call i64 @llvm.ptrauth.resign(i64 %v2) [ "ptrauth"(i64 0, i64 %v3), "ptrauth"(i64 0, i64 1234) ] %v5 = inttoptr i64 %v4 to ptr - %v6 = call i32 %v5() [ "ptrauth"(i32 0, i64 1234) ] + %v6 = call i32 %v5() [ "ptrauth"(i64 0, i64 1234) ] ret i32 %v6 } define i32 @test_ptrauth_call_resign_mismatch_key(ptr %p) { ; CHECK-LABEL: @test_ptrauth_call_resign_mismatch_key( ; CHECK-NEXT: [[V0:%.*]] = ptrtoint ptr [[P:%.*]] to i64 -; CHECK-NEXT: [[V1:%.*]] = call i64 @llvm.ptrauth.resign(i64 [[V0]], i32 1, i64 1234, i32 0, i64 5678) +; CHECK-NEXT: [[V1:%.*]] = call i64 @llvm.ptrauth.resign(i64 [[V0]]) [ "ptrauth"(i64 1, i64 1234), "ptrauth"(i64 0, i64 5678) ] ; CHECK-NEXT: [[V2:%.*]] = inttoptr i64 [[V1]] to ptr -; CHECK-NEXT: [[V3:%.*]] = call i32 [[V2]]() [ "ptrauth"(i32 1, i64 5678) ] +; CHECK-NEXT: [[V3:%.*]] = call i32 [[V2]]() [ "ptrauth"(i64 1, i64 5678) ] ; CHECK-NEXT: ret i32 [[V3]] ; %v0 = ptrtoint ptr %p to i64 - %v1 = call i64 @llvm.ptrauth.resign(i64 %v0, i32 1, i64 1234, i32 0, i64 5678) + %v1 = call i64 @llvm.ptrauth.resign(i64 %v0) [ "ptrauth"(i64 1, i64 1234), "ptrauth"(i64 0, i64 5678) ] %v2 = inttoptr i64 %v1 to ptr - %v3 = call i32 %v2() [ "ptrauth"(i32 1, i64 5678) ] + %v3 = call i32 %v2() [ "ptrauth"(i64 1, i64 5678) ] ret i32 %v3 } define i32 @test_ptrauth_call_resign_mismatch_disc(ptr %p) { ; CHECK-LABEL: @test_ptrauth_call_resign_mismatch_disc( ; CHECK-NEXT: [[V0:%.*]] = ptrtoint ptr [[P:%.*]] to i64 -; CHECK-NEXT: [[V1:%.*]] = call i64 @llvm.ptrauth.resign(i64 [[V0]], i32 1, i64 1234, i32 0, i64 9900) +; CHECK-NEXT: [[V1:%.*]] = call i64 @llvm.ptrauth.resign(i64 [[V0]]) [ "ptrauth"(i64 1, i64 1234), "ptrauth"(i64 0, i64 9900) ] ; CHECK-NEXT: [[V2:%.*]] = inttoptr i64 [[V1]] to ptr -; CHECK-NEXT: [[V3:%.*]] = call i32 [[V2]]() [ "ptrauth"(i32 1, i64 5678) ] +; CHECK-NEXT: [[V3:%.*]] = call i32 [[V2]]() [ "ptrauth"(i64 1, i64 5678) ] ; CHECK-NEXT: ret i32 [[V3]] ; %v0 = ptrtoint ptr %p to i64 - %v1 = call i64 @llvm.ptrauth.resign(i64 %v0, i32 1, i64 1234, i32 0, i64 9900) + %v1 = call i64 @llvm.ptrauth.resign(i64 %v0) [ "ptrauth"(i64 1, i64 1234), "ptrauth"(i64 0, i64 9900) ] %v2 = inttoptr i64 %v1 to ptr - %v3 = call i32 %v2() [ "ptrauth"(i32 1, i64 5678) ] + %v3 = call i32 %v2() [ "ptrauth"(i64 1, i64 5678) ] ret i32 %v3 } @@ -107,33 +107,29 @@ define i32 @test_ptrauth_call_resign_mismatch_blend(ptr %pp) { ; CHECK-NEXT: [[V1:%.*]] = ptrtoint ptr [[PP]] to i64 ; CHECK-NEXT: [[V2:%.*]] = ptrtoint ptr [[V0]] to i64 ; CHECK-NEXT: [[V6:%.*]] = call i64 @llvm.ptrauth.blend(i64 [[V1]], i64 5678) -; CHECK-NEXT: [[V4:%.*]] = call i64 @llvm.ptrauth.resign(i64 [[V2]], i32 1, i64 1234, i32 1, i64 [[V6]]) +; CHECK-NEXT: [[V4:%.*]] = call i64 @llvm.ptrauth.resign(i64 [[V2]]) [ "ptrauth"(i64 1, i64 1234), "ptrauth"(i64 1, i64 [[V6]]) ] ; CHECK-NEXT: [[V5:%.*]] = inttoptr i64 [[V4]] to ptr -; CHECK-NEXT: [[V3:%.*]] = call i32 [[V5]]() [ "ptrauth"(i32 1, i64 [[V1]]) ] +; CHECK-NEXT: [[V3:%.*]] = call i32 [[V5]]() [ "ptrauth"(i64 1, i64 [[V1]]) ] ; CHECK-NEXT: ret i32 [[V3]] ; %v0 = load ptr, ptr %pp, align 8 %v1 = ptrtoint ptr %pp to i64 %v2 = ptrtoint ptr %v0 to i64 %v3 = call i64 @llvm.ptrauth.blend(i64 %v1, i64 5678) - %v4 = call i64 @llvm.ptrauth.resign(i64 %v2, i32 1, i64 1234, i32 1, i64 %v3) + %v4 = call i64 @llvm.ptrauth.resign(i64 %v2) [ "ptrauth"(i64 1, i64 1234), "ptrauth"(i64 1, i64 %v3) ] %v5 = inttoptr i64 %v4 to ptr - %v6 = call i32 %v5() [ "ptrauth"(i32 1, i64 %v1) ] + %v6 = call i32 %v5() [ "ptrauth"(i64 1, i64 %v1) ] ret i32 %v6 } define i32 @test_ptrauth_call_resign_changing_call_key(ptr %p) { ; CHECK-LABEL: @test_ptrauth_call_resign_changing_call_key( -; CHECK-NEXT: [[V3:%.*]] = call i32 [[P:%.*]]() [ "ptrauth"(i32 2, i64 1234) ] +; CHECK-NEXT: [[V3:%.*]] = call i32 [[P:%.*]]() [ "ptrauth"(i64 2, i64 1234) ] ; CHECK-NEXT: ret i32 [[V3]] ; %v0 = ptrtoint ptr %p to i64 - %v1 = call i64 @llvm.ptrauth.resign(i64 %v0, i32 2, i64 1234, i32 1, i64 5678) + %v1 = call i64 @llvm.ptrauth.resign(i64 %v0) [ "ptrauth"(i64 2, i64 1234), "ptrauth"(i64 1, i64 5678) ] %v2 = inttoptr i64 %v1 to ptr - %v3 = call i32 %v2() [ "ptrauth"(i32 1, i64 5678) ] + %v3 = call i32 %v2() [ "ptrauth"(i64 1, i64 5678) ] ret i32 %v3 } - -declare i64 @llvm.ptrauth.sign(i64, i32, i64) -declare i64 @llvm.ptrauth.resign(i64, i32, i64, i32, i64) -declare i64 @llvm.ptrauth.blend(i64, i64) diff --git a/llvm/test/Transforms/InstCombine/ptrauth-intrinsics.ll b/llvm/test/Transforms/InstCombine/ptrauth-intrinsics.ll index 22c330fe7ae61..bf64c1abe1c3a 100644 --- a/llvm/test/Transforms/InstCombine/ptrauth-intrinsics.ll +++ b/llvm/test/Transforms/InstCombine/ptrauth-intrinsics.ll @@ -7,8 +7,8 @@ define i64 @test_ptrauth_nop(ptr %p) { ; CHECK-NEXT: ret i64 [[TMP0]] ; %tmp0 = ptrtoint ptr %p to i64 - %signed = call i64 @llvm.ptrauth.sign(i64 %tmp0, i32 1, i64 1234) - %authed = call i64 @llvm.ptrauth.auth(i64 %signed, i32 1, i64 1234) + %signed = call i64 @llvm.ptrauth.sign(i64 %tmp0) [ "ptrauth"(i64 1, i64 1234) ] + %authed = call i64 @llvm.ptrauth.auth(i64 %signed) [ "ptrauth"(i64 1, i64 1234) ] ret i64 %authed } @@ -19,7 +19,7 @@ define i64 @test_ptrauth_nop_constant() { ; CHECK-LABEL: @test_ptrauth_nop_constant( ; CHECK-NEXT: ret i64 ptrtoint (ptr @foo to i64) ; - %authed = call i64 @llvm.ptrauth.auth(i64 ptrtoint(ptr ptrauth(ptr @foo, i32 1, i64 1234) to i64), i32 1, i64 1234) + %authed = call i64 @llvm.ptrauth.auth(i64 ptrtoint(ptr ptrauth(ptr @foo, i32 1, i64 1234) to i64)) [ "ptrauth"(i64 1, i64 1234) ] ret i64 %authed } @@ -29,124 +29,124 @@ define i64 @test_ptrauth_nop_constant_addrdisc() { ; %addr = ptrtoint ptr @foo to i64 %blended = call i64 @llvm.ptrauth.blend(i64 %addr, i64 1234) - %authed = call i64 @llvm.ptrauth.auth(i64 ptrtoint(ptr ptrauth(ptr @foo, i32 1, i64 1234, ptr @foo) to i64), i32 1, i64 %blended) + %authed = call i64 @llvm.ptrauth.auth(i64 ptrtoint(ptr ptrauth(ptr @foo, i32 1, i64 1234, ptr @foo) to i64)) [ "ptrauth"(i64 1, i64 %blended) ] ret i64 %authed } define i64 @test_ptrauth_nop_mismatch(ptr %p) { ; CHECK-LABEL: @test_ptrauth_nop_mismatch( ; CHECK-NEXT: [[TMP0:%.*]] = ptrtoint ptr [[P:%.*]] to i64 -; CHECK-NEXT: [[SIGNED:%.*]] = call i64 @llvm.ptrauth.sign(i64 [[TMP0]], i32 1, i64 1234) -; CHECK-NEXT: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[SIGNED]], i32 1, i64 10) +; CHECK-NEXT: [[SIGNED:%.*]] = call i64 @llvm.ptrauth.sign(i64 [[TMP0]]) [ "ptrauth"(i64 1, i64 1234) ] +; CHECK-NEXT: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[SIGNED]]) [ "ptrauth"(i64 1, i64 10) ] ; CHECK-NEXT: ret i64 [[AUTHED]] ; %tmp0 = ptrtoint ptr %p to i64 - %signed = call i64 @llvm.ptrauth.sign(i64 %tmp0, i32 1, i64 1234) - %authed = call i64 @llvm.ptrauth.auth(i64 %signed, i32 1, i64 10) + %signed = call i64 @llvm.ptrauth.sign(i64 %tmp0) [ "ptrauth"(i64 1, i64 1234) ] + %authed = call i64 @llvm.ptrauth.auth(i64 %signed) [ "ptrauth"(i64 1, i64 10) ] ret i64 %authed } define i64 @test_ptrauth_nop_mismatch_keys(ptr %p) { ; CHECK-LABEL: @test_ptrauth_nop_mismatch_keys( ; CHECK-NEXT: [[TMP0:%.*]] = ptrtoint ptr [[P:%.*]] to i64 -; CHECK-NEXT: [[SIGNED:%.*]] = call i64 @llvm.ptrauth.sign(i64 [[TMP0]], i32 0, i64 1234) -; CHECK-NEXT: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[SIGNED]], i32 1, i64 1234) +; CHECK-NEXT: [[SIGNED:%.*]] = call i64 @llvm.ptrauth.sign(i64 [[TMP0]]) [ "ptrauth"(i64 0, i64 1234) ] +; CHECK-NEXT: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[SIGNED]]) [ "ptrauth"(i64 1, i64 1234) ] ; CHECK-NEXT: ret i64 [[AUTHED]] ; %tmp0 = ptrtoint ptr %p to i64 - %signed = call i64 @llvm.ptrauth.sign(i64 %tmp0, i32 0, i64 1234) - %authed = call i64 @llvm.ptrauth.auth(i64 %signed, i32 1, i64 1234) + %signed = call i64 @llvm.ptrauth.sign(i64 %tmp0) [ "ptrauth"(i64 0, i64 1234) ] + %authed = call i64 @llvm.ptrauth.auth(i64 %signed) [ "ptrauth"(i64 1, i64 1234) ] ret i64 %authed } define i64 @test_ptrauth_sign_resign(ptr %p) { ; CHECK-LABEL: @test_ptrauth_sign_resign( ; CHECK-NEXT: [[TMP0:%.*]] = ptrtoint ptr [[P:%.*]] to i64 -; CHECK-NEXT: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.sign(i64 [[TMP0]], i32 0, i64 42) +; CHECK-NEXT: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.sign(i64 [[TMP0]]) [ "ptrauth"(i64 0, i64 42) ] ; CHECK-NEXT: ret i64 [[AUTHED]] ; %tmp0 = ptrtoint ptr %p to i64 - %signed = call i64 @llvm.ptrauth.sign(i64 %tmp0, i32 1, i64 1234) - %authed = call i64 @llvm.ptrauth.resign(i64 %signed, i32 1, i64 1234, i32 0, i64 42) + %signed = call i64 @llvm.ptrauth.sign(i64 %tmp0) [ "ptrauth"(i64 1, i64 1234) ] + %authed = call i64 @llvm.ptrauth.resign(i64 %signed) [ "ptrauth"(i64 1, i64 1234), "ptrauth"(i64 0, i64 42) ] ret i64 %authed } define i64 @test_ptrauth_resign_resign(ptr %p) { ; CHECK-LABEL: @test_ptrauth_resign_resign( ; CHECK-NEXT: [[TMP0:%.*]] = ptrtoint ptr [[P:%.*]] to i64 -; CHECK-NEXT: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.resign(i64 [[TMP0]], i32 1, i64 1234, i32 1, i64 3141) +; CHECK-NEXT: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.resign(i64 [[TMP0]]) [ "ptrauth"(i64 1, i64 1234), "ptrauth"(i64 1, i64 3141) ] ; CHECK-NEXT: ret i64 [[AUTHED]] ; %tmp0 = ptrtoint ptr %p to i64 - %signed = call i64 @llvm.ptrauth.resign(i64 %tmp0, i32 1, i64 1234, i32 0, i64 42) - %authed = call i64 @llvm.ptrauth.resign(i64 %signed, i32 0, i64 42, i32 1, i64 3141) + %signed = call i64 @llvm.ptrauth.resign(i64 %tmp0) [ "ptrauth"(i64 1, i64 1234), "ptrauth"(i64 0, i64 42) ] + %authed = call i64 @llvm.ptrauth.resign(i64 %signed) [ "ptrauth"(i64 0, i64 42), "ptrauth"(i64 1, i64 3141) ] ret i64 %authed } define i64 @test_ptrauth_resign_auth(ptr %p) { ; CHECK-LABEL: @test_ptrauth_resign_auth( ; CHECK-NEXT: [[TMP0:%.*]] = ptrtoint ptr [[P:%.*]] to i64 -; CHECK-NEXT: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[TMP0]], i32 1, i64 1234) +; CHECK-NEXT: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[TMP0]]) [ "ptrauth"(i64 1, i64 1234) ] ; CHECK-NEXT: ret i64 [[AUTHED]] ; %tmp0 = ptrtoint ptr %p to i64 - %signed = call i64 @llvm.ptrauth.resign(i64 %tmp0, i32 1, i64 1234, i32 0, i64 42) - %authed = call i64 @llvm.ptrauth.auth(i64 %signed, i32 0, i64 42) + %signed = call i64 @llvm.ptrauth.resign(i64 %tmp0) [ "ptrauth"(i64 1, i64 1234), "ptrauth"(i64 0, i64 42) ] + %authed = call i64 @llvm.ptrauth.auth(i64 %signed) [ "ptrauth"(i64 0, i64 42) ] ret i64 %authed } define i64 @test_ptrauth_resign_auth_mismatch(ptr %p) { ; CHECK-LABEL: @test_ptrauth_resign_auth_mismatch( ; CHECK-NEXT: [[TMP0:%.*]] = ptrtoint ptr [[P:%.*]] to i64 -; CHECK-NEXT: [[SIGNED:%.*]] = call i64 @llvm.ptrauth.resign(i64 [[TMP0]], i32 1, i64 1234, i32 0, i64 10) -; CHECK-NEXT: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[SIGNED]], i32 0, i64 42) +; CHECK-NEXT: [[SIGNED:%.*]] = call i64 @llvm.ptrauth.resign(i64 [[TMP0]]) [ "ptrauth"(i64 1, i64 1234), "ptrauth"(i64 0, i64 10) ] +; CHECK-NEXT: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[SIGNED]]) [ "ptrauth"(i64 0, i64 42) ] ; CHECK-NEXT: ret i64 [[AUTHED]] ; %tmp0 = ptrtoint ptr %p to i64 - %signed = call i64 @llvm.ptrauth.resign(i64 %tmp0, i32 1, i64 1234, i32 0, i64 10) - %authed = call i64 @llvm.ptrauth.auth(i64 %signed, i32 0, i64 42) + %signed = call i64 @llvm.ptrauth.resign(i64 %tmp0) [ "ptrauth"(i64 1, i64 1234), "ptrauth"(i64 0, i64 10) ] + %authed = call i64 @llvm.ptrauth.auth(i64 %signed) [ "ptrauth"(i64 0, i64 42) ] ret i64 %authed } define i64 @test_ptrauth_nop_constant_mismatch() { ; CHECK-LABEL: @test_ptrauth_nop_constant_mismatch( -; CHECK-NEXT: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 ptrtoint (ptr ptrauth (ptr @foo, i32 1, i64 1234) to i64), i32 1, i64 12) +; CHECK-NEXT: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 ptrtoint (ptr ptrauth (ptr @foo, i32 1, i64 1234) to i64)) [ "ptrauth"(i64 1, i64 12) ] ; CHECK-NEXT: ret i64 [[AUTHED]] ; - %authed = call i64 @llvm.ptrauth.auth(i64 ptrtoint(ptr ptrauth(ptr @foo, i32 1, i64 1234) to i64), i32 1, i64 12) + %authed = call i64 @llvm.ptrauth.auth(i64 ptrtoint(ptr ptrauth(ptr @foo, i32 1, i64 1234) to i64)) [ "ptrauth"(i64 1, i64 12) ] ret i64 %authed } define i64 @test_ptrauth_nop_constant_mismatch_key() { ; CHECK-LABEL: @test_ptrauth_nop_constant_mismatch_key( -; CHECK-NEXT: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 ptrtoint (ptr ptrauth (ptr @foo, i32 1, i64 1234) to i64), i32 0, i64 1234) +; CHECK-NEXT: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 ptrtoint (ptr ptrauth (ptr @foo, i32 1, i64 1234) to i64)) [ "ptrauth"(i64 0, i64 1234) ] ; CHECK-NEXT: ret i64 [[AUTHED]] ; - %authed = call i64 @llvm.ptrauth.auth(i64 ptrtoint(ptr ptrauth(ptr @foo, i32 1, i64 1234) to i64), i32 0, i64 1234) + %authed = call i64 @llvm.ptrauth.auth(i64 ptrtoint(ptr ptrauth(ptr @foo, i32 1, i64 1234) to i64)) [ "ptrauth"(i64 0, i64 1234) ] ret i64 %authed } define i64 @test_ptrauth_nop_constant_addrdisc_mismatch() { ; CHECK-LABEL: @test_ptrauth_nop_constant_addrdisc_mismatch( ; CHECK-NEXT: [[BLENDED:%.*]] = call i64 @llvm.ptrauth.blend(i64 ptrtoint (ptr @foo to i64), i64 12) -; CHECK-NEXT: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 ptrtoint (ptr ptrauth (ptr @foo, i32 1, i64 1234, ptr @foo) to i64), i32 1, i64 [[BLENDED]]) +; CHECK-NEXT: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 ptrtoint (ptr ptrauth (ptr @foo, i32 1, i64 1234, ptr @foo) to i64)) [ "ptrauth"(i64 1, i64 [[BLENDED]]) ] ; CHECK-NEXT: ret i64 [[AUTHED]] ; %addr = ptrtoint ptr @foo to i64 %blended = call i64 @llvm.ptrauth.blend(i64 %addr, i64 12) - %authed = call i64 @llvm.ptrauth.auth(i64 ptrtoint(ptr ptrauth(ptr @foo, i32 1, i64 1234, ptr @foo) to i64), i32 1, i64 %blended) + %authed = call i64 @llvm.ptrauth.auth(i64 ptrtoint(ptr ptrauth(ptr @foo, i32 1, i64 1234, ptr @foo) to i64)) [ "ptrauth"(i64 1, i64 %blended) ] ret i64 %authed } define i64 @test_ptrauth_nop_constant_addrdisc_mismatch2() { ; CHECK-LABEL: @test_ptrauth_nop_constant_addrdisc_mismatch2( ; CHECK-NEXT: [[BLENDED:%.*]] = call i64 @llvm.ptrauth.blend(i64 ptrtoint (ptr @bar to i64), i64 1234) -; CHECK-NEXT: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 ptrtoint (ptr ptrauth (ptr @foo, i32 1, i64 1234, ptr @foo) to i64), i32 1, i64 [[BLENDED]]) +; CHECK-NEXT: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 ptrtoint (ptr ptrauth (ptr @foo, i32 1, i64 1234, ptr @foo) to i64)) [ "ptrauth"(i64 1, i64 [[BLENDED]]) ] ; CHECK-NEXT: ret i64 [[AUTHED]] ; %addr = ptrtoint ptr @bar to i64 %blended = call i64 @llvm.ptrauth.blend(i64 %addr, i64 1234) - %authed = call i64 @llvm.ptrauth.auth(i64 ptrtoint(ptr ptrauth(ptr @foo, i32 1, i64 1234, ptr @foo) to i64), i32 1, i64 %blended) + %authed = call i64 @llvm.ptrauth.auth(i64 ptrtoint(ptr ptrauth(ptr @foo, i32 1, i64 1234, ptr @foo) to i64)) [ "ptrauth"(i64 1, i64 %blended) ] ret i64 %authed } @@ -156,7 +156,7 @@ define i64 @test_ptrauth_resign_ptrauth_constant(ptr %p) { ; %tmp0 = ptrtoint ptr %p to i64 - %authed = call i64 @llvm.ptrauth.resign(i64 ptrtoint(ptr ptrauth(ptr @foo, i32 1, i64 1234) to i64), i32 1, i64 1234, i32 0, i64 42) + %authed = call i64 @llvm.ptrauth.resign(i64 ptrtoint(ptr ptrauth(ptr @foo, i32 1, i64 1234) to i64)) [ "ptrauth"(i64 1, i64 1234), "ptrauth"(i64 0, i64 42) ] ret i64 %authed } @@ -165,39 +165,34 @@ define i64 @test_ptrauth_resign_ptrauth_constant(ptr %p) { define i64 @test_ptrauth_nop_ds1(ptr %p) { ; CHECK-LABEL: @test_ptrauth_nop_ds1( ; CHECK-NEXT: [[TMP0:%.*]] = ptrtoint ptr [[P:%.*]] to i64 -; CHECK-NEXT: [[SIGNED:%.*]] = call i64 @llvm.ptrauth.sign(i64 [[TMP0]], i32 1, i64 1234) [ "deactivation-symbol"(ptr @ds) ] -; CHECK-NEXT: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[SIGNED]], i32 1, i64 1234) +; CHECK-NEXT: [[SIGNED:%.*]] = call i64 @llvm.ptrauth.sign(i64 [[TMP0]]) [ "ptrauth"(i64 1, i64 1234), "deactivation-symbol"(ptr @ds) ] +; CHECK-NEXT: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[SIGNED]]) [ "ptrauth"(i64 1, i64 1234) ] ; CHECK-NEXT: ret i64 [[AUTHED]] ; %tmp0 = ptrtoint ptr %p to i64 - %signed = call i64 @llvm.ptrauth.sign(i64 %tmp0, i32 1, i64 1234) [ "deactivation-symbol"(ptr @ds) ] - %authed = call i64 @llvm.ptrauth.auth(i64 %signed, i32 1, i64 1234) + %signed = call i64 @llvm.ptrauth.sign(i64 %tmp0) [ "ptrauth"(i64 1, i64 1234), "deactivation-symbol"(ptr @ds) ] + %authed = call i64 @llvm.ptrauth.auth(i64 %signed) [ "ptrauth"(i64 1, i64 1234) ] ret i64 %authed } define i64 @test_ptrauth_nop_ds2(ptr %p) { ; CHECK-LABEL: @test_ptrauth_nop_ds2( ; CHECK-NEXT: [[TMP0:%.*]] = ptrtoint ptr [[P:%.*]] to i64 -; CHECK-NEXT: [[SIGNED:%.*]] = call i64 @llvm.ptrauth.sign(i64 [[TMP0]], i32 1, i64 1234) -; CHECK-NEXT: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[SIGNED]], i32 1, i64 1234) [ "deactivation-symbol"(ptr @ds) ] +; CHECK-NEXT: [[SIGNED:%.*]] = call i64 @llvm.ptrauth.sign(i64 [[TMP0]]) [ "ptrauth"(i64 1, i64 1234) ] +; CHECK-NEXT: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[SIGNED]]) [ "ptrauth"(i64 1, i64 1234), "deactivation-symbol"(ptr @ds) ] ; CHECK-NEXT: ret i64 [[AUTHED]] ; %tmp0 = ptrtoint ptr %p to i64 - %signed = call i64 @llvm.ptrauth.sign(i64 %tmp0, i32 1, i64 1234) - %authed = call i64 @llvm.ptrauth.auth(i64 %signed, i32 1, i64 1234) [ "deactivation-symbol"(ptr @ds) ] + %signed = call i64 @llvm.ptrauth.sign(i64 %tmp0) [ "ptrauth"(i64 1, i64 1234) ] + %authed = call i64 @llvm.ptrauth.auth(i64 %signed) [ "ptrauth"(i64 1, i64 1234), "deactivation-symbol"(ptr @ds) ] ret i64 %authed } define i64 @test_ptrauth_nop_ds_constant() { ; CHECK-LABEL: @test_ptrauth_nop_ds_constant( -; CHECK-NEXT: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 ptrtoint (ptr ptrauth (ptr @foo, i32 1, i64 1234, ptr null, ptr @ds) to i64), i32 1, i64 1234) +; CHECK-NEXT: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 ptrtoint (ptr ptrauth (ptr @foo, i32 1, i64 1234, ptr null, ptr @ds) to i64)) [ "ptrauth"(i64 1, i64 1234) ] ; CHECK-NEXT: ret i64 [[AUTHED]] ; - %authed = call i64 @llvm.ptrauth.auth(i64 ptrtoint(ptr ptrauth(ptr @foo, i32 1, i64 1234, ptr null, ptr @ds) to i64), i32 1, i64 1234) + %authed = call i64 @llvm.ptrauth.auth(i64 ptrtoint(ptr ptrauth(ptr @foo, i32 1, i64 1234, ptr null, ptr @ds) to i64)) [ "ptrauth"(i64 1, i64 1234) ] ret i64 %authed } - -declare i64 @llvm.ptrauth.auth(i64, i32, i64) -declare i64 @llvm.ptrauth.sign(i64, i32, i64) -declare i64 @llvm.ptrauth.resign(i64, i32, i64, i32, i64) -declare i64 @llvm.ptrauth.blend(i64, i64) From 00b63497bf53459c165e19625d0c820f07827dd2 Mon Sep 17 00:00:00 2001 From: Anatoly Trosinenko Date: Wed, 3 Dec 2025 18:21:14 +0300 Subject: [PATCH 06/40] More fixes for deactivation symbols after rebase --- llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp | 17 ++++++++-- .../SelectionDAG/SelectionDAGBuilder.cpp | 33 ++++++++++++++----- .../Target/AArch64/AArch64ISelDAGToDAG.cpp | 4 +-- .../CodeGen/AArch64/deactivation-symbols.ll | 18 +++++----- .../MIR/AArch64/deactivation-symbols.mir | 2 +- 5 files changed, 51 insertions(+), 23 deletions(-) diff --git a/llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp b/llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp index 15af106eed497..fcbc0ecd701aa 100644 --- a/llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp +++ b/llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp @@ -2215,6 +2215,11 @@ bool IRTranslator::translateKnownIntrinsic(const CallInst &CI, Intrinsic::ID ID, return Res; }; + auto SetDeactivationSymbol = [&](MachineInstrBuilder &MIB) { + if (auto Bundle = CI.getOperandBundle(LLVMContext::OB_deactivation_symbol)) + MIB->setDeactivationSymbol(*MF, Bundle->Inputs[0].get()); + }; + switch (ID) { default: break; @@ -2223,7 +2228,9 @@ bool IRTranslator::translateKnownIntrinsic(const CallInst &CI, Intrinsic::ID ID, Register V = getOrCreateVReg(*CI.getArgOperand(0)); Register Bundle = TranslatePtrAuthBundle(0); - MIRBuilder.buildInstr(TargetOpcode::G_PTRAUTH_AUTH, {Dst}, {V, Bundle}); + MachineInstrBuilder MIB = MIRBuilder.buildInstr( + TargetOpcode::G_PTRAUTH_AUTH, {Dst}, {V, Bundle}); + SetDeactivationSymbol(MIB); return true; } case Intrinsic::ptrauth_sign: { @@ -2231,7 +2238,9 @@ bool IRTranslator::translateKnownIntrinsic(const CallInst &CI, Intrinsic::ID ID, Register V = getOrCreateVReg(*CI.getArgOperand(0)); Register Bundle = TranslatePtrAuthBundle(0); - MIRBuilder.buildInstr(TargetOpcode::G_PTRAUTH_SIGN, {Dst}, {V, Bundle}); + MachineInstrBuilder MIB = MIRBuilder.buildInstr( + TargetOpcode::G_PTRAUTH_SIGN, {Dst}, {V, Bundle}); + SetDeactivationSymbol(MIB); return true; } case Intrinsic::ptrauth_resign: { @@ -2240,7 +2249,9 @@ bool IRTranslator::translateKnownIntrinsic(const CallInst &CI, Intrinsic::ID ID, Register OldBundle = TranslatePtrAuthBundle(0); Register NewBundle = TranslatePtrAuthBundle(1); - MIRBuilder.buildInstr(TargetOpcode::G_PTRAUTH_RESIGN, {Dst}, {V, OldBundle, NewBundle}); + MachineInstrBuilder MIB = MIRBuilder.buildInstr( + TargetOpcode::G_PTRAUTH_RESIGN, {Dst}, {V, OldBundle, NewBundle}); + SetDeactivationSymbol(MIB); return true; } case Intrinsic::ptrauth_strip: { diff --git a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp index 2b3c00405ed51..7be4435afed78 100644 --- a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp +++ b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp @@ -6564,27 +6564,42 @@ void SelectionDAGBuilder::visitIntrinsicCall(const CallInst &I, return DAG.getNode(ISD::PtrAuthBundle, getCurSDLoc(), MVT::Other, Ops); }; + auto SetDeactivationSymbol = [&](SmallVectorImpl &Ops) { + auto Bundle = I.getOperandBundle(LLVMContext::OB_deactivation_symbol); + if (!Bundle) + return; + + auto *Sym = Bundle->Inputs[0].get(); + SDValue SDSym = getValue(Sym); + SDSym = DAG.getDeactivationSymbol(cast(Sym)); + Ops.push_back(SDSym); + }; + switch (Intrinsic) { default: // By default, turn this into a target intrinsic node. visitTargetIntrinsic(I, Intrinsic); return; case Intrinsic::ptrauth_auth: { - setValue(&I, DAG.getNode(ISD::PtrAuthAuth, sdl, MVT::i64, - getValue(I.getArgOperand(0)), - CreatePtrAuthBundle(0))); + SmallVector Ops = {getValue(I.getArgOperand(0)), + CreatePtrAuthBundle(0)}; + SetDeactivationSymbol(Ops); + setValue(&I, DAG.getNode(ISD::PtrAuthAuth, sdl, MVT::i64, Ops)); return; } case Intrinsic::ptrauth_sign: { - setValue(&I, DAG.getNode(ISD::PtrAuthSign, sdl, MVT::i64, - getValue(I.getArgOperand(0)), - CreatePtrAuthBundle(0))); + SmallVector Ops = {getValue(I.getArgOperand(0)), + CreatePtrAuthBundle(0)}; + SetDeactivationSymbol(Ops); + setValue(&I, DAG.getNode(ISD::PtrAuthSign, sdl, MVT::i64, Ops)); return; } case Intrinsic::ptrauth_resign: { - setValue(&I, DAG.getNode(ISD::PtrAuthResign, sdl, MVT::i64, - getValue(I.getArgOperand(0)), - CreatePtrAuthBundle(0), CreatePtrAuthBundle(1))); + SmallVector Ops = {getValue(I.getArgOperand(0)), + CreatePtrAuthBundle(0), + CreatePtrAuthBundle(1)}; + SetDeactivationSymbol(Ops); + setValue(&I, DAG.getNode(ISD::PtrAuthResign, sdl, MVT::i64, Ops)); return; } case Intrinsic::ptrauth_strip: { diff --git a/llvm/lib/Target/AArch64/AArch64ISelDAGToDAG.cpp b/llvm/lib/Target/AArch64/AArch64ISelDAGToDAG.cpp index 5137ac97b06b0..b3a76f3730a5b 100644 --- a/llvm/lib/Target/AArch64/AArch64ISelDAGToDAG.cpp +++ b/llvm/lib/Target/AArch64/AArch64ISelDAGToDAG.cpp @@ -1566,8 +1566,8 @@ void AArch64DAGToDAGISel::SelectPtrauthAuth(SDNode *N) { if (!Subtarget->isX16X17Safer()) { std::vector Ops = {Val, AUTKey, AUTConstDisc, AUTAddrDisc}; // Copy deactivation symbol if present. - if (N->getNumOperands() > 4) - Ops.push_back(N->getOperand(4)); + if (N->getNumOperands() > 2) + Ops.push_back(N->getOperand(2)); SDNode *AUT = CurDAG->getMachineNode(AArch64::AUTxMxN, DL, MVT::i64, MVT::i64, Ops); diff --git a/llvm/test/CodeGen/AArch64/deactivation-symbols.ll b/llvm/test/CodeGen/AArch64/deactivation-symbols.ll index 571b1067134b8..57e62e3ee4ad8 100644 --- a/llvm/test/CodeGen/AArch64/deactivation-symbols.ll +++ b/llvm/test/CodeGen/AArch64/deactivation-symbols.ll @@ -1,5 +1,7 @@ -; RUN: llc < %s -O0 -mtriple=aarch64-none-linux-gnu -mattr=+pauth | FileCheck --check-prefixes=CHECK,O0 %s -; RUN: llc < %s -O2 -mtriple=aarch64-none-linux-gnu -mattr=+pauth | FileCheck --check-prefixes=CHECK,O2 %s +; RUN: llc < %s -O0 -mtriple=aarch64-none-linux-gnu -mattr=+pauth -global-isel=0 | FileCheck --check-prefixes=CHECK,O0 %s +; RUN: llc < %s -O2 -mtriple=aarch64-none-linux-gnu -mattr=+pauth -global-isel=0 | FileCheck --check-prefixes=CHECK,O2 %s +; RUN: llc < %s -O0 -mtriple=aarch64-none-linux-gnu -mattr=+pauth -global-isel=1 -global-isel-abort=1 | FileCheck --check-prefixes=CHECK,O0 %s +; RUN: llc < %s -O2 -mtriple=aarch64-none-linux-gnu -mattr=+pauth -global-isel=1 -global-isel-abort=1 | FileCheck --check-prefixes=CHECK,O2 %s @ds = external global i8 @@ -21,7 +23,7 @@ define i64 @pauth_sign_zero(i64 %p) { ; CHECK-NEXT: .reloc [[LABEL]], R_AARCH64_PATCHINST, ds ; O0-NEXT: pacia x0, x8 ; O2-NEXT: paciza x0 - %signed = call i64 @llvm.ptrauth.sign(i64 %p, i32 0, i64 0) [ "deactivation-symbol"(ptr @ds) ] + %signed = call i64 @llvm.ptrauth.sign(i64 %p) [ "ptrauth"(i64 0, i64 0), "deactivation-symbol"(ptr @ds) ] ret i64 %signed } @@ -31,7 +33,7 @@ define i64 @pauth_sign_const(i64 %p) { ; CHECK-NEXT: [[LABEL:.L.*]]: ; CHECK-NEXT: .reloc [[LABEL]], R_AARCH64_PATCHINST, ds ; CHECK-NEXT: pacia x0, x16 - %signed = call i64 @llvm.ptrauth.sign(i64 %p, i32 0, i64 12345) [ "deactivation-symbol"(ptr @ds) ] + %signed = call i64 @llvm.ptrauth.sign(i64 %p) [ "ptrauth"(i64 0, i64 12345), "deactivation-symbol"(ptr @ds) ] ret i64 %signed } @@ -40,7 +42,7 @@ define i64 @pauth_sign(i64 %p, i64 %d) { ; CHECK: [[LABEL:.L.*]]: ; CHECK-NEXT: .reloc [[LABEL]], R_AARCH64_PATCHINST, ds ; CHECK-NEXT: pacia x0, x1 - %signed = call i64 @llvm.ptrauth.sign(i64 %p, i32 0, i64 %d) [ "deactivation-symbol"(ptr @ds) ] + %signed = call i64 @llvm.ptrauth.sign(i64 %p) [ "ptrauth"(i64 0, i64 %d), "deactivation-symbol"(ptr @ds) ] ret i64 %signed } @@ -49,7 +51,7 @@ define i64 @pauth_auth_zero(i64 %p) { ; CHECK: [[LABEL:.L.*]]: ; CHECK-NEXT: .reloc [[LABEL]], R_AARCH64_PATCHINST, ds ; CHECK-NEXT: autiza x0 - %authed = call i64 @llvm.ptrauth.auth(i64 %p, i32 0, i64 0) [ "deactivation-symbol"(ptr @ds) ] + %authed = call i64 @llvm.ptrauth.auth(i64 %p) [ "ptrauth"(i64 0, i64 0), "deactivation-symbol"(ptr @ds) ] ret i64 %authed } @@ -59,7 +61,7 @@ define i64 @pauth_auth_const(i64 %p) { ; CHECK-NEXT: [[LABEL:.L.*]]: ; CHECK-NEXT: .reloc [[LABEL]], R_AARCH64_PATCHINST, ds ; CHECK-NEXT: autia x0, x8 - %authed = call i64 @llvm.ptrauth.auth(i64 %p, i32 0, i64 12345) [ "deactivation-symbol"(ptr @ds) ] + %authed = call i64 @llvm.ptrauth.auth(i64 %p) [ "ptrauth"(i64 0, i64 12345), "deactivation-symbol"(ptr @ds) ] ret i64 %authed } @@ -68,6 +70,6 @@ define i64 @pauth_auth(i64 %p, i64 %d) { ; CHECK: [[LABEL:.L.*]]: ; CHECK-NEXT: .reloc [[LABEL]], R_AARCH64_PATCHINST, ds ; CHECK-NEXT: autia x0, x1 - %authed = call i64 @llvm.ptrauth.auth(i64 %p, i32 0, i64 %d) [ "deactivation-symbol"(ptr @ds) ] + %authed = call i64 @llvm.ptrauth.auth(i64 %p) [ "ptrauth"(i64 0, i64 %d), "deactivation-symbol"(ptr @ds) ] ret i64 %authed } diff --git a/llvm/test/CodeGen/MIR/AArch64/deactivation-symbols.mir b/llvm/test/CodeGen/MIR/AArch64/deactivation-symbols.mir index 8e0ab43274311..9dd8b3d0de4ae 100644 --- a/llvm/test/CodeGen/MIR/AArch64/deactivation-symbols.mir +++ b/llvm/test/CodeGen/MIR/AArch64/deactivation-symbols.mir @@ -5,7 +5,7 @@ @ds = external global i8 define i64 @pauth_sign_zero(i64 %p) { - ; CHECK: G_INTRINSIC intrinsic(@llvm.ptrauth.sign), %0(s64), 0, %2(s64), deactivation-symbol @ds + ; CHECK: G_PTRAUTH_SIGN %0, %2(s0), deactivation-symbol @ds %signed = call i64 @llvm.ptrauth.sign(i64 %p) [ "ptrauth"(i64 0, i64 0), "deactivation-symbol"(ptr @ds) ] ret i64 %signed } From fe2adda021116788fe50e90f6a65ed537c2bc93a Mon Sep 17 00:00:00 2001 From: Anatoly Trosinenko Date: Tue, 28 Oct 2025 18:16:13 +0300 Subject: [PATCH 07/40] Update the tests in preparation for dropping blend() calls --- clang/test/CodeGen/ptrauth-qualifier-blocks.c | 3 +- .../ptrauth-member-function-pointer.cpp | 6 ++-- clang/test/CodeGenCXX/ubsan-vtable-checks.cpp | 1 - .../ptrauth-objc-interface-selector.m | 36 ++++++++++++++----- .../ptrauth-objc-interface-selector.mm | 36 ++++++++++++++----- 5 files changed, 62 insertions(+), 20 deletions(-) diff --git a/clang/test/CodeGen/ptrauth-qualifier-blocks.c b/clang/test/CodeGen/ptrauth-qualifier-blocks.c index 1b9dc749e63d3..db2df20e57a2e 100644 --- a/clang/test/CodeGen/ptrauth-qualifier-blocks.c +++ b/clang/test/CodeGen/ptrauth-qualifier-blocks.c @@ -45,7 +45,8 @@ void test_block_address_capture() { use_block(^{ return ptr->value; }); } // CHECK-LABEL: define internal i32 @__test_block_address_capture_block_invoke -// CHECK: call i64 @llvm.ptrauth.auth(i64 {{%.*}}) [ "ptrauth"(i64 1, i64 {{%.*}}) ] +// CHECK: [[DISC:%.*]] = call i64 @llvm.ptrauth.blend(i64 {{.*}}, i64 30) +// CHECK: call i64 @llvm.ptrauth.auth(i64 {{%.*}}) [ "ptrauth"(i64 1, i64 [[DISC]]) ] // CHECK: linkonce_odr hidden void @__copy_helper_block_8_32p1d30( // CHECK: [[OLDSLOT:%.*]] = getelementptr inbounds {{.*}} {{.*}}, i32 0, i32 5 diff --git a/clang/test/CodeGenCXX/ptrauth-member-function-pointer.cpp b/clang/test/CodeGenCXX/ptrauth-member-function-pointer.cpp index 4a5d32179e171..232aa04412ea0 100644 --- a/clang/test/CodeGenCXX/ptrauth-member-function-pointer.cpp +++ b/clang/test/CodeGenCXX/ptrauth-member-function-pointer.cpp @@ -182,14 +182,16 @@ struct Class0 { // Check that the return value of the musttail call isn't copied to a temporary. // CHECK: define linkonce_odr hidden [2 x i64] @_ZN8Derived010return_aggEv_vfpthunk_(ptr noundef %{{.*}}) -// CHECK: %[[CALL:.*]] = musttail call [2 x i64] %{{.*}}(ptr noundef nonnull align {{[0-9]+}} dereferenceable(8) %{{.*}}) [ "ptrauth"(i32 0, i64 %{{.*}}) ] +// CHECK: %[[DISC:.*]] = call i64 @llvm.ptrauth.blend(i64 {{.*}}, i64 13445) +// CHECK: %[[CALL:.*]] = musttail call [2 x i64] %{{.*}}(ptr noundef nonnull align {{[0-9]+}} dereferenceable(8) %{{.*}}) [ "ptrauth"(i32 0, i64 %[[DISC]]) ] // CHECK-NEXT: ret [2 x i64] %[[CALL]] // Check that the sret pointer passed to the caller is forwarded to the musttail // call. // CHECK: define linkonce_odr hidden void @_ZN8Derived04sretEv_vfpthunk_(ptr dead_on_unwind noalias writable sret(%struct.A1) align 4 %[[AGG_RESULT:.*]], ptr noundef %{{.*}}) -// CHECK: musttail call void %{{.*}}(ptr dead_on_unwind writable sret(%struct.A1) align 4 %[[AGG_RESULT]], ptr noundef nonnull align {{[0-9]+}} dereferenceable(8) %{{.*}}) [ "ptrauth"(i32 0, i64 %{{.*}}) ] +// CHECK: %[[DISC:.*]] = call i64 @llvm.ptrauth.blend(i64 {{.*}}, i64 41281) +// CHECK: musttail call void %{{.*}}(ptr dead_on_unwind writable sret(%struct.A1) align 4 %[[AGG_RESULT]], ptr noundef nonnull align {{[0-9]+}} dereferenceable(8) %{{.*}}) [ "ptrauth"(i32 0, i64 %[[DISC]]) ] // CHECK-NEXT: ret void // Check that the thunk function doesn't destruct the trivial_abi argument. diff --git a/clang/test/CodeGenCXX/ubsan-vtable-checks.cpp b/clang/test/CodeGenCXX/ubsan-vtable-checks.cpp index 202f4891b5e56..e5845e7da5b78 100644 --- a/clang/test/CodeGenCXX/ubsan-vtable-checks.cpp +++ b/clang/test/CodeGenCXX/ubsan-vtable-checks.cpp @@ -82,7 +82,6 @@ U* dyncast(T *t) { // CHECK-VPTR-NOT: call ptr @__{{dynamic_cast|RTDynamicCast}} // CHECK-VPTR: br i1 {{.*}} label %{{.*}} // CHECK-PTRAUTH: [[V0:%.*]] = ptrtoint ptr {{%.*}} to i64 - // CHECK-PTRAUTH: [[BLENDED:%.*]] = call i64 @llvm.ptrauth.blend(i64 [[V0]], i64 17113) // CHECK-PTRAUTH: [[CAST_VTABLE:%.*]] = ptrtoint ptr {{%.*}} to i64 // CHECK-PTRAUTH: [[STRIPPED_VTABLE:%.*]] = call i64 @llvm.ptrauth.strip(i64 [[CAST_VTABLE]]) [ "ptrauth"(i64 0) ] // CHECK-PTRAUTH: [[STRIPPED_PTR:%.*]] = inttoptr i64 [[STRIPPED_VTABLE]] to ptr diff --git a/clang/test/CodeGenObjC/ptrauth-objc-interface-selector.m b/clang/test/CodeGenObjC/ptrauth-objc-interface-selector.m index f6b64b6f27df5..dd62e12b747d1 100644 --- a/clang/test/CodeGenObjC/ptrauth-objc-interface-selector.m +++ b/clang/test/CodeGenObjC/ptrauth-objc-interface-selector.m @@ -83,8 +83,13 @@ void auto_sel(Test *out, Test *in) { out->auto_sel = in->auto_sel; } // CHECK-AUTHENTICATED-SEL-LABEL: define void @auto_sel -// CHECK-AUTHENTICATED-SEL: [[DST_DESCRIMINATOR:%.*]] = call i64 @llvm.ptrauth.blend(i64 [[CAST_DST_ADDR:%.*]], i64 22466) -// CHECK-AUTHENTICATED-SEL: [[CAST_SRC_ADDR:%.*]] = ptrtoint ptr [[SRC_ADDR:%.*]] to i64 +// CHECK-AUTHENTICATED-SEL: [[V0:%.*]] = load ptr, ptr %out.addr +// CHECK-AUTHENTICATED-SEL: [[SRC_ADDR:%.*]] = getelementptr inbounds i8, ptr [[V0]], i64 0 +// CHECK-AUTHENTICATED-SEL: [[V1:%.*]] = load ptr, ptr %in.addr +// CHECK-AUTHENTICATED-SEL: [[DST_ADDR:%.*]] = getelementptr inbounds i8, ptr [[V1]], i64 0 +// CHECK-AUTHENTICATED-SEL: [[CAST_DST_ADDR:%.*]] = ptrtoint ptr [[DST_ADDR]] to i64 +// CHECK-AUTHENTICATED-SEL: [[DST_DESCRIMINATOR:%.*]] = call i64 @llvm.ptrauth.blend(i64 [[CAST_DST_ADDR]], i64 22466) +// CHECK-AUTHENTICATED-SEL: [[CAST_SRC_ADDR:%.*]] = ptrtoint ptr [[SRC_ADDR]] to i64 // CHECK-AUTHENTICATED-SEL: [[SRC_DESCRIMINATOR:%.*]] = call i64 @llvm.ptrauth.blend(i64 [[CAST_SRC_ADDR]], i64 22466) // CHECK-AUTHENTICATED-SEL: [[SRC_SEL:%.*]] = ptrtoint ptr [[SRC_SEL_ADDR:%.*]] to i64 // CHECK-AUTHENTICATED-SEL: {{%.*}} = call i64 @llvm.ptrauth.resign(i64 [[SRC_SEL]]) [ "ptrauth"(i64 3, i64 [[DST_DESCRIMINATOR]]), "ptrauth"(i64 3, i64 [[SRC_DESCRIMINATOR]]) ] @@ -105,8 +110,13 @@ void volatile_auto_sel(Test *out, Test *in) { } // CHECK-AUTHENTICATED-SEL-LABEL: define void @volatile_auto_sel -// CHECK-AUTHENTICATED-SEL: [[DST_DESCRIMINATOR:%.*]] = call i64 @llvm.ptrauth.blend(i64 [[CAST_DST_ADDR:%.*]], i64 22466) -// CHECK-AUTHENTICATED-SEL: [[CAST_SRC_ADDR:%.*]] = ptrtoint ptr [[SRC_ADDR:%.*]] to i64 +// CHECK-AUTHENTICATED-SEL: [[V0:%.*]] = load ptr, ptr %out.addr +// CHECK-AUTHENTICATED-SEL: [[SRC_ADDR:%.*]] = getelementptr inbounds i8, ptr [[V0]], i64 16 +// CHECK-AUTHENTICATED-SEL: [[V1:%.*]] = load ptr, ptr %in.addr +// CHECK-AUTHENTICATED-SEL: [[DST_ADDR:%.*]] = getelementptr inbounds i8, ptr [[V1]], i64 16 +// CHECK-AUTHENTICATED-SEL: [[CAST_DST_ADDR:%.*]] = ptrtoint ptr [[DST_ADDR]] to i64 +// CHECK-AUTHENTICATED-SEL: [[DST_DESCRIMINATOR:%.*]] = call i64 @llvm.ptrauth.blend(i64 [[CAST_DST_ADDR]], i64 22466) +// CHECK-AUTHENTICATED-SEL: [[CAST_SRC_ADDR:%.*]] = ptrtoint ptr [[SRC_ADDR]] to i64 // CHECK-AUTHENTICATED-SEL: [[SRC_DESCRIMINATOR:%.*]] = call i64 @llvm.ptrauth.blend(i64 [[CAST_SRC_ADDR]], i64 22466) // CHECK-AUTHENTICATED-SEL: [[SRC_SEL:%.*]] = ptrtoint ptr [[SRC_SEL_ADDR:%.*]] to i64 // CHECK-AUTHENTICATED-SEL: {{%.*}} = call i64 @llvm.ptrauth.resign(i64 [[SRC_SEL]]) [ "ptrauth"(i64 3, i64 [[DST_DESCRIMINATOR]]), "ptrauth"(i64 3, i64 [[SRC_DESCRIMINATOR]]) ] @@ -116,15 +126,25 @@ void manual(Test *out, Test *in) { } // CHECK-AUTHENTICATED-SEL-LABEL: define void @manual -// CHECK-AUTHENTICATED-SEL: [[DST_DESCRIMINATOR:%.*]] = call i64 @llvm.ptrauth.blend(i64 [[CAST_DST_ADDR:%.*]], i64 22467) -// CHECK-AUTHENTICATED-SEL: [[CAST_SRC_ADDR:%.*]] = ptrtoint ptr [[SRC_ADDR:%.*]] to i64 +// CHECK-AUTHENTICATED-SEL: [[V0:%.*]] = load ptr, ptr %out.addr +// CHECK-AUTHENTICATED-SEL: [[SRC_ADDR:%.*]] = getelementptr inbounds i8, ptr [[V0]], i64 24 +// CHECK-AUTHENTICATED-SEL: [[V0:%.*]] = load ptr, ptr %in.addr +// CHECK-AUTHENTICATED-SEL: [[DST_ADDR:%.*]] = getelementptr inbounds i8, ptr [[V1]], i64 24 +// CHECK-AUTHENTICATED-SEL: [[CAST_DST_ADDR:%.*]] = ptrtoint ptr [[DST_ADDR]] to i64 +// CHECK-AUTHENTICATED-SEL: [[DST_DESCRIMINATOR:%.*]] = call i64 @llvm.ptrauth.blend(i64 [[CAST_DST_ADDR]], i64 22467) +// CHECK-AUTHENTICATED-SEL: [[CAST_SRC_ADDR:%.*]] = ptrtoint ptr [[SRC_ADDR]] to i64 // CHECK-AUTHENTICATED-SEL: [[SRC_DESCRIMINATOR:%.*]] = call i64 @llvm.ptrauth.blend(i64 [[CAST_SRC_ADDR]], i64 22467) // CHECK-AUTHENTICATED-SEL: [[SRC_SEL:%.*]] = ptrtoint ptr [[SRC_SEL_ADDR:%.*]] to i64 // CHECK-AUTHENTICATED-SEL: {{%.*}} = call i64 @llvm.ptrauth.resign(i64 [[SRC_SEL]]) [ "ptrauth"(i64 3, i64 [[DST_DESCRIMINATOR]]), "ptrauth"(i64 3, i64 [[SRC_DESCRIMINATOR]]) ] // CHECK-UNAUTHENTICATED-SEL-LABEL: define void @manual -// CHECK-UNAUTHENTICATED-SEL: [[DST_DESCRIMINATOR:%.*]] = call i64 @llvm.ptrauth.blend(i64 [[CAST_DST_ADDR:%.*]], i64 22467) -// CHECK-UNAUTHENTICATED-SEL: [[CAST_SRC_ADDR:%.*]] = ptrtoint ptr [[SRC_ADDR:%.*]] to i64 +// CHECK-UNAUTHENTICATED-SEL: [[V0:%.*]] = load ptr, ptr %out.addr +// CHECK-UNAUTHENTICATED-SEL: [[SRC_ADDR:%.*]] = getelementptr inbounds i8, ptr [[V0]], i64 24 +// CHECK-UNAUTHENTICATED-SEL: [[V1:%.*]] = load ptr, ptr %in.addr +// CHECK-UNAUTHENTICATED-SEL: [[DST_ADDR:%.*]] = getelementptr inbounds i8, ptr [[V1]], i64 24 +// CHECK-UNAUTHENTICATED-SEL: [[CAST_DST_ADDR:%.*]] = ptrtoint ptr [[DST_ADDR]] to i64 +// CHECK-UNAUTHENTICATED-SEL: [[DST_DESCRIMINATOR:%.*]] = call i64 @llvm.ptrauth.blend(i64 [[CAST_DST_ADDR]], i64 22467) +// CHECK-UNAUTHENTICATED-SEL: [[CAST_SRC_ADDR:%.*]] = ptrtoint ptr [[SRC_ADDR]] to i64 // CHECK-UNAUTHENTICATED-SEL: [[SRC_DESCRIMINATOR:%.*]] = call i64 @llvm.ptrauth.blend(i64 [[CAST_SRC_ADDR]], i64 22467) // CHECK-UNAUTHENTICATED-SEL: [[SRC_SEL:%.*]] = ptrtoint ptr [[SRC_SEL_ADDR:%.*]] to i64 // CHECK-UNAUTHENTICATED-SEL: {{%.*}} = call i64 @llvm.ptrauth.resign(i64 [[SRC_SEL]]) [ "ptrauth"(i64 3, i64 [[DST_DESCRIMINATOR]]), "ptrauth"(i64 3, i64 [[SRC_DESCRIMINATOR]]) ] diff --git a/clang/test/CodeGenObjCXX/ptrauth-objc-interface-selector.mm b/clang/test/CodeGenObjCXX/ptrauth-objc-interface-selector.mm index 588538f25de44..e6526d61ac1e7 100644 --- a/clang/test/CodeGenObjCXX/ptrauth-objc-interface-selector.mm +++ b/clang/test/CodeGenObjCXX/ptrauth-objc-interface-selector.mm @@ -39,8 +39,13 @@ void auto_sel(Test *out, Test *in) { out->auto_sel = in->auto_sel; } // CHECK-AUTHENTICATED-SEL: define void @auto_sel -// CHECK-AUTHENTICATED-SEL: [[DST_DESCRIMINATOR:%.*]] = call i64 @llvm.ptrauth.blend(i64 [[CAST_DST_ADDR:%.*]], i64 22466) -// CHECK-AUTHENTICATED-SEL: [[CAST_SRC_ADDR:%.*]] = ptrtoint ptr [[SRC_ADDR:%.*]] to i64 +// CHECK-AUTHENTICATED-SEL: [[V0:%.*]] = load ptr, ptr %out.addr +// CHECK-AUTHENTICATED-SEL: [[SRC_ADDR:%.*]] = getelementptr inbounds i8, ptr [[V0]], i64 {{%.*}} +// CHECK-AUTHENTICATED-SEL: [[V1:%.*]] = load ptr, ptr %in.addr +// CHECK-AUTHENTICATED-SEL: [[DST_ADDR:%.*]] = getelementptr inbounds i8, ptr [[V1]], i64 {{%.*}} +// CHECK-AUTHENTICATED-SEL: [[CAST_DST_ADDR:%.*]] = ptrtoint ptr [[DST_ADDR]] to i64 +// CHECK-AUTHENTICATED-SEL: [[DST_DESCRIMINATOR:%.*]] = call i64 @llvm.ptrauth.blend(i64 [[CAST_DST_ADDR]], i64 22466) +// CHECK-AUTHENTICATED-SEL: [[CAST_SRC_ADDR:%.*]] = ptrtoint ptr [[SRC_ADDR]] to i64 // CHECK-AUTHENTICATED-SEL: [[SRC_DESCRIMINATOR:%.*]] = call i64 @llvm.ptrauth.blend(i64 [[CAST_SRC_ADDR]], i64 22466) // CHECK-AUTHENTICATED-SEL: [[SRC_SEL:%.*]] = ptrtoint ptr [[SRC_SEL_ADDR:%.*]] to i64 // CHECK-AUTHENTICATED-SEL: {{%.*}} = call i64 @llvm.ptrauth.resign(i64 [[SRC_SEL]]) [ "ptrauth"(i64 3, i64 [[DST_DESCRIMINATOR]]), "ptrauth"(i64 3, i64 [[SRC_DESCRIMINATOR]]) ] @@ -63,8 +68,13 @@ void volatile_auto_sel(Test *out, Test *in) { } // CHECK-AUTHENTICATED-SEL: define void @volatile_auto_sel -// CHECK-AUTHENTICATED-SEL: [[DST_DESCRIMINATOR:%.*]] = call i64 @llvm.ptrauth.blend(i64 [[CAST_DST_ADDR:%.*]], i64 22466) -// CHECK-AUTHENTICATED-SEL: [[CAST_SRC_ADDR:%.*]] = ptrtoint ptr [[SRC_ADDR:%.*]] to i64 +// CHECK-AUTHENTICATED-SEL: [[V1:%.*]] = load ptr, ptr %out.addr +// CHECK-AUTHENTICATED-SEL: [[SRC_ADDR:%.*]] = getelementptr inbounds i8, ptr [[V1]], i64 {{%.*}} +// CHECK-AUTHENTICATED-SEL: [[V2:%.*]] = load ptr, ptr %in.addr +// CHECK-AUTHENTICATED-SEL: [[DST_ADDR:%.*]] = getelementptr inbounds i8, ptr [[V2]], i64 {{%.*}} +// CHECK-AUTHENTICATED-SEL: [[CAST_DST_ADDR:%.*]] = ptrtoint ptr [[DST_ADDR]] to i64 +// CHECK-AUTHENTICATED-SEL: [[DST_DESCRIMINATOR:%.*]] = call i64 @llvm.ptrauth.blend(i64 [[CAST_DST_ADDR]], i64 22466) +// CHECK-AUTHENTICATED-SEL: [[CAST_SRC_ADDR:%.*]] = ptrtoint ptr [[SRC_ADDR]] to i64 // CHECK-AUTHENTICATED-SEL: [[SRC_DESCRIMINATOR:%.*]] = call i64 @llvm.ptrauth.blend(i64 [[CAST_SRC_ADDR]], i64 22466) // CHECK-AUTHENTICATED-SEL: [[SRC_SEL:%.*]] = ptrtoint ptr [[SRC_SEL_ADDR:%.*]] to i64 // CHECK-AUTHENTICATED-SEL: {{%.*}} = call i64 @llvm.ptrauth.resign(i64 [[SRC_SEL]]) [ "ptrauth"(i64 3, i64 [[DST_DESCRIMINATOR]]), "ptrauth"(i64 3, i64 [[SRC_DESCRIMINATOR]]) ] @@ -74,15 +84,25 @@ void manual(Test *out, Test *in) { } // CHECK-AUTHENTICATED-SEL: define void @manual -// CHECK-AUTHENTICATED-SEL: [[DST_DESCRIMINATOR:%.*]] = call i64 @llvm.ptrauth.blend(i64 [[CAST_DST_ADDR:%.*]], i64 22467) -// CHECK-AUTHENTICATED-SEL: [[CAST_SRC_ADDR:%.*]] = ptrtoint ptr [[SRC_ADDR:%.*]] to i64 +// CHECK-AUTHENTICATED-SEL: [[V0:%.*]] = load ptr, ptr %out.addr +// CHECK-AUTHENTICATED-SEL: [[SRC_ADDR:%.*]] = getelementptr inbounds i8, ptr [[V0]], i64 {{%.*}} +// CHECK-AUTHENTICATED-SEL: [[V1:%.*]] = load ptr, ptr %in.addr +// CHECK-AUTHENTICATED-SEL: [[DST_ADDR:%.*]] = getelementptr inbounds i8, ptr [[V1]], i64 {{%.*}} +// CHECK-AUTHENTICATED-SEL: [[CAST_DST_ADDR:%.*]] = ptrtoint ptr [[DST_ADDR]] to i64 +// CHECK-AUTHENTICATED-SEL: [[DST_DESCRIMINATOR:%.*]] = call i64 @llvm.ptrauth.blend(i64 [[CAST_DST_ADDR]], i64 22467) +// CHECK-AUTHENTICATED-SEL: [[CAST_SRC_ADDR:%.*]] = ptrtoint ptr [[SRC_ADDR]] to i64 // CHECK-AUTHENTICATED-SEL: [[SRC_DESCRIMINATOR:%.*]] = call i64 @llvm.ptrauth.blend(i64 [[CAST_SRC_ADDR]], i64 22467) // CHECK-AUTHENTICATED-SEL: [[SRC_SEL:%.*]] = ptrtoint ptr [[SRC_SEL_ADDR:%.*]] to i64 // CHECK-AUTHENTICATED-SEL: {{%.*}} = call i64 @llvm.ptrauth.resign(i64 [[SRC_SEL]]) [ "ptrauth"(i64 3, i64 [[DST_DESCRIMINATOR]]), "ptrauth"(i64 3, i64 [[SRC_DESCRIMINATOR]]) ] // CHECK-UNAUTHENTICATED-SEL: define void @manual -// CHECK-UNAUTHENTICATED-SEL: [[DST_DESCRIMINATOR:%.*]] = call i64 @llvm.ptrauth.blend(i64 [[CAST_DST_ADDR:%.*]], i64 22467) -// CHECK-UNAUTHENTICATED-SEL: [[CAST_SRC_ADDR:%.*]] = ptrtoint ptr [[SRC_ADDR:%.*]] to i64 +// CHECK-UNAUTHENTICATED-SEL: [[V0:%.*]] = load ptr, ptr %out.addr +// CHECK-UNAUTHENTICATED-SEL: [[SRC_ADDR:%.*]] = getelementptr inbounds i8, ptr [[V0]], i64 {{%.*}} +// CHECK-UNAUTHENTICATED-SEL: [[V1:%.*]] = load ptr, ptr %in.addr +// CHECK-UNAUTHENTICATED-SEL: [[DST_ADDR:%.*]] = getelementptr inbounds i8, ptr [[V1]], i64 {{%.*}} +// CHECK-UNAUTHENTICATED-SEL: [[CAST_DST_ADDR:%.*]] = ptrtoint ptr [[DST_ADDR]] to i64 +// CHECK-UNAUTHENTICATED-SEL: [[DST_DESCRIMINATOR:%.*]] = call i64 @llvm.ptrauth.blend(i64 [[CAST_DST_ADDR]], i64 22467) +// CHECK-UNAUTHENTICATED-SEL: [[CAST_SRC_ADDR:%.*]] = ptrtoint ptr [[SRC_ADDR]] to i64 // CHECK-UNAUTHENTICATED-SEL: [[SRC_DESCRIMINATOR:%.*]] = call i64 @llvm.ptrauth.blend(i64 [[CAST_SRC_ADDR]], i64 22467) // CHECK-UNAUTHENTICATED-SEL: [[SRC_SEL:%.*]] = ptrtoint ptr [[SRC_SEL_ADDR:%.*]] to i64 // CHECK-UNAUTHENTICATED-SEL: {{%.*}} = call i64 @llvm.ptrauth.resign(i64 [[SRC_SEL]]) [ "ptrauth"(i64 3, i64 [[DST_DESCRIMINATOR]]), "ptrauth"(i64 3, i64 [[SRC_DESCRIMINATOR]]) ] From 4288098c71f3e4de4d0a31365651ae4f92335698 Mon Sep 17 00:00:00 2001 From: Anatoly Trosinenko Date: Mon, 27 Oct 2025 22:32:50 +0300 Subject: [PATCH 08/40] Do not emit blend() in frontend-generated code --- clang/lib/CodeGen/CGClass.cpp | 2 +- clang/lib/CodeGen/CGExprConstant.cpp | 1 + clang/lib/CodeGen/CGPointerAuth.cpp | 120 ++++++--------- clang/lib/CodeGen/CGPointerAuthInfo.h | 47 ++++-- clang/lib/CodeGen/CodeGenFunction.cpp | 28 ++-- clang/lib/CodeGen/CodeGenFunction.h | 3 - clang/lib/CodeGen/ItaniumCXXABI.cpp | 10 +- .../ptrauth-function-lvalue-cast-disc.c | 6 +- .../CodeGen/ptrauth-function-lvalue-cast.c | 2 +- ...ptrauth-function-type-discriminator-cast.c | 4 +- .../ptrauth-function-type-discriminator.c | 12 +- clang/test/CodeGen/ptrauth-function.c | 2 +- clang/test/CodeGen/ptrauth-in-c-struct.c | 14 +- clang/test/CodeGen/ptrauth-qualifier-blocks.c | 27 ++-- .../test/CodeGen/ptrauth-qualifier-function.c | 10 +- .../CodeGen/ptrauth-qualifier-loadstore.c | 142 ++++++------------ .../ptrauth-restricted-intptr-qualifier.c | 50 +++--- .../CodeGenCXX/builtin-get-vtable-pointer.cpp | 51 +++---- .../ptrauth-apple-kext-indirect-call-2.cpp | 15 +- ...-apple-kext-indirect-virtual-dtor-call.cpp | 6 +- .../CodeGenCXX/ptrauth-dynamic-cast-exact.cpp | 15 +- ...trauth-explicit-vtable-pointer-control.cpp | 69 +++------ .../ptrauth-global-constant-initializers.cpp | 114 +++++++------- .../ptrauth-member-function-pointer.cpp | 24 ++- .../CodeGenCXX/ptrauth-qualifier-struct.cpp | 16 +- clang/test/CodeGenCXX/ptrauth-throw.cpp | 4 +- .../CodeGenCXX/ptrauth-type-info-vtable.cpp | 3 +- .../CodeGenCXX/ptrauth-virtual-function.cpp | 61 +++----- clang/test/CodeGenCXX/ptrauth.cpp | 2 +- clang/test/CodeGenCXX/ubsan-vtable-checks.cpp | 9 +- .../ptrauth-block-descriptor-pointer.m | 3 +- clang/test/CodeGenObjC/ptrauth-block-isa.m | 6 +- clang/test/CodeGenObjC/ptrauth-class.m | 15 +- .../ptrauth-objc-interface-selector.m | 52 ++----- .../CodeGenObjC/ptrauth-property-backing.m | 24 +-- .../ptrauth-objc-interface-selector.mm | 19 +-- 36 files changed, 389 insertions(+), 599 deletions(-) diff --git a/clang/lib/CodeGen/CGClass.cpp b/clang/lib/CodeGen/CGClass.cpp index f782b0cd17da4..624283854e130 100644 --- a/clang/lib/CodeGen/CGClass.cpp +++ b/clang/lib/CodeGen/CGClass.cpp @@ -2775,7 +2775,7 @@ llvm::Value *CodeGenFunction::GetVTablePtr(Address This, } else { VTable = cast(EmitPointerAuthAuth( CGPointerAuthInfo(0, PointerAuthenticationMode::Strip, false, false, - nullptr), + nullptr, nullptr), VTable)); } } diff --git a/clang/lib/CodeGen/CGExprConstant.cpp b/clang/lib/CodeGen/CGExprConstant.cpp index 0eec4dba4824a..f3b1210f16d08 100644 --- a/clang/lib/CodeGen/CGExprConstant.cpp +++ b/clang/lib/CodeGen/CGExprConstant.cpp @@ -2226,6 +2226,7 @@ ConstantLValueEmitter::tryEmitBase(const APValue::LValueBase &base) { if (hasNonZeroOffset()) return ConstantLValue(nullptr); + assert(!AuthInfo.isBlended()); C = applyOffset(C); C = CGM.getConstantSignedPointer( C, AuthInfo.getKey(), nullptr, diff --git a/clang/lib/CodeGen/CGPointerAuth.cpp b/clang/lib/CodeGen/CGPointerAuth.cpp index 90c4160985f72..20691db88bf1d 100644 --- a/clang/lib/CodeGen/CGPointerAuth.cpp +++ b/clang/lib/CodeGen/CGPointerAuth.cpp @@ -87,15 +87,7 @@ CGPointerAuthInfo CodeGenModule::getFunctionPointerAuthInfo(QualType T) { return CGPointerAuthInfo(Schema.getKey(), Schema.getAuthenticationMode(), /*IsaPointer=*/false, /*AuthenticatesNull=*/false, - Discriminator); -} - -llvm::Value * -CodeGenFunction::EmitPointerAuthBlendDiscriminator(llvm::Value *StorageAddress, - llvm::Value *Discriminator) { - StorageAddress = Builder.CreatePtrToInt(StorageAddress, IntPtrTy); - auto Intrinsic = CGM.getIntrinsic(llvm::Intrinsic::ptrauth_blend); - return Builder.CreateCall(Intrinsic, {StorageAddress, Discriminator}); + Discriminator, nullptr); } /// Emit the concrete pointer authentication informaton for the @@ -106,23 +98,21 @@ CGPointerAuthInfo CodeGenFunction::EmitPointerAuthInfo( if (!Schema) return CGPointerAuthInfo(); - llvm::Value *Discriminator = + llvm::Value *Discriminator = nullptr; + llvm::Value *ExtraDiscriminator = CGM.getPointerAuthOtherDiscriminator(Schema, SchemaDecl, SchemaType); if (Schema.isAddressDiscriminated()) { assert(StorageAddress && "address not provided for address-discriminated schema"); - if (Discriminator) - Discriminator = - EmitPointerAuthBlendDiscriminator(StorageAddress, Discriminator); - else - Discriminator = Builder.CreatePtrToInt(StorageAddress, IntPtrTy); + Discriminator = Builder.CreatePtrToInt(StorageAddress, IntPtrTy); } return CGPointerAuthInfo(Schema.getKey(), Schema.getAuthenticationMode(), Schema.isIsaPointer(), - Schema.authenticatesNullValues(), Discriminator); + Schema.authenticatesNullValues(), Discriminator, + ExtraDiscriminator); } CGPointerAuthInfo @@ -133,23 +123,20 @@ CodeGenFunction::EmitPointerAuthInfo(PointerAuthQualifier Qual, return CGPointerAuthInfo(); llvm::Value *Discriminator = nullptr; + llvm::Value *ExtraDiscriminator = nullptr; if (unsigned Extra = Qual.getExtraDiscriminator()) - Discriminator = llvm::ConstantInt::get(IntPtrTy, Extra); + ExtraDiscriminator = llvm::ConstantInt::get(IntPtrTy, Extra); if (Qual.isAddressDiscriminated()) { assert(StorageAddress.isValid() && "address discrimination without address"); llvm::Value *StoragePtr = StorageAddress.emitRawPointer(*this); - if (Discriminator) - Discriminator = - EmitPointerAuthBlendDiscriminator(StoragePtr, Discriminator); - else - Discriminator = Builder.CreatePtrToInt(StoragePtr, IntPtrTy); + Discriminator = Builder.CreatePtrToInt(StoragePtr, IntPtrTy); } return CGPointerAuthInfo(Qual.getKey(), Qual.getAuthenticationMode(), Qual.isIsaPointer(), Qual.authenticatesNullValues(), - Discriminator); + Discriminator, ExtraDiscriminator); } /// Return the natural pointer authentication for values of the given @@ -284,26 +271,6 @@ static bool isZeroConstant(const llvm::Value *Value) { return false; } -static bool equalAuthPolicies(const CGPointerAuthInfo &Left, - const CGPointerAuthInfo &Right) { - assert((Left.isSigned() || Right.isSigned()) && - "shouldn't be called if neither is signed"); - if (Left.isSigned() != Right.isSigned()) - return false; - return Left.getKey() == Right.getKey() && - Left.getAuthenticationMode() == Right.getAuthenticationMode() && - Left.isIsaPointer() == Right.isIsaPointer() && - Left.authenticatesNullValues() == Right.authenticatesNullValues() && - Left.getDiscriminator() == Right.getDiscriminator(); -} - -// Return the discriminator or return zero if the discriminator is null. -static llvm::Value *getDiscriminatorOrZero(const CGPointerAuthInfo &Info, - CGBuilderTy &Builder) { - llvm::Value *Discriminator = Info.getDiscriminator(); - return Discriminator ? Discriminator : Builder.getSize(0); -} - llvm::Value * CodeGenFunction::emitPointerAuthResignCall(llvm::Value *Value, const CGPointerAuthInfo &CurAuth, @@ -321,19 +288,14 @@ CodeGenFunction::emitPointerAuthResignCall(llvm::Value *Value, auto *OrigType = Value->getType(); Value = Builder.CreatePtrToInt(Value, IntPtrTy); - llvm::Value *CurKey = Builder.getInt64(CurAuth.getKey()); - llvm::Value *NewKey = Builder.getInt64(NewAuth.getKey()); - - llvm::Value *CurDiscriminator = getDiscriminatorOrZero(CurAuth, Builder); - llvm::Value *NewDiscriminator = getDiscriminatorOrZero(NewAuth, Builder); - - llvm::OperandBundleDef CurSchema("ptrauth", ArrayRef({CurKey, CurDiscriminator})); - llvm::OperandBundleDef NewSchema("ptrauth", ArrayRef({NewKey, NewDiscriminator})); + SmallVector OBs; + EmitPointerAuthOperandBundle(CurAuth, OBs); + EmitPointerAuthOperandBundle(NewAuth, OBs); // call i64 @llvm.ptrauth.resign(i64 %pointer) [ "ptrauth"(), // "ptrauth"() ] auto *Intrinsic = CGM.getIntrinsic(llvm::Intrinsic::ptrauth_resign); - Value = EmitRuntimeCall(Intrinsic, {Value}, {CurSchema, NewSchema}); + Value = EmitRuntimeCall(Intrinsic, {Value}, OBs); // Convert back to the original type. Value = Builder.CreateIntToPtr(Value, OrigType); @@ -358,15 +320,27 @@ llvm::Value *CodeGenFunction::emitPointerAuthResign( if (Value == Null) return Value; - // If both schemas sign the same way, we're done. - if (equalAuthPolicies(CurAuthInfo, NewAuthInfo)) { - const llvm::Value *CurD = CurAuthInfo.getDiscriminator(); - const llvm::Value *NewD = NewAuthInfo.getDiscriminator(); - if (CurD == NewD) - return Value; + auto GetPolicyTuple = [](const CGPointerAuthInfo &PAI) { + return std::make_tuple(PAI.getAuthenticationMode(), PAI.isIsaPointer(), + PAI.authenticatesNullValues(), PAI.getKey()); + }; - if ((CurD == nullptr && isZeroConstant(NewD)) || - (NewD == nullptr && isZeroConstant(CurD))) + // If both schemas sign the same way, we're done. + if (CurAuthInfo.isSigned() && NewAuthInfo.isSigned() && + GetPolicyTuple(CurAuthInfo) == GetPolicyTuple(NewAuthInfo)) { + auto IsSame = [](const llvm::Value *LHS, const llvm::Value *RHS) { + if (LHS == RHS) + return true; + + bool IsZeroLHS = LHS == nullptr || isZeroConstant(LHS); + bool IsZeroRHS = RHS == nullptr || isZeroConstant(RHS); + return IsZeroLHS && IsZeroRHS; + }; + + if (IsSame(CurAuthInfo.getDiscriminator(), + NewAuthInfo.getDiscriminator()) && + IsSame(CurAuthInfo.getExtraDiscriminator(), + NewAuthInfo.getExtraDiscriminator())) return Value; } @@ -484,10 +458,12 @@ llvm::Constant *CodeGenModule::getFunctionPointer(llvm::Constant *Pointer, FunctionType->isFunctionReferenceType() || FunctionType->isFunctionPointerType()); - if (auto PointerAuth = getFunctionPointerAuthInfo(FunctionType)) + if (auto PointerAuth = getFunctionPointerAuthInfo(FunctionType)) { + assert(!PointerAuth.isBlended()); return getConstantSignedPointer( Pointer, PointerAuth.getKey(), /*StorageAddress=*/nullptr, cast_or_null(PointerAuth.getDiscriminator())); + } return Pointer; } @@ -520,15 +496,18 @@ CGPointerAuthInfo CodeGenModule::getMemberFunctionPointerAuthInfo(QualType FT) { getPointerAuthOtherDiscriminator(Schema, GlobalDecl(), FT); return CGPointerAuthInfo(Schema.getKey(), Schema.getAuthenticationMode(), /* IsIsaPointer */ false, - /* AuthenticatesNullValues */ false, Discriminator); + /* AuthenticatesNullValues */ false, nullptr, + Discriminator); } llvm::Constant *CodeGenModule::getMemberFunctionPointer(llvm::Constant *Pointer, QualType FT) { - if (CGPointerAuthInfo PointerAuth = getMemberFunctionPointerAuthInfo(FT)) + if (CGPointerAuthInfo PointerAuth = getMemberFunctionPointerAuthInfo(FT)) { + assert(!PointerAuth.isBlended()); return getConstantSignedPointer( Pointer, PointerAuth.getKey(), nullptr, cast_or_null(PointerAuth.getDiscriminator())); + } if (const auto *MFT = dyn_cast(FT.getTypePtr())) { if (MFT->hasPointeeToToCFIUncheckedCalleeFunctionType()) @@ -637,23 +616,22 @@ CodeGenModule::getVTablePointerAuthInfo(CodeGenFunction *CGF, return std::nullopt; llvm::Value *Discriminator = nullptr; - if (auto ExtraDiscriminator = Authentication->getExtraDiscriminator()) - Discriminator = llvm::ConstantInt::get(IntPtrTy, ExtraDiscriminator); + llvm::Value *ExtraDiscriminator = nullptr; + if (auto Extra = Authentication->getExtraDiscriminator()) + ExtraDiscriminator = llvm::ConstantInt::get(IntPtrTy, Extra); + if (Authentication->isAddressDiscriminated()) { assert(StorageAddress && "address not provided for address-discriminated schema"); - if (Discriminator) - Discriminator = - CGF->EmitPointerAuthBlendDiscriminator(StorageAddress, Discriminator); - else - Discriminator = CGF->Builder.CreatePtrToInt(StorageAddress, IntPtrTy); + Discriminator = CGF->Builder.CreatePtrToInt(StorageAddress, IntPtrTy); } return CGPointerAuthInfo(Authentication->getKey(), PointerAuthenticationMode::SignAndAuth, /* IsIsaPointer */ false, - /* AuthenticatesNullValues */ false, Discriminator); + /* AuthenticatesNullValues */ false, Discriminator, + ExtraDiscriminator); } llvm::Value *CodeGenFunction::authPointerToPointerCast(llvm::Value *ResultPtr, diff --git a/clang/lib/CodeGen/CGPointerAuthInfo.h b/clang/lib/CodeGen/CGPointerAuthInfo.h index 0a0c11fb423f2..933a31ddb4c17 100644 --- a/clang/lib/CodeGen/CGPointerAuthInfo.h +++ b/clang/lib/CodeGen/CGPointerAuthInfo.h @@ -13,35 +13,34 @@ #ifndef LLVM_CLANG_LIB_CODEGEN_CGPOINTERAUTHINFO_H #define LLVM_CLANG_LIB_CODEGEN_CGPOINTERAUTHINFO_H -#include "clang/AST/Type.h" #include "clang/Basic/LangOptions.h" #include "llvm/IR/Type.h" #include "llvm/IR/Value.h" +#include namespace clang { namespace CodeGen { class CGPointerAuthInfo { -private: - PointerAuthenticationMode AuthenticationMode : 2; - unsigned IsIsaPointer : 1; - unsigned AuthenticatesNullValues : 1; - unsigned Key : 2; - llvm::Value *Discriminator; - public: CGPointerAuthInfo() : AuthenticationMode(PointerAuthenticationMode::None), IsIsaPointer(false), AuthenticatesNullValues(false), Key(0), - Discriminator(nullptr) {} + Discriminator(nullptr), ExtraDiscriminator(nullptr) {} CGPointerAuthInfo(unsigned Key, PointerAuthenticationMode AuthenticationMode, bool IsIsaPointer, bool AuthenticatesNullValues, - llvm::Value *Discriminator) + llvm::Value *Discriminator, llvm::Value *ExtraDiscriminator) : AuthenticationMode(AuthenticationMode), IsIsaPointer(IsIsaPointer), AuthenticatesNullValues(AuthenticatesNullValues), Key(Key), - Discriminator(Discriminator) { + Discriminator(Discriminator), ExtraDiscriminator(ExtraDiscriminator) { assert(!Discriminator || Discriminator->getType()->isIntegerTy() || Discriminator->getType()->isPointerTy()); + assert(!ExtraDiscriminator || ExtraDiscriminator->getType()->isIntegerTy()); + + if (!Discriminator) { + this->Discriminator = ExtraDiscriminator; + this->ExtraDiscriminator = nullptr; + } } explicit operator bool() const { return isSigned(); } @@ -54,11 +53,17 @@ class CGPointerAuthInfo { assert(isSigned()); return Key; } + llvm::Value *getDiscriminator() const { assert(isSigned()); return Discriminator; } + llvm::Value *getExtraDiscriminator() const { + assert(isSigned()); + return ExtraDiscriminator; + } + PointerAuthenticationMode getAuthenticationMode() const { return AuthenticationMode; } @@ -81,16 +86,30 @@ class CGPointerAuthInfo { return AuthenticationMode == PointerAuthenticationMode::SignAndAuth; } + bool isBlended() const { return ExtraDiscriminator != nullptr; } + friend bool operator!=(const CGPointerAuthInfo &LHS, const CGPointerAuthInfo &RHS) { - return LHS.Key != RHS.Key || LHS.Discriminator != RHS.Discriminator || - LHS.AuthenticationMode != RHS.AuthenticationMode; + return !(LHS == RHS); } friend bool operator==(const CGPointerAuthInfo &LHS, const CGPointerAuthInfo &RHS) { - return !(LHS != RHS); + auto AsTuple = [](const CGPointerAuthInfo &Info) { + return std::make_tuple(Info.AuthenticationMode, Info.IsIsaPointer, + Info.AuthenticatesNullValues, Info.Key, + Info.Discriminator, Info.ExtraDiscriminator); + }; + return AsTuple(LHS) == AsTuple(RHS); } + +private: + PointerAuthenticationMode AuthenticationMode : 2; + unsigned IsIsaPointer : 1; + unsigned AuthenticatesNullValues : 1; + unsigned Key : 2; + llvm::Value *Discriminator; + llvm::Value *ExtraDiscriminator; }; } // end namespace CodeGen diff --git a/clang/lib/CodeGen/CodeGenFunction.cpp b/clang/lib/CodeGen/CodeGenFunction.cpp index ae1c605031b3b..ec9a4b2387d36 100644 --- a/clang/lib/CodeGen/CodeGenFunction.cpp +++ b/clang/lib/CodeGen/CodeGenFunction.cpp @@ -3308,13 +3308,17 @@ void CodeGenFunction::EmitPointerAuthOperandBundle( if (!PointerAuth.isSigned()) return; - auto *Key = Builder.getInt32(PointerAuth.getKey()); - - llvm::Value *Discriminator = PointerAuth.getDiscriminator(); - if (!Discriminator) - Discriminator = Builder.getSize(0); + SmallVector Args; + Args.push_back(Builder.getInt64(PointerAuth.getKey())); + if (!PointerAuth.getDiscriminator() && !PointerAuth.getExtraDiscriminator()) { + Args.push_back(Builder.getInt64(0)); + } else { + if (llvm::Value *V = PointerAuth.getDiscriminator()) + Args.push_back(V); + if (llvm::Value *V = PointerAuth.getExtraDiscriminator()) + Args.push_back(V); + } - llvm::Value *Args[] = {Key, Discriminator}; Bundles.emplace_back("ptrauth", Args); } @@ -3325,14 +3329,8 @@ static llvm::Value *EmitPointerAuthCommon(CodeGenFunction &CGF, if (!PointerAuth) return Pointer; - llvm::Value *Key = CGF.Builder.getInt64(PointerAuth.getKey()); - - llvm::Value *Discriminator = PointerAuth.getDiscriminator(); - if (!Discriminator) { - Discriminator = CGF.Builder.getSize(0); - } - - llvm::OperandBundleDef OB("ptrauth", ArrayRef({Key, Discriminator})); + SmallVector OBs; + CGF.EmitPointerAuthOperandBundle(PointerAuth, OBs); // Convert the pointer to intptr_t before signing it. auto OrigType = Pointer->getType(); @@ -3340,7 +3338,7 @@ static llvm::Value *EmitPointerAuthCommon(CodeGenFunction &CGF, // call i64 @llvm.ptrauth.(i64 %pointer) [ "ptrauth"()] auto Intrinsic = CGF.CGM.getIntrinsic(IntrinsicID); - Pointer = CGF.EmitRuntimeCall(Intrinsic, {Pointer}, {OB}); + Pointer = CGF.EmitRuntimeCall(Intrinsic, {Pointer}, OBs); // Convert back to the original type. Pointer = CGF.Builder.CreateIntToPtr(Pointer, OrigType); diff --git a/clang/lib/CodeGen/CodeGenFunction.h b/clang/lib/CodeGen/CodeGenFunction.h index 6ed6495f6b976..fbf0df3407375 100644 --- a/clang/lib/CodeGen/CodeGenFunction.h +++ b/clang/lib/CodeGen/CodeGenFunction.h @@ -4591,9 +4591,6 @@ class CodeGenFunction : public CodeGenTypeCache { /// Check whether the underlying base pointer is a constant null. bool isUnderlyingBasePointerConstantNull(const Expr *E); - /// Create the discriminator from the storage address and the entity hash. - llvm::Value *EmitPointerAuthBlendDiscriminator(llvm::Value *StorageAddress, - llvm::Value *Discriminator); CGPointerAuthInfo EmitPointerAuthInfo(const PointerAuthSchema &Schema, llvm::Value *StorageAddress, GlobalDecl SchemaDecl, diff --git a/clang/lib/CodeGen/ItaniumCXXABI.cpp b/clang/lib/CodeGen/ItaniumCXXABI.cpp index 65c47633bc5c4..85e2fd5feccab 100644 --- a/clang/lib/CodeGen/ItaniumCXXABI.cpp +++ b/clang/lib/CodeGen/ItaniumCXXABI.cpp @@ -872,10 +872,15 @@ CGCallee ItaniumCXXABI::EmitLoadOfMemberFunctionPointer( assert(Schema.getKey() == AuthInfo.getKey() && "Keys for virtual and non-virtual member functions must match"); auto *NonVirtualDiscriminator = AuthInfo.getDiscriminator(); + assert(!AuthInfo.isBlended() && + isa(NonVirtualDiscriminator)); + // FIXME This does not involve call to @llvm.ptrauth.blend(), but such + // usage of constant modifier is unsafe. + DiscriminatorPHI->addIncoming(NonVirtualDiscriminator, FnNonVirtual); PointerAuth = CGPointerAuthInfo( Schema.getKey(), Schema.getAuthenticationMode(), Schema.isIsaPointer(), - Schema.authenticatesNullValues(), DiscriminatorPHI); + Schema.authenticatesNullValues(), DiscriminatorPHI, nullptr); } CGCallee Callee(FPT, CalleePtr, PointerAuth); @@ -910,6 +915,7 @@ static llvm::Constant *pointerAuthResignConstant( assert(CPA->getKey()->getZExtValue() == CurAuthInfo.getKey() && CPA->getAddrDiscriminator()->isZeroValue() && CPA->getDiscriminator() == CurAuthInfo.getDiscriminator() && + !CurAuthInfo.isBlended() && !NewAuthInfo.isBlended() && "unexpected key or discriminators"); return CGM.getConstantSignedPointer( @@ -1769,7 +1775,7 @@ llvm::Value *ItaniumCXXABI::emitExactDynamicCast( // authenticate the resulting v-table at the end of the cast check. PerformPostCastAuthentication = CGF.getLangOpts().PointerAuthCalls; CGPointerAuthInfo StrippingAuthInfo(0, PointerAuthenticationMode::Strip, - false, false, nullptr); + false, false, nullptr, nullptr); Address VTablePtrPtr = ThisAddr.withElementType(CGF.VoidPtrPtrTy); VTable = CGF.Builder.CreateLoad(VTablePtrPtr, "vtable"); if (PerformPostCastAuthentication) diff --git a/clang/test/CodeGen/ptrauth-function-lvalue-cast-disc.c b/clang/test/CodeGen/ptrauth-function-lvalue-cast-disc.c index 75bf6d6a1ba10..8cadbb379e90b 100644 --- a/clang/test/CodeGen/ptrauth-function-lvalue-cast-disc.c +++ b/clang/test/CodeGen/ptrauth-function-lvalue-cast-disc.c @@ -13,7 +13,7 @@ void test1() { // TYPE: [[LOAD:%.*]] = load ptr, ptr @cptr // TYPE: [[TOINT:%.*]] = ptrtoint ptr [[LOAD]] to i64 // TYPE: call i64 @llvm.ptrauth.resign(i64 [[TOINT]]) [ "ptrauth"(i64 0, i64 0), "ptrauth"(i64 0, i64 18983) ] - // TYPE: call void {{.*}}() [ "ptrauth"(i32 0, i64 18983) ] + // TYPE: call void {{.*}}() [ "ptrauth"(i64 0, i64 18983) ] // ZERO-NOT: @llvm.ptrauth.resign (*(fptr_t)cptr)(); @@ -45,9 +45,9 @@ void test4() { // TYPE-NEXT: [[CAST4:%.*]] = ptrtoint ptr [[LOAD]] to i64 // TYPE-NEXT: [[RESIGN:%.*]] = call i64 @llvm.ptrauth.resign(i64 [[CAST4]]) [ "ptrauth"(i64 0, i64 0), "ptrauth"(i64 0, i64 18983) ] // TYPE-NEXT: [[CAST5:%.*]] = inttoptr i64 [[RESIGN]] to ptr - // TYPE-NEXT: call void [[CAST5]]() [ "ptrauth"(i32 0, i64 18983) ] + // TYPE-NEXT: call void [[CAST5]]() [ "ptrauth"(i64 0, i64 18983) ] // ZERO-NOT: @llvm.ptrauth.resign - // ZERO: call void [[LOAD]]() [ "ptrauth"(i32 0, i64 0) ] + // ZERO: call void [[LOAD]]() [ "ptrauth"(i64 0, i64 0) ] } void *vptr; diff --git a/clang/test/CodeGen/ptrauth-function-lvalue-cast.c b/clang/test/CodeGen/ptrauth-function-lvalue-cast.c index 8d8af18fcafbe..e2299e3ebd807 100644 --- a/clang/test/CodeGen/ptrauth-function-lvalue-cast.c +++ b/clang/test/CodeGen/ptrauth-function-lvalue-cast.c @@ -9,7 +9,7 @@ void (*fptr)(void); // CHECK: define {{(dso_local )?}}void @test1 void test1() { // CHECK: [[LOAD:%.*]] = load ptr, ptr @cptr - // CHECK: call void [[LOAD]]() [ "ptrauth"(i32 0, i64 0) ] + // CHECK: call void [[LOAD]]() [ "ptrauth"(i64 0, i64 0) ] // CHECK: ret void (*(fptr_t)cptr)(); diff --git a/clang/test/CodeGen/ptrauth-function-type-discriminator-cast.c b/clang/test/CodeGen/ptrauth-function-type-discriminator-cast.c index 021bb3e38b74c..31737098230b4 100644 --- a/clang/test/CodeGen/ptrauth-function-type-discriminator-cast.c +++ b/clang/test/CodeGen/ptrauth-function-type-discriminator-cast.c @@ -97,9 +97,9 @@ void test_call_lvalue_cast() { // TYPE: entry: // TYPE-NEXT: [[RESIGN:%.*]] = call i64 @llvm.ptrauth.resign(i64 ptrtoint (ptr ptrauth (ptr @f, i32 0, i64 18983) to i64)) [ "ptrauth"(i64 0, i64 18983), "ptrauth"(i64 0, i64 2712) ] // TYPE-NEXT: [[RESIGN_INT:%.*]] = inttoptr i64 [[RESIGN]] to ptr - // TYPE-NEXT: call void [[RESIGN_INT]](i32 noundef 42) [ "ptrauth"(i32 0, i64 2712) ] + // TYPE-NEXT: call void [[RESIGN_INT]](i32 noundef 42) [ "ptrauth"(i64 0, i64 2712) ] // ZERO-NOT: @llvm.ptrauth.resign - // ZERO: call void ptrauth (ptr @f, i32 0)(i32 noundef 42) [ "ptrauth"(i32 0, i64 0) ] + // ZERO: call void ptrauth (ptr @f, i32 0)(i32 noundef 42) [ "ptrauth"(i64 0, i64 0) ] } diff --git a/clang/test/CodeGen/ptrauth-function-type-discriminator.c b/clang/test/CodeGen/ptrauth-function-type-discriminator.c index 0952c1abf6c07..5b8dc6c3d7603 100644 --- a/clang/test/CodeGen/ptrauth-function-type-discriminator.c +++ b/clang/test/CodeGen/ptrauth-function-type-discriminator.c @@ -68,7 +68,7 @@ void (*fptr4)(void) = __builtin_ptrauth_sign_constant(&external_function, 2, __b // CHECK-LABEL: define{{.*}} void @test_call() void test_call() { // CHECK: [[T0:%.*]] = load ptr, ptr @fnptr, - // CHECK-NEXT: call void [[T0]]() [ "ptrauth"(i32 0, i64 18983) ] + // CHECK-NEXT: call void [[T0]]() [ "ptrauth"(i64 0, i64 18983) ] fnptr(); } @@ -109,7 +109,7 @@ void test_knr() { // CHECKC: [[P:%.*]] = alloca ptr // CHECKC: store ptr ptrauth (ptr @knr, i32 0, i64 18983), ptr [[P]] // CHECKC: [[LOAD:%.*]] = load ptr, ptr [[P]] - // CHECKC: call void [[LOAD]](i32 noundef 0) [ "ptrauth"(i32 0, i64 18983) ] + // CHECKC: call void [[LOAD]](i32 noundef 0) [ "ptrauth"(i64 0, i64 18983) ] } // CHECKC-LABEL: define{{.*}} void @test_redeclaration @@ -123,8 +123,8 @@ void test_redeclaration() { // CHECKC: store ptr ptrauth (ptr @redecl, i32 0, i64 18983), ptr %ptr // CHECKC: store ptr ptrauth (ptr @redecl, i32 0, i64 2712), ptr %ptr2 - // CHECKC: call void {{.*}}() [ "ptrauth"(i32 0, i64 18983) ] - // CHECKC: call void {{.*}}(i32 noundef 0) [ "ptrauth"(i32 0, i64 2712) ] + // CHECKC: call void {{.*}}() [ "ptrauth"(i64 0, i64 18983) ] + // CHECKC: call void {{.*}}(i32 noundef 0) [ "ptrauth"(i64 0, i64 2712) ] } void knr2(param) @@ -137,7 +137,7 @@ void test_redecl_knr() { p(); // CHECKC: store ptr ptrauth (ptr @knr2, i32 0, i64 18983) - // CHECKC: call void {{.*}}() [ "ptrauth"(i32 0, i64 18983) ] + // CHECKC: call void {{.*}}() [ "ptrauth"(i64 0, i64 18983) ] void knr2(int); @@ -145,7 +145,7 @@ void test_redecl_knr() { p2(0); // CHECKC: store ptr ptrauth (ptr @knr2, i32 0, i64 2712) - // CHECKC: call void {{.*}}(i32 noundef 0) [ "ptrauth"(i32 0, i64 2712) ] + // CHECKC: call void {{.*}}(i32 noundef 0) [ "ptrauth"(i64 0, i64 2712) ] } #endif diff --git a/clang/test/CodeGen/ptrauth-function.c b/clang/test/CodeGen/ptrauth-function.c index eea3f7ed73747..1152b773db5a3 100644 --- a/clang/test/CodeGen/ptrauth-function.c +++ b/clang/test/CodeGen/ptrauth-function.c @@ -14,7 +14,7 @@ void test_indirect_call(void (*fp(void))) { // CHECK: %[[FP_ADDR:.*]] = alloca ptr, align 8 // CHECK: store ptr %[[FP]], ptr %[[FP_ADDR]], align 8 // CHECK: %[[V0:.*]] = load ptr, ptr %[[FP_ADDR]], align 8 - // CHECK: %[[CALL:.*]] = call ptr %[[V0]]() [ "ptrauth"(i32 0, i64 0) ] + // CHECK: %[[CALL:.*]] = call ptr %[[V0]]() [ "ptrauth"(i64 0, i64 0) ] fp(); } diff --git a/clang/test/CodeGen/ptrauth-in-c-struct.c b/clang/test/CodeGen/ptrauth-in-c-struct.c index f21ce51eb3f04..bca14fda3d506 100644 --- a/clang/test/CodeGen/ptrauth-in-c-struct.c +++ b/clang/test/CodeGen/ptrauth-in-c-struct.c @@ -55,11 +55,9 @@ int g0; // CHECK: %[[V9:.*]] = getelementptr inbounds i8, ptr %[[V1]], i64 8 // CHECK: %[[V11:.*]] = load ptr, ptr %[[V9]], align 8 // CHECK: %[[V12:.*]] = ptrtoint ptr %[[V9]] to i64 -// CHECK: %[[V13:.*]] = call i64 @llvm.ptrauth.blend(i64 %[[V12]], i64 50) // CHECK: %[[V14:.*]] = ptrtoint ptr %[[V6]] to i64 -// CHECK: %[[V15:.*]] = call i64 @llvm.ptrauth.blend(i64 %[[V14]], i64 50) // CHECK: %[[V17:.*]] = ptrtoint ptr %[[V11]] to i64 -// CHECK: %[[V18:.*]] = call i64 @llvm.ptrauth.resign(i64 %[[V17]]) [ "ptrauth"(i64 1, i64 %[[V13]]), "ptrauth"(i64 1, i64 %[[V15]]) ] +// CHECK: %[[V18:.*]] = call i64 @llvm.ptrauth.resign(i64 %[[V17]]) [ "ptrauth"(i64 1, i64 %[[V12]], i64 50), "ptrauth"(i64 1, i64 %[[V14]], i64 50) ] void test_copy_constructor_SA(SA *s) { SA t = *s; @@ -79,11 +77,9 @@ void test_copy_constructor_SA(SA *s) { // CHECK: %[[V9:.*]] = getelementptr inbounds i8, ptr %[[V1]], i64 8 // CHECK: %[[V11:.*]] = load ptr, ptr %[[V9]], align 8 // CHECK: %[[V12:.*]] = ptrtoint ptr %[[V9]] to i64 -// CHECK: %[[V13:.*]] = call i64 @llvm.ptrauth.blend(i64 %[[V12]], i64 30) // CHECK: %[[V14:.*]] = ptrtoint ptr %[[V6]] to i64 -// CHECK: %[[V15:.*]] = call i64 @llvm.ptrauth.blend(i64 %[[V14]], i64 30) // CHECK: %[[V17:.*]] = ptrtoint ptr %[[V11]] to i64 -// CHECK: %[[V18:.*]] = call i64 @llvm.ptrauth.resign(i64 %[[V17]]) [ "ptrauth"(i64 2, i64 %[[V13]]), "ptrauth"(i64 2, i64 %[[V15]]) ] +// CHECK: %[[V18:.*]] = call i64 @llvm.ptrauth.resign(i64 %[[V17]]) [ "ptrauth"(i64 2, i64 %[[V12]], i64 30), "ptrauth"(i64 2, i64 %[[V14]], i64 30) ] void test_copy_constructor_SA2(SA2 *s) { SA2 t = *s; @@ -168,14 +164,12 @@ void test_parameter_SI(SI a) { // CHECK-LABEL: define void @test_array( // CHECK: %[[F1:.*]] = getelementptr inbounds nuw %[[STRUCT_SA]], ptr %{{.*}}, i32 0, i32 1 // CHECK: %[[V0:.*]] = ptrtoint ptr %[[F1]] to i64 -// CHECK: %[[V1:.*]] = call i64 @llvm.ptrauth.blend(i64 %[[V0]], i64 50) -// CHECK: %[[V2:.*]] = call i64 @llvm.ptrauth.sign(i64 ptrtoint (ptr @g0 to i64)) [ "ptrauth"(i64 1, i64 %[[V1]]) ] +// CHECK: %[[V2:.*]] = call i64 @llvm.ptrauth.sign(i64 ptrtoint (ptr @g0 to i64)) [ "ptrauth"(i64 1, i64 %[[V0]], i64 50) ] // CHECK: %[[V3:.*]] = inttoptr i64 %[[V2]] to ptr // CHECK: store ptr %[[V3]], ptr %[[F1]], align 8 // CHECK: %[[F12:.*]] = getelementptr inbounds nuw %[[STRUCT_SA]], ptr %{{.*}}, i32 0, i32 1 // CHECK: %[[V4:.*]] = ptrtoint ptr %[[F12]] to i64 -// CHECK: %[[V5:.*]] = call i64 @llvm.ptrauth.blend(i64 %[[V4]], i64 50) -// CHECK: %[[V6:.*]] = call i64 @llvm.ptrauth.sign(i64 ptrtoint (ptr @g0 to i64)) [ "ptrauth"(i64 1, i64 %[[V5]]) ] +// CHECK: %[[V6:.*]] = call i64 @llvm.ptrauth.sign(i64 ptrtoint (ptr @g0 to i64)) [ "ptrauth"(i64 1, i64 %[[V4]], i64 50) ] // CHECK: %[[V7:.*]] = inttoptr i64 %[[V6]] to ptr // CHECK: store ptr %[[V7]], ptr %[[F12]], align 8 diff --git a/clang/test/CodeGen/ptrauth-qualifier-blocks.c b/clang/test/CodeGen/ptrauth-qualifier-blocks.c index db2df20e57a2e..251af074ab2ae 100644 --- a/clang/test/CodeGen/ptrauth-qualifier-blocks.c +++ b/clang/test/CodeGen/ptrauth-qualifier-blocks.c @@ -30,14 +30,12 @@ void test_block_address_capture() { // CHECK: store i32 1107296256, ptr // CHECK: [[CAPTURE:%.*]] = getelementptr inbounds {{.*}} [[BLOCK]], i32 0, i32 5 // CHECK: [[LOAD:%.*]] = load ptr, ptr [[VAR]], - // CHECK: [[T0:%.*]] = ptrtoint ptr [[VAR]] to i64 - // CHECK: [[OLDDISC:%.*]] = call i64 @llvm.ptrauth.blend(i64 [[T0]], i64 30) - // CHECK: [[T0:%.*]] = ptrtoint ptr [[CAPTURE]] to i64 - // CHECK: [[NEWDISC:%.*]] = call i64 @llvm.ptrauth.blend(i64 [[T0]], i64 30) + // CHECK: [[T01:%.*]] = ptrtoint ptr [[VAR]] to i64 + // CHECK: [[T02:%.*]] = ptrtoint ptr [[CAPTURE]] to i64 // CHECK: [[T0:%.*]] = icmp ne ptr [[LOAD]], null // CHECK: br i1 [[T0]] // CHECK: [[T0:%.*]] = ptrtoint ptr [[LOAD]] to i64 - // CHECK: [[T1:%.*]] = call i64 @llvm.ptrauth.resign(i64 [[T0]]) [ "ptrauth"(i64 1, i64 [[OLDDISC]]), "ptrauth"(i64 1, i64 [[NEWDISC]]) ] + // CHECK: [[T1:%.*]] = call i64 @llvm.ptrauth.resign(i64 [[T0]]) [ "ptrauth"(i64 1, i64 [[T01]], i64 30), "ptrauth"(i64 1, i64 [[T02]], i64 30) ] // CHECK: [[T2:%.*]] = inttoptr i64 [[T1]] to ptr // CHECK: [[T0:%.*]] = phi // CHECK: store ptr [[T0]], ptr [[CAPTURE]] @@ -45,21 +43,18 @@ void test_block_address_capture() { use_block(^{ return ptr->value; }); } // CHECK-LABEL: define internal i32 @__test_block_address_capture_block_invoke -// CHECK: [[DISC:%.*]] = call i64 @llvm.ptrauth.blend(i64 {{.*}}, i64 30) -// CHECK: call i64 @llvm.ptrauth.auth(i64 {{%.*}}) [ "ptrauth"(i64 1, i64 [[DISC]]) ] +// CHECK: call i64 @llvm.ptrauth.auth(i64 {{%.*}}) [ "ptrauth"(i64 1, i64 {{.*}}, i64 30) ] // CHECK: linkonce_odr hidden void @__copy_helper_block_8_32p1d30( // CHECK: [[OLDSLOT:%.*]] = getelementptr inbounds {{.*}} {{.*}}, i32 0, i32 5 // CHECK: [[NEWSLOT:%.*]] = getelementptr inbounds {{.*}} {{.*}}, i32 0, i32 5 // CHECK: [[LOAD:%.*]] = load ptr, ptr [[OLDSLOT]], -// CHECK: [[T0:%.*]] = ptrtoint ptr [[OLDSLOT]] to i64 -// CHECK: [[OLDDISC:%.*]] = call i64 @llvm.ptrauth.blend(i64 [[T0]], i64 30) -// CHECK: [[T0:%.*]] = ptrtoint ptr [[NEWSLOT]] to i64 -// CHECK: [[NEWDISC:%.*]] = call i64 @llvm.ptrauth.blend(i64 [[T0]], i64 30) +// CHECK: [[T01:%.*]] = ptrtoint ptr [[OLDSLOT]] to i64 +// CHECK: [[T02:%.*]] = ptrtoint ptr [[NEWSLOT]] to i64 // CHECK: [[T0:%.*]] = icmp ne ptr [[LOAD]], null // CHECK: br i1 [[T0]] // CHECK: [[T0:%.*]] = ptrtoint ptr [[LOAD]] to i64 -// CHECK: [[T1:%.*]] = call i64 @llvm.ptrauth.resign(i64 [[T0]]) [ "ptrauth"(i64 1, i64 [[OLDDISC]]), "ptrauth"(i64 1, i64 [[NEWDISC]]) ] +// CHECK: [[T1:%.*]] = call i64 @llvm.ptrauth.resign(i64 [[T0]]) [ "ptrauth"(i64 1, i64 [[T01]], i64 30), "ptrauth"(i64 1, i64 [[T02]], i64 30) ] // CHECK: [[T2:%.*]] = inttoptr i64 [[T1]] to ptr // CHECK: [[T0:%.*]] = phi // CHECK: store ptr [[T0]], ptr [[NEWSLOT]] @@ -101,14 +96,12 @@ void test_block_address_byref_capture() { // CHECK: [[NEWSLOT:%.*]] = getelementptr inbounds {{.*}} {{.*}}, i32 0, i32 6 // CHECK: [[OLDSLOT:%.*]] = getelementptr inbounds {{.*}} {{.*}}, i32 0, i32 6 // CHECK: [[LOAD:%.*]] = load ptr, ptr [[OLDSLOT]], -// CHECK: [[T0:%.*]] = ptrtoint ptr [[OLDSLOT]] to i64 -// CHECK: [[OLDDISC:%.*]] = call i64 @llvm.ptrauth.blend(i64 [[T0]], i64 60) -// CHECK: [[T0:%.*]] = ptrtoint ptr [[NEWSLOT]] to i64 -// CHECK: [[NEWDISC:%.*]] = call i64 @llvm.ptrauth.blend(i64 [[T0]], i64 60) +// CHECK: [[T01:%.*]] = ptrtoint ptr [[OLDSLOT]] to i64 +// CHECK: [[T02:%.*]] = ptrtoint ptr [[NEWSLOT]] to i64 // CHECK: [[T0:%.*]] = icmp ne ptr [[LOAD]], null // CHECK: br i1 [[T0]] // CHECK: [[T0:%.*]] = ptrtoint ptr [[LOAD]] to i64 -// CHECK: [[T1:%.*]] = call i64 @llvm.ptrauth.resign(i64 [[T0]]) [ "ptrauth"(i64 1, i64 [[OLDDISC]]), "ptrauth"(i64 1, i64 [[NEWDISC]]) ] +// CHECK: [[T1:%.*]] = call i64 @llvm.ptrauth.resign(i64 [[T0]]) [ "ptrauth"(i64 1, i64 [[T01]], i64 60), "ptrauth"(i64 1, i64 [[T02]], i64 60) ] // CHECK: [[T2:%.*]] = inttoptr i64 [[T1]] to ptr // CHECK: [[T0:%.*]] = phi // CHECK: store ptr [[T0]], ptr [[NEWSLOT]] diff --git a/clang/test/CodeGen/ptrauth-qualifier-function.c b/clang/test/CodeGen/ptrauth-qualifier-function.c index f21ad5ab9b7c2..7adcc5a0d71c0 100644 --- a/clang/test/CodeGen/ptrauth-qualifier-function.c +++ b/clang/test/CodeGen/ptrauth-qualifier-function.c @@ -88,8 +88,8 @@ void test_assign_from_qualified() { void test_const_ptr_function_call(void) { f_const_ptr(1); - // TYPE: call void ptrauth (ptr @f, i32 0, i64 2712)(i32 noundef 1) [ "ptrauth"(i32 0, i64 2712) ] - // ZERO: call void ptrauth (ptr @f, i32 0)(i32 noundef 1) [ "ptrauth"(i32 0, i64 0) ] + // TYPE: call void ptrauth (ptr @f, i32 0, i64 2712)(i32 noundef 1) [ "ptrauth"(i64 0, i64 2712) ] + // ZERO: call void ptrauth (ptr @f, i32 0)(i32 noundef 1) [ "ptrauth"(i64 0, i64 0) ] } #ifdef __cplusplus @@ -116,13 +116,12 @@ void (* const __ptrauth(0, 1, 43) &f_ref)(int) = f_const_ptr2; // CHECK-CXX-LABEL: define {{.*}}internal void @__cxx_global_var_init.1() // CHECK-CXX: [[ENTRY:.*]]: // CHECK-CXX: %[[V0:.*]] = load ptr, ptr @f_const_ptr2, align 8 -// CHECK-CXX: %[[V1:.*]] = call i64 @llvm.ptrauth.blend(i64 ptrtoint (ptr @_ZGR5f_ref_ to i64), i64 43) // CHECK-CXX: %[[V2:.*]] = icmp ne ptr %[[V0]], null // CHECK-CXX: br i1 %[[V2]], label %[[RESIGN_NONNULL:.*]], label %[[RESIGN_CONT:.*]] // CHECK-CXX: [[RESIGN_NONNULL]]: // CHECK-CXX: %[[V3:.*]] = ptrtoint ptr %[[V0]] to i64 -// CHECK-CXX: %[[V4:.*]] = call i64 @llvm.ptrauth.resign(i64 %[[V3]]) [ "ptrauth"(i64 0, i64 42), "ptrauth"(i64 0, i64 %[[V1]]) ] +// CHECK-CXX: %[[V4:.*]] = call i64 @llvm.ptrauth.resign(i64 %[[V3]]) [ "ptrauth"(i64 0, i64 42), "ptrauth"(i64 0, i64 ptrtoint (ptr @_ZGR5f_ref_ to i64), i64 43) ] // CHECK-CXX: %[[V5:.*]] = inttoptr i64 %[[V4]] to ptr // CHECK-CXX: br label %[[RESIGN_CONT]] @@ -138,8 +137,7 @@ void test_const_ptr_ref_function_call(void) { // CHECK-CXX: %[[V0:.*]] = load ptr, ptr @f_ref, align 8 // CHECK-CXX: %[[V1:.*]] = load ptr, ptr %[[V0]], align 8 // CHECK-CXX: %[[V2:.*]] = ptrtoint ptr %[[V0]] to i64 - // CHECK-CXX: %[[V3:.*]] = call i64 @llvm.ptrauth.blend(i64 %[[V2]], i64 43) - // CHECK-CXX: call void %[[V1]](i32 noundef 1) [ "ptrauth"(i32 0, i64 %[[V3]]) ] + // CHECK-CXX: call void %[[V1]](i32 noundef 1) [ "ptrauth"(i64 0, i64 %[[V2]], i64 43) ] } } #endif diff --git a/clang/test/CodeGen/ptrauth-qualifier-loadstore.c b/clang/test/CodeGen/ptrauth-qualifier-loadstore.c index f8348ce43ce74..eac41d9f19649 100644 --- a/clang/test/CodeGen/ptrauth-qualifier-loadstore.c +++ b/clang/test/CodeGen/ptrauth-qualifier-loadstore.c @@ -66,33 +66,30 @@ void test_store_data_iu() { void test_store_data_ia() { // CHECK: [[V:%.*]] = alloca ptr, // CHECK-NEXT: [[LOAD:%.*]] = load ptr, ptr @global_aqpi, -// CHECK-NEXT: [[OLDDISC:%.*]] = call i64 @llvm.ptrauth.blend(i64 ptrtoint (ptr @global_aqpi to i64), i64 50) // CHECK-NEXT: [[T0:%.*]] = icmp ne ptr [[LOAD]], null // CHECK-NEXT: br i1 [[T0]], // CHECK: [[T0:%.*]] = ptrtoint ptr [[LOAD]] to i64 -// CHECK-NEXT: [[T1:%.*]] = call i64 @llvm.ptrauth.resign(i64 [[T0]]) [ "ptrauth"(i64 1, i64 [[OLDDISC]]), "ptrauth"(i64 1, i64 50) ] +// CHECK-NEXT: [[T1:%.*]] = call i64 @llvm.ptrauth.resign(i64 [[T0]]) [ "ptrauth"(i64 1, i64 ptrtoint (ptr @global_aqpi to i64), i64 50), "ptrauth"(i64 1, i64 50) ] // CHECK-NEXT: [[SIGNED:%.*]] = inttoptr i64 [[T1]] to ptr // CHECK-NEXT: br label // CHECK: [[T0:%.*]] = phi ptr [ null, {{.*}} ], [ [[SIGNED]], {{.*}} ] // CHECK-NEXT: store ptr [[T0]], ptr [[V]], int * IQ iqpi = global_aqpi; // CHECK-NEXT: [[LOAD:%.*]] = load ptr, ptr @global_aqpi, -// CHECK-NEXT: [[OLDDISC:%.*]] = call i64 @llvm.ptrauth.blend(i64 ptrtoint (ptr @global_aqpi to i64), i64 50) // CHECK-NEXT: [[T0:%.*]] = icmp ne ptr [[LOAD]], null // CHECK-NEXT: br i1 [[T0]], // CHECK: [[T0:%.*]] = ptrtoint ptr [[LOAD]] to i64 -// CHECK-NEXT: [[T1:%.*]] = call i64 @llvm.ptrauth.resign(i64 [[T0]]) [ "ptrauth"(i64 1, i64 [[OLDDISC]]), "ptrauth"(i64 1, i64 50) ] +// CHECK-NEXT: [[T1:%.*]] = call i64 @llvm.ptrauth.resign(i64 [[T0]]) [ "ptrauth"(i64 1, i64 ptrtoint (ptr @global_aqpi to i64), i64 50), "ptrauth"(i64 1, i64 50) ] // CHECK-NEXT: [[SIGNED:%.*]] = inttoptr i64 [[T1]] to ptr // CHECK-NEXT: br label // CHECK: [[T0:%.*]] = phi ptr [ null, {{.*}} ], [ [[SIGNED]], {{.*}} ] // CHECK-NEXT: store ptr [[T0]], ptr [[V]], iqpi = global_aqpi; // CHECK-NEXT: [[LOAD:%.*]] = load ptr, ptr @global_aqpi, -// CHECK-NEXT: [[OLDDISC:%.*]] = call i64 @llvm.ptrauth.blend(i64 ptrtoint (ptr @global_aqpi to i64), i64 50) // CHECK-NEXT: [[T0:%.*]] = icmp ne ptr [[LOAD]], null // CHECK-NEXT: br i1 [[T0]], // CHECK: [[T0:%.*]] = ptrtoint ptr [[LOAD]] to i64 -// CHECK-NEXT: [[T1:%.*]] = call i64 @llvm.ptrauth.resign(i64 [[T0]]) [ "ptrauth"(i64 1, i64 [[OLDDISC]]), "ptrauth"(i64 1, i64 50) ] +// CHECK-NEXT: [[T1:%.*]] = call i64 @llvm.ptrauth.resign(i64 [[T0]]) [ "ptrauth"(i64 1, i64 ptrtoint (ptr @global_aqpi to i64), i64 50), "ptrauth"(i64 1, i64 50) ] // CHECK-NEXT: [[SIGNED:%.*]] = inttoptr i64 [[T1]] to ptr // CHECK-NEXT: br label // CHECK: [[RESULT:%.*]] = phi ptr [ null, {{.*}} ], [ [[SIGNED]], {{.*}} ] @@ -210,14 +207,12 @@ void test_load_data_i() { void test_store_data_a_constant() { // CHECK: [[V:%.*]] = alloca ptr, // CHECK-NEXT: [[T0:%.*]] = ptrtoint ptr [[V]] to i64 -// CHECK-NEXT: [[NEWDISC:%.*]] = call i64 @llvm.ptrauth.blend(i64 [[T0]], i64 50) -// CHECK-NEXT: [[SIGN:%.*]] = call i64 @llvm.ptrauth.sign(i64 ptrtoint (ptr @external_int to i64)) [ "ptrauth"(i64 1, i64 [[NEWDISC]]) ] +// CHECK-NEXT: [[SIGN:%.*]] = call i64 @llvm.ptrauth.sign(i64 ptrtoint (ptr @external_int to i64)) [ "ptrauth"(i64 1, i64 [[T0]], i64 50) ] // CHECK-NEXT: [[T0:%.*]] = inttoptr i64 [[SIGN]] to ptr // CHECK-NEXT: store ptr [[T0]], ptr [[V]], int * AQ aqpi = &external_int; // CHECK-NEXT: [[T0:%.*]] = ptrtoint ptr [[V]] to i64 -// CHECK-NEXT: [[NEWDISC:%.*]] = call i64 @llvm.ptrauth.blend(i64 [[T0]], i64 50) -// CHECK-NEXT: [[SIGN:%.*]] = call i64 @llvm.ptrauth.sign(i64 ptrtoint (ptr @external_int to i64)) [ "ptrauth"(i64 1, i64 [[NEWDISC]]) ] +// CHECK-NEXT: [[SIGN:%.*]] = call i64 @llvm.ptrauth.sign(i64 ptrtoint (ptr @external_int to i64)) [ "ptrauth"(i64 1, i64 [[T0]], i64 50) ] // CHECK-NEXT: [[T0:%.*]] = inttoptr i64 [[SIGN]] to ptr // CHECK-NEXT: store ptr [[T0]], ptr [[V]], aqpi = &external_int; @@ -227,24 +222,22 @@ void test_store_data_a_constant() { void test_store_data_au() { // CHECK: [[V:%.*]] = alloca ptr, // CHECK-NEXT: [[LOAD:%.*]] = load ptr, ptr @global_upi, -// CHECK-NEXT: [[T0:%.*]] = ptrtoint ptr [[V]] to i64 -// CHECK-NEXT: [[NEWDISC:%.*]] = call i64 @llvm.ptrauth.blend(i64 [[T0]], i64 50) +// CHECK-NEXT: [[T01:%.*]] = ptrtoint ptr [[V]] to i64 // CHECK-NEXT: [[T0:%.*]] = icmp ne ptr [[LOAD]], null // CHECK-NEXT: br i1 [[T0]], // CHECK: [[T0:%.*]] = ptrtoint ptr [[LOAD]] to i64 -// CHECK-NEXT: [[T1:%.*]] = call i64 @llvm.ptrauth.sign(i64 [[T0]]) [ "ptrauth"(i64 1, i64 [[NEWDISC]]) ] +// CHECK-NEXT: [[T1:%.*]] = call i64 @llvm.ptrauth.sign(i64 [[T0]]) [ "ptrauth"(i64 1, i64 [[T01]], i64 50) ] // CHECK-NEXT: [[SIGNED:%.*]] = inttoptr i64 [[T1]] to ptr // CHECK-NEXT: br label // CHECK: [[T0:%.*]] = phi ptr [ null, {{.*}} ], [ [[SIGNED]], {{.*}} ] // CHECK-NEXT: store ptr [[T0]], ptr [[V]], int * AQ aqpi = global_upi; // CHECK-NEXT: [[LOAD:%.*]] = load ptr, ptr @global_upi, -// CHECK-NEXT: [[T0:%.*]] = ptrtoint ptr [[V]] to i64 -// CHECK-NEXT: [[NEWDISC:%.*]] = call i64 @llvm.ptrauth.blend(i64 [[T0]], i64 50) +// CHECK-NEXT: [[T01:%.*]] = ptrtoint ptr [[V]] to i64 // CHECK-NEXT: [[T0:%.*]] = icmp ne ptr [[LOAD]], null // CHECK-NEXT: br i1 [[T0]], // CHECK: [[T0:%.*]] = ptrtoint ptr [[LOAD]] to i64 -// CHECK-NEXT: [[T1:%.*]] = call i64 @llvm.ptrauth.sign(i64 [[T0]]) [ "ptrauth"(i64 1, i64 [[NEWDISC]]) ] +// CHECK-NEXT: [[T1:%.*]] = call i64 @llvm.ptrauth.sign(i64 [[T0]]) [ "ptrauth"(i64 1, i64 [[T01]], i64 50) ] // CHECK-NEXT: [[SIGNED:%.*]] = inttoptr i64 [[T1]] to ptr // CHECK-NEXT: br label // CHECK: [[T0:%.*]] = phi ptr [ null, {{.*}} ], [ [[SIGNED]], {{.*}} ] @@ -256,24 +249,22 @@ void test_store_data_au() { void test_store_data_ai() { // CHECK: [[V:%.*]] = alloca ptr, // CHECK-NEXT: [[LOAD:%.*]] = load ptr, ptr @global_iqpi, -// CHECK-NEXT: [[T0:%.*]] = ptrtoint ptr [[V]] to i64 -// CHECK-NEXT: [[NEWDISC:%.*]] = call i64 @llvm.ptrauth.blend(i64 [[T0]], i64 50) +// CHECK-NEXT: [[T01:%.*]] = ptrtoint ptr [[V]] to i64 // CHECK-NEXT: [[T0:%.*]] = icmp ne ptr [[LOAD]], null // CHECK-NEXT: br i1 [[T0]], // CHECK: [[T0:%.*]] = ptrtoint ptr [[LOAD]] to i64 -// CHECK-NEXT: [[T1:%.*]] = call i64 @llvm.ptrauth.resign(i64 [[T0]]) [ "ptrauth"(i64 1, i64 50), "ptrauth"(i64 1, i64 [[NEWDISC]]) ] +// CHECK-NEXT: [[T1:%.*]] = call i64 @llvm.ptrauth.resign(i64 [[T0]]) [ "ptrauth"(i64 1, i64 50), "ptrauth"(i64 1, i64 [[T01]], i64 50) ] // CHECK-NEXT: [[SIGNED:%.*]] = inttoptr i64 [[T1]] to ptr // CHECK-NEXT: br label // CHECK: [[T0:%.*]] = phi ptr [ null, {{.*}} ], [ [[SIGNED]], {{.*}} ] // CHECK-NEXT: store ptr [[T0]], ptr [[V]], int * AQ aqpi = global_iqpi; // CHECK-NEXT: [[LOAD:%.*]] = load ptr, ptr @global_iqpi, -// CHECK-NEXT: [[T0:%.*]] = ptrtoint ptr [[V]] to i64 -// CHECK-NEXT: [[NEWDISC:%.*]] = call i64 @llvm.ptrauth.blend(i64 [[T0]], i64 50) +// CHECK-NEXT: [[T01:%.*]] = ptrtoint ptr [[V]] to i64 // CHECK-NEXT: [[T0:%.*]] = icmp ne ptr [[LOAD]], null // CHECK-NEXT: br i1 [[T0]], // CHECK: [[T0:%.*]] = ptrtoint ptr [[LOAD]] to i64 -// CHECK-NEXT: [[T1:%.*]] = call i64 @llvm.ptrauth.resign(i64 [[T0]]) [ "ptrauth"(i64 1, i64 50), "ptrauth"(i64 1, i64 [[NEWDISC]]) ] +// CHECK-NEXT: [[T1:%.*]] = call i64 @llvm.ptrauth.resign(i64 [[T0]]) [ "ptrauth"(i64 1, i64 50), "ptrauth"(i64 1, i64 [[T01]], i64 50) ] // CHECK-NEXT: [[SIGNED:%.*]] = inttoptr i64 [[T1]] to ptr // CHECK-NEXT: br label // CHECK: [[T0:%.*]] = phi ptr [ null, {{.*}} ], [ [[SIGNED]], {{.*}} ] @@ -285,26 +276,22 @@ void test_store_data_ai() { void test_store_data_aa_same() { // CHECK: [[V:%.*]] = alloca ptr, // CHECK-NEXT: [[LOAD:%.*]] = load ptr, ptr @global_aqpi, -// CHECK-NEXT: [[OLDDISC:%.*]] = call i64 @llvm.ptrauth.blend(i64 ptrtoint (ptr @global_aqpi to i64), i64 50) -// CHECK-NEXT: [[T0:%.*]] = ptrtoint ptr [[V]] to i64 -// CHECK-NEXT: [[NEWDISC:%.*]] = call i64 @llvm.ptrauth.blend(i64 [[T0]], i64 50) +// CHECK-NEXT: [[T01:%.*]] = ptrtoint ptr [[V]] to i64 // CHECK-NEXT: [[T0:%.*]] = icmp ne ptr [[LOAD]], null // CHECK-NEXT: br i1 [[T0]], // CHECK: [[T0:%.*]] = ptrtoint ptr [[LOAD]] to i64 -// CHECK-NEXT: [[T1:%.*]] = call i64 @llvm.ptrauth.resign(i64 [[T0]]) [ "ptrauth"(i64 1, i64 [[OLDDISC]]), "ptrauth"(i64 1, i64 [[NEWDISC]]) ] +// CHECK-NEXT: [[T1:%.*]] = call i64 @llvm.ptrauth.resign(i64 [[T0]]) [ "ptrauth"(i64 1, i64 ptrtoint (ptr @global_aqpi to i64), i64 50), "ptrauth"(i64 1, i64 [[T01]], i64 50) ] // CHECK-NEXT: [[SIGNED:%.*]] = inttoptr i64 [[T1]] to ptr // CHECK-NEXT: br label // CHECK: [[T0:%.*]] = phi ptr [ null, {{.*}} ], [ [[SIGNED]], {{.*}} ] // CHECK-NEXT: store ptr [[T0]], ptr [[V]], int * AQ aqpi = global_aqpi; // CHECK-NEXT: [[LOAD:%.*]] = load ptr, ptr @global_aqpi, -// CHECK-NEXT: [[OLDDISC:%.*]] = call i64 @llvm.ptrauth.blend(i64 ptrtoint (ptr @global_aqpi to i64), i64 50) -// CHECK-NEXT: [[T0:%.*]] = ptrtoint ptr [[V]] to i64 -// CHECK-NEXT: [[NEWDISC:%.*]] = call i64 @llvm.ptrauth.blend(i64 [[T0]], i64 50) +// CHECK-NEXT: [[T01:%.*]] = ptrtoint ptr [[V]] to i64 // CHECK-NEXT: [[T0:%.*]] = icmp ne ptr [[LOAD]], null // CHECK-NEXT: br i1 [[T0]], // CHECK: [[T0:%.*]] = ptrtoint ptr [[LOAD]] to i64 -// CHECK-NEXT: [[T1:%.*]] = call i64 @llvm.ptrauth.resign(i64 [[T0]]) [ "ptrauth"(i64 1, i64 [[OLDDISC]]), "ptrauth"(i64 1, i64 [[NEWDISC]]) ] +// CHECK-NEXT: [[T1:%.*]] = call i64 @llvm.ptrauth.resign(i64 [[T0]]) [ "ptrauth"(i64 1, i64 ptrtoint (ptr @global_aqpi to i64), i64 50), "ptrauth"(i64 1, i64 [[T01]], i64 50) ] // CHECK-NEXT: [[SIGNED:%.*]] = inttoptr i64 [[T1]] to ptr // CHECK-NEXT: br label // CHECK: [[T0:%.*]] = phi ptr [ null, {{.*}} ], [ [[SIGNED]], {{.*}} ] @@ -316,26 +303,22 @@ void test_store_data_aa_same() { void test_store_data_aa_different() { // CHECK: [[V:%.*]] = alloca ptr, // CHECK-NEXT: [[LOAD:%.*]] = load ptr, ptr @global_aqpi, -// CHECK-NEXT: [[OLDDISC:%.*]] = call i64 @llvm.ptrauth.blend(i64 ptrtoint (ptr @global_aqpi to i64), i64 50) -// CHECK-NEXT: [[T0:%.*]] = ptrtoint ptr [[V]] to i64 -// CHECK-NEXT: [[NEWDISC:%.*]] = call i64 @llvm.ptrauth.blend(i64 [[T0]], i64 100) +// CHECK-NEXT: [[T01:%.*]] = ptrtoint ptr [[V]] to i64 // CHECK-NEXT: [[T0:%.*]] = icmp ne ptr [[LOAD]], null // CHECK-NEXT: br i1 [[T0]], // CHECK: [[T0:%.*]] = ptrtoint ptr [[LOAD]] to i64 -// CHECK-NEXT: [[T1:%.*]] = call i64 @llvm.ptrauth.resign(i64 [[T0]]) [ "ptrauth"(i64 1, i64 [[OLDDISC]]), "ptrauth"(i64 1, i64 [[NEWDISC]]) ] +// CHECK-NEXT: [[T1:%.*]] = call i64 @llvm.ptrauth.resign(i64 [[T0]]) [ "ptrauth"(i64 1, i64 ptrtoint (ptr @global_aqpi to i64), i64 50), "ptrauth"(i64 1, i64 [[T01]], i64 100) ] // CHECK-NEXT: [[SIGNED:%.*]] = inttoptr i64 [[T1]] to ptr // CHECK-NEXT: br label // CHECK: [[T0:%.*]] = phi ptr [ null, {{.*}} ], [ [[SIGNED]], {{.*}} ] // CHECK-NEXT: store ptr [[T0]], ptr [[V]], int * DIFF_AQ aqpi = global_aqpi; // CHECK-NEXT: [[LOAD:%.*]] = load ptr, ptr @global_aqpi, -// CHECK-NEXT: [[OLDDISC:%.*]] = call i64 @llvm.ptrauth.blend(i64 ptrtoint (ptr @global_aqpi to i64), i64 50) -// CHECK-NEXT: [[T0:%.*]] = ptrtoint ptr [[V]] to i64 -// CHECK-NEXT: [[NEWDISC:%.*]] = call i64 @llvm.ptrauth.blend(i64 [[T0]], i64 100) +// CHECK-NEXT: [[T01:%.*]] = ptrtoint ptr [[V]] to i64 // CHECK-NEXT: [[T0:%.*]] = icmp ne ptr [[LOAD]], null // CHECK-NEXT: br i1 [[T0]], // CHECK: [[T0:%.*]] = ptrtoint ptr [[LOAD]] to i64 -// CHECK-NEXT: [[T1:%.*]] = call i64 @llvm.ptrauth.resign(i64 [[T0]]) [ "ptrauth"(i64 1, i64 [[OLDDISC]]), "ptrauth"(i64 1, i64 [[NEWDISC]]) ] +// CHECK-NEXT: [[T1:%.*]] = call i64 @llvm.ptrauth.resign(i64 [[T0]]) [ "ptrauth"(i64 1, i64 ptrtoint (ptr @global_aqpi to i64), i64 50), "ptrauth"(i64 1, i64 [[T01]], i64 100) ] // CHECK-NEXT: [[SIGNED:%.*]] = inttoptr i64 [[T1]] to ptr // CHECK-NEXT: br label // CHECK: [[T0:%.*]] = phi ptr [ null, {{.*}} ], [ [[SIGNED]], {{.*}} ] @@ -347,12 +330,11 @@ void test_store_data_aa_different() { void test_store_data_aa_zero() { // CHECK: [[V:%.*]] = alloca ptr, // CHECK-NEXT: [[LOAD:%.*]] = load ptr, ptr @global_aqpi, -// CHECK-NEXT: [[OLDDISC:%.*]] = call i64 @llvm.ptrauth.blend(i64 ptrtoint (ptr @global_aqpi to i64), i64 50) // CHECK-NEXT: [[NEWDISC:%.*]] = ptrtoint ptr [[V]] to i64 // CHECK-NEXT: [[T0:%.*]] = icmp ne ptr [[LOAD]], null // CHECK-NEXT: br i1 [[T0]], // CHECK: [[T0:%.*]] = ptrtoint ptr [[LOAD]] to i64 -// CHECK-NEXT: [[T1:%.*]] = call i64 @llvm.ptrauth.resign(i64 [[T0]]) [ "ptrauth"(i64 1, i64 [[OLDDISC]]), "ptrauth"(i64 1, i64 [[NEWDISC]]) ] +// CHECK-NEXT: [[T1:%.*]] = call i64 @llvm.ptrauth.resign(i64 [[T0]]) [ "ptrauth"(i64 1, i64 ptrtoint (ptr @global_aqpi to i64), i64 50), "ptrauth"(i64 1, i64 [[NEWDISC]]) ] // CHECK-NEXT: [[SIGNED:%.*]] = inttoptr i64 [[T1]] to ptr // CHECK-NEXT: br label // CHECK: [[T0:%.*]] = phi ptr [ null, {{.*}} ], [ [[SIGNED]], {{.*}} ] @@ -360,11 +342,10 @@ void test_store_data_aa_zero() { int * ZERO_AQ aqpi = global_aqpi; // CHECK: [[LOAD:%.*]] = load ptr, ptr [[V]], // CHECK-NEXT: [[OLDDISC:%.*]] = ptrtoint ptr [[V]] to i64 -// CHECK-NEXT: [[NEWDISC:%.*]] = call i64 @llvm.ptrauth.blend(i64 ptrtoint (ptr @global_aqpi to i64), i64 50) // CHECK-NEXT: [[T0:%.*]] = icmp ne ptr [[LOAD]], null // CHECK-NEXT: br i1 [[T0]], // CHECK: [[T0:%.*]] = ptrtoint ptr [[LOAD]] to i64 -// CHECK-NEXT: [[T1:%.*]] = call i64 @llvm.ptrauth.resign(i64 [[T0]]) [ "ptrauth"(i64 1, i64 [[OLDDISC]]), "ptrauth"(i64 1, i64 [[NEWDISC]]) ] +// CHECK-NEXT: [[T1:%.*]] = call i64 @llvm.ptrauth.resign(i64 [[T0]]) [ "ptrauth"(i64 1, i64 [[OLDDISC]]), "ptrauth"(i64 1, i64 ptrtoint (ptr @global_aqpi to i64), i64 50) ] // CHECK-NEXT: [[SIGNED:%.*]] = inttoptr i64 [[T1]] to ptr // CHECK-NEXT: br label // CHECK: [[T0:%.*]] = phi ptr [ null, {{.*}} ], [ [[SIGNED]], {{.*}} ] @@ -376,33 +357,30 @@ void test_store_data_aa_zero() { void test_load_data_a() { // CHECK: [[V:%.*]] = alloca ptr, // CHECK-NEXT: [[LOAD:%.*]] = load ptr, ptr @global_aqpi, -// CHECK-NEXT: [[OLDDISC:%.*]] = call i64 @llvm.ptrauth.blend(i64 ptrtoint (ptr @global_aqpi to i64), i64 50) // CHECK-NEXT: [[T0:%.*]] = icmp ne ptr [[LOAD]], null // CHECK-NEXT: br i1 [[T0]], // CHECK: [[T0:%.*]] = ptrtoint ptr [[LOAD]] to i64 -// CHECK-NEXT: [[T1:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[T0]]) [ "ptrauth"(i64 1, i64 [[OLDDISC]]) ] +// CHECK-NEXT: [[T1:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[T0]]) [ "ptrauth"(i64 1, i64 ptrtoint (ptr @global_aqpi to i64), i64 50) ] // CHECK-NEXT: [[AUTHED:%.*]] = inttoptr i64 [[T1]] to ptr // CHECK-NEXT: br label // CHECK: [[T0:%.*]] = phi ptr [ null, {{.*}} ], [ [[AUTHED]], {{.*}} ] // CHECK-NEXT: store ptr [[T0]], ptr [[V]], int *upi = global_aqpi; // CHECK-NEXT: [[LOAD:%.*]] = load ptr, ptr @global_aqpi, -// CHECK-NEXT: [[OLDDISC:%.*]] = call i64 @llvm.ptrauth.blend(i64 ptrtoint (ptr @global_aqpi to i64), i64 50) // CHECK-NEXT: [[T0:%.*]] = icmp ne ptr [[LOAD]], null // CHECK-NEXT: br i1 [[T0]], // CHECK: [[T0:%.*]] = ptrtoint ptr [[LOAD]] to i64 -// CHECK-NEXT: [[T1:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[T0]]) [ "ptrauth"(i64 1, i64 [[OLDDISC]]) ] +// CHECK-NEXT: [[T1:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[T0]]) [ "ptrauth"(i64 1, i64 ptrtoint (ptr @global_aqpi to i64), i64 50) ] // CHECK-NEXT: [[AUTHED:%.*]] = inttoptr i64 [[T1]] to ptr // CHECK-NEXT: br label // CHECK: [[T0:%.*]] = phi ptr [ null, {{.*}} ], [ [[AUTHED]], {{.*}} ] // CHECK-NEXT: store ptr [[T0]], ptr [[V]], upi = global_aqpi; // CHECK-NEXT: [[LOAD:%.*]] = load ptr, ptr @global_aqpi, -// CHECK-NEXT: [[OLDDISC:%.*]] = call i64 @llvm.ptrauth.blend(i64 ptrtoint (ptr @global_aqpi to i64), i64 50) // CHECK-NEXT: [[T0:%.*]] = icmp ne ptr [[LOAD]], null // CHECK-NEXT: br i1 [[T0]], // CHECK: [[T0:%.*]] = ptrtoint ptr [[LOAD]] to i64 -// CHECK-NEXT: [[T1:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[T0]]) [ "ptrauth"(i64 1, i64 [[OLDDISC]]) ] +// CHECK-NEXT: [[T1:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[T0]]) [ "ptrauth"(i64 1, i64 ptrtoint (ptr @global_aqpi to i64), i64 50) ] // CHECK-NEXT: [[AUTHED:%.*]] = inttoptr i64 [[T1]] to ptr // CHECK-NEXT: br label // CHECK: [[T0:%.*]] = phi ptr [ null, {{.*}} ], [ [[AUTHED]], {{.*}} ] @@ -454,33 +432,30 @@ void test_store_function_iu() { void test_store_function_ia() { // CHECK: [[V:%.*]] = alloca ptr, // CHECK-NEXT: [[LOAD:%.*]] = load ptr, ptr @global_aqpf, -// CHECK-NEXT: [[OLDDISC:%.*]] = call i64 @llvm.ptrauth.blend(i64 ptrtoint (ptr @global_aqpf to i64), i64 50) // CHECK-NEXT: [[T0:%.*]] = icmp ne ptr [[LOAD]], null // CHECK-NEXT: br i1 [[T0]], // CHECK: [[T0:%.*]] = ptrtoint ptr [[LOAD]] to i64 -// CHECK-NEXT: [[T1:%.*]] = call i64 @llvm.ptrauth.resign(i64 [[T0]]) [ "ptrauth"(i64 1, i64 [[OLDDISC]]), "ptrauth"(i64 1, i64 50) ] +// CHECK-NEXT: [[T1:%.*]] = call i64 @llvm.ptrauth.resign(i64 [[T0]]) [ "ptrauth"(i64 1, i64 ptrtoint (ptr @global_aqpf to i64), i64 50), "ptrauth"(i64 1, i64 50) ] // CHECK-NEXT: [[SIGNED:%.*]] = inttoptr i64 [[T1]] to ptr // CHECK-NEXT: br label // CHECK: [[T0:%.*]] = phi ptr [ null, {{.*}} ], [ [[SIGNED]], {{.*}} ] // CHECK-NEXT: store ptr [[T0]], ptr [[V]], func_t * IQ iqpf = global_aqpf; // CHECK-NEXT: [[LOAD:%.*]] = load ptr, ptr @global_aqpf, -// CHECK-NEXT: [[OLDDISC:%.*]] = call i64 @llvm.ptrauth.blend(i64 ptrtoint (ptr @global_aqpf to i64), i64 50) // CHECK-NEXT: [[T0:%.*]] = icmp ne ptr [[LOAD]], null // CHECK-NEXT: br i1 [[T0]], // CHECK: [[T0:%.*]] = ptrtoint ptr [[LOAD]] to i64 -// CHECK-NEXT: [[T1:%.*]] = call i64 @llvm.ptrauth.resign(i64 [[T0]]) [ "ptrauth"(i64 1, i64 [[OLDDISC]]), "ptrauth"(i64 1, i64 50) ] +// CHECK-NEXT: [[T1:%.*]] = call i64 @llvm.ptrauth.resign(i64 [[T0]]) [ "ptrauth"(i64 1, i64 ptrtoint (ptr @global_aqpf to i64), i64 50), "ptrauth"(i64 1, i64 50) ] // CHECK-NEXT: [[SIGNED:%.*]] = inttoptr i64 [[T1]] to ptr // CHECK-NEXT: br label // CHECK: [[T0:%.*]] = phi ptr [ null, {{.*}} ], [ [[SIGNED]], {{.*}} ] // CHECK-NEXT: store ptr [[T0]], ptr [[V]], iqpf = global_aqpf; // CHECK-NEXT: [[LOAD:%.*]] = load ptr, ptr @global_aqpf, -// CHECK-NEXT: [[OLDDISC:%.*]] = call i64 @llvm.ptrauth.blend(i64 ptrtoint (ptr @global_aqpf to i64), i64 50) // CHECK-NEXT: [[T0:%.*]] = icmp ne ptr [[LOAD]], null // CHECK-NEXT: br i1 [[T0]], // CHECK: [[T0:%.*]] = ptrtoint ptr [[LOAD]] to i64 -// CHECK-NEXT: [[T1:%.*]] = call i64 @llvm.ptrauth.resign(i64 [[T0]]) [ "ptrauth"(i64 1, i64 [[OLDDISC]]), "ptrauth"(i64 1, i64 50) ] +// CHECK-NEXT: [[T1:%.*]] = call i64 @llvm.ptrauth.resign(i64 [[T0]]) [ "ptrauth"(i64 1, i64 ptrtoint (ptr @global_aqpf to i64), i64 50), "ptrauth"(i64 1, i64 50) ] // CHECK-NEXT: [[SIGNED:%.*]] = inttoptr i64 [[T1]] to ptr // CHECK-NEXT: br label // CHECK: [[RESULT:%.*]] = phi ptr [ null, {{.*}} ], [ [[SIGNED]], {{.*}} ] @@ -573,14 +548,12 @@ void test_load_function_i() { void test_store_function_a_constant() { // CHECK: [[V:%.*]] = alloca ptr, // CHECK-NEXT: [[T0:%.*]] = ptrtoint ptr [[V]] to i64 -// CHECK-NEXT: [[NEWDISC:%.*]] = call i64 @llvm.ptrauth.blend(i64 [[T0]], i64 50) -// CHECK-NEXT: [[SIGN:%.*]] = call i64 @llvm.ptrauth.resign(i64 ptrtoint (ptr ptrauth (ptr @external_func, i32 0, i64 18983) to i64)) [ "ptrauth"(i64 0, i64 18983), "ptrauth"(i64 1, i64 [[NEWDISC]]) ] +// CHECK-NEXT: [[SIGN:%.*]] = call i64 @llvm.ptrauth.resign(i64 ptrtoint (ptr ptrauth (ptr @external_func, i32 0, i64 18983) to i64)) [ "ptrauth"(i64 0, i64 18983), "ptrauth"(i64 1, i64 [[T0]], i64 50) ] // CHECK-NEXT: [[T0:%.*]] = inttoptr i64 [[SIGN]] to ptr // CHECK-NEXT: store ptr [[T0]], ptr [[V]], func_t * AQ aqpf = &external_func; // CHECK-NEXT: [[T0:%.*]] = ptrtoint ptr [[V]] to i64 -// CHECK-NEXT: [[NEWDISC:%.*]] = call i64 @llvm.ptrauth.blend(i64 [[T0]], i64 50) -// CHECK-NEXT: [[SIGN:%.*]] = call i64 @llvm.ptrauth.resign(i64 ptrtoint (ptr ptrauth (ptr @external_func, i32 0, i64 18983) to i64)) [ "ptrauth"(i64 0, i64 18983), "ptrauth"(i64 1, i64 [[NEWDISC]]) ] +// CHECK-NEXT: [[SIGN:%.*]] = call i64 @llvm.ptrauth.resign(i64 ptrtoint (ptr ptrauth (ptr @external_func, i32 0, i64 18983) to i64)) [ "ptrauth"(i64 0, i64 18983), "ptrauth"(i64 1, i64 [[T0]], i64 50) ] // CHECK-NEXT: [[T0:%.*]] = inttoptr i64 [[SIGN]] to ptr // CHECK-NEXT: store ptr [[T0]], ptr [[V]], aqpf = &external_func; @@ -590,24 +563,22 @@ void test_store_function_a_constant() { void test_store_function_au() { // CHECK: [[V:%.*]] = alloca ptr, // CHECK-NEXT: [[LOAD:%.*]] = load ptr, ptr @global_upf, -// CHECK-NEXT: [[T0:%.*]] = ptrtoint ptr [[V]] to i64 -// CHECK-NEXT: [[NEWDISC:%.*]] = call i64 @llvm.ptrauth.blend(i64 [[T0]], i64 50) +// CHECK-NEXT: [[T01:%.*]] = ptrtoint ptr [[V]] to i64 // CHECK-NEXT: [[T0:%.*]] = icmp ne ptr [[LOAD]], null // CHECK-NEXT: br i1 [[T0]], // CHECK: [[T0:%.*]] = ptrtoint ptr [[LOAD]] to i64 -// CHECK-NEXT: [[T1:%.*]] = call i64 @llvm.ptrauth.resign(i64 [[T0]]) [ "ptrauth"(i64 0, i64 18983), "ptrauth"(i64 1, i64 [[NEWDISC]]) ] +// CHECK-NEXT: [[T1:%.*]] = call i64 @llvm.ptrauth.resign(i64 [[T0]]) [ "ptrauth"(i64 0, i64 18983), "ptrauth"(i64 1, i64 [[T01]], i64 50) ] // CHECK-NEXT: [[SIGNED:%.*]] = inttoptr i64 [[T1]] to ptr // CHECK-NEXT: br label // CHECK: [[T0:%.*]] = phi ptr [ null, {{.*}} ], [ [[SIGNED]], {{.*}} ] // CHECK-NEXT: store ptr [[T0]], ptr [[V]], func_t * AQ aqpf = global_upf; // CHECK-NEXT: [[LOAD:%.*]] = load ptr, ptr @global_upf, -// CHECK-NEXT: [[T0:%.*]] = ptrtoint ptr [[V]] to i64 -// CHECK-NEXT: [[NEWDISC:%.*]] = call i64 @llvm.ptrauth.blend(i64 [[T0]], i64 50) +// CHECK-NEXT: [[T01:%.*]] = ptrtoint ptr [[V]] to i64 // CHECK-NEXT: [[T0:%.*]] = icmp ne ptr [[LOAD]], null // CHECK-NEXT: br i1 [[T0]], // CHECK: [[T0:%.*]] = ptrtoint ptr [[LOAD]] to i64 -// CHECK-NEXT: [[T1:%.*]] = call i64 @llvm.ptrauth.resign(i64 [[T0]]) [ "ptrauth"(i64 0, i64 18983), "ptrauth"(i64 1, i64 [[NEWDISC]]) ] +// CHECK-NEXT: [[T1:%.*]] = call i64 @llvm.ptrauth.resign(i64 [[T0]]) [ "ptrauth"(i64 0, i64 18983), "ptrauth"(i64 1, i64 [[T01]], i64 50) ] // CHECK-NEXT: [[SIGNED:%.*]] = inttoptr i64 [[T1]] to ptr // CHECK-NEXT: br label // CHECK: [[T0:%.*]] = phi ptr [ null, {{.*}} ], [ [[SIGNED]], {{.*}} ] @@ -619,24 +590,22 @@ void test_store_function_au() { void test_store_function_ai() { // CHECK: [[V:%.*]] = alloca ptr, // CHECK-NEXT: [[LOAD:%.*]] = load ptr, ptr @global_iqpf, -// CHECK-NEXT: [[T0:%.*]] = ptrtoint ptr [[V]] to i64 -// CHECK-NEXT: [[NEWDISC:%.*]] = call i64 @llvm.ptrauth.blend(i64 [[T0]], i64 50) +// CHECK-NEXT: [[T01:%.*]] = ptrtoint ptr [[V]] to i64 // CHECK-NEXT: [[T0:%.*]] = icmp ne ptr [[LOAD]], null // CHECK-NEXT: br i1 [[T0]], // CHECK: [[T0:%.*]] = ptrtoint ptr [[LOAD]] to i64 -// CHECK-NEXT: [[T1:%.*]] = call i64 @llvm.ptrauth.resign(i64 [[T0]]) [ "ptrauth"(i64 1, i64 50), "ptrauth"(i64 1, i64 [[NEWDISC]]) ] +// CHECK-NEXT: [[T1:%.*]] = call i64 @llvm.ptrauth.resign(i64 [[T0]]) [ "ptrauth"(i64 1, i64 50), "ptrauth"(i64 1, i64 [[T01]], i64 50) ] // CHECK-NEXT: [[SIGNED:%.*]] = inttoptr i64 [[T1]] to ptr // CHECK-NEXT: br label // CHECK: [[T0:%.*]] = phi ptr [ null, {{.*}} ], [ [[SIGNED]], {{.*}} ] // CHECK-NEXT: store ptr [[T0]], ptr [[V]], func_t * AQ aqpf = global_iqpf; // CHECK-NEXT: [[LOAD:%.*]] = load ptr, ptr @global_iqpf, -// CHECK-NEXT: [[T0:%.*]] = ptrtoint ptr [[V]] to i64 -// CHECK-NEXT: [[NEWDISC:%.*]] = call i64 @llvm.ptrauth.blend(i64 [[T0]], i64 50) +// CHECK-NEXT: [[T01:%.*]] = ptrtoint ptr [[V]] to i64 // CHECK-NEXT: [[T0:%.*]] = icmp ne ptr [[LOAD]], null // CHECK-NEXT: br i1 [[T0]], // CHECK: [[T0:%.*]] = ptrtoint ptr [[LOAD]] to i64 -// CHECK-NEXT: [[T1:%.*]] = call i64 @llvm.ptrauth.resign(i64 [[T0]]) [ "ptrauth"(i64 1, i64 50), "ptrauth"(i64 1, i64 [[NEWDISC]]) ] +// CHECK-NEXT: [[T1:%.*]] = call i64 @llvm.ptrauth.resign(i64 [[T0]]) [ "ptrauth"(i64 1, i64 50), "ptrauth"(i64 1, i64 [[T01]], i64 50) ] // CHECK-NEXT: [[SIGNED:%.*]] = inttoptr i64 [[T1]] to ptr // CHECK-NEXT: br label // CHECK: [[T0:%.*]] = phi ptr [ null, {{.*}} ], [ [[SIGNED]], {{.*}} ] @@ -648,26 +617,22 @@ void test_store_function_ai() { void test_store_function_aa_same() { // CHECK: [[V:%.*]] = alloca ptr, // CHECK-NEXT: [[LOAD:%.*]] = load ptr, ptr @global_aqpf, -// CHECK-NEXT: [[OLDDISC:%.*]] = call i64 @llvm.ptrauth.blend(i64 ptrtoint (ptr @global_aqpf to i64), i64 50) -// CHECK-NEXT: [[T0:%.*]] = ptrtoint ptr [[V]] to i64 -// CHECK-NEXT: [[NEWDISC:%.*]] = call i64 @llvm.ptrauth.blend(i64 [[T0]], i64 50) +// CHECK-NEXT: [[T01:%.*]] = ptrtoint ptr [[V]] to i64 // CHECK-NEXT: [[T0:%.*]] = icmp ne ptr [[LOAD]], null // CHECK-NEXT: br i1 [[T0]], // CHECK: [[T0:%.*]] = ptrtoint ptr [[LOAD]] to i64 -// CHECK-NEXT: [[T1:%.*]] = call i64 @llvm.ptrauth.resign(i64 [[T0]]) [ "ptrauth"(i64 1, i64 [[OLDDISC]]), "ptrauth"(i64 1, i64 [[NEWDISC]]) ] +// CHECK-NEXT: [[T1:%.*]] = call i64 @llvm.ptrauth.resign(i64 [[T0]]) [ "ptrauth"(i64 1, i64 ptrtoint (ptr @global_aqpf to i64), i64 50), "ptrauth"(i64 1, i64 [[T01]], i64 50) ] // CHECK-NEXT: [[SIGNED:%.*]] = inttoptr i64 [[T1]] to ptr // CHECK-NEXT: br label // CHECK: [[T0:%.*]] = phi ptr [ null, {{.*}} ], [ [[SIGNED]], {{.*}} ] // CHECK-NEXT: store ptr [[T0]], ptr [[V]], func_t * AQ aqpf = global_aqpf; // CHECK-NEXT: [[LOAD:%.*]] = load ptr, ptr @global_aqpf, -// CHECK-NEXT: [[OLDDISC:%.*]] = call i64 @llvm.ptrauth.blend(i64 ptrtoint (ptr @global_aqpf to i64), i64 50) -// CHECK-NEXT: [[T0:%.*]] = ptrtoint ptr [[V]] to i64 -// CHECK-NEXT: [[NEWDISC:%.*]] = call i64 @llvm.ptrauth.blend(i64 [[T0]], i64 50) +// CHECK-NEXT: [[T01:%.*]] = ptrtoint ptr [[V]] to i64 // CHECK-NEXT: [[T0:%.*]] = icmp ne ptr [[LOAD]], null // CHECK-NEXT: br i1 [[T0]], // CHECK: [[T0:%.*]] = ptrtoint ptr [[LOAD]] to i64 -// CHECK-NEXT: [[T1:%.*]] = call i64 @llvm.ptrauth.resign(i64 [[T0]]) [ "ptrauth"(i64 1, i64 [[OLDDISC]]), "ptrauth"(i64 1, i64 [[NEWDISC]]) ] +// CHECK-NEXT: [[T1:%.*]] = call i64 @llvm.ptrauth.resign(i64 [[T0]]) [ "ptrauth"(i64 1, i64 ptrtoint (ptr @global_aqpf to i64), i64 50), "ptrauth"(i64 1, i64 [[T01]], i64 50) ] // CHECK-NEXT: [[SIGNED:%.*]] = inttoptr i64 [[T1]] to ptr // CHECK-NEXT: br label // CHECK: [[T0:%.*]] = phi ptr [ null, {{.*}} ], [ [[SIGNED]], {{.*}} ] @@ -679,26 +644,22 @@ void test_store_function_aa_same() { void test_store_function_aa_different() { // CHECK: [[V:%.*]] = alloca ptr, // CHECK-NEXT: [[LOAD:%.*]] = load ptr, ptr @global_aqpf, -// CHECK-NEXT: [[OLDDISC:%.*]] = call i64 @llvm.ptrauth.blend(i64 ptrtoint (ptr @global_aqpf to i64), i64 50) -// CHECK-NEXT: [[T0:%.*]] = ptrtoint ptr [[V]] to i64 -// CHECK-NEXT: [[NEWDISC:%.*]] = call i64 @llvm.ptrauth.blend(i64 [[T0]], i64 100) +// CHECK-NEXT: [[T01:%.*]] = ptrtoint ptr [[V]] to i64 // CHECK-NEXT: [[T0:%.*]] = icmp ne ptr [[LOAD]], null // CHECK-NEXT: br i1 [[T0]], // CHECK: [[T0:%.*]] = ptrtoint ptr [[LOAD]] to i64 -// CHECK-NEXT: [[T1:%.*]] = call i64 @llvm.ptrauth.resign(i64 [[T0]]) [ "ptrauth"(i64 1, i64 [[OLDDISC]]), "ptrauth"(i64 1, i64 [[NEWDISC]]) ] +// CHECK-NEXT: [[T1:%.*]] = call i64 @llvm.ptrauth.resign(i64 [[T0]]) [ "ptrauth"(i64 1, i64 ptrtoint (ptr @global_aqpf to i64), i64 50), "ptrauth"(i64 1, i64 [[T01]], i64 100) ] // CHECK-NEXT: [[SIGNED:%.*]] = inttoptr i64 [[T1]] to ptr // CHECK-NEXT: br label // CHECK: [[T0:%.*]] = phi ptr [ null, {{.*}} ], [ [[SIGNED]], {{.*}} ] // CHECK-NEXT: store ptr [[T0]], ptr [[V]], func_t * DIFF_AQ aqpf = global_aqpf; // CHECK-NEXT: [[LOAD:%.*]] = load ptr, ptr @global_aqpf, -// CHECK-NEXT: [[OLDDISC:%.*]] = call i64 @llvm.ptrauth.blend(i64 ptrtoint (ptr @global_aqpf to i64), i64 50) -// CHECK-NEXT: [[T0:%.*]] = ptrtoint ptr [[V]] to i64 -// CHECK-NEXT: [[NEWDISC:%.*]] = call i64 @llvm.ptrauth.blend(i64 [[T0]], i64 100) +// CHECK-NEXT: [[T01:%.*]] = ptrtoint ptr [[V]] to i64 // CHECK-NEXT: [[T0:%.*]] = icmp ne ptr [[LOAD]], null // CHECK-NEXT: br i1 [[T0]], // CHECK: [[T0:%.*]] = ptrtoint ptr [[LOAD]] to i64 -// CHECK-NEXT: [[T1:%.*]] = call i64 @llvm.ptrauth.resign(i64 [[T0]]) [ "ptrauth"(i64 1, i64 [[OLDDISC]]), "ptrauth"(i64 1, i64 [[NEWDISC]]) ] +// CHECK-NEXT: [[T1:%.*]] = call i64 @llvm.ptrauth.resign(i64 [[T0]]) [ "ptrauth"(i64 1, i64 ptrtoint (ptr @global_aqpf to i64), i64 50), "ptrauth"(i64 1, i64 [[T01]], i64 100) ] // CHECK-NEXT: [[SIGNED:%.*]] = inttoptr i64 [[T1]] to ptr // CHECK-NEXT: br label // CHECK: [[T0:%.*]] = phi ptr [ null, {{.*}} ], [ [[SIGNED]], {{.*}} ] @@ -710,33 +671,30 @@ void test_store_function_aa_different() { void test_load_function_a() { // CHECK: [[V:%.*]] = alloca ptr, // CHECK-NEXT: [[LOAD:%.*]] = load ptr, ptr @global_aqpf, -// CHECK-NEXT: [[OLDDISC:%.*]] = call i64 @llvm.ptrauth.blend(i64 ptrtoint (ptr @global_aqpf to i64), i64 50) // CHECK-NEXT: [[T0:%.*]] = icmp ne ptr [[LOAD]], null // CHECK-NEXT: br i1 [[T0]], // CHECK: [[T0:%.*]] = ptrtoint ptr [[LOAD]] to i64 -// CHECK-NEXT: [[T1:%.*]] = call i64 @llvm.ptrauth.resign(i64 [[T0]]) [ "ptrauth"(i64 1, i64 [[OLDDISC]]), "ptrauth"(i64 0, i64 18983) ] +// CHECK-NEXT: [[T1:%.*]] = call i64 @llvm.ptrauth.resign(i64 [[T0]]) [ "ptrauth"(i64 1, i64 ptrtoint (ptr @global_aqpf to i64), i64 50), "ptrauth"(i64 0, i64 18983) ] // CHECK-NEXT: [[SIGNED:%.*]] = inttoptr i64 [[T1]] to ptr // CHECK-NEXT: br label // CHECK: [[T0:%.*]] = phi ptr [ null, {{.*}} ], [ [[SIGNED]], {{.*}} ] // CHECK-NEXT: store ptr [[T0]], ptr [[V]], func_t *upf = global_aqpf; // CHECK-NEXT: [[LOAD:%.*]] = load ptr, ptr @global_aqpf, -// CHECK-NEXT: [[OLDDISC:%.*]] = call i64 @llvm.ptrauth.blend(i64 ptrtoint (ptr @global_aqpf to i64), i64 50) // CHECK-NEXT: [[T0:%.*]] = icmp ne ptr [[LOAD]], null // CHECK-NEXT: br i1 [[T0]], // CHECK: [[T0:%.*]] = ptrtoint ptr [[LOAD]] to i64 -// CHECK-NEXT: [[T1:%.*]] = call i64 @llvm.ptrauth.resign(i64 [[T0]]) [ "ptrauth"(i64 1, i64 [[OLDDISC]]), "ptrauth"(i64 0, i64 18983) ] +// CHECK-NEXT: [[T1:%.*]] = call i64 @llvm.ptrauth.resign(i64 [[T0]]) [ "ptrauth"(i64 1, i64 ptrtoint (ptr @global_aqpf to i64), i64 50), "ptrauth"(i64 0, i64 18983) ] // CHECK-NEXT: [[SIGNED:%.*]] = inttoptr i64 [[T1]] to ptr // CHECK-NEXT: br label // CHECK: [[T0:%.*]] = phi ptr [ null, {{.*}} ], [ [[SIGNED]], {{.*}} ] // CHECK-NEXT: store ptr [[T0]], ptr [[V]], upf = global_aqpf; // CHECK-NEXT: [[LOAD:%.*]] = load ptr, ptr @global_aqpf, -// CHECK-NEXT: [[OLDDISC:%.*]] = call i64 @llvm.ptrauth.blend(i64 ptrtoint (ptr @global_aqpf to i64), i64 50) // CHECK-NEXT: [[T0:%.*]] = icmp ne ptr [[LOAD]], null // CHECK-NEXT: br i1 [[T0]], // CHECK: [[T0:%.*]] = ptrtoint ptr [[LOAD]] to i64 -// CHECK-NEXT: [[T1:%.*]] = call i64 @llvm.ptrauth.resign(i64 [[T0]]) [ "ptrauth"(i64 1, i64 [[OLDDISC]]), "ptrauth"(i64 0, i64 18983) ] +// CHECK-NEXT: [[T1:%.*]] = call i64 @llvm.ptrauth.resign(i64 [[T0]]) [ "ptrauth"(i64 1, i64 ptrtoint (ptr @global_aqpf to i64), i64 50), "ptrauth"(i64 0, i64 18983) ] // CHECK-NEXT: [[SIGNED:%.*]] = inttoptr i64 [[T1]] to ptr // CHECK-NEXT: br label // CHECK: [[T0:%.*]] = phi ptr [ null, {{.*}} ], [ [[SIGNED]], {{.*}} ] diff --git a/clang/test/CodeGen/ptrauth-restricted-intptr-qualifier.c b/clang/test/CodeGen/ptrauth-restricted-intptr-qualifier.c index 9a5886b6c82be..ed42a9ac4eafc 100644 --- a/clang/test/CodeGen/ptrauth-restricted-intptr-qualifier.c +++ b/clang/test/CodeGen/ptrauth-restricted-intptr-qualifier.c @@ -39,11 +39,9 @@ __INTPTR_TYPE__ test_read_globals() { // CHECK: [[A:%.*]] = load i64, ptr @g1 // CHECK: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[A]]) [ "ptrauth"(i64 1, i64 56) ] // CHECK: [[B:%.*]] = load i64, ptr @g2 - // CHECK: [[BLENDED:%.*]] = call i64 @llvm.ptrauth.blend(i64 ptrtoint (ptr @g2 to i64), i64 1272) - // CHECK: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[B]]) [ "ptrauth"(i64 1, i64 [[BLENDED]]) ] + // CHECK: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[B]]) [ "ptrauth"(i64 1, i64 ptrtoint (ptr @g2 to i64), i64 1272) ] // CHECK: [[VALUE:%.*]] = load i64, ptr @g3 - // CHECK: [[BLENDED:%.*]] = call i64 @llvm.ptrauth.blend(i64 ptrtoint (ptr @g3 to i64), i64 23) - // CHECK: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VALUE]]) [ "ptrauth"(i64 3, i64 [[BLENDED]]) ] + // CHECK: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VALUE]]) [ "ptrauth"(i64 3, i64 ptrtoint (ptr @g3 to i64), i64 23) ] for (int i = 0; i < 3; i++) { result += ga[i]; @@ -57,9 +55,8 @@ __INTPTR_TYPE__ test_read_globals() { // CHECK: [[ARRAYIDX:%.*]] = getelementptr inbounds [3 x i64], ptr @ga, i64 0, i64 [[IDXPROM]] // CHECK: [[VALUE:%.*]] = load i64, ptr [[ARRAYIDX]] // CHECK: [[CASTIDX:%.*]] = ptrtoint ptr [[ARRAYIDX]] to i64 - // CHECK: [[BLENDED:%.*]] = call i64 @llvm.ptrauth.blend(i64 [[CASTIDX]], i64 712) // CHECK: resign.nonnull6: - // CHECK: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VALUE]]) [ "ptrauth"(i64 1, i64 [[BLENDED]]) ] + // CHECK: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VALUE]]) [ "ptrauth"(i64 1, i64 [[CASTIDX]], i64 712) ] // CHECK: resign.cont7 result += gs1.f0 + gs1.f1 + gs1.f2; @@ -72,13 +69,11 @@ __INTPTR_TYPE__ test_read_globals() { // CHECK: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[ADDR]]) [ "ptrauth"(i64 1, i64 783) ] result += gs2.f0 + gs2.f1 + gs2.f2; // CHECK: [[ADDR:%.*]] = load i64, ptr @gs2 - // CHECK: [[BLENDED:%.*]] = call i64 @llvm.ptrauth.blend(i64 ptrtoint (ptr @gs2 to i64), i64 1276) - // CHECK: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[ADDR]]) [ "ptrauth"(i64 1, i64 [[BLENDED]]) ] + // CHECK: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[ADDR]]) [ "ptrauth"(i64 1, i64 ptrtoint (ptr @gs2 to i64), i64 1276) ] // CHECK: [[ADDR:%.*]] = load i64, ptr getelementptr inbounds nuw (%struct.B, ptr @gs2, i32 0, i32 1) - // CHECK: [[BLENDED:%.*]] = call i64 @llvm.ptrauth.blend(i64 ptrtoint (ptr getelementptr inbounds nuw (%struct.B, ptr @gs2, i32 0, i32 1) to i64), i64 23674) - // CHECK: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[ADDR]]) [ "ptrauth"(i64 1, i64 [[BLENDED]]) ] + // CHECK: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[ADDR]]) [ "ptrauth"(i64 1, i64 ptrtoint (ptr getelementptr inbounds nuw (%struct.B, ptr @gs2, i32 0, i32 1) to i64), i64 23674) ] // CHECK: [[ADDR:%.*]] = load i64, ptr getelementptr inbounds nuw (%struct.B, ptr @gs2, i32 0, i32 2) - // CHECK: [[BLENDED:%.*]] = call i64 @llvm.ptrauth.blend(i64 ptrtoint (ptr getelementptr inbounds nuw (%struct.B, ptr @gs2, i32 0, i32 2) to i64), i64 163) + // CHECK: "ptrauth"(i64 1, i64 ptrtoint (ptr getelementptr inbounds nuw (%struct.B, ptr @gs2, i32 0, i32 2) to i64), i64 163) return result; } @@ -119,16 +114,14 @@ void test_set_B(struct B *b, __INTPTR_TYPE__ x, int y) { b->f0 = x; // CHECK: [[X:%.*]] = load i64, ptr %x.addr // CHECK: [[F0_ADDR:%.*]] = ptrtoint ptr %f0 to i64 - // CHECK: [[BLENDED:%.*]] = call i64 @llvm.ptrauth.blend(i64 [[F0_ADDR]], i64 1276) - // CHECK: [[SIGNED:%.*]] = call i64 @llvm.ptrauth.sign(i64 [[X]]) [ "ptrauth"(i64 1, i64 [[BLENDED]]) ] + // CHECK: [[SIGNED:%.*]] = call i64 @llvm.ptrauth.sign(i64 [[X]]) [ "ptrauth"(i64 1, i64 [[F0_ADDR]], i64 1276) ] b->f1 = y; // CHECK: [[B:%.*]] = load ptr, ptr %b.addr // CHECK: [[F1_ADDR:%.*]] = getelementptr inbounds nuw %struct.B, ptr [[B]], i32 0, i32 1 // CHECK: [[Y:%.*]] = load i32, ptr %y.addr, align 4 // CHECK: [[CONV:%.*]] = sext i32 [[Y]] to i64 // CHECK: [[CAST_ADDR:%.*]] = ptrtoint ptr [[F1_ADDR]] to i64 - // CHECK: [[BLENDED:%.*]] = call i64 @llvm.ptrauth.blend(i64 [[CAST_ADDR]], i64 23674) - // CHECK: [[SIGNED:%.*]] = call i64 @llvm.ptrauth.sign(i64 [[CONV]]) [ "ptrauth"(i64 1, i64 [[BLENDED]]) ] + // CHECK: [[SIGNED:%.*]] = call i64 @llvm.ptrauth.sign(i64 [[CONV]]) [ "ptrauth"(i64 1, i64 [[CAST_ADDR]], i64 23674) ] b->f2 = 0; // CHECK: [[B:%.*]] = load ptr, ptr %b.addr // CHECK: [[F2_ADDR:%.*]] = getelementptr inbounds nuw %struct.B, ptr [[B]], i32 0, i32 2 @@ -159,20 +152,17 @@ __INTPTR_TYPE__ test_get_B(struct B *b) { // CHECK: [[F0:%.*]] = getelementptr inbounds nuw %struct.B, ptr [[B]], i32 0, i32 0 // CHECK: [[VALUE:%.*]] = load i64, ptr [[F0]] // CHECK: [[CASTF0:%.*]] = ptrtoint ptr %f0 to i64 - // CHECK: [[BLENDED:%.*]] = call i64 @llvm.ptrauth.blend(i64 [[CASTF0]], i64 1276) - // CHECK: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VALUE]]) [ "ptrauth"(i64 1, i64 [[BLENDED]]) ] + // CHECK: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VALUE]]) [ "ptrauth"(i64 1, i64 [[CASTF0]], i64 1276) ] // CHECK: [[B:%.*]] = load ptr, ptr %b.addr // CHECK: [[ADDR:%.*]] = getelementptr inbounds nuw %struct.B, ptr [[B]], i32 0, i32 1 // CHECK: [[VALUE:%.*]] = load i64, ptr [[ADDR]] // CHECK: [[CAST_ADDR:%.*]] = ptrtoint ptr [[ADDR]] to i64 - // CHECK: [[BLENDED:%.*]] = call i64 @llvm.ptrauth.blend(i64 [[CAST_ADDR]], i64 23674) - // CHECK: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VALUE]]) [ "ptrauth"(i64 1, i64 [[BLENDED]]) ] + // CHECK: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VALUE]]) [ "ptrauth"(i64 1, i64 [[CAST_ADDR]], i64 23674) ] // CHECK: [[B:%.*]] = load ptr, ptr %b.addr // CHECK: [[ADDR:%.*]] = getelementptr inbounds nuw %struct.B, ptr [[B]], i32 0, i32 2 // CHECK: [[VALUE:%.*]] = load i64, ptr [[ADDR]] // CHECK: [[CAST_ADDR:%.*]] = ptrtoint ptr [[ADDR]] to i64 - // CHECK: [[BLENDED:%.*]] = call i64 @llvm.ptrauth.blend(i64 [[CAST_ADDR]], i64 163) - // CHECK: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VALUE]]) [ "ptrauth"(i64 1, i64 [[BLENDED]]) ] + // CHECK: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VALUE]]) [ "ptrauth"(i64 1, i64 [[CAST_ADDR]], i64 163) ] } // CHECK-LABEL: define void @test_resign @@ -184,8 +174,7 @@ void test_resign(struct A* a, const struct B *b) { // CHECK: [[F01:%.*]] = getelementptr inbounds nuw %struct.B, ptr [[B]], i32 0, i32 0 // CHECK: [[F01VALUE:%.*]] = load i64, ptr [[F01]] // CHECK: [[CASTF01:%.*]] = ptrtoint ptr %f01 to i64 - // CHECK: [[BLENDED:%.*]] = call i64 @llvm.ptrauth.blend(i64 [[CASTF01]], i64 1276) - // CHECK: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.resign(i64 [[F01VALUE]]) [ "ptrauth"(i64 1, i64 [[BLENDED]]), "ptrauth"(i64 1, i64 431) ] + // CHECK: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.resign(i64 [[F01VALUE]]) [ "ptrauth"(i64 1, i64 [[CASTF01]], i64 1276), "ptrauth"(i64 1, i64 431) ] } // CHECK-LABEL: define i64 @other_test @@ -195,25 +184,20 @@ __INTPTR_TYPE__ other_test(__INTPTR_TYPE__ i) { // CHECK: store i64 0, ptr %j __INTPTR_TYPE__ __ptrauth(1, 1, 43) k = 1234; // CHECK: [[ADDR:%.*]] = ptrtoint ptr %k to i64 - // CHECK: [[JBLENDED:%.*]] = call i64 @llvm.ptrauth.blend(i64 [[ADDR]], i64 43) - // CHECK: [[SIGNED:%.*]] = call i64 @llvm.ptrauth.sign(i64 1234) [ "ptrauth"(i64 1, i64 [[JBLENDED]]) ] + // CHECK: [[SIGNED:%.*]] = call i64 @llvm.ptrauth.sign(i64 1234) [ "ptrauth"(i64 1, i64 [[ADDR]], i64 43) ] __INTPTR_TYPE__ __ptrauth(1, 1, 44) l = i; // CHECK: [[I:%.*]] = load i64, ptr %i.addr // CHECK: [[ADDR:%.*]] = ptrtoint ptr %l to i64 - // CHECK: [[LBLENDED:%.*]] = call i64 @llvm.ptrauth.blend(i64 [[ADDR]], i64 44) - // CHECK: [[SIGNED:%.*]] = call i64 @llvm.ptrauth.sign(i64 [[I]]) [ "ptrauth"(i64 1, i64 [[LBLENDED]]) ] + // CHECK: [[SIGNED:%.*]] = call i64 @llvm.ptrauth.sign(i64 [[I]]) [ "ptrauth"(i64 1, i64 [[ADDR]], i64 44) ] asm volatile ("" ::: "memory"); return j + k + l; // CHECK: [[VALUE:%.*]] = load i64, ptr %j // CHECK: [[CAST_ADDR:%.*]] = ptrtoint ptr %j to i64 - // CHECK: [[BLENDED:%.*]] = call i64 @llvm.ptrauth.blend(i64 [[CAST_ADDR]], i64 42) - // CHECK: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VALUE]]) [ "ptrauth"(i64 1, i64 [[BLENDED]]) ] + // CHECK: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VALUE]]) [ "ptrauth"(i64 1, i64 [[CAST_ADDR]], i64 42) ] // CHECK: [[VALUE:%.*]] = load i64, ptr %k // CHECK: [[CASTK:%.*]] = ptrtoint ptr %k to i64 - // CHECK: [[BLENDED:%.*]] = call i64 @llvm.ptrauth.blend(i64 [[CASTK]], i64 43) - // CHECK: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VALUE]]) [ "ptrauth"(i64 1, i64 [[BLENDED]]) ] + // CHECK: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VALUE]]) [ "ptrauth"(i64 1, i64 [[CASTK]], i64 43) ] // CHECK: [[VALUE:%.*]] = load i64, ptr %l // CHECK: [[CASTL:%.*]] = ptrtoint ptr %l to i64 - // CHECK: [[BLENDED:%.*]] = call i64 @llvm.ptrauth.blend(i64 [[CASTL]], i64 44) - // CHECK: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VALUE]]) [ "ptrauth"(i64 1, i64 [[BLENDED]]) ] + // CHECK: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VALUE]]) [ "ptrauth"(i64 1, i64 [[CASTL]], i64 44) ] } diff --git a/clang/test/CodeGenCXX/builtin-get-vtable-pointer.cpp b/clang/test/CodeGenCXX/builtin-get-vtable-pointer.cpp index c7a7340d95cbf..84ee63ea61ebb 100644 --- a/clang/test/CodeGenCXX/builtin-get-vtable-pointer.cpp +++ b/clang/test/CodeGenCXX/builtin-get-vtable-pointer.cpp @@ -80,9 +80,8 @@ template struct same_type { // CHECK-BOTHAUTH-NEXT: [[TMP0:%.*]] = load ptr, ptr [[O_ADDR]], align 8, !tbaa [[TBAA6]] // CHECK-BOTHAUTH-NEXT: [[VTABLE:%.*]] = load ptr, ptr [[TMP0]], align 8, !tbaa [[TBAA9:![0-9]+]] // CHECK-BOTHAUTH-NEXT: [[TMP1:%.*]] = ptrtoint ptr [[TMP0]] to i64 -// CHECK-BOTHAUTH-NEXT: [[TMP2:%.*]] = call i64 @llvm.ptrauth.blend(i64 [[TMP1]], i64 48388) // CHECK-BOTHAUTH-NEXT: [[TMP3:%.*]] = ptrtoint ptr [[VTABLE]] to i64 -// CHECK-BOTHAUTH-NEXT: [[TMP4:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[TMP3]]) [ "ptrauth"(i64 2, i64 [[TMP2]]) ] +// CHECK-BOTHAUTH-NEXT: [[TMP4:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[TMP3]]) [ "ptrauth"(i64 2, i64 [[TMP1]], i64 48388) ] // CHECK-BOTHAUTH-NEXT: [[TMP5:%.*]] = inttoptr i64 [[TMP4]] to ptr // CHECK-BOTHAUTH-NEXT: [[TMP6:%.*]] = load volatile i8, ptr [[TMP5]], align 8 // CHECK-BOTHAUTH-NEXT: ret ptr [[TMP5]] @@ -136,9 +135,8 @@ const void *a(A *o) { // CHECK-BOTHAUTH-NEXT: [[TMP0:%.*]] = load ptr, ptr [[O_ADDR]], align 8, !tbaa [[TBAA11]] // CHECK-BOTHAUTH-NEXT: [[VTABLE:%.*]] = load ptr, ptr [[TMP0]], align 8, !tbaa [[TBAA9]] // CHECK-BOTHAUTH-NEXT: [[TMP1:%.*]] = ptrtoint ptr [[TMP0]] to i64 -// CHECK-BOTHAUTH-NEXT: [[TMP2:%.*]] = call i64 @llvm.ptrauth.blend(i64 [[TMP1]], i64 48388) // CHECK-BOTHAUTH-NEXT: [[TMP3:%.*]] = ptrtoint ptr [[VTABLE]] to i64 -// CHECK-BOTHAUTH-NEXT: [[TMP4:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[TMP3]]) [ "ptrauth"(i64 2, i64 [[TMP2]]) ] +// CHECK-BOTHAUTH-NEXT: [[TMP4:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[TMP3]]) [ "ptrauth"(i64 2, i64 [[TMP1]], i64 48388) ] // CHECK-BOTHAUTH-NEXT: [[TMP5:%.*]] = inttoptr i64 [[TMP4]] to ptr // CHECK-BOTHAUTH-NEXT: [[TMP6:%.*]] = load volatile i8, ptr [[TMP5]], align 8 // CHECK-BOTHAUTH-NEXT: ret ptr [[TMP5]] @@ -192,9 +190,8 @@ const void *b(B *o) { // CHECK-BOTHAUTH-NEXT: [[TMP0:%.*]] = load ptr, ptr [[O_ADDR]], align 8, !tbaa [[TBAA11]] // CHECK-BOTHAUTH-NEXT: [[VTABLE:%.*]] = load ptr, ptr [[TMP0]], align 8, !tbaa [[TBAA9]] // CHECK-BOTHAUTH-NEXT: [[TMP1:%.*]] = ptrtoint ptr [[TMP0]] to i64 -// CHECK-BOTHAUTH-NEXT: [[TMP2:%.*]] = call i64 @llvm.ptrauth.blend(i64 [[TMP1]], i64 48388) // CHECK-BOTHAUTH-NEXT: [[TMP3:%.*]] = ptrtoint ptr [[VTABLE]] to i64 -// CHECK-BOTHAUTH-NEXT: [[TMP4:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[TMP3]]) [ "ptrauth"(i64 2, i64 [[TMP2]]) ] +// CHECK-BOTHAUTH-NEXT: [[TMP4:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[TMP3]]) [ "ptrauth"(i64 2, i64 [[TMP1]], i64 48388) ] // CHECK-BOTHAUTH-NEXT: [[TMP5:%.*]] = inttoptr i64 [[TMP4]] to ptr // CHECK-BOTHAUTH-NEXT: [[TMP6:%.*]] = load volatile i8, ptr [[TMP5]], align 8 // CHECK-BOTHAUTH-NEXT: ret ptr [[TMP5]] @@ -248,9 +245,8 @@ const void *b_as_A(B *o) { // CHECK-BOTHAUTH-NEXT: [[TMP0:%.*]] = load ptr, ptr [[O_ADDR]], align 8, !tbaa [[TBAA13]] // CHECK-BOTHAUTH-NEXT: [[VTABLE:%.*]] = load ptr, ptr [[TMP0]], align 8, !tbaa [[TBAA9]] // CHECK-BOTHAUTH-NEXT: [[TMP1:%.*]] = ptrtoint ptr [[TMP0]] to i64 -// CHECK-BOTHAUTH-NEXT: [[TMP2:%.*]] = call i64 @llvm.ptrauth.blend(i64 [[TMP1]], i64 48388) // CHECK-BOTHAUTH-NEXT: [[TMP3:%.*]] = ptrtoint ptr [[VTABLE]] to i64 -// CHECK-BOTHAUTH-NEXT: [[TMP4:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[TMP3]]) [ "ptrauth"(i64 2, i64 [[TMP2]]) ] +// CHECK-BOTHAUTH-NEXT: [[TMP4:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[TMP3]]) [ "ptrauth"(i64 2, i64 [[TMP1]], i64 48388) ] // CHECK-BOTHAUTH-NEXT: [[TMP5:%.*]] = inttoptr i64 [[TMP4]] to ptr // CHECK-BOTHAUTH-NEXT: [[TMP6:%.*]] = load volatile i8, ptr [[TMP5]], align 8 // CHECK-BOTHAUTH-NEXT: ret ptr [[TMP5]] @@ -304,9 +300,8 @@ const void *c(C *o) { // CHECK-BOTHAUTH-NEXT: [[TMP0:%.*]] = load ptr, ptr [[O_ADDR]], align 8, !tbaa [[TBAA13]] // CHECK-BOTHAUTH-NEXT: [[VTABLE:%.*]] = load ptr, ptr [[TMP0]], align 8, !tbaa [[TBAA9]] // CHECK-BOTHAUTH-NEXT: [[TMP1:%.*]] = ptrtoint ptr [[TMP0]] to i64 -// CHECK-BOTHAUTH-NEXT: [[TMP2:%.*]] = call i64 @llvm.ptrauth.blend(i64 [[TMP1]], i64 48388) // CHECK-BOTHAUTH-NEXT: [[TMP3:%.*]] = ptrtoint ptr [[VTABLE]] to i64 -// CHECK-BOTHAUTH-NEXT: [[TMP4:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[TMP3]]) [ "ptrauth"(i64 2, i64 [[TMP2]]) ] +// CHECK-BOTHAUTH-NEXT: [[TMP4:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[TMP3]]) [ "ptrauth"(i64 2, i64 [[TMP1]], i64 48388) ] // CHECK-BOTHAUTH-NEXT: [[TMP5:%.*]] = inttoptr i64 [[TMP4]] to ptr // CHECK-BOTHAUTH-NEXT: [[TMP6:%.*]] = load volatile i8, ptr [[TMP5]], align 8 // CHECK-BOTHAUTH-NEXT: ret ptr [[TMP5]] @@ -388,9 +383,8 @@ const void *c_as_Z(C *o) { // CHECK-BOTHAUTH-NEXT: [[CAST_RESULT:%.*]] = phi ptr [ [[ADD_PTR]], %[[CAST_NOTNULL]] ], [ null, %[[ENTRY]] ] // CHECK-BOTHAUTH-NEXT: [[VTABLE:%.*]] = load ptr, ptr [[CAST_RESULT]], align 8, !tbaa [[TBAA9]] // CHECK-BOTHAUTH-NEXT: [[TMP2:%.*]] = ptrtoint ptr [[CAST_RESULT]] to i64 -// CHECK-BOTHAUTH-NEXT: [[TMP3:%.*]] = call i64 @llvm.ptrauth.blend(i64 [[TMP2]], i64 48388) // CHECK-BOTHAUTH-NEXT: [[TMP4:%.*]] = ptrtoint ptr [[VTABLE]] to i64 -// CHECK-BOTHAUTH-NEXT: [[TMP5:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[TMP4]]) [ "ptrauth"(i64 2, i64 [[TMP3]]) ] +// CHECK-BOTHAUTH-NEXT: [[TMP5:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[TMP4]]) [ "ptrauth"(i64 2, i64 [[TMP2]], i64 48388) ] // CHECK-BOTHAUTH-NEXT: [[TMP6:%.*]] = inttoptr i64 [[TMP5]] to ptr // CHECK-BOTHAUTH-NEXT: [[TMP7:%.*]] = load volatile i8, ptr [[TMP6]], align 8 // CHECK-BOTHAUTH-NEXT: ret ptr [[TMP6]] @@ -444,9 +438,8 @@ const void *c_as_B(C *o) { // CHECK-BOTHAUTH-NEXT: [[TMP0:%.*]] = load ptr, ptr [[O_ADDR]], align 8, !tbaa [[TBAA15]] // CHECK-BOTHAUTH-NEXT: [[VTABLE:%.*]] = load ptr, ptr [[TMP0]], align 8, !tbaa [[TBAA9]] // CHECK-BOTHAUTH-NEXT: [[TMP1:%.*]] = ptrtoint ptr [[TMP0]] to i64 -// CHECK-BOTHAUTH-NEXT: [[TMP2:%.*]] = call i64 @llvm.ptrauth.blend(i64 [[TMP1]], i64 48388) // CHECK-BOTHAUTH-NEXT: [[TMP3:%.*]] = ptrtoint ptr [[VTABLE]] to i64 -// CHECK-BOTHAUTH-NEXT: [[TMP4:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[TMP3]]) [ "ptrauth"(i64 2, i64 [[TMP2]]) ] +// CHECK-BOTHAUTH-NEXT: [[TMP4:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[TMP3]]) [ "ptrauth"(i64 2, i64 [[TMP1]], i64 48388) ] // CHECK-BOTHAUTH-NEXT: [[TMP5:%.*]] = inttoptr i64 [[TMP4]] to ptr // CHECK-BOTHAUTH-NEXT: [[TMP6:%.*]] = load volatile i8, ptr [[TMP5]], align 8 // CHECK-BOTHAUTH-NEXT: ret ptr [[TMP5]] @@ -540,9 +533,8 @@ const void *d(D *o) { // CHECK-BOTHAUTH: [[CAST_NOTNULL]]: // CHECK-BOTHAUTH-NEXT: [[VTABLE:%.*]] = load ptr, ptr [[TMP0]], align 8, !tbaa [[TBAA9]] // CHECK-BOTHAUTH-NEXT: [[TMP2:%.*]] = ptrtoint ptr [[TMP0]] to i64 -// CHECK-BOTHAUTH-NEXT: [[TMP3:%.*]] = call i64 @llvm.ptrauth.blend(i64 [[TMP2]], i64 48388) // CHECK-BOTHAUTH-NEXT: [[TMP4:%.*]] = ptrtoint ptr [[VTABLE]] to i64 -// CHECK-BOTHAUTH-NEXT: [[TMP5:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[TMP4]]) [ "ptrauth"(i64 2, i64 [[TMP3]]) ] +// CHECK-BOTHAUTH-NEXT: [[TMP5:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[TMP4]]) [ "ptrauth"(i64 2, i64 [[TMP2]], i64 48388) ] // CHECK-BOTHAUTH-NEXT: [[TMP6:%.*]] = inttoptr i64 [[TMP5]] to ptr // CHECK-BOTHAUTH-NEXT: [[VBASE_OFFSET_PTR:%.*]] = getelementptr i8, ptr [[TMP6]], i64 -32 // CHECK-BOTHAUTH-NEXT: [[VBASE_OFFSET:%.*]] = load i64, ptr [[VBASE_OFFSET_PTR]], align 8 @@ -552,9 +544,8 @@ const void *d(D *o) { // CHECK-BOTHAUTH-NEXT: [[CAST_RESULT:%.*]] = phi ptr [ [[ADD_PTR]], %[[CAST_NOTNULL]] ], [ null, %[[ENTRY]] ] // CHECK-BOTHAUTH-NEXT: [[VTABLE1:%.*]] = load ptr, ptr [[CAST_RESULT]], align 8, !tbaa [[TBAA9]] // CHECK-BOTHAUTH-NEXT: [[TMP7:%.*]] = ptrtoint ptr [[CAST_RESULT]] to i64 -// CHECK-BOTHAUTH-NEXT: [[TMP8:%.*]] = call i64 @llvm.ptrauth.blend(i64 [[TMP7]], i64 48388) // CHECK-BOTHAUTH-NEXT: [[TMP9:%.*]] = ptrtoint ptr [[VTABLE1]] to i64 -// CHECK-BOTHAUTH-NEXT: [[TMP10:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[TMP9]]) [ "ptrauth"(i64 2, i64 [[TMP8]]) ] +// CHECK-BOTHAUTH-NEXT: [[TMP10:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[TMP9]]) [ "ptrauth"(i64 2, i64 [[TMP7]], i64 48388) ] // CHECK-BOTHAUTH-NEXT: [[TMP11:%.*]] = inttoptr i64 [[TMP10]] to ptr // CHECK-BOTHAUTH-NEXT: [[TMP12:%.*]] = load volatile i8, ptr [[TMP11]], align 8 // CHECK-BOTHAUTH-NEXT: ret ptr [[TMP11]] @@ -608,9 +599,8 @@ const void *d_as_A(D *o) { // CHECK-BOTHAUTH-NEXT: [[TMP0:%.*]] = load ptr, ptr [[O_ADDR]], align 8, !tbaa [[TBAA17]] // CHECK-BOTHAUTH-NEXT: [[VTABLE:%.*]] = load ptr, ptr [[TMP0]], align 8, !tbaa [[TBAA9]] // CHECK-BOTHAUTH-NEXT: [[TMP1:%.*]] = ptrtoint ptr [[TMP0]] to i64 -// CHECK-BOTHAUTH-NEXT: [[TMP2:%.*]] = call i64 @llvm.ptrauth.blend(i64 [[TMP1]], i64 48388) // CHECK-BOTHAUTH-NEXT: [[TMP3:%.*]] = ptrtoint ptr [[VTABLE]] to i64 -// CHECK-BOTHAUTH-NEXT: [[TMP4:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[TMP3]]) [ "ptrauth"(i64 2, i64 [[TMP2]]) ] +// CHECK-BOTHAUTH-NEXT: [[TMP4:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[TMP3]]) [ "ptrauth"(i64 2, i64 [[TMP1]], i64 48388) ] // CHECK-BOTHAUTH-NEXT: [[TMP5:%.*]] = inttoptr i64 [[TMP4]] to ptr // CHECK-BOTHAUTH-NEXT: [[TMP6:%.*]] = load volatile i8, ptr [[TMP5]], align 8 // CHECK-BOTHAUTH-NEXT: ret ptr [[TMP5]] @@ -692,9 +682,8 @@ const void *e(E *o) { // CHECK-BOTHAUTH-NEXT: [[CAST_RESULT:%.*]] = phi ptr [ [[ADD_PTR]], %[[CAST_NOTNULL]] ], [ null, %[[ENTRY]] ] // CHECK-BOTHAUTH-NEXT: [[VTABLE:%.*]] = load ptr, ptr [[CAST_RESULT]], align 8, !tbaa [[TBAA9]] // CHECK-BOTHAUTH-NEXT: [[TMP2:%.*]] = ptrtoint ptr [[CAST_RESULT]] to i64 -// CHECK-BOTHAUTH-NEXT: [[TMP3:%.*]] = call i64 @llvm.ptrauth.blend(i64 [[TMP2]], i64 48388) // CHECK-BOTHAUTH-NEXT: [[TMP4:%.*]] = ptrtoint ptr [[VTABLE]] to i64 -// CHECK-BOTHAUTH-NEXT: [[TMP5:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[TMP4]]) [ "ptrauth"(i64 2, i64 [[TMP3]]) ] +// CHECK-BOTHAUTH-NEXT: [[TMP5:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[TMP4]]) [ "ptrauth"(i64 2, i64 [[TMP2]], i64 48388) ] // CHECK-BOTHAUTH-NEXT: [[TMP6:%.*]] = inttoptr i64 [[TMP5]] to ptr // CHECK-BOTHAUTH-NEXT: [[TMP7:%.*]] = load volatile i8, ptr [[TMP6]], align 8 // CHECK-BOTHAUTH-NEXT: ret ptr [[TMP6]] @@ -748,9 +737,8 @@ const void *e_as_B(E *o) { // CHECK-BOTHAUTH-NEXT: [[TMP0:%.*]] = load ptr, ptr [[O_ADDR]], align 8, !tbaa [[TBAA17]] // CHECK-BOTHAUTH-NEXT: [[VTABLE:%.*]] = load ptr, ptr [[TMP0]], align 8, !tbaa [[TBAA9]] // CHECK-BOTHAUTH-NEXT: [[TMP1:%.*]] = ptrtoint ptr [[TMP0]] to i64 -// CHECK-BOTHAUTH-NEXT: [[TMP2:%.*]] = call i64 @llvm.ptrauth.blend(i64 [[TMP1]], i64 48388) // CHECK-BOTHAUTH-NEXT: [[TMP3:%.*]] = ptrtoint ptr [[VTABLE]] to i64 -// CHECK-BOTHAUTH-NEXT: [[TMP4:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[TMP3]]) [ "ptrauth"(i64 2, i64 [[TMP2]]) ] +// CHECK-BOTHAUTH-NEXT: [[TMP4:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[TMP3]]) [ "ptrauth"(i64 2, i64 [[TMP1]], i64 48388) ] // CHECK-BOTHAUTH-NEXT: [[TMP5:%.*]] = inttoptr i64 [[TMP4]] to ptr // CHECK-BOTHAUTH-NEXT: [[TMP6:%.*]] = load volatile i8, ptr [[TMP5]], align 8 // CHECK-BOTHAUTH-NEXT: ret ptr [[TMP5]] @@ -804,9 +792,8 @@ const void *e_as_D(E *o) { // CHECK-BOTHAUTH-NEXT: [[TMP0:%.*]] = load ptr, ptr [[AARRAY_ADDR]], align 8, !tbaa [[TBAA6]] // CHECK-BOTHAUTH-NEXT: [[VTABLE:%.*]] = load ptr, ptr [[TMP0]], align 8, !tbaa [[TBAA9]] // CHECK-BOTHAUTH-NEXT: [[TMP1:%.*]] = ptrtoint ptr [[TMP0]] to i64 -// CHECK-BOTHAUTH-NEXT: [[TMP2:%.*]] = call i64 @llvm.ptrauth.blend(i64 [[TMP1]], i64 48388) // CHECK-BOTHAUTH-NEXT: [[TMP3:%.*]] = ptrtoint ptr [[VTABLE]] to i64 -// CHECK-BOTHAUTH-NEXT: [[TMP4:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[TMP3]]) [ "ptrauth"(i64 2, i64 [[TMP2]]) ] +// CHECK-BOTHAUTH-NEXT: [[TMP4:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[TMP3]]) [ "ptrauth"(i64 2, i64 [[TMP1]], i64 48388) ] // CHECK-BOTHAUTH-NEXT: [[TMP5:%.*]] = inttoptr i64 [[TMP4]] to ptr // CHECK-BOTHAUTH-NEXT: [[TMP6:%.*]] = load volatile i8, ptr [[TMP5]], align 8 // CHECK-BOTHAUTH-NEXT: ret ptr [[TMP5]] @@ -867,9 +854,8 @@ extern "C" const void *aArrayParameter(A aArray[]) { // CHECK-BOTHAUTH-NEXT: [[ARRAYDECAY:%.*]] = getelementptr inbounds [1 x %"struct.test1::A"], ptr [[ARRAY]], i64 0, i64 0 // CHECK-BOTHAUTH-NEXT: [[VTABLE:%.*]] = load ptr, ptr [[ARRAYDECAY]], align 8, !tbaa [[TBAA9]] // CHECK-BOTHAUTH-NEXT: [[TMP0:%.*]] = ptrtoint ptr [[ARRAYDECAY]] to i64 -// CHECK-BOTHAUTH-NEXT: [[TMP1:%.*]] = call i64 @llvm.ptrauth.blend(i64 [[TMP0]], i64 48388) // CHECK-BOTHAUTH-NEXT: [[TMP2:%.*]] = ptrtoint ptr [[VTABLE]] to i64 -// CHECK-BOTHAUTH-NEXT: [[TMP3:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[TMP2]]) [ "ptrauth"(i64 2, i64 [[TMP1]]) ] +// CHECK-BOTHAUTH-NEXT: [[TMP3:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[TMP2]]) [ "ptrauth"(i64 2, i64 [[TMP0]], i64 48388) ] // CHECK-BOTHAUTH-NEXT: [[TMP4:%.*]] = inttoptr i64 [[TMP3]] to ptr // CHECK-BOTHAUTH-NEXT: [[TMP5:%.*]] = load volatile i8, ptr [[TMP4]], align 8 // CHECK-BOTHAUTH-NEXT: call void @llvm.lifetime.end.p0(ptr [[ARRAY]]) #[[ATTR7]] @@ -1241,9 +1227,8 @@ extern "C" const void *aArrayLocal() { // CHECK-BOTHAUTH: [[CAST_NOTNULL9]]: // CHECK-BOTHAUTH-NEXT: [[VTABLE:%.*]] = load ptr, ptr [[DINSTANCE]], align 8, !tbaa [[TBAA9]] // CHECK-BOTHAUTH-NEXT: [[TMP2:%.*]] = ptrtoint ptr [[DINSTANCE]] to i64 -// CHECK-BOTHAUTH-NEXT: [[TMP3:%.*]] = call i64 @llvm.ptrauth.blend(i64 [[TMP2]], i64 48388) // CHECK-BOTHAUTH-NEXT: [[TMP4:%.*]] = ptrtoint ptr [[VTABLE]] to i64 -// CHECK-BOTHAUTH-NEXT: [[TMP5:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[TMP4]]) [ "ptrauth"(i64 2, i64 [[TMP3]]) ] +// CHECK-BOTHAUTH-NEXT: [[TMP5:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[TMP4]]) [ "ptrauth"(i64 2, i64 [[TMP2]], i64 48388) ] // CHECK-BOTHAUTH-NEXT: [[TMP6:%.*]] = inttoptr i64 [[TMP5]] to ptr // CHECK-BOTHAUTH-NEXT: [[VBASE_OFFSET_PTR:%.*]] = getelementptr i8, ptr [[TMP6]], i64 -32 // CHECK-BOTHAUTH-NEXT: [[VBASE_OFFSET:%.*]] = load i64, ptr [[VBASE_OFFSET_PTR]], align 8 @@ -1257,9 +1242,8 @@ extern "C" const void *aArrayLocal() { // CHECK-BOTHAUTH: [[CAST_NOTNULL14]]: // CHECK-BOTHAUTH-NEXT: [[VTABLE15:%.*]] = load ptr, ptr [[EINSTANCE]], align 8, !tbaa [[TBAA9]] // CHECK-BOTHAUTH-NEXT: [[TMP8:%.*]] = ptrtoint ptr [[EINSTANCE]] to i64 -// CHECK-BOTHAUTH-NEXT: [[TMP9:%.*]] = call i64 @llvm.ptrauth.blend(i64 [[TMP8]], i64 48388) // CHECK-BOTHAUTH-NEXT: [[TMP10:%.*]] = ptrtoint ptr [[VTABLE15]] to i64 -// CHECK-BOTHAUTH-NEXT: [[TMP11:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[TMP10]]) [ "ptrauth"(i64 2, i64 [[TMP9]]) ] +// CHECK-BOTHAUTH-NEXT: [[TMP11:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[TMP10]]) [ "ptrauth"(i64 2, i64 [[TMP8]], i64 48388) ] // CHECK-BOTHAUTH-NEXT: [[TMP12:%.*]] = inttoptr i64 [[TMP11]] to ptr // CHECK-BOTHAUTH-NEXT: [[VBASE_OFFSET_PTR16:%.*]] = getelementptr i8, ptr [[TMP12]], i64 -32 // CHECK-BOTHAUTH-NEXT: [[VBASE_OFFSET17:%.*]] = load i64, ptr [[VBASE_OFFSET_PTR16]], align 8 @@ -1307,9 +1291,8 @@ extern "C" const void *aArrayLocal() { // CHECK-BOTHAUTH-NEXT: [[ARRAYDECAY:%.*]] = getelementptr inbounds [1 x %"struct.test1::E"], ptr [[EARRAY]], i64 0, i64 0 // CHECK-BOTHAUTH-NEXT: [[VTABLE49:%.*]] = load ptr, ptr [[ARRAYDECAY]], align 8, !tbaa [[TBAA9]] // CHECK-BOTHAUTH-NEXT: [[TMP16:%.*]] = ptrtoint ptr [[ARRAYDECAY]] to i64 -// CHECK-BOTHAUTH-NEXT: [[TMP17:%.*]] = call i64 @llvm.ptrauth.blend(i64 [[TMP16]], i64 48388) // CHECK-BOTHAUTH-NEXT: [[TMP18:%.*]] = ptrtoint ptr [[VTABLE49]] to i64 -// CHECK-BOTHAUTH-NEXT: [[TMP19:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[TMP18]]) [ "ptrauth"(i64 2, i64 [[TMP17]]) ] +// CHECK-BOTHAUTH-NEXT: [[TMP19:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[TMP18]]) [ "ptrauth"(i64 2, i64 [[TMP16]], i64 48388) ] // CHECK-BOTHAUTH-NEXT: [[TMP20:%.*]] = inttoptr i64 [[TMP19]] to ptr // CHECK-BOTHAUTH-NEXT: [[TMP21:%.*]] = load volatile i8, ptr [[TMP20]], align 8 // CHECK-BOTHAUTH-NEXT: call void @llvm.lifetime.end.p0(ptr [[EARRAY]]) #[[ATTR7]] diff --git a/clang/test/CodeGenCXX/ptrauth-apple-kext-indirect-call-2.cpp b/clang/test/CodeGenCXX/ptrauth-apple-kext-indirect-call-2.cpp index fd6f543ffe18b..c80c6d09b658f 100644 --- a/clang/test/CodeGenCXX/ptrauth-apple-kext-indirect-call-2.cpp +++ b/clang/test/CodeGenCXX/ptrauth-apple-kext-indirect-call-2.cpp @@ -19,8 +19,7 @@ void B::VF() {} void FUNC(B* p) { // CHECK: [[T1:%.*]] = load ptr, ptr getelementptr inbounds (ptr, ptr @_ZTV1A, i64 2) -// CHECK-NEXT: [[BT1:%.*]] = call i64 @llvm.ptrauth.blend(i64 ptrtoint (ptr getelementptr inbounds (ptr, ptr @_ZTV1A, i64 2) to i64), i64 12401) -// CHECK-NEXT: [[T2:%.*]] = call noundef ptr [[T1]](ptr noundef {{.*}}) [ "ptrauth"(i32 0, i64 [[BT1]]) ] +// CHECK-NEXT: [[T2:%.*]] = call noundef ptr [[T1]](ptr noundef {{.*}}) [ "ptrauth"(i64 0, i64 ptrtoint (ptr getelementptr inbounds (ptr, ptr @_ZTV1A, i64 2) to i64), i64 12401) ] const char* c = p->A::abc(); } @@ -35,8 +34,7 @@ struct Derived : public Base { void FUNC1(Derived* p) { // CHECK: [[U1:%.*]] = load ptr, ptr getelementptr inbounds (ptr, ptr @_ZTV4Base, i64 2) -// CHECK-NEXT: [[BU1:%.*]] = call i64 @llvm.ptrauth.blend(i64 ptrtoint (ptr getelementptr inbounds (ptr, ptr @_ZTV4Base, i64 2) to i64), i64 64320) -// CHECK-NEXT: [[U2:%.*]] = call noundef ptr [[U1]](ptr noundef {{.*}}) [ "ptrauth"(i32 0, i64 [[BU1]]) ] +// CHECK-NEXT: [[U2:%.*]] = call noundef ptr [[U1]](ptr noundef {{.*}}) [ "ptrauth"(i64 0, i64 ptrtoint (ptr getelementptr inbounds (ptr, ptr @_ZTV4Base, i64 2) to i64), i64 64320) ] char* c = p->Base::abc(); } @@ -52,8 +50,7 @@ char* Derived2::efg(void) const { return 0; } void FUNC2(Derived2* p) { // CHECK: [[V1:%.*]] = load ptr, ptr getelementptr inbounds (ptr, ptr @_ZTV8Derived2, i64 3) -// CHECK-NEXT: [[BV1:%.*]] = call i64 @llvm.ptrauth.blend(i64 ptrtoint (ptr getelementptr inbounds (ptr, ptr @_ZTV8Derived2, i64 3) to i64), i64 36603) -// CHECK-NEXT: [[V2:%.*]] = call noundef ptr [[V1]](ptr noundef {{.*}}) [ "ptrauth"(i32 0, i64 [[BV1]]) ] +// CHECK-NEXT: [[V2:%.*]] = call noundef ptr [[V1]](ptr noundef {{.*}}) [ "ptrauth"(i64 0, i64 ptrtoint (ptr getelementptr inbounds (ptr, ptr @_ZTV8Derived2, i64 3) to i64), i64 36603) ] char* c = p->Derived2::efg(); } @@ -74,8 +71,7 @@ char* D2::abc(void) const { return 0; } void FUNC3(Sub* p) { // CHECK: [[W1:%.*]] = load ptr, ptr getelementptr inbounds (ptr, ptr @_ZTV2D2, i64 3) -// CHECK-NEXT: [[BW1:%.*]] = call i64 @llvm.ptrauth.blend(i64 ptrtoint (ptr getelementptr inbounds (ptr, ptr @_ZTV2D2, i64 3) to i64), i64 20222) -// CHECK-NEXT: [[W2:%.*]] = call noundef ptr [[W1]](ptr noundef {{.*}}) [ "ptrauth"(i32 0, i64 [[BW1]]) ] +// CHECK-NEXT: [[W2:%.*]] = call noundef ptr [[W1]](ptr noundef {{.*}}) [ "ptrauth"(i64 0, i64 ptrtoint (ptr getelementptr inbounds (ptr, ptr @_ZTV2D2, i64 3) to i64), i64 20222) ] char* c = p->D2::abc(); } @@ -99,7 +95,6 @@ void FUNC4(Derived4* p) { // CHECK: %[[VFN:[a-z]+]] = getelementptr inbounds ptr, ptr %[[T4]], i64 0 // CHECK: %[[T5:[0-9]+]] = load ptr, ptr %[[VFN]] // CHECK: %[[T6:[0-9]+]] = ptrtoint ptr %[[VFN]] to i64 -// CHECK: %[[T7:[0-9]+]] = call i64 @llvm.ptrauth.blend(i64 %[[T6]], i64 426) -// CHECK: call void %[[T5]](ptr noundef nonnull align {{[0-9]+}} dereferenceable(8) %{{.*}}) [ "ptrauth"(i32 0, i64 %[[T7]]) ] +// CHECK: call void %[[T5]](ptr noundef nonnull align {{[0-9]+}} dereferenceable(8) %{{.*}}) [ "ptrauth"(i64 0, i64 %[[T6]], i64 426) ] p->abc(); } diff --git a/clang/test/CodeGenCXX/ptrauth-apple-kext-indirect-virtual-dtor-call.cpp b/clang/test/CodeGenCXX/ptrauth-apple-kext-indirect-virtual-dtor-call.cpp index 7bcf1fbfdb9de..e6dc379ded44b 100644 --- a/clang/test/CodeGenCXX/ptrauth-apple-kext-indirect-virtual-dtor-call.cpp +++ b/clang/test/CodeGenCXX/ptrauth-apple-kext-indirect-virtual-dtor-call.cpp @@ -13,12 +13,10 @@ void DELETE(B1 *pb1) { } // CHECK-LABEL: define void @_ZN2B1D0Ev // CHECK: [[T1:%.*]] = load ptr, ptr getelementptr inbounds (ptr, ptr @_ZTV2B1, i64 2) -// CHECK-NEXT: [[B1:%.*]] = call i64 @llvm.ptrauth.blend(i64 ptrtoint (ptr getelementptr inbounds (ptr, ptr @_ZTV2B1, i64 2) to i64), i64 14635) -// CHECK-NEXT: call noundef ptr [[T1]](ptr noundef nonnull align 8 dereferenceable(8) [[T2:%.*]]) [ "ptrauth"(i32 0, i64 [[B1]]) ] +// CHECK-NEXT: call noundef ptr [[T1]](ptr noundef nonnull align 8 dereferenceable(8) [[T2:%.*]]) [ "ptrauth"(i64 0, i64 ptrtoint (ptr getelementptr inbounds (ptr, ptr @_ZTV2B1, i64 2) to i64), i64 14635) ] // CHECK-LABEL: define void @_Z6DELETEP2B1 // CHECK: [[T3:%.*]] = load ptr, ptr getelementptr inbounds (ptr, ptr @_ZTV2B1, i64 2) -// CHECK-NEXT: [[B3:%.*]] = call i64 @llvm.ptrauth.blend(i64 ptrtoint (ptr getelementptr inbounds (ptr, ptr @_ZTV2B1, i64 2) to i64), i64 14635) -// CHECK-NEXT: call noundef ptr [[T3]](ptr noundef nonnull align 8 dereferenceable(8) [[T4:%.*]]) [ "ptrauth"(i32 0, i64 [[B3]]) +// CHECK-NEXT: call noundef ptr [[T3]](ptr noundef nonnull align 8 dereferenceable(8) [[T4:%.*]]) [ "ptrauth"(i64 0, i64 ptrtoint (ptr getelementptr inbounds (ptr, ptr @_ZTV2B1, i64 2) to i64), i64 14635) template struct Templ { diff --git a/clang/test/CodeGenCXX/ptrauth-dynamic-cast-exact.cpp b/clang/test/CodeGenCXX/ptrauth-dynamic-cast-exact.cpp index ef34aa4c649c7..5fbd308b080d8 100644 --- a/clang/test/CodeGenCXX/ptrauth-dynamic-cast-exact.cpp +++ b/clang/test/CodeGenCXX/ptrauth-dynamic-cast-exact.cpp @@ -47,9 +47,8 @@ struct M final: G, private H { int m; }; C *exact_to_C(A *a) { // CHECK: [[UNAUTHED_VPTR:%.*]] = load ptr, ptr %a, align 8 // CHECK: [[VPTR_ADDRI:%.*]] = ptrtoint ptr %a to i64 - // CHECK: [[VPTR_ADDR_DISC:%.*]] = tail call i64 @llvm.ptrauth.blend(i64 [[VPTR_ADDRI]], i64 62866) // CHECK: [[UNAUTHED_VPTRI:%.*]] = ptrtoint ptr [[UNAUTHED_VPTR]] to i64 - // CHECK: [[AUTHED_VPTRI:%.*]] = tail call i64 @llvm.ptrauth.auth(i64 [[UNAUTHED_VPTRI]]) [ "ptrauth"(i64 2, i64 [[VPTR_ADDR_DISC]]) ] + // CHECK: [[AUTHED_VPTRI:%.*]] = tail call i64 @llvm.ptrauth.auth(i64 [[UNAUTHED_VPTRI]]) [ "ptrauth"(i64 2, i64 [[VPTR_ADDRI]], i64 62866) ] // CHECK: [[IS_EXPECTED:%.*]] = icmp eq i64 [[AUTHED_VPTRI]], ptrtoint (ptr getelementptr inbounds nuw inrange(-16, 24) (i8, ptr @_ZTV1C, i64 16) to i64) // CHECK: br i1 [[IS_EXPECTED]], label %dynamic_cast.end, label %dynamic_cast.null // CHECK: [[NULL_CHECKED_RESULT:%.*]] = phi ptr [ %a, %dynamic_cast.notnull ], [ null, %dynamic_cast.null ] @@ -62,18 +61,16 @@ D *exact_t_D(A *a) { // CHECK: dynamic_cast.notnull: // CHECK: [[SRC_UNAUTHED_VPTR:%.*]] = load ptr, ptr %a // CHECK: [[SRC_VPTR_ADDRI:%.*]] = ptrtoint ptr %a to i64 - // CHECK: [[SRC_VPTR_DISC:%.*]] = tail call i64 @llvm.ptrauth.blend(i64 [[SRC_VPTR_ADDRI]], i64 62866) // CHECK: [[SRC_UNAUTHED_VPTRI:%.*]] = ptrtoint ptr [[SRC_UNAUTHED_VPTR]] to i64 - // CHECK: [[SRC_AUTHED_VPTRI:%.*]] = tail call i64 @llvm.ptrauth.auth(i64 [[SRC_UNAUTHED_VPTRI]]) [ "ptrauth"(i64 2, i64 [[SRC_VPTR_DISC]]) ] + // CHECK: [[SRC_AUTHED_VPTRI:%.*]] = tail call i64 @llvm.ptrauth.auth(i64 [[SRC_UNAUTHED_VPTRI]]) [ "ptrauth"(i64 2, i64 [[SRC_VPTR_ADDRI]], i64 62866) ] // CHECK: [[SUCCESS:%.*]] = icmp eq i64 [[SRC_AUTHED_VPTRI]], ptrtoint (ptr getelementptr inbounds nuw inrange(-16, 16) (i8, ptr @_ZTV1D, i64 56) to i64) // CHECK: br i1 [[SUCCESS]], label %dynamic_cast.postauth.success, label %dynamic_cast.postauth.complete // CHECK: dynamic_cast.postauth.success: // CHECK: [[ADJUSTED_THIS:%.*]] = getelementptr inbounds i8, ptr %a, i64 -16 // CHECK: [[ADJUSTED_UNAUTHED_VPTR:%.*]] = load ptr, ptr [[ADJUSTED_THIS]] // CHECK: [[ADJUSTED_VPTR_ADDRI:%.*]] = ptrtoint ptr [[ADJUSTED_THIS]] to i64 - // CHECK: [[ADJUSTED_VPTR_DISC:%.*]] = tail call i64 @llvm.ptrauth.blend(i64 [[ADJUSTED_VPTR_ADDRI]], i64 28965) // CHECK: [[ADJUSTED_UNAUTHED_VPTRI:%.*]] = ptrtoint ptr [[ADJUSTED_UNAUTHED_VPTR]] to i64 - // CHECK: [[ADJUSTED_AUTHED_VPTRI:%.*]] = tail call i64 @llvm.ptrauth.auth(i64 [[ADJUSTED_UNAUTHED_VPTRI]]) [ "ptrauth"(i64 2, i64 [[ADJUSTED_VPTR_DISC]]) ] + // CHECK: [[ADJUSTED_AUTHED_VPTRI:%.*]] = tail call i64 @llvm.ptrauth.auth(i64 [[ADJUSTED_UNAUTHED_VPTRI]]) [ "ptrauth"(i64 2, i64 [[ADJUSTED_VPTR_ADDRI]], i64 28965) ] // CHECK: [[ADJUSTED_AUTHED_VPTR:%.*]] = inttoptr i64 [[ADJUSTED_AUTHED_VPTRI]] to ptr // CHECK: br label %dynamic_cast.postauth.complete // CHECK: dynamic_cast.postauth.complete: @@ -92,9 +89,8 @@ L *exact_multi(E *e) { // CHECK: dynamic_cast.notnull: // CHECK: [[VTABLE_ADDR:%.*]] = load ptr, ptr %e, align 8 // CHECK: [[THIS_ADDRI:%.*]] = ptrtoint ptr %e to i64 - // CHECK: [[VTABLE_DISC:%.*]] = tail call i64 @llvm.ptrauth.blend(i64 [[THIS_ADDRI]], i64 12810) // CHECK: [[VTABLE_ADDRI:%.*]] = ptrtoint ptr [[VTABLE_ADDR]] to i64 - // CHECK: [[AUTHED_VTABLEI:%.*]] = tail call i64 @llvm.ptrauth.auth(i64 [[VTABLE_ADDRI]]) [ "ptrauth"(i64 2, i64 [[VTABLE_DISC]]) ] + // CHECK: [[AUTHED_VTABLEI:%.*]] = tail call i64 @llvm.ptrauth.auth(i64 [[VTABLE_ADDRI]]) [ "ptrauth"(i64 2, i64 [[THIS_ADDRI]], i64 12810) ] // CHECK: [[AUTHED_VTABLE:%.*]] = inttoptr i64 [[AUTHED_VTABLEI]] to ptr // CHECK: [[PRIMARY_BASE_OFFSET:%.*]] = getelementptr inbounds i8, ptr [[AUTHED_VTABLE]], i64 -16 // CHECK: %offset.to.top = load i64, ptr [[PRIMARY_BASE_OFFSET]] @@ -106,8 +102,7 @@ L *exact_multi(E *e) { // CHECK: br i1 [[SUCCESS]], label %dynamic_cast.postauth.success, label %dynamic_cast.postauth.complete // CHECK: dynamic_cast.postauth.success: // CHECK: [[ADJUSTED_THISI:%.*]] = ptrtoint ptr [[ADJUSTED_THIS]] to i64 - // CHECK: [[DEST_DISC:%.*]] = tail call i64 @llvm.ptrauth.blend(i64 [[ADJUSTED_THISI]], i64 41434) - // CHECK: tail call i64 @llvm.ptrauth.auth(i64 [[ADJUSTED_THIS_VTABLEI]]) [ "ptrauth"(i64 2, i64 [[DEST_DISC]]) ] + // CHECK: tail call i64 @llvm.ptrauth.auth(i64 [[ADJUSTED_THIS_VTABLEI]]) [ "ptrauth"(i64 2, i64 [[ADJUSTED_THISI]], i64 41434) ] // CHECK: br label %dynamic_cast.postauth.complete // CHECK: dynamic_cast.postauth.complete: // CHECK: [[AUTHED_ADJUSTED_THIS:%.*]] = phi ptr [ [[ADJUSTED_THIS]], %dynamic_cast.postauth.success ], [ null, %dynamic_cast.notnull ] diff --git a/clang/test/CodeGenCXX/ptrauth-explicit-vtable-pointer-control.cpp b/clang/test/CodeGenCXX/ptrauth-explicit-vtable-pointer-control.cpp index 19b726d8f2386..824c23327b6e9 100644 --- a/clang/test/CodeGenCXX/ptrauth-explicit-vtable-pointer-control.cpp +++ b/clang/test/CodeGenCXX/ptrauth-explicit-vtable-pointer-control.cpp @@ -163,9 +163,8 @@ int TVDisc_ExplicitTypeDiscrimination = ptrauth_string_discriminator("_ZTVN5test // ADDR: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VTABLEI64]]) [ "ptrauth"(i64 2, i64 [[VTADDRI64]]) ] // // BOTH: [[VTADDRI64:%.*]] = ptrtoint ptr [[VTADDR]] to i64 -// BOTH: [[BLEND:%.*]] = call i64 @llvm.ptrauth.blend(i64 [[VTADDRI64]], i64 [[DISC_DEFAULT]]) // BOTH: [[VTABLEI64:%.*]] = ptrtoint ptr [[VTABLE]] to i64 -// BOTH: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VTABLEI64]]) [ "ptrauth"(i64 2, i64 [[BLEND]]) ] +// BOTH: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VTABLEI64]]) [ "ptrauth"(i64 2, i64 [[VTADDRI64]], i64 [[DISC_DEFAULT]]) ] void test_default(NoExplicitAuth *a) { a->f(); } @@ -187,18 +186,16 @@ void test_disabled(ExplicitlyDisableAuth *a) { // NODISC: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VTABLEI64]]) [ "ptrauth"(i64 2, i64 [[VTADDRI64]]) ] // // TYPE: [[VTADDRI64:%.*]] = ptrtoint ptr [[VTADDR]] to i64 -// TYPE: [[BLEND:%.*]] = call i64 @llvm.ptrauth.blend(i64 [[VTADDRI64]], i64 [[DISC_ADDR]]) // TYPE: [[VTABLEI64:%.*]] = ptrtoint ptr [[VTABLE]] to i64 -// TYPE: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VTABLEI64]]) [ "ptrauth"(i64 2, i64 [[BLEND]]) ] +// TYPE: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VTABLEI64]]) [ "ptrauth"(i64 2, i64 [[VTADDRI64]], i64 [[DISC_ADDR]]) ] // // ADDR: [[VTADDRI64:%.*]] = ptrtoint ptr [[VTADDR]] to i64 // ADDR: [[VTABLEI64:%.*]] = ptrtoint ptr [[VTABLE]] to i64 // ADDR: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VTABLEI64]]) [ "ptrauth"(i64 2, i64 [[VTADDRI64]]) ] // // BOTH: [[VTADDRI64:%.*]] = ptrtoint ptr [[VTADDR]] to i64 -// BOTH: [[BLEND:%.*]] = call i64 @llvm.ptrauth.blend(i64 [[VTADDRI64]], i64 [[DISC_ADDR]]) // BOTH: [[VTABLEI64:%.*]] = ptrtoint ptr [[VTABLE]] to i64 -// BOTH: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VTABLEI64]]) [ "ptrauth"(i64 2, i64 [[BLEND]]) ] +// BOTH: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VTABLEI64]]) [ "ptrauth"(i64 2, i64 [[VTADDRI64]], i64 [[DISC_ADDR]]) ] void test_addr_disc(ExplicitAddressDiscrimination *a) { a->f(); } @@ -254,14 +251,12 @@ void test_no_extra_disc(ExplicitNoExtraDiscrimination *a) { // TYPE: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VTABLEI64]]) [ "ptrauth"(i64 2, i64 [[DISC_TYPE]]) ] // // ADDR: [[VTADDRI64:%.*]] = ptrtoint ptr [[VTADDR]] to i64 -// ADDR: [[BLEND:%.*]] = call i64 @llvm.ptrauth.blend(i64 [[VTADDRI64]], i64 [[DISC_TYPE]]) // ADDR: [[VTABLEI64:%.*]] = ptrtoint ptr [[VTABLE]] to i64 -// ADDR: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VTABLEI64]]) [ "ptrauth"(i64 2, i64 [[BLEND]]) ] +// ADDR: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VTABLEI64]]) [ "ptrauth"(i64 2, i64 [[VTADDRI64]], i64 [[DISC_TYPE]]) ] // // BOTH: [[VTADDRI64:%.*]] = ptrtoint ptr [[VTADDR]] to i64 -// BOTH: [[BLEND:%.*]] = call i64 @llvm.ptrauth.blend(i64 [[VTADDRI64]], i64 [[DISC_TYPE]]) // BOTH: [[VTABLEI64:%.*]] = ptrtoint ptr [[VTABLE]] to i64 -// BOTH: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VTABLEI64]]) [ "ptrauth"(i64 2, i64 [[BLEND]]) ] +// BOTH: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VTABLEI64]]) [ "ptrauth"(i64 2, i64 [[VTADDRI64]], i64 [[DISC_TYPE]]) ] void test_type_disc(ExplicitTypeDiscrimination *a) { a->f(); } @@ -277,14 +272,12 @@ void test_type_disc(ExplicitTypeDiscrimination *a) { // TYPE: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VTABLEI64]]) [ "ptrauth"(i64 2, i64 42424) ] // // ADDR: [[VTADDRI64:%.*]] = ptrtoint ptr [[VTADDR]] to i64 -// ADDR: [[BLEND:%.*]] = call i64 @llvm.ptrauth.blend(i64 [[VTADDRI64]], i64 42424) // ADDR: [[VTABLEI64:%.*]] = ptrtoint ptr [[VTABLE]] to i64 -// ADDR: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VTABLEI64]]) [ "ptrauth"(i64 2, i64 [[BLEND]]) ] +// ADDR: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VTABLEI64]]) [ "ptrauth"(i64 2, i64 [[VTADDRI64]], i64 42424) ] // // BOTH: [[VTADDRI64:%.*]] = ptrtoint ptr [[VTADDR]] to i64 -// BOTH: [[BLEND:%.*]] = call i64 @llvm.ptrauth.blend(i64 [[VTADDRI64]], i64 42424) // BOTH: [[VTABLEI64:%.*]] = ptrtoint ptr [[VTABLE]] to i64 -// BOTH: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VTABLEI64]]) [ "ptrauth"(i64 2, i64 [[BLEND]]) ] +// BOTH: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VTABLEI64]]) [ "ptrauth"(i64 2, i64 [[VTADDRI64]], i64 42424) ] void test_custom_disc(ExplicitCustomDiscrimination *a) { a->f(); } @@ -309,9 +302,8 @@ void test_custom_disc(ExplicitCustomDiscrimination *a) { // ADDR: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VTABLEI64]]) [ "ptrauth"(i64 2, i64 [[VTADDRI64]]) ] // // BOTH: [[VTADDRI64:%.*]] = ptrtoint ptr [[VTADDR]] to i64 -// BOTH: [[BLEND:%.*]] = call i64 @llvm.ptrauth.blend(i64 [[VTADDRI64]], i64 [[DISC_DEFAULT]]) // BOTH: [[VTABLEI64:%.*]] = ptrtoint ptr [[VTABLE]] to i64 -// BOTH: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VTABLEI64]]) [ "ptrauth"(i64 2, i64 [[BLEND]]) ] +// BOTH: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VTABLEI64]]) [ "ptrauth"(i64 2, i64 [[VTADDRI64]], i64 [[DISC_DEFAULT]]) ] void test_subclass_default(NoExplicitAuth *a) { make_subclass(a)->f(); } @@ -333,18 +325,16 @@ void test_subclass_disabled(ExplicitlyDisableAuth *a) { // NODISC: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VTABLEI64]]) [ "ptrauth"(i64 2, i64 [[VTADDRI64]]) ] // // TYPE: [[VTADDRI64:%.*]] = ptrtoint ptr [[VTADDR]] to i64 -// TYPE: [[BLEND:%.*]] = call i64 @llvm.ptrauth.blend(i64 [[VTADDRI64]], i64 [[DISC_ADDR]]) // TYPE: [[VTABLEI64:%.*]] = ptrtoint ptr [[VTABLE]] to i64 -// TYPE: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VTABLEI64]]) [ "ptrauth"(i64 2, i64 [[BLEND]]) ] +// TYPE: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VTABLEI64]]) [ "ptrauth"(i64 2, i64 [[VTADDRI64]], i64 [[DISC_ADDR]]) ] // // ADDR: [[VTADDRI64:%.*]] = ptrtoint ptr [[VTADDR]] to i64 // ADDR: [[VTABLEI64:%.*]] = ptrtoint ptr [[VTABLE]] to i64 // ADDR: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VTABLEI64]]) [ "ptrauth"(i64 2, i64 [[VTADDRI64]]) ] // // BOTH: [[VTADDRI64:%.*]] = ptrtoint ptr [[VTADDR]] to i64 -// BOTH: [[BLEND:%.*]] = call i64 @llvm.ptrauth.blend(i64 [[VTADDRI64]], i64 [[DISC_ADDR]]) // BOTH: [[VTABLEI64:%.*]] = ptrtoint ptr [[VTABLE]] to i64 -// BOTH: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VTABLEI64]]) [ "ptrauth"(i64 2, i64 [[BLEND]]) ] +// BOTH: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VTABLEI64]]) [ "ptrauth"(i64 2, i64 [[VTADDRI64]], i64 [[DISC_ADDR]]) ] void test_subclass_addr_disc(ExplicitAddressDiscrimination *a) { make_subclass(a)->f(); } @@ -400,14 +390,12 @@ void test_subclass_no_extra_disc(ExplicitNoExtraDiscrimination *a) { // TYPE: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VTABLEI64]]) [ "ptrauth"(i64 2, i64 [[DISC_TYPE]]) ] // // ADDR: [[VTADDRI64:%.*]] = ptrtoint ptr [[VTADDR]] to i64 -// ADDR: [[BLEND:%.*]] = call i64 @llvm.ptrauth.blend(i64 [[VTADDRI64]], i64 [[DISC_TYPE]]) // ADDR: [[VTABLEI64:%.*]] = ptrtoint ptr [[VTABLE]] to i64 -// ADDR: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VTABLEI64]]) [ "ptrauth"(i64 2, i64 [[BLEND]]) ] +// ADDR: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VTABLEI64]]) [ "ptrauth"(i64 2, i64 [[VTADDRI64]], i64 [[DISC_TYPE]]) ] // // BOTH: [[VTADDRI64:%.*]] = ptrtoint ptr [[VTADDR]] to i64 -// BOTH: [[BLEND:%.*]] = call i64 @llvm.ptrauth.blend(i64 [[VTADDRI64]], i64 [[DISC_TYPE]]) // BOTH: [[VTABLEI64:%.*]] = ptrtoint ptr [[VTABLE]] to i64 -// BOTH: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VTABLEI64]]) [ "ptrauth"(i64 2, i64 [[BLEND]]) ] +// BOTH: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VTABLEI64]]) [ "ptrauth"(i64 2, i64 [[VTADDRI64]], i64 [[DISC_TYPE]]) ] void test_subclass_type_disc(ExplicitTypeDiscrimination *a) { make_subclass(a)->f(); } @@ -423,14 +411,12 @@ void test_subclass_type_disc(ExplicitTypeDiscrimination *a) { // TYPE: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VTABLEI64]]) [ "ptrauth"(i64 2, i64 42424) ] // // ADDR: [[VTADDRI64:%.*]] = ptrtoint ptr [[VTADDR]] to i64 -// ADDR: [[BLEND:%.*]] = call i64 @llvm.ptrauth.blend(i64 [[VTADDRI64]], i64 42424) // ADDR: [[VTABLEI64:%.*]] = ptrtoint ptr [[VTABLE]] to i64 -// ADDR: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VTABLEI64]]) [ "ptrauth"(i64 2, i64 [[BLEND]]) ] +// ADDR: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VTABLEI64]]) [ "ptrauth"(i64 2, i64 [[VTADDRI64]], i64 42424) ] // // BOTH: [[VTADDRI64:%.*]] = ptrtoint ptr [[VTADDR]] to i64 -// BOTH: [[BLEND:%.*]] = call i64 @llvm.ptrauth.blend(i64 [[VTADDRI64]], i64 42424) // BOTH: [[VTABLEI64:%.*]] = ptrtoint ptr [[VTABLE]] to i64 -// BOTH: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VTABLEI64]]) [ "ptrauth"(i64 2, i64 [[BLEND]]) ] +// BOTH: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VTABLEI64]]) [ "ptrauth"(i64 2, i64 [[VTADDRI64]], i64 42424) ] void test_subclass_custom_disc(ExplicitCustomDiscrimination *a) { make_subclass(a)->f(); } @@ -457,9 +443,8 @@ void test_subclass_custom_disc(ExplicitCustomDiscrimination *a) { // ADDR: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VTABLEI64]]) [ "ptrauth"(i64 2, i64 [[VTADDRI64]]) ] // // BOTH: [[VTADDRI64:%.*]] = ptrtoint ptr [[VTADDR]] to i64 -// BOTH: [[BLEND:%.*]] = call i64 @llvm.ptrauth.blend(i64 [[VTADDRI64]], i64 [[DISC_DEFAULT]]) // BOTH: [[VTABLEI64:%.*]] = ptrtoint ptr [[VTABLE]] to i64 -// BOTH: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VTABLEI64]]) [ "ptrauth"(i64 2, i64 [[BLEND]]) ] +// BOTH: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VTABLEI64]]) [ "ptrauth"(i64 2, i64 [[VTADDRI64]], i64 [[DISC_DEFAULT]]) ] void test_multiple_default(NoExplicitAuth *a) { make_multiple_primary(a)->f(); } @@ -485,14 +470,12 @@ void test_multiple_disabled(ExplicitlyDisableAuth *a) { // TYPE: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VTABLEI64]]) [ "ptrauth"(i64 2, i64 42424) ] // // ADDR: [[VTADDRI64:%.*]] = ptrtoint ptr [[VTADDR]] to i64 -// ADDR: [[BLEND:%.*]] = call i64 @llvm.ptrauth.blend(i64 [[VTADDRI64]], i64 42424) // ADDR: [[VTABLEI64:%.*]] = ptrtoint ptr [[VTABLE]] to i64 -// ADDR: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VTABLEI64]]) [ "ptrauth"(i64 2, i64 [[BLEND]]) ] +// ADDR: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VTABLEI64]]) [ "ptrauth"(i64 2, i64 [[VTADDRI64]], i64 42424) ] // // BOTH: [[VTADDRI64:%.*]] = ptrtoint ptr [[VTADDR]] to i64 -// BOTH: [[BLEND:%.*]] = call i64 @llvm.ptrauth.blend(i64 [[VTADDRI64]], i64 42424) // BOTH: [[VTABLEI64:%.*]] = ptrtoint ptr [[VTABLE]] to i64 -// BOTH: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VTABLEI64]]) [ "ptrauth"(i64 2, i64 [[BLEND]]) ] +// BOTH: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VTABLEI64]]) [ "ptrauth"(i64 2, i64 [[VTADDRI64]], i64 42424) ] void test_multiple_custom_disc(ExplicitCustomDiscrimination *a) { make_multiple_primary(a)->f(); } @@ -518,9 +501,8 @@ void test_multiple_custom_disc(ExplicitCustomDiscrimination *a) { // ADDR: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VTTABLEI64]]) [ "ptrauth"(i64 2, i64 [[VTTADDRI64]]) ] // // BOTH: [[VTTADDRI64:%.*]] = ptrtoint ptr [[VTTADDR]] to i64 -// BOTH: [[BLEND:%.*]] = call i64 @llvm.ptrauth.blend(i64 [[VTTADDRI64]], i64 [[DISC_DEFAULT]]) // BOTH: [[VTTABLEI64:%.*]] = ptrtoint ptr [[VTTABLE]] to i64 -// BOTH: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VTTABLEI64]]) [ "ptrauth"(i64 2, i64 [[BLEND]]) ] +// BOTH: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VTTABLEI64]]) [ "ptrauth"(i64 2, i64 [[VTTADDRI64]], i64 [[DISC_DEFAULT]]) ] // CHECK: [[AUTHEDPTR:%.*]] = inttoptr i64 [[AUTHED]] to ptr // CHECK: [[VBOFFPTR:%.*]] = getelementptr i8, ptr [[AUTHEDPTR]], i64 -48 @@ -539,9 +521,8 @@ void test_multiple_custom_disc(ExplicitCustomDiscrimination *a) { // ADDR: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VTABLEI64]]) [ "ptrauth"(i64 2, i64 [[VTADDRI64]]) ] // // BOTH: [[VTADDRI64:%.*]] = ptrtoint ptr [[VTADDR]] to i64 -// BOTH: [[BLEND:%.*]] = call i64 @llvm.ptrauth.blend(i64 [[VTADDRI64]], i64 [[DISC_DEFAULT]]) // BOTH: [[VTABLEI64:%.*]] = ptrtoint ptr [[VTABLE]] to i64 -// BOTH: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VTABLEI64]]) [ "ptrauth"(i64 2, i64 [[BLEND]]) ] +// BOTH: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VTABLEI64]]) [ "ptrauth"(i64 2, i64 [[VTADDRI64]], i64 [[DISC_DEFAULT]]) ] void test_virtual_default(NoExplicitAuth *a) { make_virtual_primary(a)->f(); } @@ -563,14 +544,12 @@ void test_virtual_disabled(ExplicitlyDisableAuth *a) { // TYPE: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VTTABLEI64]]) [ "ptrauth"(i64 2, i64 42424) ] // // ADDR: [[VTTADDRI64:%.*]] = ptrtoint ptr [[VTTADDR]] to i64 -// ADDR: [[BLEND:%.*]] = call i64 @llvm.ptrauth.blend(i64 [[VTTADDRI64]], i64 42424) // ADDR: [[VTTABLEI64:%.*]] = ptrtoint ptr [[VTTABLE]] to i64 -// ADDR: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VTTABLEI64]]) [ "ptrauth"(i64 2, i64 [[BLEND]]) ] +// ADDR: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VTTABLEI64]]) [ "ptrauth"(i64 2, i64 [[VTTADDRI64]], i64 42424) ] // // BOTH: [[VTTADDRI64:%.*]] = ptrtoint ptr [[VTTADDR]] to i64 -// BOTH: [[BLEND:%.*]] = call i64 @llvm.ptrauth.blend(i64 [[VTTADDRI64]], i64 42424) // BOTH: [[VTTABLEI64:%.*]] = ptrtoint ptr [[VTTABLE]] to i64 -// BOTH: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VTTABLEI64]]) [ "ptrauth"(i64 2, i64 [[BLEND]]) ] +// BOTH: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VTTABLEI64]]) [ "ptrauth"(i64 2, i64 [[VTTADDRI64]], i64 42424) ] // CHECK: [[AUTHEDPTR:%.*]] = inttoptr i64 [[AUTHED]] to ptr // CHECK: [[VBOFFPTR:%.*]] = getelementptr i8, ptr [[AUTHEDPTR]], i64 -48 @@ -585,14 +564,12 @@ void test_virtual_disabled(ExplicitlyDisableAuth *a) { // TYPE: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VTABLEI64]]) [ "ptrauth"(i64 2, i64 42424) ] // // ADDR: [[VTADDRI64:%.*]] = ptrtoint ptr [[VTADDR]] to i64 -// ADDR: [[BLEND:%.*]] = call i64 @llvm.ptrauth.blend(i64 [[VTADDRI64]], i64 42424) // ADDR: [[VTABLEI64:%.*]] = ptrtoint ptr [[VTABLE]] to i64 -// ADDR: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VTABLEI64]]) [ "ptrauth"(i64 2, i64 [[BLEND]]) ] +// ADDR: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VTABLEI64]]) [ "ptrauth"(i64 2, i64 [[VTADDRI64]], i64 42424) ] // // BOTH: [[VTADDRI64:%.*]] = ptrtoint ptr [[VTADDR]] to i64 -// BOTH: [[BLEND:%.*]] = call i64 @llvm.ptrauth.blend(i64 [[VTADDRI64]], i64 42424) // BOTH: [[VTABLEI64:%.*]] = ptrtoint ptr [[VTABLE]] to i64 -// BOTH: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VTABLEI64]]) [ "ptrauth"(i64 2, i64 [[BLEND]]) ] +// BOTH: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VTABLEI64]]) [ "ptrauth"(i64 2, i64 [[VTADDRI64]], i64 42424) ] void test_virtual_custom_disc(ExplicitCustomDiscrimination *a) { make_virtual_primary(a)->f(); } diff --git a/clang/test/CodeGenCXX/ptrauth-global-constant-initializers.cpp b/clang/test/CodeGenCXX/ptrauth-global-constant-initializers.cpp index 9ce9def6156ef..4e8b5098fcb3c 100644 --- a/clang/test/CodeGenCXX/ptrauth-global-constant-initializers.cpp +++ b/clang/test/CodeGenCXX/ptrauth-global-constant-initializers.cpp @@ -78,25 +78,25 @@ struct Derived5 : VirtualBase2, VirtualBase1 { // DARWIN-LABEL: define {{.*}} ptr @_ZN12VirtualBase1C1Ev // ELF-LABEL: define {{.*}} void @_ZN12VirtualBase1C1Ev -// CHECK: call i64 @llvm.ptrauth.blend(i64 {{%.*}}, i64 [[BASE1_VTABLE_DISC]]) -// CHECK: call i64 @llvm.ptrauth.blend(i64 {{%.*}}, i64 [[BASE1_VTABLE_DISC]]) +// CHECK: call i64 @llvm.ptrauth.sign{{.*}} [ "ptrauth"(i64 2, i64 {{%.*}}, i64 [[BASE1_VTABLE_DISC]]) ] +// CHECK: call i64 @llvm.ptrauth.sign{{.*}} [ "ptrauth"(i64 2, i64 {{%.*}}, i64 [[BASE1_VTABLE_DISC]]) ] // DARWIN-LABEL: define {{.*}} ptr @_ZN12VirtualBase2C1Ev // ELF-LABEL: define {{.*}} void @_ZN12VirtualBase2C1Ev -// CHECK: call i64 @llvm.ptrauth.blend(i64 {{%.*}}, i64 [[BASE2_VTABLE_DISC]]) -// CHECK: call i64 @llvm.ptrauth.blend(i64 {{%.*}}, i64 [[BASE1_VTABLE_DISC]]) +// CHECK: call i64 @llvm.ptrauth.sign{{.*}} [ "ptrauth"(i64 2, i64 {{%.*}}, i64 [[BASE2_VTABLE_DISC]]) ] +// CHECK: call i64 @llvm.ptrauth.sign{{.*}} [ "ptrauth"(i64 2, i64 {{%.*}}, i64 [[BASE1_VTABLE_DISC]]) ] // DARWIN-LABEL: define {{.*}} ptr @_ZN8Derived4C1Ev // ELF-LABEL: define {{.*}} void @_ZN8Derived4C1Ev -// CHECK: call i64 @llvm.ptrauth.blend(i64 {{%.*}}, i64 [[BASE1_VTABLE_DISC]]) -// CHECK: call i64 @llvm.ptrauth.blend(i64 {{%.*}}, i64 [[BASE1_VTABLE_DISC]]) -// CHECK: call i64 @llvm.ptrauth.blend(i64 {{%.*}}, i64 [[BASE2_VTABLE_DISC]]) +// CHECK: call i64 @llvm.ptrauth.sign{{.*}} [ "ptrauth"(i64 2, i64 {{%.*}}, i64 [[BASE1_VTABLE_DISC]]) ] +// CHECK: call i64 @llvm.ptrauth.sign{{.*}} [ "ptrauth"(i64 2, i64 {{%.*}}, i64 [[BASE1_VTABLE_DISC]]) ] +// CHECK: call i64 @llvm.ptrauth.sign{{.*}} [ "ptrauth"(i64 2, i64 {{%.*}}, i64 [[BASE2_VTABLE_DISC]]) ] // DARWIN-LABEL: define {{.*}} ptr @_ZN8Derived5C1Ev // ELF-LABEL: define {{.*}} void @_ZN8Derived5C1Ev -// CHECK: call i64 @llvm.ptrauth.blend(i64 {{%.*}}, i64 [[BASE2_VTABLE_DISC]]) -// CHECK: call i64 @llvm.ptrauth.blend(i64 {{%.*}}, i64 [[BASE1_VTABLE_DISC]]) -// CHECK: call i64 @llvm.ptrauth.blend(i64 {{%.*}}, i64 [[BASE1_VTABLE_DISC]]) +// CHECK: call i64 @llvm.ptrauth.sign{{.*}} [ "ptrauth"(i64 2, i64 {{%.*}}, i64 [[BASE2_VTABLE_DISC]]) ] +// CHECK: call i64 @llvm.ptrauth.sign{{.*}} [ "ptrauth"(i64 2, i64 {{%.*}}, i64 [[BASE1_VTABLE_DISC]]) ] +// CHECK: call i64 @llvm.ptrauth.sign{{.*}} [ "ptrauth"(i64 2, i64 {{%.*}}, i64 [[BASE1_VTABLE_DISC]]) ] VirtualBase1 g_vb1; @@ -164,82 +164,82 @@ extern "C" void cross_check_vtables(Base1 *b1, // CHECK-LABEL: define{{.*}} void @cross_check_vtables( // CHECK: "; b1->a()", -// CHECK: call i64 @llvm.ptrauth.blend(i64 {{%.*}}, i64 [[BASE1_VTABLE_DISC]]) -// CHECK: call i64 @llvm.ptrauth.blend(i64 {{%.*}}, i64 [[BASE1_A_DISC]]) +// CHECK: call i64 @llvm.ptrauth.auth{{.*}} [ "ptrauth"(i64 2, i64 {{%.*}}, i64 [[BASE1_VTABLE_DISC]]) ] +// CHECK: call void %{{.*}} [ "ptrauth"(i64 0, i64 {{%.*}}, i64 [[BASE1_A_DISC]]) ] // CHECK: "; b2->b()" -// CHECK: call i64 @llvm.ptrauth.blend(i64 {{%.*}}, i64 [[BASE2_VTABLE_DISC]]) -// CHECK: call i64 @llvm.ptrauth.blend(i64 {{%.*}}, i64 [[BASE2_B_DISC]]) +// CHECK: call i64 @llvm.ptrauth.auth{{.*}} [ "ptrauth"(i64 2, i64 {{%.*}}, i64 [[BASE2_VTABLE_DISC]]) ] +// CHECK: call void %{{.*}} [ "ptrauth"(i64 0, i64 {{%.*}}, i64 [[BASE2_B_DISC]]) ] // CHECK: "; d1->a()" -// CHECK: call i64 @llvm.ptrauth.blend(i64 {{%.*}}, i64 [[BASE1_VTABLE_DISC]]) -// CHECK: call i64 @llvm.ptrauth.blend(i64 {{%.*}}, i64 [[BASE1_A_DISC]]) +// CHECK: call i64 @llvm.ptrauth.auth{{.*}} [ "ptrauth"(i64 2, i64 {{%.*}}, i64 [[BASE1_VTABLE_DISC]]) ] +// CHECK: call void %{{.*}} [ "ptrauth"(i64 0, i64 {{%.*}}, i64 [[BASE1_A_DISC]]) ] // CHECK: "; d1->c()" -// CHECK: call i64 @llvm.ptrauth.blend(i64 {{%.*}}, i64 [[BASE1_VTABLE_DISC]]) -// CHECK: call i64 @llvm.ptrauth.blend(i64 {{%.*}}, i64 [[DERIVED1_C_DISC]]) +// CHECK: call i64 @llvm.ptrauth.auth{{.*}} [ "ptrauth"(i64 2, i64 {{%.*}}, i64 [[BASE1_VTABLE_DISC]]) ] +// CHECK: call void %{{.*}} [ "ptrauth"(i64 0, i64 {{%.*}}, i64 [[DERIVED1_C_DISC]]) ] // CHECK: "; d2->a()" -// CHECK: call i64 @llvm.ptrauth.blend(i64 {{%.*}}, i64 [[BASE1_VTABLE_DISC]]) -// CHECK: call i64 @llvm.ptrauth.blend(i64 {{%.*}}, i64 [[BASE1_A_DISC]]) +// CHECK: call i64 @llvm.ptrauth.auth{{.*}} [ "ptrauth"(i64 2, i64 {{%.*}}, i64 [[BASE1_VTABLE_DISC]]) ] +// CHECK: call void %{{.*}} [ "ptrauth"(i64 0, i64 {{%.*}}, i64 [[BASE1_A_DISC]]) ] // CHECK: "; d2->c()" -// CHECK: call i64 @llvm.ptrauth.blend(i64 {{%.*}}, i64 [[BASE2_VTABLE_DISC]]) -// CHECK: call i64 @llvm.ptrauth.blend(i64 {{%.*}}, i64 [[DERIVED2_C_DISC]]) +// CHECK: call i64 @llvm.ptrauth.auth{{.*}} [ "ptrauth"(i64 2, i64 {{%.*}}, i64 [[BASE2_VTABLE_DISC]]) ] +// CHECK: call void %{{.*}} [ "ptrauth"(i64 0, i64 {{%.*}}, i64 [[DERIVED2_C_DISC]]) ] // CHECK: "; d3->a()" -// CHECK: call i64 @llvm.ptrauth.blend(i64 {{%.*}}, i64 [[BASE1_VTABLE_DISC]]) -// CHECK: call i64 @llvm.ptrauth.blend(i64 {{%.*}}, i64 [[BASE1_A_DISC]]) +// CHECK: call i64 @llvm.ptrauth.auth{{.*}} [ "ptrauth"(i64 2, i64 {{%.*}}, i64 [[BASE1_VTABLE_DISC]]) ] +// CHECK: call void %{{.*}} [ "ptrauth"(i64 0, i64 {{%.*}}, i64 [[BASE1_A_DISC]]) ] // CHECK: "; d3->b()" -// CHECK: call i64 @llvm.ptrauth.blend(i64 {{%.*}}, i64 [[BASE2_VTABLE_DISC]]) -// CHECK: call i64 @llvm.ptrauth.blend(i64 {{%.*}}, i64 [[BASE2_B_DISC]]) +// CHECK: call i64 @llvm.ptrauth.auth{{.*}} [ "ptrauth"(i64 2, i64 {{%.*}}, i64 [[BASE2_VTABLE_DISC]]) ] +// CHECK: call void %{{.*}} [ "ptrauth"(i64 0, i64 {{%.*}}, i64 [[BASE2_B_DISC]]) ] // CHECK: "; d3->i()" -// CHECK: call i64 @llvm.ptrauth.blend(i64 {{%.*}}, i64 [[BASE1_VTABLE_DISC]]) -// CHECK: call i64 @llvm.ptrauth.blend(i64 {{%.*}}, i64 [[DERIVED3_I_DISC]]) +// CHECK: call i64 @llvm.ptrauth.auth{{.*}} [ "ptrauth"(i64 2, i64 {{%.*}}, i64 [[BASE1_VTABLE_DISC]]) ] +// CHECK: call void %{{.*}} [ "ptrauth"(i64 0, i64 {{%.*}}, i64 [[DERIVED3_I_DISC]]) ] // CHECK: "; vb1->a()" -// CHECK: call i64 @llvm.ptrauth.blend(i64 {{%.*}}, i64 [[BASE1_VTABLE_DISC]]) -// CHECK: call i64 @llvm.ptrauth.blend(i64 {{%.*}}, i64 [[BASE1_VTABLE_DISC]]) -// CHECK: call i64 @llvm.ptrauth.blend(i64 {{%.*}}, i64 [[BASE1_A_DISC]]) +// CHECK: call i64 @llvm.ptrauth.auth{{.*}} [ "ptrauth"(i64 2, i64 {{%.*}}, i64 [[BASE1_VTABLE_DISC]]) ] +// CHECK: call i64 @llvm.ptrauth.auth{{.*}} [ "ptrauth"(i64 2, i64 {{%.*}}, i64 [[BASE1_VTABLE_DISC]]) ] +// CHECK: call void %{{.*}} [ "ptrauth"(i64 0, i64 {{%.*}}, i64 [[BASE1_A_DISC]]) ] // CHECK: "; vb1->f()" -// CHECK: call i64 @llvm.ptrauth.blend(i64 {{%.*}}, i64 [[BASE1_VTABLE_DISC]]) -// CHECK: call i64 @llvm.ptrauth.blend(i64 {{%.*}}, i64 [[VIRTUALBASE1_F_DISC]]) +// CHECK: call i64 @llvm.ptrauth.auth{{.*}} [ "ptrauth"(i64 2, i64 {{%.*}}, i64 [[BASE1_VTABLE_DISC]]) ] +// CHECK: call void %{{.*}} [ "ptrauth"(i64 0, i64 {{%.*}}, i64 [[VIRTUALBASE1_F_DISC]]) ] // CHECK: "; vb2->a()" -// CHECK: call i64 @llvm.ptrauth.blend(i64 {{%.*}}, i64 [[BASE2_VTABLE_DISC]]) -// CHECK: call i64 @llvm.ptrauth.blend(i64 {{%.*}}, i64 [[BASE1_VTABLE_DISC]]) -// CHECK: call i64 @llvm.ptrauth.blend(i64 {{%.*}}, i64 [[BASE1_A_DISC]]) +// CHECK: call i64 @llvm.ptrauth.auth{{.*}} [ "ptrauth"(i64 2, i64 {{%.*}}, i64 [[BASE2_VTABLE_DISC]]) ] +// CHECK: call i64 @llvm.ptrauth.auth{{.*}} [ "ptrauth"(i64 2, i64 {{%.*}}, i64 [[BASE1_VTABLE_DISC]]) ] +// CHECK: call void %{{.*}} [ "ptrauth"(i64 0, i64 {{%.*}}, i64 [[BASE1_A_DISC]]) ] // CHECK: "; vb2->g()" -// CHECK: call i64 @llvm.ptrauth.blend(i64 {{%.*}}, i64 [[BASE2_VTABLE_DISC]]) -// CHECK: call i64 @llvm.ptrauth.blend(i64 {{%.*}}, i64 [[VIRTUALBASE2_G_DISC]]) +// CHECK: call i64 @llvm.ptrauth.auth{{.*}} [ "ptrauth"(i64 2, i64 {{%.*}}, i64 [[BASE2_VTABLE_DISC]]) ] +// CHECK: call void %{{.*}} [ "ptrauth"(i64 0, i64 {{%.*}}, i64 [[VIRTUALBASE2_G_DISC]]) ] // CHECK: "; d4->a()" -// CHECK: call i64 @llvm.ptrauth.blend(i64 {{%.*}}, i64 [[BASE1_VTABLE_DISC]]) -// CHECK: call i64 @llvm.ptrauth.blend(i64 {{%.*}}, i64 [[BASE1_VTABLE_DISC]]) -// CHECK: call i64 @llvm.ptrauth.blend(i64 {{%.*}}, i64 [[BASE1_A_DISC]]) +// CHECK: call i64 @llvm.ptrauth.auth{{.*}} [ "ptrauth"(i64 2, i64 {{%.*}}, i64 [[BASE1_VTABLE_DISC]]) ] +// CHECK: call i64 @llvm.ptrauth.auth{{.*}} [ "ptrauth"(i64 2, i64 {{%.*}}, i64 [[BASE1_VTABLE_DISC]]) ] +// CHECK: call void %{{.*}} [ "ptrauth"(i64 0, i64 {{%.*}}, i64 [[BASE1_A_DISC]]) ] // CHECK: "; d4->b()" -// CHECK: call i64 @llvm.ptrauth.blend(i64 {{%.*}}, i64 [[BASE2_VTABLE_DISC]]) -// CHECK: call i64 @llvm.ptrauth.blend(i64 {{%.*}}, i64 [[BASE2_B_DISC]]) +// CHECK: call i64 @llvm.ptrauth.auth{{.*}} [ "ptrauth"(i64 2, i64 {{%.*}}, i64 [[BASE2_VTABLE_DISC]]) ] +// CHECK: call void %{{.*}} [ "ptrauth"(i64 0, i64 {{%.*}}, i64 [[BASE2_B_DISC]]) ] // CHECK: "; d4->f()" -// CHECK: call i64 @llvm.ptrauth.blend(i64 {{%.*}}, i64 [[BASE1_VTABLE_DISC]]) -// CHECK: call i64 @llvm.ptrauth.blend(i64 {{%.*}}, i64 [[VIRTUALBASE1_F_DISC]]) +// CHECK: call i64 @llvm.ptrauth.auth{{.*}} [ "ptrauth"(i64 2, i64 {{%.*}}, i64 [[BASE1_VTABLE_DISC]]) ] +// CHECK: call void %{{.*}} [ "ptrauth"(i64 0, i64 {{%.*}}, i64 [[VIRTUALBASE1_F_DISC]]) ] // CHECK: "; d4->g()" -// CHECK: call i64 @llvm.ptrauth.blend(i64 {{%.*}}, i64 [[BASE2_VTABLE_DISC]]) -// CHECK: call i64 @llvm.ptrauth.blend(i64 {{%.*}}, i64 [[VIRTUALBASE2_G_DISC]]) +// CHECK: call i64 @llvm.ptrauth.auth{{.*}} [ "ptrauth"(i64 2, i64 {{%.*}}, i64 [[BASE2_VTABLE_DISC]]) ] +// CHECK: call void %{{.*}} [ "ptrauth"(i64 0, i64 {{%.*}}, i64 [[VIRTUALBASE2_G_DISC]]) ] // CHECK: "; d4->h()" -// CHECK: call i64 @llvm.ptrauth.blend(i64 {{%.*}}, i64 [[BASE1_VTABLE_DISC]]) -// CHECK: call i64 @llvm.ptrauth.blend(i64 {{%.*}}, i64 [[DERIVED4_H_DISC]]) +// CHECK: call i64 @llvm.ptrauth.auth{{.*}} [ "ptrauth"(i64 2, i64 {{%.*}}, i64 [[BASE1_VTABLE_DISC]]) ] +// CHECK: call void %{{.*}} [ "ptrauth"(i64 0, i64 {{%.*}}, i64 [[DERIVED4_H_DISC]]) ] // DARWIN-LABEL: define {{.*}} ptr @_ZN5Base1C2Ev // ELF-LABEL: define {{.*}} void @_ZN5Base1C2Ev -// CHECK: call i64 @llvm.ptrauth.blend(i64 {{%.*}}, i64 [[BASE1_VTABLE_DISC]]) +// CHECK: call i64 @llvm.ptrauth.sign{{.*}} [ "ptrauth"(i64 2, i64 {{%.*}}, i64 [[BASE1_VTABLE_DISC]]) ] // DARWIN-LABEL: define {{.*}} ptr @_ZN5Base2C2Ev // ELF-LABEL: define {{.*}} void @_ZN5Base2C2Ev -// CHECK: call i64 @llvm.ptrauth.blend(i64 {{%.*}}, i64 [[BASE2_VTABLE_DISC]]) +// CHECK: call i64 @llvm.ptrauth.sign{{.*}} [ "ptrauth"(i64 2, i64 {{%.*}}, i64 [[BASE2_VTABLE_DISC]]) ] // DARWIN-LABEL: define {{.*}} ptr @_ZN8Derived1C2Ev // ELF-LABEL: define {{.*}} void @_ZN8Derived1C2Ev -// CHECK: call i64 @llvm.ptrauth.blend(i64 {{%.*}}, i64 [[BASE1_VTABLE_DISC]]) -// CHECK: call i64 @llvm.ptrauth.blend(i64 {{%.*}}, i64 [[BASE2_VTABLE_DISC]]) +// CHECK: call i64 @llvm.ptrauth.sign{{.*}} [ "ptrauth"(i64 2, i64 {{%.*}}, i64 [[BASE1_VTABLE_DISC]]) ] +// CHECK: call i64 @llvm.ptrauth.sign{{.*}} [ "ptrauth"(i64 2, i64 {{%.*}}, i64 [[BASE2_VTABLE_DISC]]) ] // DARWIN-LABEL: define {{.*}} ptr @_ZN8Derived2C2Ev // ELF-LABEL: define {{.*}} void @_ZN8Derived2C2Ev -// CHECK: call i64 @llvm.ptrauth.blend(i64 {{%.*}}, i64 [[BASE2_VTABLE_DISC]]) -// CHECK: call i64 @llvm.ptrauth.blend(i64 {{%.*}}, i64 [[BASE1_VTABLE_DISC]]) +// CHECK: call i64 @llvm.ptrauth.sign{{.*}} [ "ptrauth"(i64 2, i64 {{%.*}}, i64 [[BASE2_VTABLE_DISC]]) ] +// CHECK: call i64 @llvm.ptrauth.sign{{.*}} [ "ptrauth"(i64 2, i64 {{%.*}}, i64 [[BASE1_VTABLE_DISC]]) ] // DARWIN-LABEL: define {{.*}} ptr @_ZN8Derived3C2Ev // ELF-LABEL: define {{.*}} void @_ZN8Derived3C2Ev -// CHECK: call i64 @llvm.ptrauth.blend(i64 {{%.*}}, i64 [[BASE1_VTABLE_DISC]]) -// CHECK: call i64 @llvm.ptrauth.blend(i64 {{%.*}}, i64 [[BASE2_VTABLE_DISC]]) +// CHECK: call i64 @llvm.ptrauth.sign{{.*}} [ "ptrauth"(i64 2, i64 {{%.*}}, i64 [[BASE1_VTABLE_DISC]]) ] +// CHECK: call i64 @llvm.ptrauth.sign{{.*}} [ "ptrauth"(i64 2, i64 {{%.*}}, i64 [[BASE2_VTABLE_DISC]]) ] diff --git a/clang/test/CodeGenCXX/ptrauth-member-function-pointer.cpp b/clang/test/CodeGenCXX/ptrauth-member-function-pointer.cpp index 232aa04412ea0..abf556decebed 100644 --- a/clang/test/CodeGenCXX/ptrauth-member-function-pointer.cpp +++ b/clang/test/CodeGenCXX/ptrauth-member-function-pointer.cpp @@ -133,8 +133,7 @@ struct Class0 { // CHECK-NEXT: %[[VFN:.*]] = getelementptr inbounds ptr, ptr %[[V4]], i64 0 // CHECK-NEXT: %[[V5:.*]] = load ptr, ptr %[[VFN]], align 8 // CHECK-NEXT: %[[V6:.*]] = ptrtoint ptr %[[VFN]] to i64 -// CHECK-NEXT: %[[V7:.*]] = call i64 @llvm.ptrauth.blend(i64 %[[V6]], i64 55600) -// CHECK-NEXT: musttail call void %[[V5]](ptr noundef nonnull align {{[0-9]+}} dereferenceable(8) %[[V0]]) [ "ptrauth"(i32 0, i64 %[[V7]]) ] +// CHECK-NEXT: musttail call void %[[V5]](ptr noundef nonnull align {{[0-9]+}} dereferenceable(8) %[[V0]]) [ "ptrauth"(i64 0, i64 %[[V6]], i64 55600) ] // CHECK-NEXT: ret void // CHECK: define linkonce_odr hidden void @_ZN5Base08virtual3Ev_vfpthunk_(ptr noundef %{{.*}}) @@ -145,7 +144,7 @@ struct Class0 { // CHECK: %[[V3:.*]] = call i64 @llvm.ptrauth.auth(i64 %[[V2]]) [ "ptrauth"(i64 2, i64 0) ] // CHECK: %[[V4:.*]] = inttoptr i64 %[[V3]] to ptr // CHECK: getelementptr inbounds ptr, ptr %[[V4]], i64 1 -// CHECK: call i64 @llvm.ptrauth.blend(i64 %{{.*}}, i64 53007) +// CHECK: call void %{{.*}} [ "ptrauth"(i64 0, i64 %{{.*}}, i64 53007) ] // CHECK: define linkonce_odr hidden void @_ZN5Base016virtual_variadicEiz_vfpthunk_(ptr noundef %[[THIS:.*]], i32 noundef %0, ...) // CHECK: %[[THIS_ADDR:.*]] = alloca ptr, align 8 @@ -162,8 +161,7 @@ struct Class0 { // CHECK-NEXT: %[[VFN:.*]] = getelementptr inbounds ptr, ptr %[[V6]], i64 2 // CHECK-NEXT: %[[V7:.*]] = load ptr, ptr %[[VFN]], align 8 // CHECK-NEXT: %[[V8:.*]] = ptrtoint ptr %[[VFN]] to i64 -// CHECK-NEXT: %[[V9:.*]] = call i64 @llvm.ptrauth.blend(i64 %[[V8]], i64 7464) -// CHECK-NEXT: musttail call void (ptr, i32, ...) %[[V7]](ptr noundef nonnull align {{[0-9]+}} dereferenceable(8) %[[V1]], i32 noundef %[[V2]], ...) [ "ptrauth"(i32 0, i64 %[[V9]]) ] +// CHECK-NEXT: musttail call void (ptr, i32, ...) %[[V7]](ptr noundef nonnull align {{[0-9]+}} dereferenceable(8) %[[V1]], i32 noundef %[[V2]], ...) [ "ptrauth"(i64 0, i64 %[[V8]], i64 7464) ] // CHECK-NEXT: ret void // CHECK: define linkonce_odr hidden void @_ZN8Derived08virtual6Ev_vfpthunk_(ptr noundef %[[THIS:.*]]) @@ -177,21 +175,19 @@ struct Class0 { // CHECK: %[[V3:.*]] = inttoptr i64 %[[V2]] to ptr // CHECK: %[[VFN:.*]] = getelementptr inbounds ptr, ptr %[[V3]], i64 3 // CHECK: %[[V5:.*]] = ptrtoint ptr %[[VFN]] to i64 -// CHECK: call i64 @llvm.ptrauth.blend(i64 %[[V5]], i64 55535) +// CHECK: call void %{{.*}} [ "ptrauth"(i64 0, i64 %[[V5]], i64 55535) ] // Check that the return value of the musttail call isn't copied to a temporary. // CHECK: define linkonce_odr hidden [2 x i64] @_ZN8Derived010return_aggEv_vfpthunk_(ptr noundef %{{.*}}) -// CHECK: %[[DISC:.*]] = call i64 @llvm.ptrauth.blend(i64 {{.*}}, i64 13445) -// CHECK: %[[CALL:.*]] = musttail call [2 x i64] %{{.*}}(ptr noundef nonnull align {{[0-9]+}} dereferenceable(8) %{{.*}}) [ "ptrauth"(i32 0, i64 %[[DISC]]) ] +// CHECK: %[[CALL:.*]] = musttail call [2 x i64] %{{.*}}(ptr noundef nonnull align {{[0-9]+}} dereferenceable(8) %{{.*}}) [ "ptrauth"(i64 0, i64 %{{.*}}, i64 13445) ] // CHECK-NEXT: ret [2 x i64] %[[CALL]] // Check that the sret pointer passed to the caller is forwarded to the musttail // call. // CHECK: define linkonce_odr hidden void @_ZN8Derived04sretEv_vfpthunk_(ptr dead_on_unwind noalias writable sret(%struct.A1) align 4 %[[AGG_RESULT:.*]], ptr noundef %{{.*}}) -// CHECK: %[[DISC:.*]] = call i64 @llvm.ptrauth.blend(i64 {{.*}}, i64 41281) -// CHECK: musttail call void %{{.*}}(ptr dead_on_unwind writable sret(%struct.A1) align 4 %[[AGG_RESULT]], ptr noundef nonnull align {{[0-9]+}} dereferenceable(8) %{{.*}}) [ "ptrauth"(i32 0, i64 %[[DISC]]) ] +// CHECK: musttail call void %{{.*}}(ptr dead_on_unwind writable sret(%struct.A1) align 4 %[[AGG_RESULT]], ptr noundef nonnull align {{[0-9]+}} dereferenceable(8) %{{.*}}) [ "ptrauth"(i64 0, i64 %{{.*}}, i64 41281) ] // CHECK-NEXT: ret void // Check that the thunk function doesn't destruct the trivial_abi argument. @@ -200,9 +196,7 @@ struct Class0 { // NODEBUG-NOT: call // CHECK: call i64 @llvm.ptrauth.auth( // NODEBUG-NOT: call -// CHECK: call i64 @llvm.ptrauth.blend( -// NODEBUG-NOT: call -// CHECK: musttail call void +// CHECK: musttail call void{{.*}} [ "ptrauth"({{.*}}) ] // CHECK-NEXT: ret void // CHECK: define linkonce_odr hidden void @_ZN5Base18virtual7Ev_vfpthunk_(ptr noundef %[[THIS:.*]]) @@ -297,7 +291,7 @@ void test0() { // CHECK: %[[V14:.*]] = phi ptr [ %[[MEMPTR_VIRTUALFN]], {{.*}} ], [ %[[MEMPTR_NONVIRTUALFN]], {{.*}} ] // CHECK: %[[V15:.*]] = phi i64 [ 0, {{.*}} ], [ [[TYPEDISC0]], {{.*}} ] -// CHECK: call void %[[V14]](ptr noundef nonnull align {{[0-9]+}} dereferenceable(8) %[[V4]]) [ "ptrauth"(i32 0, i64 %[[V15]]) ] +// CHECK: call void %[[V14]](ptr noundef nonnull align {{[0-9]+}} dereferenceable(8) %[[V4]]) [ "ptrauth"(i64 0, i64 %[[V15]]) ] // CHECK: ret void void test1(Base0 *a0, MethodTy0 a1) { @@ -307,7 +301,7 @@ void test1(Base0 *a0, MethodTy0 a1) { // CXX17: define{{.*}} void @_Z14test1_noexceptP5Base0MS_DoFvvE( // CXX17: %[[V14:.*]] = phi ptr [ %{{.*}}, {{.*}} ], [ %{{.*}}, {{.*}} ] // CXX17: %[[V15:.*]] = phi i64 [ 0, {{.*}} ], [ [[TYPEDISC0]], {{.*}} ] -// CXX17: call void %[[V14]](ptr noundef nonnull align {{[0-9]+}} dereferenceable(8) %{{.*}}) {{.*}}[ "ptrauth"(i32 0, i64 %[[V15]]) ] +// CXX17: call void %[[V14]](ptr noundef nonnull align {{[0-9]+}} dereferenceable(8) %{{.*}}) {{.*}}[ "ptrauth"(i64 0, i64 %[[V15]]) ] #if __cplusplus >= 201703L void test1_noexcept(Base0 *a0, NoExceptMethodTy0 a1) { (a0->*a1)(); diff --git a/clang/test/CodeGenCXX/ptrauth-qualifier-struct.cpp b/clang/test/CodeGenCXX/ptrauth-qualifier-struct.cpp index 4f99db32537d6..163d45ce3dbfc 100644 --- a/clang/test/CodeGenCXX/ptrauth-qualifier-struct.cpp +++ b/clang/test/CodeGenCXX/ptrauth-qualifier-struct.cpp @@ -63,11 +63,9 @@ void testMoveConstructor(SA a) { // CHECK: %[[M02:.*]] = getelementptr inbounds nuw %[[STRUCT_SA]], ptr %[[V1]], i32 0, i32 0 // CHECK: %[[V2:.*]] = load ptr, ptr %[[M02]], align 8 // CHECK: %[[V3:.*]] = ptrtoint ptr %[[M02]] to i64 -// CHECK: %[[V4:.*]] = call i64 @llvm.ptrauth.blend(i64 %[[V3]], i64 50) // CHECK: %[[V5:.*]] = ptrtoint ptr %[[M0]] to i64 -// CHECK: %[[V6:.*]] = call i64 @llvm.ptrauth.blend(i64 %[[V5]], i64 50) // CHECK: %[[V8:.*]] = ptrtoint ptr %[[V2]] to i64 -// CHECK: %[[V9:.*]] = call i64 @llvm.ptrauth.resign(i64 %[[V8]]) [ "ptrauth"(i64 1, i64 %[[V4]]), "ptrauth"(i64 1, i64 %[[V6]]) ] +// CHECK: %[[V9:.*]] = call i64 @llvm.ptrauth.resign(i64 %[[V8]]) [ "ptrauth"(i64 1, i64 %[[V3]], i64 50), "ptrauth"(i64 1, i64 %[[V5]], i64 50) ] void testCopyAssignment(SA a) { SA t; @@ -88,11 +86,9 @@ void testCopyAssignment(SA a) { // CHECK: %[[M02:.*]] = getelementptr inbounds nuw %[[STRUCT_SA]], ptr %[[V1]], i32 0, i32 0 // CHECK: %[[V2:.*]] = load ptr, ptr %[[M02]], align 8 // CHECK: %[[V3:.*]] = ptrtoint ptr %[[M02]] to i64 -// CHECK: %[[V4:.*]] = call i64 @llvm.ptrauth.blend(i64 %[[V3]], i64 50) // CHECK: %[[V5:.*]] = ptrtoint ptr %[[M0]] to i64 -// CHECK: %[[V6:.*]] = call i64 @llvm.ptrauth.blend(i64 %[[V5]], i64 50) // CHECK: %[[V8:.*]] = ptrtoint ptr %[[V2]] to i64 -// CHECK: %[[V9:.*]] = call i64 @llvm.ptrauth.resign(i64 %[[V8]]) [ "ptrauth"(i64 1, i64 %[[V4]]), "ptrauth"(i64 1, i64 %[[V6]]) ] +// CHECK: %[[V9:.*]] = call i64 @llvm.ptrauth.resign(i64 %[[V8]]) [ "ptrauth"(i64 1, i64 %[[V3]], i64 50), "ptrauth"(i64 1, i64 %[[V5]], i64 50) ] void testMoveAssignment(SA a) { SA t; @@ -142,11 +138,9 @@ void testMoveAssignment(SI a) { // CHECK: %[[M02:.*]] = getelementptr inbounds nuw %[[STRUCT_SA]], ptr %[[V1]], i32 0, i32 0 // CHECK: %[[V2:.*]] = load ptr, ptr %[[M02]], align 8 // CHECK: %[[V3:.*]] = ptrtoint ptr %[[M02]] to i64 -// CHECK: %[[V4:.*]] = call i64 @llvm.ptrauth.blend(i64 %[[V3]], i64 50) // CHECK: %[[V5:.*]] = ptrtoint ptr %[[M0]] to i64 -// CHECK: %[[V6:.*]] = call i64 @llvm.ptrauth.blend(i64 %[[V5]], i64 50) // CHECK: %[[V8:.*]] = ptrtoint ptr %[[V2]] to i64 -// CHECK: %[[V9:.*]] = call i64 @llvm.ptrauth.resign(i64 %[[V8]]) [ "ptrauth"(i64 1, i64 %[[V4]]), "ptrauth"(i64 1, i64 %[[V6]]) ] +// CHECK: %[[V9:.*]] = call i64 @llvm.ptrauth.resign(i64 %[[V8]]) [ "ptrauth"(i64 1, i64 %[[V3]], i64 50), "ptrauth"(i64 1, i64 %[[V5]], i64 50) ] // CHECK: define linkonce_odr {{.*}}@_ZN2SAC2EOS_(ptr noundef nonnull align 8 dereferenceable(16) %[[THIS:.*]], ptr noundef nonnull align 8 dereferenceable(16) %0) // IOS: %[[RETVAL:.*]] = alloca ptr, align 8 @@ -161,8 +155,6 @@ void testMoveAssignment(SI a) { // CHECK: %[[M02:.*]] = getelementptr inbounds nuw %[[STRUCT_SA]], ptr %[[V1]], i32 0, i32 0 // CHECK: %[[V2:.*]] = load ptr, ptr %[[M02]], align 8 // CHECK: %[[V3:.*]] = ptrtoint ptr %[[M02]] to i64 -// CHECK: %[[V4:.*]] = call i64 @llvm.ptrauth.blend(i64 %[[V3]], i64 50) // CHECK: %[[V5:.*]] = ptrtoint ptr %[[M0]] to i64 -// CHECK: %[[V6:.*]] = call i64 @llvm.ptrauth.blend(i64 %[[V5]], i64 50) // CHECK: %[[V8:.*]] = ptrtoint ptr %[[V2]] to i64 -// CHECK: %[[V9:.*]] = call i64 @llvm.ptrauth.resign(i64 %[[V8]]) [ "ptrauth"(i64 1, i64 %[[V4]]), "ptrauth"(i64 1, i64 %[[V6]]) ] +// CHECK: %[[V9:.*]] = call i64 @llvm.ptrauth.resign(i64 %[[V8]]) [ "ptrauth"(i64 1, i64 %[[V3]], i64 50), "ptrauth"(i64 1, i64 %[[V5]], i64 50) ] diff --git a/clang/test/CodeGenCXX/ptrauth-throw.cpp b/clang/test/CodeGenCXX/ptrauth-throw.cpp index 0e6091a370223..c347ea470f6ca 100644 --- a/clang/test/CodeGenCXX/ptrauth-throw.cpp +++ b/clang/test/CodeGenCXX/ptrauth-throw.cpp @@ -22,10 +22,10 @@ void f() { // __cxa_throw is defined to take its destructor as "void (*)(void *)" in the ABI. // CHECK-LABEL: define{{.*}} void @__cxa_throw({{.*}}) -// CHECK: call void {{%.*}}(ptr noundef {{%.*}}) [ "ptrauth"(i32 0, i64 0) ] +// CHECK: call void {{%.*}}(ptr noundef {{%.*}}) [ "ptrauth"(i64 0, i64 0) ] // CHECKDISC-LABEL: define{{.*}} void @__cxa_throw({{.*}}) -// CHECKDISC: call void {{%.*}}(ptr noundef {{%.*}}) [ "ptrauth"(i32 0, i64 10942) ] +// CHECKDISC: call void {{%.*}}(ptr noundef {{%.*}}) [ "ptrauth"(i64 0, i64 10942) ] extern "C" void __cxa_throw(void *exception, void *, void (*dtor)(void *)) { dtor(exception); diff --git a/clang/test/CodeGenCXX/ptrauth-type-info-vtable.cpp b/clang/test/CodeGenCXX/ptrauth-type-info-vtable.cpp index 73bab580019aa..d678f03c9c9b2 100644 --- a/clang/test/CodeGenCXX/ptrauth-type-info-vtable.cpp +++ b/clang/test/CodeGenCXX/ptrauth-type-info-vtable.cpp @@ -92,9 +92,8 @@ extern "C" void test_vtable(std::type_info* t) { // DISC: [[T:%.*]] = load ptr, ptr [[T_ADDR]], align 8 // DISC: [[VPTR:%.*]] = load ptr, ptr [[T]], align 8 // DISC: [[ADDR:%.*]] = ptrtoint ptr [[T]] to i64 -// DISC: [[DISCRIMINATOR:%.*]] = call i64 @llvm.ptrauth.blend(i64 [[ADDR]], i64 [[STDTYPEINFO_DISC]]) // DISC: [[VPTRI:%.*]] = ptrtoint ptr [[VPTR]] to i64 -// DISC: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VPTRI]]) [ "ptrauth"(i64 2, i64 [[DISCRIMINATOR]]) ] +// DISC: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VPTRI]]) [ "ptrauth"(i64 2, i64 [[ADDR]], i64 [[STDTYPEINFO_DISC]]) ] extern "C" const void *ensure_typeinfo() { return new TestStruct; diff --git a/clang/test/CodeGenCXX/ptrauth-virtual-function.cpp b/clang/test/CodeGenCXX/ptrauth-virtual-function.cpp index a13dc235b2ef2..7df5453e8529a 100644 --- a/clang/test/CodeGenCXX/ptrauth-virtual-function.cpp +++ b/clang/test/CodeGenCXX/ptrauth-virtual-function.cpp @@ -203,8 +203,7 @@ V1::~V1() { // CHECK: %[[VFN:[a-z]+]] = getelementptr inbounds ptr, ptr %[[T4]], i64 0 // CHECK: %[[T5:[0-9]+]] = load ptr, ptr %[[VFN]] // CHECK: %[[T6:[0-9]+]] = ptrtoint ptr %[[VFN]] to i64 -// CHECK: %[[T7:[0-9]+]] = call i64 @llvm.ptrauth.blend(i64 %[[T6]], i64 53119) -// CHECK: call void %[[T5]](ptr noundef nonnull align {{[0-9]+}} dereferenceable(12) %{{.*}}) [ "ptrauth"(i32 0, i64 %[[T7]]) ] +// CHECK: call void %[[T5]](ptr noundef nonnull align {{[0-9]+}} dereferenceable(12) %{{.*}}) [ "ptrauth"(i64 0, i64 %[[T6]], i64 53119) ] void testB0m0(B0 *a) { a->m0(); @@ -218,8 +217,7 @@ void testB0m0(B0 *a) { // CHECK: %[[VFN:[a-z]+]] = getelementptr inbounds ptr, ptr %[[T4]], i64 1 // CHECK: %[[T5:[0-9]+]] = load ptr, ptr %[[VFN]] // CHECK: %[[T6:[0-9]+]] = ptrtoint ptr %[[VFN]] to i64 -// CHECK: %[[T7:[0-9]+]] = call i64 @llvm.ptrauth.blend(i64 %[[T6]], i64 15165) -// CHECK: call noundef ptr %[[T5]](ptr noundef nonnull align {{[0-9]+}} dereferenceable(12) %{{.*}}) [ "ptrauth"(i32 0, i64 %[[T7]]) ] +// CHECK: call noundef ptr %[[T5]](ptr noundef nonnull align {{[0-9]+}} dereferenceable(12) %{{.*}}) [ "ptrauth"(i64 0, i64 %[[T6]], i64 15165) ] void testB0m1(B0 *a) { a->m1(); @@ -233,8 +231,7 @@ void testB0m1(B0 *a) { // CHECK: %[[VFN:[a-z]+]] = getelementptr inbounds ptr, ptr %[[T4]], i64 2 // CHECK: %[[T5:[0-9]+]] = load ptr, ptr %[[VFN]] // CHECK: %[[T6:[0-9]+]] = ptrtoint ptr %[[VFN]] to i64 -// CHECK: %[[T7:[0-9]+]] = call i64 @llvm.ptrauth.blend(i64 %[[T6]], i64 43073) -// CHECK: call void %[[T5]](ptr noundef nonnull align {{[0-9]+}} dereferenceable(12) %{{.*}}) [ "ptrauth"(i32 0, i64 %[[T7]]) ] +// CHECK: call void %[[T5]](ptr noundef nonnull align {{[0-9]+}} dereferenceable(12) %{{.*}}) [ "ptrauth"(i64 0, i64 %[[T6]], i64 43073) ] void testB0m2(B0 *a) { a->m2(); @@ -248,8 +245,7 @@ void testB0m2(B0 *a) { // CHECK: %[[VFN:[a-z]+]] = getelementptr inbounds ptr, ptr %[[T4]], i64 0 // CHECK: %[[T5:[0-9]+]] = load ptr, ptr %[[VFN]] // CHECK: %[[T6:[0-9]+]] = ptrtoint ptr %[[VFN]] to i64 -// CHECK: %[[T7:[0-9]+]] = call i64 @llvm.ptrauth.blend(i64 %[[T6]], i64 53119) -// CHECK: call void %[[T5]](ptr noundef nonnull align {{[0-9]+}} dereferenceable(16) %{{.*}}) [ "ptrauth"(i32 0, i64 %[[T7]]) ] +// CHECK: call void %[[T5]](ptr noundef nonnull align {{[0-9]+}} dereferenceable(16) %{{.*}}) [ "ptrauth"(i64 0, i64 %[[T6]], i64 53119) ] void testD0m0(D0 *a) { a->m0(); @@ -263,8 +259,7 @@ void testD0m0(D0 *a) { // CHECK: %[[VFN:[a-z]+]] = getelementptr inbounds ptr, ptr %[[T4]], i64 5 // CHECK: %[[T5:[0-9]+]] = load ptr, ptr %[[VFN]] // CHECK: %[[T6:[0-9]+]] = ptrtoint ptr %[[VFN]] to i64 -// CHECK: %[[T7:[0-9]+]] = call i64 @llvm.ptrauth.blend(i64 %[[T6]], i64 35045) -// CHECK: call noundef ptr %[[T5]](ptr noundef nonnull align {{[0-9]+}} dereferenceable(16) %{{.*}}) [ "ptrauth"(i32 0, i64 %[[T7]]) ] +// CHECK: call noundef ptr %[[T5]](ptr noundef nonnull align {{[0-9]+}} dereferenceable(16) %{{.*}}) [ "ptrauth"(i64 0, i64 %[[T6]], i64 35045) ] void testD0m1(D0 *a) { a->m1(); @@ -278,8 +273,7 @@ void testD0m1(D0 *a) { // CHECK: %[[VFN:[a-z]+]] = getelementptr inbounds ptr, ptr %[[T4]], i64 2 // CHECK: %[[T5:[0-9]+]] = load ptr, ptr %[[VFN]] // CHECK: %[[T6:[0-9]+]] = ptrtoint ptr %[[VFN]] to i64 -// CHECK: %[[T7:[0-9]+]] = call i64 @llvm.ptrauth.blend(i64 %[[T6]], i64 43073) -// CHECK: call void %[[T5]](ptr noundef nonnull align {{[0-9]+}} dereferenceable(12) %{{.*}}) [ "ptrauth"(i32 0, i64 %[[T7]]) ] +// CHECK: call void %[[T5]](ptr noundef nonnull align {{[0-9]+}} dereferenceable(12) %{{.*}}) [ "ptrauth"(i64 0, i64 %[[T6]], i64 43073) ] void testD0m2(D0 *a) { a->m2(); @@ -293,8 +287,7 @@ void testD0m2(D0 *a) { // CHECK: %[[VFN:[a-z]+]] = getelementptr inbounds ptr, ptr %[[T4]], i64 6 // CHECK: %[[T5:[0-9]+]] = load ptr, ptr %[[VFN]] // CHECK: %[[T6:[0-9]+]] = ptrtoint ptr %[[VFN]] to i64 -// CHECK: %[[T7:[0-9]+]] = call i64 @llvm.ptrauth.blend(i64 %[[T6]], i64 10565) -// CHECK: call void %[[T5]](ptr noundef nonnull align {{[0-9]+}} dereferenceable(16) %{{.*}}) [ "ptrauth"(i32 0, i64 %[[T7]]) ] +// CHECK: call void %[[T5]](ptr noundef nonnull align {{[0-9]+}} dereferenceable(16) %{{.*}}) [ "ptrauth"(i64 0, i64 %[[T6]], i64 10565) ] void testD0m3(D0 *a) { a->m3(); @@ -309,8 +302,7 @@ void testD0m3(D0 *a) { // CHECK: %[[VFN:[a-z]+]] = getelementptr inbounds ptr, ptr %[[T4]], i64 0 // CHECK: %[[T5:[0-9]+]] = load ptr, ptr %[[VFN]] // CHECK: %[[T6:[0-9]+]] = ptrtoint ptr %[[VFN]] to i64 -// CHECK: %[[T7:[0-9]+]] = call i64 @llvm.ptrauth.blend(i64 %[[T6]], i64 53119) -// CHECK: call void %[[T5]](ptr noundef nonnull align {{[0-9]+}} dereferenceable(16) %{{.*}}) [ "ptrauth"(i32 0, i64 %[[T7]]) ] +// CHECK: call void %[[T5]](ptr noundef nonnull align {{[0-9]+}} dereferenceable(16) %{{.*}}) [ "ptrauth"(i64 0, i64 %[[T6]], i64 53119) ] void testD1m0(D1 *a) { a->m0(); @@ -324,8 +316,7 @@ void testD1m0(D1 *a) { // CHECK: %[[VFN:[a-z]+]] = getelementptr inbounds ptr, ptr %[[T4]], i64 5 // CHECK: %[[T5:[0-9]+]] = load ptr, ptr %[[VFN]] // CHECK: %[[T6:[0-9]+]] = ptrtoint ptr %[[VFN]] to i64 -// CHECK: %[[T7:[0-9]+]] = call i64 @llvm.ptrauth.blend(i64 %[[T6]], i64 52864) -// CHECK: call noundef ptr %[[T5]](ptr noundef nonnull align {{[0-9]+}} dereferenceable(16) %{{.*}}) [ "ptrauth"(i32 0, i64 %[[T7]]) ] +// CHECK: call noundef ptr %[[T5]](ptr noundef nonnull align {{[0-9]+}} dereferenceable(16) %{{.*}}) [ "ptrauth"(i64 0, i64 %[[T6]], i64 52864) ] void testD1m1(D1 *a) { a->m1(); @@ -339,8 +330,7 @@ void testD1m1(D1 *a) { // CHECK: %[[VFN:[a-z]+]] = getelementptr inbounds ptr, ptr %[[T4]], i64 2 // CHECK: %[[T5:[0-9]+]] = load ptr, ptr %[[VFN]] // CHECK: %[[T6:[0-9]+]] = ptrtoint ptr %[[VFN]] to i64 -// CHECK: %[[T7:[0-9]+]] = call i64 @llvm.ptrauth.blend(i64 %[[T6]], i64 43073) -// CHECK: call void %[[T5]](ptr noundef nonnull align {{[0-9]+}} dereferenceable(12) %{{.*}}) [ "ptrauth"(i32 0, i64 %[[T7]]) ] +// CHECK: call void %[[T5]](ptr noundef nonnull align {{[0-9]+}} dereferenceable(12) %{{.*}}) [ "ptrauth"(i64 0, i64 %[[T6]], i64 43073) ] void testD1m2(D1 *a) { a->m2(); @@ -355,8 +345,7 @@ void testD1m2(D1 *a) { // CHECK: %[[VFN:[a-z]+]] = getelementptr inbounds ptr, ptr %[[T4]], i64 0 // CHECK: %[[T5:[0-9]+]] = load ptr, ptr %[[VFN]] // CHECK: %[[T6:[0-9]+]] = ptrtoint ptr %[[VFN]] to i64 -// CHECK: %[[T7:[0-9]+]] = call i64 @llvm.ptrauth.blend(i64 %[[T6]], i64 53119) -// CHECK: call void %[[T5]](ptr noundef nonnull align {{[0-9]+}} dereferenceable(36) %{{.*}}) [ "ptrauth"(i32 0, i64 %[[T7]]) ] +// CHECK: call void %[[T5]](ptr noundef nonnull align {{[0-9]+}} dereferenceable(36) %{{.*}}) [ "ptrauth"(i64 0, i64 %[[T6]], i64 53119) ] void testD2m0(D2 *a) { a->m0(); @@ -370,8 +359,7 @@ void testD2m0(D2 *a) { // CHECK: %[[VFN:[a-z]+]] = getelementptr inbounds ptr, ptr %[[T4]], i64 5 // CHECK: %[[T5:[0-9]+]] = load ptr, ptr %[[VFN]] // CHECK: %[[T6:[0-9]+]] = ptrtoint ptr %[[VFN]] to i64 -// CHECK: %[[T7:[0-9]+]] = call i64 @llvm.ptrauth.blend(i64 %[[T6]], i64 35045) -// CHECK: call noundef ptr %[[T5]](ptr noundef nonnull align {{[0-9]+}} dereferenceable(36) %{{.*}}) [ "ptrauth"(i32 0, i64 %[[T7]]) ] +// CHECK: call noundef ptr %[[T5]](ptr noundef nonnull align {{[0-9]+}} dereferenceable(36) %{{.*}}) [ "ptrauth"(i64 0, i64 %[[T6]], i64 35045) ] void testD2m1(D2 *a) { a->m1(); @@ -399,8 +387,7 @@ void testD2m2D1(D2 *a) { // CHECK: %[[VFN:[a-z]+]] = getelementptr inbounds ptr, ptr %[[T4]], i64 6 // CHECK: %[[T5:[0-9]+]] = load ptr, ptr %[[VFN]] // CHECK: %[[T6:[0-9]+]] = ptrtoint ptr %[[VFN]] to i64 -// CHECK: %[[T7:[0-9]+]] = call i64 @llvm.ptrauth.blend(i64 %[[T6]], i64 10565) -// CHECK: call void %[[T5]](ptr noundef nonnull align {{[0-9]+}} dereferenceable(36) %{{.*}}) [ "ptrauth"(i32 0, i64 %[[T7]]) ] +// CHECK: call void %[[T5]](ptr noundef nonnull align {{[0-9]+}} dereferenceable(36) %{{.*}}) [ "ptrauth"(i64 0, i64 %[[T6]], i64 10565) ] void testD2m3(D2 *a) { a->m3(); @@ -414,8 +401,7 @@ void testD2m3(D2 *a) { // CHECK: %[[VFN:[a-z]+]] = getelementptr inbounds ptr, ptr %[[T4]], i64 0 // CHECK: %[[T5:[0-9]+]] = load ptr, ptr %[[VFN]] // CHECK: %[[T6:[0-9]+]] = ptrtoint ptr %[[VFN]] to i64 -// CHECK: %[[T7:[0-9]+]] = call i64 @llvm.ptrauth.blend(i64 %[[T6]], i64 44578) -// CHECK: call void %[[T5]](ptr noundef nonnull align {{[0-9]+}} dereferenceable(32) %{{.*}}) [ "ptrauth"(i32 0, i64 %[[T7]]) ] +// CHECK: call void %[[T5]](ptr noundef nonnull align {{[0-9]+}} dereferenceable(32) %{{.*}}) [ "ptrauth"(i64 0, i64 %[[T6]], i64 44578) ] void testD3m0(D3 *a) { a->m0(); @@ -429,8 +415,7 @@ void testD3m0(D3 *a) { // CHECK: %[[VFN:[a-z]+]] = getelementptr inbounds ptr, ptr %[[T4]], i64 1 // CHECK: %[[T5:[0-9]+]] = load ptr, ptr %[[VFN]] // CHECK: %[[T6:[0-9]+]] = ptrtoint ptr %[[VFN]] to i64 -// CHECK: %[[T7:[0-9]+]] = call i64 @llvm.ptrauth.blend(i64 %[[T6]], i64 30766) -// CHECK: call noundef ptr %[[T5]](ptr noundef nonnull align {{[0-9]+}} dereferenceable(32) %{{.*}}) [ "ptrauth"(i32 0, i64 %[[T7]]) ] +// CHECK: call noundef ptr %[[T5]](ptr noundef nonnull align {{[0-9]+}} dereferenceable(32) %{{.*}}) [ "ptrauth"(i64 0, i64 %[[T6]], i64 30766) ] void testD3m1(D3 *a) { a->m1(); @@ -454,8 +439,7 @@ void testD3m1(D3 *a) { // CHECK: %[[VFN:.*]] = getelementptr inbounds ptr, ptr %[[V6]], i64 2 // CHECK: %[[V7:.*]] = load ptr, ptr %[[VFN]], align 8 // CHECK: %[[V8:.*]] = ptrtoint ptr %[[VFN]] to i64 -// CHECK: %[[V9:.*]] = call i64 @llvm.ptrauth.blend(i64 %[[V8]], i64 43073) -// CHECK: call void %[[V7]](ptr noundef nonnull align 8 dereferenceable(12) %[[ADD_PTR]]) [ "ptrauth"(i32 0, i64 %[[V9]]) ] +// CHECK: call void %[[V7]](ptr noundef nonnull align 8 dereferenceable(12) %[[ADD_PTR]]) [ "ptrauth"(i64 0, i64 %[[V8]], i64 43073) ] void testD3m2(D3 *a) { a->m2(); @@ -470,8 +454,7 @@ void testD3m2(D3 *a) { // CHECK: %[[VFN:[a-z]+]] = getelementptr inbounds ptr, ptr %[[T4]], i64 3 // CHECK: %[[T5:[0-9]+]] = load ptr, ptr %[[VFN]] // CHECK: %[[T6:[0-9]+]] = ptrtoint ptr %[[VFN]] to i64 -// CHECK: %[[T7:[0-9]+]] = call i64 @llvm.ptrauth.blend(i64 %[[T6]], i64 62452) -// CHECK: call void %[[T5]](ptr noundef nonnull align {{[0-9]+}} dereferenceable(32) %{{.*}}) #{{.*}} [ "ptrauth"(i32 0, i64 %[[T7]]) ] +// CHECK: call void %[[T5]](ptr noundef nonnull align {{[0-9]+}} dereferenceable(32) %{{.*}}) #{{.*}} [ "ptrauth"(i64 0, i64 %[[T6]], i64 62452) ] void testD3Destructor0(D3 *a) { delete a; @@ -493,9 +476,8 @@ void testD3Destructor0(D3 *a) { // CHECK: %[[VFN:[a-z0-9]+]] = getelementptr inbounds ptr, ptr %[[T11]], i64 2 // CHECK: %[[T12:[0-9]+]] = load ptr, ptr %[[VFN]] // CHECK: %[[T13:[0-9]+]] = ptrtoint ptr %[[VFN]] to i64 -// CHECK: %[[T14:[0-9]+]] = call i64 @llvm.ptrauth.blend(i64 %[[T13]], i64 57279) -// DARWIN: %call = call noundef ptr %[[T12]](ptr noundef nonnull align {{[0-9]+}} dereferenceable(32) %{{.*}}) #{{.*}} [ "ptrauth"(i32 0, i64 %[[T14]]) ] -// ELF: call void %[[T12]](ptr noundef nonnull align {{[0-9]+}} dereferenceable(32) %{{.*}}) #{{.*}} [ "ptrauth"(i32 0, i64 %[[T14]]) ] +// DARWIN: %call = call noundef ptr %[[T12]](ptr noundef nonnull align {{[0-9]+}} dereferenceable(32) %{{.*}}) #{{.*}} [ "ptrauth"(i64 0, i64 %[[T13]], i64 57279) ] +// ELF: call void %[[T12]](ptr noundef nonnull align {{[0-9]+}} dereferenceable(32) %{{.*}}) #{{.*}} [ "ptrauth"(i64 0, i64 %[[T13]], i64 57279) ] // CHECK: call void @_ZdlPv(ptr noundef %[[T7]]) void testD3Destructor1(D3 *a) { @@ -511,9 +493,8 @@ void testD3Destructor1(D3 *a) { // CHECK: %[[VFN:.*]] = getelementptr inbounds ptr, ptr %[[T4]], i64 2 // CHECK: %[[T5:.*]] = load ptr, ptr %[[VFN]] // CHECK: %[[T6:.*]] = ptrtoint ptr %[[VFN]] to i64 -// CHECK: %[[T7:.*]] = call i64 @llvm.ptrauth.blend(i64 %[[T6]], i64 57279) -// DARWIN: %call = call noundef ptr %[[T5]](ptr noundef nonnull align {{[0-9]+}} dereferenceable(32) %{{.*}}) #{{.*}} [ "ptrauth"(i32 0, i64 %[[T7]]) ] -// ELF: call void %[[T5]](ptr noundef nonnull align {{[0-9]+}} dereferenceable(32) %{{.*}}) #{{.*}} [ "ptrauth"(i32 0, i64 %[[T7]]) ] +// DARWIN: %call = call noundef ptr %[[T5]](ptr noundef nonnull align {{[0-9]+}} dereferenceable(32) %{{.*}}) #{{.*}} [ "ptrauth"(i64 0, i64 %[[T6]], i64 57279) ] +// ELF: call void %[[T5]](ptr noundef nonnull align {{[0-9]+}} dereferenceable(32) %{{.*}}) #{{.*}} [ "ptrauth"(i64 0, i64 %[[T6]], i64 57279) ] void testD3Destructor2(D3 *a) { a->~D3(); diff --git a/clang/test/CodeGenCXX/ptrauth.cpp b/clang/test/CodeGenCXX/ptrauth.cpp index b0c069f43969b..a2fc418f306ff 100644 --- a/clang/test/CodeGenCXX/ptrauth.cpp +++ b/clang/test/CodeGenCXX/ptrauth.cpp @@ -5,7 +5,7 @@ void f(void); auto &f_ref = f; // CHECK: define {{(dso_local )?}}void @_Z1gv( -// CHECK: call void ptrauth (ptr @_Z1fv, i32 0)() [ "ptrauth"(i32 0, i64 0) ] +// CHECK: call void ptrauth (ptr @_Z1fv, i32 0)() [ "ptrauth"(i64 0, i64 0) ] void g() { f_ref(); } diff --git a/clang/test/CodeGenCXX/ubsan-vtable-checks.cpp b/clang/test/CodeGenCXX/ubsan-vtable-checks.cpp index e5845e7da5b78..c0a6cccb27725 100644 --- a/clang/test/CodeGenCXX/ubsan-vtable-checks.cpp +++ b/clang/test/CodeGenCXX/ubsan-vtable-checks.cpp @@ -38,9 +38,8 @@ int get_v(T* t) { // CHECK-PTRAUTH: {{%.*}} = mul i64 [[STRIPPED_INT]], {{.*}} // Verify that we authenticate for the actual vcall - // CHECK-PTRAUTH: [[BLENDED:%.*]] = call i64 @llvm.ptrauth.blend(i64 {{%.*}}, i64 17113) // CHECK-PTRAUTH: [[CAST_VTABLE:%.*]] = ptrtoint ptr %vtable2 to i64 - // CHECK-PTRAUTH: [[AUTHED_INT:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[CAST_VTABLE]]) [ "ptrauth"(i64 2, i64 [[BLENDED]]) ] + // CHECK-PTRAUTH: [[AUTHED_INT:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[CAST_VTABLE]]) [ "ptrauth"(i64 2, i64 {{%.*}}, i64 17113) ] // CHECK-PTRAUTH: [[AUTHED_PTR:%.*]] = inttoptr i64 [[AUTHED_INT]] to ptr // CHECK-PTRAUTH: {{%.*}} = getelementptr inbounds ptr, ptr [[AUTHED_PTR]], i64 2 return t->v(); @@ -66,9 +65,8 @@ void delete_it(T *t) { // Second, we check that vtable is actually loaded once the type check is done. // ptrauth for the virtual function load // CHECK-PTRAUTH: [[VTABLE2:%.*]] = load ptr, ptr {{.*}} - // CHECK-PTRAUTH: [[BLENDED:%.*]] = call i64 @llvm.ptrauth.blend(i64 %{{.*}}, i64 17113) // CHECK-PTRAUTH: [[CAST_VTABLE:%.*]] = ptrtoint ptr [[VTABLE2]] to i64 - // CHECK-PTRAUTH: [[AUTHED_INT:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[CAST_VTABLE]]) [ "ptrauth"(i64 2, i64 [[BLENDED]]) ] + // CHECK-PTRAUTH: [[AUTHED_INT:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[CAST_VTABLE]]) [ "ptrauth"(i64 2, i64 %{{.*}}, i64 17113) ] // CHECK-PTRAUTH: [[AUTHED_PTR:%.*]] = inttoptr i64 [[AUTHED_INT]] to ptr // CHECK-PTRAUTH: getelementptr inbounds ptr, ptr // CHECK-PTRAUTH {{%.*}} = getelementptr inbounds ptr, ptr [[AUTHED_PTR]], i64 1 @@ -88,9 +86,8 @@ U* dyncast(T *t) { // CHECK-PTRAUTH: [[STRIPPED_INT:%.*]] = ptrtoint ptr [[STRIPPED_PTR]] to i64 // CHECK-PTRAUTH: {{%.*}} = mul i64 [[STRIPPED_INT]], {{.*}} // CHECK-VPTR: call void @__ubsan_handle_dynamic_type_cache_miss_abort - // CHECK-PTRAUTH: [[BLENDED:%.*]] = call i64 @llvm.ptrauth.blend(i64 {{%.*}}, i64 17113) // CHECK-PTRAUTH: [[CAST_VTABLE:%.*]] = ptrtoint ptr %vtable1 to i64 - // CHECK-PTRAUTH: [[AUTHED_INT:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[CAST_VTABLE]]) [ "ptrauth"(i64 2, i64 [[BLENDED]]) ] + // CHECK-PTRAUTH: [[AUTHED_INT:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[CAST_VTABLE]]) [ "ptrauth"(i64 2, i64 {{%.*}}, i64 17113) ] // CHECK-PTRAUTH: [[AUTHED_PTR:%.*]] = inttoptr i64 [[AUTHED_INT]] to ptr // CHECK-PTRAUTH: {{%.*}} = load volatile i8, ptr [[AUTHED_PTR]], align 8 // Second, we check that dynamic_cast is actually called once the type check is done. diff --git a/clang/test/CodeGenObjC/ptrauth-block-descriptor-pointer.m b/clang/test/CodeGenObjC/ptrauth-block-descriptor-pointer.m index 32cba9ff77034..aa459e9397fa2 100644 --- a/clang/test/CodeGenObjC/ptrauth-block-descriptor-pointer.m +++ b/clang/test/CodeGenObjC/ptrauth-block-descriptor-pointer.m @@ -28,8 +28,7 @@ void b(int p) { // CHECK: [[BLOCK:%.*]] = alloca <{ ptr, i32, i32, ptr, ptr, i32 }> // CHECK: [[BLOCK_DESCRIPTOR_REF:%.*]] = getelementptr inbounds nuw <{ {{.*}} }>, ptr [[BLOCK]], i32 0, i32 4 // CHECK: [[BLOCK_DESCRIPTOR_REF_INT:%.*]] = ptrtoint ptr [[BLOCK_DESCRIPTOR_REF]] to i64 - // CHECK: [[BLENDED:%.*]] = call i64 @llvm.ptrauth.blend(i64 [[BLOCK_DESCRIPTOR_REF_INT]], i64 49339) - // CHECK: [[SIGNED_REF:%.*]] = call i64 @llvm.ptrauth.sign(i64 ptrtoint (ptr @"__block_descriptor_36_e5_v8\01?0l" to i64)) [ "ptrauth"(i64 2, i64 [[BLENDED]]) ] + // CHECK: [[SIGNED_REF:%.*]] = call i64 @llvm.ptrauth.sign(i64 ptrtoint (ptr @"__block_descriptor_36_e5_v8\01?0l" to i64)) [ "ptrauth"(i64 2, i64 [[BLOCK_DESCRIPTOR_REF_INT]], i64 49339) ] // CHECK: [[SIGNED_REF_PTR:%.*]] = inttoptr i64 [[SIGNED_REF]] to ptr // CHECK: store ptr [[SIGNED_REF_PTR]], ptr [[BLOCK_DESCRIPTOR_REF]] diff --git a/clang/test/CodeGenObjC/ptrauth-block-isa.m b/clang/test/CodeGenObjC/ptrauth-block-isa.m index 7904274300c09..3f8e527ccb3a4 100644 --- a/clang/test/CodeGenObjC/ptrauth-block-isa.m +++ b/clang/test/CodeGenObjC/ptrauth-block-isa.m @@ -16,8 +16,7 @@ void test_block_literal(int i) { // CHECK-NEXT: [[BLOCK:%.*]] = alloca [[BLOCK_T:.*]], align // CHECK: [[ISAPTRADDR:%.*]] = getelementptr inbounds nuw [[BLOCK_T]], ptr [[BLOCK]], i32 0, i32 0 // CHECK-NEXT: [[ISAPTRADDR_I:%.*]] = ptrtoint ptr [[ISAPTRADDR]] to i64 - // CHECK-NEXT: [[ISADISCRIMINATOR:%.*]] = call i64 @llvm.ptrauth.blend(i64 [[ISAPTRADDR_I]], i64 27361) - // CHECK-NEXT: [[SIGNEDISA:%.*]] = call i64 @llvm.ptrauth.sign(i64 ptrtoint (ptr @_NSConcreteStackBlock to i64)) [ "ptrauth"(i64 2, i64 [[ISADISCRIMINATOR]]) ] + // CHECK-NEXT: [[SIGNEDISA:%.*]] = call i64 @llvm.ptrauth.sign(i64 ptrtoint (ptr @_NSConcreteStackBlock to i64)) [ "ptrauth"(i64 2, i64 [[ISAPTRADDR_I]], i64 27361) ] // CHECK-NEXT: [[SIGNEDISAPTR:%.*]] = inttoptr i64 [[SIGNEDISA]] to ptr // CHECK-NEXT: store ptr [[SIGNEDISAPTR]], ptr [[ISAPTRADDR]] use_block(^{return i;}); @@ -31,8 +30,7 @@ void test_conversion(id a) { // CHECK-NEXT: [[BLOCK:%.*]] = alloca [[BLOCK_T:.*]], align // CHECK: [[ISAPTRADDR:%.*]] = getelementptr inbounds nuw [[BLOCK_T]], ptr [[BLOCK]], i32 0, i32 0 // CHECK-NEXT: [[ISAPTRADDR_I:%.*]] = ptrtoint ptr [[ISAPTRADDR]] to i64 - // CHECK-NEXT: [[ISADISCRIMINATOR:%.*]] = call i64 @llvm.ptrauth.blend(i64 [[ISAPTRADDR_I]], i64 27361) - // CHECK-NEXT: [[SIGNEDISA:%.*]] = call i64 @llvm.ptrauth.sign(i64 ptrtoint (ptr @_NSConcreteStackBlock to i64)) [ "ptrauth"(i64 2, i64 [[ISADISCRIMINATOR]]) ] + // CHECK-NEXT: [[SIGNEDISA:%.*]] = call i64 @llvm.ptrauth.sign(i64 ptrtoint (ptr @_NSConcreteStackBlock to i64)) [ "ptrauth"(i64 2, i64 [[ISAPTRADDR_I]], i64 27361) ] // CHECK-NEXT: [[SIGNEDISAPTR:%.*]] = inttoptr i64 [[SIGNEDISA]] to ptr // CHECK-NEXT: store ptr [[SIGNEDISAPTR]], ptr [[ISAPTRADDR]] test_conversion_helper(^{ diff --git a/clang/test/CodeGenObjC/ptrauth-class.m b/clang/test/CodeGenObjC/ptrauth-class.m index 78315159c7318..57422e7bdfd94 100644 --- a/clang/test/CodeGenObjC/ptrauth-class.m +++ b/clang/test/CodeGenObjC/ptrauth-class.m @@ -32,9 +32,8 @@ void setTestStructIsa(struct TestStruct *t, Class c) { // CHECK: [[ISA_SLOT:%.*]] = getelementptr inbounds nuw %struct.TestStruct, ptr %0, i32 0, i32 0 // CHECK: [[C:%.*]] = load ptr, ptr %c.addr, align 8 // CHECK: [[CAST_ISA_SLOT:%.*]] = ptrtoint ptr [[ISA_SLOT]] to i64 - // CHECK: [[BLENDED_VALUE:%.*]] = call i64 @llvm.ptrauth.blend(i64 [[CAST_ISA_SLOT]], i64 1234) // CHECK: [[CAST_C:%.*]] = ptrtoint ptr [[C]] to i64 - // CHECK: [[AUTHENTICATED:%.*]] = call i64 @llvm.ptrauth.sign(i64 [[CAST_C]]) [ "ptrauth"(i64 2, i64 [[BLENDED_VALUE]]) ] + // CHECK: [[AUTHENTICATED:%.*]] = call i64 @llvm.ptrauth.sign(i64 [[CAST_C]]) [ "ptrauth"(i64 2, i64 [[CAST_ISA_SLOT]], i64 1234) ] } // CHECK-LABEL: define void @setTestClassIsa(ptr %t, ptr %c) #0 { @@ -49,9 +48,8 @@ void setTestClassIsa(TestClass *t, Class c) { // CHECK: [[ADDED_PTR:%.*]] = getelementptr inbounds i8, ptr %1, i64 [[IVAR_OFFSET64]] // CHECK: [[C_VALUE:%.*]] = load ptr, ptr [[C_ADDR]], align 8 // CHECK: [[CAST_ISA_SLOT:%.*]] = ptrtoint ptr [[ADDED_PTR]] to i64 - // CHECK: [[BLENDED_VALUE:%.*]] = call i64 @llvm.ptrauth.blend(i64 [[CAST_ISA_SLOT]], i64 1234) // CHECK: [[CAST_C_VALUE:%.*]] = ptrtoint ptr [[C_VALUE]] to i64 - // CHECK: [[SIGNED:%.*]] = call i64 @llvm.ptrauth.sign(i64 [[CAST_C_VALUE]]) [ "ptrauth"(i64 2, i64 [[BLENDED_VALUE]]) ] + // CHECK: [[SIGNED:%.*]] = call i64 @llvm.ptrauth.sign(i64 [[CAST_C_VALUE]]) [ "ptrauth"(i64 2, i64 [[CAST_ISA_SLOT]], i64 1234) ] } // CHECK-LABEL: define ptr @getTestStructIsa(ptr %t) #0 { @@ -62,9 +60,8 @@ Class getTestStructIsa(struct TestStruct *t) { // CHECK: [[ISA_SLOT:%.*]] = getelementptr inbounds nuw %struct.TestStruct, ptr [[T_VALUE]], i32 0, i32 0 // CHECK: [[ISA_VALUE:%.*]] = load ptr, ptr [[ISA_SLOT]], align 8 // CHECK: [[CAST_ISA_SLOT:%.*]] = ptrtoint ptr %isa to i64 - // CHECK: [[BLENDED_VALUE:%.*]] = call i64 @llvm.ptrauth.blend(i64 [[CAST_ISA_SLOT]], i64 1234) // CHECK: [[CAST_ISA_VALUE:%.*]] = ptrtoint ptr [[ISA_VALUE]] to i64 - // CHECK: [[SIGNED_VALUE:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[CAST_ISA_VALUE]]) [ "ptrauth"(i64 2, i64 [[BLENDED_VALUE]]) ] + // CHECK: [[SIGNED_VALUE:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[CAST_ISA_VALUE]]) [ "ptrauth"(i64 2, i64 [[CAST_ISA_SLOT]], i64 1234) ] } // CHECK-LABEL: define ptr @getTestClassIsa(ptr %t) #0 { @@ -77,10 +74,9 @@ Class getTestClassIsa(TestClass *t) { // CHECK: [[ADD_PTR:%.*]] = getelementptr inbounds i8, ptr [[T]], i64 [[IVAR_CONV]] // CHECK: [[LOADED_VALUE:%.*]] = load ptr, ptr [[ADD_PTR]], align 8 // CHECK: [[INT_VALUE:%.*]] = ptrtoint ptr [[ADD_PTR]] to i64 - // CHECK: [[BLENDED_VALUE:%.*]] = call i64 @llvm.ptrauth.blend(i64 [[INT_VALUE]], i64 1234) // CHECK: [[NULL_CHECK:%.*]] = icmp ne ptr [[LOADED_VALUE]], null // CHECK: [[CAST_VALUE:%.*]] = ptrtoint ptr [[LOADED_VALUE]] to i64 - // CHECK: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[CAST_VALUE]]) [ "ptrauth"(i64 2, i64 [[BLENDED_VALUE]]) ] + // CHECK: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[CAST_VALUE]]) [ "ptrauth"(i64 2, i64 [[INT_VALUE]], i64 1234) ] } // Just enough to verify we do actually authenticate qualified Class @@ -94,10 +90,9 @@ Class getTestConstClassIsa(TestConstClass *t) { // CHECK: [[ADD_PTR:%.*]] = getelementptr inbounds i8, ptr [[T]], i64 [[IVAR_CONV]] // CHECK: [[LOADED_VALUE:%.*]] = load ptr, ptr [[ADD_PTR]], align 8 // CHECK: [[INT_VALUE:%.*]] = ptrtoint ptr [[ADD_PTR]] to i64 - // CHECK: [[BLENDED_VALUE:%.*]] = call i64 @llvm.ptrauth.blend(i64 [[INT_VALUE]], i64 1234) // CHECK: [[NULL_CHECK:%.*]] = icmp ne ptr [[LOADED_VALUE]], null // CHECK: [[CAST_VALUE:%.*]] = ptrtoint ptr [[LOADED_VALUE]] to i64 - // CHECK: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[CAST_VALUE]]) [ "ptrauth"(i64 2, i64 [[BLENDED_VALUE]]) ] + // CHECK: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[CAST_VALUE]]) [ "ptrauth"(i64 2, i64 [[INT_VALUE]], i64 1234) ] } #endif diff --git a/clang/test/CodeGenObjC/ptrauth-objc-interface-selector.m b/clang/test/CodeGenObjC/ptrauth-objc-interface-selector.m index dd62e12b747d1..e6e408810265a 100644 --- a/clang/test/CodeGenObjC/ptrauth-objc-interface-selector.m +++ b/clang/test/CodeGenObjC/ptrauth-objc-interface-selector.m @@ -31,44 +31,31 @@ @interface Test { @end // CHECK-AUTHENTICATED-SEL-LABEL: define internal ptr @"\01-[Test test:]" -// CHECK-AUTHENTICATED-SEL: {{%.*}} = call i64 @llvm.ptrauth.blend(i64 {{%.*}}, i64 22466) -// CHECK-AUTHENTICATED-SEL: {{%.*}} = call i64 @llvm.ptrauth.blend(i64 {{%.*}}, i64 22466) -// CHECK-AUTHENTICATED-SEL: {{%.*}} = call i64 @llvm.ptrauth.resign(i64 {{%.*}}) [ "ptrauth"(i64 3, i64 {{%.*}}), "ptrauth"(i64 3, i64 {{%.*}}) ] +// CHECK-AUTHENTICATED-SEL: {{%.*}} = call i64 @llvm.ptrauth.resign(i64 {{%.*}}) [ "ptrauth"(i64 3, i64 {{%.*}}, i64 22466), "ptrauth"(i64 3, i64 {{%.*}}, i64 22466) ] // CHECK-AUTHENTICATED-SEL: {{%.*}} = load volatile ptr, ptr {{%.*}}, align 8 -// CHECK-AUTHENTICATED-SEL: {{%.*}} = call i64 @llvm.ptrauth.blend(i64 {{%.*}}, i64 22466) -// CHECK-AUTHENTICATED-SEL: {{%.*}} = call i64 @llvm.ptrauth.blend(i64 {{%.*}}, i64 22466) -// CHECK-AUTHENTICATED-SEL: {{%.*}} = call i64 @llvm.ptrauth.resign(i64 {{%.*}}) [ "ptrauth"(i64 3, i64 {{%.*}}), "ptrauth"(i64 3, i64 {{%.*}}) ] -// CHECK-AUTHENTICATED-SEL: {{%.*}} = call i64 @llvm.ptrauth.blend(i64 {{%.*}}, i64 22467) +// CHECK-AUTHENTICATED-SEL: {{%.*}} = call i64 @llvm.ptrauth.resign(i64 {{%.*}}) [ "ptrauth"(i64 3, i64 {{%.*}}, i64 22466), "ptrauth"(i64 3, i64 {{%.*}}, i64 22466) ] // CHECK-AUTHENTICATED-SEL: {{%.*}} = ptrtoint ptr {{%.*}} to i64 -// CHECK-AUTHENTICATED-SEL: {{%.*}} = call i64 @llvm.ptrauth.blend(i64 {{%.*}}, i64 22467) // CHECK-AUTHENTICATED-SEL: {{%.*}} = ptrtoint ptr {{%.*}} to i64 -// CHECK-AUTHENTICATED-SEL: {{%.*}} = call i64 @llvm.ptrauth.resign(i64 {{%.*}}) [ "ptrauth"(i64 3, i64 {{%.*}}), "ptrauth"(i64 3, i64 {{%.*}}) ] -// CHECK-AUTHENTICATED-SEL: {{%.*}} = call i64 @llvm.ptrauth.blend(i64 {{%.*}}, i64 22466) -// CHECK-AUTHENTICATED-SEL: {{%.*}} = call i64 @llvm.ptrauth.auth(i64 {{%.*}}) [ "ptrauth"(i64 3, i64 {{%.*}}) ] +// CHECK-AUTHENTICATED-SEL: {{%.*}} = call i64 @llvm.ptrauth.resign(i64 {{%.*}}) [ "ptrauth"(i64 3, i64 {{%.*}}, i64 22467), "ptrauth"(i64 3, i64 {{%.*}}, i64 22467) ] +// CHECK-AUTHENTICATED-SEL: {{%.*}} = call i64 @llvm.ptrauth.auth(i64 {{%.*}}) [ "ptrauth"(i64 3, i64 {{%.*}}, i64 22466) ] // CHECK-AUTHENTICATED-SEL-LABEL: define internal ptr @"\01-[Test auto_sel_property]" -// CHECK-AUTHENTICATED-SEL: {{%.*}} = call i64 @llvm.ptrauth.blend(i64 {{%.*}}, i64 22466) -// CHECK-AUTHENTICATED-SEL: {{%.*}} = call i64 @llvm.ptrauth.auth(i64 {{%.*}}) [ "ptrauth"(i64 3, i64 {{%.*}}) ] +// CHECK-AUTHENTICATED-SEL: {{%.*}} = call i64 @llvm.ptrauth.auth(i64 {{%.*}}) [ "ptrauth"(i64 3, i64 {{%.*}}, i64 22466) ] // CHECK-AUTHENTICATED-SEL-LABEL: define internal void @"\01-[Test setAuto_sel_property:]" -// CHECK-AUTHENTICATED-SEL: {{%.*}} = call i64 @llvm.ptrauth.blend(i64 {{%.*}}, i64 22466) -// CHECK-AUTHENTICATED-SEL: {{%.*}} = call i64 @llvm.ptrauth.sign(i64 {{%.*}}) [ "ptrauth"(i64 3, i64 {{%.*}}) ] +// CHECK-AUTHENTICATED-SEL: {{%.*}} = call i64 @llvm.ptrauth.sign(i64 {{%.*}}) [ "ptrauth"(i64 3, i64 {{%.*}}, i64 22466) ] // CHECK-AUTHENTICATED-SEL-LABEL: define internal ptr @"\01-[Test const_auto_sel_property]" -// CHECK-AUTHENTICATED-SEL: {{%.*}} = call i64 @llvm.ptrauth.blend(i64 {{%.*}}, i64 22466) -// CHECK-AUTHENTICATED-SEL: {{%.*}} = call i64 @llvm.ptrauth.auth(i64 {{%.*}}) [ "ptrauth"(i64 3, i64 {{%.*}}) ] +// CHECK-AUTHENTICATED-SEL: {{%.*}} = call i64 @llvm.ptrauth.auth(i64 {{%.*}}) [ "ptrauth"(i64 3, i64 {{%.*}}, i64 22466) ] // CHECK-AUTHENTICATED-SEL-LABEL: define internal void @"\01-[Test setConst_auto_sel_property:]" -// CHECK-AUTHENTICATED-SEL: {{%.*}} = call i64 @llvm.ptrauth.blend(i64 {{%.*}}, i64 22466) -// CHECK-AUTHENTICATED-SEL: {{%.*}} = call i64 @llvm.ptrauth.sign(i64 {{%.*}}) [ "ptrauth"(i64 3, i64 {{%.*}}) ] +// CHECK-AUTHENTICATED-SEL: {{%.*}} = call i64 @llvm.ptrauth.sign(i64 {{%.*}}) [ "ptrauth"(i64 3, i64 {{%.*}}, i64 22466) ] // CHECK-AUTHENTICATED-SEL-LABEL: define internal ptr @"\01-[Test volatile_auto_sel_property]" -// CHECK-AUTHENTICATED-SEL: {{%.*}} = call i64 @llvm.ptrauth.blend(i64 {{%.*}}, i64 22466) -// CHECK-AUTHENTICATED-SEL: {{%.*}} = call i64 @llvm.ptrauth.auth(i64 {{%.*}}) [ "ptrauth"(i64 3, i64 {{%.*}}) ] +// CHECK-AUTHENTICATED-SEL: {{%.*}} = call i64 @llvm.ptrauth.auth(i64 {{%.*}}) [ "ptrauth"(i64 3, i64 {{%.*}}, i64 22466) ] // CHECK-AUTHENTICATED-SEL-LABEL: define internal void @"\01-[Test setVolatile_auto_sel_property:]" -// CHECK-AUTHENTICATED-SEL: {{%.*}} = call i64 @llvm.ptrauth.blend(i64 {{%.*}}, i64 22466) -// CHECK-AUTHENTICATED-SEL: {{%.*}} = call i64 @llvm.ptrauth.sign(i64 {{%.*}}) [ "ptrauth"(i64 3, i64 {{%.*}}) ] +// CHECK-AUTHENTICATED-SEL: {{%.*}} = call i64 @llvm.ptrauth.sign(i64 {{%.*}}) [ "ptrauth"(i64 3, i64 {{%.*}}, i64 22466) ] @implementation Test - (SEL)test:(Test *)in { @@ -88,11 +75,9 @@ void auto_sel(Test *out, Test *in) { // CHECK-AUTHENTICATED-SEL: [[V1:%.*]] = load ptr, ptr %in.addr // CHECK-AUTHENTICATED-SEL: [[DST_ADDR:%.*]] = getelementptr inbounds i8, ptr [[V1]], i64 0 // CHECK-AUTHENTICATED-SEL: [[CAST_DST_ADDR:%.*]] = ptrtoint ptr [[DST_ADDR]] to i64 -// CHECK-AUTHENTICATED-SEL: [[DST_DESCRIMINATOR:%.*]] = call i64 @llvm.ptrauth.blend(i64 [[CAST_DST_ADDR]], i64 22466) // CHECK-AUTHENTICATED-SEL: [[CAST_SRC_ADDR:%.*]] = ptrtoint ptr [[SRC_ADDR]] to i64 -// CHECK-AUTHENTICATED-SEL: [[SRC_DESCRIMINATOR:%.*]] = call i64 @llvm.ptrauth.blend(i64 [[CAST_SRC_ADDR]], i64 22466) // CHECK-AUTHENTICATED-SEL: [[SRC_SEL:%.*]] = ptrtoint ptr [[SRC_SEL_ADDR:%.*]] to i64 -// CHECK-AUTHENTICATED-SEL: {{%.*}} = call i64 @llvm.ptrauth.resign(i64 [[SRC_SEL]]) [ "ptrauth"(i64 3, i64 [[DST_DESCRIMINATOR]]), "ptrauth"(i64 3, i64 [[SRC_DESCRIMINATOR]]) ] +// CHECK-AUTHENTICATED-SEL: {{%.*}} = call i64 @llvm.ptrauth.resign(i64 [[SRC_SEL]]) [ "ptrauth"(i64 3, i64 [[CAST_DST_ADDR]], i64 22466), "ptrauth"(i64 3, i64 [[CAST_SRC_ADDR]], i64 22466) ] // CHECK-UNAUTHENTICATED-SEL-LABEL: define void @auto_sel SEL const_auto_sel(Test *in) { @@ -100,9 +85,8 @@ SEL const_auto_sel(Test *in) { } // CHECK-AUTHENTICATED-SEL-LABEL: define ptr @const_auto_sel -// CHECK-AUTHENTICATED-SEL: {{%.*}} = call i64 @llvm.ptrauth.blend(i64 {{%.*}}, i64 22466) // CHECK-AUTHENTICATED-SEL: {{%.*}} = ptrtoint ptr {{%.*}} to i64 -// CHECK-AUTHENTICATED-SEL: [[AUTHENTICATED:%.*]] = call i64 @llvm.ptrauth.auth(i64 {{%.*}}) [ "ptrauth"(i64 3, i64 {{%.*}}) ] +// CHECK-AUTHENTICATED-SEL: [[AUTHENTICATED:%.*]] = call i64 @llvm.ptrauth.auth(i64 {{%.*}}) [ "ptrauth"(i64 3, i64 {{%.*}}, i64 22466) ] // CHECK-AUTHENTICATED-SEL: [[RESULT:%.*]] = inttoptr i64 [[AUTHENTICATED]] to ptr void volatile_auto_sel(Test *out, Test *in) { @@ -115,11 +99,9 @@ void volatile_auto_sel(Test *out, Test *in) { // CHECK-AUTHENTICATED-SEL: [[V1:%.*]] = load ptr, ptr %in.addr // CHECK-AUTHENTICATED-SEL: [[DST_ADDR:%.*]] = getelementptr inbounds i8, ptr [[V1]], i64 16 // CHECK-AUTHENTICATED-SEL: [[CAST_DST_ADDR:%.*]] = ptrtoint ptr [[DST_ADDR]] to i64 -// CHECK-AUTHENTICATED-SEL: [[DST_DESCRIMINATOR:%.*]] = call i64 @llvm.ptrauth.blend(i64 [[CAST_DST_ADDR]], i64 22466) // CHECK-AUTHENTICATED-SEL: [[CAST_SRC_ADDR:%.*]] = ptrtoint ptr [[SRC_ADDR]] to i64 -// CHECK-AUTHENTICATED-SEL: [[SRC_DESCRIMINATOR:%.*]] = call i64 @llvm.ptrauth.blend(i64 [[CAST_SRC_ADDR]], i64 22466) // CHECK-AUTHENTICATED-SEL: [[SRC_SEL:%.*]] = ptrtoint ptr [[SRC_SEL_ADDR:%.*]] to i64 -// CHECK-AUTHENTICATED-SEL: {{%.*}} = call i64 @llvm.ptrauth.resign(i64 [[SRC_SEL]]) [ "ptrauth"(i64 3, i64 [[DST_DESCRIMINATOR]]), "ptrauth"(i64 3, i64 [[SRC_DESCRIMINATOR]]) ] +// CHECK-AUTHENTICATED-SEL: {{%.*}} = call i64 @llvm.ptrauth.resign(i64 [[SRC_SEL]]) [ "ptrauth"(i64 3, i64 [[CAST_DST_ADDR]], i64 22466), "ptrauth"(i64 3, i64 [[CAST_SRC_ADDR]], i64 22466) ] void manual(Test *out, Test *in) { out->manual = in->manual; @@ -131,11 +113,9 @@ void manual(Test *out, Test *in) { // CHECK-AUTHENTICATED-SEL: [[V0:%.*]] = load ptr, ptr %in.addr // CHECK-AUTHENTICATED-SEL: [[DST_ADDR:%.*]] = getelementptr inbounds i8, ptr [[V1]], i64 24 // CHECK-AUTHENTICATED-SEL: [[CAST_DST_ADDR:%.*]] = ptrtoint ptr [[DST_ADDR]] to i64 -// CHECK-AUTHENTICATED-SEL: [[DST_DESCRIMINATOR:%.*]] = call i64 @llvm.ptrauth.blend(i64 [[CAST_DST_ADDR]], i64 22467) // CHECK-AUTHENTICATED-SEL: [[CAST_SRC_ADDR:%.*]] = ptrtoint ptr [[SRC_ADDR]] to i64 -// CHECK-AUTHENTICATED-SEL: [[SRC_DESCRIMINATOR:%.*]] = call i64 @llvm.ptrauth.blend(i64 [[CAST_SRC_ADDR]], i64 22467) // CHECK-AUTHENTICATED-SEL: [[SRC_SEL:%.*]] = ptrtoint ptr [[SRC_SEL_ADDR:%.*]] to i64 -// CHECK-AUTHENTICATED-SEL: {{%.*}} = call i64 @llvm.ptrauth.resign(i64 [[SRC_SEL]]) [ "ptrauth"(i64 3, i64 [[DST_DESCRIMINATOR]]), "ptrauth"(i64 3, i64 [[SRC_DESCRIMINATOR]]) ] +// CHECK-AUTHENTICATED-SEL: {{%.*}} = call i64 @llvm.ptrauth.resign(i64 [[SRC_SEL]]) [ "ptrauth"(i64 3, i64 [[CAST_DST_ADDR]], i64 22467), "ptrauth"(i64 3, i64 [[CAST_SRC_ADDR]], i64 22467) ] // CHECK-UNAUTHENTICATED-SEL-LABEL: define void @manual // CHECK-UNAUTHENTICATED-SEL: [[V0:%.*]] = load ptr, ptr %out.addr @@ -143,8 +123,6 @@ void manual(Test *out, Test *in) { // CHECK-UNAUTHENTICATED-SEL: [[V1:%.*]] = load ptr, ptr %in.addr // CHECK-UNAUTHENTICATED-SEL: [[DST_ADDR:%.*]] = getelementptr inbounds i8, ptr [[V1]], i64 24 // CHECK-UNAUTHENTICATED-SEL: [[CAST_DST_ADDR:%.*]] = ptrtoint ptr [[DST_ADDR]] to i64 -// CHECK-UNAUTHENTICATED-SEL: [[DST_DESCRIMINATOR:%.*]] = call i64 @llvm.ptrauth.blend(i64 [[CAST_DST_ADDR]], i64 22467) // CHECK-UNAUTHENTICATED-SEL: [[CAST_SRC_ADDR:%.*]] = ptrtoint ptr [[SRC_ADDR]] to i64 -// CHECK-UNAUTHENTICATED-SEL: [[SRC_DESCRIMINATOR:%.*]] = call i64 @llvm.ptrauth.blend(i64 [[CAST_SRC_ADDR]], i64 22467) // CHECK-UNAUTHENTICATED-SEL: [[SRC_SEL:%.*]] = ptrtoint ptr [[SRC_SEL_ADDR:%.*]] to i64 -// CHECK-UNAUTHENTICATED-SEL: {{%.*}} = call i64 @llvm.ptrauth.resign(i64 [[SRC_SEL]]) [ "ptrauth"(i64 3, i64 [[DST_DESCRIMINATOR]]), "ptrauth"(i64 3, i64 [[SRC_DESCRIMINATOR]]) ] +// CHECK-UNAUTHENTICATED-SEL: {{%.*}} = call i64 @llvm.ptrauth.resign(i64 [[SRC_SEL]]) [ "ptrauth"(i64 3, i64 [[CAST_DST_ADDR]], i64 22467), "ptrauth"(i64 3, i64 [[CAST_SRC_ADDR]], i64 22467) ] diff --git a/clang/test/CodeGenObjC/ptrauth-property-backing.m b/clang/test/CodeGenObjC/ptrauth-property-backing.m index dd873411c9f5a..6e91790ec339e 100644 --- a/clang/test/CodeGenObjC/ptrauth-property-backing.m +++ b/clang/test/CodeGenObjC/ptrauth-property-backing.m @@ -23,13 +23,11 @@ @implementation Root // CHECK-LABEL: define internal ptr @"\01-[Root field1]" // CHECK: [[LOAD:%.*]] = load atomic i64, ptr [[ADDR:%.*]] unordered // CHECK: [[CAST_ADDR:%.*]] = ptrtoint ptr [[ADDR]] to i64 -// CHECK: [[BLEND:%.*]] = call i64 @llvm.ptrauth.blend(i64 [[CAST_ADDR]], i64 1) -// CHECK: [[RESULT:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[LOAD]]) [ "ptrauth"(i64 1, i64 [[BLEND]]) ] +// CHECK: [[RESULT:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[LOAD]]) [ "ptrauth"(i64 1, i64 [[CAST_ADDR]], i64 1) ] // CHECK-LABEL: define internal void @"\01-[Root setField1:]" // CHECK: [[CAST_ADDR:%.*]] = ptrtoint ptr [[ADDR:%.*]] to i64 -// CHECK: [[BLEND:%.*]] = call i64 @llvm.ptrauth.blend(i64 [[CAST_ADDR]], i64 1) -// CHECK: [[RESULT:%.*]] = call i64 @llvm.ptrauth.sign(i64 [[VALUE:%.*]]) [ "ptrauth"(i64 1, i64 [[BLEND]]) ] +// CHECK: [[RESULT:%.*]] = call i64 @llvm.ptrauth.sign(i64 [[VALUE:%.*]]) [ "ptrauth"(i64 1, i64 [[CAST_ADDR]], i64 1) ] // CHECK: [[PHI:%.*]] = phi i64 [ 0, {{%.*}} ], [ [[RESULT]], {{%.*}} ] // CHECK: store atomic i64 [[PHI]], ptr [[ADDR]] unordered @@ -37,15 +35,13 @@ @implementation Root // CHECK: load ptr, ptr // CHECK: [[LOAD:%.*]] = load ptr, ptr [[ADDR:%.*]], // CHECK: [[CAST_ADDR:%.*]] = ptrtoint ptr [[ADDR]] to i64 -// CHECK: [[BLEND:%.*]] = call i64 @llvm.ptrauth.blend(i64 [[CAST_ADDR:%.*]], i64 1) // CHECK: [[VALUE:%.*]] = ptrtoint ptr [[LOAD]] to i64 -// CHECK: [[RESULT:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VALUE]]) [ "ptrauth"(i64 1, i64 [[BLEND]]) ] +// CHECK: [[RESULT:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VALUE]]) [ "ptrauth"(i64 1, i64 [[CAST_ADDR:%.*]], i64 1) ] // CHECK-LABEL: define internal void @"\01-[Root setField2:]" // CHECK: [[CAST_ADDR:%.*]] = ptrtoint ptr [[ADDR:%.*]] to i64 -// CHECK: [[BLEND:%.*]] = call i64 @llvm.ptrauth.blend(i64 [[CAST_ADDR]], i64 1) // CHECK: [[CAST_VALUE:%.*]] = ptrtoint ptr [[VALUE:%.*]] to i64 -// CHECK: [[SIGNED:%.*]] = call i64 @llvm.ptrauth.sign(i64 [[CAST_VALUE]]) [ "ptrauth"(i64 1, i64 [[BLEND]]) ] +// CHECK: [[SIGNED:%.*]] = call i64 @llvm.ptrauth.sign(i64 [[CAST_VALUE]]) [ "ptrauth"(i64 1, i64 [[CAST_ADDR]], i64 1) ] // CHECK: [[RESULT:%.*]] = inttoptr i64 [[SIGNED]] to ptr // CHECK: [[PHI:%.*]] = phi ptr [ null, {{%.*}} ], [ [[RESULT]], {{%.*}} ] // CHECK: store ptr [[PHI]], ptr [[ADDR]] @@ -53,28 +49,24 @@ @implementation Root // CHECK-LABEL: define internal ptr @"\01-[Root field3]" // CHECK: [[VALUE:%.*]] = load atomic i64, ptr [[ADDR:%.*]] unordered, align 8 // CHECK: [[CASTED_ADDR:%.*]] = ptrtoint ptr [[ADDR]] to i64 -// CHECK: [[BLENDED:%.*]] = call i64 @llvm.ptrauth.blend(i64 [[CASTED_ADDR]], i64 1) -// CHECK: {{%.*}} = call i64 @llvm.ptrauth.resign(i64 [[VALUE]]) [ "ptrauth"(i64 1, i64 [[BLENDED]]), "ptrauth"(i64 0, i64 0) ] +// CHECK: {{%.*}} = call i64 @llvm.ptrauth.resign(i64 [[VALUE]]) [ "ptrauth"(i64 1, i64 [[CASTED_ADDR]], i64 1), "ptrauth"(i64 0, i64 0) ] // CHECK-LABEL: define internal void @"\01-[Root setField3:]" // CHECK: [[VALUE:%.*]] = load i64, ptr {{%.*}}, align 8 // CHECK: [[CASTED_ADDR:%.*]] = ptrtoint ptr {{%.*}} to i64 -// CHECK: [[BLENDED:%.*]] = call i64 @llvm.ptrauth.blend(i64 [[CASTED_ADDR]], i64 1) -// CHECK: {{%.*}} = call i64 @llvm.ptrauth.resign(i64 [[VALUE]]) [ "ptrauth"(i64 0, i64 0), "ptrauth"(i64 1, i64 [[BLENDED]]) ] +// CHECK: {{%.*}} = call i64 @llvm.ptrauth.resign(i64 [[VALUE]]) [ "ptrauth"(i64 0, i64 0), "ptrauth"(i64 1, i64 [[CASTED_ADDR]], i64 1) ] // CHECK: store atomic i64 // CHECK-LABEL: define internal ptr @"\01-[Root field4]" // CHECK: load ptr, ptr // CHECK: [[VALUE:%.*]] = load ptr, ptr [[ADDR:%.*]], // CHECK: [[CASTED_ADDR:%.*]] = ptrtoint ptr [[ADDR]] to i64 -// CHECK: [[BLENDED:%.*]] = call i64 @llvm.ptrauth.blend(i64 [[CASTED_ADDR]], i64 123) // CHECK: [[CAST_VALUE:%.*]] = ptrtoint ptr [[VALUE]] to i64 -// CHECK: {{%.*}} = call i64 @llvm.ptrauth.resign(i64 [[CAST_VALUE]]) [ "ptrauth"(i64 1, i64 [[BLENDED]]), "ptrauth"(i64 0, i64 0) ] +// CHECK: {{%.*}} = call i64 @llvm.ptrauth.resign(i64 [[CAST_VALUE]]) [ "ptrauth"(i64 1, i64 [[CASTED_ADDR]], i64 123), "ptrauth"(i64 0, i64 0) ] // CHECK-LABEL: define internal void @"\01-[Root setField4:]" // CHECK: [[CAST_ADDR:%.*]] = ptrtoint ptr {{%.*}} to i64 -// CHECK: [[BLENDED:%.*]] = call i64 @llvm.ptrauth.blend(i64 [[CAST_ADDR]], i64 123) // CHECK: resign.nonnull: // CHECK: [[VALUE:%.*]] = ptrtoint ptr %1 to i64 -// CHECK: {{%.*}} = call i64 @llvm.ptrauth.resign(i64 [[VALUE]]) [ "ptrauth"(i64 0, i64 0), "ptrauth"(i64 1, i64 [[BLENDED]]) ] +// CHECK: {{%.*}} = call i64 @llvm.ptrauth.resign(i64 [[VALUE]]) [ "ptrauth"(i64 0, i64 0), "ptrauth"(i64 1, i64 [[CAST_ADDR]], i64 123) ] diff --git a/clang/test/CodeGenObjCXX/ptrauth-objc-interface-selector.mm b/clang/test/CodeGenObjCXX/ptrauth-objc-interface-selector.mm index e6526d61ac1e7..b72c84f6d03a7 100644 --- a/clang/test/CodeGenObjCXX/ptrauth-objc-interface-selector.mm +++ b/clang/test/CodeGenObjCXX/ptrauth-objc-interface-selector.mm @@ -44,11 +44,9 @@ void auto_sel(Test *out, Test *in) { // CHECK-AUTHENTICATED-SEL: [[V1:%.*]] = load ptr, ptr %in.addr // CHECK-AUTHENTICATED-SEL: [[DST_ADDR:%.*]] = getelementptr inbounds i8, ptr [[V1]], i64 {{%.*}} // CHECK-AUTHENTICATED-SEL: [[CAST_DST_ADDR:%.*]] = ptrtoint ptr [[DST_ADDR]] to i64 -// CHECK-AUTHENTICATED-SEL: [[DST_DESCRIMINATOR:%.*]] = call i64 @llvm.ptrauth.blend(i64 [[CAST_DST_ADDR]], i64 22466) // CHECK-AUTHENTICATED-SEL: [[CAST_SRC_ADDR:%.*]] = ptrtoint ptr [[SRC_ADDR]] to i64 -// CHECK-AUTHENTICATED-SEL: [[SRC_DESCRIMINATOR:%.*]] = call i64 @llvm.ptrauth.blend(i64 [[CAST_SRC_ADDR]], i64 22466) // CHECK-AUTHENTICATED-SEL: [[SRC_SEL:%.*]] = ptrtoint ptr [[SRC_SEL_ADDR:%.*]] to i64 -// CHECK-AUTHENTICATED-SEL: {{%.*}} = call i64 @llvm.ptrauth.resign(i64 [[SRC_SEL]]) [ "ptrauth"(i64 3, i64 [[DST_DESCRIMINATOR]]), "ptrauth"(i64 3, i64 [[SRC_DESCRIMINATOR]]) ] +// CHECK-AUTHENTICATED-SEL: {{%.*}} = call i64 @llvm.ptrauth.resign(i64 [[SRC_SEL]]) [ "ptrauth"(i64 3, i64 [[CAST_DST_ADDR]], i64 22466), "ptrauth"(i64 3, i64 [[CAST_SRC_ADDR]], i64 22466) ] // CHECK-UNAUTHENTICATED-SEL: define void @auto_sel SEL const_auto_sel(Test *in) { @@ -57,9 +55,8 @@ SEL const_auto_sel(Test *in) { } // CHECK-AUTHENTICATED-SEL: define ptr @const_auto_sel -// CHECK-AUTHENTICATED-SEL: {{%.*}} = call i64 @llvm.ptrauth.blend(i64 {{%.*}}, i64 22466) // CHECK-AUTHENTICATED-SEL: {{%.*}} = ptrtoint ptr {{%.*}} to i64 -// CHECK-AUTHENTICATED-SEL: [[AUTHENTICATED:%.*]] = call i64 @llvm.ptrauth.auth(i64 {{%.*}}) [ "ptrauth"(i64 3, i64 {{%.*}}) ] +// CHECK-AUTHENTICATED-SEL: [[AUTHENTICATED:%.*]] = call i64 @llvm.ptrauth.auth(i64 {{%.*}}) [ "ptrauth"(i64 3, i64 {{%.*}}, i64 22466) ] // CHECK-AUTHENTICATED-SEL: [[RESULT:%.*]] = inttoptr i64 [[AUTHENTICATED]] to ptr void volatile_auto_sel(Test *out, Test *in) { @@ -73,11 +70,9 @@ void volatile_auto_sel(Test *out, Test *in) { // CHECK-AUTHENTICATED-SEL: [[V2:%.*]] = load ptr, ptr %in.addr // CHECK-AUTHENTICATED-SEL: [[DST_ADDR:%.*]] = getelementptr inbounds i8, ptr [[V2]], i64 {{%.*}} // CHECK-AUTHENTICATED-SEL: [[CAST_DST_ADDR:%.*]] = ptrtoint ptr [[DST_ADDR]] to i64 -// CHECK-AUTHENTICATED-SEL: [[DST_DESCRIMINATOR:%.*]] = call i64 @llvm.ptrauth.blend(i64 [[CAST_DST_ADDR]], i64 22466) // CHECK-AUTHENTICATED-SEL: [[CAST_SRC_ADDR:%.*]] = ptrtoint ptr [[SRC_ADDR]] to i64 -// CHECK-AUTHENTICATED-SEL: [[SRC_DESCRIMINATOR:%.*]] = call i64 @llvm.ptrauth.blend(i64 [[CAST_SRC_ADDR]], i64 22466) // CHECK-AUTHENTICATED-SEL: [[SRC_SEL:%.*]] = ptrtoint ptr [[SRC_SEL_ADDR:%.*]] to i64 -// CHECK-AUTHENTICATED-SEL: {{%.*}} = call i64 @llvm.ptrauth.resign(i64 [[SRC_SEL]]) [ "ptrauth"(i64 3, i64 [[DST_DESCRIMINATOR]]), "ptrauth"(i64 3, i64 [[SRC_DESCRIMINATOR]]) ] +// CHECK-AUTHENTICATED-SEL: {{%.*}} = call i64 @llvm.ptrauth.resign(i64 [[SRC_SEL]]) [ "ptrauth"(i64 3, i64 [[CAST_DST_ADDR]], i64 22466), "ptrauth"(i64 3, i64 [[CAST_SRC_ADDR]], i64 22466) ] void manual(Test *out, Test *in) { out->manual = in->manual; @@ -89,11 +84,9 @@ void manual(Test *out, Test *in) { // CHECK-AUTHENTICATED-SEL: [[V1:%.*]] = load ptr, ptr %in.addr // CHECK-AUTHENTICATED-SEL: [[DST_ADDR:%.*]] = getelementptr inbounds i8, ptr [[V1]], i64 {{%.*}} // CHECK-AUTHENTICATED-SEL: [[CAST_DST_ADDR:%.*]] = ptrtoint ptr [[DST_ADDR]] to i64 -// CHECK-AUTHENTICATED-SEL: [[DST_DESCRIMINATOR:%.*]] = call i64 @llvm.ptrauth.blend(i64 [[CAST_DST_ADDR]], i64 22467) // CHECK-AUTHENTICATED-SEL: [[CAST_SRC_ADDR:%.*]] = ptrtoint ptr [[SRC_ADDR]] to i64 -// CHECK-AUTHENTICATED-SEL: [[SRC_DESCRIMINATOR:%.*]] = call i64 @llvm.ptrauth.blend(i64 [[CAST_SRC_ADDR]], i64 22467) // CHECK-AUTHENTICATED-SEL: [[SRC_SEL:%.*]] = ptrtoint ptr [[SRC_SEL_ADDR:%.*]] to i64 -// CHECK-AUTHENTICATED-SEL: {{%.*}} = call i64 @llvm.ptrauth.resign(i64 [[SRC_SEL]]) [ "ptrauth"(i64 3, i64 [[DST_DESCRIMINATOR]]), "ptrauth"(i64 3, i64 [[SRC_DESCRIMINATOR]]) ] +// CHECK-AUTHENTICATED-SEL: {{%.*}} = call i64 @llvm.ptrauth.resign(i64 [[SRC_SEL]]) [ "ptrauth"(i64 3, i64 [[CAST_DST_ADDR]], i64 22467), "ptrauth"(i64 3, i64 [[CAST_SRC_ADDR]], i64 22467) ] // CHECK-UNAUTHENTICATED-SEL: define void @manual // CHECK-UNAUTHENTICATED-SEL: [[V0:%.*]] = load ptr, ptr %out.addr @@ -101,10 +94,8 @@ void manual(Test *out, Test *in) { // CHECK-UNAUTHENTICATED-SEL: [[V1:%.*]] = load ptr, ptr %in.addr // CHECK-UNAUTHENTICATED-SEL: [[DST_ADDR:%.*]] = getelementptr inbounds i8, ptr [[V1]], i64 {{%.*}} // CHECK-UNAUTHENTICATED-SEL: [[CAST_DST_ADDR:%.*]] = ptrtoint ptr [[DST_ADDR]] to i64 -// CHECK-UNAUTHENTICATED-SEL: [[DST_DESCRIMINATOR:%.*]] = call i64 @llvm.ptrauth.blend(i64 [[CAST_DST_ADDR]], i64 22467) // CHECK-UNAUTHENTICATED-SEL: [[CAST_SRC_ADDR:%.*]] = ptrtoint ptr [[SRC_ADDR]] to i64 -// CHECK-UNAUTHENTICATED-SEL: [[SRC_DESCRIMINATOR:%.*]] = call i64 @llvm.ptrauth.blend(i64 [[CAST_SRC_ADDR]], i64 22467) // CHECK-UNAUTHENTICATED-SEL: [[SRC_SEL:%.*]] = ptrtoint ptr [[SRC_SEL_ADDR:%.*]] to i64 -// CHECK-UNAUTHENTICATED-SEL: {{%.*}} = call i64 @llvm.ptrauth.resign(i64 [[SRC_SEL]]) [ "ptrauth"(i64 3, i64 [[DST_DESCRIMINATOR]]), "ptrauth"(i64 3, i64 [[SRC_DESCRIMINATOR]]) ] +// CHECK-UNAUTHENTICATED-SEL: {{%.*}} = call i64 @llvm.ptrauth.resign(i64 [[SRC_SEL]]) [ "ptrauth"(i64 3, i64 [[CAST_DST_ADDR]], i64 22467), "ptrauth"(i64 3, i64 [[CAST_SRC_ADDR]], i64 22467) ] } From ea798a76c9db30646dbb92d5ebbdc2f5e24f7e68 Mon Sep 17 00:00:00 2001 From: Anatoly Trosinenko Date: Wed, 29 Oct 2025 13:51:10 +0300 Subject: [PATCH 09/40] Do not emit temporary blend intrinsic when processing builtins --- clang/lib/CodeGen/CGBuiltin.cpp | 61 +++++++++++++------------ clang/test/CodeGen/ptrauth-intrinsics.c | 56 ++++++++++++++++++----- clang/test/Sema/ptrauth-blend.c | 13 ++++++ 3 files changed, 89 insertions(+), 41 deletions(-) create mode 100644 clang/test/Sema/ptrauth-blend.c diff --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp index 65a37ffd4d38f..6ef6c8f71a24b 100644 --- a/clang/lib/CodeGen/CGBuiltin.cpp +++ b/clang/lib/CodeGen/CGBuiltin.cpp @@ -5622,61 +5622,67 @@ RValue CodeGenFunction::EmitBuiltinExpr(const GlobalDecl GD, unsigned BuiltinID, case Builtin::BI__builtin_ptrauth_sign_constant: return RValue::get(ConstantEmitter(*this).emitAbstract(E, E->getType())); + case Builtin::BI__builtin_ptrauth_blend_discriminator: { + CGM.Error(E->getExprLoc(), "Standalone blend builtin is not supported"); + llvm::Type *Ty = ConvertType(E->getType()); + return RValue::get(llvm::UndefValue::get(Ty)); + } + case Builtin::BI__builtin_ptrauth_auth: case Builtin::BI__builtin_ptrauth_auth_and_resign: - case Builtin::BI__builtin_ptrauth_blend_discriminator: case Builtin::BI__builtin_ptrauth_sign_generic_data: case Builtin::BI__builtin_ptrauth_sign_unauthenticated: case Builtin::BI__builtin_ptrauth_strip: { - // Emit the arguments. SmallVector Args; SmallVector OBs; - for (auto argExpr : E->arguments()) - Args.push_back(EmitScalarExpr(argExpr)); - auto ConvertToIntPtr = [&](Value *V) { + auto ConvertToInt64 = [&](llvm::Value *V) { if (V->getType()->isPointerTy()) return Builder.CreatePtrToInt(V, IntPtrTy); return Builder.CreateZExt(V, IntPtrTy); }; + auto AddPtrAuthBundle = [&](const Expr *Key, const Expr *Discr) { + SmallVector Operands; + Operands.push_back(ConvertToInt64(EmitScalarExpr(Key))); + const CallExpr *CE = dyn_cast(Discr); + if (CE && CE->getBuiltinCallee() == Builtin::BI__builtin_ptrauth_blend_discriminator) { + Operands.push_back(ConvertToInt64(EmitScalarExpr(CE->getArg(0)))); + Operands.push_back(ConvertToInt64(EmitScalarExpr(CE->getArg(1)))); + } else { + Operands.push_back(ConvertToInt64(EmitScalarExpr(Discr))); + } + OBs.emplace_back("ptrauth", Operands); + }; + // Cast the value to intptr_t, saving its original type. + Args.push_back(EmitScalarExpr(E->getArg(0))); llvm::Type *OrigValueType = Args[0]->getType(); - if (OrigValueType->isPointerTy()) - Args[0] = Builder.CreatePtrToInt(Args[0], IntPtrTy); + Args[0] = ConvertToInt64(Args[0]); switch (BuiltinID) { + default: + llvm_unreachable("bad ptrauth intrinsic"); case Builtin::BI__builtin_ptrauth_auth_and_resign: - OBs.emplace_back("ptrauth", ArrayRef({ ConvertToIntPtr(Args[1]), - ConvertToIntPtr(Args[2]) })); - OBs.emplace_back("ptrauth", ArrayRef({ ConvertToIntPtr(Args[3]), - ConvertToIntPtr(Args[4]) })); - - Args.resize(1); + AddPtrAuthBundle(E->getArg(1), E->getArg(2)); + AddPtrAuthBundle(E->getArg(3), E->getArg(4)); break; case Builtin::BI__builtin_ptrauth_auth: case Builtin::BI__builtin_ptrauth_sign_unauthenticated: - OBs.emplace_back("ptrauth", ArrayRef({ ConvertToIntPtr(Args[1]), - ConvertToIntPtr(Args[2]) })); - - Args.resize(1); + AddPtrAuthBundle(E->getArg(1), E->getArg(2)); break; case Builtin::BI__builtin_ptrauth_sign_generic_data: - if (Args[1]->getType()->isPointerTy()) - Args[1] = Builder.CreatePtrToInt(Args[1], IntPtrTy); + Args.push_back(ConvertToInt64(EmitScalarExpr(E->getArg(1)))); break; - case Builtin::BI__builtin_ptrauth_blend_discriminator: - break; - - case Builtin::BI__builtin_ptrauth_strip: - // FIXME i32 -> i64 - OBs.emplace_back("ptrauth", ArrayRef({Args[1]})); - Args.pop_back(); + case Builtin::BI__builtin_ptrauth_strip: { + llvm::Value *Key = ConvertToInt64(EmitScalarExpr(E->getArg(1))); + OBs.emplace_back("ptrauth", ArrayRef({Key})); break; } + } // Call the intrinsic. auto IntrinsicID = [&]() -> unsigned { @@ -5685,8 +5691,6 @@ RValue CodeGenFunction::EmitBuiltinExpr(const GlobalDecl GD, unsigned BuiltinID, return Intrinsic::ptrauth_auth; case Builtin::BI__builtin_ptrauth_auth_and_resign: return Intrinsic::ptrauth_resign; - case Builtin::BI__builtin_ptrauth_blend_discriminator: - return Intrinsic::ptrauth_blend; case Builtin::BI__builtin_ptrauth_sign_generic_data: return Intrinsic::ptrauth_sign_generic; case Builtin::BI__builtin_ptrauth_sign_unauthenticated: @@ -5700,7 +5704,6 @@ RValue CodeGenFunction::EmitBuiltinExpr(const GlobalDecl GD, unsigned BuiltinID, llvm::Value *Result = EmitRuntimeCall(Intrinsic, Args, OBs); if (BuiltinID != Builtin::BI__builtin_ptrauth_sign_generic_data && - BuiltinID != Builtin::BI__builtin_ptrauth_blend_discriminator && OrigValueType->isPointerTy()) { Result = Builder.CreateIntToPtr(Result, OrigValueType); } diff --git a/clang/test/CodeGen/ptrauth-intrinsics.c b/clang/test/CodeGen/ptrauth-intrinsics.c index 116739e67a146..75a7d716b19d2 100644 --- a/clang/test/CodeGen/ptrauth-intrinsics.c +++ b/clang/test/CodeGen/ptrauth-intrinsics.c @@ -12,8 +12,8 @@ long signature; // CHECK-LABEL: define {{.*}}void @test_auth() void test_auth() { // CHECK: [[PTR:%.*]] = load ptr, ptr @fnptr, - // CHECK-NEXT: [[DISC0:%.*]] = load ptr, ptr @ptr_discriminator, // CHECK-NEXT: [[T0:%.*]] = ptrtoint ptr [[PTR]] to i64 + // CHECK-NEXT: [[DISC0:%.*]] = load ptr, ptr @ptr_discriminator, // CHECK-NEXT: [[DISC:%.*]] = ptrtoint ptr [[DISC0]] to i64 // CHECK-NEXT: [[T1:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[T0]]) [ "ptrauth"(i64 0, i64 [[DISC]]) ] // CHECK-NEXT: [[RESULT:%.*]] = inttoptr i64 [[T1]] to ptr @@ -25,7 +25,7 @@ void test_auth() { void test_strip() { // CHECK: [[PTR:%.*]] = load ptr, ptr @fnptr, // CHECK-NEXT: [[T0:%.*]] = ptrtoint ptr [[PTR]] to i64 - // CHECK-NEXT: [[T1:%.*]] = call i64 @llvm.ptrauth.strip(i64 [[T0]]) [ "ptrauth"(i32 0) ] + // CHECK-NEXT: [[T1:%.*]] = call i64 @llvm.ptrauth.strip(i64 [[T0]]) [ "ptrauth"(i64 0) ] // CHECK-NEXT: [[RESULT:%.*]] = inttoptr i64 [[T1]] to ptr // CHECK-NEXT: store ptr [[RESULT]], ptr @fnptr, fnptr = __builtin_ptrauth_strip(fnptr, 0); @@ -34,8 +34,8 @@ void test_strip() { // CHECK-LABEL: define {{.*}}void @test_sign_unauthenticated() void test_sign_unauthenticated() { // CHECK: [[PTR:%.*]] = load ptr, ptr @fnptr, - // CHECK-NEXT: [[DISC0:%.*]] = load ptr, ptr @ptr_discriminator, // CHECK-NEXT: [[T0:%.*]] = ptrtoint ptr [[PTR]] to i64 + // CHECK-NEXT: [[DISC0:%.*]] = load ptr, ptr @ptr_discriminator, // CHECK-NEXT: [[DISC:%.*]] = ptrtoint ptr [[DISC0]] to i64 // CHECK-NEXT: [[T1:%.*]] = call i64 @llvm.ptrauth.sign(i64 [[T0]]) [ "ptrauth"(i64 0, i64 [[DISC]]) ] // CHECK-NEXT: [[RESULT:%.*]] = inttoptr i64 [[T1]] to ptr @@ -46,8 +46,8 @@ void test_sign_unauthenticated() { // CHECK-LABEL: define {{.*}}void @test_auth_and_resign() void test_auth_and_resign() { // CHECK: [[PTR:%.*]] = load ptr, ptr @fnptr, - // CHECK-NEXT: [[DISC0:%.*]] = load ptr, ptr @ptr_discriminator, // CHECK-NEXT: [[T0:%.*]] = ptrtoint ptr [[PTR]] to i64 + // CHECK-NEXT: [[DISC0:%.*]] = load ptr, ptr @ptr_discriminator, // CHECK-NEXT: [[DISC:%.*]] = ptrtoint ptr [[DISC0]] to i64 // CHECK-NEXT: [[T1:%.*]] = call i64 @llvm.ptrauth.resign(i64 [[T0]]) [ "ptrauth"(i64 0, i64 [[DISC]]), "ptrauth"(i64 3, i64 15) ] // CHECK-NEXT: [[RESULT:%.*]] = inttoptr i64 [[T1]] to ptr @@ -55,21 +55,53 @@ void test_auth_and_resign() { fnptr = __builtin_ptrauth_auth_and_resign(fnptr, 0, ptr_discriminator, 3, 15); } -// CHECK-LABEL: define {{.*}}void @test_blend_discriminator() -void test_blend_discriminator() { - // CHECK: [[PTR:%.*]] = load ptr, ptr @fnptr, +// FIXME Reject calls to blend not as an argument of auth/sign/resign. + +// CHECK-LABEL: define {{.*}}void @test_auth_blend_discriminator() +void test_auth_blend_discriminator() { + // CHECK: [[FNPTR:%.*]] = load ptr, ptr @fnptr, + // CHECK-NEXT: [[CAST_FNPTR:%.*]] = ptrtoint ptr [[FNPTR]] to i64 + // CHECK: [[PTR:%.*]] = load ptr, ptr @ptr_discriminator, + // CHECK-NEXT: [[CAST_PTR:%.*]] = ptrtoint ptr [[PTR]] to i64 // CHECK-NEXT: [[DISC:%.*]] = load i64, ptr @int_discriminator, - // CHECK-NEXT: [[T0:%.*]] = ptrtoint ptr [[PTR]] to i64 - // CHECK-NEXT: [[RESULT:%.*]] = call i64 @llvm.ptrauth.blend(i64 [[T0]], i64 [[DISC]]) - // CHECK-NEXT: store i64 [[RESULT]], ptr @int_discriminator, - int_discriminator = __builtin_ptrauth_blend_discriminator(fnptr, int_discriminator); + // CHECK-NEXT: [[T1:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[CAST_FNPTR]]) [ "ptrauth"(i64 0, i64 [[CAST_PTR]], i64 [[DISC]]) ] + // CHECK-NEXT: [[RESULT:%.*]] = inttoptr i64 [[T1]] to ptr + // CHECK-NEXT: store ptr [[RESULT]], ptr @fnptr, + fnptr = __builtin_ptrauth_auth(fnptr, 0, __builtin_ptrauth_blend_discriminator(ptr_discriminator, int_discriminator)); +} + +// CHECK-LABEL: define {{.*}}void @test_sign_blend_discriminator() +void test_sign_blend_discriminator() { + // CHECK: [[FNPTR:%.*]] = load ptr, ptr @fnptr, + // CHECK-NEXT: [[CAST_FNPTR:%.*]] = ptrtoint ptr [[FNPTR]] to i64 + // CHECK: [[PTR:%.*]] = load ptr, ptr @ptr_discriminator, + // CHECK-NEXT: [[CAST_PTR:%.*]] = ptrtoint ptr [[PTR]] to i64 + // CHECK-NEXT: [[DISC:%.*]] = load i64, ptr @int_discriminator, + // CHECK-NEXT: [[T1:%.*]] = call i64 @llvm.ptrauth.sign(i64 [[CAST_FNPTR]]) [ "ptrauth"(i64 0, i64 [[CAST_PTR]], i64 [[DISC]]) ] + // CHECK-NEXT: [[RESULT:%.*]] = inttoptr i64 [[T1]] to ptr + // CHECK-NEXT: store ptr [[RESULT]], ptr @fnptr, + fnptr = __builtin_ptrauth_sign_unauthenticated(fnptr, 0, __builtin_ptrauth_blend_discriminator(ptr_discriminator, int_discriminator)); +} + +// CHECK-LABEL: define {{.*}}void @test_resign_blend_discriminator() +void test_resign_blend_discriminator() { + // CHECK: [[FNPTR:%.*]] = load ptr, ptr @fnptr, + // CHECK-NEXT: [[CAST_FNPTR:%.*]] = ptrtoint ptr [[FNPTR]] to i64 + // CHECK: [[PTR:%.*]] = load ptr, ptr @ptr_discriminator, + // CHECK-NEXT: [[CAST_PTR:%.*]] = ptrtoint ptr [[PTR]] to i64 + // CHECK-NEXT: [[DISC:%.*]] = load i64, ptr @int_discriminator, + // CHECK-NEXT: [[T1:%.*]] = call i64 @llvm.ptrauth.resign(i64 [[CAST_FNPTR]]) [ "ptrauth"(i64 0, i64 [[CAST_PTR]], i64 [[DISC]]), "ptrauth"(i64 1, i64 ptrtoint (ptr @int_discriminator to i64), i64 1234) ] + // CHECK-NEXT: [[RESULT:%.*]] = inttoptr i64 [[T1]] to ptr + // CHECK-NEXT: store ptr [[RESULT]], ptr @fnptr, + fnptr = __builtin_ptrauth_auth_and_resign(fnptr, 0, __builtin_ptrauth_blend_discriminator(ptr_discriminator, int_discriminator), + 1, __builtin_ptrauth_blend_discriminator(&int_discriminator, 1234)); } // CHECK-LABEL: define {{.*}}void @test_sign_generic_data() void test_sign_generic_data() { // CHECK: [[PTR:%.*]] = load ptr, ptr @fnptr, - // CHECK-NEXT: [[DISC0:%.*]] = load ptr, ptr @ptr_discriminator, // CHECK-NEXT: [[T0:%.*]] = ptrtoint ptr [[PTR]] to i64 + // CHECK-NEXT: [[DISC0:%.*]] = load ptr, ptr @ptr_discriminator, // CHECK-NEXT: [[DISC:%.*]] = ptrtoint ptr [[DISC0]] to i64 // CHECK-NEXT: [[RESULT:%.*]] = call i64 @llvm.ptrauth.sign.generic(i64 [[T0]], i64 [[DISC]]) // CHECK-NEXT: store i64 [[RESULT]], ptr @signature, diff --git a/clang/test/Sema/ptrauth-blend.c b/clang/test/Sema/ptrauth-blend.c new file mode 100644 index 0000000000000..dc3359b718cf4 --- /dev/null +++ b/clang/test/Sema/ptrauth-blend.c @@ -0,0 +1,13 @@ +// RUN: %clang_cc1 -triple arm64-apple-ios -S -verify -fptrauth-intrinsics %s + +typedef __UINTPTR_TYPE__ uintptr_t; + +void callee(uintptr_t disc); + +uintptr_t test_blend_can_only_be_used_as_argument_of_ptrauth_intrinsic(int *dp) { + (void)__builtin_ptrauth_blend_discriminator(dp, 1); // expected-error {{Standalone blend builtin is not supported}} + uintptr_t tmp1 = __builtin_ptrauth_blend_discriminator(dp, 2); // expected-error {{Standalone blend builtin is not supported}} + int *tmp2 = __builtin_ptrauth_sign_unauthenticated(dp, 0, tmp1); + callee(__builtin_ptrauth_blend_discriminator(dp, 3)); // expected-error {{Standalone blend builtin is not supported}} + return __builtin_ptrauth_blend_discriminator(dp, 4); // expected-error {{Standalone blend builtin is not supported}} +} From af616a90730808a5782c5892939ef47f33f8fedb Mon Sep 17 00:00:00 2001 From: Anatoly Trosinenko Date: Fri, 7 Nov 2025 15:37:11 +0300 Subject: [PATCH 10/40] libunwind: do not store the result of blend() to temporaries --- libcxxabi/src/cxa_personality.cpp | 26 ++++++++------------------ libunwind/src/DwarfParser.hpp | 19 ++++++++++--------- 2 files changed, 18 insertions(+), 27 deletions(-) diff --git a/libcxxabi/src/cxa_personality.cpp b/libcxxabi/src/cxa_personality.cpp index b7eb0f23dbe06..25125d14120a1 100644 --- a/libcxxabi/src/cxa_personality.cpp +++ b/libcxxabi/src/cxa_personality.cpp @@ -606,13 +606,11 @@ set_registers(_Unwind_Exception* unwind_exception, _Unwind_Context* context, auto stackPointer = _Unwind_GetGR(context, UNW_REG_SP); // We manually re-sign the IP as the __ptrauth qualifiers cannot // express the required relationship with the destination address - const auto existingDiscriminator = - ptrauth_blend_discriminator(&results.landingPad, - __ptrauth_scan_results_landingpad_disc); unw_word_t newIP /* opaque __ptrauth(ptrauth_key_return_address, stackPointer, 0) */ = (unw_word_t)ptrauth_auth_and_resign(*(void* const*)&results.landingPad, __ptrauth_scan_results_landingpad_key, - existingDiscriminator, + ptrauth_blend_discriminator(&results.landingPad, + __ptrauth_scan_results_landingpad_disc), ptrauth_key_return_address, stackPointer); _Unwind_SetIP(context, newIP); @@ -974,17 +972,13 @@ using __cxa_catch_temp_type = decltype(__cxa_exception::catchTemp); static inline void set_landing_pad(scan_results& results, const __cxa_catch_temp_type& source) { #if __has_feature(ptrauth_calls) - const uintptr_t sourceDiscriminator = - ptrauth_blend_discriminator(&source, __ptrauth_cxxabi_catch_temp_disc); - const uintptr_t targetDiscriminator = - ptrauth_blend_discriminator(&results.landingPad, - __ptrauth_scan_results_landingpad_disc); uintptr_t reauthenticatedLandingPad = (uintptr_t)ptrauth_auth_and_resign(*reinterpret_cast(&source), __ptrauth_cxxabi_catch_temp_key, - sourceDiscriminator, + ptrauth_blend_discriminator(&source, __ptrauth_cxxabi_catch_temp_disc), __ptrauth_scan_results_landingpad_key, - targetDiscriminator); + ptrauth_blend_discriminator(&results.landingPad, + __ptrauth_scan_results_landingpad_disc)); memmove(reinterpret_cast(&results.landingPad), reinterpret_cast(&reauthenticatedLandingPad), sizeof(reauthenticatedLandingPad)); @@ -996,17 +990,13 @@ static inline void set_landing_pad(scan_results& results, static inline void get_landing_pad(__cxa_catch_temp_type &dest, const scan_results &results) { #if __has_feature(ptrauth_calls) - const uintptr_t sourceDiscriminator = - ptrauth_blend_discriminator(&results.landingPad, - __ptrauth_scan_results_landingpad_disc); - const uintptr_t targetDiscriminator = - ptrauth_blend_discriminator(&dest, __ptrauth_cxxabi_catch_temp_disc); uintptr_t reauthenticatedPointer = (uintptr_t)ptrauth_auth_and_resign(*reinterpret_cast(&results.landingPad), __ptrauth_scan_results_landingpad_key, - sourceDiscriminator, + ptrauth_blend_discriminator(&results.landingPad, + __ptrauth_scan_results_landingpad_disc), __ptrauth_cxxabi_catch_temp_key, - targetDiscriminator); + ptrauth_blend_discriminator(&dest, __ptrauth_cxxabi_catch_temp_disc)); memmove(reinterpret_cast(&dest), reinterpret_cast(&reauthenticatedPointer), sizeof(reauthenticatedPointer)); diff --git a/libunwind/src/DwarfParser.hpp b/libunwind/src/DwarfParser.hpp index 2b04ae2831f9a..da50c6cbfcff8 100644 --- a/libunwind/src/DwarfParser.hpp +++ b/libunwind/src/DwarfParser.hpp @@ -397,18 +397,19 @@ const char *CFI_Parser::parseCIE(A &addressSpace, pint_t cie, // schema. If we could guarantee the encoding of the personality we // could avoid this by simply giving resultAddr the correct ptrauth // schema and performing an assignment. + void *signedPtr = ptrauth_auth_and_resign( + (void *)personality, ptrauth_key_function_pointer, #if defined(__arm64e__) - const auto oldDiscriminator = resultAddr; + resultAddr, #else - const auto oldDiscriminator = ptrauth_blend_discriminator( - (void *)resultAddr, __ptrauth_unwind_pauthtest_personality_disc); + ptrauth_blend_discriminator( + (void *)resultAddr, + __ptrauth_unwind_pauthtest_personality_disc), #endif - const auto discriminator = ptrauth_blend_discriminator( - &cieInfo->personality, - __ptrauth_unwind_cie_info_personality_disc); - void *signedPtr = ptrauth_auth_and_resign( - (void *)personality, ptrauth_key_function_pointer, - oldDiscriminator, ptrauth_key_function_pointer, discriminator); + ptrauth_key_function_pointer, + ptrauth_blend_discriminator( + &cieInfo->personality, + __ptrauth_unwind_cie_info_personality_disc)); personality = (pint_t)signedPtr; } #endif From 8847b2d721bb1cae5677bbe83b0093b10d884d87 Mon Sep 17 00:00:00 2001 From: Anatoly Trosinenko Date: Thu, 30 Oct 2025 17:09:39 +0300 Subject: [PATCH 11/40] Normalize operands of ptrauth bundle --- llvm/include/llvm/CodeGen/TargetLowering.h | 7 +++ llvm/include/llvm/IR/Constants.h | 2 + llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp | 14 ++++- .../SelectionDAG/SelectionDAGBuilder.cpp | 14 ++++- llvm/lib/IR/Constants.cpp | 7 ++- .../Target/AArch64/AArch64ISelLowering.cpp | 57 +++++++++++++++++++ llvm/lib/Target/AArch64/AArch64ISelLowering.h | 3 + 7 files changed, 97 insertions(+), 7 deletions(-) diff --git a/llvm/include/llvm/CodeGen/TargetLowering.h b/llvm/include/llvm/CodeGen/TargetLowering.h index e8392a3b18e9e..79c903e22f022 100644 --- a/llvm/include/llvm/CodeGen/TargetLowering.h +++ b/llvm/include/llvm/CodeGen/TargetLowering.h @@ -4612,6 +4612,13 @@ class LLVM_ABI TargetLowering : public TargetLoweringBase { /// Return true if the target supports ptrauth operand bundles. virtual bool supportPtrAuthBundles() const { return false; } + /// Normalize operands of "ptrauth" bundle. + virtual void normalizePtrAuthBundle(const CallBase &I, OperandBundleUse OB, + SmallVectorImpl &Output) const { + assert(OB.getTagID() == LLVMContext::OB_ptrauth); + Output.append(OB.Inputs.begin(), OB.Inputs.end()); + } + /// Perform necessary initialization to handle a subset of CSRs explicitly /// via copies. This function is called at the beginning of instruction /// selection. diff --git a/llvm/include/llvm/IR/Constants.h b/llvm/include/llvm/IR/Constants.h index 514fbfa3d48e8..0693a2a22d083 100644 --- a/llvm/include/llvm/IR/Constants.h +++ b/llvm/include/llvm/IR/Constants.h @@ -1107,6 +1107,8 @@ class ConstantPtrAuth final : public Constant { const Value *AddrDisc, const Value *IntDisc, const DataLayout &DL) const; + bool isKnownCompatibleWith(ArrayRef BundleOperands, + const DataLayout &DL) const; bool isKnownCompatibleWith(ArrayRef BundleOperands, const DataLayout &DL) const; diff --git a/llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp b/llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp index fcbc0ecd701aa..5465535041fbb 100644 --- a/llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp +++ b/llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp @@ -2207,11 +2207,16 @@ bool IRTranslator::translateKnownIntrinsic(const CallInst &CI, Intrinsic::ID ID, auto TranslatePtrAuthBundle = [&](unsigned Index) { auto Bundle = CI.getOperandBundleAt(Index); assert(Bundle.getTagID() == LLVMContext::OB_ptrauth); + + SmallVector Operands; + TLI->normalizePtrAuthBundle(CI, Bundle, Operands); + Register Res = MRI->createGenericVirtualRegister(LLT::token()); auto Builder = MIRBuilder.buildInstr(TargetOpcode::G_PTRAUTH_BUNDLE); Builder.addDef(Res); - for (Value *Operand : Bundle.Inputs) + for (Value *Operand : Operands) Builder.addUse(getOrCreateVReg(*Operand)); + return Res; }; @@ -2808,15 +2813,18 @@ bool IRTranslator::translateCallBase(const CallBase &CB, assert(!isa(CB)); + SmallVector BundleOperands; + TLI->normalizePtrAuthBundle(CB, *Bundle, BundleOperands); + // Look through ptrauth constants to try to eliminate the matching bundle // and turn this into a direct call with no ptrauth. // CallLowering will use the raw pointer if it doesn't find the PAI. const auto *CalleeCPA = dyn_cast(CB.getCalledOperand()); if (!CalleeCPA || !isa(CalleeCPA->getPointer()) || - !CalleeCPA->isKnownCompatibleWith(Bundle->Inputs, *DL)) { + !CalleeCPA->isKnownCompatibleWith(BundleOperands, *DL)) { // If we can't make it direct, package the bundle into PAI. PAI = CallLowering::PtrAuthInfo(); - for (const Value *V : Bundle->Inputs) + for (const Value *V : BundleOperands) PAI->Operands.push_back(getOrCreateVReg(*V)); } } diff --git a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp index 7be4435afed78..e7b1e00b92567 100644 --- a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp +++ b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp @@ -6558,9 +6558,14 @@ void SelectionDAGBuilder::visitIntrinsicCall(const CallInst &I, auto CreatePtrAuthBundle = [&](unsigned Index) { auto Bundle = I.getOperandBundleAt(Index); assert(Bundle.getTagID() == LLVMContext::OB_ptrauth); + + SmallVector Inputs; + TLI.normalizePtrAuthBundle(I, Bundle, Inputs); + SmallVector Ops; - for (Value *Operand : Bundle.Inputs) + for (Value *Operand : Inputs) Ops.push_back(getValue(Operand)); + return DAG.getNode(ISD::PtrAuthBundle, getCurSDLoc(), MVT::Other, Ops); }; @@ -9815,15 +9820,18 @@ void SelectionDAGBuilder::visitCall(const CallInst &I) { void SelectionDAGBuilder::LowerCallSiteWithPtrAuthBundle( const CallBase &CB, const BasicBlock *EHPadBB) { + const TargetLowering &TLI = DAG.getTargetLoweringInfo(); auto PAB = CB.getOperandBundle("ptrauth"); const Value *CalleeV = CB.getCalledOperand(); assert(!isa(CB)); + SmallVector BundleOperands; + TLI.normalizePtrAuthBundle(CB, *PAB, BundleOperands); // Look through ptrauth constants to find the raw callee. // Do a direct unauthenticated call if we found it and everything matches. if (const auto *CalleeCPA = dyn_cast(CalleeV)) - if (CalleeCPA->isKnownCompatibleWith(PAB->Inputs, DAG.getDataLayout())) + if (CalleeCPA->isKnownCompatibleWith(BundleOperands, DAG.getDataLayout())) return LowerCallTo(CB, getValue(CalleeCPA->getPointer()), CB.isTailCall(), CB.isMustTailCall(), EHPadBB); @@ -9833,7 +9841,7 @@ void SelectionDAGBuilder::LowerCallSiteWithPtrAuthBundle( // Otherwise, do an authenticated indirect call. TargetLowering::PtrAuthInfo PAI; - for (const Value *V : PAB->Inputs) + for (const Value *V : BundleOperands) PAI.Operands.push_back(getValue(V)); LowerCallTo(CB, getValue(CalleeV), CB.isTailCall(), CB.isMustTailCall(), diff --git a/llvm/lib/IR/Constants.cpp b/llvm/lib/IR/Constants.cpp index 8ee5567b6cc23..3603616309238 100644 --- a/llvm/lib/IR/Constants.cpp +++ b/llvm/lib/IR/Constants.cpp @@ -2263,7 +2263,7 @@ bool ConstantPtrAuth::isKnownCompatibleWith(const Value *Key, return Base1 == Base2 && Off1 == Off2; } -bool ConstantPtrAuth::isKnownCompatibleWith(ArrayRef BundleOperands, +bool ConstantPtrAuth::isKnownCompatibleWith(ArrayRef BundleOperands, const DataLayout &DL) const { if (BundleOperands.size() == 3) return isKnownCompatibleWith(BundleOperands[0], BundleOperands[1], @@ -2273,6 +2273,11 @@ bool ConstantPtrAuth::isKnownCompatibleWith(ArrayRef BundleOperands, return false; } +bool ConstantPtrAuth::isKnownCompatibleWith(ArrayRef BundleOperands, + const DataLayout &DL) const { + SmallVector Ops(BundleOperands.begin(), BundleOperands.end()); + return isKnownCompatibleWith(Ops, DL); +} //---- ConstantExpr::get() implementations. // diff --git a/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp b/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp index b5527a99c6fe6..10c916e8b081f 100644 --- a/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp +++ b/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp @@ -30065,6 +30065,63 @@ AArch64TargetLowering::EmitKCFICheck(MachineBasicBlock &MBB, .getInstr(); } +// On AArch64, a normalized "ptrauth" bundle has the form: +// - "ptrauth"(i64 key) for a call to ptrauth_strip intrinsic +// - "ptrauth"(i64 key, i64 addr_discr, i64 int_disc) otherwise +void AArch64TargetLowering::normalizePtrAuthBundle( + const CallBase &I, OperandBundleUse OB, + SmallVectorImpl &Output) const { + LLVMContext &Ctx = I.getContext(); + assert(OB.getTagID() == LLVMContext::OB_ptrauth); + + // Validate target-specific assumptions at least once even in no-assertion + // builds, as the IR may be provided by the user. + + auto ReportIf = [&I](bool ErrorCondition, StringRef Msg) { + if (!ErrorCondition) + return; + StringRef FunctionName = I.getFunction()->getName(); + reportFatalUsageError(FunctionName + ": " + Msg); + }; + + ReportIf(OB.Inputs.size() < 1 || OB.Inputs.size() > 3, + "ptrauth bundles must have from 1 to 3 operands on AArch64"); + + // The first operand is always the key ID. + ReportIf(!isa(OB.Inputs[0]), + "Key must be constant in ptrauth bundle on AArch64"); + + // FIXME + Output.push_back(ConstantInt::get(Ctx, APInt(64, cast(OB.Inputs[0])->getZExtValue()))); + + // ptrauth_strip requires a single-operand bundle. + if (I.getIntrinsicID() == Intrinsic::ptrauth_strip) { + ReportIf(OB.Inputs.size() != 1, + "@llvm.ptrauth.strip accepts 1-element ptrauth bundle on AArch64"); + return; + } + + // Otherwise we should normalize to a three-operand form. + + if (OB.Inputs.size() == 3) { + auto *IntDiscr = dyn_cast(OB.Inputs[2]); + ReportIf(!IntDiscr || !isUInt<16>(IntDiscr->getZExtValue()), + "Constant modifier must be uint16 in ptrauth bundle on AArch64"); + + // Nothing to normalize for a valid three-element bundle. + Output.append({OB.Inputs[1], OB.Inputs[2]}); + return; + } + + Value *Disc = OB.Inputs[1]; + Value *Zero = ConstantInt::get(Ctx, APInt::getZero(64)); + if (isa(Disc) && + isUInt<16>(cast(Disc)->getZExtValue())) + Output.append({Zero, Disc}); + else + Output.append({Disc, Zero}); +} + bool AArch64TargetLowering::enableAggressiveFMAFusion(EVT VT) const { return Subtarget->hasAggressiveFMA() && VT.isFloatingPoint(); } diff --git a/llvm/lib/Target/AArch64/AArch64ISelLowering.h b/llvm/lib/Target/AArch64/AArch64ISelLowering.h index 1d4446d287462..721007b00fc55 100644 --- a/llvm/lib/Target/AArch64/AArch64ISelLowering.h +++ b/llvm/lib/Target/AArch64/AArch64ISelLowering.h @@ -474,6 +474,9 @@ class AArch64TargetLowering : public TargetLowering { bool supportPtrAuthBundles() const override { return true; } + void normalizePtrAuthBundle(const CallBase &I, OperandBundleUse OB, + SmallVectorImpl &Output) const override; + bool supportKCFIBundles() const override { return true; } MachineInstr *EmitKCFICheck(MachineBasicBlock &MBB, From 3aef7e36be4f6e96025bdb0bca82a7726652a945 Mon Sep 17 00:00:00 2001 From: Anatoly Trosinenko Date: Fri, 31 Oct 2025 14:33:29 +0300 Subject: [PATCH 12/40] Fix ConstantPtrAuth::isKnownCompatibleWith --- llvm/lib/IR/Constants.cpp | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/llvm/lib/IR/Constants.cpp b/llvm/lib/IR/Constants.cpp index 3603616309238..f6fa708d752a4 100644 --- a/llvm/lib/IR/Constants.cpp +++ b/llvm/lib/IR/Constants.cpp @@ -2160,18 +2160,20 @@ bool ConstantPtrAuth::isKnownCompatibleWith(const Value *Key, const Value *AddrDiscriminator, const Value *IntDisc, const DataLayout &DL) const { - - if (getKey() != Key) - return false; - - // Three-operand bundle implies blend! - if (!hasAddressDiscriminator()) + // If the keys are different, there's no chance for this to be compatible. + // FIXME: Should we enforce i64 everywhere? + if (getKey()->getZExtValue() != cast(Key)->getZExtValue()) return false; if (getDiscriminator() != IntDisc) return false; - // FIXME: Copied from the original method: + // Key and IntDisc are compatible, let's check AddrDiscriminator. + + // If neither this constant nor the requested schema has an address + // discriminator, we are done. + if (!hasAddressDiscriminator() && match(AddrDiscriminator, m_Zero())) + return true; // Discriminators are i64, so the provided addr disc may be a ptrtoint. if (auto *Cast = dyn_cast(AddrDiscriminator)) From 7b8adcaaa7bae8f6a3d1b1f1f0dd4cdebad5797c Mon Sep 17 00:00:00 2001 From: Anatoly Trosinenko Date: Fri, 31 Oct 2025 14:43:00 +0300 Subject: [PATCH 13/40] Removing compatibility hacks from ISel --- llvm/lib/IR/Constants.cpp | 30 ++--- .../Target/AArch64/AArch64ISelDAGToDAG.cpp | 54 +------- .../Target/AArch64/AArch64ISelLowering.cpp | 79 ++---------- llvm/lib/Target/AArch64/AArch64InstrInfo.td | 49 ++++---- .../AArch64/AArch64SelectionDAGInfo.cpp | 32 +++++ .../Target/AArch64/AArch64SelectionDAGInfo.h | 7 ++ .../AArch64/GISel/AArch64GlobalISelUtils.cpp | 41 ++---- llvm/test/CodeGen/AArch64/ptrauth-call.ll | 119 +++++++----------- ...trauth-intrinsic-auth-resign-with-blend.ll | 59 +-------- 9 files changed, 144 insertions(+), 326 deletions(-) diff --git a/llvm/lib/IR/Constants.cpp b/llvm/lib/IR/Constants.cpp index f6fa708d752a4..d35479476d947 100644 --- a/llvm/lib/IR/Constants.cpp +++ b/llvm/lib/IR/Constants.cpp @@ -2223,34 +2223,18 @@ bool ConstantPtrAuth::isKnownCompatibleWith(const Value *Key, if (!hasAddressDiscriminator()) return getDiscriminator() == Discriminator; - // Otherwise, we can isolate address and integer discriminator components. - const Value *AddrDiscriminator = nullptr; - - // This constant may or may not have an integer discriminator (instead of 0). - if (!getDiscriminator()->isNullValue()) { - // If it does, there's an implicit blend. We need to have a matching blend - // intrinsic in the provided full discriminator. - if (!match(Discriminator, - m_Intrinsic( - m_Value(AddrDiscriminator), m_Specific(getDiscriminator())))) - return false; - } else { - // Otherwise, interpret the provided full discriminator as address-only. - AddrDiscriminator = Discriminator; - } - - // Either way, we can now focus on comparing the address discriminators. + // We can now focus on comparing the address discriminators. // Discriminators are i64, so the provided addr disc may be a ptrtoint. - if (auto *Cast = dyn_cast(AddrDiscriminator)) - AddrDiscriminator = Cast->getPointerOperand(); + if (auto *Cast = dyn_cast(Discriminator)) + Discriminator = Cast->getPointerOperand(); // Beyond that, we're only interested in compatible pointers. - if (getAddrDiscriminator()->getType() != AddrDiscriminator->getType()) + if (getAddrDiscriminator()->getType() != Discriminator->getType()) return false; // These are often the same constant GEP, making them trivially equivalent. - if (getAddrDiscriminator() == AddrDiscriminator) + if (getAddrDiscriminator() == Discriminator) return true; // Finally, they may be equivalent base+offset expressions. @@ -2258,8 +2242,8 @@ bool ConstantPtrAuth::isKnownCompatibleWith(const Value *Key, auto *Base1 = getAddrDiscriminator()->stripAndAccumulateConstantOffsets( DL, Off1, /*AllowNonInbounds=*/true); - APInt Off2(DL.getIndexTypeSizeInBits(AddrDiscriminator->getType()), 0); - auto *Base2 = AddrDiscriminator->stripAndAccumulateConstantOffsets( + APInt Off2(DL.getIndexTypeSizeInBits(Discriminator->getType()), 0); + auto *Base2 = Discriminator->stripAndAccumulateConstantOffsets( DL, Off2, /*AllowNonInbounds=*/true); return Base1 == Base2 && Off1 == Off2; diff --git a/llvm/lib/Target/AArch64/AArch64ISelDAGToDAG.cpp b/llvm/lib/Target/AArch64/AArch64ISelDAGToDAG.cpp index b3a76f3730a5b..d002c307c6db9 100644 --- a/llvm/lib/Target/AArch64/AArch64ISelDAGToDAG.cpp +++ b/llvm/lib/Target/AArch64/AArch64ISelDAGToDAG.cpp @@ -1509,59 +1509,16 @@ void AArch64DAGToDAGISel::SelectTable(SDNode *N, unsigned NumVecs, unsigned Opc, ReplaceNode(N, CurDAG->getMachineNode(Opc, dl, VT, Ops)); } -static std::tuple -extractPtrauthBlendDiscriminators(SDValue Bundle, SelectionDAG *DAG) { - SDLoc DL(Bundle); - SDValue AddrDisc; - SDValue ConstDisc; - - assert(Bundle->getOpcode() == ISD::PtrAuthBundle); - unsigned KeyC = cast(Bundle->getOperand(0))->getZExtValue(); - SDValue Key = DAG->getTargetConstant(KeyC, DL, MVT::i64); - - if (Bundle->getNumOperands() == 3) - return std::make_tuple(Key, Bundle->getOperand(1), Bundle->getOperand(2)); - - // Be compatible for now. - assert(Bundle->getNumOperands() == 2); - SDValue Disc = Bundle->getOperand(1); - - // If this is a blend, remember the constant and address discriminators. - // Otherwise, it's either a constant discriminator, or a non-blended - // address discriminator. - if (Disc->getOpcode() == ISD::INTRINSIC_WO_CHAIN && - Disc->getConstantOperandVal(0) == Intrinsic::ptrauth_blend) { - AddrDisc = Disc->getOperand(1); - ConstDisc = Disc->getOperand(2); - } else { - ConstDisc = Disc; - } - - // If the constant discriminator (either the blend RHS, or the entire - // discriminator value) isn't a 16-bit constant, bail out, and let the - // discriminator be computed separately. - auto *ConstDiscN = dyn_cast(ConstDisc); - if (!ConstDiscN || !isUInt<16>(ConstDiscN->getZExtValue())) - return std::make_tuple(Key, DAG->getTargetConstant(0, DL, MVT::i64), Disc); - - // If there's no address discriminator, use XZR directly. - if (!AddrDisc) - AddrDisc = DAG->getRegister(AArch64::XZR, MVT::i64); - - return std::make_tuple( - Key, - DAG->getTargetConstant(ConstDiscN->getZExtValue(), DL, MVT::i64), - AddrDisc); -} - void AArch64DAGToDAGISel::SelectPtrauthAuth(SDNode *N) { + const AArch64SelectionDAGInfo *SDI = Subtarget->getSelectionDAGInfo(); SDLoc DL(N); + assert(N->getOpcode() == ISD::PtrAuthAuth); SDValue Val = N->getOperand(0); SDValue AUTSchema = N->getOperand(1); auto [AUTKey, AUTConstDisc, AUTAddrDisc] = - extractPtrauthBlendDiscriminators(AUTSchema, CurDAG); + SDI->extractPtrauthBlendDiscriminators(AUTSchema, CurDAG); if (!Subtarget->isX16X17Safer()) { std::vector Ops = {Val, AUTKey, AUTConstDisc, AUTAddrDisc}; @@ -1583,6 +1540,7 @@ void AArch64DAGToDAGISel::SelectPtrauthAuth(SDNode *N) { } void AArch64DAGToDAGISel::SelectPtrauthResign(SDNode *N) { + const AArch64SelectionDAGInfo *SDI = Subtarget->getSelectionDAGInfo(); SDLoc DL(N); assert(N->getOpcode() == ISD::PtrAuthResign); SDValue Val = N->getOperand(0); @@ -1590,9 +1548,9 @@ void AArch64DAGToDAGISel::SelectPtrauthResign(SDNode *N) { SDValue PACSchema = N->getOperand(2); auto [AUTKey, AUTConstDisc, AUTAddrDisc] = - extractPtrauthBlendDiscriminators(AUTSchema, CurDAG); + SDI->extractPtrauthBlendDiscriminators(AUTSchema, CurDAG); auto [PACKey, PACConstDisc, PACAddrDisc] = - extractPtrauthBlendDiscriminators(PACSchema, CurDAG); + SDI->extractPtrauthBlendDiscriminators(PACSchema, CurDAG); SDValue X16Copy = CurDAG->getCopyToReg(CurDAG->getEntryNode(), DL, AArch64::X16, Val, SDValue()); diff --git a/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp b/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp index 10c916e8b081f..f4eeb4fe238b9 100644 --- a/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp +++ b/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp @@ -351,46 +351,6 @@ static bool isZeroingInactiveLanes(SDValue Op) { } } -static std::tuple -extractPtrauthBlendDiscriminators(SmallVector Operands, SelectionDAG *DAG) { - SDValue AddrDisc; - SDValue ConstDisc; - - if (Operands.size() == 3) - return {Operands[2], Operands[1]}; - - // Stay fully compatible for now. - SDValue Disc = Operands[1]; - SDLoc DL(Disc); - - // If this is a blend, remember the constant and address discriminators. - // Otherwise, it's either a constant discriminator, or a non-blended - // address discriminator. - if (Disc->getOpcode() == ISD::INTRINSIC_WO_CHAIN && - Disc->getConstantOperandVal(0) == Intrinsic::ptrauth_blend) { - AddrDisc = Disc->getOperand(1); - ConstDisc = Disc->getOperand(2); - } else { - ConstDisc = Disc; - } - - // If the constant discriminator (either the blend RHS, or the entire - // discriminator value) isn't a 16-bit constant, bail out, and let the - // discriminator be computed separately. - const auto *ConstDiscN = dyn_cast(ConstDisc); - if (!ConstDiscN || !isUInt<16>(ConstDiscN->getZExtValue())) - return std::make_tuple(DAG->getTargetConstant(0, DL, MVT::i64), Disc); - - // If there's no address discriminator, use NoRegister, which we'll later - // replace with XZR, or directly use a Z variant of the inst. when available. - if (!AddrDisc) - AddrDisc = DAG->getRegister(AArch64::NoRegister, MVT::i64); - - return std::make_tuple( - DAG->getTargetConstant(ConstDiscN->getZExtValue(), DL, MVT::i64), - AddrDisc); -} - AArch64TargetLowering::AArch64TargetLowering(const TargetMachine &TM, const AArch64Subtarget &STI) : TargetLowering(TM, STI), Subtarget(&STI) { @@ -3336,43 +3296,19 @@ void AArch64TargetLowering::fixupPtrauthDiscriminator( Register AddrDisc = AddrDiscOp.getReg(); int64_t IntDisc = IntDiscOp.getImm(); - assert(IntDisc == 0 && "Blend components are already expanded"); - - const MachineInstr *DiscMI = stripVRegCopies(MRI, AddrDisc); - if (DiscMI) { - switch (DiscMI->getOpcode()) { - case AArch64::MOVKXi: - // blend(addr, imm) which is lowered as "MOVK addr, #imm, #48". - // #imm should be an immediate and not a global symbol, for example. - if (DiscMI->getOperand(2).isImm() && - DiscMI->getOperand(3).getImm() == 48) { - AddrDisc = DiscMI->getOperand(1).getReg(); - IntDisc = DiscMI->getOperand(2).getImm(); - } - break; - case AArch64::MOVi32imm: - case AArch64::MOVi64imm: - // Small immediate integer constant passed via VReg. - if (DiscMI->getOperand(1).isImm() && - isUInt<16>(DiscMI->getOperand(1).getImm())) { - AddrDisc = AArch64::NoRegister; - IntDisc = DiscMI->getOperand(1).getImm(); - } - break; - } - } // For uniformity, always use NoRegister, as XZR is not necessarily contained // in the requested register class. if (AddrDisc == AArch64::XZR) AddrDisc = AArch64::NoRegister; - +#if 0 // Make sure AddrDisc operand respects the register class imposed by MI. if (AddrDisc && MRI.getRegClass(AddrDisc) != AddrDiscRC) { Register TmpReg = MRI.createVirtualRegister(AddrDiscRC); BuildMI(*BB, MI, DL, TII->get(AArch64::COPY), TmpReg).addReg(AddrDisc); AddrDisc = TmpReg; } +#endif AddrDiscOp.setReg(AddrDisc); IntDiscOp.setImm(IntDisc); @@ -9568,6 +9504,7 @@ static bool shouldLowerTailCallStackArg(const MachineFunction &MF, SDValue AArch64TargetLowering::LowerCall(CallLoweringInfo &CLI, SmallVectorImpl &InVals) const { + const AArch64SelectionDAGInfo *SDI = Subtarget->getSelectionDAGInfo(); SelectionDAG &DAG = CLI.DAG; SDLoc &DL = CLI.DL; SmallVector &Outs = CLI.Outs; @@ -10163,16 +10100,14 @@ AArch64TargetLowering::LowerCall(CallLoweringInfo &CLI, } if (CLI.PAI) { - // Split the discriminator into address/integer components. - SDValue AddrDisc, IntDisc; - std::tie(IntDisc, AddrDisc) = - extractPtrauthBlendDiscriminators(CLI.PAI->Operands, &DAG); + auto [Key, IntDisc, AddrDisc] = + SDI->extractPtrauthBlendDiscriminators(CLI.PAI->Operands, DL, &DAG); if (Opc == AArch64ISD::CALL_RVMARKER) Opc = AArch64ISD::AUTH_CALL_RVMARKER; else Opc = IsTailCall ? AArch64ISD::AUTH_TC_RETURN : AArch64ISD::AUTH_CALL; - Ops.push_back(CLI.PAI->Operands[0]); + Ops.push_back(Key); Ops.push_back(IntDisc); Ops.push_back(AddrDisc); } @@ -10676,7 +10611,7 @@ AArch64TargetLowering::LowerDarwinGlobalTLSAddress(SDValue Op, // With ptrauth-calls, the tlv access thunk pointer is authenticated (IA, 0). if (DAG.getMachineFunction().getFunction().hasFnAttribute("ptrauth-calls")) { Opcode = AArch64ISD::AUTH_CALL; - Ops.push_back(DAG.getConstant(AArch64PACKey::IA, DL, MVT::i32)); + Ops.push_back(DAG.getTargetConstant(AArch64PACKey::IA, DL, MVT::i64)); Ops.push_back(DAG.getTargetConstant(0, DL, MVT::i64)); // Integer Disc. Ops.push_back(DAG.getRegister(AArch64::NoRegister, MVT::i64)); // Addr Disc. } diff --git a/llvm/lib/Target/AArch64/AArch64InstrInfo.td b/llvm/lib/Target/AArch64/AArch64InstrInfo.td index 16d14f6ea8f1d..1cd8fb6d215e0 100644 --- a/llvm/lib/Target/AArch64/AArch64InstrInfo.td +++ b/llvm/lib/Target/AArch64/AArch64InstrInfo.td @@ -817,7 +817,7 @@ def AArch64call_arm64ec_to_x64 : SDNode<"AArch64ISD::CALL_ARM64EC_TO_X64", // AUTH_CALL chain, callee, auth key #, int disc, addr disc, operands. def AArch64authcall : SDNode<"AArch64ISD::AUTH_CALL", SDTypeProfile<0, -1, [SDTCisPtrTy<0>, - SDTCisVT<1, i32>, + SDTCisVT<1, i64>, SDTCisVT<2, i64>, SDTCisVT<3, i64>]>, [SDNPHasChain, SDNPOptInGlue, SDNPOutGlue, @@ -827,7 +827,7 @@ def AArch64authcall : SDNode<"AArch64ISD::AUTH_CALL", // operands. def AArch64authtcret: SDNode<"AArch64ISD::AUTH_TC_RETURN", SDTypeProfile<0, 5, [SDTCisPtrTy<0>, - SDTCisVT<2, i32>, + SDTCisVT<2, i64>, SDTCisVT<3, i64>, SDTCisVT<4, i64>]>, [SDNPHasChain, SDNPOptInGlue, SDNPVariadic]>; @@ -837,7 +837,7 @@ def AArch64authcall_rvmarker : SDNode<"AArch64ISD::AUTH_CALL_RVMARKER", SDTypeProfile<0, -1, [SDTCisPtrTy<0>, SDTCisVT<1, i32>, SDTCisPtrTy<2>, - SDTCisVT<3, i32>, + SDTCisVT<3, i64>, SDTCisVT<4, i64>, SDTCisVT<5, i64>]>, [SDNPHasChain, SDNPOptInGlue, SDNPOutGlue, @@ -2125,9 +2125,9 @@ let Predicates = [HasPAuth] in { // operations (such as raw address manipulation or discriminator // materialization here), in part because they're handled in a safer way by // the kernel, notably on Darwin. - def BLRA : Pseudo<(outs), (ins GPR64noip:$Rn, i32imm:$Key, i64imm:$Disc, + def BLRA : Pseudo<(outs), (ins GPR64noip:$Rn, i64imm:$Key, i64imm:$Disc, GPR64:$AddrDisc), - [(AArch64authcall GPR64noip:$Rn, imm:$Key, timm:$Disc, + [(AArch64authcall GPR64noip:$Rn, timm:$Key, timm:$Disc, GPR64:$AddrDisc)]>, Sched<[]> { let isCodeGenOnly = 1; let hasSideEffects = 1; @@ -2141,9 +2141,9 @@ let Predicates = [HasPAuth] in { def BLRA_RVMARKER : Pseudo< (outs), (ins i64imm:$rvfunc, i32imm:$withmarker, GPR64noip:$Rn, - i32imm:$Key, i64imm:$Disc, GPR64:$AddrDisc), + i64imm:$Key, i64imm:$Disc, GPR64:$AddrDisc), [(AArch64authcall_rvmarker tglobaladdr:$rvfunc, timm:$withmarker, - GPR64noip:$Rn, imm:$Key, timm:$Disc, + GPR64noip:$Rn, timm:$Key, timm:$Disc, GPR64:$AddrDisc)]>, Sched<[]> { let isCodeGenOnly = 1; let isCall = 1; @@ -2154,7 +2154,7 @@ let Predicates = [HasPAuth] in { // BRA pseudo, generalized version of BRAA/BRAB/Z. // This directly manipulates x16/x17, which are the only registers the OS // guarantees are safe to use for sensitive operations. - def BRA : Pseudo<(outs), (ins GPR64noip:$Rn, i32imm:$Key, i64imm:$Disc, + def BRA : Pseudo<(outs), (ins GPR64noip:$Rn, i64imm:$Key, i64imm:$Disc, GPR64noip:$AddrDisc), []>, Sched<[]> { let isCodeGenOnly = 1; let hasNoSchedulingInfo = 1; @@ -2182,7 +2182,7 @@ let Predicates = [HasPAuth] in { // AUT pseudo. // This directly manipulates x16/x17, which are the only registers that // certain OSs guarantee are safe to use for sensitive operations. - def AUTx16x17 : Pseudo<(outs), (ins i32imm:$Key, i64imm:$Disc, + def AUTx16x17 : Pseudo<(outs), (ins i64imm:$Key, i64imm:$Disc, GPR64noip:$AddrDisc), []>, Sched<[WriteI, ReadI]> { let isCodeGenOnly = 1; @@ -2195,7 +2195,7 @@ let Predicates = [HasPAuth] in { } def AUTxMxN : Pseudo<(outs GPR64:$AuthVal, GPR64common:$Scratch), - (ins GPR64:$Val, i32imm:$Key, + (ins GPR64:$Val, i64imm:$Key, i64imm:$Disc, GPR64:$AddrDisc), [], "$AuthVal = $Val">, Sched<[WriteI, ReadI]> { let isCodeGenOnly = 1; @@ -2213,7 +2213,12 @@ let Predicates = [HasPAuth] in { // if an attacker is able to substitute AddrDisc. def PAC : Pseudo<(outs GPR64:$SignedVal), (ins GPR64:$Val, i64imm:$Key, i64imm:$Disc, GPR64noip:$AddrDisc), - [], "$SignedVal = $Val">, Sched<[WriteI, ReadI]> { + [(set GPR64:$SignedVal, + (ptrauth_sign GPR64:$Val, + (ptrauth_bundle (i64 imm:$Key), + GPR64noip:$AddrDisc, + (i64 imm:$Disc))))], + "$SignedVal = $Val">, Sched<[WriteI, ReadI]> { let isCodeGenOnly = 1; let hasSideEffects = 0; let mayStore = 0; @@ -2224,17 +2229,13 @@ let Predicates = [HasPAuth] in { let supportsDeactivationSymbol = true; } - // A standalone pattern is used, so that literal 0 can be passed as $Disc. - def : Pat<(ptrauth_sign GPR64:$Val, (ptrauth_bundle (i64 imm:$Key), GPR64noip:$AddrDisc)), - (PAC GPR64:$Val, imm:$Key, 0, GPR64noip:$AddrDisc)>; - // AUT and re-PAC a value, using different keys/data. // This directly manipulates x16/x17, which are the only registers that // certain OSs guarantee are safe to use for sensitive operations. def AUTPAC : Pseudo<(outs), - (ins i32imm:$AUTKey, i64imm:$AUTDisc, GPR64noip:$AUTAddrDisc, - i32imm:$PACKey, i64imm:$PACDisc, GPR64noip:$PACAddrDisc), + (ins i64imm:$AUTKey, i64imm:$AUTDisc, GPR64noip:$AUTAddrDisc, + i64imm:$PACKey, i64imm:$PACDisc, GPR64noip:$PACAddrDisc), []>, Sched<[WriteI, ReadI]> { let isCodeGenOnly = 1; let hasSideEffects = 1; @@ -2247,7 +2248,7 @@ let Predicates = [HasPAuth] in { // Materialize a signed global address, with adrp+add and PAC. def MOVaddrPAC : Pseudo<(outs), - (ins i64imm:$Addr, i32imm:$Key, + (ins i64imm:$Addr, i64imm:$Key, GPR64noip:$AddrDisc, i64imm:$Disc), []>, Sched<[WriteI, ReadI]> { let isReMaterializable = 1; @@ -2258,7 +2259,7 @@ let Predicates = [HasPAuth] in { // Materialize a signed global address, using a GOT load and PAC. def LOADgotPAC : Pseudo<(outs), - (ins i64imm:$Addr, i32imm:$Key, + (ins i64imm:$Addr, i64imm:$Key, GPR64noip:$AddrDisc, i64imm:$Disc), []>, Sched<[WriteI, ReadI]> { let isReMaterializable = 1; @@ -2276,7 +2277,7 @@ let Predicates = [HasPAuth] in { // Load a signed global address from a special $auth_ptr$ stub slot. def LOADauthptrstatic : Pseudo<(outs GPR64:$dst), - (ins i64imm:$Addr, i32imm:$Key, + (ins i64imm:$Addr, i64imm:$Key, i64imm:$Disc), []>, Sched<[WriteI, ReadI]> { let isReMaterializable = 1; @@ -2294,24 +2295,24 @@ let Predicates = [HasPAuth] in { let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1, Size = 16, Defs = [X16,X17], Uses = [SP] in { def AUTH_TCRETURN - : Pseudo<(outs), (ins tcGPRnotx16x17:$dst, i32imm:$FPDiff, i32imm:$Key, + : Pseudo<(outs), (ins tcGPRnotx16x17:$dst, i32imm:$FPDiff, i64imm:$Key, i64imm:$Disc, tcGPR64:$AddrDisc), []>, Sched<[WriteBrReg]>; def AUTH_TCRETURN_BTI - : Pseudo<(outs), (ins tcGPRx16x17:$dst, i32imm:$FPDiff, i32imm:$Key, + : Pseudo<(outs), (ins tcGPRx16x17:$dst, i32imm:$FPDiff, i64imm:$Key, i64imm:$Disc, tcGPRnotx16x17:$AddrDisc), []>, Sched<[WriteBrReg]>; } let Predicates = [TailCallAny] in - def : Pat<(AArch64authtcret tcGPRnotx16x17:$dst, (i32 timm:$FPDiff), (i32 imm:$Key), + def : Pat<(AArch64authtcret tcGPRnotx16x17:$dst, (i32 timm:$FPDiff), (i64 timm:$Key), (i64 timm:$Disc), tcGPR64:$AddrDisc), (AUTH_TCRETURN tcGPRnotx16x17:$dst, imm:$FPDiff, imm:$Key, imm:$Disc, tcGPR64:$AddrDisc)>; let Predicates = [TailCallX16X17] in def : Pat<(AArch64authtcret tcGPRx16x17:$dst, (i32 timm:$FPDiff), - (i32 imm:$Key), (i64 timm:$Disc), + (i64 timm:$Key), (i64 timm:$Disc), tcGPRnotx16x17:$AddrDisc), (AUTH_TCRETURN_BTI tcGPRx16x17:$dst, imm:$FPDiff, imm:$Key, imm:$Disc, tcGPRnotx16x17:$AddrDisc)>; diff --git a/llvm/lib/Target/AArch64/AArch64SelectionDAGInfo.cpp b/llvm/lib/Target/AArch64/AArch64SelectionDAGInfo.cpp index 48e03ad853d26..51f68dfcae8f7 100644 --- a/llvm/lib/Target/AArch64/AArch64SelectionDAGInfo.cpp +++ b/llvm/lib/Target/AArch64/AArch64SelectionDAGInfo.cpp @@ -12,6 +12,7 @@ #include "AArch64SelectionDAGInfo.h" #include "AArch64MachineFunctionInfo.h" +#include "llvm/CodeGen/SDPatternMatch.h" #define GET_SDNODE_DESC #include "AArch64GenSDNodeInfo.inc" @@ -341,3 +342,34 @@ SDValue AArch64SelectionDAGInfo::EmitTargetCodeForSetTag( DAG.setNodeMemRefs(cast(St), {BaseMemOperand}); return SDValue(St, 2); } + +std::tuple +AArch64SelectionDAGInfo::extractPtrauthBlendDiscriminators( + ArrayRef Operands, const SDLoc &DL, SelectionDAG *DAG) const { + using namespace SDPatternMatch; + + // Should be handled by AArch64TargetLowering::normalizePtrAuthBundle. + assert(Operands.size() == 3); + + auto *KeyN = cast(Operands[0]); + auto *ConstDiscN = cast(Operands[2]); + + SDValue AddrDisc = Operands[1]; + if (sd_match(Operands[1], m_SpecificInt(0))) + AddrDisc = DAG->getRegister(AArch64::XZR, MVT::i64); + + return std::make_tuple( + DAG->getTargetConstant(KeyN->getZExtValue(), DL, MVT::i64), + DAG->getTargetConstant(ConstDiscN->getZExtValue(), DL, MVT::i64), + AddrDisc); +} + +std::tuple +AArch64SelectionDAGInfo::extractPtrauthBlendDiscriminators( + SDValue Bundle, SelectionDAG *DAG) const { + assert(Bundle->getOpcode() == ISD::PtrAuthBundle); + SDLoc DL(Bundle); + SmallVector Operands(Bundle->ops()); + + return extractPtrauthBlendDiscriminators(Operands, DL, DAG); +} diff --git a/llvm/lib/Target/AArch64/AArch64SelectionDAGInfo.h b/llvm/lib/Target/AArch64/AArch64SelectionDAGInfo.h index 42c2797ebdd17..42287350cd793 100644 --- a/llvm/lib/Target/AArch64/AArch64SelectionDAGInfo.h +++ b/llvm/lib/Target/AArch64/AArch64SelectionDAGInfo.h @@ -62,6 +62,13 @@ class AArch64SelectionDAGInfo : public SelectionDAGGenTargetInfo { SDValue Chain, SDValue Dst, SDValue Src, SDValue Size, RTLIB::Libcall LC) const; + + std::tuple + extractPtrauthBlendDiscriminators(ArrayRef Operands, const SDLoc &DL, + SelectionDAG *DAG) const; + + std::tuple + extractPtrauthBlendDiscriminators(SDValue Bundle, SelectionDAG *DAG) const; }; } // namespace llvm diff --git a/llvm/lib/Target/AArch64/GISel/AArch64GlobalISelUtils.cpp b/llvm/lib/Target/AArch64/GISel/AArch64GlobalISelUtils.cpp index 0f409543e9ab5..0c0be19314247 100644 --- a/llvm/lib/Target/AArch64/GISel/AArch64GlobalISelUtils.cpp +++ b/llvm/lib/Target/AArch64/GISel/AArch64GlobalISelUtils.cpp @@ -99,40 +99,19 @@ bool AArch64GISelUtils::tryEmitBZero(MachineInstr &MI, std::tuple AArch64GISelUtils::extractPtrauthBlendDiscriminators(SmallVector Operands, MachineRegisterInfo &MRI) { - uint64_t KeyVal = getIConstantVRegVal(Operands[0], MRI)->getZExtValue(); - if (Operands.size() == 3) { - uint64_t ConstDiscVal = getIConstantVRegVal(Operands[2], MRI)->getZExtValue(); - assert(isUInt<16>(ConstDiscVal)); - return { KeyVal, ConstDiscVal, Operands[1] }; - } - - // Stay fully compatible for now. - Register Disc = Operands[1]; + // Should be handled by AArch64TargetLowering::normalizePtrAuthBundle. + assert(Operands.size() == 3); - Register AddrDisc = Disc; - uint16_t ConstDisc = 0; - - if (auto ConstDiscVal = getIConstantVRegVal(Disc, MRI)) { - if (isUInt<16>(ConstDiscVal->getZExtValue())) { - ConstDisc = ConstDiscVal->getZExtValue(); - AddrDisc = AArch64::NoRegister; - } - return std::make_tuple(KeyVal, ConstDisc, AddrDisc); - } + uint64_t KeyVal = getIConstantVRegVal(Operands[0], MRI)->getZExtValue(); + uint64_t ConstDiscVal = getIConstantVRegVal(Operands[2], MRI)->getZExtValue(); + assert(isUInt<16>(ConstDiscVal)); - const MachineInstr *DiscMI = MRI.getVRegDef(Disc); - if (!DiscMI || DiscMI->getOpcode() != TargetOpcode::G_INTRINSIC || - DiscMI->getOperand(1).getIntrinsicID() != Intrinsic::ptrauth_blend) - return std::make_tuple(KeyVal, ConstDisc, AddrDisc); + Register AddrDisc = Operands[1]; + std::optional AddrDiscVal = getIConstantVRegVal(AddrDisc, MRI); + if (AddrDiscVal && AddrDiscVal->isZero()) + AddrDisc = AArch64::NoRegister; - if (auto ConstDiscVal = - getIConstantVRegVal(DiscMI->getOperand(3).getReg(), MRI)) { - if (isUInt<16>(ConstDiscVal->getZExtValue())) { - ConstDisc = ConstDiscVal->getZExtValue(); - AddrDisc = DiscMI->getOperand(2).getReg(); - } - } - return std::make_tuple(KeyVal, ConstDisc, AddrDisc); + return { KeyVal, ConstDiscVal, AddrDisc }; } void AArch64GISelUtils::changeFCMPPredToAArch64CC( diff --git a/llvm/test/CodeGen/AArch64/ptrauth-call.ll b/llvm/test/CodeGen/AArch64/ptrauth-call.ll index 921ad7a632ef2..e91de2d2643ad 100644 --- a/llvm/test/CodeGen/AArch64/ptrauth-call.ll +++ b/llvm/test/CodeGen/AArch64/ptrauth-call.ll @@ -25,7 +25,7 @@ define i32 @test_call_ia_0(ptr %arg0) #0 { ; ELF-NEXT: blraaz x0 ; ELF-NEXT: ldr x30, [sp], #16 ; ELF-NEXT: ret - %tmp0 = call i32 %arg0() [ "ptrauth"(i32 0, i64 0) ] + %tmp0 = call i32 %arg0() [ "ptrauth"(i64 0, i64 0) ] ret i32 %tmp0 } @@ -41,21 +41,21 @@ define i32 @test_call_ib_0(ptr %arg0) #0 { ; ELF-NEXT: blrabz x0 ; ELF-NEXT: ldr x30, [sp], #16 ; ELF-NEXT: ret - %tmp0 = call i32 %arg0() [ "ptrauth"(i32 1, i64 0) ] + %tmp0 = call i32 %arg0() [ "ptrauth"(i64 1, i64 0) ] ret i32 %tmp0 } define i32 @test_tailcall_ia_0(ptr %arg0) #0 { ; CHECK-LABEL: test_tailcall_ia_0: ; CHECK-NEXT: braaz x0 - %tmp0 = tail call i32 %arg0() [ "ptrauth"(i32 0, i64 0) ] + %tmp0 = tail call i32 %arg0() [ "ptrauth"(i64 0, i64 0) ] ret i32 %tmp0 } define i32 @test_tailcall_ib_0(ptr %arg0) #0 { ; CHECK-LABEL: test_tailcall_ib_0: ; CHECK-NEXT: brabz x0 - %tmp0 = tail call i32 %arg0() [ "ptrauth"(i32 1, i64 0) ] + %tmp0 = tail call i32 %arg0() [ "ptrauth"(i64 1, i64 0) ] ret i32 %tmp0 } @@ -73,7 +73,7 @@ define i32 @test_call_ia_imm(ptr %arg0) #0 { ; ELF-NEXT: blraa x0, x17 ; ELF-NEXT: ldr x30, [sp], #16 ; ELF-NEXT: ret - %tmp0 = call i32 %arg0() [ "ptrauth"(i32 0, i64 42) ] + %tmp0 = call i32 %arg0() [ "ptrauth"(i64 0, i64 42) ] ret i32 %tmp0 } @@ -91,7 +91,7 @@ define i32 @test_call_ib_imm(ptr %arg0) #0 { ; ELF-NEXT: blrab x0, x17 ; ELF-NEXT: ldr x30, [sp], #16 ; ELF-NEXT: ret - %tmp0 = call i32 %arg0() [ "ptrauth"(i32 1, i64 42) ] + %tmp0 = call i32 %arg0() [ "ptrauth"(i64 1, i64 42) ] ret i32 %tmp0 } @@ -99,7 +99,7 @@ define i32 @test_tailcall_ia_imm(ptr %arg0) #0 { ; CHECK-LABEL: test_tailcall_ia_imm: ; CHECK-NEXT: mov x16, #42 ; CHECK-NEXT: braa x0, x16 - %tmp0 = tail call i32 %arg0() [ "ptrauth"(i32 0, i64 42) ] + %tmp0 = tail call i32 %arg0() [ "ptrauth"(i64 0, i64 42) ] ret i32 %tmp0 } @@ -107,7 +107,7 @@ define i32 @test_tailcall_ib_imm(ptr %arg0) #0 { ; CHECK-LABEL: test_tailcall_ib_imm: ; CHECK-NEXT: mov x16, #42 ; CHECK-NEXT: brab x0, x16 - %tmp0 = tail call i32 %arg0() [ "ptrauth"(i32 1, i64 42) ] + %tmp0 = tail call i32 %arg0() [ "ptrauth"(i64 1, i64 42) ] ret i32 %tmp0 } @@ -126,7 +126,7 @@ define i32 @test_call_ia_var(ptr %arg0, ptr %arg1) #0 { ; ELF-NEXT: ldr x30, [sp], #16 ; ELF-NEXT: ret %tmp0 = load i64, ptr %arg1 - %tmp1 = call i32 %arg0() [ "ptrauth"(i32 0, i64 %tmp0) ] + %tmp1 = call i32 %arg0() [ "ptrauth"(i64 0, i64 %tmp0) ] ret i32 %tmp1 } @@ -145,7 +145,7 @@ define i32 @test_call_ib_var(ptr %arg0, ptr %arg1) #0 { ; ELF-NEXT: ldr x30, [sp], #16 ; ELF-NEXT: ret %tmp0 = load i64, ptr %arg1 - %tmp1 = call i32 %arg0() [ "ptrauth"(i32 1, i64 %tmp0) ] + %tmp1 = call i32 %arg0() [ "ptrauth"(i64 1, i64 %tmp0) ] ret i32 %tmp1 } @@ -154,7 +154,7 @@ define i32 @test_tailcall_ia_var(ptr %arg0, ptr %arg1) #0 { ; CHECK: ldr x1, [x1] ; CHECK: braa x0, x1 %tmp0 = load i64, ptr %arg1 - %tmp1 = tail call i32 %arg0() [ "ptrauth"(i32 0, i64 %tmp0) ] + %tmp1 = tail call i32 %arg0() [ "ptrauth"(i64 0, i64 %tmp0) ] ret i32 %tmp1 } @@ -163,7 +163,7 @@ define i32 @test_tailcall_ib_var(ptr %arg0, ptr %arg1) #0 { ; CHECK: ldr x1, [x1] ; CHECK: brab x0, x1 %tmp0 = load i64, ptr %arg1 - %tmp1 = tail call i32 %arg0() [ "ptrauth"(i32 1, i64 %tmp0) ] + %tmp1 = tail call i32 %arg0() [ "ptrauth"(i64 1, i64 %tmp0) ] ret i32 %tmp1 } @@ -181,7 +181,7 @@ define i32 @test_call_da_0(ptr %arg0) #0 { ; ELF-NEXT: blr x0 ; ELF-NEXT: ldr x30, [sp], #16 ; ELF-NEXT: ret - %tmp0 = call i32 %arg0() [ "ptrauth"(i32 2, i64 0) ] + %tmp0 = call i32 %arg0() [ "ptrauth"(i64 2, i64 0) ] ret i32 %tmp0 } @@ -199,7 +199,7 @@ define i32 @test_call_db_0(ptr %arg0) #0 { ; ELF-NEXT: blr x0 ; ELF-NEXT: ldr x30, [sp], #16 ; ELF-NEXT: ret - %tmp0 = call i32 %arg0() [ "ptrauth"(i32 3, i64 0) ] + %tmp0 = call i32 %arg0() [ "ptrauth"(i64 3, i64 0) ] ret i32 %tmp0 } @@ -219,7 +219,7 @@ define i32 @test_call_da_imm(ptr %arg0) #0 { ; ELF-NEXT: blr x0 ; ELF-NEXT: ldr x30, [sp], #16 ; ELF-NEXT: ret - %tmp0 = call i32 %arg0() [ "ptrauth"(i32 2, i64 42) ] + %tmp0 = call i32 %arg0() [ "ptrauth"(i64 2, i64 42) ] ret i32 %tmp0 } @@ -239,7 +239,7 @@ define i32 @test_call_db_imm(ptr %arg0) #0 { ; ELF-NEXT: blr x0 ; ELF-NEXT: ldr x30, [sp], #16 ; ELF-NEXT: ret - %tmp0 = call i32 %arg0() [ "ptrauth"(i32 3, i64 42) ] + %tmp0 = call i32 %arg0() [ "ptrauth"(i64 3, i64 42) ] ret i32 %tmp0 } @@ -247,7 +247,7 @@ define i32 @test_tailcall_da_0(ptr %arg0) #0 { ; CHECK-LABEL: test_tailcall_da_0: ; CHECK-NEXT: autdza x0 ; CHECK-NEXT: br x0 - %tmp0 = tail call i32 %arg0() [ "ptrauth"(i32 2, i64 0) ] + %tmp0 = tail call i32 %arg0() [ "ptrauth"(i64 2, i64 0) ] ret i32 %tmp0 } @@ -255,7 +255,7 @@ define i32 @test_tailcall_db_0(ptr %arg0) #0 { ; CHECK-LABEL: test_tailcall_db_0: ; CHECK-NEXT: autdzb x0 ; CHECK-NEXT: br x0 - %tmp0 = tail call i32 %arg0() [ "ptrauth"(i32 3, i64 0) ] + %tmp0 = tail call i32 %arg0() [ "ptrauth"(i64 3, i64 0) ] ret i32 %tmp0 } @@ -264,7 +264,7 @@ define i32 @test_tailcall_da_imm(ptr %arg0) #0 { ; CHECK-NEXT: mov x16, #42 ; CHECK-NEXT: autda x0, x16 ; CHECK-NEXT: br x0 - %tmp0 = tail call i32 %arg0() [ "ptrauth"(i32 2, i64 42) ] + %tmp0 = tail call i32 %arg0() [ "ptrauth"(i64 2, i64 42) ] ret i32 %tmp0 } @@ -273,7 +273,7 @@ define i32 @test_tailcall_db_imm(ptr %arg0) #0 { ; CHECK-NEXT: mov x16, #42 ; CHECK-NEXT: autdb x0, x16 ; CHECK-NEXT: br x0 - %tmp0 = tail call i32 %arg0() [ "ptrauth"(i32 3, i64 42) ] + %tmp0 = tail call i32 %arg0() [ "ptrauth"(i64 3, i64 42) ] ret i32 %tmp0 } @@ -296,13 +296,11 @@ define void @test_tailcall_omit_mov_x16_x16(ptr %objptr) #0 { ; ELF-NEXT: braa x2, x16 %vtable.signed = load ptr, ptr %objptr, align 8 %objptr.int = ptrtoint ptr %objptr to i64 - %vtable.discr = tail call i64 @llvm.ptrauth.blend(i64 %objptr.int, i64 6503) %vtable.signed.int = ptrtoint ptr %vtable.signed to i64 - %vtable.unsigned.int = tail call i64 @llvm.ptrauth.auth(i64 %vtable.signed.int) [ "ptrauth"(i64 2, i64 %vtable.discr) ] + %vtable.unsigned.int = tail call i64 @llvm.ptrauth.auth(i64 %vtable.signed.int) [ "ptrauth"(i64 2, i64 %objptr.int, i64 6503) ] %vtable.unsigned = inttoptr i64 %vtable.unsigned.int to ptr %virt.func.signed = load ptr, ptr %vtable.unsigned, align 8 - %virt.func.discr = tail call i64 @llvm.ptrauth.blend(i64 %vtable.unsigned.int, i64 54167) - tail call void %virt.func.signed(ptr %objptr) [ "ptrauth"(i32 0, i64 %virt.func.discr) ] + tail call void %virt.func.signed(ptr %objptr) [ "ptrauth"(i64 0, i64 %vtable.unsigned.int, i64 54167) ] ret void } @@ -332,13 +330,11 @@ define i32 @test_call_omit_extra_moves(ptr %objptr) #0 { ; CHECK-NEXT: ret %vtable.signed = load ptr, ptr %objptr %objptr.int = ptrtoint ptr %objptr to i64 - %vtable.discr = tail call i64 @llvm.ptrauth.blend(i64 %objptr.int, i64 6503) %vtable.signed.int = ptrtoint ptr %vtable.signed to i64 - %vtable.int = tail call i64 @llvm.ptrauth.auth(i64 %vtable.signed.int) [ "ptrauth"(i64 2, i64 %vtable.discr) ] + %vtable.int = tail call i64 @llvm.ptrauth.auth(i64 %vtable.signed.int) [ "ptrauth"(i64 2, i64 %objptr.int, i64 6503) ] %vtable = inttoptr i64 %vtable.int to ptr %callee.signed = load ptr, ptr %vtable - %callee.discr = tail call i64 @llvm.ptrauth.blend(i64 %vtable.int, i64 34646) - %call.result = tail call i32 %callee.signed(ptr %objptr) [ "ptrauth"(i32 0, i64 %callee.discr) ] + %call.result = tail call i32 %callee.signed(ptr %objptr) [ "ptrauth"(i64 0, i64 %vtable.int, i64 34646) ] ret i32 42 } @@ -359,9 +355,8 @@ define i64 @test_call_discr_csr_live(ptr %fnptr, i64 %addr.discr) #0 { ; ELF-NEXT: ldp x20, x19, [sp, #16] ; ELF-NEXT: ldr x30, [sp], #32 ; ELF-NEXT: ret - %discr = tail call i64 @llvm.ptrauth.blend(i64 %addr.discr, i64 6503) - tail call void %fnptr() [ "ptrauth"(i32 0, i64 %discr) ] - tail call void %fnptr() [ "ptrauth"(i32 0, i64 %discr) ] + tail call void %fnptr() [ "ptrauth"(i64 0, i64 %addr.discr, i64 6503) ] + tail call void %fnptr() [ "ptrauth"(i64 0, i64 %addr.discr, i64 6503) ] ret i64 %addr.discr } @@ -382,9 +377,8 @@ define i64 @test_call_discr_csr_killed(ptr %fnptr, i64 %addr.discr) #0 { ; ELF-NEXT: mov w0, #42 ; ELF-NEXT: ldr x30, [sp], #32 ; ELF-NEXT: ret - %discr = tail call i64 @llvm.ptrauth.blend(i64 %addr.discr, i64 6503) - tail call void %fnptr() [ "ptrauth"(i32 0, i64 %discr) ] - tail call void %fnptr() [ "ptrauth"(i32 0, i64 %discr) ] + tail call void %fnptr() [ "ptrauth"(i64 0, i64 %addr.discr, i64 6503) ] + tail call void %fnptr() [ "ptrauth"(i64 0, i64 %addr.discr, i64 6503) ] ret i64 42 } @@ -400,8 +394,7 @@ define i64 @test_call_discr_arg(ptr %fnptr, i64 %addr.discr) #0 { ; ELF-NEXT: mov w0, #42 ; ELF-NEXT: ldr x30, [sp], #16 ; ELF-NEXT: ret - %discr = tail call i64 @llvm.ptrauth.blend(i64 %addr.discr, i64 6503) - tail call void %fnptr(ptr null, i64 %addr.discr) [ "ptrauth"(i32 0, i64 %discr) ] + tail call void %fnptr(ptr null, i64 %addr.discr) [ "ptrauth"(i64 0, i64 %addr.discr, i64 6503) ] ret i64 42 } @@ -415,8 +408,7 @@ define i64 @test_call_discr_non_arg(ptr %fnptr, i64 %addr.discr) #0 { ; ELF-NEXT: mov w0, #42 ; ELF-NEXT: ldr x30, [sp], #16 ; ELF-NEXT: ret - %discr = tail call i64 @llvm.ptrauth.blend(i64 %addr.discr, i64 6503) - tail call void %fnptr() [ "ptrauth"(i32 0, i64 %discr) ] + tail call void %fnptr() [ "ptrauth"(i64 0, i64 %addr.discr, i64 6503) ] ret i64 42 } @@ -428,8 +420,7 @@ define i64 @test_tailcall_discr_arg(ptr %fnptr, i64 %addr.discr) #0 { ; ELF-NEXT: mov x16, x1 ; ELF-NEXT: movk x16, #6503, lsl #48 ; ELF-NEXT: braa x2, x16 - %discr = tail call i64 @llvm.ptrauth.blend(i64 %addr.discr, i64 6503) - %result = tail call i64 %fnptr(ptr null, i64 %addr.discr) [ "ptrauth"(i32 0, i64 %discr) ] + %result = tail call i64 %fnptr(ptr null, i64 %addr.discr) [ "ptrauth"(i64 0, i64 %addr.discr, i64 6503) ] ret i64 %result } @@ -445,7 +436,7 @@ define i32 @test_call_ia_arg(ptr %arg0, i64 %arg1) #0 { ; ELF-NEXT: blraa x0, x1 ; ELF-NEXT: ldr x30, [sp], #16 ; ELF-NEXT: ret - %tmp0 = call i32 %arg0() [ "ptrauth"(i32 0, i64 %arg1) ] + %tmp0 = call i32 %arg0() [ "ptrauth"(i64 0, i64 %arg1) ] ret i32 %tmp0 } @@ -461,21 +452,21 @@ define i32 @test_call_ib_arg(ptr %arg0, i64 %arg1) #0 { ; ELF-NEXT: blrab x0, x1 ; ELF-NEXT: ldr x30, [sp], #16 ; ELF-NEXT: ret - %tmp0 = call i32 %arg0() [ "ptrauth"(i32 1, i64 %arg1) ] + %tmp0 = call i32 %arg0() [ "ptrauth"(i64 1, i64 %arg1) ] ret i32 %tmp0 } define i32 @test_tailcall_ia_arg(ptr %arg0, i64 %arg1) #0 { ; CHECK-LABEL: test_tailcall_ia_arg: ; CHECK: braa x0, x1 - %tmp0 = tail call i32 %arg0() [ "ptrauth"(i32 0, i64 %arg1) ] + %tmp0 = tail call i32 %arg0() [ "ptrauth"(i64 0, i64 %arg1) ] ret i32 %tmp0 } define i32 @test_tailcall_ib_arg(ptr %arg0, i64 %arg1) #0 { ; CHECK-LABEL: test_tailcall_ib_arg: ; CHECK: brab x0, x1 - %tmp0 = tail call i32 %arg0() [ "ptrauth"(i32 1, i64 %arg1) ] + %tmp0 = tail call i32 %arg0() [ "ptrauth"(i64 1, i64 %arg1) ] ret i32 %tmp0 } @@ -494,7 +485,7 @@ define i32 @test_call_ia_arg_ind(ptr %arg0, i64 %arg1) #0 { ; ELF-NEXT: ldr x30, [sp], #16 ; ELF-NEXT: ret %tmp0 = load ptr, ptr %arg0 - %tmp1 = call i32 %tmp0() [ "ptrauth"(i32 0, i64 %arg1) ] + %tmp1 = call i32 %tmp0() [ "ptrauth"(i64 0, i64 %arg1) ] ret i32 %tmp1 } @@ -513,7 +504,7 @@ define i32 @test_call_ib_arg_ind(ptr %arg0, i64 %arg1) #0 { ; ELF-NEXT: ldr x30, [sp], #16 ; ELF-NEXT: ret %tmp0 = load ptr, ptr %arg0 - %tmp1 = call i32 %tmp0() [ "ptrauth"(i32 1, i64 %arg1) ] + %tmp1 = call i32 %tmp0() [ "ptrauth"(i64 1, i64 %arg1) ] ret i32 %tmp1 } @@ -522,7 +513,7 @@ define i32 @test_tailcall_ia_arg_ind(ptr %arg0, i64 %arg1) #0 { ; CHECK: ldr x0, [x0] ; CHECK: braa x0, x1 %tmp0 = load ptr, ptr %arg0 - %tmp1 = tail call i32 %tmp0() [ "ptrauth"(i32 0, i64 %arg1) ] + %tmp1 = tail call i32 %tmp0() [ "ptrauth"(i64 0, i64 %arg1) ] ret i32 %tmp1 } @@ -531,7 +522,7 @@ define i32 @test_tailcall_ib_arg_ind(ptr %arg0, i64 %arg1) #0 { ; CHECK: ldr x0, [x0] ; CHECK: brab x0, x1 %tmp0 = load ptr, ptr %arg0 - %tmp1 = tail call i32 %tmp0() [ "ptrauth"(i32 1, i64 %arg1) ] + %tmp1 = tail call i32 %tmp0() [ "ptrauth"(i64 1, i64 %arg1) ] ret i32 %tmp1 } @@ -549,7 +540,7 @@ define i32 @test_direct_call() #0 { ; ELF-NEXT: bl f ; ELF-NEXT: ldr x30, [sp], #16 ; ELF-NEXT: ret - %tmp0 = call i32 ptrauth(ptr @f, i32 0, i64 42)() [ "ptrauth"(i32 0, i64 42) ] + %tmp0 = call i32 ptrauth(ptr @f, i32 0, i64 42)() [ "ptrauth"(i64 0, i64 42) ] ret i32 %tmp0 } @@ -559,7 +550,7 @@ define i32 @test_direct_tailcall(ptr %arg0) #0 { ; ; ELF-LABEL: test_direct_tailcall: ; ELF-NEXT: b f - %tmp0 = tail call i32 ptrauth(ptr @f, i32 0, i64 42)() [ "ptrauth"(i32 0, i64 42) ] + %tmp0 = tail call i32 ptrauth(ptr @f, i32 0, i64 42)() [ "ptrauth"(i64 0, i64 42) ] ret i32 %tmp0 } @@ -587,7 +578,7 @@ define i32 @test_direct_call_mismatch() #0 { ; ELF-NEXT: blrab x8, x17 ; ELF-NEXT: ldr x30, [sp], #16 ; ELF-NEXT: ret - %tmp0 = call i32 ptrauth(ptr @f, i32 0, i64 42)() [ "ptrauth"(i32 1, i64 42) ] + %tmp0 = call i32 ptrauth(ptr @f, i32 0, i64 42)() [ "ptrauth"(i64 1, i64 42) ] ret i32 %tmp0 } @@ -603,7 +594,7 @@ define i32 @test_direct_call_addr() #0 { ; ELF-NEXT: bl f ; ELF-NEXT: ldr x30, [sp], #16 ; ELF-NEXT: ret - %tmp0 = call i32 ptrauth(ptr @f, i32 1, i64 0, ptr @f.ref.ib.0.addr)() [ "ptrauth"(i32 1, i64 ptrtoint (ptr @f.ref.ib.0.addr to i64)) ] + %tmp0 = call i32 ptrauth(ptr @f, i32 1, i64 0, ptr @f.ref.ib.0.addr)() [ "ptrauth"(i64 1, i64 ptrtoint (ptr @f.ref.ib.0.addr to i64)) ] ret i32 %tmp0 } @@ -619,24 +610,7 @@ define i32 @test_direct_call_addr_blend() #0 { ; ELF-NEXT: bl f ; ELF-NEXT: ldr x30, [sp], #16 ; ELF-NEXT: ret - %tmp0 = call i64 @llvm.ptrauth.blend(i64 ptrtoint (ptr @f.ref.ib.42.addr to i64), i64 42) - %tmp1 = call i32 ptrauth(ptr @f, i32 1, i64 42, ptr @f.ref.ib.42.addr)() [ "ptrauth"(i32 1, i64 %tmp0) ] - ret i32 %tmp1 -} - -define i32 @test_direct_call_addr_blending_bundle() #0 { -; DARWIN-LABEL: test_direct_call_addr_blending_bundle: -; DARWIN-NEXT: stp x29, x30, [sp, #-16]! -; DARWIN-NEXT: bl _f -; DARWIN-NEXT: ldp x29, x30, [sp], #16 -; DARWIN-NEXT: ret -; -; ELF-LABEL: test_direct_call_addr_blending_bundle: -; ELF-NEXT: str x30, [sp, #-16]! -; ELF-NEXT: bl f -; ELF-NEXT: ldr x30, [sp], #16 -; ELF-NEXT: ret - %tmp1 = call i32 ptrauth(ptr @f, i32 1, i64 42, ptr @f.ref.ib.42.addr)() [ "ptrauth"(i32 1, i64 ptrtoint (ptr @f.ref.ib.42.addr to i64), i64 42) ] + %tmp1 = call i32 ptrauth(ptr @f, i32 1, i64 42, ptr @f.ref.ib.42.addr)() [ "ptrauth"(i64 1, i64 ptrtoint (ptr @f.ref.ib.42.addr to i64), i64 42) ] ret i32 %tmp1 } @@ -652,7 +626,7 @@ define i32 @test_direct_call_addr_gep_different_index_types() #0 { ; ELF-NEXT: bl f ; ELF-NEXT: ldr x30, [sp], #16 ; ELF-NEXT: ret - %tmp0 = call i32 ptrauth(ptr @f, i32 1, i64 0, ptr getelementptr ({ ptr }, ptr @f_struct.ref.ib.0.addr, i64 0, i32 0))() [ "ptrauth"(i32 1, i64 ptrtoint (ptr getelementptr ({ ptr }, ptr @f_struct.ref.ib.0.addr, i32 0, i32 0) to i64)) ] + %tmp0 = call i32 ptrauth(ptr @f, i32 1, i64 0, ptr getelementptr ({ ptr }, ptr @f_struct.ref.ib.0.addr, i64 0, i32 0))() [ "ptrauth"(i64 1, i64 ptrtoint (ptr getelementptr ({ ptr }, ptr @f_struct.ref.ib.0.addr, i32 0, i32 0) to i64)) ] ret i32 %tmp0 } @@ -668,8 +642,7 @@ define i32 @test_direct_call_addr_blend_gep_different_index_types() #0 { ; ELF-NEXT: bl f ; ELF-NEXT: ldr x30, [sp], #16 ; ELF-NEXT: ret - %tmp0 = call i64 @llvm.ptrauth.blend(i64 ptrtoint (ptr getelementptr ({ ptr }, ptr @f_struct.ref.ib.123.addr, i32 0, i32 0) to i64), i64 123) - %tmp1 = call i32 ptrauth(ptr @f, i32 1, i64 123, ptr getelementptr ({ ptr }, ptr @f_struct.ref.ib.123.addr, i64 0, i32 0))() [ "ptrauth"(i32 1, i64 %tmp0) ] + %tmp1 = call i32 ptrauth(ptr @f, i32 1, i64 123, ptr getelementptr ({ ptr }, ptr @f_struct.ref.ib.123.addr, i64 0, i32 0))() [ "ptrauth"(i64 1, i64 ptrtoint (ptr getelementptr ({ ptr }, ptr @f_struct.ref.ib.123.addr, i32 0, i32 0) to i64), i64 123) ] ret i32 %tmp1 } diff --git a/llvm/test/CodeGen/AArch64/ptrauth-intrinsic-auth-resign-with-blend.ll b/llvm/test/CodeGen/AArch64/ptrauth-intrinsic-auth-resign-with-blend.ll index a4c1b2b13eab0..3ad56a5ba0916 100644 --- a/llvm/test/CodeGen/AArch64/ptrauth-intrinsic-auth-resign-with-blend.ll +++ b/llvm/test/CodeGen/AArch64/ptrauth-intrinsic-auth-resign-with-blend.ll @@ -73,8 +73,7 @@ define i64 @test_auth_blend(i64 %arg, i64 %arg1) { ; TRAP-NEXT: Lauth_success_0: ; TRAP-DARWIN-NEXT: mov x0, x16 ; TRAP-NEXT: ret - %tmp0 = call i64 @llvm.ptrauth.blend(i64 %arg1, i64 65535) - %tmp1 = call i64 @llvm.ptrauth.auth(i64 %arg) [ "ptrauth"(i64 2, i64 %tmp0) ] + %tmp1 = call i64 @llvm.ptrauth.auth(i64 %arg) [ "ptrauth"(i64 2, i64 %arg1, i64 65535) ] ret i64 %tmp1 } @@ -134,9 +133,7 @@ define i64 @test_resign_blend(i64 %arg, i64 %arg1, i64 %arg2) { ; TRAP-NEXT: pacdb x16, x17 ; TRAP-NEXT: mov x0, x16 ; TRAP-NEXT: ret - %tmp0 = call i64 @llvm.ptrauth.blend(i64 %arg1, i64 12345) - %tmp1 = call i64 @llvm.ptrauth.blend(i64 %arg2, i64 56789) - %tmp2 = call i64 @llvm.ptrauth.resign(i64 %arg) [ "ptrauth"(i64 2, i64 %tmp0), "ptrauth"(i64 3, i64 %tmp1) ] + %tmp2 = call i64 @llvm.ptrauth.resign(i64 %arg) [ "ptrauth"(i64 2, i64 %arg1, i64 12345), "ptrauth"(i64 3, i64 %arg2, i64 56789) ] ret i64 %tmp2 } @@ -193,8 +190,7 @@ define i64 @test_resign_blend_and_const(i64 %arg, i64 %arg1) { ; TRAP-NEXT: pacdb x16, x17 ; TRAP-NEXT: mov x0, x16 ; TRAP-NEXT: ret - %tmp0 = call i64 @llvm.ptrauth.blend(i64 %arg1, i64 12345) - %tmp1 = call i64 @llvm.ptrauth.resign(i64 %arg) [ "ptrauth"(i64 2, i64 %tmp0), "ptrauth"(i64 3, i64 56789) ] + %tmp1 = call i64 @llvm.ptrauth.resign(i64 %arg) [ "ptrauth"(i64 2, i64 %arg1, i64 12345), "ptrauth"(i64 3, i64 56789) ] ret i64 %tmp1 } @@ -248,54 +244,7 @@ define i64 @test_resign_blend_and_addr(i64 %arg, i64 %arg1, i64 %arg2) { ; TRAP-NEXT: pacdb x16, x2 ; TRAP-NEXT: mov x0, x16 ; TRAP-NEXT: ret - %tmp0 = call i64 @llvm.ptrauth.blend(i64 %arg1, i64 12345) - %tmp1 = call i64 @llvm.ptrauth.resign(i64 %arg) [ "ptrauth"(i64 2, i64 %tmp0), "ptrauth"(i64 3, i64 %arg2) ] - ret i64 %tmp1 -} - -define i64 @test_auth_too_large_discriminator(i64 %arg, i64 %arg1) { -; UNCHECKED-LABEL: test_auth_too_large_discriminator: -; UNCHECKED: %bb.0: -; UNCHECKED-NEXT: mov w8, #65536 -; UNCHECKED-DARWIN-NEXT: bfi x1, x8, #48, #16 -; UNCHECKED-DARWIN-NEXT: mov x16, x0 -; UNCHECKED-DARWIN-NEXT: autda x16, x1 -; UNCHECKED-DARWIN-NEXT: mov x0, x16 -; UNCHECKED-ELF-NEXT: bfi x1, x8, #48, #16 -; UNCHECKED-ELF-NEXT: autda x0, x1 -; UNCHECKED-NEXT: ret -; -; CHECKED-LABEL: test_auth_too_large_discriminator: -; CHECKED: %bb.0: -; CHECKED-NEXT: mov w8, #65536 -; CHECKED-DARWIN-NEXT: bfi x1, x8, #48, #16 -; CHECKED-DARWIN-NEXT: mov x16, x0 -; CHECKED-DARWIN-NEXT: autda x16, x1 -; CHECKED-DARWIN-NEXT: mov x0, x16 -; CHECKED-ELF-NEXT: bfi x1, x8, #48, #16 -; CHECKED-ELF-NEXT: autda x0, x1 -; CHECKED-NEXT: ret -; -; TRAP-LABEL: test_auth_too_large_discriminator: -; TRAP: %bb.0: -; TRAP-NEXT: mov w8, #65536 -; TRAP-NEXT: bfi x1, x8, #48, #16 -; TRAP-DARWIN-NEXT: mov x16, x0 -; TRAP-DARWIN-NEXT: autda x16, x1 -; TRAP-DARWIN-NEXT: mov x17, x16 -; TRAP-DARWIN-NEXT: xpacd x17 -; TRAP-DARWIN-NEXT: cmp x16, x17 -; TRAP-ELF-NEXT: autda x0, x1 -; TRAP-ELF-NEXT: mov x8, x0 -; TRAP-ELF-NEXT: xpacd x8 -; TRAP-ELF-NEXT: cmp x0, x8 -; TRAP-NEXT: b.eq [[L]]auth_success_4 -; TRAP-NEXT: brk #0xc472 -; TRAP-NEXT: Lauth_success_4: -; TRAP-DARWIN-NEXT: mov x0, x16 -; TRAP-NEXT: ret - %tmp0 = call i64 @llvm.ptrauth.blend(i64 %arg1, i64 65536) - %tmp1 = call i64 @llvm.ptrauth.auth(i64 %arg) [ "ptrauth"(i64 2, i64 %tmp0) ] + %tmp1 = call i64 @llvm.ptrauth.resign(i64 %arg) [ "ptrauth"(i64 2, i64 %arg1, i64 12345), "ptrauth"(i64 3, i64 %arg2) ] ret i64 %tmp1 } From 30aa9638ba6cc4ac6bfb9b9c44d0b723a1191641 Mon Sep 17 00:00:00 2001 From: Anatoly Trosinenko Date: Fri, 31 Oct 2025 17:25:01 +0300 Subject: [PATCH 14/40] Update InstCombine tests --- .../test/Transforms/InstCombine/ptrauth-call.ll | 17 +++++------------ .../InstCombine/ptrauth-intrinsics-call.ll | 17 ++++++----------- .../InstCombine/ptrauth-intrinsics.ll | 15 +++++---------- 3 files changed, 16 insertions(+), 33 deletions(-) diff --git a/llvm/test/Transforms/InstCombine/ptrauth-call.ll b/llvm/test/Transforms/InstCombine/ptrauth-call.ll index eefe593361c05..fa8f4117579f9 100644 --- a/llvm/test/Transforms/InstCombine/ptrauth-call.ll +++ b/llvm/test/Transforms/InstCombine/ptrauth-call.ll @@ -40,8 +40,7 @@ define i32 @test_ptrauth_call_blend(i32 %a0) { ; CHECK-NEXT: [[V0:%.*]] = call i32 @f(i32 [[A0:%.*]]) ; CHECK-NEXT: ret i32 [[V0]] ; - %v = call i64 @llvm.ptrauth.blend(i64 ptrtoint (ptr @f_both_disc.ref to i64), i64 1234) - %v0 = call i32 ptrauth(ptr @f, i32 1, i64 1234, ptr @f_both_disc.ref)(i32 %a0) [ "ptrauth"(i32 1, i64 %v) ] + %v0 = call i32 ptrauth(ptr @f, i32 1, i64 1234, ptr @f_both_disc.ref)(i32 %a0) [ "ptrauth"(i32 1, i64 ptrtoint (ptr @f_both_disc.ref to i64), i64 1234) ] ret i32 %v0 } @@ -74,24 +73,18 @@ define i32 @test_ptrauth_call_mismatch_disc(i32 %a0) { define i32 @test_ptrauth_call_mismatch_blend(i32 %a0) { ; CHECK-LABEL: @test_ptrauth_call_mismatch_blend( -; CHECK-NEXT: [[V:%.*]] = call i64 @llvm.ptrauth.blend(i64 ptrtoint (ptr @f_both_disc.ref to i64), i64 0) -; CHECK-NEXT: [[V0:%.*]] = call i32 ptrauth (ptr @f, i32 1, i64 1234, ptr @f_both_disc.ref)(i32 [[A0:%.*]]) [ "ptrauth"(i32 1, i64 [[V]]) ] +; CHECK-NEXT: [[V0:%.*]] = call i32 ptrauth (ptr @f, i32 1, i64 1234, ptr @f_both_disc.ref)(i32 [[A0:%.*]]) [ "ptrauth"(i32 1, i64 ptrtoint (ptr @f_both_disc.ref to i64), i64 0) ] ; CHECK-NEXT: ret i32 [[V0]] ; - %v = call i64 @llvm.ptrauth.blend(i64 ptrtoint (ptr @f_both_disc.ref to i64), i64 0) - %v0 = call i32 ptrauth(ptr @f, i32 1, i64 1234, ptr @f_both_disc.ref)(i32 %a0) [ "ptrauth"(i32 1, i64 %v) ] + %v0 = call i32 ptrauth(ptr @f, i32 1, i64 1234, ptr @f_both_disc.ref)(i32 %a0) [ "ptrauth"(i32 1, i64 ptrtoint (ptr @f_both_disc.ref to i64), i64 0) ] ret i32 %v0 } define i32 @test_ptrauth_call_mismatch_blend_addr(i32 %a0) { ; CHECK-LABEL: @test_ptrauth_call_mismatch_blend_addr( -; CHECK-NEXT: [[V:%.*]] = call i64 @llvm.ptrauth.blend(i64 ptrtoint (ptr @f_addr_disc.ref to i64), i64 1234) -; CHECK-NEXT: [[V0:%.*]] = call i32 ptrauth (ptr @f, i32 1, i64 1234, ptr @f_both_disc.ref)(i32 [[A0:%.*]]) [ "ptrauth"(i32 1, i64 [[V]]) ] +; CHECK-NEXT: [[V0:%.*]] = call i32 ptrauth (ptr @f, i32 1, i64 1234, ptr @f_both_disc.ref)(i32 [[A0:%.*]]) [ "ptrauth"(i32 1, i64 ptrtoint (ptr @f_addr_disc.ref to i64), i64 1234) ] ; CHECK-NEXT: ret i32 [[V0]] ; - %v = call i64 @llvm.ptrauth.blend(i64 ptrtoint (ptr @f_addr_disc.ref to i64), i64 1234) - %v0 = call i32 ptrauth(ptr @f, i32 1, i64 1234, ptr @f_both_disc.ref)(i32 %a0) [ "ptrauth"(i32 1, i64 %v) ] + %v0 = call i32 ptrauth(ptr @f, i32 1, i64 1234, ptr @f_both_disc.ref)(i32 %a0) [ "ptrauth"(i32 1, i64 ptrtoint (ptr @f_addr_disc.ref to i64), i64 1234) ] ret i32 %v0 } - -declare i64 @llvm.ptrauth.blend(i64, i64) diff --git a/llvm/test/Transforms/InstCombine/ptrauth-intrinsics-call.ll b/llvm/test/Transforms/InstCombine/ptrauth-intrinsics-call.ll index f7a4ad981a6cf..b35d8c006c359 100644 --- a/llvm/test/Transforms/InstCombine/ptrauth-intrinsics-call.ll +++ b/llvm/test/Transforms/InstCombine/ptrauth-intrinsics-call.ll @@ -46,10 +46,9 @@ define i32 @test_ptrauth_call_resign_blend(ptr %pp) { %v0 = load ptr, ptr %pp, align 8 %v1 = ptrtoint ptr %pp to i64 %v2 = ptrtoint ptr %v0 to i64 - %v3 = call i64 @llvm.ptrauth.blend(i64 %v1, i64 5678) - %v4 = call i64 @llvm.ptrauth.resign(i64 %v2) [ "ptrauth"(i64 1, i64 1234), "ptrauth"(i64 1, i64 %v3) ] + %v4 = call i64 @llvm.ptrauth.resign(i64 %v2) [ "ptrauth"(i64 1, i64 1234), "ptrauth"(i64 1, i64 %v1, i64 5678) ] %v5 = inttoptr i64 %v4 to ptr - %v6 = call i32 %v5() [ "ptrauth"(i64 1, i64 %v3) ] + %v6 = call i32 %v5() [ "ptrauth"(i64 1, i64 %v1, i64 5678) ] ret i32 %v6 } @@ -57,15 +56,13 @@ define i32 @test_ptrauth_call_resign_blend_2(ptr %pp) { ; CHECK-LABEL: @test_ptrauth_call_resign_blend_2( ; CHECK-NEXT: [[V01:%.*]] = load ptr, ptr [[PP:%.*]], align 8 ; CHECK-NEXT: [[V1:%.*]] = ptrtoint ptr [[PP]] to i64 -; CHECK-NEXT: [[V3:%.*]] = call i64 @llvm.ptrauth.blend(i64 [[V1]], i64 5678) -; CHECK-NEXT: [[V6:%.*]] = call i32 [[V01]]() [ "ptrauth"(i64 0, i64 [[V3]]) ] +; CHECK-NEXT: [[V6:%.*]] = call i32 [[V01]]() [ "ptrauth"(i64 0, i64 [[V1]], i64 5678) ] ; CHECK-NEXT: ret i32 [[V6]] ; %v0 = load ptr, ptr %pp, align 8 %v1 = ptrtoint ptr %pp to i64 %v2 = ptrtoint ptr %v0 to i64 - %v3 = call i64 @llvm.ptrauth.blend(i64 %v1, i64 5678) - %v4 = call i64 @llvm.ptrauth.resign(i64 %v2) [ "ptrauth"(i64 0, i64 %v3), "ptrauth"(i64 0, i64 1234) ] + %v4 = call i64 @llvm.ptrauth.resign(i64 %v2) [ "ptrauth"(i64 0, i64 %v1, i64 5678), "ptrauth"(i64 0, i64 1234) ] %v5 = inttoptr i64 %v4 to ptr %v6 = call i32 %v5() [ "ptrauth"(i64 0, i64 1234) ] ret i32 %v6 @@ -106,8 +103,7 @@ define i32 @test_ptrauth_call_resign_mismatch_blend(ptr %pp) { ; CHECK-NEXT: [[V0:%.*]] = load ptr, ptr [[PP:%.*]], align 8 ; CHECK-NEXT: [[V1:%.*]] = ptrtoint ptr [[PP]] to i64 ; CHECK-NEXT: [[V2:%.*]] = ptrtoint ptr [[V0]] to i64 -; CHECK-NEXT: [[V6:%.*]] = call i64 @llvm.ptrauth.blend(i64 [[V1]], i64 5678) -; CHECK-NEXT: [[V4:%.*]] = call i64 @llvm.ptrauth.resign(i64 [[V2]]) [ "ptrauth"(i64 1, i64 1234), "ptrauth"(i64 1, i64 [[V6]]) ] +; CHECK-NEXT: [[V4:%.*]] = call i64 @llvm.ptrauth.resign(i64 [[V2]]) [ "ptrauth"(i64 1, i64 1234), "ptrauth"(i64 1, i64 [[V1]], i64 5678) ] ; CHECK-NEXT: [[V5:%.*]] = inttoptr i64 [[V4]] to ptr ; CHECK-NEXT: [[V3:%.*]] = call i32 [[V5]]() [ "ptrauth"(i64 1, i64 [[V1]]) ] ; CHECK-NEXT: ret i32 [[V3]] @@ -115,8 +111,7 @@ define i32 @test_ptrauth_call_resign_mismatch_blend(ptr %pp) { %v0 = load ptr, ptr %pp, align 8 %v1 = ptrtoint ptr %pp to i64 %v2 = ptrtoint ptr %v0 to i64 - %v3 = call i64 @llvm.ptrauth.blend(i64 %v1, i64 5678) - %v4 = call i64 @llvm.ptrauth.resign(i64 %v2) [ "ptrauth"(i64 1, i64 1234), "ptrauth"(i64 1, i64 %v3) ] + %v4 = call i64 @llvm.ptrauth.resign(i64 %v2) [ "ptrauth"(i64 1, i64 1234), "ptrauth"(i64 1, i64 %v1, i64 5678) ] %v5 = inttoptr i64 %v4 to ptr %v6 = call i32 %v5() [ "ptrauth"(i64 1, i64 %v1) ] ret i32 %v6 diff --git a/llvm/test/Transforms/InstCombine/ptrauth-intrinsics.ll b/llvm/test/Transforms/InstCombine/ptrauth-intrinsics.ll index bf64c1abe1c3a..c65683e557dde 100644 --- a/llvm/test/Transforms/InstCombine/ptrauth-intrinsics.ll +++ b/llvm/test/Transforms/InstCombine/ptrauth-intrinsics.ll @@ -28,8 +28,7 @@ define i64 @test_ptrauth_nop_constant_addrdisc() { ; CHECK-NEXT: ret i64 ptrtoint (ptr @foo to i64) ; %addr = ptrtoint ptr @foo to i64 - %blended = call i64 @llvm.ptrauth.blend(i64 %addr, i64 1234) - %authed = call i64 @llvm.ptrauth.auth(i64 ptrtoint(ptr ptrauth(ptr @foo, i32 1, i64 1234, ptr @foo) to i64)) [ "ptrauth"(i64 1, i64 %blended) ] + %authed = call i64 @llvm.ptrauth.auth(i64 ptrtoint(ptr ptrauth(ptr @foo, i32 1, i64 1234, ptr @foo) to i64)) [ "ptrauth"(i64 1, i64 %addr, i64 1234) ] ret i64 %authed } @@ -128,25 +127,21 @@ define i64 @test_ptrauth_nop_constant_mismatch_key() { define i64 @test_ptrauth_nop_constant_addrdisc_mismatch() { ; CHECK-LABEL: @test_ptrauth_nop_constant_addrdisc_mismatch( -; CHECK-NEXT: [[BLENDED:%.*]] = call i64 @llvm.ptrauth.blend(i64 ptrtoint (ptr @foo to i64), i64 12) -; CHECK-NEXT: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 ptrtoint (ptr ptrauth (ptr @foo, i32 1, i64 1234, ptr @foo) to i64)) [ "ptrauth"(i64 1, i64 [[BLENDED]]) ] +; CHECK-NEXT: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 ptrtoint (ptr ptrauth (ptr @foo, i32 1, i64 1234, ptr @foo) to i64)) [ "ptrauth"(i64 1, i64 ptrtoint (ptr @foo to i64), i64 12) ] ; CHECK-NEXT: ret i64 [[AUTHED]] ; %addr = ptrtoint ptr @foo to i64 - %blended = call i64 @llvm.ptrauth.blend(i64 %addr, i64 12) - %authed = call i64 @llvm.ptrauth.auth(i64 ptrtoint(ptr ptrauth(ptr @foo, i32 1, i64 1234, ptr @foo) to i64)) [ "ptrauth"(i64 1, i64 %blended) ] + %authed = call i64 @llvm.ptrauth.auth(i64 ptrtoint(ptr ptrauth(ptr @foo, i32 1, i64 1234, ptr @foo) to i64)) [ "ptrauth"(i64 1, i64 %addr, i64 12) ] ret i64 %authed } define i64 @test_ptrauth_nop_constant_addrdisc_mismatch2() { ; CHECK-LABEL: @test_ptrauth_nop_constant_addrdisc_mismatch2( -; CHECK-NEXT: [[BLENDED:%.*]] = call i64 @llvm.ptrauth.blend(i64 ptrtoint (ptr @bar to i64), i64 1234) -; CHECK-NEXT: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 ptrtoint (ptr ptrauth (ptr @foo, i32 1, i64 1234, ptr @foo) to i64)) [ "ptrauth"(i64 1, i64 [[BLENDED]]) ] +; CHECK-NEXT: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 ptrtoint (ptr ptrauth (ptr @foo, i32 1, i64 1234, ptr @foo) to i64)) [ "ptrauth"(i64 1, i64 ptrtoint (ptr @bar to i64), i64 1234) ] ; CHECK-NEXT: ret i64 [[AUTHED]] ; %addr = ptrtoint ptr @bar to i64 - %blended = call i64 @llvm.ptrauth.blend(i64 %addr, i64 1234) - %authed = call i64 @llvm.ptrauth.auth(i64 ptrtoint(ptr ptrauth(ptr @foo, i32 1, i64 1234, ptr @foo) to i64)) [ "ptrauth"(i64 1, i64 %blended) ] + %authed = call i64 @llvm.ptrauth.auth(i64 ptrtoint(ptr ptrauth(ptr @foo, i32 1, i64 1234, ptr @foo) to i64)) [ "ptrauth"(i64 1, i64 %addr, i64 1234) ] ret i64 %authed } From 0b8df8ce6ca4ac9562e07d8c2c22122af9e75d8f Mon Sep 17 00:00:00 2001 From: Anatoly Trosinenko Date: Fri, 31 Oct 2025 19:29:13 +0300 Subject: [PATCH 15/40] Implement auto-upgrade --- llvm/include/llvm/IR/Intrinsics.td | 5 - llvm/lib/IR/AutoUpgrade.cpp | 184 ++++++++++++++++++ llvm/lib/Target/AArch64/AArch64InstrInfo.td | 8 - .../AArch64/ptrauth-intrinsic-blend.ll | 48 ----- .../AArch64/ptrauth-intrinsics-upgrade.ll | 125 ++++++++++++ llvm/test/CodeGen/AArch64/ptrauth-isel.ll | 70 ------- .../RISCV/rv32zknd-intrinsic-autoupgrade.ll | 14 ++ 7 files changed, 323 insertions(+), 131 deletions(-) delete mode 100644 llvm/test/CodeGen/AArch64/ptrauth-intrinsic-blend.ll create mode 100644 llvm/test/CodeGen/AArch64/ptrauth-intrinsics-upgrade.ll diff --git a/llvm/include/llvm/IR/Intrinsics.td b/llvm/include/llvm/IR/Intrinsics.td index b1e49aa61bfd4..91c13b061f9fd 100644 --- a/llvm/include/llvm/IR/Intrinsics.td +++ b/llvm/include/llvm/IR/Intrinsics.td @@ -2888,11 +2888,6 @@ def int_ptrauth_resign : Intrinsic<[llvm_i64_ty], [llvm_i64_ty], [IntrNoMem]>; def int_ptrauth_strip : DefaultAttrsIntrinsic<[llvm_i64_ty], [llvm_i64_ty], [IntrNoMem]>; -// Blend a small integer discriminator with an address discriminator, producing -// a new discriminator value. -def int_ptrauth_blend : - DefaultAttrsIntrinsic<[llvm_i64_ty], [llvm_i64_ty, llvm_i64_ty], [IntrNoMem]>; - // Compute the signature of a value, using a given discriminator. // This differs from @llvm.ptrauth.sign in that it doesn't embed the computed // signature in the pointer, but instead returns the signature as a value. diff --git a/llvm/lib/IR/AutoUpgrade.cpp b/llvm/lib/IR/AutoUpgrade.cpp index 487db134b0df3..97bc74a520d2b 100644 --- a/llvm/lib/IR/AutoUpgrade.cpp +++ b/llvm/lib/IR/AutoUpgrade.cpp @@ -1589,11 +1589,46 @@ static bool upgradeIntrinsicFunction1(Function *F, Function *&NewFn, {F->arg_begin()->getType(), F->getArg(1)->getType()}); return true; } + if (Name.consume_front("ptrauth.")) { + // @llvm.ptrauth.sign.generic does not require upgrade. + if (Name == "sign.generic") + break; + + // @llvm.ptrauth.blend is dropped altogether. + if (Name == "blend") { + NewFn = nullptr; + return true; + } + + // All other @llvm.ptrauth.* are upgraded to single-argument intrinsics + // with signing schemas passed via separate call operand bundles. + if (F->getFunctionType()->getNumParams() == 1) + break; + + // FIXME Has to match intrinsics by name prefix, otherwise intrinsics + // auto-declaration is not handled correctly. + Intrinsic::ID ID; + ID = StringSwitch(Name) + .StartsWith("auth", Intrinsic::ptrauth_auth) + .StartsWith("sign", Intrinsic::ptrauth_sign) + .StartsWith("resign", Intrinsic::ptrauth_resign) + .StartsWith("strip", Intrinsic::ptrauth_strip) + .Default(Intrinsic::not_intrinsic); + if (ID == Intrinsic::not_intrinsic) + break; + + rename(F); + NewFn = Intrinsic::getOrInsertDeclaration(F->getParent(), ID); + return true; + } break; case 'r': { if (Name.consume_front("riscv.")) { Intrinsic::ID ID; + // FIXME: Matching on the precise string instead of a substring seems to + // be incompatible with auto-declaration of intrinsics, see + // rv32zknd-intrinsic-autoupgrade.ll for example. ID = StringSwitch(Name) .Case("aes32dsi", Intrinsic::riscv_aes32dsi) .Case("aes32dsmi", Intrinsic::riscv_aes32dsmi) @@ -4673,6 +4708,140 @@ static void upgradeDbgIntrinsicToDbgRecord(StringRef Name, CallBase *CI) { CI->getParent()->insertDbgRecordBefore(DR, CI->getIterator()); } +static CallBase *setOperandBundles(CallBase *CI, ArrayRef OBs) { + IRBuilder<> Builder(CI); + Value *Callee = CI->getCalledOperand(); + SmallVector Args(CI->arg_begin(), CI->arg_end()); + CallBase *NewCI = Builder.CreateCall(CI->getFunctionType(), Callee, + Args, OBs); + NewCI->takeName(CI); + CI->replaceAllUsesWith(NewCI); + CI->eraseFromParent(); + + return NewCI; +} + +// Transitions a ptrauth intrinsic call site to a half-upgraded state: +// 1) call %0(a, b, c, d, e) -> call %0(a, 0, 0, 0, 0) [ "ptrauth"(b, c), +// "ptrauth"(d, e) ] +// 2) call %0(a, b, c) -> call %0(a, 0, 0) [ "ptrauth"(b, c) ] +// 3) call %0(a, b) -> call %0(a, 0) [ "ptrauth"(b) ] +// 4) any call site with operand bundles attached - kept intact +// +// Upgrading ptrauth intrinsics requires inspecting their discriminator +// operand(s), which can be computed by a separate call to blend(). +// +// Because @llvm.ptruath.blend intrinsic is removed by AutoUpgrader, the +// original computation of the discriminator may be removed before regular +// processing of its users occurs. For that reason, as soon as the particular +// call to @llvm.ptrauth.blend() is processed, all its users must be ready to +// absorb the arguments of the original blend call, even if the user is not +// fully resolved at that time. +// +// Thankfully, the transformations to be applied to any *supported* call site +// can be chosen depending merely on the number of arguments and operand +// bundles: in the example above, 1) corresponds to resign() call, 2) to auth() +// and sign(), 3) to strip() and 4) naturally captures the only original use +// case of "ptrauth" bundles (indirect authenticated calls) as well as any +// @llvm.ptrauth.* intrinsics which were lazily processed already. +// +// Note that the half-upgraded call formally uses the same called function +// and the same function signature as the original one. +// +// FIXME Catch unsupported cases like this: +// +// %blend = call i64 @llvm.ptrauth.blend(...) +// %callee = load ptr, ptr fn_ptr +// call void %callee(i64 %some_arg, i32 %other_arg, i64 %blend) +static CallBase *upgradeToPtrAuthBundles(CallBase *CI) { + if (CI->getNumOperandBundles()) + return CI; + + LLVMContext &Ctx = CI->getContext(); + Value *Zero32 = ConstantInt::get(Ctx, APInt::getZero(32)); + Value *Zero64 = ConstantInt::get(Ctx, APInt::getZero(64)); + SmallVector OBs; + + switch (CI->arg_size()) { + default: +#ifndef NDEBUG + CI->dump(); +#endif + llvm_unreachable("Unexpected intrinsic"); + case 2: + // strip(value, key) -> strip(value, 0) [ "ptrauth"(key) ] + OBs.emplace_back("ptrauth", ArrayRef({CI->getArgOperand(1)})); + CI->setArgOperand(1, Zero32); + break; + case 3: + // auth(value, key, disc) -> auth(value, 0, 0) [ "ptrauth"(...) ] + // sign(value, key, disc) -> sign(value, 0, 0) [ "ptrauth"(...) ] + OBs.emplace_back("ptrauth", ArrayRef({CI->getArgOperand(1), CI->getArgOperand(2)})); + CI->setArgOperand(1, Zero32); + CI->setArgOperand(2, Zero64); + break; + case 5: + // resign(value, old_key, old_disc, new_key, new_disc) -> + // resign(value, 0, 0, 0, 0) [ "ptrauth"(), + // "ptrauth"() ] + OBs.emplace_back("ptrauth", ArrayRef({CI->getArgOperand(1), CI->getArgOperand(2)})); + CI->setArgOperand(1, Zero32); + CI->setArgOperand(2, Zero64); + OBs.emplace_back("ptrauth", ArrayRef({CI->getArgOperand(3), CI->getArgOperand(4)})); + CI->setArgOperand(3, Zero32); + CI->setArgOperand(4, Zero64); + } + + // Attach operand bundles by re-creating the call. + return setOperandBundles(CI, OBs); +} + +// Fully process a call to @llvm.ptrauth.blend(), lazily updating its users +// to the extent that they are able to absorb the information from BlendCall. +static void upgradePtrAuthBlend(CallBase *BlendCall) { + // Collect all call instructions to be upgraded before performing any + // modifications. + SmallPtrSet UpgradableUsers; + for (User *U : BlendCall->users()) + if (auto *Call = dyn_cast(U)) + UpgradableUsers.insert(Call); + + Value *AddrDisc = BlendCall->getArgOperand(0); + Value *IntDisc = BlendCall->getArgOperand(1); + + for (CallBase *Call : UpgradableUsers) { + // Lazily migrate the user to "ptrauth" bundles first. + Call = upgradeToPtrAuthBundles(Call); + + SmallVector OBs; + Call->getOperandBundlesAsDefs(OBs); + + // Expand all bundles which refer to *this* blend() call. + // This may affect multiple bundles in case of resign() intrinsic which + // only changes the key. + for (unsigned I = 0, N = OBs.size(); I < N; ++I) { + auto OB = Call->getOperandBundleAt(I); + // Skip non-ptrauth bundles. + if (OB.getTagID() != LLVMContext::OB_ptrauth) + continue; + // Skip bundles not in the form "ptrauth"(key, %this_blend_call). + if (OB.Inputs.size() != 2 || OB.Inputs[1] != BlendCall) + continue; + + Value * NewBundleOperands[] = {OB.Inputs[0], AddrDisc, IntDisc}; + OBs[I] = OperandBundleDef("ptrauth", NewBundleOperands); + } + + setOperandBundles(Call, OBs); + } + + if (!BlendCall->users().empty()) { + errs() << "Cannot upgrade all uses of @llvm.ptrauth.blend in function:\n"; + BlendCall->getFunction()->print(errs()); + reportFatalUsageError("Cannot upgrade some uses of @llvm.ptrauth.blend()."); + } +} + /// Upgrade a call to an old intrinsic. All argument and return casting must be /// provided to seamlessly integrate with existing context. void llvm::UpgradeIntrinsicCall(CallBase *CI, Function *NewFn) { @@ -4704,6 +4873,8 @@ void llvm::UpgradeIntrinsicCall(CallBase *CI, Function *NewFn) { if (!IsX86 && Name == "stackprotectorcheck") { Rep = nullptr; + } else if (Name == "ptrauth.blend") { + upgradePtrAuthBlend(CI); } else if (IsNVVM) { Rep = upgradeNVVMIntrinsicCall(Name, CI, F, Builder); } else if (IsX86) { @@ -5390,6 +5561,19 @@ void llvm::UpgradeIntrinsicCall(CallBase *CI, Function *NewFn) { NewCall = Builder.CreateCall(NewFn, Args); break; } + case Intrinsic::ptrauth_auth: + case Intrinsic::ptrauth_sign: + case Intrinsic::ptrauth_resign: + case Intrinsic::ptrauth_strip: + CI = upgradeToPtrAuthBundles(CI); + Builder.SetInsertPoint(CI); + + Value *Args[] = {CI->getArgOperand(0)}; + SmallVector OBs; + CI->getOperandBundlesAsDefs(OBs); + + NewCall = Builder.CreateCall(NewFn, Args, OBs); + break; } assert(NewCall && "Should have either set this variable or returned through " "the default case"); diff --git a/llvm/lib/Target/AArch64/AArch64InstrInfo.td b/llvm/lib/Target/AArch64/AArch64InstrInfo.td index 1cd8fb6d215e0..41d6ee7a5af70 100644 --- a/llvm/lib/Target/AArch64/AArch64InstrInfo.td +++ b/llvm/lib/Target/AArch64/AArch64InstrInfo.td @@ -10904,14 +10904,6 @@ let Predicates = [HasMOPS_GO, HasMTE] in { defm SETGOE : MOPSGoMemorySetTaggingInsns<0b10, "setgoe">; } -//----------------------------------------------------------------------------- -// v8.3 Pointer Authentication late patterns - -def : Pat<(int_ptrauth_blend GPR64:$Rd, imm64_0_65535:$imm), - (MOVKXi GPR64:$Rd, (trunc_imm imm64_0_65535:$imm), 48)>; -def : Pat<(int_ptrauth_blend GPR64:$Rd, GPR64:$Rn), - (BFMXri GPR64:$Rd, GPR64:$Rn, 16, 15)>; - //----------------------------------------------------------------------------- // This gets lowered into an instruction sequence of 20 bytes diff --git a/llvm/test/CodeGen/AArch64/ptrauth-intrinsic-blend.ll b/llvm/test/CodeGen/AArch64/ptrauth-intrinsic-blend.ll deleted file mode 100644 index 2dc8a4cdb06dd..0000000000000 --- a/llvm/test/CodeGen/AArch64/ptrauth-intrinsic-blend.ll +++ /dev/null @@ -1,48 +0,0 @@ -; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py -; RUN: llc < %s -mtriple arm64e-apple-darwin -verify-machineinstrs -global-isel=0 | FileCheck %s -; RUN: llc < %s -mtriple arm64e-apple-darwin -verify-machineinstrs -global-isel=1 -global-isel-abort=1 | FileCheck %s -; RUN: llc < %s -mtriple aarch64-linux-gnu -mattr=+pauth -verify-machineinstrs -global-isel=0 | FileCheck %s -; RUN: llc < %s -mtriple aarch64-linux-gnu -mattr=+pauth -verify-machineinstrs -global-isel=1 -global-isel-abort=1 | FileCheck %s - -define i64 @test_blend(i64 %arg, i64 %arg1) { -; CHECK-LABEL: test_blend: -; CHECK: %bb.0: -; CHECK-NEXT: bfi x0, x1, #48, #16 -; CHECK-NEXT: ret - %tmp = call i64 @llvm.ptrauth.blend(i64 %arg, i64 %arg1) - ret i64 %tmp -} - -define i64 @test_blend_constant(i64 %arg) { -; CHECK-LABEL: test_blend_constant: -; CHECK: %bb.0: -; CHECK-NEXT: movk x0, #12345, lsl #48 -; CHECK-NEXT: ret - %tmp = call i64 @llvm.ptrauth.blend(i64 %arg, i64 12345) - ret i64 %tmp -} - -; Blend isn't commutative. -define i64 @test_blend_constant_swapped(i64 %arg) { -; CHECK-LABEL: test_blend_constant_swapped: -; CHECK: %bb.0: -; CHECK-NEXT: mov w8, #12345 -; CHECK-NEXT: bfi x8, x0, #48, #16 -; CHECK-NEXT: mov x0, x8 -; CHECK-NEXT: ret - %tmp = call i64 @llvm.ptrauth.blend(i64 12345, i64 %arg) - ret i64 %tmp -} - -; Blends of constants wider than 16 bits truncate the constant. -define i64 @test_blend_constant_wide(i64 %arg) { -; CHECK-LABEL: test_blend_constant_wide: -; CHECK: %bb.0: -; CHECK-NEXT: mov w8, #65536 -; CHECK-NEXT: bfi x0, x8, #48, #16 -; CHECK-NEXT: ret - %tmp = call i64 @llvm.ptrauth.blend(i64 %arg, i64 65536) - ret i64 %tmp -} - -declare i64 @llvm.ptrauth.blend(i64, i64) diff --git a/llvm/test/CodeGen/AArch64/ptrauth-intrinsics-upgrade.ll b/llvm/test/CodeGen/AArch64/ptrauth-intrinsics-upgrade.ll new file mode 100644 index 0000000000000..7271265aada5a --- /dev/null +++ b/llvm/test/CodeGen/AArch64/ptrauth-intrinsics-upgrade.ll @@ -0,0 +1,125 @@ +; NOTE: Assertions have been autogenerated by utils/update_test_checks.py +; RUN: opt < %s -S | FileCheck %s + +define void @test_ptrauth_sign(i64 %p, i64 %addr) { +; CHECK-LABEL: @test_ptrauth_sign( +; CHECK-NEXT: [[ZERO_DISCR:%.*]] = call i64 @llvm.ptrauth.sign(i64 [[P:%.*]]) [ "ptrauth"(i32 1, i64 0) ] +; CHECK-NEXT: [[IMM_DISCR:%.*]] = call i64 @llvm.ptrauth.sign(i64 [[P]]) [ "ptrauth"(i32 1, i64 42) ] +; CHECK-NEXT: [[ADDR_DISCR:%.*]] = call i64 @llvm.ptrauth.sign(i64 [[P]]) [ "ptrauth"(i32 1, i64 [[ADDR:%.*]]) ] +; CHECK-NEXT: [[BLENDED_DISCR:%.*]] = call i64 @llvm.ptrauth.sign(i64 [[P]]) [ "ptrauth"(i32 1, i64 [[ADDR]], i64 1234) ] +; CHECK-NEXT: ret void +; + %tmp = call i64 @llvm.ptrauth.blend(i64 %addr, i64 1234) + %zero.discr = call i64 @llvm.ptrauth.sign(i64 %p, i32 1, i64 0) + %imm.discr = call i64 @llvm.ptrauth.sign(i64 %p, i32 1, i64 42) + %addr.discr = call i64 @llvm.ptrauth.sign(i64 %p, i32 1, i64 %addr) + %blended.discr = call i64 @llvm.ptrauth.sign(i64 %p, i32 1, i64 %tmp) + ret void +} + +define void @test_ptrauth_auth(i64 %p, i64 %addr) { +; CHECK-LABEL: @test_ptrauth_auth( +; CHECK-NEXT: [[ZERO_DISCR:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[P:%.*]]) [ "ptrauth"(i32 1, i64 0) ] +; CHECK-NEXT: [[IMM_DISCR:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[P]]) [ "ptrauth"(i32 1, i64 42) ] +; CHECK-NEXT: [[ADDR_DISCR:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[P]]) [ "ptrauth"(i32 1, i64 [[ADDR:%.*]]) ] +; CHECK-NEXT: [[BLENDED_DISCR:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[P]]) [ "ptrauth"(i32 1, i64 [[ADDR]], i64 1234) ] +; CHECK-NEXT: ret void +; + %tmp = call i64 @llvm.ptrauth.blend(i64 %addr, i64 1234) + %zero.discr = call i64 @llvm.ptrauth.auth(i64 %p, i32 1, i64 0) + %imm.discr = call i64 @llvm.ptrauth.auth(i64 %p, i32 1, i64 42) + %addr.discr = call i64 @llvm.ptrauth.auth(i64 %p, i32 1, i64 %addr) + %blended.discr = call i64 @llvm.ptrauth.auth(i64 %p, i32 1, i64 %tmp) + ret void +} + +define void @test_ptrauth_resign(i64 %p, i64 %addr) { +; CHECK-LABEL: @test_ptrauth_resign( +; CHECK-NEXT: [[IMM_IMM_DISCR:%.*]] = call i64 @llvm.ptrauth.resign(i64 [[P:%.*]]) [ "ptrauth"(i32 1, i64 42), "ptrauth"(i32 2, i64 123) ] +; CHECK-NEXT: [[ZERO_IMM_DISCR:%.*]] = call i64 @llvm.ptrauth.resign(i64 [[P]]) [ "ptrauth"(i32 1, i64 0), "ptrauth"(i32 2, i64 123) ] +; CHECK-NEXT: [[ADDR_IMM_DISCR:%.*]] = call i64 @llvm.ptrauth.resign(i64 [[P]]) [ "ptrauth"(i32 1, i64 [[ADDR:%.*]]), "ptrauth"(i32 2, i64 123) ] +; CHECK-NEXT: [[BLENDED_IMM_DISCR:%.*]] = call i64 @llvm.ptrauth.resign(i64 [[P]]) [ "ptrauth"(i32 1, i64 [[ADDR]], i64 1234), "ptrauth"(i32 2, i64 123) ] +; CHECK-NEXT: [[IMM_ZERO_DISCR:%.*]] = call i64 @llvm.ptrauth.resign(i64 [[P]]) [ "ptrauth"(i32 1, i64 123), "ptrauth"(i32 2, i64 0) ] +; CHECK-NEXT: [[IMM_ADDR_DISCR:%.*]] = call i64 @llvm.ptrauth.resign(i64 [[P]]) [ "ptrauth"(i32 1, i64 123), "ptrauth"(i32 2, i64 [[ADDR]]) ] +; CHECK-NEXT: [[IMM_BLENDED_DISCR:%.*]] = call i64 @llvm.ptrauth.resign(i64 [[P]]) [ "ptrauth"(i32 1, i64 123), "ptrauth"(i32 2, i64 [[ADDR]], i64 5678) ] +; CHECK-NEXT: [[ZERO_BLENDED_DISCR:%.*]] = call i64 @llvm.ptrauth.resign(i64 [[P]]) [ "ptrauth"(i32 1, i64 0), "ptrauth"(i32 2, i64 [[ADDR]], i64 4321) ] +; CHECK-NEXT: [[ADDR_BLENDED_DISCR:%.*]] = call i64 @llvm.ptrauth.resign(i64 [[P]]) [ "ptrauth"(i32 1, i64 [[ADDR]]), "ptrauth"(i32 2, i64 [[ADDR]], i64 4321) ] +; CHECK-NEXT: [[BLENDED_ZERO_DISCR:%.*]] = call i64 @llvm.ptrauth.resign(i64 [[P]]) [ "ptrauth"(i32 1, i64 [[ADDR]], i64 8765), "ptrauth"(i32 2, i64 0) ] +; CHECK-NEXT: [[BLENDED_ADDR_DISCR:%.*]] = call i64 @llvm.ptrauth.resign(i64 [[P]]) [ "ptrauth"(i32 1, i64 [[ADDR]], i64 8765), "ptrauth"(i32 2, i64 [[ADDR]]) ] +; CHECK-NEXT: [[BLENDED_BLENDED_DISCR:%.*]] = call i64 @llvm.ptrauth.resign(i64 [[P]]) [ "ptrauth"(i32 1, i64 [[ADDR]], i64 111), "ptrauth"(i32 2, i64 [[ADDR]], i64 222) ] +; CHECK-NEXT: ret void +; + %imm.imm.discr = call i64 @llvm.ptrauth.resign(i64 %p, i32 1, i64 42, i32 2, i64 123) + + %tmp1 = call i64 @llvm.ptrauth.blend(i64 %addr, i64 1234) + %zero.imm.discr = call i64 @llvm.ptrauth.resign(i64 %p, i32 1, i64 0, i32 2, i64 123) + %addr.imm.discr = call i64 @llvm.ptrauth.resign(i64 %p, i32 1, i64 %addr, i32 2, i64 123) + %blended.imm.discr = call i64 @llvm.ptrauth.resign(i64 %p, i32 1, i64 %tmp1, i32 2, i64 123) + + %tmp2 = call i64 @llvm.ptrauth.blend(i64 %addr, i64 5678) + %imm.zero.discr = call i64 @llvm.ptrauth.resign(i64 %p, i32 1, i64 123, i32 2, i64 0 ) + %imm.addr.discr = call i64 @llvm.ptrauth.resign(i64 %p, i32 1, i64 123, i32 2, i64 %addr) + %imm.blended.discr = call i64 @llvm.ptrauth.resign(i64 %p, i32 1, i64 123, i32 2, i64 %tmp2) + + %tmp3 = call i64 @llvm.ptrauth.blend(i64 %addr, i64 4321) + %zero.blended.discr = call i64 @llvm.ptrauth.resign(i64 %p, i32 1, i64 0, i32 2, i64 %tmp3) + %addr.blended.discr = call i64 @llvm.ptrauth.resign(i64 %p, i32 1, i64 %addr, i32 2, i64 %tmp3) + + %tmp4 = call i64 @llvm.ptrauth.blend(i64 %addr, i64 8765) + %blended.zero.discr = call i64 @llvm.ptrauth.resign(i64 %p, i32 1, i64 %tmp4, i32 2, i64 0 ) + %blended.addr.discr = call i64 @llvm.ptrauth.resign(i64 %p, i32 1, i64 %tmp4, i32 2, i64 %addr) + + %tmp5 = call i64 @llvm.ptrauth.blend(i64 %addr, i64 111) + %tmp6 = call i64 @llvm.ptrauth.blend(i64 %addr, i64 222) + %blended.blended.discr = call i64 @llvm.ptrauth.resign(i64 %p, i32 1, i64 %tmp5, i32 2, i64 %tmp6) + + ret void +} + +define void @test_ptrauth_strip(i64 %p) { +; CHECK-LABEL: @test_ptrauth_strip( +; CHECK-NEXT: [[RES:%.*]] = call i64 @llvm.ptrauth.strip(i64 [[P:%.*]]) [ "ptrauth"(i32 1) ] +; CHECK-NEXT: ret void +; + %res = call i64 @llvm.ptrauth.strip(i64 %p, i32 1) + ret void +} + +define void @test_ptrauth_reused_blend(i64 %p1, i64 %p2, i64 %addr) { +; CHECK-LABEL: @test_ptrauth_reused_blend( +; CHECK-NEXT: [[RES1:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[P1:%.*]]) [ "ptrauth"(i32 1, i64 [[ADDR:%.*]], i64 1234) ] +; CHECK-NEXT: [[RES2:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[P2:%.*]]) [ "ptrauth"(i32 2, i64 [[ADDR]], i64 1234) ] +; CHECK-NEXT: ret void +; + %tmp = call i64 @llvm.ptrauth.blend(i64 %addr, i64 1234) + %res1 = call i64 @llvm.ptrauth.auth(i64 %p1, i32 1, i64 %tmp) + %res2 = call i64 @llvm.ptrauth.auth(i64 %p2, i32 2, i64 %tmp) + ret void +} + +define void @test_ptrauth_reused_blend_same_inst(i64 %p, i64 %addr) { +; CHECK-LABEL: @test_ptrauth_reused_blend_same_inst( +; CHECK-NEXT: [[RES:%.*]] = call i64 @llvm.ptrauth.resign(i64 [[P:%.*]]) [ "ptrauth"(i32 1, i64 [[ADDR:%.*]], i64 1234), "ptrauth"(i32 2, i64 [[ADDR]], i64 1234) ] +; CHECK-NEXT: ret void +; + %tmp = call i64 @llvm.ptrauth.blend(i64 %addr, i64 1234) + %res = call i64 @llvm.ptrauth.resign(i64 %p, i32 1, i64 %tmp, i32 2, i64 %tmp) + ret void +} + +define void @test_ptrauth_blend_in_other_bb(i64 %p, i64 %addr) { +; CHECK-LABEL: @test_ptrauth_blend_in_other_bb( +; CHECK-NEXT: entry: +; CHECK-NEXT: br label [[EXIT:%.*]] +; CHECK: exit: +; CHECK-NEXT: [[RES:%.*]] = call i64 @llvm.ptrauth.resign(i64 [[P:%.*]]) [ "ptrauth"(i32 1, i64 [[ADDR:%.*]], i64 1234), "ptrauth"(i32 2, i64 [[ADDR]], i64 1234) ] +; CHECK-NEXT: ret void +; +entry: + %tmp = call i64 @llvm.ptrauth.blend(i64 %addr, i64 1234) + br label %exit + +exit: + %res = call i64 @llvm.ptrauth.resign(i64 %p, i32 1, i64 %tmp, i32 2, i64 %tmp) + ret void +} diff --git a/llvm/test/CodeGen/AArch64/ptrauth-isel.ll b/llvm/test/CodeGen/AArch64/ptrauth-isel.ll index 3f47685b2ec4d..af4eb40be7062 100644 --- a/llvm/test/CodeGen/AArch64/ptrauth-isel.ll +++ b/llvm/test/CodeGen/AArch64/ptrauth-isel.ll @@ -197,73 +197,3 @@ entry: %signed = call i64 @llvm.ptrauth.sign(i64 %addr) [ "ptrauth"(i64 2, i64 %disc) ] ret i64 %signed } - -; In the below test cases both %addrdisc and %disc are computed (i.e. they are -; neither global addresses, nor function arguments) in a different basic block, -; making them harder to express via ISD::PtrAuthGlobalAddress. - -define i64 @blend_and_sign_different_bbs(i64 %addr, i64 %cond) { - ; DAGISEL-LABEL: name: blend_and_sign_different_bbs - ; DAGISEL: bb.0.entry: - ; DAGISEL-NEXT: successors: %bb.1(0x50000000), %bb.2(0x30000000) - ; DAGISEL-NEXT: liveins: $x0, $x1 - ; DAGISEL-NEXT: {{ $}} - ; DAGISEL-NEXT: [[COPY:%[0-9]+]]:gpr64 = COPY $x1 - ; DAGISEL-NEXT: [[COPY1:%[0-9]+]]:gpr64 = COPY $x0 - ; DAGISEL-NEXT: [[ADRP:%[0-9]+]]:gpr64common = ADRP target-flags(aarch64-page) @discvar - ; DAGISEL-NEXT: [[LDRXui:%[0-9]+]]:gpr64 = LDRXui killed [[ADRP]], target-flags(aarch64-pageoff, aarch64-nc) @discvar :: (dereferenceable load (s64) from @discvar) - ; DAGISEL-NEXT: [[MOVKXi:%[0-9]+]]:gpr64 = MOVKXi [[LDRXui]], 42, 48 - ; DAGISEL-NEXT: [[COPY2:%[0-9]+]]:gpr64noip = COPY [[MOVKXi]] - ; DAGISEL-NEXT: CBZX [[COPY]], %bb.2 - ; DAGISEL-NEXT: B %bb.1 - ; DAGISEL-NEXT: {{ $}} - ; DAGISEL-NEXT: bb.1.next: - ; DAGISEL-NEXT: successors: %bb.2(0x80000000) - ; DAGISEL-NEXT: {{ $}} - ; DAGISEL-NEXT: [[COPY3:%[0-9]+]]:gpr64common = COPY [[COPY2]] - ; DAGISEL-NEXT: INLINEASM &nop, 1 /* sideeffect attdialect */, 3866633 /* reguse:GPR64common */, [[COPY3]] - ; DAGISEL-NEXT: {{ $}} - ; DAGISEL-NEXT: bb.2.exit: - ; DAGISEL-NEXT: [[COPY4:%[0-9]+]]:gpr64noip = COPY [[LDRXui]] - ; DAGISEL-NEXT: [[PAC:%[0-9]+]]:gpr64 = PAC [[COPY1]], 2, 42, [[COPY4]], implicit-def dead $x16, implicit-def dead $x17 - ; DAGISEL-NEXT: $x0 = COPY [[PAC]] - ; DAGISEL-NEXT: RET_ReallyLR implicit $x0 - ; - ; GISEL-LABEL: name: blend_and_sign_different_bbs - ; GISEL: bb.1.entry: - ; GISEL-NEXT: successors: %bb.2(0x50000000), %bb.3(0x30000000) - ; GISEL-NEXT: liveins: $x0, $x1 - ; GISEL-NEXT: {{ $}} - ; GISEL-NEXT: [[COPY:%[0-9]+]]:gpr64 = COPY $x0 - ; GISEL-NEXT: [[COPY1:%[0-9]+]]:gpr64 = COPY $x1 - ; GISEL-NEXT: [[ADRP:%[0-9]+]]:gpr64common = ADRP target-flags(aarch64-page) @discvar - ; GISEL-NEXT: [[LDRXui:%[0-9]+]]:gpr64 = LDRXui [[ADRP]], target-flags(aarch64-pageoff, aarch64-nc) @discvar :: (dereferenceable load (s64) from @discvar) - ; GISEL-NEXT: [[MOVKXi:%[0-9]+]]:gpr64noip = MOVKXi [[LDRXui]], 42, 48 - ; GISEL-NEXT: CBZX [[COPY1]], %bb.3 - ; GISEL-NEXT: B %bb.2 - ; GISEL-NEXT: {{ $}} - ; GISEL-NEXT: bb.2.next: - ; GISEL-NEXT: successors: %bb.3(0x80000000) - ; GISEL-NEXT: {{ $}} - ; GISEL-NEXT: [[COPY2:%[0-9]+]]:gpr64common = COPY [[MOVKXi]] - ; GISEL-NEXT: INLINEASM &nop, 1 /* sideeffect attdialect */, 3866633 /* reguse:GPR64common */, [[COPY2]] - ; GISEL-NEXT: {{ $}} - ; GISEL-NEXT: bb.3.exit: - ; GISEL-NEXT: [[COPY3:%[0-9]+]]:gpr64noip = COPY [[LDRXui]] - ; GISEL-NEXT: [[PAC:%[0-9]+]]:gpr64 = PAC [[COPY]], 2, 42, [[COPY3]], implicit-def dead $x16, implicit-def dead $x17 - ; GISEL-NEXT: $x0 = COPY [[PAC]] - ; GISEL-NEXT: RET_ReallyLR implicit $x0 -entry: - %addrdisc = load i64, ptr @discvar - %disc = call i64 @llvm.ptrauth.blend(i64 %addrdisc, i64 42) - %cond.b = icmp ne i64 %cond, 0 - br i1 %cond.b, label %next, label %exit - -next: - call void asm sideeffect "nop", "r"(i64 %disc) - br label %exit - -exit: - %signed = call i64 @llvm.ptrauth.sign(i64 %addr) [ "ptrauth"(i64 2, i64 %disc) ] - ret i64 %signed -} diff --git a/llvm/test/CodeGen/RISCV/rv32zknd-intrinsic-autoupgrade.ll b/llvm/test/CodeGen/RISCV/rv32zknd-intrinsic-autoupgrade.ll index 6e6d18490782c..e4216319256a3 100644 --- a/llvm/test/CodeGen/RISCV/rv32zknd-intrinsic-autoupgrade.ll +++ b/llvm/test/CodeGen/RISCV/rv32zknd-intrinsic-autoupgrade.ll @@ -2,6 +2,9 @@ ; RUN: llc -mtriple=riscv32 -mattr=+zknd -verify-machineinstrs < %s \ ; RUN: | FileCheck %s -check-prefix=RV32ZKND +; FIXME: Commenting this out makes auto-upgrader fail! +declare i32 @llvm.riscv.aes32dsi(i32, i32, i8); + define i32 @aes32dsi(i32 %a, i32 %b) nounwind { ; RV32ZKND-LABEL: aes32dsi: ; RV32ZKND: # %bb.0: @@ -11,6 +14,17 @@ define i32 @aes32dsi(i32 %a, i32 %b) nounwind { ret i32 %val } +define i32 @aes32dsi_1(i32 %a, i32 %b) nounwind { +; RV32ZKND-LABEL: aes32dsi_1: +; RV32ZKND: # %bb.0: +; RV32ZKND-NEXT: aes32dsi a0, a0, a1, 0 +; RV32ZKND-NEXT: ret + %val = call i32 @llvm.riscv.aes32dsi(i32 %a, i32 %b, i8 0) + ret i32 %val +} + +declare i32 @llvm.riscv.aes32dsmi(i32, i32, i8); + define i32 @aes32dsmi(i32 %a, i32 %b) nounwind { ; RV32ZKND-LABEL: aes32dsmi: ; RV32ZKND: # %bb.0: From 47b92c7447bb63112776409172e2bd708d7dd92a Mon Sep 17 00:00:00 2001 From: Anatoly Trosinenko Date: Thu, 6 Nov 2025 17:10:33 +0300 Subject: [PATCH 16/40] Upgrade key operand of ptrauth bundle to i64 --- llvm/lib/AsmParser/LLParser.cpp | 20 +++++++ llvm/lib/IR/AutoUpgrade.cpp | 55 ++++++++++++++----- .../CodeGen/AArch64/ptrauth-call-upgrade.ll | 32 +++++++++++ .../AArch64/ptrauth-intrinsics-upgrade.ll | 50 ++++++++--------- .../Transforms/InstCombine/ptrauth-call.ll | 26 ++++----- .../Transforms/TailCallElim/ptrauth-bundle.ll | 4 +- llvm/test/Verifier/operand-bundles.ll | 3 +- 7 files changed, 133 insertions(+), 57 deletions(-) create mode 100644 llvm/test/CodeGen/AArch64/ptrauth-call-upgrade.ll diff --git a/llvm/lib/AsmParser/LLParser.cpp b/llvm/lib/AsmParser/LLParser.cpp index 2a0246074a462..2594a3af82b0c 100644 --- a/llvm/lib/AsmParser/LLParser.cpp +++ b/llvm/lib/AsmParser/LLParser.cpp @@ -3353,6 +3353,20 @@ bool LLParser::parseOptionalOperandBundles( return false; } +static void upgradeOperandBundles( + SmallVectorImpl &BundleList) { + // AutoUpgrader.h exposes an API that accepts std::vector. + // Skip meaningless allocations if no bundles were parsed. + // FIXME Is it possible to change UpgradeOperandBundles function to accept + // SmallVectorImpl instead of std::vector? + if (BundleList.empty()) + return; + + std::vector BundleVector(BundleList.begin(), BundleList.end()); + UpgradeOperandBundles(BundleVector); + BundleList.assign(BundleVector.begin(), BundleVector.end()); +} + bool LLParser::checkValueID(LocTy Loc, StringRef Kind, StringRef Prefix, unsigned NextID, unsigned ID) { if (ID < NextID) @@ -7747,6 +7761,8 @@ bool LLParser::parseInvoke(Instruction *&Inst, PerFunctionState &PFS) { parseTypeAndBasicBlock(UnwindBB, PFS)) return true; + upgradeOperandBundles(BundleList); + // If RetType is a non-function pointer type, then this is the short syntax // for the call, which means that RetType is just the return type. Infer the // rest of the function argument types from the arguments that are present. @@ -8042,6 +8058,8 @@ bool LLParser::parseCallBr(Instruction *&Inst, PerFunctionState &PFS) { parseToken(lltok::lsquare, "expected '[' in callbr")) return true; + upgradeOperandBundles(BundleList); + // parse the destination list. SmallVector IndirectDests; @@ -8453,6 +8471,8 @@ bool LLParser::parseCall(Instruction *&Inst, PerFunctionState &PFS, parseOptionalOperandBundles(BundleList, PFS)) return true; + upgradeOperandBundles(BundleList); + // If RetType is a non-function pointer type, then this is the short syntax // for the call, which means that RetType is just the return type. Infer the // rest of the function argument types from the arguments that are present. diff --git a/llvm/lib/IR/AutoUpgrade.cpp b/llvm/lib/IR/AutoUpgrade.cpp index 97bc74a520d2b..536132a780045 100644 --- a/llvm/lib/IR/AutoUpgrade.cpp +++ b/llvm/lib/IR/AutoUpgrade.cpp @@ -4757,39 +4757,50 @@ static CallBase *upgradeToPtrAuthBundles(CallBase *CI) { if (CI->getNumOperandBundles()) return CI; - LLVMContext &Ctx = CI->getContext(); - Value *Zero32 = ConstantInt::get(Ctx, APInt::getZero(32)); - Value *Zero64 = ConstantInt::get(Ctx, APInt::getZero(64)); SmallVector OBs; + auto TryUpgradingToConstantI64 = [](Value *V) -> Value * { + auto *Const = dyn_cast(V); + if (!Const || Const->getType()->isIntegerTy(64)) + return V; + return ConstantInt::get(V->getContext(), Const->getValue().zext(64)); + }; + auto UpgradeToBundle = [&](unsigned KeyIndex, unsigned DiscIndex) { + Value *Key = CI->getArgOperand(KeyIndex); + Value *Disc = CI->getArgOperand(DiscIndex); + Value *Inputs[] = {TryUpgradingToConstantI64(Key), Disc}; + OBs.emplace_back("ptrauth", Inputs); + + CI->setArgOperand(KeyIndex, ConstantInt::get(Key->getType(), 0)); + CI->setArgOperand(DiscIndex, ConstantInt::get(Disc->getType(), 0)); + }; + switch (CI->arg_size()) { default: #ifndef NDEBUG CI->dump(); #endif llvm_unreachable("Unexpected intrinsic"); - case 2: + case 2: { // strip(value, key) -> strip(value, 0) [ "ptrauth"(key) ] - OBs.emplace_back("ptrauth", ArrayRef({CI->getArgOperand(1)})); - CI->setArgOperand(1, Zero32); + Value *Key = CI->getArgOperand(1); + Value *Inputs[] = {TryUpgradingToConstantI64(Key)}; + OBs.emplace_back("ptrauth", Inputs); + CI->setArgOperand(1, ConstantInt::get(Key->getType(), 0)); break; + } case 3: // auth(value, key, disc) -> auth(value, 0, 0) [ "ptrauth"(...) ] // sign(value, key, disc) -> sign(value, 0, 0) [ "ptrauth"(...) ] - OBs.emplace_back("ptrauth", ArrayRef({CI->getArgOperand(1), CI->getArgOperand(2)})); - CI->setArgOperand(1, Zero32); - CI->setArgOperand(2, Zero64); + UpgradeToBundle(1, 2); break; case 5: // resign(value, old_key, old_disc, new_key, new_disc) -> // resign(value, 0, 0, 0, 0) [ "ptrauth"(), // "ptrauth"() ] - OBs.emplace_back("ptrauth", ArrayRef({CI->getArgOperand(1), CI->getArgOperand(2)})); - CI->setArgOperand(1, Zero32); - CI->setArgOperand(2, Zero64); - OBs.emplace_back("ptrauth", ArrayRef({CI->getArgOperand(3), CI->getArgOperand(4)})); - CI->setArgOperand(3, Zero32); - CI->setArgOperand(4, Zero64); + UpgradeToBundle(1, 2); + UpgradeToBundle(3, 4); + break; } // Attach operand bundles by re-creating the call. @@ -6599,4 +6610,18 @@ void llvm::UpgradeOperandBundles(std::vector &Bundles) { return OBD.getTag() == "clang.arc.attachedcall" && OBD.inputs().empty(); }); + + for (unsigned I = 0, N = Bundles.size(); I < N; ++I) { + OperandBundleDef &OB = Bundles[I]; + if (OB.getTag() == "ptrauth" && OB.inputs().size() == 2) { + auto *Key = dyn_cast(OB.inputs()[0]); + if (!Key || !Key->getType()->isIntegerTy(32)) + continue; + + SmallVector Inputs(OB.inputs()); + Inputs[0] = ConstantInt::get(Key->getContext(), + Key->getValue().zext(64)); + Bundles[I] = OperandBundleDef("ptrauth", Inputs); + } + } } diff --git a/llvm/test/CodeGen/AArch64/ptrauth-call-upgrade.ll b/llvm/test/CodeGen/AArch64/ptrauth-call-upgrade.ll new file mode 100644 index 0000000000000..7d208d172bfea --- /dev/null +++ b/llvm/test/CodeGen/AArch64/ptrauth-call-upgrade.ll @@ -0,0 +1,32 @@ +; NOTE: Assertions have been autogenerated by utils/update_test_checks.py +; RUN: opt < %s -S | FileCheck %s + +define void @test_call_imm_disc(ptr %fn) { +; CHECK-LABEL: @test_call_imm_disc( +; CHECK-NEXT: call void [[FN:%.*]]() [ "ptrauth"(i64 1, i64 0) ] +; CHECK-NEXT: call void [[FN]]() [ "ptrauth"(i64 1, i64 42) ] +; CHECK-NEXT: ret void +; + call void %fn() [ "ptrauth"(i32 1, i64 0) ] + call void %fn() [ "ptrauth"(i32 1, i64 42) ] + ret void +} + +define void @test_call_addr_disc(ptr %fn, i64 %addr) { +; CHECK-LABEL: @test_call_addr_disc( +; CHECK-NEXT: call void [[FN:%.*]]() [ "ptrauth"(i64 1, i64 [[ADDR:%.*]]) ] +; CHECK-NEXT: ret void +; + call void %fn() [ "ptrauth"(i32 1, i64 %addr) ] + ret void +} + +define void @test_call_blended_disc(ptr %fn, i64 %addr) { +; CHECK-LABEL: @test_call_blended_disc( +; CHECK-NEXT: call void [[FN:%.*]]() [ "ptrauth"(i64 1, i64 [[ADDR:%.*]], i64 42) ] +; CHECK-NEXT: ret void +; + %disc = call i64 @llvm.ptrauth.blend(i64 %addr, i64 42) + call void %fn() [ "ptrauth"(i32 1, i64 %disc) ] + ret void +} diff --git a/llvm/test/CodeGen/AArch64/ptrauth-intrinsics-upgrade.ll b/llvm/test/CodeGen/AArch64/ptrauth-intrinsics-upgrade.ll index 7271265aada5a..54270cfd7d57b 100644 --- a/llvm/test/CodeGen/AArch64/ptrauth-intrinsics-upgrade.ll +++ b/llvm/test/CodeGen/AArch64/ptrauth-intrinsics-upgrade.ll @@ -3,10 +3,10 @@ define void @test_ptrauth_sign(i64 %p, i64 %addr) { ; CHECK-LABEL: @test_ptrauth_sign( -; CHECK-NEXT: [[ZERO_DISCR:%.*]] = call i64 @llvm.ptrauth.sign(i64 [[P:%.*]]) [ "ptrauth"(i32 1, i64 0) ] -; CHECK-NEXT: [[IMM_DISCR:%.*]] = call i64 @llvm.ptrauth.sign(i64 [[P]]) [ "ptrauth"(i32 1, i64 42) ] -; CHECK-NEXT: [[ADDR_DISCR:%.*]] = call i64 @llvm.ptrauth.sign(i64 [[P]]) [ "ptrauth"(i32 1, i64 [[ADDR:%.*]]) ] -; CHECK-NEXT: [[BLENDED_DISCR:%.*]] = call i64 @llvm.ptrauth.sign(i64 [[P]]) [ "ptrauth"(i32 1, i64 [[ADDR]], i64 1234) ] +; CHECK-NEXT: [[ZERO_DISCR:%.*]] = call i64 @llvm.ptrauth.sign(i64 [[P:%.*]]) [ "ptrauth"(i64 1, i64 0) ] +; CHECK-NEXT: [[IMM_DISCR:%.*]] = call i64 @llvm.ptrauth.sign(i64 [[P]]) [ "ptrauth"(i64 1, i64 42) ] +; CHECK-NEXT: [[ADDR_DISCR:%.*]] = call i64 @llvm.ptrauth.sign(i64 [[P]]) [ "ptrauth"(i64 1, i64 [[ADDR:%.*]]) ] +; CHECK-NEXT: [[BLENDED_DISCR:%.*]] = call i64 @llvm.ptrauth.sign(i64 [[P]]) [ "ptrauth"(i64 1, i64 [[ADDR]], i64 1234) ] ; CHECK-NEXT: ret void ; %tmp = call i64 @llvm.ptrauth.blend(i64 %addr, i64 1234) @@ -19,10 +19,10 @@ define void @test_ptrauth_sign(i64 %p, i64 %addr) { define void @test_ptrauth_auth(i64 %p, i64 %addr) { ; CHECK-LABEL: @test_ptrauth_auth( -; CHECK-NEXT: [[ZERO_DISCR:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[P:%.*]]) [ "ptrauth"(i32 1, i64 0) ] -; CHECK-NEXT: [[IMM_DISCR:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[P]]) [ "ptrauth"(i32 1, i64 42) ] -; CHECK-NEXT: [[ADDR_DISCR:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[P]]) [ "ptrauth"(i32 1, i64 [[ADDR:%.*]]) ] -; CHECK-NEXT: [[BLENDED_DISCR:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[P]]) [ "ptrauth"(i32 1, i64 [[ADDR]], i64 1234) ] +; CHECK-NEXT: [[ZERO_DISCR:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[P:%.*]]) [ "ptrauth"(i64 1, i64 0) ] +; CHECK-NEXT: [[IMM_DISCR:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[P]]) [ "ptrauth"(i64 1, i64 42) ] +; CHECK-NEXT: [[ADDR_DISCR:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[P]]) [ "ptrauth"(i64 1, i64 [[ADDR:%.*]]) ] +; CHECK-NEXT: [[BLENDED_DISCR:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[P]]) [ "ptrauth"(i64 1, i64 [[ADDR]], i64 1234) ] ; CHECK-NEXT: ret void ; %tmp = call i64 @llvm.ptrauth.blend(i64 %addr, i64 1234) @@ -35,18 +35,18 @@ define void @test_ptrauth_auth(i64 %p, i64 %addr) { define void @test_ptrauth_resign(i64 %p, i64 %addr) { ; CHECK-LABEL: @test_ptrauth_resign( -; CHECK-NEXT: [[IMM_IMM_DISCR:%.*]] = call i64 @llvm.ptrauth.resign(i64 [[P:%.*]]) [ "ptrauth"(i32 1, i64 42), "ptrauth"(i32 2, i64 123) ] -; CHECK-NEXT: [[ZERO_IMM_DISCR:%.*]] = call i64 @llvm.ptrauth.resign(i64 [[P]]) [ "ptrauth"(i32 1, i64 0), "ptrauth"(i32 2, i64 123) ] -; CHECK-NEXT: [[ADDR_IMM_DISCR:%.*]] = call i64 @llvm.ptrauth.resign(i64 [[P]]) [ "ptrauth"(i32 1, i64 [[ADDR:%.*]]), "ptrauth"(i32 2, i64 123) ] -; CHECK-NEXT: [[BLENDED_IMM_DISCR:%.*]] = call i64 @llvm.ptrauth.resign(i64 [[P]]) [ "ptrauth"(i32 1, i64 [[ADDR]], i64 1234), "ptrauth"(i32 2, i64 123) ] -; CHECK-NEXT: [[IMM_ZERO_DISCR:%.*]] = call i64 @llvm.ptrauth.resign(i64 [[P]]) [ "ptrauth"(i32 1, i64 123), "ptrauth"(i32 2, i64 0) ] -; CHECK-NEXT: [[IMM_ADDR_DISCR:%.*]] = call i64 @llvm.ptrauth.resign(i64 [[P]]) [ "ptrauth"(i32 1, i64 123), "ptrauth"(i32 2, i64 [[ADDR]]) ] -; CHECK-NEXT: [[IMM_BLENDED_DISCR:%.*]] = call i64 @llvm.ptrauth.resign(i64 [[P]]) [ "ptrauth"(i32 1, i64 123), "ptrauth"(i32 2, i64 [[ADDR]], i64 5678) ] -; CHECK-NEXT: [[ZERO_BLENDED_DISCR:%.*]] = call i64 @llvm.ptrauth.resign(i64 [[P]]) [ "ptrauth"(i32 1, i64 0), "ptrauth"(i32 2, i64 [[ADDR]], i64 4321) ] -; CHECK-NEXT: [[ADDR_BLENDED_DISCR:%.*]] = call i64 @llvm.ptrauth.resign(i64 [[P]]) [ "ptrauth"(i32 1, i64 [[ADDR]]), "ptrauth"(i32 2, i64 [[ADDR]], i64 4321) ] -; CHECK-NEXT: [[BLENDED_ZERO_DISCR:%.*]] = call i64 @llvm.ptrauth.resign(i64 [[P]]) [ "ptrauth"(i32 1, i64 [[ADDR]], i64 8765), "ptrauth"(i32 2, i64 0) ] -; CHECK-NEXT: [[BLENDED_ADDR_DISCR:%.*]] = call i64 @llvm.ptrauth.resign(i64 [[P]]) [ "ptrauth"(i32 1, i64 [[ADDR]], i64 8765), "ptrauth"(i32 2, i64 [[ADDR]]) ] -; CHECK-NEXT: [[BLENDED_BLENDED_DISCR:%.*]] = call i64 @llvm.ptrauth.resign(i64 [[P]]) [ "ptrauth"(i32 1, i64 [[ADDR]], i64 111), "ptrauth"(i32 2, i64 [[ADDR]], i64 222) ] +; CHECK-NEXT: [[IMM_IMM_DISCR:%.*]] = call i64 @llvm.ptrauth.resign(i64 [[P:%.*]]) [ "ptrauth"(i64 1, i64 42), "ptrauth"(i64 2, i64 123) ] +; CHECK-NEXT: [[ZERO_IMM_DISCR:%.*]] = call i64 @llvm.ptrauth.resign(i64 [[P]]) [ "ptrauth"(i64 1, i64 0), "ptrauth"(i64 2, i64 123) ] +; CHECK-NEXT: [[ADDR_IMM_DISCR:%.*]] = call i64 @llvm.ptrauth.resign(i64 [[P]]) [ "ptrauth"(i64 1, i64 [[ADDR:%.*]]), "ptrauth"(i64 2, i64 123) ] +; CHECK-NEXT: [[BLENDED_IMM_DISCR:%.*]] = call i64 @llvm.ptrauth.resign(i64 [[P]]) [ "ptrauth"(i64 1, i64 [[ADDR]], i64 1234), "ptrauth"(i64 2, i64 123) ] +; CHECK-NEXT: [[IMM_ZERO_DISCR:%.*]] = call i64 @llvm.ptrauth.resign(i64 [[P]]) [ "ptrauth"(i64 1, i64 123), "ptrauth"(i64 2, i64 0) ] +; CHECK-NEXT: [[IMM_ADDR_DISCR:%.*]] = call i64 @llvm.ptrauth.resign(i64 [[P]]) [ "ptrauth"(i64 1, i64 123), "ptrauth"(i64 2, i64 [[ADDR]]) ] +; CHECK-NEXT: [[IMM_BLENDED_DISCR:%.*]] = call i64 @llvm.ptrauth.resign(i64 [[P]]) [ "ptrauth"(i64 1, i64 123), "ptrauth"(i64 2, i64 [[ADDR]], i64 5678) ] +; CHECK-NEXT: [[ZERO_BLENDED_DISCR:%.*]] = call i64 @llvm.ptrauth.resign(i64 [[P]]) [ "ptrauth"(i64 1, i64 0), "ptrauth"(i64 2, i64 [[ADDR]], i64 4321) ] +; CHECK-NEXT: [[ADDR_BLENDED_DISCR:%.*]] = call i64 @llvm.ptrauth.resign(i64 [[P]]) [ "ptrauth"(i64 1, i64 [[ADDR]]), "ptrauth"(i64 2, i64 [[ADDR]], i64 4321) ] +; CHECK-NEXT: [[BLENDED_ZERO_DISCR:%.*]] = call i64 @llvm.ptrauth.resign(i64 [[P]]) [ "ptrauth"(i64 1, i64 [[ADDR]], i64 8765), "ptrauth"(i64 2, i64 0) ] +; CHECK-NEXT: [[BLENDED_ADDR_DISCR:%.*]] = call i64 @llvm.ptrauth.resign(i64 [[P]]) [ "ptrauth"(i64 1, i64 [[ADDR]], i64 8765), "ptrauth"(i64 2, i64 [[ADDR]]) ] +; CHECK-NEXT: [[BLENDED_BLENDED_DISCR:%.*]] = call i64 @llvm.ptrauth.resign(i64 [[P]]) [ "ptrauth"(i64 1, i64 [[ADDR]], i64 111), "ptrauth"(i64 2, i64 [[ADDR]], i64 222) ] ; CHECK-NEXT: ret void ; %imm.imm.discr = call i64 @llvm.ptrauth.resign(i64 %p, i32 1, i64 42, i32 2, i64 123) @@ -78,7 +78,7 @@ define void @test_ptrauth_resign(i64 %p, i64 %addr) { define void @test_ptrauth_strip(i64 %p) { ; CHECK-LABEL: @test_ptrauth_strip( -; CHECK-NEXT: [[RES:%.*]] = call i64 @llvm.ptrauth.strip(i64 [[P:%.*]]) [ "ptrauth"(i32 1) ] +; CHECK-NEXT: [[RES:%.*]] = call i64 @llvm.ptrauth.strip(i64 [[P:%.*]]) [ "ptrauth"(i64 1) ] ; CHECK-NEXT: ret void ; %res = call i64 @llvm.ptrauth.strip(i64 %p, i32 1) @@ -87,8 +87,8 @@ define void @test_ptrauth_strip(i64 %p) { define void @test_ptrauth_reused_blend(i64 %p1, i64 %p2, i64 %addr) { ; CHECK-LABEL: @test_ptrauth_reused_blend( -; CHECK-NEXT: [[RES1:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[P1:%.*]]) [ "ptrauth"(i32 1, i64 [[ADDR:%.*]], i64 1234) ] -; CHECK-NEXT: [[RES2:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[P2:%.*]]) [ "ptrauth"(i32 2, i64 [[ADDR]], i64 1234) ] +; CHECK-NEXT: [[RES1:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[P1:%.*]]) [ "ptrauth"(i64 1, i64 [[ADDR:%.*]], i64 1234) ] +; CHECK-NEXT: [[RES2:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[P2:%.*]]) [ "ptrauth"(i64 2, i64 [[ADDR]], i64 1234) ] ; CHECK-NEXT: ret void ; %tmp = call i64 @llvm.ptrauth.blend(i64 %addr, i64 1234) @@ -99,7 +99,7 @@ define void @test_ptrauth_reused_blend(i64 %p1, i64 %p2, i64 %addr) { define void @test_ptrauth_reused_blend_same_inst(i64 %p, i64 %addr) { ; CHECK-LABEL: @test_ptrauth_reused_blend_same_inst( -; CHECK-NEXT: [[RES:%.*]] = call i64 @llvm.ptrauth.resign(i64 [[P:%.*]]) [ "ptrauth"(i32 1, i64 [[ADDR:%.*]], i64 1234), "ptrauth"(i32 2, i64 [[ADDR]], i64 1234) ] +; CHECK-NEXT: [[RES:%.*]] = call i64 @llvm.ptrauth.resign(i64 [[P:%.*]]) [ "ptrauth"(i64 1, i64 [[ADDR:%.*]], i64 1234), "ptrauth"(i64 2, i64 [[ADDR]], i64 1234) ] ; CHECK-NEXT: ret void ; %tmp = call i64 @llvm.ptrauth.blend(i64 %addr, i64 1234) @@ -112,7 +112,7 @@ define void @test_ptrauth_blend_in_other_bb(i64 %p, i64 %addr) { ; CHECK-NEXT: entry: ; CHECK-NEXT: br label [[EXIT:%.*]] ; CHECK: exit: -; CHECK-NEXT: [[RES:%.*]] = call i64 @llvm.ptrauth.resign(i64 [[P:%.*]]) [ "ptrauth"(i32 1, i64 [[ADDR:%.*]], i64 1234), "ptrauth"(i32 2, i64 [[ADDR]], i64 1234) ] +; CHECK-NEXT: [[RES:%.*]] = call i64 @llvm.ptrauth.resign(i64 [[P:%.*]]) [ "ptrauth"(i64 1, i64 [[ADDR:%.*]], i64 1234), "ptrauth"(i64 2, i64 [[ADDR]], i64 1234) ] ; CHECK-NEXT: ret void ; entry: diff --git a/llvm/test/Transforms/InstCombine/ptrauth-call.ll b/llvm/test/Transforms/InstCombine/ptrauth-call.ll index fa8f4117579f9..092efb0284a05 100644 --- a/llvm/test/Transforms/InstCombine/ptrauth-call.ll +++ b/llvm/test/Transforms/InstCombine/ptrauth-call.ll @@ -9,7 +9,7 @@ define i32 @test_ptrauth_call(i32 %a0) { ; CHECK-NEXT: [[V0:%.*]] = call i32 @f(i32 [[A0:%.*]]) ; CHECK-NEXT: ret i32 [[V0]] ; - %v0 = call i32 ptrauth(ptr @f, i32 0)(i32 %a0) [ "ptrauth"(i32 0, i64 0) ] + %v0 = call i32 ptrauth(ptr @f, i32 0)(i32 %a0) [ "ptrauth"(i64 0, i64 0) ] ret i32 %v0 } @@ -18,7 +18,7 @@ define i32 @test_ptrauth_call_disc(i32 %a0) { ; CHECK-NEXT: [[V0:%.*]] = call i32 @f(i32 [[A0:%.*]]) ; CHECK-NEXT: ret i32 [[V0]] ; - %v0 = call i32 ptrauth(ptr @f, i32 1, i64 5678)(i32 %a0) [ "ptrauth"(i32 1, i64 5678) ] + %v0 = call i32 ptrauth(ptr @f, i32 1, i64 5678)(i32 %a0) [ "ptrauth"(i64 1, i64 5678) ] ret i32 %v0 } @@ -29,7 +29,7 @@ define i32 @test_ptrauth_call_addr_disc(i32 %a0) { ; CHECK-NEXT: [[V0:%.*]] = call i32 @f(i32 [[A0:%.*]]) ; CHECK-NEXT: ret i32 [[V0]] ; - %v0 = call i32 ptrauth(ptr @f, i32 1, i64 0, ptr @f_addr_disc.ref)(i32 %a0) [ "ptrauth"(i32 1, i64 ptrtoint (ptr @f_addr_disc.ref to i64)) ] + %v0 = call i32 ptrauth(ptr @f, i32 1, i64 0, ptr @f_addr_disc.ref)(i32 %a0) [ "ptrauth"(i64 1, i64 ptrtoint (ptr @f_addr_disc.ref to i64)) ] ret i32 %v0 } @@ -40,7 +40,7 @@ define i32 @test_ptrauth_call_blend(i32 %a0) { ; CHECK-NEXT: [[V0:%.*]] = call i32 @f(i32 [[A0:%.*]]) ; CHECK-NEXT: ret i32 [[V0]] ; - %v0 = call i32 ptrauth(ptr @f, i32 1, i64 1234, ptr @f_both_disc.ref)(i32 %a0) [ "ptrauth"(i32 1, i64 ptrtoint (ptr @f_both_disc.ref to i64), i64 1234) ] + %v0 = call i32 ptrauth(ptr @f, i32 1, i64 1234, ptr @f_both_disc.ref)(i32 %a0) [ "ptrauth"(i64 1, i64 ptrtoint (ptr @f_both_disc.ref to i64), i64 1234) ] ret i32 %v0 } @@ -49,42 +49,42 @@ define i64 @test_ptrauth_call_cast(i32 %a0) { ; CHECK-NEXT: [[V0:%.*]] = call i64 @f2(i32 [[A0:%.*]]) ; CHECK-NEXT: ret i64 [[V0]] ; - %v0 = call i64 ptrauth(ptr @f2, i32 0)(i32 %a0) [ "ptrauth"(i32 0, i64 0) ] + %v0 = call i64 ptrauth(ptr @f2, i32 0)(i32 %a0) [ "ptrauth"(i64 0, i64 0) ] ret i64 %v0 } define i32 @test_ptrauth_call_mismatch_key(i32 %a0) { ; CHECK-LABEL: @test_ptrauth_call_mismatch_key( -; CHECK-NEXT: [[V0:%.*]] = call i32 ptrauth (ptr @f, i32 1, i64 5678)(i32 [[A0:%.*]]) [ "ptrauth"(i32 0, i64 5678) ] +; CHECK-NEXT: [[V0:%.*]] = call i32 ptrauth (ptr @f, i32 1, i64 5678)(i32 [[A0:%.*]]) [ "ptrauth"(i64 0, i64 5678) ] ; CHECK-NEXT: ret i32 [[V0]] ; - %v0 = call i32 ptrauth(ptr @f, i32 1, i64 5678)(i32 %a0) [ "ptrauth"(i32 0, i64 5678) ] + %v0 = call i32 ptrauth(ptr @f, i32 1, i64 5678)(i32 %a0) [ "ptrauth"(i64 0, i64 5678) ] ret i32 %v0 } define i32 @test_ptrauth_call_mismatch_disc(i32 %a0) { ; CHECK-LABEL: @test_ptrauth_call_mismatch_disc( -; CHECK-NEXT: [[V0:%.*]] = call i32 ptrauth (ptr @f, i32 1, i64 5678)(i32 [[A0:%.*]]) [ "ptrauth"(i32 1, i64 0) ] +; CHECK-NEXT: [[V0:%.*]] = call i32 ptrauth (ptr @f, i32 1, i64 5678)(i32 [[A0:%.*]]) [ "ptrauth"(i64 1, i64 0) ] ; CHECK-NEXT: ret i32 [[V0]] ; - %v0 = call i32 ptrauth(ptr @f, i32 1, i64 5678)(i32 %a0) [ "ptrauth"(i32 1, i64 0) ] + %v0 = call i32 ptrauth(ptr @f, i32 1, i64 5678)(i32 %a0) [ "ptrauth"(i64 1, i64 0) ] ret i32 %v0 } define i32 @test_ptrauth_call_mismatch_blend(i32 %a0) { ; CHECK-LABEL: @test_ptrauth_call_mismatch_blend( -; CHECK-NEXT: [[V0:%.*]] = call i32 ptrauth (ptr @f, i32 1, i64 1234, ptr @f_both_disc.ref)(i32 [[A0:%.*]]) [ "ptrauth"(i32 1, i64 ptrtoint (ptr @f_both_disc.ref to i64), i64 0) ] +; CHECK-NEXT: [[V0:%.*]] = call i32 ptrauth (ptr @f, i32 1, i64 1234, ptr @f_both_disc.ref)(i32 [[A0:%.*]]) [ "ptrauth"(i64 1, i64 ptrtoint (ptr @f_both_disc.ref to i64), i64 0) ] ; CHECK-NEXT: ret i32 [[V0]] ; - %v0 = call i32 ptrauth(ptr @f, i32 1, i64 1234, ptr @f_both_disc.ref)(i32 %a0) [ "ptrauth"(i32 1, i64 ptrtoint (ptr @f_both_disc.ref to i64), i64 0) ] + %v0 = call i32 ptrauth(ptr @f, i32 1, i64 1234, ptr @f_both_disc.ref)(i32 %a0) [ "ptrauth"(i64 1, i64 ptrtoint (ptr @f_both_disc.ref to i64), i64 0) ] ret i32 %v0 } define i32 @test_ptrauth_call_mismatch_blend_addr(i32 %a0) { ; CHECK-LABEL: @test_ptrauth_call_mismatch_blend_addr( -; CHECK-NEXT: [[V0:%.*]] = call i32 ptrauth (ptr @f, i32 1, i64 1234, ptr @f_both_disc.ref)(i32 [[A0:%.*]]) [ "ptrauth"(i32 1, i64 ptrtoint (ptr @f_addr_disc.ref to i64), i64 1234) ] +; CHECK-NEXT: [[V0:%.*]] = call i32 ptrauth (ptr @f, i32 1, i64 1234, ptr @f_both_disc.ref)(i32 [[A0:%.*]]) [ "ptrauth"(i64 1, i64 ptrtoint (ptr @f_addr_disc.ref to i64), i64 1234) ] ; CHECK-NEXT: ret i32 [[V0]] ; - %v0 = call i32 ptrauth(ptr @f, i32 1, i64 1234, ptr @f_both_disc.ref)(i32 %a0) [ "ptrauth"(i32 1, i64 ptrtoint (ptr @f_addr_disc.ref to i64), i64 1234) ] + %v0 = call i32 ptrauth(ptr @f, i32 1, i64 1234, ptr @f_both_disc.ref)(i32 %a0) [ "ptrauth"(i64 1, i64 ptrtoint (ptr @f_addr_disc.ref to i64), i64 1234) ] ret i32 %v0 } diff --git a/llvm/test/Transforms/TailCallElim/ptrauth-bundle.ll b/llvm/test/Transforms/TailCallElim/ptrauth-bundle.ll index 0228d3d371333..6b0e75852e51d 100644 --- a/llvm/test/Transforms/TailCallElim/ptrauth-bundle.ll +++ b/llvm/test/Transforms/TailCallElim/ptrauth-bundle.ll @@ -4,7 +4,7 @@ define i64 @f_1(i64 %x, ptr %f_0) { ; CHECK-LABEL: @f_1( entry: -; CHECK: tail call i64 %f_0(i64 %x) [ "ptrauth"(i32 42, i64 %x) ] - %tmp = call i64 %f_0(i64 %x) [ "ptrauth"(i32 42, i64 %x) ] +; CHECK: tail call i64 %f_0(i64 %x) [ "ptrauth"(i64 42, i64 %x) ] + %tmp = call i64 %f_0(i64 %x) [ "ptrauth"(i64 42, i64 %x) ] ret i64 0 } diff --git a/llvm/test/Verifier/operand-bundles.ll b/llvm/test/Verifier/operand-bundles.ll index db85b6ae6ef5f..de57a3a2a7213 100644 --- a/llvm/test/Verifier/operand-bundles.ll +++ b/llvm/test/Verifier/operand-bundles.ll @@ -66,8 +66,7 @@ define void @f_gc_transition(ptr %ptr) { } define void @f_clang_arc_attachedcall() { -; CHECK: requires one function as an argument -; CHECK-NEXT: call ptr @foo0() [ "clang.arc.attachedcall"() ] +; CHECK-NOT: requires one function as an argument ; CHECK-NEXT: Multiple "clang.arc.attachedcall" operand bundles ; CHECK-NEXT: call ptr @foo0() [ "clang.arc.attachedcall"(ptr @llvm.objc.retainAutoreleasedReturnValue), "clang.arc.attachedcall"(ptr @llvm.objc.retainAutoreleasedReturnValue) ] ; CHECK-NEXT: must call a function returning a pointer From 1a26e4e0a0ccf3d95276f95460a6a5af7ee88d1f Mon Sep 17 00:00:00 2001 From: Anatoly Trosinenko Date: Thu, 6 Nov 2025 17:39:49 +0300 Subject: [PATCH 17/40] Upgrade various tests --- llvm/test/CodeGen/AArch64/ptrauth-bti-call.ll | 48 ++++----- .../CodeGen/AArch64/ptrauth-call-rv-marker.ll | 102 +++++++++--------- llvm/test/CodeGen/AArch64/ptrauth-invoke.ll | 8 +- llvm/test/CodeGen/AArch64/ptrauth-isel.ll | 60 +++++------ llvm/test/CodeGen/AArch64/ptrauth-ret-trap.ll | 6 +- .../AArch64/ptrauth-tail-call-regalloc.ll | 4 +- .../devirt-single-impl-check-ptrauth.ll | 2 +- 7 files changed, 109 insertions(+), 121 deletions(-) diff --git a/llvm/test/CodeGen/AArch64/ptrauth-bti-call.ll b/llvm/test/CodeGen/AArch64/ptrauth-bti-call.ll index df5e1a9f1ee10..0e8f78d56d907 100644 --- a/llvm/test/CodeGen/AArch64/ptrauth-bti-call.ll +++ b/llvm/test/CodeGen/AArch64/ptrauth-bti-call.ll @@ -17,8 +17,8 @@ ; CHECK-NEXT: bti c ; CHECK-NEXT: mov x16, x0 ; CHECK-NEXT: braaz x16 -define i32 @test_tailcall_ia_0(ptr %arg0) #0 { - %tmp0 = tail call i32 %arg0() [ "ptrauth"(i32 0, i64 0) ] +define i32 @test_tailcall_ia_0(i32 ()* %arg0) #0 { + %tmp0 = tail call i32 %arg0() [ "ptrauth"(i64 0, i64 0) ] ret i32 %tmp0 } @@ -26,8 +26,8 @@ define i32 @test_tailcall_ia_0(ptr %arg0) #0 { ; CHECK-NEXT: bti c ; CHECK-NEXT: mov x16, x0 ; CHECK-NEXT: brabz x16 -define i32 @test_tailcall_ib_0(ptr %arg0) #0 { - %tmp0 = tail call i32 %arg0() [ "ptrauth"(i32 1, i64 0) ] +define i32 @test_tailcall_ib_0(i32 ()* %arg0) #0 { + %tmp0 = tail call i32 %arg0() [ "ptrauth"(i64 1, i64 0) ] ret i32 %tmp0 } @@ -36,8 +36,8 @@ define i32 @test_tailcall_ib_0(ptr %arg0) #0 { ; CHECK-NEXT: mov x16, x0 ; CHECK-NEXT: mov x17, #42 ; CHECK-NEXT: braa x16, x17 -define i32 @test_tailcall_ia_imm(ptr %arg0) #0 { - %tmp0 = tail call i32 %arg0() [ "ptrauth"(i32 0, i64 42) ] +define i32 @test_tailcall_ia_imm(i32 ()* %arg0) #0 { + %tmp0 = tail call i32 %arg0() [ "ptrauth"(i64 0, i64 42) ] ret i32 %tmp0 } @@ -46,8 +46,8 @@ define i32 @test_tailcall_ia_imm(ptr %arg0) #0 { ; CHECK-NEXT: mov x16, x0 ; CHECK-NEXT: mov x17, #42 ; CHECK-NEXT: brab x16, x17 -define i32 @test_tailcall_ib_imm(ptr %arg0) #0 { - %tmp0 = tail call i32 %arg0() [ "ptrauth"(i32 1, i64 42) ] +define i32 @test_tailcall_ib_imm(i32 ()* %arg0) #0 { + %tmp0 = tail call i32 %arg0() [ "ptrauth"(i64 1, i64 42) ] ret i32 %tmp0 } @@ -60,9 +60,9 @@ define i32 @test_tailcall_ib_imm(ptr %arg0) #0 { ; ELF-NEXT: ldr x1, [x1] ; ELF-NEXT: mov x16, x0 ; ELF-NEXT: braa x16, x1 -define i32 @test_tailcall_ia_var(ptr %arg0, ptr %arg1) #0 { - %tmp0 = load i64, ptr %arg1 - %tmp1 = tail call i32 %arg0() [ "ptrauth"(i32 0, i64 %tmp0) ] +define i32 @test_tailcall_ia_var(i32 ()* %arg0, i64* %arg1) #0 { + %tmp0 = load i64, i64* %arg1 + %tmp1 = tail call i32 %arg0() [ "ptrauth"(i64 0, i64 %tmp0) ] ret i32 %tmp1 } @@ -75,9 +75,9 @@ define i32 @test_tailcall_ia_var(ptr %arg0, ptr %arg1) #0 { ; ELF-NEXT: ldr x1, [x1] ; ELF-NEXT: mov x16, x0 ; ELF-NEXT: brab x16, x1 -define i32 @test_tailcall_ib_var(ptr %arg0, ptr %arg1) #0 { - %tmp0 = load i64, ptr %arg1 - %tmp1 = tail call i32 %arg0() [ "ptrauth"(i32 1, i64 %tmp0) ] +define i32 @test_tailcall_ib_var(i32 ()* %arg0, i64* %arg1) #0 { + %tmp0 = load i64, i64* %arg1 + %tmp1 = tail call i32 %arg0() [ "ptrauth"(i64 1, i64 %tmp0) ] ret i32 %tmp1 } @@ -85,8 +85,8 @@ define i32 @test_tailcall_ib_var(ptr %arg0, ptr %arg1) #0 { ; CHECK-NEXT: bti c ; CHECK-NEXT: mov x16, x0 ; CHECK-NEXT: braa x16, x1 -define i32 @test_tailcall_ia_arg(ptr %arg0, i64 %arg1) #0 { - %tmp0 = tail call i32 %arg0() [ "ptrauth"(i32 0, i64 %arg1) ] +define i32 @test_tailcall_ia_arg(i32 ()* %arg0, i64 %arg1) #0 { + %tmp0 = tail call i32 %arg0() [ "ptrauth"(i64 0, i64 %arg1) ] ret i32 %tmp0 } @@ -94,8 +94,8 @@ define i32 @test_tailcall_ia_arg(ptr %arg0, i64 %arg1) #0 { ; CHECK-NEXT: bti c ; CHECK-NEXT: mov x16, x0 ; CHECK-NEXT: brab x16, x1 -define i32 @test_tailcall_ib_arg(ptr %arg0, i64 %arg1) #0 { - %tmp0 = tail call i32 %arg0() [ "ptrauth"(i32 1, i64 %arg1) ] +define i32 @test_tailcall_ib_arg(i32 ()* %arg0, i64 %arg1) #0 { + %tmp0 = tail call i32 %arg0() [ "ptrauth"(i64 1, i64 %arg1) ] ret i32 %tmp0 } @@ -103,9 +103,9 @@ define i32 @test_tailcall_ib_arg(ptr %arg0, i64 %arg1) #0 { ; CHECK-NEXT: bti c ; CHECK-NEXT: ldr x16, [x0] ; CHECK-NEXT: braa x16, x1 -define i32 @test_tailcall_ia_arg_ind(ptr %arg0, i64 %arg1) #0 { - %tmp0 = load ptr, ptr %arg0 - %tmp1 = tail call i32 %tmp0() [ "ptrauth"(i32 0, i64 %arg1) ] +define i32 @test_tailcall_ia_arg_ind(i32 ()** %arg0, i64 %arg1) #0 { + %tmp0 = load i32 ()*, i32 ()** %arg0 + %tmp1 = tail call i32 %tmp0() [ "ptrauth"(i64 0, i64 %arg1) ] ret i32 %tmp1 } @@ -113,9 +113,9 @@ define i32 @test_tailcall_ia_arg_ind(ptr %arg0, i64 %arg1) #0 { ; CHECK-NEXT: bti c ; CHECK-NEXT: ldr x16, [x0] ; CHECK-NEXT: brab x16, x1 -define i32 @test_tailcall_ib_arg_ind(ptr %arg0, i64 %arg1) #0 { - %tmp0 = load ptr, ptr %arg0 - %tmp1 = tail call i32 %tmp0() [ "ptrauth"(i32 1, i64 %arg1) ] +define i32 @test_tailcall_ib_arg_ind(i32 ()** %arg0, i64 %arg1) #0 { + %tmp0 = load i32 ()*, i32 ()** %arg0 + %tmp1 = tail call i32 %tmp0() [ "ptrauth"(i64 1, i64 %arg1) ] ret i32 %tmp1 } diff --git a/llvm/test/CodeGen/AArch64/ptrauth-call-rv-marker.ll b/llvm/test/CodeGen/AArch64/ptrauth-call-rv-marker.ll index 950db5fd6381f..dcc624eb1b084 100644 --- a/llvm/test/CodeGen/AArch64/ptrauth-call-rv-marker.ll +++ b/llvm/test/CodeGen/AArch64/ptrauth-call-rv-marker.ll @@ -4,18 +4,18 @@ target datalayout = "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128" target triple = "arm64e-apple-iphoneos" -declare ptr @foo0(i32) -declare ptr @foo1() +declare i8* @foo0(i32) +declare i8* @foo1() -declare void @llvm.objc.release(ptr) -declare ptr @llvm.objc.retainAutoreleasedReturnValue(ptr) -declare ptr @llvm.objc.unsafeClaimAutoreleasedReturnValue(ptr) +declare void @llvm.objc.release(i8*) +declare i8* @llvm.objc.retainAutoreleasedReturnValue(i8*) +declare i8* @llvm.objc.unsafeClaimAutoreleasedReturnValue(i8*) -declare void @foo2(ptr) +declare void @foo2(i8*) declare void @foo(i64, i64, i64) -define void @rv_marker_ptrauth_blraa(ptr %arg0, i64 %arg1) { +define void @rv_marker_ptrauth_blraa(i8* ()** %arg0, i64 %arg1) { ; CHECK-LABEL: rv_marker_ptrauth_blraa ; CHECK: ldr [[ADDR:x[0-9]+]], [ ; CHECK-NEXT: blraa [[ADDR]], x1 @@ -23,14 +23,14 @@ define void @rv_marker_ptrauth_blraa(ptr %arg0, i64 %arg1) { ; CHECK-NEXT: bl objc_retainAutoreleasedReturnValue ; entry: - %tmp0 = load ptr, ptr %arg0 - %call0 = call ptr %tmp0() [ "ptrauth"(i32 0, i64 %arg1), "clang.arc.attachedcall"(ptr @llvm.objc.retainAutoreleasedReturnValue) ] - tail call void @foo2(ptr %call0) - tail call void @llvm.objc.release(ptr %call0) + %tmp0 = load i8* ()*, i8* ()** %arg0 + %call0 = call i8* %tmp0() [ "ptrauth"(i64 0, i64 %arg1), "clang.arc.attachedcall"(i8* (i8*)* @llvm.objc.retainAutoreleasedReturnValue) ] + tail call void @foo2(i8* %call0) + tail call void @llvm.objc.release(i8* %call0) ret void } -define void @rv_marker_ptrauth_blraa_unsafeClaim(ptr %arg0, i64 %arg1) { +define void @rv_marker_ptrauth_blraa_unsafeClaim(i8* ()** %arg0, i64 %arg1) { ; CHECK-LABEL: rv_marker_ptrauth_blraa_unsafeClaim ; CHECK: ldr [[ADDR:x[0-9]+]], [ ; CHECK-NEXT: blraa [[ADDR]], x1 @@ -38,14 +38,14 @@ define void @rv_marker_ptrauth_blraa_unsafeClaim(ptr %arg0, i64 %arg1) { ; CHECK-NEXT: bl objc_unsafeClaimAutoreleasedReturnValue ; entry: - %tmp0 = load ptr, ptr %arg0 - %call0 = call ptr %tmp0() [ "ptrauth"(i32 0, i64 %arg1), "clang.arc.attachedcall"(ptr @llvm.objc.unsafeClaimAutoreleasedReturnValue) ] - tail call void @foo2(ptr %call0) - tail call void @llvm.objc.release(ptr %call0) + %tmp0 = load i8* ()*, i8* ()** %arg0 + %call0 = call i8* %tmp0() [ "ptrauth"(i64 0, i64 %arg1), "clang.arc.attachedcall"(i8* (i8*)* @llvm.objc.unsafeClaimAutoreleasedReturnValue) ] + tail call void @foo2(i8* %call0) + tail call void @llvm.objc.release(i8* %call0) ret void } -define void @rv_marker_ptrauth_blraa_disc_imm16(ptr %arg0) { +define void @rv_marker_ptrauth_blraa_disc_imm16(i8* ()** %arg0) { ; CHECK-LABEL: rv_marker_ptrauth_blraa_disc_imm16 ; CHECK: ldr [[ADDR:x[0-9]+]], [ ; CHECK-NEXT: mov x17, #45431 @@ -53,14 +53,14 @@ define void @rv_marker_ptrauth_blraa_disc_imm16(ptr %arg0) { ; CHECK-NEXT: mov x29, x29 ; CHECK-NEXT: bl objc_retainAutoreleasedReturnValue ; - %tmp0 = load ptr, ptr %arg0 - %call0 = call ptr %tmp0() [ "ptrauth"(i32 1, i64 45431), "clang.arc.attachedcall"(ptr @llvm.objc.retainAutoreleasedReturnValue) ] - tail call void @foo2(ptr %call0) - tail call void @llvm.objc.release(ptr %call0) + %tmp0 = load i8* ()*, i8* ()** %arg0 + %call0 = call i8* %tmp0() [ "ptrauth"(i64 1, i64 45431), "clang.arc.attachedcall"(i8* (i8*)* @llvm.objc.retainAutoreleasedReturnValue) ] + tail call void @foo2(i8* %call0) + tail call void @llvm.objc.release(i8* %call0) ret void } -define void @rv_marker_ptrauth_blraa_multiarg(ptr %arg0, i64 %arg1, i64 %a, i64 %b, i64 %c) { +define void @rv_marker_ptrauth_blraa_multiarg(i8* (i64, i64, i64)** %arg0, i64 %arg1, i64 %a, i64 %b, i64 %c) { ; CHECK-LABEL: rv_marker_ptrauth_blraa_multiarg ; CHECK: mov [[TMP:x[0-9]+]], x1 ; CHECK-DAG: ldr [[ADDR:x[0-9]+]] @@ -71,28 +71,28 @@ define void @rv_marker_ptrauth_blraa_multiarg(ptr %arg0, i64 %arg1, i64 %a, i64 ; CHECK-NEXT: bl objc_retainAutoreleasedReturnValue ; entry: - %tmp0 = load ptr, ptr %arg0 - %call0 = call ptr %tmp0(i64 %c, i64 %b, i64 %a) [ "ptrauth"(i32 0, i64 %arg1), "clang.arc.attachedcall"(ptr @llvm.objc.retainAutoreleasedReturnValue) ] - tail call void @foo2(ptr %call0) - tail call void @llvm.objc.release(ptr %call0) + %tmp0 = load i8* (i64, i64, i64)*, i8* (i64, i64, i64)** %arg0 + %call0 = call i8* %tmp0(i64 %c, i64 %b, i64 %a) [ "ptrauth"(i64 0, i64 %arg1), "clang.arc.attachedcall"(i8* (i8*)* @llvm.objc.retainAutoreleasedReturnValue) ] + tail call void @foo2(i8* %call0) + tail call void @llvm.objc.release(i8* %call0) ret void } -define void @rv_marker_ptrauth_blrab(ptr %arg0, i64 %arg1) { +define void @rv_marker_ptrauth_blrab(i8* ()** %arg0, i64 %arg1) { ; CHECK-LABEL: rv_marker_ptrauth_blrab ; CHECK: ldr [[ADDR:x[0-9]+]], [ ; CHECK-NEXT: blrab [[ADDR]], x1 ; CHECK-NEXT: mov x29, x29 ; CHECK-NEXT: bl objc_retainAutoreleasedReturnValue ; - %tmp0 = load ptr, ptr %arg0 - %call0 = call ptr %tmp0() [ "ptrauth"(i32 1, i64 %arg1), "clang.arc.attachedcall"(ptr @llvm.objc.retainAutoreleasedReturnValue) ] - tail call void @foo2(ptr %call0) - tail call void @llvm.objc.release(ptr %call0) + %tmp0 = load i8* ()*, i8* ()** %arg0 + %call0 = call i8* %tmp0() [ "ptrauth"(i64 1, i64 %arg1), "clang.arc.attachedcall"(i8* (i8*)* @llvm.objc.retainAutoreleasedReturnValue) ] + tail call void @foo2(i8* %call0) + tail call void @llvm.objc.release(i8* %call0) ret void } -define void @rv_marker_ptrauth_blrab_disc_imm16(ptr %arg0) { +define void @rv_marker_ptrauth_blrab_disc_imm16(i8* ()** %arg0) { ; CHECK-LABEL: rv_marker_ptrauth_blrab_disc_imm16 ; CHECK: ldr [[ADDR:x[0-9]+]], [ ; CHECK-NEXT: mov x17, #256 @@ -100,42 +100,42 @@ define void @rv_marker_ptrauth_blrab_disc_imm16(ptr %arg0) { ; CHECK-NEXT: mov x29, x29 ; CHECK-NEXT: bl objc_retainAutoreleasedReturnValue ; - %tmp0 = load ptr, ptr %arg0 - %call0 = call ptr %tmp0() [ "ptrauth"(i32 1, i64 256), "clang.arc.attachedcall"(ptr @llvm.objc.retainAutoreleasedReturnValue) ] - tail call void @foo2(ptr %call0) - tail call void @llvm.objc.release(ptr %call0) + %tmp0 = load i8* ()*, i8* ()** %arg0 + %call0 = call i8* %tmp0() [ "ptrauth"(i64 1, i64 256), "clang.arc.attachedcall"(i8* (i8*)* @llvm.objc.retainAutoreleasedReturnValue) ] + tail call void @foo2(i8* %call0) + tail call void @llvm.objc.release(i8* %call0) ret void } -define void @rv_marker_ptrauth_blraaz(ptr %arg0) { +define void @rv_marker_ptrauth_blraaz(i8* ()** %arg0) { ; CHECK-LABEL: rv_marker_ptrauth_blraaz ; CHECK: ldr [[ADDR:x[0-9]+]], [ ; CHECK-NEXT: blraaz [[ADDR]] ; CHECK-NEXT: mov x29, x29 ; CHECK-NEXT: bl objc_retainAutoreleasedReturnValue ; - %tmp0 = load ptr, ptr %arg0 - %call0 = call ptr %tmp0() [ "ptrauth"(i32 0, i64 0), "clang.arc.attachedcall"(ptr @llvm.objc.retainAutoreleasedReturnValue) ] - tail call void @foo2(ptr %call0) - tail call void @llvm.objc.release(ptr %call0) + %tmp0 = load i8* ()*, i8* ()** %arg0 + %call0 = call i8* %tmp0() [ "ptrauth"(i64 0, i64 0), "clang.arc.attachedcall"(i8* (i8*)* @llvm.objc.retainAutoreleasedReturnValue) ] + tail call void @foo2(i8* %call0) + tail call void @llvm.objc.release(i8* %call0) ret void } -define void @rv_marker_ptrauth_blrabz(ptr %arg0) { +define void @rv_marker_ptrauth_blrabz(i8* ()** %arg0) { ; CHECK-LABEL: rv_marker_ptrauth_blrabz ; CHECK: ldr [[ADDR:x[0-9]+]], [ ; CHECK-NEXT: blrabz [[ADDR]] ; CHECK-NEXT: mov x29, x29 ; CHECK-NEXT: bl objc_retainAutoreleasedReturnValue ; - %tmp0 = load ptr, ptr %arg0 - %call0 = call ptr %tmp0() [ "ptrauth"(i32 1, i64 0), "clang.arc.attachedcall"(ptr @llvm.objc.retainAutoreleasedReturnValue) ] - tail call void @foo2(ptr %call0) - tail call void @llvm.objc.release(ptr %call0) + %tmp0 = load i8* ()*, i8* ()** %arg0 + %call0 = call i8* %tmp0() [ "ptrauth"(i64 1, i64 0), "clang.arc.attachedcall"(i8* (i8*)* @llvm.objc.retainAutoreleasedReturnValue) ] + tail call void @foo2(i8* %call0) + tail call void @llvm.objc.release(i8* %call0) ret void } -define void @rv_marker_ptrauth_blrabz_multiarg(ptr %arg0, i64 %a, i64 %b, i64 %c) { +define void @rv_marker_ptrauth_blrabz_multiarg(i8* (i64, i64, i64)** %arg0, i64 %a, i64 %b, i64 %c) { ; CHECK-LABEL: rv_marker_ptrauth_blrabz_multiarg ; CHECK: mov [[TMP:x[0-9]+]], x1 ; CHECK-DAG: ldr [[ADDR:x[0-9]+]], [ @@ -146,9 +146,9 @@ define void @rv_marker_ptrauth_blrabz_multiarg(ptr %arg0, i64 %a, i64 %b, i64 %c ; CHECK-NEXT: mov x29, x29 ; CHECK-NEXT: bl objc_retainAutoreleasedReturnValue ; - %tmp0 = load ptr, ptr %arg0 - %call0 = call ptr %tmp0(i64 %c, i64 %b, i64 %a) [ "ptrauth"(i32 1, i64 0), "clang.arc.attachedcall"(ptr @llvm.objc.retainAutoreleasedReturnValue) ] - tail call void @foo2(ptr %call0) - tail call void @llvm.objc.release(ptr %call0) + %tmp0 = load i8* (i64, i64, i64)*, i8* (i64, i64, i64)** %arg0 + %call0 = call i8* %tmp0(i64 %c, i64 %b, i64 %a) [ "ptrauth"(i64 1, i64 0), "clang.arc.attachedcall"(i8* (i8*)* @llvm.objc.retainAutoreleasedReturnValue) ] + tail call void @foo2(i8* %call0) + tail call void @llvm.objc.release(i8* %call0) ret void } diff --git a/llvm/test/CodeGen/AArch64/ptrauth-invoke.ll b/llvm/test/CodeGen/AArch64/ptrauth-invoke.ll index f6b3a88ca4677..c3ec3953da900 100644 --- a/llvm/test/CodeGen/AArch64/ptrauth-invoke.ll +++ b/llvm/test/CodeGen/AArch64/ptrauth-invoke.ll @@ -83,7 +83,7 @@ ; CHECK-NEXT: .byte 0 {{.*}} On action: cleanup define i32 @test_invoke_ia_0(ptr %arg0) #0 personality ptr @__gxx_personality_v0 { - %tmp0 = invoke i32 %arg0() [ "ptrauth"(i32 0, i64 0) ] to label %continuebb + %tmp0 = invoke i32 %arg0() [ "ptrauth"(i64 0, i64 0) ] to label %continuebb unwind label %unwindbb unwindbb: @@ -233,7 +233,7 @@ continuebb: define void @test_invoke_ib_42_catch(ptr %fptr) #0 personality ptr @__gxx_personality_v0 { %tmp0 = call ptr @__cxa_allocate_exception(i64 8) store ptr getelementptr inbounds ([6 x i8], ptr @hello_str, i64 0, i64 0), ptr %tmp0, align 8 - invoke void %fptr(ptr %tmp0, ptr @_ZTIPKc, ptr null) [ "ptrauth"(i32 1, i64 42) ] + invoke void %fptr(ptr %tmp0, ptr @_ZTIPKc, ptr null) [ "ptrauth"(i64 1, i64 42) ] to label %continuebb unwind label %catchbb catchbb: @@ -331,7 +331,7 @@ continuebb: ; CHECK-NEXT: .byte 0 {{.*}} On action: cleanup define i32 @test_invoke_ia_0_direct() #0 personality ptr @__gxx_personality_v0 { - %tmp0 = invoke i32 ptrauth (ptr @baz, i32 0)() [ "ptrauth"(i32 0, i64 0) ] to label %continuebb + %tmp0 = invoke i32 ptrauth (ptr @baz, i32 0)() [ "ptrauth"(i64 0, i64 0) ] to label %continuebb unwind label %unwindbb unwindbb: @@ -443,7 +443,7 @@ continuebb: ; CHECK-NEXT: .byte 0 {{.*}} On action: cleanup define i32 @test_invoke_ib_2_direct_mismatch() #0 personality ptr @__gxx_personality_v0 { - %tmp0 = invoke i32 ptrauth (ptr @baz, i32 0, i64 1234)() [ "ptrauth"(i32 1, i64 2) ] to label %continuebb + %tmp0 = invoke i32 ptrauth (ptr @baz, i32 0, i64 1234)() [ "ptrauth"(i64 1, i64 2) ] to label %continuebb unwind label %unwindbb unwindbb: diff --git a/llvm/test/CodeGen/AArch64/ptrauth-isel.ll b/llvm/test/CodeGen/AArch64/ptrauth-isel.ll index af4eb40be7062..c161f9d42b98f 100644 --- a/llvm/test/CodeGen/AArch64/ptrauth-isel.ll +++ b/llvm/test/CodeGen/AArch64/ptrauth-isel.ll @@ -13,6 +13,8 @@ @discvar = dso_local global i64 0 +; FIXME Should we remove this file? + ; Make sure the components of blend(addr, imm) and integer constants are ; recognized and passed to PAC pseudo via separate operands to prevent ; substitution of the immediate modifier. @@ -28,9 +30,8 @@ define i64 @small_imm_disc_optimized(i64 %addr) { ; DAGISEL-NEXT: liveins: $x0 ; DAGISEL-NEXT: {{ $}} ; DAGISEL-NEXT: [[COPY:%[0-9]+]]:gpr64 = COPY $x0 - ; DAGISEL-NEXT: [[MOVi32imm:%[0-9]+]]:gpr32 = MOVi32imm 42 - ; DAGISEL-NEXT: [[SUBREG_TO_REG:%[0-9]+]]:gpr64noip = SUBREG_TO_REG 0, killed [[MOVi32imm]], %subreg.sub_32 - ; DAGISEL-NEXT: [[PAC:%[0-9]+]]:gpr64 = PAC [[COPY]], 2, 42, killed $noreg, implicit-def dead $x16, implicit-def dead $x17 + ; DAGISEL-NEXT: [[COPY1:%[0-9]+]]:gpr64noip = COPY $xzr + ; DAGISEL-NEXT: [[PAC:%[0-9]+]]:gpr64 = PAC [[COPY]], 2, 42, [[COPY1]], implicit-def dead $x16, implicit-def dead $x17 ; DAGISEL-NEXT: $x0 = COPY [[PAC]] ; DAGISEL-NEXT: RET_ReallyLR implicit $x0 ; @@ -39,9 +40,8 @@ define i64 @small_imm_disc_optimized(i64 %addr) { ; GISEL-NEXT: liveins: $x0 ; GISEL-NEXT: {{ $}} ; GISEL-NEXT: [[COPY:%[0-9]+]]:gpr64 = COPY $x0 - ; GISEL-NEXT: [[MOVi32imm:%[0-9]+]]:gpr32 = MOVi32imm 42 - ; GISEL-NEXT: [[SUBREG_TO_REG:%[0-9]+]]:gpr64noip = SUBREG_TO_REG 0, [[MOVi32imm]], %subreg.sub_32 - ; GISEL-NEXT: [[PAC:%[0-9]+]]:gpr64 = PAC [[COPY]], 2, 42, $noreg, implicit-def dead $x16, implicit-def dead $x17 + ; GISEL-NEXT: [[COPY1:%[0-9]+]]:gpr64noip = COPY $xzr + ; GISEL-NEXT: [[PAC:%[0-9]+]]:gpr64 = PAC [[COPY]], 2, 42, [[COPY1]], implicit-def dead $x16, implicit-def dead $x17 ; GISEL-NEXT: $x0 = COPY [[PAC]] ; GISEL-NEXT: RET_ReallyLR implicit $x0 entry: @@ -57,11 +57,10 @@ define i64 @small_imm_disc_non_optimized(i64 %addr) noinline optnone { ; DAGISEL-NEXT: {{ $}} ; DAGISEL-NEXT: [[COPY:%[0-9]+]]:gpr64 = COPY $x0 ; DAGISEL-NEXT: [[COPY1:%[0-9]+]]:gpr64 = COPY killed [[COPY]] - ; DAGISEL-NEXT: [[MOVi32imm:%[0-9]+]]:gpr32 = MOVi32imm 42 - ; DAGISEL-NEXT: [[SUBREG_TO_REG:%[0-9]+]]:gpr64noip = SUBREG_TO_REG 0, killed [[MOVi32imm]], %subreg.sub_32 - ; DAGISEL-NEXT: [[PAC:%[0-9]+]]:gpr64 = PAC [[COPY1]], 2, 42, killed $noreg, implicit-def dead $x16, implicit-def dead $x17 - ; DAGISEL-NEXT: [[COPY2:%[0-9]+]]:gpr64all = COPY [[PAC]] - ; DAGISEL-NEXT: $x0 = COPY [[COPY2]] + ; DAGISEL-NEXT: [[COPY2:%[0-9]+]]:gpr64noip = COPY $xzr + ; DAGISEL-NEXT: [[PAC:%[0-9]+]]:gpr64 = PAC [[COPY1]], 2, 42, [[COPY2]], implicit-def dead $x16, implicit-def dead $x17 + ; DAGISEL-NEXT: [[COPY3:%[0-9]+]]:gpr64all = COPY [[PAC]] + ; DAGISEL-NEXT: $x0 = COPY [[COPY3]] ; DAGISEL-NEXT: RET_ReallyLR implicit $x0 ; ; GISEL-LABEL: name: small_imm_disc_non_optimized @@ -69,8 +68,8 @@ define i64 @small_imm_disc_non_optimized(i64 %addr) noinline optnone { ; GISEL-NEXT: liveins: $x0 ; GISEL-NEXT: {{ $}} ; GISEL-NEXT: [[COPY:%[0-9]+]]:gpr64 = COPY $x0 - ; GISEL-NEXT: [[MOVi64imm:%[0-9]+]]:gpr64noip = MOVi64imm 42 - ; GISEL-NEXT: [[PAC:%[0-9]+]]:gpr64 = PAC [[COPY]], 2, 42, $noreg, implicit-def dead $x16, implicit-def dead $x17 + ; GISEL-NEXT: [[COPY1:%[0-9]+]]:gpr64noip = COPY $xzr + ; GISEL-NEXT: [[PAC:%[0-9]+]]:gpr64 = PAC [[COPY]], 2, 42, [[COPY1]], implicit-def dead $x16, implicit-def dead $x17 ; GISEL-NEXT: $x0 = COPY [[PAC]] ; GISEL-NEXT: RET_ReallyLR implicit $x0 entry: @@ -139,13 +138,10 @@ define i64 @blended_disc_non_optimized(i64 %addr, i64 %addrdisc) noinline optnon ; DAGISEL-NEXT: [[COPY:%[0-9]+]]:gpr64 = COPY $x1 ; DAGISEL-NEXT: [[COPY1:%[0-9]+]]:gpr64 = COPY $x0 ; DAGISEL-NEXT: [[COPY2:%[0-9]+]]:gpr64 = COPY killed [[COPY1]] - ; DAGISEL-NEXT: [[COPY3:%[0-9]+]]:gpr64 = COPY killed [[COPY]] - ; DAGISEL-NEXT: [[MOVKXi:%[0-9]+]]:gpr64 = MOVKXi [[COPY3]], 42, 48 - ; DAGISEL-NEXT: [[COPY4:%[0-9]+]]:gpr64noip = COPY [[MOVKXi]] - ; DAGISEL-NEXT: [[COPY5:%[0-9]+]]:gpr64noip = COPY [[COPY3]] - ; DAGISEL-NEXT: [[PAC:%[0-9]+]]:gpr64 = PAC [[COPY2]], 2, 42, [[COPY5]], implicit-def dead $x16, implicit-def dead $x17 - ; DAGISEL-NEXT: [[COPY6:%[0-9]+]]:gpr64all = COPY [[PAC]] - ; DAGISEL-NEXT: $x0 = COPY [[COPY6]] + ; DAGISEL-NEXT: [[COPY3:%[0-9]+]]:gpr64noip = COPY killed [[COPY]] + ; DAGISEL-NEXT: [[PAC:%[0-9]+]]:gpr64 = PAC [[COPY2]], 2, 42, [[COPY3]], implicit-def dead $x16, implicit-def dead $x17 + ; DAGISEL-NEXT: [[COPY4:%[0-9]+]]:gpr64all = COPY [[PAC]] + ; DAGISEL-NEXT: $x0 = COPY [[COPY4]] ; DAGISEL-NEXT: RET_ReallyLR implicit $x0 ; ; GISEL-LABEL: name: blended_disc_non_optimized @@ -153,15 +149,12 @@ define i64 @blended_disc_non_optimized(i64 %addr, i64 %addrdisc) noinline optnon ; GISEL-NEXT: liveins: $x0, $x1 ; GISEL-NEXT: {{ $}} ; GISEL-NEXT: [[COPY:%[0-9]+]]:gpr64 = COPY $x0 - ; GISEL-NEXT: [[COPY1:%[0-9]+]]:gpr64 = COPY $x1 - ; GISEL-NEXT: [[MOVKXi:%[0-9]+]]:gpr64noip = MOVKXi [[COPY1]], 42, 48 - ; GISEL-NEXT: [[COPY2:%[0-9]+]]:gpr64noip = COPY [[COPY1]] - ; GISEL-NEXT: [[PAC:%[0-9]+]]:gpr64 = PAC [[COPY]], 2, 42, [[COPY2]], implicit-def dead $x16, implicit-def dead $x17 + ; GISEL-NEXT: [[COPY1:%[0-9]+]]:gpr64noip = COPY $x1 + ; GISEL-NEXT: [[PAC:%[0-9]+]]:gpr64 = PAC [[COPY]], 2, 42, [[COPY1]], implicit-def dead $x16, implicit-def dead $x17 ; GISEL-NEXT: $x0 = COPY [[PAC]] ; GISEL-NEXT: RET_ReallyLR implicit $x0 entry: - %disc = call i64 @llvm.ptrauth.blend(i64 %addrdisc, i64 42) - %signed = call i64 @llvm.ptrauth.sign(i64 %addr) [ "ptrauth"(i64 2, i64 %disc) ] + %signed = call i64 @llvm.ptrauth.sign(i64 %addr) [ "ptrauth"(i64 2, i64 %addrdisc, i64 42) ] ret i64 %signed } @@ -172,10 +165,8 @@ define i64 @blend_and_sign_same_bb(i64 %addr) { ; DAGISEL-NEXT: {{ $}} ; DAGISEL-NEXT: [[COPY:%[0-9]+]]:gpr64 = COPY $x0 ; DAGISEL-NEXT: [[ADRP:%[0-9]+]]:gpr64common = ADRP target-flags(aarch64-page) @discvar - ; DAGISEL-NEXT: [[LDRXui:%[0-9]+]]:gpr64 = LDRXui killed [[ADRP]], target-flags(aarch64-pageoff, aarch64-nc) @discvar :: (dereferenceable load (s64) from @discvar) - ; DAGISEL-NEXT: [[MOVKXi:%[0-9]+]]:gpr64noip = MOVKXi [[LDRXui]], 42, 48 - ; DAGISEL-NEXT: [[COPY1:%[0-9]+]]:gpr64noip = COPY [[LDRXui]] - ; DAGISEL-NEXT: [[PAC:%[0-9]+]]:gpr64 = PAC [[COPY]], 2, 42, killed [[COPY1]], implicit-def dead $x16, implicit-def dead $x17 + ; DAGISEL-NEXT: [[LDRXui:%[0-9]+]]:gpr64noip = LDRXui killed [[ADRP]], target-flags(aarch64-pageoff, aarch64-nc) @discvar :: (dereferenceable load (s64) from @discvar) + ; DAGISEL-NEXT: [[PAC:%[0-9]+]]:gpr64 = PAC [[COPY]], 2, 42, killed [[LDRXui]], implicit-def dead $x16, implicit-def dead $x17 ; DAGISEL-NEXT: $x0 = COPY [[PAC]] ; DAGISEL-NEXT: RET_ReallyLR implicit $x0 ; @@ -185,15 +176,12 @@ define i64 @blend_and_sign_same_bb(i64 %addr) { ; GISEL-NEXT: {{ $}} ; GISEL-NEXT: [[COPY:%[0-9]+]]:gpr64 = COPY $x0 ; GISEL-NEXT: [[ADRP:%[0-9]+]]:gpr64common = ADRP target-flags(aarch64-page) @discvar - ; GISEL-NEXT: [[LDRXui:%[0-9]+]]:gpr64 = LDRXui [[ADRP]], target-flags(aarch64-pageoff, aarch64-nc) @discvar :: (dereferenceable load (s64) from @discvar) - ; GISEL-NEXT: [[MOVKXi:%[0-9]+]]:gpr64noip = MOVKXi [[LDRXui]], 42, 48 - ; GISEL-NEXT: [[COPY1:%[0-9]+]]:gpr64noip = COPY [[LDRXui]] - ; GISEL-NEXT: [[PAC:%[0-9]+]]:gpr64 = PAC [[COPY]], 2, 42, [[COPY1]], implicit-def dead $x16, implicit-def dead $x17 + ; GISEL-NEXT: [[LDRXui:%[0-9]+]]:gpr64noip = LDRXui [[ADRP]], target-flags(aarch64-pageoff, aarch64-nc) @discvar :: (dereferenceable load (s64) from @discvar) + ; GISEL-NEXT: [[PAC:%[0-9]+]]:gpr64 = PAC [[COPY]], 2, 42, [[LDRXui]], implicit-def dead $x16, implicit-def dead $x17 ; GISEL-NEXT: $x0 = COPY [[PAC]] ; GISEL-NEXT: RET_ReallyLR implicit $x0 entry: %addrdisc = load i64, ptr @discvar - %disc = call i64 @llvm.ptrauth.blend(i64 %addrdisc, i64 42) - %signed = call i64 @llvm.ptrauth.sign(i64 %addr) [ "ptrauth"(i64 2, i64 %disc) ] + %signed = call i64 @llvm.ptrauth.sign(i64 %addr) [ "ptrauth"(i64 2, i64 %addrdisc, i64 42) ] ret i64 %signed } diff --git a/llvm/test/CodeGen/AArch64/ptrauth-ret-trap.ll b/llvm/test/CodeGen/AArch64/ptrauth-ret-trap.ll index 4821b3c0f274b..268a2d2161ca2 100644 --- a/llvm/test/CodeGen/AArch64/ptrauth-ret-trap.ll +++ b/llvm/test/CodeGen/AArch64/ptrauth-ret-trap.ll @@ -61,7 +61,7 @@ define void @test_tailcall_indirect_in_x9(ptr sret(i64) %ret, [8 x i64] %in, ptr ; CHECK: braa x0, x16 define void @test_auth_tailcall_indirect(ptr %fptr) #0 { call i32 @test_tailcall() - tail call void %fptr() [ "ptrauth"(i32 0, i64 42) ] + tail call void %fptr() [ "ptrauth"(i64 0, i64 42) ] ret void } @@ -75,7 +75,7 @@ define void @test_auth_tailcall_indirect(ptr %fptr) #0 { define void @test_auth_tailcall_indirect_in_x9(ptr sret(i64) %ret, [8 x i64] %in, ptr %fptr) #0 { %ptr = alloca i8, i32 16 call i32 @test_tailcall() - tail call void %fptr(ptr sret(i64) %ret, [8 x i64] %in) [ "ptrauth"(i32 1, i64 0) ] + tail call void %fptr(ptr sret(i64) %ret, [8 x i64] %in) [ "ptrauth"(i64 1, i64 0) ] ret void } @@ -89,7 +89,7 @@ define void @test_auth_tailcall_indirect_in_x9(ptr sret(i64) %ret, [8 x i64] %in define void @test_auth_tailcall_indirect_bti(ptr sret(i64) %ret, [8 x i64] %in, ptr %fptr) #0 "branch-target-enforcement"="true" { %ptr = alloca i8, i32 16 call i32 @test_tailcall() - tail call void %fptr(ptr sret(i64) %ret, [8 x i64] %in) [ "ptrauth"(i32 1, i64 0) ] + tail call void %fptr(ptr sret(i64) %ret, [8 x i64] %in) [ "ptrauth"(i64 1, i64 0) ] ret void } diff --git a/llvm/test/CodeGen/AArch64/ptrauth-tail-call-regalloc.ll b/llvm/test/CodeGen/AArch64/ptrauth-tail-call-regalloc.ll index ac578e3e99b81..09093ad1f13b0 100644 --- a/llvm/test/CodeGen/AArch64/ptrauth-tail-call-regalloc.ll +++ b/llvm/test/CodeGen/AArch64/ptrauth-tail-call-regalloc.ll @@ -20,7 +20,7 @@ entry: tail call void asm sideeffect "", "~{x0},~{x1},~{x2},~{x3},~{x4},~{x5},~{x6},~{x7},~{x8},~{x9},~{x10},~{x11},~{x12},~{x13},~{x14},~{x15}"() tail call void asm sideeffect "", "~{x18},~{x19},~{x20},~{x21},~{x22},~{x23},~{x24},~{x25},~{x26},~{x27},~{x28},~{fp}"() %addr.i = ptrtoint ptr %addr to i64 - %call = tail call i32 %callee() #1 [ "ptrauth"(i32 0, i64 %addr.i) ] + %call = tail call i32 %callee() #1 [ "ptrauth"(i64 0, i64 %addr.i) ] ret i32 %call } ;; Ensure the specific tail call pseudo instruction is used. @@ -70,7 +70,7 @@ entry: tail call void asm sideeffect "", "~{x0},~{x1},~{x2},~{x3},~{x4},~{x5},~{x6},~{x7},~{x8},~{x9},~{x10},~{x11},~{x12},~{x13},~{x14},~{x15}"() tail call void asm sideeffect "", "~{x18},~{x19},~{x20},~{x21},~{x22},~{x23},~{x24},~{x25},~{x26},~{x27},~{x28},~{fp}"() %addr.i = ptrtoint ptr %addr to i64 - %call = tail call i32 %callee() #1 [ "ptrauth"(i32 0, i64 %addr.i) ] + %call = tail call i32 %callee() #1 [ "ptrauth"(i64 0, i64 %addr.i) ] ret i32 %call } ;; Ensure the specific tail call pseudo instruction is used. diff --git a/llvm/test/Transforms/WholeProgramDevirt/devirt-single-impl-check-ptrauth.ll b/llvm/test/Transforms/WholeProgramDevirt/devirt-single-impl-check-ptrauth.ll index b7a90d91ad96b..4ba1fb8893b86 100644 --- a/llvm/test/Transforms/WholeProgramDevirt/devirt-single-impl-check-ptrauth.ll +++ b/llvm/test/Transforms/WholeProgramDevirt/devirt-single-impl-check-ptrauth.ll @@ -25,7 +25,7 @@ define void @call(ptr %obj) { cont: ; CHECK: call void @vf( - call void %fptr(ptr %obj) [ "ptrauth"(i32 5, i64 120) ] + call void %fptr(ptr %obj) [ "ptrauth"(i64 5, i64 120) ] ret void trap: From 621dc28e6504fa585169f88a113e1021672277ed Mon Sep 17 00:00:00 2001 From: Anatoly Trosinenko Date: Thu, 6 Nov 2025 20:28:29 +0300 Subject: [PATCH 18/40] CGPointerAuthInfo: use null discriminator components by default --- clang/lib/CodeGen/CGClass.cpp | 3 +-- clang/lib/CodeGen/CGPointerAuth.cpp | 6 +++--- clang/lib/CodeGen/CGPointerAuthInfo.h | 3 ++- clang/lib/CodeGen/ItaniumCXXABI.cpp | 4 ++-- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/clang/lib/CodeGen/CGClass.cpp b/clang/lib/CodeGen/CGClass.cpp index 624283854e130..de10ad102be9a 100644 --- a/clang/lib/CodeGen/CGClass.cpp +++ b/clang/lib/CodeGen/CGClass.cpp @@ -2774,8 +2774,7 @@ llvm::Value *CodeGenFunction::GetVTablePtr(Address This, } } else { VTable = cast(EmitPointerAuthAuth( - CGPointerAuthInfo(0, PointerAuthenticationMode::Strip, false, false, - nullptr, nullptr), + CGPointerAuthInfo(0, PointerAuthenticationMode::Strip, false, false), VTable)); } } diff --git a/clang/lib/CodeGen/CGPointerAuth.cpp b/clang/lib/CodeGen/CGPointerAuth.cpp index 20691db88bf1d..75bacb5184e8d 100644 --- a/clang/lib/CodeGen/CGPointerAuth.cpp +++ b/clang/lib/CodeGen/CGPointerAuth.cpp @@ -87,7 +87,7 @@ CGPointerAuthInfo CodeGenModule::getFunctionPointerAuthInfo(QualType T) { return CGPointerAuthInfo(Schema.getKey(), Schema.getAuthenticationMode(), /*IsaPointer=*/false, /*AuthenticatesNull=*/false, - Discriminator, nullptr); + Discriminator); } /// Emit the concrete pointer authentication informaton for the @@ -492,12 +492,12 @@ CGPointerAuthInfo CodeGenModule::getMemberFunctionPointerAuthInfo(QualType FT) { assert(!Schema.isAddressDiscriminated() && "function pointers cannot use address-specific discrimination"); - llvm::ConstantInt *Discriminator = + llvm::ConstantInt *ExtraDiscriminator = getPointerAuthOtherDiscriminator(Schema, GlobalDecl(), FT); return CGPointerAuthInfo(Schema.getKey(), Schema.getAuthenticationMode(), /* IsIsaPointer */ false, /* AuthenticatesNullValues */ false, nullptr, - Discriminator); + ExtraDiscriminator); } llvm::Constant *CodeGenModule::getMemberFunctionPointer(llvm::Constant *Pointer, diff --git a/clang/lib/CodeGen/CGPointerAuthInfo.h b/clang/lib/CodeGen/CGPointerAuthInfo.h index 933a31ddb4c17..205aba7171f26 100644 --- a/clang/lib/CodeGen/CGPointerAuthInfo.h +++ b/clang/lib/CodeGen/CGPointerAuthInfo.h @@ -29,7 +29,8 @@ class CGPointerAuthInfo { Discriminator(nullptr), ExtraDiscriminator(nullptr) {} CGPointerAuthInfo(unsigned Key, PointerAuthenticationMode AuthenticationMode, bool IsIsaPointer, bool AuthenticatesNullValues, - llvm::Value *Discriminator, llvm::Value *ExtraDiscriminator) + llvm::Value *Discriminator = nullptr, + llvm::Value *ExtraDiscriminator = nullptr) : AuthenticationMode(AuthenticationMode), IsIsaPointer(IsIsaPointer), AuthenticatesNullValues(AuthenticatesNullValues), Key(Key), Discriminator(Discriminator), ExtraDiscriminator(ExtraDiscriminator) { diff --git a/clang/lib/CodeGen/ItaniumCXXABI.cpp b/clang/lib/CodeGen/ItaniumCXXABI.cpp index 85e2fd5feccab..f02cdf5ab4ebb 100644 --- a/clang/lib/CodeGen/ItaniumCXXABI.cpp +++ b/clang/lib/CodeGen/ItaniumCXXABI.cpp @@ -880,7 +880,7 @@ CGCallee ItaniumCXXABI::EmitLoadOfMemberFunctionPointer( DiscriminatorPHI->addIncoming(NonVirtualDiscriminator, FnNonVirtual); PointerAuth = CGPointerAuthInfo( Schema.getKey(), Schema.getAuthenticationMode(), Schema.isIsaPointer(), - Schema.authenticatesNullValues(), DiscriminatorPHI, nullptr); + Schema.authenticatesNullValues(), DiscriminatorPHI); } CGCallee Callee(FPT, CalleePtr, PointerAuth); @@ -1775,7 +1775,7 @@ llvm::Value *ItaniumCXXABI::emitExactDynamicCast( // authenticate the resulting v-table at the end of the cast check. PerformPostCastAuthentication = CGF.getLangOpts().PointerAuthCalls; CGPointerAuthInfo StrippingAuthInfo(0, PointerAuthenticationMode::Strip, - false, false, nullptr, nullptr); + false, false); Address VTablePtrPtr = ThisAddr.withElementType(CGF.VoidPtrPtrTy); VTable = CGF.Builder.CreateLoad(VTablePtrPtr, "vtable"); if (PerformPostCastAuthentication) From d314ed45bd03ebe157048efc2274367108408630 Mon Sep 17 00:00:00 2001 From: Anatoly Trosinenko Date: Thu, 6 Nov 2025 22:40:31 +0300 Subject: [PATCH 19/40] Update Verifier and fix the test --- llvm/lib/IR/Verifier.cpp | 6 +- llvm/test/Verifier/ptrauth-operand-bundles.ll | 95 +++++++++++++++---- 2 files changed, 79 insertions(+), 22 deletions(-) diff --git a/llvm/lib/IR/Verifier.cpp b/llvm/lib/IR/Verifier.cpp index 93e78fdf46654..27cdc399a5d7c 100644 --- a/llvm/lib/IR/Verifier.cpp +++ b/llvm/lib/IR/Verifier.cpp @@ -4001,8 +4001,8 @@ void Verifier::visitCallBase(CallBase &Call) { ++NumPtrauthBundles; Check(!BU.Inputs.empty(), "Expected non-empty ptrauth bundle", Call); for (Value *V : BU.Inputs) - Check(V->getType()->isIntegerTy(32) || V->getType()->isIntegerTy(64), - "Ptrauth bundle must only contain i32 or i64 operands", Call); + Check(V->getType()->isIntegerTy(64), + "Ptrauth bundle must only contain i64 operands", Call); } else if (Tag == LLVMContext::OB_kcfi) { Check(!FoundKCFIBundle, "Multiple kcfi operand bundles", Call); FoundKCFIBundle = true; @@ -4048,7 +4048,7 @@ void Verifier::visitCallBase(CallBase &Call) { Check(NumPtrauthBundles == 1, "Expected exactly one ptrauth bundle", Call); break; case Intrinsic::ptrauth_resign: - Check(NumPtrauthBundles == 2, "Expected exactly one ptrauth bundle", Call); + Check(NumPtrauthBundles == 2, "Expected exactly two ptrauth bundles", Call); break; default: Check(NumPtrauthBundles == 0, "Unexpected ptrauth bundle", Call); diff --git a/llvm/test/Verifier/ptrauth-operand-bundles.ll b/llvm/test/Verifier/ptrauth-operand-bundles.ll index 7aa5a22f7816f..1b003d953a346 100644 --- a/llvm/test/Verifier/ptrauth-operand-bundles.ll +++ b/llvm/test/Verifier/ptrauth-operand-bundles.ll @@ -2,30 +2,87 @@ declare void @g() -define void @test_ptrauth_bundle(i64 %arg0, i32 %arg1, ptr %arg2) { +define void @test_ptrauth_bundle(i64 %arg.64, ptr %arg.ptr, ptr %ok) { -; CHECK: Multiple ptrauth operand bundles -; CHECK-NEXT: call void %arg2() [ "ptrauth"(i32 42, i64 100), "ptrauth"(i32 42, i64 %arg0) ] - call void %arg2() [ "ptrauth"(i32 42, i64 100), "ptrauth"(i32 42, i64 %arg0) ] +; CHECK: Multiple ptrauth operand bundles on a function call +; CHECK-NEXT: call void %arg.ptr() [ "ptrauth"(i64 42, i64 100), "ptrauth"(i64 42, i64 %arg.64) ] + call void %arg.ptr() [ "ptrauth"(i64 42, i64 100), "ptrauth"(i64 42, i64 %arg.64) ] -; CHECK: Ptrauth bundle key operand must be an i32 constant -; CHECK-NEXT: call void %arg2() [ "ptrauth"(i32 %arg1, i64 120) ] - call void %arg2() [ "ptrauth"(i32 %arg1, i64 120) ] +; CHECK: Direct call cannot have a ptrauth bundle +; CHECK-NEXT: call void @g() [ "ptrauth"(i64 42, i64 120) ] + call void @g() [ "ptrauth"(i64 42, i64 120) ] -; CHECK: Ptrauth bundle key operand must be an i32 constant -; CHECK-NEXT: call void %arg2() [ "ptrauth"(i64 42, i64 120) ] - call void %arg2() [ "ptrauth"(i64 42, i64 120) ] +; CHECK-NOT: call void %ok() + call void %ok() [ "ptrauth"(i32 42, i64 120) ] ; OK + call void %ok() [ "ptrauth"(i32 42, i64 %arg.64) ] ; OK + call void %ok() [ "ptrauth"(i64 %arg.64, i64 123) ] ; OK + call void %ok() [ "ptrauth"(i64 %arg.64, i64 123, i64 %arg.64, i64 42) ] ; OK -; CHECK: Ptrauth bundle discriminator operand must be an i64 -; CHECK-NEXT: call void %arg2() [ "ptrauth"(i32 42, i32 120) ] - call void %arg2() [ "ptrauth"(i32 42, i32 120) ] +; CHECK: Expected non-empty ptrauth bundle +; CHECK-NEXT: call void %arg.ptr() [ "ptrauth"() ] + call void %arg.ptr() [ "ptrauth"() ] -; CHECK: Direct call cannot have a ptrauth bundle -; CHECK-NEXT: call void @g() [ "ptrauth"(i32 42, i64 120) ] - call void @g() [ "ptrauth"(i32 42, i64 120) ] +; CHECK: Ptrauth bundle must only contain i64 operands +; CHECK-NEXT: call void %arg.ptr() [ "ptrauth"(i64 42, i32 120) ] + call void %arg.ptr() [ "ptrauth"(i64 42, i32 120) ] + +; CHECK: Ptrauth bundle must only contain i64 operands +; CHECK-NEXT: call void %arg.ptr() [ "ptrauth"(i32 42, i64 120, i64 123) ] + call void %arg.ptr() [ "ptrauth"(i32 42, i64 120, i64 123) ] + +; CHECK: Ptrauth bundle must only contain i64 operands +; CHECK-NEXT: call void %arg.ptr() [ "ptrauth"(i64 42, i64 120, i32 123) ] + call void %arg.ptr() [ "ptrauth"(i64 42, i64 120, i32 123) ] + +; Note that for compatibility reasons the first operand (originally, "the key ID") +; might be auto-upgraded to i64: +; +; CHECK-NOT: call void %ok() + call void %ok() [ "ptrauth"(i32 42, i64 120) ] + +; CHECK: Expected exactly one ptrauth bundle +; CHECK-NEXT: call i64 @llvm.ptrauth.auth(i64 0) +; CHECK: Expected exactly one ptrauth bundle +; CHECK-NEXT: call i64 @llvm.ptrauth.auth(i64 0) [ "ptrauth"(i64 42, i64 120), "ptrauth"(i64 42, i64 120) ] +; CHECK-NOT: @llvm.ptrauth.auth + call i64 @llvm.ptrauth.auth(i64 0) + call i64 @llvm.ptrauth.auth(i64 0) [ "ptrauth"(i64 42, i64 120), "ptrauth"(i64 42, i64 120) ] + call i64 @llvm.ptrauth.auth(i64 0) [ "ptrauth"(i64 42, i64 120) ] + call i64 @llvm.ptrauth.auth(i64 0) [ "ptrauth"(i64 %arg.64) ] + +; CHECK: Expected exactly one ptrauth bundle +; CHECK-NEXT: call i64 @llvm.ptrauth.sign(i64 0) +; CHECK: Expected exactly one ptrauth bundle +; CHECK-NEXT: call i64 @llvm.ptrauth.sign(i64 0) [ "ptrauth"(i64 42, i64 120), "ptrauth"(i64 42, i64 120) ] +; CHECK-NOT: @llvm.ptrauth.sign + call i64 @llvm.ptrauth.sign(i64 0) + call i64 @llvm.ptrauth.sign(i64 0) [ "ptrauth"(i64 42, i64 120), "ptrauth"(i64 42, i64 120) ] + call i64 @llvm.ptrauth.sign(i64 0) [ "ptrauth"(i64 42, i64 120) ] + call i64 @llvm.ptrauth.sign(i64 0) [ "ptrauth"(i64 %arg.64) ] + +; CHECK: Expected exactly two ptrauth bundles +; CHECK-NEXT: call i64 @llvm.ptrauth.resign(i64 0) +; CHECK: Expected exactly two ptrauth bundles +; CHECK-NEXT: call i64 @llvm.ptrauth.resign(i64 0) [ "ptrauth"(i64 42, i64 120) ] +; CHECK-NOT: @llvm.ptrauth.resign + call i64 @llvm.ptrauth.resign(i64 0) + call i64 @llvm.ptrauth.resign(i64 0) [ "ptrauth"(i64 42, i64 120) ] + call i64 @llvm.ptrauth.resign(i64 0) [ "ptrauth"(i64 42, i64 120), "ptrauth"(i64 42, i64 120) ] + call i64 @llvm.ptrauth.resign(i64 0) [ "ptrauth"(i64 %arg.64), "ptrauth"(i64 42, i64 120, i64 0, i64 123) ] + +; CHECK: Expected exactly one ptrauth bundle +; CHECK-NEXT: call i64 @llvm.ptrauth.strip(i64 0) +; CHECK: Expected exactly one ptrauth bundle +; CHECK-NEXT: call i64 @llvm.ptrauth.strip(i64 0) [ "ptrauth"(i64 42, i64 120), "ptrauth"(i64 42, i64 120) ] +; CHECK-NOT: @llvm.ptrauth.strip + call i64 @llvm.ptrauth.strip(i64 0) + call i64 @llvm.ptrauth.strip(i64 0) [ "ptrauth"(i64 42, i64 120), "ptrauth"(i64 42, i64 120) ] + call i64 @llvm.ptrauth.strip(i64 0) [ "ptrauth"(i64 42, i64 120) ] + call i64 @llvm.ptrauth.strip(i64 0) [ "ptrauth"(i64 %arg.64) ] + +; CHECK: Unexpected ptrauth bundle on intrinsic call +; CHECK-NEXT: call i64 @llvm.ptrauth.sign.generic(i64 0, i64 42) [ "ptrauth"(i64 42, i64 120) ] + call i64 @llvm.ptrauth.sign.generic(i64 0, i64 42) [ "ptrauth"(i64 42, i64 120) ] -; CHECK-NOT: call void - call void %arg2() [ "ptrauth"(i32 42, i64 120) ] ; OK - call void %arg2() [ "ptrauth"(i32 42, i64 %arg0) ] ; OK ret void } From 7a1cc15cf3532c8f9c02c5c71e1c33b20287afc9 Mon Sep 17 00:00:00 2001 From: Anatoly Trosinenko Date: Fri, 7 Nov 2025 19:07:55 +0300 Subject: [PATCH 20/40] Add negative test cases for auto-upgrading of ptrauth --- llvm/lib/IR/AutoUpgrade.cpp | 11 +- .../AArch64/ptrauth-invalid-upgrade.ll | 167 ++++++++++++++++++ 2 files changed, 174 insertions(+), 4 deletions(-) create mode 100644 llvm/test/CodeGen/AArch64/ptrauth-invalid-upgrade.ll diff --git a/llvm/lib/IR/AutoUpgrade.cpp b/llvm/lib/IR/AutoUpgrade.cpp index 536132a780045..f36cff6f6c7aa 100644 --- a/llvm/lib/IR/AutoUpgrade.cpp +++ b/llvm/lib/IR/AutoUpgrade.cpp @@ -4754,6 +4754,10 @@ static CallBase *setOperandBundles(CallBase *CI, ArrayRef OBs) // %callee = load ptr, ptr fn_ptr // call void %callee(i64 %some_arg, i32 %other_arg, i64 %blend) static CallBase *upgradeToPtrAuthBundles(CallBase *CI) { + // Skip: intrinsic calls are never indirect. + if (CI->isIndirectCall()) + return CI; + // Skip: current version or already converted to using bundles. if (CI->getNumOperandBundles()) return CI; @@ -4777,10 +4781,9 @@ static CallBase *upgradeToPtrAuthBundles(CallBase *CI) { switch (CI->arg_size()) { default: -#ifndef NDEBUG - CI->dump(); -#endif - llvm_unreachable("Unexpected intrinsic"); + // Unknown intrinsic or regular function - skip it now, it will be + // reported later as a usage that was not eliminated. + return CI; case 2: { // strip(value, key) -> strip(value, 0) [ "ptrauth"(key) ] Value *Key = CI->getArgOperand(1); diff --git a/llvm/test/CodeGen/AArch64/ptrauth-invalid-upgrade.ll b/llvm/test/CodeGen/AArch64/ptrauth-invalid-upgrade.ll new file mode 100644 index 0000000000000..7241abe141f9e --- /dev/null +++ b/llvm/test/CodeGen/AArch64/ptrauth-invalid-upgrade.ll @@ -0,0 +1,167 @@ +; RUN: split-file %s %t + +;--- store.ll +; RUN: not opt -passes=verify -S < %t/store.ll 2>&1 | FileCheck --check-prefix=STORE %s + +; STORE: Cannot upgrade all uses of @llvm.ptrauth.blend in function: +; STORE-NEXT: define void @test(ptr %p, i64 %addr) { +; STORE-NEXT: %disc = call i64 @llvm.ptrauth.blend(i64 %addr, i64 42) +; STORE-NEXT: store i64 %disc, ptr %p, align 4 +; STORE-NEXT: ret void +; STORE-NEXT: } +; STORE-NEXT: LLVM ERROR: Cannot upgrade some uses of @llvm.ptrauth.blend(). + +define void @test(ptr %p, i64 %addr) { + %disc = call i64 @llvm.ptrauth.blend(i64 %addr, i64 42) + store i64 %disc, ptr %p + ret void +} + +;--- arith.ll +; RUN: not opt -passes=verify -S < %t/arith.ll 2>&1 | FileCheck --check-prefix=ARITH %s + +; ARITH: Cannot upgrade all uses of @llvm.ptrauth.blend in function: +; ARITH-NEXT: define void @test(ptr %p, i64 %addr) { +; ARITH-NEXT: %disc = call i64 @llvm.ptrauth.blend(i64 %addr, i64 42) +; ARITH-NEXT: %tmp = add i64 %disc, 42 +; ARITH-NEXT: ret void +; ARITH-NEXT: } +; ARITH-NEXT: LLVM ERROR: Cannot upgrade some uses of @llvm.ptrauth.blend(). + +define void @test(ptr %p, i64 %addr) { + %disc = call i64 @llvm.ptrauth.blend(i64 %addr, i64 42) + %tmp = add i64 %disc, 42 + ret void +} + +;--- indirect-one-arg.ll +; RUN: not opt -passes=verify -S < %t/indirect-one-arg.ll 2>&1 | FileCheck --check-prefix=INDIRECT-ONE-ARG %s + +; INDIRECT-ONE-ARG: Cannot upgrade all uses of @llvm.ptrauth.blend in function: +; INDIRECT-ONE-ARG-NEXT: define void @test(ptr %some_fn, i64 %addr) { +; INDIRECT-ONE-ARG-NEXT: %disc = call i64 @llvm.ptrauth.blend(i64 %addr, i64 42) +; INDIRECT-ONE-ARG-NEXT: call void %some_fn(i64 %disc) +; INDIRECT-ONE-ARG-NEXT: ret void +; INDIRECT-ONE-ARG-NEXT: } +; INDIRECT-ONE-ARG-NEXT: LLVM ERROR: Cannot upgrade some uses of @llvm.ptrauth.blend(). + +define void @test(ptr %some_fn, i64 %addr) { + %disc = call i64 @llvm.ptrauth.blend(i64 %addr, i64 42) + call void %some_fn(i64 %disc) + ret void +} + +;--- direct-one-arg.ll +; RUN: not opt -passes=verify -S < %t/direct-one-arg.ll 2>&1 | FileCheck --check-prefix=DIRECT-ONE-ARG %s + +; DIRECT-ONE-ARG: Cannot upgrade all uses of @llvm.ptrauth.blend in function: +; DIRECT-ONE-ARG-NEXT: define void @test(i64 %addr) { +; DIRECT-ONE-ARG-NEXT: %disc = call i64 @llvm.ptrauth.blend(i64 %addr, i64 42) +; DIRECT-ONE-ARG-NEXT: call void @some_fn(i64 %disc) +; DIRECT-ONE-ARG-NEXT: ret void +; DIRECT-ONE-ARG-NEXT: } +; DIRECT-ONE-ARG-NEXT: LLVM ERROR: Cannot upgrade some uses of @llvm.ptrauth.blend(). + +declare void @some_fn(i64 %0) + +define void @test(i64 %addr) { + %disc = call i64 @llvm.ptrauth.blend(i64 %addr, i64 42) + call void @some_fn(i64 %disc) + ret void +} + +; During the upgrade, it is not always possible to directly check whether +; a call site is an intrinsic call and if it is, which intrinsic is called. +; Though, these errors can be caught indirectly. +; In the below test cases, auth_like_fn has the same arguments as the old +; version of @llvm.ptrauth.auth intrinsic. + +;--- indirect-three-args.ll +; RUN: not opt -passes=verify -S < %t/indirect-three-args.ll 2>&1 | FileCheck --check-prefix=INDIRECT-THREE-ARGS %s + +; Invalid call to %auth_like_fn is detected, because intrinsics are never +; called indirectly. + +; INDIRECT-THREE-ARGS: Cannot upgrade all uses of @llvm.ptrauth.blend in function: +; INDIRECT-THREE-ARGS-NEXT: define void @test(i64 %p, ptr %auth_like_fn, i64 %addr) { +; INDIRECT-THREE-ARGS-NEXT: %disc = call i64 @llvm.ptrauth.blend(i64 %addr, i64 42) +; INDIRECT-THREE-ARGS-NEXT: call void %auth_like_fn(i64 %p, i32 1, i64 %disc) +; INDIRECT-THREE-ARGS-NEXT: ret void +; INDIRECT-THREE-ARGS-NEXT: } +; INDIRECT-THREE-ARGS-NEXT: LLVM ERROR: Cannot upgrade some uses of @llvm.ptrauth.blend(). + +define void @test(i64 %p, ptr %auth_like_fn, i64 %addr) { + %disc = call i64 @llvm.ptrauth.blend(i64 %addr, i64 42) + call void %auth_like_fn(i64 %p, i32 1, i64 %disc) + ret void +} + +;--- direct-three-args.ll +; RUN: not opt -passes=verify -S < %t/direct-three-args.ll 2>&1 | FileCheck --check-prefix=DIRECT-THREE-ARGS %s + +; Invalid call to @auth_like_fn is formally upgraded as if it were an intrinsic +; call, but is caught by the verifier later, as regular function calls with +; "ptrauth" operand bundles must be indirect. + +; DIRECT-THREE-ARGS: Direct call cannot have a ptrauth bundle +; DIRECT-THREE-ARGS-NEXT: call void @auth_like_fn(i64 %p, i32 0, i64 0) [ "ptrauth"(i64 1, i64 %addr, i64 42) ] +; DIRECT-THREE-ARGS-NEXT: error: input module is broken! + +declare void @auth_like_fn(i64 %0, i32 %1, i64 %2) + +define void @test(i64 %p, i64 %addr) { + %disc = call i64 @llvm.ptrauth.blend(i64 %addr, i64 42) + call void @auth_like_fn(i64 %p, i32 1, i64 %disc) + ret void +} + +;--- wrong-intrinsic-with-ptrauth-bundle.ll +; RUN: not opt -passes=verify -S < %t/wrong-intrinsic-with-ptrauth-bundle.ll 2>&1 | FileCheck --check-prefix=WRONG-INTRINSIC-WITH-PTRAUTH-BUNDLE %s + +; This test case does not involve auto-upgrading, but it shows the behavior of +; the IR verifier if any unrelated intrinsic would be formally auto-upgraded. + +; WRONG-INTRINSIC-WITH-PTRAUTH-BUNDLE: Unexpected ptrauth bundle on intrinsic call +; WRONG-INTRINSIC-WITH-PTRAUTH-BUNDLE-NEXT: %1 = call i64 @llvm.ptrauth.sign.generic(i64 %p, i64 0) [ "ptrauth"(i64 1, i64 %addr, i64 42) ] +; WRONG-INTRINSIC-WITH-PTRAUTH-BUNDLE-NEXT: /data/ast/llvm-project/build/bin/opt: -: error: input module is broken! + +define void @test(i64 %p, ptr %auth_like_fn, i64 %addr) { + %disc = call i64 @llvm.ptrauth.blend(i64 %addr, i64 42) + ; The below call uses the new-style all-i64 ptrauth bundle. + call i64 @llvm.ptrauth.sign.generic(i64 %p, i64 0) [ "ptrauth"(i64 1, i64 %disc) ] + ret void +} + +;--- wrong-position-in-bundle.ll +; RUN: not opt -passes=verify -S < %t/wrong-position-in-bundle.ll 2>&1 | FileCheck --check-prefix=WRONG-POSITION-IN-BUNDLE %s + +; WRONG-POSITION-IN-BUNDLE: Cannot upgrade all uses of @llvm.ptrauth.blend in function: +; WRONG-POSITION-IN-BUNDLE-NEXT: define void @test(i64 %p, i64 %addr) { +; WRONG-POSITION-IN-BUNDLE-NEXT: %disc = call i64 @llvm.ptrauth.blend(i64 %addr, i64 42) +; WRONG-POSITION-IN-BUNDLE-NEXT: %1 = call i64 @llvm.ptrauth.auth(i64 %p) [ "ptrauth"(i64 %disc, i64 1) ] +; WRONG-POSITION-IN-BUNDLE-NEXT: ret void +; WRONG-POSITION-IN-BUNDLE-NEXT: } +; WRONG-POSITION-IN-BUNDLE-NEXT: LLVM ERROR: Cannot upgrade some uses of @llvm.ptrauth.blend(). + +define void @test(i64 %p, i64 %addr) { + %disc = call i64 @llvm.ptrauth.blend(i64 %addr, i64 42) + call i64 @llvm.ptrauth.auth(i64 %p, i64 %disc, i64 1) + ret void +} + +;--- both-positions-in-bundle.ll +; RUN: not opt -passes=verify -S < %t/both-positions-in-bundle.ll 2>&1 | FileCheck --check-prefix=BOTH-POSITIONS-IN-BUNDLE %s + +; BOTH-POSITIONS-IN-BUNDLE: Cannot upgrade all uses of @llvm.ptrauth.blend in function: +; BOTH-POSITIONS-IN-BUNDLE-NEXT: define void @test(i64 %p, i64 %addr) { +; BOTH-POSITIONS-IN-BUNDLE-NEXT: %disc = call i64 @llvm.ptrauth.blend(i64 %addr, i64 42) +; BOTH-POSITIONS-IN-BUNDLE-NEXT: %1 = call i64 @llvm.ptrauth.auth(i64 %p) [ "ptrauth"(i64 %disc, i64 %addr, i64 42) ] +; BOTH-POSITIONS-IN-BUNDLE-NEXT: ret void +; BOTH-POSITIONS-IN-BUNDLE-NEXT: } +; BOTH-POSITIONS-IN-BUNDLE-NEXT: LLVM ERROR: Cannot upgrade some uses of @llvm.ptrauth.blend(). + +define void @test(i64 %p, i64 %addr) { + %disc = call i64 @llvm.ptrauth.blend(i64 %addr, i64 42) + call i64 @llvm.ptrauth.auth(i64 %p, i64 %disc, i64 %disc) + ret void +} From 0d0073dc869eb52e20607ffab23084fb769c6254 Mon Sep 17 00:00:00 2001 From: Anatoly Trosinenko Date: Fri, 7 Nov 2025 19:11:29 +0300 Subject: [PATCH 21/40] Check that unused llvm.ptrauth.blend is silently eliminated --- llvm/test/CodeGen/AArch64/ptrauth-intrinsics-upgrade.ll | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/llvm/test/CodeGen/AArch64/ptrauth-intrinsics-upgrade.ll b/llvm/test/CodeGen/AArch64/ptrauth-intrinsics-upgrade.ll index 54270cfd7d57b..a59c10fef78ba 100644 --- a/llvm/test/CodeGen/AArch64/ptrauth-intrinsics-upgrade.ll +++ b/llvm/test/CodeGen/AArch64/ptrauth-intrinsics-upgrade.ll @@ -123,3 +123,11 @@ exit: %res = call i64 @llvm.ptrauth.resign(i64 %p, i32 1, i64 %tmp, i32 2, i64 %tmp) ret void } + +define i64 @test_unused_blend(i64 %addr) { +; CHECK-LABEL: @test_unused_blend( +; CHECK-NEXT: ret i64 [[ADDR:%.*]] +; + %tmp = call i64 @llvm.ptrauth.blend(i64 %addr, i64 1234) + ret i64 %addr +} From b744611a3157ff0748efef5a671de7a7cd514670 Mon Sep 17 00:00:00 2001 From: Anatoly Trosinenko Date: Mon, 10 Nov 2025 18:07:34 +0300 Subject: [PATCH 22/40] Misc cleanup --- clang/lib/CodeGen/CGBuiltin.cpp | 2 +- llvm/docs/LangRef.rst | 12 +-- llvm/docs/PointerAuth.md | 30 ++++--- .../Target/AArch64/AArch64ISelLowering.cpp | 60 +++++++------ llvm/test/CodeGen/AArch64/ptrauth-isel.ll | 86 ++++--------------- 5 files changed, 70 insertions(+), 120 deletions(-) diff --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp index 6ef6c8f71a24b..0989560fcf8a0 100644 --- a/clang/lib/CodeGen/CGBuiltin.cpp +++ b/clang/lib/CodeGen/CGBuiltin.cpp @@ -5633,7 +5633,7 @@ RValue CodeGenFunction::EmitBuiltinExpr(const GlobalDecl GD, unsigned BuiltinID, case Builtin::BI__builtin_ptrauth_sign_generic_data: case Builtin::BI__builtin_ptrauth_sign_unauthenticated: case Builtin::BI__builtin_ptrauth_strip: { - SmallVector Args; + SmallVector Args; SmallVector OBs; auto ConvertToInt64 = [&](llvm::Value *V) { diff --git a/llvm/docs/LangRef.rst b/llvm/docs/LangRef.rst index f01c6bcb1b759..cec5516257c08 100644 --- a/llvm/docs/LangRef.rst +++ b/llvm/docs/LangRef.rst @@ -5315,18 +5315,12 @@ Its type is the same as the first argument. An integer constant discriminator and an address discriminator may be optionally specified. Otherwise, they have values ``i64 0`` and ``ptr null``. -If the address discriminator is ``null`` then the expression is equivalent to +The expression '``ptrauth(ptr CST, i32 KEY, i64 DISC, ptr ADDRDISC)``' is +equivalent to .. code-block:: llvm - %tmp = call i64 @llvm.ptrauth.sign(i64 ptrtoint (ptr CST to i64)) [ "ptrauth"(i32 KEY, i64 DISC) ] - %val = inttoptr i64 %tmp to ptr - -Otherwise, the expression is equivalent to: - -.. code-block:: llvm - - %tmp = call i64 @llvm.ptrauth.sign(i64 ptrtoint (ptr CST to i64)) [ "ptrauth"(i32 KEY, i64 ptrtoint (ptr ADDRDISC to i64), i64 DISC) ] + %tmp = call i64 @llvm.ptrauth.sign(i64 ptrtoint (ptr CST to i64)) [ "ptrauth"(i64 KEY, i64 ptrtoint (ptr ADDRDISC to i64), i64 DISC) ] %val = inttoptr i64 %tmp to ptr If the deactivation symbol operand ``DS`` has a non-null value, diff --git a/llvm/docs/PointerAuth.md b/llvm/docs/PointerAuth.md index 7981f91e0ed02..ef13dbf5b6012 100644 --- a/llvm/docs/PointerAuth.md +++ b/llvm/docs/PointerAuth.md @@ -15,8 +15,9 @@ For more details, see the clang documentation page for At the IR level, it is represented using: -* a [call operand bundle](#operand-bundle) (to authenticate called pointers) * a [set of intrinsics](#intrinsics) (to sign/authenticate pointers) +* a [call operand bundle](#operand-bundle) (to authenticate called pointers + and to pass signing schema description to the intrinsics) * a [signed pointer constant](#constant) (to sign globals) * a [set of function attributes](#function-attributes) (to describe what pointers are signed and how, to control implicit codegen in the backend, as @@ -107,7 +108,7 @@ target-specific way. ##### Semantics: -The '`llvm.ptrauth.sign`' intrinsic implements the `sign`_ operation. +The '`llvm.ptrauth.sign`' intrinsic implements the `sign` operation. It returns a signed value. If `value` is already a signed value, the behavior is undefined. @@ -133,11 +134,11 @@ The '`llvm.ptrauth.auth`' intrinsic authenticates a signed pointer. The `value` argument is the signed pointer value to be authenticated. The `ptrauth` call operand bundle describes the signing schema that was used -to generate the signed value in a target-specific way.. +to generate the signed value in a target-specific way. ##### Semantics: -The '`llvm.ptrauth.auth`' intrinsic implements the `auth`_ operation. +The '`llvm.ptrauth.auth`' intrinsic implements the `auth` operation. It returns a raw pointer value. If `value` does not have a correct signature for the signing schema, the intrinsic traps in a target-specific way. @@ -166,7 +167,7 @@ to generate the signed value in a target-specific way. ##### Semantics: -The '`llvm.ptrauth.strip`' intrinsic implements the `strip`_ operation. +The '`llvm.ptrauth.strip`' intrinsic implements the `strip` operation. It returns a raw pointer value. It does **not** check that the signature is valid. @@ -199,7 +200,7 @@ a different signing schema. ##### Arguments: -The `value` argument is the signed pointer value to be authenticated. +The `value` argument is the signed pointer value to be re-signed. The first `ptrauth` bundle specifies the signing schema that was used to generate the signed value. @@ -300,19 +301,20 @@ The Armv8.3-A architecture extension defines the PAuth feature, which provides support for instructions that manipulate Pointer Authentication Codes (PAC). Sign and auth operations are parameterized by a constant key identifier and -a 64-bit discriminator value. +a 64-bit discriminator value which is computed according to signing schema. On AArch64, `ptrauth` bundle may have from one to three operands, the former always being constant integer denoting the [key](#keys) identifier and the rest -operands describing the *modifier* being used: -* `"ptrauth"(i64 )`: the operation uses the key `` and modifier is - not applicable. Only used by `@llvm.ptrauth.strip` intrinsic. -* `"ptrauth"(i64 , i64 raw_discr)`: the 64-bit discriminator value is +operands describing the discriminator being used: +* `"ptrauth"(i64 )`: the operation uses the key `` and the + discriminator is zero or not applicable. It is the only form accepted by + `@llvm.ptrauth.strip` intrinsic. +* `"ptrauth"(i64 , i64 raw_disc)`: the 64-bit discriminator value is passed as-is, either constant or not. If constant value is passed, and it fits in 16 bits, it is safely materialized right before its usage. -* `"ptrauth"(i64 , i64 %addr_modif, i64 )`: the modifier to - be used is computed by [blending](#blend-operation) an integer modifier into - an address modifier. +* `"ptrauth"(i64 , i64 %addr_modif, i64 )`: the discriminator + to be used is computed by [blending](#blend-operation) an integer modifier + into an address modifier. #### Keys diff --git a/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp b/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp index f4eeb4fe238b9..c93ab1cb80669 100644 --- a/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp +++ b/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp @@ -30002,7 +30002,10 @@ AArch64TargetLowering::EmitKCFICheck(MachineBasicBlock &MBB, // On AArch64, a normalized "ptrauth" bundle has the form: // - "ptrauth"(i64 key) for a call to ptrauth_strip intrinsic -// - "ptrauth"(i64 key, i64 addr_discr, i64 int_disc) otherwise +// - "ptrauth"(i64 key, i64 addr_disc, i64 int_disc) otherwise +// +// Note that on AArch64, PAuth-related pseudo instructions currently represent +// raw, pre-computed discriminator values as (addr_disc=value, int_disc=0). void AArch64TargetLowering::normalizePtrAuthBundle( const CallBase &I, OperandBundleUse OB, SmallVectorImpl &Output) const { @@ -30011,50 +30014,57 @@ void AArch64TargetLowering::normalizePtrAuthBundle( // Validate target-specific assumptions at least once even in no-assertion // builds, as the IR may be provided by the user. - - auto ReportIf = [&I](bool ErrorCondition, StringRef Msg) { - if (!ErrorCondition) + auto Validate = [&I](bool Condition, StringRef Msg) { + if (Condition) return; StringRef FunctionName = I.getFunction()->getName(); reportFatalUsageError(FunctionName + ": " + Msg); }; - ReportIf(OB.Inputs.size() < 1 || OB.Inputs.size() > 3, + unsigned NumOperands = OB.Inputs.size(); + Validate(1 <= NumOperands && NumOperands <= 3, "ptrauth bundles must have from 1 to 3 operands on AArch64"); // The first operand is always the key ID. - ReportIf(!isa(OB.Inputs[0]), + Value *Key = OB.Inputs[0]; + Validate(isa(Key), "Key must be constant in ptrauth bundle on AArch64"); - // FIXME - Output.push_back(ConstantInt::get(Ctx, APInt(64, cast(OB.Inputs[0])->getZExtValue()))); - // ptrauth_strip requires a single-operand bundle. if (I.getIntrinsicID() == Intrinsic::ptrauth_strip) { - ReportIf(OB.Inputs.size() != 1, + Validate(NumOperands == 1, "@llvm.ptrauth.strip accepts 1-element ptrauth bundle on AArch64"); + Output.append({Key}); return; } // Otherwise we should normalize to a three-operand form. - if (OB.Inputs.size() == 3) { - auto *IntDiscr = dyn_cast(OB.Inputs[2]); - ReportIf(!IntDiscr || !isUInt<16>(IntDiscr->getZExtValue()), - "Constant modifier must be uint16 in ptrauth bundle on AArch64"); + Value *Zero = ConstantInt::get(Ctx, APInt::getZero(64)); + auto IsValidIntDisc = [](Value *V) { + auto *IntDisc = dyn_cast(V); + return V && isUInt<16>(IntDisc->getZExtValue()); + }; - // Nothing to normalize for a valid three-element bundle. - Output.append({OB.Inputs[1], OB.Inputs[2]}); - return; + if (NumOperands == 1) { + // "ptrauth"(key) -> "ptrauth"(key, 0, 0) + Output.append({Key, Zero, Zero}); + } else if (NumOperands == 2) { + // "ptrauth"(key, disc) -> "ptrauth"(key, 0, disc), if possible + // "ptrauth"(key, disc) -> "ptrauth"(key, disc, 0), otherwise + Value *Disc = OB.Inputs[1]; + if (IsValidIntDisc(Disc)) + Output.append({Key, /*addr_disc=*/Zero, /*int_disc=*/Disc}); + else + Output.append({Key, /*addr_disc=*/Disc, /*int_disc=*/Zero}); + } else { + // "ptrauth"(key, addr_disc, int_disc) - already normalized, just validate + Value *AddrDisc = OB.Inputs[1]; + Value *IntDisc = OB.Inputs[2]; + Validate(IsValidIntDisc(IntDisc), + "Constant modifier must be uint16 in ptrauth bundle on AArch64"); + Output.append({Key, AddrDisc, IntDisc}); } - - Value *Disc = OB.Inputs[1]; - Value *Zero = ConstantInt::get(Ctx, APInt::getZero(64)); - if (isa(Disc) && - isUInt<16>(cast(Disc)->getZExtValue())) - Output.append({Zero, Disc}); - else - Output.append({Disc, Zero}); } bool AArch64TargetLowering::enableAggressiveFMAFusion(EVT VT) const { diff --git a/llvm/test/CodeGen/AArch64/ptrauth-isel.ll b/llvm/test/CodeGen/AArch64/ptrauth-isel.ll index c161f9d42b98f..add5fb289056f 100644 --- a/llvm/test/CodeGen/AArch64/ptrauth-isel.ll +++ b/llvm/test/CodeGen/AArch64/ptrauth-isel.ll @@ -15,8 +15,11 @@ ; FIXME Should we remove this file? -; Make sure the components of blend(addr, imm) and integer constants are -; recognized and passed to PAC pseudo via separate operands to prevent +; Make sure various forms of "ptrauth" call bundles are properly normalized +; to a full, three-operand form and then passed as the operands of PAC pseudo. +; Specifically, make sure that "ptrauth"(i64 key, i64 disc) is handled as +; "ptrauth"(i64 key, i64 disc, i64 0) when disc is uint16 constant and as +; "ptrauth"(i64 key, i64 0, i64 disc) otherwise. This is important to prevent ; substitution of the immediate modifier. ; ; MIR output of the instruction selector is inspected, as it is hard to reliably @@ -30,8 +33,7 @@ define i64 @small_imm_disc_optimized(i64 %addr) { ; DAGISEL-NEXT: liveins: $x0 ; DAGISEL-NEXT: {{ $}} ; DAGISEL-NEXT: [[COPY:%[0-9]+]]:gpr64 = COPY $x0 - ; DAGISEL-NEXT: [[COPY1:%[0-9]+]]:gpr64noip = COPY $xzr - ; DAGISEL-NEXT: [[PAC:%[0-9]+]]:gpr64 = PAC [[COPY]], 2, 42, [[COPY1]], implicit-def dead $x16, implicit-def dead $x17 + ; DAGISEL-NEXT: [[PAC:%[0-9]+]]:gpr64 = PAC [[COPY]], 2, 42, $noreg, implicit-def dead $x16, implicit-def dead $x17 ; DAGISEL-NEXT: $x0 = COPY [[PAC]] ; DAGISEL-NEXT: RET_ReallyLR implicit $x0 ; @@ -40,8 +42,7 @@ define i64 @small_imm_disc_optimized(i64 %addr) { ; GISEL-NEXT: liveins: $x0 ; GISEL-NEXT: {{ $}} ; GISEL-NEXT: [[COPY:%[0-9]+]]:gpr64 = COPY $x0 - ; GISEL-NEXT: [[COPY1:%[0-9]+]]:gpr64noip = COPY $xzr - ; GISEL-NEXT: [[PAC:%[0-9]+]]:gpr64 = PAC [[COPY]], 2, 42, [[COPY1]], implicit-def dead $x16, implicit-def dead $x17 + ; GISEL-NEXT: [[PAC:%[0-9]+]]:gpr64 = PAC [[COPY]], 2, 42, $noreg, implicit-def dead $x16, implicit-def dead $x17 ; GISEL-NEXT: $x0 = COPY [[PAC]] ; GISEL-NEXT: RET_ReallyLR implicit $x0 entry: @@ -49,7 +50,6 @@ entry: ret i64 %signed } -; Without optimization, MOVi64imm may be used for small i64 constants as well. define i64 @small_imm_disc_non_optimized(i64 %addr) noinline optnone { ; DAGISEL-LABEL: name: small_imm_disc_non_optimized ; DAGISEL: bb.0.entry: @@ -57,8 +57,7 @@ define i64 @small_imm_disc_non_optimized(i64 %addr) noinline optnone { ; DAGISEL-NEXT: {{ $}} ; DAGISEL-NEXT: [[COPY:%[0-9]+]]:gpr64 = COPY $x0 ; DAGISEL-NEXT: [[COPY1:%[0-9]+]]:gpr64 = COPY killed [[COPY]] - ; DAGISEL-NEXT: [[COPY2:%[0-9]+]]:gpr64noip = COPY $xzr - ; DAGISEL-NEXT: [[PAC:%[0-9]+]]:gpr64 = PAC [[COPY1]], 2, 42, [[COPY2]], implicit-def dead $x16, implicit-def dead $x17 + ; DAGISEL-NEXT: [[PAC:%[0-9]+]]:gpr64 = PAC [[COPY1]], 2, 42, $noreg, implicit-def dead $x16, implicit-def dead $x17 ; DAGISEL-NEXT: [[COPY3:%[0-9]+]]:gpr64all = COPY [[PAC]] ; DAGISEL-NEXT: $x0 = COPY [[COPY3]] ; DAGISEL-NEXT: RET_ReallyLR implicit $x0 @@ -68,8 +67,7 @@ define i64 @small_imm_disc_non_optimized(i64 %addr) noinline optnone { ; GISEL-NEXT: liveins: $x0 ; GISEL-NEXT: {{ $}} ; GISEL-NEXT: [[COPY:%[0-9]+]]:gpr64 = COPY $x0 - ; GISEL-NEXT: [[COPY1:%[0-9]+]]:gpr64noip = COPY $xzr - ; GISEL-NEXT: [[PAC:%[0-9]+]]:gpr64 = PAC [[COPY]], 2, 42, [[COPY1]], implicit-def dead $x16, implicit-def dead $x17 + ; GISEL-NEXT: [[PAC:%[0-9]+]]:gpr64 = PAC [[COPY]], 2, 42, $noreg, implicit-def dead $x16, implicit-def dead $x17 ; GISEL-NEXT: $x0 = COPY [[PAC]] ; GISEL-NEXT: RET_ReallyLR implicit $x0 entry: @@ -77,8 +75,8 @@ entry: ret i64 %signed } -define i64 @large_imm_disc_wreg(i64 %addr) { - ; DAGISEL-LABEL: name: large_imm_disc_wreg +define i64 @large_imm_disc(i64 %addr) { + ; DAGISEL-LABEL: name: large_imm_disc ; DAGISEL: bb.0.entry: ; DAGISEL-NEXT: liveins: $x0 ; DAGISEL-NEXT: {{ $}} @@ -89,7 +87,7 @@ define i64 @large_imm_disc_wreg(i64 %addr) { ; DAGISEL-NEXT: $x0 = COPY [[PAC]] ; DAGISEL-NEXT: RET_ReallyLR implicit $x0 ; - ; GISEL-LABEL: name: large_imm_disc_wreg + ; GISEL-LABEL: name: large_imm_disc ; GISEL: bb.1.entry: ; GISEL-NEXT: liveins: $x0 ; GISEL-NEXT: {{ $}} @@ -104,62 +102,8 @@ entry: ret i64 %signed } -define i64 @large_imm_disc_xreg(i64 %addr) { - ; DAGISEL-LABEL: name: large_imm_disc_xreg - ; DAGISEL: bb.0.entry: - ; DAGISEL-NEXT: liveins: $x0 - ; DAGISEL-NEXT: {{ $}} - ; DAGISEL-NEXT: [[COPY:%[0-9]+]]:gpr64 = COPY $x0 - ; DAGISEL-NEXT: [[MOVi64imm:%[0-9]+]]:gpr64noip = MOVi64imm 123456789012345 - ; DAGISEL-NEXT: [[PAC:%[0-9]+]]:gpr64 = PAC [[COPY]], 2, 0, killed [[MOVi64imm]], implicit-def dead $x16, implicit-def dead $x17 - ; DAGISEL-NEXT: $x0 = COPY [[PAC]] - ; DAGISEL-NEXT: RET_ReallyLR implicit $x0 - ; - ; GISEL-LABEL: name: large_imm_disc_xreg - ; GISEL: bb.1.entry: - ; GISEL-NEXT: liveins: $x0 - ; GISEL-NEXT: {{ $}} - ; GISEL-NEXT: [[COPY:%[0-9]+]]:gpr64 = COPY $x0 - ; GISEL-NEXT: [[MOVi64imm:%[0-9]+]]:gpr64noip = MOVi64imm 123456789012345 - ; GISEL-NEXT: [[PAC:%[0-9]+]]:gpr64 = PAC [[COPY]], 2, 0, [[MOVi64imm]], implicit-def dead $x16, implicit-def dead $x17 - ; GISEL-NEXT: $x0 = COPY [[PAC]] - ; GISEL-NEXT: RET_ReallyLR implicit $x0 -entry: - %signed = call i64 @llvm.ptrauth.sign(i64 %addr) [ "ptrauth"(i64 2, i64 123456789012345) ] - ret i64 %signed -} - -; Make sure blend() is lowered as expected when optimization is disabled. -define i64 @blended_disc_non_optimized(i64 %addr, i64 %addrdisc) noinline optnone { - ; DAGISEL-LABEL: name: blended_disc_non_optimized - ; DAGISEL: bb.0.entry: - ; DAGISEL-NEXT: liveins: $x0, $x1 - ; DAGISEL-NEXT: {{ $}} - ; DAGISEL-NEXT: [[COPY:%[0-9]+]]:gpr64 = COPY $x1 - ; DAGISEL-NEXT: [[COPY1:%[0-9]+]]:gpr64 = COPY $x0 - ; DAGISEL-NEXT: [[COPY2:%[0-9]+]]:gpr64 = COPY killed [[COPY1]] - ; DAGISEL-NEXT: [[COPY3:%[0-9]+]]:gpr64noip = COPY killed [[COPY]] - ; DAGISEL-NEXT: [[PAC:%[0-9]+]]:gpr64 = PAC [[COPY2]], 2, 42, [[COPY3]], implicit-def dead $x16, implicit-def dead $x17 - ; DAGISEL-NEXT: [[COPY4:%[0-9]+]]:gpr64all = COPY [[PAC]] - ; DAGISEL-NEXT: $x0 = COPY [[COPY4]] - ; DAGISEL-NEXT: RET_ReallyLR implicit $x0 - ; - ; GISEL-LABEL: name: blended_disc_non_optimized - ; GISEL: bb.1.entry: - ; GISEL-NEXT: liveins: $x0, $x1 - ; GISEL-NEXT: {{ $}} - ; GISEL-NEXT: [[COPY:%[0-9]+]]:gpr64 = COPY $x0 - ; GISEL-NEXT: [[COPY1:%[0-9]+]]:gpr64noip = COPY $x1 - ; GISEL-NEXT: [[PAC:%[0-9]+]]:gpr64 = PAC [[COPY]], 2, 42, [[COPY1]], implicit-def dead $x16, implicit-def dead $x17 - ; GISEL-NEXT: $x0 = COPY [[PAC]] - ; GISEL-NEXT: RET_ReallyLR implicit $x0 -entry: - %signed = call i64 @llvm.ptrauth.sign(i64 %addr) [ "ptrauth"(i64 2, i64 %addrdisc, i64 42) ] - ret i64 %signed -} - -define i64 @blend_and_sign_same_bb(i64 %addr) { - ; DAGISEL-LABEL: name: blend_and_sign_same_bb +define i64 @blended_disc(i64 %addr) { + ; DAGISEL-LABEL: name: blended_disc ; DAGISEL: bb.0.entry: ; DAGISEL-NEXT: liveins: $x0 ; DAGISEL-NEXT: {{ $}} @@ -170,7 +114,7 @@ define i64 @blend_and_sign_same_bb(i64 %addr) { ; DAGISEL-NEXT: $x0 = COPY [[PAC]] ; DAGISEL-NEXT: RET_ReallyLR implicit $x0 ; - ; GISEL-LABEL: name: blend_and_sign_same_bb + ; GISEL-LABEL: name: blended_disc ; GISEL: bb.1.entry: ; GISEL-NEXT: liveins: $x0 ; GISEL-NEXT: {{ $}} From 238e72655accaaf927511fbcd69b23b8dceae65e Mon Sep 17 00:00:00 2001 From: Anatoly Trosinenko Date: Tue, 11 Nov 2025 20:15:20 +0300 Subject: [PATCH 23/40] WIP: [LLVM] Adjust ptrauth operand bundles Always use three-operand bundles for simplicity (except for ptrauth.strip). Change operand order from (key, addr, int) to (key, int, addr) to reflect operand order of ptrauth constants. More cleanup. --- llvm/docs/LangRef.rst | 7 +- llvm/docs/PointerAuth.md | 18 +-- .../llvm/CodeGen/GlobalISel/IRTranslator.h | 3 + llvm/include/llvm/CodeGen/TargetLowering.h | 23 ++- llvm/include/llvm/IR/Constants.h | 11 +- llvm/include/llvm/SandboxIR/Constant.h | 7 +- llvm/include/llvm/Target/GenericOpcodes.td | 8 +- llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp | 111 ++++++------- .../SelectionDAG/SelectionDAGBuilder.cpp | 89 +++++----- .../SelectionDAG/SelectionDAGBuilder.h | 1 + llvm/lib/IR/AutoUpgrade.cpp | 120 +++++++++----- llvm/lib/IR/Constants.cpp | 103 +++--------- llvm/lib/Target/AArch64/AArch64AsmPrinter.cpp | 30 +++- .../Target/AArch64/AArch64ISelLowering.cpp | 104 +++++------- llvm/lib/Target/AArch64/AArch64ISelLowering.h | 4 +- llvm/lib/Target/AArch64/AArch64InstrInfo.td | 15 +- .../AArch64/AArch64SelectionDAGInfo.cpp | 9 +- .../AArch64/GISel/AArch64GlobalISelUtils.cpp | 5 +- .../InstCombine/InstCombineCalls.cpp | 82 ++++------ .../CodeGen/AArch64/deactivation-symbols.ll | 12 +- llvm/test/CodeGen/AArch64/ptrauth-bti-call.ll | 48 +++--- .../CodeGen/AArch64/ptrauth-call-rv-marker.ll | 102 ++++++------ .../CodeGen/AArch64/ptrauth-call-upgrade.ll | 8 +- llvm/test/CodeGen/AArch64/ptrauth-call.ll | 152 ++++++++++-------- llvm/test/CodeGen/AArch64/ptrauth-fpac.ll | 36 ++--- ...trauth-intrinsic-auth-resign-with-blend.ll | 8 +- .../AArch64/ptrauth-intrinsic-auth-resign.ll | 40 ++--- .../CodeGen/AArch64/ptrauth-intrinsic-sign.ll | 16 +- .../AArch64/ptrauth-intrinsics-upgrade.ll | 48 +++--- .../AArch64/ptrauth-invalid-upgrade.ll | 25 +-- llvm/test/CodeGen/AArch64/ptrauth-invoke.ll | 8 +- llvm/test/CodeGen/AArch64/ptrauth-isel.ll | 8 +- llvm/test/CodeGen/AArch64/ptrauth-ret-trap.ll | 4 +- .../AArch64/ptrauth-tail-call-regalloc.ll | 4 +- .../MIR/AArch64/deactivation-symbols.mir | 4 +- .../Transforms/InstCombine/ptrauth-call.ll | 26 +-- .../InstCombine/ptrauth-intrinsics.ll | 68 ++++---- llvm/unittests/SandboxIR/SandboxIRTest.cpp | 4 +- 38 files changed, 656 insertions(+), 715 deletions(-) diff --git a/llvm/docs/LangRef.rst b/llvm/docs/LangRef.rst index cec5516257c08..023a1f85c48be 100644 --- a/llvm/docs/LangRef.rst +++ b/llvm/docs/LangRef.rst @@ -5320,7 +5320,7 @@ equivalent to .. code-block:: llvm - %tmp = call i64 @llvm.ptrauth.sign(i64 ptrtoint (ptr CST to i64)) [ "ptrauth"(i64 KEY, i64 ptrtoint (ptr ADDRDISC to i64), i64 DISC) ] + %tmp = call i64 @llvm.ptrauth.sign(i64 ptrtoint (ptr CST to i64)) [ "ptrauth"(i64 KEY, i64 DISC, i64 ptrtoint (ptr ADDRDISC to i64)) ] %val = inttoptr i64 %tmp to ptr If the deactivation symbol operand ``DS`` has a non-null value, @@ -5330,6 +5330,11 @@ calls above, with ``DS`` as the only operand. .. _constantexprs: +That is, the first operand of '``ptrauth``' constant is the pointer to be +signed (the only argument of '``@llvm.ptrauth.sign``') and all the remaining +operands have the same interpretation as in ``"ptrauth"`` call operand bundle +(with trivial type conversion). + Constant Expressions -------------------- diff --git a/llvm/docs/PointerAuth.md b/llvm/docs/PointerAuth.md index ef13dbf5b6012..17c8d912bf125 100644 --- a/llvm/docs/PointerAuth.md +++ b/llvm/docs/PointerAuth.md @@ -303,18 +303,16 @@ support for instructions that manipulate Pointer Authentication Codes (PAC). Sign and auth operations are parameterized by a constant key identifier and a 64-bit discriminator value which is computed according to signing schema. -On AArch64, `ptrauth` bundle may have from one to three operands, the former -always being constant integer denoting the [key](#keys) identifier and the rest -operands describing the discriminator being used: +On AArch64, `ptrauth` bundle may have either one or three operands, depending +on the callee. The former operand is always a constant integer denoting the +[key identifier](#keys) and the rest operands describe the discriminator: * `"ptrauth"(i64 )`: the operation uses the key `` and the - discriminator is zero or not applicable. It is the only form accepted by - `@llvm.ptrauth.strip` intrinsic. -* `"ptrauth"(i64 , i64 raw_disc)`: the 64-bit discriminator value is - passed as-is, either constant or not. If constant value is passed, and it - fits in 16 bits, it is safely materialized right before its usage. -* `"ptrauth"(i64 , i64 %addr_modif, i64 )`: the discriminator + discriminator is not applicable. This form is used by `@llvm.ptrauth.strip` + intrinsic. +* `"ptrauth"(i64 , i64 , i64 %addr_modif)`: the discriminator to be used is computed by [blending](#blend-operation) an integer modifier - into an address modifier. + into an address modifier. `const_modif` must be unsigned 16-bit integer + constant and zero value means `addr_modif` is used without any blending. #### Keys diff --git a/llvm/include/llvm/CodeGen/GlobalISel/IRTranslator.h b/llvm/include/llvm/CodeGen/GlobalISel/IRTranslator.h index 9d6038db4391f..c55f50b06ea22 100644 --- a/llvm/include/llvm/CodeGen/GlobalISel/IRTranslator.h +++ b/llvm/include/llvm/CodeGen/GlobalISel/IRTranslator.h @@ -600,6 +600,9 @@ class IRTranslator : public MachineFunctionPass { Intrinsic::ID ID, MachineIRBuilder &MIRBuilder); + bool translatePtrAuthIntrinsic(const CallInst &CI, unsigned Opcode, + MachineIRBuilder &MIRBuilder); + /// @} // Builder for machine instruction a la IRBuilder. diff --git a/llvm/include/llvm/CodeGen/TargetLowering.h b/llvm/include/llvm/CodeGen/TargetLowering.h index 79c903e22f022..c28b20a2a0626 100644 --- a/llvm/include/llvm/CodeGen/TargetLowering.h +++ b/llvm/include/llvm/CodeGen/TargetLowering.h @@ -4612,11 +4612,24 @@ class LLVM_ABI TargetLowering : public TargetLoweringBase { /// Return true if the target supports ptrauth operand bundles. virtual bool supportPtrAuthBundles() const { return false; } - /// Normalize operands of "ptrauth" bundle. - virtual void normalizePtrAuthBundle(const CallBase &I, OperandBundleUse OB, - SmallVectorImpl &Output) const { - assert(OB.getTagID() == LLVMContext::OB_ptrauth); - Output.append(OB.Inputs.begin(), OB.Inputs.end()); + /// Perform target-specific validation of "ptrauth" call operand bundles that + /// is not covered by Verifier but relied upon by the backend. + virtual std::optional + validatePtrAuthBundles(const CallBase &CB) const { + return std::nullopt; + }; + + /// Convenience function to report fatal error if user-provided IR violates + /// the assumptions relied upon by the backend. + /// + /// This function is intended to handle possible invalid user input and thus + /// always performs the check, whether the assertions are enabled or not. + void reportFatalErrorOnInvalidPtrAuthBundles(const CallBase &CB) const { + if (auto Error = validatePtrAuthBundles(CB)) { + errs() << "Ptrauth bundle violates target-specific constraints:\n"; + CB.print(errs()); + reportFatalUsageError(("Invalid ptrauth bundle: " + *Error).c_str()); + } } /// Perform necessary initialization to handle a subset of CSRs explicitly diff --git a/llvm/include/llvm/IR/Constants.h b/llvm/include/llvm/IR/Constants.h index 0693a2a22d083..efdf856c5757f 100644 --- a/llvm/include/llvm/IR/Constants.h +++ b/llvm/include/llvm/IR/Constants.h @@ -1099,18 +1099,9 @@ class ConstantPtrAuth final : public Constant { /// Check whether an authentication operation with key \p Key and (possibly /// blended) discriminator \p Discriminator is known to be compatible with /// this ptrauth signed pointer. - LLVM_ABI bool isKnownCompatibleWith(const Value *Key, - const Value *Discriminator, - const DataLayout &DL) const; - - bool isKnownCompatibleWith(const Value *Key, - const Value *AddrDisc, - const Value *IntDisc, - const DataLayout &DL) const; + // FIXME: LLVM_ABI bool isKnownCompatibleWith(ArrayRef BundleOperands, const DataLayout &DL) const; - bool isKnownCompatibleWith(ArrayRef BundleOperands, - const DataLayout &DL) const; /// Methods for support type inquiry through isa, cast, and dyn_cast: static bool classof(const Value *V) { diff --git a/llvm/include/llvm/SandboxIR/Constant.h b/llvm/include/llvm/SandboxIR/Constant.h index 2fe923f6c3866..03b1fc7522bef 100644 --- a/llvm/include/llvm/SandboxIR/Constant.h +++ b/llvm/include/llvm/SandboxIR/Constant.h @@ -1398,10 +1398,13 @@ class ConstantPtrAuth final : public Constant { /// Check whether an authentication operation with key \p Key and (possibly /// blended) discriminator \p Discriminator is known to be compatible with /// this ptrauth signed pointer. - bool isKnownCompatibleWith(const Value *Key, const Value *Discriminator, + bool isKnownCompatibleWith(ArrayRef BundleOperands, const DataLayout &DL) const { + SmallVector Operands; + for (auto *V : BundleOperands) + Operands.push_back(V->Val); return cast(Val)->isKnownCompatibleWith( - Key->Val, Discriminator->Val, DL); + Operands, DL); } /// Produce a new ptrauth expression signing the given value using diff --git a/llvm/include/llvm/Target/GenericOpcodes.td b/llvm/include/llvm/Target/GenericOpcodes.td index 1d423faa2acd8..fcddc06b171e7 100644 --- a/llvm/include/llvm/Target/GenericOpcodes.td +++ b/llvm/include/llvm/Target/GenericOpcodes.td @@ -147,7 +147,10 @@ def G_PTRAUTH_BUNDLE : GenericInstruction { def G_PTRAUTH_AUTH : GenericInstruction { let OutOperandList = (outs type0:$dst); let InOperandList = (ins type0:$value, untyped_imm_0:$schema); - let hasSideEffects = 0; + // Authentication should not be speculated: moving G_PTRAUTH_AUTH above the + // point where it is known to succeed under correct program operation may + // lead to program crashes. + let hasSideEffects = 1; } def G_PTRAUTH_SIGN : GenericInstruction { @@ -159,7 +162,8 @@ def G_PTRAUTH_SIGN : GenericInstruction { def G_PTRAUTH_RESIGN : GenericInstruction { let OutOperandList = (outs type0:$dst); let InOperandList = (ins type0:$value, untyped_imm_0:$old_schema, untyped_imm_0:$new_schema); - let hasSideEffects = 0; + // Resign includes authentication and thus should not be speculated. + let hasSideEffects = 1; } def G_PTRAUTH_STRIP : GenericInstruction { diff --git a/llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp b/llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp index 5465535041fbb..555ceb62137ee 100644 --- a/llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp +++ b/llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp @@ -2188,85 +2188,69 @@ bool IRTranslator::translateConvergenceControlIntrinsic( return true; } -bool IRTranslator::translateKnownIntrinsic(const CallInst &CI, Intrinsic::ID ID, - MachineIRBuilder &MIRBuilder) { - if (auto *MI = dyn_cast(&CI)) { - if (ORE->enabled()) { - if (MemoryOpRemark::canHandle(MI, *LibInfo)) { - MemoryOpRemark R(*ORE, "gisel-irtranslator-memsize", *DL, *LibInfo); - R.visit(MI); - } - } - } - - // If this is a simple intrinsic (that is, we just need to add a def of - // a vreg, and uses for each arg operand, then translate it. - if (translateSimpleIntrinsic(CI, ID, MIRBuilder)) - return true; +bool IRTranslator::translatePtrAuthIntrinsic(const CallInst &CI, + unsigned Opcode, + MachineIRBuilder &MIRBuilder) { + TLI->reportFatalErrorOnInvalidPtrAuthBundles(CI); auto TranslatePtrAuthBundle = [&](unsigned Index) { auto Bundle = CI.getOperandBundleAt(Index); assert(Bundle.getTagID() == LLVMContext::OB_ptrauth); - SmallVector Operands; - TLI->normalizePtrAuthBundle(CI, Bundle, Operands); - Register Res = MRI->createGenericVirtualRegister(LLT::token()); auto Builder = MIRBuilder.buildInstr(TargetOpcode::G_PTRAUTH_BUNDLE); Builder.addDef(Res); - for (Value *Operand : Operands) + for (const Use &Operand : Bundle.Inputs) Builder.addUse(getOrCreateVReg(*Operand)); return Res; }; - auto SetDeactivationSymbol = [&](MachineInstrBuilder &MIB) { - if (auto Bundle = CI.getOperandBundle(LLVMContext::OB_deactivation_symbol)) - MIB->setDeactivationSymbol(*MF, Bundle->Inputs[0].get()); - }; + SmallVector SrcOps; + SrcOps.push_back(getOrCreateVReg(*CI.getArgOperand(0))); + SrcOps.push_back(TranslatePtrAuthBundle(0)); + if (Opcode == TargetOpcode::G_PTRAUTH_RESIGN) + SrcOps.push_back(TranslatePtrAuthBundle(1)); - switch (ID) { - default: - break; - case Intrinsic::ptrauth_auth: { - Register Dst = getOrCreateVReg(CI); - Register V = getOrCreateVReg(*CI.getArgOperand(0)); - Register Bundle = TranslatePtrAuthBundle(0); + Register Dst = getOrCreateVReg(CI); + auto MIB = MIRBuilder.buildInstr(Opcode, {Dst}, SrcOps); + if (auto Bundle = CI.getOperandBundle(LLVMContext::OB_deactivation_symbol)) + MIB->setDeactivationSymbol(*MF, Bundle->Inputs[0].get()); - MachineInstrBuilder MIB = MIRBuilder.buildInstr( - TargetOpcode::G_PTRAUTH_AUTH, {Dst}, {V, Bundle}); - SetDeactivationSymbol(MIB); - return true; - } - case Intrinsic::ptrauth_sign: { - Register Dst = getOrCreateVReg(CI); - Register V = getOrCreateVReg(*CI.getArgOperand(0)); - Register Bundle = TranslatePtrAuthBundle(0); + return true; +} - MachineInstrBuilder MIB = MIRBuilder.buildInstr( - TargetOpcode::G_PTRAUTH_SIGN, {Dst}, {V, Bundle}); - SetDeactivationSymbol(MIB); - return true; +bool IRTranslator::translateKnownIntrinsic(const CallInst &CI, Intrinsic::ID ID, + MachineIRBuilder &MIRBuilder) { + if (auto *MI = dyn_cast(&CI)) { + if (ORE->enabled()) { + if (MemoryOpRemark::canHandle(MI, *LibInfo)) { + MemoryOpRemark R(*ORE, "gisel-irtranslator-memsize", *DL, *LibInfo); + R.visit(MI); + } + } } - case Intrinsic::ptrauth_resign: { - Register Dst = getOrCreateVReg(CI); - Register V = getOrCreateVReg(*CI.getArgOperand(0)); - Register OldBundle = TranslatePtrAuthBundle(0); - Register NewBundle = TranslatePtrAuthBundle(1); - MachineInstrBuilder MIB = MIRBuilder.buildInstr( - TargetOpcode::G_PTRAUTH_RESIGN, {Dst}, {V, OldBundle, NewBundle}); - SetDeactivationSymbol(MIB); + // If this is a simple intrinsic (that is, we just need to add a def of + // a vreg, and uses for each arg operand, then translate it. + if (translateSimpleIntrinsic(CI, ID, MIRBuilder)) return true; - } - case Intrinsic::ptrauth_strip: { - Register Dst = getOrCreateVReg(CI); - Register V = getOrCreateVReg(*CI.getArgOperand(0)); - Register Bundle = TranslatePtrAuthBundle(0); - MIRBuilder.buildInstr(TargetOpcode::G_PTRAUTH_STRIP, {Dst}, {V, Bundle}); - return true; - } + switch (ID) { + default: + break; + case Intrinsic::ptrauth_auth: + return translatePtrAuthIntrinsic(CI, TargetOpcode::G_PTRAUTH_AUTH, + MIRBuilder); + case Intrinsic::ptrauth_sign: + return translatePtrAuthIntrinsic(CI, TargetOpcode::G_PTRAUTH_SIGN, + MIRBuilder); + case Intrinsic::ptrauth_resign: + return translatePtrAuthIntrinsic(CI, TargetOpcode::G_PTRAUTH_RESIGN, + MIRBuilder); + case Intrinsic::ptrauth_strip: + return translatePtrAuthIntrinsic(CI, TargetOpcode::G_PTRAUTH_STRIP, + MIRBuilder); case Intrinsic::lifetime_start: case Intrinsic::lifetime_end: { // No stack colouring in O0, discard region information. @@ -2811,10 +2795,13 @@ bool IRTranslator::translateCallBase(const CallBase &CB, // Functions should never be ptrauth-called directly. assert(!CB.getCalledFunction() && "invalid direct ptrauth call"); - assert(!isa(CB)); + assert(!isa(CB) && + "Should be handled by translateKnownIntrinsic"); + + TLI->reportFatalErrorOnInvalidPtrAuthBundles(CB); - SmallVector BundleOperands; - TLI->normalizePtrAuthBundle(CB, *Bundle, BundleOperands); + SmallVector BundleOperands(Bundle->Inputs.begin(), + Bundle->Inputs.end()); // Look through ptrauth constants to try to eliminate the matching bundle // and turn this into a direct call with no ptrauth. diff --git a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp index e7b1e00b92567..4aac021881f82 100644 --- a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp +++ b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp @@ -6543,76 +6543,69 @@ void SelectionDAGBuilder::visitVectorExtractLastActive(const CallInst &I, setValue(&I, Result); } -/// Lower the call to the specified intrinsic function. -void SelectionDAGBuilder::visitIntrinsicCall(const CallInst &I, - unsigned Intrinsic) { +void SelectionDAGBuilder::visitPtrAuthIntrinsic(const CallInst &I, + unsigned Opcode) { const TargetLowering &TLI = DAG.getTargetLoweringInfo(); - SDLoc sdl = getCurSDLoc(); - DebugLoc dl = getCurDebugLoc(); - SDValue Res; + SDLoc SDL = getCurSDLoc(); - SDNodeFlags Flags; - if (auto *FPOp = dyn_cast(&I)) - Flags.copyFMF(*FPOp); + TLI.reportFatalErrorOnInvalidPtrAuthBundles(I); auto CreatePtrAuthBundle = [&](unsigned Index) { auto Bundle = I.getOperandBundleAt(Index); assert(Bundle.getTagID() == LLVMContext::OB_ptrauth); - SmallVector Inputs; - TLI.normalizePtrAuthBundle(I, Bundle, Inputs); - SmallVector Ops; - for (Value *Operand : Inputs) + for (const Use &Operand : Bundle.Inputs) Ops.push_back(getValue(Operand)); return DAG.getNode(ISD::PtrAuthBundle, getCurSDLoc(), MVT::Other, Ops); }; - auto SetDeactivationSymbol = [&](SmallVectorImpl &Ops) { - auto Bundle = I.getOperandBundle(LLVMContext::OB_deactivation_symbol); - if (!Bundle) - return; + SmallVector Ops; + Ops.push_back(getValue(I.getArgOperand(0))); + Ops.push_back(CreatePtrAuthBundle(0)); + if (Opcode == ISD::PtrAuthResign) + Ops.push_back(CreatePtrAuthBundle(1)); + if (auto Bundle = I.getOperandBundle(LLVMContext::OB_deactivation_symbol)) { auto *Sym = Bundle->Inputs[0].get(); SDValue SDSym = getValue(Sym); SDSym = DAG.getDeactivationSymbol(cast(Sym)); Ops.push_back(SDSym); - }; + } + + setValue(&I, DAG.getNode(Opcode, SDL, MVT::i64, Ops)); +} + +/// Lower the call to the specified intrinsic function. +void SelectionDAGBuilder::visitIntrinsicCall(const CallInst &I, + unsigned Intrinsic) { + const TargetLowering &TLI = DAG.getTargetLoweringInfo(); + SDLoc sdl = getCurSDLoc(); + DebugLoc dl = getCurDebugLoc(); + SDValue Res; + + SDNodeFlags Flags; + if (auto *FPOp = dyn_cast(&I)) + Flags.copyFMF(*FPOp); switch (Intrinsic) { default: // By default, turn this into a target intrinsic node. visitTargetIntrinsic(I, Intrinsic); return; - case Intrinsic::ptrauth_auth: { - SmallVector Ops = {getValue(I.getArgOperand(0)), - CreatePtrAuthBundle(0)}; - SetDeactivationSymbol(Ops); - setValue(&I, DAG.getNode(ISD::PtrAuthAuth, sdl, MVT::i64, Ops)); + case Intrinsic::ptrauth_auth: + visitPtrAuthIntrinsic(I, ISD::PtrAuthAuth); return; - } - case Intrinsic::ptrauth_sign: { - SmallVector Ops = {getValue(I.getArgOperand(0)), - CreatePtrAuthBundle(0)}; - SetDeactivationSymbol(Ops); - setValue(&I, DAG.getNode(ISD::PtrAuthSign, sdl, MVT::i64, Ops)); + case Intrinsic::ptrauth_sign: + visitPtrAuthIntrinsic(I, ISD::PtrAuthSign); return; - } - case Intrinsic::ptrauth_resign: { - SmallVector Ops = {getValue(I.getArgOperand(0)), - CreatePtrAuthBundle(0), - CreatePtrAuthBundle(1)}; - SetDeactivationSymbol(Ops); - setValue(&I, DAG.getNode(ISD::PtrAuthResign, sdl, MVT::i64, Ops)); + case Intrinsic::ptrauth_resign: + visitPtrAuthIntrinsic(I, ISD::PtrAuthResign); return; - } - case Intrinsic::ptrauth_strip: { - setValue(&I, DAG.getNode(ISD::PtrAuthStrip, sdl, MVT::i64, - getValue(I.getArgOperand(0)), - CreatePtrAuthBundle(0))); + case Intrinsic::ptrauth_strip: + visitPtrAuthIntrinsic(I, ISD::PtrAuthStrip); return; - } case Intrinsic::vscale: { EVT VT = TLI.getValueType(DAG.getDataLayout(), I.getType()); setValue(&I, DAG.getVScale(sdl, VT, APInt(VT.getSizeInBits(), 1))); @@ -9824,10 +9817,12 @@ void SelectionDAGBuilder::LowerCallSiteWithPtrAuthBundle( auto PAB = CB.getOperandBundle("ptrauth"); const Value *CalleeV = CB.getCalledOperand(); - assert(!isa(CB)); + assert(!isa(CB) && "Should be handled by visitIntrinsicCall"); + + TLI.reportFatalErrorOnInvalidPtrAuthBundles(CB); + + SmallVector BundleOperands(PAB->Inputs.begin(), PAB->Inputs.end()); - SmallVector BundleOperands; - TLI.normalizePtrAuthBundle(CB, *PAB, BundleOperands); // Look through ptrauth constants to find the raw callee. // Do a direct unauthenticated call if we found it and everything matches. if (const auto *CalleeCPA = dyn_cast(CalleeV)) @@ -9841,8 +9836,8 @@ void SelectionDAGBuilder::LowerCallSiteWithPtrAuthBundle( // Otherwise, do an authenticated indirect call. TargetLowering::PtrAuthInfo PAI; - for (const Value *V : BundleOperands) - PAI.Operands.push_back(getValue(V)); + for (const Value *Operand : BundleOperands) + PAI.Operands.push_back(getValue(Operand)); LowerCallTo(CB, getValue(CalleeV), CB.isTailCall(), CB.isMustTailCall(), EHPadBB, &PAI); diff --git a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.h b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.h index d2f720df61e72..0b330b713eab3 100644 --- a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.h +++ b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.h @@ -649,6 +649,7 @@ class SelectionDAGBuilder { void visitTargetIntrinsic(const CallInst &I, unsigned Intrinsic); void visitConstrainedFPIntrinsic(const ConstrainedFPIntrinsic &FPI); void visitConvergenceControl(const CallInst &I, unsigned Intrinsic); + void visitPtrAuthIntrinsic(const CallInst &I, unsigned Opcode); void visitVectorHistogram(const CallInst &I, unsigned IntrinsicID); void visitVectorExtractLastActive(const CallInst &I, unsigned Intrinsic); void visitVPLoad(const VPIntrinsic &VPIntrin, EVT VT, diff --git a/llvm/lib/IR/AutoUpgrade.cpp b/llvm/lib/IR/AutoUpgrade.cpp index f36cff6f6c7aa..f12ad85e31dc8 100644 --- a/llvm/lib/IR/AutoUpgrade.cpp +++ b/llvm/lib/IR/AutoUpgrade.cpp @@ -4721,17 +4721,47 @@ static CallBase *setOperandBundles(CallBase *CI, ArrayRef OBs) return NewCI; } +// Create a new, generalized "ptrauth" bundle from an old, AArch64-specific one +// by converting "ptrauth"(i32 const_key, i64 disc) to either +// - "ptrauth"(i64 const_key, i64 int_disc, i64 0) , if possible or to +// - "ptrauth"(i64 const_key, i64 0, i64 addr_disc) otherwise +// +// Caller of this function is responsible for distinguishing between old-style +// AArch64 bundles (i32 key) and new-style non-AArch64 bundles that happen to +// have two operands (which must be all i64 in the new-style bundles). +// +// Note that this function never expands calls to @llvm.ptrauth.blend, which +// are handled by upgradePtrAuthBlend later. +static OperandBundleDef createUpgradedPtrAuthBundle(ConstantInt *Key, + Value *DiscOrNull) { + LLVMContext &Ctx = Key->getContext(); + Value *Zero = ConstantInt::get(Ctx, APInt::getZero(64)); + SmallVector Inputs; + + Inputs.push_back(ConstantInt::get(Ctx, Key->getValue().zext(64))); + + auto *IntDisc = dyn_cast_or_null(DiscOrNull); + if (IntDisc && isUInt<16>(IntDisc->getZExtValue())) + Inputs.append({IntDisc, Zero}); + else if (DiscOrNull) + Inputs.append({Zero, DiscOrNull}); + else + Inputs.append({Zero, Zero}); + + return OperandBundleDef("ptrauth", Inputs); +} + // Transitions a ptrauth intrinsic call site to a half-upgraded state: -// 1) call %0(a, b, c, d, e) -> call %0(a, 0, 0, 0, 0) [ "ptrauth"(b, c), -// "ptrauth"(d, e) ] -// 2) call %0(a, b, c) -> call %0(a, 0, 0) [ "ptrauth"(b, c) ] +// 1) call %0(a, b, c, d, e) -> call %0(a, 0, 0, 0, 0) [ "ptrauth"(...), +// "ptrauth"(...) ] +// 2) call %0(a, b, c) -> call %0(a, 0, 0) [ "ptrauth"(...) ] // 3) call %0(a, b) -> call %0(a, 0) [ "ptrauth"(b) ] // 4) any call site with operand bundles attached - kept intact // // Upgrading ptrauth intrinsics requires inspecting their discriminator // operand(s), which can be computed by a separate call to blend(). // -// Because @llvm.ptruath.blend intrinsic is removed by AutoUpgrader, the +// Because @llvm.ptrauth.blend intrinsic is removed by AutoUpgrader, the // original computation of the discriminator may be removed before regular // processing of its users occurs. For that reason, as soon as the particular // call to @llvm.ptrauth.blend() is processed, all its users must be ready to @@ -4747,12 +4777,6 @@ static CallBase *setOperandBundles(CallBase *CI, ArrayRef OBs) // // Note that the half-upgraded call formally uses the same called function // and the same function signature as the original one. -// -// FIXME Catch unsupported cases like this: -// -// %blend = call i64 @llvm.ptrauth.blend(...) -// %callee = load ptr, ptr fn_ptr -// call void %callee(i64 %some_arg, i32 %other_arg, i64 %blend) static CallBase *upgradeToPtrAuthBundles(CallBase *CI) { // Skip: intrinsic calls are never indirect. if (CI->isIndirectCall()) @@ -4761,22 +4785,21 @@ static CallBase *upgradeToPtrAuthBundles(CallBase *CI) { if (CI->getNumOperandBundles()) return CI; + LLVMContext &Ctx = CI->getContext(); + Value *Zero32 = ConstantInt::get(Ctx, APInt::getZero(32)); + Value *Zero64 = ConstantInt::get(Ctx, APInt::getZero(64)); SmallVector OBs; - auto TryUpgradingToConstantI64 = [](Value *V) -> Value * { - auto *Const = dyn_cast(V); - if (!Const || Const->getType()->isIntegerTy(64)) - return V; - return ConstantInt::get(V->getContext(), Const->getValue().zext(64)); - }; auto UpgradeToBundle = [&](unsigned KeyIndex, unsigned DiscIndex) { - Value *Key = CI->getArgOperand(KeyIndex); + ConstantInt *Key = dyn_cast(CI->getArgOperand(KeyIndex)); Value *Disc = CI->getArgOperand(DiscIndex); - Value *Inputs[] = {TryUpgradingToConstantI64(Key), Disc}; - OBs.emplace_back("ptrauth", Inputs); - CI->setArgOperand(KeyIndex, ConstantInt::get(Key->getType(), 0)); - CI->setArgOperand(DiscIndex, ConstantInt::get(Disc->getType(), 0)); + if (!Key) + reportFatalUsageError("Cannot upgrade: expected constant ptrauth key ID"); + OBs.emplace_back(createUpgradedPtrAuthBundle(Key, Disc)); + + CI->setArgOperand(KeyIndex, Zero32); + CI->setArgOperand(DiscIndex, Zero64); }; switch (CI->arg_size()) { @@ -4786,10 +4809,14 @@ static CallBase *upgradeToPtrAuthBundles(CallBase *CI) { return CI; case 2: { // strip(value, key) -> strip(value, 0) [ "ptrauth"(key) ] - Value *Key = CI->getArgOperand(1); - Value *Inputs[] = {TryUpgradingToConstantI64(Key)}; + ConstantInt *Key = dyn_cast(CI->getArgOperand(1)); + if (!Key) + reportFatalUsageError("Cannot upgrade: expected constant ptrauth key ID"); + + Value *Inputs = {ConstantInt::get(Ctx, Key->getValue().zext(64))}; OBs.emplace_back("ptrauth", Inputs); - CI->setArgOperand(1, ConstantInt::get(Key->getType(), 0)); + + CI->setArgOperand(1, Zero32); break; } case 3: @@ -4810,7 +4837,7 @@ static CallBase *upgradeToPtrAuthBundles(CallBase *CI) { return setOperandBundles(CI, OBs); } -// Fully process a call to @llvm.ptrauth.blend(), lazily updating its users +// Fully process a call to @llvm.ptrauth.blend(), lazily upgrading its users // to the extent that they are able to absorb the information from BlendCall. static void upgradePtrAuthBlend(CallBase *BlendCall) { // Collect all call instructions to be upgraded before performing any @@ -4820,11 +4847,16 @@ static void upgradePtrAuthBlend(CallBase *BlendCall) { if (auto *Call = dyn_cast(U)) UpgradableUsers.insert(Call); + if (BlendCall->arg_size() != 2) + reportFatalUsageError("@llvm.ptrauth.blend must have two arguments"); Value *AddrDisc = BlendCall->getArgOperand(0); Value *IntDisc = BlendCall->getArgOperand(1); for (CallBase *Call : UpgradableUsers) { - // Lazily migrate the user to "ptrauth" bundles first. + // If Call is an old-style @llvm.ptrauth.* intrinsic call, lazily migrate + // it to "ptrauth" bundles first. + // If Call is an authenticated indirect call, it is expected to have + // already been migrated to a three-operand form by this time. Call = upgradeToPtrAuthBundles(Call); SmallVector OBs; @@ -4834,15 +4866,18 @@ static void upgradePtrAuthBlend(CallBase *BlendCall) { // This may affect multiple bundles in case of resign() intrinsic which // only changes the key. for (unsigned I = 0, N = OBs.size(); I < N; ++I) { - auto OB = Call->getOperandBundleAt(I); - // Skip non-ptrauth bundles. - if (OB.getTagID() != LLVMContext::OB_ptrauth) + auto OB = OBs[I]; + // Skip any bundles that are not of the form + // "ptrauth"(i64 key, i64 0, i64 %this_blend_call) + if (OB.getTag() != "ptrauth" || OB.input_size() != 3 || + OB.inputs()[2] != BlendCall) continue; - // Skip bundles not in the form "ptrauth"(key, %this_blend_call). - if (OB.Inputs.size() != 2 || OB.Inputs[1] != BlendCall) + + ConstantInt *TempIntDisc = dyn_cast(OB.inputs()[1]); + if (!TempIntDisc || !TempIntDisc->isZero()) continue; - Value * NewBundleOperands[] = {OB.Inputs[0], AddrDisc, IntDisc}; + Value *NewBundleOperands[] = {OB.inputs()[0], IntDisc, AddrDisc}; OBs[I] = OperandBundleDef("ptrauth", NewBundleOperands); } @@ -4852,7 +4887,8 @@ static void upgradePtrAuthBlend(CallBase *BlendCall) { if (!BlendCall->users().empty()) { errs() << "Cannot upgrade all uses of @llvm.ptrauth.blend in function:\n"; BlendCall->getFunction()->print(errs()); - reportFatalUsageError("Cannot upgrade some uses of @llvm.ptrauth.blend()."); + reportFatalUsageError("Cannot upgrade some uses of " + "@llvm.ptrauth.blend()."); } } @@ -6616,15 +6652,23 @@ void llvm::UpgradeOperandBundles(std::vector &Bundles) { for (unsigned I = 0, N = Bundles.size(); I < N; ++I) { OperandBundleDef &OB = Bundles[I]; + + // Upgrade an old-style AArch64 "ptrauth"(i32 const_key, i64 disc) bundle + // either to + // - "ptrauth"(i64 const_key, i64 int_disc, i64 0), or to + // - "ptrauth"(i64 const_key, i64 0, i64 addr_disc) + // + // Note that this can be trivially distinguished from non-AArch64 bundles + // that could have two operands, as new-style bundles should never have i32 + // operands. if (OB.getTag() == "ptrauth" && OB.inputs().size() == 2) { - auto *Key = dyn_cast(OB.inputs()[0]); + ConstantInt *Key = dyn_cast(OB.inputs()[0]); + Value *Disc = OB.inputs()[1]; + if (!Key || !Key->getType()->isIntegerTy(32)) continue; - SmallVector Inputs(OB.inputs()); - Inputs[0] = ConstantInt::get(Key->getContext(), - Key->getValue().zext(64)); - Bundles[I] = OperandBundleDef("ptrauth", Inputs); + Bundles[I] = createUpgradedPtrAuthBundle(Key, Disc); } } } diff --git a/llvm/lib/IR/Constants.cpp b/llvm/lib/IR/Constants.cpp index d35479476d947..ca5f38548b73f 100644 --- a/llvm/lib/IR/Constants.cpp +++ b/llvm/lib/IR/Constants.cpp @@ -2155,86 +2155,45 @@ bool ConstantPtrAuth::hasSpecialAddressDiscriminator(uint64_t Value) const { return IntVal->getValue() == Value; } -// For now, this method is to be called for three-operand bundles only! -bool ConstantPtrAuth::isKnownCompatibleWith(const Value *Key, - const Value *AddrDiscriminator, - const Value *IntDisc, - const DataLayout &DL) const { - // If the keys are different, there's no chance for this to be compatible. - // FIXME: Should we enforce i64 everywhere? - if (getKey()->getZExtValue() != cast(Key)->getZExtValue()) - return false; - - if (getDiscriminator() != IntDisc) - return false; - - // Key and IntDisc are compatible, let's check AddrDiscriminator. - - // If neither this constant nor the requested schema has an address - // discriminator, we are done. - if (!hasAddressDiscriminator() && match(AddrDiscriminator, m_Zero())) - return true; - - // Discriminators are i64, so the provided addr disc may be a ptrtoint. - if (auto *Cast = dyn_cast(AddrDiscriminator)) - AddrDiscriminator = Cast->getPointerOperand(); - - // Beyond that, we're only interested in compatible pointers. - if (getAddrDiscriminator()->getType() != AddrDiscriminator->getType()) - return false; - - // These are often the same constant GEP, making them trivially equivalent. - if (getAddrDiscriminator() == AddrDiscriminator) - return true; - - // Finally, they may be equivalent base+offset expressions. - APInt Off1(DL.getIndexTypeSizeInBits(getAddrDiscriminator()->getType()), 0); - auto *Base1 = getAddrDiscriminator()->stripAndAccumulateConstantOffsets( - DL, Off1, /*AllowNonInbounds=*/true); - - APInt Off2(DL.getIndexTypeSizeInBits(AddrDiscriminator->getType()), 0); - auto *Base2 = AddrDiscriminator->stripAndAccumulateConstantOffsets( - DL, Off2, /*AllowNonInbounds=*/true); - - return Base1 == Base2 && Off1 == Off2; -} - -bool ConstantPtrAuth::isKnownCompatibleWith(const Value *Key, - const Value *Discriminator, +bool ConstantPtrAuth::isKnownCompatibleWith(ArrayRef BundleOperands, const DataLayout &DL) const { // This function may only be validly called to analyze a ptrauth operation // with no deactivation symbol, so if we have one it isn't compatible. if (!getDeactivationSymbol()->isNullValue()) return false; - // If the keys are different, there's no chance for this to be compatible. - // FIXME: Should we enforce i64 everywhere? - if (getKey()->getZExtValue() != cast(Key)->getZExtValue()) + // FIXME: Generalize ptrauth constants to arbitrary schemas instead of + // assuming AArch64-style blend. + if (BundleOperands.size() != 3) return false; - // We can have 3 kinds of discriminators: - // - simple, integer-only: `i64 x, ptr null` vs. `i64 x` - // - address-only: `i64 0, ptr p` vs. `ptr p` - // - blended address/integer: `i64 x, ptr p` vs. `@llvm.ptrauth.blend(p, x)` + ConstantInt *Key = dyn_cast(BundleOperands[0]); + Value *IntDisc = BundleOperands[1]; + Value *AddrDisc = BundleOperands[2]; + + // FIXME: Use i64 consistently. + if (!Key || Key->getZExtValue() != getKey()->getZExtValue()) + return false; - // If this constant has a simple discriminator (integer, no address), easy: - // it's compatible iff the provided full discriminator is also a simple - // discriminator, identical to our integer discriminator. - if (!hasAddressDiscriminator()) - return getDiscriminator() == Discriminator; + if (getDiscriminator() != IntDisc) + return false; // We can now focus on comparing the address discriminators. + if (isa(AddrDisc) && cast(AddrDisc)->isZero() && + getAddrDiscriminator()->isNullValue()) + return true; + // Discriminators are i64, so the provided addr disc may be a ptrtoint. - if (auto *Cast = dyn_cast(Discriminator)) - Discriminator = Cast->getPointerOperand(); + if (auto *Cast = dyn_cast(AddrDisc)) + AddrDisc = Cast->getPointerOperand(); // Beyond that, we're only interested in compatible pointers. - if (getAddrDiscriminator()->getType() != Discriminator->getType()) + if (getAddrDiscriminator()->getType() != AddrDisc->getType()) return false; // These are often the same constant GEP, making them trivially equivalent. - if (getAddrDiscriminator() == Discriminator) + if (getAddrDiscriminator() == AddrDisc) return true; // Finally, they may be equivalent base+offset expressions. @@ -2242,29 +2201,13 @@ bool ConstantPtrAuth::isKnownCompatibleWith(const Value *Key, auto *Base1 = getAddrDiscriminator()->stripAndAccumulateConstantOffsets( DL, Off1, /*AllowNonInbounds=*/true); - APInt Off2(DL.getIndexTypeSizeInBits(Discriminator->getType()), 0); - auto *Base2 = Discriminator->stripAndAccumulateConstantOffsets( + APInt Off2(DL.getIndexTypeSizeInBits(AddrDisc->getType()), 0); + auto *Base2 = AddrDisc->stripAndAccumulateConstantOffsets( DL, Off2, /*AllowNonInbounds=*/true); return Base1 == Base2 && Off1 == Off2; } -bool ConstantPtrAuth::isKnownCompatibleWith(ArrayRef BundleOperands, - const DataLayout &DL) const { - if (BundleOperands.size() == 3) - return isKnownCompatibleWith(BundleOperands[0], BundleOperands[1], - BundleOperands[2], DL); - if (BundleOperands.size() == 2) - return isKnownCompatibleWith(BundleOperands[0], BundleOperands[1], DL); - return false; -} - -bool ConstantPtrAuth::isKnownCompatibleWith(ArrayRef BundleOperands, - const DataLayout &DL) const { - SmallVector Ops(BundleOperands.begin(), BundleOperands.end()); - return isKnownCompatibleWith(Ops, DL); -} - //---- ConstantExpr::get() implementations. // diff --git a/llvm/lib/Target/AArch64/AArch64AsmPrinter.cpp b/llvm/lib/Target/AArch64/AArch64AsmPrinter.cpp index bcd2aae224502..af7fc75154b6c 100644 --- a/llvm/lib/Target/AArch64/AArch64AsmPrinter.cpp +++ b/llvm/lib/Target/AArch64/AArch64AsmPrinter.cpp @@ -2314,18 +2314,19 @@ void AArch64AsmPrinter::emitPtrauthBranch(const MachineInstr *MI) { bool IsZeroDisc = DiscReg == AArch64::XZR; if (Key == AArch64PACKey::DA || Key == AArch64PACKey::DB) { + emitMovXReg(AArch64::X16, BrTarget); // Have to emit separate auth and branch instructions for D-key. MCInst AUTInst; AUTInst.setOpcode(getAUTOpcodeForKey(Key, IsZeroDisc)); - AUTInst.addOperand(MCOperand::createReg(BrTarget)); - AUTInst.addOperand(MCOperand::createReg(BrTarget)); + AUTInst.addOperand(MCOperand::createReg(AArch64::X16)); + AUTInst.addOperand(MCOperand::createReg(AArch64::X16)); if (!IsZeroDisc) AUTInst.addOperand(MCOperand::createReg(DiscReg)); EmitToStreamer(AUTInst); MCInst BranchInst; BranchInst.setOpcode(IsCall ? AArch64::BLR : AArch64::BR); - BranchInst.addOperand(MCOperand::createReg(BrTarget)); + BranchInst.addOperand(MCOperand::createReg(AArch64::X16)); EmitToStreamer(BranchInst); return; } @@ -3280,7 +3281,17 @@ void AArch64AsmPrinter::emitInstruction(const MachineInstr *MI) { Register AddrDisc = MI->getOperand(4).getReg(); - Register ScratchReg = Callee == AArch64::X16 ? AArch64::X17 : AArch64::X16; + // AUTH_TCRETURN[_BTI] pseudos are permitted to clobber both X16 and X17. + // At the same time, depending on the instruction either Callee or AddrDisc + // may be passed in X16 or X17. It is okay to have ScratchDiscReg equal to + // DiscReg and and/or ScratchCalleeCopyReg equal to Callee, as long as + // Callee != ScratchDiscReg (since Callee is read after the discriminator + // computation writes its result). + // FIXME: Come up with a cleaner approach. + Register ScratchDiscReg = AArch64::X16; + Register ScratchCalleeCopyReg = AArch64::X17; + if (Callee == ScratchDiscReg) + std::swap(ScratchDiscReg, ScratchCalleeCopyReg); emitPtrauthTailCallHardening(MI); @@ -3294,24 +3305,27 @@ void AArch64AsmPrinter::emitInstruction(const MachineInstr *MI) { // restriction manually not to clobber an unexpected register. bool AddrDiscIsImplicitDef = AddrDisc == AArch64::X16 || AddrDisc == AArch64::X17; - Register DiscReg = emitPtrauthDiscriminator(Disc, AddrDisc, ScratchReg, + Register DiscReg = emitPtrauthDiscriminator(Disc, AddrDisc, ScratchDiscReg, AddrDiscIsImplicitDef); const bool IsZero = DiscReg == AArch64::XZR; if (Key == AArch64PACKey::DA || Key == AArch64PACKey::DB) { // Have to emit separate auth and branch instructions for D-key. + if (Callee != ScratchCalleeCopyReg) + emitMovXReg(ScratchCalleeCopyReg, Callee); + MCInst AUTInst; AUTInst.setOpcode(getAUTOpcodeForKey(Key, IsZero)); - AUTInst.addOperand(MCOperand::createReg(Callee)); - AUTInst.addOperand(MCOperand::createReg(Callee)); + AUTInst.addOperand(MCOperand::createReg(ScratchCalleeCopyReg)); + AUTInst.addOperand(MCOperand::createReg(ScratchCalleeCopyReg)); if (!IsZero) AUTInst.addOperand(MCOperand::createReg(DiscReg)); EmitToStreamer(AUTInst); MCInst BranchInst; BranchInst.setOpcode(AArch64::BR); - BranchInst.addOperand(MCOperand::createReg(Callee)); + BranchInst.addOperand(MCOperand::createReg(ScratchCalleeCopyReg)); EmitToStreamer(BranchInst); return; } diff --git a/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp b/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp index c93ab1cb80669..573b061be941e 100644 --- a/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp +++ b/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp @@ -29971,6 +29971,43 @@ bool AArch64TargetLowering::preferSelectsOverBooleanArithmetic(EVT VT) const { return !VT.isFixedLengthVector(); } +std::optional +AArch64TargetLowering::validatePtrAuthBundles(const CallBase &CB) const { + auto GetMsg = [&CB](StringRef Str) { + return (CB.getFunction()->getName() + ": " + Str).str(); + }; + + for (unsigned I = 0, N = CB.getNumOperandBundles(); I < N; ++I) { + OperandBundleUse OB = CB.getOperandBundleAt(I); + if (OB.getTagID() != LLVMContext::OB_ptrauth) + continue; + + unsigned NumOperands = OB.Inputs.size(); + if (CB.getIntrinsicID() == Intrinsic::ptrauth_strip) { + if (NumOperands != 1) + return GetMsg("Single-element ptrauth bundle expected"); + } else { + if (NumOperands != 3) + return GetMsg("Three-element ptrauth bundle expected"); + } + + // The first operand is always the key ID. + if (!isa(OB.Inputs[0])) + return GetMsg("Key must be constant in ptrauth bundle on AArch64"); + + // Done validating single-operand bundles. + if (NumOperands == 1) + continue; + + auto *IntDisc = dyn_cast(OB.Inputs[1]); + if (!IntDisc || !isUInt<16>(IntDisc->getZExtValue())) + return GetMsg("Constant modifier must be 16-bit unsigned constant in " + "ptrauth bundle on AArch64"); + } + + return std::nullopt; +} + MachineInstr * AArch64TargetLowering::EmitKCFICheck(MachineBasicBlock &MBB, MachineBasicBlock::instr_iterator &MBBI, @@ -30000,73 +30037,6 @@ AArch64TargetLowering::EmitKCFICheck(MachineBasicBlock &MBB, .getInstr(); } -// On AArch64, a normalized "ptrauth" bundle has the form: -// - "ptrauth"(i64 key) for a call to ptrauth_strip intrinsic -// - "ptrauth"(i64 key, i64 addr_disc, i64 int_disc) otherwise -// -// Note that on AArch64, PAuth-related pseudo instructions currently represent -// raw, pre-computed discriminator values as (addr_disc=value, int_disc=0). -void AArch64TargetLowering::normalizePtrAuthBundle( - const CallBase &I, OperandBundleUse OB, - SmallVectorImpl &Output) const { - LLVMContext &Ctx = I.getContext(); - assert(OB.getTagID() == LLVMContext::OB_ptrauth); - - // Validate target-specific assumptions at least once even in no-assertion - // builds, as the IR may be provided by the user. - auto Validate = [&I](bool Condition, StringRef Msg) { - if (Condition) - return; - StringRef FunctionName = I.getFunction()->getName(); - reportFatalUsageError(FunctionName + ": " + Msg); - }; - - unsigned NumOperands = OB.Inputs.size(); - Validate(1 <= NumOperands && NumOperands <= 3, - "ptrauth bundles must have from 1 to 3 operands on AArch64"); - - // The first operand is always the key ID. - Value *Key = OB.Inputs[0]; - Validate(isa(Key), - "Key must be constant in ptrauth bundle on AArch64"); - - // ptrauth_strip requires a single-operand bundle. - if (I.getIntrinsicID() == Intrinsic::ptrauth_strip) { - Validate(NumOperands == 1, - "@llvm.ptrauth.strip accepts 1-element ptrauth bundle on AArch64"); - Output.append({Key}); - return; - } - - // Otherwise we should normalize to a three-operand form. - - Value *Zero = ConstantInt::get(Ctx, APInt::getZero(64)); - auto IsValidIntDisc = [](Value *V) { - auto *IntDisc = dyn_cast(V); - return V && isUInt<16>(IntDisc->getZExtValue()); - }; - - if (NumOperands == 1) { - // "ptrauth"(key) -> "ptrauth"(key, 0, 0) - Output.append({Key, Zero, Zero}); - } else if (NumOperands == 2) { - // "ptrauth"(key, disc) -> "ptrauth"(key, 0, disc), if possible - // "ptrauth"(key, disc) -> "ptrauth"(key, disc, 0), otherwise - Value *Disc = OB.Inputs[1]; - if (IsValidIntDisc(Disc)) - Output.append({Key, /*addr_disc=*/Zero, /*int_disc=*/Disc}); - else - Output.append({Key, /*addr_disc=*/Disc, /*int_disc=*/Zero}); - } else { - // "ptrauth"(key, addr_disc, int_disc) - already normalized, just validate - Value *AddrDisc = OB.Inputs[1]; - Value *IntDisc = OB.Inputs[2]; - Validate(IsValidIntDisc(IntDisc), - "Constant modifier must be uint16 in ptrauth bundle on AArch64"); - Output.append({Key, AddrDisc, IntDisc}); - } -} - bool AArch64TargetLowering::enableAggressiveFMAFusion(EVT VT) const { return Subtarget->hasAggressiveFMA() && VT.isFloatingPoint(); } diff --git a/llvm/lib/Target/AArch64/AArch64ISelLowering.h b/llvm/lib/Target/AArch64/AArch64ISelLowering.h index 721007b00fc55..75a9a097b1c0f 100644 --- a/llvm/lib/Target/AArch64/AArch64ISelLowering.h +++ b/llvm/lib/Target/AArch64/AArch64ISelLowering.h @@ -474,8 +474,8 @@ class AArch64TargetLowering : public TargetLowering { bool supportPtrAuthBundles() const override { return true; } - void normalizePtrAuthBundle(const CallBase &I, OperandBundleUse OB, - SmallVectorImpl &Output) const override; + std::optional + validatePtrAuthBundles(const CallBase &CB) const override; bool supportKCFIBundles() const override { return true; } diff --git a/llvm/lib/Target/AArch64/AArch64InstrInfo.td b/llvm/lib/Target/AArch64/AArch64InstrInfo.td index 41d6ee7a5af70..cb48a47afefb1 100644 --- a/llvm/lib/Target/AArch64/AArch64InstrInfo.td +++ b/llvm/lib/Target/AArch64/AArch64InstrInfo.td @@ -2134,7 +2134,7 @@ let Predicates = [HasPAuth] in { let mayStore = 0; let mayLoad = 0; let isCall = 1; - let Size = 12; // 4 fixed + 8 variable, to compute discriminator. + let Size = 20; // See AUTH_TCRETURN. let Defs = [X16,X17,LR]; let Uses = [SP]; } @@ -2165,8 +2165,8 @@ let Predicates = [HasPAuth] in { let isTerminator = 1; let isBarrier = 1; let isIndirectBranch = 1; - let Size = 12; // 4 fixed + 8 variable, to compute discriminator. - let Defs = [X17]; + let Size = 20; // See AUTH_TCRETURN. + let Defs = [X16, X17]; } let isReturn = 1, isTerminator = 1, isBarrier = 1 in { @@ -2216,8 +2216,8 @@ let Predicates = [HasPAuth] in { [(set GPR64:$SignedVal, (ptrauth_sign GPR64:$Val, (ptrauth_bundle (i64 imm:$Key), - GPR64noip:$AddrDisc, - (i64 imm:$Disc))))], + (i64 imm:$Disc), + GPR64noip:$AddrDisc)))], "$SignedVal = $Val">, Sched<[WriteI, ReadI]> { let isCodeGenOnly = 1; let hasSideEffects = 0; @@ -2285,14 +2285,15 @@ let Predicates = [HasPAuth] in { let Size = 8; } - // Size 16: 4 fixed + 8 variable, to compute discriminator. + // Size 20: up to 8 to compute discriminator and up to 12 to MOV, AUTD(A|B) + // and branch. // The size returned by getInstSizeInBytes() is incremented according // to the variant of LR check. // As the check requires either x16 or x17 as a scratch register and // authenticated tail call instructions have two register operands, // make sure at least one register is usable as a scratch one - for that // purpose, use tcGPRnotx16x17 register class for one of the operands. - let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1, Size = 16, + let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1, Size = 20, Defs = [X16,X17], Uses = [SP] in { def AUTH_TCRETURN : Pseudo<(outs), (ins tcGPRnotx16x17:$dst, i32imm:$FPDiff, i64imm:$Key, diff --git a/llvm/lib/Target/AArch64/AArch64SelectionDAGInfo.cpp b/llvm/lib/Target/AArch64/AArch64SelectionDAGInfo.cpp index 51f68dfcae8f7..0916bf632f39e 100644 --- a/llvm/lib/Target/AArch64/AArch64SelectionDAGInfo.cpp +++ b/llvm/lib/Target/AArch64/AArch64SelectionDAGInfo.cpp @@ -348,15 +348,14 @@ AArch64SelectionDAGInfo::extractPtrauthBlendDiscriminators( ArrayRef Operands, const SDLoc &DL, SelectionDAG *DAG) const { using namespace SDPatternMatch; - // Should be handled by AArch64TargetLowering::normalizePtrAuthBundle. assert(Operands.size() == 3); auto *KeyN = cast(Operands[0]); - auto *ConstDiscN = cast(Operands[2]); + auto *ConstDiscN = cast(Operands[1]); - SDValue AddrDisc = Operands[1]; - if (sd_match(Operands[1], m_SpecificInt(0))) - AddrDisc = DAG->getRegister(AArch64::XZR, MVT::i64); + SDValue AddrDisc = Operands[2]; + if (sd_match(AddrDisc, m_SpecificInt(0))) + AddrDisc = DAG->getRegister(AArch64::NoRegister, MVT::i64); return std::make_tuple( DAG->getTargetConstant(KeyN->getZExtValue(), DL, MVT::i64), diff --git a/llvm/lib/Target/AArch64/GISel/AArch64GlobalISelUtils.cpp b/llvm/lib/Target/AArch64/GISel/AArch64GlobalISelUtils.cpp index 0c0be19314247..c42e141bd9a40 100644 --- a/llvm/lib/Target/AArch64/GISel/AArch64GlobalISelUtils.cpp +++ b/llvm/lib/Target/AArch64/GISel/AArch64GlobalISelUtils.cpp @@ -99,14 +99,13 @@ bool AArch64GISelUtils::tryEmitBZero(MachineInstr &MI, std::tuple AArch64GISelUtils::extractPtrauthBlendDiscriminators(SmallVector Operands, MachineRegisterInfo &MRI) { - // Should be handled by AArch64TargetLowering::normalizePtrAuthBundle. assert(Operands.size() == 3); uint64_t KeyVal = getIConstantVRegVal(Operands[0], MRI)->getZExtValue(); - uint64_t ConstDiscVal = getIConstantVRegVal(Operands[2], MRI)->getZExtValue(); + uint64_t ConstDiscVal = getIConstantVRegVal(Operands[1], MRI)->getZExtValue(); assert(isUInt<16>(ConstDiscVal)); - Register AddrDisc = Operands[1]; + Register AddrDisc = Operands[2]; std::optional AddrDiscVal = getIConstantVRegVal(AddrDisc, MRI); if (AddrDiscVal && AddrDiscVal->isZero()) AddrDisc = AArch64::NoRegister; diff --git a/llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp b/llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp index 41cd1b666f67d..d3c695b06efe3 100644 --- a/llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp +++ b/llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp @@ -1730,24 +1730,6 @@ foldIntrinsicUsingDistributiveLaws(IntrinsicInst *II, return NewBinop; } -static bool areCompatiblePtrAuthBundles(OperandBundleUse LHS, - OperandBundleUse RHS) { - if (LHS.Inputs.size() != RHS.Inputs.size()) - return false; - for (auto [A, B] : llvm::zip(LHS.Inputs, RHS.Inputs)) { - auto *ConstA = dyn_cast(A); - auto *ConstB = dyn_cast(B); - // This handles the same key ids being specified either as i32 or i64. - // FIXME: Should we simply enforce i64 everywhere? - if (ConstA && ConstB && ConstA->getZExtValue() == ConstB->getZExtValue()) - continue; - - if (A != B) - return false; - } - return true; -} - /// CallInst simplification. This mostly only handles folding of intrinsic /// instructions. For normal calls, it allows visitCallBase to do the heavy /// lifting. @@ -3118,10 +3100,10 @@ Instruction *InstCombinerImpl::visitCallInst(CallInst &CI) { BasePtr = CI->getArgOperand(0); if (CI->getIntrinsicID() == Intrinsic::ptrauth_sign) { - if (!areCompatiblePtrAuthBundles(ThisAutSchema, CI->getOperandBundleAt(0))) + if (ThisAutSchema.Inputs != CI->getOperandBundleAt(0).Inputs) break; } else if (CI->getIntrinsicID() == Intrinsic::ptrauth_resign) { - if (!areCompatiblePtrAuthBundles(ThisAutSchema, CI->getOperandBundleAt(1))) + if (ThisAutSchema.Inputs != CI->getOperandBundleAt(1).Inputs) break; NewAutSchema = CI->getOperandBundleAt(0); } else @@ -3130,23 +3112,26 @@ Instruction *InstCombinerImpl::visitCallInst(CallInst &CI) { // ptrauth constants are equivalent to a call to @llvm.ptrauth.sign for // our purposes, so check for that too. const auto *CPA = dyn_cast(PtrToInt->getOperand(0)); - if (!CPA || !CPA->isKnownCompatibleWith(ThisAutSchema.Inputs, DL)) + SmallVector Operands; + llvm::append_range(Operands, ThisAutSchema.Inputs); + if (!CPA || !CPA->isKnownCompatibleWith(Operands, DL)) break; if (NeedSign) { auto ThisSignSchema = II->getOperandBundleAt(1); // resign(ptrauth(p,ks,ds),ks,ds,kr,dr) -> ptrauth(p,kr,dr) - if (ThisSignSchema.Inputs.size() == 2 && - isa(ThisSignSchema.Inputs[1])) { - auto *SignKey = cast(ThisSignSchema.Inputs[0]); - auto *SignDisc = cast(ThisSignSchema.Inputs[1]); + if (ThisSignSchema.Inputs.size() == 3) { + auto *SignKey = dyn_cast(ThisSignSchema.Inputs[0]); + auto *SignIntDisc = dyn_cast(ThisSignSchema.Inputs[1]); auto *Null = ConstantPointerNull::get(Builder.getPtrTy()); - auto *NewCPA = ConstantPtrAuth::get(CPA->getPointer(), SignKey, - SignDisc, /*AddrDisc=*/Null, - /*DeactivationSymbol=*/Null); - replaceInstUsesWith( - *II, ConstantExpr::getPointerCast(NewCPA, II->getType())); - return eraseInstFromFunction(*II); + if (SignKey && SignIntDisc) { + auto *NewCPA = ConstantPtrAuth::get(CPA->getPointer(), SignKey, + SignIntDisc, /*AddrDisc=*/Null, + /*DeactivationSymbol=*/Null); + replaceInstUsesWith( + *II, ConstantExpr::getPointerCast(NewCPA, II->getType())); + return eraseInstFromFunction(*II); + } } } @@ -3172,21 +3157,10 @@ Instruction *InstCombinerImpl::visitCallInst(CallInst &CI) { } SmallVector OBs; - - if (NewAutSchema) { - SmallVector Ops; - for (auto &U : NewAutSchema->Inputs) - Ops.push_back(U); - OBs.emplace_back("ptrauth", Ops); - } - - if (NeedSign) { - SmallVector Ops; - for (auto &U : II->getOperandBundleAt(1).Inputs) - Ops.push_back(U); - OBs.emplace_back("ptrauth", Ops); - } - + if (NewAutSchema) + OBs.emplace_back(*NewAutSchema); + if (NeedSign) + OBs.emplace_back(II->getOperandBundleAt(1)); Function *NewFn = Intrinsic::getOrInsertDeclaration(II->getModule(), NewIntrin); @@ -4356,14 +4330,10 @@ Instruction *InstCombinerImpl::foldPtrAuthIntrinsicCallee(CallBase &Call) { // call(ptrauth.resign(p)), ["ptrauth"()] -> call p, ["ptrauth"()] // assuming the call bundle and the sign operands match. case Intrinsic::ptrauth_resign: { - if (!areCompatiblePtrAuthBundles(II->getOperandBundleAt(1), - *PtrAuthBundleOrNone)) + if (II->getOperandBundleAt(1).Inputs != PtrAuthBundleOrNone->Inputs) return nullptr; - SmallVector NewBundleOps; - for (auto &Op : II->getOperandBundleAt(0).Inputs) - NewBundleOps.push_back(Op); - NewBundles.emplace_back("ptrauth", NewBundleOps); + NewBundles.emplace_back(II->getOperandBundleAt(0)); NewCallee = II->getOperand(0); break; } @@ -4372,8 +4342,7 @@ Instruction *InstCombinerImpl::foldPtrAuthIntrinsicCallee(CallBase &Call) { // assuming the call bundle and the sign operands match. // Non-ptrauth indirect calls are undesirable, but so is ptrauth.sign. case Intrinsic::ptrauth_sign: { - if (!areCompatiblePtrAuthBundles(II->getOperandBundleAt(0), - *PtrAuthBundleOrNone)) + if (II->getOperandBundleAt(0).Inputs != PtrAuthBundleOrNone->Inputs) return nullptr; NewCallee = II->getOperand(0); break; @@ -4406,8 +4375,11 @@ Instruction *InstCombinerImpl::foldPtrAuthConstantCallee(CallBase &Call) { if (!PAB) return nullptr; + SmallVector Operands; + llvm::append_range(Operands, PAB->Inputs); + // If the bundle doesn't match, this is probably going to fail to auth. - if (!CPA->isKnownCompatibleWith(PAB->Inputs, DL)) + if (!CPA->isKnownCompatibleWith(Operands, DL)) return nullptr; // If the bundle matches the constant, proceed in making this a direct call. diff --git a/llvm/test/CodeGen/AArch64/deactivation-symbols.ll b/llvm/test/CodeGen/AArch64/deactivation-symbols.ll index 57e62e3ee4ad8..feac4379efed4 100644 --- a/llvm/test/CodeGen/AArch64/deactivation-symbols.ll +++ b/llvm/test/CodeGen/AArch64/deactivation-symbols.ll @@ -23,7 +23,7 @@ define i64 @pauth_sign_zero(i64 %p) { ; CHECK-NEXT: .reloc [[LABEL]], R_AARCH64_PATCHINST, ds ; O0-NEXT: pacia x0, x8 ; O2-NEXT: paciza x0 - %signed = call i64 @llvm.ptrauth.sign(i64 %p) [ "ptrauth"(i64 0, i64 0), "deactivation-symbol"(ptr @ds) ] + %signed = call i64 @llvm.ptrauth.sign(i64 %p) [ "ptrauth"(i64 0, i64 0, i64 0), "deactivation-symbol"(ptr @ds) ] ret i64 %signed } @@ -33,7 +33,7 @@ define i64 @pauth_sign_const(i64 %p) { ; CHECK-NEXT: [[LABEL:.L.*]]: ; CHECK-NEXT: .reloc [[LABEL]], R_AARCH64_PATCHINST, ds ; CHECK-NEXT: pacia x0, x16 - %signed = call i64 @llvm.ptrauth.sign(i64 %p) [ "ptrauth"(i64 0, i64 12345), "deactivation-symbol"(ptr @ds) ] + %signed = call i64 @llvm.ptrauth.sign(i64 %p) [ "ptrauth"(i64 0, i64 12345, i64 0), "deactivation-symbol"(ptr @ds) ] ret i64 %signed } @@ -42,7 +42,7 @@ define i64 @pauth_sign(i64 %p, i64 %d) { ; CHECK: [[LABEL:.L.*]]: ; CHECK-NEXT: .reloc [[LABEL]], R_AARCH64_PATCHINST, ds ; CHECK-NEXT: pacia x0, x1 - %signed = call i64 @llvm.ptrauth.sign(i64 %p) [ "ptrauth"(i64 0, i64 %d), "deactivation-symbol"(ptr @ds) ] + %signed = call i64 @llvm.ptrauth.sign(i64 %p) [ "ptrauth"(i64 0, i64 0, i64 %d), "deactivation-symbol"(ptr @ds) ] ret i64 %signed } @@ -51,7 +51,7 @@ define i64 @pauth_auth_zero(i64 %p) { ; CHECK: [[LABEL:.L.*]]: ; CHECK-NEXT: .reloc [[LABEL]], R_AARCH64_PATCHINST, ds ; CHECK-NEXT: autiza x0 - %authed = call i64 @llvm.ptrauth.auth(i64 %p) [ "ptrauth"(i64 0, i64 0), "deactivation-symbol"(ptr @ds) ] + %authed = call i64 @llvm.ptrauth.auth(i64 %p) [ "ptrauth"(i64 0, i64 0, i64 0), "deactivation-symbol"(ptr @ds) ] ret i64 %authed } @@ -61,7 +61,7 @@ define i64 @pauth_auth_const(i64 %p) { ; CHECK-NEXT: [[LABEL:.L.*]]: ; CHECK-NEXT: .reloc [[LABEL]], R_AARCH64_PATCHINST, ds ; CHECK-NEXT: autia x0, x8 - %authed = call i64 @llvm.ptrauth.auth(i64 %p) [ "ptrauth"(i64 0, i64 12345), "deactivation-symbol"(ptr @ds) ] + %authed = call i64 @llvm.ptrauth.auth(i64 %p) [ "ptrauth"(i64 0, i64 12345, i64 0), "deactivation-symbol"(ptr @ds) ] ret i64 %authed } @@ -70,6 +70,6 @@ define i64 @pauth_auth(i64 %p, i64 %d) { ; CHECK: [[LABEL:.L.*]]: ; CHECK-NEXT: .reloc [[LABEL]], R_AARCH64_PATCHINST, ds ; CHECK-NEXT: autia x0, x1 - %authed = call i64 @llvm.ptrauth.auth(i64 %p) [ "ptrauth"(i64 0, i64 %d), "deactivation-symbol"(ptr @ds) ] + %authed = call i64 @llvm.ptrauth.auth(i64 %p) [ "ptrauth"(i64 0, i64 0, i64 %d), "deactivation-symbol"(ptr @ds) ] ret i64 %authed } diff --git a/llvm/test/CodeGen/AArch64/ptrauth-bti-call.ll b/llvm/test/CodeGen/AArch64/ptrauth-bti-call.ll index 0e8f78d56d907..f556b399a7199 100644 --- a/llvm/test/CodeGen/AArch64/ptrauth-bti-call.ll +++ b/llvm/test/CodeGen/AArch64/ptrauth-bti-call.ll @@ -17,8 +17,8 @@ ; CHECK-NEXT: bti c ; CHECK-NEXT: mov x16, x0 ; CHECK-NEXT: braaz x16 -define i32 @test_tailcall_ia_0(i32 ()* %arg0) #0 { - %tmp0 = tail call i32 %arg0() [ "ptrauth"(i64 0, i64 0) ] +define i32 @test_tailcall_ia_0(ptr %arg0) #0 { + %tmp0 = tail call i32 %arg0() [ "ptrauth"(i64 0, i64 0, i64 0) ] ret i32 %tmp0 } @@ -26,8 +26,8 @@ define i32 @test_tailcall_ia_0(i32 ()* %arg0) #0 { ; CHECK-NEXT: bti c ; CHECK-NEXT: mov x16, x0 ; CHECK-NEXT: brabz x16 -define i32 @test_tailcall_ib_0(i32 ()* %arg0) #0 { - %tmp0 = tail call i32 %arg0() [ "ptrauth"(i64 1, i64 0) ] +define i32 @test_tailcall_ib_0(ptr %arg0) #0 { + %tmp0 = tail call i32 %arg0() [ "ptrauth"(i64 1, i64 0, i64 0) ] ret i32 %tmp0 } @@ -36,8 +36,8 @@ define i32 @test_tailcall_ib_0(i32 ()* %arg0) #0 { ; CHECK-NEXT: mov x16, x0 ; CHECK-NEXT: mov x17, #42 ; CHECK-NEXT: braa x16, x17 -define i32 @test_tailcall_ia_imm(i32 ()* %arg0) #0 { - %tmp0 = tail call i32 %arg0() [ "ptrauth"(i64 0, i64 42) ] +define i32 @test_tailcall_ia_imm(ptr %arg0) #0 { + %tmp0 = tail call i32 %arg0() [ "ptrauth"(i64 0, i64 42, i64 0) ] ret i32 %tmp0 } @@ -46,8 +46,8 @@ define i32 @test_tailcall_ia_imm(i32 ()* %arg0) #0 { ; CHECK-NEXT: mov x16, x0 ; CHECK-NEXT: mov x17, #42 ; CHECK-NEXT: brab x16, x17 -define i32 @test_tailcall_ib_imm(i32 ()* %arg0) #0 { - %tmp0 = tail call i32 %arg0() [ "ptrauth"(i64 1, i64 42) ] +define i32 @test_tailcall_ib_imm(ptr %arg0) #0 { + %tmp0 = tail call i32 %arg0() [ "ptrauth"(i64 1, i64 42, i64 0) ] ret i32 %tmp0 } @@ -60,9 +60,9 @@ define i32 @test_tailcall_ib_imm(i32 ()* %arg0) #0 { ; ELF-NEXT: ldr x1, [x1] ; ELF-NEXT: mov x16, x0 ; ELF-NEXT: braa x16, x1 -define i32 @test_tailcall_ia_var(i32 ()* %arg0, i64* %arg1) #0 { - %tmp0 = load i64, i64* %arg1 - %tmp1 = tail call i32 %arg0() [ "ptrauth"(i64 0, i64 %tmp0) ] +define i32 @test_tailcall_ia_var(ptr %arg0, ptr %arg1) #0 { + %tmp0 = load i64, ptr %arg1 + %tmp1 = tail call i32 %arg0() [ "ptrauth"(i64 0, i64 0, i64 %tmp0) ] ret i32 %tmp1 } @@ -75,9 +75,9 @@ define i32 @test_tailcall_ia_var(i32 ()* %arg0, i64* %arg1) #0 { ; ELF-NEXT: ldr x1, [x1] ; ELF-NEXT: mov x16, x0 ; ELF-NEXT: brab x16, x1 -define i32 @test_tailcall_ib_var(i32 ()* %arg0, i64* %arg1) #0 { - %tmp0 = load i64, i64* %arg1 - %tmp1 = tail call i32 %arg0() [ "ptrauth"(i64 1, i64 %tmp0) ] +define i32 @test_tailcall_ib_var(ptr %arg0, ptr %arg1) #0 { + %tmp0 = load i64, ptr %arg1 + %tmp1 = tail call i32 %arg0() [ "ptrauth"(i64 1, i64 0, i64 %tmp0) ] ret i32 %tmp1 } @@ -85,8 +85,8 @@ define i32 @test_tailcall_ib_var(i32 ()* %arg0, i64* %arg1) #0 { ; CHECK-NEXT: bti c ; CHECK-NEXT: mov x16, x0 ; CHECK-NEXT: braa x16, x1 -define i32 @test_tailcall_ia_arg(i32 ()* %arg0, i64 %arg1) #0 { - %tmp0 = tail call i32 %arg0() [ "ptrauth"(i64 0, i64 %arg1) ] +define i32 @test_tailcall_ia_arg(ptr %arg0, i64 %arg1) #0 { + %tmp0 = tail call i32 %arg0() [ "ptrauth"(i64 0, i64 0, i64 %arg1) ] ret i32 %tmp0 } @@ -94,8 +94,8 @@ define i32 @test_tailcall_ia_arg(i32 ()* %arg0, i64 %arg1) #0 { ; CHECK-NEXT: bti c ; CHECK-NEXT: mov x16, x0 ; CHECK-NEXT: brab x16, x1 -define i32 @test_tailcall_ib_arg(i32 ()* %arg0, i64 %arg1) #0 { - %tmp0 = tail call i32 %arg0() [ "ptrauth"(i64 1, i64 %arg1) ] +define i32 @test_tailcall_ib_arg(ptr %arg0, i64 %arg1) #0 { + %tmp0 = tail call i32 %arg0() [ "ptrauth"(i64 1, i64 0, i64 %arg1) ] ret i32 %tmp0 } @@ -103,9 +103,9 @@ define i32 @test_tailcall_ib_arg(i32 ()* %arg0, i64 %arg1) #0 { ; CHECK-NEXT: bti c ; CHECK-NEXT: ldr x16, [x0] ; CHECK-NEXT: braa x16, x1 -define i32 @test_tailcall_ia_arg_ind(i32 ()** %arg0, i64 %arg1) #0 { - %tmp0 = load i32 ()*, i32 ()** %arg0 - %tmp1 = tail call i32 %tmp0() [ "ptrauth"(i64 0, i64 %arg1) ] +define i32 @test_tailcall_ia_arg_ind(ptr %arg0, i64 %arg1) #0 { + %tmp0 = load ptr, ptr %arg0 + %tmp1 = tail call i32 %tmp0() [ "ptrauth"(i64 0, i64 0, i64 %arg1) ] ret i32 %tmp1 } @@ -113,9 +113,9 @@ define i32 @test_tailcall_ia_arg_ind(i32 ()** %arg0, i64 %arg1) #0 { ; CHECK-NEXT: bti c ; CHECK-NEXT: ldr x16, [x0] ; CHECK-NEXT: brab x16, x1 -define i32 @test_tailcall_ib_arg_ind(i32 ()** %arg0, i64 %arg1) #0 { - %tmp0 = load i32 ()*, i32 ()** %arg0 - %tmp1 = tail call i32 %tmp0() [ "ptrauth"(i64 1, i64 %arg1) ] +define i32 @test_tailcall_ib_arg_ind(ptr %arg0, i64 %arg1) #0 { + %tmp0 = load ptr, ptr %arg0 + %tmp1 = tail call i32 %tmp0() [ "ptrauth"(i64 1, i64 0, i64 %arg1) ] ret i32 %tmp1 } diff --git a/llvm/test/CodeGen/AArch64/ptrauth-call-rv-marker.ll b/llvm/test/CodeGen/AArch64/ptrauth-call-rv-marker.ll index dcc624eb1b084..7d008552e4a93 100644 --- a/llvm/test/CodeGen/AArch64/ptrauth-call-rv-marker.ll +++ b/llvm/test/CodeGen/AArch64/ptrauth-call-rv-marker.ll @@ -4,18 +4,18 @@ target datalayout = "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128" target triple = "arm64e-apple-iphoneos" -declare i8* @foo0(i32) -declare i8* @foo1() +declare ptr @foo0(i32) +declare ptr @foo1() -declare void @llvm.objc.release(i8*) -declare i8* @llvm.objc.retainAutoreleasedReturnValue(i8*) -declare i8* @llvm.objc.unsafeClaimAutoreleasedReturnValue(i8*) +declare void @llvm.objc.release(ptr) +declare ptr @llvm.objc.retainAutoreleasedReturnValue(ptr) +declare ptr @llvm.objc.unsafeClaimAutoreleasedReturnValue(ptr) -declare void @foo2(i8*) +declare void @foo2(ptr) declare void @foo(i64, i64, i64) -define void @rv_marker_ptrauth_blraa(i8* ()** %arg0, i64 %arg1) { +define void @rv_marker_ptrauth_blraa(ptr %arg0, i64 %arg1) { ; CHECK-LABEL: rv_marker_ptrauth_blraa ; CHECK: ldr [[ADDR:x[0-9]+]], [ ; CHECK-NEXT: blraa [[ADDR]], x1 @@ -23,14 +23,14 @@ define void @rv_marker_ptrauth_blraa(i8* ()** %arg0, i64 %arg1) { ; CHECK-NEXT: bl objc_retainAutoreleasedReturnValue ; entry: - %tmp0 = load i8* ()*, i8* ()** %arg0 - %call0 = call i8* %tmp0() [ "ptrauth"(i64 0, i64 %arg1), "clang.arc.attachedcall"(i8* (i8*)* @llvm.objc.retainAutoreleasedReturnValue) ] - tail call void @foo2(i8* %call0) - tail call void @llvm.objc.release(i8* %call0) + %tmp0 = load ptr, ptr %arg0 + %call0 = call ptr %tmp0() [ "ptrauth"(i64 0, i64 0, i64 %arg1), "clang.arc.attachedcall"(ptr @llvm.objc.retainAutoreleasedReturnValue) ] + tail call void @foo2(ptr %call0) + tail call void @llvm.objc.release(ptr %call0) ret void } -define void @rv_marker_ptrauth_blraa_unsafeClaim(i8* ()** %arg0, i64 %arg1) { +define void @rv_marker_ptrauth_blraa_unsafeClaim(ptr %arg0, i64 %arg1) { ; CHECK-LABEL: rv_marker_ptrauth_blraa_unsafeClaim ; CHECK: ldr [[ADDR:x[0-9]+]], [ ; CHECK-NEXT: blraa [[ADDR]], x1 @@ -38,14 +38,14 @@ define void @rv_marker_ptrauth_blraa_unsafeClaim(i8* ()** %arg0, i64 %arg1) { ; CHECK-NEXT: bl objc_unsafeClaimAutoreleasedReturnValue ; entry: - %tmp0 = load i8* ()*, i8* ()** %arg0 - %call0 = call i8* %tmp0() [ "ptrauth"(i64 0, i64 %arg1), "clang.arc.attachedcall"(i8* (i8*)* @llvm.objc.unsafeClaimAutoreleasedReturnValue) ] - tail call void @foo2(i8* %call0) - tail call void @llvm.objc.release(i8* %call0) + %tmp0 = load ptr, ptr %arg0 + %call0 = call ptr %tmp0() [ "ptrauth"(i64 0, i64 0, i64 %arg1), "clang.arc.attachedcall"(ptr @llvm.objc.unsafeClaimAutoreleasedReturnValue) ] + tail call void @foo2(ptr %call0) + tail call void @llvm.objc.release(ptr %call0) ret void } -define void @rv_marker_ptrauth_blraa_disc_imm16(i8* ()** %arg0) { +define void @rv_marker_ptrauth_blraa_disc_imm16(ptr %arg0) { ; CHECK-LABEL: rv_marker_ptrauth_blraa_disc_imm16 ; CHECK: ldr [[ADDR:x[0-9]+]], [ ; CHECK-NEXT: mov x17, #45431 @@ -53,14 +53,14 @@ define void @rv_marker_ptrauth_blraa_disc_imm16(i8* ()** %arg0) { ; CHECK-NEXT: mov x29, x29 ; CHECK-NEXT: bl objc_retainAutoreleasedReturnValue ; - %tmp0 = load i8* ()*, i8* ()** %arg0 - %call0 = call i8* %tmp0() [ "ptrauth"(i64 1, i64 45431), "clang.arc.attachedcall"(i8* (i8*)* @llvm.objc.retainAutoreleasedReturnValue) ] - tail call void @foo2(i8* %call0) - tail call void @llvm.objc.release(i8* %call0) + %tmp0 = load ptr, ptr %arg0 + %call0 = call ptr %tmp0() [ "ptrauth"(i64 1, i64 45431, i64 0), "clang.arc.attachedcall"(ptr @llvm.objc.retainAutoreleasedReturnValue) ] + tail call void @foo2(ptr %call0) + tail call void @llvm.objc.release(ptr %call0) ret void } -define void @rv_marker_ptrauth_blraa_multiarg(i8* (i64, i64, i64)** %arg0, i64 %arg1, i64 %a, i64 %b, i64 %c) { +define void @rv_marker_ptrauth_blraa_multiarg(ptr %arg0, i64 %arg1, i64 %a, i64 %b, i64 %c) { ; CHECK-LABEL: rv_marker_ptrauth_blraa_multiarg ; CHECK: mov [[TMP:x[0-9]+]], x1 ; CHECK-DAG: ldr [[ADDR:x[0-9]+]] @@ -71,28 +71,28 @@ define void @rv_marker_ptrauth_blraa_multiarg(i8* (i64, i64, i64)** %arg0, i64 % ; CHECK-NEXT: bl objc_retainAutoreleasedReturnValue ; entry: - %tmp0 = load i8* (i64, i64, i64)*, i8* (i64, i64, i64)** %arg0 - %call0 = call i8* %tmp0(i64 %c, i64 %b, i64 %a) [ "ptrauth"(i64 0, i64 %arg1), "clang.arc.attachedcall"(i8* (i8*)* @llvm.objc.retainAutoreleasedReturnValue) ] - tail call void @foo2(i8* %call0) - tail call void @llvm.objc.release(i8* %call0) + %tmp0 = load ptr, ptr %arg0 + %call0 = call ptr %tmp0(i64 %c, i64 %b, i64 %a) [ "ptrauth"(i64 0, i64 0, i64 %arg1), "clang.arc.attachedcall"(ptr @llvm.objc.retainAutoreleasedReturnValue) ] + tail call void @foo2(ptr %call0) + tail call void @llvm.objc.release(ptr %call0) ret void } -define void @rv_marker_ptrauth_blrab(i8* ()** %arg0, i64 %arg1) { +define void @rv_marker_ptrauth_blrab(ptr %arg0, i64 %arg1) { ; CHECK-LABEL: rv_marker_ptrauth_blrab ; CHECK: ldr [[ADDR:x[0-9]+]], [ ; CHECK-NEXT: blrab [[ADDR]], x1 ; CHECK-NEXT: mov x29, x29 ; CHECK-NEXT: bl objc_retainAutoreleasedReturnValue ; - %tmp0 = load i8* ()*, i8* ()** %arg0 - %call0 = call i8* %tmp0() [ "ptrauth"(i64 1, i64 %arg1), "clang.arc.attachedcall"(i8* (i8*)* @llvm.objc.retainAutoreleasedReturnValue) ] - tail call void @foo2(i8* %call0) - tail call void @llvm.objc.release(i8* %call0) + %tmp0 = load ptr, ptr %arg0 + %call0 = call ptr %tmp0() [ "ptrauth"(i64 1, i64 0, i64 %arg1), "clang.arc.attachedcall"(ptr @llvm.objc.retainAutoreleasedReturnValue) ] + tail call void @foo2(ptr %call0) + tail call void @llvm.objc.release(ptr %call0) ret void } -define void @rv_marker_ptrauth_blrab_disc_imm16(i8* ()** %arg0) { +define void @rv_marker_ptrauth_blrab_disc_imm16(ptr %arg0) { ; CHECK-LABEL: rv_marker_ptrauth_blrab_disc_imm16 ; CHECK: ldr [[ADDR:x[0-9]+]], [ ; CHECK-NEXT: mov x17, #256 @@ -100,42 +100,42 @@ define void @rv_marker_ptrauth_blrab_disc_imm16(i8* ()** %arg0) { ; CHECK-NEXT: mov x29, x29 ; CHECK-NEXT: bl objc_retainAutoreleasedReturnValue ; - %tmp0 = load i8* ()*, i8* ()** %arg0 - %call0 = call i8* %tmp0() [ "ptrauth"(i64 1, i64 256), "clang.arc.attachedcall"(i8* (i8*)* @llvm.objc.retainAutoreleasedReturnValue) ] - tail call void @foo2(i8* %call0) - tail call void @llvm.objc.release(i8* %call0) + %tmp0 = load ptr, ptr %arg0 + %call0 = call ptr %tmp0() [ "ptrauth"(i64 1, i64 256, i64 0), "clang.arc.attachedcall"(ptr @llvm.objc.retainAutoreleasedReturnValue) ] + tail call void @foo2(ptr %call0) + tail call void @llvm.objc.release(ptr %call0) ret void } -define void @rv_marker_ptrauth_blraaz(i8* ()** %arg0) { +define void @rv_marker_ptrauth_blraaz(ptr %arg0) { ; CHECK-LABEL: rv_marker_ptrauth_blraaz ; CHECK: ldr [[ADDR:x[0-9]+]], [ ; CHECK-NEXT: blraaz [[ADDR]] ; CHECK-NEXT: mov x29, x29 ; CHECK-NEXT: bl objc_retainAutoreleasedReturnValue ; - %tmp0 = load i8* ()*, i8* ()** %arg0 - %call0 = call i8* %tmp0() [ "ptrauth"(i64 0, i64 0), "clang.arc.attachedcall"(i8* (i8*)* @llvm.objc.retainAutoreleasedReturnValue) ] - tail call void @foo2(i8* %call0) - tail call void @llvm.objc.release(i8* %call0) + %tmp0 = load ptr, ptr %arg0 + %call0 = call ptr %tmp0() [ "ptrauth"(i64 0, i64 0, i64 0), "clang.arc.attachedcall"(ptr @llvm.objc.retainAutoreleasedReturnValue) ] + tail call void @foo2(ptr %call0) + tail call void @llvm.objc.release(ptr %call0) ret void } -define void @rv_marker_ptrauth_blrabz(i8* ()** %arg0) { +define void @rv_marker_ptrauth_blrabz(ptr %arg0) { ; CHECK-LABEL: rv_marker_ptrauth_blrabz ; CHECK: ldr [[ADDR:x[0-9]+]], [ ; CHECK-NEXT: blrabz [[ADDR]] ; CHECK-NEXT: mov x29, x29 ; CHECK-NEXT: bl objc_retainAutoreleasedReturnValue ; - %tmp0 = load i8* ()*, i8* ()** %arg0 - %call0 = call i8* %tmp0() [ "ptrauth"(i64 1, i64 0), "clang.arc.attachedcall"(i8* (i8*)* @llvm.objc.retainAutoreleasedReturnValue) ] - tail call void @foo2(i8* %call0) - tail call void @llvm.objc.release(i8* %call0) + %tmp0 = load ptr, ptr %arg0 + %call0 = call ptr %tmp0() [ "ptrauth"(i64 1, i64 0, i64 0), "clang.arc.attachedcall"(ptr @llvm.objc.retainAutoreleasedReturnValue) ] + tail call void @foo2(ptr %call0) + tail call void @llvm.objc.release(ptr %call0) ret void } -define void @rv_marker_ptrauth_blrabz_multiarg(i8* (i64, i64, i64)** %arg0, i64 %a, i64 %b, i64 %c) { +define void @rv_marker_ptrauth_blrabz_multiarg(ptr %arg0, i64 %a, i64 %b, i64 %c) { ; CHECK-LABEL: rv_marker_ptrauth_blrabz_multiarg ; CHECK: mov [[TMP:x[0-9]+]], x1 ; CHECK-DAG: ldr [[ADDR:x[0-9]+]], [ @@ -146,9 +146,9 @@ define void @rv_marker_ptrauth_blrabz_multiarg(i8* (i64, i64, i64)** %arg0, i64 ; CHECK-NEXT: mov x29, x29 ; CHECK-NEXT: bl objc_retainAutoreleasedReturnValue ; - %tmp0 = load i8* (i64, i64, i64)*, i8* (i64, i64, i64)** %arg0 - %call0 = call i8* %tmp0(i64 %c, i64 %b, i64 %a) [ "ptrauth"(i64 1, i64 0), "clang.arc.attachedcall"(i8* (i8*)* @llvm.objc.retainAutoreleasedReturnValue) ] - tail call void @foo2(i8* %call0) - tail call void @llvm.objc.release(i8* %call0) + %tmp0 = load ptr, ptr %arg0 + %call0 = call ptr %tmp0(i64 %c, i64 %b, i64 %a) [ "ptrauth"(i64 1, i64 0, i64 0), "clang.arc.attachedcall"(ptr @llvm.objc.retainAutoreleasedReturnValue) ] + tail call void @foo2(ptr %call0) + tail call void @llvm.objc.release(ptr %call0) ret void } diff --git a/llvm/test/CodeGen/AArch64/ptrauth-call-upgrade.ll b/llvm/test/CodeGen/AArch64/ptrauth-call-upgrade.ll index 7d208d172bfea..10e480369c2e0 100644 --- a/llvm/test/CodeGen/AArch64/ptrauth-call-upgrade.ll +++ b/llvm/test/CodeGen/AArch64/ptrauth-call-upgrade.ll @@ -3,8 +3,8 @@ define void @test_call_imm_disc(ptr %fn) { ; CHECK-LABEL: @test_call_imm_disc( -; CHECK-NEXT: call void [[FN:%.*]]() [ "ptrauth"(i64 1, i64 0) ] -; CHECK-NEXT: call void [[FN]]() [ "ptrauth"(i64 1, i64 42) ] +; CHECK-NEXT: call void [[FN:%.*]]() [ "ptrauth"(i64 1, i64 0, i64 0) ] +; CHECK-NEXT: call void [[FN]]() [ "ptrauth"(i64 1, i64 42, i64 0) ] ; CHECK-NEXT: ret void ; call void %fn() [ "ptrauth"(i32 1, i64 0) ] @@ -14,7 +14,7 @@ define void @test_call_imm_disc(ptr %fn) { define void @test_call_addr_disc(ptr %fn, i64 %addr) { ; CHECK-LABEL: @test_call_addr_disc( -; CHECK-NEXT: call void [[FN:%.*]]() [ "ptrauth"(i64 1, i64 [[ADDR:%.*]]) ] +; CHECK-NEXT: call void [[FN:%.*]]() [ "ptrauth"(i64 1, i64 0, i64 [[ADDR:%.*]]) ] ; CHECK-NEXT: ret void ; call void %fn() [ "ptrauth"(i32 1, i64 %addr) ] @@ -23,7 +23,7 @@ define void @test_call_addr_disc(ptr %fn, i64 %addr) { define void @test_call_blended_disc(ptr %fn, i64 %addr) { ; CHECK-LABEL: @test_call_blended_disc( -; CHECK-NEXT: call void [[FN:%.*]]() [ "ptrauth"(i64 1, i64 [[ADDR:%.*]], i64 42) ] +; CHECK-NEXT: call void [[FN:%.*]]() [ "ptrauth"(i64 1, i64 42, i64 [[ADDR:%.*]]) ] ; CHECK-NEXT: ret void ; %disc = call i64 @llvm.ptrauth.blend(i64 %addr, i64 42) diff --git a/llvm/test/CodeGen/AArch64/ptrauth-call.ll b/llvm/test/CodeGen/AArch64/ptrauth-call.ll index e91de2d2643ad..98fd013642cc9 100644 --- a/llvm/test/CodeGen/AArch64/ptrauth-call.ll +++ b/llvm/test/CodeGen/AArch64/ptrauth-call.ll @@ -25,7 +25,7 @@ define i32 @test_call_ia_0(ptr %arg0) #0 { ; ELF-NEXT: blraaz x0 ; ELF-NEXT: ldr x30, [sp], #16 ; ELF-NEXT: ret - %tmp0 = call i32 %arg0() [ "ptrauth"(i64 0, i64 0) ] + %tmp0 = call i32 %arg0() [ "ptrauth"(i64 0, i64 0, i64 0) ] ret i32 %tmp0 } @@ -41,21 +41,21 @@ define i32 @test_call_ib_0(ptr %arg0) #0 { ; ELF-NEXT: blrabz x0 ; ELF-NEXT: ldr x30, [sp], #16 ; ELF-NEXT: ret - %tmp0 = call i32 %arg0() [ "ptrauth"(i64 1, i64 0) ] + %tmp0 = call i32 %arg0() [ "ptrauth"(i64 1, i64 0, i64 0) ] ret i32 %tmp0 } define i32 @test_tailcall_ia_0(ptr %arg0) #0 { ; CHECK-LABEL: test_tailcall_ia_0: ; CHECK-NEXT: braaz x0 - %tmp0 = tail call i32 %arg0() [ "ptrauth"(i64 0, i64 0) ] + %tmp0 = tail call i32 %arg0() [ "ptrauth"(i64 0, i64 0, i64 0) ] ret i32 %tmp0 } define i32 @test_tailcall_ib_0(ptr %arg0) #0 { ; CHECK-LABEL: test_tailcall_ib_0: ; CHECK-NEXT: brabz x0 - %tmp0 = tail call i32 %arg0() [ "ptrauth"(i64 1, i64 0) ] + %tmp0 = tail call i32 %arg0() [ "ptrauth"(i64 1, i64 0, i64 0) ] ret i32 %tmp0 } @@ -73,7 +73,7 @@ define i32 @test_call_ia_imm(ptr %arg0) #0 { ; ELF-NEXT: blraa x0, x17 ; ELF-NEXT: ldr x30, [sp], #16 ; ELF-NEXT: ret - %tmp0 = call i32 %arg0() [ "ptrauth"(i64 0, i64 42) ] + %tmp0 = call i32 %arg0() [ "ptrauth"(i64 0, i64 42, i64 0) ] ret i32 %tmp0 } @@ -91,7 +91,7 @@ define i32 @test_call_ib_imm(ptr %arg0) #0 { ; ELF-NEXT: blrab x0, x17 ; ELF-NEXT: ldr x30, [sp], #16 ; ELF-NEXT: ret - %tmp0 = call i32 %arg0() [ "ptrauth"(i64 1, i64 42) ] + %tmp0 = call i32 %arg0() [ "ptrauth"(i64 1, i64 42, i64 0) ] ret i32 %tmp0 } @@ -99,7 +99,7 @@ define i32 @test_tailcall_ia_imm(ptr %arg0) #0 { ; CHECK-LABEL: test_tailcall_ia_imm: ; CHECK-NEXT: mov x16, #42 ; CHECK-NEXT: braa x0, x16 - %tmp0 = tail call i32 %arg0() [ "ptrauth"(i64 0, i64 42) ] + %tmp0 = tail call i32 %arg0() [ "ptrauth"(i64 0, i64 42, i64 0) ] ret i32 %tmp0 } @@ -107,7 +107,7 @@ define i32 @test_tailcall_ib_imm(ptr %arg0) #0 { ; CHECK-LABEL: test_tailcall_ib_imm: ; CHECK-NEXT: mov x16, #42 ; CHECK-NEXT: brab x0, x16 - %tmp0 = tail call i32 %arg0() [ "ptrauth"(i64 1, i64 42) ] + %tmp0 = tail call i32 %arg0() [ "ptrauth"(i64 1, i64 42, i64 0) ] ret i32 %tmp0 } @@ -126,7 +126,7 @@ define i32 @test_call_ia_var(ptr %arg0, ptr %arg1) #0 { ; ELF-NEXT: ldr x30, [sp], #16 ; ELF-NEXT: ret %tmp0 = load i64, ptr %arg1 - %tmp1 = call i32 %arg0() [ "ptrauth"(i64 0, i64 %tmp0) ] + %tmp1 = call i32 %arg0() [ "ptrauth"(i64 0, i64 0, i64 %tmp0) ] ret i32 %tmp1 } @@ -145,7 +145,7 @@ define i32 @test_call_ib_var(ptr %arg0, ptr %arg1) #0 { ; ELF-NEXT: ldr x30, [sp], #16 ; ELF-NEXT: ret %tmp0 = load i64, ptr %arg1 - %tmp1 = call i32 %arg0() [ "ptrauth"(i64 1, i64 %tmp0) ] + %tmp1 = call i32 %arg0() [ "ptrauth"(i64 1, i64 0, i64 %tmp0) ] ret i32 %tmp1 } @@ -154,7 +154,7 @@ define i32 @test_tailcall_ia_var(ptr %arg0, ptr %arg1) #0 { ; CHECK: ldr x1, [x1] ; CHECK: braa x0, x1 %tmp0 = load i64, ptr %arg1 - %tmp1 = tail call i32 %arg0() [ "ptrauth"(i64 0, i64 %tmp0) ] + %tmp1 = tail call i32 %arg0() [ "ptrauth"(i64 0, i64 0, i64 %tmp0) ] ret i32 %tmp1 } @@ -163,43 +163,47 @@ define i32 @test_tailcall_ib_var(ptr %arg0, ptr %arg1) #0 { ; CHECK: ldr x1, [x1] ; CHECK: brab x0, x1 %tmp0 = load i64, ptr %arg1 - %tmp1 = tail call i32 %arg0() [ "ptrauth"(i64 1, i64 %tmp0) ] + %tmp1 = tail call i32 %arg0() [ "ptrauth"(i64 1, i64 0, i64 %tmp0) ] ret i32 %tmp1 } define i32 @test_call_da_0(ptr %arg0) #0 { ; DARWIN-LABEL: test_call_da_0: ; DARWIN-NEXT: stp x29, x30, [sp, #-16]! -; DARWIN-NEXT: autdza x0 -; DARWIN-NEXT: blr x0 +; DARWIN-NEXT: mov x16, x0 +; DARWIN-NEXT: autdza x16 +; DARWIN-NEXT: blr x16 ; DARWIN-NEXT: ldp x29, x30, [sp], #16 ; DARWIN-NEXT: ret ; ; ELF-LABEL: test_call_da_0: ; ELF-NEXT: str x30, [sp, #-16]! -; ELF-NEXT: autdza x0 -; ELF-NEXT: blr x0 +; ELF-NEXT: mov x16, x0 +; ELF-NEXT: autdza x16 +; ELF-NEXT: blr x16 ; ELF-NEXT: ldr x30, [sp], #16 ; ELF-NEXT: ret - %tmp0 = call i32 %arg0() [ "ptrauth"(i64 2, i64 0) ] + %tmp0 = call i32 %arg0() [ "ptrauth"(i64 2, i64 0, i64 0) ] ret i32 %tmp0 } define i32 @test_call_db_0(ptr %arg0) #0 { ; DARWIN-LABEL: test_call_db_0: ; DARWIN-NEXT: stp x29, x30, [sp, #-16]! -; DARWIN-NEXT: autdzb x0 -; DARWIN-NEXT: blr x0 +; DARWIN-NEXT: mov x16, x0 +; DARWIN-NEXT: autdzb x16 +; DARWIN-NEXT: blr x16 ; DARWIN-NEXT: ldp x29, x30, [sp], #16 ; DARWIN-NEXT: ret ; ; ELF-LABEL: test_call_db_0: ; ELF-NEXT: str x30, [sp, #-16]! -; ELF-NEXT: autdzb x0 -; ELF-NEXT: blr x0 +; ELF-NEXT: mov x16, x0 +; ELF-NEXT: autdzb x16 +; ELF-NEXT: blr x16 ; ELF-NEXT: ldr x30, [sp], #16 ; ELF-NEXT: ret - %tmp0 = call i32 %arg0() [ "ptrauth"(i64 3, i64 0) ] + %tmp0 = call i32 %arg0() [ "ptrauth"(i64 3, i64 0, i64 0) ] ret i32 %tmp0 } @@ -207,19 +211,21 @@ define i32 @test_call_da_imm(ptr %arg0) #0 { ; DARWIN-LABEL: test_call_da_imm: ; DARWIN-NEXT: stp x29, x30, [sp, #-16]! ; DARWIN-NEXT: mov x17, #42 -; DARWIN-NEXT: autda x0, x17 -; DARWIN-NEXT: blr x0 +; DARWIN-NEXT: mov x16, x0 +; DARWIN-NEXT: autda x16, x17 +; DARWIN-NEXT: blr x16 ; DARWIN-NEXT: ldp x29, x30, [sp], #16 ; DARWIN-NEXT: ret ; ; ELF-LABEL: test_call_da_imm: ; ELF-NEXT: str x30, [sp, #-16]! ; ELF-NEXT: mov x17, #42 -; ELF-NEXT: autda x0, x17 -; ELF-NEXT: blr x0 +; ELF-NEXT: mov x16, x0 +; ELF-NEXT: autda x16, x17 +; ELF-NEXT: blr x16 ; ELF-NEXT: ldr x30, [sp], #16 ; ELF-NEXT: ret - %tmp0 = call i32 %arg0() [ "ptrauth"(i64 2, i64 42) ] + %tmp0 = call i32 %arg0() [ "ptrauth"(i64 2, i64 42, i64 0) ] ret i32 %tmp0 } @@ -227,53 +233,59 @@ define i32 @test_call_db_imm(ptr %arg0) #0 { ; DARWIN-LABEL: test_call_db_imm: ; DARWIN-NEXT: stp x29, x30, [sp, #-16]! ; DARWIN-NEXT: mov x17, #42 -; DARWIN-NEXT: autdb x0, x17 -; DARWIN-NEXT: blr x0 +; DARWIN-NEXT: mov x16, x0 +; DARWIN-NEXT: autdb x16, x17 +; DARWIN-NEXT: blr x16 ; DARWIN-NEXT: ldp x29, x30, [sp], #16 ; DARWIN-NEXT: ret ; ; ELF-LABEL: test_call_db_imm: ; ELF-NEXT: str x30, [sp, #-16]! ; ELF-NEXT: mov x17, #42 -; ELF-NEXT: autdb x0, x17 -; ELF-NEXT: blr x0 +; ELF-NEXT: mov x16, x0 +; ELF-NEXT: autdb x16, x17 +; ELF-NEXT: blr x16 ; ELF-NEXT: ldr x30, [sp], #16 ; ELF-NEXT: ret - %tmp0 = call i32 %arg0() [ "ptrauth"(i64 3, i64 42) ] + %tmp0 = call i32 %arg0() [ "ptrauth"(i64 3, i64 42, i64 0) ] ret i32 %tmp0 } define i32 @test_tailcall_da_0(ptr %arg0) #0 { ; CHECK-LABEL: test_tailcall_da_0: -; CHECK-NEXT: autdza x0 -; CHECK-NEXT: br x0 - %tmp0 = tail call i32 %arg0() [ "ptrauth"(i64 2, i64 0) ] +; CHECK-NEXT: mov x17, x0 +; CHECK-NEXT: autdza x17 +; CHECK-NEXT: br x17 + %tmp0 = tail call i32 %arg0() [ "ptrauth"(i64 2, i64 0, i64 0) ] ret i32 %tmp0 } define i32 @test_tailcall_db_0(ptr %arg0) #0 { ; CHECK-LABEL: test_tailcall_db_0: -; CHECK-NEXT: autdzb x0 -; CHECK-NEXT: br x0 - %tmp0 = tail call i32 %arg0() [ "ptrauth"(i64 3, i64 0) ] +; CHECK-NEXT: mov x17, x0 +; CHECK-NEXT: autdzb x17 +; CHECK-NEXT: br x17 + %tmp0 = tail call i32 %arg0() [ "ptrauth"(i64 3, i64 0, i64 0) ] ret i32 %tmp0 } define i32 @test_tailcall_da_imm(ptr %arg0) #0 { ; CHECK-LABEL: test_tailcall_da_imm: ; CHECK-NEXT: mov x16, #42 -; CHECK-NEXT: autda x0, x16 -; CHECK-NEXT: br x0 - %tmp0 = tail call i32 %arg0() [ "ptrauth"(i64 2, i64 42) ] +; CHECK-NEXT: mov x17, x0 +; CHECK-NEXT: autda x17, x16 +; CHECK-NEXT: br x17 + %tmp0 = tail call i32 %arg0() [ "ptrauth"(i64 2, i64 42, i64 0) ] ret i32 %tmp0 } define i32 @test_tailcall_db_imm(ptr %arg0) #0 { ; CHECK-LABEL: test_tailcall_db_imm: ; CHECK-NEXT: mov x16, #42 -; CHECK-NEXT: autdb x0, x16 -; CHECK-NEXT: br x0 - %tmp0 = tail call i32 %arg0() [ "ptrauth"(i64 3, i64 42) ] +; CHECK-NEXT: mov x17, x0 +; CHECK-NEXT: autdb x17, x16 +; CHECK-NEXT: br x17 + %tmp0 = tail call i32 %arg0() [ "ptrauth"(i64 3, i64 42, i64 0) ] ret i32 %tmp0 } @@ -297,10 +309,10 @@ define void @test_tailcall_omit_mov_x16_x16(ptr %objptr) #0 { %vtable.signed = load ptr, ptr %objptr, align 8 %objptr.int = ptrtoint ptr %objptr to i64 %vtable.signed.int = ptrtoint ptr %vtable.signed to i64 - %vtable.unsigned.int = tail call i64 @llvm.ptrauth.auth(i64 %vtable.signed.int) [ "ptrauth"(i64 2, i64 %objptr.int, i64 6503) ] + %vtable.unsigned.int = tail call i64 @llvm.ptrauth.auth(i64 %vtable.signed.int) [ "ptrauth"(i64 2, i64 6503, i64 %objptr.int) ] %vtable.unsigned = inttoptr i64 %vtable.unsigned.int to ptr %virt.func.signed = load ptr, ptr %vtable.unsigned, align 8 - tail call void %virt.func.signed(ptr %objptr) [ "ptrauth"(i64 0, i64 %vtable.unsigned.int, i64 54167) ] + tail call void %virt.func.signed(ptr %objptr) [ "ptrauth"(i64 0, i64 54167, i64 %vtable.unsigned.int) ] ret void } @@ -331,10 +343,10 @@ define i32 @test_call_omit_extra_moves(ptr %objptr) #0 { %vtable.signed = load ptr, ptr %objptr %objptr.int = ptrtoint ptr %objptr to i64 %vtable.signed.int = ptrtoint ptr %vtable.signed to i64 - %vtable.int = tail call i64 @llvm.ptrauth.auth(i64 %vtable.signed.int) [ "ptrauth"(i64 2, i64 %objptr.int, i64 6503) ] + %vtable.int = tail call i64 @llvm.ptrauth.auth(i64 %vtable.signed.int) [ "ptrauth"(i64 2, i64 6503, i64 %objptr.int) ] %vtable = inttoptr i64 %vtable.int to ptr %callee.signed = load ptr, ptr %vtable - %call.result = tail call i32 %callee.signed(ptr %objptr) [ "ptrauth"(i64 0, i64 %vtable.int, i64 34646) ] + %call.result = tail call i32 %callee.signed(ptr %objptr) [ "ptrauth"(i64 0, i64 34646, i64 %vtable.int) ] ret i32 42 } @@ -355,8 +367,8 @@ define i64 @test_call_discr_csr_live(ptr %fnptr, i64 %addr.discr) #0 { ; ELF-NEXT: ldp x20, x19, [sp, #16] ; ELF-NEXT: ldr x30, [sp], #32 ; ELF-NEXT: ret - tail call void %fnptr() [ "ptrauth"(i64 0, i64 %addr.discr, i64 6503) ] - tail call void %fnptr() [ "ptrauth"(i64 0, i64 %addr.discr, i64 6503) ] + tail call void %fnptr() [ "ptrauth"(i64 0, i64 6503, i64 %addr.discr) ] + tail call void %fnptr() [ "ptrauth"(i64 0, i64 6503, i64 %addr.discr) ] ret i64 %addr.discr } @@ -377,8 +389,8 @@ define i64 @test_call_discr_csr_killed(ptr %fnptr, i64 %addr.discr) #0 { ; ELF-NEXT: mov w0, #42 ; ELF-NEXT: ldr x30, [sp], #32 ; ELF-NEXT: ret - tail call void %fnptr() [ "ptrauth"(i64 0, i64 %addr.discr, i64 6503) ] - tail call void %fnptr() [ "ptrauth"(i64 0, i64 %addr.discr, i64 6503) ] + tail call void %fnptr() [ "ptrauth"(i64 0, i64 6503, i64 %addr.discr) ] + tail call void %fnptr() [ "ptrauth"(i64 0, i64 6503, i64 %addr.discr) ] ret i64 42 } @@ -394,7 +406,7 @@ define i64 @test_call_discr_arg(ptr %fnptr, i64 %addr.discr) #0 { ; ELF-NEXT: mov w0, #42 ; ELF-NEXT: ldr x30, [sp], #16 ; ELF-NEXT: ret - tail call void %fnptr(ptr null, i64 %addr.discr) [ "ptrauth"(i64 0, i64 %addr.discr, i64 6503) ] + tail call void %fnptr(ptr null, i64 %addr.discr) [ "ptrauth"(i64 0, i64 6503, i64 %addr.discr) ] ret i64 42 } @@ -408,7 +420,7 @@ define i64 @test_call_discr_non_arg(ptr %fnptr, i64 %addr.discr) #0 { ; ELF-NEXT: mov w0, #42 ; ELF-NEXT: ldr x30, [sp], #16 ; ELF-NEXT: ret - tail call void %fnptr() [ "ptrauth"(i64 0, i64 %addr.discr, i64 6503) ] + tail call void %fnptr() [ "ptrauth"(i64 0, i64 6503, i64 %addr.discr) ] ret i64 42 } @@ -420,7 +432,7 @@ define i64 @test_tailcall_discr_arg(ptr %fnptr, i64 %addr.discr) #0 { ; ELF-NEXT: mov x16, x1 ; ELF-NEXT: movk x16, #6503, lsl #48 ; ELF-NEXT: braa x2, x16 - %result = tail call i64 %fnptr(ptr null, i64 %addr.discr) [ "ptrauth"(i64 0, i64 %addr.discr, i64 6503) ] + %result = tail call i64 %fnptr(ptr null, i64 %addr.discr) [ "ptrauth"(i64 0, i64 6503, i64 %addr.discr) ] ret i64 %result } @@ -436,7 +448,7 @@ define i32 @test_call_ia_arg(ptr %arg0, i64 %arg1) #0 { ; ELF-NEXT: blraa x0, x1 ; ELF-NEXT: ldr x30, [sp], #16 ; ELF-NEXT: ret - %tmp0 = call i32 %arg0() [ "ptrauth"(i64 0, i64 %arg1) ] + %tmp0 = call i32 %arg0() [ "ptrauth"(i64 0, i64 0, i64 %arg1) ] ret i32 %tmp0 } @@ -452,21 +464,21 @@ define i32 @test_call_ib_arg(ptr %arg0, i64 %arg1) #0 { ; ELF-NEXT: blrab x0, x1 ; ELF-NEXT: ldr x30, [sp], #16 ; ELF-NEXT: ret - %tmp0 = call i32 %arg0() [ "ptrauth"(i64 1, i64 %arg1) ] + %tmp0 = call i32 %arg0() [ "ptrauth"(i64 1, i64 0, i64 %arg1) ] ret i32 %tmp0 } define i32 @test_tailcall_ia_arg(ptr %arg0, i64 %arg1) #0 { ; CHECK-LABEL: test_tailcall_ia_arg: ; CHECK: braa x0, x1 - %tmp0 = tail call i32 %arg0() [ "ptrauth"(i64 0, i64 %arg1) ] + %tmp0 = tail call i32 %arg0() [ "ptrauth"(i64 0, i64 0, i64 %arg1) ] ret i32 %tmp0 } define i32 @test_tailcall_ib_arg(ptr %arg0, i64 %arg1) #0 { ; CHECK-LABEL: test_tailcall_ib_arg: ; CHECK: brab x0, x1 - %tmp0 = tail call i32 %arg0() [ "ptrauth"(i64 1, i64 %arg1) ] + %tmp0 = tail call i32 %arg0() [ "ptrauth"(i64 1, i64 0, i64 %arg1) ] ret i32 %tmp0 } @@ -485,7 +497,7 @@ define i32 @test_call_ia_arg_ind(ptr %arg0, i64 %arg1) #0 { ; ELF-NEXT: ldr x30, [sp], #16 ; ELF-NEXT: ret %tmp0 = load ptr, ptr %arg0 - %tmp1 = call i32 %tmp0() [ "ptrauth"(i64 0, i64 %arg1) ] + %tmp1 = call i32 %tmp0() [ "ptrauth"(i64 0, i64 0, i64 %arg1) ] ret i32 %tmp1 } @@ -504,7 +516,7 @@ define i32 @test_call_ib_arg_ind(ptr %arg0, i64 %arg1) #0 { ; ELF-NEXT: ldr x30, [sp], #16 ; ELF-NEXT: ret %tmp0 = load ptr, ptr %arg0 - %tmp1 = call i32 %tmp0() [ "ptrauth"(i64 1, i64 %arg1) ] + %tmp1 = call i32 %tmp0() [ "ptrauth"(i64 1, i64 0, i64 %arg1) ] ret i32 %tmp1 } @@ -513,7 +525,7 @@ define i32 @test_tailcall_ia_arg_ind(ptr %arg0, i64 %arg1) #0 { ; CHECK: ldr x0, [x0] ; CHECK: braa x0, x1 %tmp0 = load ptr, ptr %arg0 - %tmp1 = tail call i32 %tmp0() [ "ptrauth"(i64 0, i64 %arg1) ] + %tmp1 = tail call i32 %tmp0() [ "ptrauth"(i64 0, i64 0, i64 %arg1) ] ret i32 %tmp1 } @@ -522,7 +534,7 @@ define i32 @test_tailcall_ib_arg_ind(ptr %arg0, i64 %arg1) #0 { ; CHECK: ldr x0, [x0] ; CHECK: brab x0, x1 %tmp0 = load ptr, ptr %arg0 - %tmp1 = tail call i32 %tmp0() [ "ptrauth"(i64 1, i64 %arg1) ] + %tmp1 = tail call i32 %tmp0() [ "ptrauth"(i64 1, i64 0, i64 %arg1) ] ret i32 %tmp1 } @@ -540,7 +552,7 @@ define i32 @test_direct_call() #0 { ; ELF-NEXT: bl f ; ELF-NEXT: ldr x30, [sp], #16 ; ELF-NEXT: ret - %tmp0 = call i32 ptrauth(ptr @f, i32 0, i64 42)() [ "ptrauth"(i64 0, i64 42) ] + %tmp0 = call i32 ptrauth(ptr @f, i32 0, i64 42)() [ "ptrauth"(i64 0, i64 42, i64 0) ] ret i32 %tmp0 } @@ -550,7 +562,7 @@ define i32 @test_direct_tailcall(ptr %arg0) #0 { ; ; ELF-LABEL: test_direct_tailcall: ; ELF-NEXT: b f - %tmp0 = tail call i32 ptrauth(ptr @f, i32 0, i64 42)() [ "ptrauth"(i64 0, i64 42) ] + %tmp0 = tail call i32 ptrauth(ptr @f, i32 0, i64 42)() [ "ptrauth"(i64 0, i64 42, i64 0) ] ret i32 %tmp0 } @@ -578,7 +590,7 @@ define i32 @test_direct_call_mismatch() #0 { ; ELF-NEXT: blrab x8, x17 ; ELF-NEXT: ldr x30, [sp], #16 ; ELF-NEXT: ret - %tmp0 = call i32 ptrauth(ptr @f, i32 0, i64 42)() [ "ptrauth"(i64 1, i64 42) ] + %tmp0 = call i32 ptrauth(ptr @f, i32 0, i64 42)() [ "ptrauth"(i64 1, i64 42, i64 0) ] ret i32 %tmp0 } @@ -594,7 +606,7 @@ define i32 @test_direct_call_addr() #0 { ; ELF-NEXT: bl f ; ELF-NEXT: ldr x30, [sp], #16 ; ELF-NEXT: ret - %tmp0 = call i32 ptrauth(ptr @f, i32 1, i64 0, ptr @f.ref.ib.0.addr)() [ "ptrauth"(i64 1, i64 ptrtoint (ptr @f.ref.ib.0.addr to i64)) ] + %tmp0 = call i32 ptrauth(ptr @f, i32 1, i64 0, ptr @f.ref.ib.0.addr)() [ "ptrauth"(i64 1, i64 0, i64 ptrtoint (ptr @f.ref.ib.0.addr to i64)) ] ret i32 %tmp0 } @@ -610,7 +622,7 @@ define i32 @test_direct_call_addr_blend() #0 { ; ELF-NEXT: bl f ; ELF-NEXT: ldr x30, [sp], #16 ; ELF-NEXT: ret - %tmp1 = call i32 ptrauth(ptr @f, i32 1, i64 42, ptr @f.ref.ib.42.addr)() [ "ptrauth"(i64 1, i64 ptrtoint (ptr @f.ref.ib.42.addr to i64), i64 42) ] + %tmp1 = call i32 ptrauth(ptr @f, i32 1, i64 42, ptr @f.ref.ib.42.addr)() [ "ptrauth"(i64 1, i64 42, i64 ptrtoint (ptr @f.ref.ib.42.addr to i64)) ] ret i32 %tmp1 } @@ -626,7 +638,7 @@ define i32 @test_direct_call_addr_gep_different_index_types() #0 { ; ELF-NEXT: bl f ; ELF-NEXT: ldr x30, [sp], #16 ; ELF-NEXT: ret - %tmp0 = call i32 ptrauth(ptr @f, i32 1, i64 0, ptr getelementptr ({ ptr }, ptr @f_struct.ref.ib.0.addr, i64 0, i32 0))() [ "ptrauth"(i64 1, i64 ptrtoint (ptr getelementptr ({ ptr }, ptr @f_struct.ref.ib.0.addr, i32 0, i32 0) to i64)) ] + %tmp0 = call i32 ptrauth(ptr @f, i32 1, i64 0, ptr getelementptr ({ ptr }, ptr @f_struct.ref.ib.0.addr, i64 0, i32 0))() [ "ptrauth"(i64 1, i64 0, i64 ptrtoint (ptr getelementptr ({ ptr }, ptr @f_struct.ref.ib.0.addr, i32 0, i32 0) to i64)) ] ret i32 %tmp0 } @@ -642,7 +654,7 @@ define i32 @test_direct_call_addr_blend_gep_different_index_types() #0 { ; ELF-NEXT: bl f ; ELF-NEXT: ldr x30, [sp], #16 ; ELF-NEXT: ret - %tmp1 = call i32 ptrauth(ptr @f, i32 1, i64 123, ptr getelementptr ({ ptr }, ptr @f_struct.ref.ib.123.addr, i64 0, i32 0))() [ "ptrauth"(i64 1, i64 ptrtoint (ptr getelementptr ({ ptr }, ptr @f_struct.ref.ib.123.addr, i32 0, i32 0) to i64), i64 123) ] + %tmp1 = call i32 ptrauth(ptr @f, i32 1, i64 123, ptr getelementptr ({ ptr }, ptr @f_struct.ref.ib.123.addr, i64 0, i32 0))() [ "ptrauth"(i64 1, i64 123, i64 ptrtoint (ptr getelementptr ({ ptr }, ptr @f_struct.ref.ib.123.addr, i32 0, i32 0) to i64)) ] ret i32 %tmp1 } diff --git a/llvm/test/CodeGen/AArch64/ptrauth-fpac.ll b/llvm/test/CodeGen/AArch64/ptrauth-fpac.ll index 9f93b00bb582f..dafb23697ffe3 100644 --- a/llvm/test/CodeGen/AArch64/ptrauth-fpac.ll +++ b/llvm/test/CodeGen/AArch64/ptrauth-fpac.ll @@ -18,7 +18,7 @@ define i64 @test_auth_ia(i64 %arg, i64 %arg1) { ; ELF: // %bb.0: ; ELF-NEXT: autia x0, x1 ; ELF-NEXT: ret - %tmp = call i64 @llvm.ptrauth.auth(i64 %arg) [ "ptrauth"(i64 0, i64 %arg1) ] + %tmp = call i64 @llvm.ptrauth.auth(i64 %arg) [ "ptrauth"(i64 0, i64 0, i64 %arg1) ] ret i64 %tmp } @@ -34,7 +34,7 @@ define i64 @test_auth_ia_zero(i64 %arg) { ; ELF: // %bb.0: ; ELF-NEXT: autiza x0 ; ELF-NEXT: ret - %tmp = call i64 @llvm.ptrauth.auth(i64 %arg) [ "ptrauth"(i64 0, i64 0) ] + %tmp = call i64 @llvm.ptrauth.auth(i64 %arg) [ "ptrauth"(i64 0, i64 0, i64 0) ] ret i64 %tmp } @@ -50,7 +50,7 @@ define i64 @test_auth_ib(i64 %arg, i64 %arg1) { ; ELF: // %bb.0: ; ELF-NEXT: autib x0, x1 ; ELF-NEXT: ret - %tmp = call i64 @llvm.ptrauth.auth(i64 %arg) [ "ptrauth"(i64 1, i64 %arg1) ] + %tmp = call i64 @llvm.ptrauth.auth(i64 %arg) [ "ptrauth"(i64 1, i64 0, i64 %arg1) ] ret i64 %tmp } @@ -66,7 +66,7 @@ define i64 @test_auth_ib_zero(i64 %arg) { ; ELF: // %bb.0: ; ELF-NEXT: autizb x0 ; ELF-NEXT: ret - %tmp = call i64 @llvm.ptrauth.auth(i64 %arg) [ "ptrauth"(i64 1, i64 0) ] + %tmp = call i64 @llvm.ptrauth.auth(i64 %arg) [ "ptrauth"(i64 1, i64 0, i64 0) ] ret i64 %tmp } @@ -82,7 +82,7 @@ define i64 @test_auth_da(i64 %arg, i64 %arg1) { ; ELF: // %bb.0: ; ELF-NEXT: autda x0, x1 ; ELF-NEXT: ret - %tmp = call i64 @llvm.ptrauth.auth(i64 %arg) [ "ptrauth"(i64 2, i64 %arg1) ] + %tmp = call i64 @llvm.ptrauth.auth(i64 %arg) [ "ptrauth"(i64 2, i64 0, i64 %arg1) ] ret i64 %tmp } @@ -98,7 +98,7 @@ define i64 @test_auth_da_zero(i64 %arg) { ; ELF: // %bb.0: ; ELF-NEXT: autdza x0 ; ELF-NEXT: ret - %tmp = call i64 @llvm.ptrauth.auth(i64 %arg) [ "ptrauth"(i64 2, i64 0) ] + %tmp = call i64 @llvm.ptrauth.auth(i64 %arg) [ "ptrauth"(i64 2, i64 0, i64 0) ] ret i64 %tmp } @@ -114,7 +114,7 @@ define i64 @test_auth_db(i64 %arg, i64 %arg1) { ; ELF: // %bb.0: ; ELF-NEXT: autdb x0, x1 ; ELF-NEXT: ret - %tmp = call i64 @llvm.ptrauth.auth(i64 %arg) [ "ptrauth"(i64 3, i64 %arg1) ] + %tmp = call i64 @llvm.ptrauth.auth(i64 %arg) [ "ptrauth"(i64 3, i64 0, i64 %arg1) ] ret i64 %tmp } @@ -130,7 +130,7 @@ define i64 @test_auth_db_zero(i64 %arg) { ; ELF: // %bb.0: ; ELF-NEXT: autdzb x0 ; ELF-NEXT: ret - %tmp = call i64 @llvm.ptrauth.auth(i64 %arg) [ "ptrauth"(i64 3, i64 0) ] + %tmp = call i64 @llvm.ptrauth.auth(i64 %arg) [ "ptrauth"(i64 3, i64 0, i64 0) ] ret i64 %tmp } @@ -160,7 +160,7 @@ define i64 @test_resign_ia_ia(i64 %arg, i64 %arg1, i64 %arg2) { ; FPAC-NEXT: pacia x16, x2 ; FPAC-NEXT: mov x0, x16 ; FPAC-NEXT: ret - %tmp = call i64 @llvm.ptrauth.resign(i64 %arg) [ "ptrauth"(i64 0, i64 %arg1), "ptrauth"(i64 0, i64 %arg2) ] + %tmp = call i64 @llvm.ptrauth.resign(i64 %arg) [ "ptrauth"(i64 0, i64 0, i64 %arg1), "ptrauth"(i64 0, i64 0, i64 %arg2) ] ret i64 %tmp } @@ -188,7 +188,7 @@ define i64 @test_resign_ib_ia(i64 %arg, i64 %arg1, i64 %arg2) { ; FPAC-NEXT: pacia x16, x2 ; FPAC-NEXT: mov x0, x16 ; FPAC-NEXT: ret - %tmp = call i64 @llvm.ptrauth.resign(i64 %arg) [ "ptrauth"(i64 1, i64 %arg1), "ptrauth"(i64 0, i64 %arg2) ] + %tmp = call i64 @llvm.ptrauth.resign(i64 %arg) [ "ptrauth"(i64 1, i64 0, i64 %arg1), "ptrauth"(i64 0, i64 0, i64 %arg2) ] ret i64 %tmp } @@ -216,7 +216,7 @@ define i64 @test_resign_da_ia(i64 %arg, i64 %arg1, i64 %arg2) { ; FPAC-NEXT: pacia x16, x2 ; FPAC-NEXT: mov x0, x16 ; FPAC-NEXT: ret - %tmp = call i64 @llvm.ptrauth.resign(i64 %arg) [ "ptrauth"(i64 2, i64 %arg1), "ptrauth"(i64 0, i64 %arg2) ] + %tmp = call i64 @llvm.ptrauth.resign(i64 %arg) [ "ptrauth"(i64 2, i64 0, i64 %arg1), "ptrauth"(i64 0, i64 0, i64 %arg2) ] ret i64 %tmp } @@ -244,7 +244,7 @@ define i64 @test_resign_db_ia(i64 %arg, i64 %arg1, i64 %arg2) { ; FPAC-NEXT: pacia x16, x2 ; FPAC-NEXT: mov x0, x16 ; FPAC-NEXT: ret - %tmp = call i64 @llvm.ptrauth.resign(i64 %arg) [ "ptrauth"(i64 3, i64 %arg1), "ptrauth"(i64 0, i64 %arg2) ] + %tmp = call i64 @llvm.ptrauth.resign(i64 %arg) [ "ptrauth"(i64 3, i64 0, i64 %arg1), "ptrauth"(i64 0, i64 0, i64 %arg2) ] ret i64 %tmp } @@ -272,7 +272,7 @@ define i64 @test_resign_db_ib(i64 %arg, i64 %arg1, i64 %arg2) { ; FPAC-NEXT: pacib x16, x2 ; FPAC-NEXT: mov x0, x16 ; FPAC-NEXT: ret - %tmp = call i64 @llvm.ptrauth.resign(i64 %arg) [ "ptrauth"(i64 3, i64 %arg1), "ptrauth"(i64 1, i64 %arg2) ] + %tmp = call i64 @llvm.ptrauth.resign(i64 %arg) [ "ptrauth"(i64 3, i64 0, i64 %arg1), "ptrauth"(i64 1, i64 0, i64 %arg2) ] ret i64 %tmp } @@ -300,7 +300,7 @@ define i64 @test_resign_db_da(i64 %arg, i64 %arg1, i64 %arg2) { ; FPAC-NEXT: pacda x16, x2 ; FPAC-NEXT: mov x0, x16 ; FPAC-NEXT: ret - %tmp = call i64 @llvm.ptrauth.resign(i64 %arg) [ "ptrauth"(i64 3, i64 %arg1), "ptrauth"(i64 2, i64 %arg2) ] + %tmp = call i64 @llvm.ptrauth.resign(i64 %arg) [ "ptrauth"(i64 3, i64 0, i64 %arg1), "ptrauth"(i64 2, i64 0, i64 %arg2) ] ret i64 %tmp } @@ -328,7 +328,7 @@ define i64 @test_resign_db_db(i64 %arg, i64 %arg1, i64 %arg2) { ; FPAC-NEXT: pacdb x16, x2 ; FPAC-NEXT: mov x0, x16 ; FPAC-NEXT: ret - %tmp = call i64 @llvm.ptrauth.resign(i64 %arg) [ "ptrauth"(i64 3, i64 %arg1), "ptrauth"(i64 3, i64 %arg2) ] + %tmp = call i64 @llvm.ptrauth.resign(i64 %arg) [ "ptrauth"(i64 3, i64 0, i64 %arg1), "ptrauth"(i64 3, i64 0, i64 %arg2) ] ret i64 %tmp } @@ -356,7 +356,7 @@ define i64 @test_resign_iza_db(i64 %arg, i64 %arg1, i64 %arg2) { ; FPAC-NEXT: pacdb x16, x2 ; FPAC-NEXT: mov x0, x16 ; FPAC-NEXT: ret - %tmp = call i64 @llvm.ptrauth.resign(i64 %arg) [ "ptrauth"(i64 0, i64 0), "ptrauth"(i64 3, i64 %arg2) ] + %tmp = call i64 @llvm.ptrauth.resign(i64 %arg) [ "ptrauth"(i64 0, i64 0, i64 0), "ptrauth"(i64 3, i64 0, i64 %arg2) ] ret i64 %tmp } @@ -384,7 +384,7 @@ define i64 @test_resign_da_dzb(i64 %arg, i64 %arg1, i64 %arg2) { ; FPAC-NEXT: pacdzb x16 ; FPAC-NEXT: mov x0, x16 ; FPAC-NEXT: ret - %tmp = call i64 @llvm.ptrauth.resign(i64 %arg) [ "ptrauth"(i64 2, i64 %arg1), "ptrauth"(i64 3, i64 0) ] + %tmp = call i64 @llvm.ptrauth.resign(i64 %arg) [ "ptrauth"(i64 2, i64 0, i64 %arg1), "ptrauth"(i64 3, i64 0, i64 0) ] ret i64 %tmp } @@ -421,6 +421,6 @@ define i64 @test_auth_trap_attribute(i64 %arg, i64 %arg1) "ptrauth-auth-traps" { ; ELF-FPAC: %bb.0: ; ELF-FPAC-NEXT: autia x0, x1 ; ELF-FPAC-NEXT: ret - %tmp = call i64 @llvm.ptrauth.auth(i64 %arg) [ "ptrauth"(i64 0, i64 %arg1) ] + %tmp = call i64 @llvm.ptrauth.auth(i64 %arg) [ "ptrauth"(i64 0, i64 0, i64 %arg1) ] ret i64 %tmp } diff --git a/llvm/test/CodeGen/AArch64/ptrauth-intrinsic-auth-resign-with-blend.ll b/llvm/test/CodeGen/AArch64/ptrauth-intrinsic-auth-resign-with-blend.ll index 3ad56a5ba0916..8ece0a529ab64 100644 --- a/llvm/test/CodeGen/AArch64/ptrauth-intrinsic-auth-resign-with-blend.ll +++ b/llvm/test/CodeGen/AArch64/ptrauth-intrinsic-auth-resign-with-blend.ll @@ -73,7 +73,7 @@ define i64 @test_auth_blend(i64 %arg, i64 %arg1) { ; TRAP-NEXT: Lauth_success_0: ; TRAP-DARWIN-NEXT: mov x0, x16 ; TRAP-NEXT: ret - %tmp1 = call i64 @llvm.ptrauth.auth(i64 %arg) [ "ptrauth"(i64 2, i64 %arg1, i64 65535) ] + %tmp1 = call i64 @llvm.ptrauth.auth(i64 %arg) [ "ptrauth"(i64 2, i64 65535, i64 %arg1) ] ret i64 %tmp1 } @@ -133,7 +133,7 @@ define i64 @test_resign_blend(i64 %arg, i64 %arg1, i64 %arg2) { ; TRAP-NEXT: pacdb x16, x17 ; TRAP-NEXT: mov x0, x16 ; TRAP-NEXT: ret - %tmp2 = call i64 @llvm.ptrauth.resign(i64 %arg) [ "ptrauth"(i64 2, i64 %arg1, i64 12345), "ptrauth"(i64 3, i64 %arg2, i64 56789) ] + %tmp2 = call i64 @llvm.ptrauth.resign(i64 %arg) [ "ptrauth"(i64 2, i64 12345, i64 %arg1), "ptrauth"(i64 3, i64 56789, i64 %arg2) ] ret i64 %tmp2 } @@ -190,7 +190,7 @@ define i64 @test_resign_blend_and_const(i64 %arg, i64 %arg1) { ; TRAP-NEXT: pacdb x16, x17 ; TRAP-NEXT: mov x0, x16 ; TRAP-NEXT: ret - %tmp1 = call i64 @llvm.ptrauth.resign(i64 %arg) [ "ptrauth"(i64 2, i64 %arg1, i64 12345), "ptrauth"(i64 3, i64 56789) ] + %tmp1 = call i64 @llvm.ptrauth.resign(i64 %arg) [ "ptrauth"(i64 2, i64 12345, i64 %arg1), "ptrauth"(i64 3, i64 56789, i64 0) ] ret i64 %tmp1 } @@ -244,7 +244,7 @@ define i64 @test_resign_blend_and_addr(i64 %arg, i64 %arg1, i64 %arg2) { ; TRAP-NEXT: pacdb x16, x2 ; TRAP-NEXT: mov x0, x16 ; TRAP-NEXT: ret - %tmp1 = call i64 @llvm.ptrauth.resign(i64 %arg) [ "ptrauth"(i64 2, i64 %arg1, i64 12345), "ptrauth"(i64 3, i64 %arg2) ] + %tmp1 = call i64 @llvm.ptrauth.resign(i64 %arg) [ "ptrauth"(i64 2, i64 12345, i64 %arg1), "ptrauth"(i64 3, i64 0, i64 %arg2) ] ret i64 %tmp1 } diff --git a/llvm/test/CodeGen/AArch64/ptrauth-intrinsic-auth-resign.ll b/llvm/test/CodeGen/AArch64/ptrauth-intrinsic-auth-resign.ll index 6fdae6e6e183e..9523250540a96 100644 --- a/llvm/test/CodeGen/AArch64/ptrauth-intrinsic-auth-resign.ll +++ b/llvm/test/CodeGen/AArch64/ptrauth-intrinsic-auth-resign.ll @@ -64,7 +64,7 @@ define i64 @test_auth_ia(i64 %arg, i64 %arg1) { ; TRAP-NEXT: Lauth_success_0: ; TRAP-DARWIN-NEXT: mov x0, x16 ; TRAP-NEXT: ret - %tmp = call i64 @llvm.ptrauth.auth(i64 %arg) [ "ptrauth"(i64 0, i64 %arg1) ] + %tmp = call i64 @llvm.ptrauth.auth(i64 %arg) [ "ptrauth"(i64 0, i64 0, i64 %arg1) ] ret i64 %tmp } @@ -101,7 +101,7 @@ define i64 @test_auth_ia_zero(i64 %arg) { ; TRAP-NEXT: Lauth_success_1: ; TRAP-DARWIN-NEXT: mov x0, x16 ; TRAP-NEXT: ret - %tmp = call i64 @llvm.ptrauth.auth(i64 %arg) [ "ptrauth"(i64 0, i64 0) ] + %tmp = call i64 @llvm.ptrauth.auth(i64 %arg) [ "ptrauth"(i64 0, i64 0, i64 0) ] ret i64 %tmp } @@ -138,7 +138,7 @@ define i64 @test_auth_ib(i64 %arg, i64 %arg1) { ; TRAP-NEXT: Lauth_success_2: ; TRAP-DARWIN-NEXT: mov x0, x16 ; TRAP-NEXT: ret - %tmp = call i64 @llvm.ptrauth.auth(i64 %arg) [ "ptrauth"(i64 1, i64 %arg1) ] + %tmp = call i64 @llvm.ptrauth.auth(i64 %arg) [ "ptrauth"(i64 1, i64 0, i64 %arg1) ] ret i64 %tmp } @@ -175,7 +175,7 @@ define i64 @test_auth_ib_zero(i64 %arg) { ; TRAP-NEXT: Lauth_success_3: ; TRAP-DARWIN-NEXT: mov x0, x16 ; TRAP-NEXT: ret - %tmp = call i64 @llvm.ptrauth.auth(i64 %arg) [ "ptrauth"(i64 1, i64 0) ] + %tmp = call i64 @llvm.ptrauth.auth(i64 %arg) [ "ptrauth"(i64 1, i64 0, i64 0) ] ret i64 %tmp } @@ -212,7 +212,7 @@ define i64 @test_auth_da(i64 %arg, i64 %arg1) { ; TRAP-NEXT: Lauth_success_4: ; TRAP-DARWIN-NEXT: mov x0, x16 ; TRAP-NEXT: ret - %tmp = call i64 @llvm.ptrauth.auth(i64 %arg) [ "ptrauth"(i64 2, i64 %arg1) ] + %tmp = call i64 @llvm.ptrauth.auth(i64 %arg) [ "ptrauth"(i64 2, i64 0, i64 %arg1) ] ret i64 %tmp } @@ -249,7 +249,7 @@ define i64 @test_auth_da_zero(i64 %arg) { ; TRAP-NEXT: Lauth_success_5: ; TRAP-DARWIN-NEXT: mov x0, x16 ; TRAP-NEXT: ret - %tmp = call i64 @llvm.ptrauth.auth(i64 %arg) [ "ptrauth"(i64 2, i64 0) ] + %tmp = call i64 @llvm.ptrauth.auth(i64 %arg) [ "ptrauth"(i64 2, i64 0, i64 0) ] ret i64 %tmp } @@ -286,7 +286,7 @@ define i64 @test_auth_db(i64 %arg, i64 %arg1) { ; TRAP-NEXT: Lauth_success_6: ; TRAP-DARWIN-NEXT: mov x0, x16 ; TRAP-NEXT: ret - %tmp = call i64 @llvm.ptrauth.auth(i64 %arg) [ "ptrauth"(i64 3, i64 %arg1) ] + %tmp = call i64 @llvm.ptrauth.auth(i64 %arg) [ "ptrauth"(i64 3, i64 0, i64 %arg1) ] ret i64 %tmp } @@ -323,7 +323,7 @@ define i64 @test_auth_db_zero(i64 %arg) { ; TRAP-NEXT: Lauth_success_7: ; TRAP-DARWIN-NEXT: mov x0, x16 ; TRAP-NEXT: ret - %tmp = call i64 @llvm.ptrauth.auth(i64 %arg) [ "ptrauth"(i64 3, i64 0) ] + %tmp = call i64 @llvm.ptrauth.auth(i64 %arg) [ "ptrauth"(i64 3, i64 0, i64 0) ] ret i64 %tmp } @@ -367,7 +367,7 @@ define i64 @test_resign_ia_ia(i64 %arg, i64 %arg1, i64 %arg2) { ; TRAP-NEXT: pacia x16, x2 ; TRAP-NEXT: mov x0, x16 ; TRAP-NEXT: ret - %tmp = call i64 @llvm.ptrauth.resign(i64 %arg) [ "ptrauth"(i64 0, i64 %arg1), "ptrauth"(i64 0, i64 %arg2) ] + %tmp = call i64 @llvm.ptrauth.resign(i64 %arg) [ "ptrauth"(i64 0, i64 0, i64 %arg1), "ptrauth"(i64 0, i64 0, i64 %arg2) ] ret i64 %tmp } @@ -409,7 +409,7 @@ define i64 @test_resign_ib_ia(i64 %arg, i64 %arg1, i64 %arg2) { ; TRAP-NEXT: pacia x16, x2 ; TRAP-NEXT: mov x0, x16 ; TRAP-NEXT: ret - %tmp = call i64 @llvm.ptrauth.resign(i64 %arg) [ "ptrauth"(i64 1, i64 %arg1), "ptrauth"(i64 0, i64 %arg2) ] + %tmp = call i64 @llvm.ptrauth.resign(i64 %arg) [ "ptrauth"(i64 1, i64 0, i64 %arg1), "ptrauth"(i64 0, i64 0, i64 %arg2) ] ret i64 %tmp } @@ -451,7 +451,7 @@ define i64 @test_resign_da_ia(i64 %arg, i64 %arg1, i64 %arg2) { ; TRAP-NEXT: pacia x16, x2 ; TRAP-NEXT: mov x0, x16 ; TRAP-NEXT: ret - %tmp = call i64 @llvm.ptrauth.resign(i64 %arg) [ "ptrauth"(i64 2, i64 %arg1), "ptrauth"(i64 0, i64 %arg2) ] + %tmp = call i64 @llvm.ptrauth.resign(i64 %arg) [ "ptrauth"(i64 2, i64 0, i64 %arg1), "ptrauth"(i64 0, i64 0, i64 %arg2) ] ret i64 %tmp } @@ -493,7 +493,7 @@ define i64 @test_resign_db_da(i64 %arg, i64 %arg1, i64 %arg2) { ; TRAP-NEXT: pacda x16, x2 ; TRAP-NEXT: mov x0, x16 ; TRAP-NEXT: ret - %tmp = call i64 @llvm.ptrauth.resign(i64 %arg) [ "ptrauth"(i64 3, i64 %arg1), "ptrauth"(i64 2, i64 %arg2) ] + %tmp = call i64 @llvm.ptrauth.resign(i64 %arg) [ "ptrauth"(i64 3, i64 0, i64 %arg1), "ptrauth"(i64 2, i64 0, i64 %arg2) ] ret i64 %tmp } @@ -535,7 +535,7 @@ define i64 @test_resign_iza_db(i64 %arg, i64 %arg1, i64 %arg2) { ; TRAP-NEXT: pacdb x16, x2 ; TRAP-NEXT: mov x0, x16 ; TRAP-NEXT: ret - %tmp = call i64 @llvm.ptrauth.resign(i64 %arg) [ "ptrauth"(i64 0, i64 0), "ptrauth"(i64 3, i64 %arg2) ] + %tmp = call i64 @llvm.ptrauth.resign(i64 %arg) [ "ptrauth"(i64 0, i64 0, i64 0), "ptrauth"(i64 3, i64 0, i64 %arg2) ] ret i64 %tmp } @@ -577,7 +577,7 @@ define i64 @test_resign_da_dzb(i64 %arg, i64 %arg1, i64 %arg2) { ; TRAP-NEXT: pacdzb x16 ; TRAP-NEXT: mov x0, x16 ; TRAP-NEXT: ret - %tmp = call i64 @llvm.ptrauth.resign(i64 %arg) [ "ptrauth"(i64 2, i64 %arg1), "ptrauth"(i64 3, i64 0) ] + %tmp = call i64 @llvm.ptrauth.resign(i64 %arg) [ "ptrauth"(i64 2, i64 0, i64 %arg1), "ptrauth"(i64 3, i64 0, i64 0) ] ret i64 %tmp } @@ -623,7 +623,7 @@ define i64 @test_auth_trap_attribute(i64 %arg, i64 %arg1) "ptrauth-auth-traps" { ; TRAP-NEXT: Lauth_success_14: ; TRAP-DARWIN-NEXT: mov x0, x16 ; TRAP-NEXT: ret - %tmp = call i64 @llvm.ptrauth.auth(i64 %arg) [ "ptrauth"(i64 0, i64 %arg1) ] + %tmp = call i64 @llvm.ptrauth.auth(i64 %arg) [ "ptrauth"(i64 0, i64 0, i64 %arg1) ] ret i64 %tmp } @@ -666,7 +666,7 @@ define i64 @test_auth_ia_constdisc(i64 %arg) { ; TRAP-NEXT: Lauth_success_15: ; TRAP-DARWIN-NEXT: mov x0, x16 ; TRAP-NEXT: ret - %tmp = call i64 @llvm.ptrauth.auth(i64 %arg) [ "ptrauth"(i64 0, i64 256) ] + %tmp = call i64 @llvm.ptrauth.auth(i64 %arg) [ "ptrauth"(i64 0, i64 256, i64 0) ] ret i64 %tmp } @@ -711,7 +711,7 @@ define i64 @test_resign_da_constdisc(i64 %arg, i64 %arg1) { ; TRAP-NEXT: pacda x16, x17 ; TRAP-NEXT: mov x0, x16 ; TRAP-NEXT: ret - %tmp = call i64 @llvm.ptrauth.resign(i64 %arg) [ "ptrauth"(i64 2, i64 %arg1), "ptrauth"(i64 2, i64 256) ] + %tmp = call i64 @llvm.ptrauth.resign(i64 %arg) [ "ptrauth"(i64 2, i64 0, i64 %arg1), "ptrauth"(i64 2, i64 256, i64 0) ] ret i64 %tmp } @@ -751,7 +751,7 @@ define i64 @test_auth_ia_swapped(i64 %arg, i64 %arg1) { ; TRAP-DARWIN-NEXT: mov x0, x16 ; TRAP-ELF-NEXT: mov x0, x1 ; TRAP-NEXT: ret - %tmp = call i64 @llvm.ptrauth.auth(i64 %arg1) [ "ptrauth"(i64 0, i64 %arg) ] + %tmp = call i64 @llvm.ptrauth.auth(i64 %arg1) [ "ptrauth"(i64 0, i64 0, i64 %arg) ] ret i64 %tmp } @@ -858,11 +858,11 @@ entry: br i1 %cond, label %if.then, label %if.else if.then: - %auted.then = tail call i64 @llvm.ptrauth.auth(i64 %signed) [ "ptrauth"(i64 2, i64 0) ] + %auted.then = tail call i64 @llvm.ptrauth.auth(i64 %signed) [ "ptrauth"(i64 2, i64 0, i64 0) ] br label %return if.else: - %auted.else = tail call i64 @llvm.ptrauth.auth(i64 %signed) [ "ptrauth"(i64 3, i64 0) ] + %auted.else = tail call i64 @llvm.ptrauth.auth(i64 %signed) [ "ptrauth"(i64 3, i64 0, i64 0) ] br label %return return: diff --git a/llvm/test/CodeGen/AArch64/ptrauth-intrinsic-sign.ll b/llvm/test/CodeGen/AArch64/ptrauth-intrinsic-sign.ll index cbe4c0bacfbf9..6d3c3dd1ace94 100644 --- a/llvm/test/CodeGen/AArch64/ptrauth-intrinsic-sign.ll +++ b/llvm/test/CodeGen/AArch64/ptrauth-intrinsic-sign.ll @@ -9,7 +9,7 @@ define i64 @test_sign_ia(i64 %arg, i64 %arg1) { ; CHECK: %bb.0: ; CHECK-NEXT: pacia x0, x1 ; CHECK-NEXT: ret - %tmp = call i64 @llvm.ptrauth.sign(i64 %arg) [ "ptrauth"(i64 0, i64 %arg1) ] + %tmp = call i64 @llvm.ptrauth.sign(i64 %arg) [ "ptrauth"(i64 0, i64 0, i64 %arg1) ] ret i64 %tmp } @@ -18,7 +18,7 @@ define i64 @test_sign_ia_zero(i64 %arg) { ; CHECK: %bb.0: ; CHECK-NEXT: paciza x0 ; CHECK-NEXT: ret - %tmp = call i64 @llvm.ptrauth.sign(i64 %arg) [ "ptrauth"(i64 0, i64 0) ] + %tmp = call i64 @llvm.ptrauth.sign(i64 %arg) [ "ptrauth"(i64 0, i64 0, i64 0) ] ret i64 %tmp } @@ -27,7 +27,7 @@ define i64 @test_sign_ib(i64 %arg, i64 %arg1) { ; CHECK: %bb.0: ; CHECK-NEXT: pacib x0, x1 ; CHECK-NEXT: ret - %tmp = call i64 @llvm.ptrauth.sign(i64 %arg) [ "ptrauth"(i64 1, i64 %arg1) ] + %tmp = call i64 @llvm.ptrauth.sign(i64 %arg) [ "ptrauth"(i64 1, i64 0, i64 %arg1) ] ret i64 %tmp } @@ -36,7 +36,7 @@ define i64 @test_sign_ib_zero(i64 %arg) { ; CHECK: %bb.0: ; CHECK-NEXT: pacizb x0 ; CHECK-NEXT: ret - %tmp = call i64 @llvm.ptrauth.sign(i64 %arg) [ "ptrauth"(i64 1, i64 0) ] + %tmp = call i64 @llvm.ptrauth.sign(i64 %arg) [ "ptrauth"(i64 1, i64 0, i64 0) ] ret i64 %tmp } @@ -45,7 +45,7 @@ define i64 @test_sign_da(i64 %arg, i64 %arg1) { ; CHECK: %bb.0: ; CHECK-NEXT: pacda x0, x1 ; CHECK-NEXT: ret - %tmp = call i64 @llvm.ptrauth.sign(i64 %arg) [ "ptrauth"(i64 2, i64 %arg1) ] + %tmp = call i64 @llvm.ptrauth.sign(i64 %arg) [ "ptrauth"(i64 2, i64 0, i64 %arg1) ] ret i64 %tmp } @@ -54,7 +54,7 @@ define i64 @test_sign_da_zero(i64 %arg) { ; CHECK: %bb.0: ; CHECK-NEXT: pacdza x0 ; CHECK-NEXT: ret - %tmp = call i64 @llvm.ptrauth.sign(i64 %arg) [ "ptrauth"(i64 2, i64 0) ] + %tmp = call i64 @llvm.ptrauth.sign(i64 %arg) [ "ptrauth"(i64 2, i64 0, i64 0) ] ret i64 %tmp } @@ -63,7 +63,7 @@ define i64 @test_sign_db(i64 %arg, i64 %arg1) { ; CHECK: %bb.0: ; CHECK-NEXT: pacdb x0, x1 ; CHECK-NEXT: ret - %tmp = call i64 @llvm.ptrauth.sign(i64 %arg) [ "ptrauth"(i64 3, i64 %arg1) ] + %tmp = call i64 @llvm.ptrauth.sign(i64 %arg) [ "ptrauth"(i64 3, i64 0, i64 %arg1) ] ret i64 %tmp } @@ -72,6 +72,6 @@ define i64 @test_sign_db_zero(i64 %arg) { ; CHECK: %bb.0: ; CHECK-NEXT: pacdzb x0 ; CHECK-NEXT: ret - %tmp = call i64 @llvm.ptrauth.sign(i64 %arg) [ "ptrauth"(i64 3, i64 0) ] + %tmp = call i64 @llvm.ptrauth.sign(i64 %arg) [ "ptrauth"(i64 3, i64 0, i64 0) ] ret i64 %tmp } diff --git a/llvm/test/CodeGen/AArch64/ptrauth-intrinsics-upgrade.ll b/llvm/test/CodeGen/AArch64/ptrauth-intrinsics-upgrade.ll index a59c10fef78ba..8c13923bb0bd4 100644 --- a/llvm/test/CodeGen/AArch64/ptrauth-intrinsics-upgrade.ll +++ b/llvm/test/CodeGen/AArch64/ptrauth-intrinsics-upgrade.ll @@ -3,10 +3,10 @@ define void @test_ptrauth_sign(i64 %p, i64 %addr) { ; CHECK-LABEL: @test_ptrauth_sign( -; CHECK-NEXT: [[ZERO_DISCR:%.*]] = call i64 @llvm.ptrauth.sign(i64 [[P:%.*]]) [ "ptrauth"(i64 1, i64 0) ] -; CHECK-NEXT: [[IMM_DISCR:%.*]] = call i64 @llvm.ptrauth.sign(i64 [[P]]) [ "ptrauth"(i64 1, i64 42) ] -; CHECK-NEXT: [[ADDR_DISCR:%.*]] = call i64 @llvm.ptrauth.sign(i64 [[P]]) [ "ptrauth"(i64 1, i64 [[ADDR:%.*]]) ] -; CHECK-NEXT: [[BLENDED_DISCR:%.*]] = call i64 @llvm.ptrauth.sign(i64 [[P]]) [ "ptrauth"(i64 1, i64 [[ADDR]], i64 1234) ] +; CHECK-NEXT: [[ZERO_DISCR:%.*]] = call i64 @llvm.ptrauth.sign(i64 [[P:%.*]]) [ "ptrauth"(i64 1, i64 0, i64 0) ] +; CHECK-NEXT: [[IMM_DISCR:%.*]] = call i64 @llvm.ptrauth.sign(i64 [[P]]) [ "ptrauth"(i64 1, i64 42, i64 0) ] +; CHECK-NEXT: [[ADDR_DISCR:%.*]] = call i64 @llvm.ptrauth.sign(i64 [[P]]) [ "ptrauth"(i64 1, i64 0, i64 [[ADDR:%.*]]) ] +; CHECK-NEXT: [[BLENDED_DISCR:%.*]] = call i64 @llvm.ptrauth.sign(i64 [[P]]) [ "ptrauth"(i64 1, i64 1234, i64 [[ADDR]]) ] ; CHECK-NEXT: ret void ; %tmp = call i64 @llvm.ptrauth.blend(i64 %addr, i64 1234) @@ -19,10 +19,10 @@ define void @test_ptrauth_sign(i64 %p, i64 %addr) { define void @test_ptrauth_auth(i64 %p, i64 %addr) { ; CHECK-LABEL: @test_ptrauth_auth( -; CHECK-NEXT: [[ZERO_DISCR:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[P:%.*]]) [ "ptrauth"(i64 1, i64 0) ] -; CHECK-NEXT: [[IMM_DISCR:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[P]]) [ "ptrauth"(i64 1, i64 42) ] -; CHECK-NEXT: [[ADDR_DISCR:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[P]]) [ "ptrauth"(i64 1, i64 [[ADDR:%.*]]) ] -; CHECK-NEXT: [[BLENDED_DISCR:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[P]]) [ "ptrauth"(i64 1, i64 [[ADDR]], i64 1234) ] +; CHECK-NEXT: [[ZERO_DISCR:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[P:%.*]]) [ "ptrauth"(i64 1, i64 0, i64 0) ] +; CHECK-NEXT: [[IMM_DISCR:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[P]]) [ "ptrauth"(i64 1, i64 42, i64 0) ] +; CHECK-NEXT: [[ADDR_DISCR:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[P]]) [ "ptrauth"(i64 1, i64 0, i64 [[ADDR:%.*]]) ] +; CHECK-NEXT: [[BLENDED_DISCR:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[P]]) [ "ptrauth"(i64 1, i64 1234, i64 [[ADDR]]) ] ; CHECK-NEXT: ret void ; %tmp = call i64 @llvm.ptrauth.blend(i64 %addr, i64 1234) @@ -35,18 +35,18 @@ define void @test_ptrauth_auth(i64 %p, i64 %addr) { define void @test_ptrauth_resign(i64 %p, i64 %addr) { ; CHECK-LABEL: @test_ptrauth_resign( -; CHECK-NEXT: [[IMM_IMM_DISCR:%.*]] = call i64 @llvm.ptrauth.resign(i64 [[P:%.*]]) [ "ptrauth"(i64 1, i64 42), "ptrauth"(i64 2, i64 123) ] -; CHECK-NEXT: [[ZERO_IMM_DISCR:%.*]] = call i64 @llvm.ptrauth.resign(i64 [[P]]) [ "ptrauth"(i64 1, i64 0), "ptrauth"(i64 2, i64 123) ] -; CHECK-NEXT: [[ADDR_IMM_DISCR:%.*]] = call i64 @llvm.ptrauth.resign(i64 [[P]]) [ "ptrauth"(i64 1, i64 [[ADDR:%.*]]), "ptrauth"(i64 2, i64 123) ] -; CHECK-NEXT: [[BLENDED_IMM_DISCR:%.*]] = call i64 @llvm.ptrauth.resign(i64 [[P]]) [ "ptrauth"(i64 1, i64 [[ADDR]], i64 1234), "ptrauth"(i64 2, i64 123) ] -; CHECK-NEXT: [[IMM_ZERO_DISCR:%.*]] = call i64 @llvm.ptrauth.resign(i64 [[P]]) [ "ptrauth"(i64 1, i64 123), "ptrauth"(i64 2, i64 0) ] -; CHECK-NEXT: [[IMM_ADDR_DISCR:%.*]] = call i64 @llvm.ptrauth.resign(i64 [[P]]) [ "ptrauth"(i64 1, i64 123), "ptrauth"(i64 2, i64 [[ADDR]]) ] -; CHECK-NEXT: [[IMM_BLENDED_DISCR:%.*]] = call i64 @llvm.ptrauth.resign(i64 [[P]]) [ "ptrauth"(i64 1, i64 123), "ptrauth"(i64 2, i64 [[ADDR]], i64 5678) ] -; CHECK-NEXT: [[ZERO_BLENDED_DISCR:%.*]] = call i64 @llvm.ptrauth.resign(i64 [[P]]) [ "ptrauth"(i64 1, i64 0), "ptrauth"(i64 2, i64 [[ADDR]], i64 4321) ] -; CHECK-NEXT: [[ADDR_BLENDED_DISCR:%.*]] = call i64 @llvm.ptrauth.resign(i64 [[P]]) [ "ptrauth"(i64 1, i64 [[ADDR]]), "ptrauth"(i64 2, i64 [[ADDR]], i64 4321) ] -; CHECK-NEXT: [[BLENDED_ZERO_DISCR:%.*]] = call i64 @llvm.ptrauth.resign(i64 [[P]]) [ "ptrauth"(i64 1, i64 [[ADDR]], i64 8765), "ptrauth"(i64 2, i64 0) ] -; CHECK-NEXT: [[BLENDED_ADDR_DISCR:%.*]] = call i64 @llvm.ptrauth.resign(i64 [[P]]) [ "ptrauth"(i64 1, i64 [[ADDR]], i64 8765), "ptrauth"(i64 2, i64 [[ADDR]]) ] -; CHECK-NEXT: [[BLENDED_BLENDED_DISCR:%.*]] = call i64 @llvm.ptrauth.resign(i64 [[P]]) [ "ptrauth"(i64 1, i64 [[ADDR]], i64 111), "ptrauth"(i64 2, i64 [[ADDR]], i64 222) ] +; CHECK-NEXT: [[IMM_IMM_DISCR:%.*]] = call i64 @llvm.ptrauth.resign(i64 [[P:%.*]]) [ "ptrauth"(i64 1, i64 42, i64 0), "ptrauth"(i64 2, i64 123, i64 0) ] +; CHECK-NEXT: [[ZERO_IMM_DISCR:%.*]] = call i64 @llvm.ptrauth.resign(i64 [[P]]) [ "ptrauth"(i64 1, i64 0, i64 0), "ptrauth"(i64 2, i64 123, i64 0) ] +; CHECK-NEXT: [[ADDR_IMM_DISCR:%.*]] = call i64 @llvm.ptrauth.resign(i64 [[P]]) [ "ptrauth"(i64 1, i64 0, i64 [[ADDR:%.*]]), "ptrauth"(i64 2, i64 123, i64 0) ] +; CHECK-NEXT: [[BLENDED_IMM_DISCR:%.*]] = call i64 @llvm.ptrauth.resign(i64 [[P]]) [ "ptrauth"(i64 1, i64 1234, i64 [[ADDR]]), "ptrauth"(i64 2, i64 123, i64 0) ] +; CHECK-NEXT: [[IMM_ZERO_DISCR:%.*]] = call i64 @llvm.ptrauth.resign(i64 [[P]]) [ "ptrauth"(i64 1, i64 123, i64 0), "ptrauth"(i64 2, i64 0, i64 0) ] +; CHECK-NEXT: [[IMM_ADDR_DISCR:%.*]] = call i64 @llvm.ptrauth.resign(i64 [[P]]) [ "ptrauth"(i64 1, i64 123, i64 0), "ptrauth"(i64 2, i64 0, i64 [[ADDR]]) ] +; CHECK-NEXT: [[IMM_BLENDED_DISCR:%.*]] = call i64 @llvm.ptrauth.resign(i64 [[P]]) [ "ptrauth"(i64 1, i64 123, i64 0), "ptrauth"(i64 2, i64 5678, i64 [[ADDR]]) ] +; CHECK-NEXT: [[ZERO_BLENDED_DISCR:%.*]] = call i64 @llvm.ptrauth.resign(i64 [[P]]) [ "ptrauth"(i64 1, i64 0, i64 0), "ptrauth"(i64 2, i64 4321, i64 [[ADDR]]) ] +; CHECK-NEXT: [[ADDR_BLENDED_DISCR:%.*]] = call i64 @llvm.ptrauth.resign(i64 [[P]]) [ "ptrauth"(i64 1, i64 0, i64 [[ADDR]]), "ptrauth"(i64 2, i64 4321, i64 [[ADDR]]) ] +; CHECK-NEXT: [[BLENDED_ZERO_DISCR:%.*]] = call i64 @llvm.ptrauth.resign(i64 [[P]]) [ "ptrauth"(i64 1, i64 8765, i64 [[ADDR]]), "ptrauth"(i64 2, i64 0, i64 0) ] +; CHECK-NEXT: [[BLENDED_ADDR_DISCR:%.*]] = call i64 @llvm.ptrauth.resign(i64 [[P]]) [ "ptrauth"(i64 1, i64 8765, i64 [[ADDR]]), "ptrauth"(i64 2, i64 0, i64 [[ADDR]]) ] +; CHECK-NEXT: [[BLENDED_BLENDED_DISCR:%.*]] = call i64 @llvm.ptrauth.resign(i64 [[P]]) [ "ptrauth"(i64 1, i64 111, i64 [[ADDR]]), "ptrauth"(i64 2, i64 222, i64 [[ADDR]]) ] ; CHECK-NEXT: ret void ; %imm.imm.discr = call i64 @llvm.ptrauth.resign(i64 %p, i32 1, i64 42, i32 2, i64 123) @@ -87,8 +87,8 @@ define void @test_ptrauth_strip(i64 %p) { define void @test_ptrauth_reused_blend(i64 %p1, i64 %p2, i64 %addr) { ; CHECK-LABEL: @test_ptrauth_reused_blend( -; CHECK-NEXT: [[RES1:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[P1:%.*]]) [ "ptrauth"(i64 1, i64 [[ADDR:%.*]], i64 1234) ] -; CHECK-NEXT: [[RES2:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[P2:%.*]]) [ "ptrauth"(i64 2, i64 [[ADDR]], i64 1234) ] +; CHECK-NEXT: [[RES1:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[P1:%.*]]) [ "ptrauth"(i64 1, i64 1234, i64 [[ADDR:%.*]]) ] +; CHECK-NEXT: [[RES2:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[P2:%.*]]) [ "ptrauth"(i64 2, i64 1234, i64 [[ADDR]]) ] ; CHECK-NEXT: ret void ; %tmp = call i64 @llvm.ptrauth.blend(i64 %addr, i64 1234) @@ -99,7 +99,7 @@ define void @test_ptrauth_reused_blend(i64 %p1, i64 %p2, i64 %addr) { define void @test_ptrauth_reused_blend_same_inst(i64 %p, i64 %addr) { ; CHECK-LABEL: @test_ptrauth_reused_blend_same_inst( -; CHECK-NEXT: [[RES:%.*]] = call i64 @llvm.ptrauth.resign(i64 [[P:%.*]]) [ "ptrauth"(i64 1, i64 [[ADDR:%.*]], i64 1234), "ptrauth"(i64 2, i64 [[ADDR]], i64 1234) ] +; CHECK-NEXT: [[RES:%.*]] = call i64 @llvm.ptrauth.resign(i64 [[P:%.*]]) [ "ptrauth"(i64 1, i64 1234, i64 [[ADDR:%.*]]), "ptrauth"(i64 2, i64 1234, i64 [[ADDR]]) ] ; CHECK-NEXT: ret void ; %tmp = call i64 @llvm.ptrauth.blend(i64 %addr, i64 1234) @@ -112,7 +112,7 @@ define void @test_ptrauth_blend_in_other_bb(i64 %p, i64 %addr) { ; CHECK-NEXT: entry: ; CHECK-NEXT: br label [[EXIT:%.*]] ; CHECK: exit: -; CHECK-NEXT: [[RES:%.*]] = call i64 @llvm.ptrauth.resign(i64 [[P:%.*]]) [ "ptrauth"(i64 1, i64 [[ADDR:%.*]], i64 1234), "ptrauth"(i64 2, i64 [[ADDR]], i64 1234) ] +; CHECK-NEXT: [[RES:%.*]] = call i64 @llvm.ptrauth.resign(i64 [[P:%.*]]) [ "ptrauth"(i64 1, i64 1234, i64 [[ADDR:%.*]]), "ptrauth"(i64 2, i64 1234, i64 [[ADDR]]) ] ; CHECK-NEXT: ret void ; entry: diff --git a/llvm/test/CodeGen/AArch64/ptrauth-invalid-upgrade.ll b/llvm/test/CodeGen/AArch64/ptrauth-invalid-upgrade.ll index 7241abe141f9e..b9d523a659799 100644 --- a/llvm/test/CodeGen/AArch64/ptrauth-invalid-upgrade.ll +++ b/llvm/test/CodeGen/AArch64/ptrauth-invalid-upgrade.ll @@ -104,7 +104,7 @@ define void @test(i64 %p, ptr %auth_like_fn, i64 %addr) { ; "ptrauth" operand bundles must be indirect. ; DIRECT-THREE-ARGS: Direct call cannot have a ptrauth bundle -; DIRECT-THREE-ARGS-NEXT: call void @auth_like_fn(i64 %p, i32 0, i64 0) [ "ptrauth"(i64 1, i64 %addr, i64 42) ] +; DIRECT-THREE-ARGS-NEXT: call void @auth_like_fn(i64 %p, i32 0, i64 0) [ "ptrauth"(i64 1, i64 42, i64 %addr) ] ; DIRECT-THREE-ARGS-NEXT: error: input module is broken! declare void @auth_like_fn(i64 %0, i32 %1, i64 %2) @@ -121,27 +121,20 @@ define void @test(i64 %p, i64 %addr) { ; This test case does not involve auto-upgrading, but it shows the behavior of ; the IR verifier if any unrelated intrinsic would be formally auto-upgraded. -; WRONG-INTRINSIC-WITH-PTRAUTH-BUNDLE: Unexpected ptrauth bundle on intrinsic call -; WRONG-INTRINSIC-WITH-PTRAUTH-BUNDLE-NEXT: %1 = call i64 @llvm.ptrauth.sign.generic(i64 %p, i64 0) [ "ptrauth"(i64 1, i64 %addr, i64 42) ] +; WRONG-INTRINSIC-WITH-PTRAUTH-BUNDLE: Unexpected ptrauth bundle +; WRONG-INTRINSIC-WITH-PTRAUTH-BUNDLE-NEXT: %1 = call i64 @llvm.ptrauth.sign.generic(i64 %p, i64 0) [ "ptrauth"(i64 1, i64 42, i64 %addr) ] ; WRONG-INTRINSIC-WITH-PTRAUTH-BUNDLE-NEXT: /data/ast/llvm-project/build/bin/opt: -: error: input module is broken! define void @test(i64 %p, ptr %auth_like_fn, i64 %addr) { - %disc = call i64 @llvm.ptrauth.blend(i64 %addr, i64 42) ; The below call uses the new-style all-i64 ptrauth bundle. - call i64 @llvm.ptrauth.sign.generic(i64 %p, i64 0) [ "ptrauth"(i64 1, i64 %disc) ] + call i64 @llvm.ptrauth.sign.generic(i64 %p, i64 0) [ "ptrauth"(i64 1, i64 42, i64 %addr) ] ret void } ;--- wrong-position-in-bundle.ll ; RUN: not opt -passes=verify -S < %t/wrong-position-in-bundle.ll 2>&1 | FileCheck --check-prefix=WRONG-POSITION-IN-BUNDLE %s -; WRONG-POSITION-IN-BUNDLE: Cannot upgrade all uses of @llvm.ptrauth.blend in function: -; WRONG-POSITION-IN-BUNDLE-NEXT: define void @test(i64 %p, i64 %addr) { -; WRONG-POSITION-IN-BUNDLE-NEXT: %disc = call i64 @llvm.ptrauth.blend(i64 %addr, i64 42) -; WRONG-POSITION-IN-BUNDLE-NEXT: %1 = call i64 @llvm.ptrauth.auth(i64 %p) [ "ptrauth"(i64 %disc, i64 1) ] -; WRONG-POSITION-IN-BUNDLE-NEXT: ret void -; WRONG-POSITION-IN-BUNDLE-NEXT: } -; WRONG-POSITION-IN-BUNDLE-NEXT: LLVM ERROR: Cannot upgrade some uses of @llvm.ptrauth.blend(). +; WRONG-POSITION-IN-BUNDLE: LLVM ERROR: Cannot upgrade: expected constant ptrauth key ID define void @test(i64 %p, i64 %addr) { %disc = call i64 @llvm.ptrauth.blend(i64 %addr, i64 42) @@ -152,13 +145,7 @@ define void @test(i64 %p, i64 %addr) { ;--- both-positions-in-bundle.ll ; RUN: not opt -passes=verify -S < %t/both-positions-in-bundle.ll 2>&1 | FileCheck --check-prefix=BOTH-POSITIONS-IN-BUNDLE %s -; BOTH-POSITIONS-IN-BUNDLE: Cannot upgrade all uses of @llvm.ptrauth.blend in function: -; BOTH-POSITIONS-IN-BUNDLE-NEXT: define void @test(i64 %p, i64 %addr) { -; BOTH-POSITIONS-IN-BUNDLE-NEXT: %disc = call i64 @llvm.ptrauth.blend(i64 %addr, i64 42) -; BOTH-POSITIONS-IN-BUNDLE-NEXT: %1 = call i64 @llvm.ptrauth.auth(i64 %p) [ "ptrauth"(i64 %disc, i64 %addr, i64 42) ] -; BOTH-POSITIONS-IN-BUNDLE-NEXT: ret void -; BOTH-POSITIONS-IN-BUNDLE-NEXT: } -; BOTH-POSITIONS-IN-BUNDLE-NEXT: LLVM ERROR: Cannot upgrade some uses of @llvm.ptrauth.blend(). +; BOTH-POSITIONS-IN-BUNDLE: LLVM ERROR: Cannot upgrade: expected constant ptrauth key ID define void @test(i64 %p, i64 %addr) { %disc = call i64 @llvm.ptrauth.blend(i64 %addr, i64 42) diff --git a/llvm/test/CodeGen/AArch64/ptrauth-invoke.ll b/llvm/test/CodeGen/AArch64/ptrauth-invoke.ll index c3ec3953da900..d93152c1408c9 100644 --- a/llvm/test/CodeGen/AArch64/ptrauth-invoke.ll +++ b/llvm/test/CodeGen/AArch64/ptrauth-invoke.ll @@ -83,7 +83,7 @@ ; CHECK-NEXT: .byte 0 {{.*}} On action: cleanup define i32 @test_invoke_ia_0(ptr %arg0) #0 personality ptr @__gxx_personality_v0 { - %tmp0 = invoke i32 %arg0() [ "ptrauth"(i64 0, i64 0) ] to label %continuebb + %tmp0 = invoke i32 %arg0() [ "ptrauth"(i64 0, i64 0, i64 0) ] to label %continuebb unwind label %unwindbb unwindbb: @@ -233,7 +233,7 @@ continuebb: define void @test_invoke_ib_42_catch(ptr %fptr) #0 personality ptr @__gxx_personality_v0 { %tmp0 = call ptr @__cxa_allocate_exception(i64 8) store ptr getelementptr inbounds ([6 x i8], ptr @hello_str, i64 0, i64 0), ptr %tmp0, align 8 - invoke void %fptr(ptr %tmp0, ptr @_ZTIPKc, ptr null) [ "ptrauth"(i64 1, i64 42) ] + invoke void %fptr(ptr %tmp0, ptr @_ZTIPKc, ptr null) [ "ptrauth"(i64 1, i64 42, i64 0) ] to label %continuebb unwind label %catchbb catchbb: @@ -331,7 +331,7 @@ continuebb: ; CHECK-NEXT: .byte 0 {{.*}} On action: cleanup define i32 @test_invoke_ia_0_direct() #0 personality ptr @__gxx_personality_v0 { - %tmp0 = invoke i32 ptrauth (ptr @baz, i32 0)() [ "ptrauth"(i64 0, i64 0) ] to label %continuebb + %tmp0 = invoke i32 ptrauth (ptr @baz, i32 0)() [ "ptrauth"(i64 0, i64 0, i64 0) ] to label %continuebb unwind label %unwindbb unwindbb: @@ -443,7 +443,7 @@ continuebb: ; CHECK-NEXT: .byte 0 {{.*}} On action: cleanup define i32 @test_invoke_ib_2_direct_mismatch() #0 personality ptr @__gxx_personality_v0 { - %tmp0 = invoke i32 ptrauth (ptr @baz, i32 0, i64 1234)() [ "ptrauth"(i64 1, i64 2) ] to label %continuebb + %tmp0 = invoke i32 ptrauth (ptr @baz, i32 0, i64 1234)() [ "ptrauth"(i64 1, i64 2, i64 0) ] to label %continuebb unwind label %unwindbb unwindbb: diff --git a/llvm/test/CodeGen/AArch64/ptrauth-isel.ll b/llvm/test/CodeGen/AArch64/ptrauth-isel.ll index add5fb289056f..da8a2b48b1733 100644 --- a/llvm/test/CodeGen/AArch64/ptrauth-isel.ll +++ b/llvm/test/CodeGen/AArch64/ptrauth-isel.ll @@ -46,7 +46,7 @@ define i64 @small_imm_disc_optimized(i64 %addr) { ; GISEL-NEXT: $x0 = COPY [[PAC]] ; GISEL-NEXT: RET_ReallyLR implicit $x0 entry: - %signed = call i64 @llvm.ptrauth.sign(i64 %addr) [ "ptrauth"(i64 2, i64 42) ] + %signed = call i64 @llvm.ptrauth.sign(i64 %addr) [ "ptrauth"(i64 2, i64 42, i64 0) ] ret i64 %signed } @@ -71,7 +71,7 @@ define i64 @small_imm_disc_non_optimized(i64 %addr) noinline optnone { ; GISEL-NEXT: $x0 = COPY [[PAC]] ; GISEL-NEXT: RET_ReallyLR implicit $x0 entry: - %signed = call i64 @llvm.ptrauth.sign(i64 %addr) [ "ptrauth"(i64 2, i64 42) ] + %signed = call i64 @llvm.ptrauth.sign(i64 %addr) [ "ptrauth"(i64 2, i64 42, i64 0) ] ret i64 %signed } @@ -98,7 +98,7 @@ define i64 @large_imm_disc(i64 %addr) { ; GISEL-NEXT: $x0 = COPY [[PAC]] ; GISEL-NEXT: RET_ReallyLR implicit $x0 entry: - %signed = call i64 @llvm.ptrauth.sign(i64 %addr) [ "ptrauth"(i64 2, i64 12345678) ] + %signed = call i64 @llvm.ptrauth.sign(i64 %addr) [ "ptrauth"(i64 2, i64 0, i64 12345678) ] ret i64 %signed } @@ -126,6 +126,6 @@ define i64 @blended_disc(i64 %addr) { ; GISEL-NEXT: RET_ReallyLR implicit $x0 entry: %addrdisc = load i64, ptr @discvar - %signed = call i64 @llvm.ptrauth.sign(i64 %addr) [ "ptrauth"(i64 2, i64 %addrdisc, i64 42) ] + %signed = call i64 @llvm.ptrauth.sign(i64 %addr) [ "ptrauth"(i64 2, i64 42, i64 %addrdisc) ] ret i64 %signed } diff --git a/llvm/test/CodeGen/AArch64/ptrauth-ret-trap.ll b/llvm/test/CodeGen/AArch64/ptrauth-ret-trap.ll index 268a2d2161ca2..9c9e6f6faf356 100644 --- a/llvm/test/CodeGen/AArch64/ptrauth-ret-trap.ll +++ b/llvm/test/CodeGen/AArch64/ptrauth-ret-trap.ll @@ -75,7 +75,7 @@ define void @test_auth_tailcall_indirect(ptr %fptr) #0 { define void @test_auth_tailcall_indirect_in_x9(ptr sret(i64) %ret, [8 x i64] %in, ptr %fptr) #0 { %ptr = alloca i8, i32 16 call i32 @test_tailcall() - tail call void %fptr(ptr sret(i64) %ret, [8 x i64] %in) [ "ptrauth"(i64 1, i64 0) ] + tail call void %fptr(ptr sret(i64) %ret, [8 x i64] %in) [ "ptrauth"(i64 1, i64 0, i64 0) ] ret void } @@ -89,7 +89,7 @@ define void @test_auth_tailcall_indirect_in_x9(ptr sret(i64) %ret, [8 x i64] %in define void @test_auth_tailcall_indirect_bti(ptr sret(i64) %ret, [8 x i64] %in, ptr %fptr) #0 "branch-target-enforcement"="true" { %ptr = alloca i8, i32 16 call i32 @test_tailcall() - tail call void %fptr(ptr sret(i64) %ret, [8 x i64] %in) [ "ptrauth"(i64 1, i64 0) ] + tail call void %fptr(ptr sret(i64) %ret, [8 x i64] %in) [ "ptrauth"(i64 1, i64 0, i64 0) ] ret void } diff --git a/llvm/test/CodeGen/AArch64/ptrauth-tail-call-regalloc.ll b/llvm/test/CodeGen/AArch64/ptrauth-tail-call-regalloc.ll index 09093ad1f13b0..a159effb8671b 100644 --- a/llvm/test/CodeGen/AArch64/ptrauth-tail-call-regalloc.ll +++ b/llvm/test/CodeGen/AArch64/ptrauth-tail-call-regalloc.ll @@ -20,7 +20,7 @@ entry: tail call void asm sideeffect "", "~{x0},~{x1},~{x2},~{x3},~{x4},~{x5},~{x6},~{x7},~{x8},~{x9},~{x10},~{x11},~{x12},~{x13},~{x14},~{x15}"() tail call void asm sideeffect "", "~{x18},~{x19},~{x20},~{x21},~{x22},~{x23},~{x24},~{x25},~{x26},~{x27},~{x28},~{fp}"() %addr.i = ptrtoint ptr %addr to i64 - %call = tail call i32 %callee() #1 [ "ptrauth"(i64 0, i64 %addr.i) ] + %call = tail call i32 %callee() #1 [ "ptrauth"(i64 0, i64 0, i64 %addr.i) ] ret i32 %call } ;; Ensure the specific tail call pseudo instruction is used. @@ -70,7 +70,7 @@ entry: tail call void asm sideeffect "", "~{x0},~{x1},~{x2},~{x3},~{x4},~{x5},~{x6},~{x7},~{x8},~{x9},~{x10},~{x11},~{x12},~{x13},~{x14},~{x15}"() tail call void asm sideeffect "", "~{x18},~{x19},~{x20},~{x21},~{x22},~{x23},~{x24},~{x25},~{x26},~{x27},~{x28},~{fp}"() %addr.i = ptrtoint ptr %addr to i64 - %call = tail call i32 %callee() #1 [ "ptrauth"(i64 0, i64 %addr.i) ] + %call = tail call i32 %callee() #1 [ "ptrauth"(i64 0, i64 0, i64 %addr.i) ] ret i32 %call } ;; Ensure the specific tail call pseudo instruction is used. diff --git a/llvm/test/CodeGen/MIR/AArch64/deactivation-symbols.mir b/llvm/test/CodeGen/MIR/AArch64/deactivation-symbols.mir index 9dd8b3d0de4ae..573954ed2501e 100644 --- a/llvm/test/CodeGen/MIR/AArch64/deactivation-symbols.mir +++ b/llvm/test/CodeGen/MIR/AArch64/deactivation-symbols.mir @@ -5,8 +5,8 @@ @ds = external global i8 define i64 @pauth_sign_zero(i64 %p) { - ; CHECK: G_PTRAUTH_SIGN %0, %2(s0), deactivation-symbol @ds - %signed = call i64 @llvm.ptrauth.sign(i64 %p) [ "ptrauth"(i64 0, i64 0), "deactivation-symbol"(ptr @ds) ] + ; CHECK: G_PTRAUTH_SIGN %0, %1(s0), deactivation-symbol @ds + %signed = call i64 @llvm.ptrauth.sign(i64 %p) [ "ptrauth"(i64 0, i64 0, i64 0), "deactivation-symbol"(ptr @ds) ] ret i64 %signed } ... diff --git a/llvm/test/Transforms/InstCombine/ptrauth-call.ll b/llvm/test/Transforms/InstCombine/ptrauth-call.ll index 092efb0284a05..9af54b7bc0319 100644 --- a/llvm/test/Transforms/InstCombine/ptrauth-call.ll +++ b/llvm/test/Transforms/InstCombine/ptrauth-call.ll @@ -9,7 +9,7 @@ define i32 @test_ptrauth_call(i32 %a0) { ; CHECK-NEXT: [[V0:%.*]] = call i32 @f(i32 [[A0:%.*]]) ; CHECK-NEXT: ret i32 [[V0]] ; - %v0 = call i32 ptrauth(ptr @f, i32 0)(i32 %a0) [ "ptrauth"(i64 0, i64 0) ] + %v0 = call i32 ptrauth(ptr @f, i32 0)(i32 %a0) [ "ptrauth"(i64 0, i64 0, i64 0) ] ret i32 %v0 } @@ -18,7 +18,7 @@ define i32 @test_ptrauth_call_disc(i32 %a0) { ; CHECK-NEXT: [[V0:%.*]] = call i32 @f(i32 [[A0:%.*]]) ; CHECK-NEXT: ret i32 [[V0]] ; - %v0 = call i32 ptrauth(ptr @f, i32 1, i64 5678)(i32 %a0) [ "ptrauth"(i64 1, i64 5678) ] + %v0 = call i32 ptrauth(ptr @f, i32 1, i64 5678)(i32 %a0) [ "ptrauth"(i64 1, i64 5678, i64 0) ] ret i32 %v0 } @@ -29,7 +29,7 @@ define i32 @test_ptrauth_call_addr_disc(i32 %a0) { ; CHECK-NEXT: [[V0:%.*]] = call i32 @f(i32 [[A0:%.*]]) ; CHECK-NEXT: ret i32 [[V0]] ; - %v0 = call i32 ptrauth(ptr @f, i32 1, i64 0, ptr @f_addr_disc.ref)(i32 %a0) [ "ptrauth"(i64 1, i64 ptrtoint (ptr @f_addr_disc.ref to i64)) ] + %v0 = call i32 ptrauth(ptr @f, i32 1, i64 0, ptr @f_addr_disc.ref)(i32 %a0) [ "ptrauth"(i64 1, i64 0, i64 ptrtoint (ptr @f_addr_disc.ref to i64)) ] ret i32 %v0 } @@ -40,7 +40,7 @@ define i32 @test_ptrauth_call_blend(i32 %a0) { ; CHECK-NEXT: [[V0:%.*]] = call i32 @f(i32 [[A0:%.*]]) ; CHECK-NEXT: ret i32 [[V0]] ; - %v0 = call i32 ptrauth(ptr @f, i32 1, i64 1234, ptr @f_both_disc.ref)(i32 %a0) [ "ptrauth"(i64 1, i64 ptrtoint (ptr @f_both_disc.ref to i64), i64 1234) ] + %v0 = call i32 ptrauth(ptr @f, i32 1, i64 1234, ptr @f_both_disc.ref)(i32 %a0) [ "ptrauth"(i64 1, i64 1234, i64 ptrtoint (ptr @f_both_disc.ref to i64)) ] ret i32 %v0 } @@ -49,42 +49,42 @@ define i64 @test_ptrauth_call_cast(i32 %a0) { ; CHECK-NEXT: [[V0:%.*]] = call i64 @f2(i32 [[A0:%.*]]) ; CHECK-NEXT: ret i64 [[V0]] ; - %v0 = call i64 ptrauth(ptr @f2, i32 0)(i32 %a0) [ "ptrauth"(i64 0, i64 0) ] + %v0 = call i64 ptrauth(ptr @f2, i32 0)(i32 %a0) [ "ptrauth"(i64 0, i64 0, i64 0) ] ret i64 %v0 } define i32 @test_ptrauth_call_mismatch_key(i32 %a0) { ; CHECK-LABEL: @test_ptrauth_call_mismatch_key( -; CHECK-NEXT: [[V0:%.*]] = call i32 ptrauth (ptr @f, i32 1, i64 5678)(i32 [[A0:%.*]]) [ "ptrauth"(i64 0, i64 5678) ] +; CHECK-NEXT: [[V0:%.*]] = call i32 ptrauth (ptr @f, i32 1, i64 5678)(i32 [[A0:%.*]]) [ "ptrauth"(i64 0, i64 5678, i64 0) ] ; CHECK-NEXT: ret i32 [[V0]] ; - %v0 = call i32 ptrauth(ptr @f, i32 1, i64 5678)(i32 %a0) [ "ptrauth"(i64 0, i64 5678) ] + %v0 = call i32 ptrauth(ptr @f, i32 1, i64 5678)(i32 %a0) [ "ptrauth"(i64 0, i64 5678, i64 0) ] ret i32 %v0 } define i32 @test_ptrauth_call_mismatch_disc(i32 %a0) { ; CHECK-LABEL: @test_ptrauth_call_mismatch_disc( -; CHECK-NEXT: [[V0:%.*]] = call i32 ptrauth (ptr @f, i32 1, i64 5678)(i32 [[A0:%.*]]) [ "ptrauth"(i64 1, i64 0) ] +; CHECK-NEXT: [[V0:%.*]] = call i32 ptrauth (ptr @f, i32 1, i64 5678)(i32 [[A0:%.*]]) [ "ptrauth"(i64 1, i64 0, i64 0) ] ; CHECK-NEXT: ret i32 [[V0]] ; - %v0 = call i32 ptrauth(ptr @f, i32 1, i64 5678)(i32 %a0) [ "ptrauth"(i64 1, i64 0) ] + %v0 = call i32 ptrauth(ptr @f, i32 1, i64 5678)(i32 %a0) [ "ptrauth"(i64 1, i64 0, i64 0) ] ret i32 %v0 } define i32 @test_ptrauth_call_mismatch_blend(i32 %a0) { ; CHECK-LABEL: @test_ptrauth_call_mismatch_blend( -; CHECK-NEXT: [[V0:%.*]] = call i32 ptrauth (ptr @f, i32 1, i64 1234, ptr @f_both_disc.ref)(i32 [[A0:%.*]]) [ "ptrauth"(i64 1, i64 ptrtoint (ptr @f_both_disc.ref to i64), i64 0) ] +; CHECK-NEXT: [[V0:%.*]] = call i32 ptrauth (ptr @f, i32 1, i64 1234, ptr @f_both_disc.ref)(i32 [[A0:%.*]]) [ "ptrauth"(i64 1, i64 0, i64 ptrtoint (ptr @f_both_disc.ref to i64)) ] ; CHECK-NEXT: ret i32 [[V0]] ; - %v0 = call i32 ptrauth(ptr @f, i32 1, i64 1234, ptr @f_both_disc.ref)(i32 %a0) [ "ptrauth"(i64 1, i64 ptrtoint (ptr @f_both_disc.ref to i64), i64 0) ] + %v0 = call i32 ptrauth(ptr @f, i32 1, i64 1234, ptr @f_both_disc.ref)(i32 %a0) [ "ptrauth"(i64 1, i64 0, i64 ptrtoint (ptr @f_both_disc.ref to i64)) ] ret i32 %v0 } define i32 @test_ptrauth_call_mismatch_blend_addr(i32 %a0) { ; CHECK-LABEL: @test_ptrauth_call_mismatch_blend_addr( -; CHECK-NEXT: [[V0:%.*]] = call i32 ptrauth (ptr @f, i32 1, i64 1234, ptr @f_both_disc.ref)(i32 [[A0:%.*]]) [ "ptrauth"(i64 1, i64 ptrtoint (ptr @f_addr_disc.ref to i64), i64 1234) ] +; CHECK-NEXT: [[V0:%.*]] = call i32 ptrauth (ptr @f, i32 1, i64 1234, ptr @f_both_disc.ref)(i32 [[A0:%.*]]) [ "ptrauth"(i64 1, i64 1234, i64 ptrtoint (ptr @f_addr_disc.ref to i64)) ] ; CHECK-NEXT: ret i32 [[V0]] ; - %v0 = call i32 ptrauth(ptr @f, i32 1, i64 1234, ptr @f_both_disc.ref)(i32 %a0) [ "ptrauth"(i64 1, i64 ptrtoint (ptr @f_addr_disc.ref to i64), i64 1234) ] + %v0 = call i32 ptrauth(ptr @f, i32 1, i64 1234, ptr @f_both_disc.ref)(i32 %a0) [ "ptrauth"(i64 1, i64 1234, i64 ptrtoint (ptr @f_addr_disc.ref to i64)) ] ret i32 %v0 } diff --git a/llvm/test/Transforms/InstCombine/ptrauth-intrinsics.ll b/llvm/test/Transforms/InstCombine/ptrauth-intrinsics.ll index c65683e557dde..c5b1a3cee6574 100644 --- a/llvm/test/Transforms/InstCombine/ptrauth-intrinsics.ll +++ b/llvm/test/Transforms/InstCombine/ptrauth-intrinsics.ll @@ -7,8 +7,8 @@ define i64 @test_ptrauth_nop(ptr %p) { ; CHECK-NEXT: ret i64 [[TMP0]] ; %tmp0 = ptrtoint ptr %p to i64 - %signed = call i64 @llvm.ptrauth.sign(i64 %tmp0) [ "ptrauth"(i64 1, i64 1234) ] - %authed = call i64 @llvm.ptrauth.auth(i64 %signed) [ "ptrauth"(i64 1, i64 1234) ] + %signed = call i64 @llvm.ptrauth.sign(i64 %tmp0) [ "ptrauth"(i64 1, i64 1234, i64 0) ] + %authed = call i64 @llvm.ptrauth.auth(i64 %signed) [ "ptrauth"(i64 1, i64 1234, i64 0) ] ret i64 %authed } @@ -19,7 +19,7 @@ define i64 @test_ptrauth_nop_constant() { ; CHECK-LABEL: @test_ptrauth_nop_constant( ; CHECK-NEXT: ret i64 ptrtoint (ptr @foo to i64) ; - %authed = call i64 @llvm.ptrauth.auth(i64 ptrtoint(ptr ptrauth(ptr @foo, i32 1, i64 1234) to i64)) [ "ptrauth"(i64 1, i64 1234) ] + %authed = call i64 @llvm.ptrauth.auth(i64 ptrtoint(ptr ptrauth(ptr @foo, i32 1, i64 1234) to i64)) [ "ptrauth"(i64 1, i64 1234, i64 0) ] ret i64 %authed } @@ -28,120 +28,120 @@ define i64 @test_ptrauth_nop_constant_addrdisc() { ; CHECK-NEXT: ret i64 ptrtoint (ptr @foo to i64) ; %addr = ptrtoint ptr @foo to i64 - %authed = call i64 @llvm.ptrauth.auth(i64 ptrtoint(ptr ptrauth(ptr @foo, i32 1, i64 1234, ptr @foo) to i64)) [ "ptrauth"(i64 1, i64 %addr, i64 1234) ] + %authed = call i64 @llvm.ptrauth.auth(i64 ptrtoint(ptr ptrauth(ptr @foo, i32 1, i64 1234, ptr @foo) to i64)) [ "ptrauth"(i64 1, i64 1234, i64 %addr) ] ret i64 %authed } define i64 @test_ptrauth_nop_mismatch(ptr %p) { ; CHECK-LABEL: @test_ptrauth_nop_mismatch( ; CHECK-NEXT: [[TMP0:%.*]] = ptrtoint ptr [[P:%.*]] to i64 -; CHECK-NEXT: [[SIGNED:%.*]] = call i64 @llvm.ptrauth.sign(i64 [[TMP0]]) [ "ptrauth"(i64 1, i64 1234) ] -; CHECK-NEXT: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[SIGNED]]) [ "ptrauth"(i64 1, i64 10) ] +; CHECK-NEXT: [[SIGNED:%.*]] = call i64 @llvm.ptrauth.sign(i64 [[TMP0]]) [ "ptrauth"(i64 1, i64 1234, i64 0) ] +; CHECK-NEXT: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[SIGNED]]) [ "ptrauth"(i64 1, i64 10, i64 0) ] ; CHECK-NEXT: ret i64 [[AUTHED]] ; %tmp0 = ptrtoint ptr %p to i64 - %signed = call i64 @llvm.ptrauth.sign(i64 %tmp0) [ "ptrauth"(i64 1, i64 1234) ] - %authed = call i64 @llvm.ptrauth.auth(i64 %signed) [ "ptrauth"(i64 1, i64 10) ] + %signed = call i64 @llvm.ptrauth.sign(i64 %tmp0) [ "ptrauth"(i64 1, i64 1234, i64 0) ] + %authed = call i64 @llvm.ptrauth.auth(i64 %signed) [ "ptrauth"(i64 1, i64 10, i64 0) ] ret i64 %authed } define i64 @test_ptrauth_nop_mismatch_keys(ptr %p) { ; CHECK-LABEL: @test_ptrauth_nop_mismatch_keys( ; CHECK-NEXT: [[TMP0:%.*]] = ptrtoint ptr [[P:%.*]] to i64 -; CHECK-NEXT: [[SIGNED:%.*]] = call i64 @llvm.ptrauth.sign(i64 [[TMP0]]) [ "ptrauth"(i64 0, i64 1234) ] -; CHECK-NEXT: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[SIGNED]]) [ "ptrauth"(i64 1, i64 1234) ] +; CHECK-NEXT: [[SIGNED:%.*]] = call i64 @llvm.ptrauth.sign(i64 [[TMP0]]) [ "ptrauth"(i64 0, i64 1234, i64 0) ] +; CHECK-NEXT: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[SIGNED]]) [ "ptrauth"(i64 1, i64 1234, i64 0) ] ; CHECK-NEXT: ret i64 [[AUTHED]] ; %tmp0 = ptrtoint ptr %p to i64 - %signed = call i64 @llvm.ptrauth.sign(i64 %tmp0) [ "ptrauth"(i64 0, i64 1234) ] - %authed = call i64 @llvm.ptrauth.auth(i64 %signed) [ "ptrauth"(i64 1, i64 1234) ] + %signed = call i64 @llvm.ptrauth.sign(i64 %tmp0) [ "ptrauth"(i64 0, i64 1234, i64 0) ] + %authed = call i64 @llvm.ptrauth.auth(i64 %signed) [ "ptrauth"(i64 1, i64 1234, i64 0) ] ret i64 %authed } define i64 @test_ptrauth_sign_resign(ptr %p) { ; CHECK-LABEL: @test_ptrauth_sign_resign( ; CHECK-NEXT: [[TMP0:%.*]] = ptrtoint ptr [[P:%.*]] to i64 -; CHECK-NEXT: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.sign(i64 [[TMP0]]) [ "ptrauth"(i64 0, i64 42) ] +; CHECK-NEXT: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.sign(i64 [[TMP0]]) [ "ptrauth"(i64 0, i64 42, i64 0) ] ; CHECK-NEXT: ret i64 [[AUTHED]] ; %tmp0 = ptrtoint ptr %p to i64 - %signed = call i64 @llvm.ptrauth.sign(i64 %tmp0) [ "ptrauth"(i64 1, i64 1234) ] - %authed = call i64 @llvm.ptrauth.resign(i64 %signed) [ "ptrauth"(i64 1, i64 1234), "ptrauth"(i64 0, i64 42) ] + %signed = call i64 @llvm.ptrauth.sign(i64 %tmp0) [ "ptrauth"(i64 1, i64 1234, i64 0) ] + %authed = call i64 @llvm.ptrauth.resign(i64 %signed) [ "ptrauth"(i64 1, i64 1234, i64 0), "ptrauth"(i64 0, i64 42, i64 0) ] ret i64 %authed } define i64 @test_ptrauth_resign_resign(ptr %p) { ; CHECK-LABEL: @test_ptrauth_resign_resign( ; CHECK-NEXT: [[TMP0:%.*]] = ptrtoint ptr [[P:%.*]] to i64 -; CHECK-NEXT: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.resign(i64 [[TMP0]]) [ "ptrauth"(i64 1, i64 1234), "ptrauth"(i64 1, i64 3141) ] +; CHECK-NEXT: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.resign(i64 [[TMP0]]) [ "ptrauth"(i64 1, i64 1234, i64 0), "ptrauth"(i64 1, i64 3141, i64 0) ] ; CHECK-NEXT: ret i64 [[AUTHED]] ; %tmp0 = ptrtoint ptr %p to i64 - %signed = call i64 @llvm.ptrauth.resign(i64 %tmp0) [ "ptrauth"(i64 1, i64 1234), "ptrauth"(i64 0, i64 42) ] - %authed = call i64 @llvm.ptrauth.resign(i64 %signed) [ "ptrauth"(i64 0, i64 42), "ptrauth"(i64 1, i64 3141) ] + %signed = call i64 @llvm.ptrauth.resign(i64 %tmp0) [ "ptrauth"(i64 1, i64 1234, i64 0), "ptrauth"(i64 0, i64 42, i64 0) ] + %authed = call i64 @llvm.ptrauth.resign(i64 %signed) [ "ptrauth"(i64 0, i64 42, i64 0), "ptrauth"(i64 1, i64 3141, i64 0) ] ret i64 %authed } define i64 @test_ptrauth_resign_auth(ptr %p) { ; CHECK-LABEL: @test_ptrauth_resign_auth( ; CHECK-NEXT: [[TMP0:%.*]] = ptrtoint ptr [[P:%.*]] to i64 -; CHECK-NEXT: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[TMP0]]) [ "ptrauth"(i64 1, i64 1234) ] +; CHECK-NEXT: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[TMP0]]) [ "ptrauth"(i64 1, i64 1234, i64 0) ] ; CHECK-NEXT: ret i64 [[AUTHED]] ; %tmp0 = ptrtoint ptr %p to i64 - %signed = call i64 @llvm.ptrauth.resign(i64 %tmp0) [ "ptrauth"(i64 1, i64 1234), "ptrauth"(i64 0, i64 42) ] - %authed = call i64 @llvm.ptrauth.auth(i64 %signed) [ "ptrauth"(i64 0, i64 42) ] + %signed = call i64 @llvm.ptrauth.resign(i64 %tmp0) [ "ptrauth"(i64 1, i64 1234, i64 0), "ptrauth"(i64 0, i64 42, i64 0) ] + %authed = call i64 @llvm.ptrauth.auth(i64 %signed) [ "ptrauth"(i64 0, i64 42, i64 0) ] ret i64 %authed } define i64 @test_ptrauth_resign_auth_mismatch(ptr %p) { ; CHECK-LABEL: @test_ptrauth_resign_auth_mismatch( ; CHECK-NEXT: [[TMP0:%.*]] = ptrtoint ptr [[P:%.*]] to i64 -; CHECK-NEXT: [[SIGNED:%.*]] = call i64 @llvm.ptrauth.resign(i64 [[TMP0]]) [ "ptrauth"(i64 1, i64 1234), "ptrauth"(i64 0, i64 10) ] -; CHECK-NEXT: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[SIGNED]]) [ "ptrauth"(i64 0, i64 42) ] +; CHECK-NEXT: [[SIGNED:%.*]] = call i64 @llvm.ptrauth.resign(i64 [[TMP0]]) [ "ptrauth"(i64 1, i64 1234, i64 0), "ptrauth"(i64 0, i64 10, i64 0) ] +; CHECK-NEXT: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[SIGNED]]) [ "ptrauth"(i64 0, i64 42, i64 0) ] ; CHECK-NEXT: ret i64 [[AUTHED]] ; %tmp0 = ptrtoint ptr %p to i64 - %signed = call i64 @llvm.ptrauth.resign(i64 %tmp0) [ "ptrauth"(i64 1, i64 1234), "ptrauth"(i64 0, i64 10) ] - %authed = call i64 @llvm.ptrauth.auth(i64 %signed) [ "ptrauth"(i64 0, i64 42) ] + %signed = call i64 @llvm.ptrauth.resign(i64 %tmp0) [ "ptrauth"(i64 1, i64 1234, i64 0), "ptrauth"(i64 0, i64 10, i64 0) ] + %authed = call i64 @llvm.ptrauth.auth(i64 %signed) [ "ptrauth"(i64 0, i64 42, i64 0) ] ret i64 %authed } define i64 @test_ptrauth_nop_constant_mismatch() { ; CHECK-LABEL: @test_ptrauth_nop_constant_mismatch( -; CHECK-NEXT: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 ptrtoint (ptr ptrauth (ptr @foo, i32 1, i64 1234) to i64)) [ "ptrauth"(i64 1, i64 12) ] +; CHECK-NEXT: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 ptrtoint (ptr ptrauth (ptr @foo, i32 1, i64 1234) to i64)) [ "ptrauth"(i64 1, i64 12, i64 0) ] ; CHECK-NEXT: ret i64 [[AUTHED]] ; - %authed = call i64 @llvm.ptrauth.auth(i64 ptrtoint(ptr ptrauth(ptr @foo, i32 1, i64 1234) to i64)) [ "ptrauth"(i64 1, i64 12) ] + %authed = call i64 @llvm.ptrauth.auth(i64 ptrtoint(ptr ptrauth(ptr @foo, i32 1, i64 1234) to i64)) [ "ptrauth"(i64 1, i64 12, i64 0) ] ret i64 %authed } define i64 @test_ptrauth_nop_constant_mismatch_key() { ; CHECK-LABEL: @test_ptrauth_nop_constant_mismatch_key( -; CHECK-NEXT: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 ptrtoint (ptr ptrauth (ptr @foo, i32 1, i64 1234) to i64)) [ "ptrauth"(i64 0, i64 1234) ] +; CHECK-NEXT: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 ptrtoint (ptr ptrauth (ptr @foo, i32 1, i64 1234) to i64)) [ "ptrauth"(i64 0, i64 1234, i64 0) ] ; CHECK-NEXT: ret i64 [[AUTHED]] ; - %authed = call i64 @llvm.ptrauth.auth(i64 ptrtoint(ptr ptrauth(ptr @foo, i32 1, i64 1234) to i64)) [ "ptrauth"(i64 0, i64 1234) ] + %authed = call i64 @llvm.ptrauth.auth(i64 ptrtoint(ptr ptrauth(ptr @foo, i32 1, i64 1234) to i64)) [ "ptrauth"(i64 0, i64 1234, i64 0) ] ret i64 %authed } define i64 @test_ptrauth_nop_constant_addrdisc_mismatch() { ; CHECK-LABEL: @test_ptrauth_nop_constant_addrdisc_mismatch( -; CHECK-NEXT: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 ptrtoint (ptr ptrauth (ptr @foo, i32 1, i64 1234, ptr @foo) to i64)) [ "ptrauth"(i64 1, i64 ptrtoint (ptr @foo to i64), i64 12) ] +; CHECK-NEXT: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 ptrtoint (ptr ptrauth (ptr @foo, i32 1, i64 1234, ptr @foo) to i64)) [ "ptrauth"(i64 1, i64 12, i64 ptrtoint (ptr @foo to i64)) ] ; CHECK-NEXT: ret i64 [[AUTHED]] ; %addr = ptrtoint ptr @foo to i64 - %authed = call i64 @llvm.ptrauth.auth(i64 ptrtoint(ptr ptrauth(ptr @foo, i32 1, i64 1234, ptr @foo) to i64)) [ "ptrauth"(i64 1, i64 %addr, i64 12) ] + %authed = call i64 @llvm.ptrauth.auth(i64 ptrtoint(ptr ptrauth(ptr @foo, i32 1, i64 1234, ptr @foo) to i64)) [ "ptrauth"(i64 1, i64 12, i64 %addr) ] ret i64 %authed } define i64 @test_ptrauth_nop_constant_addrdisc_mismatch2() { ; CHECK-LABEL: @test_ptrauth_nop_constant_addrdisc_mismatch2( -; CHECK-NEXT: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 ptrtoint (ptr ptrauth (ptr @foo, i32 1, i64 1234, ptr @foo) to i64)) [ "ptrauth"(i64 1, i64 ptrtoint (ptr @bar to i64), i64 1234) ] +; CHECK-NEXT: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 ptrtoint (ptr ptrauth (ptr @foo, i32 1, i64 1234, ptr @foo) to i64)) [ "ptrauth"(i64 1, i64 1234, i64 ptrtoint (ptr @bar to i64)) ] ; CHECK-NEXT: ret i64 [[AUTHED]] ; %addr = ptrtoint ptr @bar to i64 - %authed = call i64 @llvm.ptrauth.auth(i64 ptrtoint(ptr ptrauth(ptr @foo, i32 1, i64 1234, ptr @foo) to i64)) [ "ptrauth"(i64 1, i64 %addr, i64 1234) ] + %authed = call i64 @llvm.ptrauth.auth(i64 ptrtoint(ptr ptrauth(ptr @foo, i32 1, i64 1234, ptr @foo) to i64)) [ "ptrauth"(i64 1, i64 1234, i64 %addr) ] ret i64 %authed } @@ -151,7 +151,7 @@ define i64 @test_ptrauth_resign_ptrauth_constant(ptr %p) { ; %tmp0 = ptrtoint ptr %p to i64 - %authed = call i64 @llvm.ptrauth.resign(i64 ptrtoint(ptr ptrauth(ptr @foo, i32 1, i64 1234) to i64)) [ "ptrauth"(i64 1, i64 1234), "ptrauth"(i64 0, i64 42) ] + %authed = call i64 @llvm.ptrauth.resign(i64 ptrtoint(ptr ptrauth(ptr @foo, i32 1, i64 1234) to i64)) [ "ptrauth"(i64 1, i64 1234, i64 0), "ptrauth"(i64 0, i64 42, i64 0) ] ret i64 %authed } diff --git a/llvm/unittests/SandboxIR/SandboxIRTest.cpp b/llvm/unittests/SandboxIR/SandboxIRTest.cpp index 168502f89cbf8..b475571948dcd 100644 --- a/llvm/unittests/SandboxIR/SandboxIRTest.cpp +++ b/llvm/unittests/SandboxIR/SandboxIRTest.cpp @@ -1395,8 +1395,8 @@ define ptr @foo() { LLVMPtrAuth->hasSpecialAddressDiscriminator(0u)); // Check isKnownCompatibleWith(). const DataLayout &DL = M->getDataLayout(); - EXPECT_TRUE(PtrAuth->isKnownCompatibleWith(PtrAuth->getKey(), - PtrAuth->getDiscriminator(), DL)); + EXPECT_TRUE(PtrAuth->isKnownCompatibleWith({PtrAuth->getKey(), + PtrAuth->getDiscriminator()}, DL)); // Check getWithSameSchema(). EXPECT_EQ(PtrAuth->getWithSameSchema(&F), PtrAuth); } From 5160d9980663f4b28472bc5e1bd05d231b37ffe1 Mon Sep 17 00:00:00 2001 From: Anatoly Trosinenko Date: Wed, 12 Nov 2025 14:30:39 +0300 Subject: [PATCH 24/40] LLVM: more cleanups --- .../SelectionDAG/SelectionDAGBuilder.cpp | 2 +- llvm/lib/IR/AutoUpgrade.cpp | 18 +- llvm/lib/IR/Constants.cpp | 21 +- .../Target/AArch64/AArch64ISelLowering.cpp | 30 +-- llvm/lib/Target/AArch64/AArch64ISelLowering.h | 7 - llvm/lib/Target/AArch64/AArch64InstrInfo.td | 16 +- .../AArch64/GISel/AArch64GlobalISelUtils.cpp | 16 +- .../AArch64/GISel/AArch64GlobalISelUtils.h | 12 +- .../GISel/AArch64InstructionSelector.cpp | 19 +- .../lib/Transforms/IPO/WholeProgramDevirt.cpp | 1 - .../InstCombine/InstCombineCalls.cpp | 2 + .../CodeGen/AArch64/deactivation-symbols.ll | 12 +- .../CodeGen/AArch64/ptrauth-call-upgrade.ll | 1 + .../AArch64/ptrauth-intrinsics-upgrade.ll | 1 + llvm/test/CodeGen/AArch64/ptrauth-isel.ll | 148 ++++--------- llvm/test/CodeGen/AArch64/ptrauth-isel.mir | 205 ------------------ llvm/test/CodeGen/AArch64/ptrauth-ret-trap.ll | 2 +- llvm/test/Verifier/ptrauth-operand-bundles.ll | 2 +- llvm/unittests/SandboxIR/SandboxIRTest.cpp | 5 +- 19 files changed, 121 insertions(+), 399 deletions(-) delete mode 100644 llvm/test/CodeGen/AArch64/ptrauth-isel.mir diff --git a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp index 4aac021881f82..a31f27145e61b 100644 --- a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp +++ b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp @@ -6558,7 +6558,7 @@ void SelectionDAGBuilder::visitPtrAuthIntrinsic(const CallInst &I, for (const Use &Operand : Bundle.Inputs) Ops.push_back(getValue(Operand)); - return DAG.getNode(ISD::PtrAuthBundle, getCurSDLoc(), MVT::Other, Ops); + return DAG.getNode(ISD::PtrAuthBundle, SDL, MVT::Other, Ops); }; SmallVector Ops; diff --git a/llvm/lib/IR/AutoUpgrade.cpp b/llvm/lib/IR/AutoUpgrade.cpp index f12ad85e31dc8..d9be1920ba695 100644 --- a/llvm/lib/IR/AutoUpgrade.cpp +++ b/llvm/lib/IR/AutoUpgrade.cpp @@ -4728,25 +4728,23 @@ static CallBase *setOperandBundles(CallBase *CI, ArrayRef OBs) // // Caller of this function is responsible for distinguishing between old-style // AArch64 bundles (i32 key) and new-style non-AArch64 bundles that happen to -// have two operands (which must be all i64 in the new-style bundles). +// have two operands (which must all have i64 type in the new-style bundles). // // Note that this function never expands calls to @llvm.ptrauth.blend, which // are handled by upgradePtrAuthBlend later. static OperandBundleDef createUpgradedPtrAuthBundle(ConstantInt *Key, - Value *DiscOrNull) { + Value *Disc) { LLVMContext &Ctx = Key->getContext(); Value *Zero = ConstantInt::get(Ctx, APInt::getZero(64)); SmallVector Inputs; Inputs.push_back(ConstantInt::get(Ctx, Key->getValue().zext(64))); - auto *IntDisc = dyn_cast_or_null(DiscOrNull); + auto *IntDisc = dyn_cast(Disc); if (IntDisc && isUInt<16>(IntDisc->getZExtValue())) Inputs.append({IntDisc, Zero}); - else if (DiscOrNull) - Inputs.append({Zero, DiscOrNull}); else - Inputs.append({Zero, Zero}); + Inputs.append({Zero, Disc}); return OperandBundleDef("ptrauth", Inputs); } @@ -4775,8 +4773,10 @@ static OperandBundleDef createUpgradedPtrAuthBundle(ConstantInt *Key, // case of "ptrauth" bundles (indirect authenticated calls) as well as any // @llvm.ptrauth.* intrinsics which were lazily processed already. // -// Note that the half-upgraded call formally uses the same called function -// and the same function signature as the original one. +// Note: the half-upgraded call formally uses the same called function +// and the same function signature as the original one. +// Note: authenticated indirect calls with old-style bundles are handled by +// UpgradeOperandBundles function. static CallBase *upgradeToPtrAuthBundles(CallBase *CI) { // Skip: intrinsic calls are never indirect. if (CI->isIndirectCall()) @@ -4856,7 +4856,7 @@ static void upgradePtrAuthBlend(CallBase *BlendCall) { // If Call is an old-style @llvm.ptrauth.* intrinsic call, lazily migrate // it to "ptrauth" bundles first. // If Call is an authenticated indirect call, it is expected to have - // already been migrated to a three-operand form by this time. + // already been migrated to a three-operand form by UpgradeOperandBundles. Call = upgradeToPtrAuthBundles(Call); SmallVector OBs; diff --git a/llvm/lib/IR/Constants.cpp b/llvm/lib/IR/Constants.cpp index ca5f38548b73f..71d467797b8a3 100644 --- a/llvm/lib/IR/Constants.cpp +++ b/llvm/lib/IR/Constants.cpp @@ -2168,32 +2168,33 @@ bool ConstantPtrAuth::isKnownCompatibleWith(ArrayRef BundleOperands, return false; ConstantInt *Key = dyn_cast(BundleOperands[0]); - Value *IntDisc = BundleOperands[1]; - Value *AddrDisc = BundleOperands[2]; + Value *IntDiscriminator = BundleOperands[1]; + Value *AddrDiscriminator = BundleOperands[2]; // FIXME: Use i64 consistently. if (!Key || Key->getZExtValue() != getKey()->getZExtValue()) return false; - if (getDiscriminator() != IntDisc) + if (getDiscriminator() != IntDiscriminator) return false; // We can now focus on comparing the address discriminators. - if (isa(AddrDisc) && cast(AddrDisc)->isZero() && + if (isa(AddrDiscriminator) && + cast(AddrDiscriminator)->isZero() && getAddrDiscriminator()->isNullValue()) return true; // Discriminators are i64, so the provided addr disc may be a ptrtoint. - if (auto *Cast = dyn_cast(AddrDisc)) - AddrDisc = Cast->getPointerOperand(); + if (auto *Cast = dyn_cast(AddrDiscriminator)) + AddrDiscriminator = Cast->getPointerOperand(); // Beyond that, we're only interested in compatible pointers. - if (getAddrDiscriminator()->getType() != AddrDisc->getType()) + if (getAddrDiscriminator()->getType() != AddrDiscriminator->getType()) return false; // These are often the same constant GEP, making them trivially equivalent. - if (getAddrDiscriminator() == AddrDisc) + if (getAddrDiscriminator() == AddrDiscriminator) return true; // Finally, they may be equivalent base+offset expressions. @@ -2201,8 +2202,8 @@ bool ConstantPtrAuth::isKnownCompatibleWith(ArrayRef BundleOperands, auto *Base1 = getAddrDiscriminator()->stripAndAccumulateConstantOffsets( DL, Off1, /*AllowNonInbounds=*/true); - APInt Off2(DL.getIndexTypeSizeInBits(AddrDisc->getType()), 0); - auto *Base2 = AddrDisc->stripAndAccumulateConstantOffsets( + APInt Off2(DL.getIndexTypeSizeInBits(AddrDiscriminator->getType()), 0); + auto *Base2 = AddrDiscriminator->stripAndAccumulateConstantOffsets( DL, Off2, /*AllowNonInbounds=*/true); return Base1 == Base2 && Off1 == Off2; diff --git a/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp b/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp index 573b061be941e..c641765297edf 100644 --- a/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp +++ b/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp @@ -3261,6 +3261,8 @@ AArch64TargetLowering::EmitEntryPStateSM(MachineInstr &MI, return BB; } +// Used by https://github.com/llvm/llvm-project/pull/130809. +#if 0 // Helper function to find the instruction that defined a virtual register. // If unable to find such instruction, returns nullptr. static const MachineInstr *stripVRegCopies(const MachineRegisterInfo &MRI, @@ -3286,34 +3288,8 @@ static const MachineInstr *stripVRegCopies(const MachineRegisterInfo &MRI, } return nullptr; } - -void AArch64TargetLowering::fixupPtrauthDiscriminator( - MachineInstr &MI, MachineBasicBlock *BB, MachineOperand &IntDiscOp, - MachineOperand &AddrDiscOp, const TargetRegisterClass *AddrDiscRC) const { - const TargetInstrInfo *TII = Subtarget->getInstrInfo(); - MachineRegisterInfo &MRI = MI.getMF()->getRegInfo(); - const DebugLoc &DL = MI.getDebugLoc(); - - Register AddrDisc = AddrDiscOp.getReg(); - int64_t IntDisc = IntDiscOp.getImm(); - - // For uniformity, always use NoRegister, as XZR is not necessarily contained - // in the requested register class. - if (AddrDisc == AArch64::XZR) - AddrDisc = AArch64::NoRegister; -#if 0 - // Make sure AddrDisc operand respects the register class imposed by MI. - if (AddrDisc && MRI.getRegClass(AddrDisc) != AddrDiscRC) { - Register TmpReg = MRI.createVirtualRegister(AddrDiscRC); - BuildMI(*BB, MI, DL, TII->get(AArch64::COPY), TmpReg).addReg(AddrDisc); - AddrDisc = TmpReg; - } #endif - AddrDiscOp.setReg(AddrDisc); - IntDiscOp.setImm(IntDisc); -} - MachineBasicBlock *AArch64TargetLowering::EmitInstrWithCustomInserter( MachineInstr &MI, MachineBasicBlock *BB) const { @@ -3419,8 +3395,6 @@ MachineBasicBlock *AArch64TargetLowering::EmitInstrWithCustomInserter( return EmitZTInstr(MI, BB, AArch64::MOVT_TIZ, /*Op0IsDef=*/true); case AArch64::PAC: - fixupPtrauthDiscriminator(MI, BB, MI.getOperand(3), MI.getOperand(4), - &AArch64::GPR64noipRegClass); return BB; } } diff --git a/llvm/lib/Target/AArch64/AArch64ISelLowering.h b/llvm/lib/Target/AArch64/AArch64ISelLowering.h index 75a9a097b1c0f..ff89bd355749b 100644 --- a/llvm/lib/Target/AArch64/AArch64ISelLowering.h +++ b/llvm/lib/Target/AArch64/AArch64ISelLowering.h @@ -195,13 +195,6 @@ class AArch64TargetLowering : public TargetLowering { MachineBasicBlock *EmitEntryPStateSM(MachineInstr &MI, MachineBasicBlock *BB) const; - /// Replace (0, vreg) discriminator components with the operands of blend - /// or with (immediate, NoRegister) when possible. - void fixupPtrauthDiscriminator(MachineInstr &MI, MachineBasicBlock *BB, - MachineOperand &IntDiscOp, - MachineOperand &AddrDiscOp, - const TargetRegisterClass *AddrDiscRC) const; - MachineBasicBlock * EmitInstrWithCustomInserter(MachineInstr &MI, MachineBasicBlock *MBB) const override; diff --git a/llvm/lib/Target/AArch64/AArch64InstrInfo.td b/llvm/lib/Target/AArch64/AArch64InstrInfo.td index cb48a47afefb1..e3ddae07e5edd 100644 --- a/llvm/lib/Target/AArch64/AArch64InstrInfo.td +++ b/llvm/lib/Target/AArch64/AArch64InstrInfo.td @@ -2213,12 +2213,7 @@ let Predicates = [HasPAuth] in { // if an attacker is able to substitute AddrDisc. def PAC : Pseudo<(outs GPR64:$SignedVal), (ins GPR64:$Val, i64imm:$Key, i64imm:$Disc, GPR64noip:$AddrDisc), - [(set GPR64:$SignedVal, - (ptrauth_sign GPR64:$Val, - (ptrauth_bundle (i64 imm:$Key), - (i64 imm:$Disc), - GPR64noip:$AddrDisc)))], - "$SignedVal = $Val">, Sched<[WriteI, ReadI]> { + [], "$SignedVal = $Val">, Sched<[WriteI, ReadI]> { let isCodeGenOnly = 1; let hasSideEffects = 0; let mayStore = 0; @@ -2229,6 +2224,15 @@ let Predicates = [HasPAuth] in { let supportsDeactivationSymbol = true; } + def : Pat<(ptrauth_sign GPR64:$Val, (ptrauth_bundle (i64 imm:$Key), + (i64 imm:$Disc), + (i64 0))), + (PAC GPR64:$Val, imm:$Key, imm:$Disc, zero_reg)>; + def : Pat<(ptrauth_sign GPR64:$Val, (ptrauth_bundle (i64 imm:$Key), + (i64 imm:$Disc), + GPR64noip:$AddrDisc)), + (PAC GPR64:$Val, imm:$Key, imm:$Disc, GPR64noip:$AddrDisc)>; + // AUT and re-PAC a value, using different keys/data. // This directly manipulates x16/x17, which are the only registers that // certain OSs guarantee are safe to use for sensitive operations. diff --git a/llvm/lib/Target/AArch64/GISel/AArch64GlobalISelUtils.cpp b/llvm/lib/Target/AArch64/GISel/AArch64GlobalISelUtils.cpp index c42e141bd9a40..3785c994836bd 100644 --- a/llvm/lib/Target/AArch64/GISel/AArch64GlobalISelUtils.cpp +++ b/llvm/lib/Target/AArch64/GISel/AArch64GlobalISelUtils.cpp @@ -97,8 +97,8 @@ bool AArch64GISelUtils::tryEmitBZero(MachineInstr &MI, } std::tuple -AArch64GISelUtils::extractPtrauthBlendDiscriminators(SmallVector Operands, - MachineRegisterInfo &MRI) { +AArch64GISelUtils::extractPtrauthBlendDiscriminators( + SmallVector Operands, MachineRegisterInfo &MRI) { assert(Operands.size() == 3); uint64_t KeyVal = getIConstantVRegVal(Operands[0], MRI)->getZExtValue(); @@ -113,6 +113,18 @@ AArch64GISelUtils::extractPtrauthBlendDiscriminators(SmallVector Opera return { KeyVal, ConstDiscVal, AddrDisc }; } +std::tuple +AArch64GISelUtils::extractPtrauthBlendDiscriminators(Register BundleToken, + MachineRegisterInfo &MRI) { + assert(MRI.getType(BundleToken).isToken()); + const MachineInstr *Bundle = MRI.getVRegDef(BundleToken); + assert(Bundle->getOpcode() == TargetOpcode::G_PTRAUTH_BUNDLE); + SmallVector Ops; + for (auto &Op : Bundle->uses()) + Ops.push_back(Op.getReg()); + return extractPtrauthBlendDiscriminators(Ops, MRI); +} + void AArch64GISelUtils::changeFCMPPredToAArch64CC( const CmpInst::Predicate P, AArch64CC::CondCode &CondCode, AArch64CC::CondCode &CondCode2) { diff --git a/llvm/lib/Target/AArch64/GISel/AArch64GlobalISelUtils.h b/llvm/lib/Target/AArch64/GISel/AArch64GlobalISelUtils.h index 4153300fdca3e..f77dbccf5b309 100644 --- a/llvm/lib/Target/AArch64/GISel/AArch64GlobalISelUtils.h +++ b/llvm/lib/Target/AArch64/GISel/AArch64GlobalISelUtils.h @@ -53,11 +53,15 @@ bool isCMN(const MachineInstr *MaybeSub, const CmpInst::Predicate &Pred, /// \returns true if \p MI was replaced with a G_BZERO. bool tryEmitBZero(MachineInstr &MI, MachineIRBuilder &MIRBuilder, bool MinSize); -/// Analyze a ptrauth discriminator value to try to find the constant integer -/// and address parts, cracking a ptrauth_blend intrinsic if there is one. -/// \returns integer/address disc. parts, with NoRegister if no address disc. +/// Analyze a ptrauth bundle and return the key ID, constant integer and +/// address parts. +/// \returns (Key, IntDisc, AddrDisc), with NoRegister if no address disc. std::tuple -extractPtrauthBlendDiscriminators(SmallVector Operands, MachineRegisterInfo &MRI); +extractPtrauthBlendDiscriminators(SmallVector Operands, + MachineRegisterInfo &MRI); +std::tuple +extractPtrauthBlendDiscriminators(Register BundleToken, + MachineRegisterInfo &MRI); /// Find the AArch64 condition codes necessary to represent \p P for a scalar /// floating point comparison. diff --git a/llvm/lib/Target/AArch64/GISel/AArch64InstructionSelector.cpp b/llvm/lib/Target/AArch64/GISel/AArch64InstructionSelector.cpp index 853568ab08241..1cf9683b45180 100644 --- a/llvm/lib/Target/AArch64/GISel/AArch64InstructionSelector.cpp +++ b/llvm/lib/Target/AArch64/GISel/AArch64InstructionSelector.cpp @@ -2592,23 +2592,14 @@ bool AArch64InstructionSelector::select(MachineInstr &I) { LLT Ty = I.getOperand(0).isReg() ? MRI.getType(I.getOperand(0).getReg()) : LLT{}; - auto ParsePtrAuthBundle = [&MRI](Register Schema) { - assert(MRI.getType(Schema).isToken()); - const MachineInstr *Bundle = MRI.getVRegDef(Schema); - assert(Bundle->getOpcode() == TargetOpcode::G_PTRAUTH_BUNDLE); - SmallVector Ops; - for (auto &Op : Bundle->uses()) - Ops.push_back(Op.getReg()); - return extractPtrauthBlendDiscriminators(Ops, MRI); - }; - switch (Opcode) { case TargetOpcode::G_PTRAUTH_AUTH: { Register DstReg = I.getOperand(0).getReg(); Register ValReg = I.getOperand(1).getReg(); Register Schema = I.getOperand(2).getReg(); - auto [AUTKey, AUTConstDiscC, AUTAddrDisc] = ParsePtrAuthBundle(Schema); + auto [AUTKey, AUTConstDiscC, AUTAddrDisc] = + extractPtrauthBlendDiscriminators(Schema, MRI); if (STI.isX16X17Safer()) { MIB.buildCopy({AArch64::X16}, {ValReg}); @@ -2642,8 +2633,10 @@ bool AArch64InstructionSelector::select(MachineInstr &I) { Register AUTSchema = I.getOperand(2).getReg(); Register PACSchema = I.getOperand(3).getReg(); - auto [AUTKey, AUTConstDiscC, AUTAddrDisc] = ParsePtrAuthBundle(AUTSchema); - auto [PACKey, PACConstDiscC, PACAddrDisc] = ParsePtrAuthBundle(PACSchema); + auto [AUTKey, AUTConstDiscC, AUTAddrDisc] = + extractPtrauthBlendDiscriminators(AUTSchema, MRI); + auto [PACKey, PACConstDiscC, PACAddrDisc] = + extractPtrauthBlendDiscriminators(PACSchema, MRI); MIB.buildCopy({AArch64::X16}, {ValReg}); MIB.buildInstr(TargetOpcode::IMPLICIT_DEF, {AArch64::X17}, {}); diff --git a/llvm/lib/Transforms/IPO/WholeProgramDevirt.cpp b/llvm/lib/Transforms/IPO/WholeProgramDevirt.cpp index e71f9000a9c87..4642da0abdc13 100644 --- a/llvm/lib/Transforms/IPO/WholeProgramDevirt.cpp +++ b/llvm/lib/Transforms/IPO/WholeProgramDevirt.cpp @@ -1270,7 +1270,6 @@ void DevirtModule::applySingleImplDevirt(VTableSlotInfo &SlotInfo, CB.setMetadata(LLVMContext::MD_callees, nullptr); if (CB.getCalledOperand() && CB.getOperandBundle(LLVMContext::OB_ptrauth)) { - assert(!isa(CB)); auto *NewCS = CallBase::removeOperandBundle( &CB, LLVMContext::OB_ptrauth, CB.getIterator()); CB.replaceAllUsesWith(NewCS); diff --git a/llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp b/llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp index d3c695b06efe3..6802435b79d3e 100644 --- a/llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp +++ b/llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp @@ -3120,6 +3120,8 @@ Instruction *InstCombinerImpl::visitCallInst(CallInst &CI) { if (NeedSign) { auto ThisSignSchema = II->getOperandBundleAt(1); // resign(ptrauth(p,ks,ds),ks,ds,kr,dr) -> ptrauth(p,kr,dr) + // FIXME Generalize ptrauth constant and drop AArch64-specific + // assumptions. if (ThisSignSchema.Inputs.size() == 3) { auto *SignKey = dyn_cast(ThisSignSchema.Inputs[0]); auto *SignIntDisc = dyn_cast(ThisSignSchema.Inputs[1]); diff --git a/llvm/test/CodeGen/AArch64/deactivation-symbols.ll b/llvm/test/CodeGen/AArch64/deactivation-symbols.ll index feac4379efed4..dcd0f0b1085aa 100644 --- a/llvm/test/CodeGen/AArch64/deactivation-symbols.ll +++ b/llvm/test/CodeGen/AArch64/deactivation-symbols.ll @@ -1,7 +1,7 @@ -; RUN: llc < %s -O0 -mtriple=aarch64-none-linux-gnu -mattr=+pauth -global-isel=0 | FileCheck --check-prefixes=CHECK,O0 %s -; RUN: llc < %s -O2 -mtriple=aarch64-none-linux-gnu -mattr=+pauth -global-isel=0 | FileCheck --check-prefixes=CHECK,O2 %s -; RUN: llc < %s -O0 -mtriple=aarch64-none-linux-gnu -mattr=+pauth -global-isel=1 -global-isel-abort=1 | FileCheck --check-prefixes=CHECK,O0 %s -; RUN: llc < %s -O2 -mtriple=aarch64-none-linux-gnu -mattr=+pauth -global-isel=1 -global-isel-abort=1 | FileCheck --check-prefixes=CHECK,O2 %s +; RUN: llc < %s -O0 -mtriple=aarch64-none-linux-gnu -mattr=+pauth -global-isel=0 | FileCheck %s +; RUN: llc < %s -O2 -mtriple=aarch64-none-linux-gnu -mattr=+pauth -global-isel=0 | FileCheck %s +; RUN: llc < %s -O0 -mtriple=aarch64-none-linux-gnu -mattr=+pauth -global-isel=1 -global-isel-abort=1 | FileCheck %s +; RUN: llc < %s -O2 -mtriple=aarch64-none-linux-gnu -mattr=+pauth -global-isel=1 -global-isel-abort=1 | FileCheck %s @ds = external global i8 @@ -18,11 +18,9 @@ define void @call(ptr %p) { ; CHECK: pauth_sign_zero: define i64 @pauth_sign_zero(i64 %p) { - ; O0: mov x8, xzr ; CHECK: [[LABEL:.L.*]]: ; CHECK-NEXT: .reloc [[LABEL]], R_AARCH64_PATCHINST, ds - ; O0-NEXT: pacia x0, x8 - ; O2-NEXT: paciza x0 + ; CHECK-NEXT: paciza x0 %signed = call i64 @llvm.ptrauth.sign(i64 %p) [ "ptrauth"(i64 0, i64 0, i64 0), "deactivation-symbol"(ptr @ds) ] ret i64 %signed } diff --git a/llvm/test/CodeGen/AArch64/ptrauth-call-upgrade.ll b/llvm/test/CodeGen/AArch64/ptrauth-call-upgrade.ll index 10e480369c2e0..6103c64cc2bb8 100644 --- a/llvm/test/CodeGen/AArch64/ptrauth-call-upgrade.ll +++ b/llvm/test/CodeGen/AArch64/ptrauth-call-upgrade.ll @@ -1,5 +1,6 @@ ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py ; RUN: opt < %s -S | FileCheck %s +; RUN: llvm-as < %s | opt -S | FileCheck %s define void @test_call_imm_disc(ptr %fn) { ; CHECK-LABEL: @test_call_imm_disc( diff --git a/llvm/test/CodeGen/AArch64/ptrauth-intrinsics-upgrade.ll b/llvm/test/CodeGen/AArch64/ptrauth-intrinsics-upgrade.ll index 8c13923bb0bd4..b46ca8a02bc1f 100644 --- a/llvm/test/CodeGen/AArch64/ptrauth-intrinsics-upgrade.ll +++ b/llvm/test/CodeGen/AArch64/ptrauth-intrinsics-upgrade.ll @@ -1,5 +1,6 @@ ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py ; RUN: opt < %s -S | FileCheck %s +; RUN: llvm-as < %s | opt -S | FileCheck %s define void @test_ptrauth_sign(i64 %p, i64 %addr) { ; CHECK-LABEL: @test_ptrauth_sign( diff --git a/llvm/test/CodeGen/AArch64/ptrauth-isel.ll b/llvm/test/CodeGen/AArch64/ptrauth-isel.ll index da8a2b48b1733..560621979f7bd 100644 --- a/llvm/test/CodeGen/AArch64/ptrauth-isel.ll +++ b/llvm/test/CodeGen/AArch64/ptrauth-isel.ll @@ -1,131 +1,75 @@ -; NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py UTC_ARGS: --version 5 ; RUN: llc < %s -mtriple arm64e-apple-darwin -verify-machineinstrs -stop-after=finalize-isel -global-isel=0 \ -; RUN: | FileCheck %s --check-prefixes=DAGISEL +; RUN: | FileCheck %s --check-prefixes=CHECK,DARWIN --implicit-check-not=name: --implicit-check-not=MOVKXi ; RUN: llc < %s -mtriple arm64e-apple-darwin -verify-machineinstrs -stop-after=finalize-isel -global-isel=1 -global-isel-abort=1 \ -; RUN: | FileCheck %s --check-prefixes=GISEL +; RUN: | FileCheck %s --check-prefixes=CHECK,DARWIN --implicit-check-not=name: --implicit-check-not=MOVKXi ; RUN: llc < %s -mtriple aarch64-linux-gnu -mattr=+pauth -verify-machineinstrs -stop-after=finalize-isel -global-isel=0 \ -; RUN: | FileCheck %s --check-prefixes=DAGISEL +; RUN: | FileCheck %s --check-prefixes=CHECK,ELF --implicit-check-not=name: --implicit-check-not=MOVKXi ; RUN: llc < %s -mtriple aarch64-linux-gnu -mattr=+pauth -verify-machineinstrs -stop-after=finalize-isel -global-isel=1 -global-isel-abort=1 \ -; RUN: | FileCheck %s --check-prefixes=GISEL +; RUN: | FileCheck %s --check-prefixes=CHECK,ELF --implicit-check-not=name: --implicit-check-not=MOVKXi ; Check MIR produced by the instruction selector to validate properties that ; cannot be reliably tested by only inspecting the final asm output. @discvar = dso_local global i64 0 -; FIXME Should we remove this file? - -; Make sure various forms of "ptrauth" call bundles are properly normalized -; to a full, three-operand form and then passed as the operands of PAC pseudo. -; Specifically, make sure that "ptrauth"(i64 key, i64 disc) is handled as -; "ptrauth"(i64 key, i64 disc, i64 0) when disc is uint16 constant and as -; "ptrauth"(i64 key, i64 0, i64 disc) otherwise. This is important to prevent -; substitution of the immediate modifier. +; Make sure zero address modifier is translated directly into a $noreg operand +; at the MIR level instead of a virtual register containing zero value. ; -; MIR output of the instruction selector is inspected, as it is hard to reliably -; distinguish MOVKXi immediately followed by a pseudo from a standalone pseudo -; instruction carrying address and immediate modifiers in its separate operands -; by only observing the final asm output. +; All relevant intrinsics are checked because some are selected by TableGen +; patterns and some other are selected by C++ code. -define i64 @small_imm_disc_optimized(i64 %addr) { - ; DAGISEL-LABEL: name: small_imm_disc_optimized - ; DAGISEL: bb.0.entry: - ; DAGISEL-NEXT: liveins: $x0 - ; DAGISEL-NEXT: {{ $}} - ; DAGISEL-NEXT: [[COPY:%[0-9]+]]:gpr64 = COPY $x0 - ; DAGISEL-NEXT: [[PAC:%[0-9]+]]:gpr64 = PAC [[COPY]], 2, 42, $noreg, implicit-def dead $x16, implicit-def dead $x17 - ; DAGISEL-NEXT: $x0 = COPY [[PAC]] - ; DAGISEL-NEXT: RET_ReallyLR implicit $x0 - ; - ; GISEL-LABEL: name: small_imm_disc_optimized - ; GISEL: bb.1.entry: - ; GISEL-NEXT: liveins: $x0 - ; GISEL-NEXT: {{ $}} - ; GISEL-NEXT: [[COPY:%[0-9]+]]:gpr64 = COPY $x0 - ; GISEL-NEXT: [[PAC:%[0-9]+]]:gpr64 = PAC [[COPY]], 2, 42, $noreg, implicit-def dead $x16, implicit-def dead $x17 - ; GISEL-NEXT: $x0 = COPY [[PAC]] - ; GISEL-NEXT: RET_ReallyLR implicit $x0 +define i64 @pac_no_addr_modif_optimized(i64 %addr) { + ; CHECK-LABEL: name: pac_no_addr_modif_optimized + ; CHECK: {{.*}} = PAC {{[^,]+}}, 2, 42, $noreg, implicit-def dead $x16, implicit-def dead $x17 + ; CHECK: RET_ReallyLR implicit $x0 entry: %signed = call i64 @llvm.ptrauth.sign(i64 %addr) [ "ptrauth"(i64 2, i64 42, i64 0) ] ret i64 %signed } -define i64 @small_imm_disc_non_optimized(i64 %addr) noinline optnone { - ; DAGISEL-LABEL: name: small_imm_disc_non_optimized - ; DAGISEL: bb.0.entry: - ; DAGISEL-NEXT: liveins: $x0 - ; DAGISEL-NEXT: {{ $}} - ; DAGISEL-NEXT: [[COPY:%[0-9]+]]:gpr64 = COPY $x0 - ; DAGISEL-NEXT: [[COPY1:%[0-9]+]]:gpr64 = COPY killed [[COPY]] - ; DAGISEL-NEXT: [[PAC:%[0-9]+]]:gpr64 = PAC [[COPY1]], 2, 42, $noreg, implicit-def dead $x16, implicit-def dead $x17 - ; DAGISEL-NEXT: [[COPY3:%[0-9]+]]:gpr64all = COPY [[PAC]] - ; DAGISEL-NEXT: $x0 = COPY [[COPY3]] - ; DAGISEL-NEXT: RET_ReallyLR implicit $x0 - ; - ; GISEL-LABEL: name: small_imm_disc_non_optimized - ; GISEL: bb.1.entry: - ; GISEL-NEXT: liveins: $x0 - ; GISEL-NEXT: {{ $}} - ; GISEL-NEXT: [[COPY:%[0-9]+]]:gpr64 = COPY $x0 - ; GISEL-NEXT: [[PAC:%[0-9]+]]:gpr64 = PAC [[COPY]], 2, 42, $noreg, implicit-def dead $x16, implicit-def dead $x17 - ; GISEL-NEXT: $x0 = COPY [[PAC]] - ; GISEL-NEXT: RET_ReallyLR implicit $x0 +define i64 @pac_no_addr_modif_not_optimized(i64 %addr) noinline optnone { + ; CHECK-LABEL: name: pac_no_addr_modif_not_optimized + ; CHECK: {{.*}} = PAC {{[^,]+}}, 2, 42, $noreg, implicit-def dead $x16, implicit-def dead $x17 + ; CHECK: RET_ReallyLR implicit $x0 entry: %signed = call i64 @llvm.ptrauth.sign(i64 %addr) [ "ptrauth"(i64 2, i64 42, i64 0) ] ret i64 %signed } -define i64 @large_imm_disc(i64 %addr) { - ; DAGISEL-LABEL: name: large_imm_disc - ; DAGISEL: bb.0.entry: - ; DAGISEL-NEXT: liveins: $x0 - ; DAGISEL-NEXT: {{ $}} - ; DAGISEL-NEXT: [[COPY:%[0-9]+]]:gpr64 = COPY $x0 - ; DAGISEL-NEXT: [[MOVi32imm:%[0-9]+]]:gpr32 = MOVi32imm 12345678 - ; DAGISEL-NEXT: [[SUBREG_TO_REG:%[0-9]+]]:gpr64noip = SUBREG_TO_REG 0, killed [[MOVi32imm]], %subreg.sub_32 - ; DAGISEL-NEXT: [[PAC:%[0-9]+]]:gpr64 = PAC [[COPY]], 2, 0, killed [[SUBREG_TO_REG]], implicit-def dead $x16, implicit-def dead $x17 - ; DAGISEL-NEXT: $x0 = COPY [[PAC]] - ; DAGISEL-NEXT: RET_ReallyLR implicit $x0 - ; - ; GISEL-LABEL: name: large_imm_disc - ; GISEL: bb.1.entry: - ; GISEL-NEXT: liveins: $x0 - ; GISEL-NEXT: {{ $}} - ; GISEL-NEXT: [[COPY:%[0-9]+]]:gpr64 = COPY $x0 - ; GISEL-NEXT: [[MOVi32imm:%[0-9]+]]:gpr32 = MOVi32imm 12345678 - ; GISEL-NEXT: [[SUBREG_TO_REG:%[0-9]+]]:gpr64noip = SUBREG_TO_REG 0, [[MOVi32imm]], %subreg.sub_32 - ; GISEL-NEXT: [[PAC:%[0-9]+]]:gpr64 = PAC [[COPY]], 2, 0, [[SUBREG_TO_REG]], implicit-def dead $x16, implicit-def dead $x17 - ; GISEL-NEXT: $x0 = COPY [[PAC]] - ; GISEL-NEXT: RET_ReallyLR implicit $x0 +define i64 @aut_no_addr_modif_optimized(i64 %addr) { + ; CHECK-LABEL: name: aut_no_addr_modif_optimized + ; DARWIN: AUTx16x17 2, 42, $noreg, implicit-def $x16, implicit-def {{(dead )?}}$x17, implicit-def dead $nzcv, implicit $x16 + ; ELF: {{.*}} = AUTxMxN {{[^,]+}}, 2, 42, $noreg, implicit-def dead $nzcv + ; CHECK: RET_ReallyLR implicit $x0 +entry: + %signed = call i64 @llvm.ptrauth.auth(i64 %addr) [ "ptrauth"(i64 2, i64 42, i64 0) ] + ret i64 %signed +} + +define i64 @aut_no_addr_modif_not_optimized(i64 %addr) noinline optnone { + ; CHECK-LABEL: name: aut_no_addr_modif_not_optimized + ; DARWIN: AUTx16x17 2, 42, $noreg, implicit-def $x16, implicit-def {{(dead )?}}$x17, implicit-def dead $nzcv, implicit $x16 + ; ELF: {{.*}} = AUTxMxN {{[^,]+}}, 2, 42, $noreg, implicit-def dead $nzcv + ; CHECK: RET_ReallyLR implicit $x0 +entry: + %signed = call i64 @llvm.ptrauth.auth(i64 %addr) [ "ptrauth"(i64 2, i64 42, i64 0) ] + ret i64 %signed +} + +define i64 @resign_no_addr_modif_optimized(i64 %addr) { + ; CHECK-LABEL: name: resign_no_addr_modif_optimized + ; CHECK: AUTPAC 2, 42, $noreg, 2, 123, $noreg, implicit-def $x16, implicit-def {{(dead )?}}$x17, implicit-def dead $nzcv, implicit $x16 + ; CHECK: RET_ReallyLR implicit $x0 entry: - %signed = call i64 @llvm.ptrauth.sign(i64 %addr) [ "ptrauth"(i64 2, i64 0, i64 12345678) ] + %signed = call i64 @llvm.ptrauth.resign(i64 %addr) [ "ptrauth"(i64 2, i64 42, i64 0), "ptrauth"(i64 2, i64 123, i64 0) ] ret i64 %signed } -define i64 @blended_disc(i64 %addr) { - ; DAGISEL-LABEL: name: blended_disc - ; DAGISEL: bb.0.entry: - ; DAGISEL-NEXT: liveins: $x0 - ; DAGISEL-NEXT: {{ $}} - ; DAGISEL-NEXT: [[COPY:%[0-9]+]]:gpr64 = COPY $x0 - ; DAGISEL-NEXT: [[ADRP:%[0-9]+]]:gpr64common = ADRP target-flags(aarch64-page) @discvar - ; DAGISEL-NEXT: [[LDRXui:%[0-9]+]]:gpr64noip = LDRXui killed [[ADRP]], target-flags(aarch64-pageoff, aarch64-nc) @discvar :: (dereferenceable load (s64) from @discvar) - ; DAGISEL-NEXT: [[PAC:%[0-9]+]]:gpr64 = PAC [[COPY]], 2, 42, killed [[LDRXui]], implicit-def dead $x16, implicit-def dead $x17 - ; DAGISEL-NEXT: $x0 = COPY [[PAC]] - ; DAGISEL-NEXT: RET_ReallyLR implicit $x0 - ; - ; GISEL-LABEL: name: blended_disc - ; GISEL: bb.1.entry: - ; GISEL-NEXT: liveins: $x0 - ; GISEL-NEXT: {{ $}} - ; GISEL-NEXT: [[COPY:%[0-9]+]]:gpr64 = COPY $x0 - ; GISEL-NEXT: [[ADRP:%[0-9]+]]:gpr64common = ADRP target-flags(aarch64-page) @discvar - ; GISEL-NEXT: [[LDRXui:%[0-9]+]]:gpr64noip = LDRXui [[ADRP]], target-flags(aarch64-pageoff, aarch64-nc) @discvar :: (dereferenceable load (s64) from @discvar) - ; GISEL-NEXT: [[PAC:%[0-9]+]]:gpr64 = PAC [[COPY]], 2, 42, [[LDRXui]], implicit-def dead $x16, implicit-def dead $x17 - ; GISEL-NEXT: $x0 = COPY [[PAC]] - ; GISEL-NEXT: RET_ReallyLR implicit $x0 +define i64 @resign_no_addr_modif_not_optimized(i64 %addr) noinline optnone { + ; CHECK-LABEL: name: resign_no_addr_modif_not_optimized + ; CHECK: AUTPAC 2, 42, $noreg, 2, 123, $noreg, implicit-def $x16, implicit-def {{(dead )?}}$x17, implicit-def dead $nzcv, implicit $x16 + ; CHECK: RET_ReallyLR implicit $x0 entry: - %addrdisc = load i64, ptr @discvar - %signed = call i64 @llvm.ptrauth.sign(i64 %addr) [ "ptrauth"(i64 2, i64 42, i64 %addrdisc) ] + %signed = call i64 @llvm.ptrauth.resign(i64 %addr) [ "ptrauth"(i64 2, i64 42, i64 0), "ptrauth"(i64 2, i64 123, i64 0) ] ret i64 %signed } diff --git a/llvm/test/CodeGen/AArch64/ptrauth-isel.mir b/llvm/test/CodeGen/AArch64/ptrauth-isel.mir deleted file mode 100644 index 1a155887059e3..0000000000000 --- a/llvm/test/CodeGen/AArch64/ptrauth-isel.mir +++ /dev/null @@ -1,205 +0,0 @@ -# NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py UTC_ARGS: --version 5 -# RUN: llc -o - %s -mtriple arm64e-apple-darwin -verify-machineinstrs \ -# RUN: -stop-after=finalize-isel -start-before=finalize-isel | FileCheck %s -# RUN: llc -o - %s -mtriple aarch64-linux-gnu -mattr=+pauth -verify-machineinstrs \ -# RUN: -stop-after=finalize-isel -start-before=finalize-isel | FileCheck %s - -# This MIR-based test contains several test cases that are hard to implement -# via an LLVM IR input. Most other test cases are in ptrauth-isel.ll file. - ---- | - @globalvar = dso_local global i64 0 - - define i64 @movk_correct_blend(i64 %a, i64 %b) { - entry: - ret i64 0 - } - - define i64 @movk_wrong_shift_amount(i64 %a, i64 %b) { - entry: - ret i64 0 - } - - define i64 @movk_non_immediate_operand(i64 %a, i64 %b) { - entry: - ret i64 0 - } - - define i64 @movi64imm_immediate_operand(i64 %a) { - entry: - ret i64 0 - } - - define i64 @movi64imm_non_immediate_operand(i64 %a) { - entry: - ret i64 0 - } - - define i64 @movi32imm_immediate_operand(i64 %a) { - entry: - ret i64 0 - } - - define i64 @movi32imm_non_immediate_operand(i64 %a) { - entry: - ret i64 0 - } -... ---- -name: movk_correct_blend -tracksRegLiveness: true -body: | - bb.0.entry: - liveins: $x0, $x1 - - ; CHECK-LABEL: name: movk_correct_blend - ; CHECK: liveins: $x0, $x1 - ; CHECK-NEXT: {{ $}} - ; CHECK-NEXT: [[COPY:%[0-9]+]]:gpr64 = COPY $x0 - ; CHECK-NEXT: [[COPY1:%[0-9]+]]:gpr64 = COPY $x1 - ; CHECK-NEXT: [[MOVKXi:%[0-9]+]]:gpr64noip = MOVKXi [[COPY1]], 42, 48 - ; CHECK-NEXT: [[COPY2:%[0-9]+]]:gpr64noip = COPY [[COPY1]] - ; CHECK-NEXT: [[PAC:%[0-9]+]]:gpr64 = PAC [[COPY]], 2, 42, killed [[COPY2]], implicit-def dead $x16, implicit-def dead $x17 - ; CHECK-NEXT: $x0 = COPY [[PAC]] - ; CHECK-NEXT: RET_ReallyLR implicit $x0 - %0:gpr64 = COPY $x0 - %1:gpr64 = COPY $x1 - %2:gpr64noip = MOVKXi %1, 42, 48 - %3:gpr64 = PAC %0, 2, 0, killed %2, implicit-def dead $x16, implicit-def dead $x17 - $x0 = COPY %3 - RET_ReallyLR implicit $x0 -... ---- -name: movk_wrong_shift_amount -tracksRegLiveness: true -body: | - bb.0.entry: - liveins: $x0, $x1 - - ; CHECK-LABEL: name: movk_wrong_shift_amount - ; CHECK: liveins: $x0, $x1 - ; CHECK-NEXT: {{ $}} - ; CHECK-NEXT: [[COPY:%[0-9]+]]:gpr64 = COPY $x0 - ; CHECK-NEXT: [[COPY1:%[0-9]+]]:gpr64 = COPY $x1 - ; CHECK-NEXT: [[MOVKXi:%[0-9]+]]:gpr64noip = MOVKXi [[COPY1]], 42, 0 - ; CHECK-NEXT: [[PAC:%[0-9]+]]:gpr64 = PAC [[COPY]], 2, 0, killed [[MOVKXi]], implicit-def dead $x16, implicit-def dead $x17 - ; CHECK-NEXT: $x0 = COPY [[PAC]] - ; CHECK-NEXT: RET_ReallyLR implicit $x0 - %0:gpr64 = COPY $x0 - %1:gpr64 = COPY $x1 - %2:gpr64noip = MOVKXi %1, 42, 0 - %3:gpr64 = PAC %0, 2, 0, killed %2, implicit-def dead $x16, implicit-def dead $x17 - $x0 = COPY %3 - RET_ReallyLR implicit $x0 -... ---- -name: movk_non_immediate_operand -tracksRegLiveness: true -body: | - bb.0.entry: - liveins: $x0, $x1 - - ; CHECK-LABEL: name: movk_non_immediate_operand - ; CHECK: liveins: $x0, $x1 - ; CHECK-NEXT: {{ $}} - ; CHECK-NEXT: [[COPY:%[0-9]+]]:gpr64 = COPY $x0 - ; CHECK-NEXT: [[COPY1:%[0-9]+]]:gpr64 = COPY $x1 - ; CHECK-NEXT: [[MOVKXi:%[0-9]+]]:gpr64noip = MOVKXi [[COPY1]], target-flags(aarch64-pageoff, aarch64-nc) @globalvar, 48 - ; CHECK-NEXT: [[PAC:%[0-9]+]]:gpr64 = PAC [[COPY]], 2, 0, killed [[MOVKXi]], implicit-def dead $x16, implicit-def dead $x17 - ; CHECK-NEXT: $x0 = COPY [[PAC]] - ; CHECK-NEXT: RET_ReallyLR implicit $x0 - %0:gpr64 = COPY $x0 - %1:gpr64 = COPY $x1 - %2:gpr64noip = MOVKXi %1, target-flags(aarch64-pageoff, aarch64-nc) @globalvar, 48 - %3:gpr64 = PAC %0, 2, 0, killed %2, implicit-def dead $x16, implicit-def dead $x17 - $x0 = COPY %3 - RET_ReallyLR implicit $x0 -... ---- -name: movi64imm_immediate_operand -tracksRegLiveness: true -body: | - bb.0.entry: - liveins: $x0, $x1 - - ; CHECK-LABEL: name: movi64imm_immediate_operand - ; CHECK: liveins: $x0, $x1 - ; CHECK-NEXT: {{ $}} - ; CHECK-NEXT: [[COPY:%[0-9]+]]:gpr64 = COPY $x0 - ; CHECK-NEXT: [[MOVi64imm:%[0-9]+]]:gpr64noip = MOVi64imm 42 - ; CHECK-NEXT: [[PAC:%[0-9]+]]:gpr64 = PAC [[COPY]], 2, 42, killed $noreg, implicit-def dead $x16, implicit-def dead $x17 - ; CHECK-NEXT: $x0 = COPY [[PAC]] - ; CHECK-NEXT: RET_ReallyLR implicit $x0 - %0:gpr64 = COPY $x0 - %1:gpr64noip = MOVi64imm 42 - %2:gpr64 = PAC %0, 2, 0, killed %1, implicit-def dead $x16, implicit-def dead $x17 - $x0 = COPY %2 - RET_ReallyLR implicit $x0 -... ---- -name: movi64imm_non_immediate_operand -tracksRegLiveness: true -body: | - bb.0.entry: - liveins: $x0, $x1 - - ; CHECK-LABEL: name: movi64imm_non_immediate_operand - ; CHECK: liveins: $x0, $x1 - ; CHECK-NEXT: {{ $}} - ; CHECK-NEXT: [[COPY:%[0-9]+]]:gpr64 = COPY $x0 - ; CHECK-NEXT: [[MOVi64imm:%[0-9]+]]:gpr64noip = MOVi64imm target-flags(aarch64-pageoff, aarch64-nc) @globalvar - ; CHECK-NEXT: [[PAC:%[0-9]+]]:gpr64 = PAC [[COPY]], 2, 0, killed [[MOVi64imm]], implicit-def dead $x16, implicit-def dead $x17 - ; CHECK-NEXT: $x0 = COPY [[PAC]] - ; CHECK-NEXT: RET_ReallyLR implicit $x0 - %0:gpr64 = COPY $x0 - %1:gpr64noip = MOVi64imm target-flags(aarch64-pageoff, aarch64-nc) @globalvar - %2:gpr64 = PAC %0, 2, 0, killed %1, implicit-def dead $x16, implicit-def dead $x17 - $x0 = COPY %2 - RET_ReallyLR implicit $x0 -... ---- -name: movi32imm_immediate_operand -tracksRegLiveness: true -body: | - bb.0.entry: - liveins: $x0, $x1 - - ; CHECK-LABEL: name: movi32imm_immediate_operand - ; CHECK: liveins: $x0, $x1 - ; CHECK-NEXT: {{ $}} - ; CHECK-NEXT: [[COPY:%[0-9]+]]:gpr64 = COPY $x0 - ; CHECK-NEXT: [[MOVi32imm:%[0-9]+]]:gpr32 = MOVi32imm 42 - ; CHECK-NEXT: [[SUBREG_TO_REG:%[0-9]+]]:gpr64noip = SUBREG_TO_REG 0, killed [[MOVi32imm]], %subreg.sub_32 - ; CHECK-NEXT: [[PAC:%[0-9]+]]:gpr64 = PAC [[COPY]], 2, 42, killed $noreg, implicit-def dead $x16, implicit-def dead $x17 - ; CHECK-NEXT: $x0 = COPY [[PAC]] - ; CHECK-NEXT: RET_ReallyLR implicit $x0 - %0:gpr64 = COPY $x0 - %1:gpr32 = MOVi32imm 42 - %2:gpr64noip = SUBREG_TO_REG 0, killed %1, %subreg.sub_32 - %3:gpr64 = PAC %0, 2, 0, killed %2, implicit-def dead $x16, implicit-def dead $x17 - $x0 = COPY %3 - RET_ReallyLR implicit $x0 -... ---- -name: movi32imm_non_immediate_operand -tracksRegLiveness: true -body: | - bb.0.entry: - liveins: $x0, $x1 - - ; CHECK-LABEL: name: movi32imm_non_immediate_operand - ; CHECK: liveins: $x0, $x1 - ; CHECK-NEXT: {{ $}} - ; CHECK-NEXT: [[COPY:%[0-9]+]]:gpr64 = COPY $x0 - ; CHECK-NEXT: [[MOVi32imm:%[0-9]+]]:gpr32 = MOVi32imm target-flags(aarch64-pageoff, aarch64-nc) @globalvar - ; CHECK-NEXT: [[SUBREG_TO_REG:%[0-9]+]]:gpr64noip = SUBREG_TO_REG 0, killed [[MOVi32imm]], %subreg.sub_32 - ; CHECK-NEXT: [[PAC:%[0-9]+]]:gpr64 = PAC [[COPY]], 2, 0, killed [[SUBREG_TO_REG]], implicit-def dead $x16, implicit-def dead $x17 - ; CHECK-NEXT: $x0 = COPY [[PAC]] - ; CHECK-NEXT: RET_ReallyLR implicit $x0 - %0:gpr64 = COPY $x0 - %1:gpr32 = MOVi32imm target-flags(aarch64-pageoff, aarch64-nc) @globalvar - %2:gpr64noip = SUBREG_TO_REG 0, killed %1, %subreg.sub_32 - %3:gpr64 = PAC %0, 2, 0, killed %2, implicit-def dead $x16, implicit-def dead $x17 - $x0 = COPY %3 - RET_ReallyLR implicit $x0 -... diff --git a/llvm/test/CodeGen/AArch64/ptrauth-ret-trap.ll b/llvm/test/CodeGen/AArch64/ptrauth-ret-trap.ll index 9c9e6f6faf356..77217028800f2 100644 --- a/llvm/test/CodeGen/AArch64/ptrauth-ret-trap.ll +++ b/llvm/test/CodeGen/AArch64/ptrauth-ret-trap.ll @@ -61,7 +61,7 @@ define void @test_tailcall_indirect_in_x9(ptr sret(i64) %ret, [8 x i64] %in, ptr ; CHECK: braa x0, x16 define void @test_auth_tailcall_indirect(ptr %fptr) #0 { call i32 @test_tailcall() - tail call void %fptr() [ "ptrauth"(i64 0, i64 42) ] + tail call void %fptr() [ "ptrauth"(i64 0, i64 42, i64 0) ] ret void } diff --git a/llvm/test/Verifier/ptrauth-operand-bundles.ll b/llvm/test/Verifier/ptrauth-operand-bundles.ll index 1b003d953a346..e67ab23809cde 100644 --- a/llvm/test/Verifier/ptrauth-operand-bundles.ll +++ b/llvm/test/Verifier/ptrauth-operand-bundles.ll @@ -80,7 +80,7 @@ define void @test_ptrauth_bundle(i64 %arg.64, ptr %arg.ptr, ptr %ok) { call i64 @llvm.ptrauth.strip(i64 0) [ "ptrauth"(i64 42, i64 120) ] call i64 @llvm.ptrauth.strip(i64 0) [ "ptrauth"(i64 %arg.64) ] -; CHECK: Unexpected ptrauth bundle on intrinsic call +; CHECK: Unexpected ptrauth bundle ; CHECK-NEXT: call i64 @llvm.ptrauth.sign.generic(i64 0, i64 42) [ "ptrauth"(i64 42, i64 120) ] call i64 @llvm.ptrauth.sign.generic(i64 0, i64 42) [ "ptrauth"(i64 42, i64 120) ] diff --git a/llvm/unittests/SandboxIR/SandboxIRTest.cpp b/llvm/unittests/SandboxIR/SandboxIRTest.cpp index b475571948dcd..951a31baa36ab 100644 --- a/llvm/unittests/SandboxIR/SandboxIRTest.cpp +++ b/llvm/unittests/SandboxIR/SandboxIRTest.cpp @@ -1395,8 +1395,9 @@ define ptr @foo() { LLVMPtrAuth->hasSpecialAddressDiscriminator(0u)); // Check isKnownCompatibleWith(). const DataLayout &DL = M->getDataLayout(); - EXPECT_TRUE(PtrAuth->isKnownCompatibleWith({PtrAuth->getKey(), - PtrAuth->getDiscriminator()}, DL)); + EXPECT_TRUE(PtrAuth->isKnownCompatibleWith( + {PtrAuth->getKey(), PtrAuth->getDiscriminator(), + PtrAuth->getAddrDiscriminator()}, DL)); // Check getWithSameSchema(). EXPECT_EQ(PtrAuth->getWithSameSchema(&F), PtrAuth); } From 804a5b534acd185a840a1698e2c51e22e1226295 Mon Sep 17 00:00:00 2001 From: Anatoly Trosinenko Date: Wed, 12 Nov 2025 21:09:49 +0300 Subject: [PATCH 25/40] WIP: Clang: misc cleanup --- clang/lib/CodeGen/CGBuiltin.cpp | 32 ++-- clang/lib/CodeGen/CGClass.cpp | 3 +- clang/lib/CodeGen/CGExprConstant.cpp | 5 +- clang/lib/CodeGen/CGPointerAuth.cpp | 118 ++++++-------- clang/lib/CodeGen/CGPointerAuthInfo.h | 36 ++--- clang/lib/CodeGen/CodeGenFunction.cpp | 16 +- clang/lib/CodeGen/CodeGenModule.h | 5 +- clang/lib/CodeGen/ItaniumCXXABI.cpp | 25 ++- .../ptrauth-function-lvalue-cast-disc.c | 14 +- .../CodeGen/ptrauth-function-lvalue-cast.c | 2 +- ...ptrauth-function-type-discriminator-cast.c | 16 +- .../ptrauth-function-type-discriminator.c | 12 +- clang/test/CodeGen/ptrauth-function.c | 2 +- clang/test/CodeGen/ptrauth-in-c-struct.c | 8 +- clang/test/CodeGen/ptrauth-intrinsics.c | 26 ++-- clang/test/CodeGen/ptrauth-qualifier-blocks.c | 14 +- .../test/CodeGen/ptrauth-qualifier-function.c | 22 +-- .../CodeGen/ptrauth-qualifier-loadstore.c | 112 +++++++------- .../ptrauth-restricted-intptr-qualifier.c | 50 +++--- clang/test/CodeGen/ubsan-function.cpp | 2 +- .../CodeGenCXX/builtin-get-vtable-pointer.cpp | 102 ++++++------- .../ptrauth-apple-kext-indirect-call-2.cpp | 12 +- ...-apple-kext-indirect-virtual-dtor-call.cpp | 4 +- .../CodeGenCXX/ptrauth-dynamic-cast-exact.cpp | 10 +- ...trauth-explicit-vtable-pointer-control.cpp | 144 +++++++++--------- .../ptrauth-global-constant-initializers.cpp | 114 +++++++------- .../ptrauth-member-function-pointer.cpp | 38 ++--- .../CodeGenCXX/ptrauth-qualifier-struct.cpp | 8 +- clang/test/CodeGenCXX/ptrauth-throw.cpp | 4 +- clang/test/CodeGenCXX/ptrauth-thunks.cpp | 2 +- .../CodeGenCXX/ptrauth-type-info-vtable.cpp | 4 +- .../CodeGenCXX/ptrauth-virtual-function.cpp | 108 ++++++------- ...rauth-vtable-virtual-inheritance-thunk.cpp | 16 +- clang/test/CodeGenCXX/ptrauth.cpp | 2 +- clang/test/CodeGenCXX/ubsan-vtable-checks.cpp | 6 +- .../ptrauth-block-descriptor-pointer.m | 2 +- clang/test/CodeGenObjC/ptrauth-block-isa.m | 4 +- clang/test/CodeGenObjC/ptrauth-class.m | 10 +- .../ptrauth-objc-interface-selector.m | 30 ++-- .../CodeGenObjC/ptrauth-property-backing.m | 16 +- .../ptrauth-objc-interface-selector.mm | 10 +- 41 files changed, 568 insertions(+), 598 deletions(-) diff --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp index 0989560fcf8a0..73a8c28fbefc4 100644 --- a/clang/lib/CodeGen/CGBuiltin.cpp +++ b/clang/lib/CodeGen/CGBuiltin.cpp @@ -5634,7 +5634,7 @@ RValue CodeGenFunction::EmitBuiltinExpr(const GlobalDecl GD, unsigned BuiltinID, case Builtin::BI__builtin_ptrauth_sign_unauthenticated: case Builtin::BI__builtin_ptrauth_strip: { SmallVector Args; - SmallVector OBs; + SmallVector OBs; auto ConvertToInt64 = [&](llvm::Value *V) { if (V->getType()->isPointerTy()) @@ -5642,17 +5642,29 @@ RValue CodeGenFunction::EmitBuiltinExpr(const GlobalDecl GD, unsigned BuiltinID, return Builder.CreateZExt(V, IntPtrTy); }; - auto AddPtrAuthBundle = [&](const Expr *Key, const Expr *Discr) { - SmallVector Operands; - Operands.push_back(ConvertToInt64(EmitScalarExpr(Key))); - const CallExpr *CE = dyn_cast(Discr); - if (CE && CE->getBuiltinCallee() == Builtin::BI__builtin_ptrauth_blend_discriminator) { - Operands.push_back(ConvertToInt64(EmitScalarExpr(CE->getArg(0)))); - Operands.push_back(ConvertToInt64(EmitScalarExpr(CE->getArg(1)))); + auto AddPtrAuthBundle = [&](const Expr *KeyExpr, const Expr *DiscrExpr) { + llvm::Value *Key = ConvertToInt64(EmitScalarExpr(KeyExpr)); + llvm::Value *IntDiscr = Builder.getInt64(0); + llvm::Value *AddrDiscr = Builder.getInt64(0); + + const CallExpr *MaybeBlend = dyn_cast(DiscrExpr); + if (MaybeBlend && MaybeBlend->getBuiltinCallee() == + Builtin::BI__builtin_ptrauth_blend_discriminator) { + // Assign modifiers according to blend arguments. + IntDiscr = ConvertToInt64(EmitScalarExpr(MaybeBlend->getArg(1))); + AddrDiscr = ConvertToInt64(EmitScalarExpr(MaybeBlend->getArg(0))); } else { - Operands.push_back(ConvertToInt64(EmitScalarExpr(Discr))); + // Check if discriminator is a small integer constant and fallback to + // passing an arbitrary raw value otherwise. + llvm::Value *Discr = ConvertToInt64(EmitScalarExpr(DiscrExpr)); + llvm::ConstantInt *DiscrConst = dyn_cast(Discr); + if (DiscrConst && isUInt<16>(DiscrConst->getZExtValue())) + IntDiscr = Discr; + else + AddrDiscr = Discr; } - OBs.emplace_back("ptrauth", Operands); + llvm::Value *Inputs[] = {Key, IntDiscr, AddrDiscr}; + OBs.emplace_back("ptrauth", Inputs); }; // Cast the value to intptr_t, saving its original type. diff --git a/clang/lib/CodeGen/CGClass.cpp b/clang/lib/CodeGen/CGClass.cpp index de10ad102be9a..d28d3012e0622 100644 --- a/clang/lib/CodeGen/CGClass.cpp +++ b/clang/lib/CodeGen/CGClass.cpp @@ -2774,7 +2774,8 @@ llvm::Value *CodeGenFunction::GetVTablePtr(Address This, } } else { VTable = cast(EmitPointerAuthAuth( - CGPointerAuthInfo(0, PointerAuthenticationMode::Strip, false, false), + CGPointerAuthInfo(0, PointerAuthenticationMode::Strip, false, false, + 0, nullptr), VTable)); } } diff --git a/clang/lib/CodeGen/CGExprConstant.cpp b/clang/lib/CodeGen/CGExprConstant.cpp index f3b1210f16d08..af333bcbcf782 100644 --- a/clang/lib/CodeGen/CGExprConstant.cpp +++ b/clang/lib/CodeGen/CGExprConstant.cpp @@ -2226,11 +2226,8 @@ ConstantLValueEmitter::tryEmitBase(const APValue::LValueBase &base) { if (hasNonZeroOffset()) return ConstantLValue(nullptr); - assert(!AuthInfo.isBlended()); C = applyOffset(C); - C = CGM.getConstantSignedPointer( - C, AuthInfo.getKey(), nullptr, - cast_or_null(AuthInfo.getDiscriminator())); + C = CGM.getConstantSignedPointer(C, AuthInfo); return ConstantLValue(C, /*applied offset*/ true, /*signed*/ true); } diff --git a/clang/lib/CodeGen/CGPointerAuth.cpp b/clang/lib/CodeGen/CGPointerAuth.cpp index 75bacb5184e8d..38d19b6a72da1 100644 --- a/clang/lib/CodeGen/CGPointerAuth.cpp +++ b/clang/lib/CodeGen/CGPointerAuth.cpp @@ -23,25 +23,23 @@ using namespace CodeGen; /// Given a pointer-authentication schema, return a concrete "other" /// discriminator for it. -llvm::ConstantInt *CodeGenModule::getPointerAuthOtherDiscriminator( +unsigned CodeGenModule::getPointerAuthOtherDiscriminator( const PointerAuthSchema &Schema, GlobalDecl Decl, QualType Type) { switch (Schema.getOtherDiscrimination()) { case PointerAuthSchema::Discrimination::None: - return nullptr; + return 0; case PointerAuthSchema::Discrimination::Type: assert(!Type.isNull() && "type not provided for type-discriminated schema"); - return llvm::ConstantInt::get( - IntPtrTy, getContext().getPointerAuthTypeDiscriminator(Type)); + return getContext().getPointerAuthTypeDiscriminator(Type); case PointerAuthSchema::Discrimination::Decl: assert(Decl.getDecl() && "declaration not provided for decl-discriminated schema"); - return llvm::ConstantInt::get(IntPtrTy, - getPointerAuthDeclDiscriminator(Decl)); + return getPointerAuthDeclDiscriminator(Decl); case PointerAuthSchema::Discrimination::Constant: - return llvm::ConstantInt::get(IntPtrTy, Schema.getConstantDiscrimination()); + return Schema.getConstantDiscrimination(); } llvm_unreachable("bad discrimination kind"); } @@ -79,15 +77,17 @@ CGPointerAuthInfo CodeGenModule::getFunctionPointerAuthInfo(QualType T) { assert(!Schema.isAddressDiscriminated() && "function pointers cannot use address-specific discrimination"); - llvm::Constant *Discriminator = nullptr; if (T->isFunctionPointerType() || T->isFunctionReferenceType()) T = T->getPointeeType(); + + unsigned IntDiscriminator = 0; if (T->isFunctionType()) - Discriminator = getPointerAuthOtherDiscriminator(Schema, GlobalDecl(), T); + IntDiscriminator = getPointerAuthOtherDiscriminator(Schema, GlobalDecl(), + T); return CGPointerAuthInfo(Schema.getKey(), Schema.getAuthenticationMode(), /*IsaPointer=*/false, /*AuthenticatesNull=*/false, - Discriminator); + IntDiscriminator, /*AddrDiscriminator=*/nullptr); } /// Emit the concrete pointer authentication informaton for the @@ -98,21 +98,21 @@ CGPointerAuthInfo CodeGenFunction::EmitPointerAuthInfo( if (!Schema) return CGPointerAuthInfo(); - llvm::Value *Discriminator = nullptr; - llvm::Value *ExtraDiscriminator = + unsigned IntDiscriminator = CGM.getPointerAuthOtherDiscriminator(Schema, SchemaDecl, SchemaType); + llvm::Value *AddrDiscriminator = nullptr; if (Schema.isAddressDiscriminated()) { assert(StorageAddress && "address not provided for address-discriminated schema"); - Discriminator = Builder.CreatePtrToInt(StorageAddress, IntPtrTy); + AddrDiscriminator = Builder.CreatePtrToInt(StorageAddress, IntPtrTy); } return CGPointerAuthInfo(Schema.getKey(), Schema.getAuthenticationMode(), Schema.isIsaPointer(), - Schema.authenticatesNullValues(), Discriminator, - ExtraDiscriminator); + Schema.authenticatesNullValues(), IntDiscriminator, + AddrDiscriminator); } CGPointerAuthInfo @@ -122,21 +122,19 @@ CodeGenFunction::EmitPointerAuthInfo(PointerAuthQualifier Qual, if (Qual.hasKeyNone()) return CGPointerAuthInfo(); - llvm::Value *Discriminator = nullptr; - llvm::Value *ExtraDiscriminator = nullptr; - if (unsigned Extra = Qual.getExtraDiscriminator()) - ExtraDiscriminator = llvm::ConstantInt::get(IntPtrTy, Extra); + unsigned IntDiscriminator = Qual.getExtraDiscriminator(); + llvm::Value *AddrDiscriminator = nullptr; if (Qual.isAddressDiscriminated()) { assert(StorageAddress.isValid() && "address discrimination without address"); llvm::Value *StoragePtr = StorageAddress.emitRawPointer(*this); - Discriminator = Builder.CreatePtrToInt(StoragePtr, IntPtrTy); + AddrDiscriminator = Builder.CreatePtrToInt(StoragePtr, IntPtrTy); } return CGPointerAuthInfo(Qual.getKey(), Qual.getAuthenticationMode(), Qual.isIsaPointer(), Qual.authenticatesNullValues(), - Discriminator, ExtraDiscriminator); + IntDiscriminator, AddrDiscriminator); } /// Return the natural pointer authentication for values of the given @@ -265,12 +263,6 @@ llvm::Value *CodeGenFunction::EmitPointerAuthUnqualify( IsKnownNonNull); } -static bool isZeroConstant(const llvm::Value *Value) { - if (const auto *CI = dyn_cast(Value)) - return CI->isZero(); - return false; -} - llvm::Value * CodeGenFunction::emitPointerAuthResignCall(llvm::Value *Value, const CGPointerAuthInfo &CurAuth, @@ -320,29 +312,9 @@ llvm::Value *CodeGenFunction::emitPointerAuthResign( if (Value == Null) return Value; - auto GetPolicyTuple = [](const CGPointerAuthInfo &PAI) { - return std::make_tuple(PAI.getAuthenticationMode(), PAI.isIsaPointer(), - PAI.authenticatesNullValues(), PAI.getKey()); - }; - // If both schemas sign the same way, we're done. - if (CurAuthInfo.isSigned() && NewAuthInfo.isSigned() && - GetPolicyTuple(CurAuthInfo) == GetPolicyTuple(NewAuthInfo)) { - auto IsSame = [](const llvm::Value *LHS, const llvm::Value *RHS) { - if (LHS == RHS) - return true; - - bool IsZeroLHS = LHS == nullptr || isZeroConstant(LHS); - bool IsZeroRHS = RHS == nullptr || isZeroConstant(RHS); - return IsZeroLHS && IsZeroRHS; - }; - - if (IsSame(CurAuthInfo.getDiscriminator(), - NewAuthInfo.getDiscriminator()) && - IsSame(CurAuthInfo.getExtraDiscriminator(), - NewAuthInfo.getExtraDiscriminator())) - return Value; - } + if (CurAuthInfo == NewAuthInfo) + return Value; llvm::BasicBlock *InitBB = Builder.GetInsertBlock(); llvm::BasicBlock *ResignBB = nullptr, *ContBB = nullptr; @@ -395,6 +367,14 @@ void CodeGenFunction::EmitPointerAuthCopy(PointerAuthQualifier Qual, QualType T, Builder.CreateStore(Value, DestAddress); } +llvm::Constant *CodeGenModule::getConstantSignedPointer( + llvm::Constant *Pointer, CGPointerAuthInfo Info) { + auto *AddrDisc = + dyn_cast_or_null(Info.getAddrDiscriminator()); + auto *IntDisc = llvm::ConstantInt::get(Int64Ty, Info.getIntDiscriminator()); + return getConstantSignedPointer(Pointer, Info.getKey(), AddrDisc, IntDisc); +} + llvm::Constant * CodeGenModule::getConstantSignedPointer(llvm::Constant *Pointer, unsigned Key, llvm::Constant *StorageAddress, @@ -435,11 +415,12 @@ llvm::Constant *CodeGenModule::getConstantSignedPointer( llvm::Constant *StorageAddress, GlobalDecl SchemaDecl, QualType SchemaType) { assert(shouldSignPointer(Schema)); - llvm::ConstantInt *OtherDiscriminator = + unsigned Disc = getPointerAuthOtherDiscriminator(Schema, SchemaDecl, SchemaType); + auto *IntDiscriminator = llvm::ConstantInt::get(Int64Ty, Disc); return getConstantSignedPointer(Pointer, Schema.getKey(), StorageAddress, - OtherDiscriminator); + IntDiscriminator); } llvm::Constant * @@ -458,12 +439,8 @@ llvm::Constant *CodeGenModule::getFunctionPointer(llvm::Constant *Pointer, FunctionType->isFunctionReferenceType() || FunctionType->isFunctionPointerType()); - if (auto PointerAuth = getFunctionPointerAuthInfo(FunctionType)) { - assert(!PointerAuth.isBlended()); - return getConstantSignedPointer( - Pointer, PointerAuth.getKey(), /*StorageAddress=*/nullptr, - cast_or_null(PointerAuth.getDiscriminator())); - } + if (auto PointerAuth = getFunctionPointerAuthInfo(FunctionType)) + return getConstantSignedPointer(Pointer, PointerAuth); return Pointer; } @@ -492,22 +469,18 @@ CGPointerAuthInfo CodeGenModule::getMemberFunctionPointerAuthInfo(QualType FT) { assert(!Schema.isAddressDiscriminated() && "function pointers cannot use address-specific discrimination"); - llvm::ConstantInt *ExtraDiscriminator = + unsigned IntDiscriminator = getPointerAuthOtherDiscriminator(Schema, GlobalDecl(), FT); return CGPointerAuthInfo(Schema.getKey(), Schema.getAuthenticationMode(), /* IsIsaPointer */ false, - /* AuthenticatesNullValues */ false, nullptr, - ExtraDiscriminator); + /* AuthenticatesNullValues */ false, + IntDiscriminator, /*AddrDiscriminator=*/nullptr); } llvm::Constant *CodeGenModule::getMemberFunctionPointer(llvm::Constant *Pointer, QualType FT) { - if (CGPointerAuthInfo PointerAuth = getMemberFunctionPointerAuthInfo(FT)) { - assert(!PointerAuth.isBlended()); - return getConstantSignedPointer( - Pointer, PointerAuth.getKey(), nullptr, - cast_or_null(PointerAuth.getDiscriminator())); - } + if (CGPointerAuthInfo PointerAuth = getMemberFunctionPointerAuthInfo(FT)) + return getConstantSignedPointer(Pointer, PointerAuth); if (const auto *MFT = dyn_cast(FT.getTypePtr())) { if (MFT->hasPointeeToToCFIUncheckedCalleeFunctionType()) @@ -615,23 +588,20 @@ CodeGenModule::getVTablePointerAuthInfo(CodeGenFunction *CGF, if (!Authentication) return std::nullopt; - llvm::Value *Discriminator = nullptr; - llvm::Value *ExtraDiscriminator = nullptr; - if (auto Extra = Authentication->getExtraDiscriminator()) - ExtraDiscriminator = llvm::ConstantInt::get(IntPtrTy, Extra); - + unsigned IntDiscriminator = Authentication->getExtraDiscriminator(); + llvm::Value *AddrDiscriminator = nullptr; if (Authentication->isAddressDiscriminated()) { assert(StorageAddress && "address not provided for address-discriminated schema"); - Discriminator = CGF->Builder.CreatePtrToInt(StorageAddress, IntPtrTy); + AddrDiscriminator = CGF->Builder.CreatePtrToInt(StorageAddress, IntPtrTy); } return CGPointerAuthInfo(Authentication->getKey(), PointerAuthenticationMode::SignAndAuth, /* IsIsaPointer */ false, - /* AuthenticatesNullValues */ false, Discriminator, - ExtraDiscriminator); + /* AuthenticatesNullValues */ false, IntDiscriminator, + AddrDiscriminator); } llvm::Value *CodeGenFunction::authPointerToPointerCast(llvm::Value *ResultPtr, diff --git a/clang/lib/CodeGen/CGPointerAuthInfo.h b/clang/lib/CodeGen/CGPointerAuthInfo.h index 205aba7171f26..91dc2fb7219d5 100644 --- a/clang/lib/CodeGen/CGPointerAuthInfo.h +++ b/clang/lib/CodeGen/CGPointerAuthInfo.h @@ -26,22 +26,18 @@ class CGPointerAuthInfo { CGPointerAuthInfo() : AuthenticationMode(PointerAuthenticationMode::None), IsIsaPointer(false), AuthenticatesNullValues(false), Key(0), - Discriminator(nullptr), ExtraDiscriminator(nullptr) {} + IntDiscriminator(0), AddrDiscriminator(nullptr) {} CGPointerAuthInfo(unsigned Key, PointerAuthenticationMode AuthenticationMode, bool IsIsaPointer, bool AuthenticatesNullValues, - llvm::Value *Discriminator = nullptr, - llvm::Value *ExtraDiscriminator = nullptr) + unsigned IntDiscriminator, + llvm::Value *AddrDiscriminator) : AuthenticationMode(AuthenticationMode), IsIsaPointer(IsIsaPointer), AuthenticatesNullValues(AuthenticatesNullValues), Key(Key), - Discriminator(Discriminator), ExtraDiscriminator(ExtraDiscriminator) { - assert(!Discriminator || Discriminator->getType()->isIntegerTy() || - Discriminator->getType()->isPointerTy()); - assert(!ExtraDiscriminator || ExtraDiscriminator->getType()->isIntegerTy()); - - if (!Discriminator) { - this->Discriminator = ExtraDiscriminator; - this->ExtraDiscriminator = nullptr; - } + IntDiscriminator(IntDiscriminator), + AddrDiscriminator(AddrDiscriminator) { + assert(llvm::isUInt<16>(IntDiscriminator)); + assert(!AddrDiscriminator || AddrDiscriminator->getType()->isIntegerTy() || + AddrDiscriminator->getType()->isPointerTy()); } explicit operator bool() const { return isSigned(); } @@ -55,14 +51,14 @@ class CGPointerAuthInfo { return Key; } - llvm::Value *getDiscriminator() const { + unsigned getIntDiscriminator() const { assert(isSigned()); - return Discriminator; + return IntDiscriminator; } - llvm::Value *getExtraDiscriminator() const { + llvm::Value *getAddrDiscriminator() const { assert(isSigned()); - return ExtraDiscriminator; + return AddrDiscriminator; } PointerAuthenticationMode getAuthenticationMode() const { @@ -87,8 +83,6 @@ class CGPointerAuthInfo { return AuthenticationMode == PointerAuthenticationMode::SignAndAuth; } - bool isBlended() const { return ExtraDiscriminator != nullptr; } - friend bool operator!=(const CGPointerAuthInfo &LHS, const CGPointerAuthInfo &RHS) { return !(LHS == RHS); @@ -99,7 +93,7 @@ class CGPointerAuthInfo { auto AsTuple = [](const CGPointerAuthInfo &Info) { return std::make_tuple(Info.AuthenticationMode, Info.IsIsaPointer, Info.AuthenticatesNullValues, Info.Key, - Info.Discriminator, Info.ExtraDiscriminator); + Info.IntDiscriminator, Info.AddrDiscriminator); }; return AsTuple(LHS) == AsTuple(RHS); } @@ -109,8 +103,8 @@ class CGPointerAuthInfo { unsigned IsIsaPointer : 1; unsigned AuthenticatesNullValues : 1; unsigned Key : 2; - llvm::Value *Discriminator; - llvm::Value *ExtraDiscriminator; + unsigned IntDiscriminator; + llvm::Value *AddrDiscriminator; }; } // end namespace CodeGen diff --git a/clang/lib/CodeGen/CodeGenFunction.cpp b/clang/lib/CodeGen/CodeGenFunction.cpp index ec9a4b2387d36..da78bf1a41578 100644 --- a/clang/lib/CodeGen/CodeGenFunction.cpp +++ b/clang/lib/CodeGen/CodeGenFunction.cpp @@ -3308,17 +3308,13 @@ void CodeGenFunction::EmitPointerAuthOperandBundle( if (!PointerAuth.isSigned()) return; - SmallVector Args; - Args.push_back(Builder.getInt64(PointerAuth.getKey())); - if (!PointerAuth.getDiscriminator() && !PointerAuth.getExtraDiscriminator()) { - Args.push_back(Builder.getInt64(0)); - } else { - if (llvm::Value *V = PointerAuth.getDiscriminator()) - Args.push_back(V); - if (llvm::Value *V = PointerAuth.getExtraDiscriminator()) - Args.push_back(V); - } + llvm::Value *Key = Builder.getInt64(PointerAuth.getKey()); + llvm::Value *IntDisc = Builder.getInt64(PointerAuth.getIntDiscriminator()); + llvm::Value *AddrDisc = PointerAuth.getAddrDiscriminator(); + if (!AddrDisc) + AddrDisc = Builder.getInt64(0); + llvm::Value *Args[] = {Key, IntDisc, AddrDisc}; Bundles.emplace_back("ptrauth", Args); } diff --git a/clang/lib/CodeGen/CodeGenModule.h b/clang/lib/CodeGen/CodeGenModule.h index a253bcda2d06c..5761ac0f52f16 100644 --- a/clang/lib/CodeGen/CodeGenModule.h +++ b/clang/lib/CodeGen/CodeGenModule.h @@ -1057,12 +1057,15 @@ class CodeGenModule : public CodeGenTypeCache { GlobalDecl SchemaDecl, QualType SchemaType); + llvm::Constant * + getConstantSignedPointer(llvm::Constant *Pointer, CGPointerAuthInfo Info); + llvm::Constant * getConstantSignedPointer(llvm::Constant *Pointer, unsigned Key, llvm::Constant *StorageAddress, llvm::ConstantInt *OtherDiscriminator); - llvm::ConstantInt * + unsigned getPointerAuthOtherDiscriminator(const PointerAuthSchema &Schema, GlobalDecl SchemaDecl, QualType SchemaType); diff --git a/clang/lib/CodeGen/ItaniumCXXABI.cpp b/clang/lib/CodeGen/ItaniumCXXABI.cpp index f02cdf5ab4ebb..8644299e80def 100644 --- a/clang/lib/CodeGen/ItaniumCXXABI.cpp +++ b/clang/lib/CodeGen/ItaniumCXXABI.cpp @@ -871,16 +871,16 @@ CGCallee ItaniumCXXABI::EmitLoadOfMemberFunctionPointer( CGM.getMemberFunctionPointerAuthInfo(QualType(MPT, 0)); assert(Schema.getKey() == AuthInfo.getKey() && "Keys for virtual and non-virtual member functions must match"); - auto *NonVirtualDiscriminator = AuthInfo.getDiscriminator(); - assert(!AuthInfo.isBlended() && - isa(NonVirtualDiscriminator)); + auto *NonVirtualDiscriminator = + Builder.getInt64(AuthInfo.getIntDiscriminator()); + assert(!AuthInfo.getAddrDiscriminator()); // FIXME This does not involve call to @llvm.ptrauth.blend(), but such // usage of constant modifier is unsafe. DiscriminatorPHI->addIncoming(NonVirtualDiscriminator, FnNonVirtual); PointerAuth = CGPointerAuthInfo( Schema.getKey(), Schema.getAuthenticationMode(), Schema.isIsaPointer(), - Schema.authenticatesNullValues(), DiscriminatorPHI); + Schema.authenticatesNullValues(), 0, DiscriminatorPHI); } CGCallee Callee(FPT, CalleePtr, PointerAuth); @@ -912,15 +912,14 @@ static llvm::Constant *pointerAuthResignConstant( if (!CPA) return nullptr; - assert(CPA->getKey()->getZExtValue() == CurAuthInfo.getKey() && - CPA->getAddrDiscriminator()->isZeroValue() && - CPA->getDiscriminator() == CurAuthInfo.getDiscriminator() && - !CurAuthInfo.isBlended() && !NewAuthInfo.isBlended() && - "unexpected key or discriminators"); + assert(CPA->getKey()->getZExtValue() == CurAuthInfo.getKey()); + assert(CPA->getDiscriminator()->getZExtValue() == + CurAuthInfo.getIntDiscriminator()); + assert(!CurAuthInfo.getAddrDiscriminator() && + !NewAuthInfo.getAddrDiscriminator() && + CPA->getAddrDiscriminator()->isZeroValue()); - return CGM.getConstantSignedPointer( - CPA->getPointer(), NewAuthInfo.getKey(), nullptr, - cast(NewAuthInfo.getDiscriminator())); + return CGM.getConstantSignedPointer(CPA->getPointer(), NewAuthInfo); } /// Perform a bitcast, derived-to-base, or base-to-derived member pointer @@ -1775,7 +1774,7 @@ llvm::Value *ItaniumCXXABI::emitExactDynamicCast( // authenticate the resulting v-table at the end of the cast check. PerformPostCastAuthentication = CGF.getLangOpts().PointerAuthCalls; CGPointerAuthInfo StrippingAuthInfo(0, PointerAuthenticationMode::Strip, - false, false); + false, false, 0, nullptr); Address VTablePtrPtr = ThisAddr.withElementType(CGF.VoidPtrPtrTy); VTable = CGF.Builder.CreateLoad(VTablePtrPtr, "vtable"); if (PerformPostCastAuthentication) diff --git a/clang/test/CodeGen/ptrauth-function-lvalue-cast-disc.c b/clang/test/CodeGen/ptrauth-function-lvalue-cast-disc.c index 8cadbb379e90b..15328df75f4dd 100644 --- a/clang/test/CodeGen/ptrauth-function-lvalue-cast-disc.c +++ b/clang/test/CodeGen/ptrauth-function-lvalue-cast-disc.c @@ -12,8 +12,8 @@ void (*fptr)(void); void test1() { // TYPE: [[LOAD:%.*]] = load ptr, ptr @cptr // TYPE: [[TOINT:%.*]] = ptrtoint ptr [[LOAD]] to i64 - // TYPE: call i64 @llvm.ptrauth.resign(i64 [[TOINT]]) [ "ptrauth"(i64 0, i64 0), "ptrauth"(i64 0, i64 18983) ] - // TYPE: call void {{.*}}() [ "ptrauth"(i64 0, i64 18983) ] + // TYPE: call i64 @llvm.ptrauth.resign(i64 [[TOINT]]) [ "ptrauth"(i64 0, i64 0, i64 0), "ptrauth"(i64 0, i64 18983, i64 0) ] + // TYPE: call void {{.*}}() [ "ptrauth"(i64 0, i64 18983, i64 0) ] // ZERO-NOT: @llvm.ptrauth.resign (*(fptr_t)cptr)(); @@ -29,7 +29,7 @@ char test2() { // TYPE: [[NONNULL]]: // TYPE: [[TOINT:%.*]] = ptrtoint ptr [[LOAD]] to i64 - // TYPE: [[CALL:%.*]] = call i64 @llvm.ptrauth.resign(i64 [[TOINT]]) [ "ptrauth"(i64 0, i64 18983), "ptrauth"(i64 0, i64 0) ] + // TYPE: [[CALL:%.*]] = call i64 @llvm.ptrauth.resign(i64 [[TOINT]]) [ "ptrauth"(i64 0, i64 18983, i64 0), "ptrauth"(i64 0, i64 0, i64 0) ] // TYPE: [[TOPTR:%.*]] = inttoptr i64 [[CALL]] to ptr // TYPE: [[CONT]]: @@ -43,11 +43,11 @@ void test4() { // CHECK: [[LOAD:%.*]] = load ptr, ptr @cptr // TYPE-NEXT: [[CAST4:%.*]] = ptrtoint ptr [[LOAD]] to i64 - // TYPE-NEXT: [[RESIGN:%.*]] = call i64 @llvm.ptrauth.resign(i64 [[CAST4]]) [ "ptrauth"(i64 0, i64 0), "ptrauth"(i64 0, i64 18983) ] + // TYPE-NEXT: [[RESIGN:%.*]] = call i64 @llvm.ptrauth.resign(i64 [[CAST4]]) [ "ptrauth"(i64 0, i64 0, i64 0), "ptrauth"(i64 0, i64 18983, i64 0) ] // TYPE-NEXT: [[CAST5:%.*]] = inttoptr i64 [[RESIGN]] to ptr - // TYPE-NEXT: call void [[CAST5]]() [ "ptrauth"(i64 0, i64 18983) ] + // TYPE-NEXT: call void [[CAST5]]() [ "ptrauth"(i64 0, i64 18983, i64 0) ] // ZERO-NOT: @llvm.ptrauth.resign - // ZERO: call void [[LOAD]]() [ "ptrauth"(i64 0, i64 0) ] + // ZERO: call void [[LOAD]]() [ "ptrauth"(i64 0, i64 0, i64 0) ] } void *vptr; @@ -60,7 +60,7 @@ void test5() { // TYPE-NEXT: br i1 [[CMP]], label %[[NONNULL:.*]], label %[[CONT:.*]] // TYPE: [[NONNULL]]: - // TYPE: [[RESIGN:%.*]] = call i64 @llvm.ptrauth.resign(i64 {{.*}}) [ "ptrauth"(i64 0, i64 18983), "ptrauth"(i64 0, i64 0) ] + // TYPE: [[RESIGN:%.*]] = call i64 @llvm.ptrauth.resign(i64 {{.*}}) [ "ptrauth"(i64 0, i64 18983, i64 0), "ptrauth"(i64 0, i64 0, i64 0) ] // TYPE: [[CAST:%.*]] = inttoptr i64 [[RESIGN]] to ptr // TYPE: [[CONT]]: diff --git a/clang/test/CodeGen/ptrauth-function-lvalue-cast.c b/clang/test/CodeGen/ptrauth-function-lvalue-cast.c index e2299e3ebd807..25ef81fd54966 100644 --- a/clang/test/CodeGen/ptrauth-function-lvalue-cast.c +++ b/clang/test/CodeGen/ptrauth-function-lvalue-cast.c @@ -9,7 +9,7 @@ void (*fptr)(void); // CHECK: define {{(dso_local )?}}void @test1 void test1() { // CHECK: [[LOAD:%.*]] = load ptr, ptr @cptr - // CHECK: call void [[LOAD]]() [ "ptrauth"(i64 0, i64 0) ] + // CHECK: call void [[LOAD]]() [ "ptrauth"(i64 0, i64 0, i64 0) ] // CHECK: ret void (*(fptr_t)cptr)(); diff --git a/clang/test/CodeGen/ptrauth-function-type-discriminator-cast.c b/clang/test/CodeGen/ptrauth-function-type-discriminator-cast.c index 31737098230b4..59b7130b81e47 100644 --- a/clang/test/CodeGen/ptrauth-function-type-discriminator-cast.c +++ b/clang/test/CodeGen/ptrauth-function-type-discriminator-cast.c @@ -34,7 +34,7 @@ ptr_member pm; void (*test_member)() = (void (*)())pm.fptr_; // CHECKCXX-LABEL: define{{.*}} internal void @__cxx_global_var_init -// TYPECXX: call i64 @llvm.ptrauth.resign(i64 {{.*}}) [ "ptrauth"(i64 0, i64 2712), "ptrauth"(i64 0, i64 18983) ] +// TYPECXX: call i64 @llvm.ptrauth.resign(i64 {{.*}}) [ "ptrauth"(i64 0, i64 2712, i64 0), "ptrauth"(i64 0, i64 18983, i64 0) ] #endif @@ -42,7 +42,7 @@ void (*test_member)() = (void (*)())pm.fptr_; void test_cast_to_opaque() { opaque = (void *)f; - // TYPE: [[RESIGN_VAL:%.*]] = call i64 @llvm.ptrauth.resign(i64 ptrtoint (ptr ptrauth (ptr @f, i32 0, i64 18983) to i64)) [ "ptrauth"(i64 0, i64 18983), "ptrauth"(i64 0, i64 0) ] + // TYPE: [[RESIGN_VAL:%.*]] = call i64 @llvm.ptrauth.resign(i64 ptrtoint (ptr ptrauth (ptr @f, i32 0, i64 18983) to i64)) [ "ptrauth"(i64 0, i64 18983, i64 0), "ptrauth"(i64 0, i64 0, i64 0) ] // TYPE: [[RESIGN_PTR:%.*]] = inttoptr i64 [[RESIGN_VAL]] to ptr // ZERO-NOT: @llvm.ptrauth.resign } @@ -57,7 +57,7 @@ void test_cast_from_opaque() { // TYPE: [[RESIGN_LAB]]: // TYPE: [[INT:%.*]] = ptrtoint ptr [[LOAD]] to i64 - // TYPE: [[RESIGN_INT:%.*]] = call i64 @llvm.ptrauth.resign(i64 [[INT]]) [ "ptrauth"(i64 0, i64 0), "ptrauth"(i64 0, i64 18983) ] + // TYPE: [[RESIGN_INT:%.*]] = call i64 @llvm.ptrauth.resign(i64 [[INT]]) [ "ptrauth"(i64 0, i64 0, i64 0), "ptrauth"(i64 0, i64 18983, i64 0) ] // ZERO-NOT: @llvm.ptrauth.resign } @@ -73,7 +73,7 @@ void test_cast_to_intptr() { // TYPE: [[RESIGN_LAB]]: // TYPE: [[INT:%.*]] = ptrtoint ptr [[LOAD]] to i64 - // TYPE: [[RESIGN_INT:%.*]] = call i64 @llvm.ptrauth.resign(i64 [[INT]]) [ "ptrauth"(i64 0, i64 18983), "ptrauth"(i64 0, i64 0) ] + // TYPE: [[RESIGN_INT:%.*]] = call i64 @llvm.ptrauth.resign(i64 [[INT]]) [ "ptrauth"(i64 0, i64 18983, i64 0), "ptrauth"(i64 0, i64 0, i64 0) ] // TYPE: [[RESIGN:%.*]] = inttoptr i64 [[RESIGN_INT]] to ptr // TYPE: br label %[[RESIGN_CONT]] @@ -86,7 +86,7 @@ void test_cast_to_intptr() { // CHECK-LABEL: define{{.*}} void @test_function_to_function_cast void test_function_to_function_cast() { void (*fptr2)(int) = (void (*)(int))fptr; - // TYPE: call i64 @llvm.ptrauth.resign(i64 {{.*}}) [ "ptrauth"(i64 0, i64 18983), "ptrauth"(i64 0, i64 2712) ] + // TYPE: call i64 @llvm.ptrauth.resign(i64 {{.*}}) [ "ptrauth"(i64 0, i64 18983, i64 0), "ptrauth"(i64 0, i64 2712, i64 0) ] // ZERO-NOT: @llvm.ptrauth.resign } @@ -95,11 +95,11 @@ void test_call_lvalue_cast() { (*(void (*)(int))f)(42); // TYPE: entry: - // TYPE-NEXT: [[RESIGN:%.*]] = call i64 @llvm.ptrauth.resign(i64 ptrtoint (ptr ptrauth (ptr @f, i32 0, i64 18983) to i64)) [ "ptrauth"(i64 0, i64 18983), "ptrauth"(i64 0, i64 2712) ] + // TYPE-NEXT: [[RESIGN:%.*]] = call i64 @llvm.ptrauth.resign(i64 ptrtoint (ptr ptrauth (ptr @f, i32 0, i64 18983) to i64)) [ "ptrauth"(i64 0, i64 18983, i64 0), "ptrauth"(i64 0, i64 2712, i64 0) ] // TYPE-NEXT: [[RESIGN_INT:%.*]] = inttoptr i64 [[RESIGN]] to ptr - // TYPE-NEXT: call void [[RESIGN_INT]](i32 noundef 42) [ "ptrauth"(i64 0, i64 2712) ] + // TYPE-NEXT: call void [[RESIGN_INT]](i32 noundef 42) [ "ptrauth"(i64 0, i64 2712, i64 0) ] // ZERO-NOT: @llvm.ptrauth.resign - // ZERO: call void ptrauth (ptr @f, i32 0)(i32 noundef 42) [ "ptrauth"(i64 0, i64 0) ] + // ZERO: call void ptrauth (ptr @f, i32 0)(i32 noundef 42) [ "ptrauth"(i64 0, i64 0, i64 0) ] } diff --git a/clang/test/CodeGen/ptrauth-function-type-discriminator.c b/clang/test/CodeGen/ptrauth-function-type-discriminator.c index 5b8dc6c3d7603..72b5c1423d639 100644 --- a/clang/test/CodeGen/ptrauth-function-type-discriminator.c +++ b/clang/test/CodeGen/ptrauth-function-type-discriminator.c @@ -68,7 +68,7 @@ void (*fptr4)(void) = __builtin_ptrauth_sign_constant(&external_function, 2, __b // CHECK-LABEL: define{{.*}} void @test_call() void test_call() { // CHECK: [[T0:%.*]] = load ptr, ptr @fnptr, - // CHECK-NEXT: call void [[T0]]() [ "ptrauth"(i64 0, i64 18983) ] + // CHECK-NEXT: call void [[T0]]() [ "ptrauth"(i64 0, i64 18983, i64 0) ] fnptr(); } @@ -109,7 +109,7 @@ void test_knr() { // CHECKC: [[P:%.*]] = alloca ptr // CHECKC: store ptr ptrauth (ptr @knr, i32 0, i64 18983), ptr [[P]] // CHECKC: [[LOAD:%.*]] = load ptr, ptr [[P]] - // CHECKC: call void [[LOAD]](i32 noundef 0) [ "ptrauth"(i64 0, i64 18983) ] + // CHECKC: call void [[LOAD]](i32 noundef 0) [ "ptrauth"(i64 0, i64 18983, i64 0) ] } // CHECKC-LABEL: define{{.*}} void @test_redeclaration @@ -123,8 +123,8 @@ void test_redeclaration() { // CHECKC: store ptr ptrauth (ptr @redecl, i32 0, i64 18983), ptr %ptr // CHECKC: store ptr ptrauth (ptr @redecl, i32 0, i64 2712), ptr %ptr2 - // CHECKC: call void {{.*}}() [ "ptrauth"(i64 0, i64 18983) ] - // CHECKC: call void {{.*}}(i32 noundef 0) [ "ptrauth"(i64 0, i64 2712) ] + // CHECKC: call void {{.*}}() [ "ptrauth"(i64 0, i64 18983, i64 0) ] + // CHECKC: call void {{.*}}(i32 noundef 0) [ "ptrauth"(i64 0, i64 2712, i64 0) ] } void knr2(param) @@ -137,7 +137,7 @@ void test_redecl_knr() { p(); // CHECKC: store ptr ptrauth (ptr @knr2, i32 0, i64 18983) - // CHECKC: call void {{.*}}() [ "ptrauth"(i64 0, i64 18983) ] + // CHECKC: call void {{.*}}() [ "ptrauth"(i64 0, i64 18983, i64 0) ] void knr2(int); @@ -145,7 +145,7 @@ void test_redecl_knr() { p2(0); // CHECKC: store ptr ptrauth (ptr @knr2, i32 0, i64 2712) - // CHECKC: call void {{.*}}(i32 noundef 0) [ "ptrauth"(i64 0, i64 2712) ] + // CHECKC: call void {{.*}}(i32 noundef 0) [ "ptrauth"(i64 0, i64 2712, i64 0) ] } #endif diff --git a/clang/test/CodeGen/ptrauth-function.c b/clang/test/CodeGen/ptrauth-function.c index 1152b773db5a3..31112f204b8d2 100644 --- a/clang/test/CodeGen/ptrauth-function.c +++ b/clang/test/CodeGen/ptrauth-function.c @@ -14,7 +14,7 @@ void test_indirect_call(void (*fp(void))) { // CHECK: %[[FP_ADDR:.*]] = alloca ptr, align 8 // CHECK: store ptr %[[FP]], ptr %[[FP_ADDR]], align 8 // CHECK: %[[V0:.*]] = load ptr, ptr %[[FP_ADDR]], align 8 - // CHECK: %[[CALL:.*]] = call ptr %[[V0]]() [ "ptrauth"(i64 0, i64 0) ] + // CHECK: %[[CALL:.*]] = call ptr %[[V0]]() [ "ptrauth"(i64 0, i64 0, i64 0) ] fp(); } diff --git a/clang/test/CodeGen/ptrauth-in-c-struct.c b/clang/test/CodeGen/ptrauth-in-c-struct.c index bca14fda3d506..ed928bb8214b7 100644 --- a/clang/test/CodeGen/ptrauth-in-c-struct.c +++ b/clang/test/CodeGen/ptrauth-in-c-struct.c @@ -57,7 +57,7 @@ int g0; // CHECK: %[[V12:.*]] = ptrtoint ptr %[[V9]] to i64 // CHECK: %[[V14:.*]] = ptrtoint ptr %[[V6]] to i64 // CHECK: %[[V17:.*]] = ptrtoint ptr %[[V11]] to i64 -// CHECK: %[[V18:.*]] = call i64 @llvm.ptrauth.resign(i64 %[[V17]]) [ "ptrauth"(i64 1, i64 %[[V12]], i64 50), "ptrauth"(i64 1, i64 %[[V14]], i64 50) ] +// CHECK: %[[V18:.*]] = call i64 @llvm.ptrauth.resign(i64 %[[V17]]) [ "ptrauth"(i64 1, i64 50, i64 %[[V12]]), "ptrauth"(i64 1, i64 50, i64 %[[V14]]) ] void test_copy_constructor_SA(SA *s) { SA t = *s; @@ -79,7 +79,7 @@ void test_copy_constructor_SA(SA *s) { // CHECK: %[[V12:.*]] = ptrtoint ptr %[[V9]] to i64 // CHECK: %[[V14:.*]] = ptrtoint ptr %[[V6]] to i64 // CHECK: %[[V17:.*]] = ptrtoint ptr %[[V11]] to i64 -// CHECK: %[[V18:.*]] = call i64 @llvm.ptrauth.resign(i64 %[[V17]]) [ "ptrauth"(i64 2, i64 %[[V12]], i64 30), "ptrauth"(i64 2, i64 %[[V14]], i64 30) ] +// CHECK: %[[V18:.*]] = call i64 @llvm.ptrauth.resign(i64 %[[V17]]) [ "ptrauth"(i64 2, i64 30, i64 %[[V12]]), "ptrauth"(i64 2, i64 30, i64 %[[V14]]) ] void test_copy_constructor_SA2(SA2 *s) { SA2 t = *s; @@ -164,12 +164,12 @@ void test_parameter_SI(SI a) { // CHECK-LABEL: define void @test_array( // CHECK: %[[F1:.*]] = getelementptr inbounds nuw %[[STRUCT_SA]], ptr %{{.*}}, i32 0, i32 1 // CHECK: %[[V0:.*]] = ptrtoint ptr %[[F1]] to i64 -// CHECK: %[[V2:.*]] = call i64 @llvm.ptrauth.sign(i64 ptrtoint (ptr @g0 to i64)) [ "ptrauth"(i64 1, i64 %[[V0]], i64 50) ] +// CHECK: %[[V2:.*]] = call i64 @llvm.ptrauth.sign(i64 ptrtoint (ptr @g0 to i64)) [ "ptrauth"(i64 1, i64 50, i64 %[[V0]]) ] // CHECK: %[[V3:.*]] = inttoptr i64 %[[V2]] to ptr // CHECK: store ptr %[[V3]], ptr %[[F1]], align 8 // CHECK: %[[F12:.*]] = getelementptr inbounds nuw %[[STRUCT_SA]], ptr %{{.*}}, i32 0, i32 1 // CHECK: %[[V4:.*]] = ptrtoint ptr %[[F12]] to i64 -// CHECK: %[[V6:.*]] = call i64 @llvm.ptrauth.sign(i64 ptrtoint (ptr @g0 to i64)) [ "ptrauth"(i64 1, i64 %[[V4]], i64 50) ] +// CHECK: %[[V6:.*]] = call i64 @llvm.ptrauth.sign(i64 ptrtoint (ptr @g0 to i64)) [ "ptrauth"(i64 1, i64 50, i64 %[[V4]]) ] // CHECK: %[[V7:.*]] = inttoptr i64 %[[V6]] to ptr // CHECK: store ptr %[[V7]], ptr %[[F12]], align 8 diff --git a/clang/test/CodeGen/ptrauth-intrinsics.c b/clang/test/CodeGen/ptrauth-intrinsics.c index 75a7d716b19d2..c4246ac16fc63 100644 --- a/clang/test/CodeGen/ptrauth-intrinsics.c +++ b/clang/test/CodeGen/ptrauth-intrinsics.c @@ -15,7 +15,7 @@ void test_auth() { // CHECK-NEXT: [[T0:%.*]] = ptrtoint ptr [[PTR]] to i64 // CHECK-NEXT: [[DISC0:%.*]] = load ptr, ptr @ptr_discriminator, // CHECK-NEXT: [[DISC:%.*]] = ptrtoint ptr [[DISC0]] to i64 - // CHECK-NEXT: [[T1:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[T0]]) [ "ptrauth"(i64 0, i64 [[DISC]]) ] + // CHECK-NEXT: [[T1:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[T0]]) [ "ptrauth"(i64 0, i64 0, i64 [[DISC]]) ] // CHECK-NEXT: [[RESULT:%.*]] = inttoptr i64 [[T1]] to ptr // CHECK-NEXT: store ptr [[RESULT]], ptr @fnptr, fnptr = __builtin_ptrauth_auth(fnptr, 0, ptr_discriminator); @@ -37,7 +37,7 @@ void test_sign_unauthenticated() { // CHECK-NEXT: [[T0:%.*]] = ptrtoint ptr [[PTR]] to i64 // CHECK-NEXT: [[DISC0:%.*]] = load ptr, ptr @ptr_discriminator, // CHECK-NEXT: [[DISC:%.*]] = ptrtoint ptr [[DISC0]] to i64 - // CHECK-NEXT: [[T1:%.*]] = call i64 @llvm.ptrauth.sign(i64 [[T0]]) [ "ptrauth"(i64 0, i64 [[DISC]]) ] + // CHECK-NEXT: [[T1:%.*]] = call i64 @llvm.ptrauth.sign(i64 [[T0]]) [ "ptrauth"(i64 0, i64 0, i64 [[DISC]]) ] // CHECK-NEXT: [[RESULT:%.*]] = inttoptr i64 [[T1]] to ptr // CHECK-NEXT: store ptr [[RESULT]], ptr @fnptr, fnptr = __builtin_ptrauth_sign_unauthenticated(fnptr, 0, ptr_discriminator); @@ -49,22 +49,20 @@ void test_auth_and_resign() { // CHECK-NEXT: [[T0:%.*]] = ptrtoint ptr [[PTR]] to i64 // CHECK-NEXT: [[DISC0:%.*]] = load ptr, ptr @ptr_discriminator, // CHECK-NEXT: [[DISC:%.*]] = ptrtoint ptr [[DISC0]] to i64 - // CHECK-NEXT: [[T1:%.*]] = call i64 @llvm.ptrauth.resign(i64 [[T0]]) [ "ptrauth"(i64 0, i64 [[DISC]]), "ptrauth"(i64 3, i64 15) ] + // CHECK-NEXT: [[T1:%.*]] = call i64 @llvm.ptrauth.resign(i64 [[T0]]) [ "ptrauth"(i64 0, i64 0, i64 [[DISC]]), "ptrauth"(i64 3, i64 15, i64 0) ] // CHECK-NEXT: [[RESULT:%.*]] = inttoptr i64 [[T1]] to ptr // CHECK-NEXT: store ptr [[RESULT]], ptr @fnptr, fnptr = __builtin_ptrauth_auth_and_resign(fnptr, 0, ptr_discriminator, 3, 15); } -// FIXME Reject calls to blend not as an argument of auth/sign/resign. - // CHECK-LABEL: define {{.*}}void @test_auth_blend_discriminator() void test_auth_blend_discriminator() { // CHECK: [[FNPTR:%.*]] = load ptr, ptr @fnptr, // CHECK-NEXT: [[CAST_FNPTR:%.*]] = ptrtoint ptr [[FNPTR]] to i64 - // CHECK: [[PTR:%.*]] = load ptr, ptr @ptr_discriminator, + // CHECK: [[DISC:%.*]] = load i64, ptr @int_discriminator, + // CHECK-NEXT: [[PTR:%.*]] = load ptr, ptr @ptr_discriminator, // CHECK-NEXT: [[CAST_PTR:%.*]] = ptrtoint ptr [[PTR]] to i64 - // CHECK-NEXT: [[DISC:%.*]] = load i64, ptr @int_discriminator, - // CHECK-NEXT: [[T1:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[CAST_FNPTR]]) [ "ptrauth"(i64 0, i64 [[CAST_PTR]], i64 [[DISC]]) ] + // CHECK-NEXT: [[T1:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[CAST_FNPTR]]) [ "ptrauth"(i64 0, i64 [[DISC]], i64 [[CAST_PTR]]) ] // CHECK-NEXT: [[RESULT:%.*]] = inttoptr i64 [[T1]] to ptr // CHECK-NEXT: store ptr [[RESULT]], ptr @fnptr, fnptr = __builtin_ptrauth_auth(fnptr, 0, __builtin_ptrauth_blend_discriminator(ptr_discriminator, int_discriminator)); @@ -74,10 +72,10 @@ void test_auth_blend_discriminator() { void test_sign_blend_discriminator() { // CHECK: [[FNPTR:%.*]] = load ptr, ptr @fnptr, // CHECK-NEXT: [[CAST_FNPTR:%.*]] = ptrtoint ptr [[FNPTR]] to i64 - // CHECK: [[PTR:%.*]] = load ptr, ptr @ptr_discriminator, + // CHECK: [[DISC:%.*]] = load i64, ptr @int_discriminator, + // CHECK-NEXT: [[PTR:%.*]] = load ptr, ptr @ptr_discriminator, // CHECK-NEXT: [[CAST_PTR:%.*]] = ptrtoint ptr [[PTR]] to i64 - // CHECK-NEXT: [[DISC:%.*]] = load i64, ptr @int_discriminator, - // CHECK-NEXT: [[T1:%.*]] = call i64 @llvm.ptrauth.sign(i64 [[CAST_FNPTR]]) [ "ptrauth"(i64 0, i64 [[CAST_PTR]], i64 [[DISC]]) ] + // CHECK-NEXT: [[T1:%.*]] = call i64 @llvm.ptrauth.sign(i64 [[CAST_FNPTR]]) [ "ptrauth"(i64 0, i64 [[DISC]], i64 [[CAST_PTR]]) ] // CHECK-NEXT: [[RESULT:%.*]] = inttoptr i64 [[T1]] to ptr // CHECK-NEXT: store ptr [[RESULT]], ptr @fnptr, fnptr = __builtin_ptrauth_sign_unauthenticated(fnptr, 0, __builtin_ptrauth_blend_discriminator(ptr_discriminator, int_discriminator)); @@ -87,10 +85,10 @@ void test_sign_blend_discriminator() { void test_resign_blend_discriminator() { // CHECK: [[FNPTR:%.*]] = load ptr, ptr @fnptr, // CHECK-NEXT: [[CAST_FNPTR:%.*]] = ptrtoint ptr [[FNPTR]] to i64 - // CHECK: [[PTR:%.*]] = load ptr, ptr @ptr_discriminator, + // CHECK: [[DISC:%.*]] = load i64, ptr @int_discriminator, + // CHECK-NEXT: [[PTR:%.*]] = load ptr, ptr @ptr_discriminator, // CHECK-NEXT: [[CAST_PTR:%.*]] = ptrtoint ptr [[PTR]] to i64 - // CHECK-NEXT: [[DISC:%.*]] = load i64, ptr @int_discriminator, - // CHECK-NEXT: [[T1:%.*]] = call i64 @llvm.ptrauth.resign(i64 [[CAST_FNPTR]]) [ "ptrauth"(i64 0, i64 [[CAST_PTR]], i64 [[DISC]]), "ptrauth"(i64 1, i64 ptrtoint (ptr @int_discriminator to i64), i64 1234) ] + // CHECK-NEXT: [[T1:%.*]] = call i64 @llvm.ptrauth.resign(i64 [[CAST_FNPTR]]) [ "ptrauth"(i64 0, i64 [[DISC]], i64 [[CAST_PTR]]), "ptrauth"(i64 1, i64 1234, i64 ptrtoint (ptr @int_discriminator to i64)) ] // CHECK-NEXT: [[RESULT:%.*]] = inttoptr i64 [[T1]] to ptr // CHECK-NEXT: store ptr [[RESULT]], ptr @fnptr, fnptr = __builtin_ptrauth_auth_and_resign(fnptr, 0, __builtin_ptrauth_blend_discriminator(ptr_discriminator, int_discriminator), diff --git a/clang/test/CodeGen/ptrauth-qualifier-blocks.c b/clang/test/CodeGen/ptrauth-qualifier-blocks.c index 251af074ab2ae..119f283347d1e 100644 --- a/clang/test/CodeGen/ptrauth-qualifier-blocks.c +++ b/clang/test/CodeGen/ptrauth-qualifier-blocks.c @@ -20,7 +20,7 @@ void test_block_nonaddress_capture() { use_block(^{ return ptr->value; }); } // CHECK-LABEL: define internal i32 @__test_block_nonaddress_capture_block_invoke -// CHECK: call i64 @llvm.ptrauth.auth(i64 {{%.*}}) [ "ptrauth"(i64 1, i64 15) ] +// CHECK: call i64 @llvm.ptrauth.auth(i64 {{%.*}}) [ "ptrauth"(i64 1, i64 15, i64 0) ] // CHECK-LABEL: define void @test_block_address_capture( void test_block_address_capture() { @@ -35,7 +35,7 @@ void test_block_address_capture() { // CHECK: [[T0:%.*]] = icmp ne ptr [[LOAD]], null // CHECK: br i1 [[T0]] // CHECK: [[T0:%.*]] = ptrtoint ptr [[LOAD]] to i64 - // CHECK: [[T1:%.*]] = call i64 @llvm.ptrauth.resign(i64 [[T0]]) [ "ptrauth"(i64 1, i64 [[T01]], i64 30), "ptrauth"(i64 1, i64 [[T02]], i64 30) ] + // CHECK: [[T1:%.*]] = call i64 @llvm.ptrauth.resign(i64 [[T0]]) [ "ptrauth"(i64 1, i64 30, i64 [[T01]]), "ptrauth"(i64 1, i64 30, i64 [[T02]]) ] // CHECK: [[T2:%.*]] = inttoptr i64 [[T1]] to ptr // CHECK: [[T0:%.*]] = phi // CHECK: store ptr [[T0]], ptr [[CAPTURE]] @@ -43,7 +43,7 @@ void test_block_address_capture() { use_block(^{ return ptr->value; }); } // CHECK-LABEL: define internal i32 @__test_block_address_capture_block_invoke -// CHECK: call i64 @llvm.ptrauth.auth(i64 {{%.*}}) [ "ptrauth"(i64 1, i64 {{.*}}, i64 30) ] +// CHECK: call i64 @llvm.ptrauth.auth(i64 {{%.*}}) [ "ptrauth"(i64 1, i64 30, i64 {{.*}}) ] // CHECK: linkonce_odr hidden void @__copy_helper_block_8_32p1d30( // CHECK: [[OLDSLOT:%.*]] = getelementptr inbounds {{.*}} {{.*}}, i32 0, i32 5 @@ -54,7 +54,7 @@ void test_block_address_capture() { // CHECK: [[T0:%.*]] = icmp ne ptr [[LOAD]], null // CHECK: br i1 [[T0]] // CHECK: [[T0:%.*]] = ptrtoint ptr [[LOAD]] to i64 -// CHECK: [[T1:%.*]] = call i64 @llvm.ptrauth.resign(i64 [[T0]]) [ "ptrauth"(i64 1, i64 [[T01]], i64 30), "ptrauth"(i64 1, i64 [[T02]], i64 30) ] +// CHECK: [[T1:%.*]] = call i64 @llvm.ptrauth.resign(i64 [[T0]]) [ "ptrauth"(i64 1, i64 30, i64 [[T01]]), "ptrauth"(i64 1, i64 30, i64 [[T02]]) ] // CHECK: [[T2:%.*]] = inttoptr i64 [[T1]] to ptr // CHECK: [[T0:%.*]] = phi // CHECK: store ptr [[T0]], ptr [[NEWSLOT]] @@ -79,12 +79,12 @@ void test_block_address_byref_capture() { // CHECK: store i32 48, // CHECK: [[COPY_HELPER_FIELD:%.*]] = getelementptr inbounds nuw [[BYREF_T]], ptr [[BYREF]], i32 0, i32 4 // CHECK: [[T0:%.*]] = ptrtoint ptr [[COPY_HELPER_FIELD]] to i64 - // CHECK: [[T1:%.*]] = call i64 @llvm.ptrauth.sign(i64 ptrtoint (ptr @__Block_byref_object_copy_ to i64)) [ "ptrauth"(i64 0, i64 [[T0]]) ] + // CHECK: [[T1:%.*]] = call i64 @llvm.ptrauth.sign(i64 ptrtoint (ptr @__Block_byref_object_copy_ to i64)) [ "ptrauth"(i64 0, i64 0, i64 [[T0]]) ] // CHECK: [[T2:%.*]] = inttoptr i64 [[T1]] to ptr // CHECK: store ptr [[T2]], ptr [[COPY_HELPER_FIELD]], align // CHECK: [[DISPOSE_HELPER_FIELD:%.*]] = getelementptr inbounds nuw [[BYREF_T]], ptr [[BYREF]], i32 0, i32 5 // CHECK: [[T0:%.*]] = ptrtoint ptr [[DISPOSE_HELPER_FIELD]] to i64 - // CHECK: [[T1:%.*]] = call i64 @llvm.ptrauth.sign(i64 ptrtoint (ptr @__Block_byref_object_dispose_ to i64)) [ "ptrauth"(i64 0, i64 [[T0]]) ] + // CHECK: [[T1:%.*]] = call i64 @llvm.ptrauth.sign(i64 ptrtoint (ptr @__Block_byref_object_dispose_ to i64)) [ "ptrauth"(i64 0, i64 0, i64 [[T0]]) ] // CHECK: [[T2:%.*]] = inttoptr i64 [[T1]] to ptr // CHECK: store ptr [[T2]], ptr [[DISPOSE_HELPER_FIELD]], align // flags - copy/dispose required @@ -101,7 +101,7 @@ void test_block_address_byref_capture() { // CHECK: [[T0:%.*]] = icmp ne ptr [[LOAD]], null // CHECK: br i1 [[T0]] // CHECK: [[T0:%.*]] = ptrtoint ptr [[LOAD]] to i64 -// CHECK: [[T1:%.*]] = call i64 @llvm.ptrauth.resign(i64 [[T0]]) [ "ptrauth"(i64 1, i64 [[T01]], i64 60), "ptrauth"(i64 1, i64 [[T02]], i64 60) ] +// CHECK: [[T1:%.*]] = call i64 @llvm.ptrauth.resign(i64 [[T0]]) [ "ptrauth"(i64 1, i64 60, i64 [[T01]]), "ptrauth"(i64 1, i64 60, i64 [[T02]]) ] // CHECK: [[T2:%.*]] = inttoptr i64 [[T1]] to ptr // CHECK: [[T0:%.*]] = phi // CHECK: store ptr [[T0]], ptr [[NEWSLOT]] diff --git a/clang/test/CodeGen/ptrauth-qualifier-function.c b/clang/test/CodeGen/ptrauth-qualifier-function.c index 7adcc5a0d71c0..b998184031a91 100644 --- a/clang/test/CodeGen/ptrauth-qualifier-function.c +++ b/clang/test/CodeGen/ptrauth-qualifier-function.c @@ -26,7 +26,7 @@ void test_assign_to_qualified() { // TYPE: [[RESIGN1]]: // TYPE-NEXT: [[FPTR2:%.*]] = ptrtoint ptr [[FPTR]] to i64 - // TYPE-NEXT: [[FPTR4:%.*]] = call i64 @llvm.ptrauth.resign(i64 [[FPTR2]]) [ "ptrauth"(i64 0, i64 18983), "ptrauth"(i64 0, i64 2712) ] + // TYPE-NEXT: [[FPTR4:%.*]] = call i64 @llvm.ptrauth.resign(i64 [[FPTR2]]) [ "ptrauth"(i64 0, i64 18983, i64 0), "ptrauth"(i64 0, i64 2712, i64 0) ] // TYPE-NEXT: [[FPTR5:%.*]] = inttoptr i64 [[FPTR4]] to ptr // TYPE-NEXT: br label %[[JOIN1]] @@ -37,9 +37,9 @@ void test_assign_to_qualified() { // CHECK: [[RESIGN2]]: // TYPE-NEXT: [[FPTR7:%.*]] = ptrtoint ptr [[FPTR6]] to i64 - // TYPE-NEXT: [[FPTR8:%.*]] = call i64 @llvm.ptrauth.resign(i64 [[FPTR7]]) [ "ptrauth"(i64 0, i64 2712), "ptrauth"(i64 0, i64 42) ] + // TYPE-NEXT: [[FPTR8:%.*]] = call i64 @llvm.ptrauth.resign(i64 [[FPTR7]]) [ "ptrauth"(i64 0, i64 2712, i64 0), "ptrauth"(i64 0, i64 42, i64 0) ] // ZERO-NEXT: [[FPTR7:%.*]] = ptrtoint ptr [[FPTR]] to i64 - // ZERO-NEXT: [[FPTR8:%.*]] = call i64 @llvm.ptrauth.resign(i64 [[FPTR7]]) [ "ptrauth"(i64 0, i64 0), "ptrauth"(i64 0, i64 42) ] + // ZERO-NEXT: [[FPTR8:%.*]] = call i64 @llvm.ptrauth.resign(i64 [[FPTR7]]) [ "ptrauth"(i64 0, i64 0, i64 0), "ptrauth"(i64 0, i64 42, i64 0) ] // CHECK-NEXT: [[FPTR9:%.*]] = inttoptr i64 [[FPTR8]] to ptr // CHECK-NEXT: br label %[[JOIN2]] @@ -61,7 +61,7 @@ void test_assign_from_qualified() { // TYPE: [[RESIGN1]]: // TYPE-NEXT: [[FPTR1:%.*]] = ptrtoint ptr [[FPTR]] to i64 - // TYPE-NEXT: [[FPTR2:%.*]] = call i64 @llvm.ptrauth.resign(i64 [[FPTR1]]) [ "ptrauth"(i64 0, i64 42), "ptrauth"(i64 0, i64 2712) ] + // TYPE-NEXT: [[FPTR2:%.*]] = call i64 @llvm.ptrauth.resign(i64 [[FPTR1]]) [ "ptrauth"(i64 0, i64 42, i64 0), "ptrauth"(i64 0, i64 2712, i64 0) ] // TYPE-NEXT: [[FPTR3:%.*]] = inttoptr i64 [[FPTR2]] to ptr // TYPE-NEXT: br label %[[JOIN1]] @@ -72,9 +72,9 @@ void test_assign_from_qualified() { // CHECK: [[RESIGN2]]: // TYPE-NEXT: [[FPTR6:%.*]] = ptrtoint ptr [[FPTR4]] to i64 - // TYPE-NEXT: [[FPTR7:%.*]] = call i64 @llvm.ptrauth.resign(i64 [[FPTR6]]) [ "ptrauth"(i64 0, i64 2712), "ptrauth"(i64 0, i64 18983) ] + // TYPE-NEXT: [[FPTR7:%.*]] = call i64 @llvm.ptrauth.resign(i64 [[FPTR6]]) [ "ptrauth"(i64 0, i64 2712, i64 0), "ptrauth"(i64 0, i64 18983, i64 0) ] // ZERO-NEXT: [[FPTR6:%.*]] = ptrtoint ptr [[FPTR]] to i64 - // ZERO-NEXT: [[FPTR7:%.*]] = call i64 @llvm.ptrauth.resign(i64 [[FPTR6]]) [ "ptrauth"(i64 0, i64 42), "ptrauth"(i64 0, i64 0) ] + // ZERO-NEXT: [[FPTR7:%.*]] = call i64 @llvm.ptrauth.resign(i64 [[FPTR6]]) [ "ptrauth"(i64 0, i64 42, i64 0), "ptrauth"(i64 0, i64 0, i64 0) ] // CHECK-NEXT: [[FPTR8:%.*]] = inttoptr i64 [[FPTR7]] to ptr // CHECK-NEXT: br label %[[JOIN2]] @@ -88,8 +88,8 @@ void test_assign_from_qualified() { void test_const_ptr_function_call(void) { f_const_ptr(1); - // TYPE: call void ptrauth (ptr @f, i32 0, i64 2712)(i32 noundef 1) [ "ptrauth"(i64 0, i64 2712) ] - // ZERO: call void ptrauth (ptr @f, i32 0)(i32 noundef 1) [ "ptrauth"(i64 0, i64 0) ] + // TYPE: call void ptrauth (ptr @f, i32 0, i64 2712)(i32 noundef 1) [ "ptrauth"(i64 0, i64 2712, i64 0) ] + // ZERO: call void ptrauth (ptr @f, i32 0)(i32 noundef 1) [ "ptrauth"(i64 0, i64 0, i64 0) ] } #ifdef __cplusplus @@ -105,7 +105,7 @@ void (* const __ptrauth(0, 1, 43) &f_ref)(int) = f_const_ptr2; // CHECK-CXX: [[RESIGN_NONNULL]]: // CHECK-CXX: %[[V1:.*]] = ptrtoint ptr %[[CALL]] to i64 -// CHECK-CXX: %[[V2:.*]] = call i64 @llvm.ptrauth.resign(i64 %[[V1]]) [ "ptrauth"(i64 0, i64 2712), "ptrauth"(i64 0, i64 42) ] +// CHECK-CXX: %[[V2:.*]] = call i64 @llvm.ptrauth.resign(i64 %[[V1]]) [ "ptrauth"(i64 0, i64 2712, i64 0), "ptrauth"(i64 0, i64 42, i64 0) ] // CHECK-CXX: %[[V3:.*]] = inttoptr i64 %[[V2]] to ptr // CHECK-CXX: br label %[[RESIGN_CONT]] @@ -121,7 +121,7 @@ void (* const __ptrauth(0, 1, 43) &f_ref)(int) = f_const_ptr2; // CHECK-CXX: [[RESIGN_NONNULL]]: // CHECK-CXX: %[[V3:.*]] = ptrtoint ptr %[[V0]] to i64 -// CHECK-CXX: %[[V4:.*]] = call i64 @llvm.ptrauth.resign(i64 %[[V3]]) [ "ptrauth"(i64 0, i64 42), "ptrauth"(i64 0, i64 ptrtoint (ptr @_ZGR5f_ref_ to i64), i64 43) ] +// CHECK-CXX: %[[V4:.*]] = call i64 @llvm.ptrauth.resign(i64 %[[V3]]) [ "ptrauth"(i64 0, i64 42, i64 0), "ptrauth"(i64 0, i64 43, i64 ptrtoint (ptr @_ZGR5f_ref_ to i64)) ] // CHECK-CXX: %[[V5:.*]] = inttoptr i64 %[[V4]] to ptr // CHECK-CXX: br label %[[RESIGN_CONT]] @@ -137,7 +137,7 @@ void test_const_ptr_ref_function_call(void) { // CHECK-CXX: %[[V0:.*]] = load ptr, ptr @f_ref, align 8 // CHECK-CXX: %[[V1:.*]] = load ptr, ptr %[[V0]], align 8 // CHECK-CXX: %[[V2:.*]] = ptrtoint ptr %[[V0]] to i64 - // CHECK-CXX: call void %[[V1]](i32 noundef 1) [ "ptrauth"(i64 0, i64 %[[V2]], i64 43) ] + // CHECK-CXX: call void %[[V1]](i32 noundef 1) [ "ptrauth"(i64 0, i64 43, i64 %[[V2]]) ] } } #endif diff --git a/clang/test/CodeGen/ptrauth-qualifier-loadstore.c b/clang/test/CodeGen/ptrauth-qualifier-loadstore.c index eac41d9f19649..1a9c725bac281 100644 --- a/clang/test/CodeGen/ptrauth-qualifier-loadstore.c +++ b/clang/test/CodeGen/ptrauth-qualifier-loadstore.c @@ -26,11 +26,11 @@ extern void use_upf(func_t *ptr); // CHECK-LABEL: define {{.*}}void @test_store_data_i_constant() void test_store_data_i_constant() { // CHECK: [[V:%.*]] = alloca ptr, -// CHECK-NEXT: [[SIGN:%.*]] = call i64 @llvm.ptrauth.sign(i64 ptrtoint (ptr @external_int to i64)) [ "ptrauth"(i64 1, i64 50) ] +// CHECK-NEXT: [[SIGN:%.*]] = call i64 @llvm.ptrauth.sign(i64 ptrtoint (ptr @external_int to i64)) [ "ptrauth"(i64 1, i64 50, i64 0) ] // CHECK-NEXT: [[T0:%.*]] = inttoptr i64 [[SIGN]] to ptr // CHECK-NEXT: store ptr [[T0]], ptr [[V]], int * IQ iqpi = &external_int; -// CHECK-NEXT: [[T0:%.*]] = call i64 @llvm.ptrauth.sign(i64 ptrtoint (ptr @external_int to i64)) [ "ptrauth"(i64 1, i64 50) ] +// CHECK-NEXT: [[T0:%.*]] = call i64 @llvm.ptrauth.sign(i64 ptrtoint (ptr @external_int to i64)) [ "ptrauth"(i64 1, i64 50, i64 0) ] // CHECK-NEXT: [[SIGNED:%.*]] = inttoptr i64 [[T0]] to ptr // CHECK-NEXT: store ptr [[SIGNED]], ptr [[V]], // CHECK-NEXT: ret void @@ -44,7 +44,7 @@ void test_store_data_iu() { // CHECK-NEXT: [[T0:%.*]] = icmp ne ptr [[LOAD]], null // CHECK-NEXT: br i1 [[T0]], // CHECK: [[T0:%.*]] = ptrtoint ptr [[LOAD]] to i64 -// CHECK-NEXT: [[T1:%.*]] = call i64 @llvm.ptrauth.sign(i64 [[T0]]) [ "ptrauth"(i64 1, i64 50) ] +// CHECK-NEXT: [[T1:%.*]] = call i64 @llvm.ptrauth.sign(i64 [[T0]]) [ "ptrauth"(i64 1, i64 50, i64 0) ] // CHECK-NEXT: [[SIGNED:%.*]] = inttoptr i64 [[T1]] to ptr // CHECK-NEXT: br label // CHECK: [[T0:%.*]] = phi ptr [ null, {{.*}} ], [ [[SIGNED]], {{.*}} ] @@ -54,7 +54,7 @@ void test_store_data_iu() { // CHECK-NEXT: [[T0:%.*]] = icmp ne ptr [[LOAD]], null // CHECK-NEXT: br i1 [[T0]], // CHECK: [[T0:%.*]] = ptrtoint ptr [[LOAD]] to i64 -// CHECK-NEXT: [[T1:%.*]] = call i64 @llvm.ptrauth.sign(i64 [[T0]]) [ "ptrauth"(i64 1, i64 50) ] +// CHECK-NEXT: [[T1:%.*]] = call i64 @llvm.ptrauth.sign(i64 [[T0]]) [ "ptrauth"(i64 1, i64 50, i64 0) ] // CHECK-NEXT: [[SIGNED:%.*]] = inttoptr i64 [[T1]] to ptr // CHECK-NEXT: br label // CHECK: [[T0:%.*]] = phi ptr [ null, {{.*}} ], [ [[SIGNED]], {{.*}} ] @@ -69,7 +69,7 @@ void test_store_data_ia() { // CHECK-NEXT: [[T0:%.*]] = icmp ne ptr [[LOAD]], null // CHECK-NEXT: br i1 [[T0]], // CHECK: [[T0:%.*]] = ptrtoint ptr [[LOAD]] to i64 -// CHECK-NEXT: [[T1:%.*]] = call i64 @llvm.ptrauth.resign(i64 [[T0]]) [ "ptrauth"(i64 1, i64 ptrtoint (ptr @global_aqpi to i64), i64 50), "ptrauth"(i64 1, i64 50) ] +// CHECK-NEXT: [[T1:%.*]] = call i64 @llvm.ptrauth.resign(i64 [[T0]]) [ "ptrauth"(i64 1, i64 50, i64 ptrtoint (ptr @global_aqpi to i64)), "ptrauth"(i64 1, i64 50, i64 0) ] // CHECK-NEXT: [[SIGNED:%.*]] = inttoptr i64 [[T1]] to ptr // CHECK-NEXT: br label // CHECK: [[T0:%.*]] = phi ptr [ null, {{.*}} ], [ [[SIGNED]], {{.*}} ] @@ -79,7 +79,7 @@ void test_store_data_ia() { // CHECK-NEXT: [[T0:%.*]] = icmp ne ptr [[LOAD]], null // CHECK-NEXT: br i1 [[T0]], // CHECK: [[T0:%.*]] = ptrtoint ptr [[LOAD]] to i64 -// CHECK-NEXT: [[T1:%.*]] = call i64 @llvm.ptrauth.resign(i64 [[T0]]) [ "ptrauth"(i64 1, i64 ptrtoint (ptr @global_aqpi to i64), i64 50), "ptrauth"(i64 1, i64 50) ] +// CHECK-NEXT: [[T1:%.*]] = call i64 @llvm.ptrauth.resign(i64 [[T0]]) [ "ptrauth"(i64 1, i64 50, i64 ptrtoint (ptr @global_aqpi to i64)), "ptrauth"(i64 1, i64 50, i64 0) ] // CHECK-NEXT: [[SIGNED:%.*]] = inttoptr i64 [[T1]] to ptr // CHECK-NEXT: br label // CHECK: [[T0:%.*]] = phi ptr [ null, {{.*}} ], [ [[SIGNED]], {{.*}} ] @@ -89,7 +89,7 @@ void test_store_data_ia() { // CHECK-NEXT: [[T0:%.*]] = icmp ne ptr [[LOAD]], null // CHECK-NEXT: br i1 [[T0]], // CHECK: [[T0:%.*]] = ptrtoint ptr [[LOAD]] to i64 -// CHECK-NEXT: [[T1:%.*]] = call i64 @llvm.ptrauth.resign(i64 [[T0]]) [ "ptrauth"(i64 1, i64 ptrtoint (ptr @global_aqpi to i64), i64 50), "ptrauth"(i64 1, i64 50) ] +// CHECK-NEXT: [[T1:%.*]] = call i64 @llvm.ptrauth.resign(i64 [[T0]]) [ "ptrauth"(i64 1, i64 50, i64 ptrtoint (ptr @global_aqpi to i64)), "ptrauth"(i64 1, i64 50, i64 0) ] // CHECK-NEXT: [[SIGNED:%.*]] = inttoptr i64 [[T1]] to ptr // CHECK-NEXT: br label // CHECK: [[RESULT:%.*]] = phi ptr [ null, {{.*}} ], [ [[SIGNED]], {{.*}} ] @@ -97,7 +97,7 @@ void test_store_data_ia() { // CHECK-NEXT: [[T0:%.*]] = icmp ne ptr [[RESULT]], null // CHECK-NEXT: br i1 [[T0]], // CHECK: [[T0:%.*]] = ptrtoint ptr [[RESULT]] to i64 -// CHECK-NEXT: [[T1:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[T0]]) [ "ptrauth"(i64 1, i64 50) ] +// CHECK-NEXT: [[T1:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[T0]]) [ "ptrauth"(i64 1, i64 50, i64 0) ] // CHECK-NEXT: [[AUTHED:%.*]] = inttoptr i64 [[T1]] to ptr // CHECK-NEXT: br label // CHECK: [[RESULT:%.*]] = phi ptr [ null, {{.*}} ], [ [[AUTHED]], {{.*}} ] @@ -123,7 +123,7 @@ void test_store_data_ii_different() { // CHECK-NEXT: [[T0:%.*]] = icmp ne ptr [[LOAD]], null // CHECK-NEXT: br i1 [[T0]], // CHECK: [[T0:%.*]] = ptrtoint ptr [[LOAD]] to i64 -// CHECK-NEXT: [[T1:%.*]] = call i64 @llvm.ptrauth.resign(i64 [[T0]]) [ "ptrauth"(i64 1, i64 50), "ptrauth"(i64 1, i64 100) ] +// CHECK-NEXT: [[T1:%.*]] = call i64 @llvm.ptrauth.resign(i64 [[T0]]) [ "ptrauth"(i64 1, i64 50, i64 0), "ptrauth"(i64 1, i64 100, i64 0) ] // CHECK-NEXT: [[SIGNED:%.*]] = inttoptr i64 [[T1]] to ptr // CHECK-NEXT: br label // CHECK: [[T0:%.*]] = phi ptr [ null, {{.*}} ], [ [[SIGNED]], {{.*}} ] @@ -133,7 +133,7 @@ void test_store_data_ii_different() { // CHECK-NEXT: [[T0:%.*]] = icmp ne ptr [[LOAD]], null // CHECK-NEXT: br i1 [[T0]], // CHECK: [[T0:%.*]] = ptrtoint ptr [[LOAD]] to i64 -// CHECK-NEXT: [[T1:%.*]] = call i64 @llvm.ptrauth.resign(i64 [[T0]]) [ "ptrauth"(i64 1, i64 50), "ptrauth"(i64 1, i64 100) ] +// CHECK-NEXT: [[T1:%.*]] = call i64 @llvm.ptrauth.resign(i64 [[T0]]) [ "ptrauth"(i64 1, i64 50, i64 0), "ptrauth"(i64 1, i64 100, i64 0) ] // CHECK-NEXT: [[SIGNED:%.*]] = inttoptr i64 [[T1]] to ptr // CHECK-NEXT: br label // CHECK: [[T0:%.*]] = phi ptr [ null, {{.*}} ], [ [[SIGNED]], {{.*}} ] @@ -148,7 +148,7 @@ void test_store_data_ii_zero() { // CHECK-NEXT: [[T0:%.*]] = icmp ne ptr [[LOAD]], null // CHECK-NEXT: br i1 [[T0]], // CHECK: [[T0:%.*]] = ptrtoint ptr [[LOAD]] to i64 -// CHECK-NEXT: [[T1:%.*]] = call i64 @llvm.ptrauth.resign(i64 [[T0]]) [ "ptrauth"(i64 1, i64 50), "ptrauth"(i64 1, i64 0) ] +// CHECK-NEXT: [[T1:%.*]] = call i64 @llvm.ptrauth.resign(i64 [[T0]]) [ "ptrauth"(i64 1, i64 50, i64 0), "ptrauth"(i64 1, i64 0, i64 0) ] // CHECK-NEXT: [[SIGNED:%.*]] = inttoptr i64 [[T1]] to ptr // CHECK-NEXT: br label // CHECK: [[T0:%.*]] = phi ptr [ null, {{.*}} ], [ [[SIGNED]], {{.*}} ] @@ -158,7 +158,7 @@ void test_store_data_ii_zero() { // CHECK-NEXT: [[T0:%.*]] = icmp ne ptr [[LOAD]], null // CHECK-NEXT: br i1 [[T0]], // CHECK: [[T0:%.*]] = ptrtoint ptr [[LOAD]] to i64 -// CHECK-NEXT: [[T1:%.*]] = call i64 @llvm.ptrauth.resign(i64 [[T0]]) [ "ptrauth"(i64 1, i64 0), "ptrauth"(i64 1, i64 50) ] +// CHECK-NEXT: [[T1:%.*]] = call i64 @llvm.ptrauth.resign(i64 [[T0]]) [ "ptrauth"(i64 1, i64 0, i64 0), "ptrauth"(i64 1, i64 50, i64 0) ] // CHECK-NEXT: [[SIGNED:%.*]] = inttoptr i64 [[T1]] to ptr // CHECK-NEXT: br label // CHECK: [[T0:%.*]] = phi ptr [ null, {{.*}} ], [ [[SIGNED]], {{.*}} ] @@ -173,7 +173,7 @@ void test_load_data_i() { // CHECK-NEXT: [[T0:%.*]] = icmp ne ptr [[LOAD]], null // CHECK-NEXT: br i1 [[T0]], // CHECK: [[T0:%.*]] = ptrtoint ptr [[LOAD]] to i64 -// CHECK-NEXT: [[T1:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[T0]]) [ "ptrauth"(i64 1, i64 50) ] +// CHECK-NEXT: [[T1:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[T0]]) [ "ptrauth"(i64 1, i64 50, i64 0) ] // CHECK-NEXT: [[AUTHED:%.*]] = inttoptr i64 [[T1]] to ptr // CHECK-NEXT: br label // CHECK: [[T0:%.*]] = phi ptr [ null, {{.*}} ], [ [[AUTHED]], {{.*}} ] @@ -183,7 +183,7 @@ void test_load_data_i() { // CHECK-NEXT: [[T0:%.*]] = icmp ne ptr [[LOAD]], null // CHECK-NEXT: br i1 [[T0]], // CHECK: [[T0:%.*]] = ptrtoint ptr [[LOAD]] to i64 -// CHECK-NEXT: [[T1:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[T0]]) [ "ptrauth"(i64 1, i64 50) ] +// CHECK-NEXT: [[T1:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[T0]]) [ "ptrauth"(i64 1, i64 50, i64 0) ] // CHECK-NEXT: [[AUTHED:%.*]] = inttoptr i64 [[T1]] to ptr // CHECK-NEXT: br label // CHECK: [[T0:%.*]] = phi ptr [ null, {{.*}} ], [ [[AUTHED]], {{.*}} ] @@ -193,7 +193,7 @@ void test_load_data_i() { // CHECK-NEXT: [[T0:%.*]] = icmp ne ptr [[LOAD]], null // CHECK-NEXT: br i1 [[T0]], // CHECK: [[T0:%.*]] = ptrtoint ptr [[LOAD]] to i64 -// CHECK-NEXT: [[T1:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[T0]]) [ "ptrauth"(i64 1, i64 50) ] +// CHECK-NEXT: [[T1:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[T0]]) [ "ptrauth"(i64 1, i64 50, i64 0) ] // CHECK-NEXT: [[AUTHED:%.*]] = inttoptr i64 [[T1]] to ptr // CHECK-NEXT: br label // CHECK: [[T0:%.*]] = phi ptr [ null, {{.*}} ], [ [[AUTHED]], {{.*}} ] @@ -207,12 +207,12 @@ void test_load_data_i() { void test_store_data_a_constant() { // CHECK: [[V:%.*]] = alloca ptr, // CHECK-NEXT: [[T0:%.*]] = ptrtoint ptr [[V]] to i64 -// CHECK-NEXT: [[SIGN:%.*]] = call i64 @llvm.ptrauth.sign(i64 ptrtoint (ptr @external_int to i64)) [ "ptrauth"(i64 1, i64 [[T0]], i64 50) ] +// CHECK-NEXT: [[SIGN:%.*]] = call i64 @llvm.ptrauth.sign(i64 ptrtoint (ptr @external_int to i64)) [ "ptrauth"(i64 1, i64 50, i64 [[T0]]) ] // CHECK-NEXT: [[T0:%.*]] = inttoptr i64 [[SIGN]] to ptr // CHECK-NEXT: store ptr [[T0]], ptr [[V]], int * AQ aqpi = &external_int; // CHECK-NEXT: [[T0:%.*]] = ptrtoint ptr [[V]] to i64 -// CHECK-NEXT: [[SIGN:%.*]] = call i64 @llvm.ptrauth.sign(i64 ptrtoint (ptr @external_int to i64)) [ "ptrauth"(i64 1, i64 [[T0]], i64 50) ] +// CHECK-NEXT: [[SIGN:%.*]] = call i64 @llvm.ptrauth.sign(i64 ptrtoint (ptr @external_int to i64)) [ "ptrauth"(i64 1, i64 50, i64 [[T0]]) ] // CHECK-NEXT: [[T0:%.*]] = inttoptr i64 [[SIGN]] to ptr // CHECK-NEXT: store ptr [[T0]], ptr [[V]], aqpi = &external_int; @@ -226,7 +226,7 @@ void test_store_data_au() { // CHECK-NEXT: [[T0:%.*]] = icmp ne ptr [[LOAD]], null // CHECK-NEXT: br i1 [[T0]], // CHECK: [[T0:%.*]] = ptrtoint ptr [[LOAD]] to i64 -// CHECK-NEXT: [[T1:%.*]] = call i64 @llvm.ptrauth.sign(i64 [[T0]]) [ "ptrauth"(i64 1, i64 [[T01]], i64 50) ] +// CHECK-NEXT: [[T1:%.*]] = call i64 @llvm.ptrauth.sign(i64 [[T0]]) [ "ptrauth"(i64 1, i64 50, i64 [[T01]]) ] // CHECK-NEXT: [[SIGNED:%.*]] = inttoptr i64 [[T1]] to ptr // CHECK-NEXT: br label // CHECK: [[T0:%.*]] = phi ptr [ null, {{.*}} ], [ [[SIGNED]], {{.*}} ] @@ -237,7 +237,7 @@ void test_store_data_au() { // CHECK-NEXT: [[T0:%.*]] = icmp ne ptr [[LOAD]], null // CHECK-NEXT: br i1 [[T0]], // CHECK: [[T0:%.*]] = ptrtoint ptr [[LOAD]] to i64 -// CHECK-NEXT: [[T1:%.*]] = call i64 @llvm.ptrauth.sign(i64 [[T0]]) [ "ptrauth"(i64 1, i64 [[T01]], i64 50) ] +// CHECK-NEXT: [[T1:%.*]] = call i64 @llvm.ptrauth.sign(i64 [[T0]]) [ "ptrauth"(i64 1, i64 50, i64 [[T01]]) ] // CHECK-NEXT: [[SIGNED:%.*]] = inttoptr i64 [[T1]] to ptr // CHECK-NEXT: br label // CHECK: [[T0:%.*]] = phi ptr [ null, {{.*}} ], [ [[SIGNED]], {{.*}} ] @@ -253,7 +253,7 @@ void test_store_data_ai() { // CHECK-NEXT: [[T0:%.*]] = icmp ne ptr [[LOAD]], null // CHECK-NEXT: br i1 [[T0]], // CHECK: [[T0:%.*]] = ptrtoint ptr [[LOAD]] to i64 -// CHECK-NEXT: [[T1:%.*]] = call i64 @llvm.ptrauth.resign(i64 [[T0]]) [ "ptrauth"(i64 1, i64 50), "ptrauth"(i64 1, i64 [[T01]], i64 50) ] +// CHECK-NEXT: [[T1:%.*]] = call i64 @llvm.ptrauth.resign(i64 [[T0]]) [ "ptrauth"(i64 1, i64 50, i64 0), "ptrauth"(i64 1, i64 50, i64 [[T01]]) ] // CHECK-NEXT: [[SIGNED:%.*]] = inttoptr i64 [[T1]] to ptr // CHECK-NEXT: br label // CHECK: [[T0:%.*]] = phi ptr [ null, {{.*}} ], [ [[SIGNED]], {{.*}} ] @@ -264,7 +264,7 @@ void test_store_data_ai() { // CHECK-NEXT: [[T0:%.*]] = icmp ne ptr [[LOAD]], null // CHECK-NEXT: br i1 [[T0]], // CHECK: [[T0:%.*]] = ptrtoint ptr [[LOAD]] to i64 -// CHECK-NEXT: [[T1:%.*]] = call i64 @llvm.ptrauth.resign(i64 [[T0]]) [ "ptrauth"(i64 1, i64 50), "ptrauth"(i64 1, i64 [[T01]], i64 50) ] +// CHECK-NEXT: [[T1:%.*]] = call i64 @llvm.ptrauth.resign(i64 [[T0]]) [ "ptrauth"(i64 1, i64 50, i64 0), "ptrauth"(i64 1, i64 50, i64 [[T01]]) ] // CHECK-NEXT: [[SIGNED:%.*]] = inttoptr i64 [[T1]] to ptr // CHECK-NEXT: br label // CHECK: [[T0:%.*]] = phi ptr [ null, {{.*}} ], [ [[SIGNED]], {{.*}} ] @@ -280,7 +280,7 @@ void test_store_data_aa_same() { // CHECK-NEXT: [[T0:%.*]] = icmp ne ptr [[LOAD]], null // CHECK-NEXT: br i1 [[T0]], // CHECK: [[T0:%.*]] = ptrtoint ptr [[LOAD]] to i64 -// CHECK-NEXT: [[T1:%.*]] = call i64 @llvm.ptrauth.resign(i64 [[T0]]) [ "ptrauth"(i64 1, i64 ptrtoint (ptr @global_aqpi to i64), i64 50), "ptrauth"(i64 1, i64 [[T01]], i64 50) ] +// CHECK-NEXT: [[T1:%.*]] = call i64 @llvm.ptrauth.resign(i64 [[T0]]) [ "ptrauth"(i64 1, i64 50, i64 ptrtoint (ptr @global_aqpi to i64)), "ptrauth"(i64 1, i64 50, i64 [[T01]]) ] // CHECK-NEXT: [[SIGNED:%.*]] = inttoptr i64 [[T1]] to ptr // CHECK-NEXT: br label // CHECK: [[T0:%.*]] = phi ptr [ null, {{.*}} ], [ [[SIGNED]], {{.*}} ] @@ -291,7 +291,7 @@ void test_store_data_aa_same() { // CHECK-NEXT: [[T0:%.*]] = icmp ne ptr [[LOAD]], null // CHECK-NEXT: br i1 [[T0]], // CHECK: [[T0:%.*]] = ptrtoint ptr [[LOAD]] to i64 -// CHECK-NEXT: [[T1:%.*]] = call i64 @llvm.ptrauth.resign(i64 [[T0]]) [ "ptrauth"(i64 1, i64 ptrtoint (ptr @global_aqpi to i64), i64 50), "ptrauth"(i64 1, i64 [[T01]], i64 50) ] +// CHECK-NEXT: [[T1:%.*]] = call i64 @llvm.ptrauth.resign(i64 [[T0]]) [ "ptrauth"(i64 1, i64 50, i64 ptrtoint (ptr @global_aqpi to i64)), "ptrauth"(i64 1, i64 50, i64 [[T01]]) ] // CHECK-NEXT: [[SIGNED:%.*]] = inttoptr i64 [[T1]] to ptr // CHECK-NEXT: br label // CHECK: [[T0:%.*]] = phi ptr [ null, {{.*}} ], [ [[SIGNED]], {{.*}} ] @@ -307,7 +307,7 @@ void test_store_data_aa_different() { // CHECK-NEXT: [[T0:%.*]] = icmp ne ptr [[LOAD]], null // CHECK-NEXT: br i1 [[T0]], // CHECK: [[T0:%.*]] = ptrtoint ptr [[LOAD]] to i64 -// CHECK-NEXT: [[T1:%.*]] = call i64 @llvm.ptrauth.resign(i64 [[T0]]) [ "ptrauth"(i64 1, i64 ptrtoint (ptr @global_aqpi to i64), i64 50), "ptrauth"(i64 1, i64 [[T01]], i64 100) ] +// CHECK-NEXT: [[T1:%.*]] = call i64 @llvm.ptrauth.resign(i64 [[T0]]) [ "ptrauth"(i64 1, i64 50, i64 ptrtoint (ptr @global_aqpi to i64)), "ptrauth"(i64 1, i64 100, i64 [[T01]]) ] // CHECK-NEXT: [[SIGNED:%.*]] = inttoptr i64 [[T1]] to ptr // CHECK-NEXT: br label // CHECK: [[T0:%.*]] = phi ptr [ null, {{.*}} ], [ [[SIGNED]], {{.*}} ] @@ -318,7 +318,7 @@ void test_store_data_aa_different() { // CHECK-NEXT: [[T0:%.*]] = icmp ne ptr [[LOAD]], null // CHECK-NEXT: br i1 [[T0]], // CHECK: [[T0:%.*]] = ptrtoint ptr [[LOAD]] to i64 -// CHECK-NEXT: [[T1:%.*]] = call i64 @llvm.ptrauth.resign(i64 [[T0]]) [ "ptrauth"(i64 1, i64 ptrtoint (ptr @global_aqpi to i64), i64 50), "ptrauth"(i64 1, i64 [[T01]], i64 100) ] +// CHECK-NEXT: [[T1:%.*]] = call i64 @llvm.ptrauth.resign(i64 [[T0]]) [ "ptrauth"(i64 1, i64 50, i64 ptrtoint (ptr @global_aqpi to i64)), "ptrauth"(i64 1, i64 100, i64 [[T01]]) ] // CHECK-NEXT: [[SIGNED:%.*]] = inttoptr i64 [[T1]] to ptr // CHECK-NEXT: br label // CHECK: [[T0:%.*]] = phi ptr [ null, {{.*}} ], [ [[SIGNED]], {{.*}} ] @@ -334,7 +334,7 @@ void test_store_data_aa_zero() { // CHECK-NEXT: [[T0:%.*]] = icmp ne ptr [[LOAD]], null // CHECK-NEXT: br i1 [[T0]], // CHECK: [[T0:%.*]] = ptrtoint ptr [[LOAD]] to i64 -// CHECK-NEXT: [[T1:%.*]] = call i64 @llvm.ptrauth.resign(i64 [[T0]]) [ "ptrauth"(i64 1, i64 ptrtoint (ptr @global_aqpi to i64), i64 50), "ptrauth"(i64 1, i64 [[NEWDISC]]) ] +// CHECK-NEXT: [[T1:%.*]] = call i64 @llvm.ptrauth.resign(i64 [[T0]]) [ "ptrauth"(i64 1, i64 50, i64 ptrtoint (ptr @global_aqpi to i64)), "ptrauth"(i64 1, i64 0, i64 [[NEWDISC]]) ] // CHECK-NEXT: [[SIGNED:%.*]] = inttoptr i64 [[T1]] to ptr // CHECK-NEXT: br label // CHECK: [[T0:%.*]] = phi ptr [ null, {{.*}} ], [ [[SIGNED]], {{.*}} ] @@ -345,7 +345,7 @@ void test_store_data_aa_zero() { // CHECK-NEXT: [[T0:%.*]] = icmp ne ptr [[LOAD]], null // CHECK-NEXT: br i1 [[T0]], // CHECK: [[T0:%.*]] = ptrtoint ptr [[LOAD]] to i64 -// CHECK-NEXT: [[T1:%.*]] = call i64 @llvm.ptrauth.resign(i64 [[T0]]) [ "ptrauth"(i64 1, i64 [[OLDDISC]]), "ptrauth"(i64 1, i64 ptrtoint (ptr @global_aqpi to i64), i64 50) ] +// CHECK-NEXT: [[T1:%.*]] = call i64 @llvm.ptrauth.resign(i64 [[T0]]) [ "ptrauth"(i64 1, i64 0, i64 [[OLDDISC]]), "ptrauth"(i64 1, i64 50, i64 ptrtoint (ptr @global_aqpi to i64)) ] // CHECK-NEXT: [[SIGNED:%.*]] = inttoptr i64 [[T1]] to ptr // CHECK-NEXT: br label // CHECK: [[T0:%.*]] = phi ptr [ null, {{.*}} ], [ [[SIGNED]], {{.*}} ] @@ -360,7 +360,7 @@ void test_load_data_a() { // CHECK-NEXT: [[T0:%.*]] = icmp ne ptr [[LOAD]], null // CHECK-NEXT: br i1 [[T0]], // CHECK: [[T0:%.*]] = ptrtoint ptr [[LOAD]] to i64 -// CHECK-NEXT: [[T1:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[T0]]) [ "ptrauth"(i64 1, i64 ptrtoint (ptr @global_aqpi to i64), i64 50) ] +// CHECK-NEXT: [[T1:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[T0]]) [ "ptrauth"(i64 1, i64 50, i64 ptrtoint (ptr @global_aqpi to i64)) ] // CHECK-NEXT: [[AUTHED:%.*]] = inttoptr i64 [[T1]] to ptr // CHECK-NEXT: br label // CHECK: [[T0:%.*]] = phi ptr [ null, {{.*}} ], [ [[AUTHED]], {{.*}} ] @@ -370,7 +370,7 @@ void test_load_data_a() { // CHECK-NEXT: [[T0:%.*]] = icmp ne ptr [[LOAD]], null // CHECK-NEXT: br i1 [[T0]], // CHECK: [[T0:%.*]] = ptrtoint ptr [[LOAD]] to i64 -// CHECK-NEXT: [[T1:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[T0]]) [ "ptrauth"(i64 1, i64 ptrtoint (ptr @global_aqpi to i64), i64 50) ] +// CHECK-NEXT: [[T1:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[T0]]) [ "ptrauth"(i64 1, i64 50, i64 ptrtoint (ptr @global_aqpi to i64)) ] // CHECK-NEXT: [[AUTHED:%.*]] = inttoptr i64 [[T1]] to ptr // CHECK-NEXT: br label // CHECK: [[T0:%.*]] = phi ptr [ null, {{.*}} ], [ [[AUTHED]], {{.*}} ] @@ -380,7 +380,7 @@ void test_load_data_a() { // CHECK-NEXT: [[T0:%.*]] = icmp ne ptr [[LOAD]], null // CHECK-NEXT: br i1 [[T0]], // CHECK: [[T0:%.*]] = ptrtoint ptr [[LOAD]] to i64 -// CHECK-NEXT: [[T1:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[T0]]) [ "ptrauth"(i64 1, i64 ptrtoint (ptr @global_aqpi to i64), i64 50) ] +// CHECK-NEXT: [[T1:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[T0]]) [ "ptrauth"(i64 1, i64 50, i64 ptrtoint (ptr @global_aqpi to i64)) ] // CHECK-NEXT: [[AUTHED:%.*]] = inttoptr i64 [[T1]] to ptr // CHECK-NEXT: br label // CHECK: [[T0:%.*]] = phi ptr [ null, {{.*}} ], [ [[AUTHED]], {{.*}} ] @@ -393,11 +393,11 @@ void test_load_data_a() { // CHECK-LABEL: define {{.*}}void @test_store_function_i_constant() void test_store_function_i_constant() { // CHECK: [[V:%.*]] = alloca ptr, -// CHECK-NEXT: [[SIGN:%.*]] = call i64 @llvm.ptrauth.resign(i64 ptrtoint (ptr ptrauth (ptr @external_func, i32 0, i64 18983) to i64)) [ "ptrauth"(i64 0, i64 18983), "ptrauth"(i64 1, i64 50) ] +// CHECK-NEXT: [[SIGN:%.*]] = call i64 @llvm.ptrauth.resign(i64 ptrtoint (ptr ptrauth (ptr @external_func, i32 0, i64 18983) to i64)) [ "ptrauth"(i64 0, i64 18983, i64 0), "ptrauth"(i64 1, i64 50, i64 0) ] // CHECK-NEXT: [[T0:%.*]] = inttoptr i64 [[SIGN]] to ptr // CHECK-NEXT: store ptr [[T0]], ptr [[V]], func_t * IQ iqpf = &external_func; -// CHECK-NEXT: [[SIGN:%.*]] = call i64 @llvm.ptrauth.resign(i64 ptrtoint (ptr ptrauth (ptr @external_func, i32 0, i64 18983) to i64)) [ "ptrauth"(i64 0, i64 18983), "ptrauth"(i64 1, i64 50) ] +// CHECK-NEXT: [[SIGN:%.*]] = call i64 @llvm.ptrauth.resign(i64 ptrtoint (ptr ptrauth (ptr @external_func, i32 0, i64 18983) to i64)) [ "ptrauth"(i64 0, i64 18983, i64 0), "ptrauth"(i64 1, i64 50, i64 0) ] // CHECK-NEXT: [[T0:%.*]] = inttoptr i64 [[SIGN]] to ptr // CHECK-NEXT: store ptr [[T0]], ptr [[V]], iqpf = &external_func; @@ -410,7 +410,7 @@ void test_store_function_iu() { // CHECK-NEXT: [[T0:%.*]] = icmp ne ptr [[LOAD]], null // CHECK-NEXT: br i1 [[T0]], // CHECK: [[T0:%.*]] = ptrtoint ptr [[LOAD]] to i64 -// CHECK-NEXT: [[T1:%.*]] = call i64 @llvm.ptrauth.resign(i64 [[T0]]) [ "ptrauth"(i64 0, i64 18983), "ptrauth"(i64 1, i64 50) ] +// CHECK-NEXT: [[T1:%.*]] = call i64 @llvm.ptrauth.resign(i64 [[T0]]) [ "ptrauth"(i64 0, i64 18983, i64 0), "ptrauth"(i64 1, i64 50, i64 0) ] // CHECK-NEXT: [[SIGNED:%.*]] = inttoptr i64 [[T1]] to ptr // CHECK-NEXT: br label // CHECK: [[T0:%.*]] = phi ptr [ null, {{.*}} ], [ [[SIGNED]], {{.*}} ] @@ -420,7 +420,7 @@ void test_store_function_iu() { // CHECK-NEXT: [[T0:%.*]] = icmp ne ptr [[LOAD]], null // CHECK-NEXT: br i1 [[T0]], // CHECK: [[T0:%.*]] = ptrtoint ptr [[LOAD]] to i64 -// CHECK-NEXT: [[T1:%.*]] = call i64 @llvm.ptrauth.resign(i64 [[T0]]) [ "ptrauth"(i64 0, i64 18983), "ptrauth"(i64 1, i64 50) ] +// CHECK-NEXT: [[T1:%.*]] = call i64 @llvm.ptrauth.resign(i64 [[T0]]) [ "ptrauth"(i64 0, i64 18983, i64 0), "ptrauth"(i64 1, i64 50, i64 0) ] // CHECK-NEXT: [[SIGNED:%.*]] = inttoptr i64 [[T1]] to ptr // CHECK-NEXT: br label // CHECK: [[T0:%.*]] = phi ptr [ null, {{.*}} ], [ [[SIGNED]], {{.*}} ] @@ -435,7 +435,7 @@ void test_store_function_ia() { // CHECK-NEXT: [[T0:%.*]] = icmp ne ptr [[LOAD]], null // CHECK-NEXT: br i1 [[T0]], // CHECK: [[T0:%.*]] = ptrtoint ptr [[LOAD]] to i64 -// CHECK-NEXT: [[T1:%.*]] = call i64 @llvm.ptrauth.resign(i64 [[T0]]) [ "ptrauth"(i64 1, i64 ptrtoint (ptr @global_aqpf to i64), i64 50), "ptrauth"(i64 1, i64 50) ] +// CHECK-NEXT: [[T1:%.*]] = call i64 @llvm.ptrauth.resign(i64 [[T0]]) [ "ptrauth"(i64 1, i64 50, i64 ptrtoint (ptr @global_aqpf to i64)), "ptrauth"(i64 1, i64 50, i64 0) ] // CHECK-NEXT: [[SIGNED:%.*]] = inttoptr i64 [[T1]] to ptr // CHECK-NEXT: br label // CHECK: [[T0:%.*]] = phi ptr [ null, {{.*}} ], [ [[SIGNED]], {{.*}} ] @@ -445,7 +445,7 @@ void test_store_function_ia() { // CHECK-NEXT: [[T0:%.*]] = icmp ne ptr [[LOAD]], null // CHECK-NEXT: br i1 [[T0]], // CHECK: [[T0:%.*]] = ptrtoint ptr [[LOAD]] to i64 -// CHECK-NEXT: [[T1:%.*]] = call i64 @llvm.ptrauth.resign(i64 [[T0]]) [ "ptrauth"(i64 1, i64 ptrtoint (ptr @global_aqpf to i64), i64 50), "ptrauth"(i64 1, i64 50) ] +// CHECK-NEXT: [[T1:%.*]] = call i64 @llvm.ptrauth.resign(i64 [[T0]]) [ "ptrauth"(i64 1, i64 50, i64 ptrtoint (ptr @global_aqpf to i64)), "ptrauth"(i64 1, i64 50, i64 0) ] // CHECK-NEXT: [[SIGNED:%.*]] = inttoptr i64 [[T1]] to ptr // CHECK-NEXT: br label // CHECK: [[T0:%.*]] = phi ptr [ null, {{.*}} ], [ [[SIGNED]], {{.*}} ] @@ -455,7 +455,7 @@ void test_store_function_ia() { // CHECK-NEXT: [[T0:%.*]] = icmp ne ptr [[LOAD]], null // CHECK-NEXT: br i1 [[T0]], // CHECK: [[T0:%.*]] = ptrtoint ptr [[LOAD]] to i64 -// CHECK-NEXT: [[T1:%.*]] = call i64 @llvm.ptrauth.resign(i64 [[T0]]) [ "ptrauth"(i64 1, i64 ptrtoint (ptr @global_aqpf to i64), i64 50), "ptrauth"(i64 1, i64 50) ] +// CHECK-NEXT: [[T1:%.*]] = call i64 @llvm.ptrauth.resign(i64 [[T0]]) [ "ptrauth"(i64 1, i64 50, i64 ptrtoint (ptr @global_aqpf to i64)), "ptrauth"(i64 1, i64 50, i64 0) ] // CHECK-NEXT: [[SIGNED:%.*]] = inttoptr i64 [[T1]] to ptr // CHECK-NEXT: br label // CHECK: [[RESULT:%.*]] = phi ptr [ null, {{.*}} ], [ [[SIGNED]], {{.*}} ] @@ -463,7 +463,7 @@ void test_store_function_ia() { // CHECK-NEXT: [[T0:%.*]] = icmp ne ptr [[RESULT]], null // CHECK-NEXT: br i1 [[T0]], // CHECK: [[T0:%.*]] = ptrtoint ptr [[RESULT]] to i64 -// CHECK-NEXT: [[T1:%.*]] = call i64 @llvm.ptrauth.resign(i64 [[T0]]) [ "ptrauth"(i64 1, i64 50), "ptrauth"(i64 0, i64 18983) ] +// CHECK-NEXT: [[T1:%.*]] = call i64 @llvm.ptrauth.resign(i64 [[T0]]) [ "ptrauth"(i64 1, i64 50, i64 0), "ptrauth"(i64 0, i64 18983, i64 0) ] // CHECK-NEXT: [[SIGNED:%.*]] = inttoptr i64 [[T1]] to ptr // CHECK-NEXT: br label // CHECK: [[T0:%.*]] = phi ptr [ null, {{.*}} ], [ [[SIGNED]], {{.*}} ] @@ -489,7 +489,7 @@ void test_store_function_ii_different() { // CHECK-NEXT: [[T0:%.*]] = icmp ne ptr [[LOAD]], null // CHECK-NEXT: br i1 [[T0]], // CHECK: [[T0:%.*]] = ptrtoint ptr [[LOAD]] to i64 -// CHECK-NEXT: [[T1:%.*]] = call i64 @llvm.ptrauth.resign(i64 [[T0]]) [ "ptrauth"(i64 1, i64 50), "ptrauth"(i64 1, i64 100) ] +// CHECK-NEXT: [[T1:%.*]] = call i64 @llvm.ptrauth.resign(i64 [[T0]]) [ "ptrauth"(i64 1, i64 50, i64 0), "ptrauth"(i64 1, i64 100, i64 0) ] // CHECK-NEXT: [[SIGNED:%.*]] = inttoptr i64 [[T1]] to ptr // CHECK-NEXT: br label // CHECK: [[T0:%.*]] = phi ptr [ null, {{.*}} ], [ [[SIGNED]], {{.*}} ] @@ -499,7 +499,7 @@ void test_store_function_ii_different() { // CHECK-NEXT: [[T0:%.*]] = icmp ne ptr [[LOAD]], null // CHECK-NEXT: br i1 [[T0]], // CHECK: [[T0:%.*]] = ptrtoint ptr [[LOAD]] to i64 -// CHECK-NEXT: [[T1:%.*]] = call i64 @llvm.ptrauth.resign(i64 [[T0]]) [ "ptrauth"(i64 1, i64 50), "ptrauth"(i64 1, i64 100) ] +// CHECK-NEXT: [[T1:%.*]] = call i64 @llvm.ptrauth.resign(i64 [[T0]]) [ "ptrauth"(i64 1, i64 50, i64 0), "ptrauth"(i64 1, i64 100, i64 0) ] // CHECK-NEXT: [[SIGNED:%.*]] = inttoptr i64 [[T1]] to ptr // CHECK-NEXT: br label // CHECK: [[T0:%.*]] = phi ptr [ null, {{.*}} ], [ [[SIGNED]], {{.*}} ] @@ -514,7 +514,7 @@ void test_load_function_i() { // CHECK-NEXT: [[T0:%.*]] = icmp ne ptr [[LOAD]], null // CHECK-NEXT: br i1 [[T0]], // CHECK: [[T0:%.*]] = ptrtoint ptr [[LOAD]] to i64 -// CHECK-NEXT: [[T1:%.*]] = call i64 @llvm.ptrauth.resign(i64 [[T0]]) [ "ptrauth"(i64 1, i64 50), "ptrauth"(i64 0, i64 18983) ] +// CHECK-NEXT: [[T1:%.*]] = call i64 @llvm.ptrauth.resign(i64 [[T0]]) [ "ptrauth"(i64 1, i64 50, i64 0), "ptrauth"(i64 0, i64 18983, i64 0) ] // CHECK-NEXT: [[SIGNED:%.*]] = inttoptr i64 [[T1]] to ptr // CHECK-NEXT: br label // CHECK: [[T0:%.*]] = phi ptr [ null, {{.*}} ], [ [[SIGNED]], {{.*}} ] @@ -524,7 +524,7 @@ void test_load_function_i() { // CHECK-NEXT: [[T0:%.*]] = icmp ne ptr [[LOAD]], null // CHECK-NEXT: br i1 [[T0]], // CHECK: [[T0:%.*]] = ptrtoint ptr [[LOAD]] to i64 -// CHECK-NEXT: [[T1:%.*]] = call i64 @llvm.ptrauth.resign(i64 [[T0]]) [ "ptrauth"(i64 1, i64 50), "ptrauth"(i64 0, i64 18983) ] +// CHECK-NEXT: [[T1:%.*]] = call i64 @llvm.ptrauth.resign(i64 [[T0]]) [ "ptrauth"(i64 1, i64 50, i64 0), "ptrauth"(i64 0, i64 18983, i64 0) ] // CHECK-NEXT: [[SIGNED:%.*]] = inttoptr i64 [[T1]] to ptr // CHECK-NEXT: br label // CHECK: [[T0:%.*]] = phi ptr [ null, {{.*}} ], [ [[SIGNED]], {{.*}} ] @@ -534,7 +534,7 @@ void test_load_function_i() { // CHECK-NEXT: [[T0:%.*]] = icmp ne ptr [[LOAD]], null // CHECK-NEXT: br i1 [[T0]], // CHECK: [[T0:%.*]] = ptrtoint ptr [[LOAD]] to i64 -// CHECK-NEXT: [[T1:%.*]] = call i64 @llvm.ptrauth.resign(i64 [[T0]]) [ "ptrauth"(i64 1, i64 50), "ptrauth"(i64 0, i64 18983) ] +// CHECK-NEXT: [[T1:%.*]] = call i64 @llvm.ptrauth.resign(i64 [[T0]]) [ "ptrauth"(i64 1, i64 50, i64 0), "ptrauth"(i64 0, i64 18983, i64 0) ] // CHECK-NEXT: [[SIGNED:%.*]] = inttoptr i64 [[T1]] to ptr // CHECK-NEXT: br label // CHECK: [[T0:%.*]] = phi ptr [ null, {{.*}} ], [ [[SIGNED]], {{.*}} ] @@ -548,12 +548,12 @@ void test_load_function_i() { void test_store_function_a_constant() { // CHECK: [[V:%.*]] = alloca ptr, // CHECK-NEXT: [[T0:%.*]] = ptrtoint ptr [[V]] to i64 -// CHECK-NEXT: [[SIGN:%.*]] = call i64 @llvm.ptrauth.resign(i64 ptrtoint (ptr ptrauth (ptr @external_func, i32 0, i64 18983) to i64)) [ "ptrauth"(i64 0, i64 18983), "ptrauth"(i64 1, i64 [[T0]], i64 50) ] +// CHECK-NEXT: [[SIGN:%.*]] = call i64 @llvm.ptrauth.resign(i64 ptrtoint (ptr ptrauth (ptr @external_func, i32 0, i64 18983) to i64)) [ "ptrauth"(i64 0, i64 18983, i64 0), "ptrauth"(i64 1, i64 50, i64 [[T0]]) ] // CHECK-NEXT: [[T0:%.*]] = inttoptr i64 [[SIGN]] to ptr // CHECK-NEXT: store ptr [[T0]], ptr [[V]], func_t * AQ aqpf = &external_func; // CHECK-NEXT: [[T0:%.*]] = ptrtoint ptr [[V]] to i64 -// CHECK-NEXT: [[SIGN:%.*]] = call i64 @llvm.ptrauth.resign(i64 ptrtoint (ptr ptrauth (ptr @external_func, i32 0, i64 18983) to i64)) [ "ptrauth"(i64 0, i64 18983), "ptrauth"(i64 1, i64 [[T0]], i64 50) ] +// CHECK-NEXT: [[SIGN:%.*]] = call i64 @llvm.ptrauth.resign(i64 ptrtoint (ptr ptrauth (ptr @external_func, i32 0, i64 18983) to i64)) [ "ptrauth"(i64 0, i64 18983, i64 0), "ptrauth"(i64 1, i64 50, i64 [[T0]]) ] // CHECK-NEXT: [[T0:%.*]] = inttoptr i64 [[SIGN]] to ptr // CHECK-NEXT: store ptr [[T0]], ptr [[V]], aqpf = &external_func; @@ -567,7 +567,7 @@ void test_store_function_au() { // CHECK-NEXT: [[T0:%.*]] = icmp ne ptr [[LOAD]], null // CHECK-NEXT: br i1 [[T0]], // CHECK: [[T0:%.*]] = ptrtoint ptr [[LOAD]] to i64 -// CHECK-NEXT: [[T1:%.*]] = call i64 @llvm.ptrauth.resign(i64 [[T0]]) [ "ptrauth"(i64 0, i64 18983), "ptrauth"(i64 1, i64 [[T01]], i64 50) ] +// CHECK-NEXT: [[T1:%.*]] = call i64 @llvm.ptrauth.resign(i64 [[T0]]) [ "ptrauth"(i64 0, i64 18983, i64 0), "ptrauth"(i64 1, i64 50, i64 [[T01]]) ] // CHECK-NEXT: [[SIGNED:%.*]] = inttoptr i64 [[T1]] to ptr // CHECK-NEXT: br label // CHECK: [[T0:%.*]] = phi ptr [ null, {{.*}} ], [ [[SIGNED]], {{.*}} ] @@ -578,7 +578,7 @@ void test_store_function_au() { // CHECK-NEXT: [[T0:%.*]] = icmp ne ptr [[LOAD]], null // CHECK-NEXT: br i1 [[T0]], // CHECK: [[T0:%.*]] = ptrtoint ptr [[LOAD]] to i64 -// CHECK-NEXT: [[T1:%.*]] = call i64 @llvm.ptrauth.resign(i64 [[T0]]) [ "ptrauth"(i64 0, i64 18983), "ptrauth"(i64 1, i64 [[T01]], i64 50) ] +// CHECK-NEXT: [[T1:%.*]] = call i64 @llvm.ptrauth.resign(i64 [[T0]]) [ "ptrauth"(i64 0, i64 18983, i64 0), "ptrauth"(i64 1, i64 50, i64 [[T01]]) ] // CHECK-NEXT: [[SIGNED:%.*]] = inttoptr i64 [[T1]] to ptr // CHECK-NEXT: br label // CHECK: [[T0:%.*]] = phi ptr [ null, {{.*}} ], [ [[SIGNED]], {{.*}} ] @@ -594,7 +594,7 @@ void test_store_function_ai() { // CHECK-NEXT: [[T0:%.*]] = icmp ne ptr [[LOAD]], null // CHECK-NEXT: br i1 [[T0]], // CHECK: [[T0:%.*]] = ptrtoint ptr [[LOAD]] to i64 -// CHECK-NEXT: [[T1:%.*]] = call i64 @llvm.ptrauth.resign(i64 [[T0]]) [ "ptrauth"(i64 1, i64 50), "ptrauth"(i64 1, i64 [[T01]], i64 50) ] +// CHECK-NEXT: [[T1:%.*]] = call i64 @llvm.ptrauth.resign(i64 [[T0]]) [ "ptrauth"(i64 1, i64 50, i64 0), "ptrauth"(i64 1, i64 50, i64 [[T01]]) ] // CHECK-NEXT: [[SIGNED:%.*]] = inttoptr i64 [[T1]] to ptr // CHECK-NEXT: br label // CHECK: [[T0:%.*]] = phi ptr [ null, {{.*}} ], [ [[SIGNED]], {{.*}} ] @@ -605,7 +605,7 @@ void test_store_function_ai() { // CHECK-NEXT: [[T0:%.*]] = icmp ne ptr [[LOAD]], null // CHECK-NEXT: br i1 [[T0]], // CHECK: [[T0:%.*]] = ptrtoint ptr [[LOAD]] to i64 -// CHECK-NEXT: [[T1:%.*]] = call i64 @llvm.ptrauth.resign(i64 [[T0]]) [ "ptrauth"(i64 1, i64 50), "ptrauth"(i64 1, i64 [[T01]], i64 50) ] +// CHECK-NEXT: [[T1:%.*]] = call i64 @llvm.ptrauth.resign(i64 [[T0]]) [ "ptrauth"(i64 1, i64 50, i64 0), "ptrauth"(i64 1, i64 50, i64 [[T01]]) ] // CHECK-NEXT: [[SIGNED:%.*]] = inttoptr i64 [[T1]] to ptr // CHECK-NEXT: br label // CHECK: [[T0:%.*]] = phi ptr [ null, {{.*}} ], [ [[SIGNED]], {{.*}} ] @@ -621,7 +621,7 @@ void test_store_function_aa_same() { // CHECK-NEXT: [[T0:%.*]] = icmp ne ptr [[LOAD]], null // CHECK-NEXT: br i1 [[T0]], // CHECK: [[T0:%.*]] = ptrtoint ptr [[LOAD]] to i64 -// CHECK-NEXT: [[T1:%.*]] = call i64 @llvm.ptrauth.resign(i64 [[T0]]) [ "ptrauth"(i64 1, i64 ptrtoint (ptr @global_aqpf to i64), i64 50), "ptrauth"(i64 1, i64 [[T01]], i64 50) ] +// CHECK-NEXT: [[T1:%.*]] = call i64 @llvm.ptrauth.resign(i64 [[T0]]) [ "ptrauth"(i64 1, i64 50, i64 ptrtoint (ptr @global_aqpf to i64)), "ptrauth"(i64 1, i64 50, i64 [[T01]]) ] // CHECK-NEXT: [[SIGNED:%.*]] = inttoptr i64 [[T1]] to ptr // CHECK-NEXT: br label // CHECK: [[T0:%.*]] = phi ptr [ null, {{.*}} ], [ [[SIGNED]], {{.*}} ] @@ -632,7 +632,7 @@ void test_store_function_aa_same() { // CHECK-NEXT: [[T0:%.*]] = icmp ne ptr [[LOAD]], null // CHECK-NEXT: br i1 [[T0]], // CHECK: [[T0:%.*]] = ptrtoint ptr [[LOAD]] to i64 -// CHECK-NEXT: [[T1:%.*]] = call i64 @llvm.ptrauth.resign(i64 [[T0]]) [ "ptrauth"(i64 1, i64 ptrtoint (ptr @global_aqpf to i64), i64 50), "ptrauth"(i64 1, i64 [[T01]], i64 50) ] +// CHECK-NEXT: [[T1:%.*]] = call i64 @llvm.ptrauth.resign(i64 [[T0]]) [ "ptrauth"(i64 1, i64 50, i64 ptrtoint (ptr @global_aqpf to i64)), "ptrauth"(i64 1, i64 50, i64 [[T01]]) ] // CHECK-NEXT: [[SIGNED:%.*]] = inttoptr i64 [[T1]] to ptr // CHECK-NEXT: br label // CHECK: [[T0:%.*]] = phi ptr [ null, {{.*}} ], [ [[SIGNED]], {{.*}} ] @@ -648,7 +648,7 @@ void test_store_function_aa_different() { // CHECK-NEXT: [[T0:%.*]] = icmp ne ptr [[LOAD]], null // CHECK-NEXT: br i1 [[T0]], // CHECK: [[T0:%.*]] = ptrtoint ptr [[LOAD]] to i64 -// CHECK-NEXT: [[T1:%.*]] = call i64 @llvm.ptrauth.resign(i64 [[T0]]) [ "ptrauth"(i64 1, i64 ptrtoint (ptr @global_aqpf to i64), i64 50), "ptrauth"(i64 1, i64 [[T01]], i64 100) ] +// CHECK-NEXT: [[T1:%.*]] = call i64 @llvm.ptrauth.resign(i64 [[T0]]) [ "ptrauth"(i64 1, i64 50, i64 ptrtoint (ptr @global_aqpf to i64)), "ptrauth"(i64 1, i64 100, i64 [[T01]]) ] // CHECK-NEXT: [[SIGNED:%.*]] = inttoptr i64 [[T1]] to ptr // CHECK-NEXT: br label // CHECK: [[T0:%.*]] = phi ptr [ null, {{.*}} ], [ [[SIGNED]], {{.*}} ] @@ -659,7 +659,7 @@ void test_store_function_aa_different() { // CHECK-NEXT: [[T0:%.*]] = icmp ne ptr [[LOAD]], null // CHECK-NEXT: br i1 [[T0]], // CHECK: [[T0:%.*]] = ptrtoint ptr [[LOAD]] to i64 -// CHECK-NEXT: [[T1:%.*]] = call i64 @llvm.ptrauth.resign(i64 [[T0]]) [ "ptrauth"(i64 1, i64 ptrtoint (ptr @global_aqpf to i64), i64 50), "ptrauth"(i64 1, i64 [[T01]], i64 100) ] +// CHECK-NEXT: [[T1:%.*]] = call i64 @llvm.ptrauth.resign(i64 [[T0]]) [ "ptrauth"(i64 1, i64 50, i64 ptrtoint (ptr @global_aqpf to i64)), "ptrauth"(i64 1, i64 100, i64 [[T01]]) ] // CHECK-NEXT: [[SIGNED:%.*]] = inttoptr i64 [[T1]] to ptr // CHECK-NEXT: br label // CHECK: [[T0:%.*]] = phi ptr [ null, {{.*}} ], [ [[SIGNED]], {{.*}} ] @@ -674,7 +674,7 @@ void test_load_function_a() { // CHECK-NEXT: [[T0:%.*]] = icmp ne ptr [[LOAD]], null // CHECK-NEXT: br i1 [[T0]], // CHECK: [[T0:%.*]] = ptrtoint ptr [[LOAD]] to i64 -// CHECK-NEXT: [[T1:%.*]] = call i64 @llvm.ptrauth.resign(i64 [[T0]]) [ "ptrauth"(i64 1, i64 ptrtoint (ptr @global_aqpf to i64), i64 50), "ptrauth"(i64 0, i64 18983) ] +// CHECK-NEXT: [[T1:%.*]] = call i64 @llvm.ptrauth.resign(i64 [[T0]]) [ "ptrauth"(i64 1, i64 50, i64 ptrtoint (ptr @global_aqpf to i64)), "ptrauth"(i64 0, i64 18983, i64 0) ] // CHECK-NEXT: [[SIGNED:%.*]] = inttoptr i64 [[T1]] to ptr // CHECK-NEXT: br label // CHECK: [[T0:%.*]] = phi ptr [ null, {{.*}} ], [ [[SIGNED]], {{.*}} ] @@ -684,7 +684,7 @@ void test_load_function_a() { // CHECK-NEXT: [[T0:%.*]] = icmp ne ptr [[LOAD]], null // CHECK-NEXT: br i1 [[T0]], // CHECK: [[T0:%.*]] = ptrtoint ptr [[LOAD]] to i64 -// CHECK-NEXT: [[T1:%.*]] = call i64 @llvm.ptrauth.resign(i64 [[T0]]) [ "ptrauth"(i64 1, i64 ptrtoint (ptr @global_aqpf to i64), i64 50), "ptrauth"(i64 0, i64 18983) ] +// CHECK-NEXT: [[T1:%.*]] = call i64 @llvm.ptrauth.resign(i64 [[T0]]) [ "ptrauth"(i64 1, i64 50, i64 ptrtoint (ptr @global_aqpf to i64)), "ptrauth"(i64 0, i64 18983, i64 0) ] // CHECK-NEXT: [[SIGNED:%.*]] = inttoptr i64 [[T1]] to ptr // CHECK-NEXT: br label // CHECK: [[T0:%.*]] = phi ptr [ null, {{.*}} ], [ [[SIGNED]], {{.*}} ] @@ -694,7 +694,7 @@ void test_load_function_a() { // CHECK-NEXT: [[T0:%.*]] = icmp ne ptr [[LOAD]], null // CHECK-NEXT: br i1 [[T0]], // CHECK: [[T0:%.*]] = ptrtoint ptr [[LOAD]] to i64 -// CHECK-NEXT: [[T1:%.*]] = call i64 @llvm.ptrauth.resign(i64 [[T0]]) [ "ptrauth"(i64 1, i64 ptrtoint (ptr @global_aqpf to i64), i64 50), "ptrauth"(i64 0, i64 18983) ] +// CHECK-NEXT: [[T1:%.*]] = call i64 @llvm.ptrauth.resign(i64 [[T0]]) [ "ptrauth"(i64 1, i64 50, i64 ptrtoint (ptr @global_aqpf to i64)), "ptrauth"(i64 0, i64 18983, i64 0) ] // CHECK-NEXT: [[SIGNED:%.*]] = inttoptr i64 [[T1]] to ptr // CHECK-NEXT: br label // CHECK: [[T0:%.*]] = phi ptr [ null, {{.*}} ], [ [[SIGNED]], {{.*}} ] diff --git a/clang/test/CodeGen/ptrauth-restricted-intptr-qualifier.c b/clang/test/CodeGen/ptrauth-restricted-intptr-qualifier.c index ed42a9ac4eafc..762398f74af8d 100644 --- a/clang/test/CodeGen/ptrauth-restricted-intptr-qualifier.c +++ b/clang/test/CodeGen/ptrauth-restricted-intptr-qualifier.c @@ -37,11 +37,11 @@ struct B gs2 = {0, 0, (__UINTPTR_TYPE__)&test_int}; __INTPTR_TYPE__ test_read_globals() { __INTPTR_TYPE__ result = g1 + g2 + g3; // CHECK: [[A:%.*]] = load i64, ptr @g1 - // CHECK: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[A]]) [ "ptrauth"(i64 1, i64 56) ] + // CHECK: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[A]]) [ "ptrauth"(i64 1, i64 56, i64 0) ] // CHECK: [[B:%.*]] = load i64, ptr @g2 - // CHECK: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[B]]) [ "ptrauth"(i64 1, i64 ptrtoint (ptr @g2 to i64), i64 1272) ] + // CHECK: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[B]]) [ "ptrauth"(i64 1, i64 1272, i64 ptrtoint (ptr @g2 to i64)) ] // CHECK: [[VALUE:%.*]] = load i64, ptr @g3 - // CHECK: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VALUE]]) [ "ptrauth"(i64 3, i64 ptrtoint (ptr @g3 to i64), i64 23) ] + // CHECK: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VALUE]]) [ "ptrauth"(i64 3, i64 23, i64 ptrtoint (ptr @g3 to i64)) ] for (int i = 0; i < 3; i++) { result += ga[i]; @@ -56,24 +56,24 @@ __INTPTR_TYPE__ test_read_globals() { // CHECK: [[VALUE:%.*]] = load i64, ptr [[ARRAYIDX]] // CHECK: [[CASTIDX:%.*]] = ptrtoint ptr [[ARRAYIDX]] to i64 // CHECK: resign.nonnull6: - // CHECK: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VALUE]]) [ "ptrauth"(i64 1, i64 [[CASTIDX]], i64 712) ] + // CHECK: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VALUE]]) [ "ptrauth"(i64 1, i64 712, i64 [[CASTIDX]]) ] // CHECK: resign.cont7 result += gs1.f0 + gs1.f1 + gs1.f2; // CHECK: resign.cont10: // CHECK: [[ADDR:%.*]] = load i64, ptr getelementptr inbounds nuw (%struct.A, ptr @gs1, i32 0, i32 1 // CHECK: resign.nonnull11: - // CHECK: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[ADDR]]) [ "ptrauth"(i64 1, i64 9182) ] + // CHECK: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[ADDR]]) [ "ptrauth"(i64 1, i64 9182, i64 0) ] // CHECK: resign.cont12: // CHECK: [[ADDR:%.*]] = load i64, ptr getelementptr inbounds nuw (%struct.A, ptr @gs1, i32 0, i32 2) - // CHECK: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[ADDR]]) [ "ptrauth"(i64 1, i64 783) ] + // CHECK: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[ADDR]]) [ "ptrauth"(i64 1, i64 783, i64 0) ] result += gs2.f0 + gs2.f1 + gs2.f2; // CHECK: [[ADDR:%.*]] = load i64, ptr @gs2 - // CHECK: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[ADDR]]) [ "ptrauth"(i64 1, i64 ptrtoint (ptr @gs2 to i64), i64 1276) ] + // CHECK: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[ADDR]]) [ "ptrauth"(i64 1, i64 1276, i64 ptrtoint (ptr @gs2 to i64)) ] // CHECK: [[ADDR:%.*]] = load i64, ptr getelementptr inbounds nuw (%struct.B, ptr @gs2, i32 0, i32 1) - // CHECK: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[ADDR]]) [ "ptrauth"(i64 1, i64 ptrtoint (ptr getelementptr inbounds nuw (%struct.B, ptr @gs2, i32 0, i32 1) to i64), i64 23674) ] + // CHECK: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[ADDR]]) [ "ptrauth"(i64 1, i64 23674, i64 ptrtoint (ptr getelementptr inbounds nuw (%struct.B, ptr @gs2, i32 0, i32 1) to i64)) ] // CHECK: [[ADDR:%.*]] = load i64, ptr getelementptr inbounds nuw (%struct.B, ptr @gs2, i32 0, i32 2) - // CHECK: "ptrauth"(i64 1, i64 ptrtoint (ptr getelementptr inbounds nuw (%struct.B, ptr @gs2, i32 0, i32 2) to i64), i64 163) + // CHECK: "ptrauth"(i64 1, i64 163, i64 ptrtoint (ptr getelementptr inbounds nuw (%struct.B, ptr @gs2, i32 0, i32 2) to i64)) return result; } @@ -98,11 +98,11 @@ void test_write_globals(int i, __INTPTR_TYPE__ j) { void test_set_A(struct A *a, __INTPTR_TYPE__ x, int y) { a->f0 = x; // CHECK: [[XADDR:%.*]] = load i64, ptr %x.addr - // CHECK: [[SIGNED_X:%.*]] = call i64 @llvm.ptrauth.sign(i64 [[XADDR]]) [ "ptrauth"(i64 1, i64 431) ] + // CHECK: [[SIGNED_X:%.*]] = call i64 @llvm.ptrauth.sign(i64 [[XADDR]]) [ "ptrauth"(i64 1, i64 431, i64 0) ] a->f1 = y; // CHECK: [[Y:%.*]] = load i32, ptr %y.addr // CHECK: [[CONV:%.*]] = sext i32 [[Y]] to i64 - // CHECK: [[SIGNED:%.*]] = call i64 @llvm.ptrauth.sign(i64 [[CONV]]) [ "ptrauth"(i64 1, i64 9182) ] + // CHECK: [[SIGNED:%.*]] = call i64 @llvm.ptrauth.sign(i64 [[CONV]]) [ "ptrauth"(i64 1, i64 9182, i64 0) ] a->f2 = 0; // CHECK: [[A:%.*]] = load ptr, ptr %a.addr // CHECK: [[F2:%.*]] = getelementptr inbounds nuw %struct.A, ptr [[A]], i32 0, i32 2 @@ -114,14 +114,14 @@ void test_set_B(struct B *b, __INTPTR_TYPE__ x, int y) { b->f0 = x; // CHECK: [[X:%.*]] = load i64, ptr %x.addr // CHECK: [[F0_ADDR:%.*]] = ptrtoint ptr %f0 to i64 - // CHECK: [[SIGNED:%.*]] = call i64 @llvm.ptrauth.sign(i64 [[X]]) [ "ptrauth"(i64 1, i64 [[F0_ADDR]], i64 1276) ] + // CHECK: [[SIGNED:%.*]] = call i64 @llvm.ptrauth.sign(i64 [[X]]) [ "ptrauth"(i64 1, i64 1276, i64 [[F0_ADDR]]) ] b->f1 = y; // CHECK: [[B:%.*]] = load ptr, ptr %b.addr // CHECK: [[F1_ADDR:%.*]] = getelementptr inbounds nuw %struct.B, ptr [[B]], i32 0, i32 1 // CHECK: [[Y:%.*]] = load i32, ptr %y.addr, align 4 // CHECK: [[CONV:%.*]] = sext i32 [[Y]] to i64 // CHECK: [[CAST_ADDR:%.*]] = ptrtoint ptr [[F1_ADDR]] to i64 - // CHECK: [[SIGNED:%.*]] = call i64 @llvm.ptrauth.sign(i64 [[CONV]]) [ "ptrauth"(i64 1, i64 [[CAST_ADDR]], i64 23674) ] + // CHECK: [[SIGNED:%.*]] = call i64 @llvm.ptrauth.sign(i64 [[CONV]]) [ "ptrauth"(i64 1, i64 23674, i64 [[CAST_ADDR]]) ] b->f2 = 0; // CHECK: [[B:%.*]] = load ptr, ptr %b.addr // CHECK: [[F2_ADDR:%.*]] = getelementptr inbounds nuw %struct.B, ptr [[B]], i32 0, i32 2 @@ -134,15 +134,15 @@ __INTPTR_TYPE__ test_get_A(struct A *a) { // CHECK: [[A:%.*]] = load ptr, ptr %a.addr // CHECK: [[F0_ADDR:%.*]] = getelementptr inbounds nuw %struct.A, ptr [[A]], i32 0, i32 0 // CHECK: [[F0:%.*]] = load i64, ptr [[F0_ADDR]] - // CHECK: [[AUTH:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[F0]]) [ "ptrauth"(i64 1, i64 431) ] + // CHECK: [[AUTH:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[F0]]) [ "ptrauth"(i64 1, i64 431, i64 0) ] // CHECK: [[A:%.*]] = load ptr, ptr %a.addr // CHECK: [[F1_ADDR:%.*]] = getelementptr inbounds nuw %struct.A, ptr [[A]], i32 0, i32 1 // CHECK: [[F1:%.*]] = load i64, ptr [[F1_ADDR]] - // CHECK: [[AUTH:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[F1]]) [ "ptrauth"(i64 1, i64 9182) ] + // CHECK: [[AUTH:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[F1]]) [ "ptrauth"(i64 1, i64 9182, i64 0) ] // CHECK: [[A:%.*]] = load ptr, ptr %a.addr // CHECK: [[F2_ADDR:%.*]] = getelementptr inbounds nuw %struct.A, ptr [[A]], i32 0, i32 2 // CHECK: [[F2:%.*]] = load i64, ptr [[F2_ADDR]] - // CHECK: [[AUTH:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[F2]]) [ "ptrauth"(i64 1, i64 783) ] + // CHECK: [[AUTH:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[F2]]) [ "ptrauth"(i64 1, i64 783, i64 0) ] } // CHECK-LABEL: define i64 @test_get_B @@ -152,17 +152,17 @@ __INTPTR_TYPE__ test_get_B(struct B *b) { // CHECK: [[F0:%.*]] = getelementptr inbounds nuw %struct.B, ptr [[B]], i32 0, i32 0 // CHECK: [[VALUE:%.*]] = load i64, ptr [[F0]] // CHECK: [[CASTF0:%.*]] = ptrtoint ptr %f0 to i64 - // CHECK: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VALUE]]) [ "ptrauth"(i64 1, i64 [[CASTF0]], i64 1276) ] + // CHECK: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VALUE]]) [ "ptrauth"(i64 1, i64 1276, i64 [[CASTF0]]) ] // CHECK: [[B:%.*]] = load ptr, ptr %b.addr // CHECK: [[ADDR:%.*]] = getelementptr inbounds nuw %struct.B, ptr [[B]], i32 0, i32 1 // CHECK: [[VALUE:%.*]] = load i64, ptr [[ADDR]] // CHECK: [[CAST_ADDR:%.*]] = ptrtoint ptr [[ADDR]] to i64 - // CHECK: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VALUE]]) [ "ptrauth"(i64 1, i64 [[CAST_ADDR]], i64 23674) ] + // CHECK: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VALUE]]) [ "ptrauth"(i64 1, i64 23674, i64 [[CAST_ADDR]]) ] // CHECK: [[B:%.*]] = load ptr, ptr %b.addr // CHECK: [[ADDR:%.*]] = getelementptr inbounds nuw %struct.B, ptr [[B]], i32 0, i32 2 // CHECK: [[VALUE:%.*]] = load i64, ptr [[ADDR]] // CHECK: [[CAST_ADDR:%.*]] = ptrtoint ptr [[ADDR]] to i64 - // CHECK: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VALUE]]) [ "ptrauth"(i64 1, i64 [[CAST_ADDR]], i64 163) ] + // CHECK: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VALUE]]) [ "ptrauth"(i64 1, i64 163, i64 [[CAST_ADDR]]) ] } // CHECK-LABEL: define void @test_resign @@ -174,7 +174,7 @@ void test_resign(struct A* a, const struct B *b) { // CHECK: [[F01:%.*]] = getelementptr inbounds nuw %struct.B, ptr [[B]], i32 0, i32 0 // CHECK: [[F01VALUE:%.*]] = load i64, ptr [[F01]] // CHECK: [[CASTF01:%.*]] = ptrtoint ptr %f01 to i64 - // CHECK: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.resign(i64 [[F01VALUE]]) [ "ptrauth"(i64 1, i64 [[CASTF01]], i64 1276), "ptrauth"(i64 1, i64 431) ] + // CHECK: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.resign(i64 [[F01VALUE]]) [ "ptrauth"(i64 1, i64 1276, i64 [[CASTF01]]), "ptrauth"(i64 1, i64 431, i64 0) ] } // CHECK-LABEL: define i64 @other_test @@ -184,20 +184,20 @@ __INTPTR_TYPE__ other_test(__INTPTR_TYPE__ i) { // CHECK: store i64 0, ptr %j __INTPTR_TYPE__ __ptrauth(1, 1, 43) k = 1234; // CHECK: [[ADDR:%.*]] = ptrtoint ptr %k to i64 - // CHECK: [[SIGNED:%.*]] = call i64 @llvm.ptrauth.sign(i64 1234) [ "ptrauth"(i64 1, i64 [[ADDR]], i64 43) ] + // CHECK: [[SIGNED:%.*]] = call i64 @llvm.ptrauth.sign(i64 1234) [ "ptrauth"(i64 1, i64 43, i64 [[ADDR]]) ] __INTPTR_TYPE__ __ptrauth(1, 1, 44) l = i; // CHECK: [[I:%.*]] = load i64, ptr %i.addr // CHECK: [[ADDR:%.*]] = ptrtoint ptr %l to i64 - // CHECK: [[SIGNED:%.*]] = call i64 @llvm.ptrauth.sign(i64 [[I]]) [ "ptrauth"(i64 1, i64 [[ADDR]], i64 44) ] + // CHECK: [[SIGNED:%.*]] = call i64 @llvm.ptrauth.sign(i64 [[I]]) [ "ptrauth"(i64 1, i64 44, i64 [[ADDR]]) ] asm volatile ("" ::: "memory"); return j + k + l; // CHECK: [[VALUE:%.*]] = load i64, ptr %j // CHECK: [[CAST_ADDR:%.*]] = ptrtoint ptr %j to i64 - // CHECK: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VALUE]]) [ "ptrauth"(i64 1, i64 [[CAST_ADDR]], i64 42) ] + // CHECK: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VALUE]]) [ "ptrauth"(i64 1, i64 42, i64 [[CAST_ADDR]]) ] // CHECK: [[VALUE:%.*]] = load i64, ptr %k // CHECK: [[CASTK:%.*]] = ptrtoint ptr %k to i64 - // CHECK: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VALUE]]) [ "ptrauth"(i64 1, i64 [[CASTK]], i64 43) ] + // CHECK: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VALUE]]) [ "ptrauth"(i64 1, i64 43, i64 [[CASTK]]) ] // CHECK: [[VALUE:%.*]] = load i64, ptr %l // CHECK: [[CASTL:%.*]] = ptrtoint ptr %l to i64 - // CHECK: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VALUE]]) [ "ptrauth"(i64 1, i64 [[CASTL]], i64 44) ] + // CHECK: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VALUE]]) [ "ptrauth"(i64 1, i64 44, i64 [[CASTL]]) ] } diff --git a/clang/test/CodeGen/ubsan-function.cpp b/clang/test/CodeGen/ubsan-function.cpp index d4f1956496d86..60fd7edca0613 100644 --- a/clang/test/CodeGen/ubsan-function.cpp +++ b/clang/test/CodeGen/ubsan-function.cpp @@ -17,7 +17,7 @@ void fun() {} // ARM: and i32 {{.*}}, -2, !nosanitize !5 // ARM: inttoptr i32 {{.*}} to ptr, !nosanitize !5 // AUTH: %[[STRIPPED:.*]] = ptrtoint ptr {{.*}} to i64, !nosanitize -// AUTH: call i64 @llvm.ptrauth.auth(i64 %[[STRIPPED]]) [ "ptrauth"(i64 0, i64 0) ], !nosanitize +// AUTH: call i64 @llvm.ptrauth.auth(i64 %[[STRIPPED]]) [ "ptrauth"(i64 0, i64 0, i64 0) ], !nosanitize // CHECK: getelementptr <{ i32, i32 }>, ptr {{.*}}, i32 -1, i32 0, !nosanitize // CHECK: load i32, ptr {{.*}}, align {{.*}}, !nosanitize // CHECK: icmp eq i32 {{.*}}, -1056584962, !nosanitize diff --git a/clang/test/CodeGenCXX/builtin-get-vtable-pointer.cpp b/clang/test/CodeGenCXX/builtin-get-vtable-pointer.cpp index 84ee63ea61ebb..db0fd8e20e595 100644 --- a/clang/test/CodeGenCXX/builtin-get-vtable-pointer.cpp +++ b/clang/test/CodeGenCXX/builtin-get-vtable-pointer.cpp @@ -53,7 +53,7 @@ template struct same_type { // CHECK-TYPEAUTH-NEXT: [[TMP0:%.*]] = load ptr, ptr [[O_ADDR]], align 8, !tbaa [[TBAA6]] // CHECK-TYPEAUTH-NEXT: [[VTABLE:%.*]] = load ptr, ptr [[TMP0]], align 8, !tbaa [[TBAA9:![0-9]+]] // CHECK-TYPEAUTH-NEXT: [[TMP1:%.*]] = ptrtoint ptr [[VTABLE]] to i64 -// CHECK-TYPEAUTH-NEXT: [[TMP2:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[TMP1]]) [ "ptrauth"(i64 2, i64 48388) ] +// CHECK-TYPEAUTH-NEXT: [[TMP2:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[TMP1]]) [ "ptrauth"(i64 2, i64 48388, i64 0) ] // CHECK-TYPEAUTH-NEXT: [[TMP3:%.*]] = inttoptr i64 [[TMP2]] to ptr // CHECK-TYPEAUTH-NEXT: [[TMP4:%.*]] = load volatile i8, ptr [[TMP3]], align 8 // CHECK-TYPEAUTH-NEXT: ret ptr [[TMP3]] @@ -67,7 +67,7 @@ template struct same_type { // CHECK-ADDRESSAUTH-NEXT: [[VTABLE:%.*]] = load ptr, ptr [[TMP0]], align 8, !tbaa [[TBAA9:![0-9]+]] // CHECK-ADDRESSAUTH-NEXT: [[TMP1:%.*]] = ptrtoint ptr [[TMP0]] to i64 // CHECK-ADDRESSAUTH-NEXT: [[TMP2:%.*]] = ptrtoint ptr [[VTABLE]] to i64 -// CHECK-ADDRESSAUTH-NEXT: [[TMP3:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[TMP2]]) [ "ptrauth"(i64 2, i64 [[TMP1]]) ] +// CHECK-ADDRESSAUTH-NEXT: [[TMP3:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[TMP2]]) [ "ptrauth"(i64 2, i64 0, i64 [[TMP1]]) ] // CHECK-ADDRESSAUTH-NEXT: [[TMP4:%.*]] = inttoptr i64 [[TMP3]] to ptr // CHECK-ADDRESSAUTH-NEXT: [[TMP5:%.*]] = load volatile i8, ptr [[TMP4]], align 8 // CHECK-ADDRESSAUTH-NEXT: ret ptr [[TMP4]] @@ -81,7 +81,7 @@ template struct same_type { // CHECK-BOTHAUTH-NEXT: [[VTABLE:%.*]] = load ptr, ptr [[TMP0]], align 8, !tbaa [[TBAA9:![0-9]+]] // CHECK-BOTHAUTH-NEXT: [[TMP1:%.*]] = ptrtoint ptr [[TMP0]] to i64 // CHECK-BOTHAUTH-NEXT: [[TMP3:%.*]] = ptrtoint ptr [[VTABLE]] to i64 -// CHECK-BOTHAUTH-NEXT: [[TMP4:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[TMP3]]) [ "ptrauth"(i64 2, i64 [[TMP1]], i64 48388) ] +// CHECK-BOTHAUTH-NEXT: [[TMP4:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[TMP3]]) [ "ptrauth"(i64 2, i64 48388, i64 [[TMP1]]) ] // CHECK-BOTHAUTH-NEXT: [[TMP5:%.*]] = inttoptr i64 [[TMP4]] to ptr // CHECK-BOTHAUTH-NEXT: [[TMP6:%.*]] = load volatile i8, ptr [[TMP5]], align 8 // CHECK-BOTHAUTH-NEXT: ret ptr [[TMP5]] @@ -108,7 +108,7 @@ const void *a(A *o) { // CHECK-TYPEAUTH-NEXT: [[TMP0:%.*]] = load ptr, ptr [[O_ADDR]], align 8, !tbaa [[TBAA11]] // CHECK-TYPEAUTH-NEXT: [[VTABLE:%.*]] = load ptr, ptr [[TMP0]], align 8, !tbaa [[TBAA9]] // CHECK-TYPEAUTH-NEXT: [[TMP1:%.*]] = ptrtoint ptr [[VTABLE]] to i64 -// CHECK-TYPEAUTH-NEXT: [[TMP2:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[TMP1]]) [ "ptrauth"(i64 2, i64 48388) ] +// CHECK-TYPEAUTH-NEXT: [[TMP2:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[TMP1]]) [ "ptrauth"(i64 2, i64 48388, i64 0) ] // CHECK-TYPEAUTH-NEXT: [[TMP3:%.*]] = inttoptr i64 [[TMP2]] to ptr // CHECK-TYPEAUTH-NEXT: [[TMP4:%.*]] = load volatile i8, ptr [[TMP3]], align 8 // CHECK-TYPEAUTH-NEXT: ret ptr [[TMP3]] @@ -122,7 +122,7 @@ const void *a(A *o) { // CHECK-ADDRESSAUTH-NEXT: [[VTABLE:%.*]] = load ptr, ptr [[TMP0]], align 8, !tbaa [[TBAA9]] // CHECK-ADDRESSAUTH-NEXT: [[TMP1:%.*]] = ptrtoint ptr [[TMP0]] to i64 // CHECK-ADDRESSAUTH-NEXT: [[TMP2:%.*]] = ptrtoint ptr [[VTABLE]] to i64 -// CHECK-ADDRESSAUTH-NEXT: [[TMP3:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[TMP2]]) [ "ptrauth"(i64 2, i64 [[TMP1]]) ] +// CHECK-ADDRESSAUTH-NEXT: [[TMP3:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[TMP2]]) [ "ptrauth"(i64 2, i64 0, i64 [[TMP1]]) ] // CHECK-ADDRESSAUTH-NEXT: [[TMP4:%.*]] = inttoptr i64 [[TMP3]] to ptr // CHECK-ADDRESSAUTH-NEXT: [[TMP5:%.*]] = load volatile i8, ptr [[TMP4]], align 8 // CHECK-ADDRESSAUTH-NEXT: ret ptr [[TMP4]] @@ -136,7 +136,7 @@ const void *a(A *o) { // CHECK-BOTHAUTH-NEXT: [[VTABLE:%.*]] = load ptr, ptr [[TMP0]], align 8, !tbaa [[TBAA9]] // CHECK-BOTHAUTH-NEXT: [[TMP1:%.*]] = ptrtoint ptr [[TMP0]] to i64 // CHECK-BOTHAUTH-NEXT: [[TMP3:%.*]] = ptrtoint ptr [[VTABLE]] to i64 -// CHECK-BOTHAUTH-NEXT: [[TMP4:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[TMP3]]) [ "ptrauth"(i64 2, i64 [[TMP1]], i64 48388) ] +// CHECK-BOTHAUTH-NEXT: [[TMP4:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[TMP3]]) [ "ptrauth"(i64 2, i64 48388, i64 [[TMP1]]) ] // CHECK-BOTHAUTH-NEXT: [[TMP5:%.*]] = inttoptr i64 [[TMP4]] to ptr // CHECK-BOTHAUTH-NEXT: [[TMP6:%.*]] = load volatile i8, ptr [[TMP5]], align 8 // CHECK-BOTHAUTH-NEXT: ret ptr [[TMP5]] @@ -163,7 +163,7 @@ const void *b(B *o) { // CHECK-TYPEAUTH-NEXT: [[TMP0:%.*]] = load ptr, ptr [[O_ADDR]], align 8, !tbaa [[TBAA11]] // CHECK-TYPEAUTH-NEXT: [[VTABLE:%.*]] = load ptr, ptr [[TMP0]], align 8, !tbaa [[TBAA9]] // CHECK-TYPEAUTH-NEXT: [[TMP1:%.*]] = ptrtoint ptr [[VTABLE]] to i64 -// CHECK-TYPEAUTH-NEXT: [[TMP2:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[TMP1]]) [ "ptrauth"(i64 2, i64 48388) ] +// CHECK-TYPEAUTH-NEXT: [[TMP2:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[TMP1]]) [ "ptrauth"(i64 2, i64 48388, i64 0) ] // CHECK-TYPEAUTH-NEXT: [[TMP3:%.*]] = inttoptr i64 [[TMP2]] to ptr // CHECK-TYPEAUTH-NEXT: [[TMP4:%.*]] = load volatile i8, ptr [[TMP3]], align 8 // CHECK-TYPEAUTH-NEXT: ret ptr [[TMP3]] @@ -177,7 +177,7 @@ const void *b(B *o) { // CHECK-ADDRESSAUTH-NEXT: [[VTABLE:%.*]] = load ptr, ptr [[TMP0]], align 8, !tbaa [[TBAA9]] // CHECK-ADDRESSAUTH-NEXT: [[TMP1:%.*]] = ptrtoint ptr [[TMP0]] to i64 // CHECK-ADDRESSAUTH-NEXT: [[TMP2:%.*]] = ptrtoint ptr [[VTABLE]] to i64 -// CHECK-ADDRESSAUTH-NEXT: [[TMP3:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[TMP2]]) [ "ptrauth"(i64 2, i64 [[TMP1]]) ] +// CHECK-ADDRESSAUTH-NEXT: [[TMP3:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[TMP2]]) [ "ptrauth"(i64 2, i64 0, i64 [[TMP1]]) ] // CHECK-ADDRESSAUTH-NEXT: [[TMP4:%.*]] = inttoptr i64 [[TMP3]] to ptr // CHECK-ADDRESSAUTH-NEXT: [[TMP5:%.*]] = load volatile i8, ptr [[TMP4]], align 8 // CHECK-ADDRESSAUTH-NEXT: ret ptr [[TMP4]] @@ -191,7 +191,7 @@ const void *b(B *o) { // CHECK-BOTHAUTH-NEXT: [[VTABLE:%.*]] = load ptr, ptr [[TMP0]], align 8, !tbaa [[TBAA9]] // CHECK-BOTHAUTH-NEXT: [[TMP1:%.*]] = ptrtoint ptr [[TMP0]] to i64 // CHECK-BOTHAUTH-NEXT: [[TMP3:%.*]] = ptrtoint ptr [[VTABLE]] to i64 -// CHECK-BOTHAUTH-NEXT: [[TMP4:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[TMP3]]) [ "ptrauth"(i64 2, i64 [[TMP1]], i64 48388) ] +// CHECK-BOTHAUTH-NEXT: [[TMP4:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[TMP3]]) [ "ptrauth"(i64 2, i64 48388, i64 [[TMP1]]) ] // CHECK-BOTHAUTH-NEXT: [[TMP5:%.*]] = inttoptr i64 [[TMP4]] to ptr // CHECK-BOTHAUTH-NEXT: [[TMP6:%.*]] = load volatile i8, ptr [[TMP5]], align 8 // CHECK-BOTHAUTH-NEXT: ret ptr [[TMP5]] @@ -218,7 +218,7 @@ const void *b_as_A(B *o) { // CHECK-TYPEAUTH-NEXT: [[TMP0:%.*]] = load ptr, ptr [[O_ADDR]], align 8, !tbaa [[TBAA13]] // CHECK-TYPEAUTH-NEXT: [[VTABLE:%.*]] = load ptr, ptr [[TMP0]], align 8, !tbaa [[TBAA9]] // CHECK-TYPEAUTH-NEXT: [[TMP1:%.*]] = ptrtoint ptr [[VTABLE]] to i64 -// CHECK-TYPEAUTH-NEXT: [[TMP2:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[TMP1]]) [ "ptrauth"(i64 2, i64 48388) ] +// CHECK-TYPEAUTH-NEXT: [[TMP2:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[TMP1]]) [ "ptrauth"(i64 2, i64 48388, i64 0) ] // CHECK-TYPEAUTH-NEXT: [[TMP3:%.*]] = inttoptr i64 [[TMP2]] to ptr // CHECK-TYPEAUTH-NEXT: [[TMP4:%.*]] = load volatile i8, ptr [[TMP3]], align 8 // CHECK-TYPEAUTH-NEXT: ret ptr [[TMP3]] @@ -232,7 +232,7 @@ const void *b_as_A(B *o) { // CHECK-ADDRESSAUTH-NEXT: [[VTABLE:%.*]] = load ptr, ptr [[TMP0]], align 8, !tbaa [[TBAA9]] // CHECK-ADDRESSAUTH-NEXT: [[TMP1:%.*]] = ptrtoint ptr [[TMP0]] to i64 // CHECK-ADDRESSAUTH-NEXT: [[TMP2:%.*]] = ptrtoint ptr [[VTABLE]] to i64 -// CHECK-ADDRESSAUTH-NEXT: [[TMP3:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[TMP2]]) [ "ptrauth"(i64 2, i64 [[TMP1]]) ] +// CHECK-ADDRESSAUTH-NEXT: [[TMP3:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[TMP2]]) [ "ptrauth"(i64 2, i64 0, i64 [[TMP1]]) ] // CHECK-ADDRESSAUTH-NEXT: [[TMP4:%.*]] = inttoptr i64 [[TMP3]] to ptr // CHECK-ADDRESSAUTH-NEXT: [[TMP5:%.*]] = load volatile i8, ptr [[TMP4]], align 8 // CHECK-ADDRESSAUTH-NEXT: ret ptr [[TMP4]] @@ -246,7 +246,7 @@ const void *b_as_A(B *o) { // CHECK-BOTHAUTH-NEXT: [[VTABLE:%.*]] = load ptr, ptr [[TMP0]], align 8, !tbaa [[TBAA9]] // CHECK-BOTHAUTH-NEXT: [[TMP1:%.*]] = ptrtoint ptr [[TMP0]] to i64 // CHECK-BOTHAUTH-NEXT: [[TMP3:%.*]] = ptrtoint ptr [[VTABLE]] to i64 -// CHECK-BOTHAUTH-NEXT: [[TMP4:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[TMP3]]) [ "ptrauth"(i64 2, i64 [[TMP1]], i64 48388) ] +// CHECK-BOTHAUTH-NEXT: [[TMP4:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[TMP3]]) [ "ptrauth"(i64 2, i64 48388, i64 [[TMP1]]) ] // CHECK-BOTHAUTH-NEXT: [[TMP5:%.*]] = inttoptr i64 [[TMP4]] to ptr // CHECK-BOTHAUTH-NEXT: [[TMP6:%.*]] = load volatile i8, ptr [[TMP5]], align 8 // CHECK-BOTHAUTH-NEXT: ret ptr [[TMP5]] @@ -273,7 +273,7 @@ const void *c(C *o) { // CHECK-TYPEAUTH-NEXT: [[TMP0:%.*]] = load ptr, ptr [[O_ADDR]], align 8, !tbaa [[TBAA13]] // CHECK-TYPEAUTH-NEXT: [[VTABLE:%.*]] = load ptr, ptr [[TMP0]], align 8, !tbaa [[TBAA9]] // CHECK-TYPEAUTH-NEXT: [[TMP1:%.*]] = ptrtoint ptr [[VTABLE]] to i64 -// CHECK-TYPEAUTH-NEXT: [[TMP2:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[TMP1]]) [ "ptrauth"(i64 2, i64 48388) ] +// CHECK-TYPEAUTH-NEXT: [[TMP2:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[TMP1]]) [ "ptrauth"(i64 2, i64 48388, i64 0) ] // CHECK-TYPEAUTH-NEXT: [[TMP3:%.*]] = inttoptr i64 [[TMP2]] to ptr // CHECK-TYPEAUTH-NEXT: [[TMP4:%.*]] = load volatile i8, ptr [[TMP3]], align 8 // CHECK-TYPEAUTH-NEXT: ret ptr [[TMP3]] @@ -287,7 +287,7 @@ const void *c(C *o) { // CHECK-ADDRESSAUTH-NEXT: [[VTABLE:%.*]] = load ptr, ptr [[TMP0]], align 8, !tbaa [[TBAA9]] // CHECK-ADDRESSAUTH-NEXT: [[TMP1:%.*]] = ptrtoint ptr [[TMP0]] to i64 // CHECK-ADDRESSAUTH-NEXT: [[TMP2:%.*]] = ptrtoint ptr [[VTABLE]] to i64 -// CHECK-ADDRESSAUTH-NEXT: [[TMP3:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[TMP2]]) [ "ptrauth"(i64 2, i64 [[TMP1]]) ] +// CHECK-ADDRESSAUTH-NEXT: [[TMP3:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[TMP2]]) [ "ptrauth"(i64 2, i64 0, i64 [[TMP1]]) ] // CHECK-ADDRESSAUTH-NEXT: [[TMP4:%.*]] = inttoptr i64 [[TMP3]] to ptr // CHECK-ADDRESSAUTH-NEXT: [[TMP5:%.*]] = load volatile i8, ptr [[TMP4]], align 8 // CHECK-ADDRESSAUTH-NEXT: ret ptr [[TMP4]] @@ -301,7 +301,7 @@ const void *c(C *o) { // CHECK-BOTHAUTH-NEXT: [[VTABLE:%.*]] = load ptr, ptr [[TMP0]], align 8, !tbaa [[TBAA9]] // CHECK-BOTHAUTH-NEXT: [[TMP1:%.*]] = ptrtoint ptr [[TMP0]] to i64 // CHECK-BOTHAUTH-NEXT: [[TMP3:%.*]] = ptrtoint ptr [[VTABLE]] to i64 -// CHECK-BOTHAUTH-NEXT: [[TMP4:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[TMP3]]) [ "ptrauth"(i64 2, i64 [[TMP1]], i64 48388) ] +// CHECK-BOTHAUTH-NEXT: [[TMP4:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[TMP3]]) [ "ptrauth"(i64 2, i64 48388, i64 [[TMP1]]) ] // CHECK-BOTHAUTH-NEXT: [[TMP5:%.*]] = inttoptr i64 [[TMP4]] to ptr // CHECK-BOTHAUTH-NEXT: [[TMP6:%.*]] = load volatile i8, ptr [[TMP5]], align 8 // CHECK-BOTHAUTH-NEXT: ret ptr [[TMP5]] @@ -342,7 +342,7 @@ const void *c_as_Z(C *o) { // CHECK-TYPEAUTH-NEXT: [[CAST_RESULT:%.*]] = phi ptr [ [[ADD_PTR]], %[[CAST_NOTNULL]] ], [ null, %[[ENTRY]] ] // CHECK-TYPEAUTH-NEXT: [[VTABLE:%.*]] = load ptr, ptr [[CAST_RESULT]], align 8, !tbaa [[TBAA9]] // CHECK-TYPEAUTH-NEXT: [[TMP2:%.*]] = ptrtoint ptr [[VTABLE]] to i64 -// CHECK-TYPEAUTH-NEXT: [[TMP3:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[TMP2]]) [ "ptrauth"(i64 2, i64 48388) ] +// CHECK-TYPEAUTH-NEXT: [[TMP3:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[TMP2]]) [ "ptrauth"(i64 2, i64 48388, i64 0) ] // CHECK-TYPEAUTH-NEXT: [[TMP4:%.*]] = inttoptr i64 [[TMP3]] to ptr // CHECK-TYPEAUTH-NEXT: [[TMP5:%.*]] = load volatile i8, ptr [[TMP4]], align 8 // CHECK-TYPEAUTH-NEXT: ret ptr [[TMP4]] @@ -363,7 +363,7 @@ const void *c_as_Z(C *o) { // CHECK-ADDRESSAUTH-NEXT: [[VTABLE:%.*]] = load ptr, ptr [[CAST_RESULT]], align 8, !tbaa [[TBAA9]] // CHECK-ADDRESSAUTH-NEXT: [[TMP2:%.*]] = ptrtoint ptr [[CAST_RESULT]] to i64 // CHECK-ADDRESSAUTH-NEXT: [[TMP3:%.*]] = ptrtoint ptr [[VTABLE]] to i64 -// CHECK-ADDRESSAUTH-NEXT: [[TMP4:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[TMP3]]) [ "ptrauth"(i64 2, i64 [[TMP2]]) ] +// CHECK-ADDRESSAUTH-NEXT: [[TMP4:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[TMP3]]) [ "ptrauth"(i64 2, i64 0, i64 [[TMP2]]) ] // CHECK-ADDRESSAUTH-NEXT: [[TMP5:%.*]] = inttoptr i64 [[TMP4]] to ptr // CHECK-ADDRESSAUTH-NEXT: [[TMP6:%.*]] = load volatile i8, ptr [[TMP5]], align 8 // CHECK-ADDRESSAUTH-NEXT: ret ptr [[TMP5]] @@ -384,7 +384,7 @@ const void *c_as_Z(C *o) { // CHECK-BOTHAUTH-NEXT: [[VTABLE:%.*]] = load ptr, ptr [[CAST_RESULT]], align 8, !tbaa [[TBAA9]] // CHECK-BOTHAUTH-NEXT: [[TMP2:%.*]] = ptrtoint ptr [[CAST_RESULT]] to i64 // CHECK-BOTHAUTH-NEXT: [[TMP4:%.*]] = ptrtoint ptr [[VTABLE]] to i64 -// CHECK-BOTHAUTH-NEXT: [[TMP5:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[TMP4]]) [ "ptrauth"(i64 2, i64 [[TMP2]], i64 48388) ] +// CHECK-BOTHAUTH-NEXT: [[TMP5:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[TMP4]]) [ "ptrauth"(i64 2, i64 48388, i64 [[TMP2]]) ] // CHECK-BOTHAUTH-NEXT: [[TMP6:%.*]] = inttoptr i64 [[TMP5]] to ptr // CHECK-BOTHAUTH-NEXT: [[TMP7:%.*]] = load volatile i8, ptr [[TMP6]], align 8 // CHECK-BOTHAUTH-NEXT: ret ptr [[TMP6]] @@ -411,7 +411,7 @@ const void *c_as_B(C *o) { // CHECK-TYPEAUTH-NEXT: [[TMP0:%.*]] = load ptr, ptr [[O_ADDR]], align 8, !tbaa [[TBAA15]] // CHECK-TYPEAUTH-NEXT: [[VTABLE:%.*]] = load ptr, ptr [[TMP0]], align 8, !tbaa [[TBAA9]] // CHECK-TYPEAUTH-NEXT: [[TMP1:%.*]] = ptrtoint ptr [[VTABLE]] to i64 -// CHECK-TYPEAUTH-NEXT: [[TMP2:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[TMP1]]) [ "ptrauth"(i64 2, i64 48388) ] +// CHECK-TYPEAUTH-NEXT: [[TMP2:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[TMP1]]) [ "ptrauth"(i64 2, i64 48388, i64 0) ] // CHECK-TYPEAUTH-NEXT: [[TMP3:%.*]] = inttoptr i64 [[TMP2]] to ptr // CHECK-TYPEAUTH-NEXT: [[TMP4:%.*]] = load volatile i8, ptr [[TMP3]], align 8 // CHECK-TYPEAUTH-NEXT: ret ptr [[TMP3]] @@ -425,7 +425,7 @@ const void *c_as_B(C *o) { // CHECK-ADDRESSAUTH-NEXT: [[VTABLE:%.*]] = load ptr, ptr [[TMP0]], align 8, !tbaa [[TBAA9]] // CHECK-ADDRESSAUTH-NEXT: [[TMP1:%.*]] = ptrtoint ptr [[TMP0]] to i64 // CHECK-ADDRESSAUTH-NEXT: [[TMP2:%.*]] = ptrtoint ptr [[VTABLE]] to i64 -// CHECK-ADDRESSAUTH-NEXT: [[TMP3:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[TMP2]]) [ "ptrauth"(i64 2, i64 [[TMP1]]) ] +// CHECK-ADDRESSAUTH-NEXT: [[TMP3:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[TMP2]]) [ "ptrauth"(i64 2, i64 0, i64 [[TMP1]]) ] // CHECK-ADDRESSAUTH-NEXT: [[TMP4:%.*]] = inttoptr i64 [[TMP3]] to ptr // CHECK-ADDRESSAUTH-NEXT: [[TMP5:%.*]] = load volatile i8, ptr [[TMP4]], align 8 // CHECK-ADDRESSAUTH-NEXT: ret ptr [[TMP4]] @@ -439,7 +439,7 @@ const void *c_as_B(C *o) { // CHECK-BOTHAUTH-NEXT: [[VTABLE:%.*]] = load ptr, ptr [[TMP0]], align 8, !tbaa [[TBAA9]] // CHECK-BOTHAUTH-NEXT: [[TMP1:%.*]] = ptrtoint ptr [[TMP0]] to i64 // CHECK-BOTHAUTH-NEXT: [[TMP3:%.*]] = ptrtoint ptr [[VTABLE]] to i64 -// CHECK-BOTHAUTH-NEXT: [[TMP4:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[TMP3]]) [ "ptrauth"(i64 2, i64 [[TMP1]], i64 48388) ] +// CHECK-BOTHAUTH-NEXT: [[TMP4:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[TMP3]]) [ "ptrauth"(i64 2, i64 48388, i64 [[TMP1]]) ] // CHECK-BOTHAUTH-NEXT: [[TMP5:%.*]] = inttoptr i64 [[TMP4]] to ptr // CHECK-BOTHAUTH-NEXT: [[TMP6:%.*]] = load volatile i8, ptr [[TMP5]], align 8 // CHECK-BOTHAUTH-NEXT: ret ptr [[TMP5]] @@ -479,7 +479,7 @@ const void *d(D *o) { // CHECK-TYPEAUTH: [[CAST_NOTNULL]]: // CHECK-TYPEAUTH-NEXT: [[VTABLE:%.*]] = load ptr, ptr [[TMP0]], align 8, !tbaa [[TBAA9]] // CHECK-TYPEAUTH-NEXT: [[TMP2:%.*]] = ptrtoint ptr [[VTABLE]] to i64 -// CHECK-TYPEAUTH-NEXT: [[TMP3:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[TMP2]]) [ "ptrauth"(i64 2, i64 48388) ] +// CHECK-TYPEAUTH-NEXT: [[TMP3:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[TMP2]]) [ "ptrauth"(i64 2, i64 48388, i64 0) ] // CHECK-TYPEAUTH-NEXT: [[TMP4:%.*]] = inttoptr i64 [[TMP3]] to ptr // CHECK-TYPEAUTH-NEXT: [[VBASE_OFFSET_PTR:%.*]] = getelementptr i8, ptr [[TMP4]], i64 -32 // CHECK-TYPEAUTH-NEXT: [[VBASE_OFFSET:%.*]] = load i64, ptr [[VBASE_OFFSET_PTR]], align 8 @@ -489,7 +489,7 @@ const void *d(D *o) { // CHECK-TYPEAUTH-NEXT: [[CAST_RESULT:%.*]] = phi ptr [ [[ADD_PTR]], %[[CAST_NOTNULL]] ], [ null, %[[ENTRY]] ] // CHECK-TYPEAUTH-NEXT: [[VTABLE1:%.*]] = load ptr, ptr [[CAST_RESULT]], align 8, !tbaa [[TBAA9]] // CHECK-TYPEAUTH-NEXT: [[TMP5:%.*]] = ptrtoint ptr [[VTABLE1]] to i64 -// CHECK-TYPEAUTH-NEXT: [[TMP6:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[TMP5]]) [ "ptrauth"(i64 2, i64 48388) ] +// CHECK-TYPEAUTH-NEXT: [[TMP6:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[TMP5]]) [ "ptrauth"(i64 2, i64 48388, i64 0) ] // CHECK-TYPEAUTH-NEXT: [[TMP7:%.*]] = inttoptr i64 [[TMP6]] to ptr // CHECK-TYPEAUTH-NEXT: [[TMP8:%.*]] = load volatile i8, ptr [[TMP7]], align 8 // CHECK-TYPEAUTH-NEXT: ret ptr [[TMP7]] @@ -506,7 +506,7 @@ const void *d(D *o) { // CHECK-ADDRESSAUTH-NEXT: [[VTABLE:%.*]] = load ptr, ptr [[TMP0]], align 8, !tbaa [[TBAA9]] // CHECK-ADDRESSAUTH-NEXT: [[TMP2:%.*]] = ptrtoint ptr [[TMP0]] to i64 // CHECK-ADDRESSAUTH-NEXT: [[TMP3:%.*]] = ptrtoint ptr [[VTABLE]] to i64 -// CHECK-ADDRESSAUTH-NEXT: [[TMP4:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[TMP3]]) [ "ptrauth"(i64 2, i64 [[TMP2]]) ] +// CHECK-ADDRESSAUTH-NEXT: [[TMP4:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[TMP3]]) [ "ptrauth"(i64 2, i64 0, i64 [[TMP2]]) ] // CHECK-ADDRESSAUTH-NEXT: [[TMP5:%.*]] = inttoptr i64 [[TMP4]] to ptr // CHECK-ADDRESSAUTH-NEXT: [[VBASE_OFFSET_PTR:%.*]] = getelementptr i8, ptr [[TMP5]], i64 -32 // CHECK-ADDRESSAUTH-NEXT: [[VBASE_OFFSET:%.*]] = load i64, ptr [[VBASE_OFFSET_PTR]], align 8 @@ -517,7 +517,7 @@ const void *d(D *o) { // CHECK-ADDRESSAUTH-NEXT: [[VTABLE1:%.*]] = load ptr, ptr [[CAST_RESULT]], align 8, !tbaa [[TBAA9]] // CHECK-ADDRESSAUTH-NEXT: [[TMP6:%.*]] = ptrtoint ptr [[CAST_RESULT]] to i64 // CHECK-ADDRESSAUTH-NEXT: [[TMP7:%.*]] = ptrtoint ptr [[VTABLE1]] to i64 -// CHECK-ADDRESSAUTH-NEXT: [[TMP8:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[TMP7]]) [ "ptrauth"(i64 2, i64 [[TMP6]]) ] +// CHECK-ADDRESSAUTH-NEXT: [[TMP8:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[TMP7]]) [ "ptrauth"(i64 2, i64 0, i64 [[TMP6]]) ] // CHECK-ADDRESSAUTH-NEXT: [[TMP9:%.*]] = inttoptr i64 [[TMP8]] to ptr // CHECK-ADDRESSAUTH-NEXT: [[TMP10:%.*]] = load volatile i8, ptr [[TMP9]], align 8 // CHECK-ADDRESSAUTH-NEXT: ret ptr [[TMP9]] @@ -534,7 +534,7 @@ const void *d(D *o) { // CHECK-BOTHAUTH-NEXT: [[VTABLE:%.*]] = load ptr, ptr [[TMP0]], align 8, !tbaa [[TBAA9]] // CHECK-BOTHAUTH-NEXT: [[TMP2:%.*]] = ptrtoint ptr [[TMP0]] to i64 // CHECK-BOTHAUTH-NEXT: [[TMP4:%.*]] = ptrtoint ptr [[VTABLE]] to i64 -// CHECK-BOTHAUTH-NEXT: [[TMP5:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[TMP4]]) [ "ptrauth"(i64 2, i64 [[TMP2]], i64 48388) ] +// CHECK-BOTHAUTH-NEXT: [[TMP5:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[TMP4]]) [ "ptrauth"(i64 2, i64 48388, i64 [[TMP2]]) ] // CHECK-BOTHAUTH-NEXT: [[TMP6:%.*]] = inttoptr i64 [[TMP5]] to ptr // CHECK-BOTHAUTH-NEXT: [[VBASE_OFFSET_PTR:%.*]] = getelementptr i8, ptr [[TMP6]], i64 -32 // CHECK-BOTHAUTH-NEXT: [[VBASE_OFFSET:%.*]] = load i64, ptr [[VBASE_OFFSET_PTR]], align 8 @@ -545,7 +545,7 @@ const void *d(D *o) { // CHECK-BOTHAUTH-NEXT: [[VTABLE1:%.*]] = load ptr, ptr [[CAST_RESULT]], align 8, !tbaa [[TBAA9]] // CHECK-BOTHAUTH-NEXT: [[TMP7:%.*]] = ptrtoint ptr [[CAST_RESULT]] to i64 // CHECK-BOTHAUTH-NEXT: [[TMP9:%.*]] = ptrtoint ptr [[VTABLE1]] to i64 -// CHECK-BOTHAUTH-NEXT: [[TMP10:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[TMP9]]) [ "ptrauth"(i64 2, i64 [[TMP7]], i64 48388) ] +// CHECK-BOTHAUTH-NEXT: [[TMP10:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[TMP9]]) [ "ptrauth"(i64 2, i64 48388, i64 [[TMP7]]) ] // CHECK-BOTHAUTH-NEXT: [[TMP11:%.*]] = inttoptr i64 [[TMP10]] to ptr // CHECK-BOTHAUTH-NEXT: [[TMP12:%.*]] = load volatile i8, ptr [[TMP11]], align 8 // CHECK-BOTHAUTH-NEXT: ret ptr [[TMP11]] @@ -572,7 +572,7 @@ const void *d_as_A(D *o) { // CHECK-TYPEAUTH-NEXT: [[TMP0:%.*]] = load ptr, ptr [[O_ADDR]], align 8, !tbaa [[TBAA17]] // CHECK-TYPEAUTH-NEXT: [[VTABLE:%.*]] = load ptr, ptr [[TMP0]], align 8, !tbaa [[TBAA9]] // CHECK-TYPEAUTH-NEXT: [[TMP1:%.*]] = ptrtoint ptr [[VTABLE]] to i64 -// CHECK-TYPEAUTH-NEXT: [[TMP2:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[TMP1]]) [ "ptrauth"(i64 2, i64 48388) ] +// CHECK-TYPEAUTH-NEXT: [[TMP2:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[TMP1]]) [ "ptrauth"(i64 2, i64 48388, i64 0) ] // CHECK-TYPEAUTH-NEXT: [[TMP3:%.*]] = inttoptr i64 [[TMP2]] to ptr // CHECK-TYPEAUTH-NEXT: [[TMP4:%.*]] = load volatile i8, ptr [[TMP3]], align 8 // CHECK-TYPEAUTH-NEXT: ret ptr [[TMP3]] @@ -586,7 +586,7 @@ const void *d_as_A(D *o) { // CHECK-ADDRESSAUTH-NEXT: [[VTABLE:%.*]] = load ptr, ptr [[TMP0]], align 8, !tbaa [[TBAA9]] // CHECK-ADDRESSAUTH-NEXT: [[TMP1:%.*]] = ptrtoint ptr [[TMP0]] to i64 // CHECK-ADDRESSAUTH-NEXT: [[TMP2:%.*]] = ptrtoint ptr [[VTABLE]] to i64 -// CHECK-ADDRESSAUTH-NEXT: [[TMP3:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[TMP2]]) [ "ptrauth"(i64 2, i64 [[TMP1]]) ] +// CHECK-ADDRESSAUTH-NEXT: [[TMP3:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[TMP2]]) [ "ptrauth"(i64 2, i64 0, i64 [[TMP1]]) ] // CHECK-ADDRESSAUTH-NEXT: [[TMP4:%.*]] = inttoptr i64 [[TMP3]] to ptr // CHECK-ADDRESSAUTH-NEXT: [[TMP5:%.*]] = load volatile i8, ptr [[TMP4]], align 8 // CHECK-ADDRESSAUTH-NEXT: ret ptr [[TMP4]] @@ -600,7 +600,7 @@ const void *d_as_A(D *o) { // CHECK-BOTHAUTH-NEXT: [[VTABLE:%.*]] = load ptr, ptr [[TMP0]], align 8, !tbaa [[TBAA9]] // CHECK-BOTHAUTH-NEXT: [[TMP1:%.*]] = ptrtoint ptr [[TMP0]] to i64 // CHECK-BOTHAUTH-NEXT: [[TMP3:%.*]] = ptrtoint ptr [[VTABLE]] to i64 -// CHECK-BOTHAUTH-NEXT: [[TMP4:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[TMP3]]) [ "ptrauth"(i64 2, i64 [[TMP1]], i64 48388) ] +// CHECK-BOTHAUTH-NEXT: [[TMP4:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[TMP3]]) [ "ptrauth"(i64 2, i64 48388, i64 [[TMP1]]) ] // CHECK-BOTHAUTH-NEXT: [[TMP5:%.*]] = inttoptr i64 [[TMP4]] to ptr // CHECK-BOTHAUTH-NEXT: [[TMP6:%.*]] = load volatile i8, ptr [[TMP5]], align 8 // CHECK-BOTHAUTH-NEXT: ret ptr [[TMP5]] @@ -641,7 +641,7 @@ const void *e(E *o) { // CHECK-TYPEAUTH-NEXT: [[CAST_RESULT:%.*]] = phi ptr [ [[ADD_PTR]], %[[CAST_NOTNULL]] ], [ null, %[[ENTRY]] ] // CHECK-TYPEAUTH-NEXT: [[VTABLE:%.*]] = load ptr, ptr [[CAST_RESULT]], align 8, !tbaa [[TBAA9]] // CHECK-TYPEAUTH-NEXT: [[TMP2:%.*]] = ptrtoint ptr [[VTABLE]] to i64 -// CHECK-TYPEAUTH-NEXT: [[TMP3:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[TMP2]]) [ "ptrauth"(i64 2, i64 48388) ] +// CHECK-TYPEAUTH-NEXT: [[TMP3:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[TMP2]]) [ "ptrauth"(i64 2, i64 48388, i64 0) ] // CHECK-TYPEAUTH-NEXT: [[TMP4:%.*]] = inttoptr i64 [[TMP3]] to ptr // CHECK-TYPEAUTH-NEXT: [[TMP5:%.*]] = load volatile i8, ptr [[TMP4]], align 8 // CHECK-TYPEAUTH-NEXT: ret ptr [[TMP4]] @@ -662,7 +662,7 @@ const void *e(E *o) { // CHECK-ADDRESSAUTH-NEXT: [[VTABLE:%.*]] = load ptr, ptr [[CAST_RESULT]], align 8, !tbaa [[TBAA9]] // CHECK-ADDRESSAUTH-NEXT: [[TMP2:%.*]] = ptrtoint ptr [[CAST_RESULT]] to i64 // CHECK-ADDRESSAUTH-NEXT: [[TMP3:%.*]] = ptrtoint ptr [[VTABLE]] to i64 -// CHECK-ADDRESSAUTH-NEXT: [[TMP4:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[TMP3]]) [ "ptrauth"(i64 2, i64 [[TMP2]]) ] +// CHECK-ADDRESSAUTH-NEXT: [[TMP4:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[TMP3]]) [ "ptrauth"(i64 2, i64 0, i64 [[TMP2]]) ] // CHECK-ADDRESSAUTH-NEXT: [[TMP5:%.*]] = inttoptr i64 [[TMP4]] to ptr // CHECK-ADDRESSAUTH-NEXT: [[TMP6:%.*]] = load volatile i8, ptr [[TMP5]], align 8 // CHECK-ADDRESSAUTH-NEXT: ret ptr [[TMP5]] @@ -683,7 +683,7 @@ const void *e(E *o) { // CHECK-BOTHAUTH-NEXT: [[VTABLE:%.*]] = load ptr, ptr [[CAST_RESULT]], align 8, !tbaa [[TBAA9]] // CHECK-BOTHAUTH-NEXT: [[TMP2:%.*]] = ptrtoint ptr [[CAST_RESULT]] to i64 // CHECK-BOTHAUTH-NEXT: [[TMP4:%.*]] = ptrtoint ptr [[VTABLE]] to i64 -// CHECK-BOTHAUTH-NEXT: [[TMP5:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[TMP4]]) [ "ptrauth"(i64 2, i64 [[TMP2]], i64 48388) ] +// CHECK-BOTHAUTH-NEXT: [[TMP5:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[TMP4]]) [ "ptrauth"(i64 2, i64 48388, i64 [[TMP2]]) ] // CHECK-BOTHAUTH-NEXT: [[TMP6:%.*]] = inttoptr i64 [[TMP5]] to ptr // CHECK-BOTHAUTH-NEXT: [[TMP7:%.*]] = load volatile i8, ptr [[TMP6]], align 8 // CHECK-BOTHAUTH-NEXT: ret ptr [[TMP6]] @@ -710,7 +710,7 @@ const void *e_as_B(E *o) { // CHECK-TYPEAUTH-NEXT: [[TMP0:%.*]] = load ptr, ptr [[O_ADDR]], align 8, !tbaa [[TBAA17]] // CHECK-TYPEAUTH-NEXT: [[VTABLE:%.*]] = load ptr, ptr [[TMP0]], align 8, !tbaa [[TBAA9]] // CHECK-TYPEAUTH-NEXT: [[TMP1:%.*]] = ptrtoint ptr [[VTABLE]] to i64 -// CHECK-TYPEAUTH-NEXT: [[TMP2:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[TMP1]]) [ "ptrauth"(i64 2, i64 48388) ] +// CHECK-TYPEAUTH-NEXT: [[TMP2:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[TMP1]]) [ "ptrauth"(i64 2, i64 48388, i64 0) ] // CHECK-TYPEAUTH-NEXT: [[TMP3:%.*]] = inttoptr i64 [[TMP2]] to ptr // CHECK-TYPEAUTH-NEXT: [[TMP4:%.*]] = load volatile i8, ptr [[TMP3]], align 8 // CHECK-TYPEAUTH-NEXT: ret ptr [[TMP3]] @@ -724,7 +724,7 @@ const void *e_as_B(E *o) { // CHECK-ADDRESSAUTH-NEXT: [[VTABLE:%.*]] = load ptr, ptr [[TMP0]], align 8, !tbaa [[TBAA9]] // CHECK-ADDRESSAUTH-NEXT: [[TMP1:%.*]] = ptrtoint ptr [[TMP0]] to i64 // CHECK-ADDRESSAUTH-NEXT: [[TMP2:%.*]] = ptrtoint ptr [[VTABLE]] to i64 -// CHECK-ADDRESSAUTH-NEXT: [[TMP3:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[TMP2]]) [ "ptrauth"(i64 2, i64 [[TMP1]]) ] +// CHECK-ADDRESSAUTH-NEXT: [[TMP3:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[TMP2]]) [ "ptrauth"(i64 2, i64 0, i64 [[TMP1]]) ] // CHECK-ADDRESSAUTH-NEXT: [[TMP4:%.*]] = inttoptr i64 [[TMP3]] to ptr // CHECK-ADDRESSAUTH-NEXT: [[TMP5:%.*]] = load volatile i8, ptr [[TMP4]], align 8 // CHECK-ADDRESSAUTH-NEXT: ret ptr [[TMP4]] @@ -738,7 +738,7 @@ const void *e_as_B(E *o) { // CHECK-BOTHAUTH-NEXT: [[VTABLE:%.*]] = load ptr, ptr [[TMP0]], align 8, !tbaa [[TBAA9]] // CHECK-BOTHAUTH-NEXT: [[TMP1:%.*]] = ptrtoint ptr [[TMP0]] to i64 // CHECK-BOTHAUTH-NEXT: [[TMP3:%.*]] = ptrtoint ptr [[VTABLE]] to i64 -// CHECK-BOTHAUTH-NEXT: [[TMP4:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[TMP3]]) [ "ptrauth"(i64 2, i64 [[TMP1]], i64 48388) ] +// CHECK-BOTHAUTH-NEXT: [[TMP4:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[TMP3]]) [ "ptrauth"(i64 2, i64 48388, i64 [[TMP1]]) ] // CHECK-BOTHAUTH-NEXT: [[TMP5:%.*]] = inttoptr i64 [[TMP4]] to ptr // CHECK-BOTHAUTH-NEXT: [[TMP6:%.*]] = load volatile i8, ptr [[TMP5]], align 8 // CHECK-BOTHAUTH-NEXT: ret ptr [[TMP5]] @@ -765,7 +765,7 @@ const void *e_as_D(E *o) { // CHECK-TYPEAUTH-NEXT: [[TMP0:%.*]] = load ptr, ptr [[AARRAY_ADDR]], align 8, !tbaa [[TBAA6]] // CHECK-TYPEAUTH-NEXT: [[VTABLE:%.*]] = load ptr, ptr [[TMP0]], align 8, !tbaa [[TBAA9]] // CHECK-TYPEAUTH-NEXT: [[TMP1:%.*]] = ptrtoint ptr [[VTABLE]] to i64 -// CHECK-TYPEAUTH-NEXT: [[TMP2:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[TMP1]]) [ "ptrauth"(i64 2, i64 48388) ] +// CHECK-TYPEAUTH-NEXT: [[TMP2:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[TMP1]]) [ "ptrauth"(i64 2, i64 48388, i64 0) ] // CHECK-TYPEAUTH-NEXT: [[TMP3:%.*]] = inttoptr i64 [[TMP2]] to ptr // CHECK-TYPEAUTH-NEXT: [[TMP4:%.*]] = load volatile i8, ptr [[TMP3]], align 8 // CHECK-TYPEAUTH-NEXT: ret ptr [[TMP3]] @@ -779,7 +779,7 @@ const void *e_as_D(E *o) { // CHECK-ADDRESSAUTH-NEXT: [[VTABLE:%.*]] = load ptr, ptr [[TMP0]], align 8, !tbaa [[TBAA9]] // CHECK-ADDRESSAUTH-NEXT: [[TMP1:%.*]] = ptrtoint ptr [[TMP0]] to i64 // CHECK-ADDRESSAUTH-NEXT: [[TMP2:%.*]] = ptrtoint ptr [[VTABLE]] to i64 -// CHECK-ADDRESSAUTH-NEXT: [[TMP3:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[TMP2]]) [ "ptrauth"(i64 2, i64 [[TMP1]]) ] +// CHECK-ADDRESSAUTH-NEXT: [[TMP3:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[TMP2]]) [ "ptrauth"(i64 2, i64 0, i64 [[TMP1]]) ] // CHECK-ADDRESSAUTH-NEXT: [[TMP4:%.*]] = inttoptr i64 [[TMP3]] to ptr // CHECK-ADDRESSAUTH-NEXT: [[TMP5:%.*]] = load volatile i8, ptr [[TMP4]], align 8 // CHECK-ADDRESSAUTH-NEXT: ret ptr [[TMP4]] @@ -793,7 +793,7 @@ const void *e_as_D(E *o) { // CHECK-BOTHAUTH-NEXT: [[VTABLE:%.*]] = load ptr, ptr [[TMP0]], align 8, !tbaa [[TBAA9]] // CHECK-BOTHAUTH-NEXT: [[TMP1:%.*]] = ptrtoint ptr [[TMP0]] to i64 // CHECK-BOTHAUTH-NEXT: [[TMP3:%.*]] = ptrtoint ptr [[VTABLE]] to i64 -// CHECK-BOTHAUTH-NEXT: [[TMP4:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[TMP3]]) [ "ptrauth"(i64 2, i64 [[TMP1]], i64 48388) ] +// CHECK-BOTHAUTH-NEXT: [[TMP4:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[TMP3]]) [ "ptrauth"(i64 2, i64 48388, i64 [[TMP1]]) ] // CHECK-BOTHAUTH-NEXT: [[TMP5:%.*]] = inttoptr i64 [[TMP4]] to ptr // CHECK-BOTHAUTH-NEXT: [[TMP6:%.*]] = load volatile i8, ptr [[TMP5]], align 8 // CHECK-BOTHAUTH-NEXT: ret ptr [[TMP5]] @@ -823,7 +823,7 @@ extern "C" const void *aArrayParameter(A aArray[]) { // CHECK-TYPEAUTH-NEXT: [[ARRAYDECAY:%.*]] = getelementptr inbounds [1 x %"struct.test1::A"], ptr [[ARRAY]], i64 0, i64 0 // CHECK-TYPEAUTH-NEXT: [[VTABLE:%.*]] = load ptr, ptr [[ARRAYDECAY]], align 8, !tbaa [[TBAA9]] // CHECK-TYPEAUTH-NEXT: [[TMP0:%.*]] = ptrtoint ptr [[VTABLE]] to i64 -// CHECK-TYPEAUTH-NEXT: [[TMP1:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[TMP0]]) [ "ptrauth"(i64 2, i64 48388) ] +// CHECK-TYPEAUTH-NEXT: [[TMP1:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[TMP0]]) [ "ptrauth"(i64 2, i64 48388, i64 0) ] // CHECK-TYPEAUTH-NEXT: [[TMP2:%.*]] = inttoptr i64 [[TMP1]] to ptr // CHECK-TYPEAUTH-NEXT: [[TMP3:%.*]] = load volatile i8, ptr [[TMP2]], align 8 // CHECK-TYPEAUTH-NEXT: call void @llvm.lifetime.end.p0(ptr [[ARRAY]]) #[[ATTR7]] @@ -839,7 +839,7 @@ extern "C" const void *aArrayParameter(A aArray[]) { // CHECK-ADDRESSAUTH-NEXT: [[VTABLE:%.*]] = load ptr, ptr [[ARRAYDECAY]], align 8, !tbaa [[TBAA9]] // CHECK-ADDRESSAUTH-NEXT: [[TMP0:%.*]] = ptrtoint ptr [[ARRAYDECAY]] to i64 // CHECK-ADDRESSAUTH-NEXT: [[TMP1:%.*]] = ptrtoint ptr [[VTABLE]] to i64 -// CHECK-ADDRESSAUTH-NEXT: [[TMP2:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[TMP1]]) [ "ptrauth"(i64 2, i64 [[TMP0]]) ] +// CHECK-ADDRESSAUTH-NEXT: [[TMP2:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[TMP1]]) [ "ptrauth"(i64 2, i64 0, i64 [[TMP0]]) ] // CHECK-ADDRESSAUTH-NEXT: [[TMP3:%.*]] = inttoptr i64 [[TMP2]] to ptr // CHECK-ADDRESSAUTH-NEXT: [[TMP4:%.*]] = load volatile i8, ptr [[TMP3]], align 8 // CHECK-ADDRESSAUTH-NEXT: call void @llvm.lifetime.end.p0(ptr [[ARRAY]]) #[[ATTR7]] @@ -855,7 +855,7 @@ extern "C" const void *aArrayParameter(A aArray[]) { // CHECK-BOTHAUTH-NEXT: [[VTABLE:%.*]] = load ptr, ptr [[ARRAYDECAY]], align 8, !tbaa [[TBAA9]] // CHECK-BOTHAUTH-NEXT: [[TMP0:%.*]] = ptrtoint ptr [[ARRAYDECAY]] to i64 // CHECK-BOTHAUTH-NEXT: [[TMP2:%.*]] = ptrtoint ptr [[VTABLE]] to i64 -// CHECK-BOTHAUTH-NEXT: [[TMP3:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[TMP2]]) [ "ptrauth"(i64 2, i64 [[TMP0]], i64 48388) ] +// CHECK-BOTHAUTH-NEXT: [[TMP3:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[TMP2]]) [ "ptrauth"(i64 2, i64 48388, i64 [[TMP0]]) ] // CHECK-BOTHAUTH-NEXT: [[TMP4:%.*]] = inttoptr i64 [[TMP3]] to ptr // CHECK-BOTHAUTH-NEXT: [[TMP5:%.*]] = load volatile i8, ptr [[TMP4]], align 8 // CHECK-BOTHAUTH-NEXT: call void @llvm.lifetime.end.p0(ptr [[ARRAY]]) #[[ATTR7]] @@ -1004,7 +1004,7 @@ extern "C" const void *aArrayLocal() { // CHECK-TYPEAUTH: [[CAST_NOTNULL9]]: // CHECK-TYPEAUTH-NEXT: [[VTABLE:%.*]] = load ptr, ptr [[DINSTANCE]], align 8, !tbaa [[TBAA9]] // CHECK-TYPEAUTH-NEXT: [[TMP2:%.*]] = ptrtoint ptr [[VTABLE]] to i64 -// CHECK-TYPEAUTH-NEXT: [[TMP3:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[TMP2]]) [ "ptrauth"(i64 2, i64 48388) ] +// CHECK-TYPEAUTH-NEXT: [[TMP3:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[TMP2]]) [ "ptrauth"(i64 2, i64 48388, i64 0) ] // CHECK-TYPEAUTH-NEXT: [[TMP4:%.*]] = inttoptr i64 [[TMP3]] to ptr // CHECK-TYPEAUTH-NEXT: [[VBASE_OFFSET_PTR:%.*]] = getelementptr i8, ptr [[TMP4]], i64 -32 // CHECK-TYPEAUTH-NEXT: [[VBASE_OFFSET:%.*]] = load i64, ptr [[VBASE_OFFSET_PTR]], align 8 @@ -1018,7 +1018,7 @@ extern "C" const void *aArrayLocal() { // CHECK-TYPEAUTH: [[CAST_NOTNULL14]]: // CHECK-TYPEAUTH-NEXT: [[VTABLE15:%.*]] = load ptr, ptr [[EINSTANCE]], align 8, !tbaa [[TBAA9]] // CHECK-TYPEAUTH-NEXT: [[TMP6:%.*]] = ptrtoint ptr [[VTABLE15]] to i64 -// CHECK-TYPEAUTH-NEXT: [[TMP7:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[TMP6]]) [ "ptrauth"(i64 2, i64 48388) ] +// CHECK-TYPEAUTH-NEXT: [[TMP7:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[TMP6]]) [ "ptrauth"(i64 2, i64 48388, i64 0) ] // CHECK-TYPEAUTH-NEXT: [[TMP8:%.*]] = inttoptr i64 [[TMP7]] to ptr // CHECK-TYPEAUTH-NEXT: [[VBASE_OFFSET_PTR16:%.*]] = getelementptr i8, ptr [[TMP8]], i64 -32 // CHECK-TYPEAUTH-NEXT: [[VBASE_OFFSET17:%.*]] = load i64, ptr [[VBASE_OFFSET_PTR16]], align 8 @@ -1066,7 +1066,7 @@ extern "C" const void *aArrayLocal() { // CHECK-TYPEAUTH-NEXT: [[ARRAYDECAY:%.*]] = getelementptr inbounds [1 x %"struct.test1::E"], ptr [[EARRAY]], i64 0, i64 0 // CHECK-TYPEAUTH-NEXT: [[VTABLE49:%.*]] = load ptr, ptr [[ARRAYDECAY]], align 8, !tbaa [[TBAA9]] // CHECK-TYPEAUTH-NEXT: [[TMP12:%.*]] = ptrtoint ptr [[VTABLE49]] to i64 -// CHECK-TYPEAUTH-NEXT: [[TMP13:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[TMP12]]) [ "ptrauth"(i64 2, i64 48388) ] +// CHECK-TYPEAUTH-NEXT: [[TMP13:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[TMP12]]) [ "ptrauth"(i64 2, i64 48388, i64 0) ] // CHECK-TYPEAUTH-NEXT: [[TMP14:%.*]] = inttoptr i64 [[TMP13]] to ptr // CHECK-TYPEAUTH-NEXT: [[TMP15:%.*]] = load volatile i8, ptr [[TMP14]], align 8 // CHECK-TYPEAUTH-NEXT: call void @llvm.lifetime.end.p0(ptr [[EARRAY]]) #[[ATTR7]] @@ -1115,7 +1115,7 @@ extern "C" const void *aArrayLocal() { // CHECK-ADDRESSAUTH-NEXT: [[VTABLE:%.*]] = load ptr, ptr [[DINSTANCE]], align 8, !tbaa [[TBAA9]] // CHECK-ADDRESSAUTH-NEXT: [[TMP2:%.*]] = ptrtoint ptr [[DINSTANCE]] to i64 // CHECK-ADDRESSAUTH-NEXT: [[TMP3:%.*]] = ptrtoint ptr [[VTABLE]] to i64 -// CHECK-ADDRESSAUTH-NEXT: [[TMP4:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[TMP3]]) [ "ptrauth"(i64 2, i64 [[TMP2]]) ] +// CHECK-ADDRESSAUTH-NEXT: [[TMP4:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[TMP3]]) [ "ptrauth"(i64 2, i64 0, i64 [[TMP2]]) ] // CHECK-ADDRESSAUTH-NEXT: [[TMP5:%.*]] = inttoptr i64 [[TMP4]] to ptr // CHECK-ADDRESSAUTH-NEXT: [[VBASE_OFFSET_PTR:%.*]] = getelementptr i8, ptr [[TMP5]], i64 -32 // CHECK-ADDRESSAUTH-NEXT: [[VBASE_OFFSET:%.*]] = load i64, ptr [[VBASE_OFFSET_PTR]], align 8 @@ -1130,7 +1130,7 @@ extern "C" const void *aArrayLocal() { // CHECK-ADDRESSAUTH-NEXT: [[VTABLE15:%.*]] = load ptr, ptr [[EINSTANCE]], align 8, !tbaa [[TBAA9]] // CHECK-ADDRESSAUTH-NEXT: [[TMP7:%.*]] = ptrtoint ptr [[EINSTANCE]] to i64 // CHECK-ADDRESSAUTH-NEXT: [[TMP8:%.*]] = ptrtoint ptr [[VTABLE15]] to i64 -// CHECK-ADDRESSAUTH-NEXT: [[TMP9:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[TMP8]]) [ "ptrauth"(i64 2, i64 [[TMP7]]) ] +// CHECK-ADDRESSAUTH-NEXT: [[TMP9:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[TMP8]]) [ "ptrauth"(i64 2, i64 0, i64 [[TMP7]]) ] // CHECK-ADDRESSAUTH-NEXT: [[TMP10:%.*]] = inttoptr i64 [[TMP9]] to ptr // CHECK-ADDRESSAUTH-NEXT: [[VBASE_OFFSET_PTR16:%.*]] = getelementptr i8, ptr [[TMP10]], i64 -32 // CHECK-ADDRESSAUTH-NEXT: [[VBASE_OFFSET17:%.*]] = load i64, ptr [[VBASE_OFFSET_PTR16]], align 8 @@ -1179,7 +1179,7 @@ extern "C" const void *aArrayLocal() { // CHECK-ADDRESSAUTH-NEXT: [[VTABLE49:%.*]] = load ptr, ptr [[ARRAYDECAY]], align 8, !tbaa [[TBAA9]] // CHECK-ADDRESSAUTH-NEXT: [[TMP14:%.*]] = ptrtoint ptr [[ARRAYDECAY]] to i64 // CHECK-ADDRESSAUTH-NEXT: [[TMP15:%.*]] = ptrtoint ptr [[VTABLE49]] to i64 -// CHECK-ADDRESSAUTH-NEXT: [[TMP16:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[TMP15]]) [ "ptrauth"(i64 2, i64 [[TMP14]]) ] +// CHECK-ADDRESSAUTH-NEXT: [[TMP16:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[TMP15]]) [ "ptrauth"(i64 2, i64 0, i64 [[TMP14]]) ] // CHECK-ADDRESSAUTH-NEXT: [[TMP17:%.*]] = inttoptr i64 [[TMP16]] to ptr // CHECK-ADDRESSAUTH-NEXT: [[TMP18:%.*]] = load volatile i8, ptr [[TMP17]], align 8 // CHECK-ADDRESSAUTH-NEXT: call void @llvm.lifetime.end.p0(ptr [[EARRAY]]) #[[ATTR7]] @@ -1228,7 +1228,7 @@ extern "C" const void *aArrayLocal() { // CHECK-BOTHAUTH-NEXT: [[VTABLE:%.*]] = load ptr, ptr [[DINSTANCE]], align 8, !tbaa [[TBAA9]] // CHECK-BOTHAUTH-NEXT: [[TMP2:%.*]] = ptrtoint ptr [[DINSTANCE]] to i64 // CHECK-BOTHAUTH-NEXT: [[TMP4:%.*]] = ptrtoint ptr [[VTABLE]] to i64 -// CHECK-BOTHAUTH-NEXT: [[TMP5:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[TMP4]]) [ "ptrauth"(i64 2, i64 [[TMP2]], i64 48388) ] +// CHECK-BOTHAUTH-NEXT: [[TMP5:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[TMP4]]) [ "ptrauth"(i64 2, i64 48388, i64 [[TMP2]]) ] // CHECK-BOTHAUTH-NEXT: [[TMP6:%.*]] = inttoptr i64 [[TMP5]] to ptr // CHECK-BOTHAUTH-NEXT: [[VBASE_OFFSET_PTR:%.*]] = getelementptr i8, ptr [[TMP6]], i64 -32 // CHECK-BOTHAUTH-NEXT: [[VBASE_OFFSET:%.*]] = load i64, ptr [[VBASE_OFFSET_PTR]], align 8 @@ -1243,7 +1243,7 @@ extern "C" const void *aArrayLocal() { // CHECK-BOTHAUTH-NEXT: [[VTABLE15:%.*]] = load ptr, ptr [[EINSTANCE]], align 8, !tbaa [[TBAA9]] // CHECK-BOTHAUTH-NEXT: [[TMP8:%.*]] = ptrtoint ptr [[EINSTANCE]] to i64 // CHECK-BOTHAUTH-NEXT: [[TMP10:%.*]] = ptrtoint ptr [[VTABLE15]] to i64 -// CHECK-BOTHAUTH-NEXT: [[TMP11:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[TMP10]]) [ "ptrauth"(i64 2, i64 [[TMP8]], i64 48388) ] +// CHECK-BOTHAUTH-NEXT: [[TMP11:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[TMP10]]) [ "ptrauth"(i64 2, i64 48388, i64 [[TMP8]]) ] // CHECK-BOTHAUTH-NEXT: [[TMP12:%.*]] = inttoptr i64 [[TMP11]] to ptr // CHECK-BOTHAUTH-NEXT: [[VBASE_OFFSET_PTR16:%.*]] = getelementptr i8, ptr [[TMP12]], i64 -32 // CHECK-BOTHAUTH-NEXT: [[VBASE_OFFSET17:%.*]] = load i64, ptr [[VBASE_OFFSET_PTR16]], align 8 @@ -1292,7 +1292,7 @@ extern "C" const void *aArrayLocal() { // CHECK-BOTHAUTH-NEXT: [[VTABLE49:%.*]] = load ptr, ptr [[ARRAYDECAY]], align 8, !tbaa [[TBAA9]] // CHECK-BOTHAUTH-NEXT: [[TMP16:%.*]] = ptrtoint ptr [[ARRAYDECAY]] to i64 // CHECK-BOTHAUTH-NEXT: [[TMP18:%.*]] = ptrtoint ptr [[VTABLE49]] to i64 -// CHECK-BOTHAUTH-NEXT: [[TMP19:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[TMP18]]) [ "ptrauth"(i64 2, i64 [[TMP16]], i64 48388) ] +// CHECK-BOTHAUTH-NEXT: [[TMP19:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[TMP18]]) [ "ptrauth"(i64 2, i64 48388, i64 [[TMP16]]) ] // CHECK-BOTHAUTH-NEXT: [[TMP20:%.*]] = inttoptr i64 [[TMP19]] to ptr // CHECK-BOTHAUTH-NEXT: [[TMP21:%.*]] = load volatile i8, ptr [[TMP20]], align 8 // CHECK-BOTHAUTH-NEXT: call void @llvm.lifetime.end.p0(ptr [[EARRAY]]) #[[ATTR7]] diff --git a/clang/test/CodeGenCXX/ptrauth-apple-kext-indirect-call-2.cpp b/clang/test/CodeGenCXX/ptrauth-apple-kext-indirect-call-2.cpp index c80c6d09b658f..7a4aa1ba08f85 100644 --- a/clang/test/CodeGenCXX/ptrauth-apple-kext-indirect-call-2.cpp +++ b/clang/test/CodeGenCXX/ptrauth-apple-kext-indirect-call-2.cpp @@ -19,7 +19,7 @@ void B::VF() {} void FUNC(B* p) { // CHECK: [[T1:%.*]] = load ptr, ptr getelementptr inbounds (ptr, ptr @_ZTV1A, i64 2) -// CHECK-NEXT: [[T2:%.*]] = call noundef ptr [[T1]](ptr noundef {{.*}}) [ "ptrauth"(i64 0, i64 ptrtoint (ptr getelementptr inbounds (ptr, ptr @_ZTV1A, i64 2) to i64), i64 12401) ] +// CHECK-NEXT: [[T2:%.*]] = call noundef ptr [[T1]](ptr noundef {{.*}}) [ "ptrauth"(i64 0, i64 12401, i64 ptrtoint (ptr getelementptr inbounds (ptr, ptr @_ZTV1A, i64 2) to i64)) ] const char* c = p->A::abc(); } @@ -34,7 +34,7 @@ struct Derived : public Base { void FUNC1(Derived* p) { // CHECK: [[U1:%.*]] = load ptr, ptr getelementptr inbounds (ptr, ptr @_ZTV4Base, i64 2) -// CHECK-NEXT: [[U2:%.*]] = call noundef ptr [[U1]](ptr noundef {{.*}}) [ "ptrauth"(i64 0, i64 ptrtoint (ptr getelementptr inbounds (ptr, ptr @_ZTV4Base, i64 2) to i64), i64 64320) ] +// CHECK-NEXT: [[U2:%.*]] = call noundef ptr [[U1]](ptr noundef {{.*}}) [ "ptrauth"(i64 0, i64 64320, i64 ptrtoint (ptr getelementptr inbounds (ptr, ptr @_ZTV4Base, i64 2) to i64)) ] char* c = p->Base::abc(); } @@ -50,7 +50,7 @@ char* Derived2::efg(void) const { return 0; } void FUNC2(Derived2* p) { // CHECK: [[V1:%.*]] = load ptr, ptr getelementptr inbounds (ptr, ptr @_ZTV8Derived2, i64 3) -// CHECK-NEXT: [[V2:%.*]] = call noundef ptr [[V1]](ptr noundef {{.*}}) [ "ptrauth"(i64 0, i64 ptrtoint (ptr getelementptr inbounds (ptr, ptr @_ZTV8Derived2, i64 3) to i64), i64 36603) ] +// CHECK-NEXT: [[V2:%.*]] = call noundef ptr [[V1]](ptr noundef {{.*}}) [ "ptrauth"(i64 0, i64 36603, i64 ptrtoint (ptr getelementptr inbounds (ptr, ptr @_ZTV8Derived2, i64 3) to i64)) ] char* c = p->Derived2::efg(); } @@ -71,7 +71,7 @@ char* D2::abc(void) const { return 0; } void FUNC3(Sub* p) { // CHECK: [[W1:%.*]] = load ptr, ptr getelementptr inbounds (ptr, ptr @_ZTV2D2, i64 3) -// CHECK-NEXT: [[W2:%.*]] = call noundef ptr [[W1]](ptr noundef {{.*}}) [ "ptrauth"(i64 0, i64 ptrtoint (ptr getelementptr inbounds (ptr, ptr @_ZTV2D2, i64 3) to i64), i64 20222) ] +// CHECK-NEXT: [[W2:%.*]] = call noundef ptr [[W1]](ptr noundef {{.*}}) [ "ptrauth"(i64 0, i64 20222, i64 ptrtoint (ptr getelementptr inbounds (ptr, ptr @_ZTV2D2, i64 3) to i64)) ] char* c = p->D2::abc(); } @@ -90,11 +90,11 @@ void Derived4::abc() {} void FUNC4(Derived4* p) { // CHECK: %[[VTABLE:[a-z]+]] = load ptr, ptr %{{.*}} // CHECK: %[[T0:[0-9]+]] = ptrtoint ptr %[[VTABLE]] to i64 -// CHECK: %[[T3:[0-9]+]] = call i64 @llvm.ptrauth.auth(i64 %[[T0]]) [ "ptrauth"(i64 2, i64 0) ] +// CHECK: %[[T3:[0-9]+]] = call i64 @llvm.ptrauth.auth(i64 %[[T0]]) [ "ptrauth"(i64 2, i64 0, i64 0) ] // CHECK: %[[T4:[0-9]+]] = inttoptr i64 %[[T3]] to ptr // CHECK: %[[VFN:[a-z]+]] = getelementptr inbounds ptr, ptr %[[T4]], i64 0 // CHECK: %[[T5:[0-9]+]] = load ptr, ptr %[[VFN]] // CHECK: %[[T6:[0-9]+]] = ptrtoint ptr %[[VFN]] to i64 -// CHECK: call void %[[T5]](ptr noundef nonnull align {{[0-9]+}} dereferenceable(8) %{{.*}}) [ "ptrauth"(i64 0, i64 %[[T6]], i64 426) ] +// CHECK: call void %[[T5]](ptr noundef nonnull align {{[0-9]+}} dereferenceable(8) %{{.*}}) [ "ptrauth"(i64 0, i64 426, i64 %[[T6]]) ] p->abc(); } diff --git a/clang/test/CodeGenCXX/ptrauth-apple-kext-indirect-virtual-dtor-call.cpp b/clang/test/CodeGenCXX/ptrauth-apple-kext-indirect-virtual-dtor-call.cpp index e6dc379ded44b..dcb1df0059fa0 100644 --- a/clang/test/CodeGenCXX/ptrauth-apple-kext-indirect-virtual-dtor-call.cpp +++ b/clang/test/CodeGenCXX/ptrauth-apple-kext-indirect-virtual-dtor-call.cpp @@ -13,10 +13,10 @@ void DELETE(B1 *pb1) { } // CHECK-LABEL: define void @_ZN2B1D0Ev // CHECK: [[T1:%.*]] = load ptr, ptr getelementptr inbounds (ptr, ptr @_ZTV2B1, i64 2) -// CHECK-NEXT: call noundef ptr [[T1]](ptr noundef nonnull align 8 dereferenceable(8) [[T2:%.*]]) [ "ptrauth"(i64 0, i64 ptrtoint (ptr getelementptr inbounds (ptr, ptr @_ZTV2B1, i64 2) to i64), i64 14635) ] +// CHECK-NEXT: call noundef ptr [[T1]](ptr noundef nonnull align 8 dereferenceable(8) [[T2:%.*]]) [ "ptrauth"(i64 0, i64 14635, i64 ptrtoint (ptr getelementptr inbounds (ptr, ptr @_ZTV2B1, i64 2) to i64)) ] // CHECK-LABEL: define void @_Z6DELETEP2B1 // CHECK: [[T3:%.*]] = load ptr, ptr getelementptr inbounds (ptr, ptr @_ZTV2B1, i64 2) -// CHECK-NEXT: call noundef ptr [[T3]](ptr noundef nonnull align 8 dereferenceable(8) [[T4:%.*]]) [ "ptrauth"(i64 0, i64 ptrtoint (ptr getelementptr inbounds (ptr, ptr @_ZTV2B1, i64 2) to i64), i64 14635) +// CHECK-NEXT: call noundef ptr [[T3]](ptr noundef nonnull align 8 dereferenceable(8) [[T4:%.*]]) [ "ptrauth"(i64 0, i64 14635, i64 ptrtoint (ptr getelementptr inbounds (ptr, ptr @_ZTV2B1, i64 2) to i64)) template struct Templ { diff --git a/clang/test/CodeGenCXX/ptrauth-dynamic-cast-exact.cpp b/clang/test/CodeGenCXX/ptrauth-dynamic-cast-exact.cpp index 5fbd308b080d8..9b7b1eabde6ad 100644 --- a/clang/test/CodeGenCXX/ptrauth-dynamic-cast-exact.cpp +++ b/clang/test/CodeGenCXX/ptrauth-dynamic-cast-exact.cpp @@ -48,7 +48,7 @@ C *exact_to_C(A *a) { // CHECK: [[UNAUTHED_VPTR:%.*]] = load ptr, ptr %a, align 8 // CHECK: [[VPTR_ADDRI:%.*]] = ptrtoint ptr %a to i64 // CHECK: [[UNAUTHED_VPTRI:%.*]] = ptrtoint ptr [[UNAUTHED_VPTR]] to i64 - // CHECK: [[AUTHED_VPTRI:%.*]] = tail call i64 @llvm.ptrauth.auth(i64 [[UNAUTHED_VPTRI]]) [ "ptrauth"(i64 2, i64 [[VPTR_ADDRI]], i64 62866) ] + // CHECK: [[AUTHED_VPTRI:%.*]] = tail call i64 @llvm.ptrauth.auth(i64 [[UNAUTHED_VPTRI]]) [ "ptrauth"(i64 2, i64 62866, i64 [[VPTR_ADDRI]]) ] // CHECK: [[IS_EXPECTED:%.*]] = icmp eq i64 [[AUTHED_VPTRI]], ptrtoint (ptr getelementptr inbounds nuw inrange(-16, 24) (i8, ptr @_ZTV1C, i64 16) to i64) // CHECK: br i1 [[IS_EXPECTED]], label %dynamic_cast.end, label %dynamic_cast.null // CHECK: [[NULL_CHECKED_RESULT:%.*]] = phi ptr [ %a, %dynamic_cast.notnull ], [ null, %dynamic_cast.null ] @@ -62,7 +62,7 @@ D *exact_t_D(A *a) { // CHECK: [[SRC_UNAUTHED_VPTR:%.*]] = load ptr, ptr %a // CHECK: [[SRC_VPTR_ADDRI:%.*]] = ptrtoint ptr %a to i64 // CHECK: [[SRC_UNAUTHED_VPTRI:%.*]] = ptrtoint ptr [[SRC_UNAUTHED_VPTR]] to i64 - // CHECK: [[SRC_AUTHED_VPTRI:%.*]] = tail call i64 @llvm.ptrauth.auth(i64 [[SRC_UNAUTHED_VPTRI]]) [ "ptrauth"(i64 2, i64 [[SRC_VPTR_ADDRI]], i64 62866) ] + // CHECK: [[SRC_AUTHED_VPTRI:%.*]] = tail call i64 @llvm.ptrauth.auth(i64 [[SRC_UNAUTHED_VPTRI]]) [ "ptrauth"(i64 2, i64 62866, i64 [[SRC_VPTR_ADDRI]]) ] // CHECK: [[SUCCESS:%.*]] = icmp eq i64 [[SRC_AUTHED_VPTRI]], ptrtoint (ptr getelementptr inbounds nuw inrange(-16, 16) (i8, ptr @_ZTV1D, i64 56) to i64) // CHECK: br i1 [[SUCCESS]], label %dynamic_cast.postauth.success, label %dynamic_cast.postauth.complete // CHECK: dynamic_cast.postauth.success: @@ -70,7 +70,7 @@ D *exact_t_D(A *a) { // CHECK: [[ADJUSTED_UNAUTHED_VPTR:%.*]] = load ptr, ptr [[ADJUSTED_THIS]] // CHECK: [[ADJUSTED_VPTR_ADDRI:%.*]] = ptrtoint ptr [[ADJUSTED_THIS]] to i64 // CHECK: [[ADJUSTED_UNAUTHED_VPTRI:%.*]] = ptrtoint ptr [[ADJUSTED_UNAUTHED_VPTR]] to i64 - // CHECK: [[ADJUSTED_AUTHED_VPTRI:%.*]] = tail call i64 @llvm.ptrauth.auth(i64 [[ADJUSTED_UNAUTHED_VPTRI]]) [ "ptrauth"(i64 2, i64 [[ADJUSTED_VPTR_ADDRI]], i64 28965) ] + // CHECK: [[ADJUSTED_AUTHED_VPTRI:%.*]] = tail call i64 @llvm.ptrauth.auth(i64 [[ADJUSTED_UNAUTHED_VPTRI]]) [ "ptrauth"(i64 2, i64 28965, i64 [[ADJUSTED_VPTR_ADDRI]]) ] // CHECK: [[ADJUSTED_AUTHED_VPTR:%.*]] = inttoptr i64 [[ADJUSTED_AUTHED_VPTRI]] to ptr // CHECK: br label %dynamic_cast.postauth.complete // CHECK: dynamic_cast.postauth.complete: @@ -90,7 +90,7 @@ L *exact_multi(E *e) { // CHECK: [[VTABLE_ADDR:%.*]] = load ptr, ptr %e, align 8 // CHECK: [[THIS_ADDRI:%.*]] = ptrtoint ptr %e to i64 // CHECK: [[VTABLE_ADDRI:%.*]] = ptrtoint ptr [[VTABLE_ADDR]] to i64 - // CHECK: [[AUTHED_VTABLEI:%.*]] = tail call i64 @llvm.ptrauth.auth(i64 [[VTABLE_ADDRI]]) [ "ptrauth"(i64 2, i64 [[THIS_ADDRI]], i64 12810) ] + // CHECK: [[AUTHED_VTABLEI:%.*]] = tail call i64 @llvm.ptrauth.auth(i64 [[VTABLE_ADDRI]]) [ "ptrauth"(i64 2, i64 12810, i64 [[THIS_ADDRI]]) ] // CHECK: [[AUTHED_VTABLE:%.*]] = inttoptr i64 [[AUTHED_VTABLEI]] to ptr // CHECK: [[PRIMARY_BASE_OFFSET:%.*]] = getelementptr inbounds i8, ptr [[AUTHED_VTABLE]], i64 -16 // CHECK: %offset.to.top = load i64, ptr [[PRIMARY_BASE_OFFSET]] @@ -102,7 +102,7 @@ L *exact_multi(E *e) { // CHECK: br i1 [[SUCCESS]], label %dynamic_cast.postauth.success, label %dynamic_cast.postauth.complete // CHECK: dynamic_cast.postauth.success: // CHECK: [[ADJUSTED_THISI:%.*]] = ptrtoint ptr [[ADJUSTED_THIS]] to i64 - // CHECK: tail call i64 @llvm.ptrauth.auth(i64 [[ADJUSTED_THIS_VTABLEI]]) [ "ptrauth"(i64 2, i64 [[ADJUSTED_THISI]], i64 41434) ] + // CHECK: tail call i64 @llvm.ptrauth.auth(i64 [[ADJUSTED_THIS_VTABLEI]]) [ "ptrauth"(i64 2, i64 41434, i64 [[ADJUSTED_THISI]]) ] // CHECK: br label %dynamic_cast.postauth.complete // CHECK: dynamic_cast.postauth.complete: // CHECK: [[AUTHED_ADJUSTED_THIS:%.*]] = phi ptr [ [[ADJUSTED_THIS]], %dynamic_cast.postauth.success ], [ null, %dynamic_cast.notnull ] diff --git a/clang/test/CodeGenCXX/ptrauth-explicit-vtable-pointer-control.cpp b/clang/test/CodeGenCXX/ptrauth-explicit-vtable-pointer-control.cpp index 824c23327b6e9..7f9aaf6e4b1d4 100644 --- a/clang/test/CodeGenCXX/ptrauth-explicit-vtable-pointer-control.cpp +++ b/clang/test/CodeGenCXX/ptrauth-explicit-vtable-pointer-control.cpp @@ -153,18 +153,18 @@ int TVDisc_ExplicitTypeDiscrimination = ptrauth_string_discriminator("_ZTVN5test // CHECK: [[VTABLE:%.*]] = load ptr, ptr [[VTADDR]], align 8 // // NODISC: [[VTABLEI64:%.*]] = ptrtoint ptr [[VTABLE]] to i64 -// NODISC: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VTABLEI64]]) [ "ptrauth"(i64 2, i64 0) ] +// NODISC: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VTABLEI64]]) [ "ptrauth"(i64 2, i64 0, i64 0) ] // // TYPE: [[VTABLEI64:%.*]] = ptrtoint ptr [[VTABLE]] to i64 -// TYPE: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VTABLEI64]]) [ "ptrauth"(i64 2, i64 [[DISC_DEFAULT]]) ] +// TYPE: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VTABLEI64]]) [ "ptrauth"(i64 2, i64 [[DISC_DEFAULT]], i64 0) ] // // ADDR: [[VTADDRI64:%.*]] = ptrtoint ptr [[VTADDR]] to i64 // ADDR: [[VTABLEI64:%.*]] = ptrtoint ptr [[VTABLE]] to i64 -// ADDR: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VTABLEI64]]) [ "ptrauth"(i64 2, i64 [[VTADDRI64]]) ] +// ADDR: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VTABLEI64]]) [ "ptrauth"(i64 2, i64 0, i64 [[VTADDRI64]]) ] // // BOTH: [[VTADDRI64:%.*]] = ptrtoint ptr [[VTADDR]] to i64 // BOTH: [[VTABLEI64:%.*]] = ptrtoint ptr [[VTABLE]] to i64 -// BOTH: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VTABLEI64]]) [ "ptrauth"(i64 2, i64 [[VTADDRI64]], i64 [[DISC_DEFAULT]]) ] +// BOTH: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VTABLEI64]]) [ "ptrauth"(i64 2, i64 [[DISC_DEFAULT]], i64 [[VTADDRI64]]) ] void test_default(NoExplicitAuth *a) { a->f(); } @@ -183,19 +183,19 @@ void test_disabled(ExplicitlyDisableAuth *a) { // // NODISC: [[VTADDRI64:%.*]] = ptrtoint ptr [[VTADDR]] to i64 // NODISC: [[VTABLEI64:%.*]] = ptrtoint ptr [[VTABLE]] to i64 -// NODISC: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VTABLEI64]]) [ "ptrauth"(i64 2, i64 [[VTADDRI64]]) ] +// NODISC: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VTABLEI64]]) [ "ptrauth"(i64 2, i64 0, i64 [[VTADDRI64]]) ] // // TYPE: [[VTADDRI64:%.*]] = ptrtoint ptr [[VTADDR]] to i64 // TYPE: [[VTABLEI64:%.*]] = ptrtoint ptr [[VTABLE]] to i64 -// TYPE: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VTABLEI64]]) [ "ptrauth"(i64 2, i64 [[VTADDRI64]], i64 [[DISC_ADDR]]) ] +// TYPE: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VTABLEI64]]) [ "ptrauth"(i64 2, i64 [[DISC_ADDR]], i64 [[VTADDRI64]]) ] // // ADDR: [[VTADDRI64:%.*]] = ptrtoint ptr [[VTADDR]] to i64 // ADDR: [[VTABLEI64:%.*]] = ptrtoint ptr [[VTABLE]] to i64 -// ADDR: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VTABLEI64]]) [ "ptrauth"(i64 2, i64 [[VTADDRI64]]) ] +// ADDR: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VTABLEI64]]) [ "ptrauth"(i64 2, i64 0, i64 [[VTADDRI64]]) ] // // BOTH: [[VTADDRI64:%.*]] = ptrtoint ptr [[VTADDR]] to i64 // BOTH: [[VTABLEI64:%.*]] = ptrtoint ptr [[VTABLE]] to i64 -// BOTH: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VTABLEI64]]) [ "ptrauth"(i64 2, i64 [[VTADDRI64]], i64 [[DISC_ADDR]]) ] +// BOTH: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VTABLEI64]]) [ "ptrauth"(i64 2, i64 [[DISC_ADDR]], i64 [[VTADDRI64]]) ] void test_addr_disc(ExplicitAddressDiscrimination *a) { a->f(); } @@ -205,16 +205,16 @@ void test_addr_disc(ExplicitAddressDiscrimination *a) { // CHECK: [[VTABLE:%.*]] = load ptr, ptr [[VTADDR]], align 8 // // NODISC: [[VTABLEI64:%.*]] = ptrtoint ptr [[VTABLE]] to i64 -// NODISC: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VTABLEI64]]) [ "ptrauth"(i64 2, i64 0) ] +// NODISC: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VTABLEI64]]) [ "ptrauth"(i64 2, i64 0, i64 0) ] // // TYPE: [[VTABLEI64:%.*]] = ptrtoint ptr [[VTABLE]] to i64 -// TYPE: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VTABLEI64]]) [ "ptrauth"(i64 2, i64 [[DISC_NO_ADDR]]) ] +// TYPE: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VTABLEI64]]) [ "ptrauth"(i64 2, i64 [[DISC_NO_ADDR]], i64 0) ] // // ADDR: [[VTABLEI64:%.*]] = ptrtoint ptr [[VTABLE]] to i64 -// ADDR: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VTABLEI64]]) [ "ptrauth"(i64 2, i64 0) ] +// ADDR: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VTABLEI64]]) [ "ptrauth"(i64 2, i64 0, i64 0) ] // // BOTH: [[VTABLEI64:%.*]] = ptrtoint ptr [[VTABLE]] to i64 -// BOTH: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VTABLEI64]]) [ "ptrauth"(i64 2, i64 [[DISC_NO_ADDR]]) ] +// BOTH: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VTABLEI64]]) [ "ptrauth"(i64 2, i64 [[DISC_NO_ADDR]], i64 0) ] void test_no_addr_disc(ExplicitNoAddressDiscrimination *a) { a->f(); } @@ -224,18 +224,18 @@ void test_no_addr_disc(ExplicitNoAddressDiscrimination *a) { // CHECK: [[VTABLE:%.*]] = load ptr, ptr [[VTADDR]], align 8 // // NODISC: [[VTABLEI64:%.*]] = ptrtoint ptr [[VTABLE]] to i64 -// NODISC: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VTABLEI64]]) [ "ptrauth"(i64 2, i64 0) ] +// NODISC: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VTABLEI64]]) [ "ptrauth"(i64 2, i64 0, i64 0) ] // // TYPE: [[VTABLEI64:%.*]] = ptrtoint ptr [[VTABLE]] to i64 -// TYPE: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VTABLEI64]]) [ "ptrauth"(i64 2, i64 0) ] +// TYPE: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VTABLEI64]]) [ "ptrauth"(i64 2, i64 0, i64 0) ] // // ADDR: [[VTADDRI64:%.*]] = ptrtoint ptr [[VTADDR]] to i64 // ADDR: [[VTABLEI64:%.*]] = ptrtoint ptr [[VTABLE]] to i64 -// ADDR: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VTABLEI64]]) [ "ptrauth"(i64 2, i64 [[VTADDRI64]]) ] +// ADDR: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VTABLEI64]]) [ "ptrauth"(i64 2, i64 0, i64 [[VTADDRI64]]) ] // // BOTH: [[VTADDRI64:%.*]] = ptrtoint ptr [[VTADDR]] to i64 // BOTH: [[VTABLEI64:%.*]] = ptrtoint ptr [[VTABLE]] to i64 -// BOTH: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VTABLEI64]]) [ "ptrauth"(i64 2, i64 [[VTADDRI64]]) ] +// BOTH: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VTABLEI64]]) [ "ptrauth"(i64 2, i64 0, i64 [[VTADDRI64]]) ] void test_no_extra_disc(ExplicitNoExtraDiscrimination *a) { a->f(); } @@ -245,18 +245,18 @@ void test_no_extra_disc(ExplicitNoExtraDiscrimination *a) { // CHECK: [[VTABLE:%.*]] = load ptr, ptr [[VTADDR]], align 8 // // NODISC: [[VTABLEI64:%.*]] = ptrtoint ptr [[VTABLE]] to i64 -// NODISC: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VTABLEI64]]) [ "ptrauth"(i64 2, i64 [[DISC_TYPE]]) ] +// NODISC: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VTABLEI64]]) [ "ptrauth"(i64 2, i64 [[DISC_TYPE]], i64 0) ] // // TYPE: [[VTABLEI64:%.*]] = ptrtoint ptr [[VTABLE]] to i64 -// TYPE: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VTABLEI64]]) [ "ptrauth"(i64 2, i64 [[DISC_TYPE]]) ] +// TYPE: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VTABLEI64]]) [ "ptrauth"(i64 2, i64 [[DISC_TYPE]], i64 0) ] // // ADDR: [[VTADDRI64:%.*]] = ptrtoint ptr [[VTADDR]] to i64 // ADDR: [[VTABLEI64:%.*]] = ptrtoint ptr [[VTABLE]] to i64 -// ADDR: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VTABLEI64]]) [ "ptrauth"(i64 2, i64 [[VTADDRI64]], i64 [[DISC_TYPE]]) ] +// ADDR: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VTABLEI64]]) [ "ptrauth"(i64 2, i64 [[DISC_TYPE]], i64 [[VTADDRI64]]) ] // // BOTH: [[VTADDRI64:%.*]] = ptrtoint ptr [[VTADDR]] to i64 // BOTH: [[VTABLEI64:%.*]] = ptrtoint ptr [[VTABLE]] to i64 -// BOTH: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VTABLEI64]]) [ "ptrauth"(i64 2, i64 [[VTADDRI64]], i64 [[DISC_TYPE]]) ] +// BOTH: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VTABLEI64]]) [ "ptrauth"(i64 2, i64 [[DISC_TYPE]], i64 [[VTADDRI64]]) ] void test_type_disc(ExplicitTypeDiscrimination *a) { a->f(); } @@ -266,18 +266,18 @@ void test_type_disc(ExplicitTypeDiscrimination *a) { // CHECK: [[VTABLE:%.*]] = load ptr, ptr [[VTADDR]], align 8 // // NODISC: [[VTABLEI64:%.*]] = ptrtoint ptr [[VTABLE]] to i64 -// NODISC: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VTABLEI64]]) [ "ptrauth"(i64 2, i64 42424) ] +// NODISC: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VTABLEI64]]) [ "ptrauth"(i64 2, i64 42424, i64 0) ] // // TYPE: [[VTABLEI64:%.*]] = ptrtoint ptr [[VTABLE]] to i64 -// TYPE: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VTABLEI64]]) [ "ptrauth"(i64 2, i64 42424) ] +// TYPE: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VTABLEI64]]) [ "ptrauth"(i64 2, i64 42424, i64 0) ] // // ADDR: [[VTADDRI64:%.*]] = ptrtoint ptr [[VTADDR]] to i64 // ADDR: [[VTABLEI64:%.*]] = ptrtoint ptr [[VTABLE]] to i64 -// ADDR: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VTABLEI64]]) [ "ptrauth"(i64 2, i64 [[VTADDRI64]], i64 42424) ] +// ADDR: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VTABLEI64]]) [ "ptrauth"(i64 2, i64 42424, i64 [[VTADDRI64]]) ] // // BOTH: [[VTADDRI64:%.*]] = ptrtoint ptr [[VTADDR]] to i64 // BOTH: [[VTABLEI64:%.*]] = ptrtoint ptr [[VTABLE]] to i64 -// BOTH: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VTABLEI64]]) [ "ptrauth"(i64 2, i64 [[VTADDRI64]], i64 42424) ] +// BOTH: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VTABLEI64]]) [ "ptrauth"(i64 2, i64 42424, i64 [[VTADDRI64]]) ] void test_custom_disc(ExplicitCustomDiscrimination *a) { a->f(); } @@ -292,18 +292,18 @@ void test_custom_disc(ExplicitCustomDiscrimination *a) { // CHECK: [[VTABLE:%.*]] = load ptr, ptr [[VTADDR]], align 8 // // NODISC: [[VTABLEI64:%.*]] = ptrtoint ptr [[VTABLE]] to i64 -// NODISC: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VTABLEI64]]) [ "ptrauth"(i64 2, i64 0) ] +// NODISC: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VTABLEI64]]) [ "ptrauth"(i64 2, i64 0, i64 0) ] // // TYPE: [[VTABLEI64:%.*]] = ptrtoint ptr [[VTABLE]] to i64 -// TYPE: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VTABLEI64]]) [ "ptrauth"(i64 2, i64 [[DISC_DEFAULT]]) ] +// TYPE: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VTABLEI64]]) [ "ptrauth"(i64 2, i64 [[DISC_DEFAULT]], i64 0) ] // // ADDR: [[VTADDRI64:%.*]] = ptrtoint ptr [[VTADDR]] to i64 // ADDR: [[VTABLEI64:%.*]] = ptrtoint ptr [[VTABLE]] to i64 -// ADDR: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VTABLEI64]]) [ "ptrauth"(i64 2, i64 [[VTADDRI64]]) ] +// ADDR: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VTABLEI64]]) [ "ptrauth"(i64 2, i64 0, i64 [[VTADDRI64]]) ] // // BOTH: [[VTADDRI64:%.*]] = ptrtoint ptr [[VTADDR]] to i64 // BOTH: [[VTABLEI64:%.*]] = ptrtoint ptr [[VTABLE]] to i64 -// BOTH: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VTABLEI64]]) [ "ptrauth"(i64 2, i64 [[VTADDRI64]], i64 [[DISC_DEFAULT]]) ] +// BOTH: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VTABLEI64]]) [ "ptrauth"(i64 2, i64 [[DISC_DEFAULT]], i64 [[VTADDRI64]]) ] void test_subclass_default(NoExplicitAuth *a) { make_subclass(a)->f(); } @@ -322,19 +322,19 @@ void test_subclass_disabled(ExplicitlyDisableAuth *a) { // // NODISC: [[VTADDRI64:%.*]] = ptrtoint ptr [[VTADDR]] to i64 // NODISC: [[VTABLEI64:%.*]] = ptrtoint ptr [[VTABLE]] to i64 -// NODISC: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VTABLEI64]]) [ "ptrauth"(i64 2, i64 [[VTADDRI64]]) ] +// NODISC: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VTABLEI64]]) [ "ptrauth"(i64 2, i64 0, i64 [[VTADDRI64]]) ] // // TYPE: [[VTADDRI64:%.*]] = ptrtoint ptr [[VTADDR]] to i64 // TYPE: [[VTABLEI64:%.*]] = ptrtoint ptr [[VTABLE]] to i64 -// TYPE: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VTABLEI64]]) [ "ptrauth"(i64 2, i64 [[VTADDRI64]], i64 [[DISC_ADDR]]) ] +// TYPE: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VTABLEI64]]) [ "ptrauth"(i64 2, i64 [[DISC_ADDR]], i64 [[VTADDRI64]]) ] // // ADDR: [[VTADDRI64:%.*]] = ptrtoint ptr [[VTADDR]] to i64 // ADDR: [[VTABLEI64:%.*]] = ptrtoint ptr [[VTABLE]] to i64 -// ADDR: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VTABLEI64]]) [ "ptrauth"(i64 2, i64 [[VTADDRI64]]) ] +// ADDR: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VTABLEI64]]) [ "ptrauth"(i64 2, i64 0, i64 [[VTADDRI64]]) ] // // BOTH: [[VTADDRI64:%.*]] = ptrtoint ptr [[VTADDR]] to i64 // BOTH: [[VTABLEI64:%.*]] = ptrtoint ptr [[VTABLE]] to i64 -// BOTH: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VTABLEI64]]) [ "ptrauth"(i64 2, i64 [[VTADDRI64]], i64 [[DISC_ADDR]]) ] +// BOTH: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VTABLEI64]]) [ "ptrauth"(i64 2, i64 [[DISC_ADDR]], i64 [[VTADDRI64]]) ] void test_subclass_addr_disc(ExplicitAddressDiscrimination *a) { make_subclass(a)->f(); } @@ -344,16 +344,16 @@ void test_subclass_addr_disc(ExplicitAddressDiscrimination *a) { // CHECK: [[VTABLE:%.*]] = load ptr, ptr [[VTADDR]], align 8 // // NODISC: [[VTABLEI64:%.*]] = ptrtoint ptr [[VTABLE]] to i64 -// NODISC: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VTABLEI64]]) [ "ptrauth"(i64 2, i64 0) ] +// NODISC: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VTABLEI64]]) [ "ptrauth"(i64 2, i64 0, i64 0) ] // // TYPE: [[VTABLEI64:%.*]] = ptrtoint ptr [[VTABLE]] to i64 -// TYPE: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VTABLEI64]]) [ "ptrauth"(i64 2, i64 [[DISC_NO_ADDR]]) ] +// TYPE: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VTABLEI64]]) [ "ptrauth"(i64 2, i64 [[DISC_NO_ADDR]], i64 0) ] // // ADDR: [[VTABLEI64:%.*]] = ptrtoint ptr [[VTABLE]] to i64 -// ADDR: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VTABLEI64]]) [ "ptrauth"(i64 2, i64 0) ] +// ADDR: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VTABLEI64]]) [ "ptrauth"(i64 2, i64 0, i64 0) ] // // BOTH: [[VTABLEI64:%.*]] = ptrtoint ptr [[VTABLE]] to i64 -// BOTH: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VTABLEI64]]) [ "ptrauth"(i64 2, i64 [[DISC_NO_ADDR]]) ] +// BOTH: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VTABLEI64]]) [ "ptrauth"(i64 2, i64 [[DISC_NO_ADDR]], i64 0) ] void test_subclass_no_addr_disc(ExplicitNoAddressDiscrimination *a) { make_subclass(a)->f(); } @@ -363,18 +363,18 @@ void test_subclass_no_addr_disc(ExplicitNoAddressDiscrimination *a) { // CHECK: [[VTABLE:%.*]] = load ptr, ptr [[VTADDR]], align 8 // // NODISC: [[VTABLEI64:%.*]] = ptrtoint ptr [[VTABLE]] to i64 -// NODISC: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VTABLEI64]]) [ "ptrauth"(i64 2, i64 0) ] +// NODISC: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VTABLEI64]]) [ "ptrauth"(i64 2, i64 0, i64 0) ] // // TYPE: [[VTABLEI64:%.*]] = ptrtoint ptr [[VTABLE]] to i64 -// TYPE: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VTABLEI64]]) [ "ptrauth"(i64 2, i64 0) ] +// TYPE: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VTABLEI64]]) [ "ptrauth"(i64 2, i64 0, i64 0) ] // // ADDR: [[VTADDRI64:%.*]] = ptrtoint ptr [[VTADDR]] to i64 // ADDR: [[VTABLEI64:%.*]] = ptrtoint ptr [[VTABLE]] to i64 -// ADDR: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VTABLEI64]]) [ "ptrauth"(i64 2, i64 [[VTADDRI64]]) ] +// ADDR: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VTABLEI64]]) [ "ptrauth"(i64 2, i64 0, i64 [[VTADDRI64]]) ] // // BOTH: [[VTADDRI64:%.*]] = ptrtoint ptr [[VTADDR]] to i64 // BOTH: [[VTABLEI64:%.*]] = ptrtoint ptr [[VTABLE]] to i64 -// BOTH: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VTABLEI64]]) [ "ptrauth"(i64 2, i64 [[VTADDRI64]]) ] +// BOTH: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VTABLEI64]]) [ "ptrauth"(i64 2, i64 0, i64 [[VTADDRI64]]) ] void test_subclass_no_extra_disc(ExplicitNoExtraDiscrimination *a) { make_subclass(a)->f(); } @@ -384,18 +384,18 @@ void test_subclass_no_extra_disc(ExplicitNoExtraDiscrimination *a) { // CHECK: [[VTABLE:%.*]] = load ptr, ptr [[VTADDR]], align 8 // // NODISC: [[VTABLEI64:%.*]] = ptrtoint ptr [[VTABLE]] to i64 -// NODISC: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VTABLEI64]]) [ "ptrauth"(i64 2, i64 [[DISC_TYPE]]) ] +// NODISC: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VTABLEI64]]) [ "ptrauth"(i64 2, i64 [[DISC_TYPE]], i64 0) ] // // TYPE: [[VTABLEI64:%.*]] = ptrtoint ptr [[VTABLE]] to i64 -// TYPE: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VTABLEI64]]) [ "ptrauth"(i64 2, i64 [[DISC_TYPE]]) ] +// TYPE: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VTABLEI64]]) [ "ptrauth"(i64 2, i64 [[DISC_TYPE]], i64 0) ] // // ADDR: [[VTADDRI64:%.*]] = ptrtoint ptr [[VTADDR]] to i64 // ADDR: [[VTABLEI64:%.*]] = ptrtoint ptr [[VTABLE]] to i64 -// ADDR: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VTABLEI64]]) [ "ptrauth"(i64 2, i64 [[VTADDRI64]], i64 [[DISC_TYPE]]) ] +// ADDR: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VTABLEI64]]) [ "ptrauth"(i64 2, i64 [[DISC_TYPE]], i64 [[VTADDRI64]]) ] // // BOTH: [[VTADDRI64:%.*]] = ptrtoint ptr [[VTADDR]] to i64 // BOTH: [[VTABLEI64:%.*]] = ptrtoint ptr [[VTABLE]] to i64 -// BOTH: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VTABLEI64]]) [ "ptrauth"(i64 2, i64 [[VTADDRI64]], i64 [[DISC_TYPE]]) ] +// BOTH: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VTABLEI64]]) [ "ptrauth"(i64 2, i64 [[DISC_TYPE]], i64 [[VTADDRI64]]) ] void test_subclass_type_disc(ExplicitTypeDiscrimination *a) { make_subclass(a)->f(); } @@ -405,18 +405,18 @@ void test_subclass_type_disc(ExplicitTypeDiscrimination *a) { // CHECK: [[VTABLE:%.*]] = load ptr, ptr [[VTADDR]], align 8 // // NODISC: [[VTABLEI64:%.*]] = ptrtoint ptr [[VTABLE]] to i64 -// NODISC: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VTABLEI64]]) [ "ptrauth"(i64 2, i64 42424) ] +// NODISC: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VTABLEI64]]) [ "ptrauth"(i64 2, i64 42424, i64 0) ] // // TYPE: [[VTABLEI64:%.*]] = ptrtoint ptr [[VTABLE]] to i64 -// TYPE: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VTABLEI64]]) [ "ptrauth"(i64 2, i64 42424) ] +// TYPE: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VTABLEI64]]) [ "ptrauth"(i64 2, i64 42424, i64 0) ] // // ADDR: [[VTADDRI64:%.*]] = ptrtoint ptr [[VTADDR]] to i64 // ADDR: [[VTABLEI64:%.*]] = ptrtoint ptr [[VTABLE]] to i64 -// ADDR: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VTABLEI64]]) [ "ptrauth"(i64 2, i64 [[VTADDRI64]], i64 42424) ] +// ADDR: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VTABLEI64]]) [ "ptrauth"(i64 2, i64 42424, i64 [[VTADDRI64]]) ] // // BOTH: [[VTADDRI64:%.*]] = ptrtoint ptr [[VTADDR]] to i64 // BOTH: [[VTABLEI64:%.*]] = ptrtoint ptr [[VTABLE]] to i64 -// BOTH: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VTABLEI64]]) [ "ptrauth"(i64 2, i64 [[VTADDRI64]], i64 42424) ] +// BOTH: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VTABLEI64]]) [ "ptrauth"(i64 2, i64 42424, i64 [[VTADDRI64]]) ] void test_subclass_custom_disc(ExplicitCustomDiscrimination *a) { make_subclass(a)->f(); } @@ -433,18 +433,18 @@ void test_subclass_custom_disc(ExplicitCustomDiscrimination *a) { // CHECK: [[VTABLE:%.*]] = load ptr, ptr [[VTADDR]], align 8 // // NODISC: [[VTABLEI64:%.*]] = ptrtoint ptr [[VTABLE]] to i64 -// NODISC: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VTABLEI64]]) [ "ptrauth"(i64 2, i64 0) ] +// NODISC: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VTABLEI64]]) [ "ptrauth"(i64 2, i64 0, i64 0) ] // // TYPE: [[VTABLEI64:%.*]] = ptrtoint ptr [[VTABLE]] to i64 -// TYPE: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VTABLEI64]]) [ "ptrauth"(i64 2, i64 [[DISC_DEFAULT]]) ] +// TYPE: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VTABLEI64]]) [ "ptrauth"(i64 2, i64 [[DISC_DEFAULT]], i64 0) ] // // ADDR: [[VTADDRI64:%.*]] = ptrtoint ptr [[VTADDR]] to i64 // ADDR: [[VTABLEI64:%.*]] = ptrtoint ptr [[VTABLE]] to i64 -// ADDR: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VTABLEI64]]) [ "ptrauth"(i64 2, i64 [[VTADDRI64]]) ] +// ADDR: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VTABLEI64]]) [ "ptrauth"(i64 2, i64 0, i64 [[VTADDRI64]]) ] // // BOTH: [[VTADDRI64:%.*]] = ptrtoint ptr [[VTADDR]] to i64 // BOTH: [[VTABLEI64:%.*]] = ptrtoint ptr [[VTABLE]] to i64 -// BOTH: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VTABLEI64]]) [ "ptrauth"(i64 2, i64 [[VTADDRI64]], i64 [[DISC_DEFAULT]]) ] +// BOTH: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VTABLEI64]]) [ "ptrauth"(i64 2, i64 [[DISC_DEFAULT]], i64 [[VTADDRI64]]) ] void test_multiple_default(NoExplicitAuth *a) { make_multiple_primary(a)->f(); } @@ -464,18 +464,18 @@ void test_multiple_disabled(ExplicitlyDisableAuth *a) { // CHECK: [[VTABLE:%.*]] = load ptr, ptr [[VTADDR]], align 8 // // NODISC: [[VTABLEI64:%.*]] = ptrtoint ptr [[VTABLE]] to i64 -// NODISC: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VTABLEI64]]) [ "ptrauth"(i64 2, i64 42424) ] +// NODISC: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VTABLEI64]]) [ "ptrauth"(i64 2, i64 42424, i64 0) ] // // TYPE: [[VTABLEI64:%.*]] = ptrtoint ptr [[VTABLE]] to i64 -// TYPE: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VTABLEI64]]) [ "ptrauth"(i64 2, i64 42424) ] +// TYPE: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VTABLEI64]]) [ "ptrauth"(i64 2, i64 42424, i64 0) ] // // ADDR: [[VTADDRI64:%.*]] = ptrtoint ptr [[VTADDR]] to i64 // ADDR: [[VTABLEI64:%.*]] = ptrtoint ptr [[VTABLE]] to i64 -// ADDR: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VTABLEI64]]) [ "ptrauth"(i64 2, i64 [[VTADDRI64]], i64 42424) ] +// ADDR: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VTABLEI64]]) [ "ptrauth"(i64 2, i64 42424, i64 [[VTADDRI64]]) ] // // BOTH: [[VTADDRI64:%.*]] = ptrtoint ptr [[VTADDR]] to i64 // BOTH: [[VTABLEI64:%.*]] = ptrtoint ptr [[VTABLE]] to i64 -// BOTH: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VTABLEI64]]) [ "ptrauth"(i64 2, i64 [[VTADDRI64]], i64 42424) ] +// BOTH: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VTABLEI64]]) [ "ptrauth"(i64 2, i64 42424, i64 [[VTADDRI64]]) ] void test_multiple_custom_disc(ExplicitCustomDiscrimination *a) { make_multiple_primary(a)->f(); } @@ -491,18 +491,18 @@ void test_multiple_custom_disc(ExplicitCustomDiscrimination *a) { // CHECK: [[VTTABLE:%.*]] = load ptr, ptr [[VTTADDR]], align 8 // // NODISC: [[VTTABLEI64:%.*]] = ptrtoint ptr [[VTTABLE]] to i64 -// NODISC: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VTTABLEI64]]) [ "ptrauth"(i64 2, i64 0) ] +// NODISC: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VTTABLEI64]]) [ "ptrauth"(i64 2, i64 0, i64 0) ] // // TYPE: [[VTTABLEI64:%.*]] = ptrtoint ptr [[VTTABLE]] to i64 -// TYPE: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VTTABLEI64]]) [ "ptrauth"(i64 2, i64 [[DISC_DEFAULT]]) ] +// TYPE: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VTTABLEI64]]) [ "ptrauth"(i64 2, i64 [[DISC_DEFAULT]], i64 0) ] // // ADDR: [[VTTADDRI64:%.*]] = ptrtoint ptr [[VTTADDR]] to i64 // ADDR: [[VTTABLEI64:%.*]] = ptrtoint ptr [[VTTABLE]] to i64 -// ADDR: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VTTABLEI64]]) [ "ptrauth"(i64 2, i64 [[VTTADDRI64]]) ] +// ADDR: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VTTABLEI64]]) [ "ptrauth"(i64 2, i64 0, i64 [[VTTADDRI64]]) ] // // BOTH: [[VTTADDRI64:%.*]] = ptrtoint ptr [[VTTADDR]] to i64 // BOTH: [[VTTABLEI64:%.*]] = ptrtoint ptr [[VTTABLE]] to i64 -// BOTH: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VTTABLEI64]]) [ "ptrauth"(i64 2, i64 [[VTTADDRI64]], i64 [[DISC_DEFAULT]]) ] +// BOTH: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VTTABLEI64]]) [ "ptrauth"(i64 2, i64 [[DISC_DEFAULT]], i64 [[VTTADDRI64]]) ] // CHECK: [[AUTHEDPTR:%.*]] = inttoptr i64 [[AUTHED]] to ptr // CHECK: [[VBOFFPTR:%.*]] = getelementptr i8, ptr [[AUTHEDPTR]], i64 -48 @@ -511,18 +511,18 @@ void test_multiple_custom_disc(ExplicitCustomDiscrimination *a) { // CHECK: [[VTABLE:%.*]] = load ptr, ptr [[VTADDR]], align 8 // // NODISC: [[VTABLEI64:%.*]] = ptrtoint ptr [[VTABLE]] to i64 -// NODISC: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VTABLEI64]]) [ "ptrauth"(i64 2, i64 0) ] +// NODISC: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VTABLEI64]]) [ "ptrauth"(i64 2, i64 0, i64 0) ] // // TYPE: [[VTABLEI64:%.*]] = ptrtoint ptr [[VTABLE]] to i64 -// TYPE: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VTABLEI64]]) [ "ptrauth"(i64 2, i64 [[DISC_DEFAULT]]) ] +// TYPE: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VTABLEI64]]) [ "ptrauth"(i64 2, i64 [[DISC_DEFAULT]], i64 0) ] // // ADDR: [[VTADDRI64:%.*]] = ptrtoint ptr [[VTADDR]] to i64 // ADDR: [[VTABLEI64:%.*]] = ptrtoint ptr [[VTABLE]] to i64 -// ADDR: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VTABLEI64]]) [ "ptrauth"(i64 2, i64 [[VTADDRI64]]) ] +// ADDR: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VTABLEI64]]) [ "ptrauth"(i64 2, i64 0, i64 [[VTADDRI64]]) ] // // BOTH: [[VTADDRI64:%.*]] = ptrtoint ptr [[VTADDR]] to i64 // BOTH: [[VTABLEI64:%.*]] = ptrtoint ptr [[VTABLE]] to i64 -// BOTH: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VTABLEI64]]) [ "ptrauth"(i64 2, i64 [[VTADDRI64]], i64 [[DISC_DEFAULT]]) ] +// BOTH: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VTABLEI64]]) [ "ptrauth"(i64 2, i64 [[DISC_DEFAULT]], i64 [[VTADDRI64]]) ] void test_virtual_default(NoExplicitAuth *a) { make_virtual_primary(a)->f(); } @@ -538,18 +538,18 @@ void test_virtual_disabled(ExplicitlyDisableAuth *a) { // CHECK: [[VTTABLE:%.*]] = load ptr, ptr [[VTTADDR]], align 8 // // NODISC: [[VTTABLEI64:%.*]] = ptrtoint ptr [[VTTABLE]] to i64 -// NODISC: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VTTABLEI64]]) [ "ptrauth"(i64 2, i64 42424) ] +// NODISC: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VTTABLEI64]]) [ "ptrauth"(i64 2, i64 42424, i64 0) ] // // TYPE: [[VTTABLEI64:%.*]] = ptrtoint ptr [[VTTABLE]] to i64 -// TYPE: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VTTABLEI64]]) [ "ptrauth"(i64 2, i64 42424) ] +// TYPE: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VTTABLEI64]]) [ "ptrauth"(i64 2, i64 42424, i64 0) ] // // ADDR: [[VTTADDRI64:%.*]] = ptrtoint ptr [[VTTADDR]] to i64 // ADDR: [[VTTABLEI64:%.*]] = ptrtoint ptr [[VTTABLE]] to i64 -// ADDR: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VTTABLEI64]]) [ "ptrauth"(i64 2, i64 [[VTTADDRI64]], i64 42424) ] +// ADDR: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VTTABLEI64]]) [ "ptrauth"(i64 2, i64 42424, i64 [[VTTADDRI64]]) ] // // BOTH: [[VTTADDRI64:%.*]] = ptrtoint ptr [[VTTADDR]] to i64 // BOTH: [[VTTABLEI64:%.*]] = ptrtoint ptr [[VTTABLE]] to i64 -// BOTH: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VTTABLEI64]]) [ "ptrauth"(i64 2, i64 [[VTTADDRI64]], i64 42424) ] +// BOTH: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VTTABLEI64]]) [ "ptrauth"(i64 2, i64 42424, i64 [[VTTADDRI64]]) ] // CHECK: [[AUTHEDPTR:%.*]] = inttoptr i64 [[AUTHED]] to ptr // CHECK: [[VBOFFPTR:%.*]] = getelementptr i8, ptr [[AUTHEDPTR]], i64 -48 @@ -558,18 +558,18 @@ void test_virtual_disabled(ExplicitlyDisableAuth *a) { // CHECK: [[VTABLE:%.*]] = load ptr, ptr [[VTADDR]], align 8 // // NODISC: [[VTABLEI64:%.*]] = ptrtoint ptr [[VTABLE]] to i64 -// NODISC: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VTABLEI64]]) [ "ptrauth"(i64 2, i64 42424) ] +// NODISC: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VTABLEI64]]) [ "ptrauth"(i64 2, i64 42424, i64 0) ] // // TYPE: [[VTABLEI64:%.*]] = ptrtoint ptr [[VTABLE]] to i64 -// TYPE: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VTABLEI64]]) [ "ptrauth"(i64 2, i64 42424) ] +// TYPE: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VTABLEI64]]) [ "ptrauth"(i64 2, i64 42424, i64 0) ] // // ADDR: [[VTADDRI64:%.*]] = ptrtoint ptr [[VTADDR]] to i64 // ADDR: [[VTABLEI64:%.*]] = ptrtoint ptr [[VTABLE]] to i64 -// ADDR: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VTABLEI64]]) [ "ptrauth"(i64 2, i64 [[VTADDRI64]], i64 42424) ] +// ADDR: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VTABLEI64]]) [ "ptrauth"(i64 2, i64 42424, i64 [[VTADDRI64]]) ] // // BOTH: [[VTADDRI64:%.*]] = ptrtoint ptr [[VTADDR]] to i64 // BOTH: [[VTABLEI64:%.*]] = ptrtoint ptr [[VTABLE]] to i64 -// BOTH: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VTABLEI64]]) [ "ptrauth"(i64 2, i64 [[VTADDRI64]], i64 42424) ] +// BOTH: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VTABLEI64]]) [ "ptrauth"(i64 2, i64 42424, i64 [[VTADDRI64]]) ] void test_virtual_custom_disc(ExplicitCustomDiscrimination *a) { make_virtual_primary(a)->f(); } diff --git a/clang/test/CodeGenCXX/ptrauth-global-constant-initializers.cpp b/clang/test/CodeGenCXX/ptrauth-global-constant-initializers.cpp index 4e8b5098fcb3c..616b612ea798d 100644 --- a/clang/test/CodeGenCXX/ptrauth-global-constant-initializers.cpp +++ b/clang/test/CodeGenCXX/ptrauth-global-constant-initializers.cpp @@ -78,25 +78,25 @@ struct Derived5 : VirtualBase2, VirtualBase1 { // DARWIN-LABEL: define {{.*}} ptr @_ZN12VirtualBase1C1Ev // ELF-LABEL: define {{.*}} void @_ZN12VirtualBase1C1Ev -// CHECK: call i64 @llvm.ptrauth.sign{{.*}} [ "ptrauth"(i64 2, i64 {{%.*}}, i64 [[BASE1_VTABLE_DISC]]) ] -// CHECK: call i64 @llvm.ptrauth.sign{{.*}} [ "ptrauth"(i64 2, i64 {{%.*}}, i64 [[BASE1_VTABLE_DISC]]) ] +// CHECK: call i64 @llvm.ptrauth.sign{{.*}} [ "ptrauth"(i64 2, i64 [[BASE1_VTABLE_DISC]], i64 {{%.*}}) ] +// CHECK: call i64 @llvm.ptrauth.sign{{.*}} [ "ptrauth"(i64 2, i64 [[BASE1_VTABLE_DISC]], i64 {{%.*}}) ] // DARWIN-LABEL: define {{.*}} ptr @_ZN12VirtualBase2C1Ev // ELF-LABEL: define {{.*}} void @_ZN12VirtualBase2C1Ev -// CHECK: call i64 @llvm.ptrauth.sign{{.*}} [ "ptrauth"(i64 2, i64 {{%.*}}, i64 [[BASE2_VTABLE_DISC]]) ] -// CHECK: call i64 @llvm.ptrauth.sign{{.*}} [ "ptrauth"(i64 2, i64 {{%.*}}, i64 [[BASE1_VTABLE_DISC]]) ] +// CHECK: call i64 @llvm.ptrauth.sign{{.*}} [ "ptrauth"(i64 2, i64 [[BASE2_VTABLE_DISC]], i64 {{%.*}}) ] +// CHECK: call i64 @llvm.ptrauth.sign{{.*}} [ "ptrauth"(i64 2, i64 [[BASE1_VTABLE_DISC]], i64 {{%.*}}) ] // DARWIN-LABEL: define {{.*}} ptr @_ZN8Derived4C1Ev // ELF-LABEL: define {{.*}} void @_ZN8Derived4C1Ev -// CHECK: call i64 @llvm.ptrauth.sign{{.*}} [ "ptrauth"(i64 2, i64 {{%.*}}, i64 [[BASE1_VTABLE_DISC]]) ] -// CHECK: call i64 @llvm.ptrauth.sign{{.*}} [ "ptrauth"(i64 2, i64 {{%.*}}, i64 [[BASE1_VTABLE_DISC]]) ] -// CHECK: call i64 @llvm.ptrauth.sign{{.*}} [ "ptrauth"(i64 2, i64 {{%.*}}, i64 [[BASE2_VTABLE_DISC]]) ] +// CHECK: call i64 @llvm.ptrauth.sign{{.*}} [ "ptrauth"(i64 2, i64 [[BASE1_VTABLE_DISC]], i64 {{%.*}}) ] +// CHECK: call i64 @llvm.ptrauth.sign{{.*}} [ "ptrauth"(i64 2, i64 [[BASE1_VTABLE_DISC]], i64 {{%.*}}) ] +// CHECK: call i64 @llvm.ptrauth.sign{{.*}} [ "ptrauth"(i64 2, i64 [[BASE2_VTABLE_DISC]], i64 {{%.*}}) ] // DARWIN-LABEL: define {{.*}} ptr @_ZN8Derived5C1Ev // ELF-LABEL: define {{.*}} void @_ZN8Derived5C1Ev -// CHECK: call i64 @llvm.ptrauth.sign{{.*}} [ "ptrauth"(i64 2, i64 {{%.*}}, i64 [[BASE2_VTABLE_DISC]]) ] -// CHECK: call i64 @llvm.ptrauth.sign{{.*}} [ "ptrauth"(i64 2, i64 {{%.*}}, i64 [[BASE1_VTABLE_DISC]]) ] -// CHECK: call i64 @llvm.ptrauth.sign{{.*}} [ "ptrauth"(i64 2, i64 {{%.*}}, i64 [[BASE1_VTABLE_DISC]]) ] +// CHECK: call i64 @llvm.ptrauth.sign{{.*}} [ "ptrauth"(i64 2, i64 [[BASE2_VTABLE_DISC]], i64 {{%.*}}) ] +// CHECK: call i64 @llvm.ptrauth.sign{{.*}} [ "ptrauth"(i64 2, i64 [[BASE1_VTABLE_DISC]], i64 {{%.*}}) ] +// CHECK: call i64 @llvm.ptrauth.sign{{.*}} [ "ptrauth"(i64 2, i64 [[BASE1_VTABLE_DISC]], i64 {{%.*}}) ] VirtualBase1 g_vb1; @@ -164,82 +164,82 @@ extern "C" void cross_check_vtables(Base1 *b1, // CHECK-LABEL: define{{.*}} void @cross_check_vtables( // CHECK: "; b1->a()", -// CHECK: call i64 @llvm.ptrauth.auth{{.*}} [ "ptrauth"(i64 2, i64 {{%.*}}, i64 [[BASE1_VTABLE_DISC]]) ] -// CHECK: call void %{{.*}} [ "ptrauth"(i64 0, i64 {{%.*}}, i64 [[BASE1_A_DISC]]) ] +// CHECK: call i64 @llvm.ptrauth.auth{{.*}} [ "ptrauth"(i64 2, i64 [[BASE1_VTABLE_DISC]], i64 {{%.*}}) ] +// CHECK: call void %{{.*}} [ "ptrauth"(i64 0, i64 [[BASE1_A_DISC]], i64 {{%.*}}) ] // CHECK: "; b2->b()" -// CHECK: call i64 @llvm.ptrauth.auth{{.*}} [ "ptrauth"(i64 2, i64 {{%.*}}, i64 [[BASE2_VTABLE_DISC]]) ] -// CHECK: call void %{{.*}} [ "ptrauth"(i64 0, i64 {{%.*}}, i64 [[BASE2_B_DISC]]) ] +// CHECK: call i64 @llvm.ptrauth.auth{{.*}} [ "ptrauth"(i64 2, i64 [[BASE2_VTABLE_DISC]], i64 {{%.*}}) ] +// CHECK: call void %{{.*}} [ "ptrauth"(i64 0, i64 [[BASE2_B_DISC]], i64 {{%.*}}) ] // CHECK: "; d1->a()" -// CHECK: call i64 @llvm.ptrauth.auth{{.*}} [ "ptrauth"(i64 2, i64 {{%.*}}, i64 [[BASE1_VTABLE_DISC]]) ] -// CHECK: call void %{{.*}} [ "ptrauth"(i64 0, i64 {{%.*}}, i64 [[BASE1_A_DISC]]) ] +// CHECK: call i64 @llvm.ptrauth.auth{{.*}} [ "ptrauth"(i64 2, i64 [[BASE1_VTABLE_DISC]], i64 {{%.*}}) ] +// CHECK: call void %{{.*}} [ "ptrauth"(i64 0, i64 [[BASE1_A_DISC]], i64 {{%.*}}) ] // CHECK: "; d1->c()" -// CHECK: call i64 @llvm.ptrauth.auth{{.*}} [ "ptrauth"(i64 2, i64 {{%.*}}, i64 [[BASE1_VTABLE_DISC]]) ] -// CHECK: call void %{{.*}} [ "ptrauth"(i64 0, i64 {{%.*}}, i64 [[DERIVED1_C_DISC]]) ] +// CHECK: call i64 @llvm.ptrauth.auth{{.*}} [ "ptrauth"(i64 2, i64 [[BASE1_VTABLE_DISC]], i64 {{%.*}}) ] +// CHECK: call void %{{.*}} [ "ptrauth"(i64 0, i64 [[DERIVED1_C_DISC]], i64 {{%.*}}) ] // CHECK: "; d2->a()" -// CHECK: call i64 @llvm.ptrauth.auth{{.*}} [ "ptrauth"(i64 2, i64 {{%.*}}, i64 [[BASE1_VTABLE_DISC]]) ] -// CHECK: call void %{{.*}} [ "ptrauth"(i64 0, i64 {{%.*}}, i64 [[BASE1_A_DISC]]) ] +// CHECK: call i64 @llvm.ptrauth.auth{{.*}} [ "ptrauth"(i64 2, i64 [[BASE1_VTABLE_DISC]], i64 {{%.*}}) ] +// CHECK: call void %{{.*}} [ "ptrauth"(i64 0, i64 [[BASE1_A_DISC]], i64 {{%.*}}) ] // CHECK: "; d2->c()" -// CHECK: call i64 @llvm.ptrauth.auth{{.*}} [ "ptrauth"(i64 2, i64 {{%.*}}, i64 [[BASE2_VTABLE_DISC]]) ] -// CHECK: call void %{{.*}} [ "ptrauth"(i64 0, i64 {{%.*}}, i64 [[DERIVED2_C_DISC]]) ] +// CHECK: call i64 @llvm.ptrauth.auth{{.*}} [ "ptrauth"(i64 2, i64 [[BASE2_VTABLE_DISC]], i64 {{%.*}}) ] +// CHECK: call void %{{.*}} [ "ptrauth"(i64 0, i64 [[DERIVED2_C_DISC]], i64 {{%.*}}) ] // CHECK: "; d3->a()" -// CHECK: call i64 @llvm.ptrauth.auth{{.*}} [ "ptrauth"(i64 2, i64 {{%.*}}, i64 [[BASE1_VTABLE_DISC]]) ] -// CHECK: call void %{{.*}} [ "ptrauth"(i64 0, i64 {{%.*}}, i64 [[BASE1_A_DISC]]) ] +// CHECK: call i64 @llvm.ptrauth.auth{{.*}} [ "ptrauth"(i64 2, i64 [[BASE1_VTABLE_DISC]], i64 {{%.*}}) ] +// CHECK: call void %{{.*}} [ "ptrauth"(i64 0, i64 [[BASE1_A_DISC]], i64 {{%.*}}) ] // CHECK: "; d3->b()" -// CHECK: call i64 @llvm.ptrauth.auth{{.*}} [ "ptrauth"(i64 2, i64 {{%.*}}, i64 [[BASE2_VTABLE_DISC]]) ] -// CHECK: call void %{{.*}} [ "ptrauth"(i64 0, i64 {{%.*}}, i64 [[BASE2_B_DISC]]) ] +// CHECK: call i64 @llvm.ptrauth.auth{{.*}} [ "ptrauth"(i64 2, i64 [[BASE2_VTABLE_DISC]], i64 {{%.*}}) ] +// CHECK: call void %{{.*}} [ "ptrauth"(i64 0, i64 [[BASE2_B_DISC]], i64 {{%.*}}) ] // CHECK: "; d3->i()" -// CHECK: call i64 @llvm.ptrauth.auth{{.*}} [ "ptrauth"(i64 2, i64 {{%.*}}, i64 [[BASE1_VTABLE_DISC]]) ] -// CHECK: call void %{{.*}} [ "ptrauth"(i64 0, i64 {{%.*}}, i64 [[DERIVED3_I_DISC]]) ] +// CHECK: call i64 @llvm.ptrauth.auth{{.*}} [ "ptrauth"(i64 2, i64 [[BASE1_VTABLE_DISC]], i64 {{%.*}}) ] +// CHECK: call void %{{.*}} [ "ptrauth"(i64 0, i64 [[DERIVED3_I_DISC]], i64 {{%.*}}) ] // CHECK: "; vb1->a()" -// CHECK: call i64 @llvm.ptrauth.auth{{.*}} [ "ptrauth"(i64 2, i64 {{%.*}}, i64 [[BASE1_VTABLE_DISC]]) ] -// CHECK: call i64 @llvm.ptrauth.auth{{.*}} [ "ptrauth"(i64 2, i64 {{%.*}}, i64 [[BASE1_VTABLE_DISC]]) ] -// CHECK: call void %{{.*}} [ "ptrauth"(i64 0, i64 {{%.*}}, i64 [[BASE1_A_DISC]]) ] +// CHECK: call i64 @llvm.ptrauth.auth{{.*}} [ "ptrauth"(i64 2, i64 [[BASE1_VTABLE_DISC]], i64 {{%.*}}) ] +// CHECK: call i64 @llvm.ptrauth.auth{{.*}} [ "ptrauth"(i64 2, i64 [[BASE1_VTABLE_DISC]], i64 {{%.*}}) ] +// CHECK: call void %{{.*}} [ "ptrauth"(i64 0, i64 [[BASE1_A_DISC]], i64 {{%.*}}) ] // CHECK: "; vb1->f()" -// CHECK: call i64 @llvm.ptrauth.auth{{.*}} [ "ptrauth"(i64 2, i64 {{%.*}}, i64 [[BASE1_VTABLE_DISC]]) ] -// CHECK: call void %{{.*}} [ "ptrauth"(i64 0, i64 {{%.*}}, i64 [[VIRTUALBASE1_F_DISC]]) ] +// CHECK: call i64 @llvm.ptrauth.auth{{.*}} [ "ptrauth"(i64 2, i64 [[BASE1_VTABLE_DISC]], i64 {{%.*}}) ] +// CHECK: call void %{{.*}} [ "ptrauth"(i64 0, i64 [[VIRTUALBASE1_F_DISC]], i64 {{%.*}}) ] // CHECK: "; vb2->a()" -// CHECK: call i64 @llvm.ptrauth.auth{{.*}} [ "ptrauth"(i64 2, i64 {{%.*}}, i64 [[BASE2_VTABLE_DISC]]) ] -// CHECK: call i64 @llvm.ptrauth.auth{{.*}} [ "ptrauth"(i64 2, i64 {{%.*}}, i64 [[BASE1_VTABLE_DISC]]) ] -// CHECK: call void %{{.*}} [ "ptrauth"(i64 0, i64 {{%.*}}, i64 [[BASE1_A_DISC]]) ] +// CHECK: call i64 @llvm.ptrauth.auth{{.*}} [ "ptrauth"(i64 2, i64 [[BASE2_VTABLE_DISC]], i64 {{%.*}}) ] +// CHECK: call i64 @llvm.ptrauth.auth{{.*}} [ "ptrauth"(i64 2, i64 [[BASE1_VTABLE_DISC]], i64 {{%.*}}) ] +// CHECK: call void %{{.*}} [ "ptrauth"(i64 0, i64 [[BASE1_A_DISC]], i64 {{%.*}}) ] // CHECK: "; vb2->g()" -// CHECK: call i64 @llvm.ptrauth.auth{{.*}} [ "ptrauth"(i64 2, i64 {{%.*}}, i64 [[BASE2_VTABLE_DISC]]) ] -// CHECK: call void %{{.*}} [ "ptrauth"(i64 0, i64 {{%.*}}, i64 [[VIRTUALBASE2_G_DISC]]) ] +// CHECK: call i64 @llvm.ptrauth.auth{{.*}} [ "ptrauth"(i64 2, i64 [[BASE2_VTABLE_DISC]], i64 {{%.*}}) ] +// CHECK: call void %{{.*}} [ "ptrauth"(i64 0, i64 [[VIRTUALBASE2_G_DISC]], i64 {{%.*}}) ] // CHECK: "; d4->a()" -// CHECK: call i64 @llvm.ptrauth.auth{{.*}} [ "ptrauth"(i64 2, i64 {{%.*}}, i64 [[BASE1_VTABLE_DISC]]) ] -// CHECK: call i64 @llvm.ptrauth.auth{{.*}} [ "ptrauth"(i64 2, i64 {{%.*}}, i64 [[BASE1_VTABLE_DISC]]) ] -// CHECK: call void %{{.*}} [ "ptrauth"(i64 0, i64 {{%.*}}, i64 [[BASE1_A_DISC]]) ] +// CHECK: call i64 @llvm.ptrauth.auth{{.*}} [ "ptrauth"(i64 2, i64 [[BASE1_VTABLE_DISC]], i64 {{%.*}}) ] +// CHECK: call i64 @llvm.ptrauth.auth{{.*}} [ "ptrauth"(i64 2, i64 [[BASE1_VTABLE_DISC]], i64 {{%.*}}) ] +// CHECK: call void %{{.*}} [ "ptrauth"(i64 0, i64 [[BASE1_A_DISC]], i64 {{%.*}}) ] // CHECK: "; d4->b()" -// CHECK: call i64 @llvm.ptrauth.auth{{.*}} [ "ptrauth"(i64 2, i64 {{%.*}}, i64 [[BASE2_VTABLE_DISC]]) ] -// CHECK: call void %{{.*}} [ "ptrauth"(i64 0, i64 {{%.*}}, i64 [[BASE2_B_DISC]]) ] +// CHECK: call i64 @llvm.ptrauth.auth{{.*}} [ "ptrauth"(i64 2, i64 [[BASE2_VTABLE_DISC]], i64 {{%.*}}) ] +// CHECK: call void %{{.*}} [ "ptrauth"(i64 0, i64 [[BASE2_B_DISC]], i64 {{%.*}}) ] // CHECK: "; d4->f()" -// CHECK: call i64 @llvm.ptrauth.auth{{.*}} [ "ptrauth"(i64 2, i64 {{%.*}}, i64 [[BASE1_VTABLE_DISC]]) ] -// CHECK: call void %{{.*}} [ "ptrauth"(i64 0, i64 {{%.*}}, i64 [[VIRTUALBASE1_F_DISC]]) ] +// CHECK: call i64 @llvm.ptrauth.auth{{.*}} [ "ptrauth"(i64 2, i64 [[BASE1_VTABLE_DISC]], i64 {{%.*}}) ] +// CHECK: call void %{{.*}} [ "ptrauth"(i64 0, i64 [[VIRTUALBASE1_F_DISC]], i64 {{%.*}}) ] // CHECK: "; d4->g()" -// CHECK: call i64 @llvm.ptrauth.auth{{.*}} [ "ptrauth"(i64 2, i64 {{%.*}}, i64 [[BASE2_VTABLE_DISC]]) ] -// CHECK: call void %{{.*}} [ "ptrauth"(i64 0, i64 {{%.*}}, i64 [[VIRTUALBASE2_G_DISC]]) ] +// CHECK: call i64 @llvm.ptrauth.auth{{.*}} [ "ptrauth"(i64 2, i64 [[BASE2_VTABLE_DISC]], i64 {{%.*}}) ] +// CHECK: call void %{{.*}} [ "ptrauth"(i64 0, i64 [[VIRTUALBASE2_G_DISC]], i64 {{%.*}}) ] // CHECK: "; d4->h()" -// CHECK: call i64 @llvm.ptrauth.auth{{.*}} [ "ptrauth"(i64 2, i64 {{%.*}}, i64 [[BASE1_VTABLE_DISC]]) ] -// CHECK: call void %{{.*}} [ "ptrauth"(i64 0, i64 {{%.*}}, i64 [[DERIVED4_H_DISC]]) ] +// CHECK: call i64 @llvm.ptrauth.auth{{.*}} [ "ptrauth"(i64 2, i64 [[BASE1_VTABLE_DISC]], i64 {{%.*}}) ] +// CHECK: call void %{{.*}} [ "ptrauth"(i64 0, i64 [[DERIVED4_H_DISC]], i64 {{%.*}}) ] // DARWIN-LABEL: define {{.*}} ptr @_ZN5Base1C2Ev // ELF-LABEL: define {{.*}} void @_ZN5Base1C2Ev -// CHECK: call i64 @llvm.ptrauth.sign{{.*}} [ "ptrauth"(i64 2, i64 {{%.*}}, i64 [[BASE1_VTABLE_DISC]]) ] +// CHECK: call i64 @llvm.ptrauth.sign{{.*}} [ "ptrauth"(i64 2, i64 [[BASE1_VTABLE_DISC]], i64 {{%.*}}) ] // DARWIN-LABEL: define {{.*}} ptr @_ZN5Base2C2Ev // ELF-LABEL: define {{.*}} void @_ZN5Base2C2Ev -// CHECK: call i64 @llvm.ptrauth.sign{{.*}} [ "ptrauth"(i64 2, i64 {{%.*}}, i64 [[BASE2_VTABLE_DISC]]) ] +// CHECK: call i64 @llvm.ptrauth.sign{{.*}} [ "ptrauth"(i64 2, i64 [[BASE2_VTABLE_DISC]], i64 {{%.*}}) ] // DARWIN-LABEL: define {{.*}} ptr @_ZN8Derived1C2Ev // ELF-LABEL: define {{.*}} void @_ZN8Derived1C2Ev -// CHECK: call i64 @llvm.ptrauth.sign{{.*}} [ "ptrauth"(i64 2, i64 {{%.*}}, i64 [[BASE1_VTABLE_DISC]]) ] -// CHECK: call i64 @llvm.ptrauth.sign{{.*}} [ "ptrauth"(i64 2, i64 {{%.*}}, i64 [[BASE2_VTABLE_DISC]]) ] +// CHECK: call i64 @llvm.ptrauth.sign{{.*}} [ "ptrauth"(i64 2, i64 [[BASE1_VTABLE_DISC]], i64 {{%.*}}) ] +// CHECK: call i64 @llvm.ptrauth.sign{{.*}} [ "ptrauth"(i64 2, i64 [[BASE2_VTABLE_DISC]], i64 {{%.*}}) ] // DARWIN-LABEL: define {{.*}} ptr @_ZN8Derived2C2Ev // ELF-LABEL: define {{.*}} void @_ZN8Derived2C2Ev -// CHECK: call i64 @llvm.ptrauth.sign{{.*}} [ "ptrauth"(i64 2, i64 {{%.*}}, i64 [[BASE2_VTABLE_DISC]]) ] -// CHECK: call i64 @llvm.ptrauth.sign{{.*}} [ "ptrauth"(i64 2, i64 {{%.*}}, i64 [[BASE1_VTABLE_DISC]]) ] +// CHECK: call i64 @llvm.ptrauth.sign{{.*}} [ "ptrauth"(i64 2, i64 [[BASE2_VTABLE_DISC]], i64 {{%.*}}) ] +// CHECK: call i64 @llvm.ptrauth.sign{{.*}} [ "ptrauth"(i64 2, i64 [[BASE1_VTABLE_DISC]], i64 {{%.*}}) ] // DARWIN-LABEL: define {{.*}} ptr @_ZN8Derived3C2Ev // ELF-LABEL: define {{.*}} void @_ZN8Derived3C2Ev -// CHECK: call i64 @llvm.ptrauth.sign{{.*}} [ "ptrauth"(i64 2, i64 {{%.*}}, i64 [[BASE1_VTABLE_DISC]]) ] -// CHECK: call i64 @llvm.ptrauth.sign{{.*}} [ "ptrauth"(i64 2, i64 {{%.*}}, i64 [[BASE2_VTABLE_DISC]]) ] +// CHECK: call i64 @llvm.ptrauth.sign{{.*}} [ "ptrauth"(i64 2, i64 [[BASE1_VTABLE_DISC]], i64 {{%.*}}) ] +// CHECK: call i64 @llvm.ptrauth.sign{{.*}} [ "ptrauth"(i64 2, i64 [[BASE2_VTABLE_DISC]], i64 {{%.*}}) ] diff --git a/clang/test/CodeGenCXX/ptrauth-member-function-pointer.cpp b/clang/test/CodeGenCXX/ptrauth-member-function-pointer.cpp index abf556decebed..c3b79121502bc 100644 --- a/clang/test/CodeGenCXX/ptrauth-member-function-pointer.cpp +++ b/clang/test/CodeGenCXX/ptrauth-member-function-pointer.cpp @@ -128,12 +128,12 @@ struct Class0 { // CHECK-NEXT: %[[V0:.*]] = load ptr, ptr %[[THIS_ADDR]], align 8 // CHECK-NEXT: %[[VTABLE:.*]] = load ptr, ptr %[[THIS1]], align 8 // CHECK-NEXT: %[[V2:.*]] = ptrtoint ptr %[[VTABLE]] to i64 -// CHECK-NEXT: %[[V3:.*]] = call i64 @llvm.ptrauth.auth(i64 %[[V2]]) [ "ptrauth"(i64 2, i64 0) ] +// CHECK-NEXT: %[[V3:.*]] = call i64 @llvm.ptrauth.auth(i64 %[[V2]]) [ "ptrauth"(i64 2, i64 0, i64 0) ] // CHECK-NEXT: %[[V4:.*]] = inttoptr i64 %[[V3]] to ptr // CHECK-NEXT: %[[VFN:.*]] = getelementptr inbounds ptr, ptr %[[V4]], i64 0 // CHECK-NEXT: %[[V5:.*]] = load ptr, ptr %[[VFN]], align 8 // CHECK-NEXT: %[[V6:.*]] = ptrtoint ptr %[[VFN]] to i64 -// CHECK-NEXT: musttail call void %[[V5]](ptr noundef nonnull align {{[0-9]+}} dereferenceable(8) %[[V0]]) [ "ptrauth"(i64 0, i64 %[[V6]], i64 55600) ] +// CHECK-NEXT: musttail call void %[[V5]](ptr noundef nonnull align {{[0-9]+}} dereferenceable(8) %[[V0]]) [ "ptrauth"(i64 0, i64 55600, i64 %[[V6]]) ] // CHECK-NEXT: ret void // CHECK: define linkonce_odr hidden void @_ZN5Base08virtual3Ev_vfpthunk_(ptr noundef %{{.*}}) @@ -141,10 +141,10 @@ struct Class0 { // CHECK: load ptr, ptr %{{.*}}, align 8 // CHECK: %[[VTABLE:.*]] = load ptr, ptr %{{.*}}, align 8 // CHECK: %[[V2:.*]] = ptrtoint ptr %[[VTABLE]] to i64 -// CHECK: %[[V3:.*]] = call i64 @llvm.ptrauth.auth(i64 %[[V2]]) [ "ptrauth"(i64 2, i64 0) ] +// CHECK: %[[V3:.*]] = call i64 @llvm.ptrauth.auth(i64 %[[V2]]) [ "ptrauth"(i64 2, i64 0, i64 0) ] // CHECK: %[[V4:.*]] = inttoptr i64 %[[V3]] to ptr // CHECK: getelementptr inbounds ptr, ptr %[[V4]], i64 1 -// CHECK: call void %{{.*}} [ "ptrauth"(i64 0, i64 %{{.*}}, i64 53007) ] +// CHECK: call void %{{.*}} [ "ptrauth"(i64 0, i64 53007, i64 %{{.*}}) ] // CHECK: define linkonce_odr hidden void @_ZN5Base016virtual_variadicEiz_vfpthunk_(ptr noundef %[[THIS:.*]], i32 noundef %0, ...) // CHECK: %[[THIS_ADDR:.*]] = alloca ptr, align 8 @@ -156,12 +156,12 @@ struct Class0 { // CHECK-NEXT: %[[V2:.*]] = load i32, ptr %[[_ADDR]], align 4 // CHECK-NEXT: %[[VTABLE:.*]] = load ptr, ptr %[[THIS1]], align 8 // CHECK-NEXT: %[[V4:.*]] = ptrtoint ptr %[[VTABLE]] to i64 -// CHECK-NEXT: %[[V5:.*]] = call i64 @llvm.ptrauth.auth(i64 %[[V4]]) [ "ptrauth"(i64 2, i64 0) ] +// CHECK-NEXT: %[[V5:.*]] = call i64 @llvm.ptrauth.auth(i64 %[[V4]]) [ "ptrauth"(i64 2, i64 0, i64 0) ] // CHECK-NEXT: %[[V6:.*]] = inttoptr i64 %[[V5]] to ptr // CHECK-NEXT: %[[VFN:.*]] = getelementptr inbounds ptr, ptr %[[V6]], i64 2 // CHECK-NEXT: %[[V7:.*]] = load ptr, ptr %[[VFN]], align 8 // CHECK-NEXT: %[[V8:.*]] = ptrtoint ptr %[[VFN]] to i64 -// CHECK-NEXT: musttail call void (ptr, i32, ...) %[[V7]](ptr noundef nonnull align {{[0-9]+}} dereferenceable(8) %[[V1]], i32 noundef %[[V2]], ...) [ "ptrauth"(i64 0, i64 %[[V8]], i64 7464) ] +// CHECK-NEXT: musttail call void (ptr, i32, ...) %[[V7]](ptr noundef nonnull align {{[0-9]+}} dereferenceable(8) %[[V1]], i32 noundef %[[V2]], ...) [ "ptrauth"(i64 0, i64 7464, i64 %[[V8]]) ] // CHECK-NEXT: ret void // CHECK: define linkonce_odr hidden void @_ZN8Derived08virtual6Ev_vfpthunk_(ptr noundef %[[THIS:.*]]) @@ -171,23 +171,23 @@ struct Class0 { // CHECK: %[[V0:.*]] = load ptr, ptr %[[THIS_ADDR]], align 8 // CHECK: %[[VTABLE:.*]] = load ptr, ptr %[[THIS1]], align 8 // CHECK: %[[V1:.*]] = ptrtoint ptr %[[VTABLE]] to i64 -// CHECK: %[[V2:.*]] = call i64 @llvm.ptrauth.auth(i64 %[[V1]]) [ "ptrauth"(i64 2, i64 0) ] +// CHECK: %[[V2:.*]] = call i64 @llvm.ptrauth.auth(i64 %[[V1]]) [ "ptrauth"(i64 2, i64 0, i64 0) ] // CHECK: %[[V3:.*]] = inttoptr i64 %[[V2]] to ptr // CHECK: %[[VFN:.*]] = getelementptr inbounds ptr, ptr %[[V3]], i64 3 // CHECK: %[[V5:.*]] = ptrtoint ptr %[[VFN]] to i64 -// CHECK: call void %{{.*}} [ "ptrauth"(i64 0, i64 %[[V5]], i64 55535) ] +// CHECK: call void %{{.*}} [ "ptrauth"(i64 0, i64 55535, i64 %[[V5]]) ] // Check that the return value of the musttail call isn't copied to a temporary. // CHECK: define linkonce_odr hidden [2 x i64] @_ZN8Derived010return_aggEv_vfpthunk_(ptr noundef %{{.*}}) -// CHECK: %[[CALL:.*]] = musttail call [2 x i64] %{{.*}}(ptr noundef nonnull align {{[0-9]+}} dereferenceable(8) %{{.*}}) [ "ptrauth"(i64 0, i64 %{{.*}}, i64 13445) ] +// CHECK: %[[CALL:.*]] = musttail call [2 x i64] %{{.*}}(ptr noundef nonnull align {{[0-9]+}} dereferenceable(8) %{{.*}}) [ "ptrauth"(i64 0, i64 13445, i64 %{{.*}}) ] // CHECK-NEXT: ret [2 x i64] %[[CALL]] // Check that the sret pointer passed to the caller is forwarded to the musttail // call. // CHECK: define linkonce_odr hidden void @_ZN8Derived04sretEv_vfpthunk_(ptr dead_on_unwind noalias writable sret(%struct.A1) align 4 %[[AGG_RESULT:.*]], ptr noundef %{{.*}}) -// CHECK: musttail call void %{{.*}}(ptr dead_on_unwind writable sret(%struct.A1) align 4 %[[AGG_RESULT]], ptr noundef nonnull align {{[0-9]+}} dereferenceable(8) %{{.*}}) [ "ptrauth"(i64 0, i64 %{{.*}}, i64 41281) ] +// CHECK: musttail call void %{{.*}}(ptr dead_on_unwind writable sret(%struct.A1) align 4 %[[AGG_RESULT]], ptr noundef nonnull align {{[0-9]+}} dereferenceable(8) %{{.*}}) [ "ptrauth"(i64 0, i64 41281, i64 %{{.*}}) ] // CHECK-NEXT: ret void // Check that the thunk function doesn't destruct the trivial_abi argument. @@ -207,7 +207,7 @@ struct Class0 { // CHECK: %[[V0:.*]] = load ptr, ptr %[[THIS_ADDR]], align 8 // CHECK: %[[VTABLE:.*]] = load ptr, ptr %[[THIS1]], align 8 // CHECK: %[[V1:.*]] = ptrtoint ptr %[[VTABLE]] to i64 -// CHECK: %[[V2:.*]] = call i64 @llvm.ptrauth.auth(i64 %[[V1]]) [ "ptrauth"(i64 2, i64 0) ] +// CHECK: %[[V2:.*]] = call i64 @llvm.ptrauth.auth(i64 %[[V1]]) [ "ptrauth"(i64 2, i64 0, i64 0) ] // CHECK: %[[V3:.*]] = inttoptr i64 %[[V2]] to ptr // CHECK: getelementptr inbounds ptr, ptr %[[V3]], i64 0 @@ -218,7 +218,7 @@ struct Class0 { // CHECK: load ptr, ptr %[[THIS_ADDR]], align 8 // CHECK: %[[VTABLE:.*]] = load ptr, ptr %[[THIS1]], align 8 // CHECK: %[[V1:.*]] = ptrtoint ptr %[[VTABLE]] to i64 -// CHECK: %[[V2:.*]] = call i64 @llvm.ptrauth.auth(i64 %[[V1]]) [ "ptrauth"(i64 2, i64 0) ] +// CHECK: %[[V2:.*]] = call i64 @llvm.ptrauth.auth(i64 %[[V1]]) [ "ptrauth"(i64 2, i64 0, i64 0) ] // CHECK: %[[V3:.*]] = inttoptr i64 %[[V2]] to ptr // CHECK: getelementptr inbounds ptr, ptr %[[V3]], i64 3 @@ -277,7 +277,7 @@ void test0() { // CHECK: %[[VTABLE:.*]] = load ptr, ptr %[[V4]], align 8 // CHECK: %[[V7:.*]] = ptrtoint ptr %[[VTABLE]] to i64 -// CHECK: %[[V8:.*]] = call i64 @llvm.ptrauth.auth(i64 %[[V7]]) [ "ptrauth"(i64 2, i64 0) ] +// CHECK: %[[V8:.*]] = call i64 @llvm.ptrauth.auth(i64 %[[V7]]) [ "ptrauth"(i64 2, i64 0, i64 0) ] // CHECK: %[[V9:.*]] = inttoptr i64 %[[V8]] to ptr // DARWIN: %[[V10:.*]] = trunc i64 %[[MEMPTR_PTR]] to i32 // DARWIN: %[[V11:.*]] = zext i32 %[[V10]] to i64 @@ -291,7 +291,7 @@ void test0() { // CHECK: %[[V14:.*]] = phi ptr [ %[[MEMPTR_VIRTUALFN]], {{.*}} ], [ %[[MEMPTR_NONVIRTUALFN]], {{.*}} ] // CHECK: %[[V15:.*]] = phi i64 [ 0, {{.*}} ], [ [[TYPEDISC0]], {{.*}} ] -// CHECK: call void %[[V14]](ptr noundef nonnull align {{[0-9]+}} dereferenceable(8) %[[V4]]) [ "ptrauth"(i64 0, i64 %[[V15]]) ] +// CHECK: call void %[[V14]](ptr noundef nonnull align {{[0-9]+}} dereferenceable(8) %[[V4]]) [ "ptrauth"(i64 0, i64 0, i64 %[[V15]]) ] // CHECK: ret void void test1(Base0 *a0, MethodTy0 a1) { @@ -301,7 +301,7 @@ void test1(Base0 *a0, MethodTy0 a1) { // CXX17: define{{.*}} void @_Z14test1_noexceptP5Base0MS_DoFvvE( // CXX17: %[[V14:.*]] = phi ptr [ %{{.*}}, {{.*}} ], [ %{{.*}}, {{.*}} ] // CXX17: %[[V15:.*]] = phi i64 [ 0, {{.*}} ], [ [[TYPEDISC0]], {{.*}} ] -// CXX17: call void %[[V14]](ptr noundef nonnull align {{[0-9]+}} dereferenceable(8) %{{.*}}) {{.*}}[ "ptrauth"(i64 0, i64 %[[V15]]) ] +// CXX17: call void %[[V14]](ptr noundef nonnull align {{[0-9]+}} dereferenceable(8) %{{.*}}) {{.*}}[ "ptrauth"(i64 0, i64 0, i64 %[[V15]]) ] #if __cplusplus >= 201703L void test1_noexcept(Base0 *a0, NoExceptMethodTy0 a1) { (a0->*a1)(); @@ -331,7 +331,7 @@ void test1_noexcept(Base0 *a0, NoExceptMethodTy0 a1) { // CHECK: br i1 %[[V5]] // CHECK: %[[V6:.*]] = ptrtoint ptr %[[V4]] to i64 -// CHECK: %[[V7:.*]] = call i64 @llvm.ptrauth.resign(i64 %[[V6]]) [ "ptrauth"(i64 0, i64 [[TYPEDISC0]]), "ptrauth"(i64 0, i64 [[TYPEDISC1]]) ] +// CHECK: %[[V7:.*]] = call i64 @llvm.ptrauth.resign(i64 %[[V6]]) [ "ptrauth"(i64 0, i64 [[TYPEDISC0]], i64 0), "ptrauth"(i64 0, i64 [[TYPEDISC1]], i64 0) ] // CHECK: %[[V8:.*]] = inttoptr i64 %[[V7]] to ptr // CHECK: br @@ -349,21 +349,21 @@ void testConversion0(MethodTy0 method0, MethodTy1 method1) { } // CHECK: define{{.*}} void @_Z15testConversion1M5Base0FvvE( -// CHECK: call i64 @llvm.ptrauth.resign(i64 %{{.*}}) [ "ptrauth"(i64 0, i64 [[TYPEDISC0]]), "ptrauth"(i64 0, i64 [[TYPEDISC1]]) ] +// CHECK: call i64 @llvm.ptrauth.resign(i64 %{{.*}}) [ "ptrauth"(i64 0, i64 [[TYPEDISC0]], i64 0), "ptrauth"(i64 0, i64 [[TYPEDISC1]], i64 0) ] void testConversion1(MethodTy0 method0) { MethodTy1 method1 = reinterpret_cast(method0); } // CHECK: define{{.*}} void @_Z15testConversion2M8Derived0FvvE( -// CHECK: call i64 @llvm.ptrauth.resign(i64 %{{.*}}) [ "ptrauth"(i64 0, i64 [[TYPEDISC1]]), "ptrauth"(i64 0, i64 [[TYPEDISC0]]) ] +// CHECK: call i64 @llvm.ptrauth.resign(i64 %{{.*}}) [ "ptrauth"(i64 0, i64 [[TYPEDISC1]], i64 0), "ptrauth"(i64 0, i64 [[TYPEDISC0]], i64 0) ] void testConversion2(MethodTy1 method1) { MethodTy0 method0 = static_cast(method1); } // CHECK: define{{.*}} void @_Z15testConversion3M8Derived0FvvE( -// CHECK: call i64 @llvm.ptrauth.resign(i64 %{{.*}}) [ "ptrauth"(i64 0, i64 [[TYPEDISC1]]), "ptrauth"(i64 0, i64 [[TYPEDISC0]]) ] +// CHECK: call i64 @llvm.ptrauth.resign(i64 %{{.*}}) [ "ptrauth"(i64 0, i64 [[TYPEDISC1]], i64 0), "ptrauth"(i64 0, i64 [[TYPEDISC0]], i64 0) ] void testConversion3(MethodTy1 method1) { MethodTy0 method0 = reinterpret_cast(method1); diff --git a/clang/test/CodeGenCXX/ptrauth-qualifier-struct.cpp b/clang/test/CodeGenCXX/ptrauth-qualifier-struct.cpp index 163d45ce3dbfc..f34e112da6eac 100644 --- a/clang/test/CodeGenCXX/ptrauth-qualifier-struct.cpp +++ b/clang/test/CodeGenCXX/ptrauth-qualifier-struct.cpp @@ -65,7 +65,7 @@ void testMoveConstructor(SA a) { // CHECK: %[[V3:.*]] = ptrtoint ptr %[[M02]] to i64 // CHECK: %[[V5:.*]] = ptrtoint ptr %[[M0]] to i64 // CHECK: %[[V8:.*]] = ptrtoint ptr %[[V2]] to i64 -// CHECK: %[[V9:.*]] = call i64 @llvm.ptrauth.resign(i64 %[[V8]]) [ "ptrauth"(i64 1, i64 %[[V3]], i64 50), "ptrauth"(i64 1, i64 %[[V5]], i64 50) ] +// CHECK: %[[V9:.*]] = call i64 @llvm.ptrauth.resign(i64 %[[V8]]) [ "ptrauth"(i64 1, i64 50, i64 %[[V3]]), "ptrauth"(i64 1, i64 50, i64 %[[V5]]) ] void testCopyAssignment(SA a) { SA t; @@ -88,7 +88,7 @@ void testCopyAssignment(SA a) { // CHECK: %[[V3:.*]] = ptrtoint ptr %[[M02]] to i64 // CHECK: %[[V5:.*]] = ptrtoint ptr %[[M0]] to i64 // CHECK: %[[V8:.*]] = ptrtoint ptr %[[V2]] to i64 -// CHECK: %[[V9:.*]] = call i64 @llvm.ptrauth.resign(i64 %[[V8]]) [ "ptrauth"(i64 1, i64 %[[V3]], i64 50), "ptrauth"(i64 1, i64 %[[V5]], i64 50) ] +// CHECK: %[[V9:.*]] = call i64 @llvm.ptrauth.resign(i64 %[[V8]]) [ "ptrauth"(i64 1, i64 50, i64 %[[V3]]), "ptrauth"(i64 1, i64 50, i64 %[[V5]]) ] void testMoveAssignment(SA a) { SA t; @@ -140,7 +140,7 @@ void testMoveAssignment(SI a) { // CHECK: %[[V3:.*]] = ptrtoint ptr %[[M02]] to i64 // CHECK: %[[V5:.*]] = ptrtoint ptr %[[M0]] to i64 // CHECK: %[[V8:.*]] = ptrtoint ptr %[[V2]] to i64 -// CHECK: %[[V9:.*]] = call i64 @llvm.ptrauth.resign(i64 %[[V8]]) [ "ptrauth"(i64 1, i64 %[[V3]], i64 50), "ptrauth"(i64 1, i64 %[[V5]], i64 50) ] +// CHECK: %[[V9:.*]] = call i64 @llvm.ptrauth.resign(i64 %[[V8]]) [ "ptrauth"(i64 1, i64 50, i64 %[[V3]]), "ptrauth"(i64 1, i64 50, i64 %[[V5]]) ] // CHECK: define linkonce_odr {{.*}}@_ZN2SAC2EOS_(ptr noundef nonnull align 8 dereferenceable(16) %[[THIS:.*]], ptr noundef nonnull align 8 dereferenceable(16) %0) // IOS: %[[RETVAL:.*]] = alloca ptr, align 8 @@ -157,4 +157,4 @@ void testMoveAssignment(SI a) { // CHECK: %[[V3:.*]] = ptrtoint ptr %[[M02]] to i64 // CHECK: %[[V5:.*]] = ptrtoint ptr %[[M0]] to i64 // CHECK: %[[V8:.*]] = ptrtoint ptr %[[V2]] to i64 -// CHECK: %[[V9:.*]] = call i64 @llvm.ptrauth.resign(i64 %[[V8]]) [ "ptrauth"(i64 1, i64 %[[V3]], i64 50), "ptrauth"(i64 1, i64 %[[V5]], i64 50) ] +// CHECK: %[[V9:.*]] = call i64 @llvm.ptrauth.resign(i64 %[[V8]]) [ "ptrauth"(i64 1, i64 50, i64 %[[V3]]), "ptrauth"(i64 1, i64 50, i64 %[[V5]]) ] diff --git a/clang/test/CodeGenCXX/ptrauth-throw.cpp b/clang/test/CodeGenCXX/ptrauth-throw.cpp index c347ea470f6ca..2933d22852b4a 100644 --- a/clang/test/CodeGenCXX/ptrauth-throw.cpp +++ b/clang/test/CodeGenCXX/ptrauth-throw.cpp @@ -22,10 +22,10 @@ void f() { // __cxa_throw is defined to take its destructor as "void (*)(void *)" in the ABI. // CHECK-LABEL: define{{.*}} void @__cxa_throw({{.*}}) -// CHECK: call void {{%.*}}(ptr noundef {{%.*}}) [ "ptrauth"(i64 0, i64 0) ] +// CHECK: call void {{%.*}}(ptr noundef {{%.*}}) [ "ptrauth"(i64 0, i64 0, i64 0) ] // CHECKDISC-LABEL: define{{.*}} void @__cxa_throw({{.*}}) -// CHECKDISC: call void {{%.*}}(ptr noundef {{%.*}}) [ "ptrauth"(i64 0, i64 10942) ] +// CHECKDISC: call void {{%.*}}(ptr noundef {{%.*}}) [ "ptrauth"(i64 0, i64 10942, i64 0) ] extern "C" void __cxa_throw(void *exception, void *, void (*dtor)(void *)) { dtor(exception); diff --git a/clang/test/CodeGenCXX/ptrauth-thunks.cpp b/clang/test/CodeGenCXX/ptrauth-thunks.cpp index 7c08ec3e5bbba..017b9a900bfbd 100644 --- a/clang/test/CodeGenCXX/ptrauth-thunks.cpp +++ b/clang/test/CodeGenCXX/ptrauth-thunks.cpp @@ -26,4 +26,4 @@ namespace Test1 { // CHECK: %[[This:.*]] = load ptr // CHECK: %[[SignedVTable:.*]] = load ptr, ptr %[[This]], align 8 // CHECK: %[[SignedVTableAsInt:.*]] = ptrtoint ptr %[[SignedVTable]] to i64 -// CHECK: %[[VTable:.*]] = call i64 @llvm.ptrauth.auth(i64 %[[SignedVTableAsInt]]) [ "ptrauth"(i64 2, i64 0) ] +// CHECK: %[[VTable:.*]] = call i64 @llvm.ptrauth.auth(i64 %[[SignedVTableAsInt]]) [ "ptrauth"(i64 2, i64 0, i64 0) ] diff --git a/clang/test/CodeGenCXX/ptrauth-type-info-vtable.cpp b/clang/test/CodeGenCXX/ptrauth-type-info-vtable.cpp index d678f03c9c9b2..89dff35d84c89 100644 --- a/clang/test/CodeGenCXX/ptrauth-type-info-vtable.cpp +++ b/clang/test/CodeGenCXX/ptrauth-type-info-vtable.cpp @@ -84,7 +84,7 @@ extern "C" void test_vtable(std::type_info* t) { // NODISC: [[T:%.*]] = load ptr, ptr [[T_ADDR]], align 8 // NODISC: [[VPTR:%.*]] = load ptr, ptr [[T]], align 8 // NODISC: [[CAST_VPTR:%.*]] = ptrtoint ptr [[VPTR]] to i64 -// NODISC: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[CAST_VPTR]]) [ "ptrauth"(i64 2, i64 0) ] +// NODISC: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[CAST_VPTR]]) [ "ptrauth"(i64 2, i64 0, i64 0) ] // DISC: define{{.*}} void @test_vtable(ptr noundef %t) // DISC: [[T_ADDR:%.*]] = alloca ptr, align 8 @@ -93,7 +93,7 @@ extern "C" void test_vtable(std::type_info* t) { // DISC: [[VPTR:%.*]] = load ptr, ptr [[T]], align 8 // DISC: [[ADDR:%.*]] = ptrtoint ptr [[T]] to i64 // DISC: [[VPTRI:%.*]] = ptrtoint ptr [[VPTR]] to i64 -// DISC: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VPTRI]]) [ "ptrauth"(i64 2, i64 [[ADDR]], i64 [[STDTYPEINFO_DISC]]) ] +// DISC: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VPTRI]]) [ "ptrauth"(i64 2, i64 [[STDTYPEINFO_DISC]], i64 [[ADDR]]) ] extern "C" const void *ensure_typeinfo() { return new TestStruct; diff --git a/clang/test/CodeGenCXX/ptrauth-virtual-function.cpp b/clang/test/CodeGenCXX/ptrauth-virtual-function.cpp index 7df5453e8529a..58e86406e473a 100644 --- a/clang/test/CodeGenCXX/ptrauth-virtual-function.cpp +++ b/clang/test/CodeGenCXX/ptrauth-virtual-function.cpp @@ -188,22 +188,22 @@ V1::~V1() { // CHECK: %[[THIS1:.*]] = load ptr, ptr %{{.*}} // CHECK: %[[T0:[0-9]+]] = load ptr, ptr %{{.*}} // CHECK: %[[T1:[0-9]+]] = ptrtoint ptr %[[T0]] to i64 -// CHECK: %[[T2:[0-9]+]] = call i64 @llvm.ptrauth.auth(i64 %[[T1]]) [ "ptrauth"(i64 2, i64 0) ] +// CHECK: %[[T2:[0-9]+]] = call i64 @llvm.ptrauth.auth(i64 %[[T1]]) [ "ptrauth"(i64 2, i64 0, i64 0) ] // CHECK: %[[T3:[0-9]+]] = inttoptr i64 %[[T2]] to ptr // CHECK: %[[T6:[0-9]+]] = ptrtoint ptr %[[T3]] to i64 -// CHECK: %[[T7:[0-9]+]] = call i64 @llvm.ptrauth.sign(i64 %[[T6]]) [ "ptrauth"(i64 2, i64 0) ] +// CHECK: %[[T7:[0-9]+]] = call i64 @llvm.ptrauth.sign(i64 %[[T6]]) [ "ptrauth"(i64 2, i64 0, i64 0) ] // CHECK: %[[SIGNED_VTADDR:[0-9]+]] = inttoptr i64 %[[T7]] to ptr // CHECK: store ptr %[[SIGNED_VTADDR]], ptr %[[THIS1]] // CHECK-LABEL: define{{.*}} void @_Z8testB0m0P2B0( // CHECK: %[[VTABLE:[a-z]+]] = load ptr, ptr %{{.*}} // CHECK: %[[T0:[0-9]+]] = ptrtoint ptr %[[VTABLE]] to i64 -// CHECK: %[[T3:[0-9]+]] = call i64 @llvm.ptrauth.auth(i64 %[[T0]]) [ "ptrauth"(i64 2, i64 0) ] +// CHECK: %[[T3:[0-9]+]] = call i64 @llvm.ptrauth.auth(i64 %[[T0]]) [ "ptrauth"(i64 2, i64 0, i64 0) ] // CHECK: %[[T4:[0-9]+]] = inttoptr i64 %[[T3]] to ptr // CHECK: %[[VFN:[a-z]+]] = getelementptr inbounds ptr, ptr %[[T4]], i64 0 // CHECK: %[[T5:[0-9]+]] = load ptr, ptr %[[VFN]] // CHECK: %[[T6:[0-9]+]] = ptrtoint ptr %[[VFN]] to i64 -// CHECK: call void %[[T5]](ptr noundef nonnull align {{[0-9]+}} dereferenceable(12) %{{.*}}) [ "ptrauth"(i64 0, i64 %[[T6]], i64 53119) ] +// CHECK: call void %[[T5]](ptr noundef nonnull align {{[0-9]+}} dereferenceable(12) %{{.*}}) [ "ptrauth"(i64 0, i64 53119, i64 %[[T6]]) ] void testB0m0(B0 *a) { a->m0(); @@ -212,12 +212,12 @@ void testB0m0(B0 *a) { // CHECK-LABEL: define{{.*}} void @_Z8testB0m1P2B0( // CHECK: %[[VTABLE:[a-z]+]] = load ptr, ptr %{{.*}} // CHECK: %[[T0:[0-9]+]] = ptrtoint ptr %[[VTABLE]] to i64 -// CHECK: %[[T3:[0-9]+]] = call i64 @llvm.ptrauth.auth(i64 %[[T0]]) [ "ptrauth"(i64 2, i64 0) ] +// CHECK: %[[T3:[0-9]+]] = call i64 @llvm.ptrauth.auth(i64 %[[T0]]) [ "ptrauth"(i64 2, i64 0, i64 0) ] // CHECK: %[[T4:[0-9]+]] = inttoptr i64 %[[T3]] to ptr // CHECK: %[[VFN:[a-z]+]] = getelementptr inbounds ptr, ptr %[[T4]], i64 1 // CHECK: %[[T5:[0-9]+]] = load ptr, ptr %[[VFN]] // CHECK: %[[T6:[0-9]+]] = ptrtoint ptr %[[VFN]] to i64 -// CHECK: call noundef ptr %[[T5]](ptr noundef nonnull align {{[0-9]+}} dereferenceable(12) %{{.*}}) [ "ptrauth"(i64 0, i64 %[[T6]], i64 15165) ] +// CHECK: call noundef ptr %[[T5]](ptr noundef nonnull align {{[0-9]+}} dereferenceable(12) %{{.*}}) [ "ptrauth"(i64 0, i64 15165, i64 %[[T6]]) ] void testB0m1(B0 *a) { a->m1(); @@ -226,12 +226,12 @@ void testB0m1(B0 *a) { // CHECK-LABEL: define{{.*}} void @_Z8testB0m2P2B0( // CHECK: %[[VTABLE:[a-z]+]] = load ptr, ptr %{{.*}} // CHECK: %[[T0:[0-9]+]] = ptrtoint ptr %[[VTABLE]] to i64 -// CHECK: %[[T3:[0-9]+]] = call i64 @llvm.ptrauth.auth(i64 %[[T0]]) [ "ptrauth"(i64 2, i64 0) ] +// CHECK: %[[T3:[0-9]+]] = call i64 @llvm.ptrauth.auth(i64 %[[T0]]) [ "ptrauth"(i64 2, i64 0, i64 0) ] // CHECK: %[[T4:[0-9]+]] = inttoptr i64 %[[T3]] to ptr // CHECK: %[[VFN:[a-z]+]] = getelementptr inbounds ptr, ptr %[[T4]], i64 2 // CHECK: %[[T5:[0-9]+]] = load ptr, ptr %[[VFN]] // CHECK: %[[T6:[0-9]+]] = ptrtoint ptr %[[VFN]] to i64 -// CHECK: call void %[[T5]](ptr noundef nonnull align {{[0-9]+}} dereferenceable(12) %{{.*}}) [ "ptrauth"(i64 0, i64 %[[T6]], i64 43073) ] +// CHECK: call void %[[T5]](ptr noundef nonnull align {{[0-9]+}} dereferenceable(12) %{{.*}}) [ "ptrauth"(i64 0, i64 43073, i64 %[[T6]]) ] void testB0m2(B0 *a) { a->m2(); @@ -240,12 +240,12 @@ void testB0m2(B0 *a) { // CHECK-LABEL: define{{.*}} void @_Z8testD0m0P2D0( // CHECK: %[[VTABLE:[a-z]+]] = load ptr, ptr %{{.*}} // CHECK: %[[T0:[0-9]+]] = ptrtoint ptr %[[VTABLE]] to i64 -// CHECK: %[[T3:[0-9]+]] = call i64 @llvm.ptrauth.auth(i64 %[[T0]]) [ "ptrauth"(i64 2, i64 0) ] +// CHECK: %[[T3:[0-9]+]] = call i64 @llvm.ptrauth.auth(i64 %[[T0]]) [ "ptrauth"(i64 2, i64 0, i64 0) ] // CHECK: %[[T4:[0-9]+]] = inttoptr i64 %[[T3]] to ptr // CHECK: %[[VFN:[a-z]+]] = getelementptr inbounds ptr, ptr %[[T4]], i64 0 // CHECK: %[[T5:[0-9]+]] = load ptr, ptr %[[VFN]] // CHECK: %[[T6:[0-9]+]] = ptrtoint ptr %[[VFN]] to i64 -// CHECK: call void %[[T5]](ptr noundef nonnull align {{[0-9]+}} dereferenceable(16) %{{.*}}) [ "ptrauth"(i64 0, i64 %[[T6]], i64 53119) ] +// CHECK: call void %[[T5]](ptr noundef nonnull align {{[0-9]+}} dereferenceable(16) %{{.*}}) [ "ptrauth"(i64 0, i64 53119, i64 %[[T6]]) ] void testD0m0(D0 *a) { a->m0(); @@ -254,12 +254,12 @@ void testD0m0(D0 *a) { // CHECK-LABEL: define{{.*}} void @_Z8testD0m1P2D0( // CHECK: %[[VTABLE:[a-z]+]] = load ptr, ptr %{{.*}} // CHECK: %[[T0:[0-9]+]] = ptrtoint ptr %[[VTABLE]] to i64 -// CHECK: %[[T3:[0-9]+]] = call i64 @llvm.ptrauth.auth(i64 %[[T0]]) [ "ptrauth"(i64 2, i64 0) ] +// CHECK: %[[T3:[0-9]+]] = call i64 @llvm.ptrauth.auth(i64 %[[T0]]) [ "ptrauth"(i64 2, i64 0, i64 0) ] // CHECK: %[[T4:[0-9]+]] = inttoptr i64 %[[T3]] to ptr // CHECK: %[[VFN:[a-z]+]] = getelementptr inbounds ptr, ptr %[[T4]], i64 5 // CHECK: %[[T5:[0-9]+]] = load ptr, ptr %[[VFN]] // CHECK: %[[T6:[0-9]+]] = ptrtoint ptr %[[VFN]] to i64 -// CHECK: call noundef ptr %[[T5]](ptr noundef nonnull align {{[0-9]+}} dereferenceable(16) %{{.*}}) [ "ptrauth"(i64 0, i64 %[[T6]], i64 35045) ] +// CHECK: call noundef ptr %[[T5]](ptr noundef nonnull align {{[0-9]+}} dereferenceable(16) %{{.*}}) [ "ptrauth"(i64 0, i64 35045, i64 %[[T6]]) ] void testD0m1(D0 *a) { a->m1(); @@ -268,12 +268,12 @@ void testD0m1(D0 *a) { // CHECK-LABEL: define{{.*}} void @_Z8testD0m2P2D0( // CHECK: %[[VTABLE:[a-z]+]] = load ptr, ptr %{{.*}} // CHECK: %[[T0:[0-9]+]] = ptrtoint ptr %[[VTABLE]] to i64 -// CHECK: %[[T3:[0-9]+]] = call i64 @llvm.ptrauth.auth(i64 %[[T0]]) [ "ptrauth"(i64 2, i64 0) ] +// CHECK: %[[T3:[0-9]+]] = call i64 @llvm.ptrauth.auth(i64 %[[T0]]) [ "ptrauth"(i64 2, i64 0, i64 0) ] // CHECK: %[[T4:[0-9]+]] = inttoptr i64 %[[T3]] to ptr // CHECK: %[[VFN:[a-z]+]] = getelementptr inbounds ptr, ptr %[[T4]], i64 2 // CHECK: %[[T5:[0-9]+]] = load ptr, ptr %[[VFN]] // CHECK: %[[T6:[0-9]+]] = ptrtoint ptr %[[VFN]] to i64 -// CHECK: call void %[[T5]](ptr noundef nonnull align {{[0-9]+}} dereferenceable(12) %{{.*}}) [ "ptrauth"(i64 0, i64 %[[T6]], i64 43073) ] +// CHECK: call void %[[T5]](ptr noundef nonnull align {{[0-9]+}} dereferenceable(12) %{{.*}}) [ "ptrauth"(i64 0, i64 43073, i64 %[[T6]]) ] void testD0m2(D0 *a) { a->m2(); @@ -282,12 +282,12 @@ void testD0m2(D0 *a) { // CHECK-LABEL: define{{.*}} void @_Z8testD0m3P2D0( // CHECK: %[[VTABLE:[a-z]+]] = load ptr, ptr %{{.*}} // CHECK: %[[T0:[0-9]+]] = ptrtoint ptr %[[VTABLE]] to i64 -// CHECK: %[[T3:[0-9]+]] = call i64 @llvm.ptrauth.auth(i64 %[[T0]]) [ "ptrauth"(i64 2, i64 0) ] +// CHECK: %[[T3:[0-9]+]] = call i64 @llvm.ptrauth.auth(i64 %[[T0]]) [ "ptrauth"(i64 2, i64 0, i64 0) ] // CHECK: %[[T4:[0-9]+]] = inttoptr i64 %[[T3]] to ptr // CHECK: %[[VFN:[a-z]+]] = getelementptr inbounds ptr, ptr %[[T4]], i64 6 // CHECK: %[[T5:[0-9]+]] = load ptr, ptr %[[VFN]] // CHECK: %[[T6:[0-9]+]] = ptrtoint ptr %[[VFN]] to i64 -// CHECK: call void %[[T5]](ptr noundef nonnull align {{[0-9]+}} dereferenceable(16) %{{.*}}) [ "ptrauth"(i64 0, i64 %[[T6]], i64 10565) ] +// CHECK: call void %[[T5]](ptr noundef nonnull align {{[0-9]+}} dereferenceable(16) %{{.*}}) [ "ptrauth"(i64 0, i64 10565, i64 %[[T6]]) ] void testD0m3(D0 *a) { a->m3(); @@ -297,12 +297,12 @@ void testD0m3(D0 *a) { // CHECK-LABEL: define{{.*}} void @_Z8testD1m0P2D1( // CHECK: %[[VTABLE:[a-z]+]] = load ptr, ptr %{{.*}} // CHECK: %[[T0:[0-9]+]] = ptrtoint ptr %[[VTABLE]] to i64 -// CHECK: %[[T3:[0-9]+]] = call i64 @llvm.ptrauth.auth(i64 %[[T0]]) [ "ptrauth"(i64 2, i64 0) ] +// CHECK: %[[T3:[0-9]+]] = call i64 @llvm.ptrauth.auth(i64 %[[T0]]) [ "ptrauth"(i64 2, i64 0, i64 0) ] // CHECK: %[[T4:[0-9]+]] = inttoptr i64 %[[T3]] to ptr // CHECK: %[[VFN:[a-z]+]] = getelementptr inbounds ptr, ptr %[[T4]], i64 0 // CHECK: %[[T5:[0-9]+]] = load ptr, ptr %[[VFN]] // CHECK: %[[T6:[0-9]+]] = ptrtoint ptr %[[VFN]] to i64 -// CHECK: call void %[[T5]](ptr noundef nonnull align {{[0-9]+}} dereferenceable(16) %{{.*}}) [ "ptrauth"(i64 0, i64 %[[T6]], i64 53119) ] +// CHECK: call void %[[T5]](ptr noundef nonnull align {{[0-9]+}} dereferenceable(16) %{{.*}}) [ "ptrauth"(i64 0, i64 53119, i64 %[[T6]]) ] void testD1m0(D1 *a) { a->m0(); @@ -311,12 +311,12 @@ void testD1m0(D1 *a) { // CHECK-LABEL: define{{.*}} void @_Z8testD1m1P2D1( // CHECK: %[[VTABLE:[a-z]+]] = load ptr, ptr %{{.*}} // CHECK: %[[T0:[0-9]+]] = ptrtoint ptr %[[VTABLE]] to i64 -// CHECK: %[[T3:[0-9]+]] = call i64 @llvm.ptrauth.auth(i64 %[[T0]]) [ "ptrauth"(i64 2, i64 0) ] +// CHECK: %[[T3:[0-9]+]] = call i64 @llvm.ptrauth.auth(i64 %[[T0]]) [ "ptrauth"(i64 2, i64 0, i64 0) ] // CHECK: %[[T4:[0-9]+]] = inttoptr i64 %[[T3]] to ptr // CHECK: %[[VFN:[a-z]+]] = getelementptr inbounds ptr, ptr %[[T4]], i64 5 // CHECK: %[[T5:[0-9]+]] = load ptr, ptr %[[VFN]] // CHECK: %[[T6:[0-9]+]] = ptrtoint ptr %[[VFN]] to i64 -// CHECK: call noundef ptr %[[T5]](ptr noundef nonnull align {{[0-9]+}} dereferenceable(16) %{{.*}}) [ "ptrauth"(i64 0, i64 %[[T6]], i64 52864) ] +// CHECK: call noundef ptr %[[T5]](ptr noundef nonnull align {{[0-9]+}} dereferenceable(16) %{{.*}}) [ "ptrauth"(i64 0, i64 52864, i64 %[[T6]]) ] void testD1m1(D1 *a) { a->m1(); @@ -325,12 +325,12 @@ void testD1m1(D1 *a) { // CHECK-LABEL: define{{.*}} void @_Z8testD1m2P2D1( // CHECK: %[[VTABLE:[a-z]+]] = load ptr, ptr %{{.*}} // CHECK: %[[T0:[0-9]+]] = ptrtoint ptr %[[VTABLE]] to i64 -// CHECK: %[[T3:[0-9]+]] = call i64 @llvm.ptrauth.auth(i64 %[[T0]]) [ "ptrauth"(i64 2, i64 0) ] +// CHECK: %[[T3:[0-9]+]] = call i64 @llvm.ptrauth.auth(i64 %[[T0]]) [ "ptrauth"(i64 2, i64 0, i64 0) ] // CHECK: %[[T4:[0-9]+]] = inttoptr i64 %[[T3]] to ptr // CHECK: %[[VFN:[a-z]+]] = getelementptr inbounds ptr, ptr %[[T4]], i64 2 // CHECK: %[[T5:[0-9]+]] = load ptr, ptr %[[VFN]] // CHECK: %[[T6:[0-9]+]] = ptrtoint ptr %[[VFN]] to i64 -// CHECK: call void %[[T5]](ptr noundef nonnull align {{[0-9]+}} dereferenceable(12) %{{.*}}) [ "ptrauth"(i64 0, i64 %[[T6]], i64 43073) ] +// CHECK: call void %[[T5]](ptr noundef nonnull align {{[0-9]+}} dereferenceable(12) %{{.*}}) [ "ptrauth"(i64 0, i64 43073, i64 %[[T6]]) ] void testD1m2(D1 *a) { a->m2(); @@ -340,12 +340,12 @@ void testD1m2(D1 *a) { // CHECK-LABEL: define{{.*}} void @_Z8testD2m0P2D2( // CHECK: %[[VTABLE:[a-z]+]] = load ptr, ptr %{{.*}} // CHECK: %[[T0:[0-9]+]] = ptrtoint ptr %[[VTABLE]] to i64 -// CHECK: %[[T3:[0-9]+]] = call i64 @llvm.ptrauth.auth(i64 %[[T0]]) [ "ptrauth"(i64 2, i64 0) ] +// CHECK: %[[T3:[0-9]+]] = call i64 @llvm.ptrauth.auth(i64 %[[T0]]) [ "ptrauth"(i64 2, i64 0, i64 0) ] // CHECK: %[[T4:[0-9]+]] = inttoptr i64 %[[T3]] to ptr // CHECK: %[[VFN:[a-z]+]] = getelementptr inbounds ptr, ptr %[[T4]], i64 0 // CHECK: %[[T5:[0-9]+]] = load ptr, ptr %[[VFN]] // CHECK: %[[T6:[0-9]+]] = ptrtoint ptr %[[VFN]] to i64 -// CHECK: call void %[[T5]](ptr noundef nonnull align {{[0-9]+}} dereferenceable(36) %{{.*}}) [ "ptrauth"(i64 0, i64 %[[T6]], i64 53119) ] +// CHECK: call void %[[T5]](ptr noundef nonnull align {{[0-9]+}} dereferenceable(36) %{{.*}}) [ "ptrauth"(i64 0, i64 53119, i64 %[[T6]]) ] void testD2m0(D2 *a) { a->m0(); @@ -354,12 +354,12 @@ void testD2m0(D2 *a) { // CHECK-LABEL: define{{.*}} void @_Z8testD2m1P2D2( // CHECK: %[[VTABLE:[a-z]+]] = load ptr, ptr %{{.*}} // CHECK: %[[T0:[0-9]+]] = ptrtoint ptr %[[VTABLE]] to i64 -// CHECK: %[[T3:[0-9]+]] = call i64 @llvm.ptrauth.auth(i64 %[[T0]]) [ "ptrauth"(i64 2, i64 0) ] +// CHECK: %[[T3:[0-9]+]] = call i64 @llvm.ptrauth.auth(i64 %[[T0]]) [ "ptrauth"(i64 2, i64 0, i64 0) ] // CHECK: %[[T4:[0-9]+]] = inttoptr i64 %[[T3]] to ptr // CHECK: %[[VFN:[a-z]+]] = getelementptr inbounds ptr, ptr %[[T4]], i64 5 // CHECK: %[[T5:[0-9]+]] = load ptr, ptr %[[VFN]] // CHECK: %[[T6:[0-9]+]] = ptrtoint ptr %[[VFN]] to i64 -// CHECK: call noundef ptr %[[T5]](ptr noundef nonnull align {{[0-9]+}} dereferenceable(36) %{{.*}}) [ "ptrauth"(i64 0, i64 %[[T6]], i64 35045) ] +// CHECK: call noundef ptr %[[T5]](ptr noundef nonnull align {{[0-9]+}} dereferenceable(36) %{{.*}}) [ "ptrauth"(i64 0, i64 35045, i64 %[[T6]]) ] void testD2m1(D2 *a) { a->m1(); @@ -382,12 +382,12 @@ void testD2m2D1(D2 *a) { // CHECK-LABEL: define{{.*}} void @_Z8testD2m3P2D2( // CHECK: %[[VTABLE:[a-z]+]] = load ptr, ptr %{{.*}} // CHECK: %[[T0:[0-9]+]] = ptrtoint ptr %[[VTABLE]] to i64 -// CHECK: %[[T3:[0-9]+]] = call i64 @llvm.ptrauth.auth(i64 %[[T0]]) [ "ptrauth"(i64 2, i64 0) ] +// CHECK: %[[T3:[0-9]+]] = call i64 @llvm.ptrauth.auth(i64 %[[T0]]) [ "ptrauth"(i64 2, i64 0, i64 0) ] // CHECK: %[[T4:[0-9]+]] = inttoptr i64 %[[T3]] to ptr // CHECK: %[[VFN:[a-z]+]] = getelementptr inbounds ptr, ptr %[[T4]], i64 6 // CHECK: %[[T5:[0-9]+]] = load ptr, ptr %[[VFN]] // CHECK: %[[T6:[0-9]+]] = ptrtoint ptr %[[VFN]] to i64 -// CHECK: call void %[[T5]](ptr noundef nonnull align {{[0-9]+}} dereferenceable(36) %{{.*}}) [ "ptrauth"(i64 0, i64 %[[T6]], i64 10565) ] +// CHECK: call void %[[T5]](ptr noundef nonnull align {{[0-9]+}} dereferenceable(36) %{{.*}}) [ "ptrauth"(i64 0, i64 10565, i64 %[[T6]]) ] void testD2m3(D2 *a) { a->m3(); @@ -396,12 +396,12 @@ void testD2m3(D2 *a) { // CHECK-LABEL: define{{.*}} void @_Z8testD3m0P2D3( // CHECK: %[[VTABLE:[a-z]+]] = load ptr, ptr %{{.*}} // CHECK: %[[T0:[0-9]+]] = ptrtoint ptr %[[VTABLE]] to i64 -// CHECK: %[[T3:[0-9]+]] = call i64 @llvm.ptrauth.auth(i64 %[[T0]]) [ "ptrauth"(i64 2, i64 0) ] +// CHECK: %[[T3:[0-9]+]] = call i64 @llvm.ptrauth.auth(i64 %[[T0]]) [ "ptrauth"(i64 2, i64 0, i64 0) ] // CHECK: %[[T4:[0-9]+]] = inttoptr i64 %[[T3]] to ptr // CHECK: %[[VFN:[a-z]+]] = getelementptr inbounds ptr, ptr %[[T4]], i64 0 // CHECK: %[[T5:[0-9]+]] = load ptr, ptr %[[VFN]] // CHECK: %[[T6:[0-9]+]] = ptrtoint ptr %[[VFN]] to i64 -// CHECK: call void %[[T5]](ptr noundef nonnull align {{[0-9]+}} dereferenceable(32) %{{.*}}) [ "ptrauth"(i64 0, i64 %[[T6]], i64 44578) ] +// CHECK: call void %[[T5]](ptr noundef nonnull align {{[0-9]+}} dereferenceable(32) %{{.*}}) [ "ptrauth"(i64 0, i64 44578, i64 %[[T6]]) ] void testD3m0(D3 *a) { a->m0(); @@ -410,12 +410,12 @@ void testD3m0(D3 *a) { // CHECK-LABEL: define{{.*}} void @_Z8testD3m1P2D3( // CHECK: %[[VTABLE:[a-z]+]] = load ptr, ptr %{{.*}} // CHECK: %[[T0:[0-9]+]] = ptrtoint ptr %[[VTABLE]] to i64 -// CHECK: %[[T3:[0-9]+]] = call i64 @llvm.ptrauth.auth(i64 %[[T0]]) [ "ptrauth"(i64 2, i64 0) ] +// CHECK: %[[T3:[0-9]+]] = call i64 @llvm.ptrauth.auth(i64 %[[T0]]) [ "ptrauth"(i64 2, i64 0, i64 0) ] // CHECK: %[[T4:[0-9]+]] = inttoptr i64 %[[T3]] to ptr // CHECK: %[[VFN:[a-z]+]] = getelementptr inbounds ptr, ptr %[[T4]], i64 1 // CHECK: %[[T5:[0-9]+]] = load ptr, ptr %[[VFN]] // CHECK: %[[T6:[0-9]+]] = ptrtoint ptr %[[VFN]] to i64 -// CHECK: call noundef ptr %[[T5]](ptr noundef nonnull align {{[0-9]+}} dereferenceable(32) %{{.*}}) [ "ptrauth"(i64 0, i64 %[[T6]], i64 30766) ] +// CHECK: call noundef ptr %[[T5]](ptr noundef nonnull align {{[0-9]+}} dereferenceable(32) %{{.*}}) [ "ptrauth"(i64 0, i64 30766, i64 %[[T6]]) ] void testD3m1(D3 *a) { a->m1(); @@ -427,19 +427,19 @@ void testD3m1(D3 *a) { // CHECK: %[[V0:.*]] = load ptr, ptr %[[A_ADDR]], align 8 // CHECK: %[[VTABLE:.*]] = load ptr, ptr %[[V0]], align 8 // CHECK: %[[V1:.*]] = ptrtoint ptr %[[VTABLE]] to i64 -// CHECK: %[[V2:.*]] = call i64 @llvm.ptrauth.auth(i64 %[[V1]]) [ "ptrauth"(i64 2, i64 0) ] +// CHECK: %[[V2:.*]] = call i64 @llvm.ptrauth.auth(i64 %[[V1]]) [ "ptrauth"(i64 2, i64 0, i64 0) ] // CHECK: %[[V3:.*]] = inttoptr i64 %[[V2]] to ptr // CHECK: %[[VBASE_OFFSET_PTR:.*]] = getelementptr i8, ptr %[[V3]], i64 -24 // CHECK: %[[VBASE_OFFSET:.*]] = load i64, ptr %[[VBASE_OFFSET_PTR]], align 8 // CHECK: %[[ADD_PTR:.*]] = getelementptr inbounds i8, ptr %[[V0]], i64 %[[VBASE_OFFSET]] // CHECK: %[[VTABLE1:.*]] = load ptr, ptr %[[ADD_PTR]], align 8 // CHECK: %[[V4:.*]] = ptrtoint ptr %[[VTABLE1]] to i64 -// CHECK: %[[V5:.*]] = call i64 @llvm.ptrauth.auth(i64 %[[V4]]) [ "ptrauth"(i64 2, i64 0) ] +// CHECK: %[[V5:.*]] = call i64 @llvm.ptrauth.auth(i64 %[[V4]]) [ "ptrauth"(i64 2, i64 0, i64 0) ] // CHECK: %[[V6:.*]] = inttoptr i64 %[[V5]] to ptr // CHECK: %[[VFN:.*]] = getelementptr inbounds ptr, ptr %[[V6]], i64 2 // CHECK: %[[V7:.*]] = load ptr, ptr %[[VFN]], align 8 // CHECK: %[[V8:.*]] = ptrtoint ptr %[[VFN]] to i64 -// CHECK: call void %[[V7]](ptr noundef nonnull align 8 dereferenceable(12) %[[ADD_PTR]]) [ "ptrauth"(i64 0, i64 %[[V8]], i64 43073) ] +// CHECK: call void %[[V7]](ptr noundef nonnull align 8 dereferenceable(12) %[[ADD_PTR]]) [ "ptrauth"(i64 0, i64 43073, i64 %[[V8]]) ] void testD3m2(D3 *a) { a->m2(); @@ -449,12 +449,12 @@ void testD3m2(D3 *a) { // CHECK: load ptr, ptr // CHECK: %[[VTABLE:.*]] = load ptr, ptr %{{.*}} // CHECK: %[[T2:[0-9]+]] = ptrtoint ptr %[[VTABLE]] to i64 -// CHECK: %[[T3:[0-9]+]] = call i64 @llvm.ptrauth.auth(i64 %[[T2]]) [ "ptrauth"(i64 2, i64 0) ] +// CHECK: %[[T3:[0-9]+]] = call i64 @llvm.ptrauth.auth(i64 %[[T2]]) [ "ptrauth"(i64 2, i64 0, i64 0) ] // CHECK: %[[T4:[0-9]+]] = inttoptr i64 %[[T3]] to ptr // CHECK: %[[VFN:[a-z]+]] = getelementptr inbounds ptr, ptr %[[T4]], i64 3 // CHECK: %[[T5:[0-9]+]] = load ptr, ptr %[[VFN]] // CHECK: %[[T6:[0-9]+]] = ptrtoint ptr %[[VFN]] to i64 -// CHECK: call void %[[T5]](ptr noundef nonnull align {{[0-9]+}} dereferenceable(32) %{{.*}}) #{{.*}} [ "ptrauth"(i64 0, i64 %[[T6]], i64 62452) ] +// CHECK: call void %[[T5]](ptr noundef nonnull align {{[0-9]+}} dereferenceable(32) %{{.*}}) #{{.*}} [ "ptrauth"(i64 0, i64 62452, i64 %[[T6]]) ] void testD3Destructor0(D3 *a) { delete a; @@ -464,20 +464,20 @@ void testD3Destructor0(D3 *a) { // CHECK: %[[T6:.*]] = load ptr, ptr % // CHECK: %[[VTABLE0:[a-z0-9]+]] = load ptr, ptr % // CHECK: %[[T2:[0-9]+]] = ptrtoint ptr %[[VTABLE0]] to i64 -// CHECK: %[[T3:[0-9]+]] = call i64 @llvm.ptrauth.auth(i64 %[[T2]]) [ "ptrauth"(i64 2, i64 0) ] +// CHECK: %[[T3:[0-9]+]] = call i64 @llvm.ptrauth.auth(i64 %[[T2]]) [ "ptrauth"(i64 2, i64 0, i64 0) ] // CHECK: %[[T4:[0-9]+]] = inttoptr i64 %[[T3]] to ptr // CHECK: %[[COMPLETE_OFFSET_PTR:.*]] = getelementptr inbounds i64, ptr %[[T4]], i64 -2 // CHECK: %[[T5:[0-9]+]] = load i64, ptr %[[COMPLETE_OFFSET_PTR]] // CHECK: %[[T7:[0-9]+]] = getelementptr inbounds i8, ptr %[[T6]], i64 %[[T5]] // CHECK: %[[VTABLE1:[a-z0-9]+]] = load ptr, ptr %[[T6]] // CHECK: %[[T9:[0-9]+]] = ptrtoint ptr %[[VTABLE1]] to i64 -// CHECK: %[[T10:[0-9]+]] = call i64 @llvm.ptrauth.auth(i64 %[[T9]]) [ "ptrauth"(i64 2, i64 0) ] +// CHECK: %[[T10:[0-9]+]] = call i64 @llvm.ptrauth.auth(i64 %[[T9]]) [ "ptrauth"(i64 2, i64 0, i64 0) ] // CHECK: %[[T11:[0-9]+]] = inttoptr i64 %[[T10]] to ptr // CHECK: %[[VFN:[a-z0-9]+]] = getelementptr inbounds ptr, ptr %[[T11]], i64 2 // CHECK: %[[T12:[0-9]+]] = load ptr, ptr %[[VFN]] // CHECK: %[[T13:[0-9]+]] = ptrtoint ptr %[[VFN]] to i64 -// DARWIN: %call = call noundef ptr %[[T12]](ptr noundef nonnull align {{[0-9]+}} dereferenceable(32) %{{.*}}) #{{.*}} [ "ptrauth"(i64 0, i64 %[[T13]], i64 57279) ] -// ELF: call void %[[T12]](ptr noundef nonnull align {{[0-9]+}} dereferenceable(32) %{{.*}}) #{{.*}} [ "ptrauth"(i64 0, i64 %[[T13]], i64 57279) ] +// DARWIN: %call = call noundef ptr %[[T12]](ptr noundef nonnull align {{[0-9]+}} dereferenceable(32) %{{.*}}) #{{.*}} [ "ptrauth"(i64 0, i64 57279, i64 %[[T13]]) ] +// ELF: call void %[[T12]](ptr noundef nonnull align {{[0-9]+}} dereferenceable(32) %{{.*}}) #{{.*}} [ "ptrauth"(i64 0, i64 57279, i64 %[[T13]]) ] // CHECK: call void @_ZdlPv(ptr noundef %[[T7]]) void testD3Destructor1(D3 *a) { @@ -488,13 +488,13 @@ void testD3Destructor1(D3 *a) { // CHECK: load ptr, ptr // CHECK: %[[VTABLE:.*]] = load ptr, ptr % // CHECK: %[[T2:.*]] = ptrtoint ptr %[[VTABLE]] to i64 -// CHECK: %[[T3:.*]] = call i64 @llvm.ptrauth.auth(i64 %[[T2]]) [ "ptrauth"(i64 2, i64 0) ] +// CHECK: %[[T3:.*]] = call i64 @llvm.ptrauth.auth(i64 %[[T2]]) [ "ptrauth"(i64 2, i64 0, i64 0) ] // CHECK: %[[T4:.*]] = inttoptr i64 %[[T3]] to ptr // CHECK: %[[VFN:.*]] = getelementptr inbounds ptr, ptr %[[T4]], i64 2 // CHECK: %[[T5:.*]] = load ptr, ptr %[[VFN]] // CHECK: %[[T6:.*]] = ptrtoint ptr %[[VFN]] to i64 -// DARWIN: %call = call noundef ptr %[[T5]](ptr noundef nonnull align {{[0-9]+}} dereferenceable(32) %{{.*}}) #{{.*}} [ "ptrauth"(i64 0, i64 %[[T6]], i64 57279) ] -// ELF: call void %[[T5]](ptr noundef nonnull align {{[0-9]+}} dereferenceable(32) %{{.*}}) #{{.*}} [ "ptrauth"(i64 0, i64 %[[T6]], i64 57279) ] +// DARWIN: %call = call noundef ptr %[[T5]](ptr noundef nonnull align {{[0-9]+}} dereferenceable(32) %{{.*}}) #{{.*}} [ "ptrauth"(i64 0, i64 57279, i64 %[[T6]]) ] +// ELF: call void %[[T5]](ptr noundef nonnull align {{[0-9]+}} dereferenceable(32) %{{.*}}) #{{.*}} [ "ptrauth"(i64 0, i64 57279, i64 %[[T6]]) ] void testD3Destructor2(D3 *a) { a->~D3(); @@ -514,30 +514,30 @@ void materializeConstructors() { // DARWIN-LABEL: define linkonce_odr noundef ptr @_ZN2B0C2Ev( // ELF-LABEL: define linkonce_odr void @_ZN2B0C2Ev( // CHECK: %[[THIS:.*]] = load ptr, ptr % -// CHECK: %[[T0:[0-9]+]] = call i64 @llvm.ptrauth.sign(i64 ptrtoint (ptr getelementptr inbounds inrange(-16, 40) ({ [7 x ptr] }, ptr @_ZTV2B0, i32 0, i32 0, i32 2) to i64)) [ "ptrauth"(i64 2, i64 0) ] +// CHECK: %[[T0:[0-9]+]] = call i64 @llvm.ptrauth.sign(i64 ptrtoint (ptr getelementptr inbounds inrange(-16, 40) ({ [7 x ptr] }, ptr @_ZTV2B0, i32 0, i32 0, i32 2) to i64)) [ "ptrauth"(i64 2, i64 0, i64 0) ] // CHECK: %[[SIGNED_VTADDR:[0-9]+]] = inttoptr i64 %[[T0]] to ptr // CHECK: store ptr %[[SIGNED_VTADDR]], ptr %[[THIS]] // DARWIN-LABEL: define linkonce_odr noundef ptr @_ZN2D0C2Ev( // ELF-LABEL: define linkonce_odr void @_ZN2D0C2Ev( -// CHECK: %[[T0:[0-9]+]] = call i64 @llvm.ptrauth.sign(i64 ptrtoint (ptr getelementptr inbounds inrange(-16, 56) ({ [9 x ptr] }, ptr @_ZTV2D0, i32 0, i32 0, i32 2) to i64)) [ "ptrauth"(i64 2, i64 0) ] +// CHECK: %[[T0:[0-9]+]] = call i64 @llvm.ptrauth.sign(i64 ptrtoint (ptr getelementptr inbounds inrange(-16, 56) ({ [9 x ptr] }, ptr @_ZTV2D0, i32 0, i32 0, i32 2) to i64)) [ "ptrauth"(i64 2, i64 0, i64 0) ] // CHECK: %[[SIGNED_VTADDR:[0-9]+]] = inttoptr i64 %[[T0]] to ptr // CHECK: store ptr %[[SIGNED_VTADDR]], ptr %[[THIS]] // DARWIN-LABEL: define linkonce_odr noundef ptr @_ZN2D1C2Ev( // ELF-LABEL: define linkonce_odr void @_ZN2D1C2Ev( -// CHECK: %[[T0:[0-9]+]] = call i64 @llvm.ptrauth.sign(i64 ptrtoint (ptr getelementptr inbounds inrange(-16, 48) ({ [8 x ptr] }, ptr @_ZTV2D1, i32 0, i32 0, i32 2) to i64)) [ "ptrauth"(i64 2, i64 0) ] +// CHECK: %[[T0:[0-9]+]] = call i64 @llvm.ptrauth.sign(i64 ptrtoint (ptr getelementptr inbounds inrange(-16, 48) ({ [8 x ptr] }, ptr @_ZTV2D1, i32 0, i32 0, i32 2) to i64)) [ "ptrauth"(i64 2, i64 0, i64 0) ] // CHECK: %[[SIGNED_VTADDR:[0-9]+]] = inttoptr i64 %[[T0]] to ptr // CHECK: store ptr %[[SIGNED_VTADDR]], ptr %[[THIS]] // DARWIN-LABEL: define linkonce_odr noundef ptr @_ZN2D2C2Ev( // ELF-LABEL: define linkonce_odr void @_ZN2D2C2Ev( // CHECK: %[[SLOT0:.*]] = load ptr, ptr -// CHECK: %[[SIGN_VTADDR0:[0-9]+]] = call i64 @llvm.ptrauth.sign(i64 ptrtoint (ptr getelementptr inbounds inrange(-16, 56) ({ [9 x ptr], [8 x ptr] }, ptr @_ZTV2D2, i32 0, i32 0, i32 2) to i64)) [ "ptrauth"(i64 2, i64 0) ] +// CHECK: %[[SIGN_VTADDR0:[0-9]+]] = call i64 @llvm.ptrauth.sign(i64 ptrtoint (ptr getelementptr inbounds inrange(-16, 56) ({ [9 x ptr], [8 x ptr] }, ptr @_ZTV2D2, i32 0, i32 0, i32 2) to i64)) [ "ptrauth"(i64 2, i64 0, i64 0) ] // CHECK: %[[T1:[0-9]+]] = inttoptr i64 %[[SIGN_VTADDR0]] to ptr // CHECK: store ptr %[[T1]], ptr %[[SLOT0]] // CHECK: %[[T3:[a-z0-9.]+]] = getelementptr inbounds i8, ptr %[[SLOT0]], i64 16 -// CHECK: %[[SIGN_VTADDR1:[0-9]+]] = call i64 @llvm.ptrauth.sign(i64 ptrtoint (ptr getelementptr inbounds inrange(-16, 48) ({ [9 x ptr], [8 x ptr] }, ptr @_ZTV2D2, i32 0, i32 1, i32 2) to i64)) [ "ptrauth"(i64 2, i64 0) ] +// CHECK: %[[SIGN_VTADDR1:[0-9]+]] = call i64 @llvm.ptrauth.sign(i64 ptrtoint (ptr getelementptr inbounds inrange(-16, 48) ({ [9 x ptr], [8 x ptr] }, ptr @_ZTV2D2, i32 0, i32 1, i32 2) to i64)) [ "ptrauth"(i64 2, i64 0, i64 0) ] // CHECK: %[[T5:[0-9]+]] = inttoptr i64 %[[SIGN_VTADDR1]] to ptr // CHECK: store ptr %[[T5]], ptr %[[T3]] @@ -547,25 +547,25 @@ void materializeConstructors() { // CHECK: %[[VTT:[a-z0-9]+]] = load ptr, ptr %{{.*}} // CHECK: %[[T0:[0-9]+]] = load ptr, ptr %[[VTT]] // CHECK: %[[T1:[0-9]+]] = ptrtoint ptr %[[T0]] to i64 -// CHECK: %[[T2:[0-9]+]] = call i64 @llvm.ptrauth.auth(i64 %[[T1]]) [ "ptrauth"(i64 2, i64 0) ] +// CHECK: %[[T2:[0-9]+]] = call i64 @llvm.ptrauth.auth(i64 %[[T1]]) [ "ptrauth"(i64 2, i64 0, i64 0) ] // CHECK: %[[T3:[0-9]+]] = inttoptr i64 %[[T2]] to ptr // CHECK: %[[VTADDR0:[0-9]+]] = ptrtoint ptr %[[T3]] to i64 -// CHECK: %[[T7:[0-9]+]] = call i64 @llvm.ptrauth.sign(i64 %[[VTADDR0]]) [ "ptrauth"(i64 2, i64 0) ] +// CHECK: %[[T7:[0-9]+]] = call i64 @llvm.ptrauth.sign(i64 %[[VTADDR0]]) [ "ptrauth"(i64 2, i64 0, i64 0) ] // CHECK: %[[SIGN_VTADDR0:[0-9]+]] = inttoptr i64 %[[T7]] to ptr // CHECK: store ptr %[[SIGN_VTADDR0]], ptr %[[SLOT0]] // CHECK: %[[T9:[0-9]+]] = getelementptr inbounds ptr, ptr %[[VTT]], i64 1 // CHECK: %[[T10:[0-9]+]] = load ptr, ptr %[[T9]] // CHECK: %[[T11:[0-9]+]] = ptrtoint ptr %[[T10]] to i64 -// CHECK: %[[T12:[0-9]+]] = call i64 @llvm.ptrauth.auth(i64 %[[T11]]) [ "ptrauth"(i64 2, i64 0) ] +// CHECK: %[[T12:[0-9]+]] = call i64 @llvm.ptrauth.auth(i64 %[[T11]]) [ "ptrauth"(i64 2, i64 0, i64 0) ] // CHECK: %[[T13:[0-9]+]] = inttoptr i64 %[[T12]] to ptr // CHECK: %[[VTABLE:[a-z]+]] = load ptr, ptr %[[THIS1]] // CHECK: %[[T15:[0-9]+]] = ptrtoint ptr %[[VTABLE]] to i64 -// CHECK: %[[T16:[0-9]+]] = call i64 @llvm.ptrauth.auth(i64 %[[T15]]) [ "ptrauth"(i64 2, i64 0) ] +// CHECK: %[[T16:[0-9]+]] = call i64 @llvm.ptrauth.auth(i64 %[[T15]]) [ "ptrauth"(i64 2, i64 0, i64 0) ] // CHECK: %[[T17:[0-9]+]] = inttoptr i64 %[[T16]] to ptr // CHECK: %[[VBASE_OFFSET_PTR:[a-z.]+]] = getelementptr i8, ptr %[[T17]], i64 -24 // CHECK: %[[VBASE_OFFSET:[a-z.]+]] = load i64, ptr %[[VBASE_OFFSET_PTR]] // CHECK: %[[T20:[a-z.]+]] = getelementptr inbounds i8, ptr %[[THIS1]], i64 %[[VBASE_OFFSET]] // CHECK: %[[VTADDR1:[0-9]+]] = ptrtoint ptr %[[T13]] to i64 -// CHECK: %[[T23:[0-9]+]] = call i64 @llvm.ptrauth.sign(i64 %[[VTADDR1]]) [ "ptrauth"(i64 2, i64 0) ] +// CHECK: %[[T23:[0-9]+]] = call i64 @llvm.ptrauth.sign(i64 %[[VTADDR1]]) [ "ptrauth"(i64 2, i64 0, i64 0) ] // CHECK: %[[SIGN_VTADDR1:[0-9]+]] = inttoptr i64 %[[T23]] to ptr // CHECK: store ptr %[[SIGN_VTADDR1]], ptr %[[T20]] diff --git a/clang/test/CodeGenCXX/ptrauth-vtable-virtual-inheritance-thunk.cpp b/clang/test/CodeGenCXX/ptrauth-vtable-virtual-inheritance-thunk.cpp index ce1c258cb8730..8a155d0031ad2 100644 --- a/clang/test/CodeGenCXX/ptrauth-vtable-virtual-inheritance-thunk.cpp +++ b/clang/test/CodeGenCXX/ptrauth-vtable-virtual-inheritance-thunk.cpp @@ -292,26 +292,26 @@ int main() { // And check the thunks // DARWIN: ptr @_ZTv0_n48_N1CD1Ev(ptr noundef %this) // ELF: void @_ZTv0_n48_N1CD1Ev(ptr noundef %this) -// CHECK: [[TEMP:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[TEMP:%.*]]) [ "ptrauth"(i64 2, i64 62866) ] +// CHECK: [[TEMP:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[TEMP:%.*]]) [ "ptrauth"(i64 2, i64 62866, i64 0) ] // CHECK: void @_ZTv0_n48_N1CD0Ev(ptr noundef %this) -// CHECK: [[TEMP:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[TEMP:%.*]]) [ "ptrauth"(i64 2, i64 62866) ] +// CHECK: [[TEMP:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[TEMP:%.*]]) [ "ptrauth"(i64 2, i64 62866, i64 0) ] // DARWIN: ptr @_ZTv0_n48_N1DD1Ev(ptr noundef %this) // ELF: void @_ZTv0_n48_N1DD1Ev(ptr noundef %this) -// CHECK: [[TEMP:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[TEMP:%.*]]) [ "ptrauth"(i64 2, i64 62866) ] +// CHECK: [[TEMP:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[TEMP:%.*]]) [ "ptrauth"(i64 2, i64 62866, i64 0) ] // CHECK: void @_ZTv0_n48_N1DD0Ev(ptr noundef %this) -// CHECK: [[TEMP:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[TEMP:%.*]]) [ "ptrauth"(i64 2, i64 62866) ] +// CHECK: [[TEMP:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[TEMP:%.*]]) [ "ptrauth"(i64 2, i64 62866, i64 0) ] // CHECK: void @_ZTv0_n48_N1FD0EvU11__vtptrauthILj0Lb0Lj62866E(ptr noundef %this) -// CHECK: [[TEMP:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[TEMP:%.*]]) [ "ptrauth"(i64 2, i64 62866) ] +// CHECK: [[TEMP:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[TEMP:%.*]]) [ "ptrauth"(i64 2, i64 62866, i64 0) ] // CHECK: void @_ZTv0_n48_N1FD0Ev(ptr noundef %this) -// CHECK: [[TEMP:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[TEMP:%.*]]) [ "ptrauth"(i64 2, i64 12810) ] +// CHECK: [[TEMP:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[TEMP:%.*]]) [ "ptrauth"(i64 2, i64 12810, i64 0) ] // CHECK: void @_ZTv0_n48_N1GD0Ev(ptr noundef %this) -// CHECK: [[TEMP:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[TEMP:%.*]]) [ "ptrauth"(i64 2, i64 12810) ] +// CHECK: [[TEMP:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[TEMP:%.*]]) [ "ptrauth"(i64 2, i64 12810, i64 0) ] // CHECK: void @_ZTv0_n48_N1GD0EvU11__vtptrauthILj0Lb0Lj62866E(ptr noundef %this) -// CHECK: [[TEMP:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[TEMP:%.*]]) [ "ptrauth"(i64 2, i64 62866) ] +// CHECK: [[TEMP:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[TEMP:%.*]]) [ "ptrauth"(i64 2, i64 62866, i64 0) ] diff --git a/clang/test/CodeGenCXX/ptrauth.cpp b/clang/test/CodeGenCXX/ptrauth.cpp index a2fc418f306ff..832b305b3e3bf 100644 --- a/clang/test/CodeGenCXX/ptrauth.cpp +++ b/clang/test/CodeGenCXX/ptrauth.cpp @@ -5,7 +5,7 @@ void f(void); auto &f_ref = f; // CHECK: define {{(dso_local )?}}void @_Z1gv( -// CHECK: call void ptrauth (ptr @_Z1fv, i32 0)() [ "ptrauth"(i64 0, i64 0) ] +// CHECK: call void ptrauth (ptr @_Z1fv, i32 0)() [ "ptrauth"(i64 0, i64 0, i64 0) ] void g() { f_ref(); } diff --git a/clang/test/CodeGenCXX/ubsan-vtable-checks.cpp b/clang/test/CodeGenCXX/ubsan-vtable-checks.cpp index c0a6cccb27725..96f5392c7154c 100644 --- a/clang/test/CodeGenCXX/ubsan-vtable-checks.cpp +++ b/clang/test/CodeGenCXX/ubsan-vtable-checks.cpp @@ -39,7 +39,7 @@ int get_v(T* t) { // Verify that we authenticate for the actual vcall // CHECK-PTRAUTH: [[CAST_VTABLE:%.*]] = ptrtoint ptr %vtable2 to i64 - // CHECK-PTRAUTH: [[AUTHED_INT:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[CAST_VTABLE]]) [ "ptrauth"(i64 2, i64 {{%.*}}, i64 17113) ] + // CHECK-PTRAUTH: [[AUTHED_INT:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[CAST_VTABLE]]) [ "ptrauth"(i64 2, i64 17113, i64 {{%.*}}) ] // CHECK-PTRAUTH: [[AUTHED_PTR:%.*]] = inttoptr i64 [[AUTHED_INT]] to ptr // CHECK-PTRAUTH: {{%.*}} = getelementptr inbounds ptr, ptr [[AUTHED_PTR]], i64 2 return t->v(); @@ -66,7 +66,7 @@ void delete_it(T *t) { // ptrauth for the virtual function load // CHECK-PTRAUTH: [[VTABLE2:%.*]] = load ptr, ptr {{.*}} // CHECK-PTRAUTH: [[CAST_VTABLE:%.*]] = ptrtoint ptr [[VTABLE2]] to i64 - // CHECK-PTRAUTH: [[AUTHED_INT:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[CAST_VTABLE]]) [ "ptrauth"(i64 2, i64 %{{.*}}, i64 17113) ] + // CHECK-PTRAUTH: [[AUTHED_INT:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[CAST_VTABLE]]) [ "ptrauth"(i64 2, i64 17113, i64 %{{.*}}) ] // CHECK-PTRAUTH: [[AUTHED_PTR:%.*]] = inttoptr i64 [[AUTHED_INT]] to ptr // CHECK-PTRAUTH: getelementptr inbounds ptr, ptr // CHECK-PTRAUTH {{%.*}} = getelementptr inbounds ptr, ptr [[AUTHED_PTR]], i64 1 @@ -87,7 +87,7 @@ U* dyncast(T *t) { // CHECK-PTRAUTH: {{%.*}} = mul i64 [[STRIPPED_INT]], {{.*}} // CHECK-VPTR: call void @__ubsan_handle_dynamic_type_cache_miss_abort // CHECK-PTRAUTH: [[CAST_VTABLE:%.*]] = ptrtoint ptr %vtable1 to i64 - // CHECK-PTRAUTH: [[AUTHED_INT:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[CAST_VTABLE]]) [ "ptrauth"(i64 2, i64 {{%.*}}, i64 17113) ] + // CHECK-PTRAUTH: [[AUTHED_INT:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[CAST_VTABLE]]) [ "ptrauth"(i64 2, i64 17113, i64 {{%.*}}) ] // CHECK-PTRAUTH: [[AUTHED_PTR:%.*]] = inttoptr i64 [[AUTHED_INT]] to ptr // CHECK-PTRAUTH: {{%.*}} = load volatile i8, ptr [[AUTHED_PTR]], align 8 // Second, we check that dynamic_cast is actually called once the type check is done. diff --git a/clang/test/CodeGenObjC/ptrauth-block-descriptor-pointer.m b/clang/test/CodeGenObjC/ptrauth-block-descriptor-pointer.m index aa459e9397fa2..a74c84180db1f 100644 --- a/clang/test/CodeGenObjC/ptrauth-block-descriptor-pointer.m +++ b/clang/test/CodeGenObjC/ptrauth-block-descriptor-pointer.m @@ -28,7 +28,7 @@ void b(int p) { // CHECK: [[BLOCK:%.*]] = alloca <{ ptr, i32, i32, ptr, ptr, i32 }> // CHECK: [[BLOCK_DESCRIPTOR_REF:%.*]] = getelementptr inbounds nuw <{ {{.*}} }>, ptr [[BLOCK]], i32 0, i32 4 // CHECK: [[BLOCK_DESCRIPTOR_REF_INT:%.*]] = ptrtoint ptr [[BLOCK_DESCRIPTOR_REF]] to i64 - // CHECK: [[SIGNED_REF:%.*]] = call i64 @llvm.ptrauth.sign(i64 ptrtoint (ptr @"__block_descriptor_36_e5_v8\01?0l" to i64)) [ "ptrauth"(i64 2, i64 [[BLOCK_DESCRIPTOR_REF_INT]], i64 49339) ] + // CHECK: [[SIGNED_REF:%.*]] = call i64 @llvm.ptrauth.sign(i64 ptrtoint (ptr @"__block_descriptor_36_e5_v8\01?0l" to i64)) [ "ptrauth"(i64 2, i64 49339, i64 [[BLOCK_DESCRIPTOR_REF_INT]]) ] // CHECK: [[SIGNED_REF_PTR:%.*]] = inttoptr i64 [[SIGNED_REF]] to ptr // CHECK: store ptr [[SIGNED_REF_PTR]], ptr [[BLOCK_DESCRIPTOR_REF]] diff --git a/clang/test/CodeGenObjC/ptrauth-block-isa.m b/clang/test/CodeGenObjC/ptrauth-block-isa.m index 3f8e527ccb3a4..f759c0d811c07 100644 --- a/clang/test/CodeGenObjC/ptrauth-block-isa.m +++ b/clang/test/CodeGenObjC/ptrauth-block-isa.m @@ -16,7 +16,7 @@ void test_block_literal(int i) { // CHECK-NEXT: [[BLOCK:%.*]] = alloca [[BLOCK_T:.*]], align // CHECK: [[ISAPTRADDR:%.*]] = getelementptr inbounds nuw [[BLOCK_T]], ptr [[BLOCK]], i32 0, i32 0 // CHECK-NEXT: [[ISAPTRADDR_I:%.*]] = ptrtoint ptr [[ISAPTRADDR]] to i64 - // CHECK-NEXT: [[SIGNEDISA:%.*]] = call i64 @llvm.ptrauth.sign(i64 ptrtoint (ptr @_NSConcreteStackBlock to i64)) [ "ptrauth"(i64 2, i64 [[ISAPTRADDR_I]], i64 27361) ] + // CHECK-NEXT: [[SIGNEDISA:%.*]] = call i64 @llvm.ptrauth.sign(i64 ptrtoint (ptr @_NSConcreteStackBlock to i64)) [ "ptrauth"(i64 2, i64 27361, i64 [[ISAPTRADDR_I]]) ] // CHECK-NEXT: [[SIGNEDISAPTR:%.*]] = inttoptr i64 [[SIGNEDISA]] to ptr // CHECK-NEXT: store ptr [[SIGNEDISAPTR]], ptr [[ISAPTRADDR]] use_block(^{return i;}); @@ -30,7 +30,7 @@ void test_conversion(id a) { // CHECK-NEXT: [[BLOCK:%.*]] = alloca [[BLOCK_T:.*]], align // CHECK: [[ISAPTRADDR:%.*]] = getelementptr inbounds nuw [[BLOCK_T]], ptr [[BLOCK]], i32 0, i32 0 // CHECK-NEXT: [[ISAPTRADDR_I:%.*]] = ptrtoint ptr [[ISAPTRADDR]] to i64 - // CHECK-NEXT: [[SIGNEDISA:%.*]] = call i64 @llvm.ptrauth.sign(i64 ptrtoint (ptr @_NSConcreteStackBlock to i64)) [ "ptrauth"(i64 2, i64 [[ISAPTRADDR_I]], i64 27361) ] + // CHECK-NEXT: [[SIGNEDISA:%.*]] = call i64 @llvm.ptrauth.sign(i64 ptrtoint (ptr @_NSConcreteStackBlock to i64)) [ "ptrauth"(i64 2, i64 27361, i64 [[ISAPTRADDR_I]]) ] // CHECK-NEXT: [[SIGNEDISAPTR:%.*]] = inttoptr i64 [[SIGNEDISA]] to ptr // CHECK-NEXT: store ptr [[SIGNEDISAPTR]], ptr [[ISAPTRADDR]] test_conversion_helper(^{ diff --git a/clang/test/CodeGenObjC/ptrauth-class.m b/clang/test/CodeGenObjC/ptrauth-class.m index 57422e7bdfd94..3ccbf4e12d425 100644 --- a/clang/test/CodeGenObjC/ptrauth-class.m +++ b/clang/test/CodeGenObjC/ptrauth-class.m @@ -33,7 +33,7 @@ void setTestStructIsa(struct TestStruct *t, Class c) { // CHECK: [[C:%.*]] = load ptr, ptr %c.addr, align 8 // CHECK: [[CAST_ISA_SLOT:%.*]] = ptrtoint ptr [[ISA_SLOT]] to i64 // CHECK: [[CAST_C:%.*]] = ptrtoint ptr [[C]] to i64 - // CHECK: [[AUTHENTICATED:%.*]] = call i64 @llvm.ptrauth.sign(i64 [[CAST_C]]) [ "ptrauth"(i64 2, i64 [[CAST_ISA_SLOT]], i64 1234) ] + // CHECK: [[AUTHENTICATED:%.*]] = call i64 @llvm.ptrauth.sign(i64 [[CAST_C]]) [ "ptrauth"(i64 2, i64 1234, i64 [[CAST_ISA_SLOT]]) ] } // CHECK-LABEL: define void @setTestClassIsa(ptr %t, ptr %c) #0 { @@ -49,7 +49,7 @@ void setTestClassIsa(TestClass *t, Class c) { // CHECK: [[C_VALUE:%.*]] = load ptr, ptr [[C_ADDR]], align 8 // CHECK: [[CAST_ISA_SLOT:%.*]] = ptrtoint ptr [[ADDED_PTR]] to i64 // CHECK: [[CAST_C_VALUE:%.*]] = ptrtoint ptr [[C_VALUE]] to i64 - // CHECK: [[SIGNED:%.*]] = call i64 @llvm.ptrauth.sign(i64 [[CAST_C_VALUE]]) [ "ptrauth"(i64 2, i64 [[CAST_ISA_SLOT]], i64 1234) ] + // CHECK: [[SIGNED:%.*]] = call i64 @llvm.ptrauth.sign(i64 [[CAST_C_VALUE]]) [ "ptrauth"(i64 2, i64 1234, i64 [[CAST_ISA_SLOT]]) ] } // CHECK-LABEL: define ptr @getTestStructIsa(ptr %t) #0 { @@ -61,7 +61,7 @@ Class getTestStructIsa(struct TestStruct *t) { // CHECK: [[ISA_VALUE:%.*]] = load ptr, ptr [[ISA_SLOT]], align 8 // CHECK: [[CAST_ISA_SLOT:%.*]] = ptrtoint ptr %isa to i64 // CHECK: [[CAST_ISA_VALUE:%.*]] = ptrtoint ptr [[ISA_VALUE]] to i64 - // CHECK: [[SIGNED_VALUE:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[CAST_ISA_VALUE]]) [ "ptrauth"(i64 2, i64 [[CAST_ISA_SLOT]], i64 1234) ] + // CHECK: [[SIGNED_VALUE:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[CAST_ISA_VALUE]]) [ "ptrauth"(i64 2, i64 1234, i64 [[CAST_ISA_SLOT]]) ] } // CHECK-LABEL: define ptr @getTestClassIsa(ptr %t) #0 { @@ -76,7 +76,7 @@ Class getTestClassIsa(TestClass *t) { // CHECK: [[INT_VALUE:%.*]] = ptrtoint ptr [[ADD_PTR]] to i64 // CHECK: [[NULL_CHECK:%.*]] = icmp ne ptr [[LOADED_VALUE]], null // CHECK: [[CAST_VALUE:%.*]] = ptrtoint ptr [[LOADED_VALUE]] to i64 - // CHECK: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[CAST_VALUE]]) [ "ptrauth"(i64 2, i64 [[INT_VALUE]], i64 1234) ] + // CHECK: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[CAST_VALUE]]) [ "ptrauth"(i64 2, i64 1234, i64 [[INT_VALUE]]) ] } // Just enough to verify we do actually authenticate qualified Class @@ -92,7 +92,7 @@ Class getTestConstClassIsa(TestConstClass *t) { // CHECK: [[INT_VALUE:%.*]] = ptrtoint ptr [[ADD_PTR]] to i64 // CHECK: [[NULL_CHECK:%.*]] = icmp ne ptr [[LOADED_VALUE]], null // CHECK: [[CAST_VALUE:%.*]] = ptrtoint ptr [[LOADED_VALUE]] to i64 - // CHECK: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[CAST_VALUE]]) [ "ptrauth"(i64 2, i64 [[INT_VALUE]], i64 1234) ] + // CHECK: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[CAST_VALUE]]) [ "ptrauth"(i64 2, i64 1234, i64 [[INT_VALUE]]) ] } #endif diff --git a/clang/test/CodeGenObjC/ptrauth-objc-interface-selector.m b/clang/test/CodeGenObjC/ptrauth-objc-interface-selector.m index e6e408810265a..7aa567291380f 100644 --- a/clang/test/CodeGenObjC/ptrauth-objc-interface-selector.m +++ b/clang/test/CodeGenObjC/ptrauth-objc-interface-selector.m @@ -31,31 +31,31 @@ @interface Test { @end // CHECK-AUTHENTICATED-SEL-LABEL: define internal ptr @"\01-[Test test:]" -// CHECK-AUTHENTICATED-SEL: {{%.*}} = call i64 @llvm.ptrauth.resign(i64 {{%.*}}) [ "ptrauth"(i64 3, i64 {{%.*}}, i64 22466), "ptrauth"(i64 3, i64 {{%.*}}, i64 22466) ] +// CHECK-AUTHENTICATED-SEL: {{%.*}} = call i64 @llvm.ptrauth.resign(i64 {{%.*}}) [ "ptrauth"(i64 3, i64 22466, i64 {{%.*}}), "ptrauth"(i64 3, i64 22466, i64 {{%.*}}) ] // CHECK-AUTHENTICATED-SEL: {{%.*}} = load volatile ptr, ptr {{%.*}}, align 8 -// CHECK-AUTHENTICATED-SEL: {{%.*}} = call i64 @llvm.ptrauth.resign(i64 {{%.*}}) [ "ptrauth"(i64 3, i64 {{%.*}}, i64 22466), "ptrauth"(i64 3, i64 {{%.*}}, i64 22466) ] +// CHECK-AUTHENTICATED-SEL: {{%.*}} = call i64 @llvm.ptrauth.resign(i64 {{%.*}}) [ "ptrauth"(i64 3, i64 22466, i64 {{%.*}}), "ptrauth"(i64 3, i64 22466, i64 {{%.*}}) ] // CHECK-AUTHENTICATED-SEL: {{%.*}} = ptrtoint ptr {{%.*}} to i64 // CHECK-AUTHENTICATED-SEL: {{%.*}} = ptrtoint ptr {{%.*}} to i64 -// CHECK-AUTHENTICATED-SEL: {{%.*}} = call i64 @llvm.ptrauth.resign(i64 {{%.*}}) [ "ptrauth"(i64 3, i64 {{%.*}}, i64 22467), "ptrauth"(i64 3, i64 {{%.*}}, i64 22467) ] -// CHECK-AUTHENTICATED-SEL: {{%.*}} = call i64 @llvm.ptrauth.auth(i64 {{%.*}}) [ "ptrauth"(i64 3, i64 {{%.*}}, i64 22466) ] +// CHECK-AUTHENTICATED-SEL: {{%.*}} = call i64 @llvm.ptrauth.resign(i64 {{%.*}}) [ "ptrauth"(i64 3, i64 22467, i64 {{%.*}}), "ptrauth"(i64 3, i64 22467, i64 {{%.*}}) ] +// CHECK-AUTHENTICATED-SEL: {{%.*}} = call i64 @llvm.ptrauth.auth(i64 {{%.*}}) [ "ptrauth"(i64 3, i64 22466, i64 {{%.*}}) ] // CHECK-AUTHENTICATED-SEL-LABEL: define internal ptr @"\01-[Test auto_sel_property]" -// CHECK-AUTHENTICATED-SEL: {{%.*}} = call i64 @llvm.ptrauth.auth(i64 {{%.*}}) [ "ptrauth"(i64 3, i64 {{%.*}}, i64 22466) ] +// CHECK-AUTHENTICATED-SEL: {{%.*}} = call i64 @llvm.ptrauth.auth(i64 {{%.*}}) [ "ptrauth"(i64 3, i64 22466, i64 {{%.*}}) ] // CHECK-AUTHENTICATED-SEL-LABEL: define internal void @"\01-[Test setAuto_sel_property:]" -// CHECK-AUTHENTICATED-SEL: {{%.*}} = call i64 @llvm.ptrauth.sign(i64 {{%.*}}) [ "ptrauth"(i64 3, i64 {{%.*}}, i64 22466) ] +// CHECK-AUTHENTICATED-SEL: {{%.*}} = call i64 @llvm.ptrauth.sign(i64 {{%.*}}) [ "ptrauth"(i64 3, i64 22466, i64 {{%.*}}) ] // CHECK-AUTHENTICATED-SEL-LABEL: define internal ptr @"\01-[Test const_auto_sel_property]" -// CHECK-AUTHENTICATED-SEL: {{%.*}} = call i64 @llvm.ptrauth.auth(i64 {{%.*}}) [ "ptrauth"(i64 3, i64 {{%.*}}, i64 22466) ] +// CHECK-AUTHENTICATED-SEL: {{%.*}} = call i64 @llvm.ptrauth.auth(i64 {{%.*}}) [ "ptrauth"(i64 3, i64 22466, i64 {{%.*}}) ] // CHECK-AUTHENTICATED-SEL-LABEL: define internal void @"\01-[Test setConst_auto_sel_property:]" -// CHECK-AUTHENTICATED-SEL: {{%.*}} = call i64 @llvm.ptrauth.sign(i64 {{%.*}}) [ "ptrauth"(i64 3, i64 {{%.*}}, i64 22466) ] +// CHECK-AUTHENTICATED-SEL: {{%.*}} = call i64 @llvm.ptrauth.sign(i64 {{%.*}}) [ "ptrauth"(i64 3, i64 22466, i64 {{%.*}}) ] // CHECK-AUTHENTICATED-SEL-LABEL: define internal ptr @"\01-[Test volatile_auto_sel_property]" -// CHECK-AUTHENTICATED-SEL: {{%.*}} = call i64 @llvm.ptrauth.auth(i64 {{%.*}}) [ "ptrauth"(i64 3, i64 {{%.*}}, i64 22466) ] +// CHECK-AUTHENTICATED-SEL: {{%.*}} = call i64 @llvm.ptrauth.auth(i64 {{%.*}}) [ "ptrauth"(i64 3, i64 22466, i64 {{%.*}}) ] // CHECK-AUTHENTICATED-SEL-LABEL: define internal void @"\01-[Test setVolatile_auto_sel_property:]" -// CHECK-AUTHENTICATED-SEL: {{%.*}} = call i64 @llvm.ptrauth.sign(i64 {{%.*}}) [ "ptrauth"(i64 3, i64 {{%.*}}, i64 22466) ] +// CHECK-AUTHENTICATED-SEL: {{%.*}} = call i64 @llvm.ptrauth.sign(i64 {{%.*}}) [ "ptrauth"(i64 3, i64 22466, i64 {{%.*}}) ] @implementation Test - (SEL)test:(Test *)in { @@ -77,7 +77,7 @@ void auto_sel(Test *out, Test *in) { // CHECK-AUTHENTICATED-SEL: [[CAST_DST_ADDR:%.*]] = ptrtoint ptr [[DST_ADDR]] to i64 // CHECK-AUTHENTICATED-SEL: [[CAST_SRC_ADDR:%.*]] = ptrtoint ptr [[SRC_ADDR]] to i64 // CHECK-AUTHENTICATED-SEL: [[SRC_SEL:%.*]] = ptrtoint ptr [[SRC_SEL_ADDR:%.*]] to i64 -// CHECK-AUTHENTICATED-SEL: {{%.*}} = call i64 @llvm.ptrauth.resign(i64 [[SRC_SEL]]) [ "ptrauth"(i64 3, i64 [[CAST_DST_ADDR]], i64 22466), "ptrauth"(i64 3, i64 [[CAST_SRC_ADDR]], i64 22466) ] +// CHECK-AUTHENTICATED-SEL: {{%.*}} = call i64 @llvm.ptrauth.resign(i64 [[SRC_SEL]]) [ "ptrauth"(i64 3, i64 22466, i64 [[CAST_DST_ADDR]]), "ptrauth"(i64 3, i64 22466, i64 [[CAST_SRC_ADDR]]) ] // CHECK-UNAUTHENTICATED-SEL-LABEL: define void @auto_sel SEL const_auto_sel(Test *in) { @@ -86,7 +86,7 @@ SEL const_auto_sel(Test *in) { // CHECK-AUTHENTICATED-SEL-LABEL: define ptr @const_auto_sel // CHECK-AUTHENTICATED-SEL: {{%.*}} = ptrtoint ptr {{%.*}} to i64 -// CHECK-AUTHENTICATED-SEL: [[AUTHENTICATED:%.*]] = call i64 @llvm.ptrauth.auth(i64 {{%.*}}) [ "ptrauth"(i64 3, i64 {{%.*}}, i64 22466) ] +// CHECK-AUTHENTICATED-SEL: [[AUTHENTICATED:%.*]] = call i64 @llvm.ptrauth.auth(i64 {{%.*}}) [ "ptrauth"(i64 3, i64 22466, i64 {{%.*}}) ] // CHECK-AUTHENTICATED-SEL: [[RESULT:%.*]] = inttoptr i64 [[AUTHENTICATED]] to ptr void volatile_auto_sel(Test *out, Test *in) { @@ -101,7 +101,7 @@ void volatile_auto_sel(Test *out, Test *in) { // CHECK-AUTHENTICATED-SEL: [[CAST_DST_ADDR:%.*]] = ptrtoint ptr [[DST_ADDR]] to i64 // CHECK-AUTHENTICATED-SEL: [[CAST_SRC_ADDR:%.*]] = ptrtoint ptr [[SRC_ADDR]] to i64 // CHECK-AUTHENTICATED-SEL: [[SRC_SEL:%.*]] = ptrtoint ptr [[SRC_SEL_ADDR:%.*]] to i64 -// CHECK-AUTHENTICATED-SEL: {{%.*}} = call i64 @llvm.ptrauth.resign(i64 [[SRC_SEL]]) [ "ptrauth"(i64 3, i64 [[CAST_DST_ADDR]], i64 22466), "ptrauth"(i64 3, i64 [[CAST_SRC_ADDR]], i64 22466) ] +// CHECK-AUTHENTICATED-SEL: {{%.*}} = call i64 @llvm.ptrauth.resign(i64 [[SRC_SEL]]) [ "ptrauth"(i64 3, i64 22466, i64 [[CAST_DST_ADDR]]), "ptrauth"(i64 3, i64 22466, i64 [[CAST_SRC_ADDR]]) ] void manual(Test *out, Test *in) { out->manual = in->manual; @@ -115,7 +115,7 @@ void manual(Test *out, Test *in) { // CHECK-AUTHENTICATED-SEL: [[CAST_DST_ADDR:%.*]] = ptrtoint ptr [[DST_ADDR]] to i64 // CHECK-AUTHENTICATED-SEL: [[CAST_SRC_ADDR:%.*]] = ptrtoint ptr [[SRC_ADDR]] to i64 // CHECK-AUTHENTICATED-SEL: [[SRC_SEL:%.*]] = ptrtoint ptr [[SRC_SEL_ADDR:%.*]] to i64 -// CHECK-AUTHENTICATED-SEL: {{%.*}} = call i64 @llvm.ptrauth.resign(i64 [[SRC_SEL]]) [ "ptrauth"(i64 3, i64 [[CAST_DST_ADDR]], i64 22467), "ptrauth"(i64 3, i64 [[CAST_SRC_ADDR]], i64 22467) ] +// CHECK-AUTHENTICATED-SEL: {{%.*}} = call i64 @llvm.ptrauth.resign(i64 [[SRC_SEL]]) [ "ptrauth"(i64 3, i64 22467, i64 [[CAST_DST_ADDR]]), "ptrauth"(i64 3, i64 22467, i64 [[CAST_SRC_ADDR]]) ] // CHECK-UNAUTHENTICATED-SEL-LABEL: define void @manual // CHECK-UNAUTHENTICATED-SEL: [[V0:%.*]] = load ptr, ptr %out.addr @@ -125,4 +125,4 @@ void manual(Test *out, Test *in) { // CHECK-UNAUTHENTICATED-SEL: [[CAST_DST_ADDR:%.*]] = ptrtoint ptr [[DST_ADDR]] to i64 // CHECK-UNAUTHENTICATED-SEL: [[CAST_SRC_ADDR:%.*]] = ptrtoint ptr [[SRC_ADDR]] to i64 // CHECK-UNAUTHENTICATED-SEL: [[SRC_SEL:%.*]] = ptrtoint ptr [[SRC_SEL_ADDR:%.*]] to i64 -// CHECK-UNAUTHENTICATED-SEL: {{%.*}} = call i64 @llvm.ptrauth.resign(i64 [[SRC_SEL]]) [ "ptrauth"(i64 3, i64 [[CAST_DST_ADDR]], i64 22467), "ptrauth"(i64 3, i64 [[CAST_SRC_ADDR]], i64 22467) ] +// CHECK-UNAUTHENTICATED-SEL: {{%.*}} = call i64 @llvm.ptrauth.resign(i64 [[SRC_SEL]]) [ "ptrauth"(i64 3, i64 22467, i64 [[CAST_DST_ADDR]]), "ptrauth"(i64 3, i64 22467, i64 [[CAST_SRC_ADDR]]) ] diff --git a/clang/test/CodeGenObjC/ptrauth-property-backing.m b/clang/test/CodeGenObjC/ptrauth-property-backing.m index 6e91790ec339e..c306a0e7e90cf 100644 --- a/clang/test/CodeGenObjC/ptrauth-property-backing.m +++ b/clang/test/CodeGenObjC/ptrauth-property-backing.m @@ -23,11 +23,11 @@ @implementation Root // CHECK-LABEL: define internal ptr @"\01-[Root field1]" // CHECK: [[LOAD:%.*]] = load atomic i64, ptr [[ADDR:%.*]] unordered // CHECK: [[CAST_ADDR:%.*]] = ptrtoint ptr [[ADDR]] to i64 -// CHECK: [[RESULT:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[LOAD]]) [ "ptrauth"(i64 1, i64 [[CAST_ADDR]], i64 1) ] +// CHECK: [[RESULT:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[LOAD]]) [ "ptrauth"(i64 1, i64 1, i64 [[CAST_ADDR]]) ] // CHECK-LABEL: define internal void @"\01-[Root setField1:]" // CHECK: [[CAST_ADDR:%.*]] = ptrtoint ptr [[ADDR:%.*]] to i64 -// CHECK: [[RESULT:%.*]] = call i64 @llvm.ptrauth.sign(i64 [[VALUE:%.*]]) [ "ptrauth"(i64 1, i64 [[CAST_ADDR]], i64 1) ] +// CHECK: [[RESULT:%.*]] = call i64 @llvm.ptrauth.sign(i64 [[VALUE:%.*]]) [ "ptrauth"(i64 1, i64 1, i64 [[CAST_ADDR]]) ] // CHECK: [[PHI:%.*]] = phi i64 [ 0, {{%.*}} ], [ [[RESULT]], {{%.*}} ] // CHECK: store atomic i64 [[PHI]], ptr [[ADDR]] unordered @@ -36,12 +36,12 @@ @implementation Root // CHECK: [[LOAD:%.*]] = load ptr, ptr [[ADDR:%.*]], // CHECK: [[CAST_ADDR:%.*]] = ptrtoint ptr [[ADDR]] to i64 // CHECK: [[VALUE:%.*]] = ptrtoint ptr [[LOAD]] to i64 -// CHECK: [[RESULT:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VALUE]]) [ "ptrauth"(i64 1, i64 [[CAST_ADDR:%.*]], i64 1) ] +// CHECK: [[RESULT:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[VALUE]]) [ "ptrauth"(i64 1, i64 1, i64 [[CAST_ADDR:%.*]]) ] // CHECK-LABEL: define internal void @"\01-[Root setField2:]" // CHECK: [[CAST_ADDR:%.*]] = ptrtoint ptr [[ADDR:%.*]] to i64 // CHECK: [[CAST_VALUE:%.*]] = ptrtoint ptr [[VALUE:%.*]] to i64 -// CHECK: [[SIGNED:%.*]] = call i64 @llvm.ptrauth.sign(i64 [[CAST_VALUE]]) [ "ptrauth"(i64 1, i64 [[CAST_ADDR]], i64 1) ] +// CHECK: [[SIGNED:%.*]] = call i64 @llvm.ptrauth.sign(i64 [[CAST_VALUE]]) [ "ptrauth"(i64 1, i64 1, i64 [[CAST_ADDR]]) ] // CHECK: [[RESULT:%.*]] = inttoptr i64 [[SIGNED]] to ptr // CHECK: [[PHI:%.*]] = phi ptr [ null, {{%.*}} ], [ [[RESULT]], {{%.*}} ] // CHECK: store ptr [[PHI]], ptr [[ADDR]] @@ -49,12 +49,12 @@ @implementation Root // CHECK-LABEL: define internal ptr @"\01-[Root field3]" // CHECK: [[VALUE:%.*]] = load atomic i64, ptr [[ADDR:%.*]] unordered, align 8 // CHECK: [[CASTED_ADDR:%.*]] = ptrtoint ptr [[ADDR]] to i64 -// CHECK: {{%.*}} = call i64 @llvm.ptrauth.resign(i64 [[VALUE]]) [ "ptrauth"(i64 1, i64 [[CASTED_ADDR]], i64 1), "ptrauth"(i64 0, i64 0) ] +// CHECK: {{%.*}} = call i64 @llvm.ptrauth.resign(i64 [[VALUE]]) [ "ptrauth"(i64 1, i64 1, i64 [[CASTED_ADDR]]), "ptrauth"(i64 0, i64 0, i64 0) ] // CHECK-LABEL: define internal void @"\01-[Root setField3:]" // CHECK: [[VALUE:%.*]] = load i64, ptr {{%.*}}, align 8 // CHECK: [[CASTED_ADDR:%.*]] = ptrtoint ptr {{%.*}} to i64 -// CHECK: {{%.*}} = call i64 @llvm.ptrauth.resign(i64 [[VALUE]]) [ "ptrauth"(i64 0, i64 0), "ptrauth"(i64 1, i64 [[CASTED_ADDR]], i64 1) ] +// CHECK: {{%.*}} = call i64 @llvm.ptrauth.resign(i64 [[VALUE]]) [ "ptrauth"(i64 0, i64 0, i64 0), "ptrauth"(i64 1, i64 1, i64 [[CASTED_ADDR]]) ] // CHECK: store atomic i64 // CHECK-LABEL: define internal ptr @"\01-[Root field4]" @@ -62,11 +62,11 @@ @implementation Root // CHECK: [[VALUE:%.*]] = load ptr, ptr [[ADDR:%.*]], // CHECK: [[CASTED_ADDR:%.*]] = ptrtoint ptr [[ADDR]] to i64 // CHECK: [[CAST_VALUE:%.*]] = ptrtoint ptr [[VALUE]] to i64 -// CHECK: {{%.*}} = call i64 @llvm.ptrauth.resign(i64 [[CAST_VALUE]]) [ "ptrauth"(i64 1, i64 [[CASTED_ADDR]], i64 123), "ptrauth"(i64 0, i64 0) ] +// CHECK: {{%.*}} = call i64 @llvm.ptrauth.resign(i64 [[CAST_VALUE]]) [ "ptrauth"(i64 1, i64 123, i64 [[CASTED_ADDR]]), "ptrauth"(i64 0, i64 0, i64 0) ] // CHECK-LABEL: define internal void @"\01-[Root setField4:]" // CHECK: [[CAST_ADDR:%.*]] = ptrtoint ptr {{%.*}} to i64 // CHECK: resign.nonnull: // CHECK: [[VALUE:%.*]] = ptrtoint ptr %1 to i64 -// CHECK: {{%.*}} = call i64 @llvm.ptrauth.resign(i64 [[VALUE]]) [ "ptrauth"(i64 0, i64 0), "ptrauth"(i64 1, i64 [[CAST_ADDR]], i64 123) ] +// CHECK: {{%.*}} = call i64 @llvm.ptrauth.resign(i64 [[VALUE]]) [ "ptrauth"(i64 0, i64 0, i64 0), "ptrauth"(i64 1, i64 123, i64 [[CAST_ADDR]]) ] diff --git a/clang/test/CodeGenObjCXX/ptrauth-objc-interface-selector.mm b/clang/test/CodeGenObjCXX/ptrauth-objc-interface-selector.mm index b72c84f6d03a7..8f7f2dd1d3828 100644 --- a/clang/test/CodeGenObjCXX/ptrauth-objc-interface-selector.mm +++ b/clang/test/CodeGenObjCXX/ptrauth-objc-interface-selector.mm @@ -46,7 +46,7 @@ void auto_sel(Test *out, Test *in) { // CHECK-AUTHENTICATED-SEL: [[CAST_DST_ADDR:%.*]] = ptrtoint ptr [[DST_ADDR]] to i64 // CHECK-AUTHENTICATED-SEL: [[CAST_SRC_ADDR:%.*]] = ptrtoint ptr [[SRC_ADDR]] to i64 // CHECK-AUTHENTICATED-SEL: [[SRC_SEL:%.*]] = ptrtoint ptr [[SRC_SEL_ADDR:%.*]] to i64 -// CHECK-AUTHENTICATED-SEL: {{%.*}} = call i64 @llvm.ptrauth.resign(i64 [[SRC_SEL]]) [ "ptrauth"(i64 3, i64 [[CAST_DST_ADDR]], i64 22466), "ptrauth"(i64 3, i64 [[CAST_SRC_ADDR]], i64 22466) ] +// CHECK-AUTHENTICATED-SEL: {{%.*}} = call i64 @llvm.ptrauth.resign(i64 [[SRC_SEL]]) [ "ptrauth"(i64 3, i64 22466, i64 [[CAST_DST_ADDR]]), "ptrauth"(i64 3, i64 22466, i64 [[CAST_SRC_ADDR]]) ] // CHECK-UNAUTHENTICATED-SEL: define void @auto_sel SEL const_auto_sel(Test *in) { @@ -56,7 +56,7 @@ SEL const_auto_sel(Test *in) { // CHECK-AUTHENTICATED-SEL: define ptr @const_auto_sel // CHECK-AUTHENTICATED-SEL: {{%.*}} = ptrtoint ptr {{%.*}} to i64 -// CHECK-AUTHENTICATED-SEL: [[AUTHENTICATED:%.*]] = call i64 @llvm.ptrauth.auth(i64 {{%.*}}) [ "ptrauth"(i64 3, i64 {{%.*}}, i64 22466) ] +// CHECK-AUTHENTICATED-SEL: [[AUTHENTICATED:%.*]] = call i64 @llvm.ptrauth.auth(i64 {{%.*}}) [ "ptrauth"(i64 3, i64 22466, i64 {{%.*}}) ] // CHECK-AUTHENTICATED-SEL: [[RESULT:%.*]] = inttoptr i64 [[AUTHENTICATED]] to ptr void volatile_auto_sel(Test *out, Test *in) { @@ -72,7 +72,7 @@ void volatile_auto_sel(Test *out, Test *in) { // CHECK-AUTHENTICATED-SEL: [[CAST_DST_ADDR:%.*]] = ptrtoint ptr [[DST_ADDR]] to i64 // CHECK-AUTHENTICATED-SEL: [[CAST_SRC_ADDR:%.*]] = ptrtoint ptr [[SRC_ADDR]] to i64 // CHECK-AUTHENTICATED-SEL: [[SRC_SEL:%.*]] = ptrtoint ptr [[SRC_SEL_ADDR:%.*]] to i64 -// CHECK-AUTHENTICATED-SEL: {{%.*}} = call i64 @llvm.ptrauth.resign(i64 [[SRC_SEL]]) [ "ptrauth"(i64 3, i64 [[CAST_DST_ADDR]], i64 22466), "ptrauth"(i64 3, i64 [[CAST_SRC_ADDR]], i64 22466) ] +// CHECK-AUTHENTICATED-SEL: {{%.*}} = call i64 @llvm.ptrauth.resign(i64 [[SRC_SEL]]) [ "ptrauth"(i64 3, i64 22466, i64 [[CAST_DST_ADDR]]), "ptrauth"(i64 3, i64 22466, i64 [[CAST_SRC_ADDR]]) ] void manual(Test *out, Test *in) { out->manual = in->manual; @@ -86,7 +86,7 @@ void manual(Test *out, Test *in) { // CHECK-AUTHENTICATED-SEL: [[CAST_DST_ADDR:%.*]] = ptrtoint ptr [[DST_ADDR]] to i64 // CHECK-AUTHENTICATED-SEL: [[CAST_SRC_ADDR:%.*]] = ptrtoint ptr [[SRC_ADDR]] to i64 // CHECK-AUTHENTICATED-SEL: [[SRC_SEL:%.*]] = ptrtoint ptr [[SRC_SEL_ADDR:%.*]] to i64 -// CHECK-AUTHENTICATED-SEL: {{%.*}} = call i64 @llvm.ptrauth.resign(i64 [[SRC_SEL]]) [ "ptrauth"(i64 3, i64 [[CAST_DST_ADDR]], i64 22467), "ptrauth"(i64 3, i64 [[CAST_SRC_ADDR]], i64 22467) ] +// CHECK-AUTHENTICATED-SEL: {{%.*}} = call i64 @llvm.ptrauth.resign(i64 [[SRC_SEL]]) [ "ptrauth"(i64 3, i64 22467, i64 [[CAST_DST_ADDR]]), "ptrauth"(i64 3, i64 22467, i64 [[CAST_SRC_ADDR]]) ] // CHECK-UNAUTHENTICATED-SEL: define void @manual // CHECK-UNAUTHENTICATED-SEL: [[V0:%.*]] = load ptr, ptr %out.addr @@ -96,6 +96,6 @@ void manual(Test *out, Test *in) { // CHECK-UNAUTHENTICATED-SEL: [[CAST_DST_ADDR:%.*]] = ptrtoint ptr [[DST_ADDR]] to i64 // CHECK-UNAUTHENTICATED-SEL: [[CAST_SRC_ADDR:%.*]] = ptrtoint ptr [[SRC_ADDR]] to i64 // CHECK-UNAUTHENTICATED-SEL: [[SRC_SEL:%.*]] = ptrtoint ptr [[SRC_SEL_ADDR:%.*]] to i64 -// CHECK-UNAUTHENTICATED-SEL: {{%.*}} = call i64 @llvm.ptrauth.resign(i64 [[SRC_SEL]]) [ "ptrauth"(i64 3, i64 [[CAST_DST_ADDR]], i64 22467), "ptrauth"(i64 3, i64 [[CAST_SRC_ADDR]], i64 22467) ] +// CHECK-UNAUTHENTICATED-SEL: {{%.*}} = call i64 @llvm.ptrauth.resign(i64 [[SRC_SEL]]) [ "ptrauth"(i64 3, i64 22467, i64 [[CAST_DST_ADDR]]), "ptrauth"(i64 3, i64 22467, i64 [[CAST_SRC_ADDR]]) ] } From 2020667cffe229dfe9fbf41f4baf9ad5d6757408 Mon Sep 17 00:00:00 2001 From: Anatoly Trosinenko Date: Thu, 13 Nov 2025 16:43:51 +0300 Subject: [PATCH 26/40] IMPORTANT FIX: add earlyclobber constraint to AUTxMxN --- llvm/lib/Target/AArch64/AArch64InstrInfo.td | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/llvm/lib/Target/AArch64/AArch64InstrInfo.td b/llvm/lib/Target/AArch64/AArch64InstrInfo.td index e3ddae07e5edd..ad8a274f0a3fe 100644 --- a/llvm/lib/Target/AArch64/AArch64InstrInfo.td +++ b/llvm/lib/Target/AArch64/AArch64InstrInfo.td @@ -2197,7 +2197,7 @@ let Predicates = [HasPAuth] in { def AUTxMxN : Pseudo<(outs GPR64:$AuthVal, GPR64common:$Scratch), (ins GPR64:$Val, i64imm:$Key, i64imm:$Disc, GPR64:$AddrDisc), - [], "$AuthVal = $Val">, Sched<[WriteI, ReadI]> { + [], "$AuthVal = $Val,@earlyclobber $Scratch">, Sched<[WriteI, ReadI]> { let isCodeGenOnly = 1; let hasSideEffects = 1; let mayStore = 0; From f84201d49993b0ce2b758c13864085d41be3ef72 Mon Sep 17 00:00:00 2001 From: Anatoly Trosinenko Date: Fri, 14 Nov 2025 00:02:22 +0300 Subject: [PATCH 27/40] Add/update InstCombine test cases --- .../InstCombine/ptrauth-intrinsics-call.ll | 34 ++++++++++++++ .../InstCombine/ptrauth-intrinsics.ll | 44 ++++++++++++++----- 2 files changed, 68 insertions(+), 10 deletions(-) diff --git a/llvm/test/Transforms/InstCombine/ptrauth-intrinsics-call.ll b/llvm/test/Transforms/InstCombine/ptrauth-intrinsics-call.ll index b35d8c006c359..18642461e6465 100644 --- a/llvm/test/Transforms/InstCombine/ptrauth-intrinsics-call.ll +++ b/llvm/test/Transforms/InstCombine/ptrauth-intrinsics-call.ll @@ -68,6 +68,21 @@ define i32 @test_ptrauth_call_resign_blend_2(ptr %pp) { ret i32 %v6 } +define i32 @test_ptrauth_call_resign_long_bundle_ops(ptr %pp) { +; CHECK-LABEL: @test_ptrauth_call_resign_long_bundle_ops( +; CHECK-NEXT: [[V01:%.*]] = load ptr, ptr [[PP:%.*]], align 8 +; CHECK-NEXT: [[V6:%.*]] = call i32 [[V01]]() [ "ptrauth"(i64 1, i64 1234) ] +; CHECK-NEXT: ret i32 [[V6]] +; + %v0 = load ptr, ptr %pp, align 8 + %v1 = ptrtoint ptr %pp to i64 + %v2 = ptrtoint ptr %v0 to i64 + %v4 = call i64 @llvm.ptrauth.resign(i64 %v2) [ "ptrauth"(i64 1, i64 1234), "ptrauth"(i64 1, i64 %v1, i64 5678, i64 %v2, i64 123) ] + %v5 = inttoptr i64 %v4 to ptr + %v6 = call i32 %v5() [ "ptrauth"(i64 1, i64 %v1, i64 5678, i64 %v2, i64 123) ] + ret i32 %v6 +} + define i32 @test_ptrauth_call_resign_mismatch_key(ptr %p) { ; CHECK-LABEL: @test_ptrauth_call_resign_mismatch_key( ; CHECK-NEXT: [[V0:%.*]] = ptrtoint ptr [[P:%.*]] to i64 @@ -117,6 +132,25 @@ define i32 @test_ptrauth_call_resign_mismatch_blend(ptr %pp) { ret i32 %v6 } +define i32 @test_ptrauth_call_resign_long_bundle_ops_mismatch(ptr %pp) { +; CHECK-LABEL: @test_ptrauth_call_resign_long_bundle_ops_mismatch( +; CHECK-NEXT: [[V0:%.*]] = load ptr, ptr [[PP:%.*]], align 8 +; CHECK-NEXT: [[V1:%.*]] = ptrtoint ptr [[PP]] to i64 +; CHECK-NEXT: [[V2:%.*]] = ptrtoint ptr [[V0]] to i64 +; CHECK-NEXT: [[V4:%.*]] = call i64 @llvm.ptrauth.resign(i64 [[V2]]) [ "ptrauth"(i64 1, i64 1234), "ptrauth"(i64 1, i64 [[V1]], i64 5678, i64 [[V1]], i64 123) ] +; CHECK-NEXT: [[V5:%.*]] = inttoptr i64 [[V4]] to ptr +; CHECK-NEXT: [[V3:%.*]] = call i32 [[V5]]() [ "ptrauth"(i64 1, i64 [[V1]], i64 [[V2]], i64 123) ] +; CHECK-NEXT: ret i32 [[V3]] +; + %v0 = load ptr, ptr %pp, align 8 + %v1 = ptrtoint ptr %pp to i64 + %v2 = ptrtoint ptr %v0 to i64 + %v4 = call i64 @llvm.ptrauth.resign(i64 %v2) [ "ptrauth"(i64 1, i64 1234), "ptrauth"(i64 1, i64 %v1, i64 5678, i64 %v1, i64 123) ] + %v5 = inttoptr i64 %v4 to ptr + %v6 = call i32 %v5() [ "ptrauth"(i64 1, i64 %v1, i64 %v2, i64 123) ] + ret i32 %v6 +} + define i32 @test_ptrauth_call_resign_changing_call_key(ptr %p) { ; CHECK-LABEL: @test_ptrauth_call_resign_changing_call_key( ; CHECK-NEXT: [[V3:%.*]] = call i32 [[P:%.*]]() [ "ptrauth"(i64 2, i64 1234) ] diff --git a/llvm/test/Transforms/InstCombine/ptrauth-intrinsics.ll b/llvm/test/Transforms/InstCombine/ptrauth-intrinsics.ll index c5b1a3cee6574..9901d8ae02f0f 100644 --- a/llvm/test/Transforms/InstCombine/ptrauth-intrinsics.ll +++ b/llvm/test/Transforms/InstCombine/ptrauth-intrinsics.ll @@ -12,6 +12,17 @@ define i64 @test_ptrauth_nop(ptr %p) { ret i64 %authed } +define i64 @test_ptrauth_nop_long_bundle_ops(ptr %p) { +; CHECK-LABEL: @test_ptrauth_nop_long_bundle_ops( +; CHECK-NEXT: [[TMP0:%.*]] = ptrtoint ptr [[P:%.*]] to i64 +; CHECK-NEXT: ret i64 [[TMP0]] +; + %tmp0 = ptrtoint ptr %p to i64 + %signed = call i64 @llvm.ptrauth.sign(i64 %tmp0) [ "ptrauth"(i64 1, i64 1234, i64 0, i64 42, i64 %tmp0) ] + %authed = call i64 @llvm.ptrauth.auth(i64 %signed) [ "ptrauth"(i64 1, i64 1234, i64 0, i64 42, i64 %tmp0) ] + ret i64 %authed +} + declare void @foo() declare void @bar() @@ -58,6 +69,19 @@ define i64 @test_ptrauth_nop_mismatch_keys(ptr %p) { ret i64 %authed } +define i64 @test_ptrauth_nop_long_bundle_ops_mismatch(ptr %p) { +; CHECK-LABEL: @test_ptrauth_nop_long_bundle_ops_mismatch( +; CHECK-NEXT: [[TMP0:%.*]] = ptrtoint ptr [[P:%.*]] to i64 +; CHECK-NEXT: [[SIGNED:%.*]] = call i64 @llvm.ptrauth.sign(i64 [[TMP0]]) [ "ptrauth"(i64 1, i64 1234, i64 0, i64 42, i64 [[TMP0]]) ] +; CHECK-NEXT: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[SIGNED]]) [ "ptrauth"(i64 1, i64 1234, i64 0, i64 42, i64 123) ] +; CHECK-NEXT: ret i64 [[AUTHED]] +; + %tmp0 = ptrtoint ptr %p to i64 + %signed = call i64 @llvm.ptrauth.sign(i64 %tmp0) [ "ptrauth"(i64 1, i64 1234, i64 0, i64 42, i64 %tmp0) ] + %authed = call i64 @llvm.ptrauth.auth(i64 %signed) [ "ptrauth"(i64 1, i64 1234, i64 0, i64 42, i64 123) ] + ret i64 %authed +} + define i64 @test_ptrauth_sign_resign(ptr %p) { ; CHECK-LABEL: @test_ptrauth_sign_resign( ; CHECK-NEXT: [[TMP0:%.*]] = ptrtoint ptr [[P:%.*]] to i64 @@ -65,8 +89,8 @@ define i64 @test_ptrauth_sign_resign(ptr %p) { ; CHECK-NEXT: ret i64 [[AUTHED]] ; %tmp0 = ptrtoint ptr %p to i64 - %signed = call i64 @llvm.ptrauth.sign(i64 %tmp0) [ "ptrauth"(i64 1, i64 1234, i64 0) ] - %authed = call i64 @llvm.ptrauth.resign(i64 %signed) [ "ptrauth"(i64 1, i64 1234, i64 0), "ptrauth"(i64 0, i64 42, i64 0) ] + %signed = call i64 @llvm.ptrauth.sign(i64 %tmp0) [ "ptrauth"(i64 1, i64 1234, i64 0, i64 42, i64 %tmp0) ] + %authed = call i64 @llvm.ptrauth.resign(i64 %signed) [ "ptrauth"(i64 1, i64 1234, i64 0, i64 42, i64 %tmp0), "ptrauth"(i64 0, i64 42, i64 0) ] ret i64 %authed } @@ -77,8 +101,8 @@ define i64 @test_ptrauth_resign_resign(ptr %p) { ; CHECK-NEXT: ret i64 [[AUTHED]] ; %tmp0 = ptrtoint ptr %p to i64 - %signed = call i64 @llvm.ptrauth.resign(i64 %tmp0) [ "ptrauth"(i64 1, i64 1234, i64 0), "ptrauth"(i64 0, i64 42, i64 0) ] - %authed = call i64 @llvm.ptrauth.resign(i64 %signed) [ "ptrauth"(i64 0, i64 42, i64 0), "ptrauth"(i64 1, i64 3141, i64 0) ] + %signed = call i64 @llvm.ptrauth.resign(i64 %tmp0) [ "ptrauth"(i64 1, i64 1234, i64 0), "ptrauth"(i64 0, i64 42, i64 0, i64 42, i64 %tmp0) ] + %authed = call i64 @llvm.ptrauth.resign(i64 %signed) [ "ptrauth"(i64 0, i64 42, i64 0, i64 42, i64 %tmp0), "ptrauth"(i64 1, i64 3141, i64 0) ] ret i64 %authed } @@ -89,21 +113,21 @@ define i64 @test_ptrauth_resign_auth(ptr %p) { ; CHECK-NEXT: ret i64 [[AUTHED]] ; %tmp0 = ptrtoint ptr %p to i64 - %signed = call i64 @llvm.ptrauth.resign(i64 %tmp0) [ "ptrauth"(i64 1, i64 1234, i64 0), "ptrauth"(i64 0, i64 42, i64 0) ] - %authed = call i64 @llvm.ptrauth.auth(i64 %signed) [ "ptrauth"(i64 0, i64 42, i64 0) ] + %signed = call i64 @llvm.ptrauth.resign(i64 %tmp0) [ "ptrauth"(i64 1, i64 1234, i64 0), "ptrauth"(i64 0, i64 42, i64 0, i64 42, i64 %tmp0) ] + %authed = call i64 @llvm.ptrauth.auth(i64 %signed) [ "ptrauth"(i64 0, i64 42, i64 0, i64 42, i64 %tmp0) ] ret i64 %authed } define i64 @test_ptrauth_resign_auth_mismatch(ptr %p) { ; CHECK-LABEL: @test_ptrauth_resign_auth_mismatch( ; CHECK-NEXT: [[TMP0:%.*]] = ptrtoint ptr [[P:%.*]] to i64 -; CHECK-NEXT: [[SIGNED:%.*]] = call i64 @llvm.ptrauth.resign(i64 [[TMP0]]) [ "ptrauth"(i64 1, i64 1234, i64 0), "ptrauth"(i64 0, i64 10, i64 0) ] -; CHECK-NEXT: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[SIGNED]]) [ "ptrauth"(i64 0, i64 42, i64 0) ] +; CHECK-NEXT: [[SIGNED:%.*]] = call i64 @llvm.ptrauth.resign(i64 [[TMP0]]) [ "ptrauth"(i64 1, i64 1234, i64 0), "ptrauth"(i64 0, i64 10, i64 0, i64 42, i64 [[TMP0]]) ] +; CHECK-NEXT: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[SIGNED]]) [ "ptrauth"(i64 0, i64 42, i64 0, i64 123, i64 [[TMP0]]) ] ; CHECK-NEXT: ret i64 [[AUTHED]] ; %tmp0 = ptrtoint ptr %p to i64 - %signed = call i64 @llvm.ptrauth.resign(i64 %tmp0) [ "ptrauth"(i64 1, i64 1234, i64 0), "ptrauth"(i64 0, i64 10, i64 0) ] - %authed = call i64 @llvm.ptrauth.auth(i64 %signed) [ "ptrauth"(i64 0, i64 42, i64 0) ] + %signed = call i64 @llvm.ptrauth.resign(i64 %tmp0) [ "ptrauth"(i64 1, i64 1234, i64 0), "ptrauth"(i64 0, i64 10, i64 0, i64 42, i64 %tmp0) ] + %authed = call i64 @llvm.ptrauth.auth(i64 %signed) [ "ptrauth"(i64 0, i64 42, i64 0, i64 123, i64 %tmp0) ] ret i64 %authed } From 31f049f973828e366e8bae98356068b78726d302 Mon Sep 17 00:00:00 2001 From: Anatoly Trosinenko Date: Wed, 3 Dec 2025 22:52:50 +0300 Subject: [PATCH 28/40] Fix target-specific bundle validation and add tests --- llvm/include/llvm/CodeGen/TargetLowering.h | 8 +- .../SelectionDAG/SelectionDAGBuilder.cpp | 6 +- llvm/lib/Target/AArch64/AArch64ISelLowering.h | 2 - .../AArch64/ptrauth-unsupported-bundle.ll | 234 ++++++++++++++++++ 4 files changed, 238 insertions(+), 12 deletions(-) create mode 100644 llvm/test/CodeGen/AArch64/ptrauth-unsupported-bundle.ll diff --git a/llvm/include/llvm/CodeGen/TargetLowering.h b/llvm/include/llvm/CodeGen/TargetLowering.h index c28b20a2a0626..9bb517e19803b 100644 --- a/llvm/include/llvm/CodeGen/TargetLowering.h +++ b/llvm/include/llvm/CodeGen/TargetLowering.h @@ -4609,15 +4609,12 @@ class LLVM_ABI TargetLowering : public TargetLoweringBase { /// Return true if the target supports kcfi operand bundles. virtual bool supportKCFIBundles() const { return false; } - /// Return true if the target supports ptrauth operand bundles. - virtual bool supportPtrAuthBundles() const { return false; } - /// Perform target-specific validation of "ptrauth" call operand bundles that /// is not covered by Verifier but relied upon by the backend. virtual std::optional validatePtrAuthBundles(const CallBase &CB) const { - return std::nullopt; - }; + return "This target doesn't support calls with ptrauth operand bundles"; + } /// Convenience function to report fatal error if user-provided IR violates /// the assumptions relied upon by the backend. @@ -4628,6 +4625,7 @@ class LLVM_ABI TargetLowering : public TargetLoweringBase { if (auto Error = validatePtrAuthBundles(CB)) { errs() << "Ptrauth bundle violates target-specific constraints:\n"; CB.print(errs()); + errs() << "\n"; reportFatalUsageError(("Invalid ptrauth bundle: " + *Error).c_str()); } } diff --git a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp index a31f27145e61b..1e5bd43dca128 100644 --- a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp +++ b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp @@ -9181,12 +9181,8 @@ void SelectionDAGBuilder::LowerCallTo(const CallBase &CB, SDValue Callee, .setDeactivationSymbol(DeactivationSymbol); // Set the pointer authentication info if we have it. - if (PAI) { - if (!TLI.supportPtrAuthBundles()) - report_fatal_error( - "This target doesn't support calls with ptrauth operand bundles."); + if (PAI) CLI.setPtrAuth(*PAI); - } std::pair Result = lowerInvokable(CLI, EHPadBB); diff --git a/llvm/lib/Target/AArch64/AArch64ISelLowering.h b/llvm/lib/Target/AArch64/AArch64ISelLowering.h index ff89bd355749b..cbe265d34d9b6 100644 --- a/llvm/lib/Target/AArch64/AArch64ISelLowering.h +++ b/llvm/lib/Target/AArch64/AArch64ISelLowering.h @@ -465,8 +465,6 @@ class AArch64TargetLowering : public TargetLowering { return true; } - bool supportPtrAuthBundles() const override { return true; } - std::optional validatePtrAuthBundles(const CallBase &CB) const override; diff --git a/llvm/test/CodeGen/AArch64/ptrauth-unsupported-bundle.ll b/llvm/test/CodeGen/AArch64/ptrauth-unsupported-bundle.ll new file mode 100644 index 0000000000000..56de2c1e45642 --- /dev/null +++ b/llvm/test/CodeGen/AArch64/ptrauth-unsupported-bundle.ll @@ -0,0 +1,234 @@ +; RUN: split-file %s %t +; REQUIRES: x86-registered-target + +;--- empty.ll +; RUN: not llc -mtriple aarch64 -mattr=+pauth < %t/empty.ll 2>&1 | FileCheck --check-prefix=EMPTY %s + +; Empty "ptrauth" bundles are rejected by target-independent LLVM IR Verifier. + +; EMPTY: Expected non-empty ptrauth bundle +; EMPTY-NEXT: %res = call i64 @llvm.ptrauth.sign(i64 %p) [ "ptrauth"() ] +; EMPTY-NEXT: llc: error: '': input module cannot be verified + +define i64 @test(i64 %p) { + %res = call i64 @llvm.ptrauth.sign(i64 %p) [ "ptrauth"() ] + ret i64 %res +} + +;--- wrong-type-i32.ll +; RUN: not llc -mtriple aarch64 -mattr=+pauth < %t/wrong-type-i32.ll 2>&1 | FileCheck --check-prefix=WRONG-TYPE-I32 %s + +; Non-i64 operands of "ptrauth" bundles are rejected by target-independent +; LLVM IR Verifier, provided they cannot be auto-upgraded when the LLVM IR +; source is being read. + +; WRONG-TYPE-I32: Ptrauth bundle must only contain i64 operands +; WRONG-TYPE-I32-NEXT: %res = call i64 @llvm.ptrauth.sign(i64 %p) [ "ptrauth"(i32 0, i32 0, i64 0) ] +; WRONG-TYPE-I32-NEXT: llc: error: '': input module cannot be verified + +define i64 @test(i64 %p) { + %res = call i64 @llvm.ptrauth.sign(i64 %p) [ "ptrauth"(i32 0, i32 0, i64 0) ] + ret i64 %res +} + +;--- wrong-type-ptr.ll +; RUN: not llc -mtriple aarch64 -mattr=+pauth < %t/wrong-type-ptr.ll 2>&1 | FileCheck --check-prefix=WRONG-TYPE-PTR %s + +; WRONG-TYPE-PTR: Ptrauth bundle must only contain i64 operands +; WRONG-TYPE-PTR-NEXT: %res = call i64 @llvm.ptrauth.sign(i64 %p) [ "ptrauth"(i64 0, i64 0, ptr %arg) ] +; WRONG-TYPE-PTR-NEXT: llc: error: '': input module cannot be verified + +define i64 @test(i64 %p, ptr %arg) { + %res = call i64 @llvm.ptrauth.sign(i64 %p) [ "ptrauth"(i64 0, i64 0, ptr %arg) ] + ret i64 %res +} + +;--- wrong-not-one-bundle.ll +; RUN: not llc -mtriple aarch64 -mattr=+pauth < %t/wrong-not-one-bundle.ll 2>&1 | FileCheck --check-prefix=WRONG-NOT-ONE-BUNDLE %s + +; Wrong number of "ptrauth" bundles is rejected by target-independent +; LLVM IR Verifier. + +; WRONG-NOT-ONE-BUNDLE: Expected exactly one ptrauth bundle +; WRONG-NOT-ONE-BUNDLE-NEXT: %res = call i64 @llvm.ptrauth.sign(i64 %p) [ "ptrauth"(i64 0, i64 0, i64 0), "ptrauth"(i64 0, i64 0, i64 0) ] +; WRONG-NOT-ONE-BUNDLE-NEXT: llc: error: '': input module cannot be verified + +define i64 @test(i64 %p) { + %res = call i64 @llvm.ptrauth.sign(i64 %p) [ "ptrauth"(i64 0, i64 0, i64 0), "ptrauth"(i64 0, i64 0, i64 0) ] + ret i64 %res +} + +;--- wrong-not-two-bundles.ll +; RUN: not llc -mtriple aarch64 -mattr=+pauth < %t/wrong-not-two-bundles.ll 2>&1 | FileCheck --check-prefix=WRONG-NOT-TWO-BUNDLES %s + +; WRONG-NOT-TWO-BUNDLES: Expected exactly two ptrauth bundles +; WRONG-NOT-TWO-BUNDLES-NEXT: %res = call i64 @llvm.ptrauth.resign(i64 %p) [ "ptrauth"(i64 0, i64 0, i64 0) ] +; WRONG-NOT-TWO-BUNDLES-NEXT: llc: error: '': input module cannot be verified + +define i64 @test(i64 %p) { + %res = call i64 @llvm.ptrauth.resign(i64 %p) [ "ptrauth"(i64 0, i64 0, i64 0) ] + ret i64 %res +} + +;--- wrong-missing-bundle.ll +; RUN: not llc -mtriple aarch64 -mattr=+pauth < %t/wrong-missing-bundle.ll 2>&1 | FileCheck --check-prefix=WRONG-MISSING-BUNDLE %s + +; WRONG-MISSING-BUNDLE: Expected exactly one ptrauth bundle +; WRONG-MISSING-BUNDLE-NEXT: %res = call i64 @llvm.ptrauth.sign(i64 %p) +; WRONG-MISSING-BUNDLE-NEXT: llc: error: '': input module cannot be verified + +define i64 @test(i64 %p) { + %res = call i64 @llvm.ptrauth.sign(i64 %p) + ret i64 %res +} + +;--- wrong-indirect-call-multiple-bundles.ll +; RUN: not llc -mtriple aarch64 -mattr=+pauth < %t/wrong-indirect-call-multiple-bundles.ll 2>&1 | FileCheck --check-prefix=WRONG-INDIRECT-CALL-MULTIPLE-BUNDLES %s + +; WRONG-INDIRECT-CALL-MULTIPLE-BUNDLES: Multiple ptrauth operand bundles on a function call +; WRONG-INDIRECT-CALL-MULTIPLE-BUNDLES-NEXT: %res = call i64 %fptr() [ "ptrauth"(i64 0, i64 0, i64 0), "ptrauth"(i64 0, i64 0, i64 0) ] +; WRONG-INDIRECT-CALL-MULTIPLE-BUNDLES-NEXT: llc: error: '': input module cannot be verified + +define i64 @test(ptr %fptr) { + %res = call i64 %fptr() [ "ptrauth"(i64 0, i64 0, i64 0), "ptrauth"(i64 0, i64 0, i64 0) ] + ret i64 %res +} +;--- unsupported-target-intrinsic.ll +; RUN: not llc -mtriple x86_64 < %t/unsupported-target-intrinsic.ll 2>&1 | FileCheck --check-prefix=UNSUPPORTED-TARGET-INTRINSIC %s + +; UNSUPPORTED-TARGET-INTRINSIC: Ptrauth bundle violates target-specific constraints: +; UNSUPPORTED-TARGET-INTRINSIC-NEXT: %res = call i64 @llvm.ptrauth.sign(i64 %p) [ "ptrauth"(i64 0) ] +; UNSUPPORTED-TARGET-INTRINSIC-NEXT: LLVM ERROR: Invalid ptrauth bundle: This target doesn't support calls with ptrauth operand bundles + +define i64 @test(i64 %p) { + %res = call i64 @llvm.ptrauth.sign(i64 %p) [ "ptrauth"(i64 0) ] + ret i64 %res +} + +;--- unsupported-target-indirect-call.ll +; RUN: not llc -mtriple x86_64 < %t/unsupported-target-indirect-call.ll 2>&1 | FileCheck --check-prefix=UNSUPPORTED-TARGET-INDIRECT-CALL %s + +; UNSUPPORTED-TARGET-INDIRECT-CALL: Ptrauth bundle violates target-specific constraints: +; UNSUPPORTED-TARGET-INDIRECT-CALL-NEXT: %res = call i64 %fptr() [ "ptrauth"(i64 0) ] +; UNSUPPORTED-TARGET-INDIRECT-CALL-NEXT: LLVM ERROR: Invalid ptrauth bundle: This target doesn't support calls with ptrauth operand bundles + +define i64 @test(ptr %fptr) { + %res = call i64 %fptr() [ "ptrauth"(i64 0) ] + ret i64 %res +} + +;--- wrong-not-3-ops.ll +; RUN: not llc -mtriple aarch64 -mattr=+pauth < %t/wrong-not-3-ops.ll 2>&1 | FileCheck --check-prefix=WRONG-NOT-3-OPS %s + +; Single-operand bundles are used on AArch64, but not by this intrinsic. + +; WRONG-NOT-3-OPS: Ptrauth bundle violates target-specific constraints: +; WRONG-NOT-3-OPS-NEXT: %res = call i64 @llvm.ptrauth.sign(i64 %p) [ "ptrauth"(i64 0) ] +; WRONG-NOT-3-OPS-NEXT: LLVM ERROR: Invalid ptrauth bundle: test: Three-element ptrauth bundle expected + +define i64 @test(i64 %p) { + %res = call i64 @llvm.ptrauth.sign(i64 %p) [ "ptrauth"(i64 0) ] + ret i64 %res +} + +;--- wrong-not-1-ops.ll +; RUN: not llc -mtriple aarch64 -mattr=+pauth < %t/wrong-not-1-ops.ll 2>&1 | FileCheck --check-prefix=WRONG-NOT-1-OPS %s + +; Three-operand bundles are used on AArch64, but not by this intrinsic. + +; WRONG-NOT-1-OPS: Ptrauth bundle violates target-specific constraints: +; WRONG-NOT-1-OPS-NEXT: %res = call i64 @llvm.ptrauth.strip(i64 %p) [ "ptrauth"(i64 0, i64 0, i64 0) ] +; WRONG-NOT-1-OPS-NEXT: LLVM ERROR: Invalid ptrauth bundle: test: Single-element ptrauth bundle expected + +define i64 @test(i64 %p) { + %res = call i64 @llvm.ptrauth.strip(i64 %p) [ "ptrauth"(i64 0, i64 0, i64 0) ] + ret i64 %res +} + +;--- wrong-num-operands.ll +; RUN: not llc -mtriple aarch64 -mattr=+pauth < %t/wrong-num-operands.ll 2>&1 | FileCheck --check-prefix=WRONG-NUM-OPERANDS %s + +; Four-operand bundles are never used on AArch64. + +; WRONG-NUM-OPERANDS: Ptrauth bundle violates target-specific constraints: +; WRONG-NUM-OPERANDS-NEXT: %res = call i64 @llvm.ptrauth.sign(i64 %p) [ "ptrauth"(i64 0, i64 0, i64 0, i64 0) ] +; WRONG-NUM-OPERANDS-NEXT: LLVM ERROR: Invalid ptrauth bundle: test: Three-element ptrauth bundle expected + +define i64 @test(i64 %p, i64 %arg) { + %res = call i64 @llvm.ptrauth.sign(i64 %p) [ "ptrauth"(i64 0, i64 0, i64 0, i64 0) ] + ret i64 %res +} + +;--- wrong-key-not-const.ll +; RUN: not llc -mtriple aarch64 -mattr=+pauth < %t/wrong-key-not-const.ll 2>&1 | FileCheck --check-prefix=WRONG-KEY-NOT-CONST %s + +; WRONG-KEY-NOT-CONST: Ptrauth bundle violates target-specific constraints: +; WRONG-KEY-NOT-CONST-NEXT: %res = call i64 @llvm.ptrauth.sign(i64 %p) [ "ptrauth"(i64 %arg, i64 0, i64 0) ] +; WRONG-KEY-NOT-CONST-NEXT: LLVM ERROR: Invalid ptrauth bundle: test: Key must be constant in ptrauth bundle on AArch64 + +define i64 @test(i64 %p, i64 %arg) { + %res = call i64 @llvm.ptrauth.sign(i64 %p) [ "ptrauth"(i64 %arg, i64 0, i64 0) ] + ret i64 %res +} + +;--- wrong-imm-modifier-not-const.ll +; RUN: not llc -mtriple aarch64 -mattr=+pauth < %t/wrong-imm-modifier-not-const.ll 2>&1 | FileCheck --check-prefix=WRONG-IMM-MODIFIER-NOT-CONST %s + +; WRONG-IMM-MODIFIER-NOT-CONST: Ptrauth bundle violates target-specific constraints: +; WRONG-IMM-MODIFIER-NOT-CONST-NEXT: %res = call i64 @llvm.ptrauth.sign(i64 %p) [ "ptrauth"(i64 0, i64 %arg, i64 0) ] +; WRONG-IMM-MODIFIER-NOT-CONST-NEXT: LLVM ERROR: Invalid ptrauth bundle: test: Constant modifier must be 16-bit unsigned constant in ptrauth bundle on AArch64 + +define i64 @test(i64 %p, i64 %arg) { + %res = call i64 @llvm.ptrauth.sign(i64 %p) [ "ptrauth"(i64 0, i64 %arg, i64 0) ] + ret i64 %res +} + +;--- wrong-imm-modifier-negative.ll +; RUN: not llc -mtriple aarch64 -mattr=+pauth < %t/wrong-imm-modifier-negative.ll 2>&1 | FileCheck --check-prefix=WRONG-IMM-MODIFIER-NEGATIVE %s + +; WRONG-IMM-MODIFIER-NEGATIVE: Ptrauth bundle violates target-specific constraints: +; WRONG-IMM-MODIFIER-NEGATIVE-NEXT: %res = call i64 @llvm.ptrauth.sign(i64 %p) [ "ptrauth"(i64 0, i64 -1, i64 0) ] +; WRONG-IMM-MODIFIER-NEGATIVE-NEXT: LLVM ERROR: Invalid ptrauth bundle: test: Constant modifier must be 16-bit unsigned constant in ptrauth bundle on AArch64 + +define i64 @test(i64 %p) { + %res = call i64 @llvm.ptrauth.sign(i64 %p) [ "ptrauth"(i64 0, i64 -1, i64 0) ] + ret i64 %res +} + +;--- wrong-imm-modifier-too-wide.ll +; RUN: not llc -mtriple aarch64 -mattr=+pauth < %t/wrong-imm-modifier-too-wide.ll 2>&1 | FileCheck --check-prefix=WRONG-IMM-MODIFIER-TOO-WIDE %s + +; WRONG-IMM-MODIFIER-TOO-WIDE: Ptrauth bundle violates target-specific constraints: +; WRONG-IMM-MODIFIER-TOO-WIDE-NEXT: %res = call i64 @llvm.ptrauth.sign(i64 %p) [ "ptrauth"(i64 0, i64 123456, i64 0) ] +; WRONG-IMM-MODIFIER-TOO-WIDE-NEXT: LLVM ERROR: Invalid ptrauth bundle: test: Constant modifier must be 16-bit unsigned constant in ptrauth bundle on AArch64 + +define i64 @test(i64 %p) { + %res = call i64 @llvm.ptrauth.sign(i64 %p) [ "ptrauth"(i64 0, i64 123456, i64 0) ] + ret i64 %res +} + +;--- wrong-first-bundle.ll +; RUN: not llc -mtriple aarch64 -mattr=+pauth < %t/wrong-first-bundle.ll 2>&1 | FileCheck --check-prefix=WRONG-FIRST-BUNDLE %s + +; If the intrinsic accepts two bundles, both should be checked. + +; WRONG-FIRST-BUNDLE: Ptrauth bundle violates target-specific constraints: +; WRONG-FIRST-BUNDLE-NEXT: %res = call i64 @llvm.ptrauth.resign(i64 %p) [ "ptrauth"(i64 %arg, i64 0, i64 0), "ptrauth"(i64 0, i64 0, i64 0) ] +; WRONG-FIRST-BUNDLE-NEXT: LLVM ERROR: Invalid ptrauth bundle: test: Key must be constant in ptrauth bundle on AArch64 + +define i64 @test(i64 %p, i64 %arg) { + %res = call i64 @llvm.ptrauth.resign(i64 %p) [ "ptrauth"(i64 %arg, i64 0, i64 0), "ptrauth"(i64 0, i64 0, i64 0) ] + ret i64 %res +} + +;--- wrong-second-bundle.ll +; RUN: not llc -mtriple aarch64 -mattr=+pauth < %t/wrong-second-bundle.ll 2>&1 | FileCheck --check-prefix=WRONG-SECOND-BUNDLE %s + +; WRONG-SECOND-BUNDLE: Ptrauth bundle violates target-specific constraints: +; WRONG-SECOND-BUNDLE-NEXT: %res = call i64 @llvm.ptrauth.resign(i64 %p) [ "ptrauth"(i64 0, i64 0, i64 0), "ptrauth"(i64 %arg, i64 0, i64 0) ] +; WRONG-SECOND-BUNDLE-NEXT: LLVM ERROR: Invalid ptrauth bundle: test: Key must be constant in ptrauth bundle on AArch64 + +define i64 @test(i64 %p, i64 %arg) { + %res = call i64 @llvm.ptrauth.resign(i64 %p) [ "ptrauth"(i64 0, i64 0, i64 0), "ptrauth"(i64 %arg, i64 0, i64 0) ] + ret i64 %res +} From 1715021dfe1ef923e7bc0813d347346aa775a8b7 Mon Sep 17 00:00:00 2001 From: Anatoly Trosinenko Date: Thu, 4 Dec 2025 14:29:03 +0300 Subject: [PATCH 29/40] Clarify the FIXME in EmitLoadOfMemberFunctionPointer --- clang/lib/CodeGen/ItaniumCXXABI.cpp | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/clang/lib/CodeGen/ItaniumCXXABI.cpp b/clang/lib/CodeGen/ItaniumCXXABI.cpp index 8644299e80def..47db6847063ac 100644 --- a/clang/lib/CodeGen/ItaniumCXXABI.cpp +++ b/clang/lib/CodeGen/ItaniumCXXABI.cpp @@ -874,8 +874,19 @@ CGCallee ItaniumCXXABI::EmitLoadOfMemberFunctionPointer( auto *NonVirtualDiscriminator = Builder.getInt64(AuthInfo.getIntDiscriminator()); assert(!AuthInfo.getAddrDiscriminator()); - // FIXME This does not involve call to @llvm.ptrauth.blend(), but such - // usage of constant modifier is unsafe. + // FIXME Investigate re-signing VirtualFn pointer in FnVirtual basic block + // to the same non-zero discriminator or other safer options. + // + // Depending on its origin, CalleePtr is authenticated using one of + // two possible constant discriminators. That integer discriminator + // may end up being spilled to the stack and thus be susceptible to + // substitution by the attacker. Authenticating CalleePtr at this + // point is not an option, as it would make things even worse by + // exposing completely unprotected function pointer instead of less + // sensitive discriminator value. + // + // "Upgrading" VirtualFn's schema to a custom constant discriminator + // would probably help, but it still requires investigation. DiscriminatorPHI->addIncoming(NonVirtualDiscriminator, FnNonVirtual); PointerAuth = CGPointerAuthInfo( From 43b31fe734413d2ae11bf28f59ddc57f68e5ec68 Mon Sep 17 00:00:00 2001 From: Anatoly Trosinenko Date: Thu, 11 Dec 2025 16:15:24 +0300 Subject: [PATCH 30/40] Update validatePtrAuthBundles --- llvm/include/llvm/CodeGen/TargetLowering.h | 16 ++++--- llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp | 4 +- .../SelectionDAG/SelectionDAGBuilder.cpp | 4 +- .../Target/AArch64/AArch64ISelLowering.cpp | 45 +++++++++++-------- llvm/lib/Target/AArch64/AArch64ISelLowering.h | 2 +- .../AArch64/ptrauth-unsupported-bundle.ll | 44 +++++++++--------- 6 files changed, 63 insertions(+), 52 deletions(-) diff --git a/llvm/include/llvm/CodeGen/TargetLowering.h b/llvm/include/llvm/CodeGen/TargetLowering.h index 9bb517e19803b..14efa2638993a 100644 --- a/llvm/include/llvm/CodeGen/TargetLowering.h +++ b/llvm/include/llvm/CodeGen/TargetLowering.h @@ -4609,24 +4609,26 @@ class LLVM_ABI TargetLowering : public TargetLoweringBase { /// Return true if the target supports kcfi operand bundles. virtual bool supportKCFIBundles() const { return false; } - /// Perform target-specific validation of "ptrauth" call operand bundles that +protected: + /// Perform target-specific validation of PtrAuth schema descriptions that /// is not covered by Verifier but relied upon by the backend. virtual std::optional - validatePtrAuthBundles(const CallBase &CB) const { - return "This target doesn't support calls with ptrauth operand bundles"; + validatePtrAuthSchema(const CallBase &CB) const { + return "this target does not support pointer authentication"; } +public: /// Convenience function to report fatal error if user-provided IR violates /// the assumptions relied upon by the backend. /// /// This function is intended to handle possible invalid user input and thus /// always performs the check, whether the assertions are enabled or not. - void reportFatalErrorOnInvalidPtrAuthBundles(const CallBase &CB) const { - if (auto Error = validatePtrAuthBundles(CB)) { - errs() << "Ptrauth bundle violates target-specific constraints:\n"; + void reportFatalErrorOnInvalidPtrAuthSchema(const CallBase &CB) const { + if (auto Error = validatePtrAuthSchema(CB)) { + errs() << "Ptrauth schema violates target-specific constraints:\n"; CB.print(errs()); errs() << "\n"; - reportFatalUsageError(("Invalid ptrauth bundle: " + *Error).c_str()); + reportFatalUsageError(("Invalid ptrauth schema: " + *Error).c_str()); } } diff --git a/llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp b/llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp index 555ceb62137ee..98b843f3ca050 100644 --- a/llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp +++ b/llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp @@ -2191,7 +2191,7 @@ bool IRTranslator::translateConvergenceControlIntrinsic( bool IRTranslator::translatePtrAuthIntrinsic(const CallInst &CI, unsigned Opcode, MachineIRBuilder &MIRBuilder) { - TLI->reportFatalErrorOnInvalidPtrAuthBundles(CI); + TLI->reportFatalErrorOnInvalidPtrAuthSchema(CI); auto TranslatePtrAuthBundle = [&](unsigned Index) { auto Bundle = CI.getOperandBundleAt(Index); @@ -2798,7 +2798,7 @@ bool IRTranslator::translateCallBase(const CallBase &CB, assert(!isa(CB) && "Should be handled by translateKnownIntrinsic"); - TLI->reportFatalErrorOnInvalidPtrAuthBundles(CB); + TLI->reportFatalErrorOnInvalidPtrAuthSchema(CB); SmallVector BundleOperands(Bundle->Inputs.begin(), Bundle->Inputs.end()); diff --git a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp index 1e5bd43dca128..85dfeaeb31dae 100644 --- a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp +++ b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp @@ -6548,7 +6548,7 @@ void SelectionDAGBuilder::visitPtrAuthIntrinsic(const CallInst &I, const TargetLowering &TLI = DAG.getTargetLoweringInfo(); SDLoc SDL = getCurSDLoc(); - TLI.reportFatalErrorOnInvalidPtrAuthBundles(I); + TLI.reportFatalErrorOnInvalidPtrAuthSchema(I); auto CreatePtrAuthBundle = [&](unsigned Index) { auto Bundle = I.getOperandBundleAt(Index); @@ -9815,7 +9815,7 @@ void SelectionDAGBuilder::LowerCallSiteWithPtrAuthBundle( assert(!isa(CB) && "Should be handled by visitIntrinsicCall"); - TLI.reportFatalErrorOnInvalidPtrAuthBundles(CB); + TLI.reportFatalErrorOnInvalidPtrAuthSchema(CB); SmallVector BundleOperands(PAB->Inputs.begin(), PAB->Inputs.end()); diff --git a/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp b/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp index c641765297edf..42e63cb3386db 100644 --- a/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp +++ b/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp @@ -29946,39 +29946,48 @@ bool AArch64TargetLowering::preferSelectsOverBooleanArithmetic(EVT VT) const { } std::optional -AArch64TargetLowering::validatePtrAuthBundles(const CallBase &CB) const { - auto GetMsg = [&CB](StringRef Str) { +AArch64TargetLowering::validatePtrAuthSchema(const CallBase &CB) const { + auto GetMsg = [&CB](Twine Str) -> std::string { return (CB.getFunction()->getName() + ": " + Str).str(); }; - for (unsigned I = 0, N = CB.getNumOperandBundles(); I < N; ++I) { - OperandBundleUse OB = CB.getOperandBundleAt(I); - if (OB.getTagID() != LLVMContext::OB_ptrauth) - continue; - - unsigned NumOperands = OB.Inputs.size(); - if (CB.getIntrinsicID() == Intrinsic::ptrauth_strip) { + auto ValidateSchema = [&](ArrayRef Schema, bool ExpectSingleElement) -> std::optional{ + unsigned NumOperands = Schema.size(); + if (ExpectSingleElement) { if (NumOperands != 1) - return GetMsg("Single-element ptrauth bundle expected"); + return GetMsg("single-element ptrauth bundle expected"); } else { if (NumOperands != 3) - return GetMsg("Three-element ptrauth bundle expected"); + return GetMsg("three-element ptrauth bundle expected"); } // The first operand is always the key ID. - if (!isa(OB.Inputs[0])) - return GetMsg("Key must be constant in ptrauth bundle on AArch64"); + auto *Key = dyn_cast(Schema[0]); + if (!Key || Key->getZExtValue() > AArch64PACKey::LAST) + return GetMsg("key must be constant in range [0, " + + Twine((int)AArch64PACKey::LAST) + "]"); // Done validating single-operand bundles. if (NumOperands == 1) - continue; + return std::nullopt; - auto *IntDisc = dyn_cast(OB.Inputs[1]); + auto *IntDisc = dyn_cast(Schema[1]); if (!IntDisc || !isUInt<16>(IntDisc->getZExtValue())) - return GetMsg("Constant modifier must be 16-bit unsigned constant in " - "ptrauth bundle on AArch64"); - } + return GetMsg("constant modifier must be 16-bit unsigned constant"); + + return std::nullopt; + }; + + for (unsigned I = 0, N = CB.getNumOperandBundles(); I < N; ++I) { + OperandBundleUse OB = CB.getOperandBundleAt(I); + if (OB.getTagID() != LLVMContext::OB_ptrauth) + continue; + bool ExpectSingleElement = + CB.getIntrinsicID() == Intrinsic::ptrauth_strip; + if (auto Err = ValidateSchema(OB.Inputs, ExpectSingleElement)) + return Err; + } return std::nullopt; } diff --git a/llvm/lib/Target/AArch64/AArch64ISelLowering.h b/llvm/lib/Target/AArch64/AArch64ISelLowering.h index cbe265d34d9b6..3524d066e4b59 100644 --- a/llvm/lib/Target/AArch64/AArch64ISelLowering.h +++ b/llvm/lib/Target/AArch64/AArch64ISelLowering.h @@ -466,7 +466,7 @@ class AArch64TargetLowering : public TargetLowering { } std::optional - validatePtrAuthBundles(const CallBase &CB) const override; + validatePtrAuthSchema(const CallBase &CB) const override; bool supportKCFIBundles() const override { return true; } diff --git a/llvm/test/CodeGen/AArch64/ptrauth-unsupported-bundle.ll b/llvm/test/CodeGen/AArch64/ptrauth-unsupported-bundle.ll index 56de2c1e45642..f448c33bfab6a 100644 --- a/llvm/test/CodeGen/AArch64/ptrauth-unsupported-bundle.ll +++ b/llvm/test/CodeGen/AArch64/ptrauth-unsupported-bundle.ll @@ -96,9 +96,9 @@ define i64 @test(ptr %fptr) { ;--- unsupported-target-intrinsic.ll ; RUN: not llc -mtriple x86_64 < %t/unsupported-target-intrinsic.ll 2>&1 | FileCheck --check-prefix=UNSUPPORTED-TARGET-INTRINSIC %s -; UNSUPPORTED-TARGET-INTRINSIC: Ptrauth bundle violates target-specific constraints: +; UNSUPPORTED-TARGET-INTRINSIC: Ptrauth schema violates target-specific constraints: ; UNSUPPORTED-TARGET-INTRINSIC-NEXT: %res = call i64 @llvm.ptrauth.sign(i64 %p) [ "ptrauth"(i64 0) ] -; UNSUPPORTED-TARGET-INTRINSIC-NEXT: LLVM ERROR: Invalid ptrauth bundle: This target doesn't support calls with ptrauth operand bundles +; UNSUPPORTED-TARGET-INTRINSIC-NEXT: LLVM ERROR: Invalid ptrauth schema: this target does not support pointer authentication define i64 @test(i64 %p) { %res = call i64 @llvm.ptrauth.sign(i64 %p) [ "ptrauth"(i64 0) ] @@ -108,9 +108,9 @@ define i64 @test(i64 %p) { ;--- unsupported-target-indirect-call.ll ; RUN: not llc -mtriple x86_64 < %t/unsupported-target-indirect-call.ll 2>&1 | FileCheck --check-prefix=UNSUPPORTED-TARGET-INDIRECT-CALL %s -; UNSUPPORTED-TARGET-INDIRECT-CALL: Ptrauth bundle violates target-specific constraints: +; UNSUPPORTED-TARGET-INDIRECT-CALL: Ptrauth schema violates target-specific constraints: ; UNSUPPORTED-TARGET-INDIRECT-CALL-NEXT: %res = call i64 %fptr() [ "ptrauth"(i64 0) ] -; UNSUPPORTED-TARGET-INDIRECT-CALL-NEXT: LLVM ERROR: Invalid ptrauth bundle: This target doesn't support calls with ptrauth operand bundles +; UNSUPPORTED-TARGET-INDIRECT-CALL-NEXT: LLVM ERROR: Invalid ptrauth schema: this target does not support pointer authentication define i64 @test(ptr %fptr) { %res = call i64 %fptr() [ "ptrauth"(i64 0) ] @@ -122,9 +122,9 @@ define i64 @test(ptr %fptr) { ; Single-operand bundles are used on AArch64, but not by this intrinsic. -; WRONG-NOT-3-OPS: Ptrauth bundle violates target-specific constraints: +; WRONG-NOT-3-OPS: Ptrauth schema violates target-specific constraints: ; WRONG-NOT-3-OPS-NEXT: %res = call i64 @llvm.ptrauth.sign(i64 %p) [ "ptrauth"(i64 0) ] -; WRONG-NOT-3-OPS-NEXT: LLVM ERROR: Invalid ptrauth bundle: test: Three-element ptrauth bundle expected +; WRONG-NOT-3-OPS-NEXT: LLVM ERROR: Invalid ptrauth schema: test: three-element ptrauth bundle expected define i64 @test(i64 %p) { %res = call i64 @llvm.ptrauth.sign(i64 %p) [ "ptrauth"(i64 0) ] @@ -136,9 +136,9 @@ define i64 @test(i64 %p) { ; Three-operand bundles are used on AArch64, but not by this intrinsic. -; WRONG-NOT-1-OPS: Ptrauth bundle violates target-specific constraints: +; WRONG-NOT-1-OPS: Ptrauth schema violates target-specific constraints: ; WRONG-NOT-1-OPS-NEXT: %res = call i64 @llvm.ptrauth.strip(i64 %p) [ "ptrauth"(i64 0, i64 0, i64 0) ] -; WRONG-NOT-1-OPS-NEXT: LLVM ERROR: Invalid ptrauth bundle: test: Single-element ptrauth bundle expected +; WRONG-NOT-1-OPS-NEXT: LLVM ERROR: Invalid ptrauth schema: test: single-element ptrauth bundle expected define i64 @test(i64 %p) { %res = call i64 @llvm.ptrauth.strip(i64 %p) [ "ptrauth"(i64 0, i64 0, i64 0) ] @@ -150,9 +150,9 @@ define i64 @test(i64 %p) { ; Four-operand bundles are never used on AArch64. -; WRONG-NUM-OPERANDS: Ptrauth bundle violates target-specific constraints: +; WRONG-NUM-OPERANDS: Ptrauth schema violates target-specific constraints: ; WRONG-NUM-OPERANDS-NEXT: %res = call i64 @llvm.ptrauth.sign(i64 %p) [ "ptrauth"(i64 0, i64 0, i64 0, i64 0) ] -; WRONG-NUM-OPERANDS-NEXT: LLVM ERROR: Invalid ptrauth bundle: test: Three-element ptrauth bundle expected +; WRONG-NUM-OPERANDS-NEXT: LLVM ERROR: Invalid ptrauth schema: test: three-element ptrauth bundle expected define i64 @test(i64 %p, i64 %arg) { %res = call i64 @llvm.ptrauth.sign(i64 %p) [ "ptrauth"(i64 0, i64 0, i64 0, i64 0) ] @@ -162,9 +162,9 @@ define i64 @test(i64 %p, i64 %arg) { ;--- wrong-key-not-const.ll ; RUN: not llc -mtriple aarch64 -mattr=+pauth < %t/wrong-key-not-const.ll 2>&1 | FileCheck --check-prefix=WRONG-KEY-NOT-CONST %s -; WRONG-KEY-NOT-CONST: Ptrauth bundle violates target-specific constraints: +; WRONG-KEY-NOT-CONST: Ptrauth schema violates target-specific constraints: ; WRONG-KEY-NOT-CONST-NEXT: %res = call i64 @llvm.ptrauth.sign(i64 %p) [ "ptrauth"(i64 %arg, i64 0, i64 0) ] -; WRONG-KEY-NOT-CONST-NEXT: LLVM ERROR: Invalid ptrauth bundle: test: Key must be constant in ptrauth bundle on AArch64 +; WRONG-KEY-NOT-CONST-NEXT: LLVM ERROR: Invalid ptrauth schema: test: key must be constant in range [0, 3] define i64 @test(i64 %p, i64 %arg) { %res = call i64 @llvm.ptrauth.sign(i64 %p) [ "ptrauth"(i64 %arg, i64 0, i64 0) ] @@ -174,9 +174,9 @@ define i64 @test(i64 %p, i64 %arg) { ;--- wrong-imm-modifier-not-const.ll ; RUN: not llc -mtriple aarch64 -mattr=+pauth < %t/wrong-imm-modifier-not-const.ll 2>&1 | FileCheck --check-prefix=WRONG-IMM-MODIFIER-NOT-CONST %s -; WRONG-IMM-MODIFIER-NOT-CONST: Ptrauth bundle violates target-specific constraints: +; WRONG-IMM-MODIFIER-NOT-CONST: Ptrauth schema violates target-specific constraints: ; WRONG-IMM-MODIFIER-NOT-CONST-NEXT: %res = call i64 @llvm.ptrauth.sign(i64 %p) [ "ptrauth"(i64 0, i64 %arg, i64 0) ] -; WRONG-IMM-MODIFIER-NOT-CONST-NEXT: LLVM ERROR: Invalid ptrauth bundle: test: Constant modifier must be 16-bit unsigned constant in ptrauth bundle on AArch64 +; WRONG-IMM-MODIFIER-NOT-CONST-NEXT: LLVM ERROR: Invalid ptrauth schema: test: constant modifier must be 16-bit unsigned constant define i64 @test(i64 %p, i64 %arg) { %res = call i64 @llvm.ptrauth.sign(i64 %p) [ "ptrauth"(i64 0, i64 %arg, i64 0) ] @@ -186,9 +186,9 @@ define i64 @test(i64 %p, i64 %arg) { ;--- wrong-imm-modifier-negative.ll ; RUN: not llc -mtriple aarch64 -mattr=+pauth < %t/wrong-imm-modifier-negative.ll 2>&1 | FileCheck --check-prefix=WRONG-IMM-MODIFIER-NEGATIVE %s -; WRONG-IMM-MODIFIER-NEGATIVE: Ptrauth bundle violates target-specific constraints: +; WRONG-IMM-MODIFIER-NEGATIVE: Ptrauth schema violates target-specific constraints: ; WRONG-IMM-MODIFIER-NEGATIVE-NEXT: %res = call i64 @llvm.ptrauth.sign(i64 %p) [ "ptrauth"(i64 0, i64 -1, i64 0) ] -; WRONG-IMM-MODIFIER-NEGATIVE-NEXT: LLVM ERROR: Invalid ptrauth bundle: test: Constant modifier must be 16-bit unsigned constant in ptrauth bundle on AArch64 +; WRONG-IMM-MODIFIER-NEGATIVE-NEXT: LLVM ERROR: Invalid ptrauth schema: test: constant modifier must be 16-bit unsigned constant define i64 @test(i64 %p) { %res = call i64 @llvm.ptrauth.sign(i64 %p) [ "ptrauth"(i64 0, i64 -1, i64 0) ] @@ -198,9 +198,9 @@ define i64 @test(i64 %p) { ;--- wrong-imm-modifier-too-wide.ll ; RUN: not llc -mtriple aarch64 -mattr=+pauth < %t/wrong-imm-modifier-too-wide.ll 2>&1 | FileCheck --check-prefix=WRONG-IMM-MODIFIER-TOO-WIDE %s -; WRONG-IMM-MODIFIER-TOO-WIDE: Ptrauth bundle violates target-specific constraints: +; WRONG-IMM-MODIFIER-TOO-WIDE: Ptrauth schema violates target-specific constraints: ; WRONG-IMM-MODIFIER-TOO-WIDE-NEXT: %res = call i64 @llvm.ptrauth.sign(i64 %p) [ "ptrauth"(i64 0, i64 123456, i64 0) ] -; WRONG-IMM-MODIFIER-TOO-WIDE-NEXT: LLVM ERROR: Invalid ptrauth bundle: test: Constant modifier must be 16-bit unsigned constant in ptrauth bundle on AArch64 +; WRONG-IMM-MODIFIER-TOO-WIDE-NEXT: LLVM ERROR: Invalid ptrauth schema: test: constant modifier must be 16-bit unsigned constant define i64 @test(i64 %p) { %res = call i64 @llvm.ptrauth.sign(i64 %p) [ "ptrauth"(i64 0, i64 123456, i64 0) ] @@ -212,9 +212,9 @@ define i64 @test(i64 %p) { ; If the intrinsic accepts two bundles, both should be checked. -; WRONG-FIRST-BUNDLE: Ptrauth bundle violates target-specific constraints: +; WRONG-FIRST-BUNDLE: Ptrauth schema violates target-specific constraints: ; WRONG-FIRST-BUNDLE-NEXT: %res = call i64 @llvm.ptrauth.resign(i64 %p) [ "ptrauth"(i64 %arg, i64 0, i64 0), "ptrauth"(i64 0, i64 0, i64 0) ] -; WRONG-FIRST-BUNDLE-NEXT: LLVM ERROR: Invalid ptrauth bundle: test: Key must be constant in ptrauth bundle on AArch64 +; WRONG-FIRST-BUNDLE-NEXT: LLVM ERROR: Invalid ptrauth schema: test: key must be constant in range [0, 3] define i64 @test(i64 %p, i64 %arg) { %res = call i64 @llvm.ptrauth.resign(i64 %p) [ "ptrauth"(i64 %arg, i64 0, i64 0), "ptrauth"(i64 0, i64 0, i64 0) ] @@ -224,9 +224,9 @@ define i64 @test(i64 %p, i64 %arg) { ;--- wrong-second-bundle.ll ; RUN: not llc -mtriple aarch64 -mattr=+pauth < %t/wrong-second-bundle.ll 2>&1 | FileCheck --check-prefix=WRONG-SECOND-BUNDLE %s -; WRONG-SECOND-BUNDLE: Ptrauth bundle violates target-specific constraints: +; WRONG-SECOND-BUNDLE: Ptrauth schema violates target-specific constraints: ; WRONG-SECOND-BUNDLE-NEXT: %res = call i64 @llvm.ptrauth.resign(i64 %p) [ "ptrauth"(i64 0, i64 0, i64 0), "ptrauth"(i64 %arg, i64 0, i64 0) ] -; WRONG-SECOND-BUNDLE-NEXT: LLVM ERROR: Invalid ptrauth bundle: test: Key must be constant in ptrauth bundle on AArch64 +; WRONG-SECOND-BUNDLE-NEXT: LLVM ERROR: Invalid ptrauth schema: test: key must be constant in range [0, 3] define i64 @test(i64 %p, i64 %arg) { %res = call i64 @llvm.ptrauth.resign(i64 %p) [ "ptrauth"(i64 0, i64 0, i64 0), "ptrauth"(i64 %arg, i64 0, i64 0) ] From 7f9ac2555295719dc3493ba562491969a94a70cd Mon Sep 17 00:00:00 2001 From: Anatoly Trosinenko Date: Wed, 10 Dec 2025 23:14:26 +0300 Subject: [PATCH 31/40] WIP: Make ConstantPtrAuth target-neutral --- clang/lib/CodeGen/CGPointerAuth.cpp | 18 +- clang/test/CodeGen/ptrauth-function-init.c | 4 +- ...ptrauth-function-type-discriminator-cast.c | 6 +- .../ptrauth-function-type-discriminator.c | 36 +-- clang/test/CodeGen/ptrauth-init-fini.c | 8 +- .../CodeGen/ptrauth-intrinsic-sign-constant.c | 16 +- .../CodeGen/ptrauth-qualifier-const-init.c | 44 +-- .../test/CodeGen/ptrauth-qualifier-function.c | 4 +- .../CodeGen/ptrauth-qualifier-loadstore.c | 8 +- .../ptrauth-restricted-intptr-qualifier.c | 8 +- clang/test/CodeGen/ptrauth-weak_import.c | 2 +- .../CodeGenCXX/mangle-itanium-ptrauth.cpp | 2 +- .../ptrauth-apple-kext-indirect-call-2.cpp | 8 +- .../ptrauth-apple-kext-indirect-call.cpp | 2 +- ...-apple-kext-indirect-virtual-dtor-call.cpp | 2 +- ...trauth-explicit-vtable-pointer-control.cpp | 6 +- .../ptrauth-global-constant-initializers.cpp | 36 +-- .../ptrauth-member-function-pointer.cpp | 66 ++--- clang/test/CodeGenCXX/ptrauth-rtti-layout.cpp | 4 +- .../CodeGenCXX/ptrauth-static-destructors.cpp | 8 +- clang/test/CodeGenCXX/ptrauth-throw.cpp | 4 +- .../CodeGenCXX/ptrauth-type-info-vtable.cpp | 6 +- .../CodeGenCXX/ptrauth-virtual-function.cpp | 128 ++++----- ...rauth-vtable-virtual-inheritance-thunk.cpp | 256 +++++++++--------- clang/test/CodeGenCXX/ptrauth.cpp | 2 +- .../test/CodeGenObjC/ptrauth-attr-exception.m | 2 +- .../ptrauth-block-descriptor-pointer.m | 4 +- clang/test/CodeGenObjC/ptrauth-block-isa.m | 2 +- clang/test/CodeGenObjC/ptrauth-class-ro.m | 8 +- .../test/CodeGenObjC/ptrauth-objc-isa-super.m | 10 +- .../ptrauth-objc-method-list-pointer.m | 8 +- llvm/docs/GlobalISel/GenericOpcode.rst | 2 + llvm/include/llvm-c/Core.h | 19 +- llvm/include/llvm/Bitcode/LLVMBitCodes.h | 2 + .../CodeGen/GlobalISel/MachineIRBuilder.h | 5 +- llvm/include/llvm/CodeGen/ISDOpcodes.h | 2 +- llvm/include/llvm/CodeGen/TargetLowering.h | 10 +- llvm/include/llvm/IR/Constants.h | 38 ++- llvm/include/llvm/IR/User.h | 1 + llvm/include/llvm/SandboxIR/Constant.h | 14 +- llvm/include/llvm/Target/GenericOpcodes.td | 2 +- llvm/lib/AsmParser/LLParser.cpp | 65 +++-- llvm/lib/Bitcode/CMakeLists.txt | 1 + llvm/lib/Bitcode/Reader/BitcodeReader.cpp | 3 +- llvm/lib/Bitcode/Writer/BitcodeWriter.cpp | 2 +- llvm/lib/Bitstream/CMakeLists.txt | 1 + llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp | 21 +- .../CodeGen/GlobalISel/MachineIRBuilder.cpp | 9 +- llvm/lib/CodeGen/MachineVerifier.cpp | 1 + .../SelectionDAG/SelectionDAGBuilder.cpp | 14 +- llvm/lib/IR/AsmWriter.cpp | 27 +- llvm/lib/IR/Constants.cpp | 127 +++++---- llvm/lib/IR/ConstantsContext.h | 34 ++- llvm/lib/IR/Core.cpp | 29 +- llvm/lib/IR/Verifier.cpp | 23 +- llvm/lib/SandboxIR/Constant.cpp | 23 +- .../Target/AArch64/AArch64ISelLowering.cpp | 58 ++-- llvm/lib/Target/AArch64/AArch64ISelLowering.h | 2 +- .../GISel/AArch64InstructionSelector.cpp | 19 +- .../AArch64/GISel/AArch64LegalizerInfo.cpp | 4 +- .../InstCombine/InstCombineCalls.cpp | 19 +- llvm/lib/Transforms/Utils/ValueMapper.cpp | 4 +- llvm/test/Assembler/invalid-ptrauth-const1.ll | 4 +- llvm/test/Assembler/invalid-ptrauth-const2.ll | 4 +- llvm/test/Assembler/invalid-ptrauth-const3.ll | 4 +- llvm/test/Assembler/invalid-ptrauth-const4.ll | 4 +- llvm/test/Assembler/invalid-ptrauth-const5.ll | 6 - llvm/test/Assembler/invalid-ptrauth-const6.ll | 2 +- llvm/test/Assembler/ptrauth-const.ll | 24 +- llvm/test/Bindings/llvm-c/echo.ll | 4 +- llvm/test/Bitcode/compatibility.ll | 8 +- .../GlobalISel/legalizer-info-validation.mir | 2 +- .../GlobalISel/ptrauth-constant-in-code.ll | 54 ++-- .../test/CodeGen/AArch64/ptrauth-basic-pic.ll | 6 +- llvm/test/CodeGen/AArch64/ptrauth-call.ll | 14 +- .../AArch64/ptrauth-constant-in-code.ll | 54 ++-- .../ptrauth-elf-got-function-symbols.ll | 2 +- .../test/CodeGen/AArch64/ptrauth-init-fini.ll | 12 +- llvm/test/CodeGen/AArch64/ptrauth-invoke.ll | 4 +- .../test/CodeGen/AArch64/ptrauth-irelative.ll | 14 +- llvm/test/CodeGen/AArch64/ptrauth-reloc.ll | 22 +- .../AArch64/ptrauth-type-info-vptr-discr.ll | 4 +- .../MIR/AArch64/deactivation-symbols.mir | 2 +- .../global-constructor-complex-constants.ll | 4 +- .../Transforms/InstCombine/ptrauth-call.ll | 30 +- .../InstCombine/ptrauth-intrinsics.ll | 28 +- llvm/test/Verifier/ptrauth-constant.ll | 4 +- llvm/tools/llvm-c-test/echo.cpp | 23 +- llvm/unittests/SandboxIR/SandboxIRTest.cpp | 6 +- .../Transforms/Utils/ValueMapperTest.cpp | 14 +- 90 files changed, 877 insertions(+), 781 deletions(-) delete mode 100644 llvm/test/Assembler/invalid-ptrauth-const5.ll diff --git a/clang/lib/CodeGen/CGPointerAuth.cpp b/clang/lib/CodeGen/CGPointerAuth.cpp index 38d19b6a72da1..c4e0a1f0d6d79 100644 --- a/clang/lib/CodeGen/CGPointerAuth.cpp +++ b/clang/lib/CodeGen/CGPointerAuth.cpp @@ -382,9 +382,10 @@ CodeGenModule::getConstantSignedPointer(llvm::Constant *Pointer, unsigned Key, llvm::Constant *AddressDiscriminator; if (StorageAddress) { assert(StorageAddress->getType() == DefaultPtrTy); - AddressDiscriminator = StorageAddress; + AddressDiscriminator = llvm::ConstantExpr::getPtrToInt(StorageAddress, + Int64Ty); } else { - AddressDiscriminator = llvm::Constant::getNullValue(DefaultPtrTy); + AddressDiscriminator = llvm::ConstantInt::get(Int64Ty, 0); } llvm::ConstantInt *IntegerDiscriminator; @@ -395,10 +396,15 @@ CodeGenModule::getConstantSignedPointer(llvm::Constant *Pointer, unsigned Key, IntegerDiscriminator = llvm::ConstantInt::get(Int64Ty, 0); } - return llvm::ConstantPtrAuth::get( - Pointer, llvm::ConstantInt::get(Int32Ty, Key), IntegerDiscriminator, - AddressDiscriminator, - /*DeactivationSymbol=*/llvm::Constant::getNullValue(DefaultPtrTy)); + SmallVector Schema; + Schema.push_back(llvm::ConstantInt::get(Int64Ty, Key)); + Schema.push_back(IntegerDiscriminator); + Schema.push_back(AddressDiscriminator); + + llvm::Constant *Null = llvm::Constant::getNullValue(DefaultPtrTy); + + return llvm::ConstantPtrAuth::get(Pointer, Schema, + /*DeactivationSymbol=*/Null); } /// Does a given PointerAuthScheme require us to sign a value diff --git a/clang/test/CodeGen/ptrauth-function-init.c b/clang/test/CodeGen/ptrauth-function-init.c index bf8ee53364ecc..89dad8953edaf 100644 --- a/clang/test/CodeGen/ptrauth-function-init.c +++ b/clang/test/CodeGen/ptrauth-function-init.c @@ -12,7 +12,7 @@ void f(void); #ifdef __cplusplus // CXX: define {{(dso_local )?}}internal void @__cxx_global_var_init() -// CXX: store ptr getelementptr inbounds (i32, ptr ptrauth (ptr @f, i32 0), i64 2), ptr @_ZL2fp, align 8 +// CXX: store ptr getelementptr inbounds (i32, ptr ptrauth (ptr @f, [i64 0, i64 0, i64 0]), i64 2), ptr @_ZL2fp, align 8 // This is rejected in C mode as adding a non-zero constant to a signed pointer // is unrepresentable in relocations. In C++ mode, this can be done dynamically @@ -25,7 +25,7 @@ void (*const fp)(void) = (void (*)(void))((int *)&f + 2); // CHECK: define {{(dso_local )?}}void @t1() void t1() { // CHECK: [[PF:%.*]] = alloca ptr - // CHECK: store ptr getelementptr inbounds (i32, ptr ptrauth (ptr @f, i32 0), i64 2), ptr [[PF]] + // CHECK: store ptr getelementptr inbounds (i32, ptr ptrauth (ptr @f, [i64 0, i64 0, i64 0]), i64 2), ptr [[PF]] void (*pf)(void) = (void (*)(void))((int *)&f + 2); (void)pf; diff --git a/clang/test/CodeGen/ptrauth-function-type-discriminator-cast.c b/clang/test/CodeGen/ptrauth-function-type-discriminator-cast.c index 59b7130b81e47..1c034182bb664 100644 --- a/clang/test/CodeGen/ptrauth-function-type-discriminator-cast.c +++ b/clang/test/CodeGen/ptrauth-function-type-discriminator-cast.c @@ -42,7 +42,7 @@ void (*test_member)() = (void (*)())pm.fptr_; void test_cast_to_opaque() { opaque = (void *)f; - // TYPE: [[RESIGN_VAL:%.*]] = call i64 @llvm.ptrauth.resign(i64 ptrtoint (ptr ptrauth (ptr @f, i32 0, i64 18983) to i64)) [ "ptrauth"(i64 0, i64 18983, i64 0), "ptrauth"(i64 0, i64 0, i64 0) ] + // TYPE: [[RESIGN_VAL:%.*]] = call i64 @llvm.ptrauth.resign(i64 ptrtoint (ptr ptrauth (ptr @f, [i64 0, i64 18983, i64 0]) to i64)) [ "ptrauth"(i64 0, i64 18983, i64 0), "ptrauth"(i64 0, i64 0, i64 0) ] // TYPE: [[RESIGN_PTR:%.*]] = inttoptr i64 [[RESIGN_VAL]] to ptr // ZERO-NOT: @llvm.ptrauth.resign } @@ -95,11 +95,11 @@ void test_call_lvalue_cast() { (*(void (*)(int))f)(42); // TYPE: entry: - // TYPE-NEXT: [[RESIGN:%.*]] = call i64 @llvm.ptrauth.resign(i64 ptrtoint (ptr ptrauth (ptr @f, i32 0, i64 18983) to i64)) [ "ptrauth"(i64 0, i64 18983, i64 0), "ptrauth"(i64 0, i64 2712, i64 0) ] + // TYPE-NEXT: [[RESIGN:%.*]] = call i64 @llvm.ptrauth.resign(i64 ptrtoint (ptr ptrauth (ptr @f, [i64 0, i64 18983, i64 0]) to i64)) [ "ptrauth"(i64 0, i64 18983, i64 0), "ptrauth"(i64 0, i64 2712, i64 0) ] // TYPE-NEXT: [[RESIGN_INT:%.*]] = inttoptr i64 [[RESIGN]] to ptr // TYPE-NEXT: call void [[RESIGN_INT]](i32 noundef 42) [ "ptrauth"(i64 0, i64 2712, i64 0) ] // ZERO-NOT: @llvm.ptrauth.resign - // ZERO: call void ptrauth (ptr @f, i32 0)(i32 noundef 42) [ "ptrauth"(i64 0, i64 0, i64 0) ] + // ZERO: call void ptrauth (ptr @f, [i64 0, i64 0, i64 0])(i32 noundef 42) [ "ptrauth"(i64 0, i64 0, i64 0) ] } diff --git a/clang/test/CodeGen/ptrauth-function-type-discriminator.c b/clang/test/CodeGen/ptrauth-function-type-discriminator.c index 72b5c1423d639..773decff900f7 100644 --- a/clang/test/CodeGen/ptrauth-function-type-discriminator.c +++ b/clang/test/CodeGen/ptrauth-function-type-discriminator.c @@ -27,42 +27,42 @@ unsigned long uintptr; // CHECK: @test_constant_null = global ptr null void (*test_constant_null)(int) = 0; -// CHECK: @test_constant_cast = global ptr ptrauth (ptr @f, i32 0, i64 2712) +// CHECK: @test_constant_cast = global ptr ptrauth (ptr @f, [i64 0, i64 2712, i64 0]) void (*test_constant_cast)(int) = (void (*)(int))f; #ifndef __cplusplus -// CHECKC: @enum_func_ptr = global ptr ptrauth (ptr @enum_func, i32 0, i64 2712) +// CHECKC: @enum_func_ptr = global ptr ptrauth (ptr @enum_func, [i64 0, i64 2712, i64 0]) enum Enum0; void enum_func(enum Enum0); void (*enum_func_ptr)(enum Enum0) = enum_func; #endif -// CHECK: @test_opaque = global ptr ptrauth (ptr @f, i32 0) +// CHECK: @test_opaque = global ptr ptrauth (ptr @f, [i64 0, i64 0, i64 0]) void *test_opaque = #ifdef __cplusplus (void *) #endif (void (*)(int))(double (*)(double))f; -// CHECK: @test_intptr_t = global i64 ptrtoint (ptr ptrauth (ptr @f, i32 0) to i64) +// CHECK: @test_intptr_t = global i64 ptrtoint (ptr ptrauth (ptr @f, [i64 0, i64 0, i64 0]) to i64) unsigned long test_intptr_t = (unsigned long)f; -// CHECK: @test_through_long = global ptr ptrauth (ptr @f, i32 0, i64 2712) +// CHECK: @test_through_long = global ptr ptrauth (ptr @f, [i64 0, i64 2712, i64 0]) void (*test_through_long)(int) = (void (*)(int))(long)f; -// CHECK: @test_to_long = global i64 ptrtoint (ptr ptrauth (ptr @f, i32 0) to i64) +// CHECK: @test_to_long = global i64 ptrtoint (ptr ptrauth (ptr @f, [i64 0, i64 0, i64 0]) to i64) long test_to_long = (long)(double (*)())f; extern void external_function(void); -// CHECK: @fptr1 = global ptr ptrauth (ptr @external_function, i32 0, i64 18983) +// CHECK: @fptr1 = global ptr ptrauth (ptr @external_function, [i64 0, i64 18983, i64 0]) void (*fptr1)(void) = external_function; -// CHECK: @fptr2 = global ptr ptrauth (ptr @external_function, i32 0, i64 18983) +// CHECK: @fptr2 = global ptr ptrauth (ptr @external_function, [i64 0, i64 18983, i64 0]) void (*fptr2)(void) = &external_function; -// CHECK: @fptr3 = global ptr ptrauth (ptr @external_function, i32 2, i64 26) +// CHECK: @fptr3 = global ptr ptrauth (ptr @external_function, [i64 2, i64 26, i64 0]) void (*fptr3)(void) = __builtin_ptrauth_sign_constant(&external_function, 2, 26); -// CHECK: @fptr4 = global ptr ptrauth (ptr @external_function, i32 2, i64 26, ptr @fptr4) +// CHECK: @fptr4 = global ptr ptrauth (ptr @external_function, [i64 2, i64 26, i64 ptrtoint (ptr @fptr4 to i64)]) void (*fptr4)(void) = __builtin_ptrauth_sign_constant(&external_function, 2, __builtin_ptrauth_blend_discriminator(&fptr4, 26)); // CHECK-LABEL: define{{.*}} void @test_call() @@ -73,7 +73,7 @@ void test_call() { } // CHECK-LABEL: define{{.*}} ptr @test_function_pointer() -// CHECK: ret ptr ptrauth (ptr @external_function, i32 0, i64 18983) +// CHECK: ret ptr ptrauth (ptr @external_function, [i64 0, i64 18983, i64 0]) void (*test_function_pointer())(void) { return external_function; } @@ -83,14 +83,14 @@ extern struct InitiallyIncomplete returns_initially_incomplete(void); // CHECK-LABEL: define{{.*}} void @use_while_incomplete() void use_while_incomplete() { // CHECK: [[VAR:%.*]] = alloca ptr, - // CHECK-NEXT: store ptr ptrauth (ptr @returns_initially_incomplete, i32 0, i64 25106), ptr [[VAR]] + // CHECK-NEXT: store ptr ptrauth (ptr @returns_initially_incomplete, [i64 0, i64 25106, i64 0]), ptr [[VAR]] struct InitiallyIncomplete (*fnptr)(void) = &returns_initially_incomplete; } struct InitiallyIncomplete { int x; }; // CHECK-LABEL: define{{.*}} void @use_while_complete() void use_while_complete() { // CHECK: [[VAR:%.*]] = alloca ptr, - // CHECK-NEXT: store ptr ptrauth (ptr @returns_initially_incomplete, i32 0, i64 25106), ptr [[VAR]] + // CHECK-NEXT: store ptr ptrauth (ptr @returns_initially_incomplete, [i64 0, i64 25106, i64 0]), ptr [[VAR]] // CHECK-NEXT: ret void struct InitiallyIncomplete (*fnptr)(void) = &returns_initially_incomplete; } @@ -107,7 +107,7 @@ void test_knr() { p(0); // CHECKC: [[P:%.*]] = alloca ptr - // CHECKC: store ptr ptrauth (ptr @knr, i32 0, i64 18983), ptr [[P]] + // CHECKC: store ptr ptrauth (ptr @knr, [i64 0, i64 18983, i64 0]), ptr [[P]] // CHECKC: [[LOAD:%.*]] = load ptr, ptr [[P]] // CHECKC: call void [[LOAD]](i32 noundef 0) [ "ptrauth"(i64 0, i64 18983, i64 0) ] } @@ -121,8 +121,8 @@ void test_redeclaration() { ptr(); ptr2(0); - // CHECKC: store ptr ptrauth (ptr @redecl, i32 0, i64 18983), ptr %ptr - // CHECKC: store ptr ptrauth (ptr @redecl, i32 0, i64 2712), ptr %ptr2 + // CHECKC: store ptr ptrauth (ptr @redecl, [i64 0, i64 18983, i64 0]), ptr %ptr + // CHECKC: store ptr ptrauth (ptr @redecl, [i64 0, i64 2712, i64 0]), ptr %ptr2 // CHECKC: call void {{.*}}() [ "ptrauth"(i64 0, i64 18983, i64 0) ] // CHECKC: call void {{.*}}(i32 noundef 0) [ "ptrauth"(i64 0, i64 2712, i64 0) ] } @@ -136,7 +136,7 @@ void test_redecl_knr() { void (*p)() = knr2; p(); - // CHECKC: store ptr ptrauth (ptr @knr2, i32 0, i64 18983) + // CHECKC: store ptr ptrauth (ptr @knr2, [i64 0, i64 18983, i64 0]) // CHECKC: call void {{.*}}() [ "ptrauth"(i64 0, i64 18983, i64 0) ] void knr2(int); @@ -144,7 +144,7 @@ void test_redecl_knr() { void (*p2)(int) = knr2; p2(0); - // CHECKC: store ptr ptrauth (ptr @knr2, i32 0, i64 2712) + // CHECKC: store ptr ptrauth (ptr @knr2, [i64 0, i64 2712, i64 0]) // CHECKC: call void {{.*}}(i32 noundef 0) [ "ptrauth"(i64 0, i64 2712, i64 0) ] } diff --git a/clang/test/CodeGen/ptrauth-init-fini.c b/clang/test/CodeGen/ptrauth-init-fini.c index 1e8953961d64e..834e17fd4f9d4 100644 --- a/clang/test/CodeGen/ptrauth-init-fini.c +++ b/clang/test/CodeGen/ptrauth-init-fini.c @@ -15,11 +15,11 @@ // RUN: %clang_cc1 -triple aarch64-elf -target-feature +pauth -fptrauth-init-fini \ // RUN: -emit-llvm %s -o - | FileCheck --check-prefix=UNSIGNED %s -// SIGNED: @llvm.global_ctors = appending global [1 x { i32, ptr, ptr }] [{ i32, ptr, ptr } { i32 65535, ptr ptrauth (ptr @foo, i32 0, i64 55764), ptr null }] -// SIGNED: @llvm.global_dtors = appending global [1 x { i32, ptr, ptr }] [{ i32, ptr, ptr } { i32 65535, ptr ptrauth (ptr @bar, i32 0, i64 55764), ptr null }] +// SIGNED: @llvm.global_ctors = appending global [1 x { i32, ptr, ptr }] [{ i32, ptr, ptr } { i32 65535, ptr ptrauth (ptr @foo, [i64 0, i64 55764, i64 0]), ptr null }] +// SIGNED: @llvm.global_dtors = appending global [1 x { i32, ptr, ptr }] [{ i32, ptr, ptr } { i32 65535, ptr ptrauth (ptr @bar, [i64 0, i64 55764, i64 0]), ptr null }] -// ADDRDISC: @llvm.global_ctors = appending global [1 x { i32, ptr, ptr }] [{ i32, ptr, ptr } { i32 65535, ptr ptrauth (ptr @foo, i32 0, i64 55764, ptr inttoptr (i64 1 to ptr)), ptr null }] -// ADDRDISC: @llvm.global_dtors = appending global [1 x { i32, ptr, ptr }] [{ i32, ptr, ptr } { i32 65535, ptr ptrauth (ptr @bar, i32 0, i64 55764, ptr inttoptr (i64 1 to ptr)), ptr null }] +// ADDRDISC: @llvm.global_ctors = appending global [1 x { i32, ptr, ptr }] [{ i32, ptr, ptr } { i32 65535, ptr ptrauth (ptr @foo, [i64 0, i64 55764, i64 ptrtoint (ptr inttoptr (i64 1 to ptr) to i64)]), ptr null }] +// ADDRDISC: @llvm.global_dtors = appending global [1 x { i32, ptr, ptr }] [{ i32, ptr, ptr } { i32 65535, ptr ptrauth (ptr @bar, [i64 0, i64 55764, i64 ptrtoint (ptr inttoptr (i64 1 to ptr) to i64)]), ptr null }] // UNSIGNED: @llvm.global_ctors = appending global [1 x { i32, ptr, ptr }] [{ i32, ptr, ptr } { i32 65535, ptr @foo, ptr null }] // UNSIGNED: @llvm.global_dtors = appending global [1 x { i32, ptr, ptr }] [{ i32, ptr, ptr } { i32 65535, ptr @bar, ptr null }] diff --git a/clang/test/CodeGen/ptrauth-intrinsic-sign-constant.c b/clang/test/CodeGen/ptrauth-intrinsic-sign-constant.c index bab39897b9427..5448692813ec3 100644 --- a/clang/test/CodeGen/ptrauth-intrinsic-sign-constant.c +++ b/clang/test/CodeGen/ptrauth-intrinsic-sign-constant.c @@ -3,16 +3,16 @@ extern int external; -// CHECK: @ptr1 = global ptr ptrauth (ptr @external, i32 0) +// CHECK: @ptr1 = global ptr ptrauth (ptr @external, [i64 0, i64 0, i64 0]) void *ptr1 = __builtin_ptrauth_sign_constant(&external, 0, 0); -// CHECK: @ptr2 = global ptr ptrauth (ptr @external, i32 0, i64 1234) +// CHECK: @ptr2 = global ptr ptrauth (ptr @external, [i64 0, i64 1234, i64 0]) void *ptr2 = __builtin_ptrauth_sign_constant(&external, 0, 1234); -// CHECK: @ptr3 = global ptr ptrauth (ptr @external, i32 2, i64 0, ptr @ptr3) +// CHECK: @ptr3 = global ptr ptrauth (ptr @external, [i64 2, i64 0, i64 ptrtoint (ptr @ptr3 to i64)]) void *ptr3 = __builtin_ptrauth_sign_constant(&external, 2, &ptr3); -// CHECK: @ptr4 = global ptr ptrauth (ptr @external, i32 2, i64 26, ptr @ptr4) +// CHECK: @ptr4 = global ptr ptrauth (ptr @external, [i64 2, i64 26, i64 ptrtoint (ptr @ptr4 to i64)]) void *ptr4 = __builtin_ptrauth_sign_constant(&external, 2, __builtin_ptrauth_blend_discriminator(&ptr4, 26)); // CHECK: @ptr5 = global ptr null @@ -21,10 +21,10 @@ void *ptr5; void test_sign_constant_code() { // CHECK-LABEL: define {{.*}}void @test_sign_constant_code() // CHECK-NEXT: entry: -// CHECK-NEXT: store ptr ptrauth (ptr @external, i32 0), ptr @ptr1, align 8 -// CHECK-NEXT: store ptr ptrauth (ptr @external, i32 2, i64 1234), ptr @ptr2, align 8 -// CHECK-NEXT: store ptr ptrauth (ptr @external, i32 2, i64 0, ptr @ptr3), ptr @ptr3, align 8 -// CHECK-NEXT: store ptr ptrauth (ptr @external, i32 2, i64 1234, ptr @ptr4), ptr @ptr4, align 8 +// CHECK-NEXT: store ptr ptrauth (ptr @external, [i64 0, i64 0, i64 0]), ptr @ptr1, align 8 +// CHECK-NEXT: store ptr ptrauth (ptr @external, [i64 2, i64 1234, i64 0]), ptr @ptr2, align 8 +// CHECK-NEXT: store ptr ptrauth (ptr @external, [i64 2, i64 0, i64 ptrtoint (ptr @ptr3 to i64)]), ptr @ptr3, align 8 +// CHECK-NEXT: store ptr ptrauth (ptr @external, [i64 2, i64 1234, i64 ptrtoint (ptr @ptr4 to i64)]), ptr @ptr4, align 8 // CHECK-NEXT: ret void ptr1 = __builtin_ptrauth_sign_constant(&external, 0, 0); ptr2 = __builtin_ptrauth_sign_constant(&external, 2, 1234); diff --git a/clang/test/CodeGen/ptrauth-qualifier-const-init.c b/clang/test/CodeGen/ptrauth-qualifier-const-init.c index 174f328628f19..b985a13e084af 100644 --- a/clang/test/CodeGen/ptrauth-qualifier-const-init.c +++ b/clang/test/CodeGen/ptrauth-qualifier-const-init.c @@ -4,10 +4,10 @@ // Constant initializers for data pointers. extern int external_int; -// CHECK: @g1 = global ptr ptrauth (ptr @external_int, i32 1, i64 56) +// CHECK: @g1 = global ptr ptrauth (ptr @external_int, [i64 1, i64 56, i64 0]) int * __ptrauth(1,0,56) g1 = &external_int; -// CHECK: @g2 = global ptr ptrauth (ptr @external_int, i32 1, i64 1272, ptr @g2) +// CHECK: @g2 = global ptr ptrauth (ptr @external_int, [i64 1, i64 1272, i64 ptrtoint (ptr @g2 to i64)]) int * __ptrauth(1,1,1272) g2 = &external_int; // CHECK: @g3 = global ptr null @@ -18,9 +18,9 @@ int * __ptrauth(1,1,871) g3 = 0; int * __ptrauth(1,1,1902) g4 = (int*) 1230; // CHECK: @ga = global [3 x ptr] [ -// CHECK-SAME: ptr ptrauth (ptr @external_int, i32 1, i64 712, ptr @ga), -// CHECK-SAME: ptr ptrauth (ptr @external_int, i32 1, i64 712, ptr getelementptr inbounds ([3 x ptr], ptr @ga, i32 0, i32 1)), -// CHECK-SAME: ptr ptrauth (ptr @external_int, i32 1, i64 712, ptr getelementptr inbounds ([3 x ptr], ptr @ga, i32 0, i32 2))] +// CHECK-SAME: ptr ptrauth (ptr @external_int, [i64 1, i64 712, i64 ptrtoint (ptr @ga to i64)]), +// CHECK-SAME: ptr ptrauth (ptr @external_int, [i64 1, i64 712, i64 ptrtoint (ptr getelementptr inbounds ([3 x ptr], ptr @ga, i32 0, i32 1) to i64)]), +// CHECK-SAME: ptr ptrauth (ptr @external_int, [i64 1, i64 712, i64 ptrtoint (ptr getelementptr inbounds ([3 x ptr], ptr @ga, i32 0, i32 2) to i64)])] int * __ptrauth(1,1,712) ga[3] = { &external_int, &external_int, &external_int }; struct A { @@ -30,9 +30,9 @@ struct A { }; // CHECK: @gs1 = global %struct.A { -// CHECK-SAME: ptr ptrauth (ptr @external_int, i32 1, i64 431), -// CHECK-SAME: ptr ptrauth (ptr @external_int, i32 1, i64 9182), -// CHECK-SAME: ptr ptrauth (ptr @external_int, i32 1, i64 783) } +// CHECK-SAME: ptr ptrauth (ptr @external_int, [i64 1, i64 431, i64 0]), +// CHECK-SAME: ptr ptrauth (ptr @external_int, [i64 1, i64 9182, i64 0]), +// CHECK-SAME: ptr ptrauth (ptr @external_int, [i64 1, i64 783, i64 0]) } struct A gs1 = { &external_int, &external_int, &external_int }; struct B { @@ -42,25 +42,25 @@ struct B { }; // CHECK: @gs2 = global %struct.B { -// CHECK-SAME: ptr ptrauth (ptr @external_int, i32 1, i64 1276, ptr @gs2), -// CHECK-SAME: ptr ptrauth (ptr @external_int, i32 1, i64 23674, ptr getelementptr inbounds (%struct.B, ptr @gs2, i32 0, i32 1)), -// CHECK-SAME: ptr ptrauth (ptr @external_int, i32 1, i64 163, ptr getelementptr inbounds (%struct.B, ptr @gs2, i32 0, i32 2)) } +// CHECK-SAME: ptr ptrauth (ptr @external_int, [i64 1, i64 1276, i64 ptrtoint (ptr @gs2 to i64)]), +// CHECK-SAME: ptr ptrauth (ptr @external_int, [i64 1, i64 23674, i64 ptrtoint (ptr getelementptr inbounds (%struct.B, ptr @gs2, i32 0, i32 1) to i64)]), +// CHECK-SAME: ptr ptrauth (ptr @external_int, [i64 1, i64 163, i64 ptrtoint (ptr getelementptr inbounds (%struct.B, ptr @gs2, i32 0, i32 2) to i64)]) } struct B gs2 = { &external_int, &external_int, &external_int }; // Constant initializers for function pointers. extern void external_function(void); typedef void (*fpt)(void); -// CHECK: @f1 = global ptr ptrauth (ptr @external_function, i32 1, i64 56) +// CHECK: @f1 = global ptr ptrauth (ptr @external_function, [i64 1, i64 56, i64 0]) fpt __ptrauth(1,0,56) f1 = &external_function; -// CHECK: @f2 = global ptr ptrauth (ptr @external_function, i32 1, i64 1272, ptr @f2) +// CHECK: @f2 = global ptr ptrauth (ptr @external_function, [i64 1, i64 1272, i64 ptrtoint (ptr @f2 to i64)]) fpt __ptrauth(1,1,1272) f2 = &external_function; // CHECK: @fa = global [3 x ptr] [ -// CHECK-SAME: ptr ptrauth (ptr @external_function, i32 1, i64 712, ptr @fa), -// CHECK-SAME: ptr ptrauth (ptr @external_function, i32 1, i64 712, ptr getelementptr inbounds ([3 x ptr], ptr @fa, i32 0, i32 1)), -// CHECK-SAME: ptr ptrauth (ptr @external_function, i32 1, i64 712, ptr getelementptr inbounds ([3 x ptr], ptr @fa, i32 0, i32 2))] +// CHECK-SAME: ptr ptrauth (ptr @external_function, [i64 1, i64 712, i64 ptrtoint (ptr @fa to i64)]), +// CHECK-SAME: ptr ptrauth (ptr @external_function, [i64 1, i64 712, i64 ptrtoint (ptr getelementptr inbounds ([3 x ptr], ptr @fa, i32 0, i32 1) to i64)]), +// CHECK-SAME: ptr ptrauth (ptr @external_function, [i64 1, i64 712, i64 ptrtoint (ptr getelementptr inbounds ([3 x ptr], ptr @fa, i32 0, i32 2) to i64)])] fpt __ptrauth(1,1,712) fa[3] = { &external_function, &external_function, &external_function }; struct C { @@ -69,9 +69,9 @@ struct C { fpt __ptrauth(1,0,783) f2; }; // CHECK: @fs1 = global %struct.C { -// CHECK-SAME: ptr ptrauth (ptr @external_function, i32 1, i64 431), -// CHECK-SAME: ptr ptrauth (ptr @external_function, i32 1, i64 9182), -// CHECK-SAME: ptr ptrauth (ptr @external_function, i32 1, i64 783) } +// CHECK-SAME: ptr ptrauth (ptr @external_function, [i64 1, i64 431, i64 0]), +// CHECK-SAME: ptr ptrauth (ptr @external_function, [i64 1, i64 9182, i64 0]), +// CHECK-SAME: ptr ptrauth (ptr @external_function, [i64 1, i64 783, i64 0]) } struct C fs1 = { &external_function, &external_function, &external_function }; struct D { @@ -80,7 +80,7 @@ struct D { fpt __ptrauth(1,1,163) f2; }; // CHECK: @fs2 = global %struct.D { -// CHECK-SAME: ptr ptrauth (ptr @external_function, i32 1, i64 1276, ptr @fs2), -// CHECK-SAME: ptr ptrauth (ptr @external_function, i32 1, i64 23674, ptr getelementptr inbounds (%struct.D, ptr @fs2, i32 0, i32 1)), -// CHECK-SAME: ptr ptrauth (ptr @external_function, i32 1, i64 163, ptr getelementptr inbounds (%struct.D, ptr @fs2, i32 0, i32 2)) } +// CHECK-SAME: ptr ptrauth (ptr @external_function, [i64 1, i64 1276, i64 ptrtoint (ptr @fs2 to i64)]), +// CHECK-SAME: ptr ptrauth (ptr @external_function, [i64 1, i64 23674, i64 ptrtoint (ptr getelementptr inbounds (%struct.D, ptr @fs2, i32 0, i32 1) to i64)]), +// CHECK-SAME: ptr ptrauth (ptr @external_function, [i64 1, i64 163, i64 ptrtoint (ptr getelementptr inbounds (%struct.D, ptr @fs2, i32 0, i32 2) to i64)]) } struct D fs2 = { &external_function, &external_function, &external_function }; diff --git a/clang/test/CodeGen/ptrauth-qualifier-function.c b/clang/test/CodeGen/ptrauth-qualifier-function.c index b998184031a91..fe515da646b76 100644 --- a/clang/test/CodeGen/ptrauth-qualifier-function.c +++ b/clang/test/CodeGen/ptrauth-qualifier-function.c @@ -88,8 +88,8 @@ void test_assign_from_qualified() { void test_const_ptr_function_call(void) { f_const_ptr(1); - // TYPE: call void ptrauth (ptr @f, i32 0, i64 2712)(i32 noundef 1) [ "ptrauth"(i64 0, i64 2712, i64 0) ] - // ZERO: call void ptrauth (ptr @f, i32 0)(i32 noundef 1) [ "ptrauth"(i64 0, i64 0, i64 0) ] + // TYPE: call void ptrauth (ptr @f, [i64 0, i64 2712, i64 0])(i32 noundef 1) [ "ptrauth"(i64 0, i64 2712, i64 0) ] + // ZERO: call void ptrauth (ptr @f, [i64 0, i64 0, i64 0])(i32 noundef 1) [ "ptrauth"(i64 0, i64 0, i64 0) ] } #ifdef __cplusplus diff --git a/clang/test/CodeGen/ptrauth-qualifier-loadstore.c b/clang/test/CodeGen/ptrauth-qualifier-loadstore.c index 1a9c725bac281..382730935b137 100644 --- a/clang/test/CodeGen/ptrauth-qualifier-loadstore.c +++ b/clang/test/CodeGen/ptrauth-qualifier-loadstore.c @@ -393,11 +393,11 @@ void test_load_data_a() { // CHECK-LABEL: define {{.*}}void @test_store_function_i_constant() void test_store_function_i_constant() { // CHECK: [[V:%.*]] = alloca ptr, -// CHECK-NEXT: [[SIGN:%.*]] = call i64 @llvm.ptrauth.resign(i64 ptrtoint (ptr ptrauth (ptr @external_func, i32 0, i64 18983) to i64)) [ "ptrauth"(i64 0, i64 18983, i64 0), "ptrauth"(i64 1, i64 50, i64 0) ] +// CHECK-NEXT: [[SIGN:%.*]] = call i64 @llvm.ptrauth.resign(i64 ptrtoint (ptr ptrauth (ptr @external_func, [i64 0, i64 18983, i64 0]) to i64)) [ "ptrauth"(i64 0, i64 18983, i64 0), "ptrauth"(i64 1, i64 50, i64 0) ] // CHECK-NEXT: [[T0:%.*]] = inttoptr i64 [[SIGN]] to ptr // CHECK-NEXT: store ptr [[T0]], ptr [[V]], func_t * IQ iqpf = &external_func; -// CHECK-NEXT: [[SIGN:%.*]] = call i64 @llvm.ptrauth.resign(i64 ptrtoint (ptr ptrauth (ptr @external_func, i32 0, i64 18983) to i64)) [ "ptrauth"(i64 0, i64 18983, i64 0), "ptrauth"(i64 1, i64 50, i64 0) ] +// CHECK-NEXT: [[SIGN:%.*]] = call i64 @llvm.ptrauth.resign(i64 ptrtoint (ptr ptrauth (ptr @external_func, [i64 0, i64 18983, i64 0]) to i64)) [ "ptrauth"(i64 0, i64 18983, i64 0), "ptrauth"(i64 1, i64 50, i64 0) ] // CHECK-NEXT: [[T0:%.*]] = inttoptr i64 [[SIGN]] to ptr // CHECK-NEXT: store ptr [[T0]], ptr [[V]], iqpf = &external_func; @@ -548,12 +548,12 @@ void test_load_function_i() { void test_store_function_a_constant() { // CHECK: [[V:%.*]] = alloca ptr, // CHECK-NEXT: [[T0:%.*]] = ptrtoint ptr [[V]] to i64 -// CHECK-NEXT: [[SIGN:%.*]] = call i64 @llvm.ptrauth.resign(i64 ptrtoint (ptr ptrauth (ptr @external_func, i32 0, i64 18983) to i64)) [ "ptrauth"(i64 0, i64 18983, i64 0), "ptrauth"(i64 1, i64 50, i64 [[T0]]) ] +// CHECK-NEXT: [[SIGN:%.*]] = call i64 @llvm.ptrauth.resign(i64 ptrtoint (ptr ptrauth (ptr @external_func, [i64 0, i64 18983, i64 0]) to i64)) [ "ptrauth"(i64 0, i64 18983, i64 0), "ptrauth"(i64 1, i64 50, i64 [[T0]]) ] // CHECK-NEXT: [[T0:%.*]] = inttoptr i64 [[SIGN]] to ptr // CHECK-NEXT: store ptr [[T0]], ptr [[V]], func_t * AQ aqpf = &external_func; // CHECK-NEXT: [[T0:%.*]] = ptrtoint ptr [[V]] to i64 -// CHECK-NEXT: [[SIGN:%.*]] = call i64 @llvm.ptrauth.resign(i64 ptrtoint (ptr ptrauth (ptr @external_func, i32 0, i64 18983) to i64)) [ "ptrauth"(i64 0, i64 18983, i64 0), "ptrauth"(i64 1, i64 50, i64 [[T0]]) ] +// CHECK-NEXT: [[SIGN:%.*]] = call i64 @llvm.ptrauth.resign(i64 ptrtoint (ptr ptrauth (ptr @external_func, [i64 0, i64 18983, i64 0]) to i64)) [ "ptrauth"(i64 0, i64 18983, i64 0), "ptrauth"(i64 1, i64 50, i64 [[T0]]) ] // CHECK-NEXT: [[T0:%.*]] = inttoptr i64 [[SIGN]] to ptr // CHECK-NEXT: store ptr [[T0]], ptr [[V]], aqpf = &external_func; diff --git a/clang/test/CodeGen/ptrauth-restricted-intptr-qualifier.c b/clang/test/CodeGen/ptrauth-restricted-intptr-qualifier.c index 762398f74af8d..de7119e1bd808 100644 --- a/clang/test/CodeGen/ptrauth-restricted-intptr-qualifier.c +++ b/clang/test/CodeGen/ptrauth-restricted-intptr-qualifier.c @@ -9,11 +9,11 @@ __INTPTR_TYPE__ __ptrauth(1, 1, 1272) g2 = 0; extern __UINTPTR_TYPE__ test_int; __UINTPTR_TYPE__ __ptrauth(3, 1, 23) g3 = (__UINTPTR_TYPE__)&test_int; // CHECK: @test_int = external global i64 -// CHECK: @g3 = global i64 ptrtoint (ptr ptrauth (ptr @test_int, i32 3, i64 23, ptr @g3) to i64) +// CHECK: @g3 = global i64 ptrtoint (ptr ptrauth (ptr @test_int, [i64 3, i64 23, i64 ptrtoint (ptr @g3 to i64)]) to i64) __INTPTR_TYPE__ __ptrauth(1, 1, 712) ga[3] = {0,0,(__UINTPTR_TYPE__)&test_int}; -// CHECK: @ga = global [3 x i64] [i64 0, i64 0, i64 ptrtoint (ptr ptrauth (ptr @test_int, i32 1, i64 712, ptr getelementptr inbounds ([3 x i64], ptr @ga, i32 0, i32 2)) to i64)] +// CHECK: @ga = global [3 x i64] [i64 0, i64 0, i64 ptrtoint (ptr ptrauth (ptr @test_int, [i64 1, i64 712, i64 ptrtoint (ptr getelementptr inbounds ([3 x i64], ptr @ga, i32 0, i32 2) to i64)]) to i64)] struct A { __INTPTR_TYPE__ __ptrauth(1, 0, 431) f0; @@ -22,7 +22,7 @@ struct A { }; struct A gs1 = {0, 0, (__UINTPTR_TYPE__)&test_int}; -// CHECK: @gs1 = global %struct.A { i64 0, i64 0, i64 ptrtoint (ptr ptrauth (ptr @test_int, i32 1, i64 783) to i64) } +// CHECK: @gs1 = global %struct.A { i64 0, i64 0, i64 ptrtoint (ptr ptrauth (ptr @test_int, [i64 1, i64 783, i64 0]) to i64) } struct B { __INTPTR_TYPE__ __ptrauth(1, 1, 1276) f0; @@ -31,7 +31,7 @@ struct B { }; struct B gs2 = {0, 0, (__UINTPTR_TYPE__)&test_int}; -// CHECK: @gs2 = global %struct.B { i64 0, i64 0, i64 ptrtoint (ptr ptrauth (ptr @test_int, i32 1, i64 163, ptr getelementptr inbounds (%struct.B, ptr @gs2, i32 0, i32 2)) to i64) } +// CHECK: @gs2 = global %struct.B { i64 0, i64 0, i64 ptrtoint (ptr ptrauth (ptr @test_int, [i64 1, i64 163, i64 ptrtoint (ptr getelementptr inbounds (%struct.B, ptr @gs2, i32 0, i32 2) to i64)]) to i64) } // CHECK-LABEL: i64 @test_read_globals __INTPTR_TYPE__ test_read_globals() { diff --git a/clang/test/CodeGen/ptrauth-weak_import.c b/clang/test/CodeGen/ptrauth-weak_import.c index 1f53747a2640e..c5b4bbd69a9fb 100644 --- a/clang/test/CodeGen/ptrauth-weak_import.c +++ b/clang/test/CodeGen/ptrauth-weak_import.c @@ -4,7 +4,7 @@ extern void foo() __attribute__((weak_import)); // CHECK: define {{(dso_local )?}}void @bar() -// CHECK: [[TMP1:%.*]] = icmp ne ptr ptrauth (ptr @foo, i32 0), null +// CHECK: [[TMP1:%.*]] = icmp ne ptr ptrauth (ptr @foo, [i64 0, i64 0, i64 0]), null // CHECK: br i1 [[TMP1]], label void bar() { if (foo) diff --git a/clang/test/CodeGenCXX/mangle-itanium-ptrauth.cpp b/clang/test/CodeGenCXX/mangle-itanium-ptrauth.cpp index 155b766803a0a..14c7c118d3b60 100644 --- a/clang/test/CodeGenCXX/mangle-itanium-ptrauth.cpp +++ b/clang/test/CodeGenCXX/mangle-itanium-ptrauth.cpp @@ -5,7 +5,7 @@ // clang previously emitted an incorrect discriminator for the member function // pointer because of a bug in the mangler. -// CHECK: @_ZN17test_substitution5funcsE = global [1 x { i64, i64 }] [{ i64, i64 } { i64 ptrtoint (ptr ptrauth (ptr @_ZN17test_substitution1S1fEPvS1_, i32 0, i64 48995) to i64), i64 0 }], align 8 +// CHECK: @_ZN17test_substitution5funcsE = global [1 x { i64, i64 }] [{ i64, i64 } { i64 ptrtoint (ptr ptrauth (ptr @_ZN17test_substitution1S1fEPvS1_, [i64 0, i64 48995, i64 0]) to i64), i64 0 }], align 8 namespace test_substitution { struct S { int f(void *, void *); }; diff --git a/clang/test/CodeGenCXX/ptrauth-apple-kext-indirect-call-2.cpp b/clang/test/CodeGenCXX/ptrauth-apple-kext-indirect-call-2.cpp index 7a4aa1ba08f85..c1a9093ffdf57 100644 --- a/clang/test/CodeGenCXX/ptrauth-apple-kext-indirect-call-2.cpp +++ b/clang/test/CodeGenCXX/ptrauth-apple-kext-indirect-call-2.cpp @@ -1,9 +1,9 @@ // RUN: %clang_cc1 -triple arm64-apple-ios -fptrauth-calls -fapple-kext -fno-rtti -emit-llvm -o - %s | FileCheck %s -// CHECK: @_ZTV1A = unnamed_addr constant { [4 x ptr] } { [4 x ptr] [ptr null, ptr null, ptr ptrauth (ptr @_ZNK1A3abcEv, i32 0, i64 12401, ptr getelementptr inbounds ({ [4 x ptr] }, ptr @_ZTV1A, i32 0, i32 0, i32 2)), ptr null] }, align 8 -// CHECK: @_ZTV4Base = unnamed_addr constant { [4 x ptr] } { [4 x ptr] [ptr null, ptr null, ptr ptrauth (ptr @_ZNK4Base3abcEv, i32 0, i64 64320, ptr getelementptr inbounds ({ [4 x ptr] }, ptr @_ZTV4Base, i32 0, i32 0, i32 2)), ptr null] }, align 8 -// CHECK: @_ZTV8Derived2 = unnamed_addr constant { [5 x ptr] } { [5 x ptr] [ptr null, ptr null, ptr null, ptr ptrauth (ptr @_ZNK8Derived23efgEv, i32 0, i64 36603, ptr getelementptr inbounds ({ [5 x ptr] }, ptr @_ZTV8Derived2, i32 0, i32 0, i32 3)), ptr null] }, align 8 -// CHECK: @_ZTV2D2 = unnamed_addr constant { [5 x ptr] } { [5 x ptr] [ptr null, ptr null, ptr null, ptr ptrauth (ptr @_ZNK2D23abcEv, i32 0, i64 20222, ptr getelementptr inbounds ({ [5 x ptr] }, ptr @_ZTV2D2, i32 0, i32 0, i32 3)), ptr null] }, align 8 +// CHECK: @_ZTV1A = unnamed_addr constant { [4 x ptr] } { [4 x ptr] [ptr null, ptr null, ptr ptrauth (ptr @_ZNK1A3abcEv, [i64 0, i64 12401, i64 ptrtoint (ptr getelementptr inbounds ({ [4 x ptr] }, ptr @_ZTV1A, i32 0, i32 0, i32 2) to i64)]), ptr null] }, align 8 +// CHECK: @_ZTV4Base = unnamed_addr constant { [4 x ptr] } { [4 x ptr] [ptr null, ptr null, ptr ptrauth (ptr @_ZNK4Base3abcEv, [i64 0, i64 64320, i64 ptrtoint (ptr getelementptr inbounds ({ [4 x ptr] }, ptr @_ZTV4Base, i32 0, i32 0, i32 2) to i64)]), ptr null] }, align 8 +// CHECK: @_ZTV8Derived2 = unnamed_addr constant { [5 x ptr] } { [5 x ptr] [ptr null, ptr null, ptr null, ptr ptrauth (ptr @_ZNK8Derived23efgEv, [i64 0, i64 36603, i64 ptrtoint (ptr getelementptr inbounds ({ [5 x ptr] }, ptr @_ZTV8Derived2, i32 0, i32 0, i32 3) to i64)]), ptr null] }, align 8 +// CHECK: @_ZTV2D2 = unnamed_addr constant { [5 x ptr] } { [5 x ptr] [ptr null, ptr null, ptr null, ptr ptrauth (ptr @_ZNK2D23abcEv, [i64 0, i64 20222, i64 ptrtoint (ptr getelementptr inbounds ({ [5 x ptr] }, ptr @_ZTV2D2, i32 0, i32 0, i32 3) to i64)]), ptr null] }, align 8 struct A { virtual const char* abc(void) const; diff --git a/clang/test/CodeGenCXX/ptrauth-apple-kext-indirect-call.cpp b/clang/test/CodeGenCXX/ptrauth-apple-kext-indirect-call.cpp index 996829a14d7d1..1f2fb516ef5df 100644 --- a/clang/test/CodeGenCXX/ptrauth-apple-kext-indirect-call.cpp +++ b/clang/test/CodeGenCXX/ptrauth-apple-kext-indirect-call.cpp @@ -1,6 +1,6 @@ // RUN: %clang_cc1 -triple arm64-apple-ios -fptrauth-calls -fapple-kext -emit-llvm -o - %s | FileCheck %s -// CHECK: @_ZTV5TemplIiE = internal unnamed_addr constant { [5 x ptr] } { [5 x ptr] [ptr null, ptr @_ZTI5TemplIiE, ptr ptrauth (ptr @_ZN5TemplIiE1fEv, i32 0, i64 22189, ptr getelementptr inbounds ({ [5 x ptr] }, ptr @_ZTV5TemplIiE, i32 0, i32 0, i32 2)), ptr ptrauth (ptr @_ZN5TemplIiE1gEv, i32 0, i64 9912, ptr getelementptr inbounds ({ [5 x ptr] }, ptr @_ZTV5TemplIiE, i32 0, i32 0, i32 3)), ptr null] }, align 8 +// CHECK: @_ZTV5TemplIiE = internal unnamed_addr constant { [5 x ptr] } { [5 x ptr] [ptr null, ptr @_ZTI5TemplIiE, ptr ptrauth (ptr @_ZN5TemplIiE1fEv, [i64 0, i64 22189, i64 ptrtoint (ptr getelementptr inbounds ({ [5 x ptr] }, ptr @_ZTV5TemplIiE, i32 0, i32 0, i32 2) to i64)]), ptr ptrauth (ptr @_ZN5TemplIiE1gEv, [i64 0, i64 9912, i64 ptrtoint (ptr getelementptr inbounds ({ [5 x ptr] }, ptr @_ZTV5TemplIiE, i32 0, i32 0, i32 3) to i64)]), ptr null] }, align 8 struct Base { virtual void abc(void) const; diff --git a/clang/test/CodeGenCXX/ptrauth-apple-kext-indirect-virtual-dtor-call.cpp b/clang/test/CodeGenCXX/ptrauth-apple-kext-indirect-virtual-dtor-call.cpp index dcb1df0059fa0..470b91f336784 100644 --- a/clang/test/CodeGenCXX/ptrauth-apple-kext-indirect-virtual-dtor-call.cpp +++ b/clang/test/CodeGenCXX/ptrauth-apple-kext-indirect-virtual-dtor-call.cpp @@ -1,6 +1,6 @@ // RUN: %clang_cc1 -triple arm64-apple-ios -std=c++98 -fptrauth-calls -fapple-kext -fno-rtti -disable-O0-optnone -emit-llvm -o - %s | FileCheck %s -// CHECK: @_ZTV5TemplIiE = internal unnamed_addr constant { [7 x ptr] } { [7 x ptr] [ptr null, ptr null, ptr ptrauth (ptr @_ZN5TemplIiED1Ev, i32 0, i64 57986, ptr getelementptr inbounds ({ [7 x ptr] }, ptr @_ZTV5TemplIiE, i32 0, i32 0, i32 2)), ptr ptrauth (ptr @_ZN5TemplIiED0Ev, i32 0, i64 22856, ptr getelementptr inbounds ({ [7 x ptr] }, ptr @_ZTV5TemplIiE, i32 0, i32 0, i32 3)), ptr ptrauth (ptr @_ZN5TemplIiE1fEv, i32 0, i64 22189, ptr getelementptr inbounds ({ [7 x ptr] }, ptr @_ZTV5TemplIiE, i32 0, i32 0, i32 4)), ptr ptrauth (ptr @_ZN5TemplIiE1gEv, i32 0, i64 9912, ptr getelementptr inbounds ({ [7 x ptr] }, ptr @_ZTV5TemplIiE, i32 0, i32 0, i32 5)), ptr null] }, align 8 +// CHECK: @_ZTV5TemplIiE = internal unnamed_addr constant { [7 x ptr] } { [7 x ptr] [ptr null, ptr null, ptr ptrauth (ptr @_ZN5TemplIiED1Ev, [i64 0, i64 57986, i64 ptrtoint (ptr getelementptr inbounds ({ [7 x ptr] }, ptr @_ZTV5TemplIiE, i32 0, i32 0, i32 2) to i64)]), ptr ptrauth (ptr @_ZN5TemplIiED0Ev, [i64 0, i64 22856, i64 ptrtoint (ptr getelementptr inbounds ({ [7 x ptr] }, ptr @_ZTV5TemplIiE, i32 0, i32 0, i32 3) to i64)]), ptr ptrauth (ptr @_ZN5TemplIiE1fEv, [i64 0, i64 22189, i64 ptrtoint (ptr getelementptr inbounds ({ [7 x ptr] }, ptr @_ZTV5TemplIiE, i32 0, i32 0, i32 4) to i64)]), ptr ptrauth (ptr @_ZN5TemplIiE1gEv, [i64 0, i64 9912, i64 ptrtoint (ptr getelementptr inbounds ({ [7 x ptr] }, ptr @_ZTV5TemplIiE, i32 0, i32 0, i32 5) to i64)]), ptr null] }, align 8 struct B1 { virtual ~B1(); diff --git a/clang/test/CodeGenCXX/ptrauth-explicit-vtable-pointer-control.cpp b/clang/test/CodeGenCXX/ptrauth-explicit-vtable-pointer-control.cpp index 7f9aaf6e4b1d4..2d908e4007b3b 100644 --- a/clang/test/CodeGenCXX/ptrauth-explicit-vtable-pointer-control.cpp +++ b/clang/test/CodeGenCXX/ptrauth-explicit-vtable-pointer-control.cpp @@ -79,9 +79,9 @@ struct authenticated(default_key, default_address_discrimination, custom_discrim }; // CHECK: @_ZTVN5test19ConstEvalE = external unnamed_addr constant { [3 x ptr] }, align 8 -// CHECK: @_ZN5test12ceE = global %{{.*}} { ptr ptrauth (ptr getelementptr inbounds inrange(-16, 8) ({ [3 x ptr] }, ptr @_ZTVN5test19ConstEvalE, i32 0, i32 0, i32 2), i32 2, i64 0, ptr @_ZN5test12ceE) }, align 8 -// CHECK: @_ZTVN5test116ConstEvalDerivedE = linkonce_odr unnamed_addr constant { [3 x ptr] } { [3 x ptr] [ptr null, ptr @_ZTIN5test116ConstEvalDerivedE, ptr ptrauth (ptr @_ZN5test19ConstEval1fEv, i32 0, i64 26259, ptr getelementptr inbounds ({ [3 x ptr] }, ptr @_ZTVN5test116ConstEvalDerivedE, i32 0, i32 0, i32 2))] },{{.*}}align 8 -// CHECK: @_ZN5test13cedE = global { ptr } { ptr ptrauth (ptr getelementptr inbounds inrange(-16, 8) ({ [3 x ptr] }, ptr @_ZTVN5test116ConstEvalDerivedE, i32 0, i32 0, i32 2), i32 2, i64 0, ptr @_ZN5test13cedE) }, align 8 +// CHECK: @_ZN5test12ceE = global %{{.*}} { ptr ptrauth (ptr getelementptr inbounds inrange(-16, 8) ({ [3 x ptr] }, ptr @_ZTVN5test19ConstEvalE, i32 0, i32 0, i32 2), [i64 2, i64 0, i64 ptrtoint (ptr @_ZN5test12ceE to i64)]) }, align 8 +// CHECK: @_ZTVN5test116ConstEvalDerivedE = linkonce_odr unnamed_addr constant { [3 x ptr] } { [3 x ptr] [ptr null, ptr @_ZTIN5test116ConstEvalDerivedE, ptr ptrauth (ptr @_ZN5test19ConstEval1fEv, [i64 0, i64 26259, i64 ptrtoint (ptr getelementptr inbounds ({ [3 x ptr] }, ptr @_ZTVN5test116ConstEvalDerivedE, i32 0, i32 0, i32 2) to i64)])] },{{.*}}align 8 +// CHECK: @_ZN5test13cedE = global { ptr } { ptr ptrauth (ptr getelementptr inbounds inrange(-16, 8) ({ [3 x ptr] }, ptr @_ZTVN5test116ConstEvalDerivedE, i32 0, i32 0, i32 2), [i64 2, i64 0, i64 ptrtoint (ptr @_ZN5test13cedE to i64)]) }, align 8 struct authenticated(default_key, address_discrimination, no_extra_discrimination) ConstEval { consteval ConstEval() {} diff --git a/clang/test/CodeGenCXX/ptrauth-global-constant-initializers.cpp b/clang/test/CodeGenCXX/ptrauth-global-constant-initializers.cpp index 616b612ea798d..7c01ed09fa60c 100644 --- a/clang/test/CodeGenCXX/ptrauth-global-constant-initializers.cpp +++ b/clang/test/CodeGenCXX/ptrauth-global-constant-initializers.cpp @@ -9,27 +9,27 @@ // CHECK: %struct.Derived2 = type { %struct.Base2, %struct.Base1 } // CHECK: %struct.Derived3 = type { %struct.Base1, %struct.Base2 } -// CHECK: @_ZTV5Base1 = linkonce_odr unnamed_addr constant { [3 x ptr] } { [3 x ptr] [ptr null, ptr null, ptr ptrauth (ptr @_ZN5Base11aEv, i32 0, i64 [[BASE1_A_DISC:38871]], ptr getelementptr inbounds ({ [3 x ptr] }, ptr @_ZTV5Base1, i32 0, i32 0, i32 2))] },{{.*}} align 8 -// CHECK: @g_b1 = global %struct.Base1 { ptr ptrauth (ptr getelementptr inbounds inrange(-16, 8) ({ [3 x ptr] }, ptr @_ZTV5Base1, i32 0, i32 0, i32 2), i32 2, i64 [[BASE1_VTABLE_DISC:6511]], ptr @g_b1) },{{.*}} align 8 -// CHECK: @_ZTV5Base2 = linkonce_odr unnamed_addr constant { [3 x ptr] } { [3 x ptr] [ptr null, ptr null, ptr ptrauth (ptr @_ZN5Base21bEv, i32 0, i64 [[BASE2_B_DISC:27651]], ptr getelementptr inbounds ({ [3 x ptr] }, ptr @_ZTV5Base2, i32 0, i32 0, i32 2))] },{{.*}} align 8 -// CHECK: @g_b2 = global %struct.Base2 { ptr ptrauth (ptr getelementptr inbounds inrange(-16, 8) ({ [3 x ptr] }, ptr @_ZTV5Base2, i32 0, i32 0, i32 2), i32 2, i64 [[BASE2_VTABLE_DISC:63631]], ptr @g_b2) },{{.*}} align 8 -// CHECK: @_ZTV8Derived1 = linkonce_odr unnamed_addr constant { [5 x ptr], [3 x ptr] } { [5 x ptr] [ptr null, ptr null, ptr ptrauth (ptr @_ZN5Base11aEv, i32 0, i64 [[BASE1_A_DISC]], ptr getelementptr inbounds ({ [5 x ptr], [3 x ptr] }, ptr @_ZTV8Derived1, i32 0, i32 0, i32 2)), ptr ptrauth (ptr @_ZN8Derived11cEv, i32 0, i64 [[DERIVED1_C_DISC:54092]], ptr getelementptr inbounds ({ [5 x ptr], [3 x ptr] }, ptr @_ZTV8Derived1, i32 0, i32 0, i32 3)), ptr ptrauth (ptr @_ZN8Derived11dEv, i32 0, i64 [[DERIVED1_D_DISC:37391]], ptr getelementptr inbounds ({ [5 x ptr], [3 x ptr] }, ptr @_ZTV8Derived1, i32 0, i32 0, i32 4))], [3 x ptr] [ptr inttoptr (i64 -8 to ptr), ptr null, ptr ptrauth (ptr @_ZN5Base21bEv, i32 0, i64 [[BASE2_B_DISC]], ptr getelementptr inbounds ({ [5 x ptr], [3 x ptr] }, ptr @_ZTV8Derived1, i32 0, i32 1, i32 2))] },{{.*}} align 8 -// CHECK: @g_d1 = global { ptr, ptr } { ptr ptrauth (ptr getelementptr inbounds inrange(-16, 24) ({ [5 x ptr], [3 x ptr] }, ptr @_ZTV8Derived1, i32 0, i32 0, i32 2), i32 2, i64 [[BASE1_VTABLE_DISC]], ptr @g_d1), ptr ptrauth (ptr getelementptr inbounds inrange(-16, 8) ({ [5 x ptr], [3 x ptr] }, ptr @_ZTV8Derived1, i32 0, i32 1, i32 2), i32 2, i64 [[BASE2_VTABLE_DISC]], ptr getelementptr inbounds ({ ptr, ptr }, ptr @g_d1, i32 0, i32 1)) },{{.*}} align 8 -// CHECK: @_ZTV8Derived2 = linkonce_odr unnamed_addr constant { [5 x ptr], [3 x ptr] } { [5 x ptr] [ptr null, ptr null, ptr ptrauth (ptr @_ZN5Base21bEv, i32 0, i64 [[BASE2_B_DISC]], ptr getelementptr inbounds ({ [5 x ptr], [3 x ptr] }, ptr @_ZTV8Derived2, i32 0, i32 0, i32 2)), ptr ptrauth (ptr @_ZN8Derived21cEv, i32 0, i64 [[DERIVED2_C_DISC:15537]], ptr getelementptr inbounds ({ [5 x ptr], [3 x ptr] }, ptr @_ZTV8Derived2, i32 0, i32 0, i32 3)), ptr ptrauth (ptr @_ZN8Derived21eEv, i32 0, i64 209, ptr getelementptr inbounds ({ [5 x ptr], [3 x ptr] }, ptr @_ZTV8Derived2, i32 0, i32 0, i32 4))], [3 x ptr] [ptr inttoptr (i64 -8 to ptr), ptr null, ptr ptrauth (ptr @_ZN5Base11aEv, i32 0, i64 [[BASE1_A_DISC]], ptr getelementptr inbounds ({ [5 x ptr], [3 x ptr] }, ptr @_ZTV8Derived2, i32 0, i32 1, i32 2))] },{{.*}} align 8 -// CHECK: @g_d2 = global { ptr, ptr } { ptr ptrauth (ptr getelementptr inbounds inrange(-16, 24) ({ [5 x ptr], [3 x ptr] }, ptr @_ZTV8Derived2, i32 0, i32 0, i32 2), i32 2, i64 [[BASE2_VTABLE_DISC]], ptr @g_d2), ptr ptrauth (ptr getelementptr inbounds inrange(-16, 8) ({ [5 x ptr], [3 x ptr] }, ptr @_ZTV8Derived2, i32 0, i32 1, i32 2), i32 2, i64 [[BASE1_VTABLE_DISC]], ptr getelementptr inbounds ({ ptr, ptr }, ptr @g_d2, i32 0, i32 1)) },{{.*}} align 8 -// CHECK: @_ZTV8Derived3 = linkonce_odr unnamed_addr constant { [4 x ptr], [3 x ptr] } { [4 x ptr] [ptr null, ptr null, ptr ptrauth (ptr @_ZN5Base11aEv, i32 0, i64 [[BASE1_A_DISC]], ptr getelementptr inbounds ({ [4 x ptr], [3 x ptr] }, ptr @_ZTV8Derived3, i32 0, i32 0, i32 2)), ptr ptrauth (ptr @_ZN8Derived31iEv, i32 0, i64 [[DERIVED3_I_DISC:19084]], ptr getelementptr inbounds ({ [4 x ptr], [3 x ptr] }, ptr @_ZTV8Derived3, i32 0, i32 0, i32 3))], [3 x ptr] [ptr inttoptr (i64 -8 to ptr), ptr null, ptr ptrauth (ptr @_ZN5Base21bEv, i32 0, i64 [[BASE2_B_DISC]], ptr getelementptr inbounds ({ [4 x ptr], [3 x ptr] }, ptr @_ZTV8Derived3, i32 0, i32 1, i32 2))] },{{.*}} align 8 -// CHECK: @g_d3 = global { ptr, ptr } { ptr ptrauth (ptr getelementptr inbounds inrange(-16, 16) ({ [4 x ptr], [3 x ptr] }, ptr @_ZTV8Derived3, i32 0, i32 0, i32 2), i32 2, i64 [[BASE1_VTABLE_DISC]], ptr @g_d3), ptr ptrauth (ptr getelementptr inbounds inrange(-16, 8) ({ [4 x ptr], [3 x ptr] }, ptr @_ZTV8Derived3, i32 0, i32 1, i32 2), i32 2, i64 [[BASE2_VTABLE_DISC]], ptr getelementptr inbounds ({ ptr, ptr }, ptr @g_d3, i32 0, i32 1)) },{{.*}} align 8 +// CHECK: @_ZTV5Base1 = linkonce_odr unnamed_addr constant { [3 x ptr] } { [3 x ptr] [ptr null, ptr null, ptr ptrauth (ptr @_ZN5Base11aEv, [i64 0, i64 [[BASE1_A_DISC:38871]], i64 ptrtoint (ptr getelementptr inbounds ({ [3 x ptr] }, ptr @_ZTV5Base1, i32 0, i32 0, i32 2) to i64)])] },{{.*}} align 8 +// CHECK: @g_b1 = global %struct.Base1 { ptr ptrauth (ptr getelementptr inbounds inrange(-16, 8) ({ [3 x ptr] }, ptr @_ZTV5Base1, i32 0, i32 0, i32 2), [i64 2, i64 [[BASE1_VTABLE_DISC:6511]], i64 ptrtoint (ptr @g_b1 to i64)]) },{{.*}} align 8 +// CHECK: @_ZTV5Base2 = linkonce_odr unnamed_addr constant { [3 x ptr] } { [3 x ptr] [ptr null, ptr null, ptr ptrauth (ptr @_ZN5Base21bEv, [i64 0, i64 [[BASE2_B_DISC:27651]], i64 ptrtoint (ptr getelementptr inbounds ({ [3 x ptr] }, ptr @_ZTV5Base2, i32 0, i32 0, i32 2) to i64)])] },{{.*}} align 8 +// CHECK: @g_b2 = global %struct.Base2 { ptr ptrauth (ptr getelementptr inbounds inrange(-16, 8) ({ [3 x ptr] }, ptr @_ZTV5Base2, i32 0, i32 0, i32 2), [i64 2, i64 [[BASE2_VTABLE_DISC:63631]], i64 ptrtoint (ptr @g_b2 to i64)]) },{{.*}} align 8 +// CHECK: @_ZTV8Derived1 = linkonce_odr unnamed_addr constant { [5 x ptr], [3 x ptr] } { [5 x ptr] [ptr null, ptr null, ptr ptrauth (ptr @_ZN5Base11aEv, [i64 0, i64 [[BASE1_A_DISC]], i64 ptrtoint (ptr getelementptr inbounds ({ [5 x ptr], [3 x ptr] }, ptr @_ZTV8Derived1, i32 0, i32 0, i32 2) to i64)]), ptr ptrauth (ptr @_ZN8Derived11cEv, [i64 0, i64 [[DERIVED1_C_DISC:54092]], i64 ptrtoint (ptr getelementptr inbounds ({ [5 x ptr], [3 x ptr] }, ptr @_ZTV8Derived1, i32 0, i32 0, i32 3) to i64)]), ptr ptrauth (ptr @_ZN8Derived11dEv, [i64 0, i64 [[DERIVED1_D_DISC:37391]], i64 ptrtoint (ptr getelementptr inbounds ({ [5 x ptr], [3 x ptr] }, ptr @_ZTV8Derived1, i32 0, i32 0, i32 4) to i64)])], [3 x ptr] [ptr inttoptr (i64 -8 to ptr), ptr null, ptr ptrauth (ptr @_ZN5Base21bEv, [i64 0, i64 [[BASE2_B_DISC]], i64 ptrtoint (ptr getelementptr inbounds ({ [5 x ptr], [3 x ptr] }, ptr @_ZTV8Derived1, i32 0, i32 1, i32 2) to i64)])] },{{.*}} align 8 +// CHECK: @g_d1 = global { ptr, ptr } { ptr ptrauth (ptr getelementptr inbounds inrange(-16, 24) ({ [5 x ptr], [3 x ptr] }, ptr @_ZTV8Derived1, i32 0, i32 0, i32 2), [i64 2, i64 [[BASE1_VTABLE_DISC]], i64 ptrtoint (ptr @g_d1 to i64)]), ptr ptrauth (ptr getelementptr inbounds inrange(-16, 8) ({ [5 x ptr], [3 x ptr] }, ptr @_ZTV8Derived1, i32 0, i32 1, i32 2), [i64 2, i64 [[BASE2_VTABLE_DISC]], i64 ptrtoint (ptr getelementptr inbounds ({ ptr, ptr }, ptr @g_d1, i32 0, i32 1) to i64)]) },{{.*}} align 8 +// CHECK: @_ZTV8Derived2 = linkonce_odr unnamed_addr constant { [5 x ptr], [3 x ptr] } { [5 x ptr] [ptr null, ptr null, ptr ptrauth (ptr @_ZN5Base21bEv, [i64 0, i64 [[BASE2_B_DISC]], i64 ptrtoint (ptr getelementptr inbounds ({ [5 x ptr], [3 x ptr] }, ptr @_ZTV8Derived2, i32 0, i32 0, i32 2) to i64)]), ptr ptrauth (ptr @_ZN8Derived21cEv, [i64 0, i64 [[DERIVED2_C_DISC:15537]], i64 ptrtoint (ptr getelementptr inbounds ({ [5 x ptr], [3 x ptr] }, ptr @_ZTV8Derived2, i32 0, i32 0, i32 3) to i64)]), ptr ptrauth (ptr @_ZN8Derived21eEv, [i64 0, i64 209, i64 ptrtoint (ptr getelementptr inbounds ({ [5 x ptr], [3 x ptr] }, ptr @_ZTV8Derived2, i32 0, i32 0, i32 4) to i64)])], [3 x ptr] [ptr inttoptr (i64 -8 to ptr), ptr null, ptr ptrauth (ptr @_ZN5Base11aEv, [i64 0, i64 [[BASE1_A_DISC]], i64 ptrtoint (ptr getelementptr inbounds ({ [5 x ptr], [3 x ptr] }, ptr @_ZTV8Derived2, i32 0, i32 1, i32 2) to i64)])] },{{.*}} align 8 +// CHECK: @g_d2 = global { ptr, ptr } { ptr ptrauth (ptr getelementptr inbounds inrange(-16, 24) ({ [5 x ptr], [3 x ptr] }, ptr @_ZTV8Derived2, i32 0, i32 0, i32 2), [i64 2, i64 [[BASE2_VTABLE_DISC]], i64 ptrtoint (ptr @g_d2 to i64)]), ptr ptrauth (ptr getelementptr inbounds inrange(-16, 8) ({ [5 x ptr], [3 x ptr] }, ptr @_ZTV8Derived2, i32 0, i32 1, i32 2), [i64 2, i64 [[BASE1_VTABLE_DISC]], i64 ptrtoint (ptr getelementptr inbounds ({ ptr, ptr }, ptr @g_d2, i32 0, i32 1) to i64)]) },{{.*}} align 8 +// CHECK: @_ZTV8Derived3 = linkonce_odr unnamed_addr constant { [4 x ptr], [3 x ptr] } { [4 x ptr] [ptr null, ptr null, ptr ptrauth (ptr @_ZN5Base11aEv, [i64 0, i64 [[BASE1_A_DISC]], i64 ptrtoint (ptr getelementptr inbounds ({ [4 x ptr], [3 x ptr] }, ptr @_ZTV8Derived3, i32 0, i32 0, i32 2) to i64)]), ptr ptrauth (ptr @_ZN8Derived31iEv, [i64 0, i64 [[DERIVED3_I_DISC:19084]], i64 ptrtoint (ptr getelementptr inbounds ({ [4 x ptr], [3 x ptr] }, ptr @_ZTV8Derived3, i32 0, i32 0, i32 3) to i64)])], [3 x ptr] [ptr inttoptr (i64 -8 to ptr), ptr null, ptr ptrauth (ptr @_ZN5Base21bEv, [i64 0, i64 [[BASE2_B_DISC]], i64 ptrtoint (ptr getelementptr inbounds ({ [4 x ptr], [3 x ptr] }, ptr @_ZTV8Derived3, i32 0, i32 1, i32 2) to i64)])] },{{.*}} align 8 +// CHECK: @g_d3 = global { ptr, ptr } { ptr ptrauth (ptr getelementptr inbounds inrange(-16, 16) ({ [4 x ptr], [3 x ptr] }, ptr @_ZTV8Derived3, i32 0, i32 0, i32 2), [i64 2, i64 [[BASE1_VTABLE_DISC]], i64 ptrtoint (ptr @g_d3 to i64)]), ptr ptrauth (ptr getelementptr inbounds inrange(-16, 8) ({ [4 x ptr], [3 x ptr] }, ptr @_ZTV8Derived3, i32 0, i32 1, i32 2), [i64 2, i64 [[BASE2_VTABLE_DISC]], i64 ptrtoint (ptr getelementptr inbounds ({ ptr, ptr }, ptr @g_d3, i32 0, i32 1) to i64)]) },{{.*}} align 8 // CHECK: @g_vb1 = global %struct.VirtualBase1 zeroinitializer,{{.*}} align 8 // CHECK: @g_vb2 = global %struct.VirtualBase2 zeroinitializer,{{.*}} align 8 // CHECK: @g_d4 = global %struct.Derived4 zeroinitializer,{{.*}} align 8 -// CHECK: @_ZTV12VirtualBase1 = linkonce_odr unnamed_addr constant { [6 x ptr] } { [6 x ptr] [ptr null, ptr null, ptr null, ptr null, ptr ptrauth (ptr @_ZN5Base11aEv, i32 0, i64 [[BASE1_A_DISC]], ptr getelementptr inbounds ({ [6 x ptr] }, ptr @_ZTV12VirtualBase1, i32 0, i32 0, i32 4)), ptr ptrauth (ptr @_ZN12VirtualBase11fEv, i32 0, i64 [[VIRTUALBASE1_F_DISC:7987]], ptr getelementptr inbounds ({ [6 x ptr] }, ptr @_ZTV12VirtualBase1, i32 0, i32 0, i32 5))] },{{.*}} align 8 -// CHECK: @_ZTT12VirtualBase1 = linkonce_odr unnamed_addr constant [2 x ptr] [ptr ptrauth (ptr getelementptr inbounds inrange(-32, 16) ({ [6 x ptr] }, ptr @_ZTV12VirtualBase1, i32 0, i32 0, i32 4), i32 2), ptr ptrauth (ptr getelementptr inbounds inrange(-32, 16) ({ [6 x ptr] }, ptr @_ZTV12VirtualBase1, i32 0, i32 0, i32 4), i32 2)],{{.*}} align 8 -// CHECK: @_ZTV12VirtualBase2 = linkonce_odr unnamed_addr constant { [5 x ptr], [4 x ptr] } { [5 x ptr] [ptr inttoptr (i64 8 to ptr), ptr null, ptr null, ptr ptrauth (ptr @_ZN5Base21bEv, i32 0, i64 [[BASE2_B_DISC]], ptr getelementptr inbounds ({ [5 x ptr], [4 x ptr] }, ptr @_ZTV12VirtualBase2, i32 0, i32 0, i32 3)), ptr ptrauth (ptr @_ZN12VirtualBase21gEv, i32 0, i64 [[VIRTUALBASE2_G_DISC:51224]], ptr getelementptr inbounds ({ [5 x ptr], [4 x ptr] }, ptr @_ZTV12VirtualBase2, i32 0, i32 0, i32 4))], [4 x ptr] [ptr null, ptr inttoptr (i64 -8 to ptr), ptr null, ptr ptrauth (ptr @_ZN5Base11aEv, i32 0, i64 [[BASE1_A_DISC]], ptr getelementptr inbounds ({ [5 x ptr], [4 x ptr] }, ptr @_ZTV12VirtualBase2, i32 0, i32 1, i32 3))] },{{.*}} align 8 -// CHECK: @_ZTT12VirtualBase2 = linkonce_odr unnamed_addr constant [2 x ptr] [ptr ptrauth (ptr getelementptr inbounds inrange(-24, 16) ({ [5 x ptr], [4 x ptr] }, ptr @_ZTV12VirtualBase2, i32 0, i32 0, i32 3), i32 2), ptr ptrauth (ptr getelementptr inbounds inrange(-24, 8) ({ [5 x ptr], [4 x ptr] }, ptr @_ZTV12VirtualBase2, i32 0, i32 1, i32 3), i32 2)],{{.*}} align 8 -// CHECK: @_ZTV8Derived4 = linkonce_odr unnamed_addr constant { [7 x ptr], [5 x ptr] } { [7 x ptr] [ptr null, ptr null, ptr null, ptr null, ptr ptrauth (ptr @_ZN5Base11aEv, i32 0, i64 [[BASE1_A_DISC]], ptr getelementptr inbounds ({ [7 x ptr], [5 x ptr] }, ptr @_ZTV8Derived4, i32 0, i32 0, i32 4)), ptr ptrauth (ptr @_ZN12VirtualBase11fEv, i32 0, i64 [[VIRTUALBASE1_F_DISC]], ptr getelementptr inbounds ({ [7 x ptr], [5 x ptr] }, ptr @_ZTV8Derived4, i32 0, i32 0, i32 5)), ptr ptrauth (ptr @_ZN8Derived41hEv, i32 0, i64 [[DERIVED4_H_DISC:31844]], ptr getelementptr inbounds ({ [7 x ptr], [5 x ptr] }, ptr @_ZTV8Derived4, i32 0, i32 0, i32 6))], [5 x ptr] [ptr inttoptr (i64 -8 to ptr), ptr inttoptr (i64 -8 to ptr), ptr null, ptr ptrauth (ptr @_ZN5Base21bEv, i32 0, i64 [[BASE2_B_DISC]], ptr getelementptr inbounds ({ [7 x ptr], [5 x ptr] }, ptr @_ZTV8Derived4, i32 0, i32 1, i32 3)), ptr ptrauth (ptr @_ZN12VirtualBase21gEv, i32 0, i64 [[VIRTUALBASE2_G_DISC]], ptr getelementptr inbounds ({ [7 x ptr], [5 x ptr] }, ptr @_ZTV8Derived4, i32 0, i32 1, i32 4))] },{{.*}} align 8 -// CHECK: @_ZTT8Derived4 = linkonce_odr unnamed_addr constant [7 x ptr] [ptr ptrauth (ptr getelementptr inbounds inrange(-32, 24) ({ [7 x ptr], [5 x ptr] }, ptr @_ZTV8Derived4, i32 0, i32 0, i32 4), i32 2), ptr ptrauth (ptr getelementptr inbounds inrange(-32, 16) ({ [6 x ptr] }, ptr @_ZTC8Derived40_12VirtualBase1, i32 0, i32 0, i32 4), i32 2), ptr ptrauth (ptr getelementptr inbounds inrange(-32, 16) ({ [6 x ptr] }, ptr @_ZTC8Derived40_12VirtualBase1, i32 0, i32 0, i32 4), i32 2), ptr ptrauth (ptr getelementptr inbounds inrange(-24, 16) ({ [5 x ptr], [4 x ptr] }, ptr @_ZTC8Derived48_12VirtualBase2, i32 0, i32 0, i32 3), i32 2), ptr ptrauth (ptr getelementptr inbounds inrange(-24, 8) ({ [5 x ptr], [4 x ptr] }, ptr @_ZTC8Derived48_12VirtualBase2, i32 0, i32 1, i32 3), i32 2), ptr ptrauth (ptr getelementptr inbounds inrange(-32, 24) ({ [7 x ptr], [5 x ptr] }, ptr @_ZTV8Derived4, i32 0, i32 0, i32 4), i32 2), ptr ptrauth (ptr getelementptr inbounds inrange(-24, 16) ({ [7 x ptr], [5 x ptr] }, ptr @_ZTV8Derived4, i32 0, i32 1, i32 3), i32 2)],{{.*}} align 8 -// CHECK: @_ZTC8Derived40_12VirtualBase1 = linkonce_odr unnamed_addr constant { [6 x ptr] } { [6 x ptr] [ptr null, ptr null, ptr null, ptr null, ptr ptrauth (ptr @_ZN5Base11aEv, i32 0, i64 [[BASE1_A_DISC]], ptr getelementptr inbounds ({ [6 x ptr] }, ptr @_ZTC8Derived40_12VirtualBase1, i32 0, i32 0, i32 4)), ptr ptrauth (ptr @_ZN12VirtualBase11fEv, i32 0, i64 [[VIRTUALBASE1_F_DISC]], ptr getelementptr inbounds ({ [6 x ptr] }, ptr @_ZTC8Derived40_12VirtualBase1, i32 0, i32 0, i32 5))] },{{.*}} align 8 -// CHECK: @_ZTC8Derived48_12VirtualBase2 = linkonce_odr unnamed_addr constant { [5 x ptr], [4 x ptr] } { [5 x ptr] [ptr inttoptr (i64 -8 to ptr), ptr null, ptr null, ptr ptrauth (ptr @_ZN5Base21bEv, i32 0, i64 [[BASE2_B_DISC]], ptr getelementptr inbounds ({ [5 x ptr], [4 x ptr] }, ptr @_ZTC8Derived48_12VirtualBase2, i32 0, i32 0, i32 3)), ptr ptrauth (ptr @_ZN12VirtualBase21gEv, i32 0, i64 [[VIRTUALBASE2_G_DISC]], ptr getelementptr inbounds ({ [5 x ptr], [4 x ptr] }, ptr @_ZTC8Derived48_12VirtualBase2, i32 0, i32 0, i32 4))], [4 x ptr] [ptr null, ptr inttoptr (i64 8 to ptr), ptr null, ptr ptrauth (ptr @_ZN5Base11aEv, i32 0, i64 [[BASE1_A_DISC]], ptr getelementptr inbounds ({ [5 x ptr], [4 x ptr] }, ptr @_ZTC8Derived48_12VirtualBase2, i32 0, i32 1, i32 3))] },{{.*}} align 8 +// CHECK: @_ZTV12VirtualBase1 = linkonce_odr unnamed_addr constant { [6 x ptr] } { [6 x ptr] [ptr null, ptr null, ptr null, ptr null, ptr ptrauth (ptr @_ZN5Base11aEv, [i64 0, i64 [[BASE1_A_DISC]], i64 ptrtoint (ptr getelementptr inbounds ({ [6 x ptr] }, ptr @_ZTV12VirtualBase1, i32 0, i32 0, i32 4) to i64)]), ptr ptrauth (ptr @_ZN12VirtualBase11fEv, [i64 0, i64 [[VIRTUALBASE1_F_DISC:7987]], i64 ptrtoint (ptr getelementptr inbounds ({ [6 x ptr] }, ptr @_ZTV12VirtualBase1, i32 0, i32 0, i32 5) to i64)])] },{{.*}} align 8 +// CHECK: @_ZTT12VirtualBase1 = linkonce_odr unnamed_addr constant [2 x ptr] [ptr ptrauth (ptr getelementptr inbounds inrange(-32, 16) ({ [6 x ptr] }, ptr @_ZTV12VirtualBase1, i32 0, i32 0, i32 4), [i64 2, i64 0, i64 0]), ptr ptrauth (ptr getelementptr inbounds inrange(-32, 16) ({ [6 x ptr] }, ptr @_ZTV12VirtualBase1, i32 0, i32 0, i32 4), [i64 2, i64 0, i64 0])],{{.*}} align 8 +// CHECK: @_ZTV12VirtualBase2 = linkonce_odr unnamed_addr constant { [5 x ptr], [4 x ptr] } { [5 x ptr] [ptr inttoptr (i64 8 to ptr), ptr null, ptr null, ptr ptrauth (ptr @_ZN5Base21bEv, [i64 0, i64 [[BASE2_B_DISC]], i64 ptrtoint (ptr getelementptr inbounds ({ [5 x ptr], [4 x ptr] }, ptr @_ZTV12VirtualBase2, i32 0, i32 0, i32 3) to i64)]), ptr ptrauth (ptr @_ZN12VirtualBase21gEv, [i64 0, i64 [[VIRTUALBASE2_G_DISC:51224]], i64 ptrtoint (ptr getelementptr inbounds ({ [5 x ptr], [4 x ptr] }, ptr @_ZTV12VirtualBase2, i32 0, i32 0, i32 4) to i64)])], [4 x ptr] [ptr null, ptr inttoptr (i64 -8 to ptr), ptr null, ptr ptrauth (ptr @_ZN5Base11aEv, [i64 0, i64 [[BASE1_A_DISC]], i64 ptrtoint (ptr getelementptr inbounds ({ [5 x ptr], [4 x ptr] }, ptr @_ZTV12VirtualBase2, i32 0, i32 1, i32 3) to i64)])] },{{.*}} align 8 +// CHECK: @_ZTT12VirtualBase2 = linkonce_odr unnamed_addr constant [2 x ptr] [ptr ptrauth (ptr getelementptr inbounds inrange(-24, 16) ({ [5 x ptr], [4 x ptr] }, ptr @_ZTV12VirtualBase2, i32 0, i32 0, i32 3), [i64 2, i64 0, i64 0]), ptr ptrauth (ptr getelementptr inbounds inrange(-24, 8) ({ [5 x ptr], [4 x ptr] }, ptr @_ZTV12VirtualBase2, i32 0, i32 1, i32 3), [i64 2, i64 0, i64 0])],{{.*}} align 8 +// CHECK: @_ZTV8Derived4 = linkonce_odr unnamed_addr constant { [7 x ptr], [5 x ptr] } { [7 x ptr] [ptr null, ptr null, ptr null, ptr null, ptr ptrauth (ptr @_ZN5Base11aEv, [i64 0, i64 [[BASE1_A_DISC]], i64 ptrtoint (ptr getelementptr inbounds ({ [7 x ptr], [5 x ptr] }, ptr @_ZTV8Derived4, i32 0, i32 0, i32 4) to i64)]), ptr ptrauth (ptr @_ZN12VirtualBase11fEv, [i64 0, i64 [[VIRTUALBASE1_F_DISC]], i64 ptrtoint (ptr getelementptr inbounds ({ [7 x ptr], [5 x ptr] }, ptr @_ZTV8Derived4, i32 0, i32 0, i32 5) to i64)]), ptr ptrauth (ptr @_ZN8Derived41hEv, [i64 0, i64 [[DERIVED4_H_DISC:31844]], i64 ptrtoint (ptr getelementptr inbounds ({ [7 x ptr], [5 x ptr] }, ptr @_ZTV8Derived4, i32 0, i32 0, i32 6) to i64)])], [5 x ptr] [ptr inttoptr (i64 -8 to ptr), ptr inttoptr (i64 -8 to ptr), ptr null, ptr ptrauth (ptr @_ZN5Base21bEv, [i64 0, i64 [[BASE2_B_DISC]], i64 ptrtoint (ptr getelementptr inbounds ({ [7 x ptr], [5 x ptr] }, ptr @_ZTV8Derived4, i32 0, i32 1, i32 3) to i64)]), ptr ptrauth (ptr @_ZN12VirtualBase21gEv, [i64 0, i64 [[VIRTUALBASE2_G_DISC]], i64 ptrtoint (ptr getelementptr inbounds ({ [7 x ptr], [5 x ptr] }, ptr @_ZTV8Derived4, i32 0, i32 1, i32 4) to i64)])] },{{.*}} align 8 +// CHECK: @_ZTT8Derived4 = linkonce_odr unnamed_addr constant [7 x ptr] [ptr ptrauth (ptr getelementptr inbounds inrange(-32, 24) ({ [7 x ptr], [5 x ptr] }, ptr @_ZTV8Derived4, i32 0, i32 0, i32 4), [i64 2, i64 0, i64 0]), ptr ptrauth (ptr getelementptr inbounds inrange(-32, 16) ({ [6 x ptr] }, ptr @_ZTC8Derived40_12VirtualBase1, i32 0, i32 0, i32 4), [i64 2, i64 0, i64 0]), ptr ptrauth (ptr getelementptr inbounds inrange(-32, 16) ({ [6 x ptr] }, ptr @_ZTC8Derived40_12VirtualBase1, i32 0, i32 0, i32 4), [i64 2, i64 0, i64 0]), ptr ptrauth (ptr getelementptr inbounds inrange(-24, 16) ({ [5 x ptr], [4 x ptr] }, ptr @_ZTC8Derived48_12VirtualBase2, i32 0, i32 0, i32 3), [i64 2, i64 0, i64 0]), ptr ptrauth (ptr getelementptr inbounds inrange(-24, 8) ({ [5 x ptr], [4 x ptr] }, ptr @_ZTC8Derived48_12VirtualBase2, i32 0, i32 1, i32 3), [i64 2, i64 0, i64 0]), ptr ptrauth (ptr getelementptr inbounds inrange(-32, 24) ({ [7 x ptr], [5 x ptr] }, ptr @_ZTV8Derived4, i32 0, i32 0, i32 4), [i64 2, i64 0, i64 0]), ptr ptrauth (ptr getelementptr inbounds inrange(-24, 16) ({ [7 x ptr], [5 x ptr] }, ptr @_ZTV8Derived4, i32 0, i32 1, i32 3), [i64 2, i64 0, i64 0])],{{.*}} align 8 +// CHECK: @_ZTC8Derived40_12VirtualBase1 = linkonce_odr unnamed_addr constant { [6 x ptr] } { [6 x ptr] [ptr null, ptr null, ptr null, ptr null, ptr ptrauth (ptr @_ZN5Base11aEv, [i64 0, i64 [[BASE1_A_DISC]], i64 ptrtoint (ptr getelementptr inbounds ({ [6 x ptr] }, ptr @_ZTC8Derived40_12VirtualBase1, i32 0, i32 0, i32 4) to i64)]), ptr ptrauth (ptr @_ZN12VirtualBase11fEv, [i64 0, i64 [[VIRTUALBASE1_F_DISC]], i64 ptrtoint (ptr getelementptr inbounds ({ [6 x ptr] }, ptr @_ZTC8Derived40_12VirtualBase1, i32 0, i32 0, i32 5) to i64)])] },{{.*}} align 8 +// CHECK: @_ZTC8Derived48_12VirtualBase2 = linkonce_odr unnamed_addr constant { [5 x ptr], [4 x ptr] } { [5 x ptr] [ptr inttoptr (i64 -8 to ptr), ptr null, ptr null, ptr ptrauth (ptr @_ZN5Base21bEv, [i64 0, i64 [[BASE2_B_DISC]], i64 ptrtoint (ptr getelementptr inbounds ({ [5 x ptr], [4 x ptr] }, ptr @_ZTC8Derived48_12VirtualBase2, i32 0, i32 0, i32 3) to i64)]), ptr ptrauth (ptr @_ZN12VirtualBase21gEv, [i64 0, i64 [[VIRTUALBASE2_G_DISC]], i64 ptrtoint (ptr getelementptr inbounds ({ [5 x ptr], [4 x ptr] }, ptr @_ZTC8Derived48_12VirtualBase2, i32 0, i32 0, i32 4) to i64)])], [4 x ptr] [ptr null, ptr inttoptr (i64 8 to ptr), ptr null, ptr ptrauth (ptr @_ZN5Base11aEv, [i64 0, i64 [[BASE1_A_DISC]], i64 ptrtoint (ptr getelementptr inbounds ({ [5 x ptr], [4 x ptr] }, ptr @_ZTC8Derived48_12VirtualBase2, i32 0, i32 1, i32 3) to i64)])] },{{.*}} align 8 struct Base1 { virtual void a() {} }; struct Base2 { virtual void b() {} }; diff --git a/clang/test/CodeGenCXX/ptrauth-member-function-pointer.cpp b/clang/test/CodeGenCXX/ptrauth-member-function-pointer.cpp index c3b79121502bc..0d17de23ea070 100644 --- a/clang/test/CodeGenCXX/ptrauth-member-function-pointer.cpp +++ b/clang/test/CodeGenCXX/ptrauth-member-function-pointer.cpp @@ -13,23 +13,23 @@ // RUN: %clang_cc1 -triple aarch64-linux-gnu -fptrauth-calls -fptrauth-intrinsics -emit-llvm -std=c++11 -O1 -disable-llvm-passes -stack-protector 3 -o - %s | FileCheck %s -check-prefix=STACK-PROT -// CHECK: @gmethod0 = global { i64, i64 } { i64 ptrtoint (ptr ptrauth (ptr @_ZN5Base011nonvirtual0Ev, i32 0, i64 [[TYPEDISC1:35591]]) to i64), i64 0 }, align 8 -// CHECK: @gmethod1 = global { i64, i64 } { i64 ptrtoint (ptr ptrauth (ptr @_ZN8Derived011nonvirtual5Ev, i32 0, i64 [[TYPEDISC0:22163]]) to i64), i64 0 }, align 8 -// CHECK: @gmethod2 = global { i64, i64 } { i64 ptrtoint (ptr ptrauth (ptr @_ZN5Base08virtual1Ev_vfpthunk_, i32 0, i64 [[TYPEDISC0]]) to i64), i64 0 }, align 8 +// CHECK: @gmethod0 = global { i64, i64 } { i64 ptrtoint (ptr ptrauth (ptr @_ZN5Base011nonvirtual0Ev, [i64 0, i64 [[TYPEDISC1:35591]], i64 0]) to i64), i64 0 }, align 8 +// CHECK: @gmethod1 = global { i64, i64 } { i64 ptrtoint (ptr ptrauth (ptr @_ZN8Derived011nonvirtual5Ev, [i64 0, i64 [[TYPEDISC0:22163]], i64 0]) to i64), i64 0 }, align 8 +// CHECK: @gmethod2 = global { i64, i64 } { i64 ptrtoint (ptr ptrauth (ptr @_ZN5Base08virtual1Ev_vfpthunk_, [i64 0, i64 [[TYPEDISC0]], i64 0]) to i64), i64 0 }, align 8 -// CHECK: @__const._Z13testArrayInitv.p0 = private unnamed_addr constant [1 x { i64, i64 }] [{ i64, i64 } { i64 ptrtoint (ptr ptrauth (ptr @_ZN5Base011nonvirtual0Ev, i32 0, i64 35591) to i64), i64 0 }], align 8 -// CHECK: @__const._Z13testArrayInitv.p1 = private unnamed_addr constant [1 x { i64, i64 }] [{ i64, i64 } { i64 ptrtoint (ptr ptrauth (ptr @_ZN5Base08virtual1Ev_vfpthunk_, i32 0, i64 35591) to i64), i64 0 }], align 8 -// CHECK: @__const._Z13testArrayInitv.c0 = private unnamed_addr constant %struct.Class0 { { i64, i64 } { i64 ptrtoint (ptr ptrauth (ptr @_ZN5Base011nonvirtual0Ev, i32 0, i64 35591) to i64), i64 0 } }, align 8 -// CHECK: @__const._Z13testArrayInitv.c1 = private unnamed_addr constant %struct.Class0 { { i64, i64 } { i64 ptrtoint (ptr ptrauth (ptr @_ZN5Base08virtual1Ev_vfpthunk_, i32 0, i64 35591) to i64), i64 0 } }, align 8 +// CHECK: @__const._Z13testArrayInitv.p0 = private unnamed_addr constant [1 x { i64, i64 }] [{ i64, i64 } { i64 ptrtoint (ptr ptrauth (ptr @_ZN5Base011nonvirtual0Ev, [i64 0, i64 35591, i64 0]) to i64), i64 0 }], align 8 +// CHECK: @__const._Z13testArrayInitv.p1 = private unnamed_addr constant [1 x { i64, i64 }] [{ i64, i64 } { i64 ptrtoint (ptr ptrauth (ptr @_ZN5Base08virtual1Ev_vfpthunk_, [i64 0, i64 35591, i64 0]) to i64), i64 0 }], align 8 +// CHECK: @__const._Z13testArrayInitv.c0 = private unnamed_addr constant %struct.Class0 { { i64, i64 } { i64 ptrtoint (ptr ptrauth (ptr @_ZN5Base011nonvirtual0Ev, [i64 0, i64 35591, i64 0]) to i64), i64 0 } }, align 8 +// CHECK: @__const._Z13testArrayInitv.c1 = private unnamed_addr constant %struct.Class0 { { i64, i64 } { i64 ptrtoint (ptr ptrauth (ptr @_ZN5Base08virtual1Ev_vfpthunk_, [i64 0, i64 35591, i64 0]) to i64), i64 0 } }, align 8 -// CHECK: @_ZN22testNoexceptConversion6mfptr1E = global { i64, i64 } { i64 ptrtoint (ptr ptrauth (ptr @_ZN22testNoexceptConversion1S19nonvirtual_noexceptEv, i32 0, i64 [[TYPEDISC3:.*]]) to i64), i64 0 }, -// CHECK: @_ZN22testNoexceptConversion6mfptr2E = global { i64, i64 } { i64 ptrtoint (ptr ptrauth (ptr @_ZN22testNoexceptConversion1S16virtual_noexceptEv_vfpthunk_, i32 0, i64 [[TYPEDISC3]]) to i64), i64 0 }, -// CHECK: @_ZN22testNoexceptConversion15mfptr3_noexceptE = global { i64, i64 } { i64 ptrtoint (ptr ptrauth (ptr @_ZN22testNoexceptConversion1S19nonvirtual_noexceptEv, i32 0, i64 [[TYPEDISC3]]) to i64), i64 0 }, +// CHECK: @_ZN22testNoexceptConversion6mfptr1E = global { i64, i64 } { i64 ptrtoint (ptr ptrauth (ptr @_ZN22testNoexceptConversion1S19nonvirtual_noexceptEv, [i64 0, i64 [[TYPEDISC3:.*]], i64 0]) to i64), i64 0 }, +// CHECK: @_ZN22testNoexceptConversion6mfptr2E = global { i64, i64 } { i64 ptrtoint (ptr ptrauth (ptr @_ZN22testNoexceptConversion1S16virtual_noexceptEv_vfpthunk_, [i64 0, i64 [[TYPEDISC3]], i64 0]) to i64), i64 0 }, +// CHECK: @_ZN22testNoexceptConversion15mfptr3_noexceptE = global { i64, i64 } { i64 ptrtoint (ptr ptrauth (ptr @_ZN22testNoexceptConversion1S19nonvirtual_noexceptEv, [i64 0, i64 [[TYPEDISC3]], i64 0]) to i64), i64 0 }, // CHECK: @_ZTV5Base0 = unnamed_addr constant { [5 x ptr] } { [5 x ptr] [ptr null, ptr @_ZTI5Base0, -// CHECK-SAME: ptr ptrauth (ptr @_ZN5Base08virtual1Ev, i32 0, i64 55600, ptr getelementptr inbounds ({ [5 x ptr] }, ptr @_ZTV5Base0, i32 0, i32 0, i32 2)), -// CHECK-SAME: ptr ptrauth (ptr @_ZN5Base08virtual3Ev, i32 0, i64 53007, ptr getelementptr inbounds ({ [5 x ptr] }, ptr @_ZTV5Base0, i32 0, i32 0, i32 3)), -// CHECK-SAME: ptr ptrauth (ptr @_ZN5Base016virtual_variadicEiz, i32 0, i64 7464, ptr getelementptr inbounds ({ [5 x ptr] }, ptr @_ZTV5Base0, i32 0, i32 0, i32 4))] }, align 8 +// CHECK-SAME: ptr ptrauth (ptr @_ZN5Base08virtual1Ev, [i64 0, i64 55600, i64 ptrtoint (ptr getelementptr inbounds ({ [5 x ptr] }, ptr @_ZTV5Base0, i32 0, i32 0, i32 2) to i64)]), +// CHECK-SAME: ptr ptrauth (ptr @_ZN5Base08virtual3Ev, [i64 0, i64 53007, i64 ptrtoint (ptr getelementptr inbounds ({ [5 x ptr] }, ptr @_ZTV5Base0, i32 0, i32 0, i32 3) to i64)]), +// CHECK-SAME: ptr ptrauth (ptr @_ZN5Base016virtual_variadicEiz, [i64 0, i64 7464, i64 ptrtoint (ptr getelementptr inbounds ({ [5 x ptr] }, ptr @_ZTV5Base0, i32 0, i32 0, i32 4) to i64)])] }, align 8 typedef __SIZE_TYPE__ size_t; @@ -104,21 +104,21 @@ struct Class0 { // CHECK-NEXT: %[[METHOD5:.*]] = alloca { i64, i64 }, align 8 // CHECK-NEXT: %[[METHOD6:.*]] = alloca { i64, i64 }, align 8 // CHECK-NEXT: %[[METHOD7:.*]] = alloca { i64, i64 }, align 8 -// CHECK: store { i64, i64 } { i64 ptrtoint (ptr ptrauth (ptr @_ZN5Base011nonvirtual0Ev, i32 0, i64 [[TYPEDISC0]]) to i64), i64 0 }, ptr %[[METHOD0]], align 8 -// CHECK-NEXT: store { i64, i64 } { i64 ptrtoint (ptr ptrauth (ptr @_ZN5Base08virtual1Ev_vfpthunk_, i32 0, i64 [[TYPEDISC0]]) to i64), i64 0 }, ptr %[[METHOD0]], align 8 -// CHECK-NEXT: store { i64, i64 } { i64 ptrtoint (ptr ptrauth (ptr @_ZN5Base08virtual3Ev_vfpthunk_, i32 0, i64 [[TYPEDISC0]]) to i64), i64 0 }, ptr %[[METHOD0]], align 8 -// CHECK: store { i64, i64 } { i64 ptrtoint (ptr ptrauth (ptr @_ZN5Base016virtual_variadicEiz_vfpthunk_, i32 0, i64 34368) to i64), i64 0 }, ptr %[[VARMETHOD1]], align 8 -// CHECK: store { i64, i64 } { i64 ptrtoint (ptr ptrauth (ptr @_ZN5Base011nonvirtual0Ev, i32 0, i64 [[TYPEDISC1]]) to i64), i64 0 }, ptr %[[METHOD2]], align 8 -// CHECK-NEXT: store { i64, i64 } { i64 ptrtoint (ptr ptrauth (ptr @_ZN5Base08virtual1Ev_vfpthunk_, i32 0, i64 [[TYPEDISC1]]) to i64), i64 0 }, ptr %[[METHOD2]], align 8 -// CHECK-NEXT: store { i64, i64 } { i64 ptrtoint (ptr ptrauth (ptr @_ZN5Base08virtual3Ev_vfpthunk_, i32 0, i64 [[TYPEDISC1]]) to i64), i64 0 }, ptr %[[METHOD2]], align 8 -// CHECK-NEXT: store { i64, i64 } { i64 ptrtoint (ptr ptrauth (ptr @_ZN8Derived011nonvirtual5Ev, i32 0, i64 [[TYPEDISC1]]) to i64), i64 0 }, ptr %[[METHOD2]], align 8 -// CHECK-NEXT: store { i64, i64 } { i64 ptrtoint (ptr ptrauth (ptr @_ZN8Derived08virtual6Ev_vfpthunk_, i32 0, i64 [[TYPEDISC1]]) to i64), i64 0 }, ptr %[[METHOD2]], align 8 -// CHECK: store { i64, i64 } { i64 ptrtoint (ptr ptrauth (ptr @_ZN8Derived010return_aggEv_vfpthunk_, i32 0, i64 64418) to i64), i64 0 }, ptr %[[METHOD3]], align 8 -// CHECK: store { i64, i64 } { i64 ptrtoint (ptr ptrauth (ptr @_ZN8Derived04sretEv_vfpthunk_, i32 0, i64 28187) to i64), i64 0 }, ptr %[[METHOD4]], align 8 -// CHECK: store { i64, i64 } { i64 ptrtoint (ptr ptrauth (ptr @_ZN8Derived011trivial_abiE8TrivialS_vfpthunk_, i32 0, i64 8992) to i64), i64 0 }, ptr %[[METHOD5]], align 8 -// CHECK: store { i64, i64 } { i64 ptrtoint (ptr ptrauth (ptr @_ZN5Base18virtual7Ev_vfpthunk_, i32 0, i64 [[TYPEDISC2:61596]]) to i64), i64 0 }, ptr %[[METHOD6]], align 8 -// CHECK: store { i64, i64 } { i64 ptrtoint (ptr ptrauth (ptr @_ZN8Derived18virtual7Ev_vfpthunk_, i32 0, i64 25206) to i64), i64 0 }, ptr %[[METHOD7]], align 8 -// CHECK-NEXT: store { i64, i64 } { i64 ptrtoint (ptr ptrauth (ptr @_ZN5Base08virtual1Ev_vfpthunk_, i32 0, i64 25206) to i64), i64 0 }, ptr %[[METHOD7]], align 8 +// CHECK: store { i64, i64 } { i64 ptrtoint (ptr ptrauth (ptr @_ZN5Base011nonvirtual0Ev, [i64 0, i64 [[TYPEDISC0]], i64 0]) to i64), i64 0 }, ptr %[[METHOD0]], align 8 +// CHECK-NEXT: store { i64, i64 } { i64 ptrtoint (ptr ptrauth (ptr @_ZN5Base08virtual1Ev_vfpthunk_, [i64 0, i64 [[TYPEDISC0]], i64 0]) to i64), i64 0 }, ptr %[[METHOD0]], align 8 +// CHECK-NEXT: store { i64, i64 } { i64 ptrtoint (ptr ptrauth (ptr @_ZN5Base08virtual3Ev_vfpthunk_, [i64 0, i64 [[TYPEDISC0]], i64 0]) to i64), i64 0 }, ptr %[[METHOD0]], align 8 +// CHECK: store { i64, i64 } { i64 ptrtoint (ptr ptrauth (ptr @_ZN5Base016virtual_variadicEiz_vfpthunk_, [i64 0, i64 34368, i64 0]) to i64), i64 0 }, ptr %[[VARMETHOD1]], align 8 +// CHECK: store { i64, i64 } { i64 ptrtoint (ptr ptrauth (ptr @_ZN5Base011nonvirtual0Ev, [i64 0, i64 [[TYPEDISC1]], i64 0]) to i64), i64 0 }, ptr %[[METHOD2]], align 8 +// CHECK-NEXT: store { i64, i64 } { i64 ptrtoint (ptr ptrauth (ptr @_ZN5Base08virtual1Ev_vfpthunk_, [i64 0, i64 [[TYPEDISC1]], i64 0]) to i64), i64 0 }, ptr %[[METHOD2]], align 8 +// CHECK-NEXT: store { i64, i64 } { i64 ptrtoint (ptr ptrauth (ptr @_ZN5Base08virtual3Ev_vfpthunk_, [i64 0, i64 [[TYPEDISC1]], i64 0]) to i64), i64 0 }, ptr %[[METHOD2]], align 8 +// CHECK-NEXT: store { i64, i64 } { i64 ptrtoint (ptr ptrauth (ptr @_ZN8Derived011nonvirtual5Ev, [i64 0, i64 [[TYPEDISC1]], i64 0]) to i64), i64 0 }, ptr %[[METHOD2]], align 8 +// CHECK-NEXT: store { i64, i64 } { i64 ptrtoint (ptr ptrauth (ptr @_ZN8Derived08virtual6Ev_vfpthunk_, [i64 0, i64 [[TYPEDISC1]], i64 0]) to i64), i64 0 }, ptr %[[METHOD2]], align 8 +// CHECK: store { i64, i64 } { i64 ptrtoint (ptr ptrauth (ptr @_ZN8Derived010return_aggEv_vfpthunk_, [i64 0, i64 64418, i64 0]) to i64), i64 0 }, ptr %[[METHOD3]], align 8 +// CHECK: store { i64, i64 } { i64 ptrtoint (ptr ptrauth (ptr @_ZN8Derived04sretEv_vfpthunk_, [i64 0, i64 28187, i64 0]) to i64), i64 0 }, ptr %[[METHOD4]], align 8 +// CHECK: store { i64, i64 } { i64 ptrtoint (ptr ptrauth (ptr @_ZN8Derived011trivial_abiE8TrivialS_vfpthunk_, [i64 0, i64 8992, i64 0]) to i64), i64 0 }, ptr %[[METHOD5]], align 8 +// CHECK: store { i64, i64 } { i64 ptrtoint (ptr ptrauth (ptr @_ZN5Base18virtual7Ev_vfpthunk_, [i64 0, i64 [[TYPEDISC2:61596]], i64 0]) to i64), i64 0 }, ptr %[[METHOD6]], align 8 +// CHECK: store { i64, i64 } { i64 ptrtoint (ptr ptrauth (ptr @_ZN8Derived18virtual7Ev_vfpthunk_, [i64 0, i64 25206, i64 0]) to i64), i64 0 }, ptr %[[METHOD7]], align 8 +// CHECK-NEXT: store { i64, i64 } { i64 ptrtoint (ptr ptrauth (ptr @_ZN5Base08virtual1Ev_vfpthunk_, [i64 0, i64 25206, i64 0]) to i64), i64 0 }, ptr %[[METHOD7]], align 8 // CHECK: ret void // CHECK: define linkonce_odr hidden void @_ZN5Base08virtual1Ev_vfpthunk_(ptr noundef %[[THIS:.*]]) @@ -374,7 +374,7 @@ void testConversion3(MethodTy1 method1) { // CHECK: define{{.*}} void @_Z15testConversion4v( // CHECK: %[[METHOD0:.*]] = alloca { i64, i64 }, align 8 -// CHECK: store { i64, i64 } { i64 ptrtoint (ptr ptrauth (ptr @_ZN5Base08virtual1Ev_vfpthunk_, i32 0, i64 [[TYPEDISC0]]) to i64), i64 0 }, ptr %[[METHOD0]], align 8 +// CHECK: store { i64, i64 } { i64 ptrtoint (ptr ptrauth (ptr @_ZN5Base08virtual1Ev_vfpthunk_, [i64 0, i64 [[TYPEDISC0]], i64 0]) to i64), i64 0 }, ptr %[[METHOD0]], align 8 // CHECK: ret void void testConversion4() { @@ -423,8 +423,8 @@ MethodTy0 gmethod2 = reinterpret_cast(&Derived0::virtual1); // CHECK: call void @llvm.memcpy.p0.p0.i64(ptr align 8 %p1, ptr align 8 @__const._Z13testArrayInitv.p1, i64 16, i1 false) // CHECK: call void @llvm.memcpy.p0.p0.i64(ptr align 8 %c0, ptr align 8 @__const._Z13testArrayInitv.c0, i64 16, i1 false) // CHECK: call void @llvm.memcpy.p0.p0.i64(ptr align 8 %c1, ptr align 8 @__const._Z13testArrayInitv.c1, i64 16, i1 false) -// CHECK: store { i64, i64 } { i64 ptrtoint (ptr ptrauth (ptr @_ZN5Base011nonvirtual0Ev, i32 0, i64 [[TYPEDISC1]]) to i64), i64 0 }, ptr %{{.*}} align 8 -// CHECK: store { i64, i64 } { i64 ptrtoint (ptr ptrauth (ptr @_ZN5Base08virtual1Ev_vfpthunk_, i32 0, i64 [[TYPEDISC1]]) to i64), i64 0 }, ptr %{{.*}}, align 8 +// CHECK: store { i64, i64 } { i64 ptrtoint (ptr ptrauth (ptr @_ZN5Base011nonvirtual0Ev, [i64 0, i64 [[TYPEDISC1]], i64 0]) to i64), i64 0 }, ptr %{{.*}} align 8 +// CHECK: store { i64, i64 } { i64 ptrtoint (ptr ptrauth (ptr @_ZN5Base08virtual1Ev_vfpthunk_, [i64 0, i64 [[TYPEDISC1]], i64 0]) to i64), i64 0 }, ptr %{{.*}}, align 8 void initList(std::initializer_list); @@ -462,11 +462,11 @@ namespace testNoexceptConversion { // CHECK: define {{.*}}void @_ZN22testNoexceptConversion5test0Ev() // CHECK: %[[P0:.*]] = alloca { i64, i64 }, align 8 -// CHECK: store { i64, i64 } { i64 ptrtoint (ptr ptrauth (ptr @_ZN22testNoexceptConversion1S19nonvirtual_noexceptEv, i32 0, i64 [[TYPEDISC3]]) to i64), i64 0 }, ptr %[[P0]], align 8, +// CHECK: store { i64, i64 } { i64 ptrtoint (ptr ptrauth (ptr @_ZN22testNoexceptConversion1S19nonvirtual_noexceptEv, [i64 0, i64 [[TYPEDISC3]], i64 0]) to i64), i64 0 }, ptr %[[P0]], align 8, // CHECK: define {{.*}}void @_ZN22testNoexceptConversion5test1Ev() // CHECK: %[[P0:.*]] = alloca { i64, i64 }, align 8 -// CHECK: store { i64, i64 } { i64 ptrtoint (ptr ptrauth (ptr @_ZN22testNoexceptConversion1S16virtual_noexceptEv_vfpthunk_, i32 0, i64 [[TYPEDISC3]]) to i64), i64 0 }, ptr %[[P0]], align 8, +// CHECK: store { i64, i64 } { i64 ptrtoint (ptr ptrauth (ptr @_ZN22testNoexceptConversion1S16virtual_noexceptEv_vfpthunk_, [i64 0, i64 [[TYPEDISC3]], i64 0]) to i64), i64 0 }, ptr %[[P0]], align 8, // CHECK: define {{.*}}void @_ZN22testNoexceptConversion5test2Ev() // CHECK: %[[P0:.*]] = alloca { i64, i64 }, align 8 diff --git a/clang/test/CodeGenCXX/ptrauth-rtti-layout.cpp b/clang/test/CodeGenCXX/ptrauth-rtti-layout.cpp index b50e0908f9db8..50417f8958fb0 100644 --- a/clang/test/CodeGenCXX/ptrauth-rtti-layout.cpp +++ b/clang/test/CodeGenCXX/ptrauth-rtti-layout.cpp @@ -5,11 +5,11 @@ struct A { int a; }; -// DARWIN: @_ZTI1A = linkonce_odr hidden constant { ptr, ptr } { ptr ptrauth (ptr getelementptr inbounds (ptr, ptr @_ZTVN10__cxxabiv117__class_type_infoE, i64 2), i32 2), ptr inttoptr (i64 add (i64 ptrtoint (ptr @_ZTS1A to i64), i64 -9223372036854775808) to ptr) } +// DARWIN: @_ZTI1A = linkonce_odr hidden constant { ptr, ptr } { ptr ptrauth (ptr getelementptr inbounds (ptr, ptr @_ZTVN10__cxxabiv117__class_type_infoE, i64 2), [i64 2, i64 0, i64 0]), ptr inttoptr (i64 add (i64 ptrtoint (ptr @_ZTS1A to i64), i64 -9223372036854775808) to ptr) } // DARWIN: @_ZTVN10__cxxabiv117__class_type_infoE = external global [0 x ptr] // DARWIN: @_ZTS1A = linkonce_odr hidden constant [3 x i8] c"1A\00" -// ELF: @_ZTI1A = linkonce_odr constant { ptr, ptr } { ptr ptrauth (ptr getelementptr inbounds (ptr, ptr @_ZTVN10__cxxabiv117__class_type_infoE, i64 2), i32 2), ptr @_ZTS1A } +// ELF: @_ZTI1A = linkonce_odr constant { ptr, ptr } { ptr ptrauth (ptr getelementptr inbounds (ptr, ptr @_ZTVN10__cxxabiv117__class_type_infoE, i64 2), [i64 2, i64 0, i64 0]), ptr @_ZTS1A } // ELF: @_ZTVN10__cxxabiv117__class_type_infoE = external global [0 x ptr] // ELF: @_ZTS1A = linkonce_odr constant [3 x i8] c"1A\00" diff --git a/clang/test/CodeGenCXX/ptrauth-static-destructors.cpp b/clang/test/CodeGenCXX/ptrauth-static-destructors.cpp index 634450bf62ea9..26350a4c7f2ff 100644 --- a/clang/test/CodeGenCXX/ptrauth-static-destructors.cpp +++ b/clang/test/CodeGenCXX/ptrauth-static-destructors.cpp @@ -33,13 +33,13 @@ class Foo { Foo global; // CXAATEXIT: define internal void @__cxx_global_var_init() -// CXAATEXIT: call i32 @__cxa_atexit(ptr ptrauth (ptr @_ZN3FooD1Ev, i32 0), ptr @global, ptr @__dso_handle) +// CXAATEXIT: call i32 @__cxa_atexit(ptr ptrauth (ptr @_ZN3FooD1Ev, [i64 0, i64 0, i64 0]), ptr @global, ptr @__dso_handle) // CXAATEXIT_DISC: define internal void @__cxx_global_var_init() -// CXAATEXIT_DISC: call i32 @__cxa_atexit(ptr ptrauth (ptr @_ZN3FooD1Ev, i32 0, i64 10942), ptr @global, ptr @__dso_handle) +// CXAATEXIT_DISC: call i32 @__cxa_atexit(ptr ptrauth (ptr @_ZN3FooD1Ev, [i64 0, i64 10942, i64 0]), ptr @global, ptr @__dso_handle) // ATEXIT: define internal void @__cxx_global_var_init() -// ATEXIT: %{{.*}} = call i32 @atexit(ptr ptrauth (ptr @__dtor_global, i32 0)) +// ATEXIT: %{{.*}} = call i32 @atexit(ptr ptrauth (ptr @__dtor_global, [i64 0, i64 0, i64 0])) // ATEXIT_DARWIN: define internal void @__dtor_global() {{.*}} section "__TEXT,__StaticInit,regular,pure_instructions" { // ATEXIT_ELF: define internal void @__dtor_global() {{.*}} section ".text.startup" { @@ -47,7 +47,7 @@ Foo global; // ATEXIT_ELF: call void @_ZN3FooD1Ev(ptr @global) // ATEXIT_DISC: define internal void @__cxx_global_var_init() -// ATEXIT_DISC: %{{.*}} = call i32 @atexit(ptr ptrauth (ptr @__dtor_global, i32 0, i64 10942)) +// ATEXIT_DISC: %{{.*}} = call i32 @atexit(ptr ptrauth (ptr @__dtor_global, [i64 0, i64 10942, i64 0])) // ATEXIT_DISC_DARWIN: define internal void @__dtor_global() {{.*}} section "__TEXT,__StaticInit,regular,pure_instructions" { diff --git a/clang/test/CodeGenCXX/ptrauth-throw.cpp b/clang/test/CodeGenCXX/ptrauth-throw.cpp index 2933d22852b4a..f928f970b5051 100644 --- a/clang/test/CodeGenCXX/ptrauth-throw.cpp +++ b/clang/test/CodeGenCXX/ptrauth-throw.cpp @@ -11,10 +11,10 @@ class Foo { }; // CHECK-LABEL: define{{.*}} void @_Z1fv() -// CHECK: call void @__cxa_throw(ptr %{{.*}}, ptr @_ZTI3Foo, ptr ptrauth (ptr @_ZN3FooD1Ev, i32 0)) +// CHECK: call void @__cxa_throw(ptr %{{.*}}, ptr @_ZTI3Foo, ptr ptrauth (ptr @_ZN3FooD1Ev, [i64 0, i64 0, i64 0])) // CHECKDISC-LABEL: define{{.*}} void @_Z1fv() -// CHECKDISC: call void @__cxa_throw(ptr %{{.*}}, ptr @_ZTI3Foo, ptr ptrauth (ptr @_ZN3FooD1Ev, i32 0, i64 10942)) +// CHECKDISC: call void @__cxa_throw(ptr %{{.*}}, ptr @_ZTI3Foo, ptr ptrauth (ptr @_ZN3FooD1Ev, [i64 0, i64 10942, i64 0])) void f() { throw Foo(); diff --git a/clang/test/CodeGenCXX/ptrauth-type-info-vtable.cpp b/clang/test/CodeGenCXX/ptrauth-type-info-vtable.cpp index 89dff35d84c89..e5db0841cb82e 100644 --- a/clang/test/CodeGenCXX/ptrauth-type-info-vtable.cpp +++ b/clang/test/CodeGenCXX/ptrauth-type-info-vtable.cpp @@ -59,11 +59,11 @@ static_assert(__has_feature(ptrauth_type_info_vtable_pointer_discrimination) == // CHECK: @disc_std_type_info = global i32 [[STDTYPEINFO_DISC:45546]] extern "C" int disc_std_type_info = __builtin_ptrauth_string_discriminator("_ZTVSt9type_info"); -// CHECK: @_ZTV10TestStruct = unnamed_addr constant { [4 x ptr] } { [4 x ptr] [ptr null, ptr @_ZTI10TestStruct, ptr ptrauth (ptr @_ZN10TestStructD1Ev, i32 0, i64 52216, ptr getelementptr inbounds ({ [4 x ptr] }, ptr @_ZTV10TestStruct, i32 0, i32 0, i32 2)), ptr ptrauth (ptr @_ZN10TestStructD0Ev, i32 0, i64 39671, ptr getelementptr inbounds ({ [4 x ptr] }, ptr @_ZTV10TestStruct, i32 0, i32 0, i32 3))] }, align 8 +// CHECK: @_ZTV10TestStruct = unnamed_addr constant { [4 x ptr] } { [4 x ptr] [ptr null, ptr @_ZTI10TestStruct, ptr ptrauth (ptr @_ZN10TestStructD1Ev, [i64 0, i64 52216, i64 ptrtoint (ptr getelementptr inbounds ({ [4 x ptr] }, ptr @_ZTV10TestStruct, i32 0, i32 0, i32 2) to i64)]), ptr ptrauth (ptr @_ZN10TestStructD0Ev, [i64 0, i64 39671, i64 ptrtoint (ptr getelementptr inbounds ({ [4 x ptr] }, ptr @_ZTV10TestStruct, i32 0, i32 0, i32 3) to i64)])] }, align 8 -// NODISC: @_ZTI10TestStruct = constant { ptr, ptr } { ptr ptrauth (ptr getelementptr inbounds (ptr, ptr @_ZTVN10__cxxabiv117__class_type_infoE, i64 2), i32 2), ptr @_ZTS10TestStruct }, align 8 +// NODISC: @_ZTI10TestStruct = constant { ptr, ptr } { ptr ptrauth (ptr getelementptr inbounds (ptr, ptr @_ZTVN10__cxxabiv117__class_type_infoE, i64 2), [i64 2, i64 0, i64 0]), ptr @_ZTS10TestStruct }, align 8 -// DISC: @_ZTI10TestStruct = constant { ptr, ptr } { ptr ptrauth (ptr getelementptr inbounds (ptr, ptr @_ZTVN10__cxxabiv117__class_type_infoE, i64 2), i32 2, i64 [[STDTYPEINFO_DISC]], ptr @_ZTI10TestStruct), ptr @_ZTS10TestStruct }, align 8 +// DISC: @_ZTI10TestStruct = constant { ptr, ptr } { ptr ptrauth (ptr getelementptr inbounds (ptr, ptr @_ZTVN10__cxxabiv117__class_type_infoE, i64 2), [i64 2, i64 [[STDTYPEINFO_DISC]], i64 ptrtoint (ptr @_ZTI10TestStruct to i64)]), ptr @_ZTS10TestStruct }, align 8 // CHECK: @_ZTVN10__cxxabiv117__class_type_infoE = external global [0 x ptr] // CHECK: @_ZTS10TestStruct = constant [13 x i8] c"10TestStruct\00", align 1 diff --git a/clang/test/CodeGenCXX/ptrauth-virtual-function.cpp b/clang/test/CodeGenCXX/ptrauth-virtual-function.cpp index 58e86406e473a..c0b9a600869dd 100644 --- a/clang/test/CodeGenCXX/ptrauth-virtual-function.cpp +++ b/clang/test/CodeGenCXX/ptrauth-virtual-function.cpp @@ -5,90 +5,90 @@ // CHECK: %[[CLASS_B1:.*]] = type { ptr } -// CHECK: @_ZTV2B1 = unnamed_addr constant { [3 x ptr] } { [3 x ptr] [ptr null, ptr @_ZTI2B1, ptr ptrauth (ptr @_ZN2B12m0Ev, i32 0, i64 58196, ptr getelementptr inbounds ({ [3 x ptr] }, ptr @_ZTV2B1, i32 0, i32 0, i32 2))] }, align 8 +// CHECK: @_ZTV2B1 = unnamed_addr constant { [3 x ptr] } { [3 x ptr] [ptr null, ptr @_ZTI2B1, ptr ptrauth (ptr @_ZN2B12m0Ev, [i64 0, i64 58196, i64 ptrtoint (ptr getelementptr inbounds ({ [3 x ptr] }, ptr @_ZTV2B1, i32 0, i32 0, i32 2) to i64)])] }, align 8 -// CHECK: @g_B1 = global %class.B1 { ptr ptrauth (ptr getelementptr inbounds inrange(-16, 8) ({ [3 x ptr] }, ptr @_ZTV2B1, i32 0, i32 0, i32 2), i32 2) }, align 8 +// CHECK: @g_B1 = global %class.B1 { ptr ptrauth (ptr getelementptr inbounds inrange(-16, 8) ({ [3 x ptr] }, ptr @_ZTV2B1, i32 0, i32 0, i32 2), [i64 2, i64 0, i64 0]) }, align 8 // CHECK: @_ZTV2B0 = unnamed_addr constant { [7 x ptr] } { [7 x ptr] [ptr null, ptr @_ZTI2B0, -// CHECK-SAME: ptr ptrauth (ptr @_ZN2B02m0Ev, i32 0, i64 53119, ptr getelementptr inbounds ({ [7 x ptr] }, ptr @_ZTV2B0, i32 0, i32 0, i32 2)), -// CHECK-SAME: ptr ptrauth (ptr @_ZN2B02m1Ev, i32 0, i64 15165, ptr getelementptr inbounds ({ [7 x ptr] }, ptr @_ZTV2B0, i32 0, i32 0, i32 3)), -// CHECK-SAME: ptr ptrauth (ptr @_ZN2B02m2Ev, i32 0, i64 43073, ptr getelementptr inbounds ({ [7 x ptr] }, ptr @_ZTV2B0, i32 0, i32 0, i32 4)), -// CHECK-SAME: ptr ptrauth (ptr @_ZN2B0D1Ev, i32 0, i64 25525, ptr getelementptr inbounds ({ [7 x ptr] }, ptr @_ZTV2B0, i32 0, i32 0, i32 5)), -// CHECK-SAME: ptr ptrauth (ptr @_ZN2B0D0Ev, i32 0, i64 21295, ptr getelementptr inbounds ({ [7 x ptr] }, ptr @_ZTV2B0, i32 0, i32 0, i32 6))] }, align 8 +// CHECK-SAME: ptr ptrauth (ptr @_ZN2B02m0Ev, [i64 0, i64 53119, i64 ptrtoint (ptr getelementptr inbounds ({ [7 x ptr] }, ptr @_ZTV2B0, i32 0, i32 0, i32 2) to i64)]), +// CHECK-SAME: ptr ptrauth (ptr @_ZN2B02m1Ev, [i64 0, i64 15165, i64 ptrtoint (ptr getelementptr inbounds ({ [7 x ptr] }, ptr @_ZTV2B0, i32 0, i32 0, i32 3) to i64)]), +// CHECK-SAME: ptr ptrauth (ptr @_ZN2B02m2Ev, [i64 0, i64 43073, i64 ptrtoint (ptr getelementptr inbounds ({ [7 x ptr] }, ptr @_ZTV2B0, i32 0, i32 0, i32 4) to i64)]), +// CHECK-SAME: ptr ptrauth (ptr @_ZN2B0D1Ev, [i64 0, i64 25525, i64 ptrtoint (ptr getelementptr inbounds ({ [7 x ptr] }, ptr @_ZTV2B0, i32 0, i32 0, i32 5) to i64)]), +// CHECK-SAME: ptr ptrauth (ptr @_ZN2B0D0Ev, [i64 0, i64 21295, i64 ptrtoint (ptr getelementptr inbounds ({ [7 x ptr] }, ptr @_ZTV2B0, i32 0, i32 0, i32 6) to i64)])] }, align 8 // CHECK: @_ZTV2D0 = unnamed_addr constant { [9 x ptr] } { [9 x ptr] [ptr null, ptr @_ZTI2D0, -// CHECK-SAME: ptr ptrauth (ptr @_ZN2D02m0Ev, i32 0, i64 53119, ptr getelementptr inbounds ({ [9 x ptr] }, ptr @_ZTV2D0, i32 0, i32 0, i32 2)), -// CHECK-SAME: ptr ptrauth (ptr @_ZTch0_h4_N2D02m1Ev, i32 0, i64 15165, ptr getelementptr inbounds ({ [9 x ptr] }, ptr @_ZTV2D0, i32 0, i32 0, i32 3)), -// CHECK-SAME: ptr ptrauth (ptr @_ZN2B02m2Ev, i32 0, i64 43073, ptr getelementptr inbounds ({ [9 x ptr] }, ptr @_ZTV2D0, i32 0, i32 0, i32 4)), -// CHECK-SAME: ptr ptrauth (ptr @_ZN2D0D1Ev, i32 0, i64 25525, ptr getelementptr inbounds ({ [9 x ptr] }, ptr @_ZTV2D0, i32 0, i32 0, i32 5)), -// CHECK-SAME: ptr ptrauth (ptr @_ZN2D0D0Ev, i32 0, i64 21295, ptr getelementptr inbounds ({ [9 x ptr] }, ptr @_ZTV2D0, i32 0, i32 0, i32 6)), -// CHECK-SAME: ptr ptrauth (ptr @_ZN2D02m1Ev, i32 0, i64 35045, ptr getelementptr inbounds ({ [9 x ptr] }, ptr @_ZTV2D0, i32 0, i32 0, i32 7)), -// CHECK-SAME: ptr ptrauth (ptr @_ZN2D02m3Ev, i32 0, i64 10565, ptr getelementptr inbounds ({ [9 x ptr] }, ptr @_ZTV2D0, i32 0, i32 0, i32 8))] }, align 8 +// CHECK-SAME: ptr ptrauth (ptr @_ZN2D02m0Ev, [i64 0, i64 53119, i64 ptrtoint (ptr getelementptr inbounds ({ [9 x ptr] }, ptr @_ZTV2D0, i32 0, i32 0, i32 2) to i64)]), +// CHECK-SAME: ptr ptrauth (ptr @_ZTch0_h4_N2D02m1Ev, [i64 0, i64 15165, i64 ptrtoint (ptr getelementptr inbounds ({ [9 x ptr] }, ptr @_ZTV2D0, i32 0, i32 0, i32 3) to i64)]), +// CHECK-SAME: ptr ptrauth (ptr @_ZN2B02m2Ev, [i64 0, i64 43073, i64 ptrtoint (ptr getelementptr inbounds ({ [9 x ptr] }, ptr @_ZTV2D0, i32 0, i32 0, i32 4) to i64)]), +// CHECK-SAME: ptr ptrauth (ptr @_ZN2D0D1Ev, [i64 0, i64 25525, i64 ptrtoint (ptr getelementptr inbounds ({ [9 x ptr] }, ptr @_ZTV2D0, i32 0, i32 0, i32 5) to i64)]), +// CHECK-SAME: ptr ptrauth (ptr @_ZN2D0D0Ev, [i64 0, i64 21295, i64 ptrtoint (ptr getelementptr inbounds ({ [9 x ptr] }, ptr @_ZTV2D0, i32 0, i32 0, i32 6) to i64)]), +// CHECK-SAME: ptr ptrauth (ptr @_ZN2D02m1Ev, [i64 0, i64 35045, i64 ptrtoint (ptr getelementptr inbounds ({ [9 x ptr] }, ptr @_ZTV2D0, i32 0, i32 0, i32 7) to i64)]), +// CHECK-SAME: ptr ptrauth (ptr @_ZN2D02m3Ev, [i64 0, i64 10565, i64 ptrtoint (ptr getelementptr inbounds ({ [9 x ptr] }, ptr @_ZTV2D0, i32 0, i32 0, i32 8) to i64)])] }, align 8 // CHECK: @_ZTV2D1 = unnamed_addr constant { [8 x ptr] } { [8 x ptr] [ptr null, ptr @_ZTI2D1, -// CHECK-SAME: ptr ptrauth (ptr @_ZN2D12m0Ev, i32 0, i64 53119, ptr getelementptr inbounds ({ [8 x ptr] }, ptr @_ZTV2D1, i32 0, i32 0, i32 2)), -// CHECK-SAME: ptr ptrauth (ptr @_ZTch0_h4_N2D12m1Ev, i32 0, i64 15165, ptr getelementptr inbounds ({ [8 x ptr] }, ptr @_ZTV2D1, i32 0, i32 0, i32 3)), -// CHECK-SAME: ptr ptrauth (ptr @_ZN2B02m2Ev, i32 0, i64 43073, ptr getelementptr inbounds ({ [8 x ptr] }, ptr @_ZTV2D1, i32 0, i32 0, i32 4)), -// CHECK-SAME: ptr ptrauth (ptr @_ZN2D1D1Ev, i32 0, i64 25525, ptr getelementptr inbounds ({ [8 x ptr] }, ptr @_ZTV2D1, i32 0, i32 0, i32 5)), -// CHECK-SAME: ptr ptrauth (ptr @_ZN2D1D0Ev, i32 0, i64 21295, ptr getelementptr inbounds ({ [8 x ptr] }, ptr @_ZTV2D1, i32 0, i32 0, i32 6)), -// CHECK-SAME: ptr ptrauth (ptr @_ZN2D12m1Ev, i32 0, i64 52864, ptr getelementptr inbounds ({ [8 x ptr] }, ptr @_ZTV2D1, i32 0, i32 0, i32 7))] }, align 8 +// CHECK-SAME: ptr ptrauth (ptr @_ZN2D12m0Ev, [i64 0, i64 53119, i64 ptrtoint (ptr getelementptr inbounds ({ [8 x ptr] }, ptr @_ZTV2D1, i32 0, i32 0, i32 2) to i64)]), +// CHECK-SAME: ptr ptrauth (ptr @_ZTch0_h4_N2D12m1Ev, [i64 0, i64 15165, i64 ptrtoint (ptr getelementptr inbounds ({ [8 x ptr] }, ptr @_ZTV2D1, i32 0, i32 0, i32 3) to i64)]), +// CHECK-SAME: ptr ptrauth (ptr @_ZN2B02m2Ev, [i64 0, i64 43073, i64 ptrtoint (ptr getelementptr inbounds ({ [8 x ptr] }, ptr @_ZTV2D1, i32 0, i32 0, i32 4) to i64)]), +// CHECK-SAME: ptr ptrauth (ptr @_ZN2D1D1Ev, [i64 0, i64 25525, i64 ptrtoint (ptr getelementptr inbounds ({ [8 x ptr] }, ptr @_ZTV2D1, i32 0, i32 0, i32 5) to i64)]), +// CHECK-SAME: ptr ptrauth (ptr @_ZN2D1D0Ev, [i64 0, i64 21295, i64 ptrtoint (ptr getelementptr inbounds ({ [8 x ptr] }, ptr @_ZTV2D1, i32 0, i32 0, i32 6) to i64)]), +// CHECK-SAME: ptr ptrauth (ptr @_ZN2D12m1Ev, [i64 0, i64 52864, i64 ptrtoint (ptr getelementptr inbounds ({ [8 x ptr] }, ptr @_ZTV2D1, i32 0, i32 0, i32 7) to i64)])] }, align 8 // CHECK: @_ZTV2D2 = unnamed_addr constant { [9 x ptr], [8 x ptr] } { [9 x ptr] [ptr null, ptr @_ZTI2D2, -// CHECK-SAME: ptr ptrauth (ptr @_ZN2D22m0Ev, i32 0, i64 53119, ptr getelementptr inbounds ({ [9 x ptr], [8 x ptr] }, ptr @_ZTV2D2, i32 0, i32 0, i32 2)), -// CHECK-SAME: ptr ptrauth (ptr @_ZTch0_h4_N2D22m1Ev, i32 0, i64 15165, ptr getelementptr inbounds ({ [9 x ptr], [8 x ptr] }, ptr @_ZTV2D2, i32 0, i32 0, i32 3)), -// CHECK-SAME: ptr ptrauth (ptr @_ZN2B02m2Ev, i32 0, i64 43073, ptr getelementptr inbounds ({ [9 x ptr], [8 x ptr] }, ptr @_ZTV2D2, i32 0, i32 0, i32 4)), -// CHECK-SAME: ptr ptrauth (ptr @_ZN2D2D1Ev, i32 0, i64 25525, ptr getelementptr inbounds ({ [9 x ptr], [8 x ptr] }, ptr @_ZTV2D2, i32 0, i32 0, i32 5)), -// CHECK-SAME: ptr ptrauth (ptr @_ZN2D2D0Ev, i32 0, i64 21295, ptr getelementptr inbounds ({ [9 x ptr], [8 x ptr] }, ptr @_ZTV2D2, i32 0, i32 0, i32 6)), -// CHECK-SAME: ptr ptrauth (ptr @_ZN2D22m1Ev, i32 0, i64 35045, ptr getelementptr inbounds ({ [9 x ptr], [8 x ptr] }, ptr @_ZTV2D2, i32 0, i32 0, i32 7)), -// CHECK-SAME: ptr ptrauth (ptr @_ZN2D22m3Ev, i32 0, i64 10565, ptr getelementptr inbounds ({ [9 x ptr], [8 x ptr] }, ptr @_ZTV2D2, i32 0, i32 0, i32 8))], +// CHECK-SAME: ptr ptrauth (ptr @_ZN2D22m0Ev, [i64 0, i64 53119, i64 ptrtoint (ptr getelementptr inbounds ({ [9 x ptr], [8 x ptr] }, ptr @_ZTV2D2, i32 0, i32 0, i32 2) to i64)]), +// CHECK-SAME: ptr ptrauth (ptr @_ZTch0_h4_N2D22m1Ev, [i64 0, i64 15165, i64 ptrtoint (ptr getelementptr inbounds ({ [9 x ptr], [8 x ptr] }, ptr @_ZTV2D2, i32 0, i32 0, i32 3) to i64)]), +// CHECK-SAME: ptr ptrauth (ptr @_ZN2B02m2Ev, [i64 0, i64 43073, i64 ptrtoint (ptr getelementptr inbounds ({ [9 x ptr], [8 x ptr] }, ptr @_ZTV2D2, i32 0, i32 0, i32 4) to i64)]), +// CHECK-SAME: ptr ptrauth (ptr @_ZN2D2D1Ev, [i64 0, i64 25525, i64 ptrtoint (ptr getelementptr inbounds ({ [9 x ptr], [8 x ptr] }, ptr @_ZTV2D2, i32 0, i32 0, i32 5) to i64)]), +// CHECK-SAME: ptr ptrauth (ptr @_ZN2D2D0Ev, [i64 0, i64 21295, i64 ptrtoint (ptr getelementptr inbounds ({ [9 x ptr], [8 x ptr] }, ptr @_ZTV2D2, i32 0, i32 0, i32 6) to i64)]), +// CHECK-SAME: ptr ptrauth (ptr @_ZN2D22m1Ev, [i64 0, i64 35045, i64 ptrtoint (ptr getelementptr inbounds ({ [9 x ptr], [8 x ptr] }, ptr @_ZTV2D2, i32 0, i32 0, i32 7) to i64)]), +// CHECK-SAME: ptr ptrauth (ptr @_ZN2D22m3Ev, [i64 0, i64 10565, i64 ptrtoint (ptr getelementptr inbounds ({ [9 x ptr], [8 x ptr] }, ptr @_ZTV2D2, i32 0, i32 0, i32 8) to i64)])], // CHECK-SAME: [8 x ptr] [ptr inttoptr (i64 -16 to ptr), ptr @_ZTI2D2, -// CHECK-SAME: ptr ptrauth (ptr @_ZThn16_N2D22m0Ev, i32 0, i64 53119, ptr getelementptr inbounds ({ [9 x ptr], [8 x ptr] }, ptr @_ZTV2D2, i32 0, i32 1, i32 2)), -// CHECK-SAME: ptr ptrauth (ptr @_ZTchn16_h4_N2D22m1Ev, i32 0, i64 15165, ptr getelementptr inbounds ({ [9 x ptr], [8 x ptr] }, ptr @_ZTV2D2, i32 0, i32 1, i32 3)), -// CHECK-SAME: ptr ptrauth (ptr @_ZN2B02m2Ev, i32 0, i64 43073, ptr getelementptr inbounds ({ [9 x ptr], [8 x ptr] }, ptr @_ZTV2D2, i32 0, i32 1, i32 4)), -// CHECK-SAME: ptr ptrauth (ptr @_ZThn16_N2D2D1Ev, i32 0, i64 25525, ptr getelementptr inbounds ({ [9 x ptr], [8 x ptr] }, ptr @_ZTV2D2, i32 0, i32 1, i32 5)), -// CHECK-SAME: ptr ptrauth (ptr @_ZThn16_N2D2D0Ev, i32 0, i64 21295, ptr getelementptr inbounds ({ [9 x ptr], [8 x ptr] }, ptr @_ZTV2D2, i32 0, i32 1, i32 6)), -// CHECK-SAME: ptr ptrauth (ptr @_ZThn16_N2D22m1Ev, i32 0, i64 52864, ptr getelementptr inbounds ({ [9 x ptr], [8 x ptr] }, ptr @_ZTV2D2, i32 0, i32 1, i32 7))] }, align 8 +// CHECK-SAME: ptr ptrauth (ptr @_ZThn16_N2D22m0Ev, [i64 0, i64 53119, i64 ptrtoint (ptr getelementptr inbounds ({ [9 x ptr], [8 x ptr] }, ptr @_ZTV2D2, i32 0, i32 1, i32 2) to i64)]), +// CHECK-SAME: ptr ptrauth (ptr @_ZTchn16_h4_N2D22m1Ev, [i64 0, i64 15165, i64 ptrtoint (ptr getelementptr inbounds ({ [9 x ptr], [8 x ptr] }, ptr @_ZTV2D2, i32 0, i32 1, i32 3) to i64)]), +// CHECK-SAME: ptr ptrauth (ptr @_ZN2B02m2Ev, [i64 0, i64 43073, i64 ptrtoint (ptr getelementptr inbounds ({ [9 x ptr], [8 x ptr] }, ptr @_ZTV2D2, i32 0, i32 1, i32 4) to i64)]), +// CHECK-SAME: ptr ptrauth (ptr @_ZThn16_N2D2D1Ev, [i64 0, i64 25525, i64 ptrtoint (ptr getelementptr inbounds ({ [9 x ptr], [8 x ptr] }, ptr @_ZTV2D2, i32 0, i32 1, i32 5) to i64)]), +// CHECK-SAME: ptr ptrauth (ptr @_ZThn16_N2D2D0Ev, [i64 0, i64 21295, i64 ptrtoint (ptr getelementptr inbounds ({ [9 x ptr], [8 x ptr] }, ptr @_ZTV2D2, i32 0, i32 1, i32 6) to i64)]), +// CHECK-SAME: ptr ptrauth (ptr @_ZThn16_N2D22m1Ev, [i64 0, i64 52864, i64 ptrtoint (ptr getelementptr inbounds ({ [9 x ptr], [8 x ptr] }, ptr @_ZTV2D2, i32 0, i32 1, i32 7) to i64)])] }, align 8 // CHECK: @_ZTV2D3 = unnamed_addr constant { [7 x ptr], [7 x ptr], [11 x ptr] } { [7 x ptr] [ptr inttoptr (i64 32 to ptr), ptr null, ptr @_ZTI2D3, -// CHECK-SAME: ptr ptrauth (ptr @_ZN2D32m0Ev, i32 0, i64 44578, ptr getelementptr inbounds ({ [7 x ptr], [7 x ptr], [11 x ptr] }, ptr @_ZTV2D3, i32 0, i32 0, i32 3)), -// CHECK-SAME: ptr ptrauth (ptr @_ZN2D32m1Ev, i32 0, i64 30766, ptr getelementptr inbounds ({ [7 x ptr], [7 x ptr], [11 x ptr] }, ptr @_ZTV2D3, i32 0, i32 0, i32 4)), -// CHECK-SAME: ptr ptrauth (ptr @_ZN2D3D1Ev, i32 0, i64 57279, ptr getelementptr inbounds ({ [7 x ptr], [7 x ptr], [11 x ptr] }, ptr @_ZTV2D3, i32 0, i32 0, i32 5)), -// CHECK-SAME: ptr ptrauth (ptr @_ZN2D3D0Ev, i32 0, i64 62452, ptr getelementptr inbounds ({ [7 x ptr], [7 x ptr], [11 x ptr] }, ptr @_ZTV2D3, i32 0, i32 0, i32 6))], +// CHECK-SAME: ptr ptrauth (ptr @_ZN2D32m0Ev, [i64 0, i64 44578, i64 ptrtoint (ptr getelementptr inbounds ({ [7 x ptr], [7 x ptr], [11 x ptr] }, ptr @_ZTV2D3, i32 0, i32 0, i32 3) to i64)]), +// CHECK-SAME: ptr ptrauth (ptr @_ZN2D32m1Ev, [i64 0, i64 30766, i64 ptrtoint (ptr getelementptr inbounds ({ [7 x ptr], [7 x ptr], [11 x ptr] }, ptr @_ZTV2D3, i32 0, i32 0, i32 4) to i64)]), +// CHECK-SAME: ptr ptrauth (ptr @_ZN2D3D1Ev, [i64 0, i64 57279, i64 ptrtoint (ptr getelementptr inbounds ({ [7 x ptr], [7 x ptr], [11 x ptr] }, ptr @_ZTV2D3, i32 0, i32 0, i32 5) to i64)]), +// CHECK-SAME: ptr ptrauth (ptr @_ZN2D3D0Ev, [i64 0, i64 62452, i64 ptrtoint (ptr getelementptr inbounds ({ [7 x ptr], [7 x ptr], [11 x ptr] }, ptr @_ZTV2D3, i32 0, i32 0, i32 6) to i64)])], // CHECK-SAME: [7 x ptr] [ptr inttoptr (i64 16 to ptr), ptr inttoptr (i64 -16 to ptr), ptr @_ZTI2D3, -// CHECK-SAME: ptr ptrauth (ptr @_ZThn16_N2D32m0Ev, i32 0, i64 49430, ptr getelementptr inbounds ({ [7 x ptr], [7 x ptr], [11 x ptr] }, ptr @_ZTV2D3, i32 0, i32 1, i32 3)), -// CHECK-SAME: ptr ptrauth (ptr @_ZThn16_N2D32m1Ev, i32 0, i64 57119, ptr getelementptr inbounds ({ [7 x ptr], [7 x ptr], [11 x ptr] }, ptr @_ZTV2D3, i32 0, i32 1, i32 4)), -// CHECK-SAME: ptr ptrauth (ptr @_ZThn16_N2D3D1Ev, i32 0, i64 60799, ptr getelementptr inbounds ({ [7 x ptr], [7 x ptr], [11 x ptr] }, ptr @_ZTV2D3, i32 0, i32 1, i32 5)), -// CHECK-SAME: ptr ptrauth (ptr @_ZThn16_N2D3D0Ev, i32 0, i64 52565, ptr getelementptr inbounds ({ [7 x ptr], [7 x ptr], [11 x ptr] }, ptr @_ZTV2D3, i32 0, i32 1, i32 6))], +// CHECK-SAME: ptr ptrauth (ptr @_ZThn16_N2D32m0Ev, [i64 0, i64 49430, i64 ptrtoint (ptr getelementptr inbounds ({ [7 x ptr], [7 x ptr], [11 x ptr] }, ptr @_ZTV2D3, i32 0, i32 1, i32 3) to i64)]), +// CHECK-SAME: ptr ptrauth (ptr @_ZThn16_N2D32m1Ev, [i64 0, i64 57119, i64 ptrtoint (ptr getelementptr inbounds ({ [7 x ptr], [7 x ptr], [11 x ptr] }, ptr @_ZTV2D3, i32 0, i32 1, i32 4) to i64)]), +// CHECK-SAME: ptr ptrauth (ptr @_ZThn16_N2D3D1Ev, [i64 0, i64 60799, i64 ptrtoint (ptr getelementptr inbounds ({ [7 x ptr], [7 x ptr], [11 x ptr] }, ptr @_ZTV2D3, i32 0, i32 1, i32 5) to i64)]), +// CHECK-SAME: ptr ptrauth (ptr @_ZThn16_N2D3D0Ev, [i64 0, i64 52565, i64 ptrtoint (ptr getelementptr inbounds ({ [7 x ptr], [7 x ptr], [11 x ptr] }, ptr @_ZTV2D3, i32 0, i32 1, i32 6) to i64)])], // CHECK-SAME: [11 x ptr] [ptr inttoptr (i64 -32 to ptr), ptr null, ptr inttoptr (i64 -32 to ptr), ptr inttoptr (i64 -32 to ptr), ptr inttoptr (i64 -32 to ptr), ptr @_ZTI2D3, -// CHECK-SAME: ptr ptrauth (ptr @_ZTv0_n24_N2D32m0Ev, i32 0, i64 53119, ptr getelementptr inbounds ({ [7 x ptr], [7 x ptr], [11 x ptr] }, ptr @_ZTV2D3, i32 0, i32 2, i32 6)), -// CHECK-SAME: ptr ptrauth (ptr @_ZTcv0_n32_h4_N2D32m1Ev, i32 0, i64 15165, ptr getelementptr inbounds ({ [7 x ptr], [7 x ptr], [11 x ptr] }, ptr @_ZTV2D3, i32 0, i32 2, i32 7)), -// CHECK-SAME: ptr ptrauth (ptr @_ZN2B02m2Ev, i32 0, i64 43073, ptr getelementptr inbounds ({ [7 x ptr], [7 x ptr], [11 x ptr] }, ptr @_ZTV2D3, i32 0, i32 2, i32 8)), -// CHECK-SAME: ptr ptrauth (ptr @_ZTv0_n48_N2D3D1Ev, i32 0, i64 25525, ptr getelementptr inbounds ({ [7 x ptr], [7 x ptr], [11 x ptr] }, ptr @_ZTV2D3, i32 0, i32 2, i32 9)), -// CHECK-SAME: ptr ptrauth (ptr @_ZTv0_n48_N2D3D0Ev, i32 0, i64 21295, ptr getelementptr inbounds ({ [7 x ptr], [7 x ptr], [11 x ptr] }, ptr @_ZTV2D3, i32 0, i32 2, i32 10))] }, align 8 +// CHECK-SAME: ptr ptrauth (ptr @_ZTv0_n24_N2D32m0Ev, [i64 0, i64 53119, i64 ptrtoint (ptr getelementptr inbounds ({ [7 x ptr], [7 x ptr], [11 x ptr] }, ptr @_ZTV2D3, i32 0, i32 2, i32 6) to i64)]), +// CHECK-SAME: ptr ptrauth (ptr @_ZTcv0_n32_h4_N2D32m1Ev, [i64 0, i64 15165, i64 ptrtoint (ptr getelementptr inbounds ({ [7 x ptr], [7 x ptr], [11 x ptr] }, ptr @_ZTV2D3, i32 0, i32 2, i32 7) to i64)]), +// CHECK-SAME: ptr ptrauth (ptr @_ZN2B02m2Ev, [i64 0, i64 43073, i64 ptrtoint (ptr getelementptr inbounds ({ [7 x ptr], [7 x ptr], [11 x ptr] }, ptr @_ZTV2D3, i32 0, i32 2, i32 8) to i64)]), +// CHECK-SAME: ptr ptrauth (ptr @_ZTv0_n48_N2D3D1Ev, [i64 0, i64 25525, i64 ptrtoint (ptr getelementptr inbounds ({ [7 x ptr], [7 x ptr], [11 x ptr] }, ptr @_ZTV2D3, i32 0, i32 2, i32 9) to i64)]), +// CHECK-SAME: ptr ptrauth (ptr @_ZTv0_n48_N2D3D0Ev, [i64 0, i64 21295, i64 ptrtoint (ptr getelementptr inbounds ({ [7 x ptr], [7 x ptr], [11 x ptr] }, ptr @_ZTV2D3, i32 0, i32 2, i32 10) to i64)])] }, align 8 // CHECK: @_ZTC2D30_2V0 = unnamed_addr constant { [7 x ptr], [11 x ptr] } { [7 x ptr] [ptr inttoptr (i64 32 to ptr), ptr null, ptr @_ZTI2V0, -// CHECK-SAME: ptr ptrauth (ptr @_ZN2V02m0Ev, i32 0, i64 44578, ptr getelementptr inbounds ({ [7 x ptr], [11 x ptr] }, ptr @_ZTC2D30_2V0, i32 0, i32 0, i32 3)), -// CHECK-SAME: ptr ptrauth (ptr @_ZN2V02m1Ev, i32 0, i64 30766, ptr getelementptr inbounds ({ [7 x ptr], [11 x ptr] }, ptr @_ZTC2D30_2V0, i32 0, i32 0, i32 4)), -// CHECK-SAME: ptr ptrauth (ptr @_ZN2V0D1Ev, i32 0, i64 57279, ptr getelementptr inbounds ({ [7 x ptr], [11 x ptr] }, ptr @_ZTC2D30_2V0, i32 0, i32 0, i32 5)), -// CHECK-SAME: ptr ptrauth (ptr @_ZN2V0D0Ev, i32 0, i64 62452, ptr getelementptr inbounds ({ [7 x ptr], [11 x ptr] }, ptr @_ZTC2D30_2V0, i32 0, i32 0, i32 6))], +// CHECK-SAME: ptr ptrauth (ptr @_ZN2V02m0Ev, [i64 0, i64 44578, i64 ptrtoint (ptr getelementptr inbounds ({ [7 x ptr], [11 x ptr] }, ptr @_ZTC2D30_2V0, i32 0, i32 0, i32 3) to i64)]), +// CHECK-SAME: ptr ptrauth (ptr @_ZN2V02m1Ev, [i64 0, i64 30766, i64 ptrtoint (ptr getelementptr inbounds ({ [7 x ptr], [11 x ptr] }, ptr @_ZTC2D30_2V0, i32 0, i32 0, i32 4) to i64)]), +// CHECK-SAME: ptr ptrauth (ptr @_ZN2V0D1Ev, [i64 0, i64 57279, i64 ptrtoint (ptr getelementptr inbounds ({ [7 x ptr], [11 x ptr] }, ptr @_ZTC2D30_2V0, i32 0, i32 0, i32 5) to i64)]), +// CHECK-SAME: ptr ptrauth (ptr @_ZN2V0D0Ev, [i64 0, i64 62452, i64 ptrtoint (ptr getelementptr inbounds ({ [7 x ptr], [11 x ptr] }, ptr @_ZTC2D30_2V0, i32 0, i32 0, i32 6) to i64)])], // CHECK-SAME: [11 x ptr] [ptr inttoptr (i64 -32 to ptr), ptr null, ptr inttoptr (i64 -32 to ptr), ptr inttoptr (i64 -32 to ptr), ptr inttoptr (i64 -32 to ptr), ptr @_ZTI2V0, -// CHECK-SAME: ptr ptrauth (ptr @_ZTv0_n24_N2V02m0Ev, i32 0, i64 53119, ptr getelementptr inbounds ({ [7 x ptr], [11 x ptr] }, ptr @_ZTC2D30_2V0, i32 0, i32 1, i32 6)), -// CHECK-SAME: ptr ptrauth (ptr @_ZTcv0_n32_h4_N2V02m1Ev, i32 0, i64 15165, ptr getelementptr inbounds ({ [7 x ptr], [11 x ptr] }, ptr @_ZTC2D30_2V0, i32 0, i32 1, i32 7)), -// CHECK-SAME: ptr ptrauth (ptr @_ZN2B02m2Ev, i32 0, i64 43073, ptr getelementptr inbounds ({ [7 x ptr], [11 x ptr] }, ptr @_ZTC2D30_2V0, i32 0, i32 1, i32 8)), -// CHECK-SAME: ptr ptrauth (ptr @_ZTv0_n48_N2V0D1Ev, i32 0, i64 25525, ptr getelementptr inbounds ({ [7 x ptr], [11 x ptr] }, ptr @_ZTC2D30_2V0, i32 0, i32 1, i32 9)), -// CHECK-SAME: ptr ptrauth (ptr @_ZTv0_n48_N2V0D0Ev, i32 0, i64 21295, ptr getelementptr inbounds ({ [7 x ptr], [11 x ptr] }, ptr @_ZTC2D30_2V0, i32 0, i32 1, i32 10))] }, align 8 +// CHECK-SAME: ptr ptrauth (ptr @_ZTv0_n24_N2V02m0Ev, [i64 0, i64 53119, i64 ptrtoint (ptr getelementptr inbounds ({ [7 x ptr], [11 x ptr] }, ptr @_ZTC2D30_2V0, i32 0, i32 1, i32 6) to i64)]), +// CHECK-SAME: ptr ptrauth (ptr @_ZTcv0_n32_h4_N2V02m1Ev, [i64 0, i64 15165, i64 ptrtoint (ptr getelementptr inbounds ({ [7 x ptr], [11 x ptr] }, ptr @_ZTC2D30_2V0, i32 0, i32 1, i32 7) to i64)]), +// CHECK-SAME: ptr ptrauth (ptr @_ZN2B02m2Ev, [i64 0, i64 43073, i64 ptrtoint (ptr getelementptr inbounds ({ [7 x ptr], [11 x ptr] }, ptr @_ZTC2D30_2V0, i32 0, i32 1, i32 8) to i64)]), +// CHECK-SAME: ptr ptrauth (ptr @_ZTv0_n48_N2V0D1Ev, [i64 0, i64 25525, i64 ptrtoint (ptr getelementptr inbounds ({ [7 x ptr], [11 x ptr] }, ptr @_ZTC2D30_2V0, i32 0, i32 1, i32 9) to i64)]), +// CHECK-SAME: ptr ptrauth (ptr @_ZTv0_n48_N2V0D0Ev, [i64 0, i64 21295, i64 ptrtoint (ptr getelementptr inbounds ({ [7 x ptr], [11 x ptr] }, ptr @_ZTC2D30_2V0, i32 0, i32 1, i32 10) to i64)])] }, align 8 // CHECK: @_ZTC2D316_2V1 = unnamed_addr constant { [7 x ptr], [11 x ptr] } { [7 x ptr] [ptr inttoptr (i64 16 to ptr), ptr null, ptr @_ZTI2V1, -// CHECK-SAME: ptr ptrauth (ptr @_ZN2V12m0Ev, i32 0, i64 49430, ptr getelementptr inbounds ({ [7 x ptr], [11 x ptr] }, ptr @_ZTC2D316_2V1, i32 0, i32 0, i32 3)), -// CHECK-SAME: ptr ptrauth (ptr @_ZN2V12m1Ev, i32 0, i64 57119, ptr getelementptr inbounds ({ [7 x ptr], [11 x ptr] }, ptr @_ZTC2D316_2V1, i32 0, i32 0, i32 4)), -// CHECK-SAME: ptr ptrauth (ptr @_ZN2V1D1Ev, i32 0, i64 60799, ptr getelementptr inbounds ({ [7 x ptr], [11 x ptr] }, ptr @_ZTC2D316_2V1, i32 0, i32 0, i32 5)), -// CHECK-SAME: ptr ptrauth (ptr @_ZN2V1D0Ev, i32 0, i64 52565, ptr getelementptr inbounds ({ [7 x ptr], [11 x ptr] }, ptr @_ZTC2D316_2V1, i32 0, i32 0, i32 6))], +// CHECK-SAME: ptr ptrauth (ptr @_ZN2V12m0Ev, [i64 0, i64 49430, i64 ptrtoint (ptr getelementptr inbounds ({ [7 x ptr], [11 x ptr] }, ptr @_ZTC2D316_2V1, i32 0, i32 0, i32 3) to i64)]), +// CHECK-SAME: ptr ptrauth (ptr @_ZN2V12m1Ev, [i64 0, i64 57119, i64 ptrtoint (ptr getelementptr inbounds ({ [7 x ptr], [11 x ptr] }, ptr @_ZTC2D316_2V1, i32 0, i32 0, i32 4) to i64)]), +// CHECK-SAME: ptr ptrauth (ptr @_ZN2V1D1Ev, [i64 0, i64 60799, i64 ptrtoint (ptr getelementptr inbounds ({ [7 x ptr], [11 x ptr] }, ptr @_ZTC2D316_2V1, i32 0, i32 0, i32 5) to i64)]), +// CHECK-SAME: ptr ptrauth (ptr @_ZN2V1D0Ev, [i64 0, i64 52565, i64 ptrtoint (ptr getelementptr inbounds ({ [7 x ptr], [11 x ptr] }, ptr @_ZTC2D316_2V1, i32 0, i32 0, i32 6) to i64)])], // CHECK-SAME: [11 x ptr] [ptr inttoptr (i64 -16 to ptr), ptr null, ptr inttoptr (i64 -16 to ptr), ptr inttoptr (i64 -16 to ptr), ptr inttoptr (i64 -16 to ptr), ptr @_ZTI2V1, -// CHECK-SAME: ptr ptrauth (ptr @_ZTv0_n24_N2V12m0Ev, i32 0, i64 53119, ptr getelementptr inbounds ({ [7 x ptr], [11 x ptr] }, ptr @_ZTC2D316_2V1, i32 0, i32 1, i32 6)), -// CHECK-SAME: ptr ptrauth (ptr @_ZTcv0_n32_h4_N2V12m1Ev, i32 0, i64 15165, ptr getelementptr inbounds ({ [7 x ptr], [11 x ptr] }, ptr @_ZTC2D316_2V1, i32 0, i32 1, i32 7)), -// CHECK-SAME: ptr ptrauth (ptr @_ZN2B02m2Ev, i32 0, i64 43073, ptr getelementptr inbounds ({ [7 x ptr], [11 x ptr] }, ptr @_ZTC2D316_2V1, i32 0, i32 1, i32 8)), -// CHECK-SAME: ptr ptrauth (ptr @_ZTv0_n48_N2V1D1Ev, i32 0, i64 25525, ptr getelementptr inbounds ({ [7 x ptr], [11 x ptr] }, ptr @_ZTC2D316_2V1, i32 0, i32 1, i32 9)), -// CHECK-SAME: ptr ptrauth (ptr @_ZTv0_n48_N2V1D0Ev, i32 0, i64 21295, ptr getelementptr inbounds ({ [7 x ptr], [11 x ptr] }, ptr @_ZTC2D316_2V1, i32 0, i32 1, i32 10))] }, align 8 +// CHECK-SAME: ptr ptrauth (ptr @_ZTv0_n24_N2V12m0Ev, [i64 0, i64 53119, i64 ptrtoint (ptr getelementptr inbounds ({ [7 x ptr], [11 x ptr] }, ptr @_ZTC2D316_2V1, i32 0, i32 1, i32 6) to i64)]), +// CHECK-SAME: ptr ptrauth (ptr @_ZTcv0_n32_h4_N2V12m1Ev, [i64 0, i64 15165, i64 ptrtoint (ptr getelementptr inbounds ({ [7 x ptr], [11 x ptr] }, ptr @_ZTC2D316_2V1, i32 0, i32 1, i32 7) to i64)]), +// CHECK-SAME: ptr ptrauth (ptr @_ZN2B02m2Ev, [i64 0, i64 43073, i64 ptrtoint (ptr getelementptr inbounds ({ [7 x ptr], [11 x ptr] }, ptr @_ZTC2D316_2V1, i32 0, i32 1, i32 8) to i64)]), +// CHECK-SAME: ptr ptrauth (ptr @_ZTv0_n48_N2V1D1Ev, [i64 0, i64 25525, i64 ptrtoint (ptr getelementptr inbounds ({ [7 x ptr], [11 x ptr] }, ptr @_ZTC2D316_2V1, i32 0, i32 1, i32 9) to i64)]), +// CHECK-SAME: ptr ptrauth (ptr @_ZTv0_n48_N2V1D0Ev, [i64 0, i64 21295, i64 ptrtoint (ptr getelementptr inbounds ({ [7 x ptr], [11 x ptr] }, ptr @_ZTC2D316_2V1, i32 0, i32 1, i32 10) to i64)])] }, align 8 struct S0 { diff --git a/clang/test/CodeGenCXX/ptrauth-vtable-virtual-inheritance-thunk.cpp b/clang/test/CodeGenCXX/ptrauth-vtable-virtual-inheritance-thunk.cpp index 8a155d0031ad2..b348ffd6a50ab 100644 --- a/clang/test/CodeGenCXX/ptrauth-vtable-virtual-inheritance-thunk.cpp +++ b/clang/test/CodeGenCXX/ptrauth-vtable-virtual-inheritance-thunk.cpp @@ -6,184 +6,184 @@ // The actual vtable construction // CHECK: @_ZTV1C = unnamed_addr constant { [5 x ptr], [11 x ptr] } { [5 x ptr] [ptr inttoptr (i64 8 to ptr), ptr null, ptr @_ZTI1C, -// CHECK-SAME: ptr ptrauth (ptr @_ZN1CD1Ev, i32 0, i64 31214, ptr getelementptr inbounds ({ [5 x ptr], [11 x ptr] }, ptr @_ZTV1C, i32 0, i32 0, i32 3)), -// CHECK-SAME: ptr ptrauth (ptr @_ZN1CD0Ev, i32 0, i64 8507, ptr getelementptr inbounds ({ [5 x ptr], [11 x ptr] }, ptr @_ZTV1C, i32 0, i32 0, i32 4))], +// CHECK-SAME: ptr ptrauth (ptr @_ZN1CD1Ev, [i64 0, i64 31214, i64 ptrtoint (ptr getelementptr inbounds ({ [5 x ptr], [11 x ptr] }, ptr @_ZTV1C, i32 0, i32 0, i32 3) to i64)]), +// CHECK-SAME: ptr ptrauth (ptr @_ZN1CD0Ev, [i64 0, i64 8507, i64 ptrtoint (ptr getelementptr inbounds ({ [5 x ptr], [11 x ptr] }, ptr @_ZTV1C, i32 0, i32 0, i32 4) to i64)])], // CHECK-SAME: [11 x ptr] [ptr inttoptr (i64 -8 to ptr), ptr null, ptr null, ptr null, ptr inttoptr (i64 -8 to ptr), ptr @_ZTI1C, -// CHECK-SAME: ptr ptrauth (ptr @_ZN1A1fEv, i32 0, i64 55636, ptr getelementptr inbounds ({ [5 x ptr], [11 x ptr] }, ptr @_ZTV1C, i32 0, i32 1, i32 6)), -// CHECK-SAME: ptr ptrauth (ptr @_ZN1A1gEv, i32 0, i64 19402, ptr getelementptr inbounds ({ [5 x ptr], [11 x ptr] }, ptr @_ZTV1C, i32 0, i32 1, i32 7)), -// CHECK-SAME: ptr ptrauth (ptr @_ZN1A1hEz, i32 0, i64 31735, ptr getelementptr inbounds ({ [5 x ptr], [11 x ptr] }, ptr @_ZTV1C, i32 0, i32 1, i32 8)), -// CHECK-SAME: ptr ptrauth (ptr @_ZTv0_n48_N1CD1Ev, i32 0, i64 2043, ptr getelementptr inbounds ({ [5 x ptr], [11 x ptr] }, ptr @_ZTV1C, i32 0, i32 1, i32 9)), -// CHECK-SAME: ptr ptrauth (ptr @_ZTv0_n48_N1CD0Ev, i32 0, i64 63674, ptr getelementptr inbounds ({ [5 x ptr], [11 x ptr] }, ptr @_ZTV1C, i32 0, i32 1, i32 10))] }, align 8 +// CHECK-SAME: ptr ptrauth (ptr @_ZN1A1fEv, [i64 0, i64 55636, i64 ptrtoint (ptr getelementptr inbounds ({ [5 x ptr], [11 x ptr] }, ptr @_ZTV1C, i32 0, i32 1, i32 6) to i64)]), +// CHECK-SAME: ptr ptrauth (ptr @_ZN1A1gEv, [i64 0, i64 19402, i64 ptrtoint (ptr getelementptr inbounds ({ [5 x ptr], [11 x ptr] }, ptr @_ZTV1C, i32 0, i32 1, i32 7) to i64)]), +// CHECK-SAME: ptr ptrauth (ptr @_ZN1A1hEz, [i64 0, i64 31735, i64 ptrtoint (ptr getelementptr inbounds ({ [5 x ptr], [11 x ptr] }, ptr @_ZTV1C, i32 0, i32 1, i32 8) to i64)]), +// CHECK-SAME: ptr ptrauth (ptr @_ZTv0_n48_N1CD1Ev, [i64 0, i64 2043, i64 ptrtoint (ptr getelementptr inbounds ({ [5 x ptr], [11 x ptr] }, ptr @_ZTV1C, i32 0, i32 1, i32 9) to i64)]), +// CHECK-SAME: ptr ptrauth (ptr @_ZTv0_n48_N1CD0Ev, [i64 0, i64 63674, i64 ptrtoint (ptr getelementptr inbounds ({ [5 x ptr], [11 x ptr] }, ptr @_ZTV1C, i32 0, i32 1, i32 10) to i64)])] }, align 8 -// CHECK: @_ZTT1C = unnamed_addr constant [2 x ptr] [ptr ptrauth (ptr getelementptr inbounds inrange(-24, 16) ({ [5 x ptr], [11 x ptr] }, ptr @_ZTV1C, i32 0, i32 0, i32 3), i32 2), -// CHECK-SAME: ptr ptrauth (ptr getelementptr inbounds inrange(-48, 40) ({ [5 x ptr], [11 x ptr] }, ptr @_ZTV1C, i32 0, i32 1, i32 6), i32 2)], align 8 +// CHECK: @_ZTT1C = unnamed_addr constant [2 x ptr] [ptr ptrauth (ptr getelementptr inbounds inrange(-24, 16) ({ [5 x ptr], [11 x ptr] }, ptr @_ZTV1C, i32 0, i32 0, i32 3), [i64 2, i64 0, i64 0]), +// CHECK-SAME: ptr ptrauth (ptr getelementptr inbounds inrange(-48, 40) ({ [5 x ptr], [11 x ptr] }, ptr @_ZTV1C, i32 0, i32 1, i32 6), [i64 2, i64 0, i64 0])], align 8 // CHECK: @_ZTV1D = unnamed_addr constant { [7 x ptr], [11 x ptr] } { [7 x ptr] [ptr inttoptr (i64 8 to ptr), ptr null, ptr @_ZTI1D, -// CHECK-SAME: ptr ptrauth (ptr @_ZN1DD1Ev, i32 0, i64 59423, ptr getelementptr inbounds ({ [7 x ptr], [11 x ptr] }, ptr @_ZTV1D, i32 0, i32 0, i32 3)), -// CHECK-SAME: ptr ptrauth (ptr @_ZN1DD0Ev, i32 0, i64 25900, ptr getelementptr inbounds ({ [7 x ptr], [11 x ptr] }, ptr @_ZTV1D, i32 0, i32 0, i32 4)), -// CHECK-SAME: ptr ptrauth (ptr @_ZN1D1gEv, i32 0, i64 59070, ptr getelementptr inbounds ({ [7 x ptr], [11 x ptr] }, ptr @_ZTV1D, i32 0, i32 0, i32 5)), -// CHECK-SAME: ptr ptrauth (ptr @_ZN1D1hEz, i32 0, i64 65100, ptr getelementptr inbounds ({ [7 x ptr], [11 x ptr] }, ptr @_ZTV1D, i32 0, i32 0, i32 6))], +// CHECK-SAME: ptr ptrauth (ptr @_ZN1DD1Ev, [i64 0, i64 59423, i64 ptrtoint (ptr getelementptr inbounds ({ [7 x ptr], [11 x ptr] }, ptr @_ZTV1D, i32 0, i32 0, i32 3) to i64)]), +// CHECK-SAME: ptr ptrauth (ptr @_ZN1DD0Ev, [i64 0, i64 25900, i64 ptrtoint (ptr getelementptr inbounds ({ [7 x ptr], [11 x ptr] }, ptr @_ZTV1D, i32 0, i32 0, i32 4) to i64)]), +// CHECK-SAME: ptr ptrauth (ptr @_ZN1D1gEv, [i64 0, i64 59070, i64 ptrtoint (ptr getelementptr inbounds ({ [7 x ptr], [11 x ptr] }, ptr @_ZTV1D, i32 0, i32 0, i32 5) to i64)]), +// CHECK-SAME: ptr ptrauth (ptr @_ZN1D1hEz, [i64 0, i64 65100, i64 ptrtoint (ptr getelementptr inbounds ({ [7 x ptr], [11 x ptr] }, ptr @_ZTV1D, i32 0, i32 0, i32 6) to i64)])], // CHECK-SAME: [11 x ptr] [ptr inttoptr (i64 -8 to ptr), ptr inttoptr (i64 -8 to ptr), ptr inttoptr (i64 -8 to ptr), ptr null, ptr inttoptr (i64 -8 to ptr), ptr @_ZTI1D, -// CHECK-SAME: ptr ptrauth (ptr @_ZN1A1fEv, i32 0, i64 55636, ptr getelementptr inbounds ({ [7 x ptr], [11 x ptr] }, ptr @_ZTV1D, i32 0, i32 1, i32 6)), -// CHECK-SAME: ptr ptrauth (ptr @_ZTv0_n32_N1D1gEv, i32 0, i64 19402, ptr getelementptr inbounds ({ [7 x ptr], [11 x ptr] }, ptr @_ZTV1D, i32 0, i32 1, i32 7)), -// CHECK-SAME: ptr ptrauth (ptr @_ZTv0_n40_N1D1hEz, i32 0, i64 31735, ptr getelementptr inbounds ({ [7 x ptr], [11 x ptr] }, ptr @_ZTV1D, i32 0, i32 1, i32 8)), -// CHECK-SAME: ptr ptrauth (ptr @_ZTv0_n48_N1DD1Ev, i32 0, i64 2043, ptr getelementptr inbounds ({ [7 x ptr], [11 x ptr] }, ptr @_ZTV1D, i32 0, i32 1, i32 9)), -// CHECK-SAME: ptr ptrauth (ptr @_ZTv0_n48_N1DD0Ev, i32 0, i64 63674, ptr getelementptr inbounds ({ [7 x ptr], [11 x ptr] }, ptr @_ZTV1D, i32 0, i32 1, i32 10))] }, align 8 +// CHECK-SAME: ptr ptrauth (ptr @_ZN1A1fEv, [i64 0, i64 55636, i64 ptrtoint (ptr getelementptr inbounds ({ [7 x ptr], [11 x ptr] }, ptr @_ZTV1D, i32 0, i32 1, i32 6) to i64)]), +// CHECK-SAME: ptr ptrauth (ptr @_ZTv0_n32_N1D1gEv, [i64 0, i64 19402, i64 ptrtoint (ptr getelementptr inbounds ({ [7 x ptr], [11 x ptr] }, ptr @_ZTV1D, i32 0, i32 1, i32 7) to i64)]), +// CHECK-SAME: ptr ptrauth (ptr @_ZTv0_n40_N1D1hEz, [i64 0, i64 31735, i64 ptrtoint (ptr getelementptr inbounds ({ [7 x ptr], [11 x ptr] }, ptr @_ZTV1D, i32 0, i32 1, i32 8) to i64)]), +// CHECK-SAME: ptr ptrauth (ptr @_ZTv0_n48_N1DD1Ev, [i64 0, i64 2043, i64 ptrtoint (ptr getelementptr inbounds ({ [7 x ptr], [11 x ptr] }, ptr @_ZTV1D, i32 0, i32 1, i32 9) to i64)]), +// CHECK-SAME: ptr ptrauth (ptr @_ZTv0_n48_N1DD0Ev, [i64 0, i64 63674, i64 ptrtoint (ptr getelementptr inbounds ({ [7 x ptr], [11 x ptr] }, ptr @_ZTV1D, i32 0, i32 1, i32 10) to i64)])] }, align 8 -// CHECK: @_ZTT1D = unnamed_addr constant [2 x ptr] [ptr ptrauth (ptr getelementptr inbounds inrange(-24, 32) ({ [7 x ptr], [11 x ptr] }, ptr @_ZTV1D, i32 0, i32 0, i32 3), i32 2), -// CHECK-SAME: ptr ptrauth (ptr getelementptr inbounds inrange(-48, 40) ({ [7 x ptr], [11 x ptr] }, ptr @_ZTV1D, i32 0, i32 1, i32 6), i32 2)], align 8 +// CHECK: @_ZTT1D = unnamed_addr constant [2 x ptr] [ptr ptrauth (ptr getelementptr inbounds inrange(-24, 32) ({ [7 x ptr], [11 x ptr] }, ptr @_ZTV1D, i32 0, i32 0, i32 3), [i64 2, i64 0, i64 0]), +// CHECK-SAME: ptr ptrauth (ptr getelementptr inbounds inrange(-48, 40) ({ [7 x ptr], [11 x ptr] }, ptr @_ZTV1D, i32 0, i32 1, i32 6), [i64 2, i64 0, i64 0])], align 8 // CHECK: @_ZTV1F = unnamed_addr constant { [6 x ptr], [7 x ptr], [11 x ptr], [11 x ptr] } { [6 x ptr] [ptr inttoptr (i64 32 to ptr), ptr inttoptr (i64 16 to ptr), ptr null, ptr @_ZTI1F, -// CHECK-SAME: ptr ptrauth (ptr @_ZN1FD1Ev, i32 0, i64 31214, ptr getelementptr inbounds ({ [6 x ptr], [7 x ptr], [11 x ptr], [11 x ptr] }, ptr @_ZTV1F, i32 0, i32 0, i32 4)), -// CHECK-SAME: ptr ptrauth (ptr @_ZN1FD0Ev, i32 0, i64 8507, ptr getelementptr inbounds ({ [6 x ptr], [7 x ptr], [11 x ptr], [11 x ptr] }, ptr @_ZTV1F, i32 0, i32 0, i32 5))], [7 x ptr] [ptr inttoptr (i64 8 to ptr), ptr inttoptr (i64 -8 to ptr), ptr @_ZTI1F, -// CHECK-SAME: ptr ptrauth (ptr @_ZThn8_N1FD1Ev, i32 0, i64 59423, ptr getelementptr inbounds ({ [6 x ptr], [7 x ptr], [11 x ptr], [11 x ptr] }, ptr @_ZTV1F, i32 0, i32 1, i32 3)), -// CHECK-SAME: ptr ptrauth (ptr @_ZThn8_N1FD0Ev, i32 0, i64 25900, ptr getelementptr inbounds ({ [6 x ptr], [7 x ptr], [11 x ptr], [11 x ptr] }, ptr @_ZTV1F, i32 0, i32 1, i32 4)), -// CHECK-SAME: ptr ptrauth (ptr @_ZN1D1gEv, i32 0, i64 59070, ptr getelementptr inbounds ({ [6 x ptr], [7 x ptr], [11 x ptr], [11 x ptr] }, ptr @_ZTV1F, i32 0, i32 1, i32 5)), -// CHECK-SAME: ptr ptrauth (ptr @_ZN1D1hEz, i32 0, i64 65100, ptr getelementptr inbounds ({ [6 x ptr], [7 x ptr], [11 x ptr], [11 x ptr] }, ptr @_ZTV1F, i32 0, i32 1, i32 6))], [11 x ptr] [ptr inttoptr (i64 -16 to ptr), ptr inttoptr (i64 -8 to ptr), ptr inttoptr (i64 -8 to ptr), ptr null, ptr inttoptr (i64 -16 to ptr), ptr @_ZTI1F, -// CHECK-SAME: ptr ptrauth (ptr @_ZN1A1fEv, i32 0, i64 55636, ptr getelementptr inbounds ({ [6 x ptr], [7 x ptr], [11 x ptr], [11 x ptr] }, ptr @_ZTV1F, i32 0, i32 2, i32 6)), -// CHECK-SAME: ptr ptrauth (ptr @_ZTv0_n32_N1D1gEv, i32 0, i64 19402, ptr getelementptr inbounds ({ [6 x ptr], [7 x ptr], [11 x ptr], [11 x ptr] }, ptr @_ZTV1F, i32 0, i32 2, i32 7)), -// CHECK-SAME: ptr ptrauth (ptr @_ZTv0_n40_N1D1hEz, i32 0, i64 31735, ptr getelementptr inbounds ({ [6 x ptr], [7 x ptr], [11 x ptr], [11 x ptr] }, ptr @_ZTV1F, i32 0, i32 2, i32 8)), -// CHECK-SAME: ptr ptrauth (ptr @_ZTv0_n48_N1FD1EvU11__vtptrauthILj0Lb0Lj62866E, i32 0, i64 2043, ptr getelementptr inbounds ({ [6 x ptr], [7 x ptr], [11 x ptr], [11 x ptr] }, ptr @_ZTV1F, i32 0, i32 2, i32 9)), -// CHECK-SAME: ptr ptrauth (ptr @_ZTv0_n48_N1FD0EvU11__vtptrauthILj0Lb0Lj62866E, i32 0, i64 63674, ptr getelementptr inbounds ({ [6 x ptr], [7 x ptr], [11 x ptr], [11 x ptr] }, ptr @_ZTV1F, i32 0, i32 2, i32 10))], [11 x ptr] [ptr inttoptr (i64 -32 to ptr), ptr null, ptr null, ptr null, ptr inttoptr (i64 -32 to ptr), ptr @_ZTI1F, -// CHECK-SAME: ptr ptrauth (ptr @_ZN1E1fEv, i32 0, i64 28408, ptr getelementptr inbounds ({ [6 x ptr], [7 x ptr], [11 x ptr], [11 x ptr] }, ptr @_ZTV1F, i32 0, i32 3, i32 6)), -// CHECK-SAME: ptr ptrauth (ptr @_ZN1E1gEv, i32 0, i64 22926, ptr getelementptr inbounds ({ [6 x ptr], [7 x ptr], [11 x ptr], [11 x ptr] }, ptr @_ZTV1F, i32 0, i32 3, i32 7)), -// CHECK-SAME: ptr ptrauth (ptr @_ZN1E1hEz, i32 0, i64 9832, ptr getelementptr inbounds ({ [6 x ptr], [7 x ptr], [11 x ptr], [11 x ptr] }, ptr @_ZTV1F, i32 0, i32 3, i32 8)), -// CHECK-SAME: ptr ptrauth (ptr @_ZTv0_n48_N1FD1Ev, i32 0, i64 5817, ptr getelementptr inbounds ({ [6 x ptr], [7 x ptr], [11 x ptr], [11 x ptr] }, ptr @_ZTV1F, i32 0, i32 3, i32 9)), -// CHECK-SAME: ptr ptrauth (ptr @_ZTv0_n48_N1FD0Ev, i32 0, i64 26464, ptr getelementptr inbounds ({ [6 x ptr], [7 x ptr], [11 x ptr], [11 x ptr] }, ptr @_ZTV1F, i32 0, i32 3, i32 10))] }, align 8 - -// CHECK: @_ZTT1F = unnamed_addr constant [8 x ptr] [ptr ptrauth (ptr getelementptr inbounds inrange(-32, 16) ({ [6 x ptr], [7 x ptr], [11 x ptr], [11 x ptr] }, ptr @_ZTV1F, i32 0, i32 0, i32 4), i32 2), -// CHECK-SAME: ptr ptrauth (ptr getelementptr inbounds inrange(-24, 16) ({ [5 x ptr], [11 x ptr] }, ptr @_ZTC1F0_1C, i32 0, i32 0, i32 3), i32 2), -// CHECK-SAME: ptr ptrauth (ptr getelementptr inbounds inrange(-48, 40) ({ [5 x ptr], [11 x ptr] }, ptr @_ZTC1F0_1C, i32 0, i32 1, i32 6), i32 2), -// CHECK-SAME: ptr ptrauth (ptr getelementptr inbounds inrange(-24, 32) ({ [7 x ptr], [11 x ptr] }, ptr @_ZTC1F8_1D, i32 0, i32 0, i32 3), i32 2), -// CHECK-SAME: ptr ptrauth (ptr getelementptr inbounds inrange(-48, 40) ({ [7 x ptr], [11 x ptr] }, ptr @_ZTC1F8_1D, i32 0, i32 1, i32 6), i32 2), -// CHECK-SAME: ptr ptrauth (ptr getelementptr inbounds inrange(-48, 40) ({ [6 x ptr], [7 x ptr], [11 x ptr], [11 x ptr] }, ptr @_ZTV1F, i32 0, i32 2, i32 6), i32 2), -// CHECK-SAME: ptr ptrauth (ptr getelementptr inbounds inrange(-24, 32) ({ [6 x ptr], [7 x ptr], [11 x ptr], [11 x ptr] }, ptr @_ZTV1F, i32 0, i32 1, i32 3), i32 2), -// CHECK-SAME: ptr ptrauth (ptr getelementptr inbounds inrange(-48, 40) ({ [6 x ptr], [7 x ptr], [11 x ptr], [11 x ptr] }, ptr @_ZTV1F, i32 0, i32 3, i32 6), i32 2)], align 8 +// CHECK-SAME: ptr ptrauth (ptr @_ZN1FD1Ev, [i64 0, i64 31214, i64 ptrtoint (ptr getelementptr inbounds ({ [6 x ptr], [7 x ptr], [11 x ptr], [11 x ptr] }, ptr @_ZTV1F, i32 0, i32 0, i32 4) to i64)]), +// CHECK-SAME: ptr ptrauth (ptr @_ZN1FD0Ev, [i64 0, i64 8507, i64 ptrtoint (ptr getelementptr inbounds ({ [6 x ptr], [7 x ptr], [11 x ptr], [11 x ptr] }, ptr @_ZTV1F, i32 0, i32 0, i32 5) to i64)])], [7 x ptr] [ptr inttoptr (i64 8 to ptr), ptr inttoptr (i64 -8 to ptr), ptr @_ZTI1F, +// CHECK-SAME: ptr ptrauth (ptr @_ZThn8_N1FD1Ev, [i64 0, i64 59423, i64 ptrtoint (ptr getelementptr inbounds ({ [6 x ptr], [7 x ptr], [11 x ptr], [11 x ptr] }, ptr @_ZTV1F, i32 0, i32 1, i32 3) to i64)]), +// CHECK-SAME: ptr ptrauth (ptr @_ZThn8_N1FD0Ev, [i64 0, i64 25900, i64 ptrtoint (ptr getelementptr inbounds ({ [6 x ptr], [7 x ptr], [11 x ptr], [11 x ptr] }, ptr @_ZTV1F, i32 0, i32 1, i32 4) to i64)]), +// CHECK-SAME: ptr ptrauth (ptr @_ZN1D1gEv, [i64 0, i64 59070, i64 ptrtoint (ptr getelementptr inbounds ({ [6 x ptr], [7 x ptr], [11 x ptr], [11 x ptr] }, ptr @_ZTV1F, i32 0, i32 1, i32 5) to i64)]), +// CHECK-SAME: ptr ptrauth (ptr @_ZN1D1hEz, [i64 0, i64 65100, i64 ptrtoint (ptr getelementptr inbounds ({ [6 x ptr], [7 x ptr], [11 x ptr], [11 x ptr] }, ptr @_ZTV1F, i32 0, i32 1, i32 6) to i64)])], [11 x ptr] [ptr inttoptr (i64 -16 to ptr), ptr inttoptr (i64 -8 to ptr), ptr inttoptr (i64 -8 to ptr), ptr null, ptr inttoptr (i64 -16 to ptr), ptr @_ZTI1F, +// CHECK-SAME: ptr ptrauth (ptr @_ZN1A1fEv, [i64 0, i64 55636, i64 ptrtoint (ptr getelementptr inbounds ({ [6 x ptr], [7 x ptr], [11 x ptr], [11 x ptr] }, ptr @_ZTV1F, i32 0, i32 2, i32 6) to i64)]), +// CHECK-SAME: ptr ptrauth (ptr @_ZTv0_n32_N1D1gEv, [i64 0, i64 19402, i64 ptrtoint (ptr getelementptr inbounds ({ [6 x ptr], [7 x ptr], [11 x ptr], [11 x ptr] }, ptr @_ZTV1F, i32 0, i32 2, i32 7) to i64)]), +// CHECK-SAME: ptr ptrauth (ptr @_ZTv0_n40_N1D1hEz, [i64 0, i64 31735, i64 ptrtoint (ptr getelementptr inbounds ({ [6 x ptr], [7 x ptr], [11 x ptr], [11 x ptr] }, ptr @_ZTV1F, i32 0, i32 2, i32 8) to i64)]), +// CHECK-SAME: ptr ptrauth (ptr @_ZTv0_n48_N1FD1EvU11__vtptrauthILj0Lb0Lj62866E, [i64 0, i64 2043, i64 ptrtoint (ptr getelementptr inbounds ({ [6 x ptr], [7 x ptr], [11 x ptr], [11 x ptr] }, ptr @_ZTV1F, i32 0, i32 2, i32 9) to i64)]), +// CHECK-SAME: ptr ptrauth (ptr @_ZTv0_n48_N1FD0EvU11__vtptrauthILj0Lb0Lj62866E, [i64 0, i64 63674, i64 ptrtoint (ptr getelementptr inbounds ({ [6 x ptr], [7 x ptr], [11 x ptr], [11 x ptr] }, ptr @_ZTV1F, i32 0, i32 2, i32 10) to i64)])], [11 x ptr] [ptr inttoptr (i64 -32 to ptr), ptr null, ptr null, ptr null, ptr inttoptr (i64 -32 to ptr), ptr @_ZTI1F, +// CHECK-SAME: ptr ptrauth (ptr @_ZN1E1fEv, [i64 0, i64 28408, i64 ptrtoint (ptr getelementptr inbounds ({ [6 x ptr], [7 x ptr], [11 x ptr], [11 x ptr] }, ptr @_ZTV1F, i32 0, i32 3, i32 6) to i64)]), +// CHECK-SAME: ptr ptrauth (ptr @_ZN1E1gEv, [i64 0, i64 22926, i64 ptrtoint (ptr getelementptr inbounds ({ [6 x ptr], [7 x ptr], [11 x ptr], [11 x ptr] }, ptr @_ZTV1F, i32 0, i32 3, i32 7) to i64)]), +// CHECK-SAME: ptr ptrauth (ptr @_ZN1E1hEz, [i64 0, i64 9832, i64 ptrtoint (ptr getelementptr inbounds ({ [6 x ptr], [7 x ptr], [11 x ptr], [11 x ptr] }, ptr @_ZTV1F, i32 0, i32 3, i32 8) to i64)]), +// CHECK-SAME: ptr ptrauth (ptr @_ZTv0_n48_N1FD1Ev, [i64 0, i64 5817, i64 ptrtoint (ptr getelementptr inbounds ({ [6 x ptr], [7 x ptr], [11 x ptr], [11 x ptr] }, ptr @_ZTV1F, i32 0, i32 3, i32 9) to i64)]), +// CHECK-SAME: ptr ptrauth (ptr @_ZTv0_n48_N1FD0Ev, [i64 0, i64 26464, i64 ptrtoint (ptr getelementptr inbounds ({ [6 x ptr], [7 x ptr], [11 x ptr], [11 x ptr] }, ptr @_ZTV1F, i32 0, i32 3, i32 10) to i64)])] }, align 8 + +// CHECK: @_ZTT1F = unnamed_addr constant [8 x ptr] [ptr ptrauth (ptr getelementptr inbounds inrange(-32, 16) ({ [6 x ptr], [7 x ptr], [11 x ptr], [11 x ptr] }, ptr @_ZTV1F, i32 0, i32 0, i32 4), [i64 2, i64 0, i64 0]), +// CHECK-SAME: ptr ptrauth (ptr getelementptr inbounds inrange(-24, 16) ({ [5 x ptr], [11 x ptr] }, ptr @_ZTC1F0_1C, i32 0, i32 0, i32 3), [i64 2, i64 0, i64 0]), +// CHECK-SAME: ptr ptrauth (ptr getelementptr inbounds inrange(-48, 40) ({ [5 x ptr], [11 x ptr] }, ptr @_ZTC1F0_1C, i32 0, i32 1, i32 6), [i64 2, i64 0, i64 0]), +// CHECK-SAME: ptr ptrauth (ptr getelementptr inbounds inrange(-24, 32) ({ [7 x ptr], [11 x ptr] }, ptr @_ZTC1F8_1D, i32 0, i32 0, i32 3), [i64 2, i64 0, i64 0]), +// CHECK-SAME: ptr ptrauth (ptr getelementptr inbounds inrange(-48, 40) ({ [7 x ptr], [11 x ptr] }, ptr @_ZTC1F8_1D, i32 0, i32 1, i32 6), [i64 2, i64 0, i64 0]), +// CHECK-SAME: ptr ptrauth (ptr getelementptr inbounds inrange(-48, 40) ({ [6 x ptr], [7 x ptr], [11 x ptr], [11 x ptr] }, ptr @_ZTV1F, i32 0, i32 2, i32 6), [i64 2, i64 0, i64 0]), +// CHECK-SAME: ptr ptrauth (ptr getelementptr inbounds inrange(-24, 32) ({ [6 x ptr], [7 x ptr], [11 x ptr], [11 x ptr] }, ptr @_ZTV1F, i32 0, i32 1, i32 3), [i64 2, i64 0, i64 0]), +// CHECK-SAME: ptr ptrauth (ptr getelementptr inbounds inrange(-48, 40) ({ [6 x ptr], [7 x ptr], [11 x ptr], [11 x ptr] }, ptr @_ZTV1F, i32 0, i32 3, i32 6), [i64 2, i64 0, i64 0])], align 8 // CHECK: @_ZTV1G = unnamed_addr constant { [6 x ptr], [7 x ptr], [11 x ptr], [11 x ptr] } { [6 x ptr] [ptr inttoptr (i64 16 to ptr), ptr inttoptr (i64 24 to ptr), ptr null, ptr @_ZTI1G, -// CHECK-SAME: ptr ptrauth (ptr @_ZN1GD1Ev, i32 0, i64 31214, ptr getelementptr inbounds ({ [6 x ptr], [7 x ptr], [11 x ptr], [11 x ptr] }, ptr @_ZTV1G, i32 0, i32 0, i32 4)), -// CHECK-SAME: ptr ptrauth (ptr @_ZN1GD0Ev, i32 0, i64 8507, ptr getelementptr inbounds ({ [6 x ptr], [7 x ptr], [11 x ptr], [11 x ptr] }, ptr @_ZTV1G, i32 0, i32 0, i32 5))], [7 x ptr] [ptr inttoptr (i64 16 to ptr), ptr inttoptr (i64 -8 to ptr), ptr @_ZTI1G, -// CHECK-SAME: ptr ptrauth (ptr @_ZThn8_N1GD1Ev, i32 0, i64 59423, ptr getelementptr inbounds ({ [6 x ptr], [7 x ptr], [11 x ptr], [11 x ptr] }, ptr @_ZTV1G, i32 0, i32 1, i32 3)), -// CHECK-SAME: ptr ptrauth (ptr @_ZThn8_N1GD0Ev, i32 0, i64 25900, ptr getelementptr inbounds ({ [6 x ptr], [7 x ptr], [11 x ptr], [11 x ptr] }, ptr @_ZTV1G, i32 0, i32 1, i32 4)), -// CHECK-SAME: ptr ptrauth (ptr @_ZN1D1gEv, i32 0, i64 59070, ptr getelementptr inbounds ({ [6 x ptr], [7 x ptr], [11 x ptr], [11 x ptr] }, ptr @_ZTV1G, i32 0, i32 1, i32 5)), -// CHECK-SAME: ptr ptrauth (ptr @_ZN1D1hEz, i32 0, i64 65100, ptr getelementptr inbounds ({ [6 x ptr], [7 x ptr], [11 x ptr], [11 x ptr] }, ptr @_ZTV1G, i32 0, i32 1, i32 6))], [11 x ptr] [ptr inttoptr (i64 -16 to ptr), ptr null, ptr null, ptr null, ptr inttoptr (i64 -16 to ptr), ptr @_ZTI1G, -// CHECK-SAME: ptr ptrauth (ptr @_ZN1E1fEv, i32 0, i64 28408, ptr getelementptr inbounds ({ [6 x ptr], [7 x ptr], [11 x ptr], [11 x ptr] }, ptr @_ZTV1G, i32 0, i32 2, i32 6)), -// CHECK-SAME: ptr ptrauth (ptr @_ZN1E1gEv, i32 0, i64 22926, ptr getelementptr inbounds ({ [6 x ptr], [7 x ptr], [11 x ptr], [11 x ptr] }, ptr @_ZTV1G, i32 0, i32 2, i32 7)), -// CHECK-SAME: ptr ptrauth (ptr @_ZN1E1hEz, i32 0, i64 9832, ptr getelementptr inbounds ({ [6 x ptr], [7 x ptr], [11 x ptr], [11 x ptr] }, ptr @_ZTV1G, i32 0, i32 2, i32 8)), -// CHECK-SAME: ptr ptrauth (ptr @_ZTv0_n48_N1GD1Ev, i32 0, i64 5817, ptr getelementptr inbounds ({ [6 x ptr], [7 x ptr], [11 x ptr], [11 x ptr] }, ptr @_ZTV1G, i32 0, i32 2, i32 9)), -// CHECK-SAME: ptr ptrauth (ptr @_ZTv0_n48_N1GD0Ev, i32 0, i64 26464, ptr getelementptr inbounds ({ [6 x ptr], [7 x ptr], [11 x ptr], [11 x ptr] }, ptr @_ZTV1G, i32 0, i32 2, i32 10))], [11 x ptr] [ptr inttoptr (i64 -24 to ptr), ptr inttoptr (i64 -16 to ptr), ptr inttoptr (i64 -16 to ptr), ptr null, ptr inttoptr (i64 -24 to ptr), ptr @_ZTI1G, -// CHECK-SAME: ptr ptrauth (ptr @_ZN1A1fEv, i32 0, i64 55636, ptr getelementptr inbounds ({ [6 x ptr], [7 x ptr], [11 x ptr], [11 x ptr] }, ptr @_ZTV1G, i32 0, i32 3, i32 6)), -// CHECK-SAME: ptr ptrauth (ptr @_ZTv0_n32_N1D1gEv, i32 0, i64 19402, ptr getelementptr inbounds ({ [6 x ptr], [7 x ptr], [11 x ptr], [11 x ptr] }, ptr @_ZTV1G, i32 0, i32 3, i32 7)), -// CHECK-SAME: ptr ptrauth (ptr @_ZTv0_n40_N1D1hEz, i32 0, i64 31735, ptr getelementptr inbounds ({ [6 x ptr], [7 x ptr], [11 x ptr], [11 x ptr] }, ptr @_ZTV1G, i32 0, i32 3, i32 8)), -// CHECK-SAME: ptr ptrauth (ptr @_ZTv0_n48_N1GD1EvU11__vtptrauthILj0Lb0Lj62866E, i32 0, i64 2043, ptr getelementptr inbounds ({ [6 x ptr], [7 x ptr], [11 x ptr], [11 x ptr] }, ptr @_ZTV1G, i32 0, i32 3, i32 9)), -// CHECK-SAME: ptr ptrauth (ptr @_ZTv0_n48_N1GD0EvU11__vtptrauthILj0Lb0Lj62866E, i32 0, i64 63674, ptr getelementptr inbounds ({ [6 x ptr], [7 x ptr], [11 x ptr], [11 x ptr] }, ptr @_ZTV1G, i32 0, i32 3, i32 10))] }, align 8 - -// CHECK: @_ZTT1G = unnamed_addr constant [8 x ptr] [ptr ptrauth (ptr getelementptr inbounds inrange(-32, 16) ({ [6 x ptr], [7 x ptr], [11 x ptr], [11 x ptr] }, ptr @_ZTV1G, i32 0, i32 0, i32 4), i32 2), -// CHECK-SAME: ptr ptrauth (ptr getelementptr inbounds inrange(-24, 16) ({ [5 x ptr], [11 x ptr] }, ptr @_ZTC1G0_1C, i32 0, i32 0, i32 3), i32 2), -// CHECK-SAME: ptr ptrauth (ptr getelementptr inbounds inrange(-48, 40) ({ [5 x ptr], [11 x ptr] }, ptr @_ZTC1G0_1C, i32 0, i32 1, i32 6), i32 2), -// CHECK-SAME: ptr ptrauth (ptr getelementptr inbounds inrange(-24, 32) ({ [7 x ptr], [11 x ptr] }, ptr @_ZTC1G8_1D, i32 0, i32 0, i32 3), i32 2), -// CHECK-SAME: ptr ptrauth (ptr getelementptr inbounds inrange(-48, 40) ({ [7 x ptr], [11 x ptr] }, ptr @_ZTC1G8_1D, i32 0, i32 1, i32 6), i32 2), -// CHECK-SAME: ptr ptrauth (ptr getelementptr inbounds inrange(-48, 40) ({ [6 x ptr], [7 x ptr], [11 x ptr], [11 x ptr] }, ptr @_ZTV1G, i32 0, i32 2, i32 6), i32 2), -// CHECK-SAME: ptr ptrauth (ptr getelementptr inbounds inrange(-48, 40) ({ [6 x ptr], [7 x ptr], [11 x ptr], [11 x ptr] }, ptr @_ZTV1G, i32 0, i32 3, i32 6), i32 2), -// CHECK-SAME: ptr ptrauth (ptr getelementptr inbounds inrange(-24, 32) ({ [6 x ptr], [7 x ptr], [11 x ptr], [11 x ptr] }, ptr @_ZTV1G, i32 0, i32 1, i32 3), i32 2)], align 8 +// CHECK-SAME: ptr ptrauth (ptr @_ZN1GD1Ev, [i64 0, i64 31214, i64 ptrtoint (ptr getelementptr inbounds ({ [6 x ptr], [7 x ptr], [11 x ptr], [11 x ptr] }, ptr @_ZTV1G, i32 0, i32 0, i32 4) to i64)]), +// CHECK-SAME: ptr ptrauth (ptr @_ZN1GD0Ev, [i64 0, i64 8507, i64 ptrtoint (ptr getelementptr inbounds ({ [6 x ptr], [7 x ptr], [11 x ptr], [11 x ptr] }, ptr @_ZTV1G, i32 0, i32 0, i32 5) to i64)])], [7 x ptr] [ptr inttoptr (i64 16 to ptr), ptr inttoptr (i64 -8 to ptr), ptr @_ZTI1G, +// CHECK-SAME: ptr ptrauth (ptr @_ZThn8_N1GD1Ev, [i64 0, i64 59423, i64 ptrtoint (ptr getelementptr inbounds ({ [6 x ptr], [7 x ptr], [11 x ptr], [11 x ptr] }, ptr @_ZTV1G, i32 0, i32 1, i32 3) to i64)]), +// CHECK-SAME: ptr ptrauth (ptr @_ZThn8_N1GD0Ev, [i64 0, i64 25900, i64 ptrtoint (ptr getelementptr inbounds ({ [6 x ptr], [7 x ptr], [11 x ptr], [11 x ptr] }, ptr @_ZTV1G, i32 0, i32 1, i32 4) to i64)]), +// CHECK-SAME: ptr ptrauth (ptr @_ZN1D1gEv, [i64 0, i64 59070, i64 ptrtoint (ptr getelementptr inbounds ({ [6 x ptr], [7 x ptr], [11 x ptr], [11 x ptr] }, ptr @_ZTV1G, i32 0, i32 1, i32 5) to i64)]), +// CHECK-SAME: ptr ptrauth (ptr @_ZN1D1hEz, [i64 0, i64 65100, i64 ptrtoint (ptr getelementptr inbounds ({ [6 x ptr], [7 x ptr], [11 x ptr], [11 x ptr] }, ptr @_ZTV1G, i32 0, i32 1, i32 6) to i64)])], [11 x ptr] [ptr inttoptr (i64 -16 to ptr), ptr null, ptr null, ptr null, ptr inttoptr (i64 -16 to ptr), ptr @_ZTI1G, +// CHECK-SAME: ptr ptrauth (ptr @_ZN1E1fEv, [i64 0, i64 28408, i64 ptrtoint (ptr getelementptr inbounds ({ [6 x ptr], [7 x ptr], [11 x ptr], [11 x ptr] }, ptr @_ZTV1G, i32 0, i32 2, i32 6) to i64)]), +// CHECK-SAME: ptr ptrauth (ptr @_ZN1E1gEv, [i64 0, i64 22926, i64 ptrtoint (ptr getelementptr inbounds ({ [6 x ptr], [7 x ptr], [11 x ptr], [11 x ptr] }, ptr @_ZTV1G, i32 0, i32 2, i32 7) to i64)]), +// CHECK-SAME: ptr ptrauth (ptr @_ZN1E1hEz, [i64 0, i64 9832, i64 ptrtoint (ptr getelementptr inbounds ({ [6 x ptr], [7 x ptr], [11 x ptr], [11 x ptr] }, ptr @_ZTV1G, i32 0, i32 2, i32 8) to i64)]), +// CHECK-SAME: ptr ptrauth (ptr @_ZTv0_n48_N1GD1Ev, [i64 0, i64 5817, i64 ptrtoint (ptr getelementptr inbounds ({ [6 x ptr], [7 x ptr], [11 x ptr], [11 x ptr] }, ptr @_ZTV1G, i32 0, i32 2, i32 9) to i64)]), +// CHECK-SAME: ptr ptrauth (ptr @_ZTv0_n48_N1GD0Ev, [i64 0, i64 26464, i64 ptrtoint (ptr getelementptr inbounds ({ [6 x ptr], [7 x ptr], [11 x ptr], [11 x ptr] }, ptr @_ZTV1G, i32 0, i32 2, i32 10) to i64)])], [11 x ptr] [ptr inttoptr (i64 -24 to ptr), ptr inttoptr (i64 -16 to ptr), ptr inttoptr (i64 -16 to ptr), ptr null, ptr inttoptr (i64 -24 to ptr), ptr @_ZTI1G, +// CHECK-SAME: ptr ptrauth (ptr @_ZN1A1fEv, [i64 0, i64 55636, i64 ptrtoint (ptr getelementptr inbounds ({ [6 x ptr], [7 x ptr], [11 x ptr], [11 x ptr] }, ptr @_ZTV1G, i32 0, i32 3, i32 6) to i64)]), +// CHECK-SAME: ptr ptrauth (ptr @_ZTv0_n32_N1D1gEv, [i64 0, i64 19402, i64 ptrtoint (ptr getelementptr inbounds ({ [6 x ptr], [7 x ptr], [11 x ptr], [11 x ptr] }, ptr @_ZTV1G, i32 0, i32 3, i32 7) to i64)]), +// CHECK-SAME: ptr ptrauth (ptr @_ZTv0_n40_N1D1hEz, [i64 0, i64 31735, i64 ptrtoint (ptr getelementptr inbounds ({ [6 x ptr], [7 x ptr], [11 x ptr], [11 x ptr] }, ptr @_ZTV1G, i32 0, i32 3, i32 8) to i64)]), +// CHECK-SAME: ptr ptrauth (ptr @_ZTv0_n48_N1GD1EvU11__vtptrauthILj0Lb0Lj62866E, [i64 0, i64 2043, i64 ptrtoint (ptr getelementptr inbounds ({ [6 x ptr], [7 x ptr], [11 x ptr], [11 x ptr] }, ptr @_ZTV1G, i32 0, i32 3, i32 9) to i64)]), +// CHECK-SAME: ptr ptrauth (ptr @_ZTv0_n48_N1GD0EvU11__vtptrauthILj0Lb0Lj62866E, [i64 0, i64 63674, i64 ptrtoint (ptr getelementptr inbounds ({ [6 x ptr], [7 x ptr], [11 x ptr], [11 x ptr] }, ptr @_ZTV1G, i32 0, i32 3, i32 10) to i64)])] }, align 8 + +// CHECK: @_ZTT1G = unnamed_addr constant [8 x ptr] [ptr ptrauth (ptr getelementptr inbounds inrange(-32, 16) ({ [6 x ptr], [7 x ptr], [11 x ptr], [11 x ptr] }, ptr @_ZTV1G, i32 0, i32 0, i32 4), [i64 2, i64 0, i64 0]), +// CHECK-SAME: ptr ptrauth (ptr getelementptr inbounds inrange(-24, 16) ({ [5 x ptr], [11 x ptr] }, ptr @_ZTC1G0_1C, i32 0, i32 0, i32 3), [i64 2, i64 0, i64 0]), +// CHECK-SAME: ptr ptrauth (ptr getelementptr inbounds inrange(-48, 40) ({ [5 x ptr], [11 x ptr] }, ptr @_ZTC1G0_1C, i32 0, i32 1, i32 6), [i64 2, i64 0, i64 0]), +// CHECK-SAME: ptr ptrauth (ptr getelementptr inbounds inrange(-24, 32) ({ [7 x ptr], [11 x ptr] }, ptr @_ZTC1G8_1D, i32 0, i32 0, i32 3), [i64 2, i64 0, i64 0]), +// CHECK-SAME: ptr ptrauth (ptr getelementptr inbounds inrange(-48, 40) ({ [7 x ptr], [11 x ptr] }, ptr @_ZTC1G8_1D, i32 0, i32 1, i32 6), [i64 2, i64 0, i64 0]), +// CHECK-SAME: ptr ptrauth (ptr getelementptr inbounds inrange(-48, 40) ({ [6 x ptr], [7 x ptr], [11 x ptr], [11 x ptr] }, ptr @_ZTV1G, i32 0, i32 2, i32 6), [i64 2, i64 0, i64 0]), +// CHECK-SAME: ptr ptrauth (ptr getelementptr inbounds inrange(-48, 40) ({ [6 x ptr], [7 x ptr], [11 x ptr], [11 x ptr] }, ptr @_ZTV1G, i32 0, i32 3, i32 6), [i64 2, i64 0, i64 0]), +// CHECK-SAME: ptr ptrauth (ptr getelementptr inbounds inrange(-24, 32) ({ [6 x ptr], [7 x ptr], [11 x ptr], [11 x ptr] }, ptr @_ZTV1G, i32 0, i32 1, i32 3), [i64 2, i64 0, i64 0])], align 8 // CHECK: @_ZTV1A = unnamed_addr constant { [7 x ptr] } { [7 x ptr] [ptr null, ptr @_ZTI1A, -// CHECK-SAME: ptr ptrauth (ptr @_ZN1A1fEv, i32 0, i64 55636, ptr getelementptr inbounds ({ [7 x ptr] }, ptr @_ZTV1A, i32 0, i32 0, i32 2)), -// CHECK-SAME: ptr ptrauth (ptr @_ZN1A1gEv, i32 0, i64 19402, ptr getelementptr inbounds ({ [7 x ptr] }, ptr @_ZTV1A, i32 0, i32 0, i32 3)), -// CHECK-SAME: ptr ptrauth (ptr @_ZN1A1hEz, i32 0, i64 31735, ptr getelementptr inbounds ({ [7 x ptr] }, ptr @_ZTV1A, i32 0, i32 0, i32 4)), -// CHECK-SAME: ptr ptrauth (ptr @_ZN1AD1Ev, i32 0, i64 2043, ptr getelementptr inbounds ({ [7 x ptr] }, ptr @_ZTV1A, i32 0, i32 0, i32 5)), -// CHECK-SAME: ptr ptrauth (ptr @_ZN1AD0Ev, i32 0, i64 63674, ptr getelementptr inbounds ({ [7 x ptr] }, ptr @_ZTV1A, i32 0, i32 0, i32 6))] }, align 8 +// CHECK-SAME: ptr ptrauth (ptr @_ZN1A1fEv, [i64 0, i64 55636, i64 ptrtoint (ptr getelementptr inbounds ({ [7 x ptr] }, ptr @_ZTV1A, i32 0, i32 0, i32 2) to i64)]), +// CHECK-SAME: ptr ptrauth (ptr @_ZN1A1gEv, [i64 0, i64 19402, i64 ptrtoint (ptr getelementptr inbounds ({ [7 x ptr] }, ptr @_ZTV1A, i32 0, i32 0, i32 3) to i64)]), +// CHECK-SAME: ptr ptrauth (ptr @_ZN1A1hEz, [i64 0, i64 31735, i64 ptrtoint (ptr getelementptr inbounds ({ [7 x ptr] }, ptr @_ZTV1A, i32 0, i32 0, i32 4) to i64)]), +// CHECK-SAME: ptr ptrauth (ptr @_ZN1AD1Ev, [i64 0, i64 2043, i64 ptrtoint (ptr getelementptr inbounds ({ [7 x ptr] }, ptr @_ZTV1A, i32 0, i32 0, i32 5) to i64)]), +// CHECK-SAME: ptr ptrauth (ptr @_ZN1AD0Ev, [i64 0, i64 63674, i64 ptrtoint (ptr getelementptr inbounds ({ [7 x ptr] }, ptr @_ZTV1A, i32 0, i32 0, i32 6) to i64)])] }, align 8 -// CHECK: @_ZTI1A = constant { ptr, ptr } { ptr ptrauth (ptr getelementptr inbounds (ptr, ptr @_ZTVN10__cxxabiv117__class_type_infoE, i64 2), i32 2), ptr @_ZTS1A }, align 8 +// CHECK: @_ZTI1A = constant { ptr, ptr } { ptr ptrauth (ptr getelementptr inbounds (ptr, ptr @_ZTVN10__cxxabiv117__class_type_infoE, i64 2), [i64 2, i64 0, i64 0]), ptr @_ZTS1A }, align 8 // CHECK: @_ZTVN10__cxxabiv117__class_type_infoE = external global [0 x ptr] // CHECK: @_ZTS1A = constant [3 x i8] c"1A\00", align 1 -// CHECK: @_ZTI1C = constant { ptr, ptr, i32, i32, ptr, i64 } { ptr ptrauth (ptr getelementptr inbounds (ptr, ptr @_ZTVN10__cxxabiv121__vmi_class_type_infoE, i64 2), i32 2), ptr @_ZTS1C, i32 0, i32 1, ptr @_ZTI1B, i64 -6141 }, align 8 +// CHECK: @_ZTI1C = constant { ptr, ptr, i32, i32, ptr, i64 } { ptr ptrauth (ptr getelementptr inbounds (ptr, ptr @_ZTVN10__cxxabiv121__vmi_class_type_infoE, i64 2), [i64 2, i64 0, i64 0]), ptr @_ZTS1C, i32 0, i32 1, ptr @_ZTI1B, i64 -6141 }, align 8 // CHECK: @_ZTVN10__cxxabiv121__vmi_class_type_infoE = external global [0 x ptr] // CHECK: @_ZTS1C = constant [3 x i8] c"1C\00", align 1 -// DARWIN: @_ZTI1B = linkonce_odr hidden constant { ptr, ptr, ptr } { ptr ptrauth (ptr getelementptr inbounds (ptr, ptr @_ZTVN10__cxxabiv120__si_class_type_infoE, i64 2), i32 2), ptr inttoptr (i64 add (i64 ptrtoint (ptr @_ZTS1B to i64), i64 -9223372036854775808) to ptr), ptr @_ZTI1A }, align 8 -// ELF: @_ZTI1B = linkonce_odr constant { ptr, ptr, ptr } { ptr ptrauth (ptr getelementptr inbounds (ptr, ptr @_ZTVN10__cxxabiv120__si_class_type_infoE, i64 2), i32 2), ptr @_ZTS1B, ptr @_ZTI1A }, comdat, align 8 +// DARWIN: @_ZTI1B = linkonce_odr hidden constant { ptr, ptr, ptr } { ptr ptrauth (ptr getelementptr inbounds (ptr, ptr @_ZTVN10__cxxabiv120__si_class_type_infoE, i64 2), [i64 2, i64 0, i64 0]), ptr inttoptr (i64 add (i64 ptrtoint (ptr @_ZTS1B to i64), i64 -9223372036854775808) to ptr), ptr @_ZTI1A }, align 8 +// ELF: @_ZTI1B = linkonce_odr constant { ptr, ptr, ptr } { ptr ptrauth (ptr getelementptr inbounds (ptr, ptr @_ZTVN10__cxxabiv120__si_class_type_infoE, i64 2), [i64 2, i64 0, i64 0]), ptr @_ZTS1B, ptr @_ZTI1A }, comdat, align 8 // CHECK: @_ZTVN10__cxxabiv120__si_class_type_infoE = external global [0 x ptr] // DARWIN: @_ZTS1B = linkonce_odr hidden constant [3 x i8] c"1B\00", align 1 // ELF: @_ZTS1B = linkonce_odr constant [3 x i8] c"1B\00", comdat, align 1 -// CHECK: @_ZTI1D = constant { ptr, ptr, i32, i32, ptr, i64 } { ptr ptrauth (ptr getelementptr inbounds (ptr, ptr @_ZTVN10__cxxabiv121__vmi_class_type_infoE, i64 2), i32 2), ptr @_ZTS1D, i32 0, i32 1, ptr @_ZTI1B, i64 -6141 }, align 8 +// CHECK: @_ZTI1D = constant { ptr, ptr, i32, i32, ptr, i64 } { ptr ptrauth (ptr getelementptr inbounds (ptr, ptr @_ZTVN10__cxxabiv121__vmi_class_type_infoE, i64 2), [i64 2, i64 0, i64 0]), ptr @_ZTS1D, i32 0, i32 1, ptr @_ZTI1B, i64 -6141 }, align 8 // CHECK: @_ZTS1D = constant [3 x i8] c"1D\00", align 1 // CHECK: @_ZTV1E = unnamed_addr constant { [7 x ptr] } { [7 x ptr] [ptr null, ptr @_ZTI1E, -// CHECK-SAME: ptr ptrauth (ptr @_ZN1E1fEv, i32 0, i64 28408, ptr getelementptr inbounds ({ [7 x ptr] }, ptr @_ZTV1E, i32 0, i32 0, i32 2)), -// CHECK-SAME: ptr ptrauth (ptr @_ZN1E1gEv, i32 0, i64 22926, ptr getelementptr inbounds ({ [7 x ptr] }, ptr @_ZTV1E, i32 0, i32 0, i32 3)), -// CHECK-SAME: ptr ptrauth (ptr @_ZN1E1hEz, i32 0, i64 9832, ptr getelementptr inbounds ({ [7 x ptr] }, ptr @_ZTV1E, i32 0, i32 0, i32 4)), -// CHECK-SAME: ptr ptrauth (ptr @_ZN1ED1Ev, i32 0, i64 5817, ptr getelementptr inbounds ({ [7 x ptr] }, ptr @_ZTV1E, i32 0, i32 0, i32 5)), -// CHECK-SAME: ptr ptrauth (ptr @_ZN1ED0Ev, i32 0, i64 26464, ptr getelementptr inbounds ({ [7 x ptr] }, ptr @_ZTV1E, i32 0, i32 0, i32 6))] }, align 8 +// CHECK-SAME: ptr ptrauth (ptr @_ZN1E1fEv, [i64 0, i64 28408, i64 ptrtoint (ptr getelementptr inbounds ({ [7 x ptr] }, ptr @_ZTV1E, i32 0, i32 0, i32 2) to i64)]), +// CHECK-SAME: ptr ptrauth (ptr @_ZN1E1gEv, [i64 0, i64 22926, i64 ptrtoint (ptr getelementptr inbounds ({ [7 x ptr] }, ptr @_ZTV1E, i32 0, i32 0, i32 3) to i64)]), +// CHECK-SAME: ptr ptrauth (ptr @_ZN1E1hEz, [i64 0, i64 9832, i64 ptrtoint (ptr getelementptr inbounds ({ [7 x ptr] }, ptr @_ZTV1E, i32 0, i32 0, i32 4) to i64)]), +// CHECK-SAME: ptr ptrauth (ptr @_ZN1ED1Ev, [i64 0, i64 5817, i64 ptrtoint (ptr getelementptr inbounds ({ [7 x ptr] }, ptr @_ZTV1E, i32 0, i32 0, i32 5) to i64)]), +// CHECK-SAME: ptr ptrauth (ptr @_ZN1ED0Ev, [i64 0, i64 26464, i64 ptrtoint (ptr getelementptr inbounds ({ [7 x ptr] }, ptr @_ZTV1E, i32 0, i32 0, i32 6) to i64)])] }, align 8 -// CHECK: @_ZTI1E = constant { ptr, ptr } { ptr ptrauth (ptr getelementptr inbounds (ptr, ptr @_ZTVN10__cxxabiv117__class_type_infoE, i64 2), i32 2), ptr @_ZTS1E }, align 8 +// CHECK: @_ZTI1E = constant { ptr, ptr } { ptr ptrauth (ptr getelementptr inbounds (ptr, ptr @_ZTVN10__cxxabiv117__class_type_infoE, i64 2), [i64 2, i64 0, i64 0]), ptr @_ZTS1E }, align 8 // CHECK: @_ZTS1E = constant [3 x i8] c"1E\00", align 1 // CHECK: @_ZTC1F0_1C = unnamed_addr constant { [5 x ptr], [11 x ptr] } { [5 x ptr] [ptr inttoptr (i64 16 to ptr), ptr null, ptr @_ZTI1C, -// CHECK-SAME: ptr ptrauth (ptr @_ZN1CD1Ev, i32 0, i64 31214, ptr getelementptr inbounds ({ [5 x ptr], [11 x ptr] }, ptr @_ZTC1F0_1C, i32 0, i32 0, i32 3)), -// CHECK-SAME: ptr ptrauth (ptr @_ZN1CD0Ev, i32 0, i64 8507, ptr getelementptr inbounds ({ [5 x ptr], [11 x ptr] }, ptr @_ZTC1F0_1C, i32 0, i32 0, i32 4))], [11 x ptr] [ptr inttoptr (i64 -16 to ptr), ptr null, ptr null, ptr null, ptr inttoptr (i64 -16 to ptr), ptr @_ZTI1C, -// CHECK-SAME: ptr ptrauth (ptr @_ZN1A1fEv, i32 0, i64 55636, ptr getelementptr inbounds ({ [5 x ptr], [11 x ptr] }, ptr @_ZTC1F0_1C, i32 0, i32 1, i32 6)), -// CHECK-SAME: ptr ptrauth (ptr @_ZN1A1gEv, i32 0, i64 19402, ptr getelementptr inbounds ({ [5 x ptr], [11 x ptr] }, ptr @_ZTC1F0_1C, i32 0, i32 1, i32 7)), -// CHECK-SAME: ptr ptrauth (ptr @_ZN1A1hEz, i32 0, i64 31735, ptr getelementptr inbounds ({ [5 x ptr], [11 x ptr] }, ptr @_ZTC1F0_1C, i32 0, i32 1, i32 8)), -// CHECK-SAME: ptr ptrauth (ptr @_ZTv0_n48_N1CD1Ev, i32 0, i64 2043, ptr getelementptr inbounds ({ [5 x ptr], [11 x ptr] }, ptr @_ZTC1F0_1C, i32 0, i32 1, i32 9)), -// CHECK-SAME: ptr ptrauth (ptr @_ZTv0_n48_N1CD0Ev, i32 0, i64 63674, ptr getelementptr inbounds ({ [5 x ptr], [11 x ptr] }, ptr @_ZTC1F0_1C, i32 0, i32 1, i32 10))] }, align 8 +// CHECK-SAME: ptr ptrauth (ptr @_ZN1CD1Ev, [i64 0, i64 31214, i64 ptrtoint (ptr getelementptr inbounds ({ [5 x ptr], [11 x ptr] }, ptr @_ZTC1F0_1C, i32 0, i32 0, i32 3) to i64)]), +// CHECK-SAME: ptr ptrauth (ptr @_ZN1CD0Ev, [i64 0, i64 8507, i64 ptrtoint (ptr getelementptr inbounds ({ [5 x ptr], [11 x ptr] }, ptr @_ZTC1F0_1C, i32 0, i32 0, i32 4) to i64)])], [11 x ptr] [ptr inttoptr (i64 -16 to ptr), ptr null, ptr null, ptr null, ptr inttoptr (i64 -16 to ptr), ptr @_ZTI1C, +// CHECK-SAME: ptr ptrauth (ptr @_ZN1A1fEv, [i64 0, i64 55636, i64 ptrtoint (ptr getelementptr inbounds ({ [5 x ptr], [11 x ptr] }, ptr @_ZTC1F0_1C, i32 0, i32 1, i32 6) to i64)]), +// CHECK-SAME: ptr ptrauth (ptr @_ZN1A1gEv, [i64 0, i64 19402, i64 ptrtoint (ptr getelementptr inbounds ({ [5 x ptr], [11 x ptr] }, ptr @_ZTC1F0_1C, i32 0, i32 1, i32 7) to i64)]), +// CHECK-SAME: ptr ptrauth (ptr @_ZN1A1hEz, [i64 0, i64 31735, i64 ptrtoint (ptr getelementptr inbounds ({ [5 x ptr], [11 x ptr] }, ptr @_ZTC1F0_1C, i32 0, i32 1, i32 8) to i64)]), +// CHECK-SAME: ptr ptrauth (ptr @_ZTv0_n48_N1CD1Ev, [i64 0, i64 2043, i64 ptrtoint (ptr getelementptr inbounds ({ [5 x ptr], [11 x ptr] }, ptr @_ZTC1F0_1C, i32 0, i32 1, i32 9) to i64)]), +// CHECK-SAME: ptr ptrauth (ptr @_ZTv0_n48_N1CD0Ev, [i64 0, i64 63674, i64 ptrtoint (ptr getelementptr inbounds ({ [5 x ptr], [11 x ptr] }, ptr @_ZTC1F0_1C, i32 0, i32 1, i32 10) to i64)])] }, align 8 // CHECK: @_ZTC1F8_1D = unnamed_addr constant { [7 x ptr], [11 x ptr] } { [7 x ptr] [ptr inttoptr (i64 8 to ptr), ptr null, ptr @_ZTI1D, -// CHECK-SAME: ptr ptrauth (ptr @_ZN1DD1Ev, i32 0, i64 59423, ptr getelementptr inbounds ({ [7 x ptr], [11 x ptr] }, ptr @_ZTC1F8_1D, i32 0, i32 0, i32 3)), -// CHECK-SAME: ptr ptrauth (ptr @_ZN1DD0Ev, i32 0, i64 25900, ptr getelementptr inbounds ({ [7 x ptr], [11 x ptr] }, ptr @_ZTC1F8_1D, i32 0, i32 0, i32 4)), -// CHECK-SAME: ptr ptrauth (ptr @_ZN1D1gEv, i32 0, i64 59070, ptr getelementptr inbounds ({ [7 x ptr], [11 x ptr] }, ptr @_ZTC1F8_1D, i32 0, i32 0, i32 5)), -// CHECK-SAME: ptr ptrauth (ptr @_ZN1D1hEz, i32 0, i64 65100, ptr getelementptr inbounds ({ [7 x ptr], [11 x ptr] }, ptr @_ZTC1F8_1D, i32 0, i32 0, i32 6))], [11 x ptr] [ptr inttoptr (i64 -8 to ptr), ptr inttoptr (i64 -8 to ptr), ptr inttoptr (i64 -8 to ptr), ptr null, ptr inttoptr (i64 -8 to ptr), ptr @_ZTI1D, -// CHECK-SAME: ptr ptrauth (ptr @_ZN1A1fEv, i32 0, i64 55636, ptr getelementptr inbounds ({ [7 x ptr], [11 x ptr] }, ptr @_ZTC1F8_1D, i32 0, i32 1, i32 6)), -// CHECK-SAME: ptr ptrauth (ptr @_ZTv0_n32_N1D1gEv, i32 0, i64 19402, ptr getelementptr inbounds ({ [7 x ptr], [11 x ptr] }, ptr @_ZTC1F8_1D, i32 0, i32 1, i32 7)), -// CHECK-SAME: ptr ptrauth (ptr @_ZTv0_n40_N1D1hEz, i32 0, i64 31735, ptr getelementptr inbounds ({ [7 x ptr], [11 x ptr] }, ptr @_ZTC1F8_1D, i32 0, i32 1, i32 8)), -// CHECK-SAME: ptr ptrauth (ptr @_ZTv0_n48_N1DD1Ev, i32 0, i64 2043, ptr getelementptr inbounds ({ [7 x ptr], [11 x ptr] }, ptr @_ZTC1F8_1D, i32 0, i32 1, i32 9)), -// CHECK-SAME: ptr ptrauth (ptr @_ZTv0_n48_N1DD0Ev, i32 0, i64 63674, ptr getelementptr inbounds ({ [7 x ptr], [11 x ptr] }, ptr @_ZTC1F8_1D, i32 0, i32 1, i32 10))] }, align 8 - -// CHECK: @_ZTI1F = constant { ptr, ptr, i32, i32, ptr, i64, ptr, i64, ptr, i64 } { ptr ptrauth (ptr getelementptr inbounds (ptr, ptr @_ZTVN10__cxxabiv121__vmi_class_type_infoE, i64 2), i32 2), ptr @_ZTS1F, i32 3, i32 3, ptr @_ZTI1C, i64 2, ptr @_ZTI1D, i64 2050, ptr @_ZTI1E, i64 -8189 }, align 8 +// CHECK-SAME: ptr ptrauth (ptr @_ZN1DD1Ev, [i64 0, i64 59423, i64 ptrtoint (ptr getelementptr inbounds ({ [7 x ptr], [11 x ptr] }, ptr @_ZTC1F8_1D, i32 0, i32 0, i32 3) to i64)]), +// CHECK-SAME: ptr ptrauth (ptr @_ZN1DD0Ev, [i64 0, i64 25900, i64 ptrtoint (ptr getelementptr inbounds ({ [7 x ptr], [11 x ptr] }, ptr @_ZTC1F8_1D, i32 0, i32 0, i32 4) to i64)]), +// CHECK-SAME: ptr ptrauth (ptr @_ZN1D1gEv, [i64 0, i64 59070, i64 ptrtoint (ptr getelementptr inbounds ({ [7 x ptr], [11 x ptr] }, ptr @_ZTC1F8_1D, i32 0, i32 0, i32 5) to i64)]), +// CHECK-SAME: ptr ptrauth (ptr @_ZN1D1hEz, [i64 0, i64 65100, i64 ptrtoint (ptr getelementptr inbounds ({ [7 x ptr], [11 x ptr] }, ptr @_ZTC1F8_1D, i32 0, i32 0, i32 6) to i64)])], [11 x ptr] [ptr inttoptr (i64 -8 to ptr), ptr inttoptr (i64 -8 to ptr), ptr inttoptr (i64 -8 to ptr), ptr null, ptr inttoptr (i64 -8 to ptr), ptr @_ZTI1D, +// CHECK-SAME: ptr ptrauth (ptr @_ZN1A1fEv, [i64 0, i64 55636, i64 ptrtoint (ptr getelementptr inbounds ({ [7 x ptr], [11 x ptr] }, ptr @_ZTC1F8_1D, i32 0, i32 1, i32 6) to i64)]), +// CHECK-SAME: ptr ptrauth (ptr @_ZTv0_n32_N1D1gEv, [i64 0, i64 19402, i64 ptrtoint (ptr getelementptr inbounds ({ [7 x ptr], [11 x ptr] }, ptr @_ZTC1F8_1D, i32 0, i32 1, i32 7) to i64)]), +// CHECK-SAME: ptr ptrauth (ptr @_ZTv0_n40_N1D1hEz, [i64 0, i64 31735, i64 ptrtoint (ptr getelementptr inbounds ({ [7 x ptr], [11 x ptr] }, ptr @_ZTC1F8_1D, i32 0, i32 1, i32 8) to i64)]), +// CHECK-SAME: ptr ptrauth (ptr @_ZTv0_n48_N1DD1Ev, [i64 0, i64 2043, i64 ptrtoint (ptr getelementptr inbounds ({ [7 x ptr], [11 x ptr] }, ptr @_ZTC1F8_1D, i32 0, i32 1, i32 9) to i64)]), +// CHECK-SAME: ptr ptrauth (ptr @_ZTv0_n48_N1DD0Ev, [i64 0, i64 63674, i64 ptrtoint (ptr getelementptr inbounds ({ [7 x ptr], [11 x ptr] }, ptr @_ZTC1F8_1D, i32 0, i32 1, i32 10) to i64)])] }, align 8 + +// CHECK: @_ZTI1F = constant { ptr, ptr, i32, i32, ptr, i64, ptr, i64, ptr, i64 } { ptr ptrauth (ptr getelementptr inbounds (ptr, ptr @_ZTVN10__cxxabiv121__vmi_class_type_infoE, i64 2), [i64 2, i64 0, i64 0]), ptr @_ZTS1F, i32 3, i32 3, ptr @_ZTI1C, i64 2, ptr @_ZTI1D, i64 2050, ptr @_ZTI1E, i64 -8189 }, align 8 // CHECK: @_ZTS1F = constant [3 x i8] c"1F\00", align 1 // CHECK: @_ZTC1G0_1C = unnamed_addr constant { [5 x ptr], [11 x ptr] } { [5 x ptr] [ptr inttoptr (i64 24 to ptr), ptr null, ptr @_ZTI1C, -// CHECK-SAME: ptr ptrauth (ptr @_ZN1CD1Ev, i32 0, i64 31214, ptr getelementptr inbounds ({ [5 x ptr], [11 x ptr] }, ptr @_ZTC1G0_1C, i32 0, i32 0, i32 3)), -// CHECK-SAME: ptr ptrauth (ptr @_ZN1CD0Ev, i32 0, i64 8507, ptr getelementptr inbounds ({ [5 x ptr], [11 x ptr] }, ptr @_ZTC1G0_1C, i32 0, i32 0, i32 4))], [11 x ptr] [ptr inttoptr (i64 -24 to ptr), ptr null, ptr null, ptr null, ptr inttoptr (i64 -24 to ptr), ptr @_ZTI1C, -// CHECK-SAME: ptr ptrauth (ptr @_ZN1A1fEv, i32 0, i64 55636, ptr getelementptr inbounds ({ [5 x ptr], [11 x ptr] }, ptr @_ZTC1G0_1C, i32 0, i32 1, i32 6)), -// CHECK-SAME: ptr ptrauth (ptr @_ZN1A1gEv, i32 0, i64 19402, ptr getelementptr inbounds ({ [5 x ptr], [11 x ptr] }, ptr @_ZTC1G0_1C, i32 0, i32 1, i32 7)), -// CHECK-SAME: ptr ptrauth (ptr @_ZN1A1hEz, i32 0, i64 31735, ptr getelementptr inbounds ({ [5 x ptr], [11 x ptr] }, ptr @_ZTC1G0_1C, i32 0, i32 1, i32 8)), -// CHECK-SAME: ptr ptrauth (ptr @_ZTv0_n48_N1CD1Ev, i32 0, i64 2043, ptr getelementptr inbounds ({ [5 x ptr], [11 x ptr] }, ptr @_ZTC1G0_1C, i32 0, i32 1, i32 9)), -// CHECK-SAME: ptr ptrauth (ptr @_ZTv0_n48_N1CD0Ev, i32 0, i64 63674, ptr getelementptr inbounds ({ [5 x ptr], [11 x ptr] }, ptr @_ZTC1G0_1C, i32 0, i32 1, i32 10))] }, align 8 +// CHECK-SAME: ptr ptrauth (ptr @_ZN1CD1Ev, [i64 0, i64 31214, i64 ptrtoint (ptr getelementptr inbounds ({ [5 x ptr], [11 x ptr] }, ptr @_ZTC1G0_1C, i32 0, i32 0, i32 3) to i64)]), +// CHECK-SAME: ptr ptrauth (ptr @_ZN1CD0Ev, [i64 0, i64 8507, i64 ptrtoint (ptr getelementptr inbounds ({ [5 x ptr], [11 x ptr] }, ptr @_ZTC1G0_1C, i32 0, i32 0, i32 4) to i64)])], [11 x ptr] [ptr inttoptr (i64 -24 to ptr), ptr null, ptr null, ptr null, ptr inttoptr (i64 -24 to ptr), ptr @_ZTI1C, +// CHECK-SAME: ptr ptrauth (ptr @_ZN1A1fEv, [i64 0, i64 55636, i64 ptrtoint (ptr getelementptr inbounds ({ [5 x ptr], [11 x ptr] }, ptr @_ZTC1G0_1C, i32 0, i32 1, i32 6) to i64)]), +// CHECK-SAME: ptr ptrauth (ptr @_ZN1A1gEv, [i64 0, i64 19402, i64 ptrtoint (ptr getelementptr inbounds ({ [5 x ptr], [11 x ptr] }, ptr @_ZTC1G0_1C, i32 0, i32 1, i32 7) to i64)]), +// CHECK-SAME: ptr ptrauth (ptr @_ZN1A1hEz, [i64 0, i64 31735, i64 ptrtoint (ptr getelementptr inbounds ({ [5 x ptr], [11 x ptr] }, ptr @_ZTC1G0_1C, i32 0, i32 1, i32 8) to i64)]), +// CHECK-SAME: ptr ptrauth (ptr @_ZTv0_n48_N1CD1Ev, [i64 0, i64 2043, i64 ptrtoint (ptr getelementptr inbounds ({ [5 x ptr], [11 x ptr] }, ptr @_ZTC1G0_1C, i32 0, i32 1, i32 9) to i64)]), +// CHECK-SAME: ptr ptrauth (ptr @_ZTv0_n48_N1CD0Ev, [i64 0, i64 63674, i64 ptrtoint (ptr getelementptr inbounds ({ [5 x ptr], [11 x ptr] }, ptr @_ZTC1G0_1C, i32 0, i32 1, i32 10) to i64)])] }, align 8 // CHECK: @_ZTC1G8_1D = unnamed_addr constant { [7 x ptr], [11 x ptr] } { [7 x ptr] [ptr inttoptr (i64 16 to ptr), ptr null, ptr @_ZTI1D, -// CHECK-SAME: ptr ptrauth (ptr @_ZN1DD1Ev, i32 0, i64 59423, ptr getelementptr inbounds ({ [7 x ptr], [11 x ptr] }, ptr @_ZTC1G8_1D, i32 0, i32 0, i32 3)), -// CHECK-SAME: ptr ptrauth (ptr @_ZN1DD0Ev, i32 0, i64 25900, ptr getelementptr inbounds ({ [7 x ptr], [11 x ptr] }, ptr @_ZTC1G8_1D, i32 0, i32 0, i32 4)), -// CHECK-SAME: ptr ptrauth (ptr @_ZN1D1gEv, i32 0, i64 59070, ptr getelementptr inbounds ({ [7 x ptr], [11 x ptr] }, ptr @_ZTC1G8_1D, i32 0, i32 0, i32 5)), -// CHECK-SAME: ptr ptrauth (ptr @_ZN1D1hEz, i32 0, i64 65100, ptr getelementptr inbounds ({ [7 x ptr], [11 x ptr] }, ptr @_ZTC1G8_1D, i32 0, i32 0, i32 6))], [11 x ptr] [ptr inttoptr (i64 -16 to ptr), ptr inttoptr (i64 -16 to ptr), ptr inttoptr (i64 -16 to ptr), ptr null, ptr inttoptr (i64 -16 to ptr), ptr @_ZTI1D, -// CHECK-SAME: ptr ptrauth (ptr @_ZN1A1fEv, i32 0, i64 55636, ptr getelementptr inbounds ({ [7 x ptr], [11 x ptr] }, ptr @_ZTC1G8_1D, i32 0, i32 1, i32 6)), -// CHECK-SAME: ptr ptrauth (ptr @_ZTv0_n32_N1D1gEv, i32 0, i64 19402, ptr getelementptr inbounds ({ [7 x ptr], [11 x ptr] }, ptr @_ZTC1G8_1D, i32 0, i32 1, i32 7)), -// CHECK-SAME: ptr ptrauth (ptr @_ZTv0_n40_N1D1hEz, i32 0, i64 31735, ptr getelementptr inbounds ({ [7 x ptr], [11 x ptr] }, ptr @_ZTC1G8_1D, i32 0, i32 1, i32 8)), -// CHECK-SAME: ptr ptrauth (ptr @_ZTv0_n48_N1DD1Ev, i32 0, i64 2043, ptr getelementptr inbounds ({ [7 x ptr], [11 x ptr] }, ptr @_ZTC1G8_1D, i32 0, i32 1, i32 9)), -// CHECK-SAME: ptr ptrauth (ptr @_ZTv0_n48_N1DD0Ev, i32 0, i64 63674, ptr getelementptr inbounds ({ [7 x ptr], [11 x ptr] }, ptr @_ZTC1G8_1D, i32 0, i32 1, i32 10))] }, align 8 - -// CHECK: @_ZTI1G = constant { ptr, ptr, i32, i32, ptr, i64, ptr, i64, ptr, i64 } { ptr ptrauth (ptr getelementptr inbounds (ptr, ptr @_ZTVN10__cxxabiv121__vmi_class_type_infoE, i64 2), i32 2), ptr @_ZTS1G, i32 3, i32 3, ptr @_ZTI1E, i64 -8189, ptr @_ZTI1C, i64 2, ptr @_ZTI1D, i64 2050 }, align 8 +// CHECK-SAME: ptr ptrauth (ptr @_ZN1DD1Ev, [i64 0, i64 59423, i64 ptrtoint (ptr getelementptr inbounds ({ [7 x ptr], [11 x ptr] }, ptr @_ZTC1G8_1D, i32 0, i32 0, i32 3) to i64)]), +// CHECK-SAME: ptr ptrauth (ptr @_ZN1DD0Ev, [i64 0, i64 25900, i64 ptrtoint (ptr getelementptr inbounds ({ [7 x ptr], [11 x ptr] }, ptr @_ZTC1G8_1D, i32 0, i32 0, i32 4) to i64)]), +// CHECK-SAME: ptr ptrauth (ptr @_ZN1D1gEv, [i64 0, i64 59070, i64 ptrtoint (ptr getelementptr inbounds ({ [7 x ptr], [11 x ptr] }, ptr @_ZTC1G8_1D, i32 0, i32 0, i32 5) to i64)]), +// CHECK-SAME: ptr ptrauth (ptr @_ZN1D1hEz, [i64 0, i64 65100, i64 ptrtoint (ptr getelementptr inbounds ({ [7 x ptr], [11 x ptr] }, ptr @_ZTC1G8_1D, i32 0, i32 0, i32 6) to i64)])], [11 x ptr] [ptr inttoptr (i64 -16 to ptr), ptr inttoptr (i64 -16 to ptr), ptr inttoptr (i64 -16 to ptr), ptr null, ptr inttoptr (i64 -16 to ptr), ptr @_ZTI1D, +// CHECK-SAME: ptr ptrauth (ptr @_ZN1A1fEv, [i64 0, i64 55636, i64 ptrtoint (ptr getelementptr inbounds ({ [7 x ptr], [11 x ptr] }, ptr @_ZTC1G8_1D, i32 0, i32 1, i32 6) to i64)]), +// CHECK-SAME: ptr ptrauth (ptr @_ZTv0_n32_N1D1gEv, [i64 0, i64 19402, i64 ptrtoint (ptr getelementptr inbounds ({ [7 x ptr], [11 x ptr] }, ptr @_ZTC1G8_1D, i32 0, i32 1, i32 7) to i64)]), +// CHECK-SAME: ptr ptrauth (ptr @_ZTv0_n40_N1D1hEz, [i64 0, i64 31735, i64 ptrtoint (ptr getelementptr inbounds ({ [7 x ptr], [11 x ptr] }, ptr @_ZTC1G8_1D, i32 0, i32 1, i32 8) to i64)]), +// CHECK-SAME: ptr ptrauth (ptr @_ZTv0_n48_N1DD1Ev, [i64 0, i64 2043, i64 ptrtoint (ptr getelementptr inbounds ({ [7 x ptr], [11 x ptr] }, ptr @_ZTC1G8_1D, i32 0, i32 1, i32 9) to i64)]), +// CHECK-SAME: ptr ptrauth (ptr @_ZTv0_n48_N1DD0Ev, [i64 0, i64 63674, i64 ptrtoint (ptr getelementptr inbounds ({ [7 x ptr], [11 x ptr] }, ptr @_ZTC1G8_1D, i32 0, i32 1, i32 10) to i64)])] }, align 8 + +// CHECK: @_ZTI1G = constant { ptr, ptr, i32, i32, ptr, i64, ptr, i64, ptr, i64 } { ptr ptrauth (ptr getelementptr inbounds (ptr, ptr @_ZTVN10__cxxabiv121__vmi_class_type_infoE, i64 2), [i64 2, i64 0, i64 0]), ptr @_ZTS1G, i32 3, i32 3, ptr @_ZTI1E, i64 -8189, ptr @_ZTI1C, i64 2, ptr @_ZTI1D, i64 2050 }, align 8 // CHECK: @_ZTS1G = constant [3 x i8] c"1G\00", align 1 // CHECK: @_ZTV1B = linkonce_odr unnamed_addr constant { [7 x ptr] } { [7 x ptr] [ptr null, ptr @_ZTI1B, -// CHECK-SAME: ptr ptrauth (ptr @_ZN1A1fEv, i32 0, i64 55636, ptr getelementptr inbounds ({ [7 x ptr] }, ptr @_ZTV1B, i32 0, i32 0, i32 2)), -// CHECK-SAME: ptr ptrauth (ptr @_ZN1A1gEv, i32 0, i64 19402, ptr getelementptr inbounds ({ [7 x ptr] }, ptr @_ZTV1B, i32 0, i32 0, i32 3)), -// CHECK-SAME: ptr ptrauth (ptr @_ZN1A1hEz, i32 0, i64 31735, ptr getelementptr inbounds ({ [7 x ptr] }, ptr @_ZTV1B, i32 0, i32 0, i32 4)), -// CHECK-SAME: ptr ptrauth (ptr @_ZN1BD1Ev, i32 0, i64 2043, ptr getelementptr inbounds ({ [7 x ptr] }, ptr @_ZTV1B, i32 0, i32 0, i32 5)), -// DARWIN-SAME: ptr ptrauth (ptr @_ZN1BD0Ev, i32 0, i64 63674, ptr getelementptr inbounds ({ [7 x ptr] }, ptr @_ZTV1B, i32 0, i32 0, i32 6))] }, align 8 -// ELF-SAME: ptr ptrauth (ptr @_ZN1BD0Ev, i32 0, i64 63674, ptr getelementptr inbounds ({ [7 x ptr] }, ptr @_ZTV1B, i32 0, i32 0, i32 6))] }, comdat, align 8 +// CHECK-SAME: ptr ptrauth (ptr @_ZN1A1fEv, [i64 0, i64 55636, i64 ptrtoint (ptr getelementptr inbounds ({ [7 x ptr] }, ptr @_ZTV1B, i32 0, i32 0, i32 2) to i64)]), +// CHECK-SAME: ptr ptrauth (ptr @_ZN1A1gEv, [i64 0, i64 19402, i64 ptrtoint (ptr getelementptr inbounds ({ [7 x ptr] }, ptr @_ZTV1B, i32 0, i32 0, i32 3) to i64)]), +// CHECK-SAME: ptr ptrauth (ptr @_ZN1A1hEz, [i64 0, i64 31735, i64 ptrtoint (ptr getelementptr inbounds ({ [7 x ptr] }, ptr @_ZTV1B, i32 0, i32 0, i32 4) to i64)]), +// CHECK-SAME: ptr ptrauth (ptr @_ZN1BD1Ev, [i64 0, i64 2043, i64 ptrtoint (ptr getelementptr inbounds ({ [7 x ptr] }, ptr @_ZTV1B, i32 0, i32 0, i32 5) to i64)]), +// DARWIN-SAME: ptr ptrauth (ptr @_ZN1BD0Ev, [i64 0, i64 63674, i64 ptrtoint (ptr getelementptr inbounds ({ [7 x ptr] }, ptr @_ZTV1B, i32 0, i32 0, i32 6) to i64)])] }, align 8 +// ELF-SAME: ptr ptrauth (ptr @_ZN1BD0Ev, [i64 0, i64 63674, i64 ptrtoint (ptr getelementptr inbounds ({ [7 x ptr] }, ptr @_ZTV1B, i32 0, i32 0, i32 6) to i64)])] }, comdat, align 8 extern "C" int printf(const char *format, ...); diff --git a/clang/test/CodeGenCXX/ptrauth.cpp b/clang/test/CodeGenCXX/ptrauth.cpp index 832b305b3e3bf..3e1507944b25e 100644 --- a/clang/test/CodeGenCXX/ptrauth.cpp +++ b/clang/test/CodeGenCXX/ptrauth.cpp @@ -5,7 +5,7 @@ void f(void); auto &f_ref = f; // CHECK: define {{(dso_local )?}}void @_Z1gv( -// CHECK: call void ptrauth (ptr @_Z1fv, i32 0)() [ "ptrauth"(i64 0, i64 0, i64 0) ] +// CHECK: call void ptrauth (ptr @_Z1fv, [i64 0, i64 0, i64 0])() [ "ptrauth"(i64 0, i64 0, i64 0) ] void g() { f_ref(); } diff --git a/clang/test/CodeGenObjC/ptrauth-attr-exception.m b/clang/test/CodeGenObjC/ptrauth-attr-exception.m index 8c07a698ecc70..289d13ab2c0b1 100644 --- a/clang/test/CodeGenObjC/ptrauth-attr-exception.m +++ b/clang/test/CodeGenObjC/ptrauth-attr-exception.m @@ -13,5 +13,5 @@ @interface A : Root @implementation A @end -// CHECK: @"OBJC_EHTYPE_$_A" = global %struct._objc_typeinfo { ptr ptrauth (ptr getelementptr inbounds (ptr, ptr @objc_ehtype_vtable, i32 2), i32 2), ptr @OBJC_CLASS_NAME_, ptr @"OBJC_CLASS_$_A" } +// CHECK: @"OBJC_EHTYPE_$_A" = global %struct._objc_typeinfo { ptr ptrauth (ptr getelementptr inbounds (ptr, ptr @objc_ehtype_vtable, i32 2), [i64 2, i64 0, i64 0]), ptr @OBJC_CLASS_NAME_, ptr @"OBJC_CLASS_$_A" } //. @"OBJC_EHTYPE_$_A" = global %struct._objc_typeinfo { ptr getelementptr inbounds (ptr, ptr @objc_ehtype_vtable, i32 2), ptr @OBJC_CLASS_NAME_, ptr @"OBJC_CLASS_$_A" } diff --git a/clang/test/CodeGenObjC/ptrauth-block-descriptor-pointer.m b/clang/test/CodeGenObjC/ptrauth-block-descriptor-pointer.m index a74c84180db1f..58090ce19ffed 100644 --- a/clang/test/CodeGenObjC/ptrauth-block-descriptor-pointer.m +++ b/clang/test/CodeGenObjC/ptrauth-block-descriptor-pointer.m @@ -13,10 +13,10 @@ void a() { } // CHECK: [[BLOCK_DESCRIPTOR_NAME:@"__block_descriptor_.*"]] = linkonce_odr hidden unnamed_addr constant { i64, i64, ptr, ptr } { i64 0, i64 32, ptr @.str, ptr null } -// CHECK: @__block_literal_global = internal constant { ptr, i32, i32, ptr, ptr } { ptr @_NSConcreteGlobalBlock, i32 1342177280, i32 0, ptr ptrauth (ptr @__a_block_invoke, i32 0, i64 0, ptr getelementptr inbounds ({ ptr, i32, i32, ptr, ptr }, ptr @__block_literal_global, i32 0, i32 3)), ptr ptrauth (ptr [[BLOCK_DESCRIPTOR_NAME]], i32 2, i64 49339, ptr getelementptr inbounds ({ ptr, i32, i32, ptr, ptr }, ptr @__block_literal_global, i32 0, i32 4)) } +// CHECK: @__block_literal_global = internal constant { ptr, i32, i32, ptr, ptr } { ptr @_NSConcreteGlobalBlock, i32 1342177280, i32 0, ptr ptrauth (ptr @__a_block_invoke, [i64 0, i64 0, i64 ptrtoint (ptr getelementptr inbounds ({ ptr, i32, i32, ptr, ptr }, ptr @__block_literal_global, i32 0, i32 3) to i64)]), ptr ptrauth (ptr [[BLOCK_DESCRIPTOR_NAME]], [i64 2, i64 49339, i64 ptrtoint (ptr getelementptr inbounds ({ ptr, i32, i32, ptr, ptr }, ptr @__block_literal_global, i32 0, i32 4) to i64)]) } // NODESCRIPTORAUTH: [[BLOCK_DESCRIPTOR_NAME:@"__block_descriptor_.*"]] = linkonce_odr hidden unnamed_addr constant { i64, i64, ptr, ptr } { i64 0, i64 32, ptr @.str, ptr null } -// NODESCRIPTORAUTH: @__block_literal_global = internal constant { ptr, i32, i32, ptr, ptr } { ptr @_NSConcreteGlobalBlock, i32 1342177280, i32 0, ptr ptrauth (ptr @__a_block_invoke, i32 0, i64 0, ptr getelementptr inbounds ({ ptr, i32, i32, ptr, ptr }, ptr @__block_literal_global, i32 0, i32 3)), ptr [[BLOCK_DESCRIPTOR_NAME]] } +// NODESCRIPTORAUTH: @__block_literal_global = internal constant { ptr, i32, i32, ptr, ptr } { ptr @_NSConcreteGlobalBlock, i32 1342177280, i32 0, ptr ptrauth (ptr @__a_block_invoke, [i64 0, i64 0, i64 ptrtoint (ptr getelementptr inbounds ({ ptr, i32, i32, ptr, ptr }, ptr @__block_literal_global, i32 0, i32 3) to i64)]), ptr [[BLOCK_DESCRIPTOR_NAME]] } void b(int p) { diff --git a/clang/test/CodeGenObjC/ptrauth-block-isa.m b/clang/test/CodeGenObjC/ptrauth-block-isa.m index f759c0d811c07..638a7bdf79f35 100644 --- a/clang/test/CodeGenObjC/ptrauth-block-isa.m +++ b/clang/test/CodeGenObjC/ptrauth-block-isa.m @@ -2,7 +2,7 @@ void (^globalblock)(void) = ^{}; // CHECK: [[BLOCK_DESCRIPTOR_NAME:@"__block_descriptor_.*"]] = linkonce_odr hidden unnamed_addr constant { i64, i64, ptr, ptr } { i64 0, i64 32, ptr @.str, ptr null }, comdat, align 8 -// CHECK: @__block_literal_global = internal constant { ptr, i32, i32, ptr, ptr } { ptr ptrauth (ptr @_NSConcreteGlobalBlock, i32 2, i64 27361, ptr @__block_literal_global), i32 1342177280, i32 0, ptr ptrauth (ptr @globalblock_block_invoke, i32 0, i64 0, ptr getelementptr inbounds ({ ptr, i32, i32, ptr, ptr }, ptr @__block_literal_global, i32 0, i32 3)), ptr [[BLOCK_DESCRIPTOR_NAME]] } +// CHECK: @__block_literal_global = internal constant { ptr, i32, i32, ptr, ptr } { ptr ptrauth (ptr @_NSConcreteGlobalBlock, [i64 2, i64 27361, i64 ptrtoint (ptr @__block_literal_global to i64)]), i32 1342177280, i32 0, ptr ptrauth (ptr @globalblock_block_invoke, [i64 0, i64 0, i64 ptrtoint (ptr getelementptr inbounds ({ ptr, i32, i32, ptr, ptr }, ptr @__block_literal_global, i32 0, i32 3) to i64)]), ptr [[BLOCK_DESCRIPTOR_NAME]] } @interface A - (int) count; diff --git a/clang/test/CodeGenObjC/ptrauth-class-ro.m b/clang/test/CodeGenObjC/ptrauth-class-ro.m index a80b3d34bf9f4..2e1157ca52ba8 100644 --- a/clang/test/CodeGenObjC/ptrauth-class-ro.m +++ b/clang/test/CodeGenObjC/ptrauth-class-ro.m @@ -1,13 +1,13 @@ // RUN: %clang_cc1 -triple arm64-apple-ios -fptrauth-calls -Wno-objc-root-class -fptrauth-objc-class-ro -fobjc-arc -emit-llvm -o - %s | FileCheck %s -// CHECK: @"OBJC_CLASS_$_C" = global %struct._class_t { ptr @"OBJC_METACLASS_$_C", ptr null, ptr @_objc_empty_cache, ptr null, ptr ptrauth (ptr @"_OBJC_CLASS_RO_$_C", i32 2, i64 25080, ptr getelementptr inbounds (%struct._class_t, ptr @"OBJC_CLASS_$_C", i32 0, i32 4)) }, section "__DATA, __objc_data", align 8 -// CHECK: @"OBJC_METACLASS_$_C" = global %struct._class_t { ptr @"OBJC_METACLASS_$_C", ptr @"OBJC_CLASS_$_C", ptr @_objc_empty_cache, ptr null, ptr ptrauth (ptr @"_OBJC_METACLASS_RO_$_C", i32 2, i64 25080, ptr getelementptr inbounds (%struct._class_t, ptr @"OBJC_METACLASS_$_C", i32 0, i32 4)) }, section "__DATA, __objc_data", align 8 +// CHECK: @"OBJC_CLASS_$_C" = global %struct._class_t { ptr @"OBJC_METACLASS_$_C", ptr null, ptr @_objc_empty_cache, ptr null, ptr ptrauth (ptr @"_OBJC_CLASS_RO_$_C", [i64 2, i64 25080, i64 ptrtoint (ptr getelementptr inbounds (%struct._class_t, ptr @"OBJC_CLASS_$_C", i32 0, i32 4) to i64)]) }, section "__DATA, __objc_data", align 8 +// CHECK: @"OBJC_METACLASS_$_C" = global %struct._class_t { ptr @"OBJC_METACLASS_$_C", ptr @"OBJC_CLASS_$_C", ptr @_objc_empty_cache, ptr null, ptr ptrauth (ptr @"_OBJC_METACLASS_RO_$_C", [i64 2, i64 25080, i64 ptrtoint (ptr getelementptr inbounds (%struct._class_t, ptr @"OBJC_METACLASS_$_C", i32 0, i32 4) to i64)]) }, section "__DATA, __objc_data", align 8 // CHECK: @OBJC_CLASS_NAME_ = private unnamed_addr constant [2 x i8] c"C\00", section "__TEXT,__objc_classname,cstring_literals", align 1 // CHECK: @"_OBJC_METACLASS_RO_$_C" = internal global %struct._class_ro_t { i32 131, i32 40, i32 40, ptr null, ptr @OBJC_CLASS_NAME_, ptr null, ptr null, ptr null, ptr null, ptr null }, section "__DATA, __objc_const", align 8 // CHECK: @OBJC_METH_VAR_NAME_ = private unnamed_addr constant [3 x i8] c"m0\00", section "__TEXT,__objc_methname,cstring_literals", align 1 // CHECK: @OBJC_METH_VAR_TYPE_ = private unnamed_addr constant [8 x i8] c"v16@0:8\00", section "__TEXT,__objc_methtype,cstring_literals", align 1 -// CHECK: @"_OBJC_$_INSTANCE_METHODS_C" = internal global { i32, i32, [1 x %struct._objc_method] } { i32 24, i32 1, [1 x %struct._objc_method] [%struct._objc_method { ptr @OBJC_METH_VAR_NAME_, ptr @OBJC_METH_VAR_TYPE_, ptr ptrauth (ptr @"\01-[C m0]", i32 0, i64 0, ptr getelementptr inbounds ({ i32, i32, [1 x %struct._objc_method] }, ptr @"_OBJC_$_INSTANCE_METHODS_C", i32 0, i32 2, i32 0, i32 2)) }] }, section "__DATA, __objc_const", align 8 -// CHECK: @"_OBJC_CLASS_RO_$_C" = internal global %struct._class_ro_t { i32 130, i32 0, i32 0, ptr null, ptr @OBJC_CLASS_NAME_, ptr ptrauth (ptr @"_OBJC_$_INSTANCE_METHODS_C", i32 2, i64 49936, ptr getelementptr inbounds (%struct._class_ro_t, ptr @"_OBJC_CLASS_RO_$_C", i32 0, i32 5)), ptr null, ptr null, ptr null, ptr null }, section "__DATA, __objc_const", align 8 +// CHECK: @"_OBJC_$_INSTANCE_METHODS_C" = internal global { i32, i32, [1 x %struct._objc_method] } { i32 24, i32 1, [1 x %struct._objc_method] [%struct._objc_method { ptr @OBJC_METH_VAR_NAME_, ptr @OBJC_METH_VAR_TYPE_, ptr ptrauth (ptr @"\01-[C m0]", [i64 0, i64 0, i64 ptrtoint (ptr getelementptr inbounds ({ i32, i32, [1 x %struct._objc_method] }, ptr @"_OBJC_$_INSTANCE_METHODS_C", i32 0, i32 2, i32 0, i32 2) to i64)]) }] }, section "__DATA, __objc_const", align 8 +// CHECK: @"_OBJC_CLASS_RO_$_C" = internal global %struct._class_ro_t { i32 130, i32 0, i32 0, ptr null, ptr @OBJC_CLASS_NAME_, ptr ptrauth (ptr @"_OBJC_$_INSTANCE_METHODS_C", [i64 2, i64 49936, i64 ptrtoint (ptr getelementptr inbounds (%struct._class_ro_t, ptr @"_OBJC_CLASS_RO_$_C", i32 0, i32 5) to i64)]), ptr null, ptr null, ptr null, ptr null }, section "__DATA, __objc_const", align 8 // CHECK: @OBJC_SELECTOR_REFERENCES_ = internal externally_initialized global ptr @OBJC_METH_VAR_NAME_, section "__DATA,__objc_selrefs,literal_pointers,no_dead_strip", align 8 // CHECK: @"OBJC_LABEL_CLASS_$" = private global [1 x ptr] [ptr @"OBJC_CLASS_$_C"], section "__DATA,__objc_classlist,regular,no_dead_strip" diff --git a/clang/test/CodeGenObjC/ptrauth-objc-isa-super.m b/clang/test/CodeGenObjC/ptrauth-objc-isa-super.m index 69fd01f28067d..7eb7cb14f4502 100644 --- a/clang/test/CodeGenObjC/ptrauth-objc-isa-super.m +++ b/clang/test/CodeGenObjC/ptrauth-objc-isa-super.m @@ -12,7 +12,7 @@ @class NSString; -// CHECK: @"OBJC_METACLASS_$_C" = global %struct._class_t { ptr ptrauth (ptr @"OBJC_METACLASS_$_Base", i32 2, i64 27361, ptr @"OBJC_METACLASS_$_C"), ptr ptrauth (ptr @"OBJC_METACLASS_$_Base", i32 2, i64 46507, ptr getelementptr inbounds (%struct._class_t, ptr @"OBJC_METACLASS_$_C", i32 0, i32 1)), ptr @_objc_empty_cache, ptr null, ptr @"_OBJC_METACLASS_RO_$_C" } +// CHECK: @"OBJC_METACLASS_$_C" = global %struct._class_t { ptr ptrauth (ptr @"OBJC_METACLASS_$_Base", [i64 2, i64 27361, i64 ptrtoint (ptr @"OBJC_METACLASS_$_C" to i64)]), ptr ptrauth (ptr @"OBJC_METACLASS_$_Base", [i64 2, i64 46507, i64 ptrtoint (ptr getelementptr inbounds (%struct._class_t, ptr @"OBJC_METACLASS_$_C", i32 0, i32 1) to i64)]), ptr @_objc_empty_cache, ptr null, ptr @"_OBJC_METACLASS_RO_$_C" } // CHECK: @"OBJC_CLASSLIST_SUP_REFS_$_" = private global ptr @"OBJC_METACLASS_$_C" // CHECK: @OBJC_METH_VAR_NAME_ = private unnamed_addr constant [5 x i8] c"test\00" // CHECK: @OBJC_SELECTOR_REFERENCES_ = internal externally_initialized global ptr @OBJC_METH_VAR_NAME_ @@ -20,12 +20,12 @@ // CHECK: @OBJC_CLASS_NAME_ = private unnamed_addr constant [2 x i8] c"C\00" // CHECK: @OBJC_METH_VAR_NAME_.1 = private unnamed_addr constant [11 x i8] c"super_test\00" // CHECK: @OBJC_METH_VAR_TYPE_ = private unnamed_addr constant [8 x i8] c"v16@0:8\00" -// CHECK: @"_OBJC_$_CLASS_METHODS_C" = internal global { i32, i32, [1 x %struct._objc_method] } { i32 24, i32 1, [1 x %struct._objc_method] [%struct._objc_method { ptr @OBJC_METH_VAR_NAME_.1, ptr @OBJC_METH_VAR_TYPE_, ptr ptrauth (ptr @"\01+[C super_test]", i32 0, i64 0, ptr getelementptr inbounds ({ i32, i32, [1 x %struct._objc_method] }, ptr @"_OBJC_$_CLASS_METHODS_C", i32 0, i32 2, i32 0, i32 2)) }] } -// CHECK: @"_OBJC_METACLASS_RO_$_C" = internal global %struct._class_ro_t { i32 129, i32 40, i32 40, ptr null, ptr @OBJC_CLASS_NAME_, ptr ptrauth (ptr @"_OBJC_$_CLASS_METHODS_C", i32 2, i64 49936, ptr getelementptr inbounds (%struct._class_ro_t, ptr @"_OBJC_METACLASS_RO_$_C", i32 0, i32 5)), ptr null, ptr null, ptr null, ptr null } +// CHECK: @"_OBJC_$_CLASS_METHODS_C" = internal global { i32, i32, [1 x %struct._objc_method] } { i32 24, i32 1, [1 x %struct._objc_method] [%struct._objc_method { ptr @OBJC_METH_VAR_NAME_.1, ptr @OBJC_METH_VAR_TYPE_, ptr ptrauth (ptr @"\01+[C super_test]", [i64 0, i64 0, i64 ptrtoint (ptr getelementptr inbounds ({ i32, i32, [1 x %struct._objc_method] }, ptr @"_OBJC_$_CLASS_METHODS_C", i32 0, i32 2, i32 0, i32 2) to i64)]) }] } +// CHECK: @"_OBJC_METACLASS_RO_$_C" = internal global %struct._class_ro_t { i32 129, i32 40, i32 40, ptr null, ptr @OBJC_CLASS_NAME_, ptr ptrauth (ptr @"_OBJC_$_CLASS_METHODS_C", [i64 2, i64 49936, i64 ptrtoint (ptr getelementptr inbounds (%struct._class_ro_t, ptr @"_OBJC_METACLASS_RO_$_C", i32 0, i32 5) to i64)]), ptr null, ptr null, ptr null, ptr null } // CHECK: @"OBJC_CLASS_$_Base" = external global %struct._class_t // CHECK: @"_OBJC_CLASS_RO_$_C" = internal global %struct._class_ro_t { i32 128, i32 0, i32 0, ptr null, ptr @OBJC_CLASS_NAME_, ptr null, ptr null, ptr null, ptr null, ptr null } -// @"_OBJC_CLASS_RO_$_C" = internal global %struct._class_ro_t { i32 128, i32 0, i32 0, ptr null, ptr @OBJC_CLASS_NAME_, ptr ptrauth (ptr null, i32 2, i64 49936, ptr getelementptr inbounds (%struct._class_ro_t, ptr @"_OBJC_CLASS_RO_$_C", i32 0, i32 5)), ptr null, ptr null, ptr null, ptr null } -// CHECK: @"OBJC_CLASS_$_C" = global %struct._class_t { ptr ptrauth (ptr @"OBJC_METACLASS_$_C", i32 2, i64 27361, ptr @"OBJC_CLASS_$_C"), ptr ptrauth (ptr @"OBJC_CLASS_$_Base", i32 2, i64 46507, ptr getelementptr inbounds (%struct._class_t, ptr @"OBJC_CLASS_$_C", i32 0, i32 1)), ptr @_objc_empty_cache, ptr null, ptr @"_OBJC_CLASS_RO_$_C" } +// @"_OBJC_CLASS_RO_$_C" = internal global %struct._class_ro_t { i32 128, i32 0, i32 0, ptr null, ptr @OBJC_CLASS_NAME_, ptr ptrauth (ptr null, [i64 2, i64 49936, i64 ptrtoint (ptr getelementptr inbounds (%struct._class_ro_t, ptr @"_OBJC_CLASS_RO_$_C", i32 0, i32 5) to i64]), ptr null, ptr null, ptr null, ptr null } +// CHECK: @"OBJC_CLASS_$_C" = global %struct._class_t { ptr ptrauth (ptr @"OBJC_METACLASS_$_C", [i64 2, i64 27361, i64 ptrtoint (ptr @"OBJC_CLASS_$_C" to i64)]), ptr ptrauth (ptr @"OBJC_CLASS_$_Base", [i64 2, i64 46507, i64 ptrtoint (ptr getelementptr inbounds (%struct._class_t, ptr @"OBJC_CLASS_$_C", i32 0, i32 1) to i64)]), ptr @_objc_empty_cache, ptr null, ptr @"_OBJC_CLASS_RO_$_C" } // CHECK: @"OBJC_LABEL_CLASS_$" = private global [1 x ptr] [ptr @"OBJC_CLASS_$_C"] @interface Base diff --git a/clang/test/CodeGenObjC/ptrauth-objc-method-list-pointer.m b/clang/test/CodeGenObjC/ptrauth-objc-method-list-pointer.m index e7cb5642ee490..ea19dd0d87638 100644 --- a/clang/test/CodeGenObjC/ptrauth-objc-method-list-pointer.m +++ b/clang/test/CodeGenObjC/ptrauth-objc-method-list-pointer.m @@ -6,12 +6,12 @@ @implementation X -(void)meth {} @end -// CHECK: @"OBJC_CLASS_$_X" = global %struct._class_t { ptr @"OBJC_METACLASS_$_X", ptr null, ptr @_objc_empty_cache, ptr null, ptr ptrauth (ptr @"_OBJC_CLASS_RO_$_X", i32 2, i64 25080, ptr getelementptr inbounds (%struct._class_t, ptr @"OBJC_CLASS_$_X", i32 0, i32 4)) } -// CHECK: @"OBJC_METACLASS_$_X" = global %struct._class_t { ptr @"OBJC_METACLASS_$_X", ptr @"OBJC_CLASS_$_X", ptr @_objc_empty_cache, ptr null, ptr ptrauth (ptr @"_OBJC_METACLASS_RO_$_X", i32 2, i64 25080, ptr getelementptr inbounds (%struct._class_t, ptr @"OBJC_METACLASS_$_X", i32 0, i32 4)) } +// CHECK: @"OBJC_CLASS_$_X" = global %struct._class_t { ptr @"OBJC_METACLASS_$_X", ptr null, ptr @_objc_empty_cache, ptr null, ptr ptrauth (ptr @"_OBJC_CLASS_RO_$_X", [i64 2, i64 25080, i64 ptrtoint (ptr getelementptr inbounds (%struct._class_t, ptr @"OBJC_CLASS_$_X", i32 0, i32 4) to i64)]) } +// CHECK: @"OBJC_METACLASS_$_X" = global %struct._class_t { ptr @"OBJC_METACLASS_$_X", ptr @"OBJC_CLASS_$_X", ptr @_objc_empty_cache, ptr null, ptr ptrauth (ptr @"_OBJC_METACLASS_RO_$_X", [i64 2, i64 25080, i64 ptrtoint (ptr getelementptr inbounds (%struct._class_t, ptr @"OBJC_METACLASS_$_X", i32 0, i32 4) to i64)]) } // CHECK: @OBJC_CLASS_NAME_ = private unnamed_addr constant [2 x i8] c"X\00" // CHECK: @"_OBJC_METACLASS_RO_$_X" = private global %struct._class_ro_t { i32 3, i32 40, i32 40, ptr null, ptr @OBJC_CLASS_NAME_, ptr null, ptr null, ptr null, ptr null, ptr null } // CHECK: @OBJC_METH_VAR_NAME_ = private unnamed_addr constant [5 x i8] c"meth\00" // CHECK: @OBJC_METH_VAR_TYPE_ = private unnamed_addr constant [8 x i8] c"v16@0:8\00" -// CHECK: @"_OBJC_$_INSTANCE_METHODS_X" = private global { i32, i32, [1 x %struct._objc_method] } { i32 24, i32 1, [1 x %struct._objc_method] [%struct._objc_method { ptr @OBJC_METH_VAR_NAME_, ptr @OBJC_METH_VAR_TYPE_, ptr ptrauth (ptr @"\01-[X meth]", i32 0, i64 0, ptr getelementptr inbounds ({ i32, i32, [1 x %struct._objc_method] }, ptr @"_OBJC_$_INSTANCE_METHODS_X", i32 0, i32 2, i32 0, i32 2)) }] } -// CHECK: @"_OBJC_CLASS_RO_$_X" = private global %struct._class_ro_t { i32 2, i32 0, i32 0, ptr null, ptr @OBJC_CLASS_NAME_, ptr ptrauth (ptr @"_OBJC_$_INSTANCE_METHODS_X", i32 2, i64 49936, ptr getelementptr inbounds (%struct._class_ro_t, ptr @"_OBJC_CLASS_RO_$_X", i32 0, i32 5)), ptr null, ptr null, ptr null, ptr null } +// CHECK: @"_OBJC_$_INSTANCE_METHODS_X" = private global { i32, i32, [1 x %struct._objc_method] } { i32 24, i32 1, [1 x %struct._objc_method] [%struct._objc_method { ptr @OBJC_METH_VAR_NAME_, ptr @OBJC_METH_VAR_TYPE_, ptr ptrauth (ptr @"\01-[X meth]", [i64 0, i64 0, i64 ptrtoint (ptr getelementptr inbounds ({ i32, i32, [1 x %struct._objc_method] }, ptr @"_OBJC_$_INSTANCE_METHODS_X", i32 0, i32 2, i32 0, i32 2) to i64)]) }] } +// CHECK: @"_OBJC_CLASS_RO_$_X" = private global %struct._class_ro_t { i32 2, i32 0, i32 0, ptr null, ptr @OBJC_CLASS_NAME_, ptr ptrauth (ptr @"_OBJC_$_INSTANCE_METHODS_X", [i64 2, i64 49936, i64 ptrtoint (ptr getelementptr inbounds (%struct._class_ro_t, ptr @"_OBJC_CLASS_RO_$_X", i32 0, i32 5) to i64)]), ptr null, ptr null, ptr null, ptr null } // CHECK: @"OBJC_LABEL_CLASS_$" = private global [1 x ptr] [ptr @"OBJC_CLASS_$_X"] diff --git a/llvm/docs/GlobalISel/GenericOpcode.rst b/llvm/docs/GlobalISel/GenericOpcode.rst index 329d9d13ebddd..71f16645d5a58 100644 --- a/llvm/docs/GlobalISel/GenericOpcode.rst +++ b/llvm/docs/GlobalISel/GenericOpcode.rst @@ -67,6 +67,8 @@ The signed address of a global value. Operands: address to be signed (pointer), key (32-bit imm), address for address discrimination (zero if not needed) and an extra discriminator (64-bit imm). +FIXME + .. code-block:: none %0:_(p0) = G_PTRAUTH_GLOBAL_VALUE %1:_(p0), s32, %2:_(p0), s64 diff --git a/llvm/include/llvm-c/Core.h b/llvm/include/llvm-c/Core.h index 83dd1eba876e6..047fa6e94b70f 100644 --- a/llvm/include/llvm-c/Core.h +++ b/llvm/include/llvm-c/Core.h @@ -1755,10 +1755,16 @@ LLVM_C_ABI unsigned LLVMGetVectorSize(LLVMTypeRef VectorTy); */ LLVM_C_ABI LLVMValueRef LLVMGetConstantPtrAuthPointer(LLVMValueRef PtrAuth); +LLVM_C_ABI unsigned LLVMGetConstantPtrAuthSchemaSize(LLVMValueRef PtrAuth); + +LLVM_C_ABI LLVMValueRef +LLVMGetConstantPtrAuthSchemaOperand(LLVMValueRef PtrAuth, unsigned Idx); + /** * Get the key value for the associated ConstantPtrAuth constant. * * @see llvm::ConstantPtrAuth::getKey + * @deprecated */ LLVM_C_ABI LLVMValueRef LLVMGetConstantPtrAuthKey(LLVMValueRef PtrAuth); @@ -1766,6 +1772,7 @@ LLVM_C_ABI LLVMValueRef LLVMGetConstantPtrAuthKey(LLVMValueRef PtrAuth); * Get the discriminator value for the associated ConstantPtrAuth constant. * * @see llvm::ConstantPtrAuth::getDiscriminator + * @deprecated */ LLVM_C_ABI LLVMValueRef LLVMGetConstantPtrAuthDiscriminator(LLVMValueRef PtrAuth); @@ -1775,10 +1782,14 @@ LLVMGetConstantPtrAuthDiscriminator(LLVMValueRef PtrAuth); * constant. * * @see llvm::ConstantPtrAuth::getAddrDiscriminator + * @deprecated */ LLVM_C_ABI LLVMValueRef LLVMGetConstantPtrAuthAddrDiscriminator(LLVMValueRef PtrAuth); +LLVM_C_ABI LLVMValueRef +LLVMGetConstantPtrAuthDeactivationSymbol(LLVMValueRef PtrAuth); + /** * @} */ @@ -2535,10 +2546,12 @@ LLVM_C_ABI LLVMValueRef LLVMConstVector(LLVMValueRef *ScalarConstantVals, * Create a ConstantPtrAuth constant with the given values. * * @see llvm::ConstantPtrAuth::get() + * FIXME Compatibility? */ -LLVM_C_ABI LLVMValueRef LLVMConstantPtrAuth(LLVMValueRef Ptr, LLVMValueRef Key, - LLVMValueRef Disc, - LLVMValueRef AddrDisc); +LLVM_C_ABI LLVMValueRef LLVMConstantPtrAuth(LLVMValueRef Ptr, + LLVMValueRef *Schema, + unsigned SchemaSize, + LLVMValueRef DeactivationSymbol); /** * @} diff --git a/llvm/include/llvm/Bitcode/LLVMBitCodes.h b/llvm/include/llvm/Bitcode/LLVMBitCodes.h index 2451d588bdbf7..0b210daf5e1c9 100644 --- a/llvm/include/llvm/Bitcode/LLVMBitCodes.h +++ b/llvm/include/llvm/Bitcode/LLVMBitCodes.h @@ -436,9 +436,11 @@ enum ConstantsCodes { // asmstr,conststr] CST_CODE_CE_GEP_WITH_INRANGE = 31, // [opty, flags, range, n x operands] CST_CODE_CE_GEP = 32, // [opty, flags, n x operands] + // FIXME Deprecate CST_CODE_PTRAUTH = 33, // [ptr, key, disc, addrdisc] CST_CODE_PTRAUTH2 = 34, // [ptr, key, disc, addrdisc, // deactivation_symbol] + CST_CODE_PTRAUTH3 = 35, // [ptr, n x i64, deactivation_symbol] }; /// CastOpcodes - These are values used in the bitcode files to encode which diff --git a/llvm/include/llvm/CodeGen/GlobalISel/MachineIRBuilder.h b/llvm/include/llvm/CodeGen/GlobalISel/MachineIRBuilder.h index 5f3f1d386569c..3d64cffc99fa1 100644 --- a/llvm/include/llvm/CodeGen/GlobalISel/MachineIRBuilder.h +++ b/llvm/include/llvm/CodeGen/GlobalISel/MachineIRBuilder.h @@ -982,9 +982,8 @@ class LLVM_ABI MachineIRBuilder { /// Build and insert G_PTRAUTH_GLOBAL_VALUE /// /// \return a MachineInstrBuilder for the newly created instruction. - MachineInstrBuilder buildConstantPtrAuth(const DstOp &Res, - const ConstantPtrAuth *CPA, - Register Addr, Register AddrDisc); + MachineInstrBuilder buildConstantPtrAuth(const DstOp &Res, Register Ptr, + Register Schema); /// Build and insert \p Res = COPY Op /// diff --git a/llvm/include/llvm/CodeGen/ISDOpcodes.h b/llvm/include/llvm/CodeGen/ISDOpcodes.h index 9cc9a4d20320c..eebbb69638ccd 100644 --- a/llvm/include/llvm/CodeGen/ISDOpcodes.h +++ b/llvm/include/llvm/CodeGen/ISDOpcodes.h @@ -94,7 +94,7 @@ enum NodeType { BlockAddress, /// A ptrauth constant. - /// ptr, key, addr-disc, disc + /// ptr, bundle_token /// Note that the addr-disc can be a non-constant value, to allow representing /// a constant global address signed using address-diversification, in code. PtrAuthGlobalAddress, diff --git a/llvm/include/llvm/CodeGen/TargetLowering.h b/llvm/include/llvm/CodeGen/TargetLowering.h index 14efa2638993a..32d9598a7f2d3 100644 --- a/llvm/include/llvm/CodeGen/TargetLowering.h +++ b/llvm/include/llvm/CodeGen/TargetLowering.h @@ -40,6 +40,7 @@ #include "llvm/CodeGenTypes/MachineValueType.h" #include "llvm/IR/Attributes.h" #include "llvm/IR/CallingConv.h" +#include "llvm/IR/Constants.h" #include "llvm/IR/DataLayout.h" #include "llvm/IR/DerivedTypes.h" #include "llvm/IR/Function.h" @@ -4613,7 +4614,7 @@ class LLVM_ABI TargetLowering : public TargetLoweringBase { /// Perform target-specific validation of PtrAuth schema descriptions that /// is not covered by Verifier but relied upon by the backend. virtual std::optional - validatePtrAuthSchema(const CallBase &CB) const { + validatePtrAuthSchema(const Value &V) const { return "this target does not support pointer authentication"; } @@ -4623,10 +4624,11 @@ class LLVM_ABI TargetLowering : public TargetLoweringBase { /// /// This function is intended to handle possible invalid user input and thus /// always performs the check, whether the assertions are enabled or not. - void reportFatalErrorOnInvalidPtrAuthSchema(const CallBase &CB) const { - if (auto Error = validatePtrAuthSchema(CB)) { + void reportFatalErrorOnInvalidPtrAuthSchema(const Value &V) const { + assert(isa(V) || isa(V)); + if (auto Error = validatePtrAuthSchema(V)) { errs() << "Ptrauth schema violates target-specific constraints:\n"; - CB.print(errs()); + V.print(errs()); errs() << "\n"; reportFatalUsageError(("Invalid ptrauth schema: " + *Error).c_str()); } diff --git a/llvm/include/llvm/IR/Constants.h b/llvm/include/llvm/IR/Constants.h index efdf856c5757f..7b67c763da9e5 100644 --- a/llvm/include/llvm/IR/Constants.h +++ b/llvm/include/llvm/IR/Constants.h @@ -1033,20 +1033,19 @@ class ConstantPtrAuth final : public Constant { friend struct ConstantPtrAuthKeyType; friend class Constant; - constexpr static IntrusiveOperandsAllocMarker AllocMarker{5}; - - ConstantPtrAuth(Constant *Ptr, ConstantInt *Key, ConstantInt *Disc, - Constant *AddrDisc, Constant *DeactivationSymbol); - - void *operator new(size_t s) { return User::operator new(s, AllocMarker); } + ConstantPtrAuth(Constant *Ptr, ArrayRef Schema, + Constant *DeactivationSymbol, AllocInfo AllocInfo); void destroyConstantImpl(); Value *handleOperandChangeImpl(Value *From, Value *To); public: /// Return a pointer signed with the specified parameters. - LLVM_ABI static ConstantPtrAuth *get(Constant *Ptr, ConstantInt *Key, - ConstantInt *Disc, Constant *AddrDisc, + // LLVM_ABI static ConstantPtrAuth *get(Constant *Ptr, ConstantArray *Schema, + // Constant *DeactivationSymbol); + + LLVM_ABI static ConstantPtrAuth *get(Constant *Ptr, + ArrayRef SchemaArgs, Constant *DeactivationSymbol); /// Produce a new ptrauth expression signing the given value using @@ -1059,28 +1058,40 @@ class ConstantPtrAuth final : public Constant { /// The pointer that is signed in this ptrauth signed pointer. Constant *getPointer() const { return cast(Op<0>().get()); } + ArrayRef getSchema() const { + return ArrayRef(op_begin() + 2, op_end()); + } + /// The Key ID, an i32 constant. - ConstantInt *getKey() const { return cast(Op<1>().get()); } + ConstantInt *getKey() const { + // FIXME remove this + return cast(getSchema()[0]); + } /// The integer discriminator, an i64 constant, or 0. ConstantInt *getDiscriminator() const { - return cast(Op<2>().get()); + // FIXME remove this + return cast(getSchema()[1]); } /// The address discriminator if any, or the null constant. /// If present, this must be a value equivalent to the storage location of /// the only global-initializer user of the ptrauth signed pointer. + // FIXME Remove Constant *getAddrDiscriminator() const { - return cast(Op<3>().get()); + // FIXME remove this + return cast(getSchema()[2]); } /// Whether there is any non-null address discriminator. + // FIXME Remove bool hasAddressDiscriminator() const { + // FIXME remove this return !getAddrDiscriminator()->isNullValue(); } Constant *getDeactivationSymbol() const { - return cast(Op<4>().get()); + return cast(Op<1>().get()); } /// A constant value for the address discriminator which has special @@ -1094,6 +1105,7 @@ class ConstantPtrAuth final : public Constant { /// These discriminators can't be used in real pointer-auth values; they /// can only be used in "prototype" values that indicate how some real /// schema is supposed to be produced. + // FIXME Rethink? LLVM_ABI bool hasSpecialAddressDiscriminator(uint64_t Value) const; /// Check whether an authentication operation with key \p Key and (possibly @@ -1111,7 +1123,7 @@ class ConstantPtrAuth final : public Constant { template <> struct OperandTraits - : public FixedNumOperandTraits {}; + : public VariadicOperandTraits {}; DEFINE_TRANSPARENT_OPERAND_ACCESSORS(ConstantPtrAuth, Constant) diff --git a/llvm/include/llvm/IR/User.h b/llvm/include/llvm/IR/User.h index cbb4379b68c41..cc14a3ace35fd 100644 --- a/llvm/include/llvm/IR/User.h +++ b/llvm/include/llvm/IR/User.h @@ -44,6 +44,7 @@ struct OperandTraits; class User : public Value { friend struct HungoffOperandTraits; template friend struct ConstantAggrKeyType; + friend struct ConstantPtrAuthKeyType; LLVM_ATTRIBUTE_ALWAYS_INLINE static void * allocateFixedOperandUser(size_t, unsigned, unsigned); diff --git a/llvm/include/llvm/SandboxIR/Constant.h b/llvm/include/llvm/SandboxIR/Constant.h index 03b1fc7522bef..a677cd68512d4 100644 --- a/llvm/include/llvm/SandboxIR/Constant.h +++ b/llvm/include/llvm/SandboxIR/Constant.h @@ -1362,26 +1362,35 @@ class ConstantPtrAuth final : public Constant { public: /// Return a pointer signed with the specified parameters. - LLVM_ABI static ConstantPtrAuth *get(Constant *Ptr, ConstantInt *Key, - ConstantInt *Disc, Constant *AddrDisc, + LLVM_ABI static ConstantPtrAuth *get(Constant *Ptr, ConstantArray *Schema, Constant *DeactivationSymbol); + LLVM_ABI static ConstantPtrAuth *get(Constant *Ptr, + ArrayRef Schema, + Constant *DeactivationSymbol); + + // ConstantArray *getSchema() const; + /// The pointer that is signed in this ptrauth signed pointer. LLVM_ABI Constant *getPointer() const; /// The Key ID, an i32 constant. + // FIXME Remove LLVM_ABI ConstantInt *getKey() const; /// The integer discriminator, an i64 constant, or 0. + // FIXME Remove LLVM_ABI ConstantInt *getDiscriminator() const; /// The address discriminator if any, or the null constant. /// If present, this must be a value equivalent to the storage location of /// the only global-initializer user of the ptrauth signed pointer. + // FIXME Remove LLVM_ABI Constant *getAddrDiscriminator() const; Constant *getDeactivationSymbol() const; /// Whether there is any non-null address discriminator. + // FIXME Remove bool hasAddressDiscriminator() const { return cast(Val)->hasAddressDiscriminator(); } @@ -1390,6 +1399,7 @@ class ConstantPtrAuth final : public Constant { /// These discriminators can't be used in real pointer-auth values; they /// can only be used in "prototype" values that indicate how some real /// schema is supposed to be produced. + // FIXME Rethink? bool hasSpecialAddressDiscriminator(uint64_t Value) const { return cast(Val)->hasSpecialAddressDiscriminator( Value); diff --git a/llvm/include/llvm/Target/GenericOpcodes.td b/llvm/include/llvm/Target/GenericOpcodes.td index fcddc06b171e7..787adcc6b3d40 100644 --- a/llvm/include/llvm/Target/GenericOpcodes.td +++ b/llvm/include/llvm/Target/GenericOpcodes.td @@ -133,7 +133,7 @@ def G_GLOBAL_VALUE : GenericInstruction { def G_PTRAUTH_GLOBAL_VALUE : GenericInstruction { let OutOperandList = (outs type0:$dst); - let InOperandList = (ins unknown:$addr, i32imm:$key, type1:$addrdisc, i64imm:$disc); + let InOperandList = (ins type0:$addr, untyped_imm_0:$schema); let hasSideEffects = 0; } diff --git a/llvm/lib/AsmParser/LLParser.cpp b/llvm/lib/AsmParser/LLParser.cpp index 2594a3af82b0c..3a1e48e2b2838 100644 --- a/llvm/lib/AsmParser/LLParser.cpp +++ b/llvm/lib/AsmParser/LLParser.cpp @@ -4263,27 +4263,43 @@ bool LLParser::parseValID(ValID &ID, PerFunctionState *PFS, Type *ExpectedTy) { return false; } case lltok::kw_ptrauth: { - // ValID ::= 'ptrauth' '(' ptr @foo ',' i32 - // (',' i64 (',' ptr addrdisc (',' ptr ds)? - // )? )? ')' + // ValID ::= 'ptrauth' '(' ptr @foo ',' + // '[' i64 schema_op (',' i64 schema_op)* ']' + // (',' ptr ds)? ')' Lex.Lex(); - Constant *Ptr, *Key; - Constant *Disc = nullptr, *AddrDisc = nullptr, - *DeactivationSymbol = nullptr; + Constant *Ptr; + SmallVector Schema; + Constant *DeactivationSymbol = nullptr; + + Constant *TmpSchemaOp; if (parseToken(lltok::lparen, "expected '(' in constant ptrauth expression") || parseGlobalTypeAndValue(Ptr) || parseToken(lltok::comma, "expected comma in constant ptrauth expression") || - parseGlobalTypeAndValue(Key)) + parseToken(lltok::lsquare, + "expected '[' in constant ptrauth expression")) return true; - // If present, parse the optional disc/addrdisc/ds. - if (EatIfPresent(lltok::comma) && parseGlobalTypeAndValue(Disc)) + + if (EatIfPresent(lltok::rsquare)) + return error(ID.Loc, "schema of ptrauth constant must not be empty"); + + if (parseGlobalTypeAndValue(TmpSchemaOp)) return true; - if (EatIfPresent(lltok::comma) && parseGlobalTypeAndValue(AddrDisc)) + + Schema.push_back(TmpSchemaOp); + while (EatIfPresent(lltok::comma)) { + if (parseGlobalTypeAndValue(TmpSchemaOp)) + return true; + Schema.push_back(TmpSchemaOp); + } + + if (parseToken(lltok::rsquare, + "expected ']' in constant ptrauth expression")) return true; + if (EatIfPresent(lltok::comma) && parseGlobalTypeAndValue(DeactivationSymbol)) return true; @@ -4292,29 +4308,11 @@ bool LLParser::parseValID(ValID &ID, PerFunctionState *PFS, Type *ExpectedTy) { return true; if (!Ptr->getType()->isPointerTy()) - return error(ID.Loc, "constant ptrauth base pointer must be a pointer"); - - auto *KeyC = dyn_cast(Key); - if (!KeyC || KeyC->getBitWidth() != 32) - return error(ID.Loc, "constant ptrauth key must be i32 constant"); - - ConstantInt *DiscC = nullptr; - if (Disc) { - DiscC = dyn_cast(Disc); - if (!DiscC || DiscC->getBitWidth() != 64) - return error( - ID.Loc, - "constant ptrauth integer discriminator must be i64 constant"); - } else { - DiscC = ConstantInt::get(Type::getInt64Ty(Context), 0); - } + return error(ID.Loc, "base pointer of ptrauth constant must be a pointer"); - if (AddrDisc) { - if (!AddrDisc->getType()->isPointerTy()) - return error( - ID.Loc, "constant ptrauth address discriminator must be a pointer"); - } else { - AddrDisc = ConstantPointerNull::get(PointerType::get(Context, 0)); + for (Constant *Op : Schema) { + if (!Op->getType()->isIntegerTy(64)) + return error(ID.Loc, "schema of ptrauth constant must be a tuple of i64"); } if (!DeactivationSymbol) @@ -4324,8 +4322,7 @@ bool LLParser::parseValID(ValID &ID, PerFunctionState *PFS, Type *ExpectedTy) { return error(ID.Loc, "constant ptrauth deactivation symbol must be a pointer"); - ID.ConstantVal = - ConstantPtrAuth::get(Ptr, KeyC, DiscC, AddrDisc, DeactivationSymbol); + ID.ConstantVal = ConstantPtrAuth::get(Ptr, Schema, DeactivationSymbol); ID.Kind = ValID::t_Constant; return false; } diff --git a/llvm/lib/Bitcode/CMakeLists.txt b/llvm/lib/Bitcode/CMakeLists.txt index ff7e290cad1bb..3d07fea511f61 100644 --- a/llvm/lib/Bitcode/CMakeLists.txt +++ b/llvm/lib/Bitcode/CMakeLists.txt @@ -1,2 +1,3 @@ +add_compile_options(-O0) add_subdirectory(Reader) add_subdirectory(Writer) diff --git a/llvm/lib/Bitcode/Reader/BitcodeReader.cpp b/llvm/lib/Bitcode/Reader/BitcodeReader.cpp index 90e6ffbf8992b..53d06496e3b73 100644 --- a/llvm/lib/Bitcode/Reader/BitcodeReader.cpp +++ b/llvm/lib/Bitcode/Reader/BitcodeReader.cpp @@ -1617,7 +1617,8 @@ Expected BitcodeReader::materializeValue(unsigned StartValID, return error( "ptrauth deactivation symbol operand must be a pointer"); - C = ConstantPtrAuth::get(ConstOps[0], Key, Disc, ConstOps[3], + // FIXME Upgrade + C = ConstantPtrAuth::get(ConstOps[0], {Key, Disc, ConstOps[3]}, DeactivationSymbol); break; } diff --git a/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp b/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp index 845ecb4672cf2..2b58424d53604 100644 --- a/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp +++ b/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp @@ -3030,7 +3030,7 @@ void ModuleBitcodeWriter::writeConstants(unsigned FirstVal, unsigned LastVal, Record.push_back(VE.getTypeID(NC->getGlobalValue()->getType())); Record.push_back(VE.getValueID(NC->getGlobalValue())); } else if (const auto *CPA = dyn_cast(C)) { - Code = bitc::CST_CODE_PTRAUTH2; + Code = bitc::CST_CODE_PTRAUTH3; Record.push_back(VE.getValueID(CPA->getPointer())); Record.push_back(VE.getValueID(CPA->getKey())); Record.push_back(VE.getValueID(CPA->getDiscriminator())); diff --git a/llvm/lib/Bitstream/CMakeLists.txt b/llvm/lib/Bitstream/CMakeLists.txt index 49def158f6904..1fe568f8340c9 100644 --- a/llvm/lib/Bitstream/CMakeLists.txt +++ b/llvm/lib/Bitstream/CMakeLists.txt @@ -1,2 +1,3 @@ +add_compile_options(-O0) add_subdirectory(Reader) # The writer is header-only. diff --git a/llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp b/llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp index 98b843f3ca050..f808ffe503fa4 100644 --- a/llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp +++ b/llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp @@ -2197,11 +2197,12 @@ bool IRTranslator::translatePtrAuthIntrinsic(const CallInst &CI, auto Bundle = CI.getOperandBundleAt(Index); assert(Bundle.getTagID() == LLVMContext::OB_ptrauth); - Register Res = MRI->createGenericVirtualRegister(LLT::token()); - auto Builder = MIRBuilder.buildInstr(TargetOpcode::G_PTRAUTH_BUNDLE); - Builder.addDef(Res); + SmallVector SchemaOps; for (const Use &Operand : Bundle.Inputs) - Builder.addUse(getOrCreateVReg(*Operand)); + SchemaOps.push_back(getOrCreateVReg(*Operand)); + + Register Res = MRI->createGenericVirtualRegister(LLT::token()); + MIRBuilder.buildInstr(TargetOpcode::G_PTRAUTH_BUNDLE, {Res}, SchemaOps); return Res; }; @@ -3826,9 +3827,17 @@ bool IRTranslator::translate(const Constant &C, Register Reg) { else if (auto GV = dyn_cast(&C)) EntryBuilder->buildGlobalValue(Reg, GV); else if (auto CPA = dyn_cast(&C)) { + TLI->reportFatalErrorOnInvalidPtrAuthSchema(*CPA); + Register Addr = getOrCreateVReg(*CPA->getPointer()); - Register AddrDisc = getOrCreateVReg(*CPA->getAddrDiscriminator()); - EntryBuilder->buildConstantPtrAuth(Reg, CPA, Addr, AddrDisc); + SmallVector SchemaOps; + for (const Use &Operand : CPA->getSchema()) + SchemaOps.push_back(getOrCreateVReg(*Operand)); + + Register SchemaReg = MRI->createGenericVirtualRegister(LLT::token()); + EntryBuilder->buildInstr(TargetOpcode::G_PTRAUTH_BUNDLE, {SchemaReg}, SchemaOps); + + EntryBuilder->buildConstantPtrAuth(Reg, Addr, SchemaReg); } else if (auto CAZ = dyn_cast(&C)) { Constant &Elt = *CAZ->getElementValue(0u); if (isa(CAZ->getType())) { diff --git a/llvm/lib/CodeGen/GlobalISel/MachineIRBuilder.cpp b/llvm/lib/CodeGen/GlobalISel/MachineIRBuilder.cpp index 3906b311addf0..047e361bd520c 100644 --- a/llvm/lib/CodeGen/GlobalISel/MachineIRBuilder.cpp +++ b/llvm/lib/CodeGen/GlobalISel/MachineIRBuilder.cpp @@ -421,14 +421,11 @@ MachineInstrBuilder MachineIRBuilder::buildFConstant(const DstOp &Res, MachineInstrBuilder MachineIRBuilder::buildConstantPtrAuth(const DstOp &Res, - const ConstantPtrAuth *CPA, - Register Addr, Register AddrDisc) { + Register Ptr, Register Schema) { auto MIB = buildInstr(TargetOpcode::G_PTRAUTH_GLOBAL_VALUE); Res.addDefToMIB(*getMRI(), MIB); - MIB.addUse(Addr); - MIB.addImm(CPA->getKey()->getZExtValue()); - MIB.addUse(AddrDisc); - MIB.addImm(CPA->getDiscriminator()->getZExtValue()); + MIB.addUse(Ptr); + MIB.addUse(Schema); return MIB; } diff --git a/llvm/lib/CodeGen/MachineVerifier.cpp b/llvm/lib/CodeGen/MachineVerifier.cpp index 9be741d96e456..e49ed809dbacb 100644 --- a/llvm/lib/CodeGen/MachineVerifier.cpp +++ b/llvm/lib/CodeGen/MachineVerifier.cpp @@ -2276,6 +2276,7 @@ void MachineVerifier::verifyPreISelGenericInstruction(const MachineInstr *MI) { report("addr operand must be a pointer", &AddrOp, 1); break; } + // TODO default: break; } diff --git a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp index 85dfeaeb31dae..5501ad20610ff 100644 --- a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp +++ b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp @@ -1868,10 +1868,18 @@ SDValue SelectionDAGBuilder::getValueImpl(const Value *V) { return DAG.getGlobalAddress(GV, getCurSDLoc(), VT); if (const ConstantPtrAuth *CPA = dyn_cast(C)) { + const TargetLowering &TLI = DAG.getTargetLoweringInfo(); + TLI.reportFatalErrorOnInvalidPtrAuthSchema(*CPA); + + SmallVector Ops; + for (const Use &Operand : CPA->getSchema()) + Ops.push_back(getValue(Operand)); + + SDValue Bundle = DAG.getNode(ISD::PtrAuthBundle, getCurSDLoc(), + MVT::Other, Ops); + return DAG.getNode(ISD::PtrAuthGlobalAddress, getCurSDLoc(), VT, - getValue(CPA->getPointer()), getValue(CPA->getKey()), - getValue(CPA->getAddrDiscriminator()), - getValue(CPA->getDiscriminator())); + getValue(CPA->getPointer()), Bundle); } if (isa(C)) diff --git a/llvm/lib/IR/AsmWriter.cpp b/llvm/lib/IR/AsmWriter.cpp index 7932765db8359..14f9d3eec7475 100644 --- a/llvm/lib/IR/AsmWriter.cpp +++ b/llvm/lib/IR/AsmWriter.cpp @@ -1674,22 +1674,23 @@ static void writeConstantInternal(raw_ostream &Out, const Constant *CV, if (const auto *CPA = dyn_cast(CV)) { Out << "ptrauth ("; - // ptrauth (ptr CST, i32 KEY[, i64 DISC[, ptr ADDRDISC[, ptr DS]?]?]?) - unsigned NumOpsToWrite = 2; - if (!CPA->getOperand(2)->isNullValue()) - NumOpsToWrite = 3; - if (!CPA->getOperand(3)->isNullValue()) - NumOpsToWrite = 4; - if (!CPA->getOperand(4)->isNullValue()) - NumOpsToWrite = 5; - + // ptrauth (ptr CST, [i64 ARG, ...] (, ptr DS)?) + writeAsOperandInternal(Out, CPA->getOperand(0), WriterCtx, + /*PrintType=*/true); + Out << ", ["; ListSeparator LS; - for (unsigned i = 0, e = NumOpsToWrite; i != e; ++i) { + auto Schema = CPA->getSchema(); + for (unsigned I = 0, N = Schema.size(); I < N; ++I) { Out << LS; - writeAsOperandInternal(Out, CPA->getOperand(i), WriterCtx, - /*PrintType=*/true); + writeAsOperandInternal(Out, Schema[I], WriterCtx, /*PrintType=*/true); } - Out << ')'; + Out << "]"; + Constant *Sym = CPA->getDeactivationSymbol(); + if (!Sym->isNullValue()) { + Out << ", "; + writeAsOperandInternal(Out, Sym, WriterCtx, /*PrintType=*/true); + } + Out << ")"; return; } diff --git a/llvm/lib/IR/Constants.cpp b/llvm/lib/IR/Constants.cpp index 71d467797b8a3..a2c3dd7dd45ed 100644 --- a/llvm/lib/IR/Constants.cpp +++ b/llvm/lib/IR/Constants.cpp @@ -1899,7 +1899,7 @@ void UndefValue::destroyConstantImpl() { } else if (getValueID() == PoisonValueVal) { getContext().pImpl->PVConstants.erase(getType()); } - llvm_unreachable("Not a undef or a poison!"); + llvm_unreachable("Not a undef or a poison!"); // unreachable?!? } PoisonValue *PoisonValue::get(Type *Ty) { @@ -2080,37 +2080,45 @@ Value *NoCFIValue::handleOperandChangeImpl(Value *From, Value *To) { //---- ConstantPtrAuth::get() implementations. // -ConstantPtrAuth *ConstantPtrAuth::get(Constant *Ptr, ConstantInt *Key, - ConstantInt *Disc, Constant *AddrDisc, +#if 0 +ConstantPtrAuth *ConstantPtrAuth::get(Constant *Ptr, Constant *Schema, Constant *DeactivationSymbol) { - // FIXME Should we simply enforce i64 instead? - if (Key->getBitWidth() != 32) - Key = ConstantInt::get(Key->getContext(), APInt(32, Key->getZExtValue())); - Constant *ArgVec[] = {Ptr, Key, Disc, AddrDisc, DeactivationSymbol}; + Constant *ArgVec[] = {Ptr, Schema, DeactivationSymbol}; ConstantPtrAuthKeyType MapKey(ArgVec); LLVMContextImpl *pImpl = Ptr->getContext().pImpl; return pImpl->ConstantPtrAuths.getOrCreate(Ptr->getType(), MapKey); } +#endif + +ConstantPtrAuth *ConstantPtrAuth::get(Constant *Ptr, + ArrayRef SchemaArgs, + Constant *DeactivationSymbol) { + ConstantPtrAuthKeyType MapKey(Ptr, SchemaArgs, DeactivationSymbol); + LLVMContextImpl *pImpl = Ptr->getContext().pImpl; + return pImpl->ConstantPtrAuths.getOrCreate(Ptr->getType(), MapKey); +} ConstantPtrAuth *ConstantPtrAuth::getWithSameSchema(Constant *Pointer) const { - return get(Pointer, getKey(), getDiscriminator(), getAddrDiscriminator(), - getDeactivationSymbol()); + SmallVector Schema; + for (Value *V :getSchema()) + Schema.push_back(cast(V)); + return get(Pointer, Schema, getDeactivationSymbol()); } -ConstantPtrAuth::ConstantPtrAuth(Constant *Ptr, ConstantInt *Key, - ConstantInt *Disc, Constant *AddrDisc, - Constant *DeactivationSymbol) - : Constant(Ptr->getType(), Value::ConstantPtrAuthVal, AllocMarker) { +ConstantPtrAuth::ConstantPtrAuth(Constant *Ptr, ArrayRef Schema, + Constant *DeactivationSymbol, + AllocInfo AllocInfo) + : Constant(Ptr->getType(), Value::ConstantPtrAuthVal, AllocInfo) { assert(Ptr->getType()->isPointerTy()); - assert(Key->getBitWidth() == 32); - assert(Disc->getBitWidth() == 64); - assert(AddrDisc->getType()->isPointerTy()); assert(DeactivationSymbol->getType()->isPointerTy()); setOperand(0, Ptr); - setOperand(1, Key); - setOperand(2, Disc); - setOperand(3, AddrDisc); - setOperand(4, DeactivationSymbol); + setOperand(1, DeactivationSymbol); + + assert(!Schema.empty()); + for (unsigned I = 0, N = Schema.size(); I < N; ++I) { + assert(Schema[I]->getType()->isIntegerTy(64)); + setOperand(2 + I, Schema[I]); + } } /// Remove the constant from the constant table. @@ -2122,17 +2130,16 @@ Value *ConstantPtrAuth::handleOperandChangeImpl(Value *From, Value *ToV) { assert(isa(ToV) && "Cannot make Constant refer to non-constant!"); Constant *To = cast(ToV); - SmallVector Values; + SmallVector Values; Values.reserve(getNumOperands()); unsigned NumUpdated = 0; - - Use *OperandList = getOperandList(); unsigned OperandNo = 0; - for (Use *O = OperandList, *E = OperandList + getNumOperands(); O != E; ++O) { - Constant *Val = cast(O->get()); + + for (unsigned I = 0, N = getNumOperands(); I < N; ++I) { + Constant *Val = cast(getOperand(I)); if (Val == From) { - OperandNo = (O - OperandList); + OperandNo = I; Val = To; ++NumUpdated; } @@ -2144,11 +2151,7 @@ Value *ConstantPtrAuth::handleOperandChangeImpl(Value *From, Value *ToV) { } bool ConstantPtrAuth::hasSpecialAddressDiscriminator(uint64_t Value) const { - const auto *CastV = dyn_cast(getAddrDiscriminator()); - if (!CastV || CastV->getOpcode() != Instruction::IntToPtr) - return false; - - const auto *IntVal = dyn_cast(CastV->getOperand(0)); + const auto *IntVal = dyn_cast(getAddrDiscriminator()); if (!IntVal) return false; @@ -2162,51 +2165,43 @@ bool ConstantPtrAuth::isKnownCompatibleWith(ArrayRef BundleOperands, if (!getDeactivationSymbol()->isNullValue()) return false; - // FIXME: Generalize ptrauth constants to arbitrary schemas instead of - // assuming AArch64-style blend. - if (BundleOperands.size() != 3) - return false; + auto CompatibleOperands = [&DL](Value *This, Value *Other) { + if (This == Other) + return true; - ConstantInt *Key = dyn_cast(BundleOperands[0]); - Value *IntDiscriminator = BundleOperands[1]; - Value *AddrDiscriminator = BundleOperands[2]; + // If This and Other are not trivially equal, try analyzing pointers. + if (!isa(This) || !isa(Other)) + return false; + This = cast(This)->getPointerOperand(); + Other = cast(Other)->getPointerOperand(); - // FIXME: Use i64 consistently. - if (!Key || Key->getZExtValue() != getKey()->getZExtValue()) - return false; + // Reject incompatible pointer types (different address spaces). + if (This->getType() != Other->getType()) + return false; + unsigned AddressBitWidth = DL.getIndexTypeSizeInBits(This->getType()); - if (getDiscriminator() != IntDiscriminator) - return false; + // Check if two pointers are equivalent base+offset expressions. + APInt Off1(AddressBitWidth, 0); + auto *Base1 = This->stripAndAccumulateConstantOffsets( + DL, Off1, /*AllowNonInbounds=*/true); - // We can now focus on comparing the address discriminators. + APInt Off2(AddressBitWidth, 0); + auto *Base2 = Other->stripAndAccumulateConstantOffsets( + DL, Off2, /*AllowNonInbounds=*/true); - if (isa(AddrDiscriminator) && - cast(AddrDiscriminator)->isZero() && - getAddrDiscriminator()->isNullValue()) - return true; + return Base1 == Base2 && Off1 == Off2; + }; - // Discriminators are i64, so the provided addr disc may be a ptrtoint. - if (auto *Cast = dyn_cast(AddrDiscriminator)) - AddrDiscriminator = Cast->getPointerOperand(); - // Beyond that, we're only interested in compatible pointers. - if (getAddrDiscriminator()->getType() != AddrDiscriminator->getType()) + if (getSchema().size() != BundleOperands.size()) return false; - // These are often the same constant GEP, making them trivially equivalent. - if (getAddrDiscriminator() == AddrDiscriminator) - return true; - - // Finally, they may be equivalent base+offset expressions. - APInt Off1(DL.getIndexTypeSizeInBits(getAddrDiscriminator()->getType()), 0); - auto *Base1 = getAddrDiscriminator()->stripAndAccumulateConstantOffsets( - DL, Off1, /*AllowNonInbounds=*/true); - - APInt Off2(DL.getIndexTypeSizeInBits(AddrDiscriminator->getType()), 0); - auto *Base2 = AddrDiscriminator->stripAndAccumulateConstantOffsets( - DL, Off2, /*AllowNonInbounds=*/true); + for (unsigned I = 0, N = getSchema().size(); I < N; ++I) { + if (!CompatibleOperands(getSchema()[I], BundleOperands[I])) + return false; + } - return Base1 == Base2 && Off1 == Off2; + return true; } //---- ConstantExpr::get() implementations. diff --git a/llvm/lib/IR/ConstantsContext.h b/llvm/lib/IR/ConstantsContext.h index 2073e0d42d8e3..abdf535d0396e 100644 --- a/llvm/lib/IR/ConstantsContext.h +++ b/llvm/lib/IR/ConstantsContext.h @@ -505,42 +505,52 @@ struct ConstantExprKeyType { }; struct ConstantPtrAuthKeyType { - ArrayRef Operands; + Constant *Ptr; + ArrayRef Schema; + Constant *DeactivationSymbol; - ConstantPtrAuthKeyType(ArrayRef Operands) : Operands(Operands) {} + ConstantPtrAuthKeyType(Constant *Ptr, ArrayRef Schema, + Constant *DeactivationSymbol) + : Ptr(Ptr), Schema(Schema), DeactivationSymbol(DeactivationSymbol) {} ConstantPtrAuthKeyType(ArrayRef Operands, const ConstantPtrAuth *) - : Operands(Operands) {} + : Ptr(Operands[0]), Schema(Operands.drop_front(2)), + DeactivationSymbol(Operands[1]) {} ConstantPtrAuthKeyType(const ConstantPtrAuth *C, SmallVectorImpl &Storage) { assert(Storage.empty() && "Expected empty storage"); for (unsigned I = 0, E = C->getNumOperands(); I != E; ++I) Storage.push_back(cast(C->getOperand(I))); - Operands = Storage; + Ptr = Storage[0]; + DeactivationSymbol = Storage[1]; + Schema = ArrayRef(Storage).drop_front(2); } bool operator==(const ConstantPtrAuthKeyType &X) const { - return Operands == X.Operands; + return Ptr == X.Ptr && Schema == X.Schema && + DeactivationSymbol == X.DeactivationSymbol; } bool operator==(const ConstantPtrAuth *C) const { - if (Operands.size() != C->getNumOperands()) + if (Ptr != C->getPointer() || + Schema.size() != C->getSchema().size() || + DeactivationSymbol != C->getDeactivationSymbol()) return false; - for (unsigned I = 0, E = Operands.size(); I != E; ++I) - if (Operands[I] != C->getOperand(I)) + for (auto [A, B] : llvm::zip_equal(Schema, C->getSchema())) + if (A != B) return false; return true; } - unsigned getHash() const { return hash_combine_range(Operands); } + unsigned getHash() const { return hash_combine(Ptr, hash_combine_range(Schema), DeactivationSymbol); } using TypeClass = ConstantInfo::TypeClass; ConstantPtrAuth *create(TypeClass *Ty) const { - return new ConstantPtrAuth(Operands[0], cast(Operands[1]), - cast(Operands[2]), Operands[3], - Operands[4]); + unsigned NumVals = Schema.size() + 2; + User::IntrusiveOperandsAllocMarker AllocMarker{NumVals}; + return new (AllocMarker) ConstantPtrAuth(Ptr, Schema, DeactivationSymbol, AllocMarker); } }; diff --git a/llvm/lib/IR/Core.cpp b/llvm/lib/IR/Core.cpp index 26c4f4ec784cd..f32bd2ccd2951 100644 --- a/llvm/lib/IR/Core.cpp +++ b/llvm/lib/IR/Core.cpp @@ -920,6 +920,15 @@ LLVMValueRef LLVMGetConstantPtrAuthPointer(LLVMValueRef PtrAuth) { return wrap(unwrap(PtrAuth)->getPointer()); } +LLVM_C_ABI unsigned LLVMGetConstantPtrAuthSchemaSize(LLVMValueRef PtrAuth) { + return unwrap(PtrAuth)->getSchema().size(); +} + +LLVM_C_ABI LLVMValueRef +LLVMGetConstantPtrAuthSchemaOperand(LLVMValueRef PtrAuth, unsigned Idx) { + return wrap(unwrap(PtrAuth)->getSchema()[Idx]); +} + LLVMValueRef LLVMGetConstantPtrAuthKey(LLVMValueRef PtrAuth) { return wrap(unwrap(PtrAuth)->getKey()); } @@ -932,6 +941,11 @@ LLVMValueRef LLVMGetConstantPtrAuthAddrDiscriminator(LLVMValueRef PtrAuth) { return wrap(unwrap(PtrAuth)->getAddrDiscriminator()); } +LLVM_C_ABI LLVMValueRef +LLVMGetConstantPtrAuthDeactivationSymbol(LLVMValueRef PtrAuth) { + return wrap(unwrap(PtrAuth)->getDeactivationSymbol()); +} + /*--.. Operations on other types ...........................................--*/ LLVMTypeRef LLVMPointerTypeInContext(LLVMContextRef C, unsigned AddressSpace) { @@ -1695,13 +1709,16 @@ LLVMValueRef LLVMConstVector(LLVMValueRef *ScalarConstantVals, unsigned Size) { ArrayRef(unwrap(ScalarConstantVals, Size), Size))); } -LLVMValueRef LLVMConstantPtrAuth(LLVMValueRef Ptr, LLVMValueRef Key, - LLVMValueRef Disc, LLVMValueRef AddrDisc) { +LLVMValueRef LLVMConstantPtrAuth(LLVMValueRef Ptr, LLVMValueRef *Schema, + unsigned SchemaSize, + LLVMValueRef DeactivationSymbol) { + SmallVector SchemaUnwrapped; + for (unsigned I = 0; I < SchemaSize; ++I) + SchemaUnwrapped.push_back(unwrap(Schema[I])); + return wrap(ConstantPtrAuth::get( - unwrap(Ptr), unwrap(Key), - unwrap(Disc), unwrap(AddrDisc), - ConstantPointerNull::get( - cast(unwrap(AddrDisc)->getType())))); + unwrap(Ptr), SchemaUnwrapped, + unwrap(DeactivationSymbol))); } /*-- Opcode mapping */ diff --git a/llvm/lib/IR/Verifier.cpp b/llvm/lib/IR/Verifier.cpp index 27cdc399a5d7c..431db9c4bbd2f 100644 --- a/llvm/lib/IR/Verifier.cpp +++ b/llvm/lib/IR/Verifier.cpp @@ -2719,27 +2719,24 @@ void Verifier::visitConstantExpr(const ConstantExpr *CE) { void Verifier::visitConstantPtrAuth(const ConstantPtrAuth *CPA) { Check(CPA->getPointer()->getType()->isPointerTy(), - "signed ptrauth constant base pointer must have pointer type"); + "ptrauth constant base pointer must have pointer type", CPA); Check(CPA->getType() == CPA->getPointer()->getType(), - "signed ptrauth constant must have same type as its base pointer"); + "ptrauth constant must have same type as its base pointer", CPA); - Check(CPA->getKey()->getBitWidth() == 32, - "signed ptrauth constant key must be i32 constant integer"); - - Check(CPA->getAddrDiscriminator()->getType()->isPointerTy(), - "signed ptrauth constant address discriminator must be a pointer"); - - Check(CPA->getDiscriminator()->getBitWidth() == 64, - "signed ptrauth constant discriminator must be i64 constant integer"); + Check(!CPA->getSchema().empty(), + "ptrauth constant must not have empty schema"); + for (Value *V : CPA->getSchema()) + Check(V->getType()->isIntegerTy(64), + "ptrauth constant schema must have i64 constant operands", CPA); Check(CPA->getDeactivationSymbol()->getType()->isPointerTy(), - "signed ptrauth constant deactivation symbol must be a pointer"); + "ptrauth constant deactivation symbol must be a pointer", CPA); Check(isa(CPA->getDeactivationSymbol()) || CPA->getDeactivationSymbol()->isNullValue(), - "signed ptrauth constant deactivation symbol must be a global value " - "or null"); + "ptrauth constant deactivation symbol must be a global value or null", + CPA); } bool Verifier::verifyAttributeCount(AttributeList Attrs, unsigned Params) { diff --git a/llvm/lib/SandboxIR/Constant.cpp b/llvm/lib/SandboxIR/Constant.cpp index eb14797af081c..52e8b657ba9a0 100644 --- a/llvm/lib/SandboxIR/Constant.cpp +++ b/llvm/lib/SandboxIR/Constant.cpp @@ -411,12 +411,22 @@ PointerType *NoCFIValue::getType() const { return cast(Ctx.getType(cast(Val)->getType())); } -ConstantPtrAuth *ConstantPtrAuth::get(Constant *Ptr, ConstantInt *Key, - ConstantInt *Disc, Constant *AddrDisc, +ConstantPtrAuth *ConstantPtrAuth::get(Constant *Ptr, ConstantArray *Schema, Constant *DeactivationSymbol) { auto *LLVMC = llvm::ConstantPtrAuth::get( - cast(Ptr->Val), cast(Key->Val), - cast(Disc->Val), cast(AddrDisc->Val), + cast(Ptr->Val), cast(Schema->Val), + cast(DeactivationSymbol->Val)); + return cast(Ptr->getContext().getOrCreateConstant(LLVMC)); +} + +ConstantPtrAuth *ConstantPtrAuth::get(Constant *Ptr, + ArrayRef Schema, + Constant *DeactivationSymbol) { + SmallVector LLVMSchema; + for (Constant *C : Schema) + LLVMSchema.push_back(cast(C->Val)); + auto *LLVMC = llvm::ConstantPtrAuth::get( + cast(Ptr->Val), LLVMSchema, cast(DeactivationSymbol->Val)); return cast(Ptr->getContext().getOrCreateConstant(LLVMC)); } @@ -426,6 +436,11 @@ Constant *ConstantPtrAuth::getPointer() const { cast(Val)->getPointer()); } +// ConstantArray *ConstantPtrAuth::getSchema() const { + // return cast( + // Ctx.getOrCreateConstant(cast(Val)->getSchema())); +// } + ConstantInt *ConstantPtrAuth::getKey() const { return cast( Ctx.getOrCreateConstant(cast(Val)->getKey())); diff --git a/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp b/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp index 42e63cb3386db..0aa634b015bd4 100644 --- a/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp +++ b/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp @@ -10943,8 +10943,8 @@ SDValue AArch64TargetLowering::LowerGlobalTLSAddress(SDValue Op, // checks. static SDValue LowerPtrAuthGlobalAddressStatically( - SDValue TGA, SDLoc DL, EVT VT, AArch64PACKey::ID KeyC, - SDValue Discriminator, SDValue AddrDiscriminator, SelectionDAG &DAG) { + SDValue TGA, SDLoc DL, EVT VT, SDValue Key, SDValue Discriminator, + SDValue AddrDiscriminator, SelectionDAG &DAG) { const auto *TGN = cast(TGA.getNode()); assert(TGN->getGlobal()->hasExternalWeakLinkage()); @@ -10956,10 +10956,10 @@ static SDValue LowerPtrAuthGlobalAddressStatically( report_fatal_error( "unsupported non-zero offset in weak ptrauth global reference"); - if (!isNullConstant(AddrDiscriminator)) + auto *AddrDiscReg = dyn_cast(AddrDiscriminator); + if (!AddrDiscReg || AddrDiscReg->getReg() != AArch64::NoRegister) report_fatal_error("unsupported weak addr-div ptrauth global"); - SDValue Key = DAG.getTargetConstant(KeyC, DL, MVT::i32); return SDValue(DAG.getMachineNode(AArch64::LOADauthptrstatic, DL, MVT::i64, {TGA, Key, Discriminator}), 0); @@ -10968,21 +10968,13 @@ static SDValue LowerPtrAuthGlobalAddressStatically( SDValue AArch64TargetLowering::LowerPtrAuthGlobalAddress(SDValue Op, SelectionDAG &DAG) const { + const AArch64SelectionDAGInfo *SDI = Subtarget->getSelectionDAGInfo(); SDValue Ptr = Op.getOperand(0); - uint64_t KeyC = Op.getConstantOperandVal(1); - SDValue AddrDiscriminator = Op.getOperand(2); - uint64_t DiscriminatorC = Op.getConstantOperandVal(3); EVT VT = Op.getValueType(); SDLoc DL(Op); - if (KeyC > AArch64PACKey::LAST) - report_fatal_error("key in ptrauth global out of range [0, " + - Twine((int)AArch64PACKey::LAST) + "]"); - - // Blend only works if the integer discriminator is 16-bit wide. - if (!isUInt<16>(DiscriminatorC)) - report_fatal_error( - "constant discriminator in ptrauth global out of range [0, 0xffff]"); + auto [Key, Discriminator, AddrDiscriminator] = + SDI->extractPtrauthBlendDiscriminators(Op.getOperand(1), &DAG); // Choosing between 3 lowering alternatives is target-specific. if (!Subtarget->isTargetELF() && !Subtarget->isTargetMachO()) @@ -11010,8 +11002,6 @@ AArch64TargetLowering::LowerPtrAuthGlobalAddress(SDValue Op, assert(PtrN->getTargetFlags() == 0 && "unsupported target flags on ptrauth global"); - SDValue Key = DAG.getTargetConstant(KeyC, DL, MVT::i32); - SDValue Discriminator = DAG.getTargetConstant(DiscriminatorC, DL, MVT::i64); SDValue TAddrDiscriminator = !isNullConstant(AddrDiscriminator) ? AddrDiscriminator : DAG.getRegister(AArch64::XZR, MVT::i64); @@ -11035,8 +11025,7 @@ AArch64TargetLowering::LowerPtrAuthGlobalAddress(SDValue Op, // extern_weak ref -> LOADauthptrstatic return LowerPtrAuthGlobalAddressStatically( - TPtr, DL, VT, (AArch64PACKey::ID)KeyC, Discriminator, AddrDiscriminator, - DAG); + TPtr, DL, VT, Key, Discriminator, AddrDiscriminator, DAG); } // Looks through \param Val to determine the bit that can be used to @@ -29946,9 +29935,11 @@ bool AArch64TargetLowering::preferSelectsOverBooleanArithmetic(EVT VT) const { } std::optional -AArch64TargetLowering::validatePtrAuthSchema(const CallBase &CB) const { - auto GetMsg = [&CB](Twine Str) -> std::string { - return (CB.getFunction()->getName() + ": " + Str).str(); +AArch64TargetLowering::validatePtrAuthSchema(const Value &V) const { + auto GetMsg = [&V](Twine Str) -> std::string { + if (auto *CB = dyn_cast(&V)) + return (CB->getFunction()->getName() + ": " + Str).str(); + return Str.str(); }; auto ValidateSchema = [&](ArrayRef Schema, bool ExpectSingleElement) -> std::optional{ @@ -29978,17 +29969,22 @@ AArch64TargetLowering::validatePtrAuthSchema(const CallBase &CB) const { return std::nullopt; }; - for (unsigned I = 0, N = CB.getNumOperandBundles(); I < N; ++I) { - OperandBundleUse OB = CB.getOperandBundleAt(I); - if (OB.getTagID() != LLVMContext::OB_ptrauth) - continue; + if (auto *CB = dyn_cast(&V)) { + for (unsigned I = 0, N = CB->getNumOperandBundles(); I < N; ++I) { + OperandBundleUse OB = CB->getOperandBundleAt(I); + if (OB.getTagID() != LLVMContext::OB_ptrauth) + continue; - bool ExpectSingleElement = - CB.getIntrinsicID() == Intrinsic::ptrauth_strip; - if (auto Err = ValidateSchema(OB.Inputs, ExpectSingleElement)) - return Err; + bool ExpectSingleElement = + CB->getIntrinsicID() == Intrinsic::ptrauth_strip; + if (auto Err = ValidateSchema(OB.Inputs, ExpectSingleElement)) + return Err; + } + return std::nullopt; } - return std::nullopt; + + auto &CPA = cast(V); + return ValidateSchema(CPA.getSchema(), /*ExpectSingleElement=*/false); } MachineInstr * diff --git a/llvm/lib/Target/AArch64/AArch64ISelLowering.h b/llvm/lib/Target/AArch64/AArch64ISelLowering.h index 3524d066e4b59..34081ed2d5072 100644 --- a/llvm/lib/Target/AArch64/AArch64ISelLowering.h +++ b/llvm/lib/Target/AArch64/AArch64ISelLowering.h @@ -466,7 +466,7 @@ class AArch64TargetLowering : public TargetLowering { } std::optional - validatePtrAuthSchema(const CallBase &CB) const override; + validatePtrAuthSchema(const Value &V) const override; bool supportKCFIBundles() const override { return true; } diff --git a/llvm/lib/Target/AArch64/GISel/AArch64InstructionSelector.cpp b/llvm/lib/Target/AArch64/GISel/AArch64InstructionSelector.cpp index 1cf9683b45180..612059267d346 100644 --- a/llvm/lib/Target/AArch64/GISel/AArch64InstructionSelector.cpp +++ b/llvm/lib/Target/AArch64/GISel/AArch64InstructionSelector.cpp @@ -6803,19 +6803,11 @@ bool AArch64InstructionSelector::selectPtrAuthGlobalValue( MachineInstr &I, MachineRegisterInfo &MRI) const { Register DefReg = I.getOperand(0).getReg(); Register Addr = I.getOperand(1).getReg(); - uint64_t Key = I.getOperand(2).getImm(); - Register AddrDisc = I.getOperand(3).getReg(); - uint64_t Disc = I.getOperand(4).getImm(); + Register Schema = I.getOperand(2).getReg(); int64_t Offset = 0; - if (Key > AArch64PACKey::LAST) - report_fatal_error("key in ptrauth global out of range [0, " + - Twine((int)AArch64PACKey::LAST) + "]"); - - // Blend only works if the integer discriminator is 16-bit wide. - if (!isUInt<16>(Disc)) - report_fatal_error( - "constant discriminator in ptrauth global out of range [0, 0xffff]"); + auto [Key, Disc, AddrDisc] = + extractPtrauthBlendDiscriminators(Schema, MRI); // Choosing between 3 lowering alternatives is target-specific. if (!STI.isTargetELF() && !STI.isTargetMachO()) @@ -6864,8 +6856,7 @@ bool AArch64InstructionSelector::selectPtrAuthGlobalValue( assert((!GV->hasExternalWeakLinkage() || NeedsGOTLoad) && "unsupported non-GOT reference to weak ptrauth global"); - std::optional AddrDiscVal = getIConstantVRegVal(AddrDisc, MRI); - bool HasAddrDisc = !AddrDiscVal || *AddrDiscVal != 0; + bool HasAddrDisc = AddrDisc != AArch64::NoRegister; // Non-extern_weak: // - No GOT load needed -> MOVaddrPAC @@ -6877,7 +6868,7 @@ bool AArch64InstructionSelector::selectPtrAuthGlobalValue( MIB.buildInstr(NeedsGOTLoad ? AArch64::LOADgotPAC : AArch64::MOVaddrPAC) .addGlobalAddress(GV, Offset) .addImm(Key) - .addReg(HasAddrDisc ? AddrDisc : AArch64::XZR) + .addReg(HasAddrDisc ? AddrDisc : AArch64::XZR) // FIXME Use NoRegister instead? .addImm(Disc) .constrainAllUses(TII, TRI, RBI); MIB.buildCopy(DefReg, Register(AArch64::X16)); diff --git a/llvm/lib/Target/AArch64/GISel/AArch64LegalizerInfo.cpp b/llvm/lib/Target/AArch64/GISel/AArch64LegalizerInfo.cpp index 001d8edcd613c..d56f803167e97 100644 --- a/llvm/lib/Target/AArch64/GISel/AArch64LegalizerInfo.cpp +++ b/llvm/lib/Target/AArch64/GISel/AArch64LegalizerInfo.cpp @@ -1018,7 +1018,7 @@ AArch64LegalizerInfo::AArch64LegalizerInfo(const AArch64Subtarget &ST) getActionDefinitionsBuilder(G_GLOBAL_VALUE).legalFor({p0}); getActionDefinitionsBuilder(G_PTRAUTH_GLOBAL_VALUE) - .legalIf(all(typeIs(0, p0), typeIs(1, p0))); + .legalForTypeWithAnyImm({p0}); getActionDefinitionsBuilder(G_PTRAUTH_BUNDLE).legalForTypeWithAnyImm({s64}); getActionDefinitionsBuilder(G_PTRAUTH_AUTH).legalForTypeWithAnyImm({s64}); @@ -2512,4 +2512,4 @@ bool AArch64LegalizerInfo::legalizeFptrunc(MachineInstr &MI, MRI.replaceRegWith(Dst, Fin); MI.eraseFromParent(); return true; -} \ No newline at end of file +} diff --git a/llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp b/llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp index 6802435b79d3e..647b635b38464 100644 --- a/llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp +++ b/llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp @@ -3120,20 +3120,17 @@ Instruction *InstCombinerImpl::visitCallInst(CallInst &CI) { if (NeedSign) { auto ThisSignSchema = II->getOperandBundleAt(1); // resign(ptrauth(p,ks,ds),ks,ds,kr,dr) -> ptrauth(p,kr,dr) - // FIXME Generalize ptrauth constant and drop AArch64-specific - // assumptions. - if (ThisSignSchema.Inputs.size() == 3) { - auto *SignKey = dyn_cast(ThisSignSchema.Inputs[0]); - auto *SignIntDisc = dyn_cast(ThisSignSchema.Inputs[1]); + auto IsConstant = [](Value *V) { return isa(V); }; + if (llvm::all_of(ThisSignSchema.Inputs, IsConstant)) { auto *Null = ConstantPointerNull::get(Builder.getPtrTy()); - if (SignKey && SignIntDisc) { - auto *NewCPA = ConstantPtrAuth::get(CPA->getPointer(), SignKey, - SignIntDisc, /*AddrDisc=*/Null, - /*DeactivationSymbol=*/Null); - replaceInstUsesWith( + SmallVector Ops; + for (Value *V : ThisSignSchema.Inputs) + Ops.push_back(cast(V)); + auto *NewCPA = ConstantPtrAuth::get(CPA->getPointer(), Ops, + /*DeactivationSymbol=*/Null); + replaceInstUsesWith( *II, ConstantExpr::getPointerCast(NewCPA, II->getType())); return eraseInstFromFunction(*II); - } } } diff --git a/llvm/lib/Transforms/Utils/ValueMapper.cpp b/llvm/lib/Transforms/Utils/ValueMapper.cpp index 6e36006890df4..b6fa5a00b0bae 100644 --- a/llvm/lib/Transforms/Utils/ValueMapper.cpp +++ b/llvm/lib/Transforms/Utils/ValueMapper.cpp @@ -527,8 +527,8 @@ Value *Mapper::mapValue(const Value *V) { return getVM()[V] = ConstantVector::get(Ops); if (isa(C)) return getVM()[V] = - ConstantPtrAuth::get(Ops[0], cast(Ops[1]), - cast(Ops[2]), Ops[3], Ops[4]); + ConstantPtrAuth::get(Ops[0], ArrayRef(Ops).drop_front(2), + Ops[1]); // If this is a no-operand constant, it must be because the type was remapped. if (isa(C)) return getVM()[V] = PoisonValue::get(NewTy); diff --git a/llvm/test/Assembler/invalid-ptrauth-const1.ll b/llvm/test/Assembler/invalid-ptrauth-const1.ll index fba2e23078238..7ab292eec11c8 100644 --- a/llvm/test/Assembler/invalid-ptrauth-const1.ll +++ b/llvm/test/Assembler/invalid-ptrauth-const1.ll @@ -2,5 +2,5 @@ @var = global i32 0 -; CHECK: error: constant ptrauth base pointer must be a pointer -@auth_var = global ptr ptrauth (i32 42, i32 0) +; CHECK: error: base pointer of ptrauth constant must be a pointer +@auth_var = global ptr ptrauth (i32 42, [i64 0, i64 0, i64 0]) diff --git a/llvm/test/Assembler/invalid-ptrauth-const2.ll b/llvm/test/Assembler/invalid-ptrauth-const2.ll index 4499c42601c99..985d36d54c7d6 100644 --- a/llvm/test/Assembler/invalid-ptrauth-const2.ll +++ b/llvm/test/Assembler/invalid-ptrauth-const2.ll @@ -2,5 +2,5 @@ @var = global i32 0 -; CHECK: error: constant ptrauth key must be i32 constant -@auth_var = global ptr ptrauth (ptr @var, i32 ptrtoint (ptr @var to i32)) +; CHECK: error: schema of ptrauth constant must be a tuple of i64 +@auth_var = global ptr ptrauth (ptr @var, [i32 0, i64 0, i64 0]) diff --git a/llvm/test/Assembler/invalid-ptrauth-const3.ll b/llvm/test/Assembler/invalid-ptrauth-const3.ll index 3f2688d92a001..fc82ac90d2585 100644 --- a/llvm/test/Assembler/invalid-ptrauth-const3.ll +++ b/llvm/test/Assembler/invalid-ptrauth-const3.ll @@ -2,5 +2,5 @@ @var = global i32 0 -; CHECK: error: constant ptrauth address discriminator must be a pointer -@auth_var = global ptr ptrauth (ptr @var, i32 2, i64 65535, i8 0) +; CHECK: error: schema of ptrauth constant must be a tuple of i64 +@auth_var = global ptr ptrauth (ptr @var, [i64 0, i64 0, ptr null]) diff --git a/llvm/test/Assembler/invalid-ptrauth-const4.ll b/llvm/test/Assembler/invalid-ptrauth-const4.ll index 843a220458a61..b4fa2dc157cc3 100644 --- a/llvm/test/Assembler/invalid-ptrauth-const4.ll +++ b/llvm/test/Assembler/invalid-ptrauth-const4.ll @@ -2,5 +2,5 @@ @var = global i32 0 -; CHECK: error: constant ptrauth integer discriminator must be i64 constant -@auth_var = global ptr ptrauth (ptr @var, i32 2, ptr null, i64 ptrtoint (ptr @var to i64)) +; CHECK: error: schema of ptrauth constant must not be empty +@auth_var = global ptr ptrauth (ptr @var, []) diff --git a/llvm/test/Assembler/invalid-ptrauth-const5.ll b/llvm/test/Assembler/invalid-ptrauth-const5.ll deleted file mode 100644 index 9b47f6f5f423f..0000000000000 --- a/llvm/test/Assembler/invalid-ptrauth-const5.ll +++ /dev/null @@ -1,6 +0,0 @@ -; RUN: not llvm-as < %s 2>&1 | FileCheck %s - -@var = global i32 0 - -; CHECK: error: constant ptrauth integer discriminator must be i64 constant -@auth_var = global ptr ptrauth (ptr @var, i32 2, ptr @var)) diff --git a/llvm/test/Assembler/invalid-ptrauth-const6.ll b/llvm/test/Assembler/invalid-ptrauth-const6.ll index 6e8e1d386acc8..b9e17fc61481a 100644 --- a/llvm/test/Assembler/invalid-ptrauth-const6.ll +++ b/llvm/test/Assembler/invalid-ptrauth-const6.ll @@ -3,4 +3,4 @@ @var = global i32 0 ; CHECK: error: constant ptrauth deactivation symbol must be a pointer -@ptr = global ptr ptrauth (ptr @var, i32 0, i64 65535, ptr null, i64 0) +@ptr = global ptr ptrauth (ptr @var, [i64 0, i64 65535, i64 0], i64 0) diff --git a/llvm/test/Assembler/ptrauth-const.ll b/llvm/test/Assembler/ptrauth-const.ll index 94d35146d5927..1425db573ba98 100644 --- a/llvm/test/Assembler/ptrauth-const.ll +++ b/llvm/test/Assembler/ptrauth-const.ll @@ -2,23 +2,23 @@ @var = global i32 0 -; CHECK: @basic = global ptr ptrauth (ptr @var, i32 0) -@basic = global ptr ptrauth (ptr @var, i32 0) +; CHECK: @basic = global ptr ptrauth (ptr @var, [i64 0, i64 0, i64 0]) +@basic = global ptr ptrauth (ptr @var, [i64 0, i64 0, i64 0]) -; CHECK: @keyed = global ptr ptrauth (ptr @var, i32 3) -@keyed = global ptr ptrauth (ptr @var, i32 3) +; CHECK: @keyed = global ptr ptrauth (ptr @var, [i64 3, i64 0, i64 0]) +@keyed = global ptr ptrauth (ptr @var, [i64 3, i64 0, i64 0]) -; CHECK: @intdisc = global ptr ptrauth (ptr @var, i32 0, i64 -1) -@intdisc = global ptr ptrauth (ptr @var, i32 0, i64 -1) +; CHECK: @intdisc = global ptr ptrauth (ptr @var, [i64 0, i64 -1, i64 0]) +@intdisc = global ptr ptrauth (ptr @var, [i64 0, i64 -1, i64 0]) -; CHECK: @addrdisc = global ptr ptrauth (ptr @var, i32 2, i64 1234, ptr @addrdisc) -@addrdisc = global ptr ptrauth (ptr @var, i32 2, i64 1234, ptr @addrdisc) +; CHECK: @addrdisc = global ptr ptrauth (ptr @var, [i64 2, i64 1234, i64 ptrtoint (ptr @addrdisc to i64)]) +@addrdisc = global ptr ptrauth (ptr @var, [i64 2, i64 1234, i64 ptrtoint (ptr @addrdisc to i64)]) @var1 = addrspace(1) global i32 0 -; CHECK: @addrspace = global ptr addrspace(1) ptrauth (ptr addrspace(1) @var1, i32 0) -@addrspace = global ptr addrspace(1) ptrauth (ptr addrspace(1) @var1, i32 0) +; CHECK: @addrspace = global ptr addrspace(1) ptrauth (ptr addrspace(1) @var1, [i64 0, i64 0, i64 0]) +@addrspace = global ptr addrspace(1) ptrauth (ptr addrspace(1) @var1, [i64 0, i64 0, i64 0]) -; CHECK: @addrspace_addrdisc = addrspace(2) global ptr addrspace(1) ptrauth (ptr addrspace(1) @var1, i32 2, i64 1234, ptr addrspace(2) @addrspace_addrdisc) -@addrspace_addrdisc = addrspace(2) global ptr addrspace(1) ptrauth (ptr addrspace(1) @var1, i32 2, i64 1234, ptr addrspace(2) @addrspace_addrdisc) +; CHECK: @addrspace_addrdisc = addrspace(2) global ptr addrspace(1) ptrauth (ptr addrspace(1) @var1, [i64 2, i64 1234, i64 ptrtoint (ptr addrspace(2) @addrspace_addrdisc to i64)]) +@addrspace_addrdisc = addrspace(2) global ptr addrspace(1) ptrauth (ptr addrspace(1) @var1, [i64 2, i64 1234, i64 ptrtoint (ptr addrspace(2) @addrspace_addrdisc to i64)]) diff --git a/llvm/test/Bindings/llvm-c/echo.ll b/llvm/test/Bindings/llvm-c/echo.ll index ab1771d1f879f..c5dea6dbfeee3 100644 --- a/llvm/test/Bindings/llvm-c/echo.ll +++ b/llvm/test/Bindings/llvm-c/echo.ll @@ -40,8 +40,8 @@ module asm "classical GAS" @ptrauth_addr_disc = global i32 0 @ptrauth_data = global i32 0 -@ptrauth_ptr_01 = global ptr ptrauth (ptr @ptrauth_data, i32 77, i64 1001, ptr @ptrauth_addr_disc) -@ptrauth_ptr_02 = global ptr ptrauth (ptr @ptrauth_data, i32 11, i64 99, ptr null) +@ptrauth_ptr_01 = global ptr ptrauth (ptr @ptrauth_data, [i64 77, i64 1001, i64 ptrtoint (ptr @ptrauth_addr_disc to i64)]) +@ptrauth_ptr_02 = global ptr ptrauth (ptr @ptrauth_data, [i64 11, i64 99, i64 0]) define ptr @ifunc_resolver() { entry: diff --git a/llvm/test/Bitcode/compatibility.ll b/llvm/test/Bitcode/compatibility.ll index 53cbe2d6ffd37..84046c24c272b 100644 --- a/llvm/test/Bitcode/compatibility.ll +++ b/llvm/test/Bitcode/compatibility.ll @@ -220,10 +220,10 @@ declare void @g.f1() @ds = external global i32 ; ptrauth constant -@auth_var = global ptr ptrauth (ptr @g1, i32 0, i64 65535, ptr null) -; CHECK: @auth_var = global ptr ptrauth (ptr @g1, i32 0, i64 65535) -@auth_var.ds = global ptr ptrauth (ptr @g1, i32 0, i64 65535, ptr null, ptr @ds) -; CHECK: @auth_var.ds = global ptr ptrauth (ptr @g1, i32 0, i64 65535, ptr null, ptr @ds) +@auth_var = global ptr ptrauth (ptr @g1, [i64 0, i64 65535, i64 0]) +; CHECK: @auth_var = global ptr ptrauth (ptr @g1, [i64 0, i64 65535, i64 0]) +@auth_var.ds = global ptr ptrauth (ptr @g1, [i64 0, i64 65535, i64 0], ptr @ds) +; CHECK: @auth_var.ds = global ptr ptrauth (ptr @g1, [i64 0, i64 65535, i64 0], ptr @ds) ;; Aliases ; Format: @ = [Linkage] [Visibility] [DLLStorageClass] [ThreadLocal] diff --git a/llvm/test/CodeGen/AArch64/GlobalISel/legalizer-info-validation.mir b/llvm/test/CodeGen/AArch64/GlobalISel/legalizer-info-validation.mir index 672b837d35764..dd85fec0297e6 100644 --- a/llvm/test/CodeGen/AArch64/GlobalISel/legalizer-info-validation.mir +++ b/llvm/test/CodeGen/AArch64/GlobalISel/legalizer-info-validation.mir @@ -115,7 +115,7 @@ # DEBUG-NEXT: .. type index coverage check SKIPPED: user-defined predicate detected # DEBUG-NEXT: .. imm index coverage check SKIPPED: user-defined predicate detected # -# DEBUG-NEXT: G_PTRAUTH_GLOBAL_VALUE (opcode {{[0-9]+}}): 2 type indices, 0 imm indices +# DEBUG-NEXT: G_PTRAUTH_GLOBAL_VALUE (opcode {{[0-9]+}}): 1 type index, 1 imm index # DEBUG-NEXT: .. type index coverage check SKIPPED: user-defined predicate detected # DEBUG-NEXT: .. imm index coverage check SKIPPED: user-defined predicate detected # diff --git a/llvm/test/CodeGen/AArch64/GlobalISel/ptrauth-constant-in-code.ll b/llvm/test/CodeGen/AArch64/GlobalISel/ptrauth-constant-in-code.ll index 12a3448111fcb..5852c885ad4b5 100644 --- a/llvm/test/CodeGen/AArch64/GlobalISel/ptrauth-constant-in-code.ll +++ b/llvm/test/CodeGen/AArch64/GlobalISel/ptrauth-constant-in-code.ll @@ -2,34 +2,38 @@ ;--- err1.ll -; RUN: not --crash llc < err1.ll -mtriple aarch64-elf -mattr=+pauth \ +; RUN: not llc < err1.ll -mtriple aarch64-elf -mattr=+pauth \ ; RUN: -global-isel=1 -verify-machineinstrs -global-isel-abort=1 2>&1 | \ ; RUN: FileCheck --check-prefix=ERR1 %s -; RUN: not --crash llc < err1.ll -mtriple arm64-apple-ios -mattr=+pauth \ +; RUN: not llc < err1.ll -mtriple arm64-apple-ios -mattr=+pauth \ ; RUN: -global-isel=1 -verify-machineinstrs -global-isel-abort=1 2>&1 | \ ; RUN: FileCheck --check-prefix=ERR1 %s @g = external global i32 define ptr @foo() { -; ERR1: LLVM ERROR: key in ptrauth global out of range [0, 3] - ret ptr ptrauth (ptr @g, i32 4) +; ERR1: Ptrauth schema violates target-specific constraints: +; ERR1: ptr ptrauth (ptr @g, [i64 4, i64 0, i64 0]) +; ERR1: LLVM ERROR: Invalid ptrauth schema: key must be constant in range [0, 3] + ret ptr ptrauth (ptr @g, [i64 4, i64 0, i64 0]) } ;--- err2.ll -; RUN: not --crash llc < err2.ll -mtriple aarch64-elf -mattr=+pauth \ +; RUN: not llc < err2.ll -mtriple aarch64-elf -mattr=+pauth \ ; RUN: -global-isel=1 -verify-machineinstrs -global-isel-abort=1 2>&1 | \ ; RUN: FileCheck --check-prefix=ERR2 %s -; RUN: not --crash llc < err2.ll -mtriple arm64-apple-ios -mattr=+pauth \ +; RUN: not llc < err2.ll -mtriple arm64-apple-ios -mattr=+pauth \ ; RUN: -global-isel=1 -verify-machineinstrs -global-isel-abort=1 2>&1 | \ ; RUN: FileCheck --check-prefix=ERR2 %s @g = external global i32 define ptr @foo() { -; ERR2: LLVM ERROR: constant discriminator in ptrauth global out of range [0, 0xffff] - ret ptr ptrauth (ptr @g, i32 2, i64 65536) +; ERR2: Ptrauth schema violates target-specific constraints: +; ERR2: ptr ptrauth (ptr @g, [i64 2, i64 65536, i64 0]) +; ERR2: LLVM ERROR: Invalid ptrauth schema: constant modifier must be 16-bit unsigned constant + ret ptr ptrauth (ptr @g, [i64 2, i64 65536, i64 0]) } ;--- err3.ll @@ -45,7 +49,7 @@ define ptr @foo() { define ptr @foo() { ; ERR3: LLVM ERROR: unsupported non-zero offset in weak ptrauth global reference - ret ptr ptrauth (ptr getelementptr (i8, ptr @g_weak, i64 16), i32 2, i64 42) + ret ptr ptrauth (ptr getelementptr (i8, ptr @g_weak, i64 16), [i64 2, i64 42, i64 0]) } ;--- err4.ll @@ -58,11 +62,11 @@ define ptr @foo() { ; RUN: FileCheck --check-prefix=ERR4 %s @g_weak = extern_weak global i32 -@g_weak.ref.da.42.addr = dso_local constant ptr ptrauth (ptr @g_weak, i32 2, i64 42, ptr @g_weak.ref.da.42.addr) +@g_weak.ref.da.42.addr = dso_local constant ptr ptrauth (ptr @g_weak, [i64 2, i64 42, i64 ptrtoint (ptr @g_weak.ref.da.42.addr to i64)]) define ptr @foo() { ; ERR4: LLVM ERROR: unsupported weak addr-div ptrauth global - ret ptr ptrauth (ptr @g_weak, i32 0, i64 42, ptr @g_weak.ref.da.42.addr) + ret ptr ptrauth (ptr @g_weak, [i64 0, i64 42, i64 ptrtoint (ptr @g_weak.ref.da.42.addr to i64)]) } ;--- err5.ll @@ -75,7 +79,7 @@ define ptr @foo() { define ptr @foo() { ; ERR5: LLVM ERROR: ptrauth global lowering only supported on MachO/ELF - ret ptr ptrauth (ptr @g, i32 0) + ret ptr ptrauth (ptr @g, [i64 0, i64 0, i64 0]) } ;--- ok.ll @@ -113,7 +117,7 @@ define ptr @test_global_zero_disc() { ; MACHO-NEXT: mov x0, x16 ; MACHO-NEXT: ret - ret ptr ptrauth (ptr @g, i32 0) + ret ptr ptrauth (ptr @g, [i64 0, i64 0, i64 0]) } define ptr @test_global_offset_zero_disc() { @@ -135,7 +139,7 @@ define ptr @test_global_offset_zero_disc() { ; MACHO-NEXT: mov x0, x16 ; MACHO-NEXT: ret - ret ptr ptrauth (ptr getelementptr (i8, ptr @g, i64 16), i32 2) + ret ptr ptrauth (ptr getelementptr (i8, ptr @g, i64 16), [i64 2, i64 0, i64 0]) } define ptr @test_global_neg_offset_zero_disc() { @@ -159,7 +163,7 @@ define ptr @test_global_neg_offset_zero_disc() { ; MACHO-NEXT: mov x0, x16 ; MACHO-NEXT: ret - ret ptr ptrauth (ptr getelementptr (i8, ptr @g, i64 -123456), i32 2) + ret ptr ptrauth (ptr getelementptr (i8, ptr @g, i64 -123456), [i64 2, i64 0, i64 0]) } define ptr @test_global_big_offset_zero_disc() { @@ -185,7 +189,7 @@ define ptr @test_global_big_offset_zero_disc() { ; MACHO-NEXT: mov x0, x16 ; MACHO-NEXT: ret - ret ptr ptrauth (ptr getelementptr (i8, ptr @g, i64 add (i64 2147483648, i64 65537)), i32 2) + ret ptr ptrauth (ptr getelementptr (i8, ptr @g, i64 add (i64 2147483648, i64 65537)), [i64 2, i64 0, i64 0]) } define ptr @test_global_big_neg_offset_zero_disc() { @@ -211,7 +215,7 @@ define ptr @test_global_big_neg_offset_zero_disc() { ; MACHO-NEXT: mov x0, x16 ; MACHO-NEXT: ret - ret ptr ptrauth (ptr getelementptr (i8, ptr @g, i64 -123456789), i32 2) + ret ptr ptrauth (ptr getelementptr (i8, ptr @g, i64 -123456789), [i64 2, i64 0, i64 0]) } define ptr @test_global_huge_neg_offset_zero_disc() { @@ -241,7 +245,7 @@ define ptr @test_global_huge_neg_offset_zero_disc() { ; MACHO-NEXT: mov x0, x16 ; MACHO-NEXT: ret - ret ptr ptrauth (ptr getelementptr (i8, ptr @g, i64 -9223372036854775808), i32 2) + ret ptr ptrauth (ptr getelementptr (i8, ptr @g, i64 -9223372036854775808), [i64 2, i64 0, i64 0]) } define ptr @test_global_disc() { @@ -263,10 +267,10 @@ define ptr @test_global_disc() { ; MACHO-NEXT: mov x0, x16 ; MACHO-NEXT: ret - ret ptr ptrauth (ptr @g, i32 0, i64 42) + ret ptr ptrauth (ptr @g, [i64 0, i64 42, i64 0]) } -@g.ref.da.42.addr = dso_local constant ptr ptrauth (ptr @g, i32 2, i64 42, ptr @g.ref.da.42.addr) +@g.ref.da.42.addr = dso_local constant ptr ptrauth (ptr @g, [i64 2, i64 42, i64 ptrtoint (ptr @g.ref.da.42.addr to i64)]) define ptr @test_global_addr_disc() { ; ELF-LABEL: test_global_addr_disc: @@ -295,7 +299,7 @@ define ptr @test_global_addr_disc() { ; MACHO-NEXT: mov x0, x16 ; MACHO-NEXT: ret - ret ptr ptrauth (ptr @g, i32 2, i64 42, ptr @g.ref.da.42.addr) + ret ptr ptrauth (ptr @g, [i64 2, i64 42, i64 ptrtoint (ptr @g.ref.da.42.addr to i64)]) } define ptr @test_global_process_specific() { @@ -315,7 +319,7 @@ define ptr @test_global_process_specific() { ; MACHO-NEXT: mov x0, x16 ; MACHO-NEXT: ret - ret ptr ptrauth (ptr @g, i32 1) + ret ptr ptrauth (ptr @g, [i64 1, i64 0, i64 0]) } ; Non-external symbols don't need to be accessed through the GOT. @@ -337,7 +341,7 @@ define ptr @test_global_strong_def() { ; MACHO-NEXT: mov x0, x16 ; MACHO-NEXT: ret - ret ptr ptrauth (ptr @g_strong_def, i32 2) + ret ptr ptrauth (ptr @g_strong_def, [i64 2, i64 0, i64 0]) } ; weak symbols can't be assumed to be non-nil. Use $auth_ptr$ stub slot always. @@ -357,7 +361,7 @@ define ptr @test_global_weak() { ; MACHO-NEXT: ldr x0, [x0, l_g_weak$auth_ptr$ia$42@PAGEOFF] ; MACHO-NEXT: ret - ret ptr ptrauth (ptr @g_weak, i32 0, i64 42) + ret ptr ptrauth (ptr @g_weak, [i64 0, i64 42, i64 0]) } ; Test another weak symbol to check that stubs are emitted in a stable order. @@ -377,7 +381,7 @@ define ptr @test_global_weak_2() { ; MACHO-NEXT: ldr x0, [x0, l_g_weak_2$auth_ptr$ia$42@PAGEOFF] ; MACHO-NEXT: ret - ret ptr ptrauth (ptr @g_weak_2, i32 0, i64 42) + ret ptr ptrauth (ptr @g_weak_2, [i64 0, i64 42, i64 0]) } ; ELF-LABEL: g_weak$auth_ptr$ia$42: diff --git a/llvm/test/CodeGen/AArch64/ptrauth-basic-pic.ll b/llvm/test/CodeGen/AArch64/ptrauth-basic-pic.ll index 517a0a86ef14b..e54661e388338 100644 --- a/llvm/test/CodeGen/AArch64/ptrauth-basic-pic.ll +++ b/llvm/test/CodeGen/AArch64/ptrauth-basic-pic.ll @@ -79,7 +79,7 @@ define ptr @resign_globalfunc() { ; CHECK-NEXT: mov x0, x16 ; CHECK-NEXT: ret - ret ptr ptrauth (ptr @foo, i32 0, i64 42) + ret ptr ptrauth (ptr @foo, [i64 0, i64 42, i64 0]) } define ptr @resign_globalvar() { @@ -99,7 +99,7 @@ define ptr @resign_globalvar() { ; CHECK-NEXT: mov x0, x16 ; CHECK-NEXT: ret - ret ptr ptrauth (ptr @var, i32 3, i64 43) + ret ptr ptrauth (ptr @var, [i64 3, i64 43, i64 0]) } define ptr @resign_globalvar_offset() { @@ -120,7 +120,7 @@ define ptr @resign_globalvar_offset() { ; CHECK-NEXT: mov x0, x16 ; CHECK-NEXT: ret - ret ptr ptrauth (ptr getelementptr (i8, ptr @var, i64 16), i32 2, i64 44) + ret ptr ptrauth (ptr getelementptr (i8, ptr @var, i64 16), [i64 2, i64 44, i64 0]) } !llvm.module.flags = !{!0} diff --git a/llvm/test/CodeGen/AArch64/ptrauth-call.ll b/llvm/test/CodeGen/AArch64/ptrauth-call.ll index 98fd013642cc9..8430777352ddd 100644 --- a/llvm/test/CodeGen/AArch64/ptrauth-call.ll +++ b/llvm/test/CodeGen/AArch64/ptrauth-call.ll @@ -552,7 +552,7 @@ define i32 @test_direct_call() #0 { ; ELF-NEXT: bl f ; ELF-NEXT: ldr x30, [sp], #16 ; ELF-NEXT: ret - %tmp0 = call i32 ptrauth(ptr @f, i32 0, i64 42)() [ "ptrauth"(i64 0, i64 42, i64 0) ] + %tmp0 = call i32 ptrauth(ptr @f, [i64 0, i64 42, i64 0])() [ "ptrauth"(i64 0, i64 42, i64 0) ] ret i32 %tmp0 } @@ -562,7 +562,7 @@ define i32 @test_direct_tailcall(ptr %arg0) #0 { ; ; ELF-LABEL: test_direct_tailcall: ; ELF-NEXT: b f - %tmp0 = tail call i32 ptrauth(ptr @f, i32 0, i64 42)() [ "ptrauth"(i64 0, i64 42, i64 0) ] + %tmp0 = tail call i32 ptrauth(ptr @f, [i64 0, i64 42, i64 0])() [ "ptrauth"(i64 0, i64 42, i64 0) ] ret i32 %tmp0 } @@ -590,7 +590,7 @@ define i32 @test_direct_call_mismatch() #0 { ; ELF-NEXT: blrab x8, x17 ; ELF-NEXT: ldr x30, [sp], #16 ; ELF-NEXT: ret - %tmp0 = call i32 ptrauth(ptr @f, i32 0, i64 42)() [ "ptrauth"(i64 1, i64 42, i64 0) ] + %tmp0 = call i32 ptrauth(ptr @f, [i64 0, i64 42, i64 0])() [ "ptrauth"(i64 1, i64 42, i64 0) ] ret i32 %tmp0 } @@ -606,7 +606,7 @@ define i32 @test_direct_call_addr() #0 { ; ELF-NEXT: bl f ; ELF-NEXT: ldr x30, [sp], #16 ; ELF-NEXT: ret - %tmp0 = call i32 ptrauth(ptr @f, i32 1, i64 0, ptr @f.ref.ib.0.addr)() [ "ptrauth"(i64 1, i64 0, i64 ptrtoint (ptr @f.ref.ib.0.addr to i64)) ] + %tmp0 = call i32 ptrauth(ptr @f, [i64 1, i64 0, i64 ptrtoint (ptr @f.ref.ib.0.addr to i64)])() [ "ptrauth"(i64 1, i64 0, i64 ptrtoint (ptr @f.ref.ib.0.addr to i64)) ] ret i32 %tmp0 } @@ -622,7 +622,7 @@ define i32 @test_direct_call_addr_blend() #0 { ; ELF-NEXT: bl f ; ELF-NEXT: ldr x30, [sp], #16 ; ELF-NEXT: ret - %tmp1 = call i32 ptrauth(ptr @f, i32 1, i64 42, ptr @f.ref.ib.42.addr)() [ "ptrauth"(i64 1, i64 42, i64 ptrtoint (ptr @f.ref.ib.42.addr to i64)) ] + %tmp1 = call i32 ptrauth(ptr @f, [i64 1, i64 42, i64 ptrtoint (ptr @f.ref.ib.42.addr to i64)])() [ "ptrauth"(i64 1, i64 42, i64 ptrtoint (ptr @f.ref.ib.42.addr to i64)) ] ret i32 %tmp1 } @@ -638,7 +638,7 @@ define i32 @test_direct_call_addr_gep_different_index_types() #0 { ; ELF-NEXT: bl f ; ELF-NEXT: ldr x30, [sp], #16 ; ELF-NEXT: ret - %tmp0 = call i32 ptrauth(ptr @f, i32 1, i64 0, ptr getelementptr ({ ptr }, ptr @f_struct.ref.ib.0.addr, i64 0, i32 0))() [ "ptrauth"(i64 1, i64 0, i64 ptrtoint (ptr getelementptr ({ ptr }, ptr @f_struct.ref.ib.0.addr, i32 0, i32 0) to i64)) ] + %tmp0 = call i32 ptrauth(ptr @f, [i64 1, i64 0, i64 ptrtoint (ptr getelementptr ({ ptr }, ptr @f_struct.ref.ib.0.addr, i64 0, i32 0) to i64)])() [ "ptrauth"(i64 1, i64 0, i64 ptrtoint (ptr getelementptr ({ ptr }, ptr @f_struct.ref.ib.0.addr, i32 0, i32 0) to i64)) ] ret i32 %tmp0 } @@ -654,7 +654,7 @@ define i32 @test_direct_call_addr_blend_gep_different_index_types() #0 { ; ELF-NEXT: bl f ; ELF-NEXT: ldr x30, [sp], #16 ; ELF-NEXT: ret - %tmp1 = call i32 ptrauth(ptr @f, i32 1, i64 123, ptr getelementptr ({ ptr }, ptr @f_struct.ref.ib.123.addr, i64 0, i32 0))() [ "ptrauth"(i64 1, i64 123, i64 ptrtoint (ptr getelementptr ({ ptr }, ptr @f_struct.ref.ib.123.addr, i32 0, i32 0) to i64)) ] + %tmp1 = call i32 ptrauth(ptr @f, [i64 1, i64 123, i64 ptrtoint (ptr getelementptr ({ ptr }, ptr @f_struct.ref.ib.123.addr, i64 0, i32 0) to i64)])() [ "ptrauth"(i64 1, i64 123, i64 ptrtoint (ptr getelementptr ({ ptr }, ptr @f_struct.ref.ib.123.addr, i32 0, i32 0) to i64)) ] ret i32 %tmp1 } diff --git a/llvm/test/CodeGen/AArch64/ptrauth-constant-in-code.ll b/llvm/test/CodeGen/AArch64/ptrauth-constant-in-code.ll index 76339a7cc5791..e0b2600102658 100644 --- a/llvm/test/CodeGen/AArch64/ptrauth-constant-in-code.ll +++ b/llvm/test/CodeGen/AArch64/ptrauth-constant-in-code.ll @@ -2,30 +2,34 @@ ;--- err1.ll -; RUN: not --crash llc < err1.ll -mtriple aarch64-elf -mattr=+pauth \ +; RUN: not llc < err1.ll -mtriple aarch64-elf -mattr=+pauth \ ; RUN: -global-isel=0 -verify-machineinstrs 2>&1 | FileCheck --check-prefix=ERR1 %s -; RUN: not --crash llc < err1.ll -mtriple arm64-apple-ios -mattr=+pauth \ +; RUN: not llc < err1.ll -mtriple arm64-apple-ios -mattr=+pauth \ ; RUN: -global-isel=0 -verify-machineinstrs 2>&1 | FileCheck --check-prefix=ERR1 %s @g = external global i32 define ptr @foo() { -; ERR1: LLVM ERROR: key in ptrauth global out of range [0, 3] - ret ptr ptrauth (ptr @g, i32 4) +; ERR1: Ptrauth schema violates target-specific constraints: +; ERR1: ptr ptrauth (ptr @g, [i64 4, i64 0, i64 0]) +; ERR1: LLVM ERROR: Invalid ptrauth schema: key must be constant in range [0, 3] + ret ptr ptrauth (ptr @g, [i64 4, i64 0, i64 0]) } ;--- err2.ll -; RUN: not --crash llc < err2.ll -mtriple aarch64-elf -mattr=+pauth \ +; RUN: not llc < err2.ll -mtriple aarch64-elf -mattr=+pauth \ ; RUN: -global-isel=0 -verify-machineinstrs 2>&1 | FileCheck --check-prefix=ERR2 %s -; RUN: not --crash llc < err2.ll -mtriple arm64-apple-ios -mattr=+pauth \ +; RUN: not llc < err2.ll -mtriple arm64-apple-ios -mattr=+pauth \ ; RUN: -global-isel=0 -verify-machineinstrs 2>&1 | FileCheck --check-prefix=ERR2 %s @g = external global i32 define ptr @foo() { -; ERR2: LLVM ERROR: constant discriminator in ptrauth global out of range [0, 0xffff] - ret ptr ptrauth (ptr @g, i32 2, i64 65536) +; ERR2: Ptrauth schema violates target-specific constraints: +; ERR2: ptr ptrauth (ptr @g, [i64 2, i64 65536, i64 0]) +; ERR2: LLVM ERROR: Invalid ptrauth schema: constant modifier must be 16-bit unsigned constant + ret ptr ptrauth (ptr @g, [i64 2, i64 65536, i64 0]) } ;--- err3.ll @@ -39,7 +43,7 @@ define ptr @foo() { define ptr @foo() { ; ERR3: LLVM ERROR: unsupported non-zero offset in weak ptrauth global reference - ret ptr ptrauth (ptr getelementptr (i8, ptr @g_weak, i64 16), i32 2, i64 42) + ret ptr ptrauth (ptr getelementptr (i8, ptr @g_weak, i64 16), [i64 2, i64 42, i64 0]) } ;--- err4.ll @@ -50,11 +54,11 @@ define ptr @foo() { ; RUN: -global-isel=0 -verify-machineinstrs 2>&1 | FileCheck --check-prefix=ERR4 %s @g_weak = extern_weak global i32 -@g_weak.ref.da.42.addr = dso_local constant ptr ptrauth (ptr @g_weak, i32 2, i64 42, ptr @g_weak.ref.da.42.addr) +@g_weak.ref.da.42.addr = dso_local constant ptr ptrauth (ptr @g_weak, [i64 2, i64 42, i64 ptrtoint (ptr @g_weak.ref.da.42.addr to i64)]) define ptr @foo() { ; ERR4: LLVM ERROR: unsupported weak addr-div ptrauth global - ret ptr ptrauth (ptr @g_weak, i32 0, i64 42, ptr @g_weak.ref.da.42.addr) + ret ptr ptrauth (ptr @g_weak, [i64 0, i64 42, i64 ptrtoint (ptr @g_weak.ref.da.42.addr to i64)]) } ;--- err5.ll @@ -66,7 +70,7 @@ define ptr @foo() { define ptr @foo() { ; ERR5: LLVM ERROR: ptrauth global lowering only supported on MachO/ELF - ret ptr ptrauth (ptr @g, i32 0) + ret ptr ptrauth (ptr @g, [i64 0, i64 0, i64 0]) } ;--- ok.ll @@ -102,7 +106,7 @@ define ptr @test_global_zero_disc() { ; MACHO-NEXT: mov x0, x16 ; MACHO-NEXT: ret - ret ptr ptrauth (ptr @g, i32 0) + ret ptr ptrauth (ptr @g, [i64 0, i64 0, i64 0]) } define ptr @test_global_offset_zero_disc() { @@ -124,7 +128,7 @@ define ptr @test_global_offset_zero_disc() { ; MACHO-NEXT: mov x0, x16 ; MACHO-NEXT: ret - ret ptr ptrauth (ptr getelementptr (i8, ptr @g, i64 16), i32 2) + ret ptr ptrauth (ptr getelementptr (i8, ptr @g, i64 16), [i64 2, i64 0, i64 0]) } define ptr @test_global_neg_offset_zero_disc() { @@ -148,7 +152,7 @@ define ptr @test_global_neg_offset_zero_disc() { ; MACHO-NEXT: mov x0, x16 ; MACHO-NEXT: ret - ret ptr ptrauth (ptr getelementptr (i8, ptr @g, i64 -123456), i32 2) + ret ptr ptrauth (ptr getelementptr (i8, ptr @g, i64 -123456), [i64 2, i64 0, i64 0]) } define ptr @test_global_big_offset_zero_disc() { @@ -174,7 +178,7 @@ define ptr @test_global_big_offset_zero_disc() { ; MACHO-NEXT: mov x0, x16 ; MACHO-NEXT: ret - ret ptr ptrauth (ptr getelementptr (i8, ptr @g, i64 add (i64 2147483648, i64 65537)), i32 2) + ret ptr ptrauth (ptr getelementptr (i8, ptr @g, i64 add (i64 2147483648, i64 65537)), [i64 2, i64 0, i64 0]) } define ptr @test_global_big_neg_offset_zero_disc() { @@ -200,7 +204,7 @@ define ptr @test_global_big_neg_offset_zero_disc() { ; MACHO-NEXT: mov x0, x16 ; MACHO-NEXT: ret - ret ptr ptrauth (ptr getelementptr (i8, ptr @g, i64 -123456789), i32 2) + ret ptr ptrauth (ptr getelementptr (i8, ptr @g, i64 -123456789), [i64 2, i64 0, i64 0]) } define ptr @test_global_huge_neg_offset_zero_disc() { @@ -230,7 +234,7 @@ define ptr @test_global_huge_neg_offset_zero_disc() { ; MACHO-NEXT: mov x0, x16 ; MACHO-NEXT: ret - ret ptr ptrauth (ptr getelementptr (i8, ptr @g, i64 -9223372036854775808), i32 2) + ret ptr ptrauth (ptr getelementptr (i8, ptr @g, i64 -9223372036854775808), [i64 2, i64 0, i64 0]) } define ptr @test_global_disc() { @@ -252,10 +256,10 @@ define ptr @test_global_disc() { ; MACHO-NEXT: mov x0, x16 ; MACHO-NEXT: ret - ret ptr ptrauth (ptr @g, i32 0, i64 42) + ret ptr ptrauth (ptr @g, [i64 0, i64 42, i64 0]) } -@g.ref.da.42.addr = dso_local constant ptr ptrauth (ptr @g, i32 2, i64 42, ptr @g.ref.da.42.addr) +@g.ref.da.42.addr = dso_local constant ptr ptrauth (ptr @g, [i64 2, i64 42, i64 ptrtoint (ptr @g.ref.da.42.addr to i64)]) define ptr @test_global_addr_disc() { ; ELF-LABEL: test_global_addr_disc: @@ -284,7 +288,7 @@ define ptr @test_global_addr_disc() { ; MACHO-NEXT: mov x0, x16 ; MACHO-NEXT: ret - ret ptr ptrauth (ptr @g, i32 2, i64 42, ptr @g.ref.da.42.addr) + ret ptr ptrauth (ptr @g, [i64 2, i64 42, i64 ptrtoint (ptr @g.ref.da.42.addr to i64)]) } define ptr @test_global_process_specific() { @@ -304,7 +308,7 @@ define ptr @test_global_process_specific() { ; MACHO-NEXT: mov x0, x16 ; MACHO-NEXT: ret - ret ptr ptrauth (ptr @g, i32 1) + ret ptr ptrauth (ptr @g, [i64 1, i64 0, i64 0]) } ; Non-external symbols don't need to be accessed through the GOT. @@ -326,7 +330,7 @@ define ptr @test_global_strong_def() { ; MACHO-NEXT: mov x0, x16 ; MACHO-NEXT: ret - ret ptr ptrauth (ptr @g_strong_def, i32 2) + ret ptr ptrauth (ptr @g_strong_def, [i64 2, i64 0, i64 0]) } ; weak symbols can't be assumed to be non-nil. Use $auth_ptr$ stub slot always. @@ -346,7 +350,7 @@ define ptr @test_global_weak() { ; MACHO-NEXT: ldr x0, [x0, l_g_weak$auth_ptr$ia$42@PAGEOFF] ; MACHO-NEXT: ret - ret ptr ptrauth (ptr @g_weak, i32 0, i64 42) + ret ptr ptrauth (ptr @g_weak, [i64 0, i64 42, i64 0]) } ; Test another weak symbol to check that stubs are emitted in a stable order. @@ -366,7 +370,7 @@ define ptr @test_global_weak_2() { ; MACHO-NEXT: ldr x0, [x0, l_g_weak_2$auth_ptr$ia$42@PAGEOFF] ; MACHO-NEXT: ret - ret ptr ptrauth (ptr @g_weak_2, i32 0, i64 42) + ret ptr ptrauth (ptr @g_weak_2, [i64 0, i64 42, i64 0]) } ; ELF-LABEL: g_weak$auth_ptr$ia$42: diff --git a/llvm/test/CodeGen/AArch64/ptrauth-elf-got-function-symbols.ll b/llvm/test/CodeGen/AArch64/ptrauth-elf-got-function-symbols.ll index e75acceaa0d12..5d39cf343cbaa 100644 --- a/llvm/test/CodeGen/AArch64/ptrauth-elf-got-function-symbols.ll +++ b/llvm/test/CodeGen/AArch64/ptrauth-elf-got-function-symbols.ll @@ -31,7 +31,7 @@ @fptr = private global ptr null define void @foo() { - store ptr ptrauth (ptr @bar, i32 0), ptr @fptr + store ptr ptrauth (ptr @bar, [i64 0, i64 0, i64 0]), ptr @fptr ret void } diff --git a/llvm/test/CodeGen/AArch64/ptrauth-init-fini.ll b/llvm/test/CodeGen/AArch64/ptrauth-init-fini.ll index 186a31c63ba10..75bd6226cc3f3 100644 --- a/llvm/test/CodeGen/AArch64/ptrauth-init-fini.ll +++ b/llvm/test/CodeGen/AArch64/ptrauth-init-fini.ll @@ -27,8 +27,8 @@ ;; ^^^^ 0xD9D4: constant discriminator = 55764 ;; ^^ 0x80: bits 61..60 key = IA; bit 63 addr disc = false -@llvm.global_ctors = appending global [1 x { i32, ptr, ptr }] [{ i32, ptr, ptr } { i32 65535, ptr ptrauth (ptr @foo, i32 0, i64 55764), ptr null }] -@llvm.global_dtors = appending global [1 x { i32, ptr, ptr }] [{ i32, ptr, ptr } { i32 65535, ptr ptrauth (ptr @bar, i32 0, i64 55764), ptr null }] +@llvm.global_ctors = appending global [1 x { i32, ptr, ptr }] [{ i32, ptr, ptr } { i32 65535, ptr ptrauth (ptr @foo, [i64 0, i64 55764, i64 0]), ptr null }] +@llvm.global_dtors = appending global [1 x { i32, ptr, ptr }] [{ i32, ptr, ptr } { i32 65535, ptr ptrauth (ptr @bar, [i64 0, i64 55764, i64 0]), ptr null }] define void @foo() { ret void @@ -65,8 +65,8 @@ define void @bar() { ;; ^^^^ 0xD9D4: constant discriminator = 55764 ;; ^^ 0x80: bits 61..60 key = IA; bit 63 addr disc = true -@llvm.global_ctors = appending global [1 x { i32, ptr, ptr }] [{ i32, ptr, ptr } { i32 65535, ptr ptrauth (ptr @foo, i32 0, i64 55764, ptr inttoptr (i64 1 to ptr)), ptr null }] -@llvm.global_dtors = appending global [1 x { i32, ptr, ptr }] [{ i32, ptr, ptr } { i32 65535, ptr ptrauth (ptr @bar, i32 0, i64 55764, ptr inttoptr (i64 1 to ptr)), ptr null }] +@llvm.global_ctors = appending global [1 x { i32, ptr, ptr }] [{ i32, ptr, ptr } { i32 65535, ptr ptrauth (ptr @foo, [i64 0, i64 55764, i64 1]), ptr null }] +@llvm.global_dtors = appending global [1 x { i32, ptr, ptr }] [{ i32, ptr, ptr } { i32 65535, ptr ptrauth (ptr @bar, [i64 0, i64 55764, i64 1]), ptr null }] define void @foo() { ret void @@ -83,7 +83,7 @@ define void @bar() { ; ERR1: LLVM ERROR: unexpected address discrimination value for ctors/dtors entry, only 'ptr inttoptr (i64 1 to ptr)' is allowed -@llvm.global_ctors = appending global [1 x { i32, ptr, ptr }] [{ i32, ptr, ptr } { i32 65535, ptr ptrauth (ptr @foo, i32 0, i64 55764, ptr inttoptr (i64 2 to ptr)), ptr null }] +@llvm.global_ctors = appending global [1 x { i32, ptr, ptr }] [{ i32, ptr, ptr } { i32 65535, ptr ptrauth (ptr @foo, [i64 0, i64 55764, i64 2]), ptr null }] define void @foo() { ret void @@ -97,7 +97,7 @@ define void @foo() { ; ERR2: LLVM ERROR: unexpected address discrimination value for ctors/dtors entry, only 'ptr inttoptr (i64 1 to ptr)' is allowed @g = external global ptr -@llvm.global_dtors = appending global [1 x { i32, ptr, ptr }] [{ i32, ptr, ptr } { i32 65535, ptr ptrauth (ptr @bar, i32 0, i64 55764, ptr @g), ptr null }] +@llvm.global_dtors = appending global [1 x { i32, ptr, ptr }] [{ i32, ptr, ptr } { i32 65535, ptr ptrauth (ptr @bar, [i64 0, i64 55764, i64 ptrtoint (ptr @g to i64)]), ptr null }] define void @bar() { ret void diff --git a/llvm/test/CodeGen/AArch64/ptrauth-invoke.ll b/llvm/test/CodeGen/AArch64/ptrauth-invoke.ll index d93152c1408c9..53a9bd6d462cf 100644 --- a/llvm/test/CodeGen/AArch64/ptrauth-invoke.ll +++ b/llvm/test/CodeGen/AArch64/ptrauth-invoke.ll @@ -331,7 +331,7 @@ continuebb: ; CHECK-NEXT: .byte 0 {{.*}} On action: cleanup define i32 @test_invoke_ia_0_direct() #0 personality ptr @__gxx_personality_v0 { - %tmp0 = invoke i32 ptrauth (ptr @baz, i32 0)() [ "ptrauth"(i64 0, i64 0, i64 0) ] to label %continuebb + %tmp0 = invoke i32 ptrauth (ptr @baz, [i64 0, i64 0, i64 0])() [ "ptrauth"(i64 0, i64 0, i64 0) ] to label %continuebb unwind label %unwindbb unwindbb: @@ -443,7 +443,7 @@ continuebb: ; CHECK-NEXT: .byte 0 {{.*}} On action: cleanup define i32 @test_invoke_ib_2_direct_mismatch() #0 personality ptr @__gxx_personality_v0 { - %tmp0 = invoke i32 ptrauth (ptr @baz, i32 0, i64 1234)() [ "ptrauth"(i64 1, i64 2, i64 0) ] to label %continuebb + %tmp0 = invoke i32 ptrauth (ptr @baz, [i64 0, i64 1234, i64 0])() [ "ptrauth"(i64 1, i64 2, i64 0) ] to label %continuebb unwind label %unwindbb unwindbb: diff --git a/llvm/test/CodeGen/AArch64/ptrauth-irelative.ll b/llvm/test/CodeGen/AArch64/ptrauth-irelative.ll index 4ee1c19a86490..f093ca73c0245 100644 --- a/llvm/test/CodeGen/AArch64/ptrauth-irelative.ll +++ b/llvm/test/CodeGen/AArch64/ptrauth-irelative.ll @@ -9,7 +9,7 @@ ; CHECK-NEXT: b __emupac_pacda ; CHECK-NEXT: .section .rodata ; CHECK-NEXT: .xword [[FUNC]]@FUNCINIT -@nullref = constant ptr ptrauth (ptr null, i32 2, i64 1, ptr null), align 8 +@nullref = constant ptr ptrauth (ptr null, [i64 2, i64 1, i64 0]), align 8 @dsolocal = external dso_local global i8 @@ -23,7 +23,7 @@ ; CHECK-NEXT: b __emupac_pacda ; CHECK-NEXT: .section .rodata ; CHECK-NEXT: .xword [[FUNC]]@FUNCINIT -@dsolocalref = constant ptr ptrauth (ptr @dsolocal, i32 2, i64 2, ptr null), align 8 +@dsolocalref = constant ptr ptrauth (ptr @dsolocal, [i64 2, i64 2, i64 0]), align 8 @ds = external global i8 @@ -40,7 +40,7 @@ ; CHECK-NEXT: ret ; CHECK-NEXT: .section .rodata ; CHECK-NEXT: .xword [[FUNC]]@FUNCINIT -@dsolocalrefds = constant ptr ptrauth (ptr @dsolocal, i32 2, i64 2, ptr null, ptr @ds), align 8 +@dsolocalrefds = constant ptr ptrauth (ptr @dsolocal, [i64 2, i64 2, i64 0], ptr @ds), align 8 ; CHECK: dsolocalref8: ; CHECK-NEXT: [[PLACE:.*]]: @@ -52,7 +52,7 @@ ; CHECK-NEXT: b __emupac_pacda ; CHECK-NEXT: .section .rodata ; CHECK-NEXT: .xword [[FUNC]]@FUNCINIT -@dsolocalref8 = constant ptr ptrauth (ptr getelementptr (i8, ptr @dsolocal, i64 8), i32 2, i64 3, ptr null), align 8 +@dsolocalref8 = constant ptr ptrauth (ptr getelementptr (i8, ptr @dsolocal, i64 8), [i64 2, i64 3, i64 0]), align 8 ; CHECK: disc: ; CHECK-NEXT: [[PLACE:.*]]: @@ -65,7 +65,7 @@ ; CHECK-NEXT: b __emupac_pacda ; CHECK-NEXT: .section .rodata ; CHECK-NEXT: .xword [[FUNC]]@FUNCINIT -@disc = constant ptr ptrauth (ptr @dsolocal, i32 2, i64 0, ptr @disc), align 8 +@disc = constant ptr ptrauth (ptr @dsolocal, [i64 2, i64 0, i64 ptrtoint (ptr @disc to i64)]), align 8 @global = external global i8 @@ -79,7 +79,7 @@ ; CHECK-NEXT: b __emupac_pacda ; CHECK-NEXT: .section .rodata ; CHECK-NEXT: .xword [[FUNC]]@FUNCINIT -@globalref = constant ptr ptrauth (ptr @global, i32 2, i64 4, ptr null), align 8 +@globalref = constant ptr ptrauth (ptr @global, [i64 2, i64 4, i64 0]), align 8 ; CHECK: globalref8: ; CHECK-NEXT: [[PLACE:.*]]: @@ -92,4 +92,4 @@ ; CHECK-NEXT: b __emupac_pacda ; CHECK-NEXT: .section .rodata ; CHECK-NEXT: .xword [[FUNC]]@FUNCINIT -@globalref8 = constant ptr ptrauth (ptr getelementptr (i8, ptr @global, i64 8), i32 2, i64 5, ptr null), align 8 +@globalref8 = constant ptr ptrauth (ptr getelementptr (i8, ptr @global, i64 8), [i64 2, i64 5, i64 0]), align 8 diff --git a/llvm/test/CodeGen/AArch64/ptrauth-reloc.ll b/llvm/test/CodeGen/AArch64/ptrauth-reloc.ll index 02c643f101913..e128c941152a4 100644 --- a/llvm/test/CodeGen/AArch64/ptrauth-reloc.ll +++ b/llvm/test/CodeGen/AArch64/ptrauth-reloc.ll @@ -35,7 +35,7 @@ ; CHECK-MACHO-NEXT: .quad _g@AUTH(ia,0) ; CHECK-MACHO-NEXT: .quad 6 -@g.ref.ia.0 = constant { i64, ptr, i64 } { i64 5, ptr ptrauth (ptr @g, i32 0), i64 6 } +@g.ref.ia.0 = constant { i64, ptr, i64 } { i64 5, ptr ptrauth (ptr @g, [i64 0, i64 0, i64 0]), i64 6 } ; CHECK-ELF-LABEL: .globl g.ref.ia.42 ; CHECK-ELF-NEXT: .p2align 3 @@ -47,7 +47,7 @@ ; CHECK-MACHO-NEXT: _g.ref.ia.42: ; CHECK-MACHO-NEXT: .quad _g@AUTH(ia,42) -@g.ref.ia.42 = constant ptr ptrauth (ptr @g, i32 0, i64 42) +@g.ref.ia.42 = constant ptr ptrauth (ptr @g, [i64 0, i64 42, i64 0]) ; CHECK-ELF-LABEL: .globl g.ref.ib.0 ; CHECK-ELF-NEXT: .p2align 4 @@ -63,7 +63,7 @@ ; CHECK-MACHO-NEXT: .quad _g@AUTH(ib,0) ; CHECK-MACHO-NEXT: .quad 6 -@g.ref.ib.0 = constant { i64, ptr, i64 } { i64 5, ptr ptrauth (ptr @g, i32 1, i64 0), i64 6 } +@g.ref.ib.0 = constant { i64, ptr, i64 } { i64 5, ptr ptrauth (ptr @g, [i64 1, i64 0, i64 0]), i64 6 } ; CHECK-ELF-LABEL: .globl g.ref.da.42.addr ; CHECK-ELF-NEXT: .p2align 3 @@ -75,7 +75,7 @@ ; CHECK-MACHO-NEXT: _g.ref.da.42.addr: ; CHECK-MACHO-NEXT: .quad _g@AUTH(da,42,addr) -@g.ref.da.42.addr = constant ptr ptrauth (ptr @g, i32 2, i64 42, ptr @g.ref.da.42.addr) +@g.ref.da.42.addr = constant ptr ptrauth (ptr @g, [i64 2, i64 42, i64 ptrtoint (ptr @g.ref.da.42.addr to i64)]) ; CHECK-ELF-LABEL: .globl g.offset.ref.da.0 ; CHECK-ELF-NEXT: .p2align 3 @@ -87,7 +87,7 @@ ; CHECK-MACHO-NEXT: _g.offset.ref.da.0: ; CHECK-MACHO-NEXT: .quad (_g+16)@AUTH(da,0) -@g.offset.ref.da.0 = constant ptr ptrauth (ptr getelementptr (i8, ptr @g, i64 16), i32 2) +@g.offset.ref.da.0 = constant ptr ptrauth (ptr getelementptr (i8, ptr @g, i64 16), [i64 2, i64 0, i64 0]) ; CHECK-ELF-LABEL: .globl g.big_offset.ref.da.0 ; CHECK-ELF-NEXT: .p2align 3 @@ -99,7 +99,7 @@ ; CHECK-MACHO-NEXT: _g.big_offset.ref.da.0: ; CHECK-MACHO-NEXT: .quad (_g+2147549185)@AUTH(da,0) -@g.big_offset.ref.da.0 = constant ptr ptrauth (ptr getelementptr (i8, ptr @g, i64 add (i64 2147483648, i64 65537)), i32 2) +@g.big_offset.ref.da.0 = constant ptr ptrauth (ptr getelementptr (i8, ptr @g, i64 add (i64 2147483648, i64 65537)), [i64 2, i64 0, i64 0]) ; CHECK-ELF-LABEL: .globl g.weird_ref.da.0 ; CHECK-ELF-NEXT: .p2align 3 @@ -111,7 +111,7 @@ ; CHECK-MACHO-NEXT: _g.weird_ref.da.0: ; CHECK-MACHO-NEXT: .quad (_g+16)@AUTH(da,0) -@g.weird_ref.da.0 = constant i64 ptrtoint (ptr inttoptr (i64 ptrtoint (ptr ptrauth (ptr getelementptr (i8, ptr @g, i64 16), i32 2) to i64) to ptr) to i64) +@g.weird_ref.da.0 = constant i64 ptrtoint (ptr inttoptr (i64 ptrtoint (ptr ptrauth (ptr getelementptr (i8, ptr @g, i64 16), [i64 2, i64 0, i64 0]) to i64) to ptr) to i64) ; CHECK-ELF-LABEL: .globl g_weak.ref.ia.42 ; CHECK-ELF-NEXT: .p2align 3 @@ -123,7 +123,7 @@ ; CHECK-MACHO-NEXT: _g_weak.ref.ia.42: ; CHECK-MACHO-NEXT: .quad _g_weak@AUTH(ia,42) -@g_weak.ref.ia.42 = constant ptr ptrauth (ptr @g_weak, i32 0, i64 42) +@g_weak.ref.ia.42 = constant ptr ptrauth (ptr @g_weak, [i64 0, i64 42, i64 0]) ; CHECK-ELF-LABEL: .globl g_strong_def.ref.da.0 ; CHECK-ELF-NEXT: .p2align 3 @@ -135,7 +135,7 @@ ; CHECK-MACHO-NEXT: _g_strong_def.ref.da.0: ; CHECK-MACHO-NEXT: .quad _g_strong_def@AUTH(da,0) -@g_strong_def.ref.da.0 = constant ptr ptrauth (ptr @g_strong_def, i32 2) +@g_strong_def.ref.da.0 = constant ptr ptrauth (ptr @g_strong_def, [i64 2, i64 0, i64 0]) ;--- err-key.ll @@ -155,7 +155,7 @@ @g = external global i32 -@g.ref.4.0 = constant ptr ptrauth (ptr @g, i32 4, i64 0) +@g.ref.4.0 = constant ptr ptrauth (ptr @g, [i64 4, i64 0, i64 0]) ;--- err-disc.ll @@ -174,4 +174,4 @@ ; CHECK-ERR-DISC: error: AArch64 PAC Discriminator '65536' out of range [0, 0xFFFF] @g = external global i32 -@g.ref.ia.65536 = constant ptr ptrauth (ptr @g, i32 0, i64 65536) +@g.ref.ia.65536 = constant ptr ptrauth (ptr @g, [i64 0, i64 65536, i64 0]) diff --git a/llvm/test/CodeGen/AArch64/ptrauth-type-info-vptr-discr.ll b/llvm/test/CodeGen/AArch64/ptrauth-type-info-vptr-discr.ll index 31ef6cba6fbdd..f7fbcb25b081e 100644 --- a/llvm/test/CodeGen/AArch64/ptrauth-type-info-vptr-discr.ll +++ b/llvm/test/CodeGen/AArch64/ptrauth-type-info-vptr-discr.ll @@ -12,10 +12,10 @@ ; MACHO-NEXT: .quad (__ZTVN10__cxxabiv117__class_type_infoE+16)@AUTH(da,45546) -@_ZTI10Disc = constant { ptr, ptr } { ptr ptrauth (ptr getelementptr inbounds (ptr, ptr @_ZTVN10__cxxabiv117__class_type_infoE, i64 2), i32 2, i64 45546, ptr @_ZTI10Disc), ptr @_ZTS10Disc }, align 8 +@_ZTI10Disc = constant { ptr, ptr } { ptr ptrauth (ptr getelementptr inbounds (ptr, ptr @_ZTVN10__cxxabiv117__class_type_infoE, i64 2), [i64 2, i64 45546, i64 ptrtoint (ptr @_ZTI10Disc to i64)]), ptr @_ZTS10Disc }, align 8 @_ZTS10Disc = constant [4 x i8] c"Disc", align 1 -@_ZTI10NoDisc = constant { ptr, ptr } { ptr ptrauth (ptr getelementptr inbounds (ptr, ptr @_ZTVN10__cxxabiv117__class_type_infoE, i64 2), i32 2, i64 45546), ptr @_ZTS10NoDisc }, align 8 +@_ZTI10NoDisc = constant { ptr, ptr } { ptr ptrauth (ptr getelementptr inbounds (ptr, ptr @_ZTVN10__cxxabiv117__class_type_infoE, i64 2), [i64 2, i64 45546, i64 0]), ptr @_ZTS10NoDisc }, align 8 @_ZTS10NoDisc = constant [6 x i8] c"NoDisc", align 1 @_ZTVN10__cxxabiv117__class_type_infoE = external global [0 x ptr] diff --git a/llvm/test/CodeGen/MIR/AArch64/deactivation-symbols.mir b/llvm/test/CodeGen/MIR/AArch64/deactivation-symbols.mir index 573954ed2501e..221b13358b711 100644 --- a/llvm/test/CodeGen/MIR/AArch64/deactivation-symbols.mir +++ b/llvm/test/CodeGen/MIR/AArch64/deactivation-symbols.mir @@ -5,7 +5,7 @@ @ds = external global i8 define i64 @pauth_sign_zero(i64 %p) { - ; CHECK: G_PTRAUTH_SIGN %0, %1(s0), deactivation-symbol @ds + ; CHECK: G_PTRAUTH_SIGN %0, %2(s0), deactivation-symbol @ds %signed = call i64 @llvm.ptrauth.sign(i64 %p) [ "ptrauth"(i64 0, i64 0, i64 0), "deactivation-symbol"(ptr @ds) ] ret i64 %signed } diff --git a/llvm/test/Transforms/GlobalOpt/global-constructor-complex-constants.ll b/llvm/test/Transforms/GlobalOpt/global-constructor-complex-constants.ll index 6d9bdc41a0041..12db77532f874 100644 --- a/llvm/test/Transforms/GlobalOpt/global-constructor-complex-constants.ll +++ b/llvm/test/Transforms/GlobalOpt/global-constructor-complex-constants.ll @@ -15,13 +15,13 @@ define void @ctor() { ; CHECK-LABEL: define void @ctor() { ; CHECK-NEXT: [[ENTRY:.*:]] ; CHECK-NEXT: [[DST:%.*]] = alloca ptr, align 8 -; CHECK-NEXT: store ptr ptrauth (ptr @foo, i32 0), ptr [[DST]], align 8 +; CHECK-NEXT: store ptr ptrauth (ptr @foo, [i64 0, i64 0, i64 0]), ptr [[DST]], align 8 ; CHECK-NEXT: call void @user(ptr [[DST]]) ; CHECK-NEXT: ret void ; entry: %dst = alloca ptr, align 8 - store ptr ptrauth (ptr @foo, i32 0), ptr %dst, align 8 + store ptr ptrauth (ptr @foo, [i64 0, i64 0, i64 0]), ptr %dst, align 8 call void @user(ptr %dst) ret void } diff --git a/llvm/test/Transforms/InstCombine/ptrauth-call.ll b/llvm/test/Transforms/InstCombine/ptrauth-call.ll index 9af54b7bc0319..49a793e4e7fbf 100644 --- a/llvm/test/Transforms/InstCombine/ptrauth-call.ll +++ b/llvm/test/Transforms/InstCombine/ptrauth-call.ll @@ -9,7 +9,7 @@ define i32 @test_ptrauth_call(i32 %a0) { ; CHECK-NEXT: [[V0:%.*]] = call i32 @f(i32 [[A0:%.*]]) ; CHECK-NEXT: ret i32 [[V0]] ; - %v0 = call i32 ptrauth(ptr @f, i32 0)(i32 %a0) [ "ptrauth"(i64 0, i64 0, i64 0) ] + %v0 = call i32 ptrauth(ptr @f, [i64 0, i64 0, i64 0])(i32 %a0) [ "ptrauth"(i64 0, i64 0, i64 0) ] ret i32 %v0 } @@ -18,29 +18,29 @@ define i32 @test_ptrauth_call_disc(i32 %a0) { ; CHECK-NEXT: [[V0:%.*]] = call i32 @f(i32 [[A0:%.*]]) ; CHECK-NEXT: ret i32 [[V0]] ; - %v0 = call i32 ptrauth(ptr @f, i32 1, i64 5678)(i32 %a0) [ "ptrauth"(i64 1, i64 5678, i64 0) ] + %v0 = call i32 ptrauth(ptr @f, [i64 1, i64 5678, i64 0])(i32 %a0) [ "ptrauth"(i64 1, i64 5678, i64 0) ] ret i32 %v0 } -@f_addr_disc.ref = constant ptr ptrauth(ptr @f, i32 1, i64 0, ptr @f_addr_disc.ref) +@f_addr_disc.ref = constant ptr ptrauth(ptr @f, [i64 1, i64 0, i64 ptrtoint (ptr @f_addr_disc.ref to i64)]) define i32 @test_ptrauth_call_addr_disc(i32 %a0) { ; CHECK-LABEL: @test_ptrauth_call_addr_disc( ; CHECK-NEXT: [[V0:%.*]] = call i32 @f(i32 [[A0:%.*]]) ; CHECK-NEXT: ret i32 [[V0]] ; - %v0 = call i32 ptrauth(ptr @f, i32 1, i64 0, ptr @f_addr_disc.ref)(i32 %a0) [ "ptrauth"(i64 1, i64 0, i64 ptrtoint (ptr @f_addr_disc.ref to i64)) ] + %v0 = call i32 ptrauth(ptr @f, [i64 1, i64 0, i64 ptrtoint (ptr @f_addr_disc.ref to i64)])(i32 %a0) [ "ptrauth"(i64 1, i64 0, i64 ptrtoint (ptr @f_addr_disc.ref to i64)) ] ret i32 %v0 } -@f_both_disc.ref = constant ptr ptrauth(ptr @f, i32 1, i64 1234, ptr @f_both_disc.ref) +@f_both_disc.ref = constant ptr ptrauth(ptr @f, [i64 1, i64 1234, i64 ptrtoint (ptr @f_both_disc.ref to i64)]) define i32 @test_ptrauth_call_blend(i32 %a0) { ; CHECK-LABEL: @test_ptrauth_call_blend( ; CHECK-NEXT: [[V0:%.*]] = call i32 @f(i32 [[A0:%.*]]) ; CHECK-NEXT: ret i32 [[V0]] ; - %v0 = call i32 ptrauth(ptr @f, i32 1, i64 1234, ptr @f_both_disc.ref)(i32 %a0) [ "ptrauth"(i64 1, i64 1234, i64 ptrtoint (ptr @f_both_disc.ref to i64)) ] + %v0 = call i32 ptrauth(ptr @f, [i64 1, i64 1234, i64 ptrtoint (ptr @f_both_disc.ref to i64)])(i32 %a0) [ "ptrauth"(i64 1, i64 1234, i64 ptrtoint (ptr @f_both_disc.ref to i64)) ] ret i32 %v0 } @@ -49,42 +49,42 @@ define i64 @test_ptrauth_call_cast(i32 %a0) { ; CHECK-NEXT: [[V0:%.*]] = call i64 @f2(i32 [[A0:%.*]]) ; CHECK-NEXT: ret i64 [[V0]] ; - %v0 = call i64 ptrauth(ptr @f2, i32 0)(i32 %a0) [ "ptrauth"(i64 0, i64 0, i64 0) ] + %v0 = call i64 ptrauth(ptr @f2, [i64 0, i64 0, i64 0])(i32 %a0) [ "ptrauth"(i64 0, i64 0, i64 0) ] ret i64 %v0 } define i32 @test_ptrauth_call_mismatch_key(i32 %a0) { ; CHECK-LABEL: @test_ptrauth_call_mismatch_key( -; CHECK-NEXT: [[V0:%.*]] = call i32 ptrauth (ptr @f, i32 1, i64 5678)(i32 [[A0:%.*]]) [ "ptrauth"(i64 0, i64 5678, i64 0) ] +; CHECK-NEXT: [[V0:%.*]] = call i32 ptrauth (ptr @f, [i64 1, i64 5678, i64 0])(i32 [[A0:%.*]]) [ "ptrauth"(i64 0, i64 5678, i64 0) ] ; CHECK-NEXT: ret i32 [[V0]] ; - %v0 = call i32 ptrauth(ptr @f, i32 1, i64 5678)(i32 %a0) [ "ptrauth"(i64 0, i64 5678, i64 0) ] + %v0 = call i32 ptrauth(ptr @f, [i64 1, i64 5678, i64 0])(i32 %a0) [ "ptrauth"(i64 0, i64 5678, i64 0) ] ret i32 %v0 } define i32 @test_ptrauth_call_mismatch_disc(i32 %a0) { ; CHECK-LABEL: @test_ptrauth_call_mismatch_disc( -; CHECK-NEXT: [[V0:%.*]] = call i32 ptrauth (ptr @f, i32 1, i64 5678)(i32 [[A0:%.*]]) [ "ptrauth"(i64 1, i64 0, i64 0) ] +; CHECK-NEXT: [[V0:%.*]] = call i32 ptrauth (ptr @f, [i64 1, i64 5678, i64 0])(i32 [[A0:%.*]]) [ "ptrauth"(i64 1, i64 0, i64 0) ] ; CHECK-NEXT: ret i32 [[V0]] ; - %v0 = call i32 ptrauth(ptr @f, i32 1, i64 5678)(i32 %a0) [ "ptrauth"(i64 1, i64 0, i64 0) ] + %v0 = call i32 ptrauth(ptr @f, [i64 1, i64 5678, i64 0])(i32 %a0) [ "ptrauth"(i64 1, i64 0, i64 0) ] ret i32 %v0 } define i32 @test_ptrauth_call_mismatch_blend(i32 %a0) { ; CHECK-LABEL: @test_ptrauth_call_mismatch_blend( -; CHECK-NEXT: [[V0:%.*]] = call i32 ptrauth (ptr @f, i32 1, i64 1234, ptr @f_both_disc.ref)(i32 [[A0:%.*]]) [ "ptrauth"(i64 1, i64 0, i64 ptrtoint (ptr @f_both_disc.ref to i64)) ] +; CHECK-NEXT: [[V0:%.*]] = call i32 ptrauth (ptr @f, [i64 1, i64 1234, i64 ptrtoint (ptr @f_both_disc.ref to i64)])(i32 [[A0:%.*]]) [ "ptrauth"(i64 1, i64 0, i64 ptrtoint (ptr @f_both_disc.ref to i64)) ] ; CHECK-NEXT: ret i32 [[V0]] ; - %v0 = call i32 ptrauth(ptr @f, i32 1, i64 1234, ptr @f_both_disc.ref)(i32 %a0) [ "ptrauth"(i64 1, i64 0, i64 ptrtoint (ptr @f_both_disc.ref to i64)) ] + %v0 = call i32 ptrauth(ptr @f, [i64 1, i64 1234, i64 ptrtoint (ptr @f_both_disc.ref to i64)])(i32 %a0) [ "ptrauth"(i64 1, i64 0, i64 ptrtoint (ptr @f_both_disc.ref to i64)) ] ret i32 %v0 } define i32 @test_ptrauth_call_mismatch_blend_addr(i32 %a0) { ; CHECK-LABEL: @test_ptrauth_call_mismatch_blend_addr( -; CHECK-NEXT: [[V0:%.*]] = call i32 ptrauth (ptr @f, i32 1, i64 1234, ptr @f_both_disc.ref)(i32 [[A0:%.*]]) [ "ptrauth"(i64 1, i64 1234, i64 ptrtoint (ptr @f_addr_disc.ref to i64)) ] +; CHECK-NEXT: [[V0:%.*]] = call i32 ptrauth (ptr @f, [i64 1, i64 1234, i64 ptrtoint (ptr @f_both_disc.ref to i64)])(i32 [[A0:%.*]]) [ "ptrauth"(i64 1, i64 1234, i64 ptrtoint (ptr @f_addr_disc.ref to i64)) ] ; CHECK-NEXT: ret i32 [[V0]] ; - %v0 = call i32 ptrauth(ptr @f, i32 1, i64 1234, ptr @f_both_disc.ref)(i32 %a0) [ "ptrauth"(i64 1, i64 1234, i64 ptrtoint (ptr @f_addr_disc.ref to i64)) ] + %v0 = call i32 ptrauth(ptr @f, [i64 1, i64 1234, i64 ptrtoint (ptr @f_both_disc.ref to i64)])(i32 %a0) [ "ptrauth"(i64 1, i64 1234, i64 ptrtoint (ptr @f_addr_disc.ref to i64)) ] ret i32 %v0 } diff --git a/llvm/test/Transforms/InstCombine/ptrauth-intrinsics.ll b/llvm/test/Transforms/InstCombine/ptrauth-intrinsics.ll index 9901d8ae02f0f..d33ee4b3df20d 100644 --- a/llvm/test/Transforms/InstCombine/ptrauth-intrinsics.ll +++ b/llvm/test/Transforms/InstCombine/ptrauth-intrinsics.ll @@ -30,7 +30,7 @@ define i64 @test_ptrauth_nop_constant() { ; CHECK-LABEL: @test_ptrauth_nop_constant( ; CHECK-NEXT: ret i64 ptrtoint (ptr @foo to i64) ; - %authed = call i64 @llvm.ptrauth.auth(i64 ptrtoint(ptr ptrauth(ptr @foo, i32 1, i64 1234) to i64)) [ "ptrauth"(i64 1, i64 1234, i64 0) ] + %authed = call i64 @llvm.ptrauth.auth(i64 ptrtoint(ptr ptrauth(ptr @foo, [i64 1, i64 1234, i64 0]) to i64)) [ "ptrauth"(i64 1, i64 1234, i64 0) ] ret i64 %authed } @@ -39,7 +39,7 @@ define i64 @test_ptrauth_nop_constant_addrdisc() { ; CHECK-NEXT: ret i64 ptrtoint (ptr @foo to i64) ; %addr = ptrtoint ptr @foo to i64 - %authed = call i64 @llvm.ptrauth.auth(i64 ptrtoint(ptr ptrauth(ptr @foo, i32 1, i64 1234, ptr @foo) to i64)) [ "ptrauth"(i64 1, i64 1234, i64 %addr) ] + %authed = call i64 @llvm.ptrauth.auth(i64 ptrtoint(ptr ptrauth(ptr @foo, [i64 1, i64 1234, i64 ptrtoint (ptr @foo to i64)]) to i64)) [ "ptrauth"(i64 1, i64 1234, i64 %addr) ] ret i64 %authed } @@ -133,49 +133,49 @@ define i64 @test_ptrauth_resign_auth_mismatch(ptr %p) { define i64 @test_ptrauth_nop_constant_mismatch() { ; CHECK-LABEL: @test_ptrauth_nop_constant_mismatch( -; CHECK-NEXT: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 ptrtoint (ptr ptrauth (ptr @foo, i32 1, i64 1234) to i64)) [ "ptrauth"(i64 1, i64 12, i64 0) ] +; CHECK-NEXT: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 ptrtoint (ptr ptrauth (ptr @foo, [i64 1, i64 1234, i64 0]) to i64)) [ "ptrauth"(i64 1, i64 12, i64 0) ] ; CHECK-NEXT: ret i64 [[AUTHED]] ; - %authed = call i64 @llvm.ptrauth.auth(i64 ptrtoint(ptr ptrauth(ptr @foo, i32 1, i64 1234) to i64)) [ "ptrauth"(i64 1, i64 12, i64 0) ] + %authed = call i64 @llvm.ptrauth.auth(i64 ptrtoint(ptr ptrauth(ptr @foo, [i64 1, i64 1234, i64 0]) to i64)) [ "ptrauth"(i64 1, i64 12, i64 0) ] ret i64 %authed } define i64 @test_ptrauth_nop_constant_mismatch_key() { ; CHECK-LABEL: @test_ptrauth_nop_constant_mismatch_key( -; CHECK-NEXT: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 ptrtoint (ptr ptrauth (ptr @foo, i32 1, i64 1234) to i64)) [ "ptrauth"(i64 0, i64 1234, i64 0) ] +; CHECK-NEXT: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 ptrtoint (ptr ptrauth (ptr @foo, [i64 1, i64 1234, i64 0]) to i64)) [ "ptrauth"(i64 0, i64 1234, i64 0) ] ; CHECK-NEXT: ret i64 [[AUTHED]] ; - %authed = call i64 @llvm.ptrauth.auth(i64 ptrtoint(ptr ptrauth(ptr @foo, i32 1, i64 1234) to i64)) [ "ptrauth"(i64 0, i64 1234, i64 0) ] + %authed = call i64 @llvm.ptrauth.auth(i64 ptrtoint(ptr ptrauth(ptr @foo, [i64 1, i64 1234, i64 0]) to i64)) [ "ptrauth"(i64 0, i64 1234, i64 0) ] ret i64 %authed } define i64 @test_ptrauth_nop_constant_addrdisc_mismatch() { ; CHECK-LABEL: @test_ptrauth_nop_constant_addrdisc_mismatch( -; CHECK-NEXT: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 ptrtoint (ptr ptrauth (ptr @foo, i32 1, i64 1234, ptr @foo) to i64)) [ "ptrauth"(i64 1, i64 12, i64 ptrtoint (ptr @foo to i64)) ] +; CHECK-NEXT: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 ptrtoint (ptr ptrauth (ptr @foo, [i64 1, i64 1234, i64 ptrtoint (ptr @foo to i64)]) to i64)) [ "ptrauth"(i64 1, i64 12, i64 ptrtoint (ptr @foo to i64)) ] ; CHECK-NEXT: ret i64 [[AUTHED]] ; %addr = ptrtoint ptr @foo to i64 - %authed = call i64 @llvm.ptrauth.auth(i64 ptrtoint(ptr ptrauth(ptr @foo, i32 1, i64 1234, ptr @foo) to i64)) [ "ptrauth"(i64 1, i64 12, i64 %addr) ] + %authed = call i64 @llvm.ptrauth.auth(i64 ptrtoint(ptr ptrauth(ptr @foo, [i64 1, i64 1234, i64 ptrtoint (ptr @foo to i64)]) to i64)) [ "ptrauth"(i64 1, i64 12, i64 %addr) ] ret i64 %authed } define i64 @test_ptrauth_nop_constant_addrdisc_mismatch2() { ; CHECK-LABEL: @test_ptrauth_nop_constant_addrdisc_mismatch2( -; CHECK-NEXT: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 ptrtoint (ptr ptrauth (ptr @foo, i32 1, i64 1234, ptr @foo) to i64)) [ "ptrauth"(i64 1, i64 1234, i64 ptrtoint (ptr @bar to i64)) ] +; CHECK-NEXT: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 ptrtoint (ptr ptrauth (ptr @foo, [i64 1, i64 1234, i64 ptrtoint (ptr @foo to i64)]) to i64)) [ "ptrauth"(i64 1, i64 1234, i64 ptrtoint (ptr @bar to i64)) ] ; CHECK-NEXT: ret i64 [[AUTHED]] ; %addr = ptrtoint ptr @bar to i64 - %authed = call i64 @llvm.ptrauth.auth(i64 ptrtoint(ptr ptrauth(ptr @foo, i32 1, i64 1234, ptr @foo) to i64)) [ "ptrauth"(i64 1, i64 1234, i64 %addr) ] + %authed = call i64 @llvm.ptrauth.auth(i64 ptrtoint(ptr ptrauth(ptr @foo, [i64 1, i64 1234, i64 ptrtoint (ptr @foo to i64)]) to i64)) [ "ptrauth"(i64 1, i64 1234, i64 %addr) ] ret i64 %authed } define i64 @test_ptrauth_resign_ptrauth_constant(ptr %p) { ; CHECK-LABEL: @test_ptrauth_resign_ptrauth_constant( -; CHECK-NEXT: ret i64 ptrtoint (ptr ptrauth (ptr @foo, i32 0, i64 42) to i64) +; CHECK-NEXT: ret i64 ptrtoint (ptr ptrauth (ptr @foo, [i64 0, i64 42, i64 0]) to i64) ; %tmp0 = ptrtoint ptr %p to i64 - %authed = call i64 @llvm.ptrauth.resign(i64 ptrtoint(ptr ptrauth(ptr @foo, i32 1, i64 1234) to i64)) [ "ptrauth"(i64 1, i64 1234, i64 0), "ptrauth"(i64 0, i64 42, i64 0) ] + %authed = call i64 @llvm.ptrauth.resign(i64 ptrtoint(ptr ptrauth(ptr @foo, [i64 1, i64 1234, i64 0]) to i64)) [ "ptrauth"(i64 1, i64 1234, i64 0), "ptrauth"(i64 0, i64 42, i64 0) ] ret i64 %authed } @@ -209,9 +209,9 @@ define i64 @test_ptrauth_nop_ds2(ptr %p) { define i64 @test_ptrauth_nop_ds_constant() { ; CHECK-LABEL: @test_ptrauth_nop_ds_constant( -; CHECK-NEXT: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 ptrtoint (ptr ptrauth (ptr @foo, i32 1, i64 1234, ptr null, ptr @ds) to i64)) [ "ptrauth"(i64 1, i64 1234) ] +; CHECK-NEXT: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 ptrtoint (ptr ptrauth (ptr @foo, [i64 1, i64 1234, i64 0], ptr @ds) to i64)) [ "ptrauth"(i64 1, i64 1234) ] ; CHECK-NEXT: ret i64 [[AUTHED]] ; - %authed = call i64 @llvm.ptrauth.auth(i64 ptrtoint(ptr ptrauth(ptr @foo, i32 1, i64 1234, ptr null, ptr @ds) to i64)) [ "ptrauth"(i64 1, i64 1234) ] + %authed = call i64 @llvm.ptrauth.auth(i64 ptrtoint(ptr ptrauth(ptr @foo, [i64 1, i64 1234, i64 0], ptr @ds) to i64)) [ "ptrauth"(i64 1, i64 1234) ] ret i64 %authed } diff --git a/llvm/test/Verifier/ptrauth-constant.ll b/llvm/test/Verifier/ptrauth-constant.ll index 7a6d9d2634bc8..915bf2e6c7fcd 100644 --- a/llvm/test/Verifier/ptrauth-constant.ll +++ b/llvm/test/Verifier/ptrauth-constant.ll @@ -2,5 +2,5 @@ @g = external global i8 -; CHECK: signed ptrauth constant deactivation symbol must be a global value or null -@ptr = global ptr ptrauth (ptr @g, i32 0, i64 65535, ptr null, ptr inttoptr (i64 16 to ptr)) +; CHECK: ptrauth constant deactivation symbol must be a global value or null +@ptr = global ptr ptrauth (ptr @g, [i64 0, i64 65535, i64 0], ptr inttoptr (i64 16 to ptr)) diff --git a/llvm/tools/llvm-c-test/echo.cpp b/llvm/tools/llvm-c-test/echo.cpp index 026d815b43da7..0218fff6feaee 100644 --- a/llvm/tools/llvm-c-test/echo.cpp +++ b/llvm/tools/llvm-c-test/echo.cpp @@ -15,6 +15,7 @@ //===----------------------------------------------------------------------===// #include "llvm-c-test.h" +#include "llvm-c/Core.h" #include "llvm-c/DebugInfo.h" #include "llvm-c/ErrorHandling.h" #include "llvm-c/Target.h" @@ -398,12 +399,19 @@ static LLVMValueRef clone_constant_impl(LLVMValueRef Cst, LLVMModuleRef M) { if (LLVMIsAConstantPtrAuth(Cst)) { LLVMValueRef Ptr = clone_constant(LLVMGetConstantPtrAuthPointer(Cst), M); - LLVMValueRef Key = clone_constant(LLVMGetConstantPtrAuthKey(Cst), M); - LLVMValueRef Disc = - clone_constant(LLVMGetConstantPtrAuthDiscriminator(Cst), M); - LLVMValueRef AddrDisc = - clone_constant(LLVMGetConstantPtrAuthAddrDiscriminator(Cst), M); - return LLVMConstantPtrAuth(Ptr, Key, Disc, AddrDisc); + + unsigned SchemaSize = LLVMGetConstantPtrAuthSchemaSize(Cst); + SmallVector Schema; + for (unsigned I = 0; I < SchemaSize; ++I) { + LLVMValueRef Op = LLVMGetConstantPtrAuthSchemaOperand(Cst, I); + Schema.push_back(clone_constant(Op, M)); + } + + LLVMValueRef DeactivationSymbol = clone_constant( + LLVMGetConstantPtrAuthDeactivationSymbol(Cst), M); + + return LLVMConstantPtrAuth(Ptr, Schema.data(), Schema.size(), + DeactivationSymbol); } // At this point, if it's not a constant expression, it's a kind of constant @@ -419,6 +427,9 @@ static LLVMValueRef clone_constant_impl(LLVMValueRef Cst, LLVMModuleRef M) { case LLVMBitCast: return LLVMConstBitCast(clone_constant(LLVMGetOperand(Cst, 0), M), TypeCloner(M).Clone(Cst)); + case LLVMPtrToInt: + return LLVMConstPtrToInt(clone_constant(LLVMGetOperand(Cst, 0), M), + TypeCloner(M).Clone(Cst)); case LLVMGetElementPtr: { LLVMTypeRef ElemTy = TypeCloner(M).Clone(LLVMGetGEPSourceElementType(Cst)); diff --git a/llvm/unittests/SandboxIR/SandboxIRTest.cpp b/llvm/unittests/SandboxIR/SandboxIRTest.cpp index 951a31baa36ab..8d4b24a909538 100644 --- a/llvm/unittests/SandboxIR/SandboxIRTest.cpp +++ b/llvm/unittests/SandboxIR/SandboxIRTest.cpp @@ -1367,7 +1367,7 @@ define void @foo() { TEST_F(SandboxIRTest, ConstantPtrAuth) { parseIR(C, R"IR( define ptr @foo() { - ret ptr ptrauth (ptr @foo, i32 2, i64 1234) + ret ptr ptrauth (ptr @foo, [i64 2, i64 1234, i64 0]) } )IR"); Function &LLVMF = *M->getFunction("foo"); @@ -1384,8 +1384,8 @@ define ptr @foo() { auto *PtrAuth = cast(Ret->getReturnValue()); // Check get(), getKey(), getDiscriminator(), getAddrDiscriminator(). auto *NewPtrAuth = sandboxir::ConstantPtrAuth::get( - &F, PtrAuth->getKey(), PtrAuth->getDiscriminator(), - PtrAuth->getAddrDiscriminator(), PtrAuth->getDeactivationSymbol()); + &F, {PtrAuth->getKey(), PtrAuth->getDiscriminator(), + PtrAuth->getAddrDiscriminator()}, PtrAuth->getDeactivationSymbol()); EXPECT_EQ(NewPtrAuth, PtrAuth); // Check hasAddressDiscriminator(). EXPECT_EQ(PtrAuth->hasAddressDiscriminator(), diff --git a/llvm/unittests/Transforms/Utils/ValueMapperTest.cpp b/llvm/unittests/Transforms/Utils/ValueMapperTest.cpp index 60e9c5688c795..7c543d0f3049a 100644 --- a/llvm/unittests/Transforms/Utils/ValueMapperTest.cpp +++ b/llvm/unittests/Transforms/Utils/ValueMapperTest.cpp @@ -440,7 +440,6 @@ TEST(ValueMapperTest, mapValueConstantTargetNoneToLayoutTypeNullValue) { TEST(ValueMapperTest, mapValuePtrAuth) { LLVMContext C; Type *PtrTy = PointerType::get(C, 0); - IntegerType *Int32Ty = Type::getInt32Ty(C); IntegerType *Int64Ty = Type::getInt64Ty(C); std::unique_ptr Var0 = std::make_unique( @@ -456,18 +455,21 @@ TEST(ValueMapperTest, mapValuePtrAuth) { std::unique_ptr DS1 = std::make_unique( PtrTy, false, GlobalValue::ExternalLinkage, nullptr, "DS1"); - ConstantInt *ConstKey = ConstantInt::get(Int32Ty, 1); + ConstantInt *ConstKey = ConstantInt::get(Int64Ty, 1); ConstantInt *ConstDisc = ConstantInt::get(Int64Ty, 1234); + Constant *Storage0AsInt = ConstantExpr::getPtrToInt(Storage0.get(), Int64Ty); + Constant *Storage1AsInt = ConstantExpr::getPtrToInt(Storage1.get(), Int64Ty); + ValueToValueMapTy VM; VM[Var0.get()] = Var1.get(); - VM[Storage0.get()] = Storage1.get(); + VM[Storage0AsInt] = Storage1AsInt; VM[DS0.get()] = DS1.get(); - ConstantPtrAuth *Value = ConstantPtrAuth::get(Var0.get(), ConstKey, ConstDisc, - Storage0.get(), DS0.get()); + ConstantPtrAuth *Value = ConstantPtrAuth::get( + Var0.get(), {ConstKey, ConstDisc, Storage0AsInt}, DS0.get()); ConstantPtrAuth *MappedValue = ConstantPtrAuth::get( - Var1.get(), ConstKey, ConstDisc, Storage1.get(), DS1.get()); + Var1.get(), {ConstKey, ConstDisc, Storage1AsInt}, DS1.get()); EXPECT_EQ(ValueMapper(VM).mapValue(*Value), MappedValue); } From 882d4999a83c077ba7206954b37972485d9f6bd0 Mon Sep 17 00:00:00 2001 From: Anatoly Trosinenko Date: Fri, 12 Dec 2025 18:55:56 +0300 Subject: [PATCH 32/40] WIP: More changes to bitcode I/O --- llvm/include/llvm/Bitcode/LLVMBitCodes.h | 5 +- llvm/lib/Bitcode/Reader/BitcodeAnalyzer.cpp | 4 +- llvm/lib/Bitcode/Reader/BitcodeReader.cpp | 73 +++++++++++++++------ llvm/lib/Bitcode/Writer/BitcodeWriter.cpp | 5 +- 4 files changed, 61 insertions(+), 26 deletions(-) diff --git a/llvm/include/llvm/Bitcode/LLVMBitCodes.h b/llvm/include/llvm/Bitcode/LLVMBitCodes.h index 0b210daf5e1c9..304a67e0c80ed 100644 --- a/llvm/include/llvm/Bitcode/LLVMBitCodes.h +++ b/llvm/include/llvm/Bitcode/LLVMBitCodes.h @@ -436,9 +436,8 @@ enum ConstantsCodes { // asmstr,conststr] CST_CODE_CE_GEP_WITH_INRANGE = 31, // [opty, flags, range, n x operands] CST_CODE_CE_GEP = 32, // [opty, flags, n x operands] - // FIXME Deprecate - CST_CODE_PTRAUTH = 33, // [ptr, key, disc, addrdisc] - CST_CODE_PTRAUTH2 = 34, // [ptr, key, disc, addrdisc, + CST_CODE_PTRAUTH_OLD = 33, // [ptr, key, disc, addrdisc] + CST_CODE_PTRAUTH_OLD2 = 34, // [ptr, key, disc, addrdisc, // deactivation_symbol] CST_CODE_PTRAUTH3 = 35, // [ptr, n x i64, deactivation_symbol] }; diff --git a/llvm/lib/Bitcode/Reader/BitcodeAnalyzer.cpp b/llvm/lib/Bitcode/Reader/BitcodeAnalyzer.cpp index 911ec7501eb8b..9f416cf9d17e2 100644 --- a/llvm/lib/Bitcode/Reader/BitcodeAnalyzer.cpp +++ b/llvm/lib/Bitcode/Reader/BitcodeAnalyzer.cpp @@ -222,7 +222,9 @@ GetCodeName(unsigned CodeID, unsigned BlockID, STRINGIFY_CODE(CST_CODE, CE_UNOP) STRINGIFY_CODE(CST_CODE, DSO_LOCAL_EQUIVALENT) STRINGIFY_CODE(CST_CODE, NO_CFI_VALUE) - STRINGIFY_CODE(CST_CODE, PTRAUTH) + STRINGIFY_CODE(CST_CODE, PTRAUTH_OLD) + STRINGIFY_CODE(CST_CODE, PTRAUTH_OLD2) + STRINGIFY_CODE(CST_CODE, PTRAUTH3) case bitc::CST_CODE_BLOCKADDRESS: return "CST_CODE_BLOCKADDRESS"; STRINGIFY_CODE(CST_CODE, DATA) diff --git a/llvm/lib/Bitcode/Reader/BitcodeReader.cpp b/llvm/lib/Bitcode/Reader/BitcodeReader.cpp index 53d06496e3b73..e1797f057c7e1 100644 --- a/llvm/lib/Bitcode/Reader/BitcodeReader.cpp +++ b/llvm/lib/Bitcode/Reader/BitcodeReader.cpp @@ -1601,25 +1601,48 @@ Expected BitcodeReader::materializeValue(unsigned StartValID, } else { switch (BC->Opcode) { case BitcodeConstant::ConstantPtrAuthOpcode: { - auto *Key = dyn_cast(ConstOps[1]); - if (!Key) - return error("ptrauth key operand must be ConstantInt"); - - auto *Disc = dyn_cast(ConstOps[2]); - if (!Disc) - return error("ptrauth disc operand must be ConstantInt"); - - Constant *DeactivationSymbol = - ConstOps.size() > 4 ? ConstOps[4] - : ConstantPointerNull::get(cast( - ConstOps[3]->getType())); + Constant *Ptr = nullptr; + Constant *DeactivationSymbol = nullptr; + SmallVector Schema; + + Type *Int64Ty = Type::getInt64Ty(BC->getContext()); + + switch (BC->Flags) { + default: + llvm_unreachable("Expected CST_CODE_PTRAUTH* constant"); + case bitc::CST_CODE_PTRAUTH_OLD2: + // Upgrade (ptr @ptr, i32 key, i64 disc, ptr @addr_disc, ptr @ds) + DeactivationSymbol = ConstOps[4]; + [[fallthrough]]; + case bitc::CST_CODE_PTRAUTH_OLD: + // Upgrade (ptr @ptr, i32 key, i64 disc, ptr @addr_disc) + Ptr = ConstOps[0]; + Schema.push_back(ConstantExpr::getBitCast(ConstOps[1], Int64Ty)); + Schema.push_back(ConstOps[2]); + Schema.push_back(ConstantExpr::getPtrToInt(ConstOps[3], Int64Ty)); + break; + case bitc::CST_CODE_PTRAUTH3: + Ptr = ConstOps[0]; + DeactivationSymbol = ConstOps[1]; + Schema.assign(&ConstOps[2], ConstOps.end()); + break; + } + + if (!Ptr->getType()->isPointerTy()) + return error( + "ptrauth signed operand must be a pointer"); + + for (Constant *C : Schema) + if (!C->getType()->isIntegerTy(64)) + return error("ptrauth schema operands must be i64 constants"); + + if (!DeactivationSymbol) + DeactivationSymbol = Constant::getNullValue(Ptr->getType()); if (!DeactivationSymbol->getType()->isPointerTy()) return error( "ptrauth deactivation symbol operand must be a pointer"); - // FIXME Upgrade - C = ConstantPtrAuth::get(ConstOps[0], {Key, Disc, ConstOps[3]}, - DeactivationSymbol); + C = ConstantPtrAuth::get(Ptr, Schema, DeactivationSymbol); break; } case BitcodeConstant::NoCFIOpcode: { @@ -3813,26 +3836,38 @@ Error BitcodeReader::parseConstants() { Record[1]); break; } - case bitc::CST_CODE_PTRAUTH: { + case bitc::CST_CODE_PTRAUTH_OLD: { if (Record.size() < 4) return error("Invalid ptrauth record"); // Ptr, Key, Disc, AddrDisc V = BitcodeConstant::create(Alloc, CurTy, - BitcodeConstant::ConstantPtrAuthOpcode, + {BitcodeConstant::ConstantPtrAuthOpcode, bitc::CST_CODE_PTRAUTH_OLD}, {(unsigned)Record[0], (unsigned)Record[1], (unsigned)Record[2], (unsigned)Record[3]}); break; } - case bitc::CST_CODE_PTRAUTH2: { + case bitc::CST_CODE_PTRAUTH_OLD2: { if (Record.size() < 5) return error("Invalid ptrauth record"); // Ptr, Key, Disc, AddrDisc, DeactivationSymbol V = BitcodeConstant::create( - Alloc, CurTy, BitcodeConstant::ConstantPtrAuthOpcode, + Alloc, CurTy, {BitcodeConstant::ConstantPtrAuthOpcode, bitc::CST_CODE_PTRAUTH_OLD2}, {(unsigned)Record[0], (unsigned)Record[1], (unsigned)Record[2], (unsigned)Record[3], (unsigned)Record[4]}); break; } + case bitc::CST_CODE_PTRAUTH3: { + if (Record.size() < 3) + return error("Invalid ptrauth record"); + // Ptr, DeactivationSymbol, SchemaArg0 [, SchemaArg1, ...] + + SmallVector Operands; + llvm::append_range(Operands, Record); + + V = BitcodeConstant::create( + Alloc, CurTy, {BitcodeConstant::ConstantPtrAuthOpcode, bitc::CST_CODE_PTRAUTH3}, Operands); + break; + } } assert(V->getType() == getTypeByID(CurTyID) && "Incorrect result type ID"); diff --git a/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp b/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp index 2b58424d53604..02f10472133bc 100644 --- a/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp +++ b/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp @@ -3032,10 +3032,9 @@ void ModuleBitcodeWriter::writeConstants(unsigned FirstVal, unsigned LastVal, } else if (const auto *CPA = dyn_cast(C)) { Code = bitc::CST_CODE_PTRAUTH3; 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())); Record.push_back(VE.getValueID(CPA->getDeactivationSymbol())); + for (const Use &U : CPA->getSchema()) + Record.push_back(VE.getValueID(cast(U))); } else { #ifndef NDEBUG C->dump(); From eb38c9a19b6b94356830d11a4d7d4f9920c158c3 Mon Sep 17 00:00:00 2001 From: Anatoly Trosinenko Date: Mon, 15 Dec 2025 12:54:12 +0300 Subject: [PATCH 33/40] Fix signed *structor pointers --- clang/lib/CodeGen/CGPointerAuth.cpp | 6 +++++- clang/lib/CodeGen/CodeGenModule.cpp | 8 +++----- clang/test/CodeGen/ptrauth-init-fini.c | 4 ++-- llvm/lib/Target/AArch64/AArch64AsmPrinter.cpp | 2 +- llvm/test/CodeGen/AArch64/ptrauth-init-fini.ll | 4 ++-- 5 files changed, 13 insertions(+), 11 deletions(-) diff --git a/clang/lib/CodeGen/CGPointerAuth.cpp b/clang/lib/CodeGen/CGPointerAuth.cpp index c4e0a1f0d6d79..79fc0e9aae9f8 100644 --- a/clang/lib/CodeGen/CGPointerAuth.cpp +++ b/clang/lib/CodeGen/CGPointerAuth.cpp @@ -380,7 +380,11 @@ CodeGenModule::getConstantSignedPointer(llvm::Constant *Pointer, unsigned Key, llvm::Constant *StorageAddress, llvm::ConstantInt *OtherDiscriminator) { llvm::Constant *AddressDiscriminator; - if (StorageAddress) { + if (isa_and_nonnull(StorageAddress)) { + assert(cast(StorageAddress)->getZExtValue() == + llvm::ConstantPtrAuth::AddrDiscriminator_CtorsDtors); + AddressDiscriminator = StorageAddress; + } else if (StorageAddress) { assert(StorageAddress->getType() == DefaultPtrTy); AddressDiscriminator = llvm::ConstantExpr::getPtrToInt(StorageAddress, Int64Ty); diff --git a/clang/lib/CodeGen/CodeGenModule.cpp b/clang/lib/CodeGen/CodeGenModule.cpp index a6a1b84e278b9..81ced3e0be54a 100644 --- a/clang/lib/CodeGen/CodeGenModule.cpp +++ b/clang/lib/CodeGen/CodeGenModule.cpp @@ -2329,11 +2329,9 @@ void CodeGenModule::EmitCtorList(CtorList &Fns, const char *GlobalName) { if (InitFiniAuthSchema) { llvm::Constant *StorageAddress = (InitFiniAuthSchema.isAddressDiscriminated() - ? llvm::ConstantExpr::getIntToPtr( - llvm::ConstantInt::get( - IntPtrTy, - llvm::ConstantPtrAuth::AddrDiscriminator_CtorsDtors), - PtrTy) + ? llvm::ConstantInt::get( + IntPtrTy, + llvm::ConstantPtrAuth::AddrDiscriminator_CtorsDtors) : nullptr); llvm::Constant *SignedCtorPtr = getConstantSignedPointer( I.Initializer, InitFiniAuthSchema.getKey(), StorageAddress, diff --git a/clang/test/CodeGen/ptrauth-init-fini.c b/clang/test/CodeGen/ptrauth-init-fini.c index 834e17fd4f9d4..daf62c3c1ec31 100644 --- a/clang/test/CodeGen/ptrauth-init-fini.c +++ b/clang/test/CodeGen/ptrauth-init-fini.c @@ -18,8 +18,8 @@ // SIGNED: @llvm.global_ctors = appending global [1 x { i32, ptr, ptr }] [{ i32, ptr, ptr } { i32 65535, ptr ptrauth (ptr @foo, [i64 0, i64 55764, i64 0]), ptr null }] // SIGNED: @llvm.global_dtors = appending global [1 x { i32, ptr, ptr }] [{ i32, ptr, ptr } { i32 65535, ptr ptrauth (ptr @bar, [i64 0, i64 55764, i64 0]), ptr null }] -// ADDRDISC: @llvm.global_ctors = appending global [1 x { i32, ptr, ptr }] [{ i32, ptr, ptr } { i32 65535, ptr ptrauth (ptr @foo, [i64 0, i64 55764, i64 ptrtoint (ptr inttoptr (i64 1 to ptr) to i64)]), ptr null }] -// ADDRDISC: @llvm.global_dtors = appending global [1 x { i32, ptr, ptr }] [{ i32, ptr, ptr } { i32 65535, ptr ptrauth (ptr @bar, [i64 0, i64 55764, i64 ptrtoint (ptr inttoptr (i64 1 to ptr) to i64)]), ptr null }] +// ADDRDISC: @llvm.global_ctors = appending global [1 x { i32, ptr, ptr }] [{ i32, ptr, ptr } { i32 65535, ptr ptrauth (ptr @foo, [i64 0, i64 55764, i64 1]), ptr null }] +// ADDRDISC: @llvm.global_dtors = appending global [1 x { i32, ptr, ptr }] [{ i32, ptr, ptr } { i32 65535, ptr ptrauth (ptr @bar, [i64 0, i64 55764, i64 1]), ptr null }] // UNSIGNED: @llvm.global_ctors = appending global [1 x { i32, ptr, ptr }] [{ i32, ptr, ptr } { i32 65535, ptr @foo, ptr null }] // UNSIGNED: @llvm.global_dtors = appending global [1 x { i32, ptr, ptr }] [{ i32, ptr, ptr } { i32 65535, ptr @bar, ptr null }] diff --git a/llvm/lib/Target/AArch64/AArch64AsmPrinter.cpp b/llvm/lib/Target/AArch64/AArch64AsmPrinter.cpp index af7fc75154b6c..38cd00890698a 100644 --- a/llvm/lib/Target/AArch64/AArch64AsmPrinter.cpp +++ b/llvm/lib/Target/AArch64/AArch64AsmPrinter.cpp @@ -1419,7 +1419,7 @@ void AArch64AsmPrinter::emitXXStructor(const DataLayout &DL, ConstantPtrAuth::AddrDiscriminator_CtorsDtors)) report_fatal_error( "unexpected address discrimination value for ctors/dtors entry, only " - "'ptr inttoptr (i64 1 to ptr)' is allowed"); + "'i64 1' is allowed"); // If we have signed pointers in xxstructors list, they'll be lowered to @AUTH // MCExpr's via AArch64AsmPrinter::lowerConstantPtrAuth. It does not look at // actual address discrimination value and only checks diff --git a/llvm/test/CodeGen/AArch64/ptrauth-init-fini.ll b/llvm/test/CodeGen/AArch64/ptrauth-init-fini.ll index 75bd6226cc3f3..25a3800a4e467 100644 --- a/llvm/test/CodeGen/AArch64/ptrauth-init-fini.ll +++ b/llvm/test/CodeGen/AArch64/ptrauth-init-fini.ll @@ -81,7 +81,7 @@ define void @bar() { ; RUN: not --crash llc -mtriple aarch64-elf -mattr=+pauth -filetype=asm -o - err1.ll 2>&1 | \ ; RUN: FileCheck %s --check-prefix=ERR1 -; ERR1: LLVM ERROR: unexpected address discrimination value for ctors/dtors entry, only 'ptr inttoptr (i64 1 to ptr)' is allowed +; ERR1: LLVM ERROR: unexpected address discrimination value for ctors/dtors entry, only 'i64 1' is allowed @llvm.global_ctors = appending global [1 x { i32, ptr, ptr }] [{ i32, ptr, ptr } { i32 65535, ptr ptrauth (ptr @foo, [i64 0, i64 55764, i64 2]), ptr null }] @@ -94,7 +94,7 @@ define void @foo() { ; RUN: not --crash llc -mtriple aarch64-elf -mattr=+pauth -filetype=asm -o - err2.ll 2>&1 | \ ; RUN: FileCheck %s --check-prefix=ERR2 -; ERR2: LLVM ERROR: unexpected address discrimination value for ctors/dtors entry, only 'ptr inttoptr (i64 1 to ptr)' is allowed +; ERR2: LLVM ERROR: unexpected address discrimination value for ctors/dtors entry, only 'i64 1' is allowed @g = external global ptr @llvm.global_dtors = appending global [1 x { i32, ptr, ptr }] [{ i32, ptr, ptr } { i32 65535, ptr ptrauth (ptr @bar, [i64 0, i64 55764, i64 ptrtoint (ptr @g to i64)]), ptr null }] From 75d24acd307134f0b9c25338a3eac31e9337b13f Mon Sep 17 00:00:00 2001 From: Anatoly Trosinenko Date: Mon, 15 Dec 2025 21:29:47 +0300 Subject: [PATCH 34/40] Misc cleanup --- libcxxabi/src/cxa_personality.cpp | 39 +++++++------ llvm/include/llvm/CodeGen/ISDOpcodes.h | 26 ++++++--- llvm/include/llvm/IR/Constants.h | 6 +- llvm/include/llvm/Support/TargetOpcodes.def | 12 ++-- llvm/include/llvm/Target/GenericOpcodes.td | 14 ++--- .../Target/GlobalISel/SelectionDAGCompat.td | 2 +- .../include/llvm/Target/TargetSelectionDAG.td | 4 +- llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp | 13 ++--- .../SelectionDAG/SelectionDAGBuilder.cpp | 12 ++-- .../SelectionDAG/SelectionDAGDumper.cpp | 2 +- llvm/lib/IR/Constants.cpp | 24 ++++++-- llvm/lib/Target/AArch64/AArch64InstrInfo.td | 12 ++-- .../AArch64/AArch64SelectionDAGInfo.cpp | 2 +- .../AArch64/GISel/AArch64GlobalISelUtils.cpp | 2 +- .../AArch64/GISel/AArch64LegalizerInfo.cpp | 2 +- .../InstCombine/InstCombineCalls.cpp | 22 +++----- .../GlobalISel/legalizer-info-validation.mir | 4 +- .../Inputs/reference_x86_vocab_print.txt | 2 +- .../reference_x86_vocab_wo=0.5_print.txt | 2 +- .../Transforms/InstCombine/ptrauth-call.ll | 36 ++++++++++++ .../InstCombine/ptrauth-intrinsics-call.ll | 56 +++++++++---------- .../InstCombine/ptrauth-intrinsics.ll | 35 ++++++++++++ 22 files changed, 206 insertions(+), 123 deletions(-) diff --git a/libcxxabi/src/cxa_personality.cpp b/libcxxabi/src/cxa_personality.cpp index 25125d14120a1..9dd180b9707ba 100644 --- a/libcxxabi/src/cxa_personality.cpp +++ b/libcxxabi/src/cxa_personality.cpp @@ -607,12 +607,12 @@ set_registers(_Unwind_Exception* unwind_exception, _Unwind_Context* context, // We manually re-sign the IP as the __ptrauth qualifiers cannot // express the required relationship with the destination address unw_word_t newIP /* opaque __ptrauth(ptrauth_key_return_address, stackPointer, 0) */ = - (unw_word_t)ptrauth_auth_and_resign(*(void* const*)&results.landingPad, - __ptrauth_scan_results_landingpad_key, - ptrauth_blend_discriminator(&results.landingPad, - __ptrauth_scan_results_landingpad_disc), - ptrauth_key_return_address, - stackPointer); + (unw_word_t)ptrauth_auth_and_resign( + *(void* const*)&results.landingPad, + __ptrauth_scan_results_landingpad_key, + ptrauth_blend_discriminator(&results.landingPad, + __ptrauth_scan_results_landingpad_disc), + ptrauth_key_return_address, stackPointer); _Unwind_SetIP(context, newIP); #else _Unwind_SetIP(context, results.landingPad); @@ -973,12 +973,14 @@ static inline void set_landing_pad(scan_results& results, const __cxa_catch_temp_type& source) { #if __has_feature(ptrauth_calls) uintptr_t reauthenticatedLandingPad = - (uintptr_t)ptrauth_auth_and_resign(*reinterpret_cast(&source), - __ptrauth_cxxabi_catch_temp_key, - ptrauth_blend_discriminator(&source, __ptrauth_cxxabi_catch_temp_disc), - __ptrauth_scan_results_landingpad_key, - ptrauth_blend_discriminator(&results.landingPad, - __ptrauth_scan_results_landingpad_disc)); + (uintptr_t)ptrauth_auth_and_resign( + *reinterpret_cast(&source), + __ptrauth_cxxabi_catch_temp_key, + ptrauth_blend_discriminator(&source, + __ptrauth_cxxabi_catch_temp_disc), + __ptrauth_scan_results_landingpad_key, + ptrauth_blend_discriminator(&results.landingPad, + __ptrauth_scan_results_landingpad_disc)); memmove(reinterpret_cast(&results.landingPad), reinterpret_cast(&reauthenticatedLandingPad), sizeof(reauthenticatedLandingPad)); @@ -991,12 +993,13 @@ static inline void get_landing_pad(__cxa_catch_temp_type &dest, const scan_results &results) { #if __has_feature(ptrauth_calls) uintptr_t reauthenticatedPointer = - (uintptr_t)ptrauth_auth_and_resign(*reinterpret_cast(&results.landingPad), - __ptrauth_scan_results_landingpad_key, - ptrauth_blend_discriminator(&results.landingPad, - __ptrauth_scan_results_landingpad_disc), - __ptrauth_cxxabi_catch_temp_key, - ptrauth_blend_discriminator(&dest, __ptrauth_cxxabi_catch_temp_disc)); + (uintptr_t)ptrauth_auth_and_resign( + *reinterpret_cast(&results.landingPad), + __ptrauth_scan_results_landingpad_key, + ptrauth_blend_discriminator(&results.landingPad, + __ptrauth_scan_results_landingpad_disc), + __ptrauth_cxxabi_catch_temp_key, + ptrauth_blend_discriminator(&dest, __ptrauth_cxxabi_catch_temp_disc)); memmove(reinterpret_cast(&dest), reinterpret_cast(&reauthenticatedPointer), sizeof(reauthenticatedPointer)); diff --git a/llvm/include/llvm/CodeGen/ISDOpcodes.h b/llvm/include/llvm/CodeGen/ISDOpcodes.h index eebbb69638ccd..864175b8d8d2c 100644 --- a/llvm/include/llvm/CodeGen/ISDOpcodes.h +++ b/llvm/include/llvm/CodeGen/ISDOpcodes.h @@ -93,19 +93,27 @@ enum NodeType { ExternalSymbol, BlockAddress, + /// A temporary node representing the operands of "ptrauth" bundle or the + /// schema part of ptrauth constant in the original LLVM IR. + /// It has target-dependent number of i64 operands and produces a token value + /// to be passed as input operand to one of PtrAuth(Auth|Sign|Resign|Strip) + /// or PtrAuthGlobalAddress nodes. + PtrAuthSchema, + /// A ptrauth constant. - /// ptr, bundle_token - /// Note that the addr-disc can be a non-constant value, to allow representing - /// a constant global address signed using address-diversification, in code. + /// + /// PtrAuthGlobalAddress ptr, schema_token + /// + /// Note that operands of PtrAuthSchema referenced by the token operand can + /// be non-constant, provided they can also be non-constant for a regular + /// sign operation. This is to allow representing a constant global address + /// signed using address-diversification, in code. PtrAuthGlobalAddress, - /// A temporary node representing the operands of "ptrauth" bundle in the - /// original LLVM IR. - /// It has target-dependent number of i64 operands and produces a token value - /// passed as input operand to one of PtrAuth(Auth|Sign|Resign|Strip) nodes. - PtrAuthBundle, - /// Various PtrAuth operations. + /// + /// Ptr(Auth|Sign|Strip) ptr, schema_token + /// PtrResign ptr, old_schema, new_schema PtrAuthAuth, PtrAuthSign, PtrAuthResign, diff --git a/llvm/include/llvm/IR/Constants.h b/llvm/include/llvm/IR/Constants.h index 7b67c763da9e5..00c59dd181690 100644 --- a/llvm/include/llvm/IR/Constants.h +++ b/llvm/include/llvm/IR/Constants.h @@ -1041,9 +1041,6 @@ class ConstantPtrAuth final : public Constant { public: /// Return a pointer signed with the specified parameters. - // LLVM_ABI static ConstantPtrAuth *get(Constant *Ptr, ConstantArray *Schema, - // Constant *DeactivationSymbol); - LLVM_ABI static ConstantPtrAuth *get(Constant *Ptr, ArrayRef SchemaArgs, Constant *DeactivationSymbol); @@ -1112,8 +1109,9 @@ class ConstantPtrAuth final : public Constant { /// blended) discriminator \p Discriminator is known to be compatible with /// this ptrauth signed pointer. // FIXME: LLVM_ABI - bool isKnownCompatibleWith(ArrayRef BundleOperands, + bool isKnownCompatibleWith(ArrayRef Schema, const DataLayout &DL) const; + bool isKnownCompatibleWith(ArrayRef Schema, const DataLayout &DL) const; /// Methods for support type inquiry through isa, cast, and dyn_cast: static bool classof(const Value *V) { diff --git a/llvm/include/llvm/Support/TargetOpcodes.def b/llvm/include/llvm/Support/TargetOpcodes.def index 9431d2320dbb1..665662b26f437 100644 --- a/llvm/include/llvm/Support/TargetOpcodes.def +++ b/llvm/include/llvm/Support/TargetOpcodes.def @@ -328,14 +328,14 @@ HANDLE_TARGET_OPCODE(G_FRAME_INDEX) /// Generic reference to global value. HANDLE_TARGET_OPCODE(G_GLOBAL_VALUE) -/// Generic ptrauth-signed reference to global value. -HANDLE_TARGET_OPCODE(G_PTRAUTH_GLOBAL_VALUE) - -/// A temporary instruction representing the operands of "ptrauth" bundle in -/// the original LLVM IR. +/// A temporary instruction representing the operands of a "ptrauth" bundle +/// or the schema part of a `ptrauth` constant in the original LLVM IR. /// It has target-dependent number of i64 operands and produces a token value /// passed as input operand to one of G_PTRAUTH_* instructions. -HANDLE_TARGET_OPCODE(G_PTRAUTH_BUNDLE) +HANDLE_TARGET_OPCODE(G_PTRAUTH_SCHEMA) + +/// Generic ptrauth-signed reference to global value. +HANDLE_TARGET_OPCODE(G_PTRAUTH_GLOBAL_VALUE) /// Various PtrAuth operations. HANDLE_TARGET_OPCODE(G_PTRAUTH_AUTH) diff --git a/llvm/include/llvm/Target/GenericOpcodes.td b/llvm/include/llvm/Target/GenericOpcodes.td index 787adcc6b3d40..99fa78cf0d652 100644 --- a/llvm/include/llvm/Target/GenericOpcodes.td +++ b/llvm/include/llvm/Target/GenericOpcodes.td @@ -131,19 +131,19 @@ def G_GLOBAL_VALUE : GenericInstruction { let hasSideEffects = false; } -def G_PTRAUTH_GLOBAL_VALUE : GenericInstruction { - let OutOperandList = (outs type0:$dst); - let InOperandList = (ins type0:$addr, untyped_imm_0:$schema); - let hasSideEffects = 0; -} - -def G_PTRAUTH_BUNDLE : GenericInstruction { +def G_PTRAUTH_SCHEMA : GenericInstruction { let OutOperandList = (outs untyped_imm_0:$dst); let InOperandList = (ins type0:$op1, variable_ops); let hasSideEffects = 0; let variadicOpsType = type0; } +def G_PTRAUTH_GLOBAL_VALUE : GenericInstruction { + let OutOperandList = (outs type0:$dst); + let InOperandList = (ins type0:$addr, untyped_imm_0:$schema); + let hasSideEffects = 0; +} + def G_PTRAUTH_AUTH : GenericInstruction { let OutOperandList = (outs type0:$dst); let InOperandList = (ins type0:$value, untyped_imm_0:$schema); diff --git a/llvm/include/llvm/Target/GlobalISel/SelectionDAGCompat.td b/llvm/include/llvm/Target/GlobalISel/SelectionDAGCompat.td index 4d000ce1c393e..fc979acba4aec 100644 --- a/llvm/include/llvm/Target/GlobalISel/SelectionDAGCompat.td +++ b/llvm/include/llvm/Target/GlobalISel/SelectionDAGCompat.td @@ -224,7 +224,7 @@ def : GINodeEquiv; def : GINodeEquiv; def : GINodeEquiv; -def : GINodeEquiv; +def : GINodeEquiv; def : GINodeEquiv; def : GINodeEquiv; def : GINodeEquiv; diff --git a/llvm/include/llvm/Target/TargetSelectionDAG.td b/llvm/include/llvm/Target/TargetSelectionDAG.td index 06dfcd5769b04..8f9e0e0433f83 100644 --- a/llvm/include/llvm/Target/TargetSelectionDAG.td +++ b/llvm/include/llvm/Target/TargetSelectionDAG.td @@ -913,7 +913,7 @@ def convergencectrl_glue : SDNode<"ISD::CONVERGENCECTRL_GLUE", // Pointer Authentication operations. -def SDTPtrAuthBundle : SDTypeProfile<1, -1, [ +def SDTPtrAuthSchema : SDTypeProfile<1, -1, [ SDTCisVT<0, untyped> ]>; def SDTPtrAuthOneSchema : SDTypeProfile<1, 2, [ // auth, sign, strip @@ -923,7 +923,7 @@ def SDTPtrAuthTwoSchemas : SDTypeProfile<1, 3, [ // resign SDTCisVT<0, i64>, SDTCisVT<1, i64>, SDTCisVT<2, untyped>, SDTCisVT<3, untyped> ]>; -def ptrauth_bundle : SDNode<"ISD::PtrAuthBundle", SDTPtrAuthBundle, []>; +def ptrauth_schema : SDNode<"ISD::PtrAuthSchema", SDTPtrAuthSchema, []>; def ptrauth_auth : SDNode<"ISD::PtrAuthAuth", SDTPtrAuthOneSchema, []>; def ptrauth_sign : SDNode<"ISD::PtrAuthSign", SDTPtrAuthOneSchema, []>; def ptrauth_strip : SDNode<"ISD::PtrAuthStrip", SDTPtrAuthOneSchema, []>; diff --git a/llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp b/llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp index f808ffe503fa4..97be1f7f74359 100644 --- a/llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp +++ b/llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp @@ -2202,7 +2202,7 @@ bool IRTranslator::translatePtrAuthIntrinsic(const CallInst &CI, SchemaOps.push_back(getOrCreateVReg(*Operand)); Register Res = MRI->createGenericVirtualRegister(LLT::token()); - MIRBuilder.buildInstr(TargetOpcode::G_PTRAUTH_BUNDLE, {Res}, SchemaOps); + MIRBuilder.buildInstr(TargetOpcode::G_PTRAUTH_SCHEMA, {Res}, SchemaOps); return Res; }; @@ -2801,19 +2801,16 @@ bool IRTranslator::translateCallBase(const CallBase &CB, TLI->reportFatalErrorOnInvalidPtrAuthSchema(CB); - SmallVector BundleOperands(Bundle->Inputs.begin(), - Bundle->Inputs.end()); - // Look through ptrauth constants to try to eliminate the matching bundle // and turn this into a direct call with no ptrauth. // CallLowering will use the raw pointer if it doesn't find the PAI. const auto *CalleeCPA = dyn_cast(CB.getCalledOperand()); if (!CalleeCPA || !isa(CalleeCPA->getPointer()) || - !CalleeCPA->isKnownCompatibleWith(BundleOperands, *DL)) { + !CalleeCPA->isKnownCompatibleWith(Bundle->Inputs, *DL)) { // If we can't make it direct, package the bundle into PAI. PAI = CallLowering::PtrAuthInfo(); - for (const Value *V : BundleOperands) - PAI->Operands.push_back(getOrCreateVReg(*V)); + for (const Use &U : Bundle->Inputs) + PAI->Operands.push_back(getOrCreateVReg(*U.get())); } } @@ -3835,7 +3832,7 @@ bool IRTranslator::translate(const Constant &C, Register Reg) { SchemaOps.push_back(getOrCreateVReg(*Operand)); Register SchemaReg = MRI->createGenericVirtualRegister(LLT::token()); - EntryBuilder->buildInstr(TargetOpcode::G_PTRAUTH_BUNDLE, {SchemaReg}, SchemaOps); + EntryBuilder->buildInstr(TargetOpcode::G_PTRAUTH_SCHEMA, {SchemaReg}, SchemaOps); EntryBuilder->buildConstantPtrAuth(Reg, Addr, SchemaReg); } else if (auto CAZ = dyn_cast(&C)) { diff --git a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp index 5501ad20610ff..24d14d8a8e72f 100644 --- a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp +++ b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp @@ -1875,7 +1875,7 @@ SDValue SelectionDAGBuilder::getValueImpl(const Value *V) { for (const Use &Operand : CPA->getSchema()) Ops.push_back(getValue(Operand)); - SDValue Bundle = DAG.getNode(ISD::PtrAuthBundle, getCurSDLoc(), + SDValue Bundle = DAG.getNode(ISD::PtrAuthSchema, getCurSDLoc(), MVT::Other, Ops); return DAG.getNode(ISD::PtrAuthGlobalAddress, getCurSDLoc(), VT, @@ -6566,7 +6566,7 @@ void SelectionDAGBuilder::visitPtrAuthIntrinsic(const CallInst &I, for (const Use &Operand : Bundle.Inputs) Ops.push_back(getValue(Operand)); - return DAG.getNode(ISD::PtrAuthBundle, SDL, MVT::Other, Ops); + return DAG.getNode(ISD::PtrAuthSchema, SDL, MVT::Other, Ops); }; SmallVector Ops; @@ -9825,12 +9825,10 @@ void SelectionDAGBuilder::LowerCallSiteWithPtrAuthBundle( TLI.reportFatalErrorOnInvalidPtrAuthSchema(CB); - SmallVector BundleOperands(PAB->Inputs.begin(), PAB->Inputs.end()); - // Look through ptrauth constants to find the raw callee. // Do a direct unauthenticated call if we found it and everything matches. if (const auto *CalleeCPA = dyn_cast(CalleeV)) - if (CalleeCPA->isKnownCompatibleWith(BundleOperands, DAG.getDataLayout())) + if (CalleeCPA->isKnownCompatibleWith(PAB->Inputs, DAG.getDataLayout())) return LowerCallTo(CB, getValue(CalleeCPA->getPointer()), CB.isTailCall(), CB.isMustTailCall(), EHPadBB); @@ -9840,8 +9838,8 @@ void SelectionDAGBuilder::LowerCallSiteWithPtrAuthBundle( // Otherwise, do an authenticated indirect call. TargetLowering::PtrAuthInfo PAI; - for (const Value *Operand : BundleOperands) - PAI.Operands.push_back(getValue(Operand)); + for (const Use &U : PAB->Inputs) + PAI.Operands.push_back(getValue(U.get())); LowerCallTo(CB, getValue(CalleeV), CB.isTailCall(), CB.isMustTailCall(), EHPadBB, &PAI); diff --git a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGDumper.cpp b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGDumper.cpp index 0546a2bf4568f..0654fe3691cfe 100644 --- a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGDumper.cpp +++ b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGDumper.cpp @@ -139,7 +139,7 @@ std::string SDNode::getOperationName(const SelectionDAG *G) const { case ISD::GlobalAddress: return "GlobalAddress"; case ISD::GlobalTLSAddress: return "GlobalTLSAddress"; case ISD::PtrAuthGlobalAddress: return "PtrAuthGlobalAddress"; - case ISD::PtrAuthBundle: return "PtrAuthBundle"; + case ISD::PtrAuthSchema: return "PtrAuthSchema"; case ISD::PtrAuthAuth: return "PtrAuthAuth"; case ISD::PtrAuthSign: return "PtrAuthSign"; case ISD::PtrAuthResign: return "PtrAuthResign"; diff --git a/llvm/lib/IR/Constants.cpp b/llvm/lib/IR/Constants.cpp index a2c3dd7dd45ed..82681425988b9 100644 --- a/llvm/lib/IR/Constants.cpp +++ b/llvm/lib/IR/Constants.cpp @@ -2158,11 +2158,13 @@ bool ConstantPtrAuth::hasSpecialAddressDiscriminator(uint64_t Value) const { return IntVal->getValue() == Value; } -bool ConstantPtrAuth::isKnownCompatibleWith(ArrayRef BundleOperands, - const DataLayout &DL) const { +template +static bool isConstantPtrAuthCompatibleWithSchema(const ConstantPtrAuth &CPA, + ArrayRef OtherSchema, + const DataLayout &DL) { // This function may only be validly called to analyze a ptrauth operation // with no deactivation symbol, so if we have one it isn't compatible. - if (!getDeactivationSymbol()->isNullValue()) + if (!CPA.getDeactivationSymbol()->isNullValue()) return false; auto CompatibleOperands = [&DL](Value *This, Value *Other) { @@ -2193,17 +2195,27 @@ bool ConstantPtrAuth::isKnownCompatibleWith(ArrayRef BundleOperands, }; - if (getSchema().size() != BundleOperands.size()) + if (CPA.getSchema().size() != OtherSchema.size()) return false; - for (unsigned I = 0, N = getSchema().size(); I < N; ++I) { - if (!CompatibleOperands(getSchema()[I], BundleOperands[I])) + for (unsigned I = 0, N = CPA.getSchema().size(); I < N; ++I) { + if (!CompatibleOperands(CPA.getSchema()[I], OtherSchema[I])) return false; } return true; } +bool ConstantPtrAuth::isKnownCompatibleWith(ArrayRef Schema, + const DataLayout &DL) const { + return isConstantPtrAuthCompatibleWithSchema(*this, Schema, DL); +} + +bool ConstantPtrAuth::isKnownCompatibleWith(ArrayRef Schema, + const DataLayout &DL) const { + return isConstantPtrAuthCompatibleWithSchema(*this, Schema, DL); +} + //---- ConstantExpr::get() implementations. // diff --git a/llvm/lib/Target/AArch64/AArch64InstrInfo.td b/llvm/lib/Target/AArch64/AArch64InstrInfo.td index ad8a274f0a3fe..873f9ad4663ad 100644 --- a/llvm/lib/Target/AArch64/AArch64InstrInfo.td +++ b/llvm/lib/Target/AArch64/AArch64InstrInfo.td @@ -2091,12 +2091,12 @@ let Predicates = [HasPAuth] in { defm AUT : SignAuth<0b001, 0b011, "aut", null_frag>; def XPACI : ClearAuth<0, "xpaci">; - def : Pat<(ptrauth_strip GPR64:$Rd, (ptrauth_bundle (i64 0))), (XPACI GPR64:$Rd)>; - def : Pat<(ptrauth_strip GPR64:$Rd, (ptrauth_bundle (i64 1))), (XPACI GPR64:$Rd)>; + def : Pat<(ptrauth_strip GPR64:$Rd, (ptrauth_schema (i64 0))), (XPACI GPR64:$Rd)>; + def : Pat<(ptrauth_strip GPR64:$Rd, (ptrauth_schema (i64 1))), (XPACI GPR64:$Rd)>; def XPACD : ClearAuth<1, "xpacd">; - def : Pat<(ptrauth_strip GPR64:$Rd, (ptrauth_bundle (i64 2))), (XPACD GPR64:$Rd)>; - def : Pat<(ptrauth_strip GPR64:$Rd, (ptrauth_bundle (i64 3))), (XPACD GPR64:$Rd)>; + def : Pat<(ptrauth_strip GPR64:$Rd, (ptrauth_schema (i64 2))), (XPACD GPR64:$Rd)>; + def : Pat<(ptrauth_strip GPR64:$Rd, (ptrauth_schema (i64 3))), (XPACD GPR64:$Rd)>; def PACGA : SignAuthTwoOperand<0b1100, "pacga", int_ptrauth_sign_generic>; @@ -2224,11 +2224,11 @@ let Predicates = [HasPAuth] in { let supportsDeactivationSymbol = true; } - def : Pat<(ptrauth_sign GPR64:$Val, (ptrauth_bundle (i64 imm:$Key), + def : Pat<(ptrauth_sign GPR64:$Val, (ptrauth_schema (i64 imm:$Key), (i64 imm:$Disc), (i64 0))), (PAC GPR64:$Val, imm:$Key, imm:$Disc, zero_reg)>; - def : Pat<(ptrauth_sign GPR64:$Val, (ptrauth_bundle (i64 imm:$Key), + def : Pat<(ptrauth_sign GPR64:$Val, (ptrauth_schema (i64 imm:$Key), (i64 imm:$Disc), GPR64noip:$AddrDisc)), (PAC GPR64:$Val, imm:$Key, imm:$Disc, GPR64noip:$AddrDisc)>; diff --git a/llvm/lib/Target/AArch64/AArch64SelectionDAGInfo.cpp b/llvm/lib/Target/AArch64/AArch64SelectionDAGInfo.cpp index 0916bf632f39e..e16761c69beef 100644 --- a/llvm/lib/Target/AArch64/AArch64SelectionDAGInfo.cpp +++ b/llvm/lib/Target/AArch64/AArch64SelectionDAGInfo.cpp @@ -366,7 +366,7 @@ AArch64SelectionDAGInfo::extractPtrauthBlendDiscriminators( std::tuple AArch64SelectionDAGInfo::extractPtrauthBlendDiscriminators( SDValue Bundle, SelectionDAG *DAG) const { - assert(Bundle->getOpcode() == ISD::PtrAuthBundle); + assert(Bundle->getOpcode() == ISD::PtrAuthSchema); SDLoc DL(Bundle); SmallVector Operands(Bundle->ops()); diff --git a/llvm/lib/Target/AArch64/GISel/AArch64GlobalISelUtils.cpp b/llvm/lib/Target/AArch64/GISel/AArch64GlobalISelUtils.cpp index 3785c994836bd..99ae96dab316e 100644 --- a/llvm/lib/Target/AArch64/GISel/AArch64GlobalISelUtils.cpp +++ b/llvm/lib/Target/AArch64/GISel/AArch64GlobalISelUtils.cpp @@ -118,7 +118,7 @@ AArch64GISelUtils::extractPtrauthBlendDiscriminators(Register BundleToken, MachineRegisterInfo &MRI) { assert(MRI.getType(BundleToken).isToken()); const MachineInstr *Bundle = MRI.getVRegDef(BundleToken); - assert(Bundle->getOpcode() == TargetOpcode::G_PTRAUTH_BUNDLE); + assert(Bundle->getOpcode() == TargetOpcode::G_PTRAUTH_SCHEMA); SmallVector Ops; for (auto &Op : Bundle->uses()) Ops.push_back(Op.getReg()); diff --git a/llvm/lib/Target/AArch64/GISel/AArch64LegalizerInfo.cpp b/llvm/lib/Target/AArch64/GISel/AArch64LegalizerInfo.cpp index d56f803167e97..39274b5e35516 100644 --- a/llvm/lib/Target/AArch64/GISel/AArch64LegalizerInfo.cpp +++ b/llvm/lib/Target/AArch64/GISel/AArch64LegalizerInfo.cpp @@ -1020,7 +1020,7 @@ AArch64LegalizerInfo::AArch64LegalizerInfo(const AArch64Subtarget &ST) getActionDefinitionsBuilder(G_PTRAUTH_GLOBAL_VALUE) .legalForTypeWithAnyImm({p0}); - getActionDefinitionsBuilder(G_PTRAUTH_BUNDLE).legalForTypeWithAnyImm({s64}); + getActionDefinitionsBuilder(G_PTRAUTH_SCHEMA).legalForTypeWithAnyImm({s64}); getActionDefinitionsBuilder(G_PTRAUTH_AUTH).legalForTypeWithAnyImm({s64}); getActionDefinitionsBuilder(G_PTRAUTH_SIGN).legalForTypeWithAnyImm({s64}); getActionDefinitionsBuilder(G_PTRAUTH_RESIGN).legalForTypeWithAnyImm({s64}); diff --git a/llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp b/llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp index 647b635b38464..b016ad5ebc9eb 100644 --- a/llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp +++ b/llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp @@ -3112,14 +3112,12 @@ Instruction *InstCombinerImpl::visitCallInst(CallInst &CI) { // ptrauth constants are equivalent to a call to @llvm.ptrauth.sign for // our purposes, so check for that too. const auto *CPA = dyn_cast(PtrToInt->getOperand(0)); - SmallVector Operands; - llvm::append_range(Operands, ThisAutSchema.Inputs); - if (!CPA || !CPA->isKnownCompatibleWith(Operands, DL)) + if (!CPA || !CPA->isKnownCompatibleWith(ThisAutSchema.Inputs, DL)) break; if (NeedSign) { auto ThisSignSchema = II->getOperandBundleAt(1); - // resign(ptrauth(p,ks,ds),ks,ds,kr,dr) -> ptrauth(p,kr,dr) + // resign(ptrauth(p, schema0), schema0, schema1) -> ptrauth(p, schema1) auto IsConstant = [](Value *V) { return isa(V); }; if (llvm::all_of(ThisSignSchema.Inputs, IsConstant)) { auto *Null = ConstantPointerNull::get(Builder.getPtrTy()); @@ -3134,23 +3132,24 @@ Instruction *InstCombinerImpl::visitCallInst(CallInst &CI) { } } - // auth(ptrauth(p,k,d),k,d) -> p + // auth(ptrauth(p,schema1),schema1) -> p BasePtr = Builder.CreatePtrToInt(CPA->getPointer(), II->getType()); } else break; unsigned NewIntrin; if (NewAutSchema && NeedSign) { - // resign(0,1) + resign(1,2) = resign(0, 2) + // resign(schema0, schema1) + resign(schema1, schema2) = + // resign(schema0, schema2) NewIntrin = Intrinsic::ptrauth_resign; } else if (NewAutSchema) { - // resign(0,1) + auth(1) = auth(0) + // resign(schema0, schema1) + auth(schema1) = auth(schema0) NewIntrin = Intrinsic::ptrauth_auth; } else if (NeedSign) { - // sign(0) + resign(0, 1) = sign(1) + // sign(schema0) + resign(schema0, schema1) = sign(schema1) NewIntrin = Intrinsic::ptrauth_sign; } else { - // sign(0) + auth(0) = nop + // sign(schema0) + auth(schema0) = nop replaceInstUsesWith(*II, BasePtr); return eraseInstFromFunction(*II); } @@ -4374,11 +4373,8 @@ Instruction *InstCombinerImpl::foldPtrAuthConstantCallee(CallBase &Call) { if (!PAB) return nullptr; - SmallVector Operands; - llvm::append_range(Operands, PAB->Inputs); - // If the bundle doesn't match, this is probably going to fail to auth. - if (!CPA->isKnownCompatibleWith(Operands, DL)) + if (!CPA->isKnownCompatibleWith(PAB->Inputs, DL)) return nullptr; // If the bundle matches the constant, proceed in making this a direct call. diff --git a/llvm/test/CodeGen/AArch64/GlobalISel/legalizer-info-validation.mir b/llvm/test/CodeGen/AArch64/GlobalISel/legalizer-info-validation.mir index dd85fec0297e6..ad303b363e10a 100644 --- a/llvm/test/CodeGen/AArch64/GlobalISel/legalizer-info-validation.mir +++ b/llvm/test/CodeGen/AArch64/GlobalISel/legalizer-info-validation.mir @@ -115,11 +115,11 @@ # DEBUG-NEXT: .. type index coverage check SKIPPED: user-defined predicate detected # DEBUG-NEXT: .. imm index coverage check SKIPPED: user-defined predicate detected # -# DEBUG-NEXT: G_PTRAUTH_GLOBAL_VALUE (opcode {{[0-9]+}}): 1 type index, 1 imm index +# DEBUG-NEXT: G_PTRAUTH_SCHEMA (opcode {{[0-9]+}}): 1 type index, 1 imm index # DEBUG-NEXT: .. type index coverage check SKIPPED: user-defined predicate detected # DEBUG-NEXT: .. imm index coverage check SKIPPED: user-defined predicate detected # -# DEBUG-NEXT: G_PTRAUTH_BUNDLE (opcode {{[0-9]+}}): 1 type index, 1 imm index +# DEBUG-NEXT: G_PTRAUTH_GLOBAL_VALUE (opcode {{[0-9]+}}): 1 type index, 1 imm index # DEBUG-NEXT: .. type index coverage check SKIPPED: user-defined predicate detected # DEBUG-NEXT: .. imm index coverage check SKIPPED: user-defined predicate detected # diff --git a/llvm/test/CodeGen/MIR2Vec/Inputs/reference_x86_vocab_print.txt b/llvm/test/CodeGen/MIR2Vec/Inputs/reference_x86_vocab_print.txt index 810e9676a33a0..c9b8810e391d6 100644 --- a/llvm/test/CodeGen/MIR2Vec/Inputs/reference_x86_vocab_print.txt +++ b/llvm/test/CodeGen/MIR2Vec/Inputs/reference_x86_vocab_print.txt @@ -478,9 +478,9 @@ Key: G_OR: [ 0.00 0.00 ] Key: G_PHI: [ 0.00 0.00 ] Key: G_PREFETCH: [ 0.00 0.00 ] Key: G_PTRAUTH_AUTH: [ 0.00 0.00 ] -Key: G_PTRAUTH_BUNDLE: [ 0.00 0.00 ] Key: G_PTRAUTH_GLOBAL_VALUE: [ 0.00 0.00 ] Key: G_PTRAUTH_RESIGN: [ 0.00 0.00 ] +Key: G_PTRAUTH_SCHEMA: [ 0.00 0.00 ] Key: G_PTRAUTH_SIGN: [ 0.00 0.00 ] Key: G_PTRAUTH_STRIP: [ 0.00 0.00 ] Key: G_PTRMASK: [ 0.00 0.00 ] diff --git a/llvm/test/CodeGen/MIR2Vec/Inputs/reference_x86_vocab_wo=0.5_print.txt b/llvm/test/CodeGen/MIR2Vec/Inputs/reference_x86_vocab_wo=0.5_print.txt index cf0288ddf5418..35e1d13afee5d 100644 --- a/llvm/test/CodeGen/MIR2Vec/Inputs/reference_x86_vocab_wo=0.5_print.txt +++ b/llvm/test/CodeGen/MIR2Vec/Inputs/reference_x86_vocab_wo=0.5_print.txt @@ -478,9 +478,9 @@ Key: G_OR: [ 0.00 0.00 ] Key: G_PHI: [ 0.00 0.00 ] Key: G_PREFETCH: [ 0.00 0.00 ] Key: G_PTRAUTH_AUTH: [ 0.00 0.00 ] -Key: G_PTRAUTH_BUNDLE: [ 0.00 0.00 ] Key: G_PTRAUTH_GLOBAL_VALUE: [ 0.00 0.00 ] Key: G_PTRAUTH_RESIGN: [ 0.00 0.00 ] +Key: G_PTRAUTH_SCHEMA: [ 0.00 0.00 ] Key: G_PTRAUTH_SIGN: [ 0.00 0.00 ] Key: G_PTRAUTH_STRIP: [ 0.00 0.00 ] Key: G_PTRMASK: [ 0.00 0.00 ] diff --git a/llvm/test/Transforms/InstCombine/ptrauth-call.ll b/llvm/test/Transforms/InstCombine/ptrauth-call.ll index 49a793e4e7fbf..86ec04ff4cc63 100644 --- a/llvm/test/Transforms/InstCombine/ptrauth-call.ll +++ b/llvm/test/Transforms/InstCombine/ptrauth-call.ll @@ -53,6 +53,15 @@ define i64 @test_ptrauth_call_cast(i32 %a0) { ret i64 %v0 } +define i64 @test_ptrauth_call_arbitrary_tuple(i32 %a0) { +; CHECK-LABEL: @test_ptrauth_call_arbitrary_tuple( +; CHECK-NEXT: [[V0:%.*]] = call i64 @f2(i32 [[A0:%.*]]) +; CHECK-NEXT: ret i64 [[V0]] +; + %v0 = call i64 ptrauth(ptr @f2, [i64 0, i64 ptrtoint (ptr @f2 to i64), i64 1, i64 ptrtoint (ptr @f to i64)])(i32 %a0) [ "ptrauth"(i64 0, i64 ptrtoint (ptr @f2 to i64), i64 1, i64 ptrtoint (ptr @f to i64)) ] + ret i64 %v0 +} + define i32 @test_ptrauth_call_mismatch_key(i32 %a0) { ; CHECK-LABEL: @test_ptrauth_call_mismatch_key( ; CHECK-NEXT: [[V0:%.*]] = call i32 ptrauth (ptr @f, [i64 1, i64 5678, i64 0])(i32 [[A0:%.*]]) [ "ptrauth"(i64 0, i64 5678, i64 0) ] @@ -88,3 +97,30 @@ define i32 @test_ptrauth_call_mismatch_blend_addr(i32 %a0) { %v0 = call i32 ptrauth(ptr @f, [i64 1, i64 1234, i64 ptrtoint (ptr @f_both_disc.ref to i64)])(i32 %a0) [ "ptrauth"(i64 1, i64 1234, i64 ptrtoint (ptr @f_addr_disc.ref to i64)) ] ret i32 %v0 } + +define i64 @test_ptrauth_call_arbitrary_tuple_mismatch_ints(i32 %a0) { +; CHECK-LABEL: @test_ptrauth_call_arbitrary_tuple_mismatch_ints( +; CHECK-NEXT: [[V0:%.*]] = call i64 ptrauth (ptr @f2, [i64 0, i64 ptrtoint (ptr @f2 to i64), i64 42, i64 ptrtoint (ptr @f to i64)])(i32 [[A0:%.*]]) [ "ptrauth"(i64 0, i64 ptrtoint (ptr @f2 to i64), i64 1, i64 ptrtoint (ptr @f to i64)) ] +; CHECK-NEXT: ret i64 [[V0]] +; + %v0 = call i64 ptrauth(ptr @f2, [i64 0, i64 ptrtoint (ptr @f2 to i64), i64 42, i64 ptrtoint (ptr @f to i64)])(i32 %a0) [ "ptrauth"(i64 0, i64 ptrtoint (ptr @f2 to i64), i64 1, i64 ptrtoint (ptr @f to i64)) ] + ret i64 %v0 +} + +define i64 @test_ptrauth_call_arbitrary_tuple_mismatch_ptrs(i32 %a0) { +; CHECK-LABEL: @test_ptrauth_call_arbitrary_tuple_mismatch_ptrs( +; CHECK-NEXT: [[V0:%.*]] = call i64 ptrauth (ptr @f2, [i64 0, i64 ptrtoint (ptr @f to i64), i64 1, i64 ptrtoint (ptr @f2 to i64)])(i32 [[A0:%.*]]) [ "ptrauth"(i64 0, i64 ptrtoint (ptr @f2 to i64), i64 1, i64 ptrtoint (ptr @f to i64)) ] +; CHECK-NEXT: ret i64 [[V0]] +; + %v0 = call i64 ptrauth(ptr @f2, [i64 0, i64 ptrtoint (ptr @f to i64), i64 1, i64 ptrtoint (ptr @f2 to i64)])(i32 %a0) [ "ptrauth"(i64 0, i64 ptrtoint (ptr @f2 to i64), i64 1, i64 ptrtoint (ptr @f to i64)) ] + ret i64 %v0 +} + +define i64 @test_ptrauth_call_arbitrary_tuple_mismatch_int_vs_ptr(i32 %a0) { +; CHECK-LABEL: @test_ptrauth_call_arbitrary_tuple_mismatch_int_vs_ptr( +; CHECK-NEXT: [[V0:%.*]] = call i64 ptrauth (ptr @f2, [i64 0, i64 42, i64 1, i64 ptrtoint (ptr @f to i64)])(i32 [[A0:%.*]]) [ "ptrauth"(i64 0, i64 ptrtoint (ptr @f2 to i64), i64 1, i64 ptrtoint (ptr @f to i64)) ] +; CHECK-NEXT: ret i64 [[V0]] +; + %v0 = call i64 ptrauth(ptr @f2, [i64 0, i64 42, i64 1, i64 ptrtoint (ptr @f to i64)])(i32 %a0) [ "ptrauth"(i64 0, i64 ptrtoint (ptr @f2 to i64), i64 1, i64 ptrtoint (ptr @f to i64)) ] + ret i64 %v0 +} diff --git a/llvm/test/Transforms/InstCombine/ptrauth-intrinsics-call.ll b/llvm/test/Transforms/InstCombine/ptrauth-intrinsics-call.ll index 18642461e6465..61211e7143134 100644 --- a/llvm/test/Transforms/InstCombine/ptrauth-intrinsics-call.ll +++ b/llvm/test/Transforms/InstCombine/ptrauth-intrinsics-call.ll @@ -7,9 +7,9 @@ define i32 @test_ptrauth_call_sign(ptr %p) { ; CHECK-NEXT: ret i32 [[V3]] ; %v0 = ptrtoint ptr %p to i64 - %v1 = call i64 @llvm.ptrauth.sign(i64 %v0) [ "ptrauth"(i64 2, i64 5678) ] + %v1 = call i64 @llvm.ptrauth.sign(i64 %v0) [ "ptrauth"(i64 2, i64 5678, i64 0) ] %v2 = inttoptr i64 %v1 to ptr - %v3 = call i32 %v2() [ "ptrauth"(i64 2, i64 5678) ] + %v3 = call i32 %v2() [ "ptrauth"(i64 2, i64 5678, i64 0) ] ret i32 %v3 } @@ -19,36 +19,36 @@ define i32 @test_ptrauth_call_sign_otherbundle(ptr %p) { ; CHECK-NEXT: ret i32 [[V3]] ; %v0 = ptrtoint ptr %p to i64 - %v1 = call i64 @llvm.ptrauth.sign(i64 %v0) [ "ptrauth"(i64 2, i64 5678) ] + %v1 = call i64 @llvm.ptrauth.sign(i64 %v0) [ "ptrauth"(i64 2, i64 5678, i64 0) ] %v2 = inttoptr i64 %v1 to ptr - %v3 = call i32 %v2() [ "somebundle"(ptr null), "ptrauth"(i64 2, i64 5678), "otherbundle"(i64 0) ] + %v3 = call i32 %v2() [ "somebundle"(ptr null), "ptrauth"(i64 2, i64 5678, i64 0), "otherbundle"(i64 0) ] ret i32 %v3 } define i32 @test_ptrauth_call_resign(ptr %p) { ; CHECK-LABEL: @test_ptrauth_call_resign( -; CHECK-NEXT: [[V3:%.*]] = call i32 [[P:%.*]]() [ "ptrauth"(i64 1, i64 1234) ] +; CHECK-NEXT: [[V3:%.*]] = call i32 [[P:%.*]]() [ "ptrauth"(i64 1, i64 1234, i64 0) ] ; CHECK-NEXT: ret i32 [[V3]] ; %v0 = ptrtoint ptr %p to i64 - %v1 = call i64 @llvm.ptrauth.resign(i64 %v0) [ "ptrauth"(i64 1, i64 1234), "ptrauth"(i64 1, i64 5678) ] + %v1 = call i64 @llvm.ptrauth.resign(i64 %v0) [ "ptrauth"(i64 1, i64 1234, i64 0), "ptrauth"(i64 1, i64 5678, i64 0) ] %v2 = inttoptr i64 %v1 to ptr - %v3 = call i32 %v2() [ "ptrauth"(i64 1, i64 5678) ] + %v3 = call i32 %v2() [ "ptrauth"(i64 1, i64 5678, i64 0) ] ret i32 %v3 } define i32 @test_ptrauth_call_resign_blend(ptr %pp) { ; CHECK-LABEL: @test_ptrauth_call_resign_blend( ; CHECK-NEXT: [[V01:%.*]] = load ptr, ptr [[PP:%.*]], align 8 -; CHECK-NEXT: [[V6:%.*]] = call i32 [[V01]]() [ "ptrauth"(i64 1, i64 1234) ] +; CHECK-NEXT: [[V6:%.*]] = call i32 [[V01]]() [ "ptrauth"(i64 1, i64 1234, i64 0) ] ; CHECK-NEXT: ret i32 [[V6]] ; %v0 = load ptr, ptr %pp, align 8 %v1 = ptrtoint ptr %pp to i64 %v2 = ptrtoint ptr %v0 to i64 - %v4 = call i64 @llvm.ptrauth.resign(i64 %v2) [ "ptrauth"(i64 1, i64 1234), "ptrauth"(i64 1, i64 %v1, i64 5678) ] + %v4 = call i64 @llvm.ptrauth.resign(i64 %v2) [ "ptrauth"(i64 1, i64 1234, i64 0), "ptrauth"(i64 1, i64 5678, i64 %v1) ] %v5 = inttoptr i64 %v4 to ptr - %v6 = call i32 %v5() [ "ptrauth"(i64 1, i64 %v1, i64 5678) ] + %v6 = call i32 %v5() [ "ptrauth"(i64 1, i64 5678, i64 %v1) ] ret i32 %v6 } @@ -56,15 +56,15 @@ define i32 @test_ptrauth_call_resign_blend_2(ptr %pp) { ; CHECK-LABEL: @test_ptrauth_call_resign_blend_2( ; CHECK-NEXT: [[V01:%.*]] = load ptr, ptr [[PP:%.*]], align 8 ; CHECK-NEXT: [[V1:%.*]] = ptrtoint ptr [[PP]] to i64 -; CHECK-NEXT: [[V6:%.*]] = call i32 [[V01]]() [ "ptrauth"(i64 0, i64 [[V1]], i64 5678) ] +; CHECK-NEXT: [[V6:%.*]] = call i32 [[V01]]() [ "ptrauth"(i64 0, i64 5678, i64 [[V1]]) ] ; CHECK-NEXT: ret i32 [[V6]] ; %v0 = load ptr, ptr %pp, align 8 %v1 = ptrtoint ptr %pp to i64 %v2 = ptrtoint ptr %v0 to i64 - %v4 = call i64 @llvm.ptrauth.resign(i64 %v2) [ "ptrauth"(i64 0, i64 %v1, i64 5678), "ptrauth"(i64 0, i64 1234) ] + %v4 = call i64 @llvm.ptrauth.resign(i64 %v2) [ "ptrauth"(i64 0, i64 5678, i64 %v1), "ptrauth"(i64 0, i64 1234, i64 0) ] %v5 = inttoptr i64 %v4 to ptr - %v6 = call i32 %v5() [ "ptrauth"(i64 0, i64 1234) ] + %v6 = call i32 %v5() [ "ptrauth"(i64 0, i64 1234, i64 0) ] ret i32 %v6 } @@ -86,30 +86,30 @@ define i32 @test_ptrauth_call_resign_long_bundle_ops(ptr %pp) { define i32 @test_ptrauth_call_resign_mismatch_key(ptr %p) { ; CHECK-LABEL: @test_ptrauth_call_resign_mismatch_key( ; CHECK-NEXT: [[V0:%.*]] = ptrtoint ptr [[P:%.*]] to i64 -; CHECK-NEXT: [[V1:%.*]] = call i64 @llvm.ptrauth.resign(i64 [[V0]]) [ "ptrauth"(i64 1, i64 1234), "ptrauth"(i64 0, i64 5678) ] +; CHECK-NEXT: [[V1:%.*]] = call i64 @llvm.ptrauth.resign(i64 [[V0]]) [ "ptrauth"(i64 1, i64 1234, i64 0), "ptrauth"(i64 0, i64 5678, i64 0) ] ; CHECK-NEXT: [[V2:%.*]] = inttoptr i64 [[V1]] to ptr -; CHECK-NEXT: [[V3:%.*]] = call i32 [[V2]]() [ "ptrauth"(i64 1, i64 5678) ] +; CHECK-NEXT: [[V3:%.*]] = call i32 [[V2]]() [ "ptrauth"(i64 1, i64 5678, i64 0) ] ; CHECK-NEXT: ret i32 [[V3]] ; %v0 = ptrtoint ptr %p to i64 - %v1 = call i64 @llvm.ptrauth.resign(i64 %v0) [ "ptrauth"(i64 1, i64 1234), "ptrauth"(i64 0, i64 5678) ] + %v1 = call i64 @llvm.ptrauth.resign(i64 %v0) [ "ptrauth"(i64 1, i64 1234, i64 0), "ptrauth"(i64 0, i64 5678, i64 0) ] %v2 = inttoptr i64 %v1 to ptr - %v3 = call i32 %v2() [ "ptrauth"(i64 1, i64 5678) ] + %v3 = call i32 %v2() [ "ptrauth"(i64 1, i64 5678, i64 0) ] ret i32 %v3 } define i32 @test_ptrauth_call_resign_mismatch_disc(ptr %p) { ; CHECK-LABEL: @test_ptrauth_call_resign_mismatch_disc( ; CHECK-NEXT: [[V0:%.*]] = ptrtoint ptr [[P:%.*]] to i64 -; CHECK-NEXT: [[V1:%.*]] = call i64 @llvm.ptrauth.resign(i64 [[V0]]) [ "ptrauth"(i64 1, i64 1234), "ptrauth"(i64 0, i64 9900) ] +; CHECK-NEXT: [[V1:%.*]] = call i64 @llvm.ptrauth.resign(i64 [[V0]]) [ "ptrauth"(i64 1, i64 1234, i64 0), "ptrauth"(i64 0, i64 9900, i64 0) ] ; CHECK-NEXT: [[V2:%.*]] = inttoptr i64 [[V1]] to ptr -; CHECK-NEXT: [[V3:%.*]] = call i32 [[V2]]() [ "ptrauth"(i64 1, i64 5678) ] +; CHECK-NEXT: [[V3:%.*]] = call i32 [[V2]]() [ "ptrauth"(i64 1, i64 5678, i64 0) ] ; CHECK-NEXT: ret i32 [[V3]] ; %v0 = ptrtoint ptr %p to i64 - %v1 = call i64 @llvm.ptrauth.resign(i64 %v0) [ "ptrauth"(i64 1, i64 1234), "ptrauth"(i64 0, i64 9900) ] + %v1 = call i64 @llvm.ptrauth.resign(i64 %v0) [ "ptrauth"(i64 1, i64 1234, i64 0), "ptrauth"(i64 0, i64 9900, i64 0) ] %v2 = inttoptr i64 %v1 to ptr - %v3 = call i32 %v2() [ "ptrauth"(i64 1, i64 5678) ] + %v3 = call i32 %v2() [ "ptrauth"(i64 1, i64 5678, i64 0) ] ret i32 %v3 } @@ -118,17 +118,17 @@ define i32 @test_ptrauth_call_resign_mismatch_blend(ptr %pp) { ; CHECK-NEXT: [[V0:%.*]] = load ptr, ptr [[PP:%.*]], align 8 ; CHECK-NEXT: [[V1:%.*]] = ptrtoint ptr [[PP]] to i64 ; CHECK-NEXT: [[V2:%.*]] = ptrtoint ptr [[V0]] to i64 -; CHECK-NEXT: [[V4:%.*]] = call i64 @llvm.ptrauth.resign(i64 [[V2]]) [ "ptrauth"(i64 1, i64 1234), "ptrauth"(i64 1, i64 [[V1]], i64 5678) ] +; CHECK-NEXT: [[V4:%.*]] = call i64 @llvm.ptrauth.resign(i64 [[V2]]) [ "ptrauth"(i64 1, i64 1234, i64 0), "ptrauth"(i64 1, i64 5678, i64 [[V1]]) ] ; CHECK-NEXT: [[V5:%.*]] = inttoptr i64 [[V4]] to ptr -; CHECK-NEXT: [[V3:%.*]] = call i32 [[V5]]() [ "ptrauth"(i64 1, i64 [[V1]]) ] +; CHECK-NEXT: [[V3:%.*]] = call i32 [[V5]]() [ "ptrauth"(i64 1, i64 0, i64 [[V1]]) ] ; CHECK-NEXT: ret i32 [[V3]] ; %v0 = load ptr, ptr %pp, align 8 %v1 = ptrtoint ptr %pp to i64 %v2 = ptrtoint ptr %v0 to i64 - %v4 = call i64 @llvm.ptrauth.resign(i64 %v2) [ "ptrauth"(i64 1, i64 1234), "ptrauth"(i64 1, i64 %v1, i64 5678) ] + %v4 = call i64 @llvm.ptrauth.resign(i64 %v2) [ "ptrauth"(i64 1, i64 1234, i64 0), "ptrauth"(i64 1, i64 5678, i64 %v1) ] %v5 = inttoptr i64 %v4 to ptr - %v6 = call i32 %v5() [ "ptrauth"(i64 1, i64 %v1) ] + %v6 = call i32 %v5() [ "ptrauth"(i64 1, i64 0, i64 %v1) ] ret i32 %v6 } @@ -153,12 +153,12 @@ define i32 @test_ptrauth_call_resign_long_bundle_ops_mismatch(ptr %pp) { define i32 @test_ptrauth_call_resign_changing_call_key(ptr %p) { ; CHECK-LABEL: @test_ptrauth_call_resign_changing_call_key( -; CHECK-NEXT: [[V3:%.*]] = call i32 [[P:%.*]]() [ "ptrauth"(i64 2, i64 1234) ] +; CHECK-NEXT: [[V3:%.*]] = call i32 [[P:%.*]]() [ "ptrauth"(i64 2, i64 1234, i64 0) ] ; CHECK-NEXT: ret i32 [[V3]] ; %v0 = ptrtoint ptr %p to i64 - %v1 = call i64 @llvm.ptrauth.resign(i64 %v0) [ "ptrauth"(i64 2, i64 1234), "ptrauth"(i64 1, i64 5678) ] + %v1 = call i64 @llvm.ptrauth.resign(i64 %v0) [ "ptrauth"(i64 2, i64 1234, i64 0), "ptrauth"(i64 1, i64 5678, i64 0) ] %v2 = inttoptr i64 %v1 to ptr - %v3 = call i32 %v2() [ "ptrauth"(i64 1, i64 5678) ] + %v3 = call i32 %v2() [ "ptrauth"(i64 1, i64 5678, i64 0) ] ret i32 %v3 } diff --git a/llvm/test/Transforms/InstCombine/ptrauth-intrinsics.ll b/llvm/test/Transforms/InstCombine/ptrauth-intrinsics.ll index d33ee4b3df20d..1ec26c927078f 100644 --- a/llvm/test/Transforms/InstCombine/ptrauth-intrinsics.ll +++ b/llvm/test/Transforms/InstCombine/ptrauth-intrinsics.ll @@ -43,6 +43,14 @@ define i64 @test_ptrauth_nop_constant_addrdisc() { ret i64 %authed } +define i64 @test_ptrauth_nop_constant_long_bundle() { +; CHECK-LABEL: @test_ptrauth_nop_constant_long_bundle( +; CHECK-NEXT: ret i64 ptrtoint (ptr @foo to i64) +; + %authed = call i64 @llvm.ptrauth.auth(i64 ptrtoint(ptr ptrauth(ptr @foo, [i64 1, i64 1234, i64 0, i64 ptrtoint (ptr @bar to i64)]) to i64)) [ "ptrauth"(i64 1, i64 1234, i64 0, i64 ptrtoint (ptr @bar to i64)) ] + ret i64 %authed +} + define i64 @test_ptrauth_nop_mismatch(ptr %p) { ; CHECK-LABEL: @test_ptrauth_nop_mismatch( ; CHECK-NEXT: [[TMP0:%.*]] = ptrtoint ptr [[P:%.*]] to i64 @@ -82,6 +90,33 @@ define i64 @test_ptrauth_nop_long_bundle_ops_mismatch(ptr %p) { ret i64 %authed } +define i64 @test_ptrauth_nop_constant_long_bundle_mismatch_ints() { +; CHECK-LABEL: @test_ptrauth_nop_constant_long_bundle_mismatch_ints( +; CHECK-NEXT: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 ptrtoint (ptr ptrauth (ptr @foo, [i64 1, i64 1234, i64 0, i64 ptrtoint (ptr @bar to i64), i64 42]) to i64)) [ "ptrauth"(i64 1, i64 1234, i64 0, i64 ptrtoint (ptr @bar to i64), i64 1) ] +; CHECK-NEXT: ret i64 [[AUTHED]] +; + %authed = call i64 @llvm.ptrauth.auth(i64 ptrtoint(ptr ptrauth(ptr @foo, [i64 1, i64 1234, i64 0, i64 ptrtoint (ptr @bar to i64), i64 42]) to i64)) [ "ptrauth"(i64 1, i64 1234, i64 0, i64 ptrtoint (ptr @bar to i64), i64 1) ] + ret i64 %authed +} + +define i64 @test_ptrauth_nop_constant_long_bundle_mismatch_ptrs() { +; CHECK-LABEL: @test_ptrauth_nop_constant_long_bundle_mismatch_ptrs( +; CHECK-NEXT: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 ptrtoint (ptr ptrauth (ptr @foo, [i64 1, i64 1234, i64 0, i64 ptrtoint (ptr @foo to i64)]) to i64)) [ "ptrauth"(i64 1, i64 1234, i64 0, i64 ptrtoint (ptr @bar to i64)) ] +; CHECK-NEXT: ret i64 [[AUTHED]] +; + %authed = call i64 @llvm.ptrauth.auth(i64 ptrtoint(ptr ptrauth(ptr @foo, [i64 1, i64 1234, i64 0, i64 ptrtoint (ptr @foo to i64)]) to i64)) [ "ptrauth"(i64 1, i64 1234, i64 0, i64 ptrtoint (ptr @bar to i64)) ] + ret i64 %authed +} + +define i64 @test_ptrauth_nop_constant_long_bundle_mismatch_int_vs_ptr() { +; CHECK-LABEL: @test_ptrauth_nop_constant_long_bundle_mismatch_int_vs_ptr( +; CHECK-NEXT: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 ptrtoint (ptr ptrauth (ptr @foo, [i64 1, i64 1234, i64 0, i64 42]) to i64)) [ "ptrauth"(i64 1, i64 1234, i64 0, i64 ptrtoint (ptr @bar to i64)) ] +; CHECK-NEXT: ret i64 [[AUTHED]] +; + %authed = call i64 @llvm.ptrauth.auth(i64 ptrtoint(ptr ptrauth(ptr @foo, [i64 1, i64 1234, i64 0, i64 42]) to i64)) [ "ptrauth"(i64 1, i64 1234, i64 0, i64 ptrtoint (ptr @bar to i64)) ] + ret i64 %authed +} + define i64 @test_ptrauth_sign_resign(ptr %p) { ; CHECK-LABEL: @test_ptrauth_sign_resign( ; CHECK-NEXT: [[TMP0:%.*]] = ptrtoint ptr [[P:%.*]] to i64 From 6445ea73c5d112f7c914036c0abfec3d13cf34d9 Mon Sep 17 00:00:00 2001 From: Anatoly Trosinenko Date: Mon, 15 Dec 2025 23:02:56 +0300 Subject: [PATCH 35/40] Update the docs --- llvm/docs/GlobalISel/GenericOpcode.rst | 64 ++++++++++++++++++++++++-- llvm/docs/LangRef.rst | 16 ++----- llvm/docs/PointerAuth.md | 6 +-- 3 files changed, 67 insertions(+), 19 deletions(-) diff --git a/llvm/docs/GlobalISel/GenericOpcode.rst b/llvm/docs/GlobalISel/GenericOpcode.rst index 71f16645d5a58..bece9daabf0d6 100644 --- a/llvm/docs/GlobalISel/GenericOpcode.rst +++ b/llvm/docs/GlobalISel/GenericOpcode.rst @@ -60,18 +60,72 @@ The address of a global value. %0(p0) = G_GLOBAL_VALUE @var_local +G_PTRAUTH_SCHEMA +^^^^^^^^^^^^^^^^ + +The signing schema to use for one of Pointer Authentication operations, that is +the description of how to compute the discriminator value and which key to use. +The instruction accepts variable number of `i64` operands, whose number and +semantic is target-dependent and corresponds to the elements of `"ptrauth"` +operand bundle or the schema part of `ptrauth` constant expression. +The instruction produces an opaque token value to be passed to other +`G_PTRAUTH_*` instructions. + +.. code-block:: none + + %0:_(s0) = G_PTRAUTH_SCHEMA %1:_(s64), ... + G_PTRAUTH_GLOBAL_VALUE ^^^^^^^^^^^^^^^^^^^^^^ -The signed address of a global value. Operands: address to be signed (pointer), -key (32-bit imm), address for address discrimination (zero if not needed) and -an extra discriminator (64-bit imm). +The signed address of a global value. Operands: address to be signed (pointer) +and an opaque token produced by `G_PTRAUTH_SCHEMA`. + +.. code-block:: none + + %0:_(p0) = G_PTRAUTH_GLOBAL_VALUE %1:_(p0), %2:_(s0) + +G_PTRAUTH_AUTH +^^^^^^^^^^^^^^ + +Authenticate a pointer value (converted to an integer) according to the signing +schema specified by the token operand. + +.. code-block:: none + + %0:_(s64) = G_PTRAUTH_AUTH %1:_, %2:_(s0) + +G_PTRAUTH_SIGN +^^^^^^^^^^^^^^ + +Sign a pointer value (converted to an integer) according to the signing +schema specified by the token operand. + +.. code-block:: none + + %0:_(s64) = G_PTRAUTH_SIGN %1:_, %2:_(s0) + +G_PTRAUTH_RESIGN +^^^^^^^^^^^^^^^^ + +Authenticate a pointer value (converted to an integer) and re-sign it according +to the signing schemas specified by the token operands. + +.. code-block:: none + + %0:_(s64) = G_PTRAUTH_RESIGN %1:_, %2:_(s0), %3:_(s0) + +G_PTRAUTH_STRIP +^^^^^^^^^^^^^^^ -FIXME +Produces non-signed pointer value without authenticating. +Accepts a pointer value (converted to an integer) and a token providing the +information about the signing schema that produced this value (the particular +semantic of this information is target-specific). .. code-block:: none - %0:_(p0) = G_PTRAUTH_GLOBAL_VALUE %1:_(p0), s32, %2:_(p0), s64 + %0:_(s64) = G_PTRAUTH_STRIP %1:_, %2:_(s0) G_BLOCK_ADDR ^^^^^^^^^^^^ diff --git a/llvm/docs/LangRef.rst b/llvm/docs/LangRef.rst index 023a1f85c48be..d31b56f5a76a6 100644 --- a/llvm/docs/LangRef.rst +++ b/llvm/docs/LangRef.rst @@ -5302,7 +5302,7 @@ need to refer to the actual function body. Pointer Authentication Constants -------------------------------- -``ptrauth (ptr CST, i32 KEY[, i64 DISC[, ptr ADDRDISC[, ptr DS]?]?]?)`` +``ptrauth (ptr CST, [i64 op1, ...], ptr DS)`` or ``ptrauth (ptr CST, [i64 op1, ...])`` A '``ptrauth``' constant represents a pointer with a cryptographic authentication signature embedded into some bits, as described in the @@ -5311,16 +5311,15 @@ authentication signature embedded into some bits, as described in the A '``ptrauth``' constant is simply a constant equivalent to the ``llvm.ptrauth.sign`` intrinsic. -Its type is the same as the first argument. An integer constant discriminator -and an address discriminator may be optionally specified. Otherwise, they have -values ``i64 0`` and ``ptr null``. +Its type is the same as the first argument. A variable number of `i64` operands +corresponds to a "``ptrauth``" operand bundle. -The expression '``ptrauth(ptr CST, i32 KEY, i64 DISC, ptr ADDRDISC)``' is +The expression '``ptrauth(ptr CST, [i64 op1, ..., i64 opN])``' is equivalent to .. code-block:: llvm - %tmp = call i64 @llvm.ptrauth.sign(i64 ptrtoint (ptr CST to i64)) [ "ptrauth"(i64 KEY, i64 DISC, i64 ptrtoint (ptr ADDRDISC to i64)) ] + %tmp = call i64 @llvm.ptrauth.sign(i64 ptrtoint (ptr CST to i64)) [ "ptrauth"(i64 op1, ..., i64 opN) ] %val = inttoptr i64 %tmp to ptr If the deactivation symbol operand ``DS`` has a non-null value, @@ -5330,11 +5329,6 @@ calls above, with ``DS`` as the only operand. .. _constantexprs: -That is, the first operand of '``ptrauth``' constant is the pointer to be -signed (the only argument of '``@llvm.ptrauth.sign``') and all the remaining -operands have the same interpretation as in ``"ptrauth"`` call operand bundle -(with trivial type conversion). - Constant Expressions -------------------- diff --git a/llvm/docs/PointerAuth.md b/llvm/docs/PointerAuth.md index 17c8d912bf125..7ffcacd16a333 100644 --- a/llvm/docs/PointerAuth.md +++ b/llvm/docs/PointerAuth.md @@ -258,14 +258,14 @@ The latter are represented using a which describes an authenticated relocation producing a signed pointer. ```llvm -ptrauth (ptr CST, i32 KEY, i64 DISC, ptr ADDRDISC) +ptrauth (ptr CST, [i64 op1, ..., i64 opN]) ``` is equivalent to: ```llvm - %disc = call i64 @llvm.ptrauth.blend(i64 ptrtoint(ptr ADDRDISC to i64), i64 DISC) - %signedval = call i64 @llvm.ptrauth.sign(ptr CST, i32 KEY, i64 %disc) + %signedval = call i64 @llvm.ptrauth.sign(i64 ptrtoint (ptr CST to i64)) [ "ptrauth"(i64 op1, ..., i64 opN) ] + %result = inttoptr i64 %signedval to ptr ``` From 3d7ecca704d4b23055d2dd20d90b659bea9f2ca3 Mon Sep 17 00:00:00 2001 From: Anatoly Trosinenko Date: Tue, 16 Dec 2025 14:01:40 +0300 Subject: [PATCH 36/40] Add more test cases & improve validation --- llvm/lib/Target/AArch64/AArch64AsmPrinter.cpp | 26 ++- .../Target/AArch64/AArch64ISelLowering.cpp | 60 +++---- llvm/lib/Target/AArch64/AArch64ISelLowering.h | 8 + .../ptrauth-constant-unsupported-schema.ll | 161 ++++++++++++++++++ llvm/test/CodeGen/AArch64/ptrauth-reloc.ll | 9 +- .../AArch64/ptrauth-unsupported-bundle.ll | 75 ++++++-- 6 files changed, 272 insertions(+), 67 deletions(-) create mode 100644 llvm/test/CodeGen/AArch64/ptrauth-constant-unsupported-schema.ll diff --git a/llvm/lib/Target/AArch64/AArch64AsmPrinter.cpp b/llvm/lib/Target/AArch64/AArch64AsmPrinter.cpp index 38cd00890698a..c88ff125b26c1 100644 --- a/llvm/lib/Target/AArch64/AArch64AsmPrinter.cpp +++ b/llvm/lib/Target/AArch64/AArch64AsmPrinter.cpp @@ -2564,6 +2564,14 @@ const MCExpr * AArch64AsmPrinter::lowerConstantPtrAuth(const ConstantPtrAuth &CPA) { MCContext &Ctx = OutContext; + if (auto Error = AArch64TargetLowering::validateSinglePtrAuthSchema( + CPA.getSchema(), /*ExpectSingleElement=*/false)) { + errs() << "Ptrauth schema violates target-specific constraints:\n"; + CPA.print(errs()); + errs() << "\n"; + reportFatalUsageError(("Invalid ptrauth schema: " + *Error).c_str()); + } + // Figure out the base symbol and the addend, if any. APInt Offset(64, 0); const Value *BaseGV = CPA.getPointer()->stripAndAccumulateConstantOffsets( @@ -2592,22 +2600,8 @@ AArch64AsmPrinter::lowerConstantPtrAuth(const ConstantPtrAuth &CPA) { DSExpr = MCSymbolRefExpr::create(getSymbol(DS), Ctx); } - uint64_t KeyID = CPA.getKey()->getZExtValue(); - // We later rely on valid KeyID value in AArch64PACKeyIDToString call from - // AArch64AuthMCExpr::printImpl, so fail fast. - if (KeyID > AArch64PACKey::LAST) { - CPA.getContext().emitError("AArch64 PAC Key ID '" + Twine(KeyID) + - "' out of range [0, " + - Twine((unsigned)AArch64PACKey::LAST) + "]"); - KeyID = 0; - } - - uint64_t Disc = CPA.getDiscriminator()->getZExtValue(); - if (!isUInt<16>(Disc)) { - CPA.getContext().emitError("AArch64 PAC Discriminator '" + Twine(Disc) + - "' out of range [0, 0xFFFF]"); - Disc = 0; - } + uint64_t KeyID = cast(CPA.getSchema()[0])->getZExtValue(); + uint64_t Disc = cast(CPA.getSchema()[1])->getZExtValue(); // Check if we need to represent this with an IRELATIVE and emit it if so. if (auto *IFuncSym = emitPAuthRelocationAsIRelative( diff --git a/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp b/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp index 0aa634b015bd4..c4947781dc44a 100644 --- a/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp +++ b/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp @@ -29935,40 +29935,36 @@ bool AArch64TargetLowering::preferSelectsOverBooleanArithmetic(EVT VT) const { } std::optional -AArch64TargetLowering::validatePtrAuthSchema(const Value &V) const { - auto GetMsg = [&V](Twine Str) -> std::string { - if (auto *CB = dyn_cast(&V)) - return (CB->getFunction()->getName() + ": " + Str).str(); - return Str.str(); - }; - - auto ValidateSchema = [&](ArrayRef Schema, bool ExpectSingleElement) -> std::optional{ - unsigned NumOperands = Schema.size(); - if (ExpectSingleElement) { - if (NumOperands != 1) - return GetMsg("single-element ptrauth bundle expected"); - } else { - if (NumOperands != 3) - return GetMsg("three-element ptrauth bundle expected"); - } +AArch64TargetLowering::validateSinglePtrAuthSchema(ArrayRef Schema, + bool ExpectSingleElement) { + unsigned NumOperands = Schema.size(); + if (ExpectSingleElement) { + if (NumOperands != 1) + return "single-element ptrauth schema expected"; + } else { + if (NumOperands != 3) + return "three-element ptrauth schema expected"; + } - // The first operand is always the key ID. - auto *Key = dyn_cast(Schema[0]); - if (!Key || Key->getZExtValue() > AArch64PACKey::LAST) - return GetMsg("key must be constant in range [0, " + - Twine((int)AArch64PACKey::LAST) + "]"); + // The first operand is always the key ID. + auto *Key = dyn_cast(Schema[0]); + if (!Key || Key->getZExtValue() > AArch64PACKey::LAST) + return ("key must be constant in range [0, " + + Twine((int)AArch64PACKey::LAST) + "]").str(); - // Done validating single-operand bundles. - if (NumOperands == 1) - return std::nullopt; + // Done validating single-operand schemas. + if (NumOperands == 1) + return std::nullopt; - auto *IntDisc = dyn_cast(Schema[1]); - if (!IntDisc || !isUInt<16>(IntDisc->getZExtValue())) - return GetMsg("constant modifier must be 16-bit unsigned constant"); + auto *IntDisc = dyn_cast(Schema[1]); + if (!IntDisc || !isUInt<16>(IntDisc->getZExtValue())) + return "constant modifier must be 16-bit unsigned constant"; - return std::nullopt; - }; + return std::nullopt; +} +std::optional +AArch64TargetLowering::validatePtrAuthSchema(const Value &V) const { if (auto *CB = dyn_cast(&V)) { for (unsigned I = 0, N = CB->getNumOperandBundles(); I < N; ++I) { OperandBundleUse OB = CB->getOperandBundleAt(I); @@ -29977,14 +29973,14 @@ AArch64TargetLowering::validatePtrAuthSchema(const Value &V) const { bool ExpectSingleElement = CB->getIntrinsicID() == Intrinsic::ptrauth_strip; - if (auto Err = ValidateSchema(OB.Inputs, ExpectSingleElement)) - return Err; + if (auto Error = validateSinglePtrAuthSchema(OB.Inputs, ExpectSingleElement)) + return (CB->getFunction()->getName() + ": " + *Error).str(); } return std::nullopt; } auto &CPA = cast(V); - return ValidateSchema(CPA.getSchema(), /*ExpectSingleElement=*/false); + return validateSinglePtrAuthSchema(CPA.getSchema(), /*ExpectSingleElement=*/false); } MachineInstr * diff --git a/llvm/lib/Target/AArch64/AArch64ISelLowering.h b/llvm/lib/Target/AArch64/AArch64ISelLowering.h index 34081ed2d5072..c8d7ac66d1fbd 100644 --- a/llvm/lib/Target/AArch64/AArch64ISelLowering.h +++ b/llvm/lib/Target/AArch64/AArch64ISelLowering.h @@ -465,6 +465,14 @@ class AArch64TargetLowering : public TargetLowering { return true; } + // Check a single PtrAuth schema description. + // + // FIXME This static function is defined not to duplicate code between + // AArch64AsmParser (to validate global ptrauth constants) and + // AArch64TargetLowering (to validate everything else). + static std::optional + validateSinglePtrAuthSchema(ArrayRef Schema, bool ExpectSingleElement); + std::optional validatePtrAuthSchema(const Value &V) const override; diff --git a/llvm/test/CodeGen/AArch64/ptrauth-constant-unsupported-schema.ll b/llvm/test/CodeGen/AArch64/ptrauth-constant-unsupported-schema.ll new file mode 100644 index 0000000000000..994a0c7e213d1 --- /dev/null +++ b/llvm/test/CodeGen/AArch64/ptrauth-constant-unsupported-schema.ll @@ -0,0 +1,161 @@ +; RUN: split-file %s %t +; REQUIRES: x86-registered-target + +; Note: x86 here is an arbitrary target that does *not* support PtrAuth - to be +; used by unsupported-target.ll test case. +; Note: Target-specific constraints are checked during the ISel, thus the +; corresponding test cases have RUN lines duplicated: for DAGISel and +; for GlobalISel. + +; FIXME Several kinds of invalid ptrauth constants are first unconditionally +; rejected by LLParser, then asserted-on by ConstantPtrAuth constructor +; (but only in assertion builds) and then unconditionally rejected by the +; verifier (if IR verification is requested). This way the verifier is +; not very testable. +; FIXME Is it feasible to assemble an invalid *.bc for testing? + +;--- empty.ll +; RUN: not llc -mtriple aarch64 -mattr=+pauth < %t/empty.ll 2>&1 | FileCheck --check-prefix=EMPTY %s + +; Empty schemas are rejected by target-independent *.ll source parser. + +; EMPTY: :{{.*}}:11: error: schema of ptrauth constant must not be empty +; EMPTY-NEXT: ret ptr ptrauth (ptr @glob, []) + +@glob = external global i32 + +define ptr @test() { + ret ptr ptrauth (ptr @glob, []) +} + +;--- wrong-type-i32.ll +; RUN: not llc -mtriple aarch64 -mattr=+pauth < %t/wrong-type-i32.ll 2>&1 | FileCheck --check-prefix=WRONG-TYPE-I32 %s + +; WRONG-TYPE-I32: :{{.*}}:11: error: schema of ptrauth constant must be a tuple of i64 +; WRONG-TYPE-I32-NEXT: ret ptr ptrauth (ptr @glob, [i32 0, i64 0, i64 0]) + +@glob = external global i32 + +define ptr @test() { + ret ptr ptrauth (ptr @glob, [i32 0, i64 0, i64 0]) +} + +;--- wrong-type-ptr.ll +; RUN: not llc -mtriple aarch64 -mattr=+pauth < %t/wrong-type-ptr.ll 2>&1 | FileCheck --check-prefix=WRONG-TYPE-PTR %s + +; WRONG-TYPE-PTR: :{{.*}}:11: error: schema of ptrauth constant must be a tuple of i64 +; WRONG-TYPE-PTR-NEXT: ret ptr ptrauth (ptr @glob, [i64 0, i64 0, ptr null]) + +@glob = external global i32 + +define ptr @test() { + ret ptr ptrauth (ptr @glob, [i64 0, i64 0, ptr null]) +} + +;--- unsupported-target.ll +; RUN: not llc -mtriple x86_64 -global-isel=0 < %t/unsupported-target.ll 2>&1 | FileCheck --check-prefix=UNSUPPORTED-TARGET %s +; RUN: not llc -mtriple x86_64 -global-isel=1 -global-isel-abort=1 < %t/unsupported-target.ll 2>&1 | FileCheck --check-prefix=UNSUPPORTED-TARGET %s + +; UNSUPPORTED-TARGET: Ptrauth schema violates target-specific constraints: +; UNSUPPORTED-TARGET-NEXT: ptr ptrauth (ptr @glob, [i64 0, i64 0, i64 0]) +; UNSUPPORTED-TARGET-NEXT: LLVM ERROR: Invalid ptrauth schema: this target does not support pointer authentication + +@glob = external global i32 + +define ptr @test() { + ret ptr ptrauth (ptr @glob, [i64 0, i64 0, i64 0]) +} + +;--- wrong-not-3-ops.ll +; RUN: not llc -mtriple aarch64 -mattr=+pauth < %t/wrong-not-3-ops.ll 2>&1 | FileCheck --check-prefix=WRONG-NOT-3-OPS %s +; RUN: not llc -mtriple aarch64 -mattr=+pauth -global-isel=1 -global-isel-abort=1 < %t/wrong-not-3-ops.ll 2>&1 | FileCheck --check-prefix=WRONG-NOT-3-OPS %s + +; WRONG-NOT-3-OPS: Ptrauth schema violates target-specific constraints: +; WRONG-NOT-3-OPS-NEXT: ptr ptrauth (ptr @glob, [i64 0, i64 0]) +; WRONG-NOT-3-OPS-NEXT: LLVM ERROR: Invalid ptrauth schema: three-element ptrauth schema expected + +@glob = external global i32 + +define ptr @test() { + ret ptr ptrauth (ptr @glob, [i64 0, i64 0]) +} + +;--- wrong-key-negative.ll +; RUN: not llc -mtriple aarch64 -mattr=+pauth < %t/wrong-key-negative.ll 2>&1 | FileCheck --check-prefix=WRONG-KEY-NEGATIVE %s +; RUN: not llc -mtriple aarch64 -mattr=+pauth -global-isel=1 -global-isel-abort=1 < %t/wrong-key-negative.ll 2>&1 | FileCheck --check-prefix=WRONG-KEY-NEGATIVE %s + +; WRONG-KEY-NEGATIVE: Ptrauth schema violates target-specific constraints: +; WRONG-KEY-NEGATIVE-NEXT: ptr ptrauth (ptr @glob, [i64 -1, i64 0, i64 0]) +; WRONG-KEY-NEGATIVE-NEXT: LLVM ERROR: Invalid ptrauth schema: key must be constant in range [0, 3] + +@glob = external global i32 + +define ptr @test() { + ret ptr ptrauth (ptr @glob, [i64 -1, i64 0, i64 0]) +} + +;--- wrong-key-out-of-range.ll +; RUN: not llc -mtriple aarch64 -mattr=+pauth < %t/wrong-key-out-of-range.ll 2>&1 | FileCheck --check-prefix=WRONG-KEY-OUT-OF-RANGE %s +; RUN: not llc -mtriple aarch64 -mattr=+pauth -global-isel=1 -global-isel-abort=1 < %t/wrong-key-out-of-range.ll 2>&1 | FileCheck --check-prefix=WRONG-KEY-OUT-OF-RANGE %s + +; WRONG-KEY-OUT-OF-RANGE: Ptrauth schema violates target-specific constraints: +; WRONG-KEY-OUT-OF-RANGE-NEXT: ptr ptrauth (ptr @glob, [i64 4, i64 0, i64 0]) +; WRONG-KEY-OUT-OF-RANGE-NEXT: LLVM ERROR: Invalid ptrauth schema: key must be constant in range [0, 3] + +@glob = external global i32 + +define ptr @test() { + ret ptr ptrauth (ptr @glob, [i64 4, i64 0, i64 0]) +} + +;--- wrong-imm-modifier-negative.ll +; RUN: not llc -mtriple aarch64 -mattr=+pauth < %t/wrong-imm-modifier-negative.ll 2>&1 | FileCheck --check-prefix=WRONG-IMM-MODIFIER-NEGATIVE %s +; RUN: not llc -mtriple aarch64 -mattr=+pauth -global-isel=1 -global-isel-abort=1 < %t/wrong-imm-modifier-negative.ll 2>&1 | FileCheck --check-prefix=WRONG-IMM-MODIFIER-NEGATIVE %s + +; WRONG-IMM-MODIFIER-NEGATIVE: Ptrauth schema violates target-specific constraints: +; WRONG-IMM-MODIFIER-NEGATIVE-NEXT: ptr ptrauth (ptr @glob, [i64 0, i64 -1, i64 0]) +; WRONG-IMM-MODIFIER-NEGATIVE-NEXT: LLVM ERROR: Invalid ptrauth schema: constant modifier must be 16-bit unsigned constant + +@glob = external global i32 + +define ptr @test() { + ret ptr ptrauth (ptr @glob, [i64 0, i64 -1, i64 0]) +} + +;--- wrong-imm-modifier-too-wide.ll +; RUN: not llc -mtriple aarch64 -mattr=+pauth < %t/wrong-imm-modifier-too-wide.ll 2>&1 | FileCheck --check-prefix=WRONG-IMM-MODIFIER-TOO-WIDE %s +; RUN: not llc -mtriple aarch64 -mattr=+pauth -global-isel=1 -global-isel-abort=1 < %t/wrong-imm-modifier-too-wide.ll 2>&1 | FileCheck --check-prefix=WRONG-IMM-MODIFIER-TOO-WIDE %s + +; WRONG-IMM-MODIFIER-TOO-WIDE: Ptrauth schema violates target-specific constraints: +; WRONG-IMM-MODIFIER-TOO-WIDE-NEXT: ptr ptrauth (ptr @glob, [i64 0, i64 123456, i64 0]) +; WRONG-IMM-MODIFIER-TOO-WIDE-NEXT: LLVM ERROR: Invalid ptrauth schema: constant modifier must be 16-bit unsigned constant + +@glob = external global i32 + +define ptr @test() { + ret ptr ptrauth (ptr @glob, [i64 0, i64 123456, i64 0]) +} + +; Global ptrauth constants are validated in AsmPrinter instead of ISel. +; Furthermore, the validation code is not target-neutral now, thus the +; below two test cases check that 1) ptrauth constants are rejected on +; non-supported targets (i.e. by default) and 2) validation code is +; invoked on AArch64. + +;--- unsupported-global-constant.ll +; RUN: not llc -mtriple x86_64 < %t/unsupported-global-constant.ll 2>&1 | FileCheck --check-prefix=UNSUPPORTED-GLOBAL-CONSTANT %s + +; UNSUPPORTED-GLOBAL-CONSTANT: LLVM ERROR: ptrauth constant lowering not implemented + +@glob = external global i32 +@const = constant ptr ptrauth (ptr @glob, [i64 0, i64 0]) + +;--- wrong-global-constant.ll +; RUN: not llc -mtriple aarch64 -mattr=+pauth < %t/wrong-global-constant.ll 2>&1 | FileCheck --check-prefix=WRONG-GLOBAL-CONSTANT %s + +; WRONG-GLOBAL-CONSTANT: Ptrauth schema violates target-specific constraints: +; WRONG-GLOBAL-CONSTANT-NEXT: ptr ptrauth (ptr @glob, [i64 0, i64 0]) +; WRONG-GLOBAL-CONSTANT-NEXT: LLVM ERROR: Invalid ptrauth schema: three-element ptrauth schema expected + +@glob = external global i32 +@const = constant ptr ptrauth (ptr @glob, [i64 0, i64 0]) diff --git a/llvm/test/CodeGen/AArch64/ptrauth-reloc.ll b/llvm/test/CodeGen/AArch64/ptrauth-reloc.ll index e128c941152a4..2c067f9de31c6 100644 --- a/llvm/test/CodeGen/AArch64/ptrauth-reloc.ll +++ b/llvm/test/CodeGen/AArch64/ptrauth-reloc.ll @@ -151,8 +151,9 @@ ; RUN: -global-isel -verify-machineinstrs -global-isel-abort=1 2>&1 \ ; RUN: | FileCheck %s --check-prefix=CHECK-ERR-KEY -; CHECK-ERR-KEY: error: AArch64 PAC Key ID '4' out of range [0, 3] - +; CHECK-ERR-KEY: Ptrauth schema violates target-specific constraints: +; CHECK-ERR-KEY-NEXT: ptr ptrauth (ptr @g, [i64 4, i64 0, i64 0]) +; CHECK-ERR-KEY-NEXT: LLVM ERROR: Invalid ptrauth schema: key must be constant in range [0, 3] @g = external global i32 @g.ref.4.0 = constant ptr ptrauth (ptr @g, [i64 4, i64 0, i64 0]) @@ -171,7 +172,9 @@ ; RUN: -global-isel -verify-machineinstrs -global-isel-abort=1 2>&1 \ ; RUN: | FileCheck %s --check-prefix=CHECK-ERR-DISC -; CHECK-ERR-DISC: error: AArch64 PAC Discriminator '65536' out of range [0, 0xFFFF] +; CHECK-ERR-DISC: Ptrauth schema violates target-specific constraints: +; CHECK-ERR-DISC-NEXT: ptr ptrauth (ptr @g, [i64 0, i64 65536, i64 0]) +; CHECK-ERR-DISC-NEXT: LLVM ERROR: Invalid ptrauth schema: constant modifier must be 16-bit unsigned constant @g = external global i32 @g.ref.ia.65536 = constant ptr ptrauth (ptr @g, [i64 0, i64 65536, i64 0]) diff --git a/llvm/test/CodeGen/AArch64/ptrauth-unsupported-bundle.ll b/llvm/test/CodeGen/AArch64/ptrauth-unsupported-bundle.ll index f448c33bfab6a..863d23373e9ee 100644 --- a/llvm/test/CodeGen/AArch64/ptrauth-unsupported-bundle.ll +++ b/llvm/test/CodeGen/AArch64/ptrauth-unsupported-bundle.ll @@ -1,6 +1,12 @@ ; RUN: split-file %s %t ; REQUIRES: x86-registered-target +; Note: x86 here is an arbitrary target that does *not* support PtrAuth - to be +; used by unsupported-target-*.ll test cases. +; Note: Target-specific constraints are checked during the ISel, thus the +; corresponding test cases have RUN lines duplicated: for DAGISel and +; for GlobalISel. + ;--- empty.ll ; RUN: not llc -mtriple aarch64 -mattr=+pauth < %t/empty.ll 2>&1 | FileCheck --check-prefix=EMPTY %s @@ -94,7 +100,8 @@ define i64 @test(ptr %fptr) { ret i64 %res } ;--- unsupported-target-intrinsic.ll -; RUN: not llc -mtriple x86_64 < %t/unsupported-target-intrinsic.ll 2>&1 | FileCheck --check-prefix=UNSUPPORTED-TARGET-INTRINSIC %s +; RUN: not llc -mtriple x86_64 < %t/unsupported-target-intrinsic.ll 2>&1 | FileCheck --check-prefix=UNSUPPORTED-TARGET-INTRINSIC %s +; RUN: not llc -mtriple x86_64 -global-isel=1 -global-isel-abort=1 < %t/unsupported-target-intrinsic.ll 2>&1 | FileCheck --check-prefix=UNSUPPORTED-TARGET-INTRINSIC %s ; UNSUPPORTED-TARGET-INTRINSIC: Ptrauth schema violates target-specific constraints: ; UNSUPPORTED-TARGET-INTRINSIC-NEXT: %res = call i64 @llvm.ptrauth.sign(i64 %p) [ "ptrauth"(i64 0) ] @@ -106,7 +113,8 @@ define i64 @test(i64 %p) { } ;--- unsupported-target-indirect-call.ll -; RUN: not llc -mtriple x86_64 < %t/unsupported-target-indirect-call.ll 2>&1 | FileCheck --check-prefix=UNSUPPORTED-TARGET-INDIRECT-CALL %s +; RUN: not llc -mtriple x86_64 < %t/unsupported-target-indirect-call.ll 2>&1 | FileCheck --check-prefix=UNSUPPORTED-TARGET-INDIRECT-CALL %s +; RUN: not llc -mtriple x86_64 -global-isel=1 -global-isel-abort=1 < %t/unsupported-target-indirect-call.ll 2>&1 | FileCheck --check-prefix=UNSUPPORTED-TARGET-INDIRECT-CALL %s ; UNSUPPORTED-TARGET-INDIRECT-CALL: Ptrauth schema violates target-specific constraints: ; UNSUPPORTED-TARGET-INDIRECT-CALL-NEXT: %res = call i64 %fptr() [ "ptrauth"(i64 0) ] @@ -118,13 +126,14 @@ define i64 @test(ptr %fptr) { } ;--- wrong-not-3-ops.ll -; RUN: not llc -mtriple aarch64 -mattr=+pauth < %t/wrong-not-3-ops.ll 2>&1 | FileCheck --check-prefix=WRONG-NOT-3-OPS %s +; RUN: not llc -mtriple aarch64 -mattr=+pauth < %t/wrong-not-3-ops.ll 2>&1 | FileCheck --check-prefix=WRONG-NOT-3-OPS %s +; RUN: not llc -mtriple aarch64 -mattr=+pauth -global-isel=1 -global-isel-abort=1 < %t/wrong-not-3-ops.ll 2>&1 | FileCheck --check-prefix=WRONG-NOT-3-OPS %s -; Single-operand bundles are used on AArch64, but not by this intrinsic. +; Single-operand bundles may be used on AArch64, but not by this intrinsic. ; WRONG-NOT-3-OPS: Ptrauth schema violates target-specific constraints: ; WRONG-NOT-3-OPS-NEXT: %res = call i64 @llvm.ptrauth.sign(i64 %p) [ "ptrauth"(i64 0) ] -; WRONG-NOT-3-OPS-NEXT: LLVM ERROR: Invalid ptrauth schema: test: three-element ptrauth bundle expected +; WRONG-NOT-3-OPS-NEXT: LLVM ERROR: Invalid ptrauth schema: test: three-element ptrauth schema expected define i64 @test(i64 %p) { %res = call i64 @llvm.ptrauth.sign(i64 %p) [ "ptrauth"(i64 0) ] @@ -132,13 +141,14 @@ define i64 @test(i64 %p) { } ;--- wrong-not-1-ops.ll -; RUN: not llc -mtriple aarch64 -mattr=+pauth < %t/wrong-not-1-ops.ll 2>&1 | FileCheck --check-prefix=WRONG-NOT-1-OPS %s +; RUN: not llc -mtriple aarch64 -mattr=+pauth < %t/wrong-not-1-ops.ll 2>&1 | FileCheck --check-prefix=WRONG-NOT-1-OPS %s +; RUN: not llc -mtriple aarch64 -mattr=+pauth -global-isel=1 -global-isel-abort=1 < %t/wrong-not-1-ops.ll 2>&1 | FileCheck --check-prefix=WRONG-NOT-1-OPS %s -; Three-operand bundles are used on AArch64, but not by this intrinsic. +; Three-operand bundles may be used on AArch64, but not by this intrinsic. ; WRONG-NOT-1-OPS: Ptrauth schema violates target-specific constraints: ; WRONG-NOT-1-OPS-NEXT: %res = call i64 @llvm.ptrauth.strip(i64 %p) [ "ptrauth"(i64 0, i64 0, i64 0) ] -; WRONG-NOT-1-OPS-NEXT: LLVM ERROR: Invalid ptrauth schema: test: single-element ptrauth bundle expected +; WRONG-NOT-1-OPS-NEXT: LLVM ERROR: Invalid ptrauth schema: test: single-element ptrauth schema expected define i64 @test(i64 %p) { %res = call i64 @llvm.ptrauth.strip(i64 %p) [ "ptrauth"(i64 0, i64 0, i64 0) ] @@ -146,13 +156,14 @@ define i64 @test(i64 %p) { } ;--- wrong-num-operands.ll -; RUN: not llc -mtriple aarch64 -mattr=+pauth < %t/wrong-num-operands.ll 2>&1 | FileCheck --check-prefix=WRONG-NUM-OPERANDS %s +; RUN: not llc -mtriple aarch64 -mattr=+pauth < %t/wrong-num-operands.ll 2>&1 | FileCheck --check-prefix=WRONG-NUM-OPERANDS %s +; RUN: not llc -mtriple aarch64 -mattr=+pauth -global-isel=1 -global-isel-abort=1 < %t/wrong-num-operands.ll 2>&1 | FileCheck --check-prefix=WRONG-NUM-OPERANDS %s ; Four-operand bundles are never used on AArch64. ; WRONG-NUM-OPERANDS: Ptrauth schema violates target-specific constraints: ; WRONG-NUM-OPERANDS-NEXT: %res = call i64 @llvm.ptrauth.sign(i64 %p) [ "ptrauth"(i64 0, i64 0, i64 0, i64 0) ] -; WRONG-NUM-OPERANDS-NEXT: LLVM ERROR: Invalid ptrauth schema: test: three-element ptrauth bundle expected +; WRONG-NUM-OPERANDS-NEXT: LLVM ERROR: Invalid ptrauth schema: test: three-element ptrauth schema expected define i64 @test(i64 %p, i64 %arg) { %res = call i64 @llvm.ptrauth.sign(i64 %p) [ "ptrauth"(i64 0, i64 0, i64 0, i64 0) ] @@ -160,7 +171,8 @@ define i64 @test(i64 %p, i64 %arg) { } ;--- wrong-key-not-const.ll -; RUN: not llc -mtriple aarch64 -mattr=+pauth < %t/wrong-key-not-const.ll 2>&1 | FileCheck --check-prefix=WRONG-KEY-NOT-CONST %s +; RUN: not llc -mtriple aarch64 -mattr=+pauth < %t/wrong-key-not-const.ll 2>&1 | FileCheck --check-prefix=WRONG-KEY-NOT-CONST %s +; RUN: not llc -mtriple aarch64 -mattr=+pauth -global-isel=1 -global-isel-abort=1 < %t/wrong-key-not-const.ll 2>&1 | FileCheck --check-prefix=WRONG-KEY-NOT-CONST %s ; WRONG-KEY-NOT-CONST: Ptrauth schema violates target-specific constraints: ; WRONG-KEY-NOT-CONST-NEXT: %res = call i64 @llvm.ptrauth.sign(i64 %p) [ "ptrauth"(i64 %arg, i64 0, i64 0) ] @@ -171,8 +183,35 @@ define i64 @test(i64 %p, i64 %arg) { ret i64 %res } +;--- wrong-key-negative.ll +; RUN: not llc -mtriple aarch64 -mattr=+pauth < %t/wrong-key-negative.ll 2>&1 | FileCheck --check-prefix=WRONG-KEY-NEGATIVE %s +; RUN: not llc -mtriple aarch64 -mattr=+pauth -global-isel=1 -global-isel-abort=1 < %t/wrong-key-negative.ll 2>&1 | FileCheck --check-prefix=WRONG-KEY-NEGATIVE %s + +; WRONG-KEY-NEGATIVE: Ptrauth schema violates target-specific constraints: +; WRONG-KEY-NEGATIVE-NEXT: %res = call i64 @llvm.ptrauth.sign(i64 %p) [ "ptrauth"(i64 -1, i64 0, i64 0) ] +; WRONG-KEY-NEGATIVE-NEXT: LLVM ERROR: Invalid ptrauth schema: test: key must be constant in range [0, 3] + +define i64 @test(i64 %p, i64 %arg) { + %res = call i64 @llvm.ptrauth.sign(i64 %p) [ "ptrauth"(i64 -1, i64 0, i64 0) ] + ret i64 %res +} + +;--- wrong-key-out-of-range.ll +; RUN: not llc -mtriple aarch64 -mattr=+pauth < %t/wrong-key-out-of-range.ll 2>&1 | FileCheck --check-prefix=WRONG-KEY-OUT-OF-RANGE %s +; RUN: not llc -mtriple aarch64 -mattr=+pauth -global-isel=1 -global-isel-abort=1 < %t/wrong-key-out-of-range.ll 2>&1 | FileCheck --check-prefix=WRONG-KEY-OUT-OF-RANGE %s + +; WRONG-KEY-OUT-OF-RANGE: Ptrauth schema violates target-specific constraints: +; WRONG-KEY-OUT-OF-RANGE-NEXT: %res = call i64 @llvm.ptrauth.sign(i64 %p) [ "ptrauth"(i64 4, i64 0, i64 0) ] +; WRONG-KEY-OUT-OF-RANGE-NEXT: LLVM ERROR: Invalid ptrauth schema: test: key must be constant in range [0, 3] + +define i64 @test(i64 %p, i64 %arg) { + %res = call i64 @llvm.ptrauth.sign(i64 %p) [ "ptrauth"(i64 4, i64 0, i64 0) ] + ret i64 %res +} + ;--- wrong-imm-modifier-not-const.ll -; RUN: not llc -mtriple aarch64 -mattr=+pauth < %t/wrong-imm-modifier-not-const.ll 2>&1 | FileCheck --check-prefix=WRONG-IMM-MODIFIER-NOT-CONST %s +; RUN: not llc -mtriple aarch64 -mattr=+pauth < %t/wrong-imm-modifier-not-const.ll 2>&1 | FileCheck --check-prefix=WRONG-IMM-MODIFIER-NOT-CONST %s +; RUN: not llc -mtriple aarch64 -mattr=+pauth -global-isel=1 -global-isel-abort=1 < %t/wrong-imm-modifier-not-const.ll 2>&1 | FileCheck --check-prefix=WRONG-IMM-MODIFIER-NOT-CONST %s ; WRONG-IMM-MODIFIER-NOT-CONST: Ptrauth schema violates target-specific constraints: ; WRONG-IMM-MODIFIER-NOT-CONST-NEXT: %res = call i64 @llvm.ptrauth.sign(i64 %p) [ "ptrauth"(i64 0, i64 %arg, i64 0) ] @@ -184,7 +223,8 @@ define i64 @test(i64 %p, i64 %arg) { } ;--- wrong-imm-modifier-negative.ll -; RUN: not llc -mtriple aarch64 -mattr=+pauth < %t/wrong-imm-modifier-negative.ll 2>&1 | FileCheck --check-prefix=WRONG-IMM-MODIFIER-NEGATIVE %s +; RUN: not llc -mtriple aarch64 -mattr=+pauth < %t/wrong-imm-modifier-negative.ll 2>&1 | FileCheck --check-prefix=WRONG-IMM-MODIFIER-NEGATIVE %s +; RUN: not llc -mtriple aarch64 -mattr=+pauth -global-isel=1 -global-isel-abort=1 < %t/wrong-imm-modifier-negative.ll 2>&1 | FileCheck --check-prefix=WRONG-IMM-MODIFIER-NEGATIVE %s ; WRONG-IMM-MODIFIER-NEGATIVE: Ptrauth schema violates target-specific constraints: ; WRONG-IMM-MODIFIER-NEGATIVE-NEXT: %res = call i64 @llvm.ptrauth.sign(i64 %p) [ "ptrauth"(i64 0, i64 -1, i64 0) ] @@ -196,7 +236,8 @@ define i64 @test(i64 %p) { } ;--- wrong-imm-modifier-too-wide.ll -; RUN: not llc -mtriple aarch64 -mattr=+pauth < %t/wrong-imm-modifier-too-wide.ll 2>&1 | FileCheck --check-prefix=WRONG-IMM-MODIFIER-TOO-WIDE %s +; RUN: not llc -mtriple aarch64 -mattr=+pauth < %t/wrong-imm-modifier-too-wide.ll 2>&1 | FileCheck --check-prefix=WRONG-IMM-MODIFIER-TOO-WIDE %s +; RUN: not llc -mtriple aarch64 -mattr=+pauth -global-isel=1 -global-isel-abort=1 < %t/wrong-imm-modifier-too-wide.ll 2>&1 | FileCheck --check-prefix=WRONG-IMM-MODIFIER-TOO-WIDE %s ; WRONG-IMM-MODIFIER-TOO-WIDE: Ptrauth schema violates target-specific constraints: ; WRONG-IMM-MODIFIER-TOO-WIDE-NEXT: %res = call i64 @llvm.ptrauth.sign(i64 %p) [ "ptrauth"(i64 0, i64 123456, i64 0) ] @@ -208,7 +249,8 @@ define i64 @test(i64 %p) { } ;--- wrong-first-bundle.ll -; RUN: not llc -mtriple aarch64 -mattr=+pauth < %t/wrong-first-bundle.ll 2>&1 | FileCheck --check-prefix=WRONG-FIRST-BUNDLE %s +; RUN: not llc -mtriple aarch64 -mattr=+pauth < %t/wrong-first-bundle.ll 2>&1 | FileCheck --check-prefix=WRONG-FIRST-BUNDLE %s +; RUN: not llc -mtriple aarch64 -mattr=+pauth -global-isel=1 -global-isel-abort=1 < %t/wrong-first-bundle.ll 2>&1 | FileCheck --check-prefix=WRONG-FIRST-BUNDLE %s ; If the intrinsic accepts two bundles, both should be checked. @@ -222,7 +264,8 @@ define i64 @test(i64 %p, i64 %arg) { } ;--- wrong-second-bundle.ll -; RUN: not llc -mtriple aarch64 -mattr=+pauth < %t/wrong-second-bundle.ll 2>&1 | FileCheck --check-prefix=WRONG-SECOND-BUNDLE %s +; RUN: not llc -mtriple aarch64 -mattr=+pauth < %t/wrong-second-bundle.ll 2>&1 | FileCheck --check-prefix=WRONG-SECOND-BUNDLE %s +; RUN: not llc -mtriple aarch64 -mattr=+pauth -global-isel=1 -global-isel-abort=1 < %t/wrong-second-bundle.ll 2>&1 | FileCheck --check-prefix=WRONG-SECOND-BUNDLE %s ; WRONG-SECOND-BUNDLE: Ptrauth schema violates target-specific constraints: ; WRONG-SECOND-BUNDLE-NEXT: %res = call i64 @llvm.ptrauth.resign(i64 %p) [ "ptrauth"(i64 0, i64 0, i64 0), "ptrauth"(i64 %arg, i64 0, i64 0) ] From 327b1c35b7649e6825b50a09ea09e9e677158ccd Mon Sep 17 00:00:00 2001 From: Anatoly Trosinenko Date: Tue, 16 Dec 2025 18:09:01 +0300 Subject: [PATCH 37/40] Get rid of target-specific accessors in target-neutral code --- clang/lib/CodeGen/ItaniumCXXABI.cpp | 14 +++++--- llvm/include/llvm/IR/Constants.h | 35 ------------------- llvm/include/llvm/SandboxIR/Constant.h | 34 +----------------- llvm/lib/IR/Constants.cpp | 8 ----- llvm/lib/IR/Core.cpp | 12 +++++-- llvm/lib/SandboxIR/Constant.cpp | 28 ++------------- llvm/lib/Target/AArch64/AArch64AsmPrinter.cpp | 25 ++++++++++--- llvm/unittests/SandboxIR/SandboxIRTest.cpp | 29 +++++++-------- 8 files changed, 55 insertions(+), 130 deletions(-) diff --git a/clang/lib/CodeGen/ItaniumCXXABI.cpp b/clang/lib/CodeGen/ItaniumCXXABI.cpp index 47db6847063ac..0d7824d12caa4 100644 --- a/clang/lib/CodeGen/ItaniumCXXABI.cpp +++ b/clang/lib/CodeGen/ItaniumCXXABI.cpp @@ -923,12 +923,18 @@ static llvm::Constant *pointerAuthResignConstant( if (!CPA) return nullptr; - assert(CPA->getKey()->getZExtValue() == CurAuthInfo.getKey()); - assert(CPA->getDiscriminator()->getZExtValue() == - CurAuthInfo.getIntDiscriminator()); + // FIXME Refactor and get rid of these assertions. +#ifndef NDEBUG + auto *Key = cast(CPA->getSchema()[0]); + auto *IntDiscriminator = cast(CPA->getSchema()[1]); + auto *AddrDiscriminator = cast(CPA->getSchema()[2]); + assert(CPA->getSchema().size() == 3); + assert(Key->getZExtValue() == CurAuthInfo.getKey()); + assert(IntDiscriminator->getZExtValue() == CurAuthInfo.getIntDiscriminator()); assert(!CurAuthInfo.getAddrDiscriminator() && !NewAuthInfo.getAddrDiscriminator() && - CPA->getAddrDiscriminator()->isZeroValue()); + AddrDiscriminator->isZeroValue()); +#endif return CGM.getConstantSignedPointer(CPA->getPointer(), NewAuthInfo); } diff --git a/llvm/include/llvm/IR/Constants.h b/llvm/include/llvm/IR/Constants.h index 00c59dd181690..c7e806f0aa3fb 100644 --- a/llvm/include/llvm/IR/Constants.h +++ b/llvm/include/llvm/IR/Constants.h @@ -1059,34 +1059,6 @@ class ConstantPtrAuth final : public Constant { return ArrayRef(op_begin() + 2, op_end()); } - /// The Key ID, an i32 constant. - ConstantInt *getKey() const { - // FIXME remove this - return cast(getSchema()[0]); - } - - /// The integer discriminator, an i64 constant, or 0. - ConstantInt *getDiscriminator() const { - // FIXME remove this - return cast(getSchema()[1]); - } - - /// The address discriminator if any, or the null constant. - /// If present, this must be a value equivalent to the storage location of - /// the only global-initializer user of the ptrauth signed pointer. - // FIXME Remove - Constant *getAddrDiscriminator() const { - // FIXME remove this - return cast(getSchema()[2]); - } - - /// Whether there is any non-null address discriminator. - // FIXME Remove - bool hasAddressDiscriminator() const { - // FIXME remove this - return !getAddrDiscriminator()->isNullValue(); - } - Constant *getDeactivationSymbol() const { return cast(Op<1>().get()); } @@ -1098,13 +1070,6 @@ class ConstantPtrAuth final : public Constant { /// expressions referencing these special arrays. enum { AddrDiscriminator_CtorsDtors = 1 }; - /// Whether the address uses a special address discriminator. - /// These discriminators can't be used in real pointer-auth values; they - /// can only be used in "prototype" values that indicate how some real - /// schema is supposed to be produced. - // FIXME Rethink? - LLVM_ABI bool hasSpecialAddressDiscriminator(uint64_t Value) const; - /// Check whether an authentication operation with key \p Key and (possibly /// blended) discriminator \p Discriminator is known to be compatible with /// this ptrauth signed pointer. diff --git a/llvm/include/llvm/SandboxIR/Constant.h b/llvm/include/llvm/SandboxIR/Constant.h index a677cd68512d4..a4a577f21e2a3 100644 --- a/llvm/include/llvm/SandboxIR/Constant.h +++ b/llvm/include/llvm/SandboxIR/Constant.h @@ -1362,49 +1362,17 @@ class ConstantPtrAuth final : public Constant { public: /// Return a pointer signed with the specified parameters. - LLVM_ABI static ConstantPtrAuth *get(Constant *Ptr, ConstantArray *Schema, - Constant *DeactivationSymbol); LLVM_ABI static ConstantPtrAuth *get(Constant *Ptr, ArrayRef Schema, Constant *DeactivationSymbol); - // ConstantArray *getSchema() const; + const_op_range getSchema() const; /// The pointer that is signed in this ptrauth signed pointer. LLVM_ABI Constant *getPointer() const; - /// The Key ID, an i32 constant. - // FIXME Remove - LLVM_ABI ConstantInt *getKey() const; - - /// The integer discriminator, an i64 constant, or 0. - // FIXME Remove - LLVM_ABI ConstantInt *getDiscriminator() const; - - /// The address discriminator if any, or the null constant. - /// If present, this must be a value equivalent to the storage location of - /// the only global-initializer user of the ptrauth signed pointer. - // FIXME Remove - LLVM_ABI Constant *getAddrDiscriminator() const; - Constant *getDeactivationSymbol() const; - /// Whether there is any non-null address discriminator. - // FIXME Remove - bool hasAddressDiscriminator() const { - return cast(Val)->hasAddressDiscriminator(); - } - - /// Whether the address uses a special address discriminator. - /// These discriminators can't be used in real pointer-auth values; they - /// can only be used in "prototype" values that indicate how some real - /// schema is supposed to be produced. - // FIXME Rethink? - bool hasSpecialAddressDiscriminator(uint64_t Value) const { - return cast(Val)->hasSpecialAddressDiscriminator( - Value); - } - /// Check whether an authentication operation with key \p Key and (possibly /// blended) discriminator \p Discriminator is known to be compatible with /// this ptrauth signed pointer. diff --git a/llvm/lib/IR/Constants.cpp b/llvm/lib/IR/Constants.cpp index 82681425988b9..9e650f1f42e8b 100644 --- a/llvm/lib/IR/Constants.cpp +++ b/llvm/lib/IR/Constants.cpp @@ -2150,14 +2150,6 @@ Value *ConstantPtrAuth::handleOperandChangeImpl(Value *From, Value *ToV) { Values, this, From, To, NumUpdated, OperandNo); } -bool ConstantPtrAuth::hasSpecialAddressDiscriminator(uint64_t Value) const { - const auto *IntVal = dyn_cast(getAddrDiscriminator()); - if (!IntVal) - return false; - - return IntVal->getValue() == Value; -} - template static bool isConstantPtrAuthCompatibleWithSchema(const ConstantPtrAuth &CPA, ArrayRef OtherSchema, diff --git a/llvm/lib/IR/Core.cpp b/llvm/lib/IR/Core.cpp index f32bd2ccd2951..5d3f28f589444 100644 --- a/llvm/lib/IR/Core.cpp +++ b/llvm/lib/IR/Core.cpp @@ -930,15 +930,21 @@ LLVMGetConstantPtrAuthSchemaOperand(LLVMValueRef PtrAuth, unsigned Idx) { } LLVMValueRef LLVMGetConstantPtrAuthKey(LLVMValueRef PtrAuth) { - return wrap(unwrap(PtrAuth)->getKey()); + assert(unwrap(PtrAuth)->getSchema().size() == 3 && + "Expected AArch64-style schema"); + return wrap(unwrap(PtrAuth)->getSchema()[0]); } LLVMValueRef LLVMGetConstantPtrAuthDiscriminator(LLVMValueRef PtrAuth) { - return wrap(unwrap(PtrAuth)->getDiscriminator()); + assert(unwrap(PtrAuth)->getSchema().size() == 3 && + "Expected AArch64-style schema"); + return wrap(unwrap(PtrAuth)->getSchema()[1]); } LLVMValueRef LLVMGetConstantPtrAuthAddrDiscriminator(LLVMValueRef PtrAuth) { - return wrap(unwrap(PtrAuth)->getAddrDiscriminator()); + assert(unwrap(PtrAuth)->getSchema().size() == 3 && + "Expected AArch64-style schema"); + return wrap(unwrap(PtrAuth)->getSchema()[2]); } LLVM_C_ABI LLVMValueRef diff --git a/llvm/lib/SandboxIR/Constant.cpp b/llvm/lib/SandboxIR/Constant.cpp index 52e8b657ba9a0..589116843ab90 100644 --- a/llvm/lib/SandboxIR/Constant.cpp +++ b/llvm/lib/SandboxIR/Constant.cpp @@ -411,14 +411,6 @@ PointerType *NoCFIValue::getType() const { return cast(Ctx.getType(cast(Val)->getType())); } -ConstantPtrAuth *ConstantPtrAuth::get(Constant *Ptr, ConstantArray *Schema, - Constant *DeactivationSymbol) { - auto *LLVMC = llvm::ConstantPtrAuth::get( - cast(Ptr->Val), cast(Schema->Val), - cast(DeactivationSymbol->Val)); - return cast(Ptr->getContext().getOrCreateConstant(LLVMC)); -} - ConstantPtrAuth *ConstantPtrAuth::get(Constant *Ptr, ArrayRef Schema, Constant *DeactivationSymbol) { @@ -436,24 +428,8 @@ Constant *ConstantPtrAuth::getPointer() const { cast(Val)->getPointer()); } -// ConstantArray *ConstantPtrAuth::getSchema() const { - // return cast( - // Ctx.getOrCreateConstant(cast(Val)->getSchema())); -// } - -ConstantInt *ConstantPtrAuth::getKey() const { - return cast( - Ctx.getOrCreateConstant(cast(Val)->getKey())); -} - -ConstantInt *ConstantPtrAuth::getDiscriminator() const { - return cast(Ctx.getOrCreateConstant( - cast(Val)->getDiscriminator())); -} - -Constant *ConstantPtrAuth::getAddrDiscriminator() const { - return Ctx.getOrCreateConstant( - cast(Val)->getAddrDiscriminator()); +User::const_op_range ConstantPtrAuth::getSchema() const { + return llvm::make_range(op_begin() + 2, op_end()); } Constant *ConstantPtrAuth::getDeactivationSymbol() const { diff --git a/llvm/lib/Target/AArch64/AArch64AsmPrinter.cpp b/llvm/lib/Target/AArch64/AArch64AsmPrinter.cpp index c88ff125b26c1..d1e50d2d8135c 100644 --- a/llvm/lib/Target/AArch64/AArch64AsmPrinter.cpp +++ b/llvm/lib/Target/AArch64/AArch64AsmPrinter.cpp @@ -1411,12 +1411,27 @@ void AArch64AsmPrinter::emitFunctionEntryLabel() { } } +static bool hasAddressDiscriminator(const ConstantPtrAuth &CPA) { + if (CPA.getSchema().size() != 3) + return false; + return !cast(CPA.getSchema()[2])->isNullValue(); +} + +static bool hasSpecialAddressDiscriminator(const ConstantPtrAuth &CPA, + uint64_t Value) { + if (CPA.getSchema().size() != 3) + return false; + + auto *IntVal = dyn_cast(CPA.getSchema()[2]); + return IntVal && IntVal->getZExtValue() == Value; +} + void AArch64AsmPrinter::emitXXStructor(const DataLayout &DL, const Constant *CV) { if (const auto *CPA = dyn_cast(CV)) - if (CPA->hasAddressDiscriminator() && - !CPA->hasSpecialAddressDiscriminator( - ConstantPtrAuth::AddrDiscriminator_CtorsDtors)) + if (hasAddressDiscriminator(*CPA) && + !hasSpecialAddressDiscriminator( + *CPA, ConstantPtrAuth::AddrDiscriminator_CtorsDtors)) report_fatal_error( "unexpected address discrimination value for ctors/dtors entry, only " "'i64 1' is allowed"); @@ -2605,7 +2620,7 @@ AArch64AsmPrinter::lowerConstantPtrAuth(const ConstantPtrAuth &CPA) { // Check if we need to represent this with an IRELATIVE and emit it if so. if (auto *IFuncSym = emitPAuthRelocationAsIRelative( - Sym, Disc, AArch64PACKey::ID(KeyID), CPA.hasAddressDiscriminator(), + Sym, Disc, AArch64PACKey::ID(KeyID), hasAddressDiscriminator(CPA), BaseGVB && BaseGVB->isDSOLocal(), DSExpr)) return IFuncSym; @@ -2615,7 +2630,7 @@ AArch64AsmPrinter::lowerConstantPtrAuth(const ConstantPtrAuth &CPA) { // Finally build the complete @AUTH expr. return AArch64AuthMCExpr::create(Sym, Disc, AArch64PACKey::ID(KeyID), - CPA.hasAddressDiscriminator(), Ctx); + hasAddressDiscriminator(CPA), Ctx); } void AArch64AsmPrinter::LowerLOADauthptrstatic(const MachineInstr &MI) { diff --git a/llvm/unittests/SandboxIR/SandboxIRTest.cpp b/llvm/unittests/SandboxIR/SandboxIRTest.cpp index 8d4b24a909538..b5b5d6efa0a3f 100644 --- a/llvm/unittests/SandboxIR/SandboxIRTest.cpp +++ b/llvm/unittests/SandboxIR/SandboxIRTest.cpp @@ -1371,9 +1371,6 @@ define ptr @foo() { } )IR"); Function &LLVMF = *M->getFunction("foo"); - auto *LLVMBB = &*LLVMF.begin(); - auto *LLVMRet = cast(&*LLVMBB->begin()); - auto *LLVMPtrAuth = cast(LLVMRet->getReturnValue()); sandboxir::Context Ctx(C); auto &F = *Ctx.createFunction(&LLVMF); @@ -1383,21 +1380,21 @@ define ptr @foo() { // Check classof(), creation. auto *PtrAuth = cast(Ret->getReturnValue()); // Check get(), getKey(), getDiscriminator(), getAddrDiscriminator(). - auto *NewPtrAuth = sandboxir::ConstantPtrAuth::get( - &F, {PtrAuth->getKey(), PtrAuth->getDiscriminator(), - PtrAuth->getAddrDiscriminator()}, PtrAuth->getDeactivationSymbol()); - EXPECT_EQ(NewPtrAuth, PtrAuth); - // Check hasAddressDiscriminator(). - EXPECT_EQ(PtrAuth->hasAddressDiscriminator(), - LLVMPtrAuth->hasAddressDiscriminator()); - // Check hasSpecialAddressDiscriminator(). - EXPECT_EQ(PtrAuth->hasSpecialAddressDiscriminator(0u), - LLVMPtrAuth->hasSpecialAddressDiscriminator(0u)); + { + SmallVector NewSchema; + for (const sandboxir::Use U : PtrAuth->getSchema()) + NewSchema.push_back(cast(U.get())); + auto *NewPtrAuth = sandboxir::ConstantPtrAuth::get( + &F, NewSchema, PtrAuth->getDeactivationSymbol()); + EXPECT_EQ(NewPtrAuth, PtrAuth); + } // Check isKnownCompatibleWith(). const DataLayout &DL = M->getDataLayout(); - EXPECT_TRUE(PtrAuth->isKnownCompatibleWith( - {PtrAuth->getKey(), PtrAuth->getDiscriminator(), - PtrAuth->getAddrDiscriminator()}, DL)); + { + SmallVector Schema; + llvm::append_range(Schema, PtrAuth->getSchema()); + EXPECT_TRUE(PtrAuth->isKnownCompatibleWith(Schema, DL)); + } // Check getWithSameSchema(). EXPECT_EQ(PtrAuth->getWithSameSchema(&F), PtrAuth); } From d08eaef46e4afa694e089c16ec7eb6b24982a786 Mon Sep 17 00:00:00 2001 From: Anatoly Trosinenko Date: Tue, 16 Dec 2025 21:02:27 +0300 Subject: [PATCH 38/40] More cleanups --- llvm/include/llvm/SandboxIR/Constant.h | 5 +++-- llvm/include/llvm/Target/TargetSelectionDAG.td | 4 ++-- llvm/lib/Bitcode/CMakeLists.txt | 1 - llvm/lib/Bitcode/Reader/BitcodeReader.cpp | 2 +- llvm/lib/Bitstream/CMakeLists.txt | 1 - .../CodeGen/SelectionDAG/SelectionDAGBuilder.cpp | 4 ++-- llvm/lib/IR/AutoUpgrade.cpp | 3 --- llvm/lib/IR/Constants.cpp | 14 ++------------ llvm/lib/Target/AArch64/AArch64AsmPrinter.cpp | 1 + llvm/lib/Target/AArch64/AArch64ISelLowering.cpp | 2 +- .../lib/Target/AArch64/AArch64SelectionDAGInfo.cpp | 8 ++++---- llvm/lib/Target/AArch64/AArch64SelectionDAGInfo.h | 2 +- .../AArch64/GISel/AArch64GlobalISelUtils.cpp | 10 +++++----- .../Target/AArch64/GISel/AArch64GlobalISelUtils.h | 2 +- .../Transforms/InstCombine/InstCombineCalls.cpp | 4 ++-- .../RISCV/rv32zknd-intrinsic-autoupgrade.ll | 14 -------------- 16 files changed, 25 insertions(+), 52 deletions(-) diff --git a/llvm/include/llvm/SandboxIR/Constant.h b/llvm/include/llvm/SandboxIR/Constant.h index a4a577f21e2a3..b37a355768e84 100644 --- a/llvm/include/llvm/SandboxIR/Constant.h +++ b/llvm/include/llvm/SandboxIR/Constant.h @@ -1366,11 +1366,12 @@ class ConstantPtrAuth final : public Constant { ArrayRef Schema, Constant *DeactivationSymbol); - const_op_range getSchema() const; - /// The pointer that is signed in this ptrauth signed pointer. LLVM_ABI Constant *getPointer() const; + /// The signing schema (the particular semantic is target-specific). + const_op_range getSchema() const; + Constant *getDeactivationSymbol() const; /// Check whether an authentication operation with key \p Key and (possibly diff --git a/llvm/include/llvm/Target/TargetSelectionDAG.td b/llvm/include/llvm/Target/TargetSelectionDAG.td index 8f9e0e0433f83..fbc1bc9439227 100644 --- a/llvm/include/llvm/Target/TargetSelectionDAG.td +++ b/llvm/include/llvm/Target/TargetSelectionDAG.td @@ -913,7 +913,7 @@ def convergencectrl_glue : SDNode<"ISD::CONVERGENCECTRL_GLUE", // Pointer Authentication operations. -def SDTPtrAuthSchema : SDTypeProfile<1, -1, [ +def SDTPtrAuthSchemaDef : SDTypeProfile<1, -1, [ SDTCisVT<0, untyped> ]>; def SDTPtrAuthOneSchema : SDTypeProfile<1, 2, [ // auth, sign, strip @@ -923,7 +923,7 @@ def SDTPtrAuthTwoSchemas : SDTypeProfile<1, 3, [ // resign SDTCisVT<0, i64>, SDTCisVT<1, i64>, SDTCisVT<2, untyped>, SDTCisVT<3, untyped> ]>; -def ptrauth_schema : SDNode<"ISD::PtrAuthSchema", SDTPtrAuthSchema, []>; +def ptrauth_schema : SDNode<"ISD::PtrAuthSchema", SDTPtrAuthSchemaDef, []>; def ptrauth_auth : SDNode<"ISD::PtrAuthAuth", SDTPtrAuthOneSchema, []>; def ptrauth_sign : SDNode<"ISD::PtrAuthSign", SDTPtrAuthOneSchema, []>; def ptrauth_strip : SDNode<"ISD::PtrAuthStrip", SDTPtrAuthOneSchema, []>; diff --git a/llvm/lib/Bitcode/CMakeLists.txt b/llvm/lib/Bitcode/CMakeLists.txt index 3d07fea511f61..ff7e290cad1bb 100644 --- a/llvm/lib/Bitcode/CMakeLists.txt +++ b/llvm/lib/Bitcode/CMakeLists.txt @@ -1,3 +1,2 @@ -add_compile_options(-O0) add_subdirectory(Reader) add_subdirectory(Writer) diff --git a/llvm/lib/Bitcode/Reader/BitcodeReader.cpp b/llvm/lib/Bitcode/Reader/BitcodeReader.cpp index e1797f057c7e1..961f450c8ba16 100644 --- a/llvm/lib/Bitcode/Reader/BitcodeReader.cpp +++ b/llvm/lib/Bitcode/Reader/BitcodeReader.cpp @@ -3861,7 +3861,7 @@ Error BitcodeReader::parseConstants() { return error("Invalid ptrauth record"); // Ptr, DeactivationSymbol, SchemaArg0 [, SchemaArg1, ...] - SmallVector Operands; + SmallVector Operands; llvm::append_range(Operands, Record); V = BitcodeConstant::create( diff --git a/llvm/lib/Bitstream/CMakeLists.txt b/llvm/lib/Bitstream/CMakeLists.txt index 1fe568f8340c9..49def158f6904 100644 --- a/llvm/lib/Bitstream/CMakeLists.txt +++ b/llvm/lib/Bitstream/CMakeLists.txt @@ -1,3 +1,2 @@ -add_compile_options(-O0) add_subdirectory(Reader) # The writer is header-only. diff --git a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp index 24d14d8a8e72f..00b1d4c219f4b 100644 --- a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp +++ b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp @@ -1875,11 +1875,11 @@ SDValue SelectionDAGBuilder::getValueImpl(const Value *V) { for (const Use &Operand : CPA->getSchema()) Ops.push_back(getValue(Operand)); - SDValue Bundle = DAG.getNode(ISD::PtrAuthSchema, getCurSDLoc(), + SDValue Schema = DAG.getNode(ISD::PtrAuthSchema, getCurSDLoc(), MVT::Other, Ops); return DAG.getNode(ISD::PtrAuthGlobalAddress, getCurSDLoc(), VT, - getValue(CPA->getPointer()), Bundle); + getValue(CPA->getPointer()), Schema); } if (isa(C)) diff --git a/llvm/lib/IR/AutoUpgrade.cpp b/llvm/lib/IR/AutoUpgrade.cpp index d9be1920ba695..b3f6135a85fe2 100644 --- a/llvm/lib/IR/AutoUpgrade.cpp +++ b/llvm/lib/IR/AutoUpgrade.cpp @@ -1626,9 +1626,6 @@ static bool upgradeIntrinsicFunction1(Function *F, Function *&NewFn, case 'r': { if (Name.consume_front("riscv.")) { Intrinsic::ID ID; - // FIXME: Matching on the precise string instead of a substring seems to - // be incompatible with auto-declaration of intrinsics, see - // rv32zknd-intrinsic-autoupgrade.ll for example. ID = StringSwitch(Name) .Case("aes32dsi", Intrinsic::riscv_aes32dsi) .Case("aes32dsmi", Intrinsic::riscv_aes32dsmi) diff --git a/llvm/lib/IR/Constants.cpp b/llvm/lib/IR/Constants.cpp index 9e650f1f42e8b..01abec9377adc 100644 --- a/llvm/lib/IR/Constants.cpp +++ b/llvm/lib/IR/Constants.cpp @@ -2080,16 +2080,6 @@ Value *NoCFIValue::handleOperandChangeImpl(Value *From, Value *To) { //---- ConstantPtrAuth::get() implementations. // -#if 0 -ConstantPtrAuth *ConstantPtrAuth::get(Constant *Ptr, Constant *Schema, - Constant *DeactivationSymbol) { - Constant *ArgVec[] = {Ptr, Schema, DeactivationSymbol}; - ConstantPtrAuthKeyType MapKey(ArgVec); - LLVMContextImpl *pImpl = Ptr->getContext().pImpl; - return pImpl->ConstantPtrAuths.getOrCreate(Ptr->getType(), MapKey); -} -#endif - ConstantPtrAuth *ConstantPtrAuth::get(Constant *Ptr, ArrayRef SchemaArgs, Constant *DeactivationSymbol) { @@ -2100,8 +2090,8 @@ ConstantPtrAuth *ConstantPtrAuth::get(Constant *Ptr, ConstantPtrAuth *ConstantPtrAuth::getWithSameSchema(Constant *Pointer) const { SmallVector Schema; - for (Value *V :getSchema()) - Schema.push_back(cast(V)); + for (const Use &U : getSchema()) + Schema.push_back(cast(U.get())); return get(Pointer, Schema, getDeactivationSymbol()); } diff --git a/llvm/lib/Target/AArch64/AArch64AsmPrinter.cpp b/llvm/lib/Target/AArch64/AArch64AsmPrinter.cpp index d1e50d2d8135c..387341432fbea 100644 --- a/llvm/lib/Target/AArch64/AArch64AsmPrinter.cpp +++ b/llvm/lib/Target/AArch64/AArch64AsmPrinter.cpp @@ -2329,6 +2329,7 @@ void AArch64AsmPrinter::emitPtrauthBranch(const MachineInstr *MI) { bool IsZeroDisc = DiscReg == AArch64::XZR; if (Key == AArch64PACKey::DA || Key == AArch64PACKey::DB) { + assert(AArch64::X16 != AddrDisc); emitMovXReg(AArch64::X16, BrTarget); // Have to emit separate auth and branch instructions for D-key. MCInst AUTInst; diff --git a/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp b/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp index c4947781dc44a..fd5ac6ea6107a 100644 --- a/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp +++ b/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp @@ -29948,7 +29948,7 @@ AArch64TargetLowering::validateSinglePtrAuthSchema(ArrayRef Schema, // The first operand is always the key ID. auto *Key = dyn_cast(Schema[0]); - if (!Key || Key->getZExtValue() > AArch64PACKey::LAST) + if (!Key || Key->getZExtValue() > (unsigned long)AArch64PACKey::LAST) return ("key must be constant in range [0, " + Twine((int)AArch64PACKey::LAST) + "]").str(); diff --git a/llvm/lib/Target/AArch64/AArch64SelectionDAGInfo.cpp b/llvm/lib/Target/AArch64/AArch64SelectionDAGInfo.cpp index e16761c69beef..9fb53d0689a21 100644 --- a/llvm/lib/Target/AArch64/AArch64SelectionDAGInfo.cpp +++ b/llvm/lib/Target/AArch64/AArch64SelectionDAGInfo.cpp @@ -365,10 +365,10 @@ AArch64SelectionDAGInfo::extractPtrauthBlendDiscriminators( std::tuple AArch64SelectionDAGInfo::extractPtrauthBlendDiscriminators( - SDValue Bundle, SelectionDAG *DAG) const { - assert(Bundle->getOpcode() == ISD::PtrAuthSchema); - SDLoc DL(Bundle); - SmallVector Operands(Bundle->ops()); + SDValue Schema, SelectionDAG *DAG) const { + assert(Schema->getOpcode() == ISD::PtrAuthSchema); + SDLoc DL(Schema); + SmallVector Operands(Schema->ops()); return extractPtrauthBlendDiscriminators(Operands, DL, DAG); } diff --git a/llvm/lib/Target/AArch64/AArch64SelectionDAGInfo.h b/llvm/lib/Target/AArch64/AArch64SelectionDAGInfo.h index 42287350cd793..8c3621c62bf61 100644 --- a/llvm/lib/Target/AArch64/AArch64SelectionDAGInfo.h +++ b/llvm/lib/Target/AArch64/AArch64SelectionDAGInfo.h @@ -68,7 +68,7 @@ class AArch64SelectionDAGInfo : public SelectionDAGGenTargetInfo { SelectionDAG *DAG) const; std::tuple - extractPtrauthBlendDiscriminators(SDValue Bundle, SelectionDAG *DAG) const; + extractPtrauthBlendDiscriminators(SDValue Schema, SelectionDAG *DAG) const; }; } // namespace llvm diff --git a/llvm/lib/Target/AArch64/GISel/AArch64GlobalISelUtils.cpp b/llvm/lib/Target/AArch64/GISel/AArch64GlobalISelUtils.cpp index 99ae96dab316e..b3a2cab78303c 100644 --- a/llvm/lib/Target/AArch64/GISel/AArch64GlobalISelUtils.cpp +++ b/llvm/lib/Target/AArch64/GISel/AArch64GlobalISelUtils.cpp @@ -114,13 +114,13 @@ AArch64GISelUtils::extractPtrauthBlendDiscriminators( } std::tuple -AArch64GISelUtils::extractPtrauthBlendDiscriminators(Register BundleToken, +AArch64GISelUtils::extractPtrauthBlendDiscriminators(Register SchemaToken, MachineRegisterInfo &MRI) { - assert(MRI.getType(BundleToken).isToken()); - const MachineInstr *Bundle = MRI.getVRegDef(BundleToken); - assert(Bundle->getOpcode() == TargetOpcode::G_PTRAUTH_SCHEMA); + assert(MRI.getType(SchemaToken).isToken()); + const MachineInstr *Schema = MRI.getVRegDef(SchemaToken); + assert(Schema->getOpcode() == TargetOpcode::G_PTRAUTH_SCHEMA); SmallVector Ops; - for (auto &Op : Bundle->uses()) + for (auto &Op : Schema->uses()) Ops.push_back(Op.getReg()); return extractPtrauthBlendDiscriminators(Ops, MRI); } diff --git a/llvm/lib/Target/AArch64/GISel/AArch64GlobalISelUtils.h b/llvm/lib/Target/AArch64/GISel/AArch64GlobalISelUtils.h index f77dbccf5b309..ae3fe66dc5f20 100644 --- a/llvm/lib/Target/AArch64/GISel/AArch64GlobalISelUtils.h +++ b/llvm/lib/Target/AArch64/GISel/AArch64GlobalISelUtils.h @@ -60,7 +60,7 @@ std::tuple extractPtrauthBlendDiscriminators(SmallVector Operands, MachineRegisterInfo &MRI); std::tuple -extractPtrauthBlendDiscriminators(Register BundleToken, +extractPtrauthBlendDiscriminators(Register SchemaToken, MachineRegisterInfo &MRI); /// Find the AArch64 condition codes necessary to represent \p P for a scalar diff --git a/llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp b/llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp index b016ad5ebc9eb..5c7b9f4c0a8b2 100644 --- a/llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp +++ b/llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp @@ -3122,8 +3122,8 @@ Instruction *InstCombinerImpl::visitCallInst(CallInst &CI) { if (llvm::all_of(ThisSignSchema.Inputs, IsConstant)) { auto *Null = ConstantPointerNull::get(Builder.getPtrTy()); SmallVector Ops; - for (Value *V : ThisSignSchema.Inputs) - Ops.push_back(cast(V)); + for (const Use &U : ThisSignSchema.Inputs) + Ops.push_back(cast(U.get())); auto *NewCPA = ConstantPtrAuth::get(CPA->getPointer(), Ops, /*DeactivationSymbol=*/Null); replaceInstUsesWith( diff --git a/llvm/test/CodeGen/RISCV/rv32zknd-intrinsic-autoupgrade.ll b/llvm/test/CodeGen/RISCV/rv32zknd-intrinsic-autoupgrade.ll index e4216319256a3..6e6d18490782c 100644 --- a/llvm/test/CodeGen/RISCV/rv32zknd-intrinsic-autoupgrade.ll +++ b/llvm/test/CodeGen/RISCV/rv32zknd-intrinsic-autoupgrade.ll @@ -2,9 +2,6 @@ ; RUN: llc -mtriple=riscv32 -mattr=+zknd -verify-machineinstrs < %s \ ; RUN: | FileCheck %s -check-prefix=RV32ZKND -; FIXME: Commenting this out makes auto-upgrader fail! -declare i32 @llvm.riscv.aes32dsi(i32, i32, i8); - define i32 @aes32dsi(i32 %a, i32 %b) nounwind { ; RV32ZKND-LABEL: aes32dsi: ; RV32ZKND: # %bb.0: @@ -14,17 +11,6 @@ define i32 @aes32dsi(i32 %a, i32 %b) nounwind { ret i32 %val } -define i32 @aes32dsi_1(i32 %a, i32 %b) nounwind { -; RV32ZKND-LABEL: aes32dsi_1: -; RV32ZKND: # %bb.0: -; RV32ZKND-NEXT: aes32dsi a0, a0, a1, 0 -; RV32ZKND-NEXT: ret - %val = call i32 @llvm.riscv.aes32dsi(i32 %a, i32 %b, i8 0) - ret i32 %val -} - -declare i32 @llvm.riscv.aes32dsmi(i32, i32, i8); - define i32 @aes32dsmi(i32 %a, i32 %b) nounwind { ; RV32ZKND-LABEL: aes32dsmi: ; RV32ZKND: # %bb.0: From da98811dd8fe67e00ae12193d0a19058a24f5dcf Mon Sep 17 00:00:00 2001 From: Anatoly Trosinenko Date: Tue, 16 Dec 2025 22:29:36 +0300 Subject: [PATCH 39/40] Apply clang-format --- clang/lib/CodeGen/CGBuiltin.cpp | 2 +- clang/lib/CodeGen/CGCall.cpp | 7 ++-- clang/lib/CodeGen/CGPointerAuth.cpp | 29 ++++++++------- clang/lib/CodeGen/CGPointerAuthInfo.h | 3 +- clang/lib/CodeGen/CodeGenFunction.cpp | 4 +-- clang/lib/CodeGen/CodeGenModule.h | 10 +++--- libcxxabi/src/cxa_personality.cpp | 35 +++++++------------ llvm/include/llvm/SandboxIR/Constant.h | 9 +++-- llvm/lib/AsmParser/LLParser.cpp | 13 ++++--- llvm/lib/Bitcode/Reader/BitcodeReader.cpp | 19 +++++----- llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp | 3 +- .../CodeGen/GlobalISel/MachineIRBuilder.cpp | 6 ++-- .../SelectionDAG/SelectionDAGBuilder.cpp | 4 +-- llvm/lib/IR/AutoUpgrade.cpp | 19 +++++----- llvm/lib/IR/Constants.cpp | 3 +- llvm/lib/IR/ConstantsContext.h | 10 +++--- llvm/lib/IR/Core.cpp | 5 ++- llvm/lib/SandboxIR/Constant.cpp | 6 ++-- .../Target/AArch64/AArch64ISelLowering.cpp | 21 ++++++----- .../AArch64/GISel/AArch64GlobalISelUtils.cpp | 2 +- .../GISel/AArch64InstructionSelector.cpp | 6 ++-- .../InstCombine/InstCombineCalls.cpp | 4 +-- llvm/lib/Transforms/Utils/ValueMapper.cpp | 5 ++- llvm/tools/llvm-c-test/echo.cpp | 4 +-- 24 files changed, 113 insertions(+), 116 deletions(-) diff --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp index 73a8c28fbefc4..0cf74d2a0e888 100644 --- a/clang/lib/CodeGen/CGBuiltin.cpp +++ b/clang/lib/CodeGen/CGBuiltin.cpp @@ -5649,7 +5649,7 @@ RValue CodeGenFunction::EmitBuiltinExpr(const GlobalDecl GD, unsigned BuiltinID, const CallExpr *MaybeBlend = dyn_cast(DiscrExpr); if (MaybeBlend && MaybeBlend->getBuiltinCallee() == - Builtin::BI__builtin_ptrauth_blend_discriminator) { + Builtin::BI__builtin_ptrauth_blend_discriminator) { // Assign modifiers according to blend arguments. IntDiscr = ConvertToInt64(EmitScalarExpr(MaybeBlend->getArg(1))); AddrDiscr = ConvertToInt64(EmitScalarExpr(MaybeBlend->getArg(0))); diff --git a/clang/lib/CodeGen/CGCall.cpp b/clang/lib/CodeGen/CGCall.cpp index 4dad5e528a0c4..a937e45685f8e 100644 --- a/clang/lib/CodeGen/CGCall.cpp +++ b/clang/lib/CodeGen/CGCall.cpp @@ -5043,13 +5043,12 @@ llvm::CallInst *CodeGenFunction::EmitRuntimeCall(llvm::FunctionCallee callee, } llvm::CallInst *CodeGenFunction::EmitRuntimeCall( - llvm::FunctionCallee callee, ArrayRef args, - ArrayRef extraBundles, const Twine &name) { + llvm::FunctionCallee callee, ArrayRef args, + ArrayRef extraBundles, const Twine &name) { SmallVector allBundles; llvm::append_range(allBundles, getBundlesForFunclet(callee.getCallee())); llvm::append_range(allBundles, extraBundles); - llvm::CallInst *call = Builder.CreateCall( - callee, args, allBundles, name); + llvm::CallInst *call = Builder.CreateCall(callee, args, allBundles, name); call->setCallingConv(getRuntimeCC()); // FIXME Attach "convergencectrl" bundle right away instead of re-creating diff --git a/clang/lib/CodeGen/CGPointerAuth.cpp b/clang/lib/CodeGen/CGPointerAuth.cpp index 79fc0e9aae9f8..30c4352c3db5b 100644 --- a/clang/lib/CodeGen/CGPointerAuth.cpp +++ b/clang/lib/CodeGen/CGPointerAuth.cpp @@ -82,8 +82,8 @@ CGPointerAuthInfo CodeGenModule::getFunctionPointerAuthInfo(QualType T) { unsigned IntDiscriminator = 0; if (T->isFunctionType()) - IntDiscriminator = getPointerAuthOtherDiscriminator(Schema, GlobalDecl(), - T); + IntDiscriminator = + getPointerAuthOtherDiscriminator(Schema, GlobalDecl(), T); return CGPointerAuthInfo(Schema.getKey(), Schema.getAuthenticationMode(), /*IsaPointer=*/false, /*AuthenticatesNull=*/false, @@ -109,10 +109,9 @@ CGPointerAuthInfo CodeGenFunction::EmitPointerAuthInfo( AddrDiscriminator = Builder.CreatePtrToInt(StorageAddress, IntPtrTy); } - return CGPointerAuthInfo(Schema.getKey(), Schema.getAuthenticationMode(), - Schema.isIsaPointer(), - Schema.authenticatesNullValues(), IntDiscriminator, - AddrDiscriminator); + return CGPointerAuthInfo( + Schema.getKey(), Schema.getAuthenticationMode(), Schema.isIsaPointer(), + Schema.authenticatesNullValues(), IntDiscriminator, AddrDiscriminator); } CGPointerAuthInfo @@ -367,8 +366,9 @@ void CodeGenFunction::EmitPointerAuthCopy(PointerAuthQualifier Qual, QualType T, Builder.CreateStore(Value, DestAddress); } -llvm::Constant *CodeGenModule::getConstantSignedPointer( - llvm::Constant *Pointer, CGPointerAuthInfo Info) { +llvm::Constant * +CodeGenModule::getConstantSignedPointer(llvm::Constant *Pointer, + CGPointerAuthInfo Info) { auto *AddrDisc = dyn_cast_or_null(Info.getAddrDiscriminator()); auto *IntDisc = llvm::ConstantInt::get(Int64Ty, Info.getIntDiscriminator()); @@ -386,8 +386,8 @@ CodeGenModule::getConstantSignedPointer(llvm::Constant *Pointer, unsigned Key, AddressDiscriminator = StorageAddress; } else if (StorageAddress) { assert(StorageAddress->getType() == DefaultPtrTy); - AddressDiscriminator = llvm::ConstantExpr::getPtrToInt(StorageAddress, - Int64Ty); + AddressDiscriminator = + llvm::ConstantExpr::getPtrToInt(StorageAddress, Int64Ty); } else { AddressDiscriminator = llvm::ConstantInt::get(Int64Ty, 0); } @@ -607,11 +607,10 @@ CodeGenModule::getVTablePointerAuthInfo(CodeGenFunction *CGF, AddrDiscriminator = CGF->Builder.CreatePtrToInt(StorageAddress, IntPtrTy); } - return CGPointerAuthInfo(Authentication->getKey(), - PointerAuthenticationMode::SignAndAuth, - /* IsIsaPointer */ false, - /* AuthenticatesNullValues */ false, IntDiscriminator, - AddrDiscriminator); + return CGPointerAuthInfo( + Authentication->getKey(), PointerAuthenticationMode::SignAndAuth, + /* IsIsaPointer */ false, + /* AuthenticatesNullValues */ false, IntDiscriminator, AddrDiscriminator); } llvm::Value *CodeGenFunction::authPointerToPointerCast(llvm::Value *ResultPtr, diff --git a/clang/lib/CodeGen/CGPointerAuthInfo.h b/clang/lib/CodeGen/CGPointerAuthInfo.h index 91dc2fb7219d5..9563e398e1e68 100644 --- a/clang/lib/CodeGen/CGPointerAuthInfo.h +++ b/clang/lib/CodeGen/CGPointerAuthInfo.h @@ -29,8 +29,7 @@ class CGPointerAuthInfo { IntDiscriminator(0), AddrDiscriminator(nullptr) {} CGPointerAuthInfo(unsigned Key, PointerAuthenticationMode AuthenticationMode, bool IsIsaPointer, bool AuthenticatesNullValues, - unsigned IntDiscriminator, - llvm::Value *AddrDiscriminator) + unsigned IntDiscriminator, llvm::Value *AddrDiscriminator) : AuthenticationMode(AuthenticationMode), IsIsaPointer(IsIsaPointer), AuthenticatesNullValues(AuthenticatesNullValues), Key(Key), IntDiscriminator(IntDiscriminator), diff --git a/clang/lib/CodeGen/CodeGenFunction.cpp b/clang/lib/CodeGen/CodeGenFunction.cpp index da78bf1a41578..2b1cc06fb7a22 100644 --- a/clang/lib/CodeGen/CodeGenFunction.cpp +++ b/clang/lib/CodeGen/CodeGenFunction.cpp @@ -3358,8 +3358,8 @@ llvm::Value *CodeGenFunction::emitStrip(const CGPointerAuthInfo &PointerAuth, // Convert the pointer to intptr_t before signing it. auto OrigType = Pointer->getType(); llvm::OperandBundleDef OB("ptrauth", ArrayRef({Key})); - Pointer = EmitRuntimeCall( - StripIntrinsic, {Builder.CreatePtrToInt(Pointer, IntPtrTy)}, {OB}); + Pointer = EmitRuntimeCall(StripIntrinsic, + {Builder.CreatePtrToInt(Pointer, IntPtrTy)}, {OB}); return Builder.CreateIntToPtr(Pointer, OrigType); } diff --git a/clang/lib/CodeGen/CodeGenModule.h b/clang/lib/CodeGen/CodeGenModule.h index 5761ac0f52f16..ecaac9f4d3251 100644 --- a/clang/lib/CodeGen/CodeGenModule.h +++ b/clang/lib/CodeGen/CodeGenModule.h @@ -1057,17 +1057,17 @@ class CodeGenModule : public CodeGenTypeCache { GlobalDecl SchemaDecl, QualType SchemaType); - llvm::Constant * - getConstantSignedPointer(llvm::Constant *Pointer, CGPointerAuthInfo Info); + llvm::Constant *getConstantSignedPointer(llvm::Constant *Pointer, + CGPointerAuthInfo Info); llvm::Constant * getConstantSignedPointer(llvm::Constant *Pointer, unsigned Key, llvm::Constant *StorageAddress, llvm::ConstantInt *OtherDiscriminator); - unsigned - getPointerAuthOtherDiscriminator(const PointerAuthSchema &Schema, - GlobalDecl SchemaDecl, QualType SchemaType); + unsigned getPointerAuthOtherDiscriminator(const PointerAuthSchema &Schema, + GlobalDecl SchemaDecl, + QualType SchemaType); uint16_t getPointerAuthDeclDiscriminator(GlobalDecl GD); std::optional diff --git a/libcxxabi/src/cxa_personality.cpp b/libcxxabi/src/cxa_personality.cpp index 9dd180b9707ba..203359aa79228 100644 --- a/libcxxabi/src/cxa_personality.cpp +++ b/libcxxabi/src/cxa_personality.cpp @@ -608,10 +608,8 @@ set_registers(_Unwind_Exception* unwind_exception, _Unwind_Context* context, // express the required relationship with the destination address unw_word_t newIP /* opaque __ptrauth(ptrauth_key_return_address, stackPointer, 0) */ = (unw_word_t)ptrauth_auth_and_resign( - *(void* const*)&results.landingPad, - __ptrauth_scan_results_landingpad_key, - ptrauth_blend_discriminator(&results.landingPad, - __ptrauth_scan_results_landingpad_disc), + *(void* const*)&results.landingPad, __ptrauth_scan_results_landingpad_key, + ptrauth_blend_discriminator(&results.landingPad, __ptrauth_scan_results_landingpad_disc), ptrauth_key_return_address, stackPointer); _Unwind_SetIP(context, newIP); #else @@ -971,16 +969,11 @@ _UA_CLEANUP_PHASE using __cxa_catch_temp_type = decltype(__cxa_exception::catchTemp); static inline void set_landing_pad(scan_results& results, const __cxa_catch_temp_type& source) { -#if __has_feature(ptrauth_calls) - uintptr_t reauthenticatedLandingPad = - (uintptr_t)ptrauth_auth_and_resign( - *reinterpret_cast(&source), - __ptrauth_cxxabi_catch_temp_key, - ptrauth_blend_discriminator(&source, - __ptrauth_cxxabi_catch_temp_disc), - __ptrauth_scan_results_landingpad_key, - ptrauth_blend_discriminator(&results.landingPad, - __ptrauth_scan_results_landingpad_disc)); +# if __has_feature(ptrauth_calls) + uintptr_t reauthenticatedLandingPad = (uintptr_t)ptrauth_auth_and_resign( + *reinterpret_cast(&source), __ptrauth_cxxabi_catch_temp_key, + ptrauth_blend_discriminator(&source, __ptrauth_cxxabi_catch_temp_disc), __ptrauth_scan_results_landingpad_key, + ptrauth_blend_discriminator(&results.landingPad, __ptrauth_scan_results_landingpad_disc)); memmove(reinterpret_cast(&results.landingPad), reinterpret_cast(&reauthenticatedLandingPad), sizeof(reauthenticatedLandingPad)); @@ -991,15 +984,11 @@ static inline void set_landing_pad(scan_results& results, static inline void get_landing_pad(__cxa_catch_temp_type &dest, const scan_results &results) { -#if __has_feature(ptrauth_calls) - uintptr_t reauthenticatedPointer = - (uintptr_t)ptrauth_auth_and_resign( - *reinterpret_cast(&results.landingPad), - __ptrauth_scan_results_landingpad_key, - ptrauth_blend_discriminator(&results.landingPad, - __ptrauth_scan_results_landingpad_disc), - __ptrauth_cxxabi_catch_temp_key, - ptrauth_blend_discriminator(&dest, __ptrauth_cxxabi_catch_temp_disc)); +# if __has_feature(ptrauth_calls) + uintptr_t reauthenticatedPointer = (uintptr_t)ptrauth_auth_and_resign( + *reinterpret_cast(&results.landingPad), __ptrauth_scan_results_landingpad_key, + ptrauth_blend_discriminator(&results.landingPad, __ptrauth_scan_results_landingpad_disc), + __ptrauth_cxxabi_catch_temp_key, ptrauth_blend_discriminator(&dest, __ptrauth_cxxabi_catch_temp_disc)); memmove(reinterpret_cast(&dest), reinterpret_cast(&reauthenticatedPointer), sizeof(reauthenticatedPointer)); diff --git a/llvm/include/llvm/SandboxIR/Constant.h b/llvm/include/llvm/SandboxIR/Constant.h index b37a355768e84..ab0e6d8cb2dbf 100644 --- a/llvm/include/llvm/SandboxIR/Constant.h +++ b/llvm/include/llvm/SandboxIR/Constant.h @@ -1362,9 +1362,8 @@ class ConstantPtrAuth final : public Constant { public: /// Return a pointer signed with the specified parameters. - LLVM_ABI static ConstantPtrAuth *get(Constant *Ptr, - ArrayRef Schema, - Constant *DeactivationSymbol); + LLVM_ABI static ConstantPtrAuth * + get(Constant *Ptr, ArrayRef Schema, Constant *DeactivationSymbol); /// The pointer that is signed in this ptrauth signed pointer. LLVM_ABI Constant *getPointer() const; @@ -1382,8 +1381,8 @@ class ConstantPtrAuth final : public Constant { SmallVector Operands; for (auto *V : BundleOperands) Operands.push_back(V->Val); - return cast(Val)->isKnownCompatibleWith( - Operands, DL); + return cast(Val)->isKnownCompatibleWith(Operands, + DL); } /// Produce a new ptrauth expression signing the given value using diff --git a/llvm/lib/AsmParser/LLParser.cpp b/llvm/lib/AsmParser/LLParser.cpp index 3a1e48e2b2838..294fd75b42138 100644 --- a/llvm/lib/AsmParser/LLParser.cpp +++ b/llvm/lib/AsmParser/LLParser.cpp @@ -3353,8 +3353,8 @@ bool LLParser::parseOptionalOperandBundles( return false; } -static void upgradeOperandBundles( - SmallVectorImpl &BundleList) { +static void +upgradeOperandBundles(SmallVectorImpl &BundleList) { // AutoUpgrader.h exposes an API that accepts std::vector. // Skip meaningless allocations if no bundles were parsed. // FIXME Is it possible to change UpgradeOperandBundles function to accept @@ -3362,7 +3362,8 @@ static void upgradeOperandBundles( if (BundleList.empty()) return; - std::vector BundleVector(BundleList.begin(), BundleList.end()); + std::vector BundleVector(BundleList.begin(), + BundleList.end()); UpgradeOperandBundles(BundleVector); BundleList.assign(BundleVector.begin(), BundleVector.end()); } @@ -4308,11 +4309,13 @@ bool LLParser::parseValID(ValID &ID, PerFunctionState *PFS, Type *ExpectedTy) { return true; if (!Ptr->getType()->isPointerTy()) - return error(ID.Loc, "base pointer of ptrauth constant must be a pointer"); + return error(ID.Loc, + "base pointer of ptrauth constant must be a pointer"); for (Constant *Op : Schema) { if (!Op->getType()->isIntegerTy(64)) - return error(ID.Loc, "schema of ptrauth constant must be a tuple of i64"); + return error(ID.Loc, + "schema of ptrauth constant must be a tuple of i64"); } if (!DeactivationSymbol) diff --git a/llvm/lib/Bitcode/Reader/BitcodeReader.cpp b/llvm/lib/Bitcode/Reader/BitcodeReader.cpp index 961f450c8ba16..41bcfc38d8ede 100644 --- a/llvm/lib/Bitcode/Reader/BitcodeReader.cpp +++ b/llvm/lib/Bitcode/Reader/BitcodeReader.cpp @@ -1629,8 +1629,7 @@ Expected BitcodeReader::materializeValue(unsigned StartValID, } if (!Ptr->getType()->isPointerTy()) - return error( - "ptrauth signed operand must be a pointer"); + return error("ptrauth signed operand must be a pointer"); for (Constant *C : Schema) if (!C->getType()->isIntegerTy(64)) @@ -3840,10 +3839,11 @@ Error BitcodeReader::parseConstants() { if (Record.size() < 4) return error("Invalid ptrauth record"); // Ptr, Key, Disc, AddrDisc - V = BitcodeConstant::create(Alloc, CurTy, - {BitcodeConstant::ConstantPtrAuthOpcode, bitc::CST_CODE_PTRAUTH_OLD}, - {(unsigned)Record[0], (unsigned)Record[1], - (unsigned)Record[2], (unsigned)Record[3]}); + V = BitcodeConstant::create( + Alloc, CurTy, + {BitcodeConstant::ConstantPtrAuthOpcode, bitc::CST_CODE_PTRAUTH_OLD}, + {(unsigned)Record[0], (unsigned)Record[1], (unsigned)Record[2], + (unsigned)Record[3]}); break; } case bitc::CST_CODE_PTRAUTH_OLD2: { @@ -3851,7 +3851,8 @@ Error BitcodeReader::parseConstants() { return error("Invalid ptrauth record"); // Ptr, Key, Disc, AddrDisc, DeactivationSymbol V = BitcodeConstant::create( - Alloc, CurTy, {BitcodeConstant::ConstantPtrAuthOpcode, bitc::CST_CODE_PTRAUTH_OLD2}, + Alloc, CurTy, + {BitcodeConstant::ConstantPtrAuthOpcode, bitc::CST_CODE_PTRAUTH_OLD2}, {(unsigned)Record[0], (unsigned)Record[1], (unsigned)Record[2], (unsigned)Record[3], (unsigned)Record[4]}); break; @@ -3865,7 +3866,9 @@ Error BitcodeReader::parseConstants() { llvm::append_range(Operands, Record); V = BitcodeConstant::create( - Alloc, CurTy, {BitcodeConstant::ConstantPtrAuthOpcode, bitc::CST_CODE_PTRAUTH3}, Operands); + Alloc, CurTy, + {BitcodeConstant::ConstantPtrAuthOpcode, bitc::CST_CODE_PTRAUTH3}, + Operands); break; } } diff --git a/llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp b/llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp index 97be1f7f74359..4501d72ad9eb3 100644 --- a/llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp +++ b/llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp @@ -3832,7 +3832,8 @@ bool IRTranslator::translate(const Constant &C, Register Reg) { SchemaOps.push_back(getOrCreateVReg(*Operand)); Register SchemaReg = MRI->createGenericVirtualRegister(LLT::token()); - EntryBuilder->buildInstr(TargetOpcode::G_PTRAUTH_SCHEMA, {SchemaReg}, SchemaOps); + EntryBuilder->buildInstr(TargetOpcode::G_PTRAUTH_SCHEMA, {SchemaReg}, + SchemaOps); EntryBuilder->buildConstantPtrAuth(Reg, Addr, SchemaReg); } else if (auto CAZ = dyn_cast(&C)) { diff --git a/llvm/lib/CodeGen/GlobalISel/MachineIRBuilder.cpp b/llvm/lib/CodeGen/GlobalISel/MachineIRBuilder.cpp index 047e361bd520c..d9d0a983215ad 100644 --- a/llvm/lib/CodeGen/GlobalISel/MachineIRBuilder.cpp +++ b/llvm/lib/CodeGen/GlobalISel/MachineIRBuilder.cpp @@ -419,9 +419,9 @@ MachineInstrBuilder MachineIRBuilder::buildFConstant(const DstOp &Res, return buildFConstant(Res, *CFP); } -MachineInstrBuilder -MachineIRBuilder::buildConstantPtrAuth(const DstOp &Res, - Register Ptr, Register Schema) { +MachineInstrBuilder MachineIRBuilder::buildConstantPtrAuth(const DstOp &Res, + Register Ptr, + Register Schema) { auto MIB = buildInstr(TargetOpcode::G_PTRAUTH_GLOBAL_VALUE); Res.addDefToMIB(*getMRI(), MIB); MIB.addUse(Ptr); diff --git a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp index 00b1d4c219f4b..c10db495c2070 100644 --- a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp +++ b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp @@ -1875,8 +1875,8 @@ SDValue SelectionDAGBuilder::getValueImpl(const Value *V) { for (const Use &Operand : CPA->getSchema()) Ops.push_back(getValue(Operand)); - SDValue Schema = DAG.getNode(ISD::PtrAuthSchema, getCurSDLoc(), - MVT::Other, Ops); + SDValue Schema = + DAG.getNode(ISD::PtrAuthSchema, getCurSDLoc(), MVT::Other, Ops); return DAG.getNode(ISD::PtrAuthGlobalAddress, getCurSDLoc(), VT, getValue(CPA->getPointer()), Schema); diff --git a/llvm/lib/IR/AutoUpgrade.cpp b/llvm/lib/IR/AutoUpgrade.cpp index b3f6135a85fe2..5879ccd78c10c 100644 --- a/llvm/lib/IR/AutoUpgrade.cpp +++ b/llvm/lib/IR/AutoUpgrade.cpp @@ -1609,11 +1609,11 @@ static bool upgradeIntrinsicFunction1(Function *F, Function *&NewFn, // auto-declaration is not handled correctly. Intrinsic::ID ID; ID = StringSwitch(Name) - .StartsWith("auth", Intrinsic::ptrauth_auth) - .StartsWith("sign", Intrinsic::ptrauth_sign) - .StartsWith("resign", Intrinsic::ptrauth_resign) - .StartsWith("strip", Intrinsic::ptrauth_strip) - .Default(Intrinsic::not_intrinsic); + .StartsWith("auth", Intrinsic::ptrauth_auth) + .StartsWith("sign", Intrinsic::ptrauth_sign) + .StartsWith("resign", Intrinsic::ptrauth_resign) + .StartsWith("strip", Intrinsic::ptrauth_strip) + .Default(Intrinsic::not_intrinsic); if (ID == Intrinsic::not_intrinsic) break; @@ -4705,12 +4705,13 @@ static void upgradeDbgIntrinsicToDbgRecord(StringRef Name, CallBase *CI) { CI->getParent()->insertDbgRecordBefore(DR, CI->getIterator()); } -static CallBase *setOperandBundles(CallBase *CI, ArrayRef OBs) { +static CallBase *setOperandBundles(CallBase *CI, + ArrayRef OBs) { IRBuilder<> Builder(CI); Value *Callee = CI->getCalledOperand(); SmallVector Args(CI->arg_begin(), CI->arg_end()); - CallBase *NewCI = Builder.CreateCall(CI->getFunctionType(), Callee, - Args, OBs); + CallBase *NewCI = + Builder.CreateCall(CI->getFunctionType(), Callee, Args, OBs); NewCI->takeName(CI); CI->replaceAllUsesWith(NewCI); CI->eraseFromParent(); @@ -4795,7 +4796,7 @@ static CallBase *upgradeToPtrAuthBundles(CallBase *CI) { reportFatalUsageError("Cannot upgrade: expected constant ptrauth key ID"); OBs.emplace_back(createUpgradedPtrAuthBundle(Key, Disc)); - CI->setArgOperand(KeyIndex, Zero32); + CI->setArgOperand(KeyIndex, Zero32); CI->setArgOperand(DiscIndex, Zero64); }; diff --git a/llvm/lib/IR/Constants.cpp b/llvm/lib/IR/Constants.cpp index 01abec9377adc..7345df075e619 100644 --- a/llvm/lib/IR/Constants.cpp +++ b/llvm/lib/IR/Constants.cpp @@ -2140,7 +2140,7 @@ Value *ConstantPtrAuth::handleOperandChangeImpl(Value *From, Value *ToV) { Values, this, From, To, NumUpdated, OperandNo); } -template +template static bool isConstantPtrAuthCompatibleWithSchema(const ConstantPtrAuth &CPA, ArrayRef OtherSchema, const DataLayout &DL) { @@ -2176,7 +2176,6 @@ static bool isConstantPtrAuthCompatibleWithSchema(const ConstantPtrAuth &CPA, return Base1 == Base2 && Off1 == Off2; }; - if (CPA.getSchema().size() != OtherSchema.size()) return false; diff --git a/llvm/lib/IR/ConstantsContext.h b/llvm/lib/IR/ConstantsContext.h index abdf535d0396e..e2da72d5665b4 100644 --- a/llvm/lib/IR/ConstantsContext.h +++ b/llvm/lib/IR/ConstantsContext.h @@ -533,8 +533,7 @@ struct ConstantPtrAuthKeyType { } bool operator==(const ConstantPtrAuth *C) const { - if (Ptr != C->getPointer() || - Schema.size() != C->getSchema().size() || + if (Ptr != C->getPointer() || Schema.size() != C->getSchema().size() || DeactivationSymbol != C->getDeactivationSymbol()) return false; for (auto [A, B] : llvm::zip_equal(Schema, C->getSchema())) @@ -543,14 +542,17 @@ struct ConstantPtrAuthKeyType { return true; } - unsigned getHash() const { return hash_combine(Ptr, hash_combine_range(Schema), DeactivationSymbol); } + unsigned getHash() const { + return hash_combine(Ptr, hash_combine_range(Schema), DeactivationSymbol); + } using TypeClass = ConstantInfo::TypeClass; ConstantPtrAuth *create(TypeClass *Ty) const { unsigned NumVals = Schema.size() + 2; User::IntrusiveOperandsAllocMarker AllocMarker{NumVals}; - return new (AllocMarker) ConstantPtrAuth(Ptr, Schema, DeactivationSymbol, AllocMarker); + return new (AllocMarker) + ConstantPtrAuth(Ptr, Schema, DeactivationSymbol, AllocMarker); } }; diff --git a/llvm/lib/IR/Core.cpp b/llvm/lib/IR/Core.cpp index 5d3f28f589444..55a905ab269dc 100644 --- a/llvm/lib/IR/Core.cpp +++ b/llvm/lib/IR/Core.cpp @@ -1722,9 +1722,8 @@ LLVMValueRef LLVMConstantPtrAuth(LLVMValueRef Ptr, LLVMValueRef *Schema, for (unsigned I = 0; I < SchemaSize; ++I) SchemaUnwrapped.push_back(unwrap(Schema[I])); - return wrap(ConstantPtrAuth::get( - unwrap(Ptr), SchemaUnwrapped, - unwrap(DeactivationSymbol))); + return wrap(ConstantPtrAuth::get(unwrap(Ptr), SchemaUnwrapped, + unwrap(DeactivationSymbol))); } /*-- Opcode mapping */ diff --git a/llvm/lib/SandboxIR/Constant.cpp b/llvm/lib/SandboxIR/Constant.cpp index 589116843ab90..de259bbc5c77b 100644 --- a/llvm/lib/SandboxIR/Constant.cpp +++ b/llvm/lib/SandboxIR/Constant.cpp @@ -417,9 +417,9 @@ ConstantPtrAuth *ConstantPtrAuth::get(Constant *Ptr, SmallVector LLVMSchema; for (Constant *C : Schema) LLVMSchema.push_back(cast(C->Val)); - auto *LLVMC = llvm::ConstantPtrAuth::get( - cast(Ptr->Val), LLVMSchema, - cast(DeactivationSymbol->Val)); + auto *LLVMC = + llvm::ConstantPtrAuth::get(cast(Ptr->Val), LLVMSchema, + cast(DeactivationSymbol->Val)); return cast(Ptr->getContext().getOrCreateConstant(LLVMC)); } diff --git a/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp b/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp index fd5ac6ea6107a..e3d6fd6428b2e 100644 --- a/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp +++ b/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp @@ -10942,9 +10942,11 @@ SDValue AArch64TargetLowering::LowerGlobalTLSAddress(SDValue Op, // Thus, it's only used for ptrauth references to extern_weak to avoid null // checks. -static SDValue LowerPtrAuthGlobalAddressStatically( - SDValue TGA, SDLoc DL, EVT VT, SDValue Key, SDValue Discriminator, - SDValue AddrDiscriminator, SelectionDAG &DAG) { +static SDValue LowerPtrAuthGlobalAddressStatically(SDValue TGA, SDLoc DL, + EVT VT, SDValue Key, + SDValue Discriminator, + SDValue AddrDiscriminator, + SelectionDAG &DAG) { const auto *TGN = cast(TGA.getNode()); assert(TGN->getGlobal()->hasExternalWeakLinkage()); @@ -11024,8 +11026,8 @@ AArch64TargetLowering::LowerPtrAuthGlobalAddress(SDValue Op, 0); // extern_weak ref -> LOADauthptrstatic - return LowerPtrAuthGlobalAddressStatically( - TPtr, DL, VT, Key, Discriminator, AddrDiscriminator, DAG); + return LowerPtrAuthGlobalAddressStatically(TPtr, DL, VT, Key, Discriminator, + AddrDiscriminator, DAG); } // Looks through \param Val to determine the bit that can be used to @@ -29950,7 +29952,8 @@ AArch64TargetLowering::validateSinglePtrAuthSchema(ArrayRef Schema, auto *Key = dyn_cast(Schema[0]); if (!Key || Key->getZExtValue() > (unsigned long)AArch64PACKey::LAST) return ("key must be constant in range [0, " + - Twine((int)AArch64PACKey::LAST) + "]").str(); + Twine((int)AArch64PACKey::LAST) + "]") + .str(); // Done validating single-operand schemas. if (NumOperands == 1) @@ -29973,14 +29976,16 @@ AArch64TargetLowering::validatePtrAuthSchema(const Value &V) const { bool ExpectSingleElement = CB->getIntrinsicID() == Intrinsic::ptrauth_strip; - if (auto Error = validateSinglePtrAuthSchema(OB.Inputs, ExpectSingleElement)) + if (auto Error = + validateSinglePtrAuthSchema(OB.Inputs, ExpectSingleElement)) return (CB->getFunction()->getName() + ": " + *Error).str(); } return std::nullopt; } auto &CPA = cast(V); - return validateSinglePtrAuthSchema(CPA.getSchema(), /*ExpectSingleElement=*/false); + return validateSinglePtrAuthSchema(CPA.getSchema(), + /*ExpectSingleElement=*/false); } MachineInstr * diff --git a/llvm/lib/Target/AArch64/GISel/AArch64GlobalISelUtils.cpp b/llvm/lib/Target/AArch64/GISel/AArch64GlobalISelUtils.cpp index b3a2cab78303c..d1716d866cd16 100644 --- a/llvm/lib/Target/AArch64/GISel/AArch64GlobalISelUtils.cpp +++ b/llvm/lib/Target/AArch64/GISel/AArch64GlobalISelUtils.cpp @@ -110,7 +110,7 @@ AArch64GISelUtils::extractPtrauthBlendDiscriminators( if (AddrDiscVal && AddrDiscVal->isZero()) AddrDisc = AArch64::NoRegister; - return { KeyVal, ConstDiscVal, AddrDisc }; + return {KeyVal, ConstDiscVal, AddrDisc}; } std::tuple diff --git a/llvm/lib/Target/AArch64/GISel/AArch64InstructionSelector.cpp b/llvm/lib/Target/AArch64/GISel/AArch64InstructionSelector.cpp index 612059267d346..329769d80e6a7 100644 --- a/llvm/lib/Target/AArch64/GISel/AArch64InstructionSelector.cpp +++ b/llvm/lib/Target/AArch64/GISel/AArch64InstructionSelector.cpp @@ -6806,8 +6806,7 @@ bool AArch64InstructionSelector::selectPtrAuthGlobalValue( Register Schema = I.getOperand(2).getReg(); int64_t Offset = 0; - auto [Key, Disc, AddrDisc] = - extractPtrauthBlendDiscriminators(Schema, MRI); + auto [Key, Disc, AddrDisc] = extractPtrauthBlendDiscriminators(Schema, MRI); // Choosing between 3 lowering alternatives is target-specific. if (!STI.isTargetELF() && !STI.isTargetMachO()) @@ -6868,7 +6867,8 @@ bool AArch64InstructionSelector::selectPtrAuthGlobalValue( MIB.buildInstr(NeedsGOTLoad ? AArch64::LOADgotPAC : AArch64::MOVaddrPAC) .addGlobalAddress(GV, Offset) .addImm(Key) - .addReg(HasAddrDisc ? AddrDisc : AArch64::XZR) // FIXME Use NoRegister instead? + .addReg(HasAddrDisc ? AddrDisc + : AArch64::XZR) // FIXME Use NoRegister instead? .addImm(Disc) .constrainAllUses(TII, TRI, RBI); MIB.buildCopy(DefReg, Register(AArch64::X16)); diff --git a/llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp b/llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp index 5c7b9f4c0a8b2..5fef78f5f50f8 100644 --- a/llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp +++ b/llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp @@ -3127,8 +3127,8 @@ Instruction *InstCombinerImpl::visitCallInst(CallInst &CI) { auto *NewCPA = ConstantPtrAuth::get(CPA->getPointer(), Ops, /*DeactivationSymbol=*/Null); replaceInstUsesWith( - *II, ConstantExpr::getPointerCast(NewCPA, II->getType())); - return eraseInstFromFunction(*II); + *II, ConstantExpr::getPointerCast(NewCPA, II->getType())); + return eraseInstFromFunction(*II); } } diff --git a/llvm/lib/Transforms/Utils/ValueMapper.cpp b/llvm/lib/Transforms/Utils/ValueMapper.cpp index b6fa5a00b0bae..0233450462ba7 100644 --- a/llvm/lib/Transforms/Utils/ValueMapper.cpp +++ b/llvm/lib/Transforms/Utils/ValueMapper.cpp @@ -526,9 +526,8 @@ Value *Mapper::mapValue(const Value *V) { if (isa(C)) return getVM()[V] = ConstantVector::get(Ops); if (isa(C)) - return getVM()[V] = - ConstantPtrAuth::get(Ops[0], ArrayRef(Ops).drop_front(2), - Ops[1]); + return getVM()[V] = ConstantPtrAuth::get( + Ops[0], ArrayRef(Ops).drop_front(2), Ops[1]); // If this is a no-operand constant, it must be because the type was remapped. if (isa(C)) return getVM()[V] = PoisonValue::get(NewTy); diff --git a/llvm/tools/llvm-c-test/echo.cpp b/llvm/tools/llvm-c-test/echo.cpp index 0218fff6feaee..f7f38a698d658 100644 --- a/llvm/tools/llvm-c-test/echo.cpp +++ b/llvm/tools/llvm-c-test/echo.cpp @@ -407,8 +407,8 @@ static LLVMValueRef clone_constant_impl(LLVMValueRef Cst, LLVMModuleRef M) { Schema.push_back(clone_constant(Op, M)); } - LLVMValueRef DeactivationSymbol = clone_constant( - LLVMGetConstantPtrAuthDeactivationSymbol(Cst), M); + LLVMValueRef DeactivationSymbol = + clone_constant(LLVMGetConstantPtrAuthDeactivationSymbol(Cst), M); return LLVMConstantPtrAuth(Ptr, Schema.data(), Schema.size(), DeactivationSymbol); From 2a8e94ad626bf133a98a6d72d2879744256fe543 Mon Sep 17 00:00:00 2001 From: Anatoly Trosinenko Date: Mon, 15 Dec 2025 13:21:16 +0300 Subject: [PATCH 40/40] [TMP] Fix isOSGlibc to unbreak building the runtime libraries From https://github.com/llvm/llvm-project/pull/171648. --- llvm/include/llvm/TargetParser/Triple.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/llvm/include/llvm/TargetParser/Triple.h b/llvm/include/llvm/TargetParser/Triple.h index 11b76cd183108..2274bbaa73bcb 100644 --- a/llvm/include/llvm/TargetParser/Triple.h +++ b/llvm/include/llvm/TargetParser/Triple.h @@ -769,7 +769,7 @@ class Triple { bool isOSGlibc() const { return (getOS() == Triple::Linux || getOS() == Triple::KFreeBSD || getOS() == Triple::Hurd) && - !isAndroid(); + !isAndroid() && getEnvironment() != Triple::PAuthTest; } /// Tests whether the OS is AIX.