llvm-project/llvm/lib
Roman Lebedev 85334b030a
[NFCI][SCEV] Avoid recursion in SCEVExpander::isHighCostExpansion*()
Summary:
As noted in [[ https://bugs.llvm.org/show_bug.cgi?id=45201 | PR45201 ]],
[[ https://bugs.llvm.org/show_bug.cgi?id=10090 | PR10090 ]] SCEV doesn't
always avoid recursive algorithms, and that causes issues with
large expression depths and/or smaller stack sizes.

In `SCEVExpander::isHighCostExpansion*()` case, the refactoring to avoid
recursion is rather idiomatic. We simply need to place the root expr
into a vector, and iterate over vector elements accounting for the cost
of each one, adding new exprs at the end of the vector,
thus achieving recursion-less traversal.

The order in which we will visit exprs doesn't matter here,
so we will be fine with the most basic approach of using SmallVector
and inserting/extracting from the back, which accidentally is the same
depth-first traversal that we were doing previously recursively.

Reviewers: mkazantsev, reames, wmi, ekatz

Reviewed By: mkazantsev

Subscribers: hiraditya, javed.absar, llvm-commits

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D76273
2020-03-18 17:10:54 +03:00
..
Analysis [NFCI][SCEV] Avoid recursion in SCEVExpander::isHighCostExpansion*() 2020-03-18 17:10:54 +03:00
AsmParser Add debug info support for Swift/Clang APINotes. 2020-03-11 18:47:30 -07:00
BinaryFormat [DebugInfo]: Added DWARFv5 macro header flags and corresponding helper 2020-03-07 17:53:01 +05:30
Bitcode Add debug info support for Swift/Clang APINotes. 2020-03-11 18:47:30 -07:00
Bitstream Revert "Remove redundant "std::move"s in return statements" 2020-02-10 07:07:40 -08:00
CodeGen [IPRA][ARM] Spill extra registers at -Oz 2020-03-18 13:51:16 +00:00
DWARFLinker [DebugInfo] Handle generic type DW_OP_convert ops in dsymutil 2020-03-16 12:16:37 +01:00
DebugInfo Revert "[llvm-objdump] Display locations of variables alongside disassembly" 2020-03-16 14:04:25 -04:00
Demangle Use std::foo_t rather than std::foo in LLVM. 2020-02-11 15:12:51 -08:00
ExecutionEngine [Object] Change ELFObjectFile<ELFT>::getFileFormatName() to use BFD names 2020-03-16 07:42:04 -07:00
Frontend [NFC] Revert unnecessary parts of b91c267380 2020-02-15 01:38:58 -06:00
FuzzMutate Make llvm::StringRef to std::string conversions explicit. 2020-01-28 23:25:25 +01:00
Fuzzer
IR [DwarfDebug] Fix an assertion error when emitting call site info that combines two DW_OP_stack_values 2020-03-17 12:51:49 -07:00
IRReader
LTO [LTO] onfig::addSaveTemps: clear ResolutionFile upon an error 2020-03-02 17:49:04 -08:00
LineEditor Make llvm::StringRef to std::string conversions explicit. 2020-01-28 23:25:25 +01:00
Linker IR Linking: Support merging Warning+Max module metadata flags 2020-02-07 16:29:58 -08:00
MC [MC] Recalculate fragment offsets after relaxation 2020-03-17 14:48:05 -07:00
MCA Revert "Remove redundant "std::move"s in return statements" 2020-02-10 07:07:40 -08:00
Object Drop a StringMap.h include, NFC 2020-03-11 15:45:34 -07:00
ObjectYAML [yaml2obj] - Add `ELFYAML::YAMLIntUInt` to fix how we parse a relocation `Addend` key. 2020-03-17 14:22:19 +03:00
Option Make llvm::StringRef to std::string conversions explicit. 2020-01-28 23:25:25 +01:00
Passes [memtag] Plug in stack safety analysis. 2020-03-16 16:35:25 -07:00
ProfileData [Coverage] Collect all function records in an object (D69471 followup) 2020-03-02 12:01:09 -08:00
Remarks Revert "Remove redundant "std::move"s in return statements" 2020-02-10 07:07:40 -08:00
Support [Support] Change isatty to is_displayed 2020-03-16 18:27:43 -07:00
TableGen Explicitly include <cassert> when using assert 2020-03-02 22:45:28 +01:00
Target [IPRA][ARM] Spill extra registers at -Oz 2020-03-18 13:51:16 +00:00
Testing
TextAPI [llvm][MachO] fix adding weak def syms 2020-03-02 17:00:24 -08:00
ToolDrivers [llvm] Replace SmallStr.str().str() with std::string conversion operator. 2020-01-29 21:16:46 -08:00
Transforms [InstCombine][X86] simplifyX86varShift - convert variable in-range per-element shift amounts to generic shifts (PR40391) 2020-03-18 11:26:54 +00:00
WindowsManifest Try to fix WindowsManifest CMake logic on Windows 2020-02-28 17:24:03 -08:00
XRay Use std::foo_t rather than std::foo in LLVM. 2020-02-11 15:12:51 -08:00
CMakeLists.txt [Dsymutil][Debuginfo][NFC] Reland: Refactor dsymutil to separate DWARF optimizing part. #2. 2020-01-08 14:15:31 +03:00
LLVMBuild.txt [Dsymutil][Debuginfo][NFC] Reland: Refactor dsymutil to separate DWARF optimizing part. #2. 2020-01-08 14:15:31 +03:00