[clang] ObjcRuntime.h: Add mips64, aarch64, and riscv64 to non-legacy dispatch (PR #76694)
Hugo Melder via cfe-commits
cfe-commits at lists.llvm.org
Tue Jan 2 11:37:33 PST 2024
hmelder wrote:
It seems like isLegacyDispatchDefaultForArch is only called by the driver, and not when passing `-cc1`.
https://github.com/llvm/llvm-project/blob/11ac97c67a9315dce48fd938d68ae991e3559f10/clang/lib/Driver/ToolChains/Clang.cpp#L3935-L3953
Using the driver instead of the frontend does not work as there are platform checks in `Clang::AddObjCRuntimeArgs`.
Example on macOS:
```sh
clang: error: GNUstep Objective-C runtime version 2 incompatible with target binary format
```
The result is that without specifying `-fobjc-dispatch-method=mixed` or `-fobjc-dispatch-method=no-legacy`, the frontend will always emit `call ptr @objc_msg_lookup_sender`.
Do you have an idea on how we can test this instead?
Tested with
```sh
#flags="-fobjc-dispatch-method=mixed"
flags=""
rt=gnustep-2.0
triple="x86_64-unknown-freebsd"
build-llvm/bin/clang -cc1\
-triple ${triple} \
-fobjc-runtime=${rt} ${flags} \
-emit-llvm -o - gnustep2-message-dispatch.m | less
```
<details>
<summary>gnustep2-message-dispatch.m</summary>
```objc
// DEFINE: %{triple} =
// DEFINE: %{ver} =
// DEFINE: %{prefix} = CHECK-MSG-SEND
// DEFINE: %{check} = %clang_cc1 -triple %{triple} -fobjc-runtime=gnustep-%{ver} -emit-llvm -o - %s | FileCheck %s -check-prefix %{prefix}
// REDEFINE: %{ver} = 1.6
// REDEFINE: %{triple} = x86_64-unknown-freebsd
// RUN: %{check}
// REDEFINE: %{triple} = arm-unknown-freebsd
// RUN: %{check}
// REDEFINE: %{prefix} = CHECK-MSG-LOOKUP
// REDEFINE: %{triple} = aarch64-unknown-freebsd
// RUN: %{check}
// REDEFINE: %{triple} = mips64-unknown-freebsd
// RUN: %{check}
// REDEFINE: %{triple} = riscv64-unknown-freebsd
// RUN: %{check}
// REDEFINE: %{ver} = 1.9
// REDEFINE: %{prefix} = CHECK-MSG-SEND
// REDEFINE: %{triple} = x86_64-unknown-freebsd
// RUN: %{check}
// REDEFINE: %{triple} = arm-unknown-freebsd
// RUN: %{check}
// REDEFINE: %{triple} = aarch64-unknown-freebsd
// RUN: %{check}
// REDEFINE: %{triple} = mips64-unknown-freebsd
// RUN: %{check}
// REDEFINE: %{prefix} = CHECK-MSG-LOOKUP
// REDEFINE: %{triple} = riscv64-unknown-freebsd
// RUN: %{check}
// REDEFINE: %{ver} = 2.2
// REDEFINE: %{prefix} = CHECK-MSG-SEND
// REDEFINE: %{triple} = x86_64-unknown-freebsd
// RUN: %{check}
// REDEFINE: %{triple} = arm-unknown-freebsd
// RUN: %{check}
// REDEFINE: %{triple} = aarch64-unknown-freebsd
// RUN: %{check}
// REDEFINE: %{triple} = mips64-unknown-freebsd
// RUN: %{check}
// REDEFINE: %{triple} = riscv64-unknown-freebsd
// RUN: %{check}
typedef struct {
int x;
int y;
int z[10];
} MyPoint;
void f0(id a) {
int i;
MyPoint pt = { 1, 2};
// CHECK-MSG-SEND: call {{.*}} @objc_msgSend
// CHECK-MSG-LOOKUP: call {{.*}} @objc_msg_lookup(
[a print0];
// CHECK-MSG-SEND: call {{.*}} @objc_msgSend
// CHECK-MSG-LOOKUP: call {{.*}} @objc_msg_lookup(
[a print1: 10];
// CHECK-MSG-SEND: call {{.*}} @objc_msgSend
// CHECK-MSG-LOOKUP: call {{.*}} @objc_msg_lookup(
[a print2: 10 and: "hello" and: 2.2];
// CHECK-MSG-SEND: call {{.*}} @objc_msgSend
// CHECK-MSG-LOOKUP: call {{.*}} @objc_msg_lookup(
[a takeStruct: pt ];
}
```
</details>
https://github.com/llvm/llvm-project/pull/76694
More information about the cfe-commits
mailing list