[llvm-branch-commits] [llvm-branch] r318850 - Merging r313398:
Tom Stellard via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Wed Nov 22 09:43:15 PST 2017
Author: tstellar
Date: Wed Nov 22 09:43:15 2017
New Revision: 318850
URL: http://llvm.org/viewvc/llvm-project?rev=318850&view=rev
Log:
Merging r313398:
------------------------------------------------------------------------
r313398 | steven_wu | 2017-09-15 14:12:14 -0700 (Fri, 15 Sep 2017) | 19 lines
[AutoUpgrade] Fix a compatibility issue with module flag
Summary:
After r304661, module flag to record objective-c image info section is
encoded without whitespaces after comma. The new name is equivalent to
the old one, except that when LTO a module built by old compiler and a
module built by a new compiler, it will fail with conflicting values.
Fix the issue by removing whitespaces in bitcode upgrade path.
rdar://problem/34416934
Reviewers: compnerd
Reviewed By: compnerd
Subscribers: mehdi_amini, hans, llvm-commits
Differential Revision: https://reviews.llvm.org/D37909
------------------------------------------------------------------------
Modified:
llvm/branches/release_50/lib/IR/AutoUpgrade.cpp
llvm/branches/release_50/test/Bitcode/upgrade-module-flag.ll
Modified: llvm/branches/release_50/lib/IR/AutoUpgrade.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/release_50/lib/IR/AutoUpgrade.cpp?rev=318850&r1=318849&r2=318850&view=diff
==============================================================================
--- llvm/branches/release_50/lib/IR/AutoUpgrade.cpp (original)
+++ llvm/branches/release_50/lib/IR/AutoUpgrade.cpp Wed Nov 22 09:43:15 2017
@@ -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
Modified: llvm/branches/release_50/test/Bitcode/upgrade-module-flag.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/release_50/test/Bitcode/upgrade-module-flag.ll?rev=318850&r1=318849&r2=318850&view=diff
==============================================================================
--- llvm/branches/release_50/test/Bitcode/upgrade-module-flag.ll (original)
+++ llvm/branches/release_50/test/Bitcode/upgrade-module-flag.ll Wed Nov 22 09:43:15 2017
@@ -1,13 +1,15 @@
; RUN: llvm-as < %s | llvm-dis | FileCheck %s
; RUN: verify-uselistorder < %s
-!llvm.module.flags = !{!0, !1, !2}
+!llvm.module.flags = !{!0, !1, !2, !3}
!0 = !{i32 1, !"PIC Level", i32 1}
!1 = !{i32 1, !"PIE Level", i32 1}
!2 = !{i32 1, !"Objective-C Image Info Version", i32 0}
+!3 = !{i32 1, !"Objective-C Image Info Section", !"__DATA, __objc_imageinfo, regular, no_dead_strip"}
; CHECK: !0 = !{i32 7, !"PIC Level", i32 1}
; CHECK: !1 = !{i32 7, !"PIE Level", i32 1}
; CHECK: !2 = !{i32 1, !"Objective-C Image Info Version", i32 0}
-; CHECK: !3 = !{i32 4, !"Objective-C Class Properties", i32 0}
+; CHECK: !3 = !{i32 1, !"Objective-C Image Info Section", !"__DATA,__objc_imageinfo,regular,no_dead_strip"}
+; CHECK: !4 = !{i32 4, !"Objective-C Class Properties", i32 0}
More information about the llvm-branch-commits
mailing list