[llvm-commits] [llvm] r56885 - in /llvm/trunk: include/llvm/Target/TargetLowering.h lib/CodeGen/SelectionDAG/SelectionDAG.cpp lib/Target/X86/X86ISelLowering.cpp lib/Target/X86/X86ISelLowering.h lib/Target/X86/X86Subtarget.cpp lib/Target/X86/X86Su

Evan Cheng evan.cheng at apple.com
Tue Sep 30 16:13:58 PDT 2008


Actually no.  It's a terrible idea. :-)

This logic should not be in codegen at all. Users can still right  
__builtin_memcpy and those can be optimized with -fno-builtin.

So correct solution, take two. :-) FE should not generate calls to  
@llvm.memset.i32 etc. when -fno-builtin is specified. Instead, it  
should generate a simple call to memset. So the only changes required  
are in the FE, LLVM should not know anything about -fno-builtin at  
all. That is, unless simplifylibcall decides to turn memset into  
@llvm.memset*.

Evan

On Sep 30, 2008, at 4:08 PM, Bill Wendling wrote:

> On Tue, Sep 30, 2008 at 3:55 PM, Evan Cheng <evan.cheng at apple.com>  
> wrote:
>>
>> Actually, I think it'd be better to do this the right way.
>
> Bah! :-)
>
>> The correct
>> way to handle this option is to convert all memcpy / memset (and
>> other) intrinsic calls to normal calls. Perhaps in
>> SelectionDAGBuild.cpp? e.g.
>>
>>  case Intrinsic::memcpy_i32:
>>  case Intrinsic::memcpy_i64: {
>>    SDValue Op1 = getValue(I.getOperand(1));
>>    SDValue Op2 = getValue(I.getOperand(2));
>>    SDValue Op3 = getValue(I.getOperand(3));
>>    unsigned Align = cast<ConstantInt>(I.getOperand(4))-
>>> getZExtValue();
>>    DAG.setRoot(DAG.getMemcpy(getRoot(), Op1, Op2, Op3, Align, false,
>>                              I.getOperand(1), 0, I.getOperand(2),  
>> 0));
>>    return 0;
>>  }
>>
>> We can lower it to a call to memcpy with -fno-builtin.
>>
> That's basically what I suggested in another email. So I think it's a
> brilliant idea. ;-)
>
> -bw
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits




More information about the llvm-commits mailing list