[PATCH] D33513: [ThinLTO] Fix ThinLTO crash while destroying context
Charles Saternos via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Aug 15 15:24:12 PDT 2017
ncharlie updated this revision to Diff 111265.
ncharlie added a comment.
oops - forgot a cast
https://reviews.llvm.org/D33513
Files:
include/llvm/IR/Metadata.h
tools/llvm-dis/llvm-dis.cpp
Index: tools/llvm-dis/llvm-dis.cpp
===================================================================
--- tools/llvm-dis/llvm-dis.cpp
+++ tools/llvm-dis/llvm-dis.cpp
@@ -51,9 +51,14 @@
DontPrint("disable-output", cl::desc("Don't output the .ll file"), cl::Hidden);
static cl::opt<bool>
-ShowAnnotations("show-annotations",
- cl::desc("Add informational comments to the .ll file"));
+ SetImporting("set-importing",
+ cl::desc("Set lazy loading to pretend to import a module"),
+ cl::Hidden);
+static cl::opt<bool>
+ ShowAnnotations("show-annotations",
+ cl::desc("Add informational comments to the .ll file"));
+
static cl::opt<bool> PreserveAssemblyUseListOrder(
"preserve-ll-uselistorder",
cl::desc("Preserve use-list order when writing LLVM assembly."),
@@ -142,9 +147,9 @@
static std::unique_ptr<Module> openInputFile(LLVMContext &Context) {
std::unique_ptr<MemoryBuffer> MB =
ExitOnErr(errorOrToExpected(MemoryBuffer::getFileOrSTDIN(InputFilename)));
- std::unique_ptr<Module> M =
- ExitOnErr(getOwningLazyBitcodeModule(std::move(MB), Context,
- /*ShouldLazyLoadMetadata=*/true));
+ std::unique_ptr<Module> M = ExitOnErr(getOwningLazyBitcodeModule(
+ std::move(MB), Context,
+ /*ShouldLazyLoadMetadata=*/true, SetImporting));
if (MaterializeMetadata)
ExitOnErr(M->materializeMetadata());
else
Index: include/llvm/IR/Metadata.h
===================================================================
--- include/llvm/IR/Metadata.h
+++ include/llvm/IR/Metadata.h
@@ -1303,7 +1303,13 @@
if (!Use)
return;
*Use = MD;
- Use = nullptr;
+
+ if (*Use)
+ MetadataTracking::track(*Use);
+
+ Metadata *T = cast<Metadata>(this);
+ MetadataTracking::untrack(T);
+ assert(!Use && "Use is still being tracked despite being untracked!");
}
};
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D33513.111265.patch
Type: text/x-patch
Size: 1941 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170815/b255931a/attachment.bin>
More information about the llvm-commits
mailing list