Skip to content

Commit 2a97034

Browse files
committed
Merge branch 'main' into tlsdesc-auth-mc
2 parents f941e5b + 1158729 commit 2a97034

File tree

2,449 files changed

+6099
-4928
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,449 files changed

+6099
-4928
lines changed

bolt/test/X86/linux-static-keys.s

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,13 @@ _start:
3535
.L0:
3636
jmp L1
3737
# CHECK: jit
38-
# CHECK-SAME: # ID: 1 {{.*}} # Likely: 0 # InitValue: 1
38+
# CHECK-SAME: # ID: 1 {{.*}} # Likely: 1 # InitValue: 0
3939
nop
4040
L1:
4141
.nops 5
42-
jmp .L0
4342
# CHECK: jit
44-
# CHECK-SAME: # ID: 2 {{.*}} # Likely: 1 # InitValue: 1
43+
# CHECK-SAME: # ID: 2 {{.*}} # Likely: 0 # InitValue: 0
44+
jmp .L0
4545

4646
## Check that a branch profile associated with a NOP is handled properly when
4747
## dynamic branch is created.
@@ -67,18 +67,24 @@ foo:
6767
.type __start___jump_table, %object
6868
__start___jump_table:
6969

70-
.long .L0 - . # Jump address
71-
.long L1 - . # Target address
72-
.quad 1 # Key address
70+
.long .L0 - . # Jump address
71+
.long L1 - . # Target address
72+
.quad fake_static_key + 1 - . # Key address; LSB = 1 : likely
7373

74-
.long L1 - . # Jump address
75-
.long L2 - . # Target address
76-
.quad 0 # Key address
74+
.long L1 - . # Jump address
75+
.long L2 - . # Target address
76+
.quad fake_static_key -. # Key address; LSB = 0 : unlikely
7777

7878
.globl __stop___jump_table
7979
.type __stop___jump_table, %object
8080
__stop___jump_table:
8181

82+
## Staic keys (we just use the label ignoring the format of the keys).
83+
.data
84+
.align 8
85+
fake_static_key:
86+
.quad 0
87+
8288
## Fake Linux Kernel sections.
8389
.section __ksymtab,"a",@progbits
8490
.section __ksymtab_gpl,"a",@progbits

clang-tools-extra/clangd/index/SymbolCollector.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -550,9 +550,14 @@ bool SymbolCollector::shouldCollectSymbol(const NamedDecl &ND,
550550
// Avoid indexing internal symbols in protobuf generated headers.
551551
if (isPrivateProtoDecl(ND))
552552
return false;
553+
554+
// System headers that end with `intrin.h` likely contain useful symbols.
553555
if (!Opts.CollectReserved &&
554556
(hasReservedName(ND) || hasReservedScope(*ND.getDeclContext())) &&
555-
ASTCtx.getSourceManager().isInSystemHeader(ND.getLocation()))
557+
ASTCtx.getSourceManager().isInSystemHeader(ND.getLocation()) &&
558+
!ASTCtx.getSourceManager()
559+
.getFilename(ND.getLocation())
560+
.ends_with("intrin.h"))
556561
return false;
557562

558563
return true;

clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2111,6 +2111,20 @@ TEST_F(SymbolCollectorTest, Reserved) {
21112111
EXPECT_THAT(Symbols, IsEmpty());
21122112
}
21132113

2114+
TEST_F(SymbolCollectorTest, ReservedSymbolInIntrinsicHeader) {
2115+
const char *Header = R"cpp(
2116+
#pragma once
2117+
void __foo();
2118+
)cpp";
2119+
2120+
TestHeaderName = "xintrin.h";
2121+
TestHeaderURI = URI::create(testPath(TestHeaderName)).toString();
2122+
InMemoryFileSystem = new llvm::vfs::InMemoryFileSystem;
2123+
CollectorOpts.FallbackDir = testRoot();
2124+
runSymbolCollector("#pragma GCC system_header\n" + std::string(Header), "");
2125+
EXPECT_THAT(Symbols, UnorderedElementsAre(qName("__foo")));
2126+
}
2127+
21142128
TEST_F(SymbolCollectorTest, Concepts) {
21152129
const char *Header = R"cpp(
21162130
template <class T>

clang/lib/Driver/ToolChains/CommonArgs.cpp

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1417,7 +1417,6 @@ void tools::addAsNeededOption(const ToolChain &TC,
14171417

14181418
void tools::linkSanitizerRuntimeDeps(const ToolChain &TC,
14191419
const llvm::opt::ArgList &Args,
1420-
const SanitizerArgs &SanArgs,
14211420
ArgStringList &CmdArgs) {
14221421
// Force linking against the system libraries sanitizers depends on
14231422
// (see PR15823 why this is necessary).
@@ -1444,18 +1443,18 @@ void tools::linkSanitizerRuntimeDeps(const ToolChain &TC,
14441443
// libresolv.a, even if exists, is an empty archive to satisfy POSIX -lresolv
14451444
// requirement.
14461445
if (TC.getTriple().isOSLinux() && !TC.getTriple().isAndroid() &&
1447-
!TC.getTriple().isMusl() && SanArgs.needsMsanRt())
1446+
!TC.getTriple().isMusl())
14481447
CmdArgs.push_back("-lresolv");
14491448
}
14501449

14511450
static void
14521451
collectSanitizerRuntimes(const ToolChain &TC, const ArgList &Args,
1453-
const SanitizerArgs &SanArgs,
14541452
SmallVectorImpl<StringRef> &SharedRuntimes,
14551453
SmallVectorImpl<StringRef> &StaticRuntimes,
14561454
SmallVectorImpl<StringRef> &NonWholeStaticRuntimes,
14571455
SmallVectorImpl<StringRef> &HelperStaticRuntimes,
14581456
SmallVectorImpl<StringRef> &RequiredSymbols) {
1457+
const SanitizerArgs &SanArgs = TC.getSanitizerArgs(Args);
14591458
// Collect shared runtimes.
14601459
if (SanArgs.needsSharedRt()) {
14611460
if (SanArgs.needsAsanRt()) {
@@ -1589,12 +1588,12 @@ collectSanitizerRuntimes(const ToolChain &TC, const ArgList &Args,
15891588
// Should be called before we add system libraries (C++ ABI, libstdc++/libc++,
15901589
// C runtime, etc). Returns true if sanitizer system deps need to be linked in.
15911590
bool tools::addSanitizerRuntimes(const ToolChain &TC, const ArgList &Args,
1592-
const SanitizerArgs &SanArgs,
15931591
ArgStringList &CmdArgs) {
1592+
const SanitizerArgs &SanArgs = TC.getSanitizerArgs(Args);
15941593
SmallVector<StringRef, 4> SharedRuntimes, StaticRuntimes,
15951594
NonWholeStaticRuntimes, HelperStaticRuntimes, RequiredSymbols;
15961595
if (SanArgs.linkRuntimes()) {
1597-
collectSanitizerRuntimes(TC, Args, SanArgs, SharedRuntimes, StaticRuntimes,
1596+
collectSanitizerRuntimes(TC, Args, SharedRuntimes, StaticRuntimes,
15981597
NonWholeStaticRuntimes, HelperStaticRuntimes,
15991598
RequiredSymbols);
16001599
}

clang/lib/Driver/ToolChains/CommonArgs.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,10 @@ void addLinkerCompressDebugSectionsOption(const ToolChain &TC,
3838
void claimNoWarnArgs(const llvm::opt::ArgList &Args);
3939

4040
bool addSanitizerRuntimes(const ToolChain &TC, const llvm::opt::ArgList &Args,
41-
const SanitizerArgs &SanArgs,
4241
llvm::opt::ArgStringList &CmdArgs);
4342

4443
void linkSanitizerRuntimeDeps(const ToolChain &TC,
4544
const llvm::opt::ArgList &Args,
46-
const SanitizerArgs &SanArgs,
4745
llvm::opt::ArgStringList &CmdArgs);
4846

4947
bool addXRayRuntime(const ToolChain &TC, const llvm::opt::ArgList &Args,

clang/lib/Driver/ToolChains/FreeBSD.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -297,9 +297,7 @@ void freebsd::Linker::ConstructJob(Compilation &C, const JobAction &JA,
297297
D.getLTOMode() == LTOK_Thin);
298298
}
299299

300-
const SanitizerArgs &SanArgs = ToolChain.getSanitizerArgs(Args);
301-
bool NeedsSanitizerDeps =
302-
addSanitizerRuntimes(ToolChain, Args, SanArgs, CmdArgs);
300+
bool NeedsSanitizerDeps = addSanitizerRuntimes(ToolChain, Args, CmdArgs);
303301
bool NeedsXRayDeps = addXRayRuntime(ToolChain, Args, CmdArgs);
304302
addLinkerCompressDebugSectionsOption(ToolChain, Args, CmdArgs);
305303
AddLinkerInputs(ToolChain, Inputs, Args, CmdArgs, JA);
@@ -340,7 +338,7 @@ void freebsd::Linker::ConstructJob(Compilation &C, const JobAction &JA,
340338
}
341339

342340
if (NeedsSanitizerDeps)
343-
linkSanitizerRuntimeDeps(ToolChain, Args, SanArgs, CmdArgs);
341+
linkSanitizerRuntimeDeps(ToolChain, Args, CmdArgs);
344342
if (NeedsXRayDeps)
345343
linkXRayRuntimeDeps(ToolChain, Args, CmdArgs);
346344
// FIXME: For some reason GCC passes -lgcc and -lgcc_s before adding

clang/lib/Driver/ToolChains/Fuchsia.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -184,8 +184,7 @@ void fuchsia::Linker::ConstructJob(Compilation &C, const JobAction &JA,
184184
// Note that Fuchsia never needs to link in sanitizer runtime deps. Any
185185
// sanitizer runtimes with system dependencies use the `.deplibs` feature
186186
// instead.
187-
const SanitizerArgs &SanArgs = ToolChain.getSanitizerArgs(Args);
188-
addSanitizerRuntimes(ToolChain, Args, SanArgs, CmdArgs);
187+
addSanitizerRuntimes(ToolChain, Args, CmdArgs);
189188

190189
addXRayRuntime(ToolChain, Args, CmdArgs);
191190

@@ -318,9 +317,10 @@ Fuchsia::Fuchsia(const Driver &D, const llvm::Triple &Triple,
318317
Args.hasFlag(options::OPT_fexceptions, options::OPT_fno_exceptions, true);
319318
addMultilibFlag(Exceptions, "-fexceptions", Flags);
320319
addMultilibFlag(!Exceptions, "-fno-exceptions", Flags);
321-
const SanitizerArgs &SanArgs = getSanitizerArgs(Args);
322-
addMultilibFlag(SanArgs.needsAsanRt(), "-fsanitize=address", Flags);
323-
addMultilibFlag(SanArgs.needsHwasanRt(), "-fsanitize=hwaddress", Flags);
320+
addMultilibFlag(getSanitizerArgs(Args).needsAsanRt(), "-fsanitize=address",
321+
Flags);
322+
addMultilibFlag(getSanitizerArgs(Args).needsHwasanRt(),
323+
"-fsanitize=hwaddress", Flags);
324324

325325
addMultilibFlag(Args.getLastArgValue(options::OPT_fcxx_abi_EQ) == "itanium",
326326
"-fc++-abi=itanium", Flags);

clang/lib/Driver/ToolChains/Gnu.cpp

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
#include "clang/Driver/DriverDiagnostic.h"
2424
#include "clang/Driver/MultilibBuilder.h"
2525
#include "clang/Driver/Options.h"
26-
#include "clang/Driver/SanitizerArgs.h"
2726
#include "clang/Driver/Tool.h"
2827
#include "clang/Driver/ToolChain.h"
2928
#include "llvm/ADT/StringSet.h"
@@ -539,9 +538,7 @@ void tools::gnutools::Linker::ConstructJob(Compilation &C, const JobAction &JA,
539538
if (Args.hasArg(options::OPT_Z_Xlinker__no_demangle))
540539
CmdArgs.push_back("--no-demangle");
541540

542-
const SanitizerArgs &SanArgs = ToolChain.getSanitizerArgs(Args);
543-
bool NeedsSanitizerDeps =
544-
addSanitizerRuntimes(ToolChain, Args, SanArgs, CmdArgs);
541+
bool NeedsSanitizerDeps = addSanitizerRuntimes(ToolChain, Args, CmdArgs);
545542
bool NeedsXRayDeps = addXRayRuntime(ToolChain, Args, CmdArgs);
546543
addLinkerCompressDebugSectionsOption(ToolChain, Args, CmdArgs);
547544
AddLinkerInputs(ToolChain, Inputs, Args, CmdArgs, JA);
@@ -586,7 +583,7 @@ void tools::gnutools::Linker::ConstructJob(Compilation &C, const JobAction &JA,
586583
CmdArgs.push_back("--start-group");
587584

588585
if (NeedsSanitizerDeps)
589-
linkSanitizerRuntimeDeps(ToolChain, Args, SanArgs, CmdArgs);
586+
linkSanitizerRuntimeDeps(ToolChain, Args, CmdArgs);
590587

591588
if (NeedsXRayDeps)
592589
linkXRayRuntimeDeps(ToolChain, Args, CmdArgs);

clang/lib/Driver/ToolChains/Hexagon.cpp

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
#include "clang/Driver/DriverDiagnostic.h"
1414
#include "clang/Driver/InputInfo.h"
1515
#include "clang/Driver/Options.h"
16-
#include "clang/Driver/SanitizerArgs.h"
1716
#include "llvm/ADT/StringExtras.h"
1817
#include "llvm/Option/ArgList.h"
1918
#include "llvm/Support/FileSystem.h"
@@ -216,8 +215,7 @@ void hexagon::Assembler::ConstructJob(Compilation &C, const JobAction &JA,
216215
"-mcpu=hexagon" +
217216
toolchains::HexagonToolChain::GetTargetCPUVersion(Args)));
218217

219-
SanitizerArgs SanArgs = HTC.getSanitizerArgs(Args);
220-
addSanitizerRuntimes(HTC, Args, SanArgs, CmdArgs);
218+
addSanitizerRuntimes(HTC, Args, CmdArgs);
221219

222220
assert((Output.isFilename() || Output.isNothing()) && "Invalid output.");
223221
if (Output.isFilename()) {
@@ -303,8 +301,7 @@ constructHexagonLinkArgs(Compilation &C, const JobAction &JA,
303301
bool UseShared = IsShared && !IsStatic;
304302
StringRef CpuVer = toolchains::HexagonToolChain::GetTargetCPUVersion(Args);
305303

306-
const SanitizerArgs &SanArgs = HTC.getSanitizerArgs(Args);
307-
bool NeedsSanitizerDeps = addSanitizerRuntimes(HTC, Args, SanArgs, CmdArgs);
304+
bool NeedsSanitizerDeps = addSanitizerRuntimes(HTC, Args, CmdArgs);
308305
bool NeedsXRayDeps = addXRayRuntime(HTC, Args, CmdArgs);
309306

310307
//----------------------------------------------------------------------------
@@ -374,7 +371,7 @@ constructHexagonLinkArgs(Compilation &C, const JobAction &JA,
374371

375372
if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nodefaultlibs)) {
376373
if (NeedsSanitizerDeps) {
377-
linkSanitizerRuntimeDeps(HTC, Args, SanArgs, CmdArgs);
374+
linkSanitizerRuntimeDeps(HTC, Args, CmdArgs);
378375

379376
if (UNW != ToolChain::UNW_None)
380377
CmdArgs.push_back("-lunwind");

clang/lib/Driver/ToolChains/NetBSD.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -274,12 +274,11 @@ void netbsd::Linker::ConstructJob(Compilation &C, const JobAction &JA,
274274
options::OPT_s, options::OPT_t});
275275
ToolChain.AddFilePathLibArgs(Args, CmdArgs);
276276

277-
const SanitizerArgs &SanArgs = ToolChain.getSanitizerArgs(Args);
278-
bool NeedsSanitizerDeps =
279-
addSanitizerRuntimes(ToolChain, Args, SanArgs, CmdArgs);
277+
bool NeedsSanitizerDeps = addSanitizerRuntimes(ToolChain, Args, CmdArgs);
280278
bool NeedsXRayDeps = addXRayRuntime(ToolChain, Args, CmdArgs);
281279
AddLinkerInputs(ToolChain, Inputs, Args, CmdArgs, JA);
282280

281+
const SanitizerArgs &SanArgs = ToolChain.getSanitizerArgs(Args);
283282
if (SanArgs.needsSharedRt()) {
284283
CmdArgs.push_back("-rpath");
285284
CmdArgs.push_back(Args.MakeArgString(ToolChain.getCompilerRTPath()));
@@ -335,7 +334,7 @@ void netbsd::Linker::ConstructJob(Compilation &C, const JobAction &JA,
335334
}
336335

337336
if (NeedsSanitizerDeps)
338-
linkSanitizerRuntimeDeps(ToolChain, Args, SanArgs, CmdArgs);
337+
linkSanitizerRuntimeDeps(ToolChain, Args, CmdArgs);
339338
if (NeedsXRayDeps)
340339
linkXRayRuntimeDeps(ToolChain, Args, CmdArgs);
341340
if (Args.hasArg(options::OPT_pthread))

0 commit comments

Comments
 (0)