Skip to content

Commit

Permalink
Merged main:048f184ee488 into amd-gfx:da77c7758356
Browse files Browse the repository at this point in the history
Local branch amd-gfx da77c77 Merged main:213329d7c64f into amd-gfx:e4ebc2c5f768
Remote branch main 048f184 [SplitEdge] Add new parameter to SplitEdge to name the newly created basic block
  • Loading branch information
Sw authored and Sw committed Jan 7, 2021
2 parents da77c77 + 048f184 commit e344f05
Show file tree
Hide file tree
Showing 42 changed files with 696 additions and 155 deletions.
15 changes: 8 additions & 7 deletions clang/include/clang/Tooling/CompilationDatabase.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,10 @@ namespace tooling {
/// Specifies the working directory and command of a compilation.
struct CompileCommand {
CompileCommand() = default;
CompileCommand(Twine Directory, Twine Filename,
std::vector<std::string> CommandLine, Twine Output)
CompileCommand(const Twine &Directory, const Twine &Filename,
std::vector<std::string> CommandLine, const Twine &Output)
: Directory(Directory.str()), Filename(Filename.str()),
CommandLine(std::move(CommandLine)), Output(Output.str()){}
CommandLine(std::move(CommandLine)), Output(Output.str()) {}

/// The working directory the command was executed from.
std::string Directory;
Expand Down Expand Up @@ -180,9 +180,9 @@ class FixedCompilationDatabase : public CompilationDatabase {
/// \param Argv Points to the command line arguments.
/// \param ErrorMsg Contains error text if the function returns null pointer.
/// \param Directory The base directory used in the FixedCompilationDatabase.
static std::unique_ptr<FixedCompilationDatabase> loadFromCommandLine(
int &Argc, const char *const *Argv, std::string &ErrorMsg,
Twine Directory = ".");
static std::unique_ptr<FixedCompilationDatabase>
loadFromCommandLine(int &Argc, const char *const *Argv, std::string &ErrorMsg,
const Twine &Directory = ".");

/// Reads flags from the given file, one-per-line.
/// Returns nullptr and sets ErrorMessage if we can't read the file.
Expand All @@ -196,7 +196,8 @@ class FixedCompilationDatabase : public CompilationDatabase {

/// Constructs a compilation data base from a specified directory
/// and command line.
FixedCompilationDatabase(Twine Directory, ArrayRef<std::string> CommandLine);
FixedCompilationDatabase(const Twine &Directory,
ArrayRef<std::string> CommandLine);

/// Returns the given compile command.
///
Expand Down
112 changes: 61 additions & 51 deletions clang/lib/Frontend/CompilerInvocation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -830,7 +830,7 @@ GenerateOptimizationRemarkRegex(DiagnosticsEngine &Diags, ArgList &Args,

static bool parseDiagnosticLevelMask(StringRef FlagName,
const std::vector<std::string> &Levels,
DiagnosticsEngine *Diags,
DiagnosticsEngine &Diags,
DiagnosticLevelMask &M) {
bool Success = true;
for (const auto &Level : Levels) {
Expand All @@ -843,8 +843,7 @@ static bool parseDiagnosticLevelMask(StringRef FlagName,
.Default(DiagnosticLevelMask::None);
if (PM == DiagnosticLevelMask::None) {
Success = false;
if (Diags)
Diags->Report(diag::err_drv_invalid_value) << FlagName << Level;
Diags.Report(diag::err_drv_invalid_value) << FlagName << Level;
}
M = M | PM;
}
Expand Down Expand Up @@ -1383,7 +1382,7 @@ static bool parseShowColorsArgs(const ArgList &Args, bool DefaultColor) {
}

static bool checkVerifyPrefixes(const std::vector<std::string> &VerifyPrefixes,
DiagnosticsEngine *Diags) {
DiagnosticsEngine &Diags) {
bool Success = true;
for (const auto &Prefix : VerifyPrefixes) {
// Every prefix must start with a letter and contain only alphanumeric
Expand All @@ -1393,18 +1392,59 @@ static bool checkVerifyPrefixes(const std::vector<std::string> &VerifyPrefixes,
});
if (BadChar != Prefix.end() || !isLetter(Prefix[0])) {
Success = false;
if (Diags) {
Diags->Report(diag::err_drv_invalid_value) << "-verify=" << Prefix;
Diags->Report(diag::note_drv_verify_prefix_spelling);
}
Diags.Report(diag::err_drv_invalid_value) << "-verify=" << Prefix;
Diags.Report(diag::note_drv_verify_prefix_spelling);
}
}
return Success;
}

#define PARSE_OPTION_WITH_MARSHALLING(ARGS, DIAGS, SUCCESS, ID, FLAGS, PARAM, \
SHOULD_PARSE, KEYPATH, DEFAULT_VALUE, \
IMPLIED_CHECK, IMPLIED_VALUE, \
NORMALIZER, MERGER, TABLE_INDEX) \
if ((FLAGS)&options::CC1Option) { \
this->KEYPATH = MERGER(this->KEYPATH, DEFAULT_VALUE); \
if (IMPLIED_CHECK) \
this->KEYPATH = MERGER(this->KEYPATH, IMPLIED_VALUE); \
if (SHOULD_PARSE) \
if (auto MaybeValue = \
NORMALIZER(OPT_##ID, TABLE_INDEX, ARGS, DIAGS, SUCCESS)) \
this->KEYPATH = MERGER( \
this->KEYPATH, static_cast<decltype(this->KEYPATH)>(*MaybeValue)); \
}

bool CompilerInvocation::parseSimpleArgs(const ArgList &Args,
DiagnosticsEngine &Diags) {
bool Success = true;

#define OPTION_WITH_MARSHALLING( \
PREFIX_TYPE, NAME, ID, KIND, GROUP, ALIAS, ALIASARGS, FLAGS, PARAM, \
HELPTEXT, METAVAR, VALUES, SPELLING, SHOULD_PARSE, ALWAYS_EMIT, KEYPATH, \
DEFAULT_VALUE, IMPLIED_CHECK, IMPLIED_VALUE, NORMALIZER, DENORMALIZER, \
MERGER, EXTRACTOR, TABLE_INDEX) \
PARSE_OPTION_WITH_MARSHALLING(Args, Diags, Success, ID, FLAGS, PARAM, \
SHOULD_PARSE, KEYPATH, DEFAULT_VALUE, \
IMPLIED_CHECK, IMPLIED_VALUE, NORMALIZER, \
MERGER, TABLE_INDEX)
#include "clang/Driver/Options.inc"
#undef OPTION_WITH_MARSHALLING

return Success;
}

#undef PARSE_OPTION_WITH_MARSHALLING

bool clang::ParseDiagnosticArgs(DiagnosticOptions &Opts, ArgList &Args,
DiagnosticsEngine *Diags,
bool DefaultDiagColor) {
Optional<DiagnosticsEngine> IgnoringDiags;
if (!Diags) {
IgnoringDiags.emplace(new DiagnosticIDs(), new DiagnosticOptions(),
new IgnoringDiagConsumer());
Diags = &*IgnoringDiags;
}

bool Success = true;

Opts.DiagnosticLogFile =
Expand Down Expand Up @@ -1439,10 +1479,9 @@ bool clang::ParseDiagnosticArgs(DiagnosticOptions &Opts, ArgList &Args,
Opts.setShowOverloads(Ovl_All);
else {
Success = false;
if (Diags)
Diags->Report(diag::err_drv_invalid_value)
<< Args.getLastArg(OPT_fshow_overloads_EQ)->getAsString(Args)
<< ShowOverloads;
Diags->Report(diag::err_drv_invalid_value)
<< Args.getLastArg(OPT_fshow_overloads_EQ)->getAsString(Args)
<< ShowOverloads;
}

StringRef ShowCategory =
Expand All @@ -1455,10 +1494,9 @@ bool clang::ParseDiagnosticArgs(DiagnosticOptions &Opts, ArgList &Args,
Opts.ShowCategories = 2;
else {
Success = false;
if (Diags)
Diags->Report(diag::err_drv_invalid_value)
<< Args.getLastArg(OPT_fdiagnostics_show_category)->getAsString(Args)
<< ShowCategory;
Diags->Report(diag::err_drv_invalid_value)
<< Args.getLastArg(OPT_fdiagnostics_show_category)->getAsString(Args)
<< ShowCategory;
}

StringRef Format =
Expand All @@ -1474,10 +1512,9 @@ bool clang::ParseDiagnosticArgs(DiagnosticOptions &Opts, ArgList &Args,
Opts.setFormat(DiagnosticOptions::Vi);
else {
Success = false;
if (Diags)
Diags->Report(diag::err_drv_invalid_value)
<< Args.getLastArg(OPT_fdiagnostics_format)->getAsString(Args)
<< Format;
Diags->Report(diag::err_drv_invalid_value)
<< Args.getLastArg(OPT_fdiagnostics_format)->getAsString(Args)
<< Format;
}

Opts.ShowSourceRanges = Args.hasArg(OPT_fdiagnostics_print_source_range_info);
Expand All @@ -1488,7 +1525,7 @@ bool clang::ParseDiagnosticArgs(DiagnosticOptions &Opts, ArgList &Args,
Opts.VerifyPrefixes.push_back("expected");
// Keep VerifyPrefixes in its original order for the sake of diagnostics, and
// then sort it to prepare for fast lookup using std::binary_search.
if (!checkVerifyPrefixes(Opts.VerifyPrefixes, Diags)) {
if (!checkVerifyPrefixes(Opts.VerifyPrefixes, *Diags)) {
Opts.VerifyDiagnostics = false;
Success = false;
}
Expand All @@ -1497,7 +1534,7 @@ bool clang::ParseDiagnosticArgs(DiagnosticOptions &Opts, ArgList &Args,
DiagnosticLevelMask DiagMask = DiagnosticLevelMask::None;
Success &= parseDiagnosticLevelMask("-verify-ignore-unexpected=",
Args.getAllArgValues(OPT_verify_ignore_unexpected_EQ),
Diags, DiagMask);
*Diags, DiagMask);
if (Args.hasArg(OPT_verify_ignore_unexpected))
DiagMask = DiagnosticLevelMask::All;
Opts.setVerifyIgnoreUnexpected(DiagMask);
Expand All @@ -1523,9 +1560,8 @@ bool clang::ParseDiagnosticArgs(DiagnosticOptions &Opts, ArgList &Args,
DiagnosticOptions::DefaultTabStop, Diags);
if (Opts.TabStop == 0 || Opts.TabStop > DiagnosticOptions::MaxTabStop) {
Opts.TabStop = DiagnosticOptions::DefaultTabStop;
if (Diags)
Diags->Report(diag::warn_ignoring_ftabstop_value)
<< Opts.TabStop << DiagnosticOptions::DefaultTabStop;
Diags->Report(diag::warn_ignoring_ftabstop_value)
<< Opts.TabStop << DiagnosticOptions::DefaultTabStop;
}
Opts.MessageLength =
getLastArgIntValue(Args, OPT_fmessage_length_EQ, 0, Diags);
Expand Down Expand Up @@ -2971,32 +3007,6 @@ static void ParseTargetArgs(TargetOptions &Opts, ArgList &Args,
}
}

bool CompilerInvocation::parseSimpleArgs(const ArgList &Args,
DiagnosticsEngine &Diags) {
bool Success = true;

#define OPTION_WITH_MARSHALLING( \
PREFIX_TYPE, NAME, ID, KIND, GROUP, ALIAS, ALIASARGS, FLAGS, PARAM, \
HELPTEXT, METAVAR, VALUES, SPELLING, SHOULD_PARSE, ALWAYS_EMIT, KEYPATH, \
DEFAULT_VALUE, IMPLIED_CHECK, IMPLIED_VALUE, NORMALIZER, DENORMALIZER, \
MERGER, EXTRACTOR, TABLE_INDEX) \
if ((FLAGS)&options::CC1Option) { \
this->KEYPATH = MERGER(this->KEYPATH, DEFAULT_VALUE); \
if (IMPLIED_CHECK) \
this->KEYPATH = MERGER(this->KEYPATH, IMPLIED_VALUE); \
if (SHOULD_PARSE) \
if (auto MaybeValue = \
NORMALIZER(OPT_##ID, TABLE_INDEX, Args, Diags, Success)) \
this->KEYPATH = MERGER( \
this->KEYPATH, static_cast<decltype(this->KEYPATH)>(*MaybeValue)); \
}

#include "clang/Driver/Options.inc"
#undef OPTION_WITH_MARSHALLING

return Success;
}

bool CompilerInvocation::CreateFromArgs(CompilerInvocation &Res,
ArrayRef<const char *> CommandLineArgs,
DiagnosticsEngine &Diags,
Expand Down
6 changes: 3 additions & 3 deletions clang/lib/Tooling/CompilationDatabase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,7 @@ std::unique_ptr<FixedCompilationDatabase>
FixedCompilationDatabase::loadFromCommandLine(int &Argc,
const char *const *Argv,
std::string &ErrorMsg,
Twine Directory) {
const Twine &Directory) {
ErrorMsg.clear();
if (Argc == 0)
return nullptr;
Expand Down Expand Up @@ -368,8 +368,8 @@ FixedCompilationDatabase::loadFromBuffer(StringRef Directory, StringRef Data,
return std::make_unique<FixedCompilationDatabase>(Directory, std::move(Args));
}

FixedCompilationDatabase::
FixedCompilationDatabase(Twine Directory, ArrayRef<std::string> CommandLine) {
FixedCompilationDatabase::FixedCompilationDatabase(
const Twine &Directory, ArrayRef<std::string> CommandLine) {
std::vector<std::string> ToolCommandLine(1, GetClangToolCommand());
ToolCommandLine.insert(ToolCommandLine.end(),
CommandLine.begin(), CommandLine.end());
Expand Down
23 changes: 22 additions & 1 deletion flang/lib/Semantics/check-acc-structure.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -134,9 +134,30 @@ void AccStructureChecker::Enter(
}

void AccStructureChecker::Leave(
const parser::OpenACCStandaloneDeclarativeConstruct &) {
const parser::OpenACCStandaloneDeclarativeConstruct &x) {
// Restriction - line 2409
CheckAtLeastOneClause();

// Restriction - line 2417-2418 - In a Fortran module declaration section,
// only create, copyin, device_resident, and link clauses are allowed.
const auto &declarativeDir{std::get<parser::AccDeclarativeDirective>(x.t)};
const auto &scope{context_.FindScope(declarativeDir.source)};
const Scope &containingScope{GetProgramUnitContaining(scope)};
if (containingScope.kind() == Scope::Kind::Module) {
for (auto cl : GetContext().actualClauses) {
if (cl != llvm::acc::Clause::ACCC_create &&
cl != llvm::acc::Clause::ACCC_copyin &&
cl != llvm::acc::Clause::ACCC_device_resident &&
cl != llvm::acc::Clause::ACCC_link)
context_.Say(GetContext().directiveSource,
"%s clause is not allowed on the %s directive in module "
"declaration "
"section"_err_en_US,
parser::ToUpperCaseLetters(
llvm::acc::getOpenACCClauseName(cl).str()),
ContextDirectiveAsFortran());
}
}
dirContext_.pop_back();
}

Expand Down
80 changes: 80 additions & 0 deletions flang/lib/Semantics/resolve-directives.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ class AccAttributeVisitor : DirectiveAttributeVisitor<llvm::acc::Directive> {

bool Pre(const parser::OpenACCRoutineConstruct &);
bool Pre(const parser::AccBindClause &);
void Post(const parser::OpenACCStandaloneDeclarativeConstruct &);

void Post(const parser::AccBeginBlockDirective &) {
GetContext().withinConstruct = true;
Expand Down Expand Up @@ -215,6 +216,7 @@ class AccAttributeVisitor : DirectiveAttributeVisitor<llvm::acc::Directive> {
void CheckMultipleAppearances(
const parser::Name &, const Symbol &, Symbol::Flag);
void AllowOnlyArrayAndSubArray(const parser::AccObjectList &objectList);
void DoNotAllowAssumedSizedArray(const parser::AccObjectList &objectList);
};

// Data-sharing and Data-mapping attributes for data-refs in OpenMP construct
Expand Down Expand Up @@ -470,6 +472,60 @@ bool AccAttributeVisitor::Pre(const parser::OpenACCDeclarativeConstruct &x) {
return true;
}

static const parser::AccObjectList &GetAccObjectList(
const parser::AccClause &clause) {
if (const auto *copyClause =
std::get_if<Fortran::parser::AccClause::Copy>(&clause.u)) {
return copyClause->v;
} else if (const auto *createClause =
std::get_if<Fortran::parser::AccClause::Create>(&clause.u)) {
const Fortran::parser::AccObjectListWithModifier &listWithModifier =
createClause->v;
const Fortran::parser::AccObjectList &accObjectList =
std::get<Fortran::parser::AccObjectList>(listWithModifier.t);
return accObjectList;
} else if (const auto *copyinClause =
std::get_if<Fortran::parser::AccClause::Copyin>(&clause.u)) {
const Fortran::parser::AccObjectListWithModifier &listWithModifier =
copyinClause->v;
const Fortran::parser::AccObjectList &accObjectList =
std::get<Fortran::parser::AccObjectList>(listWithModifier.t);
return accObjectList;
} else if (const auto *copyoutClause =
std::get_if<Fortran::parser::AccClause::Copyout>(&clause.u)) {
const Fortran::parser::AccObjectListWithModifier &listWithModifier =
copyoutClause->v;
const Fortran::parser::AccObjectList &accObjectList =
std::get<Fortran::parser::AccObjectList>(listWithModifier.t);
return accObjectList;
} else if (const auto *presentClause =
std::get_if<Fortran::parser::AccClause::Present>(&clause.u)) {
return presentClause->v;
} else if (const auto *deviceptrClause =
std::get_if<Fortran::parser::AccClause::Deviceptr>(
&clause.u)) {
return deviceptrClause->v;
} else if (const auto *deviceResidentClause =
std::get_if<Fortran::parser::AccClause::DeviceResident>(
&clause.u)) {
return deviceResidentClause->v;
} else if (const auto *linkClause =
std::get_if<Fortran::parser::AccClause::Link>(&clause.u)) {
return linkClause->v;
} else {
llvm_unreachable("Clause without object list!");
}
}

void AccAttributeVisitor::Post(
const parser::OpenACCStandaloneDeclarativeConstruct &x) {
const auto &clauseList = std::get<parser::AccClauseList>(x.t);
for (const auto &clause : clauseList.v) {
// Restriction - line 2414
DoNotAllowAssumedSizedArray(GetAccObjectList(clause));
}
}

bool AccAttributeVisitor::Pre(const parser::OpenACCLoopConstruct &x) {
const auto &beginDir{std::get<parser::AccBeginLoopDirective>(x.t)};
const auto &loopDir{std::get<parser::AccLoopDirective>(beginDir.t)};
Expand Down Expand Up @@ -588,6 +644,30 @@ void AccAttributeVisitor::AllowOnlyArrayAndSubArray(
}
}

void AccAttributeVisitor::DoNotAllowAssumedSizedArray(
const parser::AccObjectList &objectList) {
for (const auto &accObject : objectList.v) {
std::visit(
common::visitors{
[&](const parser::Designator &designator) {
const auto &name{GetLastName(designator)};
if (name.symbol && semantics::IsAssumedSizeArray(*name.symbol))
context_.Say(designator.source,
"Assumed-size dummy arrays may not appear on the %s "
"directive"_err_en_US,
parser::ToUpperCaseLetters(
llvm::acc::getOpenACCDirectiveName(
GetContext().directive)
.str()));
},
[&](const auto &name) {

},
},
accObject.u);
}
}

bool AccAttributeVisitor::Pre(const parser::OpenACCCacheConstruct &x) {
const auto &verbatim{std::get<parser::Verbatim>(x.t)};
PushContext(verbatim.source, llvm::acc::Directive::ACCD_cache);
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Loading

0 comments on commit e344f05

Please sign in to comment.