This is an archive of the discontinued LLVM Phabricator instance.

[DAGCombiner] Keep debug information when folding (sext (truncate x)) -> (sextinreg x)
Needs ReviewPublic

Authored by mamai on May 19 2016, 6:57 AM.

Details

Reviewers
probinson
Summary

In the case that there is a debug value on the truncate instruction and none on the sign extend, transfer it from truncate to sign extend so it does not get lost. Also adding a test case showing the debug information in IR will result in a debug value at code generation.

Diff Detail

Repository
rL LLVM

Event Timeline

mamai updated this revision to Diff 57675.May 19 2016, 6:57 AM
mamai retitled this revision from to [DAGCombiner] Keep debug information when folding (sext (truncate x)) -> (sextinreg x).
mamai updated this object.
mamai added a reviewer: probinson.
mamai set the repository for this revision to rL LLVM.
mamai added a subscriber: llvm-commits.

Generally the test case should just test the optimization - no need to go
all the way through codegen, etc.

what's the current behavior if both instructions have a location?

& why is this in an else if block? Why should it not happen if the ifs
above it are true?

mamai added a comment.May 19 2016, 8:36 AM

Good questions.

Generally the test case should just test the optimization - no need to go
all the way through codegen, etc.

I there a way to test only the DAGCombiner ?

what's the current behavior if both instructions have a location?

The behavior (before this patch) was that the debug loc and debug value of the truncate instruction were lost. With this patch, if the truncate has a debug value and the sign extend does not have one, the debug value and debug location of the truncate instruction will replace the ones of the sign extend and therefor they will be forwarded to the new SIGN_EXTEND_INREG.

& why is this in an else if block? Why should it not happen if the ifs
above it are true?

In the case of if/elseif, new nodes are created and they use the SDLoc(N0). So I assumed that in those case, the debug loc of N0 didn't need to be transferred to the sign extension node. But I might be wrong, and it might make sense to transfer the information even with the new nodes using the debug loc of N0. I didn't have a test case for that.