[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 15:55:33 PDT 2008


On Sep 30, 2008, at 3:41 PM, Bill Wendling wrote:

> On Tue, Sep 30, 2008 at 3:35 PM, Evan Cheng <evan.cheng at apple.com>  
> wrote:
>> So your take is -fno-builtin stops gcc from recognizing memcpy,  
>> memset
>> as special functions and optimizing them into something else (e.g.
>> bzero). After re-reading the man page entry a few times, I kinda see
>> it. I wish I can find the code in gcc that does this to have higher
>> confidence.
>>
> As Dale mentioned, the GCC text is not ideal. :-) I couldn't find
> anything in the GCC compiler that transformed a memset into a bzero.
> But I could have simply missed something.
>
> I'm less sure about memcpy and memset (and a few specific others). In
> freestanding mode (which, among other things, implies -fno-builtin),
> GCC still reserves these functions. But bzero should not be assumed to
> exist here.
>
>> However, this means we should 1) rename -no-builtin to something  
>> like -
>> no-builtin-optimization, 2) it should disable all of the  
>> optimizations
>> for memcpy and memset (and probably) others.
>>
> I'm not so keen on renaming the option. It could cause confusion.
> Actually, making it a function note (like Devang suggests) should
> alleviate this.
>
> I agree with (2). As I mentioned in my check-in message, this should
> be done in steps to make sure that we get it correct.

Actually, I think it'd be better to do this the right way. 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.

Evan

>
>
> -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