This is an archive of the discontinued LLVM Phabricator instance.

[DebugInfo] Call site entries cannot be generated for FrameSetup calls
ClosedPublic

Authored by lewis-revill on Dec 17 2019, 1:52 AM.

Details

Summary

Instructions marked as FrameSetup do not cause requestLabelAfterInsn to be called and so no such label is generated. Call instructions which require call site entries to be generated require this label to be present in order to calculate the return PC offset/address, but the check for whether the call instruction is marked as FrameSetup was not present.

Therefore in the case where a call instruction is marked as FrameSetup, an assertion failure occurs if a call site entry is to be generated. This is the case with RISC-V's implementation of save/restore via library calls (see https://reviews.llvm.org/D62686).

Diff Detail

Event Timeline

lewis-revill created this revision.Dec 17 2019, 1:52 AM
shiva0217 accepted this revision.Jan 7 2020, 9:24 PM

LGTM, Labels required to describe call site scope will be generated for the calls after FrameSetup instructions. When the SaveLibcall mark as FrameSetup, the Label will not be generated, so constructing call site entry for SaveLibcall will trigger an assertion. Given that SaveLibcall should be part of the prologue, so I think generating call site begin after FrameSetup instructions should be reasonable. But I hope there could be a second look.

This revision is now accepted and ready to land.Jan 7 2020, 9:24 PM
dblaikie added a project: debug-info.

What about going the other way, and making sure instructions in frame setup that need labels get them?

Please add a test case.

What about going the other way, and making sure instructions in frame setup that need labels get them?

I guess it depends if people think there is an advantage to having compiler generated calls within frame setup labelled with DW_AT_return_pc. I don't know debug information well enough to say if it makes sense or not.

Please add a test case.

I think adding a test case would make this patch and save/restore codependent, unless there is another way to generate a call marked as frame-setup.

What about going the other way, and making sure instructions in frame setup that need labels get them?

I guess it depends if people think there is an advantage to having compiler generated calls within frame setup labelled with DW_AT_return_pc. I don't know debug information well enough to say if it makes sense or not.

Would be good to rope someone who is familiar to chime in on this review, then.

Please add a test case.

I think adding a test case would make this patch and save/restore codependent, unless there is another way to generate a call marked as frame-setup.

It's not uncommon that a test in one feature might need to depend on certain functionality in another feature (most abundantly - LLVM IR parsing/emission is exercised in lots of other tests). Is the codependence you're referring to likely to be especially brittle? (are there no simple, unambiguous cases that would trigger this codepath for testing that aren't likely to be purturbed by improvements/changes to save/restore?)

If this depends on another patch please make a proper stack.
Anyhow, when we have the stack of patches (we would know that this goes after the feature you are mentioning), we could have the testcase as well.

It's hard for me to imagine a case where a frame-setup prologue requires a call that really wants debug info. For the save/restore example in D62686, the calls are to system/library helpers to support a size optimization, and as such seem like an implementation detail (along the lines of, say, implementing integer divide as a lib call when you don't have a hardware instruction). So, skipping FrameSetup instructions seems like the right tactic, although the justification in the comment isn't really the right reason.

I can see that a test here could depend on save/restore landing first, but I don't see them as co-dependent. The other one introduces the calls that become an issue for debug info, this one fixes the debug-info issue.

vsk added a comment.Feb 3 2020, 12:57 PM

It's hard for me to imagine a case where a frame-setup prologue requires a call that really wants debug info.

+ 1, I think what this patch is trying to do makes sense.

For the save/restore example in D62686, the calls are to system/library helpers to support a size optimization, and as such seem like an implementation detail (along the lines of, say, implementing integer divide as a lib call when you don't have a hardware instruction). So, skipping FrameSetup instructions seems like the right tactic, although the justification in the comment isn't really the right reason.

I can see that a test here could depend on save/restore landing first, but I don't see them as co-dependent. The other one introduces the calls that become an issue for debug info, this one fixes the debug-info issue.

Yeah, unless the issue is that the MIR parser won't accept frame-setup <call instruction> right now, but it might be possible to split that part out of the save/restore patch.

Thanks all for the feedback, I'll make this patch depend upon the save/restore feature so that I can add a testcase.

It's hard for me to imagine a case where a frame-setup prologue requires a call that really wants debug info. For the save/restore example in D62686, the calls are to system/library helpers to support a size optimization, and as such seem like an implementation detail (along the lines of, say, implementing integer divide as a lib call when you don't have a hardware instruction). So, skipping FrameSetup instructions seems like the right tactic, although the justification in the comment isn't really the right reason.

What should the comment say?

It's hard for me to imagine a case where a frame-setup prologue requires a call that really wants debug info. For the save/restore example in D62686, the calls are to system/library helpers to support a size optimization, and as such seem like an implementation detail (along the lines of, say, implementing integer divide as a lib call when you don't have a hardware instruction). So, skipping FrameSetup instructions seems like the right tactic, although the justification in the comment isn't really the right reason.

What should the comment say?

Currently, the comment implies that we *would* want to handle these calls, except that we don't have a piece of infrastructure in place yet (i.e., the missing labels). That is, it reads like a FIXME remark. IMO we don't want to handle these calls, even if we did have those labels; that is, skipping these calls is always the right thing to do. I would write the comment as something like:
// Skip instructions marked as frame setup, as they are not interesting to the user.

Updated comment and added brief testcase, which now depends on D62686

vsk accepted this revision.Feb 6 2020, 2:25 PM

LGTM.

This revision was automatically updated to reflect the committed changes.