diff options
author | Duncan P. N. Exon Smith <dexonsmith@apple.com> | 2016-04-07 02:10:50 +0000 |
---|---|---|
committer | Duncan P. N. Exon Smith <dexonsmith@apple.com> | 2016-04-07 02:10:50 +0000 |
commit | 45601e867d6990b50b1ad54c8db7bbac0950684d (patch) | |
tree | 883d3ccca6bfa2f8becacb1fe4f47e102c8d462f /llvm/lib/Transforms/Utils/ValueMapper.cpp | |
parent | 1cf67fb9cb9354a296cd41cb6d19e56797606237 (diff) | |
download | bcm5719-llvm-45601e867d6990b50b1ad54c8db7bbac0950684d.tar.gz bcm5719-llvm-45601e867d6990b50b1ad54c8db7bbac0950684d.zip |
Revert "ValueMapper: Make LocalAsMetadata match function-local Values"
This reverts commit r265631, since it caused bot failures:
http://lab.llvm.org:8011/builders/clang-ppc64be-linux/builds/3256
http://lab.llvm.org:8011/builders/clang-cmake-aarch64-42vma/builds/7272
Looks like something is depending on the old behaviour. I'll try to
track it down and recommit.
llvm-svn: 265637
Diffstat (limited to 'llvm/lib/Transforms/Utils/ValueMapper.cpp')
-rw-r--r-- | llvm/lib/Transforms/Utils/ValueMapper.cpp | 54 |
1 files changed, 16 insertions, 38 deletions
diff --git a/llvm/lib/Transforms/Utils/ValueMapper.cpp b/llvm/lib/Transforms/Utils/ValueMapper.cpp index 5a92b4c01c0..59870f81c3b 100644 --- a/llvm/lib/Transforms/Utils/ValueMapper.cpp +++ b/llvm/lib/Transforms/Utils/ValueMapper.cpp @@ -86,9 +86,6 @@ public: /// (not an MDNode, or MDNode::isResolved() returns true). Metadata *mapMetadata(const Metadata *MD); - // Map LocalAsMetadata, which never gets memoized. - Metadata *mapLocalAsMetadata(const LocalAsMetadata &LAM); - private: Value *mapBlockAddress(const BlockAddress &BA); @@ -297,27 +294,18 @@ Value *Mapper::mapValue(const Value *V) { if (const auto *MDV = dyn_cast<MetadataAsValue>(V)) { const Metadata *MD = MDV->getMetadata(); - - // Locals shouldn't be memoized. Return nullptr if mapLocalAsMetadata() - // returns nullptr; otherwise bridge back to the Value hierarchy. - if (auto *LAM = dyn_cast<LocalAsMetadata>(MD)) { - if (auto *MappedMD = mapLocalAsMetadata(*LAM)) { - if (LAM == MappedMD) - return const_cast<Value *>(V); - return MetadataAsValue::get(V->getContext(), MappedMD); - } - return nullptr; - } - // If this is a module-level metadata and we know that nothing at the module // level is changing, then use an identity mapping. - if (Flags & RF_NoModuleLevelChanges) + if (!isa<LocalAsMetadata>(MD) && (Flags & RF_NoModuleLevelChanges)) return VM[V] = const_cast<Value *>(V); - // Map the metadata and turn it into a value. + // FIXME: be consistent with function-local values for LocalAsMetadata by + // returning nullptr when LocalAsMetadata is missing. Adding a mapping is + // expensive. auto *MappedMD = mapMetadata(MD); - if (MD == MappedMD) + if (MD == MappedMD || (!MappedMD && (Flags & RF_IgnoreMissingLocals))) return VM[V] = const_cast<Value *>(V); + return VM[V] = MetadataAsValue::get(V->getContext(), MappedMD); } @@ -635,16 +623,21 @@ Optional<Metadata *> Mapper::mapSimpleMetadata(const Metadata *MD) { if (isa<MDString>(MD)) return mapToSelf(MD); - if (auto *CMD = dyn_cast<ConstantAsMetadata>(MD)) { + if (isa<ConstantAsMetadata>(MD)) if ((Flags & RF_NoModuleLevelChanges)) return mapToSelf(MD); + // FIXME: Assert that this is not LocalAsMetadata. It should be handled + // elsewhere. + if (const auto *VMD = dyn_cast<ValueAsMetadata>(MD)) { // Disallow recursion into metadata mapping through mapValue. VM.disableMapMetadata(); - Value *MappedV = mapValue(CMD->getValue()); + Value *MappedV = mapValue(VMD->getValue()); VM.enableMapMetadata(); - if (CMD->getValue() == MappedV) + // FIXME: Always use "ignore" behaviour. There should only be globals here. + if (VMD->getValue() == MappedV || + (!MappedV && (Flags & RF_IgnoreMissingLocals))) return mapToSelf(MD); return mapToMetadata(MD, MappedV ? ValueAsMetadata::get(MappedV) : nullptr); @@ -666,24 +659,9 @@ Metadata *llvm::MapMetadata(const Metadata *MD, ValueToValueMapTy &VM, return Mapper(VM, Flags, TypeMapper, Materializer).mapMetadata(MD); } -Metadata *Mapper::mapLocalAsMetadata(const LocalAsMetadata &LAM) { - if (Optional<Metadata *> NewMD = VM.getMappedMD(&LAM)) - return *NewMD; - - // Lookup the mapping for the value itself, and return the appropriate - // metadata. - if (Value *V = mapValue(LAM.getValue())) { - if (V == LAM.getValue()) - return const_cast<LocalAsMetadata *>(&LAM); - return ValueAsMetadata::get(V); - } - return nullptr; -} - Metadata *Mapper::mapMetadata(const Metadata *MD) { - if (auto *LAM = dyn_cast<LocalAsMetadata>(MD)) - return mapLocalAsMetadata(*LAM); - + // FIXME: First check for and deal with LocalAsMetadata, so that + // mapSimpleMetadata() doesn't need to deal with it. if (Optional<Metadata *> NewMD = mapSimpleMetadata(MD)) return *NewMD; |