Skip to content

Commit e9fa671

Browse files
authored
Merge branch 'main' into fix/92847
2 parents 1bd2f01 + 324e27e commit e9fa671

File tree

249 files changed

+14770
-3134
lines changed

Some content is hidden

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

249 files changed

+14770
-3134
lines changed

bolt/tools/driver/llvm-bolt.cpp

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -173,24 +173,14 @@ void boltMode(int argc, char **argv) {
173173
}
174174
}
175175

176-
static std::string GetExecutablePath(const char *Argv0) {
177-
SmallString<256> ExecutablePath(Argv0);
178-
// Do a PATH lookup if Argv0 isn't a valid path.
179-
if (!llvm::sys::fs::exists(ExecutablePath))
180-
if (llvm::ErrorOr<std::string> P =
181-
llvm::sys::findProgramByName(ExecutablePath))
182-
ExecutablePath = *P;
183-
return std::string(ExecutablePath);
184-
}
185-
186176
int main(int argc, char **argv) {
187177
// Print a stack trace if we signal out.
188178
sys::PrintStackTraceOnErrorSignal(argv[0]);
189179
PrettyStackTraceProgram X(argc, argv);
190180

191181
llvm_shutdown_obj Y; // Call llvm_shutdown() on exit.
192182

193-
std::string ToolPath = GetExecutablePath(argv[0]);
183+
std::string ToolPath = llvm::sys::fs::getMainExecutable(argv[0], nullptr);
194184

195185
// Initialize targets and assembly printers/parsers.
196186
llvm::InitializeAllTargetInfos();

clang/cmake/modules/AddClang.cmake

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,10 @@ macro(add_clang_library name)
138138
ARCHIVE DESTINATION lib${LLVM_LIBDIR_SUFFIX}
139139
RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}")
140140

141+
if (LLVM_ENABLE_PDB)
142+
install(FILES $<TARGET_PDB_FILE:${name}> DESTINATION "${CMAKE_INSTALL_BINDIR}" COMPONENT ${name} OPTIONAL)
143+
endif()
144+
141145
if (NOT LLVM_ENABLE_IDE)
142146
add_llvm_install_targets(install-${lib}
143147
DEPENDS ${lib}

clang/include/clang/Basic/FPOptions.def

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,5 +28,5 @@ OPTION(FPEvalMethod, LangOptions::FPEvalMethodKind, 2, AllowApproxFunc)
2828
OPTION(Float16ExcessPrecision, LangOptions::ExcessPrecisionKind, 2, FPEvalMethod)
2929
OPTION(BFloat16ExcessPrecision, LangOptions::ExcessPrecisionKind, 2, Float16ExcessPrecision)
3030
OPTION(MathErrno, bool, 1, BFloat16ExcessPrecision)
31-
OPTION(ComplexRange, LangOptions::ComplexRangeKind, 2, MathErrno)
31+
OPTION(ComplexRange, LangOptions::ComplexRangeKind, 3, MathErrno)
3232
#undef OPTION

clang/include/clang/Basic/LangOptions.def

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,7 @@ BENIGN_LANGOPT(NoSignedZero , 1, 0, "Permit Floating Point optimization wit
238238
BENIGN_LANGOPT(AllowRecip , 1, 0, "Permit Floating Point reciprocal")
239239
BENIGN_LANGOPT(ApproxFunc , 1, 0, "Permit Floating Point approximation")
240240

241-
ENUM_LANGOPT(ComplexRange, ComplexRangeKind, 2, CX_None, "Enable use of range reduction for complex arithmetics.")
241+
ENUM_LANGOPT(ComplexRange, ComplexRangeKind, 3, CX_None, "Enable use of range reduction for complex arithmetics.")
242242

243243
BENIGN_LANGOPT(ObjCGCBitmapPrint , 1, 0, "printing of GC's bitmap layout for __weak/__strong ivars")
244244

clang/include/clang/Basic/LangOptions.h

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -648,9 +648,12 @@ class LangOptions : public LangOptionsBase {
648648

649649
// Define accessors/mutators for language options of enumeration type.
650650
#define LANGOPT(Name, Bits, Default, Description)
651-
#define ENUM_LANGOPT(Name, Type, Bits, Default, Description) \
652-
Type get##Name() const { return static_cast<Type>(Name); } \
653-
void set##Name(Type Value) { Name = static_cast<unsigned>(Value); }
651+
#define ENUM_LANGOPT(Name, Type, Bits, Default, Description) \
652+
Type get##Name() const { return static_cast<Type>(Name); } \
653+
void set##Name(Type Value) { \
654+
assert(static_cast<unsigned>(Value) < (1u << Bits)); \
655+
Name = static_cast<unsigned>(Value); \
656+
}
654657
#include "clang/Basic/LangOptions.def"
655658

656659
/// Are we compiling a module?
@@ -959,11 +962,14 @@ class FPOptions {
959962
void applyChanges(FPOptionsOverride FPO);
960963

961964
// We can define most of the accessors automatically:
965+
// TODO: consider enforcing the assertion that value fits within bits
966+
// statically.
962967
#define OPTION(NAME, TYPE, WIDTH, PREVIOUS) \
963968
TYPE get##NAME() const { \
964969
return static_cast<TYPE>((Value & NAME##Mask) >> NAME##Shift); \
965970
} \
966971
void set##NAME(TYPE value) { \
972+
assert(storage_type(value) < (1u << WIDTH)); \
967973
Value = (Value & ~NAME##Mask) | (storage_type(value) << NAME##Shift); \
968974
}
969975
#include "clang/Basic/FPOptions.def"

clang/include/clang/StaticAnalyzer/Core/AnalyzerOptions.def

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -294,6 +294,16 @@ ANALYZER_OPTION(
294294
bool, ShouldUnrollLoops, "unroll-loops",
295295
"Whether the analysis should try to unroll loops with known bounds.", false)
296296

297+
ANALYZER_OPTION(
298+
bool, ShouldAssumeAtLeastOneIteration, "assume-at-least-one-iteration",
299+
"Whether the analyzer should always assume at least one iteration in "
300+
"loops where the loop condition is opaque (i.e. the analyzer cannot "
301+
"determine if it's true or false). Setting this to true eliminates some "
302+
"false positives (where e.g. a structure is nonempty, but the analyzer "
303+
"does not notice this); but it also eliminates some true positives (e.g. "
304+
"cases where a structure can be empty and this causes buggy behavior).",
305+
false)
306+
297307
ANALYZER_OPTION(
298308
bool, ShouldDisplayNotesAsEvents, "notes-as-events",
299309
"Whether the bug reporter should transparently treat extra note diagnostic "

clang/lib/AST/ByteCode/InterpBuiltin.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1683,7 +1683,7 @@ static bool interp__builtin_operator_new(InterpState &S, CodePtr OpPC,
16831683
assert(!ElemT);
16841684
// Structs etc.
16851685
const Descriptor *Desc = S.P.createDescriptor(
1686-
Call, ElemType.getTypePtr(), Descriptor::InlineDescMD,
1686+
NewCall, ElemType.getTypePtr(), Descriptor::InlineDescMD,
16871687
/*IsConst=*/false, /*IsTemporary=*/false, /*IsMutable=*/false,
16881688
/*Init=*/nullptr);
16891689

clang/lib/Driver/ToolChains/AMDGPU.cpp

Lines changed: 19 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -950,13 +950,7 @@ void ROCMToolChain::addClangTargetOptions(
950950
ABIVer))
951951
return;
952952

953-
std::tuple<bool, const SanitizerArgs> GPUSan(
954-
DriverArgs.hasFlag(options::OPT_fgpu_sanitize,
955-
options::OPT_fno_gpu_sanitize, true),
956-
getSanitizerArgs(DriverArgs));
957-
958953
bool Wave64 = isWave64(DriverArgs, Kind);
959-
960954
// TODO: There are way too many flags that change this. Do we need to check
961955
// them all?
962956
bool DAZ = DriverArgs.hasArg(options::OPT_cl_denorms_are_zero) ||
@@ -969,6 +963,12 @@ void ROCMToolChain::addClangTargetOptions(
969963
bool CorrectSqrt =
970964
DriverArgs.hasArg(options::OPT_cl_fp32_correctly_rounded_divide_sqrt);
971965

966+
// GPU Sanitizer currently only supports ASan and is enabled through host
967+
// ASan.
968+
bool GPUSan = DriverArgs.hasFlag(options::OPT_fgpu_sanitize,
969+
options::OPT_fno_gpu_sanitize, true) &&
970+
getSanitizerArgs(DriverArgs).needsAsanRt();
971+
972972
// Add the OpenCL specific bitcode library.
973973
llvm::SmallVector<BitCodeLibraryInfo, 12> BCLibs;
974974
BCLibs.emplace_back(RocmInstallation->getOpenCLPath().str());
@@ -1009,30 +1009,25 @@ llvm::SmallVector<ToolChain::BitCodeLibraryInfo, 12>
10091009
RocmInstallationDetector::getCommonBitcodeLibs(
10101010
const llvm::opt::ArgList &DriverArgs, StringRef LibDeviceFile, bool Wave64,
10111011
bool DAZ, bool FiniteOnly, bool UnsafeMathOpt, bool FastRelaxedMath,
1012-
bool CorrectSqrt, DeviceLibABIVersion ABIVer,
1013-
const std::tuple<bool, const SanitizerArgs> &GPUSan,
1014-
bool isOpenMP = false) const {
1012+
bool CorrectSqrt, DeviceLibABIVersion ABIVer, bool GPUSan,
1013+
bool isOpenMP) const {
10151014
llvm::SmallVector<ToolChain::BitCodeLibraryInfo, 12> BCLibs;
10161015

1017-
auto GPUSanEnabled = [GPUSan]() { return std::get<bool>(GPUSan); };
10181016
auto AddBCLib = [&](ToolChain::BitCodeLibraryInfo BCLib,
10191017
bool Internalize = true) {
10201018
BCLib.ShouldInternalize = Internalize;
10211019
BCLibs.emplace_back(BCLib);
10221020
};
10231021
auto AddSanBCLibs = [&]() {
1024-
if (GPUSanEnabled()) {
1025-
auto SanArgs = std::get<const SanitizerArgs>(GPUSan);
1026-
if (SanArgs.needsAsanRt())
1027-
AddBCLib(getAsanRTLPath(), false);
1028-
}
1022+
if (GPUSan)
1023+
AddBCLib(getAsanRTLPath(), false);
10291024
};
10301025

10311026
AddSanBCLibs();
10321027
AddBCLib(getOCMLPath());
10331028
if (!isOpenMP)
10341029
AddBCLib(getOCKLPath());
1035-
else if (GPUSanEnabled() && isOpenMP)
1030+
else if (GPUSan && isOpenMP)
10361031
AddBCLib(getOCKLPath(), false);
10371032
AddBCLib(getDenormalsAreZeroPath(DAZ));
10381033
AddBCLib(getUnsafeMathPath(UnsafeMathOpt || FastRelaxedMath));
@@ -1064,10 +1059,6 @@ ROCMToolChain::getCommonDeviceLibNames(const llvm::opt::ArgList &DriverArgs,
10641059
// If --hip-device-lib is not set, add the default bitcode libraries.
10651060
// TODO: There are way too many flags that change this. Do we need to check
10661061
// them all?
1067-
std::tuple<bool, const SanitizerArgs> GPUSan(
1068-
DriverArgs.hasFlag(options::OPT_fgpu_sanitize,
1069-
options::OPT_fno_gpu_sanitize, false),
1070-
getSanitizerArgs(DriverArgs));
10711062
bool DAZ = DriverArgs.hasFlag(options::OPT_fgpu_flush_denormals_to_zero,
10721063
options::OPT_fno_gpu_flush_denormals_to_zero,
10731064
getDefaultDenormsAreZeroForTarget(Kind));
@@ -1083,6 +1074,12 @@ ROCMToolChain::getCommonDeviceLibNames(const llvm::opt::ArgList &DriverArgs,
10831074
options::OPT_fno_hip_fp32_correctly_rounded_divide_sqrt, true);
10841075
bool Wave64 = isWave64(DriverArgs, Kind);
10851076

1077+
// GPU Sanitizer currently only supports ASan and is enabled through host
1078+
// ASan.
1079+
bool GPUSan = DriverArgs.hasFlag(options::OPT_fgpu_sanitize,
1080+
options::OPT_fno_gpu_sanitize, true) &&
1081+
getSanitizerArgs(DriverArgs).needsAsanRt();
1082+
10861083
return RocmInstallation->getCommonBitcodeLibs(
10871084
DriverArgs, LibDeviceFile, Wave64, DAZ, FiniteOnly, UnsafeMathOpt,
10881085
FastRelaxedMath, CorrectSqrt, ABIVer, GPUSan, isOpenMP);
@@ -1095,11 +1092,12 @@ bool AMDGPUToolChain::shouldSkipSanitizeOption(
10951092
if (TargetID.empty())
10961093
return false;
10971094
Option O = A->getOption();
1095+
10981096
if (!O.matches(options::OPT_fsanitize_EQ))
10991097
return false;
11001098

11011099
if (!DriverArgs.hasFlag(options::OPT_fgpu_sanitize,
1102-
options::OPT_fno_gpu_sanitize, false))
1100+
options::OPT_fno_gpu_sanitize, true))
11031101
return true;
11041102

11051103
auto &Diags = TC.getDriver().getDiags();

clang/lib/Driver/ToolChains/AMDGPUOpenMP.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,11 +68,18 @@ llvm::opt::DerivedArgList *AMDGPUOpenMPToolChain::TranslateArgs(
6868
Action::OffloadKind DeviceOffloadKind) const {
6969
DerivedArgList *DAL =
7070
HostTC.TranslateArgs(Args, BoundArch, DeviceOffloadKind);
71+
7172
if (!DAL)
7273
DAL = new DerivedArgList(Args.getBaseArgs());
7374

7475
const OptTable &Opts = getDriver().getOpts();
7576

77+
// Skip sanitize options passed from the HostTC. Claim them early.
78+
// The decision to sanitize device code is computed only by
79+
// 'shouldSkipSanitizeOption'.
80+
if (DAL->hasArg(options::OPT_fsanitize_EQ))
81+
DAL->claimAllArgs(options::OPT_fsanitize_EQ);
82+
7683
for (Arg *A : Args)
7784
if (!shouldSkipSanitizeOption(*this, Args, BoundArch, A) &&
7885
!llvm::is_contained(*DAL, A))

clang/lib/Driver/ToolChains/ROCm.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ class RocmInstallationDetector {
178178
const llvm::opt::ArgList &DriverArgs, StringRef LibDeviceFile,
179179
bool Wave64, bool DAZ, bool FiniteOnly, bool UnsafeMathOpt,
180180
bool FastRelaxedMath, bool CorrectSqrt, DeviceLibABIVersion ABIVer,
181-
const std::tuple<bool, const SanitizerArgs> &GPUSan, bool isOpenMP) const;
181+
bool GPUSan, bool isOpenMP) const;
182182
/// Check file paths of default bitcode libraries common to AMDGPU based
183183
/// toolchains. \returns false if there are invalid or missing files.
184184
bool checkCommonBitcodeLibs(StringRef GPUArch, StringRef LibDeviceFile,

0 commit comments

Comments
 (0)