Skip to content

Preserve all metadata when removing dead arguments #11414

@llvmbot

Description

@llvmbot
Bugzilla Link 11042
Version trunk
OS All
Reporter LLVM Bugzilla Contributor

Extended Description

At around Line 257 and Line 835, DAE preserves debug locations after removing the dead arguments, by copying the debug location from the old call to the new call. Should we do the same thing for other metadata (e.g. customized metadata) as well? Would it break anything?

Btw, this issue appears in LLVM 2.9 and some earlier versions as well.

Proposed patch:
Index: lib/Transforms/IPO/DeadArgumentElimination.cpp

--- lib/Transforms/IPO/DeadArgumentElimination.cpp (revision 140827)
+++ lib/Transforms/IPO/DeadArgumentElimination.cpp (working copy)
@@ -254,7 +254,14 @@
if (cast(Call)->isTailCall())
cast(New)->setTailCall();
}

  • New->setDebugLoc(Call->getDebugLoc());
  • // by Jingyue

  • // Copy all metadata

  • if (Call->hasMetadata()) {

  •  SmallVector<std::pair<unsigned, MDNode*>, 4> TheMDs;
    
  •  Call->getAllMetadata(TheMDs);
    
  •  for (unsigned i = 0, e = TheMDs.size(); i != e; ++i)
    
  •    New->setMetadata(TheMDs[i].first, TheMDs[i].second);
    
  • }

    Args.clear();

@@ -832,7 +839,14 @@
if (cast(Call)->isTailCall())
cast(New)->setTailCall();
}

  • New->setDebugLoc(Call->getDebugLoc());
  • // by Jingyue

  • // Copy all metadata

  • if (Call->hasMetadata()) {

  •  SmallVector<std::pair<unsigned, MDNode*>, 4> TheMDs;
    
  •  Call->getAllMetadata(TheMDs);
    
  •  for (unsigned i = 0, e = TheMDs.size(); i != e; ++i)
    
  •    New->setMetadata(TheMDs[i].first, TheMDs[i].second);
    
  • }

    Args.clear();

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions