llvm-project/llvm/test/Transforms
hyeongyu kim 0aeb37324d [SimpleLoopUnswitch] Re-fix introduction of UB when hoisted condition may be undef or poison
https://bugs.llvm.org/show_bug.cgi?id=27506
https://bugs.llvm.org/show_bug.cgi?id=31652
https://bugs.llvm.org/show_bug.cgi?id=51043

Problems with SimpleLoopUnswitch cause the bug reports above.

```
while (...) {
  if (C) { A }
  else   { B }
}
Into:

C' = freeze(C)
if (C') {
  while (...) { A }
} else {
  while (...) { B }
}
```
This problem can be solved by adding a freeze on hoisted branches(above transform) and has been solved by D29015.
However, D29015 is now reverted by performance regression(2b5a897651)

It is not the first time that an added freeze has caused performance regression.
SimplifyCFG also had a problem with UB caused by branching-on-undef, which was solved by adding freeze to the branching condition. (D104569)
Performance regression occurred in D104569, and patches such as D105344 and D105392 were written to minimize it.

This patch will correct the SimpleLoopUnswitch as D104569 handles the SimplyCFG while minimizing performance loss by introducing patches like D105344 and D105392(This patch was rebased with the author's permission)

Reviewed By: reames

Differential Revision: https://reviews.llvm.org/D106041
2021-10-12 01:02:09 +09:00
..
ADCE [test] Update some test cases to use -passes when specifying the pipeline 2021-09-29 21:51:08 +02:00
AddDiscriminators [test] Update some test cases to use -passes when specifying the pipeline 2021-09-29 21:51:08 +02:00
AggressiveInstCombine [test] Update some test cases to use -passes when specifying the pipeline 2021-09-29 21:51:08 +02:00
AlignmentFromAssumptions [test] Update some test cases to use -passes when specifying the pipeline 2021-09-29 21:51:08 +02:00
ArgumentPromotion [test] Update some test cases to use -passes when specifying the pipeline 2021-09-29 21:51:08 +02:00
AtomicExpand [PowerPC] Add lit.local.cfg in AtomicExpand tests 2021-07-20 09:13:50 +00:00
Attributor Reland [IR] Increase max alignment to 4GB 2021-10-06 13:29:23 -07:00
BDCE [test] Update some test cases to use -passes when specifying the pipeline 2021-09-29 21:51:08 +02:00
BlockExtractor
BranchFolding
CallSiteSplitting
CalledValuePropagation [test] Update some test cases to use -passes when specifying the pipeline 2021-09-29 21:51:08 +02:00
CanonicalizeAliases
CanonicalizeFreezeInLoops [AArch64] Make -mcpu=generic schedule for an in-order core 2021-10-09 15:58:31 +01:00
CodeExtractor [CodeExtractor] Preserve topological order for the return blocks. 2021-08-25 08:09:01 -07:00
CodeGenPrepare [AArch64] Make -mcpu=generic schedule for an in-order core 2021-10-09 15:58:31 +01:00
ConstantHoisting [RISCV] Add zext.h/zext.w to RISCVTTIImpl::getIntImmCostInst. 2021-08-18 09:40:40 -07:00
ConstantMerge
ConstraintElimination [ConstraintElimination] Rewrite tests to reduce verification complexity. 2021-08-26 16:41:40 +01:00
Coroutines [cora async] Cleanup undefined llvm.coro.async.resume 2021-09-30 13:26:53 -07:00
CorrelatedValuePropagation Revert "Recommit "Revert "[CVP] processSwitch: Remove default case when switch cover all possible values.""" 2021-09-27 20:39:05 +08:00
CrossDSOCFI
DCE [test] Update some test cases to use -passes when specifying the pipeline 2021-09-29 21:51:08 +02:00
DFAJumpThreading Add jump-threading optimization for deterministic finite automata 2021-07-27 14:34:04 -04:00
DeadArgElim [ObjC][ARC] Use the addresses of the ARC runtime functions instead of 2021-09-08 11:58:03 -07:00
DeadStoreElimination [DSE] Re-enable calloc transformation with extra care (PR25892) 2021-10-10 21:47:14 +02:00
DivRemPairs [DivRemPairs] make sure we have a valid CFG for hoisting division 2021-07-28 11:09:12 -04:00
EarlyCSE [NewPM] Use parameterized syntax for a couple of more passes 2021-08-20 14:59:21 +02:00
EliminateAvailableExternally
EntryExitInstrumenter [NewPM] Use parameterized syntax for a couple of more passes 2021-08-20 14:59:21 +02:00
ExpandMemCmp [x86] split memcmp tests for 32/64-bit targets; NFC 2021-08-15 13:51:18 -04:00
FixIrreducible
Float2Int
ForcedFunctionAttrs
FunctionAttrs [LLVM IR] Allow volatile stores to trap. 2021-07-26 10:51:00 -07:00
FunctionImport Revert "[NFC] remove explicit default value for strboolattr attribute in tests" 2021-05-24 19:43:40 +02:00
FunctionSpecialization [FuncSpec] Don't specialise (or crash) on poison or constexpr values 2021-09-27 14:58:53 +01:00
GCOVProfiling [GCov] Emit memset instead of stores in __llvm_gcov_reset 2021-08-05 22:40:15 -07:00
GVN Reland [IR] Increase max alignment to 4GB 2021-10-06 13:29:23 -07:00
GVNHoist PR46874: Reset stack after visiting a node 2021-08-20 11:25:05 -07:00
GVNSink
GlobalDCE [GlobalDCE] In VFE, replace the whole 'sub' expression of unused relative-pointer-based vtable slots 2021-10-06 15:55:55 -07:00
GlobalMerge
GlobalOpt [IR] Handle large element size when calculating GEP indices 2021-09-24 22:20:20 +02:00
GlobalSplit
GuardWidening [test] Remove -loop-guard-widening legacy PM tests 2021-09-05 11:36:21 -07:00
HardwareLoops [HardwareLoops] Loop guard intrinsic to recognise zext 2021-09-16 08:33:16 +01:00
HelloNew
HotColdSplit [CodeExtractor] Preserve topological order for the return blocks. 2021-08-25 08:09:01 -07:00
IRCE [SCEV] By more careful when traversing phis in isImpliedViaMerge. 2021-05-07 19:52:29 +01:00
IROutliner [IROutliner] Adding supports for multiple exits 2021-09-08 08:58:07 -07:00
IndVarSimplify [Test] Few more symmetrical test for D110517 2021-10-06 19:02:28 +07:00
IndirectBrExpand
InferAddressSpaces [Tests] Fix incorrect noalias metadata 2021-09-18 20:51:00 +02:00
InferFunctionAttrs Replace "CHECK-NOT: #{{.*}}" with same-line positive checks. NFC. 2021-08-05 21:55:23 -07:00
Inline [InlineCost] model calls to llvm.is.constant* more carefully 2021-10-08 15:27:30 -07:00
InstCombine [InstCombine] add tests for (X - Y) == 0; NFC 2021-10-10 11:13:46 -04:00
InstMerge
InstNamer
InstSimplify [InstSimplify] (x || y) && (x || !y) --> x 2021-10-07 12:25:25 -04:00
InterleavedAccess [InterleaveAccess] Copy fast math flags when adjusting binary operators in interleave access pass 2021-06-17 09:53:33 +01:00
Internalize [IR] Rename `comdat noduplicates` to `comdat nodeduplicate` 2021-07-20 12:47:10 -07:00
JumpThreading [test] autogen a couple of additional tests 2021-10-05 18:58:08 -07:00
LCSSA
LICM [LICM] Bail if checking a global/constant for invariant.start 2021-10-04 14:14:25 -07:00
LoadStoreVectorizer [LSV] Change the default value of InstertElement to poison 2021-10-03 17:57:34 +09:00
LoopBoundSplit [LoopBoundSplit] Handle the case in which exiting block is loop header 2021-10-08 09:13:41 +01:00
LoopDataPrefetch [LoopDataPrefetch] Add missed LoopSimplify dependence for prefetch pass 2021-08-26 21:01:59 +08:00
LoopDeletion [LoopDeletion] Support selects when symbolically evaluating 1st iteration 2021-10-09 14:47:44 +07:00
LoopDistribute Recommit "[LAA] Support pointer phis in loop by analyzing each incoming pointer." 2021-09-14 11:19:12 +01:00
LoopFlatten [LoopFlatten] Bail if we can't perform flattening after IV widening 2021-09-29 19:53:34 +01:00
LoopFusion
LoopIdiom [LoopIdiom] Fix store size SCEV type. 2021-10-11 09:39:06 +02:00
LoopInstSimplify
LoopInterchange [LoopInterchange] Check lcssa phis in the inner latch in scenarios of multi-level nested loops 2021-07-16 11:59:20 -04:00
LoopLoadElim
LoopPredication [BPI] Keep BPI available in loop passes through LoopStandardAnalysisResults 2021-09-30 10:27:05 -04:00
LoopReroll [SCEV] Fix unsound reasoning in howManyLessThans 2021-07-15 10:32:47 -07:00
LoopRotate [LoopRotate] Forget SCEV values in RewriteUsesOfClonedInstructions 2021-10-07 19:36:30 +02:00
LoopSimplify [test] Fixup tests with -analyze in llvm/test/Transforms 2021-09-04 16:45:51 -07:00
LoopSimplifyCFG [Tests] Remove explicit -enable-mssa-loop-dependency options (NFC) 2021-08-14 21:21:07 +02:00
LoopStrengthReduce [AArch64] Make -mcpu=generic schedule for an in-order core 2021-10-09 15:58:31 +01:00
LoopTransformWarning
LoopUnroll [Test] Add commit justifying revert of D110922 2021-10-09 14:32:46 +07:00
LoopUnrollAndJam [LoopUnrollAndJam] Change LoopUnrollAndJamPass to LoopNest pass 2021-06-08 20:30:02 +09:00
LoopUnswitch [Tests] Remove explicit -enable-mssa-loop-dependency options (NFC) 2021-08-14 21:21:07 +02:00
LoopVectorize [LoopVectorize] Permit vectorisation of more select(cmp(), X, Y) reduction patterns 2021-10-11 09:41:38 +01:00
LoopVersioning [SCEVExpander] Simplify pointer overflow check 2021-09-02 20:15:59 +02:00
LoopVersioningLICM [LICM] Remove AST-based implementation 2021-08-18 20:21:53 +02:00
LowerAtomic
LowerConstantIntrinsics [LowerConstantIntrinsics] Fix heap-use-after-free bug in worklist 2021-09-21 11:33:07 +02:00
LowerExpectIntrinsic
LowerGuardIntrinsic
LowerInvoke
LowerMatrixIntrinsics [Tests] Fix incorrect noalias metadata 2021-09-18 20:51:00 +02:00
LowerSwitch
LowerTypeTests [ConstantFold] Get rid of special cases for sizeof etc. 2021-07-31 13:20:47 -07:00
LowerWidenableCondition
MakeGuardsExplicit
Mem2Reg [Mem2Reg] Regenerate test checks (NFC) 2021-06-21 11:06:28 +02:00
MemCpyOpt [OpaquePtr] Forbid mixing typed and opaque pointers 2021-09-10 15:18:23 +02:00
MergeFunc
MergeICmps [MergeICmps] Don't reorder unmerged comparisons 2021-09-21 21:22:12 +02:00
MetaRenamer
NameAnonGlobals
NaryReassociate
NewGVN [MemorySSA] Support invariant.group metadata 2021-09-08 13:06:12 -07:00
ObjCARC [ObjC][ARC] Use the addresses of the ARC runtime functions instead of 2021-09-08 11:58:03 -07:00
OpenMP Reland [IR] Increase max alignment to 4GB 2021-10-06 13:29:23 -07:00
PGOProfile [InstrProfiling] Keep profd non-private for non-renamable comdat functions 2021-08-24 20:14:03 -07:00
PartialInlining
PartiallyInlineLibCalls [PartiallyInlineLibCalls] Disable sqrt expansion for strictfp. 2021-06-17 14:15:12 -07:00
PhaseOrdering Re-apply "[JumpThreading] Ignore free instructions" 2021-09-24 18:52:30 +02:00
PlaceSafepoints
PreISelIntrinsicLowering
PruneEH [NewPM] Consistently use 'simplifycfg' rather than 'simplify-cfg' 2021-07-09 09:47:03 +02:00
Reassociate Partial Reapply "[DebugInfo] Use variadic debug values to salvage BinOps and GEP instrs with non-const operands" 2021-06-24 09:46:38 +01:00
Reg2Mem [test] Update some test cases to use -passes when specifying the pipeline 2021-09-29 21:51:08 +02:00
RelLookupTableConverter/X86
RewriteStatepointsForGC [Tests] Fix incorrect noalias metadata 2021-09-18 20:51:00 +02:00
SCCP [ConstantFold] ConstantFoldGetElementPtr - use APInt::isNegative() instead of getSExtValue() to support big ints 2021-09-24 18:18:53 +01:00
SLPVectorizer [SCEV] Infer flags from add/gep in any block 2021-10-06 11:11:54 -07:00
SROA [IR] Add helper to convert offset to GEP indices 2021-09-20 20:18:16 +02:00
SafeStack [SafeStack] Use proper API to get stack guard 2021-05-30 00:52:48 -07:00
SampleProfile [CSSPGO] Set PseudoProbeInserter as a default pass. 2021-09-22 09:09:48 -07:00
ScalarizeMaskedMemIntrin
Scalarizer Update @llvm.powi to handle different int sizes for the exponent 2021-06-17 09:38:28 +02:00
SeparateConstOffsetFromGEP SeparateConstOffsetFromGEP: Fix stack overflow in unreachable code 2021-09-14 19:49:38 -04:00
SimpleLoopUnswitch [SimpleLoopUnswitch] Re-fix introduction of UB when hoisted condition may be undef or poison 2021-10-12 01:02:09 +09:00
SimplifyCFG [SimplifyCFG] Ignore free instructions when computing cost for folding branch to common dest 2021-09-22 09:52:37 -07:00
Sink
SpeculativeExecution
StraightLineStrengthReduce Revert "[NFC] remove explicit default value for strboolattr attribute in tests" 2021-05-24 19:43:40 +02:00
StripDeadPrototypes
StripSymbols
StructurizeCFG Revert "[NFC] remove explicit default value for strboolattr attribute in tests" 2021-05-24 19:43:40 +02:00
SyntheticCountsPropagation
TailCallElim [ObjC][ARC] Use the addresses of the ARC runtime functions instead of 2021-09-08 11:58:03 -07:00
ThinLTOBitcodeWriter ThinLTO: Fix inline assembly references to static functions with CFI 2021-08-03 11:35:30 -07:00
TypePromotion/ARM [ARM][TypePromotion] Re-generate test checks. NFC 2021-08-16 13:42:42 -07:00
UnifyFunctionExitNodes
UnifyLoopExits
Util Improve the effectiveness of BDCE's debug info salvaging 2021-09-30 09:28:49 -07:00
VectorCombine Workaround broken FileCheck default yet another time 2021-10-08 01:24:56 +03:00
WholeProgramDevirt [test] Update some test cases to use -passes when specifying the pipeline 2021-09-29 21:51:08 +02:00