-
Notifications
You must be signed in to change notification settings - Fork 155
fix caching of llvm::ModuleSlotTracker instances #424
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -140,18 +140,10 @@ bool matchesSignature(const llvm::FunctionType *FType1, | |
| return false; | ||
| } | ||
|
|
||
| static llvm::ModuleSlotTracker &getModuleSlotTrackerFor(const llvm::Value *V) { | ||
| static llvm::SmallDenseMap<const llvm::Module *, | ||
| std::unique_ptr<llvm::ModuleSlotTracker>, 2> | ||
| ModuleToSlotTracker; | ||
| llvm::ModuleSlotTracker &getModuleSlotTrackerFor(const llvm::Value *V) { | ||
| const auto *M = getModuleFromVal(V); | ||
|
|
||
| auto &ret = ModuleToSlotTracker[M]; | ||
| if (!ret) { | ||
| ret = std::make_unique<llvm::ModuleSlotTracker>(M); | ||
| } | ||
|
|
||
| return *ret; | ||
| return ModulesToSlotTracker::getSlotTrackerForModule(M); | ||
| } | ||
|
|
||
| std::string llvmIRToString(const llvm::Value *V) { | ||
|
|
@@ -437,4 +429,21 @@ llvm::StringRef getVarAnnotationIntrinsicName(const llvm::CallInst *CallInst) { | |
| return data->getAsCString(); | ||
| } | ||
|
|
||
| llvm::ModuleSlotTracker & | ||
| ModulesToSlotTracker::getSlotTrackerForModule(const llvm::Module *M) { | ||
| auto &ret = MToST[M]; | ||
| if (M == nullptr && ret == nullptr) { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Consider adding an assertion to prevent returning
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yeah that might ease debugging in case it happens. However, if we return nullptr we will get a crash anyway.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. done, see below |
||
| ret = std::make_unique<llvm::ModuleSlotTracker>(M); | ||
| } | ||
| assert(ret != nullptr && "no ModuleSlotTracker instance for module cached"); | ||
| return *ret; | ||
| } | ||
|
|
||
| void ModulesToSlotTracker::updateMSTForModule(const llvm::Module *M) { | ||
| MToST[M] = std::make_unique<llvm::ModuleSlotTracker>(M); | ||
| } | ||
| void ModulesToSlotTracker::deleteMSTForModule(const llvm::Module *M) { | ||
| MToST.erase(M); | ||
| } | ||
|
|
||
| } // namespace psr | ||
Uh oh!
There was an error while loading. Please reload this page.