LLVM: lib/CodeGen/MachineStableHash.cpp Source File (original) (raw)
1
2
3
4
5
6
7
8
9
10
11
12
13
28#include "llvm/Config/llvm-config.h"
35
36#define DEBUG_TYPE "machine-stable-hash"
37
38using namespace llvm;
39
40STATISTIC(StableHashBailingMachineBasicBlock,
41 "Number of encountered unsupported MachineOperands that were "
42 "MachineBasicBlocks while computing stable hashes");
43STATISTIC(StableHashBailingConstantPoolIndex,
44 "Number of encountered unsupported MachineOperands that were "
45 "ConstantPoolIndex while computing stable hashes");
46STATISTIC(StableHashBailingTargetIndexNoName,
47 "Number of encountered unsupported MachineOperands that were "
48 "TargetIndex with no name");
50 "Number of encountered unsupported MachineOperands that were "
51 "GlobalAddress while computing stable hashes");
53 "Number of encountered unsupported MachineOperands that were "
54 "BlockAddress while computing stable hashes");
55STATISTIC(StableHashBailingMetadataUnsupported,
56 "Number of encountered unsupported MachineOperands that were "
57 "Metadata of an unsupported kind while computing stable hashes");
58
65 for (auto &Def : MRI.def_instructions(MO.getReg()))
66 DefOpcodes.push_back(Def.getOpcode());
68 }
69
70
82 }
83
85 ++StableHashBailingMachineBasicBlock;
86 return 0;
88 ++StableHashBailingConstantPoolIndex;
89 return 0;
91 ++StableHashBailingBlockAddress;
92 return 0;
94 ++StableHashBailingMetadataUnsupported;
95 return 0;
101 if (!GVHash) {
103 ++StableHashBailingGlobalAddress;
104 return 0;
105 }
107 }
108
111 }
112
117 ++StableHashBailingTargetIndexNoName;
118 return 0;
119 }
120
125
130
137 unsigned RegMaskSize =
141 std::vectorllvm::stable\_hash RegMaskHashes(RegMask,
142 RegMask + RegMaskSize);
145 }
146 }
147 }
148
149 assert(0 && "MachineOperand not associated with any MachineFunction");
151 }
152
154 std::vectorllvm::stable\_hash ShuffleMaskHashes;
155
157 MO.getShuffleMask(), std::back_inserter(ShuffleMaskHashes),
158 [](int S) -> llvm::stable_hash { return llvm::stable_hash(S); });
159
162 }
167 }
171 }
184 }
186}
187
188
189
190
191
193 bool HashConstantPoolIndices,
194 bool HashMemOperands) {
195
197 HashComponents.reserve(MI.getNumOperands() + MI.getNumMemOperands() + 2);
198 HashComponents.push_back(MI.getOpcode());
201 if (!HashVRegs && MO.isReg() && MO.isDef() && MO.getReg().isVirtual())
202 continue;
203
204 if (MO.isCPI()) {
206 MO.getType(), MO.getTargetFlags(), MO.getIndex()));
207 continue;
208 }
209
211 if (!StableHash)
212 return 0;
213 HashComponents.push_back(StableHash);
214 }
215
216 for (const auto *Op : MI.memoperands()) {
217 if (!HashMemOperands)
218 break;
219 HashComponents.push_back(static_cast<unsigned>(Op->getSize().getValue()));
220 HashComponents.push_back(static_cast<unsigned>(Op->getFlags()));
221 HashComponents.push_back(static_cast<unsigned>(Op->getOffset()));
222 HashComponents.push_back(static_cast<unsigned>(Op->getSuccessOrdering()));
223 HashComponents.push_back(static_cast<unsigned>(Op->getAddrSpace()));
224 HashComponents.push_back(static_cast<unsigned>(Op->getSyncScopeID()));
225 HashComponents.push_back(static_cast<unsigned>(Op->getBaseAlign().value()));
226 HashComponents.push_back(static_cast<unsigned>(Op->getFailureOrdering()));
227 }
228
230}
231
234
235 for (const auto &MI : MBB)
238}
239
242
243 for (const auto &MBB : MF)
246}
unsigned const MachineRegisterInfo * MRI
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
This file declares a class to represent arbitrary precision floating point values and provide a varie...
This file implements a class to represent arbitrary precision integral constant values and operations...
This file contains the declarations for the subclasses of Constant, which represent the different fla...
Register const TargetRegisterInfo * TRI
This file defines the SmallVector class.
This file defines the 'Statistic' class, which is designed to be an easy way to expose various metric...
#define STATISTIC(VARNAME, DESC)
APInt bitcastToAPInt() const
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
const APFloat & getValueAPF() const
const APInt & getValue() const
Return the constant as an APInt value reference.
StringRef getName() const
getName - Get the symbol name.
MachineRegisterInfo & getRegInfo()
getRegInfo - Return information about the registers currently in use.
Representation of each machine instruction.
LLVM_ABI const MachineFunction * getMF() const
Return the function that contains the basic block that this instruction belongs to.
MachineOperand class - Representation of each machine instruction operand.
unsigned getSubReg() const
unsigned getInstrRefOpIndex() const
const GlobalValue * getGlobal() const
const uint32_t * getRegLiveOut() const
getRegLiveOut - Returns a bit mask of live-out registers.
const ConstantInt * getCImm() const
LLVM_ABI const char * getTargetIndexName() const
getTargetIndexName - If this MachineOperand is a TargetIndex that has a name, attempt to get the name...
bool isCImm() const
isCImm - Test if this is a MO_CImmediate operand.
unsigned getInstrRefInstrIndex() const
bool isRegMask() const
isRegMask - Tests if this is a MO_RegisterMask operand.
ArrayRef< int > getShuffleMask() const
LaneBitmask getLaneMask() const
unsigned getCFIIndex() const
MachineInstr * getParent()
getParent - Return the instruction that this operand belongs to.
static unsigned getRegMaskSize(unsigned NumRegs)
Returns number of elements needed for a regmask array.
unsigned getTargetFlags() const
MachineOperandType getType() const
getType - Returns the MachineOperandType for this operand.
const char * getSymbolName() const
Register getReg() const
getReg - Returns the register number.
Intrinsic::ID getIntrinsicID() const
const uint32_t * getRegMask() const
getRegMask - Returns a bit mask of registers preserved by this RegMask operand.
const ConstantFP * getFPImm() const
unsigned getPredicate() const
MCSymbol * getMCSymbol() const
@ MO_CFIIndex
MCCFIInstruction index.
@ MO_Immediate
Immediate operand.
@ MO_ConstantPoolIndex
Address of indexed Constant in Constant Pool.
@ MO_MCSymbol
MCSymbol reference (for debug/eh info)
@ MO_Predicate
Generic predicate for ISel.
@ MO_GlobalAddress
Address of a global value.
@ MO_RegisterMask
Mask of preserved registers.
@ MO_ShuffleMask
Other IR Constant for ISel (shuffle masks)
@ MO_CImmediate
Immediate >64bit operand.
@ MO_BlockAddress
Address of a basic block.
@ MO_DbgInstrRef
Integer indices referring to an instruction+operand.
@ MO_MachineBasicBlock
MachineBasicBlock reference.
@ MO_LaneMask
Mask to represent active parts of registers.
@ MO_FrameIndex
Abstract Stack Frame Index.
@ MO_Register
Register operand.
@ MO_ExternalSymbol
Name of external global symbol.
@ MO_IntrinsicID
Intrinsic ID for ISel.
@ MO_JumpTableIndex
Address of indexed Jump Table for switch.
@ MO_TargetIndex
Target-dependent index+offset operand.
@ MO_Metadata
Metadata reference (for debug info)
@ MO_FPImmediate
Floating-point immediate operand.
@ MO_RegisterLiveOut
Mask of live-out registers.
int64_t getOffset() const
Return the offset from the symbol in this operand.
MachineRegisterInfo - Keep track of information for virtual and physical registers,...
constexpr bool isVirtual() const
Return true if the specified register number is in the virtual register namespace.
constexpr unsigned id() const
void reserve(size_type N)
void push_back(const T &Elt)
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
TargetRegisterInfo base class - We assume that the target defines a static array of TargetRegisterDes...
LLVM_ABI StringRef getName() const
Return a constant reference to the value's name.
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
This is an optimization pass for GlobalISel generic memory operations.
decltype(auto) dyn_cast(const From &Val)
dyn_cast - Return the argument parameter cast to the specified type.
uint64_t stable_hash
An opaque object representing a stable hash code.
OutputIt transform(R &&Range, OutputIt d_first, UnaryFunction F)
Wrapper function around std::transform to apply a function to a range and store the result elsewhere.
LLVM_ABI stable_hash stableHashValue(const MachineOperand &MO)
Definition MachineStableHash.cpp:59
stable_hash stable_hash_name(StringRef Name)
DWARFExpression::Operation Op
stable_hash stable_hash_combine(ArrayRef< stable_hash > Buffer)
LLVM_ABI stable_hash StructuralHash(const Function &F, bool DetailedHash=false)
Returns a hash of the function F.
constexpr Type getAsInteger() const