From 68f75673ac52426337c90d176892957261426d0a Mon Sep 17 00:00:00 2001 From: Kazu Hirata Date: Thu, 6 Nov 2025 22:59:08 -0800 Subject: [PATCH] [llvm] Use static_assert on getEmptyKey and getTombstoneKey (NFC) 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. --- llvm/include/llvm/Analysis/IRSimilarityIdentifier.h | 9 ++++----- llvm/include/llvm/Transforms/IPO/IROutliner.h | 8 ++++---- llvm/lib/CodeGen/MachineOutliner.cpp | 8 ++++---- 3 files changed, 12 insertions(+), 13 deletions(-) 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 hasn't // changed. - assert(DenseMapInfo::getEmptyKey() == static_cast(-1) && - "DenseMapInfo's empty key isn't -1!"); - assert(DenseMapInfo::getTombstoneKey() == - static_cast(-2) && - "DenseMapInfo's tombstone key isn't -2!"); + static_assert(DenseMapInfo::getEmptyKey() == + static_cast(-1)); + static_assert(DenseMapInfo::getTombstoneKey() == + static_cast(-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::getEmptyKey() == (unsigned)-1 && - "DenseMapInfo's empty key isn't -1!"); - assert(DenseMapInfo::getTombstoneKey() == (unsigned)-2 && - "DenseMapInfo's tombstone key isn't -2!"); + static_assert(DenseMapInfo::getEmptyKey() == + static_cast(-1)); + static_assert(DenseMapInfo::getTombstoneKey() == + static_cast(-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 hasn't // changed. - assert(DenseMapInfo::getEmptyKey() == (unsigned)-1 && - "DenseMapInfo's empty key isn't -1!"); - assert(DenseMapInfo::getTombstoneKey() == (unsigned)-2 && - "DenseMapInfo's tombstone key isn't -2!"); + static_assert(DenseMapInfo::getEmptyKey() == + static_cast(-1)); + static_assert(DenseMapInfo::getTombstoneKey() == + static_cast(-2)); } };