[PATCH] D98682: [RISCV] Don't emit #undef BUILTIN from RISCVVEmitter.cpp

2021-03-15 Thread Craig Topper via Phabricator via cfe-commits
craig.topper added inline comments.



Comment at: clang/include/clang/Basic/BuiltinsRISCV.def:20
 
+#undef BUILTIN

Can you undef TARGET_BUILTIN here too? I missed that when I added it on line 15.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98682

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


[PATCH] D98682: [RISCV] Don't emit #undef BUILTIN from RISCVVEmitter.cpp

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

In BuiltinsRISCV.def, other extension 's intrinsics need to be defined by using 
macro BUILTIN.
So, it shouldn't undefine macro BUILTIN in the end of declaration for V 
intrinsics.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D98682

Files:
  clang/include/clang/Basic/BuiltinsRISCV.def
  clang/utils/TableGen/RISCVVEmitter.cpp


Index: clang/utils/TableGen/RISCVVEmitter.cpp
===
--- clang/utils/TableGen/RISCVVEmitter.cpp
+++ clang/utils/TableGen/RISCVVEmitter.cpp
@@ -881,7 +881,6 @@
 else
   OS << "\"\")\n";
   }
-  OS << "\n#undef BUILTIN\n";
   OS << "#undef RISCVV_BUILTIN\n";
 }
 
Index: clang/include/clang/Basic/BuiltinsRISCV.def
===
--- clang/include/clang/Basic/BuiltinsRISCV.def
+++ clang/include/clang/Basic/BuiltinsRISCV.def
@@ -17,3 +17,4 @@
 
 #include "clang/Basic/riscv_vector_builtins.inc"
 
+#undef BUILTIN


Index: clang/utils/TableGen/RISCVVEmitter.cpp
===
--- clang/utils/TableGen/RISCVVEmitter.cpp
+++ clang/utils/TableGen/RISCVVEmitter.cpp
@@ -881,7 +881,6 @@
 else
   OS << "\"\")\n";
   }
-  OS << "\n#undef BUILTIN\n";
   OS << "#undef RISCVV_BUILTIN\n";
 }
 
Index: clang/include/clang/Basic/BuiltinsRISCV.def
===
--- clang/include/clang/Basic/BuiltinsRISCV.def
+++ clang/include/clang/Basic/BuiltinsRISCV.def
@@ -17,3 +17,4 @@
 
 #include "clang/Basic/riscv_vector_builtins.inc"
 
+#undef BUILTIN
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D98638: [RFC][Coroutine] Force stack allocation after await_suspend() call

2021-03-15 Thread Chuanqi Xu via Phabricator via cfe-commits
ChuanqiXu added a comment.

It looks like there are two things this patch wants to do:

1. Don't put the temporary generated by symmetric-transfer on the coroutine 
frame.
2. Offer a mechanism to force some values (it is easy to extend Alloca to 
Value) to put in the stack instead of the coroutine frame.

I am a little confused about the first problem. Would it cause the program to 
crash? (e.g., we access the fields of coroutine frame after the frame gets 
destroyed). Or it just wastes some storage?
And I want to ask about the change of the AST nodes and SemaCoroutine. Can we 
know if a CoroutineSuspendExpr stands for a symmetric-transfer? If yes, it 
seems we can only do changes in CodeGen part.

Then I agree to introduce new intrinsic to hint the middle end to put some 
values on the stack. And the design of `@llvm.coro.forcestack.begin()` and 
`@llvm.coro.forcestack.end()` is a little strange to me. It says they mark a 
region where only data from the local stack can be accessed. But it looks 
error-prone since it is hard for the front-end to decide whether all the access 
of the region should be put on the stack. I think we could introduce only one 
intrinisic `@llvm.coro.forcestack(Value* v)`, we can use the argument to mark 
the value need to be put on the stack.

And about the problem you mentioned in D96922 
: "The lifetime of  %coro.gro" starts early 
and %coro.gro" would be used after `coro.end` (Possibly the destructor?) which 
would cause the program to access destroyed coroutine frame". It looks like the 
mechanism could solve this problem by a call to 
`@llvm.coro.forcestack(%coro.gro)`.




Comment at: clang/include/clang/AST/ExprCXX.h:4695
+/// afterwards on the stack.
 class CoroutineSuspendExpr : public Expr {
   friend class ASTStmtReader;

It looks strange for the change of `CoroutineSuspendExpr` at the first glance. 
It is easy to understand the coroutine suspend expression is consists of three 
parts: Ready, Suspend and resume. It is written in the language documentation. 
And the new added AwaitSuspendCall is confusing.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98638

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


[PATCH] D96769: [OpenMP][AMDGPU] Skip backend and assemble phases for amdgcn

2021-03-15 Thread Pushpinder Singh via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGfc12a64ecc71: [OpenMP][AMDGPU] Skip backend and assemble 
phases for amdgcn (authored by pdhaliwal).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D96769

Files:
  clang/lib/Driver/Driver.cpp
  clang/lib/Driver/ToolChains/AMDGPUOpenMP.cpp
  clang/test/Driver/amdgpu-openmp-toolchain.c

Index: clang/test/Driver/amdgpu-openmp-toolchain.c
===
--- clang/test/Driver/amdgpu-openmp-toolchain.c
+++ clang/test/Driver/amdgpu-openmp-toolchain.c
@@ -1,3 +1,4 @@
+// REQUIRES: x86-registered-target
 // REQUIRES: amdgpu-registered-target
 // RUN:   env LIBRARY_PATH=%S/Inputs/hip_dev_lib %clang -### --target=x86_64-unknown-linux-gnu -fopenmp -fopenmp-targets=amdgcn-amd-amdhsa -Xopenmp-target=amdgcn-amd-amdhsa -march=gfx906 %s 2>&1 \
 // RUN:   | FileCheck %s
@@ -5,7 +6,7 @@
 // verify the tools invocations
 // CHECK: clang{{.*}}"-cc1" "-triple" "x86_64-unknown-linux-gnu"{{.*}}"-x" "c"{{.*}}
 // CHECK: clang{{.*}}"-cc1" "-triple" "x86_64-unknown-linux-gnu"{{.*}}"-x" "ir"{{.*}}
-// CHECK: clang{{.*}}"-cc1"{{.*}}"-triple" "amdgcn-amd-amdhsa"{{.*}}"-target-cpu" "gfx906" "-fcuda-is-device" "-emit-llvm-bc" "-mlink-builtin-bitcode"{{.*}}libomptarget-amdgcn-gfx906.bc"{{.*}}
+// CHECK: clang{{.*}}"-cc1"{{.*}}"-triple" "amdgcn-amd-amdhsa"{{.*}}"-target-cpu" "gfx906" "-fcuda-is-device" "-mlink-builtin-bitcode"{{.*}}libomptarget-amdgcn-gfx906.bc"{{.*}}
 // CHECK: llvm-link{{.*}}"-o" "{{.*}}amdgpu-openmp-toolchain-{{.*}}-gfx906-linked-{{.*}}.bc"
 // CHECK: llc{{.*}}amdgpu-openmp-toolchain-{{.*}}-gfx906-linked-{{.*}}.bc" "-mtriple=amdgcn-amd-amdhsa" "-mcpu=gfx906" "-filetype=obj" "-o"{{.*}}amdgpu-openmp-toolchain-{{.*}}-gfx906-{{.*}}.o"
 // CHECK: lld{{.*}}"-flavor" "gnu" "--no-undefined" "-shared" "-o"{{.*}}amdgpu-openmp-toolchain-{{.*}}.out" "{{.*}}amdgpu-openmp-toolchain-{{.*}}-gfx906-{{.*}}.o"
@@ -25,18 +26,35 @@
 // CHECK-PHASES: 6: preprocessor, {5}, cpp-output, (device-openmp)
 // CHECK-PHASES: 7: compiler, {6}, ir, (device-openmp)
 // CHECK-PHASES: 8: offload, "host-openmp (x86_64-unknown-linux-gnu)" {2}, "device-openmp (amdgcn-amd-amdhsa)" {7}, ir
-// CHECK-PHASES: 9: backend, {8}, assembler, (device-openmp)
-// CHECK-PHASES: 10: assembler, {9}, object, (device-openmp)
-// CHECK-PHASES: 11: linker, {10}, image, (device-openmp)
-// CHECK-PHASES: 12: offload, "device-openmp (amdgcn-amd-amdhsa)" {11}, image
-// CHECK-PHASES: 13: clang-offload-wrapper, {12}, ir, (host-openmp)
-// CHECK-PHASES: 14: backend, {13}, assembler, (host-openmp)
-// CHECK-PHASES: 15: assembler, {14}, object, (host-openmp)
-// CHECK-PHASES: 16: linker, {4, 15}, image, (host-openmp)
+// CHECK-PHASES: 9: linker, {8}, image, (device-openmp)
+// CHECK-PHASES: 10: offload, "device-openmp (amdgcn-amd-amdhsa)" {9}, image
+// CHECK-PHASES: 11: clang-offload-wrapper, {10}, ir, (host-openmp)
+// CHECK-PHASES: 12: backend, {11}, assembler, (host-openmp)
+// CHECK-PHASES: 13: assembler, {12}, object, (host-openmp)
+// CHECK-PHASES: 14: linker, {4, 13}, image, (host-openmp)
 
 // handling of --libomptarget-amdgcn-bc-path
 // RUN:   %clang -### --target=x86_64-unknown-linux-gnu -fopenmp -fopenmp-targets=amdgcn-amd-amdhsa -Xopenmp-target=amdgcn-amd-amdhsa -march=gfx803 --libomptarget-amdgcn-bc-path=%S/Inputs/hip_dev_lib/libomptarget-amdgcn-gfx803.bc %s 2>&1 | FileCheck %s --check-prefix=CHECK-LIBOMPTARGET
-// CHECK-LIBOMPTARGET: clang{{.*}}"-cc1"{{.*}}"-triple" "amdgcn-amd-amdhsa"{{.*}}"-target-cpu" "gfx803" "-fcuda-is-device" "-emit-llvm-bc" "-mlink-builtin-bitcode"{{.*}}Inputs/hip_dev_lib/libomptarget-amdgcn-gfx803.bc"{{.*}}
+// CHECK-LIBOMPTARGET: clang{{.*}}"-cc1"{{.*}}"-triple" "amdgcn-amd-amdhsa"{{.*}}"-target-cpu" "gfx803" "-fcuda-is-device" "-mlink-builtin-bitcode"{{.*}}Inputs/hip_dev_lib/libomptarget-amdgcn-gfx803.bc"{{.*}}
 
 // RUN:   %clang -### --target=x86_64-unknown-linux-gnu -fopenmp -fopenmp-targets=amdgcn-amd-amdhsa -Xopenmp-target=amdgcn-amd-amdhsa -march=gfx803 -nogpulib %s 2>&1 | FileCheck %s --check-prefix=CHECK-NOGPULIB
-// CHECK-NOGPULIB-NOT: clang{{.*}}"-cc1"{{.*}}"-triple" "amdgcn-amd-amdhsa"{{.*}}"-target-cpu" "gfx803" "-fcuda-is-device" "-emit-llvm-bc" "-mlink-builtin-bitcode"{{.*}}libomptarget-amdgcn-gfx803.bc"{{.*}}
+// CHECK-NOGPULIB-NOT: clang{{.*}}"-cc1"{{.*}}"-triple" "amdgcn-amd-amdhsa"{{.*}}"-target-cpu" "gfx803" "-fcuda-is-device" "-mlink-builtin-bitcode"{{.*}}libomptarget-amdgcn-gfx803.bc"{{.*}}
+
+// RUN:   %clang -### --target=x86_64-unknown-linux-gnu -ccc-print-bindings -save-temps -fopenmp -fopenmp-targets=amdgcn-amd-amdhsa -Xopenmp-target=amdgcn-amd-amdhsa -march=gfx803 -nogpulib %s 2>&1 | FileCheck %s --check-prefix=CHECK-PRINT-BINDINGS
+// CHECK-PRINT-BINDINGS: "x86_64-unknown-linux-gnu" - "clang", inputs: ["[[INPUT:.*]]"],
+// 

[clang] fc12a64 - [OpenMP][AMDGPU] Skip backend and assemble phases for amdgcn

2021-03-15 Thread Pushpinder Singh via cfe-commits

Author: Pushpinder Singh
Date: 2021-03-16T04:58:14Z
New Revision: fc12a64ecc71bf6789b3ca67d3cda77acc8785f9

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

LOG: [OpenMP][AMDGPU] Skip backend and assemble phases for amdgcn

Remove emit-llvm-bc from addClangTargetOptions as it conflicts with -E for 
save-temps.

AMDGCN does not yet support linking object files so backend and assemble 
actions are
skipped, leaving LLVM IR as the output format.

Reviewed By: JonChesterfield, ronlieb

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

Added: 


Modified: 
clang/lib/Driver/Driver.cpp
clang/lib/Driver/ToolChains/AMDGPUOpenMP.cpp
clang/test/Driver/amdgpu-openmp-toolchain.c

Removed: 




diff  --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp
index ceaeb16df6f1..dbd365e7c9bc 100644
--- a/clang/lib/Driver/Driver.cpp
+++ b/clang/lib/Driver/Driver.cpp
@@ -3086,8 +3086,16 @@ class OffloadingActionBuilder final {
   }
 
   // By default, we produce an action for each device arch.
-  for (Action * : OpenMPDeviceActions)
+  for (unsigned I = 0; I < ToolChains.size(); ++I) {
+Action * = OpenMPDeviceActions[I];
+// AMDGPU does not support linking of object files, so we skip
+// assemble and backend actions to produce LLVM IR.
+if (ToolChains[I]->getTriple().isAMDGCN() &&
+(CurPhase == phases::Assemble || CurPhase == phases::Backend))
+  continue;
+
 A = C.getDriver().ConstructPhaseAction(C, Args, CurPhase, A);
+  }
 
   return ABRT_Success;
 }

diff  --git a/clang/lib/Driver/ToolChains/AMDGPUOpenMP.cpp 
b/clang/lib/Driver/ToolChains/AMDGPUOpenMP.cpp
index 53d25c05b623..38abd2f48368 100644
--- a/clang/lib/Driver/ToolChains/AMDGPUOpenMP.cpp
+++ b/clang/lib/Driver/ToolChains/AMDGPUOpenMP.cpp
@@ -161,6 +161,11 @@ void AMDGCN::OpenMPLinker::ConstructJob(Compilation , 
const JobAction ,
   // Each command outputs 
diff erent files.
   const char *LLVMLinkCommand =
   constructLLVMLinkCommand(C, JA, Inputs, Args, GPUArch, Prefix);
+
+  // Produce readable assembly if save-temps is enabled.
+  if (C.getDriver().isSaveTempsEnabled())
+constructLlcCommand(C, JA, Inputs, Args, GPUArch, Prefix, LLVMLinkCommand,
+/*OutputIsAsm=*/true);
   const char *LlcCommand = constructLlcCommand(C, JA, Inputs, Args, GPUArch,
Prefix, LLVMLinkCommand);
   constructLldCommand(C, JA, Inputs, Output, Args, LlcCommand);
@@ -189,7 +194,6 @@ void AMDGPUOpenMPToolChain::addClangTargetOptions(
   CC1Args.push_back("-target-cpu");
   CC1Args.push_back(DriverArgs.MakeArgStringRef(GpuArch));
   CC1Args.push_back("-fcuda-is-device");
-  CC1Args.push_back("-emit-llvm-bc");
 
   if (DriverArgs.hasArg(options::OPT_nogpulib))
 return;

diff  --git a/clang/test/Driver/amdgpu-openmp-toolchain.c 
b/clang/test/Driver/amdgpu-openmp-toolchain.c
index 0645177f00e2..f2350a51817a 100644
--- a/clang/test/Driver/amdgpu-openmp-toolchain.c
+++ b/clang/test/Driver/amdgpu-openmp-toolchain.c
@@ -1,3 +1,4 @@
+// REQUIRES: x86-registered-target
 // REQUIRES: amdgpu-registered-target
 // RUN:   env LIBRARY_PATH=%S/Inputs/hip_dev_lib %clang -### 
--target=x86_64-unknown-linux-gnu -fopenmp -fopenmp-targets=amdgcn-amd-amdhsa 
-Xopenmp-target=amdgcn-amd-amdhsa -march=gfx906 %s 2>&1 \
 // RUN:   | FileCheck %s
@@ -5,7 +6,7 @@
 // verify the tools invocations
 // CHECK: clang{{.*}}"-cc1" "-triple" "x86_64-unknown-linux-gnu"{{.*}}"-x" 
"c"{{.*}}
 // CHECK: clang{{.*}}"-cc1" "-triple" "x86_64-unknown-linux-gnu"{{.*}}"-x" 
"ir"{{.*}}
-// CHECK: clang{{.*}}"-cc1"{{.*}}"-triple" 
"amdgcn-amd-amdhsa"{{.*}}"-target-cpu" "gfx906" "-fcuda-is-device" 
"-emit-llvm-bc" 
"-mlink-builtin-bitcode"{{.*}}libomptarget-amdgcn-gfx906.bc"{{.*}}
+// CHECK: clang{{.*}}"-cc1"{{.*}}"-triple" 
"amdgcn-amd-amdhsa"{{.*}}"-target-cpu" "gfx906" "-fcuda-is-device" 
"-mlink-builtin-bitcode"{{.*}}libomptarget-amdgcn-gfx906.bc"{{.*}}
 // CHECK: llvm-link{{.*}}"-o" 
"{{.*}}amdgpu-openmp-toolchain-{{.*}}-gfx906-linked-{{.*}}.bc"
 // CHECK: llc{{.*}}amdgpu-openmp-toolchain-{{.*}}-gfx906-linked-{{.*}}.bc" 
"-mtriple=amdgcn-amd-amdhsa" "-mcpu=gfx906" "-filetype=obj" 
"-o"{{.*}}amdgpu-openmp-toolchain-{{.*}}-gfx906-{{.*}}.o"
 // CHECK: lld{{.*}}"-flavor" "gnu" "--no-undefined" "-shared" 
"-o"{{.*}}amdgpu-openmp-toolchain-{{.*}}.out" 
"{{.*}}amdgpu-openmp-toolchain-{{.*}}-gfx906-{{.*}}.o"
@@ -25,18 +26,35 @@
 // CHECK-PHASES: 6: preprocessor, {5}, cpp-output, (device-openmp)
 // CHECK-PHASES: 7: compiler, {6}, ir, (device-openmp)
 // CHECK-PHASES: 8: offload, "host-openmp (x86_64-unknown-linux-gnu)" {2}, 
"device-openmp (amdgcn-amd-amdhsa)" {7}, ir
-// CHECK-PHASES: 9: backend, {8}, assembler, 

[PATCH] D98429: [clang-format] Add new option to clang-format: SpaceBeforeForLoopSemiColon

2021-03-15 Thread Nathan Hjelm via Phabricator via cfe-commits
hjelmn updated this revision to Diff 330865.
hjelmn added a comment.

One more issue with the test. Made a mistake with whether there is a space 
before the colon.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98429

Files:
  clang/docs/ClangFormatStyleOptions.rst
  clang/docs/ReleaseNotes.rst
  clang/include/clang/Format/Format.h
  clang/lib/Format/Format.cpp
  clang/lib/Format/FormatToken.h
  clang/lib/Format/TokenAnnotator.cpp
  clang/unittests/Format/FormatTest.cpp

Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -12701,6 +12701,17 @@
InvertedSpaceStyle);
 }
 
+TEST_F(FormatTest, ConfigurableSpaceBeforeForLoopSemiColon) {
+  FormatStyle NoSpaceStyle = getLLVMStyle();
+  verifyFormat("for (i = 0; i < 10; ++i) {\n}", NoSpaceStyle);
+  verifyFormat("for (int i = 0; auto a : b) {\n}", NoSpaceStyle);
+
+  FormatStyle Space = getLLVMStyle();
+  Space.SpaceBeforeForLoopSemiColon = true;
+  verifyFormat("for (i = 0 ; i < 10 ; ++i) {\n}", Space);
+  verifyFormat("for (int i = 0 ; auto a : b) {\n}", Space);
+}
+
 TEST_F(FormatTest, ConfigurableSpaceAroundPointerQualifiers) {
   FormatStyle Style = getLLVMStyle();
 
@@ -15610,6 +15621,7 @@
   CHECK_PARSE_BOOL(SpaceBeforeCaseColon);
   CHECK_PARSE_BOOL(SpaceBeforeCpp11BracedList);
   CHECK_PARSE_BOOL(SpaceBeforeCtorInitializerColon);
+  CHECK_PARSE_BOOL(SpaceBeforeForLoopSemiColon);
   CHECK_PARSE_BOOL(SpaceBeforeInheritanceColon);
   CHECK_PARSE_BOOL(SpaceBeforeRangeBasedForLoopColon);
   CHECK_PARSE_BOOL(SpaceBeforeSquareBrackets);
Index: clang/lib/Format/TokenAnnotator.cpp
===
--- clang/lib/Format/TokenAnnotator.cpp
+++ clang/lib/Format/TokenAnnotator.cpp
@@ -,6 +,10 @@
 parseCSharpGenericTypeConstraint();
   }
   break;
+case tok::semi:
+  if (Contexts.back().ColonIsForRangeExpr)
+Tok->setType(TT_ForLoopSemiColon);
+  break;
 default:
   break;
 }
@@ -3345,6 +3349,8 @@
   if (Right.is(TT_RangeBasedForLoopColon) &&
   !Style.SpaceBeforeRangeBasedForLoopColon)
 return false;
+  if (Right.is(TT_ForLoopSemiColon) && Style.SpaceBeforeForLoopSemiColon)
+return true;
   if (Left.is(TT_BitFieldColon))
 return Style.BitFieldColonSpacing == FormatStyle::BFCS_Both ||
Style.BitFieldColonSpacing == FormatStyle::BFCS_After;
@@ -3995,6 +4001,8 @@
 return true;
   if (Right.is(TT_RangeBasedForLoopColon))
 return false;
+  if (Right.is(TT_ForLoopSemiColon))
+return false;
   if (Left.is(TT_TemplateCloser) && Right.is(TT_TemplateOpener))
 return true;
   if (Left.isOneOf(TT_TemplateCloser, TT_UnaryOperator) ||
Index: clang/lib/Format/FormatToken.h
===
--- clang/lib/Format/FormatToken.h
+++ clang/lib/Format/FormatToken.h
@@ -46,6 +46,7 @@
   TYPE(DesignatedInitializerLSquare)   \
   TYPE(DesignatedInitializerPeriod)\
   TYPE(DictLiteral)\
+  TYPE(ForLoopSemiColon)   \
   TYPE(ForEachMacro)   \
   TYPE(FunctionAnnotationRParen)   \
   TYPE(FunctionDeclarationName)\
Index: clang/lib/Format/Format.cpp
===
--- clang/lib/Format/Format.cpp
+++ clang/lib/Format/Format.cpp
@@ -657,6 +657,8 @@
Style.SpaceBeforeCpp11BracedList);
 IO.mapOptional("SpaceBeforeCtorInitializerColon",
Style.SpaceBeforeCtorInitializerColon);
+IO.mapOptional("SpaceBeforeForLoopSemiColon",
+   Style.SpaceBeforeForLoopSemiColon);
 IO.mapOptional("SpaceBeforeInheritanceColon",
Style.SpaceBeforeInheritanceColon);
 IO.mapOptional("SpaceBeforeParens", Style.SpaceBeforeParens);
@@ -1026,6 +1028,7 @@
   LLVMStyle.SpaceAroundPointerQualifiers = FormatStyle::SAPQ_Default;
   LLVMStyle.SpaceBeforeCaseColon = false;
   LLVMStyle.SpaceBeforeCtorInitializerColon = true;
+  LLVMStyle.SpaceBeforeForLoopSemiColon = false;
   LLVMStyle.SpaceBeforeInheritanceColon = true;
   LLVMStyle.SpaceBeforeParens = FormatStyle::SBPO_ControlStatements;
   LLVMStyle.SpaceBeforeRangeBasedForLoopColon = true;
Index: clang/include/clang/Format/Format.h
===
--- clang/include/clang/Format/Format.h
+++ clang/include/clang/Format/Format.h
@@ -2835,6 +2835,13 @@
   /// \endcode
   bool SpaceBeforeCtorInitializerColon;
 
+  

[PATCH] D93594: [X86] Pass to transform amx intrinsics to scalar operation.

2021-03-15 Thread Bing Yu via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG4f198b0c27b0: [X86] Pass to transform amx intrinsics to 
scalar operation. (authored by yubing).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93594

Files:
  llvm/include/llvm/CodeGen/Passes.h
  llvm/lib/Target/X86/CMakeLists.txt
  llvm/lib/Target/X86/X86.h
  llvm/lib/Target/X86/X86LowerAMXIntrinsics.cpp
  llvm/lib/Target/X86/X86LowerAMXType.cpp
  llvm/lib/Target/X86/X86TargetMachine.cpp
  llvm/test/CodeGen/X86/AMX/amx-low-intrinsics-no-amx-bitcast.ll
  llvm/test/CodeGen/X86/AMX/amx-low-intrinsics.ll
  llvm/test/CodeGen/X86/AMX/amx-type.ll
  llvm/test/CodeGen/X86/O0-pipeline.ll
  llvm/test/CodeGen/X86/opt-pipeline.ll
  llvm/tools/opt/opt.cpp

Index: llvm/tools/opt/opt.cpp
===
--- llvm/tools/opt/opt.cpp
+++ llvm/tools/opt/opt.cpp
@@ -520,7 +520,8 @@
   "expand-reductions","indirectbr-expand",
   "generic-to-nvvm",  "expandmemcmp",
   "loop-reduce",  "lower-amx-type",
-  "polyhedral-info",  "replace-with-veclib"};
+  "lower-amx-intrinsics", "polyhedral-info",
+  "replace-with-veclib"};
   for (const auto  : PassNamePrefix)
 if (Pass.startswith(P))
   return true;
Index: llvm/test/CodeGen/X86/opt-pipeline.ll
===
--- llvm/test/CodeGen/X86/opt-pipeline.ll
+++ llvm/test/CodeGen/X86/opt-pipeline.ll
@@ -24,11 +24,12 @@
 ; CHECK-NEXT: Pre-ISel Intrinsic Lowering
 ; CHECK-NEXT: FunctionPass Manager
 ; CHECK-NEXT:   Expand Atomic instructions
+; CHECK-NEXT:   Dominator Tree Construction
+; CHECK-NEXT:   Natural Loop Information
+; CHECK-NEXT:   Lower AMX intrinsics
 ; CHECK-NEXT:   Lower AMX type for load/store
 ; CHECK-NEXT:   Module Verifier
-; CHECK-NEXT:   Dominator Tree Construction
 ; CHECK-NEXT:   Basic Alias Analysis (stateless AA impl)
-; CHECK-NEXT:   Natural Loop Information
 ; CHECK-NEXT:   Canonicalize natural loops
 ; CHECK-NEXT:   Scalar Evolution Analysis
 ; CHECK-NEXT:   Loop Pass Manager
Index: llvm/test/CodeGen/X86/O0-pipeline.ll
===
--- llvm/test/CodeGen/X86/O0-pipeline.ll
+++ llvm/test/CodeGen/X86/O0-pipeline.ll
@@ -18,6 +18,9 @@
 ; CHECK-NEXT: Pre-ISel Intrinsic Lowering
 ; CHECK-NEXT: FunctionPass Manager
 ; CHECK-NEXT:   Expand Atomic instructions
+; CHECK-NEXT:   Dominator Tree Construction
+; CHECK-NEXT:   Natural Loop Information
+; CHECK-NEXT:   Lower AMX intrinsics
 ; CHECK-NEXT:   Lower AMX type for load/store
 ; CHECK-NEXT:   Module Verifier
 ; CHECK-NEXT:   Lower Garbage Collection Instructions
Index: llvm/test/CodeGen/X86/AMX/amx-type.ll
===
--- llvm/test/CodeGen/X86/AMX/amx-type.ll
+++ llvm/test/CodeGen/X86/AMX/amx-type.ll
@@ -1,5 +1,5 @@
 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
-; RUN: opt -lower-amx-type %s -S | FileCheck %s
+; RUN: opt --codegen-opt-level=2 -mtriple=x86_64 -lower-amx-type %s -S | FileCheck %s
 
 %struct.__tile_str = type { i16, i16, <256 x i32> }
 
Index: llvm/test/CodeGen/X86/AMX/amx-low-intrinsics.ll
===
--- /dev/null
+++ llvm/test/CodeGen/X86/AMX/amx-low-intrinsics.ll
@@ -0,0 +1,237 @@
+; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
+; RUN: opt -mtriple=x86_64 -lower-amx-intrinsics %s -S | FileCheck %s
+
+define dso_local void @test_amx_load_non_O0(i16 signext %row, i16 signext %col, i8 *%ptr, i64 %stride, <256 x i32>* %vptr) {
+; CHECK-LABEL: @test_amx_load_non_O0(
+; CHECK-NEXT:  entry:
+; CHECK-NEXT:[[TMP0:%.*]] = lshr i16 [[COL:%.*]], 2
+; CHECK-NEXT:[[TMP1:%.*]] = lshr i64 [[STRIDE:%.*]], 2
+; CHECK-NEXT:br label [[TILELOAD_SCALARIZE_ROWS_HEADER:%.*]]
+; CHECK:   tileload.scalarize.rows.header:
+; CHECK-NEXT:[[TILELOAD_SCALARIZE_ROWS_IV:%.*]] = phi i16 [ 0, [[ENTRY:%.*]] ], [ [[TILELOAD_SCALARIZE_ROWS_STEP:%.*]], [[TILELOAD_SCALARIZE_ROWS_LATCH:%.*]] ]
+; CHECK-NEXT:[[VEC_PHI_ROW:%.*]] = phi <256 x i32> [ zeroinitializer, [[ENTRY]] ], [ [[TMP11:%.*]], [[TILELOAD_SCALARIZE_ROWS_LATCH]] ]
+; CHECK-NEXT:br label [[TILELOAD_SCALARIZE_ROWS_BODY:%.*]]
+; CHECK:   tileload.scalarize.rows.body:
+; CHECK-NEXT:br label [[TILELOAD_SCALARIZE_COLS_HEADER:%.*]]
+; CHECK:   tileload.scalarize.cols.header:
+; CHECK-NEXT:[[TILELOAD_SCALARIZE_COLS_IV:%.*]] = phi i16 [ 0, [[TILELOAD_SCALARIZE_ROWS_BODY]] ], [ [[TILELOAD_SCALARIZE_COLS_STEP:%.*]], [[TILELOAD_SCALARIZE_COLS_LATCH:%.*]] ]
+; CHECK-NEXT:[[VEC_PHI:%.*]] = phi <256 x i32> [ [[VEC_PHI_ROW]], 

[PATCH] D93938: [clang-format] Fixed AfterEnum handling

2021-03-15 Thread Ally Tiritoglu via Phabricator via cfe-commits
atirit updated this revision to Diff 330860.
atirit added a comment.

Fixed remote build


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93938

Files:
  clang/lib/Format/TokenAnnotator.cpp
  clang/lib/Format/UnwrappedLineParser.cpp
  clang/unittests/Format/FormatTest.cpp

Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -1344,13 +1344,68 @@
   Style.AllowShortEnumsOnASingleLine = true;
   verifyFormat("enum { A, B, C } ShortEnum1, ShortEnum2;", Style);
   Style.AllowShortEnumsOnASingleLine = false;
+  verifyFormat("enum {\n"
+   "  A,\n"
+   "  B,\n"
+   "  C\n"
+   "} ShortEnum1, ShortEnum2;",
+   Style);
+}
+
+TEST_F(FormatTest, AfterEnum) {
+  FormatStyle Style = getLLVMStyle();
+  Style.BreakBeforeBraces = FormatStyle::BS_Custom;
+
+  Style.AllowShortEnumsOnASingleLine = true;
+  Style.BraceWrapping.AfterEnum = true;
+  verifyFormat("enum { A, B, C } Test1;", Style);
+  verifyFormat("enum\n"
+   "{\n"
+   "  A,\n"
+   "  B, // foo\n"
+   "  C\n"
+   "} Test2;",
+   Style);
+  Style.BraceWrapping.AfterEnum = false;
+  verifyFormat("enum { A, B, C } Test3;", Style);
+  verifyFormat("enum {\n"
+   "  A,\n"
+   "  B, // foo\n"
+   "  C\n"
+   "} Test4;",
+   Style);
+
+  Style.AllowShortEnumsOnASingleLine = false;
+  Style.BraceWrapping.AfterEnum = true;
   verifyFormat("enum\n"
"{\n"
"  A,\n"
"  B,\n"
"  C\n"
-   "} ShortEnum1, ShortEnum2;",
+   "} Test5;",
+   Style);
+  Style.BraceWrapping.AfterEnum = false;
+  verifyFormat("enum {\n"
+   "  A,\n"
+   "  B,\n"
+   "  C\n"
+   "} Test6;",
+   Style);
+}
+
+TEST_F(FormatTest, AfterEnumShortEnums) {
+  FormatStyle Style = getLLVMStyle();
+  Style.BreakBeforeBraces = FormatStyle::BS_Custom;
+
+  Style.AllowShortEnumsOnASingleLine = true;
+  Style.BraceWrapping.AfterEnum = true;
+  verifyFormat("enum\n"
+   "{\n"
+   "  A,\n"
+   "  B,\n"
+   "} ShortEnum;",
Style);
+  verifyFormat("enum { A, B } ShortEnum;", Style);
 }
 
 TEST_F(FormatTest, ShortCaseLabels) {
@@ -13276,6 +13331,7 @@
 TEST_F(FormatTest, AllmanBraceBreaking) {
   FormatStyle AllmanBraceStyle = getLLVMStyle();
   AllmanBraceStyle.BreakBeforeBraces = FormatStyle::BS_Allman;
+  AllmanBraceStyle.AllowShortEnumsOnASingleLine = false;
 
   EXPECT_EQ("namespace a\n"
 "{\n"
Index: clang/lib/Format/UnwrappedLineParser.cpp
===
--- clang/lib/Format/UnwrappedLineParser.cpp
+++ clang/lib/Format/UnwrappedLineParser.cpp
@@ -694,6 +694,8 @@
 return Style.BraceWrapping.AfterUnion;
   if (InitialToken.is(tok::kw_struct))
 return Style.BraceWrapping.AfterStruct;
+  if (InitialToken.is(tok::kw_enum))
+return Style.BraceWrapping.AfterEnum;
   return false;
 }
 
@@ -2482,8 +2484,9 @@
 return true;
   }
 
-  if (!Style.AllowShortEnumsOnASingleLine)
+  if (!Style.AllowShortEnumsOnASingleLine && Style.BraceWrapping.AfterEnum)
 addUnwrappedLine();
+
   // Parse enum body.
   nextToken();
   if (!Style.AllowShortEnumsOnASingleLine) {
Index: clang/lib/Format/TokenAnnotator.cpp
===
--- clang/lib/Format/TokenAnnotator.cpp
+++ clang/lib/Format/TokenAnnotator.cpp
@@ -3662,12 +3662,37 @@
 return true;
   }
 
-  if (isAllmanBrace(Left) || isAllmanBrace(Right))
-return (Line.startsWith(tok::kw_enum) && Style.BraceWrapping.AfterEnum) ||
-   (Line.startsWith(tok::kw_typedef, tok::kw_enum) &&
-Style.BraceWrapping.AfterEnum) ||
-   (Line.startsWith(tok::kw_class) && Style.BraceWrapping.AfterClass) ||
-   (Line.startsWith(tok::kw_struct) && Style.BraceWrapping.AfterStruct);
+  if (isAllmanBrace(Left) || isAllmanBrace(Right)) {
+// The tokens that could force an enum to not be on a single line are a
+// trailing comment and a trailing comma on the last case. This checks for
+// those.
+auto isAllowedByShortEnums = [&]() {
+  if (!Style.AllowShortEnumsOnASingleLine ||
+  (strlen(Right.TokenText.data()) + Right.OriginalColumn) >
+  Style.ColumnLimit)
+return true;
+
+  const FormatToken *breakingSearchToken = 
+  while ((breakingSearchToken = breakingSearchToken->Next)) {
+bool hasBreakingComma = breakingSearchToken->is(tok::comma) &&
+breakingSearchToken->Next->is(tok::r_brace);
+if 

[PATCH] D98676: [WebAssembly] Finalize SIMD names and opcodes

2021-03-15 Thread Thomas Lively via Phabricator via cfe-commits
tlively created this revision.
tlively added reviewers: aheejin, dschuff.
Herald added subscribers: wingo, ecnelises, sunfish, hiraditya, 
jgravelle-google, sbc100.
tlively requested review of this revision.
Herald added projects: clang, LLVM.
Herald added subscribers: llvm-commits, cfe-commits.

Updates the names (e.g. widen => extend, saturate => sat) and opcodes of all
SIMD instructions to match the finalized SIMD spec. Deliberately does not change
the public interface in wasm_simd128.h yet; that will require more care.

Depends on D98466 .


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D98676

Files:
  clang/include/clang/Basic/BuiltinsWebAssembly.def
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/lib/Headers/wasm_simd128.h
  clang/test/CodeGen/builtins-wasm.c
  llvm/include/llvm/IR/IntrinsicsWebAssembly.td
  llvm/lib/Target/WebAssembly/WebAssemblyISD.def
  llvm/lib/Target/WebAssembly/WebAssemblyISelLowering.cpp
  llvm/lib/Target/WebAssembly/WebAssemblyInstrSIMD.td
  llvm/test/CodeGen/WebAssembly/simd-extending.ll
  llvm/test/CodeGen/WebAssembly/simd-intrinsics.ll
  llvm/test/CodeGen/WebAssembly/simd-widening.ll
  llvm/test/MC/WebAssembly/simd-encodings.s

Index: llvm/test/MC/WebAssembly/simd-encodings.s
===
--- llvm/test/MC/WebAssembly/simd-encodings.s
+++ llvm/test/MC/WebAssembly/simd-encodings.s
@@ -280,38 +280,51 @@
 # CHECK: v128.bitselect # encoding: [0xfd,0x52]
 v128.bitselect
 
-# CHECK: v128.load8_lane 32, 1 # encoding: [0xfd,0x58,0x00,0x20,0x01]
+# TODO: v128.any_true # encoding: [0xfd,0x53]
+
+# CHECK: v128.load8_lane 32, 1 # encoding: [0xfd,0x54,0x00,0x20,0x01]
 v128.load8_lane 32, 1
 
-# CHECK: v128.load16_lane 32, 1 # encoding: [0xfd,0x59,0x01,0x20,0x01]
+# CHECK: v128.load16_lane 32, 1 # encoding: [0xfd,0x55,0x01,0x20,0x01]
 v128.load16_lane 32, 1
 
-# CHECK: v128.load32_lane 32, 1 # encoding: [0xfd,0x5a,0x02,0x20,0x01]
+# CHECK: v128.load32_lane 32, 1 # encoding: [0xfd,0x56,0x02,0x20,0x01]
 v128.load32_lane 32, 1
 
-# CHECK: v128.load64_lane 32, 1 # encoding: [0xfd,0x5b,0x03,0x20,0x01]
+# CHECK: v128.load64_lane 32, 1 # encoding: [0xfd,0x57,0x03,0x20,0x01]
 v128.load64_lane 32, 1
 
-# CHECK: v128.store8_lane 32, 1 # encoding: [0xfd,0x5c,0x00,0x20,0x01]
+# CHECK: v128.store8_lane 32, 1 # encoding: [0xfd,0x58,0x00,0x20,0x01]
 v128.store8_lane 32, 1
 
-# CHECK: v128.store16_lane 32, 1 # encoding: [0xfd,0x5d,0x01,0x20,0x01]
+# CHECK: v128.store16_lane 32, 1 # encoding: [0xfd,0x59,0x01,0x20,0x01]
 v128.store16_lane 32, 1
 
-# CHECK: v128.store32_lane 32, 1 # encoding: [0xfd,0x5e,0x02,0x20,0x01]
+# CHECK: v128.store32_lane 32, 1 # encoding: [0xfd,0x5a,0x02,0x20,0x01]
 v128.store32_lane 32, 1
 
-# CHECK: v128.store64_lane 32, 1 # encoding: [0xfd,0x5f,0x03,0x20,0x01]
+# CHECK: v128.store64_lane 32, 1 # encoding: [0xfd,0x5b,0x03,0x20,0x01]
 v128.store64_lane 32, 1
 
+# CHECK: v128.load32_zero 32 # encoding: [0xfd,0x5c,0x02,0x20]
+v128.load32_zero 32
+
+# CHECK: v128.load64_zero 32 # encoding: [0xfd,0x5d,0x03,0x20]
+v128.load64_zero 32
+
+# CHECK: f32x4.demote_zero_f64x2 # encoding: [0xfd,0x5e]
+f32x4.demote_zero_f64x2
+
+# CHECK: f64x2.promote_low_f32x4 # encoding: [0xfd,0x5f]
+f64x2.promote_low_f32x4
+
 # CHECK: i8x16.abs # encoding: [0xfd,0x60]
 i8x16.abs
 
 # CHECK: i8x16.neg # encoding: [0xfd,0x61]
 i8x16.neg
 
-# CHECK: i8x16.any_true # encoding: [0xfd,0x62]
-i8x16.any_true
+# TODO: i8x16.popcnt # encoding: [0xfd,0x62]
 
 # CHECK: i8x16.all_true # encoding: [0xfd,0x63]
 i8x16.all_true
@@ -325,6 +338,18 @@
 # CHECK: i8x16.narrow_i16x8_u # encoding: [0xfd,0x66]
 i8x16.narrow_i16x8_u
 
+# CHECK: f32x4.ceil # encoding: [0xfd,0x67]
+f32x4.ceil
+
+# CHECK: f32x4.floor # encoding: [0xfd,0x68]
+f32x4.floor
+
+# CHECK: f32x4.trunc # encoding: [0xfd,0x69]
+f32x4.trunc
+
+# CHECK: f32x4.nearest # encoding: [0xfd,0x6a]
+f32x4.nearest
+
 # CHECK: i8x16.shl # encoding: [0xfd,0x6b]
 i8x16.shl
 
@@ -337,20 +362,26 @@
 # CHECK: i8x16.add # encoding: [0xfd,0x6e]
 i8x16.add
 
-# CHECK: i8x16.add_saturate_s # encoding: [0xfd,0x6f]
-i8x16.add_saturate_s
+# CHECK: i8x16.add_sat_s # encoding: [0xfd,0x6f]
+i8x16.add_sat_s
 
-# CHECK: i8x16.add_saturate_u # encoding: [0xfd,0x70]
-i8x16.add_saturate_u
+# CHECK: i8x16.add_sat_u # encoding: [0xfd,0x70]
+i8x16.add_sat_u
 
 # CHECK: i8x16.sub # encoding: [0xfd,0x71]
 i8x16.sub
 
-# CHECK: i8x16.sub_saturate_s # encoding: [0xfd,0x72]
-i8x16.sub_saturate_s
+# CHECK: i8x16.sub_sat_s # encoding: [0xfd,0x72]
+i8x16.sub_sat_s
 
-# CHECK: i8x16.sub_saturate_u # encoding: [0xfd,0x73]
-i8x16.sub_saturate_u
+# CHECK: i8x16.sub_sat_u # encoding: [0xfd,0x73]
+

Re: [clang] 774b707 - Revert "Workaround a -Wmisleading-indentation warning"

2021-03-15 Thread David Blaikie via cfe-commits
Would be great to include details of why the patch was reverted - helps
folks understand if this patch will address any issues they're seeing, or
help avoid someone causing the same problem with a similar patch in the
future.

On Wed, Mar 10, 2021 at 3:36 PM Stephen Kelly via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

>
> Author: Stephen Kelly
> Date: 2021-03-10T23:35:41Z
> New Revision: 774b707564e1eed8fec5b5874d0aa82628de0651
>
> URL:
> https://github.com/llvm/llvm-project/commit/774b707564e1eed8fec5b5874d0aa82628de0651
> DIFF:
> https://github.com/llvm/llvm-project/commit/774b707564e1eed8fec5b5874d0aa82628de0651.diff
>
> LOG: Revert "Workaround a -Wmisleading-indentation warning"
>
> This reverts commit 5c22e2bec008760cc7078d8d14382ef4762c5d54.
>
> Added:
>
>
> Modified:
> clang/lib/Tooling/DumpTool/generate_cxx_src_locs.py
>
> Removed:
>
>
>
>
> 
> diff  --git a/clang/lib/Tooling/DumpTool/generate_cxx_src_locs.py
> b/clang/lib/Tooling/DumpTool/generate_cxx_src_locs.py
> index aafae2c15b29..dee7a416e69a 100755
> --- a/clang/lib/Tooling/DumpTool/generate_cxx_src_locs.py
> +++ b/clang/lib/Tooling/DumpTool/generate_cxx_src_locs.py
> @@ -171,7 +171,7 @@ def GenerateDynNodeVisitor(self, CladeNames):
>  if (const auto *N = Node.get<{0}>())
>return GetLocations(const_cast<{0} *>(N));""".format(CladeName)
>
> -self.implementationContent += '\nreturn {}; }'
> +self.implementationContent += 'return {}; }'
>
>  def GenerateEpilogue(self):
>
>
>
>
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D98160: [clang] Use decltype((E)) for compound requirement type constraint

2021-03-15 Thread Matheus Izvekov via Phabricator via cfe-commits
mizvekov added a comment.

I don't know what is going on with the clang-format linux failure here.
The patch it suggests looks awful...


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98160

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


[PATCH] D98429: [clang-format] Add new option to clang-format: SpaceBeforeForLoopSemiColon

2021-03-15 Thread Nathan Hjelm via Phabricator via cfe-commits
hjelmn updated this revision to Diff 330834.
hjelmn added a comment.

Fixed a typo


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98429

Files:
  clang/docs/ClangFormatStyleOptions.rst
  clang/docs/ReleaseNotes.rst
  clang/include/clang/Format/Format.h
  clang/lib/Format/Format.cpp
  clang/lib/Format/FormatToken.h
  clang/lib/Format/TokenAnnotator.cpp
  clang/unittests/Format/FormatTest.cpp

Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -12701,6 +12701,17 @@
InvertedSpaceStyle);
 }
 
+TEST_F(FormatTest, ConfigurableSpaceBeforeForLoopSemiColon) {
+  FormatStyle NoSpaceStyle = getLLVMStyle();
+  verifyFormat("for (i = 0; i < 10; ++i) {\n}", NoSpaceStyle);
+  verifyFormat("for (int i = 0; auto a: b) {\n}", NoSpaceStyle);
+
+  FormatStyle Space = getLLVMStyle();
+  Space.SpaceBeforeForLoopSemiColon = true;
+  verifyFormat("for (i = 0 ; i < 10 ; ++i) {\n}", Space);
+  verifyFormat("for (int i = 0 ; auto a: b) {\n}", Space);
+}
+
 TEST_F(FormatTest, ConfigurableSpaceAroundPointerQualifiers) {
   FormatStyle Style = getLLVMStyle();
 
@@ -15610,6 +15621,7 @@
   CHECK_PARSE_BOOL(SpaceBeforeCaseColon);
   CHECK_PARSE_BOOL(SpaceBeforeCpp11BracedList);
   CHECK_PARSE_BOOL(SpaceBeforeCtorInitializerColon);
+  CHECK_PARSE_BOOL(SpaceBeforeForLoopSemiColon);
   CHECK_PARSE_BOOL(SpaceBeforeInheritanceColon);
   CHECK_PARSE_BOOL(SpaceBeforeRangeBasedForLoopColon);
   CHECK_PARSE_BOOL(SpaceBeforeSquareBrackets);
Index: clang/lib/Format/TokenAnnotator.cpp
===
--- clang/lib/Format/TokenAnnotator.cpp
+++ clang/lib/Format/TokenAnnotator.cpp
@@ -,6 +,10 @@
 parseCSharpGenericTypeConstraint();
   }
   break;
+case tok::semi:
+  if (Contexts.back().ColonIsForRangeExpr)
+Tok->setType(TT_ForLoopSemiColon);
+  break;
 default:
   break;
 }
@@ -3345,6 +3349,8 @@
   if (Right.is(TT_RangeBasedForLoopColon) &&
   !Style.SpaceBeforeRangeBasedForLoopColon)
 return false;
+  if (Right.is(TT_ForLoopSemiColon) && Style.SpaceBeforeForLoopSemiColon)
+return true;
   if (Left.is(TT_BitFieldColon))
 return Style.BitFieldColonSpacing == FormatStyle::BFCS_Both ||
Style.BitFieldColonSpacing == FormatStyle::BFCS_After;
@@ -3995,6 +4001,8 @@
 return true;
   if (Right.is(TT_RangeBasedForLoopColon))
 return false;
+  if (Right.is(TT_ForLoopSemiColon))
+return false;
   if (Left.is(TT_TemplateCloser) && Right.is(TT_TemplateOpener))
 return true;
   if (Left.isOneOf(TT_TemplateCloser, TT_UnaryOperator) ||
Index: clang/lib/Format/FormatToken.h
===
--- clang/lib/Format/FormatToken.h
+++ clang/lib/Format/FormatToken.h
@@ -46,6 +46,7 @@
   TYPE(DesignatedInitializerLSquare)   \
   TYPE(DesignatedInitializerPeriod)\
   TYPE(DictLiteral)\
+  TYPE(ForLoopSemiColon)   \
   TYPE(ForEachMacro)   \
   TYPE(FunctionAnnotationRParen)   \
   TYPE(FunctionDeclarationName)\
Index: clang/lib/Format/Format.cpp
===
--- clang/lib/Format/Format.cpp
+++ clang/lib/Format/Format.cpp
@@ -657,6 +657,8 @@
Style.SpaceBeforeCpp11BracedList);
 IO.mapOptional("SpaceBeforeCtorInitializerColon",
Style.SpaceBeforeCtorInitializerColon);
+IO.mapOptional("SpaceBeforeForLoopSemiColon",
+   Style.SpaceBeforeForLoopSemiColon);
 IO.mapOptional("SpaceBeforeInheritanceColon",
Style.SpaceBeforeInheritanceColon);
 IO.mapOptional("SpaceBeforeParens", Style.SpaceBeforeParens);
@@ -1026,6 +1028,7 @@
   LLVMStyle.SpaceAroundPointerQualifiers = FormatStyle::SAPQ_Default;
   LLVMStyle.SpaceBeforeCaseColon = false;
   LLVMStyle.SpaceBeforeCtorInitializerColon = true;
+  LLVMStyle.SpaceBeforeForLoopSemiColon = false;
   LLVMStyle.SpaceBeforeInheritanceColon = true;
   LLVMStyle.SpaceBeforeParens = FormatStyle::SBPO_ControlStatements;
   LLVMStyle.SpaceBeforeRangeBasedForLoopColon = true;
Index: clang/include/clang/Format/Format.h
===
--- clang/include/clang/Format/Format.h
+++ clang/include/clang/Format/Format.h
@@ -2835,6 +2835,13 @@
   /// \endcode
   bool SpaceBeforeCtorInitializerColon;
 
+  /// If ``false``, spaces will be removed before semi-colons in for loops.
+  /// 

[PATCH] D98363: [Sema] Fold VLA types in compound literals to constant arrays.

2021-03-15 Thread Eli Friedman via Phabricator via cfe-commits
efriedma added inline comments.



Comment at: clang/test/Sema/vla.c:134
+  // expected-warning@+1{{variable length array folded to constant array as an 
extension}}
+  char (*a9)[] = (char[2][ksize]) {{1,2,3,4},{4,3,2,1}};
+

aaron.ballman wrote:
> efriedma wrote:
> > aaron.ballman wrote:
> > > efriedma wrote:
> > > > aaron.ballman wrote:
> > > > > Doesn't this violate the constraints in C17 6.5.2.5p1, "The type name 
> > > > > shall specify a complete object type or an array of unknown size, but 
> > > > > not a variable-length array type"?
> > > > Yes, this is a constraint violation.  This patch downgrades the error 
> > > > to a warning, for compatibility with older versions of clang.
> > > It was an error in older versions of Clang, so downgrading it to a 
> > > warning can't make code *more* compatible with older versions. This also 
> > > makes it harder to port C code to other compilers because Clang happily 
> > > accepts code that the C standard says should be rejected.
> > > 
> > > I'm not strongly opposed to the change, but I also don't like ignoring 
> > > constraint violations in the standard as that comes awfully close to what 
> > > `-fpermissive` does (and at least with that awful flag you have to opt 
> > > *into* the less strictly conforming behavior instead of getting it by 
> > > default as with extensions).
> > > 
> > > I'm curious if @rsmith has thoughts here?
> > > It was an error in older versions of Clang
> > 
> > https://godbolt.org/z/rvbffY
> Oh, I hadn't realized this changed *that* recently! Is this breaking some 
> significant amounts of code now that we err on it (or regressing performance 
> by not folding the VLA)?
> 
> My point still stands about disliking when we ignore constraint violations. 
> To expound a bit, in this particular case, I think the standard is being 
> over-constraining because we reasonably *can* fold this to a more efficient 
> form. Normally, I'd suggest filing a DR with WG14 over this and treating the 
> constraint as UB we can extend. However, I think the "solution" that comes 
> out of WG14 would (likely) be to make compound literal expressions of VLA 
> types be undefined behavior rather than a constraint violation (because I 
> don't see many other options in the standard wording for a more targeted fix 
> to allow *just* this safe usage). Given the security concerns around misuse 
> of VLAs already, I think that would be a worse world to live in even if it 
> gets us what we want with this specific case in mind. This is where my 
> caution is coming from. Knowing a bit more about the experience in the 
> proprietary code bases would be helpful, if it's something you can share more 
> details about.
The pattern I saw looked something like the following, at global scope, where 
it couldn't really be confused for a VLA:

```
const int x = 2;
int *p = (int[x]){0};
```

As for the frequency of it showing up, I think I got confused.  Looking again, 
there were multiple codebases with new -Wgnu-folding-constant warnings, but 
only one codebase with this specific construct.  So that makes the argument a 
bit weaker.

That said, we're doing this folding for variables already, so extending it to 
compound literals doesn't seem like a big deal.  And the warning is on by 
default.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98363

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


[PATCH] D98665: Correct Doxygen syntax for inline code

2021-03-15 Thread Aaron Puchert via Phabricator via cfe-commits
aaronpuchert created this revision.
aaronpuchert added reviewers: george.karpenkov, gribozavr2.
Herald added subscribers: dexonsmith, martong.
Herald added a reviewer: aaron.ballman.
aaronpuchert requested review of this revision.
Herald added projects: clang, LLVM.
Herald added subscribers: llvm-commits, cfe-commits.

There is no syntax like {@code ...} in Doxygen, @code is a block command
that ends with @endcode, and generally these are not enclosed in braces.
The correct syntax for inline code snippets is @c .


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D98665

Files:
  clang/include/clang/Analysis/AnyCall.h
  clang/include/clang/Analysis/RetainSummaryManager.h
  clang/lib/Analysis/RetainSummaryManager.cpp
  clang/lib/Sema/SemaDeclAttr.cpp
  clang/lib/StaticAnalyzer/Checkers/NonnullGlobalConstantsChecker.cpp
  clang/lib/StaticAnalyzer/Checkers/ObjCAutoreleaseWriteChecker.cpp
  
clang/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountDiagnostics.cpp
  clang/lib/StaticAnalyzer/Checkers/RunLoopAutoreleaseLeakChecker.cpp
  clang/lib/StaticAnalyzer/Core/BugReporter.cpp
  clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
  clang/lib/StaticAnalyzer/Core/ExprEngine.cpp
  clang/lib/StaticAnalyzer/Core/PlistDiagnostics.cpp
  llvm/include/llvm/Support/GraphWriter.h

Index: llvm/include/llvm/Support/GraphWriter.h
===
--- llvm/include/llvm/Support/GraphWriter.h
+++ llvm/include/llvm/Support/GraphWriter.h
@@ -318,8 +318,8 @@
 
 std::string createGraphFilename(const Twine , int );
 
-/// Writes graph into a provided {@code Filename}.
-/// If {@code Filename} is empty, generates a random one.
+/// Writes graph into a provided @c Filename.
+/// If @c Filename is empty, generates a random one.
 /// \return The resulting filename, or an empty string if writing
 /// failed.
 template 
Index: clang/lib/StaticAnalyzer/Core/PlistDiagnostics.cpp
===
--- clang/lib/StaticAnalyzer/Core/PlistDiagnostics.cpp
+++ clang/lib/StaticAnalyzer/Core/PlistDiagnostics.cpp
@@ -157,8 +157,8 @@
 
 } // end of anonymous namespace
 
-/// Print coverage information to output stream {@code o}.
-/// May modify the used list of files {@code Fids} by inserting new ones.
+/// Print coverage information to output stream @c o.
+/// May modify the used list of files @c Fids by inserting new ones.
 static void printCoverage(const PathDiagnostic *D,
   unsigned InputIndentLevel,
   SmallVectorImpl ,
@@ -484,8 +484,8 @@
 // Static function definitions.
 //===--===//
 
-/// Print coverage information to output stream {@code o}.
-/// May modify the used list of files {@code Fids} by inserting new ones.
+/// Print coverage information to output stream @c o.
+/// May modify the used list of files @c Fids by inserting new ones.
 static void printCoverage(const PathDiagnostic *D,
   unsigned InputIndentLevel,
   SmallVectorImpl ,
Index: clang/lib/StaticAnalyzer/Core/ExprEngine.cpp
===
--- clang/lib/StaticAnalyzer/Core/ExprEngine.cpp
+++ clang/lib/StaticAnalyzer/Core/ExprEngine.cpp
@@ -3139,8 +3139,8 @@
 
   /// \p PreCallback: callback before break.
   /// \p PostCallback: callback after break.
-  /// \p Stop: stop iteration if returns {@code true}
-  /// \return Whether {@code Stop} ever returned {@code true}.
+  /// \p Stop: stop iteration if returns @c true
+  /// \return Whether @c Stop ever returned @c true.
   static bool traverseHiddenNodes(
   const ExplodedNode *N,
   llvm::function_ref PreCallback,
Index: clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
===
--- clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
+++ clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
@@ -1846,7 +1846,7 @@
   return nullptr;
 }
 
-/// \return A subexpression of {@code Ex} which represents the
+/// \return A subexpression of @c Ex which represents the
 /// expression-of-interest.
 static const Expr *peelOffOuterExpr(const Expr *Ex,
 const ExplodedNode *N) {
Index: clang/lib/StaticAnalyzer/Core/BugReporter.cpp
===
--- clang/lib/StaticAnalyzer/Core/BugReporter.cpp
+++ clang/lib/StaticAnalyzer/Core/BugReporter.cpp
@@ -2738,8 +2738,8 @@
 }
 
 /// Generate notes from all visitors.
-/// Notes associated with {@code ErrorNode} are generated using
-/// {@code getEndPath}, and the rest are generated with {@code VisitNode}.
+/// Notes associated with @c ErrorNode are generated using
+/// @c getEndPath, and the rest are generated with @c VisitNode.
 static std::unique_ptr
 generateVisitorsDiagnostics(PathSensitiveBugReport 

[PATCH] D98363: [Sema] Fold VLA types in compound literals to constant arrays.

2021-03-15 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith added inline comments.



Comment at: clang/test/Sema/vla.c:134
+  // expected-warning@+1{{variable length array folded to constant array as an 
extension}}
+  char (*a9)[] = (char[2][ksize]) {{1,2,3,4},{4,3,2,1}};
+

aaron.ballman wrote:
> efriedma wrote:
> > aaron.ballman wrote:
> > > efriedma wrote:
> > > > aaron.ballman wrote:
> > > > > Doesn't this violate the constraints in C17 6.5.2.5p1, "The type name 
> > > > > shall specify a complete object type or an array of unknown size, but 
> > > > > not a variable-length array type"?
> > > > Yes, this is a constraint violation.  This patch downgrades the error 
> > > > to a warning, for compatibility with older versions of clang.
> > > It was an error in older versions of Clang, so downgrading it to a 
> > > warning can't make code *more* compatible with older versions. This also 
> > > makes it harder to port C code to other compilers because Clang happily 
> > > accepts code that the C standard says should be rejected.
> > > 
> > > I'm not strongly opposed to the change, but I also don't like ignoring 
> > > constraint violations in the standard as that comes awfully close to what 
> > > `-fpermissive` does (and at least with that awful flag you have to opt 
> > > *into* the less strictly conforming behavior instead of getting it by 
> > > default as with extensions).
> > > 
> > > I'm curious if @rsmith has thoughts here?
> > > It was an error in older versions of Clang
> > 
> > https://godbolt.org/z/rvbffY
> Oh, I hadn't realized this changed *that* recently! Is this breaking some 
> significant amounts of code now that we err on it (or regressing performance 
> by not folding the VLA)?
> 
> My point still stands about disliking when we ignore constraint violations. 
> To expound a bit, in this particular case, I think the standard is being 
> over-constraining because we reasonably *can* fold this to a more efficient 
> form. Normally, I'd suggest filing a DR with WG14 over this and treating the 
> constraint as UB we can extend. However, I think the "solution" that comes 
> out of WG14 would (likely) be to make compound literal expressions of VLA 
> types be undefined behavior rather than a constraint violation (because I 
> don't see many other options in the standard wording for a more targeted fix 
> to allow *just* this safe usage). Given the security concerns around misuse 
> of VLAs already, I think that would be a worse world to live in even if it 
> gets us what we want with this specific case in mind. This is where my 
> caution is coming from. Knowing a bit more about the experience in the 
> proprietary code bases would be helpful, if it's something you can share more 
> details about.
> Is this breaking some significant amounts of code now that we err on it (or 
> regressing performance by not folding the VLA)?

We only ever constant-fold VLAs to constant-length arrays in cases where a VLA 
would be invalid, so there's no regressing-performance concern. (We used to do 
such folding, but it resulted in our miscompiling certain testcases, which is 
why Clang's behavior changed recently.) As a result, there's no risk of someone 
seeing a surprise VLA here, that should have been a constraint violation.

Given the above, I don't think that changing this from a constraint violation 
to UB in the C standard would make a difference. Either way, I think a strictly 
conforming program cannot contain such a construct, and a conforming 
implementation can, as an extension, define the meaning of programs containing 
such a construct.

It's common for us to have conforming extensions that permit us to accept more 
real-world code. Accepting with an on-by-default warning is often the best 
tradeoff between accepting real-world code and diagnosing non-portable 
constructs, especially in cases where past versions of GCC (<= 4.4) and Clang 
accepted the code as an extension. I'm inclined to think that's the best we can 
do here.

If we want to more strongly discourage use of this extension (and I don't have 
any particular preferences on whether we should do so), we could promote the 
warning to `DefaultError` (but leave the extension in, so that people can still 
build legacy codebases), but I think we should do that consistently across all 
the places we fold VLAs to constant arrays, not only for compound literals.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98363

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


[PATCH] D98664: Fix crash on dumping AST containing constant initializer with ParenListExpr

2021-03-15 Thread Aaron Puchert via Phabricator via cfe-commits
aaronpuchert added inline comments.



Comment at: clang/test/AST/ast-dump-templates.cpp:71-73
+template  constexpr T var(0);
+// DUMP: VarDecl {{.*}}  col:35 var 'const T' constexpr 
callinit
+// DUMP-NEXT: ParenListExpr {{.*}}  'void'

This is what's currently crashing.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98664

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


[PATCH] D98664: Fix crash on dumping AST containing constant initializer with ParenListExpr

2021-03-15 Thread Aaron Puchert via Phabricator via cfe-commits
aaronpuchert created this revision.
aaronpuchert added reviewers: aaron.ballman, riccibruno, rsmith.
Herald added a subscriber: kristof.beyls.
aaronpuchert requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

The crash was introduced by D83183  
(f63e3ea558bb 
) as far 
as I can tell.
The problem is that ParenListExprs have a  which the
expression evaluation, specifically Expr::EvaluateAsInitializer,
couldn't deal with. One solution would have been to make the evaluation
logic capable of dealing with NULL TYPE, but I rather decided to
harmonize ParenListExprs with InitListExprs, which always have a void
type by default.

Actually I think that the dependent type would not be a bad fit here:
although the type of the contained expression might not be dependent,
the type of the expression itself might be. But this seems like a bigger
change, the assumption that InitListExprs have void type seems to be
baked into quite a few places.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D98664

Files:
  clang/include/clang/AST/Expr.h
  clang/lib/AST/Expr.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/test/AST/ast-dump-expr-json.cpp
  clang/test/AST/ast-dump-expr.cpp
  clang/test/AST/ast-dump-lambda.cpp
  clang/test/AST/ast-dump-openmp-begin-declare-variant_template_3.cpp
  clang/test/AST/ast-dump-recovery.cpp
  clang/test/AST/ast-dump-templates.cpp

Index: clang/test/AST/ast-dump-templates.cpp
===
--- clang/test/AST/ast-dump-templates.cpp
+++ clang/test/AST/ast-dump-templates.cpp
@@ -67,3 +67,7 @@
   template A(T) -> A;
   // CHECK1: template  A(T) -> A;
 }
+
+template  constexpr T var(0);
+// DUMP: VarDecl {{.*}}  col:35 var 'const T' constexpr callinit
+// DUMP-NEXT: ParenListExpr {{.*}}  'void'
Index: clang/test/AST/ast-dump-recovery.cpp
===
--- clang/test/AST/ast-dump-recovery.cpp
+++ clang/test/AST/ast-dump-recovery.cpp
@@ -173,7 +173,7 @@
   // CHECK-NEDT:   `-DeclRefExpr {{.*}} 'x'
   Bar a3{x};
   // CHECK: `-VarDecl {{.*}} a4 'Bar'
-  // CHECK-NEXT: `-ParenListExpr {{.*}} 'NULL TYPE' contains-errors
+  // CHECK-NEXT: `-ParenListExpr {{.*}} contains-errors
   // CHECK-NEXT:  `-RecoveryExpr {{.*}} contains-errors
   // CHECK-NEXT:   `-UnresolvedLookupExpr {{.*}} 'invalid'
   Bar a4(invalid());
Index: clang/test/AST/ast-dump-openmp-begin-declare-variant_template_3.cpp
===
--- clang/test/AST/ast-dump-openmp-begin-declare-variant_template_3.cpp
+++ clang/test/AST/ast-dump-openmp-begin-declare-variant_template_3.cpp
@@ -115,7 +115,7 @@
 // CHECK-NEXT: | |   | `-VarDecl [[ADDR_45:0x[a-z0-9]*]]  col:10 referenced t 'double'
 // CHECK-NEXT: | |   |-DeclStmt [[ADDR_46:0x[a-z0-9]*]] 
 // CHECK-NEXT: | |   | `-VarDecl [[ADDR_47:0x[a-z0-9]*]]  col:8 q 'S' callinit
-// CHECK-NEXT: | |   |   `-ParenListExpr [[ADDR_48:0x[a-z0-9]*]]  'NULL TYPE'
+// CHECK-NEXT: | |   |   `-ParenListExpr [[ADDR_48:0x[a-z0-9]*]]  'void'
 // CHECK-NEXT: | |   | |-IntegerLiteral [[ADDR_49:0x[a-z0-9]*]]  'int' 1
 // CHECK-NEXT: | |   | `-UnaryOperator [[ADDR_50:0x[a-z0-9]*]]  'double *' prefix '&' cannot overflow
 // CHECK-NEXT: | |   |   `-DeclRefExpr [[ADDR_51:0x[a-z0-9]*]]  'double' {{.*}}Var [[ADDR_45]] 't' 'double'
@@ -150,7 +150,7 @@
 // CHECK-NEXT: | |   | `-VarDecl [[ADDR_73:0x[a-z0-9]*]]  col:5 referenced t 'T'
 // CHECK-NEXT: | |   |-DeclStmt [[ADDR_74:0x[a-z0-9]*]] 
 // CHECK-NEXT: | |   | `-VarDecl [[ADDR_75:0x[a-z0-9]*]]  col:8 q 'S' callinit
-// CHECK-NEXT: | |   |   `-ParenListExpr [[ADDR_76:0x[a-z0-9]*]]  'NULL TYPE'
+// CHECK-NEXT: | |   |   `-ParenListExpr [[ADDR_76:0x[a-z0-9]*]]  'void'
 // CHECK-NEXT: | |   | |-IntegerLiteral [[ADDR_77:0x[a-z0-9]*]]  'int' 0
 // CHECK-NEXT: | |   | `-UnaryOperator [[ADDR_78:0x[a-z0-9]*]]  '' prefix '&' cannot overflow
 // CHECK-NEXT: | |   |   `-DeclRefExpr [[ADDR_79:0x[a-z0-9]*]]  'T' {{.*}}Var [[ADDR_73]] 't' 'T'
@@ -186,7 +186,7 @@
 // CHECK-NEXT: | | `-VarDecl [[ADDR_102:0x[a-z0-9]*]]  col:10 referenced t 'double'
 // CHECK-NEXT: | |-DeclStmt [[ADDR_103:0x[a-z0-9]*]] 
 // CHECK-NEXT: | | `-VarDecl [[ADDR_104:0x[a-z0-9]*]]  col:8 q 'S' callinit
-// CHECK-NEXT: | |   `-ParenListExpr [[ADDR_105:0x[a-z0-9]*]]  'NULL TYPE'
+// CHECK-NEXT: | |   `-ParenListExpr [[ADDR_105:0x[a-z0-9]*]]  'void'
 // CHECK-NEXT: | | |-FloatingLiteral [[ADDR_106:0x[a-z0-9]*]]  'double' 2.00e+00
 // CHECK-NEXT: | | `-UnaryOperator [[ADDR_107:0x[a-z0-9]*]]  'double *' prefix '&' cannot overflow
 // CHECK-NEXT: | |   `-DeclRefExpr [[ADDR_108:0x[a-z0-9]*]]  'double' {{.*}}Var [[ADDR_102]] 't' 'double'
Index: clang/test/AST/ast-dump-lambda.cpp

[PATCH] D98472: Emit inline implementation of __builtin__wmemchr on MSVCRT platforms.

2021-03-15 Thread Amy Huang via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGf5352dd9dab1: Emit inline implementation of 
__builtin__wmemchr on MSVCRT platforms. (authored by akhuang).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98472

Files:
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/test/CodeGen/wmemchr.c


Index: clang/test/CodeGen/wmemchr.c
===
--- /dev/null
+++ clang/test/CodeGen/wmemchr.c
@@ -0,0 +1,32 @@
+// RUN: %clang_cc1 %s -triple x86_64-pc-win32 -emit-llvm -o - | FileCheck %s
+
+typedef __SIZE_TYPE__ size_t;
+typedef __WCHAR_TYPE__ wchar_t;
+
+const wchar_t *wmemchr_test(const wchar_t *s, const wchar_t c, size_t n) {
+  // CHECK-LABEL: define dso_local i16* @wmemchr_test
+  // CHECK: [[S:%.*]] = load
+  // CHECK: [[C:%.*]] = load
+  // CHECK: [[N:%.*]] = load
+  // CHECK: [[N0:%.*]] = icmp eq i64 [[N]], 0
+  // CHECK: br i1 [[N0]], label %[[EXIT:.*]], label %[[EQ:.*]]
+
+  // CHECK: [[EQ]]:
+  // CHECK: [[SP:%.*]] = phi i16* [ [[S]], %[[ENTRY:.*]] ], [ [[SN:.*]], 
%[[NEXT:.*]] ]
+  // CHECK: [[NP:%.*]] = phi i64 [ [[N]], %[[ENTRY]] ], [ [[NN:.*]], %[[NEXT]] 
]
+  // CHECK: [[SL:%.*]] = load i16, i16* [[SP]], align 2
+  // CHECK: [[RES:%.*]] = getelementptr inbounds i16, i16* [[SP]], i32 0
+  // CHECK: [[CMPEQ:%.*]] = icmp eq i16 [[SL]], [[C]]
+  // CHECK: br i1 [[CMPEQ]], label %[[EXIT]], label %[[LT:.*]]
+
+  // CHECK: [[NEXT]]:
+  // CHECK: [[SN]] = getelementptr inbounds i16, i16* [[SP]], i32 1
+  // CHECK: [[NN]] = sub i64 [[NP]], 1
+  // CHECK: [[NN0:%.*]] = icmp eq i64 [[NN]], 0
+  // CHECK: br i1 [[NN0]], label %[[EXIT]], label %[[EQ]]
+  //
+  // CHECK: [[EXIT]]:
+  // CHECK: [[RV:%.*]] = phi i16* [ null, %[[ENTRY]] ], [ null, %[[NEXT]] ], [ 
[[RES]], %[[EQ]] ] 
+  // CHECK: ret i16* [[RV]]
+  return __builtin_wmemchr(s, c, n);
+}
Index: clang/lib/CodeGen/CGBuiltin.cpp
===
--- clang/lib/CodeGen/CGBuiltin.cpp
+++ clang/lib/CodeGen/CGBuiltin.cpp
@@ -3380,6 +3380,52 @@
 Builder.CreateMemSet(Dest, ByteVal, SizeVal, false);
 return RValue::get(Dest.getPointer());
   }
+  case Builtin::BI__builtin_wmemchr: {
+// The MSVC runtime library does not provide a definition of wmemchr, so we
+// need an inline implementation.
+if (!getTarget().getTriple().isOSMSVCRT())
+  break;
+
+llvm::Type *WCharTy = ConvertType(getContext().WCharTy);
+Value *Str = EmitScalarExpr(E->getArg(0));
+Value *Chr = EmitScalarExpr(E->getArg(1));
+Value *Size = EmitScalarExpr(E->getArg(2));
+
+BasicBlock *Entry = Builder.GetInsertBlock();
+BasicBlock *CmpEq = createBasicBlock("wmemchr.eq");
+BasicBlock *Next = createBasicBlock("wmemchr.next");
+BasicBlock *Exit = createBasicBlock("wmemchr.exit");
+Value *SizeEq0 = Builder.CreateICmpEQ(Size, ConstantInt::get(SizeTy, 0));
+Builder.CreateCondBr(SizeEq0, Exit, CmpEq);
+
+EmitBlock(CmpEq);
+PHINode *StrPhi = Builder.CreatePHI(Str->getType(), 2);
+StrPhi->addIncoming(Str, Entry);
+PHINode *SizePhi = Builder.CreatePHI(SizeTy, 2);
+SizePhi->addIncoming(Size, Entry);
+CharUnits WCharAlign =
+getContext().getTypeAlignInChars(getContext().WCharTy);
+Value *StrCh = Builder.CreateAlignedLoad(WCharTy, StrPhi, WCharAlign);
+Value *FoundChr = Builder.CreateConstInBoundsGEP1_32(WCharTy, StrPhi, 0);
+Value *StrEqChr = Builder.CreateICmpEQ(StrCh, Chr);
+Builder.CreateCondBr(StrEqChr, Exit, Next);
+
+EmitBlock(Next);
+Value *NextStr = Builder.CreateConstInBoundsGEP1_32(WCharTy, StrPhi, 1);
+Value *NextSize = Builder.CreateSub(SizePhi, ConstantInt::get(SizeTy, 1));
+Value *NextSizeEq0 =
+Builder.CreateICmpEQ(NextSize, ConstantInt::get(SizeTy, 0));
+Builder.CreateCondBr(NextSizeEq0, Exit, CmpEq);
+StrPhi->addIncoming(NextStr, Next);
+SizePhi->addIncoming(NextSize, Next);
+
+EmitBlock(Exit);
+PHINode *Ret = Builder.CreatePHI(Str->getType(), 3);
+Ret->addIncoming(llvm::Constant::getNullValue(Str->getType()), Entry);
+Ret->addIncoming(llvm::Constant::getNullValue(Str->getType()), Next);
+Ret->addIncoming(FoundChr, CmpEq);
+return RValue::get(Ret);
+  }
   case Builtin::BI__builtin_wmemcmp: {
 // The MSVC runtime library does not provide a definition of wmemcmp, so we
 // need an inline implementation.


Index: clang/test/CodeGen/wmemchr.c
===
--- /dev/null
+++ clang/test/CodeGen/wmemchr.c
@@ -0,0 +1,32 @@
+// RUN: %clang_cc1 %s -triple x86_64-pc-win32 -emit-llvm -o - | FileCheck %s
+
+typedef __SIZE_TYPE__ size_t;
+typedef __WCHAR_TYPE__ wchar_t;
+
+const wchar_t *wmemchr_test(const wchar_t *s, const wchar_t c, size_t n) {
+  // CHECK-LABEL: define dso_local i16* 

[clang] f5352dd - Emit inline implementation of __builtin__wmemchr on MSVCRT platforms.

2021-03-15 Thread Amy Huang via cfe-commits

Author: Amy Huang
Date: 2021-03-15T15:30:55-07:00
New Revision: f5352dd9dab1ee8a2ae19a3fca3111c8b5de8ce2

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

LOG: Emit inline implementation of __builtin__wmemchr on MSVCRT platforms.

The MSVC runtime library doesn't have a definition for wmemchr,
so provide an inline implementation.

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

Added: 
clang/test/CodeGen/wmemchr.c

Modified: 
clang/lib/CodeGen/CGBuiltin.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp
index 9827311e07d8..e5778c0c78f7 100644
--- a/clang/lib/CodeGen/CGBuiltin.cpp
+++ b/clang/lib/CodeGen/CGBuiltin.cpp
@@ -3380,6 +3380,52 @@ RValue CodeGenFunction::EmitBuiltinExpr(const GlobalDecl 
GD, unsigned BuiltinID,
 Builder.CreateMemSet(Dest, ByteVal, SizeVal, false);
 return RValue::get(Dest.getPointer());
   }
+  case Builtin::BI__builtin_wmemchr: {
+// The MSVC runtime library does not provide a definition of wmemchr, so we
+// need an inline implementation.
+if (!getTarget().getTriple().isOSMSVCRT())
+  break;
+
+llvm::Type *WCharTy = ConvertType(getContext().WCharTy);
+Value *Str = EmitScalarExpr(E->getArg(0));
+Value *Chr = EmitScalarExpr(E->getArg(1));
+Value *Size = EmitScalarExpr(E->getArg(2));
+
+BasicBlock *Entry = Builder.GetInsertBlock();
+BasicBlock *CmpEq = createBasicBlock("wmemchr.eq");
+BasicBlock *Next = createBasicBlock("wmemchr.next");
+BasicBlock *Exit = createBasicBlock("wmemchr.exit");
+Value *SizeEq0 = Builder.CreateICmpEQ(Size, ConstantInt::get(SizeTy, 0));
+Builder.CreateCondBr(SizeEq0, Exit, CmpEq);
+
+EmitBlock(CmpEq);
+PHINode *StrPhi = Builder.CreatePHI(Str->getType(), 2);
+StrPhi->addIncoming(Str, Entry);
+PHINode *SizePhi = Builder.CreatePHI(SizeTy, 2);
+SizePhi->addIncoming(Size, Entry);
+CharUnits WCharAlign =
+getContext().getTypeAlignInChars(getContext().WCharTy);
+Value *StrCh = Builder.CreateAlignedLoad(WCharTy, StrPhi, WCharAlign);
+Value *FoundChr = Builder.CreateConstInBoundsGEP1_32(WCharTy, StrPhi, 0);
+Value *StrEqChr = Builder.CreateICmpEQ(StrCh, Chr);
+Builder.CreateCondBr(StrEqChr, Exit, Next);
+
+EmitBlock(Next);
+Value *NextStr = Builder.CreateConstInBoundsGEP1_32(WCharTy, StrPhi, 1);
+Value *NextSize = Builder.CreateSub(SizePhi, ConstantInt::get(SizeTy, 1));
+Value *NextSizeEq0 =
+Builder.CreateICmpEQ(NextSize, ConstantInt::get(SizeTy, 0));
+Builder.CreateCondBr(NextSizeEq0, Exit, CmpEq);
+StrPhi->addIncoming(NextStr, Next);
+SizePhi->addIncoming(NextSize, Next);
+
+EmitBlock(Exit);
+PHINode *Ret = Builder.CreatePHI(Str->getType(), 3);
+Ret->addIncoming(llvm::Constant::getNullValue(Str->getType()), Entry);
+Ret->addIncoming(llvm::Constant::getNullValue(Str->getType()), Next);
+Ret->addIncoming(FoundChr, CmpEq);
+return RValue::get(Ret);
+  }
   case Builtin::BI__builtin_wmemcmp: {
 // The MSVC runtime library does not provide a definition of wmemcmp, so we
 // need an inline implementation.

diff  --git a/clang/test/CodeGen/wmemchr.c b/clang/test/CodeGen/wmemchr.c
new file mode 100644
index ..3ff3fba34043
--- /dev/null
+++ b/clang/test/CodeGen/wmemchr.c
@@ -0,0 +1,32 @@
+// RUN: %clang_cc1 %s -triple x86_64-pc-win32 -emit-llvm -o - | FileCheck %s
+
+typedef __SIZE_TYPE__ size_t;
+typedef __WCHAR_TYPE__ wchar_t;
+
+const wchar_t *wmemchr_test(const wchar_t *s, const wchar_t c, size_t n) {
+  // CHECK-LABEL: define dso_local i16* @wmemchr_test
+  // CHECK: [[S:%.*]] = load
+  // CHECK: [[C:%.*]] = load
+  // CHECK: [[N:%.*]] = load
+  // CHECK: [[N0:%.*]] = icmp eq i64 [[N]], 0
+  // CHECK: br i1 [[N0]], label %[[EXIT:.*]], label %[[EQ:.*]]
+
+  // CHECK: [[EQ]]:
+  // CHECK: [[SP:%.*]] = phi i16* [ [[S]], %[[ENTRY:.*]] ], [ [[SN:.*]], 
%[[NEXT:.*]] ]
+  // CHECK: [[NP:%.*]] = phi i64 [ [[N]], %[[ENTRY]] ], [ [[NN:.*]], %[[NEXT]] 
]
+  // CHECK: [[SL:%.*]] = load i16, i16* [[SP]], align 2
+  // CHECK: [[RES:%.*]] = getelementptr inbounds i16, i16* [[SP]], i32 0
+  // CHECK: [[CMPEQ:%.*]] = icmp eq i16 [[SL]], [[C]]
+  // CHECK: br i1 [[CMPEQ]], label %[[EXIT]], label %[[LT:.*]]
+
+  // CHECK: [[NEXT]]:
+  // CHECK: [[SN]] = getelementptr inbounds i16, i16* [[SP]], i32 1
+  // CHECK: [[NN]] = sub i64 [[NP]], 1
+  // CHECK: [[NN0:%.*]] = icmp eq i64 [[NN]], 0
+  // CHECK: br i1 [[NN0]], label %[[EXIT]], label %[[EQ]]
+  //
+  // CHECK: [[EXIT]]:
+  // CHECK: [[RV:%.*]] = phi i16* [ null, %[[ENTRY]] ], [ null, %[[NEXT]] ], [ 
[[RES]], %[[EQ]] ] 
+  // CHECK: ret i16* [[RV]]
+  return __builtin_wmemchr(s, c, n);
+}



___
cfe-commits 

[PATCH] D98472: Emit inline implementation of __builtin__wmemchr on MSVCRT platforms.

2021-03-15 Thread Amy Huang via Phabricator via cfe-commits
akhuang updated this revision to Diff 330826.
akhuang marked an inline comment as done.
akhuang added a comment.

add CHECK line to test


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98472

Files:
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/test/CodeGen/wmemchr.c


Index: clang/test/CodeGen/wmemchr.c
===
--- /dev/null
+++ clang/test/CodeGen/wmemchr.c
@@ -0,0 +1,32 @@
+// RUN: %clang_cc1 %s -triple x86_64-pc-win32 -emit-llvm -o - | FileCheck %s
+
+typedef __SIZE_TYPE__ size_t;
+typedef __WCHAR_TYPE__ wchar_t;
+
+const wchar_t *wmemchr_test(const wchar_t *s, const wchar_t c, size_t n) {
+  // CHECK-LABEL: define dso_local i16* @wmemchr_test
+  // CHECK: [[S:%.*]] = load
+  // CHECK: [[C:%.*]] = load
+  // CHECK: [[N:%.*]] = load
+  // CHECK: [[N0:%.*]] = icmp eq i64 [[N]], 0
+  // CHECK: br i1 [[N0]], label %[[EXIT:.*]], label %[[EQ:.*]]
+
+  // CHECK: [[EQ]]:
+  // CHECK: [[SP:%.*]] = phi i16* [ [[S]], %[[ENTRY:.*]] ], [ [[SN:.*]], 
%[[NEXT:.*]] ]
+  // CHECK: [[NP:%.*]] = phi i64 [ [[N]], %[[ENTRY]] ], [ [[NN:.*]], %[[NEXT]] 
]
+  // CHECK: [[SL:%.*]] = load i16, i16* [[SP]], align 2
+  // CHECK: [[RES:%.*]] = getelementptr inbounds i16, i16* [[SP]], i32 0
+  // CHECK: [[CMPEQ:%.*]] = icmp eq i16 [[SL]], [[C]]
+  // CHECK: br i1 [[CMPEQ]], label %[[EXIT]], label %[[LT:.*]]
+
+  // CHECK: [[NEXT]]:
+  // CHECK: [[SN]] = getelementptr inbounds i16, i16* [[SP]], i32 1
+  // CHECK: [[NN]] = sub i64 [[NP]], 1
+  // CHECK: [[NN0:%.*]] = icmp eq i64 [[NN]], 0
+  // CHECK: br i1 [[NN0]], label %[[EXIT]], label %[[EQ]]
+  //
+  // CHECK: [[EXIT]]:
+  // CHECK: [[RV:%.*]] = phi i16* [ null, %[[ENTRY]] ], [ null, %[[NEXT]] ], [ 
[[RES]], %[[EQ]] ] 
+  // CHECK: ret i16* [[RV]]
+  return __builtin_wmemchr(s, c, n);
+}
Index: clang/lib/CodeGen/CGBuiltin.cpp
===
--- clang/lib/CodeGen/CGBuiltin.cpp
+++ clang/lib/CodeGen/CGBuiltin.cpp
@@ -3380,6 +3380,52 @@
 Builder.CreateMemSet(Dest, ByteVal, SizeVal, false);
 return RValue::get(Dest.getPointer());
   }
+  case Builtin::BI__builtin_wmemchr: {
+// The MSVC runtime library does not provide a definition of wmemchr, so we
+// need an inline implementation.
+if (!getTarget().getTriple().isOSMSVCRT())
+  break;
+
+llvm::Type *WCharTy = ConvertType(getContext().WCharTy);
+Value *Str = EmitScalarExpr(E->getArg(0));
+Value *Chr = EmitScalarExpr(E->getArg(1));
+Value *Size = EmitScalarExpr(E->getArg(2));
+
+BasicBlock *Entry = Builder.GetInsertBlock();
+BasicBlock *CmpEq = createBasicBlock("wmemchr.eq");
+BasicBlock *Next = createBasicBlock("wmemchr.next");
+BasicBlock *Exit = createBasicBlock("wmemchr.exit");
+Value *SizeEq0 = Builder.CreateICmpEQ(Size, ConstantInt::get(SizeTy, 0));
+Builder.CreateCondBr(SizeEq0, Exit, CmpEq);
+
+EmitBlock(CmpEq);
+PHINode *StrPhi = Builder.CreatePHI(Str->getType(), 2);
+StrPhi->addIncoming(Str, Entry);
+PHINode *SizePhi = Builder.CreatePHI(SizeTy, 2);
+SizePhi->addIncoming(Size, Entry);
+CharUnits WCharAlign =
+getContext().getTypeAlignInChars(getContext().WCharTy);
+Value *StrCh = Builder.CreateAlignedLoad(WCharTy, StrPhi, WCharAlign);
+Value *FoundChr = Builder.CreateConstInBoundsGEP1_32(WCharTy, StrPhi, 0);
+Value *StrEqChr = Builder.CreateICmpEQ(StrCh, Chr);
+Builder.CreateCondBr(StrEqChr, Exit, Next);
+
+EmitBlock(Next);
+Value *NextStr = Builder.CreateConstInBoundsGEP1_32(WCharTy, StrPhi, 1);
+Value *NextSize = Builder.CreateSub(SizePhi, ConstantInt::get(SizeTy, 1));
+Value *NextSizeEq0 =
+Builder.CreateICmpEQ(NextSize, ConstantInt::get(SizeTy, 0));
+Builder.CreateCondBr(NextSizeEq0, Exit, CmpEq);
+StrPhi->addIncoming(NextStr, Next);
+SizePhi->addIncoming(NextSize, Next);
+
+EmitBlock(Exit);
+PHINode *Ret = Builder.CreatePHI(Str->getType(), 3);
+Ret->addIncoming(llvm::Constant::getNullValue(Str->getType()), Entry);
+Ret->addIncoming(llvm::Constant::getNullValue(Str->getType()), Next);
+Ret->addIncoming(FoundChr, CmpEq);
+return RValue::get(Ret);
+  }
   case Builtin::BI__builtin_wmemcmp: {
 // The MSVC runtime library does not provide a definition of wmemcmp, so we
 // need an inline implementation.


Index: clang/test/CodeGen/wmemchr.c
===
--- /dev/null
+++ clang/test/CodeGen/wmemchr.c
@@ -0,0 +1,32 @@
+// RUN: %clang_cc1 %s -triple x86_64-pc-win32 -emit-llvm -o - | FileCheck %s
+
+typedef __SIZE_TYPE__ size_t;
+typedef __WCHAR_TYPE__ wchar_t;
+
+const wchar_t *wmemchr_test(const wchar_t *s, const wchar_t c, size_t n) {
+  // CHECK-LABEL: define dso_local i16* @wmemchr_test
+  // CHECK: [[S:%.*]] = load
+  // CHECK: [[C:%.*]] = load
+  // CHECK: [[N:%.*]] = load
+  // CHECK: [[N0:%.*]] = 

[PATCH] D97119: [flang][driver] Add options for -std=f2018

2021-03-15 Thread Arnamoy B via Phabricator via cfe-commits
arnamoy10 updated this revision to Diff 330823.
arnamoy10 added a comment.

Adding one more update that is probably required in semanticContext (inspired 
by f18), also updated test case to require flang-driver


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

https://reviews.llvm.org/D97119

Files:
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/ToolChains/Flang.cpp
  flang/include/flang/Frontend/CompilerInvocation.h
  flang/lib/Frontend/CompilerInvocation.cpp
  flang/test/Driver/driver-help-hidden.f90
  flang/test/Driver/driver-help.f90
  flang/test/Driver/std2018.f90

Index: flang/test/Driver/std2018.f90
===
--- /dev/null
+++ flang/test/Driver/std2018.f90
@@ -0,0 +1,35 @@
+! REQUIRES: new-flang-driver
+! Ensure argument -std=f2018 works as expected.
+
+!-
+! FRONTEND FLANG DRIVER (flang-new -fc1)
+!-
+! RUN: %flang_fc1 %s  2>&1 | FileCheck %s --allow-empty --check-prefix=WITHOUT
+! RUN: %flang_fc1 -std=f2018 %s  2>&1 | FileCheck %s --check-prefix=GIVEN
+! RUN: %flang_fc1 -pedantic %s  2>&1 | FileCheck %s --check-prefix=GIVEN
+! RUN: not %flang_fc1 -std=90 %s  2>&1 | FileCheck %s --check-prefix=WRONG
+
+!-
+! EXPECTED OUTPUT WITHOUT
+!-
+! WITHOUT-NOT: A DO loop should terminate with an END DO or CONTINUE
+
+!-
+! EXPECTED OUTPUT WITH
+!-
+! GIVEN: A DO loop should terminate with an END DO or CONTINUE
+
+!-
+! EXPECTED OUTPUT WITH WRONG
+!-
+! WRONG: Only -std=f2018 is allowed currently.
+
+subroutine foo2()
+do 01 m=1,2
+  select case (m)
+  case default
+print*, "default", m
+  case (1)
+print*, "start"
+01end select
+end subroutine
Index: flang/test/Driver/driver-help.f90
===
--- flang/test/Driver/driver-help.f90
+++ flang/test/Driver/driver-help.f90
@@ -45,6 +45,8 @@
 ! HELP-NEXT: -IAdd directory to the end of the list of include search paths
 ! HELP-NEXT: -module-dir   Put MODULE files in 
 ! HELP-NEXT: -o   Write output to 
+! HELP-NEXT: -pedantic  Warn on language extensions
+! HELP-NEXT: -std=   Language standard to compile for
 ! HELP-NEXT: -U  Undefine macro 
 ! HELP-NEXT: --version  Print version information
 ! HELP-NEXT: -Xflang   Pass  to the flang compiler
@@ -91,6 +93,8 @@
 ! HELP-FC1-NEXT: -IAdd directory to the end of the list of include search paths
 ! HELP-FC1-NEXT: -module-dir   Put MODULE files in 
 ! HELP-FC1-NEXT: -o   Write output to 
+! HELP-FC1-NEXT: -pedantic  Warn on language extensions
+! HELP-FC1-NEXT: -std=   Language standard to compile for
 ! HELP-FC1-NEXT: -test-io   Run the InputOuputTest action. Use for development and testing only.
 ! HELP-FC1-NEXT: -U  Undefine macro 
 ! HELP-FC1-NEXT: --version  Print version information
Index: flang/test/Driver/driver-help-hidden.f90
===
--- flang/test/Driver/driver-help-hidden.f90
+++ flang/test/Driver/driver-help-hidden.f90
@@ -45,6 +45,8 @@
 ! CHECK-NEXT: -IAdd directory to the end of the list of include search paths
 ! CHECK-NEXT: -module-dir   Put MODULE files in 
 ! CHECK-NEXT: -o  Write output to 
+! CHECK-NEXT: -pedantic  Warn on language extensions
+! CHECK-NEXT: -std=   Language standard to compile for
 ! CHECK-NEXT: -U  Undefine macro 
 ! CHECK-NEXT: --version Print version information
 ! CHECK-NEXT: -Xflang   Pass  to the flang compiler
Index: flang/lib/Frontend/CompilerInvocation.cpp
===
--- flang/lib/Frontend/CompilerInvocation.cpp
+++ flang/lib/Frontend/CompilerInvocation.cpp
@@ -368,6 +368,26 @@
 res.frontendOpts().features_.Enable(
 Fortran::common::LanguageFeature::OpenMP);
   }
+
+  //-fpedantic
+  if (args.hasArg(clang::driver::options::OPT_pedantic)) {
+res.set_EnableConformanceChecks();
+  }
+  // -std=f2018.  Current behaviour is same as -fpedantic
+  // TODO: Set proper options when more fortran standards
+  // are supported.
+  if (args.hasArg(clang::driver::options::OPT_std_EQ)) {
+auto standard = args.getLastArgValue(clang::driver::options::OPT_std_EQ);
+// We only allow f2018 as the given standard
+if (standard.equals("f2018")) {
+  res.set_EnableConformanceChecks();
+} else {
+  const unsigned diagID =
+  diags.getCustomDiagID(clang::DiagnosticsEngine::Error,
+  "Only -std=f2018 is 

[PATCH] D97462: [clang][cli] Round-trip cc1 arguments in assert builds

2021-03-15 Thread Duncan P. N. Exon Smith via Phabricator via cfe-commits
dexonsmith accepted this revision.
dexonsmith 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/D97462/new/

https://reviews.llvm.org/D97462

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


[PATCH] D98363: [Sema] Fold VLA types in compound literals to constant arrays.

2021-03-15 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: clang/test/Sema/vla.c:134
+  // expected-warning@+1{{variable length array folded to constant array as an 
extension}}
+  char (*a9)[] = (char[2][ksize]) {{1,2,3,4},{4,3,2,1}};
+

efriedma wrote:
> aaron.ballman wrote:
> > efriedma wrote:
> > > aaron.ballman wrote:
> > > > Doesn't this violate the constraints in C17 6.5.2.5p1, "The type name 
> > > > shall specify a complete object type or an array of unknown size, but 
> > > > not a variable-length array type"?
> > > Yes, this is a constraint violation.  This patch downgrades the error to 
> > > a warning, for compatibility with older versions of clang.
> > It was an error in older versions of Clang, so downgrading it to a warning 
> > can't make code *more* compatible with older versions. This also makes it 
> > harder to port C code to other compilers because Clang happily accepts code 
> > that the C standard says should be rejected.
> > 
> > I'm not strongly opposed to the change, but I also don't like ignoring 
> > constraint violations in the standard as that comes awfully close to what 
> > `-fpermissive` does (and at least with that awful flag you have to opt 
> > *into* the less strictly conforming behavior instead of getting it by 
> > default as with extensions).
> > 
> > I'm curious if @rsmith has thoughts here?
> > It was an error in older versions of Clang
> 
> https://godbolt.org/z/rvbffY
Oh, I hadn't realized this changed *that* recently! Is this breaking some 
significant amounts of code now that we err on it (or regressing performance by 
not folding the VLA)?

My point still stands about disliking when we ignore constraint violations. To 
expound a bit, in this particular case, I think the standard is being 
over-constraining because we reasonably *can* fold this to a more efficient 
form. Normally, I'd suggest filing a DR with WG14 over this and treating the 
constraint as UB we can extend. However, I think the "solution" that comes out 
of WG14 would (likely) be to make compound literal expressions of VLA types be 
undefined behavior rather than a constraint violation (because I don't see many 
other options in the standard wording for a more targeted fix to allow *just* 
this safe usage). Given the security concerns around misuse of VLAs already, I 
think that would be a worse world to live in even if it gets us what we want 
with this specific case in mind. This is where my caution is coming from. 
Knowing a bit more about the experience in the proprietary code bases would be 
helpful, if it's something you can share more details about.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98363

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


[PATCH] D98660: [AIX][XCOFF] Fixed the test case which failed at aix OS because enable -mignore-xcoff-visibility by default.

2021-03-15 Thread Digger Lin via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGd1f1bff81bd9: [AIX][XCOFF] Fixed the test case which failed 
at aix OS because enable -mignore… (authored by DiggerLin).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98660

Files:
  clang/test/CodeGen/hidden-visibility.c
  clang/test/CodeGen/private-extern.c
  clang/test/Index/symbol-visibility.c


Index: clang/test/Index/symbol-visibility.c
===
--- clang/test/Index/symbol-visibility.c
+++ clang/test/Index/symbol-visibility.c
@@ -1,4 +1,4 @@
-// RUN: c-index-test -test-print-visibility %s | FileCheck %s
+// RUN: c-index-test -test-print-visibility  -fvisibility=default %s | 
FileCheck %s
 
 __attribute__ ((visibility ("default"))) void foo1();
 __attribute__ ((visibility ("hidden"))) void foo2();
Index: clang/test/CodeGen/private-extern.c
===
--- clang/test/CodeGen/private-extern.c
+++ clang/test/CodeGen/private-extern.c
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -emit-llvm -o - %s | FileCheck %s
+// RUN: %clang_cc1  -fvisibility default -emit-llvm -o - %s | FileCheck %s
 
 // CHECK-DAG: @g0 = external hidden constant i32
 // CHECK-DAG: @g1 = hidden constant i32 1
Index: clang/test/CodeGen/hidden-visibility.c
===
--- clang/test/CodeGen/hidden-visibility.c
+++ clang/test/CodeGen/hidden-visibility.c
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 %s -emit-llvm -o - | FileCheck %s
+// RUN: %clang_cc1 %s -fvisibility default -emit-llvm -o - | FileCheck %s
 
 // CHECK: hidden global
 int X __attribute__ ((__visibility__ ("hidden"))) = 123;


Index: clang/test/Index/symbol-visibility.c
===
--- clang/test/Index/symbol-visibility.c
+++ clang/test/Index/symbol-visibility.c
@@ -1,4 +1,4 @@
-// RUN: c-index-test -test-print-visibility %s | FileCheck %s
+// RUN: c-index-test -test-print-visibility  -fvisibility=default %s | FileCheck %s
 
 __attribute__ ((visibility ("default"))) void foo1();
 __attribute__ ((visibility ("hidden"))) void foo2();
Index: clang/test/CodeGen/private-extern.c
===
--- clang/test/CodeGen/private-extern.c
+++ clang/test/CodeGen/private-extern.c
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -emit-llvm -o - %s | FileCheck %s
+// RUN: %clang_cc1  -fvisibility default -emit-llvm -o - %s | FileCheck %s
 
 // CHECK-DAG: @g0 = external hidden constant i32
 // CHECK-DAG: @g1 = hidden constant i32 1
Index: clang/test/CodeGen/hidden-visibility.c
===
--- clang/test/CodeGen/hidden-visibility.c
+++ clang/test/CodeGen/hidden-visibility.c
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 %s -emit-llvm -o - | FileCheck %s
+// RUN: %clang_cc1 %s -fvisibility default -emit-llvm -o - | FileCheck %s
 
 // CHECK: hidden global
 int X __attribute__ ((__visibility__ ("hidden"))) = 123;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] d1f1bff - [AIX][XCOFF] Fixed the test case which failed at aix OS because enable -mignore-xcoff-visibility by default.

2021-03-15 Thread via cfe-commits

Author: diggerlin
Date: 2021-03-15T17:33:02-04:00
New Revision: d1f1bff81bd9909fcfdb4d97af9e3ab5d827b529

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

LOG: [AIX][XCOFF] Fixed the test case which failed at aix OS because enable 
-mignore-xcoff-visibility by default.

Summary:

because we enable -mignore-xcoff-visibility by default when there is no 
-fvisibility option in the clang in AIX OS
it will cause some test case fail at aix os. in order to let the 
-mignore-xcoff-visibility to be disable, we need to add the 
-fvisibility=default for those test case.

Reviewers: hubert.reinterpretcast daltenty
Differential Revision: https://reviews.llvm.org/D98660

Added: 


Modified: 
clang/test/CodeGen/hidden-visibility.c
clang/test/CodeGen/private-extern.c
clang/test/Index/symbol-visibility.c

Removed: 




diff  --git a/clang/test/CodeGen/hidden-visibility.c 
b/clang/test/CodeGen/hidden-visibility.c
index 65e6616ef19f..585939081cb5 100644
--- a/clang/test/CodeGen/hidden-visibility.c
+++ b/clang/test/CodeGen/hidden-visibility.c
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 %s -emit-llvm -o - | FileCheck %s
+// RUN: %clang_cc1 %s -fvisibility default -emit-llvm -o - | FileCheck %s
 
 // CHECK: hidden global
 int X __attribute__ ((__visibility__ ("hidden"))) = 123;

diff  --git a/clang/test/CodeGen/private-extern.c 
b/clang/test/CodeGen/private-extern.c
index 26b3fcede5ab..dae623762ca3 100644
--- a/clang/test/CodeGen/private-extern.c
+++ b/clang/test/CodeGen/private-extern.c
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -emit-llvm -o - %s | FileCheck %s
+// RUN: %clang_cc1  -fvisibility default -emit-llvm -o - %s | FileCheck %s
 
 // CHECK-DAG: @g0 = external hidden constant i32
 // CHECK-DAG: @g1 = hidden constant i32 1

diff  --git a/clang/test/Index/symbol-visibility.c 
b/clang/test/Index/symbol-visibility.c
index 014e80f81878..4a8179dddff3 100644
--- a/clang/test/Index/symbol-visibility.c
+++ b/clang/test/Index/symbol-visibility.c
@@ -1,4 +1,4 @@
-// RUN: c-index-test -test-print-visibility %s | FileCheck %s
+// RUN: c-index-test -test-print-visibility  -fvisibility=default %s | 
FileCheck %s
 
 __attribute__ ((visibility ("default"))) void foo1();
 __attribute__ ((visibility ("hidden"))) void foo2();



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


[PATCH] D97850: Fix PCM read from ModuleCache for ext4 filesystem

2021-03-15 Thread Duncan P. N. Exon Smith via Phabricator via cfe-commits
dexonsmith requested changes to this revision.
dexonsmith added a comment.
This revision now requires changes to proceed.

Agreed that the right fix is to remove/replace the inode-based cache, but it's 
not safe to just drop it. Consider the following filesystem layout:

  /dir/file.h
  /dir/symlink.h -> file.h

the inode-based cache is what tells us that the following all point at the same 
file (given a working directory of `/dir`):

- `/dir/file.h`
- `/dir/./file.h`
- `../dir/file.h`
- `./file.h`
- `file.h`
- `symlink.h`
- `./symlink.h`
- `../dir/symlink.h`
- `/dir/symlink.h`
- `/dir/./symlink.h`

We can't drop the inode cache until there's another solution in place for this.

(One roundabout solution would be to keep this unchanged, and rely on the VFS 
to provide stable inodes. As it happens, I'm prototyping an on-disk caching 
`FileSystem` implementation that assigns stable/virtual inodes for each real 
path (hard links get distinct inodes); doesn't seem to have any overhead over 
the "real" filesystem (at least not at scale in clang-scan-deps). We could 
change the main path in Clang to use something like that, and change the PCM 
cache to use different logic (it's the only filemanager client that doesn't 
want/expect a stable view of the FS). I don't think it'd be too hard.)

Marking this as "request changes" since `getBypassFile()` is unsound and I'd 
prefer its use not be proliferated; I have some WIP to remove its current use.

Maybe there's a simpler solution though. If it's safe to use `getBypassFile()` 
every time a PCM file is opened, then we're not getting any value out of the 
FileManager. Maybe the module manager could skip the FileManager entirely...


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97850

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


[PATCH] D98363: [Sema] Fold VLA types in compound literals to constant arrays.

2021-03-15 Thread Eli Friedman via Phabricator via cfe-commits
efriedma added inline comments.



Comment at: clang/test/Sema/vla.c:134
+  // expected-warning@+1{{variable length array folded to constant array as an 
extension}}
+  char (*a9)[] = (char[2][ksize]) {{1,2,3,4},{4,3,2,1}};
+

aaron.ballman wrote:
> efriedma wrote:
> > aaron.ballman wrote:
> > > Doesn't this violate the constraints in C17 6.5.2.5p1, "The type name 
> > > shall specify a complete object type or an array of unknown size, but not 
> > > a variable-length array type"?
> > Yes, this is a constraint violation.  This patch downgrades the error to a 
> > warning, for compatibility with older versions of clang.
> It was an error in older versions of Clang, so downgrading it to a warning 
> can't make code *more* compatible with older versions. This also makes it 
> harder to port C code to other compilers because Clang happily accepts code 
> that the C standard says should be rejected.
> 
> I'm not strongly opposed to the change, but I also don't like ignoring 
> constraint violations in the standard as that comes awfully close to what 
> `-fpermissive` does (and at least with that awful flag you have to opt *into* 
> the less strictly conforming behavior instead of getting it by default as 
> with extensions).
> 
> I'm curious if @rsmith has thoughts here?
> It was an error in older versions of Clang

https://godbolt.org/z/rvbffY


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98363

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


[PATCH] D98660: [AIX][XCOFF] Fixed the test case which failed at aix OS because enable -mignore-xcoff-visibility by default.

2021-03-15 Thread David Tenty via Phabricator via cfe-commits
daltenty accepted this revision.
daltenty added inline comments.



Comment at: clang/test/CodeGen/hidden-visibility.c:1
-// RUN: %clang_cc1 %s -emit-llvm -o - | FileCheck %s
+// RUN: %clang_cc1 %s -fvisibility default -emit-llvm -o - | FileCheck %s
 

DiggerLin wrote:
> daltenty wrote:
> > dunno if this is also accepted, but I think we prefer an equal sign here: 
> I do not think clang -cc1 support  -fvisibility=default
I guess the cc1 argument form maybe different for some reason, so feel free to 
disregard.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98660

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


[PATCH] D98660: [AIX][XCOFF] Fixed the test case which failed at aix OS because enable -mignore-xcoff-visibility by default.

2021-03-15 Thread Digger Lin via Phabricator via cfe-commits
DiggerLin marked an inline comment as done.
DiggerLin added inline comments.



Comment at: clang/test/CodeGen/hidden-visibility.c:1
-// RUN: %clang_cc1 %s -emit-llvm -o - | FileCheck %s
+// RUN: %clang_cc1 %s -fvisibility default -emit-llvm -o - | FileCheck %s
 

daltenty wrote:
> dunno if this is also accepted, but I think we prefer an equal sign here: 
I do not think clang -cc1 support  -fvisibility=default


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98660

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


[PATCH] D97901: [SystemZ] Test for infinity in testFPKind().

2021-03-15 Thread Jonas Paulsson via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG9cfd301ec8b5: [SystemZ] Test for isinf and isfinite in 
testFPKind(). (authored by jonpa).
Herald added a project: clang.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97901

Files:
  clang/lib/CodeGen/TargetInfo.cpp
  clang/test/CodeGen/SystemZ/strictfp_builtins.c

Index: clang/test/CodeGen/SystemZ/strictfp_builtins.c
===
--- clang/test/CodeGen/SystemZ/strictfp_builtins.c
+++ clang/test/CodeGen/SystemZ/strictfp_builtins.c
@@ -9,7 +9,7 @@
 // CHECK-NEXT:[[F_ADDR:%.*]] = alloca float, align 4
 // CHECK-NEXT:store float [[F:%.*]], float* [[F_ADDR]], align 4
 // CHECK-NEXT:[[TMP0:%.*]] = load float, float* [[F_ADDR]], align 4
-// CHECK-NEXT:[[TMP1:%.*]] = call i32 @llvm.s390.tdc.f32(float [[TMP0]], i64 15) [[ATTR2:#.*]]
+// CHECK-NEXT:[[TMP1:%.*]] = call i32 @llvm.s390.tdc.f32(float [[TMP0]], i64 15) #[[ATTR2:[0-9]+]]
 // CHECK-NEXT:ret i32 [[TMP1]]
 //
 int test_isnan_float(float f) {
@@ -21,7 +21,7 @@
 // CHECK-NEXT:[[D_ADDR:%.*]] = alloca double, align 8
 // CHECK-NEXT:store double [[D:%.*]], double* [[D_ADDR]], align 8
 // CHECK-NEXT:[[TMP0:%.*]] = load double, double* [[D_ADDR]], align 8
-// CHECK-NEXT:[[TMP1:%.*]] = call i32 @llvm.s390.tdc.f64(double [[TMP0]], i64 15) [[ATTR2]]
+// CHECK-NEXT:[[TMP1:%.*]] = call i32 @llvm.s390.tdc.f64(double [[TMP0]], i64 15) #[[ATTR2]]
 // CHECK-NEXT:ret i32 [[TMP1]]
 //
 int test_isnan_double(double d) {
@@ -34,10 +34,84 @@
 // CHECK-NEXT:[[LD:%.*]] = load fp128, fp128* [[TMP0:%.*]], align 8
 // CHECK-NEXT:store fp128 [[LD]], fp128* [[LD_ADDR]], align 8
 // CHECK-NEXT:[[TMP1:%.*]] = load fp128, fp128* [[LD_ADDR]], align 8
-// CHECK-NEXT:[[TMP2:%.*]] = call i32 @llvm.s390.tdc.f128(fp128 [[TMP1]], i64 15) [[ATTR2]]
+// CHECK-NEXT:[[TMP2:%.*]] = call i32 @llvm.s390.tdc.f128(fp128 [[TMP1]], i64 15) #[[ATTR2]]
 // CHECK-NEXT:ret i32 [[TMP2]]
 //
 int test_isnan_long_double(long double ld) {
   return __builtin_isnan(ld);
 }
 
+// CHECK-LABEL: @test_isinf_float(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[F_ADDR:%.*]] = alloca float, align 4
+// CHECK-NEXT:store float [[F:%.*]], float* [[F_ADDR]], align 4
+// CHECK-NEXT:[[TMP0:%.*]] = load float, float* [[F_ADDR]], align 4
+// CHECK-NEXT:[[TMP1:%.*]] = call i32 @llvm.s390.tdc.f32(float [[TMP0]], i64 48) #[[ATTR2]]
+// CHECK-NEXT:ret i32 [[TMP1]]
+//
+int test_isinf_float(float f) {
+  return __builtin_isinf(f);
+}
+
+// CHECK-LABEL: @test_isinf_double(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[D_ADDR:%.*]] = alloca double, align 8
+// CHECK-NEXT:store double [[D:%.*]], double* [[D_ADDR]], align 8
+// CHECK-NEXT:[[TMP0:%.*]] = load double, double* [[D_ADDR]], align 8
+// CHECK-NEXT:[[TMP1:%.*]] = call i32 @llvm.s390.tdc.f64(double [[TMP0]], i64 48) #[[ATTR2]]
+// CHECK-NEXT:ret i32 [[TMP1]]
+//
+int test_isinf_double(double d) {
+  return __builtin_isinf(d);
+}
+
+// CHECK-LABEL: @test_isinf_long_double(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[LD_ADDR:%.*]] = alloca fp128, align 8
+// CHECK-NEXT:[[LD:%.*]] = load fp128, fp128* [[TMP0:%.*]], align 8
+// CHECK-NEXT:store fp128 [[LD]], fp128* [[LD_ADDR]], align 8
+// CHECK-NEXT:[[TMP1:%.*]] = load fp128, fp128* [[LD_ADDR]], align 8
+// CHECK-NEXT:[[TMP2:%.*]] = call i32 @llvm.s390.tdc.f128(fp128 [[TMP1]], i64 48) #[[ATTR2]]
+// CHECK-NEXT:ret i32 [[TMP2]]
+//
+int test_isinf_long_double(long double ld) {
+  return __builtin_isinf(ld);
+}
+
+// CHECK-LABEL: @test_isfinite_float(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[F_ADDR:%.*]] = alloca float, align 4
+// CHECK-NEXT:store float [[F:%.*]], float* [[F_ADDR]], align 4
+// CHECK-NEXT:[[TMP0:%.*]] = load float, float* [[F_ADDR]], align 4
+// CHECK-NEXT:[[TMP1:%.*]] = call i32 @llvm.s390.tdc.f32(float [[TMP0]], i64 4032) #[[ATTR2]]
+// CHECK-NEXT:ret i32 [[TMP1]]
+//
+int test_isfinite_float(float f) {
+  return __builtin_isfinite(f);
+}
+
+// CHECK-LABEL: @test_isfinite_double(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[D_ADDR:%.*]] = alloca double, align 8
+// CHECK-NEXT:store double [[D:%.*]], double* [[D_ADDR]], align 8
+// CHECK-NEXT:[[TMP0:%.*]] = load double, double* [[D_ADDR]], align 8
+// CHECK-NEXT:[[TMP1:%.*]] = call i32 @llvm.s390.tdc.f64(double [[TMP0]], i64 4032) #[[ATTR2]]
+// CHECK-NEXT:ret i32 [[TMP1]]
+//
+int test_isfinite_double(double d) {
+  return __builtin_isfinite(d);
+}
+
+// CHECK-LABEL: @test_isfinite_long_double(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[LD_ADDR:%.*]] = alloca fp128, align 8
+// CHECK-NEXT:[[LD:%.*]] = load fp128, fp128* [[TMP0:%.*]], align 8
+// CHECK-NEXT:store fp128 [[LD]], fp128* [[LD_ADDR]], align 8
+// 

[clang] 9cfd301 - [SystemZ] Test for isinf and isfinite in testFPKind().

2021-03-15 Thread Jonas Paulsson via cfe-commits

Author: Jonas Paulsson
Date: 2021-03-15T15:02:39-06:00
New Revision: 9cfd301ec8b5ed6eb49bcc4b85e6f2af1a90b305

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

LOG: [SystemZ] Test for isinf and isfinite in testFPKind().

Recognize BI__builtin_isinf and BI__builtin_isfinite (and a few other opcodes
for finite) in testFPKind() and handle with TDC.

Review: Ulrich Weigand.

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

Added: 


Modified: 
clang/lib/CodeGen/TargetInfo.cpp
clang/test/CodeGen/SystemZ/strictfp_builtins.c

Removed: 




diff  --git a/clang/lib/CodeGen/TargetInfo.cpp 
b/clang/lib/CodeGen/TargetInfo.cpp
index 4f5b928f1fe6..c3df36fc1ea2 100644
--- a/clang/lib/CodeGen/TargetInfo.cpp
+++ b/clang/lib/CodeGen/TargetInfo.cpp
@@ -7218,6 +7218,18 @@ class SystemZTargetCodeGenInfo : public 
TargetCodeGenInfo {
   case Builtin::BI__builtin_isnan:
 TDCBits = 0xf;
 break;
+  case Builtin::BIfinite:
+  case Builtin::BI__finite:
+  case Builtin::BIfinitef:
+  case Builtin::BI__finitef:
+  case Builtin::BIfinitel:
+  case Builtin::BI__finitel:
+  case Builtin::BI__builtin_isfinite:
+TDCBits = 0xfc0;
+break;
+  case Builtin::BI__builtin_isinf:
+TDCBits = 0x30;
+break;
   default:
 break;
   }

diff  --git a/clang/test/CodeGen/SystemZ/strictfp_builtins.c 
b/clang/test/CodeGen/SystemZ/strictfp_builtins.c
index 2181da9b8637..58909f16a6dd 100644
--- a/clang/test/CodeGen/SystemZ/strictfp_builtins.c
+++ b/clang/test/CodeGen/SystemZ/strictfp_builtins.c
@@ -9,7 +9,7 @@
 // CHECK-NEXT:[[F_ADDR:%.*]] = alloca float, align 4
 // CHECK-NEXT:store float [[F:%.*]], float* [[F_ADDR]], align 4
 // CHECK-NEXT:[[TMP0:%.*]] = load float, float* [[F_ADDR]], align 4
-// CHECK-NEXT:[[TMP1:%.*]] = call i32 @llvm.s390.tdc.f32(float [[TMP0]], 
i64 15) [[ATTR2:#.*]]
+// CHECK-NEXT:[[TMP1:%.*]] = call i32 @llvm.s390.tdc.f32(float [[TMP0]], 
i64 15) #[[ATTR2:[0-9]+]]
 // CHECK-NEXT:ret i32 [[TMP1]]
 //
 int test_isnan_float(float f) {
@@ -21,7 +21,7 @@ int test_isnan_float(float f) {
 // CHECK-NEXT:[[D_ADDR:%.*]] = alloca double, align 8
 // CHECK-NEXT:store double [[D:%.*]], double* [[D_ADDR]], align 8
 // CHECK-NEXT:[[TMP0:%.*]] = load double, double* [[D_ADDR]], align 8
-// CHECK-NEXT:[[TMP1:%.*]] = call i32 @llvm.s390.tdc.f64(double [[TMP0]], 
i64 15) [[ATTR2]]
+// CHECK-NEXT:[[TMP1:%.*]] = call i32 @llvm.s390.tdc.f64(double [[TMP0]], 
i64 15) #[[ATTR2]]
 // CHECK-NEXT:ret i32 [[TMP1]]
 //
 int test_isnan_double(double d) {
@@ -34,10 +34,84 @@ int test_isnan_double(double d) {
 // CHECK-NEXT:[[LD:%.*]] = load fp128, fp128* [[TMP0:%.*]], align 8
 // CHECK-NEXT:store fp128 [[LD]], fp128* [[LD_ADDR]], align 8
 // CHECK-NEXT:[[TMP1:%.*]] = load fp128, fp128* [[LD_ADDR]], align 8
-// CHECK-NEXT:[[TMP2:%.*]] = call i32 @llvm.s390.tdc.f128(fp128 [[TMP1]], 
i64 15) [[ATTR2]]
+// CHECK-NEXT:[[TMP2:%.*]] = call i32 @llvm.s390.tdc.f128(fp128 [[TMP1]], 
i64 15) #[[ATTR2]]
 // CHECK-NEXT:ret i32 [[TMP2]]
 //
 int test_isnan_long_double(long double ld) {
   return __builtin_isnan(ld);
 }
 
+// CHECK-LABEL: @test_isinf_float(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[F_ADDR:%.*]] = alloca float, align 4
+// CHECK-NEXT:store float [[F:%.*]], float* [[F_ADDR]], align 4
+// CHECK-NEXT:[[TMP0:%.*]] = load float, float* [[F_ADDR]], align 4
+// CHECK-NEXT:[[TMP1:%.*]] = call i32 @llvm.s390.tdc.f32(float [[TMP0]], 
i64 48) #[[ATTR2]]
+// CHECK-NEXT:ret i32 [[TMP1]]
+//
+int test_isinf_float(float f) {
+  return __builtin_isinf(f);
+}
+
+// CHECK-LABEL: @test_isinf_double(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[D_ADDR:%.*]] = alloca double, align 8
+// CHECK-NEXT:store double [[D:%.*]], double* [[D_ADDR]], align 8
+// CHECK-NEXT:[[TMP0:%.*]] = load double, double* [[D_ADDR]], align 8
+// CHECK-NEXT:[[TMP1:%.*]] = call i32 @llvm.s390.tdc.f64(double [[TMP0]], 
i64 48) #[[ATTR2]]
+// CHECK-NEXT:ret i32 [[TMP1]]
+//
+int test_isinf_double(double d) {
+  return __builtin_isinf(d);
+}
+
+// CHECK-LABEL: @test_isinf_long_double(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[LD_ADDR:%.*]] = alloca fp128, align 8
+// CHECK-NEXT:[[LD:%.*]] = load fp128, fp128* [[TMP0:%.*]], align 8
+// CHECK-NEXT:store fp128 [[LD]], fp128* [[LD_ADDR]], align 8
+// CHECK-NEXT:[[TMP1:%.*]] = load fp128, fp128* [[LD_ADDR]], align 8
+// CHECK-NEXT:[[TMP2:%.*]] = call i32 @llvm.s390.tdc.f128(fp128 [[TMP1]], 
i64 48) #[[ATTR2]]
+// CHECK-NEXT:ret i32 [[TMP2]]
+//
+int test_isinf_long_double(long double ld) {
+  return __builtin_isinf(ld);
+}
+
+// CHECK-LABEL: @test_isfinite_float(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:  

[PATCH] D98388: [RISCV][Clang] Add RVV vle/vse intrinsic functions.

2021-03-15 Thread Craig Topper via Phabricator via cfe-commits
craig.topper added inline comments.



Comment at: clang/utils/TableGen/RISCVVEmitter.cpp:687
+
+unsigned Skew = 0;
+if (HasMaskedOffOperand)

```
unsigned Skew = HasMaskedOffOperand ? 1 : 0;
```

unless this needs to get more complicated in a future patch?




Comment at: clang/utils/TableGen/RISCVVEmitter.cpp:695
+// Verify the result of CTypeOrder has legal value.
+if (std::upper_bound(CTypeOrder.begin(), CTypeOrder.end(),
+ CTypeOrder.size() - 1) != CTypeOrder.end())

std::upper_bound requires a list to be sorted. It tells you the upper location 
of where the value belongs in the sorted sequence. std::max_element can tell 
you the largest value in an unsorted range.



Comment at: clang/utils/TableGen/RISCVVEmitter.cpp:699
+  "The index of PermuteOperand is bigger than the operand number");
+if (std::unique(CTypeOrder.begin(), CTypeOrder.end()) != CTypeOrder.end())
+  PrintFatalError(

std::unique only compares adjacent values. As far it is concerned "[1, 0, 1]" 
is unique because the adjacent values are different. To check for duplicates I 
think you need to sort it first and then you want std::adjacent_find rather 
than std::unique. std::unique modifies the range and shifts them down. 
std::adjacent_find just tells you were the duplicate is. Another option is to 
iterate and use a set to keep track of values you already saw.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98388

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


[PATCH] D98660: [AIX][XCOFF] Fixed the test case which failed at aix OS because enable -mignore-xcoff-visibility by default.

2021-03-15 Thread Hubert Tong via Phabricator via cfe-commits
hubert.reinterpretcast accepted this revision.
hubert.reinterpretcast added a comment.
This revision is now accepted and ready to land.

LGTM (with the equal sign form as @daltenty requested if it works).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98660

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


[PATCH] D98429: [clang-format] Add new option to clang-format: SpaceBeforeForLoopSemiColon

2021-03-15 Thread Nathan Hjelm via Phabricator via cfe-commits
hjelmn updated this revision to Diff 330800.
hjelmn edited the summary of this revision.
hjelmn added a comment.

Updated change log and added a test to cover range based for with initializer.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98429

Files:
  clang/docs/ClangFormatStyleOptions.rst
  clang/docs/ReleaseNotes.rst
  clang/include/clang/Format/Format.h
  clang/lib/Format/Format.cpp
  clang/lib/Format/FormatToken.h
  clang/lib/Format/TokenAnnotator.cpp
  clang/unittests/Format/FormatTest.cpp

Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -12701,6 +12701,17 @@
InvertedSpaceStyle);
 }
 
+TEST_F(FormatTest, ConfigurableSpaceBeforeForLoopSemiColon) {
+  FormatStyle NoSpaceStyle = getLLVMStyle();
+  verifyFormat("for (i = 0; i < 10; ++i) {\n}", NoSpaceStyle);
+  verifyFormat("for (int i = 0; auto a: b) {}", NoSpaceStyle);
+
+  FormatStyle Space = getLLVMStyle();
+  Space.SpaceBeforeForLoopSemiColon = true;
+  verifyFormat("for (i = 0 ; i < 10 ; ++i) {\n}", Space);
+  verifyFormat("for (int i = 0 ; auto a: b) {}", Space);
+}
+
 TEST_F(FormatTest, ConfigurableSpaceAroundPointerQualifiers) {
   FormatStyle Style = getLLVMStyle();
 
@@ -15610,6 +15621,7 @@
   CHECK_PARSE_BOOL(SpaceBeforeCaseColon);
   CHECK_PARSE_BOOL(SpaceBeforeCpp11BracedList);
   CHECK_PARSE_BOOL(SpaceBeforeCtorInitializerColon);
+  CHECK_PARSE_BOOL(SpaceBeforeForLoopSemiColon);
   CHECK_PARSE_BOOL(SpaceBeforeInheritanceColon);
   CHECK_PARSE_BOOL(SpaceBeforeRangeBasedForLoopColon);
   CHECK_PARSE_BOOL(SpaceBeforeSquareBrackets);
Index: clang/lib/Format/TokenAnnotator.cpp
===
--- clang/lib/Format/TokenAnnotator.cpp
+++ clang/lib/Format/TokenAnnotator.cpp
@@ -,6 +,10 @@
 parseCSharpGenericTypeConstraint();
   }
   break;
+case tok::semi:
+  if (Contexts.back().ColonIsForRangeExpr)
+Tok->setType(TT_ForLoopSemiColon);
+  break;
 default:
   break;
 }
@@ -3345,6 +3349,8 @@
   if (Right.is(TT_RangeBasedForLoopColon) &&
   !Style.SpaceBeforeRangeBasedForLoopColon)
 return false;
+  if (Right.is(TT_ForLoopSemiColon) && Style.SpaceBeforeForLoopSemiColon)
+return true;
   if (Left.is(TT_BitFieldColon))
 return Style.BitFieldColonSpacing == FormatStyle::BFCS_Both ||
Style.BitFieldColonSpacing == FormatStyle::BFCS_After;
@@ -3995,6 +4001,8 @@
 return true;
   if (Right.is(TT_RangeBasedForLoopColon))
 return false;
+  if (Right.is(TT_ForLoopSemiColon))
+return false;
   if (Left.is(TT_TemplateCloser) && Right.is(TT_TemplateOpener))
 return true;
   if (Left.isOneOf(TT_TemplateCloser, TT_UnaryOperator) ||
Index: clang/lib/Format/FormatToken.h
===
--- clang/lib/Format/FormatToken.h
+++ clang/lib/Format/FormatToken.h
@@ -46,6 +46,7 @@
   TYPE(DesignatedInitializerLSquare)   \
   TYPE(DesignatedInitializerPeriod)\
   TYPE(DictLiteral)\
+  TYPE(ForLoopSemiColon)   \
   TYPE(ForEachMacro)   \
   TYPE(FunctionAnnotationRParen)   \
   TYPE(FunctionDeclarationName)\
Index: clang/lib/Format/Format.cpp
===
--- clang/lib/Format/Format.cpp
+++ clang/lib/Format/Format.cpp
@@ -657,6 +657,8 @@
Style.SpaceBeforeCpp11BracedList);
 IO.mapOptional("SpaceBeforeCtorInitializerColon",
Style.SpaceBeforeCtorInitializerColon);
+IO.mapOptional("SpaceBeforeForLoopSemiColon",
+   Style.SpaceBeforeForLoopSemiColon);
 IO.mapOptional("SpaceBeforeInheritanceColon",
Style.SpaceBeforeInheritanceColon);
 IO.mapOptional("SpaceBeforeParens", Style.SpaceBeforeParens);
@@ -1026,6 +1028,7 @@
   LLVMStyle.SpaceAroundPointerQualifiers = FormatStyle::SAPQ_Default;
   LLVMStyle.SpaceBeforeCaseColon = false;
   LLVMStyle.SpaceBeforeCtorInitializerColon = true;
+  LLVMStyle.SpaceBeforeForLoopSemiColon = false;
   LLVMStyle.SpaceBeforeInheritanceColon = true;
   LLVMStyle.SpaceBeforeParens = FormatStyle::SBPO_ControlStatements;
   LLVMStyle.SpaceBeforeRangeBasedForLoopColon = true;
Index: clang/include/clang/Format/Format.h
===
--- clang/include/clang/Format/Format.h
+++ clang/include/clang/Format/Format.h
@@ -2835,6 +2835,13 @@
   /// \endcode
   bool 

[PATCH] D97119: [flang][driver] Add options for -std=f2018

2021-03-15 Thread Tim Keith via Phabricator via cfe-commits
tskeith added inline comments.



Comment at: flang/test/Driver/std2018.f90:9
+! RUN: %flang_fc1 -pedantic %s  2>&1 | FileCheck %s --check-prefix=GIVEN
+! RUN: not %flang_fc1 -std=90 %s  2>&1 | FileCheck %s --check-prefix=WRONG
+

You need to make sure these work with f18 or indicate the test requires the new 
driver. f18 doesn't currently support `-std=f2018` and doesn't complain about 
unrecognized options.


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

https://reviews.llvm.org/D97119

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


[PATCH] D98660: [AIX][XCOFF] Fixed the test case which failed at aix OS because enable -mignore-xcoff-visibility by default.

2021-03-15 Thread David Tenty via Phabricator via cfe-commits
daltenty added inline comments.



Comment at: clang/test/CodeGen/hidden-visibility.c:1
-// RUN: %clang_cc1 %s -emit-llvm -o - | FileCheck %s
+// RUN: %clang_cc1 %s -fvisibility default -emit-llvm -o - | FileCheck %s
 

dunno if this is also accepted, but I think we prefer an equal sign here: 



Comment at: clang/test/CodeGen/private-extern.c:1
-// RUN: %clang_cc1 -emit-llvm -o - %s | FileCheck %s
+// RUN: %clang_cc1  -fvisibility default -emit-llvm -o - %s | FileCheck %s
 

ditto the earlier comment


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98660

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


[PATCH] D96843: [Clang][RISCV] Add vsetvl and vsetvlmax.

2021-03-15 Thread Craig Topper via Phabricator via cfe-commits
craig.topper added inline comments.



Comment at: clang/lib/Basic/Targets/RISCV.cpp:164
+
+// SEW
+Builder.defineMacro("__rvv_e8", "0");

I'm not sure if it makes sense to expose these from the compiler. Should we 
define them in the header instead? They don't look useful without the header. 
Most of the defines from the compiler are expressing capabilities like what 
features are enabled so these seem different.



Comment at: clang/lib/Basic/Targets/RISCV.cpp:169
+Builder.defineMacro("__rvv_e64", "3");
+Builder.defineMacro("__rvv_e128", "4");
+

Are intending to support e128?



Comment at: clang/utils/TableGen/RISCVVEmitter.cpp:774
+  // Print header code
+  if (HeaderCode.size()) {
+OS << HeaderCode;

!HeaderCode.empty()


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D96843

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


[PATCH] D98660: [AIX][XCOFF] Fixed the test case which failed at aix OS because enable -mignore-xcoff-visibility by default.

2021-03-15 Thread Digger Lin via Phabricator via cfe-commits
DiggerLin created this revision.
DiggerLin added reviewers: hubert.reinterpretcast, jasonliu, sfertile, daltenty.
Herald added a subscriber: arphaman.
DiggerLin requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

because we enable -mignore-xcoff-visibility by default when there is no 
-fvisibility option in the clang in AIX OS
it will cause  some test case fail at aix os. in order to let the 
-mignore-xcoff-visibility to be disable, we need to add the 
-fvisibility=default for those test case.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D98660

Files:
  clang/test/CodeGen/hidden-visibility.c
  clang/test/CodeGen/private-extern.c
  clang/test/Index/symbol-visibility.c


Index: clang/test/Index/symbol-visibility.c
===
--- clang/test/Index/symbol-visibility.c
+++ clang/test/Index/symbol-visibility.c
@@ -1,4 +1,4 @@
-// RUN: c-index-test -test-print-visibility %s | FileCheck %s
+// RUN: c-index-test -test-print-visibility  -fvisibility=default %s | 
FileCheck %s
 
 __attribute__ ((visibility ("default"))) void foo1();
 __attribute__ ((visibility ("hidden"))) void foo2();
Index: clang/test/CodeGen/private-extern.c
===
--- clang/test/CodeGen/private-extern.c
+++ clang/test/CodeGen/private-extern.c
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -emit-llvm -o - %s | FileCheck %s
+// RUN: %clang_cc1  -fvisibility default -emit-llvm -o - %s | FileCheck %s
 
 // CHECK-DAG: @g0 = external hidden constant i32
 // CHECK-DAG: @g1 = hidden constant i32 1
Index: clang/test/CodeGen/hidden-visibility.c
===
--- clang/test/CodeGen/hidden-visibility.c
+++ clang/test/CodeGen/hidden-visibility.c
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 %s -emit-llvm -o - | FileCheck %s
+// RUN: %clang_cc1 %s -fvisibility default -emit-llvm -o - | FileCheck %s
 
 // CHECK: hidden global
 int X __attribute__ ((__visibility__ ("hidden"))) = 123;


Index: clang/test/Index/symbol-visibility.c
===
--- clang/test/Index/symbol-visibility.c
+++ clang/test/Index/symbol-visibility.c
@@ -1,4 +1,4 @@
-// RUN: c-index-test -test-print-visibility %s | FileCheck %s
+// RUN: c-index-test -test-print-visibility  -fvisibility=default %s | FileCheck %s
 
 __attribute__ ((visibility ("default"))) void foo1();
 __attribute__ ((visibility ("hidden"))) void foo2();
Index: clang/test/CodeGen/private-extern.c
===
--- clang/test/CodeGen/private-extern.c
+++ clang/test/CodeGen/private-extern.c
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -emit-llvm -o - %s | FileCheck %s
+// RUN: %clang_cc1  -fvisibility default -emit-llvm -o - %s | FileCheck %s
 
 // CHECK-DAG: @g0 = external hidden constant i32
 // CHECK-DAG: @g1 = hidden constant i32 1
Index: clang/test/CodeGen/hidden-visibility.c
===
--- clang/test/CodeGen/hidden-visibility.c
+++ clang/test/CodeGen/hidden-visibility.c
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 %s -emit-llvm -o - | FileCheck %s
+// RUN: %clang_cc1 %s -fvisibility default -emit-llvm -o - | FileCheck %s
 
 // CHECK: hidden global
 int X __attribute__ ((__visibility__ ("hidden"))) = 123;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D97901: [SystemZ] Test for infinity in testFPKind().

2021-03-15 Thread Ulrich Weigand via Phabricator via cfe-commits
uweigand accepted this revision.
uweigand added a comment.
This revision is now accepted and ready to land.

LGTM, thanks!


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

https://reviews.llvm.org/D97901

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


[PATCH] D98246: [clangd] Add basic monitoring info request for remote index server

2021-03-15 Thread Kirill Bobyrev via Phabricator via cfe-commits
kbobyrev added inline comments.



Comment at: clang-tools-extra/clangd/index/remote/server/Server.cpp:308
+  .count());
+// FIXME(kirillbobyrev): This is not really "freshness", this is just the
+// time since last index reload.

kadircet wrote:
> what's the issue to be fixed here exactly? do we want to display the index 
> build time instead of age? (if so what's the blocker)
The point here is that is the index load freshness but it's not the index load, 
not the index age itself. The index age is e.g. the time of the last commit 
being indexed. Hence, we don't actually have this information _right now_ - it 
should be provided separately (probably in a way of adjacent `index.metadata` 
file or something similar). E.g. when we download from GitHub release, we do 
know the time an index was uploaded, that's a better estimate of the index 
"age" probably. But what the comment in Proto file says is actually more like 
the commit time, e.g. when did the last change that made it into the index 
happen.



Comment at: clang-tools-extra/clangd/index/remote/server/Server.cpp:457
 
-  std::thread HotReloadThread([, , ]() {
+  Monitor Monitor(std::chrono::system_clock::now());
+

kadircet wrote:
> unless we call updateIndex here too, monitoring service won't know about the 
> one being served until the first reload right?
> 
> (another option would be to just not load the index at startup immediately, 
> and handle the initial load in HotReloadThread, but that can be a separate 
> change.)
I think using `Status.getLastModificationTime()` should be correct, right? This 
is the index we actually loaded (checked above).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98246

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


[PATCH] D98246: [clangd] Add basic monitoring info request for remote index server

2021-03-15 Thread Kirill Bobyrev via Phabricator via cfe-commits
kbobyrev updated this revision to Diff 330791.
kbobyrev marked 7 inline comments as done.
kbobyrev added a comment.
Herald added a subscriber: jfb.

Address comments, rebase on top of main.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98246

Files:
  clang-tools-extra/clangd/index/remote/CMakeLists.txt
  clang-tools-extra/clangd/index/remote/MonitoringService.proto
  clang-tools-extra/clangd/index/remote/Service.proto
  clang-tools-extra/clangd/index/remote/server/Server.cpp

Index: clang-tools-extra/clangd/index/remote/server/Server.cpp
===
--- clang-tools-extra/clangd/index/remote/server/Server.cpp
+++ clang-tools-extra/clangd/index/remote/server/Server.cpp
@@ -8,7 +8,10 @@
 
 #include "Features.inc"
 #include "Index.pb.h"
+#include "MonitoringService.grpc.pb.h"
+#include "MonitoringService.pb.h"
 #include "Service.grpc.pb.h"
+#include "Service.pb.h"
 #include "index/Index.h"
 #include "index/Serialization.h"
 #include "index/Symbol.h"
@@ -288,11 +291,44 @@
   clangd::SymbolIndex 
 };
 
+class Monitor final : public v1::Monitor::Service {
+public:
+  Monitor(llvm::sys::TimePoint<> StartTime)
+  : StartTime(StartTime), IndexLastReload(StartTime) {}
+
+  void updateIndex(llvm::sys::TimePoint<> UpdateTime) {
+IndexLastReload.exchange(UpdateTime);
+  }
+
+private:
+  // FIXME(kirillbobyrev): Most fields should be populated when the index
+  // reloads (probably in adjacent metadata.txt file next to loaded .idx) but
+  // they aren't right now.
+  grpc::Status MonitoringInfo(grpc::ServerContext *Context,
+  const v1::MonitoringInfoRequest *Request,
+  v1::MonitoringInfoReply *Reply) override {
+Reply->set_uptime_seconds(std::chrono::duration_cast(
+  std::chrono::system_clock::now() - StartTime)
+  .count());
+// FIXME(kirillbobyrev): This is not really the time an index was built,
+// this is just the time since last index reload.
+Reply->set_index_age_seconds(
+std::chrono::duration_cast(
+std::chrono::system_clock::now() - IndexLastReload.load())
+.count());
+return grpc::Status::OK;
+  }
+
+  const llvm::sys::TimePoint<> StartTime;
+  std::atomic> IndexLastReload;
+};
+
 // Detect changes in \p IndexPath file and load new versions of the index
 // whenever they become available.
 void hotReload(clangd::SwapIndex , llvm::StringRef IndexPath,
llvm::vfs::Status ,
-   llvm::IntrusiveRefCntPtr ) {
+   llvm::IntrusiveRefCntPtr ,
+   Monitor ) {
   auto Status = FS->status(IndexPath);
   // Requested file is same as loaded index: no reload is needed.
   if (!Status || (Status->getLastModificationTime() ==
@@ -309,12 +345,13 @@
 return;
   }
   Index.reset(std::move(NewIndex));
+  Monitor.updateIndex(Status->getLastModificationTime());
   log("New index version loaded. Last modification time: {0}, size: {1} bytes.",
   Status->getLastModificationTime(), Status->getSize());
 }
 
 void runServerAndWait(clangd::SymbolIndex , llvm::StringRef ServerAddress,
-  llvm::StringRef IndexPath) {
+  llvm::StringRef IndexPath, Monitor ) {
   RemoteIndexServer Service(Index, IndexRoot);
 
   grpc::EnableDefaultHealthCheckService(true);
@@ -327,6 +364,7 @@
   Builder.AddChannelArgument(GRPC_ARG_MAX_CONNECTION_IDLE_MS,
  IdleTimeoutSeconds * 1000);
   Builder.RegisterService();
+  Builder.RegisterService();
   std::unique_ptr Server(Builder.BuildAndStart());
   log("Server listening on {0}", ServerAddress);
 
@@ -425,16 +463,18 @@
   }
   clang::clangd::SwapIndex Index(std::move(SymIndex));
 
-  std::thread HotReloadThread([, , ]() {
+  Monitor Monitor(Status->getLastModificationTime());
+
+  std::thread HotReloadThread([, , , ]() {
 llvm::vfs::Status LastStatus = *Status;
 static constexpr auto RefreshFrequency = std::chrono::seconds(30);
 while (!clang::clangd::shutdownRequested()) {
-  hotReload(Index, llvm::StringRef(IndexPath), LastStatus, FS);
+  hotReload(Index, llvm::StringRef(IndexPath), LastStatus, FS, Monitor);
   std::this_thread::sleep_for(RefreshFrequency);
 }
   });
 
-  runServerAndWait(Index, ServerAddress, IndexPath);
+  runServerAndWait(Index, ServerAddress, IndexPath, Monitor);
 
   HotReloadThread.join();
 }
Index: clang-tools-extra/clangd/index/remote/Service.proto
===
--- clang-tools-extra/clangd/index/remote/Service.proto
+++ clang-tools-extra/clangd/index/remote/Service.proto
@@ -23,4 +23,3 @@
 
   rpc Relations(RelationsRequest) returns (stream RelationsReply) {}
 }
-
Index: clang-tools-extra/clangd/index/remote/MonitoringService.proto

[PATCH] D97717: [SYCL] Rework the SYCL driver options

2021-03-15 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman marked an inline comment as done.
aaron.ballman added inline comments.



Comment at: clang/unittests/Frontend/CompilerInvocationTest.cpp:547
+  // there is no syntax I could find that would allow it). However, the option
+  // is handled properly on a real invocation. See: Clang::ConstructJob().
+  ASSERT_THAT(GeneratedArgs, Contains(HasSubstr("-sycl-std=")));

jansvoboda11 wrote:
> The `generateCC1CommandLine` function is used when CC1 gets invoked with 
> `-round-trip-args`. It is also going to be used in `clang-scan-deps`.
> 
> Instead of putting a fixme here, I think it would make more sense to decide 
> how to handle the option properly. There are a couple of approaches:
> * Instead of removing `ShouldParseIf` from `sycl_std_EQ`, it 
> could be replaced with `ShouldParseIf "||", fsycl_is_host.KeyPath)>`.
> * Remove `ShouldParseIf` from `sycl_std_EQ`, but issue 
> warning/error in `CompilerInvocation::fixupInvocation` whenever `SYCLVersion 
> != LangOptions::SYCL_None && !(SYCLIsDevice || SYCLIsHost)`.
> * Remove the marshalling annotation from `sycl_std_EQ` and handle its 
> parsing/generation including the device/host checks manually in 
> `CompilerInvocation`. (I'm personally not fan of moving simple logic like 
> this from tablegen marshalling annotations to `CompilerInvocation` though.)
> 
> See 
> https://clang.llvm.org/docs/InternalsManual.html#adding-new-command-line-option
>  for more information.
Thank you for the suggestions! I took the first suggestion and applied it in 
this latest revision and I really like the results.


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

https://reviews.llvm.org/D97717

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


[PATCH] D97717: [SYCL] Rework the SYCL driver options

2021-03-15 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman updated this revision to Diff 330786.
aaron.ballman added a comment.

Update based on review feedback to gate use of -sycl-std on use of 
-fsycl-is-device or -fsycl-is-host.


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

https://reviews.llvm.org/D97717

Files:
  clang/include/clang/Basic/LangOptions.def
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/lib/Frontend/InitPreprocessor.cpp
  clang/test/CodeGenSYCL/convergent.cpp
  clang/test/CodeGenSYCL/filescope_asm.c
  clang/test/Frontend/sycl-aux-triple.cpp
  clang/test/Frontend/sycl.cpp
  clang/test/Preprocessor/sycl-macro.cpp
  clang/test/SemaSYCL/float128.cpp
  clang/test/SemaSYCL/int128.cpp
  clang/test/SemaSYCL/kernel-attribute.cpp
  clang/test/SemaSYCL/prohibit-thread-local.cpp
  clang/unittests/Frontend/CompilerInvocationTest.cpp

Index: clang/unittests/Frontend/CompilerInvocationTest.cpp
===
--- clang/unittests/Frontend/CompilerInvocationTest.cpp
+++ clang/unittests/Frontend/CompilerInvocationTest.cpp
@@ -516,7 +516,8 @@
   CompilerInvocation::CreateFromArgs(Invocation, Args, *Diags);
 
   ASSERT_FALSE(Diags->hasErrorOccurred());
-  ASSERT_FALSE(Invocation.getLangOpts()->SYCL);
+  ASSERT_FALSE(Invocation.getLangOpts()->SYCLIsDevice);
+  ASSERT_FALSE(Invocation.getLangOpts()->SYCLIsHost);
   ASSERT_EQ(Invocation.getLangOpts()->getSYCLVersion(), LangOptions::SYCL_None);
 
   Invocation.generateCC1CommandLine(GeneratedArgs, *this);
@@ -531,12 +532,14 @@
   CompilerInvocation::CreateFromArgs(Invocation, Args, *Diags);
 
   ASSERT_FALSE(Diags->hasErrorOccurred());
-  ASSERT_FALSE(Invocation.getLangOpts()->SYCL);
+  ASSERT_FALSE(Invocation.getLangOpts()->SYCLIsDevice);
+  ASSERT_FALSE(Invocation.getLangOpts()->SYCLIsHost);
   ASSERT_EQ(Invocation.getLangOpts()->getSYCLVersion(), LangOptions::SYCL_None);
 
   Invocation.generateCC1CommandLine(GeneratedArgs, *this);
 
-  ASSERT_THAT(GeneratedArgs, Not(Contains(StrEq("-fsycl";
+  ASSERT_THAT(GeneratedArgs, Not(Contains(StrEq("-fsycl-is-device";
+  ASSERT_THAT(GeneratedArgs, Not(Contains(StrEq("-fsycl-is-host";
   ASSERT_THAT(GeneratedArgs, Not(Contains(HasSubstr("-sycl-std=";
 }
 
@@ -545,13 +548,12 @@
 
   CompilerInvocation::CreateFromArgs(Invocation, Args, *Diags);
 
-  ASSERT_FALSE(Diags->hasErrorOccurred());
-  ASSERT_TRUE(Invocation.getLangOpts()->SYCL);
+  ASSERT_TRUE(Diags->hasErrorOccurred());
   ASSERT_EQ(Invocation.getLangOpts()->getSYCLVersion(), LangOptions::SYCL_None);
 
   Invocation.generateCC1CommandLine(GeneratedArgs, *this);
 
-  ASSERT_THAT(GeneratedArgs, Contains(StrEq("-fsycl")));
+  ASSERT_THAT(GeneratedArgs, Not(Contains(StrEq("-fsycl";
   ASSERT_THAT(GeneratedArgs, Not(Contains(HasSubstr("-sycl-std=";
 }
 
@@ -560,14 +562,13 @@
 
   CompilerInvocation::CreateFromArgs(Invocation, Args, *Diags);
 
-  ASSERT_FALSE(Diags->hasErrorOccurred());
-  ASSERT_TRUE(Invocation.getLangOpts()->SYCL);
-  ASSERT_EQ(Invocation.getLangOpts()->getSYCLVersion(), LangOptions::SYCL_2017);
+  ASSERT_TRUE(Diags->hasErrorOccurred());
+  ASSERT_EQ(Invocation.getLangOpts()->getSYCLVersion(), LangOptions::SYCL_None);
 
   Invocation.generateCC1CommandLine(GeneratedArgs, *this);
 
-  ASSERT_THAT(GeneratedArgs, Contains(StrEq("-fsycl")));
-  ASSERT_THAT(GeneratedArgs, Contains(StrEq("-sycl-std=2017")));
+  ASSERT_THAT(GeneratedArgs, Not(Contains(StrEq("-fsycl";
+  ASSERT_THAT(GeneratedArgs, Not(Contains(StrEq("-sycl-std=2017";
 }
 
 // Wide integer option.
Index: clang/test/SemaSYCL/prohibit-thread-local.cpp
===
--- clang/test/SemaSYCL/prohibit-thread-local.cpp
+++ clang/test/SemaSYCL/prohibit-thread-local.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsycl -fsycl-is-device -triple spir64 -verify -fsyntax-only %s
+// RUN: %clang_cc1 -fsycl-is-device -triple spir64 -verify -fsyntax-only %s
 
 thread_local const int prohobit_ns_scope = 0;
 thread_local int prohobit_ns_scope2 = 0;
Index: clang/test/SemaSYCL/kernel-attribute.cpp
===
--- clang/test/SemaSYCL/kernel-attribute.cpp
+++ clang/test/SemaSYCL/kernel-attribute.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -std=c++11 -fsyntax-only -fsycl -fsycl-is-device -verify %s
+// RUN: %clang_cc1 -std=c++11 -fsyntax-only -fsycl-is-device -verify %s
 
 // Only function templates
 [[clang::sycl_kernel]] int gv2 = 0; // expected-warning {{'sycl_kernel' attribute only applies to function templates}}
Index: clang/test/SemaSYCL/int128.cpp
===
--- clang/test/SemaSYCL/int128.cpp
+++ clang/test/SemaSYCL/int128.cpp
@@ -1,5 +1,5 @@
 // RUN: %clang_cc1 -triple spir64 -aux-triple x86_64-unknown-linux-gnu \
-// RUN:-fsycl -fsycl-is-device -verify -fsyntax-only %s
+// RUN:-fsycl-is-device 

[PATCH] D97080: [flang][driver] Add -fintrinsic-modules-path option

2021-03-15 Thread Arnamoy B via Phabricator via cfe-commits
arnamoy10 updated this revision to Diff 330785.
arnamoy10 added a comment.

Adding the dummy modules


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

https://reviews.llvm.org/D97080

Files:
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/ToolChains/Flang.cpp
  flang/include/flang/Frontend/PreprocessorOptions.h
  flang/lib/Frontend/CompilerInvocation.cpp
  flang/test/Driver/Inputs/ieee_arithmetic.mod
  flang/test/Driver/Inputs/iso_fortran_env.mod
  flang/test/Driver/driver-help-hidden.f90
  flang/test/Driver/driver-help.f90

Index: flang/test/Driver/driver-help.f90
===
--- flang/test/Driver/driver-help.f90
+++ flang/test/Driver/driver-help.f90
@@ -35,6 +35,8 @@
 ! HELP-NEXT: -ffree-formProcess source files in free form
 ! HELP-NEXT: -fimplicit-noneNo implicit typing allowed unless overridden by IMPLICIT statements
 ! HELP-NEXT: -finput-charset= Specify the default character set for source files
+! HELP-NEXT: -fintrinsic-modules-path 
+! HELP-NEXT:Specify where to find the compiled intrinsic modules
 ! HELP-NEXT: -flarge-sizes  Use INTEGER(KIND=8) for the result type in size-related intrinsics
 ! HELP-NEXT: -flogical-abbreviations Enable logical abbreviations
 ! HELP-NEXT: -fno-color-diagnostics Disable colors in diagnostics
@@ -82,6 +84,8 @@
 ! HELP-FC1-NEXT: -ffree-formProcess source files in free form
 ! HELP-FC1-NEXT: -fimplicit-noneNo implicit typing allowed unless overridden by IMPLICIT statements
 ! HELP-FC1-NEXT: -finput-charset= Specify the default character set for source files
+! HELP-FC1-NEXT: -fintrinsic-modules-path 
+! HELP-FC1-NEXT:Specify where to find the compiled intrinsic modules
 ! HELP-FC1-NEXT: -flarge-sizes  Use INTEGER(KIND=8) for the result type in size-related intrinsics
 ! HELP-FC1-NEXT: -flogical-abbreviations Enable logical abbreviations
 ! HELP-FC1-NEXT: -fopenacc  Enable OpenACC
Index: flang/test/Driver/driver-help-hidden.f90
===
--- flang/test/Driver/driver-help-hidden.f90
+++ flang/test/Driver/driver-help-hidden.f90
@@ -35,6 +35,8 @@
 ! CHECK-NEXT: -ffree-formProcess source files in free form
 ! CHECK-NEXT: -fimplicit-noneNo implicit typing allowed unless overridden by IMPLICIT statements
 ! CHECK-NEXT: -finput-charset= Specify the default character set for source files
+! CHECK-NEXT: -fintrinsic-modules-path 
+! CHECK-NEXT:Specify where to find the compiled intrinsic modules
 ! CHECK-NEXT: -flarge-sizes  Use INTEGER(KIND=8) for the result type in size-related intrinsics
 ! CHECK-NEXT: -flogical-abbreviations Enable logical abbreviations
 ! CHECK-NEXT: -fno-color-diagnostics Disable colors in diagnostics
Index: flang/test/Driver/Inputs/iso_fortran_env.mod
===
--- /dev/null
+++ flang/test/Driver/Inputs/iso_fortran_env.mod
@@ -0,0 +1,7 @@
+! DUMMY module
+! Added for testing purposes. The contents of this file are currently not relevant.
+module iso_fortran_env
+use __fortran_builtins,only:event_type=>__builtin_event_type
+use __fortran_builtins,only:lock_type=>__builtin_lock_type
+use __fortran_builtins,only:team_type=>__builtin_team_type
+end
Index: flang/test/Driver/Inputs/ieee_arithmetic.mod
===
--- /dev/null
+++ flang/test/Driver/Inputs/ieee_arithmetic.mod
@@ -0,0 +1,7 @@
+! DUMMY module
+! Added for testing purposes. The contents of this file are currently not relevant.
+module ieee_arithmetic
+type::ieee_round_type
+integer(1),private::mode=0_1
+end type
+end
Index: flang/lib/Frontend/CompilerInvocation.cpp
===
--- flang/lib/Frontend/CompilerInvocation.cpp
+++ flang/lib/Frontend/CompilerInvocation.cpp
@@ -21,8 +21,11 @@
 #include "llvm/Option/Arg.h"
 #include "llvm/Option/ArgList.h"
 #include "llvm/Option/OptTable.h"
+#include "llvm/Support/FileSystem.h"
+#include "llvm/Support/FileUtilities.h"
 #include "llvm/Support/Process.h"
 #include "llvm/Support/raw_ostream.h"
+
 #include 
 
 using namespace Fortran::frontend;
@@ -282,6 +285,14 @@
   return dashX;
 }
 
+// Generate the path to look for intrinsic modules
+static std::string getIntrinsicDir() {
+  // TODO: Find a system independent API
+  std::string driverPath = llvm::sys::fs::getMainExecutable(nullptr, nullptr);
+  driverPath = driverPath.substr(0, driverPath.size() - 9);
+  return driverPath.append("/../include/flang/");
+}
+
 /// Parses all preprocessor input arguments and populates the preprocessor
 /// options accordingly.
 ///
@@ -302,6 +313,12 @@
   // Add the ordered list of -I's.
   for (const auto *currentArg : args.filtered(clang::driver::options::OPT_I))
 

[PATCH] D98363: [Sema] Fold VLA types in compound literals to constant arrays.

2021-03-15 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: clang/test/Sema/vla.c:134
+  // expected-warning@+1{{variable length array folded to constant array as an 
extension}}
+  char (*a9)[] = (char[2][ksize]) {{1,2,3,4},{4,3,2,1}};
+

efriedma wrote:
> aaron.ballman wrote:
> > Doesn't this violate the constraints in C17 6.5.2.5p1, "The type name shall 
> > specify a complete object type or an array of unknown size, but not a 
> > variable-length array type"?
> Yes, this is a constraint violation.  This patch downgrades the error to a 
> warning, for compatibility with older versions of clang.
It was an error in older versions of Clang, so downgrading it to a warning 
can't make code *more* compatible with older versions. This also makes it 
harder to port C code to other compilers because Clang happily accepts code 
that the C standard says should be rejected.

I'm not strongly opposed to the change, but I also don't like ignoring 
constraint violations in the standard as that comes awfully close to what 
`-fpermissive` does (and at least with that awful flag you have to opt *into* 
the less strictly conforming behavior instead of getting it by default as with 
extensions).

I'm curious if @rsmith has thoughts here?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98363

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


[PATCH] D97567: [clang-tidy] performance-* checks: Also allow allow member expressions to be used in a const manner.

2021-03-15 Thread Felix Berger via Phabricator via cfe-commits
flx added a comment.

Hi,

could someone please take a look at this? Thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97567

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


[PATCH] D98472: Emit inline implementation of __builtin__wmemchr on MSVCRT platforms.

2021-03-15 Thread Reid Kleckner via Phabricator via cfe-commits
rnk accepted this revision.
rnk added a comment.
This revision is now accepted and ready to land.

lgtm w nit




Comment at: clang/test/CodeGen/wmemchr.c:7
+const wchar_t *wmemchr_test(const wchar_t *s, const wchar_t c, size_t n) {
+  // CHECK: [[S:%.*]] = load
+  // CHECK: [[C:%.*]] = load

I'd start these off with `CHECK-LABEL: define i16* @wmemchr_test` as a little 
bit of future proofing.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98472

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


[PATCH] D98546: [PowerPC] Add __PCREL__ when PC Relative is enabled.

2021-03-15 Thread Stefan Pintilie via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG86f2a3d17878: [PowerPC] Add __PCREL__ when PC Relative is 
enabled. (authored by stefanp).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98546

Files:
  clang/lib/Basic/Targets/PPC.cpp
  clang/test/Preprocessor/init-ppc64.c


Index: clang/test/Preprocessor/init-ppc64.c
===
--- clang/test/Preprocessor/init-ppc64.c
+++ clang/test/Preprocessor/init-ppc64.c
@@ -633,6 +633,7 @@
 // PPCPOWER10:#define _ARCH_PWR8 1
 // PPCPOWER10:#define _ARCH_PWR9 1
 // PPCPOWER10:#define __MMA__ 1
+// PPCPOWER10:#define __PCREL__ 1
 // PPCPOWER10-NOT:#define __ROP_PROTECTION__ 1
 //
 // RUN: %clang_cc1 -E -dM -ffreestanding -triple=powerpc64-none-none 
-target-cpu future -fno-signed-char < /dev/null | FileCheck -match-full-lines 
-check-prefix PPCFUTURE %s
@@ -652,6 +653,7 @@
 // PPCFUTURE:#define _ARCH_PWR9 1
 // PPCFUTURE:#define _ARCH_PWR_FUTURE 1
 // PPCFUTURE:#define __MMA__ 1
+// PPCFUTURE:#define __PCREL__ 1
 // PPCFUTURE-NOT:#define __ROP_PROTECTION__ 1
 //
 // RUN: %clang_cc1 -E -dM -ffreestanding -triple=powerpc64-none-none 
-target-feature +mma -target-cpu power10 -fno-signed-char < /dev/null | 
FileCheck -check-prefix PPC-MMA %s
Index: clang/lib/Basic/Targets/PPC.cpp
===
--- clang/lib/Basic/Targets/PPC.cpp
+++ clang/lib/Basic/Targets/PPC.cpp
@@ -199,6 +199,8 @@
 Builder.defineMacro("__ROP_PROTECTION__");
   if (HasP10Vector)
 Builder.defineMacro("__POWER10_VECTOR__");
+  if (HasPCRelativeMemops)
+Builder.defineMacro("__PCREL__");
 
   Builder.defineMacro("__GCC_HAVE_SYNC_COMPARE_AND_SWAP_1");
   Builder.defineMacro("__GCC_HAVE_SYNC_COMPARE_AND_SWAP_2");


Index: clang/test/Preprocessor/init-ppc64.c
===
--- clang/test/Preprocessor/init-ppc64.c
+++ clang/test/Preprocessor/init-ppc64.c
@@ -633,6 +633,7 @@
 // PPCPOWER10:#define _ARCH_PWR8 1
 // PPCPOWER10:#define _ARCH_PWR9 1
 // PPCPOWER10:#define __MMA__ 1
+// PPCPOWER10:#define __PCREL__ 1
 // PPCPOWER10-NOT:#define __ROP_PROTECTION__ 1
 //
 // RUN: %clang_cc1 -E -dM -ffreestanding -triple=powerpc64-none-none -target-cpu future -fno-signed-char < /dev/null | FileCheck -match-full-lines -check-prefix PPCFUTURE %s
@@ -652,6 +653,7 @@
 // PPCFUTURE:#define _ARCH_PWR9 1
 // PPCFUTURE:#define _ARCH_PWR_FUTURE 1
 // PPCFUTURE:#define __MMA__ 1
+// PPCFUTURE:#define __PCREL__ 1
 // PPCFUTURE-NOT:#define __ROP_PROTECTION__ 1
 //
 // RUN: %clang_cc1 -E -dM -ffreestanding -triple=powerpc64-none-none -target-feature +mma -target-cpu power10 -fno-signed-char < /dev/null | FileCheck -check-prefix PPC-MMA %s
Index: clang/lib/Basic/Targets/PPC.cpp
===
--- clang/lib/Basic/Targets/PPC.cpp
+++ clang/lib/Basic/Targets/PPC.cpp
@@ -199,6 +199,8 @@
 Builder.defineMacro("__ROP_PROTECTION__");
   if (HasP10Vector)
 Builder.defineMacro("__POWER10_VECTOR__");
+  if (HasPCRelativeMemops)
+Builder.defineMacro("__PCREL__");
 
   Builder.defineMacro("__GCC_HAVE_SYNC_COMPARE_AND_SWAP_1");
   Builder.defineMacro("__GCC_HAVE_SYNC_COMPARE_AND_SWAP_2");
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 86f2a3d - [PowerPC] Add __PCREL__ when PC Relative is enabled.

2021-03-15 Thread Stefan Pintilie via cfe-commits

Author: Stefan Pintilie
Date: 2021-03-15T15:13:02-05:00
New Revision: 86f2a3d17878e430109be209fdb013fb3f4716ee

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

LOG: [PowerPC] Add __PCREL__ when PC Relative is enabled.

This patch adds the `__PCREL__` define when PC Relative addressing is enabled.

Reviewed By: nemanjai, #powerpc

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

Added: 


Modified: 
clang/lib/Basic/Targets/PPC.cpp
clang/test/Preprocessor/init-ppc64.c

Removed: 




diff  --git a/clang/lib/Basic/Targets/PPC.cpp b/clang/lib/Basic/Targets/PPC.cpp
index 78397abfe1f5..57f5de1d0c66 100644
--- a/clang/lib/Basic/Targets/PPC.cpp
+++ b/clang/lib/Basic/Targets/PPC.cpp
@@ -199,6 +199,8 @@ void PPCTargetInfo::getTargetDefines(const LangOptions 
,
 Builder.defineMacro("__ROP_PROTECTION__");
   if (HasP10Vector)
 Builder.defineMacro("__POWER10_VECTOR__");
+  if (HasPCRelativeMemops)
+Builder.defineMacro("__PCREL__");
 
   Builder.defineMacro("__GCC_HAVE_SYNC_COMPARE_AND_SWAP_1");
   Builder.defineMacro("__GCC_HAVE_SYNC_COMPARE_AND_SWAP_2");

diff  --git a/clang/test/Preprocessor/init-ppc64.c 
b/clang/test/Preprocessor/init-ppc64.c
index 163e86b919bc..08368f323d44 100644
--- a/clang/test/Preprocessor/init-ppc64.c
+++ b/clang/test/Preprocessor/init-ppc64.c
@@ -633,6 +633,7 @@
 // PPCPOWER10:#define _ARCH_PWR8 1
 // PPCPOWER10:#define _ARCH_PWR9 1
 // PPCPOWER10:#define __MMA__ 1
+// PPCPOWER10:#define __PCREL__ 1
 // PPCPOWER10-NOT:#define __ROP_PROTECTION__ 1
 //
 // RUN: %clang_cc1 -E -dM -ffreestanding -triple=powerpc64-none-none 
-target-cpu future -fno-signed-char < /dev/null | FileCheck -match-full-lines 
-check-prefix PPCFUTURE %s
@@ -652,6 +653,7 @@
 // PPCFUTURE:#define _ARCH_PWR9 1
 // PPCFUTURE:#define _ARCH_PWR_FUTURE 1
 // PPCFUTURE:#define __MMA__ 1
+// PPCFUTURE:#define __PCREL__ 1
 // PPCFUTURE-NOT:#define __ROP_PROTECTION__ 1
 //
 // RUN: %clang_cc1 -E -dM -ffreestanding -triple=powerpc64-none-none 
-target-feature +mma -target-cpu power10 -fno-signed-char < /dev/null | 
FileCheck -check-prefix PPC-MMA %s



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


[PATCH] D98657: [flang][driver] Add options for -Werror

2021-03-15 Thread Arnamoy B via Phabricator via cfe-commits
arnamoy10 created this revision.
arnamoy10 added reviewers: awarzynski, SouraVX, tskeith, AMDChirag, sscalpone, 
bryanpkc.
Herald added subscribers: jansvoboda11, dang.
arnamoy10 requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Add the following option for the flang-driver

`-Werror`

With the option given, warnings are treated as error.

Relevant f18 test file is also updated to include `flang-new`


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D98657

Files:
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/ToolChains/Flang.cpp
  flang/include/flang/Frontend/CompilerInvocation.h
  flang/lib/Frontend/CompilerInvocation.cpp
  flang/test/Semantics/dosemantics03.f90


Index: flang/test/Semantics/dosemantics03.f90
===
--- flang/test/Semantics/dosemantics03.f90
+++ flang/test/Semantics/dosemantics03.f90
@@ -1,4 +1,5 @@
 ! RUN: %S/test_errors.sh %s %t %f18 -Mstandard -Werror
+! RUN: %S/test_errors.sh %s %t %flang_fc1 -Werror
 
 ! Issue 458 -- semantic checks for a normal DO loop.  The DO variable
 ! and the initial, final, and step expressions must be INTEGER if the
Index: flang/lib/Frontend/CompilerInvocation.cpp
===
--- flang/lib/Frontend/CompilerInvocation.cpp
+++ flang/lib/Frontend/CompilerInvocation.cpp
@@ -327,6 +327,11 @@
   if (args.hasArg(clang::driver::options::OPT_fdebug_module_writer)) {
 res.SetDebugModuleDir(true);
   }
+
+  // -Werror option
+  if (args.hasArg(clang::driver::options::OPT_werror)) {
+res.SetWarnAsErr(true);
+  }
 }
 
 /// Parses all Dialect related arguments and populates the variables
@@ -518,5 +523,6 @@
   defaultKinds(), fortranOptions.features, allCookedSources);
 
   semanticsContext_->set_moduleDirectory(moduleDir())
-  .set_searchDirectories(fortranOptions.searchDirectories);
+  .set_searchDirectories(fortranOptions.searchDirectories)
+  .set_warningsAreErrors(warnAsErr());
 }
Index: flang/include/flang/Frontend/CompilerInvocation.h
===
--- flang/include/flang/Frontend/CompilerInvocation.h
+++ flang/include/flang/Frontend/CompilerInvocation.h
@@ -71,6 +71,8 @@
 
   bool debugModuleDir_ = false;
 
+  bool warnAsErr_ = false;
+
   // Fortran Dialect options
   Fortran::common::IntrinsicTypeDefaultKinds defaultKinds_;
 
@@ -96,6 +98,9 @@
   bool () { return debugModuleDir_; }
   const bool () const { return debugModuleDir_; }
 
+  bool () { return warnAsErr_; }
+  const bool () const { return warnAsErr_; }
+
   Fortran::common::IntrinsicTypeDefaultKinds () {
 return defaultKinds_;
   }
@@ -116,6 +121,8 @@
 
   void SetDebugModuleDir(bool flag) { debugModuleDir_ = flag; }
 
+  void SetWarnAsErr(bool flag) { warnAsErr_ = flag; }
+
   /// Set the Fortran options to predifined defaults. These defaults are
   /// consistend with f18/f18.cpp.
   // TODO: We should map frontendOpts_ to parserOpts_ instead. For that, we
Index: clang/lib/Driver/ToolChains/Flang.cpp
===
--- clang/lib/Driver/ToolChains/Flang.cpp
+++ clang/lib/Driver/ToolChains/Flang.cpp
@@ -42,7 +42,8 @@
 
 void Flang::AddOtherOptions(const ArgList , ArgStringList ) const 
{
   Args.AddAllArgs(CmdArgs,
-  {options::OPT_module_dir, 
options::OPT_fdebug_module_writer});
+  {options::OPT_module_dir, options::OPT_fdebug_module_writer,
+   options::OPT_werror});
 }
 
 void Flang::ConstructJob(Compilation , const JobAction ,
Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -4342,6 +4342,8 @@
 def fno_implicit_none : Flag<["-"], "fno-implicit-none">, Group;
 def falternative_parameter_statement : Flag<["-"], 
"falternative-parameter-statement">, Group,
   HelpText<"Enable the old style PARAMETER statement">;
+def werror : Flag<["-"], "Werror">, Group,
+  HelpText<"Make all warnings into errors">;
 }
 
 
//===--===//


Index: flang/test/Semantics/dosemantics03.f90
===
--- flang/test/Semantics/dosemantics03.f90
+++ flang/test/Semantics/dosemantics03.f90
@@ -1,4 +1,5 @@
 ! RUN: %S/test_errors.sh %s %t %f18 -Mstandard -Werror
+! RUN: %S/test_errors.sh %s %t %flang_fc1 -Werror
 
 ! Issue 458 -- semantic checks for a normal DO loop.  The DO variable
 ! and the initial, final, and step expressions must be INTEGER if the
Index: flang/lib/Frontend/CompilerInvocation.cpp
===
--- flang/lib/Frontend/CompilerInvocation.cpp
+++ flang/lib/Frontend/CompilerInvocation.cpp
@@ -327,6 +327,11 @@
 

[PATCH] D98404: [clangd] Optionally add reflection for clangd-index-server

2021-03-15 Thread Kirill Bobyrev via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG9bcf0eff99a0: [clangd] Optionally add reflection for 
clangd-index-server (authored by kbobyrev).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98404

Files:
  clang-tools-extra/clangd/CMakeLists.txt
  clang-tools-extra/clangd/Features.inc.in
  clang-tools-extra/clangd/index/remote/server/CMakeLists.txt
  clang-tools-extra/clangd/index/remote/server/Server.cpp
  llvm/cmake/modules/FindGRPC.cmake

Index: llvm/cmake/modules/FindGRPC.cmake
===
--- llvm/cmake/modules/FindGRPC.cmake
+++ llvm/cmake/modules/FindGRPC.cmake
@@ -1,3 +1,5 @@
+option(ENABLE_GRPC_REFLECTION "Link clangd-index-server to gRPC Reflection library" OFF)
+
 # FIXME(kirillbobyrev): Check if gRPC and Protobuf headers can be included at
 # configure time.
 find_package(Threads REQUIRED)
@@ -22,6 +24,10 @@
   add_library(protobuf ALIAS protobuf::libprotobuf)
   set_target_properties(gRPC::grpc++ PROPERTIES IMPORTED_GLOBAL TRUE)
   add_library(grpc++ ALIAS gRPC::grpc++)
+  if (ENABLE_GRPC_REFLECTION)
+set_target_properties(gRPC::grpc++_reflection PROPERTIES IMPORTED_GLOBAL TRUE)
+add_library(grpc++_reflection ALIAS gRPC::grpc++_reflection)
+  endif()
 
   set(GRPC_CPP_PLUGIN $)
   set(PROTOC ${Protobuf_PROTOC_EXECUTABLE})
@@ -71,12 +77,21 @@
   add_library(grpc++ UNKNOWN IMPORTED GLOBAL)
   message(STATUS "Using grpc++: " ${GRPC_LIBRARY})
   set_target_properties(grpc++ PROPERTIES IMPORTED_LOCATION ${GRPC_LIBRARY})
+  if (ENABLE_GRPC_REFLECTION)
+find_library(GRPC_REFLECTION_LIBRARY grpc++_reflection $GRPC_OPTS REQUIRED)
+add_library(grpc++_reflection UNKNOWN IMPORTED GLOBAL)
+set_target_properties(grpc++_reflection PROPERTIES IMPORTED_LOCATION ${GRPC_REFLECTION_LIBRARY})
+  endif()
   find_library(PROTOBUF_LIBRARY protobuf $PROTOBUF_OPTS REQUIRED)
   message(STATUS "Using protobuf: " ${PROTOBUF_LIBRARY})
   add_library(protobuf UNKNOWN IMPORTED GLOBAL)
   set_target_properties(protobuf PROPERTIES IMPORTED_LOCATION ${PROTOBUF_LIBRARY})
 endif()
 
+if (ENABLE_GRPC_REFLECTION)
+  set(REFLECTION_LIBRARY grpc++_reflection)
+endif()
+
 # Proto headers are generated in ${CMAKE_CURRENT_BINARY_DIR}.
 # Libraries that use these headers should adjust the include path.
 # If the "GRPC" argument is given, services are also generated.
Index: clang-tools-extra/clangd/index/remote/server/Server.cpp
===
--- clang-tools-extra/clangd/index/remote/server/Server.cpp
+++ clang-tools-extra/clangd/index/remote/server/Server.cpp
@@ -6,6 +6,7 @@
 //
 //===--===//
 
+#include "Features.inc"
 #include "Index.pb.h"
 #include "Service.grpc.pb.h"
 #include "index/Index.h"
@@ -35,6 +36,10 @@
 #include 
 #include 
 
+#if ENABLE_GRPC_REFLECTION
+#include 
+#endif
+
 namespace clang {
 namespace clangd {
 namespace remote {
@@ -313,6 +318,9 @@
   RemoteIndexServer Service(Index, IndexRoot);
 
   grpc::EnableDefaultHealthCheckService(true);
+#if ENABLE_GRPC_REFLECTION
+  grpc::reflection::InitProtoReflectionServerBuilderPlugin();
+#endif
   grpc::ServerBuilder Builder;
   Builder.AddListeningPort(ServerAddress.str(),
grpc::InsecureServerCredentials());
Index: clang-tools-extra/clangd/index/remote/server/CMakeLists.txt
===
--- clang-tools-extra/clangd/index/remote/server/CMakeLists.txt
+++ clang-tools-extra/clangd/index/remote/server/CMakeLists.txt
@@ -17,4 +17,6 @@
   RemoteIndexProto
   RemoteIndexServiceProto
   clangdRemoteMarshalling
+
+  ${REFLECTION_LIBRARY}
   )
Index: clang-tools-extra/clangd/Features.inc.in
===
--- clang-tools-extra/clangd/Features.inc.in
+++ clang-tools-extra/clangd/Features.inc.in
@@ -1,3 +1,4 @@
 #define CLANGD_BUILD_XPC @CLANGD_BUILD_XPC@
 #define CLANGD_ENABLE_REMOTE @CLANGD_ENABLE_REMOTE@
+#define ENABLE_GRPC_REFLECTION @ENABLE_GRPC_REFLECTION@
 #define CLANGD_MALLOC_TRIM @CLANGD_MALLOC_TRIM@
Index: clang-tools-extra/clangd/CMakeLists.txt
===
--- clang-tools-extra/clangd/CMakeLists.txt
+++ clang-tools-extra/clangd/CMakeLists.txt
@@ -19,6 +19,7 @@
 llvm_canonicalize_cmake_booleans(
   CLANGD_BUILD_XPC
   CLANGD_ENABLE_REMOTE
+  ENABLE_GRPC_REFLECTION
   CLANGD_MALLOC_TRIM
   LLVM_ENABLE_ZLIB
 )
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] 9bcf0ef - [clangd] Optionally add reflection for clangd-index-server

2021-03-15 Thread Kirill Bobyrev via cfe-commits

Author: Kirill Bobyrev
Date: 2021-03-15T21:07:25+01:00
New Revision: 9bcf0eff99a01094c685ff375a42e3f5a9166094

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

LOG: [clangd] Optionally add reflection for clangd-index-server

This was originally landed without the optional part and reverted later:

https://github.com/llvm/llvm-project/commit/8080ea4c4b8c456c72c617587cc32f174b3105c1

Reviewed By: kadircet

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

Added: 


Modified: 
clang-tools-extra/clangd/CMakeLists.txt
clang-tools-extra/clangd/Features.inc.in
clang-tools-extra/clangd/index/remote/server/CMakeLists.txt
clang-tools-extra/clangd/index/remote/server/Server.cpp
llvm/cmake/modules/FindGRPC.cmake

Removed: 




diff  --git a/clang-tools-extra/clangd/CMakeLists.txt 
b/clang-tools-extra/clangd/CMakeLists.txt
index a6229a229002..11b8c7eadd1d 100644
--- a/clang-tools-extra/clangd/CMakeLists.txt
+++ b/clang-tools-extra/clangd/CMakeLists.txt
@@ -19,6 +19,7 @@ option(CLANGD_MALLOC_TRIM "Call malloc_trim(3) periodically 
in Clangd. (only tak
 llvm_canonicalize_cmake_booleans(
   CLANGD_BUILD_XPC
   CLANGD_ENABLE_REMOTE
+  ENABLE_GRPC_REFLECTION
   CLANGD_MALLOC_TRIM
   LLVM_ENABLE_ZLIB
 )

diff  --git a/clang-tools-extra/clangd/Features.inc.in 
b/clang-tools-extra/clangd/Features.inc.in
index c21d2b145571..5dfde58890b7 100644
--- a/clang-tools-extra/clangd/Features.inc.in
+++ b/clang-tools-extra/clangd/Features.inc.in
@@ -1,3 +1,4 @@
 #define CLANGD_BUILD_XPC @CLANGD_BUILD_XPC@
 #define CLANGD_ENABLE_REMOTE @CLANGD_ENABLE_REMOTE@
+#define ENABLE_GRPC_REFLECTION @ENABLE_GRPC_REFLECTION@
 #define CLANGD_MALLOC_TRIM @CLANGD_MALLOC_TRIM@

diff  --git a/clang-tools-extra/clangd/index/remote/server/CMakeLists.txt 
b/clang-tools-extra/clangd/index/remote/server/CMakeLists.txt
index e6959db6bbd8..90b62caf524c 100644
--- a/clang-tools-extra/clangd/index/remote/server/CMakeLists.txt
+++ b/clang-tools-extra/clangd/index/remote/server/CMakeLists.txt
@@ -17,4 +17,6 @@ target_link_libraries(clangd-index-server
   RemoteIndexProto
   RemoteIndexServiceProto
   clangdRemoteMarshalling
+
+  ${REFLECTION_LIBRARY}
   )

diff  --git a/clang-tools-extra/clangd/index/remote/server/Server.cpp 
b/clang-tools-extra/clangd/index/remote/server/Server.cpp
index 3de2c38f7c08..be0e844a1f80 100644
--- a/clang-tools-extra/clangd/index/remote/server/Server.cpp
+++ b/clang-tools-extra/clangd/index/remote/server/Server.cpp
@@ -6,6 +6,7 @@
 //
 
//===--===//
 
+#include "Features.inc"
 #include "Index.pb.h"
 #include "Service.grpc.pb.h"
 #include "index/Index.h"
@@ -35,6 +36,10 @@
 #include 
 #include 
 
+#if ENABLE_GRPC_REFLECTION
+#include 
+#endif
+
 namespace clang {
 namespace clangd {
 namespace remote {
@@ -313,6 +318,9 @@ void runServerAndWait(clangd::SymbolIndex , 
llvm::StringRef ServerAddress,
   RemoteIndexServer Service(Index, IndexRoot);
 
   grpc::EnableDefaultHealthCheckService(true);
+#if ENABLE_GRPC_REFLECTION
+  grpc::reflection::InitProtoReflectionServerBuilderPlugin();
+#endif
   grpc::ServerBuilder Builder;
   Builder.AddListeningPort(ServerAddress.str(),
grpc::InsecureServerCredentials());

diff  --git a/llvm/cmake/modules/FindGRPC.cmake 
b/llvm/cmake/modules/FindGRPC.cmake
index 8fdb3506dff1..66e9d832ae94 100644
--- a/llvm/cmake/modules/FindGRPC.cmake
+++ b/llvm/cmake/modules/FindGRPC.cmake
@@ -1,3 +1,5 @@
+option(ENABLE_GRPC_REFLECTION "Link clangd-index-server to gRPC Reflection 
library" OFF)
+
 # FIXME(kirillbobyrev): Check if gRPC and Protobuf headers can be included at
 # configure time.
 find_package(Threads REQUIRED)
@@ -22,6 +24,10 @@ if (GRPC_INSTALL_PATH)
   add_library(protobuf ALIAS protobuf::libprotobuf)
   set_target_properties(gRPC::grpc++ PROPERTIES IMPORTED_GLOBAL TRUE)
   add_library(grpc++ ALIAS gRPC::grpc++)
+  if (ENABLE_GRPC_REFLECTION)
+set_target_properties(gRPC::grpc++_reflection PROPERTIES IMPORTED_GLOBAL 
TRUE)
+add_library(grpc++_reflection ALIAS gRPC::grpc++_reflection)
+  endif()
 
   set(GRPC_CPP_PLUGIN $)
   set(PROTOC ${Protobuf_PROTOC_EXECUTABLE})
@@ -71,12 +77,21 @@ else()
   add_library(grpc++ UNKNOWN IMPORTED GLOBAL)
   message(STATUS "Using grpc++: " ${GRPC_LIBRARY})
   set_target_properties(grpc++ PROPERTIES IMPORTED_LOCATION ${GRPC_LIBRARY})
+  if (ENABLE_GRPC_REFLECTION)
+find_library(GRPC_REFLECTION_LIBRARY grpc++_reflection $GRPC_OPTS REQUIRED)
+add_library(grpc++_reflection UNKNOWN IMPORTED GLOBAL)
+set_target_properties(grpc++_reflection PROPERTIES IMPORTED_LOCATION 
${GRPC_REFLECTION_LIBRARY})
+  endif()
   find_library(PROTOBUF_LIBRARY protobuf $PROTOBUF_OPTS REQUIRED)
   message(STATUS "Using protobuf: " 

[PATCH] D98160: [clang] Use decltype((E)) for compound requirement type constraint

2021-03-15 Thread Matheus Izvekov via Phabricator via cfe-commits
mizvekov updated this revision to Diff 330775.
mizvekov added a comment.

broken bot rebuild repush


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98160

Files:
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Sema/Sema.h
  clang/lib/Sema/SemaConcept.cpp
  clang/lib/Sema/SemaExprCXX.cpp
  clang/lib/Sema/SemaType.cpp
  clang/test/CXX/expr/expr.prim/expr.prim.req/compound-requirement.cpp

Index: clang/test/CXX/expr/expr.prim/expr.prim.req/compound-requirement.cpp
===
--- clang/test/CXX/expr/expr.prim/expr.prim.req/compound-requirement.cpp
+++ clang/test/CXX/expr/expr.prim/expr.prim.req/compound-requirement.cpp
@@ -79,19 +79,23 @@
 template
 constexpr bool is_same_v = true;
 
+template struct remove_reference { using type = T; };
+template struct remove_reference { using type = T; };
+
 template
 concept Same = is_same_v;
 
 template
-concept Large = sizeof(T) >= 4; // expected-note{{because 'sizeof(short) >= 4' (2 >= 4) evaluated to false}}
+concept Large = sizeof(typename remove_reference::type) >= 4;
+// expected-note@-1{{because 'sizeof(typename remove_reference::type) >= 4' (2 >= 4) evaluated to false}}
 
-template requires requires (T t) { { t } -> Large; } // expected-note{{because 'decltype(t)' (aka 'short') does not satisfy 'Large':}}
+template requires requires (T t) { { t } -> Large; } // expected-note{{because 'decltype((t))' (aka 'short &') does not satisfy 'Large':}}
 struct r7 {};
 
 using r7i1 = r7;
 using r7i2 = r7; // expected-error{{constraints not satisfied for class template 'r7' [with T = short]}}
 
-template requires requires (T t) { { t } -> Same; }
+template requires requires (T t) { { t } -> Same; }
 struct r8 {};
 
 using r8i1 = r8;
@@ -99,7 +103,8 @@
 
 // Substitution failure in type constraint
 
-template requires requires (T t) { { t } -> Same; } // expected-note{{because 'Same' would be invalid: type 'int' cannot be used prior to '::' because it has no members}}
+template requires requires (T t) { { t } -> Same; }
+// expected-note@-1{{because 'Same' would be invalid: type 'int' cannot be used prior to '::' because it has no members}}
 struct r9 {};
 
 struct M { using type = M; };
@@ -122,6 +127,17 @@
 template requires requires (T t) { { t } -> IsEven; } // expected-error{{concept named in type constraint is not a type concept}}
 struct r11 {};
 
+// Value categories
+
+template
+requires requires (int b) {
+  { a } -> Same;
+  { b } -> Same;
+  { 0 } -> Same;
+  { static_cast(a) } -> Same;
+} void f1() {}
+template void f1<>();
+
 // C++ [expr.prim.req.compound] Example
 namespace std_example {
   template concept C1 =
@@ -172,4 +188,4 @@
   static_assert(C5);
   template struct C5_check {}; // expected-note{{because 'short' does not satisfy 'C5'}}
   using c5 = C5_check; // expected-error{{constraints not satisfied for class template 'C5_check' [with T = short]}}
-}
\ No newline at end of file
+}
Index: clang/lib/Sema/SemaType.cpp
===
--- clang/lib/Sema/SemaType.cpp
+++ clang/lib/Sema/SemaType.cpp
@@ -8832,6 +8832,28 @@
   return Context.getTypeOfExprType(E);
 }
 
+/// getDecltypeForParenthesizedExpr - Given an expr, will return the type for
+/// that expression, as in [dcl.type.simple]p4 but without taking id-expressions
+/// and class member access into account.
+static QualType getDecltypeForParenthesizedExpr(Sema , Expr *E) {
+  // C++11 [dcl.type.simple]p4:
+  //   [...]
+  QualType T = E->getType();
+  switch (E->getValueKind()) {
+  // - otherwise, if e is an xvalue, decltype(e) is T&&, where T is the
+  //   type of e;
+  case VK_XValue:
+return S.Context.getRValueReferenceType(T);
+  // - otherwise, if e is an lvalue, decltype(e) is T&, where T is the
+  //   type of e;
+  case VK_LValue:
+return S.Context.getLValueReferenceType(T);
+  //  - otherwise, decltype(e) is the type of e.
+  case VK_RValue:
+return T;
+  }
+}
+
 /// getDecltypeForExpr - Given an expr, will return the decltype for
 /// that expression, according to the rules in C++11
 /// [dcl.type.simple]p4 and C++11 [expr.lambda.prim]p18.
@@ -8896,22 +8918,7 @@
 }
   }
 
-
-  // C++11 [dcl.type.simple]p4:
-  //   [...]
-  QualType T = E->getType();
-  switch (E->getValueKind()) {
-  // - otherwise, if e is an xvalue, decltype(e) is T&&, where T is the
-  //   type of e;
-  case VK_XValue: T = S.Context.getRValueReferenceType(T); break;
-  // - otherwise, if e is an lvalue, decltype(e) is T&, where T is the
-  //   type of e;
-  case VK_LValue: T = S.Context.getLValueReferenceType(T); break;
-  //  - otherwise, decltype(e) is the type of e.
-  case VK_RValue: break;
-  }
-
-  return T;
+  return getDecltypeForParenthesizedExpr(S, E);
 }
 
 QualType Sema::BuildDecltypeType(Expr *E, SourceLocation Loc,
@@ -8930,6 +8937,11 @@
 

[PATCH] D98404: [clangd] Optionally add reflection for clangd-index-server

2021-03-15 Thread Kirill Bobyrev via Phabricator via cfe-commits
kbobyrev updated this revision to Diff 330772.
kbobyrev marked an inline comment as done.
kbobyrev added a comment.

Resolve post-LGTM comments.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98404

Files:
  clang-tools-extra/clangd/CMakeLists.txt
  clang-tools-extra/clangd/Features.inc.in
  clang-tools-extra/clangd/index/remote/server/CMakeLists.txt
  clang-tools-extra/clangd/index/remote/server/Server.cpp
  llvm/cmake/modules/FindGRPC.cmake

Index: llvm/cmake/modules/FindGRPC.cmake
===
--- llvm/cmake/modules/FindGRPC.cmake
+++ llvm/cmake/modules/FindGRPC.cmake
@@ -1,3 +1,5 @@
+option(ENABLE_GRPC_REFLECTION "Link clangd-index-server to gRPC Reflection library" OFF)
+
 # FIXME(kirillbobyrev): Check if gRPC and Protobuf headers can be included at
 # configure time.
 find_package(Threads REQUIRED)
@@ -22,6 +24,10 @@
   add_library(protobuf ALIAS protobuf::libprotobuf)
   set_target_properties(gRPC::grpc++ PROPERTIES IMPORTED_GLOBAL TRUE)
   add_library(grpc++ ALIAS gRPC::grpc++)
+  if (ENABLE_GRPC_REFLECTION)
+set_target_properties(gRPC::grpc++_reflection PROPERTIES IMPORTED_GLOBAL TRUE)
+add_library(grpc++_reflection ALIAS gRPC::grpc++_reflection)
+  endif()
 
   set(GRPC_CPP_PLUGIN $)
   set(PROTOC ${Protobuf_PROTOC_EXECUTABLE})
@@ -71,12 +77,21 @@
   add_library(grpc++ UNKNOWN IMPORTED GLOBAL)
   message(STATUS "Using grpc++: " ${GRPC_LIBRARY})
   set_target_properties(grpc++ PROPERTIES IMPORTED_LOCATION ${GRPC_LIBRARY})
+  if (ENABLE_GRPC_REFLECTION)
+find_library(GRPC_REFLECTION_LIBRARY grpc++_reflection $GRPC_OPTS REQUIRED)
+add_library(grpc++_reflection UNKNOWN IMPORTED GLOBAL)
+set_target_properties(grpc++_reflection PROPERTIES IMPORTED_LOCATION ${GRPC_REFLECTION_LIBRARY})
+  endif()
   find_library(PROTOBUF_LIBRARY protobuf $PROTOBUF_OPTS REQUIRED)
   message(STATUS "Using protobuf: " ${PROTOBUF_LIBRARY})
   add_library(protobuf UNKNOWN IMPORTED GLOBAL)
   set_target_properties(protobuf PROPERTIES IMPORTED_LOCATION ${PROTOBUF_LIBRARY})
 endif()
 
+if (ENABLE_GRPC_REFLECTION)
+  set(REFLECTION_LIBRARY grpc++_reflection)
+endif()
+
 # Proto headers are generated in ${CMAKE_CURRENT_BINARY_DIR}.
 # Libraries that use these headers should adjust the include path.
 # If the "GRPC" argument is given, services are also generated.
Index: clang-tools-extra/clangd/index/remote/server/Server.cpp
===
--- clang-tools-extra/clangd/index/remote/server/Server.cpp
+++ clang-tools-extra/clangd/index/remote/server/Server.cpp
@@ -6,6 +6,7 @@
 //
 //===--===//
 
+#include "Features.inc"
 #include "Index.pb.h"
 #include "Service.grpc.pb.h"
 #include "index/Index.h"
@@ -35,6 +36,10 @@
 #include 
 #include 
 
+#if ENABLE_GRPC_REFLECTION
+#include 
+#endif
+
 namespace clang {
 namespace clangd {
 namespace remote {
@@ -313,6 +318,9 @@
   RemoteIndexServer Service(Index, IndexRoot);
 
   grpc::EnableDefaultHealthCheckService(true);
+#if ENABLE_GRPC_REFLECTION
+  grpc::reflection::InitProtoReflectionServerBuilderPlugin();
+#endif
   grpc::ServerBuilder Builder;
   Builder.AddListeningPort(ServerAddress.str(),
grpc::InsecureServerCredentials());
Index: clang-tools-extra/clangd/index/remote/server/CMakeLists.txt
===
--- clang-tools-extra/clangd/index/remote/server/CMakeLists.txt
+++ clang-tools-extra/clangd/index/remote/server/CMakeLists.txt
@@ -17,4 +17,6 @@
   RemoteIndexProto
   RemoteIndexServiceProto
   clangdRemoteMarshalling
+
+  ${REFLECTION_LIBRARY}
   )
Index: clang-tools-extra/clangd/Features.inc.in
===
--- clang-tools-extra/clangd/Features.inc.in
+++ clang-tools-extra/clangd/Features.inc.in
@@ -1,3 +1,4 @@
 #define CLANGD_BUILD_XPC @CLANGD_BUILD_XPC@
 #define CLANGD_ENABLE_REMOTE @CLANGD_ENABLE_REMOTE@
+#define ENABLE_GRPC_REFLECTION @ENABLE_GRPC_REFLECTION@
 #define CLANGD_MALLOC_TRIM @CLANGD_MALLOC_TRIM@
Index: clang-tools-extra/clangd/CMakeLists.txt
===
--- clang-tools-extra/clangd/CMakeLists.txt
+++ clang-tools-extra/clangd/CMakeLists.txt
@@ -19,6 +19,7 @@
 llvm_canonicalize_cmake_booleans(
   CLANGD_BUILD_XPC
   CLANGD_ENABLE_REMOTE
+  ENABLE_GRPC_REFLECTION
   CLANGD_MALLOC_TRIM
   LLVM_ENABLE_ZLIB
 )
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D98363: [Sema] Fold VLA types in compound literals to constant arrays.

2021-03-15 Thread Eli Friedman via Phabricator via cfe-commits
efriedma added inline comments.



Comment at: clang/test/Sema/vla.c:134
+  // expected-warning@+1{{variable length array folded to constant array as an 
extension}}
+  char (*a9)[] = (char[2][ksize]) {{1,2,3,4},{4,3,2,1}};
+

aaron.ballman wrote:
> Doesn't this violate the constraints in C17 6.5.2.5p1, "The type name shall 
> specify a complete object type or an array of unknown size, but not a 
> variable-length array type"?
Yes, this is a constraint violation.  This patch downgrades the error to a 
warning, for compatibility with older versions of clang.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98363

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


[PATCH] D98278: [test] Add ability to get error messages from CMake for errc substitution

2021-03-15 Thread Markus Böck via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGaf2796c76d2f: [test] Add ability to get error messages from 
CMake for errc substitution (authored by zero9178).
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Changed prior to commit:
  https://reviews.llvm.org/D98278?vs=330653=330769#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98278

Files:
  clang/CMakeLists.txt
  clang/test/lit.site.cfg.py.in
  lld/CMakeLists.txt
  lld/test/lit.site.cfg.py.in
  llvm/CMakeLists.txt
  llvm/cmake/modules/GetErrcMessages.cmake
  llvm/test/lit.site.cfg.py.in
  llvm/utils/lit/lit/llvm/config.py

Index: llvm/utils/lit/lit/llvm/config.py
===
--- llvm/utils/lit/lit/llvm/config.py
+++ llvm/utils/lit/lit/llvm/config.py
@@ -11,6 +11,7 @@
 from lit.llvm.subst import ToolSubst
 
 lit_path_displayed = False
+python_errc_displayed = False
 
 class LLVMConfig(object):
 
@@ -356,19 +357,24 @@
 return True
 
 def add_err_msg_substitutions(self):
-host_cxx = getattr(self.config, 'host_cxx', '')
-# On Windows, python's os.strerror() does not emit the same spelling as
-# the C++ std::error_code.  As a workaround, hardcode the Windows error
-# message.
-if (sys.platform == 'win32' and 'MSYS' not in host_cxx):
+# Python's strerror may not supply the same message
+# as C++ std::error_code. One example of such a platform is
+# Visual Studio. errc_messages may be supplied which contains the error
+# messages for ENOENT, EISDIR, EINVAL and EACCES as a semi colon
+# separated string. LLVM testsuites can use get_errc_messages in cmake
+# to automatically get the messages and pass them into lit.
+errc_messages = getattr(self.config, 'errc_messages', '')
+if len(errc_messages) != 0:
+(errc_enoent, errc_eisdir,
+ errc_einval, errc_eacces) = errc_messages.split(';')
 self.config.substitutions.append(
-('%errc_ENOENT', '\'no such file or directory\''))
+('%errc_ENOENT', '\'' + errc_enoent + '\''))
 self.config.substitutions.append(
-('%errc_EISDIR', '\'is a directory\''))
+('%errc_EISDIR', '\'' + errc_eisdir + '\''))
 self.config.substitutions.append(
-('%errc_EINVAL', '\'invalid argument\''))
+('%errc_EINVAL', '\'' + errc_einval + '\''))
 self.config.substitutions.append(
-('%errc_EACCES', '\'permission denied\''))
+('%errc_EACCES', '\'' + errc_eacces + '\''))
 else:
 self.config.substitutions.append(
 ('%errc_ENOENT', '\'' + os.strerror(errno.ENOENT) + '\''))
Index: llvm/test/lit.site.cfg.py.in
===
--- llvm/test/lit.site.cfg.py.in
+++ llvm/test/lit.site.cfg.py.in
@@ -12,6 +12,7 @@
 config.llvm_shlib_ext = "@SHLIBEXT@"
 config.llvm_exe_ext = "@EXEEXT@"
 config.lit_tools_dir = path(r"@LLVM_LIT_TOOLS_DIR@")
+config.errc_messages = "@LLVM_LIT_ERRC_MESSAGES@"
 config.python_executable = "@Python3_EXECUTABLE@"
 config.gold_executable = "@GOLD_EXECUTABLE@"
 config.ld64_executable = "@LD64_EXECUTABLE@"
Index: llvm/cmake/modules/GetErrcMessages.cmake
===
--- /dev/null
+++ llvm/cmake/modules/GetErrcMessages.cmake
@@ -0,0 +1,39 @@
+
+# This function returns the messages of various POSIX error codes as they are returned by std::error_code.
+# The purpose of this function is to supply those error messages to llvm-lit using the errc_messages config
+# Currently supplied and needed error codes: ENOENT, EISDIR, EINVAL and EACCES
+# Messages are semi colon separated
+# Keep amount, order and tested error codes in sync with llvm/utils/lit/lit/llvm/config.py
+function(get_errc_messages outvar)
+
+set(errc_test_code ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/getErrc.cpp)
+
+file(WRITE ${errc_test_code} "
+#include 
+#include 
+#include 
+#include 
+
+std::string getMessageFor(int err) {
+return std::make_error_code(static_cast(err)).message();
+}
+
+int main() {
+std::cout << getMessageFor(ENOENT) << ';' << getMessageFor(EISDIR);
+std::cout << ';' << getMessageFor(EINVAL) << ';' << getMessageFor(EACCES);
+}
+")
+
+try_run(errc_exit_code
+errc_compiled
+${CMAKE_BINARY_DIR}
+${errc_test_code}
+RUN_OUTPUT_VARIABLE errc_result
+COMPILE_OUTPUT_VARIABLE errc_compile_errors)
+if (errc_compiled)
+set(${outvar} ${errc_result} PARENT_SCOPE)

[clang] af2796c - [test] Add ability to get error messages from CMake for errc substitution

2021-03-15 Thread Markus Böck via cfe-commits

Author: Markus Böck
Date: 2021-03-15T20:56:08+01:00
New Revision: af2796c76d2ff4b73165ed47959afd35a769beee

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

LOG: [test] Add ability to get error messages from CMake for errc substitution

Visual Studios implementation of the C++ Standard Library does not use strerror 
to produce a message for std::error_code unlike other standard libraries such 
as libstdc++ or libc++ that might be used.

This patch adds a cmake script that through running a C++ program gets the 
error messages for the POSIX error codes and passes them onto lit through an 
optional config parameter.

If the config parameter is not set, or getting the messages failed, due to say 
a cross compiling configuration without an emulator, it will fall back to using 
pythons strerror functions.

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

Added: 
llvm/cmake/modules/GetErrcMessages.cmake

Modified: 
clang/CMakeLists.txt
clang/test/lit.site.cfg.py.in
lld/CMakeLists.txt
lld/test/lit.site.cfg.py.in
llvm/CMakeLists.txt
llvm/test/lit.site.cfg.py.in
llvm/utils/lit/lit/llvm/config.py

Removed: 




diff  --git a/clang/CMakeLists.txt b/clang/CMakeLists.txt
index 9ecf4b9d2de8..7af05c331e94 100644
--- a/clang/CMakeLists.txt
+++ b/clang/CMakeLists.txt
@@ -113,6 +113,7 @@ if( CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR )
   include(TableGen)
   include(HandleLLVMOptions)
   include(VersionFromVCS)
+  include(GetErrcMessages)
   include(LLVMDistributionSupport)
 
   set(PACKAGE_VERSION "${LLVM_PACKAGE_VERSION}")
@@ -177,6 +178,8 @@ if( CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR )
   endif()
   set(LLVM_LIT_ARGS "${LIT_ARGS_DEFAULT}" CACHE STRING "Default options 
for lit")
 
+  get_errc_messages(LLVM_LIT_ERRC_MESSAGES)
+
   # On Win32 hosts, provide an option to specify the path to the GnuWin32 
tools.
   if( WIN32 AND NOT CYGWIN )
 set(LLVM_LIT_TOOLS_DIR "" CACHE PATH "Path to GnuWin32 tools")

diff  --git a/clang/test/lit.site.cfg.py.in b/clang/test/lit.site.cfg.py.in
index eb01720249af..c3382e2c1c42 100644
--- a/clang/test/lit.site.cfg.py.in
+++ b/clang/test/lit.site.cfg.py.in
@@ -9,6 +9,7 @@ config.llvm_libs_dir = path(r"@LLVM_LIBS_DIR@")
 config.llvm_shlib_dir = path(r"@SHLIBDIR@")
 config.llvm_plugin_ext = "@LLVM_PLUGIN_EXT@"
 config.lit_tools_dir = path(r"@LLVM_LIT_TOOLS_DIR@")
+config.errc_messages = "@LLVM_LIT_ERRC_MESSAGES@"
 config.clang_obj_root = path(r"@CLANG_BINARY_DIR@")
 config.clang_src_dir = path(r"@CLANG_SOURCE_DIR@")
 config.clang_tools_dir = path(r"@CLANG_TOOLS_DIR@")

diff  --git a/lld/CMakeLists.txt b/lld/CMakeLists.txt
index cbca979aaeb1..53e09f93 100644
--- a/lld/CMakeLists.txt
+++ b/lld/CMakeLists.txt
@@ -54,6 +54,7 @@ if(CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
   include(AddLLVM)
   include(TableGen)
   include(HandleLLVMOptions)
+  include(GetErrcMessages)
   include(CheckAtomic)
 
   if(LLVM_INCLUDE_TESTS)
@@ -98,6 +99,8 @@ if(CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
   endif()
   set(LLVM_LIT_ARGS "${LIT_ARGS_DEFAULT}" CACHE STRING "Default options 
for lit")
 
+  get_errc_messages(LLVM_LIT_ERRC_MESSAGES)
+
   # On Win32 hosts, provide an option to specify the path to the GnuWin32 
tools.
   if(WIN32 AND NOT CYGWIN)
 set(LLVM_LIT_TOOLS_DIR "" CACHE PATH "Path to GnuWin32 tools")

diff  --git a/lld/test/lit.site.cfg.py.in b/lld/test/lit.site.cfg.py.in
index a140284e0ded..57fa15e730b1 100644
--- a/lld/test/lit.site.cfg.py.in
+++ b/lld/test/lit.site.cfg.py.in
@@ -8,6 +8,7 @@ config.llvm_obj_root = "@LLVM_BINARY_DIR@"
 config.llvm_tools_dir = "@LLVM_TOOLS_DIR@"
 config.llvm_libs_dir = "@LLVM_LIBS_DIR@"
 config.lit_tools_dir = "@LLVM_LIT_TOOLS_DIR@"
+config.errc_messages = "@LLVM_LIT_ERRC_MESSAGES@"
 config.lld_obj_root = "@LLD_BINARY_DIR@"
 config.lld_libs_dir = "@LLD_LIBS_DIR@"
 config.lld_tools_dir = "@LLD_TOOLS_DIR@"

diff  --git a/llvm/CMakeLists.txt b/llvm/CMakeLists.txt
index 22c1a130f4a5..51ed113f58c5 100644
--- a/llvm/CMakeLists.txt
+++ b/llvm/CMakeLists.txt
@@ -507,6 +507,9 @@ if (MSVC_IDE OR XCODE)
 endif()
 set(LLVM_LIT_ARGS "${LIT_ARGS_DEFAULT}" CACHE STRING "Default options for lit")
 
+include(GetErrcMessages)
+get_errc_messages(LLVM_LIT_ERRC_MESSAGES)
+
 # On Win32 hosts, provide an option to specify the path to the GnuWin32 tools.
 if( WIN32 AND NOT CYGWIN )
   set(LLVM_LIT_TOOLS_DIR "" CACHE PATH "Path to GnuWin32 tools")

diff  --git a/llvm/cmake/modules/GetErrcMessages.cmake 
b/llvm/cmake/modules/GetErrcMessages.cmake
new file mode 100644
index ..79aa6456cc7e
--- /dev/null
+++ b/llvm/cmake/modules/GetErrcMessages.cmake
@@ -0,0 +1,39 @@
+
+# This function returns the messages of various POSIX 

[PATCH] D98246: [clangd] Add basic monitoring info request for remote index server

2021-03-15 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet added inline comments.



Comment at: clang-tools-extra/clangd/index/remote/MonitoringService.proto:17
+  optional uint64 uptime = 1;
+  // Time since the index was built on the indexing machine.
+  optional uint64 freshness = 3;

mention the units in here too (e.g. seconds)

(it might be even better to just put that in the name actually, e.g. 
uptime_seconds, as documentation for generated files might not show up in tools 
like clangd :P, up to you though)



Comment at: clang-tools-extra/clangd/index/remote/MonitoringService.proto:18
+  // Time since the index was built on the indexing machine.
+  optional uint64 freshness = 3;
+  // ID of the indexed commit in Version Control System.

what happened to `2` ?



Comment at: clang-tools-extra/clangd/index/remote/MonitoringService.proto:18
+  // Time since the index was built on the indexing machine.
+  optional uint64 freshness = 3;
+  // ID of the indexed commit in Version Control System.

kadircet wrote:
> what happened to `2` ?
nit: maybe rename this to `index_age`



Comment at: clang-tools-extra/clangd/index/remote/server/Server.cpp:294
+
+  void updateIndex(const llvm::sys::TimePoint<> UpdateTime) {
+IndexLastReload = UpdateTime;

nit: drop the `const`, as that's the style in clangd in general if we are going 
to copy the parameters anyway.



Comment at: clang-tools-extra/clangd/index/remote/server/Server.cpp:308
+  .count());
+// FIXME(kirillbobyrev): This is not really "freshness", this is just the
+// time since last index reload.

what's the issue to be fixed here exactly? do we want to display the index 
build time instead of age? (if so what's the blocker)



Comment at: clang-tools-extra/clangd/index/remote/server/Server.cpp:317
+  const llvm::sys::TimePoint<> StartTime;
+  llvm::sys::TimePoint<> IndexLastReload;
+};

we should either use an atomic here or use a mutex. as the `updateIndex` and 
serving RPCs are happening on different threads.



Comment at: clang-tools-extra/clangd/index/remote/server/Server.cpp:344
   Status->getLastModificationTime(), Status->getSize());
+  Monitor.updateIndex(Status->getLastModificationTime());
 }

nit: i'd log after this one.



Comment at: clang-tools-extra/clangd/index/remote/server/Server.cpp:457
 
-  std::thread HotReloadThread([, , ]() {
+  Monitor Monitor(std::chrono::system_clock::now());
+

unless we call updateIndex here too, monitoring service won't know about the 
one being served until the first reload right?

(another option would be to just not load the index at startup immediately, and 
handle the initial load in HotReloadThread, but that can be a separate change.)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98246

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


[PATCH] D92004: [OpenCL] add CL 3.0 optional feature support to opencl-c.h

2021-03-15 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia added a comment.

FYI the testing of headers functionality is now being discussed in 
https://reviews.llvm.org/D97869


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D92004

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


[PATCH] D97869: [OpenCL][Draft] Add OpenCL builtin test generator

2021-03-15 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia added a comment.

In D97869#2617063 , @svenvh wrote:

> In D97869#2616772 , @Anastasia wrote:
>
>> Regarding 2 and 4 I think we should drive towards deprecation of 
>> `opencl-c.h` as it is a maintenance overhead but we could convert it into a 
>> test instead?
>
> Perhaps you misunderstood option 4, as that does not require maintaining 
> `opencl-c.h`.  Only for option 2 we would have to maintain `opencl-c.h`.  For 
> option 4, the checked in files could look something like this:
>
> name=clang/test/SemaOpenCL/builtins-opencl2.0.check
>   ; RUN: clang-tblgen -emit-opencl-builtin-count -cl-std=cl2.0 
> OpenCLBuiltins.td | FileCheck '%s'
>   
>   ; This file lists the number of builtin function declarations per builtin 
> function name
>   ; available in the OpenCL 2.0 language mode.
>   
>   CHECK: absdiff 48
>   CHECK: abs 48
>   CHECK: acos 18
>   CHECK: acosh 18
>   CHECK: acospi 18
>   ...
>
> To illustrate the use, suppose a developer writes a patch that accidentally 
> makes the `double` variants of `acos` unavailable in OpenCL 2.0.  The 
> reported number of `acos` builtins would be different so FileCheck would fail 
> on the line containing `acos 18`.  If we use option 4 in combination with 
> option 1, a Clang developer can regenerate the test and observe the 
> differences for the `acos` tests: from there it becomes obvious that the 
> double variants of `acos` disappeared.

Ok, I see. It is more clear now. I like that it is easy enough to understand. 
Still it has the issue of non-standard testing but we have mentioned it already.

>> Aside from option 3 all other options will require adding non-standard 
>> testing formats in Clang. This means that if there is any core refactoring 
>> changes even outside of OpenCL affecting the functionality in the headers, 
>> it would be required to learn how we do the testing in order to address any 
>> breakages. Perhaps this can be mitigated by the documentation, but overall 
>> it is an extra burden to the community. Speaking from my personal experience 
>> I was in the situations breaking functionality outside of OpenCL and having 
>> a unified testing format is a big advantage in understanding and addressing 
>> the issues in unfamiliar code.
>
> Do you expect this to be a problem in practice for the other proposals, and 
> if so could you elaborate in more detail about any particular concerns for 
> the other proposals?

Not sure I understand what you mean by "other proposals" though. I think this 
is only an issue for the proposals that don't use regular clang invocation for 
testing. It is probably not a widespread problem but it could bother someone 
someday potentially.

>> What problems do you see with checking in autogenerated files? There are 
>> some existing tests that check similar functionality and they seem to 
>> contain repetitive patterns. Honestly, I wouldn't be able to say if they 
>> were written with copy/paste or auto-generated but I am not sure whether it 
>> is very important. Of course, it would have been better if we have built up 
>> the functionality incrementally, and it is still an option. But it hasn't 
>> been possible in the past and as a matter of fact the original header was 
>> committed as one large file (around 15K lines).
>>
>>>   Updates to OpenCLBuiltins.td will give large diffs when regenerating the 
>>> tests (regardless of whether the file is split or not).
>>
>> Could you provide more details. I don't follow this.
>
> There are two problems here that combine to make the problem bigger: checking 
> in autogenerated files, and the fact that those files are large.  The problem 
> I anticipate with regenerating the test files (at least with the current 
> generator), is that inserting a new builtin in the .td file results in 
> renumbering of the test functions, which results in a large diff.
>
> Other problems I see with checking in large autogenerated files:
>
> - Merge conflicts in the generated files when reordering/rebasing/porting 
> patches.  A single conflict in the .td description could expand to many 
> conflicts in the autogenerated file(s).
> - Diffs in the autogenerated files clutter the output of for example `git log 
> -p`.
> - Code reviews of changes to those files are harder due to the size.
> - It bloats the repository.
>
> Disclaimer: I may be biased by my previous experience on projects that had 
> large autogenerated files checked in, that's why I feel that we should avoid 
> doing so if we reasonably can.  I have probably revealed now that option 3 is 
> my least favorite option. :-)

Ok, fair point. :D But however your option 3 and my option 3 are apparently not 
the same. I was thinking we would only generate test once and then manually 
modify and extend it every time new functionality is added. We could see it as 
if the file was written with copy-paste or perfect formatting. So every time 

[PATCH] D97119: [flang][driver] Add options for -std=f2018

2021-03-15 Thread Arnamoy B via Phabricator via cfe-commits
arnamoy10 updated this revision to Diff 330762.
arnamoy10 added a comment.

1. Update the test case to only test `flang-new -fc1`
2. Updated help text
3. Clang-formatted and also removed redundant code


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

https://reviews.llvm.org/D97119

Files:
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/ToolChains/Flang.cpp
  flang/include/flang/Frontend/CompilerInvocation.h
  flang/lib/Frontend/CompilerInvocation.cpp
  flang/test/Driver/driver-help-hidden.f90
  flang/test/Driver/driver-help.f90
  flang/test/Driver/std2018.f90

Index: flang/test/Driver/std2018.f90
===
--- /dev/null
+++ flang/test/Driver/std2018.f90
@@ -0,0 +1,34 @@
+! Ensure argument -std=f2018 works as expected.
+
+!-
+! FRONTEND FLANG DRIVER (flang-new -fc1)
+!-
+! RUN: %flang_fc1 %s  2>&1 | FileCheck %s --allow-empty --check-prefix=WITHOUT
+! RUN: %flang_fc1 -std=f2018 %s  2>&1 | FileCheck %s --check-prefix=GIVEN
+! RUN: %flang_fc1 -pedantic %s  2>&1 | FileCheck %s --check-prefix=GIVEN
+! RUN: not %flang_fc1 -std=90 %s  2>&1 | FileCheck %s --check-prefix=WRONG
+
+!-
+! EXPECTED OUTPUT WITHOUT
+!-
+! WITHOUT-NOT: A DO loop should terminate with an END DO or CONTINUE
+
+!-
+! EXPECTED OUTPUT WITH
+!-
+! GIVEN: A DO loop should terminate with an END DO or CONTINUE
+
+!-
+! EXPECTED OUTPUT WITH WRONG
+!-
+! WRONG: Only -std=f2018 is allowed currently.
+
+subroutine foo2()
+do 01 m=1,2
+  select case (m)
+  case default
+print*, "default", m
+  case (1)
+print*, "start"
+01end select
+end subroutine
Index: flang/test/Driver/driver-help.f90
===
--- flang/test/Driver/driver-help.f90
+++ flang/test/Driver/driver-help.f90
@@ -45,6 +45,8 @@
 ! HELP-NEXT: -IAdd directory to the end of the list of include search paths
 ! HELP-NEXT: -module-dir   Put MODULE files in 
 ! HELP-NEXT: -o   Write output to 
+! HELP-NEXT: -pedantic  Warn on language extensions
+! HELP-NEXT: -std=   Language standard to compile for
 ! HELP-NEXT: -U  Undefine macro 
 ! HELP-NEXT: --version  Print version information
 ! HELP-NEXT: -Xflang   Pass  to the flang compiler
@@ -91,6 +93,8 @@
 ! HELP-FC1-NEXT: -IAdd directory to the end of the list of include search paths
 ! HELP-FC1-NEXT: -module-dir   Put MODULE files in 
 ! HELP-FC1-NEXT: -o   Write output to 
+! HELP-FC1-NEXT: -pedantic  Warn on language extensions
+! HELP-FC1-NEXT: -std=   Language standard to compile for
 ! HELP-FC1-NEXT: -test-io   Run the InputOuputTest action. Use for development and testing only.
 ! HELP-FC1-NEXT: -U  Undefine macro 
 ! HELP-FC1-NEXT: --version  Print version information
Index: flang/test/Driver/driver-help-hidden.f90
===
--- flang/test/Driver/driver-help-hidden.f90
+++ flang/test/Driver/driver-help-hidden.f90
@@ -45,6 +45,8 @@
 ! CHECK-NEXT: -IAdd directory to the end of the list of include search paths
 ! CHECK-NEXT: -module-dir   Put MODULE files in 
 ! CHECK-NEXT: -o  Write output to 
+! CHECK-NEXT: -pedantic  Warn on language extensions
+! CHECK-NEXT: -std=   Language standard to compile for
 ! CHECK-NEXT: -U  Undefine macro 
 ! CHECK-NEXT: --version Print version information
 ! CHECK-NEXT: -Xflang   Pass  to the flang compiler
Index: flang/lib/Frontend/CompilerInvocation.cpp
===
--- flang/lib/Frontend/CompilerInvocation.cpp
+++ flang/lib/Frontend/CompilerInvocation.cpp
@@ -368,6 +368,26 @@
 res.frontendOpts().features_.Enable(
 Fortran::common::LanguageFeature::OpenMP);
   }
+
+  //-fpedantic
+  if (args.hasArg(clang::driver::options::OPT_pedantic)) {
+res.set_EnableConformanceChecks();
+  }
+  // -std=f2018.  Current behaviour is same as -fpedantic
+  // TODO: Set proper options when more fortran standards
+  // are supported.
+  if (args.hasArg(clang::driver::options::OPT_std_EQ)) {
+auto standard = args.getLastArgValue(clang::driver::options::OPT_std_EQ);
+// We only allow f2018 as the given standard
+if (standard.equals("f2018")) {
+  res.set_EnableConformanceChecks();
+} else {
+  const unsigned diagID =
+  diags.getCustomDiagID(clang::DiagnosticsEngine::Error,
+  "Only -std=f2018 is allowed currently.");
+  

[PATCH] D96877: [libomptarget] Try a fallback devicertl if the preferred one is missing

2021-03-15 Thread Jon Chesterfield via Phabricator via cfe-commits
JonChesterfield abandoned this revision.
JonChesterfield added a comment.

I'm going to abandon this. I'm not confident that a cuda toolkit that is newer 
than the compiler will work with it correctly and would prefer it take some 
jury rigging on the end users part to put the two together.

I get that 'works out of the box, whatever cuda is installed' would be an 
amazing feature to have. This patch sort of promises that without necessarily 
delivering on the 'works' part.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D96877

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


[PATCH] D97785: [SystemZ][z/OS] Distinguish between text and binary files on z/OS

2021-03-15 Thread Zibi Sarbino via Phabricator via cfe-commits
zibi added inline comments.



Comment at: clang/lib/Frontend/CompilerInstance.cpp:771
+TempPath, fd, TempPath,
+llvm::sys::fs::all_read | llvm::sys::fs::all_write,
+Binary ? llvm::sys::fs::OF_None : llvm::sys::fs::OF_Text);

The ` llvm::sys::fs::all_read | llvm::sys::fs::all_write` seems to be a default 
so if we make that parameter last we won't need to pass it and worry about the 
mode parameter which would be the second last default parameter.  Switch 
parameters only when you determine that indeed `tag` is more frequent parameter 
which need to be set comparing to `mode` parameter.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97785

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


[PATCH] D97785: [SystemZ][z/OS] Distinguish between text and binary files on z/OS

2021-03-15 Thread Anirudh Prasad via Phabricator via cfe-commits
anirudhp added a comment.

LGTM.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97785

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


[PATCH] D98622: [-Wcalled-once-parameter] Let escapes overwrite MaybeCalled states

2021-03-15 Thread Valeriy Savchenko via Phabricator via cfe-commits
vsavchenko updated this revision to Diff 330760.
vsavchenko added a comment.

Unify the way we deal with escapes


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98622

Files:
  clang/lib/Analysis/CalledOnceCheck.cpp
  clang/test/SemaObjC/warn-called-once.m


Index: clang/test/SemaObjC/warn-called-once.m
===
--- clang/test/SemaObjC/warn-called-once.m
+++ clang/test/SemaObjC/warn-called-once.m
@@ -1130,4 +1130,32 @@
   }
 }
 
+- (void)test_escape_before_branch:(int)cond
+   withCompletion:(void (^)(void))handler {
+  if (cond) {
+filler();
+  }
+
+  void (^copiedHandler)(void) = ^{
+handler();
+  };
+
+  if (cond) {
+// no-warning
+handler();
+  } else {
+copiedHandler();
+  }
+}
+
+- (void)test_escape_after_branch:(int)cond
+  withCompletion:(void (^)(void))handler {
+  if (cond) {
+// no-warning
+handler();
+  }
+
+  escape(handler);
+}
+
 @end
Index: clang/lib/Analysis/CalledOnceCheck.cpp
===
--- clang/lib/Analysis/CalledOnceCheck.cpp
+++ clang/lib/Analysis/CalledOnceCheck.cpp
@@ -867,16 +867,14 @@
 // Let's check if any of the call arguments is a point of interest.
 for (const auto  : llvm::enumerate(Arguments)) {
   if (auto Index = getIndexOfExpression(Argument.value())) {
-ParameterStatus  = 
CurrentState.getStatusFor(*Index);
-
 if (shouldBeCalledOnce(CallOrMessage, Argument.index())) {
   // If the corresponding parameter is marked as 'called_once' we 
should
   // consider it as a call.
   processCallFor(*Index, CallOrMessage);
-} else if (CurrentParamStatus.getKind() == ParameterStatus::NotCalled) 
{
+} else {
   // Otherwise, we mark this parameter as escaped, which can be
   // interpreted both as called or not called depending on the context.
-  CurrentParamStatus = ParameterStatus::Escaped;
+  processEscapeFor(*Index);
 }
 // Otherwise, let's keep the state as it is.
   }
@@ -910,6 +908,16 @@
 }
   }
 
+  /// Process escape of the parameter with the given index
+  void processEscapeFor(unsigned Index) {
+ParameterStatus  = CurrentState.getStatusFor(Index);
+
+// Escape overrides whatever error we think happened.
+if (CurrentParamStatus.isErrorStatus()) {
+  CurrentParamStatus = ParameterStatus::Escaped;
+}
+  }
+
   void findAndReportNotCalledBranches(const CFGBlock *Parent, unsigned Index,
   bool IsEscape = false) {
 for (const CFGBlock *Succ : Parent->succs()) {
@@ -1365,11 +1373,7 @@
   /// Check given parameter that was discovered to escape.
   void checkEscapee(const ParmVarDecl ) {
 if (auto Index = getIndex(Parameter)) {
-  ParameterStatus  = CurrentState.getStatusFor(*Index);
-
-  if (CurrentParamStatus.getKind() == ParameterStatus::NotCalled) {
-CurrentParamStatus = ParameterStatus::Escaped;
-  }
+  processEscapeFor(*Index);
 }
   }
 


Index: clang/test/SemaObjC/warn-called-once.m
===
--- clang/test/SemaObjC/warn-called-once.m
+++ clang/test/SemaObjC/warn-called-once.m
@@ -1130,4 +1130,32 @@
   }
 }
 
+- (void)test_escape_before_branch:(int)cond
+   withCompletion:(void (^)(void))handler {
+  if (cond) {
+filler();
+  }
+
+  void (^copiedHandler)(void) = ^{
+handler();
+  };
+
+  if (cond) {
+// no-warning
+handler();
+  } else {
+copiedHandler();
+  }
+}
+
+- (void)test_escape_after_branch:(int)cond
+  withCompletion:(void (^)(void))handler {
+  if (cond) {
+// no-warning
+handler();
+  }
+
+  escape(handler);
+}
+
 @end
Index: clang/lib/Analysis/CalledOnceCheck.cpp
===
--- clang/lib/Analysis/CalledOnceCheck.cpp
+++ clang/lib/Analysis/CalledOnceCheck.cpp
@@ -867,16 +867,14 @@
 // Let's check if any of the call arguments is a point of interest.
 for (const auto  : llvm::enumerate(Arguments)) {
   if (auto Index = getIndexOfExpression(Argument.value())) {
-ParameterStatus  = CurrentState.getStatusFor(*Index);
-
 if (shouldBeCalledOnce(CallOrMessage, Argument.index())) {
   // If the corresponding parameter is marked as 'called_once' we should
   // consider it as a call.
   processCallFor(*Index, CallOrMessage);
-} else if (CurrentParamStatus.getKind() == ParameterStatus::NotCalled) {
+} else {
   // Otherwise, we mark this parameter as escaped, which can be
   // interpreted both as called or not called depending on the context.
-  CurrentParamStatus = ParameterStatus::Escaped;
+  processEscapeFor(*Index);
 }
   

[PATCH] D98610: [RISCV] Support clang -fpatchable-function-entry && GNU function attribute 'patchable_function_entry'

2021-03-15 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added inline comments.



Comment at: llvm/test/CodeGen/RISCV/patchable-function-entry.ll:24
+; RVC-NEXT:  c.jr ra
+; CHECK:   .section __patchable_function_entries,"awo",@progbits,f1{{$}}
+; 32:  .p2align 2

jrtc27 wrote:
> Is there a benefit from treating these like labels with CHECK-LABEL?
I don't find a difference regarding the diagnostic.

The `:29:2: note: possible intended match here\n.section 
__patchable_function_entries,"awo",@progbits,f1` lines do not change. So 
`-LABEL:` does not improve diagnostic.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98610

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


[PATCH] D98610: [RISCV] Support clang -fpatchable-function-entry && GNU function attribute 'patchable_function_entry'

2021-03-15 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay updated this revision to Diff 330759.
MaskRay marked 5 inline comments as done.
MaskRay added a comment.

Change check prefixes from 32/64 to RV32/RV64

Rebase and use `MCInst getNop`


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98610

Files:
  clang/include/clang/Basic/Attr.td
  clang/include/clang/Basic/AttrDocs.td
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/test/Driver/fpatchable-function-entry.c
  clang/test/Sema/patchable-function-entry-attr.cpp
  llvm/lib/Target/RISCV/RISCV.h
  llvm/lib/Target/RISCV/RISCVAsmPrinter.cpp
  llvm/lib/Target/RISCV/RISCVInstrInfo.cpp
  llvm/lib/Target/RISCV/RISCVInstrInfo.h
  llvm/lib/Target/RISCV/RISCVMCInstLower.cpp
  llvm/test/CodeGen/RISCV/patchable-function-entry.ll

Index: llvm/test/CodeGen/RISCV/patchable-function-entry.ll
===
--- /dev/null
+++ llvm/test/CodeGen/RISCV/patchable-function-entry.ll
@@ -0,0 +1,71 @@
+;; Test the function attribute "patchable-function-entry".
+; RUN: llc -mtriple=riscv32 --riscv-no-aliases < %s | FileCheck %s --check-prefixes=CHECK,RV32,NORVC
+; RUN: llc -mtriple=riscv64 --riscv-no-aliases < %s | FileCheck %s --check-prefixes=CHECK,RV64,NORVC
+; RUN: llc -mtriple=riscv32 -mattr=+c --riscv-no-aliases < %s | FileCheck %s --check-prefixes=CHECK,RV32,RVC
+; RUN: llc -mtriple=riscv64 -mattr=+c --riscv-no-aliases < %s | FileCheck %s --check-prefixes=CHECK,RV64,RVC
+
+define void @f0() "patchable-function-entry"="0" {
+; CHECK-LABEL: f0:
+; CHECK-NEXT:  .Lfunc_begin0:
+; CHECK-NOT: {{addi|c.nop}}
+; NORVC: jalr zero, 0(ra)
+; RVC:   c.jr ra
+; CHECK-NOT:   .section __patchable_function_entries
+  ret void
+}
+
+define void @f1() "patchable-function-entry"="1" {
+; CHECK-LABEL: f1:
+; CHECK-NEXT: .Lfunc_begin1:
+; NORVC: addi zero, zero, 0
+; NORVC-NEXT:jalr zero, 0(ra)
+; RVC:   c.nop
+; RVC-NEXT:  c.jr ra
+; CHECK:   .section __patchable_function_entries,"awo",@progbits,f1{{$}}
+; 32:  .p2align 2
+; 32-NEXT: .word .Lfunc_begin1
+; 64:  .p2align 3
+; 64-NEXT: .quad .Lfunc_begin1
+  ret void
+}
+
+$f5 = comdat any
+define void @f5() "patchable-function-entry"="5" comdat {
+; CHECK-LABEL: f5:
+; CHECK-NEXT:  .Lfunc_begin2:
+; NORVC-COUNT-5: addi zero, zero, 0
+; NORVC-NEXT:jalr zero, 0(ra)
+; RVC-COUNT-5:   c.nop
+; RVC-NEXT:  c.jr ra
+; CHECK:   .section __patchable_function_entries,"aGwo",@progbits,f5,comdat,f5{{$}}
+; RV32:.p2align 2
+; RV32-NEXT:   .word .Lfunc_begin2
+; RV64:.p2align 3
+; RV64-NEXT:   .quad .Lfunc_begin2
+  ret void
+}
+
+;; -fpatchable-function-entry=3,2
+;; "patchable-function-prefix" emits data before the function entry label.
+define void @f3_2() "patchable-function-entry"="1" "patchable-function-prefix"="2" {
+; CHECK-LABEL: .type f3_2,@function
+; CHECK-NEXT:  .Ltmp0: # @f3_2
+; NORVC-COUNT-2: addi zero, zero, 0
+; RVC-COUNT-2:   c.nop
+; CHECK-NEXT:  f3_2:
+; CHECK:   # %bb.0:
+; NORVC-NEXT:addi zero, zero, 0
+; NORVC-NEXT:addi sp, sp, -16
+; RVC-NEXT:  c.nop
+; RVC-NEXT:  c.addi sp, -16
+;; .size does not include the prefix.
+; CHECK:  .Lfunc_end3:
+; CHECK-NEXT: .size f3_2, .Lfunc_end3-f3_2
+; CHECK:  .section __patchable_function_entries,"awo",@progbits,f3_2{{$}}
+; RV32:   .p2align 2
+; RV32-NEXT:  .word .Ltmp0
+; RV64:   .p2align 3
+; RV64-NEXT:  .quad .Ltmp0
+  %frame = alloca i8, i32 16
+  ret void
+}
Index: llvm/lib/Target/RISCV/RISCVMCInstLower.cpp
===
--- llvm/lib/Target/RISCV/RISCVMCInstLower.cpp
+++ llvm/lib/Target/RISCV/RISCVMCInstLower.cpp
@@ -204,10 +204,10 @@
   return true;
 }
 
-void llvm::LowerRISCVMachineInstrToMCInst(const MachineInstr *MI, MCInst ,
-  const AsmPrinter ) {
+bool llvm::lowerRISCVMachineInstrToMCInst(const MachineInstr *MI, MCInst ,
+  AsmPrinter ) {
   if (lowerRISCVVMachineInstrToMCInst(MI, OutMI))
-return;
+return false;
 
   OutMI.setOpcode(MI->getOpcode());
 
@@ -217,19 +217,32 @@
   OutMI.addOperand(MCOp);
   }
 
-  if (OutMI.getOpcode() == RISCV::PseudoReadVLENB) {
+  switch (OutMI.getOpcode()) {
+  case TargetOpcode::PATCHABLE_FUNCTION_ENTER: {
+const Function  = MI->getParent()->getParent()->getFunction();
+if (F.hasFnAttribute("patchable-function-entry")) {
+  unsigned Num;
+  if (F.getFnAttribute("patchable-function-entry")
+  .getValueAsString()
+  .getAsInteger(10, Num))
+return false;
+  AP.emitNops(Num);
+  return true;
+}
+break;
+  }
+  case RISCV::PseudoReadVLENB:
 OutMI.setOpcode(RISCV::CSRRS);
 OutMI.addOperand(MCOperand::createImm(
 RISCVSysReg::lookupSysRegByName("VLENB")->Encoding));
 

[PATCH] D94355: [Passes] Add relative lookup table converter pass

2021-03-15 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri added inline comments.



Comment at: llvm/include/llvm/CodeGen/BasicTTIImpl.h:390-391
+
+if (!TM.getTargetTriple().isArch64Bit())
+  return false;
+

1. But all tests are using `x86_64` triple?
2. This is somewhat backwards. if the target wants to disable this, it will 
need to override this function with `return false;`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D94355

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


[PATCH] D97901: [SystemZ] Test for infinity in testFPKind().

2021-03-15 Thread Jonas Paulsson via Phabricator via cfe-commits
jonpa updated this revision to Diff 330753.
jonpa added a comment.

> This "invert" logic doesn't look correct. "isfinite" and "isinf" both need to 
> return false on NaNs. I think you should just drop the invert logic and use a 
> TDC mask of 0xFC0 (zero, normal, or subnormal) to implement "isfinite".

Rebased and updated per review.


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

https://reviews.llvm.org/D97901

Files:
  clang/lib/CodeGen/TargetInfo.cpp
  clang/test/CodeGen/SystemZ/strictfp_builtins.c

Index: clang/test/CodeGen/SystemZ/strictfp_builtins.c
===
--- clang/test/CodeGen/SystemZ/strictfp_builtins.c
+++ clang/test/CodeGen/SystemZ/strictfp_builtins.c
@@ -9,7 +9,7 @@
 // CHECK-NEXT:[[F_ADDR:%.*]] = alloca float, align 4
 // CHECK-NEXT:store float [[F:%.*]], float* [[F_ADDR]], align 4
 // CHECK-NEXT:[[TMP0:%.*]] = load float, float* [[F_ADDR]], align 4
-// CHECK-NEXT:[[TMP1:%.*]] = call i32 @llvm.s390.tdc.f32(float [[TMP0]], i64 15) [[ATTR2:#.*]]
+// CHECK-NEXT:[[TMP1:%.*]] = call i32 @llvm.s390.tdc.f32(float [[TMP0]], i64 15) #[[ATTR2:[0-9]+]]
 // CHECK-NEXT:ret i32 [[TMP1]]
 //
 int test_isnan_float(float f) {
@@ -21,7 +21,7 @@
 // CHECK-NEXT:[[D_ADDR:%.*]] = alloca double, align 8
 // CHECK-NEXT:store double [[D:%.*]], double* [[D_ADDR]], align 8
 // CHECK-NEXT:[[TMP0:%.*]] = load double, double* [[D_ADDR]], align 8
-// CHECK-NEXT:[[TMP1:%.*]] = call i32 @llvm.s390.tdc.f64(double [[TMP0]], i64 15) [[ATTR2]]
+// CHECK-NEXT:[[TMP1:%.*]] = call i32 @llvm.s390.tdc.f64(double [[TMP0]], i64 15) #[[ATTR2]]
 // CHECK-NEXT:ret i32 [[TMP1]]
 //
 int test_isnan_double(double d) {
@@ -34,10 +34,84 @@
 // CHECK-NEXT:[[LD:%.*]] = load fp128, fp128* [[TMP0:%.*]], align 8
 // CHECK-NEXT:store fp128 [[LD]], fp128* [[LD_ADDR]], align 8
 // CHECK-NEXT:[[TMP1:%.*]] = load fp128, fp128* [[LD_ADDR]], align 8
-// CHECK-NEXT:[[TMP2:%.*]] = call i32 @llvm.s390.tdc.f128(fp128 [[TMP1]], i64 15) [[ATTR2]]
+// CHECK-NEXT:[[TMP2:%.*]] = call i32 @llvm.s390.tdc.f128(fp128 [[TMP1]], i64 15) #[[ATTR2]]
 // CHECK-NEXT:ret i32 [[TMP2]]
 //
 int test_isnan_long_double(long double ld) {
   return __builtin_isnan(ld);
 }
 
+// CHECK-LABEL: @test_isinf_float(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[F_ADDR:%.*]] = alloca float, align 4
+// CHECK-NEXT:store float [[F:%.*]], float* [[F_ADDR]], align 4
+// CHECK-NEXT:[[TMP0:%.*]] = load float, float* [[F_ADDR]], align 4
+// CHECK-NEXT:[[TMP1:%.*]] = call i32 @llvm.s390.tdc.f32(float [[TMP0]], i64 48) #[[ATTR2]]
+// CHECK-NEXT:ret i32 [[TMP1]]
+//
+int test_isinf_float(float f) {
+  return __builtin_isinf(f);
+}
+
+// CHECK-LABEL: @test_isinf_double(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[D_ADDR:%.*]] = alloca double, align 8
+// CHECK-NEXT:store double [[D:%.*]], double* [[D_ADDR]], align 8
+// CHECK-NEXT:[[TMP0:%.*]] = load double, double* [[D_ADDR]], align 8
+// CHECK-NEXT:[[TMP1:%.*]] = call i32 @llvm.s390.tdc.f64(double [[TMP0]], i64 48) #[[ATTR2]]
+// CHECK-NEXT:ret i32 [[TMP1]]
+//
+int test_isinf_double(double d) {
+  return __builtin_isinf(d);
+}
+
+// CHECK-LABEL: @test_isinf_long_double(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[LD_ADDR:%.*]] = alloca fp128, align 8
+// CHECK-NEXT:[[LD:%.*]] = load fp128, fp128* [[TMP0:%.*]], align 8
+// CHECK-NEXT:store fp128 [[LD]], fp128* [[LD_ADDR]], align 8
+// CHECK-NEXT:[[TMP1:%.*]] = load fp128, fp128* [[LD_ADDR]], align 8
+// CHECK-NEXT:[[TMP2:%.*]] = call i32 @llvm.s390.tdc.f128(fp128 [[TMP1]], i64 48) #[[ATTR2]]
+// CHECK-NEXT:ret i32 [[TMP2]]
+//
+int test_isinf_long_double(long double ld) {
+  return __builtin_isinf(ld);
+}
+
+// CHECK-LABEL: @test_isfinite_float(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[F_ADDR:%.*]] = alloca float, align 4
+// CHECK-NEXT:store float [[F:%.*]], float* [[F_ADDR]], align 4
+// CHECK-NEXT:[[TMP0:%.*]] = load float, float* [[F_ADDR]], align 4
+// CHECK-NEXT:[[TMP1:%.*]] = call i32 @llvm.s390.tdc.f32(float [[TMP0]], i64 4032) #[[ATTR2]]
+// CHECK-NEXT:ret i32 [[TMP1]]
+//
+int test_isfinite_float(float f) {
+  return __builtin_isfinite(f);
+}
+
+// CHECK-LABEL: @test_isfinite_double(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[D_ADDR:%.*]] = alloca double, align 8
+// CHECK-NEXT:store double [[D:%.*]], double* [[D_ADDR]], align 8
+// CHECK-NEXT:[[TMP0:%.*]] = load double, double* [[D_ADDR]], align 8
+// CHECK-NEXT:[[TMP1:%.*]] = call i32 @llvm.s390.tdc.f64(double [[TMP0]], i64 4032) #[[ATTR2]]
+// CHECK-NEXT:ret i32 [[TMP1]]
+//
+int test_isfinite_double(double d) {
+  return __builtin_isfinite(d);
+}
+
+// CHECK-LABEL: @test_isfinite_long_double(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[LD_ADDR:%.*]] = alloca fp128, align 8
+// CHECK-NEXT:[[LD:%.*]] = load fp128, fp128* [[TMP0:%.*]], align 8
+// CHECK-NEXT:store fp128 [[LD]], fp128* 

[PATCH] D94355: [Passes] Add relative lookup table converter pass

2021-03-15 Thread Leonard Chan via Phabricator via cfe-commits
leonardchan accepted this revision.
leonardchan added a comment.
This revision is now accepted and ready to land.

LGTM pending a few more comments. Should also give some time to let others 
respond if they have feedback.




Comment at: llvm/lib/Transforms/Utils/RelLookupTableConverter.cpp:41-42
+
+  if (!dyn_cast(GEP->use_begin()->getUser()))
+return false;
+

Not needed here since you have the `isa` below.



Comment at: 
llvm/test/Transforms/RelLookupTableConverter/relative_lookup_table.ll:2-3
+; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
+; RUN: opt < %s -rel-lookup-table-converter -relocation-model=pic -S | 
FileCheck %s
+; RUN: opt < %s -passes=rel-lookup-table-converter -relocation-model=pic -S | 
FileCheck %s
+target datalayout = 
"e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64-S128"

We should also check some other `RUN`s to check that this isn't run on cases 
that return false in `shouldBuildRelLookupTables`: non-PIC, non-64-bit, other 
code model sizes, etc.



Comment at: 
llvm/test/Transforms/RelLookupTableConverter/switch_relative_lookup_table.ll:39
+; ; Relative switch lookup table for strings
+define i8* @string_table(i32 %cond) {
+  ; FNOPIC-LABEL: @string_table(

It looks like this test case isn't much different from `string_table` in 
`relative_lookup_table.ll`? If so, then this file could be removed.



Comment at: llvm/utils/gn/secondary/llvm/lib/Transforms/Utils/BUILD.gn:64
 "PromoteMemoryToRegister.cpp",
+"RelLookupTableConverter.cpp"
 "SSAUpdater.cpp",

Good that you added this, but I think Nico has a bot that automatically updates 
these BUILD.gn files so manually updating them may not be necessary.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D94355

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


[PATCH] D97785: [SystemZ][z/OS] Distinguish between text and binary files on z/OS

2021-03-15 Thread Abhina Sree via Phabricator via cfe-commits
abhina.sreeskantharajan marked 2 inline comments as done.
abhina.sreeskantharajan added a comment.

In D97785#2626427 , @zibi wrote:

> LGTM, I just wonder if we can make an extra parameter to be default. I notice 
> some places that is a default parameter but not in all instances. With 
> default parameter some of the calls might be simplified if there is no need 
> to override it.

Thanks for reviewing. Do you have an example of which function is missing a 
default? The functions I modified in the .h files all have defaults to OF_None 
or binary. I can make another patch for additional changes.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97785

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


[PATCH] D97785: [SystemZ][z/OS] Distinguish between text and binary files on z/OS

2021-03-15 Thread Abhina Sree via Phabricator via cfe-commits
abhina.sreeskantharajan updated this revision to Diff 330747.
abhina.sreeskantharajan added a comment.

Removing llvm::Triple variables


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97785

Files:
  clang/lib/Frontend/CompilerInstance.cpp
  clang/lib/Frontend/FrontendActions.cpp
  clang/lib/StaticAnalyzer/Core/HTMLDiagnostics.cpp
  clang/tools/arcmt-test/arcmt-test.cpp
  llvm/include/llvm/Support/FileSystem.h
  llvm/include/llvm/Support/MemoryBuffer.h
  llvm/lib/IRReader/IRReader.cpp
  llvm/lib/Support/MemoryBuffer.cpp
  llvm/lib/Support/Path.cpp
  llvm/lib/Support/ToolOutputFile.cpp
  llvm/lib/TableGen/Main.cpp
  llvm/utils/FileCheck/FileCheck.cpp

Index: llvm/utils/FileCheck/FileCheck.cpp
===
--- llvm/utils/FileCheck/FileCheck.cpp
+++ llvm/utils/FileCheck/FileCheck.cpp
@@ -803,7 +803,9 @@
 
   // Read the expected strings from the check file.
   ErrorOr> CheckFileOrErr =
-  MemoryBuffer::getFileOrSTDIN(CheckFilename);
+  MemoryBuffer::getFileOrSTDIN(CheckFilename, /*FileSize*/ -1,
+   /*RequiresNullTerminator*/ true,
+   /*IsText*/ true);
   if (std::error_code EC = CheckFileOrErr.getError()) {
 errs() << "Could not open check file '" << CheckFilename
<< "': " << EC.message() << '\n';
@@ -825,7 +827,9 @@
 
   // Open the file to check and add it to SourceMgr.
   ErrorOr> InputFileOrErr =
-  MemoryBuffer::getFileOrSTDIN(InputFilename);
+  MemoryBuffer::getFileOrSTDIN(InputFilename, /*FileSize*/ -1,
+   /*RequiresNullTerminator*/ true,
+   /*IsText*/ true);
   if (InputFilename == "-")
 InputFilename = ""; // Overwrite for improved diagnostic messages
   if (std::error_code EC = InputFileOrErr.getError()) {
Index: llvm/lib/TableGen/Main.cpp
===
--- llvm/lib/TableGen/Main.cpp
+++ llvm/lib/TableGen/Main.cpp
@@ -70,7 +70,7 @@
 return reportError(argv0, "the option -d must be used together with -o\n");
 
   std::error_code EC;
-  ToolOutputFile DepOut(DependFilename, EC, sys::fs::OF_None);
+  ToolOutputFile DepOut(DependFilename, EC, sys::fs::OF_Text);
   if (EC)
 return reportError(argv0, "error opening " + DependFilename + ":" +
   EC.message() + "\n");
@@ -93,7 +93,7 @@
 
   Records.startTimer("Parse, build records");
   ErrorOr> FileOrErr =
-  MemoryBuffer::getFileOrSTDIN(InputFilename);
+  MemoryBuffer::getFileOrSTDIN(InputFilename, -1, true, true);
   if (std::error_code EC = FileOrErr.getError())
 return reportError(argv0, "Could not open input file '" + InputFilename +
   "': " + EC.message() + "\n");
@@ -137,13 +137,14 @@
 // Only updates the real output file if there are any differences.
 // This prevents recompilation of all the files depending on it if there
 // aren't any.
-if (auto ExistingOrErr = MemoryBuffer::getFile(OutputFilename))
+if (auto ExistingOrErr =
+MemoryBuffer::getFile(OutputFilename, -1, true, false, true))
   if (std::move(ExistingOrErr.get())->getBuffer() == Out.str())
 WriteFile = false;
   }
   if (WriteFile) {
 std::error_code EC;
-ToolOutputFile OutFile(OutputFilename, EC, sys::fs::OF_None);
+ToolOutputFile OutFile(OutputFilename, EC, sys::fs::OF_Text);
 if (EC)
   return reportError(argv0, "error opening " + OutputFilename + ": " +
 EC.message() + "\n");
Index: llvm/lib/Support/ToolOutputFile.cpp
===
--- llvm/lib/Support/ToolOutputFile.cpp
+++ llvm/lib/Support/ToolOutputFile.cpp
@@ -11,6 +11,7 @@
 //===--===//
 
 #include "llvm/Support/ToolOutputFile.h"
+#include "llvm/ADT/Triple.h"
 #include "llvm/Support/FileSystem.h"
 #include "llvm/Support/Signals.h"
 using namespace llvm;
@@ -45,7 +46,12 @@
 EC = std::error_code();
 return;
   }
-  OSHolder.emplace(Filename, EC, Flags);
+
+  // On Windows, we set the OF_None flag even for text files to avoid
+  // CRLF translation.
+  OSHolder.emplace(
+  Filename, EC,
+  llvm::Triple(LLVM_HOST_TRIPLE).isOSWindows() ? sys::fs::OF_None : Flags);
   OS = OSHolder.getPointer();
   // If open fails, no cleanup is needed.
   if (EC)
Index: llvm/lib/Support/Path.cpp
===
--- llvm/lib/Support/Path.cpp
+++ llvm/lib/Support/Path.cpp
@@ -816,13 +816,7 @@
 
 std::error_code createUniqueFile(const Twine , int ,
  SmallVectorImpl ,
- unsigned Mode) {
-  return createUniqueEntity(Model, ResultFd, ResultPath, false, Mode, 

[PATCH] D98404: [clangd] Optionally add reflection for clangd-index-server

2021-03-15 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet accepted this revision.
kadircet added a comment.
This revision is now accepted and ready to land.

thanks, lgtm!




Comment at: clang-tools-extra/clangd/CMakeLists.txt:190
 option(CLANGD_ENABLE_REMOTE "Use gRPC library to enable remote index support 
for Clangd" OFF)
+option(ENABLE_GRPC_REFLECTION "Link clangd-index-server to gRPC Reflection 
library" OFF)
 set(GRPC_INSTALL_PATH "" CACHE PATH "Path to gRPC library manual 
installation.")

i think this option belongs to `FindGRPC.cmake`, as it configures the grpc 
linking behavior in general, not something specific to clangd.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98404

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


[PATCH] D98610: [RISCV] Support clang -fpatchable-function-entry && GNU function attribute 'patchable_function_entry'

2021-03-15 Thread Jessica Clarke via Phabricator via cfe-commits
jrtc27 added inline comments.



Comment at: llvm/lib/Target/RISCV/RISCVInstrInfo.cpp:53
 
+void RISCVInstrInfo::getNoop(MCInst ) const {
+  if (STI.getFeatureBits()[RISCV::FeatureStdExtC])

MaskRay wrote:
> jrtc27 wrote:
> > I will forever wonder why TII didn't make it `MCInst getNoop()`...
> Let me do a refactoring before this patch?
Definitely won't complain if you're volunteering to fix it to be a saner 
interface :)



Comment at: llvm/lib/Target/RISCV/RISCVMCInstLower.cpp:247
   }
+  return false;
 }

MaskRay wrote:
> jrtc27 wrote:
> > true, surely?
> false.
> 
> We want to call `EmitToStreamer(*OutStreamer, TmpInst);`
> 
> If a pseudo instruction is not handled here, in MCAsmStreamer we will see its 
> comment (`AsmString`).
Ok, yes, I agree now, worked out what's going on



Comment at: llvm/test/CodeGen/RISCV/patchable-function-entry.ll:24
+; RVC-NEXT:  c.jr ra
+; CHECK:   .section __patchable_function_entries,"awo",@progbits,f1{{$}}
+; 32:  .p2align 2

Is there a benefit from treating these like labels with CHECK-LABEL?



Comment at: llvm/test/CodeGen/RISCV/patchable-function-entry.ll:1-3
+;; Test the function attribute "patchable-function-entry".
+; RUN: llc -mtriple=riscv32 < %s | FileCheck %s --check-prefixes=CHECK,32
+; RUN: llc -mtriple=riscv64 < %s | FileCheck %s --check-prefixes=CHECK,64

jrtc27 wrote:
> MaskRay wrote:
> > jrtc27 wrote:
> > > luismarques wrote:
> > > > jrtc27 wrote:
> > > > > Please match the style of the other tests: 
> > > > > - update_llc_test_checks.py
> > > > > - RV32I/RV32IC/RV64I/RV64IC
> > > > > Please match the style of the other tests: 
> > > > > - update_llc_test_checks.py
> > > > 
> > > > I was going to comment on that but I was unsure it applied here, given 
> > > > that this test was running more than just `llc`. The other RISC-V 
> > > > CodeGen tests we have with objdump don't use the update script IIRC. 
> > > > (And these manual tests were neatly written and much more condensed 
> > > > that the sprawling output of the auto updated checks). But I agree that 
> > > > in general using the script is the way to go for the RISC-V tests.
> > > Yeah, though as you'll see in my comment below I don't think using 
> > > llvm-objdump adds any value, at which point UTC works just fine.
> > I do not think we can use `update_llc_test_checks.py`. We should test 
> > `__patchable_function_entries` which can be scrubbed by 
> > `update_llc_test_checks.py`.
> > 
> > The test is written in such a way with low maintenance: it will very 
> > unlikely change due to codegen differences. (The one `; CHECK-NEXT:addi 
> > sp, sp, -16` below is the only exception.)
> > 
> > Testing more variants seems wasteful.
> > 
> Testing more variants is not wasteful if you can unify the compressed 
> checking RUN lines below with these ones. There would only be 4 separate RUN 
> lines in total, one for each, checking the assembly output (without aliases).
Ok now please use RV32/RV64 rather than bare 32/64 to be more consistent with 
existing tests


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98610

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


[PATCH] D98363: [Sema] Fold VLA types in compound literals to constant arrays.

2021-03-15 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: clang/test/Sema/vla.c:134
+  // expected-warning@+1{{variable length array folded to constant array as an 
extension}}
+  char (*a9)[] = (char[2][ksize]) {{1,2,3,4},{4,3,2,1}};
+

Doesn't this violate the constraints in C17 6.5.2.5p1, "The type name shall 
specify a complete object type or an array of unknown size, but not a 
variable-length array type"?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98363

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


[PATCH] D98610: [RISCV] Support clang -fpatchable-function-entry && GNU function attribute 'patchable_function_entry'

2021-03-15 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added inline comments.



Comment at: llvm/lib/Target/RISCV/RISCVInstrInfo.cpp:53
 
+void RISCVInstrInfo::getNoop(MCInst ) const {
+  if (STI.getFeatureBits()[RISCV::FeatureStdExtC])

jrtc27 wrote:
> I will forever wonder why TII didn't make it `MCInst getNoop()`...
Let me do a refactoring before this patch?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98610

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


[PATCH] D97555: [clangd] Add diagnostic augmentation hook to Modules

2021-03-15 Thread Sam McCall via Phabricator via cfe-commits
sammccall added a comment.
Herald added a project: clang-tools-extra.

Is this entirely obsoleted by the approach in D98499 
?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97555

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


[PATCH] D98610: [RISCV] Support clang -fpatchable-function-entry && GNU function attribute 'patchable_function_entry'

2021-03-15 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay updated this revision to Diff 330744.
MaskRay marked 8 inline comments as done.
MaskRay added a comment.

Mention supported targets in clang/include/clang/Basic/AttrDocs.td

Use 4 llc RUN lines and --riscv-no-aliases


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98610

Files:
  clang/include/clang/Basic/Attr.td
  clang/include/clang/Basic/AttrDocs.td
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/test/Driver/fpatchable-function-entry.c
  clang/test/Sema/patchable-function-entry-attr.cpp
  llvm/lib/Target/RISCV/RISCV.h
  llvm/lib/Target/RISCV/RISCVAsmPrinter.cpp
  llvm/lib/Target/RISCV/RISCVInstrInfo.cpp
  llvm/lib/Target/RISCV/RISCVInstrInfo.h
  llvm/lib/Target/RISCV/RISCVMCInstLower.cpp
  llvm/test/CodeGen/RISCV/patchable-function-entry.ll

Index: llvm/test/CodeGen/RISCV/patchable-function-entry.ll
===
--- /dev/null
+++ llvm/test/CodeGen/RISCV/patchable-function-entry.ll
@@ -0,0 +1,71 @@
+;; Test the function attribute "patchable-function-entry".
+; RUN: llc -mtriple=riscv32 --riscv-no-aliases < %s | FileCheck %s --check-prefixes=CHECK,32,NORVC
+; RUN: llc -mtriple=riscv64 --riscv-no-aliases < %s | FileCheck %s --check-prefixes=CHECK,64,NORVC
+; RUN: llc -mtriple=riscv32 -mattr=+c --riscv-no-aliases < %s | FileCheck %s --check-prefixes=CHECK,32,RVC
+; RUN: llc -mtriple=riscv64 -mattr=+c --riscv-no-aliases < %s | FileCheck %s --check-prefixes=CHECK,64,RVC
+
+define void @f0() "patchable-function-entry"="0" {
+; CHECK-LABEL: f0:
+; CHECK-NEXT:  .Lfunc_begin0:
+; CHECK-NOT: {{addi|c.nop}}
+; NORVC: jalr zero, 0(ra)
+; RVC:   c.jr ra
+; CHECK-NOT:   .section __patchable_function_entries
+  ret void
+}
+
+define void @f1() "patchable-function-entry"="1" {
+; CHECK-LABEL: f1:
+; CHECK-NEXT: .Lfunc_begin1:
+; NORVC: addi zero, zero, 0
+; NORVC-NEXT:jalr zero, 0(ra)
+; RVC:   c.nop
+; RVC-NEXT:  c.jr ra
+; CHECK:   .section __patchable_function_entries,"awo",@progbits,f1{{$}}
+; 32:  .p2align 2
+; 32-NEXT: .word .Lfunc_begin1
+; 64:  .p2align 3
+; 64-NEXT: .quad .Lfunc_begin1
+  ret void
+}
+
+$f5 = comdat any
+define void @f5() "patchable-function-entry"="5" comdat {
+; CHECK-LABEL: f5:
+; CHECK-NEXT:  .Lfunc_begin2:
+; NORVC-COUNT-5: addi zero, zero, 0
+; NORVC-NEXT:jalr zero, 0(ra)
+; RVC-COUNT-5:   c.nop
+; RVC-NEXT:  c.jr ra
+; CHECK:   .section __patchable_function_entries,"aGwo",@progbits,f5,comdat,f5{{$}}
+; 32:  .p2align 2
+; 32-NEXT: .word .Lfunc_begin2
+; 64:  .p2align 3
+; 64-NEXT: .quad .Lfunc_begin2
+  ret void
+}
+
+;; -fpatchable-function-entry=3,2
+;; "patchable-function-prefix" emits data before the function entry label.
+define void @f3_2() "patchable-function-entry"="1" "patchable-function-prefix"="2" {
+; CHECK-LABEL: .type f3_2,@function
+; CHECK-NEXT:  .Ltmp0: # @f3_2
+; NORVC-COUNT-2: addi zero, zero, 0
+; RVC-COUNT-2:   c.nop
+; CHECK-NEXT:  f3_2:
+; CHECK:   # %bb.0:
+; NORVC-NEXT:addi zero, zero, 0
+; NORVC-NEXT:addi sp, sp, -16
+; RVC-NEXT:  c.nop
+; RVC-NEXT:  c.addi sp, -16
+;; .size does not include the prefix.
+; CHECK:  .Lfunc_end3:
+; CHECK-NEXT: .size f3_2, .Lfunc_end3-f3_2
+; CHECK:  .section __patchable_function_entries,"awo",@progbits,f3_2{{$}}
+; 32: .p2align 2
+; 32-NEXT:.word .Ltmp0
+; 64: .p2align 3
+; 64-NEXT:.quad .Ltmp0
+  %frame = alloca i8, i32 16
+  ret void
+}
Index: llvm/lib/Target/RISCV/RISCVMCInstLower.cpp
===
--- llvm/lib/Target/RISCV/RISCVMCInstLower.cpp
+++ llvm/lib/Target/RISCV/RISCVMCInstLower.cpp
@@ -204,10 +204,10 @@
   return true;
 }
 
-void llvm::LowerRISCVMachineInstrToMCInst(const MachineInstr *MI, MCInst ,
-  const AsmPrinter ) {
+bool llvm::lowerRISCVMachineInstrToMCInst(const MachineInstr *MI, MCInst ,
+  AsmPrinter ) {
   if (lowerRISCVVMachineInstrToMCInst(MI, OutMI))
-return;
+return false;
 
   OutMI.setOpcode(MI->getOpcode());
 
@@ -217,19 +217,32 @@
   OutMI.addOperand(MCOp);
   }
 
-  if (OutMI.getOpcode() == RISCV::PseudoReadVLENB) {
+  switch (OutMI.getOpcode()) {
+  case TargetOpcode::PATCHABLE_FUNCTION_ENTER: {
+const Function  = MI->getParent()->getParent()->getFunction();
+if (F.hasFnAttribute("patchable-function-entry")) {
+  unsigned Num;
+  if (F.getFnAttribute("patchable-function-entry")
+  .getValueAsString()
+  .getAsInteger(10, Num))
+return false;
+  AP.emitNops(Num);
+  return true;
+}
+break;
+  }
+  case RISCV::PseudoReadVLENB:
 OutMI.setOpcode(RISCV::CSRRS);
 OutMI.addOperand(MCOperand::createImm(
 RISCVSysReg::lookupSysRegByName("VLENB")->Encoding));
 

[PATCH] D98498: [clangd] Enable modules to contribute tweaks.

2021-03-15 Thread Sam McCall via Phabricator via cfe-commits
sammccall accepted this revision.
sammccall added a comment.
This revision is now accepted and ready to land.
Herald added a project: clang-tools-extra.

Should we have a test somewhere that tweaks defined in modules actually work?




Comment at: clang-tools-extra/clangd/FeatureModule.h:97
+  virtual void
+  contributeTweaks(std::vector> ) {}
+

nit: can you move the forward declaration up the top? Makes the (sort-of) dep 
clearer, and is less fragile re scopes when moving code around.



Comment at: clang-tools-extra/clangd/refactor/Tweak.cpp:55
+  if (!Modules)
+return All;
+  for (auto  : *Modules)

nit: the early return seems more confusing to me here than conditionally 
adding...



Comment at: clang-tools-extra/clangd/refactor/Tweak.h:130
 std::vector>
-prepareTweaks(const Tweak::Selection ,
+prepareTweaks(const class FeatureModuleSet *Modules, const Tweak::Selection ,
   llvm::function_ref Filter);

forward decl: and here



Comment at: clang-tools-extra/clangd/refactor/Tweak.h:130
 std::vector>
-prepareTweaks(const Tweak::Selection ,
+prepareTweaks(const class FeatureModuleSet *Modules, const Tweak::Selection ,
   llvm::function_ref Filter);

sammccall wrote:
> forward decl: and here
nit: move the modules to the end of the list?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98498

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


[PATCH] D98635: [libtooling][clang-tidy] Fix diagnostics not respecting and highlighting fed SourceRanges

2021-03-15 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

In D98635#2626485 , @whisperity wrote:

> In D98635#2626464 , @whisperity 
> wrote:
>
>> Strange because I specifically ran both `check-clang` **and** 
>> `check-clang-tools` locally, but will look into this.
>
> Turns out there is a `check-clang-extra-unit` too, and it looks like those 
> test TUs either didn't compile for me at all (as in, it was not commanded to 
> compile them), or I messed something up during the rebase.
> (But TIL we finally have some semblance of pre-merge checking instead of 
> always reverting commits! )

Yes, it's actually been catching some useful things lately, too, which is nice!

> What's the outlook on the executive decision... changing the **schema** in 
> `libToolingCore`... is such even allowed? I'm venturing into parts unknown 
> here.

I think @alexfh will have to make the final call, but I think the changes here 
look reasonable. I have no idea if we've made stability guarantees about the 
schema though.

I'm giving my LGTM, but not accepting the review because I'd like to hear from 
Alex before this lands.


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

https://reviews.llvm.org/D98635

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


[PATCH] D93938: [clang-format] Fixed AfterEnum handling

2021-03-15 Thread Ally Tiritoglu via Phabricator via cfe-commits
atirit updated this revision to Diff 330738.
atirit added a comment.

Implemented requested changes


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93938

Files:
  clang/lib/Format/TokenAnnotator.cpp
  clang/unittests/Format/FormatTest.cpp


Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -1393,6 +1393,21 @@
Style);
 }
 
+TEST_F(FormatTest, AfterEnumShortEnums) {
+  FormatStyle Style = getLLVMStyle();
+  Style.BreakBeforeBraces = FormatStyle::BS_Custom;
+
+  Style.AllowShortEnumsOnASingleLine = true;
+  Style.BraceWrapping.AfterEnum = true;
+  verifyFormat("enum\n"
+   "{\n"
+   "  A,\n"
+   "  B,\n"
+   "} ShortEnum;",
+   Style);
+  verifyFormat("enum { A, B } ShortEnum;", Style);
+}
+
 TEST_F(FormatTest, ShortCaseLabels) {
   FormatStyle Style = getLLVMStyle();
   Style.AllowShortCaseLabelsOnASingleLine = true;
Index: clang/lib/Format/TokenAnnotator.cpp
===
--- clang/lib/Format/TokenAnnotator.cpp
+++ clang/lib/Format/TokenAnnotator.cpp
@@ -3666,29 +3666,31 @@
 // The tokens that could force an enum to not be on a single line are a
 // trailing comment and a trailing comma on the last case. This checks for
 // those.
-bool lineContainsBreakingTokens = false;
-const FormatToken *breakingSearchToken = 
-while ((breakingSearchToken = breakingSearchToken->Next)) {
-  bool hasBreakingComma = breakingSearchToken->is(tok::comma) &&
-  breakingSearchToken->Next->is(tok::r_brace);
-  if (breakingSearchToken->isTrailingComment() || hasBreakingComma) {
-lineContainsBreakingTokens = true;
-break;
+auto isAllowedByShortEnums = [&]() {
+  if (!Style.AllowShortEnumsOnASingleLine ||
+  (strlen(Right.TokenText.data()) + Right.OriginalColumn) >
+  Style.ColumnLimit)
+return true;
+
+  const FormatToken *breakingSearchToken = 
+  while ((breakingSearchToken = breakingSearchToken->Next)) {
+bool hasBreakingComma = breakingSearchToken->is(tok::comma) &&
+breakingSearchToken->Next->is(tok::r_brace);
+if (breakingSearchToken->isTrailingComment() || hasBreakingComma) {
+  return true;
+}
   }
-}
+
+  return false;
+};
 bool isAllowedByAfterEnum =
 (Line.startsWith(tok::kw_enum) ||
  Line.startsWith(tok::kw_typedef, tok::kw_enum)) &&
 Style.BraceWrapping.AfterEnum;
-bool isLineTooBig = (strlen(Right.TokenText.data()) +
- Right.OriginalColumn) > Style.ColumnLimit;
-// AllowShortEnumsOnASingleLine is ignored if the line is too long or
-// contains breaking tokens.
-bool isAllowedByShortEnums = isLineTooBig || lineContainsBreakingTokens ||
- !Style.AllowShortEnumsOnASingleLine;
-return (isAllowedByAfterEnum && isAllowedByShortEnums) ||
-   (Line.startsWith(tok::kw_class) && Style.BraceWrapping.AfterClass) 
||
-   (Line.startsWith(tok::kw_struct) && 
Style.BraceWrapping.AfterStruct);
+return (Line.startsWith(tok::kw_class) && Style.BraceWrapping.AfterClass) 
||
+   (Line.startsWith(tok::kw_struct) &&
+Style.BraceWrapping.AfterStruct) ||
+   (isAllowedByAfterEnum && isAllowedByShortEnums());
   }
 
   if (Left.is(TT_ObjCBlockLBrace) &&


Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -1393,6 +1393,21 @@
Style);
 }
 
+TEST_F(FormatTest, AfterEnumShortEnums) {
+  FormatStyle Style = getLLVMStyle();
+  Style.BreakBeforeBraces = FormatStyle::BS_Custom;
+
+  Style.AllowShortEnumsOnASingleLine = true;
+  Style.BraceWrapping.AfterEnum = true;
+  verifyFormat("enum\n"
+   "{\n"
+   "  A,\n"
+   "  B,\n"
+   "} ShortEnum;",
+   Style);
+  verifyFormat("enum { A, B } ShortEnum;", Style);
+}
+
 TEST_F(FormatTest, ShortCaseLabels) {
   FormatStyle Style = getLLVMStyle();
   Style.AllowShortCaseLabelsOnASingleLine = true;
Index: clang/lib/Format/TokenAnnotator.cpp
===
--- clang/lib/Format/TokenAnnotator.cpp
+++ clang/lib/Format/TokenAnnotator.cpp
@@ -3666,29 +3666,31 @@
 // The tokens that could force an enum to not be on a single line are a
 // trailing comment and a trailing comma on the last case. This checks for
 // those.
-bool lineContainsBreakingTokens = false;
-const FormatToken *breakingSearchToken = 
-while 

[PATCH] D98635: [libtooling][clang-tidy] Fix diagnostics not respecting and highlighting fed SourceRanges

2021-03-15 Thread Whisperity via Phabricator via cfe-commits
whisperity updated this revision to Diff 330737.
whisperity edited the summary of this revision.
whisperity added a subscriber: compositeprimes.
whisperity added a comment.

Fixed a test file that I originally missed to align with the changes.


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

https://reviews.llvm.org/D98635

Files:
  clang-tools-extra/clang-tidy/ClangTidy.cpp
  clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp
  clang-tools-extra/docs/ReleaseNotes.rst
  clang-tools-extra/test/clang-tidy/infrastructure/export-diagnostics.cpp
  clang-tools-extra/unittests/clang-apply-replacements/ApplyReplacementsTest.cpp
  clang-tools-extra/unittests/clang-tidy/TransformerClangTidyCheckTest.cpp
  clang/include/clang/Tooling/Core/Diagnostic.h
  clang/include/clang/Tooling/DiagnosticsYaml.h
  clang/lib/Tooling/Core/Diagnostic.cpp
  clang/unittests/Tooling/DiagnosticsYamlTest.cpp

Index: clang/unittests/Tooling/DiagnosticsYamlTest.cpp
===
--- clang/unittests/Tooling/DiagnosticsYamlTest.cpp
+++ clang/unittests/Tooling/DiagnosticsYamlTest.cpp
@@ -20,14 +20,16 @@
 using namespace clang::tooling;
 using clang::tooling::Diagnostic;
 
-static DiagnosticMessage makeMessage(const std::string , int FileOffset,
- const std::string ,
- const StringMap ) {
+static DiagnosticMessage
+makeMessage(const std::string , int FileOffset,
+const std::string , const StringMap ,
+const SmallVector ) {
   DiagnosticMessage DiagMessage;
   DiagMessage.Message = Message;
   DiagMessage.FileOffset = FileOffset;
   DiagMessage.FilePath = FilePath;
   DiagMessage.Fix = Fix;
+  DiagMessage.Ranges = Ranges;
   return DiagMessage;
 }
 
@@ -47,8 +49,8 @@
  const StringMap ,
  const SmallVector ) {
   return Diagnostic(DiagnosticName,
-makeMessage(Message, FileOffset, FilePath, Fix), {},
-Diagnostic::Warning, "path/to/build/directory", Ranges);
+makeMessage(Message, FileOffset, FilePath, Fix, Ranges), {},
+Diagnostic::Warning, "path/to/build/directory");
 }
 
 static const char *YAMLContent =
@@ -77,12 +79,12 @@
 "  Offset:  62\n"
 "  Length:  2\n"
 "  ReplacementText: 'replacement #2'\n"
+"  Ranges:\n"
+"- FilePath:'path/to/source.cpp'\n"
+"  FileOffset:  10\n"
+"  Length:  10\n"
 "Level:   Warning\n"
 "BuildDirectory:  'path/to/build/directory'\n"
-"Ranges:\n"
-"  - FilePath:'path/to/source.cpp'\n"
-"FileOffset:  10\n"
-"Length:  10\n"
 "  - DiagnosticName:  'diagnostic#3'\n"
 "DiagnosticMessage:\n"
 "  Message: 'message #3'\n"
@@ -123,9 +125,9 @@
   TUD.Diagnostics.push_back(makeDiagnostic("diagnostic#3", "message #3", 72,
"path/to/source2.cpp", {}, {}));
   TUD.Diagnostics.back().Notes.push_back(
-  makeMessage("Note1", 88, "path/to/note1.cpp", {}));
+  makeMessage("Note1", 88, "path/to/note1.cpp", {}, {}));
   TUD.Diagnostics.back().Notes.push_back(
-  makeMessage("Note2", 99, "path/to/note2.cpp", {}));
+  makeMessage("Note2", 99, "path/to/note2.cpp", {}, {}));
 
   std::string YamlContent;
   raw_string_ostream YamlContentStream(YamlContent);
@@ -166,7 +168,7 @@
   EXPECT_EQ(100u, Fixes1[0].getOffset());
   EXPECT_EQ(12u, Fixes1[0].getLength());
   EXPECT_EQ("replacement #1", Fixes1[0].getReplacementText());
-  EXPECT_TRUE(D1.Ranges.empty());
+  EXPECT_TRUE(D1.Message.Ranges.empty());
 
   Diagnostic D2 = TUDActual.Diagnostics[1];
   EXPECT_EQ("diagnostic#2", D2.DiagnosticName);
@@ -179,10 +181,10 @@
   EXPECT_EQ(62u, Fixes2[0].getOffset());
   EXPECT_EQ(2u, Fixes2[0].getLength());
   EXPECT_EQ("replacement #2", Fixes2[0].getReplacementText());
-  EXPECT_EQ(1u, D2.Ranges.size());
-  EXPECT_EQ("path/to/source.cpp", D2.Ranges[0].FilePath);
-  EXPECT_EQ(10u, D2.Ranges[0].FileOffset);
-  EXPECT_EQ(10u, D2.Ranges[0].Length);
+  EXPECT_EQ(1u, D2.Message.Ranges.size());
+  EXPECT_EQ("path/to/source.cpp", D2.Message.Ranges[0].FilePath);
+  EXPECT_EQ(10u, D2.Message.Ranges[0].FileOffset);
+  EXPECT_EQ(10u, D2.Message.Ranges[0].Length);
 
   Diagnostic D3 = TUDActual.Diagnostics[2];
   EXPECT_EQ("diagnostic#3", D3.DiagnosticName);
@@ -198,5 +200,5 @@
   EXPECT_EQ("path/to/note2.cpp", D3.Notes[1].FilePath);
   std::vector Fixes3 = getFixes(D3.Message.Fix);
   EXPECT_TRUE(Fixes3.empty());
-  EXPECT_TRUE(D3.Ranges.empty());
+  EXPECT_TRUE(D3.Message.Ranges.empty());
 }
Index: clang/lib/Tooling/Core/Diagnostic.cpp
===
--- clang/lib/Tooling/Core/Diagnostic.cpp
+++ 

[PATCH] D93938: [clang-format] Fixed AfterEnum handling

2021-03-15 Thread Ally Tiritoglu via Phabricator via cfe-commits
atirit added inline comments.



Comment at: clang/unittests/Format/FormatTest.cpp:13319
   AllmanBraceStyle.BreakBeforeBraces = FormatStyle::BS_Allman;
+  AllmanBraceStyle.AllowShortEnumsOnASingleLine = false;
 

HazardyKnusperkeks wrote:
> curdeius wrote:
> > That shouldn't be necessary here.
> Is it useful to test once with false and once with true?
Please see the test at `clang/unittests/Format/FormatTest.cpp:13416`:
```
verifyFormat("enum X\n"
 "{\n"
 "  Y = 0\n"
 "}\n",
 AllmanBraceStyle);
```
The default LLVM style that this test bases its style on has 
`AllowShortEnumsOnASingleLine` set to `true`, which conflicts with this test. 
Based on what it expects is the resultant formatting, I think it's safe to 
assume it expects `AllowShortEnumsOnASingleLine` to be `false`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93938

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


[PATCH] D98610: [RISCV] Support clang -fpatchable-function-entry && GNU function attribute 'patchable_function_entry'

2021-03-15 Thread Jessica Clarke via Phabricator via cfe-commits
jrtc27 added inline comments.



Comment at: llvm/test/CodeGen/RISCV/patchable-function-entry.ll:1-3
+;; Test the function attribute "patchable-function-entry".
+; RUN: llc -mtriple=riscv32 < %s | FileCheck %s --check-prefixes=CHECK,32
+; RUN: llc -mtriple=riscv64 < %s | FileCheck %s --check-prefixes=CHECK,64

MaskRay wrote:
> jrtc27 wrote:
> > luismarques wrote:
> > > jrtc27 wrote:
> > > > Please match the style of the other tests: 
> > > > - update_llc_test_checks.py
> > > > - RV32I/RV32IC/RV64I/RV64IC
> > > > Please match the style of the other tests: 
> > > > - update_llc_test_checks.py
> > > 
> > > I was going to comment on that but I was unsure it applied here, given 
> > > that this test was running more than just `llc`. The other RISC-V CodeGen 
> > > tests we have with objdump don't use the update script IIRC. (And these 
> > > manual tests were neatly written and much more condensed that the 
> > > sprawling output of the auto updated checks). But I agree that in general 
> > > using the script is the way to go for the RISC-V tests.
> > Yeah, though as you'll see in my comment below I don't think using 
> > llvm-objdump adds any value, at which point UTC works just fine.
> I do not think we can use `update_llc_test_checks.py`. We should test 
> `__patchable_function_entries` which can be scrubbed by 
> `update_llc_test_checks.py`.
> 
> The test is written in such a way with low maintenance: it will very unlikely 
> change due to codegen differences. (The one `; CHECK-NEXT:addi sp, sp, 
> -16` below is the only exception.)
> 
> Testing more variants seems wasteful.
> 
Testing more variants is not wasteful if you can unify the compressed checking 
RUN lines below with these ones. There would only be 4 separate RUN lines in 
total, one for each, checking the assembly output (without aliases).



Comment at: llvm/test/CodeGen/RISCV/patchable-function-entry.ll:5-9
+;; RVC uses 2-byte nop.
+; RUN: llc -filetype=obj -mtriple=riscv64 %s -o %t.o
+; RUN: llvm-objdump -d %t.o | FileCheck %s --check-prefix=NORVC
+; RUN: llc -filetype=obj -mtriple=riscv64 -mattr=+c %s -o %tc.o
+; RUN: llvm-objdump -d %tc.o | FileCheck %s --check-prefix=RVC

MaskRay wrote:
> jrtc27 wrote:
> > I don't think this is particularly useful if we've checked the assembly 
> > output (and it stops us using update_llc_test_checks.py), we know nops get 
> > emitted correctly, that's tested in various other places.
> objdump -d/llvm-objdump -d does not print c.nop => it is an important detail. 
> Without it we cannot make sure the correct number of bytes is used.
Then use -riscv-no-aliases for the assembly-printing llc above, you don't need 
to go through assembling and dumping


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98610

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


[PATCH] D98610: [RISCV] Support clang -fpatchable-function-entry && GNU function attribute 'patchable_function_entry'

2021-03-15 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay marked 2 inline comments as done.
MaskRay added inline comments.



Comment at: llvm/lib/Target/RISCV/RISCVMCInstLower.cpp:247
   }
+  return false;
 }

jrtc27 wrote:
> true, surely?
false.

We want to call `EmitToStreamer(*OutStreamer, TmpInst);`

If a pseudo instruction is not handled here, in MCAsmStreamer we will see its 
comment (`AsmString`).



Comment at: llvm/test/CodeGen/RISCV/patchable-function-entry.ll:1-3
+;; Test the function attribute "patchable-function-entry".
+; RUN: llc -mtriple=riscv32 < %s | FileCheck %s --check-prefixes=CHECK,32
+; RUN: llc -mtriple=riscv64 < %s | FileCheck %s --check-prefixes=CHECK,64

jrtc27 wrote:
> luismarques wrote:
> > jrtc27 wrote:
> > > Please match the style of the other tests: 
> > > - update_llc_test_checks.py
> > > - RV32I/RV32IC/RV64I/RV64IC
> > > Please match the style of the other tests: 
> > > - update_llc_test_checks.py
> > 
> > I was going to comment on that but I was unsure it applied here, given that 
> > this test was running more than just `llc`. The other RISC-V CodeGen tests 
> > we have with objdump don't use the update script IIRC. (And these manual 
> > tests were neatly written and much more condensed that the sprawling output 
> > of the auto updated checks). But I agree that in general using the script 
> > is the way to go for the RISC-V tests.
> Yeah, though as you'll see in my comment below I don't think using 
> llvm-objdump adds any value, at which point UTC works just fine.
I do not think we can use `update_llc_test_checks.py`. We should test 
`__patchable_function_entries` which can be scrubbed by 
`update_llc_test_checks.py`.

The test is written in such a way with low maintenance: it will very unlikely 
change due to codegen differences. (The one `; CHECK-NEXT:addi sp, sp, -16` 
below is the only exception.)

Testing more variants seems wasteful.




Comment at: llvm/test/CodeGen/RISCV/patchable-function-entry.ll:5-9
+;; RVC uses 2-byte nop.
+; RUN: llc -filetype=obj -mtriple=riscv64 %s -o %t.o
+; RUN: llvm-objdump -d %t.o | FileCheck %s --check-prefix=NORVC
+; RUN: llc -filetype=obj -mtriple=riscv64 -mattr=+c %s -o %tc.o
+; RUN: llvm-objdump -d %tc.o | FileCheck %s --check-prefix=RVC

jrtc27 wrote:
> I don't think this is particularly useful if we've checked the assembly 
> output (and it stops us using update_llc_test_checks.py), we know nops get 
> emitted correctly, that's tested in various other places.
objdump -d/llvm-objdump -d does not print c.nop => it is an important detail. 
Without it we cannot make sure the correct number of bytes is used.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98610

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


[PATCH] D98264: [AArch64] Implement __rndr, __rndrrs intrinsics

2021-03-15 Thread Stelios Ioannou via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGab86edbc88fa: [AArch64] Implement __rndr, __rndrrs 
intrinsics (authored by stelios-arm).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98264

Files:
  clang/include/clang/Basic/BuiltinsAArch64.def
  clang/lib/Basic/Targets/AArch64.cpp
  clang/lib/Basic/Targets/AArch64.h
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/lib/Headers/arm_acle.h
  clang/test/CodeGen/arm_acle.c
  clang/test/CodeGen/builtins-arm64.c
  clang/test/Preprocessor/aarch64-target-features.c
  llvm/include/llvm/IR/IntrinsicsAArch64.td
  llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
  llvm/lib/Target/AArch64/AArch64ISelLowering.h
  llvm/lib/Target/AArch64/AArch64InstrFormats.td
  llvm/lib/Target/AArch64/AArch64InstrInfo.td
  llvm/test/CodeGen/AArch64/rand.ll
  llvm/test/CodeGen/AArch64/stp-opt-with-renaming.mir

Index: llvm/test/CodeGen/AArch64/stp-opt-with-renaming.mir
===
--- llvm/test/CodeGen/AArch64/stp-opt-with-renaming.mir
+++ llvm/test/CodeGen/AArch64/stp-opt-with-renaming.mir
@@ -100,11 +100,11 @@
   bb.0:
 liveins: $x0
 
-renamable $x8 = MRS 58880
+renamable $x8 = MRS 58880, implicit-def $nzcv
 renamable $x8 = MOVZXi 15309, 0
 renamable $x8 = MOVKXi renamable $x8, 26239, 16
 STRXui renamable $x8, renamable $x0, 0, implicit killed $x8 :: (store 8)
-renamable $x8 = MRS 55840
+renamable $x8 = MRS 55840, implicit-def $nzcv
 STRXui killed renamable  $x8, renamable killed $x0, 1, implicit killed $x8 :: (store 8)
 RET undef $lr
 
@@ -134,9 +134,9 @@
   bb.0:
 liveins: $x0, $x1
 
-renamable $x8 = MRS 58880
+renamable $x8 = MRS 58880, implicit-def $nzcv
 STRXui renamable $x8, renamable $x0, 0, implicit killed $x8 :: (store 4)
-renamable $x8 = MRS 55840
+renamable $x8 = MRS 55840, implicit-def $nzcv
 STRXui killed renamable  $x8, renamable killed $x0, 1, implicit killed $x8 :: (store 4)
 RET undef $lr
 
@@ -166,9 +166,9 @@
   bb.0:
 liveins: $x0, $x1
 
-renamable $x8 = MRS 58880
+renamable $x8 = MRS 58880, implicit-def $nzcv
 STRWui renamable $w8, renamable $x0, 0, implicit killed $x8 :: (store 4)
-renamable $x8 = MRS 55840
+renamable $x8 = MRS 55840, implicit-def $nzcv
 STRWui killed renamable $w8, renamable killed $x0, 1, implicit killed $x8 :: (store 4)
 RET undef $lr
 
@@ -275,10 +275,10 @@
   bb.0:
 liveins: $x0, $x1
 
-renamable $x8 = MRS 58880
+renamable $x8 = MRS 58880, implicit-def $nzcv
 renamable $w8 = ORRWrs $wzr, killed renamable $w8, 0, implicit-def $x8
 STRWui renamable $w8, renamable $x0, 0, implicit killed $x8 :: (store 4)
-renamable $x8 = MRS 55840
+renamable $x8 = MRS 55840, implicit-def $nzcv
 STRWui killed renamable $w8, renamable killed $x0, 1, implicit killed $x8 :: (store 4)
 RET undef $lr
 
Index: llvm/test/CodeGen/AArch64/rand.ll
===
--- /dev/null
+++ llvm/test/CodeGen/AArch64/rand.ll
@@ -0,0 +1,40 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
+; RUN: llc -mtriple=aarch64 -mattr=+v8.5a,+rand %s -o - | FileCheck %s
+
+define  i32 @rndr(i64* %__addr) {
+; CHECK-LABEL: rndr:
+; CHECK:   // %bb.0:
+; CHECK-NEXT:mrs x9, RNDR
+; CHECK-NEXT:cset w8, eq
+; CHECK-NEXT:and w8, w8, #0x1
+; CHECK-NEXT:str x9, [x0]
+; CHECK-NEXT:mov w0, w8
+; CHECK-NEXT:ret
+  %1 = tail call { i64, i1 } @llvm.aarch64.rndr()
+  %2 = extractvalue { i64, i1 } %1, 0
+  %3 = extractvalue { i64, i1 } %1, 1
+  store i64 %2, i64* %__addr, align 8
+  %4 = zext i1 %3 to i32
+  ret i32 %4
+}
+
+
+define  i32 @rndrrs(i64*  %__addr) {
+; CHECK-LABEL: rndrrs:
+; CHECK:   // %bb.0:
+; CHECK-NEXT:mrs x9, RNDRRS
+; CHECK-NEXT:cset w8, eq
+; CHECK-NEXT:and w8, w8, #0x1
+; CHECK-NEXT:str x9, [x0]
+; CHECK-NEXT:mov w0, w8
+; CHECK-NEXT:ret
+  %1 = tail call { i64, i1 } @llvm.aarch64.rndrrs()
+  %2 = extractvalue { i64, i1 } %1, 0
+  %3 = extractvalue { i64, i1 } %1, 1
+  store i64 %2, i64* %__addr, align 8
+  %4 = zext i1 %3 to i32
+  ret i32 %4
+}
+
+declare { i64, i1 } @llvm.aarch64.rndr()
+declare { i64, i1 } @llvm.aarch64.rndrrs()
Index: llvm/lib/Target/AArch64/AArch64InstrInfo.td
===
--- llvm/lib/Target/AArch64/AArch64InstrInfo.td
+++ llvm/lib/Target/AArch64/AArch64InstrInfo.td
@@ -607,7 +607,9 @@
 def AArch64stnp : SDNode<"AArch64ISD::STNP", SDT_AArch64stnp, [SDNPHasChain, SDNPMayStore, SDNPMemOperand]>;
 
 def AArch64tbl : SDNode<"AArch64ISD::TBL", SDT_AArch64TBL>;
-
+def AArch64mrs : SDNode<"AArch64ISD::MRS",
+SDTypeProfile<1, 1, [SDTCisVT<0, i64>, SDTCisVT<1, i32>]>,
+

[clang] ab86edb - [AArch64] Implement __rndr, __rndrrs intrinsics

2021-03-15 Thread Stelios Ioannou via cfe-commits

Author: Stelios Ioannou
Date: 2021-03-15T17:51:48Z
New Revision: ab86edbc88fa41e9cb9c6b43d99b69278c9c5040

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

LOG: [AArch64] Implement __rndr, __rndrrs intrinsics

This patch implements the __rndr and __rndrrs intrinsics to provide access to 
the random
number instructions introduced in Armv8.5-A. They are only defined for the 
AArch64
execution state and are available when __ARM_FEATURE_RNG is defined.

These intrinsics store the random number in their pointer argument and return a 
status
code if the generation succeeded. The difference between __rndr __rndrrs, is 
that the latter
intrinsic reseeds the random number generator.

The instructions write the NZCV flags indicating the success of the operation 
that we can
then read with a CSET.

[1] https://developer.arm.com/docs/101028/latest/data-processing-intrinsics
[2] https://bugs.llvm.org/show_bug.cgi?id=47838

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

Change-Id: I8f92e7bf5b450e5da3e59943b53482edf0df6efc

Added: 
llvm/test/CodeGen/AArch64/rand.ll

Modified: 
clang/include/clang/Basic/BuiltinsAArch64.def
clang/lib/Basic/Targets/AArch64.cpp
clang/lib/Basic/Targets/AArch64.h
clang/lib/CodeGen/CGBuiltin.cpp
clang/lib/Headers/arm_acle.h
clang/test/CodeGen/arm_acle.c
clang/test/CodeGen/builtins-arm64.c
clang/test/Preprocessor/aarch64-target-features.c
llvm/include/llvm/IR/IntrinsicsAArch64.td
llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
llvm/lib/Target/AArch64/AArch64ISelLowering.h
llvm/lib/Target/AArch64/AArch64InstrFormats.td
llvm/lib/Target/AArch64/AArch64InstrInfo.td
llvm/test/CodeGen/AArch64/stp-opt-with-renaming.mir

Removed: 




diff  --git a/clang/include/clang/Basic/BuiltinsAArch64.def 
b/clang/include/clang/Basic/BuiltinsAArch64.def
index cfd6ff7f410b..1dac5d2371d4 100644
--- a/clang/include/clang/Basic/BuiltinsAArch64.def
+++ b/clang/include/clang/Basic/BuiltinsAArch64.def
@@ -109,6 +109,10 @@ BUILTIN(__builtin_arm_frint32x, "dd", "")
 BUILTIN(__builtin_arm_frint64xf, "ff", "")
 BUILTIN(__builtin_arm_frint64x, "dd", "")
 
+// Armv8.5-A Random number generation intrinsics
+BUILTIN(__builtin_arm_rndr,   "iWUi*", "n")
+BUILTIN(__builtin_arm_rndrrs, "iWUi*", "n")
+
 // Armv8.7-A load/store 64-byte intrinsics
 BUILTIN(__builtin_arm_ld64b, "vvC*WUi*", "n")
 BUILTIN(__builtin_arm_st64b, "vv*WUiC*", "n")

diff  --git a/clang/lib/Basic/Targets/AArch64.cpp 
b/clang/lib/Basic/Targets/AArch64.cpp
index 5b7981ea5256..f102f738582b 100644
--- a/clang/lib/Basic/Targets/AArch64.cpp
+++ b/clang/lib/Basic/Targets/AArch64.cpp
@@ -360,6 +360,9 @@ void AArch64TargetInfo::getTargetDefines(const LangOptions 
,
   if (HasLS64)
 Builder.defineMacro("__ARM_FEATURE_LS64", "1");
 
+  if (HasRandGen)
+Builder.defineMacro("__ARM_FEATURE_RNG", "1");
+
   switch (ArchKind) {
   default:
 break;
@@ -425,6 +428,7 @@ bool 
AArch64TargetInfo::handleTargetFeatures(std::vector ,
   HasMTE = false;
   HasTME = false;
   HasLS64 = false;
+  HasRandGen = false;
   HasMatMul = false;
   HasBFloat16 = false;
   HasSVE2 = false;
@@ -524,6 +528,8 @@ bool 
AArch64TargetInfo::handleTargetFeatures(std::vector ,
   HasLSE = true;
 if (Feature == "+ls64")
   HasLS64 = true;
+if (Feature == "+rand")
+  HasRandGen = true;
 if (Feature == "+flagm")
   HasFlagM = true;
   }

diff  --git a/clang/lib/Basic/Targets/AArch64.h 
b/clang/lib/Basic/Targets/AArch64.h
index 2809fbce9c88..c1f79e2055f9 100644
--- a/clang/lib/Basic/Targets/AArch64.h
+++ b/clang/lib/Basic/Targets/AArch64.h
@@ -38,6 +38,7 @@ class LLVM_LIBRARY_VISIBILITY AArch64TargetInfo : public 
TargetInfo {
   bool HasTME;
   bool HasPAuth;
   bool HasLS64;
+  bool HasRandGen;
   bool HasMatMul;
   bool HasSVE2;
   bool HasSVE2AES;

diff  --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp
index 29886b57a81f..9827311e07d8 100644
--- a/clang/lib/CodeGen/CGBuiltin.cpp
+++ b/clang/lib/CodeGen/CGBuiltin.cpp
@@ -9255,6 +9255,23 @@ Value *CodeGenFunction::EmitAArch64BuiltinExpr(unsigned 
BuiltinID,
 }
   }
 
+  if (BuiltinID == AArch64::BI__builtin_arm_rndr ||
+  BuiltinID == AArch64::BI__builtin_arm_rndrrs) {
+
+auto Intr = (BuiltinID == AArch64::BI__builtin_arm_rndr
+ ? Intrinsic::aarch64_rndr
+ : Intrinsic::aarch64_rndrrs);
+Function *F = CGM.getIntrinsic(Intr);
+llvm::Value *Val = Builder.CreateCall(F);
+Value *RandomValue = Builder.CreateExtractValue(Val, 0);
+Value *Status = Builder.CreateExtractValue(Val, 1);
+
+Address MemAddress = EmitPointerWithAlignment(E->getArg(0));
+Builder.CreateStore(RandomValue, MemAddress);
+Status = Builder.CreateZExt(Status, 

[PATCH] D98638: [RFC][Coroutine] Force stack allocation after await_suspend() call

2021-03-15 Thread Xun Li via Phabricator via cfe-commits
lxfind created this revision.
Herald added subscribers: ChuanqiXu, hoy, modimo, wenlei, hiraditya.
lxfind requested review of this revision.
Herald added subscribers: llvm-commits, cfe-commits, jdoerfert.
Herald added projects: clang, LLVM.

One of the challenges with the alloca analysis in CoroSplit is that in a few 
cases we need to make sure the allocas must be put on the stack, not on the 
frame.
One of the cases is symmetric transfer. Symmetric transfer is a newly 
introduced feature in C++ coroutines that allows for immediate transfer to a 
different coroutine when the current coroutine is suspended.
The await_suspend() call will return a coroutine handle type, and when that 
happens, the compiler should generate code to resume the returned handle. Like 
this:

  coroutine_handle tmp = awaiter.await_suspend();
  __builtin_coro_resume(tmp.address());

It's very common that after the call to await_suspend(), the current coroutine 
frame is already destroyed, which means we should not be accessing the 
coroutine frame from there.
And we shouldn't because we we use here is a temporary variable which will be 
short-lived. However in a debug build when we don't have lifetime intrinsics, 
it's very hard for 
the compiler to determine that tmp doesn't escape. There are two specific 
challenges here:

1. If the address() function call is not inlined (this should be the default 
case with -O0), we will have a function call that takes tmp as a pointer. The 
compiler does not know that the address call will not capture. This will lead 
to tmp being put on the frame. We could potentially special handle the address 
function in either front-end or CoroSplit, but both are fragile (we will need 
to do some name pattern matching).
2. If the address() function call is inlined (in some versions of libc++, 
address seems to have "always_inline" attribute), we will end up with a series 
of store/load instructions. For a naive analysis, a store of the pointer will 
also be treated as escape. To solve that problem, I introduced D91305 
, which tries to match this specific 
store/load pattern and be able to deal with it. It looks very hacky.

To solve this problem once for all, and provide a framework for solving similar 
problems in the future, this patch introduces 2 new intrinsics to mark a region 
where all data accessed must be put on the stack.
In the case of symmetric transfer, in order to be able to insert code during 
front-end codegen right after the await_suspend call, we need to split the 
Suspend subnode CoroutineSuspendExpr at await_suspend call, as the new 
AwaitSuspendCall subnode.
Then we create a OpaqueValueExpr to wrap around AwaitSuspendCall, and use it to 
continue build the rest of the Suspend subnode. OpaqueValueExpr is necessary 
because we don't want to emit the await_suspend call twice. OpaqueValueExpr 
serves as a stopper in codegen.
If there is no symmetric transfer, the new nodes will be nullptr.
After this patch, now right after the await_suspend() call, we will see a 
llvm.coro.forcestack.begin() intrinsic, and then right before coro.suspend(), 
we will see a llvm.coro.forcestack.end() intrinsic.
CoroSplit will then be able to use this information to decide whether some data 
must be put on the stack.
We are also able to remove the code that tries to match the special store/load 
instruction sequence.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D98638

Files:
  clang/include/clang/AST/ExprCXX.h
  clang/lib/CodeGen/CGCoroutine.cpp
  clang/lib/Sema/SemaCoroutine.cpp
  clang/lib/Serialization/ASTReaderStmt.cpp
  clang/lib/Serialization/ASTWriterStmt.cpp
  clang/test/CodeGenCoroutines/coro-symmetric-transfer-01.cpp
  clang/test/CodeGenCoroutines/coro-symmetric-transfer-02.cpp
  llvm/docs/Coroutines.rst
  llvm/include/llvm/IR/Intrinsics.td
  llvm/lib/Transforms/Coroutines/CoroFrame.cpp
  llvm/test/Transforms/Coroutines/coro-alloca-06.ll

Index: llvm/test/Transforms/Coroutines/coro-alloca-06.ll
===
--- llvm/test/Transforms/Coroutines/coro-alloca-06.ll
+++ llvm/test/Transforms/Coroutines/coro-alloca-06.ll
@@ -1,5 +1,5 @@
-; Test that in some simple cases allocas will not live on the frame even
-; though their pointers are stored.
+; Test that even though some stores may seem to escape pointers,
+; they can be put on the stack as long as they are within forcestack range.
 ; RUN: opt < %s -coro-split -S | FileCheck %s
 ; RUN: opt < %s -passes=coro-split -S | FileCheck %s
 
@@ -19,14 +19,12 @@
   %2 = call i8* @await_suspend()
   %3 = getelementptr inbounds %"handle", %"handle"* %0, i32 0, i32 0
   store i8* %2, i8** %3, align 8
-  %4 = bitcast %"handle"** %1 to i8*
-  call void @llvm.lifetime.start.p0i8(i64 8, i8* %4)
+  %4 = call i8* @llvm.coro.forcestack.begin()
   store %"handle"* %0, %"handle"** %1, align 8
   %5 = load %"handle"*, %"handle"** %1, align 8
   %6 = getelementptr 

[PATCH] D98411: [OpenCL] Respect calling convention for builtin

2021-03-15 Thread Luke Drummond via Phabricator via cfe-commits
ldrumm added a comment.

Given this fixes a runtime crash bug, should it be backported to the relevant 
release branch?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98411

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


[PATCH] D97846: Allow __ieee128 as an alias to __float128 on ppc

2021-03-15 Thread serge via Phabricator via cfe-commits
serge-sans-paille added a comment.

Thanks @hubert.reinterpretcast , @jwakely and @hubert.reinterpretcast for the 
feedback on that review!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97846

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


[PATCH] D97846: Allow __ieee128 as an alias to __float128 on ppc

2021-03-15 Thread serge via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG4aa510be78a7: Allow __ieee128 as an alias to __float128 on 
ppc (authored by serge-sans-paille).
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97846

Files:
  clang/include/clang/Basic/LangOptions.def
  clang/lib/Basic/IdentifierTable.cpp
  clang/lib/Basic/Targets/PPC.cpp
  clang/test/Sema/128bitfloat.cpp


Index: clang/test/Sema/128bitfloat.cpp
===
--- clang/test/Sema/128bitfloat.cpp
+++ clang/test/Sema/128bitfloat.cpp
@@ -6,6 +6,13 @@
 // RUN: %clang_cc1 -triple x86_64-windows-msvc -verify -std=c++11 %s
 
 #if defined(__FLOAT128__) || defined(__SIZEOF_FLOAT128__)
+
+#if defined(__ppc__)
+template  struct __is_float128 { static constexpr bool value = 
false; };
+template <> struct __is_float128<__float128> { static constexpr bool value = 
true; };
+static_assert(__is_float128<__ieee128>::value, "__ieee128 aliases to 
__float128");
+#endif
+
 __float128 f;
 template struct __is_floating_point_helper {};
 template<> struct __is_floating_point_helper<__float128> {};
Index: clang/lib/Basic/Targets/PPC.cpp
===
--- clang/lib/Basic/Targets/PPC.cpp
+++ clang/lib/Basic/Targets/PPC.cpp
@@ -566,6 +566,7 @@
 LongDoubleFormat = Opts.PPCIEEELongDouble
? ::APFloat::IEEEquad()
: ::APFloat::PPCDoubleDouble();
+  Opts.IEEE128 = 1;
 }
 
 ArrayRef PPCTargetInfo::getTargetBuiltins() const {
Index: clang/lib/Basic/IdentifierTable.cpp
===
--- clang/lib/Basic/IdentifierTable.cpp
+++ clang/lib/Basic/IdentifierTable.cpp
@@ -227,6 +227,9 @@
   if (LangOpts.DeclSpecKeyword)
 AddKeyword("__declspec", tok::kw___declspec, KEYALL, LangOpts, *this);
 
+  if (LangOpts.IEEE128)
+AddKeyword("__ieee128", tok::kw___float128, KEYALL, LangOpts, *this);
+
   // Add the 'import' contextual keyword.
   get("import").setModulesImport(true);
 }
Index: clang/include/clang/Basic/LangOptions.def
===
--- clang/include/clang/Basic/LangOptions.def
+++ clang/include/clang/Basic/LangOptions.def
@@ -109,6 +109,7 @@
 LANGOPT(Half  , 1, 0, "half keyword")
 LANGOPT(WChar , 1, CPlusPlus, "wchar_t keyword")
 LANGOPT(Char8 , 1, 0, "char8_t keyword")
+LANGOPT(IEEE128   , 1, 0, "__ieee128 keyword")
 LANGOPT(DeclSpecKeyword   , 1, 0, "__declspec keyword")
 BENIGN_LANGOPT(DollarIdents   , 1, 1, "'$' in identifiers")
 BENIGN_LANGOPT(AsmPreprocessor, 1, 0, "preprocessor in asm mode")


Index: clang/test/Sema/128bitfloat.cpp
===
--- clang/test/Sema/128bitfloat.cpp
+++ clang/test/Sema/128bitfloat.cpp
@@ -6,6 +6,13 @@
 // RUN: %clang_cc1 -triple x86_64-windows-msvc -verify -std=c++11 %s
 
 #if defined(__FLOAT128__) || defined(__SIZEOF_FLOAT128__)
+
+#if defined(__ppc__)
+template  struct __is_float128 { static constexpr bool value = false; };
+template <> struct __is_float128<__float128> { static constexpr bool value = true; };
+static_assert(__is_float128<__ieee128>::value, "__ieee128 aliases to __float128");
+#endif
+
 __float128 f;
 template struct __is_floating_point_helper {};
 template<> struct __is_floating_point_helper<__float128> {};
Index: clang/lib/Basic/Targets/PPC.cpp
===
--- clang/lib/Basic/Targets/PPC.cpp
+++ clang/lib/Basic/Targets/PPC.cpp
@@ -566,6 +566,7 @@
 LongDoubleFormat = Opts.PPCIEEELongDouble
? ::APFloat::IEEEquad()
: ::APFloat::PPCDoubleDouble();
+  Opts.IEEE128 = 1;
 }
 
 ArrayRef PPCTargetInfo::getTargetBuiltins() const {
Index: clang/lib/Basic/IdentifierTable.cpp
===
--- clang/lib/Basic/IdentifierTable.cpp
+++ clang/lib/Basic/IdentifierTable.cpp
@@ -227,6 +227,9 @@
   if (LangOpts.DeclSpecKeyword)
 AddKeyword("__declspec", tok::kw___declspec, KEYALL, LangOpts, *this);
 
+  if (LangOpts.IEEE128)
+AddKeyword("__ieee128", tok::kw___float128, KEYALL, LangOpts, *this);
+
   // Add the 'import' contextual keyword.
   get("import").setModulesImport(true);
 }
Index: clang/include/clang/Basic/LangOptions.def
===
--- clang/include/clang/Basic/LangOptions.def
+++ clang/include/clang/Basic/LangOptions.def
@@ -109,6 +109,7 @@
 LANGOPT(Half  , 1, 0, "half keyword")
 LANGOPT(WChar , 1, CPlusPlus, "wchar_t keyword")
 LANGOPT(Char8 , 1, 0, "char8_t keyword")
+LANGOPT(IEEE128   , 1, 0, 

[clang] 4aa510b - Allow __ieee128 as an alias to __float128 on ppc

2021-03-15 Thread via cfe-commits

Author: serge-sans-paille
Date: 2021-03-15T18:28:26+01:00
New Revision: 4aa510be78a75a4da82657fe433016f00dad0784

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

LOG: Allow __ieee128 as an alias to __float128 on ppc

This matches gcc behavior.

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

Added: 


Modified: 
clang/include/clang/Basic/LangOptions.def
clang/lib/Basic/IdentifierTable.cpp
clang/lib/Basic/Targets/PPC.cpp
clang/test/Sema/128bitfloat.cpp

Removed: 




diff  --git a/clang/include/clang/Basic/LangOptions.def 
b/clang/include/clang/Basic/LangOptions.def
index 620b0899507a2..7efc661002fe7 100644
--- a/clang/include/clang/Basic/LangOptions.def
+++ b/clang/include/clang/Basic/LangOptions.def
@@ -109,6 +109,7 @@ LANGOPT(Bool  , 1, 0, "bool, true, and false 
keywords")
 LANGOPT(Half  , 1, 0, "half keyword")
 LANGOPT(WChar , 1, CPlusPlus, "wchar_t keyword")
 LANGOPT(Char8 , 1, 0, "char8_t keyword")
+LANGOPT(IEEE128   , 1, 0, "__ieee128 keyword")
 LANGOPT(DeclSpecKeyword   , 1, 0, "__declspec keyword")
 BENIGN_LANGOPT(DollarIdents   , 1, 1, "'$' in identifiers")
 BENIGN_LANGOPT(AsmPreprocessor, 1, 0, "preprocessor in asm mode")

diff  --git a/clang/lib/Basic/IdentifierTable.cpp 
b/clang/lib/Basic/IdentifierTable.cpp
index 51c6e02e2e2e0..cedc94a935504 100644
--- a/clang/lib/Basic/IdentifierTable.cpp
+++ b/clang/lib/Basic/IdentifierTable.cpp
@@ -227,6 +227,9 @@ void IdentifierTable::AddKeywords(const LangOptions 
) {
   if (LangOpts.DeclSpecKeyword)
 AddKeyword("__declspec", tok::kw___declspec, KEYALL, LangOpts, *this);
 
+  if (LangOpts.IEEE128)
+AddKeyword("__ieee128", tok::kw___float128, KEYALL, LangOpts, *this);
+
   // Add the 'import' contextual keyword.
   get("import").setModulesImport(true);
 }

diff  --git a/clang/lib/Basic/Targets/PPC.cpp b/clang/lib/Basic/Targets/PPC.cpp
index 73ecc05f20154..78397abfe1f5e 100644
--- a/clang/lib/Basic/Targets/PPC.cpp
+++ b/clang/lib/Basic/Targets/PPC.cpp
@@ -566,6 +566,7 @@ void PPCTargetInfo::adjust(LangOptions ) {
 LongDoubleFormat = Opts.PPCIEEELongDouble
? ::APFloat::IEEEquad()
: ::APFloat::PPCDoubleDouble();
+  Opts.IEEE128 = 1;
 }
 
 ArrayRef PPCTargetInfo::getTargetBuiltins() const {

diff  --git a/clang/test/Sema/128bitfloat.cpp b/clang/test/Sema/128bitfloat.cpp
index 4a826b479d017..6a9ae743c6f06 100644
--- a/clang/test/Sema/128bitfloat.cpp
+++ b/clang/test/Sema/128bitfloat.cpp
@@ -6,6 +6,13 @@
 // RUN: %clang_cc1 -triple x86_64-windows-msvc -verify -std=c++11 %s
 
 #if defined(__FLOAT128__) || defined(__SIZEOF_FLOAT128__)
+
+#if defined(__ppc__)
+template  struct __is_float128 { static constexpr bool value = 
false; };
+template <> struct __is_float128<__float128> { static constexpr bool value = 
true; };
+static_assert(__is_float128<__ieee128>::value, "__ieee128 aliases to 
__float128");
+#endif
+
 __float128 f;
 template struct __is_floating_point_helper {};
 template<> struct __is_floating_point_helper<__float128> {};



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


[PATCH] D98637: [NFC] Use higher level constructs to check for whitespace/newlines in the lexer

2021-03-15 Thread serge via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG9628cb1feef6: [NFC] Use higher level constructs to check for 
whitespace/newlines in the lexer (authored by serge-sans-paille).
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98637

Files:
  clang/lib/Lex/Lexer.cpp


Index: clang/lib/Lex/Lexer.cpp
===
--- clang/lib/Lex/Lexer.cpp
+++ clang/lib/Lex/Lexer.cpp
@@ -2061,7 +2061,7 @@
 if (C == '\\')
   C = getAndAdvanceChar(CurPtr, Result);
 
-if (C == '\n' || C == '\r' ||// Newline.
+if (isVerticalWhitespace(C) ||   // Newline.
 (C == 0 && (CurPtr - 1 == BufferEnd))) { // End of file.
   // If the filename is unterminated, then it must just be a lone <
   // character.  Return this as such.
@@ -3208,10 +3208,10 @@
   const char *CurPtr = BufferPtr;
 
   // Small amounts of horizontal whitespace is very common between tokens.
-  if ((*CurPtr == ' ') || (*CurPtr == '\t')) {
-++CurPtr;
-while ((*CurPtr == ' ') || (*CurPtr == '\t'))
+  if (isHorizontalWhitespace(*CurPtr)) {
+do {
   ++CurPtr;
+} while (isHorizontalWhitespace(*CurPtr));
 
 // If we are keeping whitespace and other tokens, just return what we just
 // skipped.  The next lexer invocation will return the token after the


Index: clang/lib/Lex/Lexer.cpp
===
--- clang/lib/Lex/Lexer.cpp
+++ clang/lib/Lex/Lexer.cpp
@@ -2061,7 +2061,7 @@
 if (C == '\\')
   C = getAndAdvanceChar(CurPtr, Result);
 
-if (C == '\n' || C == '\r' ||// Newline.
+if (isVerticalWhitespace(C) ||   // Newline.
 (C == 0 && (CurPtr - 1 == BufferEnd))) { // End of file.
   // If the filename is unterminated, then it must just be a lone <
   // character.  Return this as such.
@@ -3208,10 +3208,10 @@
   const char *CurPtr = BufferPtr;
 
   // Small amounts of horizontal whitespace is very common between tokens.
-  if ((*CurPtr == ' ') || (*CurPtr == '\t')) {
-++CurPtr;
-while ((*CurPtr == ' ') || (*CurPtr == '\t'))
+  if (isHorizontalWhitespace(*CurPtr)) {
+do {
   ++CurPtr;
+} while (isHorizontalWhitespace(*CurPtr));
 
 // If we are keeping whitespace and other tokens, just return what we just
 // skipped.  The next lexer invocation will return the token after the
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 9628cb1 - [NFC] Use higher level constructs to check for whitespace/newlines in the lexer

2021-03-15 Thread via cfe-commits

Author: serge-sans-paille
Date: 2021-03-15T18:27:19+01:00
New Revision: 9628cb1feef63d764c57fd0652016f9188000e2f

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

LOG: [NFC] Use higher level constructs to check for whitespace/newlines in the 
lexer

It turns out that according to valgrind and perf, it's also slightly faster.

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

Added: 


Modified: 
clang/lib/Lex/Lexer.cpp

Removed: 




diff  --git a/clang/lib/Lex/Lexer.cpp b/clang/lib/Lex/Lexer.cpp
index e63574e306fb..75c0fb65f5b1 100644
--- a/clang/lib/Lex/Lexer.cpp
+++ b/clang/lib/Lex/Lexer.cpp
@@ -2061,7 +2061,7 @@ bool Lexer::LexAngledStringLiteral(Token , const 
char *CurPtr) {
 if (C == '\\')
   C = getAndAdvanceChar(CurPtr, Result);
 
-if (C == '\n' || C == '\r' ||// Newline.
+if (isVerticalWhitespace(C) ||   // Newline.
 (C == 0 && (CurPtr - 1 == BufferEnd))) { // End of file.
   // If the filename is unterminated, then it must just be a lone <
   // character.  Return this as such.
@@ -3208,10 +3208,10 @@ bool Lexer::LexTokenInternal(Token , bool 
TokAtPhysicalStartOfLine) {
   const char *CurPtr = BufferPtr;
 
   // Small amounts of horizontal whitespace is very common between tokens.
-  if ((*CurPtr == ' ') || (*CurPtr == '\t')) {
-++CurPtr;
-while ((*CurPtr == ' ') || (*CurPtr == '\t'))
+  if (isHorizontalWhitespace(*CurPtr)) {
+do {
   ++CurPtr;
+} while (isHorizontalWhitespace(*CurPtr));
 
 // If we are keeping whitespace and other tokens, just return what we just
 // skipped.  The next lexer invocation will return the token after the



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


[PATCH] D98411: [OpenCL] Respect calling convention for builtin

2021-03-15 Thread Luke Drummond via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGfcfd3fda7190: [OpenCL] Respect calling convention for 
builtin (authored by ldrumm).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98411

Files:
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/test/CodeGenOpenCL/sampler.cl


Index: clang/test/CodeGenOpenCL/sampler.cl
===
--- clang/test/CodeGenOpenCL/sampler.cl
+++ clang/test/CodeGenOpenCL/sampler.cl
@@ -39,7 +39,7 @@
   // Case 2b
   sampler_t smp = CLK_ADDRESS_CLAMP_TO_EDGE | CLK_NORMALIZED_COORDS_TRUE | 
CLK_FILTER_NEAREST;
   // CHECK: [[smp_ptr:%[A-Za-z0-9_\.]+]] = alloca %opencl.sampler_t 
addrspace(2)*
-  // CHECK: [[SAMP:%[0-9]+]] = call %opencl.sampler_t addrspace(2)* 
@__translate_sampler_initializer(i32 19)
+  // CHECK: [[SAMP:%[0-9]+]] = call spir_func %opencl.sampler_t addrspace(2)* 
@__translate_sampler_initializer(i32 19)
   // CHECK: store %opencl.sampler_t addrspace(2)* [[SAMP]], %opencl.sampler_t 
addrspace(2)** [[smp_ptr]]
 
   // Case 1b
@@ -56,12 +56,12 @@
 
   // Case 1a/2a
   fnc4smp(glb_smp);
-  // CHECK: [[SAMP:%[0-9]+]] = call %opencl.sampler_t addrspace(2)* 
@__translate_sampler_initializer(i32 35)
+  // CHECK: [[SAMP:%[0-9]+]] = call spir_func %opencl.sampler_t addrspace(2)* 
@__translate_sampler_initializer(i32 35)
   // CHECK: call spir_func void [[FUNCNAME]](%opencl.sampler_t addrspace(2)* 
[[SAMP]])
 
   // Case 1a/2c
   fnc4smp(glb_smp_const);
-  // CHECK: [[SAMP:%[0-9]+]] = call %opencl.sampler_t addrspace(2)* 
@__translate_sampler_initializer(i32 35)
+  // CHECK: [[SAMP:%[0-9]+]] = call spir_func %opencl.sampler_t addrspace(2)* 
@__translate_sampler_initializer(i32 35)
   // CHECK: call spir_func void [[FUNCNAME]](%opencl.sampler_t addrspace(2)* 
[[SAMP]])
 
   // Case 1c
@@ -70,12 +70,12 @@
   // CHECK: call spir_func void [[FUNCNAME]](%opencl.sampler_t addrspace(2)* 
[[SAMP]])
 
   fnc4smp(5);
-  // CHECK: [[SAMP:%[0-9]+]] = call %opencl.sampler_t addrspace(2)* 
@__translate_sampler_initializer(i32 5)
+  // CHECK: [[SAMP:%[0-9]+]] = call spir_func %opencl.sampler_t addrspace(2)* 
@__translate_sampler_initializer(i32 5)
   // CHECK: call spir_func void [[FUNCNAME]](%opencl.sampler_t addrspace(2)* 
[[SAMP]])
 
   const sampler_t const_smp = CLK_ADDRESS_CLAMP_TO_EDGE | 
CLK_NORMALIZED_COORDS_TRUE | CLK_FILTER_LINEAR;
   fnc4smp(const_smp);
-   // CHECK: [[CONST_SAMP:%[0-9]+]] = call %opencl.sampler_t addrspace(2)* 
@__translate_sampler_initializer(i32 35)
+   // CHECK: [[CONST_SAMP:%[0-9]+]] = call spir_func %opencl.sampler_t 
addrspace(2)* @__translate_sampler_initializer(i32 35)
   // CHECK: store %opencl.sampler_t addrspace(2)* [[CONST_SAMP]], 
%opencl.sampler_t addrspace(2)** [[CONST_SMP_PTR:%[a-zA-Z0-9]+]]
   fnc4smp(const_smp);
   // CHECK: [[SAMP:%[0-9]+]] = load %opencl.sampler_t addrspace(2)*, 
%opencl.sampler_t addrspace(2)** [[CONST_SMP_PTR]]
@@ -83,7 +83,7 @@
 
   constant sampler_t constant_smp = CLK_ADDRESS_CLAMP_TO_EDGE | 
CLK_NORMALIZED_COORDS_TRUE | CLK_FILTER_LINEAR;
   fnc4smp(constant_smp);
-  // CHECK: [[SAMP:%[0-9]+]] = call %opencl.sampler_t addrspace(2)* 
@__translate_sampler_initializer(i32 35)
+  // CHECK: [[SAMP:%[0-9]+]] = call spir_func %opencl.sampler_t addrspace(2)* 
@__translate_sampler_initializer(i32 35)
   // CHECK: call spir_func void [[FUNCNAME]](%opencl.sampler_t addrspace(2)* 
[[SAMP]])
 
   // TODO: enable sampler initialization with non-constant integer.
Index: clang/lib/CodeGen/CodeGenModule.cpp
===
--- clang/lib/CodeGen/CodeGenModule.cpp
+++ clang/lib/CodeGen/CodeGenModule.cpp
@@ -6258,15 +6258,17 @@
 
   return *SanStats;
 }
+
 llvm::Value *
 CodeGenModule::createOpenCLIntToSamplerConversion(const Expr *E,
   CodeGenFunction ) {
   llvm::Constant *C = ConstantEmitter(CGF).emitAbstract(E, E->getType());
-  auto SamplerT = getOpenCLRuntime().getSamplerType(E->getType().getTypePtr());
-  auto FTy = llvm::FunctionType::get(SamplerT, {C->getType()}, false);
-  return CGF.Builder.CreateCall(CreateRuntimeFunction(FTy,
-"__translate_sampler_initializer"),
-{C});
+  auto *SamplerT = 
getOpenCLRuntime().getSamplerType(E->getType().getTypePtr());
+  auto *FTy = llvm::FunctionType::get(SamplerT, {C->getType()}, false);
+  auto *Call = CGF.Builder.CreateCall(
+  CreateRuntimeFunction(FTy, "__translate_sampler_initializer"), {C});
+  Call->setCallingConv(Call->getCalledFunction()->getCallingConv());
+  return Call;
 }
 
 CharUnits CodeGenModule::getNaturalPointeeTypeAlignment(


Index: clang/test/CodeGenOpenCL/sampler.cl
===
--- clang/test/CodeGenOpenCL/sampler.cl
+++ clang/test/CodeGenOpenCL/sampler.cl
@@ -39,7 +39,7 

[PATCH] D96769: [OpenMP][AMDGPU] Skip backend and assemble phases for amdgcn

2021-03-15 Thread Ron Lieberman via Phabricator via cfe-commits
ronlieb accepted this revision.
ronlieb added a comment.

LGTM


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D96769

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


[PATCH] D96875: [flang][driver] Add -fdebug-module-writer option

2021-03-15 Thread Arnamoy B via Phabricator via cfe-commits
arnamoy10 added a comment.

Abandon


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

https://reviews.llvm.org/D96875

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


[PATCH] D96875: [flang][driver] Add -fdebug-module-writer option

2021-03-15 Thread Arnamoy B via Phabricator via cfe-commits
arnamoy10 added a comment.

This has been merged, closing it.


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

https://reviews.llvm.org/D96875

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


[PATCH] D97080: [flang][driver] Add -fintrinsic-modules-path option

2021-03-15 Thread Arnamoy B via Phabricator via cfe-commits
arnamoy10 updated this revision to Diff 330711.
arnamoy10 added a comment.

Clang-formatting and addressing reviewers' comments:

Moved the default directory append to `setFortranOpts()`


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

https://reviews.llvm.org/D97080

Files:
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/ToolChains/Flang.cpp
  flang/include/flang/Frontend/PreprocessorOptions.h
  flang/lib/Frontend/CompilerInvocation.cpp
  flang/test/Driver/driver-help-hidden.f90
  flang/test/Driver/driver-help.f90
  flang/test/Driver/intrinsic_module_path.f90

Index: flang/test/Driver/intrinsic_module_path.f90
===
--- /dev/null
+++ flang/test/Driver/intrinsic_module_path.f90
@@ -0,0 +1,35 @@
+! Ensure argument -fintrinsic-modules-path works as expected.
+! WITHOUT the option, the default location for the module is checked and no error generated.
+! With the option GIVEN, the module with the same name is PREPENDED, and considered over the
+! default one, causing a CHECKSUM error.
+
+
+!--
+! FLANG DRIVER (flang-new)
+!--
+! RUN: %flang-new -fsyntax-only %s  2>&1 | FileCheck %s --allow-empty --check-prefix=WITHOUT
+! RUN: not %flang-new -fsyntax-only -fintrinsic-modules-path %S/Inputs/ %s  2>&1 | FileCheck %s --check-prefix=GIVEN
+
+!-
+! FRONTEND FLANG DRIVER (flang-new -fc1)
+!-
+! RUN: %flang-new -fc1 %s  2>&1 | FileCheck %s --allow-empty --check-prefix=WITHOUT
+! RUN: not %flang-new -fc1 -fintrinsic-modules-path %S/Inputs/ %s  2>&1 | FileCheck %s --check-prefix=GIVEN
+
+!-
+! EXPECTED OUTPUT WITHOUT
+!-
+! WITHOUT-NOT: 'ieee_arithmetic.mod' was not found
+! WITHOUT-NOT: 'iso_fortran_env.mod' was not found
+
+!-
+! EXPECTED OUTPUT WITH
+!-
+! GIVEN: error: Cannot read module file for module 'ieee_arithmetic': File has invalid checksum
+! GIVEN: error: Cannot read module file for module 'iso_fortran_env': File has invalid checksum
+
+
+program test_intrinsic_module_path
+   use ieee_arithmetic, only: ieee_round_type
+   use iso_fortran_env, only: team_type, event_type, lock_type
+end program
Index: flang/test/Driver/driver-help.f90
===
--- flang/test/Driver/driver-help.f90
+++ flang/test/Driver/driver-help.f90
@@ -35,6 +35,8 @@
 ! HELP-NEXT: -ffree-formProcess source files in free form
 ! HELP-NEXT: -fimplicit-noneNo implicit typing allowed unless overridden by IMPLICIT statements
 ! HELP-NEXT: -finput-charset= Specify the default character set for source files
+! HELP-NEXT: -fintrinsic-modules-path 
+! HELP-NEXT:Specify where to find the compiled intrinsic modules
 ! HELP-NEXT: -flarge-sizes  Use INTEGER(KIND=8) for the result type in size-related intrinsics
 ! HELP-NEXT: -flogical-abbreviations Enable logical abbreviations
 ! HELP-NEXT: -fno-color-diagnostics Disable colors in diagnostics
@@ -82,6 +84,8 @@
 ! HELP-FC1-NEXT: -ffree-formProcess source files in free form
 ! HELP-FC1-NEXT: -fimplicit-noneNo implicit typing allowed unless overridden by IMPLICIT statements
 ! HELP-FC1-NEXT: -finput-charset= Specify the default character set for source files
+! HELP-FC1-NEXT: -fintrinsic-modules-path 
+! HELP-FC1-NEXT:Specify where to find the compiled intrinsic modules
 ! HELP-FC1-NEXT: -flarge-sizes  Use INTEGER(KIND=8) for the result type in size-related intrinsics
 ! HELP-FC1-NEXT: -flogical-abbreviations Enable logical abbreviations
 ! HELP-FC1-NEXT: -fopenacc  Enable OpenACC
Index: flang/test/Driver/driver-help-hidden.f90
===
--- flang/test/Driver/driver-help-hidden.f90
+++ flang/test/Driver/driver-help-hidden.f90
@@ -35,6 +35,8 @@
 ! CHECK-NEXT: -ffree-formProcess source files in free form
 ! CHECK-NEXT: -fimplicit-noneNo implicit typing allowed unless overridden by IMPLICIT statements
 ! CHECK-NEXT: -finput-charset= Specify the default character set for source files
+! CHECK-NEXT: -fintrinsic-modules-path 
+! CHECK-NEXT:Specify where to find the compiled intrinsic modules
 ! CHECK-NEXT: -flarge-sizes  Use INTEGER(KIND=8) for the result type in size-related intrinsics
 ! CHECK-NEXT: -flogical-abbreviations Enable logical abbreviations
 ! CHECK-NEXT: -fno-color-diagnostics Disable colors in diagnostics
Index: flang/lib/Frontend/CompilerInvocation.cpp
===
--- flang/lib/Frontend/CompilerInvocation.cpp
+++ flang/lib/Frontend/CompilerInvocation.cpp
@@ -21,8 +21,11 @@
 #include 

[PATCH] D96769: [OpenMP][AMDGPU] Skip backend and assemble phases for amdgcn

2021-03-15 Thread Jon Chesterfield via Phabricator via cfe-commits
JonChesterfield accepted this revision.
JonChesterfield added a comment.
This revision is now accepted and ready to land.

Agreed. Lack of save temps is causing grief when debugging, so I keep on 
applying this patch locally. Let's go with this for now. and change to 
something better when we think of it.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D96769

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


  1   2   >