[llvm] r281685 - Fix autoupgrade logic for Objective-C class properties module flag

Mehdi Amini via llvm-commits llvm-commits at lists.llvm.org
Thu Sep 15 17:38:19 PDT 2016


Author: mehdi_amini
Date: Thu Sep 15 19:38:18 2016
New Revision: 281685

URL: http://llvm.org/viewvc/llvm-project?rev=281685&view=rev
Log:
Fix autoupgrade logic for Objective-C class properties module flag

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.

Differential Revision: https://reviews.llvm.org/D24620

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

Modified: llvm/trunk/lib/IR/AutoUpgrade.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/AutoUpgrade.cpp?rev=281685&r1=281684&r2=281685&view=diff
==============================================================================
--- llvm/trunk/lib/IR/AutoUpgrade.cpp (original)
+++ llvm/trunk/lib/IR/AutoUpgrade.cpp Thu Sep 15 19:38:18 2016
@@ -1587,11 +1587,11 @@ bool llvm::UpgradeModuleFlags(Module &M)
   }
   // "Objective-C Class Properties" is recently added for Objective-C. We
   // upgrade ObjC bitcodes to contain a "Objective-C Class Properties" module
-  // flag of value 0, so we can correclty report error when trying to link
-  // an ObjC bitcode without this module flag with an ObjC bitcode with this
-  // module flag.
+  // flag of value 0, so we can correclty downgrade this flag when trying to
+  // link 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;
   }

Modified: llvm/trunk/test/Bitcode/upgrade-module-flag.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Bitcode/upgrade-module-flag.ll?rev=281685&r1=281684&r2=281685&view=diff
==============================================================================
--- llvm/trunk/test/Bitcode/upgrade-module-flag.ll (original)
+++ llvm/trunk/test/Bitcode/upgrade-module-flag.ll Thu Sep 15 19:38:18 2016
@@ -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}

Added: llvm/trunk/test/Linker/Inputs/objectivec-class-property-flag-mismatch.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Linker/Inputs/objectivec-class-property-flag-mismatch.ll?rev=281685&view=auto
==============================================================================
--- llvm/trunk/test/Linker/Inputs/objectivec-class-property-flag-mismatch.ll (added)
+++ llvm/trunk/test/Linker/Inputs/objectivec-class-property-flag-mismatch.ll Thu Sep 15 19:38:18 2016
@@ -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}

Added: llvm/trunk/test/Linker/objectivec-class-property-flag-mismatch.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Linker/objectivec-class-property-flag-mismatch.ll?rev=281685&view=auto
==============================================================================
--- llvm/trunk/test/Linker/objectivec-class-property-flag-mismatch.ll (added)
+++ llvm/trunk/test/Linker/objectivec-class-property-flag-mismatch.ll Thu Sep 15 19:38:18 2016
@@ -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}




More information about the llvm-commits mailing list