comparison gen/passes/GarbageCollect2Stack.cpp @ 1571:8d086d552909

IntegerType is now contextifed. Requires llvm >= 78969. resistor says this will be the last context API change :)
author Benjamin Kramer <benny.kra@gmail.com>
date Fri, 14 Aug 2009 00:39:18 +0200
parents 06d5cc873350
children
comparison
equal deleted inserted replaced
1570:ab03cfb3a212 1571:8d086d552909
60 // Helper functions 60 // Helper functions
61 //===----------------------------------------------------------------------===// 61 //===----------------------------------------------------------------------===//
62 62
63 void EmitMemSet(IRBuilder<>& B, Value* Dst, Value* Val, Value* Len, 63 void EmitMemSet(IRBuilder<>& B, Value* Dst, Value* Val, Value* Len,
64 const Analysis& A) { 64 const Analysis& A) {
65 Dst = B.CreateBitCast(Dst, PointerType::getUnqual(Type::Int8Ty)); 65 Dst = B.CreateBitCast(Dst, PointerType::getUnqual(B.getInt8Ty()));
66 66
67 Module *M = B.GetInsertBlock()->getParent()->getParent(); 67 Module *M = B.GetInsertBlock()->getParent()->getParent();
68 const Type* Tys[1]; 68 const Type* Tys[1];
69 Tys[0] = Len->getType(); 69 Tys[0] = Len->getType();
70 Function *MemSet = Intrinsic::getDeclaration(M, Intrinsic::memset, Tys, 1); 70 Function *MemSet = Intrinsic::getDeclaration(M, Intrinsic::memset, Tys, 1);
71 Value *Align = ConstantInt::get(Type::Int32Ty, 1); 71 Value *Align = ConstantInt::get(B.getInt32Ty(), 1);
72 72
73 CallSite CS = B.CreateCall4(MemSet, Dst, Val, Len, Align); 73 CallSite CS = B.CreateCall4(MemSet, Dst, Val, Len, Align);
74 if (A.CGNode) 74 if (A.CGNode)
75 A.CGNode->addCalledFunction(CS, A.CG->getOrInsertFunction(MemSet)); 75 A.CGNode->addCalledFunction(CS, A.CG->getOrInsertFunction(MemSet));
76 } 76 }
77 77
78 static void EmitMemZero(IRBuilder<>& B, Value* Dst, Value* Len, 78 static void EmitMemZero(IRBuilder<>& B, Value* Dst, Value* Len,
79 const Analysis& A) { 79 const Analysis& A) {
80 EmitMemSet(B, Dst, ConstantInt::get(Type::Int8Ty, 0), Len, A); 80 EmitMemSet(B, Dst, ConstantInt::get(B.getInt8Ty(), 0), Len, A);
81 } 81 }
82 82
83 83
84 //===----------------------------------------------------------------------===// 84 //===----------------------------------------------------------------------===//
85 // Helpers for specific types of GC calls. 85 // Helpers for specific types of GC calls.
172 } else { 172 } else {
173 NumToDynSize++; 173 NumToDynSize++;
174 } 174 }
175 175
176 // Convert array size to 32 bits if necessary 176 // Convert array size to 32 bits if necessary
177 Value* count = Builder.CreateIntCast(arrSize, Type::Int32Ty, false); 177 Value* count = Builder.CreateIntCast(arrSize, Builder.getInt32Ty(), false);
178 AllocaInst* alloca = Builder.CreateAlloca(Ty, count, ".nongc_mem"); // FIXME: align? 178 AllocaInst* alloca = Builder.CreateAlloca(Ty, count, ".nongc_mem"); // FIXME: align?
179 179
180 if (Initialized) { 180 if (Initialized) {
181 // For now, only zero-init is supported. 181 // For now, only zero-init is supported.
182 uint64_t size = A.TD.getTypeStoreSize(Ty); 182 uint64_t size = A.TD.getTypeStoreSize(Ty);
585 CallSite CS = CallSite::get(I); 585 CallSite CS = CallSite::get(I);
586 // Not captured if the callee is readonly, doesn't return a copy through 586 // Not captured if the callee is readonly, doesn't return a copy through
587 // its return value and doesn't unwind (a readonly function can leak bits 587 // its return value and doesn't unwind (a readonly function can leak bits
588 // by throwing an exception or not depending on the input value). 588 // by throwing an exception or not depending on the input value).
589 if (CS.onlyReadsMemory() && CS.doesNotThrow() && 589 if (CS.onlyReadsMemory() && CS.doesNotThrow() &&
590 I->getType() == Type::VoidTy) 590 I->getType() == Type::getVoidTy(I->getContext()))
591 break; 591 break;
592 592
593 // Not captured if only passed via 'nocapture' arguments. Note that 593 // Not captured if only passed via 'nocapture' arguments. Note that
594 // calling a function pointer does not in itself cause the pointer to 594 // calling a function pointer does not in itself cause the pointer to
595 // be captured. This is a subtle point considering that (for example) 595 // be captured. This is a subtle point considering that (for example)