33146 Commits

Author SHA1 Message Date
Arthur Eubanks
e94b59ee75 [Debugify/Strip] Fix returned PreservedAnalyses 2023-03-15 11:45:25 -07:00
Arthur Eubanks
6a3fdcdd38 [WPD] Fix PreservedAnalyses value after runForTesting() 2023-03-15 11:43:24 -07:00
Alexandros Lamprineas
9627bcdeac [FuncSpec][NFC] Command line option renaming.
Standardize all options with 'funcspec' prefix and shorter abreviations.

Differential Revision: https://reviews.llvm.org/D145378
2023-03-15 18:03:44 +00:00
Yuanfang Chen
e7a2da5298 [Inliner] Assign dummy debug location to the memcpy for byval argument
A similar fix to D133095.

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

Reviewed By: aprantl

Differential Revision: https://reviews.llvm.org/D145607
2023-03-15 10:30:28 -07:00
Philip Reames
e3dac9e93f [MSAN] Replace another open-coded convertToBool instance [nfc]
Note that getCleanShadow always returns Constant::getNullValue so the prior code is equivalent to convertToBool.
2023-03-15 10:24:49 -07:00
Philip Reames
75e22e8699 [MSAN] Inline getShadowTyNoVec into convertShadowToScalar [nfc]
This is an implementation detail of the flattening scheme, so hide it in the implementation thereof.  This does require one caller to go through the appropriate utility, but doing that makes the code cleaner anyways.
2023-03-15 10:24:49 -07:00
ibricchi
65f7ebe72e [InlineOrder] Plugin Inline Order
Adds the ability to load a plugin to control the inline order.
This allows developing and distributing inlining heuristics
outside of tree. And together with the inline advisor plugins
allows for fine grained control of the inliner.

The PluginInlineOrderAnalysis class serves as the entry point
for dynamic advisors. Plugins must register instances of this
class to provide their own InlineOrder.

Reviewed By: kazu

Differential Revision: https://reviews.llvm.org/D140637
2023-03-15 13:15:14 -04:00
Jake Egan
1628a5695e Revert "[InlineOrder] Plugin Inline Order"
This commit is causing a CMake error on AIX. Will recommit with
a fix.

This reverts commit e46d8a731535afcf0c5c2a2f6cf3c5d4fb69cd5b.
2023-03-15 13:12:04 -04:00
Arthur Eubanks
6d7da41b80 [Debugify] Invalidate function analyses
Since debugify inserts instructions.
2023-03-15 09:19:05 -07:00
Nikita Popov
77c90ebeb7 [ASAN] Use AI.getAllocationSize() helper (NFC) 2023-03-15 16:51:52 +01:00
Kazu Hirata
8bdf387858 Use *{Map,Set}::contains (NFC)
Differential Revision: https://reviews.llvm.org/D146104
2023-03-15 08:46:32 -07:00
Philip Reames
de71056a7d [ASAN] Initial support memory checks on scalable vector typed allocas
This patch adjusts the memory instrumentation to account for scalable vector types in allocas. Note that we don't allow scalable vector globals, so we don't need to update that codepath.

A couple points.

First, this simply disables the optimization for scalable allocas. We can revisit this in the future, but it requires a bit of plumbing to get scalable object sizes through the visitor to be useful.

Second, I am simply disabling stack poisoning for scalable vector allocas. This is mostly for staging the change as I can't write a working test for memory instrumentation without doing so. I don't think it's unreasonable to do on it's own basis as without the bailout, we crash the compiler.

Differential Revision: https://reviews.llvm.org/D145259
2023-03-15 07:59:42 -07:00
Matt Arsenault
0d18f315d8 InstCombine: Handle folding fcmp of 0 into llvm.is.fpclass
This needs to consider the denormal mode.
2023-03-15 07:07:55 -04:00
Matt Arsenault
4109e3f1db Reapply "InstCombine: Fold is.fpclass(x, fcZero) to fcmp oeq 0"
This reverts commit 458ad6900e6635e4640229d40e6f713147e52de7.
2023-03-15 07:06:50 -04:00
Alexandros Lamprineas
67fde2b932 [FuncSpec] Minor refactoring in statistics and debug messages.
* Remove redundant variable `NbFunctionsSpecialized` as it is no longer
  used by the cost model.
* Rename statistic `NumFuncSpecialized` to `NumSpecsCreated` as a better
  description (the old name confusingly implied number of functions we have
  created clones for).
* Same for variable `SpecializedFuncs`. Renamed to `Specializations`.
* Move debug message in the destructor (avoids repetition when MaxIters > 1).

Differential Revision: https://reviews.llvm.org/D145375
2023-03-15 09:10:06 +00:00
chenglin.bi
d99d765fc0 [InstCombine] Remove one-use limit when it can simplify to a const in the pattern foldICmpUsingBoolRange
This patch follow up dd31a3b3a5, when the pattern return a constant we needn't limit it to one-use.
2023-03-15 16:57:51 +08:00
Michael Maitland
194f3dc8fd [VPlan] VPWidenIntOrFpInductionRecipe inherits from VPHeaderPHIRecipe
Differential Revision: https://reviews.llvm.org/D144125
2023-03-14 17:01:34 -07:00
Arthur Eubanks
093b2640ea [SimplifyLibCalls] Return Value from optimizeSinCosPi when making change
Or else InstCombine can incorrectly report that no change has been made.

This optimization doesn't really fit into InstCombine since it optimizes multiple instructions at once; there's likely a more comprehensive fix.

Reviewed By: nikic

Differential Revision: https://reviews.llvm.org/D146064
2023-03-14 15:16:44 -07:00
Philip Reames
c361741a27 [BasicBlockUtils] Expose an internal utility in API [nfc]
Shrinking a patch about to be posted for review.
2023-03-14 14:11:16 -07:00
Valery N Dmitriev
f9b438b519 [SLP] Outline GEP chain cost modeling into new TTI interface - NFCI.
Cost modeling for GEPs should actually be target dependent but is currently
done inside SLP target-independent way.
Sinking it into TTI enables target dependent implementation.
This patch adds new TTI interface and implementation of the basic functionality
trying to retain existing cost modeling.

Differential Revision: https://reviews.llvm.org/D144770
2023-03-14 14:01:34 -07:00
Arthur Eubanks
1a90faacf1 [Passes] Remove some legacy passes
NewGVN
GVNHoist
GVNSink
MemCpyOpt
Float2Int

These were only used for the optimization pipeline, of which the legacy version was removed.
2023-03-14 13:32:59 -07:00
Philip Reames
a98ac8ea55 [MSAN] Minor refactor to reduce future diff [nfc] 2023-03-14 13:18:24 -07:00
Kazu Hirata
e46d8a7315 [InlineOrder] Plugin Inline Order
This allows developing and distributing inlining heuristics
outside of tree. And together with the inline advisor plugins
allows for fine grained control of the inliner.

The PluginInlineOrderAnalysis class serves as the entry point
for dynamic advisors. Plugins must register instances of this
class to provide their own InlineOrder.

I'm checking in this patch on behalf of ibricchi
<ibricchi@student.ethz.ch>.

Differential Revision: https://reviews.llvm.org/D140637
2023-03-14 13:13:56 -07:00
Philip Reames
9227f286ac Move utility for acting on each lane of ElementCount to common code [nfc]
This was first written for AddressSanitizer, but I'm about to reuse it for MemorySanitizer as well.
2023-03-14 10:38:02 -07:00
Alexey Bataev
641939baa9 [SLP]Remove CreateShuffle lambda and reuse ShuffleBuilder functions.
After merging main part of the gather/buildvector code, CreateShuffle
lambda can removed and ShuffleBuilder add functions can be used instead.
Also, part of the code from CreateShuffle migrated to createShuffle of
the BaseShuffleAnalysis::createShuffle function for better code emission.

Differential Revision: https://reviews.llvm.org/D145988
2023-03-14 10:15:41 -07:00
Nikita Popov
fdda602c04 Revert "[InstCombine] Return instruction from replaceUse()"
This reverts commit 27c4e233104ba765cd986b3f8b0dcd3a6c3a9f89.

I think I made a mistake with the use in RemoveConditionFromAssume(),
because the instruction being changed is not the current one, but
the next assume. Revert the change for now.
2023-03-14 17:46:33 +01:00
Arthur Eubanks
3fd42f50d8 [CoroCleanup] Invalidate analyses on changed functions before running SimplifyCFG
Or else the sub-FunctionPassManager may see out of date analyses.
2023-03-14 09:34:55 -07:00
Arthur Eubanks
f8bd0be602 [AssumeBundleBuilder] Fix PreservedAnalyses reporting
These weren't properly reporting changes.
2023-03-14 09:28:00 -07:00
Nikita Popov
27c4e23310 [InstCombine] Return instruction from replaceUse()
Same as with other replacement methods, it's generally necessary
to report a change on the instruction itself, e.g. by returning
it from the visit method (or possibly explicitly adding it to the
worklist).

Return Instruction * from replaceUse() to encourage the usual
"return replaceXYZ" pattern.
2023-03-14 16:53:03 +01:00
Nikita Popov
271b5cf562 [InstCombine] Fix infinite combine loop (PR61361)
In the degenerate case where the select is fed by an unsimplified
icmp with two constant operands, don't try to replace one constant
with another. Wait for the icmp to be simplified first instead.

Fixes https://github.com/llvm/llvm-project/issues/61361.
2023-03-14 16:43:00 +01:00
Alexey Bataev
874c49f554 [SLP]Fix PR61395: need to adjust vector factor after emitting shuffle
operation for combined entries.

The vector factor after combining of the shuffle entries is defined by
the size of the mask, not by the vector factors  of the original
entries. So, need to adjust it to emit correct code.
2023-03-14 06:27:08 -07:00
Nikita Popov
5b86eaeb7e Reapply [LowerTypeTests] Avoid creation of select constant expression
Reapply with a fix for phi handling: For phis, we need to insert
into the incoming block, not above the phi. This is especially
tricky if there are multiple incoming values from the same
predecessor, because these must all use the same value.

-----

LowerTypeTests replaces weak declarations with an icmp+select
constant expressions. As this is not a relocatable expression,
it additionally promotes initializers using it to global ctors.

As part of https://discourse.llvm.org/t/rfc-remove-most-constant-expressions/63179,
I would like to remove the select constant expression, of which LTT
is now the last user. This is a bit tricky, because we now need to
replace a constant with an instruction, which might require
converting intermediate constant expression users to instructions as
well.

We do this using the convertUsersOfConstantsToInstructions() helper.
However, it needs to be slightly extended to also support expansion
of ConstantAggregates. These are important in this context, because
the promotion of initializers to global ctors will produce stores
of such aggregates.

Differential Revision: https://reviews.llvm.org/D145247
2023-03-14 12:06:24 +01:00
Max Kazantsev
c113d0b766 [NFC] Drop NDEBUG around MSSA verification
Proposed on review of https://reviews.llvm.org/D145894.
2023-03-14 17:39:54 +07:00
Max Kazantsev
47021bda64 [IndVars] Option verify-indvars is broken (and always has been), delete it
This option is switched off by default, and it seems that it has never worked correctly.
What it basically does is: it remembers current BECount SCEV, and after all transforms
tries to validate some facts for it. However, between these two points this SCEV may
become invalid (e.g. because some SCEVUnknown it references may be deleted as dead
code). So basically it may work with broken pointers.

Besides, its implementation does strange things (e.g. forgetLoop) which are invasive and
may affect behavior in other parts of the system (specifically verification), concealing some
other problems. Another issue is that it may use SCEVCouldNotCompute object without
checking this.

The option is not used in any unit tests, and if switched on by default, the following tests
fail:
```
********************
Failed Tests (14):
  LLVM :: Transforms/IndVarSimplify/2005-06-15-InstMoveCrash.ll
  LLVM :: Transforms/IndVarSimplify/2007-06-06-DeleteDanglesPtr.ll
  LLVM :: Transforms/IndVarSimplify/2008-10-03-CouldNotCompute.ll
  LLVM :: Transforms/IndVarSimplify/2009-05-24-useafterfree.ll
  LLVM :: Transforms/IndVarSimplify/2011-10-27-lftrnull.ll
  LLVM :: Transforms/IndVarSimplify/ARM/code-size.ll
  LLVM :: Transforms/IndVarSimplify/X86/deterministic-scev-verify.ll
  LLVM :: Transforms/IndVarSimplify/X86/pr57187.ll
  LLVM :: Transforms/IndVarSimplify/X86/verify-scev.ll
  LLVM :: Transforms/IndVarSimplify/bbi-63564.ll
  LLVM :: Transforms/IndVarSimplify/invalidate-modified-lcssa-phi.ll
  LLVM :: Transforms/IndVarSimplify/loop-predication.ll
  LLVM :: Transforms/IndVarSimplify/post-inc-range.ll
  LLVM :: Transforms/IndVarSimplify/turn-to-invariant.ll

********************
Unexpectedly Passed Tests (1):
  LLVM :: Transforms/IndVarSimplify/pr55689.ll
```

None of these looks like real problems found by verification, these are
bugs in the verifying code itself (such as use of deleted SCEVs and
SCEVCouldNotCompute's).

I think it all gives enough justification for its removal.

https://github.com/llvm/llvm-project/issues/61302

Differential Revision: https://reviews.llvm.org/D145894
Reviewed By: nikic
2023-03-14 17:39:54 +07:00
pvanhout
e4ea2d5919 [StructurizeCFG] Correctly depend on UniformityAnalysis
Small oversight in https://reviews.llvm.org/D145688 - the pass' dependency was not updated to reflect the change to UA.

Also, change DivergenceAnalysis to UniformityAnalysis in a comment. That way, StructurizeCFG only refers to UA and not DA anymore.
2023-03-14 11:25:22 +01:00
Nikita Popov
af101f9ae0 [IR] Allow !range on vector of integer instructions
Inspired by https://reviews.llvm.org/D144467#4188310, this allows
!range on vector of integer instructions, with the usual
element-wise interpretation, which is already used by various
analysis APIs that support vectors.

Differential Revision: https://reviews.llvm.org/D145920
2023-03-14 09:41:56 +01:00
Kazu Hirata
c8f9555c4d [Transforms] Use *{Set,Map}::contains (NFC) 2023-03-14 00:24:30 -07:00
chenglin.bi
76df706bca Revert "[LogicCombine 1/?] Implement a general way to simplify logical operations."
This reverts commit 97dcbea63e11d566cff0cd3a758cf1114cf1f633.
2023-03-14 09:00:06 +08:00
Jakub Kuderski
b9db89fbcf [ADT][NFCI] Do not use non-const lvalue-refs with enumerate in llvm/
Replace references to `enumerate` results with either const lvalue
rerences or structured bindings. I did not use structured bindings
everywhere as it wasn't clear to me it would improve readability.

This is in preparation to the switch to `zip` semantics which won't
support non-const lvalue reference to elements:
https://reviews.llvm.org/D144503.

Reviewed By: dblaikie

Differential Revision: https://reviews.llvm.org/D145987
2023-03-13 20:59:06 -04:00
Carl Ritson
2aaaed3527 [IRLinker] Fix mapping of declaration metadata
Ensure metadata for declarations copied during materialization
is properly mapped if declarations do not become definitions.

Reviewed By: tejohnson

Differential Revision: https://reviews.llvm.org/D145318
2023-03-14 08:42:44 +09:00
Philip Reames
5d2ddb129c [ASAN] Extract out a helper routine for foreach lane on vectors [nfc]
The new API matches a case we also need in MSAN.  For the moment, I'm staging this as a local-to-ASAN commit, but I expect to move this to a shared location and reuse in the next day or two.
2023-03-13 15:06:58 -07:00
Philip Reames
991e573046 [MSAN] Use TypeSize and related utilities [nfc-ish]
This is part of prework for supporting scalable vector types.  This isn't NFC because it shifts the point of failure (i.e. which assert triggers first), but should be NFC for all non-scalable vector inputs.
2023-03-13 14:10:37 -07:00
Philip Reames
a835577269 [MSAN] Remove usage of FixedVectorType where trivial [nfc]
This is a prepass on generalizing for scalable vectors; I'm just picking off the easy bits.
2023-03-13 13:18:37 -07:00
David Green
98481bc723 [LV][VPlan] Fix printing TripCount liveins. NFC
The TripCount liveins would currently be printed as badref in the vplan as they
are not allocated slots in the VPSlotTracker. This patch allocates them a slot
and adds them to the printed Live-Ins. It also makes a minor adjustment to
printing of Live-ins to reduce the empty lines when multiple Live-ins are
present.

Differential Revision: https://reviews.llvm.org/D145507
2023-03-13 19:44:12 +00:00
Philip Reames
dae682ce92 [IRBuilder] Add utilities for materializing scalable values [nfc]
These idioms already appear a number of places in code, and upcoming changes to the various sanitizers continue to need more instances of the same patterns.

Differential Revision: https://reviews.llvm.org/D145945
2023-03-13 11:54:19 -07:00
Nick Desaulniers
b7a33893f5 [GVNHoist] add cast to unbreak windows build
Follow up to
commit 831e99fee90e ("[GVNHoist] don't hoist callbr users into the callbr's block")

Looks like MSVC has trouble with llvm::is_contained. Unbreak the build.

Link: https://lab.llvm.org/buildbot/#/builders/127/builds/45021/steps/7/logs/stdio

Reviewed By: hans, kuhar

Differential Revision: https://reviews.llvm.org/D145969
2023-03-13 11:22:49 -07:00
Nick Desaulniers
831e99fee9 [GVNHoist] don't hoist callbr users into the callbr's block
This isn't safe to do.

Link: https://github.com/llvm/llvm-project/issues/53562
Fixes: https://github.com/llvm/llvm-project/issues/61023

Reviewed By: efriedma, nikic

Differential Revision: https://reviews.llvm.org/D144927
2023-03-13 10:20:57 -07:00
Zequan Wu
528c53ee28 Revert "[LowerTypeTests] Avoid creation of select constant expression"
This reverts commit 0317147a2848547ec97d8e76782f7dc38267a21f.

It causes broken module error when building chromium media_unittests
PHI nodes not grouped at top of basic block!
%19 = phi ptr [ %16, %15 ], [ %18, %12 ], !dbg !16
label %17
LLVM ERROR: Broken module found, compilation aborted!
2023-03-13 12:46:59 -04:00
Arthur Eubanks
d623b2f95f [PassManagerBuilder] Remove PassManagerBuilder
PassManagerBuilder is dead, long live PassBuilder!

bugpoint's -O# are now useless (and probably have been for a while given the number of passes we've removed from PassManagerBuilder). Perhaps they'll be revived if bugpoint ever works with the new PM.

Reviewed By: nikic, MaskRay

Differential Revision: https://reviews.llvm.org/D145835
2023-03-13 09:30:30 -07:00
Alexey Bataev
f3a68ac10c [SLP][NFC]Initial merge of gather/buildvector code in the createBuildVector function.
Required for future changes with combining shuffled nodes and
buildvector sequences to improve cost/emission of the gather nodes.

Part of D110978

Differential Revision: https://reviews.llvm.org/D145732
2023-03-13 06:11:05 -07:00