Commit Graph

12045 Commits

Author SHA1 Message Date
zhoujing e6ae0f7ac6 [VENTUS][RISCV][fix] Disable simple loop optimization to call llvm memset/memcpy intrinsics 2023-07-11 16:26:49 +08:00
Fangrui Song a996cc217c Remove unused #include "llvm/ADT/Optional.h" 2022-12-05 06:31:11 +00:00
Fangrui Song 89fae41ef1 [IR] llvm::Optional => std::optional
Many llvm/IR/* files have been migrated by other contributors.
This migrates most remaining files.
2022-12-05 04:13:11 +00:00
Kazu Hirata 595f1a6aaf [llvm] Use std::nullopt instead of None in comments (NFC)
This is part of an effort to migrate from llvm::Optional to
std::optional:

https://discourse.llvm.org/t/deprecating-llvm-optional-x-hasvalue-getvalue-getvalueor/63716
2022-12-04 19:47:13 -08:00
Kazu Hirata 9f252e5567 [llvm] Use std::nullopt instead of None in comments (NFC)
This is part of an effort to migrate from llvm::Optional to
std::optional:

https://discourse.llvm.org/t/deprecating-llvm-optional-x-hasvalue-getvalue-getvalueor/63716
2022-12-04 17:31:17 -08:00
Kazu Hirata 3c09ed006a [llvm] Use std::nullopt instead of None in comments (NFC)
This is part of an effort to migrate from llvm::Optional to
std::optional:

https://discourse.llvm.org/t/deprecating-llvm-optional-x-hasvalue-getvalue-getvalueor/63716
2022-12-04 17:12:44 -08:00
Krzysztof Parzyszek f3b6dbfda8 Instructions: convert Optional to std::optional 2022-12-04 14:25:11 -06:00
Krzysztof Parzyszek df852f48c8 IRBuilder: convert Optional to std::optional 2022-12-03 15:15:46 -06:00
Kazu Hirata 343de6856e [Transforms] Use std::nullopt instead of None (NFC)
This patch mechanically replaces None with std::nullopt where the
compiler would warn if None were deprecated.  The intent is to reduce
the amount of manual work required in migrating from Optional to
std::optional.

This is part of an effort to migrate from llvm::Optional to
std::optional:

https://discourse.llvm.org/t/deprecating-llvm-optional-x-hasvalue-getvalue-getvalueor/63716
2022-12-02 21:11:37 -08:00
Matt Arsenault 27387896cf SROA: Simplify addrspacecasted allocas with volatile accesses
If the alloca is accessed through an addrspacecasted pointer, allow
the normal changes on the alloca. Cast back to the original use
address space instead of the new alloca's natural address space.
2022-12-02 15:20:56 -05:00
Florian Hahn 5fc071f2b4
[DSE] Use precise loc for memcpy_chk during overwrite checks.
Extends the logic from D115167 to memcpy_chk.

Depends on D115167

Reviewed By: asbirlea

Differential Revision: https://reviews.llvm.org/D139096
2022-12-02 14:34:34 +00:00
Florian Hahn af694c5e8d
[DSE] Use precise loc for memset_chk during overwrite checks
memset_chk may not write the number of bytes specified by the third
argument, if it is larger than the destination size (specified as 4th
argument).

Reviewed By: asbirlea

Differential Revision: https://reviews.llvm.org/D115167
2022-12-02 11:28:56 +00:00
Vasileios Porpodas bebca2b6d5 [NFC] Cleanup: Replaces BB->getInstList().splice() with BB->splice().
This is part of a series of cleanup patches towards making BasicBlock::getInstList() private.

Differential Revision: https://reviews.llvm.org/D138979
2022-12-01 15:37:51 -08:00
Krzysztof Parzyszek 467432899b MemoryLocation: convert Optional to std::optional 2022-12-01 15:36:20 -08:00
Florian Hahn ee605b0acc
[ConstraintElim] Use collectOffset result for chained gep support.
This slightly simplifies the code and addresses a correctness issue
where the index scaling for the precondition was not considered
properly.

Thanks to @nikic for pointing that out in D137840.
2022-12-01 17:01:07 +00:00
Vasileios Porpodas 8a1ccb8ae0 [NFC] Removed call to getInstList() from range loops on BBs.
Differential Revision: https://reviews.llvm.org/D138605
2022-11-29 17:33:10 -08:00
Florian Hahn 6a834d2f2b
[ConstraintElim] Use collectOffset instead of custom GEP idx iteration.
Use collectOffset to collect scaled indices and constant offset for GEP
instead of custom code. This simplifies the logic in decomposeGEP and
allows to handle all cases supported by the generic helper.
2022-11-28 16:54:58 +00:00
OCHyams 9517806064 Revert "[Assignment Tracking][13/*] Account for assignment tracking in SROA"
This reverts commit e16d59973f.

Buildbot failure:
https://lab.llvm.org/buildbot/#/builders/236/builds/1205
2022-11-28 16:07:34 +00:00
OCHyams 5e0b29bf23 Revert "[Assignment Tracking][SROA] Follow-up for failing test"
This reverts commit 285d46ef4b.

Failing buildbot:
https://lab.llvm.org/buildbot/#/builders/236/builds/1205
2022-11-28 16:07:34 +00:00
OCHyams 285d46ef4b [Assignment Tracking][SROA] Follow-up for failing test
Follow-up for D133296 / e16d59973f

Buildbot example: https://lab.llvm.org/buildbot/#/builders/6/builds/16989
2022-11-28 12:16:37 +00:00
OCHyams e16d59973f [Assignment Tracking][13/*] Account for assignment tracking in SROA
The Assignment Tracking debug-info feature is outlined in this RFC:

https://discourse.llvm.org/t/
rfc-assignment-tracking-a-better-way-of-specifying-variable-locations-in-ir

Split dbg.assign intrinsics into fragments similarly to what SROA already does
for dbg.declares, except that there's many more intrinsics to split. The
function migrateDebugInfo generates new dbg.assigns intrinsic for each part of
a split store.

Reviewed By: jmorse

Differential Revision: https://reviews.llvm.org/D133296
2022-11-28 11:31:59 +00:00
Matt Arsenault d1c0092163 SeparateConstOffsetFromGEP: Fix creating pointless bitcasts
This was directly creating new BitCastInsts, so under opaque pointers,
would end up producing bitcast from ptr to ptr.
2022-11-27 20:53:48 -05:00
Kazu Hirata d90a14f87d [Scalar] Use std::optional in SimpleLoopUnswitch.cpp (NFC)
This is part of an effort to migrate from llvm::Optional to
std::optional:

https://discourse.llvm.org/t/deprecating-llvm-optional-x-hasvalue-getvalue-getvalueor/63716
2022-11-26 17:41:52 -08:00
Kazu Hirata 6288a09c94 [Scalar] Use std::optional in ScalarizeMaskedMemIntrin.cpp (NFC)
This is part of an effort to migrate from llvm::Optional to
std::optional:

https://discourse.llvm.org/t/deprecating-llvm-optional-x-hasvalue-getvalue-getvalueor/63716
2022-11-26 17:39:36 -08:00
Kazu Hirata 85cee3a4ab [Scalar] Use std::optional in PartiallyInlineLibCalls.cpp (NFC)
This is part of an effort to migrate from llvm::Optional to
std::optional:

https://discourse.llvm.org/t/deprecating-llvm-optional-x-hasvalue-getvalue-getvalueor/63716
2022-11-26 17:36:26 -08:00
Kazu Hirata 60d644554b [Scalar] Use std::optional in LowerConstantIntrinsics.cpp (NFC)
This is part of an effort to migrate from llvm::Optional to
std::optional:

https://discourse.llvm.org/t/deprecating-llvm-optional-x-hasvalue-getvalue-getvalueor/63716
2022-11-26 17:33:11 -08:00
Kazu Hirata 3bb0c7075b [Scalar] Use std::optional in LoopUnrollPass.cpp (NFC)
This is part of an effort to migrate from llvm::Optional to
std::optional:

https://discourse.llvm.org/t/deprecating-llvm-optional-x-hasvalue-getvalue-getvalueor/63716
2022-11-26 17:29:32 -08:00
Kazu Hirata f207cf1d93 [Scalar] Use std::optional in LoopStrengthReduce.cpp (NFC)
This is part of an effort to migrate from llvm::Optional to
std::optional:

https://discourse.llvm.org/t/deprecating-llvm-optional-x-hasvalue-getvalue-getvalueor/63716
2022-11-26 17:26:57 -08:00
Kazu Hirata 42c40f7e35 [Scalar] Use std::optional in LoopSimplifyCFG.cpp (NFC)
This is part of an effort to migrate from llvm::Optional to
std::optional:

https://discourse.llvm.org/t/deprecating-llvm-optional-x-hasvalue-getvalue-getvalueor/63716
2022-11-26 17:24:20 -08:00
Kazu Hirata 27ae2354a0 [Scalar] Use std::optional in LoopRotation.cpp (NFC)
This is part of an effort to migrate from llvm::Optional to
std::optional:

https://discourse.llvm.org/t/deprecating-llvm-optional-x-hasvalue-getvalue-getvalueor/63716
2022-11-26 17:21:19 -08:00
Kazu Hirata 3e3be2955b [Scalar] Use std::optional in LoopPredication.cpp (NFC)
This is part of an effort to migrate from llvm::Optional to
std::optional:

https://discourse.llvm.org/t/deprecating-llvm-optional-x-hasvalue-getvalue-getvalueor/63716
2022-11-26 17:18:54 -08:00
Kazu Hirata d3a58c48f4 [Scalar] Use std::optional in LoopInstSimplify.cpp (NFC)
This is part of an effort to migrate from llvm::Optional to
std::optional:

https://discourse.llvm.org/t/deprecating-llvm-optional-x-hasvalue-getvalue-getvalueor/63716
2022-11-26 17:14:23 -08:00
Roman Lebedev 25f01d593c
Revert "[SROA] `isVectorPromotionViable()`: memory intrinsics operate on vectors of bytes (take 2)"
TableGen is still getting miscompiled on PPC buildbots.
Sent a mail with request for help.

This reverts commit 3c4d2a0396.
2022-11-27 00:00:06 +03:00
Roman Lebedev 3c4d2a0396
[SROA] `isVectorPromotionViable()`: memory intrinsics operate on vectors of bytes (take 2)
This is a recommit of cf624b23bc,
which was reverted in 5cfc22cafe,
because the cut-off on the number of vector elements was not low enough,
and it triggered both SDAG SDNode operand number assertions,
and caused compile time explosions in some cases.

Let's try with something really *REALLY* conservative first,
just to get somewhere, and try to bump it (to 64/128) later.

FIXME: should this respect TTI reg width * num vec regs?

Original commit message:

Now, there's a big caveat here - these bytes
are abstract bytes, not the i8 we have in LLVM,
so strictly speaking this is not exactly legal,
see e.g. https://github.com/AliveToolkit/alive2/issues/860
^ the "bytes" "could" have been a pointer,
and loading it as an integer inserts an implicit ptrtoint.

But at the same time,
InstCombine's `InstCombinerImpl::SimplifyAnyMemTransfer()`
would expand a memtransfer of 1/2/4/8 bytes
into integer-typed load+store,
so this isn't exactly a new problem.

Note that in memory, poison is byte-wise,
so we really can't widen elements,
but SROA seems to be inconsistent here.

Fixes #59116.
2022-11-26 23:19:15 +03:00
Kazu Hirata bba55813fc [Scalar] Use std::optional in LoopFlatten.cpp (NFC)
This is part of an effort to migrate from llvm::Optional to
std::optional:

https://discourse.llvm.org/t/deprecating-llvm-optional-x-hasvalue-getvalue-getvalueor/63716
2022-11-26 00:02:40 -08:00
Kazu Hirata 7fc772bbdc [Scalar] Use std::optional in InductiveRangeCheckElimination.cpp (NFC)
This is part of an effort to migrate from llvm::Optional to
std::optional:

https://discourse.llvm.org/t/deprecating-llvm-optional-x-hasvalue-getvalue-getvalueor/63716
2022-11-25 23:59:45 -08:00
Kazu Hirata b54cd3f09c [Scalar] Use std::optional in GVN.cpp (NFC)
This is part of an effort to migrate from llvm::Optional to
std::optional:

https://discourse.llvm.org/t/deprecating-llvm-optional-x-hasvalue-getvalue-getvalueor/63716
2022-11-25 23:55:44 -08:00
Kazu Hirata edace862f6 [Scalar] Use std::optional in CorrelatedValuePropagation.cpp (NFC)
This is part of an effort to migrate from llvm::Optional to
std::optional:

https://discourse.llvm.org/t/deprecating-llvm-optional-x-hasvalue-getvalue-getvalueor/63716
2022-11-25 23:52:49 -08:00
Benjamin Kramer 5cfc22cafe Revert "[SROA] `isVectorPromotionViable()`: memory intrinsics operate on vectors of bytes"
This reverts commit cf624b23bc. It
triggers crashes in clang, see the comments on github on the original
change.
2022-11-23 13:11:16 +01:00
Roman Lebedev 655d857325
[SROA] `isVectorPromotionViable()`: avoid allowing overly large vectors
Otherwise, `compiler-rt/test/asan/TestCases/pr33372.cpp` fails with an assertion:
```
clang-16: /repositories/llvm-project/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp:11988: void llvm::SelectionDAG::createOperands(llvm::SDNode *, ArrayRef<llvm::SDValue>): Assertion `SDNode::getMaxNumOperands() >= Vals.size() && "too many operands to fit into SDNode"' failed.
```
I'm not sure if this should be even more conservative,
or if we have a named constant for this in middle-end.
2022-11-23 03:23:08 +03:00
Roman Lebedev cf624b23bc
[SROA] `isVectorPromotionViable()`: memory intrinsics operate on vectors of bytes
Now, there's a big caveat here - these bytes
are abstract bytes, not the i8 we have in LLVM,
so strictly speaking this is not exactly legal,
see e.g. https://github.com/AliveToolkit/alive2/issues/860
^ the "bytes" "could" have been a pointer,
and loading it as an integer inserts an implicit ptrtoint.

But at the same time,
InstCombine's `InstCombinerImpl::SimplifyAnyMemTransfer()`
would expand a memtransfer of 1/2/4/8 bytes
into integer-typed load+store,
so this isn't exactly a new problem.

Note that in memory, poison is byte-wise,
so we really can't widen elements,
but SROA seems to be inconsistent here.

Fixes #59116.
2022-11-23 02:38:25 +03:00
Roman Lebedev 529eafd9be
[SROA] `isVectorPromotionViable()`: integer-ify non-pointer non-common types
This rectifies a FIXME that dates all the way back
to 2014 about not doing so due to the backend issues.

Presumably sufficient amount of time has passes
and all the known issues have been addressed,
or at least we will find out of there are some left...
2022-11-23 00:23:00 +03:00
Roman Lebedev 4e18d51ac5
[SROA] `isVectorPromotionViable()`: pointer-ness is sticky
As it has been established previously by precedent,
if we see a pointer type, then that is the type we must use.
Essentially, we don't want to introduce `inttoptr`'s.
2022-11-23 00:23:00 +03:00
Matt Arsenault afb3509113 LoopDeletion: Fix missing newlines in debug printing 2022-11-22 11:12:00 -05:00
David Green 8e9e22f07b [LoopFlatten] Fix IV increment use count
The add from the IV in the inner loop was always checking for 2 uses,
the phi and the compare. The compare could be based on the phi though,
leaving one valid use of the compare. In the testcase we could be left
with the phi and a lcssa phi as the two users, invalidly allowing
flattening where we shouldn't.

Fixes 58441

Differential Revision: https://reviews.llvm.org/D138404
2022-11-22 07:23:56 +00:00
Kazu Hirata 1f914944b6 Don't use Optional::getPointer (NFC)
Since std::optional does not offer getPointer(), this patch replaces
X.getPointer() with &*X to make the migration from llvm::Optional to
std::optional easier.

This is part of an effort to migrate from llvm::Optional to
std::optional:

https://discourse.llvm.org/t/deprecating-llvm-optional-x-hasvalue-getvalue-getvalueor/63716

Differential Revision: https://reviews.llvm.org/D138466
2022-11-21 19:03:40 -08:00
Manuel Brito 1e55d5b1f2 Use poison instead of undef as placeholder for vector construction [NFC]
Differential Revision: https://reviews.llvm.org/D138450
2022-11-21 18:43:23 +00:00
Max Kazantsev 2a3ac7fd0c [NFC][IndVars] Add LLVM_DEBUG printout to replaceExitCond 2022-11-21 19:33:26 +07:00
Kazu Hirata 31b6093434 [Scalar] Teach matchExpandedRem to return std::optional (NFC)
This is part of an effort to migrate from llvm::Optional to
std::optional:

https://discourse.llvm.org/t/deprecating-llvm-optional-x-hasvalue-getvalue-getvalueor/63716
2022-11-20 22:38:43 -08:00
Kazu Hirata 7524db4d44 [llvm] Remove unused forward declarations (NFC) 2022-11-20 09:59:36 -08:00