Skip to content

Commit dbadecb

Browse files
committed
LLVM and SPIRV-LLVM-Translator pulldown (WW20)
LLVM: llvm/llvm-project@2051755 SPIRV-LLVM-Translator: KhronosGroup/SPIRV-LLVM-Translator@772c7be
2 parents 619eacc + c81257c commit dbadecb

File tree

2,106 files changed

+73756
-26760
lines changed

Some content is hidden

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

2,106 files changed

+73756
-26760
lines changed

.github/workflows/release-tasks.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ jobs:
2626
2727
- name: Install Dependencies
2828
run: |
29-
sudo apt-get update \
29+
sudo apt-get update
3030
sudo apt-get install -y \
3131
doxygen \
3232
graphviz \

.github/workflows/repo-lockdown.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,11 @@ name: 'Repo Lockdown'
22
on:
33
pull_request_target:
44
types: opened
5+
paths-ignore:
6+
- 'libcxx/**'
7+
- 'libcxxabi/**'
8+
- 'libunwind/**'
9+
- 'runtimes/**'
510

611
permissions:
712
pull-requests: write

bolt/include/bolt/Core/Relocation.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,7 @@ struct Relocation {
6464
static bool skipRelocationProcess(uint64_t &Type, uint64_t Contents);
6565

6666
// Adjust value depending on relocation type (make it PC relative or not)
67-
static uint64_t adjustValue(uint64_t Type, uint64_t Value,
68-
uint64_t PC);
67+
static uint64_t encodeValue(uint64_t Type, uint64_t Value, uint64_t PC);
6968

7069
/// Extract current relocated value from binary contents. This is used for
7170
/// RISC architectures where values are encoded in specific bits depending

bolt/lib/Core/BinarySection.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ void BinarySection::flushPendingRelocations(raw_pwrite_stream &OS,
146146
if (Reloc.Symbol)
147147
Value += Resolver(Reloc.Symbol);
148148

149-
Value = Relocation::adjustValue(Reloc.Type, Value,
149+
Value = Relocation::encodeValue(Reloc.Type, Value,
150150
SectionAddress + Reloc.Offset);
151151

152152
OS.pwrite(reinterpret_cast<const char *>(&Value),

bolt/lib/Core/HashUtilities.cpp

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
#include "bolt/Core/HashUtilities.h"
1414
#include "bolt/Core/BinaryContext.h"
1515
#include "bolt/Core/BinaryFunction.h"
16+
#include "llvm/MC/MCInstPrinter.h"
1617

1718
namespace llvm {
1819
namespace bolt {
@@ -116,13 +117,11 @@ std::string hashBlock(BinaryContext &BC, const BinaryBasicBlock &BB,
116117
if (IsX86 && BC.MIB->isConditionalBranch(Inst))
117118
Opcode = BC.MIB->getShortBranchOpcode(Opcode);
118119

119-
if (Opcode == 0)
120+
if (Opcode == 0) {
120121
HashString.push_back(0);
121-
122-
while (Opcode) {
123-
uint8_t LSB = Opcode & 0xff;
124-
HashString.push_back(LSB);
125-
Opcode = Opcode >> 8;
122+
} else {
123+
StringRef OpcodeName = BC.InstPrinter->getOpcodeName(Opcode);
124+
HashString.append(OpcodeName.str());
126125
}
127126

128127
for (const MCOperand &Op : MCPlus::primeOperands(Inst))

bolt/lib/Core/Relocation.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -262,10 +262,11 @@ static bool skipRelocationProcessAArch64(uint64_t &Type, uint64_t Contents) {
262262
return false;
263263
}
264264

265-
static uint64_t adjustValueX86(uint64_t Type, uint64_t Value, uint64_t PC) {
265+
static uint64_t encodeValueX86(uint64_t Type, uint64_t Value, uint64_t PC) {
266266
switch (Type) {
267267
default:
268-
llvm_unreachable("not supported relocation");
268+
llvm_unreachable("unsupported relocation");
269+
case ELF::R_X86_64_64:
269270
case ELF::R_X86_64_32:
270271
break;
271272
case ELF::R_X86_64_PC32:
@@ -275,10 +276,10 @@ static uint64_t adjustValueX86(uint64_t Type, uint64_t Value, uint64_t PC) {
275276
return Value;
276277
}
277278

278-
static uint64_t adjustValueAArch64(uint64_t Type, uint64_t Value, uint64_t PC) {
279+
static uint64_t encodeValueAArch64(uint64_t Type, uint64_t Value, uint64_t PC) {
279280
switch (Type) {
280281
default:
281-
llvm_unreachable("not supported relocation");
282+
llvm_unreachable("unsupported relocation");
282283
case ELF::R_AARCH64_ABS32:
283284
break;
284285
case ELF::R_AARCH64_PREL16:
@@ -566,11 +567,10 @@ bool Relocation::skipRelocationProcess(uint64_t &Type, uint64_t Contents) {
566567
return skipRelocationProcessX86(Type, Contents);
567568
}
568569

569-
uint64_t Relocation::adjustValue(uint64_t Type, uint64_t Value,
570-
uint64_t PC) {
570+
uint64_t Relocation::encodeValue(uint64_t Type, uint64_t Value, uint64_t PC) {
571571
if (Arch == Triple::aarch64)
572-
return adjustValueAArch64(Type, Value, PC);
573-
return adjustValueX86(Type, Value, PC);
572+
return encodeValueAArch64(Type, Value, PC);
573+
return encodeValueX86(Type, Value, PC);
574574
}
575575

576576
uint64_t Relocation::extractValue(uint64_t Type, uint64_t Contents,

bolt/lib/Passes/RetpolineInsertion.cpp

Lines changed: 28 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
//===----------------------------------------------------------------------===//
2323

2424
#include "bolt/Passes/RetpolineInsertion.h"
25+
#include "llvm/MC/MCInstPrinter.h"
2526
#include "llvm/Support/raw_ostream.h"
2627

2728
#define DEBUG_TYPE "bolt-retpoline"
@@ -173,39 +174,45 @@ BinaryFunction *createNewRetpoline(BinaryContext &BC,
173174
std::string createRetpolineFunctionTag(BinaryContext &BC,
174175
const IndirectBranchInfo &BrInfo,
175176
bool R11Available) {
176-
if (BrInfo.isReg())
177-
return "__retpoline_r" + to_string(BrInfo.BranchReg) + "_";
177+
std::string Tag;
178+
llvm::raw_string_ostream TagOS(Tag);
179+
TagOS << "__retpoline_";
180+
181+
if (BrInfo.isReg()) {
182+
BC.InstPrinter->printRegName(TagOS, BrInfo.BranchReg);
183+
TagOS << "_";
184+
TagOS.flush();
185+
return Tag;
186+
}
178187

179188
// Memory Branch
180189
if (R11Available)
181190
return "__retpoline_r11";
182191

183-
std::string Tag = "__retpoline_mem_";
184-
185192
const IndirectBranchInfo::MemOpInfo &MemRef = BrInfo.Memory;
186193

187-
std::string DispExprStr;
188-
if (MemRef.DispExpr) {
189-
llvm::raw_string_ostream Ostream(DispExprStr);
190-
MemRef.DispExpr->print(Ostream, BC.AsmInfo.get());
191-
Ostream.flush();
192-
}
194+
TagOS << "mem_";
193195

194-
Tag += MemRef.BaseRegNum != BC.MIB->getNoRegister()
195-
? "r" + to_string(MemRef.BaseRegNum)
196-
: "";
196+
if (MemRef.BaseRegNum != BC.MIB->getNoRegister())
197+
BC.InstPrinter->printRegName(TagOS, MemRef.BaseRegNum);
197198

198-
Tag += MemRef.DispExpr ? "+" + DispExprStr : "+" + to_string(MemRef.DispImm);
199+
TagOS << "+";
200+
if (MemRef.DispExpr)
201+
MemRef.DispExpr->print(TagOS, BC.AsmInfo.get());
202+
else
203+
TagOS << MemRef.DispImm;
199204

200-
Tag += MemRef.IndexRegNum != BC.MIB->getNoRegister()
201-
? "+" + to_string(MemRef.ScaleImm) + "*" +
202-
to_string(MemRef.IndexRegNum)
203-
: "";
205+
if (MemRef.IndexRegNum != BC.MIB->getNoRegister()) {
206+
TagOS << "+" << MemRef.ScaleImm << "*";
207+
BC.InstPrinter->printRegName(TagOS, MemRef.IndexRegNum);
208+
}
204209

205-
Tag += MemRef.SegRegNum != BC.MIB->getNoRegister()
206-
? "_seg_" + to_string(MemRef.SegRegNum)
207-
: "";
210+
if (MemRef.SegRegNum != BC.MIB->getNoRegister()) {
211+
TagOS << "_seg_";
212+
BC.InstPrinter->printRegName(TagOS, MemRef.SegRegNum);
213+
}
208214

215+
TagOS.flush();
209216
return Tag;
210217
}
211218

bolt/lib/Rewrite/DWARFRewriter.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ void DWARFRewriter::updateDebugInfo() {
199199
std::make_unique<DebugLoclistWriter>(*CU.get(), DwarfVersion, false);
200200

201201
if (std::optional<uint64_t> DWOId = CU->getDWOId()) {
202-
assert(LocListWritersByCU.count(*DWOId) == 0 &&
202+
assert(RangeListsWritersByCU.count(*DWOId) == 0 &&
203203
"RangeLists writer for DWO unit already exists.");
204204
auto RangeListsSectionWriter =
205205
std::make_unique<DebugRangeListsSectionWriter>();

bolt/runtime/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
cmake_minimum_required(VERSION 3.13.4)
1+
cmake_minimum_required(VERSION 3.20.0)
22
include(CheckIncludeFiles)
33
include(GNUInstallDirs)
44

bolt/test/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ list(APPEND BOLT_TEST_DEPS
4747
llvm-objdump
4848
llvm-readelf
4949
llvm-readobj
50+
llvm-strings
5051
llvm-strip
5152
llvm-objcopy
5253
merge-fdata

bolt/test/X86/Inputs/dwarf5-loc-base-no-loc-accesshelper.s

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -286,11 +286,10 @@ fooVar:
286286
.long .Lloclists_table_base0 # DW_AT_loclists_base
287287
.byte 2 # Abbrev [2] 0x27:0xb DW_TAG_variable
288288
.byte 3 # DW_AT_name
289-
.long 50 # DW_AT_type
289+
.long 39 # DW_AT_type
290290
# DW_AT_external
291291
.byte 0 # DW_AT_decl_file
292292
.byte 1 # DW_AT_decl_line
293-
.byte 0
294293
.byte 3 # Abbrev [3] 0x32:0x4 DW_TAG_base_type
295294
.byte 4 # DW_AT_name
296295
.byte 5 # DW_AT_encoding
@@ -319,7 +318,7 @@ fooVar:
319318
.long 88 # DW_AT_type
320319
.byte 0 # End Of Children Mark
321320
.byte 8 # Abbrev [8] 0x58:0x5 DW_TAG_pointer_type
322-
.long 50 # DW_AT_type
321+
.long 39 # DW_AT_type
323322
.byte 9 # Abbrev [9] 0x5d:0x31 DW_TAG_subprogram
324323
.byte 2 # DW_AT_low_pc
325324
.long .Lfunc_end1-.Lfunc_begin1 # DW_AT_high_pc
@@ -330,18 +329,18 @@ fooVar:
330329
.byte 9 # DW_AT_name
331330
.byte 0 # DW_AT_decl_file
332331
.byte 6 # DW_AT_decl_line
333-
.long 50 # DW_AT_type
332+
.long 39 # DW_AT_type
334333
# DW_AT_external
335334
.byte 10 # Abbrev [10] 0x6d:0xa DW_TAG_formal_parameter
336335
.byte 10 # DW_AT_name
337336
.byte 0 # DW_AT_decl_file
338337
.byte 6 # DW_AT_decl_line
339-
.long 50 # DW_AT_type
338+
.long 39 # DW_AT_type
340339
.byte 11 # Abbrev [11] 0x77:0x9 DW_TAG_variable
341340
.byte 7 # DW_AT_name
342341
.byte 0 # DW_AT_decl_file
343342
.byte 7 # DW_AT_decl_line
344-
.long 50 # DW_AT_type
343+
.long 39 # DW_AT_type
345344
.byte 12 # Abbrev [12] 0x80:0xd DW_TAG_inlined_subroutine
346345
.long 74 # DW_AT_abstract_origin
347346
.byte 2 # DW_AT_low_pc

bolt/test/X86/cfi-expr-rewrite.s

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
# CHECK-NEXT: DW_CFA_expression: RBP DW_OP_breg6 RBP+0
1212
# CHECK-NEXT: DW_CFA_advance_loc: 5
1313
# CHECK-NEXT: DW_CFA_def_cfa_expression: DW_OP_breg6 RBP-8, DW_OP_deref
14-
# CHECK-NEXT: DW_CFA_advance_loc2: 3174
14+
# CHECK-NEXT: DW_CFA_advance_loc2: 3130
1515
# CHECK-NEXT: DW_CFA_def_cfa: R10 +0
1616
# CHECK-NEXT: DW_CFA_advance_loc: 5
1717
# CHECK-NEXT: DW_CFA_def_cfa: RSP +8

bolt/test/lit.cfg.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@
8787
ToolSubst('llvm-nm', unresolved='fatal'),
8888
ToolSubst('llvm-objdump', unresolved='fatal'),
8989
ToolSubst('llvm-objcopy', unresolved='fatal'),
90+
ToolSubst('llvm-strings', unresolved='fatal'),
9091
ToolSubst('llvm-strip', unresolved='fatal'),
9192
ToolSubst('llvm-readelf', unresolved='fatal'),
9293
ToolSubst('link_fdata', command=sys.executable, unresolved='fatal', extra_args=[link_fdata_cmd]),

bolt/test/runtime/X86/retpoline-synthetic.test

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,5 +20,11 @@ CHECK-CALL-NOT: callq *
2020
RUN: llvm-objdump -d -j ".text" %t | FileCheck %s -check-prefix=CHECK-JUMP
2121
CHECK-JUMP-NOT: jmpq *
2222

23+
# Check generated retpoline stub names
24+
RUN: llvm-strings %t | FileCheck %s -check-prefix=CHECK-STRINGS
25+
CHECK-STRINGS-DAG: __retpoline_%rax_
26+
CHECK-STRINGS-DAG: __retpoline_mem_%rip+DATAat0x[[#]]
27+
CHECK-STRINGS-DAG: __retpoline_mem_%rax+0
28+
2329
RUN: %t 1000 3 | FileCheck %s
2430
CHECK: 30000000

clang-tools-extra/clang-tidy/ClangTidyCheck.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -407,7 +407,6 @@ class ClangTidyCheck : public ast_matchers::MatchFinder::MatchCallback {
407407

408408
private:
409409
void run(const ast_matchers::MatchFinder::MatchResult &Result) override;
410-
StringRef getID() const override { return CheckName; }
411410
std::string CheckName;
412411
ClangTidyContext *Context;
413412

@@ -422,6 +421,7 @@ class ClangTidyCheck : public ast_matchers::MatchFinder::MatchCallback {
422421
bool areDiagsSelfContained() const {
423422
return Context->areDiagsSelfContained();
424423
}
424+
StringRef getID() const override { return CheckName; }
425425
};
426426

427427
/// Read a named option from the ``Context`` and parse it as a bool.

clang-tools-extra/clang-tidy/bugprone/AssertSideEffectCheck.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,13 +117,13 @@ void AssertSideEffectCheck::check(const MatchFinder::MatchResult &Result) {
117117
StringRef AssertMacroName;
118118
while (Loc.isValid() && Loc.isMacroID()) {
119119
StringRef MacroName = Lexer::getImmediateMacroName(Loc, SM, LangOpts);
120+
Loc = SM.getImmediateMacroCallerLoc(Loc);
120121

121122
// Check if this macro is an assert.
122123
if (llvm::is_contained(AssertMacros, MacroName)) {
123124
AssertMacroName = MacroName;
124125
break;
125126
}
126-
Loc = SM.getImmediateMacroCallerLoc(Loc);
127127
}
128128
if (AssertMacroName.empty())
129129
return;

clang-tools-extra/clang-tidy/bugprone/UncheckedOptionalAccessCheck.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ analyzeFunction(const FunctionDecl &FuncDecl, ASTContext &ASTCtx,
4040
using llvm::Expected;
4141

4242
Expected<ControlFlowContext> Context =
43-
ControlFlowContext::build(&FuncDecl, *FuncDecl.getBody(), ASTCtx);
43+
ControlFlowContext::build(FuncDecl, *FuncDecl.getBody(), ASTCtx);
4444
if (!Context)
4545
return std::nullopt;
4646

clang-tools-extra/clang-tidy/modernize/LoopConvertCheck.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -453,10 +453,6 @@ static bool containerIsConst(const Expr *ContainerExpr, bool Dereference) {
453453
return false;
454454
}
455455

456-
LoopConvertCheck::RangeDescriptor::RangeDescriptor()
457-
: ContainerNeedsDereference(false), DerefByConstRef(false),
458-
DerefByValue(false), NeedsReverseCall(false) {}
459-
460456
LoopConvertCheck::LoopConvertCheck(StringRef Name, ClangTidyContext *Context)
461457
: ClangTidyCheck(Name, Context), TUInfo(new TUTrackingInfo),
462458
MaxCopySize(Options.get("MaxCopySize", 16ULL)),

clang-tools-extra/clang-tidy/modernize/LoopConvertCheck.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,13 @@ class LoopConvertCheck : public ClangTidyCheck {
2929

3030
private:
3131
struct RangeDescriptor {
32-
RangeDescriptor();
33-
bool ContainerNeedsDereference;
34-
bool DerefByConstRef;
35-
bool DerefByValue;
32+
RangeDescriptor() = default;
33+
bool ContainerNeedsDereference = false;
34+
bool DerefByConstRef = false;
35+
bool DerefByValue = false;
3636
std::string ContainerString;
3737
QualType ElemType;
38-
bool NeedsReverseCall;
38+
bool NeedsReverseCall = false;
3939
};
4040

4141
void getAliasRange(SourceManager &SM, SourceRange &DeclRange);

clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
#include "clang/Lex/Preprocessor.h"
1515
#include "llvm/ADT/ArrayRef.h"
1616
#include "llvm/ADT/DenseMapInfo.h"
17+
#include "llvm/ADT/StringRef.h"
1718
#include "llvm/Support/Debug.h"
1819
#include "llvm/Support/Error.h"
1920
#include "llvm/Support/FormatVariadic.h"
@@ -396,7 +397,7 @@ std::string IdentifierNamingCheck::HungarianNotation::getDeclTypeName(
396397

397398
IdentifierNamingCheck::IdentifierNamingCheck(StringRef Name,
398399
ClangTidyContext *Context)
399-
: RenamerClangTidyCheck(Name, Context), Context(Context), CheckName(Name),
400+
: RenamerClangTidyCheck(Name, Context), Context(Context),
400401
GetConfigPerFile(Options.get("GetConfigPerFile", true)),
401402
IgnoreFailedSplit(Options.get("IgnoreFailedSplit", false)) {
402403

@@ -1461,6 +1462,7 @@ IdentifierNamingCheck::getStyleForFile(StringRef FileName) const {
14611462
if (Iter != NamingStylesCache.end())
14621463
return Iter->getValue();
14631464

1465+
llvm::StringRef CheckName = getID();
14641466
ClangTidyOptions Options = Context->getOptionsForFile(FileName);
14651467
if (Options.Checks && GlobList(*Options.Checks).contains(CheckName)) {
14661468
auto It = NamingStylesCache.try_emplace(

clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
#include "../utils/RenamerClangTidyCheck.h"
1313
#include <optional>
14+
#include <string>
1415
namespace clang::tidy {
1516
namespace readability {
1617

@@ -202,7 +203,6 @@ class IdentifierNamingCheck final : public RenamerClangTidyCheck {
202203
mutable llvm::StringMap<FileStyle> NamingStylesCache;
203204
FileStyle *MainFileStyle;
204205
ClangTidyContext *Context;
205-
const StringRef CheckName;
206206
const bool GetConfigPerFile;
207207
const bool IgnoreFailedSplit;
208208
HungarianNotation HungarianNotation;

0 commit comments

Comments
 (0)