[llvm-branch-commits] [llvm-branch] r323854 - Merging r323813:
Hans Wennborg via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Wed Jan 31 01:02:39 PST 2018
Author: hans
Date: Wed Jan 31 01:02:38 2018
New Revision: 323854
URL: http://llvm.org/viewvc/llvm-project?rev=323854&view=rev
Log:
Merging r323813:
------------------------------------------------------------------------
r323813 | tejohnson | 2018-01-30 21:16:32 +0100 (Tue, 30 Jan 2018) | 14 lines
Teach ValueMapper to use ODR uniqued types when available
Summary:
This is exposed during ThinLTO compilation, when we import an alias by
creating a clone of the aliasee. Without this fix the debug type is
unnecessarily cloned and we get a duplicate, undoing the uniquing.
Fixes PR36089.
Reviewers: mehdi_amini, pcc
Subscribers: eraman, JDevlieghere, llvm-commits
Differential Revision: https://reviews.llvm.org/D41669
------------------------------------------------------------------------
Added:
llvm/branches/release_60/test/ThinLTO/X86/Inputs/dicompositetype-unique-alias.ll
- copied unchanged from r323813, llvm/trunk/test/ThinLTO/X86/Inputs/dicompositetype-unique-alias.ll
llvm/branches/release_60/test/ThinLTO/X86/dicompositetype-unique-alias.ll
- copied unchanged from r323813, llvm/trunk/test/ThinLTO/X86/dicompositetype-unique-alias.ll
Modified:
llvm/branches/release_60/ (props changed)
llvm/branches/release_60/lib/Transforms/Utils/ValueMapper.cpp
Propchange: llvm/branches/release_60/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Wed Jan 31 01:02:38 2018
@@ -1,3 +1,3 @@
/llvm/branches/Apple/Pertwee:110850,110961
/llvm/branches/type-system-rewrite:133420-134817
-/llvm/trunk:155241,321751,321789,321791,321806,321862,321870,321872,321878,321980,321991,321993-321994,322003,322016,322053,322056,322103,322106,322108,322123,322131,322223,322272,322313,322372,322473,322623,322644,322724,322767,322875,322878-322879,322900,322904-322905,322973,322993,323034,323190,323307,323331,323355,323369,323371,323384,323469,323515,323582,323671-323672,323706,323710,323810-323811
+/llvm/trunk:155241,321751,321789,321791,321806,321862,321870,321872,321878,321980,321991,321993-321994,322003,322016,322053,322056,322103,322106,322108,322123,322131,322223,322272,322313,322372,322473,322623,322644,322724,322767,322875,322878-322879,322900,322904-322905,322973,322993,323034,323190,323307,323331,323355,323369,323371,323384,323469,323515,323582,323671-323672,323706,323710,323810-323811,323813
Modified: llvm/branches/release_60/lib/Transforms/Utils/ValueMapper.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/release_60/lib/Transforms/Utils/ValueMapper.cpp?rev=323854&r1=323853&r2=323854&view=diff
==============================================================================
--- llvm/branches/release_60/lib/Transforms/Utils/ValueMapper.cpp (original)
+++ llvm/branches/release_60/lib/Transforms/Utils/ValueMapper.cpp Wed Jan 31 01:02:38 2018
@@ -25,6 +25,7 @@
#include "llvm/IR/CallSite.h"
#include "llvm/IR/Constant.h"
#include "llvm/IR/Constants.h"
+#include "llvm/IR/DebugInfoMetadata.h"
#include "llvm/IR/DerivedTypes.h"
#include "llvm/IR/Function.h"
#include "llvm/IR/GlobalAlias.h"
@@ -536,13 +537,23 @@ Optional<Metadata *> MDNodeMapper::tryTo
return None;
}
+static Metadata *cloneOrBuildODR(const MDNode &N) {
+ auto *CT = dyn_cast<DICompositeType>(&N);
+ // If ODR type uniquing is enabled, we would have uniqued composite types
+ // with identifiers during bitcode reading, so we can just use CT.
+ if (CT && CT->getContext().isODRUniquingDebugTypes() &&
+ CT->getIdentifier() != "")
+ return const_cast<DICompositeType *>(CT);
+ return MDNode::replaceWithDistinct(N.clone());
+}
+
MDNode *MDNodeMapper::mapDistinctNode(const MDNode &N) {
assert(N.isDistinct() && "Expected a distinct node");
assert(!M.getVM().getMappedMD(&N) && "Expected an unmapped node");
- DistinctWorklist.push_back(cast<MDNode>(
- (M.Flags & RF_MoveDistinctMDs)
- ? M.mapToSelf(&N)
- : M.mapToMetadata(&N, MDNode::replaceWithDistinct(N.clone()))));
+ DistinctWorklist.push_back(
+ cast<MDNode>((M.Flags & RF_MoveDistinctMDs)
+ ? M.mapToSelf(&N)
+ : M.mapToMetadata(&N, cloneOrBuildODR(N))));
return DistinctWorklist.back();
}
More information about the llvm-branch-commits
mailing list