From fda49fdbc8fadb4d3fdf839da37d8543085eb738 Mon Sep 17 00:00:00 2001 From: Teresa Johnson Date: Mon, 7 Dec 2015 15:05:44 +0000 Subject: [PATCH] [ThinLTO] Support cloning of temporary DILocation metadata 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 | 6 ++++-- unittests/IR/MetadataTest.cpp | 8 ++++++++ 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/include/llvm/IR/DebugInfoMetadata.h b/include/llvm/IR/DebugInfoMetadata.h index 68a497745ae..0b3fe06f357 100644 --- a/include/llvm/IR/DebugInfoMetadata.h +++ b/include/llvm/IR/DebugInfoMetadata.h @@ -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. diff --git a/unittests/IR/MetadataTest.cpp b/unittests/IR/MetadataTest.cpp index da4271a30ae..8f346f53a2d 100644 --- a/unittests/IR/MetadataTest.cpp +++ b/unittests/IR/MetadataTest.cpp @@ -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) { -- 2.34.1