Skip to content

Commit c818709

Browse files
committed
LLVM and SPIRV-LLVM-Translator pulldown (WW13)
LLVM: llvm/llvm-project@964398ccb1168 SPIRV-LLVM-Translator: KhronosGroup/SPIRV-LLVM-Translator@a9b9ca0
2 parents e4f281c + 5a6644d commit c818709

File tree

1,397 files changed

+35686
-7346
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,397 files changed

+35686
-7346
lines changed

bolt/include/bolt/Core/MCPlusBuilder.h

+2-1
Original file line numberDiff line numberDiff line change
@@ -1282,7 +1282,8 @@ class MCPlusBuilder {
12821282

12831283
/// Replace instruction with a shorter version that could be relaxed later
12841284
/// if needed.
1285-
virtual bool shortenInstruction(MCInst &Inst) const {
1285+
virtual bool shortenInstruction(MCInst &Inst,
1286+
const MCSubtargetInfo &STI) const {
12861287
llvm_unreachable("not implemented");
12871288
return false;
12881289
}

bolt/lib/Passes/BinaryPasses.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -1011,7 +1011,7 @@ uint64_t ShortenInstructions::shortenInstructions(BinaryFunction &Function) {
10111011
if (opts::Verbosity > 2)
10121012
OriginalInst = Inst;
10131013

1014-
if (!BC.MIB->shortenInstruction(Inst))
1014+
if (!BC.MIB->shortenInstruction(Inst, *BC.STI))
10151015
continue;
10161016

10171017
if (opts::Verbosity > 2) {

bolt/lib/Target/AArch64/AArch64MCPlusBuilder.cpp

+3-1
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,9 @@ class AArch64MCPlusBuilder : public MCPlusBuilder {
5151
return false;
5252
}
5353

54-
bool shortenInstruction(MCInst &) const override { return false; }
54+
bool shortenInstruction(MCInst &, const MCSubtargetInfo &) const override {
55+
return false;
56+
}
5557

5658
bool isADRP(const MCInst &Inst) const override {
5759
return Inst.getOpcode() == AArch64::ADRP;

bolt/lib/Target/X86/CMakeLists.txt

+1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
set(LLVM_LINK_COMPONENTS
22
BOLTCore
3+
BOLTUtils
34
MC
45
Object
56
Support

bolt/lib/Target/X86/X86MCPlusBuilder.cpp

+29-5
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
#include "llvm/MC/MCInstrInfo.h"
2424
#include "llvm/MC/MCRegister.h"
2525
#include "llvm/MC/MCRegisterInfo.h"
26+
#include "llvm/Support/CommandLine.h"
2627
#include "llvm/Support/DataExtractor.h"
2728
#include "llvm/Support/Debug.h"
2829
#include "llvm/Support/Errc.h"
@@ -35,6 +36,17 @@
3536
using namespace llvm;
3637
using namespace bolt;
3738

39+
namespace opts {
40+
41+
extern cl::OptionCategory BoltOptCategory;
42+
43+
static cl::opt<bool> X86StripRedundantAddressSize(
44+
"x86-strip-redundant-address-size",
45+
cl::desc("Remove redundant Address-Size override prefix"), cl::init(true),
46+
cl::ZeroOrMore, cl::cat(BoltOptCategory));
47+
48+
} // namespace opts
49+
3850
namespace {
3951

4052
unsigned getShortBranchOpcode(unsigned Opcode) {
@@ -2031,14 +2043,26 @@ class X86MCPlusBuilder : public MCPlusBuilder {
20312043
llvm_unreachable("not implemented");
20322044
}
20332045

2034-
bool shortenInstruction(MCInst &Inst) const override {
2046+
bool shortenInstruction(MCInst &Inst,
2047+
const MCSubtargetInfo &STI) const override {
20352048
unsigned OldOpcode = Inst.getOpcode();
20362049
unsigned NewOpcode = OldOpcode;
20372050

2038-
// Check and remove EIZ/RIZ. These cases represent ambiguous cases where SIB
2039-
// byte is present, but no index is used and modrm alone shoud have been
2040-
// enough. Converting to NoRegister effectively removes the SIB byte.
20412051
int MemOpNo = getMemoryOperandNo(Inst);
2052+
2053+
// Check and remove redundant Address-Size override prefix.
2054+
if (opts::X86StripRedundantAddressSize) {
2055+
uint64_t TSFlags = Info->get(OldOpcode).TSFlags;
2056+
unsigned Flags = Inst.getFlags();
2057+
2058+
if (!X86_MC::needsAddressSizeOverride(Inst, STI, MemOpNo, TSFlags) &&
2059+
Flags & X86::IP_HAS_AD_SIZE)
2060+
Inst.setFlags(Flags ^ X86::IP_HAS_AD_SIZE);
2061+
}
2062+
2063+
// Check and remove EIZ/RIZ. These cases represent ambiguous cases where
2064+
// SIB byte is present, but no index is used and modrm alone should have
2065+
// been enough. Converting to NoRegister effectively removes the SIB byte.
20422066
if (MemOpNo >= 0) {
20432067
MCOperand &IndexOp =
20442068
Inst.getOperand(static_cast<unsigned>(MemOpNo) + X86::AddrIndexReg);
@@ -3877,7 +3901,7 @@ class X86MCPlusBuilder : public MCPlusBuilder {
38773901
return BlocksVectorTy();
38783902

38793903
CompareInst.addOperand(MCOperand::createImm(CaseIdx));
3880-
shortenInstruction(CompareInst);
3904+
shortenInstruction(CompareInst, *Ctx->getSubtargetInfo());
38813905

38823906
// jump to next target compare.
38833907
NextTarget =

bolt/test/X86/addr32.s

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# Check that we don't accidentally strip addr32 prefix
2+
3+
# RUN: llvm-mc -filetype=obj -triple x86_64-unknown-unknown %s -o %t.o
4+
# RUN: ld.lld %t.o -o %t.exe -nostdlib
5+
# RUN: llvm-objdump -d %t.exe | FileCheck %s
6+
# RUN: llvm-bolt %t.exe -o %t.out -lite=0 -x86-strip-redundant-address-size=false
7+
# RUN: llvm-objdump -d %t.out | FileCheck %s
8+
# CHECK: 67 e8 {{.*}} addr32 callq {{.*}} <foo>
9+
# RUN: llvm-bolt %t.exe -o %t.out -lite=0 -x86-strip-redundant-address-size=true
10+
# remove test name from objdump output, to only search for addr32 in disassembly
11+
# RUN: llvm-objdump -d %t.out | grep -v addr32.s | FileCheck %s --check-prefix=CHECK-STRIP
12+
# CHECK-STRIP-NOT: addr32
13+
14+
.globl _start
15+
.type _start, @function
16+
_start:
17+
.code64
18+
addr32 callq foo
19+
ret
20+
.size _start, .-_start
21+
22+
.globl foo
23+
.type foo, @function
24+
foo:
25+
ud2

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

+19-3
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,18 @@ findConstToRemove(const FunctionDecl *Def,
5353

5454
namespace {
5555

56+
AST_MATCHER(QualType, isLocalConstQualified) {
57+
return Node.isLocalConstQualified();
58+
}
59+
60+
AST_MATCHER(QualType, isTypeOfType) {
61+
return isa<TypeOfType>(Node.getTypePtr());
62+
}
63+
64+
AST_MATCHER(QualType, isTypeOfExprType) {
65+
return isa<TypeOfExprType>(Node.getTypePtr());
66+
}
67+
5668
struct CheckResult {
5769
// Source range of the relevant `const` token in the definition being checked.
5870
CharSourceRange ConstRange;
@@ -95,10 +107,14 @@ static CheckResult checkDef(const clang::FunctionDecl *Def,
95107

96108
void ConstReturnTypeCheck::registerMatchers(MatchFinder *Finder) {
97109
// Find all function definitions for which the return types are `const`
98-
// qualified.
110+
// qualified, ignoring decltype types.
111+
auto NonLocalConstType = qualType(
112+
unless(isLocalConstQualified()),
113+
anyOf(decltypeType(), autoType(), isTypeOfType(), isTypeOfExprType()));
99114
Finder->addMatcher(
100-
functionDecl(returns(isConstQualified()),
101-
anyOf(isDefinition(), cxxMethodDecl(isPure())))
115+
functionDecl(
116+
returns(allOf(isConstQualified(), unless(NonLocalConstType))),
117+
anyOf(isDefinition(), cxxMethodDecl(isPure())))
102118
.bind("func"),
103119
this);
104120
}

clang-tools-extra/clang-tidy/tool/run-clang-tidy.py

+17-8
Original file line numberDiff line numberDiff line change
@@ -90,8 +90,8 @@ def make_absolute(f, directory):
9090

9191
def get_tidy_invocation(f, clang_tidy_binary, checks, tmpdir, build_path,
9292
header_filter, allow_enabling_alpha_checkers,
93-
extra_arg, extra_arg_before, quiet, config,
94-
line_filter, use_color):
93+
extra_arg, extra_arg_before, quiet, config_path,
94+
config, line_filter, use_color):
9595
"""Gets a command line for clang-tidy."""
9696
start = [clang_tidy_binary]
9797
if allow_enabling_alpha_checkers:
@@ -121,7 +121,9 @@ def get_tidy_invocation(f, clang_tidy_binary, checks, tmpdir, build_path,
121121
start.append('-p=' + build_path)
122122
if quiet:
123123
start.append('-quiet')
124-
if config:
124+
if config_path:
125+
start.append('--config-file=' + config_path)
126+
elif config:
125127
start.append('-config=' + config)
126128
start.append(f)
127129
return start
@@ -192,8 +194,8 @@ def run_tidy(args, clang_tidy_binary, tmpdir, build_path, queue, lock,
192194
tmpdir, build_path, args.header_filter,
193195
args.allow_enabling_alpha_checkers,
194196
args.extra_arg, args.extra_arg_before,
195-
args.quiet, args.config, args.line_filter,
196-
args.use_color)
197+
args.quiet, args.config_path, args.config,
198+
args.line_filter, args.use_color)
197199

198200
proc = subprocess.Popen(invocation, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
199201
output, err = proc.communicate()
@@ -225,14 +227,21 @@ def main():
225227
parser.add_argument('-checks', default=None,
226228
help='checks filter, when not specified, use clang-tidy '
227229
'default')
228-
parser.add_argument('-config', default=None,
230+
config_group = parser.add_mutually_exclusive_group()
231+
config_group.add_argument('-config', default=None,
229232
help='Specifies a configuration in YAML/JSON format: '
230233
' -config="{Checks: \'*\', '
231234
' CheckOptions: [{key: x, '
232235
' value: y}]}" '
233236
'When the value is empty, clang-tidy will '
234237
'attempt to find a file named .clang-tidy for '
235238
'each source file in its parent directories.')
239+
config_group.add_argument('-config-file', default=None,
240+
help='Specify the path of .clang-tidy or custom config '
241+
'file: e.g. -config-file=/some/path/myTidyConfigFile. '
242+
'This option internally works exactly the same way as '
243+
'-config option after reading specified config file. '
244+
'Use either -config-file or -config, not both.')
236245
parser.add_argument('-header-filter', default=None,
237246
help='regular expression matching the names of the '
238247
'headers to output diagnostics from. Diagnostics from '
@@ -295,8 +304,8 @@ def main():
295304
None, build_path, args.header_filter,
296305
args.allow_enabling_alpha_checkers,
297306
args.extra_arg, args.extra_arg_before,
298-
args.quiet, args.config, args.line_filter,
299-
args.use_color)
307+
args.quiet, args.config_path, args.config,
308+
args.line_filter, args.use_color)
300309
invocation.append('-list-checks')
301310
invocation.append('-')
302311
if args.quiet:

clang-tools-extra/clangd/ParsedAST.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -467,7 +467,7 @@ ParsedAST::build(llvm::StringRef Filename, const ParseInputs &Inputs,
467467
if (IsInsideMainFile && CTContext->shouldSuppressDiagnostic(
468468
DiagLevel, Info, TidySuppressedErrors,
469469
/*AllowIO=*/false,
470-
/*EnableNolintBlocks=*/false)) {
470+
/*EnableNolintBlocks=*/true)) {
471471
// FIXME: should we expose the suppression error (invalid use of
472472
// NOLINT comments)?
473473
return DiagnosticsEngine::Ignored;

clang-tools-extra/clangd/SemanticHighlighting.cpp

+15-10
Original file line numberDiff line numberDiff line change
@@ -313,21 +313,26 @@ unsigned evaluateHighlightPriority(const HighlightingToken &Tok) {
313313
//
314314
// In particular, heuristically resolved dependent names get their heuristic
315315
// kind, plus the dependent modifier.
316+
llvm::Optional<HighlightingToken> resolveConflict(const HighlightingToken &A,
317+
const HighlightingToken &B) {
318+
unsigned Priority1 = evaluateHighlightPriority(A);
319+
unsigned Priority2 = evaluateHighlightPriority(B);
320+
if (Priority1 == Priority2 && A.Kind != B.Kind)
321+
return llvm::None;
322+
auto Result = Priority1 > Priority2 ? A : B;
323+
Result.Modifiers = A.Modifiers | B.Modifiers;
324+
return Result;
325+
}
316326
llvm::Optional<HighlightingToken>
317327
resolveConflict(ArrayRef<HighlightingToken> Tokens) {
318328
if (Tokens.size() == 1)
319329
return Tokens[0];
320330

321-
if (Tokens.size() != 2)
322-
return llvm::None;
323-
324-
unsigned Priority1 = evaluateHighlightPriority(Tokens[0]);
325-
unsigned Priority2 = evaluateHighlightPriority(Tokens[1]);
326-
if (Priority1 == Priority2 && Tokens[0].Kind != Tokens[1].Kind)
327-
return llvm::None;
328-
auto Result = Priority1 > Priority2 ? Tokens[0] : Tokens[1];
329-
Result.Modifiers = Tokens[0].Modifiers | Tokens[1].Modifiers;
330-
return Result;
331+
assert(Tokens.size() >= 2);
332+
Optional<HighlightingToken> Winner = resolveConflict(Tokens[0], Tokens[1]);
333+
for (size_t I = 2; Winner && I < Tokens.size(); ++I)
334+
Winner = resolveConflict(*Winner, Tokens[I]);
335+
return Winner;
331336
}
332337

333338
/// Consumes source locations and maps them to text ranges for highlightings.

clang-tools-extra/clangd/refactor/tweaks/CMakeLists.txt

+1
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ add_clang_library(clangDaemonTweaks OBJECT
2222
ExtractFunction.cpp
2323
ExtractVariable.cpp
2424
ObjCLocalizeStringLiteral.cpp
25+
ObjCMemberwiseInitializer.cpp
2526
PopulateSwitch.cpp
2627
RawStringLiteral.cpp
2728
RemoveUsingNamespace.cpp

0 commit comments

Comments
 (0)