Wiki Roadmap Timeline Tickets New Ticket Source Search Help / Guide About Trac Login

Changeset 1412:3f5ea912149d

Show
Ignore:
Timestamp:
05/22/09 18:23:39 (3 years ago)
Author:
Christian Kamm <kamm incasoftware de>
branch:
default
Message:

Fix #308 by giving finally code emitted by EnclosingTryFinally? a different landing pad.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • gen/irstate.h

    r1300 r1412  
    176176llvm::CallSite IRState::CreateCallOrInvoke(LLValue* Callee, InputIterator ArgBegin, InputIterator ArgEnd, const char* Name) 
    177177{ 
    178     llvm::BasicBlock* pad
    179     if(pad = func()->landingPad.get()
     178    llvm::BasicBlock* pad = func()->landingPad
     179    if(pad
    180180    { 
    181181        // intrinsics don't support invoking and 'nounwind' functions don't need it. 
  • gen/llvmhelpers.cpp

    r1411 r1412  
    256256{ 
    257257    if (tf->finalbody) 
     258    { 
     259        llvm::BasicBlock* oldpad = p->func()->landingPad; 
     260        p->func()->landingPad = landingPad; 
    258261        tf->finalbody->toIR(p); 
     262        p->func()->landingPad = oldpad; 
     263    } 
    259264} 
    260265 
  • gen/llvmhelpers.h

    r1351 r1412  
    1616{ 
    1717    TryFinallyStatement* tf; 
     18    llvm::BasicBlock* landingPad; 
    1819    void emitCode(IRState* p); 
    19     EnclosingTryFinally(TryFinallyStatement* _tf) : tf(_tf) {} 
     20    EnclosingTryFinally(TryFinallyStatement* _tf, llvm::BasicBlock* _pad)  
     21    : tf(_tf), landingPad(_pad) {} 
    2022}; 
    2123struct EnclosingVolatile : EnclosingHandler 
  • gen/statements.cpp

    r1350 r1412  
    593593 
    594594    assert(finalbody); 
    595     gIR->func()->landingPad.addFinally(finalbody); 
    596     gIR->func()->landingPad.push(landingpadbb); 
     595    gIR->func()->targetScopes.push_back(IRTargetScope(this,new EnclosingTryFinally(this,gIR->func()->landingPad),NULL,NULL)); 
     596    gIR->func()->landingPadInfo.addFinally(finalbody); 
     597    gIR->func()->landingPadInfo.push(landingpadbb); 
     598    gIR->func()->landingPad = gIR->func()->landingPadInfo.get(); 
    597599 
    598600    // 
     
    602604 
    603605    assert(body); 
    604     p->func()->targetScopes.push_back(IRTargetScope(this,new EnclosingTryFinally(this),NULL,NULL)); 
    605606    body->toIR(p); 
    606     p->func()->targetScopes.pop_back(); 
    607607 
    608608    // terminate try BB 
     
    610610        llvm::BranchInst::Create(finallybb, p->scopebb()); 
    611611 
    612     gIR->func()->landingPad.pop(); 
     612    gIR->func()->landingPadInfo.pop(); 
     613    gIR->func()->landingPad = gIR->func()->landingPadInfo.get(); 
     614    gIR->func()->targetScopes.pop_back(); 
    613615 
    614616    // 
     
    659661    { 
    660662        Catch *c = (Catch *)catches->data[i]; 
    661         gIR->func()->landingPad.addCatch(c, endbb); 
    662     } 
    663  
    664     gIR->func()->landingPad.push(landingpadbb); 
     663        gIR->func()->landingPadInfo.addCatch(c, endbb); 
     664    } 
     665 
     666    gIR->func()->landingPadInfo.push(landingpadbb); 
     667    gIR->func()->landingPad = gIR->func()->landingPadInfo.get(); 
    665668 
    666669    // 
     
    675678        llvm::BranchInst::Create(endbb, p->scopebb()); 
    676679 
    677     gIR->func()->landingPad.pop(); 
     680    gIR->func()->landingPadInfo.pop(); 
     681    gIR->func()->landingPad = gIR->func()->landingPadInfo.get(); 
    678682 
    679683    // rewrite the scope 
  • ir/irfunction.cpp

    r1223 r1412  
    118118    _argptr = NULL; 
    119119     
     120    landingPad = NULL; 
     121     
    120122    nextUnique.push(0); 
    121123} 
  • ir/irfunction.h

    r1223 r1412  
    7171 
    7272    // landing pads for try statements 
    73     IRLandingPad landingPad; 
     73    IRLandingPad landingPadInfo; 
     74    llvm::BasicBlock* landingPad; 
    7475 
    7576    // loop blocks 
  • ir/irlandingpad.cpp

    r1350 r1412  
    2525            assert(!catchstmt->var->ir.irLocal); 
    2626            catchstmt->var->ir.irLocal = new IrLocal(catchstmt->var); 
    27             LLValue* catch_var = gIR->func()->landingPad.getExceptionStorage(); 
     27            LLValue* catch_var = gIR->func()->landingPadInfo.getExceptionStorage(); 
    2828            catchstmt->var->ir.irLocal->value = gIR->ir->CreateBitCast(catch_var, getPtrToType(DtoType(catchstmt->var->type))); 
    2929        } 
     
    3333 
    3434        // the exception will only be stored in catch_var. copy it over if necessary 
    35         if(catchstmt->var->ir.irLocal->value != gIR->func()->landingPad.getExceptionStorage()) { 
    36             LLValue* exc = gIR->ir->CreateBitCast(DtoLoad(gIR->func()->landingPad.getExceptionStorage()), DtoType(catchstmt->var->type)); 
     35        if(catchstmt->var->ir.irLocal->value != gIR->func()->landingPadInfo.getExceptionStorage()) { 
     36            LLValue* exc = gIR->ir->CreateBitCast(DtoLoad(gIR->func()->landingPadInfo.getExceptionStorage()), DtoType(catchstmt->var->type)); 
    3737            DtoStore(exc, catchstmt->var->ir.irLocal->value); 
    3838        } 
Copyright © 2008, LDC Development Team.