Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ClangIR emits functions in the opposite order as OG sometimes #1017

Open
smeenai opened this issue Oct 29, 2024 · 0 comments
Open

ClangIR emits functions in the opposite order as OG sometimes #1017

smeenai opened this issue Oct 29, 2024 · 0 comments
Labels
IR difference A difference in ClangIR-generated LLVM IR that could complicate reusing original CodeGen tests

Comments

@smeenai
Copy link
Collaborator

smeenai commented Oct 29, 2024

https://godbolt.org/z/zxqshqdcv shows an example. This seems to be intentional on CIR's part, per:

// Some global emissions are triggered while emitting a function, e.g.
// void s() { x.method() }
//
// Be sure to insert a new function before a current one.
auto *curCGF = getCurrCIRGenFun();
if (curCGF)
builder.setInsertionPoint(curCGF->CurFn);

On the other hand, LLVM always adds a new function to the end of the module's function list:

ParentModule->getFunctionList().push_back(this);

It's not a huge deal, but it'll make sharing tests with OG more complicated, and I'm wondering if we can match OG instead.

@smeenai smeenai added the IR difference A difference in ClangIR-generated LLVM IR that could complicate reusing original CodeGen tests label Oct 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
IR difference A difference in ClangIR-generated LLVM IR that could complicate reusing original CodeGen tests
Projects
None yet
Development

No branches or pull requests

1 participant