Skip to content

Commit c0a8fb2

Browse files
authored
[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.
1 parent 23d8616 commit c0a8fb2

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

llvm/include/llvm/CodeGen/MachineFunction.h

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
#define LLVM_CODEGEN_MACHINEFUNCTION_H
1919

2020
#include "llvm/ADT/ArrayRef.h"
21-
#include "llvm/ADT/BitVector.h"
2221
#include "llvm/ADT/DenseMap.h"
2322
#include "llvm/ADT/GraphTraits.h"
2423
#include "llvm/ADT/SmallVector.h"
@@ -34,6 +33,7 @@
3433
#include "llvm/Support/Compiler.h"
3534
#include "llvm/Support/Recycler.h"
3635
#include "llvm/Target/TargetOptions.h"
36+
#include <bitset>
3737
#include <cassert>
3838
#include <cstdint>
3939
#include <memory>
@@ -217,22 +217,21 @@ class MachineFunctionProperties {
217217
}
218218

219219
MachineFunctionProperties &reset(const MachineFunctionProperties &MFP) {
220-
Properties.reset(MFP.Properties);
220+
Properties &= ~MFP.Properties;
221221
return *this;
222222
}
223223

224224
// Returns true if all properties set in V (i.e. required by a pass) are set
225225
// in this.
226226
bool verifyRequiredProperties(const MachineFunctionProperties &V) const {
227-
return !V.Properties.test(Properties);
227+
return (Properties | ~V.Properties).all();
228228
}
229229

230230
/// Print the MachineFunctionProperties in human-readable form.
231231
void print(raw_ostream &OS) const;
232232

233233
private:
234-
BitVector Properties =
235-
BitVector(static_cast<unsigned>(Property::LastProperty)+1);
234+
std::bitset<static_cast<unsigned>(Property::LastProperty) + 1> Properties;
236235
};
237236

238237
struct SEHHandler {

0 commit comments

Comments
 (0)