Merge llvm-project 13.0.0 release

This updates llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and
openmp to llvmorg-13.0.0-0-gd7b669b3a303, aka 13.0.0 release.

PR:		258209
MFC after:	2 weeks
This commit is contained in:
Dimitry Andric 2021-09-26 13:33:13 +02:00
commit 28a41182c0
25 changed files with 154 additions and 151 deletions

View File

@ -1804,30 +1804,30 @@ class DeclContext {
ObjCContainerDeclBitfields ObjCContainerDeclBits; ObjCContainerDeclBitfields ObjCContainerDeclBits;
LinkageSpecDeclBitfields LinkageSpecDeclBits; LinkageSpecDeclBitfields LinkageSpecDeclBits;
BlockDeclBitfields BlockDeclBits; BlockDeclBitfields BlockDeclBits;
};
static_assert(sizeof(DeclContextBitfields) <= 8, static_assert(sizeof(DeclContextBitfields) <= 8,
"DeclContextBitfields is larger than 8 bytes!"); "DeclContextBitfields is larger than 8 bytes!");
static_assert(sizeof(TagDeclBitfields) <= 8, static_assert(sizeof(TagDeclBitfields) <= 8,
"TagDeclBitfields is larger than 8 bytes!"); "TagDeclBitfields is larger than 8 bytes!");
static_assert(sizeof(EnumDeclBitfields) <= 8, static_assert(sizeof(EnumDeclBitfields) <= 8,
"EnumDeclBitfields is larger than 8 bytes!"); "EnumDeclBitfields is larger than 8 bytes!");
static_assert(sizeof(RecordDeclBitfields) <= 8, static_assert(sizeof(RecordDeclBitfields) <= 8,
"RecordDeclBitfields is larger than 8 bytes!"); "RecordDeclBitfields is larger than 8 bytes!");
static_assert(sizeof(OMPDeclareReductionDeclBitfields) <= 8, static_assert(sizeof(OMPDeclareReductionDeclBitfields) <= 8,
"OMPDeclareReductionDeclBitfields is larger than 8 bytes!"); "OMPDeclareReductionDeclBitfields is larger than 8 bytes!");
static_assert(sizeof(FunctionDeclBitfields) <= 8, static_assert(sizeof(FunctionDeclBitfields) <= 8,
"FunctionDeclBitfields is larger than 8 bytes!"); "FunctionDeclBitfields is larger than 8 bytes!");
static_assert(sizeof(CXXConstructorDeclBitfields) <= 8, static_assert(sizeof(CXXConstructorDeclBitfields) <= 8,
"CXXConstructorDeclBitfields is larger than 8 bytes!"); "CXXConstructorDeclBitfields is larger than 8 bytes!");
static_assert(sizeof(ObjCMethodDeclBitfields) <= 8, static_assert(sizeof(ObjCMethodDeclBitfields) <= 8,
"ObjCMethodDeclBitfields is larger than 8 bytes!"); "ObjCMethodDeclBitfields is larger than 8 bytes!");
static_assert(sizeof(ObjCContainerDeclBitfields) <= 8, static_assert(sizeof(ObjCContainerDeclBitfields) <= 8,
"ObjCContainerDeclBitfields is larger than 8 bytes!"); "ObjCContainerDeclBitfields is larger than 8 bytes!");
static_assert(sizeof(LinkageSpecDeclBitfields) <= 8, static_assert(sizeof(LinkageSpecDeclBitfields) <= 8,
"LinkageSpecDeclBitfields is larger than 8 bytes!"); "LinkageSpecDeclBitfields is larger than 8 bytes!");
static_assert(sizeof(BlockDeclBitfields) <= 8, static_assert(sizeof(BlockDeclBitfields) <= 8,
"BlockDeclBitfields is larger than 8 bytes!"); "BlockDeclBitfields is larger than 8 bytes!");
};
/// FirstDecl - The first declaration stored within this declaration /// FirstDecl - The first declaration stored within this declaration
/// context. /// context.

View File

@ -1804,40 +1804,6 @@ class alignas(8) Type : public ExtQualsTypeCommonBase {
PackExpansionTypeBitfields PackExpansionTypeBits; PackExpansionTypeBitfields PackExpansionTypeBits;
}; };
static_assert(sizeof(TypeBitfields) <= 8,
"TypeBitfields is larger than 8 bytes!");
static_assert(sizeof(ArrayTypeBitfields) <= 8,
"ArrayTypeBitfields is larger than 8 bytes!");
static_assert(sizeof(AttributedTypeBitfields) <= 8,
"AttributedTypeBitfields is larger than 8 bytes!");
static_assert(sizeof(AutoTypeBitfields) <= 8,
"AutoTypeBitfields is larger than 8 bytes!");
static_assert(sizeof(BuiltinTypeBitfields) <= 8,
"BuiltinTypeBitfields is larger than 8 bytes!");
static_assert(sizeof(FunctionTypeBitfields) <= 8,
"FunctionTypeBitfields is larger than 8 bytes!");
static_assert(sizeof(ObjCObjectTypeBitfields) <= 8,
"ObjCObjectTypeBitfields is larger than 8 bytes!");
static_assert(sizeof(ReferenceTypeBitfields) <= 8,
"ReferenceTypeBitfields is larger than 8 bytes!");
static_assert(sizeof(TypeWithKeywordBitfields) <= 8,
"TypeWithKeywordBitfields is larger than 8 bytes!");
static_assert(sizeof(ElaboratedTypeBitfields) <= 8,
"ElaboratedTypeBitfields is larger than 8 bytes!");
static_assert(sizeof(VectorTypeBitfields) <= 8,
"VectorTypeBitfields is larger than 8 bytes!");
static_assert(sizeof(SubstTemplateTypeParmPackTypeBitfields) <= 8,
"SubstTemplateTypeParmPackTypeBitfields is larger"
" than 8 bytes!");
static_assert(sizeof(TemplateSpecializationTypeBitfields) <= 8,
"TemplateSpecializationTypeBitfields is larger"
" than 8 bytes!");
static_assert(sizeof(DependentTemplateSpecializationTypeBitfields) <= 8,
"DependentTemplateSpecializationTypeBitfields is larger"
" than 8 bytes!");
static_assert(sizeof(PackExpansionTypeBitfields) <= 8,
"PackExpansionTypeBitfields is larger than 8 bytes");
private: private:
template <class T> friend class TypePropertyCache; template <class T> friend class TypePropertyCache;

View File

@ -298,8 +298,8 @@ class alignas(8) InitializedEntity {
/// Create the initialization entity for the result of a function. /// Create the initialization entity for the result of a function.
static InitializedEntity InitializeResult(SourceLocation ReturnLoc, static InitializedEntity InitializeResult(SourceLocation ReturnLoc,
QualType Type, bool NRVO) { QualType Type) {
return InitializedEntity(EK_Result, ReturnLoc, Type, NRVO); return InitializedEntity(EK_Result, ReturnLoc, Type);
} }
static InitializedEntity InitializeStmtExprResult(SourceLocation ReturnLoc, static InitializedEntity InitializeStmtExprResult(SourceLocation ReturnLoc,
@ -308,20 +308,20 @@ class alignas(8) InitializedEntity {
} }
static InitializedEntity InitializeBlock(SourceLocation BlockVarLoc, static InitializedEntity InitializeBlock(SourceLocation BlockVarLoc,
QualType Type, bool NRVO) { QualType Type) {
return InitializedEntity(EK_BlockElement, BlockVarLoc, Type, NRVO); return InitializedEntity(EK_BlockElement, BlockVarLoc, Type);
} }
static InitializedEntity InitializeLambdaToBlock(SourceLocation BlockVarLoc, static InitializedEntity InitializeLambdaToBlock(SourceLocation BlockVarLoc,
QualType Type, bool NRVO) { QualType Type) {
return InitializedEntity(EK_LambdaToBlockConversionBlockElement, return InitializedEntity(EK_LambdaToBlockConversionBlockElement,
BlockVarLoc, Type, NRVO); BlockVarLoc, Type);
} }
/// Create the initialization entity for an exception object. /// Create the initialization entity for an exception object.
static InitializedEntity InitializeException(SourceLocation ThrowLoc, static InitializedEntity InitializeException(SourceLocation ThrowLoc,
QualType Type, bool NRVO) { QualType Type) {
return InitializedEntity(EK_Exception, ThrowLoc, Type, NRVO); return InitializedEntity(EK_Exception, ThrowLoc, Type);
} }
/// Create the initialization entity for an object allocated via new. /// Create the initialization entity for an object allocated via new.

View File

@ -9934,10 +9934,19 @@ bool RecordExprEvaluator::VisitCXXConstructExpr(const CXXConstructExpr *E,
return false; return false;
// Avoid materializing a temporary for an elidable copy/move constructor. // Avoid materializing a temporary for an elidable copy/move constructor.
if (E->isElidable() && !ZeroInit) if (E->isElidable() && !ZeroInit) {
if (const MaterializeTemporaryExpr *ME // FIXME: This only handles the simplest case, where the source object
= dyn_cast<MaterializeTemporaryExpr>(E->getArg(0))) // is passed directly as the first argument to the constructor.
// This should also handle stepping though implicit casts and
// and conversion sequences which involve two steps, with a
// conversion operator followed by a converting constructor.
const Expr *SrcObj = E->getArg(0);
assert(SrcObj->isTemporaryObject(Info.Ctx, FD->getParent()));
assert(Info.Ctx.hasSameUnqualifiedType(E->getType(), SrcObj->getType()));
if (const MaterializeTemporaryExpr *ME =
dyn_cast<MaterializeTemporaryExpr>(SrcObj))
return Visit(ME->getSubExpr()); return Visit(ME->getSubExpr());
}
if (ZeroInit && !ZeroInitialization(E, T)) if (ZeroInit && !ZeroInitialization(E, T))
return false; return false;

View File

@ -1050,7 +1050,7 @@ class ThreadSafetyAnalyzer {
const CFGBlock* PredBlock, const CFGBlock* PredBlock,
const CFGBlock *CurrBlock); const CFGBlock *CurrBlock);
bool join(const FactEntry &a, const FactEntry &b); bool join(const FactEntry &a, const FactEntry &b, bool CanModify);
void intersectAndWarn(FactSet &EntrySet, const FactSet &ExitSet, void intersectAndWarn(FactSet &EntrySet, const FactSet &ExitSet,
SourceLocation JoinLoc, LockErrorKind EntryLEK, SourceLocation JoinLoc, LockErrorKind EntryLEK,
@ -2188,25 +2188,28 @@ void BuildLockset::VisitDeclStmt(const DeclStmt *S) {
} }
} }
/// Given two facts merging on a join point, decide whether to warn and which /// Given two facts merging on a join point, possibly warn and decide whether to
/// one to keep. /// keep or replace.
/// ///
/// \return false if we should keep \p A, true if we should keep \p B. /// \param CanModify Whether we can replace \p A by \p B.
bool ThreadSafetyAnalyzer::join(const FactEntry &A, const FactEntry &B) { /// \return false if we should keep \p A, true if we should take \p B.
bool ThreadSafetyAnalyzer::join(const FactEntry &A, const FactEntry &B,
bool CanModify) {
if (A.kind() != B.kind()) { if (A.kind() != B.kind()) {
// For managed capabilities, the destructor should unlock in the right mode // For managed capabilities, the destructor should unlock in the right mode
// anyway. For asserted capabilities no unlocking is needed. // anyway. For asserted capabilities no unlocking is needed.
if ((A.managed() || A.asserted()) && (B.managed() || B.asserted())) { if ((A.managed() || A.asserted()) && (B.managed() || B.asserted())) {
// The shared capability subsumes the exclusive capability. // The shared capability subsumes the exclusive capability, if possible.
return B.kind() == LK_Shared; bool ShouldTakeB = B.kind() == LK_Shared;
} else { if (CanModify || !ShouldTakeB)
Handler.handleExclusiveAndShared("mutex", B.toString(), B.loc(), A.loc()); return ShouldTakeB;
// Take the exclusive capability to reduce further warnings.
return B.kind() == LK_Exclusive;
} }
Handler.handleExclusiveAndShared("mutex", B.toString(), B.loc(), A.loc());
// Take the exclusive capability to reduce further warnings.
return CanModify && B.kind() == LK_Exclusive;
} else { } else {
// The non-asserted capability is the one we want to track. // The non-asserted capability is the one we want to track.
return A.asserted() && !B.asserted(); return CanModify && A.asserted() && !B.asserted();
} }
} }
@ -2237,8 +2240,8 @@ void ThreadSafetyAnalyzer::intersectAndWarn(FactSet &EntrySet,
FactSet::iterator EntryIt = EntrySet.findLockIter(FactMan, ExitFact); FactSet::iterator EntryIt = EntrySet.findLockIter(FactMan, ExitFact);
if (EntryIt != EntrySet.end()) { if (EntryIt != EntrySet.end()) {
if (join(FactMan[*EntryIt], ExitFact) && if (join(FactMan[*EntryIt], ExitFact,
EntryLEK == LEK_LockedSomePredecessors) EntryLEK != LEK_LockedSomeLoopIterations))
*EntryIt = Fact; *EntryIt = Fact;
} else if (!ExitFact.managed()) { } else if (!ExitFact.managed()) {
ExitFact.handleRemovalFromIntersection(ExitSet, FactMan, JoinLoc, ExitFact.handleRemovalFromIntersection(ExitSet, FactMan, JoinLoc,

View File

@ -609,15 +609,18 @@ CodeGenFunction::EmitCXXConstructExpr(const CXXConstructExpr *E,
return; return;
// Elide the constructor if we're constructing from a temporary. // Elide the constructor if we're constructing from a temporary.
// The temporary check is required because Sema sets this on NRVO
// returns.
if (getLangOpts().ElideConstructors && E->isElidable()) { if (getLangOpts().ElideConstructors && E->isElidable()) {
assert(getContext().hasSameUnqualifiedType(E->getType(), // FIXME: This only handles the simplest case, where the source object
E->getArg(0)->getType())); // is passed directly as the first argument to the constructor.
if (E->getArg(0)->isTemporaryObject(getContext(), CD->getParent())) { // This should also handle stepping though implicit casts and
EmitAggExpr(E->getArg(0), Dest); // conversion sequences which involve two steps, with a
return; // conversion operator followed by a converting constructor.
} const Expr *SrcObj = E->getArg(0);
assert(SrcObj->isTemporaryObject(getContext(), CD->getParent()));
assert(
getContext().hasSameUnqualifiedType(E->getType(), SrcObj->getType()));
EmitAggExpr(SrcObj, Dest);
return;
} }
if (const ArrayType *arrayType if (const ArrayType *arrayType

View File

@ -649,7 +649,6 @@ void UnwrappedLineParser::parseBlock(bool MustBeDeclaration, unsigned AddLevels,
nextToken(); nextToken();
Line->Level = InitialLevel; Line->Level = InitialLevel;
FormatTok->setBlockKind(BK_Block);
if (PPStartHash == PPEndHash) { if (PPStartHash == PPEndHash) {
Line->MatchingOpeningBlockLineIndex = OpeningLineIndex; Line->MatchingOpeningBlockLineIndex = OpeningLineIndex;

View File

@ -2010,7 +2010,7 @@ static void checkEscapingByref(VarDecl *VD, Sema &S) {
Expr *VarRef = Expr *VarRef =
new (S.Context) DeclRefExpr(S.Context, VD, false, T, VK_LValue, Loc); new (S.Context) DeclRefExpr(S.Context, VD, false, T, VK_LValue, Loc);
ExprResult Result; ExprResult Result;
auto IE = InitializedEntity::InitializeBlock(Loc, T, false); auto IE = InitializedEntity::InitializeBlock(Loc, T);
if (S.getLangOpts().CPlusPlus2b) { if (S.getLangOpts().CPlusPlus2b) {
auto *E = ImplicitCastExpr::Create(S.Context, T, CK_NoOp, VarRef, nullptr, auto *E = ImplicitCastExpr::Create(S.Context, T, CK_NoOp, VarRef, nullptr,
VK_XValue, FPOptionsOverride()); VK_XValue, FPOptionsOverride());

View File

@ -1533,7 +1533,7 @@ bool CoroutineStmtBuilder::makeGroDeclAndReturnStmt() {
if (GroType->isVoidType()) { if (GroType->isVoidType()) {
// Trigger a nice error message. // Trigger a nice error message.
InitializedEntity Entity = InitializedEntity Entity =
InitializedEntity::InitializeResult(Loc, FnRetType, false); InitializedEntity::InitializeResult(Loc, FnRetType);
S.PerformCopyInitialization(Entity, SourceLocation(), ReturnValue); S.PerformCopyInitialization(Entity, SourceLocation(), ReturnValue);
noteMemberDeclaredHere(S, ReturnValue, Fn); noteMemberDeclaredHere(S, ReturnValue, Fn);
return false; return false;

View File

@ -15262,8 +15262,17 @@ Sema::BuildCXXConstructExpr(SourceLocation ConstructLoc, QualType DeclInitType,
// can be omitted by constructing the temporary object // can be omitted by constructing the temporary object
// directly into the target of the omitted copy/move // directly into the target of the omitted copy/move
if (ConstructKind == CXXConstructExpr::CK_Complete && Constructor && if (ConstructKind == CXXConstructExpr::CK_Complete && Constructor &&
// FIXME: Converting constructors should also be accepted.
// But to fix this, the logic that digs down into a CXXConstructExpr
// to find the source object needs to handle it.
// Right now it assumes the source object is passed directly as the
// first argument.
Constructor->isCopyOrMoveConstructor() && hasOneRealArgument(ExprArgs)) { Constructor->isCopyOrMoveConstructor() && hasOneRealArgument(ExprArgs)) {
Expr *SubExpr = ExprArgs[0]; Expr *SubExpr = ExprArgs[0];
// FIXME: Per above, this is also incorrect if we want to accept
// converting constructors, as isTemporaryObject will
// reject temporaries with different type from the
// CXXRecord itself.
Elidable = SubExpr->isTemporaryObject( Elidable = SubExpr->isTemporaryObject(
Context, cast<CXXRecordDecl>(FoundDecl->getDeclContext())); Context, cast<CXXRecordDecl>(FoundDecl->getDeclContext()));
} }

View File

@ -15683,7 +15683,7 @@ ExprResult Sema::ActOnBlockStmtExpr(SourceLocation CaretLoc,
if (!Result.isInvalid()) { if (!Result.isInvalid()) {
Result = PerformCopyInitialization( Result = PerformCopyInitialization(
InitializedEntity::InitializeBlock(Var->getLocation(), InitializedEntity::InitializeBlock(Var->getLocation(),
Cap.getCaptureType(), false), Cap.getCaptureType()),
Loc, Result.get()); Loc, Result.get());
} }

View File

@ -893,9 +893,8 @@ ExprResult Sema::BuildCXXThrow(SourceLocation OpLoc, Expr *Ex,
if (CheckCXXThrowOperand(OpLoc, ExceptionObjectTy, Ex)) if (CheckCXXThrowOperand(OpLoc, ExceptionObjectTy, Ex))
return ExprError(); return ExprError();
InitializedEntity Entity = InitializedEntity::InitializeException( InitializedEntity Entity =
OpLoc, ExceptionObjectTy, InitializedEntity::InitializeException(OpLoc, ExceptionObjectTy);
/*NRVO=*/NRInfo.isCopyElidable());
ExprResult Res = PerformMoveOrCopyInitialization(Entity, NRInfo, Ex); ExprResult Res = PerformMoveOrCopyInitialization(Entity, NRInfo, Ex);
if (Res.isInvalid()) if (Res.isInvalid())
return ExprError(); return ExprError();

View File

@ -1975,8 +1975,7 @@ ExprResult Sema::BuildBlockForLambdaConversion(SourceLocation CurrentLocation,
CallOperator->markUsed(Context); CallOperator->markUsed(Context);
ExprResult Init = PerformCopyInitialization( ExprResult Init = PerformCopyInitialization(
InitializedEntity::InitializeLambdaToBlock(ConvLocation, Src->getType(), InitializedEntity::InitializeLambdaToBlock(ConvLocation, Src->getType()),
/*NRVO=*/false),
CurrentLocation, Src); CurrentLocation, Src);
if (!Init.isInvalid()) if (!Init.isInvalid())
Init = ActOnFinishFullExpr(Init.get(), /*DiscardedValue*/ false); Init = ActOnFinishFullExpr(Init.get(), /*DiscardedValue*/ false);

View File

@ -1467,8 +1467,7 @@ Decl *Sema::ActOnPropertyImplDecl(Scope *S,
LoadSelfExpr, true, true); LoadSelfExpr, true, true);
ExprResult Res = PerformCopyInitialization( ExprResult Res = PerformCopyInitialization(
InitializedEntity::InitializeResult(PropertyDiagLoc, InitializedEntity::InitializeResult(PropertyDiagLoc,
getterMethod->getReturnType(), getterMethod->getReturnType()),
/*NRVO=*/false),
PropertyDiagLoc, IvarRefExpr); PropertyDiagLoc, IvarRefExpr);
if (!Res.isInvalid()) { if (!Res.isInvalid()) {
Expr *ResExpr = Res.getAs<Expr>(); Expr *ResExpr = Res.getAs<Expr>();

View File

@ -3653,8 +3653,8 @@ StmtResult Sema::ActOnCapScopeReturnStmt(SourceLocation ReturnLoc,
// In C++ the return statement is handled via a copy initialization. // In C++ the return statement is handled via a copy initialization.
// the C version of which boils down to CheckSingleAssignmentConstraints. // the C version of which boils down to CheckSingleAssignmentConstraints.
InitializedEntity Entity = InitializedEntity::InitializeResult( InitializedEntity Entity =
ReturnLoc, FnRetType, NRVOCandidate != nullptr); InitializedEntity::InitializeResult(ReturnLoc, FnRetType);
ExprResult Res = PerformMoveOrCopyInitialization( ExprResult Res = PerformMoveOrCopyInitialization(
Entity, NRInfo, RetValExp, SupressSimplerImplicitMoves); Entity, NRInfo, RetValExp, SupressSimplerImplicitMoves);
if (Res.isInvalid()) { if (Res.isInvalid()) {
@ -4085,8 +4085,8 @@ StmtResult Sema::BuildReturnStmt(SourceLocation ReturnLoc, Expr *RetValExp) {
// the C version of which boils down to CheckSingleAssignmentConstraints. // the C version of which boils down to CheckSingleAssignmentConstraints.
if (!HasDependentReturnType && !RetValExp->isTypeDependent()) { if (!HasDependentReturnType && !RetValExp->isTypeDependent()) {
// we have a non-void function with an expression, continue checking // we have a non-void function with an expression, continue checking
InitializedEntity Entity = InitializedEntity::InitializeResult( InitializedEntity Entity =
ReturnLoc, RetType, NRVOCandidate != nullptr); InitializedEntity::InitializeResult(ReturnLoc, RetType);
ExprResult Res = PerformMoveOrCopyInitialization( ExprResult Res = PerformMoveOrCopyInitialization(
Entity, NRInfo, RetValExp, SupressSimplerImplicitMoves); Entity, NRInfo, RetValExp, SupressSimplerImplicitMoves);
if (Res.isInvalid()) { if (Res.isInvalid()) {

View File

@ -609,9 +609,6 @@ void Writer::finalizeAddresses() {
void Writer::run() { void Writer::run() {
ScopedTimer t1(codeLayoutTimer); ScopedTimer t1(codeLayoutTimer);
// First, clear the output sections from previous runs
outputSections.clear();
createImportTables(); createImportTables();
createSections(); createSections();
appendImportThunks(); appendImportThunks();

View File

@ -80,7 +80,7 @@ void DemandedBitsWrapperPass::print(raw_ostream &OS, const Module *M) const {
static bool isAlwaysLive(Instruction *I) { static bool isAlwaysLive(Instruction *I) {
return I->isTerminator() || isa<DbgInfoIntrinsic>(I) || I->isEHPad() || return I->isTerminator() || isa<DbgInfoIntrinsic>(I) || I->isEHPad() ||
I->mayHaveSideEffects() || !I->willReturn(); I->mayHaveSideEffects();
} }
void DemandedBits::determineLiveOperandBits( void DemandedBits::determineLiveOperandBits(

View File

@ -459,7 +459,7 @@ Constant *llvm::ConstantFoldCastInstruction(unsigned opc, Constant *V,
V.convertToInteger(IntVal, APFloat::rmTowardZero, &ignored)) { V.convertToInteger(IntVal, APFloat::rmTowardZero, &ignored)) {
// Undefined behavior invoked - the destination type can't represent // Undefined behavior invoked - the destination type can't represent
// the input constant. // the input constant.
return UndefValue::get(DestTy); return PoisonValue::get(DestTy);
} }
return ConstantInt::get(FPC->getContext(), IntVal); return ConstantInt::get(FPC->getContext(), IntVal);
} }
@ -694,7 +694,7 @@ Constant *llvm::ConstantFoldInsertElementInstruction(Constant *Val,
unsigned NumElts = ValTy->getNumElements(); unsigned NumElts = ValTy->getNumElements();
if (CIdx->uge(NumElts)) if (CIdx->uge(NumElts))
return UndefValue::get(Val->getType()); return PoisonValue::get(Val->getType());
SmallVector<Constant*, 16> Result; SmallVector<Constant*, 16> Result;
Result.reserve(NumElts); Result.reserve(NumElts);
@ -922,23 +922,21 @@ Constant *llvm::ConstantFoldBinaryInstruction(unsigned Opcode, Constant *C1,
} }
case Instruction::SDiv: case Instruction::SDiv:
case Instruction::UDiv: case Instruction::UDiv:
// X / undef -> undef // X / undef -> poison
if (isa<UndefValue>(C2)) // X / 0 -> poison
return C2; if (match(C2, m_CombineOr(m_Undef(), m_Zero())))
// undef / 0 -> undef return PoisonValue::get(C2->getType());
// undef / 1 -> undef // undef / 1 -> undef
if (match(C2, m_Zero()) || match(C2, m_One())) if (match(C2, m_One()))
return C1; return C1;
// undef / X -> 0 otherwise // undef / X -> 0 otherwise
return Constant::getNullValue(C1->getType()); return Constant::getNullValue(C1->getType());
case Instruction::URem: case Instruction::URem:
case Instruction::SRem: case Instruction::SRem:
// X % undef -> undef // X % undef -> poison
if (match(C2, m_Undef())) // X % 0 -> poison
return C2; if (match(C2, m_CombineOr(m_Undef(), m_Zero())))
// undef % 0 -> undef return PoisonValue::get(C2->getType());
if (match(C2, m_Zero()))
return C1;
// undef % X -> 0 otherwise // undef % X -> 0 otherwise
return Constant::getNullValue(C1->getType()); return Constant::getNullValue(C1->getType());
case Instruction::Or: // X | undef -> -1 case Instruction::Or: // X | undef -> -1
@ -946,28 +944,28 @@ Constant *llvm::ConstantFoldBinaryInstruction(unsigned Opcode, Constant *C1,
return C1; return C1;
return Constant::getAllOnesValue(C1->getType()); // undef | X -> ~0 return Constant::getAllOnesValue(C1->getType()); // undef | X -> ~0
case Instruction::LShr: case Instruction::LShr:
// X >>l undef -> undef // X >>l undef -> poison
if (isa<UndefValue>(C2)) if (isa<UndefValue>(C2))
return C2; return PoisonValue::get(C2->getType());
// undef >>l 0 -> undef // undef >>l 0 -> undef
if (match(C2, m_Zero())) if (match(C2, m_Zero()))
return C1; return C1;
// undef >>l X -> 0 // undef >>l X -> 0
return Constant::getNullValue(C1->getType()); return Constant::getNullValue(C1->getType());
case Instruction::AShr: case Instruction::AShr:
// X >>a undef -> undef // X >>a undef -> poison
if (isa<UndefValue>(C2)) if (isa<UndefValue>(C2))
return C2; return PoisonValue::get(C2->getType());
// undef >>a 0 -> undef // undef >>a 0 -> undef
if (match(C2, m_Zero())) if (match(C2, m_Zero()))
return C1; return C1;
// TODO: undef >>a X -> undef if the shift is exact // TODO: undef >>a X -> poison if the shift is exact
// undef >>a X -> 0 // undef >>a X -> 0
return Constant::getNullValue(C1->getType()); return Constant::getNullValue(C1->getType());
case Instruction::Shl: case Instruction::Shl:
// X << undef -> undef // X << undef -> undef
if (isa<UndefValue>(C2)) if (isa<UndefValue>(C2))
return C2; return PoisonValue::get(C2->getType());
// undef << 0 -> undef // undef << 0 -> undef
if (match(C2, m_Zero())) if (match(C2, m_Zero()))
return C1; return C1;
@ -1020,14 +1018,14 @@ Constant *llvm::ConstantFoldBinaryInstruction(unsigned Opcode, Constant *C1,
if (CI2->isOne()) if (CI2->isOne())
return C1; // X / 1 == X return C1; // X / 1 == X
if (CI2->isZero()) if (CI2->isZero())
return UndefValue::get(CI2->getType()); // X / 0 == undef return PoisonValue::get(CI2->getType()); // X / 0 == poison
break; break;
case Instruction::URem: case Instruction::URem:
case Instruction::SRem: case Instruction::SRem:
if (CI2->isOne()) if (CI2->isOne())
return Constant::getNullValue(CI2->getType()); // X % 1 == 0 return Constant::getNullValue(CI2->getType()); // X % 1 == 0
if (CI2->isZero()) if (CI2->isZero())
return UndefValue::get(CI2->getType()); // X % 0 == undef return PoisonValue::get(CI2->getType()); // X % 0 == poison
break; break;
case Instruction::And: case Instruction::And:
if (CI2->isZero()) return C2; // X & 0 == 0 if (CI2->isZero()) return C2; // X & 0 == 0
@ -1141,7 +1139,7 @@ Constant *llvm::ConstantFoldBinaryInstruction(unsigned Opcode, Constant *C1,
case Instruction::SDiv: case Instruction::SDiv:
assert(!CI2->isZero() && "Div by zero handled above"); assert(!CI2->isZero() && "Div by zero handled above");
if (C2V.isAllOnesValue() && C1V.isMinSignedValue()) if (C2V.isAllOnesValue() && C1V.isMinSignedValue())
return UndefValue::get(CI1->getType()); // MIN_INT / -1 -> undef return PoisonValue::get(CI1->getType()); // MIN_INT / -1 -> poison
return ConstantInt::get(CI1->getContext(), C1V.sdiv(C2V)); return ConstantInt::get(CI1->getContext(), C1V.sdiv(C2V));
case Instruction::URem: case Instruction::URem:
assert(!CI2->isZero() && "Div by zero handled above"); assert(!CI2->isZero() && "Div by zero handled above");
@ -1149,7 +1147,7 @@ Constant *llvm::ConstantFoldBinaryInstruction(unsigned Opcode, Constant *C1,
case Instruction::SRem: case Instruction::SRem:
assert(!CI2->isZero() && "Div by zero handled above"); assert(!CI2->isZero() && "Div by zero handled above");
if (C2V.isAllOnesValue() && C1V.isMinSignedValue()) if (C2V.isAllOnesValue() && C1V.isMinSignedValue())
return UndefValue::get(CI1->getType()); // MIN_INT % -1 -> undef return PoisonValue::get(CI1->getType()); // MIN_INT % -1 -> poison
return ConstantInt::get(CI1->getContext(), C1V.srem(C2V)); return ConstantInt::get(CI1->getContext(), C1V.srem(C2V));
case Instruction::And: case Instruction::And:
return ConstantInt::get(CI1->getContext(), C1V & C2V); return ConstantInt::get(CI1->getContext(), C1V & C2V);
@ -1160,15 +1158,15 @@ Constant *llvm::ConstantFoldBinaryInstruction(unsigned Opcode, Constant *C1,
case Instruction::Shl: case Instruction::Shl:
if (C2V.ult(C1V.getBitWidth())) if (C2V.ult(C1V.getBitWidth()))
return ConstantInt::get(CI1->getContext(), C1V.shl(C2V)); return ConstantInt::get(CI1->getContext(), C1V.shl(C2V));
return UndefValue::get(C1->getType()); // too big shift is undef return PoisonValue::get(C1->getType()); // too big shift is poison
case Instruction::LShr: case Instruction::LShr:
if (C2V.ult(C1V.getBitWidth())) if (C2V.ult(C1V.getBitWidth()))
return ConstantInt::get(CI1->getContext(), C1V.lshr(C2V)); return ConstantInt::get(CI1->getContext(), C1V.lshr(C2V));
return UndefValue::get(C1->getType()); // too big shift is undef return PoisonValue::get(C1->getType()); // too big shift is poison
case Instruction::AShr: case Instruction::AShr:
if (C2V.ult(C1V.getBitWidth())) if (C2V.ult(C1V.getBitWidth()))
return ConstantInt::get(CI1->getContext(), C1V.ashr(C2V)); return ConstantInt::get(CI1->getContext(), C1V.ashr(C2V));
return UndefValue::get(C1->getType()); // too big shift is undef return PoisonValue::get(C1->getType()); // too big shift is poison
} }
} }
@ -1214,7 +1212,7 @@ Constant *llvm::ConstantFoldBinaryInstruction(unsigned Opcode, Constant *C1,
// Fast path for splatted constants. // Fast path for splatted constants.
if (Constant *C2Splat = C2->getSplatValue()) { if (Constant *C2Splat = C2->getSplatValue()) {
if (Instruction::isIntDivRem(Opcode) && C2Splat->isNullValue()) if (Instruction::isIntDivRem(Opcode) && C2Splat->isNullValue())
return UndefValue::get(VTy); return PoisonValue::get(VTy);
if (Constant *C1Splat = C1->getSplatValue()) { if (Constant *C1Splat = C1->getSplatValue()) {
return ConstantVector::getSplat( return ConstantVector::getSplat(
VTy->getElementCount(), VTy->getElementCount(),
@ -1231,9 +1229,9 @@ Constant *llvm::ConstantFoldBinaryInstruction(unsigned Opcode, Constant *C1,
Constant *LHS = ConstantExpr::getExtractElement(C1, ExtractIdx); Constant *LHS = ConstantExpr::getExtractElement(C1, ExtractIdx);
Constant *RHS = ConstantExpr::getExtractElement(C2, ExtractIdx); Constant *RHS = ConstantExpr::getExtractElement(C2, ExtractIdx);
// If any element of a divisor vector is zero, the whole op is undef. // If any element of a divisor vector is zero, the whole op is poison.
if (Instruction::isIntDivRem(Opcode) && RHS->isNullValue()) if (Instruction::isIntDivRem(Opcode) && RHS->isNullValue())
return UndefValue::get(VTy); return PoisonValue::get(VTy);
Result.push_back(ConstantExpr::get(Opcode, LHS, RHS)); Result.push_back(ConstantExpr::get(Opcode, LHS, RHS));
} }
@ -2209,7 +2207,8 @@ Constant *llvm::ConstantFoldGetElementPtr(Type *PointeeTy, Constant *C,
return PoisonValue::get(GEPTy); return PoisonValue::get(GEPTy);
if (isa<UndefValue>(C)) if (isa<UndefValue>(C))
return UndefValue::get(GEPTy); // If inbounds, we can choose an out-of-bounds pointer as a base pointer.
return InBounds ? PoisonValue::get(GEPTy) : UndefValue::get(GEPTy);
Constant *Idx0 = cast<Constant>(Idxs[0]); Constant *Idx0 = cast<Constant>(Idxs[0]);
if (Idxs.size() == 1 && (Idx0->isNullValue() || isa<UndefValue>(Idx0))) if (Idxs.size() == 1 && (Idx0->isNullValue() || isa<UndefValue>(Idx0)))

View File

@ -1572,9 +1572,6 @@ PassBuilder::buildThinLTOPreLinkDefaultPipeline(OptimizationLevel Level) {
for (auto &C : OptimizerLastEPCallbacks) for (auto &C : OptimizerLastEPCallbacks)
C(MPM, Level); C(MPM, Level);
if (PGOOpt && PGOOpt->PseudoProbeForProfiling)
MPM.addPass(PseudoProbeUpdatePass());
// Emit annotation remarks. // Emit annotation remarks.
addAnnotationRemarksPass(MPM); addAnnotationRemarksPass(MPM);

View File

@ -1301,6 +1301,7 @@ static AArch64CC::CondCode changeICMPPredToAArch64CC(CmpInst::Predicate P) {
static Register getTestBitReg(Register Reg, uint64_t &Bit, bool &Invert, static Register getTestBitReg(Register Reg, uint64_t &Bit, bool &Invert,
MachineRegisterInfo &MRI) { MachineRegisterInfo &MRI) {
assert(Reg.isValid() && "Expected valid register!"); assert(Reg.isValid() && "Expected valid register!");
bool HasZext = false;
while (MachineInstr *MI = getDefIgnoringCopies(Reg, MRI)) { while (MachineInstr *MI = getDefIgnoringCopies(Reg, MRI)) {
unsigned Opc = MI->getOpcode(); unsigned Opc = MI->getOpcode();
@ -1314,6 +1315,9 @@ static Register getTestBitReg(Register Reg, uint64_t &Bit, bool &Invert,
// on the truncated x is the same as the bit number on x. // on the truncated x is the same as the bit number on x.
if (Opc == TargetOpcode::G_ANYEXT || Opc == TargetOpcode::G_ZEXT || if (Opc == TargetOpcode::G_ANYEXT || Opc == TargetOpcode::G_ZEXT ||
Opc == TargetOpcode::G_TRUNC) { Opc == TargetOpcode::G_TRUNC) {
if (Opc == TargetOpcode::G_ZEXT)
HasZext = true;
Register NextReg = MI->getOperand(1).getReg(); Register NextReg = MI->getOperand(1).getReg();
// Did we find something worth folding? // Did we find something worth folding?
if (!NextReg.isValid() || !MRI.hasOneNonDBGUse(NextReg)) if (!NextReg.isValid() || !MRI.hasOneNonDBGUse(NextReg))
@ -1342,8 +1346,12 @@ static Register getTestBitReg(Register Reg, uint64_t &Bit, bool &Invert,
std::swap(ConstantReg, TestReg); std::swap(ConstantReg, TestReg);
VRegAndVal = getConstantVRegValWithLookThrough(ConstantReg, MRI); VRegAndVal = getConstantVRegValWithLookThrough(ConstantReg, MRI);
} }
if (VRegAndVal) if (VRegAndVal) {
C = VRegAndVal->Value.getSExtValue(); if (HasZext)
C = VRegAndVal->Value.getZExtValue();
else
C = VRegAndVal->Value.getSExtValue();
}
break; break;
} }
case TargetOpcode::G_ASHR: case TargetOpcode::G_ASHR:

View File

@ -35823,7 +35823,7 @@ static SDValue combineX86ShuffleChain(ArrayRef<SDValue> Inputs, SDValue Root,
// See if the shuffle is a hidden identity shuffle - repeated args in HOPs // See if the shuffle is a hidden identity shuffle - repeated args in HOPs
// etc. can be simplified. // etc. can be simplified.
if (VT1 == VT2 && VT1.getSizeInBits() == RootSizeInBits) { if (VT1 == VT2 && VT1.getSizeInBits() == RootSizeInBits && VT1.isVector()) {
SmallVector<int> ScaledMask, IdentityMask; SmallVector<int> ScaledMask, IdentityMask;
unsigned NumElts = VT1.getVectorNumElements(); unsigned NumElts = VT1.getVectorNumElements();
if (BaseMask.size() <= NumElts && if (BaseMask.size() <= NumElts &&

View File

@ -326,7 +326,7 @@ void AggressiveDeadCodeElimination::initialize() {
bool AggressiveDeadCodeElimination::isAlwaysLive(Instruction &I) { bool AggressiveDeadCodeElimination::isAlwaysLive(Instruction &I) {
// TODO -- use llvm::isInstructionTriviallyDead // TODO -- use llvm::isInstructionTriviallyDead
if (I.isEHPad() || I.mayHaveSideEffects() || !I.willReturn()) { if (I.isEHPad() || I.mayHaveSideEffects()) {
// Skip any value profile instrumentation calls if they are // Skip any value profile instrumentation calls if they are
// instrumenting constants. // instrumenting constants.
if (isInstrumentsConstant(I)) if (isInstrumentsConstant(I))

View File

@ -1,14 +1,14 @@
// $FreeBSD$ // $FreeBSD$
#define LLVM_REVISION "llvmorg-13.0.0-rc3-8-g08642a395f23" #define LLVM_REVISION "llvmorg-13.0.0-0-gd7b669b3a303"
#define LLVM_REPOSITORY "git@github.com:llvm/llvm-project.git" #define LLVM_REPOSITORY "git@github.com:llvm/llvm-project.git"
#define CLANG_REVISION "llvmorg-13.0.0-rc3-8-g08642a395f23" #define CLANG_REVISION "llvmorg-13.0.0-0-gd7b669b3a303"
#define CLANG_REPOSITORY "git@github.com:llvm/llvm-project.git" #define CLANG_REPOSITORY "git@github.com:llvm/llvm-project.git"
// <Upstream revision at import>-<Local identifier in __FreeBSD_version style> // <Upstream revision at import>-<Local identifier in __FreeBSD_version style>
#define LLD_REVISION "llvmorg-13.0.0-rc3-8-g08642a395f23-1400002" #define LLD_REVISION "llvmorg-13.0.0-0-gd7b669b3a303-1400002"
#define LLD_REPOSITORY "FreeBSD" #define LLD_REPOSITORY "FreeBSD"
#define LLDB_REVISION "llvmorg-13.0.0-rc3-8-g08642a395f23" #define LLDB_REVISION "llvmorg-13.0.0-0-gd7b669b3a303"
#define LLDB_REPOSITORY "git@github.com:llvm/llvm-project.git" #define LLDB_REPOSITORY "git@github.com:llvm/llvm-project.git"

View File

@ -1,3 +1,3 @@
/* $FreeBSD$ */ /* $FreeBSD$ */
#define LLVM_REVISION "llvmorg-13.0.0-rc3-8-g08642a395f23" #define LLVM_REVISION "llvmorg-13.0.0-0-gd7b669b3a303"
#define LLVM_REPOSITORY "git@github.com:llvm/llvm-project.git" #define LLVM_REPOSITORY "git@github.com:llvm/llvm-project.git"

View File

@ -18,6 +18,22 @@ SRCS+= Win64EHDumper.cpp
SRCS+= WindowsResourceDumper.cpp SRCS+= WindowsResourceDumper.cpp
SRCS+= XCOFFDumper.cpp SRCS+= XCOFFDumper.cpp
.include "${SRCTOP}/lib/clang/llvm.pre.mk"
CFLAGS+= -I${.OBJDIR}
INCFILE= Opts.inc
TDFILE= ${LLVM_BASE}/${SRCDIR}/Opts.td
GENOPT= -gen-opt-parser-defs
${INCFILE}: ${TDFILE}
${LLVM_TBLGEN} ${GENOPT} -I ${LLVM_SRCS}/include -d ${.TARGET:C/$/.d/} \
-o ${.TARGET} ${TDFILE}
TGHDRS+= ${INCFILE}
DEPENDFILES+= ${TGHDRS:C/$/.d/}
DPSRCS+= ${TGHDRS}
CLEANFILES+= ${TGHDRS} ${TGHDRS:C/$/.d/}
LIBADD+= z LIBADD+= z
LINKS+= ${BINDIR}/llvm-readobj ${BINDIR}/llvm-readelf LINKS+= ${BINDIR}/llvm-readobj ${BINDIR}/llvm-readelf