Skip to content

Commit 99251f5

Browse files
authored
Revert "[PAC][AArch64] Lower ptrauth constants in code (#94241)" (#96865)
This reverts #94241. See buildbot failure https://lab.llvm.org/buildbot/#/builders/51/builds/570
1 parent 223a210 commit 99251f5

27 files changed

+37
-1223
lines changed

llvm/docs/GlobalISel/GenericOpcode.rst

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -60,17 +60,6 @@ The address of a global value.
6060
6161
%0(p0) = G_GLOBAL_VALUE @var_local
6262
63-
G_PTRAUTH_GLOBAL_VALUE
64-
^^^^^^^^^^^^^^^^^^^^^^
65-
66-
The signed address of a global value. Operands: address to be signed (pointer),
67-
key (32-bit imm), address for address discrimination (zero if not needed) and
68-
an extra discriminator (64-bit imm).
69-
70-
.. code-block:: none
71-
72-
%0:_(p0) = G_PTRAUTH_GLOBAL_VALUE %1:_(p0), s32, %2:_(p0), s64
73-
7463
G_BLOCK_ADDR
7564
^^^^^^^^^^^^
7665

llvm/include/llvm/CodeGen/GlobalISel/MachineIRBuilder.h

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -886,13 +886,6 @@ class MachineIRBuilder {
886886
MachineInstrBuilder buildFConstant(const DstOp &Res, double Val);
887887
MachineInstrBuilder buildFConstant(const DstOp &Res, const APFloat &Val);
888888

889-
/// Build and insert G_PTRAUTH_GLOBAL_VALUE
890-
///
891-
/// \return a MachineInstrBuilder for the newly created instruction.
892-
MachineInstrBuilder buildConstantPtrAuth(const DstOp &Res,
893-
const ConstantPtrAuth *CPA,
894-
Register Addr, Register AddrDisc);
895-
896889
/// Build and insert \p Res = COPY Op
897890
///
898891
/// Register-to-register COPY sets \p Res to \p Op.

llvm/include/llvm/CodeGen/ISDOpcodes.h

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -83,12 +83,6 @@ enum NodeType {
8383
ExternalSymbol,
8484
BlockAddress,
8585

86-
/// A ptrauth constant.
87-
/// ptr, key, addr-disc, disc
88-
/// Note that the addr-disc can be a non-constant value, to allow representing
89-
/// a constant global address signed using address-diversification, in code.
90-
PtrAuthGlobalAddress,
91-
9286
/// The address of the GOT
9387
GLOBAL_OFFSET_TABLE,
9488

llvm/include/llvm/CodeGen/MachineModuleInfoImpls.h

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -61,20 +61,10 @@ class MachineModuleInfoMachO : public MachineModuleInfoImpl {
6161
/// MachineModuleInfoELF - This is a MachineModuleInfoImpl implementation
6262
/// for ELF targets.
6363
class MachineModuleInfoELF : public MachineModuleInfoImpl {
64-
public:
65-
struct AuthStubInfo {
66-
const MCExpr *AuthPtrRef;
67-
};
68-
69-
private:
7064
/// GVStubs - These stubs are used to materialize global addresses in PIC
7165
/// mode.
7266
DenseMap<MCSymbol *, StubValueTy> GVStubs;
7367

74-
/// AuthPtrStubs - These stubs are used to materialize signed addresses for
75-
/// extern_weak symbols.
76-
DenseMap<MCSymbol *, AuthStubInfo> AuthPtrStubs;
77-
7868
virtual void anchor(); // Out of line virtual method.
7969

8070
public:
@@ -85,19 +75,9 @@ class MachineModuleInfoELF : public MachineModuleInfoImpl {
8575
return GVStubs[Sym];
8676
}
8777

88-
AuthStubInfo &getAuthPtrStubEntry(MCSymbol *Sym) {
89-
assert(Sym && "Key cannot be null");
90-
return AuthPtrStubs[Sym];
91-
}
92-
9378
/// Accessor methods to return the set of stubs in sorted order.
9479

9580
SymbolListTy GetGVStubList() { return getSortedStubs(GVStubs); }
96-
97-
using AuthStubPairTy = std::pair<MCSymbol *, AuthStubInfo>;
98-
typedef std::vector<AuthStubPairTy> AuthStubListTy;
99-
100-
AuthStubListTy getAuthGVStubList();
10181
};
10282

10383
/// MachineModuleInfoCOFF - This is a MachineModuleInfoImpl implementation

llvm/include/llvm/Support/TargetOpcodes.def

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -294,9 +294,6 @@ HANDLE_TARGET_OPCODE(G_FRAME_INDEX)
294294
/// Generic reference to global value.
295295
HANDLE_TARGET_OPCODE(G_GLOBAL_VALUE)
296296

297-
/// Generic ptrauth-signed reference to global value.
298-
HANDLE_TARGET_OPCODE(G_PTRAUTH_GLOBAL_VALUE)
299-
300297
/// Generic instruction to materialize the address of an object in the constant
301298
/// pool.
302299
HANDLE_TARGET_OPCODE(G_CONSTANT_POOL)

llvm/include/llvm/Target/GenericOpcodes.td

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -110,12 +110,6 @@ def G_GLOBAL_VALUE : GenericInstruction {
110110
let hasSideEffects = false;
111111
}
112112

113-
def G_PTRAUTH_GLOBAL_VALUE : GenericInstruction {
114-
let OutOperandList = (outs type0:$dst);
115-
let InOperandList = (ins unknown:$addr, i32imm:$key, type1:$addrdisc, i64imm:$disc);
116-
let hasSideEffects = 0;
117-
}
118-
119113
def G_CONSTANT_POOL : GenericInstruction {
120114
let OutOperandList = (outs type0:$dst);
121115
let InOperandList = (ins unknown:$src);

llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3494,11 +3494,7 @@ bool IRTranslator::translate(const Constant &C, Register Reg) {
34943494
EntryBuilder->buildConstant(Reg, 0);
34953495
else if (auto GV = dyn_cast<GlobalValue>(&C))
34963496
EntryBuilder->buildGlobalValue(Reg, GV);
3497-
else if (auto CPA = dyn_cast<ConstantPtrAuth>(&C)) {
3498-
Register Addr = getOrCreateVReg(*CPA->getPointer());
3499-
Register AddrDisc = getOrCreateVReg(*CPA->getAddrDiscriminator());
3500-
EntryBuilder->buildConstantPtrAuth(Reg, CPA, Addr, AddrDisc);
3501-
} else if (auto CAZ = dyn_cast<ConstantAggregateZero>(&C)) {
3497+
else if (auto CAZ = dyn_cast<ConstantAggregateZero>(&C)) {
35023498
if (!isa<FixedVectorType>(CAZ->getType()))
35033499
return false;
35043500
// Return the scalar if it is a <1 x Ty> vector.

llvm/lib/CodeGen/GlobalISel/MachineIRBuilder.cpp

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -397,19 +397,6 @@ MachineInstrBuilder MachineIRBuilder::buildFConstant(const DstOp &Res,
397397
return buildFConstant(Res, *CFP);
398398
}
399399

400-
MachineInstrBuilder
401-
MachineIRBuilder::buildConstantPtrAuth(const DstOp &Res,
402-
const ConstantPtrAuth *CPA,
403-
Register Addr, Register AddrDisc) {
404-
auto MIB = buildInstr(TargetOpcode::G_PTRAUTH_GLOBAL_VALUE);
405-
Res.addDefToMIB(*getMRI(), MIB);
406-
MIB.addUse(Addr);
407-
MIB.addImm(CPA->getKey()->getZExtValue());
408-
MIB.addUse(AddrDisc);
409-
MIB.addImm(CPA->getDiscriminator()->getZExtValue());
410-
return MIB;
411-
}
412-
413400
MachineInstrBuilder MachineIRBuilder::buildBrCond(const SrcOp &Tst,
414401
MachineBasicBlock &Dest) {
415402
assert(Tst.getLLTTy(*getMRI()).isScalar() && "invalid operand type");

llvm/lib/CodeGen/MachineModuleInfoImpls.cpp

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313

1414
#include "llvm/CodeGen/MachineModuleInfoImpls.h"
1515
#include "llvm/ADT/DenseMap.h"
16-
#include "llvm/ADT/STLExtras.h"
1716
#include "llvm/MC/MCSymbol.h"
1817

1918
using namespace llvm;
@@ -42,25 +41,3 @@ MachineModuleInfoImpl::SymbolListTy MachineModuleInfoImpl::getSortedStubs(
4241
Map.clear();
4342
return List;
4443
}
45-
46-
template <typename MachineModuleInfoTarget>
47-
static typename MachineModuleInfoTarget::AuthStubListTy getAuthGVStubListHelper(
48-
DenseMap<MCSymbol *, typename MachineModuleInfoTarget::AuthStubInfo>
49-
&AuthPtrStubs) {
50-
typename MachineModuleInfoTarget::AuthStubListTy List(AuthPtrStubs.begin(),
51-
AuthPtrStubs.end());
52-
53-
if (!List.empty())
54-
llvm::sort(List.begin(), List.end(),
55-
[](const typename MachineModuleInfoTarget::AuthStubPairTy &LHS,
56-
const typename MachineModuleInfoTarget::AuthStubPairTy &RHS) {
57-
return LHS.first->getName() < RHS.first->getName();
58-
});
59-
60-
AuthPtrStubs.clear();
61-
return List;
62-
}
63-
64-
MachineModuleInfoELF::AuthStubListTy MachineModuleInfoELF::getAuthGVStubList() {
65-
return getAuthGVStubListHelper<MachineModuleInfoELF>(AuthPtrStubs);
66-
}

llvm/lib/CodeGen/MachineVerifier.cpp

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2066,12 +2066,6 @@ void MachineVerifier::verifyPreISelGenericInstruction(const MachineInstr *MI) {
20662066
report("Dst operand 0 must be a pointer", MI);
20672067
break;
20682068
}
2069-
case TargetOpcode::G_PTRAUTH_GLOBAL_VALUE: {
2070-
const MachineOperand &AddrOp = MI->getOperand(1);
2071-
if (!AddrOp.isReg() || !MRI->getType(AddrOp.getReg()).isPointer())
2072-
report("addr operand must be a pointer", &AddrOp, 1);
2073-
break;
2074-
}
20752069
default:
20762070
break;
20772071
}

llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1802,13 +1802,6 @@ SDValue SelectionDAGBuilder::getValueImpl(const Value *V) {
18021802
if (const GlobalValue *GV = dyn_cast<GlobalValue>(C))
18031803
return DAG.getGlobalAddress(GV, getCurSDLoc(), VT);
18041804

1805-
if (const ConstantPtrAuth *CPA = dyn_cast<ConstantPtrAuth>(C)) {
1806-
return DAG.getNode(ISD::PtrAuthGlobalAddress, getCurSDLoc(), VT,
1807-
getValue(CPA->getPointer()), getValue(CPA->getKey()),
1808-
getValue(CPA->getAddrDiscriminator()),
1809-
getValue(CPA->getDiscriminator()));
1810-
}
1811-
18121805
if (isa<ConstantPointerNull>(C)) {
18131806
unsigned AS = V->getType()->getPointerAddressSpace();
18141807
return DAG.getConstant(0, getCurSDLoc(),

llvm/lib/CodeGen/SelectionDAG/SelectionDAGDumper.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,6 @@ std::string SDNode::getOperationName(const SelectionDAG *G) const {
7575
}
7676
return "<<Unknown Node #" + utostr(getOpcode()) + ">>";
7777

78-
// clang-format off
7978
#ifndef NDEBUG
8079
case ISD::DELETED_NODE: return "<<Deleted Node!>>";
8180
#endif
@@ -127,7 +126,6 @@ std::string SDNode::getOperationName(const SelectionDAG *G) const {
127126
case ISD::ConstantFP: return "ConstantFP";
128127
case ISD::GlobalAddress: return "GlobalAddress";
129128
case ISD::GlobalTLSAddress: return "GlobalTLSAddress";
130-
case ISD::PtrAuthGlobalAddress: return "PtrAuthGlobalAddress";
131129
case ISD::FrameIndex: return "FrameIndex";
132130
case ISD::JumpTable: return "JumpTable";
133131
case ISD::JUMP_TABLE_DEBUG_INFO:
@@ -170,6 +168,8 @@ std::string SDNode::getOperationName(const SelectionDAG *G) const {
170168
return "OpaqueTargetConstant";
171169
return "TargetConstant";
172170

171+
// clang-format off
172+
173173
case ISD::TargetConstantFP: return "TargetConstantFP";
174174
case ISD::TargetGlobalAddress: return "TargetGlobalAddress";
175175
case ISD::TargetGlobalTLSAddress: return "TargetGlobalTLSAddress";

0 commit comments

Comments
 (0)