[PATCH] D84715: [FIX] Add check for empty body function
Wei Wang via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Jul 30 17:23:10 PDT 2020
weiwang updated this revision to Diff 282085.
weiwang added a comment.
Herald added a subscriber: steven_wu.
add test case
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D84715/new/
https://reviews.llvm.org/D84715
Files:
llvm/include/llvm/Analysis/LoopInfoImpl.h
llvm/include/llvm/Support/GenericDomTreeConstruction.h
llvm/lib/Analysis/BlockFrequencyInfo.cpp
llvm/lib/Analysis/BranchProbabilityInfo.cpp
llvm/test/LTO/Resolution/X86/dead-strip-fulllto.ll
Index: llvm/test/LTO/Resolution/X86/dead-strip-fulllto.ll
===================================================================
--- llvm/test/LTO/Resolution/X86/dead-strip-fulllto.ll
+++ llvm/test/LTO/Resolution/X86/dead-strip-fulllto.ll
@@ -1,7 +1,7 @@
; RUN: opt -module-summary -o %t %s
; RUN: opt -module-summary -o %t2 %S/Inputs/dead-strip-fulllto.ll
-; RUN: llvm-lto2 run --pass-remarks-output=%t4.yaml --pass-remarks-filter=. \
+; RUN: llvm-lto2 run --pass-remarks-output=%t4.yaml --pass-remarks-filter=. --pass-remarks-with-hotness \
; RUN: %t -r %t,main,px -r %t,live1, -r %t,live2,p -r %t,dead2,p \
; RUN: %t2 -r %t2,live1,p -r %t2,live2, -r %t2,dead1,p -r %t2,dead2, -r %t2,odr, \
; RUN: -save-temps -o %t3
Index: llvm/lib/Analysis/BranchProbabilityInfo.cpp
===================================================================
--- llvm/lib/Analysis/BranchProbabilityInfo.cpp
+++ llvm/lib/Analysis/BranchProbabilityInfo.cpp
@@ -1134,6 +1134,9 @@
PostDominatorTree *PDT) {
LLVM_DEBUG(dbgs() << "---- Branch Probability Info : " << F.getName()
<< " ----\n\n");
+ if (F.empty())
+ return;
+
LastF = &F; // Store the last function we ran on for printing.
assert(PostDominatedByUnreachable.empty());
assert(PostDominatedByColdCall.empty());
Index: llvm/lib/Analysis/BlockFrequencyInfo.cpp
===================================================================
--- llvm/lib/Analysis/BlockFrequencyInfo.cpp
+++ llvm/lib/Analysis/BlockFrequencyInfo.cpp
@@ -184,6 +184,9 @@
void BlockFrequencyInfo::calculate(const Function &F,
const BranchProbabilityInfo &BPI,
const LoopInfo &LI) {
+ if (F.empty())
+ return;
+
if (!BFI)
BFI.reset(new ImplType);
BFI->calculate(F, BPI, LI);
Index: llvm/include/llvm/Support/GenericDomTreeConstruction.h
===================================================================
--- llvm/include/llvm/Support/GenericDomTreeConstruction.h
+++ llvm/include/llvm/Support/GenericDomTreeConstruction.h
@@ -42,6 +42,8 @@
#include "llvm/ADT/DepthFirstIterator.h"
#include "llvm/ADT/PointerIntPair.h"
#include "llvm/ADT/SmallPtrSet.h"
+#include "llvm/IR/Function.h"
+#include "llvm/Support/Casting.h"
#include "llvm/Support/Debug.h"
#include "llvm/Support/GenericDomTree.h"
#include <queue>
@@ -524,6 +526,16 @@
auto *Parent = DT.Parent;
DT.reset();
DT.Parent = Parent;
+
+ if constexpr (std::is_same<
+ Function *,
+ typename std::remove_const<
+ typename DomTreeT::ParentPtr>::type>::value) {
+ if (auto *F = dyn_cast<Function>(DT.Parent))
+ if (F->empty())
+ return;
+ }
+
SemiNCAInfo SNCA(nullptr); // Since we are rebuilding the whole tree,
// there's no point doing it incrementally.
Index: llvm/include/llvm/Analysis/LoopInfoImpl.h
===================================================================
--- llvm/include/llvm/Analysis/LoopInfoImpl.h
+++ llvm/include/llvm/Analysis/LoopInfoImpl.h
@@ -537,6 +537,9 @@
void LoopInfoBase<BlockT, LoopT>::analyze(const DomTreeBase<BlockT> &DomTree) {
// Postorder traversal of the dominator tree.
const DomTreeNodeBase<BlockT> *DomRoot = DomTree.getRootNode();
+ if (!DomRoot)
+ return;
+
for (auto DomNode : post_order(DomRoot)) {
BlockT *Header = DomNode->getBlock();
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D84715.282085.patch
Type: text/x-patch
Size: 3522 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200731/86540f9c/attachment.bin>
More information about the llvm-commits
mailing list