Fix crash in loop unrolling

Submitted by Rebecca N. Palmer on Jan. 6, 2019, 10:59 a.m.

Details

Message ID d30303fd-6a05-0535-a3cb-2d874d3af42b@zoho.com
State New
Headers show
Series "Fix crash in loop unrolling" ( rev: 1 ) in Beignet

Not browsing as part of any series.

Commit Message

Rebecca N. Palmer Jan. 6, 2019, 10:59 a.m.
LLVM 6+'s llvm::LoopInfo::erase(), unlike its predecessor 
llvm::LoopInfo::markAsRemoved(), doesn't necessarily remove the loop it 
erases from the to-be-processed queue.  Do this explicitly, as trying to 
process an erased (0-block) loop is likely to crash, e.g. in getHeader().

Signed-off-by: Rebecca N. Palmer <rebecca_palmer@zoho.com>
---
Looks like I introduced this (in 6e60548a) - sorry.

Examples at https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=913141

Patch hide | download patch | download mbox

diff --git a/backend/src/llvm/llvm_unroll.cpp b/backend/src/llvm/llvm_unroll.cpp
index 813e116d..f378b63d 100644
--- a/backend/src/llvm/llvm_unroll.cpp
+++ b/backend/src/llvm/llvm_unroll.cpp
@@ -206,6 +206,7 @@  namespace gbe {
             //Don't change the unrollID if doesn't force unroll.
             //setUnrollID(parentL, false);
 #if LLVM_VERSION_MAJOR >= 6
+            LPM.markLoopAsDeleted(*parentL);
             loopInfo.erase(parentL);
 #elif LLVM_VERSION_MAJOR * 10 + LLVM_VERSION_MINOR >= 38
             loopInfo.markAsRemoved(parentL);