llvm / llvm/Polygeist

Empty llvm.func with linkonce_odr linkage.

Open
#265 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

When running the following test:

```
// RUN: cgeist %s --function=* -llvm-struct=1 -memref-abi=0 -S | FileCheck %s

struct stream {
stream& operator<<(stream& (*__pf)(stream&)) { return __pf(*this); }
};

inline stream& endl(stream& stream)
{
return stream;
}

int main() {
stream str;
str << endl;
return 0;
}
```
I get the error message:

```error: 'llvm.func' op external functions must have 'external' or 'extern_weak' linkage```

The error message makes sense since there is an empty _Z4endlR6stream function that has linkonce_odr linkage.

On the Mac the example triggers also a slightly different error when I remove the inline keyword. In that case mlirs verifier complains bcs there is a redefinition of the function _Z4endlR6stream (once as llvm.func and once as func.func). However, it seems like this is not reproducible on Linux machines.

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.

Research direction

Start by running the provided cgeist command and FileCheck test with the inline stream::endl reproducer. Inspect the generated llvm.func for _Z4endlR6stream and compare the Linux and Mac behavior; done means the verifier accepts the linkage and no duplicate llvm.func/func.func definition remains.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
compilers
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.