[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

Dale Johannesen dalej at apple.com
Tue Sep 30 16:29:51 PDT 2008


On Sep 30, 2008, at 4:25 PMPDT, Evan Cheng wrote:

>
> On Sep 30, 2008, at 4:21 PM, Dale Johannesen wrote:
>
>>
>> On Sep 30, 2008, at 4:13 PMPDT, Evan Cheng wrote:
>>
>>> 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.
>>
>> Right.
>>
>>> That is, unless simplifylibcall decides to turn memset into
>>> @llvm.memset*.
>>
>> This is why simplifylibcall shouldn't be keying off names.  I don't
>> think I got through before, maybe now....
>
> This is not a simplifylibcall issue though. Even at -O0, llvm-gcc will
> emit these intrinsics. See llvm-convert.cpp:

Yep, that needs to check where -fno-builtin-memset is on.

> void TreeToLLVM::EmitMemSet(Value *DestPtr, Value *SrcVal, Value  
> *Size,
>                             unsigned Align) {
>   const Type *SBP = PointerType::getUnqual(Type::Int8Ty);
>   const Type *IntPtr = TD.getIntPtrType();
>   Value *Ops[4] = {
>     BitCastToType(DestPtr, SBP),
>     CastToSIntType(SrcVal, Type::Int8Ty),
>     CastToSIntType(Size, IntPtr),
>     ConstantInt::get(Type::Int32Ty, Align)
>   };
>
>   Intrinsic::ID IID =
>     (IntPtr == Type::Int32Ty) ? Intrinsic::memset_i32 :
> Intrinsic::memset_i64;
>
>   Builder.CreateCall(Intrinsic::getDeclaration(TheModule, IID), Ops,
> Ops+4);
> }
>
> Evan
>>
>>
>>> 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
>>>
>>> _______________________________________________
>>> llvm-commits mailing list
>>> llvm-commits at cs.uiuc.edu
>>> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
>>
>> _______________________________________________
>> llvm-commits mailing list
>> llvm-commits at cs.uiuc.edu
>> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
>
> _______________________________________________
> 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