llvm-project/llvm/lib
KAWASHIMA Takahiro 272bc25bc1 [LoopReroll] Fix rerolling loop with use outside the loop
Fixes PR41696

The loop-reroll pass generates an invalid IR (or its assertion
fails in debug build) if values of the base instruction and
other root instructions (terms used in the loop-reroll pass)
are used outside the loop block. See IRs written in PR41696
as examples.

The current implementation of the loop-reroll pass can reroll
only loops that don't have values that are used outside the
loop, except reduced values (the last values of reduction chains).
This is described in the comment of the `LoopReroll::reroll`
function.
https://github.com/llvm/llvm-project/blob/llvmorg-10.0.0/llvm/lib/Transforms/Scalar/LoopRerollPass.cpp#L1600

This is checked in the `LoopReroll::DAGRootTracker::validate`
function.
https://github.com/llvm/llvm-project/blob/llvmorg-10.0.0/llvm/lib/Transforms/Scalar/LoopRerollPass.cpp#L1393

However, the base instruction and other root instructions skip
this check in the validation loop.
https://github.com/llvm/llvm-project/blob/llvmorg-10.0.0/llvm/lib/Transforms/Scalar/LoopRerollPass.cpp#L1229

Moving the check in front of the skip is the logically simplest
fix. However, inserting the check in an earlier stage is better
in terms of compilation time of unrerollable loops. This fix
inserts the check for the base instruction into the function
to validate possible base/root instructions. Check for other
root instructions is unnecessary because they don't match any
base instructions if they have uses outside the loop.

Differential Revision: https://reviews.llvm.org/D79549
2020-05-13 13:03:03 +09:00
..
Analysis [ValueTracking] Fix crash in isGuaranteedNotToBeUndefOrPoison when V is in an unreachable block 2020-05-13 10:16:47 +09:00
AsmParser Add nomerge function attribute to supress tail merge optimization in simplifyCFG 2020-05-12 16:49:20 -07:00
BinaryFormat XCOFF.h - replace StringRef.h include with forward declaration. NFC. 2020-04-23 13:52:48 +01:00
Bitcode Add nomerge function attribute to supress tail merge optimization in simplifyCFG 2020-05-12 16:49:20 -07:00
Bitstream [Bitcode] reserve in front of push_back loops. NFCI. 2020-05-01 15:52:53 +02:00
CodeGen [TargetLoweringObjectFileImpl] Produce .text.hot. instead of .text.hot for -fno-unique-section-names 2020-05-12 14:14:17 -07:00
DWARFLinker Reland D79501 "[DebugInfo] Fix handling DW_OP_call_ref in DWARF64 units." 2020-05-08 09:35:54 -07:00
DebugInfo [DWARF5]: Added support for dumping strx forms in llvm-dwarfdump 2020-05-12 10:29:18 +05:30
Demangle Use std::foo_t rather than std::foo in LLVM. 2020-02-11 15:12:51 -08:00
ExecutionEngine [ORC] Share ownership of JITDylibs between ExecutionSession and 2020-05-10 16:37:17 -07:00
Extensions Update compiler extension integration into the build system 2020-04-24 09:40:14 +02:00
Frontend [cmake] LLVMFrontendOpenMP - fix include/llvm/Frontend/OpenMP header path 2020-04-18 12:31:39 +01:00
FuzzMutate FuzzerCLI.h - reduce StringRef.h include to forward declaration. NFC. 2020-05-12 13:03:50 +01:00
Fuzzer
IR Add nomerge function attribute to supress tail merge optimization in simplifyCFG 2020-05-12 16:49:20 -07:00
IRReader
LTO [LTO] Suppress emission of empty combined module by default 2020-05-04 18:31:09 -07:00
LineEditor
Linker [SVE] Add new VectorType subclasses 2020-04-22 08:59:01 -07:00
MC [XCOFF][AIX] Emit correct alignment for csect 2020-05-11 19:43:10 +00:00
MCA [MCA][InstrBuilder] Correctly mark reserved resources in initializeUsedResources. 2020-05-10 19:25:54 +01:00
Object [Object] Remove unused variable after D79560. NFC. 2020-05-11 13:03:53 +08:00
ObjectYAML [PDB] Remove unique_ptr wrapper around C13 line table subsections 2020-05-02 16:35:07 -07:00
Option
Passes [PassBuilder] Moved ProfileSummaryAnalysis in buildInlinerPipeline. 2020-05-12 16:00:40 +00:00
ProfileData [gcov] Emit GCOV_TAG_OBJECT_SUMMARY/GCOV_TAG_PROGRAM_SUMMARY correctly and fix llvm-cov's decoding of runcount 2020-05-11 21:53:53 -07:00
Remarks RemarkStringTable.h - reduce StringRef/Remark includes to forward declarations. NFC 2020-05-08 12:30:49 +01:00
Support [YAMLVFSWriter] Fix for delimiters 2020-05-12 15:43:10 -07:00
TableGen [TableGen] Simplify with TGParser::consume() 2020-04-26 15:26:49 -07:00
Target [AMDGPU] Make v4i64/v4f64/v8i64/v8f64 legal 2020-05-12 16:05:12 -07:00
Testing
TextAPI [cmake] Add headers in TextAPI/Elf and TextAPI/MachO subdirectories 2020-04-24 18:42:44 +01:00
ToolDrivers [COFF] Use Expected in COFFObjectFile creation 2020-05-08 14:22:28 -07:00
Transforms [LoopReroll] Fix rerolling loop with use outside the loop 2020-05-13 13:03:03 +09:00
WindowsManifest Try to fix WindowsManifest CMake logic on Windows 2020-02-28 17:24:03 -08:00
XRay [Object] Change ObjectFile::getSymbolValue() return type to Expected<uint64_t> 2020-05-02 14:04:44 +08:00
CMakeLists.txt Update compiler extension integration into the build system 2020-04-24 09:40:14 +02:00
LLVMBuild.txt Update compiler extension integration into the build system 2020-04-24 09:40:14 +02:00