Skip to content

Commit 9460104

Browse files
SC llvm teamSC llvm team
authored andcommitted
Merged main:7b97d5048a8f into amd-gfx:3ab181f6d3ad
Local branch amd-gfx 3ab181f Merge amd-gfx into merge-candidate branch Remote branch main 7b97d50 Fix MSVC "not all control paths return a value" warning. NFC.
2 parents 3ab181f + 7b97d50 commit 9460104

File tree

1,136 files changed

+61132
-30574
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,136 files changed

+61132
-30574
lines changed

.github/CODEOWNERS

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,10 @@
4242
/mlir/lib/Dialect/Vector/Transforms/VectorEmulateNarrowType.cpp @MaheshRavishankar
4343
/mlir/lib/Interfaces/TilingInterface.* @MaheshRavishankar
4444

45+
# Transform Dialect in MLIR.
46+
/mlir/include/mlir/Dialect/Transform/* @ftynse
47+
/mlir/lib/Dialect/Transform/* @ftynse
48+
4549
# SPIR-V in MLIR.
4650
/mlir/**/SPIRV/ @antiagainst @kuhar
4751
/mlir/**/SPIRVTo*/ @antiagainst @kuhar

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ env:
4444
jobs:
4545
stage1:
4646
runs-on:
47-
group: libcxx-runners-16
47+
group: libcxx-runners-8
4848
continue-on-error: false
4949
strategy:
5050
fail-fast: true
@@ -163,10 +163,10 @@ jobs:
163163
machine: libcxx-runners-8
164164
std_modules: 'ON'
165165
- config: 'generic-asan'
166-
machine: libcxx-runners-16
166+
machine: libcxx-runners-8
167167
std_modules: 'OFF'
168168
- config: 'generic-tsan'
169-
machine: libcxx-runners-16
169+
machine: libcxx-runners-8
170170
std_modules: 'OFF'
171171
- config: 'generic-ubsan'
172172
machine: libcxx-runners-8

.github/workflows/release-binaries.yml

Lines changed: 46 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,17 +57,52 @@ jobs:
5757
fi
5858
bash .github/workflows/set-release-binary-outputs.sh "${{ github.actor }}" "$tag" "$upload"
5959
60+
# Try to get around the 6 hour timeout by first running a job to fill
61+
# the build cache.
62+
fill-cache:
63+
name: "Fill Cache ${{ matrix.os }}"
64+
needs: prepare
65+
runs-on: ${{ matrix.os }}
66+
strategy:
67+
matrix:
68+
os:
69+
- ubuntu-22.04
70+
steps:
71+
- name: Checkout LLVM
72+
uses: actions/checkout@v4
73+
with:
74+
ref: ${{ inputs.tag || github.ref_name }}
75+
76+
- name: Install Ninja
77+
uses: llvm/actions/install-ninja@main
78+
79+
- name: Setup sccache
80+
uses: hendrikmuhs/ccache-action@v1
81+
with:
82+
max-size: 250M
83+
key: sccache-${{ matrix.os }}-release
84+
variant: sccache
85+
86+
- name: Build Clang
87+
run: |
88+
cmake -G Ninja -DCMAKE_C_COMPILER_LAUNCHER=sccache -DCMAKE_CXX_COMPILER_LAUNCHER=sccache -DCMAKE_BUILD_TYPE=Release -DCMAKE_ENABLE_ASSERTIONS=OFF -DCMAKE_POSITION_INDEPENDENT_CODE=ON -DLLVM_ENABLE_PROJECTS=clang -S llvm -B build
89+
ninja -v -C build
90+
91+
6092
build-binaries:
6193
name: ${{ matrix.target.triple }}
6294
permissions:
6395
contents: write # To upload assets to release.
64-
needs: prepare
96+
needs:
97+
- prepare
98+
- fill-cache
6599
runs-on: ${{ matrix.target.runs-on }}
66100
strategy:
67101
fail-fast: false
68102
matrix:
69103
target:
70104
- triple: x86_64-linux-gnu-ubuntu-22.04
105+
os: ubuntu-22.04
71106
runs-on: ubuntu-22.04-16x64
72107
debian-build-deps: >
73108
chrpath
@@ -81,6 +116,14 @@ jobs:
81116
ref: ${{ needs.prepare.outputs.ref }}
82117
path: ${{ needs.prepare.outputs.build-dir }}/llvm-project
83118

119+
- name: Setup sccache
120+
uses: hendrikmuhs/ccache-action@v1
121+
with:
122+
max-size: 250M
123+
key: sccache-${{ matrix.target.os }}-release
124+
save: false
125+
variant: sccache
126+
84127
- name: Install Brew build dependencies
85128
if: matrix.target.brew-build-deps != ''
86129
run: brew install ${{ matrix.target.brew-build-deps }}
@@ -102,7 +145,8 @@ jobs:
102145
-triple ${{ matrix.target.triple }} \
103146
-use-ninja \
104147
-no-checkout \
105-
-no-test-suite
148+
-no-test-suite \
149+
-configure-flags "-DCMAKE_C_COMPILER_LAUNCHER=sccache -DCMAKE_CXX_COMPILER_LAUNCHER=sccache"
106150
107151
- name: Upload binaries
108152
if: ${{ always() && needs.prepare.outputs.upload == 'true' }}

bolt/include/bolt/Core/BinaryContext.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1290,6 +1290,9 @@ class BinaryContext {
12901290
/// Return true if the function should be emitted to the output file.
12911291
bool shouldEmit(const BinaryFunction &Function) const;
12921292

1293+
/// Dump the assembly representation of MCInst to debug output.
1294+
void dump(const MCInst &Inst) const;
1295+
12931296
/// Print the string name for a CFI operation.
12941297
static void printCFI(raw_ostream &OS, const MCCFIInstruction &Inst);
12951298

bolt/lib/Core/BinaryContext.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1738,6 +1738,15 @@ bool BinaryContext::shouldEmit(const BinaryFunction &Function) const {
17381738
return HasRelocations || Function.isSimple();
17391739
}
17401740

1741+
void BinaryContext::dump(const MCInst &Inst) const {
1742+
if (LLVM_UNLIKELY(!InstPrinter)) {
1743+
dbgs() << "Cannot dump for InstPrinter is not initialized.\n";
1744+
return;
1745+
}
1746+
InstPrinter->printInst(&Inst, 0, "", *STI, dbgs());
1747+
dbgs() << "\n";
1748+
}
1749+
17411750
void BinaryContext::printCFI(raw_ostream &OS, const MCCFIInstruction &Inst) {
17421751
uint32_t Operation = Inst.getOperation();
17431752
switch (Operation) {

bolt/lib/Core/Exceptions.cpp

Lines changed: 33 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -112,13 +112,18 @@ void BinaryFunction::parseLSDA(ArrayRef<uint8_t> LSDASectionData,
112112
uint64_t Offset = getLSDAAddress() - LSDASectionAddress;
113113
assert(Data.isValidOffset(Offset) && "wrong LSDA address");
114114

115-
uint8_t LPStartEncoding = Data.getU8(&Offset);
116-
uint64_t LPStart = 0;
117-
// Convert to offset if LPStartEncoding is typed absptr DW_EH_PE_absptr
118-
if (std::optional<uint64_t> MaybeLPStart = Data.getEncodedPointer(
119-
&Offset, LPStartEncoding, Offset + LSDASectionAddress))
120-
LPStart = (LPStartEncoding && 0xFF == 0) ? *MaybeLPStart
121-
: *MaybeLPStart - Address;
115+
const uint8_t LPStartEncoding = Data.getU8(&Offset);
116+
uint64_t LPStart = Address;
117+
if (LPStartEncoding != dwarf::DW_EH_PE_omit) {
118+
std::optional<uint64_t> MaybeLPStart = Data.getEncodedPointer(
119+
&Offset, LPStartEncoding, Offset + LSDASectionAddress);
120+
if (!MaybeLPStart) {
121+
errs() << "BOLT-ERROR: unsupported LPStartEncoding: "
122+
<< (unsigned)LPStartEncoding << '\n';
123+
exit(1);
124+
}
125+
LPStart = *MaybeLPStart;
126+
}
122127

123128
const uint8_t TTypeEncoding = Data.getU8(&Offset);
124129
LSDATypeEncoding = TTypeEncoding;
@@ -175,38 +180,38 @@ void BinaryFunction::parseLSDA(ArrayRef<uint8_t> LSDASectionData,
175180
uint64_t LandingPad = *Data.getEncodedPointer(
176181
&CallSitePtr, CallSiteEncoding, CallSitePtr + LSDASectionAddress);
177182
uint64_t ActionEntry = Data.getULEB128(&CallSitePtr);
178-
179-
uint64_t LPOffset = LPStart + LandingPad;
180-
uint64_t LPAddress = Address + LPOffset;
181-
182-
// Verify if landing pad code is located outside current function
183-
// Support landing pad to builtin_unreachable
184-
if (LPAddress < Address || LPAddress > Address + getSize()) {
185-
BinaryFunction *Fragment =
186-
BC.getBinaryFunctionContainingAddress(LPAddress);
187-
assert(Fragment != nullptr &&
188-
"BOLT-ERROR: cannot find landing pad fragment");
189-
BC.addInterproceduralReference(this, Fragment->getAddress());
190-
BC.processInterproceduralReferences();
191-
assert(isParentOrChildOf(*Fragment) &&
192-
"BOLT-ERROR: cannot have landing pads in different functions");
193-
setHasIndirectTargetToSplitFragment(true);
194-
BC.addFragmentsToSkip(this);
195-
return;
196-
}
183+
if (LandingPad)
184+
LandingPad += LPStart;
197185

198186
if (opts::PrintExceptions) {
199187
outs() << "Call Site: [0x" << Twine::utohexstr(RangeBase + Start)
200188
<< ", 0x" << Twine::utohexstr(RangeBase + Start + Length)
201-
<< "); landing pad: 0x" << Twine::utohexstr(LPOffset)
189+
<< "); landing pad: 0x" << Twine::utohexstr(LandingPad)
202190
<< "; action entry: 0x" << Twine::utohexstr(ActionEntry) << "\n";
203191
outs() << " current offset is " << (CallSitePtr - CallSiteTableStart)
204192
<< '\n';
205193
}
206194

207195
// Create a handler entry if necessary.
208196
MCSymbol *LPSymbol = nullptr;
209-
if (LPOffset) {
197+
if (LandingPad) {
198+
// Verify if landing pad code is located outside current function
199+
// Support landing pad to builtin_unreachable
200+
if (LandingPad < Address || LandingPad > Address + getSize()) {
201+
BinaryFunction *Fragment =
202+
BC.getBinaryFunctionContainingAddress(LandingPad);
203+
assert(Fragment != nullptr &&
204+
"BOLT-ERROR: cannot find landing pad fragment");
205+
BC.addInterproceduralReference(this, Fragment->getAddress());
206+
BC.processInterproceduralReferences();
207+
assert(isParentOrChildOf(*Fragment) &&
208+
"BOLT-ERROR: cannot have landing pads in different functions");
209+
setHasIndirectTargetToSplitFragment(true);
210+
BC.addFragmentsToSkip(this);
211+
return;
212+
}
213+
214+
const uint64_t LPOffset = LandingPad - getAddress();
210215
if (!getInstructionAtOffset(LPOffset)) {
211216
if (opts::Verbosity >= 1)
212217
errs() << "BOLT-WARNING: landing pad " << Twine::utohexstr(LPOffset)

bolt/lib/Passes/ValidateInternalCalls.cpp

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -281,18 +281,16 @@ bool ValidateInternalCalls::analyzeFunction(BinaryFunction &Function) const {
281281
LLVM_DEBUG({
282282
dbgs() << "Detected out-of-range PIC reference in " << Function
283283
<< "\nReturn address load: ";
284-
BC.InstPrinter->printInst(TargetInst, 0, "", *BC.STI, dbgs());
285-
dbgs() << "\nUse: ";
286-
BC.InstPrinter->printInst(&Use, 0, "", *BC.STI, dbgs());
287-
dbgs() << "\n";
284+
BC.dump(*TargetInst);
285+
dbgs() << "Use: ";
286+
BC.dump(Use);
288287
Function.dump();
289288
});
290289
return false;
291290
}
292291
LLVM_DEBUG({
293292
dbgs() << "Validated access: ";
294-
BC.InstPrinter->printInst(&Use, 0, "", *BC.STI, dbgs());
295-
dbgs() << "\n";
293+
BC.dump(Use);
296294
});
297295
}
298296
if (!UseDetected) {

bolt/lib/Profile/YAMLProfileReader.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ static llvm::cl::opt<bool>
3131
llvm::cl::opt<bool> ProfileUseDFS("profile-use-dfs",
3232
cl::desc("use DFS order for YAML profile"),
3333
cl::Hidden, cl::cat(BoltOptCategory));
34-
}
34+
} // namespace opts
3535

3636
namespace llvm {
3737
namespace bolt {
@@ -354,7 +354,7 @@ Error YAMLProfileReader::readProfile(BinaryContext &BC) {
354354
matchProfileToFunction(YamlBF, Function);
355355
}
356356

357-
for (auto &[CommonName, LTOProfiles]: LTOCommonNameMap) {
357+
for (const auto &[CommonName, LTOProfiles] : LTOCommonNameMap) {
358358
if (!LTOCommonNameFunctionMap.contains(CommonName))
359359
continue;
360360
std::unordered_set<BinaryFunction *> &Functions =

bolt/test/lsda.cpp renamed to bolt/test/lsda-section-name.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
// This test check that LSDA section named by .gcc_except_table.main is
22
// disassembled by BOLT.
33

4-
// RUN: %clang++ %cxxflags -O3 -flto=thin -no-pie -c %s -o %t.o
5-
// RUN: %clang++ %cxxflags -flto=thin -no-pie -fuse-ld=lld %t.o -o %t.exe \
4+
// RUN: %clang++ %cxxflags -O3 -no-pie -c %s -o %t.o
5+
// RUN: %clang++ %cxxflags -no-pie -fuse-ld=lld %t.o -o %t.exe \
66
// RUN: -Wl,-q -Wl,--script=%S/Inputs/lsda.ldscript
77
// RUN: llvm-readelf -SW %t.exe | FileCheck %s
88
// RUN: llvm-bolt %t.exe -o %t.bolt
Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
# RUN: %clangxx %cflags -no-pie %s -o %t.exe -Wl,-q
2+
# RUN: llvm-bolt %t.exe -o %t.exe.bolt
3+
# RUN: %t.exe.bolt
4+
5+
# REQUIRES: system-linux
6+
7+
## Test that BOLT properly handles LPStart when LPStartEncoding is different
8+
## from DW_EH_PE_omit.
9+
10+
# The test case compiled with -O1 from:
11+
#
12+
# int main() {
13+
# try {
14+
# throw 42;
15+
# } catch (...) {
16+
# return 0;
17+
# }
18+
# return 1;
19+
# }
20+
#
21+
# The exception table was modified with udata4 LPStartEncoding and sdata4
22+
# CallSiteEncoding.
23+
24+
.text
25+
.globl main # -- Begin function main
26+
.p2align 4, 0x90
27+
.type main,@function
28+
main: # @main
29+
.Lfunc_begin0:
30+
.cfi_startproc
31+
.cfi_personality 3, __gxx_personality_v0
32+
.cfi_lsda 3, .Lexception0
33+
# %bb.0:
34+
pushq %rax
35+
.cfi_def_cfa_offset 16
36+
movl $4, %edi
37+
callq __cxa_allocate_exception
38+
movl $42, (%rax)
39+
.Ltmp0:
40+
movl $_ZTIi, %esi
41+
movq %rax, %rdi
42+
xorl %edx, %edx
43+
callq __cxa_throw
44+
.Ltmp1:
45+
# %bb.1:
46+
.LBB0_2:
47+
.Ltmp2:
48+
movq %rax, %rdi
49+
callq __cxa_begin_catch
50+
callq __cxa_end_catch
51+
xorl %eax, %eax
52+
popq %rcx
53+
.cfi_def_cfa_offset 8
54+
retq
55+
.Lfunc_end0:
56+
.size main, .Lfunc_end0-main
57+
.cfi_endproc
58+
.section .gcc_except_table,"a",@progbits
59+
.p2align 2
60+
GCC_except_table0:
61+
.Lexception0:
62+
.byte 3 # @LPStart Encoding = udata4
63+
.long 0
64+
.byte 3 # @TType Encoding = udata4
65+
.uleb128 .Lttbase0-.Lttbaseref0
66+
.Lttbaseref0:
67+
.byte 11 # Call site Encoding = sdata4
68+
.uleb128 .Lcst_end0-.Lcst_begin0
69+
.Lcst_begin0:
70+
.long .Lfunc_begin0-.Lfunc_begin0 # >> Call Site 1 <<
71+
.long .Ltmp0-.Lfunc_begin0 # Call between .Lfunc_begin0 and .Ltmp0
72+
.long 0 # has no landing pad
73+
.byte 0 # On action: cleanup
74+
.long .Ltmp0-.Lfunc_begin0 # >> Call Site 2 <<
75+
.long .Ltmp1-.Ltmp0 # Call between .Ltmp0 and .Ltmp1
76+
.long .Ltmp2 # jumps to .Ltmp2
77+
.byte 1 # On action: 1
78+
.long .Ltmp1-.Lfunc_begin0 # >> Call Site 3 <<
79+
.long .Lfunc_end0-.Ltmp1 # Call between .Ltmp1 and .Lfunc_end0
80+
.long 0 # has no landing pad
81+
.byte 0 # On action: cleanup
82+
.Lcst_end0:
83+
.byte 1 # >> Action Record 1 <<
84+
# Catch TypeInfo 1
85+
.byte 0 # No further actions
86+
.p2align 2
87+
# >> Catch TypeInfos <<
88+
.long 0 # TypeInfo 1
89+
.Lttbase0:
90+
.p2align 2
91+
# -- End function

0 commit comments

Comments
 (0)