Upgrade our copies of clang, llvm, lldb and compiler-rt to r312293 from

the upstream release_50 branch.  This corresponds to 5.0.0 rc4.

As of this version, the cad/stepcode port should now compile in a more
reasonable time on i386 (see bug 221836 for more information).

PR:		221836
MFC after:	2 months
X-MFC-with:	r321369
This commit is contained in:
Dimitry Andric 2017-09-01 18:53:36 +00:00
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=323112
22 changed files with 165 additions and 44 deletions

View File

@ -801,7 +801,8 @@ class SDNode : public FoldingSetNode, public ilist_node<SDNode> {
/// if DAG changes.
static bool hasPredecessorHelper(const SDNode *N,
SmallPtrSetImpl<const SDNode *> &Visited,
SmallVectorImpl<const SDNode *> &Worklist) {
SmallVectorImpl<const SDNode *> &Worklist,
unsigned int MaxSteps = 0) {
if (Visited.count(N))
return true;
while (!Worklist.empty()) {
@ -816,6 +817,8 @@ class SDNode : public FoldingSetNode, public ilist_node<SDNode> {
}
if (Found)
return true;
if (MaxSteps != 0 && Visited.size() >= MaxSteps)
return false;
}
return false;
}

View File

@ -23,8 +23,6 @@ using namespace llvm;
#define DEBUG_TYPE "postdomtree"
template class llvm::DominatorTreeBase<BasicBlock, true>; // PostDomTreeBase
//===----------------------------------------------------------------------===//
// PostDominatorTree Implementation
//===----------------------------------------------------------------------===//

View File

@ -1118,22 +1118,30 @@ SDValue DAGCombiner::PromoteIntBinOp(SDValue Op) {
SDValue RV =
DAG.getNode(ISD::TRUNCATE, DL, VT, DAG.getNode(Opc, DL, PVT, NN0, NN1));
// New replace instances of N0 and N1
if (Replace0 && N0 && N0.getOpcode() != ISD::DELETED_NODE && NN0 &&
NN0.getOpcode() != ISD::DELETED_NODE) {
// We are always replacing N0/N1's use in N and only need
// additional replacements if there are additional uses.
Replace0 &= !N0->hasOneUse();
Replace1 &= (N0 != N1) && !N1->hasOneUse();
// Combine Op here so it is presreved past replacements.
CombineTo(Op.getNode(), RV);
// If operands have a use ordering, make sur we deal with
// predecessor first.
if (Replace0 && Replace1 && N0.getNode()->isPredecessorOf(N1.getNode())) {
std::swap(N0, N1);
std::swap(NN0, NN1);
}
if (Replace0) {
AddToWorklist(NN0.getNode());
ReplaceLoadWithPromotedLoad(N0.getNode(), NN0.getNode());
}
if (Replace1 && N1 && N1.getOpcode() != ISD::DELETED_NODE && NN1 &&
NN1.getOpcode() != ISD::DELETED_NODE) {
if (Replace1) {
AddToWorklist(NN1.getNode());
ReplaceLoadWithPromotedLoad(N1.getNode(), NN1.getNode());
}
// Deal with Op being deleted.
if (Op && Op.getOpcode() != ISD::DELETED_NODE)
return RV;
return Op;
}
return SDValue();
}
@ -12599,25 +12607,37 @@ void DAGCombiner::getStoreMergeCandidates(
}
}
// We need to check that merging these stores does not cause a loop
// in the DAG. Any store candidate may depend on another candidate
// We need to check that merging these stores does not cause a loop in
// the DAG. Any store candidate may depend on another candidate
// indirectly through its operand (we already consider dependencies
// through the chain). Check in parallel by searching up from
// non-chain operands of candidates.
bool DAGCombiner::checkMergeStoreCandidatesForDependencies(
SmallVectorImpl<MemOpLink> &StoreNodes, unsigned NumStores) {
// FIXME: We should be able to truncate a full search of
// predecessors by doing a BFS and keeping tabs the originating
// stores from which worklist nodes come from in a similar way to
// TokenFactor simplfication.
SmallPtrSet<const SDNode *, 16> Visited;
SmallVector<const SDNode *, 8> Worklist;
// search ops of store candidates
unsigned int Max = 8192;
// Search Ops of store candidates.
for (unsigned i = 0; i < NumStores; ++i) {
SDNode *n = StoreNodes[i].MemNode;
// Potential loops may happen only through non-chain operands
for (unsigned j = 1; j < n->getNumOperands(); ++j)
Worklist.push_back(n->getOperand(j).getNode());
}
// search through DAG. We can stop early if we find a storenode
// Search through DAG. We can stop early if we find a store node.
for (unsigned i = 0; i < NumStores; ++i) {
if (SDNode::hasPredecessorHelper(StoreNodes[i].MemNode, Visited, Worklist))
if (SDNode::hasPredecessorHelper(StoreNodes[i].MemNode, Visited, Worklist,
Max))
return false;
// Check if we ended early, failing conservatively if so.
if (Visited.size() >= Max)
return false;
}
return true;

View File

@ -2028,7 +2028,10 @@ class CXXMethodDecl : public FunctionDecl {
/// \brief Returns the type of the \c this pointer.
///
/// Should only be called for instance (i.e., non-static) methods.
/// Should only be called for instance (i.e., non-static) methods. Note
/// that for the call operator of a lambda closure type, this returns the
/// desugared 'this' type (a pointer to the closure type), not the captured
/// 'this' type.
QualType getThisType(ASTContext &C) const;
unsigned getTypeQualifiers() const {

View File

@ -694,6 +694,9 @@ def fbuiltin : Flag<["-"], "fbuiltin">, Group<f_Group>;
def fbuiltin_module_map : Flag <["-"], "fbuiltin-module-map">, Group<f_Group>,
Flags<[DriverOption]>, HelpText<"Load the clang builtins module map file.">;
def fcaret_diagnostics : Flag<["-"], "fcaret-diagnostics">, Group<f_Group>;
def fclang_abi_compat_EQ : Joined<["-"], "fclang-abi-compat=">, Group<f_clang_Group>,
Flags<[CC1Option]>, MetaVarName<"<version>">, Values<"<major>.<minor>,latest">,
HelpText<"Attempt to match the ABI of Clang <version>">;
def fclasspath_EQ : Joined<["-"], "fclasspath=">, Group<f_Group>;
def fcolor_diagnostics : Flag<["-"], "fcolor-diagnostics">, Group<f_Group>,
Flags<[CoreOption, CC1Option]>, HelpText<"Use colors in diagnostics">;

View File

@ -120,6 +120,10 @@ CODEGENOPT(NoZeroInitializedInBSS , 1, 0) ///< -fno-zero-initialized-in-bss.
ENUM_CODEGENOPT(ObjCDispatchMethod, ObjCDispatchMethodKind, 2, Legacy)
CODEGENOPT(OmitLeafFramePointer , 1, 0) ///< Set when -momit-leaf-frame-pointer is
///< enabled.
/// A version of Clang that we should attempt to be ABI-compatible with.
ENUM_CODEGENOPT(ClangABICompat, ClangABI, 4, ClangABI::Latest)
VALUE_CODEGENOPT(OptimizationLevel, 2, 0) ///< The -O[0-3] option specified.
VALUE_CODEGENOPT(OptimizeSize, 2, 0) ///< If -Os (==1) or -Oz (==2) is specified.

View File

@ -69,6 +69,23 @@ class CodeGenOptions : public CodeGenOptionsBase {
LocalExecTLSModel
};
/// Clang versions with different platform ABI conformance.
enum class ClangABI {
/// Attempt to be ABI-compatible with code generated by Clang 3.8.x
/// (SVN r257626). This causes <1 x long long> to be passed in an
/// integer register instead of an SSE register on x64_64.
Ver3_8,
/// Attempt to be ABI-compatible with code generated by Clang 4.0.x
/// (SVN r291814). This causes move operations to be ignored when
/// determining whether a class type can be passed or returned directly.
Ver4,
/// Conform to the underlying platform's C and C++ ABIs as closely
/// as we can.
Latest
};
enum StructReturnConventionKind {
SRCK_Default, // No special option was passed.
SRCK_OnStack, // Small structs on the stack (-fpcc-struct-return).

View File

@ -24,6 +24,7 @@ namespace llvm {
namespace clang {
class ASTContext;
class CodeGenOptions;
class TargetInfo;
namespace CodeGen {
@ -68,6 +69,7 @@ namespace swiftcall {
llvm::LLVMContext &getVMContext() const;
const llvm::DataLayout &getDataLayout() const;
const TargetInfo &getTarget() const;
const CodeGenOptions &getCodeGenOpts() const;
/// Return the calling convention to use for system runtime
/// functions.

View File

@ -3260,7 +3260,7 @@ void CGDebugInfo::EmitInlineFunctionStart(CGBuilderTy &Builder, GlobalDecl GD) {
llvm::DISubprogram *SP = nullptr;
if (FI != SPCache.end())
SP = dyn_cast_or_null<llvm::DISubprogram>(FI->second);
if (!SP)
if (!SP || !SP->isDefinition())
SP = getFunctionStub(GD);
FnBeginRegionCount.push_back(LexicalBlockStack.size());
LexicalBlockStack.emplace_back(SP);

View File

@ -22,6 +22,7 @@
#include "CodeGenPGO.h"
#include "TargetInfo.h"
#include "clang/AST/ASTContext.h"
#include "clang/AST/ASTLambda.h"
#include "clang/AST/Decl.h"
#include "clang/AST/DeclCXX.h"
#include "clang/AST/StmtCXX.h"
@ -983,11 +984,22 @@ void CodeGenFunction::StartFunction(GlobalDecl GD,
}
// Check the 'this' pointer once per function, if it's available.
if (CXXThisValue) {
if (CXXABIThisValue) {
SanitizerSet SkippedChecks;
SkippedChecks.set(SanitizerKind::ObjectSize, true);
QualType ThisTy = MD->getThisType(getContext());
EmitTypeCheck(TCK_Load, Loc, CXXThisValue, ThisTy,
// If this is the call operator of a lambda with no capture-default, it
// may have a static invoker function, which may call this operator with
// a null 'this' pointer.
if (isLambdaCallOperator(MD) &&
cast<CXXRecordDecl>(MD->getParent())->getLambdaCaptureDefault() ==
LCD_None)
SkippedChecks.set(SanitizerKind::Null, true);
EmitTypeCheck(isa<CXXConstructorDecl>(MD) ? TCK_ConstructorCall
: TCK_MemberCall,
Loc, CXXABIThisValue, ThisTy,
getContext().getTypeAlignInChars(ThisTy->getPointeeType()),
SkippedChecks);
}

View File

@ -44,6 +44,10 @@ CodeGenTypes::~CodeGenTypes() {
delete &*I++;
}
const CodeGenOptions &CodeGenTypes::getCodeGenOpts() const {
return CGM.getCodeGenOpts();
}
void CodeGenTypes::addRecordTypeName(const RecordDecl *RD,
llvm::StructType *Ty,
StringRef suffix) {

View File

@ -178,6 +178,7 @@ class CodeGenTypes {
const TargetInfo &getTarget() const { return Target; }
CGCXXABI &getCXXABI() const { return TheCXXABI; }
llvm::LLVMContext &getLLVMContext() { return TheModule.getContext(); }
const CodeGenOptions &getCodeGenOpts() const;
/// ConvertType - Convert type T into a llvm::Type.
llvm::Type *ConvertType(QualType T);

View File

@ -62,9 +62,20 @@ class ItaniumCXXABI : public CodeGen::CGCXXABI {
bool classifyReturnType(CGFunctionInfo &FI) const override;
bool passClassIndirect(const CXXRecordDecl *RD) const {
// Clang <= 4 used the pre-C++11 rule, which ignores move operations.
// The PS4 platform ABI follows the behavior of Clang 3.2.
if (CGM.getCodeGenOpts().getClangABICompat() <=
CodeGenOptions::ClangABI::Ver4 ||
CGM.getTriple().getOS() == llvm::Triple::PS4)
return RD->hasNonTrivialDestructor() ||
RD->hasNonTrivialCopyConstructor();
return !canCopyArgument(RD);
}
RecordArgABI getRecordArgABI(const CXXRecordDecl *RD) const override {
// If C++ prohibits us from making a copy, pass by address.
if (!canCopyArgument(RD))
if (passClassIndirect(RD))
return RAA_Indirect;
return RAA_Default;
}
@ -996,7 +1007,7 @@ bool ItaniumCXXABI::classifyReturnType(CGFunctionInfo &FI) const {
return false;
// If C++ prohibits us from making a copy, return by address.
if (!canCopyArgument(RD)) {
if (passClassIndirect(RD)) {
auto Align = CGM.getContext().getTypeAlignInChars(FI.getReturnType());
FI.getReturnInfo() = ABIArgInfo::getIndirect(Align, /*ByVal=*/false);
return true;

View File

@ -183,7 +183,11 @@ const TargetInfo &ABIInfo::getTarget() const {
return CGT.getTarget();
}
bool ABIInfo:: isAndroid() const { return getTarget().getTriple().isAndroid(); }
const CodeGenOptions &ABIInfo::getCodeGenOpts() const {
return CGT.getCodeGenOpts();
}
bool ABIInfo::isAndroid() const { return getTarget().getTriple().isAndroid(); }
bool ABIInfo::isHomogeneousAggregateBaseType(QualType Ty) const {
return false;
@ -2095,9 +2099,14 @@ class X86_64ABIInfo : public SwiftABIInfo {
return !getTarget().getTriple().isOSDarwin();
}
/// GCC classifies <1 x long long> as SSE but compatibility with older clang
// compilers require us to classify it as INTEGER.
/// GCC classifies <1 x long long> as SSE but some platform ABIs choose to
/// classify it as INTEGER (for compatibility with older clang compilers).
bool classifyIntegerMMXAsSSE() const {
// Clang <= 3.8 did not do this.
if (getCodeGenOpts().getClangABICompat() <=
CodeGenOptions::ClangABI::Ver3_8)
return false;
const llvm::Triple &Triple = getTarget().getTriple();
if (Triple.isOSDarwin() || Triple.getOS() == llvm::Triple::PS4)
return false;

View File

@ -2855,6 +2855,9 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA,
addPGOAndCoverageFlags(C, D, Output, Args, CmdArgs);
if (auto *ABICompatArg = Args.getLastArg(options::OPT_fclang_abi_compat_EQ))
ABICompatArg->render(Args, CmdArgs);
// Add runtime flag for PS4 when PGO or Coverage are enabled.
if (getToolChain().getTriple().isPS4CPU())
PS4cpu::addProfileRTArgs(getToolChain(), Args, CmdArgs);

View File

@ -246,12 +246,12 @@ AlignTokenSequence(unsigned Start, unsigned End, unsigned Column, F &&Matches,
for (unsigned i = Start; i != End; ++i) {
if (ScopeStack.size() != 0 &&
Changes[i].nestingAndIndentLevel() <
Changes[ScopeStack.back()].nestingAndIndentLevel())
Changes[i].indentAndNestingLevel() <
Changes[ScopeStack.back()].indentAndNestingLevel())
ScopeStack.pop_back();
if (i != Start && Changes[i].nestingAndIndentLevel() >
Changes[i - 1].nestingAndIndentLevel())
if (i != Start && Changes[i].indentAndNestingLevel() >
Changes[i - 1].indentAndNestingLevel())
ScopeStack.push_back(i);
bool InsideNestedScope = ScopeStack.size() != 0;
@ -327,8 +327,8 @@ static unsigned AlignTokens(const FormatStyle &Style, F &&Matches,
// Measure the scope level (i.e. depth of (), [], {}) of the first token, and
// abort when we hit any token in a higher scope than the starting one.
auto NestingAndIndentLevel = StartAt < Changes.size()
? Changes[StartAt].nestingAndIndentLevel()
auto IndentAndNestingLevel = StartAt < Changes.size()
? Changes[StartAt].indentAndNestingLevel()
: std::pair<unsigned, unsigned>(0, 0);
// Keep track of the number of commas before the matching tokens, we will only
@ -359,7 +359,7 @@ static unsigned AlignTokens(const FormatStyle &Style, F &&Matches,
unsigned i = StartAt;
for (unsigned e = Changes.size(); i != e; ++i) {
if (Changes[i].nestingAndIndentLevel() < NestingAndIndentLevel)
if (Changes[i].indentAndNestingLevel() < IndentAndNestingLevel)
break;
if (Changes[i].NewlinesBefore != 0) {
@ -375,7 +375,7 @@ static unsigned AlignTokens(const FormatStyle &Style, F &&Matches,
if (Changes[i].Tok->is(tok::comma)) {
++CommasBeforeMatch;
} else if (Changes[i].nestingAndIndentLevel() > NestingAndIndentLevel) {
} else if (Changes[i].indentAndNestingLevel() > IndentAndNestingLevel) {
// Call AlignTokens recursively, skipping over this scope block.
unsigned StoppedAt = AlignTokens(Style, Matches, Changes, i);
i = StoppedAt - 1;

View File

@ -154,12 +154,11 @@ class WhitespaceManager {
const Change *StartOfBlockComment;
int IndentationOffset;
// A combination of nesting level and indent level, which are used in
// A combination of indent level and nesting level, which are used in
// tandem to compute lexical scope, for the purposes of deciding
// when to stop consecutive alignment runs.
std::pair<unsigned, unsigned>
nestingAndIndentLevel() const {
return std::make_pair(Tok->NestingLevel, Tok->IndentLevel);
std::pair<unsigned, unsigned> indentAndNestingLevel() const {
return std::make_pair(Tok->IndentLevel, Tok->NestingLevel);
}
};

View File

@ -573,6 +573,33 @@ static bool ParseCodeGenArgs(CodeGenOptions &Opts, ArgList &Args, InputKind IK,
if (!Opts.ProfileInstrumentUsePath.empty())
setPGOUseInstrumentor(Opts, Opts.ProfileInstrumentUsePath);
if (Arg *A = Args.getLastArg(OPT_fclang_abi_compat_EQ)) {
Opts.setClangABICompat(CodeGenOptions::ClangABI::Latest);
StringRef Ver = A->getValue();
std::pair<StringRef, StringRef> VerParts = Ver.split('.');
unsigned Major, Minor = 0;
// Check the version number is valid: either 3.x (0 <= x <= 9) or
// y or y.0 (4 <= y <= current version).
if (!VerParts.first.startswith("0") &&
!VerParts.first.getAsInteger(10, Major) &&
3 <= Major && Major <= CLANG_VERSION_MAJOR &&
(Major == 3 ? VerParts.second.size() == 1 &&
!VerParts.second.getAsInteger(10, Minor)
: VerParts.first.size() == Ver.size() ||
VerParts.second == "0")) {
// Got a valid version number.
if (Major == 3 && Minor <= 8)
Opts.setClangABICompat(CodeGenOptions::ClangABI::Ver3_8);
else if (Major <= 4)
Opts.setClangABICompat(CodeGenOptions::ClangABI::Ver4);
} else if (Ver != "latest") {
Diags.Report(diag::err_drv_invalid_value)
<< A->getAsString(Args) << A->getValue();
}
}
Opts.CoverageMapping =
Args.hasFlag(OPT_fcoverage_mapping, OPT_fno_coverage_mapping, false);
Opts.DumpCoverageMapping = Args.hasArg(OPT_dump_coverage_mapping);

View File

@ -198,9 +198,14 @@ Status TCPSocket::Listen(llvm::StringRef name, int backlog) {
::setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, option_value_p,
sizeof(option_value));
address.SetPort(port);
SocketAddress listen_address = address;
if(!listen_address.IsLocalhost())
listen_address.SetToAnyAddress(address.GetFamily(), port);
else
listen_address.SetPort(port);
int err = ::bind(fd, &address.sockaddr(), address.GetLength());
int err =
::bind(fd, &listen_address.sockaddr(), listen_address.GetLength());
if (-1 != err)
err = ::listen(fd, backlog);

View File

@ -8,4 +8,4 @@
#define CLANG_VENDOR "FreeBSD "
#define SVN_REVISION "311606"
#define SVN_REVISION "312293"

View File

@ -4,5 +4,5 @@
#define LLD_VERSION_STRING "5.0.0"
#define LLD_VERSION_MAJOR 5
#define LLD_VERSION_MINOR 0
#define LLD_REVISION_STRING "311606"
#define LLD_REVISION_STRING "312293"
#define LLD_REPOSITORY_STRING "FreeBSD"

View File

@ -1,2 +1,2 @@
/* $FreeBSD$ */
#define LLVM_REVISION "svn-r311606"
#define LLVM_REVISION "svn-r312293"