http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60906
Bug ID: 60906
Summary: target attribute causes other attributes to be ignored
Product: gcc
Version: 4.8.3
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: target
Assignee: unassigned at gcc dot gnu.org
Reporter: harald at gigawatt dot nl
When the target attribute is used to select a function based on CPU, other
attributes get ignored. This can lead to missed optimisations and/or wrong
code, depending on the specific attribute.
Missed optimisation:
void foo() __attribute__((target("default"), noreturn));
void foo() __attribute__((target("arch=corei7"), noreturn));
void bar() { foo(); foo(); }
The second call to foo, and the following return, could be optimised away (and
are if the target attribute is not used).
Wrong code:
#include <assert.h>
int __attribute__((target("default"), regparm(3))) f(int x) { return x; }
int __attribute__((target("arch=corei7"), regparm(3))) f(int x) { return x; }
int main() {
assert(f(3) == 3);
}
The assertion fails (on x86-32). Tested with 4.8.2.