if (FileBuildID)
return StringRef(*FileBuildID);
- return None;
+ return std::nullopt;
}
void setFileBuildID(StringRef ID) { FileBuildID = std::string(ID); }
if (Callback(StringRef(Name)))
return StringRef(Name);
- return None;
+ return std::nullopt;
}
/// Check if (possibly one out of many) function name matches the given
/// Return the name of the section this function originated from.
Optional<StringRef> getOriginSectionName() const {
if (!OriginSection)
- return None;
+ return std::nullopt;
return OriginSection->getName();
}
/// Most of the time, using type units with DWO is not a good idea.
/// If type units are used, the caller is responsible for verifying
/// that abbreviations are shared by CU and TUs.
- DebugAbbrevWriter(DWARFContext &Context, Optional<uint64_t> DWOId = None)
+ DebugAbbrevWriter(DWARFContext &Context,
+ Optional<uint64_t> DWOId = std::nullopt)
: Context(Context), DWOId(DWOId) {}
DebugAbbrevWriter(const DebugAbbrevWriter &) = delete;
unsigned Index) const {
const MCInst *AnnotationInst = getAnnotationInst(Inst);
if (!AnnotationInst)
- return None;
+ return std::nullopt;
for (int I = AnnotationInst->getNumOperands() - 1; I >= 0; --I) {
int64_t ImmValue = AnnotationInst->getOperand(I).getImm();
}
}
- return None;
+ return std::nullopt;
}
protected:
auto AI = AnnotationNameIndexMap.find(Name);
if (AI != AnnotationNameIndexMap.end())
return AI->second;
- return None;
+ return std::nullopt;
}
/// Return annotation index matching the \p Name. Create a new index if the
public:
ReachingDefOrUse(const RegAnalysis &RA, BinaryFunction &BF,
- Optional<MCPhysReg> TrackingReg = None,
+ Optional<MCPhysReg> TrackingReg = std::nullopt,
MCPlusBuilder::AllocatorIdTy AllocId = 0)
: InstrsDataflowAnalysis<ReachingDefOrUse<Def>, !Def>(BF, AllocId),
RA(RA), TrackingReg(TrackingReg) {}
}
// Gen
if (!this->BC.MIB->isCFI(Point)) {
- if (TrackingReg == None) {
+ if (TrackingReg == std::nullopt) {
// Track all instructions
Next.set(this->ExprToIdx[&Point]);
} else {
DebugAbbrevWriter &AbbrevWriter,
DebugLocWriter &DebugLocWriter,
DebugRangesSectionWriter &RangesWriter,
- Optional<uint64_t> RangesBase = None);
+ Optional<uint64_t> RangesBase = std::nullopt);
/// Patches the binary for an object's address ranges to be updated.
/// The object can be anything that has associated address ranges via either
/// \p DIE is the object's DIE in the input binary.
/// \p RangesBase if present, update \p DIE to use DW_AT_GNU_ranges_base
/// attribute.
- void updateDWARFObjectAddressRanges(const DWARFDie DIE,
- uint64_t DebugRangesOffset,
- SimpleBinaryPatcher &DebugInfoPatcher,
- DebugAbbrevWriter &AbbrevWriter,
- uint64_t LowPCToUse,
- Optional<uint64_t> RangesBase = None);
+ void updateDWARFObjectAddressRanges(
+ const DWARFDie DIE, uint64_t DebugRangesOffset,
+ SimpleBinaryPatcher &DebugInfoPatcher, DebugAbbrevWriter &AbbrevWriter,
+ uint64_t LowPCToUse, Optional<uint64_t> RangesBase = std::nullopt);
std::unique_ptr<DebugBufferVector>
makeFinalLocListsSection(DebugInfoBinaryPatcher &DebugInfoPatcher,
void convertToRangesPatchAbbrev(const DWARFUnit &Unit,
const DWARFAbbreviationDeclaration *Abbrev,
DebugAbbrevWriter &AbbrevWriter,
- Optional<uint64_t> RangesBase = None);
+ Optional<uint64_t> RangesBase = std::nullopt);
/// Update \p DIE that was using DW_AT_(low|high)_pc with DW_AT_ranges offset.
/// Updates to the DIE should be synced with abbreviation updates using the
/// function above.
- void convertToRangesPatchDebugInfo(DWARFDie DIE, uint64_t RangesSectionOffset,
- SimpleBinaryPatcher &DebugInfoPatcher,
- uint64_t LowPCToUse,
- Optional<uint64_t> RangesBase = None);
+ void
+ convertToRangesPatchDebugInfo(DWARFDie DIE, uint64_t RangesSectionOffset,
+ SimpleBinaryPatcher &DebugInfoPatcher,
+ uint64_t LowPCToUse,
+ Optional<uint64_t> RangesBase = std::nullopt);
/// Helper function for creating and returning per-DWO patchers/writers.
template <class T, class Patcher>
FileName = *FName;
assert(FileName != "");
DWARFCompileUnit *DstUnit = DwCtx->getCompileUnitForOffset(DestCUID);
- return cantFail(getDwarfFile(Dir, FileName, 0, None, None, DestCUID,
- DstUnit->getVersion()));
+ return cantFail(getDwarfFile(Dir, FileName, 0, std::nullopt, std::nullopt,
+ DestCUID, DstUnit->getVersion()));
}
std::vector<BinaryFunction *> BinaryContext::getSortedFunctions() {
Optional<DWARFUnit *> BinaryContext::getDWOCU(uint64_t DWOId) {
auto Iter = DWOCUs.find(DWOId);
if (Iter == DWOCUs.end())
- return None;
+ return std::nullopt;
return Iter->second;
}
Iter->second->getUnitDIE().find(dwarf::DW_AT_name), nullptr);
}
BinaryLineTable.setRootFile(CU->getCompilationDir(), *Name, Checksum,
- None);
+ std::nullopt);
}
BinaryLineTable.setDwarfVersion(DwarfVersion);
// Assign a unique label to every line table, one per CU.
// Make sure empty debug line tables are registered too.
if (FileNames.empty()) {
- cantFail(
- getDwarfFile("", "<unknown>", 0, None, None, CUID, DwarfVersion));
+ cantFail(getDwarfFile("", "<unknown>", 0, std::nullopt, std::nullopt,
+ CUID, DwarfVersion));
continue;
}
const uint32_t Offset = DwarfVersion < 5 ? 1 : 0;
Optional<MD5::MD5Result> Checksum;
if (DwarfVersion >= 5 && LineTable->Prologue.ContentTypes.HasMD5)
Checksum = LineTable->Prologue.FileNames[I].Checksum;
- cantFail(
- getDwarfFile(Dir, FileName, 0, Checksum, None, CUID, DwarfVersion));
+ cantFail(getDwarfFile(Dir, FileName, 0, Checksum, std::nullopt, CUID,
+ DwarfVersion));
}
}
}
}
}
- return None;
+ return std::nullopt;
}
ErrorOr<BinarySection &> BinaryContext::getSectionForAddress(uint64_t Address) {
Optional<DWARFFormValue> Value =
AbbrevDecl->getAttributeValueFromOffset(Index, Offset, U);
if (!Value)
- return None;
+ return std::nullopt;
// AttributeSpec
const DWARFAbbreviationDeclaration::AttributeSpec *AttrVal =
AbbrevDecl->attributes().begin() + Index;
Optional<AttrInfo> findAttributeInfo(const DWARFDie DIE,
dwarf::Attribute Attr) {
if (!DIE.isValid())
- return None;
+ return std::nullopt;
const DWARFAbbreviationDeclaration *AbbrevDecl =
DIE.getAbbreviationDeclarationPtr();
if (!AbbrevDecl)
- return None;
+ return std::nullopt;
Optional<uint32_t> Index = AbbrevDecl->findAttributeIndex(Attr);
if (!Index)
- return None;
+ return std::nullopt;
return findAttributeInfo(DIE, AbbrevDecl, *Index);
}
if (LineTables.empty())
return;
// In a v5 non-split line table, put the strings in a separate section.
- Optional<MCDwarfLineStr> LineStr(None);
+ Optional<MCDwarfLineStr> LineStr(std::nullopt);
ErrorOr<BinarySection &> LineStrSection =
BC.getUniqueSectionByName(".debug_line_str");
// Some versions of GCC output DWARF5 .debug_info, but DWARF4 or lower
Optional<MCLandingPad> MCPlusBuilder::getEHInfo(const MCInst &Inst) const {
if (!isCall(Inst))
- return None;
+ return std::nullopt;
Optional<int64_t> LPSym =
getAnnotationOpValue(Inst, MCAnnotation::kEHLandingPad);
if (!LPSym)
- return None;
+ return std::nullopt;
Optional<int64_t> Action =
getAnnotationOpValue(Inst, MCAnnotation::kEHAction);
if (!Action)
- return None;
+ return std::nullopt;
return std::make_pair(reinterpret_cast<const MCSymbol *>(*LPSym),
static_cast<uint64_t>(*Action));
Optional<int64_t> Value =
getAnnotationOpValue(Inst, MCAnnotation::kConditionalTailCall);
if (!Value)
- return None;
+ return std::nullopt;
return static_cast<uint64_t>(*Value);
}
Optional<uint32_t> MCPlusBuilder::getOffset(const MCInst &Inst) const {
Optional<int64_t> Value = getAnnotationOpValue(Inst, MCAnnotation::kOffset);
if (!Value)
- return None;
+ return std::nullopt;
return static_cast<uint32_t>(*Value);
}
/*ShowInst=*/false));
AsmStreamer->initSections(true, *BC.STI);
std::unique_ptr<TargetMachine> TM(BC.TheTarget->createTargetMachine(
- BC.TripleName, "", "", TargetOptions(), None));
+ BC.TripleName, "", "", TargetOptions(), std::nullopt));
std::unique_ptr<AsmPrinter> MAP(
BC.TheTarget->createAsmPrinter(*TM, std::move(AsmStreamer)));
if (RD)
return *RD;
assert(RA && "RegAnalysis required");
- RD.reset(new ReachingDefOrUse<true>(*RA, BF, None, AllocatorId));
+ RD.reset(new ReachingDefOrUse<true>(*RA, BF, std::nullopt, AllocatorId));
RD->run();
return *RD;
}
if (RU)
return *RU;
assert(RA && "RegAnalysis required");
- RU.reset(new ReachingDefOrUse<false>(*RA, BF, None, AllocatorId));
+ RU.reset(new ReachingDefOrUse<false>(*RA, BF, std::nullopt, AllocatorId));
RU->run();
return *RU;
}
auto Iter = Maps.find(FuncAddress);
if (Iter == Maps.end())
- return None;
+ return std::nullopt;
const MapTy &Map = Iter->second;
auto FromIter = Map.upper_bound(From);
TempFiles.push_back(PPI.StderrPath.data());
std::optional<StringRef> Redirects[] = {
- llvm::None, // Stdin
+ std::nullopt, // Stdin
StringRef(PPI.StdoutPath.data()), // Stdout
StringRef(PPI.StderrPath.data())}; // Stderr
if (Wait)
PPI.PI.ReturnCode = sys::ExecuteAndWait(PerfPath.data(), Argv,
- /*envp*/ llvm::None, Redirects);
+ /*envp*/ std::nullopt, Redirects);
else
- PPI.PI = sys::ExecuteNoWait(PerfPath.data(), Argv, /*envp*/ llvm::None,
+ PPI.PI = sys::ExecuteNoWait(PerfPath.data(), Argv, /*envp*/ std::nullopt,
Redirects);
free(WritableArgsString);
SmallVector<std::pair<uint64_t, uint64_t>, 16> Res;
if (!recordTrace(BF, FirstLBR, SecondLBR, Count, &Res))
- return None;
+ return std::nullopt;
return Res;
}
if (LineEnd == StringRef::npos) {
reportError("expected rest of line");
Diag << "Found: " << ParsingBuf << "\n";
- return None;
+ return std::nullopt;
}
StringRef Line = ParsingBuf.substr(0, LineEnd);
size_t Pos = Line.find("PERF_RECORD_COMM exec");
if (Pos == StringRef::npos)
- return None;
+ return std::nullopt;
Line = Line.drop_front(Pos);
// Line:
if (PIDStr.getAsInteger(10, PID)) {
reportError("expected PID");
Diag << "Found: " << PIDStr << "in '" << Line << "'\n";
- return None;
+ return std::nullopt;
}
return PID;
uint64_t USecTime;
if (SecTimeStr.getAsInteger(10, SecTime) ||
USecTimeStr.getAsInteger(10, USecTime))
- return None;
+ return std::nullopt;
return SecTime * 1000000ULL + USecTime;
}
}
if (LineEnd == StringRef::npos) {
reportError("expected rest of line");
Diag << "Found: " << ParsingBuf << "\n";
- return None;
+ return std::nullopt;
}
StringRef Line = ParsingBuf.substr(0, LineEnd);
size_t Pos = Line.find("PERF_RECORD_FORK");
if (Pos == StringRef::npos) {
consumeRestOfLine();
- return None;
+ return std::nullopt;
}
ForkInfo FI;
if (ChildPIDStr.getAsInteger(10, FI.ChildPID)) {
reportError("expected PID");
Diag << "Found: " << ChildPIDStr << "in '" << Line << "'\n";
- return None;
+ return std::nullopt;
}
const StringRef ParentPIDStr = Line.rsplit('(').second.split(':').first;
if (ParentPIDStr.getAsInteger(10, FI.ParentPID)) {
reportError("expected PID");
Diag << "Found: " << ParentPIDStr << "in '" << Line << "'\n";
- return None;
+ return std::nullopt;
}
consumeRestOfLine();
ErrorOr<StringRef> BuildIDStr = parseString(FieldSeparator, true);
if (std::error_code EC = BuildIDStr.getError())
- return None;
+ return std::nullopt;
// If one of the strings is missing, don't issue a parsing error, but still
// do not return a value.
consumeAllRemainingFS();
if (checkNewLine())
- return None;
+ return std::nullopt;
ErrorOr<StringRef> NameStr = parseString(FieldSeparator, true);
if (std::error_code EC = NameStr.getError())
- return None;
+ return std::nullopt;
consumeRestOfLine();
return std::make_pair(NameStr.get(), BuildIDStr.get());
if (!FileName.empty())
return FileName;
- return None;
+ return std::nullopt;
}
std::error_code
return Name.substr(0, LTOSuffixPos + 11);
if ((LTOSuffixPos = Name.find(".llvm.")) != StringRef::npos)
return Name.substr(0, LTOSuffixPos + 6);
- return None;
+ return std::nullopt;
}
namespace {
for (dwarf::Attribute &Attr : Attrs)
if (Optional<AttrInfo> Info = findAttributeInfo(DIE, Attr))
return Info;
- return None;
+ return std::nullopt;
}
} // namespace bolt
} // namespace llvm
DebugLocWriter->finalize(*DwoDebugInfoPatcher, *DWOAbbrevWriter);
DwoDebugInfoPatcher->clearDestinationLabels();
if (!DwoDebugInfoPatcher->getWasRangBasedUsed())
- RangesBase = None;
+ RangesBase = std::nullopt;
if (Unit->getVersion() >= 5)
TempRangesSectionWriter->finalizeSection();
}
DebugInfoPatcher.addLE32Patch(RangesBaseAttrInfo->Offset,
static_cast<uint32_t>(*RangesBase),
RangesBaseAttrInfo->Size);
- RangesBase = None;
+ RangesBase = std::nullopt;
}
}
auto SectionIter = KnownSections.find(SectionName);
if (SectionIter == KnownSections.end())
- return None;
+ return std::nullopt;
Streamer.switchSection(SectionIter->second.first);
StringRef OutData = SectionContents;
}
return (TextVMAddr && StartOffset)
? Optional<uint64_t>(*TextVMAddr + *StartOffset)
- : llvm::None;
+ : std::nullopt;
}
} // anonymous namespace
Optional<std::string> RewriteInstance::getPrintableBuildID() const {
if (BuildID.empty())
- return None;
+ return std::nullopt;
std::string Str;
raw_string_ostream OS(Str);
assert(SymbolName && "cannot get symbol name");
auto updateSymbolValue = [&](const StringRef Name,
- Optional<uint64_t> Value = None) {
+ Optional<uint64_t> Value = std::nullopt) {
NewSymbol.st_value = Value ? *Value : getNewValueForSymbol(Name);
NewSymbol.st_shndx = ELF::SHN_ABS;
outs() << "BOLT-INFO: setting " << Name << " to 0x"
if (FKI.Flags & MCFixupKindInfo::FKF_IsPCRel) {
switch (FKI.TargetSize) {
default:
- return None;
+ return std::nullopt;
case 8: RelType = ELF::R_X86_64_PC8; break;
case 16: RelType = ELF::R_X86_64_PC16; break;
case 32: RelType = ELF::R_X86_64_PC32; break;
} else {
switch (FKI.TargetSize) {
default:
- return None;
+ return std::nullopt;
case 8: RelType = ELF::R_X86_64_8; break;
case 16: RelType = ELF::R_X86_64_16; break;
case 32: RelType = ELF::R_X86_64_32; break;
Optional<uint8_t> readDWARFExpressionTargetReg(StringRef ExprBytes) {
uint8_t Opcode = ExprBytes[0];
if (Opcode == dwarf::DW_CFA_def_cfa_expression)
- return None;
+ return std::nullopt;
assert((Opcode == dwarf::DW_CFA_expression ||
Opcode == dwarf::DW_CFA_val_expression) &&
"invalid DWARF expression CFI");