[PATCH] D77465: [WebAssembly] Fix a sanitizer error in WasmEHPrepare
Heejin Ahn via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Sat Apr 4 10:04:37 PDT 2020
aheejin created this revision.
aheejin added a reviewer: dschuff.
Herald added subscribers: llvm-commits, sunfish, hiraditya, jgravelle-google, sbc100.
Herald added a project: LLVM.
aheejin added a comment.
Will land this now, because it's a weekend and the previous patch is breaking the buildbots.
D77423 <https://reviews.llvm.org/D77423> started using a dominator tree in WasmEHPrepare, but we deleted
BBs in `prepareThrows` before we used the domtree in `prepareEHPads`,
and those CFG changes were not reflected in the domtree. This uses
`DomTreeUpdater` to make sure we update the domtree every time we delete
BBs from the CFG. This fixes ubsan/msan/expensive_check errors caught in
LLVM buildbots.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D77465
Files:
llvm/lib/CodeGen/WasmEHPrepare.cpp
Index: llvm/lib/CodeGen/WasmEHPrepare.cpp
===================================================================
--- llvm/lib/CodeGen/WasmEHPrepare.cpp
+++ llvm/lib/CodeGen/WasmEHPrepare.cpp
@@ -81,6 +81,7 @@
#include "llvm/ADT/SetVector.h"
#include "llvm/ADT/Statistic.h"
#include "llvm/ADT/Triple.h"
+#include "llvm/Analysis/DomTreeUpdater.h"
#include "llvm/CodeGen/Passes.h"
#include "llvm/CodeGen/TargetLowering.h"
#include "llvm/CodeGen/TargetSubtargetInfo.h"
@@ -164,14 +165,14 @@
// Erase the specified BBs if the BB does not have any remaining predecessors,
// and also all its dead children.
template <typename Container>
-static void eraseDeadBBsAndChildren(const Container &BBs) {
+static void eraseDeadBBsAndChildren(const Container &BBs, DomTreeUpdater *DTU) {
SmallVector<BasicBlock *, 8> WL(BBs.begin(), BBs.end());
while (!WL.empty()) {
auto *BB = WL.pop_back_val();
if (pred_begin(BB) != pred_end(BB))
continue;
WL.append(succ_begin(BB), succ_end(BB));
- DeleteDeadBlock(BB);
+ DeleteDeadBlock(BB, DTU);
}
}
@@ -184,6 +185,9 @@
}
bool WasmEHPrepare::prepareThrows(Function &F) {
+ auto &DT = getAnalysis<DominatorTreeWrapperPass>().getDomTree();
+ DomTreeUpdater DTU(&DT, /*PostDominatorTree*/ nullptr,
+ DomTreeUpdater::UpdateStrategy::Eager);
Module &M = *F.getParent();
IRBuilder<> IRB(F.getContext());
bool Changed = false;
@@ -206,7 +210,7 @@
InstList.erase(std::next(BasicBlock::iterator(ThrowI)), InstList.end());
IRB.SetInsertPoint(BB);
IRB.CreateUnreachable();
- eraseDeadBBsAndChildren(Succs);
+ eraseDeadBBsAndChildren(Succs, &DTU);
}
return Changed;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D77465.255053.patch
Type: text/x-patch
Size: 1689 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200404/d50a79b7/attachment.bin>
More information about the llvm-commits
mailing list