[ObjC] type method metadata `_imp`, messenger routine at callsite with program addres...
authorMatt Jacobson <mhjacobson@me.com>
Mon, 1 Aug 2022 05:59:41 +0000 (01:59 -0400)
committerMatt Jacobson <mhjacobson@me.com>
Thu, 4 Aug 2022 09:40:32 +0000 (05:40 -0400)
commitc8b2f3f51bd923afbf9d3ebd0823bce895629630
tree1caeaa6bdce387c0b9661d45be604d055bed17f9
parent56d94b3b902e21ff79b1ce9a6fb606a3f7c1c4db
[ObjC] type method metadata `_imp`, messenger routine at callsite with program address space

On targets with non-default program address space (e.g., Harvard
architectures), clang crashes when emitting Objective-C method metadata,
because the address of the method IMP cannot be bitcast to i8*. It similarly
crashes at messenger callsite with a failed bitcast.

Define the _imp field instead as i8 addrspace(1)* (or whatever the target's
program address space is). And in getMessageSendInfo(), create signatureType by
specifying the program address space.

Add a regression test using the AVR target. Test failed previously and passes
now. Checked codegen of the test for x86_64-apple-darwin19.6.0 and saw no
difference, as expected.

Reviewed By: rjmccall, dylanmckay

Differential Revision: https://reviews.llvm.org/D112113
clang/lib/CodeGen/CGObjCMac.cpp
clang/lib/CodeGen/CGObjCRuntime.cpp
clang/test/CodeGen/avr/objc-method.m [new file with mode: 0644]