llvm / llvm/llvm-project

LLVM uses incorrect datalayout on m68k-unknown-netbsd

Open
#199,826 7 comments 0 reactions 0 assignees View on GitHub
backend:m68k
Dominant language
LLVM
Stars
40.5k
Forks
18.7k
PR merge metrics
PR metrics pending

Description

The [computeM68kDataLayout()](https://github.com/llvm/llvm-project/blob/0d5b7522dc729f04c27d8c9d536321d57b3b3196/llvm/lib/TargetParser/TargetDataLayout.cpp#L125) function in LLVM defaults to a common `datalayout` string for both Linux and NetBSD on M68k.

The currently returned `datalayout` string for all M68k targets is:

```
glaubitz@suse-laptop:~> clang --target=m68k -x c /dev/null -emit-llvm -S -o -|grep datalayout
target datalayout = "E-m:e-p:32:16:32-i8:8:8-i16:16:16-i32:16:32-n8:16:32-a:0:16-S16"
glaubitz@suse-laptop:~>
```

However, since NetBSD (target triple: `netbsd-unknown-netbsd`) uses a minimum alignment of 32 bits for both pointers and integers, the proper `datalayout` string should reflect that.

Thus, the proper string for `m68k-unknown-netbsd` would be:

`E-m:e-p:32:32-i32:32-n8:16:32-a:0:32-S32`

Thus, the function `computeM68kDataLayout()` needs to be adopted to use the proper `datalayout` for `m68k-unknown-netbsd`.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.