<div dir="ltr">On Mon, Oct 21, 2013 at 5:47 PM, Rafael Espíndola <span dir="ltr"><<a href="mailto:rafael.espindola@gmail.com" target="_blank">rafael.espindola@gmail.com</a>></span> wrote:<br><div class="gmail_extra">
<div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="im">On 21 October 2013 20:03, Richard Smith <<a href="mailto:richard@metafoo.co.uk">richard@metafoo.co.uk</a>> wrote:<br>

> @@ -929,9 +929,8 @@ static RValue EmitNewDeleteCall(CodeGenFunction &CGF,<br>
>    ///   to a replaceable global allocation function.<br>
>    ///<br>
>    /// We model such elidable calls with the 'builtin' attribute.<br>
> -  llvm::Function *Fn = dyn_cast<llvm::Function>(CalleeAddr);<br>
>    if (Callee->isReplaceableGlobalAllocationFunction() &&<br>
> -      Fn && Fn->hasFnAttribute(llvm::Attribute::NoBuiltin)) {<br>
> +      !Callee->hasAttr<AliasAttr>()) {<br>
><br>
> What's the purpose of this change? Was the previous code broken by deferring<br>
> the emission of aliases?<br>
<br>
</div>Correct. Since the alias was not emitted yet the hasFnAttribute return false.</blockquote><div><br></div><div>OK, that makes sense.</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div class="im">
><br>
> +  llvm::GlobalValue *GV = dyn_cast<llvm::GlobalValue>(Aliasee);<br>
> +  if (!GV) {<br>
> +    llvm::ConstantExpr *CE = cast<llvm::ConstantExpr>(Aliasee);<br>
> +    GV = cast<llvm::GlobalValue>(CE->getOperand(0));<br>
><br>
> Hm, what kinds of ConstantExpr can appear here? This would be more<br>
> self-documenting if you asserted that you'd got the right kind of<br>
> ConstantExpr.<br>
<br>
</div>I can add an assert, but it would be exactly the same as what the Verifier does:<br>
<br>
 Assert1(CE &&<br>
            (CE->getOpcode() == Instruction::BitCast ||<br>
             CE->getOpcode() == Instruction::GetElementPtr) && GV,<br>
            "Aliasee should be either GlobalValue or bitcast of GlobalValue",<br>
            &GA);<br>
<br>
Do you think it is worth it?</blockquote><div><br></div><div>I think we should have *something* here. Just pulling out the first operand of a ConstantExpr without checking what it is looks very suspicious. Can this happen recursively (gep of a bitcast or similar)?</div>
</div></div></div>