[ThinLTO] Support cloning of temporary DILocation metadata
authorTeresa Johnson <tejohnson@google.com>
Mon, 7 Dec 2015 15:05:44 +0000 (15:05 +0000)
committerTeresa Johnson <tejohnson@google.com>
Mon, 7 Dec 2015 15:05:44 +0000 (15:05 +0000)
This is needed to support linking of module-level metadata as a
postpass after function importing, where we will be leaving temporary
metadata on imported instructions until the postpass metadata import.

Also added unittest. Split from D14838.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@254914 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/IR/DebugInfoMetadata.h
unittests/IR/MetadataTest.cpp

index 68a497745ae746acefeacc623bc28a02ad9ad68e..0b3fe06f357679bfd04cdb025f2460c242ab3e3e 100644 (file)
@@ -1118,8 +1118,10 @@ class DILocation : public MDNode {
   }
 
   TempDILocation cloneImpl() const {
-    return getTemporary(getContext(), getLine(), getColumn(), getScope(),
-                        getInlinedAt());
+    // Get the raw scope/inlinedAt since it is possible to invoke this on
+    // a DILocation containing temporary metadata.
+    return getTemporary(getContext(), getLine(), getColumn(), getRawScope(),
+                        getRawInlinedAt());
   }
 
   // Disallow replacing operands.
index da4271a30aea81736e35e81a952f388f3882764c..8f346f53a2d22b72790d74726e071c6473a68484 100644 (file)
@@ -813,6 +813,14 @@ TEST_F(DILocationTest, getTemporary) {
   EXPECT_FALSE(L->isResolved());
 }
 
+TEST_F(DILocationTest, cloneTemporary) {
+  MDNode *N = MDNode::get(Context, None);
+  auto L = DILocation::getTemporary(Context, 2, 7, N);
+  EXPECT_TRUE(L->isTemporary());
+  auto L2 = L->clone();
+  EXPECT_TRUE(L2->isTemporary());
+}
+
 typedef MetadataTest GenericDINodeTest;
 
 TEST_F(GenericDINodeTest, get) {