[PATCH] D80802: [RISCV] Upgrade RVV MC to v0.9.

2020-07-08 Thread Alex Bradbury via Phabricator via cfe-commits
asb added a comment.

I've gone through and can't see any obvious issues. I defer to one of the 
RISC-V Vector extension usual suspects for giving a LGTM on the detail of the 
altered instructions etc. Once we have that, this looks good to land IMHO.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80802



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


[PATCH] D79719: [AIX] Implement AIX special alignment rule about double/long double

2020-07-08 Thread Hubert Tong via Phabricator via cfe-commits
hubert.reinterpretcast added inline comments.



Comment at: clang/lib/AST/RecordLayoutBuilder.cpp:1208
+// "first (inherited) member".
+HandledFirstNonOverlappingEmptyField = true;
+

We need some sort of `IsFirstNonEmptyBase` to record that the current base 
qualifies for the alignment upgrade:
```
struct A { double x; };
struct B : A {} b;
```



Comment at: clang/lib/AST/RecordLayoutBuilder.cpp:1245
+  // space or zero-extent array.
+  if (DefaultsToAIXPowerAlignment && HandledFirstNonOverlappingEmptyField) {
+UnpackedPreferredBaseAlign = UnpackedBaseAlign;

Query `!IsFirstNonEmptyBase` instead of `HandledFirstNonOverlappingEmptyField` 
here.


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

https://reviews.llvm.org/D79719



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


[PATCH] D71124: [RISCV] support clang driver to select cpu

2020-07-08 Thread Alex Bradbury via Phabricator via cfe-commits
asb added a comment.

This has been hanging around for a while, but I think we'd basically agreed 
this is the right logic. The comments have ended up referring to flags that 
don't exist on Clang making it a little hard to follow, and I've added a 
request to slightly expand testing. If you make those cleanups I think it 
should be ready for a final review and merge.

As Sam says, lets flag this in today's RISC-V LLVM call to double-check 
everyone is happy.




Comment at: clang/lib/Driver/ToolChains/Arch/RISCV.cpp:622
+  // 1. Explicit choices using `--with-arch=`
+  // 2. Based on `-mcpu` if target cpu has default isa extension feature
+  // 3. A default based on `--with-abi=`, if provided

As clang has no with-arch or with-abi, this comment seems inaccurate?



Comment at: clang/test/Driver/riscv-cpus.c:2
+// Check target CPUs are correctly passed.
+
+// RUN: %clang -target riscv32 -### -c %s 2>&1 -mcpu=rocket-rv32 | FileCheck 
-check-prefix=MCPU-ROCKETCHIP32 %s

I think for completeness this test should be validating the interaction of the 
ABI choosing logic with CPU selection as well. With the implemented logic I 
believe it should show that lp64d is selected for -mcpu=sifive-u54 and that 
-mcpu=sifive-u54 -mabi=lp64 will respect the ABI choice


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71124



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


[PATCH] D83454: [CMake] Make `intrinsics_gen` dependency unconditional.

2020-07-08 Thread Michele Scandale via Phabricator via cfe-commits
michele.scandale created this revision.
michele.scandale added reviewers: chandlerc, beanz, zturner.
Herald added subscribers: lldb-commits, cfe-commits, MaskRay, aheejin, 
arichardson, sbc100, mgorny, emaste.
Herald added a reviewer: espindola.
Herald added a reviewer: MaskRay.
Herald added projects: clang, LLDB.

The `intrinsics_gen` target exists in the CMake exports since r309389
(see LLVMConfig.cmake.in), hence projects can depend on `intrinsics_gen`
even it they are built separately from LLVM.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D83454

Files:
  clang/CMakeLists.txt
  clang/lib/CodeGen/CMakeLists.txt
  clang/lib/Frontend/CMakeLists.txt
  clang/tools/clang-fuzzer/handle-llvm/CMakeLists.txt
  clang/tools/clang-import-test/CMakeLists.txt
  clang/tools/clang-offload-bundler/CMakeLists.txt
  clang/tools/clang-offload-wrapper/CMakeLists.txt
  clang/tools/driver/CMakeLists.txt
  lld/COFF/CMakeLists.txt
  lld/Common/CMakeLists.txt
  lld/ELF/CMakeLists.txt
  lld/MinGW/CMakeLists.txt
  lld/lib/Core/CMakeLists.txt
  lld/wasm/CMakeLists.txt
  lldb/CMakeLists.txt
  lldb/source/Expression/CMakeLists.txt
  lldb/source/Plugins/ExpressionParser/Clang/CMakeLists.txt
  
lldb/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/CMakeLists.txt

Index: lldb/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/CMakeLists.txt
===
--- lldb/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/CMakeLists.txt
+++ lldb/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/CMakeLists.txt
@@ -1,8 +1,3 @@
-if(NOT LLDB_BUILT_STANDALONE)
-  set(tablegen_deps intrinsics_gen)
-endif()
-
-
 add_lldb_library(lldbPluginRenderScriptRuntime PLUGIN
   RenderScriptRuntime.cpp
   RenderScriptExpressionOpts.cpp
@@ -10,7 +5,7 @@
   RenderScriptScriptGroup.cpp
 
   DEPENDS
-  ${tablegen_deps}
+  intrinsics_gen
 
   LINK_LIBS
 lldbBreakpoint
Index: lldb/source/Plugins/ExpressionParser/Clang/CMakeLists.txt
===
--- lldb/source/Plugins/ExpressionParser/Clang/CMakeLists.txt
+++ lldb/source/Plugins/ExpressionParser/Clang/CMakeLists.txt
@@ -1,7 +1,3 @@
-if(NOT LLDB_BUILT_STANDALONE)
-  set(tablegen_deps intrinsics_gen)
-endif()
-
 add_lldb_library(lldbPluginExpressionParserClang
   ASTResultSynthesizer.cpp
   ASTStructExtractor.cpp
@@ -29,7 +25,7 @@
   NameSearchContext.cpp
 
   DEPENDS
-  ${tablegen_deps}
+  intrinsics_gen
 
   LINK_LIBS
 lldbCore
Index: lldb/source/Expression/CMakeLists.txt
===
--- lldb/source/Expression/CMakeLists.txt
+++ lldb/source/Expression/CMakeLists.txt
@@ -1,7 +1,3 @@
-if(NOT LLDB_BUILT_STANDALONE)
-  set(tablegen_deps intrinsics_gen)
-endif()
-
 add_lldb_library(lldbExpression
   DiagnosticManager.cpp
   DWARFExpression.cpp
@@ -18,7 +14,7 @@
   UtilityFunction.cpp
 
   DEPENDS
-  ${tablegen_deps}
+  intrinsics_gen
 
   LINK_LIBS
 lldbCore
Index: lldb/CMakeLists.txt
===
--- lldb/CMakeLists.txt
+++ lldb/CMakeLists.txt
@@ -64,7 +64,7 @@
 # some of these generated headers. This approach is copied from Clang's main
 # CMakeLists.txt, so it should kept in sync the code in Clang which was added
 # in llvm-svn 308844.
-if(LLVM_ENABLE_MODULES AND NOT LLDB_BUILT_STANDALONE)
+if(LLVM_ENABLE_MODULES)
   list(APPEND LLVM_COMMON_DEPENDS intrinsics_gen)
 endif()
 
Index: lld/wasm/CMakeLists.txt
===
--- lld/wasm/CMakeLists.txt
+++ lld/wasm/CMakeLists.txt
@@ -2,10 +2,6 @@
 tablegen(LLVM Options.inc -gen-opt-parser-defs)
 add_public_tablegen_target(WasmOptionsTableGen)
 
-if(NOT LLD_BUILT_STANDALONE)
-  set(tablegen_deps intrinsics_gen)
-endif()
-
 add_lld_library(lldWasm
   Driver.cpp
   InputChunks.cpp
@@ -37,5 +33,5 @@
 
   DEPENDS
   WasmOptionsTableGen
-  ${tablegen_deps}
+  intrinsics_gen
   )
Index: lld/lib/Core/CMakeLists.txt
===
--- lld/lib/Core/CMakeLists.txt
+++ lld/lib/Core/CMakeLists.txt
@@ -1,7 +1,3 @@
-if(NOT LLD_BUILT_STANDALONE)
-  set(tablegen_deps intrinsics_gen)
-endif()
-
 add_lld_library(lldCore
   DefinedAtom.cpp
   Error.cpp
@@ -24,5 +20,5 @@
   ${LLVM_PTHREAD_LIB}
 
   DEPENDS
-  ${tablegen_deps}
+  intrinsics_gen
   )
Index: lld/MinGW/CMakeLists.txt
===
--- lld/MinGW/CMakeLists.txt
+++ lld/MinGW/CMakeLists.txt
@@ -2,10 +2,6 @@
 tablegen(LLVM Options.inc -gen-opt-parser-defs)
 add_public_tablegen_target(MinGWOptionsTableGen)
 
-if(NOT LLD_BUILT_STANDALONE)
-  set(tablegen_deps intrinsics_gen)
-endif()
-
 add_lld_library(lldMinGW
   Driver.cpp
 
@@ -19,5 +15,5 @@
 
   DEPENDS
   MinGWOptionsTableGen
-  ${tablegen_deps}
+  intrinsics_gen
 )
Index: lld/ELF/CMakeLists.txt

Buildbot numbers for the week of 06/28/2020 - 07/04/2020

2020-07-08 Thread Galina Kistanova via cfe-commits
Hello everyone,

Below are some buildbot numbers for the last week of 06/28/2020 -
07/04/2020.

Please see the same data in attached csv files:

The longest time each builder was red during the week;
"Status change ratio" by active builder (percent of builds that changed the
builder status from green to red or from red to green);
Count of commits by project;
Number of completed builds, failed builds and average build time for
successful builds per active builder;
Average waiting time for a revision to get build result per active builder
(response time).

Thanks

Galina


The longest time each builder was red during the week:
   buildername| was_red
--+-
 clang-s390x-linux-multistage | 81:56:32
 clang-s390x-linux| 80:24:20
 clang-s390x-linux-lnt| 80:20:51
 llvm-clang-win-x-aarch64 | 69:41:19
 clang-cmake-aarch64-lld  | 60:26:11
 llvm-sphinx-docs | 56:14:14
 openmp-gcc-x86_64-linux-debian   | 50:07:25
 lldb-arm-ubuntu  | 49:51:53
 fuchsia-x86_64-linux | 32:37:12
 clang-x86_64-debian-new-pass-manager-fast| 32:32:17
 sanitizer-x86_64-linux-bootstrap | 27:16:04
 sanitizer-x86_64-linux-fast  | 25:36:45
 lldb-x64-windows-ninja   | 23:03:03
 clang-cmake-aarch64-full | 22:50:43
 sanitizer-x86_64-linux-android   | 19:28:03
 polly-arm-linux  | 18:18:56
 aosp-O3-polly-before-vectorizer-unprofitable | 16:57:06
 clang-ppc64le-linux-multistage   | 15:05:33
 sanitizer-x86_64-linux   | 11:40:01
 clang-with-lto-ubuntu| 08:54:10
 clang-cmake-armv8-lld| 07:51:15
 clang-with-thin-lto-ubuntu   | 07:40:48
 llvm-clang-win-x-armv7l  | 06:33:40
 clang-cmake-armv7-global-isel| 06:20:07
 clang-ppc64be-linux-multistage   | 06:10:47
 clang-cmake-aarch64-global-isel  | 06:09:00
 clang-cmake-armv7-quick  | 06:07:43
 llvm-avr-linux   | 06:07:15
 llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast | 06:02:56
 clang-x64-windows-msvc   | 06:02:15
 clang-ppc64be-linux  | 06:02:06
 clang-cmake-x86_64-sde-avx512-linux  | 05:59:56
 llvm-clang-lld-x86_64-scei-ps4-ubuntu-fast   | 05:59:54
 clang-ppc64le-rhel   | 05:58:46
 lld-x86_64-win   | 05:55:14
 flang-aarch64-ubuntu-clang   | 05:52:53
 clang-ppc64be-linux-lnt  | 05:49:22
 ppc64le-lld-multistage-test  | 05:45:38
 flang-aarch64-ubuntu | 05:43:05
 clang-cmake-aarch64-quick| 05:24:04
 sanitizer-x86_64-linux-bootstrap-msan| 05:18:10
 polly-x86_64-linux   | 05:11:52
 sanitizer-x86_64-linux-bootstrap-ubsan   | 04:41:18
 lld-x86_64-darwin| 04:36:23
 lld-x86_64-ubuntu-fast   | 04:10:41
 clang-ppc64le-linux-lnt  | 04:08:42
 sanitizer-ppc64be-linux  | 03:54:01
 clang-cmake-x86_64-avx2-linux| 03:49:53
 mlir-nvidia  | 03:28:53
 clang-x86_64-debian-fast | 03:01:37
 mlir-windows | 02:59:58
 clang-armv7-linux-build-cache| 02:46:28
 llvm-clang-x86_64-expensive-checks-ubuntu| 02:37:36
 sanitizer-x86_64-linux-fuzzer| 02:10:42
 llvm-clang-x86_64-expensive-checks-win   | 01:37:53
 clang-ppc64le-linux  | 01:30:19
 sanitizer-x86_64-linux-autoconf  | 01:09:18
 publish-sphinx-docs  | 01:07:47
 clang-cmake-armv7-lnt| 00:58:40
 clang-x86_64-linux-abi-test  | 00:49:06
 libc-x86_64-debian-dbg   | 00:40:25
 sanitizer-windows| 00:35:07
 llvm-clang-x86_64-expensive-checks-debian| 00:33:48
 lldb-aarch64-ubuntu  | 00:32:34
 llvm-clang-x86_64-win-fast   | 00:23:43
 openmp-clang-x86_64-linux-debian | 00:19:03
 lldb-x86_64-debian   | 00:15:16
(67 rows)


"Status change ratio" by active builder (percent of builds that changed the
builder status from greed to red or from red to green):
  

Buildbot numbers for the week of 06/21/2020 - 06/27/2020

2020-07-08 Thread Galina Kistanova via cfe-commits
Hello everyone,

Below are some buildbot numbers for the week of 06/21/2020 - 06/27/2020.

Please see the same data in attached csv files:

The longest time each builder was red during the week;
"Status change ratio" by active builder (percent of builds that changed the
builder status from green to red or from red to green);
Count of commits by project;
Number of completed builds, failed builds and average build time for
successful builds per active builder;
Average waiting time for a revision to get build result per active builder
(response time).

Thanks

Galina


The longest time each builder was red during the week:
   buildername| was_red
--+-
 publish-sphinx-docs  | 68:49:52
 ppc64le-lld-multistage-test  | 55:55:54
 clang-ppc64le-rhel   | 55:18:23
 clang-tools-sphinx-docs  | 51:02:34
 llvm-clang-win-x-armv7l  | 45:10:32
 clang-cmake-aarch64-lld  | 32:12:04
 llvm-clang-win-x-aarch64 | 28:46:30
 fuchsia-x86_64-linux | 22:19:45
 llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast | 22:07:12
 clang-x86_64-debian-new-pass-manager-fast| 22:00:02
 llvm-clang-x86_64-win-fast   | 21:22:05
 clang-x64-windows-msvc   | 21:13:41
 sanitizer-x86_64-linux-fast  | 20:15:48
 sanitizer-x86_64-linux-bootstrap-ubsan   | 20:06:52
 llvm-clang-x86_64-expensive-checks-ubuntu| 20:05:54
 llvm-clang-x86_64-expensive-checks-debian| 20:05:54
 llvm-clang-x86_64-expensive-checks-win   | 19:41:41
 sanitizer-x86_64-linux-bootstrap | 19:38:41
 clang-cmake-aarch64-full | 15:48:36
 aosp-O3-polly-before-vectorizer-unprofitable | 07:16:36
 lldb-x64-windows-ninja   | 07:08:00
 libc-x86_64-debian-dbg   | 07:04:21
 polly-x86_64-linux   | 06:22:52
 polly-arm-linux  | 05:52:11
 lld-x86_64-darwin| 05:35:39
 libc-x86_64-debian   | 05:24:19
 libc-x86_64-debian-dbg-asan  | 05:22:59
 clang-cmake-aarch64-quick| 05:15:34
 sanitizer-x86_64-linux-fuzzer| 05:12:29
 clang-ppc64le-linux-multistage   | 05:02:42
 llvm-avr-linux   | 04:41:41
 sanitizer-x86_64-linux-bootstrap-msan| 04:41:11
 clang-cmake-aarch64-global-isel  | 04:39:28
 clang-ppc64be-linux-lnt  | 04:21:05
 sanitizer-x86_64-linux-autoconf  | 04:13:49
 clang-s390x-linux-lnt| 03:53:46
 lldb-x86_64-debian   | 03:50:00
 clang-ppc64le-linux-lnt  | 03:40:27
 clang-x86_64-linux-abi-test  | 03:36:43
 sanitizer-windows| 03:27:49
 clang-cmake-armv8-lld| 03:23:13
 clang-s390x-linux| 03:22:57
 sanitizer-x86_64-linux-android   | 03:19:40
 clang-ppc64le-linux  | 03:13:01
 sanitizer-x86_64-linux   | 03:11:56
 clang-ppc64be-linux  | 03:07:56
 clang-ppc64be-linux-multistage   | 02:55:08
 sanitizer-ppc64be-linux  | 02:38:30
 clang-cmake-x86_64-sde-avx512-linux  | 02:30:49
 clang-cmake-x86_64-avx2-linux| 02:29:16
 clang-with-thin-lto-ubuntu   | 02:29:12
 clang-armv7-linux-build-cache| 02:27:44
 clang-s390x-linux-multistage | 02:26:52
 lldb-arm-ubuntu  | 02:20:06
 clang-cmake-armv7-global-isel| 02:02:04
 flang-aarch64-ubuntu | 01:53:50
 llvm-clang-lld-x86_64-scei-ps4-ubuntu-fast   | 01:49:54
 openmp-clang-x86_64-linux-debian | 01:43:54
 lldb-aarch64-ubuntu  | 01:36:00
 clang-cmake-armv7-quick  | 01:35:20
 lld-perf-testsuite   | 01:32:57
 lld-x86_64-win   | 01:23:29
 mlir-nvidia  | 01:09:01
 flang-aarch64-ubuntu-clang   | 00:58:25
 lld-x86_64-ubuntu-fast   | 00:56:28
 mlir-windows | 00:53:19
 clang-x86_64-debian-fast | 00:48:25
(67 rows)


"Status change ratio" by active builder (percent of builds that changed the
builder status from greed to red or from red to green):
   

[PATCH] D82087: AMDGPU/clang: Add builtins for llvm.amdgcn.ballot

2020-07-08 Thread Sameer Sahasrabuddhe via Phabricator via cfe-commits
sameerds added a comment.

The documentation for HIP __ballot seems to indicate that the user does not 
have to explicitly specify the warp size. How is that achieved with these new 
builtins? Can this  be captured in a lit test here?

https://github.com/ROCm-Developer-Tools/HIP/blob/master/docs/markdown/hip_kernel_language.md#warp-vote-and-ballot-functions




Comment at: clang/lib/Basic/Targets/AMDGPU.cpp:288
+  if (!IsNullCPU) {
+// Default to wave32 if available, or wave64 if not
+if (Features.count("wavefrontsize32") == 0 &&

So the implication here is that wave32 is the preferred choice on newer 
architectures, and hence the default when available?


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

https://reviews.llvm.org/D82087



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


[PATCH] D83448: [CodeGen] Emit destructor calls to destruct non-trivial C struct temporaries created by conditional and assignment operators

2020-07-08 Thread Akira Hatanaka via Phabricator via cfe-commits
ahatanak created this revision.
ahatanak added a reviewer: rjmccall.
ahatanak added a project: clang.
Herald added subscribers: ributzka, dexonsmith, jkorous.

rdar://problem/64989559


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D83448

Files:
  clang/lib/CodeGen/CGExprAgg.cpp
  clang/test/CodeGenObjC/strong-in-c-struct.m

Index: clang/test/CodeGenObjC/strong-in-c-struct.m
===
--- clang/test/CodeGenObjC/strong-in-c-struct.m
+++ clang/test/CodeGenObjC/strong-in-c-struct.m
@@ -95,12 +95,13 @@
 @end
 
 id g0;
+StrongSmall g1, g2;
 
+// CHECK: %[[STRUCT_STRONGSMALL:.*]] = type { i32, i8* }
 // CHECK: %[[STRUCT_STRONGOUTER:.*]] = type { %[[STRUCT_STRONG:.*]], i8*, double }
 // CHECK: %[[STRUCT_STRONG]] = type { %[[STRUCT_TRIVIAL:.*]], i8* }
 // CHECK: %[[STRUCT_TRIVIAL]] = type { [4 x i32] }
 // CHECK: %[[STRUCT_BLOCK_BYREF_T:.*]] = type { i8*, %[[STRUCT_BLOCK_BYREF_T]]*, i32, i32, i8*, i8*, i8*, %[[STRUCT_STRONGOUTER]] }
-// CHECK: %[[STRUCT_STRONGSMALL:.*]] = type { i32, i8* }
 // CHECK: %[[STRUCT_STRONGBLOCK:.*]] = type { void ()* }
 // CHECK: %[[STRUCT_BITFIELD1:.*]] = type { i8, i8, i8*, i32, i8*, [3 x i32], i8*, double, i8, i8 }
 
@@ -900,4 +901,47 @@
   a = b;
 }
 
+// CHECK-LABEL: define i8* @test_conditional0(
+// CHECK: %[[TMP:.*]] = alloca %[[STRUCT_STRONGSMALL]], align 8
+
+// CHECK: %[[V1:.*]] = bitcast %[[STRUCT_STRONGSMALL]]* %[[TMP]] to i8**
+// CHECK: call void @__copy_constructor_8_8_t0w4_s8(i8** %[[V1]], i8** bitcast (%[[STRUCT_STRONGSMALL]]* @g2 to i8**))
+
+// CHECK: %[[V2:.*]] = bitcast %[[STRUCT_STRONGSMALL]]* %[[TMP]] to i8**
+// CHECK: call void @__copy_constructor_8_8_t0w4_s8(i8** %[[V2]], i8** bitcast (%[[STRUCT_STRONGSMALL]]* @g1 to i8**))
+
+// CHECK: %[[V5:.*]] = bitcast %[[STRUCT_STRONGSMALL]]* %[[TMP]] to i8**
+// CHECK: call void @__destructor_8_s8(i8** %[[V5]])
+// CHECK: @llvm.objc.autoreleaseReturnValue
+
+id test_conditional0(int c) {
+  return (c ? g2 : g1).f1;
+}
+
+// CHECK-LABEL: define i8* @test_conditional1(
+// CHECK-NOT: call void @__destructor
+
+id test_conditional1(int c) {
+  calleeStrongSmall(c ? g2 : g1);
+}
+
+// CHECK-LABEL: define i8* @test_assignment0(
+// CHECK: %[[TMP:.*]] = alloca %[[STRUCT_STRONGSMALL]], align 8
+// CHECK: call void @__copy_assignment_8_8_t0w4_s8(i8** bitcast (%[[STRUCT_STRONGSMALL]]* @g2 to i8**), i8** bitcast (%[[STRUCT_STRONGSMALL]]* @g1 to i8**))
+// CHECK: %[[V0:.*]] = bitcast %[[STRUCT_STRONGSMALL]]* %[[TMP]] to i8**
+// CHECK: call void @__copy_constructor_8_8_t0w4_s8(i8** %[[V0]], i8** bitcast (%[[STRUCT_STRONGSMALL]]* @g2 to i8**))
+// CHECK: %[[V3:.*]] = bitcast %[[STRUCT_STRONGSMALL]]* %[[TMP]] to i8**
+// CHECK: call void @__destructor_8_s8(i8** %[[V3]])
+
+id test_assignment0(void) {
+  return (g2 = g1).f1;
+}
+
+// CHECK-LABEL: define i8* @test_assignment1(
+// CHECK-NOT: call void @__destructor
+
+id test_assignment1(void) {
+  calleeStrongSmall(g2 = g1);
+}
+
 #endif /* USESTRUCT */
Index: clang/lib/CodeGen/CGExprAgg.cpp
===
--- clang/lib/CodeGen/CGExprAgg.cpp
+++ clang/lib/CodeGen/CGExprAgg.cpp
@@ -1214,6 +1214,11 @@
 
   // Copy into the destination if the assignment isn't ignored.
   EmitFinalDestCopy(E->getType(), LHS);
+
+  if (!Dest.isIgnored() && !Dest.isExternallyDestructed() &&
+  E->getType().isDestructedType() == QualType::DK_nontrivial_c_struct)
+CGF.pushDestroy(QualType::DK_nontrivial_c_struct, Dest.getAddress(),
+E->getType());
 }
 
 void AggExprEmitter::
@@ -1231,6 +1236,11 @@
 
   // Save whether the destination's lifetime is externally managed.
   bool isExternallyDestructed = Dest.isExternallyDestructed();
+  bool destructNonTrivialCStruct =
+  !isExternallyDestructed &&
+  E->getType().isDestructedType() == QualType::DK_nontrivial_c_struct;
+  isExternallyDestructed |= destructNonTrivialCStruct;
+  Dest.setExternallyDestructed(isExternallyDestructed);
 
   eval.begin(CGF);
   CGF.EmitBlock(LHSBlock);
@@ -1252,6 +1262,10 @@
   Visit(E->getFalseExpr());
   eval.end(CGF);
 
+  if (destructNonTrivialCStruct)
+CGF.pushDestroy(QualType::DK_nontrivial_c_struct, Dest.getAddress(),
+E->getType());
+
   CGF.EmitBlock(ContBlock);
 }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D79719: [AIX] Implement AIX special alignment rule about double/long double

2020-07-08 Thread Hubert Tong via Phabricator via cfe-commits
hubert.reinterpretcast added inline comments.



Comment at: clang/lib/AST/RecordLayoutBuilder.cpp:1263
 
-  // The maximum field alignment overrides base align.
+  assert(!IsUnion && "Unions cannot have base classes.");
+  // AIX `power` alignment does not apply the preferred alignment for non-union

It seems this is a leftover copy of the code that has been moved above?



Comment at: clang/lib/AST/RecordLayoutBuilder.cpp:1809
+  Context.getTargetInfo().defaultsToAIXPowerAlignment();
+  bool FoundFirstNonOverlappingEmptyField = false;
+  if (DefaultsToAIXPowerAlignment)

The rename I suggested in my previous round of review was in coordination with 
maintaining the value not just for AIX. Since we're only maintaining the value 
for AIX, I prefer the previous name (or 
`FoundFirstNonOverlappingEmptyFieldForAIX`).



Comment at: clang/lib/AST/RecordLayoutBuilder.cpp:1810
+  bool FoundFirstNonOverlappingEmptyField = false;
+  if (DefaultsToAIXPowerAlignment)
+if (!HandledFirstNonOverlappingEmptyField) {

Please merge the `if` conditions to reduce nesting:
```
  if (DefaultsToAIXPowerAlignment && !HandledFirstNonOverlappingEmptyField) {
```



Comment at: clang/lib/AST/RecordLayoutBuilder.cpp:1817
+  // We're going to handle the "first member" based on
+  // `FoundNonOverlappingEmptyFieldToHandle` during the current invocation
+  // of this function; record it as handled for future invocations.

Keep this reference to the variable up-to-date with its name.



Comment at: clang/lib/AST/RecordLayoutBuilder.cpp:1820
+  if (FoundFirstNonOverlappingEmptyField)
+// For a union, the current field does not represent all "firsts".
+HandledFirstNonOverlappingEmptyField = !IsUnion;

Change the condition of the `if` here to `!IsOverlappingEmptyField` and move 
the setting of `FoundFirstNonOverlappingEmptyField` to `true` into this `if`.

Move the previous comment and merge it with this one here:
> [ ... ] record it as handled for future invocations (except for unions, 
> because the current field does not represent all "firsts").





Comment at: clang/lib/AST/RecordLayoutBuilder.cpp:1928
+  FoundFirstNonOverlappingEmptyField) {
+auto upgradeAlignment = [&](const BuiltinType *BTy) {
+  if (BTy->getKind() == BuiltinType::Double ||

Sorry for not seeing this earlier (I only notice some things when I hide the 
inline comments). I think `performBuiltinTypeAlignmentUpgrade` would read 
better at the call site (and better capture the checking, which is based on the 
kind of built-in type, that is within the lambda).



Comment at: clang/test/Layout/aix-Wpacked.cpp:9
+
+// CHECK-NOT: warning: packed attribute is unnecessary for 'Q' [-Wpacked]
+// CHECK: warning: packed attribute is unnecessary for 'test2::C' [-Wpacked]

Clang diagnostics are normally checked using `-verify` (as opposed to 
`FileCheck`). To use it, I think this needs to be split into the "expecting no 
diagnostics" and the "expecting diagnostics" cases. As it is, I think the 
`CHECK-NOT` has a problem because it checks for plain `'Q'`.


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

https://reviews.llvm.org/D79719



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


[PATCH] D83360: [InstSimplify] Remove select ?, undef, X -> X and select ?, X, undef -> X

2020-07-08 Thread John Regehr via Phabricator via cfe-commits
regehr added a comment.

> Did you mean to check something like the following?
> 
>   define i32 @src(i1 %cond, i32 %x) {
> %x2 = freeze i32 %x
> %s = select i1 %cond, i32 %x2, i32 undef
> ret i32 %s
>   }
>   
>   define i32 @tgt(i1 %cond, i32 %x) {
> %x2 = freeze i32 %x
> ret i32 %x2
>   }

that's fine but I still don't understand why the counterexample to my version 
says %x2 in @src can be undef


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83360



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


[PATCH] D78760: Check a class doesn't have a dependent type before iterating over its base classes

2020-07-08 Thread Akira Hatanaka via Phabricator via cfe-commits
ahatanak added a comment.

Does the updated patch look okay?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D78760



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


[PATCH] D82999: [CodeGen] Check the cleanup flag before destructing lifetime-extended temporaries created in conditional expressions

2020-07-08 Thread Akira Hatanaka via Phabricator via cfe-commits
ahatanak added a comment.

In D82999#2129855 , @rjmccall wrote:

> In D82999#2129417 , @ahatanak wrote:
>
> > In test case `test13` in clang/test/CodeGenCXX/exceptions.cpp, I think you 
> > can turn `invoke void @_ZN6test131AC1Ev` into `call void 
> > @_ZN6test131AC1Ev`, no? If the false expression throws, there is nothing to 
> > clean up in the false expression and also nothing in the true expression 
> > has to be cleaned up.
>
>
> Yes, this is true.  It would be possible to enhance Clang's cleanup stack to 
> support this sort of thing — we'd want to be able to mark a cleanup as 
> "currently known inactive" without potentially popping it off the cleanup 
> stack, and then we could have conditional scopes remember the cleanups that 
> were added, deactivate them this way, and then reactivate them after the 
> merge.  Swift's cleanup manager supports something similar.


OK, I see. Since the enhancement isn't trivial to implement, I think we should 
do it in a separate patch if it has a large impact on code size. WDYT?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82999



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


[clang] 00068c4 - Improve diagnostics for constant evaluation that fails because a

2020-07-08 Thread Richard Smith via cfe-commits

Author: Richard Smith
Date: 2020-07-08T18:14:23-07:00
New Revision: 00068c452a599c328986e8afcbb3311331d09d26

URL: 
https://github.com/llvm/llvm-project/commit/00068c452a599c328986e8afcbb3311331d09d26
DIFF: 
https://github.com/llvm/llvm-project/commit/00068c452a599c328986e8afcbb3311331d09d26.diff

LOG: Improve diagnostics for constant evaluation that fails because a
variable's initializer is not known.

The hope is that a better diagnostic for this case will reduce the rate
at which duplicates of non-bug PR41093 are reported.

Added: 


Modified: 
clang/include/clang/Basic/DiagnosticASTKinds.td
clang/lib/AST/ExprConstant.cpp
clang/test/CXX/expr/expr.const/p2-0x.cpp
clang/test/CXX/temp/temp.res/temp.dep/temp.dep.constexpr/p2.cpp
clang/test/SemaCXX/constant-expression-cxx11.cpp
clang/test/SemaCXX/constant-expression-cxx1y.cpp
clang/test/SemaCXX/cxx1y-variable-templates_in_class.cpp

Removed: 




diff  --git a/clang/include/clang/Basic/DiagnosticASTKinds.td 
b/clang/include/clang/Basic/DiagnosticASTKinds.td
index 905e3158cf40..10bedaaf7aba 100644
--- a/clang/include/clang/Basic/DiagnosticASTKinds.td
+++ b/clang/include/clang/Basic/DiagnosticASTKinds.td
@@ -101,8 +101,16 @@ def note_constexpr_null_subobject : Note<
   "access array element of|perform pointer arithmetic on|"
   "access real component of|"
   "access imaginary component of}0 null pointer">;
+def note_constexpr_function_param_value_unknown : Note<
+  "function parameter %0 with unknown value cannot be used in a constant "
+  "expression">;
+def note_constexpr_var_init_unknown : Note<
+  "initializer of %0 is unknown">;
 def note_constexpr_var_init_non_constant : Note<
   "initializer of %0 is not a constant expression">;
+def note_constexpr_var_init_weak : Note<
+  "initializer of weak variable %0 is not considered constant because "
+  "it may be 
diff erent at runtime">;
 def note_constexpr_typeid_polymorphic : Note<
   "typeid applied to expression of polymorphic type %0 is "
   "not allowed in a constant expression in C++ standards before C++20">;
@@ -159,6 +167,9 @@ def note_constexpr_access_mutable : Note<
   "mutable member %1 is not allowed in a constant expression">;
 def note_constexpr_ltor_non_const_int : Note<
   "read of non-const variable %0 is not allowed in a constant expression">;
+def note_constexpr_ltor_non_integral : Note<
+  "read of variable %0 of non-integral, non-enumeration type %1 "
+  "is not allowed in a constant expression">;
 def note_constexpr_ltor_non_constexpr : Note<
   "read of non-constexpr variable %0 is not allowed in a constant expression">;
 def note_constexpr_ltor_incomplete_type : Note<

diff  --git a/clang/lib/AST/ExprConstant.cpp b/clang/lib/AST/ExprConstant.cpp
index 9eba40c44ddc..d6dbfb14e60b 100644
--- a/clang/lib/AST/ExprConstant.cpp
+++ b/clang/lib/AST/ExprConstant.cpp
@@ -3025,7 +3025,7 @@ static bool evaluateVarDeclInit(EvalInfo , const 
Expr *E,
 if (Info.checkingPotentialConstantExpression())
   return false;
 if (!Frame || !Frame->Arguments) {
-  Info.FFDiag(E, diag::note_invalid_subexpr_in_const_expr);
+  Info.FFDiag(E, diag::note_constexpr_function_param_value_unknown) << VD;
   return false;
 }
 Result = >Arguments[PVD->getFunctionScopeIndex()];
@@ -3056,12 +3056,34 @@ static bool evaluateVarDeclInit(EvalInfo , const 
Expr *E,
   }
 
   // Dig out the initializer, and use the declaration which it's attached to.
+  // FIXME: We should eventually check whether the variable has a reachable
+  // initializing declaration.
   const Expr *Init = VD->getAnyInitializer(VD);
-  if (!Init || Init->isValueDependent()) {
-// If we're checking a potential constant expression, the variable could be
-// initialized later.
-if (!Info.checkingPotentialConstantExpression())
-  Info.FFDiag(E, diag::note_invalid_subexpr_in_const_expr);
+  if (!Init) {
+// Don't diagnose during potential constant expression checking; an
+// initializer might be added later.
+if (!Info.checkingPotentialConstantExpression()) {
+  Info.FFDiag(E, diag::note_constexpr_var_init_unknown, 1)
+<< VD;
+  Info.Note(VD->getLocation(), diag::note_declared_at);
+}
+return false;
+  }
+
+  if (Init->isValueDependent()) {
+// The DeclRefExpr is not value-dependent, but the variable it refers to
+// has a value-dependent initializer. This should only happen in
+// constant-folding cases, where the variable is not actually of a suitable
+// type for use in a constant expression (otherwise the DeclRefExpr would
+// have been value-dependent too), so diagnose that.
+assert(!VD->mightBeUsableInConstantExpressions(Info.Ctx));
+if (!Info.checkingPotentialConstantExpression()) {
+  Info.FFDiag(E, Info.getLangOpts().CPlusPlus11
+ ? diag::note_constexpr_ltor_non_constexpr
+ : 

[PATCH] D83419: [clangd] Add error() function for creating formatv-style llvm::Errors. NFC

2020-07-08 Thread Sam McCall via Phabricator via cfe-commits
sammccall added a comment.

In D83419#2140311 , @njames93 wrote:

> I'm not a huge fan of using `error`, maybe `createError`, 
>  Its definitely out of place in Logger, but there is no where else better for 
> it to live short of a new file which seems overkill.


Yeah, the naming is definitely the hardest part to be sure of here.
It's an extremely commonly used function: 75 references to StringError + 
another 20 or so references to local helpers.
This puts it in the same class as log (95), vlog (50), elog(85).
It's also similar in that it is cross cutting and has the same format string + 
args shape (so wrapping affects it similarly).

> its used in many other parts of llvm, typically with static linkage.

Yeah, there's some precedent, though not overwhelming consensus. Outside clangd 
I count 10 `createError`s, 7 `make_string_error`s, 4 `error`s, 1 `makeError`, 1 
`makeStringError`, and the canonical `makeStringError` and `make_error`.

But I think this is just a place where wider LLVM is making different tradeoffs:

- for good reasons:  many errors are diagnostics or don't need to be carefully 
routed back to a specific request
- for bad reasons: e.g. compliance with the "verb phrase" policy that's poorly 
observed and itself seems like a sad accident of history: 
http://lists.llvm.org/pipermail/llvm-dev/2018-May/thread.html#123547
- llvm::Error itself seems like a pretty strong argument that existing practice 
doesn't guarantee good ergonomics


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83419



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


[PATCH] D82085: [TRE] allow TRE for non-capturing calls.

2020-07-08 Thread Alexey Lapshin via Phabricator via cfe-commits
avl marked an inline comment as done.
avl added inline comments.



Comment at: llvm/lib/Transforms/Scalar/TailRecursionElimination.cpp:474
+  // Operand Bundles or not marked as TailCall.
+  if (CI->isNoTailCall() || CI->hasOperandBundles() || !CI->isTailCall())
 return nullptr;

efriedma wrote:
> The hasOperandBundles() check looks completely new; is there some test for it?
> 
> The `isNoTailCall()` check is currently redundant; it isn't legal to write 
> "tail notail".  I guess it makes sense to guard against that, though.
>The hasOperandBundles() check looks completely new; is there some test for it?

it is not new. it is copied from 245 line. Now, when patch changed from its 
original state all above conditions could be changed just to :

if (!CI->isTailCall())

the test is Transforms/TailCallElim/deopt-bundle.ll

>The isNoTailCall() check is currently redundant; it isn't legal to write "tail 
>notail". I guess it makes sense to guard against that, though.

would add checking for that.



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82085



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


[PATCH] D82085: [TRE] allow TRE for non-capturing calls.

2020-07-08 Thread Eli Friedman via Phabricator via cfe-commits
efriedma added a comment.

I think I'd like to see a testcase where there are multiple recursive calls, 
but only one is a tail call that can be eliminated.




Comment at: llvm/lib/Transforms/Scalar/TailRecursionElimination.cpp:474
+  // Operand Bundles or not marked as TailCall.
+  if (CI->isNoTailCall() || CI->hasOperandBundles() || !CI->isTailCall())
 return nullptr;

The hasOperandBundles() check looks completely new; is there some test for it?

The `isNoTailCall()` check is currently redundant; it isn't legal to write 
"tail notail".  I guess it makes sense to guard against that, though.



Comment at: llvm/test/Transforms/TailCallElim/basic.ll:23
+; CHECK: call i32 @test1
+   %X = call i32 @test1()  ;  [#uses=1]
ret i32 %X

I'm not sure this is testing what it was originally supposed to.  I guess 
that's okay, but please fix the comment at least.



Comment at: 
llvm/test/Transforms/TailCallElim/tre-noncapturing-alloca-calls.ll:20
+; Function Attrs: nofree noinline norecurse nounwind uwtable
+define dso_local void @_Z15globalIncrementPKi(i32* nocapture readonly %param) 
local_unnamed_addr #0 {
+entry:

For the purpose of this testcase, we don't need the definition of 
_Z15globalIncrementPKi.



Comment at: 
llvm/test/Transforms/TailCallElim/tre-noncapturing-alloca-calls.ll:37
+; CHECK: br label %tailrecurse
+; CHECK-NOT: call void @_Z4testi
+; CHECK: ret

I think I'd prefer to just generate this with update_test_checks.py


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82085



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


[PATCH] D82663: [CodeGen] Have CodeGen for fixed-point unsigned with padding emit signed operations.

2020-07-08 Thread Leonard Chan via Phabricator via cfe-commits
leonardchan added a comment.

In D82663#2130355 , @ebevhan wrote:

> Well, it's not so much as adding the bit, but adding the information that the 
> bit exists. That means either new intrinsics for all of the operations, or 
> adding flags to the existing ones. That's a fair bit of added complexity. 
> Also,  +  would do virtually the exact same 
> thing as the new unsigned-with-padding operations, so the utility of adding 
> all of it is a bit questionable.


Could the work involved just be adding the flags, then in 
`llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp` for unsigned 
operations, choosing between the signed/unsigned underlying `ISD` when lowering 
intrinsics to DAG? I think you could just pass the padding bit to 
`FixedPointIntrinsicToOpcode` and handle it from there. This is just off the 
top of my head so I could be missing other things.

I don't think this is necessarily the same as "legalizing" the intrinsic, but 
this would at least prevent frontends from second-guessing.




Comment at: clang/include/clang/Basic/FixedPoint.h:66
   /// given binary operation.
+  /// Is UnsignedPaddingIsSigned is true, unsigned semantics which would
+  /// otherwise have been unsigned will be signed instead. This is for codegen

Is -> If



Comment at: clang/lib/Basic/FixedPoint.cpp:143-158
+  // For codegen purposes, make unsigned with padding semantics signed instead.
+  // This means that we will generate signed operations. The result from these
+  // operations is defined, since ending up with a negative result is undefined
+  // for nonsaturating semantics, and for saturating semantics we will
+  // perform a clamp-to-zero in the last conversion to result semantics (since
+  // we are going from saturating signed to saturating unsigned).
+  //

If this is exclusively for codegen purposes with binary operations, would it be 
clearer to move this to `EmitFixedPointBinOp`? If `UnsignedPaddingIsSigned` 
doesn't need to be used for stuff like constant evaluation, it might be clearer 
not to provide it for everyone.



Comment at: clang/test/Frontend/fixed_point_add.c:290-294
+  // UNSIGNED-NEXT: [[USA_EXT:%[a-z0-9]+]] = zext i16 [[USA]] to i40
+  // UNSIGNED-NEXT: [[I_EXT:%[a-z0-9]+]] = zext i32 [[I]] to i40
+  // UNSIGNED-NEXT: [[I:%[a-z0-9]+]] = shl i40 [[I_EXT]], 7
+  // UNSIGNED-NEXT: [[SUM:%[0-9]+]] = add i40 [[USA_EXT]], [[I]]
+  // UNSIGNED-NEXT: [[RES:%[a-z0-9]+]] = trunc i40 [[SUM]] to i16

If this is a workaround for not being able to convey the padding bit to LLVM 
intrinsics, I think we should only limit changes to instances we would use 
intrinsics.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82663



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


[PATCH] D82085: [TRE] allow TRE for non-capturing calls.

2020-07-08 Thread Alexey Lapshin via Phabricator via cfe-commits
avl updated this revision to Diff 276591.
avl added a comment.

addressed comments.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82085

Files:
  llvm/lib/Transforms/Scalar/TailRecursionElimination.cpp
  llvm/test/Transforms/TailCallElim/basic.ll
  llvm/test/Transforms/TailCallElim/tre-noncapturing-alloca-calls.ll

Index: llvm/test/Transforms/TailCallElim/tre-noncapturing-alloca-calls.ll
===
--- /dev/null
+++ llvm/test/Transforms/TailCallElim/tre-noncapturing-alloca-calls.ll
@@ -0,0 +1,69 @@
+; RUN: opt < %s -tailcallelim -verify-dom-info -S | FileCheck %s
+
+; IR for that test was generated from the following C++ source:
+;
+;int count;
+;__attribute__((noinline)) void globalIncrement(const int* param) { count += *param; }
+;
+;void test(int recurseCount)
+;{
+;if (recurseCount == 0) return;
+;int temp = 10;
+;globalIncrement();
+;test(recurseCount - 1);
+;}
+;
+
+@count = dso_local local_unnamed_addr global i32 0, align 4
+
+; Function Attrs: nofree noinline norecurse nounwind uwtable
+define dso_local void @_Z15globalIncrementPKi(i32* nocapture readonly %param) local_unnamed_addr #0 {
+entry:
+  %0 = load i32, i32* %param, align 4
+  %1 = load i32, i32* @count, align 4
+  %add = add nsw i32 %1, %0
+  store i32 %add, i32* @count, align 4
+  ret void
+}
+
+; Test that TRE could be done for recursive tail routine containing
+; call to function receiving a pointer to local stack. 
+
+; CHECK: void @_Z4testi
+; CHECK: br label %tailrecurse
+; CHECK: tailrecurse:
+; CHECK-NOT: call void @_Z4testi
+; CHECK: br label %tailrecurse
+; CHECK-NOT: call void @_Z4testi
+; CHECK: ret
+
+; Function Attrs: nounwind uwtable
+define dso_local void @_Z4testi(i32 %recurseCount) local_unnamed_addr #1 {
+entry:
+  %temp = alloca i32, align 4
+  %cmp = icmp eq i32 %recurseCount, 0
+  br i1 %cmp, label %return, label %if.end
+
+if.end:   ; preds = %entry
+  %0 = bitcast i32* %temp to i8*
+  call void @llvm.lifetime.start.p0i8(i64 4, i8* nonnull %0) #6
+  store i32 10, i32* %temp, align 4
+  call void @_Z15globalIncrementPKi(i32* nonnull %temp)
+  %sub = add nsw i32 %recurseCount, -1
+  call void @_Z4testi(i32 %sub)
+  call void @llvm.lifetime.end.p0i8(i64 4, i8* nonnull %0) #6
+  br label %return
+
+return:   ; preds = %entry, %if.end
+  ret void
+}
+
+; Function Attrs: argmemonly nounwind willreturn
+declare void @llvm.lifetime.start.p0i8(i64 immarg, i8* nocapture) #2
+
+; Function Attrs: argmemonly nounwind willreturn
+declare void @llvm.lifetime.end.p0i8(i64 immarg, i8* nocapture) #2
+
+attributes #0 = { nofree noinline norecurse nounwind uwtable }
+attributes #1 = { nounwind uwtable }
+attributes #2 = { argmemonly nounwind willreturn }
Index: llvm/test/Transforms/TailCallElim/basic.ll
===
--- llvm/test/Transforms/TailCallElim/basic.ll
+++ llvm/test/Transforms/TailCallElim/basic.ll
@@ -19,8 +19,8 @@
 	%A = alloca i32		;  [#uses=2]
 	store i32 5, i32* %A
 	call void @use(i32* %A)
-; CHECK: tail call i32 @test1
-	%X = tail call i32 @test1()		;  [#uses=1]
+; CHECK: call i32 @test1
+	%X = call i32 @test1()		;  [#uses=1]
 	ret i32 %X
 }
 
Index: llvm/lib/Transforms/Scalar/TailRecursionElimination.cpp
===
--- llvm/lib/Transforms/Scalar/TailRecursionElimination.cpp
+++ llvm/lib/Transforms/Scalar/TailRecursionElimination.cpp
@@ -81,6 +81,7 @@
 #include "llvm/Support/raw_ostream.h"
 #include "llvm/Transforms/Scalar.h"
 #include "llvm/Transforms/Utils/BasicBlockUtils.h"
+#include "llvm/Transforms/Utils/Local.h"
 using namespace llvm;
 
 #define DEBUG_TYPE "tailcallelim"
@@ -92,7 +93,10 @@
 /// Scan the specified function for alloca instructions.
 /// If it contains any dynamic allocas, returns false.
 static bool canTRE(Function ) {
-  // Because of PR962, we don't TRE dynamic allocas.
+  // TODO: We don't do TRE if dynamic allocas are used.
+  // Dynamic allocas allocate stack space which should be
+  // deallocated before new iteration started. That is
+  // currently not implemented.
   return llvm::all_of(instructions(F), [](Instruction ) {
 auto *AI = dyn_cast();
 return !AI || AI->isStaticAlloca();
@@ -185,11 +189,9 @@
 };
 }
 
-static bool markTails(Function , bool ,
-  OptimizationRemarkEmitter *ORE) {
+static bool markTails(Function , OptimizationRemarkEmitter *ORE) {
   if (F.callsFunctionThatReturnsTwice())
 return false;
-  AllCallsAreTailCalls = true;
 
   // The local stack holds all alloca instructions and all byval arguments.
   AllocaDerivedValueTracker Tracker;
@@ -272,11 +274,8 @@
 }
   }
 
-  if (!IsNoTail && Escaped == UNESCAPED && !Tracker.AllocaUsers.count(CI)) {
+  if (!IsNoTail && Escaped 

[PATCH] D82800: [OPENMP50] extend array section for stride (Parsing/Sema/AST)

2020-07-08 Thread Chi Chun Chen via Phabricator via cfe-commits
cchen updated this revision to Diff 276589.
cchen added a comment.

Fix message and rebase


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82800

Files:
  clang/include/clang-c/Index.h
  clang/include/clang/AST/ExprOpenMP.h
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Parse/Parser.h
  clang/include/clang/Sema/Sema.h
  clang/lib/AST/StmtPrinter.cpp
  clang/lib/CodeGen/CGExpr.cpp
  clang/lib/CodeGen/CGOpenMPRuntime.cpp
  clang/lib/Parse/ParseExpr.cpp
  clang/lib/Parse/ParseOpenMP.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/lib/Sema/SemaOpenMP.cpp
  clang/lib/Sema/TreeTransform.h
  clang/lib/Serialization/ASTReaderStmt.cpp
  clang/lib/Serialization/ASTWriterStmt.cpp
  clang/test/OpenMP/target_data_messages.c
  clang/test/OpenMP/target_depend_messages.cpp
  clang/test/OpenMP/target_enter_data_depend_messages.cpp
  clang/test/OpenMP/target_exit_data_depend_messages.cpp
  clang/test/OpenMP/target_map_messages.cpp
  clang/test/OpenMP/target_parallel_depend_messages.cpp
  clang/test/OpenMP/target_parallel_for_depend_messages.cpp
  clang/test/OpenMP/target_parallel_for_simd_depend_messages.cpp
  clang/test/OpenMP/target_simd_depend_messages.cpp
  clang/test/OpenMP/target_teams_depend_messages.cpp
  clang/test/OpenMP/target_teams_distribute_depend_messages.cpp
  clang/test/OpenMP/target_teams_distribute_parallel_for_depend_messages.cpp
  
clang/test/OpenMP/target_teams_distribute_parallel_for_simd_depend_messages.cpp
  clang/test/OpenMP/target_teams_distribute_simd_depend_messages.cpp
  clang/test/OpenMP/target_update_ast_print.cpp
  clang/test/OpenMP/target_update_messages.cpp

Index: clang/test/OpenMP/target_update_messages.cpp
===
--- clang/test/OpenMP/target_update_messages.cpp
+++ clang/test/OpenMP/target_update_messages.cpp
@@ -1,6 +1,8 @@
-// RUN: %clang_cc1 -verify -fopenmp -ferror-limit 100 %s -Wuninitialized
+// RUN: %clang_cc1 -verify=expected,omp45 -fopenmp -fopenmp-version=45 -ferror-limit 100 -o - -std=c++11 %s -Wuninitialized
+// RUN: %clang_cc1 -verify=expected,omp50 -fopenmp -fopenmp-version=50 -ferror-limit 100 -o - -std=c++11 %s -Wuninitialized
 
-// RUN: %clang_cc1 -verify -fopenmp-simd -ferror-limit 100 %s -Wuninitialized
+// RUN: %clang_cc1 -verify=expected,omp45 -fopenmp-simd -fopenmp-version=45 -ferror-limit 100 -o - -std=c++11 %s -Wuninitialized
+// RUN: %clang_cc1 -verify=expected,omp50 -fopenmp-simd -fopenmp-version=50 -ferror-limit 100 -o - -std=c++11 %s -Wuninitialized
 
 void xxx(int argc) {
   int x; // expected-note {{initialize the variable 'x' to silence this warning}}
@@ -36,5 +38,11 @@
   {
 foo();
   }
+
+  int iarr[5][5];
+#pragma omp target update to(iarr[0:][1:2:-1]) // omp50-error {{section stride is evaluated to a non-positive value -1}} omp45-error {{expected ']'}} omp45-note {{to match this '['}} expected-error {{expected at least one 'to' clause or 'from' clause specified to '#pragma omp target update'}}
+  {}
+#pragma omp target update from(iarr[0:][1:2:-1]) // omp50-error {{section stride is evaluated to a non-positive value -1}} omp45-error {{expected ']'}} omp45-note {{to match this '['}} expected-error {{expected at least one 'to' clause or 'from' clause specified to '#pragma omp target update'}}
+
   return tmain(argc, argv);
 }
Index: clang/test/OpenMP/target_update_ast_print.cpp
===
--- clang/test/OpenMP/target_update_ast_print.cpp
+++ clang/test/OpenMP/target_update_ast_print.cpp
@@ -20,6 +20,11 @@
 #pragma omp target update to(([a][targ])p, a) if(l>5) device(l) nowait depend(inout:l)
 
 #pragma omp target update from(b, ([a][targ])p) if(l<5) device(l-1) nowait depend(inout:l)
+
+  int arr[100][100];
+#pragma omp target update to(arr[2][0:1:2])
+
+#pragma omp target update from(arr[2][0:1:2])
   return a + targ + (T)b;
 }
 // CHECK:  static T a, *p;
@@ -37,6 +42,9 @@
 // CHECK-NEXT: int l;
 // CHECK-NEXT: #pragma omp target update to(([a][targ])p,a) if(l > 5) device(l) nowait depend(inout : l)
 // CHECK-NEXT: #pragma omp target update from(b,([a][targ])p) if(l < 5) device(l - 1) nowait depend(inout : l)
+// CHECK:  int arr[100][100];
+// CHECK-NEXT: #pragma omp target update to(arr[2][0:1:2])
+// CHECK-NEXT: #pragma omp target update from(arr[2][0:1:2])
 
 int main(int argc, char **argv) {
   static int a;
@@ -50,6 +58,11 @@
 // CHECK-NEXT: #pragma omp target update to(a) if(f > 0.) device(n) nowait depend(in : n)
 #pragma omp target update from(f) if(f<0.0) device(n+1) nowait depend(in:n)
 // CHECK-NEXT: #pragma omp target update from(f) if(f < 0.) device(n + 1) nowait depend(in : n)
+#pragma omp target update to(argv[2][0:1:2])
+// CHECK-NEXT: #pragma omp target update to(argv[2][0:1:2])
+#pragma omp target update from(argv[2][0:1:2])
+// CHECK-NEXT: #pragma omp target update from(argv[2][0:1:2])
+
   return 

[PATCH] D80897: [OpenMP] Initial support for std::complex in target regions

2020-07-08 Thread Johannes Doerfert via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGd999cbc98832: [OpenMP] Initial support for std::complex in 
target regions (authored by jdoerfert).

Changed prior to commit:
  https://reviews.llvm.org/D80897?vs=276053=276584#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80897

Files:
  clang/lib/Headers/CMakeLists.txt
  clang/lib/Headers/__clang_cuda_complex_builtins.h
  clang/lib/Headers/__clang_cuda_math.h
  clang/lib/Headers/openmp_wrappers/complex
  clang/lib/Headers/openmp_wrappers/complex.h
  clang/test/Headers/Inputs/include/cmath
  clang/test/Headers/Inputs/include/complex
  clang/test/Headers/Inputs/include/cstdlib
  clang/test/Headers/nvptx_device_math_complex.c
  clang/test/Headers/nvptx_device_math_complex.cpp

Index: clang/test/Headers/nvptx_device_math_complex.cpp
===
--- /dev/null
+++ clang/test/Headers/nvptx_device_math_complex.cpp
@@ -0,0 +1,27 @@
+// REQUIRES: nvptx-registered-target
+// RUN: %clang_cc1 -verify -internal-isystem %S/Inputs/include -fopenmp -x c++ -triple powerpc64le-unknown-unknown -fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm-bc %s -o %t-ppc-host.bc
+// RUN: %clang_cc1 -verify -internal-isystem %S/../../lib/Headers/openmp_wrappers -include __clang_openmp_device_functions.h -internal-isystem %S/Inputs/include -fopenmp -x c++ -triple nvptx64-unknown-unknown -fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm %s -fopenmp-is-device -fopenmp-host-ir-file-path %t-ppc-host.bc -aux-triple powerpc64le-unknown-unknown -o - | FileCheck %s
+// expected-no-diagnostics
+
+#include 
+
+// CHECK-DAG: define {{.*}} @__mulsc3
+// CHECK-DAG: define {{.*}} @__muldc3
+// CHECK-DAG: define {{.*}} @__divsc3
+// CHECK-DAG: define {{.*}} @__divdc3
+
+// CHECK-DAG: call float @__nv_scalbnf(
+void test_scmplx(std::complex a) {
+#pragma omp target
+  {
+(void)(a * (a / a));
+  }
+}
+
+// CHECK-DAG: call double @__nv_scalbn(
+void test_dcmplx(std::complex a) {
+#pragma omp target
+  {
+(void)(a * (a / a));
+  }
+}
Index: clang/test/Headers/nvptx_device_math_complex.c
===
--- clang/test/Headers/nvptx_device_math_complex.c
+++ clang/test/Headers/nvptx_device_math_complex.c
@@ -1,10 +1,22 @@
 // REQUIRES: nvptx-registered-target
-// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple powerpc64le-unknown-unknown -fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm-bc %s -o %t-ppc-host.bc
-// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple nvptx64-unknown-unknown -fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm %s -fopenmp-is-device -fopenmp-host-ir-file-path %t-ppc-host.bc -o - | FileCheck %s
+// RUN: %clang_cc1 -verify -internal-isystem %S/Inputs/include -fopenmp -x c -triple powerpc64le-unknown-unknown -fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm-bc %s -o %t-ppc-host.bc
+// RUN: %clang_cc1 -verify -internal-isystem %S/../../lib/Headers/openmp_wrappers -include __clang_openmp_device_functions.h -internal-isystem %S/Inputs/include -fopenmp -x c -triple nvptx64-unknown-unknown -fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm %s -fopenmp-is-device -fopenmp-host-ir-file-path %t-ppc-host.bc -aux-triple powerpc64le-unknown-unknown -o - | FileCheck %s
+// RUN: %clang_cc1 -verify -internal-isystem %S/Inputs/include -fopenmp -x c++ -triple powerpc64le-unknown-unknown -fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm-bc %s -o %t-ppc-host.bc
+// RUN: %clang_cc1 -verify -internal-isystem %S/../../lib/Headers/openmp_wrappers -include __clang_openmp_device_functions.h -internal-isystem %S/Inputs/include -fopenmp -x c++ -triple nvptx64-unknown-unknown -fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm %s -fopenmp-is-device -fopenmp-host-ir-file-path %t-ppc-host.bc -aux-triple powerpc64le-unknown-unknown -o - | FileCheck %s
 // expected-no-diagnostics
 
-// CHECK-DAG: call { float, float } @__divsc3(
-// CHECK-DAG: call { float, float } @__mulsc3(
+#ifdef __cplusplus
+#include 
+#else
+#include 
+#endif
+
+// CHECK-DAG: define {{.*}} @__mulsc3
+// CHECK-DAG: define {{.*}} @__muldc3
+// CHECK-DAG: define {{.*}} @__divsc3
+// CHECK-DAG: define {{.*}} @__divdc3
+
+// CHECK-DAG: call float @__nv_scalbnf(
 void test_scmplx(float _Complex a) {
 #pragma omp target
   {
@@ -12,9 +24,7 @@
   }
 }
 
-
-// CHECK-DAG: call { double, double } @__divdc3(
-// CHECK-DAG: call { double, double } @__muldc3(
+// CHECK-DAG: call double @__nv_scalbn(
 void test_dcmplx(double _Complex a) {
 #pragma omp target
   {
Index: clang/test/Headers/Inputs/include/cstdlib
===
--- clang/test/Headers/Inputs/include/cstdlib
+++ clang/test/Headers/Inputs/include/cstdlib
@@ -24,4 +24,8 @@
 abs(long long __x) { return __builtin_llabs (__x); }
 
 float fabs(float __x) { return __builtin_fabs(__x); }
+
+float abs(float __x) { return fabs(__x); 

[clang] d999cbc - [OpenMP] Initial support for std::complex in target regions

2020-07-08 Thread Johannes Doerfert via cfe-commits

Author: Johannes Doerfert
Date: 2020-07-08T17:33:59-05:00
New Revision: d999cbc98832154e15e786b98281211d5c1b9f5d

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

LOG: [OpenMP] Initial support for std::complex in target regions

This simply follows the scheme we have for other wrappers. It resolves
the current link problem, e.g., `__muldc3 not found`, when std::complex
operations are used on a device.

This will not allow complex make math function calls to work properly,
e.g., sin, but that is more complex (pan intended) anyway.

Reviewed By: tra, JonChesterfield

Differential Revision: https://reviews.llvm.org/D80897

Added: 
clang/lib/Headers/openmp_wrappers/complex
clang/lib/Headers/openmp_wrappers/complex.h
clang/test/Headers/Inputs/include/complex
clang/test/Headers/nvptx_device_math_complex.cpp

Modified: 
clang/lib/Headers/CMakeLists.txt
clang/lib/Headers/__clang_cuda_complex_builtins.h
clang/lib/Headers/__clang_cuda_math.h
clang/test/Headers/Inputs/include/cmath
clang/test/Headers/Inputs/include/cstdlib
clang/test/Headers/nvptx_device_math_complex.c

Removed: 




diff  --git a/clang/lib/Headers/CMakeLists.txt 
b/clang/lib/Headers/CMakeLists.txt
index e7bee192d918..0692fe75a441 100644
--- a/clang/lib/Headers/CMakeLists.txt
+++ b/clang/lib/Headers/CMakeLists.txt
@@ -151,6 +151,8 @@ set(ppc_wrapper_files
 set(openmp_wrapper_files
   openmp_wrappers/math.h
   openmp_wrappers/cmath
+  openmp_wrappers/complex.h
+  openmp_wrappers/complex
   openmp_wrappers/__clang_openmp_device_functions.h
   openmp_wrappers/new
 )

diff  --git a/clang/lib/Headers/__clang_cuda_complex_builtins.h 
b/clang/lib/Headers/__clang_cuda_complex_builtins.h
index 576a958b16bb..d698be71d011 100644
--- a/clang/lib/Headers/__clang_cuda_complex_builtins.h
+++ b/clang/lib/Headers/__clang_cuda_complex_builtins.h
@@ -13,10 +13,61 @@
 // This header defines __muldc3, __mulsc3, __divdc3, and __divsc3.  These are
 // libgcc functions that clang assumes are available when compiling c99 complex
 // operations.  (These implementations come from libc++, and have been modified
-// to work with CUDA.)
+// to work with CUDA and OpenMP target offloading [in C and C++ mode].)
 
-extern "C" inline __device__ double _Complex __muldc3(double __a, double __b,
-  double __c, double __d) {
+#pragma push_macro("__DEVICE__")
+#ifdef _OPENMP
+#pragma omp declare target
+#define __DEVICE__ __attribute__((noinline, nothrow, cold))
+#else
+#define __DEVICE__ __device__ inline
+#endif
+
+// Make the algorithms available for C and C++ by selecting the right 
functions.
+#if defined(__cplusplus)
+// TODO: In OpenMP mode we cannot overload isinf/isnan/isfinite the way we
+// overload all other math functions because old math system headers and not
+// always conformant and return an integer instead of a boolean. Until that has
+// been addressed we need to work around it. For now, we substituate with the
+// calls we would have used to implement those three functions. Note that we
+// could use the C alternatives as well.
+#define _ISNANd ::__isnan
+#define _ISNANf ::__isnanf
+#define _ISINFd ::__isinf
+#define _ISINFf ::__isinff
+#define _ISFINITEd ::__isfinited
+#define _ISFINITEf ::__finitef
+#define _COPYSIGNd std::copysign
+#define _COPYSIGNf std::copysign
+#define _SCALBNd std::scalbn
+#define _SCALBNf std::scalbn
+#define _ABSd std::abs
+#define _ABSf std::abs
+#define _LOGBd std::logb
+#define _LOGBf std::logb
+#else
+#define _ISNANd isnan
+#define _ISNANf isnanf
+#define _ISINFd isinf
+#define _ISINFf isinff
+#define _ISFINITEd isfinite
+#define _ISFINITEf isfinitef
+#define _COPYSIGNd copysign
+#define _COPYSIGNf copysignf
+#define _SCALBNd scalbn
+#define _SCALBNf scalbnf
+#define _ABSd abs
+#define _ABSf absf
+#define _LOGBd logb
+#define _LOGBf logbf
+#endif
+
+#if defined(__cplusplus)
+extern "C" {
+#endif
+
+__DEVICE__ double _Complex __muldc3(double __a, double __b, double __c,
+double __d) {
   double __ac = __a * __c;
   double __bd = __b * __d;
   double __ad = __a * __d;
@@ -24,50 +75,49 @@ extern "C" inline __device__ double _Complex 
__muldc3(double __a, double __b,
   double _Complex z;
   __real__(z) = __ac - __bd;
   __imag__(z) = __ad + __bc;
-  if (std::isnan(__real__(z)) && std::isnan(__imag__(z))) {
+  if (_ISNANd(__real__(z)) && _ISNANd(__imag__(z))) {
 int __recalc = 0;
-if (std::isinf(__a) || std::isinf(__b)) {
-  __a = std::copysign(std::isinf(__a) ? 1 : 0, __a);
-  __b = std::copysign(std::isinf(__b) ? 1 : 0, __b);
-  if (std::isnan(__c))
-__c = std::copysign(0, __c);
-  if (std::isnan(__d))
-__d = std::copysign(0, __d);
+if (_ISINFd(__a) 

[PATCH] D71124: [RISCV] support clang driver to select cpu

2020-07-08 Thread Sam Elliott via Phabricator via cfe-commits
lenary added a comment.

I realise this is almost certainly something we want to land before the LLVM 11 
branch date, as we included schedules in LLVM 10 with no way to use them, and 
would like users to be able to use them. I'll bring it up on the call tomorrow 
- I hope this PR implements what we agreed from the previous calls.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71124



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


[PATCH] D83360: [InstSimplify] Remove select ?, undef, X -> X and select ?, X, undef -> X

2020-07-08 Thread Nuno Lopes via Phabricator via cfe-commits
nlopes added a comment.

In D83360#2140241 , @craig.topper 
wrote:

> Alive does like this https://alive2.llvm.org/ce/z/yhibbe which is what I was 
> going to implement.


right. There's a guaranteedNonPoison (or similar name) in ValueTracking that 
can be used I guess.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83360



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


[PATCH] D83436: [clangd] Fix error handling in config.yaml parsing.

2020-07-08 Thread Sam McCall via Phabricator via cfe-commits
sammccall created this revision.
sammccall added a reviewer: hokein.
Herald added subscribers: cfe-commits, usaxena95, kadircet, arphaman, jkorous, 
MaskRay, ilya-biryukov.
Herald added a project: clang.

A few things were broken:

- use of Document::parseBlockNode() is incorrect and prevents moving to the 
next doc in error cases. Use getRoot() instead.
- bailing out in the middle of iterating over a list/dict isn't allowed, unless 
you are going to throw away the parser: the next skip() asserts. Always consume 
all items.
- There were two concepts of fatal errors: error-diagnostics and drop-fragment. 
(The latter is the "return false" case in the parser). They didn't coincide. 
Now, parser errors and explicitly emitted error diagnostics are fatal.

Fixes https://github.com/clangd/clangd/issues/452


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D83436

Files:
  clang-tools-extra/clangd/ConfigYAML.cpp
  clang-tools-extra/clangd/unittests/ConfigYAMLTests.cpp

Index: clang-tools-extra/clangd/unittests/ConfigYAMLTests.cpp
===
--- clang-tools-extra/clangd/unittests/ConfigYAMLTests.cpp
+++ clang-tools-extra/clangd/unittests/ConfigYAMLTests.cpp
@@ -98,10 +98,25 @@
 DiagKind(llvm::SourceMgr::DK_Error),
 DiagPos(YAML.point()), DiagRange(llvm::None;
 
-  ASSERT_EQ(Results.size(), 2u);
+  ASSERT_EQ(Results.size(), 1u); // invalid fragment discarded.
   EXPECT_THAT(Results.front().CompileFlags.Add, ElementsAre(Val("first")));
   EXPECT_TRUE(Results.front().If.HasUnrecognizedCondition);
-  EXPECT_THAT(Results.back().CompileFlags.Add, IsEmpty());
+}
+
+TEST(ParseYAML, Invalid) {
+  CapturedDiags Diags;
+  const char *YAML = R"yaml(
+If:
+
+horrible
+---
+- 1
+  )yaml";
+  auto Results = Fragment::parseYAML(YAML, "config.yaml", Diags.callback());
+  EXPECT_THAT(Diags.Diagnostics,
+  ElementsAre(DiagMessage("If should be a dictionary"),
+  DiagMessage("Config should be a dictionary")));
+  ASSERT_THAT(Results, IsEmpty());
 }
 
 } // namespace
Index: clang-tools-extra/clangd/ConfigYAML.cpp
===
--- clang-tools-extra/clangd/ConfigYAML.cpp
+++ clang-tools-extra/clangd/ConfigYAML.cpp
@@ -26,6 +26,7 @@
 
 class Parser {
   llvm::SourceMgr 
+  bool HadError = false;
 
 public:
   Parser(llvm::SourceMgr ) : SM(SM) {}
@@ -35,40 +36,38 @@
   // The private parse() helpers follow the same pattern.
   bool parse(Fragment , Node ) {
 DictParser Dict("Config", this);
-Dict.handle("If", [&](Node ) { return parse(F.If, N); });
-Dict.handle("CompileFlags",
-[&](Node ) { return parse(F.CompileFlags, N); });
-return Dict.parse(N);
+Dict.handle("If", [&](Node ) { parse(F.If, N); });
+Dict.handle("CompileFlags", [&](Node ) { parse(F.CompileFlags, N); });
+Dict.parse(N);
+return !(N.failed() || HadError);
   }
 
 private:
-  bool parse(Fragment::IfBlock , Node ) {
+  void parse(Fragment::IfBlock , Node ) {
 DictParser Dict("If", this);
 Dict.unrecognized(
 [&](llvm::StringRef) { F.HasUnrecognizedCondition = true; });
 Dict.handle("PathMatch", [&](Node ) {
   if (auto Values = scalarValues(N))
 F.PathMatch = std::move(*Values);
-  return !N.failed();
 });
-return Dict.parse(N);
+Dict.parse(N);
   }
 
-  bool parse(Fragment::CompileFlagsBlock , Node ) {
+  void parse(Fragment::CompileFlagsBlock , Node ) {
 DictParser Dict("CompileFlags", this);
 Dict.handle("Add", [&](Node ) {
   if (auto Values = scalarValues(N))
 F.Add = std::move(*Values);
-  return !N.failed();
 });
-return Dict.parse(N);
+Dict.parse(N);
   }
 
   // Helper for parsing mapping nodes (dictionaries).
   // We don't use YamlIO as we want to control over unknown keys.
   class DictParser {
 llvm::StringRef Description;
-std::vector>> Keys;
+std::vector>> Keys;
 std::function Unknown;
 Parser *Outer;
 
@@ -79,7 +78,7 @@
 // Parse is called when Key is encountered, and passed the associated value.
 // It should emit diagnostics if the value is invalid (e.g. wrong type).
 // If Key is seen twice, Parse runs only once and an error is reported.
-void handle(llvm::StringLiteral Key, std::function Parse) {
+void handle(llvm::StringLiteral Key, std::function Parse) {
   for (const auto  : Keys) {
 (void) Entry;
 assert(Entry.first != Key && "duplicate key handler");
@@ -94,16 +93,17 @@
 }
 
 // Process a mapping node and call handlers for each key/value pair.
-bool parse(Node ) const {
+void parse(Node ) const {
   if (N.getType() != Node::NK_Mapping) {
 Outer->error(Description + " should be a dictionary", N);
-return false;
+return;
   }
   llvm::SmallSet Seen;
+  // We *must* consume all items, even on 

[PATCH] D83419: [clangd] Add error() function for creating formatv-style llvm::Errors. NFC

2020-07-08 Thread Nathan James via Phabricator via cfe-commits
njames93 added a comment.

I'm not a huge fan of using `error`, maybe `createError`, its used in many 
other parts of llvm, typically with static linkage.
Its definitely out of place in Logger, but there is no where else better for it 
to live short of a new file which seems overkill.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83419



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


[PATCH] D83364: [PowerPC][Power10] Implement Instruction definition and MC Tests for Load and Store VSX Vector with Zero or Sign Extend

2020-07-08 Thread Albion Fung via Phabricator via cfe-commits
Conanap marked 2 inline comments as done.
Conanap added a comment.

Relocated the isntr definitions to a more appropriate place.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83364



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


[PATCH] D83364: [PowerPC][Power10] Implement Instruction definition and MC Tests for Load and Store VSX Vector with Zero or Sign Extend

2020-07-08 Thread Albion Fung via Phabricator via cfe-commits
Conanap updated this revision to Diff 276564.
Conanap added a comment.

Relocated some of the instructions to a more appropriate place.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83364

Files:
  llvm/lib/Target/PowerPC/PPCInstrPrefix.td
  llvm/test/MC/Disassembler/PowerPC/ppc64-encoding-ISA31.txt
  llvm/test/MC/PowerPC/ppc64-encoding-ISA31.s


Index: llvm/test/MC/PowerPC/ppc64-encoding-ISA31.s
===
--- llvm/test/MC/PowerPC/ppc64-encoding-ISA31.s
+++ llvm/test/MC/PowerPC/ppc64-encoding-ISA31.s
@@ -405,3 +405,27 @@
 # CHECK-BE: vinsdrx 1, 2, 3   # encoding: 
[0x10,0x22,0x1b,0xcf]
 # CHECK-LE: vinsdrx 1, 2, 3   # encoding: 
[0xcf,0x1b,0x22,0x10]
 vinsdrx 1, 2, 3
+# CHECK-BE: lxvrbx 32, 1, 2   # encoding: 
[0x7c,0x01,0x10,0x1b]
+# CHECK-LE: lxvrbx 32, 1, 2   # encoding: 
[0x1b,0x10,0x01,0x7c]
+lxvrbx 32, 1, 2
+# CHECK-BE: lxvrhx 33, 1, 2   # encoding: 
[0x7c,0x21,0x10,0x5b]
+# CHECK-LE: lxvrhx 33, 1, 2   # encoding: 
[0x5b,0x10,0x21,0x7c]
+lxvrhx 33, 1, 2
+# CHECK-BE: lxvrdx 34, 1, 2   # encoding: 
[0x7c,0x41,0x10,0xdb]
+# CHECK-LE: lxvrdx 34, 1, 2   # encoding: 
[0xdb,0x10,0x41,0x7c]
+lxvrdx 34, 1, 2
+# CHECK-BE: lxvrwx 35, 1, 2   # encoding: 
[0x7c,0x61,0x10,0x9b]
+# CHECK-LE: lxvrwx 35, 1, 2   # encoding: 
[0x9b,0x10,0x61,0x7c]
+lxvrwx 35, 1, 2
+# CHECK-BE: stxvrbx 32, 3, 1  # encoding: 
[0x7c,0x03,0x09,0x1b]
+# CHECK-LE: stxvrbx 32, 3, 1  # encoding: 
[0x1b,0x09,0x03,0x7c]
+stxvrbx 32, 3, 1
+# CHECK-BE: stxvrhx 33, 3, 1  # encoding: 
[0x7c,0x23,0x09,0x5b]
+# CHECK-LE: stxvrhx 33, 3, 1  # encoding: 
[0x5b,0x09,0x23,0x7c]
+stxvrhx 33, 3, 1
+# CHECK-BE: stxvrwx 34, 3, 1  # encoding: 
[0x7c,0x43,0x09,0x9b]
+# CHECK-LE: stxvrwx 34, 3, 1  # encoding: 
[0x9b,0x09,0x43,0x7c]
+stxvrwx 34, 3, 1
+# CHECK-BE: stxvrdx 35, 3, 1  # encoding: 
[0x7c,0x63,0x09,0xdb]
+# CHECK-LE: stxvrdx 35, 3, 1  # encoding: 
[0xdb,0x09,0x63,0x7c]
+stxvrdx 35, 3, 1
Index: llvm/test/MC/Disassembler/PowerPC/ppc64-encoding-ISA31.txt
===
--- llvm/test/MC/Disassembler/PowerPC/ppc64-encoding-ISA31.txt
+++ llvm/test/MC/Disassembler/PowerPC/ppc64-encoding-ISA31.txt
@@ -278,3 +278,27 @@
 
 # CHECK: vinsdrx 1, 2, 3
 0x10 0x22 0x1b 0xcf
+
+# CHECK: lxvrbx 32, 1, 2
+0x7c 0x01 0x10 0x1b
+
+# CHECK: lxvrhx 33, 1, 2
+0x7c 0x21 0x10 0x5b
+
+# CHECK: lxvrdx 34, 1, 2
+0x7c 0x41 0x10 0xdb
+
+# CHECK: lxvrwx 35, 1, 2
+0x7c 0x61 0x10 0x9b
+
+# CHECK: stxvrbx 32, 3, 1
+0x7c 0x03 0x09 0x1b
+
+# CHECK: stxvrhx 33, 3, 1
+0x7c 0x23 0x09 0x5b
+
+# CHECK: stxvrwx 34, 3, 1
+0x7c 0x43 0x09 0x9b
+
+# CHECK: stxvrdx 35, 3, 1
+0x7c 0x63 0x09 0xdb
Index: llvm/lib/Target/PowerPC/PPCInstrPrefix.td
===
--- llvm/lib/Target/PowerPC/PPCInstrPrefix.td
+++ llvm/lib/Target/PowerPC/PPCInstrPrefix.td
@@ -934,8 +934,25 @@
  "vclrrb $vD, $vA, $rB", IIC_VecGeneral,
  [(set v16i8:$vD,
(int_ppc_altivec_vclrrb v16i8:$vA, i32:$rB))]>;
+
+  // The XFormMemOp flag for the following 8 insts is set on the instruction 
format.
+  let mayLoad = 1, mayStore = 1 in {
+def LXVRBX : X_XT6_RA5_RB5<31, 13, "lxvrbx", vsrc, []>;
+def LXVRHX : X_XT6_RA5_RB5<31, 45, "lxvrhx", vsrc, []>;
+def LXVRWX : X_XT6_RA5_RB5<31, 77, "lxvrwx", vsrc, []>;
+def LXVRDX : X_XT6_RA5_RB5<31, 109, "lxvrdx", vsrc, []>;
+  }
+
+  let mayLoad = 0, mayStore = 1 in {
+def STXVRBX : X_XS6_RA5_RB5<31, 141, "stxvrbx", vsrc, []>;
+def STXVRHX : X_XS6_RA5_RB5<31, 173, "stxvrhx", vsrc, []>;
+def STXVRWX : X_XS6_RA5_RB5<31, 205, "stxvrwx", vsrc, []>;
+def STXVRDX : X_XS6_RA5_RB5<31, 237, "stxvrdx", vsrc, []>;
+  }
 }
 
+
+
 // Anonymous Patterns 
//
 let Predicates = [IsISA3_1] in {
   def : Pat<(v16i8 (int_ppc_vsx_xxgenpcvbm v16i8:$VRB, imm:$IMM)),


Index: llvm/test/MC/PowerPC/ppc64-encoding-ISA31.s
===
--- llvm/test/MC/PowerPC/ppc64-encoding-ISA31.s
+++ llvm/test/MC/PowerPC/ppc64-encoding-ISA31.s
@@ -405,3 +405,27 @@
 # CHECK-BE: vinsdrx 1, 2, 3   # encoding: [0x10,0x22,0x1b,0xcf]
 # CHECK-LE: vinsdrx 1, 2, 3   # encoding: [0xcf,0x1b,0x22,0x10]
 vinsdrx 1, 2, 3
+# CHECK-BE: lxvrbx 32, 1, 2   # 

[PATCH] D83360: [InstSimplify] Remove select ?, undef, X -> X and select ?, X, undef -> X

2020-07-08 Thread Craig Topper via Phabricator via cfe-commits
craig.topper added a comment.

Alive does like this https://alive2.llvm.org/ce/z/yhibbe which is what I was 
going to implement.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83360



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


[PATCH] D83360: [InstSimplify] Remove select ?, undef, X -> X and select ?, X, undef -> X

2020-07-08 Thread Eli Friedman via Phabricator via cfe-commits
efriedma added a comment.

In D83360#2140224 , @regehr wrote:

> @craig.topper ok, I agree that should work. alive doesn't like it -- is this 
> an alive bug @nlopes? a freeze should not yield undef.
>  https://alive2.llvm.org/ce/z/mWAsYv


Did you mean to check something like the following?

  define i32 @src(i1 %cond, i32 %x) {
%x2 = freeze i32 %x
%s = select i1 %cond, i32 %x2, i32 undef
ret i32 %s
  }
  
  define i32 @tgt(i1 %cond, i32 %x) {
%x2 = freeze i32 %x
ret i32 %x2
  }


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83360



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


[PATCH] D83360: [InstSimplify] Remove select ?, undef, X -> X and select ?, X, undef -> X

2020-07-08 Thread John Regehr via Phabricator via cfe-commits
regehr added a comment.

@craig.topper ok, I agree that should work. alive doesn't like it -- is this an 
alive bug @nlopes? a freeze should not yield undef.
https://alive2.llvm.org/ce/z/mWAsYv


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83360



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


[PATCH] D82476: [Clang][Driver] Recognize the AIX OBJECT_MODE environment setting

2020-07-08 Thread Hubert Tong via Phabricator via cfe-commits
hubert.reinterpretcast accepted this revision.
hubert.reinterpretcast marked an inline comment as done.
hubert.reinterpretcast added a comment.

LGTM with minor nit.




Comment at: clang/lib/Driver/Driver.cpp:478
+  // On AIX, the env OBJECT_MODE may affect the resulting arch variant.
+  if (Target.isOSAIX()) {
+if (Optional ObjectModeValue =

Just a note: I guess having an AIX target is an okay proxy for being on AIX 
here... I don't think enabling `OBJECT_MODE` for other targets when building on 
AIX is superior.



Comment at: clang/test/Driver/aix-object-mode.c:1
+// Check setting an OBJECT_MODE converts the AIX triple to the right variant.
+// RUN: env OBJECT_MODE=64 \

Minor nit: Add "that" between "Check" and "setting".


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82476



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


[PATCH] D83360: [InstSimplify] Remove select ?, undef, X -> X and select ?, X, undef -> X

2020-07-08 Thread Craig Topper via Phabricator via cfe-commits
craig.topper added a comment.

Wasn't @majnemer asking about

  define i32 @src(i1 %cond, i32 %x) {
%xf = freeze i32 %x
%s = select i1 %cond, i32 %xf, i32 undef
ret i32 %s
  }

which is legal. I'm going to work on supporting known non-poison cases.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83360



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


[PATCH] D83360: [InstSimplify] Remove select ?, undef, X -> X and select ?, X, undef -> X

2020-07-08 Thread John Regehr via Phabricator via cfe-commits
regehr added a comment.

@majnemer should work: https://alive2.llvm.org/ce/z/vL4yn4


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83360



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


[PATCH] D83360: [InstSimplify] Remove select ?, undef, X -> X and select ?, X, undef -> X

2020-07-08 Thread David Majnemer via Phabricator via cfe-commits
majnemer added inline comments.



Comment at: llvm/lib/Analysis/InstructionSimplify.cpp:4121-4125
-  if (isa(TrueVal))   // select ?, undef, X -> X
-return FalseVal;
-  if (isa(FalseVal))   // select ?, X, undef -> X
-return TrueVal;
-

Can we still do these optimizations when `X` is a frozen value?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83360



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


[clang] 903bda1 - PR46640: Permit the first parameter of a destroying 'operator delete' to

2020-07-08 Thread Richard Smith via cfe-commits

Author: Richard Smith
Date: 2020-07-08T14:29:39-07:00
New Revision: 903bda14c330505ebede522a1f55673d88909c6d

URL: 
https://github.com/llvm/llvm-project/commit/903bda14c330505ebede522a1f55673d88909c6d
DIFF: 
https://github.com/llvm/llvm-project/commit/903bda14c330505ebede522a1f55673d88909c6d.diff

LOG: PR46640: Permit the first parameter of a destroying 'operator delete' to
be dependent if it names the right type.

This matches the GCC behavior, but no longer matches the standard
wording. However, the standard wording in this case is not in line with
the intent, which was to require the enclosing class type to be named
directly. I've reported this wording oversight to the committee.

Added: 


Modified: 
clang/lib/Sema/SemaDeclCXX.cpp
clang/test/SemaCXX/cxx2a-destroying-delete.cpp

Removed: 




diff  --git a/clang/lib/Sema/SemaDeclCXX.cpp b/clang/lib/Sema/SemaDeclCXX.cpp
index eb001a77518b..9cad6debc600 100644
--- a/clang/lib/Sema/SemaDeclCXX.cpp
+++ b/clang/lib/Sema/SemaDeclCXX.cpp
@@ -15216,12 +15216,6 @@ CheckOperatorNewDeleteTypes(Sema , const 
FunctionDecl *FnDecl,
   QualType ResultType =
   FnDecl->getType()->castAs()->getReturnType();
 
-  // Check that the result type is not dependent.
-  if (ResultType->isDependentType())
-return SemaRef.Diag(FnDecl->getLocation(),
-diag::err_operator_new_delete_dependent_result_type)
-<< FnDecl->getDeclName() << ExpectedResultType;
-
   // The operator is valid on any address space for OpenCL.
   if (SemaRef.getLangOpts().OpenCLCPlusPlus) {
 if (auto *PtrTy = ResultType->getAs()) {
@@ -15230,10 +15224,16 @@ CheckOperatorNewDeleteTypes(Sema , const 
FunctionDecl *FnDecl,
   }
 
   // Check that the result type is what we expect.
-  if (SemaRef.Context.getCanonicalType(ResultType) != ExpectedResultType)
-return SemaRef.Diag(FnDecl->getLocation(),
-diag::err_operator_new_delete_invalid_result_type)
-<< FnDecl->getDeclName() << ExpectedResultType;
+  if (SemaRef.Context.getCanonicalType(ResultType) != ExpectedResultType) {
+// Reject even if the type is dependent; an operator delete function is
+// required to have a non-dependent result type.
+return SemaRef.Diag(
+   FnDecl->getLocation(),
+   ResultType->isDependentType()
+   ? diag::err_operator_new_delete_dependent_result_type
+   : diag::err_operator_new_delete_invalid_result_type)
+   << FnDecl->getDeclName() << ExpectedResultType;
+  }
 
   // A function template must have at least 2 parameters.
   if (FnDecl->getDescribedFunctionTemplate() && FnDecl->getNumParams() < 2)
@@ -15247,13 +15247,7 @@ CheckOperatorNewDeleteTypes(Sema , const 
FunctionDecl *FnDecl,
 diag::err_operator_new_delete_too_few_parameters)
   << FnDecl->getDeclName();
 
-  // Check the first parameter type is not dependent.
   QualType FirstParamType = FnDecl->getParamDecl(0)->getType();
-  if (FirstParamType->isDependentType())
-return SemaRef.Diag(FnDecl->getLocation(), DependentParamTypeDiag)
-  << FnDecl->getDeclName() << ExpectedFirstParamType;
-
-  // Check that the first parameter type is what we expect.
   if (SemaRef.getLangOpts().OpenCLCPlusPlus) {
 // The operator is valid on any address space for OpenCL.
 if (auto *PtrTy =
@@ -15261,10 +15255,18 @@ CheckOperatorNewDeleteTypes(Sema , const 
FunctionDecl *FnDecl,
   FirstParamType = RemoveAddressSpaceFromPtr(SemaRef, PtrTy);
 }
   }
+
+  // Check that the first parameter type is what we expect.
   if (SemaRef.Context.getCanonicalType(FirstParamType).getUnqualifiedType() !=
-  ExpectedFirstParamType)
-return SemaRef.Diag(FnDecl->getLocation(), InvalidParamTypeDiag)
-<< FnDecl->getDeclName() << ExpectedFirstParamType;
+  ExpectedFirstParamType) {
+// The first parameter type is not allowed to be dependent. As a tentative
+// DR resolution, we allow a dependent parameter type if it is the right
+// type anyway, to allow destroying operator delete in class templates.
+return SemaRef.Diag(FnDecl->getLocation(), 
FirstParamType->isDependentType()
+   ? DependentParamTypeDiag
+   : InvalidParamTypeDiag)
+   << FnDecl->getDeclName() << ExpectedFirstParamType;
+  }
 
   return false;
 }

diff  --git a/clang/test/SemaCXX/cxx2a-destroying-delete.cpp 
b/clang/test/SemaCXX/cxx2a-destroying-delete.cpp
index 553b7a7080fe..015d11e65526 100644
--- a/clang/test/SemaCXX/cxx2a-destroying-delete.cpp
+++ b/clang/test/SemaCXX/cxx2a-destroying-delete.cpp
@@ -123,3 +123,21 @@ namespace first_param_conversion {
 delete e; // expected-error {{ambiguous conversion from derived class 
'first_param_conversion::E' to base class 'first_param_conversion::B':}}
   }
 }
+
+namespace 

[PATCH] D82646: [MSP430] Align the _Complex ABI with current msp430-gcc

2020-07-08 Thread Anton Korobeynikov via Phabricator via cfe-commits
asl accepted this revision.
asl added a comment.
This revision is now accepted and ready to land.

LGTM, thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82646



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


[PATCH] D83362: Fix warning caused by __builtin_expect_with_probability was not handled in places such as constant folding

2020-07-08 Thread Zhi Zhuang via Phabricator via cfe-commits
LukeZhuang marked an inline comment as done.
LukeZhuang added a comment.

Thank you for the new comment. I've modified my test cases


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

https://reviews.llvm.org/D83362



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


[PATCH] D83362: Fix warning caused by __builtin_expect_with_probability was not handled in places such as constant folding

2020-07-08 Thread Zhi Zhuang via Phabricator via cfe-commits
LukeZhuang updated this revision to Diff 276557.
LukeZhuang added a comment.

**updated: 07/08/2020**
(1) improve test case


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

https://reviews.llvm.org/D83362

Files:
  clang/lib/AST/ExprConstant.cpp
  clang/lib/StaticAnalyzer/Checkers/BuiltinFunctionChecker.cpp
  clang/test/Sema/builtin-expect-with-probability.cpp


Index: clang/test/Sema/builtin-expect-with-probability.cpp
===
--- clang/test/Sema/builtin-expect-with-probability.cpp
+++ clang/test/Sema/builtin-expect-with-probability.cpp
@@ -1,4 +1,30 @@
 // RUN: %clang_cc1 -fsyntax-only -verify %s
+
+__attribute__((noreturn)) extern void bar();
+
+int test_no_warn(int x) {
+  if (x) {
+if (__builtin_expect_with_probability(1, 1, 1))
+  bar();
+  } else {
+return 0;
+  }
+} // should not emit warn "control may reach end of non-void function" here 
since expr is constantly true, so the "if(__bui..)" should be constantly true 
condition and be ignored
+
+template  void tempf() {
+  static_assert(b == 1, "should be evaluated as 1"); // should not have error 
here
+}
+
+constexpr int constf() {
+  return __builtin_expect_with_probability(1, 1, 1);
+}
+
+void foo() {
+  tempf<__builtin_expect_with_probability(1, 1, 1)>();
+  constexpr int f = constf();
+  static_assert(f == 1, "should be evaluated as 1"); // should not have error 
here
+}
+
 extern int global;
 
 struct S {
Index: clang/lib/StaticAnalyzer/Checkers/BuiltinFunctionChecker.cpp
===
--- clang/lib/StaticAnalyzer/Checkers/BuiltinFunctionChecker.cpp
+++ clang/lib/StaticAnalyzer/Checkers/BuiltinFunctionChecker.cpp
@@ -64,10 +64,12 @@
 
   case Builtin::BI__builtin_unpredictable:
   case Builtin::BI__builtin_expect:
+  case Builtin::BI__builtin_expect_with_probability:
   case Builtin::BI__builtin_assume_aligned:
   case Builtin::BI__builtin_addressof: {
-// For __builtin_unpredictable, __builtin_expect, and
-// __builtin_assume_aligned, just return the value of the subexpression.
+// For __builtin_unpredictable, __builtin_expect,
+// __builtin_expect_with_probability and __builtin_assume_aligned,
+// just return the value of the subexpression.
 // __builtin_addressof is going from a reference to a pointer, but those
 // are represented the same way in the analyzer.
 assert (Call.getNumArgs() > 0);
Index: clang/lib/AST/ExprConstant.cpp
===
--- clang/lib/AST/ExprConstant.cpp
+++ clang/lib/AST/ExprConstant.cpp
@@ -11200,6 +11200,7 @@
   }
 
   case Builtin::BI__builtin_expect:
+  case Builtin::BI__builtin_expect_with_probability:
 return Visit(E->getArg(0));
 
   case Builtin::BI__builtin_ffs:


Index: clang/test/Sema/builtin-expect-with-probability.cpp
===
--- clang/test/Sema/builtin-expect-with-probability.cpp
+++ clang/test/Sema/builtin-expect-with-probability.cpp
@@ -1,4 +1,30 @@
 // RUN: %clang_cc1 -fsyntax-only -verify %s
+
+__attribute__((noreturn)) extern void bar();
+
+int test_no_warn(int x) {
+  if (x) {
+if (__builtin_expect_with_probability(1, 1, 1))
+  bar();
+  } else {
+return 0;
+  }
+} // should not emit warn "control may reach end of non-void function" here since expr is constantly true, so the "if(__bui..)" should be constantly true condition and be ignored
+
+template  void tempf() {
+  static_assert(b == 1, "should be evaluated as 1"); // should not have error here
+}
+
+constexpr int constf() {
+  return __builtin_expect_with_probability(1, 1, 1);
+}
+
+void foo() {
+  tempf<__builtin_expect_with_probability(1, 1, 1)>();
+  constexpr int f = constf();
+  static_assert(f == 1, "should be evaluated as 1"); // should not have error here
+}
+
 extern int global;
 
 struct S {
Index: clang/lib/StaticAnalyzer/Checkers/BuiltinFunctionChecker.cpp
===
--- clang/lib/StaticAnalyzer/Checkers/BuiltinFunctionChecker.cpp
+++ clang/lib/StaticAnalyzer/Checkers/BuiltinFunctionChecker.cpp
@@ -64,10 +64,12 @@
 
   case Builtin::BI__builtin_unpredictable:
   case Builtin::BI__builtin_expect:
+  case Builtin::BI__builtin_expect_with_probability:
   case Builtin::BI__builtin_assume_aligned:
   case Builtin::BI__builtin_addressof: {
-// For __builtin_unpredictable, __builtin_expect, and
-// __builtin_assume_aligned, just return the value of the subexpression.
+// For __builtin_unpredictable, __builtin_expect,
+// __builtin_expect_with_probability and __builtin_assume_aligned,
+// just return the value of the subexpression.
 // __builtin_addressof is going from a reference to a pointer, but those
 // are represented the same way in the analyzer.
 assert (Call.getNumArgs() > 0);
Index: clang/lib/AST/ExprConstant.cpp

[PATCH] D83360: [InstSimplify] Remove select ?, undef, X -> X and select ?, X, undef -> X

2020-07-08 Thread Eli Friedman via Phabricator via cfe-commits
efriedma added a comment.

> Should we remove the handling from llvm::ConstantFoldSelectInstruction

It seems silly to remove the handling from InstSimplify, but not constant 
folding.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83360



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


[PATCH] D80391: [Driver] Don't make -gsplit-dwarf imply -g2

2020-07-08 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added a comment.

Received Cary's response and I am authorized to share this

> In retrospect, I regret not naming the option -fsplit-dwarf, which clearly
>  would not have implied -g, and would have fit in with a few other
>  dwarf-related -f options. (I don't know whether Richard's objection to it is
>  because there is already -gsplit-dwarf, or if he would have objected to it as
>  an alternative-universe spelling.)
> 
> At the time, I thought it was fairly common for all/most -g options (except
>  -g0) to imply -g. Perhaps that wasn't true then or is no longer true now. If
>  the rest of the community is OK with changing -gsplit-dwarf to not imply -g,
>  and no one has said it would cause them any hardship, I'm OK with your
>  proposed change.

My remark here: GCC folks think introducing another -fsplit-dwarf will be more 
confusing at this point.

> I did design it so that you could get the equivalent by simply writing
>  "-gsplit-dwarf -g0" at the front of the compiler options (e.g., via an
>  environment variable), so that a subsequent -g would not only turn on debug
>  but would also enable split-dwarf. We used that fairly regularly at Google.
> 
> Regarding how the build system can discover whether or not split dwarf is in
>  effect, without parsing all the options presented to gcc, and without looking
>  for the side effects (the .dwo files), we dodged that in the Google build
>  system by having a higher-level build flag, --fission, which would tell the
>  build system to pass -gsplit-dwarf to gcc AND look for the .dwo files 
> produced
>  on the side. We simply disallowed having the user pass -gsplit-dwarf directly
>  to the compiler.
> 
> Feel free to share this.

My take of "-gsplit-dwarf implies -g" on cfe-dev is that people don't have 
strong opinions on updated semantics but they do notice that the implied -g2 is 
confusing.

@dblaikie I think we can proceed with this patch. I'll follow up on GCC side. 
Clang 11 will be consistent with GCC 11.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80391



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


[PATCH] D83294: [Fixed Point] Add codegen for fixed-point shifts.

2020-07-08 Thread Leonard Chan via Phabricator via cfe-commits
leonardchan added inline comments.



Comment at: clang/lib/CodeGen/CGExprScalar.cpp:3603-3604
   auto ResultFixedSema = Ctx.getFixedPointSemantics(ResultTy);
-  auto CommonFixedSema = LHSFixedSema.getCommonSemantics(RHSFixedSema, true);
+  auto CommonFixedSema = LHSFixedSema.getCommonSemantics(
+  IsShift ? LHSFixedSema : RHSFixedSema, true);
 

Could this instead be:

```
auto CommonFixedSema = IsShift ? LHSFixedSema : 
LHSFixedSema.getCommonSemantics(RHSFixedSema, true);
```





Comment at: clang/test/Frontend/fixed_point_compound.c:384
+  // CHECK-NEXT:[[TMP4:%.*]] = load i16, i16* @suf, align 2
+  // CHECK-NEXT:[[TMP5:%.*]] = trunc i32 [[TMP3]] to i16
+  // SIGNED-NEXT:   [[TMP6:%.*]] = call i16 @llvm.ushl.sat.i16(i16 [[TMP4]], 
i16 [[TMP5]])

This seems very unlikely, but if `i` in this case was a value at least 2^16, 
the upper half would be cut off and we'd potentially shift by an improper 
amount for some values of `i` when we should actually clamp to the max value. 
We should probably still   find the common semantics for both sides if we're 
doing a shift.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83294



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


[PATCH] D83426: Unbreak Clang standalone build.

2020-07-08 Thread Michele Scandale via Phabricator via cfe-commits
michele.scandale created this revision.
michele.scandale added a reviewer: chandlerc.
Herald added subscribers: cfe-commits, mgorny.
Herald added a project: clang.

Add missing C++ language standard setup for Clang standalone build.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D83426

Files:
  clang/CMakeLists.txt


Index: clang/CMakeLists.txt
===
--- clang/CMakeLists.txt
+++ clang/CMakeLists.txt
@@ -9,6 +9,10 @@
 if( CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR )
   project(Clang)
 
+  set(CMAKE_CXX_STANDARD 14 CACHE STRING "C++ standard to conform to")
+  set(CMAKE_CXX_STANDARD_REQUIRED YES)
+  set(CMAKE_CXX_EXTENSIONS NO)
+
   # Rely on llvm-config.
   set(CONFIG_OUTPUT)
   if(LLVM_CONFIG)


Index: clang/CMakeLists.txt
===
--- clang/CMakeLists.txt
+++ clang/CMakeLists.txt
@@ -9,6 +9,10 @@
 if( CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR )
   project(Clang)
 
+  set(CMAKE_CXX_STANDARD 14 CACHE STRING "C++ standard to conform to")
+  set(CMAKE_CXX_STANDARD_REQUIRED YES)
+  set(CMAKE_CXX_EXTENSIONS NO)
+
   # Rely on llvm-config.
   set(CONFIG_OUTPUT)
   if(LLVM_CONFIG)
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D79842: [clang][Driver] Correct tool search path priority

2020-07-08 Thread Steven Wan via Phabricator via cfe-commits
stevewan added a comment.

In D79842#2138857 , @DavidSpickett 
wrote:

> Right, I see the issue.
>
> The code that gets the default triple name 
> (https://reviews.llvm.org/D13340?id=36227#inline-108606) looks up the one you 
> have in cmake, not the actual default which you get in --version. We could 
> "fix" this by doing so when we make the tool name as well, but this breaks 
> whatever mips toolchain was using that. (their tools won't be 
> mips-unknown-elf-)
>
> So yes it looks up powerpc64le-linux-gnu but shows 
> powerpc64le-unknown-linux-gnu. Can't go back to using cmake's value because 
> on Mac OS, cmake has x86_64-darwin, clang has x86_64-darwin. Writing 
> to both is a short term option so I will try that and fold it into 
> https://reviews.llvm.org/D83055. (will add you on review once I update it)
>
> (this whole default triple lookup should probably go but I'd really like to 
> do that in its own commit)


Thanks. @DavidSpickett


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79842



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


[PATCH] D83013: [LPM] Port CGProfilePass from NPM to LPM

2020-07-08 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added a comment.

In D83013#2139882 , @zequanwu wrote:

> > The alternative of using LazyBlockFrequencyInfoPass and checking 
> > PSI->hasProfileSummary() first would also work I guess. If you think that's 
> > cleaner, maybe that's the better way to go.
>
> Since `PSI->hasProfileSummary()` is not necessary for this pass, it relies on 
> function entry count. So, I check for `F.getEntryCount()` before getting BFI.


Thanks. The last update looks good to me. I'll defer the approval to @nikic and 
folks who have expressed concerns about deleting legacy PM.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83013



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


[PATCH] D83079: [clang][aarch64] Generate preprocessor macros for -march=armv8.6a+sve.

2020-07-08 Thread Francesco Petrogalli via Phabricator via cfe-commits
fpetrogalli updated this revision to Diff 276542.
fpetrogalli marked an inline comment as done.
fpetrogalli added a comment.

@sdesmalen, I have followed your suggestion to use insert instead of push_back!

Code is much nicer now, thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83079

Files:
  clang/lib/Driver/ToolChains/Arch/AArch64.cpp
  clang/test/Preprocessor/aarch64-target-features.c


Index: clang/test/Preprocessor/aarch64-target-features.c
===
--- clang/test/Preprocessor/aarch64-target-features.c
+++ clang/test/Preprocessor/aarch64-target-features.c
@@ -112,6 +112,60 @@
 // CHECK-SVE-F64MM: __ARM_FEATURE_SVE 1
 // CHECK-SVE-F64MM: __ARM_FEATURE_SVE_MATMUL_FP64 1
 
+// RUN: %clang -target aarch64-none-linux-gnu -march=armv8.5-a+sve -x c -E -dM 
%s -o - | FileCheck --check-prefix=CHECK-SVE-8_5 %s
+// CHECK-SVE-8_5-NOT: __ARM_FEATURE_SVE_BF16 1
+// CHECK-SVE-8_5-NOT: __ARM_FEATURE_SVE_MATMUL_FP32 1
+// CHECK-SVE-8_5-NOT: __ARM_FEATURE_SVE_MATMUL_INT8 1
+// CHECK-SVE-8_5: __ARM_FEATURE_SVE 1
+
+// RUN: %clang -target aarch64-none-linux-gnu -march=armv8.6-a+sve -x c -E -dM 
%s -o - | FileCheck --check-prefix=CHECK-SVE-8_6 %s
+// CHECK-SVE-8_6: __ARM_FEATURE_SVE 1
+// CHECK-SVE-8_6: __ARM_FEATURE_SVE_BF16 1
+// CHECK-SVE-8_6: __ARM_FEATURE_SVE_MATMUL_FP32 1
+// CHECK-SVE-8_6: __ARM_FEATURE_SVE_MATMUL_INT8 1
+
+// RUN: %clang -target aarch64-none-linux-gnu -march=armv8.6-a+sve+noi8mm -x c 
-E -dM %s -o - | FileCheck --check-prefix=CHECK-SVE-8_6-NOI8MM %s
+// CHECK-SVE-8_6-NOI8MM-NOT: __ARM_FEATURE_SVE_MATMUL_INT8 1
+// CHECK-SVE-8_6-NOI8MM: __ARM_FEATURE_SVE 1
+// CHECK-SVE-8_6-NOI8MM: __ARM_FEATURE_SVE_BF16 1
+// CHECK-SVE-8_6-NOI8MM: __ARM_FEATURE_SVE_MATMUL_FP32 1
+
+// RUN: %clang -target aarch64-none-linux-gnu -march=armv8.6-a+sve+nobf16 -x c 
-E -dM %s -o - | FileCheck --check-prefix=CHECK-SVE-8_6-NOBF16 %s
+// CHECK-SVE-8_6-NOBF16-NOT: __ARM_FEATURE_SVE_BF16 1
+// CHECK-SVE-8_6-NOBF16: __ARM_FEATURE_SVE 1
+// CHECK-SVE-8_6-NOBF16: __ARM_FEATURE_SVE_MATMUL_FP32 1
+// CHECK-SVE-8_6-NOBF16: __ARM_FEATURE_SVE_MATMUL_INT8 1
+
+// RUN: %clang -target aarch64-none-linux-gnu -march=armv8.6-a+sve+nof32mm -x 
c -E -dM %s -o - | FileCheck --check-prefix=CHECK-SVE-8_6-NOF32MM %s
+// CHECK-SVE-8_6-NOF32MM-NOT: __ARM_FEATURE_SVE_MATMUL_FP32 1
+// CHECK-SVE-8_6-NOF32MM: __ARM_FEATURE_SVE 1
+// CHECK-SVE-8_6-NOF32MM: __ARM_FEATURE_SVE_BF16 1
+// CHECK-SVE-8_6-NOF32MM: __ARM_FEATURE_SVE_MATMUL_INT8 1
+
+// RUN: %clang -target aarch64-none-linux-gnu 
-march=armv8.6-a+sve+noi8mm+nobf16 -x c -E -dM %s -o - | FileCheck 
--check-prefix=CHECK-SVE-8_6-NOI8MMNOBF16 %s
+// CHECK-SVE-8_6-NOI8MMNOBF16-NOT: __ARM_FEATURE_SVE_BF16 1
+// CHECK-SVE-8_6-NOI8MMNOBF16-NOT: __ARM_FEATURE_SVE_MATMUL_INT8 1
+// CHECK-SVE-8_6-NOI8MMNOBF16: __ARM_FEATURE_SVE 1
+// CHECK-SVE-8_6-NOI8MMNOBF16: __ARM_FEATURE_SVE_MATMUL_FP32 1
+
+// RUN: %clang -target aarch64-none-linux-gnu 
-march=armv8.6-a+sve+noi8mm+nof32mm -x c -E -dM %s -o - | FileCheck 
--check-prefix=CHECK-SVE-8_6-NOI8MMNOF32MM %s
+// CHECK-SVE-8_6-NOI8MMNOF32MM-NOT: __ARM_FEATURE_SVE_MATMUL_FP32 1
+// CHECK-SVE-8_6-NOI8MMNOF32MM-NOT: __ARM_FEATURE_SVE_MATMUL_INT8 1
+// CHECK-SVE-8_6-NOI8MMNOF32MM: __ARM_FEATURE_SVE 1
+// CHECK-SVE-8_6-NOI8MMNOF32MM: __ARM_FEATURE_SVE_BF16 1
+
+// RUN: %clang -target aarch64-none-linux-gnu 
-march=armv8.6-a+sve+nobf16+nof32mm -x c -E -dM %s -o - | FileCheck 
--check-prefix=CHECK-SVE-8_6-NOBF16NOF32MM %s
+// CHECK-SVE-8_6-NOBF16NOF32MM-NOT: __ARM_FEATURE_SVE_BF16 1
+// CHECK-SVE-8_6-NOBF16NOF32MM-NOT: __ARM_FEATURE_SVE_MATMUL_FP32 1
+// CHECK-SVE-8_6-NOBF16NOF32MM: __ARM_FEATURE_SVE 1
+// CHECK-SVE-8_6-NOBF16NOF32MM: __ARM_FEATURE_SVE_MATMUL_INT8 1
+
+// RUN: %clang -target aarch64-none-linux-gnu 
-march=armv8.6-a+sve+noi8mm+nobf16+nof32mm -x c -E -dM %s -o - | FileCheck 
--check-prefix=CHECK-SVE-8_6-NOI8MMNOBF16NOF32MM %s
+// CHECK-SVE-8_6-NOI8MMNOBF16NOF32MM-NOT: __ARM_FEATURE_SVE_BF16 1
+// CHECK-SVE-8_6-NOI8MMNOBF16NOF32MM-NOT: __ARM_FEATURE_SVE_MATMUL_FP32 1
+// CHECK-SVE-8_6-NOI8MMNOBF16NOF32MM-NOT: __ARM_FEATURE_SVE_MATMUL_INT8 1
+// CHECK-SVE-8_6-NOI8MMNOBF16NOF32MM: __ARM_FEATURE_SVE 1
+
 // The following tests may need to be revised in the future since
 // SVE2 is currently still part of Future Architecture Technologies
 // (https://developer.arm.com/docs/ddi0602/latest)
Index: clang/lib/Driver/ToolChains/Arch/AArch64.cpp
===
--- clang/lib/Driver/ToolChains/Arch/AArch64.cpp
+++ clang/lib/Driver/ToolChains/Arch/AArch64.cpp
@@ -365,6 +365,12 @@
 }
   }
 
+  auto V8_6Pos = llvm::find(Features, "+v8.6a");
+  if (V8_6Pos != std::end(Features)) {
+V8_6Pos = Features.insert(std::next(V8_6Pos), "+i8mm");
+V8_6Pos = Features.insert(V8_6Pos, "+bf16");
+  }
+
  

[PATCH] D83360: [InstSimplify] Remove select ?, undef, X -> X and select ?, X, undef -> X

2020-07-08 Thread Craig Topper via Phabricator via cfe-commits
craig.topper added a comment.

In D83360#2139933 , @efriedma wrote:

> Please also add testcases with select constant expressions, to test constant 
> folding.


Should we remove the handling from llvm::ConstantFoldSelectInstruction


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83360



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


[PATCH] D82629: [libclang] Fix crash when visiting a captured VLA.

2020-07-08 Thread Jan Korous via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG6e089e98a9d5: [libclang] Fix crash when visiting a captured 
VLA (authored by ckandeler, committed by jkorous).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82629

Files:
  clang/test/Index/evaluate-cursor.cpp
  clang/tools/libclang/CIndex.cpp


Index: clang/tools/libclang/CIndex.cpp
===
--- clang/tools/libclang/CIndex.cpp
+++ clang/tools/libclang/CIndex.cpp
@@ -3272,7 +3272,7 @@
   }
   // Visit init captures
   for (auto InitExpr : E->capture_inits()) {
-if (Visit(InitExpr))
+if (InitExpr && Visit(InitExpr))
   return true;
   }
 
Index: clang/test/Index/evaluate-cursor.cpp
===
--- clang/test/Index/evaluate-cursor.cpp
+++ clang/test/Index/evaluate-cursor.cpp
@@ -29,6 +29,12 @@
 constexpr static int calc_val() { return 1 + 2; }
 const auto the_value = calc_val() + sizeof(char);
 
+void vlaTest() {
+  int msize = 4;
+  float arr[msize];
+  [] {};
+}
+
 // RUN: c-index-test -evaluate-cursor-at=%s:4:7 \
 // RUN:-evaluate-cursor-at=%s:8:7 \
 // RUN:-evaluate-cursor-at=%s:8:11 -std=c++11 %s | FileCheck %s
@@ -65,3 +71,7 @@
 // CHECK-EXPR: Value: 3
 // CHECK-EXPR: unsigned, Value: 4
 // CHECK-EXPR: unsigned, Value: 1
+
+// RUN: c-index-test -evaluate-cursor-at=%s:35:5 \
+// RUN:-std=c++11 %s | FileCheck -check-prefix=VLA %s
+// VLA: Not Evaluatable


Index: clang/tools/libclang/CIndex.cpp
===
--- clang/tools/libclang/CIndex.cpp
+++ clang/tools/libclang/CIndex.cpp
@@ -3272,7 +3272,7 @@
   }
   // Visit init captures
   for (auto InitExpr : E->capture_inits()) {
-if (Visit(InitExpr))
+if (InitExpr && Visit(InitExpr))
   return true;
   }
 
Index: clang/test/Index/evaluate-cursor.cpp
===
--- clang/test/Index/evaluate-cursor.cpp
+++ clang/test/Index/evaluate-cursor.cpp
@@ -29,6 +29,12 @@
 constexpr static int calc_val() { return 1 + 2; }
 const auto the_value = calc_val() + sizeof(char);
 
+void vlaTest() {
+  int msize = 4;
+  float arr[msize];
+  [] {};
+}
+
 // RUN: c-index-test -evaluate-cursor-at=%s:4:7 \
 // RUN:-evaluate-cursor-at=%s:8:7 \
 // RUN:-evaluate-cursor-at=%s:8:11 -std=c++11 %s | FileCheck %s
@@ -65,3 +71,7 @@
 // CHECK-EXPR: Value: 3
 // CHECK-EXPR: unsigned, Value: 4
 // CHECK-EXPR: unsigned, Value: 1
+
+// RUN: c-index-test -evaluate-cursor-at=%s:35:5 \
+// RUN:-std=c++11 %s | FileCheck -check-prefix=VLA %s
+// VLA: Not Evaluatable
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 6e089e9 - [libclang] Fix crash when visiting a captured VLA

2020-07-08 Thread Jan Korous via cfe-commits

Author: Christian Kandeler
Date: 2020-07-08T13:10:16-07:00
New Revision: 6e089e98a9d5d7d0dda259f68b8ba7f4556cc5b3

URL: 
https://github.com/llvm/llvm-project/commit/6e089e98a9d5d7d0dda259f68b8ba7f4556cc5b3
DIFF: 
https://github.com/llvm/llvm-project/commit/6e089e98a9d5d7d0dda259f68b8ba7f4556cc5b3.diff

LOG: [libclang] Fix crash when visiting a captured VLA

Array returned by LambdaExpr::capture_inits() can contain nullptrs.

Differential Revision: https://reviews.llvm.org/D82629

Added: 


Modified: 
clang/test/Index/evaluate-cursor.cpp
clang/tools/libclang/CIndex.cpp

Removed: 




diff  --git a/clang/test/Index/evaluate-cursor.cpp 
b/clang/test/Index/evaluate-cursor.cpp
index 2bb687a1eb88..901e988bc99e 100644
--- a/clang/test/Index/evaluate-cursor.cpp
+++ b/clang/test/Index/evaluate-cursor.cpp
@@ -29,6 +29,12 @@ template  class e {
 constexpr static int calc_val() { return 1 + 2; }
 const auto the_value = calc_val() + sizeof(char);
 
+void vlaTest() {
+  int msize = 4;
+  float arr[msize];
+  [] {};
+}
+
 // RUN: c-index-test -evaluate-cursor-at=%s:4:7 \
 // RUN:-evaluate-cursor-at=%s:8:7 \
 // RUN:-evaluate-cursor-at=%s:8:11 -std=c++11 %s | FileCheck %s
@@ -65,3 +71,7 @@ const auto the_value = calc_val() + sizeof(char);
 // CHECK-EXPR: Value: 3
 // CHECK-EXPR: unsigned, Value: 4
 // CHECK-EXPR: unsigned, Value: 1
+
+// RUN: c-index-test -evaluate-cursor-at=%s:35:5 \
+// RUN:-std=c++11 %s | FileCheck -check-prefix=VLA %s
+// VLA: Not Evaluatable

diff  --git a/clang/tools/libclang/CIndex.cpp b/clang/tools/libclang/CIndex.cpp
index 8d33deb468e2..93f9797a965e 100644
--- a/clang/tools/libclang/CIndex.cpp
+++ b/clang/tools/libclang/CIndex.cpp
@@ -3272,7 +3272,7 @@ bool CursorVisitor::RunVisitorWorkList(VisitorWorkList 
) {
   }
   // Visit init captures
   for (auto InitExpr : E->capture_inits()) {
-if (Visit(InitExpr))
+if (InitExpr && Visit(InitExpr))
   return true;
   }
 



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


[PATCH] D83360: [InstSimplify] Remove select ?, undef, X -> X and select ?, X, undef -> X

2020-07-08 Thread Eli Friedman via Phabricator via cfe-commits
efriedma added a comment.

Please also add testcases with select constant expressions, to test constant 
folding.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83360



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


[clang] 4544c2d - Recover more gracefully from stack exhaustion during template argument

2020-07-08 Thread Richard Smith via cfe-commits

Author: Richard Smith
Date: 2020-07-08T13:08:38-07:00
New Revision: 4544c2d95ad0217e1f28ddd84253cd09a91148c0

URL: 
https://github.com/llvm/llvm-project/commit/4544c2d95ad0217e1f28ddd84253cd09a91148c0
DIFF: 
https://github.com/llvm/llvm-project/commit/4544c2d95ad0217e1f28ddd84253cd09a91148c0.diff

LOG: Recover more gracefully from stack exhaustion during template argument
deduction.

Template argument deduction can trigger substitution, both with
explicitly-specified template arguments and with deduced template
arguments in various ways. We previously had no check for stack
exhaustion along some of those codepaths, making it fairly easy to crash
clang with a template resulting in a substitution that referred back to
that same template. We should now produce a proper diagnostic for such
cases rather than crashing.

Added: 


Modified: 
clang/lib/Sema/SemaTemplateDeduction.cpp
clang/test/SemaTemplate/stack-exhaustion.cpp

Removed: 




diff  --git a/clang/lib/Sema/SemaTemplateDeduction.cpp 
b/clang/lib/Sema/SemaTemplateDeduction.cpp
index e6569d4a784f..f3641afbbf8a 100644
--- a/clang/lib/Sema/SemaTemplateDeduction.cpp
+++ b/clang/lib/Sema/SemaTemplateDeduction.cpp
@@ -3041,8 +3041,13 @@ 
Sema::DeduceTemplateArguments(ClassTemplatePartialSpecializationDecl *Partial,
   if (Trap.hasErrorOccurred())
 return Sema::TDK_SubstitutionFailure;
 
-  return ::FinishTemplateArgumentDeduction(
-  *this, Partial, /*IsPartialOrdering=*/false, TemplateArgs, Deduced, 
Info);
+  TemplateDeductionResult Result;
+  runWithSufficientStackSpace(Info.getLocation(), [&] {
+Result = ::FinishTemplateArgumentDeduction(*this, Partial,
+   /*IsPartialOrdering=*/false,
+   TemplateArgs, Deduced, Info);
+  });
+  return Result;
 }
 
 /// Perform template argument deduction to determine whether
@@ -3082,8 +3087,13 @@ 
Sema::DeduceTemplateArguments(VarTemplatePartialSpecializationDecl *Partial,
   if (Trap.hasErrorOccurred())
 return Sema::TDK_SubstitutionFailure;
 
-  return ::FinishTemplateArgumentDeduction(
-  *this, Partial, /*IsPartialOrdering=*/false, TemplateArgs, Deduced, 
Info);
+  TemplateDeductionResult Result;
+  runWithSufficientStackSpace(Info.getLocation(), [&] {
+Result = ::FinishTemplateArgumentDeduction(*this, Partial,
+   /*IsPartialOrdering=*/false,
+   TemplateArgs, Deduced, Info);
+  });
+  return Result;
 }
 
 /// Determine whether the given type T is a simple-template-id type.
@@ -4032,13 +4042,12 @@ Sema::TemplateDeductionResult 
Sema::DeduceTemplateArguments(
   SmallVector ParamTypes;
   unsigned NumExplicitlySpecified = 0;
   if (ExplicitTemplateArgs) {
-TemplateDeductionResult Result =
-  SubstituteExplicitTemplateArguments(FunctionTemplate,
-  *ExplicitTemplateArgs,
-  Deduced,
-  ParamTypes,
-  nullptr,
-  Info);
+TemplateDeductionResult Result;
+runWithSufficientStackSpace(Info.getLocation(), [&] {
+  Result = SubstituteExplicitTemplateArguments(
+  FunctionTemplate, *ExplicitTemplateArgs, Deduced, ParamTypes, 
nullptr,
+  Info);
+});
 if (Result)
   return Result;
 
@@ -4140,12 +4149,16 @@ Sema::TemplateDeductionResult 
Sema::DeduceTemplateArguments(
   // that is needed when the accessibility of template arguments is checked.
   DeclContext *CallingCtx = CurContext;
 
-  return FinishTemplateArgumentDeduction(
-  FunctionTemplate, Deduced, NumExplicitlySpecified, Specialization, Info,
-  , PartialOverloading, [&, CallingCtx]() {
-ContextRAII SavedContext(*this, CallingCtx);
-return CheckNonDependent(ParamTypesForArgChecking);
-  });
+  TemplateDeductionResult Result;
+  runWithSufficientStackSpace(Info.getLocation(), [&] {
+Result = FinishTemplateArgumentDeduction(
+FunctionTemplate, Deduced, NumExplicitlySpecified, Specialization, 
Info,
+, PartialOverloading, [&, CallingCtx]() {
+  ContextRAII SavedContext(*this, CallingCtx);
+  return CheckNonDependent(ParamTypesForArgChecking);
+});
+  });
+  return Result;
 }
 
 QualType Sema::adjustCCAndNoReturn(QualType ArgFunctionType,
@@ -4231,11 +4244,13 @@ Sema::TemplateDeductionResult 
Sema::DeduceTemplateArguments(
   unsigned NumExplicitlySpecified = 0;
   SmallVector ParamTypes;
   if (ExplicitTemplateArgs) {
-if (TemplateDeductionResult Result
-  = SubstituteExplicitTemplateArguments(FunctionTemplate,
-*ExplicitTemplateArgs,
-Deduced, ParamTypes,

[PATCH] D79719: [AIX] Implement AIX special alignment rule about double/long double

2020-07-08 Thread Xiangling Liao via Phabricator via cfe-commits
Xiangling_L marked an inline comment as done.
Xiangling_L added inline comments.



Comment at: clang/lib/AST/RecordLayoutBuilder.cpp:1796
+  bool FoundFirstNonOverlappingEmptyFieldToHandle =
+  DefaultsToAIXPowerAlignment && FieldOffset == CharUnits::Zero() &&
+  !HandledFirstNonOverlappingEmptyField && !IsOverlappingEmptyField;

hubert.reinterpretcast wrote:
> Xiangling_L wrote:
> > hubert.reinterpretcast wrote:
> > > The condition is still more complex than I think it should be.
> > > 
> > > If we have found a "first" other-than-overlapping-empty-field, then we 
> > > should set `HandledFirstNonOverlappingEmptyField` to `true` for non-union 
> > > cases.
> > > 
> > > If `HandledFirstNonOverlappingEmptyField` being `false` is not enough for 
> > > `FieldOffset == CharUnits::Zero()` to be true, then I think the 
> > > correction would be to set `HandledFirstNonOverlappingEmptyField` in more 
> > > places.
> > > 
> > > I would like to remove the check on `FieldOffset == CharUnits::Zero()` 
> > > from here and instead have an assertion that 
> > > `!HandledFirstNonOverlappingEmptyField` implies `FieldOffset == 
> > > CharUnits::Zero()`.
> > > 
> > > Also, since we're managing `HandledFirstNonOverlappingEmptyField` in 
> > > non-AIX cases, we should remove the `DefaultsToAIXPowerAlignment` 
> > > condition for what is currently named 
> > > `FoundFirstNonOverlappingEmptyFieldToHandle` (adjusting uses of it as 
> > > necessary) and rename `FoundFirstNonOverlappingEmptyFieldToHandle` to 
> > > `FoundFirstNonOverlappingEmptyField`.
> > > Also, since we're managing HandledFirstNonOverlappingEmptyField in 
> > > non-AIX cases, we should remove the DefaultsToAIXPowerAlignment condition 
> > > for what is currently named FoundFirstNonOverlappingEmptyFieldToHandle 
> > 
> > I am not sure if we want to remove the `DefaultsToAIXPowerAlignment` 
> > condition and bother with maintaining correct status of 
> > `HandledFirstNonOverlappingEmptyField` for other targets.
> > 
> > We are actually claiming `HandledFirstNonOverlappingEmptyField` is an 
> > auxiliary flag used for AIX only in its definition comments.
> > 
> > Besides, if we do want to manage `HandledFirstNonOverlappingEmptyField` in 
> > non-AIX cases, I noticed that we have to set this flag to `true` somewhere 
> > for objective-C++ cases. 
> Okay, the other option I'm open is setting 
> `HandledFirstNonOverlappingEmptyField` to `true` up front when not dealing 
> with AIX `power` alignment.
Thanks, that works too. I will address it in the next commit.


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

https://reviews.llvm.org/D79719



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


[PATCH] D83419: [clangd] Add error() function for creating formatv-style llvm::Errors. NFC

2020-07-08 Thread Sam McCall via Phabricator via cfe-commits
sammccall updated this revision to Diff 276531.
sammccall added a comment.

Move a few comments around.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83419

Files:
  clang-tools-extra/clangd/ClangdLSPServer.cpp
  clang-tools-extra/clangd/ClangdServer.cpp
  clang-tools-extra/clangd/CodeComplete.cpp
  clang-tools-extra/clangd/DraftStore.cpp
  clang-tools-extra/clangd/JSONTransport.cpp
  clang-tools-extra/clangd/PathMapping.cpp
  clang-tools-extra/clangd/RIFF.cpp
  clang-tools-extra/clangd/TUScheduler.cpp
  clang-tools-extra/clangd/index/Serialization.cpp
  clang-tools-extra/clangd/support/Logger.cpp
  clang-tools-extra/clangd/support/Logger.h
  clang-tools-extra/clangd/unittests/CMakeLists.txt
  clang-tools-extra/clangd/unittests/LoggerTests.cpp

Index: clang-tools-extra/clangd/unittests/LoggerTests.cpp
===
--- /dev/null
+++ clang-tools-extra/clangd/unittests/LoggerTests.cpp
@@ -0,0 +1,62 @@
+//===-- LoggerTests.cpp ---===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+#include "support/Logger.h"
+#include "llvm/Support/Errc.h"
+#include "llvm/Support/Error.h"
+#include "gmock/gmock.h"
+#include "gtest/gtest.h"
+
+namespace clang {
+namespace clangd {
+namespace {
+
+TEST(ErrorTest, Overloads) {
+  EXPECT_EQ("foo", llvm::toString(error("foo")));
+  // Inconvertible to error code when none is specified.
+  // Don't actually try to convert, it'll crash.
+  handleAllErrors(error("foo"), [&](const llvm::ErrorInfoBase ) {
+EXPECT_EQ(llvm::inconvertibleErrorCode(), EI.convertToErrorCode());
+  });
+
+  EXPECT_EQ("foo 42", llvm::toString(error("foo {0}", 42)));
+  handleAllErrors(error("foo {0}", 42), [&](const llvm::ErrorInfoBase ) {
+EXPECT_EQ(llvm::inconvertibleErrorCode(), EI.convertToErrorCode());
+  });
+
+  EXPECT_EQ("foo", llvm::toString(error(llvm::errc::invalid_argument, "foo")));
+  EXPECT_EQ(llvm::errc::invalid_argument,
+llvm::errorToErrorCode(error(llvm::errc::invalid_argument, "foo")));
+
+  EXPECT_EQ("foo 42",
+llvm::toString(error(llvm::errc::invalid_argument, "foo {0}", 42)));
+  EXPECT_EQ(llvm::errc::invalid_argument,
+llvm::errorToErrorCode(
+error(llvm::errc::invalid_argument, "foo {0}", 42)));
+}
+
+TEST(ErrorTest, Lifetimes) {
+  llvm::Optional Err;
+  {
+// Check the error contains the value when error() was called.
+std::string S = "hello, world";
+Err = error("S={0}", llvm::StringRef(S));
+S = "garbage";
+  }
+  EXPECT_EQ("S=hello, world", llvm::toString(std::move(*Err)));
+}
+
+TEST(ErrorTest, ConsumeError) {
+  llvm::Error Foo = error("foo");
+  llvm::Error Bar = error("bar: {0}", std::move(Foo));
+  EXPECT_EQ("bar: foo", llvm::toString(std::move(Bar)));
+  // No assert for unchecked Foo.
+}
+
+} // namespace
+} // namespace clangd
+} // namespace clang
Index: clang-tools-extra/clangd/unittests/CMakeLists.txt
===
--- clang-tools-extra/clangd/unittests/CMakeLists.txt
+++ clang-tools-extra/clangd/unittests/CMakeLists.txt
@@ -62,6 +62,7 @@
   IndexActionTests.cpp
   IndexTests.cpp
   JSONTransportTests.cpp
+  LoggerTests.cpp
   LSPClient.cpp
   ParsedASTTests.cpp
   PathMappingTests.cpp
Index: clang-tools-extra/clangd/support/Logger.h
===
--- clang-tools-extra/clangd/support/Logger.h
+++ clang-tools-extra/clangd/support/Logger.h
@@ -45,6 +45,8 @@
 void log(Logger::Level L, const char *Fmt, Ts &&... Vals) {
   detail::log(L, llvm::formatv(Fmt, detail::wrap(std::forward(Vals))...));
 }
+
+llvm::Error error(std::error_code, std::string &&);
 } // namespace detail
 
 // Clangd logging functions write to a global logger set by LoggingSession.
@@ -67,6 +69,30 @@
 template  void vlog(const char *Fmt, Ts &&... Vals) {
   detail::log(Logger::Verbose, Fmt, std::forward(Vals)...);
 }
+// error() constructs an llvm::Error object, using formatv()-style arguments.
+// It is not automatically logged! (This function is a little out of place).
+// The error simply embeds the message string.
+template 
+llvm::Error error(std::error_code EC, const char *Fmt, Ts &&... Vals) {
+  // We must render the formatv_object eagerly, while references are valid.
+  return detail::error(
+  EC, llvm::formatv(Fmt, detail::wrap(std::forward(Vals))...).str());
+}
+// Overload with no error_code conversion, the error will be inconvertible.
+template  llvm::Error error(const char *Fmt, Ts &&... Vals) {
+  return detail::error(
+  llvm::inconvertibleErrorCode(),
+  

[PATCH] D79719: [AIX] Implement AIX special alignment rule about double/long double

2020-07-08 Thread Hubert Tong via Phabricator via cfe-commits
hubert.reinterpretcast added inline comments.



Comment at: clang/lib/AST/RecordLayoutBuilder.cpp:1796
+  bool FoundFirstNonOverlappingEmptyFieldToHandle =
+  DefaultsToAIXPowerAlignment && FieldOffset == CharUnits::Zero() &&
+  !HandledFirstNonOverlappingEmptyField && !IsOverlappingEmptyField;

Xiangling_L wrote:
> hubert.reinterpretcast wrote:
> > The condition is still more complex than I think it should be.
> > 
> > If we have found a "first" other-than-overlapping-empty-field, then we 
> > should set `HandledFirstNonOverlappingEmptyField` to `true` for non-union 
> > cases.
> > 
> > If `HandledFirstNonOverlappingEmptyField` being `false` is not enough for 
> > `FieldOffset == CharUnits::Zero()` to be true, then I think the correction 
> > would be to set `HandledFirstNonOverlappingEmptyField` in more places.
> > 
> > I would like to remove the check on `FieldOffset == CharUnits::Zero()` from 
> > here and instead have an assertion that 
> > `!HandledFirstNonOverlappingEmptyField` implies `FieldOffset == 
> > CharUnits::Zero()`.
> > 
> > Also, since we're managing `HandledFirstNonOverlappingEmptyField` in 
> > non-AIX cases, we should remove the `DefaultsToAIXPowerAlignment` condition 
> > for what is currently named `FoundFirstNonOverlappingEmptyFieldToHandle` 
> > (adjusting uses of it as necessary) and rename 
> > `FoundFirstNonOverlappingEmptyFieldToHandle` to 
> > `FoundFirstNonOverlappingEmptyField`.
> > Also, since we're managing HandledFirstNonOverlappingEmptyField in non-AIX 
> > cases, we should remove the DefaultsToAIXPowerAlignment condition for what 
> > is currently named FoundFirstNonOverlappingEmptyFieldToHandle 
> 
> I am not sure if we want to remove the `DefaultsToAIXPowerAlignment` 
> condition and bother with maintaining correct status of 
> `HandledFirstNonOverlappingEmptyField` for other targets.
> 
> We are actually claiming `HandledFirstNonOverlappingEmptyField` is an 
> auxiliary flag used for AIX only in its definition comments.
> 
> Besides, if we do want to manage `HandledFirstNonOverlappingEmptyField` in 
> non-AIX cases, I noticed that we have to set this flag to `true` somewhere 
> for objective-C++ cases. 
Okay, the other option I'm open is setting 
`HandledFirstNonOverlappingEmptyField` to `true` up front when not dealing with 
AIX `power` alignment.


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

https://reviews.llvm.org/D79719



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


[PATCH] D79719: [AIX] Implement AIX special alignment rule about double/long double

2020-07-08 Thread Xiangling Liao via Phabricator via cfe-commits
Xiangling_L updated this revision to Diff 276528.
Xiangling_L marked 2 inline comments as done.
Xiangling_L added a comment.

Fixed a -Wpacked related case and added the case to the tests;
Fixed the base class related code issue;
Addressed other comments;


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

https://reviews.llvm.org/D79719

Files:
  clang/include/clang/AST/RecordLayout.h
  clang/include/clang/Basic/TargetInfo.h
  clang/lib/AST/ASTContext.cpp
  clang/lib/AST/RecordLayout.cpp
  clang/lib/AST/RecordLayoutBuilder.cpp
  clang/lib/Basic/Targets/OSTargets.h
  clang/lib/Basic/Targets/PPC.h
  clang/test/Layout/aix-Wpacked.cpp
  clang/test/Layout/aix-double-struct-member.cpp
  clang/test/Layout/aix-no-unique-address-with-double.cpp
  clang/test/Layout/aix-pack-attr-on-base.cpp
  clang/test/Layout/aix-power-alignment-typedef.cpp
  clang/test/Layout/aix-virtual-function-and-base-with-double.cpp

Index: clang/test/Layout/aix-virtual-function-and-base-with-double.cpp
===
--- /dev/null
+++ clang/test/Layout/aix-virtual-function-and-base-with-double.cpp
@@ -0,0 +1,112 @@
+// RUN: %clang_cc1 -emit-llvm-only -triple powerpc-ibm-aix-xcoff \
+// RUN: -fdump-record-layouts -fsyntax-only %s | \
+// RUN:   FileCheck --check-prefixes=CHECK,CHECK32 %s
+
+// RUN: %clang_cc1 -emit-llvm-only -triple powerpc64-ibm-aix-xcoff \
+// RUN: -fdump-record-layouts -fsyntax-only %s | \
+// RUN:   FileCheck --check-prefixes=CHECK,CHECK64 %s
+
+namespace test1 {
+struct A {
+  double d1;
+  virtual void boo() {}
+};
+
+struct B {
+  double d2;
+  A a;
+};
+
+struct C : public A {
+  double d3;
+};
+
+int i = sizeof(B);
+int j = sizeof(C);
+
+// CHECK:  *** Dumping AST Record Layout
+// CHECK-NEXT:0 | struct test1::A
+// CHECK-NEXT:0 |   (A vtable pointer)
+// CHECK32-NEXT:  4 |   double d1
+// CHECK32-NEXT:| [sizeof=12, dsize=12, align=4, preferredalign=4,
+// CHECK32-NEXT:|  nvsize=12, nvalign=4, preferrednvalign=4]
+// CHECK64-NEXT:  8 |   double d1
+// CHECK64-NEXT:| [sizeof=16, dsize=16, align=8, preferredalign=8,
+// CHECK64-NEXT:|  nvsize=16, nvalign=8, preferrednvalign=8]
+
+// CHECK:  *** Dumping AST Record Layout
+// CHECK-NEXT:0 | struct test1::B
+// CHECK-NEXT:0 |   double d2
+// CHECK-NEXT:8 |   struct test1::A a
+// CHECK-NEXT:8 | (A vtable pointer)
+// CHECK32-NEXT: 12 | double d1
+// CHECK32-NEXT:| [sizeof=24, dsize=20, align=4, preferredalign=8,
+// CHECK32-NEXT:|  nvsize=20, nvalign=4, preferrednvalign=8]
+// CHECK64-NEXT: 16 | double d1
+// CHECK64-NEXT:| [sizeof=24, dsize=24, align=8, preferredalign=8,
+// CHECK64-NEXT:|  nvsize=24, nvalign=8, preferrednvalign=8]
+
+// CHECK:  *** Dumping AST Record Layout
+// CHECK-NEXT:0 | struct test1::C
+// CHECK-NEXT:0 |   struct test1::A (primary base)
+// CHECK-NEXT:0 | (A vtable pointer)
+// CHECK32-NEXT:  4 | double d1
+// CHECK32-NEXT: 12 |   double d3
+// CHECK32-NEXT:| [sizeof=20, dsize=20, align=4, preferredalign=4,
+// CHECK32-NEXT:|  nvsize=20, nvalign=4, preferrednvalign=4]
+// CHECK64-NEXT:  8 | double d1
+// CHECK64-NEXT: 16 |   double d3
+// CHECK64-NEXT:| [sizeof=24, dsize=24, align=8, preferredalign=8,
+// CHECK64-NEXT:|  nvsize=24, nvalign=8, preferrednvalign=8]
+
+} // namespace test1
+
+namespace test2 {
+struct A {
+  long long l1;
+};
+
+struct B : public virtual A {
+  double d2;
+};
+
+#pragma pack(2)
+struct C : public virtual A {
+  double __attribute__((aligned(4))) d3;
+};
+
+int i = sizeof(B);
+int j = sizeof(C);
+
+// CHECK:  *** Dumping AST Record Layout
+// CHECK-NEXT:0 | struct test2::A
+// CHECK-NEXT:0 |   long long l1
+// CHECK-NEXT:  | [sizeof=8, dsize=8, align=8, preferredalign=8,
+// CHECK-NEXT:  |  nvsize=8, nvalign=8, preferrednvalign=8]
+
+// CHECK:  *** Dumping AST Record Layout
+// CHECK-NEXT:0 | struct test2::B
+// CHECK-NEXT:0 |   (B vtable pointer)
+// CHECK32-NEXT:  4 |   double d2
+// CHECK64-NEXT:  8 |   double d2
+// CHECK-NEXT:   16 |   struct test2::A (virtual base)
+// CHECK-NEXT:   16 | long long l1
+// CHECK-NEXT:  | [sizeof=24, dsize=24, align=8, preferredalign=8,
+// CHECK32-NEXT:|  nvsize=12, nvalign=4, preferrednvalign=4]
+// CHECK64-NEXT:|  nvsize=16, nvalign=8, preferrednvalign=8]
+
+// CHECK:  *** Dumping AST Record Layout
+// CHECK-NEXT:0 | struct test2::C
+// CHECK-NEXT:0 |   (C vtable pointer)
+// CHECK32-NEXT:  4 |   double d3
+// CHECK32-NEXT: 12 |   struct test2::A (virtual base)
+// 

[PATCH] D81583: Update SystemZ ABI to handle C++20 [[no_unique_address]] attribute

2020-07-08 Thread Eli Friedman via Phabricator via cfe-commits
efriedma added a comment.

In D81583#2139002 , @uweigand wrote:

> In D81583#2137277 , @efriedma wrote:
>
> > I'm tempted to say this is a bugfix for the implementation of 
> > no_unique_address, and just fix it globally for all ABIs.  We're never 
> > going to get anything done here if we require a separate patch for each ABI 
> > variant clang supports.
>
>
> Well, I can certainly do that.  Would you prefer me to completely remove the 
> AllowNoUniqueAddress parameter, or keep it but default to true (so ABIs can 
> still override if necessary)?


Just drop it; I don't expect any ABI would want to override it.




Comment at: clang/lib/CodeGen/TargetInfo.cpp:7245
   // do count.  So do anonymous bitfields that aren't zero-sized.
-  if (getContext().getLangOpts().CPlusPlus &&
-  FD->isZeroLengthBitField(getContext()))
-continue;
+  if (getContext().getLangOpts().CPlusPlus) {
+if (FD->isZeroLengthBitField(getContext()))

uweigand wrote:
> efriedma wrote:
> > Only loosely relevant to this patch, but checking getLangOpts().CPlusPlus 
> > here seems weird; doesn't that break calling functions defined in C from 
> > C++ code?
> I agree that this difference between C and C++ is weird, but it does match 
> the behavior of GCC.  (Which is itself weird, but a long-standing accident 
> that we probably cannot fix without breaking existing code at this point.)
> 
> Now, you bring up an interesting point: When C++ code calls a function 
> defined in C code, the C++ part would have to refer to an `extern "C"` 
> declaration.  The correct thing to do would probably be to handle those 
> according to the C ABI rules, not the C++ rules, in this case where the two 
> differ.  But currently GCC doesn't do that either.  (But since that would be 
> broken anyway, I think we **can** fix that.)  In any case, I agree that this 
> is really a separate problem, distinct from this patch.
Okay.

Please move the check for NoUniqueAddressAttr out of the CPlusPlus check; I 
don't think it's currently possible to use from C, but better to be on the safe 
side.


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

https://reviews.llvm.org/D81583



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


[PATCH] D83419: [clangd] Add error() function for creating formatv-style llvm::Errors. NFC

2020-07-08 Thread Sam McCall via Phabricator via cfe-commits
sammccall created this revision.
sammccall added reviewers: kbobyrev, hokein.
Herald added subscribers: cfe-commits, usaxena95, kadircet, arphaman, jkorous, 
MaskRay, javed.absar, ilya-biryukov, mgorny.
Herald added a project: clang.

This is considerably terser than the makeStringError and friends, and
avoids verbosity cliffs that discourage adding log information.

It follows the syntax used in log/elog/vlog/dlog that have been successful.

The main caveats are:

- it's strictly out-of-place in logger.h, though kind of fits thematically and 
in implementation
- it claims the "error" identifier, which seems a bit too opinionated to put 
higher up in llvm

I've updated some users of StringError mostly at random - there are lots
more mechanical changes but I'd like to get this reviewed before making
them all.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D83419

Files:
  clang-tools-extra/clangd/ClangdLSPServer.cpp
  clang-tools-extra/clangd/ClangdServer.cpp
  clang-tools-extra/clangd/CodeComplete.cpp
  clang-tools-extra/clangd/DraftStore.cpp
  clang-tools-extra/clangd/JSONTransport.cpp
  clang-tools-extra/clangd/PathMapping.cpp
  clang-tools-extra/clangd/RIFF.cpp
  clang-tools-extra/clangd/TUScheduler.cpp
  clang-tools-extra/clangd/index/Serialization.cpp
  clang-tools-extra/clangd/support/Logger.cpp
  clang-tools-extra/clangd/support/Logger.h
  clang-tools-extra/clangd/unittests/CMakeLists.txt
  clang-tools-extra/clangd/unittests/LoggerTests.cpp

Index: clang-tools-extra/clangd/unittests/LoggerTests.cpp
===
--- /dev/null
+++ clang-tools-extra/clangd/unittests/LoggerTests.cpp
@@ -0,0 +1,62 @@
+//===-- LoggerTests.cpp ---===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+#include "support/Logger.h"
+#include "llvm/Support/Error.h"
+#include "llvm/Support/Errc.h"
+#include "gmock/gmock.h"
+#include "gtest/gtest.h"
+
+namespace clang {
+namespace clangd {
+namespace {
+
+TEST(ErrorTest, Overloads) {
+  EXPECT_EQ("foo", llvm::toString(error("foo")));
+  // Inconvertible to error code when none is specified.
+  // Don't actually try to convert, it'll crash.
+  handleAllErrors(error("foo"), [&](const llvm::ErrorInfoBase ) {
+EXPECT_EQ(llvm::inconvertibleErrorCode(), EI.convertToErrorCode());
+  });
+
+  EXPECT_EQ("foo 42", llvm::toString(error("foo {0}", 42)));
+  handleAllErrors(error("foo {0}", 42), [&](const llvm::ErrorInfoBase ) {
+EXPECT_EQ(llvm::inconvertibleErrorCode(), EI.convertToErrorCode());
+  });
+
+  EXPECT_EQ("foo", llvm::toString(error(llvm::errc::invalid_argument, "foo")));
+  EXPECT_EQ(llvm::errc::invalid_argument,
+llvm::errorToErrorCode(error(llvm::errc::invalid_argument, "foo")));
+
+  EXPECT_EQ("foo 42",
+llvm::toString(error(llvm::errc::invalid_argument, "foo {0}", 42)));
+  EXPECT_EQ(llvm::errc::invalid_argument,
+llvm::errorToErrorCode(
+error(llvm::errc::invalid_argument, "foo {0}", 42)));
+}
+
+TEST(ErrorTest, Lifetimes) {
+  llvm::Optional Err;
+  {
+// Check the error contains the value when error() was called.
+std::string S = "hello, world";
+Err = error("S={0}", llvm::StringRef(S));
+S = "garbage";
+  }
+  EXPECT_EQ("S=hello, world", llvm::toString(std::move(*Err)));
+}
+
+TEST(ErrorTest, ConsumeError) {
+  llvm::Error Foo = error("foo");
+  llvm::Error Bar = error("bar: {0}", std::move(Foo));
+  EXPECT_EQ("bar: foo", llvm::toString(std::move(Bar)));
+  // No assert for unchecked Foo.
+}
+
+} // namespace
+} // namespace clangd
+} // namespace clang
Index: clang-tools-extra/clangd/unittests/CMakeLists.txt
===
--- clang-tools-extra/clangd/unittests/CMakeLists.txt
+++ clang-tools-extra/clangd/unittests/CMakeLists.txt
@@ -62,6 +62,7 @@
   IndexActionTests.cpp
   IndexTests.cpp
   JSONTransportTests.cpp
+  LoggerTests.cpp
   LSPClient.cpp
   ParsedASTTests.cpp
   PathMappingTests.cpp
Index: clang-tools-extra/clangd/support/Logger.h
===
--- clang-tools-extra/clangd/support/Logger.h
+++ clang-tools-extra/clangd/support/Logger.h
@@ -45,6 +45,8 @@
 void log(Logger::Level L, const char *Fmt, Ts &&... Vals) {
   detail::log(L, llvm::formatv(Fmt, detail::wrap(std::forward(Vals))...));
 }
+
+llvm::Error error(std::error_code, std::string &&);
 } // namespace detail
 
 // Clangd logging functions write to a global logger set by LoggingSession.
@@ -67,6 +69,27 @@
 template  void vlog(const char *Fmt, Ts &&... Vals) {
   detail::log(Logger::Verbose, Fmt, std::forward(Vals)...);
 }
+// error() constructs an llvm::Error 

[PATCH] D83360: [InstSimplify] Remove select ?, undef, X -> X and select ?, X, undef -> X

2020-07-08 Thread Craig Topper via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG9b1e95329af7: [InstSimplify] Remove select ?, undef, X - 
X and select ?, X, undef - X… (authored by craig.topper).
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83360

Files:
  clang/test/CodeGen/arm-mve-intrinsics/dup.c
  llvm/lib/Analysis/InstructionSimplify.cpp
  llvm/test/Transforms/InstCombine/select.ll
  llvm/test/Transforms/InstSimplify/select.ll

Index: llvm/test/Transforms/InstSimplify/select.ll
===
--- llvm/test/Transforms/InstSimplify/select.ll
+++ llvm/test/Transforms/InstSimplify/select.ll
@@ -750,3 +750,43 @@
   %c3 = select i1 %c1, i1 %c2, i1 false
   ret i1 %c3
 }
+
+; Negative tests to ensure we don't remove selects with undef true/false values.
+; See https://bugs.llvm.org/show_bug.cgi?id=31633
+; https://lists.llvm.org/pipermail/llvm-dev/2016-October/106182.html
+; https://reviews.llvm.org/D83360
+define i32 @false_undef(i1 %cond, i32 %x) {
+; CHECK-LABEL: @false_undef(
+; CHECK-NEXT:[[S:%.*]] = select i1 [[COND:%.*]], i32 [[X:%.*]], i32 undef
+; CHECK-NEXT:ret i32 [[S]]
+;
+  %s = select i1 %cond, i32 %x, i32 undef
+  ret i32 %s
+}
+
+define i32 @true_undef(i1 %cond, i32 %x) {
+; CHECK-LABEL: @true_undef(
+; CHECK-NEXT:[[S:%.*]] = select i1 [[COND:%.*]], i32 undef, i32 [[X:%.*]]
+; CHECK-NEXT:ret i32 [[S]]
+;
+  %s = select i1 %cond, i32 undef, i32 %x
+  ret i32 %s
+}
+
+define <2 x i32> @false_undef_vec(i1 %cond, <2 x i32> %x) {
+; CHECK-LABEL: @false_undef_vec(
+; CHECK-NEXT:[[S:%.*]] = select i1 [[COND:%.*]], <2 x i32> [[X:%.*]], <2 x i32> undef
+; CHECK-NEXT:ret <2 x i32> [[S]]
+;
+  %s = select i1 %cond, <2 x i32> %x, <2 x i32> undef
+  ret <2 x i32> %s
+}
+
+define <2 x i32> @true_undef_vec(i1 %cond, <2 x i32> %x) {
+; CHECK-LABEL: @true_undef_vec(
+; CHECK-NEXT:[[S:%.*]] = select i1 [[COND:%.*]], <2 x i32> undef, <2 x i32> [[X:%.*]]
+; CHECK-NEXT:ret <2 x i32> [[S]]
+;
+  %s = select i1 %cond, <2 x i32> undef, <2 x i32> %x
+  ret <2 x i32> %s
+}
Index: llvm/test/Transforms/InstCombine/select.ll
===
--- llvm/test/Transforms/InstCombine/select.ll
+++ llvm/test/Transforms/InstCombine/select.ll
@@ -2273,3 +2273,43 @@
   %sel = select i1 %cond, i32 %phi, i32 %A
   ret i32 %sel
 }
+
+; Negative tests to ensure we don't remove selects with undef true/false values.
+; See https://bugs.llvm.org/show_bug.cgi?id=31633
+; https://lists.llvm.org/pipermail/llvm-dev/2016-October/106182.html
+; https://reviews.llvm.org/D83360
+define i32 @false_undef(i1 %cond, i32 %x) {
+; CHECK-LABEL: @false_undef(
+; CHECK-NEXT:[[S:%.*]] = select i1 [[COND:%.*]], i32 [[X:%.*]], i32 undef
+; CHECK-NEXT:ret i32 [[S]]
+;
+  %s = select i1 %cond, i32 %x, i32 undef
+  ret i32 %s
+}
+
+define i32 @true_undef(i1 %cond, i32 %x) {
+; CHECK-LABEL: @true_undef(
+; CHECK-NEXT:[[S:%.*]] = select i1 [[COND:%.*]], i32 undef, i32 [[X:%.*]]
+; CHECK-NEXT:ret i32 [[S]]
+;
+  %s = select i1 %cond, i32 undef, i32 %x
+  ret i32 %s
+}
+
+define <2 x i32> @false_undef_vec(i1 %cond, <2 x i32> %x) {
+; CHECK-LABEL: @false_undef_vec(
+; CHECK-NEXT:[[S:%.*]] = select i1 [[COND:%.*]], <2 x i32> [[X:%.*]], <2 x i32> undef
+; CHECK-NEXT:ret <2 x i32> [[S]]
+;
+  %s = select i1 %cond, <2 x i32> %x, <2 x i32> undef
+  ret <2 x i32> %s
+}
+
+define <2 x i32> @true_undef_vec(i1 %cond, <2 x i32> %x) {
+; CHECK-LABEL: @true_undef_vec(
+; CHECK-NEXT:[[S:%.*]] = select i1 [[COND:%.*]], <2 x i32> undef, <2 x i32> [[X:%.*]]
+; CHECK-NEXT:ret <2 x i32> [[S]]
+;
+  %s = select i1 %cond, <2 x i32> undef, <2 x i32> %x
+  ret <2 x i32> %s
+}
Index: llvm/lib/Analysis/InstructionSimplify.cpp
===
--- llvm/lib/Analysis/InstructionSimplify.cpp
+++ llvm/lib/Analysis/InstructionSimplify.cpp
@@ -4118,11 +4118,6 @@
   if (TrueVal == FalseVal)
 return TrueVal;
 
-  if (isa(TrueVal))   // select ?, undef, X -> X
-return FalseVal;
-  if (isa(FalseVal))   // select ?, X, undef -> X
-return TrueVal;
-
   // Deal with partial undef vector constants: select ?, VecC, VecC' --> VecC''
   Constant *TrueC, *FalseC;
   if (TrueVal->getType()->isVectorTy() && match(TrueVal, m_Constant(TrueC)) &&
Index: clang/test/CodeGen/arm-mve-intrinsics/dup.c
===
--- clang/test/CodeGen/arm-mve-intrinsics/dup.c
+++ clang/test/CodeGen/arm-mve-intrinsics/dup.c
@@ -242,7 +242,8 @@
 // CHECK-NEXT:[[TMP1:%.*]] = call <8 x i1> @llvm.arm.mve.pred.i2v.v8i1(i32 [[TMP0]])
 // CHECK-NEXT:[[DOTSPLATINSERT:%.*]] = insertelement <8 x half> undef, half [[A:%.*]], i32 0
 // CHECK-NEXT:[[DOTSPLAT:%.*]] = shufflevector <8 x 

[clang] 9b1e953 - [InstSimplify] Remove select ?, undef, X -> X and select ?, X, undef -> X transforms

2020-07-08 Thread Craig Topper via cfe-commits

Author: Craig Topper
Date: 2020-07-08T12:53:05-07:00
New Revision: 9b1e95329af7bb005275f18225b2c130ec3ea98d

URL: 
https://github.com/llvm/llvm-project/commit/9b1e95329af7bb005275f18225b2c130ec3ea98d
DIFF: 
https://github.com/llvm/llvm-project/commit/9b1e95329af7bb005275f18225b2c130ec3ea98d.diff

LOG: [InstSimplify] Remove select ?, undef, X -> X and select ?, X, undef -> X 
transforms

As noted here 
https://lists.llvm.org/pipermail/llvm-dev/2016-October/106182.html and by 
alive2, this transform isn't valid. If X is poison this potentially propagates 
poison when it shouldn't.

This same transform still exists in DAGCombiner.

Differential Revision: https://reviews.llvm.org/D83360

Added: 


Modified: 
clang/test/CodeGen/arm-mve-intrinsics/dup.c
llvm/lib/Analysis/InstructionSimplify.cpp
llvm/test/Transforms/InstCombine/select.ll
llvm/test/Transforms/InstSimplify/select.ll

Removed: 




diff  --git a/clang/test/CodeGen/arm-mve-intrinsics/dup.c 
b/clang/test/CodeGen/arm-mve-intrinsics/dup.c
index 283c08257005..b443917cb258 100644
--- a/clang/test/CodeGen/arm-mve-intrinsics/dup.c
+++ b/clang/test/CodeGen/arm-mve-intrinsics/dup.c
@@ -242,7 +242,8 @@ uint32x4_t test_vdupq_m_n_u32(uint32x4_t inactive, uint32_t 
a, mve_pred16_t p)
 // CHECK-NEXT:[[TMP1:%.*]] = call <8 x i1> @llvm.arm.mve.pred.i2v.v8i1(i32 
[[TMP0]])
 // CHECK-NEXT:[[DOTSPLATINSERT:%.*]] = insertelement <8 x half> undef, 
half [[A:%.*]], i32 0
 // CHECK-NEXT:[[DOTSPLAT:%.*]] = shufflevector <8 x half> 
[[DOTSPLATINSERT]], <8 x half> undef, <8 x i32> zeroinitializer
-// CHECK-NEXT:ret <8 x half> [[DOTSPLAT]]
+// CHECK-NEXT:[[TMP2:%.*]] = select <8 x i1> [[TMP1]], <8 x half> 
[[DOTSPLAT]], <8 x half> undef
+// CHECK-NEXT:ret <8 x half> [[TMP2]]
 //
 float16x8_t test_vdupq_x_n_f16(float16_t a, mve_pred16_t p)
 {
@@ -255,7 +256,8 @@ float16x8_t test_vdupq_x_n_f16(float16_t a, mve_pred16_t p)
 // CHECK-NEXT:[[TMP1:%.*]] = call <4 x i1> @llvm.arm.mve.pred.i2v.v4i1(i32 
[[TMP0]])
 // CHECK-NEXT:[[DOTSPLATINSERT:%.*]] = insertelement <4 x float> undef, 
float [[A:%.*]], i32 0
 // CHECK-NEXT:[[DOTSPLAT:%.*]] = shufflevector <4 x float> 
[[DOTSPLATINSERT]], <4 x float> undef, <4 x i32> zeroinitializer
-// CHECK-NEXT:ret <4 x float> [[DOTSPLAT]]
+// CHECK-NEXT:[[TMP2:%.*]] = select <4 x i1> [[TMP1]], <4 x float> 
[[DOTSPLAT]], <4 x float> undef
+// CHECK-NEXT:ret <4 x float> [[TMP2]]
 //
 float32x4_t test_vdupq_x_n_f32(float32_t a, mve_pred16_t p)
 {
@@ -268,7 +270,8 @@ float32x4_t test_vdupq_x_n_f32(float32_t a, mve_pred16_t p)
 // CHECK-NEXT:[[TMP1:%.*]] = call <16 x i1> 
@llvm.arm.mve.pred.i2v.v16i1(i32 [[TMP0]])
 // CHECK-NEXT:[[DOTSPLATINSERT:%.*]] = insertelement <16 x i8> undef, i8 
[[A:%.*]], i32 0
 // CHECK-NEXT:[[DOTSPLAT:%.*]] = shufflevector <16 x i8> 
[[DOTSPLATINSERT]], <16 x i8> undef, <16 x i32> zeroinitializer
-// CHECK-NEXT:ret <16 x i8> [[DOTSPLAT]]
+// CHECK-NEXT:[[TMP2:%.*]] = select <16 x i1> [[TMP1]], <16 x i8> 
[[DOTSPLAT]], <16 x i8> undef
+// CHECK-NEXT:ret <16 x i8> [[TMP2]]
 //
 int8x16_t test_vdupq_x_n_s8(int8_t a, mve_pred16_t p)
 {
@@ -281,7 +284,8 @@ int8x16_t test_vdupq_x_n_s8(int8_t a, mve_pred16_t p)
 // CHECK-NEXT:[[TMP1:%.*]] = call <8 x i1> @llvm.arm.mve.pred.i2v.v8i1(i32 
[[TMP0]])
 // CHECK-NEXT:[[DOTSPLATINSERT:%.*]] = insertelement <8 x i16> undef, i16 
[[A:%.*]], i32 0
 // CHECK-NEXT:[[DOTSPLAT:%.*]] = shufflevector <8 x i16> 
[[DOTSPLATINSERT]], <8 x i16> undef, <8 x i32> zeroinitializer
-// CHECK-NEXT:ret <8 x i16> [[DOTSPLAT]]
+// CHECK-NEXT:[[TMP2:%.*]] = select <8 x i1> [[TMP1]], <8 x i16> 
[[DOTSPLAT]], <8 x i16> undef
+// CHECK-NEXT:ret <8 x i16> [[TMP2]]
 //
 int16x8_t test_vdupq_x_n_s16(int16_t a, mve_pred16_t p)
 {
@@ -294,7 +298,8 @@ int16x8_t test_vdupq_x_n_s16(int16_t a, mve_pred16_t p)
 // CHECK-NEXT:[[TMP1:%.*]] = call <4 x i1> @llvm.arm.mve.pred.i2v.v4i1(i32 
[[TMP0]])
 // CHECK-NEXT:[[DOTSPLATINSERT:%.*]] = insertelement <4 x i32> undef, i32 
[[A:%.*]], i32 0
 // CHECK-NEXT:[[DOTSPLAT:%.*]] = shufflevector <4 x i32> 
[[DOTSPLATINSERT]], <4 x i32> undef, <4 x i32> zeroinitializer
-// CHECK-NEXT:ret <4 x i32> [[DOTSPLAT]]
+// CHECK-NEXT:[[TMP2:%.*]] = select <4 x i1> [[TMP1]], <4 x i32> 
[[DOTSPLAT]], <4 x i32> undef
+// CHECK-NEXT:ret <4 x i32> [[TMP2]]
 //
 int32x4_t test_vdupq_x_n_s32(int32_t a, mve_pred16_t p)
 {
@@ -307,7 +312,8 @@ int32x4_t test_vdupq_x_n_s32(int32_t a, mve_pred16_t p)
 // CHECK-NEXT:[[TMP1:%.*]] = call <16 x i1> 
@llvm.arm.mve.pred.i2v.v16i1(i32 [[TMP0]])
 // CHECK-NEXT:[[DOTSPLATINSERT:%.*]] = insertelement <16 x i8> undef, i8 
[[A:%.*]], i32 0
 // CHECK-NEXT:[[DOTSPLAT:%.*]] = shufflevector <16 x i8> 
[[DOTSPLATINSERT]], <16 x i8> undef, <16 x i32> zeroinitializer
-// CHECK-NEXT:ret <16 x i8> [[DOTSPLAT]]
+// CHECK-NEXT:

[PATCH] D83402: ParsedAttrInfo: Change spelling to use StringRef instead of const char*

2020-07-08 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

I think the change is safe to make, but I'm slightly uncomfortable with it 
because storing a `StringRef` is a somewhat questionable practice given that 
it's non-owning and it has converting constructors from dangerous types like 
`std::string`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83402



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


[PATCH] D82609: [PowerPC][Power10] Implement Vector Multiply High/Divide Extended Builtins in LLVM/Clang

2020-07-08 Thread Amy Kwan via Phabricator via cfe-commits
amyk marked 2 inline comments as done.
amyk added inline comments.



Comment at: clang/test/CodeGen/builtins-ppc-p10vector.c:79
+vector signed int test_vec_dive_si(void) {
+  // CHECK: @llvm.ppc.altivec.vdivesw(<4 x i32>
+  // CHECK-NEXT: ret <4 x i32>

lei wrote:
> why does the ck stops matching at the first param?  Shouldn't we check the 
> remaining param type and number of param are correct as well?
Yes, thanks for pointing that out. Will be fixing the CHECKs.



Comment at: llvm/lib/Target/PowerPC/PPCInstrPrefix.td:854
+ [(set v4i32:$vD,
+ (int_ppc_altivec_vdivesw v4i32:$vA, v4i32:$vB))]>;
   def VDIVEUW : VXForm_1<651, (outs vrrc:$vD), (ins vrrc:$vA, vrrc:$vB),

lei wrote:
> nit: indent to match up with `v4i32` on the previous line.
I will update with the proper indentation. 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82609



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


[PATCH] D83013: [LPM] Port CGProfilePass from NPM to LPM

2020-07-08 Thread Zequan Wu via Phabricator via cfe-commits
zequanwu marked an inline comment as done.
zequanwu added a comment.

> The alternative of using LazyBlockFrequencyInfoPass and checking 
> PSI->hasProfileSummary() first would also work I guess. If you think that's 
> cleaner, maybe that's the better way to go.

Since `PSI->hasProfileSummary()` is not necessary for this pass, it relies on 
function entry count. So, I check for `F.getEntryCount()` before getting BFI.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83013



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


[PATCH] D83013: [LPM] Port CGProfilePass from NPM to LPM

2020-07-08 Thread Zequan Wu via Phabricator via cfe-commits
zequanwu updated this revision to Diff 276526.
zequanwu added a comment.

- Remove "enable-call-graph-profile" option and enable CGProfilePass by 
default, unless `-no-integrated-as` is given in clang.
- Use `LazyBlockFrequencyInfoPass` instead of `BlockFrequencyInfoWrapperPass` 
and check `F.getEntryCount` before get `BFI` to reduce cost.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83013

Files:
  clang/include/clang/Basic/CodeGenOptions.def
  clang/lib/CodeGen/BackendUtil.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  llvm/include/llvm/InitializePasses.h
  llvm/include/llvm/Transforms/IPO.h
  llvm/include/llvm/Transforms/IPO/PassManagerBuilder.h
  llvm/include/llvm/Transforms/Instrumentation/CGProfile.h
  llvm/lib/Passes/PassBuilder.cpp
  llvm/lib/Transforms/IPO/PassManagerBuilder.cpp
  llvm/lib/Transforms/Instrumentation/CGProfile.cpp
  llvm/lib/Transforms/Instrumentation/Instrumentation.cpp
  llvm/test/CodeGen/AMDGPU/opt-pipeline.ll
  llvm/test/Instrumentation/cgprofile.ll
  llvm/test/Other/new-pm-cgprofile.ll
  llvm/test/Other/opt-O2-pipeline.ll
  llvm/test/Other/opt-O3-pipeline.ll
  llvm/test/Other/opt-Os-pipeline.ll

Index: llvm/test/Other/opt-Os-pipeline.ll
===
--- llvm/test/Other/opt-Os-pipeline.ll
+++ llvm/test/Other/opt-Os-pipeline.ll
@@ -266,6 +266,12 @@
 ; CHECK-NEXT: Strip Unused Function Prototypes
 ; CHECK-NEXT: Dead Global Elimination
 ; CHECK-NEXT: Merge Duplicate Global Constants
+; CHECK-NEXT: Call Graph Profile
+; CHECK-NEXT:   FunctionPass Manager
+; CHECK-NEXT: Dominator Tree Construction
+; CHECK-NEXT: Natural Loop Information
+; CHECK-NEXT: Lazy Branch Probability Analysis
+; CHECK-NEXT: Lazy Block Frequency Analysis
 ; CHECK-NEXT: FunctionPass Manager
 ; CHECK-NEXT:   Dominator Tree Construction
 ; CHECK-NEXT:   Natural Loop Information
Index: llvm/test/Other/opt-O3-pipeline.ll
===
--- llvm/test/Other/opt-O3-pipeline.ll
+++ llvm/test/Other/opt-O3-pipeline.ll
@@ -285,6 +285,12 @@
 ; CHECK-NEXT: Strip Unused Function Prototypes
 ; CHECK-NEXT: Dead Global Elimination
 ; CHECK-NEXT: Merge Duplicate Global Constants
+; CHECK-NEXT: Call Graph Profile
+; CHECK-NEXT:   FunctionPass Manager
+; CHECK-NEXT: Dominator Tree Construction
+; CHECK-NEXT: Natural Loop Information
+; CHECK-NEXT: Lazy Branch Probability Analysis
+; CHECK-NEXT: Lazy Block Frequency Analysis
 ; CHECK-NEXT: FunctionPass Manager
 ; CHECK-NEXT:   Dominator Tree Construction
 ; CHECK-NEXT:   Natural Loop Information
Index: llvm/test/Other/opt-O2-pipeline.ll
===
--- llvm/test/Other/opt-O2-pipeline.ll
+++ llvm/test/Other/opt-O2-pipeline.ll
@@ -280,6 +280,12 @@
 ; CHECK-NEXT: Strip Unused Function Prototypes
 ; CHECK-NEXT: Dead Global Elimination
 ; CHECK-NEXT: Merge Duplicate Global Constants
+; CHECK-NEXT: Call Graph Profile
+; CHECK-NEXT:   FunctionPass Manager
+; CHECK-NEXT: Dominator Tree Construction
+; CHECK-NEXT: Natural Loop Information
+; CHECK-NEXT: Lazy Branch Probability Analysis
+; CHECK-NEXT: Lazy Block Frequency Analysis
 ; CHECK-NEXT: FunctionPass Manager
 ; CHECK-NEXT:   Dominator Tree Construction
 ; CHECK-NEXT:   Natural Loop Information
Index: llvm/test/Other/new-pm-cgprofile.ll
===
--- llvm/test/Other/new-pm-cgprofile.ll
+++ /dev/null
@@ -1,11 +0,0 @@
-; RUN: opt -debug-pass-manager -passes='default' %s 2>&1 |FileCheck %s --check-prefixes=DEFAULT
-; RUN: opt -debug-pass-manager -passes='default' -enable-npm-call-graph-profile=0 %s 2>&1 |FileCheck %s --check-prefixes=OFF
-; RUN: opt -debug-pass-manager -passes='default' -enable-npm-call-graph-profile=1 %s 2>&1 |FileCheck %s --check-prefixes=ON
-;
-; DEFAULT: Running pass: CGProfilePass
-; OFF-NOT: Running pass: CGProfilePass
-; ON: Running pass: CGProfilePass
-
-define void @foo() {
-  ret void
-}
Index: llvm/test/Instrumentation/cgprofile.ll
===
--- llvm/test/Instrumentation/cgprofile.ll
+++ llvm/test/Instrumentation/cgprofile.ll
@@ -1,4 +1,5 @@
 ; RUN: opt < %s -passes cg-profile -S | FileCheck %s
+; RUN: opt < %s -cg-profile -S | FileCheck %s
 
 declare void @b()
 
Index: llvm/test/CodeGen/AMDGPU/opt-pipeline.ll
===
--- llvm/test/CodeGen/AMDGPU/opt-pipeline.ll
+++ llvm/test/CodeGen/AMDGPU/opt-pipeline.ll
@@ -276,6 +276,13 @@
 ; GCN-O1-NEXT:   Warn about non-applied transformations
 ; GCN-O1-NEXT:   Alignment from assumptions
 ; GCN-O1-NEXT: Strip Unused Function Prototypes
+; 

[PATCH] D82476: [Clang][Driver] Recognize the AIX OBJECT_MODE environment setting

2020-07-08 Thread Jason Liu via Phabricator via cfe-commits
jasonliu accepted this revision.
jasonliu added a comment.
This revision is now accepted and ready to land.

LGTM.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82476



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


[PATCH] D76389: [NewPM] Run the Speculative Execution Pass only if the target has divergent branches

2020-07-08 Thread Leonard Chan via Phabricator via cfe-commits
leonardchan abandoned this revision.
leonardchan added a comment.

In D76389#2120868 , @arsenm wrote:

> This seems like it covers a different case than D82735 
> ?


I haven't rebased in a while, but D82735  
covers this. Abandoning since this is addressed in that patch.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D76389



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


[PATCH] D81583: Update SystemZ ABI to handle C++20 [[no_unique_address]] attribute

2020-07-08 Thread John McCall via Phabricator via cfe-commits
rjmccall added a comment.

I agree with Eli that this should be considered a bugfix in the implementation 
of a recent language change and should just be rolled out consistently for all 
targets.

If this were a five-year-old feature, the ABI considerations would be 
different, but it's not.


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

https://reviews.llvm.org/D81583



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


[PATCH] D82609: [PowerPC][Power10] Implement Vector Multiply High/Divide Extended Builtins in LLVM/Clang

2020-07-08 Thread Lei Huang via Phabricator via cfe-commits
lei added inline comments.



Comment at: clang/test/CodeGen/builtins-ppc-p10vector.c:79
+vector signed int test_vec_dive_si(void) {
+  // CHECK: @llvm.ppc.altivec.vdivesw(<4 x i32>
+  // CHECK-NEXT: ret <4 x i32>

why does the ck stops matching at the first param?  Shouldn't we check the 
remaining param type and number of param are correct as well?



Comment at: llvm/lib/Target/PowerPC/PPCInstrPrefix.td:854
+ [(set v4i32:$vD,
+ (int_ppc_altivec_vdivesw v4i32:$vA, v4i32:$vB))]>;
   def VDIVEUW : VXForm_1<651, (outs vrrc:$vD), (ins vrrc:$vA, vrrc:$vB),

nit: indent to match up with `v4i32` on the previous line.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82609



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


[PATCH] D83362: Fix warning caused by __builtin_expect_with_probability was not handled in places such as constant folding

2020-07-08 Thread Erich Keane via Phabricator via cfe-commits
erichkeane added inline comments.



Comment at: clang/test/Sema/builtin-expect-with-probability.cpp:17
+constexpr int constf() {
+  return __builtin_expect_with_probability(1, 1, 1); // should not have error 
here
+}

I mean something more like:

template
void foo() { static_assert(!b,""); } // expected-error {{}}

void bar() {
  foo<__builtin_expect_with_probability(1,1,1)>();
}


This example doesn't require that constf is executed at compile time.  You'd 
need to either send the result of constf to a template, or assign it to a 
constexpr variable in order to make it work.

So something like:

void foo() {
   constexpr int f = constf();
   static_assert(f == 1, "");
}



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

https://reviews.llvm.org/D83362



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


[PATCH] D79719: [AIX] Implement AIX special alignment rule about double/long double

2020-07-08 Thread Xiangling Liao via Phabricator via cfe-commits
Xiangling_L marked 9 inline comments as done.
Xiangling_L added inline comments.



Comment at: clang/lib/AST/RecordLayoutBuilder.cpp:1796
+  bool FoundFirstNonOverlappingEmptyFieldToHandle =
+  DefaultsToAIXPowerAlignment && FieldOffset == CharUnits::Zero() &&
+  !HandledFirstNonOverlappingEmptyField && !IsOverlappingEmptyField;

hubert.reinterpretcast wrote:
> The condition is still more complex than I think it should be.
> 
> If we have found a "first" other-than-overlapping-empty-field, then we should 
> set `HandledFirstNonOverlappingEmptyField` to `true` for non-union cases.
> 
> If `HandledFirstNonOverlappingEmptyField` being `false` is not enough for 
> `FieldOffset == CharUnits::Zero()` to be true, then I think the correction 
> would be to set `HandledFirstNonOverlappingEmptyField` in more places.
> 
> I would like to remove the check on `FieldOffset == CharUnits::Zero()` from 
> here and instead have an assertion that 
> `!HandledFirstNonOverlappingEmptyField` implies `FieldOffset == 
> CharUnits::Zero()`.
> 
> Also, since we're managing `HandledFirstNonOverlappingEmptyField` in non-AIX 
> cases, we should remove the `DefaultsToAIXPowerAlignment` condition for what 
> is currently named `FoundFirstNonOverlappingEmptyFieldToHandle` (adjusting 
> uses of it as necessary) and rename 
> `FoundFirstNonOverlappingEmptyFieldToHandle` to 
> `FoundFirstNonOverlappingEmptyField`.
> Also, since we're managing HandledFirstNonOverlappingEmptyField in non-AIX 
> cases, we should remove the DefaultsToAIXPowerAlignment condition for what is 
> currently named FoundFirstNonOverlappingEmptyFieldToHandle 

I am not sure if we want to remove the `DefaultsToAIXPowerAlignment` condition 
and bother with maintaining correct status of 
`HandledFirstNonOverlappingEmptyField` for other targets.

We are actually claiming `HandledFirstNonOverlappingEmptyField` is an auxiliary 
flag used for AIX only in its definition comments.

Besides, if we do want to manage `HandledFirstNonOverlappingEmptyField` in 
non-AIX cases, I noticed that we have to set this flag to `true` somewhere for 
objective-C++ cases. 



Comment at: clang/lib/AST/RecordLayoutBuilder.cpp:1834
+TypeInfo TI = Context.getTypeInfo(D->getType());
+FieldAlign = Context.toCharUnitsFromBits(TI.Align);
+AlignIsRequired = TI.AlignIsRequired;

hubert.reinterpretcast wrote:
> I guess this works (we have a test for it), but the previous code made a 
> point to use the element type and not the array type (and the comment above 
> says we can't directly query `getTypeInfo` with the array type). 
> @Xiangling_L, can you confirm if the comment is out-of-date and update it?
I am sure `getTypeInfo` can recognize the element type for `IncompleteArray`. I 
will update the comments.


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

https://reviews.llvm.org/D79719



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


[PATCH] D83362: Fix warning caused by __builtin_expect_with_probability was not handled in places such as constant folding

2020-07-08 Thread Zhi Zhuang via Phabricator via cfe-commits
LukeZhuang marked an inline comment as done.
LukeZhuang added a comment.

@erichkeane Thank you very much for the comments. I have added test case to 
make sure it is evaluated during compile time. Previous code could not pass 
these test cases.


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

https://reviews.llvm.org/D83362



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


[PATCH] D82659: Fix missing build dependency on omp_gen.

2020-07-08 Thread Michele Scandale via Phabricator via cfe-commits
michele.scandale added a comment.

Uhm.. it looks like it is not needed anymore. In the `LLVMConfig.cmake` that 
will be installed a `intrinsics_gen` and `omp_gen` custom targets are created 
for exactly the purpose of allowing out-of-tree or standalone builds to freely 
depend on them.
The Clang code where `intrinsics_gen` is conditionally added as a dependency is 
from 2014, while the change in `LLVMConfig.cmake.in` is from 2017.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82659



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


[PATCH] D83362: Fix warning caused by __builtin_expect_with_probability was not handled in places such as constant folding

2020-07-08 Thread Zhi Zhuang via Phabricator via cfe-commits
LukeZhuang updated this revision to Diff 276517.
LukeZhuang added a comment.

**updated: 07/08/2020**
(1) improve test case


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

https://reviews.llvm.org/D83362

Files:
  clang/lib/AST/ExprConstant.cpp
  clang/lib/StaticAnalyzer/Checkers/BuiltinFunctionChecker.cpp
  clang/test/Sema/builtin-expect-with-probability.cpp


Index: clang/test/Sema/builtin-expect-with-probability.cpp
===
--- clang/test/Sema/builtin-expect-with-probability.cpp
+++ clang/test/Sema/builtin-expect-with-probability.cpp
@@ -1,4 +1,26 @@
 // RUN: %clang_cc1 -fsyntax-only -verify %s
+
+__attribute__((noreturn)) extern void bar();
+
+int test_no_warn(int x) {
+  if (x) {
+if (__builtin_expect_with_probability(1, 1, 1))
+  bar();
+  } else {
+return 0;
+  }
+} // should not emit warn "control may reach end of non-void function" here 
since expr is constantly true, so the "if(__bui..)" should be constantly true 
condition and be ignored
+
+extern void f(int x);
+
+constexpr int constf() {
+  return __builtin_expect_with_probability(1, 1, 1); // should not have error 
here
+}
+
+void foo() {
+  f(constf());
+}
+
 extern int global;
 
 struct S {
Index: clang/lib/StaticAnalyzer/Checkers/BuiltinFunctionChecker.cpp
===
--- clang/lib/StaticAnalyzer/Checkers/BuiltinFunctionChecker.cpp
+++ clang/lib/StaticAnalyzer/Checkers/BuiltinFunctionChecker.cpp
@@ -64,10 +64,12 @@
 
   case Builtin::BI__builtin_unpredictable:
   case Builtin::BI__builtin_expect:
+  case Builtin::BI__builtin_expect_with_probability:
   case Builtin::BI__builtin_assume_aligned:
   case Builtin::BI__builtin_addressof: {
-// For __builtin_unpredictable, __builtin_expect, and
-// __builtin_assume_aligned, just return the value of the subexpression.
+// For __builtin_unpredictable, __builtin_expect,
+// __builtin_expect_with_probability and __builtin_assume_aligned,
+// just return the value of the subexpression.
 // __builtin_addressof is going from a reference to a pointer, but those
 // are represented the same way in the analyzer.
 assert (Call.getNumArgs() > 0);
Index: clang/lib/AST/ExprConstant.cpp
===
--- clang/lib/AST/ExprConstant.cpp
+++ clang/lib/AST/ExprConstant.cpp
@@ -11200,6 +11200,7 @@
   }
 
   case Builtin::BI__builtin_expect:
+  case Builtin::BI__builtin_expect_with_probability:
 return Visit(E->getArg(0));
 
   case Builtin::BI__builtin_ffs:


Index: clang/test/Sema/builtin-expect-with-probability.cpp
===
--- clang/test/Sema/builtin-expect-with-probability.cpp
+++ clang/test/Sema/builtin-expect-with-probability.cpp
@@ -1,4 +1,26 @@
 // RUN: %clang_cc1 -fsyntax-only -verify %s
+
+__attribute__((noreturn)) extern void bar();
+
+int test_no_warn(int x) {
+  if (x) {
+if (__builtin_expect_with_probability(1, 1, 1))
+  bar();
+  } else {
+return 0;
+  }
+} // should not emit warn "control may reach end of non-void function" here since expr is constantly true, so the "if(__bui..)" should be constantly true condition and be ignored
+
+extern void f(int x);
+
+constexpr int constf() {
+  return __builtin_expect_with_probability(1, 1, 1); // should not have error here
+}
+
+void foo() {
+  f(constf());
+}
+
 extern int global;
 
 struct S {
Index: clang/lib/StaticAnalyzer/Checkers/BuiltinFunctionChecker.cpp
===
--- clang/lib/StaticAnalyzer/Checkers/BuiltinFunctionChecker.cpp
+++ clang/lib/StaticAnalyzer/Checkers/BuiltinFunctionChecker.cpp
@@ -64,10 +64,12 @@
 
   case Builtin::BI__builtin_unpredictable:
   case Builtin::BI__builtin_expect:
+  case Builtin::BI__builtin_expect_with_probability:
   case Builtin::BI__builtin_assume_aligned:
   case Builtin::BI__builtin_addressof: {
-// For __builtin_unpredictable, __builtin_expect, and
-// __builtin_assume_aligned, just return the value of the subexpression.
+// For __builtin_unpredictable, __builtin_expect,
+// __builtin_expect_with_probability and __builtin_assume_aligned,
+// just return the value of the subexpression.
 // __builtin_addressof is going from a reference to a pointer, but those
 // are represented the same way in the analyzer.
 assert (Call.getNumArgs() > 0);
Index: clang/lib/AST/ExprConstant.cpp
===
--- clang/lib/AST/ExprConstant.cpp
+++ clang/lib/AST/ExprConstant.cpp
@@ -11200,6 +11200,7 @@
   }
 
   case Builtin::BI__builtin_expect:
+  case Builtin::BI__builtin_expect_with_probability:
 return Visit(E->getArg(0));
 
   case Builtin::BI__builtin_ffs:
___
cfe-commits mailing list
cfe-commits@lists.llvm.org

[PATCH] D69778: Make -fmodules-codegen and -fmodules-debuginfo work also with precompiled headers

2020-07-08 Thread David Blaikie via Phabricator via cfe-commits
dblaikie accepted this revision.
dblaikie added a comment.
This revision is now accepted and ready to land.

Sounds good


Repository:
  rC Clang

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

https://reviews.llvm.org/D69778



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


[PATCH] D82085: [TRE] allow TRE for non-capturing calls.

2020-07-08 Thread Eli Friedman via Phabricator via cfe-commits
efriedma added inline comments.



Comment at: llvm/lib/Transforms/Scalar/TailRecursionElimination.cpp:94
 /// If it contains any dynamic allocas, returns false.
 static bool canTRE(Function ) {
   // Because of PR962, we don't TRE dynamic allocas.

avl wrote:
> efriedma wrote:
> > If we're not going to try to do TRE at all on calls not marked "tail", we 
> > can probably drop this check.
> It looks to me that original idea(PR962) was to avoid inefficient code which 
> is generated for dynamic alloca. 
> 
> Currently there would still be generated inefficient code:
> 
> Doing TRE for dynamic alloca requires correct stack adjustment to avoid extra 
> stack usage. 
> i.e. dynamic stack reservation done for alloca should be restored 
> in the end of the current iteration. Current TRE implementation does not do 
> this.
> 
> Please, consider the test case:
> 
> 
> ```
> #include 
> 
> int count;
> __attribute__((noinline)) void globalIncrement(const int* param) { 
>   count += *param; 
> }
> 
> void test(int recurseCount)
> {
> if (recurseCount == 0) return;
> {
> int *temp = (int*)alloca(100);
> globalIncrement(temp);
> }
> test(recurseCount - 1);
> }
> 
> 
> ```
> Following is the x86 asm generated for the above test case in assumption that 
> dynamic allocas are possible:
> 
> ```
> 
> .LBB1_2:
> movq%rsp, %rdi
> addq$-112, %rdi   << dynamic stack reservation, need 
> to be restored before "jne .LBB1_2"
> movq%rdi, %rsp
> callq   _Z15globalIncrementPKi
> addl$-1, %ebx
> jne .LBB1_2
> ```
> 
> So, it looks like we still have inefficient code here and it was a reason for 
> avoiding TRE.
I guess we can leave this for a later patch.

This isn't really any worse than the stack usage before TRE, assuming we can't 
emit a sibling call in the backend.  And we could avoid this by making TRE 
insert stacksave/stackrestore intrinsics.  But better to do one thing at a time.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82085



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


[PATCH] D83414: Unbreak Clang standalone build.

2020-07-08 Thread Michele Scandale via Phabricator via cfe-commits
michele.scandale created this revision.
michele.scandale added reviewers: clementval, simon_tatham, chandlerc.
Herald added subscribers: cfe-commits, sstefan1, martong, arphaman, mgorny.
Herald added a reviewer: jdoerfert.
Herald added a project: clang.

Having the `omp_gen` dependency added unconditionally to Clang libraries
breaks the Clang standalone build. This dependency should be added only
if `CLANG_BUILT_STANDALONE` is false, similarly to the `intrinsics_gen`
case.
Moreover the C++ standard must be set properly as well.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D83414

Files:
  clang/CMakeLists.txt
  clang/lib/ARCMigrate/CMakeLists.txt
  clang/lib/AST/CMakeLists.txt
  clang/lib/ASTMatchers/CMakeLists.txt
  clang/lib/ASTMatchers/Dynamic/CMakeLists.txt
  clang/lib/Analysis/CMakeLists.txt
  clang/lib/Basic/CMakeLists.txt
  clang/lib/Frontend/Rewrite/CMakeLists.txt
  clang/lib/Index/CMakeLists.txt
  clang/lib/Parse/CMakeLists.txt
  clang/lib/Sema/CMakeLists.txt
  clang/lib/Serialization/CMakeLists.txt
  clang/lib/StaticAnalyzer/Checkers/CMakeLists.txt
  clang/lib/StaticAnalyzer/Core/CMakeLists.txt
  clang/lib/StaticAnalyzer/Frontend/CMakeLists.txt
  clang/lib/Tooling/ASTDiff/CMakeLists.txt
  clang/lib/Tooling/CMakeLists.txt
  clang/lib/Tooling/Refactoring/CMakeLists.txt
  clang/lib/Tooling/Syntax/CMakeLists.txt
  clang/lib/Tooling/Transformer/CMakeLists.txt

Index: clang/lib/Tooling/Transformer/CMakeLists.txt
===
--- clang/lib/Tooling/Transformer/CMakeLists.txt
+++ clang/lib/Tooling/Transformer/CMakeLists.txt
@@ -19,7 +19,4 @@
   clangLex
   clangToolingCore
   clangToolingRefactoring
-
-  DEPENDS
-  omp_gen
   )
Index: clang/lib/Tooling/Syntax/CMakeLists.txt
===
--- clang/lib/Tooling/Syntax/CMakeLists.txt
+++ clang/lib/Tooling/Syntax/CMakeLists.txt
@@ -15,7 +15,4 @@
   clangFrontend
   clangLex
   clangToolingCore
-
-  DEPENDS
-  omp_gen
   )
Index: clang/lib/Tooling/Refactoring/CMakeLists.txt
===
--- clang/lib/Tooling/Refactoring/CMakeLists.txt
+++ clang/lib/Tooling/Refactoring/CMakeLists.txt
@@ -22,7 +22,4 @@
   clangLex
   clangRewrite
   clangToolingCore
-
-  DEPENDS
-  omp_gen
   )
Index: clang/lib/Tooling/CMakeLists.txt
===
--- clang/lib/Tooling/CMakeLists.txt
+++ clang/lib/Tooling/CMakeLists.txt
@@ -31,7 +31,6 @@
 
   DEPENDS
   ClangDriverOptions
-  omp_gen
 
   LINK_LIBS
   clangAST
Index: clang/lib/Tooling/ASTDiff/CMakeLists.txt
===
--- clang/lib/Tooling/ASTDiff/CMakeLists.txt
+++ clang/lib/Tooling/ASTDiff/CMakeLists.txt
@@ -8,7 +8,4 @@
   clangBasic
   clangAST
   clangLex
-
-  DEPENDS
-  omp_gen
   )
Index: clang/lib/StaticAnalyzer/Frontend/CMakeLists.txt
===
--- clang/lib/StaticAnalyzer/Frontend/CMakeLists.txt
+++ clang/lib/StaticAnalyzer/Frontend/CMakeLists.txt
@@ -23,7 +23,4 @@
   clangLex
   clangStaticAnalyzerCheckers
   clangStaticAnalyzerCore
-
-  DEPENDS
-  omp_gen
   )
Index: clang/lib/StaticAnalyzer/Core/CMakeLists.txt
===
--- clang/lib/StaticAnalyzer/Core/CMakeLists.txt
+++ clang/lib/StaticAnalyzer/Core/CMakeLists.txt
@@ -61,8 +61,5 @@
   clangLex
   clangRewrite
   clangToolingCore
-
-  DEPENDS
-  omp_gen
   )
 
Index: clang/lib/StaticAnalyzer/Checkers/CMakeLists.txt
===
--- clang/lib/StaticAnalyzer/Checkers/CMakeLists.txt
+++ clang/lib/StaticAnalyzer/Checkers/CMakeLists.txt
@@ -135,7 +135,4 @@
   clangBasic
   clangLex
   clangStaticAnalyzerCore
-
-  DEPENDS
-  omp_gen
   )
Index: clang/lib/Serialization/CMakeLists.txt
===
--- clang/lib/Serialization/CMakeLists.txt
+++ clang/lib/Serialization/CMakeLists.txt
@@ -30,7 +30,4 @@
   clangBasic
   clangLex
   clangSema
-
-  DEPENDS
-  omp_gen
   )
Index: clang/lib/Sema/CMakeLists.txt
===
--- clang/lib/Sema/CMakeLists.txt
+++ clang/lib/Sema/CMakeLists.txt
@@ -72,7 +72,6 @@
 
   DEPENDS
   ClangOpenCLBuiltinsImpl
-  omp_gen
 
   LINK_LIBS
   clangAST
Index: clang/lib/Parse/CMakeLists.txt
===
--- clang/lib/Parse/CMakeLists.txt
+++ clang/lib/Parse/CMakeLists.txt
@@ -27,7 +27,4 @@
   clangBasic
   clangLex
   clangSema
-
-  DEPENDS
-  omp_gen
   )
Index: clang/lib/Index/CMakeLists.txt
===
--- clang/lib/Index/CMakeLists.txt
+++ clang/lib/Index/CMakeLists.txt
@@ -27,7 +27,4 @@
   clangRewrite
   clangSerialization
   clangToolingCore
-
-  DEPENDS
-  omp_gen
   )

[PATCH] D83402: ParsedAttrInfo: Change spelling to use StringRef instead of const char*

2020-07-08 Thread Nikita Popov via Phabricator via cfe-commits
nikic added a comment.

This change looks reasonable to me in terms of coding style, however I'm not 
seeing any compile-time changes in terms of instructions retired myself 
(https://llvm-compile-time-tracker.com/compare.php?from=8691544a276744474ff04b71d7e220069435c7fe=75b126ecf7b5a0ce8c04cb46c37b66233854e931=instructions).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83402



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


[PATCH] D71739: [AssumeBundles] Use operand bundles to encode alignment assumptions

2020-07-08 Thread Tyker via Phabricator via cfe-commits
Tyker updated this revision to Diff 276500.
Tyker added a comment.

fixed


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71739

Files:
  clang/lib/CodeGen/CodeGenFunction.cpp
  clang/test/CodeGen/align_value.cpp
  clang/test/CodeGen/alloc-align-attr.c
  clang/test/CodeGen/assume-aligned-and-alloc-align-attributes.c
  clang/test/CodeGen/builtin-align-array.c
  clang/test/CodeGen/builtin-align.c
  clang/test/CodeGen/builtin-assume-aligned.c
  
clang/test/CodeGen/catch-alignment-assumption-attribute-align_value-on-lvalue.cpp
  
clang/test/CodeGen/catch-alignment-assumption-attribute-align_value-on-paramvar.cpp
  
clang/test/CodeGen/catch-alignment-assumption-attribute-alloc_align-on-function-variable.cpp
  
clang/test/CodeGen/catch-alignment-assumption-attribute-alloc_align-on-function.cpp
  
clang/test/CodeGen/catch-alignment-assumption-attribute-assume_aligned-on-function-two-params.cpp
  
clang/test/CodeGen/catch-alignment-assumption-attribute-assume_aligned-on-function.cpp
  
clang/test/CodeGen/catch-alignment-assumption-builtin_assume_aligned-three-params-variable.cpp
  
clang/test/CodeGen/catch-alignment-assumption-builtin_assume_aligned-three-params.cpp
  
clang/test/CodeGen/catch-alignment-assumption-builtin_assume_aligned-two-params.cpp
  clang/test/CodeGen/catch-alignment-assumption-openmp.cpp
  clang/test/CodeGen/non-power-of-2-alignment-assumptions.c
  clang/test/OpenMP/simd_codegen.cpp
  clang/test/OpenMP/simd_metadata.c
  clang/test/OpenMP/target_teams_distribute_parallel_for_simd_codegen.cpp
  llvm/include/llvm/IR/IRBuilder.h
  llvm/include/llvm/Transforms/Scalar/AlignmentFromAssumptions.h
  llvm/lib/Analysis/AssumeBundleQueries.cpp
  llvm/lib/IR/IRBuilder.cpp
  llvm/lib/IR/Verifier.cpp
  llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp
  llvm/lib/Transforms/Scalar/AlignmentFromAssumptions.cpp
  llvm/test/Transforms/AlignmentFromAssumptions/simple.ll
  llvm/test/Transforms/AlignmentFromAssumptions/simple32.ll
  llvm/test/Transforms/Inline/align.ll
  llvm/test/Transforms/InstCombine/assume.ll
  llvm/test/Transforms/PhaseOrdering/inlining-alignment-assumptions.ll
  llvm/test/Verifier/assume-bundles.ll
  llvm/unittests/Analysis/AssumeBundleQueriesTest.cpp

Index: llvm/unittests/Analysis/AssumeBundleQueriesTest.cpp
===
--- llvm/unittests/Analysis/AssumeBundleQueriesTest.cpp
+++ llvm/unittests/Analysis/AssumeBundleQueriesTest.cpp
@@ -546,3 +546,41 @@
   ASSERT_EQ(AR[0].Index, 1u);
   ASSERT_EQ(AR[0].Assume, &*First);
 }
+
+TEST(AssumeQueryAPI, Alignment) {
+  LLVMContext C;
+  SMDiagnostic Err;
+  std::unique_ptr Mod = parseAssemblyString(
+  "declare void @llvm.assume(i1)\n"
+  "define void @test(i32* %P, i32* %P1, i32* %P2, i32 %I3, i1 %B) {\n"
+  "call void @llvm.assume(i1 true) [\"align\"(i32* %P, i32 8, i32 %I3)]\n"
+  "call void @llvm.assume(i1 true) [\"align\"(i32* %P1, i32 %I3, i32 "
+  "%I3)]\n"
+  "call void @llvm.assume(i1 true) [\"align\"(i32* %P2, i32 16, i32 8)]\n"
+  "ret void\n}\n",
+  Err, C);
+  if (!Mod)
+Err.print("AssumeQueryAPI", errs());
+
+  Function *F = Mod->getFunction("test");
+  BasicBlock::iterator Start = F->begin()->begin();
+  IntrinsicInst *II;
+  RetainedKnowledge RK;
+  II = cast(&*Start);
+  RK = getKnowledgeFromBundle(*II, II->bundle_op_info_begin()[0]);
+  ASSERT_EQ(RK.AttrKind, Attribute::Alignment);
+  ASSERT_EQ(RK.WasOn, F->getArg(0));
+  ASSERT_EQ(RK.ArgValue, 1u);
+  Start++;
+  II = cast(&*Start);
+  RK = getKnowledgeFromBundle(*II, II->bundle_op_info_begin()[0]);
+  ASSERT_EQ(RK.AttrKind, Attribute::Alignment);
+  ASSERT_EQ(RK.WasOn, F->getArg(1));
+  ASSERT_EQ(RK.ArgValue, 1u);
+  Start++;
+  II = cast(&*Start);
+  RK = getKnowledgeFromBundle(*II, II->bundle_op_info_begin()[0]);
+  ASSERT_EQ(RK.AttrKind, Attribute::Alignment);
+  ASSERT_EQ(RK.WasOn, F->getArg(2));
+  ASSERT_EQ(RK.ArgValue, 8u);
+}
Index: llvm/test/Verifier/assume-bundles.ll
===
--- llvm/test/Verifier/assume-bundles.ll
+++ llvm/test/Verifier/assume-bundles.ll
@@ -1,3 +1,4 @@
+; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
 ; RUN: not opt -verify < %s 2>&1 | FileCheck %s
 
 declare void @llvm.assume(i1)
@@ -6,14 +7,21 @@
 ; CHECK: tags must be valid attribute names
   call void @llvm.assume(i1 true) ["adazdazd"()]
 ; CHECK: the second argument should be a constant integral value
-  call void @llvm.assume(i1 true) ["align"(i32* %P, i32 %P1)]
+  call void @llvm.assume(i1 true) ["dereferenceable"(i32* %P, i32 %P1)]
 ; CHECK: to many arguments
-  call void @llvm.assume(i1 true) ["align"(i32* %P, i32 8, i32 8)]
+  call void @llvm.assume(i1 true) ["dereferenceable"(i32* %P, i32 8, i32 8)]
 ; CHECK: this attribute should have 2 arguments
-  call void @llvm.assume(i1 true) ["align"(i32* %P)]
+  call void @llvm.assume(i1 

LLVM buildmaster will be updated and restarted tonight

2020-07-08 Thread Galina Kistanova via cfe-commits
 Hello everyone,

LLVM buildmaster will be updated and restarted after 6PM PST today.

Thanks

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


[PATCH] D71739: [AssumeBundles] Use operand bundles to encode alignment assumptions

2020-07-08 Thread Tyker via Phabricator via cfe-commits
Tyker updated this revision to Diff 276498.
Tyker added a comment.

addressed commemt.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71739

Files:
  clang/lib/CodeGen/CodeGenFunction.cpp
  clang/test/CodeGen/align_value.cpp
  clang/test/CodeGen/alloc-align-attr.c
  clang/test/CodeGen/assume-aligned-and-alloc-align-attributes.c
  clang/test/CodeGen/builtin-align-array.c
  clang/test/CodeGen/builtin-align.c
  clang/test/CodeGen/builtin-assume-aligned.c
  
clang/test/CodeGen/catch-alignment-assumption-attribute-align_value-on-lvalue.cpp
  
clang/test/CodeGen/catch-alignment-assumption-attribute-align_value-on-paramvar.cpp
  
clang/test/CodeGen/catch-alignment-assumption-attribute-alloc_align-on-function-variable.cpp
  
clang/test/CodeGen/catch-alignment-assumption-attribute-alloc_align-on-function.cpp
  
clang/test/CodeGen/catch-alignment-assumption-attribute-assume_aligned-on-function-two-params.cpp
  
clang/test/CodeGen/catch-alignment-assumption-attribute-assume_aligned-on-function.cpp
  
clang/test/CodeGen/catch-alignment-assumption-builtin_assume_aligned-three-params-variable.cpp
  
clang/test/CodeGen/catch-alignment-assumption-builtin_assume_aligned-three-params.cpp
  
clang/test/CodeGen/catch-alignment-assumption-builtin_assume_aligned-two-params.cpp
  clang/test/CodeGen/catch-alignment-assumption-openmp.cpp
  clang/test/CodeGen/non-power-of-2-alignment-assumptions.c
  clang/test/OpenMP/simd_codegen.cpp
  clang/test/OpenMP/simd_metadata.c
  clang/test/OpenMP/target_teams_distribute_parallel_for_simd_codegen.cpp
  llvm/include/llvm/IR/IRBuilder.h
  llvm/include/llvm/Transforms/Scalar/AlignmentFromAssumptions.h
  llvm/lib/Analysis/AssumeBundleQueries.cpp
  llvm/lib/IR/IRBuilder.cpp
  llvm/lib/IR/Verifier.cpp
  llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp
  llvm/lib/Transforms/Scalar/AlignmentFromAssumptions.cpp
  llvm/test/Transforms/AlignmentFromAssumptions/simple.ll
  llvm/test/Transforms/AlignmentFromAssumptions/simple32.ll
  llvm/test/Transforms/Inline/align.ll
  llvm/test/Transforms/InstCombine/assume.ll
  llvm/test/Transforms/PhaseOrdering/inlining-alignment-assumptions.ll
  llvm/test/Verifier/assume-bundles.ll
  llvm/unittests/Analysis/AssumeBundleQueriesTest.cpp

Index: llvm/unittests/Analysis/AssumeBundleQueriesTest.cpp
===
--- llvm/unittests/Analysis/AssumeBundleQueriesTest.cpp
+++ llvm/unittests/Analysis/AssumeBundleQueriesTest.cpp
@@ -546,3 +546,41 @@
   ASSERT_EQ(AR[0].Index, 1u);
   ASSERT_EQ(AR[0].Assume, &*First);
 }
+
+TEST(AssumeQueryAPI, Alignment) {
+  LLVMContext C;
+  SMDiagnostic Err;
+  std::unique_ptr Mod = parseAssemblyString(
+  "declare void @llvm.assume(i1)\n"
+  "define void @test(i32* %P, i32* %P1, i32* %P2, i32 %I3, i1 %B) {\n"
+  "call void @llvm.assume(i1 true) [\"align\"(i32* %P, i32 8, i32 %I3)]\n"
+  "call void @llvm.assume(i1 true) [\"align\"(i32* %P1, i32 %I3, i32 "
+  "%I3)]\n"
+  "call void @llvm.assume(i1 true) [\"align\"(i32* %P2, i32 16, i32 8)]\n"
+  "ret void\n}\n",
+  Err, C);
+  if (!Mod)
+Err.print("AssumeQueryAPI", errs());
+
+  Function *F = Mod->getFunction("test");
+  BasicBlock::iterator Start = F->begin()->begin();
+  IntrinsicInst *II;
+  RetainedKnowledge RK;
+  II = cast(&*Start);
+  RK = getKnowledgeFromBundle(*II, II->bundle_op_info_begin()[0]);
+  ASSERT_EQ(RK.AttrKind, Attribute::Alignment);
+  ASSERT_EQ(RK.WasOn, F->getArg(0));
+  ASSERT_EQ(RK.ArgValue, 1u);
+  Start++;
+  II = cast(&*Start);
+  RK = getKnowledgeFromBundle(*II, II->bundle_op_info_begin()[0]);
+  ASSERT_EQ(RK.AttrKind, Attribute::Alignment);
+  ASSERT_EQ(RK.WasOn, F->getArg(1));
+  ASSERT_EQ(RK.ArgValue, 1u);
+  Start++;
+  II = cast(&*Start);
+  RK = getKnowledgeFromBundle(*II, II->bundle_op_info_begin()[0]);
+  ASSERT_EQ(RK.AttrKind, Attribute::Alignment);
+  ASSERT_EQ(RK.WasOn, F->getArg(2));
+  ASSERT_EQ(RK.ArgValue, 8u);
+}
Index: llvm/test/Verifier/assume-bundles.ll
===
--- llvm/test/Verifier/assume-bundles.ll
+++ llvm/test/Verifier/assume-bundles.ll
@@ -1,3 +1,4 @@
+; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
 ; RUN: not opt -verify < %s 2>&1 | FileCheck %s
 
 declare void @llvm.assume(i1)
@@ -6,14 +7,21 @@
 ; CHECK: tags must be valid attribute names
   call void @llvm.assume(i1 true) ["adazdazd"()]
 ; CHECK: the second argument should be a constant integral value
-  call void @llvm.assume(i1 true) ["align"(i32* %P, i32 %P1)]
+  call void @llvm.assume(i1 true) ["dereferenceable"(i32* %P, i32 %P1)]
 ; CHECK: to many arguments
-  call void @llvm.assume(i1 true) ["align"(i32* %P, i32 8, i32 8)]
+  call void @llvm.assume(i1 true) ["dereferenceable"(i32* %P, i32 8, i32 8)]
 ; CHECK: this attribute should have 2 arguments
-  call void @llvm.assume(i1 true) ["align"(i32* %P)]
+  call void 

[PATCH] D83055: [clang][Driver] Fix tool path priority test failures

2020-07-08 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added inline comments.



Comment at: clang/test/Driver/program-path-priority.c:117
 // RUN: mv %t/$DEFAULT_TRIPLE-gcc %t/prefix
+// RUN: mv %t/%target_triple-gcc %t/prefix
 // RUN: touch %t/notreal-none-elf-gcc && chmod +x %t/notreal-none-elf-gcc

If $DEFAULT_TRIPLE == %target_triple, this mv command will fail.

The same applies to the rm below.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83055



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


[PATCH] D81678: Introduce noundef attribute at call sites for stricter poison analysis

2020-07-08 Thread Gui Andrade via Phabricator via cfe-commits
guiand updated this revision to Diff 276487.
guiand added a comment.

Per @nikic's suggestion, I isolated the LLVM side of the changes to a separate 
revision D83412 , which should be good to go.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81678

Files:
  clang/include/clang/Basic/CodeGenOptions.def
  clang/include/clang/Driver/CC1Options.td
  clang/lib/CodeGen/CGCall.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/test/CodeGen/indirect-noundef.c

Index: clang/test/CodeGen/indirect-noundef.c
===
--- /dev/null
+++ clang/test/CodeGen/indirect-noundef.c
@@ -0,0 +1,30 @@
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown -O0 -emit-llvm -o - %s | FileCheck %s
+
+union u1 { int val; };
+
+// CHECK: @indirect_callee_int_ptr = global i32 (i32)*
+int (*indirect_callee_int_ptr)(int);
+// CHECK: @indirect_callee_union_ptr = global i32 (i32)*
+union u1 (*indirect_callee_union_ptr)(union u1);
+
+// CHECK-LABEL: define noundef i32 @indirect_callee_int(i32 noundef %
+int indirect_callee_int(int a) { return a; }
+// CHECK-LABEL: define i32 @indirect_callee_union(i32 %
+union u1 indirect_callee_union(union u1 a) { return a; }
+
+int main() {
+// CHECK: call noundef i32 @indirect_callee_int(i32 noundef 0)
+indirect_callee_int(0);
+// CHECK: call i32 @indirect_callee_union(i32 %
+indirect_callee_union((union u1){0});
+
+indirect_callee_int_ptr = indirect_callee_int;
+indirect_callee_union_ptr = indirect_callee_union;
+
+// CHECK: call noundef i32 %{{.*}}(i32 noundef 0)
+indirect_callee_int_ptr(0);
+// CHECK: call i32 %{{.*}}(i32 %
+indirect_callee_union_ptr((union u1){});
+
+return 0;
+}
Index: clang/lib/Frontend/CompilerInvocation.cpp
===
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -925,6 +925,7 @@
 
   Opts.DisableFree = Args.hasArg(OPT_disable_free);
   Opts.DiscardValueNames = Args.hasArg(OPT_discard_value_names);
+  Opts.DisableNoundefArgs = Args.hasArg(OPT_disable_noundef_args);
   Opts.DisableTailCalls = Args.hasArg(OPT_mdisable_tail_calls);
   Opts.NoEscapingBlockTailCalls =
   Args.hasArg(OPT_fno_escaping_block_tail_calls);
Index: clang/lib/CodeGen/CGCall.cpp
===
--- clang/lib/CodeGen/CGCall.cpp
+++ clang/lib/CodeGen/CGCall.cpp
@@ -1876,6 +1876,33 @@
   llvm::for_each(NBA->builtinNames(), AddNoBuiltinAttr);
 }
 
+static bool DetermineNoUndef(QualType QTy, CodeGenTypes ,
+ const llvm::DataLayout , const ABIArgInfo ) {
+  llvm::Type *Ty = Types.ConvertTypeForMem(QTy);
+  if (AI.getKind() == ABIArgInfo::Indirect)
+return true;
+  if (AI.getKind() == ABIArgInfo::Extend)
+return true;
+  if (!DL.typeSizeEqualsStoreSize(Ty))
+return false;
+  if (QTy->isExtIntType())
+return true;
+  if (QTy->isReferenceType())
+return true;
+  if (QTy->isScalarType()) {
+if (const ComplexType *Complex = dyn_cast(QTy))
+  return DetermineNoUndef(Complex->getElementType(), Types, DL, AI);
+return true;
+  }
+  if (const VectorType *Vector = dyn_cast(QTy))
+return DetermineNoUndef(Vector->getElementType(), Types, DL, AI);
+  if (const MatrixType *Matrix = dyn_cast(QTy))
+return DetermineNoUndef(Matrix->getElementType(), Types, DL, AI);
+  if (const ArrayType *Array = dyn_cast(QTy))
+return DetermineNoUndef(Array->getElementType(), Types, DL, AI);
+  return false;
+}
+
 /// Construct the IR attribute list of a function or call.
 ///
 /// When adding an attribute, please consider where it should be handled:
@@ -2075,6 +2102,14 @@
 
   QualType RetTy = FI.getReturnType();
   const ABIArgInfo  = FI.getReturnInfo();
+  const llvm::DataLayout  = getDataLayout();
+
+  // Determine if the return type could be partially undef
+  if (!RetTy->isVoidType() && RetAI.getKind() != ABIArgInfo::Indirect &&
+  DetermineNoUndef(RetTy, getTypes(), DL, RetAI)) {
+RetAttrs.addAttribute(llvm::Attribute::NoUndef);
+  }
+
   switch (RetAI.getKind()) {
   case ABIArgInfo::Extend:
 if (RetAI.isSignExt())
@@ -2160,6 +2195,12 @@
   }
 }
 
+// Decide whether the argument we're handling could be partially undef
+bool ArgNoUndef = DetermineNoUndef(ParamType, getTypes(), DL, AI);
+if (!CodeGenOpts.DisableNoundefArgs && ArgNoUndef) {
+  Attrs.addAttribute(llvm::Attribute::NoUndef);
+}
+
 // 'restrict' -> 'noalias' is done in EmitFunctionProlog when we
 // have the corresponding parameter variable.  It doesn't make
 // sense to do it here because parameters are so messed up.
Index: clang/include/clang/Driver/CC1Options.td
===
--- clang/include/clang/Driver/CC1Options.td
+++ 

[PATCH] D83254: [X86] Enabled a bunch of 64-bit Interlocked* functions intrinsics on 32-bit Windows to match recent MSVC

2020-07-08 Thread Craig Topper via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG82206e7fb49d: [X86] Enabled a bunch of 64-bit Interlocked* 
functions intrinsics on 32-bit… (authored by craig.topper).
Herald added a project: clang.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83254

Files:
  clang/include/clang/Basic/BuiltinsX86.def
  clang/include/clang/Basic/BuiltinsX86_64.def
  clang/lib/Headers/intrin.h
  clang/test/CodeGen/ms-intrinsics.c

Index: clang/test/CodeGen/ms-intrinsics.c
===
--- clang/test/CodeGen/ms-intrinsics.c
+++ clang/test/CodeGen/ms-intrinsics.c
@@ -523,72 +523,72 @@
 // CHECK: store volatile i64 %v, i64* %p
 
 
-#if defined(__x86_64__) || defined(__arm__) || defined(__aarch64__)
+#if defined(__i386__) || defined(__x86_64__) || defined(__arm__) || defined(__aarch64__)
 __int64 test_InterlockedExchange64(__int64 volatile *value, __int64 mask) {
   return _InterlockedExchange64(value, mask);
 }
-// CHECK-ARM-X64: define{{.*}}i64 @test_InterlockedExchange64(i64*{{[a-z_ ]*}}%value, i64{{[a-z_ ]*}}%mask){{.*}}{
-// CHECK-ARM-X64:   [[RESULT:%[0-9]+]] = atomicrmw xchg i64* %value, i64 %mask seq_cst
-// CHECK-ARM-X64:   ret i64 [[RESULT:%[0-9]+]]
-// CHECK-ARM-X64: }
+// CHECK: define{{.*}}i64 @test_InterlockedExchange64(i64*{{[a-z_ ]*}}%value, i64{{[a-z_ ]*}}%mask){{.*}}{
+// CHECK:   [[RESULT:%[0-9]+]] = atomicrmw xchg i64* %value, i64 %mask seq_cst
+// CHECK:   ret i64 [[RESULT:%[0-9]+]]
+// CHECK: }
 
 __int64 test_InterlockedExchangeAdd64(__int64 volatile *value, __int64 mask) {
   return _InterlockedExchangeAdd64(value, mask);
 }
-// CHECK-ARM-X64: define{{.*}}i64 @test_InterlockedExchangeAdd64(i64*{{[a-z_ ]*}}%value, i64{{[a-z_ ]*}}%mask){{.*}}{
-// CHECK-ARM-X64:   [[RESULT:%[0-9]+]] = atomicrmw add i64* %value, i64 %mask seq_cst
-// CHECK-ARM-X64:   ret i64 [[RESULT:%[0-9]+]]
-// CHECK-ARM-X64: }
+// CHECK: define{{.*}}i64 @test_InterlockedExchangeAdd64(i64*{{[a-z_ ]*}}%value, i64{{[a-z_ ]*}}%mask){{.*}}{
+// CHECK:   [[RESULT:%[0-9]+]] = atomicrmw add i64* %value, i64 %mask seq_cst
+// CHECK:   ret i64 [[RESULT:%[0-9]+]]
+// CHECK: }
 
 __int64 test_InterlockedExchangeSub64(__int64 volatile *value, __int64 mask) {
   return _InterlockedExchangeSub64(value, mask);
 }
-// CHECK-ARM-X64: define{{.*}}i64 @test_InterlockedExchangeSub64(i64*{{[a-z_ ]*}}%value, i64{{[a-z_ ]*}}%mask){{.*}}{
-// CHECK-ARM-X64:   [[RESULT:%[0-9]+]] = atomicrmw sub i64* %value, i64 %mask seq_cst
-// CHECK-ARM-X64:   ret i64 [[RESULT:%[0-9]+]]
-// CHECK-ARM-X64: }
+// CHECK: define{{.*}}i64 @test_InterlockedExchangeSub64(i64*{{[a-z_ ]*}}%value, i64{{[a-z_ ]*}}%mask){{.*}}{
+// CHECK:   [[RESULT:%[0-9]+]] = atomicrmw sub i64* %value, i64 %mask seq_cst
+// CHECK:   ret i64 [[RESULT:%[0-9]+]]
+// CHECK: }
 
 __int64 test_InterlockedOr64(__int64 volatile *value, __int64 mask) {
   return _InterlockedOr64(value, mask);
 }
-// CHECK-ARM-X64: define{{.*}}i64 @test_InterlockedOr64(i64*{{[a-z_ ]*}}%value, i64{{[a-z_ ]*}}%mask){{.*}}{
-// CHECK-ARM-X64:   [[RESULT:%[0-9]+]] = atomicrmw or i64* %value, i64 %mask seq_cst
-// CHECK-ARM-X64:   ret i64 [[RESULT:%[0-9]+]]
-// CHECK-ARM-X64: }
+// CHECK: define{{.*}}i64 @test_InterlockedOr64(i64*{{[a-z_ ]*}}%value, i64{{[a-z_ ]*}}%mask){{.*}}{
+// CHECK:   [[RESULT:%[0-9]+]] = atomicrmw or i64* %value, i64 %mask seq_cst
+// CHECK:   ret i64 [[RESULT:%[0-9]+]]
+// CHECK: }
 
 __int64 test_InterlockedXor64(__int64 volatile *value, __int64 mask) {
   return _InterlockedXor64(value, mask);
 }
-// CHECK-ARM-X64: define{{.*}}i64 @test_InterlockedXor64(i64*{{[a-z_ ]*}}%value, i64{{[a-z_ ]*}}%mask){{.*}}{
-// CHECK-ARM-X64:   [[RESULT:%[0-9]+]] = atomicrmw xor i64* %value, i64 %mask seq_cst
-// CHECK-ARM-X64:   ret i64 [[RESULT:%[0-9]+]]
-// CHECK-ARM-X64: }
+// CHECK: define{{.*}}i64 @test_InterlockedXor64(i64*{{[a-z_ ]*}}%value, i64{{[a-z_ ]*}}%mask){{.*}}{
+// CHECK:   [[RESULT:%[0-9]+]] = atomicrmw xor i64* %value, i64 %mask seq_cst
+// CHECK:   ret i64 [[RESULT:%[0-9]+]]
+// CHECK: }
 
 __int64 test_InterlockedAnd64(__int64 volatile *value, __int64 mask) {
   return _InterlockedAnd64(value, mask);
 }
-// CHECK-ARM-X64: define{{.*}}i64 @test_InterlockedAnd64(i64*{{[a-z_ ]*}}%value, i64{{[a-z_ ]*}}%mask){{.*}}{
-// CHECK-ARM-X64:   [[RESULT:%[0-9]+]] = atomicrmw and i64* %value, i64 %mask seq_cst
-// CHECK-ARM-X64:   ret i64 [[RESULT:%[0-9]+]]
-// CHECK-ARM-X64: }
+// CHECK: define{{.*}}i64 @test_InterlockedAnd64(i64*{{[a-z_ ]*}}%value, i64{{[a-z_ ]*}}%mask){{.*}}{
+// CHECK:   [[RESULT:%[0-9]+]] = atomicrmw and i64* %value, i64 %mask seq_cst
+// CHECK:   ret i64 [[RESULT:%[0-9]+]]
+// CHECK: }
 
 __int64 test_InterlockedIncrement64(__int64 volatile *Addend) {
   return _InterlockedIncrement64(Addend);
 }
-// CHECK-ARM-X64: define{{.*}}i64 @test_InterlockedIncrement64(i64*{{[a-z_ ]*}}%Addend){{.*}}{
-// CHECK-ARM-X64: 

[clang] 82206e7 - [X86] Enabled a bunch of 64-bit Interlocked* functions intrinsics on 32-bit Windows to match recent MSVC

2020-07-08 Thread Craig Topper via cfe-commits

Author: Craig Topper
Date: 2020-07-08T10:39:56-07:00
New Revision: 82206e7fb49d9593d946599b107e8a8ad29a7d22

URL: 
https://github.com/llvm/llvm-project/commit/82206e7fb49d9593d946599b107e8a8ad29a7d22
DIFF: 
https://github.com/llvm/llvm-project/commit/82206e7fb49d9593d946599b107e8a8ad29a7d22.diff

LOG: [X86] Enabled a bunch of 64-bit Interlocked* functions intrinsics on 
32-bit Windows to match recent MSVC

This enables 
_InterlockedAnd64/_InterlockedOr64/_InterlockedXor64/_InterlockedDecrement64/_InterlockedIncrement64/_InterlockedExchange64/_InterlockedExchangeAdd64/_InterlockedExchangeSub64
 on 32-bit Windows

The backend already knows how to expand these to a loop using cmpxchg8b on 
32-bit targets.

Fixes PR46595

Differential Revision: https://reviews.llvm.org/D83254

Added: 


Modified: 
clang/include/clang/Basic/BuiltinsX86.def
clang/include/clang/Basic/BuiltinsX86_64.def
clang/lib/Headers/intrin.h
clang/test/CodeGen/ms-intrinsics.c

Removed: 




diff  --git a/clang/include/clang/Basic/BuiltinsX86.def 
b/clang/include/clang/Basic/BuiltinsX86.def
index 7dcbcf086ede..35fb98352ec2 100644
--- a/clang/include/clang/Basic/BuiltinsX86.def
+++ b/clang/include/clang/Basic/BuiltinsX86.def
@@ -1934,6 +1934,15 @@ TARGET_HEADER_BUILTIN(__readgsword,  "UsUNi", "nh", 
"intrin.h", ALL_MS_LANGUAGES
 TARGET_HEADER_BUILTIN(__readgsdword, "UNiUNi", "nh", "intrin.h", 
ALL_MS_LANGUAGES, "")
 TARGET_HEADER_BUILTIN(__readgsqword, "ULLiUNi", "nh", "intrin.h", 
ALL_MS_LANGUAGES, "")
 
+TARGET_HEADER_BUILTIN(_InterlockedAnd64, "WiWiD*Wi", "nh", "intrin.h", 
ALL_MS_LANGUAGES, "")
+TARGET_HEADER_BUILTIN(_InterlockedDecrement64,   "WiWiD*",   "nh", "intrin.h", 
ALL_MS_LANGUAGES, "")
+TARGET_HEADER_BUILTIN(_InterlockedExchange64,"WiWiD*Wi", "nh", "intrin.h", 
ALL_MS_LANGUAGES, "")
+TARGET_HEADER_BUILTIN(_InterlockedExchangeAdd64, "WiWiD*Wi", "nh", "intrin.h", 
ALL_MS_LANGUAGES, "")
+TARGET_HEADER_BUILTIN(_InterlockedExchangeSub64, "WiWiD*Wi", "nh", "intrin.h", 
ALL_MS_LANGUAGES, "")
+TARGET_HEADER_BUILTIN(_InterlockedIncrement64,   "WiWiD*",   "nh", "intrin.h", 
ALL_MS_LANGUAGES, "")
+TARGET_HEADER_BUILTIN(_InterlockedOr64,  "WiWiD*Wi", "nh", "intrin.h", 
ALL_MS_LANGUAGES, "")
+TARGET_HEADER_BUILTIN(_InterlockedXor64, "WiWiD*Wi", "nh", "intrin.h", 
ALL_MS_LANGUAGES, "")
+
 #undef BUILTIN
 #undef TARGET_BUILTIN
 #undef TARGET_HEADER_BUILTIN

diff  --git a/clang/include/clang/Basic/BuiltinsX86_64.def 
b/clang/include/clang/Basic/BuiltinsX86_64.def
index 7feccd2a81a0..f66ae78f7e81 100644
--- a/clang/include/clang/Basic/BuiltinsX86_64.def
+++ b/clang/include/clang/Basic/BuiltinsX86_64.def
@@ -33,14 +33,6 @@ TARGET_HEADER_BUILTIN(__faststorefence, "v", "nh", 
"intrin.h", ALL_MS_LANGUAGES,
 TARGET_HEADER_BUILTIN(__shiftleft128, "ULLiULLiULLiUc", "nch", "intrin.h", 
ALL_MS_LANGUAGES, "")
 TARGET_HEADER_BUILTIN(__shiftright128, "ULLiULLiULLiUc", "nch", "intrin.h", 
ALL_MS_LANGUAGES, "")
 
-TARGET_HEADER_BUILTIN(_InterlockedAnd64, "LLiLLiD*LLi", "nh", 
"intrin.h", ALL_MS_LANGUAGES, "")
-TARGET_HEADER_BUILTIN(_InterlockedDecrement64,   "LLiLLiD*","nh", 
"intrin.h", ALL_MS_LANGUAGES, "")
-TARGET_HEADER_BUILTIN(_InterlockedExchange64,"LLiLLiD*LLi", "nh", 
"intrin.h", ALL_MS_LANGUAGES, "")
-TARGET_HEADER_BUILTIN(_InterlockedExchangeAdd64, "LLiLLiD*LLi", "nh", 
"intrin.h", ALL_MS_LANGUAGES, "")
-TARGET_HEADER_BUILTIN(_InterlockedExchangeSub64, "LLiLLiD*LLi", "nh", 
"intrin.h", ALL_MS_LANGUAGES, "")
-TARGET_HEADER_BUILTIN(_InterlockedIncrement64,   "LLiLLiD*","nh", 
"intrin.h", ALL_MS_LANGUAGES, "")
-TARGET_HEADER_BUILTIN(_InterlockedOr64,  "LLiLLiD*LLi", "nh", 
"intrin.h", ALL_MS_LANGUAGES, "")
-TARGET_HEADER_BUILTIN(_InterlockedXor64, "LLiLLiD*LLi", "nh", 
"intrin.h", ALL_MS_LANGUAGES, "")
 TARGET_HEADER_BUILTIN(_InterlockedCompareExchange128, "UcLLiD*LLiLLiLLi*", 
"nh", "intrin.h", ALL_MS_LANGUAGES, "cx16")
 
 TARGET_BUILTIN(__builtin_ia32_readeflags_u64, "UOi", "n", "")

diff  --git a/clang/lib/Headers/intrin.h b/clang/lib/Headers/intrin.h
index f85f7a2beb49..871b47ca8267 100644
--- a/clang/lib/Headers/intrin.h
+++ b/clang/lib/Headers/intrin.h
@@ -289,6 +289,9 @@ unsigned char _BitScanForward64(unsigned long *_Index, 
unsigned __int64 _Mask);
 static __inline__
 unsigned char _BitScanReverse64(unsigned long *_Index, unsigned __int64 _Mask);
 
+#endif
+
+#if defined(__i386__) || defined(__x86_64__) || defined(__arm__) || 
defined(__aarch64__)
 static __inline__
 __int64 _InterlockedDecrement64(__int64 volatile *_Addend);
 static __inline__

diff  --git a/clang/test/CodeGen/ms-intrinsics.c 
b/clang/test/CodeGen/ms-intrinsics.c
index fed789e60d37..5182ae403984 100644
--- a/clang/test/CodeGen/ms-intrinsics.c
+++ b/clang/test/CodeGen/ms-intrinsics.c
@@ -523,72 +523,72 @@ void test_iso_volatile_store64(__int64 volatile *p, 
__int64 v) { __iso_volatile_
 // CHECK: store volatile 

[PATCH] D83369: hwasan: Don't pass the tagged-globals target-feature to non-aarch64 backends.

2020-07-08 Thread Craig Topper via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG01d5cc5386af: hwasan: Dont pass the tagged-globals 
target-feature to non-aarch64 backends. (authored by craig.topper).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83369

Files:
  clang/lib/Driver/SanitizerArgs.cpp
  clang/test/Driver/fsanitize.c


Index: clang/test/Driver/fsanitize.c
===
--- clang/test/Driver/fsanitize.c
+++ clang/test/Driver/fsanitize.c
@@ -868,9 +868,7 @@
 // RUN: %clang -target x86_64-linux-gnu -fsanitize=hwaddress 
-fsanitize-hwaddress-abi=platform %s -### 2>&1 | FileCheck %s 
--check-prefix=CHECK-HWASAN-PLATFORM-ABI
 // RUN: %clang -target x86_64-linux-gnu -fsanitize=hwaddress 
-fsanitize-hwaddress-abi=foo %s -### 2>&1 | FileCheck %s 
--check-prefix=CHECK-HWASAN-FOO-ABI
 // CHECK-HWASAN-INTERCEPTOR-ABI: "-default-function-attr" 
"hwasan-abi=interceptor"
-// CHECK-HWASAN-INTERCEPTOR-ABI: "-target-feature" "+tagged-globals"
 // CHECK-HWASAN-PLATFORM-ABI: "-default-function-attr" "hwasan-abi=platform"
-// CHECK-HWASAN-PLATFORM-ABI: "-target-feature" "+tagged-globals"
 // CHECK-HWASAN-FOO-ABI: error: invalid value 'foo' in 
'-fsanitize-hwaddress-abi=foo'
 
 // RUN: %clang -target x86_64-linux-gnu 
-fsanitize=address,pointer-compare,pointer-subtract %s -### 2>&1 | FileCheck %s 
--check-prefix=CHECK-POINTER-ALL
Index: clang/lib/Driver/SanitizerArgs.cpp
===
--- clang/lib/Driver/SanitizerArgs.cpp
+++ clang/lib/Driver/SanitizerArgs.cpp
@@ -1068,7 +1068,7 @@
 CmdArgs.push_back(Args.MakeArgString("hwasan-abi=" + HwasanAbi));
   }
 
-  if (Sanitizers.has(SanitizerKind::HWAddress)) {
+  if (Sanitizers.has(SanitizerKind::HWAddress) && TC.getTriple().isAArch64()) {
 CmdArgs.push_back("-target-feature");
 CmdArgs.push_back("+tagged-globals");
   }


Index: clang/test/Driver/fsanitize.c
===
--- clang/test/Driver/fsanitize.c
+++ clang/test/Driver/fsanitize.c
@@ -868,9 +868,7 @@
 // RUN: %clang -target x86_64-linux-gnu -fsanitize=hwaddress -fsanitize-hwaddress-abi=platform %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-HWASAN-PLATFORM-ABI
 // RUN: %clang -target x86_64-linux-gnu -fsanitize=hwaddress -fsanitize-hwaddress-abi=foo %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-HWASAN-FOO-ABI
 // CHECK-HWASAN-INTERCEPTOR-ABI: "-default-function-attr" "hwasan-abi=interceptor"
-// CHECK-HWASAN-INTERCEPTOR-ABI: "-target-feature" "+tagged-globals"
 // CHECK-HWASAN-PLATFORM-ABI: "-default-function-attr" "hwasan-abi=platform"
-// CHECK-HWASAN-PLATFORM-ABI: "-target-feature" "+tagged-globals"
 // CHECK-HWASAN-FOO-ABI: error: invalid value 'foo' in '-fsanitize-hwaddress-abi=foo'
 
 // RUN: %clang -target x86_64-linux-gnu -fsanitize=address,pointer-compare,pointer-subtract %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-POINTER-ALL
Index: clang/lib/Driver/SanitizerArgs.cpp
===
--- clang/lib/Driver/SanitizerArgs.cpp
+++ clang/lib/Driver/SanitizerArgs.cpp
@@ -1068,7 +1068,7 @@
 CmdArgs.push_back(Args.MakeArgString("hwasan-abi=" + HwasanAbi));
   }
 
-  if (Sanitizers.has(SanitizerKind::HWAddress)) {
+  if (Sanitizers.has(SanitizerKind::HWAddress) && TC.getTriple().isAArch64()) {
 CmdArgs.push_back("-target-feature");
 CmdArgs.push_back("+tagged-globals");
   }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 01d5cc5 - hwasan: Don't pass the tagged-globals target-feature to non-aarch64 backends.

2020-07-08 Thread Craig Topper via cfe-commits

Author: Craig Topper
Date: 2020-07-08T10:36:48-07:00
New Revision: 01d5cc5386affeda878e7e21b57c2a7e050d7b0a

URL: 
https://github.com/llvm/llvm-project/commit/01d5cc5386affeda878e7e21b57c2a7e050d7b0a
DIFF: 
https://github.com/llvm/llvm-project/commit/01d5cc5386affeda878e7e21b57c2a7e050d7b0a.diff

LOG: hwasan: Don't pass the tagged-globals target-feature to non-aarch64 
backends.

The other backends don't know what this feature is and print a
message to stderr.

I recently tried to rework some target feature stuff in X86 and
this unknown feature tripped an assert I added.

Differential Revision: https://reviews.llvm.org/D83369

Added: 


Modified: 
clang/lib/Driver/SanitizerArgs.cpp
clang/test/Driver/fsanitize.c

Removed: 




diff  --git a/clang/lib/Driver/SanitizerArgs.cpp 
b/clang/lib/Driver/SanitizerArgs.cpp
index 9d307e8097cb..0b81152d57f6 100644
--- a/clang/lib/Driver/SanitizerArgs.cpp
+++ b/clang/lib/Driver/SanitizerArgs.cpp
@@ -1068,7 +1068,7 @@ void SanitizerArgs::addArgs(const ToolChain , const 
llvm::opt::ArgList ,
 CmdArgs.push_back(Args.MakeArgString("hwasan-abi=" + HwasanAbi));
   }
 
-  if (Sanitizers.has(SanitizerKind::HWAddress)) {
+  if (Sanitizers.has(SanitizerKind::HWAddress) && TC.getTriple().isAArch64()) {
 CmdArgs.push_back("-target-feature");
 CmdArgs.push_back("+tagged-globals");
   }

diff  --git a/clang/test/Driver/fsanitize.c b/clang/test/Driver/fsanitize.c
index 9ff2bdf58d6c..7340bfb35e40 100644
--- a/clang/test/Driver/fsanitize.c
+++ b/clang/test/Driver/fsanitize.c
@@ -868,9 +868,7 @@
 // RUN: %clang -target x86_64-linux-gnu -fsanitize=hwaddress 
-fsanitize-hwaddress-abi=platform %s -### 2>&1 | FileCheck %s 
--check-prefix=CHECK-HWASAN-PLATFORM-ABI
 // RUN: %clang -target x86_64-linux-gnu -fsanitize=hwaddress 
-fsanitize-hwaddress-abi=foo %s -### 2>&1 | FileCheck %s 
--check-prefix=CHECK-HWASAN-FOO-ABI
 // CHECK-HWASAN-INTERCEPTOR-ABI: "-default-function-attr" 
"hwasan-abi=interceptor"
-// CHECK-HWASAN-INTERCEPTOR-ABI: "-target-feature" "+tagged-globals"
 // CHECK-HWASAN-PLATFORM-ABI: "-default-function-attr" "hwasan-abi=platform"
-// CHECK-HWASAN-PLATFORM-ABI: "-target-feature" "+tagged-globals"
 // CHECK-HWASAN-FOO-ABI: error: invalid value 'foo' in 
'-fsanitize-hwaddress-abi=foo'
 
 // RUN: %clang -target x86_64-linux-gnu 
-fsanitize=address,pointer-compare,pointer-subtract %s -### 2>&1 | FileCheck %s 
--check-prefix=CHECK-POINTER-ALL



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


[PATCH] D82646: [MSP430] Align the _Complex ABI with current msp430-gcc

2020-07-08 Thread Anatoly Trosinenko via Phabricator via cfe-commits
atrosinenko updated this revision to Diff 276480.
atrosinenko added a comment.

Support int/long/long long `_Complex` types (GCC extension). According to 
msp430-gcc v9.2.0, they behave identically.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82646

Files:
  clang/lib/CodeGen/TargetInfo.cpp
  clang/test/CodeGen/msp430-abi-complex.c

Index: clang/test/CodeGen/msp430-abi-complex.c
===
--- /dev/null
+++ clang/test/CodeGen/msp430-abi-complex.c
@@ -0,0 +1,226 @@
+// REQUIRES: msp430-registered-target
+// RUN: %clang -target msp430 -Os -S -o- %s | FileCheck %s
+
+volatile int N;
+volatile int i16_1, i16_2;
+volatile long i32_1, i32_2;
+volatile long long i64_1, i64_2;
+volatile float f1, f2;
+volatile double d1, d2;
+
+_Static_assert(sizeof(int) == 2, "Assumption failed");
+_Static_assert(sizeof(long) == 4, "Assumption failed");
+_Static_assert(sizeof(long long) == 8, "Assumption failed");
+
+void complex_i16_arg_first(int _Complex x, int n) {
+// CHECK-LABEL: @complex_i16_arg_first
+  i16_1 = __real__ x;
+// CHECK-DAG: mov r12, _1
+  i16_2 = __imag__ x;
+// CHECK-DAG: mov r13, _2
+  N = n;
+// CHECK-DAG: mov r14, 
+// CHECK: ret
+}
+
+void complex_i16_arg_second(int n, int _Complex x) {
+// CHECK-LABEL: @complex_i16_arg_second
+  N = n;
+// CHECK-DAG: mov r12, 
+  i16_1 = __real__ x;
+// CHECK-DAG: mov r13, _1
+  i16_2 = __imag__ x;
+// CHECK-DAG: mov r14, _2
+// CHECK: ret
+}
+
+void complex_i32_arg_first(long _Complex x, int n) {
+// CHECK-LABEL: @complex_i32_arg_first
+  i32_1 = __real__ x;
+// CHECK-DAG: mov r12, _1
+// CHECK-DAG: mov r13, _1+2
+  i32_2 = __imag__ x;
+// CHECK-DAG: mov r14, _2
+// CHECK-DAG: mov r15, _2+2
+  N = n;
+// CHECK-DAG: mov 2(r1), 
+// CHECK: ret
+}
+
+void complex_i32_arg_second(int n, long _Complex x) {
+// CHECK-LABEL: @complex_i32_arg_second
+  N = n;
+// CHECK-DAG: mov r12, 
+  i32_1 = __real__ x;
+// CHECK-DAG: mov 2(r1), _1
+// CHECK-DAG: mov 4(r1), _1+2
+  i32_2 = __imag__ x;
+// CHECK-DAG: mov 6(r1), _2
+// CHECK-DAG: mov 8(r1), _2+2
+// CHECK: ret
+}
+
+void complex_i64_arg_first(long long _Complex x, int n) {
+// CHECK-LABEL: @complex_i64_arg_first
+  i64_1 = __real__ x;
+// CHECK-DAG: mov 2(r1), _1
+// CHECK-DAG: mov 4(r1), _1+2
+// CHECK-DAG: mov 6(r1), _1+4
+// CHECK-DAG: mov 8(r1), _1+6
+  i64_2 = __imag__ x;
+// CHECK-DAG: mov 10(r1), _2
+// CHECK-DAG: mov 12(r1), _2+2
+// CHECK-DAG: mov 14(r1), _2+4
+// CHECK-DAG: mov 16(r1), _2+6
+  N = n;
+// CHECK-DAG: mov r12, 
+// CHECK: ret
+}
+
+void complex_i64_arg_second(int n, long long _Complex x) {
+// CHECK-LABEL: @complex_i64_arg_second
+  N = n;
+// CHECK-DAG: mov r12, 
+  i64_1 = __real__ x;
+// CHECK-DAG: mov 2(r1), _1
+// CHECK-DAG: mov 4(r1), _1+2
+// CHECK-DAG: mov 6(r1), _1+4
+// CHECK-DAG: mov 8(r1), _1+6
+  i64_2 = __imag__ x;
+// CHECK-DAG: mov 10(r1), _2
+// CHECK-DAG: mov 12(r1), _2+2
+// CHECK-DAG: mov 14(r1), _2+4
+// CHECK-DAG: mov 16(r1), _2+6
+// CHECK: ret
+}
+
+void complex_float_arg_first(float _Complex x, int n) {
+// CHECK-LABEL: @complex_float_arg_first
+  f1 = __real__ x;
+// CHECK-DAG: mov r12, 
+// CHECK-DAG: mov r13, +2
+  f2 = __imag__ x;
+// CHECK-DAG: mov r14, 
+// CHECK-DAG: mov r15, +2
+  N = n;
+// CHECK-DAG: mov 2(r1), 
+// CHECK: ret
+}
+
+void complex_float_arg_second(int n, float _Complex x) {
+// CHECK-LABEL: @complex_float_arg_second
+  N = n;
+// CHECK-DAG: mov r12, 
+  f1 = __real__ x;
+// CHECK-DAG: mov 2(r1), 
+// CHECK-DAG: mov 4(r1), +2
+  f2 = __imag__ x;
+// CHECK-DAG: mov 6(r1), 
+// CHECK-DAG: mov 8(r1), +2
+// CHECK: ret
+}
+
+void complex_double_arg_first(double _Complex x, int n) {
+// CHECK-LABEL: @complex_double_arg_first
+  d1 = __real__ x;
+// CHECK-DAG: mov 2(r1), 
+// CHECK-DAG: mov 4(r1), +2
+// CHECK-DAG: mov 6(r1), +4
+// CHECK-DAG: mov 8(r1), +6
+  d2 = __imag__ x;
+// CHECK-DAG: mov 10(r1), 
+// CHECK-DAG: mov 12(r1), +2
+// CHECK-DAG: mov 14(r1), +4
+// CHECK-DAG: mov 16(r1), +6
+  N = n;
+// CHECK-DAG: mov r12, 
+// CHECK: ret
+}
+
+void complex_double_arg_second(int n, double _Complex x) {
+// CHECK-LABEL: @complex_double_arg_second
+  d1 = __real__ x;
+// CHECK-DAG: mov 2(r1), 
+// CHECK-DAG: mov 4(r1), +2
+// CHECK-DAG: mov 6(r1), +4
+// CHECK-DAG: mov 8(r1), +6
+  d2 = __imag__ x;
+// CHECK-DAG: mov 10(r1), 
+// CHECK-DAG: mov 12(r1), +2
+// CHECK-DAG: mov 14(r1), +4
+// CHECK-DAG: mov 16(r1), +6
+  N = n;
+// CHECK-DAG: mov r12, 
+// CHECK: ret
+}
+
+int _Complex complex_i16_res(void) {
+// CHECK-LABEL: @complex_i16_res
+  int _Complex res;
+  __real__ res = 0x1122;
+// CHECK-DAG: mov #4386, r12
+  __imag__ res = 0x3344;
+// CHECK-DAG: mov #13124, r13
+  return res;
+// CHECK: ret
+}
+
+long _Complex complex_i32_res(void) {
+// CHECK-LABEL: @complex_i32_res
+  long _Complex res;
+  __real__ res = 0x11223344;
+// CHECK-DAG: mov #13124, r12
+// CHECK-DAG: 

[PATCH] D82477: [lldb-vscode] Add Support for Module Event

2020-07-08 Thread Greg Clayton via Phabricator via cfe-commits
clayborg accepted this revision.
clayborg added a comment.
This revision is now accepted and ready to land.

Looks good!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82477



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


[PATCH] D78655: [CUDA][HIP] Let lambda be host device by default

2020-07-08 Thread Yaxun Liu via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
yaxunl marked an inline comment as done.
Closed by commit rG1eaad01046c8: [CUDA][HIP] Let lambda be host device by 
default (authored by yaxunl).
Herald added a project: clang.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D78655

Files:
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Sema/Sema.h
  clang/lib/Sema/SemaCUDA.cpp
  clang/lib/Sema/SemaLambda.cpp
  clang/test/CodeGenCUDA/lambda.cu
  clang/test/SemaCUDA/Inputs/cuda.h
  clang/test/SemaCUDA/lambda.cu

Index: clang/test/SemaCUDA/lambda.cu
===
--- /dev/null
+++ clang/test/SemaCUDA/lambda.cu
@@ -0,0 +1,73 @@
+// RUN: %clang_cc1 -std=c++17 -fsyntax-only -verify=com %s
+// RUN: %clang_cc1 -std=c++17 -fsyntax-only -fcuda-is-device -verify=com,dev %s
+
+#include "Inputs/cuda.h"
+
+auto global_lambda = [] () { return 123; };
+
+template
+__global__ void kernel(F f) { f(); }
+// dev-note@-1 7{{called by 'kernel<(lambda}}
+
+__host__ __device__ void hd(int x);
+
+class A {
+  int b;
+public:
+  void test() {
+[=](){ hd(b); }();
+
+[&](){ hd(b); }();
+
+kernel<<<1,1>>>([](){ hd(0); });
+
+kernel<<<1,1>>>([=](){ hd(b); });
+// dev-error@-1 {{capture host side class data member by this pointer in device or host device lambda function}}
+
+kernel<<<1,1>>>([&](){ hd(b); });
+// dev-error@-1 {{capture host side class data member by this pointer in device or host device lambda function}}
+
+kernel<<<1,1>>>([&] __device__ (){ hd(b); });
+// dev-error@-1 {{capture host side class data member by this pointer in device or host device lambda function}}
+
+kernel<<<1,1>>>([&](){
+  auto f = [&]{ hd(b); };
+  // dev-error@-1 {{capture host side class data member by this pointer in device or host device lambda function}}
+  f();
+});
+  }
+};
+
+int main(void) {
+  auto lambda_kernel = [&]__global__(){};
+  // com-error@-1 {{kernel function 'operator()' must be a free function or static member function}}
+
+  int b;
+  [&](){ hd(b); }();
+
+  [=, ](){ hd(b); }();
+
+  kernel<<<1,1>>>(global_lambda);
+
+  kernel<<<1,1>>>([](){ hd(0); });
+
+  kernel<<<1,1>>>([=](){ hd(b); });
+
+  kernel<<<1,1>>>([b](){ hd(b); });
+
+  kernel<<<1,1>>>([&](){ hd(b); });
+  // dev-error@-1 {{capture host variable 'b' by reference in device or host device lambda function}}
+
+  kernel<<<1,1>>>([=, ](){ hd(b); });
+  // dev-error@-1 {{capture host variable 'b' by reference in device or host device lambda function}}
+
+  kernel<<<1,1>>>([&, b](){ hd(b); });
+
+  kernel<<<1,1>>>([&](){
+  auto f = [&]{ hd(b); };
+  // dev-error@-1 {{capture host variable 'b' by reference in device or host device lambda function}}
+  f();
+  });
+
+  return 0;
+}
Index: clang/test/SemaCUDA/Inputs/cuda.h
===
--- clang/test/SemaCUDA/Inputs/cuda.h
+++ clang/test/SemaCUDA/Inputs/cuda.h
@@ -17,6 +17,19 @@
   __host__ __device__ dim3(unsigned x, unsigned y = 1, unsigned z = 1) : x(x), y(y), z(z) {}
 };
 
+#ifdef __HIP__
+typedef struct hipStream *hipStream_t;
+typedef enum hipError {} hipError_t;
+int hipConfigureCall(dim3 gridSize, dim3 blockSize, size_t sharedSize = 0,
+ hipStream_t stream = 0);
+extern "C" hipError_t __hipPushCallConfiguration(dim3 gridSize, dim3 blockSize,
+ size_t sharedSize = 0,
+ hipStream_t stream = 0);
+extern "C" hipError_t hipLaunchKernel(const void *func, dim3 gridDim,
+  dim3 blockDim, void **args,
+  size_t sharedMem,
+  hipStream_t stream);
+#else
 typedef struct cudaStream *cudaStream_t;
 typedef enum cudaError {} cudaError_t;
 
@@ -29,6 +42,7 @@
 extern "C" cudaError_t cudaLaunchKernel(const void *func, dim3 gridDim,
 dim3 blockDim, void **args,
 size_t sharedMem, cudaStream_t stream);
+#endif
 
 // Host- and device-side placement new overloads.
 void *operator new(__SIZE_TYPE__, void *p) { return p; }
Index: clang/test/CodeGenCUDA/lambda.cu
===
--- /dev/null
+++ clang/test/CodeGenCUDA/lambda.cu
@@ -0,0 +1,85 @@
+// RUN: %clang_cc1 -x hip -emit-llvm -std=c++11 %s -o - \
+// RUN:   -triple x86_64-linux-gnu \
+// RUN:   | FileCheck -check-prefix=HOST %s
+// RUN: %clang_cc1 -x hip -emit-llvm -std=c++11 %s -o - \
+// RUN:   -triple amdgcn-amd-amdhsa -fcuda-is-device \
+// RUN:   | FileCheck -check-prefix=DEV %s
+
+#include "Inputs/cuda.h"
+
+// Device side kernel name.
+// HOST: @[[KERN_CAPTURE:[0-9]+]] = {{.*}} c"_Z1gIZ12test_capturevEUlvE_EvT_\00"
+// 

[PATCH] D83374: [analyzer][tests] Fix zip unpacking

2020-07-08 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ accepted this revision.
NoQ added a comment.
This revision is now accepted and ready to land.

> I think that the problem is actually with the second '/'

I thought the OS always ignores those? Ok anyway fair enough!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83374



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


[clang] 1eaad01 - [CUDA][HIP] Let lambda be host device by default

2020-07-08 Thread Yaxun Liu via cfe-commits

Author: Yaxun (Sam) Liu
Date: 2020-07-08T13:10:26-04:00
New Revision: 1eaad01046c88be6bf65265a2bcc53db5a5b48d0

URL: 
https://github.com/llvm/llvm-project/commit/1eaad01046c88be6bf65265a2bcc53db5a5b48d0
DIFF: 
https://github.com/llvm/llvm-project/commit/1eaad01046c88be6bf65265a2bcc53db5a5b48d0.diff

LOG: [CUDA][HIP] Let lambda be host device by default

This patch let lambda be host device by default and adds diagnostics for
capturing host variable by reference in device lambda.

Differential Revision: https://reviews.llvm.org/D78655

Added: 
clang/test/CodeGenCUDA/lambda.cu
clang/test/SemaCUDA/lambda.cu

Modified: 
clang/include/clang/Basic/DiagnosticSemaKinds.td
clang/include/clang/Sema/Sema.h
clang/lib/Sema/SemaCUDA.cpp
clang/lib/Sema/SemaLambda.cpp
clang/test/SemaCUDA/Inputs/cuda.h

Removed: 




diff  --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td 
b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index e99fd3d1f105..c0d0acccb181 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -7999,6 +7999,10 @@ def err_ref_bad_target : Error<
 def err_ref_bad_target_global_initializer : Error<
   "reference to %select{__device__|__global__|__host__|__host__ __device__}0 "
   "function %1 in global initializer">;
+def err_capture_bad_target : Error<
+  "capture host variable %0 by reference in device or host device lambda 
function">;
+def err_capture_bad_target_this_ptr : Error<
+  "capture host side class data member by this pointer in device or host 
device lambda function">;
 def warn_kern_is_method : Extension<
   "kernel function %0 is a member function; this may not be accepted by nvcc">,
   InGroup;

diff  --git a/clang/include/clang/Sema/Sema.h b/clang/include/clang/Sema/Sema.h
index 8ee7dd74712d..a540d788f4d8 100644
--- a/clang/include/clang/Sema/Sema.h
+++ b/clang/include/clang/Sema/Sema.h
@@ -11828,12 +11828,13 @@ class Sema final {
   /// - Otherwise, returns true without emitting any diagnostics.
   bool CheckCUDACall(SourceLocation Loc, FunctionDecl *Callee);
 
+  void CUDACheckLambdaCapture(CXXMethodDecl *D, const sema::Capture );
+
   /// Set __device__ or __host__ __device__ attributes on the given lambda
   /// operator() method.
   ///
-  /// CUDA lambdas declared inside __device__ or __global__ functions inherit
-  /// the __device__ attribute.  Similarly, lambdas inside __host__ __device__
-  /// functions become __host__ __device__ themselves.
+  /// CUDA lambdas by default is host device function unless it has explicit
+  /// host or device attribute.
   void CUDASetLambdaAttrs(CXXMethodDecl *Method);
 
   /// Finds a function in \p Matches with highest calling priority

diff  --git a/clang/lib/Sema/SemaCUDA.cpp b/clang/lib/Sema/SemaCUDA.cpp
index f54d97a2a319..283a04683a32 100644
--- a/clang/lib/Sema/SemaCUDA.cpp
+++ b/clang/lib/Sema/SemaCUDA.cpp
@@ -17,6 +17,7 @@
 #include "clang/Basic/TargetInfo.h"
 #include "clang/Lex/Preprocessor.h"
 #include "clang/Sema/Lookup.h"
+#include "clang/Sema/ScopeInfo.h"
 #include "clang/Sema/Sema.h"
 #include "clang/Sema/SemaDiagnostic.h"
 #include "clang/Sema/SemaInternal.h"
@@ -746,20 +747,58 @@ bool Sema::CheckCUDACall(SourceLocation Loc, FunctionDecl 
*Callee) {
  DiagKind != DeviceDiagBuilder::K_ImmediateWithCallStack;
 }
 
+// Check the wrong-sided reference capture of lambda for CUDA/HIP.
+// A lambda function may capture a stack variable by reference when it is
+// defined and uses the capture by reference when the lambda is called. When
+// the capture and use happen on 
diff erent sides, the capture is invalid and
+// should be diagnosed.
+void Sema::CUDACheckLambdaCapture(CXXMethodDecl *Callee,
+  const sema::Capture ) {
+  // In host compilation we only need to check lambda functions emitted on host
+  // side. In such lambda functions, a reference capture is invalid only
+  // if the lambda structure is populated by a device function or kernel then
+  // is passed to and called by a host function. However that is impossible,
+  // since a device function or kernel can only call a device function, also a
+  // kernel cannot pass a lambda back to a host function since we cannot
+  // define a kernel argument type which can hold the lambda before the lambda
+  // itself is defined.
+  if (!LangOpts.CUDAIsDevice)
+return;
+
+  // File-scope lambda can only do init captures for global variables, which
+  // results in passing by value for these global variables.
+  FunctionDecl *Caller = dyn_cast(CurContext);
+  if (!Caller)
+return;
+
+  // In device compilation, we only need to check lambda functions which are
+  // emitted on device side. For such lambdas, a reference capture is invalid
+  // only if the lambda structure is populated by a host function then passed
+  // to and called in a device function or 

[PATCH] D83008: Fix ItaniumRecordLayoutBuilder so that is grabs the correct bases class offsets from the external source

2020-07-08 Thread Shafik Yaghmour via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG63b0f8c788d8: [RecordLayout] Fix ItaniumRecordLayoutBuilder 
so that is grabs the correct… (authored by shafik).
Herald added projects: clang, LLDB.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83008

Files:
  clang/lib/AST/RecordLayoutBuilder.cpp
  lldb/test/API/lang/cpp/alignas_base_class/Makefile
  lldb/test/API/lang/cpp/alignas_base_class/TestAlignAsBaseClass.py
  lldb/test/API/lang/cpp/alignas_base_class/main.cpp


Index: lldb/test/API/lang/cpp/alignas_base_class/main.cpp
===
--- /dev/null
+++ lldb/test/API/lang/cpp/alignas_base_class/main.cpp
@@ -0,0 +1,13 @@
+struct B1 {
+  char f1;
+};
+
+struct alignas(8) B2 {
+  char f2;
+};
+
+struct D : B1, B2 {};
+
+D d3g;
+
+int main() {}
Index: lldb/test/API/lang/cpp/alignas_base_class/TestAlignAsBaseClass.py
===
--- /dev/null
+++ lldb/test/API/lang/cpp/alignas_base_class/TestAlignAsBaseClass.py
@@ -0,0 +1,16 @@
+import lldb
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+
+class TestCase(TestBase):
+
+mydir = TestBase.compute_mydir(__file__)
+
+@no_debug_info_test
+def test(self):
+self.build()
+self.dbg.CreateTarget(self.getBuildArtifact("a.out"))
+
+# The offset of f2 should be 8 because of `alignas(8)`.
+self.expect_expr("(intptr_t) - (intptr_t)", 
result_value="8")
Index: lldb/test/API/lang/cpp/alignas_base_class/Makefile
===
--- /dev/null
+++ lldb/test/API/lang/cpp/alignas_base_class/Makefile
@@ -0,0 +1,3 @@
+CXX_SOURCES := main.cpp
+
+include Makefile.rules
Index: clang/lib/AST/RecordLayoutBuilder.cpp
===
--- clang/lib/AST/RecordLayoutBuilder.cpp
+++ clang/lib/AST/RecordLayoutBuilder.cpp
@@ -1187,11 +1187,10 @@
   // Query the external layout to see if it provides an offset.
   bool HasExternalLayout = false;
   if (UseExternalLayout) {
-// FIXME: This appears to be reversed.
 if (Base->IsVirtual)
-  HasExternalLayout = External.getExternalNVBaseOffset(Base->Class, 
Offset);
-else
   HasExternalLayout = External.getExternalVBaseOffset(Base->Class, Offset);
+else
+  HasExternalLayout = External.getExternalNVBaseOffset(Base->Class, 
Offset);
   }
 
   // Clang <= 6 incorrectly applied the 'packed' attribute to base classes.


Index: lldb/test/API/lang/cpp/alignas_base_class/main.cpp
===
--- /dev/null
+++ lldb/test/API/lang/cpp/alignas_base_class/main.cpp
@@ -0,0 +1,13 @@
+struct B1 {
+  char f1;
+};
+
+struct alignas(8) B2 {
+  char f2;
+};
+
+struct D : B1, B2 {};
+
+D d3g;
+
+int main() {}
Index: lldb/test/API/lang/cpp/alignas_base_class/TestAlignAsBaseClass.py
===
--- /dev/null
+++ lldb/test/API/lang/cpp/alignas_base_class/TestAlignAsBaseClass.py
@@ -0,0 +1,16 @@
+import lldb
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+
+class TestCase(TestBase):
+
+mydir = TestBase.compute_mydir(__file__)
+
+@no_debug_info_test
+def test(self):
+self.build()
+self.dbg.CreateTarget(self.getBuildArtifact("a.out"))
+
+# The offset of f2 should be 8 because of `alignas(8)`.
+self.expect_expr("(intptr_t) - (intptr_t)", result_value="8")
Index: lldb/test/API/lang/cpp/alignas_base_class/Makefile
===
--- /dev/null
+++ lldb/test/API/lang/cpp/alignas_base_class/Makefile
@@ -0,0 +1,3 @@
+CXX_SOURCES := main.cpp
+
+include Makefile.rules
Index: clang/lib/AST/RecordLayoutBuilder.cpp
===
--- clang/lib/AST/RecordLayoutBuilder.cpp
+++ clang/lib/AST/RecordLayoutBuilder.cpp
@@ -1187,11 +1187,10 @@
   // Query the external layout to see if it provides an offset.
   bool HasExternalLayout = false;
   if (UseExternalLayout) {
-// FIXME: This appears to be reversed.
 if (Base->IsVirtual)
-  HasExternalLayout = External.getExternalNVBaseOffset(Base->Class, Offset);
-else
   HasExternalLayout = External.getExternalVBaseOffset(Base->Class, Offset);
+else
+  HasExternalLayout = External.getExternalNVBaseOffset(Base->Class, Offset);
   }
 
   // Clang <= 6 incorrectly applied the 'packed' attribute to base classes.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 63b0f8c - [RecordLayout] Fix ItaniumRecordLayoutBuilder so that is grabs the correct bases class offsets from the external source

2020-07-08 Thread via cfe-commits

Author: shafik
Date: 2020-07-08T10:07:15-07:00
New Revision: 63b0f8c788d8c6978feb099fd6db8fe219c4d166

URL: 
https://github.com/llvm/llvm-project/commit/63b0f8c788d8c6978feb099fd6db8fe219c4d166
DIFF: 
https://github.com/llvm/llvm-project/commit/63b0f8c788d8c6978feb099fd6db8fe219c4d166.diff

LOG: [RecordLayout] Fix ItaniumRecordLayoutBuilder so that is grabs the correct 
bases class offsets from the external source

Currently the ItaniumRecordLayoutBuilder when laying out base classes has the 
virtual
and non-virtual bases mixed up when pulling the base class layouts from the 
external source.

This came up in an LLDB bug where on arm64 because of differences in how it 
deals with
tail padding would layout the bases differently without the correct layout from 
the
external source (LLDB). This would result in some fields being off by 4 bytes.

Differential Revision: https://reviews.llvm.org/D83008

Added: 
lldb/test/API/lang/cpp/alignas_base_class/Makefile
lldb/test/API/lang/cpp/alignas_base_class/TestAlignAsBaseClass.py
lldb/test/API/lang/cpp/alignas_base_class/main.cpp

Modified: 
clang/lib/AST/RecordLayoutBuilder.cpp

Removed: 




diff  --git a/clang/lib/AST/RecordLayoutBuilder.cpp 
b/clang/lib/AST/RecordLayoutBuilder.cpp
index b44957a35279..d56c7e2ab8c0 100644
--- a/clang/lib/AST/RecordLayoutBuilder.cpp
+++ b/clang/lib/AST/RecordLayoutBuilder.cpp
@@ -1187,11 +1187,10 @@ ItaniumRecordLayoutBuilder::LayoutBase(const 
BaseSubobjectInfo *Base) {
   // Query the external layout to see if it provides an offset.
   bool HasExternalLayout = false;
   if (UseExternalLayout) {
-// FIXME: This appears to be reversed.
 if (Base->IsVirtual)
-  HasExternalLayout = External.getExternalNVBaseOffset(Base->Class, 
Offset);
-else
   HasExternalLayout = External.getExternalVBaseOffset(Base->Class, Offset);
+else
+  HasExternalLayout = External.getExternalNVBaseOffset(Base->Class, 
Offset);
   }
 
   // Clang <= 6 incorrectly applied the 'packed' attribute to base classes.

diff  --git a/lldb/test/API/lang/cpp/alignas_base_class/Makefile 
b/lldb/test/API/lang/cpp/alignas_base_class/Makefile
new file mode 100644
index ..8b20bcb0
--- /dev/null
+++ b/lldb/test/API/lang/cpp/alignas_base_class/Makefile
@@ -0,0 +1,3 @@
+CXX_SOURCES := main.cpp
+
+include Makefile.rules

diff  --git a/lldb/test/API/lang/cpp/alignas_base_class/TestAlignAsBaseClass.py 
b/lldb/test/API/lang/cpp/alignas_base_class/TestAlignAsBaseClass.py
new file mode 100644
index ..25f37ab7fe5f
--- /dev/null
+++ b/lldb/test/API/lang/cpp/alignas_base_class/TestAlignAsBaseClass.py
@@ -0,0 +1,16 @@
+import lldb
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+
+class TestCase(TestBase):
+
+mydir = TestBase.compute_mydir(__file__)
+
+@no_debug_info_test
+def test(self):
+self.build()
+self.dbg.CreateTarget(self.getBuildArtifact("a.out"))
+
+# The offset of f2 should be 8 because of `alignas(8)`.
+self.expect_expr("(intptr_t) - (intptr_t)", 
result_value="8")

diff  --git a/lldb/test/API/lang/cpp/alignas_base_class/main.cpp 
b/lldb/test/API/lang/cpp/alignas_base_class/main.cpp
new file mode 100644
index ..8dfced6c784e
--- /dev/null
+++ b/lldb/test/API/lang/cpp/alignas_base_class/main.cpp
@@ -0,0 +1,13 @@
+struct B1 {
+  char f1;
+};
+
+struct alignas(8) B2 {
+  char f2;
+};
+
+struct D : B1, B2 {};
+
+D d3g;
+
+int main() {}



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


[PATCH] D83407: [analyzer][StdLibraryFunctionsChecker] Add POSIX networking functions

2020-07-08 Thread Gabor Marton via Phabricator via cfe-commits
martong marked an inline comment as done.
martong added inline comments.



Comment at: clang/test/Analysis/std-c-library-functions-POSIX.c:200
+#define __SOCKADDR_ONETYPE(type) struct type *__restrict __##type##__;
+#define __SOCKADDR_ONETYPE(type) struct type *__restrict __##type##__;
+typedef union {

Remove redundant duplicated line.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83407



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


[PATCH] D83407: [analyzer][StdLibraryFunctionsChecker] Add POSIX networking functions

2020-07-08 Thread Gabor Marton via Phabricator via cfe-commits
martong created this revision.
martong added reviewers: gamesh411, Szelethus, NoQ.
Herald added subscribers: cfe-commits, ASDenysPetrov, steakhal, Charusso, 
dkrupp, donat.nagy, mikhail.ramalho, a.sidorin, rnkovacs, szepet, 
baloghadamsoftware, xazax.hun, whisperity.
Herald added a project: clang.

Adding networking functions from the POSIX standard (2017). This includes
functions that deal with sockets from socket.h, netdb.h.

In 'socket.h' of some libc implementations (e.g. glibc) with C99, sockaddr
parameter is a transparent union of the underlying sockaddr_ family of pointers
instead of being a pointer to struct sockaddr. In these cases, the standardized
signature will not match, thus we try to match with another signature that has
the joker Irrelevant type. In the case of transparent unions, we also not add
those constraints which require pointer types for the sockaddr param.

Interestingly, in 'netdb.h' sockaddr is not handled as a transparent union.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D83407

Files:
  clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
  clang/test/Analysis/std-c-library-functions-POSIX-socket-sockaddr.cpp
  clang/test/Analysis/std-c-library-functions-POSIX.c

Index: clang/test/Analysis/std-c-library-functions-POSIX.c
===
--- clang/test/Analysis/std-c-library-functions-POSIX.c
+++ clang/test/Analysis/std-c-library-functions-POSIX.c
@@ -79,6 +79,22 @@
 // CHECK: Loaded summary for: int execv(const char *path, char *const argv[])
 // CHECK: Loaded summary for: int execvp(const char *file, char *const argv[])
 // CHECK: Loaded summary for: int getopt(int argc, char *const argv[], const char *optstring)
+// CHECK: Loaded summary for: int accept(int socket, __SOCKADDR_ARG address, socklen_t *restrict address_len)
+// CHECK: Loaded summary for: int bind(int socket, __CONST_SOCKADDR_ARG address, socklen_t address_len)
+// CHECK: Loaded summary for: int getpeername(int socket, __SOCKADDR_ARG address, socklen_t *restrict address_len)
+// CHECK: Loaded summary for: int getsockname(int socket, __SOCKADDR_ARG address, socklen_t *restrict address_len)
+// CHECK: Loaded summary for: int connect(int socket, __CONST_SOCKADDR_ARG address, socklen_t address_len)
+// CHECK: Loaded summary for: ssize_t recvfrom(int socket, void *restrict buffer, size_t length, int flags, __SOCKADDR_ARG address, socklen_t *restrict address_len)
+// CHECK: Loaded summary for: ssize_t sendto(int socket, const void *message, size_t length, int flags, __CONST_SOCKADDR_ARG dest_addr, socklen_t dest_len)
+// CHECK: Loaded summary for: int listen(int sockfd, int backlog)
+// CHECK: Loaded summary for: ssize_t recv(int sockfd, void *buf, size_t len, int flags)
+// CHECK: Loaded summary for: ssize_t recvmsg(int sockfd, struct msghdr *msg, int flags)
+// CHECK: Loaded summary for: ssize_t sendmsg(int sockfd, const struct msghdr *msg, int flags)
+// CHECK: Loaded summary for: int setsockopt(int socket, int level, int option_name, const void *option_value, socklen_t option_len)
+// CHECK: Loaded summary for: int getsockopt(int socket, int level, int option_name, void *restrict option_value, socklen_t *restrict option_len)
+// CHECK: Loaded summary for: ssize_t send(int sockfd, const void *buf, size_t len, int flags)
+// CHECK: Loaded summary for: int socketpair(int domain, int type, int protocol, int sv[2])
+// CHECK: Loaded summary for: int getnameinfo(const struct sockaddr *restrict sa, socklen_t salen, char *restrict node, socklen_t nodelen, char *restrict service, socklen_t servicelen, int flags)
 
 long a64l(const char *str64);
 char *l64a(long value);
@@ -171,6 +187,47 @@
 int execvp(const char *file, char *const argv[]);
 int getopt(int argc, char *const argv[], const char *optstring);
 
+// In some libc implementations, sockaddr parameter is a transparent
+// union of the underlying sockaddr_ pointers instead of being a
+// pointer to struct sockaddr.
+// We match that with the joker Irrelevant type.
+struct sockaddr;
+struct sockaddr_at;
+#define __SOCKADDR_ALLTYPES\
+  __SOCKADDR_ONETYPE(sockaddr) \
+  __SOCKADDR_ONETYPE(sockaddr_at)
+#define __SOCKADDR_ONETYPE(type) struct type *__restrict __##type##__;
+#define __SOCKADDR_ONETYPE(type) struct type *__restrict __##type##__;
+typedef union {
+  __SOCKADDR_ALLTYPES
+} __SOCKADDR_ARG __attribute__((__transparent_union__));
+#undef __SOCKADDR_ONETYPE
+#define __SOCKADDR_ONETYPE(type) const struct type *__restrict __##type##__;
+typedef union {
+  __SOCKADDR_ALLTYPES
+} __CONST_SOCKADDR_ARG __attribute__((__transparent_union__));
+#undef __SOCKADDR_ONETYPE
+typedef unsigned socklen_t;
+
+int accept(int socket, __SOCKADDR_ARG address, socklen_t *restrict address_len);
+int bind(int socket, __CONST_SOCKADDR_ARG address, socklen_t address_len);
+int getpeername(int socket, __SOCKADDR_ARG address, socklen_t *restrict address_len);
+int getsockname(int socket, 

[PATCH] D83079: [clang][aarch64] Generate preprocessor macros for -march=armv8.6a+sve.

2020-07-08 Thread Sander de Smalen via Phabricator via cfe-commits
sdesmalen added inline comments.



Comment at: clang/lib/Driver/ToolChains/Arch/AArch64.cpp:369
+  if (llvm::is_contained(Features, "+v8.6a")) {
+if (!llvm::is_contained(Features, "-i8mm") &&
+!llvm::is_contained(Features, "+noi8mm"))

fpetrogalli wrote:
> sdesmalen wrote:
> > Is this correct and/or necessary? I would expect LLVM to just handle 
> > features in the order they're passed, and the architecture version is 
> > always processed first, e.g. `-march=armv8.6-a+noi8mm` will always first 
> > process `armv8.6a` before processing features like `noi8mm`.
> I was expecting that too, but in in this place the `+i8mm` is added after 
> whatever the user have passed to -march, which means that without this extra 
> check the user input `-mattr=armv8.6a+sve+noimm8` becomes broken because we 
> are adding `-target-feature=+i8mm` after `-i8mm`.  This behavior is guarded 
> by a regression tests that starts failing if I don't use these extra checks. 
> This was not needed in the original place were I added the functionality 
> because the `+i8mm` was being added right after `+v8.6a` and before splitting 
> up the `+sve+noi8mm`, so that the user input was the one (un)setting the 
> feature.
As you said, we end up with a Feature list as follows:

  parsing(-march=armv8.6-a+noi8mm)
  => Features = [ v8.6a ]

  parsing(+noi8mm)
  => Features = [ v8.6a, -i8mm ]

  Then going through the feature list again:
  => Features = [ v8.6a, -i8mm, +i8mm ]
  ^  
\_/
   adds +i8mm

To fix that, you can insert these features into the list straight after 
"+v8.6a", instead of appending at the end of the Features list. Either that, or 
calling `llvm::AArch64::getDefaultExtensions() + 
llvm::AArch64::getExtensionFeatures()` in `getAArch64ArchFeaturesFromMarch` 
like is done in `DecodeAArch64Mcpu`, which should do all this for free. That 
seems like a more invasive change though that you shouldn't try to do in this 
patch.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83079



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


[PATCH] D83406: Remove NormalizerRetTy and use the decltype of the KeyPath instead

2020-07-08 Thread Daniel Grumberg via Phabricator via cfe-commits
dang created this revision.
dang added a reviewer: Bigcheese.
Herald added subscribers: llvm-commits, cfe-commits, dexonsmith.
Herald added projects: clang, LLVM.

Depends on D83315 


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D83406

Files:
  clang/include/clang/Driver/Options.td
  clang/lib/Frontend/CompilerInvocation.cpp
  llvm/include/llvm/Option/OptParser.td
  llvm/utils/TableGen/OptParserEmitter.cpp

Index: llvm/utils/TableGen/OptParserEmitter.cpp
===
--- llvm/utils/TableGen/OptParserEmitter.cpp
+++ llvm/utils/TableGen/OptParserEmitter.cpp
@@ -69,7 +69,6 @@
   StringRef KeyPath;
   StringRef DefaultValue;
   StringRef NormalizedValuesScope;
-  StringRef NormalizerRetTy;
   StringRef Normalizer;
   StringRef Denormalizer;
   StringRef ValueMerger;
@@ -112,8 +111,6 @@
 OS << ", ";
 emitScopedNormalizedValue(OS, DefaultValue);
 OS << ", ";
-OS << NormalizerRetTy;
-OS << ", ";
 OS << Normalizer;
 OS << ", ";
 OS << Denormalizer;
@@ -172,9 +169,9 @@
 static MarshallingInfo::Ptr createMarshallingInfo(const Record ) {
   assert(!isa(R.getValueInit("KeyPath")) &&
  !isa(R.getValueInit("DefaultValue")) &&
- !isa(R.getValueInit("NormalizerRetTy")) &&
  !isa(R.getValueInit("ValueMerger")) &&
- "MarshallingInfo must have a type");
+ "MarshallingInfo must have a provide a keypath, default value and a "
+ "value merger");
 
   MarshallingInfo::Ptr Ret;
   if (Record *MaybeNegOption = R.getValueAsOptionalDef("NegOption")) {
@@ -187,7 +184,6 @@
   Ret->KeyPath = R.getValueAsString("KeyPath");
   Ret->DefaultValue = R.getValueAsString("DefaultValue");
   Ret->NormalizedValuesScope = R.getValueAsString("NormalizedValuesScope");
-  Ret->NormalizerRetTy = R.getValueAsString("NormalizerRetTy");
 
   Ret->Normalizer = R.getValueAsString("Normalizer");
   Ret->Denormalizer = R.getValueAsString("Denormalizer");
Index: llvm/include/llvm/Option/OptParser.td
===
--- llvm/include/llvm/Option/OptParser.td
+++ llvm/include/llvm/Option/OptParser.td
@@ -151,19 +151,16 @@
   code DefaultValue = defaultvalue;
 }
 
-class MarshallingInfoString
-  : MarshallingInfo {
-  code NormalizerRetTy = normalizerretty;
-}
+class MarshallingInfoString
+  : MarshallingInfo {}
 
-class MarshallingInfoFlag
+class MarshallingInfoFlag
   : MarshallingInfo {
-  code NormalizerRetTy = ty;
   code Normalizer = "normalizeSimpleFlag";
   code Denormalizer = "denormalizeSimpleFlag";
 }
 
-class MarshallingInfoBitfieldFlag : MarshallingInfoFlag {
+class MarshallingInfoBitfieldFlag : MarshallingInfoFlag {
   code Normalizer = "(normalizeFlagToValue)";
   code ValueMerger = "mergeMaskValue";
   code ValueExtractor = "(extractMaskValue)";
Index: clang/lib/Frontend/CompilerInvocation.cpp
===
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -260,7 +260,7 @@
 
 template 
 static T mergeForwardValue(T KeyPath, U Value) {
-  return static_cast(Value);
+  return Value;
 }
 
 template  static T mergeMaskValue(T KeyPath, U Value) {
@@ -3662,10 +3662,11 @@
 #define OPTION_WITH_MARSHALLING(   \
 PREFIX_TYPE, NAME, ID, KIND, GROUP, ALIAS, ALIASARGS, FLAGS, PARAM,\
 HELPTEXT, METAVAR, VALUES, SPELLING, ALWAYS_EMIT, KEYPATH, DEFAULT_VALUE,  \
-TYPE, NORMALIZER, DENORMALIZER, MERGER, EXTRACTOR, TABLE_INDEX)\
+NORMALIZER, DENORMALIZER, MERGER, EXTRACTOR, TABLE_INDEX)  \
   {\
 if (auto MaybeValue = NORMALIZER(OPT_##ID, TABLE_INDEX, Args, Diags))  \
-  this->KEYPATH = MERGER(this->KEYPATH, static_cast(*MaybeValue));   \
+  this->KEYPATH = MERGER(  \
+  this->KEYPATH, static_castKEYPATH)>(*MaybeValue));   \
 else   \
   this->KEYPATH = MERGER(this->KEYPATH, DEFAULT_VALUE);\
   }
@@ -3673,12 +3674,13 @@
 #define OPTION_WITH_MARSHALLING_BOOLEAN(   \
 PREFIX_TYPE, NAME, ID, KIND, GROUP, ALIAS, ALIASARGS, FLAGS, PARAM,\
 HELPTEXT, METAVAR, VALUES, SPELLING, ALWAYS_EMIT, KEYPATH, DEFAULT_VALUE,  \
-TYPE, NORMALIZER, DENORMALIZER, MERGER, EXTRACTOR, TABLE_INDEX, NEG_ID,\
+NORMALIZER, DENORMALIZER, MERGER, EXTRACTOR, TABLE_INDEX, NEG_ID,  \
 NEG_SPELLING)  \
   {\
 if (auto MaybeValue =  \
 

[PATCH] D83374: [analyzer][tests] Fix zip unpacking

2020-07-08 Thread Valeriy Savchenko via Phabricator via cfe-commits
vsavchenko added a comment.

I think that the problem is actually with the second '/', but I decided to 
retreat back to the form consistent to the rest `glob.glob` invocations in this 
file


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83374



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


[PATCH] D83211: Factor out call to EXTRACTOR in generateCC1CommandLine

2020-07-08 Thread Daniel Grumberg via Phabricator via cfe-commits
dang updated this revision to Diff 276466.
dang added a comment.

Rebase on top of latest changes


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83211

Files:
  clang/lib/Frontend/CompilerInvocation.cpp


Index: clang/lib/Frontend/CompilerInvocation.cpp
===
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -3934,9 +3934,10 @@
 PREFIX_TYPE, NAME, ID, KIND, GROUP, ALIAS, ALIASARGS, FLAGS, PARAM,
\
 HELPTEXT, METAVAR, VALUES, SPELLING, ALWAYS_EMIT, KEYPATH, DEFAULT_VALUE,  
\
 TYPE, NORMALIZER, DENORMALIZER, MERGER, EXTRACTOR, TABLE_INDEX)
\
-  if (((FLAGS)::CC1Option) &&  
\
-  (ALWAYS_EMIT || EXTRACTOR(this->KEYPATH) != DEFAULT_VALUE)) {
\
-DENORMALIZER(Args, SPELLING, SA, TABLE_INDEX, EXTRACTOR(this->KEYPATH));   
\
+  if ((FLAGS)::CC1Option) {
\
+const auto  = EXTRACTOR(this->KEYPATH);  
\
+if (ALWAYS_EMIT || Extracted != DEFAULT_VALUE) 
\
+  DENORMALIZER(Args, SPELLING, SA, TABLE_INDEX, Extracted);
\
   }
 
 #define OPTION_WITH_MARSHALLING_BOOLEAN(   
\
@@ -3944,10 +3945,10 @@
 HELPTEXT, METAVAR, VALUES, SPELLING, ALWAYS_EMIT, KEYPATH, DEFAULT_VALUE,  
\
 TYPE, NORMALIZER, DENORMALIZER, MERGER, EXTRACTOR, TABLE_INDEX, NEG_ID,
\
 NEG_SPELLING)  
\
-  if (((FLAGS)::CC1Option) &&  
\
-  (ALWAYS_EMIT || EXTRACTOR(this->KEYPATH) != DEFAULT_VALUE)) {
\
-DENORMALIZER(Args, SPELLING, NEG_SPELLING, SA, TABLE_INDEX,
\
- EXTRACTOR(this->KEYPATH));
\
+  if ((FLAGS)::CC1Option) {
\
+const auto  = EXTRACTOR(this->KEYPATH);  
\
+if (ALWAYS_EMIT || Extracted != DEFAULT_VALUE) 
\
+  DENORMALIZER(Args, SPELLING, NEG_SPELLING, SA, TABLE_INDEX, Extracted);  
\
   }
 
 #include "clang/Driver/Options.inc"


Index: clang/lib/Frontend/CompilerInvocation.cpp
===
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -3934,9 +3934,10 @@
 PREFIX_TYPE, NAME, ID, KIND, GROUP, ALIAS, ALIASARGS, FLAGS, PARAM,\
 HELPTEXT, METAVAR, VALUES, SPELLING, ALWAYS_EMIT, KEYPATH, DEFAULT_VALUE,  \
 TYPE, NORMALIZER, DENORMALIZER, MERGER, EXTRACTOR, TABLE_INDEX)\
-  if (((FLAGS)::CC1Option) &&  \
-  (ALWAYS_EMIT || EXTRACTOR(this->KEYPATH) != DEFAULT_VALUE)) {\
-DENORMALIZER(Args, SPELLING, SA, TABLE_INDEX, EXTRACTOR(this->KEYPATH));   \
+  if ((FLAGS)::CC1Option) {\
+const auto  = EXTRACTOR(this->KEYPATH);  \
+if (ALWAYS_EMIT || Extracted != DEFAULT_VALUE) \
+  DENORMALIZER(Args, SPELLING, SA, TABLE_INDEX, Extracted);\
   }
 
 #define OPTION_WITH_MARSHALLING_BOOLEAN(   \
@@ -3944,10 +3945,10 @@
 HELPTEXT, METAVAR, VALUES, SPELLING, ALWAYS_EMIT, KEYPATH, DEFAULT_VALUE,  \
 TYPE, NORMALIZER, DENORMALIZER, MERGER, EXTRACTOR, TABLE_INDEX, NEG_ID,\
 NEG_SPELLING)  \
-  if (((FLAGS)::CC1Option) &&  \
-  (ALWAYS_EMIT || EXTRACTOR(this->KEYPATH) != DEFAULT_VALUE)) {\
-DENORMALIZER(Args, SPELLING, NEG_SPELLING, SA, TABLE_INDEX,\
- EXTRACTOR(this->KEYPATH));\
+  if ((FLAGS)::CC1Option) {\
+const auto  = EXTRACTOR(this->KEYPATH);  \
+if (ALWAYS_EMIT || Extracted != DEFAULT_VALUE) \
+  DENORMALIZER(Args, SPELLING, NEG_SPELLING, SA, TABLE_INDEX, Extracted);  \
   }
 
 #include "clang/Driver/Options.inc"
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D83405: Factor out EXTRACTOR call

2020-07-08 Thread Daniel Grumberg via Phabricator via cfe-commits
dang created this revision.
Herald added subscribers: cfe-commits, dexonsmith.
Herald added a project: clang.

Depends on D83071 


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D83405

Files:
  clang/lib/Frontend/CompilerInvocation.cpp


Index: clang/lib/Frontend/CompilerInvocation.cpp
===
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -3934,9 +3934,10 @@
 PREFIX_TYPE, NAME, ID, KIND, GROUP, ALIAS, ALIASARGS, FLAGS, PARAM,
\
 HELPTEXT, METAVAR, VALUES, SPELLING, ALWAYS_EMIT, KEYPATH, DEFAULT_VALUE,  
\
 TYPE, NORMALIZER, DENORMALIZER, MERGER, EXTRACTOR, TABLE_INDEX)
\
-  if (((FLAGS)::CC1Option) &&  
\
-  (ALWAYS_EMIT || EXTRACTOR(this->KEYPATH) != DEFAULT_VALUE)) {
\
-DENORMALIZER(Args, SPELLING, SA, TABLE_INDEX, EXTRACTOR(this->KEYPATH));   
\
+  if ((FLAGS)::CC1Option) {
\
+const auto  = EXTRACTOR(this->KEYPATH);  
\
+if (ALWAYS_EMIT || Extracted != DEFAULT_VALUE) 
\
+  DENORMALIZER(Args, SPELLING, SA, TABLE_INDEX, Extracted);
\
   }
 
 #define OPTION_WITH_MARSHALLING_BOOLEAN(   
\
@@ -3944,10 +3945,10 @@
 HELPTEXT, METAVAR, VALUES, SPELLING, ALWAYS_EMIT, KEYPATH, DEFAULT_VALUE,  
\
 TYPE, NORMALIZER, DENORMALIZER, MERGER, EXTRACTOR, TABLE_INDEX, NEG_ID,
\
 NEG_SPELLING)  
\
-  if (((FLAGS)::CC1Option) &&  
\
-  (ALWAYS_EMIT || EXTRACTOR(this->KEYPATH) != DEFAULT_VALUE)) {
\
-DENORMALIZER(Args, SPELLING, NEG_SPELLING, SA, TABLE_INDEX,
\
- EXTRACTOR(this->KEYPATH));
\
+  if ((FLAGS)::CC1Option) {
\
+const auto  = EXTRACTOR(this->KEYPATH);  
\
+if (ALWAYS_EMIT || Extracted != DEFAULT_VALUE) 
\
+  DENORMALIZER(Args, SPELLING, NEG_SPELLING, SA, TABLE_INDEX, Extracted);  
\
   }
 
 #include "clang/Driver/Options.inc"


Index: clang/lib/Frontend/CompilerInvocation.cpp
===
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -3934,9 +3934,10 @@
 PREFIX_TYPE, NAME, ID, KIND, GROUP, ALIAS, ALIASARGS, FLAGS, PARAM,\
 HELPTEXT, METAVAR, VALUES, SPELLING, ALWAYS_EMIT, KEYPATH, DEFAULT_VALUE,  \
 TYPE, NORMALIZER, DENORMALIZER, MERGER, EXTRACTOR, TABLE_INDEX)\
-  if (((FLAGS)::CC1Option) &&  \
-  (ALWAYS_EMIT || EXTRACTOR(this->KEYPATH) != DEFAULT_VALUE)) {\
-DENORMALIZER(Args, SPELLING, SA, TABLE_INDEX, EXTRACTOR(this->KEYPATH));   \
+  if ((FLAGS)::CC1Option) {\
+const auto  = EXTRACTOR(this->KEYPATH);  \
+if (ALWAYS_EMIT || Extracted != DEFAULT_VALUE) \
+  DENORMALIZER(Args, SPELLING, SA, TABLE_INDEX, Extracted);\
   }
 
 #define OPTION_WITH_MARSHALLING_BOOLEAN(   \
@@ -3944,10 +3945,10 @@
 HELPTEXT, METAVAR, VALUES, SPELLING, ALWAYS_EMIT, KEYPATH, DEFAULT_VALUE,  \
 TYPE, NORMALIZER, DENORMALIZER, MERGER, EXTRACTOR, TABLE_INDEX, NEG_ID,\
 NEG_SPELLING)  \
-  if (((FLAGS)::CC1Option) &&  \
-  (ALWAYS_EMIT || EXTRACTOR(this->KEYPATH) != DEFAULT_VALUE)) {\
-DENORMALIZER(Args, SPELLING, NEG_SPELLING, SA, TABLE_INDEX,\
- EXTRACTOR(this->KEYPATH));\
+  if ((FLAGS)::CC1Option) {\
+const auto  = EXTRACTOR(this->KEYPATH);  \
+if (ALWAYS_EMIT || Extracted != DEFAULT_VALUE) \
+  DENORMALIZER(Args, SPELLING, NEG_SPELLING, SA, TABLE_INDEX, Extracted);  \
   }
 
 #include "clang/Driver/Options.inc"
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D83374: [analyzer][tests] Fix zip unpacking

2020-07-08 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added a comment.

For my own education, what was wrong with `join`?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83374



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


[PATCH] D82381: [analyzer] Introduce small improvements to the solver infra

2020-07-08 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ accepted this revision.
NoQ added inline comments.



Comment at: clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp:734
   //expressions which we currently do not know how to negate.
-  const RangeSet *getRangeForMinusSymbol(ProgramStateRef State, SymbolRef Sym) 
{
+  Optional getRangeForInvertedSub(SymbolRef Sym) {
 if (const SymSymExpr *SSE = dyn_cast(Sym)) {

vsavchenko wrote:
> ASDenysPetrov wrote:
> > vsavchenko wrote:
> > > ASDenysPetrov wrote:
> > > > As for me, I'd call this like `getRangeForNegatedSymSymExpr`, since you 
> > > > do Negate operation inside.
> > > I'm not super happy about my name either, but I feel like it describes it 
> > > better than the previous name and your version.  That function doesn't 
> > > work for any `SymSymExpr` and it doesn't simply negate whatever we gave 
> > > it.  It works specifically for symbolic subtractions and this is the 
> > > information I want to be reflected in the name.
> > Oh, I just assumed //...Sub// at the end as a //subexpression// but you 
> > mean //subtraction//. What I'm trying to say is that we can rename it like 
> > `getRangeFor...`//the expression which this function can handle//. E.g. 
> > `getRangeForNegatedSubtractionSymSymExpr`. My point is in a speaking name.
> > 
> > I think //invertion// is not something appropriate in terms of applying 
> > minus operator. I think invertion of zero should be something opposite but 
> > not a zero. Because when you would like to implement the function which 
> > turns [A, B] into [MIN, A)U(B, MAX], what would be the name of it? I think 
> > this is an //invertion//.
> > 
> > But this is not a big deal, it's just my thoughts.
> My thought process here was that we are trying to get range for `A - B` and 
> there is also information on `B - A`, so we can get something for `A - B` 
> based on that.  So, it doesn't really matter what it does under the hood with 
> ranges, it matters what its semantics are.  Here I called `B - A` //an 
> inverted subtraction//.
> I don't really know what would be the best name, but I thought that this one 
> makes more sense.
> Because when you would like to implement the function which turns [A, B] into 
> [MIN, A)U(B, MAX], what would be the name of it? I think this is an 
> //invertion//.

https://en.wikipedia.org/wiki/Complement_(set_theory)
https://en.wikipedia.org/wiki/Inverse_function

"Negated subtraction" is definitely my favorite so far. "Mirrored" might be a 
good layman term as well.



Comment at: clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp:467-470
+/// Available representations for the arguments are:
+///   * RangeSet
+///   * Optional
+///   * RangeSet *

vsavchenko wrote:
> xazax.hun wrote:
> > NoQ wrote:
> > > Why do we have these representations in the first place?
> > > 
> > > It sounds like you're treating null pointers / empty optionals 
> > > equivalently to full ranges (i.e., intersecting with them has no effect). 
> > > How hard would it be to simply construct an actual full range in all the 
> > > places in which we currently have empty optionals?
> > +1
> > 
> > I also find this confusing. Should I interpret a None as a full or empty 
> > range? Does this depend on the context or a general rule? Is there any 
> > reason we need to handle nullable pointers or could we actually make call 
> > sites more uniform to get rid of some of the complexity here?
> > It sounds like you're treating null pointers / empty optionals equivalently 
> > to full ranges (i.e., intersecting with them has no effect)
> It is not actually true.  Empty optionals is the information that "this range 
> information is not available for this symbol".  It is true that intersecting 
> with them has no effect, but they are semantically different in other 
> aspects.  
> 
> Currently solver RELIES on the information that whether the range is 
> available or not (see my previous comment), and we simply couldn't get rid of 
> this behavior as part of NFC.
> 
> > How hard would it be to simply construct an actual full range in all the 
> > places in which we currently have empty optionals?
> It is not hard architecturally, but it WILL make the change functional and 
> possibly impact the performance.
> 
> > Should I interpret a None as a full or empty range?
> Neither of those.  That is the problem right now, that we rely on different 
> sources of information for the ranges and behave differently depending on 
> whether one piece of information is available or not.
> 
> > Does this depend on the context or a general rule?
> Semantics are always the same - this info is not available.
> 
> > Is there any reason we need to handle nullable pointers?
> `State->get(abc)` returns a nullable pointer meaning optional object, it 
> is hard to avoid it especially because we currently behave very differently 
> when this information is not available.
> 
> > ...could we actually make call 

  1   2   3   >