[BOLT] Use direct storage for Label annotations. NFCI. (#70147)
Store the Label annotation directly in the operand and avoid the extra allocation and indirection overheads associated with MCSimpleAnnotation.
This commit is contained in:
parent
2400c54c37
commit
b336d741d0
@ -1181,7 +1181,7 @@ public:
|
||||
|
||||
/// Set the label of \p Inst. This label will be emitted right before \p Inst
|
||||
/// is emitted to MCStreamer.
|
||||
bool setLabel(MCInst &Inst, MCSymbol *Label, AllocatorIdTy AllocatorId = 0);
|
||||
bool setLabel(MCInst &Inst, MCSymbol *Label) const;
|
||||
|
||||
/// Return MCSymbol that represents a target of this instruction at a given
|
||||
/// operand number \p OpNum. If there's no symbol associated with
|
||||
@ -1816,6 +1816,8 @@ public:
|
||||
const ValueType &addAnnotation(MCInst &Inst, unsigned Index,
|
||||
const ValueType &Val,
|
||||
AllocatorIdTy AllocatorId = 0) {
|
||||
assert(Index >= MCPlus::MCAnnotation::kGeneric &&
|
||||
"Generic annotation type expected.");
|
||||
assert(!hasAnnotation(Inst, Index));
|
||||
AnnotationAllocator &Allocator = getAnnotationAllocator(AllocatorId);
|
||||
auto *A = new (Allocator.ValueAllocator)
|
||||
|
@ -267,15 +267,15 @@ bool MCPlusBuilder::clearOffset(MCInst &Inst) const {
|
||||
}
|
||||
|
||||
MCSymbol *MCPlusBuilder::getLabel(const MCInst &Inst) const {
|
||||
if (auto Label = tryGetAnnotationAs<MCSymbol *>(Inst, MCAnnotation::kLabel))
|
||||
return *Label;
|
||||
if (std::optional<int64_t> Label =
|
||||
getAnnotationOpValue(Inst, MCAnnotation::kLabel))
|
||||
return reinterpret_cast<MCSymbol *>(*Label);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
bool MCPlusBuilder::setLabel(MCInst &Inst, MCSymbol *Label,
|
||||
AllocatorIdTy AllocatorId) {
|
||||
getOrCreateAnnotationAs<MCSymbol *>(Inst, MCAnnotation::kLabel, AllocatorId) =
|
||||
Label;
|
||||
bool MCPlusBuilder::setLabel(MCInst &Inst, MCSymbol *Label) const {
|
||||
setAnnotationOpValue(Inst, MCAnnotation::kLabel,
|
||||
reinterpret_cast<int64_t>(Label));
|
||||
return true;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user