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

Lowering of GlobalOp ignores attributes #1442

Open
AdUhTkJm opened this issue Mar 5, 2025 · 1 comment
Open

Lowering of GlobalOp ignores attributes #1442

AdUhTkJm opened this issue Mar 5, 2025 · 1 comment
Labels
bug Something isn't working

Comments

@AdUhTkJm
Copy link
Contributor

AdUhTkJm commented Mar 5, 2025

Consider the following global variable:

cir.global @x = #cir.const_struct<{
  #cir.int<1> : !s32i,
}> : !ty_anon_struct {section = ".abc"}

On lowering, the {section = ".abc"} attribute is ignored. That is because in LoweringToLLVM.cpp, the function CIRToLLVMGlobalOpLowering::matchAndRewrite can exit prematurely before the variable attributes is used at the end of the function.

I'm not sure how to fix it -- I tried removing those early returns, but it won't work and results in a crash.

@bcardosolopes bcardosolopes added the bug Something isn't working label Mar 5, 2025
@bcardosolopes
Copy link
Member

The amount of if arms here is a bit annoying, ideally it should be broken / refactored into multiple functions to be a bit more clean.

In this example, sounds like you want to also set up the attributes right after createRegionInitializedLLVMGlobalOp but before the return.

In a PR that does that, please add the call to setup the attributes right before all returns of success (so we don't run into this again with other types of constants).

I'm not sure how to fix it -- I tried removing those early returns, but it won't work and results in a crash.

That's expected, the early returns have already setup the LLVM global in some form, doing it twice is probably leading to the crash.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants