[PATCH] D61717: Fix arm_neon.h to be clean under -fno-lax-vector-conversions.

Richard Smith - zygoloid via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed May 8 23:17:32 PDT 2019


rsmith created this revision.
rsmith added reviewers: t.p.northover, javed.absar, SjoerdMeijer, pbarrio.
Herald added a subscriber: kristof.beyls.
Herald added a project: clang.

arm_neon.h produces a large number of errors under -fno-lax-vector-conversions,
which disables some deeply dangerous implicit conversions and which we really
need to make the default (PR17164).

This patch fixes the immediate problem by removing a bunch of incorrect casts
generated in the header. But it's only the first part of the problem: the other
part is fixing the incorrect expectations in the corresponding CodeGen test
files (in particular, in two ~20K line test files). However, I don't want to
touch that until I'm confident this change is correct.


Repository:
  rC Clang

https://reviews.llvm.org/D61717

Files:
  test/Headers/arm-neon-header.c
  test/Sema/aarch64-neon-fp16-ranges.c
  utils/TableGen/NeonEmitter.cpp


Index: utils/TableGen/NeonEmitter.cpp
===================================================================
--- utils/TableGen/NeonEmitter.cpp
+++ utils/TableGen/NeonEmitter.cpp
@@ -1430,7 +1430,7 @@
     }
 
     // Check if an explicit cast is needed.
-    if (CastToType.isVector()) {
+    if (CastToType.isVector() && (LocalCK == ClassB || CastToType.isChar())) {
       CastToType.makeInteger(8, true);
       Arg = "(" + CastToType.str() + ")" + Arg;
     }
Index: test/Sema/aarch64-neon-fp16-ranges.c
===================================================================
--- test/Sema/aarch64-neon-fp16-ranges.c
+++ test/Sema/aarch64-neon-fp16-ranges.c
@@ -1,5 +1,5 @@
-// RUN: %clang_cc1 -triple arm64-linux-gnu -fallow-half-arguments-and-returns -target-feature +neon -target-feature +fullfp16 -ffreestanding -fsyntax-only -verify %s
-// RUN: %clang_cc1 -triple aarch64-linux-gnu -fallow-half-arguments-and-returns -target-feature +fullfp16 -target-feature +neon -ffreestanding -fsyntax-only -verify %s    
+// RUN: %clang_cc1 -triple arm64-linux-gnu -fallow-half-arguments-and-returns -target-feature +neon -target-feature +fullfp16 -ffreestanding -fsyntax-only -verify %s -fno-lax-vector-conversions
+// RUN: %clang_cc1 -triple aarch64-linux-gnu -fallow-half-arguments-and-returns -target-feature +fullfp16 -target-feature +neon -ffreestanding -fsyntax-only -verify %s     -fno-lax-vector-conversions
 
 #include <arm_neon.h>
 #include <arm_fp16.h>
Index: test/Headers/arm-neon-header.c
===================================================================
--- test/Headers/arm-neon-header.c
+++ test/Headers/arm-neon-header.c
@@ -2,6 +2,9 @@
 // RUN: %clang_cc1 -triple thumbv7-apple-darwin10 -target-cpu cortex-a8 -fsyntax-only -fno-lax-vector-conversions -ffreestanding %s
 // RUN: %clang_cc1 -x c++ -triple thumbv7-apple-darwin10 -target-cpu cortex-a8 -fsyntax-only -Wvector-conversions -ffreestanding %s
 
+// RUN: %clang_cc1 -triple arm64-linux-gnu -fallow-half-arguments-and-returns -target-feature +neon -target-feature +fullfp16 -ffreestanding -fsyntax-only %s -fno-lax-vector-conversions
+// RUN: %clang_cc1 -triple aarch64-linux-gnu -fallow-half-arguments-and-returns -target-feature +fullfp16 -target-feature +neon -ffreestanding -fsyntax-only %s -fno-lax-vector-conversions
+
 // RUN: %clang -fsyntax-only               -ffreestanding --target=aarch64-none-eabi -march=armv8.2-a+fp16 -std=c89 -xc %s
 // RUN: %clang -fsyntax-only -Wall -Werror -ffreestanding --target=aarch64-none-eabi -march=armv8.2-a+fp16 -std=c99 -xc %s
 // RUN: %clang -fsyntax-only -Wall -Werror -ffreestanding --target=aarch64-none-eabi -march=armv8.2-a+fp16 -std=c11 -xc %s


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D61717.198761.patch
Type: text/x-patch
Size: 2666 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20190509/f45ec2f7/attachment.bin>


More information about the cfe-commits mailing list