[cfe-commits] r97653 - /cfe/trunk/lib/CodeGen/CGBuiltin.cpp

Daniel Dunbar daniel at zuster.org
Thu Mar 4 05:41:45 PST 2010


Hi John,

On Wed, Mar 3, 2010 at 2:30 AM, John McCall <rjmccall at apple.com> wrote:
> Author: rjmccall
> Date: Wed Mar  3 04:30:05 2010
> New Revision: 97653
>
> URL: http://llvm.org/viewvc/llvm-project?rev=97653&view=rev
> Log:
> Sketch out an implementation for __builtin_dwarf_cfa.  I have no idea
> why the front-end is calculating the argument to llvm.eh.dwarf.cfa().
>
>
> Modified:
>    cfe/trunk/lib/CodeGen/CGBuiltin.cpp
>
> Modified: cfe/trunk/lib/CodeGen/CGBuiltin.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGBuiltin.cpp?rev=97653&r1=97652&r2=97653&view=diff
> ==============================================================================
> --- cfe/trunk/lib/CodeGen/CGBuiltin.cpp (original)
> +++ cfe/trunk/lib/CodeGen/CGBuiltin.cpp Wed Mar  3 04:30:05 2010
> @@ -59,6 +59,10 @@
>   return RValue::get(CGF.Builder.CreateBinOp(Op, Result, Operand));
>  }
>
> +static llvm::ConstantInt *getInt32(llvm::LLVMContext &Context, int32_t Value) {
> +  return llvm::ConstantInt::get(llvm::Type::getInt32Ty(Context), Value);
> +}

I would prefer not to have a one off utility like this dangling in
CGBuiltin. If we want such a thing, we should consistently use it.

Would it make sense to make this a method on llvm::ConstantInt?

>  RValue CodeGenFunction::EmitBuiltinExpr(const FunctionDecl *FD,
>                                         unsigned BuiltinID, const CallExpr *E) {
>   // See if we can constant fold this builtin.  If so, don't emit it at all.
> @@ -343,6 +347,20 @@
>                         llvm::ConstantInt::get(llvm::Type::getInt32Ty(VMContext), 1));
>     return RValue::get(Address);
>   }
> +  case Builtin::BI__builtin_dwarf_cfa: {
> +    // The offset in bytes from the first argument to the CFA.
> +    //
> +    // Why on earth is this in the frontend?  Is there any reason at
> +    // all that the backend can't reasonably determine this while
> +    // lowering llvm.eh.dwarf.cfa()?
> +    //
> +    // TODO: If there's a satisfactory reason, add a target hook for
> +    // this instead of hard-coding 0, which is correct for most targets.

Please use FIXME instead of TODO for easier grepability. Is this wrong
for targets we actually have support for? If so, it seems like we
should go ahead and add the hook and fix it.

 - Daniel

> +    int32_t Offset = 0;
> +
> +    Value *F = CGM.getIntrinsic(Intrinsic::eh_dwarf_cfa, 0, 0);
> +    return RValue::get(Builder.CreateCall(F, getInt32(VMContext, Offset)));
> +  }
>   case Builtin::BI__builtin_return_address: {
>     Value *Depth = EmitScalarExpr(E->getArg(0));
>     Depth = Builder.CreateIntCast(Depth,
>
>
> _______________________________________________
> cfe-commits mailing list
> cfe-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
>




More information about the cfe-commits mailing list