forked from OSchip/llvm-project
[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. llvm-svn: 310967
This commit is contained in:
parent
255387650a
commit
55d93e79df
|
@ -1303,7 +1303,13 @@ public:
|
||||||
if (!Use)
|
if (!Use)
|
||||||
return;
|
return;
|
||||||
*Use = MD;
|
*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!");
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -51,7 +51,12 @@ static cl::opt<bool>
|
||||||
DontPrint("disable-output", cl::desc("Don't output the .ll file"), cl::Hidden);
|
DontPrint("disable-output", cl::desc("Don't output the .ll file"), cl::Hidden);
|
||||||
|
|
||||||
static cl::opt<bool>
|
static cl::opt<bool>
|
||||||
ShowAnnotations("show-annotations",
|
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"));
|
cl::desc("Add informational comments to the .ll file"));
|
||||||
|
|
||||||
static cl::opt<bool> PreserveAssemblyUseListOrder(
|
static cl::opt<bool> PreserveAssemblyUseListOrder(
|
||||||
|
@ -142,9 +147,9 @@ static ExitOnError ExitOnErr;
|
||||||
static std::unique_ptr<Module> openInputFile(LLVMContext &Context) {
|
static std::unique_ptr<Module> openInputFile(LLVMContext &Context) {
|
||||||
std::unique_ptr<MemoryBuffer> MB =
|
std::unique_ptr<MemoryBuffer> MB =
|
||||||
ExitOnErr(errorOrToExpected(MemoryBuffer::getFileOrSTDIN(InputFilename)));
|
ExitOnErr(errorOrToExpected(MemoryBuffer::getFileOrSTDIN(InputFilename)));
|
||||||
std::unique_ptr<Module> M =
|
std::unique_ptr<Module> M = ExitOnErr(getOwningLazyBitcodeModule(
|
||||||
ExitOnErr(getOwningLazyBitcodeModule(std::move(MB), Context,
|
std::move(MB), Context,
|
||||||
/*ShouldLazyLoadMetadata=*/true));
|
/*ShouldLazyLoadMetadata=*/true, SetImporting));
|
||||||
if (MaterializeMetadata)
|
if (MaterializeMetadata)
|
||||||
ExitOnErr(M->materializeMetadata());
|
ExitOnErr(M->materializeMetadata());
|
||||||
else
|
else
|
||||||
|
|
Loading…
Reference in New Issue