[LLVMbugs] [Bug 11042] New: Preserve all metadata when removing dead arguments

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Thu Sep 29 17:44:31 PDT 2011


http://llvm.org/bugs/show_bug.cgi?id=11042

           Summary: Preserve all metadata when removing dead arguments
           Product: libraries
           Version: trunk
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Transformation Utilities
        AssignedTo: unassignedbugs at nondot.org
        ReportedBy: wujingyue at gmail.com
                CC: llvmbugs at cs.uiuc.edu


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<CallInst>(Call)->isTailCall())
         cast<CallInst>(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<CallInst>(Call)->isTailCall())
         cast<CallInst>(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();

-- 
Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.



More information about the llvm-bugs mailing list