This is an archive of the discontinued LLVM Phabricator instance.

Adapt the ObjC checker instrumentation to handle objc_msgSend with struct returns
ClosedPublic

Authored by jingham on Feb 26 2019, 2:34 PM.

Details

Summary

The objc_object_checker instrumentation inserts a call to the checker function before each call to any of the family of objc_msgSend calls. The checker function gets passed the object, and the selector from the msgSend. These arguments are in different places in the original call instruction depending on whether the method used the struct return convention or not. Traditionally, objc_msgSend was used for scalar returns and objc_msgSent_stret for struct return conventions. But on arm64, both scalar and struct return calls use objc_msgSend, so for struct return methods we were passing the checker the wrong object pointer and the expression was crashing in the checker.

However, the llvm::Instruction generated by the JIT knows whether it was used with struct return convention or not, so add a check for that to the code that inserts the checker.

Diff Detail

Repository
rLLDB LLDB

Event Timeline

jingham created this revision.Feb 26 2019, 2:34 PM
clayborg added inline comments.Feb 26 2019, 2:50 PM
source/Expression/IRDynamicChecks.cpp
437

move up above for all architectures?

438–439

remove these two lines after moving eMsgSend_stret up with eMsgSend and eMsgSend_fpret cases?

I chose not to do it that way because I don't think it will ever be the case the msgSend_stret will NOT be a struct return convention so the test isn't relevant (and is a bit confusing) there. And we may at some point need to do some other work that depends on the flavor of msgSend, so I wanted to keep the distinction.

If all we are ever going to care about is the return convention, then we should remove the msgSend_types classification and just encode the return type and have the Inspect pass over the Super sends. But that would obscure the fact that this code is all about instrumenting some of the objc_msgSend flavors, and make it harder to read IMO.

clayborg accepted this revision.Feb 27 2019, 11:37 AM

Sounds good.

This revision is now accepted and ready to land.Feb 27 2019, 11:37 AM
This revision was automatically updated to reflect the committed changes.