This is an archive of the discontinued LLVM Phabricator instance.

[debuginfo][CorrelatedValuePropagation] Missing debug location after replacement in processSRem function
ClosedPublic

Authored by yuanboli233 on Aug 19 2022, 4:06 AM.

Details

Summary

The variable Res is updated, however, the debug location is dropped, According to the LLVM debug location update guideline (https://llvm.org/docs/HowToUpdateDebugInfo.html), it seems that the debug location should be kept.

Here is the optimization result for the test case.

Before:

call void @llvm.assume(i1 %c1), !dbg !16
%rem = srem i8 %x, %y, !dbg !17
call void @llvm.dbg.value(metadata i8 %rem, metadata !12, metadata !DIExpression()), !dbg !17

After

call void @llvm.assume(i1 %c1), !dbg !16
%x.nonneg = sub i8 0, %x, !dbg !17
%y.nonneg = sub i8 0, %y, !dbg !17
%rem1 = urem i8 %x.nonneg, %y.nonneg, !dbg !17
%rem1.neg = sub i8 0, %rem1
call void @llvm.dbg.value(metadata i8 %rem1.neg, metadata !12, metadata !DIExpression()), !dbg !17

It seems that there is no reason to drop the debug location for %rem1.neg

Diff Detail

Event Timeline

yuanboli233 created this revision.Aug 19 2022, 4:06 AM
Herald added a project: Restricted Project. · View Herald TranscriptAug 19 2022, 4:06 AM
Herald added a subscriber: hiraditya. · View Herald Transcript
yuanboli233 requested review of this revision.Aug 19 2022, 4:06 AM
StephenTozer accepted this revision.EditedAug 19 2022, 6:48 AM
StephenTozer added a subscriber: StephenTozer.

Change LGTM, one minor nitpick with the test. Also as a general rule, as per the LLVM Phabricator review guide you should produce the diff with full context (i.e. add -U999999 to the git command).

llvm/test/Transforms/CorrelatedValuePropagation/srem_missing_debugloc.ll
3

There's nothing incorrect with the COM directive here, but it's generally only needed if the commented line actually contains a directive.

30–31

Unless these attributes are necessary for the test, they can be deleted from here and the functions that use them.

This revision is now accepted and ready to land.Aug 19 2022, 6:48 AM

Thanks for the feedback! I was busy over the past few days. I will update the revision on the weekend.

updated the revision based on the previous comments.

jmorse accepted this revision.Aug 30 2022, 6:20 AM

LGTM too

yuanboli233 marked 2 inline comments as done.Sep 1 2022, 2:13 AM

Thanks for the feedback! Can you help me to commit the changes as well?

Thanks for the feedback! Can you help me to commit the changes as well?

Will take care of this, thanks for the patch!