llvm-project icon indicating copy to clipboard operation
llvm-project copied to clipboard

[clang][CodeGen] Assertion failure for dynamically-initialized const variable with addrspace

Open brunodf-gf opened this issue 2 years ago • 1 comments

An assertion failure in clang prevents to use a const global variable in a (non-default) address space with a dynamic initialization, for example:

int f();
extern const int __attribute__((address_space(10))) test3 = f();

Godbolt demo

The issue is related to the emission of an llvm.invariant.start intrinsic in the dynamic initialization of const variables.

(Issue diagnosed with help from @kortbeek-snps.)

brunodf-gf avatar Jun 04 '24 12:06 brunodf-gf

@llvm/issue-subscribers-clang-codegen

Author: Bruno De Fraine (brunodf-snps)

An assertion failure in clang prevents to use a `const` global variable in a (non-default) address space with a dynamic initialization, for example:
int f();
extern const int __attribute__((address_space(10))) test3 = f();

Godbolt demo

The issue is related to the emission of an llvm.invariant.start intrinsic in the dynamic initialization of const variables.

(Issue diagnosed with help from @kortbeek-snps.)

llvmbot avatar Jun 04 '24 13:06 llvmbot