[llvm-branch-commits] [cfe-branch] r339233 - Merging r339128:

Hans Wennborg via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Wed Aug 8 04:27:50 PDT 2018


Author: hans
Date: Wed Aug  8 04:27:49 2018
New Revision: 339233

URL: http://llvm.org/viewvc/llvm-project?rev=339233&view=rev
Log:
Merging r339128:
------------------------------------------------------------------------
r339128 | theraven | 2018-08-07 14:02:46 +0200 (Tue, 07 Aug 2018) | 8 lines

[objc-gnustep] Don't emit .guess ivar offset vars.

These were intended to allow non-fragile and fragile ABI code to be
mixed, as long as the fragile classes were higher up the hierarchy than
the non-fragile ones.  Unfortunately:

 - No one actually wants to do this.
 - Recent versions of Linux's run-time linker break it.
------------------------------------------------------------------------

Modified:
    cfe/branches/release_70/   (props changed)
    cfe/branches/release_70/lib/CodeGen/CGObjCGNU.cpp

Propchange: cfe/branches/release_70/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Wed Aug  8 04:27:49 2018
@@ -1,4 +1,4 @@
 /cfe/branches/type-system-rewrite:134693-134817
-/cfe/trunk:338552-338553,338602,338627,338749,338942,339170
+/cfe/trunk:338552-338553,338602,338627,338749,338942,339128,339170
 /cfe/trunk/test:170344
 /cfe/trunk/test/SemaTemplate:126920

Modified: cfe/branches/release_70/lib/CodeGen/CGObjCGNU.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/release_70/lib/CodeGen/CGObjCGNU.cpp?rev=339233&r1=339232&r2=339233&view=diff
==============================================================================
--- cfe/branches/release_70/lib/CodeGen/CGObjCGNU.cpp (original)
+++ cfe/branches/release_70/lib/CodeGen/CGObjCGNU.cpp Wed Aug  8 04:27:49 2018
@@ -3812,40 +3812,10 @@ llvm::GlobalVariable *CGObjCGNU::ObjCIva
   // is.  This allows code compiled with non-fragile ivars to work correctly
   // when linked against code which isn't (most of the time).
   llvm::GlobalVariable *IvarOffsetPointer = TheModule.getNamedGlobal(Name);
-  if (!IvarOffsetPointer) {
-    // This will cause a run-time crash if we accidentally use it.  A value of
-    // 0 would seem more sensible, but will silently overwrite the isa pointer
-    // causing a great deal of confusion.
-    uint64_t Offset = -1;
-    // We can't call ComputeIvarBaseOffset() here if we have the
-    // implementation, because it will create an invalid ASTRecordLayout object
-    // that we are then stuck with forever, so we only initialize the ivar
-    // offset variable with a guess if we only have the interface.  The
-    // initializer will be reset later anyway, when we are generating the class
-    // description.
-    if (!CGM.getContext().getObjCImplementation(
-              const_cast<ObjCInterfaceDecl *>(ID)))
-      Offset = ComputeIvarBaseOffset(CGM, ID, Ivar);
-
-    llvm::ConstantInt *OffsetGuess = llvm::ConstantInt::get(Int32Ty, Offset,
-                             /*isSigned*/true);
-    // Don't emit the guess in non-PIC code because the linker will not be able
-    // to replace it with the real version for a library.  In non-PIC code you
-    // must compile with the fragile ABI if you want to use ivars from a
-    // GCC-compiled class.
-    if (CGM.getLangOpts().PICLevel) {
-      llvm::GlobalVariable *IvarOffsetGV = new llvm::GlobalVariable(TheModule,
-            Int32Ty, false,
-            llvm::GlobalValue::PrivateLinkage, OffsetGuess, Name+".guess");
-      IvarOffsetPointer = new llvm::GlobalVariable(TheModule,
-            IvarOffsetGV->getType(), false, llvm::GlobalValue::LinkOnceAnyLinkage,
-            IvarOffsetGV, Name);
-    } else {
-      IvarOffsetPointer = new llvm::GlobalVariable(TheModule,
-              llvm::Type::getInt32PtrTy(VMContext), false,
-              llvm::GlobalValue::ExternalLinkage, nullptr, Name);
-    }
-  }
+  if (!IvarOffsetPointer)
+    IvarOffsetPointer = new llvm::GlobalVariable(TheModule,
+            llvm::Type::getInt32PtrTy(VMContext), false,
+            llvm::GlobalValue::ExternalLinkage, nullptr, Name);
   return IvarOffsetPointer;
 }
 




More information about the llvm-branch-commits mailing list