diff options
author | Chris Lattner <sabre@nondot.org> | 2008-04-04 04:07:35 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2008-04-04 04:07:35 +0000 |
commit | c8aa5f1f264fb230c38182adab944232bb160c2b (patch) | |
tree | a7ab47baf8db212c4cb252e010d502e097930b86 /lib/CodeGen/CodeGenFunction.cpp | |
parent | 1330b0e6e4a6ad2d586c4a45d6cece5611829a16 (diff) |
Codegen assignment to self correctly, patch by David Chisnall!
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@49201 91177308-0d34-0410-b5e6-96231b3b80d8
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)); |