-
Notifications
You must be signed in to change notification settings - Fork 14.6k
[NFC] Split UniqueBBID definition to a separate file. #148043
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@llvm/pr-subscribers-llvm-support Author: Rahman Lavaee (rlavaee) ChangesFull diff: https://github.com/llvm/llvm-project/pull/148043.diff 6 Files Affected:
diff --git a/llvm/include/llvm/CodeGen/BasicBlockSectionsProfileReader.h b/llvm/include/llvm/CodeGen/BasicBlockSectionsProfileReader.h
index 08e6a0e3ef629..f0cfa7663c5fa 100644
--- a/llvm/include/llvm/CodeGen/BasicBlockSectionsProfileReader.h
+++ b/llvm/include/llvm/CodeGen/BasicBlockSectionsProfileReader.h
@@ -19,7 +19,6 @@
#include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/StringMap.h"
#include "llvm/ADT/StringRef.h"
-#include "llvm/CodeGen/MachineBasicBlock.h"
#include "llvm/IR/Module.h"
#include "llvm/IR/PassManager.h"
#include "llvm/InitializePasses.h"
@@ -27,12 +26,13 @@
#include "llvm/Support/Error.h"
#include "llvm/Support/LineIterator.h"
#include "llvm/Support/MemoryBuffer.h"
+#include "llvm/Support/UniqueBBID.h"
#include "llvm/Target/TargetMachine.h"
namespace llvm {
// This struct represents the cluster information for a machine basic block,
-// which is specifed by a unique ID (`MachineBasicBlock::BBID`).
+// which is specifed by a unique basic block ID.
struct BBClusterInfo {
// Basic block ID.
UniqueBBID BBID;
@@ -52,27 +52,6 @@ struct FunctionPathAndClusterInfo {
SmallVector<SmallVector<unsigned>> ClonePaths;
};
-// Provides DenseMapInfo for UniqueBBID.
-template <> struct DenseMapInfo<UniqueBBID> {
- static inline UniqueBBID getEmptyKey() {
- unsigned EmptyKey = DenseMapInfo<unsigned>::getEmptyKey();
- return UniqueBBID{EmptyKey, EmptyKey};
- }
- static inline UniqueBBID getTombstoneKey() {
- unsigned TombstoneKey = DenseMapInfo<unsigned>::getTombstoneKey();
- return UniqueBBID{TombstoneKey, TombstoneKey};
- }
- static unsigned getHashValue(const UniqueBBID &Val) {
- std::pair<unsigned, unsigned> PairVal =
- std::make_pair(Val.BaseID, Val.CloneID);
- return DenseMapInfo<std::pair<unsigned, unsigned>>::getHashValue(PairVal);
- }
- static bool isEqual(const UniqueBBID &LHS, const UniqueBBID &RHS) {
- return DenseMapInfo<unsigned>::isEqual(LHS.BaseID, RHS.BaseID) &&
- DenseMapInfo<unsigned>::isEqual(LHS.CloneID, RHS.CloneID);
- }
-};
-
class BasicBlockSectionsProfileReader {
public:
friend class BasicBlockSectionsProfileReaderWrapperPass;
diff --git a/llvm/include/llvm/CodeGen/MachineBasicBlock.h b/llvm/include/llvm/CodeGen/MachineBasicBlock.h
index 3d2da01f2c856..938d71dd030e8 100644
--- a/llvm/include/llvm/CodeGen/MachineBasicBlock.h
+++ b/llvm/include/llvm/CodeGen/MachineBasicBlock.h
@@ -25,6 +25,7 @@
#include "llvm/MC/LaneBitmask.h"
#include "llvm/Support/BranchProbability.h"
#include "llvm/Support/Compiler.h"
+#include "llvm/Support/UniqueBBID.h"
#include <cassert>
#include <cstdint>
#include <iterator>
@@ -99,13 +100,6 @@ template <> struct DenseMapInfo<MBBSectionID> {
}
};
-// This structure represents the information for a basic block pertaining to
-// the basic block sections profile.
-struct UniqueBBID {
- unsigned BaseID;
- unsigned CloneID;
-};
-
template <> struct ilist_traits<MachineInstr> {
private:
friend class MachineBasicBlock; // Set by the owning MachineBasicBlock.
diff --git a/llvm/include/llvm/Support/UniqueBBID.h b/llvm/include/llvm/Support/UniqueBBID.h
new file mode 100644
index 0000000000000..a5715cd107629
--- /dev/null
+++ b/llvm/include/llvm/Support/UniqueBBID.h
@@ -0,0 +1,50 @@
+//===- llvm/Support/UniqueBBID.h --------------------------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+//
+// Unique fixed ID assigned to basic blocks upon their creation.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_SUPPORT_UNIQUEBBID_H
+#define LLVM_SUPPORT_UNIQUEBBID_H
+
+#include "llvm/ADT/DenseMapInfo.h"
+
+namespace llvm {
+
+// This structure represents the information for a basic block pertaining to
+// the basic block sections profile.
+struct UniqueBBID {
+ unsigned BaseID;
+ unsigned CloneID;
+};
+
+// Provides DenseMapInfo for UniqueBBID.
+template <> struct DenseMapInfo<UniqueBBID> {
+ static inline UniqueBBID getEmptyKey() {
+ unsigned EmptyKey = DenseMapInfo<unsigned>::getEmptyKey();
+ return UniqueBBID{EmptyKey, EmptyKey};
+ }
+ static inline UniqueBBID getTombstoneKey() {
+ unsigned TombstoneKey = DenseMapInfo<unsigned>::getTombstoneKey();
+ return UniqueBBID{TombstoneKey, TombstoneKey};
+ }
+ static unsigned getHashValue(const UniqueBBID &Val) {
+ std::pair<unsigned, unsigned> PairVal =
+ std::make_pair(Val.BaseID, Val.CloneID);
+ return DenseMapInfo<std::pair<unsigned, unsigned>>::getHashValue(PairVal);
+ }
+ static bool isEqual(const UniqueBBID &LHS, const UniqueBBID &RHS) {
+ return DenseMapInfo<unsigned>::isEqual(LHS.BaseID, RHS.BaseID) &&
+ DenseMapInfo<unsigned>::isEqual(LHS.CloneID, RHS.CloneID);
+ }
+};
+
+} // end namespace llvm
+
+#endif // LLVM_SUPPORT_UNIQUEBBID_H
diff --git a/llvm/lib/CodeGen/BasicBlockPathCloning.cpp b/llvm/lib/CodeGen/BasicBlockPathCloning.cpp
index b58c60d1db0a9..fd7df6b872fd9 100644
--- a/llvm/lib/CodeGen/BasicBlockPathCloning.cpp
+++ b/llvm/lib/CodeGen/BasicBlockPathCloning.cpp
@@ -41,6 +41,7 @@
#include "llvm/CodeGen/Passes.h"
#include "llvm/CodeGen/TargetInstrInfo.h"
#include "llvm/InitializePasses.h"
+#include "llvm/Support/UniqueBBID.h"
#include "llvm/Support/WithColor.h"
#include "llvm/Target/TargetMachine.h"
diff --git a/llvm/lib/CodeGen/BasicBlockSections.cpp b/llvm/lib/CodeGen/BasicBlockSections.cpp
index 1eedfc4b25912..e317e1c06741f 100644
--- a/llvm/lib/CodeGen/BasicBlockSections.cpp
+++ b/llvm/lib/CodeGen/BasicBlockSections.cpp
@@ -79,6 +79,7 @@
#include "llvm/CodeGen/Passes.h"
#include "llvm/CodeGen/TargetInstrInfo.h"
#include "llvm/InitializePasses.h"
+#include "llvm/Support/UniqueBBID.h"
#include "llvm/Target/TargetMachine.h"
#include <optional>
diff --git a/llvm/lib/CodeGen/BasicBlockSectionsProfileReader.cpp b/llvm/lib/CodeGen/BasicBlockSectionsProfileReader.cpp
index fa54640265162..7baeb3fd7bcee 100644
--- a/llvm/lib/CodeGen/BasicBlockSectionsProfileReader.cpp
+++ b/llvm/lib/CodeGen/BasicBlockSectionsProfileReader.cpp
@@ -26,6 +26,7 @@
#include "llvm/Support/LineIterator.h"
#include "llvm/Support/MemoryBuffer.h"
#include "llvm/Support/Path.h"
+#include "llvm/Support/UniqueBBID.h"
#include <llvm/ADT/STLExtras.h>
using namespace llvm;
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
No description provided.