<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=Windows-1252">
<style type="text/css" style="display:none;"> P {margin-top:0;margin-bottom:0;} </style>
</head>
<body dir="ltr">
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);">
Thank you for your confirmation Eli.<br>
</div>
<div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div id="Signature">
<div></div>
<div id="divtagdefaultwrapper" dir="ltr" style="font-size: 12pt; color: rgb(0, 0, 0); font-family: Calibri, Arial, Helvetica, sans-serif;">
<font size="3"><b>Thanks,</b></font></div>
<div dir="ltr" style="font-size: 12pt; color: rgb(0, 0, 0); font-family: Calibri, Arial, Helvetica, sans-serif;">
<font size="3"><b>Jason Hu</b></font></div>
<div dir="ltr" style="font-size: 12pt; color: rgb(0, 0, 0); font-family: Calibri, Arial, Helvetica, sans-serif;">
<font size="3"><b><a href="https://hustmphrrr.github.io/" style="">https://hustmphrrr.github.io/</a></b></font><br>
<font size="3"><b></b></font><font style="font-size:12pt" size="3"><span style="color: rgb(69, 129, 142);"><span style="font-family:trebuchet ms,sans-serif"><b><a target="_blank" style=""></a></b></span></span></font></div>
</div>
</div>
<div id="appendonsend"></div>
<hr style="display:inline-block;width:98%" tabindex="-1">
<div id="divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" style="font-size:11pt" color="#000000"><b>From:</b> Eli Friedman <efriedma@quicinc.com><br>
<b>Sent:</b> April 15, 2020 2:32 PM<br>
<b>To:</b> Jason -Zhong Sheng- Hu <fdhzs2010@hotmail.com>; llvm-dev <llvm-dev@lists.llvm.org><br>
<b>Subject:</b> RE: [llvm-dev] question on the signature of malloc</font>
<div> </div>
</div>
<style>
<!--
@font-face
        {font-family:"Cambria Math"}
@font-face
        {font-family:Calibri}
p.x_MsoNormal, li.x_MsoNormal, div.x_MsoNormal
        {margin:0in;
        margin-bottom:.0001pt;
        font-size:11.0pt;
        font-family:"Calibri",sans-serif}
a:link, span.x_MsoHyperlink
        {color:blue;
        text-decoration:underline}
span.x_EmailStyle19
        {font-family:"Calibri",sans-serif;
        color:windowtext}
.x_MsoChpDefault
        {font-size:10.0pt}
@page WordSection1
        {margin:1.0in 1.0in 1.0in 1.0in}
div.x_WordSection1
        {}
-->
</style>
<div lang="EN-US" link="blue" vlink="purple">
<div class="x_WordSection1">
<p class="x_MsoNormal">It’s simply wrong.</p>
<p class="x_MsoNormal"> </p>
<p class="x_MsoNormal">On many 64-bit targets, it will appear to work anyway, depending on your luck, due to the way calling conventions works.
</p>
<p class="x_MsoNormal"> </p>
<p class="x_MsoNormal">-Eli</p>
<p class="x_MsoNormal"> </p>
<div>
<div style="border:none; border-top:solid #E1E1E1 1.0pt; padding:3.0pt 0in 0in 0in">
<p class="x_MsoNormal" style="margin-left:.5in"><b>From:</b> llvm-dev <llvm-dev-bounces@lists.llvm.org>
<b>On Behalf Of </b>Jason -Zhong Sheng- Hu via llvm-dev<br>
<b>Sent:</b> Tuesday, April 14, 2020 6:49 PM<br>
<b>To:</b> llvm-dev@lists.llvm.org<br>
<b>Subject:</b> [EXT] [llvm-dev] question on the signature of malloc</p>
</div>
</div>
<p class="x_MsoNormal" style="margin-left:.5in"> </p>
<div>
<p class="x_MsoNormal" style="margin-left:.5in; background:white"><span style="font-size:12.0pt; color:black">Hi all,</span></p>
</div>
<div>
<p class="x_MsoNormal" style="margin-left:.5in; background:white"><span style="font-size:12.0pt; color:black"> </span></p>
</div>
<div>
<p class="x_MsoNormal" style="margin-left:.5in; background:white"><span style="font-size:12.0pt; color:black">consider the following function from Core.cpp in LLVM 9.0.0:</span></p>
</div>
<div>
<p class="x_MsoNormal" style="margin-left:.5in; background:white"><span style="font-size:12.0pt; color:black"> </span></p>
</div>
<div>
<p class="x_MsoNormal" style="margin-left:.5in; background:white"><span style="font-size:12.0pt; font-family:"Courier New"; color:black">LLVMValueRef LLVMBuildMalloc(LLVMBuilderRef B, LLVMTypeRef Ty,</span><span style="font-size:12.0pt; color:black"></span></p>
<div>
<p class="x_MsoNormal" style="margin-left:.5in; background:white"><span style="font-size:12.0pt; font-family:"Courier New"; color:black">                             const char *Name) {</span><span style="font-size:12.0pt; color:black"></span></p>
</div>
<div>
<p class="x_MsoNormal" style="margin-left:.5in; background:white"><span style="font-size:12.0pt; font-family:"Courier New"; color:black; background:yellow">  Type* ITy = Type::getInt32Ty(unwrap(B)->GetInsertBlock()->getContext());</span><span style="font-size:12.0pt; color:black"></span></p>
</div>
<div>
<p class="x_MsoNormal" style="margin-left:.5in; background:white"><span style="font-size:12.0pt; font-family:"Courier New"; color:black">  Constant* AllocSize = ConstantExpr::getSizeOf(unwrap(Ty));</span><span style="font-size:12.0pt; color:black"></span></p>
</div>
<div>
<p class="x_MsoNormal" style="margin-left:.5in; background:white"><span style="font-size:12.0pt; font-family:"Courier New"; color:black">  AllocSize = ConstantExpr::getTruncOrBitCast(AllocSize, ITy);</span><span style="font-size:12.0pt; color:black"></span></p>
</div>
<div>
<p class="x_MsoNormal" style="margin-left:.5in; background:white"><span style="font-size:12.0pt; font-family:"Courier New"; color:black">  Instruction* Malloc = CallInst::CreateMalloc(unwrap(B)->GetInsertBlock(),</span><span style="font-size:12.0pt; color:black"></span></p>
</div>
<div>
<p class="x_MsoNormal" style="margin-left:.5in; background:white"><span style="font-size:12.0pt; font-family:"Courier New"; color:black">                                               ITy, unwrap(Ty), AllocSize,</span><span style="font-size:12.0pt; color:black"></span></p>
</div>
<div>
<p class="x_MsoNormal" style="margin-left:.5in; background:white"><span style="font-size:12.0pt; font-family:"Courier New"; color:black">                                               nullptr, nullptr, "");</span><span style="font-size:12.0pt; color:black"></span></p>
</div>
<div>
<p class="x_MsoNormal" style="margin-left:.5in; background:white"><span style="font-size:12.0pt; font-family:"Courier New"; color:black">  return wrap(unwrap(B)->Insert(Malloc, Twine(Name)));</span><span style="font-size:12.0pt; color:black"></span></p>
</div>
<div>
<p class="x_MsoNormal" style="margin-left:.5in; background:white"><span style="font-size:12.0pt; font-family:"Courier New"; color:black">}</span><span style="font-size:12.0pt; color:black"></span></p>
</div>
</div>
<div>
<p class="x_MsoNormal" style="margin-left:.5in; background:white"><span style="font-size:12.0pt; color:black"> </span></p>
</div>
<div>
<p class="x_MsoNormal" style="margin-left:.5in; background:white"><span style="font-size:12.0pt; color:black">In this code I highlighted the line which I have question on. the signature of malloc is</span></p>
</div>
<div>
<p class="x_MsoNormal" style="margin-left:.5in; background:white"><span style="font-size:12.0pt; color:black"> </span></p>
</div>
<div>
<p class="x_MsoNormal" style="margin-left:.5in; background:white"><span style="font-size:12.0pt; font-family:"Courier New"; color:black">void *malloc(size_t size);</span><span style="font-size:12.0pt; color:black"></span></p>
</div>
<div>
<p class="x_MsoNormal" style="margin-left:.5in; background:white"><span style="font-size:12.0pt; color:black"> </span></p>
</div>
<div>
<p class="x_MsoNormal" style="margin-left:.5in; background:white"><span style="font-size:12.0pt; color:black">is this suspiciously wrong that this builder assumes size_t is 32 bit int? will LLVM backend smart enough to link the right one, which in 64 bit system
 is 64 bit int?</span></p>
</div>
<div>
<div>
<p class="x_MsoNormal" style="margin-left:.5in"><span style="font-size:12.0pt; color:black"> </span></p>
</div>
<div id="x_Signature">
<div id="x_divtagdefaultwrapper">
<p class="x_MsoNormal" style="margin-left:.5in"><b><span style="font-size:12.0pt; color:black">Thanks,</span></b><span style="font-size:12.0pt; color:black"></span></p>
</div>
<div>
<p class="x_MsoNormal" style="margin-left:.5in"><b><span style="font-size:12.0pt; color:black">Jason Hu</span></b><span style="font-size:12.0pt; color:black"></span></p>
</div>
<div>
<p class="x_MsoNormal" style="margin-left:.5in"><b><span style="font-size:12.0pt; color:black"><a href="https://hustmphrrr.github.io/">https://hustmphrrr.github.io/</a></span></b><span style="font-size:12.0pt; color:black"></span></p>
</div>
</div>
</div>
</div>
</div>
</body>
</html>