diff options
author | Fangrui Song <i@maskray.me> | 2021-12-15 15:43:35 -0800 |
---|---|---|
committer | Fangrui Song <i@maskray.me> | 2021-12-15 15:43:35 -0800 |
commit | cf9e61a9bb61605e3c78f5d10ae8a3bcb6d8865a (patch) | |
tree | 6b176c01fe1ee36dc43213f3da753e1ab11a5da9 /llvm/lib/Analysis/ModuleSummaryAnalysis.cpp | |
parent | 65146382b379037f560b30ab661e28d6e00be948 (diff) | |
download | llvm-cf9e61a9bb61605e3c78f5d10ae8a3bcb6d8865a.zip llvm-cf9e61a9bb61605e3c78f5d10ae8a3bcb6d8865a.tar.gz llvm-cf9e61a9bb61605e3c78f5d10ae8a3bcb6d8865a.tar.bz2 |
[LTO][WPD] Simplify mustBeUnreachableFunction and test after D115492
An well-formed IR function definition must have an entry basic block and
a well-formed IR basic block must have one terminator so the emptiness
check can be simplified.
Also simplify the test a bit.
Reviewed By: luna
Differential Revision: https://reviews.llvm.org/D115780
Diffstat (limited to 'llvm/lib/Analysis/ModuleSummaryAnalysis.cpp')
-rw-r--r-- | llvm/lib/Analysis/ModuleSummaryAnalysis.cpp | 18 |
1 files changed, 5 insertions, 13 deletions
diff --git a/llvm/lib/Analysis/ModuleSummaryAnalysis.cpp b/llvm/lib/Analysis/ModuleSummaryAnalysis.cpp index 4039a44..2880ca6 100644 --- a/llvm/lib/Analysis/ModuleSummaryAnalysis.cpp +++ b/llvm/lib/Analysis/ModuleSummaryAnalysis.cpp @@ -234,24 +234,16 @@ static bool isNonVolatileStore(const Instruction *I) { return false; } -// Returns true if `F` must be an unreachable function. +// Returns true if the function definition must be unreachable. // // Note if this helper function returns true, `F` is guaranteed // to be unreachable; if it returns false, `F` might still // be unreachable but not covered by this helper function. static bool mustBeUnreachableFunction(const Function &F) { - if (!F.empty()) { - const BasicBlock &entryBlock = F.getEntryBlock(); - // A function must be unreachable if its entry block - // ends with an 'unreachable'. - if (!entryBlock.empty()) { - const Instruction *inst = &(*entryBlock.rbegin()); - if (inst->getOpcode() == Instruction::Unreachable) { - return true; - } - } - } - return false; + // A function must be unreachable if its entry block ends with an + // 'unreachable'. + assert(!F.isDeclaration()); + return isa<UnreachableInst>(F.getEntryBlock().getTerminator()); } static void computeFunctionSummary( |