Skip to content

Commit 4b65529

Browse files
committed
LLVM and SPIRV-LLVM-Translator pulldown (WW18)
LLVM: llvm/llvm-project@5c9a849 SPIRV-LLVM-Translator: KhronosGroup/SPIRV-LLVM-Translator@535afc1
2 parents 4891167 + 01eda28 commit 4b65529

File tree

5,945 files changed

+273297
-104619
lines changed

Some content is hidden

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

5,945 files changed

+273297
-104619
lines changed

.github/workflows/llvm-project-tests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ jobs:
6666
with:
6767
fetch-depth: 250
6868
- name: Setup ccache
69-
uses: hendrikmuhs/ccache-action@v1.2
69+
uses: hendrikmuhs/ccache-action@v1
7070
with:
7171
# A full build of llvm, clang, lld, and lldb takes about 250MB
7272
# of ccache space. There's not much reason to have more than this,
Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
name: Release Binaries
2+
3+
on:
4+
push:
5+
tags:
6+
- 'llvmorg-*'
7+
workflow_dispatch:
8+
inputs:
9+
upload:
10+
description: 'Upload binaries to the release page'
11+
required: true
12+
default: true
13+
type: boolean
14+
tag:
15+
description: 'Tag to build'
16+
required: true
17+
type: string
18+
19+
permissions:
20+
contents: read # Default everything to read-only
21+
22+
jobs:
23+
prepare:
24+
name: Prepare to build binaries
25+
runs-on: ubuntu-22.04
26+
if: github.repository == 'llvm/llvm-project'
27+
outputs:
28+
release-version: ${{ steps.validate-tag.outputs.release-version }}
29+
release: ${{ steps.validate-tag.outputs.release }}
30+
build-dir: ${{ steps.validate-tag.outputs.build-dir }}
31+
rc-flags: ${{ steps.validate-tag.outputs.rc-flags }}
32+
ref: ${{ steps.validate-tag.outputs.ref }}
33+
upload: ${{ steps.validate-tag.outputs.upload }}
34+
35+
steps:
36+
- name: Checkout LLVM
37+
uses: actions/checkout@v3
38+
39+
- name: Validate and parse tag
40+
id: validate-tag
41+
# In order for the test-release.sh script to run correctly, the LLVM
42+
# source needs to be at the following location relative to the build dir:
43+
# | X.Y.Z-rcN | ./rcN/llvm-project
44+
# | X.Y.Z | ./final/llvm-project
45+
#
46+
# We also need to set divergent flags based on the release version:
47+
# | X.Y.Z-rcN | -rc N -test-asserts
48+
# | X.Y.Z | -final
49+
run: |
50+
tag="${{ github.ref_name }}"
51+
trimmed=`echo ${{ inputs.tag }} | xargs`
52+
[[ "$trimmed" != "" ]] && tag="$trimmed"
53+
if [ -n "${{ inputs.upload }}" ]; then
54+
upload="${{ inputs.upload }}"
55+
else
56+
upload="true"
57+
fi
58+
bash .github/workflows/set-release-binary-outputs.sh "${{ github.actor }}" "$tag" "$upload"
59+
60+
build-binaries:
61+
name: ${{ matrix.target.triple }}
62+
permissions:
63+
contents: write # To upload assets to release.
64+
needs: prepare
65+
runs-on: ${{ matrix.target.runs-on }}
66+
strategy:
67+
fail-fast: false
68+
matrix:
69+
target:
70+
- triple: x86_64-linux-gnu-ubuntu-22.04
71+
runs-on: ubuntu-22.04-8x32
72+
debian-build-deps: >
73+
chrpath
74+
gcc-multilib
75+
ninja-build
76+
77+
steps:
78+
- name: Checkout LLVM
79+
uses: actions/checkout@v3
80+
with:
81+
ref: ${{ needs.prepare.outputs.ref }}
82+
path: ${{ needs.prepare.outputs.build-dir }}/llvm-project
83+
84+
- name: Install Brew build dependencies
85+
if: matrix.target.brew-build-deps != ''
86+
run: brew install ${{ matrix.target.brew-build-deps }}
87+
88+
- name: Install Debian build dependencies
89+
if: matrix.target.debian-build-deps != ''
90+
run: sudo apt install ${{ matrix.target.debian-build-deps }}
91+
92+
- name: Set macOS build env variables
93+
if: runner.os == 'macOS'
94+
run: |
95+
echo "MACOSX_DEPLOYMENT_TARGET=10.9" >> $GITHUB_ENV
96+
97+
- name: Build and test release
98+
run: |
99+
${{ needs.prepare.outputs.build-dir }}/llvm-project/llvm/utils/release/test-release.sh \
100+
-release ${{ needs.prepare.outputs.release }} \
101+
${{ needs.prepare.outputs.rc-flags }} \
102+
-triple ${{ matrix.target.triple }} \
103+
-use-ninja \
104+
-no-checkout \
105+
-no-test-suite
106+
107+
- name: Upload binaries
108+
if: ${{ always() && needs.prepare.outputs.upload == 'true' }}
109+
run: |
110+
sudo apt install python3-github
111+
${{ needs.prepare.outputs.build-dir }}/llvm-project/llvm/utils/release/github-upload-release.py \
112+
--token ${{ github.token }} \
113+
--release ${{ needs.prepare.outputs.release-version }} \
114+
upload \
115+
--files ${{ needs.prepare.outputs.build-dir }}/clang+llvm-${{ needs.prepare.outputs.release-version }}-${{ matrix.target.triple }}.tar.xz

.github/workflows/release-tasks.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ jobs:
2626
2727
- name: Install Dependencies
2828
run: |
29+
sudo apt-get update \
2930
sudo apt-get install -y \
3031
doxygen \
3132
graphviz \
@@ -49,7 +50,7 @@ jobs:
4950
./llvm/utils/release/github-upload-release.py --token ${{ github.token }} --release ${{ steps.validate-tag.outputs.release-version }} upload --files *doxygen*.tar.xz
5051
5152
- name: Create Release Notes Artifact
52-
uses: actions/download-artifact@v1
53+
uses: actions/download-artifact@v3
5354
with:
5455
name: release-notes
5556
path: docs-build/html-export/
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# Usage: set-release-binary-outputs.sh <github_user> <tag> <upload>
2+
3+
set -e
4+
5+
if [ -z "$GITHUB_OUTPUT" ]; then
6+
export GITHUB_OUTPUT=`mktemp`
7+
echo "Warning: Environment variable GITHUB_OUTPUT is not set."
8+
echo "Writing output variables to $GITHUB_OUTPUT"
9+
fi
10+
11+
github_user=$1
12+
tag=$2
13+
upload=$3
14+
15+
if [[ "$github_user" != "tstellar" && "$github_user" != "tru" ]]; then
16+
echo "ERROR: User not allowed: $github_user"
17+
exit 1
18+
fi
19+
pattern='^llvmorg-[0-9]\+\.[0-9]\+\.[0-9]\+\(-rc[0-9]\+\)\?$'
20+
echo "$tag" | grep -e $pattern
21+
if [ $? != 0 ]; then
22+
echo "ERROR: Tag '$tag' doesn't match pattern: $pattern"
23+
exit 1
24+
fi
25+
release_version=`echo "$tag" | sed 's/llvmorg-//g'`
26+
release=`echo "$release_version" | sed 's/-.*//g'`
27+
build_dir=`echo "$release_version" | sed 's,^[^-]\+,final,' | sed 's,[^-]\+-rc\(.\+\),rc\1,'`
28+
rc_flags=`echo "$release_version" | sed 's,^[^-]\+,-final,' | sed 's,[^-]\+-rc\(.\+\),-rc \1 -test-asserts,' | sed 's,--,-,'`
29+
echo "release-version=$release_version" >> $GITHUB_OUTPUT
30+
echo "release=$release" >> $GITHUB_OUTPUT
31+
echo "build-dir=$build_dir" >> $GITHUB_OUTPUT
32+
echo "rc-flags=$rc_flags" >> $GITHUB_OUTPUT
33+
echo "upload=$upload" >> $GITHUB_OUTPUT
34+
echo "ref=$tag" >> $GITHUB_OUTPUT

.mailmap

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ Jon Roelofs <[email protected]> <[email protected]>
3636
3737
LLVM GN Syncbot <[email protected]>
3838
Martin Storsjö <[email protected]>
39+
Med Ismail Bennani <[email protected]> <[email protected]>
40+
Med Ismail Bennani <[email protected]> <[email protected]>
3941
Ramkumar Ramachandra <[email protected]> <[email protected]>
4042
Saleem Abdulrasool <[email protected]>
4143

bolt/CMakeLists.txt

Lines changed: 41 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,47 @@ set(BOLT_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR})
44
set(BOLT_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR})
55
set(CMAKE_CXX_STANDARD 17)
66

7-
set(BOLT_ENABLE_RUNTIME OFF)
8-
if (CMAKE_SYSTEM_PROCESSOR MATCHES "x86_64")
9-
set(BOLT_ENABLE_RUNTIME ON)
7+
# Determine default set of targets to build -- the intersection of
8+
# those BOLT supports and those LLVM is targeting.
9+
set(BOLT_TARGETS_TO_BUILD_all "AArch64;X86")
10+
set(BOLT_TARGETS_TO_BUILD_default)
11+
foreach (tgt ${BOLT_TARGETS_TO_BUILD_all})
12+
if (tgt IN_LIST LLVM_TARGETS_TO_BUILD)
13+
list(APPEND BOLT_TARGETS_TO_BUILD_default ${tgt})
14+
endif()
15+
endforeach()
16+
17+
# Allow the user to specify the BOLT targets, and then check that LLVM
18+
# is indeed targeting those.
19+
set(BOLT_TARGETS_TO_BUILD "${BOLT_TARGETS_TO_BUILD_default}"
20+
CACHE STRING "Targets for BOLT to support.")
21+
if (NOT BOLT_TARGETS_TO_BUILD)
22+
message(FATAL_ERROR "BOLT enabled but BOLT_TARGETS_TO_BUILD is empty")
23+
endif()
24+
foreach (tgt ${BOLT_TARGETS_TO_BUILD})
25+
if (NOT tgt IN_LIST LLVM_TARGETS_TO_BUILD)
26+
message(FATAL_ERROR "BOLT target '${tgt}' is not in LLVM_TARGETS_TO_BUILD")
27+
endif()
28+
message(STATUS "Targeting ${tgt} in llvm-bolt")
29+
endforeach()
30+
31+
set(BOLT_ENABLE_RUNTIME_default OFF)
32+
if (CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64"
33+
AND (CMAKE_SYSTEM_NAME STREQUAL "Linux"
34+
OR CMAKE_SYSTEM_NAME STREQUAL "Darwin")
35+
AND "X86" IN_LIST BOLT_TARGETS_TO_BUILD)
36+
set(BOLT_ENABLE_RUNTIME_default ON)
37+
endif()
38+
option(BOLT_ENABLE_RUNTIME "Enable BOLT runtime" ${BOLT_ENABLE_RUNTIME_default})
39+
if (BOLT_ENABLE_RUNTIME)
40+
# Some systems prevent reading /proc/self/map_files
41+
execute_process(COMMAND ls /proc/self/map_files
42+
RESULT_VARIABLE LS OUTPUT_QUIET ERROR_QUIET)
43+
if (LS)
44+
set(BOLT_ENABLE_RUNTIME OFF)
45+
message(WARNING
46+
"BOLT runtime is disabled as /proc/self/map_files is unreadable.")
47+
endif()
1048
endif()
1149

1250
set(BOLT_CLANG_EXE "" CACHE FILEPATH "Path to clang executable for the target \

bolt/include/bolt/Core/BinaryBasicBlock.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,9 @@ class BinaryBasicBlock {
144144
/// blocks may contain out of date or incorrect information.
145145
bool IsValid{true};
146146

147+
/// Last computed hash value.
148+
mutable uint64_t Hash{0};
149+
147150
private:
148151
BinaryBasicBlock() = delete;
149152
BinaryBasicBlock(const BinaryBasicBlock &) = delete;
@@ -939,6 +942,9 @@ class BinaryBasicBlock {
939942
/// Check if the block has a jump table instruction.
940943
bool hasJumpTable() const { return getJumpTable() != nullptr; }
941944

945+
/// Returns the last computed hash value of the block.
946+
uint64_t getHash() const { return Hash; }
947+
942948
private:
943949
void adjustNumPseudos(const MCInst &Inst, int Sign);
944950

@@ -963,6 +969,9 @@ class BinaryBasicBlock {
963969
/// Set the index of this basic block.
964970
void setIndex(unsigned I) { Index = I; }
965971

972+
/// Sets the hash value of the basic block.
973+
void setHash(uint64_t Value) const { Hash = Value; }
974+
966975
template <typename T> void clearList(T &List) {
967976
T TempList;
968977
TempList.swap(List);

bolt/include/bolt/Core/BinaryFunction.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2205,6 +2205,9 @@ class BinaryFunction {
22052205
return std::string();
22062206
}) const;
22072207

2208+
/// Compute hash values for each block of the function.
2209+
void computeBlockHashes() const;
2210+
22082211
void setDWARFUnit(DWARFUnit *Unit) { DwarfUnit = Unit; }
22092212

22102213
/// Return DWARF compile unit for this function.

bolt/include/bolt/Core/BinaryLoop.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
#ifndef BOLT_CORE_BINARY_LOOP_H
1616
#define BOLT_CORE_BINARY_LOOP_H
1717

18-
#include "llvm/Analysis/LoopInfoImpl.h"
18+
#include "llvm/Support/GenericLoopInfoImpl.h"
1919

2020
namespace llvm {
2121
namespace bolt {
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
//===- bolt/Core/HashUtilities.h - Misc hash utilities --------------------===//
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 file contains functions for computing hash values over BinaryFunction
10+
// and BinaryBasicBlock.
11+
//
12+
//===----------------------------------------------------------------------===//
13+
14+
#ifndef BOLT_CORE_HASH_UTILITIES_H
15+
#define BOLT_CORE_HASH_UTILITIES_H
16+
17+
#include "bolt/Core/BinaryBasicBlock.h"
18+
#include "bolt/Core/BinaryContext.h"
19+
20+
namespace llvm {
21+
namespace bolt {
22+
23+
uint16_t hash_64_to_16(const uint64_t Hash);
24+
25+
std::string hashInteger(uint64_t Value);
26+
27+
std::string hashSymbol(BinaryContext &BC, const MCSymbol &Symbol);
28+
29+
std::string hashExpr(BinaryContext &BC, const MCExpr &Expr);
30+
31+
std::string hashInstOperand(BinaryContext &BC, const MCOperand &Operand);
32+
33+
using OperandHashFuncTy = function_ref<typename std::string(const MCOperand &)>;
34+
35+
std::string hashBlock(BinaryContext &BC, const BinaryBasicBlock &BB,
36+
OperandHashFuncTy OperandHashFunc);
37+
38+
} // namespace bolt
39+
} // namespace llvm
40+
41+
#endif

bolt/include/bolt/Core/MCPlusBuilder.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -466,6 +466,11 @@ class MCPlusBuilder {
466466

467467
virtual MCPhysReg getX86R11() const { llvm_unreachable("not implemented"); }
468468

469+
virtual unsigned getShortBranchOpcode(unsigned Opcode) const {
470+
llvm_unreachable("not implemented");
471+
return 0;
472+
}
473+
469474
/// Create increment contents of target by 1 for Instrumentation
470475
virtual InstructionListType createInstrIncMemory(const MCSymbol *Target,
471476
MCContext *Ctx,

bolt/include/bolt/Profile/ProfileYAMLMapping.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,7 @@ template <> struct MappingTraits<bolt::BinaryBasicBlockProfile> {
126126
static void mapping(IO &YamlIO, bolt::BinaryBasicBlockProfile &BBP) {
127127
YamlIO.mapRequired("bid", BBP.Index);
128128
YamlIO.mapRequired("insns", BBP.NumInstructions);
129+
YamlIO.mapOptional("hash", BBP.Hash, (llvm::yaml::Hex64)0);
129130
YamlIO.mapOptional("exec", BBP.ExecCount, (uint64_t)0);
130131
YamlIO.mapOptional("events", BBP.EventCount, (uint64_t)0);
131132
YamlIO.mapOptional("calls", BBP.CallSites,

bolt/include/bolt/Rewrite/RewriteInstance.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,6 @@ class RewriteInstance {
8989
}
9090

9191
private:
92-
using ELF64LEPhdrTy = object::ELF64LEFile::Elf_Phdr;
93-
9492
/// Populate array of binary functions and other objects of interest
9593
/// from meta data in the file.
9694
void discoverFileObjects();

0 commit comments

Comments
 (0)