This is a patch to reduce the effect that debug intrinsics have on codegen -- there are a few flavours of defect delt with here:
- Setting the DebugLoc of an instruction to one derived from a debug instruction,
- Counting the size of a block to include debug intrinsics,
- Examining debug intrinsics in SLPVectoriser (they should all be ignored)
- Picking an insertion point at a debug intrinsic in SCEVExpander
Not included in this patch are a few scenarios where we insert an existing instruction at a debug intrinsic position: these can have meaningful effects on the stepping behaviour, so we don't want to address them now. The two SCEVExpander scenarios are where the pass is generating new code and doesn't have an opinion on the line numbers.
I haven't written tests for these changes: IMO these changes are obviously correct, and I'd prefer to not test for behaviours that we're actively trying to design away.
It might be to structure this as an if ... else ... so we always test isa<DbgInfoIntrinsic>(&*I) first, instead of unconditionally calling I->getDebugLoc() and then potentially replacing it...? (If you agree, then the same comment applies to quite a few other changes here.)