[llvm-branch-commits] [llvm] caeb565 - [clang][cli] Convert Analyzer option string based options to new option parsing system
Author: Jan Svoboda Date: 2020-12-18T08:56:06+01:00 New Revision: caeb56503ec897c7244cff0657c11e87d2644f82 URL: https://github.com/llvm/llvm-project/commit/caeb56503ec897c7244cff0657c11e87d2644f82 DIFF: https://github.com/llvm/llvm-project/commit/caeb56503ec897c7244cff0657c11e87d2644f82.diff LOG: [clang][cli] Convert Analyzer option string based options to new option parsing system Depends on D84185 Reviewed By: dexonsmith Original patch by Daniel Grumberg. Differential Revision: https://reviews.llvm.org/D84186 Added: Modified: clang/include/clang/Driver/Options.td clang/include/clang/StaticAnalyzer/Core/AnalyzerOptions.h clang/lib/Frontend/CompilerInvocation.cpp llvm/include/llvm/Option/OptParser.td Removed: diff --git a/clang/include/clang/Driver/Options.td b/clang/include/clang/Driver/Options.td index ca9615e2e769..9987143009d3 100644 --- a/clang/include/clang/Driver/Options.td +++ b/clang/include/clang/Driver/Options.td @@ -4110,7 +4110,8 @@ def analyzer_display_progress : Flag<["-"], "analyzer-display-progress">, HelpText<"Emit verbose output about the analyzer's progress">, MarshallingInfoFlag<"AnalyzerOpts->AnalyzerDisplayProgress">; def analyze_function : Separate<["-"], "analyze-function">, - HelpText<"Run analysis on specific function (for C++ include parameters in name)">; + HelpText<"Run analysis on specific function (for C++ include parameters in name)">, + MarshallingInfoString<"AnalyzerOpts->AnalyzeSpecificFunction">; def analyze_function_EQ : Joined<["-"], "analyze-function=">, Alias; def trim_egraph : Flag<["-"], "trim-egraph">, HelpText<"Only show error-related paths in the analysis graph">, @@ -4124,7 +4125,9 @@ def analyzer_dump_egraph : Separate<["-"], "analyzer-dump-egraph">, def analyzer_dump_egraph_EQ : Joined<["-"], "analyzer-dump-egraph=">, Alias; def analyzer_inline_max_stack_depth : Separate<["-"], "analyzer-inline-max-stack-depth">, - HelpText<"Bound on stack depth while inlining (4 by default)">; + HelpText<"Bound on stack depth while inlining (4 by default)">, + // Cap the stack depth at 4 calls (5 stack frames, base + 4 calls). + MarshallingInfoStringInt<"AnalyzerOpts->InlineMaxStackDepth", "5">; def analyzer_inline_max_stack_depth_EQ : Joined<["-"], "analyzer-inline-max-stack-depth=">, Alias; @@ -4137,7 +4140,8 @@ def analyzer_disable_retry_exhausted : Flag<["-"], "analyzer-disable-retry-exhau MarshallingInfoFlag<"AnalyzerOpts->NoRetryExhausted">; def analyzer_max_loop : Separate<["-"], "analyzer-max-loop">, - HelpText<"The maximum number of times the analyzer will go through a loop">; + HelpText<"The maximum number of times the analyzer will go through a loop">, + MarshallingInfoStringInt<"AnalyzerOpts->maxBlockVisitOnPath", "4">; def analyzer_stats : Flag<["-"], "analyzer-stats">, HelpText<"Print internal analyzer statistics.">, MarshallingInfoFlag<"AnalyzerOpts->PrintStats">; diff --git a/clang/include/clang/StaticAnalyzer/Core/AnalyzerOptions.h b/clang/include/clang/StaticAnalyzer/Core/AnalyzerOptions.h index e1093772e02c..ccf35e0a81ec 100644 --- a/clang/include/clang/StaticAnalyzer/Core/AnalyzerOptions.h +++ b/clang/include/clang/StaticAnalyzer/Core/AnalyzerOptions.h @@ -259,8 +259,7 @@ class AnalyzerOptions : public RefCountedBase { bool AnalyzerWerror : 1; /// The inlining stack depth limit. - // Cap the stack depth at 4 calls (5 stack frames, base + 4 calls). - unsigned InlineMaxStackDepth = 5; + unsigned InlineMaxStackDepth; /// The mode of function selection used during inlining. AnalysisInliningMode InliningMode = NoRedundancy; diff --git a/clang/lib/Frontend/CompilerInvocation.cpp b/clang/lib/Frontend/CompilerInvocation.cpp index 5fbafa3b2583..d2b590f08507 100644 --- a/clang/lib/Frontend/CompilerInvocation.cpp +++ b/clang/lib/Frontend/CompilerInvocation.cpp @@ -93,6 +93,7 @@ #include #include #include +#include #include #include @@ -282,12 +283,38 @@ static Optional normalizeString(OptSpecifier Opt, int TableIndex, static void denormalizeString(SmallVectorImpl &Args, const char *Spelling, - CompilerInvocation::StringAllocator SA, - unsigned TableIndex, const std::string &Value) { + CompilerInvocation::StringAllocator SA, unsigned, + Twine Value) { Args.push_back(Spelling); Args.push_back(SA(Value)); } +template ::value && + std::is_constructible::value, + bool> = false> +static void denormalizeString(SmallVectorImpl &Args, + const char *Spelling, + CompilerInvocation::StringAllocator SA, + unsigned TableIndex, T Value) { + denormalizeString(Args, S
[llvm-branch-commits] [libc] 2d9ae1d - [libc][NFC] Use `#include ` in utils/FPUtil/ManipulationFunctions.h.
Author: Siva Chandra Reddy Date: 2020-12-18T00:05:02-08:00 New Revision: 2d9ae1d217890639518252ee1f39c9cc759749ef URL: https://github.com/llvm/llvm-project/commit/2d9ae1d217890639518252ee1f39c9cc759749ef DIFF: https://github.com/llvm/llvm-project/commit/2d9ae1d217890639518252ee1f39c9cc759749ef.diff LOG: [libc][NFC] Use `#include ` in utils/FPUtil/ManipulationFunctions.h. This reverts commit 352cba2441c6c4e00f067c9c68358cc0a6a5fffb. "add back math.h #include utils/FPUtil/ManipulationFunctions.h". Using `` correct so downstream setup should be fixed. Added: Modified: libc/utils/FPUtil/ManipulationFunctions.h Removed: diff --git a/libc/utils/FPUtil/ManipulationFunctions.h b/libc/utils/FPUtil/ManipulationFunctions.h index 2bac1b5c229f..79dc741ff629 100644 --- a/libc/utils/FPUtil/ManipulationFunctions.h +++ b/libc/utils/FPUtil/ManipulationFunctions.h @@ -13,10 +13,10 @@ #include "NearestIntegerOperations.h" #include "NormalFloat.h" -#include "include/math.h" #include "utils/CPP/TypeTraits.h" #include +#include namespace __llvm_libc { namespace fputil { ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [clang] f4511ae - [clang][cli] Port HeaderSearch simple string options to new option parsing system
Author: Jan Svoboda Date: 2020-12-18T09:30:32+01:00 New Revision: f4511aec2bf482f2ae5bbd14138a229b72c41c80 URL: https://github.com/llvm/llvm-project/commit/f4511aec2bf482f2ae5bbd14138a229b72c41c80 DIFF: https://github.com/llvm/llvm-project/commit/f4511aec2bf482f2ae5bbd14138a229b72c41c80.diff LOG: [clang][cli] Port HeaderSearch simple string options to new option parsing system Depends on D84669 Reviewed By: Bigcheese Original patch by Daniel Grumberg. Differential Revision: https://reviews.llvm.org/D84670 Added: Modified: clang/include/clang/Driver/Options.td clang/lib/Frontend/CompilerInvocation.cpp Removed: diff --git a/clang/include/clang/Driver/Options.td b/clang/include/clang/Driver/Options.td index 9987143009d3..7275e84d7c53 100644 --- a/clang/include/clang/Driver/Options.td +++ b/clang/include/clang/Driver/Options.td @@ -1797,7 +1797,8 @@ def fmodules_cache_path : Joined<["-"], "fmodules-cache-path=">, Group, HelpText<"Specify the module cache path">; def fmodules_user_build_path : Separate<["-"], "fmodules-user-build-path">, Group, Flags<[NoXarchOption, CC1Option]>, MetaVarName<"">, - HelpText<"Specify the module user build path">; + HelpText<"Specify the module user build path">, + MarshallingInfoString<"HeaderSearchOpts->ModuleUserBuildPath">; def fprebuilt_module_path : Joined<["-"], "fprebuilt-module-path=">, Group, Flags<[NoXarchOption, CC1Option]>, MetaVarName<"">, HelpText<"Specify the prebuilt module path">; @@ -1806,16 +1807,19 @@ defm prebuilt_implicit_modules : OptInFFlag<"prebuilt-implicit-modules", [NoXarchOption, CC1Option], "HeaderSearchOpts->EnablePrebuiltImplicitModules">; def fmodules_prune_interval : Joined<["-"], "fmodules-prune-interval=">, Group, Flags<[CC1Option]>, MetaVarName<"">, - HelpText<"Specify the interval (in seconds) between attempts to prune the module cache">; + HelpText<"Specify the interval (in seconds) between attempts to prune the module cache">, + MarshallingInfoStringInt<"HeaderSearchOpts->ModuleCachePruneInterval", "7 * 24 * 60 * 60">; def fmodules_prune_after : Joined<["-"], "fmodules-prune-after=">, Group, Flags<[CC1Option]>, MetaVarName<"">, - HelpText<"Specify the interval (in seconds) after which a module file will be considered unused">; + HelpText<"Specify the interval (in seconds) after which a module file will be considered unused">, + MarshallingInfoStringInt<"HeaderSearchOpts->ModuleCachePruneAfter", "31 * 24 * 60 * 60">; def fmodules_search_all : Flag <["-"], "fmodules-search-all">, Group, Flags<[NoXarchOption, CC1Option]>, HelpText<"Search even non-imported modules to resolve references">; def fbuild_session_timestamp : Joined<["-"], "fbuild-session-timestamp=">, Group, Flags<[CC1Option]>, MetaVarName<"">, - HelpText<"Time when the current build session started">; + HelpText<"Time when the current build session started">, + MarshallingInfoStringInt<"HeaderSearchOpts->BuildSessionTimestamp">; def fbuild_session_file : Joined<["-"], "fbuild-session-file=">, Group, MetaVarName<"">, HelpText<"Use the last modification time of as the build session timestamp">; @@ -2602,7 +2606,8 @@ def iprefix : JoinedOrSeparate<["-"], "iprefix">, Group, Flags<[C def iquote : JoinedOrSeparate<["-"], "iquote">, Group, Flags<[CC1Option]>, HelpText<"Add directory to QUOTE include search path">, MetaVarName<"">; def isysroot : JoinedOrSeparate<["-"], "isysroot">, Group, Flags<[CC1Option]>, - HelpText<"Set the system root directory (usually /)">, MetaVarName<"">; + HelpText<"Set the system root directory (usually /)">, MetaVarName<"">, + MarshallingInfoString<"HeaderSearchOpts->Sysroot", [{"/"}]>; def isystem : JoinedOrSeparate<["-"], "isystem">, Group, Flags<[CC1Option]>, HelpText<"Add directory to SYSTEM include search path">, MetaVarName<"">; @@ -3330,7 +3335,8 @@ def rewrite_legacy_objc : Flag<["-"], "rewrite-legacy-objc">, Flags<[NoXarchOpti def rdynamic : Flag<["-"], "rdynamic">, Group; def resource_dir : Separate<["-"], "resource-dir">, Flags<[NoXarchOption, CC1Option, CoreOption, HelpHidden]>, - HelpText<"The directory which holds the compiler resource files">; + HelpText<"The directory which holds the compiler resource files">, + MarshallingInfoString<"HeaderSearchOpts->ResourceDir">; def resource_dir_EQ : Joined<["-"], "resource-dir=">, Flags<[NoXarchOption, CoreOption]>, Alias; def rpath : Separate<["-"], "rpath">, Flags<[LinkerInput]>, Group; @@ -4671,7 +4677,8 @@ def fmodules_debuginfo : MarshallingInfoFlag<"LangOpts->ModulesDebugInfo">; def fmodule_format_EQ : Joined<["-"], "fmodule-format=">, HelpText<"Select the container format for clang modules and PCH. " - "Supported options are 'raw' and 'obj'.">; + "Supported options are 'raw' and 'obj'.">, + MarshallingInfoString<"HeaderSearchOpts->ModuleFormat", [{"ra
[llvm-branch-commits] [llvm] 9895c70 - [InlineCost] Implement cost-benefit-based inliner
Author: Kazu Hirata Date: 2020-12-18T00:37:24-08:00 New Revision: 9895c7012d61525ed541ef74d9eb43300bac9b0c URL: https://github.com/llvm/llvm-project/commit/9895c7012d61525ed541ef74d9eb43300bac9b0c DIFF: https://github.com/llvm/llvm-project/commit/9895c7012d61525ed541ef74d9eb43300bac9b0c.diff LOG: [InlineCost] Implement cost-benefit-based inliner This patch adds an alternative cost metric for the inliner to take into account both the cost (i.e. size) and cycle count savings into account. Without this patch, we decide to inline a given call site if the size of inlining the call site is below the threshold that is computed according to the hotness of the call site. This patch adds a new cost metric, turned off by default, to take over the handling of hot call sites. Specifically, with the new cost metric, we decide to inline a given call site if the ratio of cycle savings to size exceeds a threshold. The cycle savings are computed from call site costs, parameter propagation, folded conditional branches, etc, all weighted by their respective profile counts. The size is primarily the callee size, but we subtract call site costs and the size of basic blocks that are never executed. The new cost metric implicitly takes advantage of the machine function splitter recently introduced by Snehasish Kumar, which dramatically reduces the cost of duplicating (e.g. inlining) cold basic blocks by placing cold basic blocks of hot functions in the .text.split section. We evaluated the new cost metric on clang bootstrap and SPECInt 2017. For clang bootstrap, we observe 0.69% runtime improvement. For SPECInt we report the change in IntRate the C/C++ benchmarks. All benchmarks apart from perlbench and omnetpp improve, on average by 0.21% with the max for mcf at 1.96%. Benchmark % Change 500.perlbench_r -0.45 502.gcc_r0.13 505.mcf_r1.96 520.omnetpp_r -0.28 523.xalancbmk_r 0.49 525.x264_r 0.00 531.deepsjeng_r 0.00 541.leela_r 0.35 557.xz_r 0.21 Differential Revision: https://reviews.llvm.org/D92780 Added: Modified: llvm/lib/Analysis/InlineCost.cpp Removed: diff --git a/llvm/lib/Analysis/InlineCost.cpp b/llvm/lib/Analysis/InlineCost.cpp index 5ee12818e44c..bf8d9c98aa0e 100644 --- a/llvm/lib/Analysis/InlineCost.cpp +++ b/llvm/lib/Analysis/InlineCost.cpp @@ -71,6 +71,20 @@ static cl::opt cl::init(45), cl::ZeroOrMore, cl::desc("Threshold for inlining cold callsites")); +static cl::opt InlineEnableCostBenefitAnalysis( +"inline-enable-cost-benefit-analysis", cl::Hidden, cl::init(false), +cl::desc("Enable the cost-benefit analysis for the inliner")); + +static cl::opt InlineSavingsMultiplier( +"inline-savings-multiplier", cl::Hidden, cl::init(8), cl::ZeroOrMore, +cl::desc("Multiplier to multiply cycle savings by during inlining")); + +static cl::opt +InlineSizeAllowance("inline-size-allowance", cl::Hidden, cl::init(100), +cl::ZeroOrMore, +cl::desc("The maximum size of a callee that get's " + "inlined without sufficient cycle savings")); + // We introduce this threshold to help performance of instrumentation based // PGO before we actually hook up inliner with analysis passes such as BPI and // BFI. @@ -183,6 +197,9 @@ class CallAnalyzer : public InstVisitor { CallBase &CandidateCall; /// Extension points for handling callsite features. + // Called before a basic block was analyzed. + virtual void onBlockStart(const BasicBlock *BB) {} + /// Called after a basic block was analyzed. virtual void onBlockAnalyzed(const BasicBlock *BB) {} @@ -454,12 +471,24 @@ class InlineCostCallAnalyzer final : public CallAnalyzer { /// Ignore the threshold when finalizing analysis. const bool IgnoreThreshold; + // True if the cost-benefit-analysis-based inliner is enabled. + const bool CostBenefitAnalysisEnabled; + /// Inlining cost measured in abstract units, accounts for all the /// instructions expected to be executed for a given function invocation. /// Instructions that are statically proven to be dead based on call-site /// arguments are not counted here. int Cost = 0; + // The cumulative cost at the beginning of the basic block being analyzed. At + // the end of analyzing each basic block, "Cost - CostAtBBStart" represents + // the size of that basic block. + int CostAtBBStart = 0; + + // The static size of live but cold basic blocks. This is "static" in the + // sense that it's not weighted by profile counts at all. + int ColdSize = 0; + bool SingleBB = true; unsigned SROACostSavings = 0; @@ -597,7 +626,21 @@ class InlineCostCallAnalyzer final : public CallAnalyzer { SROACostSaving
[llvm-branch-commits] [clang] ff4b76d - [clang][cli] Port TargetOpts simple string based options to new option parsing system
Author: Jan Svoboda Date: 2020-12-18T09:40:56+01:00 New Revision: ff4b76d74f38a3816495c9914789e87a95525cf4 URL: https://github.com/llvm/llvm-project/commit/ff4b76d74f38a3816495c9914789e87a95525cf4 DIFF: https://github.com/llvm/llvm-project/commit/ff4b76d74f38a3816495c9914789e87a95525cf4.diff LOG: [clang][cli] Port TargetOpts simple string based options to new option parsing system Depends on D84190 Reviewed By: Bigcheese Original patch by Daniel Grumberg. Differential Revision: https://reviews.llvm.org/D84668 Added: Modified: clang/include/clang/Driver/Options.td clang/lib/Frontend/CompilerInvocation.cpp Removed: diff --git a/clang/include/clang/Driver/Options.td b/clang/include/clang/Driver/Options.td index 7275e84d7c53..b92244fd2f18 100644 --- a/clang/include/clang/Driver/Options.td +++ b/clang/include/clang/Driver/Options.td @@ -2690,7 +2690,8 @@ def mwatchos_simulator_version_min_EQ : Joined<["-"], "mwatchos-simulator-versio def mwatchsimulator_version_min_EQ : Joined<["-"], "mwatchsimulator-version-min=">, Alias; def march_EQ : Joined<["-"], "march=">, Group, Flags<[CoreOption]>; def masm_EQ : Joined<["-"], "masm=">, Group, Flags<[NoXarchOption]>; -def mcmodel_EQ : Joined<["-"], "mcmodel=">, Group, Flags<[CC1Option]>; +def mcmodel_EQ : Joined<["-"], "mcmodel=">, Group, Flags<[CC1Option]>, + MarshallingInfoString<"TargetOpts->CodeModel", [{"default"}]>; def mtls_size_EQ : Joined<["-"], "mtls-size=">, Group, Flags<[NoXarchOption, CC1Option]>, HelpText<"Specify bit size of immediate TLS offsets (AArch64 ELF only): " "12 (for 4KB) | 24 (for 16MB, default) | 32 (for 4GB) | 48 (for 256TB, needs -mcmodel=large)">; @@ -2760,7 +2761,10 @@ def mno_stack_arg_probe : Flag<["-"], "mno-stack-arg-probe">, Group, Fl def mthread_model : Separate<["-"], "mthread-model">, Group, Flags<[CC1Option]>, HelpText<"The thread model to use, e.g. posix, single (posix by default)">, Values<"posix,single">; def meabi : Separate<["-"], "meabi">, Group, Flags<[CC1Option]>, - HelpText<"Set EABI type, e.g. 4, 5 or gnu (default depends on triple)">, Values<"default,4,5,gnu">; + HelpText<"Set EABI type, e.g. 4, 5 or gnu (default depends on triple)">, Values<"default,4,5,gnu">, + MarshallingInfoString<"TargetOpts->EABIVersion", "Default">, + NormalizedValuesScope<"llvm::EABI">, + NormalizedValues<["Default", "EABI4", "EABI5", "GNU"]>, AutoNormalizeEnum; def mno_constant_cfstrings : Flag<["-"], "mno-constant-cfstrings">, Group; def mno_global_merge : Flag<["-"], "mno-global-merge">, Group, Flags<[CC1Option]>, @@ -4052,9 +4056,11 @@ let Flags = [CC1Option, NoDriverOption] in { let Flags = [CC1Option, CC1AsOption, NoDriverOption] in { def target_cpu : Separate<["-"], "target-cpu">, - HelpText<"Target a specific cpu type">; + HelpText<"Target a specific cpu type">, + MarshallingInfoString<"TargetOpts->CPU">; def tune_cpu : Separate<["-"], "tune-cpu">, - HelpText<"Tune for a specific cpu type">; + HelpText<"Tune for a specific cpu type">, + MarshallingInfoString<"TargetOpts->TuneCPU">; def target_feature : Separate<["-"], "target-feature">, HelpText<"Target specific attributes">; def triple : Separate<["-"], "triple">, @@ -4062,17 +4068,20 @@ def triple : Separate<["-"], "triple">, MarshallingInfoString<"TargetOpts->Triple", "llvm::Triple::normalize(llvm::sys::getDefaultTargetTriple())">, AlwaysEmit, Normalizer<"normalizeTriple">; def target_abi : Separate<["-"], "target-abi">, - HelpText<"Target a particular ABI type">; + HelpText<"Target a particular ABI type">, + MarshallingInfoString<"TargetOpts->ABI">; def target_sdk_version_EQ : Joined<["-"], "target-sdk-version=">, HelpText<"The version of target SDK used for compilation">; } def target_linker_version : Separate<["-"], "target-linker-version">, - HelpText<"Target linker version">; + HelpText<"Target linker version">, + MarshallingInfoString<"TargetOpts->LinkerVersion">; def triple_EQ : Joined<["-"], "triple=">, Alias; def mfpmath : Separate<["-"], "mfpmath">, - HelpText<"Which unit to use for fp math">; + HelpText<"Which unit to use for fp math">, + MarshallingInfoString<"TargetOpts->FPMath">; def fpadding_on_unsigned_fixed_point : Flag<["-"], "fpadding-on-unsigned-fixed-point">, HelpText<"Force each unsigned fixed point type to have an extra bit of padding to align their scales with those of signed fixed point types">; diff --git a/clang/lib/Frontend/CompilerInvocation.cpp b/clang/lib/Frontend/CompilerInvocation.cpp index f7bb2308953f..ea0cc74217ff 100644 --- a/clang/lib/Frontend/CompilerInvocation.cpp +++ b/clang/lib/Frontend/CompilerInvocation.cpp @@ -244,10 +244,10 @@ static llvm::Optional normalizeSimpleEnum(OptSpecifier Opt, return None; } -static void denormalizeSimpleEnum(SmallVectorImpl &Args, - const char *Spelling, -
[llvm-branch-commits] [clang] aec2991 - [clang][cli] Port LangOpts simple string based options to new option parsing system
Author: Jan Svoboda Date: 2020-12-18T09:44:02+01:00 New Revision: aec2991d083a9c5b92f94d84a7b3a7bbed405af8 URL: https://github.com/llvm/llvm-project/commit/aec2991d083a9c5b92f94d84a7b3a7bbed405af8 DIFF: https://github.com/llvm/llvm-project/commit/aec2991d083a9c5b92f94d84a7b3a7bbed405af8.diff LOG: [clang][cli] Port LangOpts simple string based options to new option parsing system Depends on D84670 Reviewed By: Bigcheese Original patch by Daniel Grumberg. Differential Revision: https://reviews.llvm.org/D84671 Added: Modified: clang/include/clang/Basic/DiagnosticFrontendKinds.td clang/include/clang/Driver/Options.td clang/lib/Frontend/CompilerInvocation.cpp Removed: diff --git a/clang/include/clang/Basic/DiagnosticFrontendKinds.td b/clang/include/clang/Basic/DiagnosticFrontendKinds.td index def189f65994..b9f8c78e43da 100644 --- a/clang/include/clang/Basic/DiagnosticFrontendKinds.td +++ b/clang/include/clang/Basic/DiagnosticFrontendKinds.td @@ -108,8 +108,6 @@ def err_fe_action_not_available : Error< "action %0 not compiled in">; def err_fe_invalid_alignment : Error< "invalid value '%1' in '%0'; alignment must be a power of 2">; -def err_fe_invalid_wchar_type -: Error<"invalid wchar_t type '%0'; must be one of 'char', 'short', 'int'">; def err_fe_invalid_exception_model : Error<"invalid exception model '%select{none|dwarf|sjlj|arm|seh|wasm|aix}0' for target '%1'">; def warn_fe_concepts_ts_flag : Warning< diff --git a/clang/include/clang/Driver/Options.td b/clang/include/clang/Driver/Options.td index b92244fd2f18..f7e3b298bccd 100644 --- a/clang/include/clang/Driver/Options.td +++ b/clang/include/clang/Driver/Options.td @@ -994,7 +994,8 @@ def interface_stub_version_EQ : JoinedOrSeparate<["-"], "interface-stub-version= def exported__symbols__list : Separate<["-"], "exported_symbols_list">; def e : JoinedOrSeparate<["-"], "e">, Flags<[LinkerInput]>, Group; def fmax_tokens_EQ : Joined<["-"], "fmax-tokens=">, Group, Flags<[CC1Option]>, - HelpText<"Max total number of preprocessed tokens for -Wmax-tokens.">; + HelpText<"Max total number of preprocessed tokens for -Wmax-tokens.">, + MarshallingInfoStringInt<"LangOpts->MaxTokens">; def fPIC : Flag<["-"], "fPIC">, Group; def fno_PIC : Flag<["-"], "fno-PIC">, Group; def fPIE : Flag<["-"], "fPIE">, Group; @@ -1212,7 +1213,10 @@ defm complete_member_pointers : BoolOption<"complete-member-pointers", " would be significant under the Microsoft ABI">, "f">, Group; def fcf_runtime_abi_EQ : Joined<["-"], "fcf-runtime-abi=">, Group, -Flags<[CC1Option]>; +Flags<[CC1Option]>, Values<"unspecified,standalone,objc,swift,swift-5.0,swift-4.2,swift-4.1">, +NormalizedValuesScope<"LangOptions::CoreFoundationABI">, +NormalizedValues<["ObjectiveC", "ObjectiveC", "ObjectiveC", "Swift5_0", "Swift5_0", "Swift4_2", "Swift4_1"]>, +MarshallingInfoString<"LangOpts->CFRuntime", "ObjectiveC">, AutoNormalizeEnum; defm constant_cfstrings : BoolFOption<"constant-cfstrings", "LangOpts->NoConstantCFStrings", DefaultsToFalse, ChangedBy, @@ -1420,7 +1424,8 @@ defm sanitize_memory_use_after_dtor : BoolOption<"sanitize-memory-use-after-dtor Group; def fsanitize_address_field_padding : Joined<["-"], "fsanitize-address-field-padding=">, Group, -HelpText<"Level of field padding for AddressSanitizer">; +HelpText<"Level of field padding for AddressSanitizer">, + MarshallingInfoStringInt<"LangOpts->SanitizeAddressFieldPadding">; defm sanitize_address_use_after_scope : BoolOption<"sanitize-address-use-after-scope", "CodeGenOpts.SanitizeAddressUseAfterScope", DefaultsToFalse, ChangedBy, ResetBy, @@ -1739,7 +1744,10 @@ defm experimental_relative_cxx_abi_vtables : BoolFOption<"experimental-relative- def flat__namespace : Flag<["-"], "flat_namespace">; def flax_vector_conversions_EQ : Joined<["-"], "flax-vector-conversions=">, Group, - HelpText<"Enable implicit vector bit-casts">, Values<"none,integer,all">, Flags<[CC1Option]>; + HelpText<"Enable implicit vector bit-casts">, Values<"none,integer,all">, Flags<[CC1Option]>, + NormalizedValuesScope<"LangOptions::LaxVectorConversionKind">, + NormalizedValues<["None", "Integer", "All"]>, + MarshallingInfoString<"LangOpts->LaxVectorConversions", "All">, AutoNormalizeEnum; def flax_vector_conversions : Flag<["-"], "flax-vector-conversions">, Group, Alias, AliasArgs<["integer"]>; def flimited_precision_EQ : Joined<["-"], "flimited-precision=">, Group; @@ -1791,7 +1799,12 @@ defm delayed_template_parsing : BoolFOption<"delayed-template-parsing", ChangedBy, ResetBy, BothFlags<[CoreOption]>>; -def fms_memptr_rep_EQ : Joined<["-"], "fms-memptr-rep=">, Group, Flags<[CC1Op
[llvm-branch-commits] [clang] d1b3f82 - [clang][cli] Port PreprocessorOpts simple string based options to new option parsing system
Author: Jan Svoboda Date: 2020-12-18T09:52:20+01:00 New Revision: d1b3f82e51378dd9fb5a23806d8fa906151f5e7b URL: https://github.com/llvm/llvm-project/commit/d1b3f82e51378dd9fb5a23806d8fa906151f5e7b DIFF: https://github.com/llvm/llvm-project/commit/d1b3f82e51378dd9fb5a23806d8fa906151f5e7b.diff LOG: [clang][cli] Port PreprocessorOpts simple string based options to new option parsing system Depends on D84671 Reviewed By: Bigcheese Original patch by Daniel Grumberg. Differential Revision: https://reviews.llvm.org/D84672 Added: Modified: clang/include/clang/Driver/Options.td clang/lib/Frontend/CompilerInvocation.cpp Removed: diff --git a/clang/include/clang/Driver/Options.td b/clang/include/clang/Driver/Options.td index f7e3b298bccd..01ee6f747e51 100644 --- a/clang/include/clang/Driver/Options.td +++ b/clang/include/clang/Driver/Options.td @@ -2615,7 +2615,8 @@ def image__base : Separate<["-"], "image_base">; def include_ : JoinedOrSeparate<["-", "--"], "include">, Group, EnumName<"include">, MetaVarName<"">, HelpText<"Include file before parsing">, Flags<[CC1Option]>; def include_pch : Separate<["-"], "include-pch">, Group, Flags<[CC1Option]>, - HelpText<"Include precompiled header file">, MetaVarName<"">; + HelpText<"Include precompiled header file">, MetaVarName<"">, + MarshallingInfoString<"PreprocessorOpts->ImplicitPCHInclude">; def relocatable_pch : Flag<["-", "--"], "relocatable-pch">, Flags<[CC1Option]>, HelpText<"Whether to build a relocatable precompiled header">, MarshallingInfoFlag<"FrontendOpts.RelocatablePCH">; @@ -4857,7 +4858,8 @@ def foverride_record_layout_EQ : Joined<["-"], "foverride-record-layout=">, HelpText<"Override record layouts with those in the given file">; def pch_through_header_EQ : Joined<["-"], "pch-through-header=">, HelpText<"Stop PCH generation after including this file. When using a PCH, " - "skip tokens until after this file is included.">; + "skip tokens until after this file is included.">, + MarshallingInfoString<"PreprocessorOpts->PCHThroughHeader">; def pch_through_hdrstop_create : Flag<["-"], "pch-through-hdrstop-create">, HelpText<"When creating a PCH, stop PCH generation after #pragma hdrstop.">, MarshallingInfoFlag<"PreprocessorOpts->PCHWithHdrStopCreate">; @@ -4904,7 +4906,9 @@ def fconstant_string_class : Separate<["-"], "fconstant-string-class">, HelpText<"Specify the class to use for constant Objective-C string objects.">, MarshallingInfoString<"LangOpts->ObjCConstantStringClass">; def fobjc_arc_cxxlib_EQ : Joined<["-"], "fobjc-arc-cxxlib=">, - HelpText<"Objective-C++ Automatic Reference Counting standard library kind">, Values<"libc++,libstdc++,none">; + HelpText<"Objective-C++ Automatic Reference Counting standard library kind">, Values<"libc++,libstdc++,none">, + NormalizedValues<["ARCXX_libcxx", "ARCXX_libstdcxx", "ARCXX_nolib"]>, + MarshallingInfoString<"PreprocessorOpts->ObjCXXARCStandardLibrary", "ARCXX_nolib">, AutoNormalizeEnum; def fobjc_runtime_has_weak : Flag<["-"], "fobjc-runtime-has-weak">, HelpText<"The target Objective-C runtime supports ARC weak operations">; def fobjc_dispatch_method_EQ : Joined<["-"], "fobjc-dispatch-method=">, diff --git a/clang/lib/Frontend/CompilerInvocation.cpp b/clang/lib/Frontend/CompilerInvocation.cpp index 5eea882e502b..a2ff437208f6 100644 --- a/clang/lib/Frontend/CompilerInvocation.cpp +++ b/clang/lib/Frontend/CompilerInvocation.cpp @@ -3115,11 +3115,8 @@ static bool isStrictlyPreprocessorAction(frontend::ActionKind Action) { static void ParsePreprocessorArgs(PreprocessorOptions &Opts, ArgList &Args, DiagnosticsEngine &Diags, frontend::ActionKind Action) { - Opts.ImplicitPCHInclude = std::string(Args.getLastArgValue(OPT_include_pch)); Opts.PCHWithHdrStop = Args.hasArg(OPT_pch_through_hdrstop_create) || Args.hasArg(OPT_pch_through_hdrstop_use); - Opts.PCHThroughHeader = - std::string(Args.getLastArgValue(OPT_pch_through_header_EQ)); Opts.AllowPCHWithCompilerErrors = Args.hasArg(OPT_fallow_pch_with_errors, OPT_fallow_pcm_with_errors); @@ -3187,19 +3184,6 @@ static void ParsePreprocessorArgs(PreprocessorOptions &Opts, ArgList &Args, Opts.addRemappedFile(Split.first, Split.second); } - if (Arg *A = Args.getLastArg(OPT_fobjc_arc_cxxlib_EQ)) { -StringRef Name = A->getValue(); -unsigned Library = llvm::StringSwitch(Name) - .Case("libc++", ARCXX_libcxx) - .Case("libstdc++", ARCXX_libstdcxx) - .Case("none", ARCXX_nolib) - .Default(~0U); -if (Library == ~0U) - Diags.Report(diag::err_drv_invalid_value) << A->getAsString(Args) << Name; -else - Opts.ObjCXXARCStandardLibrary = (ObjCXXARCStandardLibraryKind)Library; - } - // Always avoid lexing editor placeh
[llvm-branch-commits] [clang] 333d41e - [clang][cli] Port FrontendOpts simple string based options to new option parsing system
Author: Jan Svoboda Date: 2020-12-18T10:00:03+01:00 New Revision: 333d41e9eb8b5f6cd67d318e84ee8dba99b840cc URL: https://github.com/llvm/llvm-project/commit/333d41e9eb8b5f6cd67d318e84ee8dba99b840cc DIFF: https://github.com/llvm/llvm-project/commit/333d41e9eb8b5f6cd67d318e84ee8dba99b840cc.diff LOG: [clang][cli] Port FrontendOpts simple string based options to new option parsing system Depends on D84189 Reviewed By: dexonsmith Original patch by Daniel Grumberg. Differential Revision: https://reviews.llvm.org/D84190 Added: Modified: clang/include/clang/Driver/Options.td clang/lib/Frontend/CompilerInvocation.cpp Removed: diff --git a/clang/include/clang/Driver/Options.td b/clang/include/clang/Driver/Options.td index 01ee6f747e51..d143781d1d09 100644 --- a/clang/include/clang/Driver/Options.td +++ b/clang/include/clang/Driver/Options.td @@ -542,7 +542,8 @@ def ccc_arcmt_modify : Flag<["-"], "ccc-arcmt-modify">, InternalDriverOpt, def ccc_arcmt_migrate : Separate<["-"], "ccc-arcmt-migrate">, InternalDriverOpt, HelpText<"Apply modifications and produces temporary files that conform to ARC">; def arcmt_migrate_report_output : Separate<["-"], "arcmt-migrate-report-output">, - HelpText<"Output path for the plist report">, Flags<[CC1Option]>; + HelpText<"Output path for the plist report">, Flags<[CC1Option]>, + MarshallingInfoString<"FrontendOpts.ARCMTMigrateReportOut">; def arcmt_migrate_emit_arc_errors : Flag<["-"], "arcmt-migrate-emit-errors">, HelpText<"Emit ARC errors even if the migrator can fix them">, Flags<[CC1Option]>, MarshallingInfoFlag<"FrontendOpts.ARCMTMigrateEmitARCErrors">; @@ -605,7 +606,8 @@ def objcmt_migrate_designated_init : Flag<["-"], "objcmt-migrate-designated-init MarshallingInfoBitfieldFlag<"FrontendOpts.ObjCMTAction", "FrontendOptions::ObjCMT_DesignatedInitializer">; def objcmt_whitelist_dir_path: Joined<["-"], "objcmt-whitelist-dir-path=">, Flags<[CC1Option]>, - HelpText<"Only modify files with a filename contained in the provided directory path">; + HelpText<"Only modify files with a filename contained in the provided directory path">, + MarshallingInfoString<"FrontendOpts.ObjCMTWhiteListPath">; // The misspelt "white-list" [sic] alias is due for removal. def : Joined<["-"], "objcmt-white-list-dir-path=">, Flags<[CC1Option]>, Alias; @@ -2339,7 +2341,8 @@ can be analyzed with chrome://tracing or `Speedscope App MarshallingInfoFlag<"FrontendOpts.TimeTrace">; def ftime_trace_granularity_EQ : Joined<["-"], "ftime-trace-granularity=">, Group, HelpText<"Minimum time granularity (in microseconds) traced by time profiler">, - Flags<[CC1Option, CoreOption]>; + Flags<[CC1Option, CoreOption]>, + MarshallingInfoStringInt<"FrontendOpts.TimeTraceGranularity", "500u">; def fproc_stat_report : Joined<["-"], "fproc-stat-report">, Group, HelpText<"Print subprocess statistics">; def fproc_stat_report_EQ : Joined<["-"], "fproc-stat-report=">, Group, @@ -3309,7 +3312,8 @@ def nostdlibxx : Flag<["-"], "nostdlib++">; def object : Flag<["-"], "object">; def o : JoinedOrSeparate<["-"], "o">, Flags<[NoXarchOption, RenderAsInput, CC1Option, CC1AsOption, FC1Option, FlangOption]>, - HelpText<"Write output to ">, MetaVarName<"">; + HelpText<"Write output to ">, MetaVarName<"">, + MarshallingInfoString<"FrontendOpts.OutputFile">; def pagezero__size : JoinedOrSeparate<["-"], "pagezero_size">; def pass_exit_codes : Flag<["-", "--"], "pass-exit-codes">, Flags<[Unsupported]>; def pedantic_errors : Flag<["-", "--"], "pedantic-errors">, Group, Flags<[CC1Option]>; @@ -4626,7 +4630,8 @@ def aux_target_cpu : Separate<["-"], "aux-target-cpu">, def aux_target_feature : Separate<["-"], "aux-target-feature">, HelpText<"Target specific auxiliary attributes">; def aux_triple : Separate<["-"], "aux-triple">, - HelpText<"Auxiliary target triple.">; + HelpText<"Auxiliary target triple.">, + MarshallingInfoString<"FrontendOpts.AuxTriple">; def code_completion_at : Separate<["-"], "code-completion-at">, MetaVarName<"::">, HelpText<"Dump code-completion information at a location">; @@ -4672,7 +4677,8 @@ def ast_dump_filter : Separate<["-"], "ast-dump-filter">, MetaVarName<"">, HelpText<"Use with -ast-dump or -ast-print to dump/print only AST declaration" " nodes having a certain substring in a qualified name. Use" - " -ast-list to list all filterable declaration node names.">; + " -ast-list to list all filterable declaration node names.">, + MarshallingInfoString<"FrontendOpts.ASTDumpFilter">; def fno_modules_global_index : Flag<["-"], "fno-modules-global-index">, HelpText<"Do not automatically generate or update the global module index">, MarshallingInfoFlag<"FrontendOpts.UseGlobalModuleIndex", "true">, IsNegative; @@ -4815,7 +4821,8 @@ defm emit_llvm_uselists : BoolOption<"emit-llvm-useli
[llvm-branch-commits] [clang] 9e08e51 - [c++20] P1907R1: Support for generalized non-type template arguments of scalar type.
Author: Richard Smith Date: 2020-12-18T01:08:41-08:00 New Revision: 9e08e51a20d0d2b1c5724bb17e969d036fced4cd URL: https://github.com/llvm/llvm-project/commit/9e08e51a20d0d2b1c5724bb17e969d036fced4cd DIFF: https://github.com/llvm/llvm-project/commit/9e08e51a20d0d2b1c5724bb17e969d036fced4cd.diff LOG: [c++20] P1907R1: Support for generalized non-type template arguments of scalar type. Added: clang/test/CodeGenCXX/template-arguments.cpp Modified: clang/include/clang/AST/PropertiesBase.td clang/include/clang/AST/RecursiveASTVisitor.h clang/include/clang/AST/TemplateArgumentVisitor.h clang/include/clang/AST/TemplateBase.h clang/include/clang/Basic/DiagnosticSemaKinds.td clang/include/clang/Sema/Sema.h clang/include/clang/Serialization/ASTRecordWriter.h clang/lib/AST/ASTContext.cpp clang/lib/AST/ASTImporter.cpp clang/lib/AST/ASTStructuralEquivalence.cpp clang/lib/AST/Decl.cpp clang/lib/AST/ItaniumMangle.cpp clang/lib/AST/MicrosoftMangle.cpp clang/lib/AST/ODRHash.cpp clang/lib/AST/StmtProfile.cpp clang/lib/AST/TemplateBase.cpp clang/lib/AST/TypeLoc.cpp clang/lib/CodeGen/CGDebugInfo.cpp clang/lib/CodeGen/CGExprConstant.cpp clang/lib/Index/USRGeneration.cpp clang/lib/Sema/SemaLookup.cpp clang/lib/Sema/SemaOverload.cpp clang/lib/Sema/SemaTemplate.cpp clang/lib/Sema/SemaTemplateDeduction.cpp clang/lib/Sema/SemaTemplateInstantiate.cpp clang/lib/Sema/SemaTemplateVariadic.cpp clang/lib/Sema/TreeTransform.h clang/lib/Serialization/ASTReader.cpp clang/lib/Serialization/ASTWriter.cpp clang/test/CodeGenCXX/mangle-ms-templates.cpp clang/test/CodeGenCXX/mangle-template.cpp clang/test/SemaTemplate/temp_arg_nontype_cxx17.cpp clang/test/SemaTemplate/temp_arg_nontype_cxx20.cpp clang/tools/libclang/CIndex.cpp clang/tools/libclang/CXCursor.cpp Removed: diff --git a/clang/include/clang/AST/PropertiesBase.td b/clang/include/clang/AST/PropertiesBase.td index ba0f237a3bc3..dbe75ab9de19 100644 --- a/clang/include/clang/AST/PropertiesBase.td +++ b/clang/include/clang/AST/PropertiesBase.td @@ -72,6 +72,7 @@ class CountPropertyType : PropertyType { def APInt : PropertyType<"llvm::APInt"> { let PassByReference = 1; } def APSInt : PropertyType<"llvm::APSInt"> { let PassByReference = 1; } +def APValue : PropertyType { let PassByReference = 1; } def ArraySizeModifier : EnumPropertyType<"ArrayType::ArraySizeModifier">; def AttrKind : EnumPropertyType<"attr::Kind">; def AutoTypeKeyword : EnumPropertyType; @@ -450,6 +451,17 @@ let Class = PropertyTypeCase in { return TemplateArgument(ctx, value, type); }]>; } +let Class = PropertyTypeCase in { + def : Property<"value", APValue> { +let Read = [{ node.getAsUncommonValue() }]; + } + def : Property<"type", QualType> { +let Read = [{ node.getUncommonValueType() }]; + } + def : Creator<[{ +return TemplateArgument(ctx, type, value); + }]>; +} let Class = PropertyTypeCase in { def : Property<"name", TemplateName> { let Read = [{ node.getAsTemplateOrTemplatePattern() }]; diff --git a/clang/include/clang/AST/RecursiveASTVisitor.h b/clang/include/clang/AST/RecursiveASTVisitor.h index 96db0e439952..61e524793ec7 100644 --- a/clang/include/clang/AST/RecursiveASTVisitor.h +++ b/clang/include/clang/AST/RecursiveASTVisitor.h @@ -767,6 +767,7 @@ bool RecursiveASTVisitor::TraverseTemplateArgument( case TemplateArgument::Declaration: case TemplateArgument::Integral: case TemplateArgument::NullPtr: + case TemplateArgument::UncommonValue: return true; case TemplateArgument::Type: @@ -800,6 +801,7 @@ bool RecursiveASTVisitor::TraverseTemplateArgumentLoc( case TemplateArgument::Declaration: case TemplateArgument::Integral: case TemplateArgument::NullPtr: + case TemplateArgument::UncommonValue: return true; case TemplateArgument::Type: { diff --git a/clang/include/clang/AST/TemplateArgumentVisitor.h b/clang/include/clang/AST/TemplateArgumentVisitor.h index 190aa97adf45..8c0da70b25eb 100644 --- a/clang/include/clang/AST/TemplateArgumentVisitor.h +++ b/clang/include/clang/AST/TemplateArgumentVisitor.h @@ -37,6 +37,7 @@ class Base { DISPATCH(Declaration); DISPATCH(NullPtr); DISPATCH(Integral); + DISPATCH(UncommonValue); DISPATCH(Template); DISPATCH(TemplateExpansion); DISPATCH(Expression); @@ -59,6 +60,7 @@ class Base { VISIT_METHOD(Declaration); VISIT_METHOD(NullPtr); VISIT_METHOD(Integral); + VISIT_METHOD(UncommonValue); VISIT_METHOD(Template); VISIT_METHOD(TemplateExpansion); VISIT_METHOD(Expression); diff --git a/clang/include/clang/AST/TemplateBase.h b/clang/include/clang/AST/TemplateBase.h index abf873a7ee40..9968143e8761 100644 --- a/clang/include/clang/AST/TemplateBase.h +++ b/clang/include/clang/AST/TemplateBase.h @@
[llvm-branch-commits] [clang] 569676c - Make Expr::HasSideEffect more precise for instantiation-dependent
Author: Richard Smith Date: 2020-12-18T01:08:42-08:00 New Revision: 569676c05725d79909bd8a9224bc709bd621553c URL: https://github.com/llvm/llvm-project/commit/569676c05725d79909bd8a9224bc709bd621553c DIFF: https://github.com/llvm/llvm-project/commit/569676c05725d79909bd8a9224bc709bd621553c.diff LOG: Make Expr::HasSideEffect more precise for instantiation-dependent expressions. Fixes a regression in the clang-tidy test suite from making DeclRefExprs referring to dependent declarations be instantiation-dependent. Added: Modified: clang/lib/AST/Expr.cpp clang/lib/Sema/SemaExpr.cpp clang/lib/Sema/SemaExprCXX.cpp clang/lib/Sema/SemaType.cpp Removed: diff --git a/clang/lib/AST/Expr.cpp b/clang/lib/AST/Expr.cpp index 0426b20a33a9..dafa7136ecb4 100644 --- a/clang/lib/AST/Expr.cpp +++ b/clang/lib/AST/Expr.cpp @@ -3242,9 +3242,6 @@ bool Expr::HasSideEffects(const ASTContext &Ctx, if (!IncludePossibleEffects && getExprLoc().isMacroID()) return false; - if (isInstantiationDependent()) -return IncludePossibleEffects; - switch (getStmtClass()) { case NoStmtClass: #define ABSTRACT_STMT(Type) @@ -3264,7 +3261,8 @@ bool Expr::HasSideEffects(const ASTContext &Ctx, case TypoExprClass: case RecoveryExprClass: case CXXFoldExprClass: -llvm_unreachable("shouldn't see dependent / unresolved nodes here"); +// Make a conservative assumption for dependent nodes. +return IncludePossibleEffects; case DeclRefExprClass: case ObjCIvarRefExprClass: diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp index ca1939222cf0..3992a373f721 100644 --- a/clang/lib/Sema/SemaExpr.cpp +++ b/clang/lib/Sema/SemaExpr.cpp @@ -4135,7 +4135,11 @@ bool Sema::CheckUnaryExprOrTypeTraitOperand(Expr *E, // The operand for sizeof and alignof is in an unevaluated expression context, // so side effects could result in unintended consequences. + // Exclude instantiation-dependent expressions, because 'sizeof' is sometimes + // used to build SFINAE gadgets. + // FIXME: Should we consider instantiation-dependent operands to 'alignof'? if (IsUnevaluatedOperand && !inTemplateInstantiation() && + !E->isInstantiationDependent() && E->HasSideEffects(Context, false)) Diag(E->getExprLoc(), diag::warn_side_effects_unevaluated_context); diff --git a/clang/lib/Sema/SemaExprCXX.cpp b/clang/lib/Sema/SemaExprCXX.cpp index 241b8f72c56e..05b28c11e5a5 100644 --- a/clang/lib/Sema/SemaExprCXX.cpp +++ b/clang/lib/Sema/SemaExprCXX.cpp @@ -7691,7 +7691,8 @@ ExprResult Sema::BuildCXXNoexceptExpr(SourceLocation KeyLoc, Expr *Operand, Operand = R.get(); - if (!inTemplateInstantiation() && Operand->HasSideEffects(Context, false)) { + if (!inTemplateInstantiation() && !Operand->isInstantiationDependent() && + Operand->HasSideEffects(Context, false)) { // The expression operand for noexcept is in an unevaluated expression // context, so side effects could result in unintended consequences. Diag(Operand->getExprLoc(), diag::warn_side_effects_unevaluated_context); diff --git a/clang/lib/Sema/SemaType.cpp b/clang/lib/Sema/SemaType.cpp index 6485bebc0e8e..00ec0c4a0cee 100644 --- a/clang/lib/Sema/SemaType.cpp +++ b/clang/lib/Sema/SemaType.cpp @@ -8993,9 +8993,11 @@ QualType Sema::BuildDecltypeType(Expr *E, SourceLocation Loc, assert(!E->hasPlaceholderType() && "unexpected placeholder"); if (AsUnevaluated && CodeSynthesisContexts.empty() && - E->HasSideEffects(Context, false)) { + !E->isInstantiationDependent() && E->HasSideEffects(Context, false)) { // The expression operand for decltype is in an unevaluated expression // context, so side effects could result in unintended consequences. +// Exclude instantiation-dependent expressions, because 'decltype' is often +// used to build SFINAE gadgets. Diag(E->getExprLoc(), diag::warn_side_effects_unevaluated_context); } ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [libcxx] e83e0ca - [libcxx] Make filesystem::path::value_type wchar_t on windows
Author: Martin Storsjö Date: 2020-12-18T11:24:52+02:00 New Revision: e83e0cac041bc071301f8399bb5c32b2529fc83f URL: https://github.com/llvm/llvm-project/commit/e83e0cac041bc071301f8399bb5c32b2529fc83f DIFF: https://github.com/llvm/llvm-project/commit/e83e0cac041bc071301f8399bb5c32b2529fc83f.diff LOG: [libcxx] Make filesystem::path::value_type wchar_t on windows Also set the preferred separator to backslash. libc++ doesn't compile successfully for windows prior to this change, and this change on its own isn't enough to make it compile successfully either, but is the first stepping stone towards making it work correctly. Most of operations.cpp will need to be touched, both for calling functions that take wchar paths, but also for using other windows specific functions instead of the posix functions used so far; that is handled in later commits. Changing parts of operations.cpp to generalize the string type handling in code that doesn't touch system functions. Differential Revision: https://reviews.llvm.org/D91135 Added: Modified: libcxx/include/filesystem libcxx/src/filesystem/filesystem_common.h libcxx/src/filesystem/operations.cpp Removed: diff --git a/libcxx/include/filesystem b/libcxx/include/filesystem index 764ec6573a50..7aeabeb2d1ec 100644 --- a/libcxx/include/filesystem +++ b/libcxx/include/filesystem @@ -568,9 +568,19 @@ struct __can_convert_char { template typename enable_if<__can_convert_char<_ECharT>::value, bool>::type __is_separator(_ECharT __e) { +#if defined(_LIBCPP_WIN32API) + return __e == _ECharT('/') || __e == _ECharT('\\'); +#else return __e == _ECharT('/'); +#endif } +#ifndef _LIBCPP_NO_HAS_CHAR8_T +typedef u8string __u8_string; +#else +typedef string __u8_string; +#endif + struct _NullSentinel {}; template @@ -672,6 +682,14 @@ struct __is_pathable<_Tp, false, true, false> : __is_pathable_char_array<_Tp> { template struct __is_pathable<_Tp, false, false, true> : __is_pathable_iter<_Tp> {}; +#if defined(_LIBCPP_WIN32API) +typedef wstring __path_string; +typedef wchar_t __path_value; +#else +typedef string __path_string; +typedef char __path_value; +#endif + template struct _PathCVT; @@ -682,24 +700,40 @@ struct _PathCVT { "Char type not convertible"); typedef __narrow_to_utf8 _Narrower; +#if defined(_LIBCPP_WIN32API) + typedef __widen_from_utf8 _Widener; +#endif - static void __append_range(string& __dest, _ECharT const* __b, + static void __append_range(__path_string& __dest, _ECharT const* __b, _ECharT const* __e) { +#if defined(_LIBCPP_WIN32API) +string __utf8; +_Narrower()(back_inserter(__utf8), __b, __e); +_Widener()(back_inserter(__dest), __utf8.data(), __utf8.data() + __utf8.size()); +#else _Narrower()(back_inserter(__dest), __b, __e); +#endif } template - static void __append_range(string& __dest, _Iter __b, _Iter __e) { + static void __append_range(__path_string& __dest, _Iter __b, _Iter __e) { static_assert(!is_same<_Iter, _ECharT*>::value, "Call const overload"); if (__b == __e) return; basic_string<_ECharT> __tmp(__b, __e); +#if defined(_LIBCPP_WIN32API) +string __utf8; +_Narrower()(back_inserter(__utf8), __tmp.data(), +__tmp.data() + __tmp.length()); +_Widener()(back_inserter(__dest), __utf8.data(), __utf8.data() + __utf8.size()); +#else _Narrower()(back_inserter(__dest), __tmp.data(), __tmp.data() + __tmp.length()); +#endif } template - static void __append_range(string& __dest, _Iter __b, _NullSentinel) { + static void __append_range(__path_string& __dest, _Iter __b, _NullSentinel) { static_assert(!is_same<_Iter, _ECharT*>::value, "Call const overload"); const _ECharT __sentinel = _ECharT{}; if (*__b == __sentinel) @@ -707,12 +741,19 @@ struct _PathCVT { basic_string<_ECharT> __tmp; for (; *__b != __sentinel; ++__b) __tmp.push_back(*__b); +#if defined(_LIBCPP_WIN32API) +string __utf8; +_Narrower()(back_inserter(__utf8), __tmp.data(), +__tmp.data() + __tmp.length()); +_Widener()(back_inserter(__dest), __utf8.data(), __utf8.data() + __utf8.size()); +#else _Narrower()(back_inserter(__dest), __tmp.data(), __tmp.data() + __tmp.length()); +#endif } template - static void __append_source(string& __dest, _Source const& __s) { + static void __append_source(__path_string& __dest, _Source const& __s) { using _Traits = __is_pathable<_Source>; __append_range(__dest, _Traits::__range_begin(__s), _Traits::__range_end(__s)); @@ -721,36 +762,79 @@ struct _PathCVT { #endif // !_LIBCPP_HAS_NO_LOCALIZATION template <> -struct _PathCVT { +struct _PathCVT<__path_value> { template static typename enable_if<__is_exactly_cpp17_input_iterator<_Iter>::
[llvm-branch-commits] [libcxx] de698ae - [libcxx] Convert paths to/from the right narrow code page for narrow strings on windows
Author: Martin Storsjö Date: 2020-12-18T11:24:52+02:00 New Revision: de698ae73444b5160dd6b8d768b30d6764be004e URL: https://github.com/llvm/llvm-project/commit/de698ae73444b5160dd6b8d768b30d6764be004e DIFF: https://github.com/llvm/llvm-project/commit/de698ae73444b5160dd6b8d768b30d6764be004e.diff LOG: [libcxx] Convert paths to/from the right narrow code page for narrow strings on windows On windows, the narrow, char based paths normally don't use utf8, but can use many different native code pages, and this is what system functions that operate on files, taking such paths/file names, interpret them as. Differential Revision: https://reviews.llvm.org/D91137 Added: Modified: libcxx/include/filesystem libcxx/src/filesystem/filesystem_common.h libcxx/src/filesystem/operations.cpp Removed: diff --git a/libcxx/include/filesystem b/libcxx/include/filesystem index adc863f052db..e39790c50955 100644 --- a/libcxx/include/filesystem +++ b/libcxx/include/filesystem @@ -690,6 +690,13 @@ typedef string __path_string; typedef char __path_value; #endif +#if defined(_LIBCPP_WIN32API) +_LIBCPP_FUNC_VIS +size_t __wide_to_char(const wstring&, char*, size_t); +_LIBCPP_FUNC_VIS +size_t __char_to_wide(const string&, wchar_t*, size_t); +#endif + template struct _PathCVT; @@ -793,6 +800,48 @@ struct _PathCVT<__path_value> { }; #if defined(_LIBCPP_WIN32API) +template <> +struct _PathCVT { + + static void + __append_string(__path_string& __dest, const basic_string &__str) { + size_t __size = __char_to_wide(__str, nullptr, 0); + size_t __pos = __dest.size(); + __dest.resize(__pos + __size); + __char_to_wide(__str, const_cast<__path_value*>(__dest.data()) + __pos, __size); + } + + template + static typename enable_if<__is_exactly_cpp17_input_iterator<_Iter>::value>::type + __append_range(__path_string& __dest, _Iter __b, _Iter __e) { +basic_string __tmp(__b, __e); +__append_string(__dest, __tmp); + } + + template + static typename enable_if<__is_cpp17_forward_iterator<_Iter>::value>::type + __append_range(__path_string& __dest, _Iter __b, _Iter __e) { +basic_string __tmp(__b, __e); +__append_string(__dest, __tmp); + } + + template + static void __append_range(__path_string& __dest, _Iter __b, _NullSentinel) { +const char __sentinel = char{}; +basic_string __tmp; +for (; *__b != __sentinel; ++__b) + __tmp.push_back(*__b); +__append_string(__dest, __tmp); + } + + template + static void __append_source(__path_string& __dest, _Source const& __s) { +using _Traits = __is_pathable<_Source>; +__append_range(__dest, _Traits::__range_begin(__s), + _Traits::__range_end(__s)); + } +}; + template struct _PathExport { typedef __narrow_to_utf8 _Narrower; @@ -806,6 +855,17 @@ struct _PathExport { } }; +template <> +struct _PathExport { + template + static void __append(_Str& __dest, const __path_string& __src) { +size_t __size = __wide_to_char(__src, nullptr, 0); +size_t __pos = __dest.size(); +__dest.resize(__size); +__wide_to_char(__src, const_cast(__dest.data()) + __pos, __size); + } +}; + template <> struct _PathExport { template @@ -1110,7 +1170,11 @@ public: return string(); } _LIBCPP_INLINE_VISIBILITY __u8_string u8string() const { -return string<__u8_string::value_type>(); +using _CVT = __narrow_to_utf8; +__u8_string __s; +__s.reserve(__pn_.size()); +_CVT()(back_inserter(__s), __pn_.data(), __pn_.data() + __pn_.size()); +return __s; } _LIBCPP_INLINE_VISIBILITY _VSTD::u16string u16string() const { @@ -1373,9 +1437,42 @@ _LIBCPP_INLINE_VISIBILITY _LIBCPP_DEPRECATED_WITH_CHAR8_T is_same::__char_type, char>::value, "u8path(Iter, Iter) requires Iter have a value_type of type 'char'" " or 'char8_t'"); +#if defined(_LIBCPP_WIN32API) + string __tmp(__f, __l); + using _CVT = __widen_from_utf8; + _VSTD::wstring __w; + __w.reserve(__tmp.size()); + _CVT()(back_inserter(__w), __tmp.data(), __tmp.data() + __tmp.size()); + return path(__w); +#else return path(__f, __l); +#endif /* !_LIBCPP_WIN32API */ } +#if defined(_LIBCPP_WIN32API) +template +_LIBCPP_INLINE_VISIBILITY _LIBCPP_DEPRECATED_WITH_CHAR8_T +typename enable_if<__is_pathable<_InputIt>::value, path>::type +u8path(_InputIt __f, _NullSentinel) { + static_assert( +#ifndef _LIBCPP_NO_HAS_CHAR8_T + is_same::__char_type, char8_t>::value || +#endif + is_same::__char_type, char>::value, + "u8path(Iter, Iter) requires Iter have a value_type of type 'char'" + " or 'char8_t'"); + string __tmp; + const char __sentinel = char{}; + for (; *__f != __sentinel; ++__f) +__tmp.push_back(*__f); + using _CVT = __widen_from_utf8; + _VSTD::wstring __w; + __w.reserve(__tmp.size()); + _CVT()(back_inserter(__w), __tmp.data(), __tmp.data() +
[llvm-branch-commits] [libcxx] 48c6500 - [libcxx] Reorder the two u8path functions, to make the following diff more readable. NFC.
Author: Martin Storsjö Date: 2020-12-18T11:24:52+02:00 New Revision: 48c6500b5bfa60dfe6ca5f407fcdbf5ddff0c289 URL: https://github.com/llvm/llvm-project/commit/48c6500b5bfa60dfe6ca5f407fcdbf5ddff0c289 DIFF: https://github.com/llvm/llvm-project/commit/48c6500b5bfa60dfe6ca5f407fcdbf5ddff0c289.diff LOG: [libcxx] Reorder the two u8path functions, to make the following diff more readable. NFC. Differential Revision: https://reviews.llvm.org/D91136 Added: Modified: libcxx/include/filesystem Removed: diff --git a/libcxx/include/filesystem b/libcxx/include/filesystem index 7aeabeb2d1ec..adc863f052db 100644 --- a/libcxx/include/filesystem +++ b/libcxx/include/filesystem @@ -1362,20 +1362,6 @@ inline _LIBCPP_INLINE_VISIBILITY void swap(path& __lhs, path& __rhs) noexcept { _LIBCPP_FUNC_VIS size_t hash_value(const path& __p) noexcept; -template -_LIBCPP_INLINE_VISIBILITY _LIBCPP_DEPRECATED_WITH_CHAR8_T -typename enable_if<__is_pathable<_Source>::value, path>::type -u8path(const _Source& __s) { - static_assert( -#ifndef _LIBCPP_NO_HAS_CHAR8_T - is_same::__char_type, char8_t>::value || -#endif - is_same::__char_type, char>::value, - "u8path(Source const&) requires Source have a character type of type " - "'char' or 'char8_t'"); - return path(__s); -} - template _LIBCPP_INLINE_VISIBILITY _LIBCPP_DEPRECATED_WITH_CHAR8_T typename enable_if<__is_pathable<_InputIt>::value, path>::type @@ -1390,6 +1376,20 @@ _LIBCPP_INLINE_VISIBILITY _LIBCPP_DEPRECATED_WITH_CHAR8_T return path(__f, __l); } +template +_LIBCPP_INLINE_VISIBILITY _LIBCPP_DEPRECATED_WITH_CHAR8_T +typename enable_if<__is_pathable<_Source>::value, path>::type +u8path(const _Source& __s) { + static_assert( +#ifndef _LIBCPP_NO_HAS_CHAR8_T + is_same::__char_type, char8_t>::value || +#endif + is_same::__char_type, char>::value, + "u8path(Source const&) requires Source have a character type of type " + "'char' or 'char8_t'"); + return path(__s); +} + class _LIBCPP_TYPE_VIS path::iterator { public: enum _ParserState : unsigned char { ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [libcxx] 1561807 - [libcxx] Fix the preexisting directory_iterator code for windows
Author: Martin Storsjö Date: 2020-12-18T11:24:53+02:00 New Revision: 156180727d6c347eda3ba749730707acb8a48093 URL: https://github.com/llvm/llvm-project/commit/156180727d6c347eda3ba749730707acb8a48093 DIFF: https://github.com/llvm/llvm-project/commit/156180727d6c347eda3ba749730707acb8a48093.diff LOG: [libcxx] Fix the preexisting directory_iterator code for windows The directory_iterator.cpp file did contain an incomplete, non-working implementation for windows. Change it to use the wchar version of the APIs. Don't set the windows specific errors from GetLastError() as code in the generic category; remap the errors to the std::errc values. Error out cleanly on empty paths. Invoke FindFirstFile on /* to actually list the entries of the directory. If the first entry retured by FindFirstFile is to be skipped (e.g. being "." or ".."), call advance() (which calls FindNextFile and loops) which doesn't return until a valid entry is found (or the end is reached). Differential Revision: https://reviews.llvm.org/D91140 Added: Modified: libcxx/src/filesystem/directory_iterator.cpp libcxx/src/filesystem/filesystem_common.h libcxx/src/filesystem/operations.cpp Removed: diff --git a/libcxx/src/filesystem/directory_iterator.cpp b/libcxx/src/filesystem/directory_iterator.cpp index e8941b3494b3..2721dea5c98f 100644 --- a/libcxx/src/filesystem/directory_iterator.cpp +++ b/libcxx/src/filesystem/directory_iterator.cpp @@ -10,6 +10,7 @@ #include "__config" #if defined(_LIBCPP_WIN32API) #define WIN32_LEAN_AND_MEAN +#define NOMINMAX #include #else #include @@ -72,16 +73,20 @@ static pair posix_readdir(DIR* dir_stream, } } #else +// defined(_LIBCPP_WIN32API) -static file_type get_file_type(const WIN32_FIND_DATA& data) { - //auto attrs = data.dwFileAttributes; - // FIXME(EricWF) - return file_type::unknown; +static file_type get_file_type(const WIN32_FIND_DATAW& data) { + if (data.dwFileAttributes & FILE_ATTRIBUTE_REPARSE_POINT && + data.dwReserved0 == IO_REPARSE_TAG_SYMLINK) +return file_type::symlink; + if (data.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) +return file_type::directory; + return file_type::regular; } -static uintmax_t get_file_size(const WIN32_FIND_DATA& data) { - return (data.nFileSizeHigh * (MAXDWORD + 1)) + data.nFileSizeLow; +static uintmax_t get_file_size(const WIN32_FIND_DATAW& data) { + return (static_cast(data.nFileSizeHigh) << 32) + data.nFileSizeLow; } -static file_time_type get_write_time(const WIN32_FIND_DATA& data) { +static file_time_type get_write_time(const WIN32_FIND_DATAW& data) { ULARGE_INTEGER tmp; const FILETIME& time = data.ftLastWriteTime; tmp.u.LowPart = time.dwLowDateTime; @@ -110,15 +115,21 @@ class __dir_stream { __dir_stream(const path& root, directory_options opts, error_code& ec) : __stream_(INVALID_HANDLE_VALUE), __root_(root) { -__stream_ = ::FindFirstFile(root.c_str(), &__data_); +if (root.native().empty()) { + ec = make_error_code(errc::no_such_file_or_directory); + return; +} +__stream_ = ::FindFirstFileW((root / "*").c_str(), &__data_); if (__stream_ == INVALID_HANDLE_VALUE) { - ec = error_code(::GetLastError(), generic_category()); + ec = detail::make_windows_error(GetLastError()); const bool ignore_permission_denied = bool(opts & directory_options::skip_permission_denied); if (ignore_permission_denied && ec.value() == ERROR_ACCESS_DENIED) ec.clear(); return; } +if (!assign()) + advance(ec); } ~__dir_stream() noexcept { @@ -130,35 +141,39 @@ class __dir_stream { bool good() const noexcept { return __stream_ != INVALID_HANDLE_VALUE; } bool advance(error_code& ec) { -while (::FindNextFile(__stream_, &__data_)) { - if (!strcmp(__data_.cFileName, ".") || strcmp(__data_.cFileName, "..")) -continue; - // FIXME: Cache more of this - //directory_entry::__cached_data cdata; - //cdata.__type_ = get_file_type(__data_); - //cdata.__size_ = get_file_size(__data_); - //cdata.__write_time_ = get_write_time(__data_); - __entry_.__assign_iter_entry( - __root_ / __data_.cFileName, - directory_entry::__create_iter_result(detail::get_file_type(__data))); - return true; +while (::FindNextFileW(__stream_, &__data_)) { + if (assign()) +return true; } -ec = error_code(::GetLastError(), generic_category()); close(); return false; } + bool assign() { +if (!wcscmp(__data_.cFileName, L".") || !wcscmp(__data_.cFileName, L"..")) + return false; +// FIXME: Cache more of this +//directory_entry::__cached_data cdata; +//cdata.__type_ = get_file_type(__data_); +//cdata.__size_ = get_file_size(__data_); +//cdata.__write_time_ = get_write_time(__data_); +__entry_.__assign_iter_en
[llvm-branch-commits] [clang] 95d3cc6 - [clang][cli] Port CodeGenOpts simple string flags to new option parsing system
Author: Jan Svoboda Date: 2020-12-18T10:28:48+01:00 New Revision: 95d3cc67caac04668ef808f65c30ced60ed14f5d URL: https://github.com/llvm/llvm-project/commit/95d3cc67caac04668ef808f65c30ced60ed14f5d DIFF: https://github.com/llvm/llvm-project/commit/95d3cc67caac04668ef808f65c30ced60ed14f5d.diff LOG: [clang][cli] Port CodeGenOpts simple string flags to new option parsing system Depends on D84668 Reviewed By: Bigcheese Original patch by Daniel Grumberg. Differential Revision: https://reviews.llvm.org/D84669 Added: Modified: clang/include/clang/Basic/CodeGenOptions.h clang/include/clang/Basic/DiagnosticDriverKinds.td clang/include/clang/Driver/Options.td clang/lib/Frontend/CompilerInvocation.cpp clang/test/Profile/c-generate.c Removed: diff --git a/clang/include/clang/Basic/CodeGenOptions.h b/clang/include/clang/Basic/CodeGenOptions.h index 5c540812ed31..ef4fa31256cd 100644 --- a/clang/include/clang/Basic/CodeGenOptions.h +++ b/clang/include/clang/Basic/CodeGenOptions.h @@ -30,6 +30,8 @@ namespace clang { /// Bitfields of CodeGenOptions, split out from CodeGenOptions to ensure /// that this large collection of bitfields is a trivial class type. class CodeGenOptionsBase { + friend class CompilerInvocation; + public: #define CODEGENOPT(Name, Bits, Default) unsigned Name : Bits; #define ENUM_CODEGENOPT(Name, Type, Bits, Default) diff --git a/clang/include/clang/Basic/DiagnosticDriverKinds.td b/clang/include/clang/Basic/DiagnosticDriverKinds.td index 0e85be8f058b..c67cce099a28 100644 --- a/clang/include/clang/Basic/DiagnosticDriverKinds.td +++ b/clang/include/clang/Basic/DiagnosticDriverKinds.td @@ -86,8 +86,6 @@ def err_drv_invalid_thread_model_for_target : Error< "invalid thread model '%0' in '%1' for this target">; def err_drv_invalid_linker_name : Error< "invalid linker name in argument '%0'">; -def err_drv_invalid_pgo_instrumentor : Error< - "invalid PGO instrumentor in argument '%0'">; def err_drv_invalid_rtlib_name : Error< "invalid runtime library name in argument '%0'">; def err_drv_unsupported_rtlib_for_platform : Error< diff --git a/clang/include/clang/Driver/Options.td b/clang/include/clang/Driver/Options.td index d143781d1d09..3e4fbf1fbb8f 100644 --- a/clang/include/clang/Driver/Options.td +++ b/clang/include/clang/Driver/Options.td @@ -1053,7 +1053,10 @@ defm coroutines_ts : OptInFFlag<"coroutines-ts", "Enable support for the C++ Cor def fembed_bitcode_EQ : Joined<["-"], "fembed-bitcode=">, Group, Flags<[NoXarchOption, CC1Option, CC1AsOption]>, MetaVarName<"">, -HelpText<"Embed LLVM bitcode (option: off, all, bitcode, marker)">; +HelpText<"Embed LLVM bitcode (option: off, all, bitcode, marker)">, +Values<"off,all,bitcode,marker">, NormalizedValuesScope<"CodeGenOptions">, +NormalizedValues<["Embed_Off", "Embed_All", "Embed_Bitcode", "Embed_Marker"]>, +MarshallingInfoString<"CodeGenOpts.EmbedBitcode", "Embed_Off">, AutoNormalizeEnum; def fembed_bitcode : Flag<["-"], "fembed-bitcode">, Group, Alias, AliasArgs<["all"]>, HelpText<"Embed LLVM IR bitcode as data">; @@ -1070,7 +1073,8 @@ def fno_profile_sample_use : Flag<["-"], "fno-profile-sample-use">, Group; def fprofile_sample_use_EQ : Joined<["-"], "fprofile-sample-use=">, Group, Flags<[NoXarchOption, CC1Option]>, -HelpText<"Enable sample-based profile guided optimizations">; +HelpText<"Enable sample-based profile guided optimizations">, +MarshallingInfoString<"CodeGenOpts.SampleProfileFile">; def fprofile_sample_accurate : Flag<["-"], "fprofile-sample-accurate">, Group, Flags<[NoXarchOption, CC1Option]>, HelpText<"Specifies that the sample profile is accurate">, @@ -1093,7 +1097,8 @@ def fno_auto_profile_accurate : Flag<["-"], "fno-auto-profile-accurate">, Group, Alias; def fdebug_compilation_dir : Separate<["-"], "fdebug-compilation-dir">, Group, Flags<[CC1Option, CC1AsOption, CoreOption]>, -HelpText<"The compilation directory to embed in the debug info.">; +HelpText<"The compilation directory to embed in the debug info.">, +MarshallingInfoString<"CodeGenOpts.DebugCompilationDir">; def fdebug_compilation_dir_EQ : Joined<["-"], "fdebug-compilation-dir=">, Group, Flags<[CC1Option, CC1AsOption, CoreOption]>, Alias; @@ -1114,7 +1119,8 @@ def fprofile_instr_use_EQ : Joined<["-"], "fprofile-instr-use=">, HelpText<"Use instrumentation data for profile-guided optimization">; def fprofile_remapping_file_EQ : Joined<["-"], "fprofile-remapping-file=">, Group, Flags<[CC1Option, CoreOption]>, MetaVarName<"">, -HelpText<"Use the remappings described in to match the profile data against names in the program">; +HelpText<"Use the remappings described in to match the profile data against names in the program">, +MarshallingInfoString<"CodeGenOpts.ProfileRemappingFile">; def fprofile_re
[llvm-branch-commits] [clang] 7d246cb - [flang][driver] Add support for `-fsyntax-only`
Author: Andrzej Warzynski Date: 2020-12-18T09:35:02Z New Revision: 7d246cb19db9fce65946fb4bac6e570787dbe78a URL: https://github.com/llvm/llvm-project/commit/7d246cb19db9fce65946fb4bac6e570787dbe78a DIFF: https://github.com/llvm/llvm-project/commit/7d246cb19db9fce65946fb4bac6e570787dbe78a.diff LOG: [flang][driver] Add support for `-fsyntax-only` The behaviour triggered with this flag is consistent with `-fparse-only` in `flang` (i.e. the throwaway driver). This new spelling is consistent with Clang and gfortran, and was proposed and agreed on for the new driver in [1]. This patch also adds some minimal logic to communicate whether the semantic checks have failed or not. When semantic checks fail, a frontend driver error is generated. The return code from the frontend driver is then determined by checking the driver diagnostics - the presence of driver errors means that the compilation has failed. This logic is consistent with `clang -cc1`. [1] http://lists.llvm.org/pipermail/flang-dev/2020-November/000588.html Differential Revision: https://reviews.llvm.org/D92854 Added: flang/test/Flang-Driver/syntax-only.f90 Modified: clang/include/clang/Driver/Options.td flang/include/flang/Frontend/CompilerInstance.h flang/include/flang/Frontend/FrontendActions.h flang/include/flang/Frontend/FrontendOptions.h flang/lib/Frontend/CMakeLists.txt flang/lib/Frontend/CompilerInstance.cpp flang/lib/Frontend/CompilerInvocation.cpp flang/lib/Frontend/FrontendActions.cpp flang/lib/FrontendTool/ExecuteCompilerInvocation.cpp flang/unittests/Frontend/PrintPreprocessedTest.cpp Removed: diff --git a/clang/include/clang/Driver/Options.td b/clang/include/clang/Driver/Options.td index 3e4fbf1fbb8f..63a5b5484f0f 100644 --- a/clang/include/clang/Driver/Options.td +++ b/clang/include/clang/Driver/Options.td @@ -2287,7 +2287,7 @@ defm strict_vtable_pointers : BoolFOption<"strict-vtable-pointers", ResetBy>; def fstrict_overflow : Flag<["-"], "fstrict-overflow">, Group; def fsyntax_only : Flag<["-"], "fsyntax-only">, - Flags<[NoXarchOption,CoreOption,CC1Option]>, Group; + Flags<[NoXarchOption,CoreOption,CC1Option,FC1Option]>, Group; def ftabstop_EQ : Joined<["-"], "ftabstop=">, Group; def ftemplate_depth_EQ : Joined<["-"], "ftemplate-depth=">, Group; def ftemplate_depth_ : Joined<["-"], "ftemplate-depth-">, Group; diff --git a/flang/include/flang/Frontend/CompilerInstance.h b/flang/include/flang/Frontend/CompilerInstance.h index 21ef9f0dcd47..b00b5cd4479a 100644 --- a/flang/include/flang/Frontend/CompilerInstance.h +++ b/flang/include/flang/Frontend/CompilerInstance.h @@ -12,6 +12,7 @@ #include "flang/Frontend/FrontendAction.h" #include "flang/Parser/parsing.h" #include "flang/Parser/provenance.h" +#include "flang/Semantics/semantics.h" #include "llvm/Support/raw_ostream.h" namespace Fortran::frontend { @@ -28,6 +29,12 @@ class CompilerInstance { std::shared_ptr parsing_; + /// The stream for diagnostics from Semantics + llvm::raw_ostream *semaOutputStream_ = &llvm::errs(); + + /// The stream for diagnostics from Semantics if owned, otherwise nullptr. + std::unique_ptr ownedSemaOutputStream_; + /// The diagnostics engine instance. llvm::IntrusiveRefCntPtr diagnostics_; @@ -77,6 +84,11 @@ class CompilerInstance { bool HasAllSources() const { return allSources_ != nullptr; } + parser::AllCookedSources &allCookedSources() { +assert(allCookedSources_ && "Compiler instance has no AllCookedSources!"); +return *allCookedSources_; + }; + /// } /// @name Parser Operations /// { @@ -84,6 +96,19 @@ class CompilerInstance { /// Return parsing to be used by Actions. Fortran::parser::Parsing &parsing() const { return *parsing_; } + /// } + /// @name Semantic analysis + /// { + + /// Replace the current stream for verbose output. + void set_semaOutputStream(llvm::raw_ostream &Value); + + /// Replace the current stream for verbose output. + void set_semaOutputStream(std::unique_ptr Value); + + /// Get the current stream for verbose output. + llvm::raw_ostream &semaOutputStream() { return *semaOutputStream_; } + /// } /// @name High-Level Operations /// { diff --git a/flang/include/flang/Frontend/FrontendActions.h b/flang/include/flang/Frontend/FrontendActions.h index db5afe4da7eb..3eea94b60bf5 100644 --- a/flang/include/flang/Frontend/FrontendActions.h +++ b/flang/include/flang/Frontend/FrontendActions.h @@ -25,6 +25,10 @@ class PrintPreprocessedAction : public FrontendAction { void ExecuteAction() override; }; +class ParseSyntaxOnlyAction : public FrontendAction { + void ExecuteAction() override; +}; + } // namespace Fortran::frontend #endif // LLVM_FLANG_FRONTEND_FRONTENDACTIONS_H diff --git a/flang/include/flang/Frontend/FrontendOptions.h b/flang/include/flang/Frontend/FrontendOptions.h index ac8f01d2a1
[llvm-branch-commits] [llvm] 324d96b - [IndVars] A test for adding trunc instructions to unwind blocks
Author: Yevgeny Rouban Date: 2020-12-18T17:08:26+07:00 New Revision: 324d96b63759c00804ddb2ad74440afc39c52ebf URL: https://github.com/llvm/llvm-project/commit/324d96b63759c00804ddb2ad74440afc39c52ebf DIFF: https://github.com/llvm/llvm-project/commit/324d96b63759c00804ddb2ad74440afc39c52ebf.diff LOG: [IndVars] A test for adding trunc instructions to unwind blocks Differential Revision: https://reviews.llvm.org/D93521 Reviewed By: skatkov Added: Modified: llvm/test/Transforms/IndVarSimplify/widen-loop-comp.ll Removed: diff --git a/llvm/test/Transforms/IndVarSimplify/widen-loop-comp.ll b/llvm/test/Transforms/IndVarSimplify/widen-loop-comp.ll index 94cd63257cf4..70e9a755c7a8 100644 --- a/llvm/test/Transforms/IndVarSimplify/widen-loop-comp.ll +++ b/llvm/test/Transforms/IndVarSimplify/widen-loop-comp.ll @@ -738,6 +738,66 @@ failure: unreachable } +declare void @test14a-callee(i1 %cond) + +; Same as @test14 but with unwind exit. +; Trunc instructions must be added below the landing pad. +define i32 @test14a(i32 %start, i32* %p, i32* %q, i1 %c) personality i1 1 { +; CHECK-LABEL: @test14a( +; CHECK-NEXT: entry: +; CHECK-NEXT:[[TMP0:%.*]] = zext i32 [[START:%.*]] to i64 +; CHECK-NEXT:br label [[LOOP:%.*]] +; CHECK: loop: +; CHECK-NEXT:[[INDVARS_IV:%.*]] = phi i64 [ [[INDVARS_IV_NEXT:%.*]], [[BACKEDGE:%.*]] ], [ [[TMP0]], [[ENTRY:%.*]] ] +; CHECK-NEXT:[[COND:%.*]] = icmp eq i64 [[INDVARS_IV]], 0 +; CHECK-NEXT:[[TMP1:%.*]] = add nsw i64 [[INDVARS_IV]], -1 +; CHECK-NEXT:br i1 [[COND]], label [[EXIT:%.*]], label [[BACKEDGE]] +; CHECK: backedge: +; CHECK-NEXT:[[STORE_ADDR:%.*]] = getelementptr i32, i32* [[P:%.*]], i64 [[TMP1]] +; CHECK-NEXT:store i32 1, i32* [[STORE_ADDR]], align 4 +; CHECK-NEXT:[[STOP:%.*]] = load i32, i32* [[Q:%.*]], align 4 +; CHECK-NEXT:[[LOOP_COND:%.*]] = icmp eq i32 [[STOP]], 0 +; CHECK-NEXT:[[INDVARS_IV_NEXT]] = add nsw i64 [[INDVARS_IV]], -1 +; CHECK-NEXT:invoke void @test14a-callee(i1 [[LOOP_COND]]) +; CHECK-NEXT:to label [[LOOP]] unwind label [[EXCEPTION:%.*]] +; CHECK: exit: +; CHECK-NEXT:[[TMP2:%.*]] = trunc i64 -1 to i32 +; CHECK-NEXT:ret i32 [[TMP2]] +; CHECK: exception: +; CHECK-NEXT:[[FOO_LCSSA1_WIDE:%.*]] = phi i64 [ [[TMP1]], [[BACKEDGE]] ] +; CHECK-NEXT:[[TMP3:%.*]] = landingpad i1 +; CHECK-NEXT:cleanup +; CHECK-NEXT:[[TMP4:%.*]] = trunc i64 [[FOO_LCSSA1_WIDE]] to i32 +; CHECK-NEXT:ret i32 [[TMP4]] +; +entry: + br label %loop + +loop: + %iv = phi i32 [%start, %entry], [%iv.next.1, %backedge] + %cond = icmp eq i32 %iv, 0 + %foo = add i32 %iv, -1 + br i1 %cond, label %exit, label %backedge + +backedge: + %index = zext i32 %foo to i64 + %store.addr = getelementptr i32, i32* %p, i64 %index + store i32 1, i32* %store.addr + %load.addr = getelementptr i32, i32* %q, i64 %index + %stop = load i32, i32* %q + %loop.cond = icmp eq i32 %stop, 0 + %iv.next.1 = add i32 %iv, -1 + invoke void @test14a-callee(i1 %loop.cond) to label %loop unwind label %exception + +exit: + ret i32 %foo + +exception: + landingpad i1 + cleanup + ret i32 %foo +} + declare void @use(i32 %arg) define i32 @test15(i32 %start, i32* %p, i32* %q) { ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [clang-tools-extra] 9899319 - [clangd] Add hot-reload of compile_commands.json and compile_flags.txt
Author: Sam McCall Date: 2020-12-18T11:16:46+01:00 New Revision: 98993193e9037345ad13720a62974064a5f3d953 URL: https://github.com/llvm/llvm-project/commit/98993193e9037345ad13720a62974064a5f3d953 DIFF: https://github.com/llvm/llvm-project/commit/98993193e9037345ad13720a62974064a5f3d953.diff LOG: [clangd] Add hot-reload of compile_commands.json and compile_flags.txt When querying the CDB, we stat the underlying file to check it hasn't changed. We don't do this every time, but only if we didn't check within 5 seconds. This behavior only exists for compile_commands.json and compile_flags.txt. The CDB plugin system doesn't expose enough information to handle others. Slight behavior change: we now only look for `build/compile_commands.json` rather than trying every CDB strategy under `build` subdirectories. Differential Revision: https://reviews.llvm.org/D92663 Added: Modified: clang-tools-extra/clangd/ClangdLSPServer.cpp clang-tools-extra/clangd/GlobalCompilationDatabase.cpp clang-tools-extra/clangd/GlobalCompilationDatabase.h clang-tools-extra/clangd/tool/Check.cpp clang-tools-extra/clangd/unittests/GlobalCompilationDatabaseTests.cpp Removed: diff --git a/clang-tools-extra/clangd/ClangdLSPServer.cpp b/clang-tools-extra/clangd/ClangdLSPServer.cpp index 66dee68ec474..b32c9e13973b 100644 --- a/clang-tools-extra/clangd/ClangdLSPServer.cpp +++ b/clang-tools-extra/clangd/ClangdLSPServer.cpp @@ -496,8 +496,10 @@ void ClangdLSPServer::onInitialize(const InitializeParams &Params, if (const auto &Dir = Params.initializationOptions.compilationDatabasePath) Opts.CompileCommandsDir = Dir; if (Opts.UseDirBasedCDB) { -BaseCDB = std::make_unique( -Opts.CompileCommandsDir); +DirectoryBasedGlobalCompilationDatabase::Options CDBOpts(TFS); +CDBOpts.CompileCommandsDir = Opts.CompileCommandsDir; +BaseCDB = +std::make_unique(CDBOpts); BaseCDB = getQueryDriverDatabase(llvm::makeArrayRef(Opts.QueryDriverGlobs), std::move(BaseCDB)); } @@ -704,6 +706,10 @@ void ClangdLSPServer::onFileEvent(const DidChangeWatchedFilesParams &Params) { // - this is useful e.g. when switching git branches, but we're likely to see //fresh headers but still have the old-branch main-file content Server->onFileEvent(Params); + // FIXME: observe config files, immediately expire time-based caches, reparse: + // - compile_commands.json and compile_flags.txt + // - .clang_format and .clang-tidy + // - .clangd and clangd/config.yaml } void ClangdLSPServer::onCommand(const ExecuteCommandParams &Params, diff --git a/clang-tools-extra/clangd/GlobalCompilationDatabase.cpp b/clang-tools-extra/clangd/GlobalCompilationDatabase.cpp index add0eec4a2c8..41b549cefc7c 100644 --- a/clang-tools-extra/clangd/GlobalCompilationDatabase.cpp +++ b/clang-tools-extra/clangd/GlobalCompilationDatabase.cpp @@ -8,11 +8,15 @@ #include "GlobalCompilationDatabase.h" #include "FS.h" +#include "SourceCode.h" #include "support/Logger.h" #include "support/Path.h" +#include "support/ThreadsafeFS.h" #include "clang/Frontend/CompilerInvocation.h" #include "clang/Tooling/ArgumentsAdjusters.h" #include "clang/Tooling/CompilationDatabase.h" +#include "clang/Tooling/CompilationDatabasePluginRegistry.h" +#include "clang/Tooling/JSONCompilationDatabase.h" #include "llvm/ADT/None.h" #include "llvm/ADT/Optional.h" #include "llvm/ADT/STLExtras.h" @@ -22,6 +26,7 @@ #include "llvm/Support/FileUtilities.h" #include "llvm/Support/Path.h" #include "llvm/Support/Program.h" +#include "llvm/Support/VirtualFileSystem.h" #include #include #include @@ -85,33 +90,78 @@ GlobalCompilationDatabase::getFallbackCommand(PathRef File) const { // - 1) determine all the paths that might be searched // - 2) acquire the map lock and get-or-create all the DirectoryCache entries // - 3) release the map lock and query the caches as desired -// -// FIXME: this should revalidate the cache sometimes -// FIXME: IO should go through a VFS class DirectoryBasedGlobalCompilationDatabase::DirectoryCache { - // Absolute canonical path that we're the cache for. (Not case-folded). - const std::string Path; - - // True if we've looked for a CDB here and found none. - // (This makes it possible for get() to return without taking a lock) - // FIXME: this should have an expiry time instead of lasting forever. - std::atomic FinalizedNoCDB = {false}; - - // Guards following cache state. + using stopwatch = std::chrono::steady_clock; + + // CachedFile is used to read a CDB file on disk (e.g. compile_commands.json). + // It specializes in being able to quickly bail out if the file is unchanged, + // which is the common case. + // Internally, it stores file metadata so a stat() can verify it's unchanged. + // We don't actually cache the content as it's not needed -
[llvm-branch-commits] [llvm] 7c8796f - [TTI] Add supportsScalableVectors target hook
Author: Cullen Rhodes Date: 2020-12-18T10:37:01Z New Revision: 7c8796f9db2c82ea6e3721744a7d98ebf0e77cd3 URL: https://github.com/llvm/llvm-project/commit/7c8796f9db2c82ea6e3721744a7d98ebf0e77cd3 DIFF: https://github.com/llvm/llvm-project/commit/7c8796f9db2c82ea6e3721744a7d98ebf0e77cd3.diff LOG: [TTI] Add supportsScalableVectors target hook This is split off from D91718 and adds a new target hook supportsScalableVectors that can be queried to check if scalable vectors are supported by the backend. For AArch64 this returns true if SVE is enabled. Reviewed By: david-arm Differential Revision: https://reviews.llvm.org/D93060 Added: Modified: llvm/include/llvm/Analysis/TargetTransformInfo.h llvm/include/llvm/Analysis/TargetTransformInfoImpl.h llvm/lib/Analysis/TargetTransformInfo.cpp llvm/lib/Target/AArch64/AArch64TargetTransformInfo.h Removed: diff --git a/llvm/include/llvm/Analysis/TargetTransformInfo.h b/llvm/include/llvm/Analysis/TargetTransformInfo.h index b9b9df35cdb0..0953a3b3f451 100644 --- a/llvm/include/llvm/Analysis/TargetTransformInfo.h +++ b/llvm/include/llvm/Analysis/TargetTransformInfo.h @@ -1340,6 +1340,9 @@ class TargetTransformInfo { /// to a stack reload. unsigned getGISelRematGlobalCost() const; + /// \returns True if the target supports scalable vectors. + bool supportsScalableVectors() const; + /// \name Vector Predication Information /// @{ /// Whether the target supports the %evl parameter of VP intrinsic efficiently @@ -1634,6 +1637,7 @@ class TargetTransformInfo::Concept { ReductionFlags) const = 0; virtual bool shouldExpandReduction(const IntrinsicInst *II) const = 0; virtual unsigned getGISelRematGlobalCost() const = 0; + virtual bool supportsScalableVectors() const = 0; virtual bool hasActiveVectorLength() const = 0; virtual int getInstructionLatency(const Instruction *I) = 0; }; @@ -2163,6 +2167,10 @@ class TargetTransformInfo::Model final : public TargetTransformInfo::Concept { return Impl.getGISelRematGlobalCost(); } + bool supportsScalableVectors() const override { +return Impl.supportsScalableVectors(); + } + bool hasActiveVectorLength() const override { return Impl.hasActiveVectorLength(); } diff --git a/llvm/include/llvm/Analysis/TargetTransformInfoImpl.h b/llvm/include/llvm/Analysis/TargetTransformInfoImpl.h index 2c206094ac4a..6415e7bfe7c3 100644 --- a/llvm/include/llvm/Analysis/TargetTransformInfoImpl.h +++ b/llvm/include/llvm/Analysis/TargetTransformInfoImpl.h @@ -685,6 +685,8 @@ class TargetTransformInfoImplBase { unsigned getGISelRematGlobalCost() const { return 1; } + bool supportsScalableVectors() const { return false; } + bool hasActiveVectorLength() const { return false; } protected: diff --git a/llvm/lib/Analysis/TargetTransformInfo.cpp b/llvm/lib/Analysis/TargetTransformInfo.cpp index 086a212ee65b..becf74c64fd5 100644 --- a/llvm/lib/Analysis/TargetTransformInfo.cpp +++ b/llvm/lib/Analysis/TargetTransformInfo.cpp @@ -1056,6 +1056,10 @@ unsigned TargetTransformInfo::getGISelRematGlobalCost() const { return TTIImpl->getGISelRematGlobalCost(); } +bool TargetTransformInfo::supportsScalableVectors() const { + return TTIImpl->supportsScalableVectors(); +} + int TargetTransformInfo::getInstructionLatency(const Instruction *I) const { return TTIImpl->getInstructionLatency(I); } diff --git a/llvm/lib/Target/AArch64/AArch64TargetTransformInfo.h b/llvm/lib/Target/AArch64/AArch64TargetTransformInfo.h index baf11cd7fa23..c8e721b1fb9f 100644 --- a/llvm/lib/Target/AArch64/AArch64TargetTransformInfo.h +++ b/llvm/lib/Target/AArch64/AArch64TargetTransformInfo.h @@ -228,6 +228,8 @@ class AArch64TTIImpl : public BasicTTIImplBase { return 2; } + bool supportsScalableVectors() const { return ST->hasSVE(); } + bool useReductionIntrinsic(unsigned Opcode, Type *Ty, TTI::ReductionFlags Flags) const; ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [llvm] b58b440 - [AMDGPU][NFC] Document high parameter of f16 interp intrinsics
Author: Carl Ritson Date: 2020-12-18T19:59:13+09:00 New Revision: b58b440d19c84f59aae4679608c55db0d95ff879 URL: https://github.com/llvm/llvm-project/commit/b58b440d19c84f59aae4679608c55db0d95ff879 DIFF: https://github.com/llvm/llvm-project/commit/b58b440d19c84f59aae4679608c55db0d95ff879.diff LOG: [AMDGPU][NFC] Document high parameter of f16 interp intrinsics Added: Modified: llvm/include/llvm/IR/IntrinsicsAMDGPU.td Removed: diff --git a/llvm/include/llvm/IR/IntrinsicsAMDGPU.td b/llvm/include/llvm/IR/IntrinsicsAMDGPU.td index ea4a93f8bdef..2cab7f38e281 100644 --- a/llvm/include/llvm/IR/IntrinsicsAMDGPU.td +++ b/llvm/include/llvm/IR/IntrinsicsAMDGPU.td @@ -1330,6 +1330,7 @@ def int_amdgcn_interp_p2 : // See int_amdgcn_v_interp_p1 for why this is IntrNoMem. // __builtin_amdgcn_interp_p1_f16 , , , , +// high selects whether high or low 16-bits are loaded from LDS def int_amdgcn_interp_p1_f16 : GCCBuiltin<"__builtin_amdgcn_interp_p1_f16">, Intrinsic<[llvm_float_ty], @@ -1338,6 +1339,7 @@ def int_amdgcn_interp_p1_f16 : ImmArg>, ImmArg>, ImmArg>]>; // __builtin_amdgcn_interp_p2_f16 , , , , , +// high selects whether high or low 16-bits are loaded from LDS def int_amdgcn_interp_p2_f16 : GCCBuiltin<"__builtin_amdgcn_interp_p2_f16">, Intrinsic<[llvm_half_ty], ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [llvm] da21f7e - [AArch64] Add support for the Branch Record Buffer extension
Author: Lucas Prates Date: 2020-12-18T11:11:06Z New Revision: da21f7ec146e7e46a1622253f1cce8af3b290e23 URL: https://github.com/llvm/llvm-project/commit/da21f7ec146e7e46a1622253f1cce8af3b290e23 DIFF: https://github.com/llvm/llvm-project/commit/da21f7ec146e7e46a1622253f1cce8af3b290e23.diff LOG: [AArch64] Add support for the Branch Record Buffer extension This introduces asm support for the Branch Record Buffer extension, through the new 'brbe' subtarget feature. It consists of a new set of system registers that enable the handling of branch records. Patch written by Simon Tatham. Reviewed By: ostannard Differential Revision: https://reviews.llvm.org/D92389 Added: llvm/test/MC/AArch64/brbe.s llvm/test/MC/Disassembler/AArch64/brbe.txt Modified: llvm/include/llvm/Support/AArch64TargetParser.def llvm/include/llvm/Support/AArch64TargetParser.h llvm/lib/Support/AArch64TargetParser.cpp llvm/lib/Target/AArch64/AArch64.td llvm/lib/Target/AArch64/AArch64InstrInfo.td llvm/lib/Target/AArch64/AArch64Subtarget.h llvm/lib/Target/AArch64/AArch64SystemOperands.td Removed: diff --git a/llvm/include/llvm/Support/AArch64TargetParser.def b/llvm/include/llvm/Support/AArch64TargetParser.def index 3683148427b8..97172730e364 100644 --- a/llvm/include/llvm/Support/AArch64TargetParser.def +++ b/llvm/include/llvm/Support/AArch64TargetParser.def @@ -107,6 +107,7 @@ AARCH64_ARCH_EXT_NAME("f32mm",AArch64::AEK_F32MM, "+f32mm", "-f32m AARCH64_ARCH_EXT_NAME("f64mm",AArch64::AEK_F64MM, "+f64mm", "-f64mm") AARCH64_ARCH_EXT_NAME("tme", AArch64::AEK_TME, "+tme", "-tme") AARCH64_ARCH_EXT_NAME("ls64", AArch64::AEK_LS64,"+ls64", "-ls64") +AARCH64_ARCH_EXT_NAME("brbe", AArch64::AEK_BRBE,"+brbe", "-brbe") #undef AARCH64_ARCH_EXT_NAME #ifndef AARCH64_CPU_NAME diff --git a/llvm/include/llvm/Support/AArch64TargetParser.h b/llvm/include/llvm/Support/AArch64TargetParser.h index aac9197b9c5d..a3c9c6a30483 100644 --- a/llvm/include/llvm/Support/AArch64TargetParser.h +++ b/llvm/include/llvm/Support/AArch64TargetParser.h @@ -63,6 +63,7 @@ enum ArchExtKind : uint64_t { AEK_F32MM = 1ULL << 31, AEK_F64MM = 1ULL << 32, AEK_LS64 =1ULL << 33, + AEK_BRBE =1ULL << 34, }; enum class ArchKind { diff --git a/llvm/lib/Support/AArch64TargetParser.cpp b/llvm/lib/Support/AArch64TargetParser.cpp index ac8f5ac8ca01..62761177c8c2 100644 --- a/llvm/lib/Support/AArch64TargetParser.cpp +++ b/llvm/lib/Support/AArch64TargetParser.cpp @@ -100,6 +100,8 @@ bool AArch64::getExtensionFeatures(uint64_t Extensions, Features.push_back("+sve2-bitperm"); if (Extensions & AEK_RCPC) Features.push_back("+rcpc"); + if (Extensions & AEK_BRBE) +Features.push_back("+brbe"); return true; } diff --git a/llvm/lib/Target/AArch64/AArch64.td b/llvm/lib/Target/AArch64/AArch64.td index 69f2e31ecfb4..6457c86e926f 100644 --- a/llvm/lib/Target/AArch64/AArch64.td +++ b/llvm/lib/Target/AArch64/AArch64.td @@ -412,6 +412,9 @@ def FeatureHCX : SubtargetFeature< def FeatureLS64 : SubtargetFeature<"ls64", "HasLS64", "true", "Enable Armv8.7-A LD64B/ST64B Accelerator Extension">; +def FeatureBRBE : SubtargetFeature<"brbe", "HasBRBE", +"true", "Enable Branch Record Buffer Extension">; + def FeatureFineGrainedTraps : SubtargetFeature<"fgt", "HasFineGrainedTraps", "true", "Enable fine grained virtualization traps extension">; diff --git a/llvm/lib/Target/AArch64/AArch64InstrInfo.td b/llvm/lib/Target/AArch64/AArch64InstrInfo.td index 97b2ea3c345a..5c55dd9834a7 100644 --- a/llvm/lib/Target/AArch64/AArch64InstrInfo.td +++ b/llvm/lib/Target/AArch64/AArch64InstrInfo.td @@ -157,6 +157,8 @@ def HasWFxT : Predicate<"Subtarget->hasWFxT()">, AssemblerPredicate<(all_of FeatureWFxT), "wfxt">; def HasLS64 : Predicate<"Subtarget->hasLS64()">, AssemblerPredicate<(all_of FeatureLS64), "ls64">; +def HasBRBE : Predicate<"Subtarget->hasBRBE()">, + AssemblerPredicate<(all_of FeatureBRBE), "brbe">; def IsLE : Predicate<"Subtarget->isLittleEndian()">; def IsBE : Predicate<"!Subtarget->isLittleEndian()">; def IsWindows: Predicate<"Subtarget->isTargetWindows()">; diff --git a/llvm/lib/Target/AArch64/AArch64Subtarget.h b/llvm/lib/Target/AArch64/AArch64Subtarget.h index 2a9426cf8c30..169e8494f173 100644 --- a/llvm/lib/Target/AArch64/AArch64Subtarget.h +++ b/llvm/lib/Target/AArch64/AArch64Subtarget.h @@ -184,6 +184,7 @@ class AArch64Subtarget final : public AArch64GenSubtargetInfo { // Future architecture extensions. bool HasETE = false; bool HasTRBE = false; + bool HasBRBE = false; // HasZeroCycleRegMove - Has zero-cycle register mov instructions. bool HasZeroCycleRegM
[llvm-branch-commits] [llvm] 51fe17b - [AArch64] Add support for the SPE-EEF feature
Author: Lucas Prates Date: 2020-12-18T11:11:56Z New Revision: 51fe17b0471a2b0a27ce038426e6b996218061a2 URL: https://github.com/llvm/llvm-project/commit/51fe17b0471a2b0a27ce038426e6b996218061a2 DIFF: https://github.com/llvm/llvm-project/commit/51fe17b0471a2b0a27ce038426e6b996218061a2.diff LOG: [AArch64] Add support for the SPE-EEF feature This is an addition to the existing Statistical Profiling extension, which introduces an extra system register that is enabled by the new 'spe-eef' subtarget feature. Patch written by Simon Tatham. Reviewed By: ostannard Differential Revision: https://reviews.llvm.org/D92391 Added: llvm/test/MC/AArch64/spe.s Modified: llvm/lib/Target/AArch64/AArch64.td llvm/lib/Target/AArch64/AArch64InstrInfo.td llvm/lib/Target/AArch64/AArch64Subtarget.h llvm/lib/Target/AArch64/AArch64SystemOperands.td Removed: diff --git a/llvm/lib/Target/AArch64/AArch64.td b/llvm/lib/Target/AArch64/AArch64.td index 6457c86e926f..2df4e92e42cb 100644 --- a/llvm/lib/Target/AArch64/AArch64.td +++ b/llvm/lib/Target/AArch64/AArch64.td @@ -415,6 +415,9 @@ def FeatureLS64 : SubtargetFeature<"ls64", "HasLS64", def FeatureBRBE : SubtargetFeature<"brbe", "HasBRBE", "true", "Enable Branch Record Buffer Extension">; +def FeatureSPE_EEF : SubtargetFeature<"spe-eef", "HasSPE_EEF", +"true", "Enable extra register in the Statistical Profiling Extension">; + def FeatureFineGrainedTraps : SubtargetFeature<"fgt", "HasFineGrainedTraps", "true", "Enable fine grained virtualization traps extension">; diff --git a/llvm/lib/Target/AArch64/AArch64InstrInfo.td b/llvm/lib/Target/AArch64/AArch64InstrInfo.td index 5c55dd9834a7..c1d8fd1aba3d 100644 --- a/llvm/lib/Target/AArch64/AArch64InstrInfo.td +++ b/llvm/lib/Target/AArch64/AArch64InstrInfo.td @@ -159,6 +159,8 @@ def HasLS64 : Predicate<"Subtarget->hasLS64()">, AssemblerPredicate<(all_of FeatureLS64), "ls64">; def HasBRBE : Predicate<"Subtarget->hasBRBE()">, AssemblerPredicate<(all_of FeatureBRBE), "brbe">; +def HasSPE_EEF : Predicate<"Subtarget->hasSPE_EEF()">, + AssemblerPredicate<(all_of FeatureSPE_EEF), "spe-eef">; def IsLE : Predicate<"Subtarget->isLittleEndian()">; def IsBE : Predicate<"!Subtarget->isLittleEndian()">; def IsWindows: Predicate<"Subtarget->isTargetWindows()">; diff --git a/llvm/lib/Target/AArch64/AArch64Subtarget.h b/llvm/lib/Target/AArch64/AArch64Subtarget.h index 169e8494f173..641450a6d776 100644 --- a/llvm/lib/Target/AArch64/AArch64Subtarget.h +++ b/llvm/lib/Target/AArch64/AArch64Subtarget.h @@ -185,6 +185,7 @@ class AArch64Subtarget final : public AArch64GenSubtargetInfo { bool HasETE = false; bool HasTRBE = false; bool HasBRBE = false; + bool HasSPE_EEF = false; // HasZeroCycleRegMove - Has zero-cycle register mov instructions. bool HasZeroCycleRegMove = false; diff --git a/llvm/lib/Target/AArch64/AArch64SystemOperands.td b/llvm/lib/Target/AArch64/AArch64SystemOperands.td index a753b4d4fbc4..a69aa68405d4 100644 --- a/llvm/lib/Target/AArch64/AArch64SystemOperands.td +++ b/llvm/lib/Target/AArch64/AArch64SystemOperands.td @@ -1593,6 +1593,10 @@ foreach n = 0-31 in { } } +// Statistical Profiling Extension system register +let Requires = [{ {AArch64::FeatureSPE_EEF} }] in +def : RWSysReg<"PMSNEVFR_EL1", 0b11, 0b000, 0b1001, 0b1001, 0b001>; + // Cyclone specific system registers // Op0Op1 CRn CRmOp2 let Requires = [{ {AArch64::ProcAppleA7} }] in diff --git a/llvm/test/MC/AArch64/spe.s b/llvm/test/MC/AArch64/spe.s new file mode 100644 index ..a6fb46291dea --- /dev/null +++ b/llvm/test/MC/AArch64/spe.s @@ -0,0 +1,6 @@ +// RUN: llvm-mc -triple aarch64 -mattr +spe-eef -show-encoding %s 2>%t | FileCheck %s + +msr PMSNEVFR_EL1, x0 +mrs x1, PMSNEVFR_EL1 +// CHECK: msr PMSNEVFR_EL1, x0// encoding: [0x20,0x99,0x18,0xd5] +// CHECK: mrs x1, PMSNEVFR_EL1// encoding: [0x21,0x99,0x38,0xd5] ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [llvm] 7722494 - [AMDGPU][NFC] Remove unused Hi16Elt definition
Author: Carl Ritson Date: 2020-12-18T20:38:54+09:00 New Revision: 7722494834a8357a42d3da70d22f4a9d87c78e2c URL: https://github.com/llvm/llvm-project/commit/7722494834a8357a42d3da70d22f4a9d87c78e2c DIFF: https://github.com/llvm/llvm-project/commit/7722494834a8357a42d3da70d22f4a9d87c78e2c.diff LOG: [AMDGPU][NFC] Remove unused Hi16Elt definition Added: Modified: llvm/lib/Target/AMDGPU/SIInstrInfo.td Removed: diff --git a/llvm/lib/Target/AMDGPU/SIInstrInfo.td b/llvm/lib/Target/AMDGPU/SIInstrInfo.td index 5a6c81a0c89b..746d08b8ce0e 100644 --- a/llvm/lib/Target/AMDGPU/SIInstrInfo.td +++ b/llvm/lib/Target/AMDGPU/SIInstrInfo.td @@ -1331,9 +1331,6 @@ def VOP3OpSelMods : ComplexPattern; def VOP3PMadMixMods : ComplexPattern; - -def Hi16Elt : ComplexPattern; - //===--===// // SI assembler operands //===--===// ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [llvm] 992fad0 - [X86][AVX] Replace extract_subvector(broadcast(), 0) folds with generic SimplifyDemandedVectorEltsForTargetNode handling.
Author: Simon Pilgrim Date: 2020-12-18T11:51:10Z New Revision: 992fad03e27586d7ffd03833c4609e29be5b60c8 URL: https://github.com/llvm/llvm-project/commit/992fad03e27586d7ffd03833c4609e29be5b60c8 DIFF: https://github.com/llvm/llvm-project/commit/992fad03e27586d7ffd03833c4609e29be5b60c8.diff LOG: [X86][AVX] Replace extract_subvector(broadcast(), 0) folds with generic SimplifyDemandedVectorEltsForTargetNode handling. Simplifies a few more cases, notably shuffle demanded elts cases. Added: Modified: llvm/lib/Target/X86/X86ISelLowering.cpp llvm/test/CodeGen/X86/avx512-shuffles/partial_permute.ll llvm/test/CodeGen/X86/oddshuffles.ll llvm/test/CodeGen/X86/vec_int_to_fp.ll llvm/test/CodeGen/X86/vector-fshl-rot-256.ll llvm/test/CodeGen/X86/vector-rotate-256.ll llvm/test/CodeGen/X86/vector-shift-shl-256.ll Removed: diff --git a/llvm/lib/Target/X86/X86ISelLowering.cpp b/llvm/lib/Target/X86/X86ISelLowering.cpp index 20a75cb64fa8..d4aa97a706ef 100644 --- a/llvm/lib/Target/X86/X86ISelLowering.cpp +++ b/llvm/lib/Target/X86/X86ISelLowering.cpp @@ -38007,7 +38007,7 @@ bool X86TargetLowering::SimplifyDemandedVectorEltsForTargetNode( SDValue Src = Op.getOperand(0); MVT SrcVT = Src.getSimpleValueType(); if (!SrcVT.isVector()) - return false; + break; // Don't bother broadcasting if we just need the 0'th element. if (DemandedElts == 1) { if (Src.getValueType() != VT) @@ -38060,6 +38060,33 @@ bool X86TargetLowering::SimplifyDemandedVectorEltsForTargetNode( ExtSizeInBits = SizeInBits / 4; switch (Opc) { + // Scalar broadcast. +case X86ISD::VBROADCAST: { + SDLoc DL(Op); + SDValue Src = Op.getOperand(0); + if (Src.getValueSizeInBits() > ExtSizeInBits) +Src = extractSubVector(Src, 0, TLO.DAG, DL, ExtSizeInBits); + EVT BcstVT = EVT::getVectorVT(*TLO.DAG.getContext(), VT.getScalarType(), +ExtSizeInBits / VT.getScalarSizeInBits()); + SDValue Bcst = TLO.DAG.getNode(X86ISD::VBROADCAST, DL, BcstVT, Src); + return TLO.CombineTo(Op, insertSubVector(TLO.DAG.getUNDEF(VT), Bcst, 0, + TLO.DAG, DL, ExtSizeInBits)); +} +case X86ISD::VBROADCAST_LOAD: { + SDLoc DL(Op); + auto *MemIntr = cast(Op); + EVT BcstVT = EVT::getVectorVT(*TLO.DAG.getContext(), VT.getScalarType(), +ExtSizeInBits / VT.getScalarSizeInBits()); + SDVTList Tys = TLO.DAG.getVTList(BcstVT, MVT::Other); + SDValue Ops[] = {MemIntr->getOperand(0), MemIntr->getOperand(1)}; + SDValue Bcst = TLO.DAG.getMemIntrinsicNode( + X86ISD::VBROADCAST_LOAD, DL, Tys, Ops, MemIntr->getMemoryVT(), + MemIntr->getMemOperand()); + TLO.DAG.makeEquivalentMemoryOrdering(SDValue(MemIntr, 1), + Bcst.getValue(1)); + return TLO.CombineTo(Op, insertSubVector(TLO.DAG.getUNDEF(VT), Bcst, 0, + TLO.DAG, DL, ExtSizeInBits)); +} // Subvector broadcast. case X86ISD::SUBV_BROADCAST: { SDLoc DL(Op); @@ -49365,27 +49392,6 @@ static SDValue combineExtractSubvector(SDNode *N, SelectionDAG &DAG, InVec.getOperand(1), InVec.getOperand(2)); } - // If we're extracting from a broadcast then we're better off just - // broadcasting to the smaller type directly, assuming this is the only use. - // As its a broadcast we don't care about the extraction index. - if (InVec.getOpcode() == X86ISD::VBROADCAST && InVec.hasOneUse() && - InVec.getOperand(0).getValueSizeInBits() <= SizeInBits) -return DAG.getNode(X86ISD::VBROADCAST, SDLoc(N), VT, InVec.getOperand(0)); - - if (InVec.getOpcode() == X86ISD::VBROADCAST_LOAD && InVec.hasOneUse()) { -auto *MemIntr = cast(InVec); -if (MemIntr->getMemoryVT().getSizeInBits() <= SizeInBits) { - SDVTList Tys = DAG.getVTList(VT, MVT::Other); - SDValue Ops[] = {MemIntr->getChain(), MemIntr->getBasePtr()}; - SDValue BcastLd = - DAG.getMemIntrinsicNode(X86ISD::VBROADCAST_LOAD, SDLoc(N), Tys, Ops, - MemIntr->getMemoryVT(), - MemIntr->getMemOperand()); - DAG.ReplaceAllUsesOfValueWith(SDValue(MemIntr, 1), BcastLd.getValue(1)); - return BcastLd; -} - } - // If we're extracting an upper subvector from a broadcast we should just // extract the lowest subvector instead which should allow // SimplifyDemandedVectorElts do more simplifications. diff --git a/llvm/test/CodeGen/X86/avx512-shuffles/partial_permute.ll b/llvm/test/CodeGen/X86/avx512-shuffles/partial_permute.ll index 58fd4c9c586c..29ea4d3bf55d 100644 --- a/llvm/test/CodeGen/X86/avx512-shuffles/partial_permute.ll +++ b/llvm/test/CodeGen/X86/avx512-shuffles/partial_perm
[llvm-branch-commits] [llvm] 52e4084 - [SVE][CodeGen] Vector + immediate addressing mode for masked gather/scatter
Author: Kerry McLaughlin Date: 2020-12-18T11:56:36Z New Revision: 52e4084d9c3b15dbb73906f28f7f5aa45b835b64 URL: https://github.com/llvm/llvm-project/commit/52e4084d9c3b15dbb73906f28f7f5aa45b835b64 DIFF: https://github.com/llvm/llvm-project/commit/52e4084d9c3b15dbb73906f28f7f5aa45b835b64.diff LOG: [SVE][CodeGen] Vector + immediate addressing mode for masked gather/scatter This patch extends LowerMGATHER/MSCATTER to make use of the vector + reg/immediate addressing modes for scalable masked gathers & scatters. selectGatherScatterAddrMode checks if the base pointer is null, in which case we can swap the base pointer and the index, e.g. getelementptr nullptr, (splat(%offset)) + %indices) -> getelementptr %offset, %indices Reviewed By: david-arm Differential Revision: https://reviews.llvm.org/D93132 Added: llvm/test/CodeGen/AArch64/sve-masked-gather-vec-plus-imm.ll llvm/test/CodeGen/AArch64/sve-masked-gather-vec-plus-reg.ll llvm/test/CodeGen/AArch64/sve-masked-gather.ll llvm/test/CodeGen/AArch64/sve-masked-scatter-vec-plus-imm.ll llvm/test/CodeGen/AArch64/sve-masked-scatter-vec-plus-reg.ll llvm/test/CodeGen/AArch64/sve-masked-scatter.ll Modified: llvm/lib/Target/AArch64/AArch64ISelLowering.cpp llvm/test/CodeGen/AArch64/sve-masked-gather-legalize.ll Removed: diff --git a/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp b/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp index 9eeacc8df0bf..43db745d6328 100644 --- a/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp +++ b/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp @@ -3812,6 +3812,8 @@ unsigned getSignExtendedGatherOpcode(unsigned Opcode) { return Opcode; case AArch64ISD::GLD1_MERGE_ZERO: return AArch64ISD::GLD1S_MERGE_ZERO; + case AArch64ISD::GLD1_IMM_MERGE_ZERO: +return AArch64ISD::GLD1S_IMM_MERGE_ZERO; case AArch64ISD::GLD1_UXTW_MERGE_ZERO: return AArch64ISD::GLD1S_UXTW_MERGE_ZERO; case AArch64ISD::GLD1_SXTW_MERGE_ZERO: @@ -3843,6 +3845,60 @@ bool getGatherScatterIndexIsExtended(SDValue Index) { return false; } +// If the base pointer of a masked gather or scatter is null, we +// may be able to swap BasePtr & Index and use the vector + register +// or vector + immediate addressing mode, e.g. +// VECTOR + REGISTER: +//getelementptr nullptr, (splat(%offset)) + %indices) +// -> getelementptr %offset, %indices +// VECTOR + IMMEDIATE: +//getelementptr nullptr, (splat(#x)) + %indices) +// -> getelementptr #x, %indices +void selectGatherScatterAddrMode(SDValue &BasePtr, SDValue &Index, EVT MemVT, + unsigned &Opcode, bool IsGather, + SelectionDAG &DAG) { + if (!isNullConstant(BasePtr)) +return; + + ConstantSDNode *Offset = nullptr; + if (Index.getOpcode() == ISD::ADD) +if (auto SplatVal = DAG.getSplatValue(Index.getOperand(1))) { + if (isa(SplatVal)) +Offset = cast(SplatVal); + else { +BasePtr = SplatVal; +Index = Index->getOperand(0); +return; + } +} + + unsigned NewOp = + IsGather ? AArch64ISD::GLD1_IMM_MERGE_ZERO : AArch64ISD::SST1_IMM_PRED; + + if (!Offset) { +std::swap(BasePtr, Index); +Opcode = NewOp; +return; + } + + uint64_t OffsetVal = Offset->getZExtValue(); + unsigned ScalarSizeInBytes = MemVT.getScalarSizeInBits() / 8; + auto ConstOffset = DAG.getConstant(OffsetVal, SDLoc(Index), MVT::i64); + + if (OffsetVal % ScalarSizeInBytes || OffsetVal / ScalarSizeInBytes > 31) { +// Index is out of range for the immediate addressing mode +BasePtr = ConstOffset; +Index = Index->getOperand(0); +return; + } + + // Immediate is in range + Opcode = NewOp; + BasePtr = Index->getOperand(0); + Index = ConstOffset; + return; +} + SDValue AArch64TargetLowering::LowerMGATHER(SDValue Op, SelectionDAG &DAG) const { SDLoc DL(Op); @@ -3892,6 +3948,9 @@ SDValue AArch64TargetLowering::LowerMGATHER(SDValue Op, Index = Index.getOperand(0); unsigned Opcode = getGatherVecOpcode(IsScaled, IsSigned, IdxNeedsExtend); + selectGatherScatterAddrMode(BasePtr, Index, MemVT, Opcode, + /*isGather=*/true, DAG); + if (ResNeedsSignExtend) Opcode = getSignExtendedGatherOpcode(Opcode); @@ -3944,9 +4003,12 @@ SDValue AArch64TargetLowering::LowerMSCATTER(SDValue Op, if (getGatherScatterIndexIsExtended(Index)) Index = Index.getOperand(0); + unsigned Opcode = getScatterVecOpcode(IsScaled, IsSigned, NeedsExtend); + selectGatherScatterAddrMode(BasePtr, Index, MemVT, Opcode, + /*isGather=*/false, DAG); + SDValue Ops[] = {Chain, StoreVal, Mask, BasePtr, Index, InputVT}; - return DAG.getNode(getScatterVecOpcode(IsScaled, IsSigned, NeedsExtend), DL, - VTs, Ops); + return DAG.getNode(Opcode, D
[llvm-branch-commits] [lldb] c15c296 - [lldb/test] Reduce boilerplate in lldb-server tests
Author: Pavel Labath Date: 2020-12-18T13:01:42+01:00 New Revision: c15c29652118292c389d5f9fde1b11b55c248cd9 URL: https://github.com/llvm/llvm-project/commit/c15c29652118292c389d5f9fde1b11b55c248cd9 DIFF: https://github.com/llvm/llvm-project/commit/c15c29652118292c389d5f9fde1b11b55c248cd9.diff LOG: [lldb/test] Reduce boilerplate in lldb-server tests Nearly all of our lldb-server tests have two flavours (lldb-server and debugserver). Each of them is tagged with an appropriate decorator, and each of them starts with a call to a matching "init" method. The init calls are mandatory, and it's not possible to meaningfully combine them with a different decorator. This patch leverages the existing decorators to also tag the tests with the appropriate debug server tag, similar to how we do with debug info flavours. This allows us to make the "init" calls from inside the common setUp method. Added: Modified: lldb/packages/Python/lldbsuite/test/decorators.py lldb/packages/Python/lldbsuite/test/tools/lldb-server/gdbremote_testcase.py lldb/test/API/commands/target/auto-install-main-executable/TestAutoInstallMainExecutable.py lldb/test/API/tools/lldb-server/TestAppleSimulatorOSType.py lldb/test/API/tools/lldb-server/TestGdbRemoteAttach.py lldb/test/API/tools/lldb-server/TestGdbRemoteAuxvSupport.py lldb/test/API/tools/lldb-server/TestGdbRemoteExitCode.py lldb/test/API/tools/lldb-server/TestGdbRemoteExpeditedRegisters.py lldb/test/API/tools/lldb-server/TestGdbRemoteHostInfo.py lldb/test/API/tools/lldb-server/TestGdbRemoteKill.py lldb/test/API/tools/lldb-server/TestGdbRemoteModuleInfo.py lldb/test/API/tools/lldb-server/TestGdbRemoteProcessInfo.py lldb/test/API/tools/lldb-server/TestGdbRemoteRegisterState.py lldb/test/API/tools/lldb-server/TestGdbRemoteSingleStep.py lldb/test/API/tools/lldb-server/TestGdbRemoteThreadsInStopReply.py lldb/test/API/tools/lldb-server/TestGdbRemote_qThreadStopInfo.py lldb/test/API/tools/lldb-server/TestGdbRemote_vCont.py lldb/test/API/tools/lldb-server/TestGdbRemote_vContThreads.py lldb/test/API/tools/lldb-server/TestLldbGdbServer.py lldb/test/API/tools/lldb-server/commandline/TestGdbRemoteConnection.py lldb/test/API/tools/lldb-server/commandline/TestStubSetSID.py lldb/test/API/tools/lldb-server/inferior-crash/TestGdbRemoteAbort.py lldb/test/API/tools/lldb-server/inferior-crash/TestGdbRemoteSegFault.py lldb/test/API/tools/lldb-server/libraries-svr4/TestGdbRemoteLibrariesSvr4Support.py lldb/test/API/tools/lldb-server/memory-allocation/TestGdbRemoteMemoryAllocation.py lldb/test/API/tools/lldb-server/platform-process-connect/TestPlatformProcessConnect.py lldb/test/API/tools/lldb-server/register-reading/TestGdbRemoteGPacket.py lldb/test/API/tools/lldb-server/registers-target-xml-reading/TestGdbRemoteTargetXmlPacket.py lldb/test/API/tools/lldb-server/signal-filtering/TestGdbRemote_QPassSignals.py lldb/test/API/tools/lldb-server/thread-name/TestGdbRemoteThreadName.py Removed: diff --git a/lldb/packages/Python/lldbsuite/test/decorators.py b/lldb/packages/Python/lldbsuite/test/decorators.py index ff445fa0b926..a17cd6ea33ab 100644 --- a/lldb/packages/Python/lldbsuite/test/decorators.py +++ b/lldb/packages/Python/lldbsuite/test/decorators.py @@ -373,11 +373,13 @@ def should_skip_simulator_test(): def debugserver_test(func): """Decorate the item as a debugserver test.""" +func.debug_server = "debugserver" return add_test_categories(["debugserver"])(func) def llgs_test(func): """Decorate the item as a lldb-server test.""" +func.debug_server = "llgs" return add_test_categories(["llgs"])(func) diff --git a/lldb/packages/Python/lldbsuite/test/tools/lldb-server/gdbremote_testcase.py b/lldb/packages/Python/lldbsuite/test/tools/lldb-server/gdbremote_testcase.py index b578aae12062..03cf2d4ab981 100644 --- a/lldb/packages/Python/lldbsuite/test/tools/lldb-server/gdbremote_testcase.py +++ b/lldb/packages/Python/lldbsuite/test/tools/lldb-server/gdbremote_testcase.py @@ -80,6 +80,10 @@ def isVerboseLoggingRequested(self): return any(("gdb-remote" in channel) for channel in lldbtest_config.channels) +def getDebugServer(self): +method = getattr(self, self.testMethodName) +return getattr(method, "debug_server", None) + def setUp(self): super(GdbRemoteTestCaseBase, self).setUp() @@ -114,6 +118,12 @@ def setUp(self): else: self.stub_hostname = "localhost" +debug_server = self.getDebugServer() +if debug_server == "debugserver": +self._init_debugserver_test() +else: +self._init_llgs_test() + def tearDown(self): self.logger.removeHandler(self._verbose_log_handler) self._verbose_log_handler = No
[llvm-branch-commits] [clang-tools-extra] e35f922 - [clangd] Ignore the static index refs from the dynamic index files.
Author: Aleksandr Platonov Date: 2020-12-18T15:36:30+03:00 New Revision: e35f9229dcb264be4a0a1ecf5cca2493f2c48878 URL: https://github.com/llvm/llvm-project/commit/e35f9229dcb264be4a0a1ecf5cca2493f2c48878 DIFF: https://github.com/llvm/llvm-project/commit/e35f9229dcb264be4a0a1ecf5cca2493f2c48878.diff LOG: [clangd] Ignore the static index refs from the dynamic index files. This patch fixes the following problem: - open a file with references to the symbol `Foo` - remove all references to `Foo` (from the dynamic index). - `MergedIndex::refs()` result will contain positions of removed references (from the static index). The idea of this patch is to keep a set of files which were used during index build inside the index. Thus at processing the static index references we can check if the file of processing reference is a part of the dynamic index or not. Reviewed By: sammccall Differential Revision: https://reviews.llvm.org/D93393 Added: Modified: clang-tools-extra/clangd/index/FileIndex.cpp clang-tools-extra/clangd/index/Index.cpp clang-tools-extra/clangd/index/Index.h clang-tools-extra/clangd/index/MemIndex.cpp clang-tools-extra/clangd/index/MemIndex.h clang-tools-extra/clangd/index/Merge.cpp clang-tools-extra/clangd/index/Merge.h clang-tools-extra/clangd/index/ProjectAware.cpp clang-tools-extra/clangd/index/dex/Dex.cpp clang-tools-extra/clangd/index/dex/Dex.h clang-tools-extra/clangd/index/remote/Client.cpp clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp clang-tools-extra/clangd/unittests/DexTests.cpp clang-tools-extra/clangd/unittests/IndexTests.cpp clang-tools-extra/clangd/unittests/RenameTests.cpp clang-tools-extra/clangd/unittests/TestFS.cpp Removed: diff --git a/clang-tools-extra/clangd/index/FileIndex.cpp b/clang-tools-extra/clangd/index/FileIndex.cpp index 1ccfb4485638..143e76863777 100644 --- a/clang-tools-extra/clangd/index/FileIndex.cpp +++ b/clang-tools-extra/clangd/index/FileIndex.cpp @@ -266,11 +266,14 @@ FileSymbols::buildIndex(IndexType Type, DuplicateHandling DuplicateHandle, std::vector> SymbolSlabs; std::vector> RefSlabs; std::vector> RelationSlabs; + llvm::StringSet<> Files; std::vector MainFileRefs; { std::lock_guard Lock(Mutex); -for (const auto &FileAndSymbols : SymbolsSnapshot) +for (const auto &FileAndSymbols : SymbolsSnapshot) { SymbolSlabs.push_back(FileAndSymbols.second); + Files.insert(FileAndSymbols.first()); +} for (const auto &FileAndRefs : RefsSnapshot) { RefSlabs.push_back(FileAndRefs.second.Slab); if (FileAndRefs.second.CountReferences) @@ -372,14 +375,14 @@ FileSymbols::buildIndex(IndexType Type, DuplicateHandling DuplicateHandle, case IndexType::Light: return std::make_unique( llvm::make_pointee_range(AllSymbols), std::move(AllRefs), -std::move(AllRelations), +std::move(AllRelations), std::move(Files), std::make_tuple(std::move(SymbolSlabs), std::move(RefSlabs), std::move(RefsStorage), std::move(SymsStorage)), StorageSize); case IndexType::Heavy: return std::make_unique( llvm::make_pointee_range(AllSymbols), std::move(AllRefs), -std::move(AllRelations), +std::move(AllRelations), std::move(Files), std::make_tuple(std::move(SymbolSlabs), std::move(RefSlabs), std::move(RefsStorage), std::move(SymsStorage)), StorageSize); diff --git a/clang-tools-extra/clangd/index/Index.cpp b/clang-tools-extra/clangd/index/Index.cpp index b309053972eb..5da06f36ffe4 100644 --- a/clang-tools-extra/clangd/index/Index.cpp +++ b/clang-tools-extra/clangd/index/Index.cpp @@ -76,6 +76,11 @@ void SwapIndex::relations( return snapshot()->relations(R, CB); } +llvm::unique_function +SwapIndex::indexedFiles() const { + return snapshot()->indexedFiles(); +} + size_t SwapIndex::estimateMemoryUsage() const { return snapshot()->estimateMemoryUsage(); } diff --git a/clang-tools-extra/clangd/index/Index.h b/clang-tools-extra/clangd/index/Index.h index f0959e71d50f..c961aa9d8bd9 100644 --- a/clang-tools-extra/clangd/index/Index.h +++ b/clang-tools-extra/clangd/index/Index.h @@ -14,6 +14,7 @@ #include "Symbol.h" #include "SymbolID.h" #include "llvm/ADT/DenseSet.h" +#include "llvm/ADT/FunctionExtras.h" #include "llvm/ADT/Optional.h" #include "llvm/ADT/StringExtras.h" #include "llvm/Support/JSON.h" @@ -121,6 +122,11 @@ class SymbolIndex { llvm::function_ref Callback) const = 0; + /// Returns function which checks if the specified file was used to build this + /// index or not. The function must only be called while the index is alive. + virtual llvm::unique_function + indexedFiles() const = 0; + /// Returns estimated size of index (in bytes). virtual size_t estimateM
[llvm-branch-commits] [clang-tools-extra] e69e551 - new altera single work item barrier check
Author: Frank Derry Wanye Date: 2020-12-18T07:52:20-05:00 New Revision: e69e551e0e5fddffb6479da6a2998457104ba9e6 URL: https://github.com/llvm/llvm-project/commit/e69e551e0e5fddffb6479da6a2998457104ba9e6 DIFF: https://github.com/llvm/llvm-project/commit/e69e551e0e5fddffb6479da6a2998457104ba9e6.diff LOG: new altera single work item barrier check This lint check is a part of the FLOCL (FPGA Linters for OpenCL) project out of the Synergy Lab at Virginia Tech. FLOCL is a set of lint checks aimed at FPGA developers who write code in OpenCL. The altera single work item barrier check finds OpenCL kernel functions that call a barrier function but do not call an ID function. These kernel functions will be treated as single work-item kernels, which could be inefficient or lead to errors. Based on the "Altera SDK for OpenCL: Best Practices Guide." Added: clang-tools-extra/clang-tidy/altera/SingleWorkItemBarrierCheck.cpp clang-tools-extra/clang-tidy/altera/SingleWorkItemBarrierCheck.h clang-tools-extra/docs/clang-tidy/checks/altera-single-work-item-barrier.rst clang-tools-extra/test/clang-tidy/checkers/altera-single-work-item-barrier.cpp Modified: clang-tools-extra/clang-tidy/altera/AlteraTidyModule.cpp clang-tools-extra/clang-tidy/altera/CMakeLists.txt clang-tools-extra/docs/ReleaseNotes.rst clang-tools-extra/docs/clang-tidy/checks/list.rst Removed: diff --git a/clang-tools-extra/clang-tidy/altera/AlteraTidyModule.cpp b/clang-tools-extra/clang-tidy/altera/AlteraTidyModule.cpp index d3e906b673ce..a328f05da5d0 100644 --- a/clang-tools-extra/clang-tidy/altera/AlteraTidyModule.cpp +++ b/clang-tools-extra/clang-tidy/altera/AlteraTidyModule.cpp @@ -10,6 +10,7 @@ #include "../ClangTidyModule.h" #include "../ClangTidyModuleRegistry.h" #include "KernelNameRestrictionCheck.h" +#include "SingleWorkItemBarrierCheck.h" #include "StructPackAlignCheck.h" using namespace clang::ast_matchers; @@ -23,6 +24,8 @@ class AlteraModule : public ClangTidyModule { void addCheckFactories(ClangTidyCheckFactories &CheckFactories) override { CheckFactories.registerCheck( "altera-kernel-name-restriction"); +CheckFactories.registerCheck( +"altera-single-work-item-barrier"); CheckFactories.registerCheck( "altera-struct-pack-align"); } diff --git a/clang-tools-extra/clang-tidy/altera/CMakeLists.txt b/clang-tools-extra/clang-tidy/altera/CMakeLists.txt index 8ab5cc1aa4ad..0765b9735cf9 100644 --- a/clang-tools-extra/clang-tidy/altera/CMakeLists.txt +++ b/clang-tools-extra/clang-tidy/altera/CMakeLists.txt @@ -6,6 +6,7 @@ set(LLVM_LINK_COMPONENTS add_clang_library(clangTidyAlteraModule AlteraTidyModule.cpp KernelNameRestrictionCheck.cpp + SingleWorkItemBarrierCheck.cpp StructPackAlignCheck.cpp LINK_LIBS diff --git a/clang-tools-extra/clang-tidy/altera/SingleWorkItemBarrierCheck.cpp b/clang-tools-extra/clang-tidy/altera/SingleWorkItemBarrierCheck.cpp new file mode 100644 index ..759c81c34ca6 --- /dev/null +++ b/clang-tools-extra/clang-tidy/altera/SingleWorkItemBarrierCheck.cpp @@ -0,0 +1,84 @@ +//===--- SingleWorkItemBarrierCheck.cpp - clang-tidy---===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===--===// + +#include "SingleWorkItemBarrierCheck.h" +#include "clang/AST/ASTContext.h" +#include "clang/ASTMatchers/ASTMatchFinder.h" + +using namespace clang::ast_matchers; + +namespace clang { +namespace tidy { +namespace altera { + +void SingleWorkItemBarrierCheck::registerMatchers(MatchFinder *Finder) { + // Find any function that calls barrier but does not call an ID function. + // hasAttr(attr::Kind::OpenCLKernel) restricts it to only kernel functions. + // FIXME: Have it accept all functions but check for a parameter that gets an + // ID from one of the four ID functions. + Finder->addMatcher( + // Find function declarations... + functionDecl( + allOf( + // That are OpenCL kernels... + hasAttr(attr::Kind::OpenCLKernel), + // And call a barrier function (either 1.x or 2.x version)... + forEachDescendant(callExpr(callee(functionDecl(hasAnyName( + "barrier", "work_group_barrier" +.bind("barrier")), + // But do not call an ID function. + unless(hasDescendant(callExpr(callee(functionDecl( + hasAnyName("get_global_id", "get_local_id", "get_group_id", + "get_local_linear_id" + .bind("function"), + this); +} + +void SingleWorkItemBarrie
[llvm-branch-commits] [lldb] 430d5d8 - [LLDB] Unbreak the build after recent clang changes
Author: David Zarzycki Date: 2020-12-18T07:54:36-05:00 New Revision: 430d5d8429473c2b10b109991d7577a3cea41140 URL: https://github.com/llvm/llvm-project/commit/430d5d8429473c2b10b109991d7577a3cea41140 DIFF: https://github.com/llvm/llvm-project/commit/430d5d8429473c2b10b109991d7577a3cea41140.diff LOG: [LLDB] Unbreak the build after recent clang changes 9e08e51a20d0d2b1c5724bb17e969d036fced4cd introduced a new enum case. Added: Modified: lldb/include/lldb/lldb-enumerations.h lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp Removed: diff --git a/lldb/include/lldb/lldb-enumerations.h b/lldb/include/lldb/lldb-enumerations.h index 2679ee52136d..ff4e15e7e070 100644 --- a/lldb/include/lldb/lldb-enumerations.h +++ b/lldb/include/lldb/lldb-enumerations.h @@ -816,6 +816,7 @@ enum TemplateArgumentKind { eTemplateArgumentKindExpression, eTemplateArgumentKindPack, eTemplateArgumentKindNullPtr, + eTemplateArgumentKindUncommonValue, }; /// Options that can be set for a formatter to alter its behavior. Not diff --git a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp index 643ea7e02206..894faa847450 100644 --- a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp +++ b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp @@ -6981,6 +6981,9 @@ TypeSystemClang::GetTemplateArgumentKind(lldb::opaque_compiler_type_t type, case clang::TemplateArgument::Pack: return eTemplateArgumentKindPack; + + case clang::TemplateArgument::UncommonValue: +return eTemplateArgumentKindUncommonValue; } llvm_unreachable("Unhandled clang::TemplateArgument::ArgKind"); } ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [clang] 2d2498e - No longer reject tag declarations in the clause-1 of a for loop.
Author: Aaron Ballman Date: 2020-12-18T07:56:17-05:00 New Revision: 2d2498ec6c42b12eae873257e6ddcefe8348 URL: https://github.com/llvm/llvm-project/commit/2d2498ec6c42b12eae873257e6ddcefe8348 DIFF: https://github.com/llvm/llvm-project/commit/2d2498ec6c42b12eae873257e6ddcefe8348.diff LOG: No longer reject tag declarations in the clause-1 of a for loop. We currently reject this valid C construct by claiming it declares a non-local variable: for (struct { int i; } s={0}; s.i != 0; s.i--) ; We expected all declaration in the clause-1 declaration statement to be a local VarDecl, but there can be other declarations involved such as a tag declaration. This fixes PR35757. Added: Modified: clang/lib/Sema/SemaStmt.cpp clang/test/Sema/for.c Removed: diff --git a/clang/lib/Sema/SemaStmt.cpp b/clang/lib/Sema/SemaStmt.cpp index d89dfaf78a9c..8d0ebe7e2409 100644 --- a/clang/lib/Sema/SemaStmt.cpp +++ b/clang/lib/Sema/SemaStmt.cpp @@ -1822,15 +1822,27 @@ StmtResult Sema::ActOnForStmt(SourceLocation ForLoc, SourceLocation LParenLoc, // C99 6.8.5p3: The declaration part of a 'for' statement shall only // declare identifiers for objects having storage class 'auto' or // 'register'. + const Decl *NonVarSeen = nullptr; + bool VarDeclSeen = false; for (auto *DI : DS->decls()) { -VarDecl *VD = dyn_cast(DI); -if (VD && VD->isLocalVarDecl() && !VD->hasLocalStorage()) - VD = nullptr; -if (!VD) { - Diag(DI->getLocation(), diag::err_non_local_variable_decl_in_for); - DI->setInvalidDecl(); +if (VarDecl *VD = dyn_cast(DI)) { + VarDeclSeen = true; + if (VD->isLocalVarDecl() && !VD->hasLocalStorage()) { +Diag(DI->getLocation(), diag::err_non_local_variable_decl_in_for); +DI->setInvalidDecl(); + } +} else if (!NonVarSeen) { + // Keep track of the first non-variable declaration we saw so that + // we can diagnose if we don't see any variable declarations. This + // covers a case like declaring a typedef, function, or structure + // type rather than a variable. + NonVarSeen = DI; } } + // Diagnose if we saw a non-variable declaration but no variable + // declarations. + if (NonVarSeen && !VarDeclSeen) +Diag(NonVarSeen->getLocation(), diag::err_non_variable_decl_in_for); } } diff --git a/clang/test/Sema/for.c b/clang/test/Sema/for.c index b998f4b07cf0..d0c2f7f21a96 100644 --- a/clang/test/Sema/for.c +++ b/clang/test/Sema/for.c @@ -2,6 +2,12 @@ // Check C99 6.8.5p3 void b1 (void) { for (void (*f) (void);;); } -void b2 (void) { for (void f (void);;); } // expected-error {{declaration of non-local variable}} +void b2 (void) { for (void f (void);;); } // expected-error {{non-variable declaration in 'for' loop}} void b3 (void) { for (static int f;;); }// expected-error {{declaration of non-local variable}} -void b4 (void) { for (typedef int f;;); } // expected-error {{declaration of non-local variable}} +void b4 (void) { for (typedef int f;;); } // expected-error {{non-variable declaration in 'for' loop}} +void b5 (void) { for (struct { int i; } s;;); } +void b6 (void) { for (enum { zero, ten = 10 } i;;); } +void b7 (void) { for (struct s { int i; };;); } // expected-error {{non-variable declaration in 'for' loop}} +void b8 (void) { for (static struct { int i; } s;;); } // expected-error {{declaration of non-local variable}} +void b9 (void) { for (struct { int i; } (*s)(struct { int j; } o) = 0;;); } +void b10(void) { for (typedef struct { int i; } (*s)(struct { int j; });;); } // expected-error {{non-variable declaration in 'for' loop}} ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [llvm] 07622b6 - [gn build] Port e69e551e0e5
Author: LLVM GN Syncbot Date: 2020-12-18T13:00:09Z New Revision: 07622b696f32a2080e0591e6e85b590d6a422cce URL: https://github.com/llvm/llvm-project/commit/07622b696f32a2080e0591e6e85b590d6a422cce DIFF: https://github.com/llvm/llvm-project/commit/07622b696f32a2080e0591e6e85b590d6a422cce.diff LOG: [gn build] Port e69e551e0e5 Added: Modified: llvm/utils/gn/secondary/clang-tools-extra/clang-tidy/altera/BUILD.gn Removed: diff --git a/llvm/utils/gn/secondary/clang-tools-extra/clang-tidy/altera/BUILD.gn b/llvm/utils/gn/secondary/clang-tools-extra/clang-tidy/altera/BUILD.gn index d46111bd6ed2d..dff088d817114 100644 --- a/llvm/utils/gn/secondary/clang-tools-extra/clang-tidy/altera/BUILD.gn +++ b/llvm/utils/gn/secondary/clang-tools-extra/clang-tidy/altera/BUILD.gn @@ -14,6 +14,7 @@ static_library("altera") { sources = [ "AlteraTidyModule.cpp", "KernelNameRestrictionCheck.cpp", +"SingleWorkItemBarrierCheck.cpp", "StructPackAlignCheck.cpp", ] } ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [llvm] c0bc169 - [NFC][SVE] Clean up bfloat isel patterns that emit non-bfloat instructions.
Author: Paul Walker Date: 2020-12-18T13:20:41Z New Revision: c0bc169cb17397e981952dad7321b263756ddaa0 URL: https://github.com/llvm/llvm-project/commit/c0bc169cb17397e981952dad7321b263756ddaa0 DIFF: https://github.com/llvm/llvm-project/commit/c0bc169cb17397e981952dad7321b263756ddaa0.diff LOG: [NFC][SVE] Clean up bfloat isel patterns that emit non-bfloat instructions. During isel there's no need to protect illegal types. Patch also adds a missing unit test for tbl2 intrinsic using bfloat types. Differential Revision: https://reviews.llvm.org/D93404 Added: Modified: llvm/lib/Target/AArch64/AArch64SVEInstrInfo.td llvm/lib/Target/AArch64/SVEInstrFormats.td llvm/test/CodeGen/AArch64/sve2-intrinsics-perm-tb.ll Removed: diff --git a/llvm/lib/Target/AArch64/AArch64SVEInstrInfo.td b/llvm/lib/Target/AArch64/AArch64SVEInstrInfo.td index fbe24460d51f..f28c55ae22e6 100644 --- a/llvm/lib/Target/AArch64/AArch64SVEInstrInfo.td +++ b/llvm/lib/Target/AArch64/AArch64SVEInstrInfo.td @@ -373,10 +373,6 @@ let Predicates = [HasSVE] in { defm CLZ_ZPmZ : sve_int_un_pred_arit_1< 0b001, "clz", int_aarch64_sve_clz>; defm CNT_ZPmZ : sve_int_un_pred_arit_1< 0b010, "cnt", int_aarch64_sve_cnt>; - let Predicates = [HasSVE, HasBF16] in { - def : SVE_3_Op_Pat(CNT_ZPmZ_H)>; - } - defm CNOT_ZPmZ : sve_int_un_pred_arit_1< 0b011, "cnot", int_aarch64_sve_cnot>; defm NOT_ZPmZ : sve_int_un_pred_arit_1< 0b110, "not", int_aarch64_sve_not>; defm FABS_ZPmZ : sve_int_un_pred_arit_1_fp<0b100, "fabs", AArch64fabs_mt>; @@ -514,11 +510,6 @@ let Predicates = [HasSVE] in { defm CPY_ZPmR : sve_int_perm_cpy_r<"cpy", AArch64dup_mt>; defm CPY_ZPmV : sve_int_perm_cpy_v<"cpy", AArch64dup_mt>; - let Predicates = [HasSVE, HasBF16] in { -def : Pat<(nxv8bf16 (AArch64dup_mt nxv8i1:$pg, bf16:$splat, nxv8bf16:$passthru)), - (CPY_ZPmV_H $passthru, $pg, $splat)>; - } - // Duplicate FP scalar into all vector elements def : Pat<(nxv8f16 (AArch64dup (f16 FPR16:$src))), (DUP_ZZI_H (INSERT_SUBREG (IMPLICIT_DEF), FPR16:$src, hsub), 0)>; @@ -532,10 +523,8 @@ let Predicates = [HasSVE] in { (DUP_ZZI_S (INSERT_SUBREG (IMPLICIT_DEF), FPR32:$src, ssub), 0)>; def : Pat<(nxv2f64 (AArch64dup (f64 FPR64:$src))), (DUP_ZZI_D (INSERT_SUBREG (IMPLICIT_DEF), FPR64:$src, dsub), 0)>; - let Predicates = [HasSVE, HasBF16] in { -def : Pat<(nxv8bf16 (AArch64dup (bf16 FPR16:$src))), - (DUP_ZZI_H (INSERT_SUBREG (IMPLICIT_DEF), FPR16:$src, hsub), 0)>; - } + def : Pat<(nxv8bf16 (AArch64dup (bf16 FPR16:$src))), +(DUP_ZZI_H (INSERT_SUBREG (IMPLICIT_DEF), FPR16:$src, hsub), 0)>; // Duplicate +0.0 into all vector elements def : Pat<(nxv8f16 (AArch64dup (f16 fpimm0))), (DUP_ZI_H 0, 0)>; @@ -544,9 +533,7 @@ let Predicates = [HasSVE] in { def : Pat<(nxv4f32 (AArch64dup (f32 fpimm0))), (DUP_ZI_S 0, 0)>; def : Pat<(nxv2f32 (AArch64dup (f32 fpimm0))), (DUP_ZI_S 0, 0)>; def : Pat<(nxv2f64 (AArch64dup (f64 fpimm0))), (DUP_ZI_D 0, 0)>; - let Predicates = [HasSVE, HasBF16] in { -def : Pat<(nxv8bf16 (AArch64dup (bf16 fpimm0))), (DUP_ZI_H 0, 0)>; - } + def : Pat<(nxv8bf16 (AArch64dup (bf16 fpimm0))), (DUP_ZI_H 0, 0)>; // Duplicate Int immediate into all vector elements def : Pat<(nxv16i8 (AArch64dup (i32 (SVE8BitLslImm i32:$a, i32:$b, @@ -579,20 +566,11 @@ let Predicates = [HasSVE] in { defm SPLICE_ZPZ : sve_int_perm_splice<"splice", int_aarch64_sve_splice>; - let Predicates = [HasSVE, HasBF16] in { -def : SVE_3_Op_Pat; -def : SVE_3_Op_Pat; - } - defm COMPACT_ZPZ : sve_int_perm_compact<"compact", int_aarch64_sve_compact>; defm INSR_ZR : sve_int_perm_insrs<"insr", AArch64insr>; defm INSR_ZV : sve_int_perm_insrv<"insr", AArch64insr>; defm EXT_ZZI : sve_int_perm_extract_i<"ext", AArch64ext>; - let Predicates = [HasSVE, HasBF16] in { -def : SVE_2_Op_Pat; - } - defm RBIT_ZPmZ : sve_int_perm_rev_rbit<"rbit", int_aarch64_sve_rbit>; defm REVB_ZPmZ : sve_int_perm_rev_revb<"revb", int_aarch64_sve_revb, bswap>; defm REVH_ZPmZ : sve_int_perm_rev_revh<"revh", int_aarch64_sve_revh>; @@ -601,10 +579,6 @@ let Predicates = [HasSVE] in { defm REV_PP : sve_int_perm_reverse_p<"rev", AArch64rev>; defm REV_ZZ : sve_int_perm_reverse_z<"rev", AArch64rev>; - let Predicates = [HasSVE, HasBF16] in { -def : SVE_1_Op_Pat; - } - defm SUNPKLO_ZZ : sve_int_perm_unpk<0b00, "sunpklo", AArch64sunpklo>; defm SUNPKHI_ZZ : sve_int_perm_unpk<0b01, "sunpkhi", AArch64sunpkhi>; defm UUNPKLO_ZZ : sve_int_perm_unpk<0b10, "uunpklo", AArch64uunpklo>; @@ -661,23 +635,11 @@ let Predicates = [HasSVE] in { defm CLASTA_ZPZ : sve_int_perm_clast_zz<0, "clasta", int_aarch64_sve_clasta>; defm CLASTB_ZPZ : sve_int_perm_clast_zz<1, "clastb", int_aarch64_sve_clastb>; - let Predicates = [HasSVE, HasBF16] in
[llvm-branch-commits] [llvm] fc712eb - [AArch64] Fix Copy Elemination for negative values
Author: Tomas Matheson Date: 2020-12-18T13:30:46Z New Revision: fc712eb7aa00aabcdafda54776038efdc486d570 URL: https://github.com/llvm/llvm-project/commit/fc712eb7aa00aabcdafda54776038efdc486d570 DIFF: https://github.com/llvm/llvm-project/commit/fc712eb7aa00aabcdafda54776038efdc486d570.diff LOG: [AArch64] Fix Copy Elemination for negative values Redundant Copy Elimination was eliminating a MOVi32imm -1 when it determined that the value of the destination register is already -1. However, it didn't take into account that the MOVi32imm zeroes the upper 32 bits (which are ) and therefore cannot be eliminated. Reviewed By: paulwalker-arm Differential Revision: https://reviews.llvm.org/D93100 Added: Modified: llvm/lib/Target/AArch64/AArch64RedundantCopyElimination.cpp llvm/test/CodeGen/AArch64/machine-copy-remove.mir Removed: diff --git a/llvm/lib/Target/AArch64/AArch64RedundantCopyElimination.cpp b/llvm/lib/Target/AArch64/AArch64RedundantCopyElimination.cpp index 0d75ab7ac8a9..019220e3a527 100644 --- a/llvm/lib/Target/AArch64/AArch64RedundantCopyElimination.cpp +++ b/llvm/lib/Target/AArch64/AArch64RedundantCopyElimination.cpp @@ -408,6 +408,11 @@ bool AArch64RedundantCopyElimination::optimizeBlock(MachineBasicBlock *MBB) { O.getReg() != CmpReg; })) continue; + +// Don't remove a move immediate that implicitly defines the upper +// bits as diff erent. +if (TRI->isSuperRegister(DefReg, KnownReg.Reg) && KnownReg.Imm < 0) + continue; } if (IsCopy) diff --git a/llvm/test/CodeGen/AArch64/machine-copy-remove.mir b/llvm/test/CodeGen/AArch64/machine-copy-remove.mir index 4e3cb3c12806..b2fc40a4d255 100644 --- a/llvm/test/CodeGen/AArch64/machine-copy-remove.mir +++ b/llvm/test/CodeGen/AArch64/machine-copy-remove.mir @@ -536,13 +536,13 @@ body: | bb.2: RET_ReallyLR ... -# Eliminate redundant MOVi32imm -1 in bb.1 +# Don't eliminate redundant MOVi32imm -1 in bb.1: the upper bits are nonzero. # Note: 64-bit compare/32-bit move imm # Kill marker should be removed from compare. # CHECK-LABEL: name: test21 -# CHECK: ADDSXri $x0, 1, 0, implicit-def $nzcv +# CHECK: ADDSXri killed $x0, 1, 0, implicit-def $nzcv # CHECK: bb.1: -# CHECK-NOT: MOVi32imm +# CHECK: MOVi32imm name:test21 tracksRegLiveness: true body: | ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [lld] 8590b5c - [libObject, llvm-readobj] - Reimplement `ELFFile::getEntry`.
Author: Georgii Rymar Date: 2020-12-18T16:52:27+03:00 New Revision: 8590b5ccd568764287ec5ed28567d0284ab9dbdb URL: https://github.com/llvm/llvm-project/commit/8590b5ccd568764287ec5ed28567d0284ab9dbdb DIFF: https://github.com/llvm/llvm-project/commit/8590b5ccd568764287ec5ed28567d0284ab9dbdb.diff LOG: [libObject, llvm-readobj] - Reimplement `ELFFile::getEntry`. Currently, `ELFFile::getEntry` does not check an index of an entry. Because of that the code might read past the end of the symbol table silently. I've added a test to `llvm-readobj\ELF\relocations.test` to demonstrate the possible issue. Also, I've added a unit test for this method. After this change, `getEntry` stops reporting the section index and reuses the `getSectionContentsAsArray` method, which already has all the validation needed. Our related warnings now provide more and better context sometimes. Differential revision: https://reviews.llvm.org/D93209 Added: Modified: lld/test/ELF/invalid/dynamic-section-broken.test llvm/include/llvm/Object/ELF.h llvm/test/Object/invalid.test llvm/test/tools/llvm-readobj/ELF/call-graph-profile.test llvm/test/tools/llvm-readobj/ELF/reloc-symbol-with-versioning.test llvm/test/tools/llvm-readobj/ELF/relocation-errors.test llvm/test/tools/llvm-readobj/ELF/relocations.test llvm/test/tools/llvm-readobj/ELF/relr-relocs.test llvm/test/tools/llvm-readobj/ELF/stack-sizes.test llvm/test/tools/llvm-readobj/ELF/symbols.test llvm/test/tools/llvm-readobj/ELF/versym-invalid.test llvm/test/tools/obj2yaml/ELF/dynamic-section.yaml llvm/test/tools/obj2yaml/ELF/rel-rela-section.yaml llvm/test/tools/yaml2obj/ELF/sht-symtab-shndx.yaml llvm/tools/llvm-readobj/ELFDumper.cpp llvm/unittests/Object/ELFObjectFileTest.cpp Removed: diff --git a/lld/test/ELF/invalid/dynamic-section-broken.test b/lld/test/ELF/invalid/dynamic-section-broken.test index 31317f632487..62f311470a2e 100644 --- a/lld/test/ELF/invalid/dynamic-section-broken.test +++ b/lld/test/ELF/invalid/dynamic-section-broken.test @@ -1,7 +1,7 @@ ## .dynamic section has invalid sh_entsize, check we report it. # RUN: yaml2obj --docnum=1 %s -o %t.so # RUN: not ld.lld %t.so -o /dev/null 2>&1 | FileCheck %s --check-prefix=ERR1 -# ERR1: error: {{.*}}.so: section [index 1] has an invalid sh_entsize: 291 +# ERR1: error: {{.*}}.so: section [index 1] has invalid sh_entsize: expected 16, but got 291 --- !ELF FileHeader: diff --git a/llvm/include/llvm/Object/ELF.h b/llvm/include/llvm/Object/ELF.h index efe518f93192..25f2df47781b 100644 --- a/llvm/include/llvm/Object/ELF.h +++ b/llvm/include/llvm/Object/ELF.h @@ -412,7 +412,8 @@ Expected> ELFFile::getSectionContentsAsArray(const Elf_Shdr &Sec) const { if (Sec.sh_entsize != sizeof(T) && sizeof(T) != 1) return createError("section " + getSecIndexForError(*this, Sec) + - " has an invalid sh_entsize: " + Twine(Sec.sh_entsize)); + " has invalid sh_entsize: expected " + Twine(sizeof(T)) + + ", but got " + Twine(Sec.sh_entsize)); uintX_t Offset = Sec.sh_offset; uintX_t Size = Sec.sh_size; @@ -618,17 +619,17 @@ template template Expected ELFFile::getEntry(const Elf_Shdr &Section, uint32_t Entry) const { - if (sizeof(T) != Section.sh_entsize) -return createError("section " + getSecIndexForError(*this, Section) + - " has invalid sh_entsize: expected " + Twine(sizeof(T)) + - ", but got " + Twine(Section.sh_entsize)); - uint64_t Pos = Section.sh_offset + (uint64_t)Entry * sizeof(T); - if (Pos + sizeof(T) > Buf.size()) -return createError("unable to access section " + - getSecIndexForError(*this, Section) + " data at 0x" + - Twine::utohexstr(Pos) + - ": offset goes past the end of file"); - return reinterpret_cast(base() + Pos); + Expected> EntriesOrErr = getSectionContentsAsArray(Section); + if (!EntriesOrErr) +return EntriesOrErr.takeError(); + + ArrayRef Arr = *EntriesOrErr; + if (Entry >= Arr.size()) +return createError("can't read an entry at 0x" + + Twine::utohexstr(Entry * sizeof(T)) + + ": it goes past the end of the section (0x" + + Twine::utohexstr(Section.sh_size) + ")"); + return &Arr[Entry]; } template diff --git a/llvm/test/Object/invalid.test b/llvm/test/Object/invalid.test index 57fb006351eb..95b677fae293 100644 --- a/llvm/test/Object/invalid.test +++ b/llvm/test/Object/invalid.test @@ -118,7 +118,7 @@ Symbols: # RUN: yaml2obj %s --docnum=6 -o %t6 # RUN: llvm-readobj --symbols %t6 2>&1 | FileCheck -DFILE=%t6 --check-prefix=INVALID-SYM-SIZE %s -# INVALID-SYM-SIZE: warning: '[[FILE]]': unable to read symbols from the SHT
[llvm-branch-commits] [clang-tools-extra] 0336ff0 - [clangd] Fix broken JSON test on windows
Author: Sam McCall Date: 2020-12-18T15:11:08+01:00 New Revision: 0336ff0a17e6aec831334aeb50e6685f6b184065 URL: https://github.com/llvm/llvm-project/commit/0336ff0a17e6aec831334aeb50e6685f6b184065 DIFF: https://github.com/llvm/llvm-project/commit/0336ff0a17e6aec831334aeb50e6685f6b184065.diff LOG: [clangd] Fix broken JSON test on windows Added: Modified: clang-tools-extra/clangd/unittests/GlobalCompilationDatabaseTests.cpp Removed: diff --git a/clang-tools-extra/clangd/unittests/GlobalCompilationDatabaseTests.cpp b/clang-tools-extra/clangd/unittests/GlobalCompilationDatabaseTests.cpp index d9fccb835c96..12c986572d8b 100644 --- a/clang-tools-extra/clangd/unittests/GlobalCompilationDatabaseTests.cpp +++ b/clang-tools-extra/clangd/unittests/GlobalCompilationDatabaseTests.cpp @@ -432,12 +432,13 @@ TEST_F(DirectoryBasedGlobalCompilationDatabaseCacheTest, Cacheable) { EXPECT_THAT(FooBar, hasFlag("-DFOOBAR")) << "cdb reloaded"; // compile_commands.json takes precedence over compile_flags.txt. - FS.Files["foo/compile_commands.json"] = llvm::formatv(R"json([{ + FS.Files["foo/compile_commands.json"] = + llvm::formatv(R"json([{ "file": "{0}/foo/dummy.cc", "command": "clang -DBAZ dummy.cc", "directory": "{0}/foo", }])json", -testRoot()); +llvm::sys::path::convert_to_slash(testRoot())); EXPECT_EQ(FooBar, lookupCDB(GDB, testPath("foo/test.cc"), Stale)) << "cache still valid"; auto Baz = lookupCDB(GDB, testPath("foo/test.cc"), Fresh); ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [llvm] 47aaa99 - [VectorCombine] allow peeking through GEPs when creating a vector load
Author: Sanjay Patel Date: 2020-12-18T09:25:03-05:00 New Revision: 47aaa99c0e1e28573bf24d95c5540005ee734531 URL: https://github.com/llvm/llvm-project/commit/47aaa99c0e1e28573bf24d95c5540005ee734531 DIFF: https://github.com/llvm/llvm-project/commit/47aaa99c0e1e28573bf24d95c5540005ee734531.diff LOG: [VectorCombine] allow peeking through GEPs when creating a vector load This is an enhancement motivated by https://llvm.org/PR16739 (see D92858 for another). We can look through a GEP to find a base pointer that may be safe to use for a vector load. If so, then we shuffle (shift) the necessary vector element over to index 0. Alive2 proof based on 1 of the regression tests: https://alive2.llvm.org/ce/z/yPJLkh The vector translation is independent of endian (verify by changing to leading 'E' in the datalayout string). Differential Revision: https://reviews.llvm.org/D93229 Added: Modified: llvm/lib/Transforms/Vectorize/VectorCombine.cpp llvm/test/Transforms/VectorCombine/X86/load.ll Removed: diff --git a/llvm/lib/Transforms/Vectorize/VectorCombine.cpp b/llvm/lib/Transforms/Vectorize/VectorCombine.cpp index 8e341619dcf4..a865f88cba74 100644 --- a/llvm/lib/Transforms/Vectorize/VectorCombine.cpp +++ b/llvm/lib/Transforms/Vectorize/VectorCombine.cpp @@ -93,6 +93,7 @@ static void replaceValue(Value &Old, Value &New) { bool VectorCombine::vectorizeLoadInsert(Instruction &I) { // Match insert into fixed vector of scalar value. + // TODO: Handle non-zero insert index. auto *Ty = dyn_cast(I.getType()); Value *Scalar; if (!Ty || !match(&I, m_InsertElt(m_Undef(), m_Value(Scalar), m_ZeroInt())) || @@ -115,7 +116,6 @@ bool VectorCombine::vectorizeLoadInsert(Instruction &I) { mustSuppressSpeculation(*Load)) return false; - // TODO: Extend this to match GEP with constant offsets. const DataLayout &DL = I.getModule()->getDataLayout(); Value *SrcPtr = Load->getPointerOperand()->stripPointerCasts(); assert(isa(SrcPtr->getType()) && "Expected a pointer type"); @@ -127,10 +127,13 @@ bool VectorCombine::vectorizeLoadInsert(Instruction &I) { if (AS != SrcPtr->getType()->getPointerAddressSpace()) SrcPtr = Load->getPointerOperand(); + // We are potentially transforming byte-sized (8-bit) memory accesses, so make + // sure we have all of our type-based constraints in place for this target. Type *ScalarTy = Scalar->getType(); uint64_t ScalarSize = ScalarTy->getPrimitiveSizeInBits(); unsigned MinVectorSize = TTI.getMinVectorRegisterBitWidth(); - if (!ScalarSize || !MinVectorSize || MinVectorSize % ScalarSize != 0) + if (!ScalarSize || !MinVectorSize || MinVectorSize % ScalarSize != 0 || + ScalarSize % 8 != 0) return false; // Check safety of replacing the scalar load with a larger vector load. @@ -139,12 +142,45 @@ bool VectorCombine::vectorizeLoadInsert(Instruction &I) { // we may use a larger value based on alignment attributes. unsigned MinVecNumElts = MinVectorSize / ScalarSize; auto *MinVecTy = VectorType::get(ScalarTy, MinVecNumElts, false); - if (!isSafeToLoadUnconditionally(SrcPtr, MinVecTy, Align(1), DL, Load, &DT)) -return false; + unsigned OffsetEltIndex = 0; + Align Alignment = Load->getAlign(); + if (!isSafeToLoadUnconditionally(SrcPtr, MinVecTy, Align(1), DL, Load, &DT)) { +// It is not safe to load directly from the pointer, but we can still peek +// through gep offsets and check if it safe to load from a base address with +// updated alignment. If it is, we can shuffle the element(s) into place +// after loading. +unsigned OffsetBitWidth = DL.getIndexTypeSizeInBits(SrcPtr->getType()); +APInt Offset(OffsetBitWidth, 0); +SrcPtr = SrcPtr->stripAndAccumulateInBoundsConstantOffsets(DL, Offset); + +// We want to shuffle the result down from a high element of a vector, so +// the offset must be positive. +if (Offset.isNegative()) + return false; + +// The offset must be a multiple of the scalar element to shuffle cleanly +// in the element's size. +uint64_t ScalarSizeInBytes = ScalarSize / 8; +if (Offset.urem(ScalarSizeInBytes) != 0) + return false; + +// If we load MinVecNumElts, will our target element still be loaded? +OffsetEltIndex = Offset.udiv(ScalarSizeInBytes).getZExtValue(); +if (OffsetEltIndex >= MinVecNumElts) + return false; + +if (!isSafeToLoadUnconditionally(SrcPtr, MinVecTy, Align(1), DL, Load, &DT)) + return false; + +// Update alignment with offset value. Note that the offset could be negated +// to more accurately represent "(new) SrcPtr - Offset = (old) SrcPtr", but +// negation does not change the result of the alignment calculation. +Alignment = commonAlignment(Alignment, Offset.getZExtValue()); + } // Original pattern: insertelt undef, load [free casts of] PtrOp, 0 // Use the grea
[llvm-branch-commits] [clang-tools-extra] c46c7c9 - [clangd] Smarter hover on auto and decltype
Author: Quentin Chateau Date: 2020-12-18T16:27:09+01:00 New Revision: c46c7c9bcf9752971fe4bbcf67140c99066ad2e0 URL: https://github.com/llvm/llvm-project/commit/c46c7c9bcf9752971fe4bbcf67140c99066ad2e0 DIFF: https://github.com/llvm/llvm-project/commit/c46c7c9bcf9752971fe4bbcf67140c99066ad2e0.diff LOG: [clangd] Smarter hover on auto and decltype Only show the keyword as the hover "Name". Show whether the type is deduced or undeduced as the hover "Documentation". Show the deduced type (if any) as the "Definition". Don't show any hover information for: - the "auto" word of "decltype(auto)" - "auto" in lambda parameters - "auto" in template arguments --- This diff is a suggestion based on what @sammccall suggested in https://reviews.llvm.org/D92977 about hover on "auto". It somehow "hacks" onto the "Documentation" and "Definition" fields of `HoverInfo`. It sure looks good on VSCode, let me know if this seem acceptable to you. Reviewed By: sammccall Differential Revision: https://reviews.llvm.org/D93227 Added: Modified: clang-tools-extra/clangd/AST.cpp clang-tools-extra/clangd/AST.h clang-tools-extra/clangd/Hover.cpp clang-tools-extra/clangd/refactor/tweaks/ExpandAutoType.cpp clang-tools-extra/clangd/unittests/HoverTests.cpp Removed: diff --git a/clang-tools-extra/clangd/AST.cpp b/clang-tools-extra/clangd/AST.cpp index b0c9ecab1e05..c5f87af86319 100644 --- a/clang-tools-extra/clangd/AST.cpp +++ b/clang-tools-extra/clangd/AST.cpp @@ -350,8 +350,7 @@ class DeducedTypeVisitor : public RecursiveASTVisitor { return true; if (auto *AT = D->getType()->getContainedAutoType()) { - if (!AT->getDeducedType().isNull()) -DeducedType = AT->getDeducedType(); + DeducedType = AT->desugar(); } return true; } diff --git a/clang-tools-extra/clangd/AST.h b/clang-tools-extra/clangd/AST.h index 1e3447376c10..b603964189e8 100644 --- a/clang-tools-extra/clangd/AST.h +++ b/clang-tools-extra/clangd/AST.h @@ -109,6 +109,7 @@ QualType declaredType(const TypeDecl *D); /// Retrieves the deduced type at a given location (auto, decltype). /// It will return the underlying type. +/// If the type is an undeduced auto, returns the type itself. llvm::Optional getDeducedType(ASTContext &, SourceLocation Loc); /// Gets the nested name specifier necessary for spelling \p ND in \p diff --git a/clang-tools-extra/clangd/Hover.cpp b/clang-tools-extra/clangd/Hover.cpp index e461c7c43364..b5eda93ddbbc 100644 --- a/clang-tools-extra/clangd/Hover.cpp +++ b/clang-tools-extra/clangd/Hover.cpp @@ -27,6 +27,7 @@ #include "clang/AST/ExprCXX.h" #include "clang/AST/OperationKinds.h" #include "clang/AST/PrettyPrinter.h" +#include "clang/AST/RecursiveASTVisitor.h" #include "clang/AST/Type.h" #include "clang/Basic/SourceLocation.h" #include "clang/Basic/Specifiers.h" @@ -550,29 +551,6 @@ HoverInfo getHoverContents(const NamedDecl *D, const SymbolIndex *Index) { return HI; } -/// Generate a \p Hover object given the type \p T. -HoverInfo getHoverContents(QualType T, ASTContext &ASTCtx, - const SymbolIndex *Index, - bool SuppressScope = false) { - HoverInfo HI; - - if (const auto *D = T->getAsTagDecl()) { -HI.Name = printName(ASTCtx, *D); -HI.Kind = index::getSymbolInfo(D).Kind; - -const auto *CommentD = getDeclForComment(D); -HI.Documentation = getDeclComment(ASTCtx, *CommentD); -enhanceFromIndex(HI, *CommentD, Index); - } else { -// Builtin types -auto Policy = printingPolicyForDecls(ASTCtx.getPrintingPolicy()); -Policy.SuppressTagKeyword = true; -Policy.SuppressScope = SuppressScope; -HI.Name = T.getAsString(Policy); - } - return HI; -} - /// Generate a \p Hover object given the macro \p MacroDecl. HoverInfo getHoverContents(const DefinedMacro &Macro, ParsedAST &AST) { HoverInfo HI; @@ -608,6 +586,52 @@ HoverInfo getHoverContents(const DefinedMacro &Macro, ParsedAST &AST) { return HI; } +llvm::Optional getThisExprHoverContents(const CXXThisExpr *CTE, + ASTContext &ASTCtx) { + QualType OriginThisType = CTE->getType()->getPointeeType(); + QualType ClassType = declaredType(OriginThisType->getAsTagDecl()); + // For partial specialization class, origin `this` pointee type will be + // parsed as `InjectedClassNameType`, which will ouput template arguments + // like "type-parameter-0-0". So we retrieve user written class type in this + // case. + QualType PrettyThisType = ASTCtx.getPointerType( + QualType(ClassType.getTypePtr(), OriginThisType.getCVRQualifiers())); + + auto Policy = printingPolicyForDecls(ASTCtx.getPrintingPolicy()); + Policy.SuppressTagKeyword = true; + Policy.SuppressScope = true; + HoverInfo HI; + HI.Name = "this"; + HI.Definition = PrettyThisType.getAsString(Poli
[llvm-branch-commits] [clang-tools-extra] 95c7b6c - [clangd] zap a few warnings
Author: Sam McCall Date: 2020-12-18T16:34:34+01:00 New Revision: 95c7b6cadbc9a3d4376ef44edbeb3c8bb5b8d7fc URL: https://github.com/llvm/llvm-project/commit/95c7b6cadbc9a3d4376ef44edbeb3c8bb5b8d7fc DIFF: https://github.com/llvm/llvm-project/commit/95c7b6cadbc9a3d4376ef44edbeb3c8bb5b8d7fc.diff LOG: [clangd] zap a few warnings Added: Modified: clang-tools-extra/clangd/DumpAST.cpp clang-tools-extra/clangd/FindTarget.cpp clang-tools-extra/clangd/index/remote/Client.cpp Removed: diff --git a/clang-tools-extra/clangd/DumpAST.cpp b/clang-tools-extra/clangd/DumpAST.cpp index 12698b42ef3e..8f1b3f3a1aae 100644 --- a/clang-tools-extra/clangd/DumpAST.cpp +++ b/clang-tools-extra/clangd/DumpAST.cpp @@ -143,6 +143,7 @@ class DumpVisitor : public RecursiveASTVisitor { TEMPLATE_ARGUMENT_KIND(Declaration); TEMPLATE_ARGUMENT_KIND(Template); TEMPLATE_ARGUMENT_KIND(TemplateExpansion); + TEMPLATE_ARGUMENT_KIND(UncommonValue); #undef TEMPLATE_ARGUMENT_KIND } llvm_unreachable("Unhandled ArgKind enum"); diff --git a/clang-tools-extra/clangd/FindTarget.cpp b/clang-tools-extra/clangd/FindTarget.cpp index 3afd65522680..c5c7d71be661 100644 --- a/clang-tools-extra/clangd/FindTarget.cpp +++ b/clang-tools-extra/clangd/FindTarget.cpp @@ -1069,6 +1069,7 @@ class ExplicitReferenceCollector case TemplateArgument::Pack: case TemplateArgument::Type: case TemplateArgument::Expression: +case TemplateArgument::UncommonValue: break; // Handled by VisitType and VisitExpression. }; return RecursiveASTVisitor::TraverseTemplateArgumentLoc(A); diff --git a/clang-tools-extra/clangd/index/remote/Client.cpp b/clang-tools-extra/clangd/index/remote/Client.cpp index b09dbf915e46..a153a8812baf 100644 --- a/clang-tools-extra/clangd/index/remote/Client.cpp +++ b/clang-tools-extra/clangd/index/remote/Client.cpp @@ -152,7 +152,8 @@ class IndexClient : public clangd::SymbolIndex { }); } - llvm::unique_function indexedFiles() const { + llvm::unique_function + indexedFiles() const override { // FIXME: For now we always return "false" regardless of whether the file //was indexed or not. A possible implementation could be based on //the idea that we do not want to send a request at every ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [flang] db2195b - [flang][driver] Rename unittest file (nfc)
Author: Andrzej Warzynski Date: 2020-12-18T15:35:45Z New Revision: db2195bc5b3e3ef60e840d5877a62871a369203c URL: https://github.com/llvm/llvm-project/commit/db2195bc5b3e3ef60e840d5877a62871a369203c DIFF: https://github.com/llvm/llvm-project/commit/db2195bc5b3e3ef60e840d5877a62871a369203c.diff LOG: [flang][driver] Rename unittest file (nfc) This patch renames PrintPreprocessedTest.cpp as FrontendActionTest.cpp. The latter reflects the contents of the file more accurately. Added: flang/unittests/Frontend/FrontendActionTest.cpp Modified: flang/unittests/Frontend/CMakeLists.txt Removed: flang/unittests/Frontend/PrintPreprocessedTest.cpp diff --git a/flang/unittests/Frontend/CMakeLists.txt b/flang/unittests/Frontend/CMakeLists.txt index 8ecdaf3ba9c7..fb8160bb023c 100644 --- a/flang/unittests/Frontend/CMakeLists.txt +++ b/flang/unittests/Frontend/CMakeLists.txt @@ -1,7 +1,7 @@ add_flang_unittest(FlangFrontendTests CompilerInstanceTest.cpp InputOutputTest.cpp - PrintPreprocessedTest.cpp + FrontendActionTest.cpp ) target_link_libraries(FlangFrontendTests diff --git a/flang/unittests/Frontend/PrintPreprocessedTest.cpp b/flang/unittests/Frontend/FrontendActionTest.cpp similarity index 100% rename from flang/unittests/Frontend/PrintPreprocessedTest.cpp rename to flang/unittests/Frontend/FrontendActionTest.cpp ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [llvm] 8767f3b - [X86][AVX] Remove X86ISD::SUBV_BROADCAST (PR38969)
Author: Simon Pilgrim Date: 2020-12-18T15:49:53Z New Revision: 8767f3bb972f5122ad2e914df13470219b68bac4 URL: https://github.com/llvm/llvm-project/commit/8767f3bb972f5122ad2e914df13470219b68bac4 DIFF: https://github.com/llvm/llvm-project/commit/8767f3bb972f5122ad2e914df13470219b68bac4.diff LOG: [X86][AVX] Remove X86ISD::SUBV_BROADCAST (PR38969) Followup to D92645 - remove the remaining places where we create X86ISD::SUBV_BROADCAST, and fold splatted vector loads to X86ISD::SUBV_BROADCAST_LOAD instead. Remove all the X86SubVBroadcast isel patterns, including all the fallbacks for if memory folding failed. Added: Modified: llvm/lib/Target/X86/X86ISelLowering.cpp llvm/lib/Target/X86/X86ISelLowering.h llvm/lib/Target/X86/X86InstrAVX512.td llvm/lib/Target/X86/X86InstrFragmentsSIMD.td llvm/lib/Target/X86/X86InstrSSE.td llvm/test/CodeGen/X86/avx-vbroadcastf128.ll llvm/test/CodeGen/X86/avx2-vbroadcasti128.ll llvm/test/CodeGen/X86/oddshuffles.ll llvm/test/CodeGen/X86/oddsubvector.ll llvm/test/CodeGen/X86/subvector-broadcast.ll llvm/test/CodeGen/X86/x86-upgrade-avx2-vbroadcast.ll Removed: diff --git a/llvm/lib/Target/X86/X86ISelLowering.cpp b/llvm/lib/Target/X86/X86ISelLowering.cpp index d4aa97a706ef..a8e18e0d06cf 100644 --- a/llvm/lib/Target/X86/X86ISelLowering.cpp +++ b/llvm/lib/Target/X86/X86ISelLowering.cpp @@ -8601,6 +8601,11 @@ static SDValue EltsFromConsecutiveLoads(EVT VT, ArrayRef Elts, if (!Subtarget.hasAVX2() && ScalarSize < 32) continue; + // Don't attempt a 1:N subvector broadcast - it should be caught by + // combineConcatVectorOps, else will cause infinite loops. + if (RepeatSize > ScalarSize && SubElems == 1) +continue; + bool Match = true; SmallVector RepeatedLoads(SubElems, DAG.getUNDEF(EltBaseVT)); for (unsigned i = 0; i != NumElems && Match; ++i) { @@ -8632,9 +8637,14 @@ static SDValue EltsFromConsecutiveLoads(EVT VT, ArrayRef Elts, if (TLI.isTypeLegal(BroadcastVT)) { if (SDValue RepeatLoad = EltsFromConsecutiveLoads( RepeatVT, RepeatedLoads, DL, DAG, Subtarget, isAfterLegalize)) { - unsigned Opcode = RepeatSize > ScalarSize ? X86ISD::SUBV_BROADCAST -: X86ISD::VBROADCAST; - SDValue Broadcast = DAG.getNode(Opcode, DL, BroadcastVT, RepeatLoad); + SDValue Broadcast = RepeatLoad; + if (RepeatSize > ScalarSize) { +while (Broadcast.getValueSizeInBits() < VT.getSizeInBits()) + Broadcast = concatSubVectors(Broadcast, Broadcast, DAG, DL); + } else { +Broadcast = +DAG.getNode(X86ISD::VBROADCAST, DL, BroadcastVT, RepeatLoad); + } return DAG.getBitcast(VT, Broadcast); } } @@ -30945,7 +30955,6 @@ const char *X86TargetLowering::getTargetNodeName(unsigned Opcode) const { NODE_NAME_CASE(VBROADCAST) NODE_NAME_CASE(VBROADCAST_LOAD) NODE_NAME_CASE(VBROADCASTM) - NODE_NAME_CASE(SUBV_BROADCAST) NODE_NAME_CASE(SUBV_BROADCAST_LOAD) NODE_NAME_CASE(VPERMILPV) NODE_NAME_CASE(VPERMILPI) @@ -38088,20 +38097,6 @@ bool X86TargetLowering::SimplifyDemandedVectorEltsForTargetNode( TLO.DAG, DL, ExtSizeInBits)); } // Subvector broadcast. -case X86ISD::SUBV_BROADCAST: { - SDLoc DL(Op); - SDValue Src = Op.getOperand(0); - if (Src.getValueSizeInBits() > ExtSizeInBits) -Src = extractSubVector(Src, 0, TLO.DAG, DL, ExtSizeInBits); - else if (Src.getValueSizeInBits() < ExtSizeInBits) { -MVT SrcSVT = Src.getSimpleValueType().getScalarType(); -MVT SrcVT = -MVT::getVectorVT(SrcSVT, ExtSizeInBits / SrcSVT.getSizeInBits()); -Src = TLO.DAG.getNode(X86ISD::SUBV_BROADCAST, DL, SrcVT, Src); - } - return TLO.CombineTo(Op, insertSubVector(TLO.DAG.getUNDEF(VT), Src, 0, - TLO.DAG, DL, ExtSizeInBits)); -} case X86ISD::SUBV_BROADCAST_LOAD: { auto *MemIntr = cast(Op); EVT MemVT = MemIntr->getMemoryVT(); @@ -48873,41 +48868,47 @@ static SDValue combineConcatVectorOps(const SDLoc &DL, MVT VT, SDValue Op0 = Ops[0]; bool IsSplat = llvm::all_of(Ops, [&Op0](SDValue Op) { return Op == Op0; }); - // Fold subvector loads into one. - // If needed, look through bitcasts to get to the load. - if (auto *FirstLd = dyn_cast(peekThroughBitcasts(Op0))) { -bool Fast; -const X86TargetLowering *TLI = Subtarget.getTargetLowering(); -if (TLI->allowsMemoryAccess(*DAG.getContext(), DAG.getDataLayout(), VT, -*FirstLd->getMemOperand(), &Fast) && -Fast) { - if (SDValue Ld = - EltsFromConsecutiveLoads(VT, Ops, DL, DAG, Subtarget, false)) -
[llvm-branch-commits] [llvm] 1a9577b - [AArch64] Add support for ls64 to the .arch_extension asm directive
Author: Lucas Prates Date: 2020-12-18T15:55:55Z New Revision: 1a9577bde1dd3dc25eac2a78fb685f37351004cb URL: https://github.com/llvm/llvm-project/commit/1a9577bde1dd3dc25eac2a78fb685f37351004cb DIFF: https://github.com/llvm/llvm-project/commit/1a9577bde1dd3dc25eac2a78fb685f37351004cb.diff LOG: [AArch64] Add support for ls64 to the .arch_extension asm directive This adds support for the 'ls64' AArch64 extension to the `.arch_extension` asm directive. Reviewed By: ostannard Differential Revision: https://reviews.llvm.org/D92574 Added: Modified: llvm/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp llvm/test/MC/AArch64/directive-arch_extension-negative.s llvm/test/MC/AArch64/directive-arch_extension.s Removed: diff --git a/llvm/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp b/llvm/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp index 069bb5e44f0e..26e093bf4ce7 100644 --- a/llvm/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp +++ b/llvm/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp @@ -2912,6 +2912,7 @@ static const struct Extension { {"sve2-sm4", {AArch64::FeatureSVE2SM4}}, {"sve2-sha3", {AArch64::FeatureSVE2SHA3}}, {"sve2-bitperm", {AArch64::FeatureSVE2BitPerm}}, +{"ls64", {AArch64::FeatureLS64}}, {"xs", {AArch64::FeatureXS}}, // FIXME: Unsupported extensions {"pan", {}}, diff --git a/llvm/test/MC/AArch64/directive-arch_extension-negative.s b/llvm/test/MC/AArch64/directive-arch_extension-negative.s index 8901247978a8..9d67abb80054 100644 --- a/llvm/test/MC/AArch64/directive-arch_extension-negative.s +++ b/llvm/test/MC/AArch64/directive-arch_extension-negative.s @@ -83,3 +83,8 @@ dc cvap, x7 ldapr x0, [x1] // CHECK: error: instruction requires: rcpc // CHECK-NEXT: ldapr x0, [x1] + +.arch_extension nols64 +ld64b x0, [x13] +// CHECK: error: instruction requires: ls64 +// CHECK-NEXT: ld64b x0, [x13] diff --git a/llvm/test/MC/AArch64/directive-arch_extension.s b/llvm/test/MC/AArch64/directive-arch_extension.s index 790bcf355475..a44b14ddeea2 100644 --- a/llvm/test/MC/AArch64/directive-arch_extension.s +++ b/llvm/test/MC/AArch64/directive-arch_extension.s @@ -67,3 +67,7 @@ dc cvap, x7 .arch_extension rcpc ldapr x0, [x1] // CHECK: ldapr x0, [x1] + +.arch_extension ls64 +ld64b x0, [x13] +// CHECK: ld64b x0, [x13] ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [llvm] 91593e4 - [AArch64] Updating .arch_extension negative tests
Author: Lucas Prates Date: 2020-12-18T15:57:11Z New Revision: 91593e461a24f355fa6138c2a7b136d1ec1d9d79 URL: https://github.com/llvm/llvm-project/commit/91593e461a24f355fa6138c2a7b136d1ec1d9d79 DIFF: https://github.com/llvm/llvm-project/commit/91593e461a24f355fa6138c2a7b136d1ec1d9d79.diff LOG: [AArch64] Updating .arch_extension negative tests This updates the test for the `.arch_extension` as directive negatives to properly enable the extensions being tested on the llvm-mc command line before validating that the directive correctly disables them. Reviewed By: ostannard Differential Revision: https://reviews.llvm.org/D93538 Added: Modified: llvm/test/MC/AArch64/directive-arch_extension-negative.s Removed: diff --git a/llvm/test/MC/AArch64/directive-arch_extension-negative.s b/llvm/test/MC/AArch64/directive-arch_extension-negative.s index 9d67abb80054..29920d442a8a 100644 --- a/llvm/test/MC/AArch64/directive-arch_extension-negative.s +++ b/llvm/test/MC/AArch64/directive-arch_extension-negative.s @@ -1,90 +1,126 @@ -// RUN: not llvm-mc -triple aarch64 -filetype asm -o - %s 2>&1 | FileCheck %s +// RUN: not llvm-mc -triple aarch64 \ +// RUN: -mattr=+crc,+sm4,+sha3,+sha2,+aes,+fp,+neon,+ras,+lse,+predres,+ccdp,+mte,+tlb-rmi,+pan-rwv,+ccpp,+rcpc,+ls64 \ +// RUN: -filetype asm -o - %s 2>&1 | FileCheck %s .arch_extension axp64 // CHECK: error: unknown architectural extension: axp64 // CHECK-NEXT: .arch_extension axp64 +crc32cx w0, w1, x3 +// CHECK-NOT: [[@LINE-1]]:1: error: instruction requires: crc .arch_extension nocrc crc32cx w0, w1, x3 -// CHECK: error: instruction requires: crc +// CHECK: [[@LINE-1]]:1: error: instruction requires: crc // CHECK-NEXT: crc32cx w0, w1, x3 +sm4e v2.4s, v15.4s +// CHECK-NOT: [[@LINE-1]]:1: error: instruction requires: sm4 .arch_extension nosm4 sm4e v2.4s, v15.4s -// CHECK: error: instruction requires: sm4 +// CHECK: [[@LINE-1]]:1: error: instruction requires: sm4 // CHECK-NEXT: sm4e v2.4s, v15.4s +sha512h q0, q1, v2.2d +// CHECK-NOT: [[@LINE-1]]:1: error: instruction requires: sha3 .arch_extension nosha3 sha512h q0, q1, v2.2d -// CHECK: error: instruction requires: sha3 +// CHECK: [[@LINE-1]]:1: error: instruction requires: sha3 // CHECK-NEXT: sha512h q0, q1, v2.2d +sha1h s0, s1 +// CHECK-NOT: [[@LINE-1]]:1: error: instruction requires: sha2 .arch_extension nosha2 sha1h s0, s1 -// CHECK: error: instruction requires: sha2 +// CHECK: [[@LINE-1]]:1: error: instruction requires: sha2 // CHECK-NEXT: sha1h s0, s1 +aese v0.16b, v1.16b +// CHECK-NOT: [[@LINE-1]]:1: error: instruction requires: aes .arch_extension noaes aese v0.16b, v1.16b -// CHECK: error: instruction requires: aes +// CHECK: [[@LINE-1]]:1: error: instruction requires: aes // CHECK-NEXT: aese v0.16b, v1.16b +fminnm d0, d0, d1 +// CHECK-NOT: [[@LINE-1]]:1: error: instruction requires: fp .arch_extension nofp fminnm d0, d0, d1 -// CHECK: error: instruction requires: fp +// CHECK: [[@LINE-1]]:1: error: instruction requires: fp // CHECK-NEXT: fminnm d0, d0, d1 +addp v0.4s, v0.4s, v0.4s +// CHECK-NOT: [[@LINE-1]]:1: error: instruction requires: neon .arch_extension nosimd addp v0.4s, v0.4s, v0.4s -// CHECK: error: instruction requires: neon +// CHECK: [[@LINE-1]]:1: error: instruction requires: neon // CHECK-NEXT: addp v0.4s, v0.4s, v0.4s +esb +// CHECK-NOT: [[@LINE-1]]:1: error: instruction requires: ras .arch_extension noras esb -// CHECK: error: instruction requires: ras +// CHECK: [[@LINE-1]]:1: error: instruction requires: ras // CHECK-NEXT: esb +casa w5, w7, [x20] +// CHECK-NOT: [[@LINE-1]]:1: error: instruction requires: lse .arch_extension nolse casa w5, w7, [x20] -// CHECK: error: instruction requires: lse +// CHECK: [[@LINE-1]]:1: error: instruction requires: lse // CHECK-NEXT: casa w5, w7, [x20] +cfp rctx, x0 +// CHECK-NOT: [[@LINE-1]]:5: error: CFPRCTX requires: predres .arch_extension nopredres cfp rctx, x0 -// CHECK: error: CFPRCTX requires: predres +// CHECK: [[@LINE-1]]:5: error: CFPRCTX requires: predres // CHECK-NEXT: cfp rctx, x0 +dc cvadp, x7 +// CHECK-NOT: [[@LINE-1]]:4: error: DC CVADP requires: ccdp .arch_extension noccdp dc cvadp, x7 -// CHECK: error: DC CVADP requires: ccdp +// CHECK: [[@LINE-1]]:4: error: DC CVADP requires: ccdp // CHECK-NEXT: dc cvadp, x7 +irg x0, x1 +// CHECK-NOT: [[@LINE-1]]:1: error: instruction requires: mte .arch_extension nomte irg x0, x1 -// CHECK: error: instruction requires: mte +// CHECK: [[@LINE-1]]:1: error: instruction requires: mte // CHECK-NEXT: irg x0, x1 +tlbi vmalle1os +// CHECK-NOT: [[@LINE-1]]:6: error: TLBI VMALLE1OS requires: tlb-rmi .arch_extension notlb-rmi tlbi vmalle1os -// CHECK: error: TLBI VMALLE1OS requires: tlb-rmi +// CHECK: [[@LINE-1]]:6: error: TLBI VMALLE1OS requires: tlb-rmi // CHECK-NEXT: tlbi vmalle1os +at s1e1wp, x2 +// CHECK-NOT: [[@LINE-1]]:4: error: AT S1E1WP r
[llvm-branch-commits] [llvm] 94da2cf - [X86] Avoid std::string creation in RecognizableInstr constructor. NFCI.
Author: Simon Pilgrim Date: 2020-12-18T16:00:41Z New Revision: 94da2cf650dd4397e8f84982c81e70f7a1825103 URL: https://github.com/llvm/llvm-project/commit/94da2cf650dd4397e8f84982c81e70f7a1825103 DIFF: https://github.com/llvm/llvm-project/commit/94da2cf650dd4397e8f84982c81e70f7a1825103.diff LOG: [X86] Avoid std::string creation in RecognizableInstr constructor. NFCI. The value names in byteFromRec calls are compile time constants - just create StringRef directly instead of via std::string. Added: Modified: llvm/utils/TableGen/X86RecognizableInstr.cpp Removed: diff --git a/llvm/utils/TableGen/X86RecognizableInstr.cpp b/llvm/utils/TableGen/X86RecognizableInstr.cpp index 6a245b5eb425..e4b7c05cfb88 100644 --- a/llvm/utils/TableGen/X86RecognizableInstr.cpp +++ b/llvm/utils/TableGen/X86RecognizableInstr.cpp @@ -54,7 +54,7 @@ static uint8_t byteFromBitsInit(BitsInit &init) { /// @param rec - The record from which to extract the value. /// @param name - The name of the field in the record. /// @return - The field, as translated by byteFromBitsInit(). -static uint8_t byteFromRec(const Record* rec, const std::string &name) { +static uint8_t byteFromRec(const Record* rec, StringRef name) { BitsInit* bits = rec->getValueAsBitsInit(name); return byteFromBitsInit(*bits); } ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [llvm] fd0f5fb - PEI: Only call updateLiveness once per function
Author: Matt Arsenault Date: 2020-12-18T11:02:28-05:00 New Revision: fd0f5fb8de26230cbb0eeedaef58036ddede4c63 URL: https://github.com/llvm/llvm-project/commit/fd0f5fb8de26230cbb0eeedaef58036ddede4c63 DIFF: https://github.com/llvm/llvm-project/commit/fd0f5fb8de26230cbb0eeedaef58036ddede4c63.diff LOG: PEI: Only call updateLiveness once per function This only needs to be called once for the function, and it visits all the necessary blocks in the function. It looks like 631f6b888c50276450fee8b9ef129f37f83fc5a1 accidentally moved this into the loop over all save blocks. Added: Modified: llvm/lib/CodeGen/PrologEpilogInserter.cpp Removed: diff --git a/llvm/lib/CodeGen/PrologEpilogInserter.cpp b/llvm/lib/CodeGen/PrologEpilogInserter.cpp index 9ae155a7b6fb..7c38b193a980 100644 --- a/llvm/lib/CodeGen/PrologEpilogInserter.cpp +++ b/llvm/lib/CodeGen/PrologEpilogInserter.cpp @@ -620,12 +620,12 @@ void PEI::spillCalleeSavedRegs(MachineFunction &MF) { if (!MFI.hasCalls()) NumLeafFuncWithSpills++; - for (MachineBasicBlock *SaveBlock : SaveBlocks) { + for (MachineBasicBlock *SaveBlock : SaveBlocks) insertCSRSaves(*SaveBlock, CSI); -// Update the live-in information of all the blocks up to the save -// point. -updateLiveness(MF); - } + + // Update the live-in information of all the blocks up to the save point. + updateLiveness(MF); + for (MachineBasicBlock *RestoreBlock : RestoreBlocks) insertCSRRestores(*RestoreBlock, CSI); } ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [llvm] 4652718 - Cleanup coro-inline.ll
Author: Xun Li Date: 2020-12-18T08:05:04-08:00 New Revision: 4652718ee38c519c6bb9470758d07430b0de02dd URL: https://github.com/llvm/llvm-project/commit/4652718ee38c519c6bb9470758d07430b0de02dd DIFF: https://github.com/llvm/llvm-project/commit/4652718ee38c519c6bb9470758d07430b0de02dd.diff LOG: Cleanup coro-inline.ll Following up with the comments in D92706. - Use -passes instead of -enable-new-pm - CoroEarly should happen before AlwaysInliner, adjust it. - Remove some unnecessary barriers (still kept one) - Cleanup unnecessary debug info Differential Revision: https://reviews.llvm.org/D93342 Added: Modified: llvm/test/Transforms/Coroutines/coro-inline.ll Removed: diff --git a/llvm/test/Transforms/Coroutines/coro-inline.ll b/llvm/test/Transforms/Coroutines/coro-inline.ll index fc5c1d0d6b1f..2cc679a0127d 100644 --- a/llvm/test/Transforms/Coroutines/coro-inline.ll +++ b/llvm/test/Transforms/Coroutines/coro-inline.ll @@ -1,7 +1,7 @@ -; RUN: opt < %s -always-inline -barrier -coro-early -barrier -coro-split -S | FileCheck %s -; RUN: opt < %s -enable-new-pm -always-inline -coro-early -coro-split -S | FileCheck %s -; RUN: opt < %s -sample-profile-file=%S/Inputs/sample.text.prof -pgo-kind=pgo-sample-use-pipeline -coro-early -barrier -sample-profile -barrier -coro-split -disable-inlining=true -S | FileCheck %s -; RUN: opt < %s -enable-new-pm -sample-profile-file=%S/Inputs/sample.text.prof -pgo-kind=pgo-sample-use-pipeline -coro-early -sample-profile -coro-split -disable-inlining=true -S | FileCheck %s +; RUN: opt < %s -always-inline -barrier -coro-split -S | FileCheck %s +; RUN: opt < %s -passes='always-inline,cgscc(coro-split)' -S | FileCheck %s +; RUN: opt < %s -sample-profile-file=%S/Inputs/sample.text.prof -pgo-kind=pgo-sample-use-pipeline -sample-profile -coro-split -disable-inlining=true -S | FileCheck %s +; RUN: opt < %s -sample-profile-file=%S/Inputs/sample.text.prof -pgo-kind=pgo-sample-use-pipeline -passes='sample-profile,cgscc(coro-split)' -disable-inlining=true -S | FileCheck %s ; Function Attrs: alwaysinline ssp uwtable define void @ff() #0 !dbg !12 { @@ -11,7 +11,6 @@ entry: ret void } -; CHECK: call void @ff() ; Function Attrs: alwaysinline ssp uwtable define void @foo() #0 !dbg !8 { entry: @@ -20,11 +19,14 @@ entry: call void @ff(), !dbg !11 ret void } +; CHECK-LABEL: define void @foo() +; CHECK: call void @ff() + declare token @llvm.coro.id(i32, i8* readnone, i8* nocapture readonly, i8*) declare i8* @llvm.coro.begin(token, i8* writeonly) -attributes #0 = { alwaysinline ssp uwtable "coroutine.presplit"="1" "correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false" "frame-pointer"="all" "less-precise-fpmad"="false" "min-legal-vector-width"="0" "no-infs-fp-math"="false" "no-jump-tables"="false" "no-nans-fp-math"="false" "no-signed-zeros-fp-math"="false" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="penryn" "target-features"="+cx16,+cx8,+fxsr,+mmx,+sahf,+sse,+sse2,+sse3,+sse4.1,+ssse3,+x87" "unsafe-fp-math"="false" "use-sample-profile" "use-soft-float"="false" } +attributes #0 = { alwaysinline ssp uwtable "coroutine.presplit"="1" "use-sample-profile" } !llvm.dbg.cu = !{!0} !llvm.module.flags = !{!3, !4, !5, !6} ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [mlir] b88ed4e - [mlir][Linlag] Reflow Linalg.md - NFC
Author: Nicolas Vasilache Date: 2020-12-18T16:15:58Z New Revision: b88ed4ec8e7d35f786a59de527989316ba9c5f48 URL: https://github.com/llvm/llvm-project/commit/b88ed4ec8e7d35f786a59de527989316ba9c5f48 DIFF: https://github.com/llvm/llvm-project/commit/b88ed4ec8e7d35f786a59de527989316ba9c5f48.diff LOG: [mlir][Linlag] Reflow Linalg.md - NFC Markdown formatting seems to now be available, reflowing the doc without changing any content. Added: Modified: mlir/docs/Dialects/Linalg.md Removed: diff --git a/mlir/docs/Dialects/Linalg.md b/mlir/docs/Dialects/Linalg.md index c6681a93e53e..02508a81b63a 100644 --- a/mlir/docs/Dialects/Linalg.md +++ b/mlir/docs/Dialects/Linalg.md @@ -6,12 +6,12 @@ https://user-images.githubusercontent.com/10148468/73613629-c5586580-45c5-11ea-94b7-074aeea94c7b.png";> -Linalg is designed to solve the High-level Hierarchical Optimization -(HHO box) in MLIR and to interoperate nicely within a -*Mixture Of Expert Compilers* environment (i.e. the *CGSel* box). +Linalg is designed to solve the High-level Hierarchical Optimization (HHO box) +in MLIR and to interoperate nicely within a *Mixture Of Expert Compilers* +environment (i.e. the *CGSel* box). -The [Rationale Document](../Rationale/RationaleLinalgDialect.md) -goes into significantly more design and architectural decision details. +The [Rationale Document](../Rationale/RationaleLinalgDialect.md) goes into +significantly more design and architectural decision details. ## Set of Key Transformations @@ -20,51 +20,56 @@ Linalg. They are all implemented in terms of the properties of the `linalg.generic` OpInterface and avoid the pitfall of relying on hardcoded one-off op knowledge. -The textual form description of these transformations is left for future -work. Still, it is useful to at least the key transformations that are -performed on the Linalg IR and that have influenced its design: -1. Progressive Buffer Allocation. -1. Parametric Tiling. -1. Promotion to Temporary Buffer in Fast Memory. -1. Tiled Producer-Consumer Fusion with Parametric Tile-And-Fuse. -1. Map to Parallel and Reduction Loops and Hardware. -1. Vectorization: Rewrite in Vector Form. -1. Lower to Loops (Affine, Generic, and Parallel). -1. Lower to Library Calls or Special Instructions, Intrinsics or ISA. -1. Partially Lower to Iterations Over a Finer-Grained Linalg Op. +The textual form description of these transformations is left for future work. +Still, it is useful to at least the key transformations that are performed on +the Linalg IR and that have influenced its design: + +1. Progressive Buffer Allocation. +1. Parametric Tiling. +1. Promotion to Temporary Buffer in Fast Memory. +1. Tiled Producer-Consumer Fusion with Parametric Tile-And-Fuse. +1. Map to Parallel and Reduction Loops and Hardware. +1. Vectorization: Rewrite in Vector Form. +1. Lower to Loops (Affine, Generic, and Parallel). +1. Lower to Library Calls or Special Instructions, Intrinsics or ISA. +1. Partially Lower to Iterations Over a Finer-Grained Linalg Op. ## High-Level Description of Linalg Ops -Linalg takes at least some inspiration from all previously [listed prior -art](#prior_art). The design enables the definition of ***CustomOps*** with -generic properties that enable [key transformations](#key_transformations), -including lowering to scalar load/store and other operations or to external -library calls and intrinsics. + +Linalg takes at least some inspiration from all previously +[listed prior art](#prior_art). The design enables the definition of +***CustomOps*** with generic properties that enable +[key transformations](#key_transformations), including lowering to scalar +load/store and other operations or to external library calls and intrinsics. These ops can have ***either tensor or buffer operands***, subject to [conventions and limitations](#tensors_and_buffers). ### Payload-Carrying Ops -Linalg defines two payload carrying operations that implement the [structured ops]( -https://docs.google.com/presentation/d/1P-j1GrH6Q5gLBjao0afQ-GfvcAeF-QU4GXXeSy0eJ9I/edit#slide=id.p -) abstraction on tensors and buffers. This is architected as two generic operations -`linalg.generic` (resp. `linalg.indexed_generic`) that can express custom -operations with *index-free semantics* (resp. *indexing semantics*). -The properties of these generic ops are the result of applying the -guiding principles described in the [Rationale Document](../Rationale/RationaleLinalgDialect.md). -They are listed next, with a brief example and discussion for each. + +Linalg defines two payload carrying operations that implement the +[structured ops](https://docs.google.com/presentation/d/1P-j1GrH6Q5gLBjao0afQ-GfvcAeF-QU4GXXeSy0eJ9I/edit#slide=id.p) +abstraction on tensors and buffers. This is architected as two generic +operations `linalg.generic` (resp. `linalg.indexed_generic`)
[llvm-branch-commits] [lld] 22c1bd5 - [ELF] Rename R_TLS to R_TPREL and R_NEG_TLS to R_TPREL_NEG. NFC
Author: Fangrui Song Date: 2020-12-18T08:24:42-08:00 New Revision: 22c1bd57bf34391cd16e91fa4830dba4cdf17aa2 URL: https://github.com/llvm/llvm-project/commit/22c1bd57bf34391cd16e91fa4830dba4cdf17aa2 DIFF: https://github.com/llvm/llvm-project/commit/22c1bd57bf34391cd16e91fa4830dba4cdf17aa2.diff LOG: [ELF] Rename R_TLS to R_TPREL and R_NEG_TLS to R_TPREL_NEG. NFC The scope of R_TLS (TP offset relocation types (TPREL/TPOFF) used for the local-exec TLS model) is actually narrower than its name may imply. R_TLS_NEG is only used by Solaris R_386_TLS_LE_32. Rename them so that they will be less confusing. Reviewed By: grimar, psmith, rprichard Differential Revision: https://reviews.llvm.org/D93467 Added: Modified: lld/ELF/Arch/AArch64.cpp lld/ELF/Arch/ARM.cpp lld/ELF/Arch/Hexagon.cpp lld/ELF/Arch/Mips.cpp lld/ELF/Arch/PPC.cpp lld/ELF/Arch/PPC64.cpp lld/ELF/Arch/RISCV.cpp lld/ELF/Arch/SPARCV9.cpp lld/ELF/Arch/X86.cpp lld/ELF/Arch/X86_64.cpp lld/ELF/InputSection.cpp lld/ELF/Relocations.cpp lld/ELF/Relocations.h Removed: diff --git a/lld/ELF/Arch/AArch64.cpp b/lld/ELF/Arch/AArch64.cpp index e61251903059..61230a6dabbd 100644 --- a/lld/ELF/Arch/AArch64.cpp +++ b/lld/ELF/Arch/AArch64.cpp @@ -120,7 +120,7 @@ RelExpr AArch64::getRelExpr(RelType type, const Symbol &s, case R_AARCH64_TLSLE_MOVW_TPREL_G1: case R_AARCH64_TLSLE_MOVW_TPREL_G1_NC: case R_AARCH64_TLSLE_MOVW_TPREL_G2: -return R_TLS; +return R_TPREL; case R_AARCH64_CALL26: case R_AARCH64_CONDBR19: case R_AARCH64_JUMP26: diff --git a/lld/ELF/Arch/ARM.cpp b/lld/ELF/Arch/ARM.cpp index fd90557cc4f6..e90e7efd34bd 100644 --- a/lld/ELF/Arch/ARM.cpp +++ b/lld/ELF/Arch/ARM.cpp @@ -150,7 +150,7 @@ RelExpr ARM::getRelExpr(RelType type, const Symbol &s, case R_ARM_NONE: return R_NONE; case R_ARM_TLS_LE32: -return R_TLS; +return R_TPREL; case R_ARM_V4BX: // V4BX is just a marker to indicate there's a "bx rN" instruction at the // given address. It can be used to implement a special linker mode which diff --git a/lld/ELF/Arch/Hexagon.cpp b/lld/ELF/Arch/Hexagon.cpp index 4896c75c4491..02d872d58caf 100644 --- a/lld/ELF/Arch/Hexagon.cpp +++ b/lld/ELF/Arch/Hexagon.cpp @@ -154,7 +154,7 @@ RelExpr Hexagon::getRelExpr(RelType type, const Symbol &s, case R_HEX_TPREL_32_6_X: case R_HEX_TPREL_HI16: case R_HEX_TPREL_LO16: -return R_TLS; +return R_TPREL; default: error(getErrorLocation(loc) + "unknown relocation (" + Twine(type) + ") against symbol " + toString(s)); diff --git a/lld/ELF/Arch/Mips.cpp b/lld/ELF/Arch/Mips.cpp index d5eaf94625e0..5c6b3e2371ef 100644 --- a/lld/ELF/Arch/Mips.cpp +++ b/lld/ELF/Arch/Mips.cpp @@ -146,7 +146,7 @@ RelExpr MIPS::getRelExpr(RelType type, const Symbol &s, case R_MIPS_TLS_TPREL64: case R_MICROMIPS_TLS_TPREL_HI16: case R_MICROMIPS_TLS_TPREL_LO16: -return R_TLS; +return R_TPREL; case R_MIPS_PC32: case R_MIPS_PC16: case R_MIPS_PC19_S2: diff --git a/lld/ELF/Arch/PPC.cpp b/lld/ELF/Arch/PPC.cpp index 88a1b2143b8e..5b22e6cd3f5f 100644 --- a/lld/ELF/Arch/PPC.cpp +++ b/lld/ELF/Arch/PPC.cpp @@ -259,7 +259,7 @@ RelExpr PPC::getRelExpr(RelType type, const Symbol &s, case R_PPC_TPREL16_HA: case R_PPC_TPREL16_LO: case R_PPC_TPREL16_HI: -return R_TLS; +return R_TPREL; default: error(getErrorLocation(loc) + "unknown relocation (" + Twine(type) + ") against symbol " + toString(s)); diff --git a/lld/ELF/Arch/PPC64.cpp b/lld/ELF/Arch/PPC64.cpp index 65652b1c471f..477f76bd31b7 100644 --- a/lld/ELF/Arch/PPC64.cpp +++ b/lld/ELF/Arch/PPC64.cpp @@ -1025,7 +1025,7 @@ RelExpr PPC64::getRelExpr(RelType type, const Symbol &s, case R_PPC64_TPREL16_HIGHEST: case R_PPC64_TPREL16_HIGHESTA: case R_PPC64_TPREL34: -return R_TLS; +return R_TPREL; case R_PPC64_DTPREL16: case R_PPC64_DTPREL16_DS: case R_PPC64_DTPREL16_HA: diff --git a/lld/ELF/Arch/RISCV.cpp b/lld/ELF/Arch/RISCV.cpp index 4cbf925dcfa2..ca4178b18e76 100644 --- a/lld/ELF/Arch/RISCV.cpp +++ b/lld/ELF/Arch/RISCV.cpp @@ -235,7 +235,7 @@ RelExpr RISCV::getRelExpr(const RelType type, const Symbol &s, case R_RISCV_TPREL_HI20: case R_RISCV_TPREL_LO12_I: case R_RISCV_TPREL_LO12_S: -return R_TLS; +return R_TPREL; case R_RISCV_RELAX: case R_RISCV_TPREL_ADD: return R_NONE; diff --git a/lld/ELF/Arch/SPARCV9.cpp b/lld/ELF/Arch/SPARCV9.cpp index f137c21fc898..9e18ae4753bc 100644 --- a/lld/ELF/Arch/SPARCV9.cpp +++ b/lld/ELF/Arch/SPARCV9.cpp @@ -78,7 +78,7 @@ RelExpr SPARCV9::getRelExpr(RelType type, const Symbol &s, return R_NONE; case R_SPARC_TLS_LE_HIX22: case R_SPARC_TLS_LE_LOX10: -return R_TLS; +return R_TPREL; default: error(getErrorLocation(loc) + "unknown relocation (" + Twine(type) + ") against symbol " + toString(s))
[llvm-branch-commits] [llvm] 06d5b1c - [SROA] Remove Dead Instructions while creating speculative instructions
Author: Arnamoy Bhattacharyya Date: 2020-12-18T11:47:02-05:00 New Revision: 06d5b1c9ad52476e845f969cf82e00e383f9cf40 URL: https://github.com/llvm/llvm-project/commit/06d5b1c9ad52476e845f969cf82e00e383f9cf40 DIFF: https://github.com/llvm/llvm-project/commit/06d5b1c9ad52476e845f969cf82e00e383f9cf40.diff LOG: [SROA] Remove Dead Instructions while creating speculative instructions The SROA pass tries to be lazy for removing dead instructions that are collected during iterative run of the pass in the DeadInsts list. However it does not remove instructions from the dead list while running eraseFromParent() on those instructions. This causes (rare) null pointer dereferences. For example, in the speculatePHINodeLoads() instruction, in the following code snippet: ``` while (!PN.use_empty()) { LoadInst *LI = cast(PN.user_back()); LI->replaceAllUsesWith(NewPN); LI->eraseFromParent(); } ``` If the Load instruction LI belongs to the DeadInsts list, it should be removed when eraseFromParent() is called. However, the bug does not show up in most cases, because immediately in the same function, a new LoadInst is created in the following line: ``` LoadInst *Load = PredBuilder.CreateAlignedLoad( LoadTy, InVal, Alignment, (PN.getName() + ".sroa.speculate.load." + Pred->getName())); ``` This new LoadInst object takes the same memory address of the just deleted LI using eraseFromParent(), therefore the bug does not materialize. In very rare cases, the addresses differ and therefore, a dangling pointer is created, causing a crash. Reviewed By: lebedev.ri Differential Revision: https://reviews.llvm.org/D92431 Added: Modified: llvm/include/llvm/Transforms/Scalar/SROA.h llvm/lib/Transforms/Scalar/SROA.cpp Removed: diff --git a/llvm/include/llvm/Transforms/Scalar/SROA.h b/llvm/include/llvm/Transforms/Scalar/SROA.h index 864a0cbd9db1..6ef7c6b22c0b 100644 --- a/llvm/include/llvm/Transforms/Scalar/SROA.h +++ b/llvm/include/llvm/Transforms/Scalar/SROA.h @@ -18,6 +18,7 @@ #include "llvm/ADT/SetVector.h" #include "llvm/ADT/SmallVector.h" #include "llvm/IR/PassManager.h" +#include "llvm/IR/ValueHandle.h" #include namespace llvm { @@ -77,8 +78,8 @@ class SROA : public PassInfoMixin { /// A collection of instructions to delete. /// We try to batch deletions to simplify code and make things a bit more - /// efficient. - SetVector> DeadInsts; + /// efficient. We also make sure there is no dangling pointers. + SmallVector DeadInsts; /// Post-promotion worklist. /// diff --git a/llvm/lib/Transforms/Scalar/SROA.cpp b/llvm/lib/Transforms/Scalar/SROA.cpp index 600863d50d54..7df98694c8b0 100644 --- a/llvm/lib/Transforms/Scalar/SROA.cpp +++ b/llvm/lib/Transforms/Scalar/SROA.cpp @@ -2460,7 +2460,7 @@ class llvm::sroa::AllocaSliceRewriter void deleteIfTriviallyDead(Value *V) { Instruction *I = cast(V); if (isInstructionTriviallyDead(I)) - Pass.DeadInsts.insert(I); + Pass.DeadInsts.push_back(I); } Value *rewriteVectorizedLoadInst() { @@ -2600,7 +2600,7 @@ class llvm::sroa::AllocaSliceRewriter LI.replaceAllUsesWith(V); } -Pass.DeadInsts.insert(&LI); +Pass.DeadInsts.push_back(&LI); deleteIfTriviallyDead(OldOp); LLVM_DEBUG(dbgs() << " to: " << *V << "\n"); return !LI.isVolatile() && !IsPtrAdjusted; @@ -2629,7 +2629,7 @@ class llvm::sroa::AllocaSliceRewriter StoreInst *Store = IRB.CreateAlignedStore(V, &NewAI, NewAI.getAlign()); if (AATags) Store->setAAMetadata(AATags); -Pass.DeadInsts.insert(&SI); +Pass.DeadInsts.push_back(&SI); LLVM_DEBUG(dbgs() << " to: " << *Store << "\n"); return true; @@ -2653,7 +2653,7 @@ class llvm::sroa::AllocaSliceRewriter LLVMContext::MD_access_group}); if (AATags) Store->setAAMetadata(AATags); -Pass.DeadInsts.insert(&SI); +Pass.DeadInsts.push_back(&SI); LLVM_DEBUG(dbgs() << " to: " << *Store << "\n"); return true; } @@ -2727,7 +2727,7 @@ class llvm::sroa::AllocaSliceRewriter NewSI->setAtomic(SI.getOrdering(), SI.getSyncScopeID()); if (NewSI->isAtomic()) NewSI->setAlignment(SI.getAlign()); -Pass.DeadInsts.insert(&SI); +Pass.DeadInsts.push_back(&SI); deleteIfTriviallyDead(OldOp); LLVM_DEBUG(dbgs() << " to: " << *NewSI << "\n"); @@ -2788,7 +2788,7 @@ class llvm::sroa::AllocaSliceRewriter } // Record this instruction for deletion. -Pass.DeadInsts.insert(&II); +Pass.DeadInsts.push_back(&II); Type *AllocaTy = NewAI.getAllocatedType(); Type *ScalarTy = AllocaTy->getScalarType(); @@ -2958,7 +2958,7 @@ class llvm::sroa::AllocaSliceRewriter return false; } // Record this instruction for deletion. -Pass.DeadInsts.insert(&II); +Pass.DeadInsts.
[llvm-branch-commits] [llvm] ce94e7d - [MCA, ExecutionEngine, Object] Use llvm::is_contained (NFC)
Author: Kazu Hirata Date: 2020-12-18T09:09:04-08:00 New Revision: ce94e7d867abf5c08f5b0008f2d31b3f169b815d URL: https://github.com/llvm/llvm-project/commit/ce94e7d867abf5c08f5b0008f2d31b3f169b815d DIFF: https://github.com/llvm/llvm-project/commit/ce94e7d867abf5c08f5b0008f2d31b3f169b815d.diff LOG: [MCA, ExecutionEngine, Object] Use llvm::is_contained (NFC) Added: Modified: llvm/include/llvm/MCA/HardwareUnits/Scheduler.h llvm/lib/ExecutionEngine/Orc/RTDyldObjectLinkingLayer.cpp llvm/lib/Object/MachOObjectFile.cpp Removed: diff --git a/llvm/include/llvm/MCA/HardwareUnits/Scheduler.h b/llvm/include/llvm/MCA/HardwareUnits/Scheduler.h index 6c196757e571..0293364e26ef 100644 --- a/llvm/include/llvm/MCA/HardwareUnits/Scheduler.h +++ b/llvm/include/llvm/MCA/HardwareUnits/Scheduler.h @@ -267,9 +267,9 @@ class Scheduler : public HardwareUnit { // This routine performs a sanity check. This routine should only be called // when we know that 'IR' is not in the scheduler's instruction queues. void sanityCheck(const InstRef &IR) const { -assert(find(WaitSet, IR) == WaitSet.end() && "Already in the wait set!"); -assert(find(ReadySet, IR) == ReadySet.end() && "Already in the ready set!"); -assert(find(IssuedSet, IR) == IssuedSet.end() && "Already executing!"); +assert(!is_contained(WaitSet, IR) && "Already in the wait set!"); +assert(!is_contained(ReadySet, IR) && "Already in the ready set!"); +assert(!is_contained(IssuedSet, IR) && "Already executing!"); } #endif // !NDEBUG }; diff --git a/llvm/lib/ExecutionEngine/Orc/RTDyldObjectLinkingLayer.cpp b/llvm/lib/ExecutionEngine/Orc/RTDyldObjectLinkingLayer.cpp index a6cccb90936c..0ad666ebbebd 100644 --- a/llvm/lib/ExecutionEngine/Orc/RTDyldObjectLinkingLayer.cpp +++ b/llvm/lib/ExecutionEngine/Orc/RTDyldObjectLinkingLayer.cpp @@ -167,8 +167,7 @@ void RTDyldObjectLinkingLayer::emit( void RTDyldObjectLinkingLayer::registerJITEventListener(JITEventListener &L) { std::lock_guard Lock(RTDyldLayerMutex); - assert(llvm::none_of(EventListeners, - [&](JITEventListener *O) { return O == &L; }) && + assert(!llvm::is_contained(EventListeners, &L) && "Listener has already been registered"); EventListeners.push_back(&L); } diff --git a/llvm/lib/Object/MachOObjectFile.cpp b/llvm/lib/Object/MachOObjectFile.cpp index 9ed2b8acc7e0..302255926289 100644 --- a/llvm/lib/Object/MachOObjectFile.cpp +++ b/llvm/lib/Object/MachOObjectFile.cpp @@ -2743,7 +2743,7 @@ Triple MachOObjectFile::getHostArch() { bool MachOObjectFile::isValidArch(StringRef ArchFlag) { auto validArchs = getValidArchs(); - return llvm::find(validArchs, ArchFlag) != validArchs.end(); + return llvm::is_contained(validArchs, ArchFlag); } ArrayRef MachOObjectFile::getValidArchs() { ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [llvm] 2a814cd - Ensure SplitEdge to return the new block between the two given blocks
Author: Whitney Tsang Date: 2020-12-18T17:37:17Z New Revision: 2a814cd9e1e8493c6606712d55f9ffdb58396481 URL: https://github.com/llvm/llvm-project/commit/2a814cd9e1e8493c6606712d55f9ffdb58396481 DIFF: https://github.com/llvm/llvm-project/commit/2a814cd9e1e8493c6606712d55f9ffdb58396481.diff LOG: Ensure SplitEdge to return the new block between the two given blocks This PR implements the function splitBasicBlockBefore to address an issue that occurred during SplitEdge(BB, Succ, ...), inside splitBlockBefore. The issue occurs in SplitEdge when the Succ has a single predecessor and the edge between the BB and Succ is not critical. This produces the result ‘BB->Succ->New’. The new function splitBasicBlockBefore was added to splitBlockBefore to handle the issue and now produces the correct result ‘BB->New->Succ’. Below is an example of splitting the block bb1 at its first instruction. /// Original IR bb0: br bb1 bb1: %0 = mul i32 1, 2 br bb2 bb2: /// IR after splitEdge(bb0, bb1) using splitBasicBlock bb0: br bb1 bb1: br bb1.split bb1.split: %0 = mul i32 1, 2 br bb2 bb2: /// IR after splitEdge(bb0, bb1) using splitBasicBlockBefore bb0: br bb1.split bb1.split br bb1 bb1: %0 = mul i32 1, 2 br bb2 bb2: Differential Revision: https://reviews.llvm.org/D92200 Added: Modified: llvm/include/llvm/IR/BasicBlock.h llvm/include/llvm/Transforms/Utils/BasicBlockUtils.h llvm/lib/IR/BasicBlock.cpp llvm/lib/Transforms/Utils/BasicBlockUtils.cpp llvm/test/CodeGen/AMDGPU/call-constexpr.ll llvm/test/Transforms/LoopUnswitch/2011-11-18-SimpleSwitch.ll llvm/unittests/Transforms/Utils/BasicBlockUtilsTest.cpp Removed: diff --git a/llvm/include/llvm/IR/BasicBlock.h b/llvm/include/llvm/IR/BasicBlock.h index 0cce2a599d9c..b86bb16e1239 100644 --- a/llvm/include/llvm/IR/BasicBlock.h +++ b/llvm/include/llvm/IR/BasicBlock.h @@ -398,22 +398,49 @@ class BasicBlock final : public Value, // Basic blocks are data objects also /// Split the basic block into two basic blocks at the specified instruction. /// - /// Note that all instructions BEFORE the specified iterator stay as part of - /// the original basic block, an unconditional branch is added to the original - /// BB, and the rest of the instructions in the BB are moved to the new BB, - /// including the old terminator. The newly formed BasicBlock is returned. - /// This function invalidates the specified iterator. + /// If \p Before is true, splitBasicBlockBefore handles the + /// block splitting. Otherwise, execution proceeds as described below. + /// + /// Note that all instructions BEFORE the specified iterator + /// stay as part of the original basic block, an unconditional branch is added + /// to the original BB, and the rest of the instructions in the BB are moved + /// to the new BB, including the old terminator. The newly formed basic block + /// is returned. This function invalidates the specified iterator. /// /// Note that this only works on well formed basic blocks (must have a - /// terminator), and 'I' must not be the end of instruction list (which would - /// cause a degenerate basic block to be formed, having a terminator inside of - /// the basic block). + /// terminator), and \p 'I' must not be the end of instruction list (which + /// would cause a degenerate basic block to be formed, having a terminator + /// inside of the basic block). /// /// Also note that this doesn't preserve any passes. To split blocks while /// keeping loop information consistent, use the SplitBlock utility function. - BasicBlock *splitBasicBlock(iterator I, const Twine &BBName = ""); - BasicBlock *splitBasicBlock(Instruction *I, const Twine &BBName = "") { -return splitBasicBlock(I->getIterator(), BBName); + BasicBlock *splitBasicBlock(iterator I, const Twine &BBName = "", + bool Before = false); + BasicBlock *splitBasicBlock(Instruction *I, const Twine &BBName = "", + bool Before = false) { +return splitBasicBlock(I->getIterator(), BBName, Before); + } + + /// Split the basic block into two basic blocks at the specified instruction + /// and insert the new basic blocks as the predecessor of the current block. + /// + /// This function ensures all instructions AFTER and including the specified + /// iterator \p I are part of the original basic block. All Instructions + /// BEFORE the iterator \p I are moved to the new BB and an unconditional + /// branch is added to the new BB. The new basic block is returned. + /// + /// Note that this only works on well formed basic blocks (must have a + /// terminator), and \p 'I' must not be the end of instruction list (which + /// would cause a degenerate basic block to be formed, having a terminator + /// insid
[llvm-branch-commits] [llvm] 7fef551 - Revert "Revert "[FPEnv] Teach the IRBuilder about invoke's correct use of the strictfp attribute.""
Author: Kevin P. Neal Date: 2020-12-18T12:42:06-05:00 New Revision: 7fef551cb123d9f1956f8ec7a142bd8a63d25fa9 URL: https://github.com/llvm/llvm-project/commit/7fef551cb123d9f1956f8ec7a142bd8a63d25fa9 DIFF: https://github.com/llvm/llvm-project/commit/7fef551cb123d9f1956f8ec7a142bd8a63d25fa9.diff LOG: Revert "Revert "[FPEnv] Teach the IRBuilder about invoke's correct use of the strictfp attribute."" Similar to D69312, and documented in D69839, the IRBuilder needs to add the strictfp attribute to invoke instructions when constrained floating point is enabled. This is try 2, with the test corrected. Differential Revision: https://reviews.llvm.org/D93134 Added: clang/test/CodeGen/exceptions-strictfp.c Modified: llvm/include/llvm/IR/IRBuilder.h Removed: diff --git a/clang/test/CodeGen/exceptions-strictfp.c b/clang/test/CodeGen/exceptions-strictfp.c new file mode 100644 index ..6f9e9f891b6c --- /dev/null +++ b/clang/test/CodeGen/exceptions-strictfp.c @@ -0,0 +1,37 @@ +// RUN: %clang_cc1 -triple armv7-apple-unknown -ffp-exception-behavior=strict -fexperimental-strict-floating-point -emit-llvm -o - %s -fexceptions -exception-model=sjlj -fblocks | FileCheck %s + +// Verify strictfp attributes on invoke calls (and therefore also on +// function definitions). + +// rdar://problem/8621849 +void test1() { + extern void test1_helper(void (^)(int)); + + // CHECK: define arm_aapcscc void @test1() [[STRICTFP0:#[0-9]+]] personality i8* bitcast (i32 (...)* @__gcc_personality_sj0 to i8*) + + __block int x = 10; + + // CHECK: invoke arm_aapcscc void @test1_helper({{.*}}) [[STRICTFP1:#[0-9]+]] + test1_helper(^(int v) { x = v; }); + + // CHECK: landingpad { i8*, i32 } + // CHECK-NEXT: cleanup +} + +void test2_helper(); +void test2() { + // CHECK: define arm_aapcscc void @test2() [[STRICTFP0]] personality i8* bitcast (i32 (...)* @__gcc_personality_sj0 to i8*) { + __block int x = 10; + ^{ (void)x; }; + + // CHECK: invoke arm_aapcscc void @test2_helper({{.*}}) [[STRICTFP1:#[0-9]+]] + test2_helper(5, 6, 7); + + // CHECK: landingpad { i8*, i32 } + // CHECK-NEXT: cleanup +} +void test2_helper(int x, int y) { +} + +// CHECK: attributes [[STRICTFP0]] = { {{.*}}strictfp{{.*}} } +// CHECK: attributes [[STRICTFP1]] = { strictfp } diff --git a/llvm/include/llvm/IR/IRBuilder.h b/llvm/include/llvm/IR/IRBuilder.h index 56005b26a538..6bc5e89453ad 100644 --- a/llvm/include/llvm/IR/IRBuilder.h +++ b/llvm/include/llvm/IR/IRBuilder.h @@ -350,7 +350,7 @@ class IRBuilderBase { } } - void setConstrainedFPCallAttr(CallInst *I) { + void setConstrainedFPCallAttr(CallBase *I) { I->addAttribute(AttributeList::FunctionIndex, Attribute::StrictFP); } @@ -1088,16 +1088,21 @@ class IRBuilderBase { ArrayRef Args, ArrayRef OpBundles, const Twine &Name = "") { -return Insert( -InvokeInst::Create(Ty, Callee, NormalDest, UnwindDest, Args, OpBundles), -Name); +InvokeInst *II = +InvokeInst::Create(Ty, Callee, NormalDest, UnwindDest, Args, OpBundles); +if (IsFPConstrained) + setConstrainedFPCallAttr(II); +return Insert(II, Name); } InvokeInst *CreateInvoke(FunctionType *Ty, Value *Callee, BasicBlock *NormalDest, BasicBlock *UnwindDest, ArrayRef Args = None, const Twine &Name = "") { -return Insert(InvokeInst::Create(Ty, Callee, NormalDest, UnwindDest, Args), - Name); +InvokeInst *II = +InvokeInst::Create(Ty, Callee, NormalDest, UnwindDest, Args); +if (IsFPConstrained) + setConstrainedFPCallAttr(II); +return Insert(II, Name); } InvokeInst *CreateInvoke(FunctionCallee Callee, BasicBlock *NormalDest, ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [llvm] fc7b7fc - [RISCV] Add intrinsics for vmv.v.v, vmv.v.x, and vmv.x.i
Author: Craig Topper Date: 2020-12-18T09:49:07-08:00 New Revision: fc7b7fc066946f83b04928d80242fcffbf23323e URL: https://github.com/llvm/llvm-project/commit/fc7b7fc066946f83b04928d80242fcffbf23323e DIFF: https://github.com/llvm/llvm-project/commit/fc7b7fc066946f83b04928d80242fcffbf23323e.diff LOG: [RISCV] Add intrinsics for vmv.v.v, vmv.v.x, and vmv.x.i We work with @rogfer01 from BSC to come out this patch. Authored-by: Roger Ferrer Ibanez Co-Authored-by: Craig Topper Differential Revision: https://reviews.llvm.org/D93514 Added: llvm/test/CodeGen/RISCV/rvv/vmv.v.v-rv32.ll llvm/test/CodeGen/RISCV/rvv/vmv.v.v-rv64.ll llvm/test/CodeGen/RISCV/rvv/vmv.v.x-rv32.ll llvm/test/CodeGen/RISCV/rvv/vmv.v.x-rv64.ll Modified: llvm/include/llvm/IR/IntrinsicsRISCV.td llvm/lib/Target/RISCV/RISCVInstrInfoVPseudos.td Removed: diff --git a/llvm/include/llvm/IR/IntrinsicsRISCV.td b/llvm/include/llvm/IR/IntrinsicsRISCV.td index 6d20f39a4020..c207100adb7e 100644 --- a/llvm/include/llvm/IR/IntrinsicsRISCV.td +++ b/llvm/include/llvm/IR/IntrinsicsRISCV.td @@ -229,6 +229,14 @@ let TargetPrefix = "riscv" in { let ExtendOperand = 3; } + // For vmv.v.v, vmv.v.x, vmv.v.i + // Input: (vector_in/scalar_in, vl) + class RISCVUnary : Intrinsic<[llvm_anyvector_ty], + [llvm_any_ty, llvm_anyint_ty], + [IntrNoMem] >, RISCVVIntrinsic { +let ExtendOperand = 1; + } + multiclass RISCVUSLoad { def "int_riscv_" # NAME : RISCVUSLoad; def "int_riscv_" # NAME # "_mask" : RISCVUSLoadMask; @@ -328,4 +336,7 @@ let TargetPrefix = "riscv" in { defm vsadd : RISCVSaturatingBinaryAAX; defm vssubu : RISCVSaturatingBinaryAAX; defm vssub : RISCVSaturatingBinaryAAX; + + def int_riscv_vmv_v_v : RISCVUnary; + def int_riscv_vmv_v_x : RISCVUnary; } // TargetPrefix = "riscv" diff --git a/llvm/lib/Target/RISCV/RISCVInstrInfoVPseudos.td b/llvm/lib/Target/RISCV/RISCVInstrInfoVPseudos.td index 3363aed34f39..bd4694633791 100644 --- a/llvm/lib/Target/RISCV/RISCVInstrInfoVPseudos.td +++ b/llvm/lib/Target/RISCV/RISCVInstrInfoVPseudos.td @@ -401,6 +401,22 @@ class VPseudoSStoreMask: let BaseInstr = !cast(PseudoToVInst.VInst); } +// Unary instruction that is never masked so HasDummyMask=0. +class VPseudoUnaryNoDummyMask : +Pseudo<(outs RetClass:$rd), + (ins Op2Class:$rs1, GPR:$vl, ixlenimm:$sew), []>, +RISCVVPseudo { + let mayLoad = 0; + let mayStore = 0; + let hasSideEffects = 0; + let usesCustomInserter = 1; + let Uses = [VL, VTYPE]; + let VLIndex = 2; + let SEWIndex = 3; + let BaseInstr = !cast(PseudoToVInst.VInst); +} + class VPseudoBinaryNoMask; } +multiclass VPseudoUnaryV_V_X_I_NoDummyMask { + foreach m = MxList.m in { +let VLMul = m.value in { + def "_V_" # m.MX : VPseudoUnaryNoDummyMask; + def "_X_" # m.MX : VPseudoUnaryNoDummyMask; + def "_I_" # m.MX : VPseudoUnaryNoDummyMask; +} + } +} + multiclass VPseudoBinaryV_VV_VX_VI { defm "" : VPseudoBinaryV_VV; defm "" : VPseudoBinaryV_VX; @@ -1295,6 +1321,12 @@ defm PseudoVWMUL : VPseudoBinaryW_VV_VX; defm PseudoVWMULU : VPseudoBinaryW_VV_VX; defm PseudoVWMULSU : VPseudoBinaryW_VV_VX; +//===--===// +// 12.17. Vector Integer Move Instructions +//===--===// + +defm PseudoVMV_V : VPseudoUnaryV_V_X_I_NoDummyMask; + //===--===// // 13.1. Vector Single-Width Saturating Add and Subtract //===--===// @@ -1444,6 +1476,25 @@ defm "" : VPatBinaryW_VV_VX<"int_riscv_vwmul", "PseudoVWMUL">; defm "" : VPatBinaryW_VV_VX<"int_riscv_vwmulu", "PseudoVWMULU">; defm "" : VPatBinaryW_VV_VX<"int_riscv_vwmulsu", "PseudoVWMULSU">; +//===--===// +// 12.17. Vector Integer Move Instructions +//===--===// +foreach vti = AllVectors in { + def : Pat<(vti.Vector (int_riscv_vmv_v_v (vti.Vector vti.RegClass:$rs1), + GPR:$vl)), +(!cast("PseudoVMV_V_V_"#vti.LMul.MX) + $rs1, (NoX0 GPR:$vl), vti.SEW)>; +} + +foreach vti = AllIntegerVectors in { + def : Pat<(vti.Vector (int_riscv_vmv_v_x GPR:$rs2, GPR:$vl)), +(!cast("PseudoVMV_V_X_"#vti.LMul.MX) + $rs2, (NoX0 GPR:$vl), vti.SEW)>; + def : Pat<(vti.Vector (int_riscv_vmv_v_x simm5:$imm5, GPR:$vl)), +(!cast("PseudoVMV_V_I_"#vti.LMul.MX) + simm5:$imm5, (NoX0 GPR:$vl), vti.SEW)>; +} + //===--===
[llvm-branch-commits] [llvm] a74941d - Revert "[BasicAA] Handle two unknown sizes for GEPs"
Author: Florian Hahn Date: 2020-12-18T17:59:12Z New Revision: a74941da716d29a1d962d17b8112c40a8a45f9e7 URL: https://github.com/llvm/llvm-project/commit/a74941da716d29a1d962d17b8112c40a8a45f9e7 DIFF: https://github.com/llvm/llvm-project/commit/a74941da716d29a1d962d17b8112c40a8a45f9e7.diff LOG: Revert "[BasicAA] Handle two unknown sizes for GEPs" Temporarily revert commit 8b1c4e310c2f9686cad925ad81d8e2be10a1ef3c. After 8b1c4e310c2f the compile-time for `MultiSource/Benchmarks/MiBench/consumer-lame` dramatically increases with -O3 & LTO, causing issues for builders with that configuration. I filed PR48553 with a smallish reproducer that shows a 10-100x compile time increase. Added: Modified: llvm/lib/Analysis/BasicAliasAnalysis.cpp llvm/test/Analysis/BasicAA/phi-aa.ll llvm/test/Analysis/BasicAA/recphi.ll llvm/test/Transforms/LoopVectorize/ARM/pointer_iv.ll llvm/test/Transforms/LoopVersioning/exit-block-dominates-rt-check-block.ll Removed: diff --git a/llvm/lib/Analysis/BasicAliasAnalysis.cpp b/llvm/lib/Analysis/BasicAliasAnalysis.cpp index 3e22ce84d181..caa0635459b3 100644 --- a/llvm/lib/Analysis/BasicAliasAnalysis.cpp +++ b/llvm/lib/Analysis/BasicAliasAnalysis.cpp @@ -1098,22 +1098,6 @@ AliasResult BasicAAResult::aliasGEP( const GEPOperator *GEP1, LocationSize V1Size, const AAMDNodes &V1AAInfo, const Value *V2, LocationSize V2Size, const AAMDNodes &V2AAInfo, const Value *UnderlyingV1, const Value *UnderlyingV2, AAQueryInfo &AAQI) { - // If both accesses are unknown size, we can only check whether the - // underlying objects are diff erent. - if (!V1Size.hasValue() && !V2Size.hasValue()) { -// If the other operand is a phi/select, let phi/select handling perform -// this check. Otherwise the same recursive walk is done twice. -if (!isa(V2) && !isa(V2)) { - AliasResult BaseAlias = - aliasCheck(UnderlyingV1, LocationSize::beforeOrAfterPointer(), - AAMDNodes(), UnderlyingV2, - LocationSize::beforeOrAfterPointer(), AAMDNodes(), AAQI); - if (BaseAlias == NoAlias) -return NoAlias; -} -return MayAlias; - } - DecomposedGEP DecompGEP1 = DecomposeGEPExpression(GEP1, DL, &AC, DT); DecomposedGEP DecompGEP2 = DecomposeGEPExpression(V2, DL, &AC, DT); @@ -1172,6 +1156,10 @@ AliasResult BasicAAResult::aliasGEP( // instruction. If one pointer is a GEP with a non-zero index of the other // pointer, we know they cannot alias. +// If both accesses are unknown size, we can't do anything useful here. +if (!V1Size.hasValue() && !V2Size.hasValue()) + return MayAlias; + AliasResult R = aliasCheck( UnderlyingV1, LocationSize::beforeOrAfterPointer(), AAMDNodes(), V2, V2Size, V2AAInfo, AAQI, nullptr, UnderlyingV2); diff --git a/llvm/test/Analysis/BasicAA/phi-aa.ll b/llvm/test/Analysis/BasicAA/phi-aa.ll index 3446d0bef849..bf5915f1e0fe 100644 --- a/llvm/test/Analysis/BasicAA/phi-aa.ll +++ b/llvm/test/Analysis/BasicAA/phi-aa.ll @@ -152,7 +152,8 @@ loop: } ; CHECK-LABEL: phi_and_gep_unknown_size -; CHECK: NoModRef: call void @llvm.memset.p0i8.i32(i8* %g, i8 0, i32 %size, i1 false) <-> call void @llvm.memset.p0i8.i32(i8* %z, i8 0, i32 %size, i1 false) +; CHECK: Just Mod: call void @llvm.memset.p0i8.i32(i8* %g, i8 0, i32 %size, i1 false) <-> call void @llvm.memset.p0i8.i32(i8* %z, i8 0, i32 %size, i1 false) +; TODO: This should be NoModRef. define void @phi_and_gep_unknown_size(i1 %c, i8* %x, i8* %y, i8* noalias %z, i32 %size) { entry: br i1 %c, label %true, label %false diff --git a/llvm/test/Analysis/BasicAA/recphi.ll b/llvm/test/Analysis/BasicAA/recphi.ll index 882128a2daf0..7f8bc9d7b668 100644 --- a/llvm/test/Analysis/BasicAA/recphi.ll +++ b/llvm/test/Analysis/BasicAA/recphi.ll @@ -267,8 +267,9 @@ exit: ; CHECK: NoAlias: i8* %a, i8* %p.base ; CHECK: NoAlias: i8* %a, i8* %p.outer ; CHECK: NoAlias: i8* %a, i8* %p.outer.next -; CHECK: NoAlias: i8* %a, i8* %p.inner +; CHECK: MayAlias: i8* %a, i8* %p.inner ; CHECK: NoAlias: i8* %a, i8* %p.inner.next +; TODO: (a, p.inner) could be NoAlias define void @nested_loop2(i1 %c, i1 %c2, i8* noalias %p.base) { entry: %a = alloca i8 diff --git a/llvm/test/Transforms/LoopVectorize/ARM/pointer_iv.ll b/llvm/test/Transforms/LoopVectorize/ARM/pointer_iv.ll index b30e342d9a3f..6c6cfa9fadc3 100644 --- a/llvm/test/Transforms/LoopVectorize/ARM/pointer_iv.ll +++ b/llvm/test/Transforms/LoopVectorize/ARM/pointer_iv.ll @@ -876,31 +876,62 @@ for.body: define hidden void @mult_ptr_iv(i8* noalias nocapture readonly %x, i8* noalias nocapture %z) { ; CHECK-LABEL: @mult_ptr_iv( ; CHECK-NEXT: entry: +; CHECK-NEXT:[[SCEVGEP:%.*]] = getelementptr i8, i8* [[Z:%.*]], i32 3000 +; CHECK-NEXT:[[SCEVGEP1:%.*]] = getelementptr i8, i8* [[X:%.*]], i32 3000 +; CHECK-NEXT:[[BOUND0:%.*]]
[llvm-branch-commits] [llvm] d551e40 - [AIX] Change the code based on https://lists.llvm.org/pipermail/llvm-commits/Week-of-Mon-20201214/864235.html
Author: diggerlin Date: 2020-12-18T13:02:41-05:00 New Revision: d551e40f1cff7a63218f34112bd0dddaa2b12dbb URL: https://github.com/llvm/llvm-project/commit/d551e40f1cff7a63218f34112bd0dddaa2b12dbb DIFF: https://github.com/llvm/llvm-project/commit/d551e40f1cff7a63218f34112bd0dddaa2b12dbb.diff LOG: [AIX] Change the code based on https://lists.llvm.org/pipermail/llvm-commits/Week-of-Mon-20201214/864235.html Summary: change the code based on the discussion as: https://lists.llvm.org/pipermail/llvm-commits/Week-of-Mon-20201214/864235.html Added: Modified: llvm/lib/Target/PowerPC/PPCMachineFunctionInfo.cpp Removed: diff --git a/llvm/lib/Target/PowerPC/PPCMachineFunctionInfo.cpp b/llvm/lib/Target/PowerPC/PPCMachineFunctionInfo.cpp index d364eb9d3996..c976a9c62d3b 100644 --- a/llvm/lib/Target/PowerPC/PPCMachineFunctionInfo.cpp +++ b/llvm/lib/Target/PowerPC/PPCMachineFunctionInfo.cpp @@ -94,6 +94,6 @@ void PPCFunctionInfo::appendParameterType(ParamType Type) { } assert(Type != FixedType && "FixedType should already be handled."); - if (30 - Bits >= 0) + if (Bits < 31) ParameterType |= Type << (30 - Bits); } ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [clang] 5e5ef53 - [clang-format][NFC] Expand BreakBeforeBraces examples
Author: Björn Schäpers Date: 2020-12-18T19:08:03+01:00 New Revision: 5e5ef5359742c3feb6f41058a356a28c7ab3ea6d URL: https://github.com/llvm/llvm-project/commit/5e5ef5359742c3feb6f41058a356a28c7ab3ea6d DIFF: https://github.com/llvm/llvm-project/commit/5e5ef5359742c3feb6f41058a356a28c7ab3ea6d.diff LOG: [clang-format][NFC] Expand BreakBeforeBraces examples Differential Revision: https://reviews.llvm.org/D93170 Added: Modified: clang/docs/ClangFormatStyleOptions.rst clang/include/clang/Format/Format.h Removed: diff --git a/clang/docs/ClangFormatStyleOptions.rst b/clang/docs/ClangFormatStyleOptions.rst index f63ed168f099..32942648378b 100644 --- a/clang/docs/ClangFormatStyleOptions.rst +++ b/clang/docs/ClangFormatStyleOptions.rst @@ -1205,16 +1205,47 @@ the configuration (without a prefix: ``Auto``). .. code-block:: c++ - try { -foo(); - } catch () { + namespace N { + enum E { +E1, +E2, + }; + + class C { + public: +C(); + }; + + bool baz(int i) { +try { + do { +switch (i) { +case 1: { + foobar(); + break; +} +default: { + break; +} +} + } while (--i); + return true; +} catch (...) { + handleError(); + return false; +} } - void foo() { bar(); } - class foo {}; - if (foo()) { - } else { + + void foo(bool b) { +if (b) { + baz(2); +} else { + baz(5); +} } - enum X : int { A, B }; + + void bar() { foo(true); } + } // namespace N * ``BS_Linux`` (in configuration: ``Linux``) Like ``Attach``, but break before braces on function, namespace and @@ -1222,18 +1253,51 @@ the configuration (without a prefix: ``Auto``). .. code-block:: c++ - try { -foo(); - } catch () { - } - void foo() { bar(); } - class foo + namespace N { + enum E { +E1, +E2, }; - if (foo()) { - } else { + + class C + { + public: +C(); + }; + + bool baz(int i) + { +try { + do { +switch (i) { +case 1: { + foobar(); + break; +} +default: { + break; +} +} + } while (--i); + return true; +} catch (...) { + handleError(); + return false; +} } - enum X : int { A, B }; + + void foo(bool b) + { +if (b) { + baz(2); +} else { + baz(5); +} + } + + void bar() { foo(true); } + } // namespace N * ``BS_Mozilla`` (in configuration: ``Mozilla``) Like ``Attach``, but break before braces on enum, function, and record @@ -1241,18 +1305,51 @@ the configuration (without a prefix: ``Auto``). .. code-block:: c++ - try { -foo(); - } catch () { - } - void foo() { bar(); } - class foo + namespace N { + enum E { +E1, +E2, }; - if (foo()) { - } else { + + class C + { + public: +C(); + }; + + bool baz(int i) + { +try { + do { +switch (i) { +case 1: { + foobar(); + break; +} +default: { + break; +} +} + } while (--i); + return true; +} catch (...) { + handleError(); + return false; +} } - enum X : int { A, B }; + + void foo(bool b) + { +if (b) { + baz(2); +} else { + baz(5); +} + } + + void bar() { foo(true); } + } // namespace N * ``BS_Stroustrup`` (in configuration: ``Stroustrup``) Like ``Attach``, but break before function definitions, ``catch``, and @@ -1260,75 +1357,175 @@ the configuration (without a prefix: ``Auto``). .. code-block:: c++ - try { -foo(); - } - catch () { - } - void foo() { bar(); } - class foo { + namespace N { + enum E { +E1, +E2, }; - if (foo()) { + + class C { + public: +C(); + }; + + bool baz(int i) + { +try { + do { +switch (i) { +case 1: { + foobar(); + break; +} +default: { + break; +} +} + } while (--i); + return true; +} +catch (...) { + handleError(); + return false; +} } - else { +
[llvm-branch-commits] [llvm] 5f75dcf - [DebugInfo] Support Fortran 'use ' statement.
Author: Chih-Ping Chen Date: 2020-12-18T13:10:57-05:00 New Revision: 5f75dcf5719f8ba2819b73109888175cf92fe253 URL: https://github.com/llvm/llvm-project/commit/5f75dcf5719f8ba2819b73109888175cf92fe253 DIFF: https://github.com/llvm/llvm-project/commit/5f75dcf5719f8ba2819b73109888175cf92fe253.diff LOG: [DebugInfo] Support Fortran 'use ' statement. The main change is to add a 'IsDecl' field to DIModule so that when IsDecl is set to true, the debug info entry generated for the module would be marked as a declaration. That way, the debugger would look up the definition of the module in the gloabl scope. Please see the comments in llvm/test/DebugInfo/X86/dimodule.ll for what the debug info entries would look like. Differential Revision: https://reviews.llvm.org/D93462 Added: llvm/test/Bitcode/DIModule-fortran-external-module.ll llvm/test/DebugInfo/X86/dimodule.ll Modified: llvm/include/llvm/IR/DIBuilder.h llvm/include/llvm/IR/DebugInfoMetadata.h llvm/lib/AsmParser/LLParser.cpp llvm/lib/Bitcode/Reader/MetadataLoader.cpp llvm/lib/Bitcode/Writer/BitcodeWriter.cpp llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp llvm/lib/IR/AsmWriter.cpp llvm/lib/IR/DIBuilder.cpp llvm/lib/IR/DebugInfoMetadata.cpp llvm/lib/IR/LLVMContextImpl.h llvm/test/Assembler/dimodule.ll llvm/unittests/IR/MetadataTest.cpp Removed: diff --git a/llvm/include/llvm/IR/DIBuilder.h b/llvm/include/llvm/IR/DIBuilder.h index 11c6e9784cfa..e0238567f251 100644 --- a/llvm/include/llvm/IR/DIBuilder.h +++ b/llvm/include/llvm/IR/DIBuilder.h @@ -772,14 +772,18 @@ namespace llvm { ///definitions as they would appear on a command line. /// \param IncludePath The path to the module map file. /// \param APINotesFile The path to an API notes file for this module. -/// \param FileSource file of the module declaration. Used for -///Fortran modules. -/// \param LineNo Source line number of the module declaration. +/// \param FileSource file of the module. ///Used for Fortran modules. +/// \param LineNo Source line number of the module. +///Used for Fortran modules. +/// \param IsDecl This is a module declaration; default to false; +///when set to true, only Scope and Name are required +///as this entry is just a hint for the debugger to find +///the corresponding definition in the global scope. DIModule *createModule(DIScope *Scope, StringRef Name, StringRef ConfigurationMacros, StringRef IncludePath, StringRef APINotesFile = {}, DIFile *File = nullptr, - unsigned LineNo = 0); + unsigned LineNo = 0, bool IsDecl = false); /// This creates a descriptor for a lexical block with a new file /// attached. This merely extends the existing diff --git a/llvm/include/llvm/IR/DebugInfoMetadata.h b/llvm/include/llvm/IR/DebugInfoMetadata.h index 0ba4c09dc92f..94b3beb4effd 100644 --- a/llvm/include/llvm/IR/DebugInfoMetadata.h +++ b/llvm/include/llvm/IR/DebugInfoMetadata.h @@ -2297,49 +2297,52 @@ class DIModule : public DIScope { friend class LLVMContextImpl; friend class MDNode; unsigned LineNo; + bool IsDecl; DIModule(LLVMContext &Context, StorageType Storage, unsigned LineNo, - ArrayRef Ops) + bool IsDecl, ArrayRef Ops) : DIScope(Context, DIModuleKind, Storage, dwarf::DW_TAG_module, Ops), -LineNo(LineNo) {} +LineNo(LineNo), IsDecl(IsDecl) {} ~DIModule() = default; static DIModule *getImpl(LLVMContext &Context, DIFile *File, DIScope *Scope, StringRef Name, StringRef ConfigurationMacros, StringRef IncludePath, StringRef APINotesFile, - unsigned LineNo, StorageType Storage, + unsigned LineNo, bool IsDecl, StorageType Storage, bool ShouldCreate = true) { return getImpl(Context, File, Scope, getCanonicalMDString(Context, Name), getCanonicalMDString(Context, ConfigurationMacros), getCanonicalMDString(Context, IncludePath), - getCanonicalMDString(Context, APINotesFile), LineNo, Storage, - ShouldCreate); + getCanonicalMDString(Context, APINotesFile), LineNo, IsDecl, + Storage, ShouldCreate); } static DIModule *getImpl(LLVMContext &Context, Metadata *File, Metadata *Scope, MDString *Name, MDString *ConfigurationMacros, MDString *IncludePath, - MDString *APINotesFile, unsigned LineNo, +
[llvm-branch-commits] [llvm] e9289dc - [InstSimplify] Don't miscompile `X == 0 ? abs(X) : -abs(X) --> -abs(X)` xform
Author: Roman Lebedev Date: 2020-12-18T21:18:13+03:00 New Revision: e9289dc25f7923abff9ac762bd3f6819c0605f20 URL: https://github.com/llvm/llvm-project/commit/e9289dc25f7923abff9ac762bd3f6819c0605f20 DIFF: https://github.com/llvm/llvm-project/commit/e9289dc25f7923abff9ac762bd3f6819c0605f20.diff LOG: [InstSimplify] Don't miscompile `X == 0 ? abs(X) : -abs(X) --> -abs(X)` xform The transform wasn't checking that the LHS of the comparison *is* the `X` in question... This is the miscompile that was holding up D87188. Thanks to Dave Green for producing an actionable reproducer! Added: Modified: llvm/lib/Analysis/InstructionSimplify.cpp llvm/test/Transforms/InstSimplify/abs_intrinsic.ll Removed: diff --git a/llvm/lib/Analysis/InstructionSimplify.cpp b/llvm/lib/Analysis/InstructionSimplify.cpp index 35c21a023bae..55f3bc4f2923 100644 --- a/llvm/lib/Analysis/InstructionSimplify.cpp +++ b/llvm/lib/Analysis/InstructionSimplify.cpp @@ -4020,11 +4020,12 @@ static Value *simplifySelectWithICmpCond(Value *CondVal, Value *TrueVal, // X == 0 ? abs(X) : -abs(X) --> -abs(X) // X == 0 ? -abs(X) : abs(X) --> abs(X) -if (match(TrueVal, m_Intrinsic(m_Value(X))) && -match(FalseVal, m_Neg(m_Intrinsic(m_Specific(X) +if (match(TrueVal, m_Intrinsic(m_Specific(CmpLHS))) && +match(FalseVal, m_Neg(m_Intrinsic(m_Specific(CmpLHS) return FalseVal; -if (match(TrueVal, m_Neg(m_Intrinsic(m_Value(X && -match(FalseVal, m_Intrinsic(m_Specific(X +if (match(TrueVal, + m_Neg(m_Intrinsic(m_Specific(CmpLHS && +match(FalseVal, m_Intrinsic(m_Specific(CmpLHS return FalseVal; } diff --git a/llvm/test/Transforms/InstSimplify/abs_intrinsic.ll b/llvm/test/Transforms/InstSimplify/abs_intrinsic.ll index e0bb1704bc48..9d5980fbf782 100644 --- a/llvm/test/Transforms/InstSimplify/abs_intrinsic.ll +++ b/llvm/test/Transforms/InstSimplify/abs_intrinsic.ll @@ -225,7 +225,10 @@ define i32 @select_abs_of_abs_eq(i32 %x) { define i32 @select_abs_of_abs_eq_wrong(i32 %x, i32 %y) { ; CHECK-LABEL: @select_abs_of_abs_eq_wrong( ; CHECK-NEXT:[[ABS:%.*]] = call i32 @llvm.abs.i32(i32 [[X:%.*]], i1 false) -; CHECK-NEXT:ret i32 [[ABS]] +; CHECK-NEXT:[[NEG:%.*]] = sub i32 0, [[ABS]] +; CHECK-NEXT:[[CMP:%.*]] = icmp eq i32 [[Y:%.*]], 0 +; CHECK-NEXT:[[SEL:%.*]] = select i1 [[CMP]], i32 [[NEG]], i32 [[ABS]] +; CHECK-NEXT:ret i32 [[SEL]] ; %abs = call i32 @llvm.abs.i32(i32 %x, i1 false) %neg = sub i32 0, %abs @@ -264,7 +267,9 @@ define i32 @select_nabs_of_abs_eq_wrong(i32 %x, i32 %y) { ; CHECK-LABEL: @select_nabs_of_abs_eq_wrong( ; CHECK-NEXT:[[ABS:%.*]] = call i32 @llvm.abs.i32(i32 [[X:%.*]], i1 false) ; CHECK-NEXT:[[NEG:%.*]] = sub i32 0, [[ABS]] -; CHECK-NEXT:ret i32 [[NEG]] +; CHECK-NEXT:[[CMP:%.*]] = icmp eq i32 [[Y:%.*]], 0 +; CHECK-NEXT:[[SEL:%.*]] = select i1 [[CMP]], i32 [[ABS]], i32 [[NEG]] +; CHECK-NEXT:ret i32 [[SEL]] ; %abs = call i32 @llvm.abs.i32(i32 %x, i1 false) %neg = sub i32 0, %abs ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [llvm] 9b183a1 - [NFC][InstSimplify] Add miscompiled testcase from D87188/D87197
Author: Roman Lebedev Date: 2020-12-18T21:18:13+03:00 New Revision: 9b183a1452c7e5091be01661188b7cb04d842a4c URL: https://github.com/llvm/llvm-project/commit/9b183a1452c7e5091be01661188b7cb04d842a4c DIFF: https://github.com/llvm/llvm-project/commit/9b183a1452c7e5091be01661188b7cb04d842a4c.diff LOG: [NFC][InstSimplify] Add miscompiled testcase from D87188/D87197 Thanks to Dave Green for producing an actionable reproducer! It is (obviously) a miscompile: ``` define i32 @select_abs_of_abs_eq_wrong(i32 %x, i32 %y) { %0: %abs = abs i32 %x, 0 %neg = sub i32 0, %abs %cmp = icmp eq i32 %y, 0 %sel = select i1 %cmp, i32 %neg, i32 %abs ret i32 %sel } => define i32 @select_abs_of_abs_eq_wrong(i32 %x, i32 %y) { %0: %abs = abs i32 %x, 0 ret i32 %abs } Transformation doesn't verify! ERROR: Value mismatch Example: i32 %x = #xe000 (3758096384, -536870912) i32 %y = #x (0) Source: i32 %abs = #x2000 (536870912) i32 %neg = #xe000 (3758096384, -536870912) i1 %cmp = #x1 (1) i32 %sel = #xe000 (3758096384, -536870912) Target: i32 %abs = #x2000 (536870912) Source value: #xe000 (3758096384, -536870912) Target value: #x2000 (536870912) Alive2: Transform doesn't verify! ``` Added: Modified: llvm/test/Transforms/InstSimplify/abs_intrinsic.ll Removed: diff --git a/llvm/test/Transforms/InstSimplify/abs_intrinsic.ll b/llvm/test/Transforms/InstSimplify/abs_intrinsic.ll index 4598c5732e12..e0bb1704bc48 100644 --- a/llvm/test/Transforms/InstSimplify/abs_intrinsic.ll +++ b/llvm/test/Transforms/InstSimplify/abs_intrinsic.ll @@ -221,6 +221,19 @@ define i32 @select_abs_of_abs_eq(i32 %x) { ret i32 %sel } +; The comparison is not with the same value we take abs() of, so this isn't the pattern. +define i32 @select_abs_of_abs_eq_wrong(i32 %x, i32 %y) { +; CHECK-LABEL: @select_abs_of_abs_eq_wrong( +; CHECK-NEXT:[[ABS:%.*]] = call i32 @llvm.abs.i32(i32 [[X:%.*]], i1 false) +; CHECK-NEXT:ret i32 [[ABS]] +; + %abs = call i32 @llvm.abs.i32(i32 %x, i1 false) + %neg = sub i32 0, %abs + %cmp = icmp eq i32 %y, 0 ; not %x + %sel = select i1 %cmp, i32 %neg, i32 %abs + ret i32 %sel +} + define i32 @select_abs_of_abs_ne(i32 %x) { ; CHECK-LABEL: @select_abs_of_abs_ne( ; CHECK-NEXT:[[ABS:%.*]] = call i32 @llvm.abs.i32(i32 [[X:%.*]], i1 false) @@ -246,6 +259,20 @@ define i32 @select_nabs_of_abs_eq(i32 %x) { ret i32 %sel } +; The comparison is not with the same value we take abs() of, so this isn't the pattern. +define i32 @select_nabs_of_abs_eq_wrong(i32 %x, i32 %y) { +; CHECK-LABEL: @select_nabs_of_abs_eq_wrong( +; CHECK-NEXT:[[ABS:%.*]] = call i32 @llvm.abs.i32(i32 [[X:%.*]], i1 false) +; CHECK-NEXT:[[NEG:%.*]] = sub i32 0, [[ABS]] +; CHECK-NEXT:ret i32 [[NEG]] +; + %abs = call i32 @llvm.abs.i32(i32 %x, i1 false) + %neg = sub i32 0, %abs + %cmp = icmp eq i32 %y, 0 + %sel = select i1 %cmp, i32 %abs, i32 %neg + ret i32 %sel +} + define i32 @select_nabs_of_abs_ne(i32 %x) { ; CHECK-LABEL: @select_nabs_of_abs_ne( ; CHECK-NEXT:[[ABS:%.*]] = call i32 @llvm.abs.i32(i32 [[X:%.*]], i1 false) ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [llvm] 897c985 - [InstCombine] Canonicalize SPF to abs intrinsic
Author: Roman Lebedev Date: 2020-12-18T21:18:14+03:00 New Revision: 897c985e1e21927b2870f964bb07ff293bd74407 URL: https://github.com/llvm/llvm-project/commit/897c985e1e21927b2870f964bb07ff293bd74407 DIFF: https://github.com/llvm/llvm-project/commit/897c985e1e21927b2870f964bb07ff293bd74407.diff LOG: [InstCombine] Canonicalize SPF to abs intrinsic This patch enables canonicalization of SPF_ABS and SPF_ABS to the abs intrinsic. This is a recommit, the original try was 05d4c4ebc2fb006b8a2bd05b24c6aba10dd2eef8, but it was reverted due to an apparent miscompile, which since then has just been fixed by the previous commit. Differential Revision: https://reviews.llvm.org/D87188 Added: Modified: clang/test/CodeGen/builtins-wasm.c llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp llvm/test/Transforms/InstCombine/abs-1.ll llvm/test/Transforms/InstCombine/abs_abs.ll llvm/test/Transforms/InstCombine/call-callconv.ll llvm/test/Transforms/InstCombine/cttz-abs.ll llvm/test/Transforms/InstCombine/icmp.ll llvm/test/Transforms/InstCombine/max-of-nots.ll llvm/test/Transforms/InstCombine/select_meta.ll llvm/test/Transforms/InstCombine/sub-of-negatible.ll llvm/test/Transforms/PhaseOrdering/X86/vector-reductions.ll llvm/test/Transforms/PhaseOrdering/min-max-abs-cse.ll Removed: diff --git a/clang/test/CodeGen/builtins-wasm.c b/clang/test/CodeGen/builtins-wasm.c index 92fd9843e44b..76dd2622fe2f 100644 --- a/clang/test/CodeGen/builtins-wasm.c +++ b/clang/test/CodeGen/builtins-wasm.c @@ -384,26 +384,20 @@ u8x16 sub_saturate_u_i8x16(u8x16 x, u8x16 y) { i8x16 abs_i8x16(i8x16 v) { return __builtin_wasm_abs_i8x16(v); - // WEBASSEMBLY: %neg = sub <16 x i8> zeroinitializer, %v - // WEBASSEMBLY: %abscond = icmp slt <16 x i8> %v, zeroinitializer - // WEBASSEMBLY: %abs = select <16 x i1> %abscond, <16 x i8> %neg, <16 x i8> %v - // WEBASSEMBLY: ret <16 x i8> %abs + // WEBASSEMBLY: call <16 x i8> @llvm.abs.v16i8(<16 x i8> %v, i1 false) + // WEBASSEMBLY-NEXT: ret } i16x8 abs_i16x8(i16x8 v) { return __builtin_wasm_abs_i16x8(v); - // WEBASSEMBLY: %neg = sub <8 x i16> zeroinitializer, %v - // WEBASSEMBLY: %abscond = icmp slt <8 x i16> %v, zeroinitializer - // WEBASSEMBLY: %abs = select <8 x i1> %abscond, <8 x i16> %neg, <8 x i16> %v - // WEBASSEMBLY: ret <8 x i16> %abs + // WEBASSEMBLY: call <8 x i16> @llvm.abs.v8i16(<8 x i16> %v, i1 false) + // WEBASSEMBLY-NEXT: ret } i32x4 abs_i32x4(i32x4 v) { return __builtin_wasm_abs_i32x4(v); - // WEBASSEMBLY: %neg = sub <4 x i32> zeroinitializer, %v - // WEBASSEMBLY: %abscond = icmp slt <4 x i32> %v, zeroinitializer - // WEBASSEMBLY: %abs = select <4 x i1> %abscond, <4 x i32> %neg, <4 x i32> %v - // WEBASSEMBLY: ret <4 x i32> %abs + // WEBASSEMBLY: call <4 x i32> @llvm.abs.v4i32(<4 x i32> %v, i1 false) + // WEBASSEMBLY-NEXT: ret } i8x16 min_s_i8x16(i8x16 x, i8x16 y) { diff --git a/llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp b/llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp index d6f8d2dcc7ce..e05fa4ffa403 100644 --- a/llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp +++ b/llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp @@ -1047,89 +1047,28 @@ static Instruction *canonicalizeMinMaxWithConstant(SelectInst &Sel, return &Sel; } -/// There are many select variants for each of ABS/NABS. -/// In matchSelectPattern(), there are diff erent compare constants, compare -/// predicates/operands and select operands. -/// In isKnownNegation(), there are diff erent formats of negated operands. -/// Canonicalize all these variants to 1 pattern. -/// This makes CSE more likely. static Instruction *canonicalizeAbsNabs(SelectInst &Sel, ICmpInst &Cmp, InstCombinerImpl &IC) { if (!Cmp.hasOneUse() || !isa(Cmp.getOperand(1))) return nullptr; - // Choose a sign-bit check for the compare (likely simpler for codegen). - // ABS: (X hasOneUse() || (RHS->hasNUses(2) && CmpUsesNegatedOp))) - return nullptr; + bool IntMinIsPoison = match(RHS, m_NSWNeg(m_Specific(LHS))); + Constant *IntMinIsPoisonC = + ConstantInt::get(Type::getInt1Ty(Sel.getContext()), IntMinIsPoison); + Instruction *Abs = + IC.Builder.CreateBinaryIntrinsic(Intrinsic::abs, LHS, IntMinIsPoisonC); - // Create the canonical compare: icmp slt LHS 0. - if (!CmpCanonicalized) { -Cmp.setPredicate(ICmpInst::ICMP_SLT); -Cmp.setOperand(1, ConstantInt::getNullValue(Cmp.getOperand(0)->getType())); -if (CmpUsesNegatedOp) - Cmp.setOperand(0, LHS); - } - - // Create the canonical RHS: RHS = sub (0, LHS). - if (!RHSCanonicalized) { -assert(RHS->hasOneUse() && "RHS use number is not right"); -RHS = IC.Builder.CreateNeg(LHS); -if (TVal == LHS) { - // Replace false value. - IC.replaceOperand(Sel, 2, RHS); - FVal = RHS; -} else
[llvm-branch-commits] [llvm] 5ac3772 - [GVNHoist] Remove successorDominate (NFC)
Author: Kazu Hirata Date: 2020-12-18T10:29:52-08:00 New Revision: 5ac37725df32c5d01460cbe221bd2a7481763c9d URL: https://github.com/llvm/llvm-project/commit/5ac37725df32c5d01460cbe221bd2a7481763c9d DIFF: https://github.com/llvm/llvm-project/commit/5ac37725df32c5d01460cbe221bd2a7481763c9d.diff LOG: [GVNHoist] Remove successorDominate (NFC) The function was introduced on Aug 25, 2016 in commit 5f0d0e60d11b8d2e48aacf31a82762280f9a8712. Its last use was removed on Sep 13, 2017 in commit dfa8741c9693c344477c842a25ee0cb6a6f59fcd. Added: Modified: llvm/lib/Transforms/Scalar/GVNHoist.cpp Removed: diff --git a/llvm/lib/Transforms/Scalar/GVNHoist.cpp b/llvm/lib/Transforms/Scalar/GVNHoist.cpp index 769830da4894..8478521952b1 100644 --- a/llvm/lib/Transforms/Scalar/GVNHoist.cpp +++ b/llvm/lib/Transforms/Scalar/GVNHoist.cpp @@ -293,15 +293,6 @@ class GVNHoist { // Return true when there are exception handling in BB. bool hasEH(const BasicBlock *BB); - // Return true when a successor of BB dominates A. - bool successorDominate(const BasicBlock *BB, const BasicBlock *A) { -for (const BasicBlock *Succ : successors(BB)) - if (DT->dominates(Succ, A)) -return true; - -return false; - } - // Return true when I1 appears before I2 in the instructions of BB. bool firstInBB(const Instruction *I1, const Instruction *I2) { assert(I1->getParent() == I2->getParent()); ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [llvm] 86d282b - [RISCV] Add intrinsics for vmv.x.s and vmv.s.x
Author: Craig Topper Date: 2020-12-18T10:30:48-08:00 New Revision: 86d282baede58f675ea6df8d64bfee582b6679b7 URL: https://github.com/llvm/llvm-project/commit/86d282baede58f675ea6df8d64bfee582b6679b7 DIFF: https://github.com/llvm/llvm-project/commit/86d282baede58f675ea6df8d64bfee582b6679b7.diff LOG: [RISCV] Add intrinsics for vmv.x.s and vmv.s.x This adds intrinsics for vmv.x.s and vmv.s.x. I've used stricter type constraints on these intrinsics than what we've been doing on the arithmetic intrinsics so far. This will allow us to not need to pass the scalar type to the Intrinsic::getDeclaration call when creating these intrinsics. A custom ISD is used for vmv.x.s in order to implement the change in computeNumSignBitsForTargetNode which can remove sign extends on the result. I also modified the MC layer description of these instructions to show the tied source/dest operand. This is different than what we do for masked instructions where we drop the tied source operand when converting to MC. But it is a more accurate description of the instruction. We can't do this for masked instructions since we use the same MC instruction for masked and unmasked. Tools like llvm-mca operate in the MC layer and rely on ins/outs and Uses/Defs for analysis so I don't know if we'll be able to maintain the current behavior for masked instructions. So I went with the accurate description here since it was easy. Reviewed By: frasercrmck Differential Revision: https://reviews.llvm.org/D93365 Added: llvm/test/CodeGen/RISCV/rvv/vmv.s.x-rv32.ll llvm/test/CodeGen/RISCV/rvv/vmv.s.x-rv64.ll llvm/test/CodeGen/RISCV/rvv/vmv.x.s-rv32.ll llvm/test/CodeGen/RISCV/rvv/vmv.x.s-rv64.ll Modified: llvm/include/llvm/IR/IntrinsicsRISCV.td llvm/lib/Target/RISCV/RISCVISelLowering.cpp llvm/lib/Target/RISCV/RISCVISelLowering.h llvm/lib/Target/RISCV/RISCVInstrInfoV.td llvm/lib/Target/RISCV/RISCVInstrInfoVPseudos.td Removed: diff --git a/llvm/include/llvm/IR/IntrinsicsRISCV.td b/llvm/include/llvm/IR/IntrinsicsRISCV.td index c207100adb7e..c6f3a492683e 100644 --- a/llvm/include/llvm/IR/IntrinsicsRISCV.td +++ b/llvm/include/llvm/IR/IntrinsicsRISCV.td @@ -339,4 +339,14 @@ let TargetPrefix = "riscv" in { def int_riscv_vmv_v_v : RISCVUnary; def int_riscv_vmv_v_x : RISCVUnary; + + def int_riscv_vmv_x_s : Intrinsic<[LLVMVectorElementType<0>], +[llvm_anyint_ty], +[IntrNoMem]>, RISCVVIntrinsic; + def int_riscv_vmv_s_x : Intrinsic<[llvm_anyint_ty], +[LLVMMatchType<0>, LLVMVectorElementType<0>, + llvm_anyint_ty], +[IntrNoMem]>, RISCVVIntrinsic { +let ExtendOperand = 2; + } } // TargetPrefix = "riscv" diff --git a/llvm/lib/Target/RISCV/RISCVISelLowering.cpp b/llvm/lib/Target/RISCV/RISCVISelLowering.cpp index 6dac023fe337..a484669e7a0b 100644 --- a/llvm/lib/Target/RISCV/RISCVISelLowering.cpp +++ b/llvm/lib/Target/RISCV/RISCVISelLowering.cpp @@ -348,14 +348,17 @@ RISCVTargetLowering::RISCVTargetLowering(const TargetMachine &TM, setBooleanVectorContents(ZeroOrOneBooleanContent); // RVV intrinsics may have illegal operands. +// We also need to custom legalize vmv.x.s. setOperationAction(ISD::INTRINSIC_WO_CHAIN, MVT::i8, Custom); setOperationAction(ISD::INTRINSIC_WO_CHAIN, MVT::i16, Custom); setOperationAction(ISD::INTRINSIC_W_CHAIN, MVT::i8, Custom); setOperationAction(ISD::INTRINSIC_W_CHAIN, MVT::i16, Custom); +setOperationAction(ISD::INTRINSIC_WO_CHAIN, MVT::i32, Custom); +setOperationAction(ISD::INTRINSIC_W_CHAIN, MVT::i32, Custom); if (Subtarget.is64Bit()) { - setOperationAction(ISD::INTRINSIC_WO_CHAIN, MVT::i32, Custom); - setOperationAction(ISD::INTRINSIC_W_CHAIN, MVT::i32, Custom); + setOperationAction(ISD::INTRINSIC_WO_CHAIN, MVT::i64, Custom); + setOperationAction(ISD::INTRINSIC_W_CHAIN, MVT::i64, Custom); } } @@ -1039,9 +1042,9 @@ SDValue RISCVTargetLowering::LowerINTRINSIC_WO_CHAIN(SDValue Op, assert(II->ExtendedOperand < Op.getNumOperands()); SmallVector Operands(Op->op_begin(), Op->op_end()); SDValue &ScalarOp = Operands[II->ExtendedOperand]; -if (ScalarOp.getValueType() == MVT::i8 || -ScalarOp.getValueType() == MVT::i16 || -ScalarOp.getValueType() == MVT::i32) { +EVT OpVT = ScalarOp.getValueType(); +if (OpVT == MVT::i8 || OpVT == MVT::i16 || +(OpVT == MVT::i32 && Subtarget.is64Bit())) { ScalarOp = DAG.getNode(ISD::ANY_EXTEND, DL, Subtarget.getXLenVT(), ScalarOp); return DAG.getNode(ISD::INTRINSIC_WO_CHAIN, DL, Op.getValueType(), @@ -1058,6 +1061,10 @@ SDValue RISCVTargetLowering::LowerINTRINSIC_WO_CHAIN(SD
[llvm-branch-commits] [llvm] 0e94ba9 - [NFC][InstCombine] Fixup check lines for prof md in select_meta.ll test
Author: Roman Lebedev Date: 2020-12-18T21:33:30+03:00 New Revision: 0e94ba9d40d931fc1c647347302f39d24bd88d96 URL: https://github.com/llvm/llvm-project/commit/0e94ba9d40d931fc1c647347302f39d24bd88d96 DIFF: https://github.com/llvm/llvm-project/commit/0e94ba9d40d931fc1c647347302f39d24bd88d96.diff LOG: [NFC][InstCombine] Fixup check lines for prof md in select_meta.ll test Added: Modified: llvm/test/Transforms/InstCombine/select_meta.ll Removed: diff --git a/llvm/test/Transforms/InstCombine/select_meta.ll b/llvm/test/Transforms/InstCombine/select_meta.ll index 00b6800ce7f7..be9d8be857d8 100644 --- a/llvm/test/Transforms/InstCombine/select_meta.ll +++ b/llvm/test/Transforms/InstCombine/select_meta.ll @@ -335,7 +335,7 @@ define <2 x i32> @not_cond_vec_undef(<2 x i1> %c, <2 x i32> %tv, <2 x i32> %fv) !1 = !{!"branch_weights", i32 2, i32 10} !2 = !{!"branch_weights", i32 3, i32 10} -; CHECK-DAG: ![[$MD1]] = !{!"branch_weights", i32 2, i32 10} -; CHECK-DAG: ![[$MD3]] = !{!"branch_weights", i32 10, i32 2} -; CHECK-DAG: ![[$MD4]] = !{!"branch_weights", i32 10, i32 3} +; CHECK: !0 = !{!"branch_weights", i32 2, i32 10} +; CHECK-NEXT: !1 = !{!"branch_weights", i32 10, i32 2} +; CHECK-NEXT: !2 = !{!"branch_weights", i32 10, i32 3} ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [llvm] 46a40c4 - [RISCV] Add intrinsics for vfmv.f.s and vfmv.s.f
Author: Craig Topper Date: 2020-12-18T11:11:15-08:00 New Revision: 46a40c4bc10671ebddb45fabd1a3b0b419a58109 URL: https://github.com/llvm/llvm-project/commit/46a40c4bc10671ebddb45fabd1a3b0b419a58109 DIFF: https://github.com/llvm/llvm-project/commit/46a40c4bc10671ebddb45fabd1a3b0b419a58109.diff LOG: [RISCV] Add intrinsics for vfmv.f.s and vfmv.s.f Similar to D93365, but for floating point. No need for special ISD opcodes though. We can directly isel these from intrinsics. I had to use anyfloat_ty instead of anyvector_ty in the intrinsics to make LLVMVectorElementType not crash when imported into the -gen-dag-isel tablegen backend. Differential Revision: https://reviews.llvm.org/D93426 Added: Modified: llvm/include/llvm/IR/IntrinsicsRISCV.td llvm/lib/Target/RISCV/RISCVInstrInfoV.td llvm/lib/Target/RISCV/RISCVInstrInfoVPseudos.td Removed: diff --git a/llvm/include/llvm/IR/IntrinsicsRISCV.td b/llvm/include/llvm/IR/IntrinsicsRISCV.td index c6f3a492683e..3a089e0762f1 100644 --- a/llvm/include/llvm/IR/IntrinsicsRISCV.td +++ b/llvm/include/llvm/IR/IntrinsicsRISCV.td @@ -349,4 +349,12 @@ let TargetPrefix = "riscv" in { [IntrNoMem]>, RISCVVIntrinsic { let ExtendOperand = 2; } + + def int_riscv_vfmv_f_s : Intrinsic<[LLVMVectorElementType<0>], + [llvm_anyfloat_ty], + [IntrNoMem]>, RISCVVIntrinsic; + def int_riscv_vfmv_s_f : Intrinsic<[llvm_anyfloat_ty], + [LLVMMatchType<0>, LLVMVectorElementType<0>, + llvm_anyint_ty], + [IntrNoMem]>, RISCVVIntrinsic; } // TargetPrefix = "riscv" diff --git a/llvm/lib/Target/RISCV/RISCVInstrInfoV.td b/llvm/lib/Target/RISCV/RISCVInstrInfoV.td index 3c587636144f..677d9f392bb3 100644 --- a/llvm/lib/Target/RISCV/RISCVInstrInfoV.td +++ b/llvm/lib/Target/RISCV/RISCVInstrInfoV.td @@ -980,8 +980,9 @@ let hasSideEffects = 0, mayLoad = 0, mayStore = 0, vm = 1 in { // Floating-Point Scalar Move Instructions def VFMV_F_S : RVInstV<0b01, 0b0, OPFVV, (outs FPR32:$vd), (ins VR:$vs2), "vfmv.f.s", "$vd, $vs2">; -def VFMV_S_F : RVInstV2<0b01, 0b0, OPFVF, (outs VR:$vd), - (ins FPR32:$rs1), "vfmv.s.f", "$vd, $rs1">; +let Constraints = "$vd = $vd_wb" in +def VFMV_S_F : RVInstV2<0b01, 0b0, OPFVF, (outs VR:$vd_wb), + (ins VR:$vd, FPR32:$rs1), "vfmv.s.f", "$vd, $rs1">; } // hasSideEffects = 0, mayLoad = 0, mayStore = 0, vm = 1 } // Predicates = [HasStdExtV, HasStdExtF] diff --git a/llvm/lib/Target/RISCV/RISCVInstrInfoVPseudos.td b/llvm/lib/Target/RISCV/RISCVInstrInfoVPseudos.td index 4927b82ec661..92340785d861 100644 --- a/llvm/lib/Target/RISCV/RISCVInstrInfoVPseudos.td +++ b/llvm/lib/Target/RISCV/RISCVInstrInfoVPseudos.td @@ -1370,12 +1370,37 @@ let mayLoad = 0, mayStore = 0, hasSideEffects = 0, usesCustomInserter = 1, Constraints = "$rd = $rs1" in def PseudoVMV_S_X # "_" # m.MX: Pseudo<(outs m.vrclass:$rd), (ins m.vrclass:$rs1, GPR:$rs2, - GPR:$vl, ixlenimm:$sew), + GPR:$vl, ixlenimm:$sew), []>, RISCVVPseudo; } } } +} // Predicates = [HasStdExtV] + +//===--===// +// 17.2. Floating-Point Scalar Move Instructions +//===--===// + +let Predicates = [HasStdExtV, HasStdExtF] in { +let mayLoad = 0, mayStore = 0, hasSideEffects = 0, usesCustomInserter = 1, +Uses = [VL, VTYPE] in { + foreach m = MxList.m in { +let VLMul = m.value in { + let SEWIndex = 2, BaseInstr = VFMV_F_S in + def PseudoVFMV_F_S # "_" # m.MX : Pseudo<(outs FPR32:$rd), + (ins m.vrclass:$rs2, +ixlenimm:$sew), + []>, RISCVVPseudo; + let VLIndex = 3, SEWIndex = 4, BaseInstr = VFMV_S_F, + Constraints = "$rd = $rs1" in + def PseudoVFMV_S_F # "_" # m.MX : Pseudo<(outs m.vrclass:$rd), + (ins m.vrclass:$rs1, FPR32:$rs2, +GPR:$vl, ixlenimm:$sew), + []>, RISCVVPseudo; +} + } } +} // Predicates = [HasStdExtV, HasStdExtF] //===--===// // Patterns. @@ -1557,3 +1582,34 @@ foreach vti = AllIntegerVectors in { (vti.Vector $rs1), $rs2, (NoX0 GPR:$vl), vti.SEW)>; } } /
[llvm-branch-commits] [llvm] cd3e811 - Revert "[RISCV] Add intrinsics for vfmv.f.s and vfmv.s.f"
Author: Craig Topper Date: 2020-12-18T11:16:36-08:00 New Revision: cd3e8118648f6fd6894e7d38cf0a0750488e8cac URL: https://github.com/llvm/llvm-project/commit/cd3e8118648f6fd6894e7d38cf0a0750488e8cac DIFF: https://github.com/llvm/llvm-project/commit/cd3e8118648f6fd6894e7d38cf0a0750488e8cac.diff LOG: Revert "[RISCV] Add intrinsics for vfmv.f.s and vfmv.s.f" This reverts commit 46a40c4bc10671ebddb45fabd1a3b0b419a58109. I forgot to git add the tests. Added: Modified: llvm/include/llvm/IR/IntrinsicsRISCV.td llvm/lib/Target/RISCV/RISCVInstrInfoV.td llvm/lib/Target/RISCV/RISCVInstrInfoVPseudos.td Removed: diff --git a/llvm/include/llvm/IR/IntrinsicsRISCV.td b/llvm/include/llvm/IR/IntrinsicsRISCV.td index 3a089e0762f1..c6f3a492683e 100644 --- a/llvm/include/llvm/IR/IntrinsicsRISCV.td +++ b/llvm/include/llvm/IR/IntrinsicsRISCV.td @@ -349,12 +349,4 @@ let TargetPrefix = "riscv" in { [IntrNoMem]>, RISCVVIntrinsic { let ExtendOperand = 2; } - - def int_riscv_vfmv_f_s : Intrinsic<[LLVMVectorElementType<0>], - [llvm_anyfloat_ty], - [IntrNoMem]>, RISCVVIntrinsic; - def int_riscv_vfmv_s_f : Intrinsic<[llvm_anyfloat_ty], - [LLVMMatchType<0>, LLVMVectorElementType<0>, - llvm_anyint_ty], - [IntrNoMem]>, RISCVVIntrinsic; } // TargetPrefix = "riscv" diff --git a/llvm/lib/Target/RISCV/RISCVInstrInfoV.td b/llvm/lib/Target/RISCV/RISCVInstrInfoV.td index 677d9f392bb3..3c587636144f 100644 --- a/llvm/lib/Target/RISCV/RISCVInstrInfoV.td +++ b/llvm/lib/Target/RISCV/RISCVInstrInfoV.td @@ -980,9 +980,8 @@ let hasSideEffects = 0, mayLoad = 0, mayStore = 0, vm = 1 in { // Floating-Point Scalar Move Instructions def VFMV_F_S : RVInstV<0b01, 0b0, OPFVV, (outs FPR32:$vd), (ins VR:$vs2), "vfmv.f.s", "$vd, $vs2">; -let Constraints = "$vd = $vd_wb" in -def VFMV_S_F : RVInstV2<0b01, 0b0, OPFVF, (outs VR:$vd_wb), - (ins VR:$vd, FPR32:$rs1), "vfmv.s.f", "$vd, $rs1">; +def VFMV_S_F : RVInstV2<0b01, 0b0, OPFVF, (outs VR:$vd), + (ins FPR32:$rs1), "vfmv.s.f", "$vd, $rs1">; } // hasSideEffects = 0, mayLoad = 0, mayStore = 0, vm = 1 } // Predicates = [HasStdExtV, HasStdExtF] diff --git a/llvm/lib/Target/RISCV/RISCVInstrInfoVPseudos.td b/llvm/lib/Target/RISCV/RISCVInstrInfoVPseudos.td index 92340785d861..4927b82ec661 100644 --- a/llvm/lib/Target/RISCV/RISCVInstrInfoVPseudos.td +++ b/llvm/lib/Target/RISCV/RISCVInstrInfoVPseudos.td @@ -1370,37 +1370,12 @@ let mayLoad = 0, mayStore = 0, hasSideEffects = 0, usesCustomInserter = 1, Constraints = "$rd = $rs1" in def PseudoVMV_S_X # "_" # m.MX: Pseudo<(outs m.vrclass:$rd), (ins m.vrclass:$rs1, GPR:$rs2, - GPR:$vl, ixlenimm:$sew), + GPR:$vl, ixlenimm:$sew), []>, RISCVVPseudo; } } } -} // Predicates = [HasStdExtV] - -//===--===// -// 17.2. Floating-Point Scalar Move Instructions -//===--===// - -let Predicates = [HasStdExtV, HasStdExtF] in { -let mayLoad = 0, mayStore = 0, hasSideEffects = 0, usesCustomInserter = 1, -Uses = [VL, VTYPE] in { - foreach m = MxList.m in { -let VLMul = m.value in { - let SEWIndex = 2, BaseInstr = VFMV_F_S in - def PseudoVFMV_F_S # "_" # m.MX : Pseudo<(outs FPR32:$rd), - (ins m.vrclass:$rs2, -ixlenimm:$sew), - []>, RISCVVPseudo; - let VLIndex = 3, SEWIndex = 4, BaseInstr = VFMV_S_F, - Constraints = "$rd = $rs1" in - def PseudoVFMV_S_F # "_" # m.MX : Pseudo<(outs m.vrclass:$rd), - (ins m.vrclass:$rs1, FPR32:$rs2, -GPR:$vl, ixlenimm:$sew), - []>, RISCVVPseudo; -} - } } -} // Predicates = [HasStdExtV, HasStdExtF] //===--===// // Patterns. @@ -1582,34 +1557,3 @@ foreach vti = AllIntegerVectors in { (vti.Vector $rs1), $rs2, (NoX0 GPR:$vl), vti.SEW)>; } } // Predicates = [HasStdExtV] - -//===--===// -// 17.2. Floating-Point Scalar Move Instructions -//===--===/
[llvm-branch-commits] [llvm] 1c3a667 - Recommit "[RISCV] Add intrinsics for vfmv.f.s and vfmv.s.f"
Author: Craig Topper Date: 2020-12-18T11:19:05-08:00 New Revision: 1c3a6671c25ea72dcc241fde9313daa31d320fed URL: https://github.com/llvm/llvm-project/commit/1c3a6671c25ea72dcc241fde9313daa31d320fed DIFF: https://github.com/llvm/llvm-project/commit/1c3a6671c25ea72dcc241fde9313daa31d320fed.diff LOG: Recommit "[RISCV] Add intrinsics for vfmv.f.s and vfmv.s.f" This time with tests. Original message: Similar to D93365, but for floating point. No need for special ISD opcodes though. We can directly isel these from intrinsics. I had to use anyfloat_ty instead of anyvector_ty in the intrinsics to make LLVMVectorElementType not crash when imported into the -gen-dag-isel tablegen backend. Differential Revision: https://reviews.llvm.org/D93426 Added: llvm/test/CodeGen/RISCV/rvv/vfmv.f.s.ll llvm/test/CodeGen/RISCV/rvv/vfmv.s.f-rv32.ll llvm/test/CodeGen/RISCV/rvv/vfmv.s.f-rv64.ll Modified: llvm/include/llvm/IR/IntrinsicsRISCV.td llvm/lib/Target/RISCV/RISCVInstrInfoV.td llvm/lib/Target/RISCV/RISCVInstrInfoVPseudos.td Removed: diff --git a/llvm/include/llvm/IR/IntrinsicsRISCV.td b/llvm/include/llvm/IR/IntrinsicsRISCV.td index c6f3a492683e..3a089e0762f1 100644 --- a/llvm/include/llvm/IR/IntrinsicsRISCV.td +++ b/llvm/include/llvm/IR/IntrinsicsRISCV.td @@ -349,4 +349,12 @@ let TargetPrefix = "riscv" in { [IntrNoMem]>, RISCVVIntrinsic { let ExtendOperand = 2; } + + def int_riscv_vfmv_f_s : Intrinsic<[LLVMVectorElementType<0>], + [llvm_anyfloat_ty], + [IntrNoMem]>, RISCVVIntrinsic; + def int_riscv_vfmv_s_f : Intrinsic<[llvm_anyfloat_ty], + [LLVMMatchType<0>, LLVMVectorElementType<0>, + llvm_anyint_ty], + [IntrNoMem]>, RISCVVIntrinsic; } // TargetPrefix = "riscv" diff --git a/llvm/lib/Target/RISCV/RISCVInstrInfoV.td b/llvm/lib/Target/RISCV/RISCVInstrInfoV.td index 3c587636144f..677d9f392bb3 100644 --- a/llvm/lib/Target/RISCV/RISCVInstrInfoV.td +++ b/llvm/lib/Target/RISCV/RISCVInstrInfoV.td @@ -980,8 +980,9 @@ let hasSideEffects = 0, mayLoad = 0, mayStore = 0, vm = 1 in { // Floating-Point Scalar Move Instructions def VFMV_F_S : RVInstV<0b01, 0b0, OPFVV, (outs FPR32:$vd), (ins VR:$vs2), "vfmv.f.s", "$vd, $vs2">; -def VFMV_S_F : RVInstV2<0b01, 0b0, OPFVF, (outs VR:$vd), - (ins FPR32:$rs1), "vfmv.s.f", "$vd, $rs1">; +let Constraints = "$vd = $vd_wb" in +def VFMV_S_F : RVInstV2<0b01, 0b0, OPFVF, (outs VR:$vd_wb), + (ins VR:$vd, FPR32:$rs1), "vfmv.s.f", "$vd, $rs1">; } // hasSideEffects = 0, mayLoad = 0, mayStore = 0, vm = 1 } // Predicates = [HasStdExtV, HasStdExtF] diff --git a/llvm/lib/Target/RISCV/RISCVInstrInfoVPseudos.td b/llvm/lib/Target/RISCV/RISCVInstrInfoVPseudos.td index 4927b82ec661..92340785d861 100644 --- a/llvm/lib/Target/RISCV/RISCVInstrInfoVPseudos.td +++ b/llvm/lib/Target/RISCV/RISCVInstrInfoVPseudos.td @@ -1370,12 +1370,37 @@ let mayLoad = 0, mayStore = 0, hasSideEffects = 0, usesCustomInserter = 1, Constraints = "$rd = $rs1" in def PseudoVMV_S_X # "_" # m.MX: Pseudo<(outs m.vrclass:$rd), (ins m.vrclass:$rs1, GPR:$rs2, - GPR:$vl, ixlenimm:$sew), + GPR:$vl, ixlenimm:$sew), []>, RISCVVPseudo; } } } +} // Predicates = [HasStdExtV] + +//===--===// +// 17.2. Floating-Point Scalar Move Instructions +//===--===// + +let Predicates = [HasStdExtV, HasStdExtF] in { +let mayLoad = 0, mayStore = 0, hasSideEffects = 0, usesCustomInserter = 1, +Uses = [VL, VTYPE] in { + foreach m = MxList.m in { +let VLMul = m.value in { + let SEWIndex = 2, BaseInstr = VFMV_F_S in + def PseudoVFMV_F_S # "_" # m.MX : Pseudo<(outs FPR32:$rd), + (ins m.vrclass:$rs2, +ixlenimm:$sew), + []>, RISCVVPseudo; + let VLIndex = 3, SEWIndex = 4, BaseInstr = VFMV_S_F, + Constraints = "$rd = $rs1" in + def PseudoVFMV_S_F # "_" # m.MX : Pseudo<(outs m.vrclass:$rd), + (ins m.vrclass:$rs1, FPR32:$rs2, +GPR:$vl, ixlenimm:$sew), + []>, RISCVVPseudo; +} + } } +} // Predicates = [HasStdExtV, HasStdExtF] //===--
[llvm-branch-commits] [llvm] 1f11450 - [DSE] Use correct memory location for read clobber check
Author: Nikita Popov Date: 2020-12-18T20:26:53+01:00 New Revision: 1f1145006b32533484c9ebc0f45e241a02fe6c8b URL: https://github.com/llvm/llvm-project/commit/1f1145006b32533484c9ebc0f45e241a02fe6c8b DIFF: https://github.com/llvm/llvm-project/commit/1f1145006b32533484c9ebc0f45e241a02fe6c8b.diff LOG: [DSE] Use correct memory location for read clobber check MSSA DSE starts at a killing store, finds an earlier store and then checks that the earlier store is not read along any paths (without being killed first). However, it uses the memory location of the killing store for that, not the earlier store that we're attempting to eliminate. This has a number of problems: * Mismatches between what BasicAA considers aliasing and what DSE considers an overwrite (even though both are correct in isolation) can result in miscompiles. This is PR48279, which D92045 tries to fix in a different way. The problem is that we're using a location from a store that is potentially not executed and thus may be UB, in which case analysis results can be arbitrary. * Metadata on the killing store may be used to determine aliasing, but there is no guarantee that the metadata is valid, as the specific killing store may not be executed. Using the metadata on the earlier store is valid (it is the store we're removing, so on any execution where its removal may be observed, it must be executed). * The location is imprecise. For full overwrites the killing store will always have a location that is larger or equal than the earlier access location, so it's beneficial to use the earlier access location. This is not the case for partial overwrites, in which case either location might be smaller. There is some room for improvement here. Using the earlier access location means that we can no longer cache which accesses are read for a given killing store, as we may be querying different locations. However, it turns out that simply dropping the cache has no notable impact on compile-time. Differential Revision: https://reviews.llvm.org/D93523 Added: Modified: llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp llvm/test/Transforms/DeadStoreElimination/MSSA/multiblock-memintrinsics.ll llvm/test/Transforms/DeadStoreElimination/MSSA/out-of-bounds-stores.ll llvm/test/Transforms/DeadStoreElimination/MSSA/overlap.ll llvm/test/Transforms/DeadStoreElimination/MSSA/scoped-noalias.ll Removed: diff --git a/llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp b/llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp index 6cc1b43c05e8..1a1d0c01f77e 100644 --- a/llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp +++ b/llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp @@ -1634,18 +1634,6 @@ struct DSEState { /// basic block. DenseMap IOLs; - struct CheckCache { -SmallPtrSet KnownNoReads; -SmallPtrSet KnownReads; - -bool isKnownNoRead(MemoryAccess *A) const { - return KnownNoReads.find(A) != KnownNoReads.end(); -} -bool isKnownRead(MemoryAccess *A) const { - return KnownReads.find(A) != KnownReads.end(); -} - }; - DSEState(Function &F, AliasAnalysis &AA, MemorySSA &MSSA, DominatorTree &DT, PostDominatorTree &PDT, const TargetLibraryInfo &TLI) : F(F), AA(AA), BatchAA(AA), MSSA(MSSA), DT(DT), PDT(PDT), TLI(TLI), @@ -1940,9 +1928,8 @@ struct DSEState { Optional getDomMemoryDef(MemoryDef *KillingDef, MemoryAccess *StartAccess, const MemoryLocation &DefLoc, const Value *DefUO, - CheckCache &Cache, unsigned &ScanLimit, - unsigned &WalkerStepLimit, bool IsMemTerm, - unsigned &PartialLimit) { + unsigned &ScanLimit, unsigned &WalkerStepLimit, + bool IsMemTerm, unsigned &PartialLimit) { if (ScanLimit == 0 || WalkerStepLimit == 0) { LLVM_DEBUG(dbgs() << "\n... hit scan limit\n"); return None; @@ -1954,6 +1941,7 @@ struct DSEState { LLVM_DEBUG(dbgs() << " trying to get dominating access\n"); // Find the next clobbering Mod access for DefLoc, starting at StartAccess. +Optional CurrentLoc; do { StepAgain = false; LLVM_DEBUG({ @@ -2017,12 +2005,8 @@ struct DSEState { // clobber, bail out, as the path is not profitable. We skip this check // for intrinsic calls, because the code knows how to handle memcpy // intrinsics. - if (!isa(CurrentI) && - (Cache.KnownReads.contains(Current) || - isReadClobber(DefLoc, CurrentI))) { -Cache.KnownReads.insert(Current); + if (!isa(CurrentI) && isReadClobber(DefLoc, CurrentI)) return None; - } // Quick check if there are direct uses that are read-clobbers. if (any_of(Current->uses(), [this, &DefLoc, StartAccess](Use &U) { @@ -2031,7 +2015,6 @@ struct DSEState {
[llvm-branch-commits] [llvm] 09468a9 - [RISCV] Sign extend constant arguments to V intrinsics when promoting to XLen.
Author: Craig Topper Date: 2020-12-18T11:43:38-08:00 New Revision: 09468a914827b33fe6fe1fcf05ba87c60709d49d URL: https://github.com/llvm/llvm-project/commit/09468a914827b33fe6fe1fcf05ba87c60709d49d DIFF: https://github.com/llvm/llvm-project/commit/09468a914827b33fe6fe1fcf05ba87c60709d49d.diff LOG: [RISCV] Sign extend constant arguments to V intrinsics when promoting to XLen. The default behavior for any_extend of a constant is to zero extend. This occurs inside of getNode rather than allowing type legalization to promote the constant which would sign extend. By using sign extend with getNode the constant will be sign extended. This gives a better chance for isel to find a simm5 immediate since all xlen bits are examined there. For instructions that use a uimm5 immediate, this change only affects constants >= 128 for i8 or >= 32768 for i16. Constants that large already wouldn't have been eligible for uimm5 and would need to use a scalar register. If the instruction isn't able to use simm5 or the immediate is too large, we'll need to materialize the immediate in a register. As far as I know constants with all 1s in the upper bits should materialize as well or better than all 0s. Longer term we should probably have a SEW aware PatFrag to ignore the bits above SEW before checking simm5. I updated about half the test cases in some tests to use a negative constant to get coverage for this. Reviewed By: evandro Differential Revision: https://reviews.llvm.org/D93487 Added: Modified: llvm/lib/Target/RISCV/RISCVISelLowering.cpp llvm/test/CodeGen/RISCV/rvv/vadc-rv32.ll llvm/test/CodeGen/RISCV/rvv/vadc-rv64.ll llvm/test/CodeGen/RISCV/rvv/vadd-rv32.ll llvm/test/CodeGen/RISCV/rvv/vmadc-rv32.ll llvm/test/CodeGen/RISCV/rvv/vmadc-rv64.ll llvm/test/CodeGen/RISCV/rvv/vmadc.carry.in-rv32.ll llvm/test/CodeGen/RISCV/rvv/vrsub-rv32.ll Removed: diff --git a/llvm/lib/Target/RISCV/RISCVISelLowering.cpp b/llvm/lib/Target/RISCV/RISCVISelLowering.cpp index a484669e7a0b..5334666baf22 100644 --- a/llvm/lib/Target/RISCV/RISCVISelLowering.cpp +++ b/llvm/lib/Target/RISCV/RISCVISelLowering.cpp @@ -1045,8 +1045,13 @@ SDValue RISCVTargetLowering::LowerINTRINSIC_WO_CHAIN(SDValue Op, EVT OpVT = ScalarOp.getValueType(); if (OpVT == MVT::i8 || OpVT == MVT::i16 || (OpVT == MVT::i32 && Subtarget.is64Bit())) { - ScalarOp = - DAG.getNode(ISD::ANY_EXTEND, DL, Subtarget.getXLenVT(), ScalarOp); + // If the operand is a constant, sign extend to increase our chances + // of being able to use a .vi instruction. ANY_EXTEND would become a + // a zero extend and the simm5 check in isel would fail. + // FIXME: Should we ignore the upper bits in isel instead? + unsigned ExtOpc = isa(ScalarOp) ? ISD::SIGN_EXTEND + : ISD::ANY_EXTEND; + ScalarOp = DAG.getNode(ExtOpc, DL, Subtarget.getXLenVT(), ScalarOp); return DAG.getNode(ISD::INTRINSIC_WO_CHAIN, DL, Op.getValueType(), Operands); } @@ -1087,9 +1092,15 @@ SDValue RISCVTargetLowering::LowerINTRINSIC_W_CHAIN(SDValue Op, EVT OpVT = ScalarOp.getValueType(); if (OpVT == MVT::i8 || OpVT == MVT::i16 || (OpVT == MVT::i32 && Subtarget.is64Bit())) { - ScalarOp = - DAG.getNode(ISD::ANY_EXTEND, DL, Subtarget.getXLenVT(), ScalarOp); - return DAG.getNode(ISD::INTRINSIC_W_CHAIN, DL, Op->getVTList(), Operands); + // If the operand is a constant, sign extend to increase our chances + // of being able to use a .vi instruction. ANY_EXTEND would become a + // a zero extend and the simm5 check in isel would fail. + // FIXME: Should we ignore the upper bits in isel instead? + unsigned ExtOpc = isa(ScalarOp) ? ISD::SIGN_EXTEND + : ISD::ANY_EXTEND; + ScalarOp = DAG.getNode(ExtOpc, DL, Subtarget.getXLenVT(), ScalarOp); + return DAG.getNode(ISD::INTRINSIC_W_CHAIN, DL, Op->getVTList(), + Operands); } } } diff --git a/llvm/test/CodeGen/RISCV/rvv/vadc-rv32.ll b/llvm/test/CodeGen/RISCV/rvv/vadc-rv32.ll index 0557e58946ce..b4861b3c3e0a 100644 --- a/llvm/test/CodeGen/RISCV/rvv/vadc-rv32.ll +++ b/llvm/test/CodeGen/RISCV/rvv/vadc-rv32.ll @@ -724,10 +724,10 @@ define @intrinsic_vadc_vim_nxv1i8_nxv1i8_i8( entry: ; CHECK-LABEL: intrinsic_vadc_vim_nxv1i8_nxv1i8_i8 ; CHECK: vsetvli {{.*}}, {{a[0-9]+}}, e8,mf8,ta,mu -; CHECK: vadc.vim {{v[0-9]+}}, {{v[0-9]+}}, 9, v0 +; CHECK: vadc.vim {{v[0-9]+}}, {{v[0-9]+}}, -9, v0 %a = call @llvm.riscv.vadc.nxv1i8.i8( %0, -i8 9, +i8 -9, %1, i32 %2) @@ -752,10 +752,10 @@ define
[llvm-branch-commits] [llvm] 2af2f58 - [InstCombine] Regenerate test checks (NFC)
Author: Nikita Popov Date: 2020-12-18T20:55:26+01:00 New Revision: 2af2f58ec09257d65a2a6f99f833a1b242d434a3 URL: https://github.com/llvm/llvm-project/commit/2af2f58ec09257d65a2a6f99f833a1b242d434a3 DIFF: https://github.com/llvm/llvm-project/commit/2af2f58ec09257d65a2a6f99f833a1b242d434a3.diff LOG: [InstCombine] Regenerate test checks (NFC) Added: Modified: llvm/test/Transforms/InstCombine/CPP_min_max.ll llvm/test/Transforms/InstCombine/clamp-to-minmax.ll llvm/test/Transforms/InstCombine/minmax-fp.ll llvm/test/Transforms/InstCombine/pr21199.ll llvm/test/Transforms/InstCombine/preserve-sminmax.ll llvm/test/Transforms/InstCombine/smax-icmp.ll llvm/test/Transforms/InstCombine/smin-icmp.ll llvm/test/Transforms/InstCombine/umax-icmp.ll llvm/test/Transforms/InstCombine/umin-icmp.ll Removed: diff --git a/llvm/test/Transforms/InstCombine/CPP_min_max.ll b/llvm/test/Transforms/InstCombine/CPP_min_max.ll index 04bf0ceefea9..cd65a4253de2 100644 --- a/llvm/test/Transforms/InstCombine/CPP_min_max.ll +++ b/llvm/test/Transforms/InstCombine/CPP_min_max.ll @@ -1,5 +1,5 @@ -; RUN: opt < %s -instcombine -S | \ -; RUN: grep select | not grep 'i32\*' +; NOTE: Assertions have been autogenerated by utils/update_test_checks.py +; RUN: opt < %s -instcombine -S | FileCheck %s ; This testcase corresponds to PR362, which notices that this horrible code ; is generated by the C++ front-end and LLVM optimizers, which has lots of @@ -9,26 +9,44 @@ ; allow elimination of the extra stuff by the mem2reg pass. define void @_Z5test1RiS_(i32* %x, i32* %y) { +; CHECK-LABEL: @_Z5test1RiS_( +; CHECK-NEXT: entry: +; CHECK-NEXT:[[TMP_1_I:%.*]] = load i32, i32* [[Y:%.*]], align 4 +; CHECK-NEXT:[[TMP_3_I:%.*]] = load i32, i32* [[X:%.*]], align 4 +; CHECK-NEXT:[[TMP_4_I:%.*]] = icmp slt i32 [[TMP_1_I]], [[TMP_3_I]] +; CHECK-NEXT:[[TMP_4:%.*]] = select i1 [[TMP_4_I]], i32 [[TMP_1_I]], i32 [[TMP_3_I]] +; CHECK-NEXT:store i32 [[TMP_4]], i32* [[X]], align 4 +; CHECK-NEXT:ret void +; entry: -%tmp.1.i = load i32, i32* %y ; [#uses=1] -%tmp.3.i = load i32, i32* %x ; [#uses=1] -%tmp.4.i = icmp slt i32 %tmp.1.i, %tmp.3.i ; [#uses=1] -%retval.i = select i1 %tmp.4.i, i32* %y, i32* %x; [#uses=1] -%tmp.4 = load i32, i32* %retval.i; [#uses=1] -store i32 %tmp.4, i32* %x -ret void + %tmp.1.i = load i32, i32* %y ; [#uses=1] + %tmp.3.i = load i32, i32* %x ; [#uses=1] + %tmp.4.i = icmp slt i32 %tmp.1.i, %tmp.3.i ; [#uses=1] + %retval.i = select i1 %tmp.4.i, i32* %y, i32* %x; [#uses=1] + %tmp.4 = load i32, i32* %retval.i; [#uses=1] + store i32 %tmp.4, i32* %x + ret void } define void @_Z5test2RiS_(i32* %x, i32* %y) { +; CHECK-LABEL: @_Z5test2RiS_( +; CHECK-NEXT: entry: +; CHECK-NEXT:[[TMP_2:%.*]] = load i32, i32* [[X:%.*]], align 4 +; CHECK-NEXT:[[TMP_3_I:%.*]] = load i32, i32* [[Y:%.*]], align 4 +; CHECK-NEXT:[[TMP_4_I:%.*]] = icmp slt i32 [[TMP_2]], [[TMP_3_I]] +; CHECK-NEXT:[[TMP_6:%.*]] = select i1 [[TMP_4_I]], i32 [[TMP_3_I]], i32 [[TMP_2]] +; CHECK-NEXT:store i32 [[TMP_6]], i32* [[Y]], align 4 +; CHECK-NEXT:ret void +; entry: -%tmp.0 = alloca i32 ; [#uses=2] -%tmp.2 = load i32, i32* %x ; [#uses=2] -store i32 %tmp.2, i32* %tmp.0 -%tmp.3.i = load i32, i32* %y ; [#uses=1] -%tmp.4.i = icmp slt i32 %tmp.2, %tmp.3.i; [#uses=1] -%retval.i = select i1 %tmp.4.i, i32* %y, i32* %tmp.0; [#uses=1] -%tmp.6 = load i32, i32* %retval.i; [#uses=1] -store i32 %tmp.6, i32* %y -ret void + %tmp.0 = alloca i32 ; [#uses=2] + %tmp.2 = load i32, i32* %x ; [#uses=2] + store i32 %tmp.2, i32* %tmp.0 + %tmp.3.i = load i32, i32* %y ; [#uses=1] + %tmp.4.i = icmp slt i32 %tmp.2, %tmp.3.i; [#uses=1] + %retval.i = select i1 %tmp.4.i, i32* %y, i32* %tmp.0; [#uses=1] + %tmp.6 = load i32, i32* %retval.i; [#uses=1] + store i32 %tmp.6, i32* %y + ret void } diff --git a/llvm/test/Transforms/InstCombine/clamp-to-minmax.ll b/llvm/test/Transforms/InstCombine/clamp-to-minmax.ll index f23819cd5f16..a872357aa686 100644 --- a/llvm/test/Transforms/InstCombine/clamp-to-minmax.ll +++ b/llvm/test/Transforms/InstCombine/clamp-to-minmax.ll @@ -3,7 +3,7 @@ ; (X < C1) ? C1 : MIN(X, C2) define float @clamp_float_fast_ordered_strict_maxmin(float %x) { -; CHECK-LABEL: define {{[^@]+}}@clamp_float_fast_ordered_strict_maxmin( +; CHECK-LABEL: @clamp_float_fast_ordered_strict_maxmin( ; CHECK-NEXT:[[CMP2:%.*]] = fcmp fast olt float [[X:%.*]], 2.55e+02 ; CHECK-NEXT:[[MIN:%.*]] = selec
[llvm-branch-commits] [llvm] 9caca72 - [AArch64][GlobalISel] Use the look-through constant helper for the shift s32->s64 custom legalization.
Author: Amara Emerson Date: 2020-12-18T11:57:24-08:00 New Revision: 9caca7241d447266a23a99ea0536f30faaf19694 URL: https://github.com/llvm/llvm-project/commit/9caca7241d447266a23a99ea0536f30faaf19694 DIFF: https://github.com/llvm/llvm-project/commit/9caca7241d447266a23a99ea0536f30faaf19694.diff LOG: [AArch64][GlobalISel] Use the look-through constant helper for the shift s32->s64 custom legalization. Almost NFC, except it catches more cases and gives a 0.1% CTMark -O0 size win. Added: Modified: llvm/lib/Target/AArch64/GISel/AArch64LegalizerInfo.cpp llvm/test/CodeGen/AArch64/GlobalISel/legalize-unmerge-values.mir Removed: diff --git a/llvm/lib/Target/AArch64/GISel/AArch64LegalizerInfo.cpp b/llvm/lib/Target/AArch64/GISel/AArch64LegalizerInfo.cpp index 2eaec0b970fa..3dcc244a08fa 100644 --- a/llvm/lib/Target/AArch64/GISel/AArch64LegalizerInfo.cpp +++ b/llvm/lib/Target/AArch64/GISel/AArch64LegalizerInfo.cpp @@ -710,16 +710,14 @@ bool AArch64LegalizerInfo::legalizeShlAshrLshr( // If the shift amount is a G_CONSTANT, promote it to a 64 bit type so the // imported patterns can select it later. Either way, it will be legal. Register AmtReg = MI.getOperand(2).getReg(); - auto *CstMI = MRI.getVRegDef(AmtReg); - assert(CstMI && "expected to find a vreg def"); - if (CstMI->getOpcode() != TargetOpcode::G_CONSTANT) + auto VRegAndVal = getConstantVRegValWithLookThrough(AmtReg, MRI); + if (!VRegAndVal) return true; // Check the shift amount is in range for an immediate form. - unsigned Amount = CstMI->getOperand(1).getCImm()->getZExtValue(); + int64_t Amount = VRegAndVal->Value; if (Amount > 31) return true; // This will have to remain a register variant. - assert(MRI.getType(AmtReg).getSizeInBits() == 32); - auto ExtCst = MIRBuilder.buildZExt(LLT::scalar(64), AmtReg); + auto ExtCst = MIRBuilder.buildConstant(LLT::scalar(64), Amount); MI.getOperand(2).setReg(ExtCst.getReg(0)); return true; } diff --git a/llvm/test/CodeGen/AArch64/GlobalISel/legalize-unmerge-values.mir b/llvm/test/CodeGen/AArch64/GlobalISel/legalize-unmerge-values.mir index 56c5b8a8f1e2..9c1f6fc6f41b 100644 --- a/llvm/test/CodeGen/AArch64/GlobalISel/legalize-unmerge-values.mir +++ b/llvm/test/CodeGen/AArch64/GlobalISel/legalize-unmerge-values.mir @@ -24,9 +24,10 @@ body: | ; CHECK-LABEL: name: test_unmerge_s4 ; CHECK: [[COPY:%[0-9]+]]:_(s32) = COPY $w0 ; CHECK: [[UV:%[0-9]+]]:_(s8), [[UV1:%[0-9]+]]:_(s8), [[UV2:%[0-9]+]]:_(s8), [[UV3:%[0-9]+]]:_(s8) = G_UNMERGE_VALUES [[COPY]](s32) -; CHECK: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 4 +; CHECK: [[C:%[0-9]+]]:_(s8) = G_CONSTANT i8 4 ; CHECK: [[ZEXT:%[0-9]+]]:_(s32) = G_ZEXT [[UV]](s8) -; CHECK: [[LSHR:%[0-9]+]]:_(s32) = G_LSHR [[ZEXT]], [[C]](s32) +; CHECK: [[C1:%[0-9]+]]:_(s64) = G_CONSTANT i64 4 +; CHECK: [[LSHR:%[0-9]+]]:_(s32) = G_LSHR [[ZEXT]], [[C1]](s64) ; CHECK: [[ANYEXT:%[0-9]+]]:_(s64) = G_ANYEXT [[UV]](s8) ; CHECK: [[ANYEXT1:%[0-9]+]]:_(s64) = G_ANYEXT [[LSHR]](s32) ; CHECK: $x0 = COPY [[ANYEXT]](s64) ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [llvm] 43ff75f - [AArch64][GlobalISel] Promote scalar G_SHL constant shift amounts to s64.
Author: Amara Emerson Date: 2020-12-18T11:57:38-08:00 New Revision: 43ff75f2c3feef64f9d73328230d34dac8832a91 URL: https://github.com/llvm/llvm-project/commit/43ff75f2c3feef64f9d73328230d34dac8832a91 DIFF: https://github.com/llvm/llvm-project/commit/43ff75f2c3feef64f9d73328230d34dac8832a91.diff LOG: [AArch64][GlobalISel] Promote scalar G_SHL constant shift amounts to s64. This was supposed to be done in the first place as is currently the case for G_ASHR and G_LSHR but was forgotten when the original shift legalization overhaul was done last year. This was exposed because we started falling back on s32 = s32, s64 SHLs due to a recent combiner change. Gives a very minor (0.1%) code size -O0 improvement on consumer-typeset. Added: Modified: llvm/lib/Target/AArch64/GISel/AArch64LegalizerInfo.cpp llvm/test/CodeGen/AArch64/GlobalISel/legalize-merge-values.mir llvm/test/CodeGen/AArch64/GlobalISel/legalize-non-pow2-load-store.mir llvm/test/CodeGen/AArch64/GlobalISel/legalize-shift.mir llvm/test/CodeGen/AArch64/arm64-clrsb.ll Removed: diff --git a/llvm/lib/Target/AArch64/GISel/AArch64LegalizerInfo.cpp b/llvm/lib/Target/AArch64/GISel/AArch64LegalizerInfo.cpp index 3dcc244a08fa..4ffde2a7e3c4 100644 --- a/llvm/lib/Target/AArch64/GISel/AArch64LegalizerInfo.cpp +++ b/llvm/lib/Target/AArch64/GISel/AArch64LegalizerInfo.cpp @@ -97,15 +97,25 @@ AArch64LegalizerInfo::AArch64LegalizerInfo(const AArch64Subtarget &ST) .moreElementsToNextPow2(0); getActionDefinitionsBuilder(G_SHL) -.legalFor({{s32, s32}, {s64, s64}, - {v2s32, v2s32}, {v4s32, v4s32}, {v2s64, v2s64}}) -.clampScalar(1, s32, s64) -.clampScalar(0, s32, s64) -.widenScalarToNextPow2(0) -.clampNumElements(0, v2s32, v4s32) -.clampNumElements(0, v2s64, v2s64) -.moreElementsToNextPow2(0) -.minScalarSameAs(1, 0); + .customIf([=](const LegalityQuery &Query) { +const auto &SrcTy = Query.Types[0]; +const auto &AmtTy = Query.Types[1]; +return !SrcTy.isVector() && SrcTy.getSizeInBits() == 32 && + AmtTy.getSizeInBits() == 32; + }) + .legalFor({{s32, s32}, + {s64, s64}, + {s32, s64}, + {v2s32, v2s32}, + {v4s32, v4s32}, + {v2s64, v2s64}}) + .clampScalar(1, s32, s64) + .clampScalar(0, s32, s64) + .widenScalarToNextPow2(0) + .clampNumElements(0, v2s32, v4s32) + .clampNumElements(0, v2s64, v2s64) + .moreElementsToNextPow2(0) + .minScalarSameAs(1, 0); getActionDefinitionsBuilder(G_PTR_ADD) .legalFor({{p0, s64}, {v2p0, v2s64}}) diff --git a/llvm/test/CodeGen/AArch64/GlobalISel/legalize-merge-values.mir b/llvm/test/CodeGen/AArch64/GlobalISel/legalize-merge-values.mir index 09ae228b4f1d..a802baca4c8d 100644 --- a/llvm/test/CodeGen/AArch64/GlobalISel/legalize-merge-values.mir +++ b/llvm/test/CodeGen/AArch64/GlobalISel/legalize-merge-values.mir @@ -6,11 +6,12 @@ name:test_merge_s4 body: | bb.0: ; CHECK-LABEL: name: test_merge_s4 -; CHECK: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 4 +; CHECK: [[C:%[0-9]+]]:_(s8) = G_CONSTANT i8 4 ; CHECK: [[C1:%[0-9]+]]:_(s32) = G_CONSTANT i32 15 ; CHECK: [[C2:%[0-9]+]]:_(s32) = G_CONSTANT i32 0 ; CHECK: [[AND:%[0-9]+]]:_(s32) = G_AND [[C2]], [[C1]] -; CHECK: [[SHL:%[0-9]+]]:_(s32) = G_SHL [[AND]], [[C]](s32) +; CHECK: [[C3:%[0-9]+]]:_(s64) = G_CONSTANT i64 4 +; CHECK: [[SHL:%[0-9]+]]:_(s32) = G_SHL [[AND]], [[C3]](s64) ; CHECK: [[COPY:%[0-9]+]]:_(s32) = COPY [[C2]](s32) ; CHECK: [[AND1:%[0-9]+]]:_(s32) = G_AND [[COPY]], [[C1]] ; CHECK: [[COPY1:%[0-9]+]]:_(s32) = COPY [[SHL]](s32) diff --git a/llvm/test/CodeGen/AArch64/GlobalISel/legalize-non-pow2-load-store.mir b/llvm/test/CodeGen/AArch64/GlobalISel/legalize-non-pow2-load-store.mir index 7d7b77aa7535..6dc28e738dbc 100644 --- a/llvm/test/CodeGen/AArch64/GlobalISel/legalize-non-pow2-load-store.mir +++ b/llvm/test/CodeGen/AArch64/GlobalISel/legalize-non-pow2-load-store.mir @@ -28,12 +28,11 @@ body: | ; CHECK: [[C1:%[0-9]+]]:_(s64) = G_CONSTANT i64 2 ; CHECK: [[PTR_ADD:%[0-9]+]]:_(p0) = G_PTR_ADD [[COPY]], [[C1]](s64) ; CHECK: [[LOAD:%[0-9]+]]:_(s32) = G_LOAD [[PTR_ADD]](p0) :: (load 1 from %ir.ptr + 2, align 4) -; CHECK: [[C2:%[0-9]+]]:_(s32) = G_CONSTANT i32 16 -; CHECK: [[SHL:%[0-9]+]]:_(s32) = G_SHL [[LOAD]], [[C2]](s32) +; CHECK: [[C2:%[0-9]+]]:_(s64) = G_CONSTANT i64 16 +; CHECK: [[SHL:%[0-9]+]]:_(s32) = G_SHL [[LOAD]], [[C2]](s64) ; CHECK: [[OR:%[0-9]+]]:_(s32) = G_OR [[SHL]], [[ZEXTLOAD]] ; CHECK: [[COPY2:%[0-9]+]]:_(s32) = COPY [[OR]](s32) -; CHECK: [[C3:%[0-9]+]]:_(s64) = G_CONSTANT i64 16 -; CHECK: [[LSHR:%[0-9]+]]:_(s32) = G_LSHR [[COPY2]], [[C3]](s64) +; CHECK: [[LSHR:%[0-9]+]]:_(s32) = G_LSHR [[COPY
[llvm-branch-commits] [llvm] 9c978dd - [TableGen] Fix D90844 introduced non-determinism due to iteration over a std::map over allocated object pointers
Author: Fangrui Song Date: 2020-12-18T12:08:16-08:00 New Revision: 9c978dd6e12e5ffaf5441f459db47e9892b09a82 URL: https://github.com/llvm/llvm-project/commit/9c978dd6e12e5ffaf5441f459db47e9892b09a82 DIFF: https://github.com/llvm/llvm-project/commit/9c978dd6e12e5ffaf5441f459db47e9892b09a82.diff LOG: [TableGen] Fix D90844 introduced non-determinism due to iteration over a std::map over allocated object pointers 993eaf2d69d8beb97e4695cbd919b927ed1cfe86 (D90844) is still wrong. The allocated const Record* pointers do not have an order guarantee so switching from DenseMap to std::map does not help. ProcModelMapTy = std::map Sort the values instead. Added: Modified: llvm/utils/TableGen/CodeGenSchedule.cpp llvm/utils/TableGen/CodeGenSchedule.h Removed: diff --git a/llvm/utils/TableGen/CodeGenSchedule.cpp b/llvm/utils/TableGen/CodeGenSchedule.cpp index f1bfe42001a3..8b54ff0d1d72 100644 --- a/llvm/utils/TableGen/CodeGenSchedule.cpp +++ b/llvm/utils/TableGen/CodeGenSchedule.cpp @@ -1718,6 +1718,9 @@ std::vector CodeGenSchedModels::getAllProcIndices() const { for (const auto &PM : ProcModelMap) if (PM.second != 0) ProcIdVec.push_back(PM.second); + // The order of the keys (Record pointers) of ProcModelMap are not stable. + // Sort to stabalize the values. + llvm::sort(ProcIdVec); return ProcIdVec; } diff --git a/llvm/utils/TableGen/CodeGenSchedule.h b/llvm/utils/TableGen/CodeGenSchedule.h index 3fa642607b63..9020447c940b 100644 --- a/llvm/utils/TableGen/CodeGenSchedule.h +++ b/llvm/utils/TableGen/CodeGenSchedule.h @@ -410,7 +410,7 @@ class STIPredicateFunction { ArrayRef getGroups() const { return Groups; } }; -using ProcModelMapTy = std::map; +using ProcModelMapTy = DenseMap; /// Top level container for machine model data. class CodeGenSchedModels { ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [llvm] 69c8d12 - [RISCV] Add intrinsics for vsetvli instruction
Author: Craig Topper Date: 2020-12-18T12:10:09-08:00 New Revision: 69c8d121f7f22e483e35a3d893052011ee70c23e URL: https://github.com/llvm/llvm-project/commit/69c8d121f7f22e483e35a3d893052011ee70c23e DIFF: https://github.com/llvm/llvm-project/commit/69c8d121f7f22e483e35a3d893052011ee70c23e.diff LOG: [RISCV] Add intrinsics for vsetvli instruction This patch adds two IR intrinsics for vsetvli instruction. One to set the vector length to a user specified value and one to set it to vlmax. The vlmax uses the X0 source register encoding. Clang builtins will follow in a separate patch Differential Revision: https://reviews.llvm.org/D92973 Added: llvm/test/CodeGen/RISCV/rvv/rv32-vsetvli-intrinsics.ll llvm/test/CodeGen/RISCV/rvv/rv64-vsetvli-intrinsics.ll Modified: llvm/include/llvm/IR/IntrinsicsRISCV.td llvm/lib/Target/RISCV/RISCVISelDAGToDAG.cpp llvm/lib/Target/RISCV/Utils/RISCVBaseInfo.cpp llvm/lib/Target/RISCV/Utils/RISCVBaseInfo.h Removed: diff --git a/llvm/include/llvm/IR/IntrinsicsRISCV.td b/llvm/include/llvm/IR/IntrinsicsRISCV.td index 3a089e0762f1..a6fbccdc75a0 100644 --- a/llvm/include/llvm/IR/IntrinsicsRISCV.td +++ b/llvm/include/llvm/IR/IntrinsicsRISCV.td @@ -79,6 +79,21 @@ class RISCVVIntrinsic { } let TargetPrefix = "riscv" in { + // We use anyint here but we only support XLen. + def int_riscv_vsetvli : Intrinsic<[llvm_anyint_ty], + /* AVL */ [LLVMMatchType<0>, + /* VSEW */ LLVMMatchType<0>, + /* VLMUL */ LLVMMatchType<0>], + [IntrNoMem, IntrHasSideEffects, + ImmArg>, + ImmArg>]>; + def int_riscv_vsetvlimax : Intrinsic<[llvm_anyint_ty], +/* VSEW */ [LLVMMatchType<0>, +/* VLMUL */ LLVMMatchType<0>], + [IntrNoMem, IntrHasSideEffects, + ImmArg>, + ImmArg>]>; + // For unit stride load // Input: (pointer, vl) class RISCVUSLoad diff --git a/llvm/lib/Target/RISCV/RISCVISelDAGToDAG.cpp b/llvm/lib/Target/RISCV/RISCVISelDAGToDAG.cpp index 1d7789b83fb9..f06f7ea3f2af 100644 --- a/llvm/lib/Target/RISCV/RISCVISelDAGToDAG.cpp +++ b/llvm/lib/Target/RISCV/RISCVISelDAGToDAG.cpp @@ -14,6 +14,7 @@ #include "MCTargetDesc/RISCVMCTargetDesc.h" #include "Utils/RISCVMatInt.h" #include "llvm/CodeGen/MachineFrameInfo.h" +#include "llvm/IR/IntrinsicsRISCV.h" #include "llvm/Support/Alignment.h" #include "llvm/Support/Debug.h" #include "llvm/Support/MathExtras.h" @@ -141,6 +142,70 @@ void RISCVDAGToDAGISel::Select(SDNode *Node) { } break; } + case ISD::INTRINSIC_W_CHAIN: { +unsigned IntNo = cast(Node->getOperand(1))->getZExtValue(); +switch (IntNo) { + // By default we do not custom select any intrinsic. +default: + break; + +case Intrinsic::riscv_vsetvli: { + if (!Subtarget->hasStdExtV()) +break; + + assert(Node->getNumOperands() == 5); + + RISCVVSEW VSEW = + static_cast(Node->getConstantOperandVal(3) & 0x7); + RISCVVLMUL VLMul = + static_cast(Node->getConstantOperandVal(4) & 0x7); + + unsigned VTypeI = RISCVVType::encodeVTYPE( + VLMul, VSEW, /*TailAgnostic*/ true, /*MaskAgnostic*/ false); + SDValue VTypeIOp = CurDAG->getTargetConstant(VTypeI, DL, XLenVT); + + SDValue VLOperand = Node->getOperand(2); + if (auto *C = dyn_cast(VLOperand)) { +if (C->isNullValue()) { + VLOperand = SDValue( + CurDAG->getMachineNode(RISCV::ADDI, DL, XLenVT, + CurDAG->getRegister(RISCV::X0, XLenVT), + CurDAG->getTargetConstant(0, DL, XLenVT)), + 0); +} + } + + ReplaceNode(Node, + CurDAG->getMachineNode(RISCV::PseudoVSETVLI, DL, XLenVT, + MVT::Other, VLOperand, VTypeIOp, + /* Chain */ Node->getOperand(0))); + return; +} +case Intrinsic::riscv_vsetvlimax: { + if (!Subtarget->hasStdExtV()) +break; + + assert(Node->getNumOperands() == 4); + + RISCVVSEW VSEW = + static_cast(Node->getConstantOperandVal(2) & 0x7); + RISCVVLMUL VLMul = + static_cast(Node->getConstantOperandVal(3) & 0x7); + + unsigned VTypeI = RISCVVType::encodeVTYPE( + VLMul, VSEW, /*TailAgnostic*/ true, /*MaskAgnostic*/ false); + SDValue VTypeIOp = CurDAG->getTargetConstant(VTypeI, DL, XLenVT); + + SDValue VLOperand = CurDAG->getRegister(RISCV::X0, XLenVT); + ReplaceNode(Node, + CurDAG->getMachineNode(RISCV::PseudoVSETVLI, DL, XLenVT, +
[llvm-branch-commits] [llvm] 08c4b40 - Rename files with same (case insensitive) name
Author: Chih-Ping Chen Date: 2020-12-18T16:01:37-05:00 New Revision: 08c4b4054b3ded660fc87ccbaa9a6bc4e390f6ff URL: https://github.com/llvm/llvm-project/commit/08c4b4054b3ded660fc87ccbaa9a6bc4e390f6ff DIFF: https://github.com/llvm/llvm-project/commit/08c4b4054b3ded660fc87ccbaa9a6bc4e390f6ff.diff LOG: Rename files with same (case insensitive) name Patch by: Aditya Kumar. Differential Revision: https://reviews.llvm.org/D93559 Added: llvm/test/DebugInfo/X86/dimodule-external-fortran.ll Modified: Removed: llvm/test/DebugInfo/X86/dimodule.ll diff --git a/llvm/test/DebugInfo/X86/dimodule.ll b/llvm/test/DebugInfo/X86/dimodule-external-fortran.ll similarity index 100% rename from llvm/test/DebugInfo/X86/dimodule.ll rename to llvm/test/DebugInfo/X86/dimodule-external-fortran.ll ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [llvm] d4ed253 - [RISCV] Assume no-op addrspacecasts by default
Author: Fraser Cormack Date: 2020-12-18T21:03:37Z New Revision: d4ed253d0b8487d9e9fd95a3895f83c437e5e7bb URL: https://github.com/llvm/llvm-project/commit/d4ed253d0b8487d9e9fd95a3895f83c437e5e7bb DIFF: https://github.com/llvm/llvm-project/commit/d4ed253d0b8487d9e9fd95a3895f83c437e5e7bb.diff LOG: [RISCV] Assume no-op addrspacecasts by default To support OpenCL, which typically uses SPIR as an IR, non-zero address spaces must be accounted for. This patch makes the RISC-V target assume no-op address space casts across the board, which effectively removes the need to support addrspacecast instructions in the backend. For a RISC-V implementation with different configurations or specialized address spaces where casts aren't no-ops, the function can be adjusted as required. Reviewed By: jrtc27 Differential Revision: https://reviews.llvm.org/D93536 Added: llvm/test/CodeGen/RISCV/addrspacecast.ll Modified: llvm/lib/Target/RISCV/RISCVTargetMachine.cpp llvm/lib/Target/RISCV/RISCVTargetMachine.h Removed: diff --git a/llvm/lib/Target/RISCV/RISCVTargetMachine.cpp b/llvm/lib/Target/RISCV/RISCVTargetMachine.cpp index 5851f56bf4cf..5e1b623db056 100644 --- a/llvm/lib/Target/RISCV/RISCVTargetMachine.cpp +++ b/llvm/lib/Target/RISCV/RISCVTargetMachine.cpp @@ -113,6 +113,15 @@ RISCVTargetMachine::getTargetTransformInfo(const Function &F) { return TargetTransformInfo(RISCVTTIImpl(this, F)); } +// A RISC-V hart has a single byte-addressable address space of 2^XLEN bytes +// for all memory accesses, so it is reasonable to assume that an +// implementation has no-op address space casts. If an implementation makes a +// change to this, they can override it here. +bool RISCVTargetMachine::isNoopAddrSpaceCast(unsigned SrcAS, + unsigned DstAS) const { + return true; +} + namespace { class RISCVPassConfig : public TargetPassConfig { public: diff --git a/llvm/lib/Target/RISCV/RISCVTargetMachine.h b/llvm/lib/Target/RISCV/RISCVTargetMachine.h index a4476fa40a7d..9d1e04a42f72 100644 --- a/llvm/lib/Target/RISCV/RISCVTargetMachine.h +++ b/llvm/lib/Target/RISCV/RISCVTargetMachine.h @@ -43,6 +43,9 @@ class RISCVTargetMachine : public LLVMTargetMachine { } TargetTransformInfo getTargetTransformInfo(const Function &F) override; + + virtual bool isNoopAddrSpaceCast(unsigned SrcAS, + unsigned DstAS) const override; }; } diff --git a/llvm/test/CodeGen/RISCV/addrspacecast.ll b/llvm/test/CodeGen/RISCV/addrspacecast.ll new file mode 100644 index ..1519e1ec6e5d --- /dev/null +++ b/llvm/test/CodeGen/RISCV/addrspacecast.ll @@ -0,0 +1,49 @@ +; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py +; RUN: llc -mtriple=riscv32 -verify-machineinstrs < %s \ +; RUN: | FileCheck %s --check-prefix=RV32I +; RUN: llc -mtriple=riscv64 -verify-machineinstrs < %s \ +; RUN: | FileCheck %s --check-prefix=RV64I + +define void @cast0(i32 addrspace(1)* %ptr) { +; RV32I-LABEL: cast0: +; RV32I: # %bb.0: +; RV32I-NEXT:sw zero, 0(a0) +; RV32I-NEXT:ret +; +; RV64I-LABEL: cast0: +; RV64I: # %bb.0: +; RV64I-NEXT:sw zero, 0(a0) +; RV64I-NEXT:ret + %ptr0 = addrspacecast i32 addrspace(1)* %ptr to i32 addrspace(0)* + store i32 0, i32* %ptr0 + ret void +} + +define void @cast1(i32* %ptr) { +; RV32I-LABEL: cast1: +; RV32I: # %bb.0: +; RV32I-NEXT:addi sp, sp, -16 +; RV32I-NEXT:.cfi_def_cfa_offset 16 +; RV32I-NEXT:sw ra, 12(sp) # 4-byte Folded Spill +; RV32I-NEXT:.cfi_offset ra, -4 +; RV32I-NEXT:call foo@plt +; RV32I-NEXT:lw ra, 12(sp) # 4-byte Folded Reload +; RV32I-NEXT:addi sp, sp, 16 +; RV32I-NEXT:ret +; +; RV64I-LABEL: cast1: +; RV64I: # %bb.0: +; RV64I-NEXT:addi sp, sp, -16 +; RV64I-NEXT:.cfi_def_cfa_offset 16 +; RV64I-NEXT:sd ra, 8(sp) # 8-byte Folded Spill +; RV64I-NEXT:.cfi_offset ra, -8 +; RV64I-NEXT:call foo@plt +; RV64I-NEXT:ld ra, 8(sp) # 8-byte Folded Reload +; RV64I-NEXT:addi sp, sp, 16 +; RV64I-NEXT:ret + %castptr = addrspacecast i32* %ptr to i32 addrspace(10)* + call void @foo(i32 addrspace(10)* %castptr) + ret void +} + +declare void @foo(i32 addrspace(10)*) ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [clang] b4c63ef - [c++20] Mark class type NTTPs as done and start defining the feature test macro.
Author: Richard Smith Date: 2020-12-18T13:42:23-08:00 New Revision: b4c63ef6dd90dba9af26a111c9a78b121c5284b1 URL: https://github.com/llvm/llvm-project/commit/b4c63ef6dd90dba9af26a111c9a78b121c5284b1 DIFF: https://github.com/llvm/llvm-project/commit/b4c63ef6dd90dba9af26a111c9a78b121c5284b1.diff LOG: [c++20] Mark class type NTTPs as done and start defining the feature test macro. Added: Modified: clang/lib/Frontend/InitPreprocessor.cpp clang/test/Lexer/cxx-features.cpp clang/www/cxx_status.html Removed: diff --git a/clang/lib/Frontend/InitPreprocessor.cpp b/clang/lib/Frontend/InitPreprocessor.cpp index f2c8d0f6b59a..d4b77a65aa63 100644 --- a/clang/lib/Frontend/InitPreprocessor.cpp +++ b/clang/lib/Frontend/InitPreprocessor.cpp @@ -565,7 +565,7 @@ static void InitializeCPlusPlusFeatureTestMacros(const LangOptions &LangOpts, Builder.defineMacro("__cpp_aggregate_bases", "201603L"); Builder.defineMacro("__cpp_structured_bindings", "201606L"); Builder.defineMacro("__cpp_nontype_template_args", -"201411L"); // (not latest) +LangOpts.CPlusPlus20 ? "201911L" : "201411L"); Builder.defineMacro("__cpp_fold_expressions", "201603L"); Builder.defineMacro("__cpp_guaranteed_copy_elision", "201606L"); Builder.defineMacro("__cpp_nontype_template_parameter_auto", "201606L"); diff --git a/clang/test/Lexer/cxx-features.cpp b/clang/test/Lexer/cxx-features.cpp index 8b9cb5434730..afc3b56d8a37 100644 --- a/clang/test/Lexer/cxx-features.cpp +++ b/clang/test/Lexer/cxx-features.cpp @@ -155,7 +155,7 @@ #error "wrong value for __cpp_structured_bindings" #endif -#if check(nontype_template_args, 0, 0, 0, 201411, 201411) +#if check(nontype_template_args, 0, 0, 0, 201411, 201911) #error "wrong value for __cpp_nontype_template_args" #endif diff --git a/clang/www/cxx_status.html b/clang/www/cxx_status.html index 4a66b7f9465e..923b13db73a6 100755 --- a/clang/www/cxx_status.html +++ b/clang/www/cxx_status.html @@ -1005,7 +1005,7 @@ C++20 implementation status Class types as non-type template parameters https://wg21.link/p0732r2";>P0732R2 - No + Clang 12 https://wg21.link/p1907r1";>P1907R1 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [clang] 939ba0b - Add tests for the absence of feature test macros for features we don't
Author: Richard Smith Date: 2020-12-18T13:42:23-08:00 New Revision: 939ba0b501b27a2535c9bb62b6f6dc027d49f76d URL: https://github.com/llvm/llvm-project/commit/939ba0b501b27a2535c9bb62b6f6dc027d49f76d DIFF: https://github.com/llvm/llvm-project/commit/939ba0b501b27a2535c9bb62b6f6dc027d49f76d.diff LOG: Add tests for the absence of feature test macros for features we don't support yet. Added: Modified: clang/test/Lexer/cxx-features.cpp Removed: diff --git a/clang/test/Lexer/cxx-features.cpp b/clang/test/Lexer/cxx-features.cpp index afc3b56d8a37..852c53449568 100644 --- a/clang/test/Lexer/cxx-features.cpp +++ b/clang/test/Lexer/cxx-features.cpp @@ -28,16 +28,30 @@ // --- C++20 features --- +#if check(aggregate_paren_init, 0, 0, 0, 0, 0) +// FIXME: 201902 in C++20 +#error "wrong value for __cpp_aggregate_paren_init" +#endif + #if defined(CHAR8_T) ? check(char8_t, 201811, 201811, 201811, 201811, 201811) : \ defined(NO_CHAR8_T) ? check(char8_t, 0, 0, 0, 0, 0) : \ check(char8_t, 0, 0, 0, 0, 201811) #error "wrong value for __cpp_char8_t" #endif +#if check(concepts, 0, 0, 0, 0, 201907) +#error "wrong value for __cpp_concepts" +#endif + #if check(conditional_explicit, 0, 0, 0, 0, 201806) #error "wrong value for __cpp_conditional_explicit" #endif +#if check(consteval, 0, 0, 0, 0, 0) +// FIXME: 201811 in C++20 +#error "wrong value for __cpp_consteval" +#endif + // constexpr checked below #if check(constexpr_dynamic_alloc, 0, 0, 0, 0, 201907) @@ -52,6 +66,8 @@ #error "wrong value for __cpp_constinit" #endif +// deduction_guides checked below + #if check(designated_initializers, 0, 0, 0, 0, 201707) #error "wrong value for __cpp_designated_initializers" #endif @@ -68,8 +84,14 @@ // init_captures checked below -#if check(concepts, 0, 0, 0, 0, 201907) -#error "wrong value for __cpp_concepts" +#if check(modules, 0, 0, 0, 0, 0) +// FIXME: 201907 in C++20 +#error "wrong value for __cpp_modules" +#endif + +#if check(using_enum, 0, 0, 0, 0, 0) +// FIXME: 201907 in C++20 +#error "wrong value for __cpp_using_enum" #endif // --- C++17 features --- @@ -113,6 +135,7 @@ // static_assert checked below #if check(deduction_guides, 0, 0, 0, 201703, 201703) +// FIXME: 201907 in C++20 #error "wrong value for __cpp_deduction_guides" #endif ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [clang] 72d8f79 - [c++2b] Add tests for feature test macros.
Author: Richard Smith Date: 2020-12-18T13:42:23-08:00 New Revision: 72d8f79f0c31c9b95454672b2319ac3eea8d2f9b URL: https://github.com/llvm/llvm-project/commit/72d8f79f0c31c9b95454672b2319ac3eea8d2f9b DIFF: https://github.com/llvm/llvm-project/commit/72d8f79f0c31c9b95454672b2319ac3eea8d2f9b.diff LOG: [c++2b] Add tests for feature test macros. Added: Modified: clang/test/Lexer/cxx-features.cpp Removed: diff --git a/clang/test/Lexer/cxx-features.cpp b/clang/test/Lexer/cxx-features.cpp index 852c53449568..f57faed4ed90 100644 --- a/clang/test/Lexer/cxx-features.cpp +++ b/clang/test/Lexer/cxx-features.cpp @@ -2,7 +2,8 @@ // RUN: %clang_cc1 -std=c++11 -fcxx-exceptions -verify %s // RUN: %clang_cc1 -std=c++14 -fcxx-exceptions -fsized-deallocation -verify %s // RUN: %clang_cc1 -std=c++17 -fcxx-exceptions -fsized-deallocation -verify %s -// RUN: %clang_cc1 -std=c++2a -fcxx-exceptions -fsized-deallocation -verify %s +// RUN: %clang_cc1 -std=c++20 -fcxx-exceptions -fsized-deallocation -verify %s +// RUN: %clang_cc1 -std=c++2b -fcxx-exceptions -fsized-deallocation -verify %s // // RUN: %clang_cc1 -std=c++17 -fcxx-exceptions -fsized-deallocation -frelaxed-template-template-args -DRELAXED_TEMPLATE_TEMPLATE_ARGS=1 -verify %s // RUN: %clang_cc1 -std=c++17 -fcxx-exceptions -fsized-deallocation -DCONCEPTS_TS=1 -verify %s @@ -15,118 +16,120 @@ // FIXME using `defined` in a macro has undefined behavior. #if __cplusplus < 201103L -#define check(macro, cxx98, cxx11, cxx14, cxx17, cxx20) (cxx98 == 0 ? defined(__cpp_##macro) : __cpp_##macro != cxx98) +#define check(macro, cxx98, cxx11, cxx14, cxx17, cxx20, cxx23) (cxx98 == 0 ? defined(__cpp_##macro) : __cpp_##macro != cxx98) #elif __cplusplus < 201402L -#define check(macro, cxx98, cxx11, cxx14, cxx17, cxx20) (cxx11 == 0 ? defined(__cpp_##macro) : __cpp_##macro != cxx11) +#define check(macro, cxx98, cxx11, cxx14, cxx17, cxx20, cxx23) (cxx11 == 0 ? defined(__cpp_##macro) : __cpp_##macro != cxx11) #elif __cplusplus < 201703L -#define check(macro, cxx98, cxx11, cxx14, cxx17, cxx20) (cxx14 == 0 ? defined(__cpp_##macro) : __cpp_##macro != cxx14) -#elif __cplusplus <= 201703L -#define check(macro, cxx98, cxx11, cxx14, cxx17, cxx20) (cxx17 == 0 ? defined(__cpp_##macro) : __cpp_##macro != cxx17) +#define check(macro, cxx98, cxx11, cxx14, cxx17, cxx20, cxx23) (cxx14 == 0 ? defined(__cpp_##macro) : __cpp_##macro != cxx14) +#elif __cplusplus < 202002L +#define check(macro, cxx98, cxx11, cxx14, cxx17, cxx20, cxx23) (cxx17 == 0 ? defined(__cpp_##macro) : __cpp_##macro != cxx17) +#elif __cplusplus == 202002L +#define check(macro, cxx98, cxx11, cxx14, cxx17, cxx20, cxx23) (cxx20 == 0 ? defined(__cpp_##macro) : __cpp_##macro != cxx20) #else -#define check(macro, cxx98, cxx11, cxx14, cxx17, cxx20) (cxx20 == 0 ? defined(__cpp_##macro) : __cpp_##macro != cxx20) +#define check(macro, cxx98, cxx11, cxx14, cxx17, cxx20, cxx23) (cxx23 == 0 ? defined(__cpp_##macro) : __cpp_##macro != cxx23) #endif // --- C++20 features --- -#if check(aggregate_paren_init, 0, 0, 0, 0, 0) +#if check(aggregate_paren_init, 0, 0, 0, 0, 0, 0) // FIXME: 201902 in C++20 #error "wrong value for __cpp_aggregate_paren_init" #endif -#if defined(CHAR8_T) ? check(char8_t, 201811, 201811, 201811, 201811, 201811) : \ -defined(NO_CHAR8_T) ? check(char8_t, 0, 0, 0, 0, 0) : \ -check(char8_t, 0, 0, 0, 0, 201811) +#if defined(CHAR8_T) ? check(char8_t, 201811, 201811, 201811, 201811, 201811, 201811) : \ +defined(NO_CHAR8_T) ? check(char8_t, 0, 0, 0, 0, 0, 0) : \ +check(char8_t, 0, 0, 0, 0, 201811, 201811) #error "wrong value for __cpp_char8_t" #endif -#if check(concepts, 0, 0, 0, 0, 201907) +#if check(concepts, 0, 0, 0, 0, 201907, 201907) #error "wrong value for __cpp_concepts" #endif -#if check(conditional_explicit, 0, 0, 0, 0, 201806) +#if check(conditional_explicit, 0, 0, 0, 0, 201806, 201806) #error "wrong value for __cpp_conditional_explicit" #endif -#if check(consteval, 0, 0, 0, 0, 0) +#if check(consteval, 0, 0, 0, 0, 0, 0) // FIXME: 201811 in C++20 #error "wrong value for __cpp_consteval" #endif // constexpr checked below -#if check(constexpr_dynamic_alloc, 0, 0, 0, 0, 201907) +#if check(constexpr_dynamic_alloc, 0, 0, 0, 0, 201907, 201907) #error "wrong value for __cpp_constexpr_dynamic_alloc" #endif -#if check(constexpr_in_decltype, 0, 201711, 201711, 201711, 201711) +#if check(constexpr_in_decltype, 0, 201711, 201711, 201711, 201711, 201711) #error "wrong value for __cpp_constexpr_in_decltype" #endif -#if check(constinit, 0, 0, 0, 0, 201907) +#if check(constinit, 0, 0, 0, 0, 201907, 201907) #error "wrong value for __cpp_constinit" #endif // deduction_guides checked below -#if check(designated_initializers, 0, 0, 0, 0, 201707) +#if check(designated_initializers, 0, 0, 0, 0, 201707, 201707) #error "wrong value for __cpp_designated_initializ
[llvm-branch-commits] [clang] ed13d8c - Fix memory leak complicated non-type template arguments.
Author: Richard Smith Date: 2020-12-18T13:42:24-08:00 New Revision: ed13d8c66781b50ff007cb089c5905f9bb9e8af2 URL: https://github.com/llvm/llvm-project/commit/ed13d8c66781b50ff007cb089c5905f9bb9e8af2 DIFF: https://github.com/llvm/llvm-project/commit/ed13d8c66781b50ff007cb089c5905f9bb9e8af2.diff LOG: Fix memory leak complicated non-type template arguments. Added: Modified: clang/include/clang/AST/ASTContext.h clang/lib/AST/TemplateBase.cpp Removed: diff --git a/clang/include/clang/AST/ASTContext.h b/clang/include/clang/AST/ASTContext.h index 0c5d82b3e9aa..a9bfdb4d5fa5 100644 --- a/clang/include/clang/AST/ASTContext.h +++ b/clang/include/clang/AST/ASTContext.h @@ -2818,8 +2818,8 @@ class ASTContext : public RefCountedBase { /// for destruction. template void addDestruction(T *Ptr) const { if (!std::is_trivially_destructible::value) { - auto DestroyPtr = [](void *V) { static_cast(V)->~T(); }; - AddDeallocation(DestroyPtr, Ptr); + auto DestroyPtr = [](void *V) { ((T*)V)->~T(); }; + AddDeallocation(DestroyPtr, (void*)Ptr); } } diff --git a/clang/lib/AST/TemplateBase.cpp b/clang/lib/AST/TemplateBase.cpp index 0029c90a0ab6..a746db315d85 100644 --- a/clang/lib/AST/TemplateBase.cpp +++ b/clang/lib/AST/TemplateBase.cpp @@ -137,6 +137,7 @@ TemplateArgument::TemplateArgument(const ASTContext &Ctx, QualType Type, else { Value.Kind = UncommonValue; Value.Value = new (Ctx) APValue(V); +Ctx.addDestruction(Value.Value); Value.Type = Type.getAsOpaquePtr(); } } ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [llvm] 37d0dda - [SLP] fix typo; NFC
Author: Sanjay Patel Date: 2020-12-18T16:55:52-05:00 New Revision: 37d0dda739aa5ebc1ad8cca8c570788b2a3ef5cf URL: https://github.com/llvm/llvm-project/commit/37d0dda739aa5ebc1ad8cca8c570788b2a3ef5cf DIFF: https://github.com/llvm/llvm-project/commit/37d0dda739aa5ebc1ad8cca8c570788b2a3ef5cf.diff LOG: [SLP] fix typo; NFC Added: Modified: llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp Removed: diff --git a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp index 9ab89e091596..80d510185470 100644 --- a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp +++ b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp @@ -6911,12 +6911,12 @@ class HorizontalReduction { ReductionData.initReductionOps(ReductionOps); while (!Stack.empty()) { Instruction *TreeN = Stack.back().first; - unsigned EdgeToVist = Stack.back().second++; + unsigned EdgeToVisit = Stack.back().second++; OperationData OpData = getOperationData(TreeN); bool IsReducedValue = OpData != ReductionData; // Postorder vist. - if (IsReducedValue || EdgeToVist == OpData.getNumberOfOperands()) { + if (IsReducedValue || EdgeToVisit == OpData.getNumberOfOperands()) { if (IsReducedValue) ReducedVals.push_back(TreeN); else { @@ -6942,7 +6942,7 @@ class HorizontalReduction { } // Visit left or right. - Value *NextV = TreeN->getOperand(EdgeToVist); + Value *NextV = TreeN->getOperand(EdgeToVisit); if (NextV != Phi) { auto *I = dyn_cast(NextV); OpData = getOperationData(I); ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [llvm] 7948cd1 - [RISCV] Address clang-tidy warnings in RISCVTargetMachine. NFC.
Author: Fraser Cormack Date: 2020-12-18T21:50:55Z New Revision: 7948cd11d17bea2d8679b9898d9debdcec5c11be URL: https://github.com/llvm/llvm-project/commit/7948cd11d17bea2d8679b9898d9debdcec5c11be DIFF: https://github.com/llvm/llvm-project/commit/7948cd11d17bea2d8679b9898d9debdcec5c11be.diff LOG: [RISCV] Address clang-tidy warnings in RISCVTargetMachine. NFC. Added: Modified: llvm/lib/Target/RISCV/RISCVTargetMachine.cpp llvm/lib/Target/RISCV/RISCVTargetMachine.h Removed: diff --git a/llvm/lib/Target/RISCV/RISCVTargetMachine.cpp b/llvm/lib/Target/RISCV/RISCVTargetMachine.cpp index 5e1b623db056..fe352296fb73 100644 --- a/llvm/lib/Target/RISCV/RISCVTargetMachine.cpp +++ b/llvm/lib/Target/RISCV/RISCVTargetMachine.cpp @@ -35,7 +35,7 @@ using namespace llvm; extern "C" LLVM_EXTERNAL_VISIBILITY void LLVMInitializeRISCVTarget() { RegisterTargetMachine X(getTheRISCV32Target()); RegisterTargetMachine Y(getTheRISCV64Target()); - auto PR = PassRegistry::getPassRegistry(); + auto *PR = PassRegistry::getPassRegistry(); initializeGlobalISel(*PR); initializeRISCVMergeBaseOffsetOptPass(*PR); initializeRISCVExpandPseudoPass(*PR); @@ -43,12 +43,10 @@ extern "C" LLVM_EXTERNAL_VISIBILITY void LLVMInitializeRISCVTarget() { } static StringRef computeDataLayout(const Triple &TT) { - if (TT.isArch64Bit()) { + if (TT.isArch64Bit()) return "e-m:e-p:64:64-i64:64-i128:128-n64-S128"; - } else { -assert(TT.isArch32Bit() && "only RV32 and RV64 are currently supported"); -return "e-m:e-p:32:32-i64:64-n32-S128"; - } + assert(TT.isArch32Bit() && "only RV32 and RV64 are currently supported"); + return "e-m:e-p:32:32-i64:64-n32-S128"; } static Reloc::Model getEffectiveRelocModel(const Triple &TT, @@ -143,7 +141,7 @@ class RISCVPassConfig : public TargetPassConfig { void addPreSched2() override; void addPreRegAlloc() override; }; -} +} // namespace TargetPassConfig *RISCVTargetMachine::createPassConfig(PassManagerBase &PM) { return new RISCVPassConfig(*this, PM); diff --git a/llvm/lib/Target/RISCV/RISCVTargetMachine.h b/llvm/lib/Target/RISCV/RISCVTargetMachine.h index 9d1e04a42f72..3156333f7ee1 100644 --- a/llvm/lib/Target/RISCV/RISCVTargetMachine.h +++ b/llvm/lib/Target/RISCV/RISCVTargetMachine.h @@ -47,6 +47,6 @@ class RISCVTargetMachine : public LLVMTargetMachine { virtual bool isNoopAddrSpaceCast(unsigned SrcAS, unsigned DstAS) const override; }; -} +} // namespace llvm #endif ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [clang] f5cef87 - [www] Remove '$Date$' marker from cxx_dr_status.
Author: Richard Smith Date: 2020-12-18T14:14:52-08:00 New Revision: f5cef870d116104354fe557c71025a9d4bfbe952 URL: https://github.com/llvm/llvm-project/commit/f5cef870d116104354fe557c71025a9d4bfbe952 DIFF: https://github.com/llvm/llvm-project/commit/f5cef870d116104354fe557c71025a9d4bfbe952.diff LOG: [www] Remove '$Date$' marker from cxx_dr_status. This doesn't actually work (any more?), and instead renders as a literal $Date$ on the website. Added: Modified: clang/www/cxx_dr_status.html clang/www/make_cxx_dr_status Removed: diff --git a/clang/www/cxx_dr_status.html b/clang/www/cxx_dr_status.html index b40d2c53bdec..9be6f1262b68 100755 --- a/clang/www/cxx_dr_status.html +++ b/clang/www/cxx_dr_status.html @@ -28,7 +28,6 @@ C++ Defect Report Support in Clang -Last updated: $Date$ C++ defect report implementation status diff --git a/clang/www/make_cxx_dr_status b/clang/www/make_cxx_dr_status index 3a9b18f59cfd..ee113779e32d 100755 --- a/clang/www/make_cxx_dr_status +++ b/clang/www/make_cxx_dr_status @@ -79,7 +79,6 @@ print >> out_file, '''\ C++ Defect Report Support in Clang -Last updated: $Date$ C++ defect report implementation status ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [llvm] adc55b5 - [X86] Avoid generating invalid R_X86_64_GOTPCRELX relocations
Author: Harald van Dijk Date: 2020-12-18T23:38:38Z New Revision: adc55b5a5ae49f1fe3a04f7f79b1c08f508b4307 URL: https://github.com/llvm/llvm-project/commit/adc55b5a5ae49f1fe3a04f7f79b1c08f508b4307 DIFF: https://github.com/llvm/llvm-project/commit/adc55b5a5ae49f1fe3a04f7f79b1c08f508b4307.diff LOG: [X86] Avoid generating invalid R_X86_64_GOTPCRELX relocations We need to make sure not to emit R_X86_64_GOTPCRELX relocations for instructions that use a REX prefix. If a REX prefix is present, we need to instead use a R_X86_64_REX_GOTPCRELX relocation. The existing logic for CALL64m, JMP64m, etc. already handles this by checking the HasREX parameter and using it to determine which relocation type to use. Do this for all instructions that can use relaxed relocations. Reviewed By: MaskRay Differential Revision: https://reviews.llvm.org/D93561 Added: Modified: lld/test/ELF/x86-64-gotpc-relax-nopic.s llvm/lib/Target/X86/MCTargetDesc/X86MCCodeEmitter.cpp llvm/test/MC/X86/gotpcrelx.s Removed: llvm/test/MC/ELF/got-relaxed-rex.s diff --git a/lld/test/ELF/x86-64-gotpc-relax-nopic.s b/lld/test/ELF/x86-64-gotpc-relax-nopic.s index 501414f7bdde..81d25f9ecafb 100644 --- a/lld/test/ELF/x86-64-gotpc-relax-nopic.s +++ b/lld/test/ELF/x86-64-gotpc-relax-nopic.s @@ -23,8 +23,8 @@ # DISASM-NEXT: orl {{.*}}(%rip), %edi # 202240 # DISASM-NEXT: sbbl {{.*}}(%rip), %esi # 202240 # DISASM-NEXT: subl {{.*}}(%rip), %ebp # 202240 -# DISASM-NEXT: xorl {{.*}}(%rip), %r8d # 202240 -# DISASM-NEXT: testl %r15d, {{.*}}(%rip) # 202240 +# DISASM-NEXT: xorl $0x203248, %r8d +# DISASM-NEXT: testl $0x203248, %r15d # DISASM-NEXT: 201200: adcq $0x203248, %rax # DISASM-NEXT: addq $0x203248, %rbx # DISASM-NEXT: andq $0x203248, %rcx diff --git a/llvm/lib/Target/X86/MCTargetDesc/X86MCCodeEmitter.cpp b/llvm/lib/Target/X86/MCTargetDesc/X86MCCodeEmitter.cpp index 59860cad01f7..260253a5302d 100644 --- a/llvm/lib/Target/X86/MCTargetDesc/X86MCCodeEmitter.cpp +++ b/llvm/lib/Target/X86/MCTargetDesc/X86MCCodeEmitter.cpp @@ -409,6 +409,12 @@ void X86MCCodeEmitter::emitMemModRMByte(const MCInst &MI, unsigned Op, switch (Opcode) { default: return X86::reloc_riprel_4byte; + case X86::MOV64rm: +// movq loads is a subset of reloc_riprel_4byte_relax_rex. It is a +// special case because COFF and Mach-O don't support ELF's more +// flexible R_X86_64_REX_GOTPCRELX relaxation. +assert(HasREX); +return X86::reloc_riprel_4byte_movq_load; case X86::ADC32rm: case X86::ADD32rm: case X86::AND32rm: @@ -419,13 +425,6 @@ void X86MCCodeEmitter::emitMemModRMByte(const MCInst &MI, unsigned Op, case X86::SUB32rm: case X86::TEST32mr: case X86::XOR32rm: -return X86::reloc_riprel_4byte_relax; - case X86::MOV64rm: -// movq loads is a subset of reloc_riprel_4byte_relax_rex. It is a -// special case because COFF and Mach-O don't support ELF's more -// flexible R_X86_64_REX_GOTPCRELX relaxation. -assert(HasREX); -return X86::reloc_riprel_4byte_movq_load; case X86::CALL64m: case X86::JMP64m: case X86::TAILJMPm64: diff --git a/llvm/test/MC/ELF/got-relaxed-rex.s b/llvm/test/MC/ELF/got-relaxed-rex.s deleted file mode 100644 index 1924bddc473e.. --- a/llvm/test/MC/ELF/got-relaxed-rex.s +++ /dev/null @@ -1,36 +0,0 @@ -// RUN: llvm-mc -filetype=obj -triple x86_64-pc-linux %s -o - | llvm-readobj -r - | FileCheck %s - -// these should produce R_X86_64_REX_GOTPCRELX - -movq mov@GOTPCREL(%rip), %rax -test %rax, test@GOTPCREL(%rip) -adc adc@GOTPCREL(%rip), %rax -add add@GOTPCREL(%rip), %rax -and and@GOTPCREL(%rip), %rax -cmp cmp@GOTPCREL(%rip), %rax -or or@GOTPCREL(%rip), %rax -sbb sbb@GOTPCREL(%rip), %rax -sub sub@GOTPCREL(%rip), %rax -xor xor@GOTPCREL(%rip), %rax - -.section .norelax,"ax" -## This expression loads the GOT entry with an offset. -## Don't emit R_X86_64_REX_GOTPCRELX. -movq mov@GOTPCREL+1(%rip), %rax - -// CHECK: Relocations [ -// CHECK-NEXT: Section ({{.*}}) .rela.text { -// CHECK-NEXT: R_X86_64_REX_GOTPCRELX mov -// CHECK-NEXT: R_X86_64_REX_GOTPCRELX test -// CHECK-NEXT: R_X86_64_REX_GOTPCRELX adc -// CHECK-NEXT: R_X86_64_REX_GOTPCRELX add -// CHECK-NEXT: R_X86_64_REX_GOTPCRELX and -// CHECK-NEXT: R_X86_64_REX_GOTPCRELX cmp -// CHECK-NEXT: R_X86_64_REX_GOTPCRELX or -// CHECK-NEXT: R_X86_64_REX_GOTPCRELX sbb -// CHECK-NEXT: R_X86_64_REX_GOTPCRELX sub -// CHECK-NEXT: R_X86_64_REX_GOTPCRELX xor -// CHECK-NEXT: } -// CHECK-NEXT: Section ({{.*}}) .rela.norelax { -// CHECK-N
[llvm-branch-commits] [clang-tools-extra] b061564 - [clangd] Make our printing policies for Hover more consistent, especially tags
Author: Sam McCall Date: 2020-12-19T00:52:55+01:00 New Revision: b0615642f647bea1483659f1e14515a836015254 URL: https://github.com/llvm/llvm-project/commit/b0615642f647bea1483659f1e14515a836015254 DIFF: https://github.com/llvm/llvm-project/commit/b0615642f647bea1483659f1e14515a836015254.diff LOG: [clangd] Make our printing policies for Hover more consistent, especially tags Different cases were using a bunch of different variants of the printing policy. Each of these had something going for it, but the result was inconsistent. Goals: - single printing policy used (almost) everywhere - avoid unidiomatic tags like `class vector` - be informative and easy to understand For tags, the solution I wound up with is: we print only the outer tag and only in the simplest cases where this elaboration won't cause confusion. For example: - class X - enum Foo - vector - X* This seems to strike a nice balance of providing plenty of info/context in common cases while never being confusing. Differential Revision: https://reviews.llvm.org/D93553 Added: Modified: clang-tools-extra/clangd/Hover.cpp clang-tools-extra/clangd/unittests/HoverTests.cpp Removed: diff --git a/clang-tools-extra/clangd/Hover.cpp b/clang-tools-extra/clangd/Hover.cpp index b5eda93ddbbc..6d707c8d1521 100644 --- a/clang-tools-extra/clangd/Hover.cpp +++ b/clang-tools-extra/clangd/Hover.cpp @@ -49,16 +49,13 @@ namespace clang { namespace clangd { namespace { -PrintingPolicy printingPolicyForDecls(PrintingPolicy Base) { - PrintingPolicy Policy(Base); - - Policy.AnonymousTagLocations = false; - Policy.TerseOutput = true; - Policy.PolishForDeclaration = true; - Policy.ConstantsAsWritten = true; - Policy.SuppressTagKeyword = false; - - return Policy; +PrintingPolicy getPrintingPolicy(PrintingPolicy Base) { + Base.AnonymousTagLocations = false; + Base.TerseOutput = true; + Base.PolishForDeclaration = true; + Base.ConstantsAsWritten = true; + Base.SuppressTemplateArgsInCXXConstructors = true; + return Base; } /// Given a declaration \p D, return a human-readable string representing the @@ -108,26 +105,33 @@ std::string getNamespaceScope(const Decl *D) { return ""; } -std::string printDefinition(const Decl *D) { +std::string printDefinition(const Decl *D, const PrintingPolicy &PP) { std::string Definition; llvm::raw_string_ostream OS(Definition); - PrintingPolicy Policy = - printingPolicyForDecls(D->getASTContext().getPrintingPolicy()); - Policy.IncludeTagDefinition = false; - Policy.SuppressTemplateArgsInCXXConstructors = true; - Policy.SuppressTagKeyword = true; - D->print(OS, Policy); + D->print(OS, PP); OS.flush(); return Definition; } -std::string printType(QualType QT, const PrintingPolicy &Policy) { +std::string printType(QualType QT, const PrintingPolicy &PP) { // TypePrinter doesn't resolve decltypes, so resolve them here. // FIXME: This doesn't handle composite types that contain a decltype in them. // We should rather have a printing policy for that. while (!QT.isNull() && QT->isDecltypeType()) QT = QT->getAs()->getUnderlyingType(); - return QT.getAsString(Policy); + std::string Result; + llvm::raw_string_ostream OS(Result); + // Special case: if the outer type is a tag type without qualifiers, then + // include the tag for extra clarity. + // This isn't very idiomatic, so don't attempt it for complex cases, including + // pointers/references, template specializations, etc. + if (!QT.isNull() && !QT.hasQualifiers() && PP.SuppressTagKeyword) { +if (auto *TT = llvm::dyn_cast(QT.getTypePtr())) + OS << TT->getDecl()->getKindName() << " "; + } + OS.flush(); + QT.print(OS, PP); + return Result; } std::string printType(const TemplateTypeParmDecl *TTP) { @@ -291,15 +295,15 @@ const Expr *getDefaultArg(const ParmVarDecl *PVD) { } HoverInfo::Param toHoverInfoParam(const ParmVarDecl *PVD, - const PrintingPolicy &Policy) { + const PrintingPolicy &PP) { HoverInfo::Param Out; - Out.Type = printType(PVD->getType(), Policy); + Out.Type = printType(PVD->getType(), PP); if (!PVD->getName().empty()) Out.Name = PVD->getNameAsString(); if (const Expr *DefArg = getDefaultArg(PVD)) { Out.Default.emplace(); llvm::raw_string_ostream OS(*Out.Default); -DefArg->printPretty(OS, nullptr, Policy); +DefArg->printPretty(OS, nullptr, PP); } return Out; } @@ -307,10 +311,10 @@ HoverInfo::Param toHoverInfoParam(const ParmVarDecl *PVD, // Populates Type, ReturnType, and Parameters for function-like decls. void fillFunctionTypeAndParams(HoverInfo &HI, const Decl *D, const FunctionDecl *FD, - const PrintingPolicy &Policy) { + const PrintingPolicy &PP) { HI.Paramet
[llvm-branch-commits] [llvm] af83b74 - [VE] Support copy of vector mask registers
Author: Kazushi (Jam) Marukawa Date: 2020-12-19T09:16:43+09:00 New Revision: af83b74dc2e563c429dfcf5bd0a21dd2d4b8af7b URL: https://github.com/llvm/llvm-project/commit/af83b74dc2e563c429dfcf5bd0a21dd2d4b8af7b DIFF: https://github.com/llvm/llvm-project/commit/af83b74dc2e563c429dfcf5bd0a21dd2d4b8af7b.diff LOG: [VE] Support copy of vector mask registers Support VM and VMP registers in copyPhysReg() function. Also add regression tests. Reviewed By: simoll Differential Revision: https://reviews.llvm.org/D93547 Added: Modified: llvm/lib/Target/VE/VEInstrInfo.cpp llvm/test/CodeGen/VE/Vector/fastcc_callee.ll Removed: diff --git a/llvm/lib/Target/VE/VEInstrInfo.cpp b/llvm/lib/Target/VE/VEInstrInfo.cpp index 530c5d655931..9770052ff913 100644 --- a/llvm/lib/Target/VE/VEInstrInfo.cpp +++ b/llvm/lib/Target/VE/VEInstrInfo.cpp @@ -341,6 +341,11 @@ static void copyPhysSubRegs(MachineBasicBlock &MBB, MachineInstrBuilder MIB = BuildMI(MBB, I, DL, MCID, SubDest).addReg(SubSrc).addImm(0); MovMI = MIB.getInstr(); +} else if (MCID.getOpcode() == VE::ANDMmm) { + // generate "ANDM, dest, vm0, src" instruction. + MachineInstrBuilder MIB = + BuildMI(MBB, I, DL, MCID, SubDest).addReg(VE::VM0).addReg(SubSrc); + MovMI = MIB.getInstr(); } else { llvm_unreachable("Unexpected reg-to-reg copy instruction"); } @@ -379,6 +384,16 @@ void VEInstrInfo::copyPhysReg(MachineBasicBlock &MBB, .addReg(SrcReg, getKillRegState(KillSrc)) .addReg(SubTmp, getKillRegState(true)); MIB.getInstr()->addRegisterKilled(TmpReg, TRI, true); + } else if (VE::VMRegClass.contains(DestReg, SrcReg)) { +BuildMI(MBB, I, DL, get(VE::ANDMmm), DestReg) +.addReg(VE::VM0) +.addReg(SrcReg, getKillRegState(KillSrc)); + } else if (VE::VM512RegClass.contains(DestReg, SrcReg)) { +// Use two instructions. +const unsigned SubRegIdx[] = {VE::sub_vm_even, VE::sub_vm_odd}; +unsigned int NumSubRegs = 2; +copyPhysSubRegs(MBB, I, DL, DestReg, SrcReg, KillSrc, get(VE::ANDMmm), +NumSubRegs, SubRegIdx, &getRegisterInfo()); } else if (VE::F128RegClass.contains(DestReg, SrcReg)) { // Use two instructions. const unsigned SubRegIdx[] = {VE::sub_even, VE::sub_odd}; diff --git a/llvm/test/CodeGen/VE/Vector/fastcc_callee.ll b/llvm/test/CodeGen/VE/Vector/fastcc_callee.ll index fe601b082192..c0ad247d0e74 100644 --- a/llvm/test/CodeGen/VE/Vector/fastcc_callee.ll +++ b/llvm/test/CodeGen/VE/Vector/fastcc_callee.ll @@ -120,3 +120,20 @@ define fastcc <256 x i32> @vreg_arg_v256i32_r6(<256 x i32> %p0, <256 x i32> %p1, ; define <256 x i32> @vreg_arg_v256i32_r8(<256 x i32> %p0, <256 x i32> %p1, <256 x i32> %p2, <256 x i32> %p3, <256 x i32> %p4, <256 x i32> %p5, <256 x i32> %p6, <256 x i32> %p7, <256 x i32> %p8) { ; ret <256 x i32> %p8 ; } + +define fastcc <256 x i1> @vreg_arg_v256i1_vm7(<256 x i1> %vm1, <256 x i1> %vm2, <256 x i1> %vm3, <256 x i1> %vm4, <256 x i1> %vm5, <256 x i1> %vm6, <256 x i1> %vm7, <256 x i1> %vm8) { +; CHECK-LABEL: vreg_arg_v256i1_vm7: +; CHECK: # %bb.0: +; CHECK-NEXT:andm %vm1, %vm0, %vm6 +; CHECK-NEXT:b.l.t (, %s10) + ret <256 x i1> %vm6 +} + +define fastcc <512 x i1> @vreg_arg_v512i1_vmp3(<512 x i1> %vmp1, <512 x i1> %vmp2, <512 x i1> %vmp3, <512 x i1> %vmp4) { +; CHECK-LABEL: vreg_arg_v512i1_vmp3: +; CHECK: # %bb.0: +; CHECK-NEXT:andm %vm2, %vm0, %vm6 +; CHECK-NEXT:andm %vm3, %vm0, %vm7 +; CHECK-NEXT:b.l.t (, %s10) + ret <512 x i1> %vmp3 +} ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [llvm] ffd982f - [ObjC][ARC] Fix a bug where the inline-asm retain/claim RV marker wasn't
Author: Akira Hatanaka Date: 2020-12-18T16:59:06-08:00 New Revision: ffd982f7db58acf6653f987ca6411712feea25c3 URL: https://github.com/llvm/llvm-project/commit/ffd982f7db58acf6653f987ca6411712feea25c3 DIFF: https://github.com/llvm/llvm-project/commit/ffd982f7db58acf6653f987ca6411712feea25c3.diff LOG: [ObjC][ARC] Fix a bug where the inline-asm retain/claim RV marker wasn't inserted when the original call had a 'returned' argument The code is testing whether the instruction BBI points to is the call that is paired up with the retainRV/claimRV call, but it doesn't work when the call has a 'returned' argument since GetArgRCIdentityRoot looks through 'returned' arguments. rdar://72485383 Added: Modified: llvm/lib/Transforms/ObjCARC/ObjCARCContract.cpp llvm/test/Transforms/ObjCARC/contract-marker.ll Removed: diff --git a/llvm/lib/Transforms/ObjCARC/ObjCARCContract.cpp b/llvm/lib/Transforms/ObjCARC/ObjCARCContract.cpp index e190c46b613b..c2499fc85cf5 100644 --- a/llvm/lib/Transforms/ObjCARC/ObjCARCContract.cpp +++ b/llvm/lib/Transforms/ObjCARC/ObjCARCContract.cpp @@ -476,7 +476,7 @@ bool ObjCARCContract::tryToPeepholeInstruction( --BBI; } while (IsNoopInstruction(&*BBI)); -if (&*BBI == GetArgRCIdentityRoot(Inst)) { +if (GetRCIdentityRoot(&*BBI) == GetArgRCIdentityRoot(Inst)) { LLVM_DEBUG(dbgs() << "Adding inline asm marker for the return value " "optimization.\n"); Changed = true; diff --git a/llvm/test/Transforms/ObjCARC/contract-marker.ll b/llvm/test/Transforms/ObjCARC/contract-marker.ll index a93bbe3a2901..e2217068d5d1 100644 --- a/llvm/test/Transforms/ObjCARC/contract-marker.ll +++ b/llvm/test/Transforms/ObjCARC/contract-marker.ll @@ -32,11 +32,31 @@ entry: ret void } +; CHECK-LABEL: define i8* @foo3( +; CHECK: call i8* @returnsArg( +; CHECK-NEXT: call void asm sideeffect + +define i8* @foo3(i8* %a) { + %call = call i8* @returnsArg(i8* %a) + call i8* @llvm.objc.retainAutoreleasedReturnValue(i8* %call) + ret i8* %call +} + +; CHECK-LABEL: define i8* @foo4( +; CHECK: call i8* @returnsArg( +; CHECK-NEXT: call void asm sideeffect + +define i8* @foo4(i8* %a) { + %call = call i8* @returnsArg(i8* %a) + call i8* @llvm.objc.retainAutoreleasedReturnValue(i8* %a) + ret i8* %call +} declare i32* @qux() declare i8* @llvm.objc.retainAutoreleasedReturnValue(i8*) declare i8* @llvm.objc.unsafeClaimAutoreleasedReturnValue(i8*) declare void @bar(i8*) +declare i8* @returnsArg(i8* returned) !llvm.module.flags = !{!0} ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [clang-tools-extra] 2fced5a - [clangd] Don't cancel requests based on "updates" with same content
Author: Sam McCall Date: 2020-12-19T02:03:40+01:00 New Revision: 2fced5a07b45ef527ac00a13e63bfca61e407ee3 URL: https://github.com/llvm/llvm-project/commit/2fced5a07b45ef527ac00a13e63bfca61e407ee3 DIFF: https://github.com/llvm/llvm-project/commit/2fced5a07b45ef527ac00a13e63bfca61e407ee3.diff LOG: [clangd] Don't cancel requests based on "updates" with same content There's an unfortunate collision between two features: - we implicitly cancel certain requests when the file changes, to avoid the queue getting clogged building old revisions to service stale requests - we "reparse-if-needed" by synthesizing a file change, e.g. on didSave We could explicitly mark these synthetic requests to avoid this, but looking for changes in file content clutters our APIs less and is arguably the correct thing to do in any case. Fixes https://github.com/clangd/clangd/issues/620 Added: Modified: clang-tools-extra/clangd/TUScheduler.cpp clang-tools-extra/clangd/unittests/TUSchedulerTests.cpp Removed: diff --git a/clang-tools-extra/clangd/TUScheduler.cpp b/clang-tools-extra/clangd/TUScheduler.cpp index 443abcfe847a..813a000b41a5 100644 --- a/clang-tools-extra/clangd/TUScheduler.cpp +++ b/clang-tools-extra/clangd/TUScheduler.cpp @@ -385,7 +385,7 @@ class ASTWorker { ParsingCallbacks &Callbacks); ~ASTWorker(); - void update(ParseInputs Inputs, WantDiagnostics); + void update(ParseInputs Inputs, WantDiagnostics, bool ContentChanged); void runWithAST(llvm::StringRef Name, llvm::unique_function)> Action, @@ -419,6 +419,18 @@ class ASTWorker { bool isASTCached() const; private: + // Details of an update request that are relevant to scheduling. + struct UpdateType { +// Do we want diagnostics from this version? +// If Yes, we must always build this version. +// If No, we only need to build this version if it's read. +// If Auto, we build if it's read or if the debounce expires. +WantDiagnostics Diagnostics; +// Did the main-file content of the document change? +// If so, we're allowed to cancel certain invalidated preceding reads. +bool ContentChanged; + }; + /// Publishes diagnostics for \p Inputs. It will build an AST or reuse the /// cached one if applicable. Assumes LatestPreamble is compatible for \p /// Inputs. @@ -431,9 +443,10 @@ class ASTWorker { void run(); /// Signal that run() should finish processing pending requests and exit. void stop(); + /// Adds a new task to the end of the request queue. void startTask(llvm::StringRef Name, llvm::unique_function Task, - llvm::Optional UpdateType, + llvm::Optional Update, TUScheduler::ASTActionInvalidation); /// Determines the next action to perform. @@ -449,7 +462,7 @@ class ASTWorker { std::string Name; steady_clock::time_point AddTime; Context Ctx; -llvm::Optional UpdateType; +llvm::Optional Update; TUScheduler::ASTActionInvalidation InvalidationPolicy; Canceler Invalidate; }; @@ -598,7 +611,8 @@ ASTWorker::~ASTWorker() { #endif } -void ASTWorker::update(ParseInputs Inputs, WantDiagnostics WantDiags) { +void ASTWorker::update(ParseInputs Inputs, WantDiagnostics WantDiags, + bool ContentChanged) { std::string TaskName = llvm::formatv("Update ({0})", Inputs.Version); auto Task = [=]() mutable { // Get the actual command as `Inputs` does not have a command. @@ -679,7 +693,8 @@ void ASTWorker::update(ParseInputs Inputs, WantDiagnostics WantDiags) { }); return; }; - startTask(TaskName, std::move(Task), WantDiags, TUScheduler::NoInvalidation); + startTask(TaskName, std::move(Task), UpdateType{WantDiags, ContentChanged}, +TUScheduler::NoInvalidation); } void ASTWorker::runWithAST( @@ -723,7 +738,7 @@ void ASTWorker::runWithAST( FileInputs.Version); Action(InputsAndAST{FileInputs, **AST}); }; - startTask(Name, std::move(Task), /*UpdateType=*/None, Invalidation); + startTask(Name, std::move(Task), /*Update=*/None, Invalidation); } void PreambleThread::build(Request Req) { @@ -960,7 +975,7 @@ void ASTWorker::stop() { void ASTWorker::startTask(llvm::StringRef Name, llvm::unique_function Task, - llvm::Optional UpdateType, + llvm::Optional Update, TUScheduler::ASTActionInvalidation Invalidation) { if (RunSync) { assert(!Done && "running a task after stop()"); @@ -974,11 +989,11 @@ void ASTWorker::startTask(llvm::StringRef Name, std::lock_guard Lock(Mutex); assert(!Done && "running a task after stop()"); // Cancel any requests invalidated by this request. -if (UpdateType) { +if (Update && Update->ContentChanged) { for (auto &R : ll
[llvm-branch-commits] [llvm] 1ab4db0 - [HotColdSplit] Reflect full cost of parameters in split penalty
Author: Aditya Kumar Date: 2020-12-18T17:06:17-08:00 New Revision: 1ab4db0f847fa1ddd394dbf54a5051b626eab160 URL: https://github.com/llvm/llvm-project/commit/1ab4db0f847fa1ddd394dbf54a5051b626eab160 DIFF: https://github.com/llvm/llvm-project/commit/1ab4db0f847fa1ddd394dbf54a5051b626eab160.diff LOG: [HotColdSplit] Reflect full cost of parameters in split penalty Make the penalty for splitting a region more accurately reflect the cost of materializing all of the inputs/outputs to/from the region. This almost entirely eliminates code growth within functions which undergo splitting in key internal frameworks, and reduces the size of those frameworks between 2.6% to 3%. rdar://49167240 Patch by: Vedant Kumar(@vsk) Reviewers: hiraditya,rjf,t.p.northover Reviewed By: hiraditya,rjf Differential Revision: https://reviews.llvm.org/D59715 Added: Modified: llvm/lib/Transforms/IPO/HotColdSplitting.cpp llvm/test/Transforms/CodeExtractor/extract-assume.ll llvm/test/Transforms/HotColdSplit/apply-penalty-for-inputs.ll llvm/test/Transforms/HotColdSplit/apply-penalty-for-outputs.ll llvm/test/Transforms/HotColdSplit/apply-successor-penalty.ll llvm/test/Transforms/HotColdSplit/assumption-cache-invalidation.ll Removed: diff --git a/llvm/lib/Transforms/IPO/HotColdSplitting.cpp b/llvm/lib/Transforms/IPO/HotColdSplitting.cpp index b25b789d1dae..aa708ee520b1 100644 --- a/llvm/lib/Transforms/IPO/HotColdSplitting.cpp +++ b/llvm/lib/Transforms/IPO/HotColdSplitting.cpp @@ -67,6 +67,7 @@ #include "llvm/Transforms/Utils/Local.h" #include "llvm/Transforms/Utils/ValueMapper.h" #include +#include #include #include @@ -96,6 +97,10 @@ static cl::opt cl::desc("Name for the section containing cold functions " "extracted by hot-cold splitting.")); +static cl::opt MaxParametersForSplit( +"hotcoldsplit-max-params", cl::init(4), cl::Hidden, +cl::desc("Maximum number of parameters for a split function")); + namespace { // Same as blockEndsInUnreachable in CodeGen/BranchFolding.cpp. Do not modify // this function unless you modify the MBB version as well. @@ -257,18 +262,6 @@ static int getOutliningPenalty(ArrayRef Region, if (SplittingThreshold <= 0) return Penalty; - // The typical code size cost for materializing an argument for the outlined - // call. - LLVM_DEBUG(dbgs() << "Applying penalty for: " << NumInputs << " inputs\n"); - const int CostForArgMaterialization = TargetTransformInfo::TCC_Basic; - Penalty += CostForArgMaterialization * NumInputs; - - // The typical code size cost for an output alloca, its associated store, and - // its associated reload. - LLVM_DEBUG(dbgs() << "Applying penalty for: " << NumOutputs << " outputs\n"); - const int CostForRegionOutput = 3 * TargetTransformInfo::TCC_Basic; - Penalty += CostForRegionOutput * NumOutputs; - // Find the number of distinct exit blocks for the region. Use a conservative // check to determine whether control returns from the region. bool NoBlocksReturn = true; @@ -289,6 +282,48 @@ static int getOutliningPenalty(ArrayRef Region, } } + // Count the number of phis in exit blocks with >= 2 incoming values from the + // outlining region. These phis are split (\ref severSplitPHINodesOfExits), + // and new outputs are created to supply the split phis. CodeExtractor can't + // report these new outputs until extraction begins, but it's important to + // factor the cost of the outputs into the cost calculation. + unsigned NumSplitExitPhis = 0; + for (BasicBlock *ExitBB : SuccsOutsideRegion) { +for (PHINode &PN : ExitBB->phis()) { + // Find all incoming values from the outlining region. + int NumIncomingVals = 0; + for (unsigned i = 0; i < PN.getNumIncomingValues(); ++i) +if (find(Region, PN.getIncomingBlock(i)) != Region.end()) { + ++NumIncomingVals; + if (NumIncomingVals > 1) { +++NumSplitExitPhis; +break; + } +} +} + } + + // Apply a penalty for calling the split function. Factor in the cost of + // materializing all of the parameters. + int NumOutputsAndSplitPhis = NumOutputs + NumSplitExitPhis; + int NumParams = NumInputs + NumOutputsAndSplitPhis; + if (NumParams > MaxParametersForSplit) { +LLVM_DEBUG(dbgs() << NumInputs << " inputs and " << NumOutputsAndSplitPhis + << " outputs exceeds parameter limit (" + << MaxParametersForSplit << ")\n"); +return std::numeric_limits::max(); + } + const int CostForArgMaterialization = 2 * TargetTransformInfo::TCC_Basic; + LLVM_DEBUG(dbgs() << "Applying penalty for: " << NumParams << " params\n"); + Penalty += CostForArgMaterialization * NumParams; + + // Apply the typical code size cost for an output alloca and its associated + // reload in the caller. Also
[llvm-branch-commits] [clang-tools-extra] 2b62e62 - [clangd] Fix windows path handling in .clang-tidy parsing
Author: Sam McCall Date: 2020-12-19T02:24:25+01:00 New Revision: 2b62e62328841b7d2dc01e390e13fb9151d06263 URL: https://github.com/llvm/llvm-project/commit/2b62e62328841b7d2dc01e390e13fb9151d06263 DIFF: https://github.com/llvm/llvm-project/commit/2b62e62328841b7d2dc01e390e13fb9151d06263.diff LOG: [clangd] Fix windows path handling in .clang-tidy parsing Added: Modified: clang-tools-extra/clangd/TidyProvider.cpp Removed: diff --git a/clang-tools-extra/clangd/TidyProvider.cpp b/clang-tools-extra/clangd/TidyProvider.cpp index c12dab7e2e5e..0a9f12221287 100644 --- a/clang-tools-extra/clangd/TidyProvider.cpp +++ b/clang-tools-extra/clangd/TidyProvider.cpp @@ -106,12 +106,17 @@ class DotClangTidyTree { llvm::SmallVector Caches; { std::lock_guard Lock(Mu); - for (auto I = path::begin(Parent, path::Style::posix), -E = path::end(Parent); - I != E; ++I) { + for (auto I = path::begin(Parent), E = path::end(Parent); I != E; ++I) { assert(I->end() >= Parent.begin() && I->end() <= Parent.end() && "Canonical path components should be substrings"); llvm::StringRef Ancestor(Parent.begin(), I->end() - Parent.begin()); +#ifdef _WIN32 +// C:\ is an ancestor, but skip its (relative!) parent C:. +if (Ancestor.size() == 2 && Ancestor.back() == ':') + continue; +#endif +assert(path::is_absolute(Ancestor)); + auto It = Cache.find(Ancestor); // Assemble the actual config file path only if needed. ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [llvm] 44f399c - [FileCheck] Add a literal check directive modifier
Author: Jacques Pienaar Date: 2020-12-18T17:26:15-08:00 New Revision: 44f399ccc12e27d20bae1ea7e712ef7f71e2ff3a URL: https://github.com/llvm/llvm-project/commit/44f399ccc12e27d20bae1ea7e712ef7f71e2ff3a DIFF: https://github.com/llvm/llvm-project/commit/44f399ccc12e27d20bae1ea7e712ef7f71e2ff3a.diff LOG: [FileCheck] Add a literal check directive modifier Introduce CHECK modifiers that change the behavior of the CHECK directive. Also add a LITERAL modifier for cases where matching could end requiring escaping strings interpreted as regex where only literal/fixed string matching is desired (making the CHECK's more difficult to write/fragile and difficult to interpret). Added: llvm/test/FileCheck/check-literal.txt Modified: llvm/docs/CommandGuide/FileCheck.rst llvm/include/llvm/FileCheck/FileCheck.h llvm/lib/FileCheck/FileCheck.cpp Removed: diff --git a/llvm/docs/CommandGuide/FileCheck.rst b/llvm/docs/CommandGuide/FileCheck.rst index bf8147abf0a3..398cce1f8a8c 100644 --- a/llvm/docs/CommandGuide/FileCheck.rst +++ b/llvm/docs/CommandGuide/FileCheck.rst @@ -660,6 +660,30 @@ simply uniquely match a single line in the file being verified. ``CHECK-LABEL:`` directives cannot contain variable definitions or uses. +Directive modifiers +~~~ + +A directive modifier can be append to a directive by following the directive +with ``{}`` where the only supported value for is +``LITERAL``. + +The ``LITERAL`` directive modifier can be used to perform a literal match. The +modifier results in the directive not recognizing any syntax to perform regex +matching, variable capture or any substitutions. This is useful when the text +to match would require excessive escaping otherwise. For example, the +following will perform literal matches rather than considering these as +regular expressions: + +.. code-block:: text + + Input: [[[10, 20]], [[30, 40]]] + Output %r10: [[10, 20]] + Output %r10: [[30, 40]] + + ; CHECK{LITERAL}: [[[10, 20]], [[30, 40]]] + ; CHECK-DAG{LITERAL}: [[30, 40]] + ; CHECK-DAG{LITERAL}: [[10, 20]] + FileCheck Regex Matching Syntax ~~~ diff --git a/llvm/include/llvm/FileCheck/FileCheck.h b/llvm/include/llvm/FileCheck/FileCheck.h index b10db710ef38..b44ab025694b 100644 --- a/llvm/include/llvm/FileCheck/FileCheck.h +++ b/llvm/include/llvm/FileCheck/FileCheck.h @@ -17,6 +17,7 @@ #include "llvm/Support/MemoryBuffer.h" #include "llvm/Support/Regex.h" #include "llvm/Support/SourceMgr.h" +#include #include #include @@ -64,12 +65,23 @@ enum FileCheckKind { CheckBadCount }; +enum FileCheckKindModifier { + /// Modifies directive to perform literal match. + ModifierLiteral = 0, + + // The number of modifier. + Size +}; + class FileCheckType { FileCheckKind Kind; int Count; ///< optional Count for some checks + /// Modifers for the check directive. + std::bitset Modifiers; public: - FileCheckType(FileCheckKind Kind = CheckNone) : Kind(Kind), Count(1) {} + FileCheckType(FileCheckKind Kind = CheckNone) + : Kind(Kind), Count(1), Modifiers() {} FileCheckType(const FileCheckType &) = default; FileCheckType &operator=(const FileCheckType &) = default; @@ -78,8 +90,19 @@ class FileCheckType { int getCount() const { return Count; } FileCheckType &setCount(int C); + bool isLiteralMatch() const { +return Modifiers[FileCheckKindModifier::ModifierLiteral]; + } + FileCheckType &setLiteralMatch(bool Literal = true) { +Modifiers.set(FileCheckKindModifier::ModifierLiteral, Literal); +return *this; + } + // \returns a description of \p Prefix. std::string getDescription(StringRef Prefix) const; + + // \returns a description of \p Modifiers. + std::string getModifiersDescription() const; }; } // namespace Check diff --git a/llvm/lib/FileCheck/FileCheck.cpp b/llvm/lib/FileCheck/FileCheck.cpp index d6fda5b36e69..c6a5b69e2055 100644 --- a/llvm/lib/FileCheck/FileCheck.cpp +++ b/llvm/lib/FileCheck/FileCheck.cpp @@ -917,6 +917,12 @@ bool Pattern::parsePattern(StringRef PatternStr, StringRef Prefix, return false; } + // If literal check, set fixed string. + if (CheckTy.isLiteralMatch()) { +FixedStr = PatternStr; +return false; + } + // Check to see if this is a fixed string, or if it has regex pieces. if (!MatchFullLinesHere && (PatternStr.size() < 2 || (PatternStr.find("{{") == StringRef::npos && @@ -1588,26 +1594,43 @@ Check::FileCheckType &Check::FileCheckType::setCount(int C) { return *this; } +std::string Check::FileCheckType::getModifiersDescription() const { + if (Modifiers.none()) +return ""; + std::string Ret; + raw_string_ostream OS(Ret); + OS << '{'; + if (isLiteralMatch()) +OS << "LITERAL"; + OS << '}'; + return OS.str(); +} + std::string Check::FileCheckType::getDescription(StringRef Prefix) const { + // App
[llvm-branch-commits] [flang] bf0870d - [flang] Fix bug in IMPLICIT NONE(EXTERNAL)
Author: Tim Keith Date: 2020-12-18T17:43:53-08:00 New Revision: bf0870d8640df27b6bb082de0347008240cb0e67 URL: https://github.com/llvm/llvm-project/commit/bf0870d8640df27b6bb082de0347008240cb0e67 DIFF: https://github.com/llvm/llvm-project/commit/bf0870d8640df27b6bb082de0347008240cb0e67.diff LOG: [flang] Fix bug in IMPLICIT NONE(EXTERNAL) We were only checking the restrictions of IMPLICIT NONE(EXTERNAL) when a procedure name is first encountered. But it can also happen with an existing symbol, e.g. if an external function's return type is declared before is it called. This change adds a check in that branch too. Differential Revision: https://reviews.llvm.org/D93552 Added: Modified: flang/lib/Semantics/resolve-names.cpp flang/test/Semantics/implicit07.f90 Removed: diff --git a/flang/lib/Semantics/resolve-names.cpp b/flang/lib/Semantics/resolve-names.cpp index 495d7d0f8584..8d5284131cc0 100644 --- a/flang/lib/Semantics/resolve-names.cpp +++ b/flang/lib/Semantics/resolve-names.cpp @@ -1364,6 +1364,7 @@ class ResolveNamesVisitor : public virtual ScopeHandler, void CheckImport(const SourceName &, const SourceName &); void HandleCall(Symbol::Flag, const parser::Call &); void HandleProcedureName(Symbol::Flag, const parser::Name &); + bool CheckImplicitNoneExternal(const SourceName &, const Symbol &); bool SetProcFlag(const parser::Name &, Symbol &, Symbol::Flag); void ResolveSpecificationParts(ProgramTree &); void AddSubpNames(ProgramTree &); @@ -5853,10 +5854,7 @@ void ResolveNamesVisitor::HandleProcedureName( return; } if (!symbol->attrs().test(Attr::INTRINSIC)) { - if (isImplicitNoneExternal() && !symbol->attrs().test(Attr::EXTERNAL)) { -Say(name, -"'%s' is an external procedure without the EXTERNAL" -" attribute in a scope with IMPLICIT NONE(EXTERNAL)"_err_en_US); + if (!CheckImplicitNoneExternal(name.source, *symbol)) { return; } MakeExternal(*symbol); @@ -5877,6 +5875,7 @@ void ResolveNamesVisitor::HandleProcedureName( if (!SetProcFlag(name, *symbol, flag)) { return; // reported error } +CheckImplicitNoneExternal(name.source, *symbol); if (IsProcedure(*symbol) || symbol->has() || symbol->has() || symbol->has()) { @@ -5895,6 +5894,18 @@ void ResolveNamesVisitor::HandleProcedureName( } } +bool ResolveNamesVisitor::CheckImplicitNoneExternal( +const SourceName &name, const Symbol &symbol) { + if (isImplicitNoneExternal() && !symbol.attrs().test(Attr::EXTERNAL) && + !symbol.attrs().test(Attr::INTRINSIC) && !symbol.HasExplicitInterface()) { +Say(name, +"'%s' is an external procedure without the EXTERNAL" +" attribute in a scope with IMPLICIT NONE(EXTERNAL)"_err_en_US); +return false; + } + return true; +} + // Variant of HandleProcedureName() for use while skimming the executable // part of a subprogram to catch calls to dummy procedures that are part // of the subprogram's interface, and to mark as procedures any symbols diff --git a/flang/test/Semantics/implicit07.f90 b/flang/test/Semantics/implicit07.f90 index df015f7bcc62..5362f91dcb02 100644 --- a/flang/test/Semantics/implicit07.f90 +++ b/flang/test/Semantics/implicit07.f90 @@ -1,9 +1,12 @@ ! RUN: %S/test_errors.sh %s %t %f18 implicit none(external) external x +integer :: f, i call x !ERROR: 'y' is an external procedure without the EXTERNAL attribute in a scope with IMPLICIT NONE(EXTERNAL) call y +!ERROR: 'f' is an external procedure without the EXTERNAL attribute in a scope with IMPLICIT NONE(EXTERNAL) +i = f() block !ERROR: 'z' is an external procedure without the EXTERNAL attribute in a scope with IMPLICIT NONE(EXTERNAL) call z ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [lldb] a913a58 - [lldb] Simplify the is_finalized logic in process and make it thread safe.
Author: Jonas Devlieghere Date: 2020-12-18T18:41:33-08:00 New Revision: a913a583f00a31c37a1572089fe8898a6c19536c URL: https://github.com/llvm/llvm-project/commit/a913a583f00a31c37a1572089fe8898a6c19536c DIFF: https://github.com/llvm/llvm-project/commit/a913a583f00a31c37a1572089fe8898a6c19536c.diff LOG: [lldb] Simplify the is_finalized logic in process and make it thread safe. This is a speculative fix when looking at the finalization code in Process. It tackles the following issues: - Adds synchronization to prevent races between threads. - Marks the process as finalized/invalid as soon as Finalize is called rather than at the end. - Simplifies the code by using only a single instance variable to track finalization. Differential revision: https://reviews.llvm.org/D93479 Added: Modified: lldb/include/lldb/Target/Process.h lldb/source/Target/Process.cpp Removed: diff --git a/lldb/include/lldb/Target/Process.h b/lldb/include/lldb/Target/Process.h index 744deab276c4..e8dd8847e87a 100644 --- a/lldb/include/lldb/Target/Process.h +++ b/lldb/include/lldb/Target/Process.h @@ -594,7 +594,7 @@ class Process : public std::enable_shared_from_this, /// \return /// Returns \b true if this Process has not been finalized /// and \b false otherwise. - bool IsValid() const { return !m_finalize_called; } + bool IsValid() const { return !m_finalizing; } /// Return a multi-word command object that can be used to expose plug-in /// specific commands. @@ -2831,10 +2831,11 @@ void PruneThreadPlans(); // m_currently_handling_do_on_removals are true, // Resume will only request a resume, using this // flag to check. - bool m_finalizing; // This is set at the beginning of Process::Finalize() to - // stop functions from looking up or creating things - // during a finalize call - bool m_finalize_called; // This is set at the end of Process::Finalize() + + /// This is set at the beginning of Process::Finalize() to stop functions + /// from looking up or creating things during or after a finalize call. + std::atomic m_finalizing; + bool m_clear_thread_plans_on_stop; bool m_force_next_event_delivery; lldb::StateType m_last_broadcast_state; /// This helps with the Public event @@ -2938,6 +2939,8 @@ void PruneThreadPlans(); void LoadOperatingSystemPlugin(bool flush); private: + Status DestroyImpl(bool force_kill); + /// This is the part of the event handling that for a process event. It /// decides what to do with the event and returns true if the event needs to /// be propagated to the user, and false otherwise. If the event is not diff --git a/lldb/source/Target/Process.cpp b/lldb/source/Target/Process.cpp index 14f8326cfcec..a4eab1aa0b41 100644 --- a/lldb/source/Target/Process.cpp +++ b/lldb/source/Target/Process.cpp @@ -556,7 +556,7 @@ Process::Process(lldb::TargetSP target_sp, ListenerSP listener_sp, m_profile_data_comm_mutex(), m_profile_data(), m_iohandler_sync(0), m_memory_cache(*this), m_allocated_memory_cache(*this), m_should_detach(false), m_next_event_action_up(), m_public_run_lock(), - m_private_run_lock(), m_finalizing(false), m_finalize_called(false), + m_private_run_lock(), m_finalizing(false), m_clear_thread_plans_on_stop(false), m_force_next_event_delivery(false), m_last_broadcast_state(eStateInvalid), m_destroy_in_process(false), m_can_interpret_function_calls(false), m_warnings_issued(), @@ -632,7 +632,8 @@ const ProcessPropertiesSP &Process::GetGlobalProperties() { } void Process::Finalize() { - m_finalizing = true; + if (m_finalizing.exchange(true)) +return; // Destroy this process if needed switch (GetPrivateState()) { @@ -644,7 +645,7 @@ void Process::Finalize() { case eStateStepping: case eStateCrashed: case eStateSuspended: -Destroy(false); +DestroyImpl(false); break; case eStateInvalid: @@ -707,7 +708,6 @@ void Process::Finalize() { m_private_run_lock.TrySetRunning(); // This will do nothing if already locked m_private_run_lock.SetStopped(); m_structured_data_plugin_map.clear(); - m_finalize_called = true; } void Process::RegisterNotificationCallbacks(const Notifications &callbacks) { @@ -1516,7 +1516,7 @@ bool Process::StateChangedIsHijackedForSynchronousResume() { StateType Process::GetPrivateState() { return m_private_state.GetValue(); } void Process::SetPrivateState(StateType new_state) { - if (m_finalize_called) + if (m_finalizing) return; Log *log(lldb_private::GetLogIfAnyCategoriesSet(LIBLLDB_LOG_STATE | @@ -1566,11 +1566,7 @@ void Process::SetPrivateState(StateType new_state) { StateAsCString(new_state), m_mod_id.GetStopID()); } -// Use our target
[llvm-branch-commits] [llvm] 805d595 - [Analysis, CodeGen, IR] Use contains (NFC)
Author: Kazu Hirata Date: 2020-12-18T19:08:17-08:00 New Revision: 805d59593f50a5c5050c0fc5cb9fbe02cd751511 URL: https://github.com/llvm/llvm-project/commit/805d59593f50a5c5050c0fc5cb9fbe02cd751511 DIFF: https://github.com/llvm/llvm-project/commit/805d59593f50a5c5050c0fc5cb9fbe02cd751511.diff LOG: [Analysis, CodeGen, IR] Use contains (NFC) Added: Modified: llvm/lib/Analysis/BranchProbabilityInfo.cpp llvm/lib/Analysis/DivergenceAnalysis.cpp llvm/lib/Analysis/IRSimilarityIdentifier.cpp llvm/lib/CodeGen/LiveDebugValues/InstrRefBasedImpl.cpp llvm/lib/IR/ModuleSummaryIndex.cpp Removed: diff --git a/llvm/lib/Analysis/BranchProbabilityInfo.cpp b/llvm/lib/Analysis/BranchProbabilityInfo.cpp index ac5dbe1ce6e9..d4cb46c82e3a 100644 --- a/llvm/lib/Analysis/BranchProbabilityInfo.cpp +++ b/llvm/lib/Analysis/BranchProbabilityInfo.cpp @@ -795,8 +795,7 @@ bool BranchProbabilityInfo::calcLoopBranchHeuristics(const BasicBlock *BB, for (const_succ_iterator I = succ_begin(BB), E = succ_end(BB); I != E; ++I) { LoopBlock SuccLB(*I, LI, *SccI.get()); LoopEdge Edge(LB, SuccLB); -bool IsUnlikelyEdge = -LB.getLoop() && (UnlikelyBlocks.find(*I) != UnlikelyBlocks.end()); +bool IsUnlikelyEdge = LB.getLoop() && UnlikelyBlocks.contains(*I); if (IsUnlikelyEdge) UnlikelyEdges.push_back(I.getSuccessorIndex()); diff --git a/llvm/lib/Analysis/DivergenceAnalysis.cpp b/llvm/lib/Analysis/DivergenceAnalysis.cpp index c10971dab95c..7bd25de43ffb 100644 --- a/llvm/lib/Analysis/DivergenceAnalysis.cpp +++ b/llvm/lib/Analysis/DivergenceAnalysis.cpp @@ -118,7 +118,7 @@ bool DivergenceAnalysis::isTemporalDivergent(const BasicBlock &ObservingBlock, for (const auto *Loop = LI.getLoopFor(Inst->getParent()); Loop != RegionLoop && !Loop->contains(&ObservingBlock); Loop = Loop->getParentLoop()) { -if (DivergentLoops.find(Loop) != DivergentLoops.end()) +if (DivergentLoops.contains(Loop)) return true; } @@ -332,11 +332,11 @@ void DivergenceAnalysis::compute() { } bool DivergenceAnalysis::isAlwaysUniform(const Value &V) const { - return UniformOverrides.find(&V) != UniformOverrides.end(); + return UniformOverrides.contains(&V); } bool DivergenceAnalysis::isDivergent(const Value &V) const { - return DivergentValues.find(&V) != DivergentValues.end(); + return DivergentValues.contains(&V); } bool DivergenceAnalysis::isDivergentUse(const Use &U) const { diff --git a/llvm/lib/Analysis/IRSimilarityIdentifier.cpp b/llvm/lib/Analysis/IRSimilarityIdentifier.cpp index dc8385ff87e6..41e234651349 100644 --- a/llvm/lib/Analysis/IRSimilarityIdentifier.cpp +++ b/llvm/lib/Analysis/IRSimilarityIdentifier.cpp @@ -286,14 +286,14 @@ bool checkNumberingAndReplace( // instruction. DenseSet &TargetSet = Val->second; - if (TargetSet.size() > 1 && TargetSet.find(TargetArgVal) != TargetSet.end()) { + if (TargetSet.size() > 1 && TargetSet.contains(TargetArgVal)) { TargetSet.clear(); TargetSet.insert(TargetArgVal); return true; } // Return true if we can find the value in the set. - return TargetSet.find(TargetArgVal) != TargetSet.end(); + return TargetSet.contains(TargetArgVal); } bool IRSimilarityCandidate::compareOperandMapping(OperandMapping A, @@ -375,14 +375,12 @@ bool IRSimilarityCandidate::compareStructure(const IRSimilarityCandidate &A, // Ensure that the mappings for the instructions exists. std::tie(ValueMappingIt, WasInserted) = ValueNumberMappingA.insert( std::make_pair(InstValA, DenseSet({InstValB}))); -if (!WasInserted && ValueMappingIt->second.find(InstValB) == -ValueMappingIt->second.end()) +if (!WasInserted && !ValueMappingIt->second.contains(InstValB)) return false; std::tie(ValueMappingIt, WasInserted) = ValueNumberMappingB.insert( std::make_pair(InstValB, DenseSet({InstValA}))); -if (!WasInserted && ValueMappingIt->second.find(InstValA) == -ValueMappingIt->second.end()) +if (!WasInserted && !ValueMappingIt->second.contains(InstValA)) return false; // TODO: Handle commutative instructions by mapping one operand to many diff --git a/llvm/lib/CodeGen/LiveDebugValues/InstrRefBasedImpl.cpp b/llvm/lib/CodeGen/LiveDebugValues/InstrRefBasedImpl.cpp index e7256a98eb87..04ead18cc3de 100644 --- a/llvm/lib/CodeGen/LiveDebugValues/InstrRefBasedImpl.cpp +++ b/llvm/lib/CodeGen/LiveDebugValues/InstrRefBasedImpl.cpp @@ -2679,7 +2679,7 @@ std::tuple InstrRefBasedLDV::vlocJoin( for (auto p : BlockOrders) { // If the predecessor isn't in scope / to be explored, we'll never be // able to join any locations. - if (BlocksToExplore.find(p) == BlocksToExplore.end()) { + if (!BlocksToExplore.contains(p)) { Bail = true; break; } diff --git a/llvm