What do we expect from the following IR?
@i2 = constant i32 30, section “INITDATA”, align 4
@i1 = global i32 0, section “INITDATA”, align 4
Currently, we stick them in one section that isn’t writable which is problematic because @i1 is writable. If you flip @i1 and @i2 you get one section which is writable.
It seems like we should do one of the following:
- Two sections, one writable + one that isn’t
- One section that is writable
- Give an error
Personally, I like #1 or #2.
Seems like #2 won’t work for this case:
@l = thread_local global i32 0, section “bar”, align 4
@k = global i32 0, section “bar”, align 4
Why not #3? It the frontend wants a constant section it can print @i1
differently. It if wants a writable section it can print @i2
I’ve come around and believe #3 is the right answer. Better yet, we should give a way to specify the section attributes somewhere explicitly and only infer them as a fallback.
Cool. I have reported llvm.org/pr17554 to track this.