Skip to content

Commit

Permalink
Destroy ValueNames after all unique_ptr<Value>
Browse files Browse the repository at this point in the history
This UB detected by -fsanitize-memory-use-after-dtor in tensorflow/MLIR.
  • Loading branch information
vitalybuka committed Apr 1, 2022
1 parent d17c7cc commit 0f37afc
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions llvm/lib/IR/LLVMContextImpl.h
Expand Up @@ -1386,6 +1386,8 @@ class LLVMContextImpl {
LLVMContext::YieldCallbackTy YieldCallback = nullptr;
void *YieldOpaqueHandle = nullptr;

DenseMap<const Value *, ValueName *> ValueNames;

using IntMapTy =
DenseMap<APInt, std::unique_ptr<ConstantInt>, DenseMapAPIntKeyInfo>;
IntMapTy IntConstants;
Expand All @@ -1402,8 +1404,6 @@ class LLVMContextImpl {
DenseMap<Value *, ValueAsMetadata *> ValuesAsMetadata;
DenseMap<Metadata *, MetadataAsValue *> MetadataAsValues;

DenseMap<const Value *, ValueName *> ValueNames;

#define HANDLE_MDNODE_LEAF_UNIQUABLE(CLASS) \
DenseSet<CLASS *, CLASS##Info> CLASS##s;
#include "llvm/IR/Metadata.def"
Expand Down

0 comments on commit 0f37afc

Please sign in to comment.