The IRBuilder will currently automatically put the strictfp attribute on a function definition if strictfp mode is enabled and a function call is emitted. It turns out that this is incorrect since the IRBuilder is currently being used to add instructions to BasicBlocks that do _not_ have a Function. A segv is the result.
The new rule is that the front end must be the one to set the attribute on a function definition. Period. No attempt is made to be clever about trying to handle this in the IRBuilder automatically since it cannot be done with 100% reliably as far as I know.
This ticket is needed to unblock D62731.
This seemed odd if we're making the assumption that in general the BasicBlock IRBuilder is working with doesn't need to have a parent. So, I looked through the IRBuilder code a bit to see if we're assuming a parent exists anywhere else. We are. It happens all over the place. For example, IRBuilder::CreateAlloca() calls BB->getParent()->getParent() to get the Module.
While it might be reasonable to expect users to know that they can't set FP function attributes unless the IRBuilder is working with a BasicBlock that is already in a Function, it's more of a stretch to think that a user would know that about creating an AllocaInst. (The reason is that we need the DataLayout.) The same thing happens with any methods that create intrinsic calls.
I think that we should probably explicitly document that the IRBuilder must have a full chain from BasicBlock to Parent to Module.
That said, the changes in this patch seem reasonable.