[PATCH] D14682: Fix mapping of unmaterialized global values during metadata linking
Teresa Johnson via llvm-commits
llvm-commits at lists.llvm.org
Sun Nov 15 06:52:54 PST 2015
This revision was automatically updated to reflect the committed changes.
Closed by commit rL253170: Fix mapping of unmaterialized global values during metadata linking (authored by tejohnson).
Changed prior to commit:
http://reviews.llvm.org/D14682?vs=40215&id=40238#toc
Repository:
rL LLVM
http://reviews.llvm.org/D14682
Files:
llvm/trunk/include/llvm/Transforms/Utils/ValueMapper.h
llvm/trunk/lib/Linker/LinkModules.cpp
llvm/trunk/lib/Transforms/Utils/ValueMapper.cpp
Index: llvm/trunk/include/llvm/Transforms/Utils/ValueMapper.h
===================================================================
--- llvm/trunk/include/llvm/Transforms/Utils/ValueMapper.h
+++ llvm/trunk/include/llvm/Transforms/Utils/ValueMapper.h
@@ -69,6 +69,10 @@
/// Instruct the remapper to move distinct metadata instead of duplicating
/// it when there are module-level changes.
RF_MoveDistinctMDs = 4,
+
+ /// Any global values not in value map are mapped to null instead of
+ /// mapping to self. Illegal if RF_IgnoreMissingEntries is also set.
+ RF_NullMapMissingGlobalValues = 8,
};
static inline RemapFlags operator|(RemapFlags LHS, RemapFlags RHS) {
Index: llvm/trunk/lib/Transforms/Utils/ValueMapper.cpp
===================================================================
--- llvm/trunk/lib/Transforms/Utils/ValueMapper.cpp
+++ llvm/trunk/lib/Transforms/Utils/ValueMapper.cpp
@@ -42,9 +42,16 @@
// Global values do not need to be seeded into the VM if they
// are using the identity mapping.
- if (isa<GlobalValue>(V))
+ if (isa<GlobalValue>(V)) {
+ if (Flags & RF_NullMapMissingGlobalValues) {
+ assert(!(Flags & RF_IgnoreMissingEntries) &&
+ "Illegal to specify both RF_NullMapMissingGlobalValues and "
+ "RF_IgnoreMissingEntries");
+ return nullptr;
+ }
return VM[V] = const_cast<Value*>(V);
-
+ }
+
if (const InlineAsm *IA = dyn_cast<InlineAsm>(V)) {
// Inline asm may need *type* remapping.
FunctionType *NewTy = IA->getFunctionType();
@@ -74,7 +81,8 @@
// correct. For now, just match behaviour from before the metadata/value
// split.
//
- // assert(MappedMD && "Referenced metadata value not in value map");
+ // assert((MappedMD || (Flags & RF_NullMapMissingGlobalValues)) &&
+ // "Referenced metadata value not in value map");
return VM[V] = MetadataAsValue::get(V->getContext(), MappedMD);
}
@@ -184,7 +192,8 @@
// correct. For now, just match behaviour from before the metadata/value
// split.
//
- // llvm_unreachable("Referenced metadata not in value map!");
+ // assert((Flags & RF_NullMapMissingGlobalValues) &&
+ // "Referenced metadata not in value map!");
return nullptr;
}
@@ -305,7 +314,8 @@
// correct. For now, just match behaviour from before the metadata/value
// split.
//
- // assert(MappedV && "Referenced metadata not in value map!");
+ // assert((MappedV || (Flags & RF_NullMapMissingGlobalValues)) &&
+ // "Referenced metadata not in value map!");
if (MappedV)
return mapToMetadata(VM, MD, ValueAsMetadata::get(MappedV));
return nullptr;
Index: llvm/trunk/lib/Linker/LinkModules.cpp
===================================================================
--- llvm/trunk/lib/Linker/LinkModules.cpp
+++ llvm/trunk/lib/Linker/LinkModules.cpp
@@ -1628,8 +1628,9 @@
NamedMDNode *DestNMD = DstM->getOrInsertNamedMetadata(NMD.getName());
// Add Src elements into Dest node.
for (const MDNode *op : NMD.operands())
- DestNMD->addOperand(MapMetadata(op, ValueMap, RF_MoveDistinctMDs,
- &TypeMap, &ValMaterializer));
+ DestNMD->addOperand(MapMetadata(
+ op, ValueMap, RF_MoveDistinctMDs | RF_NullMapMissingGlobalValues,
+ &TypeMap, &ValMaterializer));
}
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D14682.40238.patch
Type: text/x-patch
Size: 3420 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20151115/ecae40bf/attachment.bin>
More information about the llvm-commits
mailing list