summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms
diff options
context:
space:
mode:
authorDuncan P. N. Exon Smith <dexonsmith@apple.com>2015-08-04 13:23:30 +0000
committerDuncan P. N. Exon Smith <dexonsmith@apple.com>2015-08-04 13:23:30 +0000
commit5ed90c027882500cd59eb85e36ecb5c8d2d68075 (patch)
treef1e10a86510b4882ccf39e132246c76112aa836f /llvm/lib/Transforms
parent2d6b2f20108b39c4728d0e3cd2ff80fd22d85ff7 (diff)
downloadbcm5719-llvm-5ed90c027882500cd59eb85e36ecb5c8d2d68075.tar.gz
bcm5719-llvm-5ed90c027882500cd59eb85e36ecb5c8d2d68075.zip
Linker: Fix ASan failure from r243961
r243883 and r243961 made a use-after-free far more likely: http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux-fast/builds/6041/steps/check-llvm%20asan/logs/stdio Unresolved nodes get inserted into the `Cycles` array. If they later get resolved through RAUW, we need to update the reference. It's interesting that this never hit before (maybe an asan-ified clang bootstrap with `-flto -g` would have hit it, but I admit I haven't tried anything quite that crazy). llvm-svn: 243976
Diffstat (limited to 'llvm/lib/Transforms')
-rw-r--r--llvm/lib/Transforms/Utils/ValueMapper.cpp20
1 files changed, 11 insertions, 9 deletions
diff --git a/llvm/lib/Transforms/Utils/ValueMapper.cpp b/llvm/lib/Transforms/Utils/ValueMapper.cpp
index 8aa546c7211..3253a75bd44 100644
--- a/llvm/lib/Transforms/Utils/ValueMapper.cpp
+++ b/llvm/lib/Transforms/Utils/ValueMapper.cpp
@@ -156,12 +156,13 @@ static Metadata *mapToSelf(ValueToValueMapTy &VM, const Metadata *MD) {
}
static Metadata *MapMetadataImpl(const Metadata *MD,
- SmallVectorImpl<MDNode *> &Cycles,
+ SmallVectorImpl<TrackingMDNodeRef> &Cycles,
ValueToValueMapTy &VM, RemapFlags Flags,
ValueMapTypeRemapper *TypeMapper,
ValueMaterializer *Materializer);
-static Metadata *mapMetadataOp(Metadata *Op, SmallVectorImpl<MDNode *> &Cycles,
+static Metadata *mapMetadataOp(Metadata *Op,
+ SmallVectorImpl<TrackingMDNodeRef> &Cycles,
ValueToValueMapTy &VM, RemapFlags Flags,
ValueMapTypeRemapper *TypeMapper,
ValueMaterializer *Materializer) {
@@ -189,8 +190,9 @@ static Metadata *mapMetadataOp(Metadata *Op, SmallVectorImpl<MDNode *> &Cycles,
///
/// \pre \c NewNode is a clone of \c OldNode.
static bool remap(const MDNode *OldNode, MDNode *NewNode,
- SmallVectorImpl<MDNode *> &Cycles, ValueToValueMapTy &VM,
- RemapFlags Flags, ValueMapTypeRemapper *TypeMapper,
+ SmallVectorImpl<TrackingMDNodeRef> &Cycles,
+ ValueToValueMapTy &VM, RemapFlags Flags,
+ ValueMapTypeRemapper *TypeMapper,
ValueMaterializer *Materializer) {
assert(OldNode->getNumOperands() == NewNode->getNumOperands() &&
"Expected nodes to match");
@@ -223,7 +225,7 @@ static bool remap(const MDNode *OldNode, MDNode *NewNode,
/// place; effectively, they're moved from one graph to another. Otherwise,
/// they're cloned/duplicated, and the new copy's operands are remapped.
static Metadata *mapDistinctNode(const MDNode *Node,
- SmallVectorImpl<MDNode *> &Cycles,
+ SmallVectorImpl<TrackingMDNodeRef> &Cycles,
ValueToValueMapTy &VM, RemapFlags Flags,
ValueMapTypeRemapper *TypeMapper,
ValueMaterializer *Materializer) {
@@ -241,7 +243,7 @@ static Metadata *mapDistinctNode(const MDNode *Node,
for (Metadata *Op : NewMD->operands())
if (auto *Node = dyn_cast_or_null<MDNode>(Op))
if (!Node->isResolved())
- Cycles.push_back(Node);
+ Cycles.emplace_back(Node);
return NewMD;
}
@@ -250,7 +252,7 @@ static Metadata *mapDistinctNode(const MDNode *Node,
///
/// Uniqued nodes may not need to be recreated (they may map to themselves).
static Metadata *mapUniquedNode(const MDNode *Node,
- SmallVectorImpl<MDNode *> &Cycles,
+ SmallVectorImpl<TrackingMDNodeRef> &Cycles,
ValueToValueMapTy &VM, RemapFlags Flags,
ValueMapTypeRemapper *TypeMapper,
ValueMaterializer *Materializer) {
@@ -270,7 +272,7 @@ static Metadata *mapUniquedNode(const MDNode *Node,
}
static Metadata *MapMetadataImpl(const Metadata *MD,
- SmallVectorImpl<MDNode *> &Cycles,
+ SmallVectorImpl<TrackingMDNodeRef> &Cycles,
ValueToValueMapTy &VM, RemapFlags Flags,
ValueMapTypeRemapper *TypeMapper,
ValueMaterializer *Materializer) {
@@ -323,7 +325,7 @@ static Metadata *MapMetadataImpl(const Metadata *MD,
Metadata *llvm::MapMetadata(const Metadata *MD, ValueToValueMapTy &VM,
RemapFlags Flags, ValueMapTypeRemapper *TypeMapper,
ValueMaterializer *Materializer) {
- SmallVector<MDNode *, 8> Cycles;
+ SmallVector<TrackingMDNodeRef, 8> Cycles;
Metadata *NewMD =
MapMetadataImpl(MD, Cycles, VM, Flags, TypeMapper, Materializer);
OpenPOWER on IntegriCloud