[llvm] 4dd103e - [CodeGen][ShrinkWrap] Clarify StackAddressUsedBlockInfo meaning (#80679)

via llvm-commits llvm-commits at lists.llvm.org
Wed Apr 3 01:22:47 PDT 2024


Author: Elizaveta Noskova
Date: 2024-04-03T11:22:43+03:00
New Revision: 4dd103e9c65de7d3dbf12e76fbb72724127ec325

URL: https://github.com/llvm/llvm-project/commit/4dd103e9c65de7d3dbf12e76fbb72724127ec325
DIFF: https://github.com/llvm/llvm-project/commit/4dd103e9c65de7d3dbf12e76fbb72724127ec325.diff

LOG: [CodeGen][ShrinkWrap] Clarify StackAddressUsedBlockInfo meaning (#80679)

Added: 
    

Modified: 
    llvm/lib/CodeGen/ShrinkWrap.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/CodeGen/ShrinkWrap.cpp b/llvm/lib/CodeGen/ShrinkWrap.cpp
index ab57d08e527e4d..a4b2299abc20f9 100644
--- a/llvm/lib/CodeGen/ShrinkWrap.cpp
+++ b/llvm/lib/CodeGen/ShrinkWrap.cpp
@@ -161,9 +161,11 @@ class ShrinkWrap : public MachineFunctionPass {
   /// Current MachineFunction.
   MachineFunction *MachineFunc = nullptr;
 
-  /// Is `true` for block numbers where we can guarantee no stack access
-  /// or computation of stack-relative addresses on any CFG path including
-  /// the block itself.
+  /// Is `true` for the block numbers where we assume possible stack accesses
+  /// or computation of stack-relative addresses on any CFG path including the
+  /// block itself. Is `false` for basic blocks where we can guarantee the
+  /// opposite. False positives won't lead to incorrect analysis results,
+  /// therefore this approach is fair.
   BitVector StackAddressUsedBlockInfo;
 
   /// Check if \p MI uses or defines a callee-saved register or
@@ -948,6 +950,9 @@ bool ShrinkWrap::runOnMachineFunction(MachineFunction &MF) {
 
   bool Changed = false;
 
+  // Initially, conservatively assume that stack addresses can be used in each
+  // basic block and change the state only for those basic blocks for which we
+  // were able to prove the opposite.
   StackAddressUsedBlockInfo.resize(MF.getNumBlockIDs(), true);
   bool HasCandidate = performShrinkWrapping(RPOT, RS.get());
   StackAddressUsedBlockInfo.clear();


        


More information about the llvm-commits mailing list