[clang] 5baea05 - [SEH] Fix capture of this in lambda functions

2021-03-11 Thread Olivier Goffart via cfe-commits

Author: Olivier Goffart
Date: 2021-03-11T09:12:42+01:00
New Revision: 5baea0560160a693b19022c5d0ba637b6b46b2d8

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

LOG: [SEH] Fix capture of this in lambda functions

Commit 1b04bdc2f3ffaa7a0e1e3dbdc3a0cd08f0b9a4ce added support for
capturing the 'this' pointer in a SEH context (__finally or __except),
But the case in which the 'this' pointer is part of a lambda capture
was not handled properly

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

Added: 


Modified: 
clang/lib/CodeGen/CGException.cpp
clang/test/CodeGenCXX/exceptions-seh-filter-captures.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/CGException.cpp 
b/clang/lib/CodeGen/CGException.cpp
index 97e2a3a4b69a..5ac037cd9db9 100644
--- a/clang/lib/CodeGen/CGException.cpp
+++ b/clang/lib/CodeGen/CGException.cpp
@@ -1879,8 +1879,24 @@ void CodeGenFunction::EmitCapturedLocals(CodeGenFunction 
&ParentCGF,
 setAddrOfLocalVar(VD, Recovered);
 
 if (isa(VD)) {
-  CXXThisValue = Builder.CreateLoad(Recovered, "this");
-  CXXABIThisValue = CXXThisValue;
+  CXXABIThisAlignment = ParentCGF.CXXABIThisAlignment;
+  CXXThisAlignment = ParentCGF.CXXThisAlignment;
+  CXXABIThisValue = Builder.CreateLoad(Recovered, "this");
+  if (ParentCGF.LambdaThisCaptureField) {
+LambdaThisCaptureField = ParentCGF.LambdaThisCaptureField;
+// We are in a lambda function where "this" is captured so the
+// CXXThisValue need to be loaded from the lambda capture
+LValue ThisFieldLValue =
+EmitLValueForLambdaField(LambdaThisCaptureField);
+if (!LambdaThisCaptureField->getType()->isPointerType()) {
+  CXXThisValue = ThisFieldLValue.getAddress(*this).getPointer();
+} else {
+  CXXThisValue = EmitLoadOfLValue(ThisFieldLValue, SourceLocation())
+ .getScalarVal();
+}
+  } else {
+CXXThisValue = CXXABIThisValue;
+  }
 }
   }
 
@@ -1949,6 +1965,7 @@ void 
CodeGenFunction::startOutlinedSEHHelper(CodeGenFunction &ParentCGF,
   StartFunction(GlobalDecl(), RetTy, Fn, FnInfo, Args,
 OutlinedStmt->getBeginLoc(), OutlinedStmt->getBeginLoc());
   CurSEHParent = ParentCGF.CurSEHParent;
+  CurCodeDecl = ParentCGF.CurCodeDecl;
 
   CGM.SetInternalFunctionAttributes(GlobalDecl(), CurFn, FnInfo);
   EmitCapturedLocals(ParentCGF, OutlinedStmt, IsFilter);

diff  --git a/clang/test/CodeGenCXX/exceptions-seh-filter-captures.cpp 
b/clang/test/CodeGenCXX/exceptions-seh-filter-captures.cpp
index f6cca8eda9d9..6b5c27097cbd 100644
--- a/clang/test/CodeGenCXX/exceptions-seh-filter-captures.cpp
+++ b/clang/test/CodeGenCXX/exceptions-seh-filter-captures.cpp
@@ -123,3 +123,25 @@ void test_lambda() {
 // CHECK: %[[l1_ref:[^ ]*]] = load i32*, i32** %[[l1_ref_ptr]]
 // CHECK: %[[l1:[^ ]*]] = load i32, i32* %[[l1_ref]]
 // CHECK: call i32 (i32, ...) @basic_filter(i32 %[[l1]], i32 %[[l2]])
+
+struct U {
+  void this_in_lambda();
+};
+
+void U::this_in_lambda() {
+  auto lambda = [=]() {
+__try {
+  might_crash();
+} __except (basic_filter(0, this)) {
+}
+  };
+  lambda();
+}
+
+// CHECK-LABEL: define internal i32 
@"?filt$0@0@?R@?0??this_in_lambda@U@@QEAAXXZ@"(i8* 
%exception_pointers, i8* %frame_pointer)
+// CHECK: %[[this_i8:[^ ]*]] = call i8* @llvm.localrecover(i8* bitcast (void 
(%class.anon.0*)* @"??R@?0??this_in_lambda@U@@QEAAXXZ@QEBA@XZ" to 
i8*), i8* %[[fp:[^ ]*]], i32 0)
+// CHECK: %[[this_ptr:[^ ]*]] = bitcast i8* %[[this_i8]] to %class.anon.0**
+// CHECK: %[[this:[^ ]*]] = load %class.anon.0*, %class.anon.0** 
%[[this_ptr]], align 8
+// CHECK: %[[actual_this_ptr:[^ ]*]] = getelementptr inbounds %class.anon.0, 
%class.anon.0* %[[this]], i32 0, i32 0
+// CHECK: %[[actual_this:[^ ]*]] = load %struct.U*, %struct.U** 
%[[actual_this_ptr]], align 8
+// CHECK: call i32 (i32, ...) @basic_filter(i32 0, %struct.U* %[[actual_this]])



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


[PATCH] D97687: [SEH] Fix capture of this in lambda functions

2021-03-11 Thread Olivier Goffart via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG5baea0560160: [SEH] Fix capture of this in lambda functions 
(authored by ogoffart).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97687

Files:
  clang/lib/CodeGen/CGException.cpp
  clang/test/CodeGenCXX/exceptions-seh-filter-captures.cpp


Index: clang/test/CodeGenCXX/exceptions-seh-filter-captures.cpp
===
--- clang/test/CodeGenCXX/exceptions-seh-filter-captures.cpp
+++ clang/test/CodeGenCXX/exceptions-seh-filter-captures.cpp
@@ -123,3 +123,25 @@
 // CHECK: %[[l1_ref:[^ ]*]] = load i32*, i32** %[[l1_ref_ptr]]
 // CHECK: %[[l1:[^ ]*]] = load i32, i32* %[[l1_ref]]
 // CHECK: call i32 (i32, ...) @basic_filter(i32 %[[l1]], i32 %[[l2]])
+
+struct U {
+  void this_in_lambda();
+};
+
+void U::this_in_lambda() {
+  auto lambda = [=]() {
+__try {
+  might_crash();
+} __except (basic_filter(0, this)) {
+}
+  };
+  lambda();
+}
+
+// CHECK-LABEL: define internal i32 
@"?filt$0@0@?R@?0??this_in_lambda@U@@QEAAXXZ@"(i8* 
%exception_pointers, i8* %frame_pointer)
+// CHECK: %[[this_i8:[^ ]*]] = call i8* @llvm.localrecover(i8* bitcast (void 
(%class.anon.0*)* @"??R@?0??this_in_lambda@U@@QEAAXXZ@QEBA@XZ" to 
i8*), i8* %[[fp:[^ ]*]], i32 0)
+// CHECK: %[[this_ptr:[^ ]*]] = bitcast i8* %[[this_i8]] to %class.anon.0**
+// CHECK: %[[this:[^ ]*]] = load %class.anon.0*, %class.anon.0** 
%[[this_ptr]], align 8
+// CHECK: %[[actual_this_ptr:[^ ]*]] = getelementptr inbounds %class.anon.0, 
%class.anon.0* %[[this]], i32 0, i32 0
+// CHECK: %[[actual_this:[^ ]*]] = load %struct.U*, %struct.U** 
%[[actual_this_ptr]], align 8
+// CHECK: call i32 (i32, ...) @basic_filter(i32 0, %struct.U* %[[actual_this]])
Index: clang/lib/CodeGen/CGException.cpp
===
--- clang/lib/CodeGen/CGException.cpp
+++ clang/lib/CodeGen/CGException.cpp
@@ -1879,8 +1879,24 @@
 setAddrOfLocalVar(VD, Recovered);
 
 if (isa(VD)) {
-  CXXThisValue = Builder.CreateLoad(Recovered, "this");
-  CXXABIThisValue = CXXThisValue;
+  CXXABIThisAlignment = ParentCGF.CXXABIThisAlignment;
+  CXXThisAlignment = ParentCGF.CXXThisAlignment;
+  CXXABIThisValue = Builder.CreateLoad(Recovered, "this");
+  if (ParentCGF.LambdaThisCaptureField) {
+LambdaThisCaptureField = ParentCGF.LambdaThisCaptureField;
+// We are in a lambda function where "this" is captured so the
+// CXXThisValue need to be loaded from the lambda capture
+LValue ThisFieldLValue =
+EmitLValueForLambdaField(LambdaThisCaptureField);
+if (!LambdaThisCaptureField->getType()->isPointerType()) {
+  CXXThisValue = ThisFieldLValue.getAddress(*this).getPointer();
+} else {
+  CXXThisValue = EmitLoadOfLValue(ThisFieldLValue, SourceLocation())
+ .getScalarVal();
+}
+  } else {
+CXXThisValue = CXXABIThisValue;
+  }
 }
   }
 
@@ -1949,6 +1965,7 @@
   StartFunction(GlobalDecl(), RetTy, Fn, FnInfo, Args,
 OutlinedStmt->getBeginLoc(), OutlinedStmt->getBeginLoc());
   CurSEHParent = ParentCGF.CurSEHParent;
+  CurCodeDecl = ParentCGF.CurCodeDecl;
 
   CGM.SetInternalFunctionAttributes(GlobalDecl(), CurFn, FnInfo);
   EmitCapturedLocals(ParentCGF, OutlinedStmt, IsFilter);


Index: clang/test/CodeGenCXX/exceptions-seh-filter-captures.cpp
===
--- clang/test/CodeGenCXX/exceptions-seh-filter-captures.cpp
+++ clang/test/CodeGenCXX/exceptions-seh-filter-captures.cpp
@@ -123,3 +123,25 @@
 // CHECK: %[[l1_ref:[^ ]*]] = load i32*, i32** %[[l1_ref_ptr]]
 // CHECK: %[[l1:[^ ]*]] = load i32, i32* %[[l1_ref]]
 // CHECK: call i32 (i32, ...) @basic_filter(i32 %[[l1]], i32 %[[l2]])
+
+struct U {
+  void this_in_lambda();
+};
+
+void U::this_in_lambda() {
+  auto lambda = [=]() {
+__try {
+  might_crash();
+} __except (basic_filter(0, this)) {
+}
+  };
+  lambda();
+}
+
+// CHECK-LABEL: define internal i32 @"?filt$0@0@?R@?0??this_in_lambda@U@@QEAAXXZ@"(i8* %exception_pointers, i8* %frame_pointer)
+// CHECK: %[[this_i8:[^ ]*]] = call i8* @llvm.localrecover(i8* bitcast (void (%class.anon.0*)* @"??R@?0??this_in_lambda@U@@QEAAXXZ@QEBA@XZ" to i8*), i8* %[[fp:[^ ]*]], i32 0)
+// CHECK: %[[this_ptr:[^ ]*]] = bitcast i8* %[[this_i8]] to %class.anon.0**
+// CHECK: %[[this:[^ ]*]] = load %class.anon.0*, %class.anon.0** %[[this_ptr]], align 8
+// CHECK: %[[actual_this_ptr:[^ ]*]] = getelementptr inbounds %class.anon.0, %class.anon.0* %[[this]], i32 0, i32 0
+// CHECK: %[[actual_this:[^ ]*]] = load %struct.U*, %struct.U** %[[actual_this_ptr]], align 8
+// CHECK: call i32 (i32, ...) @basic_filter(i32 0, %struct.U* %[[actual_this]])
Index: clang/lib/CodeGen/CGException.cpp
=

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

2021-03-11 Thread Dave Green via Phabricator via cfe-commits
dmgreen added inline comments.



Comment at: llvm/lib/Target/AArch64/AArch64InstrFormats.td:1495
   let DecoderNamespace = "Fallback";
+  let Defs = [NZCV];
 }

stelios-arm wrote:
> SjoerdMeijer wrote:
> > SjoerdMeijer wrote:
> > > dmgreen wrote:
> > > > SjoerdMeijer wrote:
> > > > > dmgreen wrote:
> > > > > > SjoerdMeijer wrote:
> > > > > > > Do all MRS instructions do this?
> > > > > > No, but some do and it's not obvious which ones do and don't. I 
> > > > > > think it should be reasonable to always def NZCV here, even if they 
> > > > > > are just dead. It should be very rare that it would be beneficial 
> > > > > > for NZCV to be live across a MRS instruction.
> > > > > True, but since creating another definition is cheap, what would the 
> > > > > cons be of:
> > > > > 
> > > > >   class MRS_NZCV : MRSI {
> > > > > ..
> > > > > let Defs = [NZCV];
> > > > >   }
> > > > > 
> > > > > The way I look at it is that the description would be more accurate?
> > > > I believe that would have an over-lapping definition with the existing 
> > > > MRS instruction?
> > > > 
> > > > It would need to be a pseudo I think, which would eventually be turned 
> > > > into a MSR proper late enough on the pipeline for it to be valid (or 
> > > > the other way around, the no-nzcv version gets turned into a the nzcv 
> > > > version to keep the verifier happy).
> > > > 
> > > > It could also be a optional def, but those are only used in the arm 
> > > > backend and I would not recommend using them anywhere else.  I would 
> > > > probably suggest just setting MRS as a NZCV setting instruction, unless 
> > > > we find a reason to need to implement it differently.
> > > > I believe that would have an over-lapping definition with the existing 
> > > > MRS instruction?
> > > 
> > > Ah yeah, that might be true.
> > > 
> > > > It would need to be a pseudo I think
> > > 
> > > How much work is adding a pseudo for this case? My first reaction would 
> > > be just trying to model this correctly, then we potentially don't have to 
> > > worry again later about this. 
> > I just wanted to add that I don't have too strong opinions on this, but 
> > what I suggested seemed more the correct, even though the consequence of 
> > setting NCZV for all MRS is minimal. So I will leave this one up to you 
> > @dmgreen and @stelios-arm .
> I will talk with @dmgreen and if it is decided that it is needed to change, I 
> will address it in a future revision. Please note that the next revision of 
> patch, will not address this comment (temporarily). 
Hmm. I feel like adding the pseudo is more trouble than it is worth - they do 
not come for free. With the extra lowering and adding things like scheduling 
info, etc. It feels simpler to me to set the flags, even if that's not always 
exactly what the instruction would do.


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

https://reviews.llvm.org/D98264

___
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-11 Thread Kirill Bobyrev via Phabricator via cfe-commits
kbobyrev updated this revision to Diff 329865.
kbobyrev marked 8 inline comments as done.
kbobyrev added a comment.

Address review comments.

The current format is "store seconds since X event". Should we store UNIX
timestamps instead? This is probably not portable until C++20, so maybe it
isn't a great idea.


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/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,6 +8,7 @@
 
 #include "Index.pb.h"
 #include "Service.grpc.pb.h"
+#include "Service.pb.h"
 #include "index/Index.h"
 #include "index/Serialization.h"
 #include "index/Symbol.h"
@@ -283,11 +284,39 @@
   clangd::SymbolIndex &Index;
 };
 
+class Monitor final : public v1::Monitor::Service {
+public:
+  Monitor(llvm::sys::TimePoint<> StartTime)
+  : StartTime(StartTime), IndexLastReload(StartTime) {}
+
+  void updateIndex(const llvm::sys::TimePoint<> UpdateTime) {
+IndexLastReload = UpdateTime;
+  }
+
+private:
+  grpc::Status MonitoringInfo(grpc::ServerContext *Context,
+  const v1::MonitoringInfoRequest *Request,
+  v1::MonitoringInfoReply *Reply) override {
+Reply->set_uptime(std::chrono::duration_cast(
+  std::chrono::system_clock::now() - StartTime)
+  .count());
+Reply->set_time_since_reload(
+std::chrono::duration_cast(
+std::chrono::system_clock::now() - IndexLastReload)
+.count());
+return grpc::Status::OK;
+  }
+
+  const llvm::sys::TimePoint<> StartTime;
+  llvm::sys::TimePoint<> IndexLastReload;
+};
+
 // Detect changes in \p IndexPath file and load new versions of the index
 // whenever they become available.
 void hotReload(clangd::SwapIndex &Index, llvm::StringRef IndexPath,
llvm::vfs::Status &LastStatus,
-   llvm::IntrusiveRefCntPtr &FS) {
+   llvm::IntrusiveRefCntPtr &FS,
+   Monitor &Monitor) {
   auto Status = FS->status(IndexPath);
   // Requested file is same as loaded index: no reload is needed.
   if (!Status || (Status->getLastModificationTime() ==
@@ -306,6 +335,7 @@
   Index.reset(std::move(NewIndex));
   log("New index version loaded. Last modification time: {0}, size: {1} bytes.",
   Status->getLastModificationTime(), Status->getSize());
+  Monitor.updateIndex(Status->getLastModificationTime());
 }
 
 void runServerAndWait(clangd::SymbolIndex &Index, llvm::StringRef ServerAddress,
@@ -417,11 +447,13 @@
   }
   clang::clangd::SwapIndex Index(std::move(SymIndex));
 
-  std::thread HotReloadThread([&Index, &Status, &FS]() {
+  Monitor Monitor(std::chrono::system_clock::now());
+
+  std::thread HotReloadThread([&Index, &Status, &FS, &Monitor]() {
 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);
 }
   });
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
@@ -24,3 +24,23 @@
   rpc Relations(RelationsRequest) returns (stream RelationsReply) {}
 }
 
+message MonitoringInfoRequest {}
+message MonitoringInfoReply {
+  // Time since the server started (in seconds).
+  optional uint64 uptime = 1;
+  // Time since the last index reload (in seconds).
+  optional uint64 time_since_reload = 2;
+  // FIXME(kirillbobyrev): The following fields should be provided with the
+  // index (probably in adjacent metadata.txt file next to loaded .idx).
+  // Time since the index was built on the indexing machine.
+  optional uint64 freshness = 3;
+  // Time since the index was built on the indexing machine.
+  optional string index_commit_hash = 4;
+  // URL to the index file.
+  optional string index_link = 5;
+  optional string metadata = 9000;
+}
+
+service Monitor {
+  rpc MonitoringInfo(MonitoringInfoRequest) returns (MonitoringInfoReply) {}
+}
___
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-11 Thread Sjoerd Meijer via Phabricator via cfe-commits
SjoerdMeijer added inline comments.



Comment at: llvm/lib/Target/AArch64/AArch64InstrFormats.td:1495
   let DecoderNamespace = "Fallback";
+  let Defs = [NZCV];
 }

dmgreen wrote:
> stelios-arm wrote:
> > SjoerdMeijer wrote:
> > > SjoerdMeijer wrote:
> > > > dmgreen wrote:
> > > > > SjoerdMeijer wrote:
> > > > > > dmgreen wrote:
> > > > > > > SjoerdMeijer wrote:
> > > > > > > > Do all MRS instructions do this?
> > > > > > > No, but some do and it's not obvious which ones do and don't. I 
> > > > > > > think it should be reasonable to always def NZCV here, even if 
> > > > > > > they are just dead. It should be very rare that it would be 
> > > > > > > beneficial for NZCV to be live across a MRS instruction.
> > > > > > True, but since creating another definition is cheap, what would 
> > > > > > the cons be of:
> > > > > > 
> > > > > >   class MRS_NZCV : MRSI {
> > > > > > ..
> > > > > > let Defs = [NZCV];
> > > > > >   }
> > > > > > 
> > > > > > The way I look at it is that the description would be more accurate?
> > > > > I believe that would have an over-lapping definition with the 
> > > > > existing MRS instruction?
> > > > > 
> > > > > It would need to be a pseudo I think, which would eventually be 
> > > > > turned into a MSR proper late enough on the pipeline for it to be 
> > > > > valid (or the other way around, the no-nzcv version gets turned into 
> > > > > a the nzcv version to keep the verifier happy).
> > > > > 
> > > > > It could also be a optional def, but those are only used in the arm 
> > > > > backend and I would not recommend using them anywhere else.  I would 
> > > > > probably suggest just setting MRS as a NZCV setting instruction, 
> > > > > unless we find a reason to need to implement it differently.
> > > > > I believe that would have an over-lapping definition with the 
> > > > > existing MRS instruction?
> > > > 
> > > > Ah yeah, that might be true.
> > > > 
> > > > > It would need to be a pseudo I think
> > > > 
> > > > How much work is adding a pseudo for this case? My first reaction would 
> > > > be just trying to model this correctly, then we potentially don't have 
> > > > to worry again later about this. 
> > > I just wanted to add that I don't have too strong opinions on this, but 
> > > what I suggested seemed more the correct, even though the consequence of 
> > > setting NCZV for all MRS is minimal. So I will leave this one up to you 
> > > @dmgreen and @stelios-arm .
> > I will talk with @dmgreen and if it is decided that it is needed to change, 
> > I will address it in a future revision. Please note that the next revision 
> > of patch, will not address this comment (temporarily). 
> Hmm. I feel like adding the pseudo is more trouble than it is worth - they do 
> not come for free. With the extra lowering and adding things like scheduling 
> info, etc. It feels simpler to me to set the flags, even if that's not always 
> exactly what the instruction would do.
Okidoki, then we at least need some comments here explaining this all.


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

https://reviews.llvm.org/D98264

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


[PATCH] D98061: [InstrProfiling] Generate runtime hook for ELF platforms

2021-03-11 Thread Petr Hosek via Phabricator via cfe-commits
phosek updated this revision to Diff 329875.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98061

Files:
  clang/docs/UsersManual.rst
  clang/lib/Driver/ToolChains/Fuchsia.cpp
  clang/lib/Driver/ToolChains/Fuchsia.h
  clang/lib/Driver/ToolChains/Linux.cpp
  clang/lib/Driver/ToolChains/Linux.h
  clang/test/Driver/coverage-ld.c
  clang/test/Driver/fuchsia.c
  llvm/lib/Transforms/Instrumentation/InstrProfiling.cpp
  llvm/test/Instrumentation/InstrProfiling/linkage.ll
  llvm/test/Instrumentation/InstrProfiling/profiling.ll

Index: llvm/test/Instrumentation/InstrProfiling/profiling.ll
===
--- llvm/test/Instrumentation/InstrProfiling/profiling.ll
+++ llvm/test/Instrumentation/InstrProfiling/profiling.ll
@@ -1,14 +1,11 @@
 ; RUN: opt < %s -mtriple=x86_64 -passes=instrprof -S | FileCheck %s --check-prefixes=CHECK,ELF,ELF_GENERIC
 ; RUN: opt < %s -mtriple=x86_64-linux -passes=instrprof -S | FileCheck %s --check-prefixes=CHECK,ELF_LINUX
 ; RUN: opt < %s -mtriple=x86_64-apple-macosx10.10.0 -passes=instrprof -S | FileCheck %s --check-prefixes=CHECK,MACHO
-; RUN: opt < %s -mtriple=x86_64-windows -passes=instrprof -S | FileCheck %s --check-prefixes=CHECK,WIN
+; RUN: opt < %s -mtriple=x86_64-windows -passes=instrprof -S | FileCheck %s --check-prefixes=CHECK,COFF
 
 ; RUN: opt < %s -mtriple=x86_64-apple-macosx10.10.0 -instrprof -S | FileCheck %s
 
-; ELF_GENERIC: @__llvm_profile_runtime = external global i32
-; ELF_LINUX-NOT: @__llvm_profile_runtime
 ; MACHO: @__llvm_profile_runtime = external global i32
-; WIN: @__llvm_profile_runtime = external global i32
 
 @__profn_foo = hidden constant [3 x i8] c"foo"
 ; CHECK-NOT: __profn_foo
@@ -21,8 +18,8 @@
 ; ELF:   @__profd_foo = hidden {{.*}}, section "__llvm_prf_data", comdat, align 8
 ; MACHO: @__profc_foo = hidden global [1 x i64] zeroinitializer, section "__DATA,__llvm_prf_cnts", align 8
 ; MACHO: @__profd_foo = hidden {{.*}}, section "__DATA,__llvm_prf_data,regular,live_support", align 8
-; WIN:   @__profc_foo = internal global [1 x i64] zeroinitializer, section ".lprfc$M", align 8
-; WIN:   @__profd_foo = internal {{.*}}, section ".lprfd$M", align 8
+; COFF:   @__profc_foo = internal global [1 x i64] zeroinitializer, section ".lprfc$M", align 8
+; COFF:   @__profd_foo = internal {{.*}}, section ".lprfd$M", align 8
 define void @foo() {
   call void @llvm.instrprof.increment(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @__profn_foo, i32 0, i32 0), i64 0, i32 1, i32 0)
   ret void
@@ -32,8 +29,8 @@
 ; ELF:   @__profd_bar = hidden {{.*}}, section "__llvm_prf_data", comdat, align 8
 ; MACHO: @__profc_bar = hidden global [1 x i64] zeroinitializer, section "__DATA,__llvm_prf_cnts", align 8
 ; MACHO: @__profd_bar = hidden {{.*}}, section "__DATA,__llvm_prf_data,regular,live_support", align 8
-; WIN:   @__profc_bar = internal global [1 x i64] zeroinitializer, section ".lprfc$M", align 8
-; WIN:   @__profd_bar = internal {{.*}}, section ".lprfd$M", align 8
+; COFF:   @__profc_bar = internal global [1 x i64] zeroinitializer, section ".lprfc$M", align 8
+; COFF:   @__profd_bar = internal {{.*}}, section ".lprfd$M", align 8
 define void @bar() {
   call void @llvm.instrprof.increment(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @__profn_bar, i32 0, i32 0), i64 0, i32 1, i32 0)
   ret void
@@ -43,8 +40,8 @@
 ; ELF:   @__profd_baz = hidden {{.*}}, section "__llvm_prf_data", comdat, align 8
 ; MACHO: @__profc_baz = hidden global [3 x i64] zeroinitializer, section "__DATA,__llvm_prf_cnts", align 8
 ; MACHO: @__profd_baz = hidden {{.*}}, section "__DATA,__llvm_prf_data,regular,live_support", align 8
-; WIN:   @__profc_baz = internal global [3 x i64] zeroinitializer, section ".lprfc$M", align 8
-; WIN:   @__profd_baz = internal {{.*}}, section ".lprfd$M", align 8
+; COFF:   @__profc_baz = internal global [3 x i64] zeroinitializer, section ".lprfc$M", align 8
+; COFF:   @__profd_baz = internal {{.*}}, section ".lprfd$M", align 8
 define void @baz() {
   call void @llvm.instrprof.increment(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @__profn_baz, i32 0, i32 0), i64 0, i32 3, i32 0)
   call void @llvm.instrprof.increment(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @__profn_baz, i32 0, i32 0), i64 0, i32 3, i32 1)
@@ -54,12 +51,14 @@
 
 declare void @llvm.instrprof.increment(i8*, i64, i32, i32)
 
-; ELF:   @llvm.compiler.used = appending global {{.*}} @__llvm_profile_runtime {{.*}} @__profd_foo {{.*}} @__profd_bar {{.*}} @__profd_baz
+; ELF:   @__llvm_profile_runtime = external global i32
+; COFF:  @__llvm_profile_runtime = external global i32
+
+; ELF:   @llvm.compiler.used = appending global {{.*}} @__profd_foo {{.*}} @__profd_bar {{.*}} @__profd_baz {{.*}} @__llvm_profile_runtime
 ; MACHO: @llvm.used = appending global {{.*}} @__llvm_profile_runtime {{.*}} @__profd_foo {{.*}} @__profd_bar {{.*}} @__profd_baz
-; WIN:   @llvm.used

[clang] 68e0133 - [CGBuilder] Remove type-less CreateAlignedLoad() APIs (NFC)

2021-03-11 Thread Nikita Popov via cfe-commits

Author: Nikita Popov
Date: 2021-03-11T10:41:23+01:00
New Revision: 68e01339cc5bc3d8a885bc9413611fbc6ca151e4

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

LOG: [CGBuilder] Remove type-less CreateAlignedLoad() APIs (NFC)

These are incompatible with opaque pointers. This is in preparation
of dropping this API on the IRBuilder side as well.

Instead explicitly pass the loaded type.

Added: 


Modified: 
clang/lib/CodeGen/CGBlocks.cpp
clang/lib/CodeGen/CGBuilder.h
clang/lib/CodeGen/CGBuiltin.cpp
clang/lib/CodeGen/CGCall.cpp
clang/lib/CodeGen/CGException.cpp
clang/lib/CodeGen/CGExpr.cpp
clang/lib/CodeGen/CGObjC.cpp
clang/lib/CodeGen/CGObjCGNU.cpp
clang/lib/CodeGen/CGObjCMac.cpp
clang/lib/CodeGen/CodeGenFunction.cpp
clang/lib/CodeGen/ItaniumCXXABI.cpp
clang/lib/CodeGen/MicrosoftCXXABI.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/CGBlocks.cpp b/clang/lib/CodeGen/CGBlocks.cpp
index 91c726f4cf641..7e5d96fb8633e 100644
--- a/clang/lib/CodeGen/CGBlocks.cpp
+++ b/clang/lib/CodeGen/CGBlocks.cpp
@@ -1190,8 +1190,10 @@ RValue CodeGenFunction::EmitBlockCallExpr(const CallExpr 
*E,
 
 // First argument of a block call is a generic block literal casted to
 // generic void pointer, i.e. i8 addrspace(4)*
+llvm::Type *GenericVoidPtrTy =
+CGM.getOpenCLRuntime().getGenericVoidPointerType();
 llvm::Value *BlockDescriptor = Builder.CreatePointerCast(
-BlockPtr, CGM.getOpenCLRuntime().getGenericVoidPointerType());
+BlockPtr, GenericVoidPtrTy);
 QualType VoidPtrQualTy = Ctx.getPointerType(
 Ctx.getAddrSpaceQualType(Ctx.VoidTy, LangAS::opencl_generic));
 Args.add(RValue::get(BlockDescriptor), VoidPtrQualTy);
@@ -1203,7 +1205,8 @@ RValue CodeGenFunction::EmitBlockCallExpr(const CallExpr 
*E,
   Func = CGM.getOpenCLRuntime().getInvokeFunction(E->getCallee());
 else {
   llvm::Value *FuncPtr = Builder.CreateStructGEP(GenBlockTy, BlockPtr, 2);
-  Func = Builder.CreateAlignedLoad(FuncPtr, getPointerAlign());
+  Func = Builder.CreateAlignedLoad(GenericVoidPtrTy, FuncPtr,
+   getPointerAlign());
 }
   } else {
 // Bitcast the block literal to a generic block literal.
@@ -1219,7 +1222,7 @@ RValue CodeGenFunction::EmitBlockCallExpr(const CallExpr 
*E,
 EmitCallArgs(Args, FnType->getAs(), E->arguments());
 
 // Load the function.
-Func = Builder.CreateAlignedLoad(FuncPtr, getPointerAlign());
+Func = Builder.CreateAlignedLoad(VoidPtrTy, FuncPtr, getPointerAlign());
   }
 
   const FunctionType *FuncTy = FnType->castAs();

diff  --git a/clang/lib/CodeGen/CGBuilder.h b/clang/lib/CodeGen/CGBuilder.h
index 4cdf9fce7a3eb..320278eac1241 100644
--- a/clang/lib/CodeGen/CGBuilder.h
+++ b/clang/lib/CodeGen/CGBuilder.h
@@ -82,19 +82,11 @@ class CGBuilderTy : public CGBuilderBaseTy {
   }
 
   using CGBuilderBaseTy::CreateAlignedLoad;
-  llvm::LoadInst *CreateAlignedLoad(llvm::Value *Addr, CharUnits Align,
-const llvm::Twine &Name = "") {
-return CreateAlignedLoad(Addr, Align.getAsAlign(), Name);
-  }
-  llvm::LoadInst *CreateAlignedLoad(llvm::Value *Addr, CharUnits Align,
-const char *Name) {
-return CreateAlignedLoad(Addr, Align.getAsAlign(), Name);
-  }
   llvm::LoadInst *CreateAlignedLoad(llvm::Type *Ty, llvm::Value *Addr,
 CharUnits Align,
 const llvm::Twine &Name = "") {
 assert(Addr->getType()->getPointerElementType() == Ty);
-return CreateAlignedLoad(Addr, Align.getAsAlign(), Name);
+return CreateAlignedLoad(Ty, Addr, Align.getAsAlign(), Name);
   }
 
   // Note that we intentionally hide the CreateStore APIs that don't

diff  --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp
index ac10fabaea390..44bd151093cce 100644
--- a/clang/lib/CodeGen/CGBuiltin.cpp
+++ b/clang/lib/CodeGen/CGBuiltin.cpp
@@ -414,7 +414,7 @@ static Value *EmitISOVolatileLoad(CodeGenFunction &CGF, 
const CallExpr *E) {
   llvm::Type *ITy =
   llvm::IntegerType::get(CGF.getLLVMContext(), LoadSize.getQuantity() * 8);
   Ptr = CGF.Builder.CreateBitCast(Ptr, ITy->getPointerTo());
-  llvm::LoadInst *Load = CGF.Builder.CreateAlignedLoad(Ptr, LoadSize);
+  llvm::LoadInst *Load = CGF.Builder.CreateAlignedLoad(ITy, Ptr, LoadSize);
   Load->setVolatile(true);
   return Load;
 }
@@ -12160,7 +12160,8 @@ Value *CodeGenFunction::EmitX86CpuIs(StringRef CPUStr) {
   llvm::Value *Idxs[] = {ConstantInt::get(Int32Ty, 0),
  ConstantInt::get(Int32Ty, Index)};
   llvm::Value *CpuValue = Builder.CreateGEP(STy, CpuModel, Idxs);
-  CpuValue = Builder.CreateAlignedLoad(CpuValue,

[PATCH] D95561: [Clang] Introduce Swift async calling convention.

2021-03-11 Thread Varun Gandhi via Phabricator via cfe-commits
varungandhi-apple updated this revision to Diff 329883.
varungandhi-apple added a comment.

Permit swift_context and swift_indirect_result parameters for
swiftasynccall functions. (Earlier, these were restricted to
swiftcall-only.)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95561

Files:
  clang/include/clang-c/Index.h
  clang/include/clang/Basic/Attr.td
  clang/include/clang/Basic/AttrDocs.td
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Basic/Features.def
  clang/include/clang/Basic/Specifiers.h
  clang/include/clang/CodeGen/SwiftCallingConv.h
  clang/lib/AST/ItaniumMangle.cpp
  clang/lib/AST/MicrosoftMangle.cpp
  clang/lib/AST/Type.cpp
  clang/lib/AST/TypePrinter.cpp
  clang/lib/Basic/Targets/AArch64.cpp
  clang/lib/Basic/Targets/ARM.cpp
  clang/lib/Basic/Targets/PPC.h
  clang/lib/Basic/Targets/SystemZ.h
  clang/lib/Basic/Targets/WebAssembly.h
  clang/lib/Basic/Targets/X86.h
  clang/lib/CodeGen/CGCall.cpp
  clang/lib/CodeGen/CGDebugInfo.cpp
  clang/lib/Sema/SemaDeclAttr.cpp
  clang/lib/Sema/SemaType.cpp
  clang/test/CodeGen/arm-swiftcall.c
  clang/test/CodeGen/debug-info-cc.c
  clang/test/CodeGen/swift-call-conv.c
  clang/test/Sema/attr-c2x.c
  clang/test/Sema/attr-swiftcall.c
  clang/test/Sema/no_callconv.cpp
  clang/test/SemaCXX/attr-swiftcall.cpp
  clang/tools/libclang/CXType.cpp
  llvm/include/llvm/Demangle/MicrosoftDemangleNodes.h
  llvm/lib/Demangle/MicrosoftDemangle.cpp
  llvm/lib/Demangle/MicrosoftDemangleNodes.cpp
  llvm/test/Demangle/ms-mangle.test

Index: llvm/test/Demangle/ms-mangle.test
===
--- llvm/test/Demangle/ms-mangle.test
+++ llvm/test/Demangle/ms-mangle.test
@@ -341,6 +341,9 @@
 ?swift_func@@YSXXZ
 ; CHECK: void __attribute__((__swiftcall__)) swift_func(void)
 
+?swift_async_func@@YTXXZ
+; CHECK: void __attribute__((__swiftasynccall__)) swift_async_func(void)
+
 ??$fn_tmpl@$1?extern_c_func@@YAXXZ@@YAXXZ
 ; CHECK: void __cdecl fn_tmpl<&void __cdecl extern_c_func(void)>(void)
 
Index: llvm/lib/Demangle/MicrosoftDemangleNodes.cpp
===
--- llvm/lib/Demangle/MicrosoftDemangleNodes.cpp
+++ llvm/lib/Demangle/MicrosoftDemangleNodes.cpp
@@ -110,6 +110,9 @@
   case CallingConv::Swift:
 OS << "__attribute__((__swiftcall__)) ";
 break;
+  case CallingConv::SwiftAsync:
+OS << "__attribute__((__swiftasynccall__)) ";
+break;
   default:
 break;
   }
Index: llvm/lib/Demangle/MicrosoftDemangle.cpp
===
--- llvm/lib/Demangle/MicrosoftDemangle.cpp
+++ llvm/lib/Demangle/MicrosoftDemangle.cpp
@@ -1713,6 +1713,8 @@
 return CallingConv::Vectorcall;
   case 'S':
 return CallingConv::Swift;
+  case 'T':
+return CallingConv::SwiftAsync;
   }
 
   return CallingConv::None;
Index: llvm/include/llvm/Demangle/MicrosoftDemangleNodes.h
===
--- llvm/include/llvm/Demangle/MicrosoftDemangleNodes.h
+++ llvm/include/llvm/Demangle/MicrosoftDemangleNodes.h
@@ -67,7 +67,8 @@
   Eabi,
   Vectorcall,
   Regcall,
-  Swift, // Clang-only
+  Swift,  // Clang-only
+  SwiftAsync, // Clang-only
 };
 
 enum class ReferenceKind : uint8_t { None, LValueRef, RValueRef };
Index: clang/tools/libclang/CXType.cpp
===
--- clang/tools/libclang/CXType.cpp
+++ clang/tools/libclang/CXType.cpp
@@ -664,6 +664,7 @@
   TCALLINGCONV(AAPCS_VFP);
   TCALLINGCONV(IntelOclBicc);
   TCALLINGCONV(Swift);
+  TCALLINGCONV(SwiftAsync);
   TCALLINGCONV(PreserveMost);
   TCALLINGCONV(PreserveAll);
 case CC_SpirFunction: return CXCallingConv_Unexposed;
Index: clang/test/SemaCXX/attr-swiftcall.cpp
===
--- clang/test/SemaCXX/attr-swiftcall.cpp
+++ clang/test/SemaCXX/attr-swiftcall.cpp
@@ -1,20 +1,29 @@
 // RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fsyntax-only -verify %s
 
 #define SWIFTCALL __attribute__((swiftcall))
+#define SWIFTASYNCCALL __attribute__((swiftasynccall))
 #define INDIRECT_RESULT __attribute__((swift_indirect_result))
 #define ERROR_RESULT __attribute__((swift_error_result))
 #define CONTEXT __attribute__((swift_context))
+#define ASYNC_CONTEXT __attribute__((swift_async_context))
 
 int notAFunction SWIFTCALL; // expected-warning {{'swiftcall' only applies to function types; type here is 'int'}}
+int notAnAsyncFunction SWIFTASYNCCALL; // expected-warning {{'swiftasynccall' only applies to function types; type here is 'int'}}
 void variadic(int x, ...) SWIFTCALL; // expected-error {{variadic function cannot use swiftcall calling convention}}
+void variadic_async(int x, ...) SWIFTASYNCCALL; // expected-error {{variadic function cannot use swiftasynccall calling convention}}
 void multiple

[clang] dcdd476 - [OpenCL] Add missing atomic_xchg overload

2021-03-11 Thread Sven van Haastregt via cfe-commits

Author: Sven van Haastregt
Date: 2021-03-11T10:20:29Z
New Revision: dcdd476c46dcab6e11d4421475e3792e65c1dd1f

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

LOG: [OpenCL] Add missing atomic_xchg overload

Added: 


Modified: 
clang/lib/Sema/OpenCLBuiltins.td

Removed: 




diff  --git a/clang/lib/Sema/OpenCLBuiltins.td 
b/clang/lib/Sema/OpenCLBuiltins.td
index 05dd6a1bd8f8..d6d77dc90d30 100644
--- a/clang/lib/Sema/OpenCLBuiltins.td
+++ b/clang/lib/Sema/OpenCLBuiltins.td
@@ -1043,6 +1043,7 @@ let Extension = FuncExtKhrInt64ExtendedAtomics in {
 }
 // OpenCL v1.1 s6.11.1, v1.2 s6.12.11 - Atomic Functions
 foreach AS = [GlobalAS, LocalAS] in {
+  def : Builtin<"atomic_xchg", [Float, PointerType, AS>, 
Float]>;
   foreach Type = [Int, UInt] in {
 foreach name = ["atomic_add", "atomic_sub", "atomic_xchg",
 "atomic_min", "atomic_max", "atomic_and",



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


[PATCH] D95984: [CodeGen] Fix codegen for __attribute__((swiftasynccall)).

2021-03-11 Thread Varun Gandhi via Phabricator via cfe-commits
varungandhi-apple updated this revision to Diff 329889.
varungandhi-apple added a comment.

Use musttail call instead of tail call.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95984

Files:
  clang/lib/CodeGen/CGCall.cpp
  clang/lib/CodeGen/CGStmt.cpp
  clang/test/CodeGen/64bit-swiftcall.c
  clang/test/CodeGen/arm-swiftcall.c
  clang/test/CodeGen/swift-async-call-conv.c
  clang/test/CodeGen/swift-call-conv.c

Index: clang/test/CodeGen/swift-call-conv.c
===
--- clang/test/CodeGen/swift-call-conv.c
+++ clang/test/CodeGen/swift-call-conv.c
@@ -6,3 +6,5 @@
 void __attribute__((__swiftcall__)) f(void) {}
 // CHECK-LABEL: define dso_local swiftcc void @f()
 
+void __attribute__((__swiftasynccall__)) f_async(void) {}
+// CHECK-LABEL: define dso_local swifttailcc void @f_async()
Index: clang/test/CodeGen/swift-async-call-conv.c
===
--- /dev/null
+++ clang/test/CodeGen/swift-async-call-conv.c
@@ -0,0 +1,138 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -target-cpu core2 -emit-llvm -o - %s | FileCheck %s
+// RUN: %clang_cc1 -triple arm64-apple-ios9 -target-cpu cyclone -emit-llvm -o - %s | FileCheck %s
+// RUN: %clang_cc1 -triple armv7-apple-darwin9 -emit-llvm -o - %s | FileCheck %s
+// RUN: %clang_cc1 -triple armv7s-apple-ios9 -emit-llvm -o - %s | FileCheck %s
+// RUN: %clang_cc1 -triple armv7k-apple-ios9 -emit-llvm -o - %s | FileCheck %s
+
+// RUN: %clang_cc1 -x c++ -triple x86_64-apple-darwin10 -target-cpu core2 -emit-llvm -o - %s | FileCheck %s
+// RUN: %clang_cc1 -x c++ -triple arm64-apple-ios9 -target-cpu cyclone -emit-llvm -o - %s | FileCheck %s
+// RUN: %clang_cc1 -x c++ -triple armv7-apple-darwin9 -emit-llvm -o - %s | FileCheck %s
+// RUN: %clang_cc1 -x c++ -triple armv7s-apple-ios9 -emit-llvm -o - %s | FileCheck %s
+// RUN: %clang_cc1 -x c++ -triple armv7k-apple-ios9 -emit-llvm -o - %s | FileCheck %s
+
+// Test tail call behavior when a swiftasynccall function is called
+// from another swiftasynccall function.
+
+#define SWIFTCALL __attribute__((swiftcall))
+#define SWIFTASYNCCALL __attribute__((swiftasynccall))
+#define ASYNC_CONTEXT __attribute__((swift_async_context))
+
+// CHECK-LABEL: swifttailcc void {{.*}}async_leaf1{{.*}}(i8* swiftasync
+SWIFTASYNCCALL void async_leaf1(char * ASYNC_CONTEXT ctx) {
+  *ctx += 1;
+}
+
+// CHECK-LABEL: swifttailcc void {{.*}}async_leaf2{{.*}}(i8* swiftasync
+SWIFTASYNCCALL void async_leaf2(char * ASYNC_CONTEXT ctx) {
+  *ctx += 2;
+}
+
+#if __cplusplus
+  #define MYBOOL bool
+#else
+  #define MYBOOL _Bool
+#endif
+
+// CHECK-LABEL: swifttailcc void {{.*}}async_branch{{.*}}i8* swiftasync
+// CHECK: musttail call swifttailcc void @{{.*}}async_leaf1
+// CHECK-NEXT: ret void
+// CHECK: musttail call swifttailcc void @{{.*}}async_leaf2
+// CHECK-NEXT: ret void
+SWIFTASYNCCALL void async_branch(MYBOOL b, char * ASYNC_CONTEXT ctx) {
+  if (b) {
+return async_leaf1(ctx);
+  } else {
+return async_leaf2(ctx);
+  }
+}
+
+// CHECK-LABEL: swifttailcc void {{.*}}async_not_all_tail
+// CHECK-NOT:  musttail call swifttailcc void @{{.*}}async_leaf1
+// CHECK:  call swifttailcc void @{{.*}}async_leaf1
+// CHECK-NOT:  ret void
+// CHECK:  musttail call swifttailcc void @{{.*}}async_leaf2
+// CHECK-NEXT: ret void
+SWIFTASYNCCALL void async_not_all_tail(char * ASYNC_CONTEXT ctx) {
+  async_leaf1(ctx);
+  return async_leaf2(ctx);
+}
+
+// CHECK-LABEL: swifttailcc void {{.*}}async_loop
+// CHECK: musttail call swifttailcc void @{{.*}}async_leaf1
+// CHECK-NEXT: ret void
+// CHECK: musttail call swifttailcc void @{{.*}}async_leaf2
+// CHECK-NEXT: ret void
+// CHECK: musttail call swifttailcc void @{{.*}}async_loop
+// CHECK-NEXT: ret void
+SWIFTASYNCCALL void async_loop(unsigned u, char * ASYNC_CONTEXT ctx) {
+  if (u == 0) {
+return async_leaf1(ctx);
+  } else if (u == 1) {
+return async_leaf2(ctx);
+  }
+  return async_loop(u - 2, ctx);
+}
+
+// Forward-declaration + mutual recursion is okay.
+
+SWIFTASYNCCALL void async_mutual_loop2(unsigned u, char * ASYNC_CONTEXT ctx);
+
+// CHECK-LABEL: swifttailcc void {{.*}}async_mutual_loop1
+// CHECK: musttail call swifttailcc void @{{.*}}async_leaf1
+// CHECK-NEXT: ret void
+// CHECK: musttail call swifttailcc void @{{.*}}async_leaf2
+// CHECK-NEXT: ret void
+// There is some bugginess around FileCheck's greediness/matching,
+// so skipping the check for async_mutual_loop2 here.
+SWIFTASYNCCALL void async_mutual_loop1(unsigned u, char * ASYNC_CONTEXT ctx) {
+  if (u == 0) {
+return async_leaf1(ctx);
+  } else if (u == 1) {
+return async_leaf2(ctx);
+  }
+  return async_mutual_loop2(u - 2, ctx);
+}
+
+// CHECK-LABEL: swifttailcc void {{.*}}async_mutual_loop2
+// CHECK: musttail call swifttailcc void @{{.*}}async_leaf1
+// CHECK-NEXT: ret void
+// CHECK: musttail call swifttailcc void @{{.*}}async_

[PATCH] D98253: [clang][ARM] Refactor ComputeLLVMTriple code for ARM

2021-03-11 Thread David Spickett via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG87358dba8182: [clang][ARM] Refactor ComputeLLVMTriple code 
for ARM (authored by DavidSpickett).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98253

Files:
  clang/lib/Driver/ToolChain.cpp
  clang/lib/Driver/ToolChains/Arch/ARM.cpp
  clang/lib/Driver/ToolChains/Arch/ARM.h

Index: clang/lib/Driver/ToolChains/Arch/ARM.h
===
--- clang/lib/Driver/ToolChains/Arch/ARM.h
+++ clang/lib/Driver/ToolChains/Arch/ARM.h
@@ -51,7 +51,11 @@
 FloatABI getARMFloatABI(const ToolChain &TC, const llvm::opt::ArgList &Args);
 FloatABI getARMFloatABI(const Driver &D, const llvm::Triple &Triple,
 const llvm::opt::ArgList &Args);
+void setFloatABIInTriple(const Driver &D, const llvm::opt::ArgList &Args,
+ llvm::Triple &triple);
 ReadTPMode getReadTPMode(const Driver &D, const llvm::opt::ArgList &Args);
+void setArchNameInTriple(const Driver &D, const llvm::opt::ArgList &Args,
+ types::ID InputType, llvm::Triple &Triple);
 
 bool useAAPCSForMachO(const llvm::Triple &T);
 void getARMArchCPUFromArgs(const llvm::opt::ArgList &Args,
Index: clang/lib/Driver/ToolChains/Arch/ARM.cpp
===
--- clang/lib/Driver/ToolChains/Arch/ARM.cpp
+++ clang/lib/Driver/ToolChains/Arch/ARM.cpp
@@ -166,6 +166,132 @@
   return ReadTPMode::Soft;
 }
 
+void arm::setArchNameInTriple(const Driver &D, const ArgList &Args,
+  types::ID InputType, llvm::Triple &Triple) {
+  StringRef MCPU, MArch;
+  if (const Arg *A = Args.getLastArg(options::OPT_mcpu_EQ))
+MCPU = A->getValue();
+  if (const Arg *A = Args.getLastArg(options::OPT_march_EQ))
+MArch = A->getValue();
+
+  std::string CPU = Triple.isOSBinFormatMachO()
+? tools::arm::getARMCPUForMArch(MArch, Triple).str()
+: tools::arm::getARMTargetCPU(MCPU, MArch, Triple);
+  StringRef Suffix = tools::arm::getLLVMArchSuffixForARM(CPU, MArch, Triple);
+
+  bool IsBigEndian = Triple.getArch() == llvm::Triple::armeb ||
+ Triple.getArch() == llvm::Triple::thumbeb;
+  // Handle pseudo-target flags '-mlittle-endian'/'-EL' and
+  // '-mbig-endian'/'-EB'.
+  if (Arg *A = Args.getLastArg(options::OPT_mlittle_endian,
+   options::OPT_mbig_endian)) {
+IsBigEndian = !A->getOption().matches(options::OPT_mlittle_endian);
+  }
+  std::string ArchName = IsBigEndian ? "armeb" : "arm";
+
+  // FIXME: Thumb should just be another -target-feaure, not in the triple.
+  bool IsMProfile =
+  llvm::ARM::parseArchProfile(Suffix) == llvm::ARM::ProfileKind::M;
+  bool ThumbDefault = IsMProfile ||
+  // Thumb2 is the default for V7 on Darwin.
+  (llvm::ARM::parseArchVersion(Suffix) == 7 &&
+   Triple.isOSBinFormatMachO()) ||
+  // FIXME: this is invalid for WindowsCE
+  Triple.isOSWindows();
+
+  // Check if ARM ISA was explicitly selected (using -mno-thumb or -marm) for
+  // M-Class CPUs/architecture variants, which is not supported.
+  bool ARMModeRequested =
+  !Args.hasFlag(options::OPT_mthumb, options::OPT_mno_thumb, ThumbDefault);
+  if (IsMProfile && ARMModeRequested) {
+if (MCPU.size())
+  D.Diag(diag::err_cpu_unsupported_isa) << CPU << "ARM";
+else
+  D.Diag(diag::err_arch_unsupported_isa)
+  << tools::arm::getARMArch(MArch, Triple) << "ARM";
+  }
+
+  // Check to see if an explicit choice to use thumb has been made via
+  // -mthumb. For assembler files we must check for -mthumb in the options
+  // passed to the assembler via -Wa or -Xassembler.
+  bool IsThumb = false;
+  if (InputType != types::TY_PP_Asm)
+IsThumb =
+Args.hasFlag(options::OPT_mthumb, options::OPT_mno_thumb, ThumbDefault);
+  else {
+// Ideally we would check for these flags in
+// CollectArgsForIntegratedAssembler but we can't change the ArchName at
+// that point.
+llvm::StringRef WaMArch, WaMCPU;
+for (const auto *A :
+ Args.filtered(options::OPT_Wa_COMMA, options::OPT_Xassembler)) {
+  for (StringRef Value : A->getValues()) {
+// There is no assembler equivalent of -mno-thumb, -marm, or -mno-arm.
+if (Value == "-mthumb")
+  IsThumb = true;
+else if (Value.startswith("-march="))
+  WaMArch = Value.substr(7);
+else if (Value.startswith("-mcpu="))
+  WaMCPU = Value.substr(6);
+  }
+}
+
+if (WaMCPU.size() || WaMArch.size()) {
+  // The way this works means that we prefer -Wa,-mcpu's architecture
+  // over -Wa,-march. Which matches the compiler behaviour.
+  Suffix = tools::arm::getLLVMArchSuffixForARM(WaMCPU, Wa

[clang] 87358db - [clang][ARM] Refactor ComputeLLVMTriple code for ARM

2021-03-11 Thread David Spickett via cfe-commits

Author: David Spickett
Date: 2021-03-11T10:25:16Z
New Revision: 87358dba8182b4ee2d9eedabb8afb319b59a322b

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

LOG: [clang][ARM] Refactor ComputeLLVMTriple code for ARM

This moves code that sets the architecture name
and Float ABI into two new functions in
ToolChains/Arch/ARM.cpp. Greatly simplifying ComputeLLVMTriple.

Some light refactoring in setArchNameInTriple to
move local variables closer to their first use.

Reviewed By: ostannard

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

Added: 


Modified: 
clang/lib/Driver/ToolChain.cpp
clang/lib/Driver/ToolChains/Arch/ARM.cpp
clang/lib/Driver/ToolChains/Arch/ARM.h

Removed: 




diff  --git a/clang/lib/Driver/ToolChain.cpp b/clang/lib/Driver/ToolChain.cpp
index e6a6fe2cb062..217ba56c3351 100644
--- a/clang/lib/Driver/ToolChain.cpp
+++ b/clang/lib/Driver/ToolChain.cpp
@@ -735,129 +735,9 @@ std::string ToolChain::ComputeLLVMTriple(const ArgList 
&Args,
   case llvm::Triple::armeb:
   case llvm::Triple::thumb:
   case llvm::Triple::thumbeb: {
-// FIXME: Factor into subclasses.
 llvm::Triple Triple = getTriple();
-bool IsBigEndian = getTriple().getArch() == llvm::Triple::armeb ||
-   getTriple().getArch() == llvm::Triple::thumbeb;
-
-// Handle pseudo-target flags '-mlittle-endian'/'-EL' and
-// '-mbig-endian'/'-EB'.
-if (Arg *A = Args.getLastArg(options::OPT_mlittle_endian,
- options::OPT_mbig_endian)) {
-  IsBigEndian = !A->getOption().matches(options::OPT_mlittle_endian);
-}
-
-// Thumb2 is the default for V7 on Darwin.
-//
-// FIXME: Thumb should just be another -target-feaure, not in the triple.
-StringRef MCPU, MArch;
-if (const Arg *A = Args.getLastArg(options::OPT_mcpu_EQ))
-  MCPU = A->getValue();
-if (const Arg *A = Args.getLastArg(options::OPT_march_EQ))
-  MArch = A->getValue();
-std::string CPU =
-Triple.isOSBinFormatMachO()
-? tools::arm::getARMCPUForMArch(MArch, Triple).str()
-: tools::arm::getARMTargetCPU(MCPU, MArch, Triple);
-StringRef Suffix =
-  tools::arm::getLLVMArchSuffixForARM(CPU, MArch, Triple);
-bool IsMProfile = ARM::parseArchProfile(Suffix) == ARM::ProfileKind::M;
-bool ThumbDefault = IsMProfile || (ARM::parseArchVersion(Suffix) == 7 &&
-   getTriple().isOSBinFormatMachO());
-// FIXME: this is invalid for WindowsCE
-if (getTriple().isOSWindows())
-  ThumbDefault = true;
-std::string ArchName;
-if (IsBigEndian)
-  ArchName = "armeb";
-else
-  ArchName = "arm";
-
-// Check if ARM ISA was explicitly selected (using -mno-thumb or -marm) for
-// M-Class CPUs/architecture variants, which is not supported.
-bool ARMModeRequested = !Args.hasFlag(options::OPT_mthumb,
-  options::OPT_mno_thumb, 
ThumbDefault);
-if (IsMProfile && ARMModeRequested) {
-  if (!MCPU.empty())
-getDriver().Diag(diag::err_cpu_unsupported_isa) << CPU << "ARM";
-   else
-getDriver().Diag(diag::err_arch_unsupported_isa)
-  << tools::arm::getARMArch(MArch, getTriple()) << "ARM";
-}
-
-// Check to see if an explicit choice to use thumb has been made via
-// -mthumb. For assembler files we must check for -mthumb in the options
-// passed to the assembler via -Wa or -Xassembler.
-bool IsThumb = false;
-if (InputType != types::TY_PP_Asm)
-  IsThumb = Args.hasFlag(options::OPT_mthumb, options::OPT_mno_thumb,
-  ThumbDefault);
-else {
-  // Ideally we would check for these flags in
-  // CollectArgsForIntegratedAssembler but we can't change the ArchName at
-  // that point.
-  llvm::StringRef WaMArch, WaMCPU;
-  for (const auto *A :
-   Args.filtered(options::OPT_Wa_COMMA, options::OPT_Xassembler)) {
-for (StringRef Value : A->getValues()) {
-  // There is no assembler equivalent of -mno-thumb, -marm, or 
-mno-arm.
-  if (Value == "-mthumb")
-IsThumb = true;
-  else if (Value.startswith("-march="))
-WaMArch = Value.substr(7);
-  else if (Value.startswith("-mcpu="))
-WaMCPU = Value.substr(6);
-}
-  }
-
-  if (WaMCPU.size() || WaMArch.size()) {
-// The way this works means that we prefer -Wa,-mcpu's architecture
-// over -Wa,-march. Which matches the compiler behaviour.
-Suffix = tools::arm::getLLVMArchSuffixForARM(WaMCPU, WaMArch, Triple);
-  }
-}
-// Assembly files should start in ARM mode, unless arch is M-profile, or
-// -mthumb has been passed explic

[clang] d53866f - Fix MSVC "result of 32-bit shift implicitly converted to 64 bits" warnings. NFCI.

2021-03-11 Thread Simon Pilgrim via cfe-commits

Author: Simon Pilgrim
Date: 2021-03-11T10:29:14Z
New Revision: d53866ff473d4023b0e3db68a1b91cfa59aacbb9

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

LOG: Fix MSVC "result of 32-bit shift implicitly converted to 64 bits" 
warnings. NFCI.

Added: 


Modified: 
clang/utils/TableGen/RISCVVEmitter.cpp

Removed: 




diff  --git a/clang/utils/TableGen/RISCVVEmitter.cpp 
b/clang/utils/TableGen/RISCVVEmitter.cpp
index 49574e45d5bd..ba96396c780d 100644
--- a/clang/utils/TableGen/RISCVVEmitter.cpp
+++ b/clang/utils/TableGen/RISCVVEmitter.cpp
@@ -244,8 +244,8 @@ LMULType::LMULType(int NewLog2LMUL) {
 
 std::string LMULType::str() const {
   if (Log2LMUL < 0)
-return "mf" + utostr(1 << (-Log2LMUL));
-  return "m" + utostr(1 << Log2LMUL);
+return "mf" + utostr(1ULL << (-Log2LMUL));
+  return "m" + utostr(1ULL << Log2LMUL);
 }
 
 VScaleVal LMULType::getScale(unsigned ElementBitwidth) const {



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


[PATCH] D96033: [clang-repl] Land initial infrastructure for incremental parsing

2021-03-11 Thread Vassil Vassilev via Phabricator via cfe-commits
v.g.vassilev updated this revision to Diff 329894.
v.g.vassilev added a comment.

Address most of the formatting suggestions.


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

https://reviews.llvm.org/D96033

Files:
  clang/include/clang/CodeGen/CodeGenAction.h
  clang/include/clang/Frontend/FrontendAction.h
  clang/include/clang/Interpreter/Interpreter.h
  clang/include/clang/Interpreter/Transaction.h
  clang/lib/CMakeLists.txt
  clang/lib/CodeGen/CodeGenAction.cpp
  clang/lib/Frontend/FrontendAction.cpp
  clang/lib/Interpreter/CMakeLists.txt
  clang/lib/Interpreter/IncrementalExecutor.cpp
  clang/lib/Interpreter/IncrementalExecutor.h
  clang/lib/Interpreter/IncrementalParser.cpp
  clang/lib/Interpreter/IncrementalParser.h
  clang/lib/Interpreter/Interpreter.cpp
  clang/test/CMakeLists.txt
  clang/test/Interpreter/execute.c
  clang/test/Interpreter/sanity.c
  clang/test/lit.cfg.py
  clang/tools/CMakeLists.txt
  clang/tools/clang-repl/CMakeLists.txt
  clang/tools/clang-repl/ClangRepl.cpp
  clang/unittests/CMakeLists.txt
  clang/unittests/CodeGen/CMakeLists.txt
  clang/unittests/CodeGen/IncrementalProcessingTest.cpp
  clang/unittests/Interpreter/CMakeLists.txt
  clang/unittests/Interpreter/IncrementalProcessingTest.cpp
  clang/unittests/Interpreter/InterpreterTest.cpp

Index: clang/unittests/Interpreter/InterpreterTest.cpp
===
--- /dev/null
+++ clang/unittests/Interpreter/InterpreterTest.cpp
@@ -0,0 +1,91 @@
+//===- unittests/Interpreter/InterpreterTest.cpp --- Interpreter tests ===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+//
+// Unit tests for Clang's Interpreter library.
+//
+//===--===//
+
+#include "clang/Interpreter/Interpreter.h"
+
+#include "clang/AST/Decl.h"
+#include "clang/AST/DeclGroup.h"
+#include "clang/Frontend/CompilerInstance.h"
+
+#include "llvm/ADT/ArrayRef.h"
+
+#include "gtest/gtest.h"
+
+using namespace clang;
+
+namespace {
+
+static std::unique_ptr createInterpreter() {
+  std::vector ClangArgs = {"-Xclang", "-emit-llvm-only"};
+  auto CI = cantFail(clang::IncrementalCompilerBuilder::create(ClangArgs));
+  return cantFail(clang::Interpreter::create(std::move(CI)));
+}
+
+TEST(InterpreterTest, Sanity) {
+  std::unique_ptr Interp = createInterpreter();
+  Transaction &R1(cantFail(Interp->Parse("void g(); void g() {}")));
+  EXPECT_EQ(2U, R1.Decls.size());
+
+  Transaction &R2(cantFail(Interp->Parse("int i;")));
+  EXPECT_EQ(1U, R2.Decls.size());
+}
+
+static std::string DeclToString(DeclGroupRef DGR) {
+  return llvm::cast(DGR.getSingleDecl())->getQualifiedNameAsString();
+}
+
+TEST(InterpreterTest, IncrementalInputTopLevelDecls) {
+  std::unique_ptr Interp = createInterpreter();
+  auto R1OrErr = Interp->Parse("int var1 = 42; int f() { return var1; }");
+  // gtest doesn't expand into explicit bool conversions.
+  EXPECT_TRUE(!!R1OrErr);
+  auto R1 = R1OrErr->Decls;
+  EXPECT_EQ(2U, R1.size());
+  EXPECT_EQ("var1", DeclToString(R1[0]));
+  EXPECT_EQ("f", DeclToString(R1[1]));
+
+  auto R2OrErr = Interp->Parse("int var2 = f();");
+  EXPECT_TRUE(!!R2OrErr);
+  auto R2 = R2OrErr->Decls;
+  EXPECT_EQ(1U, R2.size());
+  EXPECT_EQ("var2", DeclToString(R2[0]));
+}
+
+TEST(InterpreterTest, Errors) {
+  std::unique_ptr Interp = createInterpreter();
+  auto Err = Interp->Parse("intentional_error v1 = 42; ").takeError();
+  EXPECT_EQ("Parsing failed.", llvm::toString(std::move(Err)));
+
+  EXPECT_DEATH((void)Interp->Parse("int var1 = 42;"), "");
+}
+
+// Here we test whether the user can mix declarations and statements. The
+// interpreter should be smart enough to recognize the declarations from the
+// statements and wrap the latter into a declaration, producing valid code.
+TEST(InterpreterTest, DeclsAndStatements) {
+  std::unique_ptr Interp = createInterpreter();
+  auto R1OrErr = Interp->Parse(
+  "int var1 = 42; extern \"C\" int printf(const char*, ...);");
+  // gtest doesn't expand into explicit bool conversions.
+  EXPECT_TRUE(!!R1OrErr);
+
+  auto R1 = R1OrErr->Decls;
+  EXPECT_EQ(2U, R1.size());
+
+  // FIXME: Add support for wrapping and running statements.
+  auto R2OrErr = Interp->Parse("var1++; printf(\"var1 value %d\\n\", var1);");
+  EXPECT_FALSE(!!R2OrErr);
+  auto Err = R2OrErr.takeError();
+  EXPECT_EQ("Parsing failed.", llvm::toString(std::move(Err)));
+}
+
+} // end anonymous namespace
Index: clang/unittests/Interpreter/IncrementalProcessingTest.cpp
===
--- /dev/null
+++ clang/unittests/Interpreter/IncrementalProcessingTest.cpp
@@ -0,0 +1,82 @@
+//=== unittests/CodeGen/IncrementalProcessingTest.cpp - Incr

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

2021-03-11 Thread Kirill Bobyrev via Phabricator via cfe-commits
kbobyrev created this revision.
kbobyrev added a reviewer: kadircet.
Herald added subscribers: usaxena95, arphaman, mgorny.
kbobyrev requested review of this revision.
Herald added subscribers: llvm-commits, cfe-commits, MaskRay, ilya-biryukov.
Herald added projects: clang, LLVM.

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

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


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D98404

Files:
  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
@@ -18,10 +18,14 @@
 
   # gRPC CMake CONFIG gives the libraries slightly odd names, make them match
   # the conventional system-installed names.
-  set_target_properties(protobuf::libprotobuf PROPERTIES IMPORTED_GLOBAL TRUE)
-  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_target_properties(protobuf::libprotobuf PROPERTIES IMPORTED_GLOBAL TRUE)
+  add_library(protobuf ALIAS protobuf::libprotobuf)
 
   set(GRPC_CPP_PLUGIN $)
   set(PROTOC ${Protobuf_PROTOC_EXECUTABLE})
@@ -71,6 +75,11 @@
   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)
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
@@ -35,6 +35,10 @@
 #include 
 #include 
 
+#ifdef ENABLE_GRPC_REFLECTION
+#include 
+#endif
+
 namespace clang {
 namespace clangd {
 namespace remote {
@@ -313,6 +317,9 @@
   RemoteIndexServer Service(Index, IndexRoot);
 
   grpc::EnableDefaultHealthCheckService(true);
+#ifdef 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
@@ -9,6 +9,11 @@
   RemoteIndexServiceProto
   )
 
+if (ENABLE_GRPC_REFLECTION)
+  set(REFLECTION_LIBRARY grpc++_reflection)
+  add_definitions(-DENABLE_GRPC_REFLECTION)
+endif()
+
 target_link_libraries(clangd-index-server
   PRIVATE
   clangDaemon
@@ -17,4 +22,6 @@
   RemoteIndexProto
   RemoteIndexServiceProto
   clangdRemoteMarshalling
+
+  ${REFLECTION_LIBRARY}
   )


Index: llvm/cmake/modules/FindGRPC.cmake
===
--- llvm/cmake/modules/FindGRPC.cmake
+++ llvm/cmake/modules/FindGRPC.cmake
@@ -18,10 +18,14 @@
 
   # gRPC CMake CONFIG gives the libraries slightly odd names, make them match
   # the conventional system-installed names.
-  set_target_properties(protobuf::libprotobuf PROPERTIES IMPORTED_GLOBAL TRUE)
-  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_target_properties(protobuf::libprotobuf PROPERTIES IMPORTED_GLOBAL TRUE)
+  add_library(protobuf ALIAS protobuf::libprotobuf)
 
   set(GRPC_CPP_PLUGIN $)
   set(PROTOC ${Protobuf_PROTOC_EXECUTABLE})
@@ -71,6 +75,11 @@
   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 REQ

[PATCH] D98341: [analyzer][solver] Prevent infeasible states (PR49490)

2021-03-11 Thread Balázs Benics via Phabricator via cfe-commits
steakhal accepted this revision.
steakhal added a comment.

Looks good btw.




Comment at: clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp:1400-1406
+  LLVM_ATTRIBUTE_UNUSED inline bool areFeasible(ConstraintRangeTy Constraints) 
{
+return llvm::none_of(
+Constraints,
+[](const std::pair ClassConstraint) {
+  return ClassConstraint.second.isEmpty();
+});
+  }

`inline` is unnecessary. All member functions are inline by default.
I would take the parameter by `const ref` in the lambda.
Why did you mark it `LLVM_ATTRIBUTE_UNUSED `? `LLVM_NODISCARD` would be 
probably a better choice.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98341

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


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

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



Comment at: clang-tools-extra/clangd/index/remote/server/CMakeLists.txt:12
 
+if (ENABLE_GRPC_REFLECTION)
+  set(REFLECTION_LIBRARY grpc++_reflection)

can we move this piece into FindGRPC.cmake instead?



Comment at: llvm/cmake/modules/FindGRPC.cmake:21
   # the conventional system-installed names.
-  set_target_properties(protobuf::libprotobuf PROPERTIES IMPORTED_GLOBAL TRUE)
-  add_library(protobuf ALIAS protobuf::libprotobuf)

nit: is this change needed?


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] D98341: [analyzer][solver] Prevent infeasible states (PR49490)

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

Fix review comments


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98341

Files:
  clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
  clang/test/Analysis/PR49490.cpp


Index: clang/test/Analysis/PR49490.cpp
===
--- /dev/null
+++ clang/test/Analysis/PR49490.cpp
@@ -0,0 +1,31 @@
+// RUN: %clang_analyze_cc1 -w -analyzer-checker=core -verify %s
+
+// expected-no-diagnostics
+
+struct toggle {
+  bool value;
+};
+
+toggle global_toggle;
+toggle get_global_toggle() { return global_toggle; }
+
+int *ints;
+int oob_access();
+
+bool compare(toggle one, bool other) {
+  if (one.value != other)
+return true;
+
+  if (one.value)
+oob_access();
+  return true;
+}
+
+bool coin();
+
+void bar() {
+  bool left = coin();
+  bool right = coin();
+  for (;;)
+compare(get_global_toggle(), left) && compare(get_global_toggle(), right);
+}
Index: clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
===
--- clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
+++ clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
@@ -19,6 +19,8 @@
 #include "clang/StaticAnalyzer/Core/PathSensitive/SValVisitor.h"
 #include "llvm/ADT/FoldingSet.h"
 #include "llvm/ADT/ImmutableSet.h"
+#include "llvm/ADT/STLExtras.h"
+#include "llvm/Support/Compiler.h"
 #include "llvm/Support/raw_ostream.h"
 
 using namespace clang;
@@ -1395,12 +1397,23 @@
 return EquivalenceClass::merge(getBasicVals(), F, State, LHS, RHS);
   }
 
-  LLVM_NODISCARD inline ProgramStateRef setConstraint(ProgramStateRef State,
-  EquivalenceClass Class,
-  RangeSet Constraint) {
+  LLVM_NODISCARD LLVM_ATTRIBUTE_UNUSED bool
+  areFeasible(ConstraintRangeTy Constraints) {
+return llvm::none_of(
+Constraints,
+[](const std::pair &ClassConstraint) {
+  return ClassConstraint.second.isEmpty();
+});
+  }
+
+  LLVM_NODISCARD ProgramStateRef setConstraint(ProgramStateRef State,
+   EquivalenceClass Class,
+   RangeSet Constraint) {
 ConstraintRangeTy Constraints = State->get();
 ConstraintRangeTy::Factory &CF = State->get_context();
 
+assert(!Constraint.isEmpty() && "New constraint should not be empty");
+
 // Add new constraint.
 Constraints = CF.add(Constraints, Class, Constraint);
 
@@ -1413,9 +1426,18 @@
   for (EquivalenceClass DisequalClass : Class.getDisequalClasses(State)) {
 RangeSet UpdatedConstraint =
 getRange(State, DisequalClass).Delete(getBasicVals(), F, *Point);
+
+// If we end up with at least one of the disequal classes to be
+// constrainted with an empty range-set, the state is infeasible.
+if (UpdatedConstraint.isEmpty())
+  return nullptr;
+
 Constraints = CF.add(Constraints, DisequalClass, UpdatedConstraint);
   }
 
+assert(areFeasible(Constraints) && "Constraint manager shouldn't produce "
+   "a state with infeasible constraints");
+
 return State->set(Constraints);
   }
 


Index: clang/test/Analysis/PR49490.cpp
===
--- /dev/null
+++ clang/test/Analysis/PR49490.cpp
@@ -0,0 +1,31 @@
+// RUN: %clang_analyze_cc1 -w -analyzer-checker=core -verify %s
+
+// expected-no-diagnostics
+
+struct toggle {
+  bool value;
+};
+
+toggle global_toggle;
+toggle get_global_toggle() { return global_toggle; }
+
+int *ints;
+int oob_access();
+
+bool compare(toggle one, bool other) {
+  if (one.value != other)
+return true;
+
+  if (one.value)
+oob_access();
+  return true;
+}
+
+bool coin();
+
+void bar() {
+  bool left = coin();
+  bool right = coin();
+  for (;;)
+compare(get_global_toggle(), left) && compare(get_global_toggle(), right);
+}
Index: clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
===
--- clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
+++ clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
@@ -19,6 +19,8 @@
 #include "clang/StaticAnalyzer/Core/PathSensitive/SValVisitor.h"
 #include "llvm/ADT/FoldingSet.h"
 #include "llvm/ADT/ImmutableSet.h"
+#include "llvm/ADT/STLExtras.h"
+#include "llvm/Support/Compiler.h"
 #include "llvm/Support/raw_ostream.h"
 
 using namespace clang;
@@ -1395,12 +1397,23 @@
 return EquivalenceClass::merge(getBasicVals(), F, State, LHS, RHS);
   }
 
-  LLVM_NODISCARD inline ProgramStateRef setConstraint(ProgramStateRef State,
-  EquivalenceClass Class,
-

[PATCH] D98341: [analyzer][solver] Prevent infeasible states (PR49490)

2021-03-11 Thread Valeriy Savchenko via Phabricator via cfe-commits
vsavchenko marked an inline comment as done.
vsavchenko added inline comments.



Comment at: clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp:1400-1406
+  LLVM_ATTRIBUTE_UNUSED inline bool areFeasible(ConstraintRangeTy Constraints) 
{
+return llvm::none_of(
+Constraints,
+[](const std::pair ClassConstraint) {
+  return ClassConstraint.second.isEmpty();
+});
+  }

steakhal wrote:
> `inline` is unnecessary. All member functions are inline by default.
> I would take the parameter by `const ref` in the lambda.
> Why did you mark it `LLVM_ATTRIBUTE_UNUSED `? `LLVM_NODISCARD` would be 
> probably a better choice.
Fair point about `inline`.
`LLVM_NODISCARD` doesn't exclude `LLVM_ATTRIBUTE_UNUSED`.
It should be marked that way for Release builds when compiler might figure out 
that this class is local to only this TU, and this function is not used here 
anywhere.  You can see in the comment for this macro that this is actually the 
main motivation for this macro to be used.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98341

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


[PATCH] D98341: [analyzer][solver] Prevent infeasible states (PR49490)

2021-03-11 Thread Valeriy Savchenko via Phabricator via cfe-commits
vsavchenko updated this revision to Diff 329903.
vsavchenko marked an inline comment as done.
vsavchenko added a comment.

Make `areFeasible` function static


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98341

Files:
  clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
  clang/test/Analysis/PR49490.cpp


Index: clang/test/Analysis/PR49490.cpp
===
--- /dev/null
+++ clang/test/Analysis/PR49490.cpp
@@ -0,0 +1,31 @@
+// RUN: %clang_analyze_cc1 -w -analyzer-checker=core -verify %s
+
+// expected-no-diagnostics
+
+struct toggle {
+  bool value;
+};
+
+toggle global_toggle;
+toggle get_global_toggle() { return global_toggle; }
+
+int *ints;
+int oob_access();
+
+bool compare(toggle one, bool other) {
+  if (one.value != other)
+return true;
+
+  if (one.value)
+oob_access();
+  return true;
+}
+
+bool coin();
+
+void bar() {
+  bool left = coin();
+  bool right = coin();
+  for (;;)
+compare(get_global_toggle(), left) && compare(get_global_toggle(), right);
+}
Index: clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
===
--- clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
+++ clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
@@ -19,6 +19,8 @@
 #include "clang/StaticAnalyzer/Core/PathSensitive/SValVisitor.h"
 #include "llvm/ADT/FoldingSet.h"
 #include "llvm/ADT/ImmutableSet.h"
+#include "llvm/ADT/STLExtras.h"
+#include "llvm/Support/Compiler.h"
 #include "llvm/Support/raw_ostream.h"
 
 using namespace clang;
@@ -1395,12 +1397,23 @@
 return EquivalenceClass::merge(getBasicVals(), F, State, LHS, RHS);
   }
 
-  LLVM_NODISCARD inline ProgramStateRef setConstraint(ProgramStateRef State,
-  EquivalenceClass Class,
-  RangeSet Constraint) {
+  LLVM_NODISCARD LLVM_ATTRIBUTE_UNUSED static bool
+  areFeasible(ConstraintRangeTy Constraints) {
+return llvm::none_of(
+Constraints,
+[](const std::pair &ClassConstraint) {
+  return ClassConstraint.second.isEmpty();
+});
+  }
+
+  LLVM_NODISCARD ProgramStateRef setConstraint(ProgramStateRef State,
+   EquivalenceClass Class,
+   RangeSet Constraint) {
 ConstraintRangeTy Constraints = State->get();
 ConstraintRangeTy::Factory &CF = State->get_context();
 
+assert(!Constraint.isEmpty() && "New constraint should not be empty");
+
 // Add new constraint.
 Constraints = CF.add(Constraints, Class, Constraint);
 
@@ -1413,9 +1426,18 @@
   for (EquivalenceClass DisequalClass : Class.getDisequalClasses(State)) {
 RangeSet UpdatedConstraint =
 getRange(State, DisequalClass).Delete(getBasicVals(), F, *Point);
+
+// If we end up with at least one of the disequal classes to be
+// constrainted with an empty range-set, the state is infeasible.
+if (UpdatedConstraint.isEmpty())
+  return nullptr;
+
 Constraints = CF.add(Constraints, DisequalClass, UpdatedConstraint);
   }
 
+assert(areFeasible(Constraints) && "Constraint manager shouldn't produce "
+   "a state with infeasible constraints");
+
 return State->set(Constraints);
   }
 


Index: clang/test/Analysis/PR49490.cpp
===
--- /dev/null
+++ clang/test/Analysis/PR49490.cpp
@@ -0,0 +1,31 @@
+// RUN: %clang_analyze_cc1 -w -analyzer-checker=core -verify %s
+
+// expected-no-diagnostics
+
+struct toggle {
+  bool value;
+};
+
+toggle global_toggle;
+toggle get_global_toggle() { return global_toggle; }
+
+int *ints;
+int oob_access();
+
+bool compare(toggle one, bool other) {
+  if (one.value != other)
+return true;
+
+  if (one.value)
+oob_access();
+  return true;
+}
+
+bool coin();
+
+void bar() {
+  bool left = coin();
+  bool right = coin();
+  for (;;)
+compare(get_global_toggle(), left) && compare(get_global_toggle(), right);
+}
Index: clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
===
--- clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
+++ clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
@@ -19,6 +19,8 @@
 #include "clang/StaticAnalyzer/Core/PathSensitive/SValVisitor.h"
 #include "llvm/ADT/FoldingSet.h"
 #include "llvm/ADT/ImmutableSet.h"
+#include "llvm/ADT/STLExtras.h"
+#include "llvm/Support/Compiler.h"
 #include "llvm/Support/raw_ostream.h"
 
 using namespace clang;
@@ -1395,12 +1397,23 @@
 return EquivalenceClass::merge(getBasicVals(), F, State, LHS, RHS);
   }
 
-  LLVM_NODISCARD inline ProgramStateRef setConstraint(ProgramStateRef State,
-

[PATCH] D98371: [clangd] Group filename calculations in SymbolCollector, and cache mroe.

2021-03-11 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.

the savings look great, thanks!




Comment at: clang-tools-extra/clangd/index/SymbolCollector.cpp:217
+  llvm::SmallString<256> AbsPath = Path;
+  // We don't perform is_absolute check in an else branch because
+  // makeAbsolute might return a relative path on some InMemoryFileSystems.

i don't think the comments are applicable anymore, this was talking about the 
makeAbsolute inside getCanonicalPath, which is no longer the only call path.



Comment at: clang-tools-extra/clangd/index/SymbolCollector.cpp:322
 SymbolCollector::SymbolCollector(Options Opts) : Opts(std::move(Opts)) {}
+SymbolCollector::~SymbolCollector() = default;
 

why do we need this now?



Comment at: clang-tools-extra/clangd/index/SymbolCollector.cpp:719
+  }
+  // Otherwise find the approprate include header for the definiting file.
+  if (IncludeHeader.empty())

s/definiting/defining



Comment at: clang-tools-extra/clangd/index/SymbolCollector.h:176
   llvm::DenseMap CanonicalDecls;
-  // Cache whether to index a file or not.
   llvm::DenseMap FilesToIndexCache;

is this intentional ?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98371

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


[PATCH] D98329: [clangd] Add cache for FID to Header mappings

2021-03-11 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet abandoned this revision.
kadircet added a comment.

abandoning in favor of D98371 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98329

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


[clang-tools-extra] b8c5837 - [clangd] Group filename calculations in SymbolCollector, and cache mroe.

2021-03-11 Thread Sam McCall via cfe-commits

Author: Sam McCall
Date: 2021-03-11T12:59:26+01:00
New Revision: b8c58374f66b2a03ff3f48c419037d463c5b80ed

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

LOG: [clangd] Group filename calculations in SymbolCollector, and cache mroe.

Also give CanonicalIncludes a less powerful interface (canonicalizes
symbols vs headers separately) so we can cache its results better.

Prior to this:
 - path->uri conversions were not consistently cached, this is
   particularly cheap when we start from a FileEntry* (which we often can)
 - only a small fraction of header-to-include calculation was cached

This is a significant speedup at least for dynamic indexing of preambles.
On my machine, opening XRefs.cpp:

```
PreambleCallback 1.208 -> 1.019 (-15.7%)
BuildPreamble5.538 -> 5.214 (-5.8%)
```

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

Added: 


Modified: 
clang-tools-extra/clangd/index/CanonicalIncludes.cpp
clang-tools-extra/clangd/index/CanonicalIncludes.h
clang-tools-extra/clangd/index/FileIndex.cpp
clang-tools-extra/clangd/index/SymbolCollector.cpp
clang-tools-extra/clangd/index/SymbolCollector.h
clang-tools-extra/clangd/unittests/CanonicalIncludesTests.cpp
clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/index/CanonicalIncludes.cpp 
b/clang-tools-extra/clangd/index/CanonicalIncludes.cpp
index 4741ef622512..f7269b686552 100644
--- a/clang-tools-extra/clangd/index/CanonicalIncludes.cpp
+++ b/clang-tools-extra/clangd/index/CanonicalIncludes.cpp
@@ -28,22 +28,14 @@ void CanonicalIncludes::addMapping(llvm::StringRef Path,
 /// Used to minimize the number of lookups in suffix path mappings.
 constexpr int MaxSuffixComponents = 3;
 
-llvm::StringRef
-CanonicalIncludes::mapHeader(llvm::StringRef Header,
- llvm::StringRef QualifiedName) const {
+llvm::StringRef CanonicalIncludes::mapHeader(llvm::StringRef Header) const {
   assert(!Header.empty());
-  if (StdSymbolMapping) {
-auto SE = StdSymbolMapping->find(QualifiedName);
-if (SE != StdSymbolMapping->end())
-  return SE->second;
-  }
-
   auto MapIt = FullPathMapping.find(Header);
   if (MapIt != FullPathMapping.end())
 return MapIt->second;
 
   if (!StdSuffixHeaderMapping)
-return Header;
+return "";
 
   int Components = 1;
 
@@ -56,7 +48,11 @@ CanonicalIncludes::mapHeader(llvm::StringRef Header,
 if (MappingIt != StdSuffixHeaderMapping->end())
   return MappingIt->second;
   }
-  return Header;
+  return "";
+}
+
+llvm::StringRef CanonicalIncludes::mapSymbol(llvm::StringRef QName) const {
+  return StdSymbolMapping ? StdSymbolMapping->lookup(QName) : "";
 }
 
 std::unique_ptr

diff  --git a/clang-tools-extra/clangd/index/CanonicalIncludes.h 
b/clang-tools-extra/clangd/index/CanonicalIncludes.h
index da7dc46db778..36e33e9324dc 100644
--- a/clang-tools-extra/clangd/index/CanonicalIncludes.h
+++ b/clang-tools-extra/clangd/index/CanonicalIncludes.h
@@ -38,11 +38,11 @@ class CanonicalIncludes {
   /// Adds a string-to-string mapping from \p Path to \p CanonicalPath.
   void addMapping(llvm::StringRef Path, llvm::StringRef CanonicalPath);
 
-  /// Returns the canonical include for symbol with \p QualifiedName.
-  /// \p Header is the file the declaration was reachable from.
-  /// Header itself will be returned if there is no relevant mapping.
-  llvm::StringRef mapHeader(llvm::StringRef Header,
-llvm::StringRef QualifiedName) const;
+  /// Returns the overridden include for symbol with \p QualifiedName, or "".
+  llvm::StringRef mapSymbol(llvm::StringRef QualifiedName) const;
+
+  /// Returns the overridden include for for files in \p Header, or "".
+  llvm::StringRef mapHeader(llvm::StringRef Header) const;
 
   /// Adds mapping for system headers and some special symbols (e.g. STL 
symbols
   /// in  need to be mapped individually). Approximately, the following

diff  --git a/clang-tools-extra/clangd/index/FileIndex.cpp 
b/clang-tools-extra/clangd/index/FileIndex.cpp
index b91c66b88770..eb9648c2a6ae 100644
--- a/clang-tools-extra/clangd/index/FileIndex.cpp
+++ b/clang-tools-extra/clangd/index/FileIndex.cpp
@@ -77,9 +77,9 @@ SlabTuple indexSymbols(ASTContext &AST, 
std::shared_ptr PP,
 
   SymbolCollector Collector(std::move(CollectorOpts));
   Collector.setPreprocessor(PP);
+  index::indexTopLevelDecls(AST, *PP, DeclsToIndex, Collector, IndexOpts);
   if (MacroRefsToIndex)
 Collector.handleMacros(*MacroRefsToIndex);
-  index::indexTopLevelDecls(AST, *PP, DeclsToIndex, Collector, IndexOpts);
 
   const auto &SM = AST.getSourceManager();
   const auto *MainFileEntry = SM.getFileEntryForID(SM.getMainFileID());

diff  --git a/clang-tools-extra/clangd/in

[PATCH] D98371: [clangd] Group filename calculations in SymbolCollector, and cache mroe.

2021-03-11 Thread Sam McCall via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
sammccall marked 4 inline comments as done.
Closed by commit rGb8c58374f66b: [clangd] Group filename calculations in 
SymbolCollector, and cache mroe. (authored by sammccall).

Changed prior to commit:
  https://reviews.llvm.org/D98371?vs=329774&id=329912#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98371

Files:
  clang-tools-extra/clangd/index/CanonicalIncludes.cpp
  clang-tools-extra/clangd/index/CanonicalIncludes.h
  clang-tools-extra/clangd/index/FileIndex.cpp
  clang-tools-extra/clangd/index/SymbolCollector.cpp
  clang-tools-extra/clangd/index/SymbolCollector.h
  clang-tools-extra/clangd/unittests/CanonicalIncludesTests.cpp
  clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp

Index: clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp
===
--- clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp
+++ clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp
@@ -1463,9 +1463,6 @@
   }
   )cpp",
   /*Main=*/"");
-  for (const auto &S : Symbols)
-llvm::errs() << S.Scope << S.Name << " in " << S.IncludeHeaders.size()
- << "\n";
   EXPECT_THAT(
   Symbols,
   UnorderedElementsAre(
Index: clang-tools-extra/clangd/unittests/CanonicalIncludesTests.cpp
===
--- clang-tools-extra/clangd/unittests/CanonicalIncludesTests.cpp
+++ clang-tools-extra/clangd/unittests/CanonicalIncludesTests.cpp
@@ -20,11 +20,8 @@
   Language.C11 = true;
   CI.addSystemHeadersMapping(Language);
   // Usual standard library symbols are mapped correctly.
-  EXPECT_EQ("", CI.mapHeader("path/stdio.h", "printf"));
-  // Suffix mapping isn't available for C, instead of mapping to ` we
-  // just leave the header as-is.
-  EXPECT_EQ("include/stdio.h",
-CI.mapHeader("include/stdio.h", "unknown_symbol"));
+  EXPECT_EQ("", CI.mapSymbol("printf"));
+  EXPECT_EQ("", CI.mapSymbol("unknown_symbol"));
 }
 
 TEST(CanonicalIncludesTest, CXXStandardLibrary) {
@@ -34,17 +31,16 @@
   CI.addSystemHeadersMapping(Language);
 
   // Usual standard library symbols are mapped correctly.
-  EXPECT_EQ("", CI.mapHeader("path/vector.h", "std::vector"));
-  EXPECT_EQ("", CI.mapHeader("path/stdio.h", "std::printf"));
+  EXPECT_EQ("", CI.mapSymbol("std::vector"));
+  EXPECT_EQ("", CI.mapSymbol("std::printf"));
   // std::move is ambiguous, currently always mapped to 
-  EXPECT_EQ("",
-CI.mapHeader("libstdc++/bits/stl_algo.h", "std::move"));
+  EXPECT_EQ("", CI.mapSymbol("std::move"));
   // Unknown std symbols aren't mapped.
-  EXPECT_EQ("foo/bar.h", CI.mapHeader("foo/bar.h", "std::notathing"));
+  EXPECT_EQ("", CI.mapSymbol("std::notathing"));
   // iosfwd declares some symbols it doesn't own.
-  EXPECT_EQ("", CI.mapHeader("iosfwd", "std::ostream"));
+  EXPECT_EQ("", CI.mapSymbol("std::ostream"));
   // And (for now) we assume it owns the others.
-  EXPECT_EQ("", CI.mapHeader("iosfwd", "std::notwathing"));
+  EXPECT_EQ("", CI.mapHeader("iosfwd"));
 }
 
 TEST(CanonicalIncludesTest, PathMapping) {
@@ -52,20 +48,8 @@
   CanonicalIncludes CI;
   CI.addMapping("foo/bar", "");
 
-  EXPECT_EQ("", CI.mapHeader("foo/bar", "some::symbol"));
-  EXPECT_EQ("bar/bar", CI.mapHeader("bar/bar", "some::symbol"));
-}
-
-TEST(CanonicalIncludesTest, SymbolMapping) {
-  // As used for standard library.
-  CanonicalIncludes CI;
-  LangOptions Language;
-  Language.CPlusPlus = true;
-  // Ensures 'std::vector' is mapped to ''.
-  CI.addSystemHeadersMapping(Language);
-
-  EXPECT_EQ("", CI.mapHeader("foo/bar", "std::vector"));
-  EXPECT_EQ("foo/bar", CI.mapHeader("foo/bar", "other::symbol"));
+  EXPECT_EQ("", CI.mapHeader("foo/bar"));
+  EXPECT_EQ("", CI.mapHeader("bar/bar"));
 }
 
 TEST(CanonicalIncludesTest, Precedence) {
@@ -76,15 +60,9 @@
   CI.addSystemHeadersMapping(Language);
 
   // We added a mapping from some/path to .
-  ASSERT_EQ("", CI.mapHeader("some/path", ""));
+  ASSERT_EQ("", CI.mapHeader("some/path"));
   // We should have a path from 'bits/stl_vector.h' to ''.
-  ASSERT_EQ("", CI.mapHeader("bits/stl_vector.h", ""));
-  // We should also have a symbol mapping from 'std::map' to ''.
-  ASSERT_EQ("", CI.mapHeader("some/header.h", "std::map"));
-
-  // And the symbol mapping should take precedence over paths mapping.
-  EXPECT_EQ("", CI.mapHeader("bits/stl_vector.h", "std::map"));
-  EXPECT_EQ("", CI.mapHeader("some/path", "std::map"));
+  ASSERT_EQ("", CI.mapHeader("bits/stl_vector.h"));
 }
 
 } // namespace
Index: clang-tools-extra/clangd/index/SymbolCollector.h
===
--- clang-tools-extra/clangd/index/SymbolCollector.h
+++ clang-tools-extra/clangd/index/SymbolCollector.h
@@ -91,6 +91

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

2021-03-11 Thread Kirill Bobyrev via Phabricator via cfe-commits
kbobyrev updated this revision to Diff 329913.
kbobyrev marked 2 inline comments as done.
kbobyrev added a comment.

Address review 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/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
@@ -22,6 +22,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 +75,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
@@ -35,6 +35,10 @@
 #include 
 #include 
 
+#ifdef ENABLE_GRPC_REFLECTION
+#include 
+#endif
+
 namespace clang {
 namespace clangd {
 namespace remote {
@@ -313,6 +317,9 @@
   RemoteIndexServer Service(Index, IndexRoot);
 
   grpc::EnableDefaultHealthCheckService(true);
+#ifdef 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
@@ -9,6 +9,10 @@
   RemoteIndexServiceProto
   )
 
+if (ENABLE_GRPC_REFLECTION)
+  add_definitions(-DENABLE_GRPC_REFLECTION)
+endif()
+
 target_link_libraries(clangd-index-server
   PRIVATE
   clangDaemon
@@ -17,4 +21,6 @@
   RemoteIndexProto
   RemoteIndexServiceProto
   clangdRemoteMarshalling
+
+  ${REFLECTION_LIBRARY}
   )


Index: llvm/cmake/modules/FindGRPC.cmake
===
--- llvm/cmake/modules/FindGRPC.cmake
+++ llvm/cmake/modules/FindGRPC.cmake
@@ -22,6 +22,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 +75,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_CURRE

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

2021-03-11 Thread Luke Drummond via Phabricator via cfe-commits
ldrumm created this revision.
ldrumm added reviewers: Anastasia, mibintc, bader, yaxunl.
ldrumm added a project: clang.
Herald added a subscriber: wenlei.
ldrumm requested review of this revision.

`__translate_sampler_initializer` has a calling convention of
`spir_func`, but clang generated calls to it using the default CC.

Instruction Combining was lowering these mismatching calling conventions
to `store i1* undef` which itself was subsequently lowered to a trap
instruction by simplifyCFG resulting in runtime `SIGILL`

There are arguably two bugs here: but whether there's any wisdom in
converting an obviously invalid call into a runtime crash over aborting
with a sensible error message will require further discussion. So for
now it's enough to set the right calling convention on the runtime
helper.


Repository:
  rG LLVM Github Monorepo

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
@@ -6263,15 +6263,17 @@
 
   return *SanStats;
 }
+
 llvm::Value *
 CodeGenModule::createOpenCLIntToSamplerConversion(const Expr *E,
   CodeGenFunction &CGF) {
   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(

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

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



Comment at: clang-tools-extra/clangd/index/remote/server/CMakeLists.txt:12
 
+if (ENABLE_GRPC_REFLECTION)
+  set(REFLECTION_LIBRARY grpc++_reflection)

kadircet wrote:
> can we move this piece into FindGRPC.cmake instead?
Yes, but I think only the `set(REFLECTION_LIBRARY grpc++_reflection)` part? 
Having the `-DENABLE_GRPC_REFLECTION` definition globally is probably not very 
nice and as with the other target under `clangd/index/remote`, 
`add_target_definition` doesn't work because of `add_clan_executable` :(


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] D95016: [Clang][RISCV] Add custom TableGen backend for riscv-vector intrinsics.

2021-03-11 Thread Zakk Chen 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 rGd6a0560bf258: [Clang][RISCV] Add custom TableGen backend for 
riscv-vector intrinsics. (authored by khchen).

Changed prior to commit:
  https://reviews.llvm.org/D95016?vs=328533&id=329819#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95016

Files:
  clang/include/clang/Basic/BuiltinsRISCV.def
  clang/include/clang/Basic/CMakeLists.txt
  clang/include/clang/Basic/riscv_vector.td
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/lib/Headers/CMakeLists.txt
  clang/test/CodeGen/RISCV/rvv-intrinsics-generic/vadd.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-generic/vfadd.c
  clang/test/CodeGen/RISCV/rvv-intrinsics/vadd.c
  clang/test/CodeGen/RISCV/rvv-intrinsics/vfadd.c
  clang/test/CodeGen/RISCV/vadd.c
  clang/test/Headers/riscv-vector-header.c
  clang/utils/TableGen/CMakeLists.txt
  clang/utils/TableGen/RISCVVEmitter.cpp
  clang/utils/TableGen/TableGen.cpp
  clang/utils/TableGen/TableGenBackends.h
  llvm/docs/CommandGuide/tblgen.rst

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


[PATCH] D98242: [clangd] Store system relative includes as verbatim

2021-03-11 Thread Sam McCall via Phabricator via cfe-commits
sammccall added a comment.

I've landed the caching patch so this is good to go.
The merge is *conceptually* trivial but the enclosing function has moved so you 
may need to reapply it by hand, sorry...




Comment at: clang-tools-extra/clangd/index/SymbolCollector.cpp:801
+  if (IsSystem)
+return "<" + ShorterInclude + ">";
   // Standard case: just insert the file itself.

sammccall wrote:
> kadircet wrote:
> > sammccall wrote:
> > > This is a great heuristic, now I'm thinking of all the ways it can go 
> > > wrong...
> > > 
> > > ---
> > > 
> > > It could be slow: it's doing a string comparison for every include path 
> > > entry (not just the -isystems) and that can be a long list for big 
> > > codebases. We're calling this for most symbols we encounter, so in 
> > > principle this looks quadratic in codebase size when indexing a preamble.
> > > 
> > > It's tempting to throw a cache on it but actually... the callsite looks 
> > > like:
> > > ```
> > > foreach header:
> > >   foreach symbol:
> > > adjust(getIncludeHeader(symbol, header));
> > > ```
> > > 
> > > getIncludeHeader() is entirely dependent on the header almost ignores the 
> > > symbol, so hoisting it out of the loop would be as good as caching it.
> > > 
> > > The wrinkle is the std::move hack, but we can move *that* part alone 
> > > inside the loop instead.
> > > 
> > > ---
> > > 
> > > It could fail to translate properly between paths, being inserted where 
> > > the -isystem wasn't available. Often this means the *library* isn't 
> > > available in this part of the codebase, so really the problem is offering 
> > > the symbol at all (though using verbatim headers may make this harder to 
> > > fix). Dynamic indexes spanning multiple projects are another case, but I 
> > > think a marginal one. I don't think we need to address this.
> > > 
> > > ---
> > > 
> > > It may give inconsistent results between TUs for the same symbol.
> > > When a definition is indexed, it should win, so the problematic cases are:
> > >  - header-only symbols (or no definition indexed) with inconsistent 
> > > -isystem. This is not terribly important, as above I think.
> > >  - definition is missing -isystem, because *within* the library headers 
> > > are not considered "system". This seems likely to be common, and I'm not 
> > > sure how to address it (other than giving verbatim headers priority 
> > > always, which seems dubious). It's not a regression though (just the bug 
> > > doesn't get fixed for these symbols.)
> > >  - definition has -isystem (library impl considers its own headers as 
> > > system) but other files don't. Also not sure how to solve this but it 
> > > seems less likely to be common to me.
> > > 
> > > One design around these problems would be to store *both* a preferred 
> > > spelling and a filename, and to use the spelling if it can be resolved. 
> > > But this is invasive, means doing stat()s, doesn't work well with 
> > > genfiles... I'm not really sure of a clean solution here.
> > > 
> > > Maybe we just move ahead as-is and see if we hit problems...
> > for latency concerns, i was mostly turning a blind eye as this would only 
> > happen once per indexing. but you are right, we can get away from any 
> > possible regressions by moving it to per-header layer.
> > 
> > ---
> > 
> > > It could fail to translate properly between paths, being inserted where 
> > > the -isystem wasn't available. Often this means the *library* isn't 
> > > available in this part of the codebase, so really the problem is offering 
> > > the symbol at all (though using verbatim headers may make this harder to 
> > > fix). Dynamic indexes spanning multiple projects are another case, but I 
> > > think a marginal one. I don't think we need to address this.
> > 
> > as you mentioned this is likely to show up either when there's a 
> > remote-index/static-index built on another machine in use or dynamic index 
> > with multiple projects.
> > - for remote-index/static-index case, i think it is unlikely to show up, as 
> > the symbol should be available during local development too.
> > -for dynamic index spanning multiple indexes though, previously we would 
> > just suggest a wrong symbol and now we'll also perform a wrong header 
> > insertion so it is sort-of worse. but as you mentioned this should probably 
> > be handled on symbol level as well.
> > 
> > my mental model around the fix was rather making use of the 
> > declaration/definition location of the symbol, which is guaranteed to be a 
> > URI, rather than a symbolic representation of the "owning" header. hence i 
> > feel like this shouldn't make things harder when we are fixing that issue.
> > 
> > > It may give inconsistent results between TUs for the same symbol.
> > 
> > I didn't consider this case thoroughly, as I was assuming system search 
> > paths to be same for the whole codebase (leaving multiple-projects case 
> > out).
> > 
> > > header-only sym

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

2021-03-11 Thread Alexey Bader via Phabricator via cfe-commits
bader accepted this revision.
bader added a comment.
This revision is now accepted and ready to land.

Thanks! LGTM.
I think we should consider deprecating `spir_func` calling convention in favor 
of default calling convention. I don't much value in having it today.


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] D98246: [clangd] Add basic monitoring info request for remote index server

2021-03-11 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet added a comment.

thanks! this mostly LG, just a couple comments here and there.

> The current format is "store seconds since X event".

I think this is great for certain things like freshness, so thanks!

> Should we store UNIX timestamps instead? This is probably not portable until 
> C++20, so maybe it isn't a great idea.

But I believe we also need to record timepoints. what about just storing 
seconds since unix epoch in an int64?
i don't follow why it would be unportable, as by definition it is the time 
elapsed since 1-1-1970, so i don't think it has anything specific to UNIX 
itself, apart from the name.




Comment at: clang-tools-extra/clangd/index/remote/Service.proto:27
 
+message MonitoringInfoRequest {}
+message MonitoringInfoReply {

nit: i'd prefer these to be on a separate file (both messages and the service 
definition), WDYT?



Comment at: clang-tools-extra/clangd/index/remote/Service.proto:32
+  // Time since the last index reload (in seconds).
+  optional uint64 time_since_reload = 2;
+  // FIXME(kirillbobyrev): The following fields should be provided with the

this and freshness has very little difference. i'd either drop one (preferably 
this one), or change this one to be a timepoint for the latest index reload.



Comment at: clang-tools-extra/clangd/index/remote/Service.proto:33
+  optional uint64 time_since_reload = 2;
+  // FIXME(kirillbobyrev): The following fields should be provided with the
+  // index (probably in adjacent metadata.txt file next to loaded .idx).

i think this fixme belongs to the service implementation.



Comment at: clang-tools-extra/clangd/index/remote/Service.proto:37
+  optional uint64 freshness = 3;
+  // Time since the index was built on the indexing machine.
+  optional string index_commit_hash = 4;

i smell some c/p



Comment at: clang-tools-extra/clangd/index/remote/Service.proto:41
+  optional string index_link = 5;
+  optional string metadata = 9000;
+}

what's the point of this exactly?



Comment at: clang-tools-extra/clangd/index/remote/server/Server.cpp:351
  IdleTimeoutSeconds * 1000);
   Builder.RegisterService(&Service);
   std::unique_ptr Server(Builder.BuildAndStart());

don't we need to register monitoring service in here?


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


[clang-tools-extra] b1a5df1 - [clangd] Drop explicit specifier on define out-of-line

2021-03-11 Thread Kadir Cetinkaya via cfe-commits

Author: Kadir Cetinkaya
Date: 2021-03-11T13:27:24+01:00
New Revision: b1a5df174e1d5a58f2498c30795cf18c9bf3e1b1

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

LOG: [clangd] Drop explicit specifier on define out-of-line

Explicit specifier can only be mentioned on the in-line declaration of a
constructor, so don't carry it over to the definition.

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

Added: 


Modified: 
clang-tools-extra/clangd/refactor/tweaks/DefineOutline.cpp
clang-tools-extra/clangd/unittests/tweaks/DefineOutlineTests.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/refactor/tweaks/DefineOutline.cpp 
b/clang-tools-extra/clangd/refactor/tweaks/DefineOutline.cpp
index 4cdd36cbd4c9..18c521119972 100644
--- a/clang-tools-extra/clangd/refactor/tweaks/DefineOutline.cpp
+++ b/clang-tools-extra/clangd/refactor/tweaks/DefineOutline.cpp
@@ -272,6 +272,10 @@ getFunctionSourceCode(const FunctionDecl *FD, 
llvm::StringRef TargetNamespace,
 if (MD->isStatic())
   DelKeyword(tok::kw_static, {FD->getBeginLoc(), FD->getLocation()});
   }
+  if (const auto *CD = dyn_cast(FD)) {
+if (CD->isExplicit())
+  DelKeyword(tok::kw_explicit, {FD->getBeginLoc(), FD->getLocation()});
+  }
 
   if (Errors)
 return std::move(Errors);

diff  --git a/clang-tools-extra/clangd/unittests/tweaks/DefineOutlineTests.cpp 
b/clang-tools-extra/clangd/unittests/tweaks/DefineOutlineTests.cpp
index fa627282e193..a872341a871a 100644
--- a/clang-tools-extra/clangd/unittests/tweaks/DefineOutlineTests.cpp
+++ b/clang-tools-extra/clangd/unittests/tweaks/DefineOutlineTests.cpp
@@ -267,6 +267,28 @@ TEST_F(DefineOutlineTest, ApplyTest) {
 };)cpp",
   "  void A::foo() {}\n",
   },
+  {
+  R"cpp(
+struct Foo {
+  explicit Fo^o(int) {}
+};)cpp",
+  R"cpp(
+struct Foo {
+  explicit Foo(int) ;
+};)cpp",
+  " Foo::Foo(int) {}\n",
+  },
+  {
+  R"cpp(
+struct Foo {
+  explicit explicit Fo^o(int) {}
+};)cpp",
+  R"cpp(
+struct Foo {
+  explicit explicit Foo(int) ;
+};)cpp",
+  "  Foo::Foo(int) {}\n",
+  },
   };
   for (const auto &Case : Cases) {
 SCOPED_TRACE(Case.Test);



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


[PATCH] D98164: [clangd] Drop explicit specifier on define out-of-line

2021-03-11 Thread Kadir Cetinkaya via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGb1a5df174e1d: [clangd] Drop explicit specifier on define 
out-of-line (authored by kadircet).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98164

Files:
  clang-tools-extra/clangd/refactor/tweaks/DefineOutline.cpp
  clang-tools-extra/clangd/unittests/tweaks/DefineOutlineTests.cpp


Index: clang-tools-extra/clangd/unittests/tweaks/DefineOutlineTests.cpp
===
--- clang-tools-extra/clangd/unittests/tweaks/DefineOutlineTests.cpp
+++ clang-tools-extra/clangd/unittests/tweaks/DefineOutlineTests.cpp
@@ -267,6 +267,28 @@
 };)cpp",
   "  void A::foo() {}\n",
   },
+  {
+  R"cpp(
+struct Foo {
+  explicit Fo^o(int) {}
+};)cpp",
+  R"cpp(
+struct Foo {
+  explicit Foo(int) ;
+};)cpp",
+  " Foo::Foo(int) {}\n",
+  },
+  {
+  R"cpp(
+struct Foo {
+  explicit explicit Fo^o(int) {}
+};)cpp",
+  R"cpp(
+struct Foo {
+  explicit explicit Foo(int) ;
+};)cpp",
+  "  Foo::Foo(int) {}\n",
+  },
   };
   for (const auto &Case : Cases) {
 SCOPED_TRACE(Case.Test);
Index: clang-tools-extra/clangd/refactor/tweaks/DefineOutline.cpp
===
--- clang-tools-extra/clangd/refactor/tweaks/DefineOutline.cpp
+++ clang-tools-extra/clangd/refactor/tweaks/DefineOutline.cpp
@@ -272,6 +272,10 @@
 if (MD->isStatic())
   DelKeyword(tok::kw_static, {FD->getBeginLoc(), FD->getLocation()});
   }
+  if (const auto *CD = dyn_cast(FD)) {
+if (CD->isExplicit())
+  DelKeyword(tok::kw_explicit, {FD->getBeginLoc(), FD->getLocation()});
+  }
 
   if (Errors)
 return std::move(Errors);


Index: clang-tools-extra/clangd/unittests/tweaks/DefineOutlineTests.cpp
===
--- clang-tools-extra/clangd/unittests/tweaks/DefineOutlineTests.cpp
+++ clang-tools-extra/clangd/unittests/tweaks/DefineOutlineTests.cpp
@@ -267,6 +267,28 @@
 };)cpp",
   "  void A::foo() {}\n",
   },
+  {
+  R"cpp(
+struct Foo {
+  explicit Fo^o(int) {}
+};)cpp",
+  R"cpp(
+struct Foo {
+  explicit Foo(int) ;
+};)cpp",
+  " Foo::Foo(int) {}\n",
+  },
+  {
+  R"cpp(
+struct Foo {
+  explicit explicit Fo^o(int) {}
+};)cpp",
+  R"cpp(
+struct Foo {
+  explicit explicit Foo(int) ;
+};)cpp",
+  "  Foo::Foo(int) {}\n",
+  },
   };
   for (const auto &Case : Cases) {
 SCOPED_TRACE(Case.Test);
Index: clang-tools-extra/clangd/refactor/tweaks/DefineOutline.cpp
===
--- clang-tools-extra/clangd/refactor/tweaks/DefineOutline.cpp
+++ clang-tools-extra/clangd/refactor/tweaks/DefineOutline.cpp
@@ -272,6 +272,10 @@
 if (MD->isStatic())
   DelKeyword(tok::kw_static, {FD->getBeginLoc(), FD->getLocation()});
   }
+  if (const auto *CD = dyn_cast(FD)) {
+if (CD->isExplicit())
+  DelKeyword(tok::kw_explicit, {FD->getBeginLoc(), FD->getLocation()});
+  }
 
   if (Errors)
 return std::move(Errors);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] 4f1bbc0 - [clangd] Introduce a CommandLineConfigProvider

2021-03-11 Thread Kadir Cetinkaya via cfe-commits

Author: Kadir Cetinkaya
Date: 2021-03-11T13:35:05+01:00
New Revision: 4f1bbc0b842621d2048ed8687e328e2eab375b0a

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

LOG: [clangd] Introduce a CommandLineConfigProvider

This enables unifying command line flags with config options in clangd
internals. This patch changes behaviour in 2 places:
- BackgroundIndex was previously disabled when -remote-index was
provided. After this patch, it will be enabled but all files will have
bkgindex policy set to Skip.
- -index-file was loaded at startup (at least load was initiated), now
the load will happen through ProjectAwareIndex with first index query.

Unfortunately this doesn't simplify any options initially, as
- CompileCommandsDir is also used by clangd --check workflow, which
doesn't use configs.
- EnableBackgroundIndex option controls whether the component will be
created at all, which implies creation of extra threads registering a
listener for compilation database discoveries.

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

Added: 


Modified: 
clang-tools-extra/clangd/ClangdLSPServer.cpp
clang-tools-extra/clangd/ClangdLSPServer.h
clang-tools-extra/clangd/test/log.test
clang-tools-extra/clangd/tool/Check.cpp
clang-tools-extra/clangd/tool/ClangdMain.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/ClangdLSPServer.cpp 
b/clang-tools-extra/clangd/ClangdLSPServer.cpp
index 8875f85c8b70..cd13e013aa50 100644
--- a/clang-tools-extra/clangd/ClangdLSPServer.cpp
+++ b/clang-tools-extra/clangd/ClangdLSPServer.cpp
@@ -467,11 +467,10 @@ void ClangdLSPServer::onInitialize(const InitializeParams 
&Params,
   if (Server)
 return Reply(llvm::make_error("server already initialized",
 ErrorCode::InvalidRequest));
-  if (const auto &Dir = Params.initializationOptions.compilationDatabasePath)
-Opts.CompileCommandsDir = Dir;
   if (Opts.UseDirBasedCDB) {
 DirectoryBasedGlobalCompilationDatabase::Options CDBOpts(TFS);
-CDBOpts.CompileCommandsDir = Opts.CompileCommandsDir;
+if (const auto &Dir = Params.initializationOptions.compilationDatabasePath)
+  CDBOpts.CompileCommandsDir = Dir;
 CDBOpts.ContextProvider = Opts.ContextProvider;
 BaseCDB =
 std::make_unique(CDBOpts);

diff  --git a/clang-tools-extra/clangd/ClangdLSPServer.h 
b/clang-tools-extra/clangd/ClangdLSPServer.h
index 01d0ec20f098..fc13c6257ee6 100644
--- a/clang-tools-extra/clangd/ClangdLSPServer.h
+++ b/clang-tools-extra/clangd/ClangdLSPServer.h
@@ -48,9 +48,6 @@ class ClangdLSPServer : private ClangdServer::Callbacks,
 /// Look for compilation databases, rather than using compile commands
 /// set via LSP (extensions) only.
 bool UseDirBasedCDB = true;
-/// A fixed directory to search for a compilation database in.
-/// If not set, we search upward from the source file.
-llvm::Optional CompileCommandsDir;
 /// The offset-encoding to use, or None to negotiate it over LSP.
 llvm::Optional Encoding;
 /// If set, periodically called to release memory.

diff  --git a/clang-tools-extra/clangd/test/log.test 
b/clang-tools-extra/clangd/test/log.test
index 5d60c10eb917..7a53d361ddde 100644
--- a/clang-tools-extra/clangd/test/log.test
+++ b/clang-tools-extra/clangd/test/log.test
@@ -1,9 +1,9 @@
-# RUN: env CLANGD_FLAGS=-index-file=no-such-index not clangd -lit-test 
&1 >/dev/null | FileCheck %s
+# RUN: env CLANGD_FLAGS=-compile-commands-dir=no-such-dir not clangd -lit-test 
&1 >/dev/null | FileCheck %s
 CHECK: I[{{.*}}]{{.*}} clangd version {{.*}}
 CHECK: Working directory: {{.*}}
 CHECK: argv[0]: clangd
 CHECK: argv[1]: -lit-test
-CHECK: CLANGD_FLAGS: -index-file=no-such-index
-CHECK: E[{{.*}}] Can't open no-such-index
+CHECK: CLANGD_FLAGS: -compile-commands-dir=no-such-dir
+CHECK: E[{{.*}}] Path specified by --compile-commands-dir does not exist.
 CHECK: Starting LSP over stdin/stdout
 

diff  --git a/clang-tools-extra/clangd/tool/Check.cpp 
b/clang-tools-extra/clangd/tool/Check.cpp
index 9e3e439ae70d..00a4609e5134 100644
--- a/clang-tools-extra/clangd/tool/Check.cpp
+++ b/clang-tools-extra/clangd/tool/Check.cpp
@@ -26,6 +26,7 @@
 
 #include "ClangdLSPServer.h"
 #include "CodeComplete.h"
+#include "Config.h"
 #include "GlobalCompilationDatabase.h"
 #include "Hover.h"
 #include "ParsedAST.h"
@@ -93,7 +94,8 @@ class Checker {
   bool buildCommand(const ThreadsafeFS &TFS) {
 log("Loading compilation database...");
 DirectoryBasedGlobalCompilationDatabase::Options CDBOpts(TFS);
-CDBOpts.CompileCommandsDir = Opts.CompileCommandsDir;
+CDBOpts.CompileCommandsDir =
+Config::current().CompileFlags.CDBSearch.FixedCDBPath;
 std::unique_ptr BaseCDB =
 std::make_unique(CDBOpts);

[PATCH] D98029: [clangd] Introduce a CommandLineConfigProvider

2021-03-11 Thread Kadir Cetinkaya 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 rG4f1bbc0b8426: [clangd] Introduce a CommandLineConfigProvider 
(authored by kadircet).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98029

Files:
  clang-tools-extra/clangd/ClangdLSPServer.cpp
  clang-tools-extra/clangd/ClangdLSPServer.h
  clang-tools-extra/clangd/test/log.test
  clang-tools-extra/clangd/tool/Check.cpp
  clang-tools-extra/clangd/tool/ClangdMain.cpp

Index: clang-tools-extra/clangd/tool/ClangdMain.cpp
===
--- clang-tools-extra/clangd/tool/ClangdMain.cpp
+++ clang-tools-extra/clangd/tool/ClangdMain.cpp
@@ -8,6 +8,8 @@
 
 #include "ClangdLSPServer.h"
 #include "CodeComplete.h"
+#include "Config.h"
+#include "ConfigProvider.h"
 #include "Features.inc"
 #include "PathMapping.h"
 #include "Protocol.h"
@@ -43,6 +45,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 
 #ifndef _WIN32
@@ -544,15 +547,91 @@
 log("Associating {0} with monolithic index at {1}.", External.MountPoint,
 External.Location);
 auto NewIndex = std::make_unique(std::make_unique());
-Tasks.runAsync("Load-index:" + External.Location,
-   [File = External.Location, PlaceHolder = NewIndex.get()] {
- if (auto Idx = loadIndex(File, /*UseDex=*/true))
-   PlaceHolder->reset(std::move(Idx));
-   });
+auto IndexLoadTask = [File = External.Location,
+  PlaceHolder = NewIndex.get()] {
+  if (auto Idx = loadIndex(File, /*UseDex=*/true))
+PlaceHolder->reset(std::move(Idx));
+};
+// FIXME: The signature should contain a null-able TaskRunner istead, and
+// the task should be scheduled accordingly.
+if (Sync) {
+  IndexLoadTask();
+} else {
+  Tasks.runAsync("Load-index:" + External.Location,
+ std::move(IndexLoadTask));
+}
 return std::move(NewIndex);
   }
   llvm_unreachable("Invalid ExternalIndexKind.");
 }
+
+class FlagsConfigProvider : public config::Provider {
+private:
+  config::CompiledFragment Frag;
+
+  std::vector
+  getFragments(const config::Params &,
+   config::DiagnosticCallback) const override {
+return {Frag};
+  }
+
+public:
+  FlagsConfigProvider() {
+llvm::Optional CDBSearch;
+llvm::Optional IndexSpec;
+llvm::Optional BGPolicy;
+
+// If --compile-commands-dir arg was invoked, check value and override
+// default path.
+if (!CompileCommandsDir.empty()) {
+  if (llvm::sys::fs::exists(CompileCommandsDir)) {
+// We support passing both relative and absolute paths to the
+// --compile-commands-dir argument, but we assume the path is absolute
+// in the rest of clangd so we make sure the path is absolute before
+// continuing.
+llvm::SmallString<128> Path(CompileCommandsDir);
+if (std::error_code EC = llvm::sys::fs::make_absolute(Path)) {
+  elog("Error while converting the relative path specified by "
+   "--compile-commands-dir to an absolute path: {0}. The argument "
+   "will be ignored.",
+   EC.message());
+} else {
+  CDBSearch = {Config::CDBSearchSpec::FixedDir, Path.str().str()};
+}
+  } else {
+elog("Path specified by --compile-commands-dir does not exist. The "
+ "argument will be ignored.");
+  }
+}
+if (!IndexFile.empty()) {
+  Config::ExternalIndexSpec Spec;
+  Spec.Kind = Spec.File;
+  Spec.Location = IndexFile;
+  IndexSpec = std::move(Spec);
+}
+if (!RemoteIndexAddress.empty()) {
+  assert(!ProjectRoot.empty() && IndexFile.empty());
+  Config::ExternalIndexSpec Spec;
+  Spec.Kind = Spec.Server;
+  Spec.Location = RemoteIndexAddress;
+  Spec.MountPoint = ProjectRoot;
+  IndexSpec = std::move(Spec);
+  BGPolicy = Config::BackgroundPolicy::Skip;
+}
+if (!EnableBackgroundIndex) {
+  BGPolicy = Config::BackgroundPolicy::Skip;
+}
+Frag = [=](const config::Params &, Config &C) {
+  if (CDBSearch)
+C.CompileFlags.CDBSearch = *CDBSearch;
+  if (IndexSpec)
+C.Index.External = *IndexSpec;
+  if (BGPolicy)
+C.Index.Background = *BGPolicy;
+  return true;
+};
+  }
+};
 } // namespace
 } // namespace clangd
 } // namespace clang
@@ -693,29 +772,6 @@
   ClangdLSPServer::Options Opts;
   Opts.UseDirBasedCDB = (CompileArgsFrom == FilesystemCompileArgs);
 
-  // If --compile-commands-dir arg was invoked, check value and override default
-  // path.
-  if (!CompileCommandsDir.empty()) {
-if (llvm::sys::fs::exists(CompileCommandsDir)) {
-  // We support passing both relative and absolute paths to the
-  // --compile-commands

[PATCH] D98414: [clangd] Turn off implicit cancellation based on client capabilities

2021-03-11 Thread Sam McCall via Phabricator via cfe-commits
sammccall created this revision.
sammccall added a reviewer: kadircet.
Herald added subscribers: usaxena95, arphaman.
sammccall requested review of this revision.
Herald added subscribers: cfe-commits, MaskRay, ilya-biryukov.
Herald added a project: clang.

Capability is in upcoming 3.17: 
https://microsoft.github.io/language-server-protocol/specifications/specification-3-17/

(This is also useful for C++ embedders)


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D98414

Files:
  clang-tools-extra/clangd/ClangdLSPServer.cpp
  clang-tools-extra/clangd/ClangdServer.cpp
  clang-tools-extra/clangd/ClangdServer.h
  clang-tools-extra/clangd/Protocol.cpp
  clang-tools-extra/clangd/Protocol.h

Index: clang-tools-extra/clangd/Protocol.h
===
--- clang-tools-extra/clangd/Protocol.h
+++ clang-tools-extra/clangd/Protocol.h
@@ -475,6 +475,10 @@
   /// window.implicitWorkDoneProgressCreate
   bool ImplicitProgressCreation = false;
 
+  /// Whether the client claims to cancel stale requests.
+  /// general.staleRequestSupport.cancel
+  bool CancelsStaleRequests = false;
+
   /// Whether the client implementation supports a refresh request sent from the
   /// server to the client.
   bool SemanticTokenRefreshSupport = false;
Index: clang-tools-extra/clangd/Protocol.cpp
===
--- clang-tools-extra/clangd/Protocol.cpp
+++ clang-tools-extra/clangd/Protocol.cpp
@@ -414,6 +414,12 @@
 if (auto Implicit = Window->getBoolean("implicitWorkDoneProgressCreate"))
   R.ImplicitProgressCreation = *Implicit;
   }
+  if (auto *General = O->getObject("general")) {
+if (auto *StaleRequestSupport = General->getObject("staleRequestSupport")) {
+  if (auto Cancel = StaleRequestSupport->getBoolean("cancel"))
+R.CancelsStaleRequests = *Cancel;
+}
+  }
   if (auto *OffsetEncoding = O->get("offsetEncoding")) {
 R.offsetEncoding.emplace();
 if (!fromJSON(*OffsetEncoding, *R.offsetEncoding,
Index: clang-tools-extra/clangd/ClangdServer.h
===
--- clang-tools-extra/clangd/ClangdServer.h
+++ clang-tools-extra/clangd/ClangdServer.h
@@ -146,6 +146,12 @@
 /*RebuildRatio=*/1,
 };
 
+/// Cancel certain requests if the file changes before they begin running.
+/// This is useful for "transient" actions like enumerateTweaks that were
+/// likely implicitly generated, and avoids redundant work if clients forget
+/// to cancel. Clients that always cancel stale requests should clear this.
+bool ImplicitCancellation = true;
+
 /// Clangd will execute compiler drivers matching one of these globs to
 /// fetch system include path.
 std::vector QueryDriverGlobs;
@@ -391,6 +397,8 @@
 
   llvm::Optional WorkspaceRoot;
   llvm::Optional WorkScheduler;
+  // Invalidation policy used for actions that we assume are "transient".
+  TUScheduler::ASTActionInvalidation Transient;
 
   // Store of the current versions of the open documents.
   // Only written from the main thread (despite being threadsafe).
Index: clang-tools-extra/clangd/ClangdServer.cpp
===
--- clang-tools-extra/clangd/ClangdServer.cpp
+++ clang-tools-extra/clangd/ClangdServer.cpp
@@ -150,6 +150,8 @@
   DynamicIdx(Opts.BuildDynamicSymbolIndex ? new FileIndex() : nullptr),
   ClangTidyProvider(Opts.ClangTidyProvider),
   WorkspaceRoot(Opts.WorkspaceRoot),
+  Transient(Opts.ImplicitCancellation ? TUScheduler::InvalidateOnUpdate
+  : TUScheduler::NoInvalidation),
   DirtyFS(std::make_unique(TFS, DraftMgr)) {
   // Pass a callback into `WorkScheduler` to extract symbols from a newly
   // parsed file and rebuild the file index synchronously each time an AST
@@ -592,7 +594,7 @@
   };
 
   WorkScheduler->runWithAST("EnumerateTweaks", File, std::move(Action),
-TUScheduler::InvalidateOnUpdate);
+Transient);
 }
 
 void ClangdServer::applyTweak(PathRef File, Range Sel, StringRef TweakID,
@@ -682,8 +684,7 @@
 CB(clangd::findDocumentHighlights(InpAST->AST, Pos));
   };
 
-  WorkScheduler->runWithAST("Highlights", File, std::move(Action),
-TUScheduler::InvalidateOnUpdate);
+  WorkScheduler->runWithAST("Highlights", File, std::move(Action), Transient);
 }
 
 void ClangdServer::findHover(PathRef File, Position Pos,
@@ -697,8 +698,7 @@
 CB(clangd::getHover(InpAST->AST, Pos, std::move(Style), Index));
   };
 
-  WorkScheduler->runWithAST("Hover", File, std::move(Action),
-TUScheduler::InvalidateOnUpdate);
+  WorkScheduler->runWithAST("Hover", File, std::move(Action), Transient);
 }
 
 void ClangdServer::typeHierarchy(PathRef File, Position Pos, int Resolve,
@@ -770,7 +770,7 @@
 CB(clangd:

[clang-tools-extra] cec62ae - [clangd] Fix buildbots without grpc enabled

2021-03-11 Thread Kadir Cetinkaya via cfe-commits

Author: Kadir Cetinkaya
Date: 2021-03-11T13:46:52+01:00
New Revision: cec62ae28a5fc5698a1b720a67187972c8e125cb

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

LOG: [clangd] Fix buildbots without grpc enabled

Added: 


Modified: 
clang-tools-extra/clangd/tool/ClangdMain.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/tool/ClangdMain.cpp 
b/clang-tools-extra/clangd/tool/ClangdMain.cpp
index eca30eec3679..ad8d3c928b3c 100644
--- a/clang-tools-extra/clangd/tool/ClangdMain.cpp
+++ b/clang-tools-extra/clangd/tool/ClangdMain.cpp
@@ -609,6 +609,7 @@ class FlagsConfigProvider : public config::Provider {
   Spec.Location = IndexFile;
   IndexSpec = std::move(Spec);
 }
+#if CLANGD_ENABLE_REMOTE
 if (!RemoteIndexAddress.empty()) {
   assert(!ProjectRoot.empty() && IndexFile.empty());
   Config::ExternalIndexSpec Spec;
@@ -618,6 +619,7 @@ class FlagsConfigProvider : public config::Provider {
   IndexSpec = std::move(Spec);
   BGPolicy = Config::BackgroundPolicy::Skip;
 }
+#endif
 if (!EnableBackgroundIndex) {
   BGPolicy = Config::BackgroundPolicy::Skip;
 }



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


[PATCH] D98415: [aarch64][WOA64][docs] Release note for WoA-hosted LLVM 12 binary

2021-03-11 Thread Maxim Kuvyrkov via Phabricator via cfe-commits
maxim-kuvyrkov created this revision.
maxim-kuvyrkov added reviewers: richard.townsend.arm, tstellar.
Herald added subscribers: danielkiss, kristof.beyls.
maxim-kuvyrkov requested review of this revision.
Herald added a reviewer: jdoerfert.
Herald added subscribers: cfe-commits, sstefan1.
Herald added a project: clang.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D98415

Files:
  clang/docs/ReleaseNotes.rst


Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -183,6 +183,13 @@
   exception. To workaround (with reduced security), compile with
   /guard:cf,nolongjmp.
 
+- Windows on Arm64: LLVM 12 adds official binary release hosted on
+  Windows on Arm64.  The binary is built and tested by Linaro alongside
+  AArch64 and ARM 32-bit Linux binary releases.  This first WoA release
+  includes Clang compiler, LLD Linker, and compiler-rt runtime libraries.
+  Work on LLDB, sanitizer support, OpenMP, and other features is in progress
+  and will be included in future Windows on Arm64 LLVM releases.
+
 C Language Changes in Clang
 ---
 


Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -183,6 +183,13 @@
   exception. To workaround (with reduced security), compile with
   /guard:cf,nolongjmp.
 
+- Windows on Arm64: LLVM 12 adds official binary release hosted on
+  Windows on Arm64.  The binary is built and tested by Linaro alongside
+  AArch64 and ARM 32-bit Linux binary releases.  This first WoA release
+  includes Clang compiler, LLD Linker, and compiler-rt runtime libraries.
+  Work on LLDB, sanitizer support, OpenMP, and other features is in progress
+  and will be included in future Windows on Arm64 LLVM releases.
+
 C Language Changes in Clang
 ---
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D98341: [analyzer][solver] Prevent infeasible states (PR49490)

2021-03-11 Thread Balázs Benics via Phabricator via cfe-commits
steakhal added inline comments.



Comment at: clang/test/Analysis/PR49490.cpp:12
+
+int *ints;
+int oob_access();

I think you can remove this line.
We already have a global variable to be invalidated by the evaluation of 
`oob_access()` call.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98341

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


[PATCH] D98341: [analyzer][solver] Prevent infeasible states (PR49490)

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

Remove unused global variable from the test


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98341

Files:
  clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
  clang/test/Analysis/PR49490.cpp


Index: clang/test/Analysis/PR49490.cpp
===
--- /dev/null
+++ clang/test/Analysis/PR49490.cpp
@@ -0,0 +1,30 @@
+// RUN: %clang_analyze_cc1 -w -analyzer-checker=core -verify %s
+
+// expected-no-diagnostics
+
+struct toggle {
+  bool value;
+};
+
+toggle global_toggle;
+toggle get_global_toggle() { return global_toggle; }
+
+int oob_access();
+
+bool compare(toggle one, bool other) {
+  if (one.value != other)
+return true;
+
+  if (one.value)
+oob_access();
+  return true;
+}
+
+bool coin();
+
+void bar() {
+  bool left = coin();
+  bool right = coin();
+  for (;;)
+compare(get_global_toggle(), left) && compare(get_global_toggle(), right);
+}
Index: clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
===
--- clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
+++ clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
@@ -19,6 +19,8 @@
 #include "clang/StaticAnalyzer/Core/PathSensitive/SValVisitor.h"
 #include "llvm/ADT/FoldingSet.h"
 #include "llvm/ADT/ImmutableSet.h"
+#include "llvm/ADT/STLExtras.h"
+#include "llvm/Support/Compiler.h"
 #include "llvm/Support/raw_ostream.h"
 
 using namespace clang;
@@ -1395,12 +1397,23 @@
 return EquivalenceClass::merge(getBasicVals(), F, State, LHS, RHS);
   }
 
-  LLVM_NODISCARD inline ProgramStateRef setConstraint(ProgramStateRef State,
-  EquivalenceClass Class,
-  RangeSet Constraint) {
+  LLVM_NODISCARD LLVM_ATTRIBUTE_UNUSED static bool
+  areFeasible(ConstraintRangeTy Constraints) {
+return llvm::none_of(
+Constraints,
+[](const std::pair &ClassConstraint) {
+  return ClassConstraint.second.isEmpty();
+});
+  }
+
+  LLVM_NODISCARD ProgramStateRef setConstraint(ProgramStateRef State,
+   EquivalenceClass Class,
+   RangeSet Constraint) {
 ConstraintRangeTy Constraints = State->get();
 ConstraintRangeTy::Factory &CF = State->get_context();
 
+assert(!Constraint.isEmpty() && "New constraint should not be empty");
+
 // Add new constraint.
 Constraints = CF.add(Constraints, Class, Constraint);
 
@@ -1413,9 +1426,18 @@
   for (EquivalenceClass DisequalClass : Class.getDisequalClasses(State)) {
 RangeSet UpdatedConstraint =
 getRange(State, DisequalClass).Delete(getBasicVals(), F, *Point);
+
+// If we end up with at least one of the disequal classes to be
+// constrainted with an empty range-set, the state is infeasible.
+if (UpdatedConstraint.isEmpty())
+  return nullptr;
+
 Constraints = CF.add(Constraints, DisequalClass, UpdatedConstraint);
   }
 
+assert(areFeasible(Constraints) && "Constraint manager shouldn't produce "
+   "a state with infeasible constraints");
+
 return State->set(Constraints);
   }
 


Index: clang/test/Analysis/PR49490.cpp
===
--- /dev/null
+++ clang/test/Analysis/PR49490.cpp
@@ -0,0 +1,30 @@
+// RUN: %clang_analyze_cc1 -w -analyzer-checker=core -verify %s
+
+// expected-no-diagnostics
+
+struct toggle {
+  bool value;
+};
+
+toggle global_toggle;
+toggle get_global_toggle() { return global_toggle; }
+
+int oob_access();
+
+bool compare(toggle one, bool other) {
+  if (one.value != other)
+return true;
+
+  if (one.value)
+oob_access();
+  return true;
+}
+
+bool coin();
+
+void bar() {
+  bool left = coin();
+  bool right = coin();
+  for (;;)
+compare(get_global_toggle(), left) && compare(get_global_toggle(), right);
+}
Index: clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
===
--- clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
+++ clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
@@ -19,6 +19,8 @@
 #include "clang/StaticAnalyzer/Core/PathSensitive/SValVisitor.h"
 #include "llvm/ADT/FoldingSet.h"
 #include "llvm/ADT/ImmutableSet.h"
+#include "llvm/ADT/STLExtras.h"
+#include "llvm/Support/Compiler.h"
 #include "llvm/Support/raw_ostream.h"
 
 using namespace clang;
@@ -1395,12 +1397,23 @@
 return EquivalenceClass::merge(getBasicVals(), F, State, LHS, RHS);
   }
 
-  LLVM_NODISCARD inline ProgramStateRef setConstraint(ProgramStateRef State,
-  EquivalenceClass Class

[PATCH] D98416: [clang-tidy] Fix cppcoreguidelines-narrowing-conversions false positive

2021-03-11 Thread Nathan James via Phabricator via cfe-commits
njames93 created this revision.
njames93 added reviewers: alexfh, aaron.ballman.
Herald added subscribers: shchenz, kbarton, xazax.hun, nemanjai.
njames93 requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Fix https://llvm.org/PR49498.
The check notices 2 sides of a conditional operator have types with a different 
constness and so tries to examine the implicit cast.
As one side is infinity, the float narrowing detection sees when its casted to 
a double(which it already was) it thinks the result is out of range.

I've fixed this by just disregarding expressions where the builtin type(without 
quals) match as no conversion would take place.

However this has opened a can of worms. Currenty `float a = 
std::numeric_limits::infinity();` is marked as narrowing.
Whats more suspicious is `double a = std::numeric_limits::infinity();` 
is also marked as narrowing.
It could be argued `double inf -> float inf` is narrowing, but `float inf -> 
double inf` definitely isnt.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D98416

Files:
  clang-tools-extra/clang-tidy/cppcoreguidelines/NarrowingConversionsCheck.cpp
  
clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-narrowing-conversions-narrowingfloatingpoint-option.cpp


Index: 
clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-narrowing-conversions-narrowingfloatingpoint-option.cpp
===
--- 
clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-narrowing-conversions-narrowingfloatingpoint-option.cpp
+++ 
clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-narrowing-conversions-narrowingfloatingpoint-option.cpp
@@ -54,4 +54,11 @@
   f = __builtin_nan("0"); // double NaN is not narrowing.
 }
 
+double false_positive_const_qualified_cast(bool t) {
+  double b = 1.0;
+  constexpr double a = __builtin_huge_val();
+  // PR49498 The constness difference of 'a' and 'b' results in an implicit 
cast.
+  return t ? b : a;
+}
+
 } // namespace floats
Index: 
clang-tools-extra/clang-tidy/cppcoreguidelines/NarrowingConversionsCheck.cpp
===
--- clang-tools-extra/clang-tidy/cppcoreguidelines/NarrowingConversionsCheck.cpp
+++ clang-tools-extra/clang-tidy/cppcoreguidelines/NarrowingConversionsCheck.cpp
@@ -369,6 +369,8 @@
   const BuiltinType *RhsType = getBuiltinType(Rhs);
   if (RhsType == nullptr || LhsType == nullptr)
 return;
+  if (LhsType == RhsType)
+return;
   if (RhsType->getKind() == BuiltinType::Bool && LhsType->isSignedInteger())
 return handleBooleanToSignedIntegral(Context, SourceLoc, Lhs, Rhs);
   if (RhsType->isInteger() && LhsType->getKind() == BuiltinType::Bool)
@@ -408,6 +410,8 @@
   const Expr &Rhs = *Cast.getSubExpr();
   if (Lhs.isInstantiationDependent() || Rhs.isInstantiationDependent())
 return;
+  if (getBuiltinType(Lhs) == getBuiltinType(Rhs))
+return;
   if (handleConditionalOperator(Context, Lhs, Rhs))
 return;
   SourceLocation SourceLoc = Lhs.getExprLoc();


Index: clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-narrowing-conversions-narrowingfloatingpoint-option.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-narrowing-conversions-narrowingfloatingpoint-option.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-narrowing-conversions-narrowingfloatingpoint-option.cpp
@@ -54,4 +54,11 @@
   f = __builtin_nan("0"); // double NaN is not narrowing.
 }
 
+double false_positive_const_qualified_cast(bool t) {
+  double b = 1.0;
+  constexpr double a = __builtin_huge_val();
+  // PR49498 The constness difference of 'a' and 'b' results in an implicit cast.
+  return t ? b : a;
+}
+
 } // namespace floats
Index: clang-tools-extra/clang-tidy/cppcoreguidelines/NarrowingConversionsCheck.cpp
===
--- clang-tools-extra/clang-tidy/cppcoreguidelines/NarrowingConversionsCheck.cpp
+++ clang-tools-extra/clang-tidy/cppcoreguidelines/NarrowingConversionsCheck.cpp
@@ -369,6 +369,8 @@
   const BuiltinType *RhsType = getBuiltinType(Rhs);
   if (RhsType == nullptr || LhsType == nullptr)
 return;
+  if (LhsType == RhsType)
+return;
   if (RhsType->getKind() == BuiltinType::Bool && LhsType->isSignedInteger())
 return handleBooleanToSignedIntegral(Context, SourceLoc, Lhs, Rhs);
   if (RhsType->isInteger() && LhsType->getKind() == BuiltinType::Bool)
@@ -408,6 +410,8 @@
   const Expr &Rhs = *Cast.getSubExpr();
   if (Lhs.isInstantiationDependent() || Rhs.isInstantiationDependent())
 return;
+  if (getBuiltinType(Lhs) == getBuiltinType(Rhs))
+return;
   if (handleConditionalOperator(Context, Lhs, Rhs))
 return;
   SourceLocation SourceLoc = Lhs.getExprLoc();
___
cfe-commits mailing

[PATCH] D95244: [clang][AST] Handle overload callee type in CallExpr::getCallReturnType.

2021-03-11 Thread Gabor Marton via Phabricator via cfe-commits
martong added reviewers: aaron.ballman, riccibruno, dblaikie.
martong added subscribers: aaron.ballman, dblaikie.
martong added a comment.

Hi @aaron.ballman @riccibruno @dblaikie, I am adding you as a reviewer because 
it seems you have great experience with Clang's AST.
Could you please take a look on this patch? The problem is that we currently do 
not handle a CallExpr's return type properly in case of a dependent context. 
This seems to be a flaw in the implementation of CallExpr.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95244

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


[clang] 1fd4bee - [flang][driver] Add -fdebug-module-writer option

2021-03-11 Thread Arnamoy Bhattacharyya via cfe-commits

Author: Arnamoy Bhattacharyya
Date: 2021-03-11T08:04:37-05:00
New Revision: 1fd4beecc8bb1148123265a63e0bff92b626c4a3

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

LOG: [flang][driver] Add -fdebug-module-writer option

Added: 


Modified: 
clang/include/clang/Driver/Options.td
clang/lib/Driver/ToolChains/Flang.cpp
flang/include/flang/Frontend/CompilerInvocation.h
flang/lib/Frontend/CompilerInvocation.cpp
flang/lib/Frontend/FrontendActions.cpp
flang/test/Driver/driver-help.f90
flang/test/Semantics/mod-file-rewriter.f90

Removed: 




diff  --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index 376a3baf0a4b..f4d4ece9baeb 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -4367,6 +4367,8 @@ def fdebug_measure_parse_tree : Flag<["-"], 
"fdebug-measure-parse-tree">, Group<
   HelpText<"Measure the parse tree">;
 def fdebug_pre_fir_tree : Flag<["-"], "fdebug-pre-fir-tree">, 
Group,
   HelpText<"Dump the pre-FIR tree">;
+def fdebug_module_writer : Flag<["-"],"fdebug-module-writer">, 
+  HelpText<"Enable debug messages while writing module files">;
 
 }
 

diff  --git a/clang/lib/Driver/ToolChains/Flang.cpp 
b/clang/lib/Driver/ToolChains/Flang.cpp
index 1a812589d473..153a1dfc8592 100644
--- a/clang/lib/Driver/ToolChains/Flang.cpp
+++ b/clang/lib/Driver/ToolChains/Flang.cpp
@@ -41,7 +41,8 @@ void Flang::AddPreprocessingOptions(const ArgList &Args,
 }
 
 void Flang::AddOtherOptions(const ArgList &Args, ArgStringList &CmdArgs) const 
{
-  Args.AddAllArgs(CmdArgs, options::OPT_module_dir);
+  Args.AddAllArgs(CmdArgs,
+  {options::OPT_module_dir, 
options::OPT_fdebug_module_writer});
 }
 
 void Flang::ConstructJob(Compilation &C, const JobAction &JA,

diff  --git a/flang/include/flang/Frontend/CompilerInvocation.h 
b/flang/include/flang/Frontend/CompilerInvocation.h
index 9946f3e4a6e6..3be6f3fc4d40 100644
--- a/flang/include/flang/Frontend/CompilerInvocation.h
+++ b/flang/include/flang/Frontend/CompilerInvocation.h
@@ -69,6 +69,8 @@ class CompilerInvocation : public CompilerInvocationBase {
   // of options.
   std::string moduleDir_ = ".";
 
+  bool debugModuleDir_ = false;
+
   // Fortran Dialect options
   Fortran::common::IntrinsicTypeDefaultKinds defaultKinds_;
 
@@ -91,6 +93,9 @@ class CompilerInvocation : public CompilerInvocationBase {
   std::string &moduleDir() { return moduleDir_; }
   const std::string &moduleDir() const { return moduleDir_; }
 
+  bool &debugModuleDir() { return debugModuleDir_; }
+  const bool &debugModuleDir() const { return debugModuleDir_; }
+
   Fortran::common::IntrinsicTypeDefaultKinds &defaultKinds() {
 return defaultKinds_;
   }
@@ -106,6 +111,11 @@ class CompilerInvocation : public CompilerInvocationBase {
   llvm::ArrayRef commandLineArgs,
   clang::DiagnosticsEngine &diags);
 
+  /// Useful setters
+  void SetModuleDir(std::string &moduleDir) { moduleDir_ = moduleDir; }
+
+  void SetDebugModuleDir(bool flag) { debugModuleDir_ = 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

diff  --git a/flang/lib/Frontend/CompilerInvocation.cpp 
b/flang/lib/Frontend/CompilerInvocation.cpp
index 17649700e0d2..1271cd314831 100644
--- a/flang/lib/Frontend/CompilerInvocation.cpp
+++ b/flang/lib/Frontend/CompilerInvocation.cpp
@@ -306,9 +306,10 @@ static void parsePreprocessorArgs(
 
 /// Parses all semantic related arguments and populates the variables
 /// options accordingly.
-static void parseSemaArgs(std::string &moduleDir, llvm::opt::ArgList &args,
+static void parseSemaArgs(CompilerInvocation &res, llvm::opt::ArgList &args,
 clang::DiagnosticsEngine &diags) {
 
+  // -J/module-dir option
   auto moduleDirList =
   args.getAllArgValues(clang::driver::options::OPT_module_dir);
   // User can only specify -J/-module-dir once
@@ -320,7 +321,12 @@ static void parseSemaArgs(std::string &moduleDir, 
llvm::opt::ArgList &args,
 diags.Report(diagID);
   }
   if (moduleDirList.size() == 1)
-moduleDir = moduleDirList[0];
+res.SetModuleDir(moduleDirList[0]);
+
+  // -fdebug-module-writer option
+  if (args.hasArg(clang::driver::options::OPT_fdebug_module_writer)) {
+res.SetDebugModuleDir(true);
+  }
 }
 
 /// Parses all Dialect related arguments and populates the variables
@@ -395,7 +401,7 @@ bool CompilerInvocation::CreateFromArgs(CompilerInvocation 
&res,
   // Parse the preprocessor args
   parsePreprocessorArgs(res.preprocessorOpts(), args);
   // Parse semantic args
-  parseSemaArgs(res.moduleDir(), args, diags);
+  parseSemaArgs(res, args, diags);
   // Parse d

[PATCH] D98242: [clangd] Store system relative includes as verbatim

2021-03-11 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet updated this revision to Diff 329930.
kadircet added a comment.

- Rebase
- Add a storage for returned verbatim header spellings, as 
getHeaderIncludeUncached can only return a ref.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98242

Files:
  clang-tools-extra/clangd/index/SymbolCollector.cpp
  clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp


Index: clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp
===
--- clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp
+++ clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp
@@ -1446,6 +1446,20 @@
   UnorderedElementsAre(IncludeHeaderWithRef(TestHeaderURI, 1u)));
 }
 
+TEST_F(SymbolCollectorTest, IncludeHeaderFromSystemIsVerbatim) {
+  llvm::StringRef HeaderName = "header.h";
+  TestHeaderName = testPath(HeaderName);
+  TestHeaderURI = URI::create(TestHeaderName).toString();
+  CollectorOpts.CollectIncludePath = true;
+  runSymbolCollector("#pragma once\nclass Foo {};", /*Main=*/"",
+ {"-isystem", testRoot()});
+  EXPECT_THAT(Symbols, UnorderedElementsAre(
+   AllOf(QName("Foo"), DeclURI(TestHeaderURI;
+  EXPECT_THAT(Symbols.begin()->IncludeHeaders,
+  UnorderedElementsAre(
+  IncludeHeaderWithRef("<" + HeaderName.str() + ">", 1u)));
+}
+
 TEST_F(SymbolCollectorTest, CanonicalSTLHeader) {
   CollectorOpts.CollectIncludePath = true;
   CanonicalIncludes Includes;
Index: clang-tools-extra/clangd/index/SymbolCollector.cpp
===
--- clang-tools-extra/clangd/index/SymbolCollector.cpp
+++ clang-tools-extra/clangd/index/SymbolCollector.cpp
@@ -35,6 +35,7 @@
 #include "llvm/Support/FileSystem.h"
 #include "llvm/Support/MemoryBuffer.h"
 #include "llvm/Support/Path.h"
+#include 
 
 namespace clang {
 namespace clangd {
@@ -167,6 +168,7 @@
   llvm::StringRef FallbackDir;
   llvm::DenseMap CacheFEToURI;
   llvm::StringMap CachePathToURI;
+  std::list StorageForSystemHeaders;
   llvm::DenseMap CacheFIDToInclude;
 
 public:
@@ -250,6 +252,18 @@
   // Conservatively refuse to insert #includes to files without guards.
   return "";
 }
+// Store system includes as verbatim. This enables making use of the same
+// index in different environments, e.g. a system header like 
+// might resolve to different absolute paths, but the path relative to
+// sysroot will be the same.
+bool IsSystem = false;
+auto ShorterInclude =
+PP->getHeaderSearchInfo().suggestPathToFileForDiagnostics(FE, "",
+  &IsSystem);
+if (IsSystem) {
+  StorageForSystemHeaders.push_back("<" + ShorterInclude + ">");
+  return StorageForSystemHeaders.back();
+}
 // Standard case: just insert the file itself.
 return toURI(FE);
   }


Index: clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp
===
--- clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp
+++ clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp
@@ -1446,6 +1446,20 @@
   UnorderedElementsAre(IncludeHeaderWithRef(TestHeaderURI, 1u)));
 }
 
+TEST_F(SymbolCollectorTest, IncludeHeaderFromSystemIsVerbatim) {
+  llvm::StringRef HeaderName = "header.h";
+  TestHeaderName = testPath(HeaderName);
+  TestHeaderURI = URI::create(TestHeaderName).toString();
+  CollectorOpts.CollectIncludePath = true;
+  runSymbolCollector("#pragma once\nclass Foo {};", /*Main=*/"",
+ {"-isystem", testRoot()});
+  EXPECT_THAT(Symbols, UnorderedElementsAre(
+   AllOf(QName("Foo"), DeclURI(TestHeaderURI;
+  EXPECT_THAT(Symbols.begin()->IncludeHeaders,
+  UnorderedElementsAre(
+  IncludeHeaderWithRef("<" + HeaderName.str() + ">", 1u)));
+}
+
 TEST_F(SymbolCollectorTest, CanonicalSTLHeader) {
   CollectorOpts.CollectIncludePath = true;
   CanonicalIncludes Includes;
Index: clang-tools-extra/clangd/index/SymbolCollector.cpp
===
--- clang-tools-extra/clangd/index/SymbolCollector.cpp
+++ clang-tools-extra/clangd/index/SymbolCollector.cpp
@@ -35,6 +35,7 @@
 #include "llvm/Support/FileSystem.h"
 #include "llvm/Support/MemoryBuffer.h"
 #include "llvm/Support/Path.h"
+#include 
 
 namespace clang {
 namespace clangd {
@@ -167,6 +168,7 @@
   llvm::StringRef FallbackDir;
   llvm::DenseMap CacheFEToURI;
   llvm::StringMap CachePathToURI;
+  std::list StorageForSystemHeaders;
   llvm::DenseMap CacheFIDToInclude;
 
 public:
@@ -250,6 +252,18 @@
   // Conservatively refuse to insert #includes to files without guards.
   return "";
 }
+// Store system includes as verbatim. This enables 

[PATCH] D98364: [clangd] Use ref counted strings throughout for File Contents

2021-03-11 Thread Nathan James via Phabricator via cfe-commits
njames93 updated this revision to Diff 329933.
njames93 marked 4 inline comments as done.
njames93 added a comment.

Remove some unneeded changes.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98364

Files:
  clang-tools-extra/clangd/ClangdLSPServer.cpp
  clang-tools-extra/clangd/ClangdServer.cpp
  clang-tools-extra/clangd/CodeComplete.cpp
  clang-tools-extra/clangd/Compiler.h
  clang-tools-extra/clangd/DraftStore.cpp
  clang-tools-extra/clangd/DraftStore.h
  clang-tools-extra/clangd/ParsedAST.cpp
  clang-tools-extra/clangd/Preamble.cpp
  clang-tools-extra/clangd/TUScheduler.cpp
  clang-tools-extra/clangd/TUScheduler.h
  clang-tools-extra/clangd/tool/Check.cpp
  clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
  clang-tools-extra/clangd/unittests/DraftStoreTests.cpp
  clang-tools-extra/clangd/unittests/FileIndexTests.cpp
  clang-tools-extra/clangd/unittests/TUSchedulerTests.cpp
  clang-tools-extra/clangd/unittests/TestTU.cpp

Index: clang-tools-extra/clangd/unittests/TestTU.cpp
===
--- clang-tools-extra/clangd/unittests/TestTU.cpp
+++ clang-tools-extra/clangd/unittests/TestTU.cpp
@@ -54,7 +54,7 @@
   Argv.push_back(FullFilename);
   Inputs.CompileCommand.Filename = FullFilename;
   Inputs.CompileCommand.Directory = testRoot();
-  Inputs.Contents = Code;
+  Inputs.Contents = std::make_shared(Code);
   if (OverlayRealFileSystemForModules)
 FS.OverlayRealFileSystemForModules = true;
   Inputs.TFS = &FS;
Index: clang-tools-extra/clangd/unittests/TUSchedulerTests.cpp
===
--- clang-tools-extra/clangd/unittests/TUSchedulerTests.cpp
+++ clang-tools-extra/clangd/unittests/TUSchedulerTests.cpp
@@ -93,7 +93,7 @@
 ParseInputs Inputs;
 Inputs.CompileCommand = *CDB.getCompileCommand(File);
 Inputs.TFS = &FS;
-Inputs.Contents = std::move(Contents);
+Inputs.Contents = std::make_shared(std::move(Contents));
 Inputs.Opts = ParseOptions();
 return Inputs;
   }
@@ -528,7 +528,7 @@
 EXPECT_EQ(File, boundPath());
 
 ASSERT_TRUE((bool)AST);
-EXPECT_EQ(AST->Inputs.Contents, Inputs.Contents);
+EXPECT_EQ(*AST->Inputs.Contents, *Inputs.Contents);
 EXPECT_EQ(AST->Inputs.Version, Inputs.Version);
 EXPECT_EQ(AST->AST.version(), Inputs.Version);
 
@@ -548,7 +548,7 @@
 EXPECT_EQ(File, boundPath());
 
 ASSERT_TRUE((bool)Preamble);
-EXPECT_EQ(Preamble->Contents, Inputs.Contents);
+EXPECT_EQ(*Preamble->Contents, *Inputs.Contents);
 
 std::lock_guard Lock(Mut);
 ++TotalPreambleReads;
Index: clang-tools-extra/clangd/unittests/FileIndexTests.cpp
===
--- clang-tools-extra/clangd/unittests/FileIndexTests.cpp
+++ clang-tools-extra/clangd/unittests/FileIndexTests.cpp
@@ -295,12 +295,12 @@
   )cpp";
   PI.TFS = &FS;
 
-  PI.Contents = R"cpp(
+  PI.Contents = std::make_shared(R"cpp(
 #include "foo.h"
 namespace ns_in_source {
   int func_in_source();
 }
-  )cpp";
+  )cpp");
 
   // Rebuild the file.
   IgnoreDiagnostics IgnoreDiags;
Index: clang-tools-extra/clangd/unittests/DraftStoreTests.cpp
===
--- clang-tools-extra/clangd/unittests/DraftStoreTests.cpp
+++ clang-tools-extra/clangd/unittests/DraftStoreTests.cpp
@@ -22,20 +22,21 @@
   DraftStore DS;
   Path File = "foo.cpp";
 
-  EXPECT_EQ("25", DS.addDraft(File, "25", ""));
+  EXPECT_EQ("25", DS.addDraft(File, "25", std::make_shared("")));
   EXPECT_EQ("25", DS.getDraft(File)->Version);
   EXPECT_EQ("", *DS.getDraft(File)->Contents);
 
-  EXPECT_EQ("26", DS.addDraft(File, "", "x"));
+  EXPECT_EQ("26", DS.addDraft(File, "", std::make_shared("x")));
   EXPECT_EQ("26", DS.getDraft(File)->Version);
   EXPECT_EQ("x", *DS.getDraft(File)->Contents);
 
-  EXPECT_EQ("27", DS.addDraft(File, "", "x")) << "no-op change";
+  EXPECT_EQ("27", DS.addDraft(File, "", std::make_shared("x")))
+  << "no-op change";
   EXPECT_EQ("27", DS.getDraft(File)->Version);
   EXPECT_EQ("x", *DS.getDraft(File)->Contents);
 
   // We allow versions to go backwards.
-  EXPECT_EQ("7", DS.addDraft(File, "7", "y"));
+  EXPECT_EQ("7", DS.addDraft(File, "7", std::make_shared("y")));
   EXPECT_EQ("7", DS.getDraft(File)->Version);
   EXPECT_EQ("y", *DS.getDraft(File)->Contents);
 }
Index: clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
===
--- clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
+++ clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
@@ -153,7 +153,8 @@
 
   MockFS FS;
   Annotations Test(Text);
-  ParseInputs ParseInput{tooling::CompileCommand(), &FS, Test.

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

2021-03-11 Thread Stelios Ioannou via Phabricator via cfe-commits
stelios-arm updated this revision to Diff 329931.
stelios-arm marked an inline comment as done.
stelios-arm added a comment.

1. Addressed the comment made by @SjoerdMeijer and added the comment for the 
MRS instruction.
2. Added the `+rang` feature in `arm_acle.c `




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
  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,38 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
+; RUN: llc -mtriple=aarch64 -mcpu=neoverse-v1 -mattr=+rand %s -o - | FileCheck %s
+
+define  i32 @rndr(i64* %__addr) {
+; CHECK-LABEL: rndr:
+; CHECK:   // %bb.0:
+; CHECK-NEXT:mrs x8, RNDR
+; CHECK-NEXT:cset w9, eq
+; CHECK-NEXT:str x8, [x0]
+; CHECK-NEXT:and w0, w9, #0x1
+; 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 x8, RNDRRS
+; CHECK-NEXT:cset w9, eq
+; CHECK-NEXT:str x8, [x0]
+; CHECK-NEXT:and w0, w9, #0x1
+; 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,10 @@
 def AArch64stnp : SDNode<"AArch64ISD::STNP", SDT_AArch64stnp, [SDNPHasChain, SDNPMayStore, SDNPMemOperand]>;
 
 def AArch64tbl : SDNode<"AArch64ISD::TBL", SDT_AArch64TBL>;
-
+// MRS from CodeGen.
+def AArch64mrs : SDNode<"AArch64ISD::MRS",
+SDTypeProfile<1, 1, [SDTCisVT<0, i64>, SDTCisVT<1, i32>]>,
+[SDNPHasChain, SDNPOutGlue]>;
 //===

[clang] 46354ba - [OpaquePtrs] Remove some uses of type-less CreateLoad APIs (NFC)

2021-03-11 Thread Nikita Popov via cfe-commits

Author: Nikita Popov
Date: 2021-03-11T14:40:57+01:00
New Revision: 46354bac76f60e988537181b3609a8e3ac89f523

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

LOG: [OpaquePtrs] Remove some uses of type-less CreateLoad APIs (NFC)

Explicitly pass loaded type when creating loads, in preparation
for the deprecation of these APIs.

There are still a couple of uses left.

Added: 


Modified: 
clang/lib/CodeGen/CGBuilder.h
clang/lib/CodeGen/CGBuiltin.cpp
clang/lib/CodeGen/CGCXX.cpp
clang/lib/CodeGen/CodeGenFunction.h
llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
llvm/lib/Target/AMDGPU/AMDGPULateCodeGenPrepare.cpp
llvm/lib/Transforms/Scalar/LowerMatrixIntrinsics.cpp
llvm/lib/Transforms/Utils/AMDGPUEmitPrintf.cpp
polly/lib/CodeGen/IslNodeBuilder.cpp
polly/lib/CodeGen/LoopGenerators.cpp
polly/lib/CodeGen/LoopGeneratorsGOMP.cpp
polly/lib/CodeGen/LoopGeneratorsKMP.cpp
polly/lib/CodeGen/PerfMonitor.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/CGBuilder.h b/clang/lib/CodeGen/CGBuilder.h
index 320278eac124..4e22db67c57e 100644
--- a/clang/lib/CodeGen/CGBuilder.h
+++ b/clang/lib/CodeGen/CGBuilder.h
@@ -66,19 +66,20 @@ class CGBuilderTy : public CGBuilderBaseTy {
   // Note that we intentionally hide the CreateLoad APIs that don't
   // take an alignment.
   llvm::LoadInst *CreateLoad(Address Addr, const llvm::Twine &Name = "") {
-return CreateAlignedLoad(Addr.getPointer(),
+return CreateAlignedLoad(Addr.getElementType(), Addr.getPointer(),
  Addr.getAlignment().getAsAlign(), Name);
   }
   llvm::LoadInst *CreateLoad(Address Addr, const char *Name) {
 // This overload is required to prevent string literals from
 // ending up in the IsVolatile overload.
-return CreateAlignedLoad(Addr.getPointer(),
+return CreateAlignedLoad(Addr.getElementType(), Addr.getPointer(),
  Addr.getAlignment().getAsAlign(), Name);
   }
   llvm::LoadInst *CreateLoad(Address Addr, bool IsVolatile,
  const llvm::Twine &Name = "") {
-return CreateAlignedLoad(
-Addr.getPointer(), Addr.getAlignment().getAsAlign(), IsVolatile, Name);
+return CreateAlignedLoad(Addr.getElementType(), Addr.getPointer(),
+ Addr.getAlignment().getAsAlign(), IsVolatile,
+ Name);
   }
 
   using CGBuilderBaseTy::CreateAlignedLoad;

diff  --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp
index 44bd151093cc..a3a33e46583b 100644
--- a/clang/lib/CodeGen/CGBuiltin.cpp
+++ b/clang/lib/CodeGen/CGBuiltin.cpp
@@ -14663,11 +14663,12 @@ Value *CodeGenFunction::EmitX86BuiltinExpr(unsigned 
BuiltinID,
   break;
 }
 
+llvm::Type *Ty = FixedVectorType::get(Builder.getInt64Ty(), 2);
 Value *InOps[9];
 InOps[0] = Ops[2];
 for (int i = 0; i != 8; ++i) {
   Value *Ptr = Builder.CreateConstGEP1_32(Ops[1], i);
-  InOps[i + 1] = Builder.CreateAlignedLoad(Ptr, Align(16));
+  InOps[i + 1] = Builder.CreateAlignedLoad(Ty, Ptr, Align(16));
 }
 
 Value *Call = Builder.CreateCall(CGM.getIntrinsic(IID), InOps);

diff  --git a/clang/lib/CodeGen/CGCXX.cpp b/clang/lib/CodeGen/CGCXX.cpp
index a4bd2c6d5da0..641740c37a68 100644
--- a/clang/lib/CodeGen/CGCXX.cpp
+++ b/clang/lib/CodeGen/CGCXX.cpp
@@ -252,8 +252,8 @@ static CGCallee BuildAppleKextVirtualCall(CodeGenFunction 
&CGF,
  "No kext in Microsoft ABI");
   CodeGenModule &CGM = CGF.CGM;
   llvm::Value *VTable = CGM.getCXXABI().getAddrOfVTable(RD, CharUnits());
-  Ty = Ty->getPointerTo()->getPointerTo();
-  VTable = CGF.Builder.CreateBitCast(VTable, Ty);
+  Ty = Ty->getPointerTo();
+  VTable = CGF.Builder.CreateBitCast(VTable, Ty->getPointerTo());
   assert(VTable && "BuildVirtualCall = kext vtbl pointer is null");
   uint64_t VTableIndex = 
CGM.getItaniumVTableContext().getMethodVTableIndex(GD);
   const VTableLayout &VTLayout = 
CGM.getItaniumVTableContext().getVTableLayout(RD);
@@ -264,7 +264,7 @@ static CGCallee BuildAppleKextVirtualCall(CodeGenFunction 
&CGF,
   llvm::Value *VFuncPtr =
 CGF.Builder.CreateConstInBoundsGEP1_64(VTable, VTableIndex, "vfnkxt");
   llvm::Value *VFunc = CGF.Builder.CreateAlignedLoad(
-  VFuncPtr, llvm::Align(CGF.PointerAlignInBytes));
+  Ty, VFuncPtr, llvm::Align(CGF.PointerAlignInBytes));
   CGCallee Callee(GD, VFunc);
   return Callee;
 }

diff  --git a/clang/lib/CodeGen/CodeGenFunction.h 
b/clang/lib/CodeGen/CodeGenFunction.h
index 98e8d5bb9efa..fc342bbdbd71 100644
--- a/clang/lib/CodeGen/CodeGenFunction.h
+++ b/clang/lib/CodeGen/CodeGenFunction.h
@@ -4807,7 +4807,8 @@ inline llvm::Value 
*DominatingLLVMValue::restore(CodeGenFunction &CGF,
 
   // Otherwise, it should be an alloca instr

[PATCH] D98364: [clangd] Use ref counted strings throughout for File Contents

2021-03-11 Thread Nathan James via Phabricator via cfe-commits
njames93 updated this revision to Diff 329939.
njames93 added a comment.

Remove other unnecessary ownership.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98364

Files:
  clang-tools-extra/clangd/ClangdLSPServer.cpp
  clang-tools-extra/clangd/ClangdServer.cpp
  clang-tools-extra/clangd/CodeComplete.cpp
  clang-tools-extra/clangd/Compiler.h
  clang-tools-extra/clangd/DraftStore.cpp
  clang-tools-extra/clangd/DraftStore.h
  clang-tools-extra/clangd/ParsedAST.cpp
  clang-tools-extra/clangd/Preamble.cpp
  clang-tools-extra/clangd/TUScheduler.cpp
  clang-tools-extra/clangd/TUScheduler.h
  clang-tools-extra/clangd/tool/Check.cpp
  clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
  clang-tools-extra/clangd/unittests/DraftStoreTests.cpp
  clang-tools-extra/clangd/unittests/FileIndexTests.cpp
  clang-tools-extra/clangd/unittests/TUSchedulerTests.cpp
  clang-tools-extra/clangd/unittests/TestTU.cpp

Index: clang-tools-extra/clangd/unittests/TestTU.cpp
===
--- clang-tools-extra/clangd/unittests/TestTU.cpp
+++ clang-tools-extra/clangd/unittests/TestTU.cpp
@@ -54,7 +54,7 @@
   Argv.push_back(FullFilename);
   Inputs.CompileCommand.Filename = FullFilename;
   Inputs.CompileCommand.Directory = testRoot();
-  Inputs.Contents = Code;
+  Inputs.Contents = std::make_shared(Code);
   if (OverlayRealFileSystemForModules)
 FS.OverlayRealFileSystemForModules = true;
   Inputs.TFS = &FS;
Index: clang-tools-extra/clangd/unittests/TUSchedulerTests.cpp
===
--- clang-tools-extra/clangd/unittests/TUSchedulerTests.cpp
+++ clang-tools-extra/clangd/unittests/TUSchedulerTests.cpp
@@ -93,7 +93,7 @@
 ParseInputs Inputs;
 Inputs.CompileCommand = *CDB.getCompileCommand(File);
 Inputs.TFS = &FS;
-Inputs.Contents = std::move(Contents);
+Inputs.Contents = std::make_shared(std::move(Contents));
 Inputs.Opts = ParseOptions();
 return Inputs;
   }
@@ -528,7 +528,7 @@
 EXPECT_EQ(File, boundPath());
 
 ASSERT_TRUE((bool)AST);
-EXPECT_EQ(AST->Inputs.Contents, Inputs.Contents);
+EXPECT_EQ(*AST->Inputs.Contents, *Inputs.Contents);
 EXPECT_EQ(AST->Inputs.Version, Inputs.Version);
 EXPECT_EQ(AST->AST.version(), Inputs.Version);
 
@@ -548,7 +548,7 @@
 EXPECT_EQ(File, boundPath());
 
 ASSERT_TRUE((bool)Preamble);
-EXPECT_EQ(Preamble->Contents, Inputs.Contents);
+EXPECT_EQ(*Preamble->Contents, *Inputs.Contents);
 
 std::lock_guard Lock(Mut);
 ++TotalPreambleReads;
Index: clang-tools-extra/clangd/unittests/FileIndexTests.cpp
===
--- clang-tools-extra/clangd/unittests/FileIndexTests.cpp
+++ clang-tools-extra/clangd/unittests/FileIndexTests.cpp
@@ -295,12 +295,12 @@
   )cpp";
   PI.TFS = &FS;
 
-  PI.Contents = R"cpp(
+  PI.Contents = std::make_shared(R"cpp(
 #include "foo.h"
 namespace ns_in_source {
   int func_in_source();
 }
-  )cpp";
+  )cpp");
 
   // Rebuild the file.
   IgnoreDiagnostics IgnoreDiags;
Index: clang-tools-extra/clangd/unittests/DraftStoreTests.cpp
===
--- clang-tools-extra/clangd/unittests/DraftStoreTests.cpp
+++ clang-tools-extra/clangd/unittests/DraftStoreTests.cpp
@@ -22,20 +22,21 @@
   DraftStore DS;
   Path File = "foo.cpp";
 
-  EXPECT_EQ("25", DS.addDraft(File, "25", ""));
+  EXPECT_EQ("25", DS.addDraft(File, "25", std::make_shared("")));
   EXPECT_EQ("25", DS.getDraft(File)->Version);
   EXPECT_EQ("", *DS.getDraft(File)->Contents);
 
-  EXPECT_EQ("26", DS.addDraft(File, "", "x"));
+  EXPECT_EQ("26", DS.addDraft(File, "", std::make_shared("x")));
   EXPECT_EQ("26", DS.getDraft(File)->Version);
   EXPECT_EQ("x", *DS.getDraft(File)->Contents);
 
-  EXPECT_EQ("27", DS.addDraft(File, "", "x")) << "no-op change";
+  EXPECT_EQ("27", DS.addDraft(File, "", std::make_shared("x")))
+  << "no-op change";
   EXPECT_EQ("27", DS.getDraft(File)->Version);
   EXPECT_EQ("x", *DS.getDraft(File)->Contents);
 
   // We allow versions to go backwards.
-  EXPECT_EQ("7", DS.addDraft(File, "7", "y"));
+  EXPECT_EQ("7", DS.addDraft(File, "7", std::make_shared("y")));
   EXPECT_EQ("7", DS.getDraft(File)->Version);
   EXPECT_EQ("y", *DS.getDraft(File)->Contents);
 }
Index: clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
===
--- clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
+++ clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
@@ -153,7 +153,8 @@
 
   MockFS FS;
   Annotations Test(Text);
-  ParseInputs ParseInput{tooling::CompileCommand(), &FS, Test.code().str()};
+  ParseInputs ParseIn

[PATCH] D98364: [clangd] Use ref counted strings throughout for File Contents

2021-03-11 Thread Nathan James via Phabricator via cfe-commits
njames93 added a comment.

I've cleaned some changes up a bit. I do agree its not as important as the 
dirty buffer case, but this is about uniformity as much as anything.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98364

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


[PATCH] D98418: [OpenCL] Remove mixed signedness atomic_fetch_ from opencl-c.h

2021-03-11 Thread Sven van Haastregt via Phabricator via cfe-commits
svenvh created this revision.
svenvh added reviewers: stuart, Anastasia.
svenvh added a project: clang.
Herald added subscribers: jfb, yaxunl.
svenvh requested review of this revision.
Herald added a subscriber: cfe-commits.

The OpenCL C specification v3.0.6 s6.15.12.7.5 mentions:

  For atomic_fetch and modify functions with key = or, xor, and, min
  and max on atomic type atomic_intptr_t, M is intptr_t, and on
  atomic type atomic_uintptr_t, M is uintptr_t.

Remove the atomic_fetch_* overloads from `opencl-c.h` that mix `intptr_t`
and `uintptr_t` in the same declaration.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D98418

Files:
  clang/lib/Headers/opencl-c.h


Index: clang/lib/Headers/opencl-c.h
===
--- clang/lib/Headers/opencl-c.h
+++ clang/lib/Headers/opencl-c.h
@@ -13393,7 +13393,6 @@
 
 // OpenCL v2.0 s6.13.11.7.5:
 // add/sub: atomic type argument can be uintptr_t/intptr_t, value type 
argument can be ptrdiff_t.
-// or/xor/and/min/max: atomic type argument can be intptr_t/uintptr_t, value 
type argument can be intptr_t/uintptr_t.
 
 #if defined(cl_khr_int64_base_atomics) && 
defined(cl_khr_int64_extended_atomics)
 uintptr_t __ovld atomic_fetch_add(volatile atomic_uintptr_t *object, ptrdiff_t 
operand);
@@ -13402,38 +13401,6 @@
 uintptr_t __ovld atomic_fetch_sub(volatile atomic_uintptr_t *object, ptrdiff_t 
operand);
 uintptr_t __ovld atomic_fetch_sub_explicit(volatile atomic_uintptr_t *object, 
ptrdiff_t operand, memory_order order);
 uintptr_t __ovld atomic_fetch_sub_explicit(volatile atomic_uintptr_t *object, 
ptrdiff_t operand, memory_order order, memory_scope scope);
-
-uintptr_t __ovld atomic_fetch_or(volatile atomic_uintptr_t *object, intptr_t 
operand);
-uintptr_t __ovld atomic_fetch_or_explicit(volatile atomic_uintptr_t *object, 
intptr_t operand, memory_order order);
-uintptr_t __ovld atomic_fetch_or_explicit(volatile atomic_uintptr_t *object, 
intptr_t operand, memory_order order, memory_scope scope);
-uintptr_t __ovld atomic_fetch_xor(volatile atomic_uintptr_t *object, intptr_t 
operand);
-uintptr_t __ovld atomic_fetch_xor_explicit(volatile atomic_uintptr_t *object, 
intptr_t operand, memory_order order);
-uintptr_t __ovld atomic_fetch_xor_explicit(volatile atomic_uintptr_t *object, 
intptr_t operand, memory_order order, memory_scope scope);
-uintptr_t __ovld atomic_fetch_and(volatile atomic_uintptr_t *object, intptr_t 
operand);
-uintptr_t __ovld atomic_fetch_and_explicit(volatile atomic_uintptr_t *object, 
intptr_t operand, memory_order order);
-uintptr_t __ovld atomic_fetch_and_explicit(volatile atomic_uintptr_t *object, 
intptr_t operand, memory_order order, memory_scope scope);
-uintptr_t __ovld atomic_fetch_min(volatile atomic_uintptr_t *object, intptr_t 
opermax);
-uintptr_t __ovld atomic_fetch_min_explicit(volatile atomic_uintptr_t *object, 
intptr_t opermax, memory_order minder);
-uintptr_t __ovld atomic_fetch_min_explicit(volatile atomic_uintptr_t *object, 
intptr_t opermax, memory_order minder, memory_scope scope);
-uintptr_t __ovld atomic_fetch_max(volatile atomic_uintptr_t *object, intptr_t 
opermax);
-uintptr_t __ovld atomic_fetch_max_explicit(volatile atomic_uintptr_t *object, 
intptr_t opermax, memory_order minder);
-uintptr_t __ovld atomic_fetch_max_explicit(volatile atomic_uintptr_t *object, 
intptr_t opermax, memory_order minder, memory_scope scope);
-
-intptr_t __ovld atomic_fetch_or(volatile atomic_intptr_t *object, uintptr_t 
operand);
-intptr_t __ovld atomic_fetch_or_explicit(volatile atomic_intptr_t *object, 
uintptr_t operand, memory_order order);
-intptr_t __ovld atomic_fetch_or_explicit(volatile atomic_intptr_t *object, 
uintptr_t operand, memory_order order, memory_scope scope);
-intptr_t __ovld atomic_fetch_xor(volatile atomic_intptr_t *object, uintptr_t 
operand);
-intptr_t __ovld atomic_fetch_xor_explicit(volatile atomic_intptr_t *object, 
uintptr_t operand, memory_order order);
-intptr_t __ovld atomic_fetch_xor_explicit(volatile atomic_intptr_t *object, 
uintptr_t operand, memory_order order, memory_scope scope);
-intptr_t __ovld atomic_fetch_and(volatile atomic_intptr_t *object, uintptr_t 
operand);
-intptr_t __ovld atomic_fetch_and_explicit(volatile atomic_intptr_t *object, 
uintptr_t operand, memory_order order);
-intptr_t __ovld atomic_fetch_and_explicit(volatile atomic_intptr_t *object, 
uintptr_t operand, memory_order order, memory_scope scope);
-intptr_t __ovld atomic_fetch_min(volatile atomic_intptr_t *object, uintptr_t 
opermax);
-intptr_t __ovld atomic_fetch_min_explicit(volatile atomic_intptr_t *object, 
uintptr_t opermax, memory_order minder);
-intptr_t __ovld atomic_fetch_min_explicit(volatile atomic_intptr_t *object, 
uintptr_t opermax, memory_order minder, memory_scope scope);
-intptr_t __ovld atomic_fetch_max(volatile atomic_intptr_t *object, uintptr_t 
opermax);
-intptr_t __ovld atomic_fetch_max_explicit(volatile atomic_intptr_t *object, 
uintptr_t operm

[clang] cb559c8 - [Sema] Add some basic lambda capture fix-its

2021-03-11 Thread Nathan James via cfe-commits

Author: Nathan James
Date: 2021-03-11T13:46:25Z
New Revision: cb559c8d5ebea60b07dec4654064ed775890b93b

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

LOG: [Sema] Add some basic lambda capture fix-its

Adds fix-its when users forget to explicitly capture variables or this in 
lambdas

Addresses https://github.com/clangd/clangd/issues/697

Reviewed By: kbobyrev

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

Added: 


Modified: 
clang/include/clang/Basic/DiagnosticSemaKinds.td
clang/lib/Sema/SemaExpr.cpp
clang/lib/Sema/SemaExprCXX.cpp
clang/test/CXX/drs/dr6xx.cpp
clang/test/CXX/expr/expr.prim/expr.prim.lambda/p12.cpp
clang/test/CXX/expr/expr.prim/expr.prim.lambda/p2-generic-lambda-1y.cpp
clang/test/SemaCXX/cxx1y-generic-lambdas-capturing.cpp
clang/test/SemaCXX/cxx1y-generic-lambdas.cpp
clang/test/SemaCXX/cxx1y-init-captures.cpp
clang/test/SemaCXX/cxx1z-constexpr-lambdas.cpp
clang/test/SemaCXX/lambda-expressions.cpp
clang/test/SemaCXX/lambda-invalid-capture.cpp
clang/test/SemaObjCXX/capturing-flexible-array-in-block.mm

Removed: 




diff  --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td 
b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index 7076274dcb6b..5f3389f96397 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -7462,6 +7462,8 @@ let CategoryName = "Lambda Issue" in {
 "duration">;
   def err_this_capture : Error<
 "'this' cannot be %select{implicitly |}0captured in this context">;
+  def note_lambda_this_capture_fixit : Note<
+"explicitly capture 'this'">;
   def err_lambda_capture_anonymous_var : Error<
 "unnamed variable cannot be implicitly captured in a lambda expression">;
   def err_lambda_capture_flexarray_type : Error<
@@ -7470,6 +7472,10 @@ let CategoryName = "Lambda Issue" in {
   def err_lambda_impcap : Error<
 "variable %0 cannot be implicitly captured in a lambda with no "
 "capture-default specified">;
+  def note_lambda_variable_capture_fixit : Note<
+"capture %0 by %select{value|reference}1">;
+  def note_lambda_default_capture_fixit : Note<
+"default capture by %select{value|reference}0">;
   def note_lambda_decl : Note<"lambda expression begins here">;
   def err_lambda_unevaluated_operand : Error<
 "lambda expression in an unevaluated operand">;

diff  --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp
index 6a56743ee382..49508e5880d6 100644
--- a/clang/lib/Sema/SemaExpr.cpp
+++ b/clang/lib/Sema/SemaExpr.cpp
@@ -46,6 +46,7 @@
 #include "clang/Sema/SemaFixItUtils.h"
 #include "clang/Sema/SemaInternal.h"
 #include "clang/Sema/Template.h"
+#include "llvm/ADT/STLExtras.h"
 #include "llvm/Support/ConvertUTF.h"
 #include "llvm/Support/SaveAndRestore.h"
 using namespace clang;
@@ -17431,6 +17432,107 @@ static bool captureInLambda(LambdaScopeInfo *LSI,
   return !Invalid;
 }
 
+static bool canCaptureVariableByCopy(VarDecl *Var, const ASTContext &Context) {
+  // Offer a Copy fix even if the type is dependent.
+  if (Var->getType()->isDependentType())
+return true;
+  QualType T = Var->getType().getNonReferenceType();
+  if (T.isTriviallyCopyableType(Context))
+return true;
+  if (CXXRecordDecl *RD = T->getAsCXXRecordDecl()) {
+
+if (!(RD = RD->getDefinition()))
+  return false;
+if (RD->hasSimpleCopyConstructor())
+  return true;
+if (RD->hasUserDeclaredCopyConstructor())
+  for (CXXConstructorDecl *Ctor : RD->ctors())
+if (Ctor->isCopyConstructor())
+  return !Ctor->isDeleted();
+  }
+  return false;
+}
+
+/// Create up to 4 fix-its for explicit reference and value capture of \p Var 
or
+/// default capture. Fixes may be omitted if they aren't allowed by the
+/// standard, for example we can't emit a default copy capture fix-it if we
+/// already explicitly copy capture capture another variable.
+static void buildLambdaCaptureFixit(Sema &Sema, LambdaScopeInfo *LSI,
+VarDecl *Var) {
+  assert(LSI->ImpCaptureStyle == CapturingScopeInfo::ImpCap_None);
+  // Don't offer Capture by copy of default capture by copy fixes if Var is
+  // known not to be copy constructible.
+  bool ShouldOfferCopyFix = canCaptureVariableByCopy(Var, 
Sema.getASTContext());
+
+  SmallString<32> FixBuffer;
+  StringRef Separator = LSI->NumExplicitCaptures > 0 ? ", " : "";
+  if (Var->getDeclName().isIdentifier() && !Var->getName().empty()) {
+SourceLocation VarInsertLoc = LSI->IntroducerRange.getEnd();
+if (ShouldOfferCopyFix) {
+  // Offer fixes to insert an explicit capture for the variable.
+  // [] -> [VarName]
+  // [OtherCapture] -> [OtherCapture, VarName]
+  FixBuffer.assign({Separator, Va

[PATCH] D96975: [Sema] Add some basic lambda capture fix-its

2021-03-11 Thread Nathan James via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGcb559c8d5ebe: [Sema] Add some basic lambda capture fix-its 
(authored by njames93).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D96975

Files:
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/Sema/SemaExpr.cpp
  clang/lib/Sema/SemaExprCXX.cpp
  clang/test/CXX/drs/dr6xx.cpp
  clang/test/CXX/expr/expr.prim/expr.prim.lambda/p12.cpp
  clang/test/CXX/expr/expr.prim/expr.prim.lambda/p2-generic-lambda-1y.cpp
  clang/test/SemaCXX/cxx1y-generic-lambdas-capturing.cpp
  clang/test/SemaCXX/cxx1y-generic-lambdas.cpp
  clang/test/SemaCXX/cxx1y-init-captures.cpp
  clang/test/SemaCXX/cxx1z-constexpr-lambdas.cpp
  clang/test/SemaCXX/lambda-expressions.cpp
  clang/test/SemaCXX/lambda-invalid-capture.cpp
  clang/test/SemaObjCXX/capturing-flexible-array-in-block.mm

Index: clang/test/SemaObjCXX/capturing-flexible-array-in-block.mm
===
--- clang/test/SemaObjCXX/capturing-flexible-array-in-block.mm
+++ clang/test/SemaObjCXX/capturing-flexible-array-in-block.mm
@@ -5,5 +5,5 @@
   struct { int x; int y[]; } a; // expected-note 3 {{'a' declared here}}
   ^{return a.x;}(); // expected-error {{cannot refer to declaration of structure variable with flexible array member inside block}}
   [=] {return a.x;}(); // expected-error {{variable 'a' with flexible array member cannot be captured in a lambda expression}}
-  [] {return a.x;}(); // expected-error {{variable 'a' cannot be implicitly captured in a lambda with no capture-default}} expected-note {{here}}
+  [] {return a.x;}(); // expected-error {{variable 'a' cannot be implicitly captured in a lambda with no capture-default}} expected-note {{here}} expected-note 2 {{capture 'a' by}} expected-note 2 {{default capture by}}
 }
Index: clang/test/SemaCXX/lambda-invalid-capture.cpp
===
--- clang/test/SemaCXX/lambda-invalid-capture.cpp
+++ clang/test/SemaCXX/lambda-invalid-capture.cpp
@@ -18,7 +18,7 @@
 }
 
 int pr43080(int i) { // expected-note {{declared here}}
-  return [] { // expected-note {{begins here}}
+  return [] {// expected-note {{begins here}} expected-note 2 {{capture 'i' by}} expected-note 2 {{default capture by}}
 return sizeof i <
   i; // expected-error {{variable 'i' cannot be implicitly captured in a lambda with no capture-default specified}}
   }();
Index: clang/test/SemaCXX/lambda-expressions.cpp
===
--- clang/test/SemaCXX/lambda-expressions.cpp
+++ clang/test/SemaCXX/lambda-expressions.cpp
@@ -12,17 +12,17 @@
 virtual C& Overload(float);
 
 void ImplicitThisCapture() {
-  [](){(void)Member;}; // expected-error {{'this' cannot be implicitly captured in this context}}
-  const int var = [](){(void)Member; return 0;}(); // expected-error {{'this' cannot be implicitly captured in this context}}
+  []() { (void)Member; }; // expected-error {{'this' cannot be implicitly captured in this context}} expected-note {{explicitly capture 'this'}}
+  const int var = []() {(void)Member; return 0; }(); // expected-error {{'this' cannot be implicitly captured in this context}} expected-note {{explicitly capture 'this'}}
   [&](){(void)Member;};
 
   [this](){(void)Member;};
   [this]{[this]{};};
   []{[this]{};};// expected-error {{'this' cannot be implicitly captured in this context}}
   []{Overload(3);};
-  []{Overload();}; // expected-error {{'this' cannot be implicitly captured in this context}}
+  [] { Overload(); }; // expected-error {{'this' cannot be implicitly captured in this context}} expected-note {{explicitly capture 'this'}}
   []{(void)typeid(Overload());};
-  []{(void)typeid(Overload(.5f));};// expected-error {{'this' cannot be implicitly captured in this context}}
+  [] { (void)typeid(Overload(.5f)); }; // expected-error {{'this' cannot be implicitly captured in this context}} expected-note {{explicitly capture 'this'}}
 }
   };
 
@@ -47,14 +47,14 @@
 namespace ImplicitCapture {
   void test() {
 int a = 0; // expected-note 5 {{declared}}
-[]() { return a; }; // expected-error {{variable 'a' cannot be implicitly captured in a lambda with no capture-default specified}} expected-note {{begins here}}
+[]() { return a; }; // expected-error {{variable 'a' cannot be implicitly captured in a lambda with no capture-default specified}} expected-note {{begins here}} expected-note 2 {{capture 'a' by}} expected-note 2 {{default capture by}}
 [&]() { return a; };
 [=]() { return a; };
 [=]() { int* b = &a; }; // expected-error {{cannot initialize a variable of type 'int *' with an rvalue of type 'const int *'}}
 [=]() { return [&]() { return a; }; };
-[]() { return [&]() { return a; }

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

2021-03-11 Thread Stelios Ioannou via Phabricator via cfe-commits
stelios-arm updated this revision to Diff 329941.
stelios-arm added a comment.

Rephrased a comment.


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
  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,38 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
+; RUN: llc -mtriple=aarch64 -mcpu=neoverse-v1 -mattr=+rand %s -o - | FileCheck %s
+
+define  i32 @rndr(i64* %__addr) {
+; CHECK-LABEL: rndr:
+; CHECK:   // %bb.0:
+; CHECK-NEXT:mrs x8, RNDR
+; CHECK-NEXT:cset w9, eq
+; CHECK-NEXT:str x8, [x0]
+; CHECK-NEXT:and w0, w9, #0x1
+; 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 x8, RNDRRS
+; CHECK-NEXT:cset w9, eq
+; CHECK-NEXT:str x8, [x0]
+; CHECK-NEXT:and w0, w9, #0x1
+; 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,10 @@
 def AArch64stnp : SDNode<"AArch64ISD::STNP", SDT_AArch64stnp, [SDNPHasChain, SDNPMayStore, SDNPMemOperand]>;
 
 def AArch64tbl : SDNode<"AArch64ISD::TBL", SDT_AArch64TBL>;
-
+// MRS from CodeGen.
+def AArch64mrs : SDNode<"AArch64ISD::MRS",
+SDTypeProfile<1, 1, [SDTCisVT<0, i64>, SDTCisVT<1, i32>]>,
+[SDNPHasChain, SDNPOutGlue]>;
 //===--===//
 
 //===--===//
@@ -1266,6 +1269,9 @@
 def MSRpstateImm1 : MSRpstate

[PATCH] D98076: [OpenCL][Docs] Release 12.0 notes

2021-03-11 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia updated this revision to Diff 329944.
Anastasia added a comment.

- Added nested pointer item
- Elaborated list of removed extensions with no kernel language changes.


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

https://reviews.llvm.org/D98076

Files:
  clang/docs/ReleaseNotes.rst


Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -200,10 +200,38 @@
 Objective-C Language Changes in Clang
 -
 
-OpenCL C Language Changes in Clang
---
-
-...
+OpenCL Kernel Language Changes in Clang
+---
+
+- Improved online documentation: :doc:`UsersManual` and :doc:`OpenCLSupport`
+  pages.
+- Added ``-cl-std=CL3.0`` and predefined version macro for OpenCL 3.0.
+- Added ``-cl-std=CL1.0`` and mapped to the existing OpenCL 1.0 functionality.
+- Improved OpenCL extension handling per target.
+- Added clang extension for function pointers ``__cl_clang_function_pointers``
+  and variadic functions ``__cl_clang_variadic_functions``, more details can be
+  found in :doc:`LanguageExtensions`.
+- Removed extensions without kernel language changes:
+  ``cl_khr_select_fprounding_mode``, ``cl_khr_gl_sharing``, ``cl_khr_icd``,
+  ``cl_khr_gl_event``, ``cl_khr_d3d10_sharing``, ``cl_khr_context_abort``,
+  ``cl_khr_d3d11_sharing``, ``cl_khr_dx9_media_sharing``,
+  ``cl_khr_image2d_from_buffer``, ``cl_khr_initialize_memory``,
+  ``cl_khr_gl_depth_images``, ``cl_khr_spir``, ``cl_khr_egl_event``,
+  ``cl_khr_egl_image``, ``cl_khr_terminate_context``.
+- Improved diagnostics for  unevaluated ``vec_step`` expression.
+- Allow nested pointers (e.g. pointer-to-pointer) kernel arguments beyond 
OpenCL
+  1.2.
+- Added ``global_device`` and ``global_host`` address spaces for USM
+  allocations.
+
+Miscellaneous improvements in C++ for OpenCL support:
+
+- Added diagnostics for pointers to member functions and references to
+  functions.
+- Added support of ``vec_step`` builtin.
+- Fixed ICE on address spaces with forwarding references and templated copy
+  constructors.
+- Removed warning for variadic macro use.
 
 ABI Changes in Clang
 


Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -200,10 +200,38 @@
 Objective-C Language Changes in Clang
 -
 
-OpenCL C Language Changes in Clang
---
-
-...
+OpenCL Kernel Language Changes in Clang
+---
+
+- Improved online documentation: :doc:`UsersManual` and :doc:`OpenCLSupport`
+  pages.
+- Added ``-cl-std=CL3.0`` and predefined version macro for OpenCL 3.0.
+- Added ``-cl-std=CL1.0`` and mapped to the existing OpenCL 1.0 functionality.
+- Improved OpenCL extension handling per target.
+- Added clang extension for function pointers ``__cl_clang_function_pointers``
+  and variadic functions ``__cl_clang_variadic_functions``, more details can be
+  found in :doc:`LanguageExtensions`.
+- Removed extensions without kernel language changes:
+  ``cl_khr_select_fprounding_mode``, ``cl_khr_gl_sharing``, ``cl_khr_icd``,
+  ``cl_khr_gl_event``, ``cl_khr_d3d10_sharing``, ``cl_khr_context_abort``,
+  ``cl_khr_d3d11_sharing``, ``cl_khr_dx9_media_sharing``,
+  ``cl_khr_image2d_from_buffer``, ``cl_khr_initialize_memory``,
+  ``cl_khr_gl_depth_images``, ``cl_khr_spir``, ``cl_khr_egl_event``,
+  ``cl_khr_egl_image``, ``cl_khr_terminate_context``.
+- Improved diagnostics for  unevaluated ``vec_step`` expression.
+- Allow nested pointers (e.g. pointer-to-pointer) kernel arguments beyond OpenCL
+  1.2.
+- Added ``global_device`` and ``global_host`` address spaces for USM
+  allocations.
+
+Miscellaneous improvements in C++ for OpenCL support:
+
+- Added diagnostics for pointers to member functions and references to
+  functions.
+- Added support of ``vec_step`` builtin.
+- Fixed ICE on address spaces with forwarding references and templated copy
+  constructors.
+- Removed warning for variadic macro use.
 
 ABI Changes in Clang
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D98076: [OpenCL][Docs] Release 12.0 notes

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

Sorry for the last-minute change, I have decided to add this too:

  +- Removed extensions without kernel language changes:
  +  ``cl_khr_select_fprounding_mode``, ``cl_khr_gl_sharing``, ``cl_khr_icd``,
  +  ``cl_khr_gl_event``, ``cl_khr_d3d10_sharing``, ``cl_khr_context_abort``,
  +  ``cl_khr_d3d11_sharing``, ``cl_khr_dx9_media_sharing``,
  +  ``cl_khr_image2d_from_buffer``, ``cl_khr_initialize_memory``,
  +  ``cl_khr_gl_depth_images``, ``cl_khr_spir``, ``cl_khr_egl_event``,
  +  ``cl_khr_egl_image``, ``cl_khr_terminate_context``.


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

https://reviews.llvm.org/D98076

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


[PATCH] D98076: [OpenCL][Docs] Release 12.0 notes

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

@tstellar is it ok if I commit this to the release branch or do you prefer to 
do it yourself?


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

https://reviews.llvm.org/D98076

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


[PATCH] D98076: [OpenCL][Docs] Release 12.0 notes

2021-03-11 Thread Sven van Haastregt via Phabricator via cfe-commits
svenvh accepted this revision.
svenvh added a comment.

In D98076#2619425 , @Anastasia wrote:

> Sorry for the last-minute change, I have decided to add this too:
>
>   +- Removed extensions without kernel language changes:
>   +  ``cl_khr_select_fprounding_mode``, ``cl_khr_gl_sharing``, ``cl_khr_icd``,
>   +  ``cl_khr_gl_event``, ``cl_khr_d3d10_sharing``, ``cl_khr_context_abort``,
>   +  ``cl_khr_d3d11_sharing``, ``cl_khr_dx9_media_sharing``,
>   +  ``cl_khr_image2d_from_buffer``, ``cl_khr_initialize_memory``,
>   +  ``cl_khr_gl_depth_images``, ``cl_khr_spir``, ``cl_khr_egl_event``,
>   +  ``cl_khr_egl_image``, ``cl_khr_terminate_context``.

Makes sense, LGTM!


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

https://reviews.llvm.org/D98076

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


[PATCH] D98211: Solve PR49479, File scope fp pragma should propagate to functions nested in struct, and initialization expressions

2021-03-11 Thread Erich Keane via Phabricator via cfe-commits
erichkeane accepted this revision.
erichkeane added a comment.
This revision is now accepted and ready to land.

The description of the problem, and hte patch and tests seem to make sense, so 
I think this should be ok.   Please give some of the others a little bit of 
time before committing to speak their final bit, but LGTM .


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98211

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


[clang] bafcb4c - [OpenCL][Docs] Add guidelines for new extensions and features.

2021-03-11 Thread Anastasia Stulova via cfe-commits

Author: Anastasia Stulova
Date: 2021-03-11T14:28:48Z
New Revision: bafcb4c6841a302d502b14fb93101fb590459935

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

LOG: [OpenCL][Docs] Add guidelines for new extensions and features.

Add documentation that explains how to extend clang with the new
extensions/features. The guidelines also detail clang's position
about the extension pragmas for the new functionality.

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

Added: 


Modified: 
clang/docs/OpenCLSupport.rst

Removed: 




diff  --git a/clang/docs/OpenCLSupport.rst b/clang/docs/OpenCLSupport.rst
index 02522052e106..f7d6b1f7f2c9 100644
--- a/clang/docs/OpenCLSupport.rst
+++ b/clang/docs/OpenCLSupport.rst
@@ -168,6 +168,8 @@ also :ref:`the section on the address space attribute 
`).
 
  $ clang -cc1 -ffake-address-space-map test.cl
 
+.. _opencl_builtins:
+
 OpenCL builtins
 ---
 
@@ -210,6 +212,82 @@ of the following main components:
   inserted using ``InsertOCLBuiltinDeclarationsFromTable`` and overload
   resolution takes place.
 
+OpenCL Extensions and Features
+--
+
+Clang implements various extensions to OpenCL kernel languages.
+
+New functionality is accepted as soon as the documentation is detailed to the
+level sufficient to be implemented. There should be an evidence that the
+extension is designed with implementation feasibility in consideration and
+assessment of complexity for C/C++ based compilers. Alternatively, the
+documentation can be accepted in a format of a draft that can be further
+refined during the implementation.
+
+Implementation guidelines
+^
+
+This section explains how to extend clang with the new functionality.
+
+**Parsing functionality**
+
+If an extension modifies the standard parsing it needs to be added to
+the clang frontend source code. This also means that the associated macro
+indicating the presence of the extension should be added to clang.
+
+The default flow for adding a new extension into the frontend is to
+modify `OpenCLExtensions.def
+`_
+
+This will add the macro automatically and also add a field in the target
+options ``clang::TargetOptions::OpenCLFeaturesMap`` to control the exposure
+of the new extension during the compilation.
+
+Note that by default targets like `SPIR` or `X86` expose all the OpenCL
+extensions. For all other targets the configuration has to be made explicitly.
+
+Note that the target extension support performed by clang can be overridden
+with :ref:`-cl-ext ` command-line flags.
+
+**Library functionality**
+
+If an extension adds functionality that does not modify standard language
+parsing it should not require modifying anything other than header files or
+``OpenCLBuiltins.td`` detailed in :ref:`OpenCL builtins `.
+Most commonly such extensions add functionality via libraries (by adding
+non-native types or functions) parsed regularly. Similar to other languages 
this
+is the most common way to add new functionality.
+
+Clang has standard headers where new types and functions are being added,
+for more details refer to
+:ref:`the section on the OpenCL Header `. The macros indicating
+the presence of such extensions can be added in the standard header files
+conditioned on target specific predefined macros or/and language version
+predefined macros.
+
+**Pragmas**
+
+Some extensions alter standard parsing dynamically via pragmas.
+
+Clang provides a mechanism to add the standard extension pragma
+``OPENCL EXTENSION`` by setting a dedicated flag in the extension list entry of
+``OpenCLExtensions.def``. Note that there is no default behavior for the
+standard extension pragmas as it is not specified (for the standards up to and
+including version 3.0) in a sufficient level of detail and, therefore,
+there is no default functionality provided by clang.
+
+Pragmas without detailed information of their behavior (e.g. an explanation of
+changes it triggers in the parsing) should not be added to clang. Moreover, the
+pragmas should provide useful functionality to the user. For example, such
+functionality should address a practical use case and not be redundant i.e.
+cannot be achieved using existing features.
+
+Note that some legacy extensions (published prior to OpenCL 3.0) still
+provide some non-conformant functionality for pragmas e.g. add diagnostics on
+the use of types or functions. This functionality is not guaranteed to remain 
in
+future releases. However, any future changes should not affect backward
+compatibility.
+
 .. _opencl_addrsp:
 
 Address spaces attribute



___
cfe-commit

[PATCH] D97072: [OpenCL][Docs] Add guidelines for adding new extensions and features

2021-03-11 Thread Anastasia Stulova 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 rGbafcb4c6841a: [OpenCL][Docs] Add guidelines for new 
extensions and features. (authored by Anastasia).
Herald added a project: clang.

Changed prior to commit:
  https://reviews.llvm.org/D97072?vs=329605&id=329952#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97072

Files:
  clang/docs/OpenCLSupport.rst


Index: clang/docs/OpenCLSupport.rst
===
--- clang/docs/OpenCLSupport.rst
+++ clang/docs/OpenCLSupport.rst
@@ -168,6 +168,8 @@
 
  $ clang -cc1 -ffake-address-space-map test.cl
 
+.. _opencl_builtins:
+
 OpenCL builtins
 ---
 
@@ -210,6 +212,82 @@
   inserted using ``InsertOCLBuiltinDeclarationsFromTable`` and overload
   resolution takes place.
 
+OpenCL Extensions and Features
+--
+
+Clang implements various extensions to OpenCL kernel languages.
+
+New functionality is accepted as soon as the documentation is detailed to the
+level sufficient to be implemented. There should be an evidence that the
+extension is designed with implementation feasibility in consideration and
+assessment of complexity for C/C++ based compilers. Alternatively, the
+documentation can be accepted in a format of a draft that can be further
+refined during the implementation.
+
+Implementation guidelines
+^
+
+This section explains how to extend clang with the new functionality.
+
+**Parsing functionality**
+
+If an extension modifies the standard parsing it needs to be added to
+the clang frontend source code. This also means that the associated macro
+indicating the presence of the extension should be added to clang.
+
+The default flow for adding a new extension into the frontend is to
+modify `OpenCLExtensions.def
+`_
+
+This will add the macro automatically and also add a field in the target
+options ``clang::TargetOptions::OpenCLFeaturesMap`` to control the exposure
+of the new extension during the compilation.
+
+Note that by default targets like `SPIR` or `X86` expose all the OpenCL
+extensions. For all other targets the configuration has to be made explicitly.
+
+Note that the target extension support performed by clang can be overridden
+with :ref:`-cl-ext ` command-line flags.
+
+**Library functionality**
+
+If an extension adds functionality that does not modify standard language
+parsing it should not require modifying anything other than header files or
+``OpenCLBuiltins.td`` detailed in :ref:`OpenCL builtins `.
+Most commonly such extensions add functionality via libraries (by adding
+non-native types or functions) parsed regularly. Similar to other languages 
this
+is the most common way to add new functionality.
+
+Clang has standard headers where new types and functions are being added,
+for more details refer to
+:ref:`the section on the OpenCL Header `. The macros indicating
+the presence of such extensions can be added in the standard header files
+conditioned on target specific predefined macros or/and language version
+predefined macros.
+
+**Pragmas**
+
+Some extensions alter standard parsing dynamically via pragmas.
+
+Clang provides a mechanism to add the standard extension pragma
+``OPENCL EXTENSION`` by setting a dedicated flag in the extension list entry of
+``OpenCLExtensions.def``. Note that there is no default behavior for the
+standard extension pragmas as it is not specified (for the standards up to and
+including version 3.0) in a sufficient level of detail and, therefore,
+there is no default functionality provided by clang.
+
+Pragmas without detailed information of their behavior (e.g. an explanation of
+changes it triggers in the parsing) should not be added to clang. Moreover, the
+pragmas should provide useful functionality to the user. For example, such
+functionality should address a practical use case and not be redundant i.e.
+cannot be achieved using existing features.
+
+Note that some legacy extensions (published prior to OpenCL 3.0) still
+provide some non-conformant functionality for pragmas e.g. add diagnostics on
+the use of types or functions. This functionality is not guaranteed to remain 
in
+future releases. However, any future changes should not affect backward
+compatibility.
+
 .. _opencl_addrsp:
 
 Address spaces attribute


Index: clang/docs/OpenCLSupport.rst
===
--- clang/docs/OpenCLSupport.rst
+++ clang/docs/OpenCLSupport.rst
@@ -168,6 +168,8 @@
 
  $ clang -cc1 -ffake-address-space-map test.cl
 
+.. _opencl_builtins:
+
 OpenCL builtins
 ---
 
@@ -210,6 +212,82 @@
   inserted using ``InsertOCLBuiltinDeclarationsFromTable`` and over

[PATCH] D98211: Solve PR49479, File scope fp pragma should propagate to functions nested in struct, and initialization expressions

2021-03-11 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman accepted this revision.
aaron.ballman added a comment.

LGTM as well, but feel free to give the other reviewers a chance to weigh in.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98211

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


[PATCH] D98424: [clangd] Reject renames to non-identifier characters

2021-03-11 Thread Sam McCall via Phabricator via cfe-commits
sammccall created this revision.
sammccall added a reviewer: usaxena95.
Herald added subscribers: kadircet, arphaman.
sammccall requested review of this revision.
Herald added subscribers: cfe-commits, MaskRay, ilya-biryukov.
Herald added a project: clang.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D98424

Files:
  clang-tools-extra/clangd/refactor/Rename.cpp
  clang-tools-extra/clangd/unittests/RenameTests.cpp

Index: clang-tools-extra/clangd/unittests/RenameTests.cpp
===
--- clang-tools-extra/clangd/unittests/RenameTests.cpp
+++ clang-tools-extra/clangd/unittests/RenameTests.cpp
@@ -1240,6 +1240,21 @@
   testing::HasSubstr("keyword"));
   EXPECT_THAT(Tracer.takeMetric("rename_name_invalid", "Keywords"),
   ElementsAre(1));
+
+  for (std::string BadIdent : {"foo!bar", "123foo", "😀@"}) {
+Results = runPrepareRename(Server, FooCCPath, FooCC.point(),
+   /*NewName=*/BadIdent, {});
+EXPECT_FALSE(Results);
+EXPECT_THAT(llvm::toString(Results.takeError()),
+testing::HasSubstr("identifier"));
+EXPECT_THAT(Tracer.takeMetric("rename_name_invalid", "BadIdentifier"),
+ElementsAre(1));
+  }
+  for (std::string GoodIdent : {"fooBar", "__foo$", "😀"}) {
+Results = runPrepareRename(Server, FooCCPath, FooCC.point(),
+   /*NewName=*/GoodIdent, {});
+EXPECT_TRUE(bool(Results));
+  }
 }
 
 TEST(CrossFileRenameTests, DirtyBuffer) {
Index: clang-tools-extra/clangd/refactor/Rename.cpp
===
--- clang-tools-extra/clangd/refactor/Rename.cpp
+++ clang-tools-extra/clangd/refactor/Rename.cpp
@@ -22,14 +22,17 @@
 #include "clang/AST/DeclTemplate.h"
 #include "clang/AST/ParentMapContext.h"
 #include "clang/AST/Stmt.h"
+#include "clang/Basic/CharInfo.h"
 #include "clang/Basic/LLVM.h"
 #include "clang/Basic/SourceLocation.h"
 #include "clang/Tooling/Syntax/Tokens.h"
 #include "llvm/ADT/None.h"
 #include "llvm/ADT/STLExtras.h"
+#include "llvm/ADT/StringExtras.h"
 #include "llvm/Support/Casting.h"
 #include "llvm/Support/Error.h"
 #include "llvm/Support/FormatVariadic.h"
+#include "llvm/Support/JSON.h"
 #include 
 
 namespace clang {
@@ -178,8 +181,7 @@
   UnsupportedSymbol,
   AmbiguousSymbol,
 
-  // name validation.
-  RenameToKeywords,
+  // name validation. FIXME: reconcile with InvalidName
   SameName,
 };
 
@@ -241,8 +243,6 @@
   return "symbol is not a supported kind (e.g. namespace, macro)";
 case ReasonToReject::AmbiguousSymbol:
   return "there are multiple symbols at the given location";
-case ReasonToReject::RenameToKeywords:
-  return "the chosen name is a keyword";
 case ReasonToReject::SameName:
   return "new name is the same as the old name";
 }
@@ -437,6 +437,7 @@
   enum Kind {
 Keywords,
 Conflict,
+BadIdentifier,
   };
   Kind K;
   std::string Details;
@@ -447,24 +448,44 @@
 return "Keywords";
   case InvalidName::Conflict:
 return "Conflict";
+  case InvalidName::BadIdentifier:
+return "BadIdentifier";
   }
   llvm_unreachable("unhandled InvalidName kind");
 }
 
 llvm::Error makeError(InvalidName Reason) {
-  auto Message = [](InvalidName Reason) {
+  auto Message = [](InvalidName Reason) -> std::string {
 switch (Reason.K) {
 case InvalidName::Keywords:
   return llvm::formatv("the chosen name \"{0}\" is a keyword",
Reason.Details);
 case InvalidName::Conflict:
   return llvm::formatv("conflict with the symbol in {0}", Reason.Details);
+case InvalidName::BadIdentifier:
+  return "the chosen name \"{0}\" is not a valid identifier";
 }
 llvm_unreachable("unhandled InvalidName kind");
   };
   return error("invalid name: {0}", Message(Reason));
 }
 
+static bool mayBeValidIdentifier(llvm::StringRef Ident) {
+  assert(llvm::json::isUTF8(Ident));
+  if (Ident.empty())
+return false;
+  // We don't check all the rules for non-ascii characters (most are allowed).
+  bool AllowDollar = true; // lenient
+  if (llvm::isASCII(Ident.front()) &&
+  !isIdentifierHead(Ident.front(), AllowDollar))
+return false;
+  for (char C : Ident) {
+if (llvm::isASCII(C) && !isIdentifierBody(C, AllowDollar))
+  return false;
+  }
+  return true;
+}
+
 // Check if we can rename the given RenameDecl into NewName.
 // Return details if the rename would produce a conflict.
 llvm::Optional checkName(const NamedDecl &RenameDecl,
@@ -476,6 +497,8 @@
   llvm::Optional Result;
   if (isKeyword(NewName, ASTCtx.getLangOpts()))
 Result = InvalidName{InvalidName::Keywords, NewName.str()};
+  else if (!mayBeValidIdentifier(NewName))
+Result = InvalidName{InvalidName::BadIdentifier, NewName.str()};
   else {
 // Name conflict detection.
 // Function conflicts are subtle (overloading), so ignore them.
__

[clang] df2a6ee - [Sema] Use castAs<> instead getAs<> for dereferenced pointer casts. NFCI.

2021-03-11 Thread Simon Pilgrim via cfe-commits

Author: Simon Pilgrim
Date: 2021-03-11T14:51:25Z
New Revision: df2a6ee3247c9d00b42c14ea924fd25cc45bda87

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

LOG: [Sema] Use castAs<> instead getAs<> for dereferenced pointer casts. NFCI.

getAs<> returns null for missed casts, resulting in null dereferences - use 
castAs<> instead which will assert the cast is correct.

Added: 


Modified: 
clang/lib/Sema/SemaDeclAttr.cpp

Removed: 




diff  --git a/clang/lib/Sema/SemaDeclAttr.cpp b/clang/lib/Sema/SemaDeclAttr.cpp
index c309f0436437..459343637318 100644
--- a/clang/lib/Sema/SemaDeclAttr.cpp
+++ b/clang/lib/Sema/SemaDeclAttr.cpp
@@ -2836,8 +2836,10 @@ static void handleSentinelAttr(Sema &S, Decl *D, const 
ParsedAttr &AL) {
 QualType Ty = V->getType();
 if (Ty->isBlockPointerType() || Ty->isFunctionPointerType()) {
   const FunctionType *FT = Ty->isFunctionPointerType()
-   ? D->getFunctionType()
-   : 
Ty->castAs()->getPointeeType()->getAs();
+   ? D->getFunctionType()
+   : Ty->castAs()
+ ->getPointeeType()
+ ->castAs();
   if (!cast(FT)->isVariadic()) {
 int m = Ty->isFunctionPointerType() ? 0 : 1;
 S.Diag(AL.getLoc(), diag::warn_attribute_sentinel_not_variadic) << m;
@@ -5836,7 +5838,7 @@ static void checkSwiftAsyncErrorBlock(Sema &S, Decl *D,
   // handleSwiftAsyncAttr already verified the type is correct, so no need to
   // double-check it here.
   const auto *FuncTy = HandlerParam->getType()
-   ->getAs()
+   ->castAs()
->getPointeeType()
->getAs();
   ArrayRef BlockParams;
@@ -6313,8 +6315,8 @@ static void handleSwiftAsyncAttr(Sema &S, Decl *D, const 
ParsedAttr &AL) {
   return;
 }
 QualType BlockTy =
-CompletionBlockType->getAs()->getPointeeType();
-if (!BlockTy->getAs()->getReturnType()->isVoidType()) {
+CompletionBlockType->castAs()->getPointeeType();
+if (!BlockTy->castAs()->getReturnType()->isVoidType()) {
   S.Diag(CompletionBlock->getLocation(),
  diag::err_swift_async_bad_block_type)
   << CompletionBlock->getType();



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


[clang] 807466e - [OpenMP] Restore backwards compatibility for libomptarget

2021-03-11 Thread Joseph Huber via cfe-commits

Author: Joseph Huber
Date: 2021-03-11T09:52:11-05:00
New Revision: 807466ef28125cf7268c860b09d5563c9c93602a

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

LOG: [OpenMP] Restore backwards compatibility for libomptarget

Summary:
The changes introduced in D87946 changed the API for libomptarget
functions. `__kmpc_push_target_tripcount` was a function in Clang 11.x
but was not given a backward-compatible interface. This change will
require people using Clang 13.x or 12.x to recompile their offloading
programs.

Reviewed By: jdoerfert cchen

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

Added: 


Modified: 
clang/lib/CodeGen/CGOpenMPRuntime.cpp
clang/test/OpenMP/target_teams_distribute_parallel_for_codegen.cpp
clang/test/OpenMP/target_teams_distribute_parallel_for_if_codegen.cpp
clang/test/OpenMP/target_teams_distribute_parallel_for_order_codegen.cpp
clang/test/OpenMP/target_teams_distribute_parallel_for_simd_codegen.cpp
clang/test/OpenMP/target_teams_distribute_parallel_for_simd_if_codegen.cpp
clang/test/OpenMP/teams_distribute_codegen.cpp
clang/test/OpenMP/teams_distribute_parallel_for_codegen.cpp
clang/test/OpenMP/teams_distribute_parallel_for_simd_codegen.cpp
clang/test/OpenMP/teams_distribute_simd_codegen.cpp
llvm/include/llvm/Frontend/OpenMP/OMPKinds.def
llvm/test/Transforms/OpenMP/add_attributes.ll
openmp/libomptarget/include/omptarget.h
openmp/libomptarget/src/exports
openmp/libomptarget/src/interface.cpp
openmp/libomptarget/src/omptarget.cpp
openmp/libomptarget/test/offloading/host_as_target.c

Removed: 




diff  --git a/clang/lib/CodeGen/CGOpenMPRuntime.cpp 
b/clang/lib/CodeGen/CGOpenMPRuntime.cpp
index f9c79e6c95f5..e41eeef04331 100644
--- a/clang/lib/CodeGen/CGOpenMPRuntime.cpp
+++ b/clang/lib/CodeGen/CGOpenMPRuntime.cpp
@@ -9948,7 +9948,7 @@ void CGOpenMPRuntime::emitTargetNumIterationsCall(
   llvm::Value *Args[] = {RTLoc, DeviceID, NumIterations};
   CGF.EmitRuntimeCall(
   OMPBuilder.getOrCreateRuntimeFunction(
-  CGM.getModule(), OMPRTL___kmpc_push_target_tripcount),
+  CGM.getModule(), OMPRTL___kmpc_push_target_tripcount_mapper),
   Args);
 }
   };

diff  --git 
a/clang/test/OpenMP/target_teams_distribute_parallel_for_codegen.cpp 
b/clang/test/OpenMP/target_teams_distribute_parallel_for_codegen.cpp
index 0229ace911f8..c0f53239aa13 100644
--- a/clang/test/OpenMP/target_teams_distribute_parallel_for_codegen.cpp
+++ b/clang/test/OpenMP/target_teams_distribute_parallel_for_codegen.cpp
@@ -39,7 +39,7 @@
 
 #ifdef CK1
 
-// HCK_NO_TGT-NOT: @__kmpc_push_target_tripcount
+// HCK_NO_TGT-NOT: @__kmpc_push_target_tripcount_mapper
 
 // HCK1: define{{.*}} i32 @{{.+}}target_teams_fun{{.*}}(
 int target_teams_fun(int *g){
@@ -60,7 +60,7 @@ int target_teams_fun(int *g){
   // HCK1: [[N_PAR:%.+]] = load{{.+}}, {{.+}} [[N_CAST]],
   // HCK1: [[TE_PAR:%.+]] = load{{.+}}, {{.+}} [[TE_CAST]],
   // HCK1: [[TH_PAR:%.+]] = load{{.+}}, {{.+}} [[TH_CAST]],
-  // HCK1: call void @__kmpc_push_target_tripcount(%struct.ident_t* @{{.+}}, 
i64 -1, i64 %{{.+}})
+  // HCK1: call void @__kmpc_push_target_tripcount_mapper(%struct.ident_t* 
@{{.+}}, i64 -1, i64 %{{.+}})
   // HCK1: call i32 @__tgt_target_teams_mapper(%struct.ident_t* @{{.+}}, i64 
-1, i8* @{{[^,]+}}, i32 4, i8** %{{[^,]+}}, i8** %{{[^,]+}},
 
   // HCK1: call void @[[OFFL1:.+]](i{{32|64}} [[N_PAR]], {{.+}}, i{{32|64}} 
[[TE_PAR]], i{{32|64}} [[TH_PAR]])

diff  --git 
a/clang/test/OpenMP/target_teams_distribute_parallel_for_if_codegen.cpp 
b/clang/test/OpenMP/target_teams_distribute_parallel_for_if_codegen.cpp
index 6650e0557511..efe7df819fb6 100644
--- a/clang/test/OpenMP/target_teams_distribute_parallel_for_if_codegen.cpp
+++ b/clang/test/OpenMP/target_teams_distribute_parallel_for_if_codegen.cpp
@@ -49,10 +49,10 @@ int Arg;
 
 // CHECK-LABEL: define {{.*}}void @{{.+}}gtid_test
 void gtid_test() {
-// CHECK: call void @__kmpc_push_target_tripcount(%struct.ident_t* @{{.+}}, 
i64 -1, i64 100)
+// CHECK: call void @__kmpc_push_target_tripcount_mapper(%struct.ident_t* 
@{{.+}}, i64 -1, i64 100)
 // CHECK: call i{{[0-9]+}} @__tgt_target_teams_mapper(%struct.ident_t* @{{.+}},
 // CHECK: call void [[OFFLOADING_FUN_0:@.+]](
-// CHECK: call void @__kmpc_push_target_tripcount(%struct.ident_t* @{{.+}}, 
i64 -1, i64 100)
+// CHECK: call void @__kmpc_push_target_tripcount_mapper(%struct.ident_t* 
@{{.+}}, i64 -1, i64 100)
 // CHECK: call i{{[0-9]+}} @__tgt_target_teams_mapper(%struct.ident_t* @{{.+}},
 // CHECK: call void [[OFFLOADING_FUN_1:@.+]](
 #pragma omp target teams distribute parallel for
@@ -107,12 +107,12 @@ int tmain(T Arg) {
 
 // CHECK-LABEL: define {{.*}}i{{[0-9]+}} @main()
 int main() {
-// CHECK: cal

[PATCH] D98358: [OpenMP] Restore backwards compatibility for libomptarget

2021-03-11 Thread Joseph Huber 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 rG807466ef2812: [OpenMP] Restore backwards compatibility for 
libomptarget (authored by jhuber6).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98358

Files:
  clang/lib/CodeGen/CGOpenMPRuntime.cpp
  clang/test/OpenMP/target_teams_distribute_parallel_for_codegen.cpp
  clang/test/OpenMP/target_teams_distribute_parallel_for_if_codegen.cpp
  clang/test/OpenMP/target_teams_distribute_parallel_for_order_codegen.cpp
  clang/test/OpenMP/target_teams_distribute_parallel_for_simd_codegen.cpp
  clang/test/OpenMP/target_teams_distribute_parallel_for_simd_if_codegen.cpp
  clang/test/OpenMP/teams_distribute_codegen.cpp
  clang/test/OpenMP/teams_distribute_parallel_for_codegen.cpp
  clang/test/OpenMP/teams_distribute_parallel_for_simd_codegen.cpp
  clang/test/OpenMP/teams_distribute_simd_codegen.cpp
  llvm/include/llvm/Frontend/OpenMP/OMPKinds.def
  llvm/test/Transforms/OpenMP/add_attributes.ll
  openmp/libomptarget/include/omptarget.h
  openmp/libomptarget/src/exports
  openmp/libomptarget/src/interface.cpp
  openmp/libomptarget/src/omptarget.cpp
  openmp/libomptarget/test/offloading/host_as_target.c

Index: openmp/libomptarget/test/offloading/host_as_target.c
===
--- openmp/libomptarget/test/offloading/host_as_target.c
+++ openmp/libomptarget/test/offloading/host_as_target.c
@@ -55,8 +55,8 @@
   printf("omp_is_initial_device() = %d\n", omp_is_initial_device());
   CHECK_DATA();
 
-  // Check that __kmpc_push_target_tripcount doesn't fail.  I'm not sure how to
-  // check that it actually pushes to the initial device.
+  // Check that __kmpc_push_target_tripcount_mapper doesn't fail. I'm not sure
+  // how to check that it actually pushes to the initial device.
   #pragma omp target teams device(DevInit) num_teams(1)
   #pragma omp distribute
   for (int i = 0; i < 2; ++i)
@@ -112,8 +112,8 @@
   printf("omp_is_initial_device() = %d\n", omp_is_initial_device());
   CHECK_DATA();
 
-  // Check that __kmpc_push_target_tripcount doesn't fail.  I'm not sure how to
-  // check that it actually pushes to the initial device.
+  // Check that __kmpc_push_target_tripcount_mapper doesn't fail. I'm not sure
+  // how to check that it actually pushes to the initial device.
   #pragma omp target teams num_teams(1)
   #pragma omp distribute
   for (int i = 0; i < 2; ++i)
Index: openmp/libomptarget/src/omptarget.cpp
===
--- openmp/libomptarget/src/omptarget.cpp
+++ openmp/libomptarget/src/omptarget.cpp
@@ -1023,8 +1023,8 @@
 
 /// Get loop trip count
 /// FIXME: This function will not work right if calling
-/// __kmpc_push_target_tripcount in one thread but doing offloading in another
-/// thread, which might occur when we call task yield.
+/// __kmpc_push_target_tripcount_mapper in one thread but doing offloading in
+/// another thread, which might occur when we call task yield.
 uint64_t getLoopTripCount(int64_t DeviceId) {
   DeviceTy &Device = PM->Devices[DeviceId];
   uint64_t LoopTripCount = 0;
Index: openmp/libomptarget/src/interface.cpp
===
--- openmp/libomptarget/src/interface.cpp
+++ openmp/libomptarget/src/interface.cpp
@@ -437,8 +437,13 @@
   MapComponentInfoTy(base, begin, size, type, name));
 }
 
-EXTERN void __kmpc_push_target_tripcount(ident_t *loc, int64_t device_id,
+EXTERN void __kmpc_push_target_tripcount(int64_t device_id,
  uint64_t loop_tripcount) {
+  __kmpc_push_target_tripcount_mapper(nullptr, device_id, loop_tripcount);
+}
+
+EXTERN void __kmpc_push_target_tripcount_mapper(ident_t *loc, int64_t device_id,
+uint64_t loop_tripcount) {
   TIMESCOPE_WITH_IDENT(loc);
   if (checkDeviceAndCtors(device_id, loc) != OFFLOAD_SUCCESS) {
 DP("Not offloading to device %" PRId64 "\n", device_id);
Index: openmp/libomptarget/src/exports
===
--- openmp/libomptarget/src/exports
+++ openmp/libomptarget/src/exports
@@ -25,6 +25,8 @@
 __tgt_target_teams_nowait_mapper;
 __tgt_mapper_num_components;
 __tgt_push_mapper_component;
+__kmpc_push_target_tripcount;
+__kmpc_push_target_tripcount_mapper;
 omp_get_num_devices;
 omp_get_initial_device;
 omp_target_alloc;
@@ -34,7 +36,6 @@
 omp_target_memcpy_rect;
 omp_target_associate_ptr;
 omp_target_disassociate_ptr;
-__kmpc_push_target_tripcount;
   local:
 *;
 };
Index: openmp/libomptarget/include/omptarget.h
===
--- openmp/libomptarget/include/omptarget.h
+++ openmp/libomptarget/include/omptarget.h

[PATCH] D95635: [CMake] Actually require python 3.6 or greater

2021-03-11 Thread Christopher Tetreault via Phabricator via cfe-commits
ctetreau planned changes to this revision.
ctetreau added a comment.
Herald added subscribers: dcaballe, cota.

I plan to revive this patch. I will try to rig it to only require 3.6 or above 
is testing is enabled using LLVM_INCLUDE_TESTS. Hopefully if any build bots 
haven't been fixed by now, they will not be setting this variable to ON (since 
they clearly aren't running tests)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95635

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


[PATCH] D97388: [analyzer] Replace StoreManager::evalIntegralCast with SValBuilder::evalCast

2021-03-11 Thread Denys Petrov via Phabricator via cfe-commits
ASDenysPetrov added a comment.

In D97388#2615104 , @NoQ wrote:

> Ok then, let's try to land it! 🤞

Thanks for the approval. Before land this we should land the preparatory 
revision D97296 . Please, take a look.


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

https://reviews.llvm.org/D97388

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


[PATCH] D98424: [clangd] Reject renames to non-identifier characters

2021-03-11 Thread Nathan James via Phabricator via cfe-commits
njames93 added inline comments.



Comment at: clang-tools-extra/clangd/refactor/Rename.cpp:473-488
+static bool mayBeValidIdentifier(llvm::StringRef Ident) {
+  assert(llvm::json::isUTF8(Ident));
+  if (Ident.empty())
+return false;
+  // We don't check all the rules for non-ascii characters (most are allowed).
+  bool AllowDollar = true; // lenient
+  if (llvm::isASCII(Ident.front()) &&

What's wrong with `isValidIdentifier` in `CharInfo.h`.
Also isIdentifier(Body|Head) cover isASCII.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98424

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


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

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



Comment at: clang-tools-extra/clangd/index/remote/server/CMakeLists.txt:12
 
+if (ENABLE_GRPC_REFLECTION)
+  set(REFLECTION_LIBRARY grpc++_reflection)

kbobyrev wrote:
> kadircet wrote:
> > can we move this piece into FindGRPC.cmake instead?
> Yes, but I think only the `set(REFLECTION_LIBRARY grpc++_reflection)` part? 
> Having the `-DENABLE_GRPC_REFLECTION` definition globally is probably not 
> very nice and as with the other target under `clangd/index/remote`, 
> `add_target_definition` doesn't work because of `add_clan_executable` :(
ah i forgot about that one, can we have this in 
`clang-tools-extra/clangd/Features.inc.in` then, with rest of our definitions?

you might also want to canonicalize the option via 
`llvm_canonicalize_cmake_booleans`


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] D98424: [clangd] Reject renames to non-identifier characters

2021-03-11 Thread Sam McCall via Phabricator via cfe-commits
sammccall added inline comments.



Comment at: clang-tools-extra/clangd/refactor/Rename.cpp:473-488
+static bool mayBeValidIdentifier(llvm::StringRef Ident) {
+  assert(llvm::json::isUTF8(Ident));
+  if (Ident.empty())
+return false;
+  // We don't check all the rules for non-ascii characters (most are allowed).
+  bool AllowDollar = true; // lenient
+  if (llvm::isASCII(Ident.front()) &&

njames93 wrote:
> What's wrong with `isValidIdentifier` in `CharInfo.h`.
> Also isIdentifier(Body|Head) cover isASCII.
Many (most?) non-ascii characters *are* allowed.

isValidIdentifier & friends return `false` for non-ascii characters. This is OK 
for the fast-path of the parser, where false negatives are OK and fall back to 
the slow path.

We want the opposite bias: false positives are OK (allow some incorrect renames 
involving unicode characters) but false negatives are not (reject some valid 
renames)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98424

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


[PATCH] D98414: [clangd] Turn off implicit cancellation based on client capabilities

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



Comment at: clang-tools-extra/clangd/ClangdServer.h:153
+/// to cancel. Clients that always cancel stale requests should clear this.
+bool ImplicitCancellation = true;
+

this makes sense as is, but i wonder if we should lift this to LSPServer 
instead.

3.17 specs also introduce `retryOnContentModified`, which is supposed to be a 
list of RPC names. so if we decide to take that into account, rather than 
deciding on what's "transient" ourselves, having all of this hardcoded in 
clangdserver would be limiting. 

We can accept a cancellation policy on all of the ClangdServer endpoints, have 
some sensible defaults in clangdlspserver, enable those to be overwritten by 
client specs on initialize. (or if we don't want to make them part of the 
signature i suppose we can make use of config/context, but ... yikes). WDYT?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98414

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


[PATCH] D95635: [CMake] Actually require python 3.6 or greater

2021-03-11 Thread Christopher Tetreault via Phabricator via cfe-commits
ctetreau updated this revision to Diff 329965.
ctetreau added a comment.
This revision is now accepted and ready to land.

Only require if adding test suite targets


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95635

Files:
  clang/CMakeLists.txt
  lld/CMakeLists.txt
  llvm/CMakeLists.txt
  mlir/CMakeLists.txt


Index: mlir/CMakeLists.txt
===
--- mlir/CMakeLists.txt
+++ mlir/CMakeLists.txt
@@ -79,7 +79,12 @@
 
 if(MLIR_BINDINGS_PYTHON_ENABLED)
   include(MLIRDetectPythonEnv)
-  find_package(Python3 COMPONENTS Interpreter Development NumPy REQUIRED)
+  if (LLVM_INCLUDE_TESTS)
+# Test suite uses features of 3.6
+find_package(Python3 3.6 COMPONENTS Interpreter Development NumPy REQUIRED)
+  else()
+find_package(Python3 COMPONENTS Interpreter Development NumPy REQUIRED)
+  endif()
   message(STATUS "Found python include dirs: ${Python3_INCLUDE_DIRS}")
   message(STATUS "Found python libraries: ${Python3_LIBRARIES}")
   message(STATUS "Found numpy v${Python3_NumPy_VERSION}: 
${Python3_NumPy_INCLUDE_DIRS}")
Index: llvm/CMakeLists.txt
===
--- llvm/CMakeLists.txt
+++ llvm/CMakeLists.txt
@@ -697,7 +697,12 @@
 
 include(HandleLLVMOptions)
 
-find_package(Python3 REQUIRED COMPONENTS Interpreter)
+if (LLVM_INCLUDE_TESTS)
+  # Test suite uses features of 3.6
+  find_package(Python3 3.6 REQUIRED COMPONENTS Interpreter)
+else()
+  find_package(Python3 REQUIRED COMPONENTS Interpreter)
+endif()
 
 ##
 
Index: lld/CMakeLists.txt
===
--- lld/CMakeLists.txt
+++ lld/CMakeLists.txt
@@ -57,7 +57,7 @@
   include(CheckAtomic)
 
   if(LLVM_INCLUDE_TESTS)
-find_package(Python3 REQUIRED COMPONENTS Interpreter)
+find_package(Python3 3.6 REQUIRED COMPONENTS Interpreter)
 
 # Check prebuilt llvm/utils.
 if(EXISTS ${LLVM_TOOLS_BINARY_DIR}/FileCheck${CMAKE_EXECUTABLE_SUFFIX}
Index: clang/CMakeLists.txt
===
--- clang/CMakeLists.txt
+++ clang/CMakeLists.txt
@@ -131,7 +131,7 @@
   set( CMAKE_ARCHIVE_OUTPUT_DIRECTORY 
${CMAKE_BINARY_DIR}/lib${LLVM_LIBDIR_SUFFIX} )
 
   if(LLVM_INCLUDE_TESTS)
-find_package(Python3 REQUIRED COMPONENTS Interpreter)
+find_package(Python3 3.6 REQUIRED COMPONENTS Interpreter)
 
 # Check prebuilt llvm/utils.
 if(EXISTS ${LLVM_TOOLS_BINARY_DIR}/FileCheck${CMAKE_EXECUTABLE_SUFFIX}


Index: mlir/CMakeLists.txt
===
--- mlir/CMakeLists.txt
+++ mlir/CMakeLists.txt
@@ -79,7 +79,12 @@
 
 if(MLIR_BINDINGS_PYTHON_ENABLED)
   include(MLIRDetectPythonEnv)
-  find_package(Python3 COMPONENTS Interpreter Development NumPy REQUIRED)
+  if (LLVM_INCLUDE_TESTS)
+# Test suite uses features of 3.6
+find_package(Python3 3.6 COMPONENTS Interpreter Development NumPy REQUIRED)
+  else()
+find_package(Python3 COMPONENTS Interpreter Development NumPy REQUIRED)
+  endif()
   message(STATUS "Found python include dirs: ${Python3_INCLUDE_DIRS}")
   message(STATUS "Found python libraries: ${Python3_LIBRARIES}")
   message(STATUS "Found numpy v${Python3_NumPy_VERSION}: ${Python3_NumPy_INCLUDE_DIRS}")
Index: llvm/CMakeLists.txt
===
--- llvm/CMakeLists.txt
+++ llvm/CMakeLists.txt
@@ -697,7 +697,12 @@
 
 include(HandleLLVMOptions)
 
-find_package(Python3 REQUIRED COMPONENTS Interpreter)
+if (LLVM_INCLUDE_TESTS)
+  # Test suite uses features of 3.6
+  find_package(Python3 3.6 REQUIRED COMPONENTS Interpreter)
+else()
+  find_package(Python3 REQUIRED COMPONENTS Interpreter)
+endif()
 
 ##
 
Index: lld/CMakeLists.txt
===
--- lld/CMakeLists.txt
+++ lld/CMakeLists.txt
@@ -57,7 +57,7 @@
   include(CheckAtomic)
 
   if(LLVM_INCLUDE_TESTS)
-find_package(Python3 REQUIRED COMPONENTS Interpreter)
+find_package(Python3 3.6 REQUIRED COMPONENTS Interpreter)
 
 # Check prebuilt llvm/utils.
 if(EXISTS ${LLVM_TOOLS_BINARY_DIR}/FileCheck${CMAKE_EXECUTABLE_SUFFIX}
Index: clang/CMakeLists.txt
===
--- clang/CMakeLists.txt
+++ clang/CMakeLists.txt
@@ -131,7 +131,7 @@
   set( CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib${LLVM_LIBDIR_SUFFIX} )
 
   if(LLVM_INCLUDE_TESTS)
-find_package(Python3 REQUIRED COMPONENTS Interpreter)
+find_package(Python3 3.6 REQUIRED COMPONENTS Interpreter)
 
 # Check prebuilt llvm/utils.
 if(EXISTS ${LLVM_TOOLS_BINARY_DIR}/FileCheck${CMAKE_EXECUTABLE_SUFFIX}
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D95635: [CMake] Require python 3.6 if enabling LLVM test targets

2021-03-11 Thread Christopher Tetreault via Phabricator via cfe-commits
ctetreau requested review of this revision.
ctetreau added a comment.

Ping


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95635

___
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-11 Thread Arnamoy B via Phabricator via cfe-commits
arnamoy10 updated this revision to Diff 329970.
arnamoy10 added a comment.
Herald added a subscriber: ormris.

1. Updated to set the default search directory for the intrinsic module
2. Modified the test case to check the prepend behavior


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
  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/test/Driver/Inputs/iso_fortran_env.mod
===

[PATCH] D82547: [Debugify] Expose original debug info preservation check as CC1 option

2021-03-11 Thread Djordje Todorovic via Phabricator via cfe-commits
djtodoro updated this revision to Diff 329972.
djtodoro added a comment.

- rebase on top of trunk
- refactor the code

ping :)


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

https://reviews.llvm.org/D82547

Files:
  clang/include/clang/Basic/CodeGenOptions.def
  clang/include/clang/Basic/CodeGenOptions.h
  clang/include/clang/Driver/Options.td
  clang/lib/CodeGen/BackendUtil.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/test/Driver/verify-debug-info-preservation.c
  llvm/docs/HowToUpdateDebugInfo.rst

Index: llvm/docs/HowToUpdateDebugInfo.rst
===
--- llvm/docs/HowToUpdateDebugInfo.rst
+++ llvm/docs/HowToUpdateDebugInfo.rst
@@ -376,6 +376,17 @@
 
   $ llvm-original-di-preservation.py sample.json sample.html
 
+Testing of original debug info preservation can be invoked from front-end level
+as follows:
+
+.. code-block:: bash
+
+  # Test each pass.
+  $ clang -Xclang -fverify-debuginfo-preserve -g -O2 sample.c
+
+  # Test each pass and export the issues report into the JSON file.
+  $ clang -Xclang -fverify-debuginfo-preserve -Xclang -fverify-debuginfo-preserve-export=sample.json -g -O2 sample.c
+
 Mutation testing for MIR-level transformations
 --
 
Index: clang/test/Driver/verify-debug-info-preservation.c
===
--- /dev/null
+++ clang/test/Driver/verify-debug-info-preservation.c
@@ -0,0 +1,14 @@
+// We support the CC1 options for testing whether each LLVM pass preserves
+// original debug info.
+
+// RUN: %clang -g -Xclang -fverify-debuginfo-preserve -### %s 2>&1 \
+// RUN: | FileCheck --check-prefix=VERIFYDIPRESERVE %s
+
+// VERIFYDIPRESERVE: "-fverify-debuginfo-preserve"
+
+// RUN: %clang -g -Xclang -fverify-debuginfo-preserve \
+// RUN: -Xclang -fverify-debuginfo-preserve-export=%t.json -### %s 2>&1 \
+// RUN: | FileCheck --check-prefix=VERIFYDIPRESERVE-JSON-EXPORT %s
+
+// VERIFYDIPRESERVE-JSON-EXPORT: "-fverify-debuginfo-preserve"
+// VERIFYDIPRESERVE-JSON-EXPORT: "-fverify-debuginfo-preserve-export={{.*}}"
Index: clang/lib/Frontend/CompilerInvocation.cpp
===
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -1641,6 +1641,14 @@
   llvm::is_contained(DebugEntryValueArchs, T.getArch()))
 Opts.EmitCallSiteInfo = true;
 
+  Opts.EnableDIPreservationVerify = Args.hasArg(OPT_fverify_debuginfo_preserve);
+  // Ignore the option if the -fverify-debuginfo-preserve wasn't enabled.
+  if (Opts.EnableDIPreservationVerify &&
+  Args.hasArg(OPT_fverify_debuginfo_preserve_export)) {
+Opts.DIBugsReportFilePath = std::string(
+Args.getLastArgValue(OPT_fverify_debuginfo_preserve_export));
+  }
+
   Opts.NewStructPathTBAA = !Args.hasArg(OPT_no_struct_path_tbaa) &&
Args.hasArg(OPT_new_struct_path_tbaa);
   Opts.OptimizeSize = getOptimizationLevelSize(Args);
Index: clang/lib/CodeGen/BackendUtil.cpp
===
--- clang/lib/CodeGen/BackendUtil.cpp
+++ clang/lib/CodeGen/BackendUtil.cpp
@@ -81,6 +81,7 @@
 #include "llvm/Transforms/Scalar/LowerMatrixIntrinsics.h"
 #include "llvm/Transforms/Utils.h"
 #include "llvm/Transforms/Utils/CanonicalizeAliases.h"
+#include "llvm/Transforms/Utils/Debugify.h"
 #include "llvm/Transforms/Utils/EntryExitInstrumenter.h"
 #include "llvm/Transforms/Utils/NameAnonGlobals.h"
 #include "llvm/Transforms/Utils/SymbolRewriter.h"
@@ -945,7 +946,16 @@
   if (TM)
 TheModule->setDataLayout(TM->createDataLayout());
 
-  legacy::PassManager PerModulePasses;
+  DebugifyCustomPassManager PerModulePasses;
+  DebugInfoPerPassMap DIPreservationMap;
+  if (CodeGenOpts.EnableDIPreservationVerify) {
+PerModulePasses.setDebugifyMode(DebugifyMode::OriginalDebugInfo);
+PerModulePasses.setDIPreservationMap(DIPreservationMap);
+
+if (!CodeGenOpts.DIBugsReportFilePath.empty())
+  PerModulePasses.setOrigDIVerifyBugsReportFilePath(
+  CodeGenOpts.DIBugsReportFilePath);
+  }
   PerModulePasses.add(
   createTargetTransformInfoWrapperPass(getTargetIRAnalysis()));
 
Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -4865,6 +4865,16 @@
 "fexperimental-debug-variable-locations">,
 HelpText<"Use experimental new value-tracking variable locations">,
 MarshallingInfoFlag>;
+def fverify_debuginfo_preserve
+: Flag<["-"], "fverify-debuginfo-preserve">,
+  HelpText<"Enable Debug Info Metadata preservation testing in "
+   "optimizations.">;
+def fverify_debuginfo_preserve_export
+: Joined<["-"], "fverify-debuginfo-preserve-export=">,
+  MetaVarName<"">,
+  HelpText<"Export debug info (by

[PATCH] D98414: [clangd] Turn off implicit cancellation based on client capabilities

2021-03-11 Thread Sam McCall via Phabricator via cfe-commits
sammccall added inline comments.



Comment at: clang-tools-extra/clangd/ClangdServer.h:153
+/// to cancel. Clients that always cancel stale requests should clear this.
+bool ImplicitCancellation = true;
+

kadircet wrote:
> this makes sense as is, but i wonder if we should lift this to LSPServer 
> instead.
> 
> 3.17 specs also introduce `retryOnContentModified`, which is supposed to be a 
> list of RPC names. so if we decide to take that into account, rather than 
> deciding on what's "transient" ourselves, having all of this hardcoded in 
> clangdserver would be limiting. 
> 
> We can accept a cancellation policy on all of the ClangdServer endpoints, 
> have some sensible defaults in clangdlspserver, enable those to be 
> overwritten by client specs on initialize. (or if we don't want to make them 
> part of the signature i suppose we can make use of config/context, but ... 
> yikes). WDYT?
I thought about this, but I don't think it's better...

 - it's complicated and boilerplatey with the method names, way out of 
proportion to the value here
 - I think "will the client take care of cancellation" is actually the more 
pertinent question rather than "will the client retry if we cancel"
 - we want to disable this (entirely) in C++ embedders, and a boolean option is 
the simplest way to do that.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98414

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


[PATCH] D57838: [clang-cl] support /Oy- on aarch64

2021-03-11 Thread Kevin Rico via Phabricator via cfe-commits
krico4272 added a comment.
Herald added a subscriber: danielkiss.

In D57838#1388400 , @mstorsjo wrote:

> LGTM



In D57838#1388400 , @mstorsjo wrote:

> LGTM

F15823649: reboot.zip 


Repository:
  rC Clang

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

https://reviews.llvm.org/D57838

___
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-11 Thread Nathan Hjelm via Phabricator via cfe-commits
hjelmn created this revision.
hjelmn added reviewers: krasimir, djasper.
hjelmn requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

The option SpaceBeforeForLoopSemiColon controls whether clang-format puts
a space before the semi-colons in a for loop. When disabled (default) there
is no change to the current behavior. When enabled clang-format will put a
space before semi-colons in for loops:

enabled:

for (int i = 0 ; i < 10 ; ++i) {}

disabled:

for (int i = 0; i < 10; ++i) {}

Signed-off-by: Nathan Hjelm 


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D98429

Files:
  clang/docs/ClangFormatStyleOptions.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,15 @@
InvertedSpaceStyle);
 }
 
+TEST_F(FormatTest, ConfigurableSpaceBeforeForLoopSemiColon) {
+  FormatStyle NoSpaceStyle = getLLVMStyle();
+  verifyFormat("for (i = 0; i < 10; ++i) {\n}", NoSpaceStyle);
+
+  FormatStyle Space = getLLVMStyle();
+  Space.SpaceBeforeForLoopSemiColon = true;
+  verifyFormat("for (i = 0 ; i < 10 ; ++i) {\n}", Space);
+}
+
 TEST_F(FormatTest, ConfigurableSpaceAroundPointerQualifiers) {
   FormatStyle Style = getLLVMStyle();
 
@@ -15610,6 +15619,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
=

[PATCH] D86855: Convert __m64 intrinsics to unconditionally use SSE2 instead of MMX instructions.

2021-03-11 Thread James Y Knight via Phabricator via cfe-commits
jyknight added a comment.

Ping, thanks!

Or, if you have suggestions on how to make it easier to review, I'd be open to 
that.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86855

___
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-11 Thread Arnamoy B via Phabricator via cfe-commits
arnamoy10 updated this revision to Diff 329976.
arnamoy10 added a comment.

Clang-formatting


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
  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/test/Driver/Inputs/iso_fortran_env.mod
===
--- /dev/null
+++ flang/test/Driver/Inputs/iso_fortran_env.mod
@@ -0,0 +1,6 @@
+! DUMMY module
+module iso_fortran_env
+u

[PATCH] D95635: [CMake] Require python 3.6 if enabling LLVM test targets

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

would it make sense to syndicate the minimal version in a single variable, say 
`LLVM_MINIMAL_PYTHON_VERSION`, and use it in several place instead of 
hard-coding the value across multiple files?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95635

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


[PATCH] D96090: [analyzer] Replace StoreManager::CastRetrievedVal with SValBuilder::evalCast

2021-03-11 Thread Denys Petrov via Phabricator via cfe-commits
ASDenysPetrov updated this revision to Diff 329982.
ASDenysPetrov added a comment.

Updated.

In D96090#2618410 , @NoQ wrote:

> In all cases we're supposed to have an **original** type, whether we need it 
> or not. Simply because we're simulating a typed language. If we don't have it 
> it's a bug.

I agree. That's how `evalCastFromNonLoc` and `evalCastFromLoc` work now. 
Finally I want to replace them along with passing a correct **original** type. 
This is just one another step closer to this direction. I don't want patches be 
too comlicated.

>> Some cases can extract the type from `SVal`
>
> Which is generally impossible because integral casts aren't modeled correctly.

Maybe I'm missing smth, But how about this:

  QualType T = V.castAs().getSymbol()->getType();
  QualType T = 
cast(V.castAs().getAsRegion()).getSymbol()->getType();
  // Belowees are not exact types but well narrowed information which can be 
sufficient.
  V.castAs() <-> OriginalTy->isIntegralOrEnumerationType() 
  V.castAs() | V.castAs() | 
V.castAs() <-> Loc::isLocType(CastTy)
  V.castAs() <-> OriginalTy->isMemberPointerType() 
 (I guess)
  ...

> None of these ideal situations leave room for an API that receives the type 
> //optionally//.

I've returned back `OriginalTy` param from a **default** to a **regular** one 
as @steakhal advised in D96090#261 
.


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

https://reviews.llvm.org/D96090

Files:
  clang/include/clang/StaticAnalyzer/Core/PathSensitive/Store.h
  clang/lib/StaticAnalyzer/Core/RegionStore.cpp
  clang/lib/StaticAnalyzer/Core/SValBuilder.cpp
  clang/lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp
  clang/lib/StaticAnalyzer/Core/Store.cpp

Index: clang/lib/StaticAnalyzer/Core/Store.cpp
===
--- clang/lib/StaticAnalyzer/Core/Store.cpp
+++ clang/lib/StaticAnalyzer/Core/Store.cpp
@@ -394,48 +394,6 @@
   return UnknownVal();
 }
 
-static bool hasSameUnqualifiedPointeeType(QualType ty1, QualType ty2) {
-  return ty1->getPointeeType().getCanonicalType().getTypePtr() ==
- ty2->getPointeeType().getCanonicalType().getTypePtr();
-}
-
-/// CastRetrievedVal - Used by subclasses of StoreManager to implement
-///  implicit casts that arise from loads from regions that are reinterpreted
-///  as another region.
-SVal StoreManager::CastRetrievedVal(SVal V, const TypedValueRegion *R,
-QualType castTy) {
-  if (castTy.isNull() || V.isUnknownOrUndef())
-return V;
-
-  // The dispatchCast() call below would convert the int into a float.
-  // What we want, however, is a bit-by-bit reinterpretation of the int
-  // as a float, which usually yields nothing garbage. For now skip casts
-  // from ints to floats.
-  // TODO: What other combinations of types are affected?
-  if (castTy->isFloatingType()) {
-SymbolRef Sym = V.getAsSymbol();
-if (Sym && !Sym->getType()->isFloatingType())
-  return UnknownVal();
-  }
-
-  // When retrieving symbolic pointer and expecting a non-void pointer,
-  // wrap them into element regions of the expected type if necessary.
-  // SValBuilder::dispatchCast() doesn't do that, but it is necessary to
-  // make sure that the retrieved value makes sense, because there's no other
-  // cast in the AST that would tell us to cast it to the correct pointer type.
-  // We might need to do that for non-void pointers as well.
-  // FIXME: We really need a single good function to perform casts for us
-  // correctly every time we need it.
-  if (castTy->isPointerType() && !castTy->isVoidPointerType())
-if (const auto *SR = dyn_cast_or_null(V.getAsRegion())) {
-  QualType sr = SR->getSymbol()->getType();
-  if (!hasSameUnqualifiedPointeeType(sr, castTy))
-  return loc::MemRegionVal(castRegion(SR, castTy));
-}
-
-  return svalBuilder.dispatchCast(V, castTy);
-}
-
 SVal StoreManager::getLValueFieldOrIvar(const Decl *D, SVal Base) {
   if (Base.isUnknownOrUndef())
 return Base;
Index: clang/lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp
===
--- clang/lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp
+++ clang/lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp
@@ -65,12 +65,12 @@
 // Transfer function for Casts.
 //===--===//
 
+// FIXME: This function should be eliminated and replaced with `evalCast`
 SVal SimpleSValBuilder::dispatchCast(SVal Val, QualType CastTy) {
-  assert(Val.getAs() || Val.getAs());
-  return Val.getAs() ? evalCastFromLoc(Val.castAs(), CastTy)
-   : evalCastFromNonLoc(Val.castAs(), CastTy);
+  return evalCast(Val, CastTy, QualType{});
 }
 
+// FIXME: This function should be eliminated and replaced with `evalCast`
 SVal SimpleSValBuilder::evalCastFromNonLoc(NonLoc val

[PATCH] D98424: [clangd] Reject renames to non-identifier characters

2021-03-11 Thread Utkarsh Saxena via Phabricator via cfe-commits
usaxena95 accepted this revision.
usaxena95 added a comment.
This revision is now accepted and ready to land.

LGTM. Thanks.




Comment at: clang-tools-extra/clangd/refactor/Rename.cpp:466
+case InvalidName::BadIdentifier:
+  return "the chosen name \"{0}\" is not a valid identifier";
 }

Please format the string with `Reason.Details`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98424

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


[PATCH] D97183: [analyzer] Add NoteTag for smart-ptr get()

2021-03-11 Thread Deep Majumder via Phabricator via cfe-commits
RedDocMD updated this revision to Diff 329989.
RedDocMD added a comment.

Calling trackExpressionValue to mark InnerPointerVal as interesting


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97183

Files:
  clang/lib/StaticAnalyzer/Checkers/SmartPtrChecker.cpp
  clang/lib/StaticAnalyzer/Checkers/SmartPtrModeling.cpp


Index: clang/lib/StaticAnalyzer/Checkers/SmartPtrModeling.cpp
===
--- clang/lib/StaticAnalyzer/Checkers/SmartPtrModeling.cpp
+++ clang/lib/StaticAnalyzer/Checkers/SmartPtrModeling.cpp
@@ -464,7 +464,7 @@
 if (&BR.getBugType() != smartptr::getNullDereferenceBugType() ||
 !BR.isInteresting(ThisRegion))
   return;
-if (!State->assume(InnerPointerVal.castAs(), true))
+if (!BR.isInteresting(InnerPointerVal) || 
!BR.isInteresting(InnerPointerVal.getAsSymbol()))
   return;
 if (ThisRegion->canPrintPretty()) {
   OS << "Obtained null inner pointer from";
Index: clang/lib/StaticAnalyzer/Checkers/SmartPtrChecker.cpp
===
--- clang/lib/StaticAnalyzer/Checkers/SmartPtrChecker.cpp
+++ clang/lib/StaticAnalyzer/Checkers/SmartPtrChecker.cpp
@@ -87,7 +87,12 @@
   auto R = std::make_unique(NullDereferenceBugType,
 OS.str(), ErrNode);
   R->markInteresting(DerefRegion);
-  C.emitReport(std::move(R));
+  const Expr *BugExpr = Call.getOriginExpr();
+  const ProgramStateRef State = C.getState();
+  if (const ExplodedNode *E = C.generateNonFatalErrorNode(State)) {
+bugreporter::trackExpressionValue(E, BugExpr, *R);
+C.emitReport(std::move(R));
+  }
 }
 
 void SmartPtrChecker::explainDereference(llvm::raw_ostream &OS,


Index: clang/lib/StaticAnalyzer/Checkers/SmartPtrModeling.cpp
===
--- clang/lib/StaticAnalyzer/Checkers/SmartPtrModeling.cpp
+++ clang/lib/StaticAnalyzer/Checkers/SmartPtrModeling.cpp
@@ -464,7 +464,7 @@
 if (&BR.getBugType() != smartptr::getNullDereferenceBugType() ||
 !BR.isInteresting(ThisRegion))
   return;
-if (!State->assume(InnerPointerVal.castAs(), true))
+if (!BR.isInteresting(InnerPointerVal) || !BR.isInteresting(InnerPointerVal.getAsSymbol()))
   return;
 if (ThisRegion->canPrintPretty()) {
   OS << "Obtained null inner pointer from";
Index: clang/lib/StaticAnalyzer/Checkers/SmartPtrChecker.cpp
===
--- clang/lib/StaticAnalyzer/Checkers/SmartPtrChecker.cpp
+++ clang/lib/StaticAnalyzer/Checkers/SmartPtrChecker.cpp
@@ -87,7 +87,12 @@
   auto R = std::make_unique(NullDereferenceBugType,
 OS.str(), ErrNode);
   R->markInteresting(DerefRegion);
-  C.emitReport(std::move(R));
+  const Expr *BugExpr = Call.getOriginExpr();
+  const ProgramStateRef State = C.getState();
+  if (const ExplodedNode *E = C.generateNonFatalErrorNode(State)) {
+bugreporter::trackExpressionValue(E, BugExpr, *R);
+C.emitReport(std::move(R));
+  }
 }
 
 void SmartPtrChecker::explainDereference(llvm::raw_ostream &OS,
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D98414: [clangd] Turn off implicit cancellation based on client capabilities

2021-03-11 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/ClangdServer.h:153
+/// to cancel. Clients that always cancel stale requests should clear this.
+bool ImplicitCancellation = true;
+

sammccall wrote:
> kadircet wrote:
> > this makes sense as is, but i wonder if we should lift this to LSPServer 
> > instead.
> > 
> > 3.17 specs also introduce `retryOnContentModified`, which is supposed to be 
> > a list of RPC names. so if we decide to take that into account, rather than 
> > deciding on what's "transient" ourselves, having all of this hardcoded in 
> > clangdserver would be limiting. 
> > 
> > We can accept a cancellation policy on all of the ClangdServer endpoints, 
> > have some sensible defaults in clangdlspserver, enable those to be 
> > overwritten by client specs on initialize. (or if we don't want to make 
> > them part of the signature i suppose we can make use of config/context, but 
> > ... yikes). WDYT?
> I thought about this, but I don't think it's better...
> 
>  - it's complicated and boilerplatey with the method names, way out of 
> proportion to the value here
>  - I think "will the client take care of cancellation" is actually the more 
> pertinent question rather than "will the client retry if we cancel"
>  - we want to disable this (entirely) in C++ embedders, and a boolean option 
> is the simplest way to do that.
> we want to disable this (entirely) in C++ embedders, and a boolean option is 
> the simplest way to do that.

i think it should be okay for embedders to specify what behavior they want per 
action, but i agree with the other two points. thanks for the explanation!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98414

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


[PATCH] D98433: [C++2b] [P1102] Accept lambdas without parameter list ().

2021-03-11 Thread Marek Kurdej via Phabricator via cfe-commits
curdeius created this revision.
curdeius added reviewers: rsmith, aaron.ballman, faisalv.
curdeius requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

- http://eel.is/c++draft/expr.prim.lambda
- http://wg21.link/P1102


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D98433

Files:
  clang/lib/Parse/ParseExprCXX.cpp
  clang/test/Parser/cxx2b-lambdas.cpp
  clang/www/cxx_status.html

Index: clang/www/cxx_status.html
===
--- clang/www/cxx_status.html
+++ clang/www/cxx_status.html
@@ -63,7 +63,7 @@
 
  C++2b (tentatively C++23)
  -std=c++2b
- No
+ Partial
 
 
 
@@ -1276,7 +1276,7 @@
 
   Make () in lambdas optional in all cases
   https://wg21.link/p1102r2";>P1102R2
-  No
+  Clang 13
 
 
 
Index: clang/test/Parser/cxx2b-lambdas.cpp
===
--- /dev/null
+++ clang/test/Parser/cxx2b-lambdas.cpp
@@ -0,0 +1,22 @@
+// RUN: %clang_cc1 -std=c++2b %s -verify
+
+auto L0 = [] constexpr {};
+auto L1 = [] mutable {};
+auto L2 = [] noexcept {};
+auto L3 = [] constexpr mutable {};
+auto L4 = [] mutable constexpr {};
+auto L5 = [] constexpr mutable noexcept {};
+auto L6 = [s = 1] mutable {};
+auto L7 = [s = 1] constexpr mutable noexcept {};
+auto L8 = [] -> bool { return true; };
+auto L9 = [] { return true; };
+auto L10 = [] noexcept { return true; };
+auto L11 = [] -> bool { return true; };
+auto L12 = [] consteval {};
+auto L13 = [] requires requires() { true; }
+{};
+auto L15 = [] [[maybe_unused]]{};
+
+auto XL0 = [] mutable constexpr mutable {};// expected-error{{cannot appear multiple times}}
+auto XL1 = [] constexpr mutable constexpr {};  // expected-error{{cannot appear multiple times}}
+auto XL2 = []) constexpr mutable constexpr {}; // expected-error{{expected body}}
Index: clang/lib/Parse/ParseExprCXX.cpp
===
--- clang/lib/Parse/ParseExprCXX.cpp
+++ clang/lib/Parse/ParseExprCXX.cpp
@@ -688,9 +688,9 @@
 /// ParseLambdaExpression - Parse a C++11 lambda expression.
 ///
 ///   lambda-expression:
-/// lambda-introducer lambda-declarator[opt] compound-statement
+/// lambda-introducer lambda-declarator compound-statement
 /// lambda-introducer '<' template-parameter-list '>'
-/// lambda-declarator[opt] compound-statement
+/// lambda-declarator compound-statement
 ///
 ///   lambda-introducer:
 /// '[' lambda-capture[opt] ']'
@@ -722,9 +722,13 @@
 /// '&' identifier initializer
 ///
 ///   lambda-declarator:
-/// '(' parameter-declaration-clause ')' attribute-specifier[opt]
-///   'mutable'[opt] exception-specification[opt]
-///   trailing-return-type[opt]
+/// lambda-specifiers [C++2b]
+/// '(' parameter-declaration-clause ')' lambda-specifiers
+/// requires-clause[opt]
+///
+///   lambda-specifiers:
+/// decl-specifier-seq[opt] noexcept-specifier[opt]
+/// attribute-specifier-seq[opt] trailing-return-type[opt]
 ///
 ExprResult Parser::ParseLambdaExpression() {
   // Parse lambda-introducer.
@@ -1315,11 +1319,92 @@
 
   TypeResult TrailingReturnType;
   SourceLocation TrailingReturnTypeLoc;
+
+  auto ParseLambdaSpecifiers =
+  [&](SourceLocation LParenLoc, SourceLocation RParenLoc,
+  MutableArrayRef ParamInfo,
+  SourceLocation EllipsisLoc) {
+SourceLocation DeclEndLoc = RParenLoc;
+
+// GNU-style attributes must be parsed before the mutable specifier to
+// be compatible with GCC. MSVC-style attributes must be parsed before
+// the mutable specifier to be compatible with MSVC.
+MaybeParseAttributes(PAKM_GNU | PAKM_Declspec, Attr);
+
+// Parse mutable-opt and/or constexpr-opt or consteval-opt, and update
+// the DeclEndLoc.
+SourceLocation MutableLoc;
+SourceLocation ConstexprLoc;
+SourceLocation ConstevalLoc;
+tryConsumeLambdaSpecifierToken(*this, MutableLoc, ConstexprLoc,
+   ConstevalLoc, DeclEndLoc);
+
+addConstexprToLambdaDeclSpecifier(*this, ConstexprLoc, DS);
+addConstevalToLambdaDeclSpecifier(*this, ConstevalLoc, DS);
+// Parse exception-specification[opt].
+ExceptionSpecificationType ESpecType = EST_None;
+SourceRange ESpecRange;
+SmallVector DynamicExceptions;
+SmallVector DynamicExceptionRanges;
+ExprResult NoexceptExpr;
+CachedTokens *ExceptionSpecTokens;
+ESpecType = tryParseExceptionSpecification(
+/*Delayed=*/false, ESpecRange, DynamicExceptions,
+DynamicExceptionRanges, NoexceptExpr, ExceptionSpecTokens);
+
+if (ESpecType != EST_None)
+  DeclEndLoc = ESpecRange.getEnd();
+
+// Parse attribute-specifier[

[PATCH] D97183: [analyzer] Add NoteTag for smart-ptr get()

2021-03-11 Thread Deep Majumder via Phabricator via cfe-commits
RedDocMD added a comment.

@NoQ, I am using `trackExpressionValue` to add intersetingness to the 
`InnerPointerVal`. That solves the original problem. However, it is causing the 
**MoveChecker** to add extra warnings to use-after-move cases. Essentially, 
when a `unique_ptr` is moved and subsequently used, it triggers two warnings - 
one from `SmartPointerModelling` and another from `MoveChecker`. It seems to me 
that two separate checkers are tracking the same bug - use after move. 
So should I make another patch to modify `SmartPointerModelling` to not emit 
warnings on use after move (instead just leaving the GDM updating code)? Or is 
there a better solution to this?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97183

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


[PATCH] D98433: [C++2b] [P1102] Accept lambdas without parameter list ().

2021-03-11 Thread Marek Kurdej via Phabricator via cfe-commits
curdeius updated this revision to Diff 329998.
curdeius added a comment.

Revert unintended changes.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98433

Files:
  clang/lib/Parse/ParseExprCXX.cpp
  clang/test/Parser/cxx2b-lambdas.cpp
  clang/www/cxx_status.html

Index: clang/www/cxx_status.html
===
--- clang/www/cxx_status.html
+++ clang/www/cxx_status.html
@@ -63,7 +63,7 @@
 
  C++2b (tentatively C++23)
  -std=c++2b
- No
+ Partial
 
 
 
@@ -1276,7 +1276,7 @@
 
   Make () in lambdas optional in all cases
   https://wg21.link/p1102r2";>P1102R2
-  No
+  Clang 13
 
 
 
Index: clang/test/Parser/cxx2b-lambdas.cpp
===
--- /dev/null
+++ clang/test/Parser/cxx2b-lambdas.cpp
@@ -0,0 +1,22 @@
+// RUN: %clang_cc1 -std=c++2b %s -verify
+
+auto L0 = [] constexpr {};
+auto L1 = [] mutable {};
+auto L2 = [] noexcept {};
+auto L3 = [] constexpr mutable {};
+auto L4 = [] mutable constexpr {};
+auto L5 = [] constexpr mutable noexcept {};
+auto L6 = [s = 1] mutable {};
+auto L7 = [s = 1] constexpr mutable noexcept {};
+auto L8 = [] -> bool { return true; };
+auto L9 = [] { return true; };
+auto L10 = [] noexcept { return true; };
+auto L11 = [] -> bool { return true; };
+auto L12 = [] consteval {};
+auto L13 = [] requires requires() { true; }
+{};
+auto L15 = [] [[maybe_unused]]{};
+
+auto XL0 = [] mutable constexpr mutable {};// expected-error{{cannot appear multiple times}}
+auto XL1 = [] constexpr mutable constexpr {};  // expected-error{{cannot appear multiple times}}
+auto XL2 = []) constexpr mutable constexpr {}; // expected-error{{expected body}}
Index: clang/lib/Parse/ParseExprCXX.cpp
===
--- clang/lib/Parse/ParseExprCXX.cpp
+++ clang/lib/Parse/ParseExprCXX.cpp
@@ -688,9 +688,9 @@
 /// ParseLambdaExpression - Parse a C++11 lambda expression.
 ///
 ///   lambda-expression:
-/// lambda-introducer lambda-declarator[opt] compound-statement
+/// lambda-introducer lambda-declarator compound-statement
 /// lambda-introducer '<' template-parameter-list '>'
-/// lambda-declarator[opt] compound-statement
+/// lambda-declarator compound-statement
 ///
 ///   lambda-introducer:
 /// '[' lambda-capture[opt] ']'
@@ -722,9 +722,13 @@
 /// '&' identifier initializer
 ///
 ///   lambda-declarator:
-/// '(' parameter-declaration-clause ')' attribute-specifier[opt]
-///   'mutable'[opt] exception-specification[opt]
-///   trailing-return-type[opt]
+/// lambda-specifiers [C++2b]
+/// '(' parameter-declaration-clause ')' lambda-specifiers
+/// requires-clause[opt]
+///
+///   lambda-specifiers:
+/// decl-specifier-seq[opt] noexcept-specifier[opt]
+/// attribute-specifier-seq[opt] trailing-return-type[opt]
 ///
 ExprResult Parser::ParseLambdaExpression() {
   // Parse lambda-introducer.
@@ -1315,11 +1319,92 @@
 
   TypeResult TrailingReturnType;
   SourceLocation TrailingReturnTypeLoc;
+
+  auto ParseLambdaSpecifiers =
+  [&](SourceLocation LParenLoc, SourceLocation RParenLoc,
+  MutableArrayRef ParamInfo,
+  SourceLocation EllipsisLoc) {
+SourceLocation DeclEndLoc = RParenLoc;
+
+// GNU-style attributes must be parsed before the mutable specifier to
+// be compatible with GCC. MSVC-style attributes must be parsed before
+// the mutable specifier to be compatible with MSVC.
+MaybeParseAttributes(PAKM_GNU | PAKM_Declspec, Attr);
+
+// Parse mutable-opt and/or constexpr-opt or consteval-opt, and update
+// the DeclEndLoc.
+SourceLocation MutableLoc;
+SourceLocation ConstexprLoc;
+SourceLocation ConstevalLoc;
+tryConsumeLambdaSpecifierToken(*this, MutableLoc, ConstexprLoc,
+   ConstevalLoc, DeclEndLoc);
+
+addConstexprToLambdaDeclSpecifier(*this, ConstexprLoc, DS);
+addConstevalToLambdaDeclSpecifier(*this, ConstevalLoc, DS);
+// Parse exception-specification[opt].
+ExceptionSpecificationType ESpecType = EST_None;
+SourceRange ESpecRange;
+SmallVector DynamicExceptions;
+SmallVector DynamicExceptionRanges;
+ExprResult NoexceptExpr;
+CachedTokens *ExceptionSpecTokens;
+ESpecType = tryParseExceptionSpecification(
+/*Delayed=*/false, ESpecRange, DynamicExceptions,
+DynamicExceptionRanges, NoexceptExpr, ExceptionSpecTokens);
+
+if (ESpecType != EST_None)
+  DeclEndLoc = ESpecRange.getEnd();
+
+// Parse attribute-specifier[opt].
+MaybeParseCXX11Attributes(Attr, &DeclEndLoc);
+
+// Parse OpenCL addr space attribu

[PATCH] D97857: [Matrix] Add support for matrix-by-scalar division.

2021-03-11 Thread Florian Hahn via Phabricator via cfe-commits
fhahn updated this revision to Diff 33.
fhahn added a comment.

Thank you very much John! I applied your suggestions to the wording and removed 
the unneeded language feature.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97857

Files:
  clang/docs/MatrixTypes.rst
  clang/include/clang/Basic/Features.def
  clang/lib/AST/Type.cpp
  clang/lib/CodeGen/CGExprScalar.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/test/CodeGen/matrix-type-operators.c
  clang/test/CodeGen/matrix-type.c
  clang/test/Sema/matrix-type-operators.c
  llvm/include/llvm/IR/MatrixBuilder.h

Index: llvm/include/llvm/IR/MatrixBuilder.h
===
--- llvm/include/llvm/IR/MatrixBuilder.h
+++ llvm/include/llvm/IR/MatrixBuilder.h
@@ -215,6 +215,22 @@
 return B.CreateMul(LHS, RHS);
   }
 
+  /// Divide matrix \p LHS by scalar \p RHS. If the operands are integers, \p
+  /// IsUnsigned indicates whether UDiv or SDiv should be used.
+  Value *CreateScalarDiv(Value *LHS, Value *RHS, bool IsUnsigned) {
+assert(LHS->getType()->isVectorTy() && !RHS->getType()->isVectorTy());
+assert(!isa(LHS->getType()) &&
+   "LHS Assumed to be fixed width");
+RHS =
+B.CreateVectorSplat(cast(LHS->getType())->getElementCount(),
+RHS, "scalar.splat");
+return cast(LHS->getType())
+   ->getElementType()
+   ->isFloatingPointTy()
+   ? B.CreateFDiv(LHS, RHS)
+   : (IsUnsigned ? B.CreateUDiv(LHS, RHS) : B.CreateSDiv(LHS, RHS));
+  }
+
   /// Extracts the element at (\p RowIdx, \p ColumnIdx) from \p Matrix.
   Value *CreateExtractElement(Value *Matrix, Value *RowIdx, Value *ColumnIdx,
   unsigned NumRows, Twine const &Name = "") {
Index: clang/test/Sema/matrix-type-operators.c
===
--- clang/test/Sema/matrix-type-operators.c
+++ clang/test/Sema/matrix-type-operators.c
@@ -94,6 +94,40 @@
   // expected-error@-1 {{assigning to 'float' from incompatible type 'sx10x10_t' (aka 'float __attribute__((matrix_type(10, 10)))')}}
 }
 
+void mat_scalar_divide(sx10x10_t a, sx5x10_t b, float sf, char *p) {
+  // Shape of multiplication result does not match the type of b.
+  b = a / sf;
+  // expected-error@-1 {{assigning to 'sx5x10_t' (aka 'float __attribute__((matrix_type(5, 10)))') from incompatible type 'sx10x10_t' (aka 'float __attribute__((matrix_type(10, 10)))')}}
+  b = sf / a;
+  // expected-error@-1 {{invalid operands to binary expression ('float' and 'sx10x10_t' (aka 'float __attribute__((matrix_type(10, 10)))'))}}
+
+  a = a / p;
+  // expected-error@-1 {{invalid operands to binary expression ('sx10x10_t' (aka 'float __attribute__((matrix_type(10, 10)))') and 'char *')}}
+  a = p / a;
+  // expected-error@-1 {{invalid operands to binary expression ('char *' and 'sx10x10_t' (aka 'float __attribute__((matrix_type(10, 10)))'))}}
+
+  sf = a / sf;
+  // expected-error@-1 {{assigning to 'float' from incompatible type 'sx10x10_t' (aka 'float __attribute__((matrix_type(10, 10)))')}}
+}
+
+void matrix_matrix_divide(sx10x10_t a, sx5x10_t b, ix10x5_t c, ix10x10_t d, float sf, char *p) {
+  // Matrix by matrix division is not supported.
+  a = a / a;
+  // expected-error@-1 {{invalid operands to binary expression ('sx10x10_t' (aka 'float __attribute__((matrix_type(10, 10)))') and 'sx10x10_t')}}
+
+  b = a / a;
+  // expected-error@-1 {{invalid operands to binary expression ('sx10x10_t' (aka 'float __attribute__((matrix_type(10, 10)))') and 'sx10x10_t')}}
+
+  // Check element type mismatches.
+  a = b / c;
+  // expected-error@-1 {{invalid operands to binary expression ('sx5x10_t' (aka 'float __attribute__((matrix_type(5, 10)))') and 'ix10x5_t' (aka 'int __attribute__((matrix_type(10, 5)))'))}}
+  d = a / a;
+  // expected-error@-1 {{invalid operands to binary expression ('sx10x10_t' (aka 'float __attribute__((matrix_type(10, 10)))') and 'sx10x10_t')}}
+
+  p = a / a;
+  // expected-error@-1 {{invalid operands to binary expression ('sx10x10_t' (aka 'float __attribute__((matrix_type(10, 10)))') and 'sx10x10_t')}}
+}
+
 sx5x10_t get_matrix();
 
 void insert(sx5x10_t a, float f) {
Index: clang/test/CodeGen/matrix-type.c
===
--- clang/test/CodeGen/matrix-type.c
+++ clang/test/CodeGen/matrix-type.c
@@ -4,6 +4,10 @@
 #error Expected extension 'matrix_types' to be enabled
 #endif
 
+#if !__has_extension(matrix_types_scalar_division)
+#error Expected extension 'matrix_types_scalar_division' to be enabled
+#endif
+
 typedef double dx5x5_t __attribute__((matrix_type(5, 5)));
 
 // CHECK: %struct.Matrix = type { i8, [12 x float], float }
Index: clang/test/CodeGen/matrix-type-operators.c
===
--- clang/test/CodeGen/matrix-typ

[PATCH] D98433: [C++2b] [P1102] Accept lambdas without parameter list ().

2021-03-11 Thread Marek Kurdej via Phabricator via cfe-commits
curdeius added a comment.

Is there something else that I should test?




Comment at: clang/lib/Parse/ParseExprCXX.cpp:1447
+std::vector EmptyParamInfo;
+ParseLambdaSpecifiers(/*LParenLoc=*/NoLoc, /*RParenLoc=*/NoLoc,
+  EmptyParamInfo, /*EllipsisLoc=*/NoLoc);

I'm not sure what I should do with `LParenLoc` and `RParenLoc`. Any idea?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98433

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


[PATCH] D98165: [clangd] Make ProjectAwareIndex optionally sync

2021-03-11 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet added a comment.

ping


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98165

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


[PATCH] D98037: [clangd] Add config block for Completion and option for AllScopes

2021-03-11 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet added a comment.

ping


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98037

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


[PATCH] D98436: [Hexagon] Support inlined use of cs0 and cs1

2021-03-11 Thread Sid Manning via Phabricator via cfe-commits
sidneym created this revision.
sidneym added reviewers: bcain, kparzysz.
Herald added a subscriber: hiraditya.
sidneym requested review of this revision.
Herald added projects: clang, LLVM.
Herald added a subscriber: cfe-commits.

Allow inline assembly to reference cs0 and cs1 registers.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D98436

Files:
  clang/lib/Basic/Targets/Hexagon.cpp
  llvm/lib/Target/Hexagon/HexagonISelLowering.cpp
  llvm/test/CodeGen/Hexagon/namedreg.ll


Index: llvm/test/CodeGen/Hexagon/namedreg.ll
===
--- llvm/test/CodeGen/Hexagon/namedreg.ll
+++ llvm/test/CodeGen/Hexagon/namedreg.ll
@@ -4,10 +4,29 @@
   %0 = call i32 @llvm.read_register.i32(metadata !0)
   ret i32 %0
 }
-
 declare i32 @llvm.read_register.i32(metadata) #1
 
+define dso_local i32 @rcs0() #0 {
+entry:
+  %0 = call i32 @llvm.read_register.i32(metadata !1)
+  ret i32 %0
+}
+
+define dso_local i32 @rcs1() #0 {
+entry:
+  %0 = call i32 @llvm.read_register.i32(metadata !2)
+  ret i32 %0
+}
+
+
+
 !llvm.named.register.r19 = !{!0}
+!llvm.named.register.cs0 = !{!1}
+!llvm.named.register.cs1 = !{!2}
 
 !0 = !{!"r19"}
+!1 = !{!"cs0"}
+!2 = !{!"cs1"}
 ; CHECK: r0 = r19
+; CHECK: r0 = cs0
+; CHECK: r0 = cs1
Index: llvm/lib/Target/Hexagon/HexagonISelLowering.cpp
===
--- llvm/lib/Target/Hexagon/HexagonISelLowering.cpp
+++ llvm/lib/Target/Hexagon/HexagonISelLowering.cpp
@@ -308,6 +308,8 @@
  .Case("m1", Hexagon::M1)
  .Case("usr", Hexagon::USR)
  .Case("ugp", Hexagon::UGP)
+ .Case("cs0", Hexagon::CS0)
+ .Case("cs1", Hexagon::CS1)
  .Default(Register());
   if (Reg)
 return Reg;
Index: clang/lib/Basic/Targets/Hexagon.cpp
===
--- clang/lib/Basic/Targets/Hexagon.cpp
+++ clang/lib/Basic/Targets/Hexagon.cpp
@@ -136,7 +136,7 @@
 "r9",  "r10", "r11", "r12", "r13", "r14", "r15", "r16", "r17",
 "r18", "r19", "r20", "r21", "r22", "r23", "r24", "r25", "r26",
 "r27", "r28", "r29", "r30", "r31", "p0",  "p1",  "p2",  "p3",
-"sa0", "lc0", "sa1", "lc1", "m0",  "m1",  "usr", "ugp",
+"sa0", "lc0", "sa1", "lc1", "m0",  "m1",  "usr", "ugp", "cs0", "cs1",
 "r1:0", "r3:2", "r5:4", "r7:6", "r9:8", "r11:10", "r13:12", "r15:14",
 "r17:16", "r19:18", "r21:20", "r23:22", "r25:24", "r27:26", "r29:28",
 "r31:30"


Index: llvm/test/CodeGen/Hexagon/namedreg.ll
===
--- llvm/test/CodeGen/Hexagon/namedreg.ll
+++ llvm/test/CodeGen/Hexagon/namedreg.ll
@@ -4,10 +4,29 @@
   %0 = call i32 @llvm.read_register.i32(metadata !0)
   ret i32 %0
 }
-
 declare i32 @llvm.read_register.i32(metadata) #1
 
+define dso_local i32 @rcs0() #0 {
+entry:
+  %0 = call i32 @llvm.read_register.i32(metadata !1)
+  ret i32 %0
+}
+
+define dso_local i32 @rcs1() #0 {
+entry:
+  %0 = call i32 @llvm.read_register.i32(metadata !2)
+  ret i32 %0
+}
+
+
+
 !llvm.named.register.r19 = !{!0}
+!llvm.named.register.cs0 = !{!1}
+!llvm.named.register.cs1 = !{!2}
 
 !0 = !{!"r19"}
+!1 = !{!"cs0"}
+!2 = !{!"cs1"}
 ; CHECK: r0 = r19
+; CHECK: r0 = cs0
+; CHECK: r0 = cs1
Index: llvm/lib/Target/Hexagon/HexagonISelLowering.cpp
===
--- llvm/lib/Target/Hexagon/HexagonISelLowering.cpp
+++ llvm/lib/Target/Hexagon/HexagonISelLowering.cpp
@@ -308,6 +308,8 @@
  .Case("m1", Hexagon::M1)
  .Case("usr", Hexagon::USR)
  .Case("ugp", Hexagon::UGP)
+ .Case("cs0", Hexagon::CS0)
+ .Case("cs1", Hexagon::CS1)
  .Default(Register());
   if (Reg)
 return Reg;
Index: clang/lib/Basic/Targets/Hexagon.cpp
===
--- clang/lib/Basic/Targets/Hexagon.cpp
+++ clang/lib/Basic/Targets/Hexagon.cpp
@@ -136,7 +136,7 @@
 "r9",  "r10", "r11", "r12", "r13", "r14", "r15", "r16", "r17",
 "r18", "r19", "r20", "r21", "r22", "r23", "r24", "r25", "r26",
 "r27", "r28", "r29", "r30", "r31", "p0",  "p1",  "p2",  "p3",
-"sa0", "lc0", "sa1", "lc1", "m0",  "m1",  "usr", "ugp",
+"sa0", "lc0", "sa1", "lc1", "m0",  "m1",  "usr", "ugp", "cs0", "cs1",
 "r1:0", "r3:2", "r5:4", "r7:6", "r9:8", "r11:10", "r13:12", "r15:14",
 "r17:16", "r19:18", "r21:20", "r23:22", "r25:24", "r27:26", "r29:28",
 "r31:30"
___
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-11 Thread Andrzej Warzynski via Phabricator via cfe-commits
awarzynski added a comment.

Thank you for updating this @arnamoy10 !




Comment at: flang/lib/Frontend/CompilerInvocation.cpp:26
 #include "llvm/Support/raw_ostream.h"
+
+#include "llvm/Support/FileSystem.h"

Not needed



Comment at: flang/lib/Frontend/CompilerInvocation.cpp:292
+  std::string driverPath = llvm::sys::fs::getMainExecutable(nullptr, nullptr);
+  driverPath = driverPath.substr(0, driverPath.find_last_of("/\\"));
+  return driverPath.append("/../tools/flang/include/flang/");

This will not work on Windows, will it? I couldn't find any API to deal with 
this in a OS-agnostic way. Perhaps just remove 9 characters at the end? Or use 
`#ifndef _WIN32`?



Comment at: flang/test/Driver/Inputs/ieee_arithmetic.mod:1
+! DUMMY module
+module ieee_arithmetic

I think that currently the contents of this file are not relevant. So I would 
limit it to some helpful comment, e.g.:
```
Added for testing purposes. The contents of this file are currently not 
relevant.
```


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

https://reviews.llvm.org/D97080

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


[PATCH] D97894: [Driver] Drop $sysroot/usr special case from Gentoo gcc-config detection

2021-03-11 Thread Manoj Gupta via Phabricator via cfe-commits
manojgupta accepted this revision.
manojgupta added a comment.

@MaskRay I have verified that Chrome OS builds are not affected by this change.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97894

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


[PATCH] D97894: [Driver] Drop $sysroot/usr special case from Gentoo gcc-config detection

2021-03-11 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added a comment.

In D97894#2620077 , @manojgupta wrote:

> @MaskRay I have verified that Chrome OS builds are not affected by this 
> change.

Thank you for testing!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97894

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


[clang] 8d8a919 - [Driver] Drop $sysroot/usr special case from Gentoo gcc-config detection

2021-03-11 Thread Fangrui Song via cfe-commits

Author: Fangrui Song
Date: 2021-03-11T10:13:01-08:00
New Revision: 8d8a9190db19b487198680adab9a6ca173f20bb3

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

LOG: [Driver] Drop $sysroot/usr special case from Gentoo gcc-config detection

If --gcc-toolchain is specified, we should detect GCC installation there, and 
suppress other directories for detection.

Reviewed By: mgorny, manojgupta

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

Added: 


Modified: 
clang/lib/Driver/ToolChains/Gnu.cpp

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/Gnu.cpp 
b/clang/lib/Driver/ToolChains/Gnu.cpp
index 3d88053c6b08..fbf2f29e0514 100644
--- a/clang/lib/Driver/ToolChains/Gnu.cpp
+++ b/clang/lib/Driver/ToolChains/Gnu.cpp
@@ -1934,13 +1934,10 @@ void Generic_GCC::GCCInstallationDetector::init(
   // Typically /usr.
   AddDefaultGCCPrefixes(TargetTriple, Prefixes, D.SysRoot);
 }
-  }
 
-  // Try to respect gcc-config on Gentoo. However, do that only
-  // if --gcc-toolchain is not provided or equal to the Gentoo install
-  // in /usr. This avoids accidentally enforcing the system GCC version
-  // when using a custom toolchain.
-  if (GCCToolchainDir == "" || GCCToolchainDir == D.SysRoot + "/usr") {
+// Try to respect gcc-config on Gentoo if --gcc-toolchain is not provided.
+// This avoids accidentally enforcing the system GCC version when using a
+// custom toolchain.
 SmallVector GentooTestTriples;
 // Try to match an exact triple as target triple first.
 // e.g. crossdev -S x86_64-gentoo-linux-gnu will install gcc libs for



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


[PATCH] D97894: [Driver] Drop $sysroot/usr special case from Gentoo gcc-config detection

2021-03-11 Thread Fangrui Song via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG8d8a9190db19: [Driver] Drop $sysroot/usr special case from 
Gentoo gcc-config detection (authored by MaskRay).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97894

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


Index: clang/lib/Driver/ToolChains/Gnu.cpp
===
--- clang/lib/Driver/ToolChains/Gnu.cpp
+++ clang/lib/Driver/ToolChains/Gnu.cpp
@@ -1934,13 +1934,10 @@
   // Typically /usr.
   AddDefaultGCCPrefixes(TargetTriple, Prefixes, D.SysRoot);
 }
-  }
 
-  // Try to respect gcc-config on Gentoo. However, do that only
-  // if --gcc-toolchain is not provided or equal to the Gentoo install
-  // in /usr. This avoids accidentally enforcing the system GCC version
-  // when using a custom toolchain.
-  if (GCCToolchainDir == "" || GCCToolchainDir == D.SysRoot + "/usr") {
+// Try to respect gcc-config on Gentoo if --gcc-toolchain is not provided.
+// This avoids accidentally enforcing the system GCC version when using a
+// custom toolchain.
 SmallVector GentooTestTriples;
 // Try to match an exact triple as target triple first.
 // e.g. crossdev -S x86_64-gentoo-linux-gnu will install gcc libs for


Index: clang/lib/Driver/ToolChains/Gnu.cpp
===
--- clang/lib/Driver/ToolChains/Gnu.cpp
+++ clang/lib/Driver/ToolChains/Gnu.cpp
@@ -1934,13 +1934,10 @@
   // Typically /usr.
   AddDefaultGCCPrefixes(TargetTriple, Prefixes, D.SysRoot);
 }
-  }
 
-  // Try to respect gcc-config on Gentoo. However, do that only
-  // if --gcc-toolchain is not provided or equal to the Gentoo install
-  // in /usr. This avoids accidentally enforcing the system GCC version
-  // when using a custom toolchain.
-  if (GCCToolchainDir == "" || GCCToolchainDir == D.SysRoot + "/usr") {
+// Try to respect gcc-config on Gentoo if --gcc-toolchain is not provided.
+// This avoids accidentally enforcing the system GCC version when using a
+// custom toolchain.
 SmallVector GentooTestTriples;
 // Try to match an exact triple as target triple first.
 // e.g. crossdev -S x86_64-gentoo-linux-gnu will install gcc libs for
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D98438: Clang: Allow selecting the hash algorithm for file checksums in debug info.

2021-03-11 Thread Arlo Siemsen via Phabricator via cfe-commits
arlosi created this revision.
Herald added subscribers: jansvoboda11, dexonsmith, dang.
arlosi requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Adds clang-cl support for the /ZH: option used to select MD5, SHA1,
or SHA_256 hashing algorithms in debug info.

Previously only the MD5 algorithm was supported.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D98438

Files:
  clang/include/clang/Basic/CodeGenOptions.def
  clang/include/clang/Basic/CodeGenOptions.h
  clang/include/clang/Driver/Options.td
  clang/lib/CodeGen/CGDebugInfo.cpp
  clang/lib/CodeGen/CGDebugInfo.h
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Frontend/CompilerInvocation.cpp

Index: clang/lib/Frontend/CompilerInvocation.cpp
===
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -1928,6 +1928,20 @@
   else if (Args.hasArg(options::OPT_fno_finite_loops))
 Opts.FiniteLoops = CodeGenOptions::FiniteLoopsKind::Never;
 
+  if (Arg *A = Args.getLastArg(OPT_gsrc_hash_algorithm_EQ)) {
+unsigned Val = llvm::StringSwitch(A->getValue())
+   .Case("md5", CodeGenOptions::CSK_MD5)
+   .Case("sha1", CodeGenOptions::CSK_SHA1)
+   .Case("sha256", CodeGenOptions::CSK_SHA256)
+   .Default(~0U);
+if (Val == ~0U)
+  Diags.Report(diag::err_drv_invalid_value)
+  << A->getAsString(Args) << A->getValue();
+else
+  Opts.setDebugSrcHashAlgorithm(
+  static_cast(Val));
+  }
+
   return Success && Diags.getNumErrors() == NumErrorsBefore;
 }
 
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -7107,6 +7107,19 @@
   D.Diag(diag::err_drv_invalid_value) << A->getSpelling() << GuardArgs;
 }
   }
+
+  if (Arg *A = Args.getLastArg(options::OPT__SLASH_ZH)) {
+StringRef Val = A->getValue();
+if (Val.equals("MD5")) {
+  CmdArgs.push_back("-gsrc-hash-algorithm=md5");
+} else if (Val.equals("SHA1")) {
+  CmdArgs.push_back("-gsrc-hash-algorithm=sha1");
+} else if (Val.equals("SHA_256")) {
+  CmdArgs.push_back("-gsrc-hash-algorithm=sha256");
+} else {
+  D.Diag(diag::err_drv_invalid_value) << A->getAsString(Args) << Val;
+}
+  }
 }
 
 const char *Clang::getBaseInputName(const ArgList &Args,
Index: clang/lib/CodeGen/CGDebugInfo.h
===
--- clang/lib/CodeGen/CGDebugInfo.h
+++ clang/lib/CodeGen/CGDebugInfo.h
@@ -572,8 +572,9 @@
   void CreateCompileUnit();
 
   /// Compute the file checksum debug info for input file ID.
-  Optional
-  computeChecksum(FileID FID, SmallString<32> &Checksum) const;
+  /// Storage of the checksum string is owned by the caller.
+  Optional>
+  computeChecksum(FileID FID, SmallString<64> &Checksum) const;
 
   /// Get the source of the given file ID.
   Optional getSource(const SourceManager &SM, FileID FID);
Index: clang/lib/CodeGen/CGDebugInfo.cpp
===
--- clang/lib/CodeGen/CGDebugInfo.cpp
+++ clang/lib/CodeGen/CGDebugInfo.cpp
@@ -44,9 +44,13 @@
 #include "llvm/IR/Metadata.h"
 #include "llvm/IR/Module.h"
 #include "llvm/Support/FileSystem.h"
+#include "llvm/Support/Format.h"
 #include "llvm/Support/MD5.h"
 #include "llvm/Support/Path.h"
+#include "llvm/Support/SHA1.h"
+#include "llvm/Support/SHA256.h"
 #include "llvm/Support/TimeProfiler.h"
+#include "llvm/Support/raw_ostream.h"
 using namespace clang;
 using namespace clang::CodeGen;
 
@@ -361,10 +365,12 @@
   return StringRef();
 }
 
-Optional
-CGDebugInfo::computeChecksum(FileID FID, SmallString<32> &Checksum) const {
+Optional>
+CGDebugInfo::computeChecksum(FileID FID, SmallString<64> &Checksum) const {
   Checksum.clear();
 
+  llvm::DIFile::ChecksumKind CSKind;
+  Optional> CSInfo;
   if (!CGM.getCodeGenOpts().EmitCodeView &&
   CGM.getCodeGenOpts().DwarfVersion < 5)
 return None;
@@ -374,14 +380,42 @@
   if (!MemBuffer)
 return None;
 
-  llvm::MD5 Hash;
-  llvm::MD5::MD5Result Result;
-
-  Hash.update(MemBuffer->getBuffer());
-  Hash.final(Result);
+  switch (CGM.getCodeGenOpts().getDebugSrcHashAlgorithm()) {
+  case clang::CodeGenOptions::CSK_MD5: {
+CSKind = llvm::DIFile::CSK_MD5;
+llvm::MD5 Hash;
+llvm::MD5::MD5Result Result;
+Hash.update(MemBuffer->getBuffer());
+Hash.final(Result);
+Checksum = Result.digest();
+break;
+  }
+  case clang::CodeGenOptions::CSK_SHA1: {
+CSKind = llvm::DIFile::CSK_SHA1;
+llvm::SHA1 Hash;
+Hash.update(MemBuffer->getBuffer());
+StringRef Result = Hash.final();
+llvm::raw_svector_ostream Res(Checksum);
+for (int i = 0; i < 20; ++i)
+  Res << llvm::format("%.2x", static_cast(Result[

[PATCH] D97411: [DebugInfo] Add an attribute to force type info to be emitted for types that are required to be complete.

2021-03-11 Thread Amy Huang via Phabricator via cfe-commits
akhuang added a reviewer: EricWF.
akhuang added a subscriber: EricWF.
akhuang added a comment.

@EricWF, comments on using this attribute in libc++ vs fixing the code 
otherwise?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97411

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


  1   2   >