Fix Duraid's changes to work when TLI is null. This fixes the failing
authorChris Lattner <sabre@nondot.org>
Tue, 5 Sep 2006 17:48:07 +0000 (17:48 +0000)
committerChris Lattner <sabre@nondot.org>
Tue, 5 Sep 2006 17:48:07 +0000 (17:48 +0000)
lowerinvoke regtests.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@30115 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Transforms/Utils/LowerInvoke.cpp

index 73d703b7388ee33c45795512df9393b974797fc4..918055722dfdcfa74680c44fca919ca12767f48a 100644 (file)
@@ -113,7 +113,9 @@ bool LowerInvoke::doInitialization(Module &M) {
   AbortMessage = 0;
   if (ExpensiveEHSupport) {
     // Insert a type for the linked list of jump buffers.
-    const Type *JmpBufTy = ArrayType::get(VoidPtrTy, TLI->getJumpBufSize());
+    unsigned JBSize = TLI ? TLI->getJumpBufSize() : 0;
+    JBSize = JBSize ? JBSize : 200;
+    const Type *JmpBufTy = ArrayType::get(VoidPtrTy, JBSize);
 
     { // The type is recursive, so use a type holder.
       std::vector<const Type*> Elements;
@@ -130,11 +132,12 @@ bool LowerInvoke::doInitialization(Module &M) {
 
     // Now that we've done that, insert the jmpbuf list head global, unless it
     // already exists.
-    if (!(JBListHead = M.getGlobalVariable("llvm.sjljeh.jblist", PtrJBList)))
+    if (!(JBListHead = M.getGlobalVariable("llvm.sjljeh.jblist", PtrJBList))) {
       JBListHead = new GlobalVariable(PtrJBList, false,
                                       GlobalValue::LinkOnceLinkage,
                                       Constant::getNullValue(PtrJBList),
                                       "llvm.sjljeh.jblist", &M);
+    }
     SetJmpFn = M.getOrInsertFunction("llvm.setjmp", Type::IntTy,
                                      PointerType::get(JmpBufTy), (Type *)0);
     LongJmpFn = M.getOrInsertFunction("llvm.longjmp", Type::VoidTy,
@@ -452,8 +455,9 @@ bool LowerInvoke::insertExpensiveEHSupport(Function &F) {
     // Create an alloca for the incoming jump buffer ptr and the new jump buffer
     // that needs to be restored on all exits from the function.  This is an
     // alloca because the value needs to be live across invokes.
+    unsigned Align = TLI ? TLI->getJumpBufAlignment() : 0;
     AllocaInst *JmpBuf = 
-      new AllocaInst(JBLinkTy, 0, TLI->getJumpBufAlignment(), "jblink", F.begin()->begin());
+      new AllocaInst(JBLinkTy, 0, Align, "jblink", F.begin()->begin());
     
     std::vector<Value*> Idx;
     Idx.push_back(Constant::getNullValue(Type::IntTy));