aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDimitry Andric <dim@FreeBSD.org>2021-11-20 17:36:30 +0000
committerDimitry Andric <dim@FreeBSD.org>2021-11-20 17:36:30 +0000
commit846a2208a8ab099f595fe7e8b2e6d54a7b5e67fb (patch)
tree73c1a7a230c8bb19317a3893d937c4d8a219e91c
parentc0981da47d5696fe36474fcf86b4ce03ae3ff818 (diff)
downloadsrc-846a2208a8ab099f595fe7e8b2e6d54a7b5e67fb.tar.gz
src-846a2208a8ab099f595fe7e8b2e6d54a7b5e67fb.zip
Vendor import of llvm-project main llvmorg-14-init-10223-g401b76fdf2b3.vendor/llvm-project/llvmorg-14-init-10223-g401b76fdf2b3
-rw-r--r--clang/include/clang/AST/Redeclarable.h3
-rw-r--r--clang/include/clang/AST/Type.h6
-rw-r--r--clang/include/clang/Analysis/CFG.h2
-rw-r--r--clang/include/clang/Basic/Attr.td1
-rw-r--r--clang/include/clang/CodeGen/CGFunctionInfo.h2
-rw-r--r--clang/include/clang/Sema/Lookup.h7
-rw-r--r--clang/lib/AST/ASTContext.cpp3
-rw-r--r--clang/lib/Analysis/BodyFarm.cpp5
-rw-r--r--clang/lib/Analysis/RetainSummaryManager.cpp2
-rw-r--r--clang/lib/Basic/DiagnosticIDs.cpp2
-rw-r--r--clang/lib/Basic/SourceManager.cpp11
-rw-r--r--clang/lib/Driver/ToolChains/Clang.cpp1
-rw-r--r--clang/lib/Format/Format.cpp2
-rw-r--r--clang/lib/Frontend/FrontendActions.cpp2
-rw-r--r--clang/lib/Sema/SemaChecking.cpp7
-rw-r--r--clang/lib/Sema/SemaDecl.cpp8
-rw-r--r--clang/lib/Sema/SemaDeclCXX.cpp5
-rw-r--r--clang/lib/Sema/SemaExpr.cpp1
-rw-r--r--clang/lib/Sema/SemaExprCXX.cpp5
-rw-r--r--clang/lib/Sema/SemaLookup.cpp4
-rw-r--r--clang/lib/StaticAnalyzer/Checkers/CStringChecker.cpp6
-rw-r--r--clang/lib/StaticAnalyzer/Checkers/MIGChecker.cpp2
-rw-r--r--clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp6
-rw-r--r--clang/lib/StaticAnalyzer/Checkers/UnixAPIChecker.cpp5
-rw-r--r--clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp7
-rw-r--r--clang/lib/StaticAnalyzer/Core/ExprEngine.cpp4
-rw-r--r--clang/lib/StaticAnalyzer/Core/Store.cpp2
-rw-r--r--clang/lib/Tooling/Syntax/Tree.cpp2
-rw-r--r--clang/tools/clang-nvlink-wrapper/ClangNvlinkWrapper.cpp196
-rw-r--r--compiler-rt/lib/builtins/cpu_model.c6
-rw-r--r--libcxx/include/__algorithm/binary_search.h2
-rw-r--r--libcxx/include/__algorithm/is_heap.h4
-rw-r--r--libcxx/include/__algorithm/is_heap_until.h21
-rw-r--r--libcxx/include/__algorithm/is_sorted.h4
-rw-r--r--libcxx/include/__algorithm/is_sorted_until.h19
-rw-r--r--libcxx/include/__algorithm/max.h4
-rw-r--r--libcxx/include/__algorithm/max_element.h21
-rw-r--r--libcxx/include/__algorithm/min.h4
-rw-r--r--libcxx/include/__algorithm/min_element.h21
-rw-r--r--libcxx/include/version2
-rw-r--r--llvm/include/llvm/ExecutionEngine/JITLink/JITLinkDylib.h13
-rw-r--r--llvm/include/llvm/ExecutionEngine/Orc/Core.h10
-rw-r--r--llvm/lib/DebugInfo/DWARF/DWARFVerifier.cpp8
-rw-r--r--llvm/lib/ExecutionEngine/Orc/Core.cpp4
-rw-r--r--llvm/lib/Target/AMDGPU/MCTargetDesc/AMDGPUMCAsmInfo.cpp1
-rw-r--r--llvm/lib/Target/ARM/Thumb2SizeReduction.cpp2
-rw-r--r--llvm/lib/Target/Hexagon/HexagonMachineScheduler.cpp2
-rw-r--r--llvm/lib/Target/X86/X86ISelLowering.cpp6
-rw-r--r--llvm/lib/Transforms/Instrumentation/InstrProfiling.cpp2
-rw-r--r--llvm/lib/Transforms/Utils/CloneModule.cpp72
-rw-r--r--llvm/lib/Transforms/Utils/Evaluator.cpp5
-rw-r--r--llvm/lib/Transforms/Utils/LoopSimplify.cpp13
-rw-r--r--llvm/lib/Transforms/Utils/LoopUtils.cpp12
-rw-r--r--llvm/lib/Transforms/Utils/MetaRenamer.cpp6
-rw-r--r--llvm/lib/Transforms/Utils/VNCoercion.cpp14
55 files changed, 206 insertions, 381 deletions
diff --git a/clang/include/clang/AST/Redeclarable.h b/clang/include/clang/AST/Redeclarable.h
index 77b827c52bfb..58ec07973920 100644
--- a/clang/include/clang/AST/Redeclarable.h
+++ b/clang/include/clang/AST/Redeclarable.h
@@ -258,7 +258,8 @@ public:
redecl_iterator& operator++() {
assert(Current && "Advancing while iterator has reached end");
- // Sanity check to avoid infinite loop on invalid redecl chain.
+ // Make sure we don't infinitely loop on an invalid redecl chain. This
+ // should never happen.
if (Current->isFirstDecl()) {
if (PassedFirst) {
assert(0 && "Passed first decl twice, invalid redecl chain!");
diff --git a/clang/include/clang/AST/Type.h b/clang/include/clang/AST/Type.h
index fd25ec25d4f2..4c89c297bf34 100644
--- a/clang/include/clang/AST/Type.h
+++ b/clang/include/clang/AST/Type.h
@@ -5073,8 +5073,10 @@ public:
static void Profile(llvm::FoldingSetNodeID &ID, TemplateName Template,
QualType Deduced, bool IsDependent) {
Template.Profile(ID);
- ID.AddPointer(Deduced.getAsOpaquePtr());
- ID.AddBoolean(IsDependent);
+ QualType CanonicalType =
+ Deduced.isNull() ? Deduced : Deduced.getCanonicalType();
+ ID.AddPointer(CanonicalType.getAsOpaquePtr());
+ ID.AddBoolean(IsDependent || Template.isDependent());
}
static bool classof(const Type *T) {
diff --git a/clang/include/clang/Analysis/CFG.h b/clang/include/clang/Analysis/CFG.h
index f9223fe58a27..3b9b22e87f35 100644
--- a/clang/include/clang/Analysis/CFG.h
+++ b/clang/include/clang/Analysis/CFG.h
@@ -515,7 +515,7 @@ public:
/// of the most derived class while we're in the base class.
VirtualBaseBranch,
- /// Number of different kinds, for sanity checks. We subtract 1 so that
+ /// Number of different kinds, for validity checks. We subtract 1 so that
/// to keep receiving compiler warnings when we don't cover all enum values
/// in a switch.
NumKindsMinusOne = VirtualBaseBranch
diff --git a/clang/include/clang/Basic/Attr.td b/clang/include/clang/Basic/Attr.td
index d8f0fcd56550..39588d94cf09 100644
--- a/clang/include/clang/Basic/Attr.td
+++ b/clang/include/clang/Basic/Attr.td
@@ -2310,6 +2310,7 @@ def SwiftAttr : InheritableAttr {
let Spellings = [GNU<"swift_attr">];
let Args = [StringArgument<"Attribute">];
let Documentation = [SwiftAttrDocs];
+ let PragmaAttributeSupport = 1;
}
def SwiftBridge : InheritableAttr {
diff --git a/clang/include/clang/CodeGen/CGFunctionInfo.h b/clang/include/clang/CodeGen/CGFunctionInfo.h
index 4899c9deda6a..cd6c7e2e3128 100644
--- a/clang/include/clang/CodeGen/CGFunctionInfo.h
+++ b/clang/include/clang/CodeGen/CGFunctionInfo.h
@@ -250,7 +250,7 @@ public:
static ABIArgInfo getCoerceAndExpand(llvm::StructType *coerceToType,
llvm::Type *unpaddedCoerceToType) {
#ifndef NDEBUG
- // Sanity checks on unpaddedCoerceToType.
+ // Check that unpaddedCoerceToType has roughly the right shape.
// Assert that we only have a struct type if there are multiple elements.
auto unpaddedStruct = dyn_cast<llvm::StructType>(unpaddedCoerceToType);
diff --git a/clang/include/clang/Sema/Lookup.h b/clang/include/clang/Sema/Lookup.h
index c6edc2df5b9f..54fe7081b710 100644
--- a/clang/include/clang/Sema/Lookup.h
+++ b/clang/include/clang/Sema/Lookup.h
@@ -319,7 +319,7 @@ public:
}
LookupResultKind getResultKind() const {
- assert(sanity());
+ assert(checkDebugAssumptions());
return ResultKind;
}
@@ -706,10 +706,9 @@ private:
void addDeclsFromBasePaths(const CXXBasePaths &P);
void configure();
- // Sanity checks.
- bool sanity() const;
+ bool checkDebugAssumptions() const;
- bool sanityCheckUnresolved() const {
+ bool checkUnresolved() const {
for (iterator I = begin(), E = end(); I != E; ++I)
if (isa<UnresolvedUsingValueDecl>((*I)->getUnderlyingDecl()))
return true;
diff --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp
index f0b931bdc905..294cc20f76c5 100644
--- a/clang/lib/AST/ASTContext.cpp
+++ b/clang/lib/AST/ASTContext.cpp
@@ -5676,6 +5676,9 @@ QualType ASTContext::getDeducedTemplateSpecializationType(
auto *DTST = new (*this, TypeAlignment)
DeducedTemplateSpecializationType(Template, DeducedType, IsDependent);
+ llvm::FoldingSetNodeID TempID;
+ DTST->Profile(TempID);
+ assert(ID == TempID && "ID does not match");
Types.push_back(DTST);
DeducedTemplateSpecializationTypes.InsertNode(DTST, InsertPos);
return QualType(DTST, 0);
diff --git a/clang/lib/Analysis/BodyFarm.cpp b/clang/lib/Analysis/BodyFarm.cpp
index 49ac74c233bd..92c236ed9080 100644
--- a/clang/lib/Analysis/BodyFarm.cpp
+++ b/clang/lib/Analysis/BodyFarm.cpp
@@ -790,9 +790,8 @@ static Stmt *createObjCPropertyGetter(ASTContext &Ctx,
}
}
- // Sanity check that the property is the same type as the ivar, or a
- // reference to it, and that it is either an object pointer or trivially
- // copyable.
+ // We expect that the property is the same type as the ivar, or a reference to
+ // it, and that it is either an object pointer or trivially copyable.
if (!Ctx.hasSameUnqualifiedType(IVar->getType(),
Prop->getType().getNonReferenceType()))
return nullptr;
diff --git a/clang/lib/Analysis/RetainSummaryManager.cpp b/clang/lib/Analysis/RetainSummaryManager.cpp
index 1d7b968e994f..836e369758d3 100644
--- a/clang/lib/Analysis/RetainSummaryManager.cpp
+++ b/clang/lib/Analysis/RetainSummaryManager.cpp
@@ -791,7 +791,7 @@ RetainSummaryManager::getUnarySummary(const FunctionType* FT,
// Unary functions have no arg effects by definition.
ArgEffects ScratchArgs(AF.getEmptyMap());
- // Sanity check that this is *really* a unary function. This can
+ // Verify that this is *really* a unary function. This can
// happen if people do weird things.
const FunctionProtoType* FTP = dyn_cast<FunctionProtoType>(FT);
if (!FTP || FTP->getNumParams() != 1)
diff --git a/clang/lib/Basic/DiagnosticIDs.cpp b/clang/lib/Basic/DiagnosticIDs.cpp
index 88801c683e8d..a9f2d09924cd 100644
--- a/clang/lib/Basic/DiagnosticIDs.cpp
+++ b/clang/lib/Basic/DiagnosticIDs.cpp
@@ -692,7 +692,7 @@ void DiagnosticIDs::getAllDiagnostics(diag::Flavor Flavor,
StringRef DiagnosticIDs::getNearestOption(diag::Flavor Flavor,
StringRef Group) {
StringRef Best;
- unsigned BestDistance = Group.size() + 1; // Sanity threshold.
+ unsigned BestDistance = Group.size() + 1; // Maximum threshold.
for (const WarningOption &O : OptionTable) {
// Don't suggest ignored warning flags.
if (!O.Members && !O.SubGroups)
diff --git a/clang/lib/Basic/SourceManager.cpp b/clang/lib/Basic/SourceManager.cpp
index c2e7b684cfd8..ec3e35595bb7 100644
--- a/clang/lib/Basic/SourceManager.cpp
+++ b/clang/lib/Basic/SourceManager.cpp
@@ -59,12 +59,10 @@ unsigned ContentCache::getSizeBytesMapped() const {
/// Returns the kind of memory used to back the memory buffer for
/// this content cache. This is used for performance analysis.
llvm::MemoryBuffer::BufferKind ContentCache::getMemoryBufferKind() const {
- assert(Buffer);
-
- // Should be unreachable, but keep for sanity.
- if (!Buffer)
+ if (Buffer == nullptr) {
+ assert(0 && "Buffer should never be null");
return llvm::MemoryBuffer::MemoryBuffer_Malloc;
-
+ }
return Buffer->getBufferKind();
}
@@ -864,7 +862,6 @@ FileID SourceManager::getFileIDLocal(SourceLocation::UIntTy SLocOffset) const {
/// This function knows that the SourceLocation is in a loaded buffer, not a
/// local one.
FileID SourceManager::getFileIDLoaded(SourceLocation::UIntTy SLocOffset) const {
- // Sanity checking, otherwise a bug may lead to hanging in release build.
if (SLocOffset < CurrentLoadedOffset) {
assert(0 && "Invalid SLocOffset or bad function choice");
return FileID();
@@ -909,7 +906,6 @@ FileID SourceManager::getFileIDLoaded(SourceLocation::UIntTy SLocOffset) const {
++NumProbes;
if (E.getOffset() > SLocOffset) {
- // Sanity checking, otherwise a bug may lead to hanging in release build.
if (GreaterIndex == MiddleIndex) {
assert(0 && "binary search missed the entry");
return FileID();
@@ -925,7 +921,6 @@ FileID SourceManager::getFileIDLoaded(SourceLocation::UIntTy SLocOffset) const {
return Res;
}
- // Sanity checking, otherwise a bug may lead to hanging in release build.
if (LessIndex == MiddleIndex) {
assert(0 && "binary search missed the entry");
return FileID();
diff --git a/clang/lib/Driver/ToolChains/Clang.cpp b/clang/lib/Driver/ToolChains/Clang.cpp
index e5476e07a5cc..55518cd7926f 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -4303,7 +4303,6 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA,
const Driver &D = TC.getDriver();
ArgStringList CmdArgs;
- // Check number of inputs for sanity. We need at least one input.
assert(Inputs.size() >= 1 && "Must have at least one input.");
// CUDA/HIP compilation may have multiple inputs (source file + results of
// device-side compilations). OpenMP device jobs also take the host IR as a
diff --git a/clang/lib/Format/Format.cpp b/clang/lib/Format/Format.cpp
index 085cca8853e6..8ae29c54a762 100644
--- a/clang/lib/Format/Format.cpp
+++ b/clang/lib/Format/Format.cpp
@@ -2579,7 +2579,7 @@ tooling::Replacements sortCppIncludes(const FormatStyle &Style, StringRef Code,
// doesn't have hidden dependencies
// (http://llvm.org/docs/CodingStandards.html#include-style).
//
- // FIXME: Do some sanity checking, e.g. edit distance of the base name, to fix
+ // FIXME: Do some validation, e.g. edit distance of the base name, to fix
// cases where the first #include is unlikely to be the main header.
tooling::IncludeCategoryManager Categories(Style.IncludeStyle, FileName);
bool FirstIncludeBlock = true;
diff --git a/clang/lib/Frontend/FrontendActions.cpp b/clang/lib/Frontend/FrontendActions.cpp
index b5544afa9f24..fb8132a5e40a 100644
--- a/clang/lib/Frontend/FrontendActions.cpp
+++ b/clang/lib/Frontend/FrontendActions.cpp
@@ -842,7 +842,7 @@ void PrintPreprocessedAction::ExecuteAction() {
const char *next = (cur != end) ? cur + 1 : end;
// Limit ourselves to only scanning 256 characters into the source
- // file. This is mostly a sanity check in case the file has no
+ // file. This is mostly a check in case the file has no
// newlines whatsoever.
if (end - cur > 256)
end = cur + 256;
diff --git a/clang/lib/Sema/SemaChecking.cpp b/clang/lib/Sema/SemaChecking.cpp
index 6ffd2096cbc5..a0f6702a5f82 100644
--- a/clang/lib/Sema/SemaChecking.cpp
+++ b/clang/lib/Sema/SemaChecking.cpp
@@ -5532,8 +5532,8 @@ ExprResult Sema::BuildAtomicExpr(SourceRange CallRange, SourceRange ExprRange,
// For an arithmetic operation, the implied arithmetic must be well-formed.
if (Form == Arithmetic) {
- // gcc does not enforce these rules for GNU atomics, but we do so for
- // sanity.
+ // GCC does not enforce these rules for GNU atomics, but we do, because if
+ // we didn't it would be very confusing. FIXME: For whom? How so?
auto IsAllowedValueType = [&](QualType ValType) {
if (ValType->isIntegerType())
return true;
@@ -5574,7 +5574,8 @@ ExprResult Sema::BuildAtomicExpr(SourceRange CallRange, SourceRange ExprRange,
if (!IsC11 && !AtomTy.isTriviallyCopyableType(Context) &&
!AtomTy->isScalarType()) {
// For GNU atomics, require a trivially-copyable type. This is not part of
- // the GNU atomics specification, but we enforce it for sanity.
+ // the GNU atomics specification, but we enforce it, because if we didn't it
+ // would be very confusing. FIXME: For whom? How so?
Diag(ExprRange.getBegin(), diag::err_atomic_op_needs_trivial_copy)
<< Ptr->getType() << Ptr->getSourceRange();
return ExprError();
diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp
index 4fcc01012d44..af174ac1ca1a 100644
--- a/clang/lib/Sema/SemaDecl.cpp
+++ b/clang/lib/Sema/SemaDecl.cpp
@@ -12621,8 +12621,9 @@ void Sema::AddInitializerToDecl(Decl *RealDecl, Expr *Init, bool DirectInit) {
}
/// ActOnInitializerError - Given that there was an error parsing an
-/// initializer for the given declaration, try to return to some form
-/// of sanity.
+/// initializer for the given declaration, try to at least re-establish
+/// invariants such as whether a variable's type is either dependent or
+/// complete.
void Sema::ActOnInitializerError(Decl *D) {
// Our main concern here is re-establishing invariants like "a
// variable's type is either dependent or complete".
@@ -15997,8 +15998,7 @@ Decl *Sema::ActOnTag(Scope *S, unsigned TagSpec, TagUseKind TUK,
// It's okay to have a tag decl in the same scope as a typedef
// which hides a tag decl in the same scope. Finding this
- // insanity with a redeclaration lookup can only actually happen
- // in C++.
+ // with a redeclaration lookup can only actually happen in C++.
//
// This is also okay for elaborated-type-specifiers, which is
// technically forbidden by the current standard but which is
diff --git a/clang/lib/Sema/SemaDeclCXX.cpp b/clang/lib/Sema/SemaDeclCXX.cpp
index 20410a959cd0..2658e9698688 100644
--- a/clang/lib/Sema/SemaDeclCXX.cpp
+++ b/clang/lib/Sema/SemaDeclCXX.cpp
@@ -9172,7 +9172,8 @@ bool SpecialMemberDeletionInfo::shouldDeleteForField(FieldDecl *FD) {
}
// Don't check the implicit member of the anonymous union type.
- // This is technically non-conformant, but sanity demands it.
+ // This is technically non-conformant but supported, and we have a
+ // diagnostic for this elsewhere.
return false;
}
@@ -12256,7 +12257,7 @@ NamedDecl *Sema::BuildUsingDeclaration(
// Unlike most lookups, we don't always want to hide tag
// declarations: tag names are visible through the using declaration
// even if hidden by ordinary names, *except* in a dependent context
- // where it's important for the sanity of two-phase lookup.
+ // where they may be used by two-phase lookup.
if (!IsInstantiation)
R.setHideTags(false);
diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp
index 97f2062d4485..8592335e20d3 100644
--- a/clang/lib/Sema/SemaExpr.cpp
+++ b/clang/lib/Sema/SemaExpr.cpp
@@ -11185,7 +11185,6 @@ QualType Sema::CheckShiftOperands(ExprResult &LHS, ExprResult &RHS,
isScopedEnumerationType(RHSType)) {
return InvalidOperands(Loc, LHS, RHS);
}
- // Sanity-check shift operands
DiagnoseBadShiftValues(*this, LHS, RHS, Loc, Opc, LHSType);
// "The type of the result is that of the promoted left operand."
diff --git a/clang/lib/Sema/SemaExprCXX.cpp b/clang/lib/Sema/SemaExprCXX.cpp
index 891909c443cc..635252584562 100644
--- a/clang/lib/Sema/SemaExprCXX.cpp
+++ b/clang/lib/Sema/SemaExprCXX.cpp
@@ -1507,8 +1507,9 @@ Sema::BuildCXXTypeConstructExpr(TypeSourceInfo *TInfo,
ElemTy = Context.getBaseElementType(Ty);
}
- // There doesn't seem to be an explicit rule against this but sanity demands
- // we only construct objects with object types.
+ // Only construct objects with object types.
+ // There doesn't seem to be an explicit rule for this but functions are
+ // not objects, so they cannot take initializers.
if (Ty->isFunctionType())
return ExprError(Diag(TyBeginLoc, diag::err_init_for_function_type)
<< Ty << FullRange);
diff --git a/clang/lib/Sema/SemaLookup.cpp b/clang/lib/Sema/SemaLookup.cpp
index 05529d055621..0711e6d89383 100644
--- a/clang/lib/Sema/SemaLookup.cpp
+++ b/clang/lib/Sema/SemaLookup.cpp
@@ -324,14 +324,14 @@ void LookupResult::configure() {
}
}
-bool LookupResult::sanity() const {
+bool LookupResult::checkDebugAssumptions() const {
// This function is never called by NDEBUG builds.
assert(ResultKind != NotFound || Decls.size() == 0);
assert(ResultKind != Found || Decls.size() == 1);
assert(ResultKind != FoundOverloaded || Decls.size() > 1 ||
(Decls.size() == 1 &&
isa<FunctionTemplateDecl>((*begin())->getUnderlyingDecl())));
- assert(ResultKind != FoundUnresolvedValue || sanityCheckUnresolved());
+ assert(ResultKind != FoundUnresolvedValue || checkUnresolved());
assert(ResultKind != Ambiguous || Decls.size() > 1 ||
(Decls.size() == 1 && (Ambiguity == AmbiguousBaseSubobjects ||
Ambiguity == AmbiguousBaseSubobjectTypes)));
diff --git a/clang/lib/StaticAnalyzer/Checkers/CStringChecker.cpp b/clang/lib/StaticAnalyzer/Checkers/CStringChecker.cpp
index 475cee9ce04b..6955efe8e6c2 100644
--- a/clang/lib/StaticAnalyzer/Checkers/CStringChecker.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/CStringChecker.cpp
@@ -1517,7 +1517,7 @@ void CStringChecker::evalStrcat(CheckerContext &C, const CallExpr *CE) const {
}
void CStringChecker::evalStrncat(CheckerContext &C, const CallExpr *CE) const {
- //char *strncat(char *restrict s1, const char *restrict s2, size_t n);
+ // char *strncat(char *restrict s1, const char *restrict s2, size_t n);
evalStrcpyCommon(C, CE,
/* ReturnEnd = */ false,
/* IsBounded = */ true,
@@ -2069,8 +2069,8 @@ void CStringChecker::evalStrcmpCommon(CheckerContext &C, const CallExpr *CE,
}
void CStringChecker::evalStrsep(CheckerContext &C, const CallExpr *CE) const {
- //char *strsep(char **stringp, const char *delim);
- // Sanity: does the search string parameter match the return type?
+ // char *strsep(char **stringp, const char *delim);
+ // Verify whether the search string parameter matches the return type.
SourceArgExpr SearchStrPtr = {CE->getArg(0), 0};
QualType CharPtrTy = SearchStrPtr.Expression->getType()->getPointeeType();
diff --git a/clang/lib/StaticAnalyzer/Checkers/MIGChecker.cpp b/clang/lib/StaticAnalyzer/Checkers/MIGChecker.cpp
index 5bf96acc0462..139bc0e99d78 100644
--- a/clang/lib/StaticAnalyzer/Checkers/MIGChecker.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/MIGChecker.cpp
@@ -160,7 +160,7 @@ static bool isInMIGCall(CheckerContext &C) {
if (Optional<AnyCall> AC = AnyCall::forDecl(D)) {
// Even though there's a Sema warning when the return type of an annotated
// function is not a kern_return_t, this warning isn't an error, so we need
- // an extra sanity check here.
+ // an extra check here.
// FIXME: AnyCall doesn't support blocks yet, so they remain unchecked
// for now.
if (!AC->getReturnType(C.getASTContext())
diff --git a/clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp b/clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
index e8b963a535d8..5a8edcabda71 100644
--- a/clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
@@ -155,7 +155,7 @@ class StdLibraryFunctionsChecker
protected:
ArgNo ArgN; // Argument to which we apply the constraint.
- /// Do polymorphic sanity check on the constraint.
+ /// Do polymorphic validation check on the constraint.
virtual bool checkSpecificValidity(const FunctionDecl *FD) const {
return true;
}
@@ -527,8 +527,8 @@ class StdLibraryFunctionsChecker
}
private:
- // Once we know the exact type of the function then do sanity check on all
- // the given constraints.
+ // Once we know the exact type of the function then do validation check on
+ // all the given constraints.
bool validateByConstraints(const FunctionDecl *FD) const {
for (const ConstraintSet &Case : CaseConstraints)
for (const ValueConstraintPtr &Constraint : Case)
diff --git a/clang/lib/StaticAnalyzer/Checkers/UnixAPIChecker.cpp b/clang/lib/StaticAnalyzer/Checkers/UnixAPIChecker.cpp
index 2244cdb96d4f..41adc36b021a 100644
--- a/clang/lib/StaticAnalyzer/Checkers/UnixAPIChecker.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/UnixAPIChecker.cpp
@@ -182,8 +182,7 @@ void UnixAPIMisuseChecker::CheckOpenVariant(CheckerContext &C,
ProgramStateRef state = C.getState();
if (CE->getNumArgs() < MinArgCount) {
- // The frontend should issue a warning for this case, so this is a sanity
- // check.
+ // The frontend should issue a warning for this case. Just return.
return;
} else if (CE->getNumArgs() == MaxArgCount) {
const Expr *Arg = CE->getArg(CreateModeArgIndex);
@@ -366,7 +365,7 @@ void UnixAPIPortabilityChecker::BasicAllocationCheck(CheckerContext &C,
const unsigned numArgs,
const unsigned sizeArg,
const char *fn) const {
- // Sanity check for the correct number of arguments
+ // Check for the correct number of arguments.
if (CE->getNumArgs() != numArgs)
return;
diff --git a/clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp b/clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
index 8774dc3323ab..b957bec7493e 100644
--- a/clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
+++ b/clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
@@ -1670,9 +1670,10 @@ PathDiagnosticPieceRef TrackConstraintBRVisitor::VisitNode(
if (isUnderconstrained(PrevN)) {
IsSatisfied = true;
- // As a sanity check, make sure that the negation of the constraint
- // was infeasible in the current state. If it is feasible, we somehow
- // missed the transition point.
+ // At this point, the negation of the constraint should be infeasible. If it
+ // is feasible, make sure that the negation of the constrainti was
+ // infeasible in the current state. If it is feasible, we somehow missed
+ // the transition point.
assert(!isUnderconstrained(N));
// We found the transition point for the constraint. We now need to
diff --git a/clang/lib/StaticAnalyzer/Core/ExprEngine.cpp b/clang/lib/StaticAnalyzer/Core/ExprEngine.cpp
index 12b005d43c55..a170ef3885b2 100644
--- a/clang/lib/StaticAnalyzer/Core/ExprEngine.cpp
+++ b/clang/lib/StaticAnalyzer/Core/ExprEngine.cpp
@@ -326,8 +326,8 @@ ProgramStateRef ExprEngine::createTemporaryRegionIfNeeded(
}
Result = InitWithAdjustments;
} else {
- // We need to create a region no matter what. For sanity, make sure we don't
- // try to stuff a Loc into a non-pointer temporary region.
+ // We need to create a region no matter what. Make sure we don't try to
+ // stuff a Loc into a non-pointer temporary region.
assert(!InitValWithAdjustments.getAs<Loc>() ||
Loc::isLocType(Result->getType()) ||
Result->getType()->isMemberPointerType());
diff --git a/clang/lib/StaticAnalyzer/Core/Store.cpp b/clang/lib/StaticAnalyzer/Core/Store.cpp
index 3cc0cd224d7a..05feb1325c93 100644
--- a/clang/lib/StaticAnalyzer/Core/Store.cpp
+++ b/clang/lib/StaticAnalyzer/Core/Store.cpp
@@ -249,7 +249,7 @@ static bool regionMatchesCXXRecordType(SVal V, QualType Ty) {
}
SVal StoreManager::evalDerivedToBase(SVal Derived, const CastExpr *Cast) {
- // Sanity check to avoid doing the wrong thing in the face of
+ // Early return to avoid doing the wrong thing in the face of
// reinterpret_cast.
if (!regionMatchesCXXRecordType(Derived, Cast->getSubExpr()->getType()))
return UnknownVal();
diff --git a/clang/lib/Tooling/Syntax/Tree.cpp b/clang/lib/Tooling/Syntax/Tree.cpp
index 07ee13e313f5..1e3a90f3a316 100644
--- a/clang/lib/Tooling/Syntax/Tree.cpp
+++ b/clang/lib/Tooling/Syntax/Tree.cpp
@@ -126,7 +126,7 @@ void syntax::Tree::replaceChildRangeLowLevel(Node *Begin, Node *End,
for (auto *N = New; N; N = N->NextSibling) {
assert(N->Parent == nullptr);
assert(N->getRole() != NodeRole::Detached && "Roles must be set");
- // FIXME: sanity-check the role.
+ // FIXME: validate the role.
}
auto Reachable = [](Node *From, Node *N) {
diff --git a/clang/tools/clang-nvlink-wrapper/ClangNvlinkWrapper.cpp b/clang/tools/clang-nvlink-wrapper/ClangNvlinkWrapper.cpp
deleted file mode 100644
index bc5b9a9f1fde..000000000000
--- a/clang/tools/clang-nvlink-wrapper/ClangNvlinkWrapper.cpp
+++ /dev/null
@@ -1,196 +0,0 @@
-//===-- clang-nvlink-wrapper/ClangNvlinkWrapper.cpp - wrapper over nvlink-===//
-//
-// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-//
-//===---------------------------------------------------------------------===//
-///
-/// \file
-/// This tool works as a wrapper over nvlink program. It transparently passes
-/// every input option and objects to nvlink except archive files. It reads
-/// each input archive file to extract archived cubin files as temporary files.
-/// These temp (*.cubin) files are passed to nvlink, because nvlink does not
-/// support linking of archive files implicitly.
-///
-/// During linking of heterogeneous device archive libraries, the
-/// clang-offload-bundler creates a device specific archive of cubin files.
-/// Such an archive is then passed to this tool to extract cubin files before
-/// passing to nvlink.
-///
-/// Example:
-/// clang-nvlink-wrapper -o a.out-openmp-nvptx64 /tmp/libTest-nvptx-sm_50.a
-///
-/// 1. Extract (libTest-nvptx-sm_50.a) => /tmp/a.cubin /tmp/b.cubin
-/// 2. nvlink -o a.out-openmp-nvptx64 /tmp/a.cubin /tmp/b.cubin
-//===---------------------------------------------------------------------===//
-
-#include "clang/Basic/Version.h"
-#include "llvm/Object/Archive.h"
-#include "llvm/Support/CommandLine.h"
-#include "llvm/Support/Errc.h"
-#include "llvm/Support/FileSystem.h"
-#include "llvm/Support/MemoryBuffer.h"
-#include "llvm/Support/Path.h"
-#include "llvm/Support/Program.h"
-#include "llvm/Support/Signals.h"
-#include "llvm/Support/StringSaver.h"
-#include "llvm/Support/WithColor.h"
-#include "llvm/Support/raw_ostream.h"
-
-using namespace llvm;
-
-static cl::opt<bool> Help("h", cl::desc("Alias for -help"), cl::Hidden);
-
-// Mark all our options with this category, everything else (except for -help)
-// will be hidden.
-static cl::OptionCategory
- ClangNvlinkWrapperCategory("clang-nvlink-wrapper options");
-
-static cl::opt<std::string> NvlinkUserPath("nvlink-path",
- cl::desc("Path of nvlink binary"),
- cl::cat(ClangNvlinkWrapperCategory));
-
-// Do not parse nvlink options
-static cl::list<std::string>
- NVArgs(cl::Sink, cl::desc("<options to be passed to nvlink>..."));
-
-static Error runNVLink(std::string NVLinkPath,
- SmallVectorImpl<std::string> &Args) {
- std::vector<StringRef> NVLArgs;
- NVLArgs.push_back(NVLinkPath);
- for (auto &Arg : Args) {
- NVLArgs.push_back(Arg);
- }
-
- if (sys::ExecuteAndWait(NVLinkPath.c_str(), NVLArgs))
- return createStringError(inconvertibleErrorCode(), "'nvlink' failed");
- return Error::success();
-}
-
-static Error extractArchiveFiles(StringRef Filename,
- SmallVectorImpl<std::string> &Args,
- SmallVectorImpl<std::string> &TmpFiles) {
- std::vector<std::unique_ptr<MemoryBuffer>> ArchiveBuffers;
-
- ErrorOr<std::unique_ptr<MemoryBuffer>> BufOrErr =
- MemoryBuffer::getFileOrSTDIN(Filename, false, false);
- if (std::error_code EC = BufOrErr.getError())
- return createFileError(Filename, EC);
-
- ArchiveBuffers.push_back(std::move(*BufOrErr));
- Expected<std::unique_ptr<llvm::object::Archive>> LibOrErr =
- object::Archive::create(ArchiveBuffers.back()->getMemBufferRef());
- if (!LibOrErr)
- return LibOrErr.takeError();
-
- auto Archive = std::move(*LibOrErr);
-
- Error Err = Error::success();
- auto ChildEnd = Archive->child_end();
- for (auto ChildIter = Archive->child_begin(Err); ChildIter != ChildEnd;
- ++ChildIter) {
- if (Err)
- return Err;
- auto ChildNameOrErr = (*ChildIter).getName();
- if (!ChildNameOrErr)
- return ChildNameOrErr.takeError();
-
- StringRef ChildName = sys::path::filename(ChildNameOrErr.get());
-
- auto ChildBufferRefOrErr = (*ChildIter).getMemoryBufferRef();
- if (!ChildBufferRefOrErr)
- return ChildBufferRefOrErr.takeError();
-
- auto ChildBuffer =
- MemoryBuffer::getMemBuffer(ChildBufferRefOrErr.get(), false);
- auto ChildNameSplit = ChildName.split('.');
-
- SmallString<16> Path;
- int FileDesc;
- if (std::error_code EC = sys::fs::createTemporaryFile(
- (ChildNameSplit.first), (ChildNameSplit.second), FileDesc, Path))
- return createFileError(ChildName, EC);
-
- std::string TmpFileName(Path.str());
- Args.push_back(TmpFileName);
- TmpFiles.push_back(TmpFileName);
- std::error_code EC;
- raw_fd_ostream OS(Path.c_str(), EC, sys::fs::OF_None);
- if (EC)
- return createFileError(TmpFileName, errc::io_error);
- OS << ChildBuffer->getBuffer();
- OS.close();
- }
- return Err;
-}
-
-static Error cleanupTmpFiles(SmallVectorImpl<std::string> &TmpFiles) {
- for (auto &TmpFile : TmpFiles) {
- if (std::error_code EC = sys::fs::remove(TmpFile))
- return createFileError(TmpFile, errc::no_such_file_or_directory);
- }
- return Error::success();
-}
-
-static void PrintVersion(raw_ostream &OS) {
- OS << clang::getClangToolFullVersion("clang-nvlink-wrapper") << '\n';
-}
-
-int main(int argc, const char **argv) {
- sys::PrintStackTraceOnErrorSignal(argv[0]);
- cl::SetVersionPrinter(PrintVersion);
- cl::HideUnrelatedOptions(ClangNvlinkWrapperCategory);
- cl::ParseCommandLineOptions(
- argc, argv,
- "A wrapper tool over nvlink program. It transparently passes every \n"
- "input option and objects to nvlink except archive files and path of \n"
- "nvlink binary. It reads each input archive file to extract archived \n"
- "cubin files as temporary files.\n");
-
- if (Help) {
- cl::PrintHelpMessage();
- return 0;
- }
-
- auto reportError = [argv](Error E) {
- logAllUnhandledErrors(std::move(E), WithColor::error(errs(), argv[0]));
- exit(1);
- };
-
- std::string NvlinkPath;
- SmallVector<const char *, 0> Argv(argv, argv + argc);
- SmallVector<std::string, 0> ArgvSubst;
- SmallVector<std::string, 0> TmpFiles;
- BumpPtrAllocator Alloc;
- StringSaver Saver(Alloc);
- cl::ExpandResponseFiles(Saver, cl::TokenizeGNUCommandLine, Argv);
-
- for (const std::string &Arg : NVArgs) {
- if (sys::path::extension(Arg) == ".a") {
- if (Error Err = extractArchiveFiles(Arg, ArgvSubst, TmpFiles))
- reportError(std::move(Err));
- } else {
- ArgvSubst.push_back(Arg);
- }
- }
-
- NvlinkPath = NvlinkUserPath;
-
- // If user hasn't specified nvlink binary then search it in PATH
- if (NvlinkPath.empty()) {
- ErrorOr<std::string> NvlinkPathErr = sys::findProgramByName("nvlink");
- if (!NvlinkPathErr) {
- reportError(createStringError(NvlinkPathErr.getError(),
- "unable to find 'nvlink' in path"));
- }
- NvlinkPath = NvlinkPathErr.get();
- }
-
- if (Error Err = runNVLink(NvlinkPath, ArgvSubst))
- reportError(std::move(Err));
- if (Error Err = cleanupTmpFiles(TmpFiles))
- reportError(std::move(Err));
-
- return 0;
-}
diff --git a/compiler-rt/lib/builtins/cpu_model.c b/compiler-rt/lib/builtins/cpu_model.c
index b8d807ed651c..53e2d89708dc 100644
--- a/compiler-rt/lib/builtins/cpu_model.c
+++ b/compiler-rt/lib/builtins/cpu_model.c
@@ -799,8 +799,14 @@ _Bool __aarch64_have_lse_atomics
#define HWCAP_ATOMICS (1 << 8)
#endif
static void CONSTRUCTOR_ATTRIBUTE init_have_lse_atomics(void) {
+#if defined(__FreeBSD__)
+ unsigned long hwcap;
+ int result = elf_aux_info(AT_HWCAP, &hwcap, sizeof hwcap);
+ __aarch64_have_lse_atomics = result == 0 && (hwcap & HWCAP_ATOMICS) != 0;
+#else
unsigned long hwcap = getauxval(AT_HWCAP);
__aarch64_have_lse_atomics = (hwcap & HWCAP_ATOMICS) != 0;
+#endif
}
#endif // defined(__has_include)
#endif // __has_include(<sys/auxv.h>)
diff --git a/libcxx/include/__algorithm/binary_search.h b/libcxx/include/__algorithm/binary_search.h
index cd1d7b1a752d..8fc55b9becb1 100644
--- a/libcxx/include/__algorithm/binary_search.h
+++ b/libcxx/include/__algorithm/binary_search.h
@@ -11,8 +11,8 @@
#include <__config>
#include <__algorithm/comp.h>
-#include <__algorithm/lower_bound.h>
#include <__algorithm/comp_ref_type.h>
+#include <__algorithm/lower_bound.h>
#include <__iterator/iterator_traits.h>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
diff --git a/libcxx/include/__algorithm/is_heap.h b/libcxx/include/__algorithm/is_heap.h
index 7fd5d6ff9a00..22c27a66d129 100644
--- a/libcxx/include/__algorithm/is_heap.h
+++ b/libcxx/include/__algorithm/is_heap.h
@@ -11,6 +11,7 @@
#include <__config>
#include <__algorithm/comp.h>
+#include <__algorithm/comp_ref_type.h>
#include <__algorithm/is_heap_until.h>
#include <__iterator/iterator_traits.h>
@@ -26,7 +27,8 @@ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
bool
is_heap(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp)
{
- return _VSTD::is_heap_until(__first, __last, __comp) == __last;
+ typedef typename __comp_ref_type<_Compare>::type _Comp_ref;
+ return _VSTD::__is_heap_until<_Comp_ref>(__first, __last, __comp) == __last;
}
template<class _RandomAccessIterator>
diff --git a/libcxx/include/__algorithm/is_heap_until.h b/libcxx/include/__algorithm/is_heap_until.h
index 99291c102bfc..dd8a62f07fd3 100644
--- a/libcxx/include/__algorithm/is_heap_until.h
+++ b/libcxx/include/__algorithm/is_heap_until.h
@@ -11,6 +11,7 @@
#include <__config>
#include <__algorithm/comp.h>
+#include <__algorithm/comp_ref_type.h>
#include <__iterator/iterator_traits.h>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
@@ -19,9 +20,9 @@
_LIBCPP_BEGIN_NAMESPACE_STD
-template <class _RandomAccessIterator, class _Compare>
-_LIBCPP_NODISCARD_EXT _LIBCPP_CONSTEXPR_AFTER_CXX17 _RandomAccessIterator
-is_heap_until(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp)
+template <class _Compare, class _RandomAccessIterator>
+_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 _RandomAccessIterator
+__is_heap_until(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp)
{
typedef typename iterator_traits<_RandomAccessIterator>::difference_type difference_type;
difference_type __len = __last - __first;
@@ -46,13 +47,19 @@ is_heap_until(_RandomAccessIterator __first, _RandomAccessIterator __last, _Comp
return __last;
}
+template <class _RandomAccessIterator, class _Compare>
+_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 _RandomAccessIterator
+is_heap_until(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp)
+{
+ typedef typename __comp_ref_type<_Compare>::type _Comp_ref;
+ return _VSTD::__is_heap_until<_Comp_ref>(__first, __last, __comp);
+}
+
template<class _RandomAccessIterator>
-_LIBCPP_NODISCARD_EXT inline
-_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
-_RandomAccessIterator
+_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 _RandomAccessIterator
is_heap_until(_RandomAccessIterator __first, _RandomAccessIterator __last)
{
- return _VSTD::is_heap_until(__first, __last, __less<typename iterator_traits<_RandomAccessIterator>::value_type>());
+ return _VSTD::__is_heap_until(__first, __last, __less<typename iterator_traits<_RandomAccessIterator>::value_type>());
}
_LIBCPP_END_NAMESPACE_STD
diff --git a/libcxx/include/__algorithm/is_sorted.h b/libcxx/include/__algorithm/is_sorted.h
index c6954934e8c0..57953295a888 100644
--- a/libcxx/include/__algorithm/is_sorted.h
+++ b/libcxx/include/__algorithm/is_sorted.h
@@ -10,6 +10,7 @@
#define _LIBCPP___ALGORITHM_IS_SORTED_H
#include <__algorithm/comp.h>
+#include <__algorithm/comp_ref_type.h>
#include <__algorithm/is_sorted_until.h>
#include <__config>
#include <__iterator/iterator_traits.h>
@@ -26,7 +27,8 @@ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
bool
is_sorted(_ForwardIterator __first, _ForwardIterator __last, _Compare __comp)
{
- return _VSTD::is_sorted_until(__first, __last, __comp) == __last;
+ typedef typename __comp_ref_type<_Compare>::type _Comp_ref;
+ return _VSTD::__is_sorted_until<_Comp_ref>(__first, __last, __comp) == __last;
}
template<class _ForwardIterator>
diff --git a/libcxx/include/__algorithm/is_sorted_until.h b/libcxx/include/__algorithm/is_sorted_until.h
index 5b6385991a74..9a7f275c5400 100644
--- a/libcxx/include/__algorithm/is_sorted_until.h
+++ b/libcxx/include/__algorithm/is_sorted_until.h
@@ -11,6 +11,7 @@
#include <__config>
#include <__algorithm/comp.h>
+#include <__algorithm/comp_ref_type.h>
#include <__iterator/iterator_traits.h>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
@@ -19,9 +20,9 @@
_LIBCPP_BEGIN_NAMESPACE_STD
-template <class _ForwardIterator, class _Compare>
-_LIBCPP_NODISCARD_EXT _LIBCPP_CONSTEXPR_AFTER_CXX17 _ForwardIterator
-is_sorted_until(_ForwardIterator __first, _ForwardIterator __last, _Compare __comp)
+template <class _Compare, class _ForwardIterator>
+_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 _ForwardIterator
+__is_sorted_until(_ForwardIterator __first, _ForwardIterator __last, _Compare __comp)
{
if (__first != __last)
{
@@ -36,10 +37,16 @@ is_sorted_until(_ForwardIterator __first, _ForwardIterator __last, _Compare __co
return __last;
}
+template <class _ForwardIterator, class _Compare>
+_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 _ForwardIterator
+is_sorted_until(_ForwardIterator __first, _ForwardIterator __last, _Compare __comp)
+{
+ typedef typename __comp_ref_type<_Compare>::type _Comp_ref;
+ return _VSTD::__is_sorted_until<_Comp_ref>(__first, __last, __comp);
+}
+
template<class _ForwardIterator>
-_LIBCPP_NODISCARD_EXT inline
-_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
-_ForwardIterator
+_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 _ForwardIterator
is_sorted_until(_ForwardIterator __first, _ForwardIterator __last)
{
return _VSTD::is_sorted_until(__first, __last, __less<typename iterator_traits<_ForwardIterator>::value_type>());
diff --git a/libcxx/include/__algorithm/max.h b/libcxx/include/__algorithm/max.h
index 2fa97cad87f6..79cbd2be86b6 100644
--- a/libcxx/include/__algorithm/max.h
+++ b/libcxx/include/__algorithm/max.h
@@ -11,6 +11,7 @@
#include <__config>
#include <__algorithm/comp.h>
+#include <__algorithm/comp_ref_type.h>
#include <__algorithm/max_element.h>
#include <initializer_list>
@@ -49,7 +50,8 @@ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
_Tp
max(initializer_list<_Tp> __t, _Compare __comp)
{
- return *_VSTD::max_element(__t.begin(), __t.end(), __comp);
+ typedef typename __comp_ref_type<_Compare>::type _Comp_ref;
+ return *_VSTD::__max_element<_Comp_ref>(__t.begin(), __t.end(), __comp);
}
template<class _Tp>
diff --git a/libcxx/include/__algorithm/max_element.h b/libcxx/include/__algorithm/max_element.h
index c51519605af9..f932ca7049fa 100644
--- a/libcxx/include/__algorithm/max_element.h
+++ b/libcxx/include/__algorithm/max_element.h
@@ -11,6 +11,7 @@
#include <__config>
#include <__algorithm/comp.h>
+#include <__algorithm/comp_ref_type.h>
#include <__iterator/iterator_traits.h>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
@@ -19,11 +20,9 @@
_LIBCPP_BEGIN_NAMESPACE_STD
-template <class _ForwardIterator, class _Compare>
-_LIBCPP_NODISCARD_EXT inline
-_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
-_ForwardIterator
-max_element(_ForwardIterator __first, _ForwardIterator __last, _Compare __comp)
+template <class _Compare, class _ForwardIterator>
+inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 _ForwardIterator
+__max_element(_ForwardIterator __first, _ForwardIterator __last, _Compare __comp)
{
static_assert(__is_cpp17_forward_iterator<_ForwardIterator>::value,
"std::max_element requires a ForwardIterator");
@@ -37,11 +36,17 @@ max_element(_ForwardIterator __first, _ForwardIterator __last, _Compare __comp)
return __first;
}
+template <class _ForwardIterator, class _Compare>
+_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 _ForwardIterator
+max_element(_ForwardIterator __first, _ForwardIterator __last, _Compare __comp)
+{
+ typedef typename __comp_ref_type<_Compare>::type _Comp_ref;
+ return _VSTD::__max_element<_Comp_ref>(__first, __last, __comp);
+}
+
template <class _ForwardIterator>
-_LIBCPP_NODISCARD_EXT inline
-_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
-_ForwardIterator
+_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 _ForwardIterator
max_element(_ForwardIterator __first, _ForwardIterator __last)
{
return _VSTD::max_element(__first, __last,
diff --git a/libcxx/include/__algorithm/min.h b/libcxx/include/__algorithm/min.h
index 9fea7f70a2bb..5cacb2f28e7e 100644
--- a/libcxx/include/__algorithm/min.h
+++ b/libcxx/include/__algorithm/min.h
@@ -11,6 +11,7 @@
#include <__config>
#include <__algorithm/comp.h>
+#include <__algorithm/comp_ref_type.h>
#include <__algorithm/min_element.h>
#include <initializer_list>
@@ -49,7 +50,8 @@ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
_Tp
min(initializer_list<_Tp> __t, _Compare __comp)
{
- return *_VSTD::min_element(__t.begin(), __t.end(), __comp);
+ typedef typename __comp_ref_type<_Compare>::type _Comp_ref;
+ return *_VSTD::__min_element<_Comp_ref>(__t.begin(), __t.end(), __comp);
}
template<class _Tp>
diff --git a/libcxx/include/__algorithm/min_element.h b/libcxx/include/__algorithm/min_element.h
index 9bfd0793c69d..3aebebca91ab 100644
--- a/libcxx/include/__algorithm/min_element.h
+++ b/libcxx/include/__algorithm/min_element.h
@@ -11,6 +11,7 @@
#include <__config>
#include <__algorithm/comp.h>
+#include <__algorithm/comp_ref_type.h>
#include <__iterator/iterator_traits.h>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
@@ -19,11 +20,9 @@
_LIBCPP_BEGIN_NAMESPACE_STD
-template <class _ForwardIterator, class _Compare>
-_LIBCPP_NODISCARD_EXT inline
-_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
-_ForwardIterator
-min_element(_ForwardIterator __first, _ForwardIterator __last, _Compare __comp)
+template <class _Compare, class _ForwardIterator>
+inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 _ForwardIterator
+__min_element(_ForwardIterator __first, _ForwardIterator __last, _Compare __comp)
{
static_assert(__is_cpp17_forward_iterator<_ForwardIterator>::value,
"std::min_element requires a ForwardIterator");
@@ -37,10 +36,16 @@ min_element(_ForwardIterator __first, _ForwardIterator __last, _Compare __comp)
return __first;
}
+template <class _ForwardIterator, class _Compare>
+_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 _ForwardIterator
+min_element(_ForwardIterator __first, _ForwardIterator __last, _Compare __comp)
+{
+ typedef typename __comp_ref_type<_Compare>::type _Comp_ref;
+ return _VSTD::__min_element<_Comp_ref>(__first, __last, __comp);
+}
+
template <class _ForwardIterator>
-_LIBCPP_NODISCARD_EXT inline
-_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
-_ForwardIterator
+_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 _ForwardIterator
min_element(_ForwardIterator __first, _ForwardIterator __last)
{
return _VSTD::min_element(__first, __last,
diff --git a/libcxx/include/version b/libcxx/include/version
index d2286f5e8207..7c16ac85e430 100644
--- a/libcxx/include/version
+++ b/libcxx/include/version
@@ -149,7 +149,7 @@ __cpp_lib_syncbuf 201803L <syncstream>
__cpp_lib_three_way_comparison 201907L <compare>
__cpp_lib_to_address 201711L <memory>
__cpp_lib_to_array 201907L <array>
-__cpp_lib_to_chars 201611L <utility>
+__cpp_lib_to_chars 201611L <charconv>
__cpp_lib_to_underlying 202102L <utility>
__cpp_lib_transformation_trait_aliases 201304L <type_traits>
__cpp_lib_transparent_operators 201510L <functional> <memory>
diff --git a/llvm/include/llvm/ExecutionEngine/JITLink/JITLinkDylib.h b/llvm/include/llvm/ExecutionEngine/JITLink/JITLinkDylib.h
index 2aa88cb50074..6bb1b5a285b1 100644
--- a/llvm/include/llvm/ExecutionEngine/JITLink/JITLinkDylib.h
+++ b/llvm/include/llvm/ExecutionEngine/JITLink/JITLinkDylib.h
@@ -13,10 +13,21 @@
#ifndef LLVM_EXECUTIONENGINE_JITLINK_JITLINKDYLIB_H
#define LLVM_EXECUTIONENGINE_JITLINK_JITLINKDYLIB_H
+#include <string>
+
namespace llvm {
namespace jitlink {
-class JITLinkDylib {};
+class JITLinkDylib {
+public:
+ JITLinkDylib(std::string Name) : Name(std::move(Name)) {}
+
+ /// Get the name for this JITLinkDylib.
+ const std::string &getName() const { return Name; }
+
+private:
+ std::string Name;
+};
} // end namespace jitlink
} // end namespace llvm
diff --git a/llvm/include/llvm/ExecutionEngine/Orc/Core.h b/llvm/include/llvm/ExecutionEngine/Orc/Core.h
index 5cac65b49a05..362e8ab8e296 100644
--- a/llvm/include/llvm/ExecutionEngine/Orc/Core.h
+++ b/llvm/include/llvm/ExecutionEngine/Orc/Core.h
@@ -927,17 +927,11 @@ class JITDylib : public ThreadSafeRefCountedBase<JITDylib>,
friend class MaterializationResponsibility;
public:
- using AsynchronousSymbolQuerySet =
- std::set<std::shared_ptr<AsynchronousSymbolQuery>>;
-
JITDylib(const JITDylib &) = delete;
JITDylib &operator=(const JITDylib &) = delete;
JITDylib(JITDylib &&) = delete;
JITDylib &operator=(JITDylib &&) = delete;
- /// Get the name for this JITDylib.
- const std::string &getName() const { return JITDylibName; }
-
/// Get a reference to the ExecutionSession for this JITDylib.
ExecutionSession &getExecutionSession() const { return ES; }
@@ -1070,6 +1064,9 @@ public:
std::vector<JITDylibSP> getReverseDFSLinkOrder();
private:
+ using AsynchronousSymbolQuerySet =
+ std::set<std::shared_ptr<AsynchronousSymbolQuery>>;
+
using AsynchronousSymbolQueryList =
std::vector<std::shared_ptr<AsynchronousSymbolQuery>>;
@@ -1200,7 +1197,6 @@ private:
failSymbols(FailedSymbolsWorklist);
ExecutionSession &ES;
- std::string JITDylibName;
std::mutex GeneratorsMutex;
bool Open = true;
SymbolTable Symbols;
diff --git a/llvm/lib/DebugInfo/DWARF/DWARFVerifier.cpp b/llvm/lib/DebugInfo/DWARF/DWARFVerifier.cpp
index dcabefb9896e..fb0798f204e1 100644
--- a/llvm/lib/DebugInfo/DWARF/DWARFVerifier.cpp
+++ b/llvm/lib/DebugInfo/DWARF/DWARFVerifier.cpp
@@ -1289,16 +1289,14 @@ DWARFVerifier::verifyNameIndexAbbrevs(const DWARFDebugNames::NameIndex &NI) {
static SmallVector<StringRef, 2> getNames(const DWARFDie &DIE,
bool IncludeLinkageName = true) {
SmallVector<StringRef, 2> Result;
- if (const char *Str = DIE.getName(DINameKind::ShortName))
+ if (const char *Str = DIE.getShortName())
Result.emplace_back(Str);
else if (DIE.getTag() == dwarf::DW_TAG_namespace)
Result.emplace_back("(anonymous namespace)");
if (IncludeLinkageName) {
- if (const char *Str = DIE.getName(DINameKind::LinkageName)) {
- if (Result.empty() || Result[0] != Str)
- Result.emplace_back(Str);
- }
+ if (const char *Str = DIE.getLinkageName())
+ Result.emplace_back(Str);
}
return Result;
diff --git a/llvm/lib/ExecutionEngine/Orc/Core.cpp b/llvm/lib/ExecutionEngine/Orc/Core.cpp
index 64e5090e4c53..6b24d6461b63 100644
--- a/llvm/lib/ExecutionEngine/Orc/Core.cpp
+++ b/llvm/lib/ExecutionEngine/Orc/Core.cpp
@@ -1364,7 +1364,7 @@ Error JITDylib::remove(const SymbolNameSet &Names) {
void JITDylib::dump(raw_ostream &OS) {
ES.runSessionLocked([&, this]() {
- OS << "JITDylib \"" << JITDylibName << "\" (ES: "
+ OS << "JITDylib \"" << getName() << "\" (ES: "
<< format("0x%016" PRIx64, reinterpret_cast<uintptr_t>(&ES)) << "):\n"
<< "Link order: " << LinkOrder << "\n"
<< "Symbol table:\n";
@@ -1450,7 +1450,7 @@ JITDylib::MaterializingInfo::takeQueriesMeeting(SymbolState RequiredState) {
}
JITDylib::JITDylib(ExecutionSession &ES, std::string Name)
- : ES(ES), JITDylibName(std::move(Name)) {
+ : JITLinkDylib(std::move(Name)), ES(ES) {
LinkOrder.push_back({this, JITDylibLookupFlags::MatchAllSymbols});
}
diff --git a/llvm/lib/Target/AMDGPU/MCTargetDesc/AMDGPUMCAsmInfo.cpp b/llvm/lib/Target/AMDGPU/MCTargetDesc/AMDGPUMCAsmInfo.cpp
index 5c728bd86817..7708579a4491 100644
--- a/llvm/lib/Target/AMDGPU/MCTargetDesc/AMDGPUMCAsmInfo.cpp
+++ b/llvm/lib/Target/AMDGPU/MCTargetDesc/AMDGPUMCAsmInfo.cpp
@@ -28,7 +28,6 @@ AMDGPUMCAsmInfo::AMDGPUMCAsmInfo(const Triple &TT,
MaxInstLength = (TT.getArch() == Triple::amdgcn) ? 20 : 16;
SeparatorString = "\n";
CommentString = ";";
- PrivateLabelPrefix = "";
InlineAsmStart = ";#ASMSTART";
InlineAsmEnd = ";#ASMEND";
diff --git a/llvm/lib/Target/ARM/Thumb2SizeReduction.cpp b/llvm/lib/Target/ARM/Thumb2SizeReduction.cpp
index 0f7e19038673..132516694f4e 100644
--- a/llvm/lib/Target/ARM/Thumb2SizeReduction.cpp
+++ b/llvm/lib/Target/ARM/Thumb2SizeReduction.cpp
@@ -718,7 +718,7 @@ Thumb2SizeReduce::ReduceSpecial(MachineBasicBlock &MBB, MachineInstr *MI,
case ARM::t2CMPrr: {
// Try to reduce to the lo-reg only version first. Why there are two
// versions of the instruction is a mystery.
- // It would be nice to just have two entries in the master table that
+ // It would be nice to just have two entries in the main table that
// are prioritized, but the table assumes a unique entry for each
// source insn opcode. So for now, we hack a local entry record to use.
static const ReduceEntry NarrowEntry =
diff --git a/llvm/lib/Target/Hexagon/HexagonMachineScheduler.cpp b/llvm/lib/Target/Hexagon/HexagonMachineScheduler.cpp
index 47bebf77b31b..60d58f421bbb 100644
--- a/llvm/lib/Target/Hexagon/HexagonMachineScheduler.cpp
+++ b/llvm/lib/Target/Hexagon/HexagonMachineScheduler.cpp
@@ -121,7 +121,7 @@ bool VLIWResourceModel::isResourceAvailable(SUnit *SU, bool IsTop) {
const auto &QII = *QST.getInstrInfo();
// Now see if there are no other dependencies to instructions already
- // in the packet.
+ // in the packet.
if (IsTop) {
for (unsigned i = 0, e = Packet.size(); i != e; ++i)
if (hasDependence(Packet[i], SU, QII))
diff --git a/llvm/lib/Target/X86/X86ISelLowering.cpp b/llvm/lib/Target/X86/X86ISelLowering.cpp
index dba0321d9431..17d14053d804 100644
--- a/llvm/lib/Target/X86/X86ISelLowering.cpp
+++ b/llvm/lib/Target/X86/X86ISelLowering.cpp
@@ -44004,7 +44004,11 @@ static SDValue combineSetCCMOVMSK(SDValue EFLAGS, X86::CondCode &CC,
// signbits extend down to all the sub-elements as well.
// Calling MOVMSK with the wider type, avoiding the bitcast, helps expose
// potential SimplifyDemandedBits/Elts cases.
- if (Vec.getOpcode() == ISD::BITCAST) {
+ // If we looked through a truncate that discard bits, we can't do this
+ // transform.
+ // FIXME: We could do this transform for truncates that discarded bits by
+ // inserting an AND mask between the new MOVMSK and the CMP.
+ if (Vec.getOpcode() == ISD::BITCAST && NumElts <= CmpBits) {
SDValue BC = peekThroughBitcasts(Vec);
MVT BCVT = BC.getSimpleValueType();
unsigned BCNumElts = BCVT.getVectorNumElements();
diff --git a/llvm/lib/Transforms/Instrumentation/InstrProfiling.cpp b/llvm/lib/Transforms/Instrumentation/InstrProfiling.cpp
index ad21fec269ec..36a66e096382 100644
--- a/llvm/lib/Transforms/Instrumentation/InstrProfiling.cpp
+++ b/llvm/lib/Transforms/Instrumentation/InstrProfiling.cpp
@@ -692,7 +692,7 @@ void InstrProfiling::lowerIncrement(InstrProfIncrementInst *Inc) {
IRBuilder<> Builder(Inc);
uint64_t Index = Inc->getIndex()->getZExtValue();
- Value *Addr = Builder.CreateConstInBoundsGEP2_64(Counters->getValueType(),
+ Value *Addr = Builder.CreateConstInBoundsGEP2_32(Counters->getValueType(),
Counters, 0, Index);
if (isRuntimeCounterRelocationEnabled()) {
diff --git a/llvm/lib/Transforms/Utils/CloneModule.cpp b/llvm/lib/Transforms/Utils/CloneModule.cpp
index eb226b9b246d..200deca4b317 100644
--- a/llvm/lib/Transforms/Utils/CloneModule.cpp
+++ b/llvm/lib/Transforms/Utils/CloneModule.cpp
@@ -58,17 +58,13 @@ std::unique_ptr<Module> llvm::CloneModule(
// new module. Here we add them to the VMap and to the new Module. We
// don't worry about attributes or initializers, they will come later.
//
- for (Module::const_global_iterator I = M.global_begin(), E = M.global_end();
- I != E; ++I) {
- GlobalVariable *GV = new GlobalVariable(*New,
- I->getValueType(),
- I->isConstant(), I->getLinkage(),
- (Constant*) nullptr, I->getName(),
- (GlobalVariable*) nullptr,
- I->getThreadLocalMode(),
- I->getType()->getAddressSpace());
- GV->copyAttributesFrom(&*I);
- VMap[&*I] = GV;
+ for (const GlobalVariable &I : M.globals()) {
+ GlobalVariable *NewGV = new GlobalVariable(
+ *New, I.getValueType(), I.isConstant(), I.getLinkage(),
+ (Constant *)nullptr, I.getName(), (GlobalVariable *)nullptr,
+ I.getThreadLocalMode(), I.getType()->getAddressSpace());
+ NewGV->copyAttributesFrom(&I);
+ VMap[&I] = NewGV;
}
// Loop over the functions in the module, making external functions as before
@@ -81,34 +77,33 @@ std::unique_ptr<Module> llvm::CloneModule(
}
// Loop over the aliases in the module
- for (Module::const_alias_iterator I = M.alias_begin(), E = M.alias_end();
- I != E; ++I) {
- if (!ShouldCloneDefinition(&*I)) {
+ for (const GlobalAlias &I : M.aliases()) {
+ if (!ShouldCloneDefinition(&I)) {
// An alias cannot act as an external reference, so we need to create
// either a function or a global variable depending on the value type.
// FIXME: Once pointee types are gone we can probably pick one or the
// other.
GlobalValue *GV;
- if (I->getValueType()->isFunctionTy())
- GV = Function::Create(cast<FunctionType>(I->getValueType()),
- GlobalValue::ExternalLinkage,
- I->getAddressSpace(), I->getName(), New.get());
+ if (I.getValueType()->isFunctionTy())
+ GV = Function::Create(cast<FunctionType>(I.getValueType()),
+ GlobalValue::ExternalLinkage, I.getAddressSpace(),
+ I.getName(), New.get());
else
- GV = new GlobalVariable(
- *New, I->getValueType(), false, GlobalValue::ExternalLinkage,
- nullptr, I->getName(), nullptr,
- I->getThreadLocalMode(), I->getType()->getAddressSpace());
- VMap[&*I] = GV;
+ GV = new GlobalVariable(*New, I.getValueType(), false,
+ GlobalValue::ExternalLinkage, nullptr,
+ I.getName(), nullptr, I.getThreadLocalMode(),
+ I.getType()->getAddressSpace());
+ VMap[&I] = GV;
// We do not copy attributes (mainly because copying between different
// kinds of globals is forbidden), but this is generally not required for
// correctness.
continue;
}
- auto *GA = GlobalAlias::create(I->getValueType(),
- I->getType()->getPointerAddressSpace(),
- I->getLinkage(), I->getName(), New.get());
- GA->copyAttributesFrom(&*I);
- VMap[&*I] = GA;
+ auto *GA = GlobalAlias::create(I.getValueType(),
+ I.getType()->getPointerAddressSpace(),
+ I.getLinkage(), I.getName(), New.get());
+ GA->copyAttributesFrom(&I);
+ VMap[&I] = GA;
}
// Now that all of the things that global variable initializer can refer to
@@ -153,10 +148,9 @@ std::unique_ptr<Module> llvm::CloneModule(
}
Function::arg_iterator DestI = F->arg_begin();
- for (Function::const_arg_iterator J = I.arg_begin(); J != I.arg_end();
- ++J) {
- DestI->setName(J->getName());
- VMap[&*J] = &*DestI++;
+ for (const Argument &J : I.args()) {
+ DestI->setName(J.getName());
+ VMap[&J] = &*DestI++;
}
SmallVector<ReturnInst *, 8> Returns; // Ignore returns cloned.
@@ -170,21 +164,17 @@ std::unique_ptr<Module> llvm::CloneModule(
}
// And aliases
- for (Module::const_alias_iterator I = M.alias_begin(), E = M.alias_end();
- I != E; ++I) {
+ for (const GlobalAlias &I : M.aliases()) {
// We already dealt with undefined aliases above.
- if (!ShouldCloneDefinition(&*I))
+ if (!ShouldCloneDefinition(&I))
continue;
- GlobalAlias *GA = cast<GlobalAlias>(VMap[&*I]);
- if (const Constant *C = I->getAliasee())
+ GlobalAlias *GA = cast<GlobalAlias>(VMap[&I]);
+ if (const Constant *C = I.getAliasee())
GA->setAliasee(MapValue(C, VMap));
}
// And named metadata....
- for (Module::const_named_metadata_iterator I = M.named_metadata_begin(),
- E = M.named_metadata_end();
- I != E; ++I) {
- const NamedMDNode &NMD = *I;
+ for (const NamedMDNode &NMD : M.named_metadata()) {
NamedMDNode *NewNMD = New->getOrInsertNamedMetadata(NMD.getName());
for (unsigned i = 0, e = NMD.getNumOperands(); i != e; ++i)
NewNMD->addOperand(MapMetadata(NMD.getOperand(i), VMap));
diff --git a/llvm/lib/Transforms/Utils/Evaluator.cpp b/llvm/lib/Transforms/Utils/Evaluator.cpp
index 9c8aed94708e..91630d876fc8 100644
--- a/llvm/lib/Transforms/Utils/Evaluator.cpp
+++ b/llvm/lib/Transforms/Utils/Evaluator.cpp
@@ -285,9 +285,8 @@ bool Evaluator::getFormalParams(CallBase &CB, Function *F,
}
auto ArgI = CB.arg_begin();
- for (auto ParI = FTy->param_begin(), ParE = FTy->param_end(); ParI != ParE;
- ++ParI) {
- auto *ArgC = ConstantFoldLoadThroughBitcast(getVal(*ArgI), *ParI, DL);
+ for (Type *PTy : FTy->params()) {
+ auto *ArgC = ConstantFoldLoadThroughBitcast(getVal(*ArgI), PTy, DL);
if (!ArgC) {
LLVM_DEBUG(dbgs() << "Can not convert function argument.\n");
return false;
diff --git a/llvm/lib/Transforms/Utils/LoopSimplify.cpp b/llvm/lib/Transforms/Utils/LoopSimplify.cpp
index d14c006c8032..67311ab4cd02 100644
--- a/llvm/lib/Transforms/Utils/LoopSimplify.cpp
+++ b/llvm/lib/Transforms/Utils/LoopSimplify.cpp
@@ -293,9 +293,8 @@ static Loop *separateNestedLoop(Loop *L, BasicBlock *Preheader,
// L is now a subloop of our outer loop.
NewOuter->addChildLoop(L);
- for (Loop::block_iterator I = L->block_begin(), E = L->block_end();
- I != E; ++I)
- NewOuter->addBlockEntry(*I);
+ for (BasicBlock *BB : L->blocks())
+ NewOuter->addBlockEntry(BB);
// Now reset the header in L, which had been moved by
// SplitBlockPredecessors for the outer loop.
@@ -496,12 +495,12 @@ ReprocessLoop:
// predecessors that are not in the loop. This is not valid for natural
// loops, but can occur if the blocks are unreachable. Since they are
// unreachable we can just shamelessly delete those CFG edges!
- for (Loop::block_iterator BB = L->block_begin(), E = L->block_end();
- BB != E; ++BB) {
- if (*BB == L->getHeader()) continue;
+ for (BasicBlock *BB : L->blocks()) {
+ if (BB == L->getHeader())
+ continue;
SmallPtrSet<BasicBlock*, 4> BadPreds;
- for (BasicBlock *P : predecessors(*BB))
+ for (BasicBlock *P : predecessors(BB))
if (!L->contains(P))
BadPreds.insert(P);
diff --git a/llvm/lib/Transforms/Utils/LoopUtils.cpp b/llvm/lib/Transforms/Utils/LoopUtils.cpp
index f0f079335683..68572d479742 100644
--- a/llvm/lib/Transforms/Utils/LoopUtils.cpp
+++ b/llvm/lib/Transforms/Utils/LoopUtils.cpp
@@ -663,9 +663,8 @@ void llvm::deleteDeadLoop(Loop *L, DominatorTree *DT, ScalarEvolution *SE,
// about ordering because we already dropped the references.
// NOTE: This iteration is safe because erasing the block does not remove
// its entry from the loop's block list. We do that in the next section.
- for (Loop::block_iterator LpI = L->block_begin(), LpE = L->block_end();
- LpI != LpE; ++LpI)
- (*LpI)->eraseFromParent();
+ for (BasicBlock *BB : L->blocks())
+ BB->eraseFromParent();
// Finally, the blocks from loopinfo. This has to happen late because
// otherwise our loop iterators won't work.
@@ -1501,10 +1500,9 @@ Loop *llvm::cloneLoop(Loop *L, Loop *PL, ValueToValueMapTy &VM,
LPM->addLoop(New);
// Add all of the blocks in L to the new loop.
- for (Loop::block_iterator I = L->block_begin(), E = L->block_end();
- I != E; ++I)
- if (LI->getLoopFor(*I) == L)
- New.addBasicBlockToLoop(cast<BasicBlock>(VM[*I]), *LI);
+ for (BasicBlock *BB : L->blocks())
+ if (LI->getLoopFor(BB) == L)
+ New.addBasicBlockToLoop(cast<BasicBlock>(VM[BB]), *LI);
// Add all of the subloops to the new loop.
for (Loop *I : *L)
diff --git a/llvm/lib/Transforms/Utils/MetaRenamer.cpp b/llvm/lib/Transforms/Utils/MetaRenamer.cpp
index b1965cf2becb..3ce10535d45f 100644
--- a/llvm/lib/Transforms/Utils/MetaRenamer.cpp
+++ b/llvm/lib/Transforms/Utils/MetaRenamer.cpp
@@ -92,12 +92,12 @@ void MetaRename(Module &M,
Renamer renamer(randSeed);
// Rename all aliases
- for (auto AI = M.alias_begin(), AE = M.alias_end(); AI != AE; ++AI) {
- StringRef Name = AI->getName();
+ for (GlobalAlias &GA : M.aliases()) {
+ StringRef Name = GA.getName();
if (Name.startswith("llvm.") || (!Name.empty() && Name[0] == 1))
continue;
- AI->setName("alias");
+ GA.setName("alias");
}
// Rename all global variables
diff --git a/llvm/lib/Transforms/Utils/VNCoercion.cpp b/llvm/lib/Transforms/Utils/VNCoercion.cpp
index dbe3cc93e72b..bbe6b3dc23b3 100644
--- a/llvm/lib/Transforms/Utils/VNCoercion.cpp
+++ b/llvm/lib/Transforms/Utils/VNCoercion.cpp
@@ -201,19 +201,7 @@ static int analyzeLoadFromClobberingWrite(Type *LoadTy, Value *LoadPtr,
// (issue a smaller load then merge the bits in) but this seems unlikely to be
// valuable.
if (StoreOffset > LoadOffset ||
- StoreOffset + StoreSize < LoadOffset + LoadSize)
- return -1;
-
- // If the load and store are to the exact same address, they should have been
- // a must alias. AA must have gotten confused.
- // FIXME: Study to see if/when this happens. One case is forwarding a memset
- // to a load from the base of the memset.
-
- // If the load and store don't overlap at all, the store doesn't provide
- // anything to the load. In this case, they really don't alias at all, AA
- // must have gotten confused. The if statement above ensure the condition
- // that StoreOffset <= LoadOffset.
- if (StoreOffset + int64_t(StoreSize) <= LoadOffset)
+ StoreOffset + int64_t(StoreSize) < LoadOffset + int64_t(LoadSize))
return -1;
// Okay, we can do this transformation. Return the number of bytes into the