diff --git a/llvm/include/llvm/CodeGen/MachineBasicBlock.h b/llvm/include/llvm/CodeGen/MachineBasicBlock.h index 51660e4ded13eae7c7c99eaeff14e3f1bfc150c3..b8789cd5afd49b8995c10b40173dd57db5de266b 100644 --- a/llvm/include/llvm/CodeGen/MachineBasicBlock.h +++ b/llvm/include/llvm/CodeGen/MachineBasicBlock.h @@ -667,12 +667,19 @@ public: std::optional getBBID() const { return BBID; } - uint64_t getHash() const { return BBID->Hash; } + uint64_t getHash() const { + if (BBID) + return BBID->Hash; + return 0; + } /// Returns the section ID of this basic block. MBBSectionID getSectionID() const { return SectionID; } - void setHash(uint64_t Hash) { BBID->Hash = Hash; } + void setHash(uint64_t Hash) { + if (BBID) + BBID->Hash = Hash; + } /// Sets the fixed BBID of this basic block. void setBBID(const UniqueBBID &V) {