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: [email protected]
        ReportedBy: [email protected]
                CC: [email protected]


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.
_______________________________________________
LLVMbugs mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/llvmbugs

Reply via email to