comparison gen/passes/GarbageCollect2Stack.cpp @ 1539:6364e09628fd

Build fix for LLVM r75546 and r75559
author Benjamin Kramer <benny.kra@gmail.com>
date Tue, 14 Jul 2009 02:19:05 +0200
parents d1652c8fb4f6
children 7fcb72d518f6
comparison
equal deleted inserted replaced
1538:e4ff2e15cf5f 1539:6364e09628fd
83 //===----------------------------------------------------------------------===// 83 //===----------------------------------------------------------------------===//
84 84
85 namespace { 85 namespace {
86 class FunctionInfo { 86 class FunctionInfo {
87 protected: 87 protected:
88 LLVMContext* Context;
88 const Type* Ty; 89 const Type* Ty;
89 90
90 public: 91 public:
91 unsigned TypeInfoArgNr; 92 unsigned TypeInfoArgNr;
92 bool SafeToDelete; 93 bool SafeToDelete;
106 107
107 Instruction* Begin = CS.getCaller()->getEntryBlock().begin(); 108 Instruction* Begin = CS.getCaller()->getEntryBlock().begin();
108 return new AllocaInst(Ty, ".nongc_mem", Begin); // FIXME: align? 109 return new AllocaInst(Ty, ".nongc_mem", Begin); // FIXME: align?
109 } 110 }
110 111
111 FunctionInfo(unsigned typeInfoArgNr, bool safeToDelete) 112 FunctionInfo(LLVMContext* context, unsigned typeInfoArgNr, bool safeToDelete)
112 : TypeInfoArgNr(typeInfoArgNr), SafeToDelete(safeToDelete) {} 113 : Context(context), TypeInfoArgNr(typeInfoArgNr), SafeToDelete(safeToDelete) {}
113 }; 114 };
114 115
115 class ArrayFI : public FunctionInfo { 116 class ArrayFI : public FunctionInfo {
116 Value* arrSize; 117 Value* arrSize;
117 int ArrSizeArgNr; 118 int ArrSizeArgNr;
118 bool Initialized; 119 bool Initialized;
119 120
120 public: 121 public:
121 ArrayFI(unsigned tiArgNr, bool safeToDelete, bool initialized, 122 ArrayFI(LLVMContext* context, unsigned tiArgNr, bool safeToDelete,
122 unsigned arrSizeArgNr) 123 bool initialized, unsigned arrSizeArgNr)
123 : FunctionInfo(tiArgNr, safeToDelete), 124 : FunctionInfo(context, tiArgNr, safeToDelete),
124 ArrSizeArgNr(arrSizeArgNr), 125 ArrSizeArgNr(arrSizeArgNr),
125 Initialized(initialized) 126 Initialized(initialized)
126 {} 127 {}
127 128
128 virtual bool analyze(CallSite CS, const Analysis& A) { 129 virtual bool analyze(CallSite CS, const Analysis& A) {
220 // those can be ignored) 221 // those can be ignored)
221 Constant* hasCustomDelete = dyn_cast<Constant>(MD_GetElement(node, CD_CustomDelete)); 222 Constant* hasCustomDelete = dyn_cast<Constant>(MD_GetElement(node, CD_CustomDelete));
222 if (hasDestructor == NULL || hasCustomDelete == NULL) 223 if (hasDestructor == NULL || hasCustomDelete == NULL)
223 return false; 224 return false;
224 225
225 if (ConstantExpr::getOr(hasDestructor, hasCustomDelete) 226 if (Context->getConstantExprOr(hasDestructor, hasCustomDelete)
226 != ConstantInt::getFalse()) 227 != ConstantInt::getFalse())
227 return false; 228 return false;
228 229
229 Ty = MD_GetElement(node, CD_BodyType)->getType(); 230 Ty = MD_GetElement(node, CD_BodyType)->getType();
230 return true; 231 return true;
231 } 232 }
232 233
233 // The default promote() should be fine. 234 // The default promote() should be fine.
234 235
235 AllocClassFI() : FunctionInfo(~0u, true) {} 236 AllocClassFI(LLVMContext* context) : FunctionInfo(context, ~0u, true) {}
236 }; 237 };
237 } 238 }
238 239
239 240
240 //===----------------------------------------------------------------------===// 241 //===----------------------------------------------------------------------===//
283 return new GarbageCollect2Stack(); 284 return new GarbageCollect2Stack();
284 } 285 }
285 286
286 GarbageCollect2Stack::GarbageCollect2Stack() 287 GarbageCollect2Stack::GarbageCollect2Stack()
287 : FunctionPass(&ID), 288 : FunctionPass(&ID),
288 AllocMemoryT(0, true), 289 AllocMemoryT(Context, 0, true),
289 NewArrayVT(0, true, false, 1), 290 NewArrayVT(Context, 0, true, false, 1),
290 NewArrayT(0, true, true, 1) 291 NewArrayT(Context, 0, true, true, 1),
292 AllocClass(Context)
291 { 293 {
292 KnownFunctions["_d_allocmemoryT"] = &AllocMemoryT; 294 KnownFunctions["_d_allocmemoryT"] = &AllocMemoryT;
293 KnownFunctions["_d_newarrayvT"] = &NewArrayVT; 295 KnownFunctions["_d_newarrayvT"] = &NewArrayVT;
294 KnownFunctions["_d_newarrayT"] = &NewArrayT; 296 KnownFunctions["_d_newarrayT"] = &NewArrayT;
295 KnownFunctions["_d_allocclass"] = &AllocClass; 297 KnownFunctions["_d_allocclass"] = &AllocClass;