| OLD | NEW |
| 1 //===- PNaClSjLjEH.cpp - Lower C++ exception handling to use setjmp()------===// | 1 //===- PNaClSjLjEH.cpp - Lower C++ exception handling to use setjmp()------===// |
| 2 // | 2 // |
| 3 // The LLVM Compiler Infrastructure | 3 // The LLVM Compiler Infrastructure |
| 4 // | 4 // |
| 5 // This file is distributed under the University of Illinois Open Source | 5 // This file is distributed under the University of Illinois Open Source |
| 6 // License. See LICENSE.TXT for details. | 6 // License. See LICENSE.TXT for details. |
| 7 // | 7 // |
| 8 //===----------------------------------------------------------------------===// | 8 //===----------------------------------------------------------------------===// |
| 9 // | 9 // |
| 10 // The PNaClSjLjEH pass is part of an implementation of C++ exception | 10 // The PNaClSjLjEH pass is part of an implementation of C++ exception |
| (...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 185 // invoke instructions in the function. | 185 // invoke instructions in the function. |
| 186 Type *I32 = Type::getInt32Ty(M->getContext()); | 186 Type *I32 = Type::getInt32Ty(M->getContext()); |
| 187 Frame = new AllocaInst(ExceptionFrameTy, ConstantInt::get(I32, 1), | 187 Frame = new AllocaInst(ExceptionFrameTy, ConstantInt::get(I32, 1), |
| 188 kPNaClJmpBufAlign, "invoke_frame"); | 188 kPNaClJmpBufAlign, "invoke_frame"); |
| 189 Func->getEntryBlock().getInstList().push_front(Frame); | 189 Func->getEntryBlock().getInstList().push_front(Frame); |
| 190 | 190 |
| 191 // Calculate addresses of fields in the exception frame. | 191 // Calculate addresses of fields in the exception frame. |
| 192 Value *JmpBufIndexes[] = { ConstantInt::get(I32, 0), | 192 Value *JmpBufIndexes[] = { ConstantInt::get(I32, 0), |
| 193 ConstantInt::get(I32, 0), | 193 ConstantInt::get(I32, 0), |
| 194 ConstantInt::get(I32, 0) }; | 194 ConstantInt::get(I32, 0) }; |
| 195 FrameJmpBuf = GetElementPtrInst::Create(Frame, JmpBufIndexes, | 195 FrameJmpBuf = GetElementPtrInst::Create( |
| 196 "invoke_jmp_buf"); | 196 ExceptionFrameTy, Frame, JmpBufIndexes, "invoke_jmp_buf"); |
| 197 FrameJmpBuf->insertAfter(Frame); | 197 FrameJmpBuf->insertAfter(Frame); |
| 198 | 198 |
| 199 Value *NextPtrIndexes[] = { ConstantInt::get(I32, 0), | 199 Value *NextPtrIndexes[] = { ConstantInt::get(I32, 0), |
| 200 ConstantInt::get(I32, 1) }; | 200 ConstantInt::get(I32, 1) }; |
| 201 FrameNextPtr = GetElementPtrInst::Create(Frame, NextPtrIndexes, | 201 FrameNextPtr = GetElementPtrInst::Create( |
| 202 "invoke_next"); | 202 ExceptionFrameTy, Frame, NextPtrIndexes, "invoke_next"); |
| 203 FrameNextPtr->insertAfter(Frame); | 203 FrameNextPtr->insertAfter(Frame); |
| 204 | 204 |
| 205 Value *ExcInfoIndexes[] = { ConstantInt::get(I32, 0), | 205 Value *ExcInfoIndexes[] = { ConstantInt::get(I32, 0), |
| 206 ConstantInt::get(I32, 2) }; | 206 ConstantInt::get(I32, 2) }; |
| 207 FrameExcInfo = GetElementPtrInst::Create(Frame, ExcInfoIndexes, | 207 FrameExcInfo = GetElementPtrInst::Create( |
| 208 "exc_info_ptr"); | 208 ExceptionFrameTy, Frame, ExcInfoIndexes, "exc_info_ptr"); |
| 209 FrameExcInfo->insertAfter(Frame); | 209 FrameExcInfo->insertAfter(Frame); |
| 210 } | 210 } |
| 211 | 211 |
| 212 // Creates the helper function that will do the setjmp() call and | 212 // Creates the helper function that will do the setjmp() call and |
| 213 // function call for implementing Invoke. Creates the call to the | 213 // function call for implementing Invoke. Creates the call to the |
| 214 // helper function. Returns a Value which is zero on the normal | 214 // helper function. Returns a Value which is zero on the normal |
| 215 // execution path and non-zero if the landingpad block should be | 215 // execution path and non-zero if the landingpad block should be |
| 216 // entered. | 216 // entered. |
| 217 Value *FuncRewriter::createSetjmpWrappedCall(InvokeInst *Invoke) { | 217 Value *FuncRewriter::createSetjmpWrappedCall(InvokeInst *Invoke) { |
| 218 Type *I32 = Type::getInt32Ty(Func->getContext()); | 218 Type *I32 = Type::getInt32Ty(Func->getContext()); |
| (...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 456 FuncRewriter Rewriter(ExceptionFrameTy, &ExcInfoWriter, Func); | 456 FuncRewriter Rewriter(ExceptionFrameTy, &ExcInfoWriter, Func); |
| 457 Rewriter.expandFunc(); | 457 Rewriter.expandFunc(); |
| 458 } | 458 } |
| 459 ExcInfoWriter.defineGlobalVariables(&M); | 459 ExcInfoWriter.defineGlobalVariables(&M); |
| 460 return true; | 460 return true; |
| 461 } | 461 } |
| 462 | 462 |
| 463 ModulePass *llvm::createPNaClSjLjEHPass() { | 463 ModulePass *llvm::createPNaClSjLjEHPass() { |
| 464 return new PNaClSjLjEH(); | 464 return new PNaClSjLjEH(); |
| 465 } | 465 } |
| OLD | NEW |