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

Matt Arsenault via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Apr 11 19:27:55 PDT 2017


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();
+}
+
 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;
+  }
+
   /// Return the builtin name for the __builtin___clear_cache intrinsic
   /// Default is to invoke the clear cache library call
   virtual const char * getClearCacheBuiltinName() const {


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D31962.94931.patch
Type: text/x-patch
Size: 2281 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170412/d1404650/attachment.bin>


More information about the llvm-commits mailing list