Skip to content

Commit 73b9c93

Browse files
committed
Merge branch 'main' into bugfix_structurizecfg
2 parents e619896 + 60c0663 commit 73b9c93

File tree

1,051 files changed

+40786
-25783
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,051 files changed

+40786
-25783
lines changed

.ci/compute_projects.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -333,6 +333,7 @@ def get_env_variables(modified_files: list[str], platform: str) -> Set[str]:
333333
current_platform = platform.system()
334334
if len(sys.argv) == 2:
335335
current_platform = sys.argv[1]
336-
env_variables = get_env_variables(sys.stdin.readlines(), current_platform)
336+
changed_files = [line.strip() for line in sys.stdin.readlines()]
337+
env_variables = get_env_variables(changed_files, current_platform)
337338
for env_variable in env_variables:
338339
print(f"{env_variable}='{env_variables[env_variable]}'")

.github/workflows/containers/github-action-ci/Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,8 @@ RUN apt-get update && \
7373
# caching), so we manually install it here.
7474
# TODO(boomanaiden154): We should return to installing this from the apt
7575
# repository once a version containing the necessary bug fixes is available.
76-
RUN curl -L 'https://github.com/mozilla/sccache/releases/download/v0.10.0/sccache-v0.10.0-x86_64-unknown-linux-musl.tar.gz' > /tmp/sccache.tar.gz && \
77-
echo "1fbb35e135660d04a2d5e42b59c7874d39b3deb17de56330b25b713ec59f849b /tmp/sccache.tar.gz" | sha256sum -c && \
76+
RUN curl -L "https://github.com/mozilla/sccache/releases/download/v0.10.0/sccache-v0.10.0-$(arch)-unknown-linux-musl.tar.gz" > /tmp/sccache.tar.gz && \
77+
echo $( [ $(arch) = 'x86_64' ] && echo "1fbb35e135660d04a2d5e42b59c7874d39b3deb17de56330b25b713ec59f849b" || echo "d6a1ce4acd02b937cd61bc675a8be029a60f7bc167594c33d75732bbc0a07400") /tmp/sccache.tar.gz | sha256sum -c && \
7878
tar xzf /tmp/sccache.tar.gz -O --wildcards '*/sccache' > '/usr/local/bin/sccache' && \
7979
rm /tmp/sccache.tar.gz && \
8080
chmod +x /usr/local/bin/sccache

.github/workflows/premerge.yaml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,8 @@ jobs:
6565
# several test suites in a row and discard statistics that we want
6666
# to save in the end.
6767
export SCCACHE_IDLE_TIMEOUT=0
68-
sccache --start-server
68+
mkdir artifacts
69+
SCCACHE_LOG=info SCCACHE_ERROR_LOG=$(pwd)/artifacts/sccache.log sccache --start-server
6970
7071
./.ci/monolithic-linux.sh "${projects_to_build}" "${project_check_targets}" "${runtimes_to_build}" "${runtimes_check_targets}" "${runtimes_check_targets_needs_reconfig}" "${enable_cir}"
7172
- name: Upload Artifacts
@@ -117,7 +118,7 @@ jobs:
117118
call C:\\BuildTools\\Common7\\Tools\\VsDevCmd.bat -arch=amd64 -host_arch=amd64
118119
# See the comments above in the Linux job for why we define each of
119120
# these environment variables.
120-
bash -c "export SCCACHE_GCS_BUCKET=$CACHE_GCS_BUCKET; export SCCACHE_GCS_RW_MODE=READ_WRITE; export SCCACHE_IDLE_TIMEOUT=0; sccache --start-server; .ci/monolithic-windows.sh \"${{ steps.vars.outputs.windows-projects }}\" \"${{ steps.vars.outputs.windows-check-targets }}\""
121+
bash -c "export SCCACHE_GCS_BUCKET=$CACHE_GCS_BUCKET; export SCCACHE_GCS_RW_MODE=READ_WRITE; export SCCACHE_IDLE_TIMEOUT=0; mkdir artifacts; SCCACHE_LOG=info SCCACHE_ERROR_LOG=$(pwd)/artifacts/sccache.log sccache --start-server; .ci/monolithic-windows.sh \"${{ steps.vars.outputs.windows-projects }}\" \"${{ steps.vars.outputs.windows-check-targets }}\""
121122
- name: Upload Artifacts
122123
# In some cases, Github will fail to upload the artifact. We want to
123124
# continue anyways as a failed artifact upload is an infra failure, not

bolt/lib/Core/BinaryFunction.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3773,6 +3773,8 @@ MCSymbol *BinaryFunction::addEntryPointAtOffset(uint64_t Offset) {
37733773
assert(Offset && "cannot add primary entry point");
37743774

37753775
const uint64_t EntryPointAddress = getAddress() + Offset;
3776+
assert(!isInConstantIsland(EntryPointAddress) &&
3777+
"cannot add entry point that points to constant data");
37763778
MCSymbol *LocalSymbol = getOrCreateLocalLabel(EntryPointAddress);
37773779

37783780
MCSymbol *EntrySymbol = getSecondaryEntryPointSymbol(LocalSymbol);

bolt/lib/Rewrite/RewriteInstance.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2935,7 +2935,8 @@ void RewriteInstance::handleRelocation(const SectionRef &RelocatedSection,
29352935
ReferencedSymbol = nullptr;
29362936
ExtractedValue = Address;
29372937
} else if (RefFunctionOffset) {
2938-
if (ContainingBF && ContainingBF != ReferencedBF) {
2938+
if (ContainingBF && ContainingBF != ReferencedBF &&
2939+
!ReferencedBF->isInConstantIsland(Address)) {
29392940
ReferencedSymbol =
29402941
ReferencedBF->addEntryPointAtOffset(RefFunctionOffset);
29412942
} else {

bolt/test/AArch64/validate-secondary-entry-point.s

Lines changed: 41 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,23 @@
11
# This test is to verify that BOLT won't take a label pointing to constant
2-
# island as a secondary entry point (function `_start` doesn't have ELF size
3-
# set originally) and the function won't otherwise be mistaken as non-simple.
2+
# island as a secondary entry point. This could happen when function doesn't
3+
# have ELF size set if it is from assembly code, or a constant island is
4+
# referenced by another function discovered during relocation processing.
45

5-
# RUN: %clang %cflags -pie %s -o %t.so -Wl,-q -Wl,--init=_foo -Wl,--fini=_foo
6+
# RUN: split-file %s %t
7+
8+
# RUN: %clang %cflags -pie %t/tt.asm -o %t.so \
9+
# RUN: -Wl,-q -Wl,--init=_foo -Wl,--fini=_foo
610
# RUN: llvm-bolt %t.so -o %t.bolt.so --print-cfg 2>&1 | FileCheck %s
711
# CHECK-NOT: BOLT-WARNING: reference in the middle of instruction detected \
812
# CHECK-NOT: function _start at offset 0x{{[0-9a-f]+}}
913
# CHECK: Binary Function "_start" after building cfg
1014

15+
# RUN: %clang %cflags -ffunction-sections -shared %t/tt.c %t/ss.c -o %tt.so \
16+
# RUN: -Wl,-q -Wl,--init=_start -Wl,--fini=_start \
17+
# RUN: -Wl,--version-script=%t/linker_script
18+
# RUN: llvm-bolt %tt.so -o %tt.bolted.so
19+
20+
;--- tt.asm
1121
.text
1222

1323
.global _foo
@@ -32,3 +42,31 @@ _bar:
3242

3343
# Dummy relocation to force relocation mode
3444
.reloc 0, R_AARCH64_NONE
45+
46+
;--- tt.c
47+
void _start() {}
48+
49+
__attribute__((naked)) void foo() {
50+
asm("ldr x16, .L_fnptr\n"
51+
"blr x16\n"
52+
"ret\n"
53+
54+
"_rodatx:"
55+
".global _rodatx;"
56+
".quad 0;"
57+
".L_fnptr:"
58+
".quad 0;");
59+
}
60+
61+
;--- ss.c
62+
__attribute__((visibility("hidden"))) extern void* _rodatx;
63+
void* bar() { return &_rodatx; }
64+
65+
;--- linker_script
66+
{
67+
global:
68+
_start;
69+
foo;
70+
bar;
71+
local: *;
72+
};

bolt/test/AArch64/veneer-lld-abs.s

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
## Occasionally, we see the linker not generating $d symbols for long veneers
1414
## causing BOLT to fail veneer elimination.
15-
# RUN: llvm-objcopy --remove-symbol-prefix=\$d %t.exe %t.no-marker.exe
15+
# RUN: llvm-objcopy --remove-symbol-prefix='$d' %t.exe %t.no-marker.exe
1616
# RUN: llvm-bolt %t.no-marker.exe -o %t.no-marker.bolt \
1717
# RUN: 2>&1 | FileCheck %s --check-prefix=CHECK-BOLT
1818
# RUN: llvm-objdump -d -j .text %t.no-marker.bolt | \

bolt/test/X86/double-jump.test

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,11 @@
11
## Test the double jump removal peephole.
22

3-
## This test has commands that rely on shell capabilities that won't execute
4-
## correctly on Windows e.g. subshell execution
5-
REQUIRES: shell
6-
73
RUN: %clangxx %cxxflags %p/Inputs/double_jump.cpp -o %t.exe
8-
RUN: (llvm-bolt %t.exe --peepholes=double-jumps \
9-
RUN: --eliminate-unreachable -o %t 2>&1 \
10-
RUN: && llvm-objdump -d %t --print-imm-hex --no-show-raw-insn) | FileCheck %s
4+
RUN: llvm-bolt %t.exe --peepholes=double-jumps \
5+
RUN: --eliminate-unreachable -o %t | FileCheck --check-prefix CHECK-BOLT %s
6+
RUN: llvm-objdump -d %t --print-imm-hex --no-show-raw-insn | FileCheck %s
117

12-
CHECK: BOLT-INFO: Peephole: 1 double jumps patched.
8+
CHECK-BOLT: BOLT-INFO: Peephole: 1 double jumps patched.
139

1410
CHECK: <_Z3foom>:
1511
CHECK-NEXT: pushq %rbp

bolt/test/X86/jmp-optimization.test

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
11
## Tests the optimization of functions that just do a tail call in the beginning.
22

3-
## This test has commands that rely on shell capabilities that won't execute
4-
## correctly on Windows e.g. unsupported parameter expansion
5-
REQUIRES: shell
6-
7-
RUN: %clangxx %cxxflags -O2 %S/Inputs/jmp_opt{,2,3}.cpp -o %t
3+
RUN: %clangxx %cxxflags -O2 %S/Inputs/jmp_opt.cpp %S/Inputs/jmp_opt2.cpp \
4+
RUN: %S/Inputs/jmp_opt3.cpp -o %t
85
RUN: llvm-bolt -inline-small-functions %t -o %t.bolt
96
RUN: llvm-objdump -d %t.bolt --print-imm-hex | FileCheck %s
107

bolt/test/X86/jump-table-icp.test

Lines changed: 14 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,16 @@ RUN: link_fdata %p/Inputs/jump_table_icp.s %t.o %t.fdata --nmtool llvm-nm
44
RUN: llvm-strip --strip-unneeded %t.o
55
RUN: %clang %cflags -no-pie %t.o -o %t.exe -Wl,-q
66

7-
## This test has commands that rely on shell capabilities that won't execute
8-
## correctly on Windows e.g. subshell execution
9-
REQUIRES: shell
10-
11-
RUN: (llvm-bolt %t.exe --data %t.fdata -o %t --relocs \
7+
RUN: llvm-bolt %t.exe --data %t.fdata -o %t --relocs \
128
RUN: --reorder-blocks=cache --split-functions --split-all-cold \
139
RUN: --use-gnu-stack --dyno-stats --indirect-call-promotion=jump-tables \
1410
RUN: --print-icp -v=0 \
1511
RUN: --enable-bat --print-cache-metrics \
1612
RUN: --icp-jt-remaining-percent-threshold=10 \
1713
RUN: --icp-jt-total-percent-threshold=2 \
1814
RUN: --indirect-call-promotion-topn=1 \
19-
RUN: --icp-jump-tables-targets --align-functions-max-bytes=7 2>&1 && \
20-
RUN: llvm-objdump -d %t --print-imm-hex) | FileCheck %s
15+
RUN: --icp-jump-tables-targets --align-functions-max-bytes=7 | FileCheck %s
16+
RUN: llvm-objdump -d %t --print-imm-hex | FileCheck --check-prefix CHECK-ASM %s
2117

2218
BOLT-INFO: ICP total indirect callsites = 0
2319
BOLT-INFO: ICP total jump table callsites = 2
@@ -107,14 +103,14 @@ CHECK-NEXT: Exec Count : 140
107103
CHECK: Predecessors: .Ltmp{{.*}}, .LFT{{.*}}
108104
CHECK: Successors: .Ltmp{{.*}} (mispreds: 0, count: 98)
109105

110-
CHECK: <_Z3inci>:
111-
CHECK: movq 0x{{.*}}(,%rax,8), %rax
112-
CHECK-NEXT: cmpq $0x{{.*}}, %rax
113-
CHECK-NEXT: je {{.*}} <_Z3inci+0x{{.*}}>
114-
CHECK-NEXT: jmpq *%rax
115-
116-
CHECK: <_Z7inc_dupi>:
117-
CHECK: movq 0x{{.*}}(,%rax,8), %rax
118-
CHECK-NEXT: cmpq $0x{{.*}}, %rax
119-
CHECK-NEXT: je {{.*}} <_Z7inc_dupi+0x{{.*}}>
120-
CHECK-NEXT: jmpq *%rax
106+
CHECK-ASM: <_Z3inci>:
107+
CHECK-ASM: movq 0x{{.*}}(,%rax,8), %rax
108+
CHECK-ASM-NEXT: cmpq $0x{{.*}}, %rax
109+
CHECK-ASM-NEXT: je {{.*}} <_Z3inci+0x{{.*}}>
110+
CHECK-ASM-NEXT: jmpq *%rax
111+
112+
CHECK-ASM: <_Z7inc_dupi>:
113+
CHECK-ASM: movq 0x{{.*}}(,%rax,8), %rax
114+
CHECK-ASM-NEXT: cmpq $0x{{.*}}, %rax
115+
CHECK-ASM-NEXT: je {{.*}} <_Z7inc_dupi+0x{{.*}}>
116+
CHECK-ASM-NEXT: jmpq *%rax

0 commit comments

Comments
 (0)