508916 Commits

Author SHA1 Message Date
David Spickett
08201cb424 [lldb][test] Fix GCC warnings in TestGetControlFlowKindX86.cpp
```
<...>/TestGetControlFlowKindx86.cpp:148:8: warning: suggest explicit braces to avoid ambiguous ‘else’ [-Wdangling-else]
  148 |     if (kind == eInstructionControlFlowKindReturn)
      |        ^
```

Usually llvm is a "no braces for single line body" project but
for whatever reason gcc objects to it here. Perhaps because it's
within a for loop.

Added the newlines just for readability.
2024-08-19 16:35:47 +01:00
Akshat Oke
576aa3a509
[TableGen] Resolve References at top level (#104578)
Add a dummy resolver to resolve references outside records. This invokes
Fold() with isFinal to force resolution.

Fixes #102447

Co-authored-by: Akshat Oke <Akshat.Oke@amd.com>
2024-08-19 21:05:39 +05:30
Wesley Wiser
0abb779161
[LLVM] [X86] Fix integer overflows in frame layout for huge frames (#101840)
Fix 32-bit integer overflows in the X86 target frame layout when dealing
with frames larger than 4gb. When this occurs, we'll scavenge a scratch
register to be able to hold the correct stack offset for frame locals.

This completes reapplying #84114.

Fixes #48911
Fixes #75944 
Fixes #87154
2024-08-19 19:31:20 +04:00
Michael Buch
c7a54bfd1d [lldb][ASTUtils] Remove unused SemaSourceWithPriorities::addSource API
As far as I can tell, this has always been unused. My hunch is that
this was supposed to mimick the `MultiplexExternalSemaSource::AddSource`
API which `SemaSourceWithPriorities` is based on.
2024-08-19 16:19:44 +01:00
David Spickett
b1d75fe48c [lldb][test] Fix cast dropping const warnin in TestBreakpointSetCallback.cpp
When building with gcc I get this warning:
```
<...>TestBreakpointSetCallback.cpp:58:25: warning: cast from type ‘const char*’ to type ‘void*’ casts away qualifiers [-Wcast-qual]
   58 |   void *baton = (void *)"hello";
      |                         ^~~~~~~
```

Use the address of a mutable global variable instead. All we care about
is that the address passed as the baton is the same one we get later.
2024-08-19 15:16:04 +00:00
Nikita Popov
b64e7e07e5 [SimplifyCFG] Add tests for hoisting of commutative instructions (NFC) 2024-08-19 17:13:21 +02:00
Christudasan Devadasan
a449b85724
[AMDGPU][R600] Move R600CodeGenPassBuilder into R600TargetMachine(NFC). (#103721) 2024-08-19 20:40:12 +05:30
Daniel Grumberg
b18b4547f1 Revert "[clang][ExtractAPI] Stop dropping fields of nested anonymous record types when they aren't attached to variable declaration (#104600)"
This reverts commit c60da1a271a6bb271e7703b2f7c71fbece67ab78.
2024-08-19 16:06:43 +01:00
Ramkumar Ramachandra
7dd6340bda
MathExtras: template'ize alignToPowerOf2 (#97814)
Follow up on 5627794 (MathExtras: avoid unnecessarily widening types) to
change the overflow behavior of alignToPowerOf2 to only overflow if the
result is not representable in the return type. This allows us to
template'ize it, and avoid unnecessarily widening the types of
arguments.
2024-08-19 16:03:42 +01:00
Christudasan Devadasan
a566635915
[AMDGPU] Move AMDGPUCodeGenPassBuilder into AMDGPUTargetMachine(NFC) (#103720)
This will allow us to reuse the existing flags and the static
functions while building the pipeline for new pass manager.
2024-08-19 20:32:55 +05:30
Daniel Grumberg
c60da1a271
[clang][ExtractAPI] Stop dropping fields of nested anonymous record types when they aren't attached to variable declaration (#104600)
- Introduce primitives for removing records from `APISet` and managing
the record chain of `RecordContext`
- Detect nested anonymous record types and remove them from the `APISet`
after they have been fully traversed and transfer ownership of child
records to the parent context (if any)
2024-08-19 15:57:43 +01:00
smanna12
79f6ae05c1
[Clang][NFC] Fix potential null dereference in encodeTypeForFunctionPointerAuth (#104737)
This patch replaces getAs with castAs in
encodeTypeForFunctionPointerAuth to prevent dereferencing a potential
null pointer, enhancing type safety as reported by static analyzer tool.
2024-08-19 09:37:06 -05:00
Nikita Popov
4f083c0a2c [DebugInfo] Make tests SimplifyCFG-independent (NFC)
Run SimplifyCFG over the test input and disable the SimplifyCFG
run in the backend, so that these tests are not affected by changes
to SimplifyCFG.
2024-08-19 16:00:46 +02:00
Benjamin Maxwell
ea28668f8c
[mlir][ArmSME] Remove XFAILs (#104758)
Buildbots have been updated to QEMU 9.0.2: 
https://github.com/llvm/llvm-project/pull/104758#issuecomment-2296592845
2024-08-19 14:55:09 +01:00
Michael Maitland
7efa068f7a
[RISCV] Add vector and vector crypto to SiFiveP400 scheduler model (#102155)
The SiFiveP400 scheduler model did not support vector or vector crypto.
With the addition of the sifive-p470 processor, this model needs to support
these extensions.

The processors who use this model but do not have vector or vector
crypto will never produce these instructions, so there is no impact to these
processors.

Co-authored-by: Min Hsu <min.hsu@sifive.com>
2024-08-19 09:41:42 -04:00
Julian Brown
3188e9b4e0
[clang][OpenMP] Diagnose badly-formed collapsed imperfect loop nests (#60678) (#101305)
This patch fixes a couple of cases where Clang aborts with loop nests
that are being collapsed (via the relevant OpenMP clause) into a new,
combined loop.

The problematic cases happen when a variable declared within the loop
nest is used in the (init, condition, iter) statement of a more
deeply-nested loop. I don't think these cases (generally?) fall under
the non-rectangular loop nest rules as defined in OpenMP 5.0+, but I
could be wrong (and anyway, emitting an error is better than crashing).

In terms of implementation: the crash happens because (to a first
approximation) all the loop bounds calculations are pulled out to the
start of the new, combined loop, but variables declared in the loop nest
"haven't been seen yet". I believe there is special handling for
iteration variables declared in "for" init statements, but not for
variables declared elsewhere in the "imperfect" parts of a loop nest.

So, this patch tries to diagnose the troublesome cases before they can
cause a crash. This is slightly awkward because at the point where we
want to do the diagnosis (SemaOpenMP.cpp), we don't have scope
information readily available. Instead we "manually" scan through the
AST of the loop nest looking for var decls (ForVarDeclFinder), then we
ensure we're not using any of those in loop control subexprs
(ForSubExprChecker). All that is only done when we have a "collapse"
clause.

Range-for loops can also cause crashes at present without this patch, so
are handled too.
2024-08-19 09:37:32 -04:00
Hans Wennborg
a567d45987 Require !windows instead of XFAIL'ing ubsan/TestCases/Integer/bit-int.c
The test would unexpectedly pass on Windows when there's 128-bit runtime
routines available. See comment on #104494
2024-08-19 15:34:17 +02:00
Timm Baeder
c6605a0868
[clang][bytecode] Fix member pointers to IndirectFieldDecls (#104756) 2024-08-19 15:28:12 +02:00
David Green
13865b09c6 [AArch64] Add fneg(fmul) and fmul(fneg) tests. NFC 2024-08-19 14:23:39 +01:00
Timm Baeder
3e999bbc2d
[clang][bytecode] Use first FieldDecl instead of asserting (#104760)
This assertion fails sometimes. We use the first decl for lookup later,
so let's use the first decl here as well.
2024-08-19 15:14:44 +02:00
Sergei Barannikov
50daa2397f
[DataLayout] Refactor parsing of i/f/v/a specifications (#104699)
Split off of #104545 to reduce patch size.
2024-08-19 16:09:46 +03:00
Simon Pilgrim
b05c55472b
[X86] LowerABD - simplify i32/i64 to use sub+sub+cmov instead of repeating nodes via abs (#102174)
Using X86ISD::SUB nodes directly allows us to drive the X86ISD::CMOV node with exact flags instead of trying to cleanup the generic codegen via ICMP/SUBO nodes.
2024-08-19 13:50:07 +01:00
Piotr Fusik
0cc6b464f8
[docs] Update a filename, fix indentation (#103018) 2024-08-19 16:39:17 +04:00
Simon Pilgrim
c6e9493a00 [CostModel][X86] Add cost tests for scmp/ucmp intrinsics 2024-08-19 13:35:02 +01:00
tcwzxx
816068e462
[NFC][SLP] Remove useless code of the schedule (#104697)
Currently, the SLP schedule has two containers of `ScheduleData`:
`ExtraScheduleDataMap` and `ScheduleDataMap`. However, the
`ScheduleData` in `ExtraScheduleDataMap` is only used to indicate
whether the instruction is processed or not and does not participate in
the schedule, which is useless. `ScheduleDataMap` is sufficient for this
purpose. The `OpValue` member is used only in `ExtraScheduleDataMap`,
which is also useless.
2024-08-19 20:16:51 +08:00
Florian Hahn
f2fcd9cb97
[VPlan] Rename getBestPlanFor -> getPlanFor (NFC).
As suggested in https://github.com/llvm/llvm-project/pull/103033, more
accurately rename to getPlanFor , as it simplify returns the VPlan for
VF, relying on the fact that there is a single VPlan for each VF at the
moment.
2024-08-19 13:05:19 +01:00
Volodymyr Vasylkun
abf69a167b
[InstCombine] Fold (x < y) ? -1 : zext(x != y) into u/scmp(x,y) (#101049)
This patch adds the aforementioned fold to InstCombine. This pattern is
produced after naive implementations of 3-way comparison in high-level
languages are transformed into LLVM IR and then optimized.

Proofs: https://alive2.llvm.org/ce/z/w4QLq_
2024-08-19 13:02:29 +01:00
Florian Hahn
b8dccb7d56
[VPlan] Emit note when UserVF > MaxUserVF (NFCI).
As suggested in https://github.com/llvm/llvm-project/pull/103033, add a
remark when the UserVF is ignored due to it being larger than MaxUserVF.

Only changes behavior of diagnostic/debug output.
2024-08-19 12:40:20 +01:00
Tim Besard
00def06c6e
[LLVM][NewPM] Add C API for running the pipeline on a single function. (#103773)
By adding a new entrypoint, `LLVMRunPassesOnFunction`, as suggested in
https://discourse.llvm.org/t/newpm-c-api-questions/80598.

Also removes erroneous `LLVMConsumeError`s from the pass builder unit
tests as the string conversion already consumes the error, causing an
abort when the test would fail.
2024-08-19 12:34:23 +02:00
Benjamin Maxwell
74a512df2b
[mlir][vector] Populate sink patterns in apply_patterns.vector.reduction_to_contract (#104754)
This restores the functionality to before:
42944da5ba
This fixes a buildbot failure:
https://lab.llvm.org/buildbot/#/builders/143/builds/1487
2024-08-19 11:20:18 +01:00
David Spickett
cde806b0e6 [lld][MachO] Fix a suspicous assert in SyntheticSections.cpp
This was comparing some .size() (uint64_t) against the sizeof a size_t
which changes with system bitness. This produced a warning that
brought this to my attention.

These tests were failing too on 32 bit Arm only:
  lld :: MachO/objc-category-merging-complete-test.s
  lld :: MachO/objc-category-merging-minimal.s

The assert I think meant to check the value of target->wordSize,
not the size of its type. Which is a type that changes size between
systems.
2024-08-19 10:12:45 +00:00
Qiu Chaofan
b6d1df2afd
[PowerPC] Support -mno-red-zone option (#94581) 2024-08-19 17:58:08 +08:00
Daniil Kovalev
de5deb7b07
[PAC][ELF][AArch64] Encode several ptrauth features in PAuth core info (#102508)
For llvm_linux platform, define the following meaning for bits 9, 10,
11:

- bit 9: set if indirect gotos signing is enabled;
- bit 10: set if type info vtable pointer discrimination is enabled;
- bit 11: set if function pointer type discrimination is enabled.
2024-08-19 12:53:43 +03:00
Florian Hahn
740f055451
[VPlan] Rename getBestVF -> computeBestVF (NFC).
As suggested in https://github.com/llvm/llvm-project/pull/103033, more
accurately rename to computeBestVF, as it now does not simply return the
best VF, but directly computes it.
2024-08-19 10:44:50 +01:00
Christian Ulmann
065d2d9c60
[MLIR][LLVM] Improve the noalias propagation during inlining (#104750)
This commit changes the LLVM dialect's inliner interface to properly
propagate noalias information to memory accesses that have different
underlying object. By always introducing an SSACopy intrinsic, it's
possible to understand that specific memory operations are using
unrelated pointers. Previously, the backwards slice walk did continue
beyond the boundary of the original function and failed to reason about
the "underlying objects".
2024-08-19 11:27:30 +02:00
Weining Lu
63267ca901 [LoongArch] Fix the assertion for atomic store with 'ptr' type 2024-08-19 17:17:36 +08:00
Kerry McLaughlin
9211977d13
[AArch64][SME] Return false from produceCompactUnwindFrame if VG save required. (#104588)
The compact unwind format requires all registers are stored in pairs, so
return false from produceCompactUnwindFrame if we require saving VG.
2024-08-19 10:17:10 +01:00
Simon Pilgrim
8b1916b766 [X86] Cleanup lowerShuffleWithUNPCK/PACK signatures to match (most) other lowerShuffle* methods. NFC. 2024-08-19 10:05:15 +01:00
Simon Pilgrim
9e3e8b5715 [X86] VPERM2*128 instructions aren't microcoded on znver1
AMD refer to them as microcoded, but not in the same way as LLVM - the uop count and pipe usage is high but predictable

Confirmed with Agner + uops.info.
2024-08-19 10:05:15 +01:00
Simon Pilgrim
5ab65a6c1c [X86] VPERM2*128 instructions aren't microcoded on znver2
This appears to be a copy+paste error from znver1 (which isn't really microcoded either - but it is rather complex!).

Confirmed with Agner + uops.info.
2024-08-19 10:05:15 +01:00
Florian Hahn
cd60d10a10
[VPlan] Move some LoopVectorizationPlanner helpers to VPlan.cpp (NFC).
Members not requiring access to LoopVectorizationLegality or
LoopVectorizationCostModel can safely be moved out of the very large
LoopVectorization.cpp and are more accurately placed in VPlan.cpp
2024-08-19 09:58:46 +01:00
Matthias Springer
5795f9e273
[mlir][docs] Update Bytecode documentation (#99854)
There were some discrepancies between the dialect section documentation
and the implementation.
2024-08-19 10:23:56 +02:00
Nikita Popov
83879f4f53
[SimplifyCFG] Don't block sinking for allocas if no phi created (#104579)
SimplifyCFG sinking currently does not sink loads/stores of allocas,
because historically SROA was unable to handle the resulting IR. Since
then, SROA both learned to speculate loads/stores over selects and phis,
*and* SimplifyCFG sinking has been deferred to the end of the function
simplification pipeline, which means that SROA happens before it.

As such, I believe that this workaround should no longer be necessary.
Given how sensitive SimplifyCFG sinking seems to be, this patch takes a
very conservative step towards removing this, by allowing sinking if we
don't actually need to form a phi over the pointer argument.

This fixes https://github.com/llvm/llvm-project/issues/104567, where
sinking a store to an escaped alloca allows converting a switch into
arithmetic.
2024-08-19 09:55:30 +02:00
hev
985d64b03a
[LoongArch] Merge base and offset for LSX/LASX memory accesses (#104452) 2024-08-19 15:23:05 +08:00
Craig Topper
371f936c45 [RISCV] Make extension names lower case in RISCVISAInfo::checkDependency() error messages. 2024-08-19 00:22:28 -07:00
Craig Topper
10a4f1ef9e [RISCV] Add helper functions to exploit similarity of some RISCVISAInfo::checkDependency() error strings. NFC 2024-08-19 00:22:28 -07:00
Craig Topper
d489b7ccb7 [RISCV] Merge some ISA error reporting together and make some errors more precise.
Loop over the extension names that have the same error message.

Print the name of Zvk* extensions instead of 'zvk*'.
2024-08-19 00:22:28 -07:00
Pengcheng Wang
164d1230f7
[RISCV] Simplify reserse fixed regs (#104736)
Add a macro to simplify some codes.
2024-08-19 15:16:51 +08:00
Craig Topper
f802c39cea [RISCV] Add more tests for RISCVISAInfo::checkDependency(). NFC 2024-08-18 23:59:25 -07:00
Daniel Cederman
7faf1a0868
[Sparc] Add errata workaround pass for GR712RC and UT700 (#103843)
This patch adds a pass that provides workarounds for the errata
described in GRLIB-TN-0009, GRLIB-TN-0010, GRLIB-TN-0011, GRLIB-TN-0012,
and GRLIB-TN-0013, that are applicable to the GR712RC and UT700. The
documents are available for download from here:

https://www.gaisler.com/index.php/information/app-tech-notes

The pass will detect certain sensitive instruction sequences and prevent
them from occurring by inserting NOP instruction. Below is an overview
of each of the workarounds. A similar implementation is available in
GCC.

GRLIB-TN-0009:

* Insert NOPs to prevent the sequence (stb/sth/st/stf) -> (single
non-store/load instruction) -> (any store)

* Insert NOPs to prevent the sequence (std/stdf) -> (any store)

GRLIB-TN-0010:

* Insert a NOP between load instruction and atomic instruction (swap and
casa).

* Insert a NOP at branch target if load in delay slot and atomic
instruction at branch target.

* Do not allow functions to begin with atomic instruction.

GRLIB-TN-0011:

* Insert .p2align 4 before atomic instructions (swap and casa).

GRLIB-TN-0012:

* Place a NOP at the branch target of an integer branch if it is a
floating-point operation or a floating-point branch.

GRLIB-TN-0013:

* Prevent (div/sqrt) instructions in the delay slot.

* Insert NOPs to prevent the sequence (div/sqrt) -> (two or three
floating point operations or loads) -> (div/sqrt).

* Do not insert NOPs if any of the floating point operations have a
dependency on the destination register of the first (div/sqrt).

* Do not insert NOPs if one of the floating point operations is a
(div/sqrt).

* Insert NOPs to prevent (div/sqrt) followed by a branch.
2024-08-19 07:59:58 +02:00