This is an archive of the discontinued LLVM Phabricator instance.

[DebugInfo] Fix incorrect handling of debug values with duplicate location operands
ClosedPublic

Authored by StephenTozer on Jul 12 2021, 11:32 AM.

Details

Summary

This patch fixes several errors found by searching for code that does not correctly handle dbg.values with duplicate operands, such as DIArgList(i32 %a, i32 %a), following from the more specific errors found in D105129.

There are 2 types of errors fixed in this patch:

  • The errors in llvm::salvageDebugInfoForDbgValues and HWAddressSanitizer::instrumentStack are caused by applying an update to the dbg.value for only the first instance of a duplicated operand, when the update needs to be applied for each instance.
  • The errors in HWAddressSanitizer::sanitizeFunction and AArch64StackTagging::runOnFunction are caused by tracking values in the dbg.value that need to be replaced later, and then trying to replace the duplicated operand multiple times when it should only be replaced once.

In the longer term it will probably be easier to prevent duplicated operands from existing at all, but doing so requires further changes to prevent a DIArgList and its associated DIExpression from falling out of sync with each other. This can mostly be handled in DbgVariableIntrinsic and DIArgList::handleUpdatedOperand, but there are exceptions that may require a design change (such as joining the DIArgList and DIExpression in a single MDNode) to be handled in a generalized manner.

Diff Detail

Event Timeline

StephenTozer created this revision.Jul 12 2021, 11:32 AM
StephenTozer requested review of this revision.Jul 12 2021, 11:32 AM
Herald added a project: Restricted Project. · View Herald TranscriptJul 12 2021, 11:32 AM

Basically LGTM.

llvm/lib/Transforms/Utils/Local.cpp
1736

Can we add a comment here by explaining what is the intention of the code below?

llvm/test/CodeGen/AArch64/stack-tagging-dbg.ll
41

nit: This is unused.

Addressed comments: Added comment to explain salvage changes, removed unused metadata entry.

djtodoro accepted this revision.Jul 13 2021, 5:16 AM
This revision is now accepted and ready to land.Jul 13 2021, 5:16 AM
This revision was landed with ongoing or failed builds.Jul 14 2021, 3:19 AM
This revision was automatically updated to reflect the committed changes.