Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

Don't apply the aligned attribute nedlessly

Aperta
#714 1 commento 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
5/5
Tempo stimato
Più di una settimana
Idoneità per principianti
35/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Ferma
Stack tecnologico
rust
Ambito
compilers

Direzione di ricerca

Inizia tracciando Builder::load e la chiamata a get_aligned, quindi analizza come rustc espone l'allineamento garantito per i tipi interi, a virgola mobile, vettoriali e compositi. Il lavoro è completato quando il backend emette l'allineamento solo quando differisce dall'allineamento garantito del tipo, evitando di emetterlo anche per i tipi di dimensione pari a un byte e per le strutture naturalmente allineate.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

enhancement

Currently, we apply the aligned attribute to all integers, regardless of their actual aligement.

This leads to such gems as this:

__int8_t  __attribute__((aligned(1)))

Since a byte-sized type has a size of 1(by definition), it's alignment can be 1 and only 1.

This attribute is thus unneeded, and only leads to increased memory consumption, and more confusing debug strings. It could also inhibit some optimizations(no examples of that yet, but it is not hard to imagine some of them can't deal with under / over aligned types, and ignore types with explicit alignment altogether).

While removing this attribute for byte-sized types is an easy fix, other types pose a bigger challenge.

Ideally, we'd need an API to query GCC about the aligement of intigers / floats / vectors, and then use that API to not emit this attribute when not necessary(eg. a structure composed of floats with aligement 4 is alteady correctly aligned by the virtue of containing floats).

For example, Builder::load could check if the requested align: Align differs from the one already guaranteed for a type(by checking the aligement on the rustc side of things). We could then call get_aligned if and only if this aligement differs, reducing the usage of this attribute(thus reducing memory usage).

Lingua principale
Rust
Stelle
1.2k
Fork
106
Merge medio
6h 30m
PR unite (30g)
22

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di rust-lang/rustc_codegen_gcc

Tutte le issue di rust-lang/rustc_codegen_gcc

Issue simili

Altre issue su Rust

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.