Mercurial > projects > ldc
comparison gen/passes/GarbageCollect2Stack.cpp @ 1555:ed0cffe895ec
use the new NamedMDNode class
this will need a LLVM >= r77619
author | Benjamin Kramer <benny.kra@gmail.com> |
---|---|
date | Thu, 30 Jul 2009 20:54:03 +0200 |
parents | d6e8d5db259f |
children | 3adcb70700cb |
comparison
equal
deleted
inserted
replaced
1554:d6e8d5db259f | 1555:ed0cffe895ec |
---|---|
199 return false; | 199 return false; |
200 Value* arg = CS.getArgument(0)->stripPointerCasts(); | 200 Value* arg = CS.getArgument(0)->stripPointerCasts(); |
201 GlobalVariable* ClassInfo = dyn_cast<GlobalVariable>(arg); | 201 GlobalVariable* ClassInfo = dyn_cast<GlobalVariable>(arg); |
202 if (!ClassInfo) | 202 if (!ClassInfo) |
203 return false; | 203 return false; |
204 | 204 |
205 std::string metaname = CD_PREFIX; | 205 std::string metaname = CD_PREFIX; |
206 metaname += ClassInfo->getName(); | 206 metaname += ClassInfo->getName(); |
207 | 207 |
208 GlobalVariable* global = A.M.getGlobalVariable(metaname); | 208 NamedMDNode* meta = A.M.getNamedMetadata(metaname); |
209 if (!global || !global->hasInitializer()) | 209 if (!meta) |
210 return false; | 210 return false; |
211 | 211 |
212 MDNode* node = dyn_cast<MDNode>(global->getInitializer()); | 212 MDNode* node = static_cast<MDNode*>(meta->getElement(0)); |
213 if (!node || MD_GetNumElements(node) != CD_NumFields) | 213 if (!node || MD_GetNumElements(node) != CD_NumFields) |
214 return false; | 214 return false; |
215 | 215 |
216 // Inserting destructor calls is not implemented yet, so classes | 216 // Inserting destructor calls is not implemented yet, so classes |
217 // with destructors are ignored for now. | 217 // with destructors are ignored for now. |
218 Constant* hasDestructor = dyn_cast<Constant>(MD_GetElement(node, CD_Finalize)); | 218 Constant* hasDestructor = dyn_cast<Constant>(MD_GetElement(node, CD_Finalize)); |
219 // We can't stack-allocate if the class has a custom deallocator | 219 // We can't stack-allocate if the class has a custom deallocator |
220 // (Custom allocators don't get turned into this runtime call, so | 220 // (Custom allocators don't get turned into this runtime call, so |
394 if (!ti_global) | 394 if (!ti_global) |
395 return NULL; | 395 return NULL; |
396 | 396 |
397 std::string metaname = TD_PREFIX; | 397 std::string metaname = TD_PREFIX; |
398 metaname += ti_global->getName(); | 398 metaname += ti_global->getName(); |
399 | 399 |
400 GlobalVariable* global = M.getGlobalVariable(metaname); | 400 NamedMDNode* meta = M.getNamedMetadata(metaname); |
401 if (!global || !global->hasInitializer()) | 401 if (!meta) |
402 return NULL; | 402 return NULL; |
403 | 403 |
404 MDNode* node = dyn_cast<MDNode>(global->getInitializer()); | 404 MDNode* node = static_cast<MDNode*>(meta->getElement(0)); |
405 if (!node) | 405 if (!node) |
406 return NULL; | 406 return NULL; |
407 | 407 |
408 if (MD_GetNumElements(node) != TD_NumFields) | 408 if (MD_GetNumElements(node) != TD_NumFields) |
409 return NULL; | 409 return NULL; |
410 if (TD_Confirm >= 0 && (!MD_GetElement(node, TD_Confirm) || | 410 if (TD_Confirm >= 0 && (!MD_GetElement(node, TD_Confirm) || |
411 MD_GetElement(node, TD_Confirm)->stripPointerCasts() != ti_global)) | 411 MD_GetElement(node, TD_Confirm)->stripPointerCasts() != ti_global)) |
412 return NULL; | 412 return NULL; |