https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102914
Bug ID: 102914 Summary: spurious warnings are emitted on ARM about non-delegitimized UNSPEC UNSPEC_TLS Product: gcc Version: 12.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: target Assignee: unassigned at gcc dot gnu.org Reporter: ardb at kernel dot org Target Milestone: --- Target: ARM The Linux/ARM kernel uses __builtin_thread_pointer() to access the TPIDRURO TLS register, which triggers warning such as this one when using GCC 12.0.0. The warning does not appear with 11.2 /home/ard/linux/init/calibrate.c: In function ‘calibrate_delay’: /home/ard/linux/init/calibrate.c:275:6: note: non-delegitimized UNSPEC UNSPEC_TLS (17) found in variable location 275 | void calibrate_delay(void) | ^~~~~~~~~~~~~~~ This appears to be triggered by the presence of notes in the RTL such as the one below: (note 1826 74 76 2 (var_location this_cpu (mem:SI (plus:SI (unspec:SI [ (const_int 0 [0]) ] UNSPEC_TLS) (const_int 8 [0x8])) [5 MEM[(struct thread_info *)cur_24].cpu+0 S4 A64])) NOTE_INSN_VAR_LOCATION) which are generated from dereferences of the (struct thread_info *) pointer which is initialized from __builtin_thread_pointer(). (insn 50 2215 2217 2 (set (reg/v/f:SI 3 r3 [orig:124 cur ] [124]) (unspec:SI [ (const_int 0 [0]) ] UNSPEC_TLS)) "/home/ard/linux/arch/arm/include/asm/current.h":36:8 401 {load_tp_hard} (expr_list:REG_EQUIV (unspec:SI [ (const_int 0 [0]) ] UNSPEC_TLS) (nil))) (insn 54 2226 1499 2 (set (reg/v:SI 2 r2 [orig:125 this_cpu ] [125]) (mem:SI (plus:SI (reg/v/f:SI 3 r3 [orig:124 cur ] [124]) (const_int 8 [0x8])) [5 MEM[(struct thread_info *)cur_24].cpu+0 S4 A64])) "/home/ard/linux/init/calibrate.c":279:6 990 {*thumb2_movsi_insn} (expr_list:REG_DEAD (reg/v/f:SI 3 r3 [orig:124 cur ] [124]) (nil)))