[PATCH] D13354: Assign correct edge weights to unwind destinations when lowering invoke statement.
Reid Kleckner via llvm-commits
llvm-commits at lists.llvm.org
Mon Oct 12 13:17:55 PDT 2015
rnk added a comment.
This seems like the right approach. My first thought was to add logic similar to findUnwindDestinations in BPI::getEdgeWeight, but after thinking more I like this is better.
================
Comment at: lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp:1203
@@ +1202,3 @@
+ BranchProbabilityInfo *BPI = FuncInfo.BPI;
+ // A lambda that updates the weight of the edge to the new EHPadBB.
+ auto GetUnwindDest = [BPI, &Weight](const BasicBlock *EHPadBB,
----------------
This is just code that runs on every iteration of the while loop. We don't need a lambda, just put it before the end of the loop. You'll have to create a `NewEHPadBB` local variable and assign it to EHPadBB, but that seems OK to me.
================
Comment at: test/CodeGen/X86/catchpad-weight.ll:1
@@ +1,2 @@
+; RUN: llc -march=x86-64 -print-machineinstrs=expand-isel-pseudos %s -o /dev/null 2>&1 | FileCheck %s
+
----------------
I think the IR for this C++ code would make a better test case:
struct A {};
struct B {};
struct C {};
struct HasDtor {
~HasDtor();
};
void may_throw();
int main() {
HasDtor o;
try {
may_throw();
} catch (A) {
} catch (B) {
} catch (C) {
}
}
Then the invoke for `may_throw` has five total successors: the normal edge, the three catchpads, and the cleanup.
You can get the catchpad IR like this:
$ clang -c --target=x86_64-windows-msvc t.cpp -S -emit-llvm -o - -fexceptions -O2
http://reviews.llvm.org/D13354
More information about the llvm-commits
mailing list