summaryrefslogtreecommitdiffstats
path: root/llvm/lib/LTO/ThinLTOCodeGenerator.cpp
diff options
context:
space:
mode:
authorJohan Engelen <jbc.engelen@gmail.com>2017-09-17 17:38:26 +0000
committerJohan Engelen <jbc.engelen@gmail.com>2017-09-17 17:38:26 +0000
commitd3a827126f733c05952184afc6827adb44bffd22 (patch)
tree77b9aa4d3013499d731d026bb7a113d8d29f72ac /llvm/lib/LTO/ThinLTOCodeGenerator.cpp
parentf60ebcda68ff0fa9fc0f2ec21e7a0c083a29e4d0 (diff)
downloadbcm5719-llvm-d3a827126f733c05952184afc6827adb44bffd22.tar.gz
bcm5719-llvm-d3a827126f733c05952184afc6827adb44bffd22.zip
[ThinLTO] Avoid archive member collisions with old API
Summary: ld64 on OSX uses the old ThinLTOCodegenerator API. When two modules have the same name in an archive (valid archive), a name collision happens for the modules' buffer identifiers. This PR resolves this, by suffixing the module name with an increasing number such that the identifiers are guaranteed to be unique. For a similar fix in LLD, see https://reviews.llvm.org/D25495 Reviewers: mehdi_amini, tejohnson Reviewed By: mehdi_amini Subscribers: inglorion, eraman, llvm-commits Differential Revision: https://reviews.llvm.org/D37961 llvm-svn: 313488
Diffstat (limited to 'llvm/lib/LTO/ThinLTOCodeGenerator.cpp')
-rw-r--r--llvm/lib/LTO/ThinLTOCodeGenerator.cpp4
1 files changed, 3 insertions, 1 deletions
diff --git a/llvm/lib/LTO/ThinLTOCodeGenerator.cpp b/llvm/lib/LTO/ThinLTOCodeGenerator.cpp
index ffd78dad922..d6e5d4d0c21 100644
--- a/llvm/lib/LTO/ThinLTOCodeGenerator.cpp
+++ b/llvm/lib/LTO/ThinLTOCodeGenerator.cpp
@@ -535,7 +535,9 @@ static void initTMBuilder(TargetMachineBuilder &TMBuilder,
} // end anonymous namespace
void ThinLTOCodeGenerator::addModule(StringRef Identifier, StringRef Data) {
- ThinLTOBuffer Buffer(Data, Identifier);
+ std::string Id =
+ (Twine(Identifier) + "_" + std::to_string(Modules.size())).str();
+ ThinLTOBuffer Buffer(Data, std::move(Id));
LLVMContext Context;
StringRef TripleStr;
ErrorOr<std::string> TripleOrErr = expectedToErrorOrAndEmitErrors(
OpenPOWER on IntegriCloud