This is an archive of the discontinued LLVM Phabricator instance.

[AMDGPU] Corrected directive to use for ELF weak refs
ClosedPublic

Authored by dp on Sep 16 2020, 7:38 AM.

Details

Summary

WeakRefDirective should specify a directive to declare "a global as being a weak undefined symbol".

The directive used by AMDGPU is incorrect - ".weakref" is intended for other purposes.
The correct directive is ".weak" and it is already defined as default for ELF.

This issue was found when compiling a HIP program using -O0 -save-temps. The following declaration

%struct.__hip_builtin_blockIdx_t = type { i8 }
@blockIdx = extern_weak dso_local protected addrspace(1) global %struct.__hip_builtin_blockIdx_t, align 1

resulted in code which cannot be assembled:

.protected	blockIdx
.weakref	blockIdx

Diff Detail

Event Timeline

dp created this revision.Sep 16 2020, 7:38 AM
Herald added a project: Restricted Project. · View Herald TranscriptSep 16 2020, 7:38 AM
dp requested review of this revision.Sep 16 2020, 7:38 AM
dp updated this revision to Diff 292225.Sep 16 2020, 8:27 AM

Added a test

arsenm accepted this revision.Sep 16 2020, 8:27 AM
This revision is now accepted and ready to land.Sep 16 2020, 8:27 AM
This revision was automatically updated to reflect the committed changes.