From e3eb7efd29b2bf7a91e7dbbded0e4a841cdb25c1 Mon Sep 17 00:00:00 2001 From: Matt Arsenault Date: Fri, 14 Jun 2019 13:42:40 +0000 Subject: [PATCH] RegBankSelect: Remove checks for invalid mappings Avoid a check for valid and a set of redundant asserts. The place InstructionMapping is constructed asserts all of the default fields are passed anyway for an invalid mapping, so don't overcomplicate this. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@363391 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/CodeGen/GlobalISel/RegisterBankInfo.h | 6 +----- lib/CodeGen/GlobalISel/RegisterBankInfo.cpp | 7 ++----- 2 files changed, 3 insertions(+), 10 deletions(-) diff --git a/include/llvm/CodeGen/GlobalISel/RegisterBankInfo.h b/include/llvm/CodeGen/GlobalISel/RegisterBankInfo.h index 37a63d1bae0..f6a58abf64c 100644 --- a/include/llvm/CodeGen/GlobalISel/RegisterBankInfo.h +++ b/include/llvm/CodeGen/GlobalISel/RegisterBankInfo.h @@ -193,7 +193,7 @@ public: unsigned Cost = 0; /// Mapping of all the operands. - const ValueMapping *OperandsMapping; + const ValueMapping *OperandsMapping = nullptr; /// Number of operands. unsigned NumOperands = 0; @@ -210,15 +210,11 @@ public: /// The rationale is that it is more efficient for the optimizers /// to be able to assume that the mapping of the ith operand is /// at the index i. - /// - /// \pre ID != InvalidMappingID InstructionMapping(unsigned ID, unsigned Cost, const ValueMapping *OperandsMapping, unsigned NumOperands) : ID(ID), Cost(Cost), OperandsMapping(OperandsMapping), NumOperands(NumOperands) { - assert(getID() != InvalidMappingID && - "Use the default constructor for invalid mapping"); } /// Default constructor. diff --git a/lib/CodeGen/GlobalISel/RegisterBankInfo.cpp b/lib/CodeGen/GlobalISel/RegisterBankInfo.cpp index 55f10a2d065..9542c1fe1fc 100644 --- a/lib/CodeGen/GlobalISel/RegisterBankInfo.cpp +++ b/lib/CodeGen/GlobalISel/RegisterBankInfo.cpp @@ -374,11 +374,8 @@ RegisterBankInfo::getInstructionMappingImpl( ++NumInstructionMappingsCreated; auto &InstrMapping = MapOfInstructionMappings[Hash]; - if (IsInvalid) - InstrMapping = llvm::make_unique(); - else - InstrMapping = llvm::make_unique( - ID, Cost, OperandsMapping, NumOperands); + InstrMapping = llvm::make_unique( + ID, Cost, OperandsMapping, NumOperands); return *InstrMapping; } -- 2.40.0