Skip to content

Commit 79978fa

Browse files
committed
Merge remote-tracking branch 'origin/sycl-web' into llvmspirv_pulldown
2 parents 7a7619d + 4fe5a3c commit 79978fa

File tree

2,750 files changed

+97154
-37529
lines changed

Some content is hidden

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

2,750 files changed

+97154
-37529
lines changed

.github/workflows/issue-write.yml

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ on:
55
workflows:
66
- "Check code formatting"
77
- "Check for private emails used in PRs"
8+
- "PR Request Release Note"
89
types:
910
- completed
1011

@@ -17,7 +18,11 @@ jobs:
1718
permissions:
1819
pull-requests: write
1920
if: >
20-
github.event.workflow_run.event == 'pull_request'
21+
github.event.workflow_run.event == 'pull_request' &&
22+
(
23+
github.event.workflow_run.conclusion == 'success' ||
24+
github.event.workflow_run.conclusion == 'failure'
25+
)
2126
steps:
2227
- name: 'Download artifact'
2328
uses: actions/download-artifact@6b208ae046db98c579e8a3aa621ab581ff575935 # v4.1.1
@@ -92,7 +97,11 @@ jobs:
9297
9398
var pr_number = 0;
9499
gql_result.repository.ref.associatedPullRequests.nodes.forEach((pr) => {
95-
if (pr.baseRepository.owner.login = context.repo.owner && pr.state == 'OPEN') {
100+
101+
// The largest PR number is the one we care about. The only way
102+
// to have more than one associated pull requests is if all the
103+
// old pull requests are in the closed state.
104+
if (pr.baseRepository.owner.login = context.repo.owner && pr.number > pr_number) {
96105
pr_number = pr.number;
97106
}
98107
});

.github/workflows/pr-request-release-note.yml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ name: PR Request Release Note
22

33
permissions:
44
contents: read
5-
pull-requests: write
65

76
on:
87
pull_request:
@@ -41,3 +40,10 @@ jobs:
4140
--token "$GITHUB_TOKEN" \
4241
request-release-note \
4342
--pr-number ${{ github.event.pull_request.number}}
43+
44+
- uses: actions/upload-artifact@26f96dfa697d77e81fd5907df203aa23a56210a8 #v4.3.0
45+
if: always()
46+
with:
47+
name: workflow-args
48+
path: |
49+
comments

bolt/docs/CommandLineArgumentReference.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -259,6 +259,10 @@
259259

260260
Always use long jumps/nops for Linux kernel static keys
261261

262+
- `--match-profile-with-function-hash`
263+
264+
Match profile with function hash
265+
262266
- `--max-data-relocations=<uint>`
263267

264268
Maximum number of data relocations to process

bolt/include/bolt/Core/BinaryFunction.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -930,6 +930,10 @@ class BinaryFunction {
930930
return const_cast<BinaryFunction *>(this)->getInstructionAtOffset(Offset);
931931
}
932932

933+
/// When the function is in disassembled state, return an instruction that
934+
/// contains the \p Offset.
935+
MCInst *getInstructionContainingOffset(uint64_t Offset);
936+
933937
std::optional<MCInst> disassembleInstructionAtOffset(uint64_t Offset) const;
934938

935939
/// Return offset for the first instruction. If there is data at the

bolt/include/bolt/Passes/BinaryFunctionCallGraph.h renamed to bolt/include/bolt/Core/BinaryFunctionCallGraph.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//===- bolt/Passes/CallGraph.h ----------------------------------*- C++ -*-===//
1+
//===- bolt/Core/CallGraph.h ----------------------------------*- C++ -*-===//
22
//
33
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
44
// See https://llvm.org/LICENSE.txt for license information.
@@ -9,7 +9,7 @@
99
#ifndef BOLT_PASSES_BINARY_FUNCTION_CALLGRAPH_H
1010
#define BOLT_PASSES_BINARY_FUNCTION_CALLGRAPH_H
1111

12-
#include "bolt/Passes/CallGraph.h"
12+
#include "bolt/Core/CallGraph.h"
1313
#include <deque>
1414
#include <functional>
1515
#include <unordered_map>

bolt/include/bolt/Passes/CallGraph.h renamed to bolt/include/bolt/Core/CallGraph.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//===- bolt/Passes/CallGraph.h ----------------------------------*- C++ -*-===//
1+
//===- bolt/Core/CallGraph.h ----------------------------------*- C++ -*-===//
22
//
33
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
44
// See https://llvm.org/LICENSE.txt for license information.

bolt/include/bolt/Passes/CallGraphWalker.h renamed to bolt/include/bolt/Core/CallGraphWalker.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//===- bolt/Passes/CallGraphWalker.h ----------------------------*- C++ -*-===//
1+
//===- bolt/Core/CallGraphWalker.h ----------------------------*- C++ -*-===//
22
//
33
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
44
// See https://llvm.org/LICENSE.txt for license information.

bolt/include/bolt/Core/MCPlusBuilder.h

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -439,7 +439,20 @@ class MCPlusBuilder {
439439
}
440440

441441
/// Check whether this conditional branch can be reversed
442-
virtual bool isReversibleBranch(const MCInst &Inst) const { return true; }
442+
virtual bool isReversibleBranch(const MCInst &Inst) const {
443+
assert(!isUnsupportedInstruction(Inst) && isConditionalBranch(Inst) &&
444+
"Instruction is not known conditional branch");
445+
446+
if (isDynamicBranch(Inst))
447+
return false;
448+
return true;
449+
}
450+
451+
/// Return true if this instruction inhibits analysis of the containing
452+
/// function.
453+
virtual bool isUnsupportedInstruction(const MCInst &Inst) const {
454+
return false;
455+
}
443456

444457
/// Return true of the instruction is of pseudo kind.
445458
virtual bool isPseudo(const MCInst &Inst) const {

bolt/include/bolt/Passes/HFSort.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
#ifndef BOLT_PASSES_HFSORT_H
2020
#define BOLT_PASSES_HFSORT_H
2121

22-
#include "bolt/Passes/CallGraph.h"
22+
#include "bolt/Core/CallGraph.h"
2323

2424
#include <string>
2525
#include <vector>

bolt/include/bolt/Passes/RegReAssign.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
#ifndef BOLT_PASSES_REGREASSIGN_H
1010
#define BOLT_PASSES_REGREASSIGN_H
1111

12-
#include "bolt/Passes/BinaryFunctionCallGraph.h"
12+
#include "bolt/Core/BinaryFunctionCallGraph.h"
1313
#include "bolt/Passes/BinaryPasses.h"
1414
#include "bolt/Passes/RegAnalysis.h"
1515

bolt/include/bolt/Passes/ReorderFunctions.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
#ifndef BOLT_PASSES_REORDER_FUNCTIONS_H
1010
#define BOLT_PASSES_REORDER_FUNCTIONS_H
1111

12-
#include "bolt/Passes/BinaryFunctionCallGraph.h"
12+
#include "bolt/Core/BinaryFunctionCallGraph.h"
1313
#include "bolt/Passes/BinaryPasses.h"
1414

1515
namespace llvm {

bolt/include/bolt/Rewrite/DWARFRewriter.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
#include "llvm/ADT/StringRef.h"
1717
#include "llvm/CodeGen/DIE.h"
1818
#include "llvm/DWP/DWP.h"
19-
#include "llvm/MC/MCAsmLayout.h"
2019
#include "llvm/MC/MCContext.h"
2120
#include "llvm/Support/ToolOutputFile.h"
2221
#include <cstdint>
@@ -183,7 +182,7 @@ class DWARFRewriter {
183182
void updateDebugInfo();
184183

185184
/// Update stmt_list for CUs based on the new .debug_line \p Layout.
186-
void updateLineTableOffsets(const MCAsmLayout &Layout);
185+
void updateLineTableOffsets(const MCAssembler &Asm);
187186

188187
uint64_t getDwoRangesBase(uint64_t DWOId) { return DwoRangesBase[DWOId]; }
189188

bolt/lib/Core/BinaryContext.cpp

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
#include "llvm/DebugInfo/DWARF/DWARFCompileUnit.h"
2121
#include "llvm/DebugInfo/DWARF/DWARFFormValue.h"
2222
#include "llvm/DebugInfo/DWARF/DWARFUnit.h"
23-
#include "llvm/MC/MCAsmLayout.h"
2423
#include "llvm/MC/MCAssembler.h"
2524
#include "llvm/MC/MCContext.h"
2625
#include "llvm/MC/MCDisassembler/MCDisassembler.h"
@@ -2416,20 +2415,19 @@ BinaryContext::calculateEmittedSize(BinaryFunction &BF, bool FixBranches) {
24162415

24172416
MCAssembler &Assembler =
24182417
static_cast<MCObjectStreamer *>(Streamer.get())->getAssembler();
2419-
MCAsmLayout Layout(Assembler);
2420-
Assembler.layout(Layout);
2418+
Assembler.layout();
24212419

24222420
// Obtain fragment sizes.
24232421
std::vector<uint64_t> FragmentSizes;
24242422
// Main fragment size.
2425-
const uint64_t HotSize =
2426-
Layout.getSymbolOffset(*EndLabel) - Layout.getSymbolOffset(*StartLabel);
2423+
const uint64_t HotSize = Assembler.getSymbolOffset(*EndLabel) -
2424+
Assembler.getSymbolOffset(*StartLabel);
24272425
FragmentSizes.push_back(HotSize);
24282426
// Split fragment sizes.
24292427
uint64_t ColdSize = 0;
24302428
for (const auto &Labels : SplitLabels) {
2431-
uint64_t Size = Layout.getSymbolOffset(*Labels.second) -
2432-
Layout.getSymbolOffset(*Labels.first);
2429+
uint64_t Size = Assembler.getSymbolOffset(*Labels.second) -
2430+
Assembler.getSymbolOffset(*Labels.first);
24332431
FragmentSizes.push_back(Size);
24342432
ColdSize += Size;
24352433
}
@@ -2439,7 +2437,8 @@ BinaryContext::calculateEmittedSize(BinaryFunction &BF, bool FixBranches) {
24392437
for (FunctionFragment &FF : BF.getLayout().fragments()) {
24402438
BinaryBasicBlock *PrevBB = nullptr;
24412439
for (BinaryBasicBlock *BB : FF) {
2442-
const uint64_t BBStartOffset = Layout.getSymbolOffset(*(BB->getLabel()));
2440+
const uint64_t BBStartOffset =
2441+
Assembler.getSymbolOffset(*(BB->getLabel()));
24432442
BB->setOutputStartAddress(BBStartOffset);
24442443
if (PrevBB)
24452444
PrevBB->setOutputEndAddress(BBStartOffset);

bolt/lib/Core/BinaryFunction.cpp

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -543,7 +543,7 @@ void BinaryFunction::print(raw_ostream &OS, std::string Annotation) {
543543
else
544544
OS << "<unknown>\n";
545545
}
546-
if (BB->getCFIState() >= 0)
546+
if (hasCFI())
547547
OS << " CFI State : " << BB->getCFIState() << '\n';
548548
if (opts::EnableBAT) {
549549
OS << " Input offset: 0x" << Twine::utohexstr(BB->getInputOffset())
@@ -611,7 +611,7 @@ void BinaryFunction::print(raw_ostream &OS, std::string Annotation) {
611611
}
612612

613613
// In CFG_Finalized state we can miscalculate CFI state at exit.
614-
if (CurrentState == State::CFG) {
614+
if (CurrentState == State::CFG && hasCFI()) {
615615
const int32_t CFIStateAtExit = BB->getCFIStateAtExit();
616616
if (CFIStateAtExit >= 0)
617617
OS << " CFI State: " << CFIStateAtExit << '\n';
@@ -1276,6 +1276,10 @@ Error BinaryFunction::disassemble() {
12761276
}
12771277
}
12781278

1279+
bool IsUnsupported = BC.MIB->isUnsupportedInstruction(Instruction);
1280+
if (IsUnsupported)
1281+
setIgnored();
1282+
12791283
if (MIB->isBranch(Instruction) || MIB->isCall(Instruction)) {
12801284
uint64_t TargetAddress = 0;
12811285
if (MIB->evaluateBranch(Instruction, AbsoluteInstrAddr, Size,
@@ -1289,12 +1293,10 @@ Error BinaryFunction::disassemble() {
12891293
const bool IsCondBranch = MIB->isConditionalBranch(Instruction);
12901294
MCSymbol *TargetSymbol = nullptr;
12911295

1292-
if (!BC.MIB->isReversibleBranch(Instruction)) {
1293-
setIgnored();
1294-
if (BinaryFunction *TargetFunc =
1296+
if (IsUnsupported)
1297+
if (auto *TargetFunc =
12951298
BC.getBinaryFunctionContainingAddress(TargetAddress))
12961299
TargetFunc->setIgnored();
1297-
}
12981300

12991301
if (IsCall && containsAddress(TargetAddress)) {
13001302
if (TargetAddress == getAddress()) {
@@ -4472,6 +4474,18 @@ MCInst *BinaryFunction::getInstructionAtOffset(uint64_t Offset) {
44724474
}
44734475
}
44744476

4477+
MCInst *BinaryFunction::getInstructionContainingOffset(uint64_t Offset) {
4478+
assert(CurrentState == State::Disassembled && "Wrong function state");
4479+
4480+
if (Offset > Size)
4481+
return nullptr;
4482+
4483+
auto II = Instructions.upper_bound(Offset);
4484+
assert(II != Instructions.begin() && "First instruction not at offset 0");
4485+
--II;
4486+
return &II->second;
4487+
}
4488+
44754489
void BinaryFunction::printLoopInfo(raw_ostream &OS) const {
44764490
if (!opts::shouldPrint(*this))
44774491
return;

bolt/lib/Passes/BinaryFunctionCallGraph.cpp renamed to bolt/lib/Core/BinaryFunctionCallGraph.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//===- bolt/Passes/BinaryFunctionCallGraph.cpp ----------------------------===//
1+
//===- bolt/Core/BinaryFunctionCallGraph.cpp ----------------------------===//
22
//
33
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
44
// See https://llvm.org/LICENSE.txt for license information.
@@ -10,7 +10,7 @@
1010
//
1111
//===----------------------------------------------------------------------===//
1212

13-
#include "bolt/Passes/BinaryFunctionCallGraph.h"
13+
#include "bolt/Core/BinaryFunctionCallGraph.h"
1414
#include "bolt/Core/BinaryContext.h"
1515
#include "bolt/Core/BinaryFunction.h"
1616
#include "llvm/Support/CommandLine.h"

bolt/lib/Core/CMakeLists.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,11 @@ add_llvm_library(LLVMBOLTCore
1717
BinaryData.cpp
1818
BinaryEmitter.cpp
1919
BinaryFunction.cpp
20+
BinaryFunctionCallGraph.cpp
2021
BinaryFunctionProfile.cpp
2122
BinarySection.cpp
23+
CallGraph.cpp
24+
CallGraphWalker.cpp
2225
DebugData.cpp
2326
DebugNames.cpp
2427
DIEBuilder.cpp

bolt/lib/Passes/CallGraph.cpp renamed to bolt/lib/Core/CallGraph.cpp

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//===- bolt/Passes/CallGraph.cpp ------------------------------------------===//
1+
//===- bolt/Core/CallGraph.cpp ------------------------------------------===//
22
//
33
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
44
// See https://llvm.org/LICENSE.txt for license information.
@@ -10,16 +10,16 @@
1010
//
1111
//===----------------------------------------------------------------------===//
1212

13-
#include "bolt/Passes/CallGraph.h"
13+
#include "bolt/Core/CallGraph.h"
1414

1515
#define DEBUG_TYPE "callgraph"
1616

1717
#if defined(__x86_64__) && !defined(_MSC_VER)
18-
# if (!defined USE_SSECRC)
19-
# define USE_SSECRC
20-
# endif
18+
#if (!defined USE_SSECRC)
19+
#define USE_SSECRC
20+
#endif
2121
#else
22-
# undef USE_SSECRC
22+
#undef USE_SSECRC
2323
#endif
2424

2525
static LLVM_ATTRIBUTE_UNUSED inline size_t hash_int64_fallback(int64_t k) {
@@ -50,7 +50,7 @@ static inline size_t hash_int64_pair(int64_t k1, int64_t k2) {
5050
// crc32 is commutative, so we need to perturb k1 so that (k1, k2) hashes
5151
// differently from (k2, k1).
5252
k1 += k1;
53-
__asm("crc32q %1, %0\n" : "+r" (k1) : "rm"(k2));
53+
__asm("crc32q %1, %0\n" : "+r"(k1) : "rm"(k2));
5454
return k1;
5555
#else
5656
return (hash_int64(k1) << 1) ^ hash_int64(k2);
@@ -118,5 +118,5 @@ void CallGraph::adjustArcWeights() {
118118
}
119119
}
120120

121-
}
122-
}
121+
} // namespace bolt
122+
} // namespace llvm

bolt/lib/Passes/CallGraphWalker.cpp renamed to bolt/lib/Core/CallGraphWalker.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//===- bolt/Passes/CallGraphWalker.cpp ------------------------------------===//
1+
//===- bolt/Core/CallGraphWalker.cpp ------------------------------------===//
22
//
33
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
44
// See https://llvm.org/LICENSE.txt for license information.
@@ -10,8 +10,8 @@
1010
//
1111
//===----------------------------------------------------------------------===//
1212

13-
#include "bolt/Passes/CallGraphWalker.h"
14-
#include "bolt/Passes/BinaryFunctionCallGraph.h"
13+
#include "bolt/Core/CallGraphWalker.h"
14+
#include "bolt/Core/BinaryFunctionCallGraph.h"
1515
#include "llvm/Support/CommandLine.h"
1616
#include "llvm/Support/Timer.h"
1717
#include <queue>

bolt/lib/Passes/CMakeLists.txt

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,8 @@ add_llvm_library(LLVMBOLTPasses
44
AllocCombiner.cpp
55
AsmDump.cpp
66
BinaryPasses.cpp
7-
BinaryFunctionCallGraph.cpp
87
CMOVConversion.cpp
98
CacheMetrics.cpp
10-
CallGraph.cpp
11-
CallGraphWalker.cpp
129
DataflowAnalysis.cpp
1310
DataflowInfoManager.cpp
1411
FrameAnalysis.cpp

bolt/lib/Passes/FrameAnalysis.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
1111
//===----------------------------------------------------------------------===//
1212

1313
#include "bolt/Passes/FrameAnalysis.h"
14+
#include "bolt/Core/CallGraphWalker.h"
1415
#include "bolt/Core/ParallelUtilities.h"
15-
#include "bolt/Passes/CallGraphWalker.h"
1616
#include "llvm/MC/MCRegisterInfo.h"
1717
#include "llvm/Support/Timer.h"
1818
#include <fstream>

bolt/lib/Passes/FrameOptimizer.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
1111
//===----------------------------------------------------------------------===//
1212

1313
#include "bolt/Passes/FrameOptimizer.h"
14+
#include "bolt/Core/BinaryFunctionCallGraph.h"
1415
#include "bolt/Core/ParallelUtilities.h"
15-
#include "bolt/Passes/BinaryFunctionCallGraph.h"
1616
#include "bolt/Passes/DataflowInfoManager.h"
1717
#include "bolt/Passes/ShrinkWrapping.h"
1818
#include "bolt/Passes/StackAvailableExpressions.h"

0 commit comments

Comments
 (0)