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

Pass explicit alignment to globals #626

Open
bcardosolopes opened this issue May 24, 2024 · 0 comments
Open

Pass explicit alignment to globals #626

bcardosolopes opened this issue May 24, 2024 · 0 comments
Labels
good first issue Good for newcomers

Comments

@bcardosolopes
Copy link
Member

ClangIR and Vanilla LLVM have the following diff in the generated IR:

 // LLVM-LABEL: @literals
-// LLVM:  global %struct.anon {
+// LLVM:  global %struct.anon.1 {
 // LLVM:    [10 x i8] c"1\00\00\00\00\00\00\00\00\00",
 // LLVM:    [10 x i8] zeroinitializer,
 // LLVM:    [10 x i8] zeroinitializer
-// LLVM:  }, align 1
+// LLVM:  }

From langref:

An explicit alignment may be specified for a global, which must be a power of 2. If not present, or if the alignment is set to zero, the alignment of the global is set by the target to whatever it feels convenient. If an explicit alignment is specified, the global is forced to have exactly that alignment.

We should make it explicit to avoid alignment issues in the future.

Originally posted by @ivanmurashko in #617 (comment)

@bcardosolopes bcardosolopes added the good first issue Good for newcomers label May 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

1 participant