llvm-project/llvm/lib/Transforms/Utils
Nikita Popov 835104a114 [LSR] Drop potentially invalid nowrap flags when switching to post-inc IV (PR46943)
When LSR converts a branch on the pre-inc IV into a branch on the
post-inc IV, the nowrap flags on the addition may no longer be valid.
Previously, a poison result of the addition might have been ignored,
in which case the program was well defined. After branching on the
post-inc IV, we might be branching on poison, which is undefined behavior.

Fix this by discarding nowrap flags which are not present on the SCEV
expression. Nowrap flags on the SCEV expression are proven by SCEV
to always hold, independently of how the expression will be used.
This is essentially the same fix we applied to IndVars LFTR, which
also performs this kind of pre-inc to post-inc conversion.

I believe a similar problem can also exist for getelementptr inbounds,
but I was not able to come up with a problematic test case. The
inbounds case would have to be addressed in a differently anyway
(as SCEV does not track this property).

Fixes https://bugs.llvm.org/show_bug.cgi?id=46943.

Differential Revision: https://reviews.llvm.org/D95286
2021-01-25 23:13:48 +01:00
..
AMDGPUEmitPrintf.cpp [NFC][AMDGPU] Reduce include files dependency. 2021-01-07 22:22:05 +03:00
ASanStackFrameLayout.cpp
AddDiscriminators.cpp
AssumeBundleBuilder.cpp [ValueTracking] Use assume's noundef operand bundle 2020-10-14 20:16:33 +09:00
BasicBlockUtils.cpp [SimplifyCFG][BasicBlockUtils] Port SplitBlockPredecessors()/SplitLandingPadPredecessors() to DomTreeUpdater 2021-01-15 23:35:56 +03:00
BreakCriticalEdges.cpp BreakCriticalEdges: do not split the critical edge from a CallBr indirect successor 2021-01-15 13:51:47 -08:00
BuildLibCalls.cpp [Analysis] Support AIX vec_malloc routines 2021-01-22 16:03:01 -05:00
BypassSlowDivision.cpp
CMakeLists.txt [NFC] Move ImportedFunctionsInliningStatistics to Analysis 2021-01-20 13:18:03 -08:00
CallGraphUpdater.cpp [CGSCC][Coroutine][NewPM] Properly support function splitting/outlining 2021-01-06 11:19:15 -08:00
CallPromotionUtils.cpp [llvm] Construct SmallVector with iterator ranges (NFC) 2021-01-20 21:35:52 -08:00
CanonicalizeAliases.cpp
CanonicalizeFreezeInLoops.cpp [ValueTracking] Use assume's noundef operand bundle 2020-10-14 20:16:33 +09:00
CloneFunction.cpp [Utils] Use NoAliasScopeDeclInst in a few more places (NFC) 2021-01-24 16:24:11 +01:00
CloneModule.cpp [Cloning] Copy metadata of global declarations 2021-01-08 08:21:18 +08:00
CodeExtractor.cpp [llvm] Construct SmallVector with iterator ranges (NFC) 2021-01-20 21:35:52 -08:00
CodeMoverUtils.cpp [CodeGen, Transforms] Use llvm::any_of (NFC) 2020-12-24 09:08:36 -08:00
CtorUtils.cpp
Debugify.cpp [llvm] Construct SmallVector with iterator ranges (NFC) 2021-01-16 09:40:53 -08:00
DemoteRegToStack.cpp
EntryExitInstrumenter.cpp Migrate deprecated DebugLoc::get to DILocation::get 2020-12-11 12:45:22 -08:00
EscapeEnumerator.cpp [musttail] Unify musttail call preceding return checking 2020-11-03 11:39:27 -08:00
Evaluator.cpp [CodeGen, Transforms] Use *Map::lookup (NFC) 2020-12-27 09:57:27 -08:00
FixIrreducible.cpp [llvm] Use pop_back_val (NFC) 2021-01-23 10:56:33 -08:00
FlattenCFG.cpp
FunctionComparator.cpp Fix use-of-uninitialized-value in rG75f50e15bf8f 2020-11-26 01:39:22 -07:00
FunctionImportUtils.cpp
GlobalStatus.cpp [globalopt] Teach to look through `addrspacecast`. 2020-10-16 08:43:09 -04:00
GuardUtils.cpp [llvm] Construct SmallVector with iterator ranges (NFC) 2021-01-20 21:35:52 -08:00
InjectTLIMappings.cpp [NFC] Reduce include files dependency. 2020-12-03 18:25:05 +03:00
InlineFunction.cpp Revert "[ObjC][ARC] Annotate calls with attributes instead of emitting retainRV" 2021-01-25 13:53:38 -08:00
InstructionNamer.cpp Port -instnamer to NPM 2020-10-22 12:08:36 -07:00
IntegerDivision.cpp
LCSSA.cpp [llvm] Construct SmallVector with iterator ranges (NFC) 2021-01-16 09:40:53 -08:00
LibCallsShrinkWrap.cpp
Local.cpp [Local] Treat calls that may not return as being alive. 2021-01-23 16:05:14 +00:00
LoopPeel.cpp Loop peeling: check that latch is conditional branch 2021-01-20 11:01:16 -05:00
LoopRotationUtils.cpp [Utils] Use NoAliasScopeDeclInst in a few more places (NFC) 2021-01-24 16:24:11 +01:00
LoopSimplify.cpp [Transforms] Use llvm::append_range (NFC) 2021-01-20 21:35:54 -08:00
LoopUnroll.cpp [Utils] Use NoAliasScopeDeclInst in a few more places (NFC) 2021-01-24 16:24:11 +01:00
LoopUnrollAndJam.cpp [llvm] Use pop_back_val (NFC) 2021-01-23 10:56:33 -08:00
LoopUnrollRuntime.cpp [NFC] Reduce include files dependency and AA header cleanup (part 2). 2020-12-17 14:04:48 +03:00
LoopUtils.cpp [LoopDeletion] Handle inner loops w/untaken backedges 2021-01-22 16:31:29 -08:00
LoopVersioning.cpp [LV] Weaken spuriously strong assert in LoopVersioning 2021-01-12 12:57:13 -08:00
LowerInvoke.cpp [Transforms/Utils] Construct SmallVector with iterator ranges (NFC) 2020-12-29 19:23:23 -08:00
LowerMemIntrinsics.cpp
LowerSwitch.cpp [Transforms] Use llvm::erase_if (NFC) 2020-12-17 19:53:10 -08:00
MatrixUtils.cpp
Mem2Reg.cpp
MetaRenamer.cpp [MetaRenamer][NewPM] Port metarenamer to NPM 2020-10-02 15:42:25 -07:00
ModuleUtils.cpp
NameAnonGlobals.cpp
PredicateInfo.cpp [PredicateInfo] Handle logical and/or 2021-01-20 21:03:07 +01:00
PromoteMemoryToRegister.cpp [STLExtras] Use return type from operator* of the wrapped iter. 2021-01-10 14:41:13 +00:00
SSAUpdater.cpp [Transforms] Use llvm::append_range (NFC) 2021-01-20 21:35:54 -08:00
SSAUpdaterBulk.cpp
SanitizerStats.cpp
ScalarEvolutionExpander.cpp [LSR] Drop potentially invalid nowrap flags when switching to post-inc IV (PR46943) 2021-01-25 23:13:48 +01:00
SimplifyCFG.cpp [NFC][SimplifyCFG] Extract CloneInstructionsIntoPredecessorBlockAndUpdateSSAUses() out of PerformBranchToCommonDestFolding() 2021-01-24 00:54:55 +03:00
SimplifyIndVar.cpp [SimplifyIndVar] createWideIV - make WideIVInfo arg a const ref. NFCI. 2021-01-05 10:31:45 +00:00
SimplifyLibCalls.cpp [InstCombine] remove incompatible attribute when simplifying some lib calls 2021-01-22 17:27:36 -08:00
SizeOpts.cpp
SplitModule.cpp
StripGCRelocates.cpp Port StripGCRelocates pass to NPM 2020-10-07 14:41:29 -07:00
StripNonLineTableDebugInfo.cpp [NPM] Port strip nonlinetable debuginfo pass to the new pass manager 2020-10-07 14:35:36 -07:00
SymbolRewriter.cpp
UnifyFunctionExitNodes.cpp [NPM] Port -mergereturn to NPM 2020-10-20 10:33:58 -07:00
UnifyLoopExits.cpp Remove unnecessary header include which violates layering 2020-10-20 20:14:03 -07:00
UniqueInternalLinkageNames.cpp Add sample-profile-suffix-elision-policy attribute with -funique-internal-linkage-names. 2021-01-12 15:15:53 -08:00
Utils.cpp [NPM] port -unify-loop-exits to NPM 2020-10-20 10:46:57 -07:00
VNCoercion.cpp [VNCoercion] Disallow coercion between different ni addrspaces 2020-12-07 20:19:48 -05:00
ValueMapper.cpp [Transforms] Delete unused declarations from NewGVN/CoroSplit/ValueMapper 2020-12-06 13:04:01 -08:00