This patch addresses 2 problems:
- In ShuffleBlockStrategy, when BB is an EHPad, BB.getFirstInsertionPt() will return BB.end(), which cannot be dereferenced and will cause crash in following loop.
- In isCompatibleReplacement, a call instruction's callee might be replaced by a pointer, causing 2 subproblems:
- we cannot guarantee that the pointer is a function pointer (even if it is, we cannot guarantee it matches the signature).
- after such a replacement, getCalledFunction will from then on return nullptr (since it's indirect call) which causes Segmentation Fault in the lines below.
This patch fixes the first problem by checking if a block to be mutated is an EHPad in base class IRMutationStrategy and skipping mutating it if so.
This patch fixes the second problem by avoiding replacing callee with pointer and adding a null check for indirect calls.