sammccall created this revision.
Herald added subscribers: martong, xazax.hun.
Herald added a reviewer: NoQ.
Herald added a project: All.
sammccall requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

This appears to be just an accidental copy rather than move from a scratch
variable.
As well as doing redundant work, these copies introduce extra SAT variables
which make debugging harder (each Enviroment has a unique FC token).

Example flow condition before:

  (B0:1 = V15)
  (B1:1 = V8)
  (B2:1 = V10)
  (B3:1 = (V4 & (!V7 => V6)))
  (V10 = (B3:1 & !V7))
  (V12 = B1:1)
  (V13 = B2:1)
  (V15 = (V12 | V13))
  (V3 = V2)
  (V4 = V3)
  (V8 = (B3:1 & !!V7))
  B0:1
  V2

after:

  (B0:1 = (V9 | V10))
  (B1:1 = (B3:1 & !!V6))
  (B2:1 = (B3:1 & !V6))
  (B3:1 = (V3 & (!V6 => V5)))
  (V10 = B2:1)
  (V3 = V2)
  (V9 = B1:1)
  B0:1
  V2

(with labelling from D153488 <https://reviews.llvm.org/D153488>)

There are also some more copies that can be avoided here (when multiple blocks
without terminating statements are joined), but they're less trivial, so I'll
put those in another patch.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D153491

Files:
  clang/lib/Analysis/FlowSensitive/TypeErasedDataflowAnalysis.cpp


Index: clang/lib/Analysis/FlowSensitive/TypeErasedDataflowAnalysis.cpp
===================================================================
--- clang/lib/Analysis/FlowSensitive/TypeErasedDataflowAnalysis.cpp
+++ clang/lib/Analysis/FlowSensitive/TypeErasedDataflowAnalysis.cpp
@@ -269,7 +269,7 @@
     // initialize the state of each basic block differently.
     MaybeState.emplace(Analysis.typeErasedInitialElement(), AC.InitEnv);
   }
-  return *MaybeState;
+  return std::move(*MaybeState);
 }
 
 /// Built-in transfer function for `CFGStmt`.


Index: clang/lib/Analysis/FlowSensitive/TypeErasedDataflowAnalysis.cpp
===================================================================
--- clang/lib/Analysis/FlowSensitive/TypeErasedDataflowAnalysis.cpp
+++ clang/lib/Analysis/FlowSensitive/TypeErasedDataflowAnalysis.cpp
@@ -269,7 +269,7 @@
     // initialize the state of each basic block differently.
     MaybeState.emplace(Analysis.typeErasedInitialElement(), AC.InitEnv);
   }
-  return *MaybeState;
+  return std::move(*MaybeState);
 }
 
 /// Built-in transfer function for `CFGStmt`.
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to