mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
Lazily Associated a SILRemarkStreamer with an LLVMContext at IRGen time
Corrects a mistake introduced in #31106 I was under the impression that the LLVMContext for an instance of llvm::remarks::RemarkStreamer was somehow just scratch-space. It turns out the ASMPrinters don't gather remarks data from modules, they gather it from the remark streamer associated with the module's context. Thus, we cannot have the module's context be distinct from whatever context the streamer is eventually associated with. In order to bring these two systems back into harmony, introduce a simple ownership contract to SILRemarkStreamer. That is, it starts owned by a SILModule, in which case the SILRemarkStreamer holds onto the underlying LLVM object as the optimizer emits remarks. When it comes time to IRGen the module, then and only then do we install the streamer on the module's context. This tranfers ownership of the underlying LLVM streamer to LLVM itself, so it acts as a consuming operation. When we are about to perform IR Generation, the SILModule will be expiring anyways, so the streamer was already about to be destroyed. We're just putting it to better use doing its job.
This commit is contained in:
@@ -523,6 +523,9 @@ public:
|
||||
swift::SILRemarkStreamer *getSILRemarkStreamer() {
|
||||
return silRemarkStreamer.get();
|
||||
}
|
||||
std::unique_ptr<swift::SILRemarkStreamer> takeSILRemarkStreamer() {
|
||||
return std::move(silRemarkStreamer);
|
||||
}
|
||||
void installSILRemarkStreamer();
|
||||
|
||||
// This is currently limited to VarDecl because the visibility of global
|
||||
|
||||
Reference in New Issue
Block a user