<html><head></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><br><div><div>On Sep 22, 2009, at 11:23 AM, Victor Hernandez wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><span class="Apple-style-span" style="border-collapse: separate; font-family: Helvetica; font-size: medium; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; ">On Sep 22, 2009, at 6:11 AM, Duncan Sands wrote:<br><br><blockquote type="cite">Hi Victor, this code from the verifier broke the Ada front-end build:<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">const Module* M = CI.getParent()->getParent()->getParent();<br></blockquote><blockquote type="cite">Constant *MallocFunc = M->getFunction("malloc");<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">if (CI.getOperand(0) == MallocFunc) {<br></blockquote><blockquote type="cite">  const PointerType *PTy =<br></blockquote><blockquote type="cite">PointerType::getUnqual(Type::getInt8Ty(CI.getParent()->getContext()));<br></blockquote><blockquote type="cite">  Assert1(CI.getType() == PTy, "Malloc call must return i8*", &CI);<br></blockquote><blockquote type="cite">}<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">I think it is completely wrong for the verifier to be checking  <br></blockquote><blockquote type="cite">anything<br></blockquote><blockquote type="cite">about calls to functions that happen to be called "malloc".  What if I<br></blockquote><blockquote type="cite">have my own runtime in which "malloc" is completely different to the<br></blockquote><blockquote type="cite">usual one?  From my reading of the gcc docs, malloc is not provided<br></blockquote><blockquote type="cite">in a freestanding environment and thus cannot be assumed to be the<br></blockquote><blockquote type="cite">normal malloc.<br></blockquote><br>What does the Ada front-end declare malloc as?<br><br><blockquote type="cite"><br></blockquote><blockquote type="cite">I think this code should be removed from the verifier.  Instead,<br></blockquote><blockquote type="cite">isMalloc should also check the number of parameters and their types,<br></blockquote><blockquote type="cite">as well as the return value.<br></blockquote><br>The verifier code is needed because when a malloc return value is used  <br>directly, not via a bitcast, the type of the malloc is determined to  <br>be i8*.  But that could be updated to use the declared return type of  <br>malloc.  I need to understand more about how this is breaking Ada to  <br>determine how to resolve this.  Removing this check from the verifier  <br>could end up being the resolution.</span></blockquote></div><br><div>Just looked at <span class="Apple-style-span" style="font-family: Menlo; font-size: 11px; ">getMallocType() <span class="Apple-style-span" style="font-family: Helvetica; font-size: medium; ">and it does not assume that the return type of a malloc call is i8*, so I have removed this check from the verifier.</span></span></div><div><br></div><div>Victor</div></body></html>