Skip to content

Commit

Permalink
Merged master:36ed0ceec7d into amd-gfx:7dc0b13fd24
Browse files Browse the repository at this point in the history
Local branch amd-gfx 7dc0b13 Merged master:30a8b77080b into amd-gfx:752bb16716c
Remote branch master 36ed0ce [OPENMP50]Add basic support for inscan reduction modifier.
  • Loading branch information
Sw authored and Sw committed Mar 27, 2020
2 parents 7dc0b13 + 36ed0ce commit a4c6533
Show file tree
Hide file tree
Showing 223 changed files with 1,545 additions and 547 deletions.
30 changes: 9 additions & 21 deletions clang/include/clang/AST/Type.h
Original file line number Diff line number Diff line change
Expand Up @@ -6679,9 +6679,9 @@ inline bool Type::isTemplateTypeParmType() const {
}

inline bool Type::isSpecificBuiltinType(unsigned K) const {
if (const BuiltinType *BT = getAs<BuiltinType>())
if (BT->getKind() == (BuiltinType::Kind) K)
return true;
if (const BuiltinType *BT = getAs<BuiltinType>()) {
return BT->getKind() == static_cast<BuiltinType::Kind>(K);
}
return false;
}

Expand All @@ -6700,9 +6700,7 @@ inline const BuiltinType *Type::getAsPlaceholderType() const {

inline bool Type::isSpecificPlaceholderType(unsigned K) const {
assert(BuiltinType::isPlaceholderTypeKind((BuiltinType::Kind) K));
if (const auto *BT = dyn_cast<BuiltinType>(this))
return (BT->getKind() == (BuiltinType::Kind) K);
return false;
return isSpecificBuiltinType(K);
}

inline bool Type::isNonOverloadPlaceholderType() const {
Expand All @@ -6712,34 +6710,24 @@ inline bool Type::isNonOverloadPlaceholderType() const {
}

inline bool Type::isVoidType() const {
if (const auto *BT = dyn_cast<BuiltinType>(CanonicalType))
return BT->getKind() == BuiltinType::Void;
return false;
return isSpecificBuiltinType(BuiltinType::Void);
}

inline bool Type::isHalfType() const {
if (const auto *BT = dyn_cast<BuiltinType>(CanonicalType))
return BT->getKind() == BuiltinType::Half;
// FIXME: Should we allow complex __fp16? Probably not.
return false;
return isSpecificBuiltinType(BuiltinType::Half);
}

inline bool Type::isFloat16Type() const {
if (const auto *BT = dyn_cast<BuiltinType>(CanonicalType))
return BT->getKind() == BuiltinType::Float16;
return false;
return isSpecificBuiltinType(BuiltinType::Float16);
}

inline bool Type::isFloat128Type() const {
if (const auto *BT = dyn_cast<BuiltinType>(CanonicalType))
return BT->getKind() == BuiltinType::Float128;
return false;
return isSpecificBuiltinType(BuiltinType::Float128);
}

inline bool Type::isNullPtrType() const {
if (const auto *BT = getAs<BuiltinType>())
return BT->getKind() == BuiltinType::NullPtr;
return false;
return isSpecificBuiltinType(BuiltinType::NullPtr);
}

bool IsEnumDeclComplete(EnumDecl *);
Expand Down
13 changes: 13 additions & 0 deletions clang/include/clang/Basic/DiagnosticSemaKinds.td
Original file line number Diff line number Diff line change
Expand Up @@ -10101,6 +10101,19 @@ def err_omp_depobj_single_clause_expected : Error<
"exactly one of 'depend', 'destroy', or 'update' clauses is expected">;
def err_omp_scan_single_clause_expected : Error<
"exactly one of 'inclusive' or 'exclusive' clauses is expected">;
def err_omp_inclusive_exclusive_not_reduction : Error<
"the list item must appear in 'reduction' clause with the 'inscan' modifier "
"of the parent directive">;
def err_omp_reduction_not_inclusive_exclusive : Error<
"the inscan reduction list item must appear as a list item in an 'inclusive' or"
" 'exclusive' clause on an inner 'omp scan' directive">;
def err_omp_wrong_inscan_reduction : Error<
"'inscan' modifier can be used only in 'omp for', 'omp simd', 'omp for simd',"
" 'omp parallel for', or 'omp parallel for simd' directive">;
def err_omp_inscan_reduction_expected : Error<
"expected 'reduction' clause with the 'inscan' modifier">;
def note_omp_previous_inscan_reduction : Note<
"'reduction' clause with 'inscan' modifier is used here">;
def err_omp_expected_predefined_allocator : Error<
"expected one of the predefined allocators for the variables with the static "
"storage: 'omp_default_mem_alloc', 'omp_large_cap_mem_alloc', "
Expand Down
1 change: 1 addition & 0 deletions clang/include/clang/Basic/OpenMPKinds.def
Original file line number Diff line number Diff line change
Expand Up @@ -1112,6 +1112,7 @@ OPENMP_DEPOBJ_CLAUSE(update)

// Modifiers for 'reduction' clause.
OPENMP_REDUCTION_MODIFIER(default)
OPENMP_REDUCTION_MODIFIER(inscan)

#undef OPENMP_REDUCTION_MODIFIER
#undef OPENMP_SCAN_CLAUSE
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class CheckerRegistry;
#define GET_CHECKERS
#define CHECKER(FULLNAME, CLASS, HELPTEXT, DOC_URI, IS_HIDDEN) \
void register##CLASS(CheckerManager &mgr); \
bool shouldRegister##CLASS(const LangOptions &LO);
bool shouldRegister##CLASS(const CheckerManager &mgr);
#include "clang/StaticAnalyzer/Checkers/Checkers.inc"
#undef CHECKER
#undef GET_CHECKERS
Expand Down
13 changes: 6 additions & 7 deletions clang/include/clang/StaticAnalyzer/Frontend/CheckerRegistry.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@ namespace clang {

class AnalyzerOptions;
class DiagnosticsEngine;
class LangOptions;

namespace ento {

Expand All @@ -96,7 +95,7 @@ class CheckerRegistry {
/// Initialization functions perform any necessary setup for a checker.
/// They should include a call to CheckerManager::registerChecker.
using InitializationFunction = void (*)(CheckerManager &);
using ShouldRegisterFunction = bool (*)(const LangOptions &);
using ShouldRegisterFunction = bool (*)(const CheckerManager &);

/// Specifies a command line option. It may either belong to a checker or a
/// package.
Expand Down Expand Up @@ -168,12 +167,12 @@ class CheckerRegistry {

ConstCheckerInfoList Dependencies;

bool isEnabled(const LangOptions &LO) const {
return State == StateFromCmdLine::State_Enabled && ShouldRegister(LO);
bool isEnabled(const CheckerManager &mgr) const {
return State == StateFromCmdLine::State_Enabled && ShouldRegister(mgr);
}

bool isDisabled(const LangOptions &LO) const {
return State == StateFromCmdLine::State_Disabled || !ShouldRegister(LO);
bool isDisabled(const CheckerManager &mgr) const {
return State == StateFromCmdLine::State_Disabled || !ShouldRegister(mgr);
}

// Since each checker must have a different full name, we can identify
Expand Down Expand Up @@ -220,7 +219,7 @@ class CheckerRegistry {
mgr.template registerChecker<T>();
}

template <typename T> static bool returnTrue(const LangOptions &) {
template <typename T> static bool returnTrue(const CheckerManager &mgr) {
return true;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ class AnalyzerOptions;

namespace ento {

class CheckerManager;

//===----------------------------------------------------------------------===//
// AST Consumer Actions
//===----------------------------------------------------------------------===//
Expand Down Expand Up @@ -52,7 +54,6 @@ class ParseModelFileAction : public ASTFrontendAction {
};

} // namespace ento

} // end namespace clang

#endif
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ void registerMyChecker(CheckerManager &Mgr) {
<< '\n';
}

bool shouldRegisterMyChecker(const LangOptions &LO) { return true; }
bool shouldRegisterMyChecker(const CheckerManager &mgr) { return true; }

} // end anonymous namespace

Expand Down
18 changes: 10 additions & 8 deletions clang/lib/Driver/ToolChains/CommonArgs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
#include "llvm/Support/Program.h"
#include "llvm/Support/ScopedPrinter.h"
#include "llvm/Support/TargetParser.h"
#include "llvm/Support/Threading.h"
#include "llvm/Support/VirtualFileSystem.h"
#include "llvm/Support/YAMLParser.h"

Expand Down Expand Up @@ -338,14 +339,14 @@ std::string tools::getCPUName(const ArgList &Args, const llvm::Triple &T,
}
}

unsigned tools::getLTOParallelism(const ArgList &Args, const Driver &D) {
unsigned Parallelism = 0;
llvm::StringRef tools::getLTOParallelism(const ArgList &Args, const Driver &D) {
Arg *LtoJobsArg = Args.getLastArg(options::OPT_flto_jobs_EQ);
if (LtoJobsArg &&
StringRef(LtoJobsArg->getValue()).getAsInteger(10, Parallelism))
D.Diag(diag::err_drv_invalid_int_value) << LtoJobsArg->getAsString(Args)
<< LtoJobsArg->getValue();
return Parallelism;
if (!LtoJobsArg)
return {};
if (!llvm::get_threadpool_strategy(LtoJobsArg->getValue()))
D.Diag(diag::err_drv_invalid_int_value)
<< LtoJobsArg->getAsString(Args) << LtoJobsArg->getValue();
return LtoJobsArg->getValue();
}

// CloudABI uses -ffunction-sections and -fdata-sections by default.
Expand Down Expand Up @@ -410,7 +411,8 @@ void tools::addLTOOptions(const ToolChain &ToolChain, const ArgList &Args,
if (IsThinLTO)
CmdArgs.push_back("-plugin-opt=thinlto");

if (unsigned Parallelism = getLTOParallelism(Args, ToolChain.getDriver()))
StringRef Parallelism = getLTOParallelism(Args, ToolChain.getDriver());
if (!Parallelism.empty())
CmdArgs.push_back(
Args.MakeArgString("-plugin-opt=jobs=" + Twine(Parallelism)));

Expand Down
3 changes: 2 additions & 1 deletion clang/lib/Driver/ToolChains/CommonArgs.h
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,8 @@ llvm::opt::Arg *getLastProfileSampleUseArg(const llvm::opt::ArgList &Args);

bool isObjCAutoRefCount(const llvm::opt::ArgList &Args);

unsigned getLTOParallelism(const llvm::opt::ArgList &Args, const Driver &D);
llvm::StringRef getLTOParallelism(const llvm::opt::ArgList &Args,
const Driver &D);

bool areOptimizationsEnabled(const llvm::opt::ArgList &Args);

Expand Down
9 changes: 6 additions & 3 deletions clang/lib/Driver/ToolChains/Darwin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
#include "llvm/Support/Path.h"
#include "llvm/Support/ScopedPrinter.h"
#include "llvm/Support/TargetParser.h"
#include "llvm/Support/Threading.h"
#include "llvm/Support/VirtualFileSystem.h"
#include <cstdlib> // ::getenv

Expand Down Expand Up @@ -605,10 +606,12 @@ void darwin::Linker::ConstructJob(Compilation &C, const JobAction &JA,

getMachOToolChain().addProfileRTLibs(Args, CmdArgs);

if (unsigned Parallelism =
getLTOParallelism(Args, getToolChain().getDriver())) {
StringRef Parallelism = getLTOParallelism(Args, getToolChain().getDriver());
if (!Parallelism.empty()) {
CmdArgs.push_back("-mllvm");
CmdArgs.push_back(Args.MakeArgString("-threads=" + Twine(Parallelism)));
unsigned NumThreads =
llvm::get_threadpool_strategy(Parallelism)->compute_thread_count();
CmdArgs.push_back(Args.MakeArgString("-threads=" + Twine(NumThreads)));
}

if (getToolChain().ShouldLinkCXXStdlib(Args))
Expand Down
Loading

0 comments on commit a4c6533

Please sign in to comment.