Skip to content

Commit

Permalink
Merged master:b56b1e67e38 into amd-gfx:50a6dc63b7f
Browse files Browse the repository at this point in the history
Local branch amd-gfx 50a6dc6 Merged master:494c7ecef92 into amd-gfx:0818bf78a8c
Remote branch master b56b1e6 [gcov] Default coverage version to '408*' and delete CC1 option -coverage-exit-block-before-body
  • Loading branch information
Sw authored and Sw committed May 12, 2020
2 parents 50a6dc6 + b56b1e6 commit 401de83
Show file tree
Hide file tree
Showing 130 changed files with 5,253 additions and 1,407 deletions.
17 changes: 17 additions & 0 deletions clang-tools-extra/clangd/Selection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include "Selection.h"
#include "SourceCode.h"
#include "support/Logger.h"
#include "support/Trace.h"
#include "clang/AST/ASTTypeTraits.h"
#include "clang/AST/Decl.h"
#include "clang/AST/DeclCXX.h"
Expand All @@ -35,6 +36,21 @@ namespace {
using Node = SelectionTree::Node;
using ast_type_traits::DynTypedNode;

// Measure the fraction of selections that were enabled by recovery AST.
void recordMetrics(const SelectionTree &S) {
static constexpr trace::Metric SelectionUsedRecovery(
"selection_recovery", trace::Metric::Distribution);
const auto *Common = S.commonAncestor();
for (const auto *N = Common; N; N = N->Parent) {
if (N->ASTNode.get<RecoveryExpr>()) {
SelectionUsedRecovery.record(1); // used recovery ast.
return;
}
}
if (Common)
SelectionUsedRecovery.record(0); // unused.
}

// An IntervalSet maintains a set of disjoint subranges of an array.
//
// Initially, it contains the entire array.
Expand Down Expand Up @@ -774,6 +790,7 @@ SelectionTree::SelectionTree(ASTContext &AST, const syntax::TokenBuffer &Tokens,
.printToString(SM));
Nodes = SelectionVisitor::collect(AST, Tokens, PrintPolicy, Begin, End, FID);
Root = Nodes.empty() ? nullptr : &Nodes.front();
recordMetrics(*this);
dlog("Built selection tree\n{0}", *this);
}

Expand Down
19 changes: 19 additions & 0 deletions clang-tools-extra/clangd/unittests/SelectionTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include "Selection.h"
#include "SourceCode.h"
#include "TestTU.h"
#include "support/TestTracer.h"
#include "clang/AST/Decl.h"
#include "llvm/Support/Casting.h"
#include "gmock/gmock.h"
Expand Down Expand Up @@ -390,6 +391,7 @@ TEST(SelectionTest, CommonAncestor) {
)cpp", "DeclRefExpr"} // DeclRefExpr to the "operator->" method.
};
for (const Case &C : Cases) {
trace::TestTracer Tracer;
Annotations Test(C.Code);

TestTU TU;
Expand All @@ -407,6 +409,7 @@ TEST(SelectionTest, CommonAncestor) {
if (Test.ranges().empty()) {
// If no [[range]] is marked in the example, there should be no selection.
EXPECT_FALSE(T.commonAncestor()) << C.Code << "\n" << T;
EXPECT_THAT(Tracer.takeMetric("selection_recovery"), testing::IsEmpty());
} else {
// If there is an expected selection, common ancestor should exist
// with the appropriate node type.
Expand All @@ -422,6 +425,8 @@ TEST(SelectionTest, CommonAncestor) {
// and no nodes outside it are selected.
EXPECT_TRUE(verifyCommonAncestor(T.root(), T.commonAncestor(), C.Code))
<< C.Code;
EXPECT_THAT(Tracer.takeMetric("selection_recovery"),
testing::ElementsAreArray({0}));
}
}
}
Expand All @@ -436,6 +441,20 @@ TEST(SelectionTest, InjectedClassName) {
EXPECT_FALSE(D->isInjectedClassName());
}

TEST(SelectionTree, Metrics) {
const char *Code = R"cpp(
// error-ok: testing behavior on recovery expression
int foo();
int foo(int, int);
int x = fo^o(42);
)cpp";
auto AST = TestTU::withCode(Annotations(Code).code()).build();
trace::TestTracer Tracer;
auto T = makeSelectionTree(Code, AST);
EXPECT_THAT(Tracer.takeMetric("selection_recovery"),
testing::ElementsAreArray({1}));
}

// FIXME: Doesn't select the binary operator node in
// #define FOO(X) X + 1
// int a, b = [[FOO(a)]];
Expand Down
1 change: 0 additions & 1 deletion clang/include/clang/Basic/CodeGenOptions.def
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ CODEGENOPT(ObjCAutoRefCountExceptions , 1, 0) ///< Whether ARC should be EH-safe
CODEGENOPT(Backchain , 1, 0) ///< -mbackchain
CODEGENOPT(ControlFlowGuardNoChecks , 1, 0) ///< -cfguard-no-checks
CODEGENOPT(ControlFlowGuard , 1, 0) ///< -cfguard
CODEGENOPT(CoverageExitBlockBeforeBody, 1, 0) ///< Whether to emit the exit block before the body blocks in GCNO files.
CODEGENOPT(CXAAtExit , 1, 1) ///< Use __cxa_atexit for calling destructors.
CODEGENOPT(RegisterGlobalDtorsWithAtExit, 1, 1) ///< Use atexit or __cxa_atexit to register global destructors.
CODEGENOPT(CXXCtorDtorAliases, 1, 0) ///< Emit complete ctors/dtors as linker
Expand Down
2 changes: 1 addition & 1 deletion clang/include/clang/Basic/DiagnosticSemaKinds.td
Original file line number Diff line number Diff line change
Expand Up @@ -860,7 +860,7 @@ def warn_pragma_pack_pop_identifier_and_alignment : Warning<
def warn_pragma_pop_failed : Warning<"#pragma %0(pop, ...) failed: %1">,
InGroup<IgnoredPragmas>;
def err_pragma_fc_pp_scope : Error<
"'#pragma float_control push/pop' can only appear at file scope">;
"'#pragma float_control push/pop' can only appear at file scope or namespace scope">;
def err_pragma_fc_noprecise_requires_nofenv : Error<
"'#pragma float_control(precise, off)' is illegal when fenv_access is enabled">;
def err_pragma_fc_except_requires_precise : Error<
Expand Down
14 changes: 13 additions & 1 deletion clang/include/clang/Basic/arm_sve.td
Original file line number Diff line number Diff line change
Expand Up @@ -627,6 +627,13 @@ def SVDUPQ_16 : SInst<"svdupq[_n]_{d}", "dssssssss", "sUsh", MergeNone>;
def SVDUPQ_32 : SInst<"svdupq[_n]_{d}", "dssss", "iUif", MergeNone>;
def SVDUPQ_64 : SInst<"svdupq[_n]_{d}", "dss", "lUld", MergeNone>;

def SVDUP : SInst<"svdup[_n]_{d}", "ds", "csilUcUsUiUlhfd", MergeNone, "aarch64_sve_dup_x">;
def SVDUP_M : SInst<"svdup[_n]_{d}", "ddPs", "csilUcUsUiUlhfd", MergeOp1, "aarch64_sve_dup">;
def SVDUP_X : SInst<"svdup[_n]_{d}", "dPs", "csilUcUsUiUlhfd", MergeAnyExp, "aarch64_sve_dup">;
def SVDUP_Z : SInst<"svdup[_n]_{d}", "dPs", "csilUcUsUiUlhfd", MergeZeroExp, "aarch64_sve_dup">;

def SVINDEX : SInst<"svindex_{d}", "dss", "csilUcUsUiUl", MergeNone, "aarch64_sve_index">;

// Integer arithmetic

multiclass SInstZPZ<string name, string types, string intrinsic, list<FlagType> flags=[]> {
Expand Down Expand Up @@ -1061,7 +1068,11 @@ def SVCLASTA_N : SInst<"svclasta[_n_{d}]", "sPsd", "csilUcUsUiUlhfd", MergeNo
def SVCLASTB : SInst<"svclastb[_{d}]", "dPdd", "csilUcUsUiUlhfd", MergeNone, "aarch64_sve_clastb">;
def SVCLASTB_N : SInst<"svclastb[_n_{d}]", "sPsd", "csilUcUsUiUlhfd", MergeNone, "aarch64_sve_clastb_n">;
def SVCOMPACT : SInst<"svcompact[_{d}]", "dPd", "ilUiUlfd", MergeNone, "aarch64_sve_compact">;
// SVDUP_LANE (to land in D78750)
// Note: svdup_lane is implemented using the intrinsic for TBL to represent a
// splat of any possible lane. It is upto LLVM to pick a more efficient
// instruction such as DUP (indexed) if the lane index fits the range of the
// instruction's immediate.
def SVDUP_LANE : SInst<"svdup_lane[_{d}]", "ddL", "csilUcUsUiUlhfd", MergeNone, "aarch64_sve_tbl">;
def SVDUPQ_LANE : SInst<"svdupq_lane[_{d}]", "ddn", "csilUcUsUiUlhfd", MergeNone, "aarch64_sve_dupq_lane">;
def SVEXT : SInst<"svext[_{d}]", "dddi", "csilUcUsUiUlhfd", MergeNone, "aarch64_sve_ext", [], [ImmCheck<2, ImmCheckExtract, 1>]>;
def SVLASTA : SInst<"svlasta[_{d}]", "sPd", "csilUcUsUiUlhfd", MergeNone, "aarch64_sve_lasta">;
Expand Down Expand Up @@ -1104,6 +1115,7 @@ def SVDUPQ_B8 : SInst<"svdupq[_n]_{d}", "Pssssssssssssssss", "Pc", MergeN
def SVDUPQ_B16 : SInst<"svdupq[_n]_{d}", "Pssssssss", "Ps", MergeNone>;
def SVDUPQ_B32 : SInst<"svdupq[_n]_{d}", "Pssss", "Pi", MergeNone>;
def SVDUPQ_B64 : SInst<"svdupq[_n]_{d}", "Pss", "Pl", MergeNone>;
def SVDUP_N_B : SInst<"svdup[_n]_{d}", "Ps", "PcPsPiPl", MergeNone>;


////////////////////////////////////////////////////////////////////////////////
Expand Down
2 changes: 0 additions & 2 deletions clang/include/clang/Driver/CC1Options.td
Original file line number Diff line number Diff line change
Expand Up @@ -262,8 +262,6 @@ def coverage_notes_file : Separate<["-"], "coverage-notes-file">,
HelpText<"Emit coverage notes to this filename.">;
def coverage_notes_file_EQ : Joined<["-"], "coverage-notes-file=">,
Alias<coverage_notes_file>;
def coverage_exit_block_before_body : Flag<["-"], "coverage-exit-block-before-body">,
HelpText<"Emit the exit block before the body blocks in .gcno files.">;
def coverage_version_EQ : Joined<["-"], "coverage-version=">,
HelpText<"Four-byte version string for gcov files.">;
def test_coverage : Flag<["-"], "test-coverage">,
Expand Down
2 changes: 2 additions & 0 deletions clang/include/clang/Sema/Sema.h
Original file line number Diff line number Diff line change
Expand Up @@ -11671,6 +11671,8 @@ class Sema final {
return IdentifyCUDATarget(dyn_cast<FunctionDecl>(CurContext));
}

static bool IsCUDAImplicitHostDeviceFunction(const FunctionDecl *D);

// CUDA function call preference. Must be ordered numerically from
// worst to best.
enum CUDAFunctionPreference {
Expand Down
5 changes: 1 addition & 4 deletions clang/lib/AST/Expr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4686,10 +4686,7 @@ RecoveryExpr::RecoveryExpr(ASTContext &Ctx, QualType T, SourceLocation BeginLoc,
: Expr(RecoveryExprClass, T, VK_LValue, OK_Ordinary), BeginLoc(BeginLoc),
EndLoc(EndLoc), NumExprs(SubExprs.size()) {
assert(!T.isNull());
#ifndef NDEBUG // avoid -Wunused warnings.
for (auto *E : SubExprs)
assert(E != nullptr);
#endif
assert(llvm::all_of(SubExprs, [](Expr* E) { return E != nullptr; }));

llvm::copy(SubExprs, getTrailingObjects<Expr *>());
setDependence(computeDependence(this));
Expand Down
2 changes: 1 addition & 1 deletion clang/lib/Basic/CodeGenOptions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ CodeGenOptions::CodeGenOptions() {
#include "clang/Basic/CodeGenOptions.def"

RelocationModel = llvm::Reloc::PIC_;
memcpy(CoverageVersion, "407*", 4);
memcpy(CoverageVersion, "408*", 4);
}

bool CodeGenOptions::isNoBuiltinFunc(const char *Name) const {
Expand Down
1 change: 0 additions & 1 deletion clang/lib/CodeGen/BackendUtil.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -533,7 +533,6 @@ static Optional<GCOVOptions> getGCOVOptions(const CodeGenOptions &CodeGenOpts) {
Options.NoRedZone = CodeGenOpts.DisableRedZone;
Options.Filter = CodeGenOpts.ProfileFilterFiles;
Options.Exclude = CodeGenOpts.ProfileExcludeFiles;
Options.ExitBlockBeforeBody = CodeGenOpts.CoverageExitBlockBeforeBody;
return Options;
}

Expand Down
20 changes: 17 additions & 3 deletions clang/lib/CodeGen/CGBuiltin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7909,12 +7909,15 @@ Value *CodeGenFunction::EmitSVEMaskedStore(const CallExpr *E,

// Limit the usage of scalable llvm IR generated by the ACLE by using the
// sve dup.x intrinsic instead of IRBuilder::CreateVectorSplat.
Value *CodeGenFunction::EmitSVEDupX(Value* Scalar) {
auto F = CGM.getIntrinsic(Intrinsic::aarch64_sve_dup_x,
getSVEVectorForElementType(Scalar->getType()));
Value *CodeGenFunction::EmitSVEDupX(Value *Scalar, llvm::Type *Ty) {
auto F = CGM.getIntrinsic(Intrinsic::aarch64_sve_dup_x, Ty);
return Builder.CreateCall(F, Scalar);
}

Value *CodeGenFunction::EmitSVEDupX(Value* Scalar) {
return EmitSVEDupX(Scalar, getSVEVectorForElementType(Scalar->getType()));
}

Value *CodeGenFunction::EmitSVEReinterpret(Value *Val, llvm::Type *Ty) {
// FIXME: For big endian this needs an additional REV, or needs a separate
// intrinsic that is code-generated as a no-op, because the LLVM bitcast
Expand Down Expand Up @@ -8109,6 +8112,17 @@ Value *CodeGenFunction::EmitAArch64SVEBuiltinExpr(unsigned BuiltinID,
case SVE::BI__builtin_sve_svpmullb_n_u64:
return EmitSVEPMull(TypeFlags, Ops, Intrinsic::aarch64_sve_pmullb_pair);

case SVE::BI__builtin_sve_svdup_n_b8:
case SVE::BI__builtin_sve_svdup_n_b16:
case SVE::BI__builtin_sve_svdup_n_b32:
case SVE::BI__builtin_sve_svdup_n_b64: {
Value *CmpNE =
Builder.CreateICmpNE(Ops[0], Constant::getNullValue(Ops[0]->getType()));
llvm::ScalableVectorType *OverloadedTy = getSVEType(TypeFlags);
Value *Dup = EmitSVEDupX(CmpNE, OverloadedTy);
return EmitSVEPredicateCast(Dup, cast<llvm::ScalableVectorType>(Ty));
}

case SVE::BI__builtin_sve_svdupq_n_b8:
case SVE::BI__builtin_sve_svdupq_n_b16:
case SVE::BI__builtin_sve_svdupq_n_b32:
Expand Down
1 change: 1 addition & 0 deletions clang/lib/CodeGen/CodeGenFunction.h
Original file line number Diff line number Diff line change
Expand Up @@ -3920,6 +3920,7 @@ class CodeGenFunction : public CodeGenTypeCache {
llvm::ScalableVectorType *getSVEPredType(SVETypeFlags TypeFlags);
llvm::Value *EmitSVEAllTruePred(SVETypeFlags TypeFlags);
llvm::Value *EmitSVEDupX(llvm::Value *Scalar);
llvm::Value *EmitSVEDupX(llvm::Value *Scalar, llvm::Type *Ty);
llvm::Value *EmitSVEReinterpret(llvm::Value *Val, llvm::Type *Ty);
llvm::Value *EmitSVEPMull(SVETypeFlags TypeFlags,
llvm::SmallVectorImpl<llvm::Value *> &Ops,
Expand Down
Loading

0 comments on commit 401de83

Please sign in to comment.