Commit Graph

442179 Commits

Author SHA1 Message Date
Emmmer 4113e98ea7 [LLDB][RISCV] Allow accessing registers through ABI names
This patch uses RISCV ABI register name as `alt_name` in `RegisterInfo` in `lldb-private-types.h`

Reviewed By: DavidSpickett

Differential Revision: https://reviews.llvm.org/D137508
2022-11-17 19:39:06 +08:00
Timm Bäder ec782951d7 [clang] Short-circuit evaluation in ::EvaluateAsConstantExpr
Use FastEvaluateAsRValue() in EvaluateAsConstantExpr() as well, to
short-circuit evaluation of simple integrals.

Differential Revision: https://reviews.llvm.org/D138115
2022-11-17 12:01:37 +01:00
Uday Bondhugula 303d14f33d [MLIR] NFC. Fix unused context warning from Parser.h
NFC. Fix unused context warning from Parser.h.

```
..include/mlir/Parser/Parser.h:39:38: warning: parameter ‘context’ set but not used [-Wunused-but-set-parameter]
   39 |     Block *parsedBlock, MLIRContext *context, Location sourceFileLoc) {
```

Differential Revision: https://reviews.llvm.org/D138192
2022-11-17 16:03:09 +05:30
Anton Sidorenko b6c790736e [MachineCombiner][RISCV] Add fmadd/fmsub/fnmsub instructions patterns
This patch adds tranformation of fmul+fadd/fsub chains to fused multiply
instructions:
  * fmul+fadd->fmadd
  * fmul+fsub->fmsub/fnmsub

We also will try to combine these instructions if the fmul has more than one use
and cannot be deleted. However, removing the dependence between fmul and fadd can
still be profitable, and we rely on machine combiner approximations of scheduling.

Differential Revision: https://reviews.llvm.org/D136764
2022-11-17 13:24:04 +03:00
Evgeniy Brevnov 50f8eb05af Revert "[JT] Preserve exisiting BPI/BFI during JumpThreading"
This reverts commit 52a4018506.
2022-11-17 17:11:47 +07:00
Evgeniy Brevnov 52a4018506 [JT] Preserve exisiting BPI/BFI during JumpThreading
Currently, JT creates and updates local instances of BPI\BFI. As a result global ones have to be invalidated if JT made any changes.
In fact, JT doesn't use any information from BPI/BFI for the sake of the transformation itself. It only creates BPI/BFI to keep them up to date. But since it updates local copies (besides cases when it updates profile metadata) it just waste of time.

Current patch is a rework of D124439. D124439 makes one step and replaces local copies with global ones retrieved through AnalysisPassManager. Here we do one more step and don't create BPI/BFI if the only reason of creation is to keep BPI/BFI up to date. Overall logic is the following. If there is cached BPI/BFI then update it along the transformations. If there is no existing BPI/BFI, then create it only if it is required to update profile metadata.

Please note if BPI/BFI exists on exit from JT (either cached or created) it is always up to date and no reason to invalidate it.

Differential Revision: https://reviews.llvm.org/D136827
2022-11-17 17:00:00 +07:00
Valentin Clement 6393d2ea24
[flang] Create fir.dispatch_table and fir.dt_entry operations
Create the fir.dispatch_table operation based on semantics
information. The fir.dispatch_table will be used for static devirtualization
as well as for fir.select_type conversion.

Depends on D138129

Reviewed By: jeanPerier, PeteSteinfeld

Differential Revision: https://reviews.llvm.org/D138131
2022-11-17 10:53:43 +01:00
Valentin Clement ded52a44d0
[flang] Make CollectBindings available to lowering
Reviewed By: jeanPerier, PeteSteinfeld

Differential Revision: https://reviews.llvm.org/D138129
2022-11-17 10:46:15 +01:00
Jay Foad 898b18844c [AMDGPU] Add GFX11 to some tests with manual checks
Differential Revision: https://reviews.llvm.org/D138138
2022-11-17 09:42:28 +00:00
Tobias Gysi 2c9d264785 [mlir][llvm] Move call and gep LLVM IR import tests.
The revision moves call and gep tests to instructions.ll.

Reviewed By: ftynse

Differential Revision: https://reviews.llvm.org/D137636
2022-11-17 10:41:07 +01:00
Emilia Dreamer 48a932e13e
[clang-format] Remove special case for kw_operator when aligning decls
This change breaks no existing tests but does fix the linked issue.
Declarations of operator overloads are annotated with
`TT_FunctionDeclarationName` on the `operator` keyword, which is already
being checked for when aligning, so the extra `kw_operator` doesn't seem
to be necessary. (just for reference, it was added in
rG92b397fb9d55ccdf4632c2b1b15b4a0ee417cf74 / 92b397fb9d)

Fixes https://github.com/llvm/llvm-project/issues/55733

Reviewed By: HazardyKnusperkeks, owenpan

Differential Revision: https://reviews.llvm.org/D137223
2022-11-17 11:38:28 +02:00
Emilia Dreamer df6f4b8513
[clang-format] Defer formatting of operator< to honor paren spacing
I'm not exactly sure what the intent of that section of
`spaceRequiredBetween` is doing, it seems to handle templates and <<,
but the part which adds spaces before parens is way later, as part
of `spaceRequiredBeforeParens`.

Fixes https://github.com/llvm/llvm-project/issues/58821

Reviewed By: HazardyKnusperkeks, owenpan, MyDeveloperDay

Differential Revision: https://reviews.llvm.org/D137474
2022-11-17 11:38:21 +02:00
Aliia Khasanova 9729b6930b [mlir] Make kDynamicSize equal to kDynamicOffsetAndStride.
Differential Revision: https://reviews.llvm.org/D134807
2022-11-17 09:36:03 +00:00
Tobias Gysi 2920095d41 [mlir][llvm] Consolidate function attribute import tests (NFC).
The revision puts the function attributes tests previously distributed
accross multiple files int a single function-attributes.ll test file.

Reviewed By: ftynse

Differential Revision: https://reviews.llvm.org/D137627
2022-11-17 10:28:02 +01:00
Tobias Gysi 356f41705d [mlir][llvm] Test LLVM IR global variable import separately (NFC).
The revision moves tests related to LLVM IR global variable
import into a separate global-variables.ll file.

Reviewed By: ftynse

Differential Revision: https://reviews.llvm.org/D137622
2022-11-17 10:26:15 +01:00
Sinan Lin 2caf1de1b8 Fix broken CI
The test case introduced in https://reviews.llvm.org/D137535 does not
set a proper triple, which breaks CI from ppc/x86win/nvptx64. Hope this
patch can fix the issue.

Reviewed By: arsenm

Differential Revision: https://reviews.llvm.org/D138188
2022-11-17 17:22:52 +08:00
Anton Sidorenko 374d076563 [MachineCombiner][RISCV] Precommit tests for D136764 2022-11-17 12:12:46 +03:00
Matt Jacobson 2d0a2e334e In ChangePrinters tests, redirect stderr of `diff --help` to stdout
FreeBSD's diff writes its `--help` to stderr.
2022-11-17 04:06:17 -05:00
Jay Foad 96a661de4b [GlobalISel] Better verification of G_UNMERGE_VALUES
Verify three cases of G_UNMERGE_VALUES separately:

1. Splitting a vector into subvectors (the converse of
   G_CONCAT_VECTORS).
2. Splitting a vector into its elements (the converse of
   G_BUILD_VECTOR).
3. Splitting a scalar into smaller scalars (the converse of
   G_MERGE_VALUES).

Previously #1 allowed strange combinations like this:
  %1:_(<2 x s16>),%2:_(<2 x s16>) = G_UNMERGE_VALUES %0(<2 x s32>)
This has been tightened up to check that the source and destination
element types match, and some MIR test cases updated accordingly.

Differential Revision: https://reviews.llvm.org/D111132
2022-11-17 08:19:57 +00:00
Muhammad Omair Javaid 38d6202a42 Revert "[lld-macho] Overhaul map file code"
This reverts commit 213dbdbef0.
This patch series breaks lld:map-file.s on arm v7 linux buildbots.
e.g https://lab.llvm.org/buildbot/#/builders/178/builds/3190
2022-11-17 12:13:13 +04:00
Muhammad Omair Javaid ac3096e1dd Revert "[lld-macho] Emit map file entry for compact unwind info"
This reverts commit 7f0779967f.
This patch series breaks lld:map-file.s on arm v7 linux buildbots.
e.g https://lab.llvm.org/buildbot/#/builders/178/builds/3190
2022-11-17 12:13:13 +04:00
Muhammad Omair Javaid e2c868fbf7 Revert "[lld-macho] Fix bugs around EH_Frame symbols"
This reverts commit 1a2bc103bb.
This patch series breaks lld:map-file.s on arm v7 linux buildbots.
e.g https://lab.llvm.org/buildbot/#/builders/178/builds/3190
2022-11-17 12:13:13 +04:00
Fangrui Song 3ea86a13f4 [Sink] Add a single successor test 2022-11-17 00:12:42 -08:00
Matt Arsenault ba1669c81f ValueTracking: Look through fabs and fneg in isKnownNeverInfinity 2022-11-17 00:06:15 -08:00
Matt Arsenault d24fe812ec ValueTracking: Look through canonicalize in isKnownNeverInfinity 2022-11-17 00:06:15 -08:00
Che-Yu Wu 4fdf624b78 Increase the limit of SCF nested tiling loop to 10
Differential Revision: https://reviews.llvm.org/D138156
2022-11-17 08:00:21 +00:00
Vladislav Khmelevsky 750d17bb72 [BOLT][runtime] Change fPIE flag to fPIC
Since instrumentation could be used on libraries we need to use fPIC,
not fPIE flag.

Differential Revision: https://reviews.llvm.org/D138099
2022-11-17 11:50:43 +04:00
Sinan Lin 4ad8952d2d [CodeGen][BasicBlockSections] Fix wrong alignment directive placement in
basic block section cases

MachineBlockPlacement pass sets an alignment attribute to the loop
header MBB and this attribute will lead to an alignment directive during
emitting asm. In the case of the basic block section, the alignment
directive is put before the section label, and thus the alignment is set
to the predecessor of the loop header, which is not what we expect and
increases the code size (both inserting nop and set section alignment).

Reviewed By: rahmanl

Differential Revision: https://reviews.llvm.org/D137535
2022-11-17 15:01:57 +08:00
Vitaly Buka 605355f0dc [NFC][asan] Reformat macro 2022-11-16 22:45:08 -08:00
Vitaly Buka e7376adbea [NFC][asan] clang-format the test 2022-11-16 22:45:08 -08:00
Vitaly Buka 38b5a37082 [NFC][asan] format __sanitizer_annotate_contiguous_container 2022-11-16 22:45:08 -08:00
Chi Chun Chen 6d076780a8 [OpenMP][NFC] Claim thread_limit clause in target directive 2022-11-17 00:44:44 -06:00
Carlos Alberto Enciso d896ea75c5 [llvm-debuginfo-analyzer] Return by reference instead of value.
The following functions are used in the unittest, to access
invalid data detected by the Reader during the debug information
analysis:

- getDebugTags
- getWarningOffsets
- getInvalidLocations
- getInvalidCoverages
- getInvalidRanges
- getLinesZero

Just return a reference to the container with the information.

Reviewed By: dblaikie

Differential Revision: https://reviews.llvm.org/D138092
2022-11-17 06:30:56 +00:00
Mehdi Amini 5060abb6d3 Apply clang-tidy fixes for readability-identifier-naming in StandaloneExtension.cpp (NFC) 2022-11-17 06:23:30 +00:00
Fangrui Song 12050a3fb7 [LTO] Make local linkage GlobalValue in non-prevailing COMDAT available_externally
For a local linkage GlobalObject in a non-prevailing COMDAT, it remains defined while its
leader has been made available_externally. This violates the COMDAT rule that
its members must be retained or discarded as a unit.

To fix this, update the regular LTO change D34803 to track local linkage
GlobalValues, and port the code to ThinLTO (GlobalAliases are not handled.)

This fixes two problems.

(a) `__cxx_global_var_init` in a non-prevailing COMDAT group used to
linger around (unreferenced, hence benign), and is now correctly discarded.
```
int foo();
inline int v = foo();
```

(b) Fix https://github.com/llvm/llvm-project/issues/58215:
as a size optimization, we place private `__profd_` in a COMDAT with a
`__profc_` key. When FuncImport.cpp makes `__profc_` available_externally due to
a non-prevailing COMDAT, `__profd_` incorrectly remains private. This change
makes the `__profd_` available_externally.

```
cat > c.h <<'eof'
extern void bar();
inline __attribute__((noinline)) void foo() {}
eof
cat > m1.cc <<'eof'
#include "c.h"
int main() {
  bar();
  foo();
}
eof
cat > m2.cc <<'eof'
#include "c.h"
__attribute__((noinline)) void bar() {
  foo();
}
eof

clang -O2 -fprofile-generate=./t m1.cc m2.cc -flto -fuse-ld=lld -o t_gen
rm -fr t && ./t_gen && llvm-profdata show -function=foo t/default_*.profraw

clang -O2 -fprofile-generate=./t m1.cc m2.cc -flto=thin -fuse-ld=lld -o t_gen
rm -fr t && ./t_gen && llvm-profdata show -function=foo t/default_*.profraw
```

If a GlobalAlias references a GlobalValue which is just changed to
available_externally, change the GlobalAlias as well (e.g. C5/D5 comdats due to
cc1 -mconstructor-aliases). The GlobalAlias may be referenced by other
available_externally functions, so it cannot easily be removed.

Depends on D137441: we use available_externally to mark a GlobalAlias in a
non-prevailing COMDAT, similar to how we handle GlobalVariable/Function.
GlobalAlias may refer to a ConstantExpr, not changing GlobalAlias to
GlobalVariable gives flexibility for future extensions (the use case is niche.
For simplicity we don't handle it yet). In addition, available_externally
GlobalAlias is the most straightforward implementation and retains the aliasee
information to help optimizers.

See windows-vftable.ll: Windows vftable uses an alias pointing to a
private constant where the alias is the COMDAT leader. The COMDAT use case
is skeptical and ThinLTO does not discard the alias in the non-prevailing COMDAT.
This patch retains the behavior.

See new tests ctor-dtor-alias2.ll: depending on whether the complete object
destructor emitted, when ctor/dtor aliases are used, we may see D0/D2 COMDATs in
one TU and D0/D1/D2 in a D5 COMDAT in another TU.
Allow such a mix-and-match with `if (GO->getComdat()->getName() == GO->getName()) NonPrevailingComdats.insert(GO->getComdat());`

GlobalAlias handling in ThinLTO is still weird, but this patch should hopefully
improve the situation for at least all cases I can think of.

Reviewed By: tejohnson

Differential Revision: https://reviews.llvm.org/D135427
2022-11-16 22:13:22 -08:00
Fangrui Song 2c239da691 Revert D135427 "[LTO] Make local linkage GlobalValue in non-prevailing COMDAT available_externally"
This reverts commit 8901635423.

This change broke the following example and we need to check `if (GO->getComdat()->getName() == GO->getName())`
before `NonPrevailingComdats.insert(GO->getComdat());`
Revert for clarify.

```
// a.cc
template <typename T>
struct A final { virtual ~A() {} };
extern "C" void aa() { A<int> a; }
// b.cc
template <typename T>
struct A final { virtual ~A() {} };
template struct A<int>;
extern "C" void bb(A<int> *a) { delete a; }

clang -c -fpic -O0 -flto=thin a.cc && ld.lld -shared a.o b.o
```
2022-11-16 21:43:50 -08:00
Matt Jacobson bbe6bd724a Trivial fix to failing test on FreeBSD
This file can't use C99-style comments.
2022-11-17 00:20:23 -05:00
Serge Pavlov 1ddd586308 [clang] Missed rounding mode use in constant evaluation
Integer-to-float conversion was handled in constant evaluator with
default rounding mode. This change fixes the behavior and the conversion
is made using rounding mode stored in ImplicitCastExpr node.

Differential Revision: https://reviews.llvm.org/D137719
2022-11-17 12:05:28 +07:00
Yashwant Singh 2652db4d68 Handling ADD|SUB U64 decomposed Pseudos not getting lowered to SDWA form
This patch fixes some of the V_ADD/SUB_U64_PSEUDO not getting converted to their sdwa form.
We still get below patterns in generated code:
v_and_b32_e32 v0, 0xff, v0
v_add_co_u32_e32 v0, vcc, v1, v0
v_addc_co_u32_e64 v1, s[0:1], 0, 0, vcc

and,
v_and_b32_e32 v2, 0xff, v2
v_add_co_u32_e32 v0, vcc, v0, v2
v_addc_co_u32_e32 v1, vcc, 0, v1, vcc

1st and 2nd instructions of both above examples should have been folded into sdwa add with BYTE_0 src operand.

The reason being the pseudo instruction is broken down into VOP3 instruction pair of V_ADD_CO_U32_e64 and V_ADDC_U32_e64.
The sdwa pass attempts lowering them to their VOP2 form before converting them into sdwa instructions. However V_ADDC_U32_e64
cannot be shrunk to it's VOP2 form if it has non-reg src1 operand.
This change attempts to fix that problem by only shrinking V_ADD_CO_U32_e64 instruction.

Reviewed By: arsenm

Differential Revision: https://reviews.llvm.org/D136663
2022-11-17 10:01:40 +05:30
WANG Xuerui cc07185a68 [BinaryFormat] Add LoongArch
Reviewed By: MaskRay

Differential Revision: https://reviews.llvm.org/D138018
2022-11-17 12:00:48 +08:00
zhanglimin db8a96731f [OpenMP] kmp_affinity.h: add LoongArch64 support
In D135552 the #else is added, which causes build error when
building openmp on LoongArch. This patch fixed the error:
      "Unknown or unsupported architecture"

Reviewed By: SixWeining, MaskRay

Differential Revision: https://reviews.llvm.org/D137604
2022-11-17 11:59:00 +08:00
Youling Tang 4ae3e13c7d [sanitizer] Add ptrace interceptor support for LoongArch
Add ptrace interceptor support for LoongArch, `ptrace.cpp` has been
tested and passed.

Reviewed By: SixWeining

Differential Revision: https://reviews.llvm.org/D137228
2022-11-17 11:57:32 +08:00
Alex Brachet 925eaeb3f4 Revert "[CMake] Drop libLTO and switch to PIE for Fuchsia toolchain"
This reverts commit a6f621b8ca.

We suspect that this patch might be the culprit that is causing
every llvm executable to be sigkill'd immediately on Apple Silicon
machines. Notably, the only other cache file with CMAKE_POSITION_INDEPENDENT_CODE
is Apple's and they have it off.
2022-11-17 03:37:58 +00:00
Mike Hommey ff111a997f [lld-macho] Increase slop to prevent thunk out of range again.
Building Firefox with -O0 on arm64 mac recently hit the
"FIXME: thunk range overrun" error on multiple occasions.

Doubling or tripling slop was not sufficient in some cases, so
quadruple it.

Reviewed By: #lld-macho, int3

Differential Revision: https://reviews.llvm.org/D138174
2022-11-16 22:11:54 -05:00
Craig Topper 7e15ea102f [RISCV] Add a DAG combine to pre-promote (i1 (truncate (i32 (srl X, Y)))) with Zbs on RV64.
Type legalization will want to turn (srl X, Y) into RISCVISD::SRLW,
which will prevent us from using a BEXT instruction.

This is similar to what we do for (i32 (and (srl X, Y), 1)).
2022-11-16 19:07:33 -08:00
Joshua Batista 083d949f38 [HLSL] add sin library function
This change exposes the sin library function for HLSL,
excluding long, int, and long long doubles.
Sin is supported for all scalar, vector, and matrix types.

Long and long long double support is missing in this patch because those types
don't exist in HLSL. Int is missing because the sin function only works on floating type arguments.

The full documentation of the HLSL sin function is available here:
https://docs.microsoft.com/en-us/windows/win32/direct3dhlsl/dx-graphics-hlsl-sin

Reviewed By: python3kgae

Differential Revision: https://reviews.llvm.org/D138161
2022-11-16 18:29:50 -08:00
Koakuma fd0aeaa83a [SPARC] Don't emit deprecated FP branches when targeting v9
Don't emit deprecated v8-style FP compares & branches when targeting v9
processors.

For now, always use %fcc0, because currently the allocator requires allocatable
registers to also be spillable, which isn't the case with v9 FCC registers.

The work to enable allocation over the entire FCC register file will be done in
a future patch.

Fixes bug #17834

Reviewed By: arsenm

Differential Revision: https://reviews.llvm.org/D135515
2022-11-16 20:56:17 -05:00
Koakuma 586d5f91e6 [SPARC] Improve integer branch handling for v9 targets
Do not emit deprecated v8-style branches when targeting a v9 processor.

As a side effect, this also fixes the emission of useless ba's when doing
conditional branches on 64-bit integer values.

Reviewed By: arsenm

Differential Revision: https://reviews.llvm.org/D130006
2022-11-16 20:51:20 -05:00
wren romano c3082e2ca2 [mlir][sparse] Adding wrapper for `__has_builtin`
This is a followup to D138154 and should resolve build issues on Windows.

Reviewed By: aartbik

Differential Revision: https://reviews.llvm.org/D138167
2022-11-16 17:46:42 -08:00
gonglingqin 825547247a [LoongArch] Eliminate extra un-accounted-for successors
Specifically:
```
*** Bad machine code: MBB has unexpected successors which are not branch targets, fallthrough, EHPads, or inlineasm_br targets. ***
- function:    atomicrmw_umax_i8_acquire
- basic block: %bb.3  (0x1b90bd8)

*** Bad machine code: Non-terminator instruction after the first terminator ***
- function:    atomicrmw_umax_i8_acquire
- basic block: %bb.3  (0x1b90bd8)
- instruction: DBAR 1792
```

Differential Revision: https://reviews.llvm.org/D137884
2022-11-17 09:44:59 +08:00