Details
Diff Detail
- Repository
- rL LLVM
Event Timeline
Matthias,
Juergen is probably more familiar with FastISel than I these days, but the patch itself looks reasonable. I'll let Juergen give the final LGTM, however.
Is the degenerate IR a result of not running the optimizers (i.e., using -O0)? I'm just trying to understand how we arrived at this situation to determine if this really is the correct place to address the problem.
Chad
I should think that if the input IR is legal, LLVM must not crash. Therefore, ultimately this defensive patch seems appropriate.
But this patch is in response to PR24581, which is about a function with 'optnone' attribute. The goal of optnone is to approximate -O0 even if you didn't say -O0. If optnone is running something it should not, or failing to run something it really should, it's worth knowing. The set of transformations that 'optnone' turns off was determined in a very ad-hoc way and it's *very* possible that there's a missing or extra check somewhere. I'd like to see some kind of description of how the IR got into this state (or failed to get out of it).
Yes this code is the result of an optnone attribute. But in any case this is legal IR and SelectionDAG handles this case in the same way[1], so there is no reason for FastISel to produce invalid MI.
[1] SelectionDAGBuilder.cpp:
// Update successor info addSuccessorWithWeight(SwitchBB, CB.TrueBB, CB.TrueWeight); // TrueBB and FalseBB are always different unless the incoming IR is // degenerate. This only happens when running llc on weird IR. if (CB.TrueBB != CB.FalseBB) addSuccessorWithWeight(SwitchBB, CB.FalseBB, CB.FalseWeight);
Obviously, ignore my first comment about deferring to Juergen.. :) This seems quite reasonable.