[llvm] [BOLT] Gadget scanner: reformulate the state for data-flow analysis (PR #131898)

Anatoly Trosinenko via llvm-commits llvm-commits at lists.llvm.org
Tue Mar 25 04:05:24 PDT 2025


================
@@ -169,16 +186,26 @@ struct State {
   std::vector<SmallPtrSet<const MCInst *, 4>> LastInstWritingReg;
   State() {}
   State(unsigned NumRegs, unsigned NumRegsToTrack)
-      : NonAutClobRegs(NumRegs), LastInstWritingReg(NumRegsToTrack) {}
-  State &operator|=(const State &StateIn) {
-    NonAutClobRegs |= StateIn.NonAutClobRegs;
+      : SafeToDerefRegs(NumRegs), LastInstWritingReg(NumRegsToTrack) {}
+
+  /// Returns S, so that S.merge(S1) == S1.merge(S) == S1.
+  static State getMergeNeutralElement(unsigned NumRegs,
+                                      unsigned NumRegsToTrack) {
+    State S(NumRegs, NumRegsToTrack);
+    S.SafeToDerefRegs.set();
----------------
atrosinenko wrote:

This definitely requires some explanatory comment, thanks!

https://github.com/llvm/llvm-project/pull/131898


More information about the llvm-commits mailing list