This is an archive of the discontinued LLVM Phabricator instance.

Ignore metainstructions during the shrink wrap analysis
ClosedPublic

Authored by aprantl on Dec 13 2017, 10:21 AM.

Details

Summary

Shrink wrapping should ignore DBG_VALUEs referring to frame indices, since the presence of debug information must not affect code generation.

Diff Detail

Repository
rL LLVM

Event Timeline

This revision is now accepted and ready to land.Dec 13 2017, 10:41 AM
This revision was automatically updated to reflect the committed changes.
thegameg added inline comments.
llvm/trunk/lib/CodeGen/ShrinkWrap.cpp
244

Do we also want to ignore

%csr = IMPLICIT_DEF

?

I remember @MatzeB suggested this approach to me to write cleaner tests.

MatzeB added inline comments.Jan 12 2018, 7:12 AM
llvm/trunk/lib/CodeGen/ShrinkWrap.cpp
244

Should probably do MO.isDef() || MO.readsReg() below instead of this check.

thegameg added inline comments.Jan 16 2018, 3:35 AM
llvm/trunk/lib/CodeGen/ShrinkWrap.cpp
244

That would do it for register operands, but seems that DBG_VALUE instructions also have FrameIndex operands. Is MI.isDebugValue() not enough here?

MatzeB added inline comments.Jan 16 2018, 10:05 AM
llvm/trunk/lib/CodeGen/ShrinkWrap.cpp
244

the operands of DBG_VALUE have MachineOperand::isDebug() set, so readsReg() will always return false for them. The good thing about MachineOperand::readsReg() is that it also checks some other conditions that are often forgotten (such as undef operands or internals reads in bundles, which both are forgotten here as well it seems).

MatzeB added inline comments.Jan 16 2018, 10:09 AM
llvm/trunk/lib/CodeGen/ShrinkWrap.cpp
244

And you are right you probably need an extra MO.isDebugValue() check for the frame index case, didn't realize the code was checking MachineOperand::isFI() here. But in this case I'd move the isDebugValue() check closer to the isFI() check.