diff options
| author | 2017-12-24 23:15:17 +0000 | |
|---|---|---|
| committer | 2017-12-24 23:15:17 +0000 | |
| commit | 34091ed6d5747c7d4acdc1ef6af75ce9b7a8adba (patch) | |
| tree | 53479f738fa2c63ce6cf95113985510e3653de23 /gnu/llvm/lib/IR/AutoUpgrade.cpp | |
| parent | Consolidate printf(3) calls at the end of main(). (diff) | |
| download | wireguard-openbsd-34091ed6d5747c7d4acdc1ef6af75ce9b7a8adba.tar.xz wireguard-openbsd-34091ed6d5747c7d4acdc1ef6af75ce9b7a8adba.zip | |
Import LLVM 5.0.1 release including clang, lld and lldb.
Diffstat (limited to 'gnu/llvm/lib/IR/AutoUpgrade.cpp')
| -rw-r--r-- | gnu/llvm/lib/IR/AutoUpgrade.cpp | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/gnu/llvm/lib/IR/AutoUpgrade.cpp b/gnu/llvm/lib/IR/AutoUpgrade.cpp index a501799b479..80640def955 100644 --- a/gnu/llvm/lib/IR/AutoUpgrade.cpp +++ b/gnu/llvm/lib/IR/AutoUpgrade.cpp @@ -2271,6 +2271,24 @@ bool llvm::UpgradeModuleFlags(Module &M) { } } } + // Upgrade Objective-C Image Info Section. Removed the whitespce in the + // section name so that llvm-lto will not complain about mismatching + // module flags that is functionally the same. + if (ID->getString() == "Objective-C Image Info Section") { + if (auto *Value = dyn_cast_or_null<MDString>(Op->getOperand(2))) { + SmallVector<StringRef, 4> ValueComp; + Value->getString().split(ValueComp, " "); + if (ValueComp.size() != 1) { + std::string NewValue; + for (auto &S : ValueComp) + NewValue += S.str(); + Metadata *Ops[3] = {Op->getOperand(0), Op->getOperand(1), + MDString::get(M.getContext(), NewValue)}; + ModFlags->setOperand(I, MDNode::get(M.getContext(), Ops)); + Changed = true; + } + } + } } // "Objective-C Class Properties" is recently added for Objective-C. We @@ -2287,6 +2305,35 @@ bool llvm::UpgradeModuleFlags(Module &M) { return Changed; } +void llvm::UpgradeSectionAttributes(Module &M) { + auto TrimSpaces = [](StringRef Section) -> std::string { + SmallVector<StringRef, 5> Components; + Section.split(Components, ','); + + SmallString<32> Buffer; + raw_svector_ostream OS(Buffer); + + for (auto Component : Components) + OS << ',' << Component.trim(); + + return OS.str().substr(1); + }; + + for (auto &GV : M.globals()) { + if (!GV.hasSection()) + continue; + + StringRef Section = GV.getSection(); + + if (!Section.startswith("__DATA, __objc_catlist")) + continue; + + // __DATA, __objc_catlist, regular, no_dead_strip + // __DATA,__objc_catlist,regular,no_dead_strip + GV.setSection(TrimSpaces(Section)); + } +} + static bool isOldLoopArgument(Metadata *MD) { auto *T = dyn_cast_or_null<MDTuple>(MD); if (!T) |
