[llvm-dev] Malloc signature errors

zealain via llvm-dev llvm-dev at lists.llvm.org
Thu Jun 17 01:47:39 PDT 2021


I am trying to insert malloc calls in my function pass, yet it keeps
complaining about the parameter type:

Call parameter type does not match function signature!
i64 4096
 i8*  %malloccall = tail call i8* @malloc(i64 4096)

Comparing this to a call generated by simply having a malloc in the C code,
I cannot spot significant differences. The following (generated by clang)
works just fine:

%2 = call noalias i8* @malloc(i64 4096) #2

Why does one work but the other doesn't? Below is the code I use to
generate the instruction:

Type *int8Type = Type::getInt8Ty(this->currentFunction->getContext());
Type *int64Type = Type::getInt64Ty(this->currentFunction->getContext());

auto allocSize = ConstantInt::get(int64Type, 4096);

Instruction* mallocInstr =
int8Type, allocSize,
                                                  nullptr, nullptr, "");

I tried changing up the types already but didn't find a combination that
works yet. Any hints would be appreciated.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20210617/4a9ed14d/attachment.html>

More information about the llvm-dev mailing list