[PATCH] D112401: [Clang] Mutate printf bulitin names under IEEE128 on PPC64

2021-10-24 Thread Qiu Chaofan via Phabricator via cfe-commits
qiucf created this revision.
qiucf added reviewers: nemanjai, jsji, PowerPC.
Herald added subscribers: shchenz, kbarton.
qiucf requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Glibc uses these new symbol names to support IEEE-754 128-bit float support.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D112401

Files:
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/test/CodeGen/ppc64-f128-builtins.c


Index: clang/test/CodeGen/ppc64-f128-builtins.c
===
--- /dev/null
+++ clang/test/CodeGen/ppc64-f128-builtins.c
@@ -0,0 +1,37 @@
+// RUN: %clang_cc1 -triple powerpc64le-linux-gnu -emit-llvm -o - %s \
+// RUN:   -mabi=ieeelongdouble | FileCheck --check-prefix=IEEE128 %s
+// RUN: %clang_cc1 -triple powerpc64le-linux-gnu -emit-llvm -o - %s \
+// RUN:   -mabi=ibmlongdouble | FileCheck --check-prefix=PPC128 %s
+
+long double x;
+
+void test_printf() {
+  __builtin_printf("%.Lf", x);
+}
+
+void test_vsnprintf() {
+  char buf[20];
+  __builtin_va_list va;
+  __builtin_vsnprintf(buf, 20, "%.Lf", va);
+}
+
+void test_vsprintf() {
+  char buf[20];
+  __builtin_va_list va;
+  __builtin_vsprintf(buf, "%.Lf", va);
+}
+
+void test_sprintf() {
+  char buf[20];
+  __builtin_sprintf(buf, "%.Lf", x);
+}
+
+void test_snprintf() {
+  char buf[20];
+  __builtin_snprintf(buf, 20, "%.Lf", x);
+}
+
+void test_fprintf() {
+  FILE *fp;
+  __builtin_fprintf(fp, "%.Lf", x):
+}
Index: clang/lib/CodeGen/CGBuiltin.cpp
===
--- clang/lib/CodeGen/CGBuiltin.cpp
+++ clang/lib/CodeGen/CGBuiltin.cpp
@@ -101,8 +101,42 @@
   // that prefix labels.
   if (FD->hasAttr())
 Name = getMangledName(D);
-  else
-Name = Context.BuiltinInfo.getName(BuiltinID) + 10;
+  else {
+// TODO: This mutation should also be applied to other targets other than
+// PPC, after backend supports IEEE 128-bit style libcalls.
+bool UseF128Name =
+getTriple().isPPC64() &&
+().getLongDoubleFormat() == ::APFloat::IEEEquad();
+switch (BuiltinID) {
+case Builtin::BIprintf:
+case Builtin::BI__builtin_printf:
+  Name = UseF128Name ? "__printfieee128" : "printf";
+  break;
+case Builtin::BIvsnprintf:
+case Builtin::BI__builtin_vsnprintf:
+  Name = UseF128Name ? "__vsnprintfieee128" : "vsnprintf";
+  break;
+case Builtin::BIvsprintf:
+case Builtin::BI__builtin_vsprintf:
+  Name = UseF128Name ? "__vsprintfieee128" : "vsprintf";
+  break;
+case Builtin::BIsprintf:
+case Builtin::BI__builtin_sprintf:
+  Name = UseF128Name ? "__sprintfieee128" : "sprintf";
+  break;
+case Builtin::BIsnprintf:
+case Builtin::BI__builtin_snprintf:
+  Name = UseF128Name ? "__snprintfieee128" : "snprintf";
+  break;
+case Builtin::BIfprintf:
+case Builtin::BI__builtin_fprintf:
+  Name = UseF128Name ? "__fprintfieee128" : "fprintf";
+  break;
+default:
+  Name = Context.BuiltinInfo.getName(BuiltinID) + 10;
+  break;
+}
+  }
 
   llvm::FunctionType *Ty =
 cast(getTypes().ConvertType(FD->getType()));


Index: clang/test/CodeGen/ppc64-f128-builtins.c
===
--- /dev/null
+++ clang/test/CodeGen/ppc64-f128-builtins.c
@@ -0,0 +1,37 @@
+// RUN: %clang_cc1 -triple powerpc64le-linux-gnu -emit-llvm -o - %s \
+// RUN:   -mabi=ieeelongdouble | FileCheck --check-prefix=IEEE128 %s
+// RUN: %clang_cc1 -triple powerpc64le-linux-gnu -emit-llvm -o - %s \
+// RUN:   -mabi=ibmlongdouble | FileCheck --check-prefix=PPC128 %s
+
+long double x;
+
+void test_printf() {
+  __builtin_printf("%.Lf", x);
+}
+
+void test_vsnprintf() {
+  char buf[20];
+  __builtin_va_list va;
+  __builtin_vsnprintf(buf, 20, "%.Lf", va);
+}
+
+void test_vsprintf() {
+  char buf[20];
+  __builtin_va_list va;
+  __builtin_vsprintf(buf, "%.Lf", va);
+}
+
+void test_sprintf() {
+  char buf[20];
+  __builtin_sprintf(buf, "%.Lf", x);
+}
+
+void test_snprintf() {
+  char buf[20];
+  __builtin_snprintf(buf, 20, "%.Lf", x);
+}
+
+void test_fprintf() {
+  FILE *fp;
+  __builtin_fprintf(fp, "%.Lf", x):
+}
Index: clang/lib/CodeGen/CGBuiltin.cpp
===
--- clang/lib/CodeGen/CGBuiltin.cpp
+++ clang/lib/CodeGen/CGBuiltin.cpp
@@ -101,8 +101,42 @@
   // that prefix labels.
   if (FD->hasAttr())
 Name = getMangledName(D);
-  else
-Name = Context.BuiltinInfo.getName(BuiltinID) + 10;
+  else {
+// TODO: This mutation should also be applied to other targets other than
+// PPC, after backend supports IEEE 128-bit style libcalls.
+bool UseF128Name =
+getTriple().isPPC64() &&
+().getLongDoubleFormat() == ::APFloat::IEEEquad();
+switch (BuiltinID) {
+case Builtin::BIprintf:
+case Builtin::BI__builtin_printf:
+  Name = UseF128Name ? "__printfieee128" : "printf";
+ 

[PATCH] D108696: [Coroutines] [Frontend] Lookup in std namespace first

2021-10-24 Thread Arthur O'Dwyer via Phabricator via cfe-commits
Quuxplusone added a comment.

In D108696#3082866 , @ChuanqiXu wrote:

> @Quuxplusone gentle ping~

I think this PR is mostly above my pay grade. :)
IIUC, there is a chicken-and-egg problem between D108696 
 and D109433 
? If I understand the situation correctly 
(which maybe I don't), I think you should add D108696 
 as a "Parent Revision" of D109433 
, and tag both of them with //both// "libc++" 
//and// "clang" project tags, and then poke buildkite to re-run the CI on both 
of them. I would hope that D109433 's test 
results would still be green. And then you'd land both D108696 
 and D109433 
 in very quick succession. //But//, I'm not 
going to be an approver on D108696  because 
it's over my head. Originally you pinged @rjmccall @lxfind @junparser ; are 
they still happy with D108696  and the 
general direction we're taking on coroutines stuff in 14.x and 15.x?

(AIUI, the intent is for libc++ 14.x to support both C++11 
`` and C++20 ``, and then in libc++ 15.x to 
support //only// C++20 ``.)




Comment at: clang/test/SemaCXX/coroutine_handle-addres-return-type.cpp:1
 // RUN: %clang_cc1 -verify %s -stdlib=libc++ -std=c++1z -fcoroutines-ts 
-fsyntax-only
 

Pre-existing: in the name of this file, `addres` should be `address`



Comment at: clang/test/SemaCXX/coroutines-exp-namespace.cpp:2
+// This file is the same with coroutines.cpp except the coroutine components 
are defined in std::experimental namespace.
+// This intention of this test is to make sure the legacy imeplementation in 
std::experimental namespace could work.
+// TODO: Remove this test once we didn't support

ldionne wrote:
> 
...and not just "could work," but "works." :)
```
// This file is the same as coroutines.cpp, except the components are defined 
in namespace std::experimental.
// The intent of this test is to make sure the std::experimental implementation 
still works.
// TODO: Remove this test once we drop support for .
```

Also, it occurs to me that you should probably be testing both `` 
and `` in all the other tests, as well; e.g. 
`coroutine_handle-address-return-type.cpp` should have a matching 
`coroutine_handle-address-return-type-exp-namespace.cpp` and so on. Otherwise, 
aren't you removing a lot of regression tests for ``, 
despite that we still claim to support `` in Clang 14.x?

In many cases, it should be possible to do something like
```
// RUN: %clang_cc1 -std=c++14 -fcoroutines-ts -fsyntax-only -verify %s 
-DINCLUDE_EXPERIMENTAL=1
// RUN: %clang_cc1 -std=c++20 -fsyntax-only -verify %s -DINCLUDE_EXPERIMENTAL=0

#if INCLUDE_EXPERIMENTAL
#include 
namespace coro = std::experimental;
#else
#include 
namespace coro = std;
#endif

[...]
```


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

https://reviews.llvm.org/D108696

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


[PATCH] D111866: [RISCV] Support Zfhmin extension

2021-10-24 Thread Shao-Ce SUN via Phabricator via cfe-commits
achieveartificialintelligence added a comment.

Is there any suggestion?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D111866

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


[PATCH] D112399: Get Bazel building `//clang` on Windows with clang-cl.

2021-10-24 Thread Chandler Carruth via Phabricator via cfe-commits
chandlerc created this revision.
chandlerc added a reviewer: GMNGeoffrey.
Herald added a subscriber: mcrosier.
chandlerc requested review of this revision.
Herald added a reviewer: jdoerfert.
Herald added a subscriber: sstefan1.

This required substantially more invasive changes I'm afraid.

First, there is an issue with a Clang header that isn't really robust on
Windows unless you get the includes *just* right. I've reworked it to be
a bit more defensive.

Second, I needed a different approach to get `libclang` working well.
This, IMO, improves things on all platforms. Now we build the plugin and
actually wrap it back up with `cc_import`. We have to use a collection
of manually tagged `cc_binary` rules to get the naming to work out the
right way, but this isn't too different from the prior approach. By
directly having a `cc_binary` rule for each platform spelling of
`libclang`, we can actually extract the interface library from it and
correctly depend on it with `cc_import`. I think the result now is much
closer to the intent and to the CMake build for libclang.

Last but not least, some tests needed disabling. This is actually
narrower than what CMake does. The issue isn't indicative of anything
serious -- the test just assumes Unix-style paths.


https://reviews.llvm.org/D112399

Files:
  clang/include/clang/Basic/Builtins.def
  utils/bazel/.bazelrc
  utils/bazel/llvm-project-overlay/clang/BUILD.bazel
  utils/bazel/llvm-project-overlay/clang/include/clang/Config/config.h
  utils/bazel/llvm-project-overlay/clang/unittests/BUILD.bazel
  utils/bazel/llvm-project-overlay/llvm/cc_plugin_library.bzl

Index: utils/bazel/llvm-project-overlay/llvm/cc_plugin_library.bzl
===
--- utils/bazel/llvm-project-overlay/llvm/cc_plugin_library.bzl
+++ utils/bazel/llvm-project-overlay/llvm/cc_plugin_library.bzl
@@ -4,51 +4,72 @@
 
 """A macro to produce a loadable plugin library for the target OS.
 
-This macro produces a `cc_binary` rule with the name `name + "_impl"`. It
-forces the rule to statically link in its dependencies but to be linked as a
-shared "plugin" library. It then creates binary aliases to `.so`, `.dylib`
-,and `.dll` suffixed names for use on various platforms and selects between
-these into a filegroup with the exact name passed to the macro.
+This macro produces a set of platform-specific `cc_binary` rules, by appending
+the platform suffix (`.dll`, `.dylib`, or `.so`) to the provided `name`. It then
+connects these to a `cc_import` rule with `name` exactly and `hdrs` that can be
+used by other Bazel rules to depend on the plugin library.
+
+The `srcs` attribute for the `cc_binary` rules is `srcs + hdrs`. Other explicit
+arguments are passed to all of the rules where they apply, and can be used to
+configure generic aspects of all generated rules such as `testonly`. Lastly,
+`kwargs` is expanded into all the `cc_binary` rules.
 """
 
-load("@rules_cc//cc:defs.bzl", "cc_binary")
-load(":binary_alias.bzl", "binary_alias")
+load("@rules_cc//cc:defs.bzl", "cc_binary", "cc_import", "cc_library")
 
-def cc_plugin_library(name, **kwargs):
+def cc_plugin_library(name, srcs, hdrs, include_prefix = None, strip_include_prefix = None, alwayslink = False, features = [], tags = [], testonly = False, **kwargs):
 # Neither the name of the plugin binary nor tags on whether it is built are
-# configurable. Instead, we build a `cc_binary` that implements the plugin
-# library using a `_impl` suffix. Bazel will use appropriate flags to cause
-# this file to be a plugin library regardless of its name. We then create
-# binary aliases in the different possible platform names, and select
-# between these different names into a filegroup. The macro's name becomes
-# the filegroup name and it contains exactly one target that is the target
-# platform suffixed plugin library.
+# configurable. Instead, we build a `cc_binary` with each name and
+# selectively depend on them based on platform.
 #
 # All-in-all, this is a pretty poor workaround. I think this is part of the
 # Bazel issue: https://github.com/bazelbuild/bazel/issues/7538
-cc_binary(
-name = name + "_impl",
-linkshared = True,
-linkstatic = True,
-**kwargs
-)
-binary_alias(
-name = name + ".so",
-binary = ":" + name + "_impl",
-)
-binary_alias(
-name = name + ".dll",
-binary = ":" + name + "_impl",
-)
-binary_alias(
-name = name + ".dylib",
-binary = ":" + name + "_impl",
-)
+so_name = name + ".so"
+dll_name = name + ".dll"
+dylib_name = name + ".dylib"
+interface_output_name = name + "_interface_output"
+import_name = name + "_import"
+for impl_name in [dll_name, dylib_name, so_name]:
+cc_binary(
+name = impl_name,
+srcs = srcs + hdrs,
+linkshared = True,
+

[PATCH] D112398: [RISCV] Add ABI testing for Float16.

2021-10-24 Thread Hsiangkai Wang via Phabricator via cfe-commits
HsiangKai created this revision.
HsiangKai added reviewers: craig.topper, kito-cheng, frasercrmck, rogfer01.
Herald added subscribers: achieveartificialintelligence, StephenFan, vkmr, 
evandro, luismarques, apazos, sameer.abuasal, s.egerton, Jim, benna, psnobl, 
jocewei, PkmX, the_o, brucehoult, MartinMosbeck, edward-jones, zzheng, jrtc27, 
shiva0217, niosHD, sabuasal, simoncook, johnrusso, rbar, asb.
HsiangKai requested review of this revision.
Herald added subscribers: cfe-commits, MaskRay.
Herald added a project: clang.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D112398

Files:
  clang/test/CodeGen/RISCV/Float16.c

Index: clang/test/CodeGen/RISCV/Float16.c
===
--- /dev/null
+++ clang/test/CodeGen/RISCV/Float16.c
@@ -0,0 +1,375 @@
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py
+// RUN: %clang_cc1 -triple riscv32 -O0 -target-abi ilp32 -emit-llvm %s \
+// RUN:   -o - | FileCheck --check-prefix=CHECK-NOZFH-ILP32 %s
+// RUN: %clang_cc1 -triple riscv32 -target-feature +experimental-zfh -O0 -target-abi ilp32 -emit-llvm %s \
+// RUN:   -o - | FileCheck --check-prefix=CHECK-ZFH-ILP32 %s
+// RUN: %clang_cc1 -triple riscv32 -O0 -target-abi ilp32f -emit-llvm %s \
+// RUN:   -o - | FileCheck --check-prefix=CHECK-NOZFH-ILP32F %s
+// RUN: %clang_cc1 -triple riscv32 -target-feature +experimental-zfh -O0 -target-abi ilp32f -emit-llvm %s \
+// RUN:   -o - | FileCheck --check-prefix=CHECK-ZFH-ILP32F %s
+
+#include 
+
+_Float16 varg(int num, ...);
+
+// CHECK-NOZFH-ILP32-LABEL: @foo(
+// CHECK-NOZFH-ILP32-NEXT:  entry:
+// CHECK-NOZFH-ILP32-NEXT:[[A_ADDR:%.*]] = alloca half, align 2
+// CHECK-NOZFH-ILP32-NEXT:[[B_ADDR:%.*]] = alloca half, align 2
+// CHECK-NOZFH-ILP32-NEXT:store half [[A:%.*]], half* [[A_ADDR]], align 2
+// CHECK-NOZFH-ILP32-NEXT:store half [[B:%.*]], half* [[B_ADDR]], align 2
+// CHECK-NOZFH-ILP32-NEXT:[[TMP0:%.*]] = load half, half* [[A_ADDR]], align 2
+// CHECK-NOZFH-ILP32-NEXT:[[TMP1:%.*]] = load half, half* [[B_ADDR]], align 2
+// CHECK-NOZFH-ILP32-NEXT:[[ADD:%.*]] = fadd half [[TMP0]], [[TMP1]]
+// CHECK-NOZFH-ILP32-NEXT:ret half [[ADD]]
+//
+// CHECK-ZFH-ILP32-LABEL: @foo(
+// CHECK-ZFH-ILP32-NEXT:  entry:
+// CHECK-ZFH-ILP32-NEXT:[[A_ADDR:%.*]] = alloca half, align 2
+// CHECK-ZFH-ILP32-NEXT:[[B_ADDR:%.*]] = alloca half, align 2
+// CHECK-ZFH-ILP32-NEXT:store half [[A:%.*]], half* [[A_ADDR]], align 2
+// CHECK-ZFH-ILP32-NEXT:store half [[B:%.*]], half* [[B_ADDR]], align 2
+// CHECK-ZFH-ILP32-NEXT:[[TMP0:%.*]] = load half, half* [[A_ADDR]], align 2
+// CHECK-ZFH-ILP32-NEXT:[[TMP1:%.*]] = load half, half* [[B_ADDR]], align 2
+// CHECK-ZFH-ILP32-NEXT:[[ADD:%.*]] = fadd half [[TMP0]], [[TMP1]]
+// CHECK-ZFH-ILP32-NEXT:ret half [[ADD]]
+//
+// CHECK-NOZFH-ILP32F-LABEL: @foo(
+// CHECK-NOZFH-ILP32F-NEXT:  entry:
+// CHECK-NOZFH-ILP32F-NEXT:[[A_ADDR:%.*]] = alloca half, align 2
+// CHECK-NOZFH-ILP32F-NEXT:[[B_ADDR:%.*]] = alloca half, align 2
+// CHECK-NOZFH-ILP32F-NEXT:store half [[A:%.*]], half* [[A_ADDR]], align 2
+// CHECK-NOZFH-ILP32F-NEXT:store half [[B:%.*]], half* [[B_ADDR]], align 2
+// CHECK-NOZFH-ILP32F-NEXT:[[TMP0:%.*]] = load half, half* [[A_ADDR]], align 2
+// CHECK-NOZFH-ILP32F-NEXT:[[TMP1:%.*]] = load half, half* [[B_ADDR]], align 2
+// CHECK-NOZFH-ILP32F-NEXT:[[ADD:%.*]] = fadd half [[TMP0]], [[TMP1]]
+// CHECK-NOZFH-ILP32F-NEXT:ret half [[ADD]]
+//
+// CHECK-ZFH-ILP32F-LABEL: @foo(
+// CHECK-ZFH-ILP32F-NEXT:  entry:
+// CHECK-ZFH-ILP32F-NEXT:[[A_ADDR:%.*]] = alloca half, align 2
+// CHECK-ZFH-ILP32F-NEXT:[[B_ADDR:%.*]] = alloca half, align 2
+// CHECK-ZFH-ILP32F-NEXT:store half [[A:%.*]], half* [[A_ADDR]], align 2
+// CHECK-ZFH-ILP32F-NEXT:store half [[B:%.*]], half* [[B_ADDR]], align 2
+// CHECK-ZFH-ILP32F-NEXT:[[TMP0:%.*]] = load half, half* [[A_ADDR]], align 2
+// CHECK-ZFH-ILP32F-NEXT:[[TMP1:%.*]] = load half, half* [[B_ADDR]], align 2
+// CHECK-ZFH-ILP32F-NEXT:[[ADD:%.*]] = fadd half [[TMP0]], [[TMP1]]
+// CHECK-ZFH-ILP32F-NEXT:ret half [[ADD]]
+//
+_Float16 foo(_Float16 a, _Float16 b) {
+  return a + b;
+}
+
+// CHECK-NOZFH-ILP32-LABEL: @foo1(
+// CHECK-NOZFH-ILP32-NEXT:  entry:
+// CHECK-NOZFH-ILP32-NEXT:[[A_ADDR:%.*]] = alloca half, align 2
+// CHECK-NOZFH-ILP32-NEXT:store half [[A:%.*]], half* [[A_ADDR]], align 2
+// CHECK-NOZFH-ILP32-NEXT:[[TMP0:%.*]] = load half, half* [[A_ADDR]], align 2
+// CHECK-NOZFH-ILP32-NEXT:[[CALL:%.*]] = call half (i32, ...) @varg(i32 1, half [[TMP0]])
+// CHECK-NOZFH-ILP32-NEXT:ret half [[CALL]]
+//
+// CHECK-ZFH-ILP32-LABEL: @foo1(
+// CHECK-ZFH-ILP32-NEXT:  entry:
+// CHECK-ZFH-ILP32-NEXT:[[A_ADDR:%.*]] = alloca half, align 2
+// CHECK-ZFH-ILP32-NEXT:store half [[A:%.*]], half* [[A_ADDR]], align 2
+// CHECK-ZFH-ILP32-NEXT:[[TMP0:%.*]] = load half, half* [[A_ADDR]], align 2

[PATCH] D112158: mips: fix search path for multilib o32

2021-10-24 Thread YunQiang Su via Phabricator via cfe-commits
wzssyqa updated this revision to Diff 381826.
Herald added subscribers: ormris, jrtc27.

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

https://reviews.llvm.org/D112158

Files:
  clang/lib/Driver/ToolChains/Gnu.cpp
  clang/lib/Driver/ToolChains/Linux.cpp
  clang/test/Driver/Inputs/debian_6_mips64_tree/libo32/.keep
  
clang/test/Driver/Inputs/debian_6_mips64_tree/usr/lib/gcc/mips64-linux-gnuabi64/4.9/32/crtbegin.o
  
clang/test/Driver/Inputs/debian_6_mips64_tree/usr/lib/gcc/mips64-linux-gnuabi64/4.9/32/crtend.o
  
clang/test/Driver/Inputs/debian_6_mips64_tree/usr/lib/gcc/mips64-linux-gnuabi64/4.9/n32/crtbegin.o
  
clang/test/Driver/Inputs/debian_6_mips64_tree/usr/lib/gcc/mips64-linux-gnuabi64/4.9/n32/crtend.o
  
clang/test/Driver/Inputs/debian_6_mips64_tree/usr/lib/gcc/mips64el-linux-gnuabi64/4.9/32/crtbegin.o
  
clang/test/Driver/Inputs/debian_6_mips64_tree/usr/lib/gcc/mips64el-linux-gnuabi64/4.9/32/crtend.o
  
clang/test/Driver/Inputs/debian_6_mips64_tree/usr/lib/gcc/mips64el-linux-gnuabi64/4.9/n32/crtbegin.o
  
clang/test/Driver/Inputs/debian_6_mips64_tree/usr/lib/gcc/mips64el-linux-gnuabi64/4.9/n32/crtend.o
  clang/test/Driver/Inputs/debian_6_mips64_tree/usr/libo32/crt1.o
  clang/test/Driver/Inputs/debian_6_mips64_tree/usr/libo32/crti.o
  clang/test/Driver/Inputs/debian_6_mips64_tree/usr/libo32/crtn.o
  clang/test/Driver/linux-ld.c


Index: clang/test/Driver/linux-ld.c
===
--- clang/test/Driver/linux-ld.c
+++ clang/test/Driver/linux-ld.c
@@ -1039,7 +1039,6 @@
 // CHECK-SPARCV9: "-m" "elf64_sparc"
 // CHECK-SPARCV9: "-dynamic-linker" 
"{{(/usr/sparcv9-unknown-linux-gnu)?}}/lib{{(64)?}}/ld-linux.so.2"
 
-
 // Test linker invocation on Android.
 // RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
 // RUN: --target=arm-linux-androideabi -rtlib=platform 
--unwindlib=platform \
@@ -1455,6 +1454,22 @@
 // CHECK-DEBIAN-ML-MIPS64EL-N32: "-L[[SYSROOT]]/usr/lib"
 //
 // RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
+// RUN: --target=mips64el-linux-gnuabi64 -rtlib=platform -mabi=32 \
+// RUN: --gcc-toolchain="" \
+// RUN: --sysroot=%S/Inputs/debian_6_mips64_tree \
+// RUN:   | FileCheck --check-prefix=CHECK-DEBIAN-ML-MIPS64EL-O32 %s
+// CHECK-DEBIAN-ML-MIPS64EL-O32: "{{.*}}ld{{(.exe)?}}" 
"--sysroot=[[SYSROOT:[^"]+]]"
+// CHECK-DEBIAN-ML-MIPS64EL-O32: 
"{{.*}}/usr/lib/gcc/mips64el-linux-gnuabi64/4.9/../../../../libo32{{/|}}crt1.o"
+// CHECK-DEBIAN-ML-MIPS64EL-O32: 
"{{.*}}/usr/lib/gcc/mips64el-linux-gnuabi64/4.9/../../../../libo32{{/|}}crti.o"
+// CHECK-DEBIAN-ML-MIPS64EL-O32: 
"{{.*}}/usr/lib/gcc/mips64el-linux-gnuabi64/4.9/32{{/|}}crtbegin.o"
+// CHECK-DEBIAN-ML-MIPS64EL-O32: 
"-L[[SYSROOT]]/usr/lib/gcc/mips64el-linux-gnuabi64/4.9/32"
+// CHECK-DEBIAN-ML-MIPS64EL-O32: 
"-L[[SYSROOT]]/usr/lib/gcc/mips64el-linux-gnuabi64/4.9/../../../../libo32"
+// CHECK-DEBIAN-ML-MIPS64EL-O32: "-L[[SYSROOT]]/libo32"
+// CHECK-DEBIAN-ML-MIPS64EL-O32: "-L[[SYSROOT]]/usr/libo32"
+// CHECK-DEBIAN-ML-MIPS64EL-O32: "-L[[SYSROOT]]/lib"
+// CHECK-DEBIAN-ML-MIPS64EL-O32: "-L[[SYSROOT]]/usr/lib"
+//
+// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
 // RUN: --target=mips64-unknown-linux-gnu --rtlib=platform \
 // RUN: --gcc-toolchain="" \
 // RUN: --sysroot=%S/Inputs/debian_6_mips64_tree \
Index: clang/lib/Driver/ToolChains/Linux.cpp
===
--- clang/lib/Driver/ToolChains/Linux.cpp
+++ clang/lib/Driver/ToolChains/Linux.cpp
@@ -261,6 +261,13 @@
   const std::string OSLibDir = std::string(getOSLibDir(Triple, Args));
   const std::string MultiarchTriple = getMultiarchTriple(D, Triple, SysRoot);
 
+  // mips32: Debian multilib, we use /libo32, while in other case, /lib is
+  // used. We need add both libo32 and /lib.
+  if (Arch == llvm::Triple::mips || Arch == llvm::Triple::mipsel) {
+Generic_GCC::AddMultilibPaths(D, SysRoot, "libo32", MultiarchTriple, 
Paths);
+addPathIfExists(D, SysRoot + "/libo32", Paths);
+addPathIfExists(D, SysRoot + "/usr/libo32", Paths);
+  }
   Generic_GCC::AddMultilibPaths(D, SysRoot, OSLibDir, MultiarchTriple, Paths);
 
   addPathIfExists(D, SysRoot + "/lib/" + MultiarchTriple, Paths);
Index: clang/lib/Driver/ToolChains/Gnu.cpp
===
--- clang/lib/Driver/ToolChains/Gnu.cpp
+++ clang/lib/Driver/ToolChains/Gnu.cpp
@@ -1081,7 +1081,8 @@
.flag("-m32")
.flag("-mabi=n32");
 
-Multilib M32 = Multilib().flag("-m64").flag("+m32").flag("-mabi=n32");
+Multilib M32 =
+
Multilib().gccSuffix("/32").flag("-m64").flag("+m32").flag("-mabi=n32");
 
 DebianMipsMultilibs =
 MultilibSet().Either(M32, M64, MAbiN32).FilterOut(NonExistent);
@@ -2120,11 +2121,11 @@
   static const char *const M68kTriples[] = {
   "m68k-linux-gnu", "m68k-unknown-linux-gnu", "m68k-suse-linux"};

[PATCH] D109632: [clang] de-duplicate methods from AST files

2021-10-24 Thread Volodymyr Sapsai via Phabricator via cfe-commits
vsapsai added a comment.

Raw data with some additional visualization is available at 
https://observablehq.com/@vsapsai/method_pool-performance-comparison


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109632

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


[PATCH] D108696: [Coroutines] [Frontend] Lookup in std namespace first

2021-10-24 Thread Chuanqi Xu via Phabricator via cfe-commits
ChuanqiXu added a comment.

@Quuxplusone gentle ping~


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

https://reviews.llvm.org/D108696

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


[PATCH] D112390: [AIX][ZOS] Disable module tests due to lack of Objective-C support

2021-10-24 Thread Jake Egan via Phabricator via cfe-commits
Jake-Egan updated this revision to Diff 381814.
Jake-Egan edited the summary of this revision.
Jake-Egan added a comment.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Add llvm/test/DebugInfo/X86/objc_direct.ll


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112390

Files:
  clang/test/Modules/ModuleDebugInfo.cpp
  clang/test/Modules/ModuleDebugInfo.m
  clang/test/Modules/clang_module_file_info.m
  clang/test/Modules/debug-info-moduleimport-in-module.m
  clang/test/Modules/module-debuginfo-prefix.m
  llvm/test/DebugInfo/X86/objc_direct.ll


Index: llvm/test/DebugInfo/X86/objc_direct.ll
===
--- llvm/test/DebugInfo/X86/objc_direct.ll
+++ llvm/test/DebugInfo/X86/objc_direct.ll
@@ -1,3 +1,4 @@
+// UNSUPPORTED: -zos, -aix
 ; RUN: llc < %s -filetype=obj -o %t
 ; RUN: llvm-dwarfdump -v %t | FileCheck %s
 
Index: clang/test/Modules/module-debuginfo-prefix.m
===
--- clang/test/Modules/module-debuginfo-prefix.m
+++ clang/test/Modules/module-debuginfo-prefix.m
@@ -1,3 +1,4 @@
+// UNSUPPORTED: -zos, -aix
 // REQUIRES: asserts
 
 // Modules:
Index: clang/test/Modules/debug-info-moduleimport-in-module.m
===
--- clang/test/Modules/debug-info-moduleimport-in-module.m
+++ clang/test/Modules/debug-info-moduleimport-in-module.m
@@ -1,3 +1,4 @@
+// UNSUPPORTED: -zos, -aix
 // Test that an @import inside a module is not represented in the debug info.
 
 // REQUIRES: asserts
Index: clang/test/Modules/clang_module_file_info.m
===
--- clang/test/Modules/clang_module_file_info.m
+++ clang/test/Modules/clang_module_file_info.m
@@ -1,4 +1,4 @@
-
+// UNSUPPORTED: -zos, -aix
 @import DependsOnModule;
 
 // RUN: rm -rf %t %t-obj
Index: clang/test/Modules/ModuleDebugInfo.m
===
--- clang/test/Modules/ModuleDebugInfo.m
+++ clang/test/Modules/ModuleDebugInfo.m
@@ -1,3 +1,4 @@
+// UNSUPPORTED: -zos, -aix
 // Test that debug info is emitted for an Objective-C module and
 // a precompiled header.
 
Index: clang/test/Modules/ModuleDebugInfo.cpp
===
--- clang/test/Modules/ModuleDebugInfo.cpp
+++ clang/test/Modules/ModuleDebugInfo.cpp
@@ -1,3 +1,4 @@
+// UNSUPPORTED: -zos, -aix
 // Test that (the same) debug info is emitted for an Objective-C++
 // module and a C++ precompiled header.
 


Index: llvm/test/DebugInfo/X86/objc_direct.ll
===
--- llvm/test/DebugInfo/X86/objc_direct.ll
+++ llvm/test/DebugInfo/X86/objc_direct.ll
@@ -1,3 +1,4 @@
+// UNSUPPORTED: -zos, -aix
 ; RUN: llc < %s -filetype=obj -o %t
 ; RUN: llvm-dwarfdump -v %t | FileCheck %s
 
Index: clang/test/Modules/module-debuginfo-prefix.m
===
--- clang/test/Modules/module-debuginfo-prefix.m
+++ clang/test/Modules/module-debuginfo-prefix.m
@@ -1,3 +1,4 @@
+// UNSUPPORTED: -zos, -aix
 // REQUIRES: asserts
 
 // Modules:
Index: clang/test/Modules/debug-info-moduleimport-in-module.m
===
--- clang/test/Modules/debug-info-moduleimport-in-module.m
+++ clang/test/Modules/debug-info-moduleimport-in-module.m
@@ -1,3 +1,4 @@
+// UNSUPPORTED: -zos, -aix
 // Test that an @import inside a module is not represented in the debug info.
 
 // REQUIRES: asserts
Index: clang/test/Modules/clang_module_file_info.m
===
--- clang/test/Modules/clang_module_file_info.m
+++ clang/test/Modules/clang_module_file_info.m
@@ -1,4 +1,4 @@
-
+// UNSUPPORTED: -zos, -aix
 @import DependsOnModule;
 
 // RUN: rm -rf %t %t-obj
Index: clang/test/Modules/ModuleDebugInfo.m
===
--- clang/test/Modules/ModuleDebugInfo.m
+++ clang/test/Modules/ModuleDebugInfo.m
@@ -1,3 +1,4 @@
+// UNSUPPORTED: -zos, -aix
 // Test that debug info is emitted for an Objective-C module and
 // a precompiled header.
 
Index: clang/test/Modules/ModuleDebugInfo.cpp
===
--- clang/test/Modules/ModuleDebugInfo.cpp
+++ clang/test/Modules/ModuleDebugInfo.cpp
@@ -1,3 +1,4 @@
+// UNSUPPORTED: -zos, -aix
 // Test that (the same) debug info is emitted for an Objective-C++
 // module and a C++ precompiled header.
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D112102: [RISCV] Reduce the number of RISCV vector builtins by an order of magnitude.

2021-10-24 Thread Zakk Chen via Phabricator via cfe-commits
khchen added a comment.

LGTM, too.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112102

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


[clang] 4bd4650 - Use llvm::any_of and llvm::none_of (NFC)

2021-10-24 Thread Kazu Hirata via cfe-commits

Author: Kazu Hirata
Date: 2021-10-24T17:35:33-07:00
New Revision: 4bd46501c394ce221d34b60155f48ebbf6b6897d

URL: 
https://github.com/llvm/llvm-project/commit/4bd46501c394ce221d34b60155f48ebbf6b6897d
DIFF: 
https://github.com/llvm/llvm-project/commit/4bd46501c394ce221d34b60155f48ebbf6b6897d.diff

LOG: Use llvm::any_of and llvm::none_of (NFC)

Added: 


Modified: 
clang/include/clang/AST/DeclContextInternals.h
clang/lib/Analysis/CFG.cpp
clang/lib/Analysis/ThreadSafety.cpp
clang/lib/Basic/Targets/AVR.cpp
clang/lib/CodeGen/CGGPUBuiltin.cpp
clang/lib/CodeGen/CoverageMappingGen.cpp
clang/lib/Driver/ToolChains/Clang.cpp
clang/lib/Format/UnwrappedLineParser.cpp
clang/lib/Parse/ParseExprCXX.cpp
clang/lib/Sema/AnalysisBasedWarnings.cpp
clang/lib/Sema/SemaDeclCXX.cpp
clang/lib/Sema/SemaTemplateVariadic.cpp
clang/utils/TableGen/ClangAttrEmitter.cpp
clang/utils/TableGen/NeonEmitter.cpp
lld/ELF/SyntheticSections.cpp
lld/wasm/Writer.cpp
lldb/source/Plugins/Platform/Windows/PlatformWindows.cpp
lldb/source/Utility/VMRange.cpp
llvm/lib/Analysis/AssumptionCache.cpp
llvm/lib/Analysis/LoopCacheAnalysis.cpp
llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp
llvm/lib/Support/TimeProfiler.cpp
llvm/lib/Target/Hexagon/HexagonBitSimplify.cpp

Removed: 




diff  --git a/clang/include/clang/AST/DeclContextInternals.h 
b/clang/include/clang/AST/DeclContextInternals.h
index 2eef2343b7500..9899fc29b82d6 100644
--- a/clang/include/clang/AST/DeclContextInternals.h
+++ b/clang/include/clang/AST/DeclContextInternals.h
@@ -78,8 +78,7 @@ class StoredDeclsList {
 }
 Data.setPointer(NewHead);
 
-assert(llvm::find_if(getLookupResult(), ShouldErase) ==
-   getLookupResult().end() && "Still exists!");
+assert(llvm::none_of(getLookupResult(), ShouldErase) && "Still exists!");
   }
 
   void erase(NamedDecl *ND) {

diff  --git a/clang/lib/Analysis/CFG.cpp b/clang/lib/Analysis/CFG.cpp
index 69b745c8b4518..8a3051a2f9eed 100644
--- a/clang/lib/Analysis/CFG.cpp
+++ b/clang/lib/Analysis/CFG.cpp
@@ -5912,7 +5912,7 @@ static bool isImmediateSinkBlock(const CFGBlock *Blk) {
   // at least for now, but once we have better support for exceptions,
   // we'd need to carefully handle the case when the throw is being
   // immediately caught.
-  if (std::any_of(Blk->begin(), Blk->end(), [](const CFGElement ) {
+  if (llvm::any_of(*Blk, [](const CFGElement ) {
 if (Optional StmtElm = Elm.getAs())
   if (isa(StmtElm->getStmt()))
 return true;

diff  --git a/clang/lib/Analysis/ThreadSafety.cpp 
b/clang/lib/Analysis/ThreadSafety.cpp
index d6bb8cf673f75..b196ffa73cbfb 100644
--- a/clang/lib/Analysis/ThreadSafety.cpp
+++ b/clang/lib/Analysis/ThreadSafety.cpp
@@ -86,11 +86,9 @@ class CapExprSet : public SmallVector {
 public:
   /// Push M onto list, but discard duplicates.
   void push_back_nodup(const CapabilityExpr ) {
-iterator It = std::find_if(begin(), end(),
-   [=](const CapabilityExpr ) {
-  return CapE.equals(CapE2);
-});
-if (It == end())
+if (llvm::none_of(*this, [=](const CapabilityExpr ) {
+  return CapE.equals(CapE2);
+}))
   push_back(CapE);
   }
 };

diff  --git a/clang/lib/Basic/Targets/AVR.cpp b/clang/lib/Basic/Targets/AVR.cpp
index 38ce61386bb4c..50b0fc07b3118 100644
--- a/clang/lib/Basic/Targets/AVR.cpp
+++ b/clang/lib/Basic/Targets/AVR.cpp
@@ -313,10 +313,8 @@ static constexpr llvm::StringLiteral ValidFamilyNames[] = {
 bool AVRTargetInfo::isValidCPUName(StringRef Name) const {
   bool IsFamily = llvm::is_contained(ValidFamilyNames, Name);
 
-  bool IsMCU =
-  llvm::find_if(AVRMcus, [&](const MCUInfo ) {
-return Info.Name == Name;
-  }) != std::end(AVRMcus);
+  bool IsMCU = llvm::any_of(
+  AVRMcus, [&](const MCUInfo ) { return Info.Name == Name; });
   return IsFamily || IsMCU;
 }
 

diff  --git a/clang/lib/CodeGen/CGGPUBuiltin.cpp 
b/clang/lib/CodeGen/CGGPUBuiltin.cpp
index f860623e2bc37..afbebd070c054 100644
--- a/clang/lib/CodeGen/CGGPUBuiltin.cpp
+++ b/clang/lib/CodeGen/CGGPUBuiltin.cpp
@@ -83,7 +83,7 @@ CodeGenFunction::EmitNVPTXDevicePrintfCallExpr(const CallExpr 
*E,
/* ParamsToSkip = */ 0);
 
   // We don't know how to emit non-scalar varargs.
-  if (std::any_of(Args.begin() + 1, Args.end(), [&](const CallArg ) {
+  if (llvm::any_of(llvm::drop_begin(Args), [&](const CallArg ) {
 return !A.getRValue(*this).isScalar();
   })) {
 CGM.ErrorUnsupported(E, "non-scalar arg to printf");

diff  --git a/clang/lib/CodeGen/CoverageMappingGen.cpp 
b/clang/lib/CodeGen/CoverageMappingGen.cpp
index 8a11da600e4a1..2d11495b4ff0a 100644
--- a/clang/lib/CodeGen/CoverageMappingGen.cpp
+++ b/clang/lib/CodeGen/CoverageMappingGen.cpp
@@ -751,13 +751,11 @@ struct CounterCoverageMappingBuilder
   /// is already added to \c 

[PATCH] D112390: [AIX][ZOS] Disable module tests due to lack of Objective-C support

2021-10-24 Thread Jake Egan via Phabricator via cfe-commits
Jake-Egan created this revision.
Jake-Egan requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D112390

Files:
  clang/test/Modules/ModuleDebugInfo.cpp
  clang/test/Modules/ModuleDebugInfo.m
  clang/test/Modules/clang_module_file_info.m
  clang/test/Modules/debug-info-moduleimport-in-module.m
  clang/test/Modules/module-debuginfo-prefix.m


Index: clang/test/Modules/module-debuginfo-prefix.m
===
--- clang/test/Modules/module-debuginfo-prefix.m
+++ clang/test/Modules/module-debuginfo-prefix.m
@@ -1,3 +1,4 @@
+// UNSUPPORTED: -zos, -aix
 // REQUIRES: asserts
 
 // Modules:
Index: clang/test/Modules/debug-info-moduleimport-in-module.m
===
--- clang/test/Modules/debug-info-moduleimport-in-module.m
+++ clang/test/Modules/debug-info-moduleimport-in-module.m
@@ -1,3 +1,4 @@
+// UNSUPPORTED: -zos, -aix
 // Test that an @import inside a module is not represented in the debug info.
 
 // REQUIRES: asserts
Index: clang/test/Modules/clang_module_file_info.m
===
--- clang/test/Modules/clang_module_file_info.m
+++ clang/test/Modules/clang_module_file_info.m
@@ -1,4 +1,4 @@
-
+// UNSUPPORTED: -zos, -aix
 @import DependsOnModule;
 
 // RUN: rm -rf %t %t-obj
Index: clang/test/Modules/ModuleDebugInfo.m
===
--- clang/test/Modules/ModuleDebugInfo.m
+++ clang/test/Modules/ModuleDebugInfo.m
@@ -1,3 +1,4 @@
+// UNSUPPORTED: -zos, -aix
 // Test that debug info is emitted for an Objective-C module and
 // a precompiled header.
 
Index: clang/test/Modules/ModuleDebugInfo.cpp
===
--- clang/test/Modules/ModuleDebugInfo.cpp
+++ clang/test/Modules/ModuleDebugInfo.cpp
@@ -1,3 +1,4 @@
+// UNSUPPORTED: -zos, -aix
 // Test that (the same) debug info is emitted for an Objective-C++
 // module and a C++ precompiled header.
 


Index: clang/test/Modules/module-debuginfo-prefix.m
===
--- clang/test/Modules/module-debuginfo-prefix.m
+++ clang/test/Modules/module-debuginfo-prefix.m
@@ -1,3 +1,4 @@
+// UNSUPPORTED: -zos, -aix
 // REQUIRES: asserts
 
 // Modules:
Index: clang/test/Modules/debug-info-moduleimport-in-module.m
===
--- clang/test/Modules/debug-info-moduleimport-in-module.m
+++ clang/test/Modules/debug-info-moduleimport-in-module.m
@@ -1,3 +1,4 @@
+// UNSUPPORTED: -zos, -aix
 // Test that an @import inside a module is not represented in the debug info.
 
 // REQUIRES: asserts
Index: clang/test/Modules/clang_module_file_info.m
===
--- clang/test/Modules/clang_module_file_info.m
+++ clang/test/Modules/clang_module_file_info.m
@@ -1,4 +1,4 @@
-
+// UNSUPPORTED: -zos, -aix
 @import DependsOnModule;
 
 // RUN: rm -rf %t %t-obj
Index: clang/test/Modules/ModuleDebugInfo.m
===
--- clang/test/Modules/ModuleDebugInfo.m
+++ clang/test/Modules/ModuleDebugInfo.m
@@ -1,3 +1,4 @@
+// UNSUPPORTED: -zos, -aix
 // Test that debug info is emitted for an Objective-C module and
 // a precompiled header.
 
Index: clang/test/Modules/ModuleDebugInfo.cpp
===
--- clang/test/Modules/ModuleDebugInfo.cpp
+++ clang/test/Modules/ModuleDebugInfo.cpp
@@ -1,3 +1,4 @@
+// UNSUPPORTED: -zos, -aix
 // Test that (the same) debug info is emitted for an Objective-C++
 // module and a C++ precompiled header.
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D106674: Runtime for Interop directive

2021-10-24 Thread Sri Hari Krishna Narayanan via Phabricator via cfe-commits
sriharikrishna marked 3 inline comments as done.
sriharikrishna added inline comments.



Comment at: openmp/libomptarget/src/interop.cpp:239-242
+  if (interop_val->interop_type == kmp_interop_type_tasksync) {
+__kmpc_omp_wait_deps(loc_ref, gtid, ndeps, dep_list, ndeps_noalias,
+ noalias_dep_list);
+  }

RaviNarayanaswamy wrote:
> Need to flush the queue if interop object was created with targetsync
A TODO has been left because flushing is not supported.



Comment at: openmp/libomptarget/src/interop.cpp:260-263
+  if (interop_val->interop_type == kmp_interop_type_tasksync) {
+__kmpc_omp_wait_deps(loc_ref, gtid, ndeps, dep_list, ndeps_noalias,
+ noalias_dep_list);
+  }

jdoerfert wrote:
> RaviNarayanaswamy wrote:
> > You don't wait for the omp tasks.  Need to flush the queue associated with 
> > the interop through the plugin
> Waiting for omp task is necessary and the above should do it. Flushing and 
> signaling out dependences will be added in the next revision.
A TODOs been left because flushing is not supported.



Comment at: openmp/runtime/src/kmp_ftn_entry.h:1449-1494
+/// TODO: Include the `omp.h` of the current build
+/* OpenMP 5.1 interop */
+typedef intptr_t omp_intptr_t;
+
+/* 0..omp_get_num_interop_properties()-1 are reserved for 
implementation-defined
+ * properties */
+typedef enum omp_interop_property {

jdoerfert wrote:
> RaviNarayanaswamy wrote:
> > Why do you have all this in openmp/runtime.  Openmp should call 
> > libomptarget to get interop properties. if libomptarget is not loaded it 
> > should return 0
> That is exactly what this code does, no? Look for libomptarget and redirect 
> to that one, otherwise return 0.
> Unsure I see your point. FWIW, this is copied from other functions we 
> duplicate in libomp but that actually are part of libomptarget.
Im leaving it as is.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D106674

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


[PATCH] D106674: Runtime for Interop directive

2021-10-24 Thread Sri Hari Krishna Narayanan via Phabricator via cfe-commits
sriharikrishna updated this revision to Diff 381801.
sriharikrishna marked 16 inline comments as done.
sriharikrishna added a comment.

Runtime for Interop directive


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D106674

Files:
  openmp/libomptarget/include/interop.h
  openmp/libomptarget/include/omptarget.h
  openmp/libomptarget/include/omptargetplugin.h
  openmp/libomptarget/plugins/cuda/src/rtl.cpp
  openmp/libomptarget/plugins/exports
  openmp/libomptarget/src/CMakeLists.txt
  openmp/libomptarget/src/exports
  openmp/libomptarget/src/interop.cpp
  openmp/libomptarget/src/private.h
  openmp/libomptarget/src/rtl.cpp
  openmp/libomptarget/src/rtl.h
  openmp/libomptarget/test/offloading/interop.c
  openmp/runtime/src/dllexports
  openmp/runtime/src/kmp_ftn_entry.h
  openmp/runtime/src/kmp_ftn_os.h

Index: openmp/runtime/src/kmp_ftn_os.h
===
--- openmp/runtime/src/kmp_ftn_os.h
+++ openmp/runtime/src/kmp_ftn_os.h
@@ -140,6 +140,14 @@
 #define FTN_SET_TEAMS_THREAD_LIMIT omp_set_teams_thread_limit
 #define FTN_GET_TEAMS_THREAD_LIMIT omp_get_teams_thread_limit
 
+#define FTN_GET_NUM_INTEROP_PROPERTIES omp_get_num_interop_properties
+#define FTN_GET_INTEROP_INT omp_get_interop_int
+#define FTN_GET_INTEROP_PTR omp_get_interop_ptr
+#define FTN_GET_INTEROP_STR omp_get_interop_str
+#define FTN_GET_INTEROP_NAME omp_get_interop_name
+#define FTN_GET_INTEROP_TYPE_DESC omp_get_interop_type_desc
+#define FTN_GET_INTEROP_RC_DESC omp_get_interop_rc_desc
+
 #endif /* KMP_FTN_PLAIN */
 
 /*  */
Index: openmp/runtime/src/kmp_ftn_entry.h
===
--- openmp/runtime/src/kmp_ftn_entry.h
+++ openmp/runtime/src/kmp_ftn_entry.h
@@ -1446,6 +1446,120 @@
 #endif
 }
 
+/// TODO: Include the `omp.h` of the current build
+/* OpenMP 5.1 interop */
+typedef intptr_t omp_intptr_t;
+
+/* 0..omp_get_num_interop_properties()-1 are reserved for implementation-defined
+ * properties */
+typedef enum omp_interop_property {
+  omp_ipr_fr_id = -1,
+  omp_ipr_fr_name = -2,
+  omp_ipr_vendor = -3,
+  omp_ipr_vendor_name = -4,
+  omp_ipr_device_num = -5,
+  omp_ipr_platform = -6,
+  omp_ipr_device = -7,
+  omp_ipr_device_context = -8,
+  omp_ipr_targetsync = -9,
+  omp_ipr_first = -9
+} omp_interop_property_t;
+
+#define omp_interop_none 0
+
+typedef enum omp_interop_rc {
+  omp_irc_no_value = 1,
+  omp_irc_success = 0,
+  omp_irc_empty = -1,
+  omp_irc_out_of_range = -2,
+  omp_irc_type_int = -3,
+  omp_irc_type_ptr = -4,
+  omp_irc_type_str = -5,
+  omp_irc_other = -6
+} omp_interop_rc_t;
+
+typedef enum omp_interop_fr {
+  omp_ifr_cuda = 1,
+  omp_ifr_cuda_driver = 2,
+  omp_ifr_opencl = 3,
+  omp_ifr_sycl = 4,
+  omp_ifr_hip = 5,
+  omp_ifr_level_zero = 6,
+  omp_ifr_last = 7
+} omp_interop_fr_t;
+
+typedef void *omp_interop_t;
+
+// libomptarget, if loaded, provides this function
+int FTN_STDCALL FTN_GET_NUM_INTEROP_PROPERTIES(const omp_interop_t interop) {
+#if KMP_MIC || KMP_OS_DARWIN || defined(KMP_STUB)
+  return 0;
+#else
+  int (*fptr)(const omp_interop_t);
+  if ((*(void **)() = KMP_DLSYM_NEXT("omp_get_num_interop_properties")))
+return (*fptr)(interop);
+  return 0;
+#endif // KMP_MIC || KMP_OS_DARWIN || KMP_OS_WINDOWS || defined(KMP_STUB)
+}
+
+/// TODO Convert FTN_GET_INTEROP_XXX functions into a macro like interop.cpp
+// libomptarget, if loaded, provides this function
+intptr_t FTN_STDCALL FTN_GET_INTEROP_INT(const omp_interop_t interop,
+ omp_interop_property_t property_id,
+ int *err) {
+  intptr_t (*fptr)(const omp_interop_t, omp_interop_property_t, int *);
+  if ((*(void **)() = KMP_DLSYM_NEXT("omp_get_interop_int")))
+return (*fptr)(interop, property_id, err);
+  return 0;
+}
+
+// libomptarget, if loaded, provides this function
+void *FTN_STDCALL FTN_GET_INTEROP_PTR(const omp_interop_t interop,
+  omp_interop_property_t property_id,
+  int *err) {
+  void *(*fptr)(const omp_interop_t, omp_interop_property_t, int *);
+  if ((*(void **)() = KMP_DLSYM_NEXT("omp_get_interop_ptr")))
+return (*fptr)(interop, property_id, err);
+  return nullptr;
+}
+
+// libomptarget, if loaded, provides this function
+const char *FTN_STDCALL FTN_GET_INTEROP_STR(const omp_interop_t interop,
+omp_interop_property_t property_id,
+int *err) {
+  const char *(*fptr)(const omp_interop_t, omp_interop_property_t, int *);
+  if ((*(void **)() = KMP_DLSYM_NEXT("omp_get_interop_str")))
+return (*fptr)(interop, property_id, err);
+  return nullptr;
+}
+
+// libomptarget, if loaded, provides this function
+const char *FTN_STDCALL 

[PATCH] D106674: Runtime for Interop directive

2021-10-24 Thread Sri Hari Krishna Narayanan via Phabricator via cfe-commits
sriharikrishna updated this revision to Diff 381800.
sriharikrishna added a comment.

Runtime for Interop directive


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D106674

Files:
  openmp/libomptarget/include/interop.h
  openmp/libomptarget/include/omptarget.h
  openmp/libomptarget/include/omptargetplugin.h
  openmp/libomptarget/plugins/cuda/src/rtl.cpp
  openmp/libomptarget/plugins/exports
  openmp/libomptarget/src/CMakeLists.txt
  openmp/libomptarget/src/exports
  openmp/libomptarget/src/interop.cpp
  openmp/libomptarget/src/private.h
  openmp/libomptarget/src/rtl.cpp
  openmp/libomptarget/src/rtl.h
  openmp/libomptarget/test/offloading/interop.c
  openmp/runtime/src/dllexports
  openmp/runtime/src/kmp_ftn_entry.h
  openmp/runtime/src/kmp_ftn_os.h

Index: openmp/runtime/src/kmp_ftn_os.h
===
--- openmp/runtime/src/kmp_ftn_os.h
+++ openmp/runtime/src/kmp_ftn_os.h
@@ -140,6 +140,14 @@
 #define FTN_SET_TEAMS_THREAD_LIMIT omp_set_teams_thread_limit
 #define FTN_GET_TEAMS_THREAD_LIMIT omp_get_teams_thread_limit
 
+#define FTN_GET_NUM_INTEROP_PROPERTIES omp_get_num_interop_properties
+#define FTN_GET_INTEROP_INT omp_get_interop_int
+#define FTN_GET_INTEROP_PTR omp_get_interop_ptr
+#define FTN_GET_INTEROP_STR omp_get_interop_str
+#define FTN_GET_INTEROP_NAME omp_get_interop_name
+#define FTN_GET_INTEROP_TYPE_DESC omp_get_interop_type_desc
+#define FTN_GET_INTEROP_RC_DESC omp_get_interop_rc_desc
+
 #endif /* KMP_FTN_PLAIN */
 
 /*  */
Index: openmp/runtime/src/kmp_ftn_entry.h
===
--- openmp/runtime/src/kmp_ftn_entry.h
+++ openmp/runtime/src/kmp_ftn_entry.h
@@ -1446,6 +1446,120 @@
 #endif
 }
 
+/// TODO: Include the `omp.h` of the current build
+/* OpenMP 5.1 interop */
+typedef intptr_t omp_intptr_t;
+
+/* 0..omp_get_num_interop_properties()-1 are reserved for implementation-defined
+ * properties */
+typedef enum omp_interop_property {
+  omp_ipr_fr_id = -1,
+  omp_ipr_fr_name = -2,
+  omp_ipr_vendor = -3,
+  omp_ipr_vendor_name = -4,
+  omp_ipr_device_num = -5,
+  omp_ipr_platform = -6,
+  omp_ipr_device = -7,
+  omp_ipr_device_context = -8,
+  omp_ipr_targetsync = -9,
+  omp_ipr_first = -9
+} omp_interop_property_t;
+
+#define omp_interop_none 0
+
+typedef enum omp_interop_rc {
+  omp_irc_no_value = 1,
+  omp_irc_success = 0,
+  omp_irc_empty = -1,
+  omp_irc_out_of_range = -2,
+  omp_irc_type_int = -3,
+  omp_irc_type_ptr = -4,
+  omp_irc_type_str = -5,
+  omp_irc_other = -6
+} omp_interop_rc_t;
+
+typedef enum omp_interop_fr {
+  omp_ifr_cuda = 1,
+  omp_ifr_cuda_driver = 2,
+  omp_ifr_opencl = 3,
+  omp_ifr_sycl = 4,
+  omp_ifr_hip = 5,
+  omp_ifr_level_zero = 6,
+  omp_ifr_last = 7
+} omp_interop_fr_t;
+
+typedef void *omp_interop_t;
+
+// libomptarget, if loaded, provides this function
+int FTN_STDCALL FTN_GET_NUM_INTEROP_PROPERTIES(const omp_interop_t interop) {
+#if KMP_MIC || KMP_OS_DARWIN || defined(KMP_STUB)
+  return 0;
+#else
+  int (*fptr)(const omp_interop_t);
+  if ((*(void **)() = KMP_DLSYM_NEXT("omp_get_num_interop_properties")))
+return (*fptr)(interop);
+  return 0;
+#endif // KMP_MIC || KMP_OS_DARWIN || KMP_OS_WINDOWS || defined(KMP_STUB)
+}
+
+/// TODO Convert FTN_GET_INTEROP_XXX functions into a macro like interop.cpp
+// libomptarget, if loaded, provides this function
+intptr_t FTN_STDCALL FTN_GET_INTEROP_INT(const omp_interop_t interop,
+ omp_interop_property_t property_id,
+ int *err) {
+  intptr_t (*fptr)(const omp_interop_t, omp_interop_property_t, int *);
+  if ((*(void **)() = KMP_DLSYM_NEXT("omp_get_interop_int")))
+return (*fptr)(interop, property_id, err);
+  return 0;
+}
+
+// libomptarget, if loaded, provides this function
+void *FTN_STDCALL FTN_GET_INTEROP_PTR(const omp_interop_t interop,
+  omp_interop_property_t property_id,
+  int *err) {
+  void *(*fptr)(const omp_interop_t, omp_interop_property_t, int *);
+  if ((*(void **)() = KMP_DLSYM_NEXT("omp_get_interop_ptr")))
+return (*fptr)(interop, property_id, err);
+  return nullptr;
+}
+
+// libomptarget, if loaded, provides this function
+const char *FTN_STDCALL FTN_GET_INTEROP_STR(const omp_interop_t interop,
+omp_interop_property_t property_id,
+int *err) {
+  const char *(*fptr)(const omp_interop_t, omp_interop_property_t, int *);
+  if ((*(void **)() = KMP_DLSYM_NEXT("omp_get_interop_str")))
+return (*fptr)(interop, property_id, err);
+  return nullptr;
+}
+
+// libomptarget, if loaded, provides this function
+const char *FTN_STDCALL FTN_GET_INTEROP_NAME(
+const omp_interop_t 

[PATCH] D111952: [clang] [MinGW] Guess the right ix86 arch name spelling as sysroot

2021-10-24 Thread Martin Storsjö via Phabricator via cfe-commits
mstorsjo updated this revision to Diff 381795.
mstorsjo added a comment.

Moved the fixup into `computeTargetTriple`, so it's only done after applying 
the `-m32`/`-m64` options.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D111952

Files:
  clang/lib/Driver/Driver.cpp
  clang/lib/Driver/ToolChains/MinGW.cpp
  clang/lib/Driver/ToolChains/MinGW.h
  clang/test/Driver/mingw-sysroot.cpp

Index: clang/test/Driver/mingw-sysroot.cpp
===
--- clang/test/Driver/mingw-sysroot.cpp
+++ clang/test/Driver/mingw-sysroot.cpp
@@ -12,6 +12,7 @@
 // RUN: mkdir -p %T/testroot-clang/bin
 // RUN: ln -s %clang %T/testroot-clang/bin/x86_64-w64-mingw32-clang
 // RUN: ln -s %S/Inputs/mingw_ubuntu_posix_tree/usr/x86_64-w64-mingw32 %T/testroot-clang/x86_64-w64-mingw32
+// RUN: ln -s %S/Inputs/mingw_arch_tree/usr/i686-w64-mingw32 %T/testroot-clang/i686-w64-mingw32
 
 
 // If we find a gcc in the path with the right triplet prefix, pick that as
@@ -36,3 +37,14 @@
 // the libgcc directory:
 
 // RUN: env "PATH=%T/testroot-gcc/bin:%PATH%" %T/testroot-gcc/bin/x86_64-w64-mingw32-clang -target x86_64-w64-mingw32 -rtlib=platform -stdlib=libstdc++ --sysroot="" -c -### %s 2>&1 | FileCheck -check-prefix=CHECK_TESTROOT_GCC %s
+
+
+// If the user requests a different arch via the -m32 option, which changes
+// x86_64 into i386, check that the driver notices that it can't find a
+// sysroot for i386 but there is one for i686, and uses that one.
+// (In practice, this usecase is when using an unprefixed native clang
+// that defaults to x86_64 mingw, but it's easier to test in cross setups
+// with symlinks, like the other tests here.)
+
+// RUN: env "PATH=%T/testroot-gcc/bin:%PATH%" %T/testroot-clang/bin/x86_64-w64-mingw32-clang -target x86_64-w64-mingw32 -m32 -rtlib=compiler-rt -stdlib=libstdc++ --sysroot="" -c -### %s 2>&1 | FileCheck -check-prefix=CHECK_TESTROOT_CLANG_I686 %s
+// CHECK_TESTROOT_CLANG_I686: "{{[^"]+}}/testroot-clang{{/|}}i686-w64-mingw32{{/|}}include"
Index: clang/lib/Driver/ToolChains/MinGW.h
===
--- clang/lib/Driver/ToolChains/MinGW.h
+++ clang/lib/Driver/ToolChains/MinGW.h
@@ -60,6 +60,9 @@
   MinGW(const Driver , const llvm::Triple ,
 const llvm::opt::ArgList );
 
+  static void FixTripleArch(const Driver , llvm::Triple ,
+const llvm::opt::ArgList );
+
   bool HasNativeLLVMSupport() const override;
 
   bool IsIntegratedAssemblerDefault() const override;
@@ -103,8 +106,6 @@
   mutable std::unique_ptr Preprocessor;
   mutable std::unique_ptr Compiler;
   void findGccLibDir();
-  llvm::ErrorOr findGcc();
-  llvm::ErrorOr findClangRelativeSysroot();
 
   bool NativeLLVMSupport;
 };
Index: clang/lib/Driver/ToolChains/MinGW.cpp
===
--- clang/lib/Driver/ToolChains/MinGW.cpp
+++ clang/lib/Driver/ToolChains/MinGW.cpp
@@ -369,9 +369,9 @@
   }
 }
 
-llvm::ErrorOr toolchains::MinGW::findGcc() {
+static llvm::ErrorOr findGcc(const llvm::Triple ) {
   llvm::SmallVector, 2> Gccs;
-  Gccs.emplace_back(getTriple().getArchName());
+  Gccs.emplace_back(T.getArchName());
   Gccs[0] += "-w64-mingw32-gcc";
   Gccs.emplace_back("mingw32-gcc");
   // Please do not add "gcc" here
@@ -381,13 +381,14 @@
   return make_error_code(std::errc::no_such_file_or_directory);
 }
 
-llvm::ErrorOr toolchains::MinGW::findClangRelativeSysroot() {
+static llvm::ErrorOr
+findClangRelativeSysroot(const Driver , const llvm::Triple ,
+ std::string ) {
   llvm::SmallVector, 2> Subdirs;
-  Subdirs.emplace_back(getTriple().str());
-  Subdirs.emplace_back(getTriple().getArchName());
+  Subdirs.emplace_back(T.str());
+  Subdirs.emplace_back(T.getArchName());
   Subdirs[1] += "-w64-mingw32";
-  StringRef ClangRoot =
-  llvm::sys::path::parent_path(getDriver().getInstalledDir());
+  StringRef ClangRoot = llvm::sys::path::parent_path(D.getInstalledDir());
   StringRef Sep = llvm::sys::path::get_separator();
   for (StringRef CandidateSubdir : Subdirs) {
 if (llvm::sys::fs::is_directory(ClangRoot + Sep + CandidateSubdir)) {
@@ -404,13 +405,16 @@
   RocmInstallation(D, Triple, Args) {
   getProgramPaths().push_back(getDriver().getInstalledDir());
 
+  // The sequence for detecting a sysroot here should be kept in sync with
+  // the testTriple function below.
   if (getDriver().SysRoot.size())
 Base = getDriver().SysRoot;
   // Look for /../; if found, use /.. as the
   // base as it could still be a base for a gcc setup with libgcc.
-  else if (llvm::ErrorOr TargetSubdir = findClangRelativeSysroot())
+  else if (llvm::ErrorOr TargetSubdir =
+   findClangRelativeSysroot(getDriver(), getTriple(), SysrootName))
 Base = std::string(llvm::sys::path::parent_path(TargetSubdir.get()));
-  else if (llvm::ErrorOr 

[PATCH] D111952: [clang] [MinGW] Guess the right ix86 arch name spelling as sysroot

2021-10-24 Thread Martin Storsjö via Phabricator via cfe-commits
mstorsjo added a comment.

In D111952#3068680 , @mstorsjo wrote:

> I guess a downside of this solution, is that if an `i686` sysroot exists next 
> to the clang binary, it becomes practically impossible to test codegen 
> differences when you run it with various `-target iX86-w64-mingw32` options, 
> as they'd all be corrected back to `i686`. (This wouldn't be an issue if the 
> autodetection was done in `computeTargetTriple` only when the `-m32`/`-m64` 
> options are used though.)

Ok, it turned out to not be that bad to move the fixup into 
`computeTargetTriple` to this location after all, it looks fairly neat and not 
that much out of line compared to the existing triple tweaks done there.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D111952

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


[PATCH] D112387: [clang] [MinGW] Rename the 'Arch' member to 'SysrootName'. NFC.

2021-10-24 Thread Martin Storsjö via Phabricator via cfe-commits
mstorsjo created this revision.
mstorsjo added a reviewer: MaskRay.
mstorsjo requested review of this revision.
Herald added a project: clang.

This string isn't a plain architecture name, but contains the whole
subdir name used for the sysroot, which often is equal to the target
triple.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D112387

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

Index: clang/lib/Driver/ToolChains/MinGW.h
===
--- clang/lib/Driver/ToolChains/MinGW.h
+++ clang/lib/Driver/ToolChains/MinGW.h
@@ -99,7 +99,7 @@
   std::string Base;
   std::string GccLibDir;
   std::string Ver;
-  std::string Arch;
+  std::string SysrootName;
   mutable std::unique_ptr Preprocessor;
   mutable std::unique_ptr Compiler;
   void findGccLibDir();
Index: clang/lib/Driver/ToolChains/MinGW.cpp
===
--- clang/lib/Driver/ToolChains/MinGW.cpp
+++ clang/lib/Driver/ToolChains/MinGW.cpp
@@ -349,20 +349,20 @@
 }
 
 void toolchains::MinGW::findGccLibDir() {
-  llvm::SmallVector, 2> Archs;
-  Archs.emplace_back(getTriple().getArchName());
-  Archs[0] += "-w64-mingw32";
-  Archs.emplace_back("mingw32");
-  if (Arch.empty())
-Arch = std::string(Archs[0].str());
+  llvm::SmallVector, 2> SysrootNames;
+  SysrootNames.emplace_back(getTriple().getArchName());
+  SysrootNames[0] += "-w64-mingw32";
+  SysrootNames.emplace_back("mingw32");
+  if (SysrootName.empty())
+SysrootName = std::string(SysrootNames[0].str());
   // lib: Arch Linux, Ubuntu, Windows
   // lib64: openSUSE Linux
   for (StringRef CandidateLib : {"lib", "lib64"}) {
-for (StringRef CandidateArch : Archs) {
+for (StringRef CandidateSysroot : SysrootNames) {
   llvm::SmallString<1024> LibDir(Base);
-  llvm::sys::path::append(LibDir, CandidateLib, "gcc", CandidateArch);
+  llvm::sys::path::append(LibDir, CandidateLib, "gcc", CandidateSysroot);
   if (findGccVersion(LibDir, GccLibDir, Ver)) {
-Arch = std::string(CandidateArch);
+SysrootName = std::string(CandidateSysroot);
 return;
   }
 }
@@ -391,7 +391,7 @@
   StringRef Sep = llvm::sys::path::get_separator();
   for (StringRef CandidateSubdir : Subdirs) {
 if (llvm::sys::fs::is_directory(ClangRoot + Sep + CandidateSubdir)) {
-  Arch = std::string(CandidateSubdir);
+  SysrootName = std::string(CandidateSubdir);
   return (ClangRoot + Sep + CandidateSubdir).str();
 }
   }
@@ -423,10 +423,10 @@
   // correct crtbegin.o ,cetend.o would be found.
   getFilePaths().push_back(GccLibDir);
   getFilePaths().push_back(
-  (Base + Arch + llvm::sys::path::get_separator() + "lib").str());
+  (Base + SysrootName + llvm::sys::path::get_separator() + "lib").str());
   getFilePaths().push_back(Base + "lib");
   // openSUSE
-  getFilePaths().push_back(Base + Arch + "/sys-root/mingw/lib");
+  getFilePaths().push_back(Base + SysrootName + "/sys-root/mingw/lib");
 
   NativeLLVMSupport =
   Args.getLastArgValue(options::OPT_fuse_ld_EQ, CLANG_DEFAULT_LINKER)
@@ -573,11 +573,12 @@
   if (GetRuntimeLibType(DriverArgs) == ToolChain::RLT_Libgcc) {
 // openSUSE
 addSystemInclude(DriverArgs, CC1Args,
- Base + Arch + "/sys-root/mingw/include");
+ Base + SysrootName + "/sys-root/mingw/include");
   }
 
   addSystemInclude(DriverArgs, CC1Args,
-   Base + Arch + llvm::sys::path::get_separator() + "include");
+   Base + SysrootName + llvm::sys::path::get_separator() +
+   "include");
   addSystemInclude(DriverArgs, CC1Args, Base + "include");
 }
 
@@ -596,8 +597,9 @@
 .str();
 if (getDriver().getVFS().exists(TargetDir))
   addSystemInclude(DriverArgs, CC1Args, TargetDir);
-addSystemInclude(DriverArgs, CC1Args, Base + Arch + Slash + "include" +
-  Slash + "c++" + Slash + "v1");
+addSystemInclude(DriverArgs, CC1Args,
+ Base + SysrootName + Slash + "include" + Slash + "c++" +
+ Slash + "v1");
 addSystemInclude(DriverArgs, CC1Args,
  Base + "include" + Slash + "c++" + Slash + "v1");
 break;
@@ -606,9 +608,10 @@
   case ToolChain::CST_Libstdcxx:
 llvm::SmallVector, 4> CppIncludeBases;
 CppIncludeBases.emplace_back(Base);
-llvm::sys::path::append(CppIncludeBases[0], Arch, "include", "c++");
+llvm::sys::path::append(CppIncludeBases[0], SysrootName, "include", "c++");
 CppIncludeBases.emplace_back(Base);
-llvm::sys::path::append(CppIncludeBases[1], Arch, "include", "c++", Ver);
+llvm::sys::path::append(CppIncludeBases[1], SysrootName, "include", "c++",
+Ver);
 CppIncludeBases.emplace_back(Base);
 llvm::sys::path::append(CppIncludeBases[2], "include", 

[clang] 7cc8fa2 - Use llvm::is_contained (NFC)

2021-10-24 Thread Kazu Hirata via cfe-commits

Author: Kazu Hirata
Date: 2021-10-24T09:32:57-07:00
New Revision: 7cc8fa2dd2d8167d427cadb4fc6f4254b53a8359

URL: 
https://github.com/llvm/llvm-project/commit/7cc8fa2dd2d8167d427cadb4fc6f4254b53a8359
DIFF: 
https://github.com/llvm/llvm-project/commit/7cc8fa2dd2d8167d427cadb4fc6f4254b53a8359.diff

LOG: Use llvm::is_contained (NFC)

Added: 


Modified: 
clang/lib/AST/ASTImporter.cpp
clang/lib/Analysis/ObjCNoReturn.cpp
clang/lib/Driver/ToolChains/Cuda.cpp
clang/lib/Lex/ModuleMap.cpp
clang/lib/Sema/SemaChecking.cpp
clang/lib/Sema/SemaOpenMP.cpp
lldb/source/Breakpoint/BreakpointID.cpp

Removed: 




diff  --git a/clang/lib/AST/ASTImporter.cpp b/clang/lib/AST/ASTImporter.cpp
index 1afc1e13d25a7..4e74355f2639a 100644
--- a/clang/lib/AST/ASTImporter.cpp
+++ b/clang/lib/AST/ASTImporter.cpp
@@ -300,11 +300,8 @@ namespace clang {
   auto *ToNamed = cast(ToD);
   DeclContextLookupResult FromLookup =
   FromDC->lookup(FromNamed->getDeclName());
-  for (NamedDecl *ND : FromLookup)
-if (ND == FromNamed) {
-  ToDC->makeDeclVisibleInContext(ToNamed);
-  break;
-}
+  if (llvm::is_contained(FromLookup, FromNamed))
+ToDC->makeDeclVisibleInContext(ToNamed);
 }
   }
 }

diff  --git a/clang/lib/Analysis/ObjCNoReturn.cpp 
b/clang/lib/Analysis/ObjCNoReturn.cpp
index fe1edb496859e..9d7c365c3b992 100644
--- a/clang/lib/Analysis/ObjCNoReturn.cpp
+++ b/clang/lib/Analysis/ObjCNoReturn.cpp
@@ -54,12 +54,9 @@ bool ObjCNoReturn::isImplicitNoReturn(const ObjCMessageExpr 
*ME) {
   }
 
   if (const ObjCInterfaceDecl *ID = ME->getReceiverInterface()) {
-if (isSubclass(ID, NSExceptionII)) {
-  for (unsigned i = 0; i < NUM_RAISE_SELECTORS; ++i) {
-if (S == NSExceptionInstanceRaiseSelectors[i])
-  return true;
-  }
-}
+if (isSubclass(ID, NSExceptionII) &&
+llvm::is_contained(NSExceptionInstanceRaiseSelectors, S))
+  return true;
   }
 
   return false;

diff  --git a/clang/lib/Driver/ToolChains/Cuda.cpp 
b/clang/lib/Driver/ToolChains/Cuda.cpp
index 0ad1ffb079b31..09418aa2390f2 100644
--- a/clang/lib/Driver/ToolChains/Cuda.cpp
+++ b/clang/lib/Driver/ToolChains/Cuda.cpp
@@ -822,17 +822,9 @@ CudaToolChain::TranslateArgs(const 
llvm::opt::DerivedArgList ,
   // flags are not duplicated.
   // Also append the compute capability.
   if (DeviceOffloadKind == Action::OFK_OpenMP) {
-for (Arg *A : Args) {
-  bool IsDuplicate = false;
-  for (Arg *DALArg : *DAL) {
-if (A == DALArg) {
-  IsDuplicate = true;
-  break;
-}
-  }
-  if (!IsDuplicate)
+for (Arg *A : Args)
+  if (!llvm::is_contained(*DAL, A))
 DAL->append(A);
-}
 
 StringRef Arch = DAL->getLastArgValue(options::OPT_march_EQ);
 if (Arch.empty())

diff  --git a/clang/lib/Lex/ModuleMap.cpp b/clang/lib/Lex/ModuleMap.cpp
index 08381d0422058..6324cdc5a6b0a 100644
--- a/clang/lib/Lex/ModuleMap.cpp
+++ b/clang/lib/Lex/ModuleMap.cpp
@@ -1217,9 +1217,8 @@ void ModuleMap::addHeader(Module *Mod, Module::Header 
Header,
   // FIXME: Should we diagnose if a header is listed twice in the
   // same module definition?
   auto  = Headers[Header.Entry];
-  for (auto H : HeaderList)
-if (H == KH)
-  return;
+  if (llvm::is_contained(HeaderList, KH))
+return;
 
   HeaderList.push_back(KH);
   Mod->Headers[headerRoleToKind(Role)].push_back(Header);

diff  --git a/clang/lib/Sema/SemaChecking.cpp b/clang/lib/Sema/SemaChecking.cpp
index a7a48016fe1e2..63c2d9fff8816 100644
--- a/clang/lib/Sema/SemaChecking.cpp
+++ b/clang/lib/Sema/SemaChecking.cpp
@@ -2688,12 +2688,7 @@ static bool isValidBPFPreserveEnumValueArg(Expr *Arg) {
 return false;
 
   // The enum value must be supported.
-  for (auto *EDI : ET->getDecl()->enumerators()) {
-if (EDI == Enumerator)
-  return true;
-  }
-
-  return false;
+  return llvm::is_contained(ET->getDecl()->enumerators(), Enumerator);
 }
 
 bool Sema::CheckBPFBuiltinFunctionCall(unsigned BuiltinID,

diff  --git a/clang/lib/Sema/SemaOpenMP.cpp b/clang/lib/Sema/SemaOpenMP.cpp
index 2e8f208866803..ccd17fc5102d1 100644
--- a/clang/lib/Sema/SemaOpenMP.cpp
+++ b/clang/lib/Sema/SemaOpenMP.cpp
@@ -4963,14 +4963,7 @@ static bool checkIfClauses(Sema , OpenMPDirectiveKind 
Kind,
   // directive.
   // At most one if clause with the particular directive-name-modifier can
   // appear on the directive.
-  bool MatchFound = false;
-  for (auto NM : AllowedNameModifiers) {
-if (CurNM == NM) {
-  MatchFound = true;
-  break;
-}
-  }
-  if (!MatchFound) {
+  if (!llvm::is_contained(AllowedNameModifiers, CurNM)) {
 S.Diag(IC->getNameModifierLoc(),
diag::err_omp_wrong_if_directive_name_modifier)
 << getOpenMPDirectiveName(CurNM) 

[PATCH] D106102: [analyzer][solver] Introduce reasoning for not equal to operator

2021-10-24 Thread Balázs Benics via Phabricator via cfe-commits
steakhal added a comment.

In D106102#3082399 , @manas wrote:

> Based on the information from debugger, the logs 
>  show RangeSets `[0, 255]` and 
> `[INT_MIN, 0]` from different types 
>  are causing the failure.
> I tried producing a compact test case . 
> The essential part is the comparison between different types, as in this case 
> `unsigned int` and `int`. In other binary operators (BO_And, BO_Rem, etc.), 
> this gets handled by coarsing RangeSets to Ranges and converting those Ranges 
> to resulting type for comparison. This is missing in `BO_NE`. I suppose, this 
> may be the reason behind the signedness mismatch.
>
> One way to solve this would be to let the specialization of 
> `VisitBinaryOperator` (definition here 
> )
>  handle the coarse/convert, and then `VisitBinaryOperator` checking 
> for any reasonable result which can be inferred from those Ranges.

I think you are right. I'm gonna have a deeper look at this tomorrow. Until 
then you shouls figure out how this was avoided in other operations. Dealing 
with this for one and all seems promising. Ive seen multiple fixup commits 
resolving similar issues, so it seems to bite back regularly.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D106102

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


[PATCH] D112349: [Verifier] Add verification logic for GlobalIFuncs

2021-10-24 Thread Itay Bookstein via Phabricator via cfe-commits
ibookstein updated this revision to Diff 381773.
ibookstein added a comment.

Change BitcodeReader to transparently fix up the type rather than returning an 
error because older formats use wrong type.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112349

Files:
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/test/CodeGen/ifunc.c
  clang/test/CodeGen/semantic-interposition.c
  llvm/include/llvm/IR/GlobalIFunc.h
  llvm/lib/Bitcode/Reader/BitcodeReader.cpp
  llvm/lib/IR/Globals.cpp
  llvm/lib/IR/Verifier.cpp
  llvm/test/Assembler/ifunc-asm.ll
  llvm/test/Assembler/ifunc-dsolocal.ll
  llvm/test/Assembler/ifunc-use-list-order.ll
  llvm/test/Bindings/llvm-c/echo.ll
  llvm/test/Bitcode/compatibility-3.9.ll
  llvm/test/Bitcode/compatibility-4.0.ll
  llvm/test/Bitcode/compatibility-5.0.ll
  llvm/test/Bitcode/compatibility-6.0.ll
  llvm/test/Bitcode/compatibility.ll
  llvm/test/Bitcode/dso_local_equivalent.ll
  llvm/test/Bitcode/dso_location.ll
  llvm/test/CodeGen/PowerPC/ifunc.ll
  llvm/test/CodeGen/X86/addrsig.ll
  llvm/test/CodeGen/X86/dso_local_equivalent.ll
  llvm/test/CodeGen/X86/ifunc-asm.ll
  llvm/test/CodeGen/X86/partition.ll
  llvm/test/LTO/Resolution/X86/Inputs/ifunc2.ll
  llvm/test/LTO/Resolution/X86/ifunc.ll
  llvm/test/LTO/Resolution/X86/ifunc2.ll
  llvm/test/Linker/ifunc.ll
  llvm/test/Object/X86/nm-ir.ll
  llvm/test/ThinLTO/X86/empty-module.ll
  llvm/test/Transforms/GlobalDCE/global-ifunc.ll

Index: llvm/test/Transforms/GlobalDCE/global-ifunc.ll
===
--- llvm/test/Transforms/GlobalDCE/global-ifunc.ll
+++ llvm/test/Transforms/GlobalDCE/global-ifunc.ll
@@ -2,12 +2,12 @@
 target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
 target triple = "x86_64-unknown-linux-gnu"
 
-@if = ifunc void (), void ()* @fn
+@if = ifunc void (), void ()* ()* @fn
 
-define internal void @fn() {
+define internal void ()* @fn() {
 entry:
-  ret void
+  ret void ()* null
 }
 
-; CHECK-DAG: @if = ifunc void (), void ()* @fn
-; CHECK-DAG: define internal void @fn(
+; CHECK-DAG: @if = ifunc void (), void ()* ()* @fn
+; CHECK-DAG: define internal void ()* @fn(
Index: llvm/test/ThinLTO/X86/empty-module.ll
===
--- llvm/test/ThinLTO/X86/empty-module.ll
+++ llvm/test/ThinLTO/X86/empty-module.ll
@@ -10,9 +10,9 @@
 target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
 target triple = "x86_64-unknown-linux-gnu"
 
-@foo = ifunc i32 (i32), i64 ()* @foo_ifunc
+@foo = ifunc i32 (i32), i32 (i32)* ()* @foo_ifunc
 
-define internal i64 @foo_ifunc() {
+define internal i32 (i32)* @foo_ifunc() {
 entry:
-  ret i64 0
+  ret i32 (i32)* null
 }
Index: llvm/test/Object/X86/nm-ir.ll
===
--- llvm/test/Object/X86/nm-ir.ll
+++ llvm/test/Object/X86/nm-ir.ll
@@ -32,12 +32,12 @@
 @a1 = alias i32, i32* @g1
 @a2 = internal alias i32, i32* @g1
 
-define void @f1() {
+define void ()* @f1() {
   call void @f5()
-  ret void
+  ret void ()* null
 }
 
-@ifunc_f1 = ifunc void (), void ()* @f1
+@ifunc_f1 = ifunc void (), void ()* ()* @f1
 
 define internal void @f2() {
   ret void
Index: llvm/test/Linker/ifunc.ll
===
--- llvm/test/Linker/ifunc.ll
+++ llvm/test/Linker/ifunc.ll
@@ -3,18 +3,18 @@
 
 ;; Check that ifuncs are linked in properly.
 
-; CHECK-DAG: @foo = ifunc void (), bitcast (void ()* ()* @foo_resolve to void ()*)
+; CHECK-DAG: @foo = ifunc void (), void ()* ()* @foo_resolve
 ; CHECK-DAG: define internal void ()* @foo_resolve() {
 
-; CHECK-DAG: @bar = ifunc void (), bitcast (void ()* ()* @bar_resolve to void ()*)
+; CHECK-DAG: @bar = ifunc void (), void ()* ()* @bar_resolve
 ; CHECK-DAG: define internal void ()* @bar_resolve() {
 
 ;--- a.ll
 declare void @bar()
 
 ;--- b.ll
-@foo = ifunc void (), bitcast (void ()* ()* @foo_resolve to void ()*)
-@bar = ifunc void (), bitcast (void ()* ()* @bar_resolve to void ()*)
+@foo = ifunc void (), void ()* ()* @foo_resolve
+@bar = ifunc void (), void ()* ()* @bar_resolve
 
 define internal void ()* @foo_resolve() {
   ret void ()* null
Index: llvm/test/LTO/Resolution/X86/ifunc2.ll
===
--- llvm/test/LTO/Resolution/X86/ifunc2.ll
+++ llvm/test/LTO/Resolution/X86/ifunc2.ll
@@ -6,14 +6,14 @@
 target datalayout = "e-p:64:64"
 target triple = "x86_64-unknown-linux-gnu"
 
-; CHECK: @foo = ifunc i32 (), i32 ()* @foo_resolver.2
-@foo = ifunc i32 (), i32 ()* @foo_resolver
+; CHECK: @foo = ifunc i32 (), i32 ()* ()* @foo_resolver.2
+@foo = ifunc i32 (), i32 ()* ()* @foo_resolver
 
-; CHECK: define internal i32 @foo_resolver.2() {
-; CHECK-NEXT: ret i32 1
-define weak i32 @foo_resolver() {
-  ret i32 1
+; CHECK: define internal i32 ()* @foo_resolver.2() {
+; CHECK-NEXT: ret i32 ()*