Commit Graph

428513 Commits

Author SHA1 Message Date
Phoebe Wang abeeae570e [X86] Support `_Float16` on SSE2 and up
This is split from D113107 to address #56204 and https://discourse.llvm.org/t/how-to-build-compiler-rt-for-new-x86-half-float-abi/63366

Reviewed By: zahiraam, rjmccall, bkramer, MaskRay

Differential Revision: https://reviews.llvm.org/D128571
2022-06-30 17:21:37 +08:00
Nikita Popov 41f0b6a781 [Evaluator] Use ConstantFoldInstOperands()
For instructions that don't need any special handling, use
ConstantFoldInstOperands(), rather than re-implementing individual
cases.

This is probably not NFC because it can handle cases the previous
code missed (e.g. vector operations).
2022-06-30 11:10:17 +02:00
Nikita Popov a6d4b4138f [ConstantFold] Supports compares in ConstantFoldInstOperands()
Support compares in ConstantFoldInstOperands(), instead of
forcing the use of ConstantFoldCompareInstOperands(). Also handle
insertvalue (extractvalue was already handled).

This removes a footgun, where many uses of ConstantFoldInstOperands()
need a separate check for compares beforehand. It's particularly
insidious if called on a constant expression, because it doesn't
fail in that case, but will just not do DL-dependent folding.
2022-06-30 11:05:24 +02:00
Weining Lu ed7d351309 [LoongArch] Fix wrong function names in bstrpick_w.ll. NFC 2022-06-30 16:59:26 +08:00
Fraser Cormack d5213c83ff [RISCV] Add a test covering a (reverted) codegen issue
This test checks one of problematic cases outlined in D128006, leading
to the patch's reversal. I thought it best to add a test just in case
this sort of optimization is attempted again in the future in some
fashion.
2022-06-30 09:27:52 +01:00
Valentin Clement 411f839ae3
[flang] Fix for array upper bounds with *
Even though the array is declared with '*' upper bounds, it has an
initial value that has a statically known shape. Use the shape from
the type of the initializer when the declared size is '*'.

This patch is part of the upstreaming effort from fir-dev branch.

Reviewed By: jeanPerier

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

Co-authored-by: Eric Schweitz <eschweitz@nvidia.com>
2022-06-30 10:37:22 +02:00
Valentin Clement c628e9eb5e
[flang][NFC] Add FIR array test
This patch is part of the upstreaming effort from fir-dev branch.

Reviewed By: jeanPerier

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

Co-authored-by: V Donaldson <vdonaldson@nvidia.com>
Co-authored-by: Jean Perier <jperier@nvidia.com>
Co-authored-by: Eric Schweitz <eschweitz@nvidia.com>
2022-06-30 10:36:18 +02:00
Amir Ayupov 66b01a8934 [BOLT] Fix getDynoStats to handle BCs with no functions
Address fuzzer crash

Reviewed By: yota9

Differential Revision: https://reviews.llvm.org/D120696
2022-06-30 01:18:45 -07:00
Florian Hahn 24b5f8e0d0
[VPlan] Make sure optimizeInductions removes wide ind from scalar plan.
In some cases, there may be widened users of inductions even though the
plan includes the scalar VF. In those cases, make sure we still replace
the VPWidenIntOrFpInductionRecipe with scalar steps, as otherwise we may
try to execute a VPWidenIntOrFpInductionRecipe with a scalar VF.

Alternatively the patch could also split the range if needed.

This fixes a crash exposed by D123720.

Reviewed By: Ayal

Differential Revision: https://reviews.llvm.org/D128755
2022-06-30 09:11:48 +01:00
Valentin Clement 06d103ff95
[flang] Correct bug in literal CHARACTER constant names
The names of CHARACTER strings were being truncated leading to invalid
collisions and other failures. This change makes sure to use the entire
string as the seed for the unique name.

This patch is part of the upstreaming effort from fir-dev branch.

Reviewed By: jeanPerier

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

Co-authored-by: Eric Schweitz <eschweitz@nvidia.com>
2022-06-30 10:10:37 +02:00
Matthias Springer 76f7e4b7a3 [mlir][SCF][bufferize][NFC] Utilize recently added helper function
This should have been part of D128666.

Differential Revision: https://reviews.llvm.org/D128885
2022-06-30 09:54:52 +02:00
Chuanqi Xu f595003e8e [NFC] [Modules] Add test for inherit default arguments 2022-06-30 15:48:22 +08:00
Amir Ayupov cb75faf40c [X86][BOLT] Use getOperandType to determine memory access size
Generate INSTRINFO_OPERAND_TYPE table in X86GenInstrInfo.inc.

This diff adds support for instructions that were previously reported as having
memory access size 0. It replaces the heuristic of looking at instruction
register width to determine memory access width by instead checking the memory
operand type using tablegen-provided tables.

Reviewed By: skan

Differential Revision: https://reviews.llvm.org/D126116
2022-06-30 00:25:32 -07:00
Nikita Popov 10c531cd5b [SCCP] Simplify CFG in SCCP as well
Currently, we only remove dead blocks and non-feasible edges in
IPSCCP, but not in SCCP. I'm not aware of any strong reason for
that difference, so this patch updates SCCP to perform the CFG
cleanup as well.

Compile-time impact seems to be pretty minimal, in the 0.05%
geomean range on CTMark.

For the test case from https://reviews.llvm.org/D126962#3611579
the result after -sccp now looks like this:

    define void @test(i1 %c) {
    entry:
      br i1 %c, label %unreachable, label %next
    next:
      unreachable
    unreachable:
      call void @bar()
      unreachable
    }

-jump-threading does nothing on this, but -simplifycfg will produce
the optimal result.

Differential Revision: https://reviews.llvm.org/D128796
2022-06-30 09:25:03 +02:00
Valentin Clement 1e55ec6666
[flang] SELECT CASE constructs with character selectors that require a temp
Here is a character SELECT CASE construct that requires a temp to hold the
result of the TRIM intrinsic call:

```
module m
      character(len=6) :: s
    contains
      subroutine sc
        n = 0
        if (lge(s,'00')) then
          select case(trim(s))
          case('11')
             n = 1
          case default
             continue
          case('22')
             n = 2
          case('33')
             n = 3
          case('44':'55','66':'77','88':)
             n = 4
          end select
        end if
        print*, n
      end subroutine
    end module m
```

This SELECT CASE construct is implemented as an IF/ELSE-IF/ELSE comparison
sequence.  The temp must be retained until some comparison is successful.
At that point the temp may be freed.  Generalize statement context processing
to allow multiple finalize calls to do this, such that the program always
executes exactly one freemem call.

This patch is part of the upstreaming effort from fir-dev branch.

Reviewed By: klausler, vdonaldson

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

Co-authored-by: V Donaldson <vdonaldson@nvidia.com>
2022-06-30 09:04:27 +02:00
Valentin Clement ac1bda21c9
[flang] Fix error message in test 2022-06-30 09:01:58 +02:00
Stanislav Gatev 8207c2a660 [clang][dataflow] Handle `for` statements without conditions
Handle `for` statements without conditions.

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

Reviewed-by: xazax.hun, gribozavr2, li.zhe.hua
2022-06-30 07:00:35 +00:00
Valentin Clement 6c48700204
[flang][NFC] Revert message to not implemented yet 2022-06-30 08:36:10 +02:00
Carl Ritson d0f6641615 [AMDGPU] Fix liveness for loops in si-optimize-exec-masking-pre-ra
Follow up to D127894, new liveness update code needs to handle
the case where S_ANDN2 input must be extended through loops when
V_CNDMASK_B32 has been hoisted.

Reviewed By: arsenm

Differential Revision: https://reviews.llvm.org/D128800
2022-06-30 15:26:50 +09:00
Fangrui Song 3f17dc89d3 [flang][test] Remove RUN COMMAND/EXPECTED OUTPUT/INPUT markers from other directories 2022-06-29 22:10:59 -07:00
Fangrui Song d5d420bb3b [flang][test] Remove RUN LINES?/EXPECTED OUTPUT.*/INPUT markers from test/Driver
Follow-up to D128763.
2022-06-29 22:08:02 -07:00
Fangrui Song 67854f9ed0 Use value_or instead of getValueOr. NFC 2022-06-29 21:55:02 -07:00
Kevin Cadieux a3ec54c660 [lldb] Fix unused variable warning in TraceHTR (NFC)
A warning was recently introduced in [D128576](https://reviews.llvm.org/D128576) due to now unused lambda `function_name_from_load_address`. This warning causes build failures when treating warnings as errors. This change expands the comment to also include the definition of this lambda, fixing the warning.

Error:
```
[3809/6000] Building CXX object tools/lldb/source/Plugins/TraceExporter/common/CMakeFiles/lldbPluginTraceExporterCommon.dir/TraceHTR.cpp.o
FAILED: tools/lldb/source/Plugins/TraceExporter/common/CMakeFiles/lldbPluginTraceExporterCommon.dir/TraceHTR.cpp.o
/usr/bin/clang++ -DHAVE_ROUND -DLLDB_CONFIGURATION_DEBUG -D_DEBUG -D_GNU_SOURCE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -I/__w/1/b/llvm/Debug/tools/lldb/source/Plugins/TraceExporter/common -I/__w/1/llvm-project/lldb/source/Plugins/TraceExporter/common -I/__w/1/llvm-project/lldb/include -I/__w/1/b/llvm/Debug/tools/lldb/include -I/__w/1/b/llvm/Debug/include -I/__w/1/llvm-project/llvm/include -I/__w/1/llvm-project/llvm/../clang/include -I/__w/1/b/llvm/Debug/tools/lldb/../clang/include -I/__w/1/llvm-project/lldb/source -I/__w/1/b/llvm/Debug/tools/lldb/source -isystem /usr/include/libxml2 -fPIC -fvisibility-inlines-hidden -Werror -Werror=date-time -Werror=unguarded-availability-new -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wmissing-field-initializers -pedantic -Wno-long-long -Wc++98-compat-extra-semi -Wimplicit-fallthrough -Wcovered-switch-default -Wno-noexcept-type -Wnon-virtual-dtor -Wdelete-non-virtual-dtor -Wsuggest-override -Wstring-conversion -Wmisleading-indentation -fdiagnostics-color -Wno-deprecated-declarations -Wno-unknown-pragmas -Wno-strict-aliasing -Wno-deprecated-register -Wno-vla-extension -g  -fno-exceptions -gsplit-dwarf -std=c++14 -MD -MT tools/lldb/source/Plugins/TraceExporter/common/CMakeFiles/lldbPluginTraceExporterCommon.dir/TraceHTR.cpp.o -MF tools/lldb/source/Plugins/TraceExporter/common/CMakeFiles/lldbPluginTraceExporterCommon.dir/TraceHTR.cpp.o.d -o tools/lldb/source/Plugins/TraceExporter/common/CMakeFiles/lldbPluginTraceExporterCommon.dir/TraceHTR.cpp.o -c /__w/1/llvm-project/lldb/source/Plugins/TraceExporter/common/TraceHTR.cpp
/__w/1/llvm-project/lldb/source/Plugins/TraceExporter/common/TraceHTR.cpp:136:8: error: unused variable 'function_name_from_load_address' [-Werror,-Wunused-variable]
  auto function_name_from_load_address =
```

Reviewed By: wallace

Differential Revision: https://reviews.llvm.org/D128874
2022-06-29 21:29:50 -07:00
Daniel Bertalan a3f67f0920 [lld-macho] Initial support for Linker Optimization Hints
Linker optimization hints mark a sequence of instructions used for
synthesizing an address, like ADRP+ADD. If the referenced symbol ends up
close enough, it can be replaced by a faster sequence of instructions
like ADR+NOP.

This commit adds support for 2 of the 7 defined ARM64 optimization
hints:
- LOH_ARM64_ADRP_ADD, which transforms a pair of ADRP+ADD into ADR+NOP
  if the referenced address is within +/- 1 MiB
- LOH_ARM64_ADRP_ADRP, which transforms two ADRP instructions into
  ADR+NOP if they reference the same page

These two kinds already cover more than 50% of all LOHs in
chromium_framework.

Differential Review: https://reviews.llvm.org/D128093
2022-06-30 06:28:42 +02:00
Keegan Saunders fd6b9074ca [MC] Skip lower-case integer suffixes
`mov x0, 1024u` is permitted in binutils but rejected by the integrated
assembler. Support the case. This is especially important when using the C
pre-processor with the assembler: some shared code between C and assembler may
use lower-cased suffices.

Reviewed By: MaskRay

Differential Revision: https://reviews.llvm.org/D128871
2022-06-29 20:55:05 -07:00
Chuanqi Xu 7a567c60f2 [Coroutines] Add REQUIRES clause to skip unsupported targets 2022-06-30 11:37:41 +08:00
Petr Hosek 75113f3539 [Driver] Always use --as-needed with libunwind
With libgcc, we follow the behavior of GCC for backwards compatibility,
only using --as-needed in the non-C++ mode.

With libunwind, there are no backward compatibility requirements so we
can always use --as-needed on all supported platforms.

Differential Revision: https://reviews.llvm.org/D128841
2022-06-30 03:33:40 +00:00
Chuanqi Xu 0b5ead6590 [WebAssembly] Don't set musttail for coroutines when tail-call is not
enabled

The C++20 Coroutines couldn't be compiled to WebAssembly due to an
optimization named symmetric transfer requires the support for musttail
calls but WebAssembly doesn't support it yet.

This patch tries to fix the problem by adding a supportsTailCalls
method to TargetTransformImpl to skip the symmetric transfer when
tail-call feature is not supported.

Reviewed By: tlively

Differential Revision: https://reviews.llvm.org/D128794
2022-06-30 11:15:40 +08:00
Luo, Yuanke fa8656d28d [greedyalloc] Return early when there is no register to allocate.
In X86 we split greddy register allocation into 2 passes. The 1st pass
is to allocate tile register, and the 2nd pass is to allocate the rest
of virtual register. In most cases there is no tile register, so the 1st
pass is unnecessary. To improve the compiling time, we check if there is
any register need to be allocated by invoking callback
`ShouldAllocateClass`. If there is no register to be allocated, just
return false in the pass. This would improve the 1st greed RA pass for
normal cases.

Differential Revision: https://reviews.llvm.org/D128804
2022-06-30 11:12:05 +08:00
Kito Cheng 1b8cde9b63 [RISCV][NFC] Move static global variables into static variable in function.
It's violate coding guideline in LLVM coding standard[1], because the  the initialization order is nondeterministic and that might increase the launch time of programs.

However these variables are only used to cache query result, so we can move these variables into the function,, that which resolve both issue: 1. initialized in deterministic order, 2. Initialized that when the first time used.

[1] https://llvm.org/docs/CodingStandards.html#do-not-use-static-constructors

Reviewed By: MaskRay

Differential Revision: https://reviews.llvm.org/D128726
2022-06-30 10:30:01 +08:00
Fangrui Song 9a572164d5 [ELF] Move InputFiles global variables (memoryBuffers, objectFiles, etc) into Ctx. NFC 2022-06-29 18:53:38 -07:00
zhongyunde 404479b4b0 [InstCombine] Use known bits to determine exact int->fp cast
Reviewed By: spatel, nikic

Differential Revision: https://reviews.llvm.org/D127854
2022-06-30 09:45:11 +08:00
Daniel Müller 70557eb393 [clang][BPF] Update comment to include TYPE_MATCH
D126838 added support for the TYPE_MATCH compile-once run-everywhere
relocation to LLVM proper. On the clang side no changes are necessary,
other than the adjustment of a comment to mention this relocation as well.
This change takes care of that.

Differential Revision: https://reviews.llvm.org/D126839
2022-06-29 18:32:06 -07:00
Aart Bik e057f25dee [mlir][sparse] auto-insertion of conversion to resolve cycles
When the iteration graph is cyclic (even after several attempts using less and less constraints), the current sparse compiler bails out, and no rewriting hapens. However, this revision adds some new logic where the sparse compiler tries to find a single input sparse tensor that breaks the cycle, and then adds a proper sparse conversion operation. This way, more incoming kernels can be handled!

Note, the resulting code is not optimal (although it keeps more or less proper "sparse" complexity), and more improvements should be added (especially when the kernel directly yields without computation, such as the transpose example). However, handling is better than not handling ;-)

Reviewed By: bixia

Differential Revision: https://reviews.llvm.org/D128847
2022-06-29 18:28:18 -07:00
Daniel Müller d129ac27e8 [BPF] Introduce support for type match relocations
Among others, BPF currently supports the type-exists CO-RE relocation
(e.g., see D83878 & D83242). Its intention, as the name tries to convey,
is to be used for checking existence of a type in a target.
While that check is useful and has its place, we would also like to
be able to perform stricter type queries: instead of just checking mere
existence, we want to make sure that members match up in composite
types, that enum variants are present, etc. We refer to this as "type
match".

This change proposes the addition of a new relocation variant/value that
we intend to use for establishing this match relation.

Differential Revision: https://reviews.llvm.org/D126838
2022-06-29 18:23:08 -07:00
Vitaly Buka 72cd6b6c83 Revert "[Debuginfo][DWARF][NFC] Refactor DwarfStringPoolEntryRef."
Breaks msan bot, see D126883

This reverts commit 77df3be0de.
2022-06-29 17:53:42 -07:00
Fangrui Song e980f16d52 [ELF] Move whyExtract/backwardReferences from LinkerDriver to Ctx. NFC
Ctx was recently added as a more suitable place for such singletons.
2022-06-29 17:34:31 -07:00
Zequan Wu bd2044c108 [CodeView] Call llvm::codeview::visitMemberRecordStream with the deserialized CVType whose kind is FieldListRecord.
llvm::codeview::visitMemberRecordStream expects to receive an array ref that's FieldListRecord's Data not a CVType's data which has 4 more bytes preceeding. The first 2 bytes indicate the size of the FieldListRecord, and following 2 bytes is always 0x1203. Inside llvm::codeview::visitMemberRecordStream, it iterates to the data to check if first two bytes matching some type record kinds. If the size coincidentally matches one type kind, it will start parsing from there and causing crash.
2022-06-29 17:18:56 -07:00
Christian Kandeler c09e533374 [clangd] Also mark output arguments of operator call expressions
There's no reason that arguments to e.g. lambda calls should be treated
differently than those to "real" functions.

Reviewed By: nridge

Differential Revision: https://reviews.llvm.org/D128329
2022-06-29 20:12:37 -04:00
Jonas Devlieghere 1b8c73522e
[lldb] Use assertState in even more tests (NFC)
Followup to D127355 and D127378, converting more instances of
assertEqual to assertState.
2022-06-29 17:05:58 -07:00
Amir Ayupov 798e92c6c4 [BOLT] Respect shouldPrint in dump-dot-all
Don't dump dot CFG graph for functions that should not be printed.

Reviewed By: rafauler, maksfb

Differential Revision: https://reviews.llvm.org/D128699
2022-06-29 17:01:17 -07:00
Jonas Devlieghere dee672ee85
[lldb] Skip instead of XFAIL TestGdbRemote_vContThreads on Darwin
The two XFAILed tests started timing out after D126983. Given that they
were XFAILed anyway I didn't investigate and just skipped them.
2022-06-29 16:34:34 -07:00
Argyrios Kyrtzidis c68b8c84eb [Lex] Make sure to notify `MultipleIncludeOpt` for "read tokens" during fast dependency directive lexing
Otherwise a header may be erroneously marked as having a header macro guard and won't get re-included.

Differential Revision: https://reviews.llvm.org/D128772
2022-06-29 15:50:16 -07:00
Michael Kruse 6fa65f8a98 [Polly][MatMul] Abandon dependence analysis.
The copy statements inserted by the matrix-multiplication optimization
introduce new dependencies between the copy statements and other
statements. As a result, the DependenceInfo must be recomputed.

Not recomputing them caused IslAstInfo to deduce that some loops are
parallel but cause race conditions when accessing the packed arrays.
As a result, matrix-matrix multiplication currently cannot be
parallelized.

Also see discussion at https://reviews.llvm.org/D125202
2022-06-29 17:20:05 -05:00
Jonas Devlieghere 3944780dd8
[lldb] Skip TestAppleSimulatorOSType is simulator isn't available
Skip TestAppleSimulatorOSType is simulator isn't available for the given
platform.
2022-06-29 15:10:16 -07:00
Jonas Devlieghere 65a7ebff33
[lldb] XFAIL TestVSCode_breakpointEvents.py on Ventura
TestVSCode_breakpointEvents.py is failing on macOS Ventura because we
receive 3 breakpoint events instead of one. This is likely the result of
dyld moving into the shared cache.
2022-06-29 15:00:57 -07:00
Volodymyr Sapsai 3514131219 [ODRHash diagnostics] Fix typos. NFC. 2022-06-29 14:59:37 -07:00
Jin Xin Ng f702c7bb9e
[ThinLTO][test] Add tests for emitting files in-process
Completes D127777 by adding llvm-side tests for emitting index and imports files from in-process ThinLTO

Differential Revision: https://reviews.llvm.org/D128771
2022-06-29 14:42:45 -07:00
Petr Hosek ff093c0a5d Revert "[Driver] Always use --as-needed with libunwind"
This reverts commit 2483b3a9679ed2d92abbdbae6927e022903acc70 since
it broke clang-armv7-vfpv3-full-2stage builder:

  https://lab.llvm.org/buildbot#builders/190/builds/887
2022-06-29 21:41:47 +00:00
Maksim Panchenko ed74304506 [BOLT] Fix EH trampoline backout code
When SplitFunctions pass adds a trampoline code for exception landing
pads (limited to shared objects), it may increase the size of the hot
fragment making it larger than the whole function pre-split. When this
happens, the pass reverts the splitting action by restoring the original
block order and marking all blocks hot.

However, if createEHTrampolines() added new blocks to the CFG and
modified invoke instructions, simply restoring the original block layout
will not suffice as the new CFG has more blocks.

For proper backout of the split, modify the original layout by merging
in trampoline blocks immediately before their matching targets. As a
result, the number of blocks increases, but the number of instructions
and the function size remains the same as pre-split.

Add an assertion for the number of blocks when updating a function
layout.

Reviewed By: rafauler

Differential Revision: https://reviews.llvm.org/D128696
2022-06-29 14:35:57 -07:00