Mercurial > projects > ldc
comparison gen/llvmhelpers.cpp @ 315:a9697749e898 trunk
[svn r336] Made sure calls within a landing pad area are invokes.
Nested trys still need some consideration.
author | ChristianK |
---|---|
date | Thu, 03 Jul 2008 22:05:45 +0200 |
parents | d59c363fccad |
children | 7086a84ab3d6 |
comparison
equal
deleted
inserted
replaced
314:8d98e42ece93 | 315:a9697749e898 |
---|---|
28 llvm::Function* fn = LLVM_D_GetRuntimeFunction(gIR->module, "_d_allocmemoryT"); | 28 llvm::Function* fn = LLVM_D_GetRuntimeFunction(gIR->module, "_d_allocmemoryT"); |
29 // get type info | 29 // get type info |
30 LLConstant* ti = DtoTypeInfoOf(newtype); | 30 LLConstant* ti = DtoTypeInfoOf(newtype); |
31 assert(isaPointer(ti)); | 31 assert(isaPointer(ti)); |
32 // call runtime allocator | 32 // call runtime allocator |
33 LLValue* mem = gIR->ir->CreateCall(fn, ti, ".gc_mem"); | 33 LLValue* mem = gIR->CreateCallOrInvoke(fn, ti, ".gc_mem")->get(); |
34 // cast | 34 // cast |
35 return DtoBitCast(mem, getPtrToType(DtoType(newtype)), ".gc_mem"); | 35 return DtoBitCast(mem, getPtrToType(DtoType(newtype)), ".gc_mem"); |
36 } | 36 } |
37 | 37 |
38 void DtoDeleteMemory(LLValue* ptr) | 38 void DtoDeleteMemory(LLValue* ptr) |
41 llvm::Function* fn = LLVM_D_GetRuntimeFunction(gIR->module, "_d_delmemory"); | 41 llvm::Function* fn = LLVM_D_GetRuntimeFunction(gIR->module, "_d_delmemory"); |
42 // build args | 42 // build args |
43 LLSmallVector<LLValue*,1> arg; | 43 LLSmallVector<LLValue*,1> arg; |
44 arg.push_back(DtoBitCast(ptr, getVoidPtrType(), ".tmp")); | 44 arg.push_back(DtoBitCast(ptr, getVoidPtrType(), ".tmp")); |
45 // call | 45 // call |
46 llvm::CallInst::Create(fn, arg.begin(), arg.end(), "", gIR->scopebb()); | 46 gIR->CreateCallOrInvoke(fn, arg.begin(), arg.end()); |
47 } | 47 } |
48 | 48 |
49 void DtoDeleteClass(LLValue* inst) | 49 void DtoDeleteClass(LLValue* inst) |
50 { | 50 { |
51 // get runtime function | 51 // get runtime function |
52 llvm::Function* fn = LLVM_D_GetRuntimeFunction(gIR->module, "_d_delclass"); | 52 llvm::Function* fn = LLVM_D_GetRuntimeFunction(gIR->module, "_d_delclass"); |
53 // build args | 53 // build args |
54 LLSmallVector<LLValue*,1> arg; | 54 LLSmallVector<LLValue*,1> arg; |
55 arg.push_back(DtoBitCast(inst, fn->getFunctionType()->getParamType(0), ".tmp")); | 55 arg.push_back(DtoBitCast(inst, fn->getFunctionType()->getParamType(0), ".tmp")); |
56 // call | 56 // call |
57 llvm::CallInst::Create(fn, arg.begin(), arg.end(), "", gIR->scopebb()); | 57 gIR->CreateCallOrInvoke(fn, arg.begin(), arg.end()); |
58 } | 58 } |
59 | 59 |
60 void DtoDeleteInterface(LLValue* inst) | 60 void DtoDeleteInterface(LLValue* inst) |
61 { | 61 { |
62 // get runtime function | 62 // get runtime function |
63 llvm::Function* fn = LLVM_D_GetRuntimeFunction(gIR->module, "_d_delinterface"); | 63 llvm::Function* fn = LLVM_D_GetRuntimeFunction(gIR->module, "_d_delinterface"); |
64 // build args | 64 // build args |
65 LLSmallVector<LLValue*,1> arg; | 65 LLSmallVector<LLValue*,1> arg; |
66 arg.push_back(DtoBitCast(inst, fn->getFunctionType()->getParamType(0), ".tmp")); | 66 arg.push_back(DtoBitCast(inst, fn->getFunctionType()->getParamType(0), ".tmp")); |
67 // call | 67 // call |
68 llvm::CallInst::Create(fn, arg.begin(), arg.end(), "", gIR->scopebb()); | 68 gIR->CreateCallOrInvoke(fn, arg.begin(), arg.end()); |
69 } | 69 } |
70 | 70 |
71 void DtoDeleteArray(DValue* arr) | 71 void DtoDeleteArray(DValue* arr) |
72 { | 72 { |
73 // get runtime function | 73 // get runtime function |
75 // build args | 75 // build args |
76 LLSmallVector<LLValue*,2> arg; | 76 LLSmallVector<LLValue*,2> arg; |
77 arg.push_back(DtoArrayLen(arr)); | 77 arg.push_back(DtoArrayLen(arr)); |
78 arg.push_back(DtoBitCast(DtoArrayPtr(arr), getVoidPtrType(), ".tmp")); | 78 arg.push_back(DtoBitCast(DtoArrayPtr(arr), getVoidPtrType(), ".tmp")); |
79 // call | 79 // call |
80 llvm::CallInst::Create(fn, arg.begin(), arg.end(), "", gIR->scopebb()); | 80 gIR->CreateCallOrInvoke(fn, arg.begin(), arg.end()); |
81 } | 81 } |
82 | 82 |
83 /****************************************************************************************/ | 83 /****************************************************************************************/ |
84 /*//////////////////////////////////////////////////////////////////////////////////////// | 84 /*//////////////////////////////////////////////////////////////////////////////////////// |
85 // ASSERT HELPER | 85 // ASSERT HELPER |
141 // line param | 141 // line param |
142 c = DtoConstUint(loc->linnum); | 142 c = DtoConstUint(loc->linnum); |
143 args.push_back(c); | 143 args.push_back(c); |
144 | 144 |
145 // call | 145 // call |
146 llvm::CallInst* call = llvm::CallInst::Create(fn, args.begin(), args.end(), "", gIR->scopebb()); | 146 CallOrInvoke* call = gIR->CreateCallOrInvoke(fn, args.begin(), args.end()); |
147 call->setParamAttrs(palist); | 147 call->setParamAttrs(palist); |
148 | 148 |
149 // after assert is always unreachable | 149 // after assert is always unreachable |
150 gIR->ir->CreateUnreachable(); | 150 gIR->ir->CreateUnreachable(); |
151 } | 151 } |
273 ////////////////////////////////////////////////////////////////////////////////////////*/ | 273 ////////////////////////////////////////////////////////////////////////////////////////*/ |
274 | 274 |
275 void DtoEnterCritical(LLValue* g) | 275 void DtoEnterCritical(LLValue* g) |
276 { | 276 { |
277 LLFunction* fn = LLVM_D_GetRuntimeFunction(gIR->module, "_d_criticalenter"); | 277 LLFunction* fn = LLVM_D_GetRuntimeFunction(gIR->module, "_d_criticalenter"); |
278 gIR->ir->CreateCall(fn, g, ""); | 278 gIR->CreateCallOrInvoke(fn, g); |
279 } | 279 } |
280 | 280 |
281 void DtoLeaveCritical(LLValue* g) | 281 void DtoLeaveCritical(LLValue* g) |
282 { | 282 { |
283 LLFunction* fn = LLVM_D_GetRuntimeFunction(gIR->module, "_d_criticalexit"); | 283 LLFunction* fn = LLVM_D_GetRuntimeFunction(gIR->module, "_d_criticalexit"); |
284 gIR->ir->CreateCall(fn, g, ""); | 284 gIR->CreateCallOrInvoke(fn, g); |
285 } | 285 } |
286 | 286 |
287 void DtoEnterMonitor(LLValue* v) | 287 void DtoEnterMonitor(LLValue* v) |
288 { | 288 { |
289 LLFunction* fn = LLVM_D_GetRuntimeFunction(gIR->module, "_d_monitorenter"); | 289 LLFunction* fn = LLVM_D_GetRuntimeFunction(gIR->module, "_d_monitorenter"); |
290 v = DtoBitCast(v, fn->getFunctionType()->getParamType(0)); | 290 v = DtoBitCast(v, fn->getFunctionType()->getParamType(0)); |
291 gIR->ir->CreateCall(fn, v, ""); | 291 gIR->CreateCallOrInvoke(fn, v); |
292 } | 292 } |
293 | 293 |
294 void DtoLeaveMonitor(LLValue* v) | 294 void DtoLeaveMonitor(LLValue* v) |
295 { | 295 { |
296 LLFunction* fn = LLVM_D_GetRuntimeFunction(gIR->module, "_d_monitorexit"); | 296 LLFunction* fn = LLVM_D_GetRuntimeFunction(gIR->module, "_d_monitorexit"); |
297 v = DtoBitCast(v, fn->getFunctionType()->getParamType(0)); | 297 v = DtoBitCast(v, fn->getFunctionType()->getParamType(0)); |
298 gIR->ir->CreateCall(fn, v, ""); | 298 gIR->CreateCallOrInvoke(fn, v); |
299 } | 299 } |
300 | 300 |
301 /****************************************************************************************/ | 301 /****************************************************************************************/ |
302 /*//////////////////////////////////////////////////////////////////////////////////////// | 302 /*//////////////////////////////////////////////////////////////////////////////////////// |
303 // NESTED VARIABLE HELPERS | 303 // NESTED VARIABLE HELPERS |