Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BOLT] Match functions with name similarity #95884

Merged
Merged
Show file tree
Hide file tree
Changes from 31 commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
fab60ab
[𝘀𝗽𝗿] changes to main this commit is based on
sayhaan Jun 18, 2024
7ac4c1a
[𝘀𝗽𝗿] initial version
shawbyoung Jun 18, 2024
0a5a829
[𝘀𝗽𝗿] changes introduced through rebase
shawbyoung Jun 21, 2024
190949c
spr amend
shawbyoung Jun 21, 2024
34652b2
spr amend
shawbyoung Jun 21, 2024
2d23bbd
spr amend
shawbyoung Jun 21, 2024
9e6bb26
spr amend
shawbyoung Jun 21, 2024
ff561cb
[𝘀𝗽𝗿] changes introduced through rebase
shawbyoung Jun 21, 2024
58993f9
spr amend
shawbyoung Jun 21, 2024
669afca
spr amend
shawbyoung Jun 21, 2024
9c021f8
spr amend
shawbyoung Jun 21, 2024
9fc1899
spr amend
shawbyoung Jun 21, 2024
d687bc0
Added test
shawbyoung Jun 24, 2024
bba68e6
[𝘀𝗽𝗿] changes introduced through rebase
maksfb Jun 24, 2024
2d99875
Changed DeriveNameSpace argument
shawbyoung Jun 24, 2024
550d6ac
[𝘀𝗽𝗿] changes introduced through rebase
maksfb Jun 25, 2024
be21785
spr diff --update-message
shawbyoung Jun 25, 2024
5493cd4
[𝘀𝗽𝗿] changes introduced through rebase
maksfb Jun 25, 2024
0ddd72b
Refactored DeriveNamespace and expanded flag description
shawbyoung Jun 25, 2024
5d3e8db
[𝘀𝗽𝗿] changes introduced through rebase
maksfb Jun 26, 2024
0eeeeb6
Removed tmp file
shawbyoung Jun 26, 2024
85c74bd
[𝘀𝗽𝗿] changes introduced through rebase
maksfb Jun 26, 2024
5da6a09
Small optimization
shawbyoung Jun 26, 2024
c40b612
[𝘀𝗽𝗿] changes introduced through rebase
maksfb Jun 28, 2024
e9974a9
Refactored into function
shawbyoung Jun 28, 2024
3885a7f
[𝘀𝗽𝗿] changes introduced through rebase
maksfb Jun 28, 2024
d00d613
Changed verbosity
shawbyoung Jun 28, 2024
60d7d92
[𝘀𝗽𝗿] changes introduced through rebase
maksfb Jun 28, 2024
c65bce0
Formatting
shawbyoung Jun 28, 2024
4c63f17
[𝘀𝗽𝗿] changes introduced through rebase
maksfb Jul 3, 2024
873afb2
Using BufferSize from getContextDeclCxtName
shawbyoung Jul 3, 2024
d61c640
[𝘀𝗽𝗿] changes introduced through rebase
maksfb Jul 3, 2024
a801ff3
Comments
shawbyoung Jul 3, 2024
32cce08
[𝘀𝗽𝗿] changes introduced through rebase
aaupov Jul 3, 2024
1dab537
Rebase
shawbyoung Jul 3, 2024
60047ab
Changing buffer initialization in DeriveNamespace
shawbyoung Jul 3, 2024
df20265
[𝘀𝗽𝗿] changes introduced through rebase
aaupov Jul 3, 2024
2e0eae4
Rebase
shawbyoung Jul 3, 2024
39a6901
Rebase
shawbyoung Jul 3, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
The diff you're trying to view is too large. We only load the first 3000 changed files.
3 changes: 1 addition & 2 deletions .ci/generate-buildkite-pipeline-premerge
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,7 @@ function compute-projects-to-test() {
fi
;;
clang)
# lldb is temporarily removed to alleviate Linux pre-commit CI waiting times
for p in clang-tools-extra compiler-rt cross-project-tests; do
for p in clang-tools-extra compiler-rt lldb cross-project-tests; do
echo $p
done
;;
Expand Down
3 changes: 0 additions & 3 deletions .git-blame-ignore-revs
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,3 @@ f6d557ee34b6bbdb1dc32f29e34b4a4a8ad35e81

# [NFC] clang-format utils/TableGen (#80973)
b9079baaddfed5e604fbfaa1d81a7a1c38e78c26

# [libc++][NFC] Run clang-format on libcxx/include again (#95874)
e2c2ffbe7a1b5d9e32a2ce64279475b50c4cba5b
2 changes: 1 addition & 1 deletion .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ jobs:
with:
fetch-depth: 1
- name: Setup Python env
uses: actions/setup-python@v5
uses: actions/setup-python@v4
with:
python-version: '3.11'
cache: 'pip'
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/libclang-python-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version: ["3.8", "3.11"]
python-version: ["3.7", "3.11"]
uses: ./.github/workflows/llvm-project-tests.yml
with:
build_target: check-clang-python
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/libcxx-build-and-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -209,16 +209,16 @@ jobs:
- uses: actions/checkout@v4
- name: Install dependencies
run: |
choco install -y ninja
choco install -y ninja wget
pip install psutil
- name: Install a current LLVM
if: ${{ matrix.mingw != true }}
run: |
choco install -y llvm --version=18.1.6 --allow-downgrade
choco install -y llvm --version=17.0.6
- name: Install llvm-mingw
if: ${{ matrix.mingw == true }}
run: |
curl -LO https://github.com/mstorsjo/llvm-mingw/releases/download/20240606/llvm-mingw-20240606-ucrt-x86_64.zip
curl -LO https://github.com/mstorsjo/llvm-mingw/releases/download/20231128/llvm-mingw-20231128-ucrt-x86_64.zip
powershell Expand-Archive llvm-mingw*.zip -DestinationPath .
del llvm-mingw*.zip
mv llvm-mingw* c:\llvm-mingw
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/llvm-project-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ jobs:
# lldb. Using this setup-python action to make 3.10 the default
# python fixes this.
- name: Setup Python
uses: actions/setup-python@v5
uses: actions/setup-python@v4
with:
python-version: ${{ inputs.python_version }}
- name: Install Ninja
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/pr-code-format.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,10 @@ jobs:
- name: Install clang-format
uses: aminya/setup-cpp@v1
with:
clangformat: 18.1.7
clangformat: 18.1.1

- name: Setup Python env
uses: actions/setup-python@v5
uses: actions/setup-python@v4
with:
python-version: '3.11'
cache: 'pip'
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release-documentation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ jobs:
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1

- name: Setup Python env
uses: actions/setup-python@v5
uses: actions/setup-python@v4
with:
cache: 'pip'
cache-dependency-path: './llvm/docs/requirements.txt'
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release-doxygen.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ jobs:
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1

- name: Setup Python env
uses: actions/setup-python@v5
uses: actions/setup-python@v4
with:
cache: 'pip'
cache-dependency-path: './llvm/docs/requirements.txt'
Expand Down
104 changes: 0 additions & 104 deletions .github/workflows/release-sources.yml

This file was deleted.

11 changes: 0 additions & 11 deletions .github/workflows/release-tasks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -85,14 +85,3 @@ jobs:
with:
release-version: ${{ needs.validate-tag.outputs.release-version }}
upload: true

release-sources:
name: Package Release Sources
permissions:
id-token: write
attestations: write
needs:
- validate-tag
uses: ./.github/workflows/release-sources.yml
with:
release-version: ${{ needs.validate-tag.outputs.release-version }}
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ jobs:
script: |
const failure_regex = /Process completed with exit code 1./
const preemption_regex = /The runner has received a shutdown signal/

const wf_run = context.payload.workflow_run
core.notice(`Running on "${wf_run.display_title}" by @${wf_run.actor.login} (event: ${wf_run.event})\nWorkflow run URL: ${wf_run.html_url}`)

Expand Down Expand Up @@ -80,30 +80,30 @@ jobs:
}
check_run_ids.push(check_run.id);
}

has_preempted_job = false;

for (check_run_id of check_run_ids) {
console.log('Listing annotations for check run: ' + check_run_id);

annotations = await github.rest.checks.listAnnotations({
owner: context.repo.owner,
repo: context.repo.repo,
check_run_id: check_run_id
})

for (annotation of annotations.data) {
if (annotation.annotation_level != 'failure') {
continue;
}

const preemption_match = annotation.message.match(preemption_regex);

if (preemption_match != null) {
console.log('Found preemption message: ' + annotation.message);
has_preempted_job = true;
}

const failure_match = annotation.message.match(failure_regex);
if (failure_match != null) {
// We only want to restart the workflow if all of the failures were due to preemption.
Expand All @@ -115,18 +115,20 @@ jobs:
return;
}
}
}

}
if (!has_preempted_job) {
core.notice('No preempted jobs found. Not restarting workflow.');
await create_check_run('neutral', 'No preempted jobs found. Not restarting workflow.')
return;
}

core.notice("Restarted workflow: " + context.payload.workflow_run.id);
await github.rest.actions.reRunWorkflowFailedJobs({
owner: context.repo.owner,
repo: context.repo.repo,
run_id: context.payload.workflow_run.id
})
await create_check_run('success', 'Restarted workflow run due to preempted job')


11 changes: 5 additions & 6 deletions bolt/docs/CommandLineArgumentReference.md
Original file line number Diff line number Diff line change
Expand Up @@ -630,6 +630,10 @@

Use a modified clustering algorithm geared towards minimizing branches

- `--name-similarity-function-matching-threshold=<uint>`

Match functions using namespace and edit distance.

- `--no-inline`

Disable all inlining (overrides other inlining options)
Expand Down Expand Up @@ -802,11 +806,6 @@

The maximum size of a function to consider for inference.

- `--stale-matching-min-matched-block=<uint>`

Minimum percent of exact match block for a function to be considered for
profile inference.

- `--stale-threshold=<uint>`

Maximum percentage of stale functions to tolerate (default: 100)
Expand Down Expand Up @@ -1166,4 +1165,4 @@

- `--print-options`

Print non-default options after command line parsing
Print non-default options after command line parsing
13 changes: 6 additions & 7 deletions bolt/include/bolt/Core/MCPlusBuilder.h
Original file line number Diff line number Diff line change
Expand Up @@ -1412,14 +1412,13 @@ class MCPlusBuilder {
return false;
}

/// Creates an indirect call to the function within the \p DirectCall PLT
/// stub. The function's memory location is pointed by the \p TargetLocation
/// symbol.
virtual InstructionListType
createIndirectPltCall(const MCInst &DirectCall,
const MCSymbol *TargetLocation, MCContext *Ctx) {
/// Modify a direct call instruction \p Inst with an indirect call taking
/// a destination from a memory location pointed by \p TargetLocation symbol.
virtual bool convertCallToIndirectCall(MCInst &Inst,
const MCSymbol *TargetLocation,
MCContext *Ctx) {
llvm_unreachable("not implemented");
return {};
return false;
}

/// Morph an indirect call into a load where \p Reg holds the call target.
Expand Down
3 changes: 3 additions & 0 deletions bolt/include/bolt/Profile/YAMLProfileReader.h
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,9 @@ class YAMLProfileReader : public ProfileReaderBase {
ProfiledFunctions.emplace(&BF);
}

/// Matches functions with similarly named profiled functions.
uint64_t matchWithNameSimilarity(BinaryContext &BC);

/// Check if the profile uses an event with a given \p Name.
bool usesEvent(StringRef Name) const;
};
Expand Down
11 changes: 11 additions & 0 deletions bolt/include/bolt/Rewrite/DWARFRewriter.h
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,9 @@ class DWARFRewriter {
/// blocks) to be updated.
void updateDebugAddressRanges();

/// Rewrite .gdb_index section if present.
void updateGdbIndexSection(CUOffsetMap &CUMap, uint32_t NumCUs);

/// DWARFDie contains a pointer to a DIE and hence gets invalidated once the
/// embedded DIE is destroyed. This wrapper class stores a DIE internally and
/// could be cast to a DWARFDie that is valid even after the initial DIE is
Expand Down Expand Up @@ -191,6 +194,14 @@ class DWARFRewriter {
DwoRangesBase[DWOId] = RangesBase;
}

/// Adds an GDBIndexTUEntry if .gdb_index seciton exists.
void addGDBTypeUnitEntry(const GDBIndexTUEntry &&Entry);

/// Returns all entries needed for Types CU list
const GDBIndexTUEntryType &getGDBIndexTUEntryVector() const {
return GDBIndexTUEntryVector;
}

using OverriddenSectionsMap = std::unordered_map<DWARFSectionKind, StringRef>;
/// Output .dwo files.
void writeDWOFiles(DWARFUnit &, const OverriddenSectionsMap &,
Expand Down
1 change: 1 addition & 0 deletions bolt/lib/Core/BinaryEmitter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -487,6 +487,7 @@ void BinaryEmitter::emitFunctionBody(BinaryFunction &BF, FunctionFragment &FF,
// This assumes the second instruction in the macro-op pair will get
// assigned to its own MCRelaxableFragment. Since all JCC instructions
// are relaxable, we should be safe.
Streamer.emitNeverAlignCodeAtEnd(/*Alignment to avoid=*/64, *BC.STI);
}

if (!EmitCodeOnly) {
Expand Down
4 changes: 1 addition & 3 deletions bolt/lib/Passes/BinaryPasses.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -636,9 +636,7 @@ Error LowerAnnotations::runOnFunctions(BinaryContext &BC) {
Error CleanMCState::runOnFunctions(BinaryContext &BC) {
MCContext &Ctx = *BC.Ctx;
for (const auto &SymMapEntry : Ctx.getSymbols()) {
const MCSymbol *S = SymMapEntry.getValue().Symbol;
if (!S)
continue;
const MCSymbol *S = SymMapEntry.second;
if (S->isDefined()) {
LLVM_DEBUG(dbgs() << "BOLT-DEBUG: Symbol \"" << S->getName()
<< "\" is already defined\n");
Expand Down
Loading