aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Target/WebAssembly/WebAssemblyCFGStackify.cpp
diff options
context:
space:
mode:
authorHeejin Ahn <aheejin@gmail.com>2019-10-07 22:19:40 +0000
committerHeejin Ahn <aheejin@gmail.com>2019-10-07 22:19:40 +0000
commitdaeead4b02f062bf5a21e154ab7726b3e1dd41bd (patch)
treefa89bbf3b84bce2db36c8554d613a3f676470338 /llvm/lib/Target/WebAssembly/WebAssemblyCFGStackify.cpp
parentae5bad7277f497a8b19e331dffc14c74e3db7587 (diff)
downloadllvm-daeead4b02f062bf5a21e154ab7726b3e1dd41bd.zip
llvm-daeead4b02f062bf5a21e154ab7726b3e1dd41bd.tar.gz
llvm-daeead4b02f062bf5a21e154ab7726b3e1dd41bd.tar.bz2
[WebAssembly] Fix unwind mismatch stat computation
Summary: There was a bug when computing the number of unwind destination mismatches in CFGStackify. When there are many mismatched calls that share the same (original) destination BB, they have to be counted separately. This also fixes a typo and runs `fixUnwindMismatches` only when the wasm exception handling is enabled. This is to prevent unnecessary computations and does not change behavior. Reviewers: dschuff Subscribers: sbc100, jgravelle-google, hiraditya, sunfish, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D68552 llvm-svn: 373975
Diffstat (limited to 'llvm/lib/Target/WebAssembly/WebAssemblyCFGStackify.cpp')
-rw-r--r--llvm/lib/Target/WebAssembly/WebAssemblyCFGStackify.cpp8
1 files changed, 5 insertions, 3 deletions
diff --git a/llvm/lib/Target/WebAssembly/WebAssemblyCFGStackify.cpp b/llvm/lib/Target/WebAssembly/WebAssemblyCFGStackify.cpp
index 6b20946..d2a3557 100644
--- a/llvm/lib/Target/WebAssembly/WebAssemblyCFGStackify.cpp
+++ b/llvm/lib/Target/WebAssembly/WebAssemblyCFGStackify.cpp
@@ -848,7 +848,7 @@ bool WebAssemblyCFGStackify::fixUnwindMismatches(MachineFunction &MF) {
SmallVector<const MachineBasicBlock *, 8> EHPadStack;
// Range of intructions to be wrapped in a new nested try/catch
using TryRange = std::pair<MachineInstr *, MachineInstr *>;
- // In original CFG, <unwind destionation BB, a vector of try ranges>
+ // In original CFG, <unwind destination BB, a vector of try ranges>
DenseMap<MachineBasicBlock *, SmallVector<TryRange, 4>> UnwindDestToTryRanges;
// In new CFG, <destination to branch to, a vector of try ranges>
DenseMap<MachineBasicBlock *, SmallVector<TryRange, 4>> BrDestToTryRanges;
@@ -985,7 +985,7 @@ bool WebAssemblyCFGStackify::fixUnwindMismatches(MachineFunction &MF) {
// ...
// cont:
for (auto &P : UnwindDestToTryRanges) {
- NumUnwindMismatches++;
+ NumUnwindMismatches += P.second.size();
// This means the destination is the appendix BB, which was separately
// handled above.
@@ -1300,7 +1300,9 @@ void WebAssemblyCFGStackify::placeMarkers(MachineFunction &MF) {
}
}
// Fix mismatches in unwind destinations induced by linearizing the code.
- fixUnwindMismatches(MF);
+ if (MCAI->getExceptionHandlingType() == ExceptionHandling::Wasm &&
+ MF.getFunction().hasPersonalityFn())
+ fixUnwindMismatches(MF);
}
void WebAssemblyCFGStackify::rewriteDepthImmediates(MachineFunction &MF) {