llvm.org GIT mirror llvm / d07b802
Merging r315086: ------------------------------------------------------------------------ r315086 | compnerd | 2017-10-06 11:06:59 -0700 (Fri, 06 Oct 2017) | 8 lines Bitcode: add an auto-upgrade for LTO section name The bitcode reader looks specifically for `__DATA, __objc_catlist` as a section name. However, SVN r304661 removed the spaces (the two names are functionally equivalent but do not compare equally lexicographically). This causes compatibility issues. Add an auto-upgrade path for removing the spaces as well as use the new name in the LTO plugin. ------------------------------------------------------------------------ git-svn-id: https://llvm.org/svn/llvm-project/llvm/branches/release_50@318851 91177308-0d34-0410-b5e6-96231b3b80d8 Tom Stellard 1 year, 9 months ago
5 changed file(s) with 64 addition(s) and 1 deletion(s). Raw diff Collapse all Expand all
5050 /// module is modified.
5151 bool UpgradeModuleFlags(Module &M);
5252
53 void UpgradeSectionAttributes(Module &M);
54
5355 /// If the given TBAA tag uses the scalar TBAA format, create a new node
5456 /// corresponding to the upgrade to the struct-path aware TBAA format.
5557 /// Otherwise return the \p TBAANode itself.
239239 UpgradeDebugInfo(*M);
240240
241241 UpgradeModuleFlags(*M);
242 UpgradeSectionAttributes(*M);
242243
243244 if (!Slots)
244245 return false;
263263 if (convertToString(Record, 0, S))
264264 return error("Invalid record");
265265 // Check for the i386 and other (x86_64, ARM) conventions
266 if (S.find("__DATA, __objc_catlist") != std::string::npos ||
266 if (S.find("__DATA,__objc_catlist") != std::string::npos ||
267267 S.find("__OBJC,__category") != std::string::npos)
268268 return true;
269269 break;
23042304 return Changed;
23052305 }
23062306
2307 void llvm::UpgradeSectionAttributes(Module &M) {
2308 auto TrimSpaces = [](StringRef Section) -> std::string {
2309 SmallVector Components;
2310 Section.split(Components, ',');
2311
2312 SmallString<32> Buffer;
2313 raw_svector_ostream OS(Buffer);
2314
2315 for (auto Component : Components)
2316 OS << ',' << Component.trim();
2317
2318 return OS.str().substr(1);
2319 };
2320
2321 for (auto &GV : M.globals()) {
2322 if (!GV.hasSection())
2323 continue;
2324
2325 StringRef Section = GV.getSection();
2326
2327 if (!Section.startswith("__DATA, __objc_catlist"))
2328 continue;
2329
2330 // __DATA, __objc_catlist, regular, no_dead_strip
2331 // __DATA,__objc_catlist,regular,no_dead_strip
2332 GV.setSection(TrimSpaces(Section));
2333 }
2334 }
2335
23072336 static bool isOldLoopArgument(Metadata *MD) {
23082337 auto *T = dyn_cast_or_null(MD);
23092338 if (!T)
0 ; RUN: llvm-as %s -o - | llvm-dis - | FileCheck %s
1
2 %struct._class_t = type { %struct._class_t*, %struct._class_t*, %struct._objc_cache*, i8* (i8*, i8*)**, %struct._class_ro_t* }
3 %struct._objc_cache = type opaque
4 %struct._class_ro_t = type { i32, i32, i32, i8*, i8*, %struct.__method_list_t*, %struct._objc_protocol_list*, %struct._ivar_list_t*, i8*, %struct._prop_list_t* }
5 %struct.__method_list_t = type { i32, i32, [0 x %struct._objc_method] }
6 %struct._objc_method = type { i8*, i8*, i8* }
7 %struct._objc_protocol_list = type { i64, [0 x %struct._protocol_t*] }
8 %struct._protocol_t = type { i8*, i8*, %struct._objc_protocol_list*, %struct.__method_list_t*, %struct.__method_list_t*, %struct.__method_list_t*, %struct.__method_list_t*, %struct._prop_list_t*, i32, i32, i8**, i8*, %struct._prop_list_t* }
9 %struct._ivar_list_t = type { i32, i32, [0 x %struct._ivar_t] }
10 %struct._ivar_t = type { i64*, i8*, i8*, i32, i32 }
11 %struct._prop_list_t = type { i32, i32, [0 x %struct._prop_t] }
12 %struct._prop_t = type { i8*, i8* }
13 %struct._category_t = type { i8*, %struct._class_t*, %struct.__method_list_t*, %struct.__method_list_t*, %struct._objc_protocol_list*, %struct._prop_list_t*, %struct._prop_list_t*, i32 }
14
15 @OBJC_CLASS_NAME_ = private unnamed_addr constant [6 x i8] c"Robot\00", section "__TEXT,__objc_classname,cstring_literals", align 1
16 @"OBJC_CLASS_$_I" = external global %struct._class_t
17 @"\01l_OBJC_$_CATEGORY_I_$_Robot" = private global %struct._category_t { i8* getelementptr inbounds ([6 x i8], [6 x i8]* @OBJC_CLASS_NAME_, i32 0, i32 0), %struct._class_t* @"OBJC_CLASS_$_I", %struct.__method_list_t* null, %struct.__method_list_t* null, %struct._objc_protocol_list* null, %struct._prop_list_t* null, %struct._prop_list_t* null, i32 64 }, section "__DATA, __objc_const", align 8
18 @"OBJC_LABEL_CATEGORY_$" = private global [1 x i8*] [i8* bitcast (%struct._category_t* @"\01l_OBJC_$_CATEGORY_I_$_Robot" to i8*)], section "__DATA, __objc_catlist, regular, no_dead_strip", align 8
19 @llvm.compiler.used = appending global [3 x i8*] [i8* bitcast (%struct._category_t* @"\01l_OBJC_$_CATEGORY_I_$_Robot" to i8*), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @OBJC_CLASS_NAME_, i32 0, i32 0), i8* bitcast ([1 x i8*]* @"OBJC_LABEL_CATEGORY_$" to i8*)], section "llvm.metadata"
20
21 !llvm.module.flags = !{!0, !1, !2, !3, !4, !5}
22
23 !0 = !{i32 1, !"Objective-C Version", i32 2}
24 !1 = !{i32 1, !"Objective-C Image Info Version", i32 0}
25 !2 = !{i32 1, !"Objective-C Image Info Section", !"__DATA, __objc_imageinfo, regular, no_dead_strip"}
26 !3 = !{i32 4, !"Objective-C Garbage Collection", i32 0}
27 !4 = !{i32 1, !"Objective-C Class Properties", i32 64}
28 !5 = !{i32 1, !"PIC Level", i32 2}
29
30 ; CHECK: @"OBJC_LABEL_CATEGORY_$" = {{.*}}, section "__DATA,__objc_catlist,regular,no_dead_strip"