[PATCH][arm] Fix assembler option rewrite alphabetical comparison

Kyrill Tkachov kyrylo.tkachov@foss.arm.com
Thu Dec 21 14:46:00 GMT 2017


Hi all,

While doing some experimentation with options
in arm-cpus.in I hit an assembler error where
the alphabetical sorting in arm_rewrite_selected_arch
  would not sort the string "+simd+fp16" properly
into "+fp16+simd" like gas expects.

The way the comparator function compare_opt_names
is written it can never return false as the for-loop starts
from 0 and doesn't have an exit condition and its only
exit point is a "return true;".

I think it also hits undefined behaviour if the second string
is shorter than the first.

In any case, what we need is a strcmp to perform a normal
alphabetical comparison, which is what this patch does.

With this we canonicalise "+simd+fp16" to "+fp16+simd" as expected.

Bootstrapped and tested on arm-none-linux-gnueabihf.
Committed to trunk.

Thanks,
Kyrill

2017-12-21  Kyrylo Tkachov  <kyrylo.tkachov@arm.com>

     * common/config/arm/arm-common.c (compare_opt_names): Add function
     comment.  Use strcmp instead of manual loop.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: arm-alpha.patch
Type: text/x-patch
Size: 866 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20171221/c4b30e8d/attachment.bin>


More information about the Gcc-patches mailing list