[PATCH] D31962: DAG: Set hasCalls on frame info earlier

Justin Bogner via llvm-commits llvm-commits at lists.llvm.org
Mon Jun 19 14:23:22 PDT 2017


Matt Arsenault via Phabricator <reviews at reviews.llvm.org> writes:
> arsenm updated this revision to Diff 94931.
> arsenm added a comment.
> Herald added a subscriber: nhaehnle.
>
> Make it a target hook.
>
> There are some special cases that make it difficult to make this
> test generically. SystemZ emits some libcalls as special instructions,
> and this depends on whether the target will end up emitting a
> tail call.
>
>
> https://reviews.llvm.org/D31962
>
> Files:
>   include/llvm/Target/TargetLowering.h
>   lib/CodeGen/SelectionDAG/FunctionLoweringInfo.cpp
>   lib/Target/AMDGPU/SIISelLowering.cpp
>   lib/Target/AMDGPU/SIISelLowering.h
>
> Index: lib/Target/AMDGPU/SIISelLowering.h
> ===================================================================
> --- lib/Target/AMDGPU/SIISelLowering.h
> +++ lib/Target/AMDGPU/SIISelLowering.h
> @@ -132,6 +132,8 @@
>  
>    const SISubtarget *getSubtarget() const;
>  
> +  bool shouldAssumeEmittedAsCall(ImmutableCallSite CS) const override;
> +
>    bool isShuffleMaskLegal(const SmallVectorImpl<int> &/*Mask*/,
>                            EVT /*VT*/) const override;
>  
> Index: lib/Target/AMDGPU/SIISelLowering.cpp
> ===================================================================
> --- lib/Target/AMDGPU/SIISelLowering.cpp
> +++ lib/Target/AMDGPU/SIISelLowering.cpp
> @@ -512,6 +512,11 @@
>  // TargetLowering queries
>  //===----------------------------------------------------------------------===//
>  
> +bool SITargetLowering::shouldAssumeEmittedAsCall(ImmutableCallSite CS) const {
> +  const Function *F = CS.getCalledFunction();
> +  return !F || !F->isIntrinsic();

When does the !F case come up?

> +}
> +
>  bool SITargetLowering::isShuffleMaskLegal(const SmallVectorImpl<int> &,
>                                            EVT) const {
>    // SI has some legal vector types, but no legal vector operations. Say no
> Index: lib/CodeGen/SelectionDAG/FunctionLoweringInfo.cpp
> ===================================================================
> --- lib/CodeGen/SelectionDAG/FunctionLoweringInfo.cpp
> +++ lib/CodeGen/SelectionDAG/FunctionLoweringInfo.cpp
> @@ -190,6 +190,8 @@
>                  MF->getFrameInfo().setHasOpaqueSPAdjustment(true);
>              }
>            }
> +        } else if (TLI->shouldAssumeEmittedAsCall(CS)) {
> +          MF->getFrameInfo().setHasCalls(true);
>          }
>        }
>  
> Index: include/llvm/Target/TargetLowering.h
> ===================================================================
> --- include/llvm/Target/TargetLowering.h
> +++ include/llvm/Target/TargetLowering.h
> @@ -2811,6 +2811,12 @@
>      return false;
>    }
>  
> +  /// Return true if it should be assumed this will be emitted as a call, not a
> +  /// tail call or special instruction.
> +  virtual bool shouldAssumeEmittedAsCall(ImmutableCallSite CS) const {
> +    return false;
> +  }

Based on the comment, defaulting to returning false seems a bit funny
(won't most of these be emitted as a call?).

> +
>    /// Return the builtin name for the __builtin___clear_cache intrinsic
>    /// Default is to invoke the clear cache library call
>    virtual const char * getClearCacheBuiltinName() const {
>


More information about the llvm-commits mailing list