Skip to content

Commit

Permalink
Merged main:3bd2ad5a0828 into amd-gfx:655807befc95
Browse files Browse the repository at this point in the history
Local branch amd-gfx 655807b Merged main:9935b0fc9023 into amd-gfx:e448aeec0a4c
Remote branch main 3bd2ad5 [DFSan] Add several math functions to ABI list.
  • Loading branch information
Sw authored and Sw committed Dec 8, 2020
2 parents 655807b + 3bd2ad5 commit ce73b58
Show file tree
Hide file tree
Showing 90 changed files with 3,039 additions and 659 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,10 @@ void NarrowingConversionsCheck::registerMatchers(MatchFinder *Finder) {
Finder->addMatcher(
traverse(
ast_type_traits::TK_AsIs,
implicitCastExpr(hasImplicitDestinationType(builtinType()),
hasSourceExpression(hasType(builtinType())),
implicitCastExpr(hasImplicitDestinationType(
hasUnqualifiedDesugaredType(builtinType())),
hasSourceExpression(hasType(
hasUnqualifiedDesugaredType(builtinType()))),
unless(hasSourceExpression(IsCeilFloorCallExpr)),
unless(hasParent(castExpr())),
unless(isInTemplateInstantiation()))
Expand All @@ -58,16 +60,18 @@ void NarrowingConversionsCheck::registerMatchers(MatchFinder *Finder) {

// Binary operators:
// i += 0.5;
Finder->addMatcher(binaryOperator(isAssignmentOperator(),
hasLHS(expr(hasType(builtinType()))),
hasRHS(expr(hasType(builtinType()))),
unless(hasRHS(IsCeilFloorCallExpr)),
unless(isInTemplateInstantiation()),
// The `=` case generates an implicit cast
// which is covered by the previous matcher.
unless(hasOperatorName("=")))
.bind("binary_op"),
this);
Finder->addMatcher(
binaryOperator(
isAssignmentOperator(),
hasLHS(expr(hasType(hasUnqualifiedDesugaredType(builtinType())))),
hasRHS(expr(hasType(hasUnqualifiedDesugaredType(builtinType())))),
unless(hasRHS(IsCeilFloorCallExpr)),
unless(isInTemplateInstantiation()),
// The `=` case generates an implicit cast
// which is covered by the previous matcher.
unless(hasOperatorName("=")))
.bind("binary_op"),
this);
}

static const BuiltinType *getBuiltinType(const Expr &E) {
Expand Down
15 changes: 7 additions & 8 deletions clang-tools-extra/clangd/ConfigProvider.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ Provider::fromAncestorRelativeYAMLFiles(llvm::StringRef RelPath,

std::unique_ptr<Provider>
Provider::combine(std::vector<const Provider *> Providers) {
struct CombinedProvider : Provider {
class CombinedProvider : public Provider {
std::vector<const Provider *> Providers;

std::vector<CompiledFragment>
Expand All @@ -156,14 +156,13 @@ Provider::combine(std::vector<const Provider *> Providers) {
}
return Result;
}

public:
CombinedProvider(std::vector<const Provider *> Providers)
: Providers(std::move(Providers)) {}
};
auto Result = std::make_unique<CombinedProvider>();
Result->Providers = std::move(Providers);
// FIXME: This is a workaround for a bug in older versions of clang (< 3.9)
// The constructor that is supposed to allow for Derived to Base
// conversion does not work. Remove this if we drop support for such
// configurations.
return std::unique_ptr<Provider>(Result.release());

return std::make_unique<CombinedProvider>(std::move(Providers));
}

Config Provider::getConfig(const Params &P, DiagnosticCallback DC) const {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -343,4 +343,17 @@ void macro_context() {
DERP(i, .5l);
}

// We understand typedefs.
void typedef_context() {
typedef long long myint64_t;
int i;
myint64_t i64;

i64 = i64; // Okay, no conversion.
i64 = i; // Okay, no narrowing.

i = i64;
// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: narrowing conversion from 'myint64_t' (aka 'long long') to signed type 'int' is implementation-defined [cppcoreguidelines-narrowing-conversions]
}

} // namespace floats
3 changes: 2 additions & 1 deletion clang/include/clang/Basic/CodeGenOptions.def
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,8 @@ CODEGENOPT(SpeculativeLoadHardening, 1, 0) ///< Enable speculative load hardenin
CODEGENOPT(FineGrainedBitfieldAccesses, 1, 0) ///< Enable fine-grained bitfield accesses.
CODEGENOPT(StrictEnums , 1, 0) ///< Optimize based on strict enum definition.
CODEGENOPT(StrictVTablePointers, 1, 0) ///< Optimize based on the strict vtable pointers
CODEGENOPT(TimePasses , 1, 0) ///< Set when -ftime-report is enabled.
CODEGENOPT(TimePasses , 1, 0) ///< Set when -ftime-report or -ftime-report= is enabled.
CODEGENOPT(TimePassesPerRun , 1, 0) ///< Set when -ftime-report=per-pass-run is enabled.
CODEGENOPT(TimeTrace , 1, 0) ///< Set when -ftime-trace is enabled.
VALUE_CODEGENOPT(TimeTraceGranularity, 32, 500) ///< Minimum time granularity (in microseconds),
///< traced by time profiler
Expand Down
7 changes: 6 additions & 1 deletion clang/include/clang/Driver/Options.td
Original file line number Diff line number Diff line change
Expand Up @@ -2005,7 +2005,12 @@ def Wframe_larger_than_EQ : Joined<["-"], "Wframe-larger-than=">, Group<f_Group>
def : Flag<["-"], "fterminated-vtables">, Alias<fapple_kext>;
def fthreadsafe_statics : Flag<["-"], "fthreadsafe-statics">, Group<f_Group>;
def ftime_report : Flag<["-"], "ftime-report">, Group<f_Group>, Flags<[CC1Option]>,
MarshallingInfoFlag<"FrontendOpts.ShowTimers">;
MarshallingInfoFlag<"CodeGenOpts.TimePasses">;
def ftime_report_EQ: Joined<["-"], "ftime-report=">, Group<f_Group>,
Flags<[CC1Option]>, Values<"per-pass,per-pass-run">,
MarshallingInfoFlag<"CodeGenOpts.TimePassesPerRun">,
HelpText<"(For new pass manager) \"per-pass\": one report for each pass; "
"\"per-pass-run\": one report for each pass invocation">;
def ftime_trace : Flag<["-"], "ftime-trace">, Group<f_Group>,
HelpText<"Turn on time profiler. Generates JSON file based on output filename.">,
DocBrief<[{
Expand Down
21 changes: 9 additions & 12 deletions clang/include/clang/Frontend/FrontendOptions.h
Original file line number Diff line number Diff line change
Expand Up @@ -239,9 +239,6 @@ class FrontendOptions {
/// Show frontend performance metrics and statistics.
unsigned ShowStats : 1;

/// Show timers for individual actions.
unsigned ShowTimers : 1;

/// print the supported cpus for the current target
unsigned PrintSupportedCPUs : 1;

Expand Down Expand Up @@ -453,15 +450,15 @@ class FrontendOptions {
public:
FrontendOptions()
: DisableFree(false), RelocatablePCH(false), ShowHelp(false),
ShowStats(false), ShowTimers(false), TimeTrace(false),
ShowVersion(false), FixWhatYouCan(false), FixOnlyWarnings(false),
FixAndRecompile(false), FixToTemporaries(false),
ARCMTMigrateEmitARCErrors(false), SkipFunctionBodies(false),
UseGlobalModuleIndex(true), GenerateGlobalModuleIndex(true),
ASTDumpDecls(false), ASTDumpLookups(false),
BuildingImplicitModule(false), ModulesEmbedAllFiles(false),
IncludeTimestamps(true), UseTemporary(true),
AllowPCMWithCompilerErrors(false), TimeTraceGranularity(500) {}
ShowStats(false), TimeTrace(false), ShowVersion(false),
FixWhatYouCan(false), FixOnlyWarnings(false), FixAndRecompile(false),
FixToTemporaries(false), ARCMTMigrateEmitARCErrors(false),
SkipFunctionBodies(false), UseGlobalModuleIndex(true),
GenerateGlobalModuleIndex(true), ASTDumpDecls(false),
ASTDumpLookups(false), BuildingImplicitModule(false),
ModulesEmbedAllFiles(false), IncludeTimestamps(true),
UseTemporary(true), AllowPCMWithCompilerErrors(false),
TimeTraceGranularity(500) {}

/// getInputKindForExtension - Return the appropriate input kind for a file
/// extension. For example, "c" would return Language::C.
Expand Down
4 changes: 0 additions & 4 deletions clang/include/clang/Frontend/Utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -227,10 +227,6 @@ std::unique_ptr<CompilerInvocation> createInvocationFromCommandLine(

// Frontend timing utils

/// If the user specifies the -ftime-report argument on an Clang command line
/// then the value of this boolean will be true, otherwise false.
extern bool FrontendTimesIsEnabled;

} // namespace clang

#endif // LLVM_CLANG_FRONTEND_UTILS_H
4 changes: 2 additions & 2 deletions clang/lib/CodeGen/BackendUtil.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -907,7 +907,7 @@ bool EmitAssemblyHelper::AddEmitPasses(legacy::PassManager &CodeGenPasses,

void EmitAssemblyHelper::EmitAssembly(BackendAction Action,
std::unique_ptr<raw_pwrite_stream> OS) {
TimeRegion Region(FrontendTimesIsEnabled ? &CodeGenerationTime : nullptr);
TimeRegion Region(CodeGenOpts.TimePasses ? &CodeGenerationTime : nullptr);

setCommandLineOpts(CodeGenOpts);

Expand Down Expand Up @@ -1064,7 +1064,7 @@ static PassBuilder::OptimizationLevel mapToLevel(const CodeGenOptions &Opts) {
/// `EmitAssembly` at some point in the future when the default switches.
void EmitAssemblyHelper::EmitAssemblyWithNewPassManager(
BackendAction Action, std::unique_ptr<raw_pwrite_stream> OS) {
TimeRegion Region(FrontendTimesIsEnabled ? &CodeGenerationTime : nullptr);
TimeRegion Region(CodeGenOpts.TimePasses ? &CodeGenerationTime : nullptr);
setCommandLineOpts(CodeGenOpts);

bool RequiresCodeGen = (Action != Backend_EmitNothing &&
Expand Down
38 changes: 20 additions & 18 deletions clang/lib/CodeGen/CodeGenAction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,8 @@ namespace clang {
/// can happen when Clang plugins trigger additional AST deserialization.
bool IRGenFinished = false;

bool TimerIsEnabled = false;

std::unique_ptr<CodeGenerator> Gen;

SmallVector<LinkModule, 4> LinkModules;
Expand All @@ -136,8 +138,7 @@ namespace clang {
const PreprocessorOptions &PPOpts,
const CodeGenOptions &CodeGenOpts,
const TargetOptions &TargetOpts,
const LangOptions &LangOpts, bool TimePasses,
const std::string &InFile,
const LangOptions &LangOpts, const std::string &InFile,
SmallVector<LinkModule, 4> LinkModules,
std::unique_ptr<raw_pwrite_stream> OS, LLVMContext &C,
CoverageSourceInfo *CoverageInfo = nullptr)
Expand All @@ -149,8 +150,9 @@ namespace clang {
Gen(CreateLLVMCodeGen(Diags, InFile, HeaderSearchOpts, PPOpts,
CodeGenOpts, C, CoverageInfo)),
LinkModules(std::move(LinkModules)) {
FrontendTimesIsEnabled = TimePasses;
llvm::TimePassesIsEnabled = TimePasses;
TimerIsEnabled = CodeGenOpts.TimePasses;
llvm::TimePassesIsEnabled = CodeGenOpts.TimePasses;
llvm::TimePassesPerRun = CodeGenOpts.TimePassesPerRun;
}

// This constructor is used in installing an empty BackendConsumer
Expand All @@ -161,7 +163,7 @@ namespace clang {
const PreprocessorOptions &PPOpts,
const CodeGenOptions &CodeGenOpts,
const TargetOptions &TargetOpts,
const LangOptions &LangOpts, bool TimePasses,
const LangOptions &LangOpts,
SmallVector<LinkModule, 4> LinkModules, LLVMContext &C,
CoverageSourceInfo *CoverageInfo = nullptr)
: Diags(Diags), Action(Action), HeaderSearchOpts(HeaderSearchOpts),
Expand All @@ -172,8 +174,9 @@ namespace clang {
Gen(CreateLLVMCodeGen(Diags, "", HeaderSearchOpts, PPOpts,
CodeGenOpts, C, CoverageInfo)),
LinkModules(std::move(LinkModules)) {
FrontendTimesIsEnabled = TimePasses;
llvm::TimePassesIsEnabled = TimePasses;
TimerIsEnabled = CodeGenOpts.TimePasses;
llvm::TimePassesIsEnabled = CodeGenOpts.TimePasses;
llvm::TimePassesPerRun = CodeGenOpts.TimePassesPerRun;
}
llvm::Module *getModule() const { return Gen->GetModule(); }
std::unique_ptr<llvm::Module> takeModule() {
Expand All @@ -191,12 +194,12 @@ namespace clang {

Context = &Ctx;

if (FrontendTimesIsEnabled)
if (TimerIsEnabled)
LLVMIRGeneration.startTimer();

Gen->Initialize(Ctx);

if (FrontendTimesIsEnabled)
if (TimerIsEnabled)
LLVMIRGeneration.stopTimer();
}

Expand All @@ -206,15 +209,15 @@ namespace clang {
"LLVM IR generation of declaration");

// Recurse.
if (FrontendTimesIsEnabled) {
if (TimerIsEnabled) {
LLVMIRGenerationRefCount += 1;
if (LLVMIRGenerationRefCount == 1)
LLVMIRGeneration.startTimer();
}

Gen->HandleTopLevelDecl(D);

if (FrontendTimesIsEnabled) {
if (TimerIsEnabled) {
LLVMIRGenerationRefCount -= 1;
if (LLVMIRGenerationRefCount == 0)
LLVMIRGeneration.stopTimer();
Expand All @@ -227,12 +230,12 @@ namespace clang {
PrettyStackTraceDecl CrashInfo(D, SourceLocation(),
Context->getSourceManager(),
"LLVM IR generation of inline function");
if (FrontendTimesIsEnabled)
if (TimerIsEnabled)
LLVMIRGeneration.startTimer();

Gen->HandleInlineFunctionDefinition(D);

if (FrontendTimesIsEnabled)
if (TimerIsEnabled)
LLVMIRGeneration.stopTimer();
}

Expand Down Expand Up @@ -280,15 +283,15 @@ namespace clang {
{
llvm::TimeTraceScope TimeScope("Frontend");
PrettyStackTraceString CrashInfo("Per-file LLVM IR generation");
if (FrontendTimesIsEnabled) {
if (TimerIsEnabled) {
LLVMIRGenerationRefCount += 1;
if (LLVMIRGenerationRefCount == 1)
LLVMIRGeneration.startTimer();
}

Gen->HandleTranslationUnit(C);

if (FrontendTimesIsEnabled) {
if (TimerIsEnabled) {
LLVMIRGenerationRefCount -= 1;
if (LLVMIRGenerationRefCount == 0)
LLVMIRGeneration.stopTimer();
Expand Down Expand Up @@ -967,8 +970,8 @@ CodeGenAction::CreateASTConsumer(CompilerInstance &CI, StringRef InFile) {
std::unique_ptr<BackendConsumer> Result(new BackendConsumer(
BA, CI.getDiagnostics(), CI.getHeaderSearchOpts(),
CI.getPreprocessorOpts(), CI.getCodeGenOpts(), CI.getTargetOpts(),
CI.getLangOpts(), CI.getFrontendOpts().ShowTimers, std::string(InFile),
std::move(LinkModules), std::move(OS), *VMContext, CoverageInfo));
CI.getLangOpts(), std::string(InFile), std::move(LinkModules),
std::move(OS), *VMContext, CoverageInfo));
BEConsumer = Result.get();

// Enable generating macro debug info only when debug info is not disabled and
Expand Down Expand Up @@ -1115,7 +1118,6 @@ void CodeGenAction::ExecuteAction() {
BackendConsumer Result(BA, CI.getDiagnostics(), CI.getHeaderSearchOpts(),
CI.getPreprocessorOpts(), CI.getCodeGenOpts(),
CI.getTargetOpts(), CI.getLangOpts(),
CI.getFrontendOpts().ShowTimers,
std::move(LinkModules), *VMContext, nullptr);
// PR44896: Force DiscardValueNames as false. DiscardValueNames cannot be
// true here because the valued names are needed for reading textual IR.
Expand Down
1 change: 1 addition & 0 deletions clang/lib/Driver/ToolChains/Clang.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5501,6 +5501,7 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA,
Args.AddLastArg(CmdArgs, options::OPT_fdiagnostics_print_source_range_info);
Args.AddLastArg(CmdArgs, options::OPT_fdiagnostics_parseable_fixits);
Args.AddLastArg(CmdArgs, options::OPT_ftime_report);
Args.AddLastArg(CmdArgs, options::OPT_ftime_report_EQ);
Args.AddLastArg(CmdArgs, options::OPT_ftime_trace);
Args.AddLastArg(CmdArgs, options::OPT_ftime_trace_granularity_EQ);
Args.AddLastArg(CmdArgs, options::OPT_ftrapv);
Expand Down
1 change: 0 additions & 1 deletion clang/lib/Frontend/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ add_clang_library(clangFrontend
FrontendAction.cpp
FrontendActions.cpp
FrontendOptions.cpp
FrontendTiming.cpp
HeaderIncludeGen.cpp
InitHeaderSearch.cpp
InitPreprocessor.cpp
Expand Down
2 changes: 1 addition & 1 deletion clang/lib/Frontend/CompilerInstance.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -975,7 +975,7 @@ bool CompilerInstance::ExecuteAction(FrontendAction &Act) {
<< " based upon " << BACKEND_PACKAGE_STRING
<< " default target " << llvm::sys::getDefaultTargetTriple() << "\n";

if (getFrontendOpts().ShowTimers)
if (getCodeGenOpts().TimePasses)
createFrontendTimer();

if (getFrontendOpts().ShowStats || !getFrontendOpts().StatsFile.empty())
Expand Down
20 changes: 20 additions & 0 deletions clang/lib/Frontend/CompilerInvocation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1046,6 +1046,26 @@ static bool ParseCodeGenArgs(CodeGenOptions &Opts, ArgList &Args, InputKind IK,
Opts.setFramePointer(FP);
}

if (const Arg *A = Args.getLastArg(OPT_ftime_report, OPT_ftime_report_EQ)) {
Opts.TimePasses = true;

// -ftime-report= is only for new pass manager.
if (A->getOption().getID() == OPT_ftime_report_EQ) {
if (!Opts.ExperimentalNewPassManager)
Diags.Report(diag::err_drv_argument_only_allowed_with)
<< A->getAsString(Args) << "-fexperimental-new-pass-manager";

StringRef Val = A->getValue();
if (Val == "per-pass")
Opts.TimePassesPerRun = false;
else if (Val == "per-pass-run")
Opts.TimePassesPerRun = true;
else
Diags.Report(diag::err_drv_invalid_value)
<< A->getAsString(Args) << A->getValue();
}
}

Opts.DisableFree = Args.hasArg(OPT_disable_free);
Opts.DiscardValueNames = Args.hasArg(OPT_discard_value_names);
Opts.DisableTailCalls = Args.hasArg(OPT_mdisable_tail_calls);
Expand Down
19 changes: 0 additions & 19 deletions clang/lib/Frontend/FrontendTiming.cpp

This file was deleted.

2 changes: 1 addition & 1 deletion clang/lib/Parse/ParseDecl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1119,7 +1119,7 @@ void Parser::ParseAvailabilityAttribute(IdentifierInfo &Availability,
// Also reject wide string literals.
if (StringLiteral *MessageStringLiteral =
cast_or_null<StringLiteral>(MessageExpr.get())) {
if (MessageStringLiteral->getCharByteWidth() != 1) {
if (!MessageStringLiteral->isAscii()) {
Diag(MessageStringLiteral->getSourceRange().getBegin(),
diag::err_expected_string_literal)
<< /*Source='availability attribute'*/ 2;
Expand Down
Loading

0 comments on commit ce73b58

Please sign in to comment.