diff options
author | Matt Arsenault <Matthew.Arsenault@amd.com> | 2021-05-10 20:56:24 -0400 |
---|---|---|
committer | Matt Arsenault <Matthew.Arsenault@amd.com> | 2021-05-11 09:07:32 -0400 |
commit | bce3cca4889a9e4ab7b9652b0c44bb49ca8f3bad (patch) | |
tree | a59b8f8198c1ee7799ed50acd84841e4f6e467f2 /llvm/lib/CodeGen/MachineBlockFrequencyInfo.cpp | |
parent | c02476f3158f2908ef0a6f628210b5380bd33695 (diff) | |
download | llvm-bce3cca4889a9e4ab7b9652b0c44bb49ca8f3bad.zip llvm-bce3cca4889a9e4ab7b9652b0c44bb49ca8f3bad.tar.gz llvm-bce3cca4889a9e4ab7b9652b0c44bb49ca8f3bad.tar.bz2 |
CodeGen: Fix null dereference before null check
Diffstat (limited to 'llvm/lib/CodeGen/MachineBlockFrequencyInfo.cpp')
-rw-r--r-- | llvm/lib/CodeGen/MachineBlockFrequencyInfo.cpp | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/llvm/lib/CodeGen/MachineBlockFrequencyInfo.cpp b/llvm/lib/CodeGen/MachineBlockFrequencyInfo.cpp index 0368583..c569f03 100644 --- a/llvm/lib/CodeGen/MachineBlockFrequencyInfo.cpp +++ b/llvm/lib/CodeGen/MachineBlockFrequencyInfo.cpp @@ -233,14 +233,20 @@ MachineBlockFrequencyInfo::getBlockFreq(const MachineBasicBlock *MBB) const { Optional<uint64_t> MachineBlockFrequencyInfo::getBlockProfileCount( const MachineBasicBlock *MBB) const { + if (!MBFI) + return None; + const Function &F = MBFI->getFunction()->getFunction(); - return MBFI ? MBFI->getBlockProfileCount(F, MBB) : None; + return MBFI->getBlockProfileCount(F, MBB); } Optional<uint64_t> MachineBlockFrequencyInfo::getProfileCountFromFreq(uint64_t Freq) const { + if (!MBFI) + return None; + const Function &F = MBFI->getFunction()->getFunction(); - return MBFI ? MBFI->getProfileCountFromFreq(F, Freq) : None; + return MBFI->getProfileCountFromFreq(F, Freq); } bool MachineBlockFrequencyInfo::isIrrLoopHeader( |