platform/upstream/llvm.git
2 years ago[flang][NFC] Deallocation of polymorphoc entities are done with the runtime call
Valentin Clement [Mon, 31 Oct 2022 13:51:44 +0000 (14:51 +0100)]
[flang][NFC] Deallocation of polymorphoc entities are done with the runtime call

The runtime function `AllocatableDeallocate/PointerDeallocate` is reponsible to
deallocate and finalize it. This patch just adds tests to make sure the correct
runtime function is called.

Reviewed By: PeteSteinfeld

Differential Revision: https://reviews.llvm.org/D137068

2 years ago[clangd] Run semantic highligting in clangd check.
Haojian Wu [Mon, 31 Oct 2022 09:04:27 +0000 (10:04 +0100)]
[clangd] Run semantic highligting in clangd check.

Allowing us to test this feature (context: a recent crash in
semantic highlighting.)

Differential Revision: https://reviews.llvm.org/D137063

2 years ago[AArch64][SVE2] Add the SVE2.1 shift-and-narrow instructions
David Sherwood [Wed, 19 Oct 2022 15:21:08 +0000 (15:21 +0000)]
[AArch64][SVE2] Add the SVE2.1 shift-and-narrow instructions

This patch adds the assembly/disassembly for the following instructions:

sqrshrn  : Signed saturating rounding shift right narrow by immediate and interleave
sqrshrun : Signed saturating rounding shift right unsigned narrow by immediate and interleave
uqrshrn  : Unsigned saturating rounding shift right narrow by immediate and interleave

The reference can be found here:
https://developer.arm.com/documentation/ddi0602/2022-09

Differential Revision: https://reviews.llvm.org/D136690

2 years agoNFC: restructure code for CreateControlFlowHub()
Brendon Cahoon [Sun, 9 Oct 2022 22:07:20 +0000 (17:07 -0500)]
NFC: restructure code for CreateControlFlowHub()

Differential review: https://reviews.llvm.org/D127830

2 years ago[NFC] Use isa<...> to replace isa<>||isa<> in clang/Serialization
Chuanqi Xu [Mon, 31 Oct 2022 13:15:04 +0000 (21:15 +0800)]
[NFC] Use isa<...> to replace isa<>||isa<>  in clang/Serialization

Now isa supports the variant args, which could simplify the codes
further. This patch simplify the uses in clang/Serialization

2 years ago[InstCombine] fold mul with decremented "shl -1" factor
Sanjay Patel [Mon, 31 Oct 2022 12:54:18 +0000 (08:54 -0400)]
[InstCombine] fold mul with decremented "shl -1" factor

This is a sibling to:
6064e92b0a84
...but we canonicalize the shl+add to shl+xor,
so the pattern is different than I expected:
https://alive2.llvm.org/ce/z/8CX16e

I have not found any patterns that are safe
to propagate no-wrap, so that is not included
here.

2 years ago[InstCombine] add tests for mul with shl; NFC
Sanjay Patel [Mon, 31 Oct 2022 12:41:25 +0000 (08:41 -0400)]
[InstCombine] add tests for mul with shl; NFC

2 years ago[AArch64] Include SME2 in +all
David Green [Mon, 31 Oct 2022 13:04:32 +0000 (13:04 +0000)]
[AArch64] Include SME2 in +all

The sme2 predicate was as AssemblerPredicate, not
AssemblerPredicateWithAll like all the other features, meaning it wasn't
included in +all. This fixes that inconsistency, allowing the
instructions to be decoded by default.

Differential Revision: https://reviews.llvm.org/D137016

2 years ago[X86] combineConcatVectorOps - fold concat(GF2P8AFFINEQB(x,y,c),GF2P8AFFINEQB(z,w...
Simon Pilgrim [Mon, 31 Oct 2022 12:27:47 +0000 (12:27 +0000)]
[X86] combineConcatVectorOps - fold concat(GF2P8AFFINEQB(x,y,c),GF2P8AFFINEQB(z,w,c)) -> GF2P8AFFINEQB(concat(x,z),concat(y,w),c)

Pulled out of D137026

2 years ago[lldb][CPlusPlus] Implement CPlusPlusLanguage::GetFunctionDisplayName
Michael Buch [Thu, 27 Oct 2022 10:10:28 +0000 (11:10 +0100)]
[lldb][CPlusPlus] Implement CPlusPlusLanguage::GetFunctionDisplayName

This patch implements the `GetFunctionDisplayName` API which gets
used by the frame-formatting code to decide how to print a
function name.

Currently this API trivially returns `false`, so we try to parse
the demangled function base-name by hand. We try find the closing
parenthesis by doing a forward scan through the demangled name. However,
for arguments that contain parenthesis (e.g., function pointers)
this would leave garbage in the frame function name.

By re-using the `CPlusPlusLanguage` parser for this we offload the
need to parse function names to a component that knows how to do this
already.

We leave the existing parsing code in `FormatEntity` since it's used
in cases where a language-plugin is not available (and is not
necessarily C++ specific).

**Example**

For following function:
```
int foo(std::function<int(void)> const& func) { return 1; }
```

Before patch:
```
frame #0: 0x000000010000151c a.out`foo(func= Function = bar() )> const&) at sample.cpp:11:49
```

After patch:
```
frame #0: 0x000000010000151c a.out`foo(func= Function = bar() ) at sample.cpp:11:49
```

**Testing**

* Added shell test

2 years ago[lldb][CPlusPlus] Introduce CPlusPlusLanguage::MethodName::GetReturnType
Michael Buch [Thu, 27 Oct 2022 10:09:22 +0000 (11:09 +0100)]
[lldb][CPlusPlus] Introduce CPlusPlusLanguage::MethodName::GetReturnType

This patch adds a way to extract the return type out
of the `CPlusPlusNameParser`. This will be useful
for cases where we want a function's basename *and* the
return type but not the function arguments; this is
currently not possible (the parser either gives us the
full name or just the basename). Since the parser knows
how to handle return types already we should just expose
this to users that need it.

**Testing**

* Added unit-tests

Differential Revision: https://reviews.llvm.org/D136935

2 years ago[lldb][FormatEntity][NFC] Move function argument parsing code into separate functions
Michael Buch [Wed, 26 Oct 2022 16:13:00 +0000 (17:13 +0100)]
[lldb][FormatEntity][NFC] Move function argument parsing code into separate functions

Hopefully makes the code more readable and allows
us to re-use argument pretty-printing code from
the `CPlusPlusLanguage` plugin in a follow-up commit.

Differential Revision: https://reviews.llvm.org/D136934

2 years agoAdd explicit cast to fix MSVC error: "'return': cannot convert from 'int (__cdecl...
Simon Pilgrim [Mon, 31 Oct 2022 12:01:06 +0000 (12:01 +0000)]
Add explicit cast to fix MSVC error: "'return': cannot convert from 'int (__cdecl *)(int)' to '`anonymous-namespace'::Plus1FunctionRef::FuncT'"

2 years ago[flang] Add -ffp-contract option processing
Tom Eccles [Mon, 31 Oct 2022 11:30:32 +0000 (11:30 +0000)]
[flang] Add -ffp-contract option processing

Only add the option processing and store the result. No attributes are
added to FIR yet.

Only the "off" and "fast" options are supported. "fast-honor-pragmas" is not applicable because we do not implement `#pragma clang fp contract()` in Fortran [1]. "on" is not supported because it is unclear how to fuse only within individual statements. gfortran also does not implement "on": treating it as an "off".

Currently the default value is "off" to preserve existing behavior. gfortran uses "fast" by default and that may be the right thing for flang-new after further discussion in the future, but that can be changed separately. gfortran's documentation is available [[ https://gcc.gnu.org/onlinedocs/gcc/Optimize-Options.html | here ]].

[1] https://clang.llvm.org/docs/LanguageExtensions.html#extensions-to-specify-floating-point-flags

Reviewed By: vzakhari, awarzynski

Differential Revision: https://reviews.llvm.org/D136080

2 years ago[AArch64][SME] Make all SME intrinsics use 32bit immediates.
Sander de Smalen [Fri, 28 Oct 2022 13:26:39 +0000 (13:26 +0000)]
[AArch64][SME] Make all SME intrinsics use 32bit immediates.

This aligns with what was done for SVE, which consistently uses 32bit
immediates at the LLVM IR level.

Additionally, this change forces the intrinsic operands to be immediates
using ImmArg<>, which subsequently requires the codegenerator to match
TargetConstants instead of Constants.

Reviewed By: paulwalker-arm

Differential Revision: https://reviews.llvm.org/D136933

2 years ago[clang][Interp] Reorder field destruction to avoid use after dtor
Benjamin Kramer [Mon, 31 Oct 2022 11:20:10 +0000 (12:20 +0100)]
[clang][Interp] Reorder field destruction to avoid use after dtor

Found by msan -fsanitize-memory-use-after-dtor.

==8259==WARNING: MemorySanitizer: use-of-uninitialized-value
    #0 0x55dbec54d2b8 in dtorRecord(clang::interp::Block*, char*, clang::interp::Descriptor*) clang/lib/AST/Interp/Descriptor.cpp:150:22
    #1 0x55dbec54bfcf in dtorArrayDesc(clang::interp::Block*, char*, clang::interp::Descriptor*) clang/lib/AST/Interp/Descriptor.cpp:97:7
    #2 0x55dbec508578 in invokeDtor clang/lib/AST/Interp/InterpBlock.h:79:7
    #3 0x55dbec508578 in clang::interp::Program::~Program() clang/lib/AST/Interp/Program.h:55:19
    #4 0x55dbec50657a in operator() third_party/crosstool/v18/stable/toolchain/bin/../include/c++/v1/__memory/unique_ptr.h:55:5
    #5 0x55dbec50657a in std::__msan::unique_ptr<clang::interp::Program, std::__msan::default_delete<clang::interp::Program>>::~unique_ptr() third_party/crosstool/v18/stable/toolchain/bin/../include/c++/v1/__memory/unique_ptr.h:261:7
    #6 0x55dbec5035a1 in clang::interp::Context::~Context() clang/lib/AST/Interp/Context.cpp:27:22
    #7 0x55dbebec1daa in operator() third_party/crosstool/v18/stable/toolchain/bin/../include/c++/v1/__memory/unique_ptr.h:55:5
    #8 0x55dbebec1daa in std::__msan::unique_ptr<clang::interp::Context, std::__msan::default_delete<clang::interp::Context>>::~unique_ptr() third_party/crosstool/v18/stable/toolchain/bin/../include/c++/v1/__memory/unique_ptr.h:261:7
    #9 0x55dbebe285f9 in clang::ASTContext::~ASTContext() clang/lib/AST/ASTContext.cpp:1038:40
    #10 0x55dbe941ff13 in llvm::RefCountedBase<clang::ASTContext>::Release() const llvm/include/llvm/ADT/IntrusiveRefCntPtr.h:101:7
    #11 0x55dbe94353ef in release llvm/include/llvm/ADT/IntrusiveRefCntPtr.h:159:38
    #12 0x55dbe94353ef in release llvm/include/llvm/ADT/IntrusiveRefCntPtr.h:224:7
    #13 0x55dbe94353ef in ~IntrusiveRefCntPtr llvm/include/llvm/ADT/IntrusiveRefCntPtr.h:191:27
    #14 0x55dbe94353ef in clang::CompilerInstance::setASTContext(clang::ASTContext*) clang/lib/Frontend/CompilerInstance.cpp:178:3
    #15 0x55dbe95ad0ad in clang::FrontendAction::EndSourceFile() clang/lib/Frontend/FrontendAction.cpp:1100:8
    #16 0x55dbe9445fcf in clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) clang/lib/Frontend/CompilerInstance.cpp:1047:11
    #17 0x55dbe6b3afef in clang::ExecuteCompilerInvocation(clang::CompilerInstance*) clang/lib/FrontendTool/ExecuteCompilerInvocation.cpp:266:25
    #18 0x55dbe6b13288 in cc1_main(llvm::ArrayRef<char const*>, char const*, void*) clang/tools/driver/cc1_main.cpp:250:15
    #19 0x55dbe6b0095f in ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&) clang/tools/driver/driver.cpp:319:12
    #20 0x55dbe6aff41c in clang_main(int, char**) clang/tools/driver/driver.cpp:395:12
    #21 0x7f9be07fa632 in __libc_start_main
    #22 0x55dbe6a702e9 in _start

  Member fields were destroyed
    #0 0x55dbe6a7da5d in __sanitizer_dtor_callback_fields compiler-rt/lib/msan/msan_interceptors.cpp:949:5
    #1 0x55dbec5094ac in ~SmallVectorImpl llvm/include/llvm/ADT/SmallVector.h:479:7
    #2 0x55dbec5094ac in ~SmallVectorImpl llvm/include/llvm/ADT/SmallVector.h:612:3
    #3 0x55dbec5094ac in llvm::SmallVector<clang::interp::Record::Base, 8u>::~SmallVector() llvm/include/llvm/ADT/SmallVector.h:1207:3
    #4 0x55dbec508e79 in clang::interp::Record::~Record() clang/lib/AST/Interp/Record.h:24:7
    #5 0x55dbec508612 in clang::interp::Program::~Program() clang/lib/AST/Interp/Program.h:49:26
    #6 0x55dbec50657a in operator() third_party/crosstool/v18/stable/toolchain/bin/../include/c++/v1/__memory/unique_ptr.h:55:5
    #7 0x55dbec50657a in std::__msan::unique_ptr<clang::interp::Program, std::__msan::default_delete<clang::interp::Program>>::~unique_ptr() third_party/crosstool/v18/stable/toolchain/bin/../include/c++/v1/__memory/unique_ptr.h:261:7
    #8 0x55dbec5035a1 in clang::interp::Context::~Context() clang/lib/AST/Interp/Context.cpp:27:22
    #9 0x55dbebec1daa in operator() third_party/crosstool/v18/stable/toolchain/bin/../include/c++/v1/__memory/unique_ptr.h:55:5
    #10 0x55dbebec1daa in std::__msan::unique_ptr<clang::interp::Context, std::__msan::default_delete<clang::interp::Context>>::~unique_ptr() third_party/crosstool/v18/stable/toolchain/bin/../include/c++/v1/__memory/unique_ptr.h:261:7
    #11 0x55dbebe285f9 in clang::ASTContext::~ASTContext() clang/lib/AST/ASTContext.cpp:1038:40
    #12 0x55dbe941ff13 in llvm::RefCountedBase<clang::ASTContext>::Release() const llvm/include/llvm/ADT/IntrusiveRefCntPtr.h:101:7
    #13 0x55dbe94353ef in release llvm/include/llvm/ADT/IntrusiveRefCntPtr.h:159:38
    #14 0x55dbe94353ef in release llvm/include/llvm/ADT/IntrusiveRefCntPtr.h:224:7
    #15 0x55dbe94353ef in ~IntrusiveRefCntPtr llvm/include/llvm/ADT/IntrusiveRefCntPtr.h:191:27
    #16 0x55dbe94353ef in clang::CompilerInstance::setASTContext(clang::ASTContext*) clang/lib/Frontend/CompilerInstance.cpp:178:3
    #17 0x55dbe95ad0ad in clang::FrontendAction::EndSourceFile() clang/lib/Frontend/FrontendAction.cpp:1100:8
    #18 0x55dbe9445fcf in clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) clang/lib/Frontend/CompilerInstance.cpp:1047:11
    #19 0x55dbe6b3afef in clang::ExecuteCompilerInvocation(clang::CompilerInstance*) clang/lib/FrontendTool/ExecuteCompilerInvocation.cpp:266:25
    #20 0x55dbe6b13288 in cc1_main(llvm::ArrayRef<char const*>, char const*, void*) clang/tools/driver/cc1_main.cpp:250:15
    #21 0x55dbe6b0095f in ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&) clang/tools/driver/driver.cpp:319:12
    #22 0x55dbe6aff41c in clang_main(int, char**) clang/tools/driver/driver.cpp:395:12
    #23 0x7f9be07fa632 in __libc_start_main
    #24 0x55dbe6a702e9 in _start

2 years ago[AArch64-SVE]: Force generating code compatible to streaming mode.
Hassnaa Hamdi [Mon, 24 Oct 2022 09:45:00 +0000 (09:45 +0000)]
[AArch64-SVE]: Force generating code compatible to streaming mode.

When streaming mode is enabled, lower some operations and disable some code paths;
to force generateing code compatible to streaming mode.
Add streaming-mode flag for new sve-fixed-length testing files:
build_vector.ll
concat.ll
extract-subvector.ll
extract-vector-elt.ll
int-shifts.ll
loads.ll
shuffle.ll
stores.ll

Differential Revision: https://reviews.llvm.org/D135564

2 years ago[AArch64] Adjust operand sequence for Add+Sub to combine more inline shift
chenglin.bi [Mon, 31 Oct 2022 02:37:40 +0000 (10:37 +0800)]
[AArch64] Adjust operand sequence for Add+Sub to combine more inline shift

((X >> C) - Y) + Z --> (Z - Y) + (X >> C)

Fix AArch part: #55714

Reviewed By: dmgreen

Differential Revision: https://reviews.llvm.org/D136158

2 years ago[MLIR][OpenMP] Allow the single operation to have a region
Kiran Chandramohan [Mon, 31 Oct 2022 10:34:39 +0000 (10:34 +0000)]
[MLIR][OpenMP] Allow the single operation to have a region

The OpenMP standard specifies the region inside to be a structured
block. This means that branches into or out of the region is not
permitted but branches are permitted inside the OpenMP single region.
This is currently modeled by having a region of kind `AnyRegion` for
all the OpenMP ops. In future we can have a more strictly defined
region.

Fixes #58396.

Reviewed By: peixin

Differential Revision: https://reviews.llvm.org/D137023

2 years ago[clangd] Populate ranges and symbol origin for paramname completions
Kadir Cetinkaya [Fri, 28 Oct 2022 14:30:22 +0000 (16:30 +0200)]
[clangd] Populate ranges and symbol origin for paramname completions

Differential Revision: https://reviews.llvm.org/D136951

2 years ago[clangd] Fix a semantic-highlighting crash.
Haojian Wu [Mon, 31 Oct 2022 08:58:58 +0000 (09:58 +0100)]
[clangd] Fix a semantic-highlighting crash.

Differential Revision: https://reviews.llvm.org/D137064

2 years ago[mlir][bufferize][NFC] Better debug output for One-Shot Analysis
Matthias Springer [Mon, 31 Oct 2022 09:46:33 +0000 (10:46 +0100)]
[mlir][bufferize][NFC] Better debug output for One-Shot Analysis

Run mlir-opt with `-debug-only="one-shot-analysis"` for detailed debug output.

Differential Revision: https://reviews.llvm.org/D135549

2 years ago[flang] Set declared type when NULLIFY a polymorphic pointer
Valentin Clement [Mon, 31 Oct 2022 10:02:50 +0000 (11:02 +0100)]
[flang] Set declared type when NULLIFY a polymorphic pointer

Fortran standard 7.3.2.3 point 7 mentions that a diassociated
pointer dynamic type is its declared type.
in 9.7.2 note 1, when a NULLIFY statement is applied to a polymorphic pointer,
its dynamic type becomes the same as its declared type.
This patch enforce these standard points by calling the runtime function
`PointerNullifyDerived` with the declared type descriptor.

Reviewed By: jeanPerier

Differential Revision: https://reviews.llvm.org/D136948

2 years ago[Attributes] Add additional MemoryEffects APIs (NFC)
Nikita Popov [Mon, 31 Oct 2022 09:34:51 +0000 (10:34 +0100)]
[Attributes] Add additional MemoryEffects APIs (NFC)

This adds the usual complement of APIs for creating and fetching
a non-trivial attribute.

Split out from D135780.

2 years ago[mlir][bufferize][NFC] Debug output during bufferization
Matthias Springer [Mon, 31 Oct 2022 09:24:02 +0000 (10:24 +0100)]
[mlir][bufferize][NFC] Debug output during bufferization

When running with `-debug`, print the IR after bufferizing each op.

Differential Revision: https://reviews.llvm.org/D137065

2 years ago[llvm][ocaml] Replace deprecated C functions in OCaml bindings
Alan Hu [Mon, 31 Oct 2022 09:23:35 +0000 (10:23 +0100)]
[llvm][ocaml] Replace deprecated C functions in OCaml bindings

Follow-up to D135524, to replace two more deprecated C functions
in the OCaml bindings. const_in_bounds_gep now accepts the source
element type as argument, and const_element has been changed into
aggregate_element, which works on a wider range of constants and
returns an option.

Differential Revision: https://reviews.llvm.org/D136914

2 years ago[ValueTracking] Improve performance of programUndefinedIfUndefOrPoison (NFC)
Geza Lore [Mon, 31 Oct 2022 09:20:11 +0000 (10:20 +0100)]
[ValueTracking] Improve performance of programUndefinedIfUndefOrPoison (NFC)

programUndefinedIfUndefOrPoison used to eagerly propagate the fact that
a value is poison to the users of the value. The problem is that if the
value has a lot of uses (orders of magnitude more than the scanning
limit we use in this function), then we spend the bulk of our time in
eagerly propagating the poison property, which we will mostly never use
later anyway due to the scanning limit.

I have a test case (of ~50k lines of machine generated C++), where this
results in ~60% of 35s compilation time being spent doing just this
eager propagation.

This patch changes programUndefinedIfUndefOrPoison to only propagate to
instructions actually visited, looking back to see if their operands are
poison. This should be equivalent and no functional change is intended,
but we regain virtually all of the 60% compilation time spent in this
function in my test case (i.e.: a 2.5x total compilation speedup).

Differential Revision: https://reviews.llvm.org/D137027

2 years ago[BasicAA] Include MayBeCrossIteration in cache key
Nikita Popov [Tue, 18 Oct 2022 10:05:12 +0000 (12:05 +0200)]
[BasicAA] Include MayBeCrossIteration in cache key

Rather than switching to a new AAQI instance with empty cache when
MayBeCrossIteration is toggled, include the value in the cache key.

The implementation redundantly include the information in both sides
of the pair, but that seems simpler than trying to store it only on
one side.

Differential Revision: https://reviews.llvm.org/D136175

2 years ago[flang][NFC] Update document with current status
Valentin Clement [Mon, 31 Oct 2022 08:45:38 +0000 (09:45 +0100)]
[flang][NFC] Update document with current status

fir.dispatch codegen was done in D136189.

2 years ago[Coroutines] Use default attributes for some coro intrinsics
Nikita Popov [Fri, 28 Oct 2022 09:42:10 +0000 (11:42 +0200)]
[Coroutines] Use default attributes for some coro intrinsics

This adds the default attributes (nosync, nofree, nocallback,
willreturn) to the coro.id and coro.subfn.addr intrinsics. This
is needed to avoid optimization regressions in the future.

It's probably possible to use default attributes for most other
coro intrinsics as well, but I only hit these as problematic in
practice.

Differential Revision: https://reviews.llvm.org/D136932

2 years agoHandle errors in expansion of response files
Serge Pavlov [Mon, 31 Oct 2022 05:59:15 +0000 (12:59 +0700)]
Handle errors in expansion of response files

Previously an error raised during an expansion of response files (including
configuration files) was ignored and only the fact of its presence was
reported to the user with generic error messages. This made it difficult to
analyze problems. For example, if a configuration file tried to read an
inexistent file, the error message said that 'configuration file cannot
be found', which is wrong and misleading.

This change enhances handling errors in the expansion so that users
could get more informative error messages.

Differential Revision: https://reviews.llvm.org/D136090

2 years ago[libarcher] Place classes in anonymous namespace
Nikita Popov [Thu, 27 Oct 2022 13:58:57 +0000 (15:58 +0200)]
[libarcher] Place classes in anonymous namespace

Place various classes/structs into anonymous namespaces and mark
variables as static. As far as I understand, these are all
implementation details and not intended to be exported -- only a
small number of tsan hooks are supposed to be.

Differential Revision: https://reviews.llvm.org/D136845

2 years ago[X86] Use default attributes for intrinsics
Nikita Popov [Fri, 28 Oct 2022 10:30:28 +0000 (12:30 +0200)]
[X86] Use default attributes for intrinsics

This adds the default attributes (nocallback, nosync, nofree,
willreturn) to some X86 intrinsics. This will be needed to avoid
optimization regressions in the future (once we remove the
readonly -> willreturn implication for intrinsics).

Due to the number of intrinsics, this patch focuses just on the
IntrNoMem intrinsics up to the AVX2 section.

Differential Revision: https://reviews.llvm.org/D136939

2 years ago[mlir] Do not expose MLIRContext::isDialectLoading
Matthias Springer [Mon, 31 Oct 2022 07:59:12 +0000 (08:59 +0100)]
[mlir] Do not expose MLIRContext::isDialectLoading

This addresses post-commit comments and should have been part of D136685.

Differential Revision: https://reviews.llvm.org/D136923

2 years ago[docs] Add the description about mixing use of clang modules and c++
Chuanqi Xu [Mon, 24 Oct 2022 03:00:03 +0000 (11:00 +0800)]
[docs] Add the description about mixing use of clang modules and c++
modules

From the discussion in
https://discourse.llvm.org/t/how-should-we-support-dependency-scanner-for-c-20-modules/66027,
we get a consensus that we want to support clang modules and c++ modules
at the same time. This patch documents this intention.

Reviewed By: bruno

Differential Revision: https://reviews.llvm.org/D136221

2 years agoFix unused-variable warning in release build, NFC
Haojian Wu [Mon, 31 Oct 2022 07:53:04 +0000 (08:53 +0100)]
Fix unused-variable warning in release build, NFC

2 years ago[libc++] newlib/xlocale.h: remove redundant includes
Michael Platings [Fri, 28 Oct 2022 13:19:05 +0000 (14:19 +0100)]
[libc++] newlib/xlocale.h: remove redundant includes

This permits using the <locale> header with newlib or picolibc when
LIBCXX_ENABLE_WIDE_CHARACTERS=FALSE.

Since D136682 the __support/xlocale headers themselves include the
headers they require, respecting the LIBCXX_ENABLE_WIDE_CHARACTERS
option.

Differential Revision: https://reviews.llvm.org/D136947

2 years ago[lit][NFC] not check stdout in googletest-timeout.py
Yuanfang Chen [Mon, 31 Oct 2022 06:17:50 +0000 (23:17 -0700)]
[lit][NFC] not check stdout in googletest-timeout.py

This is flicky for buildbots (for example, https://lab.llvm.org/buildbot/#/builders/188/builds/21560)
because of the short timeout. The test coverage is not reduced because
the stdout check is performed in other googtest-* unit tests.

2 years ago[Clang] use non-instantiated function declaration for constraints partial ordering
Yuanfang Chen [Mon, 31 Oct 2022 04:33:22 +0000 (21:33 -0700)]
[Clang] use non-instantiated function declaration for constraints partial ordering

Per wordings in
- https://eel.is/c++draft/over.match#best.general-2.6
- https://eel.is/c++draft/temp.constr.order
- https://eel.is/c++draft/temp.constr#atomic-1

constraints partial ordering should use the unsubstituted template
parameters of the constrained entity, not the instantiated entity.

Fix #56154

Reviewed By: erichkeane, royjacobson, mizvekov

Differential Revision: https://reviews.llvm.org/D136545

2 years ago[Clang] perform "maximum TLS alignment" check for template instantiation
Yuanfang Chen [Mon, 31 Oct 2022 04:33:10 +0000 (21:33 -0700)]
[Clang] perform "maximum TLS alignment" check for template instantiation

follow up https://github.com/llvm/llvm-project/commit/d30e2eefc3cf8dfd2210aefd62f13a6e7c011b43

Reviewed By: mizvekov

Differential Revision: https://reviews.llvm.org/D136744

2 years ago[PowerPC] Optimize compare by using record form in post-RA.
esmeyi [Mon, 31 Oct 2022 05:33:50 +0000 (01:33 -0400)]
[PowerPC] Optimize compare by using record form in post-RA.

Summary: We currently optimize the comparison only in SSA, therefore we will miss some optimization opportunities where the input of comparison is lowered from COPY in post-RA.
Ie. ExpandPostRA::LowerCopy is called after PPCInstrInfo::optimizeCompareInstr.
This patch optimizes the comparison in post-RA and only the cases that compare against zero can be handled.
D131374 converts the comparison and its user to a compare against zero with the appropriate predicate on the branch, which creates additional opportunities for this patch.

Reviewed By: shchenz, lkail

Differential Revision: https://reviews.llvm.org/D131873

2 years ago[JITLink][AArch64] Update edge names to be more descriptive, add comments.
Lang Hames [Mon, 31 Oct 2022 01:41:28 +0000 (18:41 -0700)]
[JITLink][AArch64] Update edge names to be more descriptive, add comments.

This brings the aarch64 edges into alignment with the naming scheme for the
x86-64 edges.

Edge behavior is mostly unchanged, but some irrelevant assertions and errors
have been removed.

2 years ago[LoongArch] Support inline asm operand modifier 'z'
Weining Lu [Mon, 31 Oct 2022 01:15:29 +0000 (09:15 +0800)]
[LoongArch] Support inline asm operand modifier 'z'

Print $zero register if operand is zero, otherwise print it normally.

Clang is highly compatible [1] with GCC inline assembly extensions,
allowing the same set of constraints, modifiers and operands as GCC
inline assembly. This patch tries to make it compatible regarding
LoongArch specific operand modifiers.

GCC supports many modifiers [2], but it seems that only x86 and msp430
are documented [3][4]. I don't know if any other modifiers are being
used except the 'z' in Linux [5].

[1]: https://clang.llvm.org/compatibility.html#inline-asm
[2]: https://github.com/gcc-mirror/gcc/blob/master/gcc/config/loongarch/loongarch.cc#L4884-L4911
[3]: https://gcc.gnu.org/onlinedocs/gcc/Extended-Asm.html#x86Operandmodifiers
[4]: https://gcc.gnu.org/onlinedocs/gcc/Extended-Asm.html#msp430Operandmodifiers
[5]: https://github.com/torvalds/linux/blob/master/arch/loongarch/include/asm/cmpxchg.h#L17

Differential Revision: https://reviews.llvm.org/D136841

2 years ago[LoongArch] Replace assertion by error message while lowering RETURNADDR and FRAMEADDR
gonglingqin [Mon, 31 Oct 2022 01:18:20 +0000 (09:18 +0800)]
[LoongArch] Replace assertion by error message while lowering RETURNADDR and FRAMEADDR

If `__builtin_frame_address` or `__builtin_return_address` is invoked with
non-zero argument, show an error message instead of a crash.

Reference: https://reviews.llvm.org/rG83b88441ad951fe99c30402930ef3cd661f2fd2b

Differential Revision: https://reviews.llvm.org/D136917

2 years ago[Clang][LoongArch] Support inline asm constraint 'J'
Weining Lu [Mon, 31 Oct 2022 00:46:58 +0000 (08:46 +0800)]
[Clang][LoongArch] Support inline asm constraint 'J'

'J' is defined in GCC [1] but not documented [2] while Linux [3] has
already used it in LoongArch port.

[1]: https://github.com/gcc-mirror/gcc/blob/master/gcc/config/loongarch/constraints.md#L61
[2]: https://gcc.gnu.org/onlinedocs/gccint/Machine-Constraints.html
[3]: https://github.com/torvalds/linux/blob/master/arch/loongarch/include/asm/cmpxchg.h#L19

Differential Revision: https://reviews.llvm.org/D136835

2 years ago[flang] Catch attempts to do anything with statement functions other than call them
Peter Klausler [Mon, 24 Oct 2022 23:59:55 +0000 (16:59 -0700)]
[flang] Catch attempts to do anything with statement functions other than call them

A statement function in Fortran may be called, but it may not be the target
of a procedure pointer or passed as an actual argument.

2 years ago[NFC][m68k] Add pipeline.ll
Sheng [Mon, 31 Oct 2022 00:50:54 +0000 (08:50 +0800)]
[NFC][m68k] Add pipeline.ll

2 years ago[JITLink][i386] Adds absolute and pc relative relocation support for ELF/i386.
Kshitij Jain [Mon, 31 Oct 2022 00:24:57 +0000 (17:24 -0700)]
[JITLink][i386] Adds absolute and pc relative relocation support for ELF/i386.

This commit adds support for 32 bit absolute and pc relative relocations in
ELF/i386 objects, along with simple regression tests.

Reviewed By: sgraenitz, lhames

Differential Revision: https://reviews.llvm.org/D135523

2 years ago[flang] Require explicit interface for some dummy procedures
Peter Klausler [Mon, 24 Oct 2022 22:47:56 +0000 (15:47 -0700)]
[flang] Require explicit interface for some dummy procedures

Some of the circumstances that require that a procedure have an
explicit interface at a point of call due to a characteristic of
a dummy argument apply to dummy procedures, too.

Differential Revision: https://reviews.llvm.org/D136994

2 years agoMake scf.for and affine.for conditionally speculatable
Sanjoy Das [Thu, 20 Oct 2022 06:03:14 +0000 (23:03 -0700)]
Make scf.for and affine.for conditionally speculatable

for (I = Start; I < End; I += 1) always terminates so mark
{scf|affine}.for as RecursivelySpeculatable when step is known to be
1.

Reviewed By: chelini

Differential Revision: https://reviews.llvm.org/D136376

2 years ago[JITLink][aarch64] Remove the unused PairedAddend aarch64 edge kind.
Lang Hames [Sun, 30 Oct 2022 22:53:38 +0000 (15:53 -0700)]
[JITLink][aarch64] Remove the unused PairedAddend aarch64 edge kind.

This is a vestige of the original MachO-specific edge set and was never used
as a generic aarch64 edge kind.

2 years ago[flang][MSVC] Disable test
Peter Klausler [Sun, 30 Oct 2022 21:53:05 +0000 (14:53 -0700)]
[flang][MSVC] Disable test

Disable the test that corresponds to a semantic check that was
disabled to work around an MSVC build problem.

2 years ago[flang] Enforce C815
Peter Klausler [Mon, 24 Oct 2022 20:03:50 +0000 (13:03 -0700)]
[flang] Enforce C815

A Fortran program may not specify a particular attribute multiple
times for the same entity in a scope.

Differential Revision: https://reviews.llvm.org/D136991

2 years ago[InstCombine] Allow memcpys from constant memory to readonly nocapture parameters...
Patrick Walton [Thu, 27 Oct 2022 02:54:26 +0000 (19:54 -0700)]
[InstCombine] Allow memcpys from constant memory to readonly nocapture parameters to be elided.

Currently, InstCombine can elide a memcpy from a constant to a local alloca if
that alloca is passed as a nocapture parameter to a *function* that's readnone
or readonly, but it can't forward the memcpy if the *argument* is marked
readonly nocapture, even though readonly guarantees that the callee won't
mutate the pointee through that pointer. This patch adds support for detecting
and handling such situations, which arise relatively frequently in Rust, a
frontend that liberally emits readonly.

A more general version of this optimization would use alias analysis to check
the call's ModRef info for the pointee, but I was concerned about blowing up
compile time, so for now I'm just checking for one of readnone on the function,
readonly on the function, or readonly on the parameter.

Differential Revision: https://reviews.llvm.org/D136822

2 years ago[ADT] Make mapped_iterator copy assignable
James Player [Sun, 30 Oct 2022 21:37:07 +0000 (14:37 -0700)]
[ADT] Make mapped_iterator copy assignable

As mentioned in https://discourse.llvm.org/t/rfc-extend-ranges-infrastructure-to-better-match-c-20/65377

Lambda objects are not copy assignable, and therefore neither are
iterator types which hold a lambda.  STL code require iterators be
copy assignable.  Users may not use mapped_iterator with a std::deque
for example: https://godbolt.org/z/4Px7odEEd

This blog post [1] explains the problem and solution.  We define a
wrapper class to store callable objects with two specialization.

1. Specialization for non-function types
    - Use a std::optional as storage for non-function callable.
    - Define operator=() implementation(s) which use
      std::optional::emplace() instead of the assignment operator.
2. Specialization for function types
    - Store as a pointer (even if template argument is a function reference).
    - Default construct pointer to nullptr.

This Callable wrapper class is now default constructible (with invalid
state) and copy/move assignable.

With these new properties available on the callable object,
mapped_iterator can define a default constructor as well.

[1] https://www.fluentcpp.com/2019/04/16/an-alternative-design-to-iterators-and-ranges-using-stdoptional/

Reviewed By: kazu

Differential Revision: https://reviews.llvm.org/D134675

2 years ago[flang] Correct a predicate around a semantic check
Peter Klausler [Mon, 24 Oct 2022 19:06:56 +0000 (12:06 -0700)]
[flang] Correct a predicate around a semantic check

When a dummy argument is a procedure pointer without INTENT(IN),
any actual argument must also be a procedure pointer, whether the
dummy procedure pointer's interface is explicit or not.

Differential Revision: https://reviews.llvm.org/D136989

2 years ago[SimpleLoopUnswitch] Forget block and loop dispositions.
Florian Hahn [Sun, 30 Oct 2022 20:44:21 +0000 (20:44 +0000)]
[SimpleLoopUnswitch] Forget block and loop dispositions.

Also invalidate block and loop dispositions during non-trivial
unswitching.

Fixes #58564.

2 years ago[flang] Don't resolve component names to components in derived-type definition scope
Peter Klausler [Mon, 24 Oct 2022 18:22:22 +0000 (11:22 -0700)]
[flang] Don't resolve component names to components in derived-type definition scope

We implemented 19.3.4p1 literally in name resolution:

  A component name has the scope of its derived-type definition. Outside the type definition,
  it may also appear within a designator of a component of a structure of that type or as a
  component keyword in a structure constructor for that type.

and within the derived-type definition would resolve the "bare"
names of components in specification inquiries and other contexts to
those components, not to any symbols in the enclosing scopes.

It turns out that most Fortran compilers resolve only "bare" names thus
when they are type parameters, and the names of data and procedure components
do not shadow exterior symbols.  Adjust name resolution to follow that
precedent rather than what seems to be clear language in the standard.

Differential Revision: https://reviews.llvm.org/D136984

2 years ago[flang][NFC] Change wording of an I/O runtime error message
Peter Klausler [Sat, 22 Oct 2022 15:52:29 +0000 (08:52 -0700)]
[flang][NFC] Change wording of an I/O runtime error message

Make a requested change to the wording of a fatal I/O error
message.

Differential Revision: https://reviews.llvm.org/D136984

2 years ago[llvm-objdump] Set --print-imm-hex by default.
Daniel Thornburgh [Sat, 29 Oct 2022 03:09:09 +0000 (20:09 -0700)]
[llvm-objdump] Set --print-imm-hex by default.

This was previously attempted in 2016 by colinl's D18770, but LLD tests
were missed, which caused the change to be reverted.

Setting --print-imm-hex by default brings llvm-objdump's behavior closer
in line with objdump, and it makes it easier to read addresses and
alignment from the disassembly. It may make non-address immediates
harder to interpret, but it still seems the better default, barring more
context-sensitive base selection logic.

Differential Revision: https://reviews.llvm.org/D136972

2 years ago[llvm-objdump] Add --no-print-imm-hex to new tests depending on it.
Daniel Thornburgh [Sun, 30 Oct 2022 20:34:22 +0000 (13:34 -0700)]
[llvm-objdump] Add --no-print-imm-hex to new tests depending on it.

This prepares for an upcoming change to make --print-imm-hex the default
behavior of llvm-objdump. A few newly-added tests were missed the first
time around.

See D136972 for details.

2 years ago[lld] Fix a warning
Kazu Hirata [Sun, 30 Oct 2022 20:33:33 +0000 (13:33 -0700)]
[lld] Fix a warning

This patch fixes:

  lld/MachO/SyntheticSections.cpp: In member function ‘virtual void
  lld::macho::ChainedFixupsSection::writeTo(uint8_t*) const’:

2 years ago[flang][MSVC] Take 2 on a work-around for bogus MSVC error
Peter Klausler [Sun, 30 Oct 2022 20:30:55 +0000 (13:30 -0700)]
[flang][MSVC] Take 2 on a work-around for bogus MSVC error

Previous attempt to work around a bogus error from MSVC 14 on
code from a recent patch failed, so add an #ifdef and disable
the feature for MSVC builds to get the build bot back up.

2 years ago[lld] Fix a warning
Kazu Hirata [Sun, 30 Oct 2022 20:28:00 +0000 (13:28 -0700)]
[lld] Fix a warning

This patch fixes:

  lld/MachO/OutputSegment.cpp:50:43: warning: enumerated and
  non-enumerated type in conditional expression [-Wextra]

2 years agoRevert "[ADT] Remove redundaunt typename (NFC)"
Kazu Hirata [Sun, 30 Oct 2022 20:20:50 +0000 (13:20 -0700)]
Revert "[ADT] Remove redundaunt typename (NFC)"

This reverts commit 95eaefd0df7564a380f71a6909a5bd6b3ad32ab2.

I accidentally committed a patch to add a redundant typename.

2 years ago[test][asan] Make the printf-5.c test case actually emit a volatile memcpy.
Patrick Walton [Sun, 30 Oct 2022 18:07:38 +0000 (11:07 -0700)]
[test][asan] Make the printf-5.c test case actually emit a volatile memcpy.

The current test in printf-5.c appears to try to emit a volatile memcpy for the
format string, but it doesn't because the volatile qualifier is implicitly
casted away. Using a string literal instead preserves the volatile qualifier.

This is a follow-up to D137031 and is a prerequisite for D136822, which elides
memcpys in more instances and would otherwise break this test.

Differential Revision: https://reviews.llvm.org/D137042

2 years ago[ADT] Remove redundaunt typename (NFC)
Kazu Hirata [Sun, 30 Oct 2022 20:17:04 +0000 (13:17 -0700)]
[ADT] Remove redundaunt typename (NFC)

2 years ago[AMDGPU] Fix a warning
Kazu Hirata [Sun, 30 Oct 2022 20:09:59 +0000 (13:09 -0700)]
[AMDGPU] Fix a warning

This patch fixes:

  llvm/lib/Target/AMDGPU/SIInstrInfo.cpp:7383: warning: enumerated
  mismatch in conditional expression:
  ‘llvm::AMDGPU::UfmtGFX11::UnifiedFormat’ vs
  ‘llvm::AMDGPU::UfmtGFX10::UnifiedFormat’

2 years ago[Mips] Fix a warning
Kazu Hirata [Sun, 30 Oct 2022 20:03:32 +0000 (13:03 -0700)]
[Mips] Fix a warning

This patch fixes:

  llvm/lib/Target/Mips/MipsInstrInfo.cpp:71:52: warning: enumerated
  and non-enumerated type in conditional expression [-Wextra]

2 years ago[flang][MSVC] Work around what seems to be a bogus MSVC error
Peter Klausler [Sun, 30 Oct 2022 19:40:19 +0000 (12:40 -0700)]
[flang][MSVC] Work around what seems to be a bogus MSVC error

Recode a recent patch in an attempt to dodge a nonsensical error
from MSVC 14.

2 years ago[Hexagon] Remove HexagonVectorCombine::simplify
Kazu Hirata [Sun, 30 Oct 2022 19:56:59 +0000 (12:56 -0700)]
[Hexagon] Remove HexagonVectorCombine::simplify

This patch fixes:

  llvm/lib/Target/Hexagon/HexagonVectorCombine.cpp:1554:6: warning:
  ‘llvm::Value*
  {anonymous}::HexagonVectorCombine::simplify(llvm::Value*) const’
  defined but not used [-Wunused-function]

2 years ago[Analysis] Fix warnings
Kazu Hirata [Sun, 30 Oct 2022 19:52:06 +0000 (12:52 -0700)]
[Analysis] Fix warnings

This patch fixes:

  llvm/utils/unittest/googletest/include/gtest/gtest.h:1526:11: error:
  comparison of integers of different signs: 'const unsigned long' and
  'const int' [-Werror,-Wsign-compare]

2 years agoManagedStatic: remove from DebugCounter
Nicolai Hähnle [Mon, 4 Jul 2022 10:52:08 +0000 (12:52 +0200)]
ManagedStatic: remove from DebugCounter

[Re-submit after earlier revert due to a test failure. Commit dce78646f07
("clang-tblgen build: avoid duplicate inclusion of libLLVMSupport")
is believe to address the root cause of the test failure.]

Follow the pattern used in MLIR for the cl::opt instances.

v2:
- make DebugCounter::isCountingEnabled public so that the
  DebugCounterOwner doesn't have to be a nested class. This simplifies
  later changes

v3:
- remove the indirection via DebugCounterOwner::instance()

Differential Revision: https://reviews.llvm.org/D129116

2 years ago[flang] Fix a warning
Kazu Hirata [Sun, 30 Oct 2022 19:33:39 +0000 (12:33 -0700)]
[flang] Fix a warning

This patch fixes:

  flang/lib/Evaluate/fold-integer.cpp:613:25: error: lambda capture
  'name' is not used [-Werror,-Wunused-lambda-capture]

2 years ago[flang][MSVC] Resolve warning message
Peter Klausler [Sun, 30 Oct 2022 18:20:13 +0000 (11:20 -0700)]
[flang][MSVC] Resolve warning message

MSVC emits a warning on some recently patched code; fix it.

2 years ago[JITLink][AArch64] Remove unused Pointer64Anon edge kind.
Lang Hames [Sun, 30 Oct 2022 18:11:27 +0000 (11:11 -0700)]
[JITLink][AArch64] Remove unused Pointer64Anon edge kind.

Pointer64Anon was lifted out of the MachO backend and into aarch64.h when that
header was created, but Pointer64Anon is really a MachO-specific "normalized"
relocation value, rather than a generic Edge::Kind. Any uses can be safely
replaced with Pointer64.

(Side note: the role of MachOPointer64Anon is to aid MachO relocation parsing:
For MachOPointer64, the target symbol is specified by the r_symbolnum field in
the relocation. For MachOPointer64Anon the address of the anonymous target is
read from the fixup location.)

2 years ago[flang] Complex constructors are scalar only
Peter Klausler [Fri, 14 Oct 2022 21:28:22 +0000 (14:28 -0700)]
[flang] Complex constructors are scalar only

The common language extension that allows arbitary expressions
to be used as components in a complex constructor (x,y) -- not both
constant, since that would make it a complex literal constant --
still have to be scalar; it's not an elemental operation like the
CMPLX() intrinsic function is.

Differential Revision: https://reviews.llvm.org/D136978

2 years ago[flang] Emit warnings when results of folding some integer intrinsics overflow
Peter Klausler [Fri, 14 Oct 2022 00:14:20 +0000 (17:14 -0700)]
[flang] Emit warnings when results of folding some integer intrinsics overflow

When the compile-time result value of a reference to an integer-valued intrinsic
function COUNT, ICHAR, IACHAR, INDEX, SCAN, or VERIFY cannot be represented in
the selected result kind, emit a warning.

Differential Revision: https://reviews.llvm.org/D136974

2 years ago[ValueTracking] Assert known bits sanity in isKnownNonZero
Philip Reames [Sun, 30 Oct 2022 17:52:27 +0000 (10:52 -0700)]
[ValueTracking] Assert known bits sanity in isKnownNonZero

These are the same asserts we have in other query routines; cover this interface too.

2 years ago[X86] Remove unnecessary MMX PACKSS/PACKUS SchedWriteRes overrides
Simon Pilgrim [Sun, 30 Oct 2022 17:41:53 +0000 (17:41 +0000)]
[X86] Remove unnecessary MMX PACKSS/PACKUS SchedWriteRes overrides

These overrides should now match the default WriteShuffle schedules

This also fixes a typo where we were missing load latencies for the memory folded variants

2 years ago[VectorUtils] Add getShuffleDemandedElts helper
Simon Pilgrim [Sun, 30 Oct 2022 17:03:49 +0000 (17:03 +0000)]
[VectorUtils] Add getShuffleDemandedElts helper

We have similar code to translate a demanded elements mask for a shuffle's operands in multiple places - this patch adds a helper function to VectorUtils and updates a number of locations to use it directly.

Differential Revision: https://reviews.llvm.org/D136832

2 years ago[flang] Stricter scrutiny of MOVE_ALLOC calls
Peter Klausler [Thu, 13 Oct 2022 23:44:34 +0000 (16:44 -0700)]
[flang] Stricter scrutiny of MOVE_ALLOC calls

Enforce remaining semantic restrictions on the arguments to MOVE_ALLOC,
namely that the first two arguments must be allocatable (!) and that
if the source is polymorphic, so must the destination be.

Differential Revision: https://reviews.llvm.org/D136973

2 years ago[clang-tools-extra] Use llvm::find (NFC)
Kazu Hirata [Sun, 30 Oct 2022 16:41:55 +0000 (09:41 -0700)]
[clang-tools-extra] Use llvm::find (NFC)

2 years agoAllow scalable vectors in computeKnownBits
Philip Reames [Sun, 30 Oct 2022 15:42:36 +0000 (08:42 -0700)]
Allow scalable vectors in computeKnownBits

This extends the computeKnownBits analysis to support scalable vectors. The critical detail is in deciding how to represent the demanded elements of a vector whose length is unknown at compile time.

For this patch, I adopt the convention that we track one bit which corresponds to all lanes. That is, that bit is implicitly broadcast to all lanes of the scalable vector resulting in all lanes being demanded. This is the same convention we use in getSplatValue in SelectionDAG.

Note that this convention doesn't actually impact much. Most of the code is agnostic to the interpretation of the demanded elements, and the few cases which actually care need case by case handling anyways. In this patch, I just bail out of those cases.

A prior patch (D128159) proposed using a different convention in SDAG. I don't see any strong reason to prefer one scheme over the other, so I propose we go with this one as it's conceptually the simplest. Getting known and demanded bit optimizations unblocked at all is a significant win.

I've locally implemented this scheme in reasonable large parts of ValueTracking.cpp and SelectionDAG equivalents, and have not hit any blockers. If this is approved, I plan to post a series of patches plumbing this through all the relevant parts.

In the discussion on that patch, a preference was expressed for introducing some form of abstraction around the demanded elements. I'll note that I've played with several variations on that idea locally, and have yet to find anything which results in more readable code. If anyone has concrete ideas in this area, I'm happy to explore in follow up patches. I'd strongly prefer to be making API changes in NFC manner with tests in place.

Differential Revision: https://reviews.llvm.org/D136470

2 years ago[X86] Fix simd integer ALU and shuffle port allocations
Simon Pilgrim [Sun, 30 Oct 2022 14:23:51 +0000 (14:23 +0000)]
[X86] Fix simd integer ALU and shuffle port allocations

znver1/2 uses pipes0/1/3 for most integer ALU and nearly all integer/float shuffles occur on pipes1/2

More cleanup work to hopefully get shuffle kinds costs testing added to the D103695 script sometime soon

Confirmed with the AMD SoG, Agner + instlatx64

2 years ago[X86] Ensure 256-bit sqrt + crosslane shuffles are set to 2 uops + half rate
Simon Pilgrim [Sun, 30 Oct 2022 14:01:48 +0000 (14:01 +0000)]
[X86] Ensure 256-bit sqrt + crosslane shuffles are set to 2 uops + half rate

Fixes another mismatch between the D103695 script and the znver1 scheduler model

Confirmed with the AMD SoG, Agner + instlatx64

2 years ago[InstCombine] refactor the SimplifyUsingDistributiveLaws NFC
zhongyunde [Sun, 30 Oct 2022 13:00:54 +0000 (21:00 +0800)]
[InstCombine] refactor the SimplifyUsingDistributiveLaws NFC

Precommit for D136015
Reviewed By: spatel
Differential Revision: https://reviews.llvm.org/D137019

2 years agoFix the clang Sphinx build
Aaron Ballman [Sun, 30 Oct 2022 12:59:33 +0000 (08:59 -0400)]
Fix the clang Sphinx build

This should address the issue found in:
https://lab.llvm.org/buildbot/#/builders/92/builds/34906

2 years ago[clang-format] Adds a formatter for aligning trailing comments over empty lines
Yusuke Kadowaki [Sun, 30 Oct 2022 12:21:20 +0000 (12:21 +0000)]
[clang-format] Adds a formatter for aligning trailing comments over empty lines

This patch addresses https://github.com/llvm/llvm-project/issues/19756

Reviewed By: MyDeveloperDay, HazardyKnusperkeks

Differential Revision: https://reviews.llvm.org/D132131

2 years ago[test][InstCombine] Add tests for removing memcpy to an alloca that is passed to...
Patrick Walton [Sun, 30 Oct 2022 02:03:29 +0000 (19:03 -0700)]
[test][InstCombine] Add tests for removing memcpy to an alloca that is passed to a readonly nocapture function parameter, in preparation for D136822.

This commit adds tests to Transforms/InstCombine/memcpy-from-global.ll that
test various situations involving memcpy from a constant to an alloca that is
then passed to function parameters with various attributes. The forthcoming
D136822 allows InstCombine to remove these memcpys if they're passed to a
single readonly nocapture parameter.

Differential Revision: https://reviews.llvm.org/D137033

2 years ago[InstCombine] Avoid deleting volatile memcpys.
Patrick Walton [Sun, 30 Oct 2022 00:34:57 +0000 (17:34 -0700)]
[InstCombine] Avoid deleting volatile memcpys.

InstCombine can replace memcpy to an alloca with a pointer directly to the
source in certain cases. Unfortunately, it also did so for volatile memcpys.
This patch makes it stop doing that.

This was discovered in D136822.

Differential Revision: https://reviews.llvm.org/D137031

2 years ago[test][InstCombine] Add a test case for volatile memcpy forwarding in InstCombine...
Patrick Walton [Sat, 29 Oct 2022 23:38:27 +0000 (16:38 -0700)]
[test][InstCombine] Add a test case for volatile memcpy forwarding in InstCombine, which is currently optimized incorrectly.

D136822 demonstrated that we currently delete volatile memcpys in InstCombine,
which we shouldn't do. This commit adds a test for this. A forthcoming commit
will fix it.

Differential Revision: https://reviews.llvm.org/D137029

2 years ago[clang][Interp] Implement bitXor opcode
Timm Bäder [Sat, 22 Oct 2022 14:59:19 +0000 (16:59 +0200)]
[clang][Interp] Implement bitXor opcode

Differential Revision: https://reviews.llvm.org/D136956

2 years ago[clang][Interp] Implement left and right shifts
Timm Bäder [Sat, 22 Oct 2022 16:19:10 +0000 (18:19 +0200)]
[clang][Interp] Implement left and right shifts

Differential Revision: https://reviews.llvm.org/D136532

2 years ago[mlir] Fix a warning
Kazu Hirata [Sun, 30 Oct 2022 07:18:08 +0000 (00:18 -0700)]
[mlir] Fix a warning

This patch fixes:

  mlir/include/mlir/IR/PatternMatch.h:1209:72: warning: parameter
  ‘values’ set but not used [-Wunused-but-set-parameter]

2 years ago[clang][Interp] Implement add and sub compound assign operators
Timm Bäder [Sat, 22 Oct 2022 13:32:27 +0000 (15:32 +0200)]
[clang][Interp] Implement add and sub compound assign operators

Differential Revision: https://reviews.llvm.org/D136528

2 years ago[ADT] Remove redundant typename (NFC)
Kazu Hirata [Sun, 30 Oct 2022 06:50:56 +0000 (23:50 -0700)]
[ADT] Remove redundant typename (NFC)

2 years ago[clang-format] Don't crash on malformed preprocessor conditions
sstwcw [Sun, 30 Oct 2022 02:18:58 +0000 (02:18 +0000)]
[clang-format] Don't crash on malformed preprocessor conditions

Previously the program would crash on this input:

```
#else
#if X
```

The problem was that in `parsePPElse`, `PPBranchLevel` would be
incremented when the first `#else` gets parsed, but `PPLevelBranchCount`
and `PPLevelBranchIndex` would not be updated together.

I found the problem when working on D135740.

Differential Revision: https://reviews.llvm.org/D135972

2 years ago[flang] Abstract interfaces can't be designated or referenced
Peter Klausler [Thu, 13 Oct 2022 17:38:55 +0000 (10:38 -0700)]
[flang] Abstract interfaces can't be designated or referenced

Broaden the check for misuse of ABSTRACT procedure interfaces by
doing it in expression analysis rather than name resolution so that
cases like pointer assignment targets and actual arguments are also
diagnosed as errors.

Differential Revision: https://reviews.llvm.org/D136971

2 years ago[flang] Stricter scrutiny of deferred type parameters (C702)
Peter Klausler [Wed, 12 Oct 2022 22:15:33 +0000 (15:15 -0700)]
[flang] Stricter scrutiny of deferred type parameters (C702)

Semantics checks C702, which disallows deferred type parameters for
any entity that is neither an allocatable nor a pointer, only during
name resolution of type declaration statements.  This check needs to
be broader, since Fortran entities can have their types specified in
other ways.  Rewrite the check and move it to the general declaration
checking pass.

Differential Revision: https://reviews.llvm.org/D136970