[llvm] r310967 - [ThinLTO] Fix ThinLTO crash while destroying context
Charles Saternos via llvm-commits
llvm-commits at lists.llvm.org
Tue Aug 15 15:23:44 PDT 2017
Author: ncharlie
Date: Tue Aug 15 15:23:44 2017
New Revision: 310967
URL: http://llvm.org/viewvc/llvm-project?rev=310967&view=rev
Log:
[ThinLTO] Fix ThinLTO crash while destroying context
Fix for PR32763
An assert that checks if a Ref was untracked fails during ThinLTO context cleanup. The issue is because lazy loading temporary nodes didn't properly track ValueAsMetadata nodes. This patch ensures that the temporary nodes are properly tracked when they're replaced with the value.
Modified:
llvm/trunk/include/llvm/IR/Metadata.h
llvm/trunk/tools/llvm-dis/llvm-dis.cpp
Modified: llvm/trunk/include/llvm/IR/Metadata.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/IR/Metadata.h?rev=310967&r1=310966&r2=310967&view=diff
==============================================================================
--- llvm/trunk/include/llvm/IR/Metadata.h (original)
+++ llvm/trunk/include/llvm/IR/Metadata.h Tue Aug 15 15:23:44 2017
@@ -1303,7 +1303,13 @@ public:
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!");
}
};
Modified: llvm/trunk/tools/llvm-dis/llvm-dis.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-dis/llvm-dis.cpp?rev=310967&r1=310966&r2=310967&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-dis/llvm-dis.cpp (original)
+++ llvm/trunk/tools/llvm-dis/llvm-dis.cpp Tue Aug 15 15:23:44 2017
@@ -51,8 +51,13 @@ static cl::opt<bool>
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",
@@ -142,9 +147,9 @@ static ExitOnError ExitOnErr;
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
More information about the llvm-commits
mailing list