Skip to content

Commit b45efad

Browse files
committed
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 ------------------------------------------------------------------------ llvm-svn: 318850
1 parent f0cacaa commit b45efad

File tree

2 files changed

+22
-2
lines changed

2 files changed

+22
-2
lines changed

llvm/lib/IR/AutoUpgrade.cpp

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2271,6 +2271,24 @@ bool llvm::UpgradeModuleFlags(Module &M) {
22712271
}
22722272
}
22732273
}
2274+
// Upgrade Objective-C Image Info Section. Removed the whitespce in the
2275+
// section name so that llvm-lto will not complain about mismatching
2276+
// module flags that is functionally the same.
2277+
if (ID->getString() == "Objective-C Image Info Section") {
2278+
if (auto *Value = dyn_cast_or_null<MDString>(Op->getOperand(2))) {
2279+
SmallVector<StringRef, 4> ValueComp;
2280+
Value->getString().split(ValueComp, " ");
2281+
if (ValueComp.size() != 1) {
2282+
std::string NewValue;
2283+
for (auto &S : ValueComp)
2284+
NewValue += S.str();
2285+
Metadata *Ops[3] = {Op->getOperand(0), Op->getOperand(1),
2286+
MDString::get(M.getContext(), NewValue)};
2287+
ModFlags->setOperand(I, MDNode::get(M.getContext(), Ops));
2288+
Changed = true;
2289+
}
2290+
}
2291+
}
22742292
}
22752293

22762294
// "Objective-C Class Properties" is recently added for Objective-C. We
Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11
; RUN: llvm-as < %s | llvm-dis | FileCheck %s
22
; RUN: verify-uselistorder < %s
33

4-
!llvm.module.flags = !{!0, !1, !2}
4+
!llvm.module.flags = !{!0, !1, !2, !3}
55

66
!0 = !{i32 1, !"PIC Level", i32 1}
77
!1 = !{i32 1, !"PIE Level", i32 1}
88
!2 = !{i32 1, !"Objective-C Image Info Version", i32 0}
9+
!3 = !{i32 1, !"Objective-C Image Info Section", !"__DATA, __objc_imageinfo, regular, no_dead_strip"}
910

1011
; CHECK: !0 = !{i32 7, !"PIC Level", i32 1}
1112
; CHECK: !1 = !{i32 7, !"PIE Level", i32 1}
1213
; CHECK: !2 = !{i32 1, !"Objective-C Image Info Version", i32 0}
13-
; CHECK: !3 = !{i32 4, !"Objective-C Class Properties", i32 0}
14+
; CHECK: !3 = !{i32 1, !"Objective-C Image Info Section", !"__DATA,__objc_imageinfo,regular,no_dead_strip"}
15+
; CHECK: !4 = !{i32 4, !"Objective-C Class Properties", i32 0}

0 commit comments

Comments
 (0)