[cfe-commits] r69392 - in /cfe/trunk: lib/CodeGen/CGObjCMac.cpp test/CodeGenObjC/runtime-fns.m

Chris Lattner sabre at nondot.org
Fri Apr 17 15:12:36 PDT 2009


Author: lattner
Date: Fri Apr 17 17:12:36 2009
New Revision: 69392

URL: http://llvm.org/viewvc/llvm-project?rev=69392&view=rev
Log:
fix a crash compiling code with its own definition of objc_assign_weak.
rdar://6800430


Modified:
    cfe/trunk/lib/CodeGen/CGObjCMac.cpp
    cfe/trunk/test/CodeGenObjC/runtime-fns.m

Modified: cfe/trunk/lib/CodeGen/CGObjCMac.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGObjCMac.cpp?rev=69392&r1=69391&r2=69392&view=diff

==============================================================================
--- cfe/trunk/lib/CodeGen/CGObjCMac.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGObjCMac.cpp Fri Apr 17 17:12:36 2009
@@ -92,7 +92,14 @@
   llvm::Constant *GcReadWeakFn;
   
   /// GcAssignWeakFn -- LLVM objc_assign_weak function.
-  llvm::Constant *GcAssignWeakFn;
+  llvm::Constant *getGcAssignWeakFn() {
+    // id objc_assign_weak (id, id *)
+    std::vector<const llvm::Type*> Args(1, ObjectPtrTy);
+    Args.push_back(ObjectPtrTy->getPointerTo());
+    llvm::FunctionType *FTy =
+      llvm::FunctionType::get(ObjectPtrTy, Args, false);
+    return CGM.CreateRuntimeFunction(FTy, "objc_assign_weak");
+  }
   
   /// GcAssignGlobalFn -- LLVM objc_assign_global function.
   llvm::Constant *GcAssignGlobalFn;
@@ -2282,7 +2289,7 @@
   }
   src = CGF.Builder.CreateBitCast(src, ObjCTypes.ObjectPtrTy);
   dst = CGF.Builder.CreateBitCast(dst, ObjCTypes.PtrObjectPtrTy);
-  CGF.Builder.CreateCall2(ObjCTypes.GcAssignWeakFn,
+  CGF.Builder.CreateCall2(ObjCTypes.getGcAssignWeakFn(),
                           src, dst, "weakassign");
   return;
 }
@@ -3278,13 +3285,12 @@
   FTy = Types.GetFunctionType(Types.getFunctionInfo(IdType, Params), false);
   GcReadWeakFn = CGM.CreateRuntimeFunction(FTy, "objc_read_weak");
 
-  // id objc_assign_weak (id, id *)
+  // id objc_assign_global (id, id *)
   Params.clear();
   Params.push_back(IdType);
   Params.push_back(Ctx.getPointerType(IdType));
   
   FTy = Types.GetFunctionType(Types.getFunctionInfo(IdType, Params), false);
-  GcAssignWeakFn = CGM.CreateRuntimeFunction(FTy, "objc_assign_weak");
   GcAssignGlobalFn = CGM.CreateRuntimeFunction(FTy, "objc_assign_global");
   GcAssignIvarFn = CGM.CreateRuntimeFunction(FTy, "objc_assign_ivar");
   GcAssignStrongCastFn = 
@@ -5248,7 +5254,7 @@
   }
   src = CGF.Builder.CreateBitCast(src, ObjCTypes.ObjectPtrTy);
   dst = CGF.Builder.CreateBitCast(dst, ObjCTypes.PtrObjectPtrTy);
-  CGF.Builder.CreateCall2(ObjCTypes.GcAssignWeakFn,
+  CGF.Builder.CreateCall2(ObjCTypes.getGcAssignWeakFn(),
                           src, dst, "weakassign");
   return;
 }

Modified: cfe/trunk/test/CodeGenObjC/runtime-fns.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenObjC/runtime-fns.m?rev=69392&r1=69391&r2=69392&view=diff

==============================================================================
--- cfe/trunk/test/CodeGenObjC/runtime-fns.m (original)
+++ cfe/trunk/test/CodeGenObjC/runtime-fns.m Fri Apr 17 17:12:36 2009
@@ -25,4 +25,9 @@
 id objc_msgSend(int x) {
   return 0;
 }
+
+// rdar://6800430
+void objc_assign_weak(id value, id *location) {
+}
+
 #endif





More information about the cfe-commits mailing list