Skip to content

Commit 33cc337

Browse files
author
iclsrc
committed
Merge from 'main' to 'sycl-web' (126 commits)
2 parents f23cfb5 + 8d86963 commit 33cc337

File tree

695 files changed

+22050
-11591
lines changed

Some content is hidden

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

695 files changed

+22050
-11591
lines changed

.github/new-prs-labeler.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -554,6 +554,12 @@ flang:fir-hlfir:
554554
flang:codegen:
555555
- flang/**/CodeGen/**
556556

557+
llvm:codegen:
558+
- llvm/lib/CodeGen/*
559+
- llvm/lib/CodeGen/MIRParser/*
560+
- llvm/lib/CodeGen/LiveDebugValues/*
561+
- llvm/lib/CodeGen/AsmPrinter/*
562+
557563
llvm:globalisel:
558564
- llvm/**/GlobalISel/**
559565
- llvm/utils/TableGen/GlobalISel*

bolt/lib/Passes/ADRRelaxationPass.cpp

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -81,17 +81,15 @@ void ADRRelaxationPass::runOnFunction(BinaryFunction &BF) {
8181
It = BB.eraseInstruction(std::prev(It));
8282
} else if (std::next(It) != BB.end() && BC.MIB->isNoop(*std::next(It))) {
8383
BB.eraseInstruction(std::next(It));
84-
} else if (!opts::StrictMode && !BF.isSimple()) {
84+
} else if (!BF.isSimple()) {
8585
// If the function is not simple, it may contain a jump table undetected
8686
// by us. This jump table may use an offset from the branch instruction
8787
// to land in the desired place. If we add new instructions, we
8888
// invalidate this offset, so we have to rely on linker-inserted NOP to
8989
// replace it with ADRP, and abort if it is not present.
9090
auto L = BC.scopeLock();
91-
BC.errs() << formatv(
92-
"BOLT-ERROR: Cannot relax adr in non-simple function "
93-
"{0}. Use --strict option to override\n",
94-
BF.getOneName());
91+
BC.errs() << "BOLT-ERROR: cannot relax ADR in non-simple function "
92+
<< BF << '\n';
9593
PassFailed = true;
9694
return;
9795
}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
## Check that llvm-bolt generates a proper error message when ADR instruction
2+
## cannot be relaxed.
3+
4+
# RUN: llvm-mc -filetype=obj -triple aarch64-unknown-unknown %s -o %t.o
5+
# RUN: %clang %cflags %t.o -o %t.exe -Wl,-q -static
6+
# RUN: not llvm-bolt %t.exe -o %t.bolt 2>&1 | FileCheck %s
7+
# RUN: not llvm-bolt %t.exe -o %t.bolt --strict 2>&1 | FileCheck %s
8+
9+
# CHECK: BOLT-ERROR: cannot relax ADR in non-simple function _start
10+
11+
## The function contains unknown control flow and llvm-bolt fails to recover
12+
## CFG. As BOLT has to preserve the function layout, the ADR instruction cannot
13+
## be relaxed into ADRP+ADD.
14+
.text
15+
.globl _start
16+
.type _start, %function
17+
_start:
18+
.cfi_startproc
19+
adr x1, foo
20+
adr x2, .L1
21+
.L1:
22+
br x0
23+
ret x0
24+
.cfi_endproc
25+
.size _start, .-_start
26+
27+
.globl foo
28+
.type foo, %function
29+
foo:
30+
.cfi_startproc
31+
ret x0
32+
.cfi_endproc
33+
.size foo, .-foo

bolt/test/AArch64/adr-relaxation.s

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
# RUN: llvm-mc -filetype=obj -triple aarch64-unknown-unknown %s -o %t.o
44
# RUN: %clang %cflags %t.o -o %t.exe -Wl,-q -static
55
# RUN: llvm-bolt %t.exe -o %t.bolt --split-functions --split-strategy=random2
6-
# RUN: llvm-objdump -d --disassemble-symbols=_start %t.bolt | FileCheck %s
6+
# RUN: llvm-objdump -d -j .text %t.bolt | FileCheck %s
77
# RUN: llvm-objdump -d --disassemble-symbols=foo.cold.0 %t.bolt \
88
# RUN: | FileCheck --check-prefix=CHECK-FOO %s
99

@@ -13,11 +13,10 @@
1313
.globl _start
1414
.type _start, %function
1515
_start:
16-
# CHECK: <_start>:
1716
.cfi_startproc
17+
# CHECK: <_start>:
18+
# CHECK-NEXT: adr
1819
adr x1, _start
19-
# CHECK-NOT: adrp
20-
# CHECK: adr
2120
cmp x1, x11
2221
b.hi .L1
2322
mov x0, #0x0
@@ -38,12 +37,27 @@ foo:
3837
mov x0, #0x0
3938
.L2:
4039
# CHECK-FOO: <foo.cold.0>:
41-
adr x1, foo
42-
# CHECK-FOO: adrp
40+
# CHECK-FOO-NEXT: adrp
4341
# CHECK-FOO-NEXT: add
42+
adr x1, foo
4443
ret x30
4544
.cfi_endproc
4645
.size foo, .-foo
4746

48-
## Force relocation mode.
49-
.reloc 0, R_AARCH64_NONE
47+
## bar is a non-simple function. We can still relax ADR, because it has a
48+
## preceding NOP.
49+
.globl bar
50+
.type bar, %function
51+
bar:
52+
.cfi_startproc
53+
# CHECK-LABEL: <bar>:
54+
# CHECK-NEXT: adrp
55+
# CHECK-NEXT: add
56+
nop
57+
adr x0, foo
58+
adr x1, .L3
59+
br x1
60+
.L3:
61+
ret x0
62+
.cfi_endproc
63+
.size bar, .-bar

bolt/test/AArch64/r_aarch64_prelxx.s

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,14 @@
1212
// CHECKPREL-NEXT: R_AARCH64_PREL32 {{.*}} _start + 4
1313
// CHECKPREL-NEXT: R_AARCH64_PREL64 {{.*}} _start + 8
1414

15-
// RUN: llvm-bolt %t.exe -o %t.bolt --strict
15+
// RUN: llvm-bolt %t.exe -o %t.bolt
1616
// RUN: llvm-objdump -D %t.bolt | FileCheck %s --check-prefix=CHECKPREL32
1717

1818
// CHECKPREL32: [[#%x,DATATABLEADDR:]] <datatable>:
1919
// CHECKPREL32-NEXT: 00:
2020
// CHECKPREL32-NEXT: 04: {{.*}} .word 0x[[#%x,VALUE:]]
2121

22-
// 4 is offset in datatable
23-
// 8 is addend
24-
// CHECKPREL32: [[#DATATABLEADDR + 4 - 8 + VALUE]] <_start>:
22+
// CHECKPREL32: [[#DATATABLEADDR + VALUE]] <_start>:
2523

2624
// RUN: llvm-objdump -D %t.bolt | FileCheck %s --check-prefix=CHECKPREL64
2725
// CHECKPREL64: [[#%x,DATATABLEADDR:]] <datatable>:
@@ -30,16 +28,15 @@
3028
// CHECKPREL64-NEXT: 08: {{.*}} .word 0x[[#%x,VALUE:]]
3129
// CHECKPREL64-NEXT: 0c: {{.*}} .word 0x00000000
3230

33-
// 8 is offset in datatable
34-
// 12 is addend
35-
// CHECKPREL64: [[#DATATABLEADDR + 8 - 12 + VALUE]] <_start>:
31+
// CHECKPREL64: [[#DATATABLEADDR + VALUE]] <_start>:
3632

3733
.section .text
3834
.align 4
3935
.globl _start
4036
.type _start, %function
4137
_start:
42-
adr x0, datatable
38+
adrp x0, datatable
39+
add x0, x0, :lo12:datable
4340
mov x0, #0
4441
ret
4542

bolt/test/AArch64/test-indirect-branch.s

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77

88
// RUN: llvm-mc -filetype=obj -triple aarch64-unknown-unknown -mattr=+pauth %s -o %t.o
99
// RUN: %clang %cflags --target=aarch64-unknown-linux %t.o -o %t.exe -Wl,-q
10-
// RUN: llvm-bolt %t.exe -o %t.bolt --print-cfg --strict --debug-only=mcplus \
11-
// RUN: -v=1 2>&1 | FileCheck %s
10+
// RUN: llvm-bolt %t.exe -o %t.bolt --print-cfg --debug-only=mcplus -v=1 2>&1 \
11+
// RUN: | FileCheck %s
1212

1313
// Pattern 1: there is no shift amount after the 'add' instruction.
1414
//
@@ -45,6 +45,7 @@ _start:
4545
.type test1, %function
4646
test1:
4747
mov x1, #0
48+
nop
4849
adr x3, datatable
4950
add x3, x3, x1, lsl #2
5051
ldr w2, [x3]
@@ -56,6 +57,11 @@ test1_1:
5657
ret
5758
test1_2:
5859
ret
60+
.size test1, .-test1
61+
62+
// Temporary workaround for PC-relative relocations from datatable leaking into
63+
// test2 function and creating phantom entry points.
64+
.skip 0x100
5965

6066
// Pattern 2
6167
// CHECK: BOLT-DEBUG: failed to match indirect branch: nop/adr instead of adrp/add
@@ -65,6 +71,7 @@ test2:
6571
nop
6672
adr x3, jump_table
6773
ldrh w3, [x3, x1, lsl #1]
74+
nop
6875
adr x1, test2_0
6976
add x3, x1, w3, sxth #2
7077
br x3

bolt/test/runtime/AArch64/adrrelaxationpass.s

Lines changed: 0 additions & 62 deletions
This file was deleted.

clang-tools-extra/clang-doc/BitcodeReader.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
#include "BitcodeReader.h"
1010
#include "llvm/ADT/IndexedMap.h"
1111
#include "llvm/Support/Error.h"
12+
#include "llvm/Support/TimeProfiler.h"
1213
#include "llvm/Support/raw_ostream.h"
1314
#include <optional>
1415

@@ -672,6 +673,7 @@ llvm::Error ClangDocBitcodeReader::readRecord(unsigned ID, T I) {
672673

673674
template <>
674675
llvm::Error ClangDocBitcodeReader::readRecord(unsigned ID, Reference *I) {
676+
llvm::TimeTraceScope("Reducing infos", "readRecord");
675677
Record R;
676678
llvm::StringRef Blob;
677679
llvm::Expected<unsigned> MaybeRecID = Stream.readRecord(ID, R, &Blob);
@@ -683,6 +685,7 @@ llvm::Error ClangDocBitcodeReader::readRecord(unsigned ID, Reference *I) {
683685
// Read a block of records into a single info.
684686
template <typename T>
685687
llvm::Error ClangDocBitcodeReader::readBlock(unsigned ID, T I) {
688+
llvm::TimeTraceScope("Reducing infos", "readBlock");
686689
if (llvm::Error Err = Stream.EnterSubBlock(ID))
687690
return Err;
688691

@@ -713,6 +716,7 @@ llvm::Error ClangDocBitcodeReader::readBlock(unsigned ID, T I) {
713716

714717
template <typename T>
715718
llvm::Error ClangDocBitcodeReader::readSubBlock(unsigned ID, T I) {
719+
llvm::TimeTraceScope("Reducing infos", "readSubBlock");
716720
switch (ID) {
717721
// Blocks can only have certain types of sub blocks.
718722
case BI_COMMENT_BLOCK_ID: {
@@ -819,6 +823,7 @@ llvm::Error ClangDocBitcodeReader::readSubBlock(unsigned ID, T I) {
819823

820824
ClangDocBitcodeReader::Cursor
821825
ClangDocBitcodeReader::skipUntilRecordOrBlock(unsigned &BlockOrRecordID) {
826+
llvm::TimeTraceScope("Reducing infos", "skipUntilRecordOrBlock");
822827
BlockOrRecordID = 0;
823828

824829
while (!Stream.AtEndOfStream()) {
@@ -880,6 +885,7 @@ llvm::Error ClangDocBitcodeReader::validateStream() {
880885
}
881886

882887
llvm::Error ClangDocBitcodeReader::readBlockInfoBlock() {
888+
llvm::TimeTraceScope("Reducing infos", "readBlockInfoBlock");
883889
Expected<std::optional<llvm::BitstreamBlockInfo>> MaybeBlockInfo =
884890
Stream.ReadBlockInfoBlock();
885891
if (!MaybeBlockInfo)
@@ -895,6 +901,7 @@ llvm::Error ClangDocBitcodeReader::readBlockInfoBlock() {
895901
template <typename T>
896902
llvm::Expected<std::unique_ptr<Info>>
897903
ClangDocBitcodeReader::createInfo(unsigned ID) {
904+
llvm::TimeTraceScope("Reducing infos", "createInfo");
898905
std::unique_ptr<Info> I = std::make_unique<T>();
899906
if (auto Err = readBlock(ID, static_cast<T *>(I.get())))
900907
return std::move(Err);
@@ -903,6 +910,7 @@ ClangDocBitcodeReader::createInfo(unsigned ID) {
903910

904911
llvm::Expected<std::unique_ptr<Info>>
905912
ClangDocBitcodeReader::readBlockToInfo(unsigned ID) {
913+
llvm::TimeTraceScope("Reducing infos", "readBlockToInfo");
906914
switch (ID) {
907915
case BI_NAMESPACE_BLOCK_ID:
908916
return createInfo<NamespaceInfo>(ID);

clang-tools-extra/clang-doc/HTMLMustacheGenerator.cpp

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
#include "llvm/Support/MemoryBuffer.h"
2020
#include "llvm/Support/Mustache.h"
2121
#include "llvm/Support/Path.h"
22+
#include "llvm/Support/TimeProfiler.h"
2223

2324
using namespace llvm;
2425
using namespace llvm::json;
@@ -125,13 +126,18 @@ static Error setupTemplateFiles(const clang::doc::ClangDocContext &CDCtx) {
125126
Error MustacheHTMLGenerator::generateDocs(
126127
StringRef RootDir, StringMap<std::unique_ptr<doc::Info>> Infos,
127128
const clang::doc::ClangDocContext &CDCtx) {
128-
if (auto Err = setupTemplateFiles(CDCtx))
129-
return Err;
129+
{
130+
llvm::TimeTraceScope TS("Setup Templates");
131+
if (auto Err = setupTemplateFiles(CDCtx))
132+
return Err;
133+
}
134+
130135
// Track which directories we already tried to create.
131136
StringSet<> CreatedDirs;
132137
// Collect all output by file name and create the necessary directories.
133138
StringMap<std::vector<doc::Info *>> FileToInfos;
134139
for (const auto &Group : Infos) {
140+
llvm::TimeTraceScope TS("setup directories");
135141
doc::Info *Info = Group.getValue().get();
136142

137143
SmallString<128> Path;
@@ -148,15 +154,19 @@ Error MustacheHTMLGenerator::generateDocs(
148154
FileToInfos[Path].push_back(Info);
149155
}
150156

151-
for (const auto &Group : FileToInfos) {
152-
std::error_code FileErr;
153-
raw_fd_ostream InfoOS(Group.getKey(), FileErr, sys::fs::OF_None);
154-
if (FileErr)
155-
return createFileOpenError(Group.getKey(), FileErr);
156-
157-
for (const auto &Info : Group.getValue())
158-
if (Error Err = generateDocForInfo(Info, InfoOS, CDCtx))
159-
return Err;
157+
{
158+
llvm::TimeTraceScope TS("Generate Docs");
159+
for (const auto &Group : FileToInfos) {
160+
llvm::TimeTraceScope TS("Info to Doc");
161+
std::error_code FileErr;
162+
raw_fd_ostream InfoOS(Group.getKey(), FileErr, sys::fs::OF_None);
163+
if (FileErr)
164+
return createFileOpenError(Group.getKey(), FileErr);
165+
166+
for (const auto &Info : Group.getValue())
167+
if (Error Err = generateDocForInfo(Info, InfoOS, CDCtx))
168+
return Err;
169+
}
160170
}
161171
return Error::success();
162172
}

0 commit comments

Comments
 (0)