10329 Commits

Author SHA1 Message Date
Rahul Joshi
bde2357f71
[LLVM][TableGen] Rename Option emitter files (#109216)
Rename OptXXXEmitter.cpp to OptionXXXEmitter.cpp to have a less
ambiguous
name, as `Opt` could also mean optimization.
2024-09-24 16:54:36 -07:00
Matt Arsenault
71ca9fcb8d
llvm-reduce: Don't print verifier failed machine functions (#109673)
This produces far too much terminal output, particularly for the
instruction reduction. Since it doesn't consider the liveness of of
the instructions it's deleting, it produces quite a lot of verifier
errors.
2024-09-24 22:32:53 +04:00
vporpo
f4042077e2
[SandboxIR] Implement a few Instruction member functions (#109820)
This patch implements a few sandboxir::Instruction predicate functions.
2024-09-24 10:12:12 -07:00
Rahul Joshi
6bed79b3f0
[Support] Add scaling support in indent (#109478)
Scaled indent is useful when indentation is always in steps of a fixed
number (the Scale) and still allow using the +/- operators to adjust
indentation.
2024-09-23 18:41:40 -07:00
Jorge Gorbe Moya
3bb92b530f
[SandboxVec] Tag insts in a Region with metadata. (#109353)
For each region, we create a metadata node. Then when an instruction is
added to the Region, it gets tagged with the metadata node for that
region. In the following example, we have a Region that contains only
the `%t0` instruction.

```
define i8 @foo(i8 %v0, i8 %v1) {
  %t0 = add i8 %v0, 1, !sbvec !0
  %t1 = add i8 %t0, %v1
  ret i8 %t1
}

!0 = distinct !{!"region"}
```

This commit also adds a function to create regions from metadata already
present in a Function.

This metadata can be used for debugging: if we dump IR before a Region
pass, the IR will contain enough info to re-create the Region and run
the pass by itself in a later invocation.

---------

Co-authored-by: Alina Sbirlea <alina.g.simion@gmail.com>
2024-09-23 16:59:02 -07:00
vporpo
74405b9d74
[SandboxIR] Implement a few Instruction member functions (#109709)
This patch implements some of the missing member functions of
sandboxir::Instruction.
2024-09-23 13:46:28 -07:00
vporpo
416c3ce013
[SandboxIR] Implement ConstantExpr (#109491)
This patch implements an empty sandboxir::ConstantExpr class, mirroring
llvm::ConstantExpr.
2024-09-23 11:45:20 -07:00
Sterling-Augustine
d1edef56e8
[SandboxIR] Functions to find vectorizor-relevant properties (#109221)
When vectorizing, the destination type and value of stores is more
relevant than the type of the instruction itself. Similarly for return
instructions. These functions provide a convenient way to do that
without special-casing them everywhere, and avoids the need for
friending any class that needs access to Value::LLVMTy to calculate it.

Open to better naming.
2024-09-23 11:05:23 -07:00
Nikita Popov
ecb98f9fed [IRBuilder] Remove uses of CreateGlobalStringPtr() (NFC)
Since the migration to opaque pointers, CreateGlobalStringPtr()
is the same as CreateGlobalString(). Normalize to the latter.
2024-09-23 16:30:50 +02:00
Lang Hames
255870d7b5 [JITLink] Update splitBlock to support splitting into multiple blocks.
LinkGraph::splitBlock used to take a single split-point to split a Block into
two. In the common case where a block needs to be split repeatedly (e.g. in
eh-frame and compact-unwind sections), iterative calls to splitBlock could
lead to poor performance as symbols and edges are repeatedly shuffled to new
blocks.

This commit updates LinkGraph::splitBlock to take a sequence of split offsets,
allowing a block to be split into an arbitrary number of new blocks. Internally,
Symbols and Edges only need to be moved once (directly to whichever new block
they will be associated with), leading to better performance.

On some large MachO object files in an out of tree project this change improved
the performance of splitBlock by several orders of magnitude.

rdar://135820493
2024-09-22 09:52:08 +10:00
vporpo
8f31ee996a
[SandboxVec][DAG] Implement DGNode::isMem() (#109504)
DGNode::isMem() returns true if the node is a memory dependency
candidate.
2024-09-21 08:09:30 -07:00
Jay Foad
eb6e7e8f89
[unittests] Use {} instead of std::nullopt to initialize empty ArrayRef (#109388)
Follow up to #109133.
2024-09-21 10:59:50 +01:00
Fangrui Song
b84d773fd0 [Parallel] Revert sequential task changes
https://reviews.llvm.org/D148728 introduced `bool Sequential` to unify
`execute` and the old `spawn` without argument. However, sequential
tasks might be executed by any worker thread (non-deterministic),
leading to non-determinism output for ld.lld -z nocombreloc (see
https://reviews.llvm.org/D133003).

In addition, the extra member variables have overhead.
This sequential task has only been used for lld parallel relocation
scanning.

This patch restores the behavior before https://reviews.llvm.org/D148728 .

Fix #105958

Pull Request: https://github.com/llvm/llvm-project/pull/109084
2024-09-20 21:15:42 -07:00
vporpo
0c9f7ef527
[SandboxVec][DAG] Implement extend(ArrayRef) (#109493)
This builds the DAG from an ArrayRef of Instructions.
2024-09-20 19:09:00 -07:00
vporpo
abc2412f07
[SandboxVec][InstrInterval] Add ArrayRef constructor (#109357)
The new constructor creates an InstrInterval from an
ArrayRef<Instruction *>. This patch also adds top() and bottom()
getters.
2024-09-20 16:17:09 -07:00
vporpo
c0b1c623be
[SandboxIR] Implement ConstantPtrAuth (#109315)
This patch implements sandboxir::ConstantPtrAuth mirroring
llvm::ConstantPtrAuth
2024-09-20 15:43:54 -07:00
Abhina Sreeskantharajan
efdb3ae232 Revert "[SystemZ][z/OS] Propagate IsText parameter to open text files as text (#107906)"
This reverts commit edf3b277a5f2ebe144827ed47463c22743cac5f9.
2024-09-20 08:18:16 -04:00
Nikita Popov
37e5319a12 [UnitTests] Fix APInt signed flags (NFC)
This makes unit tests compatible with the assertion added in
https://github.com/llvm/llvm-project/pull/106524, by setting the
isSigned flag to the correct value or changing how the value is
constructed.
2024-09-20 12:13:33 +02:00
braw-lee
173841cc56
[TLI] Add basic support for fdim libcall (#108702)
first PR to fix #108695

Signed-off-by: Kushal Pal <kushalpal109@gmail.com>
2024-09-20 10:22:33 +04:00
Alex Rønne Petersen
72a218056d
[llvm][Triple] Add Environment members and parsing for glibc/musl parity. (#107664)
This adds support for:

* `muslabin32` (MIPS N32)
* `muslabi64` (MIPS N64)
* `muslf32` (LoongArch ILP32F/LP64F)
* `muslsf` (LoongArch ILP32S/LP64S)

As we start adding glibc/musl cross-compilation support for these
targets in Zig, it would make our life easier if LLVM recognized these
triples. I'm hoping this'll be uncontroversial since the same has
already been done for `musleabi`, `musleabihf`, and `muslx32`.

I intentionally left out a musl equivalent of `gnuf64` (LoongArch
ILP32D/LP64D); my understanding is that Loongson ultimately settled on
simply `gnu` for this much more common case, so there doesn't *seem* to
be a particularly compelling reason to add a `muslf64` that's basically
deprecated on arrival.

Note: I don't have commit access.
2024-09-20 08:53:03 +08:00
vporpo
7688393201
[SandboxVec] Simple Instruction Interval class (#108882)
An InstrInterval is a range of instructions in a block. The class will
eventually have an API for set operations, like union, intersection etc.
2024-09-19 17:18:40 -07:00
Abhina Sree
edf3b277a5
[SystemZ][z/OS] Propagate IsText parameter to open text files as text (#107906)
This patch adds an IsText parameter to the following functions
openFileForRead, getBufferForFile, getBufferForFileImpl and determines
whether a file is text by querying the file tag on z/OS. The default is
set to OF_Text instead of OF_None, this change in value does not affect
any other platforms other than z/OS.
2024-09-19 14:30:10 -04:00
Franklin
e45f9aa7fa
[AArch64] Initial sched model for Neoverse N3 (#106371)
References:

* Arm Neoverse N3 Software Optimization Guide
* Arm A64 Instruction Set for A-profile architecture
2024-09-19 19:22:24 +01:00
vporpo
74c0ab6f39
[SandboxIR] Implement NoCFIValue (#109046)
This patch implements sandboxir::NoCFIValue mirroring llvm::NoCFIValue.
2024-09-19 10:12:28 -07:00
Jay Foad
e03f427196
[LLVM] Use {} instead of std::nullopt to initialize empty ArrayRef (#109133)
It is almost always simpler to use {} instead of std::nullopt to
initialize an empty ArrayRef. This patch changes all occurrences I could
find in LLVM itself. In future the ArrayRef(std::nullopt_t) constructor
could be deprecated or removed.
2024-09-19 16:16:38 +01:00
Vasileios Porpodas
9f5139ccee [SandboxIR] Fix unused variable build error 2024-09-18 17:58:23 -07:00
vporpo
1bda7ba12e
[SandboxIR] Add Instruction::isStackSaveRestoreIntrinsic() and isMemDepCandidate() (#109212)
These are helper functions to be used by the vectorizer's dependency
graph.
2024-09-18 17:29:59 -07:00
Jorge Gorbe Moya
71e434d302
[SandboxVec] Reapply "Add barebones Region class. (#108899)" (#109059)
A `#ifndef NDEBUG` in the wrong place caused an error in release builds.
2024-09-18 11:36:45 -07:00
Rahul Joshi
2731be7ac5
[Support] Add helper struct indent for adding indentation (#108966)
Add helper struct indent() for adding indentation to raw_ostream.
2024-09-18 08:54:11 -07:00
Florian Hahn
0d736e296c
[VPlan] Add getSCEVExprForVPValue util, use to get trip count SCEV (NFC) (#94464)
Add a new getSCEVExprForVPValue utility which can be used to get a SCEV
expression for a VPValue. The initial implementation only returns SCEVs
for live-in IR values (by constructing a SCEV based on the live-in IR
value) and VPExpandSCEVRecipe. This is enough to serve its first use,
getting a SCEV for a VPlan's trip count, but will be extended in the
future.

It also removes createTripCountSCEV, as the new helper can be used to
retrieve the SCEV from the VPlan.

PR: https://github.com/llvm/llvm-project/pull/94464
2024-09-18 14:41:56 +01:00
Benjamin Maxwell
43c9203d49
[TLI] Support inferring function attributes for sincos[f|l] (#108554) 2024-09-18 09:40:29 +01:00
Franklin
c2c425fccf
[AArch64] Add missing tests for Arm cpus (#106749) 2024-09-18 09:33:39 +01:00
vporpo
42c5a301f5
[SandboxVec] Legality boilerplate (#108650)
This patch adds the basic API for the Legality component of the
vectorizer. It also adds some very basic code in the bottom-up
vectorizer that uses the API.
2024-09-17 17:06:29 -07:00
Jorge Gorbe Moya
aa2e6b8734
Revert "[SandboxVec] Add barebones Region class." (#109058)
Reverts llvm/llvm-project#108899

It broke the llvm-clang-x86_64-win-fast buildbot.
2024-09-17 15:47:30 -07:00
Jorge Gorbe Moya
3aecf41c2b
[SandboxVec] Add barebones Region class. (#108899)
A region identifies a set of vector instructions generated by
vectorization passes. The vectorizer can then run a series of
RegionPasses on the region, evaluate the cost, and commit/reject the
transforms on a region-by-region basis, instead of an entire basic
block.

This is heavily based ov @vporpo's prototype. In particular, the doc
comment for the Region class is all his. The rest of this commit is
mostly boilerplate around a SetVector: getters, iterators, and some
debug helpers.
2024-09-17 15:40:24 -07:00
vporpo
b846638548
[SanbdoxIR] Implement BBIterator::getNodeParent() (#109039)
This patch implements sandboxir::BasicBlock::iterator::getNodeParent()
which returns the parent basic block of an iterator.
2024-09-17 15:20:09 -07:00
vporpo
9a312d47f3
[SandboxIR] Implement GlobalAlias (#109019)
This patch implements sandboxir::GlobalAlias, mirroring
llvm::GlobalAlias.
2024-09-17 13:45:36 -07:00
Vasileios Porpodas
c8fcfe1980 [SandboxIR][NFC] Fix unittest build warning in release 2024-09-17 13:13:16 -07:00
vporpo
318d2f5e5d
[SandboxVec][DAG] Boilerplate (#108862)
This patch adds a very basic implementation of the Dependency Graph to
be used by the vectorizer.
2024-09-17 12:03:52 -07:00
vporpo
b9bf831e8d
[SandboxIR] Implement GlobalVariable (#108642)
This patch implements sandboxir::GlobalVariable mirroring
llvm::GlobalVariable.
2024-09-17 10:26:34 -07:00
Michael Maitland
ee2add0683
[GISEL] Fix bugs and clarify spec of G_EXTRACT_SUBVECTOR (#108848)
The implementation was missing the fact that `G_EXTRACT_SUBVECTOR`
destination and source vector can be different types.

Also fix a bug in the MIR builder for `G_EXTRACT_SUBVECTOR` to generate
the correct opcode.

Clarify the G_EXTRACT_SUBVECTOR specification.
2024-09-17 10:08:39 -04:00
Rahul Joshi
2f7ffbaad3
[Support] Fix bugs in formatv automatic index assignment (#108384)
Fix bugs found when actually trying to use formatv() automatic index
assignment in IntrinsicEmitter.cpp:
- Assign automatic index only for `ReplacementType::Format`.
- Make the check for all replacement indices being either automatic orexplicit more accurate.
  The existing check fails for formatv("{}{0}{}", 0, 1) (added as a unit test). Explicitly track if we
  have seen any explicit and any automatic index instead.
2024-09-16 21:48:05 -07:00
Jake Egan
53d60398ef
[CMake] Use old DynamicLibrary symbol behavior on AIX for now (#108692)
New behavior broke the AIX bot, so fall back to the old behavior on AIX
for now to give time to investigate
2024-09-16 10:57:06 -04:00
Robert Dazi
8837898b8d
[DAGCombine] Count leading ones: refine post DAG/Type Legalisation if promotion (#102877)
This PR is related to #99591. In this PR, instead of modifying how the
legalisation occurs depending on surrounding instructions, we refine
after legalisation.

This PR has two parts:

* `SDPatternMatch/MatchContext`: Modify a little bit the code to match
Operands (used by `m_Node(...)`) and Unary/Binary/Ternary Patterns to
make it compatible with `VPMatchContext`, instead of only `m_Opc`
supported. Some tests were added to ensure no regressions.
* `DAGCombiner`: Add a `foldSubCtlzNot` which detect and rewrite the
patterns using matching context.

Remaining Tasks:

- [ ] GlobalISel
- [ ] Currently the pattern matching will occur even before
legalisation. Should I restrict it to specific stages instead ?
- [ ] Style: Add a visitVP_SUB ?? Move `foldSubCtlzNot` in another
location for style consistency purpose ?

@topperc

---------

Co-authored-by: v01dxyz <v01dxyz@v01d.xyz>
2024-09-15 15:48:36 +04:00
Craig Topper
f78a48cfaf [MC] Use std::optional<MCRegisters> for values returned by MCRegisterInfo::getLLVMRegNum. NFC
I missed a few places when I changed the function return type in
f2b71491d11355c0df0c92ef7cce7d610c894660.
2024-09-13 22:47:19 -07:00
Mircea Trofin
82266d3a2b
[nfc][ctx_prof] Factor the callsite instrumentation exclusion criteria (#108471)
Reusing this in the logic fetching the instrumentation in `CtxProfAnalysis`.
2024-09-13 21:25:47 -07:00
JOE1994
459a82e689 [llvm][unittests] Don't call raw_string_ostream::flush() (NFC)
raw_string_ostream::flush() is essentially a no-op (also specified in docs).
Don't call it in tests that aren't meant to test 'raw_string_ostream' itself.

p.s. remove a few redundant calls to raw_string_ostream::str()
2024-09-13 19:55:44 -04:00
JOE1994
52b48a70d3 [llvm][unittests] Strip unneeded use of raw_string_ostream::str() (NFC)
Avoid excess layer of indirection.
2024-09-13 19:01:08 -04:00
JOE1994
77bab2a6f3 [llvm][unittests] Strip unneeded use of raw_string_ostream::str() (NFC)
Avoid unneeded layer of indirection.
2024-09-13 18:33:41 -04:00
vporpo
6cbb2455ae
[SandboxIR] Implement missng Instruction::comesBefore() (#108635) 2024-09-13 14:25:18 -07:00