if (Function* F = M.getFunction("free")) {
assert(F->isDeclaration() && "free not external?");
if (!F->use_empty()) {
- Function* FN = new Function(F->getFunctionType(),
- GlobalValue::LinkOnceLinkage,
- "free_llvm_bounce", &M);
- BasicBlock* bb = new BasicBlock("entry",FN);
- Instruction* R = new ReturnInst(bb);
+ Function* FN = Function::Create(F->getFunctionType(),
+ GlobalValue::LinkOnceLinkage,
+ "free_llvm_bounce", &M);
+ BasicBlock* bb = BasicBlock::Create("entry",FN);
+ Instruction* R = ReturnInst::Create(bb);
new FreeInst(FN->arg_begin(), R);
++NumBounce;
NumBounceSites += F->getNumUses();
if (Function* F = M.getFunction("malloc")) {
assert(F->isDeclaration() && "malloc not external?");
if (!F->use_empty()) {
- Function* FN = new Function(F->getFunctionType(),
- GlobalValue::LinkOnceLinkage,
- "malloc_llvm_bounce", &M);
- BasicBlock* bb = new BasicBlock("entry",FN);
+ Function* FN = Function::Create(F->getFunctionType(),
+ GlobalValue::LinkOnceLinkage,
+ "malloc_llvm_bounce", &M);
+ BasicBlock* bb = BasicBlock::Create("entry",FN);
Instruction* c = CastInst::createIntegerCast(
FN->arg_begin(), Type::Int32Ty, false, "c", bb);
Instruction* a = new MallocInst(Type::Int8Ty, c, "m", bb);
- new ReturnInst(a, bb);
+ ReturnInst::Create(a, bb);
++NumBounce;
NumBounceSites += F->getNumUses();
F->replaceAllUsesWith(FN);