Skip to content

Commit

Permalink
merge main into amd-staging
Browse files Browse the repository at this point in the history
revert: stacked on SPIRV patches
a22578d ConstraintElim: teach fact-transfer about samesign (llvm#115893)

Change-Id: If585e91c8cf2ac18d204be5564131956b18f14e8
  • Loading branch information
ronlieb committed Dec 15, 2024
2 parents 98abacc + e339f0a commit c543643
Show file tree
Hide file tree
Showing 2,301 changed files with 3,896 additions and 3,477 deletions.
7 changes: 6 additions & 1 deletion clang-tools-extra/clangd/index/SymbolCollector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -550,9 +550,14 @@ bool SymbolCollector::shouldCollectSymbol(const NamedDecl &ND,
// Avoid indexing internal symbols in protobuf generated headers.
if (isPrivateProtoDecl(ND))
return false;

// System headers that end with `intrin.h` likely contain useful symbols.
if (!Opts.CollectReserved &&
(hasReservedName(ND) || hasReservedScope(*ND.getDeclContext())) &&
ASTCtx.getSourceManager().isInSystemHeader(ND.getLocation()))
ASTCtx.getSourceManager().isInSystemHeader(ND.getLocation()) &&
!ASTCtx.getSourceManager()
.getFilename(ND.getLocation())
.ends_with("intrin.h"))
return false;

return true;
Expand Down
14 changes: 14 additions & 0 deletions clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2111,6 +2111,20 @@ TEST_F(SymbolCollectorTest, Reserved) {
EXPECT_THAT(Symbols, IsEmpty());
}

TEST_F(SymbolCollectorTest, ReservedSymbolInIntrinsicHeader) {
const char *Header = R"cpp(
#pragma once
void __foo();
)cpp";

TestHeaderName = "xintrin.h";
TestHeaderURI = URI::create(testPath(TestHeaderName)).toString();
InMemoryFileSystem = new llvm::vfs::InMemoryFileSystem;
CollectorOpts.FallbackDir = testRoot();
runSymbolCollector("#pragma GCC system_header\n" + std::string(Header), "");
EXPECT_THAT(Symbols, UnorderedElementsAre(qName("__foo")));
}

TEST_F(SymbolCollectorTest, Concepts) {
const char *Header = R"cpp(
template <class T>
Expand Down
9 changes: 4 additions & 5 deletions clang/lib/Driver/ToolChains/CommonArgs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1561,7 +1561,6 @@ void tools::addAsNeededOption(const ToolChain &TC,

void tools::linkSanitizerRuntimeDeps(const ToolChain &TC,
const llvm::opt::ArgList &Args,
const SanitizerArgs &SanArgs,
ArgStringList &CmdArgs) {
// Force linking against the system libraries sanitizers depends on
// (see PR15823 why this is necessary).
Expand All @@ -1588,18 +1587,18 @@ void tools::linkSanitizerRuntimeDeps(const ToolChain &TC,
// libresolv.a, even if exists, is an empty archive to satisfy POSIX -lresolv
// requirement.
if (TC.getTriple().isOSLinux() && !TC.getTriple().isAndroid() &&
!TC.getTriple().isMusl() && SanArgs.needsMsanRt())
!TC.getTriple().isMusl())
CmdArgs.push_back("-lresolv");
}

static void
collectSanitizerRuntimes(const ToolChain &TC, const ArgList &Args,
const SanitizerArgs &SanArgs,
SmallVectorImpl<StringRef> &SharedRuntimes,
SmallVectorImpl<StringRef> &StaticRuntimes,
SmallVectorImpl<StringRef> &NonWholeStaticRuntimes,
SmallVectorImpl<StringRef> &HelperStaticRuntimes,
SmallVectorImpl<StringRef> &RequiredSymbols) {
const SanitizerArgs &SanArgs = TC.getSanitizerArgs(Args);
// Collect shared runtimes.
if (SanArgs.needsSharedRt()) {
if (SanArgs.needsAsanRt()) {
Expand Down Expand Up @@ -1733,12 +1732,12 @@ collectSanitizerRuntimes(const ToolChain &TC, const ArgList &Args,
// Should be called before we add system libraries (C++ ABI, libstdc++/libc++,
// C runtime, etc). Returns true if sanitizer system deps need to be linked in.
bool tools::addSanitizerRuntimes(const ToolChain &TC, const ArgList &Args,
const SanitizerArgs &SanArgs,
ArgStringList &CmdArgs) {
const SanitizerArgs &SanArgs = TC.getSanitizerArgs(Args);
SmallVector<StringRef, 4> SharedRuntimes, StaticRuntimes,
NonWholeStaticRuntimes, HelperStaticRuntimes, RequiredSymbols;
if (SanArgs.linkRuntimes()) {
collectSanitizerRuntimes(TC, Args, SanArgs, SharedRuntimes, StaticRuntimes,
collectSanitizerRuntimes(TC, Args, SharedRuntimes, StaticRuntimes,
NonWholeStaticRuntimes, HelperStaticRuntimes,
RequiredSymbols);
}
Expand Down
2 changes: 0 additions & 2 deletions clang/lib/Driver/ToolChains/CommonArgs.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,10 @@ void addLinkerCompressDebugSectionsOption(const ToolChain &TC,
void claimNoWarnArgs(const llvm::opt::ArgList &Args);

bool addSanitizerRuntimes(const ToolChain &TC, const llvm::opt::ArgList &Args,
const SanitizerArgs &SanArgs,
llvm::opt::ArgStringList &CmdArgs);

void linkSanitizerRuntimeDeps(const ToolChain &TC,
const llvm::opt::ArgList &Args,
const SanitizerArgs &SanArgs,
llvm::opt::ArgStringList &CmdArgs);

bool addXRayRuntime(const ToolChain &TC, const llvm::opt::ArgList &Args,
Expand Down
6 changes: 2 additions & 4 deletions clang/lib/Driver/ToolChains/FreeBSD.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -297,9 +297,7 @@ void freebsd::Linker::ConstructJob(Compilation &C, const JobAction &JA,
D.getLTOMode() == LTOK_Thin);
}

const SanitizerArgs &SanArgs = ToolChain.getSanitizerArgs(Args);
bool NeedsSanitizerDeps =
addSanitizerRuntimes(ToolChain, Args, SanArgs, CmdArgs);
bool NeedsSanitizerDeps = addSanitizerRuntimes(ToolChain, Args, CmdArgs);
bool NeedsXRayDeps = addXRayRuntime(ToolChain, Args, CmdArgs);
addLinkerCompressDebugSectionsOption(ToolChain, Args, CmdArgs);
AddLinkerInputs(ToolChain, Inputs, Args, CmdArgs, JA);
Expand Down Expand Up @@ -340,7 +338,7 @@ void freebsd::Linker::ConstructJob(Compilation &C, const JobAction &JA,
}

if (NeedsSanitizerDeps)
linkSanitizerRuntimeDeps(ToolChain, Args, SanArgs, CmdArgs);
linkSanitizerRuntimeDeps(ToolChain, Args, CmdArgs);
if (NeedsXRayDeps)
linkXRayRuntimeDeps(ToolChain, Args, CmdArgs);
// FIXME: For some reason GCC passes -lgcc and -lgcc_s before adding
Expand Down
10 changes: 5 additions & 5 deletions clang/lib/Driver/ToolChains/Fuchsia.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -184,8 +184,7 @@ void fuchsia::Linker::ConstructJob(Compilation &C, const JobAction &JA,
// Note that Fuchsia never needs to link in sanitizer runtime deps. Any
// sanitizer runtimes with system dependencies use the `.deplibs` feature
// instead.
const SanitizerArgs &SanArgs = ToolChain.getSanitizerArgs(Args);
addSanitizerRuntimes(ToolChain, Args, SanArgs, CmdArgs);
addSanitizerRuntimes(ToolChain, Args, CmdArgs);

addXRayRuntime(ToolChain, Args, CmdArgs);

Expand Down Expand Up @@ -318,9 +317,10 @@ Fuchsia::Fuchsia(const Driver &D, const llvm::Triple &Triple,
Args.hasFlag(options::OPT_fexceptions, options::OPT_fno_exceptions, true);
addMultilibFlag(Exceptions, "-fexceptions", Flags);
addMultilibFlag(!Exceptions, "-fno-exceptions", Flags);
const SanitizerArgs &SanArgs = getSanitizerArgs(Args);
addMultilibFlag(SanArgs.needsAsanRt(), "-fsanitize=address", Flags);
addMultilibFlag(SanArgs.needsHwasanRt(), "-fsanitize=hwaddress", Flags);
addMultilibFlag(getSanitizerArgs(Args).needsAsanRt(), "-fsanitize=address",
Flags);
addMultilibFlag(getSanitizerArgs(Args).needsHwasanRt(),
"-fsanitize=hwaddress", Flags);

addMultilibFlag(Args.getLastArgValue(options::OPT_fcxx_abi_EQ) == "itanium",
"-fc++-abi=itanium", Flags);
Expand Down
7 changes: 2 additions & 5 deletions clang/lib/Driver/ToolChains/Gnu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
#include "clang/Driver/DriverDiagnostic.h"
#include "clang/Driver/MultilibBuilder.h"
#include "clang/Driver/Options.h"
#include "clang/Driver/SanitizerArgs.h"
#include "clang/Driver/Tool.h"
#include "clang/Driver/ToolChain.h"
#include "llvm/ADT/StringSet.h"
Expand Down Expand Up @@ -550,9 +549,7 @@ void tools::gnutools::Linker::ConstructJob(Compilation &C, const JobAction &JA,
if (Args.hasArg(options::OPT_Z_Xlinker__no_demangle))
CmdArgs.push_back("--no-demangle");

const SanitizerArgs &SanArgs = ToolChain.getSanitizerArgs(Args);
bool NeedsSanitizerDeps =
addSanitizerRuntimes(ToolChain, Args, SanArgs, CmdArgs);
bool NeedsSanitizerDeps = addSanitizerRuntimes(ToolChain, Args, CmdArgs);
bool NeedsXRayDeps = addXRayRuntime(ToolChain, Args, CmdArgs);
addLinkerCompressDebugSectionsOption(ToolChain, Args, CmdArgs);
AddLinkerInputs(ToolChain, Inputs, Args, CmdArgs, JA);
Expand Down Expand Up @@ -597,7 +594,7 @@ void tools::gnutools::Linker::ConstructJob(Compilation &C, const JobAction &JA,
CmdArgs.push_back("--start-group");

if (NeedsSanitizerDeps)
linkSanitizerRuntimeDeps(ToolChain, Args, SanArgs, CmdArgs);
linkSanitizerRuntimeDeps(ToolChain, Args, CmdArgs);

if (NeedsXRayDeps)
linkXRayRuntimeDeps(ToolChain, Args, CmdArgs);
Expand Down
9 changes: 3 additions & 6 deletions clang/lib/Driver/ToolChains/Hexagon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
#include "clang/Driver/DriverDiagnostic.h"
#include "clang/Driver/InputInfo.h"
#include "clang/Driver/Options.h"
#include "clang/Driver/SanitizerArgs.h"
#include "llvm/ADT/StringExtras.h"
#include "llvm/Option/ArgList.h"
#include "llvm/Support/FileSystem.h"
Expand Down Expand Up @@ -216,8 +215,7 @@ void hexagon::Assembler::ConstructJob(Compilation &C, const JobAction &JA,
"-mcpu=hexagon" +
toolchains::HexagonToolChain::GetTargetCPUVersion(Args)));

SanitizerArgs SanArgs = HTC.getSanitizerArgs(Args);
addSanitizerRuntimes(HTC, Args, SanArgs, CmdArgs);
addSanitizerRuntimes(HTC, Args, CmdArgs);

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

const SanitizerArgs &SanArgs = HTC.getSanitizerArgs(Args);
bool NeedsSanitizerDeps = addSanitizerRuntimes(HTC, Args, SanArgs, CmdArgs);
bool NeedsSanitizerDeps = addSanitizerRuntimes(HTC, Args, CmdArgs);
bool NeedsXRayDeps = addXRayRuntime(HTC, Args, CmdArgs);

//----------------------------------------------------------------------------
Expand Down Expand Up @@ -374,7 +371,7 @@ constructHexagonLinkArgs(Compilation &C, const JobAction &JA,

if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nodefaultlibs)) {
if (NeedsSanitizerDeps) {
linkSanitizerRuntimeDeps(HTC, Args, SanArgs, CmdArgs);
linkSanitizerRuntimeDeps(HTC, Args, CmdArgs);

if (UNW != ToolChain::UNW_None)
CmdArgs.push_back("-lunwind");
Expand Down
7 changes: 3 additions & 4 deletions clang/lib/Driver/ToolChains/NetBSD.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -274,12 +274,11 @@ void netbsd::Linker::ConstructJob(Compilation &C, const JobAction &JA,
options::OPT_s, options::OPT_t});
ToolChain.AddFilePathLibArgs(Args, CmdArgs);

const SanitizerArgs &SanArgs = ToolChain.getSanitizerArgs(Args);
bool NeedsSanitizerDeps =
addSanitizerRuntimes(ToolChain, Args, SanArgs, CmdArgs);
bool NeedsSanitizerDeps = addSanitizerRuntimes(ToolChain, Args, CmdArgs);
bool NeedsXRayDeps = addXRayRuntime(ToolChain, Args, CmdArgs);
AddLinkerInputs(ToolChain, Inputs, Args, CmdArgs, JA);

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

if (NeedsSanitizerDeps)
linkSanitizerRuntimeDeps(ToolChain, Args, SanArgs, CmdArgs);
linkSanitizerRuntimeDeps(ToolChain, Args, CmdArgs);
if (NeedsXRayDeps)
linkXRayRuntimeDeps(ToolChain, Args, CmdArgs);
if (Args.hasArg(options::OPT_pthread))
Expand Down
6 changes: 2 additions & 4 deletions clang/lib/Driver/ToolChains/OpenBSD.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -213,9 +213,7 @@ void openbsd::Linker::ConstructJob(Compilation &C, const JobAction &JA,
D.getLTOMode() == LTOK_Thin);
}

const SanitizerArgs &SanArgs = ToolChain.getSanitizerArgs(Args);
bool NeedsSanitizerDeps =
addSanitizerRuntimes(ToolChain, Args, SanArgs, CmdArgs);
bool NeedsSanitizerDeps = addSanitizerRuntimes(ToolChain, Args, CmdArgs);
bool NeedsXRayDeps = addXRayRuntime(ToolChain, Args, CmdArgs);
AddLinkerInputs(ToolChain, Inputs, Args, CmdArgs, JA);

Expand Down Expand Up @@ -253,7 +251,7 @@ void openbsd::Linker::ConstructJob(Compilation &C, const JobAction &JA,

if (NeedsSanitizerDeps) {
CmdArgs.push_back(ToolChain.getCompilerRTArgString(Args, "builtins"));
linkSanitizerRuntimeDeps(ToolChain, Args, SanArgs, CmdArgs);
linkSanitizerRuntimeDeps(ToolChain, Args, CmdArgs);
}
if (NeedsXRayDeps) {
CmdArgs.push_back(ToolChain.getCompilerRTArgString(Args, "builtins"));
Expand Down
6 changes: 3 additions & 3 deletions clang/lib/Driver/ToolChains/Solaris.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -203,8 +203,7 @@ void solaris::Linker::ConstructJob(Compilation &C, const JobAction &JA,

Args.addAllArgs(CmdArgs, {options::OPT_L, options::OPT_T_Group});

const SanitizerArgs &SA = ToolChain.getSanitizerArgs(Args);
bool NeedsSanitizerDeps = addSanitizerRuntimes(ToolChain, Args, SA, CmdArgs);
bool NeedsSanitizerDeps = addSanitizerRuntimes(ToolChain, Args, CmdArgs);
AddLinkerInputs(ToolChain, Inputs, Args, CmdArgs, JA);

if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nodefaultlibs,
Expand Down Expand Up @@ -251,8 +250,9 @@ void solaris::Linker::ConstructJob(Compilation &C, const JobAction &JA,
if (!Args.hasArg(options::OPT_shared)) {
CmdArgs.push_back("-lgcc");
}
const SanitizerArgs &SA = ToolChain.getSanitizerArgs(Args);
if (NeedsSanitizerDeps) {
linkSanitizerRuntimeDeps(ToolChain, Args, SA, CmdArgs);
linkSanitizerRuntimeDeps(ToolChain, Args, CmdArgs);

// Work around Solaris/amd64 ld bug when calling __tls_get_addr directly.
// However, ld -z relax=transtls is available since Solaris 11.2, but not
Expand Down
Loading

0 comments on commit c543643

Please sign in to comment.