diff options
Diffstat (limited to 'lib/CodeGen/CodeGenFunction.cpp')
-rw-r--r-- | lib/CodeGen/CodeGenFunction.cpp | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/lib/CodeGen/CodeGenFunction.cpp b/lib/CodeGen/CodeGenFunction.cpp index c804098ec9..a07eaff305 100644 --- a/lib/CodeGen/CodeGenFunction.cpp +++ b/lib/CodeGen/CodeGenFunction.cpp @@ -97,7 +97,13 @@ void CodeGenFunction::GenerateObjCMethod(const ObjCMethodDecl *OMD) { // TODO: Add something to AST to let the runtime specify the names and types // of these. llvm::Value *&DMEntry = LocalDeclMap[&(*OMD->getSelfDecl())]; - DMEntry = AI; + const llvm::Type *SelfTy = AI->getType(); + llvm::Value *DeclPtr = new llvm::AllocaInst(SelfTy, 0, "self.addr", + AllocaInsertPt); + + // Store the initial value into the alloca. + Builder.CreateStore(AI, DeclPtr); + DMEntry = DeclPtr; ++AI; ++AI; @@ -130,13 +136,22 @@ void CodeGenFunction::GenerateObjCMethod(const ObjCMethodDecl *OMD) { assert(!verifyFunction(*CurFn) && "Generated method is not well formed."); } +llvm::Value *CodeGenFunction::LoadObjCSelf(void) +{ + if(const ObjCMethodDecl *OMD = dyn_cast<ObjCMethodDecl>(CurFuncDecl)) { + llvm::Value *SelfPtr = LocalDeclMap[&(*OMD->getSelfDecl())]; + return Builder.CreateLoad(SelfPtr, "self"); + } + return NULL; +} + void CodeGenFunction::GenerateCode(const FunctionDecl *FD) { LLVMIntTy = ConvertType(getContext().IntTy); LLVMPointerWidth = static_cast<unsigned>( getContext().getTypeSize(getContext().getPointerType(getContext().VoidTy))); CurFuncDecl = FD; - FnRetTy = CurFuncDecl->getType()->getAsFunctionType()->getResultType(); + FnRetTy = FD->getType()->getAsFunctionType()->getResultType(); CurFn = cast<llvm::Function>(CGM.GetAddrOfFunctionDecl(FD, true)); |