Open Quuxplusone opened 5 years ago
Attached small.bc
(3420 bytes, application/octet-stream): .bc file of the source code
Attached small-opt.bc
(3368 bytes, application/octet-stream): optimized .bc file of source code
The "problem" is not the attribute deduction it is just the first to expose it.
The small-opt.bc source contains this beautiful, dead, and endless looping
basic block that does not adhere to fundamental SSA properties:
; <label>:3: ; preds = %3
%.sroa.0.0.vec.extract = extractelement <2 x i32*> %.sroa.0.8.vec.insert, i32 0
%.sroa.0.8.vec.insert = insertelement <2 x i32*> %.sroa.0.8.vec.insert, i32* %.sroa.0.0.vec.extract, i32 1
%.sroa.0.8.vec.extract = extractelement <2 x i32*> %.sroa.0.8.vec.insert, i32 1
[...]
br label %3
Once that block is analyzed anywhere, things will explode. (In this case
llvm::findScalarElemen(..) in VectorUtils got stuck in an endless loop when it
followed the self referencing insertelement vector).
The culprit here is jump-threading, before that, the IR was valid (or at least
looked that way to me).
I'm not an expert on the jump-threading code so I'd suggest the following:
- could you change the bug title to name the actual problem, maybe something along the lines of: "Jump Threading produces invalid IR in the presence of endless loops"
- we then try to get somebody else to look into it.
Our dominance predicate states that any instruction dominates an instruction in an unreachable block, including other unreachable instructions. (By "unreachable block", I mean a block where there is no CFG path from the entry block of the function to that block.) So the IR is valid, I think, and this is actually a bug in attribute deduction.
Granted, this does come up from time to time as something possibly worth changing; it's an edge case people writing passes often forget.
small.bc
(3420 bytes, application/octet-stream)small-opt.bc
(3368 bytes, application/octet-stream)