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
2 changes: 1 addition & 1 deletion bolt/docs/BinaryAnalysis.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# BOLT-based binary analysis

As part of post-link-time optimizing, BOLT needs to perform a range of analyses
on binaries such as recontructing control flow graphs, and more.
on binaries such as reconstructing control flow graphs, and more.

The `llvm-bolt-binary-analysis` tool enables running requested binary analyses
on binaries, and generating reports. It does this by building on top of the
Expand Down
2 changes: 1 addition & 1 deletion bolt/docs/CommandLineArgumentReference.md
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,7 @@

- `--use-old-text`

Re-use space in old .text if possible (relocation mode)
Reuse space in old .text if possible (relocation mode)

- `-v <uint>`

Expand Down
2 changes: 1 addition & 1 deletion bolt/docs/RuntimeLibrary.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ However, this approach quickly becomes awkward if we want to insert a lot of cod
Currently, our runtime library is written in C++ and contains code that helps us instrument a binary.

### Limitations
Our library is not written with regular C++ code as it is not linked against any other libraries (this means we cannnot rely on anything defined on libstdc++, glibc, libgcc etc), but is self sufficient. In runtime/CMakeLists.txt, we can see it is built with -ffreestanding, which requires the compiler to avoid using a runtime library by itself.
Our library is not written with regular C++ code as it is not linked against any other libraries (this means we cannot rely on anything defined on libstdc++, glibc, libgcc etc), but is self sufficient. In runtime/CMakeLists.txt, we can see it is built with -ffreestanding, which requires the compiler to avoid using a runtime library by itself.

While this requires us to make our own syscalls, it does simplify our linker a lot, which is very limited and can only do basic function name resolving. However, this is a big improvement in comparison with programmatically generating the code in assembly language using MCInsts.

Expand Down
2 changes: 1 addition & 1 deletion bolt/docs/doxygen.cfg.in
Original file line number Diff line number Diff line change
Expand Up @@ -1070,7 +1070,7 @@ HTML_STYLESHEET =
# defined cascading style sheet that is included after the standard style sheets
# created by doxygen. Using this option one can overrule certain style aspects.
# This is preferred over using HTML_STYLESHEET since it does not replace the
# standard style sheet and is therefor more robust against future updates.
# standard style sheet and is therefore more robust against future updates.
# Doxygen will copy the style sheet file to the output directory. For an example
# see the documentation.
# This tag requires that the tag GENERATE_HTML is set to YES.
Expand Down
2 changes: 1 addition & 1 deletion bolt/include/bolt/Core/BinaryFunction.h
Original file line number Diff line number Diff line change
Expand Up @@ -1336,7 +1336,7 @@ class BinaryFunction {
ColdCodeSectionName = Name.str();
}

/// Return true iif the function will halt execution on entry.
/// Return true if the function will halt execution on entry.
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

iff can be if-and-only-if but I do not sense that is the case here.

bool trapsOnEntry() const { return TrapsOnEntry; }

/// Make the function always trap on entry. Other than the trap instruction,
Expand Down
2 changes: 1 addition & 1 deletion bolt/include/bolt/Core/DIEBuilder.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ class DIEBuilder {
uint32_t UnitLength = 0;
bool IsConstructed = false;
// A map of DIE offsets in original DWARF section to DIE ID.
// Whih is used to access DieInfoVector.
// Which is used to access DieInfoVector.
std::unordered_map<uint64_t, uint32_t> DIEIDMap;

// Some STL implementations don't have a noexcept move constructor for
Expand Down
6 changes: 3 additions & 3 deletions bolt/include/bolt/Core/DebugData.h
Original file line number Diff line number Diff line change
Expand Up @@ -326,8 +326,8 @@ class DebugAddrWriter {
/// Write out entries in to .debug_addr section for CUs.
virtual std::optional<uint64_t> finalize(const size_t BufferSize);

/// Return buffer with all the entries in .debug_addr already writen out using
/// update(...).
/// Return buffer with all the entries in .debug_addr already written out
/// using update(...).
virtual std::unique_ptr<AddressSectionBuffer> releaseBuffer() {
return std::move(Buffer);
}
Expand Down Expand Up @@ -409,7 +409,7 @@ class DebugAddrWriter {
std::mutex WriterMutex;
std::unique_ptr<AddressSectionBuffer> Buffer;
std::unique_ptr<raw_svector_ostream> AddressStream;
/// Used to track sections that were not modified so that they can be re-used.
/// Used to track sections that were not modified so that they can be reused.
static DenseMap<uint64_t, uint64_t> UnmodifiedAddressOffsets;
};

Expand Down
4 changes: 2 additions & 2 deletions bolt/include/bolt/Core/DebugNames.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ class DWARF5AcceleratorTable {
void setCurrentUnit(DWARFUnit &Unit, const uint64_t UnitStartOffset);
/// Emit Accelerator table.
void emitAccelTable();
/// Returns true if the table was crated.
/// Returns true if the table was created.
bool isCreated() const { return NeedToCreate; }
/// Returns buffer containing the accelerator table.
std::unique_ptr<DebugBufferVector> releaseBuffer() {
Expand All @@ -91,7 +91,7 @@ class DWARF5AcceleratorTable {
uint64_t CurrentUnitOffset = 0;
const DWARFUnit *CurrentUnit = nullptr;
std::unordered_map<uint32_t, uint32_t> AbbrevTagToIndexMap;
/// Contains a map of TU hashes to a Foreign TU indecies.
/// Contains a map of TU hashes to a Foreign TU indices.
/// This is used to reduce the size of Foreign TU list since there could be
/// multiple TUs with the same hash.
DenseMap<uint64_t, uint32_t> TUHashToIndexMap;
Expand Down
4 changes: 2 additions & 2 deletions bolt/include/bolt/Core/MCPlusBuilder.h
Original file line number Diff line number Diff line change
Expand Up @@ -432,7 +432,7 @@ class MCPlusBuilder {
return Analysis->isConditionalBranch(Inst);
}

/// Returns true if Inst is a condtional move instruction
/// Returns true if Inst is a conditional move instruction
virtual bool isConditionalMove(const MCInst &Inst) const {
llvm_unreachable("not implemented");
return false;
Expand Down Expand Up @@ -1564,7 +1564,7 @@ class MCPlusBuilder {
}

/// Get the default def_in and live_out registers for the function
/// Currently only used for the Stoke optimzation
/// Currently only used for the Stoke optimization
virtual void getDefaultDefIn(BitVector &Regs) const {
llvm_unreachable("not implemented");
}
Expand Down
2 changes: 1 addition & 1 deletion bolt/include/bolt/Passes/FrameAnalysis.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ struct FrameIndexEntry {
int64_t StackOffset;
uint8_t Size;

/// If this is false, we will never atempt to remove or optimize this
/// If this is false, we will never attempt to remove or optimize this
/// instruction. We just use it to keep track of stores we don't fully
/// understand but we know it may write to a frame position.
bool IsSimple;
Expand Down
2 changes: 1 addition & 1 deletion bolt/include/bolt/Passes/LongJmp.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ namespace bolt {
/// 64-bit range, we guarantee it can reach any code location.
///
class LongJmpPass : public BinaryFunctionPass {
/// Used to implement stub grouping (re-using a stub from one function into
/// Used to implement stub grouping (reusing a stub from one function into
/// another)
using StubTy = std::pair<uint64_t, BinaryBasicBlock *>;
using StubGroupTy = SmallVector<StubTy, 4>;
Expand Down
2 changes: 1 addition & 1 deletion bolt/include/bolt/Passes/ProfileQualityStats.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
// aggregates the block gaps into 2 values for the function: "weighted" is the
// weighted average of the block conservation gaps, where the weights depend on
// each block's execution count and instruction count; "worst" is the worst
// (biggest) block gap acorss all basic blocks in the function with an execution
// (biggest) block gap across all basic blocks in the function with an execution
// count of > 500. The pass then reports the 95th percentile of the weighted and
// worst values of the 1000 functions in a single BOLT-INFO line. The smaller
// the reported values are, the better the BOLT profile satisfies the function
Expand Down
2 changes: 1 addition & 1 deletion bolt/include/bolt/Passes/ReorderAlgorithm.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ namespace bolt {

/// Objects of this class implement various basic block clustering algorithms.
/// Basic block clusters are chains of basic blocks that should be laid out
/// in this order to maximize performace. These algorithms group basic blocks
/// in this order to maximize performance. These algorithms group basic blocks
/// into clusters using execution profile data and various heuristics.
class ClusterAlgorithm {
public:
Expand Down
2 changes: 1 addition & 1 deletion bolt/include/bolt/Rewrite/DWARFRewriter.h
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ class DWARFRewriter {
CUOffsetMap finalizeTypeSections(DIEBuilder &DIEBlder, DIEStreamer &Streamer,
GDBIndex &GDBIndexSection);

/// Process and write out CUs that are passsed in.
/// Process and write out CUs that are passed in.
void finalizeCompileUnits(DIEBuilder &DIEBlder, DIEStreamer &Streamer,
CUOffsetMap &CUMap,
const std::list<DWARFUnit *> &CUs,
Expand Down
4 changes: 2 additions & 2 deletions bolt/lib/Core/BinaryContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -844,7 +844,7 @@ BinaryContext::getOrCreateJumpTable(BinaryFunction &Function, uint64_t Address,
auto isSibling = std::bind(&BinaryContext::areRelatedFragments, this,
&Function, std::placeholders::_1);
assert(llvm::all_of(JT->Parents, isSibling) &&
"cannot re-use jump table of a different function");
"cannot reuse jump table of a different function");
(void)isSibling;
if (opts::Verbosity > 2) {
this->outs() << "BOLT-INFO: multiple fragments access the same jump table"
Expand All @@ -860,7 +860,7 @@ BinaryContext::getOrCreateJumpTable(BinaryFunction &Function, uint64_t Address,
return JT->getFirstLabel();
}

// Re-use the existing symbol if possible.
// Reuse the existing symbol if possible.
MCSymbol *JTLabel = nullptr;
if (BinaryData *Object = getBinaryDataAtAddress(Address)) {
if (!isInternalSymbolName(Object->getSymbol()->getName()))
Expand Down
2 changes: 1 addition & 1 deletion bolt/lib/Core/BinaryFunction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3875,7 +3875,7 @@ uint64_t BinaryFunction::getEntryIDForSymbol(const MCSymbol *Symbol) const {
if (FunctionSymbol == Symbol)
return 0;

// Check all secondary entries available as either basic blocks or lables.
// Check all secondary entries available as either basic blocks or labels.
uint64_t NumEntries = 1;
for (const BinaryBasicBlock *BB : BasicBlocks) {
MCSymbol *EntrySymbol = getSecondaryEntryPointSymbol(*BB);
Expand Down
2 changes: 1 addition & 1 deletion bolt/lib/Core/BinaryFunctionCallGraph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ buildCallGraph(BinaryContext &BC, CgFilterFunction Filter, bool CgFromPerfData,
// create a node for a function unless it was the target of a call from
// a hot block. The alternative would be to set the count to one or
// accumulate the number of calls from the callsite into the function
// samples. Results from perfomance testing seem to favor the zero
// samples. Results from performance testing seem to favor the zero
// count though, so I'm leaving it this way for now.
return Cg.addNode(Function, Size, Function->getKnownExecutionCount());
}
Expand Down
6 changes: 3 additions & 3 deletions bolt/lib/Core/DIEBuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ void DIEBuilder::updateReferences() {
DIEInteger(NewAddr));
}

// Handling referenes in location expressions.
// Handling references in location expressions.
for (LocWithReference &LocExpr : getState().LocWithReferencesToProcess) {
SmallVector<uint8_t, 32> Buffer;
DataExtractor Data(StringRef((const char *)LocExpr.BlockData.data(),
Expand Down Expand Up @@ -336,7 +336,7 @@ void DIEBuilder::buildCompileUnits(const bool Init) {
registerUnit(*DU, false);
}

// Using DULIst since it can be modified by cross CU refrence resolution.
// Using DULIst since it can be modified by cross CU reference resolution.
for (DWARFUnit *DU : getState().DUList) {
if (DU->isTypeUnit())
continue;
Expand Down Expand Up @@ -508,7 +508,7 @@ void DIEBuilder::finish() {
UnitStartOffset += CurUnitInfo.UnitLength;
};
// Computing offsets for .debug_types section.
// It's processed first when CU is registered so will be at the begginnig of
// It's processed first when CU is registered so will be at the beginning of
// the vector.
uint64_t TypeUnitStartOffset = 0;
for (DWARFUnit *CU : getState().DUList) {
Expand Down
4 changes: 2 additions & 2 deletions bolt/lib/Core/DebugData.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -876,7 +876,7 @@ void DebugStrOffsetsWriter::finalizeSection(DWARFUnit &Unit,
DIEValue StrListBaseAttrInfo =
Die.findAttribute(dwarf::DW_AT_str_offsets_base);
auto RetVal = ProcessedBaseOffsets.find(*Val);
// Handling re-use of str-offsets section.
// Handling reuse of str-offsets section.
if (RetVal == ProcessedBaseOffsets.end() || StrOffsetSectionWasModified) {
initialize(Unit);
// Update String Offsets that were modified.
Expand Down Expand Up @@ -1167,7 +1167,7 @@ void DwarfLineTable::emitCU(MCStreamer *MCOS, MCDwarfLineTableParams Params,
// For functions that we do not modify we output them as raw data.
// Re-constructing .debug_line_str so that offsets are correct for those
// debug line tables.
// Bonus is that when we output a final binary we can re-use .debug_line_str
// Bonus is that when we output a final binary we can reuse .debug_line_str
// section. So we don't have to do the SHF_ALLOC trick we did with
// .debug_line.
static void parseAndPopulateDebugLineStr(BinarySection &LineStrSection,
Expand Down
4 changes: 2 additions & 2 deletions bolt/lib/Core/DebugNames.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ DWARF5AcceleratorTable::DWARF5AcceleratorTable(
llvm::hash_value(llvm::StringRef(CStr)), StrOffset);
if (!R.second)
BC.errs()
<< "BOLT-WARNING: [internal-dwarf-error]: collision occured on "
<< "BOLT-WARNING: [internal-dwarf-error]: collision occurred on "
<< CStr << " at offset : 0x" << Twine::utohexstr(StrOffset)
<< ". Previous string offset is: 0x"
<< Twine::utohexstr(R.first->second) << ".\n";
Expand Down Expand Up @@ -86,7 +86,7 @@ void DWARF5AcceleratorTable::addUnit(DWARFUnit &Unit,
if (Unit.isTypeUnit()) {
if (DWOID) {
// We adding an entry for a DWO TU. The DWO CU might not have any entries,
// so need to add it to the list pre-emptively.
// so need to add it to the list preemptively.
auto Iter = CUOffsetsToPatch.insert({*DWOID, CUList.size()});
if (Iter.second)
CUList.push_back(BADCUOFFSET);
Expand Down
4 changes: 2 additions & 2 deletions bolt/lib/Passes/Aligner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,15 +60,15 @@ namespace llvm {
namespace bolt {

// Align function to the specified byte-boundary (typically, 64) offsetting
// the fuction by not more than the corresponding value
// the function by not more than the corresponding value
static void alignMaxBytes(BinaryFunction &Function) {
Function.setAlignment(opts::AlignFunctions);
Function.setMaxAlignmentBytes(opts::AlignFunctionsMaxBytes);
Function.setMaxColdAlignmentBytes(opts::AlignFunctionsMaxBytes);
}

// Align function to the specified byte-boundary (typically, 64) offsetting
// the fuction by not more than the minimum over
// the function by not more than the minimum over
// -- the size of the function
// -- the specified number of bytes
static void alignCompact(BinaryFunction &Function,
Expand Down
6 changes: 3 additions & 3 deletions bolt/lib/Passes/RegReAssign.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -145,15 +145,15 @@ void RegReAssign::rankRegisters(BinaryFunction &Function) {
const bool CannotUseREX = BC.MIB->cannotUseREX(Inst);
const MCInstrDesc &Desc = BC.MII->get(Inst.getOpcode());

// Disallow substituitions involving regs in implicit uses lists
// Disallow substitutions involving regs in implicit uses lists
for (MCPhysReg ImplicitUse : Desc.implicit_uses()) {
const size_t RegEC =
BC.MIB->getAliases(ImplicitUse, false).find_first();
RegScore[RegEC] =
std::numeric_limits<decltype(RegScore)::value_type>::min();
}

// Disallow substituitions involving regs in implicit defs lists
// Disallow substitutions involving regs in implicit defs lists
for (MCPhysReg ImplicitDef : Desc.implicit_defs()) {
const size_t RegEC =
BC.MIB->getAliases(ImplicitDef, false).find_first();
Expand All @@ -174,7 +174,7 @@ void RegReAssign::rankRegisters(BinaryFunction &Function) {
if (RegEC == 0)
continue;

// Disallow substituitions involving regs in instrs that cannot use REX
// Disallow substitutions involving regs in instrs that cannot use REX
// The relationship of X86 registers is shown in the diagram. BL and BH
// do not have a direct alias relationship. However, if the BH register
// cannot be swapped, then the BX/EBX/RBX registers cannot be swapped as
Expand Down
12 changes: 6 additions & 6 deletions bolt/lib/Passes/SplitFunctions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -386,7 +386,7 @@ struct SplitCacheDirected final : public SplitStrategy {
}

/// Compute sum of scores over jumps within \p BlockOrder given \p SplitIndex.
/// Increament Score.LocalScore in place by the sum.
/// Increment Score.LocalScore in place by the sum.
void computeJumpScore(const BasicBlockOrder &BlockOrder,
const size_t SplitIndex, SplitScore &Score) {

Expand All @@ -413,7 +413,7 @@ struct SplitCacheDirected final : public SplitStrategy {
}

/// Compute sum of scores over calls originated in the current function
/// given \p SplitIndex. Increament Score.LocalScore in place by the sum.
/// given \p SplitIndex. Increment Score.LocalScore in place by the sum.
void computeLocalCallScore(const BasicBlockOrder &BlockOrder,
const size_t SplitIndex, SplitScore &Score) {
if (opts::CallScale == 0)
Expand Down Expand Up @@ -455,7 +455,7 @@ struct SplitCacheDirected final : public SplitStrategy {
}

/// Compute sum of splitting scores for cover calls of the input function.
/// Increament Score.CoverCallScore in place by the sum.
/// Increment Score.CoverCallScore in place by the sum.
void computeCoverCallScore(const BasicBlockOrder &BlockOrder,
const size_t SplitIndex,
const std::vector<CallInfo> &CoverCalls,
Expand All @@ -467,7 +467,7 @@ struct SplitCacheDirected final : public SplitStrategy {
assert(CI.Length >= Score.HotSizeReduction &&
"Length of cover calls must exceed reduced size of hot fragment.");
// Compute the new length of the call, which is shorter than the original
// one by the size of the splitted fragment minus the total size increase.
// one by the size of the split fragment minus the total size increase.
const size_t NewCallLength = CI.Length - Score.HotSizeReduction;
Score.CoverCallScore += computeCallScore(CI.Count, NewCallLength);
}
Expand Down Expand Up @@ -502,12 +502,12 @@ struct SplitCacheDirected final : public SplitStrategy {

// First part of LocalScore is the sum over call edges originated in the
// input function. These edges can get shorter or longer depending on
// SplitIndex. Score.LocalScore is increamented in place.
// SplitIndex. Score.LocalScore is incremented in place.
computeLocalCallScore(BlockOrder, SplitIndex, Score);

// Second part of LocalScore is the sum over jump edges with src basic block
// and dst basic block in the current function. Score.LocalScore is
// increamented in place.
// incremented in place.
computeJumpScore(BlockOrder, SplitIndex, Score);

// Compute CoverCallScore and store in Score in place.
Expand Down
2 changes: 1 addition & 1 deletion bolt/lib/Profile/DataReader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -907,7 +907,7 @@ ErrorOr<uint64_t> DataReader::parseHexField(char EndChar, bool EndNl) {
StringRef NumStr = NumStrRes.get();
uint64_t Num;
if (NumStr.getAsInteger(16, Num)) {
reportError("expected hexidecimal number");
reportError("expected hexadecimal number");
Diag << "Found: " << NumStr << "\n";
return make_error_code(llvm::errc::io_error);
}
Expand Down
2 changes: 1 addition & 1 deletion bolt/lib/Rewrite/BuildIDRewriter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ class BuildIDRewriter final : public MetadataRewriter {
};

Error BuildIDRewriter::sectionInitializer() {
// Typically, build ID will reside in .note.gnu.build-id section. Howerver,
// Typically, build ID will reside in .note.gnu.build-id section. However,
// a linker script can change the section name and such is the case with
// the Linux kernel. Hence, we iterate over all note sections.
for (BinarySection &NoteSection : BC.sections()) {
Expand Down
6 changes: 3 additions & 3 deletions bolt/lib/Rewrite/DWARFRewriter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1723,7 +1723,7 @@ StringRef getSectionName(const SectionRef &Section) {
return Name;
}

// Exctracts an appropriate slice if input is DWP.
// Extracts an appropriate slice if input is DWP.
// Applies patches or overwrites the section.
std::optional<StringRef> updateDebugData(
DWARFContext &DWCtx, StringRef SectionName, StringRef SectionContents,
Expand Down Expand Up @@ -1759,7 +1759,7 @@ std::optional<StringRef> updateDebugData(
auto Iter = OverridenSections.find(Kind);
if (Iter == OverridenSections.end()) {
errs()
<< "BOLT-WARNING: [internal-dwarf-error]: Could not find overriden "
<< "BOLT-WARNING: [internal-dwarf-error]: Could not find overridden "
"section for: "
<< Twine::utohexstr(DWOId) << ".\n";
return std::nullopt;
Expand Down Expand Up @@ -1991,7 +1991,7 @@ void DWARFRewriter::convertToRangesPatchDebugInfo(
}
}

// HighPC was conveted into DW_AT_ranges.
// HighPC was converted into DW_AT_ranges.
// For DWARF5 we only access ranges through index.

DIEBldr.replaceValue(&Die, HighPCAttrInfo.getAttribute(), dwarf::DW_AT_ranges,
Expand Down
Loading
Loading