Just don't transform this memset into "bzero" if no-builtin is specified.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@56888 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Bill Wendling 2008-09-30 22:05:33 +00:00
parent 0483d018c4
commit 6e08738d4b
4 changed files with 22 additions and 20 deletions

View File

@ -5148,22 +5148,24 @@ X86TargetLowering::EmitTargetCodeForMemset(SelectionDAG &DAG,
// Check to see if there is a specialized entry-point for memory zeroing.
ConstantSDNode *V = dyn_cast<ConstantSDNode>(Src);
if (const char *bzeroEntry = V &&
V->isNullValue() ? Subtarget->getBZeroEntry(NoBuiltin) : 0) {
MVT IntPtr = getPointerTy();
const Type *IntPtrTy = TD->getIntPtrType();
TargetLowering::ArgListTy Args;
TargetLowering::ArgListEntry Entry;
Entry.Node = Dst;
Entry.Ty = IntPtrTy;
Args.push_back(Entry);
Entry.Node = Size;
Args.push_back(Entry);
std::pair<SDValue,SDValue> CallResult =
LowerCallTo(Chain, Type::VoidTy, false, false, false, false,
CallingConv::C, false,
DAG.getExternalSymbol(bzeroEntry, IntPtr), Args, DAG);
return CallResult.second;
if (!NoBuiltin) {
if (const char *bzeroEntry = V &&
V->isNullValue() ? Subtarget->getBZeroEntry() : 0) {
MVT IntPtr = getPointerTy();
const Type *IntPtrTy = TD->getIntPtrType();
TargetLowering::ArgListTy Args;
TargetLowering::ArgListEntry Entry;
Entry.Node = Dst;
Entry.Ty = IntPtrTy;
Args.push_back(Entry);
Entry.Node = Size;
Args.push_back(Entry);
std::pair<SDValue,SDValue> CallResult =
LowerCallTo(Chain, Type::VoidTy, false, false, false, false,
CallingConv::C, false,
DAG.getExternalSymbol(bzeroEntry, IntPtr), Args, DAG);
return CallResult.second;
}
}
// Otherwise have the target-independent code call memset.

View File

@ -63,10 +63,10 @@ bool X86Subtarget::GVRequiresExtraLoad(const GlobalValue* GV,
/// interface like the non-standard bzero function, if such a function exists on
/// the current subtarget and it is considered prefereable over memset with zero
/// passed as the second argument. Otherwise it returns null.
const char *X86Subtarget::getBZeroEntry(bool NoBuiltin) const {
const char *X86Subtarget::getBZeroEntry() const {
// Darwin 10 has a __bzero entry point for this purpose.
if (getDarwinVers() >= 10)
return NoBuiltin ? "_bzero" : "__bzero";
return "__bzero";
return 0;
}

View File

@ -184,7 +184,7 @@ public:
/// the current subtarget and it is considered prefereable over
/// memset with zero passed as the second argument. Otherwise it
/// returns null.
const char *getBZeroEntry(bool NoBuiltin) const;
const char *getBZeroEntry() const;
};
namespace X86 {

View File

@ -1,5 +1,5 @@
; RUN: llvm-as < %s | llc -mtriple=i386-apple-darwin10 | grep __bzero
; RUN: llvm-as < %s | llc -mtriple=i386-apple-darwin10 -no-builtin | grep _bzero
; RUN: llvm-as < %s | llc -mtriple=i386-apple-darwin10 -no-builtin | grep _memset
declare void @llvm.memset.i32(i8*, i8, i32, i32)