[PATCH] D24620: Fix autoupgrade logic for Objective-C class properties module flag

Mehdi AMINI via llvm-commits llvm-commits at lists.llvm.org
Thu Sep 15 12:56:47 PDT 2016


mehdi_amini created this revision.
mehdi_amini added reviewers: dexonsmith, manmanren.
mehdi_amini added a subscriber: llvm-commits.

Previous we were issuing an error when linking a module containing
the new Objective-C metadata structure for class properties with an
"old" one.
Now instead we downgrade the module flag so that the Objective-C
runtime does not expect the new metadata structure.

This is consistent with what ld64 is doing on binary files.

https://reviews.llvm.org/D24620

Files:
  llvm/lib/IR/AutoUpgrade.cpp
  llvm/test/Bitcode/upgrade-module-flag.ll
  llvm/test/Linker/Inputs/objectivec-class-property-flag-mismatch.ll
  llvm/test/Linker/objectivec-class-property-flag-mismatch.ll

Index: llvm/test/Linker/objectivec-class-property-flag-mismatch.ll
===================================================================
--- /dev/null
+++ llvm/test/Linker/objectivec-class-property-flag-mismatch.ll
@@ -0,0 +1,16 @@
+; RUN: llvm-as < %s -o %t1.bc
+; RUN: llvm-as < %p/Inputs/objectivec-class-property-flag-mismatch.ll -o %t2.bc
+
+
+; RUN: llvm-link %t1.bc %t2.bc -S | FileCheck %s
+; RUN: llvm-link %t2.bc %t1.bc -S | FileCheck %s
+
+
+; CHECK: !0 = !{i32 1, !"Objective-C Image Info Version", i32 0}
+; CHECK: !1 = !{i32 4, !"Objective-C Class Properties", i32 0}
+
+
+
+!llvm.module.flags = !{!0}
+
+!0 = !{i32 1, !"Objective-C Image Info Version", i32 0}
Index: llvm/test/Linker/Inputs/objectivec-class-property-flag-mismatch.ll
===================================================================
--- /dev/null
+++ llvm/test/Linker/Inputs/objectivec-class-property-flag-mismatch.ll
@@ -0,0 +1,5 @@
+
+!llvm.module.flags = !{!0, !1}
+
+!0 = !{i32 1, !"Objective-C Image Info Version", i32 0}
+!1 = !{i32 1, !"Objective-C Class Properties", i32 64}
Index: llvm/test/Bitcode/upgrade-module-flag.ll
===================================================================
--- llvm/test/Bitcode/upgrade-module-flag.ll
+++ llvm/test/Bitcode/upgrade-module-flag.ll
@@ -6,4 +6,4 @@
 !0 = !{i32 1, !"Objective-C Image Info Version", i32 0}
 
 ; CHECK: !0 = !{i32 1, !"Objective-C Image Info Version", i32 0}
-; CHECK: !1 = !{i32 1, !"Objective-C Class Properties", i32 0}
+; CHECK: !1 = !{i32 4, !"Objective-C Class Properties", i32 0}
Index: llvm/lib/IR/AutoUpgrade.cpp
===================================================================
--- llvm/lib/IR/AutoUpgrade.cpp
+++ llvm/lib/IR/AutoUpgrade.cpp
@@ -1567,7 +1567,7 @@
   // an ObjC bitcode without this module flag with an ObjC bitcode with this
   // module flag.
   if (HasObjCFlag && !HasClassProperties) {
-    M.addModuleFlag(llvm::Module::Error, "Objective-C Class Properties",
+    M.addModuleFlag(llvm::Module::Override, "Objective-C Class Properties",
                     (uint32_t)0);
     return true;
   }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D24620.71538.patch
Type: text/x-patch
Size: 2080 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160915/208db04b/attachment.bin>


More information about the llvm-commits mailing list