[PATCH] D66132: [CodeGen] Add `isSpeculativeExecutionForbidden()` to `TargetTransformInfo`
    Anton Afanasyev via Phabricator via llvm-commits 
    llvm-commits at lists.llvm.org
       
    Tue Aug 13 03:13:54 PDT 2019
    
    
  
anton-afanasyev created this revision.
Herald added subscribers: llvm-commits, hiraditya.
Herald added a project: LLVM.
For particular subtargets setting `isSpeculativeExecutionForbidden()` to true
prevents SimplePRE optimization of MIR code.
Repository:
  rG LLVM Github Monorepo
https://reviews.llvm.org/D66132
Files:
  llvm/include/llvm/CodeGen/TargetInstrInfo.h
  llvm/lib/CodeGen/MachineCSE.cpp
Index: llvm/lib/CodeGen/MachineCSE.cpp
===================================================================
--- llvm/lib/CodeGen/MachineCSE.cpp
+++ llvm/lib/CodeGen/MachineCSE.cpp
@@ -887,8 +887,10 @@
   DT = &getAnalysis<MachineDominatorTree>();
   MBFI = &getAnalysis<MachineBlockFrequencyInfo>();
   LookAheadLimit = TII->getMachineCSELookAheadLimit();
-  bool ChangedPRE, ChangedCSE;
-  ChangedPRE = PerformSimplePRE(DT);
+  bool ChangedPRE = false, ChangedCSE;
+  if (!TII->isSpeculativeExecutionForbidden()) {
+    ChangedPRE = PerformSimplePRE(DT);
+  }
   ChangedCSE = PerformCSE(DT->getRootNode());
   return ChangedPRE || ChangedCSE;
 }
Index: llvm/include/llvm/CodeGen/TargetInstrInfo.h
===================================================================
--- llvm/include/llvm/CodeGen/TargetInstrInfo.h
+++ llvm/include/llvm/CodeGen/TargetInstrInfo.h
@@ -1022,6 +1022,9 @@
   /// even if it has glue.
   virtual bool canCopyGluedNodeDuringSchedule(SDNode *N) const { return false; }
 
+  /// Return true if speculative execution of target instructions is forbidden.
+  virtual bool isSpeculativeExecutionForbidden() const { return false; }
+
 protected:
   /// Target-dependent implementation for foldMemoryOperand.
   /// Target-independent code in foldMemoryOperand will
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D66132.214792.patch
Type: text/x-patch
Size: 1283 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190813/3220abf2/attachment.bin>
    
    
More information about the llvm-commits
mailing list