[PATCH] D17165: Fix cloning of debug info

Yichao Yu via llvm-commits llvm-commits at lists.llvm.org
Thu Feb 11 12:46:28 PST 2016


yuyichao created this revision.
yuyichao added reviewers: pcc, loladiro.
yuyichao added subscribers: vtjnash, carnaval, llvm-commits.
Herald added a subscriber: aemerson.

Export function to clone function debug info and autmatically clone the debug info in CloneModule.

This currently causes a regression in the debug info of the generated code we saves to a file since some of the debug info are not copied. (especially after  http://reviews.llvm.org/D14265)

Test done: The code copied into julia fixes the missing debug info on both x64 and aarch64.


http://reviews.llvm.org/D17165

Files:
  include/llvm/Transforms/Utils/Cloning.h
  lib/Transforms/Utils/CloneFunction.cpp
  lib/Transforms/Utils/CloneModule.cpp

Index: lib/Transforms/Utils/CloneModule.cpp
===================================================================
--- lib/Transforms/Utils/CloneModule.cpp
+++ lib/Transforms/Utils/CloneModule.cpp
@@ -136,6 +136,7 @@
         VMap[&*J] = &*DestI++;
       }
 
+      CloneDebugInfoMetadata(F, &*I, VMap);
       SmallVector<ReturnInst*, 8> Returns;  // Ignore returns cloned.
       CloneFunctionInto(F, &*I, VMap, /*ModuleLevelChanges=*/true, Returns);
     }
Index: lib/Transforms/Utils/CloneFunction.cpp
===================================================================
--- lib/Transforms/Utils/CloneFunction.cpp
+++ lib/Transforms/Utils/CloneFunction.cpp
@@ -187,8 +187,8 @@
 
 // Clone the module-level debug info associated with OldFunc. The cloned data
 // will point to NewFunc instead.
-static void CloneDebugInfoMetadata(Function *NewFunc, const Function *OldFunc,
-                            ValueToValueMapTy &VMap) {
+void llvm::CloneDebugInfoMetadata(Function *NewFunc, const Function *OldFunc,
+                                  ValueToValueMapTy &VMap) {
   DebugInfoFinder Finder;
   Finder.processModule(*OldFunc->getParent());
 
Index: include/llvm/Transforms/Utils/Cloning.h
===================================================================
--- include/llvm/Transforms/Utils/Cloning.h
+++ include/llvm/Transforms/Utils/Cloning.h
@@ -130,6 +130,11 @@
                         bool ModuleLevelChanges,
                         ClonedCodeInfo *CodeInfo = nullptr);
 
+// Clone the module-level debug info associated with OldFunc. The cloned data
+// will point to NewFunc instead.
+void CloneDebugInfoMetadata(Function *NewFunc, const Function *OldFunc,
+                            ValueToValueMapTy &VMap);
+
 /// Clone OldFunc into NewFunc, transforming the old arguments into references
 /// to VMap values.  Note that if NewFunc already has basic blocks, the ones
 /// cloned into it will be added to the end of the function.  This function


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D17165.47703.patch
Type: text/x-patch
Size: 1965 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160211/1e084d5c/attachment.bin>


More information about the llvm-commits mailing list