[cfe-commits] r85988 - in /cfe/trunk: lib/CodeGen/CGCXX.cpp test/CodeGenCXX/virt.cpp

Chris Lattner clattner at apple.com
Tue Nov 3 20:41:02 PST 2009


On Nov 3, 2009, at 4:53 PM, Mike Stump wrote:

> Author: mrs
> Date: Tue Nov  3 18:53:51 2009
> New Revision: 85988
>
> URL: http://llvm.org/viewvc/llvm-project?rev=85988&view=rev
> Log:
> Split out return adjustments in thunks from this adjustment in thunks
> so the optimizer can tailcall into the return value adjustment thunk.
> This improves codesize for complex hierarchies.

Hi Mike,

Doing filecheck on the generated x86-64 code is going to be very  
unstable.  I'd strongly recommend pattern matching on the -O0 LLVM IR.

-Chris

>
> Modified:
>    cfe/trunk/lib/CodeGen/CGCXX.cpp
>    cfe/trunk/test/CodeGenCXX/virt.cpp
>
> Modified: cfe/trunk/lib/CodeGen/CGCXX.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGCXX.cpp?rev=85988&r1=85987&r2=85988&view=diff
>
> = 
> = 
> = 
> = 
> = 
> = 
> = 
> = 
> ======================================================================
> --- cfe/trunk/lib/CodeGen/CGCXX.cpp (original)
> +++ cfe/trunk/lib/CodeGen/CGCXX.cpp Tue Nov  3 18:53:51 2009
> @@ -779,9 +779,17 @@
>
>   QualType ArgType = MD->getThisType(getContext());
>   llvm::Value *Arg = Builder.CreateLoad(LocalDeclMap[ThisDecl],  
> "this");
> -  if (nv_t || v_t)
> +  if (nv_t || v_t) {
>     // Do the this adjustment.
> +    const llvm::Type *OrigTy = Callee->getType();
>     Arg = DynamicTypeAdjust(Arg, nv_t, v_t);
> +    if (nv_r || v_r) {
> +      Callee = CGM.BuildCovariantThunk(MD, Extern, 0, 0, nv_r, v_r);
> +      Callee = Builder.CreateBitCast(Callee, OrigTy);
> +      nv_r = v_r = 0;
> +    }
> +  }
> +
>   CallArgs.push_back(std::make_pair(RValue::get(Arg), ArgType));
>
>   for (FunctionDecl::param_const_iterator i = MD->param_begin(),
> @@ -795,7 +803,6 @@
>     CallArgs.push_back(std::make_pair(EmitCallArg(Arg, ArgType),  
> ArgType));
>   }
>
> -  // FIXME: be sure to call the right function when we thunk to a  
> thunk
>   RValue RV = EmitCall(CGM.getTypes().getFunctionInfo(ResultType,  
> CallArgs),
>                        Callee, CallArgs, MD);
>   if (nv_r || v_r) {
>
> Modified: cfe/trunk/test/CodeGenCXX/virt.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/virt.cpp?rev=85988&r1=85987&r2=85988&view=diff
>
> = 
> = 
> = 
> = 
> = 
> = 
> = 
> = 
> ======================================================================
> --- cfe/trunk/test/CodeGenCXX/virt.cpp (original)
> +++ cfe/trunk/test/CodeGenCXX/virt.cpp Tue Nov  3 18:53:51 2009
> @@ -93,10 +93,10 @@
>
> // FIXME: This is the wrong thunk, but until these issues are fixed,  
> better
> // than nothing.
> -// CHECK-LP64:     __ZTcvn16_n72_v16_n32_N8test16_D4foo1Ev27:
> -// CHECK-LP64-NEXT:Leh_func_begin33:
> +// CHECK-LP64:     __ZTcvn16_n72_v16_n32_N8test16_D4foo1Ev:
> +// CHECK-LP64-NEXT:Leh_func_begin43:
> // CHECK-LP64-NEXT:    subq    $24, %rsp
> -// CHECK-LP64-NEXT:Llabel33:
> +// CHECK-LP64-NEXT:Llabel43:
> // CHECK-LP64-NEXT:    movq    %rdi, %rax
> // CHECK-LP64-NEXT:    movq    %rax, 8(%rsp)
> // CHECK-LP64-NEXT:    movq    8(%rsp), %rax
> @@ -108,6 +108,20 @@
> // CHECK-LP64-NEXT:    addq    %rax, %rcx
> // CHECK-LP64-NEXT:    movq    %rcx, %rax
> // CHECK-LP64-NEXT:    movq    %rax, %rdi
> +// CHECK-LP64-NEXT:    call    __ZTch0_v16_n32_N8test16_D4foo1Ev
> +// CHECK-LP64-NEXT:    movq    %rax, 16(%rsp)
> +// CHECK-LP64-NEXT:    movq    16(%rsp), %rax
> +// CHECK-LP64-NEXT:    addq    $24, %rsp
> +// CHECK-LP64-NEXT:    ret
> +
> +// CHECK-LP64:     __ZTch0_v16_n32_N8test16_D4foo1Ev:
> +// CHECK-LP64-NEXT:Leh_func_begin44:
> +// CHECK-LP64-NEXT:    subq    $24, %rsp
> +// CHECK-LP64-NEXT:Llabel44:
> +// CHECK-LP64-NEXT:    movq    %rdi, %rax
> +// CHECK-LP64-NEXT:    movq    %rax, 8(%rsp)
> +// CHECK-LP64-NEXT:    movq    8(%rsp), %rax
> +// CHECK-LP64-NEXT:    movq    %rax, %rdi
> // CHECK-LP64-NEXT:    call    __ZN8test16_D4foo1Ev
> // CHECK-LP64-NEXT:    movq    %rax, %rcx
> // CHECK-LP64-NEXT:    movabsq $16, %rdx
>
>
> _______________________________________________
> 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