llvm / llvm/Polygeist

[Bug] Inconsistent Datalayout in frontend.

Open
#280 3 comments 0 reactions 1 assignee View on GitHub

@ivanradanov is already working on this.

Since Nov 8, 2022.

Dominant language
C++
Stars
624
Forks
170
PR merge metrics
No merged PRs in 30d

Description

**Background**: I was cross-compiling(64bit arch-> 32bit arch) polybench using polygeist while meeting an error. After debugging, I found the datalayout information is lost in frontend.

I add the compiled options: _--target=arm-linux-gnueabi -mcpu=cortex-m55_ for **mlir-clang**, during your _parseMLIR_ function, we can get te correct datalayout like below. (BTW, I have applied your patch to enable cross compilation :) )
![image](https://user-images.githubusercontent.com/46161336/197143269-d09276c9-5c6a-411a-9d8a-a3b61fa5e72f.png)
However, we lost the information while codegen for struct **File** in **fprintf** (This is the error reporting point, I am not sure where exactly lose the DL information).
![image](https://user-images.githubusercontent.com/46161336/197147362-e213b73d-ccc7-46a5-8189-5c4261c594ce.png)

And in order to compared with clang tools, I also cross compiled the same case using clang and got the correct datalayout which leads to no compilation error
![image](https://user-images.githubusercontent.com/46161336/197145642-bc15f761-fbae-4b36-a5ec-205205afe34b.png)

**The whole compiling commands are**
**1. For mlir-clang**
```
/project/td/xdsa/user/zzy01/mlir-clang-debug/build/bin/mlir-clang --target=arm-linux-gnueabi -mcp /project/td/xdsa/user/zzy01/polygeist/scripts/polybench-c-4.2.1-beta/utilities -I /project/td/xdsa/user/zzy01/polygeist/../mlir-clang/llvm/../clang/lib/Headers -D POLYBENCH_TIME -D POLYBENCH_NO_FLUSH_CACHE -D EXTRALARGE_DATASET -D DATA_TYPE_IS_FLOAT -emit-llvm correlation.c -o correlation_m55.mlir-clang.ll
```
and the error snapshot:
![image](https://user-images.githubusercontent.com/46161336/197146042-ecf9fd7a-284e-4c45-b7e8-cec6685a62c0.png)

**2. For clang**
```
/project/td/xdsa/user/zzy01/polygeist/../mlir-clang-debug/build/bin/clang --target=arm-linux-gnueabi -mcpu=ex-m55 -I /project/td/xdsa/user/zzy01/polygeist/scripts/polybench-c-4.2.1-beta/utilities -I /project/td/xdsa/user/zzy01/polygeist/../mlir-clang/llvm/../clang/lib/Headers -D POLYBENCH_TIME -D POLYBENCH_NO_FLUSH_CACHE -D EXTRALARGE_DATASET -D DATA_TYPE_IS_FLOAT -O1 -S -emit-llvm -Xclang -disable-llvm-passes correlation.c -o correlation.clangsing.ll
```

Hope to hear from you soon. :)

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.