Index: lib/CodeGen/CGExprScalar.cpp
===================================================================
--- lib/CodeGen/CGExprScalar.cpp	(revision 48734)
+++ lib/CodeGen/CGExprScalar.cpp	(working copy)
@@ -481,11 +515,13 @@
   // Get the selector string
   std::string SelStr = E->getSelector().getName();
   llvm::Constant *Selector = CGF.CGM.GetAddrOfConstantString(SelStr);
-  ConvertType(E->getType());
+
+  llvm::Value *SelPtr = Builder.CreateStructGEP(Selector, 0);
   return Runtime->generateMessageSend(Builder,
       ConvertType(E->getType()),
+      CGF.CurFn->getValueSymbolTable().lookup("self"),
       Receiver,
-      Selector,
+      SelPtr,
       &Args[0],
       Args.size());
 }
Index: lib/CodeGen/CodeGenModule.cpp
===================================================================
--- lib/CodeGen/CodeGenModule.cpp	(revision 48734)
+++ lib/CodeGen/CodeGenModule.cpp	(working copy)
@@ -34,10 +34,16 @@
   : Context(C), Features(LO), TheModule(M), TheTargetData(TD), Diags(diags),
     Types(C, M, TD), MemCpyFn(0), MemSetFn(0), CFConstantStringClassRef(0) {
   //TODO: Make this selectable at runtime
-  Runtime = CreateObjCRuntime(M);
+  Runtime = CreateObjCRuntime(M,
+      getTypes().ConvertType(getContext().IntTy),
+      getTypes().ConvertType(getContext().LongTy));
 }
 
 CodeGenModule::~CodeGenModule() {
+  llvm::Function *ObjCInitFunction = Runtime->ModuleInitFunction();
+  if (ObjCInitFunction) {
+    AddGlobalCtor(ObjCInitFunction);
+  }
   EmitGlobalCtors();
   delete Runtime;
 }
Index: lib/CodeGen/CGObjCRuntime.h
===================================================================
--- lib/CodeGen/CGObjCRuntime.h	(revision 48734)
+++ lib/CodeGen/CGObjCRuntime.h	(working copy)
@@ -22,8 +22,10 @@
   class Type;
   class Value;
   class Module;
+  class Function;
 }
 
+
 namespace clang {
 namespace CodeGen {
 
@@ -35,13 +37,30 @@
   // Generate an Objective-C message send operation
   virtual llvm::Value *generateMessageSend(llvm::LLVMFoldingBuilder &Builder,
                                            const llvm::Type *ReturnTy,
+                                           llvm::Value *Sender,
                                            llvm::Value *Receiver,
-                                           llvm::Constant *Selector,
+                                           llvm::Value *Selector,
                                            llvm::Value** ArgV,
                                            unsigned ArgC) = 0;
+  // Generate the function required to register all Objective-C components in
+  // this compilation unit with the runtime library.
+  virtual llvm::Function *ModuleInitFunction() { return 0; }
+  // Generate a function preamble for a method with the specified types
+  virtual llvm::Function *MethodPreamble(const llvm::Type *ReturnTy,
+                                         const llvm::Type *SelfTy,
+                                         const llvm::Type **ArgTy,
+                                         unsigned ArgC,
+                                         bool isVarArg) = 0;
+  // If instance variable addresses are determined at runtime then this should
+  // return true, otherwise instance variables will be accessed directly from
+  // the structure.  If this returns true then @defs is invalid for this
+  // runtime and a warning should be generated.
+  virtual bool LateBoundIVars() { return false; }
 };
 
-CGObjCRuntime *CreateObjCRuntime(llvm::Module &M);
+CGObjCRuntime *CreateObjCRuntime(llvm::Module &M,
+                                 const llvm::Type *LLVMIntType,
+                                 const llvm::Type *LLVMLongType);
 }
 }
 #endif
