[PATCH] D34103: Allow use of fixed width integer types in builtin definitions

2017-06-12 Thread Edward Jones via Phabricator via cfe-commits
edward-jones created this revision.

This makes it possible to specify a bit width after the 'i' integer type 
specifier when defining builtins. The bswap and bitreverse builtins have been 
updated so that their definitions use fixed-width types instead of short, int 
and long, so that they work on targets where int != 32-bits and long != 64 bits.


https://reviews.llvm.org/D34103

Files:
  include/clang/Basic/Builtins.def
  lib/AST/ASTContext.cpp
  test/CodeGen/builtins.c

Index: test/CodeGen/builtins.c
===
--- test/CodeGen/builtins.c
+++ test/CodeGen/builtins.c
@@ -111,8 +111,9 @@
   P(object_size, (s0, 2));
   P(object_size, (s0, 3));
 
-  // Whatever
-
+  // CHECK: @llvm.bswap.i16
+  // CHECK: @llvm.bswap.i32
+  // CHECK: @llvm.bswap.i64
   P(bswap16, (N));
   P(bswap32, (N));
   P(bswap64, (N));
@@ -603,4 +604,4 @@
   __builtin_os_log_format(buf, "%s %% %s", data1, data2);
 }
 
-#endif
\ No newline at end of file
+#endif
Index: lib/AST/ASTContext.cpp
===
--- lib/AST/ASTContext.cpp
+++ lib/AST/ASTContext.cpp
@@ -8585,16 +8585,26 @@
 else
   Type = Context.ShortTy;
 break;
-  case 'i':
-if (HowLong == 3)
-  Type = Unsigned ? Context.UnsignedInt128Ty : Context.Int128Ty;
-else if (HowLong == 2)
-  Type = Unsigned ? Context.UnsignedLongLongTy : Context.LongLongTy;
-else if (HowLong == 1)
-  Type = Unsigned ? Context.UnsignedLongTy : Context.LongTy;
-else
-  Type = Unsigned ? Context.UnsignedIntTy : Context.IntTy;
+  case 'i': {
+char *End;
+unsigned BitWidth = strtoul(Str, &End, 10);
+if (End != Str) {
+  // Optional fixed width modifier
+  Str = End;
+  assert(HowLong == 0 && "Bad modifiers used with fixed-width integer");
+  Type = Context.getIntTypeForBitwidth(BitWidth, !Unsigned);
+} else {
+  if (HowLong == 3)
+Type = Unsigned ? Context.UnsignedInt128Ty : Context.Int128Ty;
+  else if (HowLong == 2)
+Type = Unsigned ? Context.UnsignedLongLongTy : Context.LongLongTy;
+  else if (HowLong == 1)
+Type = Unsigned ? Context.UnsignedLongTy : Context.LongTy;
+  else
+Type = Unsigned ? Context.UnsignedIntTy : Context.IntTy;
+}
 break;
+  }
   case 'c':
 assert(HowLong == 0 && "Bad modifiers used with 'c'!");
 if (Signed)
Index: include/clang/Basic/Builtins.def
===
--- include/clang/Basic/Builtins.def
+++ include/clang/Basic/Builtins.def
@@ -24,7 +24,7 @@
 //  b -> boolean
 //  c -> char
 //  s -> short
-//  i -> int
+//  i -> int, optionally followed by the bit width of the integer type
 //  h -> half
 //  f -> float
 //  d -> double
@@ -47,7 +47,9 @@
 //  p -> pid_t
 //  . -> "...".  This may only occur at the end of the function list.
 //
-// Types may be prefixed with the following modifiers:
+// Types may be prefixed with a number of modifiers. Modifiers which affect
+// the width of the integer type cannot be used if the integer is specified
+// as a fixed-width type.
 //  L   -> long (e.g. Li for 'long int')
 //  LL  -> long long
 //  LLL -> __int128_t (e.g. LLLi)
@@ -406,16 +408,14 @@
 BUILTIN(__builtin_popcountl , "iULi" , "nc")
 BUILTIN(__builtin_popcountll, "iULLi", "nc")
 
-// FIXME: These type signatures are not correct for targets with int != 32-bits
-// or with ULL != 64-bits.
-BUILTIN(__builtin_bswap16, "UsUs", "nc")
-BUILTIN(__builtin_bswap32, "UiUi", "nc")
-BUILTIN(__builtin_bswap64, "ULLiULLi", "nc")
+BUILTIN(__builtin_bswap16, "Ui16Ui16", "nc")
+BUILTIN(__builtin_bswap32, "Ui32Ui32", "nc")
+BUILTIN(__builtin_bswap64, "Ui64Ui64", "nc")
 
-BUILTIN(__builtin_bitreverse8, "UcUc", "nc")
-BUILTIN(__builtin_bitreverse16, "UsUs", "nc")
-BUILTIN(__builtin_bitreverse32, "UiUi", "nc")
-BUILTIN(__builtin_bitreverse64, "ULLiULLi", "nc")
+BUILTIN(__builtin_bitreverse8,  "Ui8Ui8", "nc")
+BUILTIN(__builtin_bitreverse16, "Ui16Ui16", "nc")
+BUILTIN(__builtin_bitreverse32, "Ui32Ui32", "nc")
+BUILTIN(__builtin_bitreverse64, "Ui64Ui64", "nc")
 
 // Random GCC builtins
 BUILTIN(__builtin_constant_p, "i.", "nctu")
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D53392: [RISCV] Collect library directories and triples for riscv64 triple too

2018-10-18 Thread Edward Jones via Phabricator via cfe-commits
edward-jones created this revision.
edward-jones added a reviewer: asb.
Herald added subscribers: cfe-commits, jocewei, PkmX, rkruppe, the_o, 
brucehoult, MartinMosbeck, rogfer01, mgrang, zzheng, jrtc27, shiva0217, 
kito-cheng, niosHD, sabuasal, apazos, simoncook, johnrusso, rbar, arichardson, 
emaste.
Herald added a reviewer: espindola.

When setting up library and tools paths when detecting an accompanying GCC 
installation only riscv32 was handled. As a consequence when targetting riscv64 
neither the linker nor libraries would be found. This adds handling and tests 
for riscv64.


Repository:
  rC Clang

https://reviews.llvm.org/D53392

Files:
  lib/Driver/ToolChains/Gnu.cpp
  test/Driver/Inputs/basic_riscv64_tree/bin/riscv64-unknown-elf-ld
  
test/Driver/Inputs/basic_riscv64_tree/lib/gcc/riscv64-unknown-elf/8.0.1/crtbegin.o
  
test/Driver/Inputs/basic_riscv64_tree/lib/gcc/riscv64-unknown-elf/8.0.1/crtend.o
  
test/Driver/Inputs/basic_riscv64_tree/riscv64-unknown-elf/include/c++/8.0.1/.keep
  test/Driver/Inputs/basic_riscv64_tree/riscv64-unknown-elf/lib/crt0.o
  test/Driver/riscv64-toolchain.c

Index: test/Driver/riscv64-toolchain.c
===
--- test/Driver/riscv64-toolchain.c
+++ test/Driver/riscv64-toolchain.c
@@ -3,6 +3,102 @@
 // RUN: %clang %s -### -no-canonical-prefixes -target riscv64 2>&1 | FileCheck -check-prefix=CC1 %s
 // CC1: clang{{.*}} "-cc1" "-triple" "riscv64"
 
+// RUN: %clang %s -### -no-canonical-prefixes \
+// RUN:   -target riscv64-unknown-elf \
+// RUN:   --gcc-toolchain=%S/Inputs/basic_riscv64_tree \
+// RUN:   --sysroot=%S/Inputs/basic_riscv64_tree/riscv64-unknown-elf 2>&1 \
+// RUN:   | FileCheck -check-prefix=C-RV64-BAREMETAL-LP64 %s
+
+// C-RV64-BAREMETAL-LP64: "-fuse-init-array"
+// C-RV64-BAREMETAL-LP64: "{{.*}}Inputs/basic_riscv64_tree/lib/gcc/riscv64-unknown-elf/8.0.1/../../../../bin{{/|}}riscv64-unknown-elf-ld"
+// C-RV64-BAREMETAL-LP64: "--sysroot={{.*}}/Inputs/basic_riscv64_tree/riscv64-unknown-elf"
+// C-RV64-BAREMETAL-LP64: "{{.*}}/Inputs/basic_riscv64_tree/riscv64-unknown-elf/lib{{/|}}crt0.o"
+// C-RV64-BAREMETAL-LP64: "{{.*}}/Inputs/basic_riscv64_tree/lib/gcc/riscv64-unknown-elf/8.0.1{{/|}}crtbegin.o"
+// C-RV64-BAREMETAL-LP64: "-L{{.*}}/Inputs/basic_riscv64_tree/riscv64-unknown-elf/lib"
+// C-RV64-BAREMETAL-LP64: "-L{{.*}}/Inputs/basic_riscv64_tree/lib/gcc/riscv64-unknown-elf/8.0.1"
+// C-RV64-BAREMETAL-LP64: "--start-group" "-lc" "-lgloss" "--end-group" "-lgcc"
+// C-RV64-BAREMETAL-LP64: "{{.*}}/Inputs/basic_riscv64_tree/lib/gcc/riscv64-unknown-elf/8.0.1{{/|}}crtend.o"
+
+// RUN: %clang %s -### -no-canonical-prefixes \
+// RUN:   -target riscv64-unknown-elf \
+// RUN:   --sysroot= \
+// RUN:   --gcc-toolchain=%S/Inputs/basic_riscv64_tree 2>&1 \
+// RUN:   | FileCheck -check-prefix=C-RV64-BAREMETAL-NOSYSROOT-LP64 %s
+
+// C-RV64-BAREMETAL-NOSYSROOT-LP64: "-fuse-init-array"
+// C-RV64-BAREMETAL-NOSYSROOT-LP64: "{{.*}}Inputs/basic_riscv64_tree/lib/gcc/riscv64-unknown-elf/8.0.1/../../../../bin{{/|}}riscv64-unknown-elf-ld"
+// C-RV64-BAREMETAL-NOSYSROOT-LP64: "{{.*}}/Inputs/basic_riscv64_tree/lib/gcc/riscv64-unknown-elf/8.0.1/../../../../riscv64-unknown-elf/lib{{/|}}crt0.o"
+// C-RV64-BAREMETAL-NOSYSROOT-LP64: "{{.*}}/Inputs/basic_riscv64_tree/lib/gcc/riscv64-unknown-elf/8.0.1{{/|}}crtbegin.o"
+// C-RV64-BAREMETAL-NOSYSROOT-LP64: "-L{{.*}}/Inputs/basic_riscv64_tree/lib/gcc/riscv64-unknown-elf/8.0.1/../../../../riscv64-unknown-elf{{/|}}lib"
+// C-RV64-BAREMETAL-NOSYSROOT-LP64: "-L{{.*}}/Inputs/basic_riscv64_tree/lib/gcc/riscv64-unknown-elf/8.0.1"
+// C-RV64-BAREMETAL-NOSYSROOT-LP64: "--start-group" "-lc" "-lgloss" "--end-group" "-lgcc"
+// C-RV64-BAREMETAL-NOSYSROOT-LP64: "{{.*}}/Inputs/basic_riscv64_tree/lib/gcc/riscv64-unknown-elf/8.0.1{{/|}}crtend.o"
+
+// RUN: %clangxx %s -### -no-canonical-prefixes \
+// RUN:   -target riscv64-unknown-elf -stdlib=libstdc++ \
+// RUN:   --gcc-toolchain=%S/Inputs/basic_riscv64_tree \
+// RUN:   --sysroot=%S/Inputs/basic_riscv64_tree/riscv64-unknown-elf 2>&1 \
+// RUN:   | FileCheck -check-prefix=CXX-RV64-BAREMETAL-LP64 %s
+
+// CXX-RV64-BAREMETAL-LP64: "-fuse-init-array"
+// CXX-RV64-BAREMETAL-LP64: "-internal-isystem" "{{.*}}Inputs/basic_riscv64_tree/riscv64-unknown-elf/include/c++{{/|}}8.0.1"
+// CXX-RV64-BAREMETAL-LP64: "{{.*}}Inputs/basic_riscv64_tree/lib/gcc/riscv64-unknown-elf/8.0.1/../../../../bin{{/|}}riscv64-unknown-elf-ld"
+// CXX-RV64-BAREMETAL-LP64: "--sysroot={{.*}}/Inputs/basic_riscv64_tree/riscv64-unknown-elf"
+// CXX-RV64-BAREMETAL-LP64: "{{.*}}/Inputs/basic_riscv64_tree/riscv64-unknown-elf/lib{{/|}}crt0.o"
+// CXX-RV64-BAREMETAL-LP64: "{{.*}}/Inputs/basic_riscv64_tree/lib/gcc/riscv64-unknown-elf/8.0.1{{/|}}crtbegin.o"
+// CXX-RV64-BAREMETAL-LP64: "-L{{.*}}/Inputs/basic_riscv64_tree/riscv64-unknown-elf/lib"
+// CXX-RV64-BAREMETAL-LP64: "-L{{.*}}/Inputs/basic_riscv64_tree/lib/gcc/riscv64-unknown-elf/8.0.1"
+/

[PATCH] D53392: [RISCV] Collect library directories and triples for riscv64 triple too

2018-10-22 Thread Edward Jones via Phabricator via cfe-commits
edward-jones updated this revision to Diff 170373.
edward-jones added a comment.

I've incorporated your suggested changes and added riscv32/64-linux-gnu entrys 
to the Triple + LibDirs lists.

Is it worth also updating the riscv32-toolchain.c test in this patch to rename 
riscv32-linux-unknown-elf to riscv32-unknown-linux-gnu? It looks like 
"riscv32-linux-unknown-elf" has been there since the the driver was introduced.


https://reviews.llvm.org/D53392

Files:
  lib/Driver/ToolChains/Gnu.cpp
  test/Driver/Inputs/basic_riscv64_tree/bin/riscv64-unknown-elf-ld
  
test/Driver/Inputs/basic_riscv64_tree/lib/gcc/riscv64-unknown-elf/8.0.1/crtbegin.o
  
test/Driver/Inputs/basic_riscv64_tree/lib/gcc/riscv64-unknown-elf/8.0.1/crtend.o
  
test/Driver/Inputs/basic_riscv64_tree/riscv64-unknown-elf/include/c++/8.0.1/.keep
  test/Driver/Inputs/basic_riscv64_tree/riscv64-unknown-elf/lib/crt0.o
  test/Driver/riscv64-toolchain.c

Index: test/Driver/riscv64-toolchain.c
===
--- test/Driver/riscv64-toolchain.c
+++ test/Driver/riscv64-toolchain.c
@@ -3,6 +3,102 @@
 // RUN: %clang %s -### -no-canonical-prefixes -target riscv64 2>&1 | FileCheck -check-prefix=CC1 %s
 // CC1: clang{{.*}} "-cc1" "-triple" "riscv64"
 
+// RUN: %clang %s -### -no-canonical-prefixes \
+// RUN:   -target riscv64-unknown-elf \
+// RUN:   --gcc-toolchain=%S/Inputs/basic_riscv64_tree \
+// RUN:   --sysroot=%S/Inputs/basic_riscv64_tree/riscv64-unknown-elf 2>&1 \
+// RUN:   | FileCheck -check-prefix=C-RV64-BAREMETAL-LP64 %s
+
+// C-RV64-BAREMETAL-LP64: "-fuse-init-array"
+// C-RV64-BAREMETAL-LP64: "{{.*}}Inputs/basic_riscv64_tree/lib/gcc/riscv64-unknown-elf/8.0.1/../../../../bin{{/|}}riscv64-unknown-elf-ld"
+// C-RV64-BAREMETAL-LP64: "--sysroot={{.*}}/Inputs/basic_riscv64_tree/riscv64-unknown-elf"
+// C-RV64-BAREMETAL-LP64: "{{.*}}/Inputs/basic_riscv64_tree/riscv64-unknown-elf/lib{{/|}}crt0.o"
+// C-RV64-BAREMETAL-LP64: "{{.*}}/Inputs/basic_riscv64_tree/lib/gcc/riscv64-unknown-elf/8.0.1{{/|}}crtbegin.o"
+// C-RV64-BAREMETAL-LP64: "-L{{.*}}/Inputs/basic_riscv64_tree/riscv64-unknown-elf/lib"
+// C-RV64-BAREMETAL-LP64: "-L{{.*}}/Inputs/basic_riscv64_tree/lib/gcc/riscv64-unknown-elf/8.0.1"
+// C-RV64-BAREMETAL-LP64: "--start-group" "-lc" "-lgloss" "--end-group" "-lgcc"
+// C-RV64-BAREMETAL-LP64: "{{.*}}/Inputs/basic_riscv64_tree/lib/gcc/riscv64-unknown-elf/8.0.1{{/|}}crtend.o"
+
+// RUN: %clang %s -### -no-canonical-prefixes \
+// RUN:   -target riscv64-unknown-elf \
+// RUN:   --sysroot= \
+// RUN:   --gcc-toolchain=%S/Inputs/basic_riscv64_tree 2>&1 \
+// RUN:   | FileCheck -check-prefix=C-RV64-BAREMETAL-NOSYSROOT-LP64 %s
+
+// C-RV64-BAREMETAL-NOSYSROOT-LP64: "-fuse-init-array"
+// C-RV64-BAREMETAL-NOSYSROOT-LP64: "{{.*}}Inputs/basic_riscv64_tree/lib/gcc/riscv64-unknown-elf/8.0.1/../../../../bin{{/|}}riscv64-unknown-elf-ld"
+// C-RV64-BAREMETAL-NOSYSROOT-LP64: "{{.*}}/Inputs/basic_riscv64_tree/lib/gcc/riscv64-unknown-elf/8.0.1/../../../../riscv64-unknown-elf/lib{{/|}}crt0.o"
+// C-RV64-BAREMETAL-NOSYSROOT-LP64: "{{.*}}/Inputs/basic_riscv64_tree/lib/gcc/riscv64-unknown-elf/8.0.1{{/|}}crtbegin.o"
+// C-RV64-BAREMETAL-NOSYSROOT-LP64: "-L{{.*}}/Inputs/basic_riscv64_tree/lib/gcc/riscv64-unknown-elf/8.0.1/../../../../riscv64-unknown-elf{{/|}}lib"
+// C-RV64-BAREMETAL-NOSYSROOT-LP64: "-L{{.*}}/Inputs/basic_riscv64_tree/lib/gcc/riscv64-unknown-elf/8.0.1"
+// C-RV64-BAREMETAL-NOSYSROOT-LP64: "--start-group" "-lc" "-lgloss" "--end-group" "-lgcc"
+// C-RV64-BAREMETAL-NOSYSROOT-LP64: "{{.*}}/Inputs/basic_riscv64_tree/lib/gcc/riscv64-unknown-elf/8.0.1{{/|}}crtend.o"
+
+// RUN: %clangxx %s -### -no-canonical-prefixes \
+// RUN:   -target riscv64-unknown-elf -stdlib=libstdc++ \
+// RUN:   --gcc-toolchain=%S/Inputs/basic_riscv64_tree \
+// RUN:   --sysroot=%S/Inputs/basic_riscv64_tree/riscv64-unknown-elf 2>&1 \
+// RUN:   | FileCheck -check-prefix=CXX-RV64-BAREMETAL-LP64 %s
+
+// CXX-RV64-BAREMETAL-LP64: "-fuse-init-array"
+// CXX-RV64-BAREMETAL-LP64: "-internal-isystem" "{{.*}}Inputs/basic_riscv64_tree/riscv64-unknown-elf/include/c++{{/|}}8.0.1"
+// CXX-RV64-BAREMETAL-LP64: "{{.*}}Inputs/basic_riscv64_tree/lib/gcc/riscv64-unknown-elf/8.0.1/../../../../bin{{/|}}riscv64-unknown-elf-ld"
+// CXX-RV64-BAREMETAL-LP64: "--sysroot={{.*}}/Inputs/basic_riscv64_tree/riscv64-unknown-elf"
+// CXX-RV64-BAREMETAL-LP64: "{{.*}}/Inputs/basic_riscv64_tree/riscv64-unknown-elf/lib{{/|}}crt0.o"
+// CXX-RV64-BAREMETAL-LP64: "{{.*}}/Inputs/basic_riscv64_tree/lib/gcc/riscv64-unknown-elf/8.0.1{{/|}}crtbegin.o"
+// CXX-RV64-BAREMETAL-LP64: "-L{{.*}}/Inputs/basic_riscv64_tree/riscv64-unknown-elf/lib"
+// CXX-RV64-BAREMETAL-LP64: "-L{{.*}}/Inputs/basic_riscv64_tree/lib/gcc/riscv64-unknown-elf/8.0.1"
+// CXX-RV64-BAREMETAL-LP64: "-lstdc++" "--start-group" "-lc" "-lgloss" "--end-group" "-lgcc"
+// CXX-RV64-BAREMETAL-LP64: "{{.*}}/Inputs/basic_riscv64_tree/lib/gcc/riscv64-unknown-elf/8.0.1{

[PATCH] D53392: [RISCV] Collect library directories and triples for riscv64 triple too

2018-10-22 Thread Edward Jones via Phabricator via cfe-commits
edward-jones updated this revision to Diff 170374.
edward-jones marked 2 inline comments as done.

https://reviews.llvm.org/D53392

Files:
  lib/Driver/ToolChains/Gnu.cpp
  test/Driver/Inputs/basic_riscv64_tree/bin/riscv64-unknown-elf-ld
  
test/Driver/Inputs/basic_riscv64_tree/lib/gcc/riscv64-unknown-elf/8.0.1/crtbegin.o
  
test/Driver/Inputs/basic_riscv64_tree/lib/gcc/riscv64-unknown-elf/8.0.1/crtend.o
  
test/Driver/Inputs/basic_riscv64_tree/riscv64-unknown-elf/include/c++/8.0.1/.keep
  test/Driver/Inputs/basic_riscv64_tree/riscv64-unknown-elf/lib/crt0.o
  test/Driver/riscv64-toolchain.c

Index: test/Driver/riscv64-toolchain.c
===
--- test/Driver/riscv64-toolchain.c
+++ test/Driver/riscv64-toolchain.c
@@ -3,6 +3,102 @@
 // RUN: %clang %s -### -no-canonical-prefixes -target riscv64 2>&1 | FileCheck -check-prefix=CC1 %s
 // CC1: clang{{.*}} "-cc1" "-triple" "riscv64"
 
+// RUN: %clang %s -### -no-canonical-prefixes \
+// RUN:   -target riscv64-unknown-elf \
+// RUN:   --gcc-toolchain=%S/Inputs/basic_riscv64_tree \
+// RUN:   --sysroot=%S/Inputs/basic_riscv64_tree/riscv64-unknown-elf 2>&1 \
+// RUN:   | FileCheck -check-prefix=C-RV64-BAREMETAL-LP64 %s
+
+// C-RV64-BAREMETAL-LP64: "-fuse-init-array"
+// C-RV64-BAREMETAL-LP64: "{{.*}}Inputs/basic_riscv64_tree/lib/gcc/riscv64-unknown-elf/8.0.1/../../../../bin{{/|}}riscv64-unknown-elf-ld"
+// C-RV64-BAREMETAL-LP64: "--sysroot={{.*}}/Inputs/basic_riscv64_tree/riscv64-unknown-elf"
+// C-RV64-BAREMETAL-LP64: "{{.*}}/Inputs/basic_riscv64_tree/riscv64-unknown-elf/lib{{/|}}crt0.o"
+// C-RV64-BAREMETAL-LP64: "{{.*}}/Inputs/basic_riscv64_tree/lib/gcc/riscv64-unknown-elf/8.0.1{{/|}}crtbegin.o"
+// C-RV64-BAREMETAL-LP64: "-L{{.*}}/Inputs/basic_riscv64_tree/riscv64-unknown-elf/lib"
+// C-RV64-BAREMETAL-LP64: "-L{{.*}}/Inputs/basic_riscv64_tree/lib/gcc/riscv64-unknown-elf/8.0.1"
+// C-RV64-BAREMETAL-LP64: "--start-group" "-lc" "-lgloss" "--end-group" "-lgcc"
+// C-RV64-BAREMETAL-LP64: "{{.*}}/Inputs/basic_riscv64_tree/lib/gcc/riscv64-unknown-elf/8.0.1{{/|}}crtend.o"
+
+// RUN: %clang %s -### -no-canonical-prefixes \
+// RUN:   -target riscv64-unknown-elf \
+// RUN:   --sysroot= \
+// RUN:   --gcc-toolchain=%S/Inputs/basic_riscv64_tree 2>&1 \
+// RUN:   | FileCheck -check-prefix=C-RV64-BAREMETAL-NOSYSROOT-LP64 %s
+
+// C-RV64-BAREMETAL-NOSYSROOT-LP64: "-fuse-init-array"
+// C-RV64-BAREMETAL-NOSYSROOT-LP64: "{{.*}}Inputs/basic_riscv64_tree/lib/gcc/riscv64-unknown-elf/8.0.1/../../../../bin{{/|}}riscv64-unknown-elf-ld"
+// C-RV64-BAREMETAL-NOSYSROOT-LP64: "{{.*}}/Inputs/basic_riscv64_tree/lib/gcc/riscv64-unknown-elf/8.0.1/../../../../riscv64-unknown-elf/lib{{/|}}crt0.o"
+// C-RV64-BAREMETAL-NOSYSROOT-LP64: "{{.*}}/Inputs/basic_riscv64_tree/lib/gcc/riscv64-unknown-elf/8.0.1{{/|}}crtbegin.o"
+// C-RV64-BAREMETAL-NOSYSROOT-LP64: "-L{{.*}}/Inputs/basic_riscv64_tree/lib/gcc/riscv64-unknown-elf/8.0.1/../../../../riscv64-unknown-elf{{/|}}lib"
+// C-RV64-BAREMETAL-NOSYSROOT-LP64: "-L{{.*}}/Inputs/basic_riscv64_tree/lib/gcc/riscv64-unknown-elf/8.0.1"
+// C-RV64-BAREMETAL-NOSYSROOT-LP64: "--start-group" "-lc" "-lgloss" "--end-group" "-lgcc"
+// C-RV64-BAREMETAL-NOSYSROOT-LP64: "{{.*}}/Inputs/basic_riscv64_tree/lib/gcc/riscv64-unknown-elf/8.0.1{{/|}}crtend.o"
+
+// RUN: %clangxx %s -### -no-canonical-prefixes \
+// RUN:   -target riscv64-unknown-elf -stdlib=libstdc++ \
+// RUN:   --gcc-toolchain=%S/Inputs/basic_riscv64_tree \
+// RUN:   --sysroot=%S/Inputs/basic_riscv64_tree/riscv64-unknown-elf 2>&1 \
+// RUN:   | FileCheck -check-prefix=CXX-RV64-BAREMETAL-LP64 %s
+
+// CXX-RV64-BAREMETAL-LP64: "-fuse-init-array"
+// CXX-RV64-BAREMETAL-LP64: "-internal-isystem" "{{.*}}Inputs/basic_riscv64_tree/riscv64-unknown-elf/include/c++{{/|}}8.0.1"
+// CXX-RV64-BAREMETAL-LP64: "{{.*}}Inputs/basic_riscv64_tree/lib/gcc/riscv64-unknown-elf/8.0.1/../../../../bin{{/|}}riscv64-unknown-elf-ld"
+// CXX-RV64-BAREMETAL-LP64: "--sysroot={{.*}}/Inputs/basic_riscv64_tree/riscv64-unknown-elf"
+// CXX-RV64-BAREMETAL-LP64: "{{.*}}/Inputs/basic_riscv64_tree/riscv64-unknown-elf/lib{{/|}}crt0.o"
+// CXX-RV64-BAREMETAL-LP64: "{{.*}}/Inputs/basic_riscv64_tree/lib/gcc/riscv64-unknown-elf/8.0.1{{/|}}crtbegin.o"
+// CXX-RV64-BAREMETAL-LP64: "-L{{.*}}/Inputs/basic_riscv64_tree/riscv64-unknown-elf/lib"
+// CXX-RV64-BAREMETAL-LP64: "-L{{.*}}/Inputs/basic_riscv64_tree/lib/gcc/riscv64-unknown-elf/8.0.1"
+// CXX-RV64-BAREMETAL-LP64: "-lstdc++" "--start-group" "-lc" "-lgloss" "--end-group" "-lgcc"
+// CXX-RV64-BAREMETAL-LP64: "{{.*}}/Inputs/basic_riscv64_tree/lib/gcc/riscv64-unknown-elf/8.0.1{{/|}}crtend.o"
+
+// RUN: %clangxx %s -### -no-canonical-prefixes \
+// RUN:   -target riscv64-unknown-elf -stdlib=libstdc++ \
+// RUN:   --sysroot= \
+// RUN:   --gcc-toolchain=%S/Inputs/basic_riscv64_tree 2>&1 \
+// RUN:   | FileCheck -check-prefix=CXX-RV64-BAREMETAL-NOSYSROOT-LP64 %s
+
+// CXX-RV64-BAREMETAL-NOSYSROOT-L

[PATCH] D58896: Suppress -Wchar-subscripts if the index is a literal char

2019-03-04 Thread Edward Jones via Phabricator via cfe-commits
edward-jones created this revision.
Herald added subscribers: cfe-commits, arphaman.
Herald added a project: clang.

Assume that the user knows what they're doing if they provide a char literal as 
an array index. This more closely matches the behavior of GCC.


Repository:
  rC Clang

https://reviews.llvm.org/D58896

Files:
  lib/Sema/SemaExpr.cpp
  test/SemaCXX/warn-char-subscripts.cpp


Index: test/SemaCXX/warn-char-subscripts.cpp
===
--- test/SemaCXX/warn-char-subscripts.cpp
+++ test/SemaCXX/warn-char-subscripts.cpp
@@ -14,6 +14,19 @@
   int val = subscript[array]; // expected-warning{{array subscript is of type 
'char'}}
 }
 
+void t3() {
+  int array[50] = { 0 };
+  int val = array[' ']; // no warning, subscript is a literal
+}
+void t4() {
+  int array[50] = { 0 };
+  int val = '('[array]; // no warning, subscript is a literal
+}
+void t5() {
+  int array[50] = { 0 };
+  int val = array['\x11']; // no warning, subscript is a literal
+}
+
 void test() {
   t1(); // expected-note {{in instantiation of function template 
specialization 't1' requested here}}
   t2(); // expected-note {{in instantiation of function template 
specialization 't2' requested here}}
Index: lib/Sema/SemaExpr.cpp
===
--- lib/Sema/SemaExpr.cpp
+++ lib/Sema/SemaExpr.cpp
@@ -4718,7 +4718,8 @@
 
   if ((IndexExpr->getType()->isSpecificBuiltinType(BuiltinType::Char_S) ||
IndexExpr->getType()->isSpecificBuiltinType(BuiltinType::Char_U))
- && !IndexExpr->isTypeDependent())
+ && !IndexExpr->isTypeDependent()
+ && !isa(IndexExpr))
 Diag(LLoc, diag::warn_subscript_is_char) << IndexExpr->getSourceRange();
 
   // C99 6.5.2.1p1: "shall have type "pointer to *object* type". Similarly,


Index: test/SemaCXX/warn-char-subscripts.cpp
===
--- test/SemaCXX/warn-char-subscripts.cpp
+++ test/SemaCXX/warn-char-subscripts.cpp
@@ -14,6 +14,19 @@
   int val = subscript[array]; // expected-warning{{array subscript is of type 'char'}}
 }
 
+void t3() {
+  int array[50] = { 0 };
+  int val = array[' ']; // no warning, subscript is a literal
+}
+void t4() {
+  int array[50] = { 0 };
+  int val = '('[array]; // no warning, subscript is a literal
+}
+void t5() {
+  int array[50] = { 0 };
+  int val = array['\x11']; // no warning, subscript is a literal
+}
+
 void test() {
   t1(); // expected-note {{in instantiation of function template specialization 't1' requested here}}
   t2(); // expected-note {{in instantiation of function template specialization 't2' requested here}}
Index: lib/Sema/SemaExpr.cpp
===
--- lib/Sema/SemaExpr.cpp
+++ lib/Sema/SemaExpr.cpp
@@ -4718,7 +4718,8 @@
 
   if ((IndexExpr->getType()->isSpecificBuiltinType(BuiltinType::Char_S) ||
IndexExpr->getType()->isSpecificBuiltinType(BuiltinType::Char_U))
- && !IndexExpr->isTypeDependent())
+ && !IndexExpr->isTypeDependent()
+ && !isa(IndexExpr))
 Diag(LLoc, diag::warn_subscript_is_char) << IndexExpr->getSourceRange();
 
   // C99 6.5.2.1p1: "shall have type "pointer to *object* type". Similarly,
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D58896: Suppress -Wchar-subscripts if the index is a literal char

2019-03-14 Thread Edward Jones via Phabricator via cfe-commits
edward-jones added a comment.

In D58896#1419964 , @aaron.ballman 
wrote:

> Do you have some evidence that the current behavior is causing a lot of false 
> positives in the wild? For ASCII character literals, I can sort of guess at 
> why people might want to do this, but for things like wide character 
> literals, or character literals relying on the current code page, etc, I'm 
> less convinced.


I don't know about the false positive rate,  just the one report on twitter 
which triggered me to submit this change. As for wide character literals I was 
under the impression that they would be promoted to integers and wouldn't have 
triggered the -Wchar-subscript anyway?


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D58896/new/

https://reviews.llvm.org/D58896



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D63417: [WIP][RISCV] Specify registers used for exception handling

2019-06-17 Thread Edward Jones via Phabricator via cfe-commits
edward-jones created this revision.
edward-jones added reviewers: asb, lewis-revill.
Herald added subscribers: cfe-commits, Jim, benna, psnobl, jocewei, PkmX, 
rkruppe, the_o, brucehoult, MartinMosbeck, rogfer01, zzheng, jrtc27, shiva0217, 
kito-cheng, niosHD, sabuasal, apazos, simoncook, johnrusso, rbar.
Herald added a project: clang.

Implements the handling of __builtin_eh_return_regno()

Work in progress as this is missing tests


Repository:
  rC Clang

https://reviews.llvm.org/D63417

Files:
  lib/Basic/Targets/RISCV.h


Index: lib/Basic/Targets/RISCV.h
===
--- lib/Basic/Targets/RISCV.h
+++ lib/Basic/Targets/RISCV.h
@@ -58,6 +58,15 @@
 
   ArrayRef getGCCRegNames() const override;
 
+  int getEHDataRegisterNumber(unsigned RegNo) const override {
+if (RegNo == 0)
+  return 10;
+else if (RegNo == 1)
+  return 11;
+else
+  return -1;
+  }
+
   ArrayRef getGCCRegAliases() const override;
 
   bool validateAsmConstraint(const char *&Name,


Index: lib/Basic/Targets/RISCV.h
===
--- lib/Basic/Targets/RISCV.h
+++ lib/Basic/Targets/RISCV.h
@@ -58,6 +58,15 @@
 
   ArrayRef getGCCRegNames() const override;
 
+  int getEHDataRegisterNumber(unsigned RegNo) const override {
+if (RegNo == 0)
+  return 10;
+else if (RegNo == 1)
+  return 11;
+else
+  return -1;
+  }
+
   ArrayRef getGCCRegAliases() const override;
 
   bool validateAsmConstraint(const char *&Name,
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D63417: [RISCV] Specify registers used for exception handling

2019-06-19 Thread Edward Jones via Phabricator via cfe-commits
edward-jones updated this revision to Diff 205542.
edward-jones retitled this revision from "[WIP][RISCV] Specify registers used 
for exception handling" to "[RISCV] Specify registers used for exception 
handling".
edward-jones edited the summary of this revision.
edward-jones added a comment.

Added tests


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D63417/new/

https://reviews.llvm.org/D63417

Files:
  lib/Basic/Targets/RISCV.h
  test/CodeGen/builtin-riscv.c


Index: test/CodeGen/builtin-riscv.c
===
--- /dev/null
+++ test/CodeGen/builtin-riscv.c
@@ -0,0 +1,10 @@
+// RUN: %clang_cc1 -Wall -Werror -triple riscv32 -disable-O0-optnone 
-emit-llvm -o - %s | opt -S -mem2reg | FileCheck %s
+
+void test_eh_return_data_regno()
+{
+  // CHECK: store volatile i32 10
+  // CHECK: store volatile i32 11
+  volatile int res;
+  res = __builtin_eh_return_data_regno(0);
+  res = __builtin_eh_return_data_regno(1);
+}
Index: lib/Basic/Targets/RISCV.h
===
--- lib/Basic/Targets/RISCV.h
+++ lib/Basic/Targets/RISCV.h
@@ -57,6 +57,15 @@
 
   ArrayRef getGCCRegNames() const override;
 
+  int getEHDataRegisterNumber(unsigned RegNo) const override {
+if (RegNo == 0)
+  return 10;
+else if (RegNo == 1)
+  return 11;
+else
+  return -1;
+  }
+
   ArrayRef getGCCRegAliases() const override;
 
   bool validateAsmConstraint(const char *&Name,


Index: test/CodeGen/builtin-riscv.c
===
--- /dev/null
+++ test/CodeGen/builtin-riscv.c
@@ -0,0 +1,10 @@
+// RUN: %clang_cc1 -Wall -Werror -triple riscv32 -disable-O0-optnone -emit-llvm -o - %s | opt -S -mem2reg | FileCheck %s
+
+void test_eh_return_data_regno()
+{
+  // CHECK: store volatile i32 10
+  // CHECK: store volatile i32 11
+  volatile int res;
+  res = __builtin_eh_return_data_regno(0);
+  res = __builtin_eh_return_data_regno(1);
+}
Index: lib/Basic/Targets/RISCV.h
===
--- lib/Basic/Targets/RISCV.h
+++ lib/Basic/Targets/RISCV.h
@@ -57,6 +57,15 @@
 
   ArrayRef getGCCRegNames() const override;
 
+  int getEHDataRegisterNumber(unsigned RegNo) const override {
+if (RegNo == 0)
+  return 10;
+else if (RegNo == 1)
+  return 11;
+else
+  return -1;
+  }
+
   ArrayRef getGCCRegAliases() const override;
 
   bool validateAsmConstraint(const char *&Name,
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D63417: [RISCV] Specify registers used for exception handling

2019-07-03 Thread Edward Jones via Phabricator via cfe-commits
edward-jones updated this revision to Diff 207736.
edward-jones added a comment.

Add riscv64 target run line, renamed test file to builtins-riscv.c, and rebased.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D63417/new/

https://reviews.llvm.org/D63417

Files:
  lib/Basic/Targets/RISCV.h
  test/CodeGen/builtins-riscv.c


Index: test/CodeGen/builtins-riscv.c
===
--- /dev/null
+++ test/CodeGen/builtins-riscv.c
@@ -0,0 +1,11 @@
+// RUN: %clang_cc1 -Wall -Werror -triple riscv32 -disable-O0-optnone 
-emit-llvm -o - %s | opt -S -mem2reg | FileCheck %s
+// RUN: %clang_cc1 -Wall -Werror -triple riscv64 -disable-O0-optnone 
-emit-llvm -o - %s | opt -S -mem2reg | FileCheck %s
+
+void test_eh_return_data_regno()
+{
+  // CHECK: store volatile i32 10
+  // CHECK: store volatile i32 11
+  volatile int res;
+  res = __builtin_eh_return_data_regno(0);
+  res = __builtin_eh_return_data_regno(1);
+}
Index: lib/Basic/Targets/RISCV.h
===
--- lib/Basic/Targets/RISCV.h
+++ lib/Basic/Targets/RISCV.h
@@ -57,6 +57,15 @@
 
   ArrayRef getGCCRegNames() const override;
 
+  int getEHDataRegisterNumber(unsigned RegNo) const override {
+if (RegNo == 0)
+  return 10;
+else if (RegNo == 1)
+  return 11;
+else
+  return -1;
+  }
+
   ArrayRef getGCCRegAliases() const override;
 
   bool validateAsmConstraint(const char *&Name,


Index: test/CodeGen/builtins-riscv.c
===
--- /dev/null
+++ test/CodeGen/builtins-riscv.c
@@ -0,0 +1,11 @@
+// RUN: %clang_cc1 -Wall -Werror -triple riscv32 -disable-O0-optnone -emit-llvm -o - %s | opt -S -mem2reg | FileCheck %s
+// RUN: %clang_cc1 -Wall -Werror -triple riscv64 -disable-O0-optnone -emit-llvm -o - %s | opt -S -mem2reg | FileCheck %s
+
+void test_eh_return_data_regno()
+{
+  // CHECK: store volatile i32 10
+  // CHECK: store volatile i32 11
+  volatile int res;
+  res = __builtin_eh_return_data_regno(0);
+  res = __builtin_eh_return_data_regno(1);
+}
Index: lib/Basic/Targets/RISCV.h
===
--- lib/Basic/Targets/RISCV.h
+++ lib/Basic/Targets/RISCV.h
@@ -57,6 +57,15 @@
 
   ArrayRef getGCCRegNames() const override;
 
+  int getEHDataRegisterNumber(unsigned RegNo) const override {
+if (RegNo == 0)
+  return 10;
+else if (RegNo == 1)
+  return 11;
+else
+  return -1;
+  }
+
   ArrayRef getGCCRegAliases() const override;
 
   bool validateAsmConstraint(const char *&Name,
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D63417: [RISCV] Specify registers used for exception handling

2019-07-03 Thread Edward Jones via Phabricator via cfe-commits
edward-jones updated this revision to Diff 207769.

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D63417/new/

https://reviews.llvm.org/D63417

Files:
  lib/Basic/Targets/RISCV.h
  test/CodeGen/builtins-riscv.c


Index: test/CodeGen/builtins-riscv.c
===
--- /dev/null
+++ test/CodeGen/builtins-riscv.c
@@ -0,0 +1,10 @@
+// RUN: %clang_cc1 -Wall -Werror -triple riscv32 -disable-O0-optnone 
-emit-llvm -o - %s | opt -S -mem2reg | FileCheck %s
+// RUN: %clang_cc1 -Wall -Werror -triple riscv64 -disable-O0-optnone 
-emit-llvm -o - %s | opt -S -mem2reg | FileCheck %s
+
+void test_eh_return_data_regno() {
+  // CHECK: store volatile i32 10
+  // CHECK: store volatile i32 11
+  volatile int res;
+  res = __builtin_eh_return_data_regno(0);
+  res = __builtin_eh_return_data_regno(1);
+}
Index: lib/Basic/Targets/RISCV.h
===
--- lib/Basic/Targets/RISCV.h
+++ lib/Basic/Targets/RISCV.h
@@ -57,6 +57,15 @@
 
   ArrayRef getGCCRegNames() const override;
 
+  int getEHDataRegisterNumber(unsigned RegNo) const override {
+if (RegNo == 0)
+  return 10;
+else if (RegNo == 1)
+  return 11;
+else
+  return -1;
+  }
+
   ArrayRef getGCCRegAliases() const override;
 
   bool validateAsmConstraint(const char *&Name,


Index: test/CodeGen/builtins-riscv.c
===
--- /dev/null
+++ test/CodeGen/builtins-riscv.c
@@ -0,0 +1,10 @@
+// RUN: %clang_cc1 -Wall -Werror -triple riscv32 -disable-O0-optnone -emit-llvm -o - %s | opt -S -mem2reg | FileCheck %s
+// RUN: %clang_cc1 -Wall -Werror -triple riscv64 -disable-O0-optnone -emit-llvm -o - %s | opt -S -mem2reg | FileCheck %s
+
+void test_eh_return_data_regno() {
+  // CHECK: store volatile i32 10
+  // CHECK: store volatile i32 11
+  volatile int res;
+  res = __builtin_eh_return_data_regno(0);
+  res = __builtin_eh_return_data_regno(1);
+}
Index: lib/Basic/Targets/RISCV.h
===
--- lib/Basic/Targets/RISCV.h
+++ lib/Basic/Targets/RISCV.h
@@ -57,6 +57,15 @@
 
   ArrayRef getGCCRegNames() const override;
 
+  int getEHDataRegisterNumber(unsigned RegNo) const override {
+if (RegNo == 0)
+  return 10;
+else if (RegNo == 1)
+  return 11;
+else
+  return -1;
+  }
+
   ArrayRef getGCCRegAliases() const override;
 
   bool validateAsmConstraint(const char *&Name,
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D68391: [RISCV] Improve sysroot computation if no GCC install detected

2019-10-03 Thread Edward Jones via Phabricator via cfe-commits
edward-jones created this revision.
Herald added subscribers: cfe-commits, pzheng, simoncook, s.egerton, lenary, 
Jim, benna, psnobl, jocewei, PkmX, rkruppe, the_o, brucehoult, MartinMosbeck, 
rogfer01, zzheng, MaskRay, jrtc27, shiva0217, kito-cheng, niosHD, sabuasal, 
apazos, johnrusso, rbar, asb.
Herald added a project: clang.

If a GCC installed is not detected, the driver would default to the root of the 
filesystem. This is not ideal when this doesn't match the install directory of 
the toolchain and can cause undesireable behavior such as picking up system 
libraries or the system linker when cross-compiling.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D68391

Files:
  clang/lib/Driver/ToolChains/RISCVToolchain.cpp


Index: clang/lib/Driver/ToolChains/RISCVToolchain.cpp
===
--- clang/lib/Driver/ToolChains/RISCVToolchain.cpp
+++ clang/lib/Driver/ToolChains/RISCVToolchain.cpp
@@ -73,17 +73,20 @@
   if (!getDriver().SysRoot.empty())
 return getDriver().SysRoot;
 
-  if (!GCCInstallation.isValid())
-return std::string();
-
-  StringRef LibDir = GCCInstallation.getParentLibPath();
-  StringRef TripleStr = GCCInstallation.getTriple().str();
-  std::string SysRootDir = LibDir.str() + "/../" + TripleStr.str();
+  SmallString<128> SysRootDir;
+  if (GCCInstallation.isValid()) {
+StringRef LibDir = GCCInstallation.getParentLibPath();
+StringRef TripleStr = GCCInstallation.getTriple().str();
+llvm::sys::path::append(SysRootDir, LibDir, "..", TripleStr);
+  } else {
+llvm::sys::path::append(SysRootDir, getDriver().Dir, "..",
+getTriple().str());
+  }
 
   if (!llvm::sys::fs::exists(SysRootDir))
 return std::string();
 
-  return SysRootDir;
+  return SysRootDir.str();
 }
 
 void RISCV::Linker::ConstructJob(Compilation &C, const JobAction &JA,


Index: clang/lib/Driver/ToolChains/RISCVToolchain.cpp
===
--- clang/lib/Driver/ToolChains/RISCVToolchain.cpp
+++ clang/lib/Driver/ToolChains/RISCVToolchain.cpp
@@ -73,17 +73,20 @@
   if (!getDriver().SysRoot.empty())
 return getDriver().SysRoot;
 
-  if (!GCCInstallation.isValid())
-return std::string();
-
-  StringRef LibDir = GCCInstallation.getParentLibPath();
-  StringRef TripleStr = GCCInstallation.getTriple().str();
-  std::string SysRootDir = LibDir.str() + "/../" + TripleStr.str();
+  SmallString<128> SysRootDir;
+  if (GCCInstallation.isValid()) {
+StringRef LibDir = GCCInstallation.getParentLibPath();
+StringRef TripleStr = GCCInstallation.getTriple().str();
+llvm::sys::path::append(SysRootDir, LibDir, "..", TripleStr);
+  } else {
+llvm::sys::path::append(SysRootDir, getDriver().Dir, "..",
+getTriple().str());
+  }
 
   if (!llvm::sys::fs::exists(SysRootDir))
 return std::string();
 
-  return SysRootDir;
+  return SysRootDir.str();
 }
 
 void RISCV::Linker::ConstructJob(Compilation &C, const JobAction &JA,
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D68391: [RISCV] Improve sysroot computation if no GCC install detected

2019-10-03 Thread Edward Jones via Phabricator via cfe-commits
edward-jones added a comment.

Before falling back to returning the empty string this first looks for a 
directory with the triple name up one level from the driver.

This uses the Triple string in the path, however this Triple has been 
normalized so even if the user specifies "clang --target=riscv32-unknown-elf", 
it will use "riscv32-unknown-unknown-elf" when looking for the sysroot. I am 
wondering whether it would be sensible to do a more "intelligent" search for 
the sysroot here by iteratively stripping "unknown"s from the triple.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D68391/new/

https://reviews.llvm.org/D68391



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D68407: [WIP][RISCV] Use compiler-rt if no GCC installation detected

2019-10-03 Thread Edward Jones via Phabricator via cfe-commits
edward-jones created this revision.
edward-jones added a reviewer: asb.
Herald added subscribers: cfe-commits, pzheng, simoncook, s.egerton, lenary, 
Jim, benna, psnobl, jocewei, PkmX, rkruppe, the_o, brucehoult, MartinMosbeck, 
rogfer01, zzheng, MaskRay, jrtc27, shiva0217, kito-cheng, niosHD, sabuasal, 
apazos, johnrusso, rbar, dberris.
Herald added a project: clang.

If a GCC installation is not detected, they this attempts to use compiler-rt 
and the compiler-rt crtbegin/crtend implementations as a fallback.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D68407

Files:
  clang/lib/Driver/ToolChains/RISCVToolchain.cpp
  clang/lib/Driver/ToolChains/RISCVToolchain.h


Index: clang/lib/Driver/ToolChains/RISCVToolchain.h
===
--- clang/lib/Driver/ToolChains/RISCVToolchain.h
+++ clang/lib/Driver/ToolChains/RISCVToolchain.h
@@ -45,13 +45,18 @@
 namespace RISCV {
 class LLVM_LIBRARY_VISIBILITY Linker : public GnuTool {
 public:
-  Linker(const ToolChain &TC) : GnuTool("RISCV::Linker", "ld", TC) {}
+  Linker(const ToolChain &TC, bool ShouldUseLibGCC)
+  : GnuTool("RISCV::Linker", "ld", TC),
+UseLibGCC(ShouldUseLibGCC) {}
   bool hasIntegratedCPP() const override { return false; }
   bool isLinkJob() const override { return true; }
   void ConstructJob(Compilation &C, const JobAction &JA,
 const InputInfo &Output, const InputInfoList &Inputs,
 const llvm::opt::ArgList &TCArgs,
 const char *LinkingOutput) const override;
+
+private:
+  bool UseLibGCC;
 };
 } // end namespace RISCV
 } // end namespace tools
Index: clang/lib/Driver/ToolChains/RISCVToolchain.cpp
===
--- clang/lib/Driver/ToolChains/RISCVToolchain.cpp
+++ clang/lib/Driver/ToolChains/RISCVToolchain.cpp
@@ -36,7 +36,8 @@
 }
 
 Tool *RISCVToolChain::buildLinker() const {
-  return new tools::RISCV::Linker(*this);
+  bool useLibGCC = GCCInstallation.isValid();
+  return new tools::RISCV::Linker(*this, useLibGCC);
 }
 
 void RISCVToolChain::addClangTargetOptions(
@@ -94,7 +95,7 @@
  const InputInfoList &Inputs,
  const ArgList &Args,
  const char *LinkingOutput) const {
-  const ToolChain &ToolChain = getToolChain();
+  const auto &ToolChain = getToolChain();
   const Driver &D = ToolChain.getDriver();
   ArgStringList CmdArgs;
 
@@ -106,9 +107,28 @@
   bool WantCRTs =
   !Args.hasArg(options::OPT_nostdlib, options::OPT_nostartfiles);
 
+  const char *crtbegin, *crtend, *rtlib;
+  if (UseLibGCC) {
+crtbegin = "crtbegin.o";
+crtend = "crtend.o";
+rtlib = "-lgcc";
+  } else {
+auto Arch = ToolChain.getTriple().getArch();
+if (Arch == llvm::Triple::ArchType::riscv32) {
+  crtbegin = "clang_rt.crtbegin-riscv32.o";
+  crtend = "clang_rt.crtend-riscv32.o";
+  rtlib = "-lclang_rt.builtins-riscv32";
+} else {
+  assert(Arch == llvm::Triple::ArchType::riscv64);
+  crtbegin = "clang_rt.crtbegin-riscv64.o";
+  crtend = "clang_rt.crtend-riscv64.o";
+  rtlib = "-lclang_rt.builtins-riscv64";
+}
+  }
+
   if (WantCRTs) {
 CmdArgs.push_back(Args.MakeArgString(ToolChain.GetFilePath("crt0.o")));
-CmdArgs.push_back(Args.MakeArgString(ToolChain.GetFilePath("crtbegin.o")));
+CmdArgs.push_back(Args.MakeArgString(ToolChain.GetFilePath(crtbegin)));
   }
 
   Args.AddAllArgs(CmdArgs, options::OPT_L);
@@ -129,11 +149,11 @@
 CmdArgs.push_back("-lc");
 CmdArgs.push_back("-lgloss");
 CmdArgs.push_back("--end-group");
-CmdArgs.push_back("-lgcc");
+CmdArgs.push_back(rtlib);
   }
 
   if (WantCRTs)
-CmdArgs.push_back(Args.MakeArgString(ToolChain.GetFilePath("crtend.o")));
+CmdArgs.push_back(Args.MakeArgString(ToolChain.GetFilePath(crtend)));
 
   CmdArgs.push_back("-o");
   CmdArgs.push_back(Output.getFilename());


Index: clang/lib/Driver/ToolChains/RISCVToolchain.h
===
--- clang/lib/Driver/ToolChains/RISCVToolchain.h
+++ clang/lib/Driver/ToolChains/RISCVToolchain.h
@@ -45,13 +45,18 @@
 namespace RISCV {
 class LLVM_LIBRARY_VISIBILITY Linker : public GnuTool {
 public:
-  Linker(const ToolChain &TC) : GnuTool("RISCV::Linker", "ld", TC) {}
+  Linker(const ToolChain &TC, bool ShouldUseLibGCC)
+  : GnuTool("RISCV::Linker", "ld", TC),
+UseLibGCC(ShouldUseLibGCC) {}
   bool hasIntegratedCPP() const override { return false; }
   bool isLinkJob() const override { return true; }
   void ConstructJob(Compilation &C, const JobAction &JA,
 const InputInfo &Output, const InputInfoList &Inputs,
 const llvm::opt::ArgList &TCArgs,
 const char *LinkingOutput) const override;
+
+private:
+  bool UseLibGCC;
 };
 } // end namespace RISCV
 } // end namespace tools
Ind

[PATCH] D68407: [WIP][RISCV] Use compiler-rt if no GCC installation detected

2019-10-03 Thread Edward Jones via Phabricator via cfe-commits
edward-jones added a comment.

Work in progress because this needs tests (and probably clang-format too).

My assumption is that libgcc should be used in preference if it is available. 
At the moment this either uses libgcc and libgcc's crtbegin/crtend, or the 
Clang equivalents. Potentially a user might want to mix compiler-rt builtins 
with libgcc's crt*.o files, but for now that's not possible.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D68407/new/

https://reviews.llvm.org/D68407



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D68391: [RISCV] Improve sysroot computation if no GCC install detected

2019-10-04 Thread Edward Jones via Phabricator via cfe-commits
edward-jones planned changes to this revision.
edward-jones added a comment.

I'm reworking this at the moment and adding some tests. Standby!


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D68391/new/

https://reviews.llvm.org/D68391



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D68391: [RISCV] Improve sysroot computation if no GCC install detected

2019-10-04 Thread Edward Jones via Phabricator via cfe-commits
edward-jones updated this revision to Diff 223205.
edward-jones added a comment.
Herald added subscribers: arichardson, emaste.
Herald added a reviewer: espindola.

Rebased and added tests

I've made this use the Triple from the driver rather than the parsed LLVM 
triple, this means the Triple doesn't get normalized which seems like more 
desirable behavior.

I've added to the riscv{32,64}-toolchain.c test files, however the added tests 
cannot be run without a shell so I've had to disable those tests on Windows. If 
necessary I can split these new tests out into separate files.

I realize that there don't appear to be any tests for the case where no GCC 
install is found and no sysroot is provided to the driver. At the moment this 
will result in a generic linker command using the system linker, such as:

/usr/bin/ld crt0.o crtbegin.o ... -lgcc crtend.o

Is this the desired behaviour? And if so should a test be added for this too?


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D68391/new/

https://reviews.llvm.org/D68391

Files:
  clang/lib/Driver/ToolChains/RISCVToolchain.cpp
  clang/test/Driver/Inputs/basic_riscv32_nogcc_tree/bin/riscv32-unknown-elf-ld
  
clang/test/Driver/Inputs/basic_riscv32_nogcc_tree/riscv32-unknown-elf/lib/crt0.o
  
clang/test/Driver/Inputs/basic_riscv32_nogcc_tree/riscv32-unknown-elf/lib/crtbegin.o
  
clang/test/Driver/Inputs/basic_riscv32_nogcc_tree/riscv32-unknown-elf/lib/crtend.o
  clang/test/Driver/Inputs/basic_riscv64_nogcc_tree/bin/riscv64-unknown-elf-ld
  
clang/test/Driver/Inputs/basic_riscv64_nogcc_tree/riscv64-unknown-elf/lib/crt0.o
  
clang/test/Driver/Inputs/basic_riscv64_nogcc_tree/riscv64-unknown-elf/lib/crtbegin.o
  
clang/test/Driver/Inputs/basic_riscv64_nogcc_tree/riscv64-unknown-elf/lib/crtend.o
  clang/test/Driver/riscv32-toolchain.c
  clang/test/Driver/riscv64-toolchain.c

Index: clang/test/Driver/riscv64-toolchain.c
===
--- clang/test/Driver/riscv64-toolchain.c
+++ clang/test/Driver/riscv64-toolchain.c
@@ -1,4 +1,6 @@
 // A basic clang -cc1 command-line, and simple environment check.
+// REQUIRES: shell
+// UNSUPPORTED: system-windows
 
 // RUN: %clang %s -### -no-canonical-prefixes -target riscv64 2>&1 | FileCheck -check-prefix=CC1 %s
 // CC1: clang{{.*}} "-cc1" "-triple" "riscv64"
@@ -34,6 +36,33 @@
 // C-RV64-BAREMETAL-NOSYSROOT-LP64: "--start-group" "-lc" "-lgloss" "--end-group" "-lgcc"
 // C-RV64-BAREMETAL-NOSYSROOT-LP64: "{{.*}}/Inputs/basic_riscv64_tree/lib/gcc/riscv64-unknown-elf/8.0.1{{/|}}crtend.o"
 
+// If there is no GCC install detected then the driver searches for executables
+// and runtime starting from the directory tree above the driver itself.
+// The test below checks that the driver correctly finds the linker and
+// runtime iff they exist.
+// 
+// RUN: mkdir -p %T/testroot-riscv64-baremetal-nogcc/bin
+// RUN: [ ! -s %T/testroot-riscv64-baremetal-nogcc/bin/clang ] || rm %T/testroot-riscv64-baremetal-nogcc/bin/clang
+// RUN: [ ! -s %T/testroot-riscv64-baremetal-nogcc/bin/riscv64-unknown-elf-ld ] || rm %T/testroot-riscv64-baremetal-nogcc/bin/riscv64-unknown-elf-ld
+// RUN: [ ! -s %T/testroot-riscv64-baremetal-nogcc/riscv64-unknown-elf ] || rm %T/testroot-riscv64-baremetal-nogcc/riscv64-unknown-elf
+// RUN: ln -s %clang %T/testroot-riscv64-baremetal-nogcc/bin/clang
+// RUN: ln -s %S/Inputs/basic_riscv64_nogcc_tree/bin/riscv64-unknown-elf-ld %T/testroot-riscv64-baremetal-nogcc/bin/riscv64-unknown-elf-ld
+// RUN: ln -s %S/Inputs/basic_riscv64_nogcc_tree/riscv64-unknown-elf %T/testroot-riscv64-baremetal-nogcc/riscv64-unknown-elf
+// RUN: %T/testroot-riscv64-baremetal-nogcc/bin/clang %s -### -no-canonical-prefixes \
+// RUN:-target riscv64-unknown-elf 2>&1 \
+// RUN:| FileCheck -check-prefix=C-RV64-BAREMETAL-LP64-NOGCC %s
+
+// C-RV64-BAREMETAL-LP64-NOGCC: InstalledDir: [[DRIVERDIR:.*]]
+// C-RV64-BAREMETAL-LP64-NOGCC: "-fuse-init-array"
+// C-RV64-BAREMETAL-LP64-NOGCC: "-internal-isystem" "[[DRIVERDIR]]/../riscv64-unknown-elf/include"
+// C-RV64-BAREMETAL-LP64-NOGCC: "[[DRIVERDIR]]/riscv64-unknown-elf-ld"
+// C-RV64-BAREMETAL-LP64-NOGCC: "[[DRIVERDIR]]/../riscv64-unknown-elf/lib/crt0.o"
+// C-RV64-BAREMETAL-LP64-NOGCC: "[[DRIVERDIR]]/../riscv64-unknown-elf/lib/crtbegin.o"
+// C-RV64-BAREMETAL-LP64-NOGCC: "-L[[DRIVERDIR]]/../riscv64-unknown-elf/lib"
+// C-RV64-BAREMETAL-LP64-NOGCC: "--start-group" "-lc" "-lgloss" "--end-group" "-lgcc"
+// C-RV64-BAREMETAL-LP64-NOGCC: "[[DRIVERDIR]]/../riscv64-unknown-elf/lib/crtend.o"
+
+
 // RUN: %clangxx %s -### -no-canonical-prefixes \
 // RUN:   -target riscv64-unknown-elf -stdlib=libstdc++ \
 // RUN:   --gcc-toolchain=%S/Inputs/basic_riscv64_tree \
Index: clang/test/Driver/riscv32-toolchain.c
===
--- clang/test/Driver/riscv32-toolchain.c
+++ clang/test/Driver/riscv32-toolchain.c
@@ -1,4 +1,6 @@
 // A basic clang -cc1 command-line, and simple environment check.
+

[PATCH] D68407: [RISCV] Use compiler-rt if no GCC installation detected

2019-10-04 Thread Edward Jones via Phabricator via cfe-commits
edward-jones updated this revision to Diff 223209.
edward-jones retitled this revision from "[WIP][RISCV] Use compiler-rt if no 
GCC installation detected" to "[RISCV] Use compiler-rt if no GCC installation 
detected".
edward-jones added a comment.
Herald added subscribers: arichardson, emaste.
Herald added a reviewer: espindola.

Rebased, updated tests from D68391  to check 
for existence of compiler-rt crtbegin/crtend and runtime library.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D68407/new/

https://reviews.llvm.org/D68407

Files:
  clang/lib/Driver/ToolChains/RISCVToolchain.cpp
  clang/lib/Driver/ToolChains/RISCVToolchain.h
  
clang/test/Driver/Inputs/basic_riscv32_nogcc_tree/riscv32-unknown-elf/lib/clang_rt.crtbegin-riscv32.o
  
clang/test/Driver/Inputs/basic_riscv32_nogcc_tree/riscv32-unknown-elf/lib/clang_rt.crtend-riscv32.o
  
clang/test/Driver/Inputs/basic_riscv32_nogcc_tree/riscv32-unknown-elf/lib/crtbegin.o
  
clang/test/Driver/Inputs/basic_riscv32_nogcc_tree/riscv32-unknown-elf/lib/crtend.o
  
clang/test/Driver/Inputs/basic_riscv64_nogcc_tree/riscv64-unknown-elf/lib/clang_rt.crtbegin-riscv64.o
  
clang/test/Driver/Inputs/basic_riscv64_nogcc_tree/riscv64-unknown-elf/lib/clang_rt.crtend-riscv64.o
  
clang/test/Driver/Inputs/basic_riscv64_nogcc_tree/riscv64-unknown-elf/lib/crtbegin.o
  
clang/test/Driver/Inputs/basic_riscv64_nogcc_tree/riscv64-unknown-elf/lib/crtend.o
  clang/test/Driver/riscv32-toolchain.c
  clang/test/Driver/riscv64-toolchain.c

Index: clang/test/Driver/riscv64-toolchain.c
===
--- clang/test/Driver/riscv64-toolchain.c
+++ clang/test/Driver/riscv64-toolchain.c
@@ -57,10 +57,10 @@
 // C-RV64-BAREMETAL-LP64-NOGCC: "-internal-isystem" "[[DRIVERDIR]]/../riscv64-unknown-elf/include"
 // C-RV64-BAREMETAL-LP64-NOGCC: "[[DRIVERDIR]]/riscv64-unknown-elf-ld"
 // C-RV64-BAREMETAL-LP64-NOGCC: "[[DRIVERDIR]]/../riscv64-unknown-elf/lib/crt0.o"
-// C-RV64-BAREMETAL-LP64-NOGCC: "[[DRIVERDIR]]/../riscv64-unknown-elf/lib/crtbegin.o"
+// C-RV64-BAREMETAL-LP64-NOGCC: "[[DRIVERDIR]]/../riscv64-unknown-elf/lib/clang_rt.crtbegin-riscv64.o"
 // C-RV64-BAREMETAL-LP64-NOGCC: "-L[[DRIVERDIR]]/../riscv64-unknown-elf/lib"
-// C-RV64-BAREMETAL-LP64-NOGCC: "--start-group" "-lc" "-lgloss" "--end-group" "-lgcc"
-// C-RV64-BAREMETAL-LP64-NOGCC: "[[DRIVERDIR]]/../riscv64-unknown-elf/lib/crtend.o"
+// C-RV64-BAREMETAL-LP64-NOGCC: "--start-group" "-lc" "-lgloss" "--end-group" "-lclang_rt.builtins-riscv64"
+// C-RV64-BAREMETAL-LP64-NOGCC: "[[DRIVERDIR]]/../riscv64-unknown-elf/lib/clang_rt.crtend-riscv64.o"
 
 
 // RUN: %clangxx %s -### -no-canonical-prefixes \
Index: clang/test/Driver/riscv32-toolchain.c
===
--- clang/test/Driver/riscv32-toolchain.c
+++ clang/test/Driver/riscv32-toolchain.c
@@ -57,10 +57,10 @@
 // C-RV32-BAREMETAL-ILP32-NOGCC: "-internal-isystem" "[[DRIVERDIR]]/../riscv32-unknown-elf/include"
 // C-RV32-BAREMETAL-ILP32-NOGCC: "[[DRIVERDIR]]/riscv32-unknown-elf-ld"
 // C-RV32-BAREMETAL-ILP32-NOGCC: "[[DRIVERDIR]]/../riscv32-unknown-elf/lib/crt0.o"
-// C-RV32-BAREMETAL-ILP32-NOGCC: "[[DRIVERDIR]]/../riscv32-unknown-elf/lib/crtbegin.o"
+// C-RV32-BAREMETAL-ILP32-NOGCC: "[[DRIVERDIR]]/../riscv32-unknown-elf/lib/clang_rt.crtbegin-riscv32.o"
 // C-RV32-BAREMETAL-ILP32-NOGCC: "-L[[DRIVERDIR]]/../riscv32-unknown-elf/lib"
-// C-RV32-BAREMETAL-ILP32-NOGCC: "--start-group" "-lc" "-lgloss" "--end-group" "-lgcc"
-// C-RV32-BAREMETAL-ILP32-NOGCC: "[[DRIVERDIR]]/../riscv32-unknown-elf/lib/crtend.o"
+// C-RV32-BAREMETAL-ILP32-NOGCC: "--start-group" "-lc" "-lgloss" "--end-group" "-lclang_rt.builtins-riscv32"
+// C-RV32-BAREMETAL-ILP32-NOGCC: "[[DRIVERDIR]]/../riscv32-unknown-elf/lib/clang_rt.crtend-riscv32.o"
 
 // RUN: %clangxx %s -### -no-canonical-prefixes \
 // RUN:   -target riscv32-unknown-elf -stdlib=libstdc++ \
Index: clang/lib/Driver/ToolChains/RISCVToolchain.h
===
--- clang/lib/Driver/ToolChains/RISCVToolchain.h
+++ clang/lib/Driver/ToolChains/RISCVToolchain.h
@@ -45,13 +45,18 @@
 namespace RISCV {
 class LLVM_LIBRARY_VISIBILITY Linker : public GnuTool {
 public:
-  Linker(const ToolChain &TC) : GnuTool("RISCV::Linker", "ld", TC) {}
+  Linker(const ToolChain &TC, bool ShouldUseLibGCC)
+  : GnuTool("RISCV::Linker", "ld", TC),
+UseLibGCC(ShouldUseLibGCC) {}
   bool hasIntegratedCPP() const override { return false; }
   bool isLinkJob() const override { return true; }
   void ConstructJob(Compilation &C, const JobAction &JA,
 const InputInfo &Output, const InputInfoList &Inputs,
 const llvm::opt::ArgList &TCArgs,
 const char *LinkingOutput) const override;
+
+private:
+  bool UseLibGCC;
 };
 } // end namespace RISCV
 } // end namespace tools
Index: clang/lib/Driver/ToolChains/RISCVToolchain.cpp
===

[PATCH] D81946: [WIP][RISCV] Enable multilib support even without a detected GCC install

2020-06-16 Thread Edward Jones via Phabricator via cfe-commits
edward-jones created this revision.
edward-jones added reviewers: asb, simoncook, lenary.
Herald added subscribers: cfe-commits, evandro, luismarques, apazos, 
sameer.abuasal, pzheng, s.egerton, Jim, benna, psnobl, jocewei, PkmX, rkruppe, 
the_o, brucehoult, MartinMosbeck, rogfer01, zzheng, MaskRay, jrtc27, shiva0217, 
kito-cheng, niosHD, sabuasal, johnrusso, rbar, emaste.
Herald added a reviewer: espindola.
Herald added a project: clang.

Previously the driver would only report multilibs which already exist. This has 
been relaxed so that when there is no detected GCC installation the multilibs 
will be reported anyway.

In the absence of a GCC installation, the driver will look for libraries 
starting from the resource directory:

  /lib/clang/

This is slightly different to the path in the case where a GCC install is 
detected. in that case the resource directory includes the triple:

  /lib/gcc//

In addition to the resource directory the driver will also look for libraries 
not installed alongside the compiler in the following directories:

In the absence of a detected GCC installation:

  /lib/clang//../../..//lib

With a GCC installation:

  /lib/gcc///../../../..//lib

The calculation of the sysroot has also been updated. If a sysroot was not 
provided to the driver then the driver would try to derive it from the detected 
GCC installation. If this was not possible then it would be derived from the 
directory of the driver "/bin/clang" as follows:

  /bin/../

This uses the original triple as provided to the compiler, however this isn't 
ideal as the presence of multilibs means that riscv32 libraries/headers/tools 
may be installed under "/riscv64-unknown-elf" instead of 
"/riscv32-unknown-elf". The GCC installation detector already handles 
this by trying both the original triple *and* the triple of the biarch variant 
using the first directory with exists. This behaviour has been copied so the 
same occurs even without a gcc installation.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D81946

Files:
  clang/lib/Driver/ToolChains/Arch/RISCV.cpp
  clang/lib/Driver/ToolChains/Arch/RISCV.h
  clang/lib/Driver/ToolChains/Gnu.cpp
  clang/lib/Driver/ToolChains/RISCVToolchain.cpp
  clang/lib/Driver/ToolChains/RISCVToolchain.h
  
clang/test/Driver/Inputs/multilib_riscv_elf_nogcc_tree/bin/riscv32-unknown-elf-ld
  
clang/test/Driver/Inputs/multilib_riscv_elf_nogcc_tree/bin/riscv64-unknown-elf-ld
  
clang/test/Driver/Inputs/multilib_riscv_elf_nogcc_tree/lib/clang/11.0.0/rv32i/ilp32/clang_rt.crtbegin-riscv32.o
  
clang/test/Driver/Inputs/multilib_riscv_elf_nogcc_tree/lib/clang/11.0.0/rv32i/ilp32/clang_rt.crtend-riscv32.o
  
clang/test/Driver/Inputs/multilib_riscv_elf_nogcc_tree/lib/clang/11.0.0/rv32i/ilp32/libclang_rt.builtins-riscv32.a
  
clang/test/Driver/Inputs/multilib_riscv_elf_nogcc_tree/lib/clang/11.0.0/rv32iac/ilp32/clang_rt.crtbegin-riscv32.o
  
clang/test/Driver/Inputs/multilib_riscv_elf_nogcc_tree/lib/clang/11.0.0/rv32iac/ilp32/clang_rt.crtend-riscv32.o
  
clang/test/Driver/Inputs/multilib_riscv_elf_nogcc_tree/lib/clang/11.0.0/rv32iac/ilp32/libclang_rt.builtins-riscv32.a
  
clang/test/Driver/Inputs/multilib_riscv_elf_nogcc_tree/lib/clang/11.0.0/rv32im/ilp32/clang_rt.crtbegin-riscv32.o
  
clang/test/Driver/Inputs/multilib_riscv_elf_nogcc_tree/lib/clang/11.0.0/rv32im/ilp32/clang_rt.crtend-riscv32.o
  
clang/test/Driver/Inputs/multilib_riscv_elf_nogcc_tree/lib/clang/11.0.0/rv32im/ilp32/libclang_rt.builtins-riscv32.a
  
clang/test/Driver/Inputs/multilib_riscv_elf_nogcc_tree/lib/clang/11.0.0/rv32imac/ilp32/clang_rt.crtbegin-riscv32.o
  
clang/test/Driver/Inputs/multilib_riscv_elf_nogcc_tree/lib/clang/11.0.0/rv32imac/ilp32/clang_rt.crtend-riscv32.o
  
clang/test/Driver/Inputs/multilib_riscv_elf_nogcc_tree/lib/clang/11.0.0/rv32imac/ilp32/libclang_rt.builtins-riscv32.a
  
clang/test/Driver/Inputs/multilib_riscv_elf_nogcc_tree/lib/clang/11.0.0/rv32imafc/ilp32f/clang_rt.crtbegin-riscv32.o
  
clang/test/Driver/Inputs/multilib_riscv_elf_nogcc_tree/lib/clang/11.0.0/rv32imafc/ilp32f/clang_rt.crtend-riscv32.o
  
clang/test/Driver/Inputs/multilib_riscv_elf_nogcc_tree/lib/clang/11.0.0/rv32imafc/ilp32f/libclang_rt.builtins-riscv32.a
  
clang/test/Driver/Inputs/multilib_riscv_elf_nogcc_tree/lib/clang/11.0.0/rv64imac/lp64/clang_rt.crtbegin-riscv64.o
  
clang/test/Driver/Inputs/multilib_riscv_elf_nogcc_tree/lib/clang/11.0.0/rv64imac/lp64/clang_rt.crtend-riscv64.o
  
clang/test/Driver/Inputs/multilib_riscv_elf_nogcc_tree/lib/clang/11.0.0/rv64imac/lp64/libclang_rt.builtins-riscv64.a
  
clang/test/Driver/Inputs/multilib_riscv_elf_nogcc_tree/lib/clang/11.0.0/rv64imafdc/lp64d/clang_rt.crtbegin-riscv64.o
  
clang/test/Driver/Inputs/multilib_riscv_elf_nogcc_tree/lib/clang/11.0.0/rv64imafdc/lp64d/clang_rt.crtend-riscv64.o
  
clang/test/Driver/Inputs/multilib_riscv_elf_nogcc_tree/lib/clang/11.0.0/rv64imafdc/lp64d/libclang_rt.builtins-riscv64.a
  
clang/test/Driver/Inputs/multilib_riscv_elf_nogcc_tree/riscv64-u

[PATCH] D24461: CodeGen: Cast llvm.flt.rounds result to match __builtin_flt_rounds

2017-08-15 Thread Edward Jones via Phabricator via cfe-commits
edward-jones added a comment.

No, this doesn't seem to have been committed yet.


https://reviews.llvm.org/D24461



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D109372: [RISCV][RFC] Add Clang support for RISC-V overlay system

2021-09-23 Thread Edward Jones via Phabricator via cfe-commits
edward-jones updated this revision to Diff 374609.
edward-jones added a comment.
Herald added a subscriber: achieveartificialintelligence.

Changes here:

  - Merged the separate attributes overlaycall and overlaydata into a single 
overlay attribute (though I may need to undo this to match the high level 
document)
  - Fixed to use the correct type of attribute and handle it in a less sloppy 
way
  - Errors/warnings messages are hopefully more descriptive now
  - Renamed option to -moverlay to match the high level document
  - It's no longer an error to use the attribute without -moverlay, you'll just 
get "attribute ignored" warnings
- Updated tests

Still to do:

- Writing more tests
- Warn the user to turn on -moverlay as a fix for "attribute ignored" warnings
- Rebase


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D109372/new/

https://reviews.llvm.org/D109372

Files:
  clang/include/clang/Basic/Attr.td
  clang/include/clang/Basic/AttrDocs.td
  clang/include/clang/Basic/DiagnosticDriverKinds.td
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Basic/LangOptions.def
  clang/include/clang/Driver/Options.td
  clang/lib/CodeGen/CGCall.cpp
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/lib/Driver/ToolChains/Arch/RISCV.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Sema/SemaDecl.cpp
  clang/lib/Sema/SemaDeclAttr.cpp
  clang/test/CodeGen/riscv-overlay.c
  clang/test/Driver/riscv-overlay.c
  clang/test/Sema/riscv-overlay-attr.c
  clang/test/Sema/riscv-overlay-namespace.cpp

Index: clang/test/Sema/riscv-overlay-namespace.cpp
===
--- /dev/null
+++ clang/test/Sema/riscv-overlay-namespace.cpp
@@ -0,0 +1,20 @@
+// RUN: %clang_cc1 %s -triple riscv32-unknown-elf -verify -fsyntax-only -moverlay
+// RUN: %clang_cc1 %s -triple riscv64-unknown-elf -verify -fsyntax-only -moverlay
+
+namespace {
+class foo {
+public:
+  static int X() __attribute__((overlay)) { return 0; } // expected-error {{functions marked with 'overlay' attribute must have external linkage}}
+};
+} // end of anonymous namespace
+
+namespace X {
+class bar {
+public:
+  static int X() __attribute__((overlay)) { return 1; }
+};
+} // end of namespace X
+
+extern "C" {
+int main(void) { return foo::X() + X::bar::X(); }
+}
Index: clang/test/Sema/riscv-overlay-attr.c
===
--- /dev/null
+++ clang/test/Sema/riscv-overlay-attr.c
@@ -0,0 +1,16 @@
+// RUN: %clang_cc1 -triple riscv32 -moverlay -fsyntax-only -verify %s
+// RUN: %clang_cc1 -triple riscv64 -moverlay -fsyntax-only -verify %s
+
+int notAFunction __attribute__((overlay));
+// expected-warning@-1 {{'overlay' attribute only applies to functions and global constants}}
+
+void incompatForwardDecl(int x);
+void __attribute__((overlay)) incompatForwardDecl(int x) {}
+// expected-error@-1 {{redeclaration of 'incompatForwardDecl' must not have the 'overlay' attribute}}
+// expected-note@-3 {{previous definition is here}}
+
+static void staticcall() __attribute__((overlay)) {}
+// expected-error@-1 {{functions marked with 'overlay' attribute must have external linkage}}
+
+static void __attribute__((overlay)) staticcall2() {}
+// expected-error@-1 {{functions marked with 'overlay' attribute must have external linkage}}
Index: clang/test/Driver/riscv-overlay.c
===
--- /dev/null
+++ clang/test/Driver/riscv-overlay.c
@@ -0,0 +1,5 @@
+// Check that ComRV Driver Arguments
+
+// RUN: not %clang -target riscv32 -moverlay %s -o %t.o -mabi=ilp32f 2>&1 \
+// RUN:   | FileCheck -check-prefix=INVALID-ABI %s
+// INVALID-ABI: invalid ABI 'ilp32f' when using '-moverlay'
Index: clang/test/CodeGen/riscv-overlay.c
===
--- /dev/null
+++ clang/test/CodeGen/riscv-overlay.c
@@ -0,0 +1,11 @@
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py UTC_ARGS: --check-attributes
+// RUN: %clang_cc1 -triple riscv32 -moverlay -emit-llvm %s -o - \
+// RUN:| FileCheck %s
+
+// CHECK-LABEL: @test_overlay_func(
+// CHECK-SAME: #0
+// CHECK: attributes #0 = {
+// CHECK-SAME: "overlay"
+int __attribute__((overlay)) test_overlay_func(void) {
+  return 5;
+}
Index: clang/lib/Sema/SemaDeclAttr.cpp
===
--- clang/lib/Sema/SemaDeclAttr.cpp
+++ clang/lib/Sema/SemaDeclAttr.cpp
@@ -2039,6 +2039,29 @@
   D->addAttr(::new (S.Context) CmseNSEntryAttr(S.Context, AL));
 }
 
+static void handleRISCVOverlayAttr(Sema &S, Decl *D, const ParsedAttr &AL) {
+  if (!S.getLangOpts().Overlay) {
+S.Diag(AL.getRange().getBegin(), diag::warn_attribute_ignored) << AL;
+return;
+  }
+
+  if (isFunctionOrMethod(D)) {
+const auto *FD = cast(D);
+if (!FD->isExternallyVisible()) {
+  S.Diag(AL.getLoc(), diag::err_overlay_func_external_linkage);
+  AL.setInvalid();
+  retu

[PATCH] D109372: [RISCV][RFC] Add Clang support for RISC-V overlay system

2021-11-01 Thread Edward Jones via Phabricator via cfe-commits
edward-jones added a comment.
Herald added subscribers: VincentWu, luke957.

I reverted some of the previous changes I made so that this patch matches the 
spec as currently written - this means it's two attributes again, and the 
diagnostic messages have been updated a bit too. The two Clang attributes match 
to the same LLVM attribute internally though.

This is at a stage where more review would be nice. Obviously this is gated on 
patches to other toolchain components, but I hope that these changes won't 
change too much now unless the spec also changes.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D109372/new/

https://reviews.llvm.org/D109372

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D109372: [RISCV][RFC] Add Clang support for RISC-V overlay system

2021-11-04 Thread Edward Jones via Phabricator via cfe-commits
edward-jones added a comment.

In D109372#3099969 , @jrtc27 wrote:

> In D109372#3099947 , @edward-jones 
> wrote:
>
>> I reverted some of the previous changes I made so that this patch matches 
>> the spec as currently written - this means it's two attributes again, and 
>> the diagnostic messages have been updated a bit too. The two Clang 
>> attributes match to the same LLVM attribute internally though.
>>
>> This is at a stage where more review would be nice. Obviously this is gated 
>> on patches to other toolchain components, but I hope that these changes 
>> won't change too much now unless the spec also changes.
>
> The whole point of putting it up for review is so you get feedback about the 
> entire direction of the spec, which was written by people who are not experts 
> when it comes to toolchains. You’re supposed to take our feedback, relay it 
> to them and get the draft spec revised. Otherwise, if the spec written by 
> people who don’t know what makes sense for toolchains is regarded as holy and 
> immutable then I’m just going to NACK this as poorly designed and something 
> LLVM shouldn’t bow to implementing, and you’ve wasted my time asking for a 
> full review.

Understood, and apologies for requesting a review without first getting the 
spec clarified. I had relayed feedback about naming of relocs/attributes and 1 
vs 2 attributes offline, but that hadn't reached a conclusion so I had reverted 
to closer to the spec in the meantime. I've opened issues on the riscv-overlay 
repository to incorporate the feedback here.

https://github.com/riscv-software-src/riscv-overlay/issues/28
https://github.com/riscv-software-src/riscv-overlay/issues/29
https://github.com/riscv-software-src/riscv-overlay/issues/30




Comment at: clang/include/clang/Basic/Attr.td:1797
+def RISCVOverlayCall : InheritableAttr {
+  let Spellings = [GCC<"overlaycall">];
+  let Subjects = SubjectList<[Function]>;

aaron.ballman wrote:
> aaron.ballman wrote:
> > Does GCC support this attribute? If not, this should be using the `Clang` 
> > spelling (same below).
> > 
> > Also, `overlaycall` is pretty hard to read; why not `overlay_call` and 
> > `overlay_data`?
> Still wondering about the naming choice.
I'll push for an underscore in the names if we're going to have two attributes.

I'm also wondering now whether to use `overlay_function` instead of 
`overlay_call` since the attribute is marking that the function exists in an 
overlay rather than the mechanism by which it is called.



Comment at: clang/include/clang/Basic/Attr.td:1798
+  let Spellings = [GCC<"overlaycall">];
+  let Subjects = SubjectList<[Function]>;
+  let LangOpts = [RISCVOverlayFunctions];

aaron.ballman wrote:
> aaron.ballman wrote:
> > What about Objective-C methods?
> And still wondering about ObjC methods for `RISCVOverlayCallAttr`.
Would simply disallowing this attribute to be used with ObjC be acceptable 
whilst getting clarification on whether overlays should be usable from ObjC?



Comment at: clang/include/clang/Basic/AttrDocs.td:2149
+  let Content = [{
+``__attribute__((overlaycall))`` indicates that a function resides in an
+overlay and therefore any calls to or from that function must be handled

aaron.ballman wrote:
> edward-jones wrote:
> > jrtc27 wrote:
> > > Why not just a single attribute that DTRT based on the type?
> > Good point. I'll see if I can do that. The fact we used multiple attributes 
> > is mainly a consequence of how we put this together rather than any 
> > inherent technical need I think.
> I'm confused as to why this is two attributes again. I think using a single 
> attribute makes more sense if they're both documented to be exactly the same 
> thing.
> 
> Also, this is missing information about the data overlay restrictions (that 
> it be a global constant variable), and examples. Further, these docs aren't 
> really telling me why I'd use this attribute. Are there other docs we should 
> be linking to that describe what an overlay is, etc?
Would it be sufficient to document based on the restrictions defined [[ 
https://github.com/riscv-software-src/riscv-overlay/blob/master/docs/overlay-hld.adoc#2716-constraints
 | here ]]? As far as I'm aware LLVM documentation doesn't often refer out to 
external documents so I assume the attribute's documentation needs to be a 
self-contained summary?

I'm still not sure about one vs two attribute. One attribute is overall a bit 
simpler, but any diagnostics are going to need to differentiate anyway. Also, I 
wonder whether a single `overlay` attribute could confuse users if it was 
applied to a global function pointer - a naive user might think that the 
attribute applies to the type of the function rather than the Decl of the 
pointer.



Comment at: clang/lib/Sema/SemaDeclAttr.cpp:2

[PATCH] D109372: [RISCV][RFC] Add Clang support for RISC-V overlay system

2021-11-24 Thread Edward Jones via Phabricator via cfe-commits
edward-jones updated this revision to Diff 389520.

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D109372/new/

https://reviews.llvm.org/D109372

Files:
  clang/include/clang/Basic/Attr.td
  clang/include/clang/Basic/AttrDocs.td
  clang/include/clang/Basic/DiagnosticDriverKinds.td
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Basic/LangOptions.def
  clang/include/clang/Driver/Options.td
  clang/lib/CodeGen/CGCall.cpp
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/lib/Driver/ToolChains/Arch/RISCV.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Sema/SemaDecl.cpp
  clang/lib/Sema/SemaDeclAttr.cpp
  clang/test/CodeGen/riscv-overlay.c
  clang/test/Driver/riscv-overlay.c
  clang/test/Misc/pragma-attribute-supported-attributes-list.test
  clang/test/Sema/riscv-overlay-attr.c
  clang/test/Sema/riscv-overlay-namespace.cpp

Index: clang/test/Sema/riscv-overlay-namespace.cpp
===
--- /dev/null
+++ clang/test/Sema/riscv-overlay-namespace.cpp
@@ -0,0 +1,20 @@
+// RUN: %clang_cc1 %s -triple riscv32-unknown-elf -verify -fsyntax-only -moverlay
+// RUN: %clang_cc1 %s -triple riscv64-unknown-elf -verify -fsyntax-only -moverlay
+
+namespace {
+class foo {
+public:
+  static int X() __attribute__((overlay_call)) { return 0; } // expected-error {{functions marked with 'overlay_call' attribute must have external linkage}}
+};
+} // end of anonymous namespace
+
+namespace X {
+class bar {
+public:
+  static int X() __attribute__((overlay_call)) { return 1; }
+};
+} // end of namespace X
+
+extern "C" {
+int main(void) { return foo::X() + X::bar::X(); }
+}
Index: clang/test/Sema/riscv-overlay-attr.c
===
--- /dev/null
+++ clang/test/Sema/riscv-overlay-attr.c
@@ -0,0 +1,16 @@
+// RUN: %clang_cc1 -triple riscv32 -moverlay -fsyntax-only -verify %s
+// RUN: %clang_cc1 -triple riscv64 -moverlay -fsyntax-only -verify %s
+
+int notAFunction __attribute__((overlay_call));
+// expected-warning@-1 {{'overlay_call' attribute only applies to functions}}
+
+void incompatForwardDecl(int x);
+void __attribute__((overlay_call)) incompatForwardDecl(int x) {}
+// expected-error@-1 {{redeclaration of 'incompatForwardDecl' must not have the 'overlay_call' attribute}}
+// expected-note@-3 {{previous definition is here}}
+
+static void staticcall() __attribute__((overlay_call)) {}
+// expected-error@-1 {{functions marked with 'overlay_call' attribute must have external linkage}}
+
+static void __attribute__((overlay_call)) staticcall2() {}
+// expected-error@-1 {{functions marked with 'overlay_call' attribute must have external linkage}}
Index: clang/test/Misc/pragma-attribute-supported-attributes-list.test
===
--- clang/test/Misc/pragma-attribute-supported-attributes-list.test
+++ clang/test/Misc/pragma-attribute-supported-attributes-list.test
@@ -147,6 +147,7 @@
 // CHECK-NEXT: PassObjectSize (SubjectMatchRule_variable_is_parameter)
 // CHECK-NEXT: PatchableFunctionEntry (SubjectMatchRule_function, SubjectMatchRule_objc_method)
 // CHECK-NEXT: Pointer (SubjectMatchRule_record_not_is_union)
+// CHECK-NEXT: RISCVOverlayCall (SubjectMatchRule_function)
 // CHECK-NEXT: ReleaseHandle (SubjectMatchRule_variable_is_parameter)
 // CHECK-NEXT: RenderScriptKernel (SubjectMatchRule_function)
 // CHECK-NEXT: ReqdWorkGroupSize (SubjectMatchRule_function)
Index: clang/test/Driver/riscv-overlay.c
===
--- /dev/null
+++ clang/test/Driver/riscv-overlay.c
@@ -0,0 +1,5 @@
+// Check that ComRV Driver Arguments
+
+// RUN: not %clang -target riscv32 -moverlay %s -o %t.o -mabi=ilp32f 2>&1 \
+// RUN:   | FileCheck -check-prefix=INVALID-ABI %s
+// INVALID-ABI: invalid ABI 'ilp32f' when using '-moverlay'
Index: clang/test/CodeGen/riscv-overlay.c
===
--- /dev/null
+++ clang/test/CodeGen/riscv-overlay.c
@@ -0,0 +1,11 @@
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py UTC_ARGS: --check-attributes
+// RUN: %clang_cc1 -triple riscv32 -moverlay -emit-llvm %s -o - \
+// RUN:| FileCheck %s
+
+// CHECK-LABEL: @test_overlay_func(
+// CHECK-SAME: #0
+// CHECK: attributes #0 = {
+// CHECK-SAME: "overlay"
+int __attribute__((overlay_call)) test_overlay_func(void) {
+  return 5;
+}
Index: clang/lib/Sema/SemaDeclAttr.cpp
===
--- clang/lib/Sema/SemaDeclAttr.cpp
+++ clang/lib/Sema/SemaDeclAttr.cpp
@@ -2039,6 +2039,33 @@
   D->addAttr(::new (S.Context) CmseNSEntryAttr(S.Context, AL));
 }
 
+static void handleRISCVOverlayAttr(Sema &S, Decl *D, const ParsedAttr &AL) {
+  if (!S.getLangOpts().Overlay) {
+S.Diag(AL.getRange().getBegin(), diag::warn_attribute_ignored_overlay)
+<< AL;
+return;
+  }
+
+  if (isFunctionOrMethod(D)) {
+ 

[PATCH] D75061: [RISCV] Fix sysroot tests without GCC on RISC-V hosts with GCC

2020-02-25 Thread Edward Jones via Phabricator via cfe-commits
edward-jones accepted this revision.
edward-jones added a comment.
This revision is now accepted and ready to land.

Looks good to me. Clang tests all pass on my local build.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D75061/new/

https://reviews.llvm.org/D75061



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D68391: [RISCV] Improve sysroot computation if no GCC install detected

2019-11-04 Thread Edward Jones via Phabricator via cfe-commits
edward-jones updated this revision to Diff 227721.
edward-jones added a comment.

Rebased, added a comment to explain that this is using the user provided triple 
instead of the canonical one, and split out the tests requiring a shell into 
separate files (clang/test/Driver/riscv{32,64}-toolchain-extra.c)


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D68391/new/

https://reviews.llvm.org/D68391

Files:
  clang/lib/Driver/ToolChains/RISCVToolchain.cpp
  clang/test/Driver/Inputs/basic_riscv32_nogcc_tree/bin/riscv32-unknown-elf-ld
  
clang/test/Driver/Inputs/basic_riscv32_nogcc_tree/riscv32-unknown-elf/lib/crt0.o
  
clang/test/Driver/Inputs/basic_riscv32_nogcc_tree/riscv32-unknown-elf/lib/crtbegin.o
  
clang/test/Driver/Inputs/basic_riscv32_nogcc_tree/riscv32-unknown-elf/lib/crtend.o
  clang/test/Driver/Inputs/basic_riscv64_nogcc_tree/bin/riscv64-unknown-elf-ld
  
clang/test/Driver/Inputs/basic_riscv64_nogcc_tree/riscv64-unknown-elf/lib/crt0.o
  
clang/test/Driver/Inputs/basic_riscv64_nogcc_tree/riscv64-unknown-elf/lib/crtbegin.o
  
clang/test/Driver/Inputs/basic_riscv64_nogcc_tree/riscv64-unknown-elf/lib/crtend.o
  clang/test/Driver/riscv32-toolchain-extra.c
  clang/test/Driver/riscv64-toolchain-extra.c

Index: clang/test/Driver/riscv64-toolchain-extra.c
===
--- /dev/null
+++ clang/test/Driver/riscv64-toolchain-extra.c
@@ -0,0 +1,33 @@
+// A basic clang -cc1 command-line, and simple environment check.
+
+// The tests here are similar to those in riscv64-toolchain.c, however
+// these tests need to create symlinks to test directory trees in order to
+// set up the environment and therefore shell support is required.
+// REQUIRES: shell
+// UNSUPPORTED: system-windows
+
+// If there is no GCC install detected then the driver searches for executables
+// and runtime starting from the directory tree above the driver itself.
+// The test below checks that the driver correctly finds the linker and
+// runtime if and only if they exist.
+//
+// RUN: mkdir -p %T/testroot-riscv64-baremetal-nogcc/bin
+// RUN: [ ! -s %T/testroot-riscv64-baremetal-nogcc/bin/clang ] || rm %T/testroot-riscv64-baremetal-nogcc/bin/clang
+// RUN: [ ! -s %T/testroot-riscv64-baremetal-nogcc/bin/riscv64-unknown-elf-ld ] || rm %T/testroot-riscv64-baremetal-nogcc/bin/riscv64-unknown-elf-ld
+// RUN: [ ! -s %T/testroot-riscv64-baremetal-nogcc/riscv64-unknown-elf ] || rm %T/testroot-riscv64-baremetal-nogcc/riscv64-unknown-elf
+// RUN: ln -s %clang %T/testroot-riscv64-baremetal-nogcc/bin/clang
+// RUN: ln -s %S/Inputs/basic_riscv64_nogcc_tree/bin/riscv64-unknown-elf-ld %T/testroot-riscv64-baremetal-nogcc/bin/riscv64-unknown-elf-ld
+// RUN: ln -s %S/Inputs/basic_riscv64_nogcc_tree/riscv64-unknown-elf %T/testroot-riscv64-baremetal-nogcc/riscv64-unknown-elf
+// RUN: %T/testroot-riscv64-baremetal-nogcc/bin/clang %s -### -no-canonical-prefixes \
+// RUN:-target riscv64-unknown-elf 2>&1 \
+// RUN:| FileCheck -check-prefix=C-RV64-BAREMETAL-LP64-NOGCC %s
+
+// C-RV64-BAREMETAL-LP64-NOGCC: InstalledDir: [[DRIVERDIR:.*]]
+// C-RV64-BAREMETAL-LP64-NOGCC: "-fuse-init-array"
+// C-RV64-BAREMETAL-LP64-NOGCC: "-internal-isystem" "[[DRIVERDIR]]/../riscv64-unknown-elf/include"
+// C-RV64-BAREMETAL-LP64-NOGCC: "[[DRIVERDIR]]/riscv64-unknown-elf-ld"
+// C-RV64-BAREMETAL-LP64-NOGCC: "[[DRIVERDIR]]/../riscv64-unknown-elf/lib/crt0.o"
+// C-RV64-BAREMETAL-LP64-NOGCC: "[[DRIVERDIR]]/../riscv64-unknown-elf/lib/crtbegin.o"
+// C-RV64-BAREMETAL-LP64-NOGCC: "-L[[DRIVERDIR]]/../riscv64-unknown-elf/lib"
+// C-RV64-BAREMETAL-LP64-NOGCC: "--start-group" "-lc" "-lgloss" "--end-group" "-lgcc"
+// C-RV64-BAREMETAL-LP64-NOGCC: "[[DRIVERDIR]]/../riscv64-unknown-elf/lib/crtend.o"
Index: clang/test/Driver/riscv32-toolchain-extra.c
===
--- /dev/null
+++ clang/test/Driver/riscv32-toolchain-extra.c
@@ -0,0 +1,33 @@
+// A basic clang -cc1 command-line, and simple environment check.
+
+// The tests here are similar to those in riscv32-toolchain.c, however
+// these tests need to create symlinks to test directory trees in order to
+// set up the environment and therefore shell support is required.
+// REQUIRES: shell
+// UNSUPPORTED: system-windows
+
+// If there is no GCC install detected then the driver searches for executables
+// and runtime starting from the directory tree above the driver itself.
+// The test below checks that the driver correctly finds the linker and
+// runtime if and only if they exist.
+//
+// RUN: mkdir -p %T/testroot-riscv32-baremetal-nogcc/bin
+// RUN: [ ! -s %T/testroot-riscv32-baremetal-nogcc/bin/clang ] || rm %T/testroot-riscv32-baremetal-nogcc/bin/clang
+// RUN: [ ! -s %T/testroot-riscv32-baremetal-nogcc/bin/riscv32-unknown-elf-ld ] || rm %T/testroot-riscv32-baremetal-nogcc/bin/riscv32-unknown-elf-ld
+// RUN: [ ! -s %T/testroot-riscv32-baremetal-nogcc/riscv32-unknown-elf ] || rm %T/testroot-riscv32-baremetal-nogcc/risc

[PATCH] D68407: [WIP][RISCV] Use compiler-rt if no GCC installation detected

2019-11-04 Thread Edward Jones via Phabricator via cfe-commits
edward-jones updated this revision to Diff 227722.
edward-jones retitled this revision from "[RISCV] Use compiler-rt if no GCC 
installation detected" to "[WIP][RISCV] Use compiler-rt if no GCC installation 
detected".
edward-jones edited the summary of this revision.
edward-jones added a comment.
Herald added a subscriber: sameer.abuasal.

I've rebased, and also refactored this to use `AddRunTimeLibs` and 
`GetDefaultRuntimeLibType`. The tests have been updated to reflect the changes. 
Notable changes compared to the last version of the patch:

- `AddRunTimeLibs` causes `-lgcc_s` to also be added to the linker command 
alongside `-lgcc`. It seems that this is added as part of `AddUnwindLibrary` in 
`clang/lib/Driver/ToolChains/CommonArgs.cpp`. Based on the comments for that 
function, I would expect to get either `-lgcc_s -lgcc` or `-lgcc -lgcc_eh` on 
the linker command depending on the type of unwinding supported, but this 
doesn't match the existing behaviour of the RISC-V driver (hence this patch 
breaks tests), nor does it match the behaviour of RISC-V gcc.
- The search for compiler-rt no longer looks in `//lib` for the 
runtime libraries. It instead looks in the resource directory 
`/lib/clang//lib`. This seems to be more correct; out-of-tree 
compiler-rt builds just need to make sure to set the install prefix to the 
result of `clang -print-resource-dir`.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D68407/new/

https://reviews.llvm.org/D68407

Files:
  clang/lib/Driver/ToolChains/RISCVToolchain.cpp
  clang/lib/Driver/ToolChains/RISCVToolchain.h
  
clang/test/Driver/Inputs/basic_riscv32_nogcc_tree/riscv32-unknown-elf/lib/crtbegin.o
  
clang/test/Driver/Inputs/basic_riscv32_nogcc_tree/riscv32-unknown-elf/lib/crtend.o
  
clang/test/Driver/Inputs/basic_riscv64_nogcc_tree/riscv64-unknown-elf/lib/crtbegin.o
  
clang/test/Driver/Inputs/basic_riscv64_nogcc_tree/riscv64-unknown-elf/lib/crtend.o
  clang/test/Driver/riscv32-toolchain-extra.c
  clang/test/Driver/riscv64-toolchain-extra.c

Index: clang/test/Driver/riscv64-toolchain-extra.c
===
--- clang/test/Driver/riscv64-toolchain-extra.c
+++ clang/test/Driver/riscv64-toolchain-extra.c
@@ -22,12 +22,12 @@
 // RUN:-target riscv64-unknown-elf 2>&1 \
 // RUN:| FileCheck -check-prefix=C-RV64-BAREMETAL-LP64-NOGCC %s
 
-// C-RV64-BAREMETAL-LP64-NOGCC: InstalledDir: [[DRIVERDIR:.*]]
 // C-RV64-BAREMETAL-LP64-NOGCC: "-fuse-init-array"
-// C-RV64-BAREMETAL-LP64-NOGCC: "-internal-isystem" "[[DRIVERDIR]]/../riscv64-unknown-elf/include"
-// C-RV64-BAREMETAL-LP64-NOGCC: "[[DRIVERDIR]]/riscv64-unknown-elf-ld"
-// C-RV64-BAREMETAL-LP64-NOGCC: "[[DRIVERDIR]]/../riscv64-unknown-elf/lib/crt0.o"
-// C-RV64-BAREMETAL-LP64-NOGCC: "[[DRIVERDIR]]/../riscv64-unknown-elf/lib/crtbegin.o"
-// C-RV64-BAREMETAL-LP64-NOGCC: "-L[[DRIVERDIR]]/../riscv64-unknown-elf/lib"
-// C-RV64-BAREMETAL-LP64-NOGCC: "--start-group" "-lc" "-lgloss" "--end-group" "-lgcc"
-// C-RV64-BAREMETAL-LP64-NOGCC: "[[DRIVERDIR]]/../riscv64-unknown-elf/lib/crtend.o"
+// C-RV64-BAREMETAL-LP64-NOGCC: "-internal-isystem" "{{.*}}Output/testroot-riscv64-baremetal-nogcc/bin/../riscv64-unknown-elf/include"
+// C-RV64-BAREMETAL-LP64-NOGCC: "{{.*}}Output/testroot-riscv64-baremetal-nogcc/bin/riscv64-unknown-elf-ld"
+// C-RV64-BAREMETAL-LP64-NOGCC: "{{.*}}Output/testroot-riscv64-baremetal-nogcc/bin/../riscv64-unknown-elf/lib/crt0.o"
+// C-RV64-BAREMETAL-LP64-NOGCC: "{{.*}}Output/testroot-riscv64-baremetal-nogcc/lib/clang/{{[0-9.]*}}/lib/clang_rt.crtbegin-riscv64.o"
+// C-RV64-BAREMETAL-LP64-NOGCC: "{{.*}}Output/testroot-riscv64-baremetal-nogcc/bin/../riscv64-unknown-elf/lib"
+// C-RV64-BAREMETAL-LP64-NOGCC: "--start-group" "-lc" "-lgloss" "--end-group"
+// C-RV64-BAREMETAL-LP64-NOGCC: "{{.*}}Output/testroot-riscv64-baremetal-nogcc/lib/clang/{{[0-9.]*}}/lib/libclang_rt.builtins-riscv64.a"
+// C-RV64-BAREMETAL-LP64-NOGCC: "{{.*}}Output/testroot-riscv64-baremetal-nogcc/lib/clang/{{[0-9.]*}}/lib/clang_rt.crtend-riscv64.o"
Index: clang/test/Driver/riscv32-toolchain-extra.c
===
--- clang/test/Driver/riscv32-toolchain-extra.c
+++ clang/test/Driver/riscv32-toolchain-extra.c
@@ -22,12 +22,12 @@
 // RUN:-target riscv32-unknown-elf 2>&1 \
 // RUN:| FileCheck -check-prefix=C-RV32-BAREMETAL-ILP32-NOGCC %s
 
-// C-RV32-BAREMETAL-ILP32-NOGCC: InstalledDir: [[DRIVERDIR:.*]]
 // C-RV32-BAREMETAL-ILP32-NOGCC: "-fuse-init-array"
-// C-RV32-BAREMETAL-ILP32-NOGCC: "-internal-isystem" "[[DRIVERDIR]]/../riscv32-unknown-elf/include"
-// C-RV32-BAREMETAL-ILP32-NOGCC: "[[DRIVERDIR]]/riscv32-unknown-elf-ld"
-// C-RV32-BAREMETAL-ILP32-NOGCC: "[[DRIVERDIR]]/../riscv32-unknown-elf/lib/crt0.o"
-// C-RV32-BAREMETAL-ILP32-NOGCC: "[[DRIVERDIR]]/../riscv32-unknown-elf/lib/crtbegin.o"
-// C-RV32-BAREMETAL-ILP32-NOGCC: "-L[[DRIVERDIR]]/../riscv32-unknown-elf/lib"
-// C-RV32-BAREMETAL-ILP32-NOGCC: "--start-group" 

[PATCH] D68407: [WIP][RISCV] Use compiler-rt if no GCC installation detected

2019-11-04 Thread Edward Jones via Phabricator via cfe-commits
edward-jones added a comment.

In D68407#1709235 , @lenary wrote:

> Please can you add a test for riscv32 and riscv64 without libgcc?


I'm not sure what you mean here; I believe the existing tests already cover 
riscv{32,64} without libgcc.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D68407/new/

https://reviews.llvm.org/D68407



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D68391: [RISCV] Improve sysroot computation if no GCC install detected

2019-11-07 Thread Edward Jones via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGde61aa3118b9: [RISCV] Improve sysroot computation if no GCC 
install detected (authored by edward-jones).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D68391/new/

https://reviews.llvm.org/D68391

Files:
  clang/lib/Driver/ToolChains/RISCVToolchain.cpp
  clang/test/Driver/Inputs/basic_riscv32_nogcc_tree/bin/riscv32-unknown-elf-ld
  
clang/test/Driver/Inputs/basic_riscv32_nogcc_tree/riscv32-unknown-elf/lib/crt0.o
  
clang/test/Driver/Inputs/basic_riscv32_nogcc_tree/riscv32-unknown-elf/lib/crtbegin.o
  
clang/test/Driver/Inputs/basic_riscv32_nogcc_tree/riscv32-unknown-elf/lib/crtend.o
  clang/test/Driver/Inputs/basic_riscv64_nogcc_tree/bin/riscv64-unknown-elf-ld
  
clang/test/Driver/Inputs/basic_riscv64_nogcc_tree/riscv64-unknown-elf/lib/crt0.o
  
clang/test/Driver/Inputs/basic_riscv64_nogcc_tree/riscv64-unknown-elf/lib/crtbegin.o
  
clang/test/Driver/Inputs/basic_riscv64_nogcc_tree/riscv64-unknown-elf/lib/crtend.o
  clang/test/Driver/riscv32-toolchain-extra.c
  clang/test/Driver/riscv64-toolchain-extra.c

Index: clang/test/Driver/riscv64-toolchain-extra.c
===
--- /dev/null
+++ clang/test/Driver/riscv64-toolchain-extra.c
@@ -0,0 +1,33 @@
+// A basic clang -cc1 command-line, and simple environment check.
+
+// The tests here are similar to those in riscv64-toolchain.c, however
+// these tests need to create symlinks to test directory trees in order to
+// set up the environment and therefore shell support is required.
+// REQUIRES: shell
+// UNSUPPORTED: system-windows
+
+// If there is no GCC install detected then the driver searches for executables
+// and runtime starting from the directory tree above the driver itself.
+// The test below checks that the driver correctly finds the linker and
+// runtime if and only if they exist.
+//
+// RUN: mkdir -p %T/testroot-riscv64-baremetal-nogcc/bin
+// RUN: [ ! -s %T/testroot-riscv64-baremetal-nogcc/bin/clang ] || rm %T/testroot-riscv64-baremetal-nogcc/bin/clang
+// RUN: [ ! -s %T/testroot-riscv64-baremetal-nogcc/bin/riscv64-unknown-elf-ld ] || rm %T/testroot-riscv64-baremetal-nogcc/bin/riscv64-unknown-elf-ld
+// RUN: [ ! -s %T/testroot-riscv64-baremetal-nogcc/riscv64-unknown-elf ] || rm %T/testroot-riscv64-baremetal-nogcc/riscv64-unknown-elf
+// RUN: ln -s %clang %T/testroot-riscv64-baremetal-nogcc/bin/clang
+// RUN: ln -s %S/Inputs/basic_riscv64_nogcc_tree/bin/riscv64-unknown-elf-ld %T/testroot-riscv64-baremetal-nogcc/bin/riscv64-unknown-elf-ld
+// RUN: ln -s %S/Inputs/basic_riscv64_nogcc_tree/riscv64-unknown-elf %T/testroot-riscv64-baremetal-nogcc/riscv64-unknown-elf
+// RUN: %T/testroot-riscv64-baremetal-nogcc/bin/clang %s -### -no-canonical-prefixes \
+// RUN:-target riscv64-unknown-elf 2>&1 \
+// RUN:| FileCheck -check-prefix=C-RV64-BAREMETAL-LP64-NOGCC %s
+
+// C-RV64-BAREMETAL-LP64-NOGCC: InstalledDir: [[DRIVERDIR:.*]]
+// C-RV64-BAREMETAL-LP64-NOGCC: "-fuse-init-array"
+// C-RV64-BAREMETAL-LP64-NOGCC: "-internal-isystem" "[[DRIVERDIR]]/../riscv64-unknown-elf/include"
+// C-RV64-BAREMETAL-LP64-NOGCC: "[[DRIVERDIR]]/riscv64-unknown-elf-ld"
+// C-RV64-BAREMETAL-LP64-NOGCC: "[[DRIVERDIR]]/../riscv64-unknown-elf/lib/crt0.o"
+// C-RV64-BAREMETAL-LP64-NOGCC: "[[DRIVERDIR]]/../riscv64-unknown-elf/lib/crtbegin.o"
+// C-RV64-BAREMETAL-LP64-NOGCC: "-L[[DRIVERDIR]]/../riscv64-unknown-elf/lib"
+// C-RV64-BAREMETAL-LP64-NOGCC: "--start-group" "-lc" "-lgloss" "--end-group" "-lgcc"
+// C-RV64-BAREMETAL-LP64-NOGCC: "[[DRIVERDIR]]/../riscv64-unknown-elf/lib/crtend.o"
Index: clang/test/Driver/riscv32-toolchain-extra.c
===
--- /dev/null
+++ clang/test/Driver/riscv32-toolchain-extra.c
@@ -0,0 +1,33 @@
+// A basic clang -cc1 command-line, and simple environment check.
+
+// The tests here are similar to those in riscv32-toolchain.c, however
+// these tests need to create symlinks to test directory trees in order to
+// set up the environment and therefore shell support is required.
+// REQUIRES: shell
+// UNSUPPORTED: system-windows
+
+// If there is no GCC install detected then the driver searches for executables
+// and runtime starting from the directory tree above the driver itself.
+// The test below checks that the driver correctly finds the linker and
+// runtime if and only if they exist.
+//
+// RUN: mkdir -p %T/testroot-riscv32-baremetal-nogcc/bin
+// RUN: [ ! -s %T/testroot-riscv32-baremetal-nogcc/bin/clang ] || rm %T/testroot-riscv32-baremetal-nogcc/bin/clang
+// RUN: [ ! -s %T/testroot-riscv32-baremetal-nogcc/bin/riscv32-unknown-elf-ld ] || rm %T/testroot-riscv32-baremetal-nogcc/bin/riscv32-unknown-elf-ld
+// RUN: [ ! -s %T/testroot-riscv32-baremetal-nogcc/riscv32-unknown-elf ] || rm %T/testroot-riscv32-baremetal-nogcc/riscv32-unknown-elf
+// RUN: ln -s %clang %T/testroot-riscv32-baremetal-no

[PATCH] D58896: Suppress -Wchar-subscripts if the index is a literal char

2019-11-07 Thread Edward Jones via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG7adab7719e55: [Sema] Suppress -Wchar-subscripts if the index 
is a literal char (authored by edward-jones).
Herald added a subscriber: simoncook.

Changed prior to commit:
  https://reviews.llvm.org/D58896?vs=189127&id=228249#toc

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D58896/new/

https://reviews.llvm.org/D58896

Files:
  clang/lib/Sema/SemaExpr.cpp
  clang/test/SemaCXX/warn-char-subscripts.cpp


Index: clang/test/SemaCXX/warn-char-subscripts.cpp
===
--- clang/test/SemaCXX/warn-char-subscripts.cpp
+++ clang/test/SemaCXX/warn-char-subscripts.cpp
@@ -14,6 +14,19 @@
   int val = subscript[array]; // expected-warning{{array subscript is of type 
'char'}}
 }
 
+void t3() {
+  int array[50] = { 0 };
+  int val = array[' ']; // no warning, subscript is a literal
+}
+void t4() {
+  int array[50] = { 0 };
+  int val = '('[array]; // no warning, subscript is a literal
+}
+void t5() {
+  int array[50] = { 0 };
+  int val = array['\x11']; // no warning, subscript is a literal
+}
+
 void test() {
   t1(); // expected-note {{in instantiation of function template 
specialization 't1' requested here}}
   t2(); // expected-note {{in instantiation of function template 
specialization 't2' requested here}}
Index: clang/lib/Sema/SemaExpr.cpp
===
--- clang/lib/Sema/SemaExpr.cpp
+++ clang/lib/Sema/SemaExpr.cpp
@@ -4741,7 +4741,8 @@
 
   if ((IndexExpr->getType()->isSpecificBuiltinType(BuiltinType::Char_S) ||
IndexExpr->getType()->isSpecificBuiltinType(BuiltinType::Char_U))
- && !IndexExpr->isTypeDependent())
+ && !IndexExpr->isTypeDependent()
+ && !isa(IndexExpr))
 Diag(LLoc, diag::warn_subscript_is_char) << IndexExpr->getSourceRange();
 
   // C99 6.5.2.1p1: "shall have type "pointer to *object* type". Similarly,


Index: clang/test/SemaCXX/warn-char-subscripts.cpp
===
--- clang/test/SemaCXX/warn-char-subscripts.cpp
+++ clang/test/SemaCXX/warn-char-subscripts.cpp
@@ -14,6 +14,19 @@
   int val = subscript[array]; // expected-warning{{array subscript is of type 'char'}}
 }
 
+void t3() {
+  int array[50] = { 0 };
+  int val = array[' ']; // no warning, subscript is a literal
+}
+void t4() {
+  int array[50] = { 0 };
+  int val = '('[array]; // no warning, subscript is a literal
+}
+void t5() {
+  int array[50] = { 0 };
+  int val = array['\x11']; // no warning, subscript is a literal
+}
+
 void test() {
   t1(); // expected-note {{in instantiation of function template specialization 't1' requested here}}
   t2(); // expected-note {{in instantiation of function template specialization 't2' requested here}}
Index: clang/lib/Sema/SemaExpr.cpp
===
--- clang/lib/Sema/SemaExpr.cpp
+++ clang/lib/Sema/SemaExpr.cpp
@@ -4741,7 +4741,8 @@
 
   if ((IndexExpr->getType()->isSpecificBuiltinType(BuiltinType::Char_S) ||
IndexExpr->getType()->isSpecificBuiltinType(BuiltinType::Char_U))
- && !IndexExpr->isTypeDependent())
+ && !IndexExpr->isTypeDependent()
+ && !isa(IndexExpr))
 Diag(LLoc, diag::warn_subscript_is_char) << IndexExpr->getSourceRange();
 
   // C99 6.5.2.1p1: "shall have type "pointer to *object* type". Similarly,
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D68407: [WIP][RISCV] Use compiler-rt if no GCC installation detected

2019-11-07 Thread Edward Jones via Phabricator via cfe-commits
edward-jones added a comment.

In D68407#1732685 , @lenary wrote:

> This patch is looking much better, thanks for updating it.
>
> Please may you clarify what RISC-V gcc does for `-lgcc`, `-lgcc_s`, 
> `-lgcc_eh`? Is it different to what gcc does on other targets? Being closer 
> to matching the linker arguments that gcc provides to ld seems like a good 
> idea, IMO.


The default behaviour on RISC-V GCC is just `-lgcc`, however for Clang if I 
call `tools::AddRunTimeLibs` then by default I get `-lgcc --as-needed -lgcc_s 
--no-as-needed` in the link step.

When libgcc is needed `tools::AddRunTimeLibs` unconditionally calls 
`AddUnwindLibrary`, which in turn calls `ToolChain::GetUnwindLibType` which 
always returns `ToolChain::UNW_Libgcc` for libgcc. The code in 
`AddUnwindLibrary` will then always add either `-lgcc_eh` (for a static 
libgcc), or `-lgcc_s` (for a shared libgcc) to the command line. I can override 
this by reimplementing `ToolChain::GetUnwindLibType` in the target and making 
it return `ToolChain::UNW_None`, but I'm not sure whether that's the desired 
behavior.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D68407/new/

https://reviews.llvm.org/D68407



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D58896: Suppress -Wchar-subscripts if the index is a literal char

2019-11-07 Thread Edward Jones via Phabricator via cfe-commits
edward-jones added a comment.

In D58896#1737113 , @sberg wrote:

> But how about literals like `'\x80'` where the promoted value depends on 
> whether plain `char` is signed or unsigned?


If 'char' is signed and index into an array then this will typically trigger an 
`-Warray-bounds` warning because it references before the start of the array.

In D58896#1737200 , @xbolva00 wrote:

> Well, i am not sure if one twitter report is good motivation to criple 
> warning.


The motivation for suppressing the warning was that it is not uncommon to use a 
character literal in lookup tables. In addition in brings the warning inline 
with the behaviour of `-Wchar-subscripts` in GCC.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D58896/new/

https://reviews.llvm.org/D58896



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D68407: [WIP][RISCV] Use compiler-rt if no GCC installation detected

2019-11-07 Thread Edward Jones via Phabricator via cfe-commits
edward-jones updated this revision to Diff 228268.
edward-jones added a comment.

I've changed this to always return `ToolChain::UNW_None` from 
`RISCVToolChain::GetUnwindLibType` now. As a consequence we get the original 
behaviour of only `-lgcc` being added to the link command.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D68407/new/

https://reviews.llvm.org/D68407

Files:
  clang/lib/Driver/ToolChains/RISCVToolchain.cpp
  clang/lib/Driver/ToolChains/RISCVToolchain.h
  
clang/test/Driver/Inputs/basic_riscv32_nogcc_tree/riscv32-unknown-elf/lib/crtbegin.o
  
clang/test/Driver/Inputs/basic_riscv32_nogcc_tree/riscv32-unknown-elf/lib/crtend.o
  
clang/test/Driver/Inputs/basic_riscv64_nogcc_tree/riscv64-unknown-elf/lib/crtbegin.o
  
clang/test/Driver/Inputs/basic_riscv64_nogcc_tree/riscv64-unknown-elf/lib/crtend.o
  clang/test/Driver/riscv32-toolchain-extra.c
  clang/test/Driver/riscv64-toolchain-extra.c

Index: clang/test/Driver/riscv64-toolchain-extra.c
===
--- clang/test/Driver/riscv64-toolchain-extra.c
+++ clang/test/Driver/riscv64-toolchain-extra.c
@@ -22,12 +22,12 @@
 // RUN:-target riscv64-unknown-elf 2>&1 \
 // RUN:| FileCheck -check-prefix=C-RV64-BAREMETAL-LP64-NOGCC %s
 
-// C-RV64-BAREMETAL-LP64-NOGCC: InstalledDir: [[DRIVERDIR:.*]]
 // C-RV64-BAREMETAL-LP64-NOGCC: "-fuse-init-array"
-// C-RV64-BAREMETAL-LP64-NOGCC: "-internal-isystem" "[[DRIVERDIR]]/../riscv64-unknown-elf/include"
-// C-RV64-BAREMETAL-LP64-NOGCC: "[[DRIVERDIR]]/riscv64-unknown-elf-ld"
-// C-RV64-BAREMETAL-LP64-NOGCC: "[[DRIVERDIR]]/../riscv64-unknown-elf/lib/crt0.o"
-// C-RV64-BAREMETAL-LP64-NOGCC: "[[DRIVERDIR]]/../riscv64-unknown-elf/lib/crtbegin.o"
-// C-RV64-BAREMETAL-LP64-NOGCC: "-L[[DRIVERDIR]]/../riscv64-unknown-elf/lib"
-// C-RV64-BAREMETAL-LP64-NOGCC: "--start-group" "-lc" "-lgloss" "--end-group" "-lgcc"
-// C-RV64-BAREMETAL-LP64-NOGCC: "[[DRIVERDIR]]/../riscv64-unknown-elf/lib/crtend.o"
+// C-RV64-BAREMETAL-LP64-NOGCC: "-internal-isystem" "{{.*}}Output/testroot-riscv64-baremetal-nogcc/bin/../riscv64-unknown-elf/include"
+// C-RV64-BAREMETAL-LP64-NOGCC: "{{.*}}Output/testroot-riscv64-baremetal-nogcc/bin/riscv64-unknown-elf-ld"
+// C-RV64-BAREMETAL-LP64-NOGCC: "{{.*}}Output/testroot-riscv64-baremetal-nogcc/bin/../riscv64-unknown-elf/lib/crt0.o"
+// C-RV64-BAREMETAL-LP64-NOGCC: "{{.*}}Output/testroot-riscv64-baremetal-nogcc/lib/clang/{{[0-9.]*}}/lib/clang_rt.crtbegin-riscv64.o"
+// C-RV64-BAREMETAL-LP64-NOGCC: "{{.*}}Output/testroot-riscv64-baremetal-nogcc/bin/../riscv64-unknown-elf/lib"
+// C-RV64-BAREMETAL-LP64-NOGCC: "--start-group" "-lc" "-lgloss" "--end-group"
+// C-RV64-BAREMETAL-LP64-NOGCC: "{{.*}}Output/testroot-riscv64-baremetal-nogcc/lib/clang/{{[0-9.]*}}/lib/libclang_rt.builtins-riscv64.a"
+// C-RV64-BAREMETAL-LP64-NOGCC: "{{.*}}Output/testroot-riscv64-baremetal-nogcc/lib/clang/{{[0-9.]*}}/lib/clang_rt.crtend-riscv64.o"
Index: clang/test/Driver/riscv32-toolchain-extra.c
===
--- clang/test/Driver/riscv32-toolchain-extra.c
+++ clang/test/Driver/riscv32-toolchain-extra.c
@@ -22,12 +22,12 @@
 // RUN:-target riscv32-unknown-elf 2>&1 \
 // RUN:| FileCheck -check-prefix=C-RV32-BAREMETAL-ILP32-NOGCC %s
 
-// C-RV32-BAREMETAL-ILP32-NOGCC: InstalledDir: [[DRIVERDIR:.*]]
 // C-RV32-BAREMETAL-ILP32-NOGCC: "-fuse-init-array"
-// C-RV32-BAREMETAL-ILP32-NOGCC: "-internal-isystem" "[[DRIVERDIR]]/../riscv32-unknown-elf/include"
-// C-RV32-BAREMETAL-ILP32-NOGCC: "[[DRIVERDIR]]/riscv32-unknown-elf-ld"
-// C-RV32-BAREMETAL-ILP32-NOGCC: "[[DRIVERDIR]]/../riscv32-unknown-elf/lib/crt0.o"
-// C-RV32-BAREMETAL-ILP32-NOGCC: "[[DRIVERDIR]]/../riscv32-unknown-elf/lib/crtbegin.o"
-// C-RV32-BAREMETAL-ILP32-NOGCC: "-L[[DRIVERDIR]]/../riscv32-unknown-elf/lib"
-// C-RV32-BAREMETAL-ILP32-NOGCC: "--start-group" "-lc" "-lgloss" "--end-group" "-lgcc"
-// C-RV32-BAREMETAL-ILP32-NOGCC: "[[DRIVERDIR]]/../riscv32-unknown-elf/lib/crtend.o"
+// C-RV32-BAREMETAL-ILP32-NOGCC: "-internal-isystem" "{{.*}}Output/testroot-riscv32-baremetal-nogcc/bin/../riscv32-unknown-elf/include"
+// C-RV32-BAREMETAL-ILP32-NOGCC: "{{.*}}Output/testroot-riscv32-baremetal-nogcc/bin/riscv32-unknown-elf-ld"
+// C-RV32-BAREMETAL-ILP32-NOGCC: "{{.*}}Output/testroot-riscv32-baremetal-nogcc/bin/../riscv32-unknown-elf/lib/crt0.o"
+// C-RV32-BAREMETAL-ILP32-NOGCC: "{{.*}}Output/testroot-riscv32-baremetal-nogcc/lib/clang/{{[0-9.]*}}/lib/clang_rt.crtbegin-riscv32.o"
+// C-RV32-BAREMETAL-ILP32-NOGCC: "{{.*}}Output/testroot-riscv32-baremetal-nogcc/bin/../riscv32-unknown-elf/lib"
+// C-RV32-BAREMETAL-ILP32-NOGCC: "--start-group" "-lc" "-lgloss" "--end-group"
+// C-RV32-BAREMETAL-ILP32-NOGCC: "{{.*}}Output/testroot-riscv32-baremetal-nogcc/lib/clang/{{[0-9.]*}}/lib/libclang_rt.builtins-riscv32.a"
+// C-RV32-BAREMETAL-ILP32-NOGCC: "{{.*}}Output/testroot-riscv32-baremetal-nogcc/lib/clang/{{[0-9.]*}}/lib/clang_rt.crtend-riscv32.o"
Index: clang

[PATCH] D58896: Suppress -Wchar-subscripts if the index is a literal char

2019-11-07 Thread Edward Jones via Phabricator via cfe-commits
edward-jones added a comment.

Okay I've reverted this in rG90ecfa2f5f7f 
 . I'll 
make improvements and resubmit this for review.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D58896/new/

https://reviews.llvm.org/D58896



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D68407: [WIP][RISCV] Use compiler-rt if no GCC installation detected

2019-11-13 Thread Edward Jones via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG3289352e6bb9: [RISCV] Use compiler-rt if no GCC installation 
detected (authored by edward-jones).

Changed prior to commit:
  https://reviews.llvm.org/D68407?vs=228268&id=229121#toc

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D68407/new/

https://reviews.llvm.org/D68407

Files:
  clang/lib/Driver/ToolChains/RISCVToolchain.cpp
  clang/lib/Driver/ToolChains/RISCVToolchain.h
  
clang/test/Driver/Inputs/basic_riscv32_nogcc_tree/riscv32-unknown-elf/lib/crtbegin.o
  
clang/test/Driver/Inputs/basic_riscv32_nogcc_tree/riscv32-unknown-elf/lib/crtend.o
  
clang/test/Driver/Inputs/basic_riscv64_nogcc_tree/riscv64-unknown-elf/lib/crtbegin.o
  
clang/test/Driver/Inputs/basic_riscv64_nogcc_tree/riscv64-unknown-elf/lib/crtend.o
  clang/test/Driver/riscv32-toolchain-extra.c
  clang/test/Driver/riscv64-toolchain-extra.c

Index: clang/test/Driver/riscv64-toolchain-extra.c
===
--- clang/test/Driver/riscv64-toolchain-extra.c
+++ clang/test/Driver/riscv64-toolchain-extra.c
@@ -22,12 +22,12 @@
 // RUN:-target riscv64-unknown-elf 2>&1 \
 // RUN:| FileCheck -check-prefix=C-RV64-BAREMETAL-LP64-NOGCC %s
 
-// C-RV64-BAREMETAL-LP64-NOGCC: InstalledDir: [[DRIVERDIR:.*]]
 // C-RV64-BAREMETAL-LP64-NOGCC: "-fuse-init-array"
-// C-RV64-BAREMETAL-LP64-NOGCC: "-internal-isystem" "[[DRIVERDIR]]/../riscv64-unknown-elf/include"
-// C-RV64-BAREMETAL-LP64-NOGCC: "[[DRIVERDIR]]/riscv64-unknown-elf-ld"
-// C-RV64-BAREMETAL-LP64-NOGCC: "[[DRIVERDIR]]/../riscv64-unknown-elf/lib/crt0.o"
-// C-RV64-BAREMETAL-LP64-NOGCC: "[[DRIVERDIR]]/../riscv64-unknown-elf/lib/crtbegin.o"
-// C-RV64-BAREMETAL-LP64-NOGCC: "-L[[DRIVERDIR]]/../riscv64-unknown-elf/lib"
-// C-RV64-BAREMETAL-LP64-NOGCC: "--start-group" "-lc" "-lgloss" "--end-group" "-lgcc"
-// C-RV64-BAREMETAL-LP64-NOGCC: "[[DRIVERDIR]]/../riscv64-unknown-elf/lib/crtend.o"
+// C-RV64-BAREMETAL-LP64-NOGCC: "-internal-isystem" "{{.*}}Output/testroot-riscv64-baremetal-nogcc/bin/../riscv64-unknown-elf/include"
+// C-RV64-BAREMETAL-LP64-NOGCC: "{{.*}}Output/testroot-riscv64-baremetal-nogcc/bin/riscv64-unknown-elf-ld"
+// C-RV64-BAREMETAL-LP64-NOGCC: "{{.*}}Output/testroot-riscv64-baremetal-nogcc/bin/../riscv64-unknown-elf/lib/crt0.o"
+// C-RV64-BAREMETAL-LP64-NOGCC: "{{.*}}Output/testroot-riscv64-baremetal-nogcc/lib/clang/{{[0-9.]*}}/lib/clang_rt.crtbegin-riscv64.o"
+// C-RV64-BAREMETAL-LP64-NOGCC: "{{.*}}Output/testroot-riscv64-baremetal-nogcc/bin/../riscv64-unknown-elf/lib"
+// C-RV64-BAREMETAL-LP64-NOGCC: "--start-group" "-lc" "-lgloss" "--end-group"
+// C-RV64-BAREMETAL-LP64-NOGCC: "{{.*}}Output/testroot-riscv64-baremetal-nogcc/lib/clang/{{[0-9.]*}}/lib/libclang_rt.builtins-riscv64.a"
+// C-RV64-BAREMETAL-LP64-NOGCC: "{{.*}}Output/testroot-riscv64-baremetal-nogcc/lib/clang/{{[0-9.]*}}/lib/clang_rt.crtend-riscv64.o"
Index: clang/test/Driver/riscv32-toolchain-extra.c
===
--- clang/test/Driver/riscv32-toolchain-extra.c
+++ clang/test/Driver/riscv32-toolchain-extra.c
@@ -22,12 +22,12 @@
 // RUN:-target riscv32-unknown-elf 2>&1 \
 // RUN:| FileCheck -check-prefix=C-RV32-BAREMETAL-ILP32-NOGCC %s
 
-// C-RV32-BAREMETAL-ILP32-NOGCC: InstalledDir: [[DRIVERDIR:.*]]
 // C-RV32-BAREMETAL-ILP32-NOGCC: "-fuse-init-array"
-// C-RV32-BAREMETAL-ILP32-NOGCC: "-internal-isystem" "[[DRIVERDIR]]/../riscv32-unknown-elf/include"
-// C-RV32-BAREMETAL-ILP32-NOGCC: "[[DRIVERDIR]]/riscv32-unknown-elf-ld"
-// C-RV32-BAREMETAL-ILP32-NOGCC: "[[DRIVERDIR]]/../riscv32-unknown-elf/lib/crt0.o"
-// C-RV32-BAREMETAL-ILP32-NOGCC: "[[DRIVERDIR]]/../riscv32-unknown-elf/lib/crtbegin.o"
-// C-RV32-BAREMETAL-ILP32-NOGCC: "-L[[DRIVERDIR]]/../riscv32-unknown-elf/lib"
-// C-RV32-BAREMETAL-ILP32-NOGCC: "--start-group" "-lc" "-lgloss" "--end-group" "-lgcc"
-// C-RV32-BAREMETAL-ILP32-NOGCC: "[[DRIVERDIR]]/../riscv32-unknown-elf/lib/crtend.o"
+// C-RV32-BAREMETAL-ILP32-NOGCC: "-internal-isystem" "{{.*}}Output/testroot-riscv32-baremetal-nogcc/bin/../riscv32-unknown-elf/include"
+// C-RV32-BAREMETAL-ILP32-NOGCC: "{{.*}}Output/testroot-riscv32-baremetal-nogcc/bin/riscv32-unknown-elf-ld"
+// C-RV32-BAREMETAL-ILP32-NOGCC: "{{.*}}Output/testroot-riscv32-baremetal-nogcc/bin/../riscv32-unknown-elf/lib/crt0.o"
+// C-RV32-BAREMETAL-ILP32-NOGCC: "{{.*}}Output/testroot-riscv32-baremetal-nogcc/lib/clang/{{[0-9.]*}}/lib/clang_rt.crtbegin-riscv32.o"
+// C-RV32-BAREMETAL-ILP32-NOGCC: "{{.*}}Output/testroot-riscv32-baremetal-nogcc/bin/../riscv32-unknown-elf/lib"
+// C-RV32-BAREMETAL-ILP32-NOGCC: "--start-group" "-lc" "-lgloss" "--end-group"
+// C-RV32-BAREMETAL-ILP32-NOGCC: "{{.*}}Output/testroot-riscv32-baremetal-nogcc/lib/clang/{{[0-9.]*}}/lib/libclang_rt.builtins-riscv32.a"
+// C-RV32-BAREMETAL-ILP32-NOGCC: "{{.*}}Output/testroot-riscv32-baremetal-nogcc/lib/clang/{{[0-9.]*}}/lib/clang_r

[PATCH] D68407: [WIP][RISCV] Use compiler-rt if no GCC installation detected

2019-11-14 Thread Edward Jones via Phabricator via cfe-commits
edward-jones added a comment.

Okay. I'll see if I can find a way to test this when `CLANG_DEFAULT_RTLIB` is 
set, and then I'll resubmit


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D68407/new/

https://reviews.llvm.org/D68407



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D68407: [WIP][RISCV] Use compiler-rt if no GCC installation detected

2019-11-14 Thread Edward Jones via Phabricator via cfe-commits
edward-jones updated this revision to Diff 229273.
edward-jones added a comment.

It seems that the option `--rtlib=platform` exists to force the driver to 
ignore the `-DCLANG_DEFAULT_RTLIB` for testing purposes, so I've added this 
option to the tests that were broken.

These tests now seem to pass regardless of whether `CLANG_DEFAULT_RTLIB` is set 
to `compiler-rt` or `libgcc`.

I'm leaving this WIP as I think it will be prudent to add some tests for 
`--rtlib=compiler` and `--rtlib=libgcc`.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D68407/new/

https://reviews.llvm.org/D68407

Files:
  clang/lib/Driver/ToolChains/RISCVToolchain.cpp
  clang/lib/Driver/ToolChains/RISCVToolchain.h
  
clang/test/Driver/Inputs/basic_riscv32_nogcc_tree/riscv32-unknown-elf/lib/crtbegin.o
  
clang/test/Driver/Inputs/basic_riscv32_nogcc_tree/riscv32-unknown-elf/lib/crtend.o
  
clang/test/Driver/Inputs/basic_riscv64_nogcc_tree/riscv64-unknown-elf/lib/crtbegin.o
  
clang/test/Driver/Inputs/basic_riscv64_nogcc_tree/riscv64-unknown-elf/lib/crtend.o
  clang/test/Driver/riscv32-toolchain-extra.c
  clang/test/Driver/riscv32-toolchain.c
  clang/test/Driver/riscv64-toolchain-extra.c
  clang/test/Driver/riscv64-toolchain.c

Index: clang/test/Driver/riscv64-toolchain.c
===
--- clang/test/Driver/riscv64-toolchain.c
+++ clang/test/Driver/riscv64-toolchain.c
@@ -4,7 +4,7 @@
 // CC1: clang{{.*}} "-cc1" "-triple" "riscv64"
 
 // RUN: %clang %s -### -no-canonical-prefixes \
-// RUN:   -target riscv64-unknown-elf \
+// RUN:   -target riscv64-unknown-elf --rtlib=platform \
 // RUN:   --gcc-toolchain=%S/Inputs/basic_riscv64_tree \
 // RUN:   --sysroot=%S/Inputs/basic_riscv64_tree/riscv64-unknown-elf 2>&1 \
 // RUN:   | FileCheck -check-prefix=C-RV64-BAREMETAL-LP64 %s
@@ -20,7 +20,7 @@
 // C-RV64-BAREMETAL-LP64: "{{.*}}/Inputs/basic_riscv64_tree/lib/gcc/riscv64-unknown-elf/8.0.1{{/|}}crtend.o"
 
 // RUN: %clang %s -### -no-canonical-prefixes \
-// RUN:   -target riscv64-unknown-elf \
+// RUN:   -target riscv64-unknown-elf --rtlib=platform \
 // RUN:   --sysroot= \
 // RUN:   --gcc-toolchain=%S/Inputs/basic_riscv64_tree 2>&1 \
 // RUN:   | FileCheck -check-prefix=C-RV64-BAREMETAL-NOSYSROOT-LP64 %s
@@ -35,7 +35,7 @@
 // C-RV64-BAREMETAL-NOSYSROOT-LP64: "{{.*}}/Inputs/basic_riscv64_tree/lib/gcc/riscv64-unknown-elf/8.0.1{{/|}}crtend.o"
 
 // RUN: %clangxx %s -### -no-canonical-prefixes \
-// RUN:   -target riscv64-unknown-elf -stdlib=libstdc++ \
+// RUN:   -target riscv64-unknown-elf -stdlib=libstdc++ --rtlib=platform \
 // RUN:   --gcc-toolchain=%S/Inputs/basic_riscv64_tree \
 // RUN:   --sysroot=%S/Inputs/basic_riscv64_tree/riscv64-unknown-elf 2>&1 \
 // RUN:   | FileCheck -check-prefix=CXX-RV64-BAREMETAL-LP64 %s
@@ -52,7 +52,7 @@
 // CXX-RV64-BAREMETAL-LP64: "{{.*}}/Inputs/basic_riscv64_tree/lib/gcc/riscv64-unknown-elf/8.0.1{{/|}}crtend.o"
 
 // RUN: %clangxx %s -### -no-canonical-prefixes \
-// RUN:   -target riscv64-unknown-elf -stdlib=libstdc++ \
+// RUN:   -target riscv64-unknown-elf -stdlib=libstdc++ --rtlib=platform \
 // RUN:   --sysroot= \
 // RUN:   --gcc-toolchain=%S/Inputs/basic_riscv64_tree 2>&1 \
 // RUN:   | FileCheck -check-prefix=CXX-RV64-BAREMETAL-NOSYSROOT-LP64 %s
@@ -68,7 +68,7 @@
 // CXX-RV64-BAREMETAL-NOSYSROOT-LP64: "{{.*}}/Inputs/basic_riscv64_tree/lib/gcc/riscv64-unknown-elf/8.0.1{{/|}}crtend.o"
 
 // RUN: %clang %s -### -no-canonical-prefixes -fuse-ld=ld \
-// RUN:   -target riscv64-unknown-linux-gnu -mabi=lp64 \
+// RUN:   -target riscv64-unknown-linux-gnu --rtlib=platform -mabi=lp64 \
 // RUN:   --gcc-toolchain=%S/Inputs/multilib_riscv_linux_sdk \
 // RUN:   --sysroot=%S/Inputs/multilib_riscv_linux_sdk/sysroot 2>&1 \
 // RUN:   | FileCheck -check-prefix=C-RV64-LINUX-MULTI-LP64 %s
@@ -84,7 +84,7 @@
 // C-RV64-LINUX-MULTI-LP64: "-L{{.*}}/Inputs/multilib_riscv_linux_sdk/sysroot/usr/lib64/lp64"
 
 // RUN: %clang %s -### -no-canonical-prefixes -fuse-ld=ld \
-// RUN:   -target riscv64-unknown-linux-gnu -march=rv64imafd \
+// RUN:   -target riscv64-unknown-linux-gnu --rtlib=platform -march=rv64imafd \
 // RUN:   --gcc-toolchain=%S/Inputs/multilib_riscv_linux_sdk \
 // RUN:   --sysroot=%S/Inputs/multilib_riscv_linux_sdk/sysroot 2>&1 \
 // RUN:   | FileCheck -check-prefix=C-RV64-LINUX-MULTI-LP64D %s
Index: clang/test/Driver/riscv64-toolchain-extra.c
===
--- clang/test/Driver/riscv64-toolchain-extra.c
+++ clang/test/Driver/riscv64-toolchain-extra.c
@@ -19,15 +19,15 @@
 // RUN: ln -s %S/Inputs/basic_riscv64_nogcc_tree/bin/riscv64-unknown-elf-ld %T/testroot-riscv64-baremetal-nogcc/bin/riscv64-unknown-elf-ld
 // RUN: ln -s %S/Inputs/basic_riscv64_nogcc_tree/riscv64-unknown-elf %T/testroot-riscv64-baremetal-nogcc/riscv64-unknown-elf
 // RUN: %T/testroot-riscv64-baremetal-nogcc/bin/clang %s -### -no-canonical-prefixes \
-// RUN:-target riscv64-unknown-elf 2>&1 \
+// RUN:-targ

[PATCH] D68407: [WIP][RISCV] Use compiler-rt if no GCC installation detected

2019-11-14 Thread Edward Jones via Phabricator via cfe-commits
edward-jones added a comment.

If I set `-DCLANG_DEFAULT_RTLIB=compiler-rt` I see the following failure in 
`clang/test/Driver/cross-linux.c`:

  /home/ed/work/proj/riscv-testing/llvm/clang/test/Driver/cross-linux.c:62:26: 
error: CHECK-MULTI32-X86-64: expected string not found in input
  // CHECK-MULTI32-X86-64: "crti.o" 
"[[gcc_install:.*/Inputs/multilib_32bit_linux_tree/usr/lib/gcc/i386-unknown-linux/4.6.0]]/64{{/|}}crtbegin.o"
   ^
  :7:327: note: scanning from here
   
"/home/ed/work/proj/riscv-testing/llvm/clang/test/Driver/Inputs/multilib_32bit_linux_tree/usr/lib/gcc/i386-unknown-linux/4.6.0/../../../../i386-unknown-linux/bin/ld"
 
"--sysroot=/home/ed/work/proj/riscv-testing/llvm/clang/test/Driver/Inputs/basic_linux_tree"
 "-z" "relro" "--hash-style=gnu" "--eh-frame-hdr" "-m" "elf_x86_64" 
"-dynamic-linker" "/lib64/ld-linux-x86-64.so.2" "-o" 
"/home/ed/work/proj/riscv-testing/build/llvm/tools/clang/test/Driver/Output/cross-linux.c.tmp"
 "crt1.o" "crti.o" 
"/home/ed/work/proj/riscv-testing/build/llvm/lib/clang/10.0.0/lib/linux/clang_rt.crtbegin-x86_64.o"
 
"-L/home/ed/work/proj/riscv-testing/llvm/clang/test/Driver/Inputs/multilib_32bit_linux_tree/usr/lib/gcc/i386-unknown-linux/4.6.0/64"
 
"-L/home/ed/work/proj/riscv-testing/llvm/clang/test/Driver/Inputs/multilib_32bit_linux_tree/usr/lib/gcc/i386-unknown-linux/4.6.0/../../../../i386-unknown-linux/lib/../lib64"
 
"-L/home/ed/work/proj/riscv-testing/llvm/clang/test/Driver/Inputs/multilib_32bit_linux_tree/usr/lib/gcc/i386-unknown-linux/4.6.0"
 
"-L/home/ed/work/proj/riscv-testing/llvm/clang/test/Driver/Inputs/multilib_32bit_linux_tree/usr/lib/gcc/i386-unknown-linux/4.6.0/../../../../i386-unknown-linux/lib"
 
"-L/home/ed/work/proj/riscv-testing/llvm/clang/test/Driver/Inputs/basic_linux_tree/lib"
 
"-L/home/ed/work/proj/riscv-testing/llvm/clang/test/Driver/Inputs/basic_linux_tree/usr/lib"
 "/tmp/cross-linux-bb2220.o" 
"/home/ed/work/proj/riscv-testing/build/llvm/lib/clang/10.0.0/lib/linux/libclang_rt.builtins-x86_64.a"
 "--as-needed" "-lgcc_s" "--no-as-needed" "-lc" 
"/home/ed/work/proj/riscv-testing/build/llvm/lib/clang/10.0.0/lib/linux/libclang_rt.builtins-x86_64.a"
 "--as-needed" "-lgcc_s" "--no-as-needed" 
"/home/ed/work/proj/riscv-testing/build/llvm/lib/clang/10.0.0/lib/linux/clang_rt.crtend-x86_64.o"
 "crtn.o"




^

And if I set `-DCLANG_DEFAULT_RTLIB=libgcc` then I see the following failure in 
`clang/test/Driver/wasm-toolchain.cpp`:

  
/home/ed/work/proj/riscv-testing/llvm/clang/test/Driver/wasm-toolchain.cpp:20:10:
 error: LINK: expected string not found in input
  // LINK: wasm-ld{{.*}}" "-L/foo/lib" "crt1.o" "[[temp]]" "-lc++" "-lc++abi" 
"-lc" "{{.*[/\\]}}libclang_rt.builtins-wasm32.a" "-o" "a.out"
  
  :6:1018: note: scanning from here
   "/home/ed/work/proj/riscv-testing/build/llvm/bin/clang" "-cc1" "-triple" 
"wasm32-unknown-unknown" "-emit-obj" "-mrelax-all" "-disable-free" 
"-main-file-name" "wasm-toolchain.cpp" "-mrelocation-model" "static" 
"-mthread-model" "posix" "-mframe-pointer=none" "-fno-rounding-math" 
"-masm-verbose" "-mconstructor-aliases" "-fuse-init-array" "-target-cpu" 
"generic" "-fvisibility" "hidden" "-dwarf-column-info" "-debugger-tuning=gdb" 
"-resource-dir" "/home/ed/work/proj/riscv-testing/build/llvm/lib/clang/10.0.0" 
"-isysroot" "/foo" "-internal-isystem" "/foo/include/c++/v1" 
"-internal-isystem" 
"/home/ed/work/proj/riscv-testing/build/llvm/lib/clang/10.0.0/include" 
"-internal-isystem" "/foo/include" "-fdeprecated-macro" 
"-fdebug-compilation-dir" 
"/home/ed/work/proj/riscv-testing/build/llvm/tools/clang/test/Driver" 
"-ferror-limit" "19" "-fmessage-length" "0" "-fgnuc-version=4.2.1" 
"-fobjc-runtime=gnustep" "-fcxx-exceptions" "-fexceptions" "-fno-common" 
"-fdiagnostics-show-option" "-o" "/tmp/wasm-toolchain-718d0c.o" "-x" "c++" 
"/home/ed/work/proj/riscv-testing/llvm/clang/test/Driver/wasm-toolchain.cpp"









 

[PATCH] D68407: [RISCV] Use compiler-rt if no GCC installation detected

2019-11-14 Thread Edward Jones via Phabricator via cfe-commits
edward-jones updated this revision to Diff 229284.
edward-jones retitled this revision from "[WIP][RISCV] Use compiler-rt if no 
GCC installation detected" to "[RISCV] Use compiler-rt if no GCC installation 
detected".
edward-jones added a comment.

Added tests that a user can specify a specific runtime library through 
`--rtlib`. Also rebased on master, and added a comment explaining the use of 
`--rtlib=platform` in the tests.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D68407/new/

https://reviews.llvm.org/D68407

Files:
  clang/lib/Driver/ToolChains/RISCVToolchain.cpp
  clang/lib/Driver/ToolChains/RISCVToolchain.h
  
clang/test/Driver/Inputs/basic_riscv32_nogcc_tree/riscv32-unknown-elf/lib/crtbegin.o
  
clang/test/Driver/Inputs/basic_riscv32_nogcc_tree/riscv32-unknown-elf/lib/crtend.o
  
clang/test/Driver/Inputs/basic_riscv64_nogcc_tree/riscv64-unknown-elf/lib/crtbegin.o
  
clang/test/Driver/Inputs/basic_riscv64_nogcc_tree/riscv64-unknown-elf/lib/crtend.o
  clang/test/Driver/riscv32-toolchain-extra.c
  clang/test/Driver/riscv32-toolchain.c
  clang/test/Driver/riscv64-toolchain-extra.c
  clang/test/Driver/riscv64-toolchain.c

Index: clang/test/Driver/riscv64-toolchain.c
===
--- clang/test/Driver/riscv64-toolchain.c
+++ clang/test/Driver/riscv64-toolchain.c
@@ -3,8 +3,11 @@
 // RUN: %clang %s -### -no-canonical-prefixes -target riscv64 2>&1 | FileCheck -check-prefix=CC1 %s
 // CC1: clang{{.*}} "-cc1" "-triple" "riscv64"
 
+// In the below tests, --rtlib=platform is used so that the driver ignores
+// the configure-time CLANG_DEFAULT_RTLIB option when choosing the runtime lib
+
 // RUN: %clang %s -### -no-canonical-prefixes \
-// RUN:   -target riscv64-unknown-elf \
+// RUN:   -target riscv64-unknown-elf --rtlib=platform \
 // RUN:   --gcc-toolchain=%S/Inputs/basic_riscv64_tree \
 // RUN:   --sysroot=%S/Inputs/basic_riscv64_tree/riscv64-unknown-elf 2>&1 \
 // RUN:   | FileCheck -check-prefix=C-RV64-BAREMETAL-LP64 %s
@@ -20,7 +23,7 @@
 // C-RV64-BAREMETAL-LP64: "{{.*}}/Inputs/basic_riscv64_tree/lib/gcc/riscv64-unknown-elf/8.0.1{{/|}}crtend.o"
 
 // RUN: %clang %s -### -no-canonical-prefixes \
-// RUN:   -target riscv64-unknown-elf \
+// RUN:   -target riscv64-unknown-elf --rtlib=platform \
 // RUN:   --sysroot= \
 // RUN:   --gcc-toolchain=%S/Inputs/basic_riscv64_tree 2>&1 \
 // RUN:   | FileCheck -check-prefix=C-RV64-BAREMETAL-NOSYSROOT-LP64 %s
@@ -35,7 +38,7 @@
 // C-RV64-BAREMETAL-NOSYSROOT-LP64: "{{.*}}/Inputs/basic_riscv64_tree/lib/gcc/riscv64-unknown-elf/8.0.1{{/|}}crtend.o"
 
 // RUN: %clangxx %s -### -no-canonical-prefixes \
-// RUN:   -target riscv64-unknown-elf -stdlib=libstdc++ \
+// RUN:   -target riscv64-unknown-elf -stdlib=libstdc++ --rtlib=platform \
 // RUN:   --gcc-toolchain=%S/Inputs/basic_riscv64_tree \
 // RUN:   --sysroot=%S/Inputs/basic_riscv64_tree/riscv64-unknown-elf 2>&1 \
 // RUN:   | FileCheck -check-prefix=CXX-RV64-BAREMETAL-LP64 %s
@@ -52,7 +55,7 @@
 // CXX-RV64-BAREMETAL-LP64: "{{.*}}/Inputs/basic_riscv64_tree/lib/gcc/riscv64-unknown-elf/8.0.1{{/|}}crtend.o"
 
 // RUN: %clangxx %s -### -no-canonical-prefixes \
-// RUN:   -target riscv64-unknown-elf -stdlib=libstdc++ \
+// RUN:   -target riscv64-unknown-elf -stdlib=libstdc++ --rtlib=platform \
 // RUN:   --sysroot= \
 // RUN:   --gcc-toolchain=%S/Inputs/basic_riscv64_tree 2>&1 \
 // RUN:   | FileCheck -check-prefix=CXX-RV64-BAREMETAL-NOSYSROOT-LP64 %s
@@ -68,7 +71,7 @@
 // CXX-RV64-BAREMETAL-NOSYSROOT-LP64: "{{.*}}/Inputs/basic_riscv64_tree/lib/gcc/riscv64-unknown-elf/8.0.1{{/|}}crtend.o"
 
 // RUN: %clang %s -### -no-canonical-prefixes -fuse-ld=ld \
-// RUN:   -target riscv64-unknown-linux-gnu -mabi=lp64 \
+// RUN:   -target riscv64-unknown-linux-gnu --rtlib=platform -mabi=lp64 \
 // RUN:   --gcc-toolchain=%S/Inputs/multilib_riscv_linux_sdk \
 // RUN:   --sysroot=%S/Inputs/multilib_riscv_linux_sdk/sysroot 2>&1 \
 // RUN:   | FileCheck -check-prefix=C-RV64-LINUX-MULTI-LP64 %s
@@ -84,7 +87,7 @@
 // C-RV64-LINUX-MULTI-LP64: "-L{{.*}}/Inputs/multilib_riscv_linux_sdk/sysroot/usr/lib64/lp64"
 
 // RUN: %clang %s -### -no-canonical-prefixes -fuse-ld=ld \
-// RUN:   -target riscv64-unknown-linux-gnu -march=rv64imafd \
+// RUN:   -target riscv64-unknown-linux-gnu --rtlib=platform -march=rv64imafd \
 // RUN:   --gcc-toolchain=%S/Inputs/multilib_riscv_linux_sdk \
 // RUN:   --sysroot=%S/Inputs/multilib_riscv_linux_sdk/sysroot 2>&1 \
 // RUN:   | FileCheck -check-prefix=C-RV64-LINUX-MULTI-LP64D %s
@@ -99,6 +102,23 @@
 // C-RV64-LINUX-MULTI-LP64D: "-L{{.*}}/Inputs/multilib_riscv_linux_sdk/sysroot/lib64/lp64d"
 // C-RV64-LINUX-MULTI-LP64D: "-L{{.*}}/Inputs/multilib_riscv_linux_sdk/sysroot/usr/lib64/lp64d"
 
+// Check that --rtlib can be used to override the used runtime library
+// RUN: %clang %s -### -no-canonical-prefixes \
+// RUN:   -target riscv64-unknown-elf --rtlib=libgcc 2>&1 \
+// RUN:   | FileCheck -check-prefix=C-RV64-RTLIB-LIBGCC-LP64 %s
+

[PATCH] D68407: [RISCV] Use compiler-rt if no GCC installation detected

2019-11-22 Thread Edward Jones via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGe0f22fe04a5c: [RISCV] Use compiler-rt if no GCC installation 
detected (authored by edward-jones).

Changed prior to commit:
  https://reviews.llvm.org/D68407?vs=229284&id=230708#toc

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D68407/new/

https://reviews.llvm.org/D68407

Files:
  clang/lib/Driver/ToolChains/RISCVToolchain.cpp
  clang/lib/Driver/ToolChains/RISCVToolchain.h
  clang/test/Driver/riscv32-toolchain-extra.c
  clang/test/Driver/riscv32-toolchain.c
  clang/test/Driver/riscv64-toolchain-extra.c
  clang/test/Driver/riscv64-toolchain.c

Index: clang/test/Driver/riscv64-toolchain.c
===
--- clang/test/Driver/riscv64-toolchain.c
+++ clang/test/Driver/riscv64-toolchain.c
@@ -3,8 +3,11 @@
 // RUN: %clang %s -### -no-canonical-prefixes -target riscv64 2>&1 | FileCheck -check-prefix=CC1 %s
 // CC1: clang{{.*}} "-cc1" "-triple" "riscv64"
 
+// In the below tests, --rtlib=platform is used so that the driver ignores
+// the configure-time CLANG_DEFAULT_RTLIB option when choosing the runtime lib
+
 // RUN: %clang %s -### -no-canonical-prefixes \
-// RUN:   -target riscv64-unknown-elf \
+// RUN:   -target riscv64-unknown-elf --rtlib=platform \
 // RUN:   --gcc-toolchain=%S/Inputs/basic_riscv64_tree \
 // RUN:   --sysroot=%S/Inputs/basic_riscv64_tree/riscv64-unknown-elf 2>&1 \
 // RUN:   | FileCheck -check-prefix=C-RV64-BAREMETAL-LP64 %s
@@ -20,7 +23,7 @@
 // C-RV64-BAREMETAL-LP64: "{{.*}}/Inputs/basic_riscv64_tree/lib/gcc/riscv64-unknown-elf/8.0.1{{/|}}crtend.o"
 
 // RUN: %clang %s -### -no-canonical-prefixes \
-// RUN:   -target riscv64-unknown-elf \
+// RUN:   -target riscv64-unknown-elf --rtlib=platform \
 // RUN:   --sysroot= \
 // RUN:   --gcc-toolchain=%S/Inputs/basic_riscv64_tree 2>&1 \
 // RUN:   | FileCheck -check-prefix=C-RV64-BAREMETAL-NOSYSROOT-LP64 %s
@@ -35,7 +38,7 @@
 // C-RV64-BAREMETAL-NOSYSROOT-LP64: "{{.*}}/Inputs/basic_riscv64_tree/lib/gcc/riscv64-unknown-elf/8.0.1{{/|}}crtend.o"
 
 // RUN: %clangxx %s -### -no-canonical-prefixes \
-// RUN:   -target riscv64-unknown-elf -stdlib=libstdc++ \
+// RUN:   -target riscv64-unknown-elf -stdlib=libstdc++ --rtlib=platform \
 // RUN:   --gcc-toolchain=%S/Inputs/basic_riscv64_tree \
 // RUN:   --sysroot=%S/Inputs/basic_riscv64_tree/riscv64-unknown-elf 2>&1 \
 // RUN:   | FileCheck -check-prefix=CXX-RV64-BAREMETAL-LP64 %s
@@ -52,7 +55,7 @@
 // CXX-RV64-BAREMETAL-LP64: "{{.*}}/Inputs/basic_riscv64_tree/lib/gcc/riscv64-unknown-elf/8.0.1{{/|}}crtend.o"
 
 // RUN: %clangxx %s -### -no-canonical-prefixes \
-// RUN:   -target riscv64-unknown-elf -stdlib=libstdc++ \
+// RUN:   -target riscv64-unknown-elf -stdlib=libstdc++ --rtlib=platform \
 // RUN:   --sysroot= \
 // RUN:   --gcc-toolchain=%S/Inputs/basic_riscv64_tree 2>&1 \
 // RUN:   | FileCheck -check-prefix=CXX-RV64-BAREMETAL-NOSYSROOT-LP64 %s
@@ -68,7 +71,7 @@
 // CXX-RV64-BAREMETAL-NOSYSROOT-LP64: "{{.*}}/Inputs/basic_riscv64_tree/lib/gcc/riscv64-unknown-elf/8.0.1{{/|}}crtend.o"
 
 // RUN: %clang %s -### -no-canonical-prefixes -fuse-ld=ld \
-// RUN:   -target riscv64-unknown-linux-gnu -mabi=lp64 \
+// RUN:   -target riscv64-unknown-linux-gnu --rtlib=platform -mabi=lp64 \
 // RUN:   --gcc-toolchain=%S/Inputs/multilib_riscv_linux_sdk \
 // RUN:   --sysroot=%S/Inputs/multilib_riscv_linux_sdk/sysroot 2>&1 \
 // RUN:   | FileCheck -check-prefix=C-RV64-LINUX-MULTI-LP64 %s
@@ -84,7 +87,7 @@
 // C-RV64-LINUX-MULTI-LP64: "-L{{.*}}/Inputs/multilib_riscv_linux_sdk/sysroot/usr/lib64/lp64"
 
 // RUN: %clang %s -### -no-canonical-prefixes -fuse-ld=ld \
-// RUN:   -target riscv64-unknown-linux-gnu -march=rv64imafd \
+// RUN:   -target riscv64-unknown-linux-gnu --rtlib=platform -march=rv64imafd \
 // RUN:   --gcc-toolchain=%S/Inputs/multilib_riscv_linux_sdk \
 // RUN:   --sysroot=%S/Inputs/multilib_riscv_linux_sdk/sysroot 2>&1 \
 // RUN:   | FileCheck -check-prefix=C-RV64-LINUX-MULTI-LP64D %s
@@ -100,7 +103,8 @@
 // C-RV64-LINUX-MULTI-LP64D: "-L{{.*}}/Inputs/multilib_riscv_linux_sdk/sysroot/usr/lib64/lp64d"
 
 // RUN: %clang %s -### -no-canonical-prefixes -fuse-ld=ld \
-// RUN:   -target riscv64-unknown-elf --sysroot= -march=rv64imac -mabi=lp64\
+// RUN:   -target riscv64-unknown-elf --rtlib=platform --sysroot= \
+// RUN:   -march=rv64imac -mabi=lp64\
 // RUN:   --gcc-toolchain=%S/Inputs/multilib_riscv_elf_sdk 2>&1 \
 // RUN:   | FileCheck -check-prefix=C-RV64IMAC-BAREMETAL-MULTI-LP64 %s
 
@@ -115,7 +119,8 @@
 // C-RV64IMAC-BAREMETAL-MULTI-LP64: "{{.*}}/Inputs/multilib_riscv_elf_sdk/lib/gcc/riscv64-unknown-elf/8.2.0/rv64imac/lp64{{/|}}crtend.o"
 
 // RUN: %clang %s -### -no-canonical-prefixes -fuse-ld=ld \
-// RUN:   -target riscv64-unknown-elf --sysroot= -march=rv64imafdc -mabi=lp64d \
+// RUN:   -target riscv64-unknown-elf --rtlib=platform --sysroot= \
+// RUN:   -march=rv64imafdc -mabi=lp64d \
 

[PATCH] D109372: [RISCV][RFC] Add Clang support for RISC-V overlay system

2021-10-18 Thread Edward Jones via Phabricator via cfe-commits
edward-jones updated this revision to Diff 380347.

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D109372/new/

https://reviews.llvm.org/D109372

Files:
  clang/include/clang/Basic/Attr.td
  clang/include/clang/Basic/AttrDocs.td
  clang/include/clang/Basic/DiagnosticDriverKinds.td
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Basic/LangOptions.def
  clang/include/clang/Driver/Options.td
  clang/lib/CodeGen/CGCall.cpp
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/lib/Driver/ToolChains/Arch/RISCV.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Sema/SemaDecl.cpp
  clang/lib/Sema/SemaDeclAttr.cpp
  clang/test/CodeGen/riscv-overlay.c
  clang/test/Driver/riscv-overlay.c
  clang/test/Misc/pragma-attribute-supported-attributes-list.test
  clang/test/Sema/riscv-overlay-attr.c
  clang/test/Sema/riscv-overlay-namespace.cpp

Index: clang/test/Sema/riscv-overlay-namespace.cpp
===
--- /dev/null
+++ clang/test/Sema/riscv-overlay-namespace.cpp
@@ -0,0 +1,20 @@
+// RUN: %clang_cc1 %s -triple riscv32-unknown-elf -verify -fsyntax-only -moverlay
+// RUN: %clang_cc1 %s -triple riscv64-unknown-elf -verify -fsyntax-only -moverlay
+
+namespace {
+class foo {
+public:
+  static int X() __attribute__((overlaycall)) { return 0; } // expected-error {{functions marked with 'overlaycall' attribute must have external linkage}}
+};
+} // end of anonymous namespace
+
+namespace X {
+class bar {
+public:
+  static int X() __attribute__((overlaycall)) { return 1; }
+};
+} // end of namespace X
+
+extern "C" {
+int main(void) { return foo::X() + X::bar::X(); }
+}
Index: clang/test/Sema/riscv-overlay-attr.c
===
--- /dev/null
+++ clang/test/Sema/riscv-overlay-attr.c
@@ -0,0 +1,16 @@
+// RUN: %clang_cc1 -triple riscv32 -moverlay -fsyntax-only -verify %s
+// RUN: %clang_cc1 -triple riscv64 -moverlay -fsyntax-only -verify %s
+
+int notAFunction __attribute__((overlaycall));
+// expected-warning@-1 {{'overlaycall' attribute only applies to functions}}
+
+void incompatForwardDecl(int x);
+void __attribute__((overlaycall)) incompatForwardDecl(int x) {}
+// expected-error@-1 {{redeclaration of 'incompatForwardDecl' must not have the 'overlaycall' attribute}}
+// expected-note@-3 {{previous definition is here}}
+
+static void staticcall() __attribute__((overlaycall)) {}
+// expected-error@-1 {{functions marked with 'overlaycall' attribute must have external linkage}}
+
+static void __attribute__((overlaycall)) staticcall2() {}
+// expected-error@-1 {{functions marked with 'overlaycall' attribute must have external linkage}}
Index: clang/test/Misc/pragma-attribute-supported-attributes-list.test
===
--- clang/test/Misc/pragma-attribute-supported-attributes-list.test
+++ clang/test/Misc/pragma-attribute-supported-attributes-list.test
@@ -147,6 +147,7 @@
 // CHECK-NEXT: PassObjectSize (SubjectMatchRule_variable_is_parameter)
 // CHECK-NEXT: PatchableFunctionEntry (SubjectMatchRule_function, SubjectMatchRule_objc_method)
 // CHECK-NEXT: Pointer (SubjectMatchRule_record_not_is_union)
+// CHECK-NEXT: RISCVOverlayCall (SubjectMatchRule_function)
 // CHECK-NEXT: ReleaseHandle (SubjectMatchRule_variable_is_parameter)
 // CHECK-NEXT: RenderScriptKernel (SubjectMatchRule_function)
 // CHECK-NEXT: ReqdWorkGroupSize (SubjectMatchRule_function)
Index: clang/test/Driver/riscv-overlay.c
===
--- /dev/null
+++ clang/test/Driver/riscv-overlay.c
@@ -0,0 +1,5 @@
+// Check that ComRV Driver Arguments
+
+// RUN: not %clang -target riscv32 -moverlay %s -o %t.o -mabi=ilp32f 2>&1 \
+// RUN:   | FileCheck -check-prefix=INVALID-ABI %s
+// INVALID-ABI: invalid ABI 'ilp32f' when using '-moverlay'
Index: clang/test/CodeGen/riscv-overlay.c
===
--- /dev/null
+++ clang/test/CodeGen/riscv-overlay.c
@@ -0,0 +1,11 @@
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py UTC_ARGS: --check-attributes
+// RUN: %clang_cc1 -triple riscv32 -moverlay -emit-llvm %s -o - \
+// RUN:| FileCheck %s
+
+// CHECK-LABEL: @test_overlay_func(
+// CHECK-SAME: #0
+// CHECK: attributes #0 = {
+// CHECK-SAME: "overlay"
+int __attribute__((overlaycall)) test_overlay_func(void) {
+  return 5;
+}
Index: clang/lib/Sema/SemaDeclAttr.cpp
===
--- clang/lib/Sema/SemaDeclAttr.cpp
+++ clang/lib/Sema/SemaDeclAttr.cpp
@@ -2039,6 +2039,33 @@
   D->addAttr(::new (S.Context) CmseNSEntryAttr(S.Context, AL));
 }
 
+static void handleRISCVOverlayAttr(Sema &S, Decl *D, const ParsedAttr &AL) {
+  if (!S.getLangOpts().Overlay) {
+S.Diag(AL.getRange().getBegin(), diag::warn_attribute_ignored_overlay)
+<< AL;
+return;
+  }
+
+  if (isFunctionOrMethod(D)) {
+const aut

[PATCH] D109372: [RISCV][RFC] Add Clang support for RISC-V overlay system

2021-09-07 Thread Edward Jones via Phabricator via cfe-commits
edward-jones created this revision.
Herald added subscribers: vkmr, frasercrmck, dexonsmith, dang, jdoerfert, 
evandro, luismarques, apazos, sameer.abuasal, simoncook, s.egerton, Jim, benna, 
psnobl, jocewei, PkmX, the_o, brucehoult, MartinMosbeck, rogfer01, zzheng, 
jrtc27, shiva0217, kito-cheng, niosHD, sabuasal, johnrusso, rbar, asb.
Herald added a reviewer: aaron.ballman.
edward-jones requested review of this revision.
Herald added subscribers: cfe-commits, MaskRay.
Herald added a project: clang.

This is the Clang component of a change to add support for a proposed 'overlay' 
system for RISC-V to LLVM.

This adds two new attributes, __attribute__((overlaydata)), and 
__attribute__((overlaycall)), which are used to mark functions or global data 
as only accessible through the overlay engine. Internally they are converted to 
'overlay-data' and 'overlay-call' attributes in LLVM IR.

This change also adds the option `-fcomrv` to enable use of the overlay system. 
This has the effect of reserving registers x28, x29, x30 and x31 for exclusive 
used by the overlay engine.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D109372

Files:
  clang/include/clang/Basic/Attr.td
  clang/include/clang/Basic/AttrDocs.td
  clang/include/clang/Basic/DiagnosticDriverKinds.td
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Basic/LangOptions.def
  clang/include/clang/Driver/Options.td
  clang/lib/AST/TypePrinter.cpp
  clang/lib/CodeGen/CGCall.cpp
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/lib/Driver/ToolChains/Arch/RISCV.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Driver/ToolChains/CommonArgs.cpp
  clang/lib/Driver/ToolChains/RISCVToolchain.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/lib/Sema/SemaDecl.cpp
  clang/lib/Sema/SemaDeclAttr.cpp
  clang/test/CodeGen/riscv-overlaycall.c
  clang/test/Driver/riscv-comrv.c
  clang/test/Misc/pragma-attribute-supported-attributes-list.test
  clang/test/Sema/attr-overlaycall.c
  clang/test/Sema/riscv-overlaycall-namespace.cpp

Index: clang/test/Sema/riscv-overlaycall-namespace.cpp
===
--- /dev/null
+++ clang/test/Sema/riscv-overlaycall-namespace.cpp
@@ -0,0 +1,20 @@
+// RUN: %clang_cc1 %s -triple riscv32-unknown-elf -verify -fsyntax-only -fcomrv
+// RUN: %clang_cc1 %s -triple riscv64-unknown-elf -verify -fsyntax-only -fcomrv
+
+namespace {
+class foo {
+public:
+  static int X() __attribute__((overlaycall)) { return 0; } // expected-error {{RISC-V 'overlaycall' attribute not supported on static functions}}
+};
+} // end of anonymous namespace
+
+namespace X {
+  class bar {
+  public:
+static int X() __attribute__((overlaycall)) { return 1; }
+  };
+} // end of namespace X
+
+extern "C" {
+int main(void) { return foo::X() + X::bar::X(); }
+}
Index: clang/test/Sema/attr-overlaycall.c
===
--- /dev/null
+++ clang/test/Sema/attr-overlaycall.c
@@ -0,0 +1,17 @@
+// RUN: %clang_cc1 -triple riscv32 -fcomrv -fsyntax-only -verify %s
+// RUN: %clang_cc1 -triple riscv64 -fcomrv -fsyntax-only -verify %s
+
+int notAFunction __attribute__((overlaycall));
+// expected-warning@-1 {{'overlaycall' attribute only applies to functions}}
+
+void incompatForwardDecl(int x);
+void __attribute__((overlaycall)) incompatForwardDecl(int x) {}
+// expected-error@-1 {{redeclaration of 'incompatForwardDecl' must not have the RISC-V 'overlaycall' attribute}}
+// expected-note@-3 {{previous definition is here}}
+
+static void staticcall() __attribute__((overlaycall)) {}
+// expected-error@-1 {{attribute not supported on static functions}}
+// expected-warning@-2 {{GCC does not allow 'overlaycall' attribute in this position on a function definition}}
+
+static void __attribute__((overlaycall)) staticcall2(){}
+// expected-error@-1 {{attribute not supported on static functions}}
Index: clang/test/Misc/pragma-attribute-supported-attributes-list.test
===
--- clang/test/Misc/pragma-attribute-supported-attributes-list.test
+++ clang/test/Misc/pragma-attribute-supported-attributes-list.test
@@ -147,6 +147,7 @@
 // CHECK-NEXT: PassObjectSize (SubjectMatchRule_variable_is_parameter)
 // CHECK-NEXT: PatchableFunctionEntry (SubjectMatchRule_function, SubjectMatchRule_objc_method)
 // CHECK-NEXT: Pointer (SubjectMatchRule_record_not_is_union)
+// CHECK-NEXT: RISCVOverlayCall (SubjectMatchRule_function)
 // CHECK-NEXT: ReleaseHandle (SubjectMatchRule_variable_is_parameter)
 // CHECK-NEXT: RenderScriptKernel (SubjectMatchRule_function)
 // CHECK-NEXT: ReqdWorkGroupSize (SubjectMatchRule_function)
Index: clang/test/Driver/riscv-comrv.c
===
--- /dev/null
+++ clang/test/Driver/riscv-comrv.c
@@ -0,0 +1,8 @@
+// Check ComRV Driver Arguments
+//
+// REQUIRES: riscv-registered-target
+//
+// RUN: %clang -target risc

[PATCH] D109372: [RISCV][RFC] Add Clang support for RISC-V overlay system

2021-09-08 Thread Edward Jones via Phabricator via cfe-commits
edward-jones added a comment.

In D109372#2987411 , @jrtc27 wrote:

> In D109372#2987405 , @MaskRay wrote:
>
>> The name "overlay" is ambiguous. Even after I ruled out Gentoo Overlay and 
>> overlayfs, I am thinking whether this has anything to do with `OVERLAY` 
>> description in a linker script: 
>> https://sourceware.org/binutils/docs/ld/Overlay-Description.html#Overlay-Description
>>
>>> which are used to mark functions or global data as only accessible through 
>>> the overlay engine
>>
>> Can you give more descriptions for folks who don't follow the RISC-V side 
>> proposal but need to review your changes? :)
>
> Basically hardware-assisted code+rodata banking (I guess either by actually 
> banking ROMs or just paging stuff in and out) that's mostly transparent to 
> software. Functions at the boundary of components (don't know what the 
> granularity is) use a weird indirect calling convention where you instead 
> call into some magic runtime with a unique ID for the callee, it ensures 
> everything's loaded and then tail calls it for you.

Yes it's essentially this. The start of the proposal for this 'overlay' system 
for RISC-V is a FOSDEM talk 'Cacheable Overlay Manager RISC‐V' 
.
 That's also the source of the weird name for the `-fcomrv` option name.

Would something like `-foverlay-manager` make more sense? (maybe an `-m` option 
would actually be more appropriate given this is still very RISC-V specific?). 
I'm not sure how to disambiguate from the many overloaded meanings of 'overlay'.

Thank's for the feedback. I'll update this and come back with a tidier patch.




Comment at: clang/include/clang/Basic/Attr.td:1793-1795
+// This is not marked as a TargetSpecificAttr because that would trigger
+// an 'attribute ignored' warning, but we want to check it explicitly and
+// trigger an error.

aaron.ballman wrote:
> This is not typical attribute behavior -- if the target architecture doesn't 
> support the attribute, are the semantics such that an error is 
> appropriate/required? Put another way, why do we want to trigger an error for 
> this attribute while not triggering errors for other target-specific 
> attributes (like calling conventions)?
If the attribute is being used then the expectation is that it is being 
supported by an overlay engine, and if that isn't the case then it implies an 
error in the build setup. That said I need to check this because I'm not 
convinced it's necessary.



Comment at: clang/include/clang/Basic/Attr.td:1796
+// trigger an error.
+def RISCVOverlayCall : InheritableAttr {
+  let Spellings = [GCC<"overlaycall">];

jrtc27 wrote:
> If you want this to be portable to non-GNU compilers you should consider 
> using a keyword instead (which can still map to an attribute internally). 
> That also tends to get you better errors (there are places where type 
> attributes can get silently ignored currently).
I don't think much consideration has been given to other compilers, but would 
it be unreasonable for the interface to this feature to not necessarily be 
identical between GNU and non-GNU compilers?

That said, I'm happy to switch to a keyword, especially if as you mention there 
are cases where an attribute can silently go missing without error. I'm not 
sure on the distinction of when to use a keyword vs attribute though, given 
that keywords are used pretty sparingly in comparison.



Comment at: clang/include/clang/Basic/AttrDocs.td:2149
+  let Content = [{
+``__attribute__((overlaycall))`` indicates that a function resides in an
+overlay and therefore any calls to or from that function must be handled

jrtc27 wrote:
> Why not just a single attribute that DTRT based on the type?
Good point. I'll see if I can do that. The fact we used multiple attributes is 
mainly a consequence of how we put this together rather than any inherent 
technical need I think.



Comment at: clang/test/Sema/riscv-overlaycall-namespace.cpp:7
+public:
+  static int X() __attribute__((overlaycall)) { return 0; } // expected-error 
{{RISC-V 'overlaycall' attribute not supported on static functions}}
+};

jrtc27 wrote:
> This error message is misleading. The semantics also don't seem great to me.
From recollection the current overlay system only works with externally visible 
symbols and these semantics are a consequence of that.

That said, it's not documented in the code, and as you point out the error 
message is just wrong so I'll fix this.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D109372/new/

https://reviews.llvm.org/D109372

___