From 618d422cdd0b853d55b2c7d8d975d4a835732190 Mon Sep 17 00:00:00 2001 From: Bill Wendling Date: Tue, 30 Sep 2008 22:05:33 +0000 Subject: [PATCH] Just don't transform this memset into "bzero" if no-builtin is specified. llvm-svn: 56888 --- lib/Target/X86/X86ISelLowering.cpp | 34 ++++++++++++++++-------------- lib/Target/X86/X86Subtarget.cpp | 4 ++-- lib/Target/X86/X86Subtarget.h | 2 +- test/CodeGen/X86/darwin-bzero.ll | 2 +- 4 files changed, 22 insertions(+), 20 deletions(-) diff --git a/lib/Target/X86/X86ISelLowering.cpp b/lib/Target/X86/X86ISelLowering.cpp index 1d3fa288273..755554ba282 100644 --- a/lib/Target/X86/X86ISelLowering.cpp +++ b/lib/Target/X86/X86ISelLowering.cpp @@ -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(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 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 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. diff --git a/lib/Target/X86/X86Subtarget.cpp b/lib/Target/X86/X86Subtarget.cpp index 3eb0e28aab4..0d90ef61169 100644 --- a/lib/Target/X86/X86Subtarget.cpp +++ b/lib/Target/X86/X86Subtarget.cpp @@ -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; } diff --git a/lib/Target/X86/X86Subtarget.h b/lib/Target/X86/X86Subtarget.h index 98ebe89a229..b95a2e45e5e 100644 --- a/lib/Target/X86/X86Subtarget.h +++ b/lib/Target/X86/X86Subtarget.h @@ -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 { diff --git a/test/CodeGen/X86/darwin-bzero.ll b/test/CodeGen/X86/darwin-bzero.ll index 941577eae1c..63185cc2d23 100644 --- a/test/CodeGen/X86/darwin-bzero.ll +++ b/test/CodeGen/X86/darwin-bzero.ll @@ -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)