https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104879
Bug ID: 104879 Summary: [nvptx] Use .common directive (available starting ptx isa version 5.0) Product: gcc Version: 12.0 Status: UNCONFIRMED Severity: enhancement Priority: P3 Component: target Assignee: unassigned at gcc dot gnu.org Reporter: vries at gcc dot gnu.org Target Milestone: --- We currently have in the nvptx port in nvptx_option_override: ... /* Set flag_no_common, unless explicitly disabled. We fake common using .weak, and that's not entirely accurate, so avoid it unless forced. */ if (!OPTION_SET_P (flag_no_common)) flag_no_common = 1; ... and in nvptx_output_aligned_decl: ... /* If this is public, it is common. The nearest thing we have to common is weak. */ fprintf (file, "\t%s", TREE_PUBLIC (decl) ? ".weak " : ""); ... [ There's also some optimisation note related to .common: ... /* Buffer needed to broadcast across workers and vectors. This is used for both worker-neutering and worker broadcasting, and vector-neutering and boardcasting when vector_length > 32. It is shared by all functions emitted. The buffer is placed in shared memory. It'd be nice if PTX supported common blocks, because then this could be shared across TUs (taking the largest size). */ ... but I'm not sure whether this is safe, perhaps this would require a mutex to make it safe. ] Starting with ptx isa 5.0, we have the .common directive available in ptx. However, it "can be used only on variables with .global storage", so it's somewhat limited.