Skip to content
Snippets Groups Projects
Commit 421f488c authored by Nuno Lopes's avatar Nuno Lopes
Browse files

fix crash when the malloc/free function is defined or is a declaration with 0 parameters.

this pass doesnt seem to be used, but still it's now a little more correct

llvm-svn: 55873
parent 95c2a784
No related branches found
No related tags found
No related merge requests found
......@@ -51,8 +51,7 @@ bool IndMemRemPass::runOnModule(Module &M) {
//happen through intrinsics.
bool changed = false;
if (Function* F = M.getFunction("free")) {
assert(F->isDeclaration() && "free not external?");
if (!F->use_empty()) {
if (F->isDeclaration() && F->arg_size() == 1 && !F->use_empty()) {
Function* FN = Function::Create(F->getFunctionType(),
GlobalValue::LinkOnceLinkage,
"free_llvm_bounce", &M);
......@@ -66,8 +65,7 @@ bool IndMemRemPass::runOnModule(Module &M) {
}
}
if (Function* F = M.getFunction("malloc")) {
assert(F->isDeclaration() && "malloc not external?");
if (!F->use_empty()) {
if (F->isDeclaration() && F->arg_size() == 1 && !F->use_empty()) {
Function* FN = Function::Create(F->getFunctionType(),
GlobalValue::LinkOnceLinkage,
"malloc_llvm_bounce", &M);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment