Index: llvm/trunk/include/llvm/IR/ValueMap.h =================================================================== --- llvm/trunk/include/llvm/IR/ValueMap.h +++ llvm/trunk/include/llvm/IR/ValueMap.h @@ -93,7 +93,6 @@ MapT Map; Optional MDMap; ExtraData Data; - bool MayMapMetadata = true; public: using key_type = KeyT; @@ -120,10 +119,6 @@ } Optional &getMDMap() { return MDMap; } - bool mayMapMetadata() const { return MayMapMetadata; } - void enableMapMetadata() { MayMapMetadata = true; } - void disableMapMetadata() { MayMapMetadata = false; } - /// Get the mapped metadata, if it's in the map. Optional getMappedMD(const Metadata *MD) const { if (!MDMap) Index: llvm/trunk/lib/Transforms/Utils/ValueMapper.cpp =================================================================== --- llvm/trunk/lib/Transforms/Utils/ValueMapper.cpp +++ llvm/trunk/lib/Transforms/Utils/ValueMapper.cpp @@ -774,20 +774,6 @@ return *getMappedOp(&FirstN); } -namespace { - -struct MapMetadataDisabler { - ValueToValueMapTy &VM; - - MapMetadataDisabler(ValueToValueMapTy &VM) : VM(VM) { - VM.disableMapMetadata(); - } - - ~MapMetadataDisabler() { VM.enableMapMetadata(); } -}; - -} // end anonymous namespace - Optional Mapper::mapSimpleMetadata(const Metadata *MD) { // If the value already exists in the map, use it. if (Optional NewMD = getVM().getMappedMD(MD)) @@ -802,9 +788,6 @@ return const_cast(MD); if (auto *CMD = dyn_cast(MD)) { - // Disallow recursion into metadata mapping through mapValue. - MapMetadataDisabler MMD(getVM()); - // Don't memoize ConstantAsMetadata. Instead of lasting until the // LLVMContext is destroyed, they can be deleted when the GlobalValue they // reference is destructed. These aren't super common, so the extra