[llvm-commits] [llvm] r161232 - in /llvm/trunk: include/llvm/CodeGen/FastISel.h include/llvm/Target/TargetLowering.h lib/CodeGen/SelectionDAG/FastISel.cpp lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp lib/Target/ARM/ARMFastISel.cpp lib/Target/ARM

Eli Friedman eli.friedman at gmail.com
Thu Aug 2 21:59:36 PDT 2012


On Thu, Aug 2, 2012 at 9:06 PM, Bob Wilson <bob.wilson at apple.com> wrote:
> Author: bwilson
> Date: Thu Aug  2 23:06:28 2012
> New Revision: 161232
>
> URL: http://llvm.org/viewvc/llvm-project?rev=161232&view=rev
> Log:
> Fall back to selection DAG isel for calls to builtin functions.
>
> Fast isel doesn't currently have support for translating builtin function
> calls to target instructions.  For embedded environments where the library
> functions are not available, this is a matter of correctness and not
> just optimization.  Most of this patch is just arranging to make the
> TargetLibraryInfo available in fast isel.  <rdar://problem/12008746>
>
> Modified:
>     llvm/trunk/include/llvm/CodeGen/FastISel.h
>     llvm/trunk/include/llvm/Target/TargetLowering.h
>     llvm/trunk/lib/CodeGen/SelectionDAG/FastISel.cpp
>     llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp
>     llvm/trunk/lib/Target/ARM/ARMFastISel.cpp
>     llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp
>     llvm/trunk/lib/Target/ARM/ARMISelLowering.h
>     llvm/trunk/lib/Target/X86/X86FastISel.cpp
>     llvm/trunk/lib/Target/X86/X86ISelLowering.cpp
>     llvm/trunk/lib/Target/X86/X86ISelLowering.h
>     llvm/trunk/test/CodeGen/X86/fabs.ll
>
> Modified: llvm/trunk/include/llvm/CodeGen/FastISel.h
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/FastISel.h?rev=161232&r1=161231&r2=161232&view=diff
> ==============================================================================
> --- llvm/trunk/include/llvm/CodeGen/FastISel.h (original)
> +++ llvm/trunk/include/llvm/CodeGen/FastISel.h Thu Aug  2 23:06:28 2012
> @@ -34,6 +34,7 @@
>  class MachineRegisterInfo;
>  class TargetData;
>  class TargetInstrInfo;
> +class TargetLibraryInfo;
>  class TargetLowering;
>  class TargetMachine;
>  class TargetRegisterClass;
> @@ -57,6 +58,7 @@
>    const TargetInstrInfo &TII;
>    const TargetLowering &TLI;
>    const TargetRegisterInfo &TRI;
> +  const TargetLibraryInfo *LibInfo;
>
>    /// The position of the last instruction for materializing constants
>    /// for use in the current block. It resets to EmitStartPt when it
> @@ -144,7 +146,8 @@
>    virtual ~FastISel();
>
>  protected:
> -  explicit FastISel(FunctionLoweringInfo &funcInfo);
> +  explicit FastISel(FunctionLoweringInfo &funcInfo,
> +                    const TargetLibraryInfo *libInfo);
>
>    /// TargetSelectInstruction - This method is called by target-independent
>    /// code when the normal FastISel process fails to select an instruction.
>
> Modified: llvm/trunk/include/llvm/Target/TargetLowering.h
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Target/TargetLowering.h?rev=161232&r1=161231&r2=161232&view=diff
> ==============================================================================
> --- llvm/trunk/include/llvm/Target/TargetLowering.h (original)
> +++ llvm/trunk/include/llvm/Target/TargetLowering.h Thu Aug  2 23:06:28 2012
> @@ -51,6 +51,7 @@
>    template<typename T> class SmallVectorImpl;
>    class TargetData;
>    class TargetRegisterClass;
> +  class TargetLibraryInfo;
>    class TargetLoweringObjectFile;
>    class Value;
>
> @@ -1413,7 +1414,8 @@
>
>    /// createFastISel - This method returns a target specific FastISel object,
>    /// or null if the target does not support "fast" ISel.
> -  virtual FastISel *createFastISel(FunctionLoweringInfo &) const {
> +  virtual FastISel *createFastISel(FunctionLoweringInfo &,
> +                                   const TargetLibraryInfo *) const {
>      return 0;
>    }
>
>
> Modified: llvm/trunk/lib/CodeGen/SelectionDAG/FastISel.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/FastISel.cpp?rev=161232&r1=161231&r2=161232&view=diff
> ==============================================================================
> --- llvm/trunk/lib/CodeGen/SelectionDAG/FastISel.cpp (original)
> +++ llvm/trunk/lib/CodeGen/SelectionDAG/FastISel.cpp Thu Aug  2 23:06:28 2012
> @@ -55,6 +55,7 @@
>  #include "llvm/Analysis/Loads.h"
>  #include "llvm/Target/TargetData.h"
>  #include "llvm/Target/TargetInstrInfo.h"
> +#include "llvm/Target/TargetLibraryInfo.h"
>  #include "llvm/Target/TargetLowering.h"
>  #include "llvm/Target/TargetMachine.h"
>  #include "llvm/Support/ErrorHandling.h"
> @@ -789,6 +790,18 @@
>
>    MachineBasicBlock::iterator SavedInsertPt = FuncInfo.InsertPt;
>
> +  // As a special case, don't even try to handle calls to builtin library
> +  // functions so that calls to builtin functions get translated to
> +  // instructions when supported by the target.
> +  if (const CallInst *Call = dyn_cast<CallInst>(I)) {
> +    const Function *F = Call->getCalledFunction();
> +    LibFunc::Func Func;
> +    if (F && !F->hasLocalLinkage() && F->hasName() &&
> +        LibInfo->getLibFunc(F->getName(), Func) &&
> +        LibInfo->has(Func))
> +      return false;
> +  }

This falls back to DAG-isel for any function recognized by
TargetLibraryInfo.  This is means that we can't use fast-isel to
select, for example, printf.  I'm slightly worried about the
compile-time performance impact.

-Eli



More information about the llvm-commits mailing list