"op symbol declaration cannot have public visibility" when using "new" keyword
Nobody has claimed this yet.
- Dominant language
- C++
- Stars
- 624
- Forks
- 170
- PR merge metrics
- No merged PRs in 30d
Description
I am using this commit: https://github.com/llvm/Polygeist/commit/a27def31a2b0742308e7c8db4c0f40a37727269a to transform C++ code to MLIR. I run into issues when using the `new` keyword with `--memref-abi=0`.
With this simple C++ code (**test.cpp**):
```
int main()
{
int* arr = new int[5];
return arr[0];
}
```
I am executing the command `cgeist test.cpp --resource-dir="$(clang++ -print-resource-dir)" --function=* -S --memref-abi=0`. It results in the following output:
full output
```
error: 'func.func' op symbol declaration cannot have public visibility
"builtin.module"() ({
"func.func"() ({
}) {function_type = (i64) -> memref, sym_name = "malloc"} : () -> ()
"func.func"() ({
%0 = "arith.constant"() {value = 20 : index} : () -> index
%1 = "func.call"(%0) {callee = @malloc} : (index) -> memref
%2 = "llvm.bitcast"(%1) : (memref) -> !llvm.ptr
%3 = "llvm.load"(%2) : (!llvm.ptr) -> i32
"func.return"(%3) : (i32) -> ()
}) {function_type = () -> i32, llvm.linkage = #llvm.linkage, sym_name = "main"} : () -> ()
}) {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry<"dlti.endianness", "little">, #dlti.dl_entry : vector<2xi32>>, #dlti.dl_entry : vector<2xi32>>, #dlti.dl_entry : vector<2xi32>>, #dlti.dl_entry : vector<2xi32>>, #dlti.dl_entry : vector<2xi32>>, #dlti.dl_entry : vector<2xi32>>, #dlti.dl_entry : vector<2xi32>>, #dlti.dl_entry : vector<2xi32>>, #dlti.dl_entry : vector<2xi32>>>, llvm.data_layout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128", llvm.target_triple = "x86_64-unknown-linux-gnu", "polygeist.target-cpu" = "broadwell", "polygeist.target-features" = "+64bit,+adx,+aes,+avx,+avx2,+bmi,+bmi2,+cmov,+crc32,+cx16,+cx8,+f16c,+fma,+fsgsbase,+fxsr,+invpcid,+lzcnt,+mmx,+movbe,+pclmul,+popcnt,+prfchw,+rdrnd,+rdseed,+rtm,+sahf,+sse,+sse2,+sse3,+sse4.1,+sse4.2,+ssse3,+x87,+xsave,+xsaveopt,-amx-bf16,-amx-fp16,-amx-int8,-amx-tile,-avx512bf16,-avx512bitalg,-avx512bw,-avx512cd,-avx512dq,-avx512er,-avx512f,-avx512fp16,-avx512ifma,-avx512pf,-avx512vbmi,-avx512vbmi2,-avx512vl,-avx512vnni,-avx512vp2intersect,-avx512vpopcntdq,-avxvnni,-cldemote,-clflushopt,-clwb,-clzero,-enqcmd,-fma4,-gfni,-hreset,-kl,-lwp,-movdir64b,-movdiri,-mwaitx,-pconfig,-pku,-prefetchi,-prefetchwt1,-ptwrite,-rdpid,-rdpru,-serialize,-sgx,-sha,-shstk,-sse4a,-tbm,-tsxldtrk,-uintr,-vaes,-vpclmulqdq,-waitpkg,-wbnoinvd,-widekl,-xop,-xsavec,-xsaves"} : () -> ()
```
There is an error about the declaration of the `malloc` function. It seems that the issue is that it is missing the external linkage.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the diagnostic with test.cpp and the documented cgeist command using --memref-abi=0. Inspect where the generated malloc func.func declaration is created and verify that the declaration has external linkage; done means the example no longer reports the public-visibility error.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100