<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<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);">
Hi all,</div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);">
<br>
</div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);">
consider the following function from Core.cpp in LLVM 9.0.0:<br>
</div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);">
<br>
</div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);">
<span style="font-family: "Courier New", monospace;">LLVMValueRef LLVMBuildMalloc(LLVMBuilderRef B, LLVMTypeRef Ty,</span><span><br>
</span>
<div><span style="font-family: "Courier New", monospace;">                             const char *Name) {</span><br>
</div>
<div><span style="font-family: "Courier New", monospace; background-color: rgb(255, 255, 0);">  Type* ITy = Type::getInt32Ty(unwrap(B)->GetInsertBlock()->getContext());</span><br>
</div>
<div><span style="font-family: "Courier New", monospace;">  Constant* AllocSize = ConstantExpr::getSizeOf(unwrap(Ty));</span><br>
</div>
<div><span style="font-family: "Courier New", monospace;">  AllocSize = ConstantExpr::getTruncOrBitCast(AllocSize, ITy);</span><br>
</div>
<div><span style="font-family: "Courier New", monospace;">  Instruction* Malloc = CallInst::CreateMalloc(unwrap(B)->GetInsertBlock(),</span><br>
</div>
<div><span style="font-family: "Courier New", monospace;">                                               ITy, unwrap(Ty), AllocSize,</span><br>
</div>
<div><span style="font-family: "Courier New", monospace;">                                               nullptr, nullptr, "");</span><br>
</div>
<div><span style="font-family: "Courier New", monospace;">  return wrap(unwrap(B)->Insert(Malloc, Twine(Name)));</span><br>
</div>
<div><span style="font-family: "Courier New", monospace;">}</span><br>
</div>
<span></span></div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);">
<br>
</div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);">
In this code I highlighted the line which I have question on. the signature of malloc is</div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);">
<br>
</div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);">
<span style="font-family: "Courier New", monospace;">void *malloc(size_t size);</span></div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);">
<br>
</div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);">
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?<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>
</body>
</html>