llvm-project icon indicating copy to clipboard operation
llvm-project copied to clipboard

[DebugInfo][SimplifyIndVar] Missing debug location updates for overflow/saturation instructions

Open svs-quic opened this issue 2 years ago • 1 comments

There are a couple of instances where the debug information has not been propagated to the new overflow/saturation instructions:

  BinaryOperator *NewResult = BinaryOperator::Create(
      WO->getBinaryOp(), WO->getLHS(), WO->getRHS(), "", WO->getIterator());

.....

  for (auto *U : WO->users()) {
    if (auto *EVI = dyn_cast<ExtractValueInst>(U)) {
      if (EVI->getIndices()[0] == 1)
        EVI->replaceAllUsesWith(ConstantInt::getFalse(WO->getContext()));
      else {
        assert(EVI->getIndices()[0] == 0 && "Only two possibilities!");
        EVI->replaceAllUsesWith(NewResult);
      }
BinaryOperator *BO = BinaryOperator::Create(
      SI->getBinaryOp(), SI->getLHS(), SI->getRHS(), SI->getName(), SI->getIterator());
  if (SI->isSigned())
    BO->setHasNoSignedWrap();
  else
    BO->setHasNoUnsignedWrap();

  SI->replaceAllUsesWith(BO);

svs-quic avatar Jul 08 '24 04:07 svs-quic

@llvm/issue-subscribers-debuginfo

Author: Sudharsan Veeravalli (svs-quic)

There are a couple of instances where the debug information has not been propagated to the new overflow/saturation instructions:
  BinaryOperator *NewResult = BinaryOperator::Create(
      WO-&gt;getBinaryOp(), WO-&gt;getLHS(), WO-&gt;getRHS(), "", WO-&gt;getIterator());

.....

  for (auto *U : WO-&gt;users()) {
    if (auto *EVI = dyn_cast&lt;ExtractValueInst&gt;(U)) {
      if (EVI-&gt;getIndices()[0] == 1)
        EVI-&gt;replaceAllUsesWith(ConstantInt::getFalse(WO-&gt;getContext()));
      else {
        assert(EVI-&gt;getIndices()[0] == 0 &amp;&amp; "Only two possibilities!");
        EVI-&gt;replaceAllUsesWith(NewResult);
      }
BinaryOperator *BO = BinaryOperator::Create(
      SI-&gt;getBinaryOp(), SI-&gt;getLHS(), SI-&gt;getRHS(), SI-&gt;getName(), SI-&gt;getIterator());
  if (SI-&gt;isSigned())
    BO-&gt;setHasNoSignedWrap();
  else
    BO-&gt;setHasNoUnsignedWrap();

  SI-&gt;replaceAllUsesWith(BO);

llvmbot avatar Jul 08 '24 05:07 llvmbot