Skip to content

Globals: LLVM lowering missing constant attribute #801

Closed
@bcardosolopes

Description

@bcardosolopes

There is a small difference between LLVM-IR code generated by ClangIR and vanilla LLVM.

ClangIR generates (... -fclangir -emit-llvm ...):

@_ZN6compat1bE = weak_odr global i32 2
@compat_use_before_redecl = global ptr @_ZN6compat1bE
@_ZN6compat1aE = weak_odr global i32 1
@_ZN6compat1cE = weak_odr global i32 3
@_ZN6compat1eE = global i32 5
@_ZN6compat1fE = weak_odr global i32 6
@compat_use_after_redecl1 = global ptr @_ZN6compat1cE
@_ZN6compat1dE = linkonce_odr global i32 4
@compat_use_after_redecl2 = global ptr @_ZN6compat1dE
@_ZN6compat1gE = linkonce_odr global i32 7
@compat_use_after_redecl3 = global ptr @_ZN6compat1gE

Vanila LLVM (.. -emit-llvm ...):

@_ZN6compat1bE = weak_odr constant i32 2, comdat, align 4
@compat_use_before_redecl = constant ptr @_ZN6compat1bE, align 8
@_ZN6compat1aE = weak_odr constant i32 1, comdat, align 4
@_ZN6compat1cE = weak_odr constant i32 3, comdat, align 4
@_ZN6compat1eE = constant i32 5, align 4
@_ZN6compat1fE = weak_odr constant i32 6, comdat, align 4
@compat_use_after_redecl1 = constant ptr @_ZN6compat1cE, align 8
@_ZN6compat1dE = linkonce_odr constant i32 4, comdat, align 4
@compat_use_after_redecl2 = constant ptr @_ZN6compat1dE, align 8
@_ZN6compat1gE = linkonce_odr constant i32 7, comdat, align 4
@compat_use_after_redecl3 = constant ptr @_ZN6compat1gE, align 8

I.e. some align and constant were added by the vanilla LLVM. @bcardosolopes, is it OK?

Originally posted by @ivanmurashko in #794 (comment)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions