[PATCH] D77513: [RDA] Use TinyPtrVector to store reaching defs (NFCI)
Nikita Popov via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Apr 8 09:13:16 PDT 2020
This revision was automatically updated to reflect the committed changes.
Closed by commit rG952c2741599e: [RDA] Use TinyPtrVector to store reaching defs (NFCI) (authored by nikic).
Changed prior to commit:
https://reviews.llvm.org/D77513?vs=255192&id=256041#toc
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D77513/new/
https://reviews.llvm.org/D77513
Files:
llvm/include/llvm/CodeGen/ReachingDefAnalysis.h
Index: llvm/include/llvm/CodeGen/ReachingDefAnalysis.h
===================================================================
--- llvm/include/llvm/CodeGen/ReachingDefAnalysis.h
+++ llvm/include/llvm/CodeGen/ReachingDefAnalysis.h
@@ -23,6 +23,7 @@
#include "llvm/ADT/DenseMap.h"
#include "llvm/ADT/SmallVector.h"
+#include "llvm/ADT/TinyPtrVector.h"
#include "llvm/CodeGen/LoopTraversal.h"
#include "llvm/CodeGen/MachineFunctionPass.h"
#include "llvm/InitializePasses.h"
@@ -32,6 +33,37 @@
class MachineBasicBlock;
class MachineInstr;
+/// Thin wrapper around "int" used to store reaching definitions,
+/// using an encoding that makes it compatible with TinyPtrVector.
+/// The 0th LSB is forced zero (and will be used for pointer union tagging),
+/// The 1st LSB is forced one (to make sure the value is non-zero).
+class ReachingDef {
+ uintptr_t Encoded;
+ friend struct PointerLikeTypeTraits<ReachingDef>;
+ explicit ReachingDef(uintptr_t Encoded) : Encoded(Encoded) {}
+
+public:
+ ReachingDef(int Instr) : Encoded((Instr << 2) | 2) {}
+ operator int() const { return ((int) Encoded) >> 2; }
+};
+
+template<>
+struct PointerLikeTypeTraits<ReachingDef> {
+ static constexpr int NumLowBitsAvailable = 1;
+
+ static inline void *getAsVoidPointer(const ReachingDef &RD) {
+ return reinterpret_cast<void *>(RD.Encoded);
+ }
+
+ static inline ReachingDef getFromVoidPointer(void *P) {
+ return ReachingDef(reinterpret_cast<uintptr_t>(P));
+ }
+
+ static inline ReachingDef getFromVoidPointer(const void *P) {
+ return ReachingDef(reinterpret_cast<uintptr_t>(P));
+ }
+};
+
/// This class provides the reaching def analysis.
class ReachingDefAnalysis : public MachineFunctionPass {
private:
@@ -61,7 +93,7 @@
DenseMap<MachineInstr *, int> InstIds;
/// All reaching defs of a given RegUnit for a given MBB.
- using MBBRegUnitDefs = SmallVector<int, 1>;
+ using MBBRegUnitDefs = TinyPtrVector<ReachingDef>;
/// All reaching defs of all reg units for a given MBB
using MBBDefsInfo = std::vector<MBBRegUnitDefs>;
/// All reaching defs of all reg units for a all MBBs
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D77513.256041.patch
Type: text/x-patch
Size: 2114 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200408/a1c1ea65/attachment.bin>
More information about the llvm-commits
mailing list