summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms
diff options
context:
space:
mode:
authorDuncan P. N. Exon Smith <dexonsmith@apple.com>2016-04-03 20:54:51 +0000
committerDuncan P. N. Exon Smith <dexonsmith@apple.com>2016-04-03 20:54:51 +0000
commit756e1c3db452165ddcc8b8d11df8a3d36fd427bb (patch)
tree4fe3249c92551ecf294b1fd977eca881fd54ab55 /llvm/lib/Transforms
parenta997856b3d0610a7db795dbd03c511eabb6d0382 (diff)
downloadbcm5719-llvm-756e1c3db452165ddcc8b8d11df8a3d36fd427bb.tar.gz
bcm5719-llvm-756e1c3db452165ddcc8b8d11df8a3d36fd427bb.zip
ValueMapper: Disallow metadata mapping recursion through mapValue
This adds an assertion to maintain the property from r265273. When Mapper::mapSimpleMetadata calls Mapper::mapValue, it should not find its way back to mapMetadataImpl. This guarantees that mapSimpleMetadata is not involved in any recursion. Since Mapper::mapValue calls out to arbitrary materializers, we need to save a bit on the ValueMap to make this assertion effective. There should be no functionality change here. This co-recursion should already have been impossible. llvm-svn: 265276
Diffstat (limited to 'llvm/lib/Transforms')
-rw-r--r--llvm/lib/Transforms/Utils/ValueMapper.cpp5
1 files changed, 5 insertions, 0 deletions
diff --git a/llvm/lib/Transforms/Utils/ValueMapper.cpp b/llvm/lib/Transforms/Utils/ValueMapper.cpp
index 64ba98e55c9..78f4618aef9 100644
--- a/llvm/lib/Transforms/Utils/ValueMapper.cpp
+++ b/llvm/lib/Transforms/Utils/ValueMapper.cpp
@@ -379,7 +379,11 @@ Optional<Metadata *> Mapper::mapSimpleMetadata(const Metadata *MD) {
return mapToSelf(MD);
if (const auto *VMD = dyn_cast<ValueAsMetadata>(MD)) {
+ // Disallow recursion into metadata mapping through mapValue.
+ VM.disableMapMetadata();
Value *MappedV = mapValue(VMD->getValue());
+ VM.enableMapMetadata();
+
if (VMD->getValue() == MappedV ||
(!MappedV && (Flags & RF_IgnoreMissingEntries)))
return mapToSelf(MD);
@@ -406,6 +410,7 @@ Optional<Metadata *> Mapper::mapSimpleMetadata(const Metadata *MD) {
}
Metadata *Mapper::mapMetadataImpl(const Metadata *MD) {
+ assert(VM.mayMapMetadata() && "Unexpected co-recursion through mapValue");
if (Optional<Metadata *> NewMD = mapSimpleMetadata(MD))
return *NewMD;
OpenPOWER on IntegriCloud