diff options
author | Chris Lattner <sabre@nondot.org> | 2003-09-08 18:54:55 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2003-09-08 18:54:55 +0000 |
commit | 9c58cf6d035e63247064b71800d6c52c3b0824fe (patch) | |
tree | 72a0174b38d30a5bedc352acacd092a709cad16d /llvm/lib/CWriter/Writer.cpp | |
parent | 66d5f575bae78ada86e8f8a83d5ad9e65c120a36 (diff) | |
download | bcm5719-llvm-9c58cf6d035e63247064b71800d6c52c3b0824fe.tar.gz bcm5719-llvm-9c58cf6d035e63247064b71800d6c52c3b0824fe.zip |
Add support for the unwind instruction
llvm-svn: 8408
Diffstat (limited to 'llvm/lib/CWriter/Writer.cpp')
-rw-r--r-- | llvm/lib/CWriter/Writer.cpp | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/llvm/lib/CWriter/Writer.cpp b/llvm/lib/CWriter/Writer.cpp index 721ead091c2..073ce19189f 100644 --- a/llvm/lib/CWriter/Writer.cpp +++ b/llvm/lib/CWriter/Writer.cpp @@ -117,6 +117,7 @@ namespace { void visitBranchInst(BranchInst &I); void visitSwitchInst(SwitchInst &I); void visitInvokeInst(InvokeInst &I); + void visitUnwindInst(UnwindInst &I); void visitPHINode(PHINode &I); void visitBinaryOperator(Instruction &I); @@ -980,6 +981,19 @@ void CWriter::visitInvokeInst(InvokeInst &II) { } +void CWriter::visitUnwindInst(UnwindInst &I) { + // The unwind instructions causes a control flow transfer out of the current + // function, unwinding the stack until a caller who used the invoke + // instruction is found. In this context, we code generated the invoke + // instruction to add an entry to the top of the jmpbuf_list. Thus, here we + // just have to longjmp to the specified handler. + Out << " if (__llvm_jmpbuf_list == 0) { /* llvm.unwind */\n" + << " printf(\"throw found with no handler!\\n\"); abort();\n" + << " }\n" + << " longjmp(__llvm_jmpbuf_list->buf, 1);\n"; + emittedInvoke = true; +} + static bool isGotoCodeNeccessary(BasicBlock *From, BasicBlock *To) { // If PHI nodes need copies, we need the copy code... if (isa<PHINode>(To->front()) || |