[llvm] c0a8fb2 - [CodeGen] Use std::bitset for MachineFunctionProperties (#94627)

via llvm-commits llvm-commits at lists.llvm.org
Thu Jun 6 08:13:05 PDT 2024


Author: aengelke
Date: 2024-06-06T17:13:01+02:00
New Revision: c0a8fb2120c6cf1e3006d6cc45eccef6fb5069f5

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

LOG: [CodeGen] Use std::bitset for MachineFunctionProperties (#94627)

The size of the properties is fixed, so no need for a BitVector.
Assigning small, fixed-size bitsets is faster.

It's a minor performance improvement.

Added: 
    

Modified: 
    llvm/include/llvm/CodeGen/MachineFunction.h

Removed: 
    


################################################################################
diff  --git a/llvm/include/llvm/CodeGen/MachineFunction.h b/llvm/include/llvm/CodeGen/MachineFunction.h
index 9f8e846cac45..6e7292abeddb 100644
--- a/llvm/include/llvm/CodeGen/MachineFunction.h
+++ b/llvm/include/llvm/CodeGen/MachineFunction.h
@@ -18,7 +18,6 @@
 #define LLVM_CODEGEN_MACHINEFUNCTION_H
 
 #include "llvm/ADT/ArrayRef.h"
-#include "llvm/ADT/BitVector.h"
 #include "llvm/ADT/DenseMap.h"
 #include "llvm/ADT/GraphTraits.h"
 #include "llvm/ADT/SmallVector.h"
@@ -34,6 +33,7 @@
 #include "llvm/Support/Compiler.h"
 #include "llvm/Support/Recycler.h"
 #include "llvm/Target/TargetOptions.h"
+#include <bitset>
 #include <cassert>
 #include <cstdint>
 #include <memory>
@@ -217,22 +217,21 @@ class MachineFunctionProperties {
   }
 
   MachineFunctionProperties &reset(const MachineFunctionProperties &MFP) {
-    Properties.reset(MFP.Properties);
+    Properties &= ~MFP.Properties;
     return *this;
   }
 
   // Returns true if all properties set in V (i.e. required by a pass) are set
   // in this.
   bool verifyRequiredProperties(const MachineFunctionProperties &V) const {
-    return !V.Properties.test(Properties);
+    return (Properties | ~V.Properties).all();
   }
 
   /// Print the MachineFunctionProperties in human-readable form.
   void print(raw_ostream &OS) const;
 
 private:
-  BitVector Properties =
-      BitVector(static_cast<unsigned>(Property::LastProperty)+1);
+  std::bitset<static_cast<unsigned>(Property::LastProperty) + 1> Properties;
 };
 
 struct SEHHandler {


        


More information about the llvm-commits mailing list