<div dir="ltr">Might be missing the noalias attribute on the result?</div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Thu, Jun 17, 2021 at 10:46 AM zealain via llvm-dev <<a href="mailto:llvm-dev@lists.llvm.org">llvm-dev@lists.llvm.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr">Hello<div><br></div><div>I am trying to insert malloc calls in my function pass, yet it keeps complaining about the parameter type:</div><div><br></div><div><font face="monospace">Call parameter type does not match function signature!<br>i64 4096<br> i8*  %malloccall = tail call i8* @malloc(i64 4096)</font><br></div><div><font face="monospace"><br></font></div><div><font face="arial, sans-serif">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:</font></div><div><font face="arial, sans-serif"><br></font></div><div><font face="monospace">%2 = call noalias i8* @malloc(i64 4096) #2</font><font face="arial, sans-serif"><br></font></div><div><br></div><div>Why does one work but the other doesn't? Below is the code I use to generate the instruction:</div><div><br></div><div>T<font face="monospace">ype *int8Type = Type::getInt8Ty(this->currentFunction->getContext());<br>Type *int64Type = Type::getInt64Ty(this->currentFunction->getContext());<br><br>auto allocSize = ConstantInt::get(int64Type, 4096);<br><br>Instruction* mallocInstr = CallInst::CreateMalloc(this->currentFunction->getEntryBlock().getFirstNonPHI(),<br>                                                  int8Type->getPointerTo(), int8Type, allocSize,<br>                                                  nullptr, nullptr, "");</font><br></div><div><font face="arial, sans-serif"><br></font></div><div><font face="arial, sans-serif">I tried changing up the types already but didn't find a combination that works yet. Any hints would be appreciated.</font></div><div><font face="monospace"><br></font></div><div><font face="arial, sans-serif">Regards,</font></div><div><font face="arial, sans-serif">Z</font></div></div>
_______________________________________________<br>
LLVM Developers mailing list<br>
<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a><br>
<a href="https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" rel="noreferrer" target="_blank">https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev</a><br>
</blockquote></div>