This is an archive of the discontinued LLVM Phabricator instance.

[instcombine] Sunk instruction introduces unnecessary poison dbg.value
ClosedPublic

Authored by CarlosAlbertoEnciso on Aug 17 2023, 3:58 AM.

Details

Summary

For the given test case, when the 'int Four = Two;' is sunk into the 'case 0:'
block, the debug value for 'Three' is set incorrectly to 'poison'.

...
int Four = Two;
switch (One) {
  case 0:
    Three = Four;
    break;
...

Diff Detail

Event Timeline

CarlosAlbertoEnciso requested review of this revision.Aug 17 2023, 3:58 AM
aprantl added inline comments.Aug 17 2023, 9:51 AM
llvm/lib/Transforms/InstCombine/InstructionCombining.cpp
3863

Looking at the testcase, this seems good, I just have trouble parsing the comment: what does "preserved from any salvage debug use" mean?

llvm/lib/Transforms/InstCombine/InstructionCombining.cpp
3863

May be changing the comment to:

// For all debug values in the destination block, the sunk instruction
// will still be available, so they do not need to be dropped.

will add clarity.

aprantl accepted this revision.Aug 18 2023, 1:18 PM
This revision is now accepted and ready to land.Aug 18 2023, 1:18 PM

@aprantl Thanks for your valuable review.