numba/numba — pull request #874 by gmarkall (2014-11-26 13:02:45+00:00)
Title: Restructure the generation of Record destructors to fix issue #870

Branching to a switch table that dominates all the BBs that clean up in the event of an error unboxing arguments can sometimes fail the LLVM Verifier checks. This is because the verifier sees that not all of the cleanup blocks are dominated by all of the blocks that initialise what they are cleaning up (though in practice control flow cannot reach uninitialised values, but this cannot be seen purely considering the CFG).

This PR restructures the cleanup to avoid using a switch table, and instead to branch directly from arguments which have failed unboxing into their cleanup block. Each cleanup block then branches directly to the cleanup block for the preceding argument. This cleans up arguments in the reverse order of the parameter list and then exits the function.

Tests that trigger the bug are added (using a record type for any argument other than the first argument would trigger it). There are a couple of additional tests for passing multiple records and multiple record types into functions that are also added in the hope of avoiding regressions when passing multiple record types.