[llvm-dev] Malloc signature errors
David Blaikie via llvm-dev
llvm-dev at lists.llvm.org
Thu Jun 17 10:49:46 PDT 2021
Might be missing the noalias attribute on the result?
On Thu, Jun 17, 2021 at 10:46 AM zealain via llvm-dev <
llvm-dev at lists.llvm.org> wrote:
> Hello
>
> 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 =
> CallInst::CreateMalloc(this->currentFunction->getEntryBlock().getFirstNonPHI(),
>
> int8Type->getPointerTo(), 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.
>
> Regards,
> Z
> _______________________________________________
> LLVM Developers mailing list
> llvm-dev at lists.llvm.org
> https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20210617/78a46b63/attachment.html>
More information about the llvm-dev
mailing list