https://gcc.gnu.org/bugzilla/show_bug.cgi?id=123171
Bug ID: 123171
Summary: LoongArch: target attribute "arch=XXX" is not properly
scoped
Product: gcc
Version: 16.0
Status: UNCONFIRMED
Keywords: wrong-code
Severity: normal
Priority: P3
Component: target
Assignee: unassigned at gcc dot gnu.org
Reporter: xen0n at gentoo dot org
CC: chenglulu at loongson dot cn, xry111 at gcc dot gnu.org
Target Milestone: ---
Target: loongarch*-*-*
Created attachment 63070
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=63070&action=edit
Reproducer
I'm experimenting with the newly upstreamed LA32 support, and discovered that
the effect of overriding target arch with scoped `#pragma GCC target
"arch=XXX"` or `__attribute__((target("arch=XXX")))` does not get properly
contained.
A draft test case is attached, where the arch attribute is tweaked in two ways,
and codegen is supposed to be different in each group. In fact it seems the
last option wins -- all 4 functions are code-genereated as if arch=la32rv1.0. I
suppose LA64 suffers from the same issue too.