Skip to content

Commit

Permalink
Merged main:7b97d5048a8f into amd-gfx:3ab181f6d3ad
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
SC llvm team authored and SC llvm team committed Nov 23, 2023
2 parents 3ab181f + 7b97d50 commit 9460104
Show file tree
Hide file tree
Showing 1,136 changed files with 61,132 additions and 30,574 deletions.
4 changes: 4 additions & 0 deletions .github/CODEOWNERS
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@
/mlir/lib/Dialect/Vector/Transforms/VectorEmulateNarrowType.cpp @MaheshRavishankar
/mlir/lib/Interfaces/TilingInterface.* @MaheshRavishankar

# Transform Dialect in MLIR.
/mlir/include/mlir/Dialect/Transform/* @ftynse
/mlir/lib/Dialect/Transform/* @ftynse

# SPIR-V in MLIR.
/mlir/**/SPIRV/ @antiagainst @kuhar
/mlir/**/SPIRVTo*/ @antiagainst @kuhar
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 @@ -44,7 +44,7 @@ env:
jobs:
stage1:
runs-on:
group: libcxx-runners-16
group: libcxx-runners-8
continue-on-error: false
strategy:
fail-fast: true
Expand Down Expand Up @@ -163,10 +163,10 @@ jobs:
machine: libcxx-runners-8
std_modules: 'ON'
- config: 'generic-asan'
machine: libcxx-runners-16
machine: libcxx-runners-8
std_modules: 'OFF'
- config: 'generic-tsan'
machine: libcxx-runners-16
machine: libcxx-runners-8
std_modules: 'OFF'
- config: 'generic-ubsan'
machine: libcxx-runners-8
Expand Down
48 changes: 46 additions & 2 deletions .github/workflows/release-binaries.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,17 +57,52 @@ jobs:
fi
bash .github/workflows/set-release-binary-outputs.sh "${{ github.actor }}" "$tag" "$upload"
# Try to get around the 6 hour timeout by first running a job to fill
# the build cache.
fill-cache:
name: "Fill Cache ${{ matrix.os }}"
needs: prepare
runs-on: ${{ matrix.os }}
strategy:
matrix:
os:
- ubuntu-22.04
steps:
- name: Checkout LLVM
uses: actions/checkout@v4
with:
ref: ${{ inputs.tag || github.ref_name }}

- name: Install Ninja
uses: llvm/actions/install-ninja@main

- name: Setup sccache
uses: hendrikmuhs/ccache-action@v1
with:
max-size: 250M
key: sccache-${{ matrix.os }}-release
variant: sccache

- name: Build Clang
run: |
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
ninja -v -C build
build-binaries:
name: ${{ matrix.target.triple }}
permissions:
contents: write # To upload assets to release.
needs: prepare
needs:
- prepare
- fill-cache
runs-on: ${{ matrix.target.runs-on }}
strategy:
fail-fast: false
matrix:
target:
- triple: x86_64-linux-gnu-ubuntu-22.04
os: ubuntu-22.04
runs-on: ubuntu-22.04-16x64
debian-build-deps: >
chrpath
Expand All @@ -81,6 +116,14 @@ jobs:
ref: ${{ needs.prepare.outputs.ref }}
path: ${{ needs.prepare.outputs.build-dir }}/llvm-project

- name: Setup sccache
uses: hendrikmuhs/ccache-action@v1
with:
max-size: 250M
key: sccache-${{ matrix.target.os }}-release
save: false
variant: sccache

- name: Install Brew build dependencies
if: matrix.target.brew-build-deps != ''
run: brew install ${{ matrix.target.brew-build-deps }}
Expand All @@ -102,7 +145,8 @@ jobs:
-triple ${{ matrix.target.triple }} \
-use-ninja \
-no-checkout \
-no-test-suite
-no-test-suite \
-configure-flags "-DCMAKE_C_COMPILER_LAUNCHER=sccache -DCMAKE_CXX_COMPILER_LAUNCHER=sccache"
- name: Upload binaries
if: ${{ always() && needs.prepare.outputs.upload == 'true' }}
Expand Down
3 changes: 3 additions & 0 deletions bolt/include/bolt/Core/BinaryContext.h
Original file line number Diff line number Diff line change
Expand Up @@ -1290,6 +1290,9 @@ class BinaryContext {
/// Return true if the function should be emitted to the output file.
bool shouldEmit(const BinaryFunction &Function) const;

/// Dump the assembly representation of MCInst to debug output.
void dump(const MCInst &Inst) const;

/// Print the string name for a CFI operation.
static void printCFI(raw_ostream &OS, const MCCFIInstruction &Inst);

Expand Down
9 changes: 9 additions & 0 deletions bolt/lib/Core/BinaryContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1738,6 +1738,15 @@ bool BinaryContext::shouldEmit(const BinaryFunction &Function) const {
return HasRelocations || Function.isSimple();
}

void BinaryContext::dump(const MCInst &Inst) const {
if (LLVM_UNLIKELY(!InstPrinter)) {
dbgs() << "Cannot dump for InstPrinter is not initialized.\n";
return;
}
InstPrinter->printInst(&Inst, 0, "", *STI, dbgs());
dbgs() << "\n";
}

void BinaryContext::printCFI(raw_ostream &OS, const MCCFIInstruction &Inst) {
uint32_t Operation = Inst.getOperation();
switch (Operation) {
Expand Down
61 changes: 33 additions & 28 deletions bolt/lib/Core/Exceptions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -112,13 +112,18 @@ void BinaryFunction::parseLSDA(ArrayRef<uint8_t> LSDASectionData,
uint64_t Offset = getLSDAAddress() - LSDASectionAddress;
assert(Data.isValidOffset(Offset) && "wrong LSDA address");

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

const uint8_t TTypeEncoding = Data.getU8(&Offset);
LSDATypeEncoding = TTypeEncoding;
Expand Down Expand Up @@ -175,38 +180,38 @@ void BinaryFunction::parseLSDA(ArrayRef<uint8_t> LSDASectionData,
uint64_t LandingPad = *Data.getEncodedPointer(
&CallSitePtr, CallSiteEncoding, CallSitePtr + LSDASectionAddress);
uint64_t ActionEntry = Data.getULEB128(&CallSitePtr);

uint64_t LPOffset = LPStart + LandingPad;
uint64_t LPAddress = Address + LPOffset;

// Verify if landing pad code is located outside current function
// Support landing pad to builtin_unreachable
if (LPAddress < Address || LPAddress > Address + getSize()) {
BinaryFunction *Fragment =
BC.getBinaryFunctionContainingAddress(LPAddress);
assert(Fragment != nullptr &&
"BOLT-ERROR: cannot find landing pad fragment");
BC.addInterproceduralReference(this, Fragment->getAddress());
BC.processInterproceduralReferences();
assert(isParentOrChildOf(*Fragment) &&
"BOLT-ERROR: cannot have landing pads in different functions");
setHasIndirectTargetToSplitFragment(true);
BC.addFragmentsToSkip(this);
return;
}
if (LandingPad)
LandingPad += LPStart;

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

// Create a handler entry if necessary.
MCSymbol *LPSymbol = nullptr;
if (LPOffset) {
if (LandingPad) {
// Verify if landing pad code is located outside current function
// Support landing pad to builtin_unreachable
if (LandingPad < Address || LandingPad > Address + getSize()) {
BinaryFunction *Fragment =
BC.getBinaryFunctionContainingAddress(LandingPad);
assert(Fragment != nullptr &&
"BOLT-ERROR: cannot find landing pad fragment");
BC.addInterproceduralReference(this, Fragment->getAddress());
BC.processInterproceduralReferences();
assert(isParentOrChildOf(*Fragment) &&
"BOLT-ERROR: cannot have landing pads in different functions");
setHasIndirectTargetToSplitFragment(true);
BC.addFragmentsToSkip(this);
return;
}

const uint64_t LPOffset = LandingPad - getAddress();
if (!getInstructionAtOffset(LPOffset)) {
if (opts::Verbosity >= 1)
errs() << "BOLT-WARNING: landing pad " << Twine::utohexstr(LPOffset)
Expand Down
10 changes: 4 additions & 6 deletions bolt/lib/Passes/ValidateInternalCalls.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -281,18 +281,16 @@ bool ValidateInternalCalls::analyzeFunction(BinaryFunction &Function) const {
LLVM_DEBUG({
dbgs() << "Detected out-of-range PIC reference in " << Function
<< "\nReturn address load: ";
BC.InstPrinter->printInst(TargetInst, 0, "", *BC.STI, dbgs());
dbgs() << "\nUse: ";
BC.InstPrinter->printInst(&Use, 0, "", *BC.STI, dbgs());
dbgs() << "\n";
BC.dump(*TargetInst);
dbgs() << "Use: ";
BC.dump(Use);
Function.dump();
});
return false;
}
LLVM_DEBUG({
dbgs() << "Validated access: ";
BC.InstPrinter->printInst(&Use, 0, "", *BC.STI, dbgs());
dbgs() << "\n";
BC.dump(Use);
});
}
if (!UseDetected) {
Expand Down
4 changes: 2 additions & 2 deletions bolt/lib/Profile/YAMLProfileReader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ static llvm::cl::opt<bool>
llvm::cl::opt<bool> ProfileUseDFS("profile-use-dfs",
cl::desc("use DFS order for YAML profile"),
cl::Hidden, cl::cat(BoltOptCategory));
}
} // namespace opts

namespace llvm {
namespace bolt {
Expand Down Expand Up @@ -354,7 +354,7 @@ Error YAMLProfileReader::readProfile(BinaryContext &BC) {
matchProfileToFunction(YamlBF, Function);
}

for (auto &[CommonName, LTOProfiles]: LTOCommonNameMap) {
for (const auto &[CommonName, LTOProfiles] : LTOCommonNameMap) {
if (!LTOCommonNameFunctionMap.contains(CommonName))
continue;
std::unordered_set<BinaryFunction *> &Functions =
Expand Down
4 changes: 2 additions & 2 deletions bolt/test/lsda.cpp → bolt/test/lsda-section-name.cpp
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
// This test check that LSDA section named by .gcc_except_table.main is
// disassembled by BOLT.

// RUN: %clang++ %cxxflags -O3 -flto=thin -no-pie -c %s -o %t.o
// RUN: %clang++ %cxxflags -flto=thin -no-pie -fuse-ld=lld %t.o -o %t.exe \
// RUN: %clang++ %cxxflags -O3 -no-pie -c %s -o %t.o
// RUN: %clang++ %cxxflags -no-pie -fuse-ld=lld %t.o -o %t.exe \
// RUN: -Wl,-q -Wl,--script=%S/Inputs/lsda.ldscript
// RUN: llvm-readelf -SW %t.exe | FileCheck %s
// RUN: llvm-bolt %t.exe -o %t.bolt
Expand Down
91 changes: 91 additions & 0 deletions bolt/test/runtime/X86/exceptions-lpstart-zero.s
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
# RUN: %clangxx %cflags -no-pie %s -o %t.exe -Wl,-q
# RUN: llvm-bolt %t.exe -o %t.exe.bolt
# RUN: %t.exe.bolt

# REQUIRES: system-linux

## Test that BOLT properly handles LPStart when LPStartEncoding is different
## from DW_EH_PE_omit.

# The test case compiled with -O1 from:
#
# int main() {
# try {
# throw 42;
# } catch (...) {
# return 0;
# }
# return 1;
# }
#
# The exception table was modified with udata4 LPStartEncoding and sdata4
# CallSiteEncoding.

.text
.globl main # -- Begin function main
.p2align 4, 0x90
.type main,@function
main: # @main
.Lfunc_begin0:
.cfi_startproc
.cfi_personality 3, __gxx_personality_v0
.cfi_lsda 3, .Lexception0
# %bb.0:
pushq %rax
.cfi_def_cfa_offset 16
movl $4, %edi
callq __cxa_allocate_exception
movl $42, (%rax)
.Ltmp0:
movl $_ZTIi, %esi
movq %rax, %rdi
xorl %edx, %edx
callq __cxa_throw
.Ltmp1:
# %bb.1:
.LBB0_2:
.Ltmp2:
movq %rax, %rdi
callq __cxa_begin_catch
callq __cxa_end_catch
xorl %eax, %eax
popq %rcx
.cfi_def_cfa_offset 8
retq
.Lfunc_end0:
.size main, .Lfunc_end0-main
.cfi_endproc
.section .gcc_except_table,"a",@progbits
.p2align 2
GCC_except_table0:
.Lexception0:
.byte 3 # @LPStart Encoding = udata4
.long 0
.byte 3 # @TType Encoding = udata4
.uleb128 .Lttbase0-.Lttbaseref0
.Lttbaseref0:
.byte 11 # Call site Encoding = sdata4
.uleb128 .Lcst_end0-.Lcst_begin0
.Lcst_begin0:
.long .Lfunc_begin0-.Lfunc_begin0 # >> Call Site 1 <<
.long .Ltmp0-.Lfunc_begin0 # Call between .Lfunc_begin0 and .Ltmp0
.long 0 # has no landing pad
.byte 0 # On action: cleanup
.long .Ltmp0-.Lfunc_begin0 # >> Call Site 2 <<
.long .Ltmp1-.Ltmp0 # Call between .Ltmp0 and .Ltmp1
.long .Ltmp2 # jumps to .Ltmp2
.byte 1 # On action: 1
.long .Ltmp1-.Lfunc_begin0 # >> Call Site 3 <<
.long .Lfunc_end0-.Ltmp1 # Call between .Ltmp1 and .Lfunc_end0
.long 0 # has no landing pad
.byte 0 # On action: cleanup
.Lcst_end0:
.byte 1 # >> Action Record 1 <<
# Catch TypeInfo 1
.byte 0 # No further actions
.p2align 2
# >> Catch TypeInfos <<
.long 0 # TypeInfo 1
.Lttbase0:
.p2align 2
# -- End function
Loading

0 comments on commit 9460104

Please sign in to comment.