comparison ir/irlandingpad.cpp @ 1650:40bd4a0d4870

Update to work with LLVM 2.7. Removed use of dyn_cast, llvm no compiles without exceptions and rtti by default. We do need exceptions for the libconfig stuff, but rtti isn't necessary (anymore). Debug info needs to be rewritten, as in LLVM 2.7 the format has completely changed. To have something to look at while rewriting, the old code has been wrapped inside #ifndef DISABLE_DEBUG_INFO , this means that you have to define this to compile at the moment. Updated tango 0.99.9 patch to include updated EH runtime code, which is needed for LLVM 2.7 as well.
author Tomas Lindquist Olsen
date Wed, 19 May 2010 12:42:32 +0200
parents f4c56ed32238
children
comparison
equal deleted inserted replaced
1649:36da40ecbbe0 1650:40bd4a0d4870
131 selectorargs.insert(selectorargs.begin(), it->catchType->ir.irStruct->getClassInfoSymbol()); 131 selectorargs.insert(selectorargs.begin(), it->catchType->ir.irStruct->getClassInfoSymbol());
132 } 132 }
133 } 133 }
134 // if there's a finally, the eh table has to have a 0 action 134 // if there's a finally, the eh table has to have a 0 action
135 if(hasFinally) 135 if(hasFinally)
136 selectorargs.push_back(DtoConstSize_t(0));//LLConstantInt::get(LLType::getInt32Ty(gIR->context()), 0)); 136 selectorargs.push_back(DtoConstUint(0));
137 137
138 // personality fn 138 // personality fn
139 llvm::Function* personality_fn = LLVM_D_GetRuntimeFunction(gIR->module, "_d_eh_personality"); 139 llvm::Function* personality_fn = LLVM_D_GetRuntimeFunction(gIR->module, "_d_eh_personality");
140 LLValue* personality_fn_arg = gIR->ir->CreateBitCast(personality_fn, getPtrToType(LLType::getInt8Ty(gIR->context()))); 140 LLValue* personality_fn_arg = gIR->ir->CreateBitCast(personality_fn, getPtrToType(LLType::getInt8Ty(gIR->context())));
141 selectorargs.insert(selectorargs.begin(), personality_fn_arg); 141 selectorargs.insert(selectorargs.begin(), personality_fn_arg);
142 142
143 // eh storage target 143 // eh storage target
144 selectorargs.insert(selectorargs.begin(), eh_ptr); 144 selectorargs.insert(selectorargs.begin(), eh_ptr);
145 145
146 // if there is a catch and some catch allocated storage, store exception object 146 // if there is a catch and some catch allocated storage, store exception object
147 if(catchToInt.size() && catch_var) 147 if(catchToInt.size() && catch_var)
148 { 148 {
149 const LLType* objectTy = DtoType(ClassDeclaration::object->type); 149 const LLType* objectTy = DtoType(ClassDeclaration::object->type);
150 gIR->ir->CreateStore(gIR->ir->CreateBitCast(eh_ptr, objectTy), catch_var); 150 gIR->ir->CreateStore(gIR->ir->CreateBitCast(eh_ptr, objectTy), catch_var);
151 } 151 }
152 152
153 // eh_sel = llvm.eh.selector(eh_ptr, cast(byte*)&_d_eh_personality, <selectorargs>); 153 // eh_sel = llvm.eh.selector(eh_ptr, cast(byte*)&_d_eh_personality, <selectorargs>);
154 llvm::Function* eh_selector_fn; 154 llvm::Function* eh_selector_fn = GET_INTRINSIC_DECL(eh_selector);
155 if (global.params.is64bit)
156 eh_selector_fn = GET_INTRINSIC_DECL(eh_selector_i64);
157 else
158 eh_selector_fn = GET_INTRINSIC_DECL(eh_selector_i32);
159 LLValue* eh_sel = gIR->ir->CreateCall(eh_selector_fn, selectorargs.begin(), selectorargs.end()); 155 LLValue* eh_sel = gIR->ir->CreateCall(eh_selector_fn, selectorargs.begin(), selectorargs.end());
160 156
161 // emit finallys and switches that branch to catches until there are no more catches 157 // emit finallys and switches that branch to catches until there are no more catches
162 // then simply branch to the finally chain 158 // then simply branch to the finally chain
163 llvm::SwitchInst* switchinst = NULL; 159 llvm::SwitchInst* switchinst = NULL;
184 switchinst = gIR->ir->CreateSwitch(eh_sel, llvm::BasicBlock::Create(gIR->context(), "switchdefault", gIR->topfunc(), gIR->scopeend()), infos.size()); 180 switchinst = gIR->ir->CreateSwitch(eh_sel, llvm::BasicBlock::Create(gIR->context(), "switchdefault", gIR->topfunc(), gIR->scopeend()), infos.size());
185 gIR->scope() = IRScope(switchinst->getDefaultDest(), gIR->scopeend()); 181 gIR->scope() = IRScope(switchinst->getDefaultDest(), gIR->scopeend());
186 } 182 }
187 // dubious comment 183 // dubious comment
188 // catches matched first get the largest switchval, so do size - unique int 184 // catches matched first get the largest switchval, so do size - unique int
189 llvm::ConstantInt* switchval = LLConstantInt::get(DtoSize_t(), catchToInt[rit->catchType]); 185 llvm::ConstantInt* switchval = DtoConstUint(catchToInt[rit->catchType]);
190 // and make sure we don't add the same switchval twice, may happen with nested trys 186 // and make sure we don't add the same switchval twice, may happen with nested trys
191 if(!switchinst->findCaseValue(switchval)) 187 if(!switchinst->findCaseValue(switchval))
192 switchinst->addCase(switchval, rit->target); 188 switchinst->addCase(switchval, rit->target);
193 } 189 }
194 } 190 }