Skip to content

Commit 0be6939

Browse files
committed
Merge remote-tracking branch 'origin/main' into vplan-introduce-region-as-transform
2 parents 4a3ec74 + 37374fb commit 0be6939

File tree

1,755 files changed

+135461
-26866
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

1,755 files changed

+135461
-26866
lines changed

.ci/metrics/metrics.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import os
44
from dataclasses import dataclass
55
import sys
6+
import logging
67

78
import github
89
from github import Github
@@ -192,6 +193,10 @@ def get_per_workflow_metrics(
192193
# in nanoseconds.
193194
created_at_ns = int(created_at.timestamp()) * 10**9
194195

196+
logging.info(
197+
f"Adding a job metric for job {workflow_job.id} in workflow {workflow_run.id}"
198+
)
199+
195200
workflow_metrics.append(
196201
JobMetrics(
197202
workflow_run.name + "-" + workflow_job.name,
@@ -220,7 +225,7 @@ def upload_metrics(workflow_metrics, metrics_userid, api_key):
220225
"""
221226

222227
if len(workflow_metrics) == 0:
223-
print("No metrics found to upload.", file=sys.stderr)
228+
logging.info("No metrics found to upload.")
224229
return
225230

226231
metrics_batch = []
@@ -249,9 +254,7 @@ def upload_metrics(workflow_metrics, metrics_userid, api_key):
249254
)
250255

251256
if response.status_code < 200 or response.status_code >= 300:
252-
print(
253-
f"Failed to submit data to Grafana: {response.status_code}", file=sys.stderr
254-
)
257+
logging.info(f"Failed to submit data to Grafana: {response.status_code}")
255258

256259

257260
def main():
@@ -275,7 +278,7 @@ def main():
275278
current_metrics += get_sampled_workflow_metrics(github_repo)
276279

277280
upload_metrics(current_metrics, grafana_metrics_userid, grafana_api_key)
278-
print(f"Uploaded {len(current_metrics)} metrics", file=sys.stderr)
281+
logging.info(f"Uploaded {len(current_metrics)} metrics")
279282

280283
for workflow_metric in reversed(current_metrics):
281284
if isinstance(workflow_metric, JobMetrics):
@@ -287,4 +290,5 @@ def main():
287290

288291

289292
if __name__ == "__main__":
293+
logging.basicConfig(level=logging.INFO)
290294
main()

.github/workflows/libcxx-build-and-test.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -255,11 +255,11 @@ jobs:
255255
- name: Install a current LLVM
256256
if: ${{ matrix.mingw != true }}
257257
run: |
258-
choco install -y llvm --version=18.1.6 --allow-downgrade
258+
choco install -y llvm --version=19.1.7 --allow-downgrade
259259
- name: Install llvm-mingw
260260
if: ${{ matrix.mingw == true }}
261261
run: |
262-
curl -LO https://github.com/mstorsjo/llvm-mingw/releases/download/20240606/llvm-mingw-20240606-ucrt-x86_64.zip
262+
curl -LO https://github.com/mstorsjo/llvm-mingw/releases/download/20250114/llvm-mingw-20250114-ucrt-x86_64.zip
263263
powershell Expand-Archive llvm-mingw*.zip -DestinationPath .
264264
del llvm-mingw*.zip
265265
mv llvm-mingw* c:\llvm-mingw

bolt/include/bolt/Passes/ContinuityStats.h

Lines changed: 0 additions & 61 deletions
This file was deleted.
Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
//===- bolt/Passes/ProfileQualityStats.h ------------------------*- C++ -*-===//
2+
//
3+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4+
// See https://llvm.org/LICENSE.txt for license information.
5+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6+
//
7+
//===----------------------------------------------------------------------===//
8+
//
9+
// This pass checks the BOLT input profile quality.
10+
//
11+
// Check 1: how well the input profile satisfies the following
12+
// "CFG continuity" property of a perfect profile:
13+
//
14+
// Each positive-execution-count block in the function’s CFG
15+
// is *reachable* from a positive-execution-count function
16+
// entry block through a positive-execution-count path.
17+
//
18+
// More specifically, for each of the hottest 1000 functions, the pass
19+
// calculates the function’s fraction of basic block execution counts
20+
// that is *unreachable*. It then reports the 95th percentile of the
21+
// distribution of the 1000 unreachable fractions in a single BOLT-INFO line.
22+
// The smaller the reported value is, the better the BOLT profile
23+
// satisfies the CFG continuity property.
24+
//
25+
// Check 2: how well the input profile satisfies the "call graph flow
26+
// conservation" property of a perfect profile:
27+
//
28+
// For each function that is not a program entry, the number of times the
29+
// function is called is equal to the net CFG outflow of the
30+
// function's entry block(s).
31+
//
32+
// More specifically, for each of the hottest 1000 functions, the pass obtains
33+
// A = number of times the function is called, B = the function's entry blocks'
34+
// inflow, C = the function's entry blocks' outflow, where B and C are computed
35+
// using the function's weighted CFG. It then computes gap = 1 - MIN(A,C-B) /
36+
// MAX(A, C-B). The pass reports the 95th percentile of the distribution of the
37+
// 1000 gaps in a single BOLT-INFO line. The smaller the reported value is, the
38+
// better the BOLT profile satisfies the call graph flow conservation property.
39+
//
40+
// Check 3: how well the input profile satisfies the "function CFG flow
41+
// conservation property" of a perfect profile:
42+
//
43+
// A non-entry non-exit basic block's inflow is equal to its outflow.
44+
//
45+
// More specifically, for each of the hottest 1000 functions, the pass loops
46+
// over its basic blocks that are non-entry and non-exit, and for each block
47+
// obtains a block gap = 1 - MIN(block inflow, block outflow, block call count
48+
// if any) / MAX(block inflow, block outflow, block call count if any). It then
49+
// aggregates the block gaps into 2 values for the function: "weighted" is the
50+
// weighted average of the block conservation gaps, where the weights depend on
51+
// each block's execution count and instruction count; "worst" is the worst
52+
// (biggest) block gap acorss all basic blocks in the function with an execution
53+
// count of > 500. The pass then reports the 95th percentile of the weighted and
54+
// worst values of the 1000 functions in a single BOLT-INFO line. The smaller
55+
// the reported values are, the better the BOLT profile satisfies the function
56+
// CFG flow conservation property.
57+
//
58+
// The default value of 1000 above can be changed via the hidden BOLT option
59+
// `-top-functions-for-profile-quality-check=[N]`.
60+
// The default reporting of the 95th percentile can be changed via the hidden
61+
// BOLT option `-percentile-for-profile-quality-check=[M]`.
62+
//
63+
// If more detailed stats are needed, `-v=1` can be used: the hottest N
64+
// functions will be grouped into 5 equally-sized buckets, from the hottest
65+
// to the coldest; for each bucket, various summary statistics of the
66+
// profile quality will be reported.
67+
//
68+
//===----------------------------------------------------------------------===//
69+
70+
#ifndef BOLT_PASSES_PROFILEQUALITYSTATS_H
71+
#define BOLT_PASSES_PROFILEQUALITYSTATS_H
72+
73+
#include "bolt/Passes/BinaryPasses.h"
74+
#include <vector>
75+
76+
namespace llvm {
77+
78+
class raw_ostream;
79+
80+
namespace bolt {
81+
class BinaryContext;
82+
83+
/// Compute and report to the user the profile quality
84+
class PrintProfileQualityStats : public BinaryFunctionPass {
85+
public:
86+
explicit PrintProfileQualityStats(const cl::opt<bool> &PrintPass)
87+
: BinaryFunctionPass(PrintPass) {}
88+
89+
bool shouldOptimize(const BinaryFunction &BF) const override;
90+
const char *getName() const override { return "profile-quality-stats"; }
91+
bool shouldPrint(const BinaryFunction &) const override { return false; }
92+
Error runOnFunctions(BinaryContext &BC) override;
93+
};
94+
95+
} // namespace bolt
96+
} // namespace llvm
97+
98+
#endif // BOLT_PASSES_PROFILEQUALITYSTATS_H

bolt/include/bolt/Rewrite/RewriteInstance.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -505,6 +505,9 @@ class RewriteInstance {
505505
/// Number of local symbols in newly written symbol table.
506506
uint64_t NumLocalSymbols{0};
507507

508+
/// Flag indicating runtime library linking just started.
509+
bool StartLinkingRuntimeLib{false};
510+
508511
/// Information on special Procedure Linkage Table sections. There are
509512
/// multiple variants generated by different linkers.
510513
struct PLTSectionInfo {

bolt/lib/Core/BinaryFunction.cpp

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1544,15 +1544,11 @@ MCSymbol *BinaryFunction::registerBranch(uint64_t Src, uint64_t Dst) {
15441544
}
15451545

15461546
void BinaryFunction::analyzeInstructionForFuncReference(const MCInst &Inst) {
1547-
for (const MCOperand &Op : MCPlus::primeOperands(Inst)) {
1548-
if (!Op.isExpr())
1547+
for (unsigned OpNum = 0; OpNum < MCPlus::getNumPrimeOperands(Inst); ++OpNum) {
1548+
const MCSymbol *Symbol = BC.MIB->getTargetSymbol(Inst, OpNum);
1549+
if (!Symbol)
15491550
continue;
1550-
const MCExpr &Expr = *Op.getExpr();
1551-
if (Expr.getKind() != MCExpr::SymbolRef)
1552-
continue;
1553-
const MCSymbol &Symbol = cast<MCSymbolRefExpr>(Expr).getSymbol();
1554-
// Set HasAddressTaken for a function regardless of the ICF level.
1555-
if (BinaryFunction *BF = BC.getFunctionForSymbol(&Symbol))
1551+
if (BinaryFunction *BF = BC.getFunctionForSymbol(Symbol))
15561552
BF->setHasAddressTaken(true);
15571553
}
15581554
}

bolt/lib/Passes/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ add_llvm_library(LLVMBOLTPasses
2727
PatchEntries.cpp
2828
PettisAndHansen.cpp
2929
PLTCall.cpp
30-
ContinuityStats.cpp
30+
ProfileQualityStats.cpp
3131
RegAnalysis.cpp
3232
RegReAssign.cpp
3333
ReorderAlgorithm.cpp

0 commit comments

Comments
 (0)