Incorrect code generation when using -fprofile-generate on code which contains exception handling (Windows target)

I think this is the same underlying issue as CCing Reid, who's had a bunch of thoughts on this in the past.

Thanks for the link. I agree, looks like it's another instance of the same class of problems. Since the compiler still requires funclet operand bundles, it sounds like one of the 3 options below will be required until a longer term project of eliminating them is available. Anybody have a strong preference?


I think the simplest, most complete, short term fix, would be to call llvm::colorEHFunclets, and to have the relevant instrumentation passes apply the appropriate funclet bundle when inserting function calls. It’s not elegant because it means every simple instrumentation pass that inserts regular function calls (ASan, TSan, MSan, instrprof, etc) needs to be funclet-aware. But, it will work, and the code isn’t so bad. is an example of using colorEHFunclets this way (and is a follow-up which demonstrates another usage). If I remember correctly, the analysis needs to be updated if the pass is updating the CFG, which those ARC passes weren’t doing. I’m not sure what that updating looks like, though I’m sure we have an example of it somewhere in-tree … Reid might know off the top of his head.

Thanks. I’ll take a look at the examples and give it a try for creating a patch.