Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion bolt/include/bolt/Core/MCPlusBuilder.h
Original file line number Diff line number Diff line change
Expand Up @@ -1181,7 +1181,7 @@ class MCPlusBuilder {

/// 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
Expand Down Expand Up @@ -1816,6 +1816,8 @@ class MCPlusBuilder {
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)
Expand Down
12 changes: 6 additions & 6 deletions bolt/lib/Core/MCPlusBuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down