-
Notifications
You must be signed in to change notification settings - Fork 15.1k
[llvm] Use static_assert on getEmptyKey and getTombstoneKey (NFC) #167167
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
[llvm] Use static_assert on getEmptyKey and getTombstoneKey (NFC) #167167
Conversation
Note that DenseMapInfo<unsigned>::getEmptyKey() and getTombstoneKey() are constexpr. This patch removes assertion messages as they don't state any more than what's expressed in the assertion condition. Identified with misc-static-assert.
|
@llvm/pr-subscribers-llvm-analysis Author: Kazu Hirata (kazutakahirata) ChangesNote that DenseMapInfo<unsigned>::getEmptyKey() and getTombstoneKey() This patch removes assertion messages as they don't state any more Identified with misc-static-assert. Full diff: https://github.com/llvm/llvm-project/pull/167167.diff 3 Files Affected:
diff --git a/llvm/include/llvm/Analysis/IRSimilarityIdentifier.h b/llvm/include/llvm/Analysis/IRSimilarityIdentifier.h
index 09a8875e1e28c..693777483ade2 100644
--- a/llvm/include/llvm/Analysis/IRSimilarityIdentifier.h
+++ b/llvm/include/llvm/Analysis/IRSimilarityIdentifier.h
@@ -509,11 +509,10 @@ struct IRInstructionMapper {
: InstDataAllocator(IDA), IDLAllocator(IDLA) {
// Make sure that the implementation of DenseMapInfo<unsigned> hasn't
// changed.
- assert(DenseMapInfo<unsigned>::getEmptyKey() == static_cast<unsigned>(-1) &&
- "DenseMapInfo<unsigned>'s empty key isn't -1!");
- assert(DenseMapInfo<unsigned>::getTombstoneKey() ==
- static_cast<unsigned>(-2) &&
- "DenseMapInfo<unsigned>'s tombstone key isn't -2!");
+ static_assert(DenseMapInfo<unsigned>::getEmptyKey() ==
+ static_cast<unsigned>(-1));
+ static_assert(DenseMapInfo<unsigned>::getTombstoneKey() ==
+ static_cast<unsigned>(-2));
IDL = new (IDLAllocator->Allocate())
IRInstructionDataList();
diff --git a/llvm/include/llvm/Transforms/IPO/IROutliner.h b/llvm/include/llvm/Transforms/IPO/IROutliner.h
index 28970f7dcdf10..e8275b2d20ade 100644
--- a/llvm/include/llvm/Transforms/IPO/IROutliner.h
+++ b/llvm/include/llvm/Transforms/IPO/IROutliner.h
@@ -204,10 +204,10 @@ class IROutliner {
: getTTI(GTTI), getIRSI(GIRSI), getORE(GORE) {
// Check that the DenseMap implementation has not changed.
- assert(DenseMapInfo<unsigned>::getEmptyKey() == (unsigned)-1 &&
- "DenseMapInfo<unsigned>'s empty key isn't -1!");
- assert(DenseMapInfo<unsigned>::getTombstoneKey() == (unsigned)-2 &&
- "DenseMapInfo<unsigned>'s tombstone key isn't -2!");
+ static_assert(DenseMapInfo<unsigned>::getEmptyKey() ==
+ static_cast<unsigned>(-1));
+ static_assert(DenseMapInfo<unsigned>::getTombstoneKey() ==
+ static_cast<unsigned>(-2));
}
bool run(Module &M);
diff --git a/llvm/lib/CodeGen/MachineOutliner.cpp b/llvm/lib/CodeGen/MachineOutliner.cpp
index 9feb9740de126..9f95c5ee9cbc6 100644
--- a/llvm/lib/CodeGen/MachineOutliner.cpp
+++ b/llvm/lib/CodeGen/MachineOutliner.cpp
@@ -420,10 +420,10 @@ struct InstructionMapper {
InstructionMapper(const MachineModuleInfo &MMI_) : MMI(MMI_) {
// Make sure that the implementation of DenseMapInfo<unsigned> hasn't
// changed.
- assert(DenseMapInfo<unsigned>::getEmptyKey() == (unsigned)-1 &&
- "DenseMapInfo<unsigned>'s empty key isn't -1!");
- assert(DenseMapInfo<unsigned>::getTombstoneKey() == (unsigned)-2 &&
- "DenseMapInfo<unsigned>'s tombstone key isn't -2!");
+ static_assert(DenseMapInfo<unsigned>::getEmptyKey() ==
+ static_cast<unsigned>(-1));
+ static_assert(DenseMapInfo<unsigned>::getTombstoneKey() ==
+ static_cast<unsigned>(-2));
}
};
|
|
@llvm/pr-subscribers-llvm-transforms Author: Kazu Hirata (kazutakahirata) ChangesNote that DenseMapInfo<unsigned>::getEmptyKey() and getTombstoneKey() This patch removes assertion messages as they don't state any more Identified with misc-static-assert. Full diff: https://github.com/llvm/llvm-project/pull/167167.diff 3 Files Affected:
diff --git a/llvm/include/llvm/Analysis/IRSimilarityIdentifier.h b/llvm/include/llvm/Analysis/IRSimilarityIdentifier.h
index 09a8875e1e28c..693777483ade2 100644
--- a/llvm/include/llvm/Analysis/IRSimilarityIdentifier.h
+++ b/llvm/include/llvm/Analysis/IRSimilarityIdentifier.h
@@ -509,11 +509,10 @@ struct IRInstructionMapper {
: InstDataAllocator(IDA), IDLAllocator(IDLA) {
// Make sure that the implementation of DenseMapInfo<unsigned> hasn't
// changed.
- assert(DenseMapInfo<unsigned>::getEmptyKey() == static_cast<unsigned>(-1) &&
- "DenseMapInfo<unsigned>'s empty key isn't -1!");
- assert(DenseMapInfo<unsigned>::getTombstoneKey() ==
- static_cast<unsigned>(-2) &&
- "DenseMapInfo<unsigned>'s tombstone key isn't -2!");
+ static_assert(DenseMapInfo<unsigned>::getEmptyKey() ==
+ static_cast<unsigned>(-1));
+ static_assert(DenseMapInfo<unsigned>::getTombstoneKey() ==
+ static_cast<unsigned>(-2));
IDL = new (IDLAllocator->Allocate())
IRInstructionDataList();
diff --git a/llvm/include/llvm/Transforms/IPO/IROutliner.h b/llvm/include/llvm/Transforms/IPO/IROutliner.h
index 28970f7dcdf10..e8275b2d20ade 100644
--- a/llvm/include/llvm/Transforms/IPO/IROutliner.h
+++ b/llvm/include/llvm/Transforms/IPO/IROutliner.h
@@ -204,10 +204,10 @@ class IROutliner {
: getTTI(GTTI), getIRSI(GIRSI), getORE(GORE) {
// Check that the DenseMap implementation has not changed.
- assert(DenseMapInfo<unsigned>::getEmptyKey() == (unsigned)-1 &&
- "DenseMapInfo<unsigned>'s empty key isn't -1!");
- assert(DenseMapInfo<unsigned>::getTombstoneKey() == (unsigned)-2 &&
- "DenseMapInfo<unsigned>'s tombstone key isn't -2!");
+ static_assert(DenseMapInfo<unsigned>::getEmptyKey() ==
+ static_cast<unsigned>(-1));
+ static_assert(DenseMapInfo<unsigned>::getTombstoneKey() ==
+ static_cast<unsigned>(-2));
}
bool run(Module &M);
diff --git a/llvm/lib/CodeGen/MachineOutliner.cpp b/llvm/lib/CodeGen/MachineOutliner.cpp
index 9feb9740de126..9f95c5ee9cbc6 100644
--- a/llvm/lib/CodeGen/MachineOutliner.cpp
+++ b/llvm/lib/CodeGen/MachineOutliner.cpp
@@ -420,10 +420,10 @@ struct InstructionMapper {
InstructionMapper(const MachineModuleInfo &MMI_) : MMI(MMI_) {
// Make sure that the implementation of DenseMapInfo<unsigned> hasn't
// changed.
- assert(DenseMapInfo<unsigned>::getEmptyKey() == (unsigned)-1 &&
- "DenseMapInfo<unsigned>'s empty key isn't -1!");
- assert(DenseMapInfo<unsigned>::getTombstoneKey() == (unsigned)-2 &&
- "DenseMapInfo<unsigned>'s tombstone key isn't -2!");
+ static_assert(DenseMapInfo<unsigned>::getEmptyKey() ==
+ static_cast<unsigned>(-1));
+ static_assert(DenseMapInfo<unsigned>::getTombstoneKey() ==
+ static_cast<unsigned>(-2));
}
};
|
Note that DenseMapInfo::getEmptyKey() and getTombstoneKey()
are constexpr.
This patch removes assertion messages as they don't state any more
than what's expressed in the assertion condition.
Identified with misc-static-assert.