[clang] ace56d4 - [WoA][MSVC] Use default linker setting in MSVC-compatible driver

2021-03-18 Thread Maxim Kuvyrkov via cfe-commits

Author: Maxim Kuvyrkov
Date: 2021-03-18T07:42:55Z
New Revision: ace56d41aca8cac7cead9c2c97278aa50fc945b1

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

LOG: [WoA][MSVC] Use default linker setting in MSVC-compatible driver

At the moment "link.exe" is hard-coded as default linker in MSVC.cpp,
so there's no way to use LLD as default linker for MSVC driver.

This patch adds checking of CLANG_DEFAULT_LINKER to MSVC.cpp.

Reviewed By: asl

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

Added: 


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

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/MSVC.cpp 
b/clang/lib/Driver/ToolChains/MSVC.cpp
index 96de02378ca2..38ad7125b4af 100644
--- a/clang/lib/Driver/ToolChains/MSVC.cpp
+++ b/clang/lib/Driver/ToolChains/MSVC.cpp
@@ -11,6 +11,7 @@
 #include "Darwin.h"
 #include "clang/Basic/CharInfo.h"
 #include "clang/Basic/Version.h"
+#include "clang/Config/config.h"
 #include "clang/Driver/Compilation.h"
 #include "clang/Driver/Driver.h"
 #include "clang/Driver/DriverDiagnostic.h"
@@ -577,7 +578,10 @@ void visualstudio::Linker::ConstructJob(Compilation &C, 
const JobAction &JA,
   // translate 'lld' into 'lld-link', and in the case of the regular msvc
   // linker, we need to use a special search algorithm.
   llvm::SmallString<128> linkPath;
-  StringRef Linker = Args.getLastArgValue(options::OPT_fuse_ld_EQ, "link");
+  StringRef Linker = Args.getLastArgValue(options::OPT_fuse_ld_EQ,
+ CLANG_DEFAULT_LINKER);
+  if (Linker.empty())
+Linker = "link";
   if (Linker.equals_lower("lld"))
 Linker = "lld-link";
 



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


[PATCH] D98493: [WoA][MSVC] Use default linker setting in MSVC-compatible driver

2021-03-18 Thread Maxim Kuvyrkov 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 rGace56d41aca8: [WoA][MSVC] Use default linker setting in 
MSVC-compatible driver (authored by maxim-kuvyrkov).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98493

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


Index: clang/lib/Driver/ToolChains/MSVC.cpp
===
--- clang/lib/Driver/ToolChains/MSVC.cpp
+++ clang/lib/Driver/ToolChains/MSVC.cpp
@@ -11,6 +11,7 @@
 #include "Darwin.h"
 #include "clang/Basic/CharInfo.h"
 #include "clang/Basic/Version.h"
+#include "clang/Config/config.h"
 #include "clang/Driver/Compilation.h"
 #include "clang/Driver/Driver.h"
 #include "clang/Driver/DriverDiagnostic.h"
@@ -577,7 +578,10 @@
   // translate 'lld' into 'lld-link', and in the case of the regular msvc
   // linker, we need to use a special search algorithm.
   llvm::SmallString<128> linkPath;
-  StringRef Linker = Args.getLastArgValue(options::OPT_fuse_ld_EQ, "link");
+  StringRef Linker = Args.getLastArgValue(options::OPT_fuse_ld_EQ,
+ CLANG_DEFAULT_LINKER);
+  if (Linker.empty())
+Linker = "link";
   if (Linker.equals_lower("lld"))
 Linker = "lld-link";
 


Index: clang/lib/Driver/ToolChains/MSVC.cpp
===
--- clang/lib/Driver/ToolChains/MSVC.cpp
+++ clang/lib/Driver/ToolChains/MSVC.cpp
@@ -11,6 +11,7 @@
 #include "Darwin.h"
 #include "clang/Basic/CharInfo.h"
 #include "clang/Basic/Version.h"
+#include "clang/Config/config.h"
 #include "clang/Driver/Compilation.h"
 #include "clang/Driver/Driver.h"
 #include "clang/Driver/DriverDiagnostic.h"
@@ -577,7 +578,10 @@
   // translate 'lld' into 'lld-link', and in the case of the regular msvc
   // linker, we need to use a special search algorithm.
   llvm::SmallString<128> linkPath;
-  StringRef Linker = Args.getLastArgValue(options::OPT_fuse_ld_EQ, "link");
+  StringRef Linker = Args.getLastArgValue(options::OPT_fuse_ld_EQ,
+	  CLANG_DEFAULT_LINKER);
+  if (Linker.empty())
+Linker = "link";
   if (Linker.equals_lower("lld"))
 Linker = "lld-link";
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D98493: [WoA][MSVC] Use default linker setting in MSVC-compatible driver

2021-03-18 Thread Maxim Kuvyrkov via Phabricator via cfe-commits
maxim-kuvyrkov added a subscriber: tstellar.
maxim-kuvyrkov added a comment.

@tstellar , OK to backport to release/12.x if buildbots are happy with this?
I've filed https://bugs.llvm.org/show_bug.cgi?id=49624 with background info.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98493

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


[clang] 6802fdf - [NFC] Minor cleanup to use default setting of getLastArg()

2021-03-18 Thread Maxim Kuvyrkov via cfe-commits

Author: Maxim Kuvyrkov
Date: 2021-03-18T07:47:31Z
New Revision: 6802fdf8871f69d52b06d0a2b7f62f3af8292690

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

LOG: [NFC] Minor cleanup to use default setting of getLastArg()

Noticed this while I was looking at linker defaults.

Reviewed By: asl

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

Added: 


Modified: 
clang/lib/Driver/ToolChain.cpp

Removed: 




diff  --git a/clang/lib/Driver/ToolChain.cpp b/clang/lib/Driver/ToolChain.cpp
index 217ba56c3351..94ae40e1e65f 100644
--- a/clang/lib/Driver/ToolChain.cpp
+++ b/clang/lib/Driver/ToolChain.cpp
@@ -571,8 +571,8 @@ std::string ToolChain::GetLinkerPath(bool *LinkerIsLLD,
 
   // Get -fuse-ld= first to prevent -Wunused-command-line-argument. -fuse-ld= 
is
   // considered as the linker flavor, e.g. "bfd", "gold", or "lld".
-  const Arg* A = Args.getLastArg(options::OPT_fuse_ld_EQ);
-  StringRef UseLinker = A ? A->getValue() : CLANG_DEFAULT_LINKER;
+  StringRef UseLinker = Args.getLastArgValue(options::OPT_fuse_ld_EQ,
+CLANG_DEFAULT_LINKER);
 
   // --ld-path= takes precedence over -fuse-ld= and specifies the executable
   // name. -B, COMPILER_PATH and PATH and consulted if the value does not



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


[PATCH] D98494: [NFC] Minor cleanup to use default setting of getLastArg()

2021-03-18 Thread Maxim Kuvyrkov 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 rG6802fdf8871f: [NFC] Minor cleanup to use default setting of 
getLastArg() (authored by maxim-kuvyrkov).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98494

Files:
  clang/lib/Driver/ToolChain.cpp


Index: clang/lib/Driver/ToolChain.cpp
===
--- clang/lib/Driver/ToolChain.cpp
+++ clang/lib/Driver/ToolChain.cpp
@@ -571,8 +571,8 @@
 
   // Get -fuse-ld= first to prevent -Wunused-command-line-argument. -fuse-ld= 
is
   // considered as the linker flavor, e.g. "bfd", "gold", or "lld".
-  const Arg* A = Args.getLastArg(options::OPT_fuse_ld_EQ);
-  StringRef UseLinker = A ? A->getValue() : CLANG_DEFAULT_LINKER;
+  StringRef UseLinker = Args.getLastArgValue(options::OPT_fuse_ld_EQ,
+CLANG_DEFAULT_LINKER);
 
   // --ld-path= takes precedence over -fuse-ld= and specifies the executable
   // name. -B, COMPILER_PATH and PATH and consulted if the value does not


Index: clang/lib/Driver/ToolChain.cpp
===
--- clang/lib/Driver/ToolChain.cpp
+++ clang/lib/Driver/ToolChain.cpp
@@ -571,8 +571,8 @@
 
   // Get -fuse-ld= first to prevent -Wunused-command-line-argument. -fuse-ld= is
   // considered as the linker flavor, e.g. "bfd", "gold", or "lld".
-  const Arg* A = Args.getLastArg(options::OPT_fuse_ld_EQ);
-  StringRef UseLinker = A ? A->getValue() : CLANG_DEFAULT_LINKER;
+  StringRef UseLinker = Args.getLastArgValue(options::OPT_fuse_ld_EQ,
+	 CLANG_DEFAULT_LINKER);
 
   // --ld-path= takes precedence over -fuse-ld= and specifies the executable
   // name. -B, COMPILER_PATH and PATH and consulted if the value does not
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D90448: [clang] Add type check for explicit instantiation of static data members

2021-03-18 Thread Chuyang Chen via Phabricator via cfe-commits
nomanous added a comment.

Ping @rsmith @dblaikie @MaskRay @Xiangling_L @lebedev.ri


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D90448

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


[PATCH] D87981: [X86] AMX programming model.

2021-03-18 Thread Bing Yu via Phabricator via cfe-commits
yubing added inline comments.



Comment at: llvm/lib/Target/X86/X86PreTileConfig.cpp:90
+INITIALIZE_PASS_BEGIN(X86PreTileConfig, "tilepreconfig",
+  "Tile Register Configure", false, false)
+INITIALIZE_PASS_DEPENDENCY(MachineDominatorTree)

It should be Pre Tile configure instead of Tile Register Configure.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87981

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


[clang] 62948c4 - Revert "[NFC] Minor cleanup to use default setting of getLastArg()"

2021-03-18 Thread Maxim Kuvyrkov via cfe-commits

Author: Maxim Kuvyrkov
Date: 2021-03-18T08:07:02Z
New Revision: 62948c4532d59b59f63409eae5d7f9e4990e5626

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

LOG: Revert "[NFC] Minor cleanup to use default setting of getLastArg()"

The patch was wrong.  We use "const Arg *A" at the end of
GetLinkerPath, so can't remove it.

This reverts commit 6802fdf8871f69d52b06d0a2b7f62f3af8292690.

Added: 


Modified: 
clang/lib/Driver/ToolChain.cpp

Removed: 




diff  --git a/clang/lib/Driver/ToolChain.cpp b/clang/lib/Driver/ToolChain.cpp
index 94ae40e1e65f..217ba56c3351 100644
--- a/clang/lib/Driver/ToolChain.cpp
+++ b/clang/lib/Driver/ToolChain.cpp
@@ -571,8 +571,8 @@ std::string ToolChain::GetLinkerPath(bool *LinkerIsLLD,
 
   // Get -fuse-ld= first to prevent -Wunused-command-line-argument. -fuse-ld= 
is
   // considered as the linker flavor, e.g. "bfd", "gold", or "lld".
-  StringRef UseLinker = Args.getLastArgValue(options::OPT_fuse_ld_EQ,
-CLANG_DEFAULT_LINKER);
+  const Arg* A = Args.getLastArg(options::OPT_fuse_ld_EQ);
+  StringRef UseLinker = A ? A->getValue() : CLANG_DEFAULT_LINKER;
 
   // --ld-path= takes precedence over -fuse-ld= and specifies the executable
   // name. -B, COMPILER_PATH and PATH and consulted if the value does not



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


[PATCH] D98494: [NFC] Minor cleanup to use default setting of getLastArg()

2021-03-18 Thread Maxim Kuvyrkov via Phabricator via cfe-commits
maxim-kuvyrkov added a comment.

The patch was wrong.  We use "const Arg *A" at the end of GetLinkerPath, so 
can't remove it.  I thought I tested this, but, apparently, not.

Reverted in 62948c4532d59b59f63409eae5d7f9e4990e5626 
 .


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98494

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


[PATCH] D98494: [NFC] Minor cleanup to use default setting of getLastArg()

2021-03-18 Thread Anton Korobeynikov via Phabricator via cfe-commits
asl added a comment.

Indeed! And even worse, there is another 'A' shadowing definition below :)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98494

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


[PATCH] D98502: [clang][Checkers] Extend PthreadLockChecker state dump (NFC).

2021-03-18 Thread Balázs Kéri via Phabricator via cfe-commits
balazske updated this revision to Diff 331484.
balazske added a comment.

Change of text in dump, add a test.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98502

Files:
  clang/lib/StaticAnalyzer/Checkers/PthreadLockChecker.cpp
  clang/test/Analysis/pthreadlock_state.c

Index: clang/test/Analysis/pthreadlock_state.c
===
--- /dev/null
+++ clang/test/Analysis/pthreadlock_state.c
@@ -0,0 +1,77 @@
+// RUN: %clang_analyze_cc1 -analyzer-checker=alpha.unix.PthreadLock,debug.ExprInspection 2>&1 %s | FileCheck %s
+
+#include "Inputs/system-header-simulator-for-pthread-lock.h"
+
+#define NULL 0
+
+void clang_analyzer_printState();
+
+pthread_mutex_t mtx;
+
+void test(pthread_mutex_t *mtx1) {
+  clang_analyzer_printState();
+  // CHECK:"checker_messages": null
+
+  pthread_mutex_init(&mtx, NULL);
+  clang_analyzer_printState();
+  // CHECK: "checker_messages": [
+  // CHECK-NEXT:{ "checker": "alpha.core.PthreadLockBase", "messages": [
+  // CHECK-NEXT:  "Mutex states:", 
+  // CHECK-NEXT:  "mtx: unlocked", 
+  // CHECK-NEXT:  ""
+  // CHECK-NEXT:]}
+  // CHECK-NEXT:  ]
+
+  pthread_mutex_lock(&mtx);
+  clang_analyzer_printState();
+  // CHECK: "checker_messages": [
+  // CHECK-NEXT:{ "checker": "alpha.core.PthreadLockBase", "messages": [
+  // CHECK-NEXT:  "Mutex states:", 
+  // CHECK-NEXT:  "mtx: locked", 
+  // CHECK-NEXT:  "Mutex lock order:", 
+  // CHECK-NEXT:  "mtx", 
+  // CHECK-NEXT:  ""
+  // CHECK-NEXT:]}
+  // CHECK-NEXT:  ]
+
+  pthread_mutex_unlock(&mtx);
+  clang_analyzer_printState();
+  // CHECK: "checker_messages": [
+  // CHECK-NEXT:{ "checker": "alpha.core.PthreadLockBase", "messages": [
+  // CHECK-NEXT:  "Mutex states:", 
+  // CHECK-NEXT:  "mtx: unlocked", 
+  // CHECK-NEXT:  ""
+  // CHECK-NEXT:]}
+  // CHECK-NEXT:  ]
+
+  int ret = pthread_mutex_destroy(&mtx);
+  clang_analyzer_printState();
+  // CHECK: "checker_messages": [
+  // CHECK-NEXT:{ "checker": "alpha.core.PthreadLockBase", "messages": [
+  // CHECK-NEXT:  "Mutex states:", 
+  // CHECK-NEXT:  "mtx: unlocked, possibly destroyed", 
+  // CHECK-NEXT:  "Mutexes in unresolved possibly destroyed state:", 
+  // CHECK-NEXT:  "mtx: conj_$11{int, LC1, S1874, #1}", 
+  // CHECK-NEXT:  ""
+  // CHECK-NEXT:]}
+  // CHECK-NEXT:  ]
+
+  if (ret)
+return;
+
+  ret = pthread_mutex_destroy(mtx1);
+  clang_analyzer_printState();
+  // CHECK: "checker_messages": [
+  // CHECK-NEXT:{ "checker": "alpha.core.PthreadLockBase", "messages": [
+  // CHECK-NEXT:  "Mutex states:", 
+  // CHECK-NEXT:  "mtx: destroyed", 
+  // CHECK-NEXT:  "SymRegion{reg_$12}: not tracked, possibly destroyed", 
+  // CHECK-NEXT:  "Mutexes in unresolved possibly destroyed state:", 
+  // CHECK-NEXT:  "SymRegion{reg_$12}: conj_$15{int, LC1, S1921, #1}", 
+  // CHECK-NEXT:  ""
+  // CHECK-NEXT:]}
+  // CHECK-NEXT:  ]
+  if (ret)
+return;
+  pthread_mutex_init(mtx1, NULL);
+}
Index: clang/lib/StaticAnalyzer/Checkers/PthreadLockChecker.cpp
===
--- clang/lib/StaticAnalyzer/Checkers/PthreadLockChecker.cpp
+++ clang/lib/StaticAnalyzer/Checkers/PthreadLockChecker.cpp
@@ -302,7 +302,6 @@
   state = state->set(lockR, LockState::getUnlocked());
   } else
 state = state->set(lockR, LockState::getDestroyed());
-
   // Removing the map entry (lockR, sym) from DestroyRetVal as the lock state is
   // now resolved.
   state = state->remove(lockR);
@@ -339,7 +338,16 @@
 }
   }
 
-  // TODO: Dump destroyed mutex symbols?
+  DestroyRetValTy DRV = State->get();
+  if (!DRV.isEmpty()) {
+Out << Sep << "Mutexes in unresolved possibly destroyed state:" << NL;
+for (auto I : DRV) {
+  I.first->dumpToStream(Out);
+  Out << ": ";
+  I.second->dumpToStream(Out);
+  Out << NL;
+}
+  }
 }
 
 void PthreadLockChecker::AcquirePthreadLock(const CallEvent &Call,
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D98502: [clang][Checkers] Extend PthreadLockChecker state dump (NFC).

2021-03-18 Thread Balázs Kéri via Phabricator via cfe-commits
balazske updated this revision to Diff 331485.
balazske added a comment.

Add accidentally removed empty line.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98502

Files:
  clang/lib/StaticAnalyzer/Checkers/PthreadLockChecker.cpp
  clang/test/Analysis/pthreadlock_state.c

Index: clang/test/Analysis/pthreadlock_state.c
===
--- /dev/null
+++ clang/test/Analysis/pthreadlock_state.c
@@ -0,0 +1,77 @@
+// RUN: %clang_analyze_cc1 -analyzer-checker=alpha.unix.PthreadLock,debug.ExprInspection 2>&1 %s | FileCheck %s
+
+#include "Inputs/system-header-simulator-for-pthread-lock.h"
+
+#define NULL 0
+
+void clang_analyzer_printState();
+
+pthread_mutex_t mtx;
+
+void test(pthread_mutex_t *mtx1) {
+  clang_analyzer_printState();
+  // CHECK:"checker_messages": null
+
+  pthread_mutex_init(&mtx, NULL);
+  clang_analyzer_printState();
+  // CHECK: "checker_messages": [
+  // CHECK-NEXT:{ "checker": "alpha.core.PthreadLockBase", "messages": [
+  // CHECK-NEXT:  "Mutex states:", 
+  // CHECK-NEXT:  "mtx: unlocked", 
+  // CHECK-NEXT:  ""
+  // CHECK-NEXT:]}
+  // CHECK-NEXT:  ]
+
+  pthread_mutex_lock(&mtx);
+  clang_analyzer_printState();
+  // CHECK: "checker_messages": [
+  // CHECK-NEXT:{ "checker": "alpha.core.PthreadLockBase", "messages": [
+  // CHECK-NEXT:  "Mutex states:", 
+  // CHECK-NEXT:  "mtx: locked", 
+  // CHECK-NEXT:  "Mutex lock order:", 
+  // CHECK-NEXT:  "mtx", 
+  // CHECK-NEXT:  ""
+  // CHECK-NEXT:]}
+  // CHECK-NEXT:  ]
+
+  pthread_mutex_unlock(&mtx);
+  clang_analyzer_printState();
+  // CHECK: "checker_messages": [
+  // CHECK-NEXT:{ "checker": "alpha.core.PthreadLockBase", "messages": [
+  // CHECK-NEXT:  "Mutex states:", 
+  // CHECK-NEXT:  "mtx: unlocked", 
+  // CHECK-NEXT:  ""
+  // CHECK-NEXT:]}
+  // CHECK-NEXT:  ]
+
+  int ret = pthread_mutex_destroy(&mtx);
+  clang_analyzer_printState();
+  // CHECK: "checker_messages": [
+  // CHECK-NEXT:{ "checker": "alpha.core.PthreadLockBase", "messages": [
+  // CHECK-NEXT:  "Mutex states:", 
+  // CHECK-NEXT:  "mtx: unlocked, possibly destroyed", 
+  // CHECK-NEXT:  "Mutexes in unresolved possibly destroyed state:", 
+  // CHECK-NEXT:  "mtx: conj_$11{int, LC1, S1874, #1}", 
+  // CHECK-NEXT:  ""
+  // CHECK-NEXT:]}
+  // CHECK-NEXT:  ]
+
+  if (ret)
+return;
+
+  ret = pthread_mutex_destroy(mtx1);
+  clang_analyzer_printState();
+  // CHECK: "checker_messages": [
+  // CHECK-NEXT:{ "checker": "alpha.core.PthreadLockBase", "messages": [
+  // CHECK-NEXT:  "Mutex states:", 
+  // CHECK-NEXT:  "mtx: destroyed", 
+  // CHECK-NEXT:  "SymRegion{reg_$12}: not tracked, possibly destroyed", 
+  // CHECK-NEXT:  "Mutexes in unresolved possibly destroyed state:", 
+  // CHECK-NEXT:  "SymRegion{reg_$12}: conj_$15{int, LC1, S1921, #1}", 
+  // CHECK-NEXT:  ""
+  // CHECK-NEXT:]}
+  // CHECK-NEXT:  ]
+  if (ret)
+return;
+  pthread_mutex_init(mtx1, NULL);
+}
Index: clang/lib/StaticAnalyzer/Checkers/PthreadLockChecker.cpp
===
--- clang/lib/StaticAnalyzer/Checkers/PthreadLockChecker.cpp
+++ clang/lib/StaticAnalyzer/Checkers/PthreadLockChecker.cpp
@@ -339,7 +339,16 @@
 }
   }
 
-  // TODO: Dump destroyed mutex symbols?
+  DestroyRetValTy DRV = State->get();
+  if (!DRV.isEmpty()) {
+Out << Sep << "Mutexes in unresolved possibly destroyed state:" << NL;
+for (auto I : DRV) {
+  I.first->dumpToStream(Out);
+  Out << ": ";
+  I.second->dumpToStream(Out);
+  Out << NL;
+}
+  }
 }
 
 void PthreadLockChecker::AcquirePthreadLock(const CallEvent &Call,
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D87981: [X86] AMX programming model.

2021-03-18 Thread LuoYuanke via Phabricator via cfe-commits
LuoYuanke added inline comments.



Comment at: llvm/lib/Target/X86/X86PreTileConfig.cpp:90
+INITIALIZE_PASS_BEGIN(X86PreTileConfig, "tilepreconfig",
+  "Tile Register Configure", false, false)
+INITIALIZE_PASS_DEPENDENCY(MachineDominatorTree)

yubing wrote:
> It should be Pre Tile configure instead of Tile Register Configure.
You are right. Thanks. Will fix it.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87981

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


[PATCH] D97371: [clang][parser] Remove questionable ProhibitAttributes() call in objc parsing

2021-03-18 Thread Timm Bäder via Phabricator via cfe-commits
tbaeder added a comment.

Thank you.

I'm not looking at this test case:

  void opaque(void);
  void opaque2(void);
  void opaque3(void);
  
  @class C;
  
  int main(int argc, const char * argv[]) {
__attribute__((nomerge)) @try {
  opaque();
} @catch(C *c) {
  opaque2();
} @finally {
  opaque3();
}
  return 0;
  }

and compiling with `-S -emit-llvm`

shows:

  %0 = type opaque
  
  ; Function Attrs: noinline nounwind optnone uwtable
  define dso_local i32 @main(i32 %argc, i8** %argv) #0 {
  entry:
; ...
call void @opaque() #2
; ...
  
  cleanup:  ; preds = %entry, %catch
%cleanup.dest.saved = load i32, i32* %cleanup.dest.slot, align 4
call void @opaque3() #2
%finally.shouldthrow = load i1, i1* %finally.for-eh, align 1
br i1 %finally.shouldthrow, label %finally.rethrow, label %finally.cont
  
  catch:; No predecessors!
; ...
call void @opaque2() #2
; ...
  
  attributes #2 = { nomerge }

So all three function calls have the `nomerge` attribute.

I can't find an existing test case checking that `nomerge`, shall I just add 
this one in `clang/test/CodeGenObjC` in this patch?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97371

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


[PATCH] D98824: [Tooling] Handle compilation databases with clang-cl commands generated by CMake 3.19+

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

thanks for looking into this!

we also had a related report about this in clangd 
, but didn't have time to dive 
into it. this is definitely fixing an issue in interpolating compilation 
database, but unfortunately there are still issues lurking around in clangd and 
command line adjusters.

- any adjuster inserting command line arguments should insert before `--` if 
exists, and any adjuster stripping flags should not strip anything after a 
`--`. these can be found in 
https://github.com/llvm/llvm-project/tree/main/clang/lib/Tooling/ArgumentsAdjusters.cpp
- for clangd we need to ensure resource-dir and sysroot related flags are 
inserted before `--`, if exists in 
https://github.com/llvm/llvm-project/blob/main/clang-tools-extra/clangd/CompileCommands.cpp#L211
- insertion of extra flags should happen after `--` in 
https://github.com/llvm/llvm-project/blob/main/clang-tools-extra/clangd/ConfigCompile.cpp#L271
- we should again stop stripping flags after `--` in 
https://github.com/llvm/llvm-project/blob/main/clang-tools-extra/clangd/CompileCommands.cpp#L478

do you mind fixing those cases too? if not i can also make some follow-ups, but 
as-is this isn't really useful to tools, at least without the adjuster fixes i 
mentioned in the first item(as they are used by almost all clang-based tools), 
the rest is specific to clangd.




Comment at: clang/lib/Tooling/InterpolatingCompilationDatabase.cpp:182
+  if (Opt.matches(OPT__DASH_DASH)) {
+continue;
+  }

isn't everything after double dash treated as inputs? i think this should be a 
`break` instead of a `continue`.



Comment at: clang/lib/Tooling/InterpolatingCompilationDatabase.cpp:243
 }
 Result.CommandLine.push_back(std::string(Filename));
 return Result;

i think it actually makes sense to insert a double dash here too, if the 
filename starts with a `/` or `-` they might actually be treated as compile 
flags rather than filenames.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98824

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


[clang] f1a7d5a - [-Wcalled-once-parameter] Harden analysis in terms of block use

2021-03-18 Thread Valeriy Savchenko via cfe-commits

Author: Valeriy Savchenko
Date: 2021-03-18T12:12:18+03:00
New Revision: f1a7d5a7b0ec810057ff6e88371ab86d1fce812c

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

LOG: [-Wcalled-once-parameter] Harden analysis in terms of block use

This patch introduces a very simple inter-procedural analysis
between blocks and enclosing functions.

We always analyze blocks first (analysis is done as part of semantic
analysis that goes side-by-side with the parsing process), and at the
moment of reporting we don't know how that block will be actually
used.

This patch introduces new logic delaying reports of the "never called"
warnings on blocks.  If we are not sure that the block will be called
exactly once, we shouldn't warn our users about that.  Double calls,
however, don't require such delays.  While analyzing the enclosing
function, we can actually decide what we should do with those
warnings.

Additionally, as a side effect, we can be more confident about blocks
in such context and can treat them not as escapes, but as direct
calls.

rdar://74090107

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

Added: 


Modified: 
clang/include/clang/Analysis/Analyses/CalledOnceCheck.h
clang/include/clang/Sema/AnalysisBasedWarnings.h
clang/lib/Analysis/CalledOnceCheck.cpp
clang/lib/Sema/AnalysisBasedWarnings.cpp
clang/test/SemaObjC/warn-called-once.m

Removed: 




diff  --git a/clang/include/clang/Analysis/Analyses/CalledOnceCheck.h 
b/clang/include/clang/Analysis/Analyses/CalledOnceCheck.h
index fc574c680a44..a0c767bf92d2 100644
--- a/clang/include/clang/Analysis/Analyses/CalledOnceCheck.h
+++ b/clang/include/clang/Analysis/Analyses/CalledOnceCheck.h
@@ -17,6 +17,7 @@
 namespace clang {
 
 class AnalysisDeclContext;
+class BlockDecl;
 class CFG;
 class Decl;
 class DeclContext;
@@ -79,6 +80,7 @@ class CalledOnceCheckHandler {
   /// the path containing the call and not containing the call.  This helps us
   /// to pinpoint a bad path for the user.
   /// \param Parameter -- parameter that should be called once.
+  /// \param Function -- function declaration where the problem occured.
   /// \param Where -- the least common ancestor statement.
   /// \param Reason -- a reason describing the path without a call.
   /// \param IsCalledDirectly -- true, if parameter actually gets called on
@@ -86,9 +88,22 @@ class CalledOnceCheckHandler {
   /// collection, passed as a parameter, etc.).
   /// \param IsCompletionHandler -- true, if parameter is a completion handler.
   virtual void handleNeverCalled(const ParmVarDecl *Parameter,
- const Stmt *Where, NeverCalledReason Reason,
+ const Decl *Function, const Stmt *Where,
+ NeverCalledReason Reason,
  bool IsCalledDirectly,
  bool IsCompletionHandler) {}
+
+  /// Called when the block is guaranteed to be called exactly once.
+  /// It means that we can be stricter with what we report on that block.
+  /// \param Block -- block declaration that is known to be called exactly 
once.
+  virtual void
+  handleBlockThatIsGuaranteedToBeCalledOnce(const BlockDecl *Block) {}
+
+  /// Called when the block has no guarantees about how many times it can get
+  /// called.
+  /// It means that we should be more lenient with reporting warnings in it.
+  /// \param Block -- block declaration in question.
+  virtual void handleBlockWithNoGuarantees(const BlockDecl *Block) {}
 };
 
 /// Check given CFG for 'called once' parameter violations.

diff  --git a/clang/include/clang/Sema/AnalysisBasedWarnings.h 
b/clang/include/clang/Sema/AnalysisBasedWarnings.h
index e13fe955eaf4..49b69c585ff7 100644
--- a/clang/include/clang/Sema/AnalysisBasedWarnings.h
+++ b/clang/include/clang/Sema/AnalysisBasedWarnings.h
@@ -14,6 +14,7 @@
 #define LLVM_CLANG_SEMA_ANALYSISBASEDWARNINGS_H
 
 #include "llvm/ADT/DenseMap.h"
+#include 
 
 namespace clang {
 
@@ -47,6 +48,9 @@ class AnalysisBasedWarnings {
   Sema &S;
   Policy DefaultPolicy;
 
+  class InterProceduralData;
+  std::unique_ptr IPData;
+
   enum VisitFlag { NotVisited = 0, Visited = 1, Pending = 2 };
   llvm::DenseMap VisitedFD;
 
@@ -88,6 +92,7 @@ class AnalysisBasedWarnings {
 
 public:
   AnalysisBasedWarnings(Sema &s);
+  ~AnalysisBasedWarnings();
 
   void IssueWarnings(Policy P, FunctionScopeInfo *fscope,
  const Decl *D, QualType BlockType);
@@ -97,6 +102,7 @@ class AnalysisBasedWarnings {
   void PrintStats() const;
 };
 
-}} // end namespace clang::sema
+} // namespace sema
+} // namespace clang
 
 #endif

diff  --git a/clang/lib/Analysis/CalledOnceCheck.cpp 
b/clang/lib/Analysis/CalledOnceCheck.cpp
index d24e0b500564..2902

[PATCH] D98688: [-Wcalled-once-parameter] Harden analysis in terms of block use

2021-03-18 Thread Valeriy Savchenko via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGf1a7d5a7b0ec: [-Wcalled-once-parameter] Harden analysis in 
terms of block use (authored by vsavchenko).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98688

Files:
  clang/include/clang/Analysis/Analyses/CalledOnceCheck.h
  clang/include/clang/Sema/AnalysisBasedWarnings.h
  clang/lib/Analysis/CalledOnceCheck.cpp
  clang/lib/Sema/AnalysisBasedWarnings.cpp
  clang/test/SemaObjC/warn-called-once.m

Index: clang/test/SemaObjC/warn-called-once.m
===
--- clang/test/SemaObjC/warn-called-once.m
+++ clang/test/SemaObjC/warn-called-once.m
@@ -31,6 +31,16 @@
 @class NSString, Protocol;
 extern void NSLog(NSString *format, ...);
 
+typedef int group_t;
+typedef struct dispatch_queue_s *dispatch_queue_t;
+typedef void (^dispatch_block_t)(void);
+extern dispatch_queue_t queue;
+
+void dispatch_group_async(dispatch_queue_t queue,
+  group_t group,
+  dispatch_block_t block);
+void dispatch_async(dispatch_queue_t queue, dispatch_block_t block);
+
 void escape(void (^callback)(void));
 void escape_void(void *);
 void indirect_call(void (^callback)(void) CALLED_ONCE);
@@ -225,11 +235,11 @@
 }
 
 void block_call_1(void (^callback)(void) CALLED_ONCE) {
-  indirect_call(^{
-callback();
-  });
-  callback();
-  // no-warning
+  indirect_call( // expected-note{{previous call is here}}
+  ^{
+callback();
+  });
+  callback(); // expected-warning{{'callback' parameter marked 'called_once' is called twice}}
 }
 
 void block_call_2(void (^callback)(void) CALLED_ONCE) {
@@ -255,7 +265,7 @@
   // expected-warning@-1{{'callback' parameter marked 'called_once' is never used when taking false branch}}
   escape(callback);
 }
-  }();
+  }(); // no-warning
 }
 
 void block_call_5(void (^outer)(void) CALLED_ONCE) {
@@ -273,6 +283,32 @@
   outer(); // expected-warning{{'outer' parameter marked 'called_once' is called twice}}
 }
 
+void block_dispatch_call(int cond, void (^callback)(void) CALLED_ONCE) {
+  dispatch_async(queue, ^{
+if (cond) // expected-warning{{'callback' parameter marked 'called_once' is never called when taking false branch}}
+  callback();
+  });
+}
+
+void block_escape_call_1(int cond, void (^callback)(void) CALLED_ONCE) {
+  escape_void((__bridge void *)^{
+if (cond) {
+  // no-warning
+  callback();
+}
+  });
+}
+
+void block_escape_call_2(int cond, void (^callback)(void) CALLED_ONCE) {
+  escape_void((__bridge void *)^{
+if (cond) {
+  callback(); // expected-note{{previous call is here}}
+}
+// Double call can still be reported.
+callback(); // expected-warning{{'callback' parameter marked 'called_once' is called twice}}
+  });
+}
+
 void never_called_one_exit(int cond, void (^callback)(void) CALLED_ONCE) {
   if (!cond) // expected-warning{{'callback' parameter marked 'called_once' is never called when taking true branch}}
 return;
@@ -822,11 +858,10 @@
 
 - (void)block_call_1:(void (^)(void))CALLED_ONCE callback {
   // We consider captures by blocks as escapes
-  [self indirect_call:(^{
+  [self indirect_call:(^{ // expected-note{{previous call is here}}
   callback();
 })];
-  callback();
-  // no-warning
+  callback(); // expected-warning{{'callback' parameter marked 'called_once' is called twice}}
 }
 
 - (void)block_call_2:(int)cond callback:(void (^)(void))CALLED_ONCE callback {
Index: clang/lib/Sema/AnalysisBasedWarnings.cpp
===
--- clang/lib/Sema/AnalysisBasedWarnings.cpp
+++ clang/lib/Sema/AnalysisBasedWarnings.cpp
@@ -1506,6 +1506,25 @@
   }
 }
 
+namespace clang {
+namespace {
+typedef SmallVector OptionalNotes;
+typedef std::pair DelayedDiag;
+typedef std::list DiagList;
+
+struct SortDiagBySourceLocation {
+  SourceManager &SM;
+  SortDiagBySourceLocation(SourceManager &SM) : SM(SM) {}
+
+  bool operator()(const DelayedDiag &left, const DelayedDiag &right) {
+// Although this call will be slow, this is only called when outputting
+// multiple warnings.
+return SM.isBeforeInTranslationUnit(left.first.first, right.first.first);
+  }
+};
+} // anonymous namespace
+} // namespace clang
+
 namespace {
 class UninitValsDiagReporter : public UninitVariablesHandler {
   Sema &S;
@@ -1626,9 +1645,35 @@
   }
 };
 
+/// Inter-procedural data for the called-once checker.
+class CalledOnceInterProceduralData {
+public:
+  // Add the delayed warning for the given block.
+  void addDelayedWarning(const BlockDecl *Block,
+ PartialDiagnosticAt &&Warning) {
+DelayedBlockWarnings[Block].emplace_back(std::move(Warning));
+  }
+  // Report all of the warnings we've gathered for the given block.
+  void flushWarnings(const BlockDecl *Block, 

[PATCH] D98757: [AMX] Not fold constant bitcast into amx intrisic

2021-03-18 Thread Florian Hahn via Phabricator via cfe-commits
fhahn added a comment.

In D98757#2633396 , @xiangzhangllvm 
wrote:

> In D98757#2631042 , @lebedev.ri 
> wrote:
>
>> The ongoing special-casing of `X86_AMXTy` through the llvm due to the 
>> inability of the existing backend passes to handle certain llvm ir 
>> constructs.
>
> We have bring up it to llvm-dev.
> BTW,** All the Type should see as target independent.** (Even it support by 
> less targets or 1 target)
>
> Current we see  “ if (Ty.isVectorTy()) {…}” is make sense in Mid-End. 
> Why we can’t see “if (Ty.isX86_AMXTy()){…}” is make sense ?

One thing to note is that there appears to be no documentation of `x86_amx` in 
the langref (maybe there is, but searching for `x86_amx` did not surface 
anything). Without that, making any decisions based on the type in general LLVM 
optimizations seems problematic, because the type is effectively not specified.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98757

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


[clang] 4a7afc9 - [-Wcalled-once-parameter] Fix false positives for cleanup attr

2021-03-18 Thread Valeriy Savchenko via cfe-commits

Author: Valeriy Savchenko
Date: 2021-03-18T12:32:16+03:00
New Revision: 4a7afc9a8843f4793296a260f7153fd2ef4ec497

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

LOG: [-Wcalled-once-parameter] Fix false positives for cleanup attr

Cleanup attribute allows users to attach a destructor-like functions
to variable declarations to be called whenever they leave the scope.
The logic of such functions is not supported by the Clang's CFG and
is too hard to be reasoned about.  In order to avoid false positives
in this situation, we assume that we didn't see ALL of the executtion
paths of the function and, thus, can warn only about multiple call
violation.

rdar://74441906

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

Added: 


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

Removed: 




diff  --git a/clang/lib/Analysis/CalledOnceCheck.cpp 
b/clang/lib/Analysis/CalledOnceCheck.cpp
index 29021b0a9016..ab56d3e3c988 100644
--- a/clang/lib/Analysis/CalledOnceCheck.cpp
+++ b/clang/lib/Analysis/CalledOnceCheck.cpp
@@ -812,8 +812,12 @@ class CalledOnceChecker : public 
ConstStmtVisitor {
   }
 }
 
-// Early exit if we don't have parameters for extra analysis.
-if (NotCalledOnEveryPath.none() && NotUsedOnEveryPath.none())
+// Early exit if we don't have parameters for extra analysis...
+if (NotCalledOnEveryPath.none() && NotUsedOnEveryPath.none() &&
+// ... or if we've seen variables with cleanup functions.
+// We can't reason that we've seen every path in this case,
+// and thus abandon reporting any warnings that imply that.
+!FunctionHasCleanupVars)
   return;
 
 // We are looking for a pair of blocks A, B so that the following is true:
@@ -1601,6 +1605,10 @@ class CalledOnceChecker : public 
ConstStmtVisitor {
 if (Var->getInit()) {
   checkEscapee(Var->getInit());
 }
+
+if (Var->hasAttr()) {
+  FunctionHasCleanupVars = true;
+}
   }
 }
   }
@@ -1669,6 +1677,13 @@ class CalledOnceChecker : public 
ConstStmtVisitor {
   // around.
   bool SuppressOnConventionalErrorPaths = false;
 
+  // The user can annotate variable declarations with cleanup functions, which
+  // essentially imposes a custom destructor logic on that variable.
+  // It is possible to use it, however, to call tracked parameters on all exits
+  // from the function.  For this reason, we track the fact that the function
+  // actually has these.
+  bool FunctionHasCleanupVars = false;
+
   State CurrentState;
   ParamSizedVector TrackedParams;
   CFGSizedVector States;

diff  --git a/clang/test/SemaObjC/warn-called-once.m 
b/clang/test/SemaObjC/warn-called-once.m
index 825d491f53bb..ff2778d4bd0a 100644
--- a/clang/test/SemaObjC/warn-called-once.m
+++ b/clang/test/SemaObjC/warn-called-once.m
@@ -1193,4 +1193,46 @@ - (void)test_escape_after_branch:(int)cond
   escape(handler);
 }
 
+// rdar://74441906
+typedef void (^DeferredBlock)(void);
+static inline void DefferedCallback(DeferredBlock *inBlock) { (*inBlock)(); }
+#define _DEFERCONCAT(a, b) a##b
+#define _DEFERNAME(a) _DEFERCONCAT(__DeferredVar_, a)
+#define DEFER __extension__ __attribute__((cleanup(DefferedCallback), unused)) 
\
+  DeferredBlock _DEFERNAME(__COUNTER__) = ^
+
+- (void)test_cleanup_1:(int)cond
+withCompletion:(void (^)(void))handler {
+  int error = 0;
+  DEFER {
+if (error)
+  handler();
+  };
+
+  if (cond) {
+error = 1;
+  } else {
+// no-warning
+handler();
+  }
+}
+
+- (void)test_cleanup_2:(int)cond
+withCompletion:(void (^)(void))handler {
+  int error = 0;
+  DEFER {
+if (error)
+  handler();
+  };
+
+  if (cond) {
+error = 1;
+  } else {
+handler(); // expected-note{{previous call is here}}
+  }
+
+  // We still can warn about double call even in this case.
+  handler(); // expected-warning{{completion handler is called twice}}
+}
+
 @end



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


[PATCH] D98694: [-Wcalled-once-parameter] Fix false positives for cleanup attr

2021-03-18 Thread Valeriy Savchenko via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG4a7afc9a8843: [-Wcalled-once-parameter] Fix false positives 
for cleanup attr (authored by vsavchenko).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98694

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


Index: clang/test/SemaObjC/warn-called-once.m
===
--- clang/test/SemaObjC/warn-called-once.m
+++ clang/test/SemaObjC/warn-called-once.m
@@ -1193,4 +1193,46 @@
   escape(handler);
 }
 
+// rdar://74441906
+typedef void (^DeferredBlock)(void);
+static inline void DefferedCallback(DeferredBlock *inBlock) { (*inBlock)(); }
+#define _DEFERCONCAT(a, b) a##b
+#define _DEFERNAME(a) _DEFERCONCAT(__DeferredVar_, a)
+#define DEFER __extension__ __attribute__((cleanup(DefferedCallback), unused)) 
\
+  DeferredBlock _DEFERNAME(__COUNTER__) = ^
+
+- (void)test_cleanup_1:(int)cond
+withCompletion:(void (^)(void))handler {
+  int error = 0;
+  DEFER {
+if (error)
+  handler();
+  };
+
+  if (cond) {
+error = 1;
+  } else {
+// no-warning
+handler();
+  }
+}
+
+- (void)test_cleanup_2:(int)cond
+withCompletion:(void (^)(void))handler {
+  int error = 0;
+  DEFER {
+if (error)
+  handler();
+  };
+
+  if (cond) {
+error = 1;
+  } else {
+handler(); // expected-note{{previous call is here}}
+  }
+
+  // We still can warn about double call even in this case.
+  handler(); // expected-warning{{completion handler is called twice}}
+}
+
 @end
Index: clang/lib/Analysis/CalledOnceCheck.cpp
===
--- clang/lib/Analysis/CalledOnceCheck.cpp
+++ clang/lib/Analysis/CalledOnceCheck.cpp
@@ -812,8 +812,12 @@
   }
 }
 
-// Early exit if we don't have parameters for extra analysis.
-if (NotCalledOnEveryPath.none() && NotUsedOnEveryPath.none())
+// Early exit if we don't have parameters for extra analysis...
+if (NotCalledOnEveryPath.none() && NotUsedOnEveryPath.none() &&
+// ... or if we've seen variables with cleanup functions.
+// We can't reason that we've seen every path in this case,
+// and thus abandon reporting any warnings that imply that.
+!FunctionHasCleanupVars)
   return;
 
 // We are looking for a pair of blocks A, B so that the following is true:
@@ -1601,6 +1605,10 @@
 if (Var->getInit()) {
   checkEscapee(Var->getInit());
 }
+
+if (Var->hasAttr()) {
+  FunctionHasCleanupVars = true;
+}
   }
 }
   }
@@ -1669,6 +1677,13 @@
   // around.
   bool SuppressOnConventionalErrorPaths = false;
 
+  // The user can annotate variable declarations with cleanup functions, which
+  // essentially imposes a custom destructor logic on that variable.
+  // It is possible to use it, however, to call tracked parameters on all exits
+  // from the function.  For this reason, we track the fact that the function
+  // actually has these.
+  bool FunctionHasCleanupVars = false;
+
   State CurrentState;
   ParamSizedVector TrackedParams;
   CFGSizedVector States;


Index: clang/test/SemaObjC/warn-called-once.m
===
--- clang/test/SemaObjC/warn-called-once.m
+++ clang/test/SemaObjC/warn-called-once.m
@@ -1193,4 +1193,46 @@
   escape(handler);
 }
 
+// rdar://74441906
+typedef void (^DeferredBlock)(void);
+static inline void DefferedCallback(DeferredBlock *inBlock) { (*inBlock)(); }
+#define _DEFERCONCAT(a, b) a##b
+#define _DEFERNAME(a) _DEFERCONCAT(__DeferredVar_, a)
+#define DEFER __extension__ __attribute__((cleanup(DefferedCallback), unused)) \
+  DeferredBlock _DEFERNAME(__COUNTER__) = ^
+
+- (void)test_cleanup_1:(int)cond
+withCompletion:(void (^)(void))handler {
+  int error = 0;
+  DEFER {
+if (error)
+  handler();
+  };
+
+  if (cond) {
+error = 1;
+  } else {
+// no-warning
+handler();
+  }
+}
+
+- (void)test_cleanup_2:(int)cond
+withCompletion:(void (^)(void))handler {
+  int error = 0;
+  DEFER {
+if (error)
+  handler();
+  };
+
+  if (cond) {
+error = 1;
+  } else {
+handler(); // expected-note{{previous call is here}}
+  }
+
+  // We still can warn about double call even in this case.
+  handler(); // expected-warning{{completion handler is called twice}}
+}
+
 @end
Index: clang/lib/Analysis/CalledOnceCheck.cpp
===
--- clang/lib/Analysis/CalledOnceCheck.cpp
+++ clang/lib/Analysis/CalledOnceCheck.cpp
@@ -812,8 +812,12 @@
   }
 }
 
-// Early exit if we don't have parameters for extra analysis.
-if (NotCalledOnEveryPath.none() && NotUsedOnEveryPath.none())
+// Early exit if we don't have parameters fo

[PATCH] D20689: [clang-tidy] Add 'readability-suspicious-call-argument' check

2021-03-18 Thread Whisperity via Phabricator via cfe-commits
whisperity marked 8 inline comments as done.
whisperity added inline comments.



Comment at: 
clang-tools-extra/clang-tidy/readability/SuspiciousCallArgumentCheck.cpp:51
+{true, 40, 50}, // Substring.
+{true, 50, 66}, // Levenshtein.
+{true, 75, 85}, // Jaro-Winkler.

aaron.ballman wrote:
> We should probably document where all these numbers come from, but `66` 
> definitely jumps out at me as being a bit strange. :-D
Unfortunately, I have absolutely no idea. All these values are percentages 
between 0 and 100 (`-1` is just saying that //"This heuristic doesn't accept 
percentages"//), and this is written in the documentation now. However, the 
answer to //"**why** 66%?"//, unless @varjujan can say something, I think is 
lost to history...

I'll read over his thesis once again, maybe I can find anything with regards to 
this.

Either way, I've detailed from both the code and the thesis how the percentages 
are meant. In some cases, the % is calculated as //"% of the longer string's 
length"//. In the Leventhstein's case, it's actually inverted:

```
Dist = (1 - Dist / LongerLength) * 100;
```

So what this says is that if the current arg1-param1 arg2-param2 pairing has 
less than the inverse of 50% (which is more than 50%) of the longer string's 
edit distance, but the arg2-param1 and arg1-param2 (the suggested swapped 
order) has more than the inverse of 66% (which is less than 33%), then the swap 
will be suggested.

Originally these values were called `LowerBound` and `UpperBound`, 
respectively, which was saying **even less** about what they mean...



Comment at: 
clang-tools-extra/clang-tidy/readability/SuspiciousCallArgumentCheck.cpp:271-272
+
+// Checks whether ArgType is an array type identical to ParamType`s array type.
+// Enforces array elements` qualifier compatibility as well.
+static bool isCompatibleWithArrayReference(const QualType &ArgType,

aaron.ballman wrote:
> 
Good catch! I believe this is what happens when you write LaTeX and code at the 
same time? I didn't notice this when I was tidying up the code...



Comment at: 
clang-tools-extra/clang-tidy/readability/SuspiciousCallArgumentCheck.cpp:347
+// Checks whether ArgType converts implicitly to ParamType.
+static bool areTypesCompatible(QualType ArgType, QualType ParamType,
+   const ASTContext &Ctx) {

aaron.ballman wrote:
> It seems like we're doing an awful lot of the same work as 
> `ASTContext::typesAreCompatible()` and type compatibility rules are pretty 
> complex, so I worry about this implementation being different than the 
> `ASTContext` implementation. Have you explored whether we can reuse more of 
> the logic from `ASTContext` here, or are they doing fundamentally different 
> kinds of type compatibility checks?
No, I didn't know that function even existed. This check must be older than 
that function.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D20689

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


[PATCH] D98848: [RISCV][Clang] Add RVV Vector Indexed Load intrinsic functions.

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

Support Complex type transformer to define more complexity legal type.

Overall our downstream implementation there are only four instructions need to
use complex type transformer, it's not a common case.
I still feel using a string for prototypes is simple and clear.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D98848

Files:
  clang/include/clang/Basic/riscv_vector.td
  clang/test/CodeGen/RISCV/rvv-intrinsics/vloxei.c
  clang/test/CodeGen/RISCV/rvv-intrinsics/vluxei.c
  clang/utils/TableGen/RISCVVEmitter.cpp

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


[PATCH] D20689: [clang-tidy] Add 'readability-suspicious-call-argument' check

2021-03-18 Thread Varju Janos via Phabricator via cfe-commits
varjujan added inline comments.



Comment at: 
clang-tools-extra/clang-tidy/readability/SuspiciousCallArgumentCheck.cpp:51
+{true, 40, 50}, // Substring.
+{true, 50, 66}, // Levenshtein.
+{true, 75, 85}, // Jaro-Winkler.

whisperity wrote:
> aaron.ballman wrote:
> > We should probably document where all these numbers come from, but `66` 
> > definitely jumps out at me as being a bit strange. :-D
> Unfortunately, I have absolutely no idea. All these values are percentages 
> between 0 and 100 (`-1` is just saying that //"This heuristic doesn't accept 
> percentages"//), and this is written in the documentation now. However, the 
> answer to //"**why** 66%?"//, unless @varjujan can say something, I think is 
> lost to history...
> 
> I'll read over his thesis once again, maybe I can find anything with regards 
> to this.
> 
> Either way, I've detailed from both the code and the thesis how the 
> percentages are meant. In some cases, the % is calculated as //"% of the 
> longer string's length"//. In the Leventhstein's case, it's actually inverted:
> 
> ```
> Dist = (1 - Dist / LongerLength) * 100;
> ```
> 
> So what this says is that if the current arg1-param1 arg2-param2 pairing has 
> less than the inverse of 50% (which is more than 50%) of the longer string's 
> edit distance, but the arg2-param1 and arg1-param2 (the suggested swapped 
> order) has more than the inverse of 66% (which is less than 33%), then the 
> swap will be suggested.
> 
> Originally these values were called `LowerBound` and `UpperBound`, 
> respectively, which was saying **even less** about what they mean...
Sadly, I think there isn't any scientific reason behind these numbers. They 
just looked ok after a couple of test runs. (Maybe they make sense for shorter 
arg names, like the 66 for 3 char long names.)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D20689

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


[PATCH] D98493: [WoA][MSVC] Use default linker setting in MSVC-compatible driver

2021-03-18 Thread Shaurya Gupta via Phabricator via cfe-commits
SureYeaah added a comment.

What if CLANG_DEFAULT_LINKER=ld?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98493

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


[PATCH] D98493: [WoA][MSVC] Use default linker setting in MSVC-compatible driver

2021-03-18 Thread Maxim Kuvyrkov via Phabricator via cfe-commits
maxim-kuvyrkov added a comment.

This patch broke clang-ppc64le-rhel builder.  The patch makes MSVC-compatible 
driver honour CLANG_DEFAULT_LINKER setting, which this builder sets to “lld”.  
Therefore there’s an expected change in the output now that 
CLANG_DEFAULT_LINKER can override link.exe.

This is the only builder, which sets -DCLANG_DEFAULT_LINKER to something other 
than the default. I’m looking how to fix this.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98493

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


[PATCH] D98493: [WoA][MSVC] Use default linker setting in MSVC-compatible driver

2021-03-18 Thread Maxim Kuvyrkov via Phabricator via cfe-commits
maxim-kuvyrkov added a comment.

In D98493#2634089 , @SureYeaah wrote:

> What if CLANG_DEFAULT_LINKER=ld?

@SureYeaah , then *-msvc targets will attempt to use "ld" linker as instructed. 
 Or are you asking about something else?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98493

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


[PATCH] D98493: [WoA][MSVC] Use default linker setting in MSVC-compatible driver

2021-03-18 Thread Shaurya Gupta via Phabricator via cfe-commits
SureYeaah added a comment.

We are seeing some internal breakage in google because CLANG_DEFAULT_LINKER is 
set to ld. It would be nice to make the tests more tolerant.

Can we revert this patch until then?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98493

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


[PATCH] D98852: [test] Fix variable definition in acle_sve_ld1.sh

2021-03-18 Thread Thomas Preud'homme via Phabricator via cfe-commits
thopre created this revision.
thopre added reviewers: andwar, david-arm, sdesmalen, SjoerdMeijer, kmclaughlin.
Herald added a subscriber: tschuett.
thopre requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Clang test acle_sve_ld1.sh is missing the colon in one of the string
variable definition separating the variable name from the regex. This
leads the substitution block to be parsed as a numeric variable use.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D98852

Files:
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_ld1sh.c


Index: clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_ld1sh.c
===
--- clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_ld1sh.c
+++ clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_ld1sh.c
@@ -114,7 +114,7 @@
 
 svint64_t test_svld1sh_gather_u64base_s64(svbool_t pg, svuint64_t bases) {
   // CHECK-LABEL: test_svld1sh_gather_u64base_s64
-  // CHECK: %[[PG.*]] = call  
@llvm.aarch64.sve.convert.from.svbool.nxv2i1( %pg)
+  // CHECK: %[[PG:.*]] = call  
@llvm.aarch64.sve.convert.from.svbool.nxv2i1( %pg)
   // CHECK: %[[LOAD:.*]] = call  
@llvm.aarch64.sve.ld1.gather.scalar.offset.nxv2i16.nxv2i64( 
%[[PG]],  %bases, i64 0)
   // CHECK: %[[SEXT:.*]] = sext  %[[LOAD]] to 
   // CHECK: ret  %[[SEXT]]


Index: clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_ld1sh.c
===
--- clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_ld1sh.c
+++ clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_ld1sh.c
@@ -114,7 +114,7 @@
 
 svint64_t test_svld1sh_gather_u64base_s64(svbool_t pg, svuint64_t bases) {
   // CHECK-LABEL: test_svld1sh_gather_u64base_s64
-  // CHECK: %[[PG.*]] = call  @llvm.aarch64.sve.convert.from.svbool.nxv2i1( %pg)
+  // CHECK: %[[PG:.*]] = call  @llvm.aarch64.sve.convert.from.svbool.nxv2i1( %pg)
   // CHECK: %[[LOAD:.*]] = call  @llvm.aarch64.sve.ld1.gather.scalar.offset.nxv2i16.nxv2i64( %[[PG]],  %bases, i64 0)
   // CHECK: %[[SEXT:.*]] = sext  %[[LOAD]] to 
   // CHECK: ret  %[[SEXT]]
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D98493: [WoA][MSVC] Use default linker setting in MSVC-compatible driver

2021-03-18 Thread Maxim Kuvyrkov via Phabricator via cfe-commits
maxim-kuvyrkov added a comment.

In D98493#2634107 , @SureYeaah wrote:

> We are seeing some internal breakage in google because CLANG_DEFAULT_LINKER 
> is set to ld. It would be nice to make the tests more tolerant.
>
> Can we revert this patch until then?

I'm testing a patch to the testsuite to fix the tests.  I'll revert the patch 
if can't get it fixes in a few hours.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98493

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


[PATCH] D98852: [test] Fix variable definition in acle_sve_ld1.sh

2021-03-18 Thread Sander de Smalen via Phabricator via cfe-commits
sdesmalen accepted this revision.
sdesmalen added a comment.
This revision is now accepted and ready to land.

LGTM, thanks for fixing!

I'm curious, how did you find this case? :)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98852

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


[clang] d8b8f54 - [Reland] "Do not apply calling conventions to MSVC entry points"

2021-03-18 Thread Elizabeth Andrews via cfe-commits

Author: Elizabeth Andrews
Date: 2021-03-18T04:26:47-07:00
New Revision: d8b8f544d9de30cd14584094596090d3f9992345

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

LOG: [Reland] "Do not apply calling conventions to MSVC entry points"

This patch is a second attempt at fixing a link error for MSVC
entry points when calling conventions are specified using a flag.

Calling conventions specified using flags should not be applied to MSVC
entry points. The default calling convention is set in this case. The
default calling convention for MSVC entry points main and wmain is cdecl.
For WinMain, wWinMain and DllMain, the default calling convention is
stdcall on 32 bit Windows.

Explicitly specified calling conventions are applied to MSVC entry points.

For MinGW, the default calling convention for all MSVC entry points is
cdecl.

First attempt: 4cff1b40dacf6
Revert of first attempt: bebfc3b92d5e8

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

Added: 


Modified: 
clang/lib/Sema/SemaDecl.cpp
clang/test/CodeGenCXX/default_calling_conv.cpp

Removed: 




diff  --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp
index b962bd965223..76e3ee965777 100644
--- a/clang/lib/Sema/SemaDecl.cpp
+++ b/clang/lib/Sema/SemaDecl.cpp
@@ -11173,6 +11173,25 @@ void Sema::CheckMain(FunctionDecl* FD, const DeclSpec& 
DS) {
   }
 }
 
+static bool isDefaultStdCall(FunctionDecl *FD, Sema &S) {
+
+  // Default calling convention for main and wmain is __cdecl
+  if (FD->getName() == "main" || FD->getName() == "wmain")
+return false;
+
+  // Default calling convention for MinGW is __cdecl
+  const llvm::Triple &T = S.Context.getTargetInfo().getTriple();
+  if (T.isWindowsGNUEnvironment())
+return false;
+
+  // Default calling convention for WinMain, wWinMain and DllMain
+  // is __stdcall on 32 bit Windows
+  if (T.isOSWindows() && T.getArch() == llvm::Triple::x86)
+return true;
+
+  return false;
+}
+
 void Sema::CheckMSVCRTEntryPoint(FunctionDecl *FD) {
   QualType T = FD->getType();
   assert(T->isFunctionType() && "function decl is not of function type");
@@ -11187,6 +11206,21 @@ void Sema::CheckMSVCRTEntryPoint(FunctionDecl *FD) {
 if (FD->getName() != "DllMain")
   FD->setHasImplicitReturnZero(true);
 
+  // Explicity specified calling conventions are applied to MSVC entry points
+  if (!hasExplicitCallingConv(T)) {
+if (isDefaultStdCall(FD, *this)) {
+  if (FT->getCallConv() != CC_X86StdCall) {
+FT = Context.adjustFunctionType(
+FT, FT->getExtInfo().withCallingConv(CC_X86StdCall));
+FD->setType(QualType(FT, 0));
+  }
+} else if (FT->getCallConv() != CC_C) {
+  FT = Context.adjustFunctionType(FT,
+  FT->getExtInfo().withCallingConv(CC_C));
+  FD->setType(QualType(FT, 0));
+}
+  }
+
   if (!FD->isInvalidDecl() && FD->getDescribedFunctionTemplate()) {
 Diag(FD->getLocation(), diag::err_mainlike_template_decl) << FD;
 FD->setInvalidDecl();

diff  --git a/clang/test/CodeGenCXX/default_calling_conv.cpp 
b/clang/test/CodeGenCXX/default_calling_conv.cpp
index e3d7ac429a60..83d1200e0ab1 100644
--- a/clang/test/CodeGenCXX/default_calling_conv.cpp
+++ b/clang/test/CodeGenCXX/default_calling_conv.cpp
@@ -4,6 +4,9 @@
 // RUN: %clang_cc1 -triple i486-unknown-linux-gnu -mrtd -emit-llvm -o - %s | 
FileCheck %s --check-prefix=STDCALL --check-prefix=ALL
 // RUN: %clang_cc1 -triple i986-unknown-linux-gnu 
-fdefault-calling-conv=vectorcall -emit-llvm -o - %s | FileCheck %s 
--check-prefix=VECTORCALL --check-prefix=ALL
 // RUN: %clang_cc1 -triple i986-unknown-linux-gnu 
-fdefault-calling-conv=regcall -emit-llvm -o - %s | FileCheck %s 
--check-prefix=REGCALL --check-prefix=ALL
+// RUN: %clang_cc1 -triple i686-pc-win32 -fdefault-calling-conv=vectorcall 
-emit-llvm -o - %s -DWINDOWS | FileCheck %s --check-prefix=WIN32
+// RUN: %clang_cc1 -triple x86_64-windows-msvc 
-fdefault-calling-conv=vectorcall -emit-llvm -o - %s -DWINDOWS | FileCheck %s 
--check-prefix=WIN64
+// RUN: %clang_cc1 -triple i686-pc-win32 -emit-llvm -o - %s -DEXPLICITCC | 
FileCheck %s --check-prefix=EXPLICITCC
 
 // CDECL: define{{.*}} void @_Z5test1v
 // FASTCALL: define{{.*}} x86_fastcallcc void @_Z5test1v
@@ -50,3 +53,45 @@ void test() {
 int main() {
   return 1;
 }
+
+#ifdef WINDOWS
+// WIN32: define dso_local i32 @wmain
+// WIN64: define dso_local i32 @wmain
+int wmain() {
+  return 1;
+}
+// WIN32: define dso_local x86_stdcallcc i32 @WinMain
+// WIN64: define dso_local i32 @WinMain
+int WinMain() {
+  return 1;
+}
+// WIN32: define dso_local x86_stdcallcc i32 @wWinMain
+// WIN64: define dso_local i32 @wWinMain
+int wWinMain() {
+  return 1;
+}
+// WIN32: define dso_local x86_stdcallcc i32 @DllMain
+// WIN64: defi

[PATCH] D97941: [Reland] "Do not apply calling conventions to MSVC entry points"

2021-03-18 Thread Elizabeth Andrews via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
eandrews marked an inline comment as done.
Closed by commit rGd8b8f544d9de: [Reland] "Do not apply calling 
conventions to MSVC entry points" (authored by eandrews).
Herald added a project: clang.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97941

Files:
  clang/lib/Sema/SemaDecl.cpp
  clang/test/CodeGenCXX/default_calling_conv.cpp

Index: clang/test/CodeGenCXX/default_calling_conv.cpp
===
--- clang/test/CodeGenCXX/default_calling_conv.cpp
+++ clang/test/CodeGenCXX/default_calling_conv.cpp
@@ -4,6 +4,9 @@
 // RUN: %clang_cc1 -triple i486-unknown-linux-gnu -mrtd -emit-llvm -o - %s | FileCheck %s --check-prefix=STDCALL --check-prefix=ALL
 // RUN: %clang_cc1 -triple i986-unknown-linux-gnu -fdefault-calling-conv=vectorcall -emit-llvm -o - %s | FileCheck %s --check-prefix=VECTORCALL --check-prefix=ALL
 // RUN: %clang_cc1 -triple i986-unknown-linux-gnu -fdefault-calling-conv=regcall -emit-llvm -o - %s | FileCheck %s --check-prefix=REGCALL --check-prefix=ALL
+// RUN: %clang_cc1 -triple i686-pc-win32 -fdefault-calling-conv=vectorcall -emit-llvm -o - %s -DWINDOWS | FileCheck %s --check-prefix=WIN32
+// RUN: %clang_cc1 -triple x86_64-windows-msvc -fdefault-calling-conv=vectorcall -emit-llvm -o - %s -DWINDOWS | FileCheck %s --check-prefix=WIN64
+// RUN: %clang_cc1 -triple i686-pc-win32 -emit-llvm -o - %s -DEXPLICITCC | FileCheck %s --check-prefix=EXPLICITCC
 
 // CDECL: define{{.*}} void @_Z5test1v
 // FASTCALL: define{{.*}} x86_fastcallcc void @_Z5test1v
@@ -50,3 +53,45 @@
 int main() {
   return 1;
 }
+
+#ifdef WINDOWS
+// WIN32: define dso_local i32 @wmain
+// WIN64: define dso_local i32 @wmain
+int wmain() {
+  return 1;
+}
+// WIN32: define dso_local x86_stdcallcc i32 @WinMain
+// WIN64: define dso_local i32 @WinMain
+int WinMain() {
+  return 1;
+}
+// WIN32: define dso_local x86_stdcallcc i32 @wWinMain
+// WIN64: define dso_local i32 @wWinMain
+int wWinMain() {
+  return 1;
+}
+// WIN32: define dso_local x86_stdcallcc i32 @DllMain
+// WIN64: define dso_local i32 @DllMain
+int DllMain() {
+  return 1;
+}
+#endif // Windows
+
+#ifdef EXPLICITCC
+// EXPLICITCC: define dso_local x86_fastcallcc i32 @wmain
+int __fastcall wmain() {
+  return 1;
+}
+// EXPLICITCC: define dso_local x86_fastcallcc i32 @WinMain
+int __fastcall WinMain() {
+  return 1;
+}
+// EXPLICITCC: define dso_local x86_fastcallcc i32 @wWinMain
+int __fastcall wWinMain() {
+  return 1;
+}
+// EXPLICITCC: define dso_local x86_fastcallcc i32 @DllMain
+int __fastcall DllMain() {
+  return 1;
+}
+#endif // ExplicitCC
Index: clang/lib/Sema/SemaDecl.cpp
===
--- clang/lib/Sema/SemaDecl.cpp
+++ clang/lib/Sema/SemaDecl.cpp
@@ -11173,6 +11173,25 @@
   }
 }
 
+static bool isDefaultStdCall(FunctionDecl *FD, Sema &S) {
+
+  // Default calling convention for main and wmain is __cdecl
+  if (FD->getName() == "main" || FD->getName() == "wmain")
+return false;
+
+  // Default calling convention for MinGW is __cdecl
+  const llvm::Triple &T = S.Context.getTargetInfo().getTriple();
+  if (T.isWindowsGNUEnvironment())
+return false;
+
+  // Default calling convention for WinMain, wWinMain and DllMain
+  // is __stdcall on 32 bit Windows
+  if (T.isOSWindows() && T.getArch() == llvm::Triple::x86)
+return true;
+
+  return false;
+}
+
 void Sema::CheckMSVCRTEntryPoint(FunctionDecl *FD) {
   QualType T = FD->getType();
   assert(T->isFunctionType() && "function decl is not of function type");
@@ -11187,6 +11206,21 @@
 if (FD->getName() != "DllMain")
   FD->setHasImplicitReturnZero(true);
 
+  // Explicity specified calling conventions are applied to MSVC entry points
+  if (!hasExplicitCallingConv(T)) {
+if (isDefaultStdCall(FD, *this)) {
+  if (FT->getCallConv() != CC_X86StdCall) {
+FT = Context.adjustFunctionType(
+FT, FT->getExtInfo().withCallingConv(CC_X86StdCall));
+FD->setType(QualType(FT, 0));
+  }
+} else if (FT->getCallConv() != CC_C) {
+  FT = Context.adjustFunctionType(FT,
+  FT->getExtInfo().withCallingConv(CC_C));
+  FD->setType(QualType(FT, 0));
+}
+  }
+
   if (!FD->isInvalidDecl() && FD->getDescribedFunctionTemplate()) {
 Diag(FD->getLocation(), diag::err_mainlike_template_decl) << FD;
 FD->setInvalidDecl();
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 8b8b9af - [-Wcalled-once-parameter][NFC] Fix GCC compilation error

2021-03-18 Thread Valeriy Savchenko via cfe-commits

Author: Valeriy Savchenko
Date: 2021-03-18T14:49:24+03:00
New Revision: 8b8b9af8c9132acb446fc42569de8a0f57c6b556

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

LOG: [-Wcalled-once-parameter][NFC] Fix GCC compilation error

Added: 


Modified: 
clang/lib/Analysis/CalledOnceCheck.cpp

Removed: 




diff  --git a/clang/lib/Analysis/CalledOnceCheck.cpp 
b/clang/lib/Analysis/CalledOnceCheck.cpp
index ab56d3e3c988..00bb51a1c0d3 100644
--- a/clang/lib/Analysis/CalledOnceCheck.cpp
+++ b/clang/lib/Analysis/CalledOnceCheck.cpp
@@ -63,14 +63,14 @@ struct KnownCalledOnceParameter {
   unsigned ParamIndex;
 };
 constexpr KnownCalledOnceParameter KNOWN_CALLED_ONCE_PARAMETERS[] = {
-{"dispatch_async", 1},
-{"dispatch_async_and_wait", 1},
-{"dispatch_after", 2},
-{"dispatch_sync", 1},
-{"dispatch_once", 1},
-{"dispatch_barrier_async", 1},
-{"dispatch_barrier_async_and_wait", 1},
-{"dispatch_barrier_sync", 1}};
+{llvm::StringLiteral{"dispatch_async"}, 1},
+{llvm::StringLiteral{"dispatch_async_and_wait"}, 1},
+{llvm::StringLiteral{"dispatch_after"}, 2},
+{llvm::StringLiteral{"dispatch_sync"}, 1},
+{llvm::StringLiteral{"dispatch_once"}, 1},
+{llvm::StringLiteral{"dispatch_barrier_async"}, 1},
+{llvm::StringLiteral{"dispatch_barrier_async_and_wait"}, 1},
+{llvm::StringLiteral{"dispatch_barrier_sync"}, 1}};
 
 class ParameterStatus {
 public:



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


[PATCH] D98855: [OpenCL] Support template parameters for as_type

2021-03-18 Thread Sven van Haastregt via Phabricator via cfe-commits
svenvh created this revision.
svenvh added a reviewer: Anastasia.
svenvh added a project: clang.
Herald added a subscriber: yaxunl.
svenvh requested review of this revision.
Herald added a subscriber: cfe-commits.

Implement the TreeTransform for AsTypeExpr.  Split `BuildAsTypeExpr`
out of `ActOnAsTypeExpr`, such that we can call the Build method from
the TreeTransform.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D98855

Files:
  clang/include/clang/Sema/Sema.h
  clang/lib/Sema/SemaExpr.cpp
  clang/lib/Sema/TreeTransform.h
  clang/test/SemaOpenCLCXX/template-astype.cl


Index: clang/test/SemaOpenCLCXX/template-astype.cl
===
--- /dev/null
+++ clang/test/SemaOpenCLCXX/template-astype.cl
@@ -0,0 +1,14 @@
+// RUN: %clang_cc1 -fdeclare-opencl-builtins -finclude-default-header %s 
-cl-std=clc++ -verify
+
+template 
+auto templated_astype(T x) {
+  return as_int2(x);
+  // expected-error@-1{{invalid reinterpretation: sizes of 'int2' (vector of 2 
'int' values) and '__private int' must match}}
+}
+
+auto test_long(long x) { return templated_astype(x); }
+
+auto neg_test_int(int x) { return templated_astype(x); }
+// expected-note@-1{{in instantiation of function template specialization 
'templated_astype' requested here}}
+
+auto test_short4(short4 x) { return templated_astype(x); }
Index: clang/lib/Sema/TreeTransform.h
===
--- clang/lib/Sema/TreeTransform.h
+++ clang/lib/Sema/TreeTransform.h
@@ -13952,7 +13952,14 @@
 template
 ExprResult
 TreeTransform::TransformAsTypeExpr(AsTypeExpr *E) {
-  llvm_unreachable("Cannot transform asType expressions yet");
+  ExprResult SrcExpr = getDerived().TransformExpr(E->getSrcExpr());
+  if (SrcExpr.isInvalid())
+return ExprError();
+
+  QualType Type = getDerived().TransformType(E->getType());
+
+  return SemaRef.BuildAsTypeExpr(SrcExpr.get(), Type, E->getBuiltinLoc(),
+ E->getRParenLoc());
 }
 
 template
Index: clang/lib/Sema/SemaExpr.cpp
===
--- clang/lib/Sema/SemaExpr.cpp
+++ clang/lib/Sema/SemaExpr.cpp
@@ -6497,24 +6497,30 @@
ExecConfig, IsExecConfig);
 }
 
-/// ActOnAsTypeExpr - create a new asType (bitcast) from the arguments.
+/// Parse a __builtin_astype expression.
 ///
 /// __builtin_astype( value, dst type )
 ///
 ExprResult Sema::ActOnAsTypeExpr(Expr *E, ParsedType ParsedDestTy,
  SourceLocation BuiltinLoc,
  SourceLocation RParenLoc) {
+  QualType DstTy = GetTypeFromParser(ParsedDestTy);
+  return BuildAsTypeExpr(E, DstTy, BuiltinLoc, RParenLoc);
+}
+
+/// Create a new AsTypeExpr node (bitcast) from the arguments.
+ExprResult Sema::BuildAsTypeExpr(Expr *E, QualType DestTy,
+ SourceLocation BuiltinLoc,
+ SourceLocation RParenLoc) {
   ExprValueKind VK = VK_RValue;
   ExprObjectKind OK = OK_Ordinary;
-  QualType DstTy = GetTypeFromParser(ParsedDestTy);
   QualType SrcTy = E->getType();
-  if (Context.getTypeSize(DstTy) != Context.getTypeSize(SrcTy))
-return ExprError(Diag(BuiltinLoc,
-  diag::err_invalid_astype_of_different_size)
- << DstTy
- << SrcTy
- << E->getSourceRange());
-  return new (Context) AsTypeExpr(E, DstTy, VK, OK, BuiltinLoc, RParenLoc);
+  if (!SrcTy->isDependentType() &&
+  Context.getTypeSize(DestTy) != Context.getTypeSize(SrcTy))
+return ExprError(
+Diag(BuiltinLoc, diag::err_invalid_astype_of_different_size)
+<< DestTy << SrcTy << E->getSourceRange());
+  return new (Context) AsTypeExpr(E, DestTy, VK, OK, BuiltinLoc, RParenLoc);
 }
 
 /// ActOnConvertVectorExpr - create a new convert-vector expression from the
Index: clang/include/clang/Sema/Sema.h
===
--- clang/include/clang/Sema/Sema.h
+++ clang/include/clang/Sema/Sema.h
@@ -5574,6 +5574,9 @@
   ExprResult ActOnAsTypeExpr(Expr *E, ParsedType ParsedDestTy,
  SourceLocation BuiltinLoc,
  SourceLocation RParenLoc);
+  ExprResult BuildAsTypeExpr(Expr *E, QualType DestTy,
+ SourceLocation BuiltinLoc,
+ SourceLocation RParenLoc);
 
   //=== C++ Features 
--===//
 


Index: clang/test/SemaOpenCLCXX/template-astype.cl
===
--- /dev/null
+++ clang/test/SemaOpenCLCXX/template-astype.cl
@@ -0,0 +1,14 @@
+// RUN: %clang_cc1 -fdeclare-opencl-builtins -finclude-default-header %s -cl-std=clc++ -verify
+
+template 
+auto templated_astype(T x) {
+  return as_int2(x);
+  // expected-error@-1{{invalid reinterpretat

[clang] c1fb23c - [clang][ASTImporter] Fix import of VarDecl regarding thread local storage spec

2021-03-18 Thread Balazs Benics via cfe-commits

Author: Balazs Benics
Date: 2021-03-18T13:06:38+01:00
New Revision: c1fb23c1aadd22e736c4a1c36c146bbfbc48f959

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

LOG: [clang][ASTImporter] Fix import of VarDecl regarding thread local storage 
spec

After the import, we did not copy the `TSCSpec`.
This commit resolves that.

Reviewed By: balazske

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

Added: 


Modified: 
clang/lib/AST/ASTImporter.cpp
clang/unittests/AST/ASTImporterTest.cpp

Removed: 




diff  --git a/clang/lib/AST/ASTImporter.cpp b/clang/lib/AST/ASTImporter.cpp
index f4dfc54b36cb..d48e173eb3b3 100644
--- a/clang/lib/AST/ASTImporter.cpp
+++ b/clang/lib/AST/ASTImporter.cpp
@@ -4018,6 +4018,7 @@ ExpectedDecl ASTNodeImporter::VisitVarDecl(VarDecl *D) {
   D->getStorageClass()))
 return ToVar;
 
+  ToVar->setTSCSpec(D->getTSCSpec());
   ToVar->setQualifierInfo(ToQualifierLoc);
   ToVar->setAccess(D->getAccess());
   ToVar->setLexicalDeclContext(LexicalDC);

diff  --git a/clang/unittests/AST/ASTImporterTest.cpp 
b/clang/unittests/AST/ASTImporterTest.cpp
index 39612d43799b..43464cc0c9ca 100644
--- a/clang/unittests/AST/ASTImporterTest.cpp
+++ b/clang/unittests/AST/ASTImporterTest.cpp
@@ -735,6 +735,12 @@ TEST_P(ImportDecl, ImportRecordDeclInFunc) {
  has(declStmt(hasSingleDecl(varDecl(hasName("d");
 }
 
+TEST_P(ImportDecl, ImportedVarDeclPreservesThreadLocalStorage) {
+  MatchVerifier Verifier;
+  testImport("thread_local int declToImport;", Lang_CXX11, "", Lang_CXX11,
+ Verifier, varDecl(hasThreadStorageDuration()));
+}
+
 TEST_P(ASTImporterOptionSpecificTestBase, ImportRecordTypeInFunc) {
   Decl *FromTU = getTuDecl("int declToImport() { "
"  struct data_t {int a;int b;};"



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


[PATCH] D98707: [clang][ASTImporter] Fix import of VarDecl regarding thread local storage spec

2021-03-18 Thread Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGc1fb23c1aadd: [clang][ASTImporter] Fix import of VarDecl 
regarding thread local storage spec (authored by Balazs Benics 
).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98707

Files:
  clang/lib/AST/ASTImporter.cpp
  clang/unittests/AST/ASTImporterTest.cpp


Index: clang/unittests/AST/ASTImporterTest.cpp
===
--- clang/unittests/AST/ASTImporterTest.cpp
+++ clang/unittests/AST/ASTImporterTest.cpp
@@ -735,6 +735,12 @@
  has(declStmt(hasSingleDecl(varDecl(hasName("d");
 }
 
+TEST_P(ImportDecl, ImportedVarDeclPreservesThreadLocalStorage) {
+  MatchVerifier Verifier;
+  testImport("thread_local int declToImport;", Lang_CXX11, "", Lang_CXX11,
+ Verifier, varDecl(hasThreadStorageDuration()));
+}
+
 TEST_P(ASTImporterOptionSpecificTestBase, ImportRecordTypeInFunc) {
   Decl *FromTU = getTuDecl("int declToImport() { "
"  struct data_t {int a;int b;};"
Index: clang/lib/AST/ASTImporter.cpp
===
--- clang/lib/AST/ASTImporter.cpp
+++ clang/lib/AST/ASTImporter.cpp
@@ -4018,6 +4018,7 @@
   D->getStorageClass()))
 return ToVar;
 
+  ToVar->setTSCSpec(D->getTSCSpec());
   ToVar->setQualifierInfo(ToQualifierLoc);
   ToVar->setAccess(D->getAccess());
   ToVar->setLexicalDeclContext(LexicalDC);


Index: clang/unittests/AST/ASTImporterTest.cpp
===
--- clang/unittests/AST/ASTImporterTest.cpp
+++ clang/unittests/AST/ASTImporterTest.cpp
@@ -735,6 +735,12 @@
  has(declStmt(hasSingleDecl(varDecl(hasName("d");
 }
 
+TEST_P(ImportDecl, ImportedVarDeclPreservesThreadLocalStorage) {
+  MatchVerifier Verifier;
+  testImport("thread_local int declToImport;", Lang_CXX11, "", Lang_CXX11,
+ Verifier, varDecl(hasThreadStorageDuration()));
+}
+
 TEST_P(ASTImporterOptionSpecificTestBase, ImportRecordTypeInFunc) {
   Decl *FromTU = getTuDecl("int declToImport() { "
"  struct data_t {int a;int b;};"
Index: clang/lib/AST/ASTImporter.cpp
===
--- clang/lib/AST/ASTImporter.cpp
+++ clang/lib/AST/ASTImporter.cpp
@@ -4018,6 +4018,7 @@
   D->getStorageClass()))
 return ToVar;
 
+  ToVar->setTSCSpec(D->getTSCSpec());
   ToVar->setQualifierInfo(ToQualifierLoc);
   ToVar->setAccess(D->getAccess());
   ToVar->setLexicalDeclContext(LexicalDC);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D98856: Always emit error for wrong interfaces to scalable vectors, unless cmdline flag is passed.

2021-03-18 Thread Sander de Smalen via Phabricator via cfe-commits
sdesmalen created this revision.
Herald added subscribers: dexonsmith, hiraditya, kristof.beyls, mgorny.
sdesmalen requested review of this revision.
Herald added projects: clang, LLVM.
Herald added subscribers: llvm-commits, cfe-commits.

In order to bring up scalable vector support in LLVM incrementally,
we introduced behaviour to emit a warning, instead of an error, when
asking the wrong question of a scalable vector, like asking for the
fixed number of elements.

This patch puts that behaviour under a flag. The default behaviour is
that the compiler will always error, which means that all LLVM unit
tests and regression tests will now fail when a code-path is taken that
still uses the wrong interface.

The behaviour to demote an error to a warning can be individually enabled
for tools that want to support experimental use of scalable vectors.
This patch enables that behaviour when driving compilation from Clang.
This means that for users who want to try out scalable-vector support,
fixed-width codegen support, or build user-code with scalable vector
intrinsics, Clang will not crash and burn when the compiler encounters
such a case.

This allows us to do away with the following pattern in many of the SVE tests:

  RUN:  2>%t
  RUN: cat %t | FileCheck --check-prefix=WARN
  WARN-NOT: warning: ...

The behaviour to emit warnings is only temporary and we expect this flag
to be removed in the future when scalable vector support is more stable.

This patch also has fixes the following tests:
unittests:

  ScalableVectorMVTsTest.SizeQueries
  SelectionDAGAddressAnalysisTest.unknownSizeFrameObjects
  AArch64SelectionDAGTest.computeKnownBitsSVE_ZERO_EXTEND_VECTOR_INREG

regression tests:

  Transforms/InstCombine/vscale_gep.ll


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D98856

Files:
  clang/lib/Driver/ToolChains/Clang.cpp
  llvm/include/llvm/CodeGen/ValueTypes.h
  llvm/include/llvm/Support/TypeSize.h
  llvm/lib/Analysis/InstructionSimplify.cpp
  llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
  llvm/lib/CodeGen/ValueTypes.cpp
  llvm/lib/Support/CMakeLists.txt
  llvm/lib/Support/TypeSize.cpp
  llvm/unittests/CodeGen/ScalableVectorMVTsTest.cpp
  llvm/unittests/CodeGen/SelectionDAGAddressAnalysisTest.cpp

Index: llvm/unittests/CodeGen/SelectionDAGAddressAnalysisTest.cpp
===
--- llvm/unittests/CodeGen/SelectionDAGAddressAnalysisTest.cpp
+++ llvm/unittests/CodeGen/SelectionDAGAddressAnalysisTest.cpp
@@ -169,10 +169,10 @@
   TypeSize Offset1 = SubVecVT.getStoreSize();
   SDValue Index0 = DAG->getMemBasePlusOffset(FIPtr, Offset0, Loc);
   SDValue Index1 = DAG->getMemBasePlusOffset(FIPtr, Offset1, Loc);
-  SDValue Store0 = DAG->getStore(DAG->getEntryNode(), Loc, Value, Index0,
- PtrInfo.getWithOffset(Offset0));
+  SDValue Store0 =
+  DAG->getStore(DAG->getEntryNode(), Loc, Value, Index0, PtrInfo);
   SDValue Store1 = DAG->getStore(DAG->getEntryNode(), Loc, Value, Index1,
- PtrInfo.getWithOffset(Offset1));
+ MachinePointerInfo(PtrInfo.getAddrSpace()));
   Optional NumBytes0 = MemoryLocation::getSizeOrUnknown(
   cast(Store0)->getMemoryVT().getStoreSize());
   Optional NumBytes1 = MemoryLocation::getSizeOrUnknown(
Index: llvm/unittests/CodeGen/ScalableVectorMVTsTest.cpp
===
--- llvm/unittests/CodeGen/ScalableVectorMVTsTest.cpp
+++ llvm/unittests/CodeGen/ScalableVectorMVTsTest.cpp
@@ -180,7 +180,8 @@
   // Check convenience size scaling methods.
   EXPECT_EQ(v2i32.getSizeInBits() * 2, v4i32.getSizeInBits());
   EXPECT_EQ(2 * nxv2i32.getSizeInBits(), nxv4i32.getSizeInBits());
-  EXPECT_EQ(nxv2f64.getSizeInBits() / 2, nxv2i32.getSizeInBits());
+  EXPECT_EQ(nxv2f64.getSizeInBits().divideCoefficientBy(2),
+nxv2i32.getSizeInBits());
 }
 
 } // end anonymous namespace
Index: llvm/lib/Support/TypeSize.cpp
===
--- /dev/null
+++ llvm/lib/Support/TypeSize.cpp
@@ -0,0 +1,39 @@
+//===- TypeSize.cpp - Wrapper around type sizes--*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "llvm/Support/TypeSize.h"
+#include "llvm/Support/CommandLine.h"
+
+using namespace llvm;
+
+cl::opt llvm::TypeSizeClOpt::ScalableErrorAsWarning(
+"treat-scalable-fixed-error-as-warning", cl::Hidden, cl::init(false),
+cl::desc("Treat issues where a fixed-width property is requested from a "
+ "scalable type as a warning, instead of an error."),
+cl::ZeroOrMore);
+
+TypeSize::operator TypeSize::ScalarTy() const {
+  auto Error = [

[PATCH] D98852: [test] Fix variable definition in acle_sve_ld1.sh

2021-03-18 Thread Thomas Preud'homme via Phabricator via cfe-commits
thopre added a comment.

In D98852#2634189 , @sdesmalen wrote:

> LGTM, thanks for fixing!
>
> I'm curious, how did you find this case? :)

The issue was caught by a patch of mine to FileCheck: 
https://reviews.llvm.org/D98691


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98852

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


[clang] e5cd5b3 - [test] Fix variable definition in acle_sve_ld1.sh

2021-03-18 Thread Thomas Preud'homme via cfe-commits

Author: Thomas Preud'homme
Date: 2021-03-18T12:15:45Z
New Revision: e5cd5b352ff481f02e1f4555033edf87112dcc0c

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

LOG: [test] Fix variable definition in acle_sve_ld1.sh

Clang test acle_sve_ld1.sh is missing the colon in one of the string
variable definition separating the variable name from the regex. This
leads the substitution block to be parsed as a numeric variable use.

Reviewed By: sdesmalen

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

Added: 


Modified: 
clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_ld1sh.c

Removed: 




diff  --git a/clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_ld1sh.c 
b/clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_ld1sh.c
index 6475b19ab653..6e3b32e1cc19 100644
--- a/clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_ld1sh.c
+++ b/clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_ld1sh.c
@@ -114,7 +114,7 @@ svint32_t test_svld1sh_gather_u32base_s32(svbool_t pg, 
svuint32_t bases) {
 
 svint64_t test_svld1sh_gather_u64base_s64(svbool_t pg, svuint64_t bases) {
   // CHECK-LABEL: test_svld1sh_gather_u64base_s64
-  // CHECK: %[[PG.*]] = call  
@llvm.aarch64.sve.convert.from.svbool.nxv2i1( %pg)
+  // CHECK: %[[PG:.*]] = call  
@llvm.aarch64.sve.convert.from.svbool.nxv2i1( %pg)
   // CHECK: %[[LOAD:.*]] = call  
@llvm.aarch64.sve.ld1.gather.scalar.offset.nxv2i16.nxv2i64( 
%[[PG]],  %bases, i64 0)
   // CHECK: %[[SEXT:.*]] = sext  %[[LOAD]] to 
   // CHECK: ret  %[[SEXT]]



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


[PATCH] D98852: [test] Fix variable definition in acle_sve_ld1.sh

2021-03-18 Thread Thomas Preud'homme via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGe5cd5b352ff4: [test] Fix variable definition in 
acle_sve_ld1.sh (authored by thopre).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98852

Files:
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_ld1sh.c


Index: clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_ld1sh.c
===
--- clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_ld1sh.c
+++ clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_ld1sh.c
@@ -114,7 +114,7 @@
 
 svint64_t test_svld1sh_gather_u64base_s64(svbool_t pg, svuint64_t bases) {
   // CHECK-LABEL: test_svld1sh_gather_u64base_s64
-  // CHECK: %[[PG.*]] = call  
@llvm.aarch64.sve.convert.from.svbool.nxv2i1( %pg)
+  // CHECK: %[[PG:.*]] = call  
@llvm.aarch64.sve.convert.from.svbool.nxv2i1( %pg)
   // CHECK: %[[LOAD:.*]] = call  
@llvm.aarch64.sve.ld1.gather.scalar.offset.nxv2i16.nxv2i64( 
%[[PG]],  %bases, i64 0)
   // CHECK: %[[SEXT:.*]] = sext  %[[LOAD]] to 
   // CHECK: ret  %[[SEXT]]


Index: clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_ld1sh.c
===
--- clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_ld1sh.c
+++ clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_ld1sh.c
@@ -114,7 +114,7 @@
 
 svint64_t test_svld1sh_gather_u64base_s64(svbool_t pg, svuint64_t bases) {
   // CHECK-LABEL: test_svld1sh_gather_u64base_s64
-  // CHECK: %[[PG.*]] = call  @llvm.aarch64.sve.convert.from.svbool.nxv2i1( %pg)
+  // CHECK: %[[PG:.*]] = call  @llvm.aarch64.sve.convert.from.svbool.nxv2i1( %pg)
   // CHECK: %[[LOAD:.*]] = call  @llvm.aarch64.sve.ld1.gather.scalar.offset.nxv2i16.nxv2i64( %[[PG]],  %bases, i64 0)
   // CHECK: %[[SEXT:.*]] = sext  %[[LOAD]] to 
   // CHECK: ret  %[[SEXT]]
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] c5c4a88 - [OpenCL] Remove spurious atomic_fetch tablegen builtins

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

Author: Sven van Haastregt
Date: 2021-03-18T12:17:12Z
New Revision: c5c4a88a840037fd38cb35d5efd524d51dcc091b

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

LOG: [OpenCL] Remove spurious atomic_fetch tablegen builtins

The `int` and `long` versions of these builtins already provide the
necessary overloads for `intptr_t` and `uintptr_t` arguments, as
`ASTContext` defines `atomic_(u)intptr_t` in terms of the `int` or
`long` types.

Prior to this patch, calls to those builtins with particular argument
types resulted in call-is-ambiguous errors.

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

Added: 


Modified: 
clang/lib/Sema/OpenCLBuiltins.td
clang/test/SemaOpenCL/fdeclare-opencl-builtins.cl

Removed: 




diff  --git a/clang/lib/Sema/OpenCLBuiltins.td 
b/clang/lib/Sema/OpenCLBuiltins.td
index d6d77dc90d30..1ff658e567b8 100644
--- a/clang/lib/Sema/OpenCLBuiltins.td
+++ b/clang/lib/Sema/OpenCLBuiltins.td
@@ -1100,7 +1100,6 @@ let MinVersion = CL20 in {
 
   foreach TypePair = [[AtomicInt, Int, Int], [AtomicUInt, UInt, UInt],
   [AtomicLong, Long, Long], [AtomicULong, ULong, ULong],
-  [AtomicIntPtr, IntPtr, PtrDiff],
   [AtomicUIntPtr, UIntPtr, PtrDiff]] in {
 foreach ModOp = ["add", "sub"] in {
   def : Builtin<"atomic_fetch_" # ModOp,
@@ -1112,9 +,7 @@ let MinVersion = CL20 in {
 }
   }
   foreach TypePair = [[AtomicInt, Int, Int], [AtomicUInt, UInt, UInt],
-  [AtomicLong, Long, Long], [AtomicULong, ULong, ULong],
-  [AtomicIntPtr, IntPtr, IntPtr],
-  [AtomicUIntPtr, UIntPtr, UIntPtr]] in {
+  [AtomicLong, Long, Long], [AtomicULong, ULong, ULong]] 
in {
 foreach ModOp = ["or", "xor", "and", "min", "max"] in {
   def : Builtin<"atomic_fetch_" # ModOp,
   [TypePair[1], PointerType, GenericAS>, 
TypePair[2]]>;

diff  --git a/clang/test/SemaOpenCL/fdeclare-opencl-builtins.cl 
b/clang/test/SemaOpenCL/fdeclare-opencl-builtins.cl
index 825dd3a935d0..103d1d8b262b 100644
--- a/clang/test/SemaOpenCL/fdeclare-opencl-builtins.cl
+++ b/clang/test/SemaOpenCL/fdeclare-opencl-builtins.cl
@@ -39,6 +39,9 @@ typedef unsigned int uint;
 typedef unsigned long ulong;
 typedef unsigned short ushort;
 typedef __SIZE_TYPE__ size_t;
+typedef __PTRDIFF_TYPE__ ptr
diff _t;
+typedef __INTPTR_TYPE__ intptr_t;
+typedef __UINTPTR_TYPE__ uintptr_t;
 typedef char char2 __attribute__((ext_vector_type(2)));
 typedef char char4 __attribute__((ext_vector_type(4)));
 typedef uchar uchar4 __attribute__((ext_vector_type(4)));
@@ -98,6 +101,24 @@ void test_typedef_args(clk_event_t evt, volatile 
atomic_flag *flg, global unsign
   size_t ws[2] = {2, 8};
   ndrange_t r = ndrange_2D(ws);
 }
+
+// Check that atomic_fetch_ functions can be called with (u)intptr_t arguments,
+// despite OpenCLBuiltins.td not providing explicit overloads for those types.
+void test_atomic_fetch(volatile __generic atomic_int *a_int,
+   volatile __generic atomic_intptr_t *a_intptr,
+   volatile __generic atomic_uintptr_t *a_uintptr) {
+  int i;
+  intptr_t ip;
+  uintptr_t uip;
+  ptr
diff _t ptr
diff ;
+
+  i = atomic_fetch_add(a_int, i);
+  ip = atomic_fetch_add(a_intptr, ptr
diff );
+  uip = atomic_fetch_add(a_uintptr, ptr
diff );
+
+  ip = atomic_fetch_or(a_intptr, ip);
+  uip = atomic_fetch_or(a_uintptr, uip);
+}
 #endif
 
 kernel void basic_conversion() {



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


[PATCH] D98520: [OpenCL] Remove spurious atomic_fetch tablegen builtins

2021-03-18 Thread Sven van Haastregt via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGc5c4a88a8400: [OpenCL] Remove spurious atomic_fetch tablegen 
builtins (authored by svenvh).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98520

Files:
  clang/lib/Sema/OpenCLBuiltins.td
  clang/test/SemaOpenCL/fdeclare-opencl-builtins.cl


Index: clang/test/SemaOpenCL/fdeclare-opencl-builtins.cl
===
--- clang/test/SemaOpenCL/fdeclare-opencl-builtins.cl
+++ clang/test/SemaOpenCL/fdeclare-opencl-builtins.cl
@@ -39,6 +39,9 @@
 typedef unsigned long ulong;
 typedef unsigned short ushort;
 typedef __SIZE_TYPE__ size_t;
+typedef __PTRDIFF_TYPE__ ptrdiff_t;
+typedef __INTPTR_TYPE__ intptr_t;
+typedef __UINTPTR_TYPE__ uintptr_t;
 typedef char char2 __attribute__((ext_vector_type(2)));
 typedef char char4 __attribute__((ext_vector_type(4)));
 typedef uchar uchar4 __attribute__((ext_vector_type(4)));
@@ -98,6 +101,24 @@
   size_t ws[2] = {2, 8};
   ndrange_t r = ndrange_2D(ws);
 }
+
+// Check that atomic_fetch_ functions can be called with (u)intptr_t arguments,
+// despite OpenCLBuiltins.td not providing explicit overloads for those types.
+void test_atomic_fetch(volatile __generic atomic_int *a_int,
+   volatile __generic atomic_intptr_t *a_intptr,
+   volatile __generic atomic_uintptr_t *a_uintptr) {
+  int i;
+  intptr_t ip;
+  uintptr_t uip;
+  ptrdiff_t ptrdiff;
+
+  i = atomic_fetch_add(a_int, i);
+  ip = atomic_fetch_add(a_intptr, ptrdiff);
+  uip = atomic_fetch_add(a_uintptr, ptrdiff);
+
+  ip = atomic_fetch_or(a_intptr, ip);
+  uip = atomic_fetch_or(a_uintptr, uip);
+}
 #endif
 
 kernel void basic_conversion() {
Index: clang/lib/Sema/OpenCLBuiltins.td
===
--- clang/lib/Sema/OpenCLBuiltins.td
+++ clang/lib/Sema/OpenCLBuiltins.td
@@ -1100,7 +1100,6 @@
 
   foreach TypePair = [[AtomicInt, Int, Int], [AtomicUInt, UInt, UInt],
   [AtomicLong, Long, Long], [AtomicULong, ULong, ULong],
-  [AtomicIntPtr, IntPtr, PtrDiff],
   [AtomicUIntPtr, UIntPtr, PtrDiff]] in {
 foreach ModOp = ["add", "sub"] in {
   def : Builtin<"atomic_fetch_" # ModOp,
@@ -1112,9 +,7 @@
 }
   }
   foreach TypePair = [[AtomicInt, Int, Int], [AtomicUInt, UInt, UInt],
-  [AtomicLong, Long, Long], [AtomicULong, ULong, ULong],
-  [AtomicIntPtr, IntPtr, IntPtr],
-  [AtomicUIntPtr, UIntPtr, UIntPtr]] in {
+  [AtomicLong, Long, Long], [AtomicULong, ULong, ULong]] 
in {
 foreach ModOp = ["or", "xor", "and", "min", "max"] in {
   def : Builtin<"atomic_fetch_" # ModOp,
   [TypePair[1], PointerType, GenericAS>, 
TypePair[2]]>;


Index: clang/test/SemaOpenCL/fdeclare-opencl-builtins.cl
===
--- clang/test/SemaOpenCL/fdeclare-opencl-builtins.cl
+++ clang/test/SemaOpenCL/fdeclare-opencl-builtins.cl
@@ -39,6 +39,9 @@
 typedef unsigned long ulong;
 typedef unsigned short ushort;
 typedef __SIZE_TYPE__ size_t;
+typedef __PTRDIFF_TYPE__ ptrdiff_t;
+typedef __INTPTR_TYPE__ intptr_t;
+typedef __UINTPTR_TYPE__ uintptr_t;
 typedef char char2 __attribute__((ext_vector_type(2)));
 typedef char char4 __attribute__((ext_vector_type(4)));
 typedef uchar uchar4 __attribute__((ext_vector_type(4)));
@@ -98,6 +101,24 @@
   size_t ws[2] = {2, 8};
   ndrange_t r = ndrange_2D(ws);
 }
+
+// Check that atomic_fetch_ functions can be called with (u)intptr_t arguments,
+// despite OpenCLBuiltins.td not providing explicit overloads for those types.
+void test_atomic_fetch(volatile __generic atomic_int *a_int,
+   volatile __generic atomic_intptr_t *a_intptr,
+   volatile __generic atomic_uintptr_t *a_uintptr) {
+  int i;
+  intptr_t ip;
+  uintptr_t uip;
+  ptrdiff_t ptrdiff;
+
+  i = atomic_fetch_add(a_int, i);
+  ip = atomic_fetch_add(a_intptr, ptrdiff);
+  uip = atomic_fetch_add(a_uintptr, ptrdiff);
+
+  ip = atomic_fetch_or(a_intptr, ip);
+  uip = atomic_fetch_or(a_uintptr, uip);
+}
 #endif
 
 kernel void basic_conversion() {
Index: clang/lib/Sema/OpenCLBuiltins.td
===
--- clang/lib/Sema/OpenCLBuiltins.td
+++ clang/lib/Sema/OpenCLBuiltins.td
@@ -1100,7 +1100,6 @@
 
   foreach TypePair = [[AtomicInt, Int, Int], [AtomicUInt, UInt, UInt],
   [AtomicLong, Long, Long], [AtomicULong, ULong, ULong],
-  [AtomicIntPtr, IntPtr, PtrDiff],
   [AtomicUIntPtr, UIntPtr, PtrDiff]] in {
 foreach ModOp = ["add", "sub"] in {
   def : Builtin<"atomic_fetch_" # ModOp,
@@ -1112,9 +,7 @@
 }
   }
   foreach TypePair = [[AtomicInt, Int, Int], [AtomicUI

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

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

Fixing bug in test case


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,37 @@
+! 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.
+
+! REQUIRES: new-flang-driver
+
+
+!--
+! 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,7 @@
+! 

[PATCH] D20689: [clang-tidy] Add 'readability-suspicious-call-argument' check

2021-03-18 Thread Whisperity via Phabricator via cfe-commits
whisperity updated this revision to Diff 331532.
whisperity marked 3 inline comments as done.
whisperity added a comment.

**NFC** Made the code more legible, updated and clarified some comments, fixed 
grammar issues.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D20689

Files:
  clang-tools-extra/clang-tidy/readability/CMakeLists.txt
  clang-tools-extra/clang-tidy/readability/ReadabilityTidyModule.cpp
  clang-tools-extra/clang-tidy/readability/SuspiciousCallArgumentCheck.cpp
  clang-tools-extra/clang-tidy/readability/SuspiciousCallArgumentCheck.h
  clang-tools-extra/docs/ReleaseNotes.rst
  clang-tools-extra/docs/clang-tidy/checks/list.rst
  
clang-tools-extra/docs/clang-tidy/checks/readability-suspicious-call-argument.rst
  
clang-tools-extra/test/clang-tidy/checkers/readability-suspicious-call-argument.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/readability-suspicious-call-argument.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/readability-suspicious-call-argument.cpp
@@ -0,0 +1,468 @@
+// RUN: %check_clang_tidy %s readability-suspicious-call-argument %t -- -- -std=c++11
+
+void foo_1(int aa, int bb) {}
+
+void foo_2(int source, int aa) {}
+
+void foo_3(int valToRet, int aa) {}
+
+void foo_4(int pointer, int aa) {}
+
+void foo_5(int aa, int bb, int cc, ...) {}
+
+void foo_6(const int dd, bool &ee) {}
+
+void foo_7(int aa, int bb, int cc, int ff = 7) {}
+
+// Test functions for convertible argument--parameter types.
+void fun(const int &m);
+void fun2() {
+  int m = 3;
+  fun(m);
+}
+
+// Test cases for parameters of const reference and value.
+void value_const_reference(int ll, const int &kk);
+
+void const_ref_value_swapped() {
+  const int &kk = 42;
+  const int &ll = 42;
+  value_const_reference(kk, ll);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: 1st argument 'kk' (passed to 'll') looks like it might be swapped with the 2nd, 'll' (passed to 'kk') [readability-suspicious-call-argument]
+  // CHECK-MESSAGES: :[[@LINE-7]]:6: note: in the call to 'value_const_reference', declared here
+}
+
+// Const, non const references.
+void const_nonconst_parameters(const int &mm, int &nn);
+
+void const_nonconst_swap1() {
+  const int &nn = 42;
+  int mm;
+  // Do not check, because non-const reference parameter cannot bind to const reference argument.
+  const_nonconst_parameters(nn, mm);
+}
+
+void const_nonconst_swap3() {
+  const int nn = 42;
+  int m = 42;
+  int &mm = m;
+  // Do not check, const int does not bind to non const reference.
+  const_nonconst_parameters(nn, mm);
+}
+
+void const_nonconst_swap2() {
+  int nn;
+  int mm;
+  // Check for swapped arguments. (Both arguments are non-const.)
+  const_nonconst_parameters(nn, mm);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: 1st argument 'nn' (passed to 'mm') looks like it might be swapped with the 2nd, 'mm' (passed to 'nn')
+}
+
+void const_nonconst_pointers(const int *mm, int *nn);
+void const_nonconst_pointers2(const int *mm, const int *nn);
+
+void const_nonconst_pointers_swapped() {
+  int *mm;
+  const int *nn;
+  const_nonconst_pointers(nn, mm);
+}
+
+void const_nonconst_pointers_swapped2() {
+  const int *mm;
+  int *nn;
+  const_nonconst_pointers2(nn, mm);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: 1st argument 'nn' (passed to 'mm') looks like it might be swapped with the 2nd, 'mm' (passed to 'nn')
+}
+
+// Test cases for pointers and arrays.
+void pointer_array_parameters(
+int *pp, int qq[4]);
+
+void pointer_array_swap() {
+  int qq[5];
+  int *pp;
+  // Check for swapped arguments. An array implicitly converts to a pointer.
+  pointer_array_parameters(qq, pp);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: 1st argument 'qq' (passed to 'pp') looks like it might be swapped with the 2nd, 'pp' (passed to 'qq')
+}
+
+// Test cases for multilevel pointers.
+void multilevel_pointer_parameters(int *const **pp,
+   const int *const *volatile const *qq);
+void multilevel_pointer_parameters2(
+char *nn, char *volatile *const *const *const *const &mm);
+
+typedef float T;
+typedef T *S;
+typedef S *const volatile R;
+typedef R *Q;
+typedef Q *P;
+typedef P *O;
+void multilevel_pointer_parameters3(float **const volatile ***rr, O &ss);
+
+void multilevel_pointer_swap() {
+  int *const **qq;
+  int *const **pp;
+  multilevel_pointer_parameters(qq, pp);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: 1st argument 'qq' (passed to 'pp') looks like it might be swapped with the 2nd, 'pp' (passed to 'qq')
+
+  

[PATCH] D20689: [clang-tidy] Add 'readability-suspicious-call-argument' check

2021-03-18 Thread Whisperity via Phabricator via cfe-commits
whisperity added inline comments.



Comment at: 
clang-tools-extra/clang-tidy/readability/SuspiciousCallArgumentCheck.cpp:31-32
+
+  char DissimilarBelow;
+  char SimilarAbove;
+

aaron.ballman wrote:
> `signed char` since we're doing `> -1` below? Or better yet, `int8_t` because 
> these aren't really characters?
Oh right, I always forget `char` isn't guaranteed. `int8_t` seems like a better 
idea anyways (until we have `int6_t`...)



Comment at: 
clang-tools-extra/clang-tidy/readability/SuspiciousCallArgumentCheck.cpp:51
+{true, 40, 50}, // Substring.
+{true, 50, 66}, // Levenshtein.
+{true, 75, 85}, // Jaro-Winkler.

varjujan wrote:
> whisperity wrote:
> > aaron.ballman wrote:
> > > We should probably document where all these numbers come from, but `66` 
> > > definitely jumps out at me as being a bit strange. :-D
> > Unfortunately, I have absolutely no idea. All these values are percentages 
> > between 0 and 100 (`-1` is just saying that //"This heuristic doesn't 
> > accept percentages"//), and this is written in the documentation now. 
> > However, the answer to //"**why** 66%?"//, unless @varjujan can say 
> > something, I think is lost to history...
> > 
> > I'll read over his thesis once again, maybe I can find anything with 
> > regards to this.
> > 
> > Either way, I've detailed from both the code and the thesis how the 
> > percentages are meant. In some cases, the % is calculated as //"% of the 
> > longer string's length"//. In the Leventhstein's case, it's actually 
> > inverted:
> > 
> > ```
> > Dist = (1 - Dist / LongerLength) * 100;
> > ```
> > 
> > So what this says is that if the current arg1-param1 arg2-param2 pairing 
> > has less than the inverse of 50% (which is more than 50%) of the longer 
> > string's edit distance, but the arg2-param1 and arg1-param2 (the suggested 
> > swapped order) has more than the inverse of 66% (which is less than 33%), 
> > then the swap will be suggested.
> > 
> > Originally these values were called `LowerBound` and `UpperBound`, 
> > respectively, which was saying **even less** about what they mean...
> Sadly, I think there isn't any scientific reason behind these numbers. They 
> just looked ok after a couple of test runs. (Maybe they make sense for 
> shorter arg names, like the 66 for 3 char long names.)
In [Rice2017], the inflexion point of the precision/recall plot is at around 
`0.55`-ish threshold. They express this threshold as the distance of distances, 
i.e. `0` would mean the (a1, p1) - (a2, p2) pair is good as it is, and `1` 
would mean that it should **definitely** be (a2, p1) - (a1, p2) instead. 



Comment at: 
clang-tools-extra/clang-tidy/readability/SuspiciousCallArgumentCheck.cpp:347
+// Checks whether ArgType converts implicitly to ParamType.
+static bool areTypesCompatible(QualType ArgType, QualType ParamType,
+   const ASTContext &Ctx) {

whisperity wrote:
> aaron.ballman wrote:
> > It seems like we're doing an awful lot of the same work as 
> > `ASTContext::typesAreCompatible()` and type compatibility rules are pretty 
> > complex, so I worry about this implementation being different than the 
> > `ASTContext` implementation. Have you explored whether we can reuse more of 
> > the logic from `ASTContext` here, or are they doing fundamentally different 
> > kinds of type compatibility checks?
> No, I didn't know that function even existed. This check must be older than 
> that function.
Actually, no, that function is pretty old... However, that function, and all 
the function it subsequently calls, require a **non-const** `ASTContext`. I 
have changed `ASTContext`:

```
╰─ git diff --cached --stat
 clang/include/clang/AST/ASTContext.h | 67 
---
 clang/lib/AST/ASTContext.cpp | 72 
+---
 2 files changed, 73 insertions(+), 66 deletions(-)
```

making related member functions and internal static functions take `const 
ASTContext &`/`*`.

This, by itself, did not break any of the tests of `check-clang 
check-clang-unit check-clang-tools check-clang-extra-unit`!



Comment at: 
clang-tools-extra/clang-tidy/readability/SuspiciousCallArgumentCheck.cpp:347-349
+static bool areTypesCompatible(QualType ArgType, QualType ParamType,
+   const ASTContext &Ctx) {
+  if (ArgType.isNull() || ParamType.isNull())

whisperity wrote:
> whisperity wrote:
> > aaron.ballman wrote:
> > > It seems like we're doing an awful lot of the same work as 
> > > `ASTContext::typesAreCompatible()` and type compatibility rules are 
> > > pretty complex, so I worry about this implementation being different than 
> > > the `ASTContext` implementation. Have

[PATCH] D20689: [clang-tidy] Add 'readability-suspicious-call-argument' check

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



Comment at: 
clang-tools-extra/clang-tidy/readability/SuspiciousCallArgumentCheck.cpp:51
+{true, 40, 50}, // Substring.
+{true, 50, 66}, // Levenshtein.
+{true, 75, 85}, // Jaro-Winkler.

varjujan wrote:
> whisperity wrote:
> > aaron.ballman wrote:
> > > We should probably document where all these numbers come from, but `66` 
> > > definitely jumps out at me as being a bit strange. :-D
> > Unfortunately, I have absolutely no idea. All these values are percentages 
> > between 0 and 100 (`-1` is just saying that //"This heuristic doesn't 
> > accept percentages"//), and this is written in the documentation now. 
> > However, the answer to //"**why** 66%?"//, unless @varjujan can say 
> > something, I think is lost to history...
> > 
> > I'll read over his thesis once again, maybe I can find anything with 
> > regards to this.
> > 
> > Either way, I've detailed from both the code and the thesis how the 
> > percentages are meant. In some cases, the % is calculated as //"% of the 
> > longer string's length"//. In the Leventhstein's case, it's actually 
> > inverted:
> > 
> > ```
> > Dist = (1 - Dist / LongerLength) * 100;
> > ```
> > 
> > So what this says is that if the current arg1-param1 arg2-param2 pairing 
> > has less than the inverse of 50% (which is more than 50%) of the longer 
> > string's edit distance, but the arg2-param1 and arg1-param2 (the suggested 
> > swapped order) has more than the inverse of 66% (which is less than 33%), 
> > then the swap will be suggested.
> > 
> > Originally these values were called `LowerBound` and `UpperBound`, 
> > respectively, which was saying **even less** about what they mean...
> Sadly, I think there isn't any scientific reason behind these numbers. They 
> just looked ok after a couple of test runs. (Maybe they make sense for 
> shorter arg names, like the 66 for 3 char long names.)
Thank you for the explanations! I'm fine with the values as they are (they're 
defaults that can be changed anyway).



Comment at: 
clang-tools-extra/clang-tidy/readability/SuspiciousCallArgumentCheck.cpp:164
+static bool applyLevenshteinHeuristic(StringRef Arg, StringRef Param,
+  std::size_t Threshold) {
+  std::size_t LongerLength = std::max(Arg.size(), Param.size());





Comment at: 
clang-tools-extra/clang-tidy/readability/SuspiciousCallArgumentCheck.cpp:347
+// Checks whether ArgType converts implicitly to ParamType.
+static bool areTypesCompatible(QualType ArgType, QualType ParamType,
+   const ASTContext &Ctx) {

whisperity wrote:
> whisperity wrote:
> > aaron.ballman wrote:
> > > It seems like we're doing an awful lot of the same work as 
> > > `ASTContext::typesAreCompatible()` and type compatibility rules are 
> > > pretty complex, so I worry about this implementation being different than 
> > > the `ASTContext` implementation. Have you explored whether we can reuse 
> > > more of the logic from `ASTContext` here, or are they doing fundamentally 
> > > different kinds of type compatibility checks?
> > No, I didn't know that function even existed. This check must be older than 
> > that function.
> Actually, no, that function is pretty old... However, that function, and all 
> the function it subsequently calls, require a **non-const** `ASTContext`. I 
> have changed `ASTContext`:
> 
> ```
> ╰─ git diff --cached --stat
>  clang/include/clang/AST/ASTContext.h | 
> 67 ---
>  clang/lib/AST/ASTContext.cpp | 
> 72 +---
>  2 files changed, 73 insertions(+), 66 deletions(-)
> ```
> 
> making related member functions and internal static functions take `const 
> ASTContext &`/`*`.
> 
> This, by itself, did not break any of the tests of `check-clang 
> check-clang-unit check-clang-tools check-clang-extra-unit`!
Doubtful -- `typesAreCompatible()` is critical for checking the semantics of 
assignment in C, overloading in C++, etc. It may have simply been overlooked 
when writing this check. Given the complexities of type checking, my intuition 
is that we should be leaning on `ASTContext` for as much of this functionality 
as we can get away with. That will also get us nice "extras" like caring about 
address spaces, ARC, etc which are what got me worried when I started looking 
at this implementation.



Comment at: 
clang-tools-extra/clang-tidy/readability/SuspiciousCallArgumentCheck.cpp:624
+  diag(MatchedCallExpr->getExprLoc(),
+   "%ordinal0 argument '%1' (passed to '%2') looks like it might be "
+   "swapped with the %ordinal3, '%4' (passed to '%5')")

TIL about `%ordinal` in diagnostics, thanks 

[PATCH] D20689: [clang-tidy] Add 'readability-suspicious-call-argument' check

2021-03-18 Thread Whisperity via Phabricator via cfe-commits
whisperity marked an inline comment as done.
whisperity added inline comments.



Comment at: 
clang-tools-extra/clang-tidy/readability/SuspiciousCallArgumentCheck.cpp:657-660
+} else {
+  ParamTypes.push_back(QualType());
+  ParamNames.push_back(StringRef());
+}

aaron.ballman wrote:
> Can this case happen?
Oops... It seems I posted the updated patch right where you were writing more 
comments and we got into a data race. Which case are you referring to? It's now 
affixed to a `diag(` call for me...



Comment at: 
clang-tools-extra/docs/clang-tidy/checks/readability-suspicious-call-argument.rst:61-68
+The *prefix* heuristic reports if one of the strings is a sufficiently long
+prefix of the other string, e.g. ``target`` to ``targetPtr``.
+The similarity percentage is the length ratio of the prefix to the longer
+string, in the previous example, it would be `6 / 9 = 66.66...`\%.
+
+This heuristic can be configured with :ref:`bounds`.
+The default bounds are: below `25`\% dissimilar and above `30`\% similar.

aaron.ballman wrote:
> I wonder how Hungarian notation impacts this heuristic -- I would imagine a 
> lot of similar prefixes in such a code base, and things like `lpstr` as a 
> prefix could be a pretty large chunk of some identifiers.
The switch is only warned if it would be type-safe. If the HN prefix is in both 
//the same way//, then it could be ignored. Thus, given `f(const char* lpszFoo, 
const char* lpszBar, uint16_t psnzXXX)  {}`, if I do a `f(lpszX, lpszA, ...);`, 
it should consider in both cases that the prefix is common and matches. Note 
that to produce a diagnostic, **two** things has to be proven: first, that the 
//current// ordering is dissimilar (below threshold A), and second, that the 
potential swapped ordering is more similar (above threshold B).



Comment at: 
clang-tools-extra/docs/clang-tidy/checks/readability-suspicious-call-argument.rst:75
+In the case of ``oldValue`` and ``value`` compared, the similarity percentage
+is `8 / 5 = 62.5`\%.
+

aaron.ballman wrote:
> Similar to above, I wonder how numeric digits impact this heuristic -- do the 
> defaults consider this to be a swap?
> ```
> void foo(int frobble1, int frobble2);
> foo(frobble2, frobble1); // Hopefully identified as a swap
> foo(bar2, bar1); // How about this?
> ```
Currently, neither of these are matched. I have to look into why the first 
isn't... it really should, based on the "equality" heuristic. It's too trivial.

The second... well... that's trickier. I would say it shouldn't match, because 
if it did, we would be swamped with false positives. The suffix is only 1 
character, and we need 25/30% based on the string's length.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D20689

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


[PATCH] D95460: [flang][driver] Add forced form flags and -ffixed-line-length

2021-03-18 Thread Andrzej Warzynski via Phabricator via cfe-commits
awarzynski added a comment.

Hi @protze.joachim,

Thank you for your feedback. I'm sorry that this is causing issues in your 
set-up.

In D95460#2632844 , @protze.joachim 
wrote:

> Before this patch, clang would happily ignore a `-ffree-form` flag.

It's a bit more nuanced than this. Originally, `-ffree-form` (and other similar 
flags) were added to be forwarded to `gfortran`. This forwarding was 
effectively switched off ~6 months before this patch, please see this commit 
. As such, 
these flags stopped being used/needed by Clang. This patch makes Flang 
"re-claim" them.

> With this patch, none of `-Wno-error=unknown-argument`, 
> `-Wno-unknown-argument` , `-Qunused-arguments` help to avoid clang from 
> exiting with
>
>   error: unknown argument: '-ffree-form'
>
> Why can't clang ignore these flags as any other unknown flags?

IIUC, this is not something specific to the options refactored in this patch. 
For example:

  # Test -foo
  clang-cl -c -Wno-unknown-argument -foo  file.c
  clang -c -Wno-unknown-argument -foo  file.c
  clang-13: error: unknown argument: '-foo'
  # Test -ffree-form
  clang-cl -c -Wno-unknown-argument -ffree-form  file.c
  clang -c -Wno-unknown-argument -ffree-form  file.c
  clang-13: error: unknown argument: '-ffree-form'

Basically, `-Wno-unknown-argument` is only honored in `clang-cl`. Also, it 
applies to any option rather then just the options modified here.
I'm not particularly familiar with the semantics of the diagnostics options 
that you listed (`-Wno-error=unknown-argument`, `-Wno-unknown-argument` , 
`-Qunused-arguments`), but I get the impression that in general `clang` does 
not ignore options that it does not know about. I couldn't find any example 
that would demonstrate otherwise.

> As a background: in the build system I'm dealing with, I cannot avoid that 
> fortran flags are passed to the linking command. As C++ and fortran is 
> involved, I prefer using clang++ as the linking command and explicitly link 
> the fortran runtime library (at the moment gfortran, but in the future 
> probably the flang runtime library)

It sounds like your build system relies on the `gfortran` support in Clang, but 
this support has been "bit rotting 
". I'm 
keen to help you resolve your problems, but finding a solution that will work 
for `clang`, `flang` and `gfortran` might require some effort. Would you be 
able to step-up as Clang's `gfortran`-mode maintainer? (no pressure, just 
brainstorming!)
Alternatively, do you need ToT `clang` for your build system?

Thank you,
-Andrzej


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95460

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


[PATCH] D95403: [clang-tidy][analyzer][WIP] Clang-tidy reverse integration into Static Analyzer.

2021-03-18 Thread Jan Svoboda via Phabricator via cfe-commits
jansvoboda11 removed a reviewer: jansvoboda11.
jansvoboda11 added inline comments.
Herald added a subscriber: jansvoboda11.



Comment at: clang/lib/Frontend/CompilerInvocation.cpp:640
+StringRef CheckList = A->getValue();
+Opts.TidyChecks.emplace_back(CheckList);
+  }

Can you please use the option marshalling infrastructure instead? 
https://clang.llvm.org/docs/InternalsManual.html#adding-new-command-line-option


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95403

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


[PATCH] D98862: [clang] Update unit-tests after linker selection fix for *-msvc targets

2021-03-18 Thread Maxim Kuvyrkov via Phabricator via cfe-commits
maxim-kuvyrkov created this revision.
maxim-kuvyrkov added a reviewer: asl.
maxim-kuvyrkov requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

After https://reviews.llvm.org/D98493 clang driver for *-msvc target
uses linker from CLANG_DEFAULT_LINKER instead of hard-coded "link.exe".
Update unit-tests that expect link.exe linker to explicitly select it
via -fuse-ld=link, so that buildbots and other builds that set
-DCLANG_DEFAULT_LINKER=foobar don't fail these tests.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D98862

Files:
  clang/test/Driver/Xlinker-args.c
  clang/test/Driver/cl-inputs.c
  clang/test/Driver/cl-link-at-file.c
  clang/test/Driver/cl-link.c
  clang/test/Driver/msvc-link.c
  clang/test/OpenMP/linking.c

Index: clang/test/OpenMP/linking.c
===
--- clang/test/OpenMP/linking.c
+++ clang/test/OpenMP/linking.c
@@ -81,7 +81,7 @@
 // CHECK-LD-OVERRIDE-64: "-lgomp" "-lrt"
 // CHECK-LD-OVERRIDE-64: "-lpthread" "-lc"
 //
-// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
+// RUN: %clang -no-canonical-prefixes -fuse-ld=link %s -### -o %t.o 2>&1 \
 // RUN: -fopenmp=libomp -target x86_64-msvc-win32 -rtlib=platform \
 // RUN:   | FileCheck --check-prefix=CHECK-MSVC-LINK-64 %s
 // CHECK-MSVC-LINK-64: link.exe
Index: clang/test/Driver/msvc-link.c
===
--- clang/test/Driver/msvc-link.c
+++ clang/test/Driver/msvc-link.c
@@ -1,4 +1,4 @@
-// RUN: %clang -target i686-pc-windows-msvc -### %s 2>&1 | FileCheck --check-prefix=BASIC %s
+// RUN: %clang -target i686-pc-windows-msvc -fuse-ld=link -### %s 2>&1 | FileCheck --check-prefix=BASIC %s
 // BASIC: link.exe"
 // BASIC: "-out:a.exe"
 // BASIC: "-defaultlib:libcmt"
@@ -19,13 +19,13 @@
 // LIBPATH: "-libpath:/usr/lib"
 // LIBPATH: "-nologo"
 
-// RUN: %clang_cl /Brepro -### -- %s 2>&1 | FileCheck --check-prefix=REPRO %s
+// RUN: %clang_cl /Brepro -fuse-ld=link -### -- %s 2>&1 | FileCheck --check-prefix=REPRO %s
 // REPRO: link.exe"
 // REPRO: "-out:msvc-link.exe"
 // REPRO: "-nologo"
 // REPRO: "-Brepro"
 
-// RUN: %clang_cl /Brepro- -### -- %s 2>&1 | FileCheck --check-prefix=NOREPRO %s
+// RUN: %clang_cl /Brepro- -fuse-ld=link -### -- %s 2>&1 | FileCheck --check-prefix=NOREPRO %s
 // NOREPRO: link.exe"
 // NOREPRO: "-out:msvc-link.exe"
 // NOREPRO: "-nologo"
Index: clang/test/Driver/cl-link.c
===
--- clang/test/Driver/cl-link.c
+++ clang/test/Driver/cl-link.c
@@ -2,14 +2,14 @@
 // be interpreted as a command-line option, e.g. on Mac where %s is commonly
 // under /Users.
 
-// RUN: %clang_cl /Tc%s -### /link foo bar baz 2>&1 | FileCheck --check-prefix=LINK %s
-// RUN: %clang_cl /Tc%s -### /linkfoo bar baz 2>&1 | FileCheck --check-prefix=LINK %s
+// RUN: %clang_cl /Tc%s -fuse-ld=link -### /link foo bar baz 2>&1 | FileCheck --check-prefix=LINK %s
+// RUN: %clang_cl /Tc%s -fuse-ld=link -### /linkfoo bar baz 2>&1 | FileCheck --check-prefix=LINK %s
 // LINK: link.exe
 // LINK: "foo"
 // LINK: "bar"
 // LINK: "baz"
 
-// RUN: %clang_cl -m32 -arch:IA32 --target=i386-pc-win32 /Tc%s -### -fsanitize=address 2>&1 | FileCheck --check-prefix=ASAN %s
+// RUN: %clang_cl -m32 -arch:IA32 --target=i386-pc-win32 /Tc%s -fuse-ld=link -### -fsanitize=address 2>&1 | FileCheck --check-prefix=ASAN %s
 // ASAN: link.exe
 // ASAN: "-debug"
 // ASAN: "-incremental:no"
@@ -19,7 +19,7 @@
 // ASAN: "-wholearchive:{{.*}}clang_rt.asan_cxx-i386.lib"
 // ASAN: "{{.*}}cl-link{{.*}}.obj"
 
-// RUN: %clang_cl -m32 -arch:IA32 --target=i386-pc-win32 /MD /Tc%s -### -fsanitize=address 2>&1 | FileCheck --check-prefix=ASAN-MD %s
+// RUN: %clang_cl -m32 -arch:IA32 --target=i386-pc-win32 /MD /Tc%s -fuse-ld=link -### -fsanitize=address 2>&1 | FileCheck --check-prefix=ASAN-MD %s
 // ASAN-MD: link.exe
 // ASAN-MD: "-debug"
 // ASAN-MD: "-incremental:no"
@@ -29,13 +29,13 @@
 // ASAN-MD: "-wholearchive:{{.*}}clang_rt.asan_dynamic_runtime_thunk-i386.lib"
 // ASAN-MD: "{{.*}}cl-link{{.*}}.obj"
 
-// RUN: %clang_cl /LD -### /Tc%s 2>&1 | FileCheck --check-prefix=DLL %s
-// RUN: %clang_cl /LDd -### /Tc%s 2>&1 | FileCheck --check-prefix=DLL %s
+// RUN: %clang_cl /LD -fuse-ld=link -### /Tc%s 2>&1 | FileCheck --check-prefix=DLL %s
+// RUN: %clang_cl /LDd -fuse-ld=link -### /Tc%s 2>&1 | FileCheck --check-prefix=DLL %s
 // DLL: link.exe
 // "-dll"
 
-// RUN: %clang_cl -m32 -arch:IA32 --target=i386-pc-win32 /LD /Tc%s -### -fsanitize=address 2>&1 | FileCheck --check-prefix=ASAN-DLL %s
-// RUN: %clang_cl -m32 -arch:IA32 --target=i386-pc-win32 /LDd /Tc%s -### -fsanitize=address 2>&1 | FileCheck --check-prefix=ASAN-DLL %s
+// RUN: %clang_cl -m32 -arch:IA32 --target=i386-pc-win32 /LD /Tc%s -fuse-ld=link -### -fsanitize=address 2>&1 | FileCheck --check-prefix=ASAN-DLL %s
+// RUN: %clang_cl -m32 -arch:IA32 --target=i386-pc-win32 /LDd /Tc%s -fuse-ld=link -#

[PATCH] D20689: [clang-tidy] Add 'readability-suspicious-call-argument' check

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



Comment at: 
clang-tools-extra/clang-tidy/readability/SuspiciousCallArgumentCheck.cpp:347-349
+static bool areTypesCompatible(QualType ArgType, QualType ParamType,
+   const ASTContext &Ctx) {
+  if (ArgType.isNull() || ParamType.isNull())

whisperity wrote:
> aaron.ballman wrote:
> > whisperity wrote:
> > > whisperity wrote:
> > > > aaron.ballman wrote:
> > > > > It seems like we're doing an awful lot of the same work as 
> > > > > `ASTContext::typesAreCompatible()` and type compatibility rules are 
> > > > > pretty complex, so I worry about this implementation being different 
> > > > > than the `ASTContext` implementation. Have you explored whether we 
> > > > > can reuse more of the logic from `ASTContext` here, or are they doing 
> > > > > fundamentally different kinds of type compatibility checks?
> > > > No, I didn't know that function even existed. This check must be older 
> > > > than that function.
> > > Actually, no, that function is pretty old... However, that function, and 
> > > all the function it subsequently calls, require a **non-const** 
> > > `ASTContext`. I have changed `ASTContext`:
> > > 
> > > ```
> > > ╰─ git diff --cached --stat
> > >  clang/include/clang/AST/ASTContext.h 
> > > | 67 ---
> > >  clang/lib/AST/ASTContext.cpp 
> > > | 72 
> > > +---
> > >  2 files changed, 73 insertions(+), 66 deletions(-)
> > > ```
> > > 
> > > making related member functions and internal static functions take `const 
> > > ASTContext &`/`*`.
> > > 
> > > This, by itself, did not break any of the tests of `check-clang 
> > > check-clang-unit check-clang-tools check-clang-extra-unit`!
> > Doubtful -- `typesAreCompatible()` is critical for checking the semantics 
> > of assignment in C, overloading in C++, etc. It may have simply been 
> > overlooked when writing this check. Given the complexities of type 
> > checking, my intuition is that we should be leaning on `ASTContext` for as 
> > much of this functionality as we can get away with. That will also get us 
> > nice "extras" like caring about address spaces, ARC, etc which are what got 
> > me worried when I started looking at this implementation.
> @aaron.ballman Changing the function to be 
> 
> ```
> return Ctx.typesAreCompatible(ArgType, ParamType);
> ```
> 
> will make the checker miss the test case about `T`/`const T&` mixup.
> 
> ```
> void value_const_reference(int ll, const int& kk);
> void const_ref_value_swapped() {
>   const int& kk = 42;
>   const int& ll = 42;
>   value_const_reference(kk, ll);
>   // error: CHECK-MESSAGES: expected string not found in input:
>   // warning: 1st argument 'kk' (passed to 'll') looks like it might 
> be swapped with the 2nd, 'll' (passed to 'kk')
> }
> ```
> 
> 
> 
> Setting `bool CompareUnqualified = true` (3rd argument to 
> `typesAreCompatible`) doesn't help either.
> Which is valid from `typesAreCompatible`'s perspective... that function 
> answer the question, applied to the context of the above test: //"Is `ll 
> = kk;` valid?"//, which is obviously **false** as both are `const T&`s.
Yeah, I expect there to be a delta between the work this check is doing and the 
existing work done by `typesAreCompatible()`. However, given the complexity of 
type compatibility checking, I'd say it's better for us to try to refactor the 
ASTContext functionality so that we can share as much of the implementation as 
plausible rather than duplicate some really difficult logic in the tidy check.



Comment at: 
clang-tools-extra/clang-tidy/readability/SuspiciousCallArgumentCheck.cpp:657-660
+} else {
+  ParamTypes.push_back(QualType());
+  ParamNames.push_back(StringRef());
+}

whisperity wrote:
> aaron.ballman wrote:
> > Can this case happen?
> Oops... It seems I posted the updated patch right where you were writing more 
> comments and we got into a data race. Which case are you referring to? It's 
> now affixed to a `diag(` call for me...
Hehe, it's "fun" when the comments move around like this, isn't it? :-D I meant 
the `else` clause in:
```
  for (std::size_t I = 0, E = CalleeFuncDecl->getNumParams(); I != E; ++I) {
if (const ParmVarDecl *Param = CalleeFuncDecl->getParamDecl(I)) {
  ParamTypes.push_back(Param->getType());

  if (IdentifierInfo *II = Param->getIdentifier()) {
ParamNames.push_back(II->getName());
  } else {
ParamNames.push_back(StringRef());
  }
} else { // This seems like it should be impossible, no?
  ParamTypes.push_back(QualType());
  ParamNames.push_back(StringRef());
}
  }
```



Comment at: 
clang-tools-extra/docs/c

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

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

In D97869#2628679 , @azabaznov wrote:

> I have one more though.
>
> I like the idea of turning `opencl-c.h` into the test: as it is already in 
> the repo and is already being used for quite a while we can assume it as a 
> mainline for now. I think the first step should be to test that 
> `-fdeclare-oprencl-builtins` generates the same built-ins which are declared 
> in `opencl-c.h`. If we can't do this //programmable way// we can use AST 
> pretty-printing for tablegen header and `opencl-c.h` and compare these with 
> //diff //(we can also do a clean-up of AST files with //rm// while running 
> that tests).
>
> Once this is done we can incrementally modify either `opencl-c.h` header and 
> tablegen header. Testing changes to either of them can combine sanity check 
> as @svenvh suggested in **builtins-opencl2.0.check** and diff for AST pretty 
> printing.
>
> Advantages:
>
> - Time of testing. Locally I get nice results: 
>
>   $ time ./build_release/bin/clang-check -extra-arg=-cl-std=CL2.0 --ast-print 
>  llvm-project/clang/lib/Headers/opencl-c.h &> header.h
>   real    0m0.182s
>   user    0m0.162s
>   sys     0m0.020s
>
>   But not yet clear how much time such printing will take for tablegen 
> header. I assume it won't take a lot longer.
>
> - This will keep changes to `opencl-h` header and tablegen header consistent 
> (until `opencl-c.h` will be deprecated)
>
>  
> Disadvantages:
>
> - Still doesn't eliminate subtle errors, need to carefully collect 
> information from the spec about amount of the built-ins

Thanks for elaborating on this option. Yes, I think this could make the testing 
quick. The biggest concern with this I see is that it doesn't actually show 
that the header is working through the clang frontend. For example, we could 
easily change something very significant like remove the definition of macros 
guarding the function declarations and not notice that it means the 
declarations are no longer available to the users of clang. So I would say 
while it covers all the builtin overloads it doesn't give the confidence that 
them at all are exposed correctly to the users. We could of course work around 
this by providing complimentary partial testing using clang invocation but it 
means our testing will become harder to understand.

Overall I think we have made a good progress on brainstorming here so I suggest 
to give the ideas broader visibility via RFC to cfe-dev. We could include the 
following:

- Start from standard clang testing idea i.e. adding a large test file(s) using 
clang invocation and calling the functions (either written manually or 
autogenerated).
- Summarize the issues with the standard approach and highlight that similar 
tests with other clang features (i.e. target intrinsics) show time bottlenecks.
- Enumerate various alternative options and hybrid options to avoid adding 
large test files with long execution time highlighting adv/disadv for each of 
them.

Does this sound reasonable? Is there anything else we should include in such 
RFC?


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

https://reviews.llvm.org/D97869

___
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-18 Thread Arnamoy B via Phabricator via cfe-commits
arnamoy10 added inline comments.



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

bryanpkc wrote:
> Can you use `llvm::sys::path::remove_filename` here?
Thank you.  This seems like a better option, but I could not make it work.  For 
the sake of time I am keeping this hard coded manipulation.  It can be improved 
in a later revision.


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] D20689: [clang-tidy] Add 'readability-suspicious-call-argument' check

2021-03-18 Thread Whisperity via Phabricator via cfe-commits
whisperity marked 12 inline comments as done.
whisperity added inline comments.



Comment at: 
clang-tools-extra/clang-tidy/readability/SuspiciousCallArgumentCheck.cpp:657-660
+} else {
+  ParamTypes.push_back(QualType());
+  ParamNames.push_back(StringRef());
+}

whisperity wrote:
> aaron.ballman wrote:
> > Can this case happen?
> Oops... It seems I posted the updated patch right where you were writing more 
> comments and we got into a data race. Which case are you referring to? It's 
> now affixed to a `diag(` call for me...
Oh, nevermind, there is a button that shows me the older diff where it's 
aligned properly.

And yeah, it seems it can't, `getParamDecl` always returns a `ParmVarDecl`. 
Weird issues might arise when the vectors that are built here get out of sync 
(such as the issue we had with `operator()` calls before I fixed it!), so I 
understood the reason behind keeping the two functions parallel with each other 
in terms of pure visuals, even.



Comment at: 
clang-tools-extra/clang-tidy/readability/SuspiciousCallArgumentCheck.cpp:743-744
+
+if (AreNamesSimilar)
+  break;
+

aaron.ballman wrote:
> Any reason not to move this below the `switch` and use `=` instead of `|=` 
> within the cases? (Or return from the cases directly?)
Returning from the cases directly is a bad idea because we want to try all 
heuristics and only say `false` if none of them matches.
But this break in a very bad location, I agree.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D20689

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


[PATCH] D98864: [SystemZ][z/OS] Set maximum value to truncate attribute aligned to for static variables on z/OS target

2021-03-18 Thread Fanbo Meng via Phabricator via cfe-commits
fanbo-meng created this revision.
fanbo-meng added reviewers: abhina.sreeskantharajan, muiez, Kai, anirudhp, 
DanielMcIntosh-IBM.
fanbo-meng requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

On z/OS there is a hard limitation on on the maximum requestable alignment in 
aligned attribute for static variables. We need to truncate values greater than 
that.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D98864

Files:
  clang/include/clang/Basic/TargetInfo.h
  clang/lib/AST/ASTContext.cpp
  clang/lib/Basic/TargetInfo.cpp
  clang/lib/Basic/Targets/OSTargets.h
  clang/test/CodeGen/SystemZ/zos-alignment.c


Index: clang/test/CodeGen/SystemZ/zos-alignment.c
===
--- clang/test/CodeGen/SystemZ/zos-alignment.c
+++ clang/test/CodeGen/SystemZ/zos-alignment.c
@@ -1,4 +1,16 @@
-// RUN: %clang_cc1 -emit-llvm-only -triple s390x-none-zos 
-fdump-record-layouts %s | FileCheck %s
+// RUN: %clang_cc1 -emit-llvm-only -triple s390x-none-zos 
-fdump-record-layouts %s | FileCheck %s --check-prefix=CHECK
+// RUN: %clang_cc1 -emit-llvm -triple s390x-none-zos %s -o - | FileCheck %s 
--check-prefix=DECL
+
+static int __attribute__((aligned(32))) v0;
+int __attribute__((aligned(32))) v1;
+typedef int __attribute__((aligned(32))) int32;
+static int32 v2;
+int32 v3;
+int f0() { return v0 + v1 + v2 + v3; }
+// DECL:  @v0 {{.*}} align 16
+// DECL-NEXT: @v1 {{.*}} align 32
+// DECL-NEXT: @v2 {{.*}} align 16
+// DECL-NEXT: @v3 {{.*}} align 32
 
 struct s0 {
   short a:3;
Index: clang/lib/Basic/Targets/OSTargets.h
===
--- clang/lib/Basic/Targets/OSTargets.h
+++ clang/lib/Basic/Targets/OSTargets.h
@@ -788,6 +788,7 @@
   ZOSTargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts)
   : OSTargetInfo(Triple, Opts) {
 this->WCharType = TargetInfo::UnsignedInt;
+this->MaxAlignedAttribute = 128;
 this->UseBitFieldTypeAlignment = false;
 this->UseZeroLengthBitfieldAlignment = true;
 this->ZeroLengthBitfieldBoundary = 32;
Index: clang/lib/Basic/TargetInfo.cpp
===
--- clang/lib/Basic/TargetInfo.cpp
+++ clang/lib/Basic/TargetInfo.cpp
@@ -106,6 +106,7 @@
   UseZeroLengthBitfieldAlignment = false;
   UseExplicitBitFieldAlignment = true;
   ZeroLengthBitfieldBoundary = 0;
+  MaxAlignedAttribute = 0;
   HalfFormat = &llvm::APFloat::IEEEhalf();
   FloatFormat = &llvm::APFloat::IEEEsingle();
   DoubleFormat = &llvm::APFloat::IEEEdouble();
Index: clang/lib/AST/ASTContext.cpp
===
--- clang/lib/AST/ASTContext.cpp
+++ clang/lib/AST/ASTContext.cpp
@@ -1783,6 +1783,13 @@
 }
   }
 
+  // Some targets have hard limitation on the maximum requestable alignment in
+  // aligned attribute for static variables.
+  const unsigned MaxAlignedAttr = getTargetInfo().getMaxAlignedAttribute();
+  const auto *VD = dyn_cast(D);
+  if (MaxAlignedAttr && VD && VD->getStorageClass() == SC_Static)
+Align = std::min(Align, MaxAlignedAttr);
+
   return toCharUnitsFromBits(Align);
 }
 
Index: clang/include/clang/Basic/TargetInfo.h
===
--- clang/include/clang/Basic/TargetInfo.h
+++ clang/include/clang/Basic/TargetInfo.h
@@ -161,6 +161,10 @@
   /// If non-zero, specifies a fixed alignment value for bitfields that follow
   /// zero length bitfield, regardless of the zero length bitfield type.
   unsigned ZeroLengthBitfieldBoundary;
+
+  /// If non-zero, specifies a maximum alignment to truncate alignment
+  /// specified in the aligned attribute of a static variable to this value.
+  unsigned MaxAlignedAttribute;
 };
 
 /// OpenCL type kinds.
@@ -774,6 +778,12 @@
 return ZeroLengthBitfieldBoundary;
   }
 
+  /// Get the maximum alignment in bits for a static variable with
+  /// aligned attribute.
+  unsigned getMaxAlignedAttribute() const {
+return MaxAlignedAttribute;
+  }
+
   /// Check whether explicit bitfield alignment attributes should be
   //  honored, as in "__attribute__((aligned(2))) int b : 1;".
   bool useExplicitBitFieldAlignment() const {


Index: clang/test/CodeGen/SystemZ/zos-alignment.c
===
--- clang/test/CodeGen/SystemZ/zos-alignment.c
+++ clang/test/CodeGen/SystemZ/zos-alignment.c
@@ -1,4 +1,16 @@
-// RUN: %clang_cc1 -emit-llvm-only -triple s390x-none-zos -fdump-record-layouts %s | FileCheck %s
+// RUN: %clang_cc1 -emit-llvm-only -triple s390x-none-zos -fdump-record-layouts %s | FileCheck %s --check-prefix=CHECK
+// RUN: %clang_cc1 -emit-llvm -triple s390x-none-zos %s -o - | FileCheck %s --check-prefix=DECL
+
+static int __attribute__((aligned(32))) v0;
+int __attribute__((aligned(32))) v1;
+typedef int __attribute__((aligned(32))) int32;
+static int32 v2;
+int32 v3

[PATCH] D98864: [SystemZ][z/OS] Set maximum value to truncate attribute aligned to for static variables on z/OS target

2021-03-18 Thread Fanbo Meng via Phabricator via cfe-commits
fanbo-meng updated this revision to Diff 331553.
fanbo-meng added a comment.
Herald added subscribers: sstefan1, phosek, s.egerton, jfb, mgrang, simoncook, 
fedor.sergeev, aheejin, krytarowski, dschuff.
Herald added a reviewer: jfb.
Herald added a reviewer: jdoerfert.

clang-formatted


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

https://reviews.llvm.org/D98864

Files:
  clang/include/clang/Basic/TargetInfo.h
  clang/lib/AST/ASTContext.cpp
  clang/lib/Basic/TargetInfo.cpp
  clang/lib/Basic/Targets/OSTargets.h
  clang/test/CodeGen/SystemZ/zos-alignment.c
  myPatch.diff

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


[clang] eefda60 - [flang][driver] Add support for `-fget-symbols-sources`

2021-03-18 Thread Andrzej Warzynski via cfe-commits

Author: Andrzej Warzynski
Date: 2021-03-18T14:13:24Z
New Revision: eefda605fe1701937a8fe5379357e0990ad2fb4e

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

LOG: [flang][driver] Add support for `-fget-symbols-sources`

Adds support for `-fget-symbols-sources` in the new Flang driver. All
relevant tests are updated to use the new driver when
`FLANG_BUILD_NEW_DRIVER` is set.

`RUN` lines in tests are updated so `-fsyntax-only`
comes before `-fget-symbols-sources`. That's because:
  * both `-fsyntax-only` and `-fget-symbols-sources` are
action flags, and
  * the new driver, flang-new, will only consider the right-most
action flag.
In other words, this change is needed so that the tests work with both
`f18` (requires both flags) and `flang-new` (only considers the last
action flag).

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

Added: 


Modified: 
clang/include/clang/Driver/Options.td
flang/include/flang/Frontend/FrontendActions.h
flang/include/flang/Frontend/FrontendOptions.h
flang/lib/Frontend/CompilerInvocation.cpp
flang/lib/Frontend/FrontendActions.cpp
flang/lib/FrontendTool/ExecuteCompilerInvocation.cpp
flang/test/Driver/driver-help.f90
flang/test/Semantics/getsymbols01.f90
flang/test/Semantics/getsymbols02.f90
flang/test/Semantics/getsymbols03-a.f90
flang/test/Semantics/getsymbols04.f90
flang/test/Semantics/getsymbols05.f90

Removed: 




diff  --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index a3a0d86c054a..55dddab6160c 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -4364,6 +4364,8 @@ def fdebug_pre_fir_tree : Flag<["-"], 
"fdebug-pre-fir-tree">, Group;
 def fdebug_module_writer : Flag<["-"],"fdebug-module-writer">, 
   HelpText<"Enable debug messages while writing module files">;
+def fget_symbols_sources : Flag<["-"], "fget-symbols-sources">, 
Group,
+  HelpText<"Dump symbols and their source code locations">;
 
 }
 

diff  --git a/flang/include/flang/Frontend/FrontendActions.h 
b/flang/include/flang/Frontend/FrontendActions.h
index 35d1e6f29b0f..f49f9f4714b5 100644
--- a/flang/include/flang/Frontend/FrontendActions.h
+++ b/flang/include/flang/Frontend/FrontendActions.h
@@ -100,6 +100,10 @@ class DebugPreFIRTreeAction : public PrescanAndSemaAction {
   void ExecuteAction() override;
 };
 
+class GetSymbolsSourcesAction : public PrescanAndSemaAction {
+  void ExecuteAction() override;
+};
+
 class ParseSyntaxOnlyAction : public PrescanAndSemaAction {
   void ExecuteAction() override;
 };

diff  --git a/flang/include/flang/Frontend/FrontendOptions.h 
b/flang/include/flang/Frontend/FrontendOptions.h
index 48182f488466..1d9002335c3c 100644
--- a/flang/include/flang/Frontend/FrontendOptions.h
+++ b/flang/include/flang/Frontend/FrontendOptions.h
@@ -58,7 +58,10 @@ enum ActionKind {
   DebugMeasureParseTree,
 
   /// Parse, run semantics and then output the pre-FIR tree
-  DebugPreFIRTree
+  DebugPreFIRTree,
+
+  /// Parse, run semantics and then dump symbol sources map
+  GetSymbolsSources
 
   /// TODO: RunPreprocessor, EmitLLVM, EmitLLVMOnly,
   /// EmitCodeGenOnly, EmitAssembly, (...)

diff  --git a/flang/lib/Frontend/CompilerInvocation.cpp 
b/flang/lib/Frontend/CompilerInvocation.cpp
index 1271cd314831..d2318d3d683d 100644
--- a/flang/lib/Frontend/CompilerInvocation.cpp
+++ b/flang/lib/Frontend/CompilerInvocation.cpp
@@ -143,6 +143,9 @@ static InputKind ParseFrontendArgs(FrontendOptions &opts,
 case clang::driver::options::OPT_fdebug_pre_fir_tree:
   opts.programAction_ = DebugPreFIRTree;
   break;
+case clang::driver::options::OPT_fget_symbols_sources:
+  opts.programAction_ = GetSymbolsSources;
+  break;
 
   // TODO:
   // case calng::driver::options::OPT_emit_llvm:

diff  --git a/flang/lib/Frontend/FrontendActions.cpp 
b/flang/lib/Frontend/FrontendActions.cpp
index ea283fe7a0c9..1871a35444db 100644
--- a/flang/lib/Frontend/FrontendActions.cpp
+++ b/flang/lib/Frontend/FrontendActions.cpp
@@ -16,6 +16,7 @@
 #include "flang/Parser/provenance.h"
 #include "flang/Parser/source.h"
 #include "flang/Parser/unparse.h"
+#include "flang/Semantics/runtime-type-info.h"
 #include "flang/Semantics/semantics.h"
 #include "flang/Semantics/unparse-with-symbols.h"
 #include "llvm/ADT/StringRef.h"
@@ -314,6 +315,15 @@ void DebugDumpParsingLogAction::ExecuteAction() {
   ci.parsing().DumpParsingLog(llvm::outs());
 }
 
+void GetSymbolsSourcesAction::ExecuteAction() {
+  // Report and exit if fatal semantic errors are present
+  if (reportFatalSemanticErrors(semantics(), this->instance().diagnostics(),
+  GetCurrentFileOrBufferName()))
+return;
+
+  semantics().DumpSymbolsSources(llvm::outs());

[PATCH] D98191: [flang][driver] Add support for `-fdebug-dump-symbols-sources`

2021-03-18 Thread Andrzej Warzynski 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 rGeefda605fe17: [flang][driver] Add support for 
`-fget-symbols-sources` (authored by awarzynski).

Changed prior to commit:
  https://reviews.llvm.org/D98191?vs=330978&id=331557#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98191

Files:
  clang/include/clang/Driver/Options.td
  flang/include/flang/Frontend/FrontendActions.h
  flang/include/flang/Frontend/FrontendOptions.h
  flang/lib/Frontend/CompilerInvocation.cpp
  flang/lib/Frontend/FrontendActions.cpp
  flang/lib/FrontendTool/ExecuteCompilerInvocation.cpp
  flang/test/Driver/driver-help.f90
  flang/test/Semantics/getsymbols01.f90
  flang/test/Semantics/getsymbols02.f90
  flang/test/Semantics/getsymbols03-a.f90
  flang/test/Semantics/getsymbols04.f90
  flang/test/Semantics/getsymbols05.f90

Index: flang/test/Semantics/getsymbols05.f90
===
--- flang/test/Semantics/getsymbols05.f90
+++ flang/test/Semantics/getsymbols05.f90
@@ -9,7 +9,7 @@
   x = y
 end program
 
-! RUN: %f18 -fget-symbols-sources -fsyntax-only %s 2>&1 | FileCheck %s
+! RUN: %flang_fc1 -fsyntax-only -fget-symbols-sources %s 2>&1 | FileCheck %s
 ! CHECK:x:{{.*}}getsymbols05.f90, 3, 14-15
 ! CHECK:x:{{.*}}getsymbols05.f90, 6, 16-17
 ! CHECK:y:{{.*}}getsymbols05.f90, 4, 14-15
Index: flang/test/Semantics/getsymbols04.f90
===
--- flang/test/Semantics/getsymbols04.f90
+++ flang/test/Semantics/getsymbols04.f90
@@ -6,7 +6,7 @@
   x = y
 end program
 
-! RUN: %f18 -fget-symbols-sources -fsyntax-only %s 2>&1 | FileCheck %s
+! RUN: %flang_fc1 -fsyntax-only -fget-symbols-sources %s 2>&1 | FileCheck %s
 ! CHECK:x:{{.*}}getsymbols04.f90, 3, 14-15
 ! CHECK:x:{{.*}}getsymbols04.f90, 5, 11-12
 ! CHECK:y:{{.*}}getsymbols04.f90, 4, 14-15
Index: flang/test/Semantics/getsymbols03-a.f90
===
--- flang/test/Semantics/getsymbols03-a.f90
+++ flang/test/Semantics/getsymbols03-a.f90
@@ -7,7 +7,7 @@
  x = f
 end program
 
-! RUN: %f18 -fget-symbols-sources -fsyntax-only %s 2>&1 | FileCheck %s
+! RUN: %flang_fc1 -fsyntax-only -fget-symbols-sources %s 2>&1 | FileCheck %s
 ! CHECK:f:{{.*}}getsymbols03-b.f90, 2, 12-13
 ! CHECK:main:{{.*}}getsymbols03-a.f90, 4, 9-13
 ! CHECK:mm3:{{.*}}getsymbols03-a.f90, 5, 6-9
Index: flang/test/Semantics/getsymbols02.f90
===
--- flang/test/Semantics/getsymbols02.f90
+++ flang/test/Semantics/getsymbols02.f90
@@ -7,8 +7,8 @@
 i = callget5()
 ENDPROGRAM
 
-! RUN: %f18 -fsyntax-only %S/Inputs/getsymbols02-a.f90
-! RUN: %f18 -fsyntax-only %S/Inputs/getsymbols02-b.f90
-! RUN: %f18 -fget-symbols-sources -fsyntax-only %s 2>&1 | FileCheck %s
+! RUN: %flang_fc1 -fsyntax-only %S/Inputs/getsymbols02-a.f90
+! RUN: %flang_fc1 -fsyntax-only %S/Inputs/getsymbols02-b.f90
+! RUN: %flang_fc1 -fsyntax-only -fget-symbols-sources %s 2>&1 | FileCheck %s
 ! CHECK: callget5: .{{[/\\]}}mm2b.mod,
 ! CHECK: get5: .{{[/\\]}}mm2a.mod,
Index: flang/test/Semantics/getsymbols01.f90
===
--- flang/test/Semantics/getsymbols01.f90
+++ flang/test/Semantics/getsymbols01.f90
@@ -15,7 +15,7 @@
  end function
 end module
 
-! RUN: %f18 -fget-symbols-sources -fsyntax-only %s 2>&1 | FileCheck %s
+! RUN: %flang_fc1 -fsyntax-only -fget-symbols-sources %s 2>&1 | FileCheck %s
 ! CHECK-COUNT-1:f:{{.*}}getsymbols01.f90, 12, 26-27
 ! CHECK-COUNT-1:mm1:{{.*}}getsymbols01.f90, 2, 8-11
 ! CHECK-COUNT-1:s:{{.*}}getsymbols01.f90, 5, 18-19
Index: flang/test/Driver/driver-help.f90
===
--- flang/test/Driver/driver-help.f90
+++ flang/test/Driver/driver-help.f90
@@ -80,6 +80,7 @@
 ! HELP-FC1-NEXT: -ffixed-line-length=
 ! HELP-FC1-NEXT: Use  as character line width in fixed mode
 ! HELP-FC1-NEXT: -ffree-formProcess source files in free form
+! HELP-FC1-NEXT: -fget-symbols-sources   Dump symbols and their source code locations
 ! 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: -flarge-sizes  Use INTEGER(KIND=8) for the result type in size-related intrinsics
Index: flang/lib/FrontendTool/ExecuteCompilerInvocation.cpp
===
--- flang/lib/FrontendTool/ExecuteCompilerInvocation.cpp
+++ flang/lib/FrontendTool/ExecuteCompilerInvocation.cpp
@@ -61,6 +61,9 @@
   case DebugPreFIRTree:
 return std::make_unique();
 break;
+  case GetSymbolsSources:
+return std::make_unique();
+break;
   defa

[PATCH] D98867: [HIP] Fix ROCm detection

2021-03-18 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl created this revision.
yaxunl added a reviewer: tra.
Herald added subscribers: kerbowa, nhaehnle, jvesely.
yaxunl requested review of this revision.

ROCm has changed installation path to /opt/rocm-{release}. Add detection
for that. Also support ROCM_PATH environment variable.


https://reviews.llvm.org/D98867

Files:
  clang/lib/Driver/ToolChains/AMDGPU.cpp
  clang/test/Driver/rocm-detect.hip


Index: clang/test/Driver/rocm-detect.hip
===
--- clang/test/Driver/rocm-detect.hip
+++ clang/test/Driver/rocm-detect.hip
@@ -21,6 +21,21 @@
 // RUN:   --rocm-path=%S/Inputs/rocm %s 2>&1 \
 // RUN:   | FileCheck -check-prefixes=COMMON,NODEFAULTLIBS %s
 
+// Test environment variable ROCM_PATH.
+// RUN: env ROCM_PATH=%S/Inputs/rocm %clang -### -target x86_64-linux-gnu \
+// RUN:   --print-rocm-search-dirs %s 2>&1 \
+// RUN:   | FileCheck -check-prefixes=ROCM-ENV %s
+
+// Test detecting latest /opt/rocm-{release} directory.
+// RUN: rm -rf %T/opt/rocm-4.0.0
+// RUN: rm -rf %T/opt/rocm-4.2.0-6566
+// RUN: mkdir -p %T/opt
+// RUN: cp -r %S/Inputs/rocm %T/opt/rocm-4.0.0
+// RUN: cp -r %S/Inputs/rocm %T/opt/rocm-4.1.0
+// RUN: %clang -### -target x86_64-linux-gnu --sysroot=%T \
+// RUN:   --print-rocm-search-dirs %s 2>&1 \
+// RUN:   | FileCheck -check-prefixes=ROCM-REL %s
+
 // Test ROCm installation built by SPACK by invoke clang at 
%T/rocm-spack/llvm-amdgpu-*
 // directory through a soft link.
 
@@ -60,6 +75,11 @@
 
 // COMMON: "-triple" "amdgcn-amd-amdhsa"
 
+// ROCM-ENV: ROCm installation search path: {{.*}}/Inputs/rocm
+
+// ROCM-REL: ROCm installation search path: {{.*}}/opt/rocm
+// ROCM-REL: ROCm installation search path: {{.*}}/opt/rocm-4.1.0
+
 // SPACK: ROCm installation search path (Spack 4.0.0): [[DIR:.*]]
 // SPACK: ROCm installation search path: [[CLANG:.*]]
 // SPACK: ROCm installation search path: [[CLANG]]/lib/clang/{{[0-9.]+}}
Index: clang/lib/Driver/ToolChains/AMDGPU.cpp
===
--- clang/lib/Driver/ToolChains/AMDGPU.cpp
+++ clang/lib/Driver/ToolChains/AMDGPU.cpp
@@ -186,6 +186,12 @@
 ROCmSearchDirs.emplace_back(RocmPathArg.str());
 DoPrintROCmSearchDirs();
 return ROCmSearchDirs;
+  } else if (const char *RocmPathEnv = ::getenv("ROCM_PATH")) {
+if (!StringRef(RocmPathEnv).empty()) {
+  ROCmSearchDirs.emplace_back(RocmPathEnv);
+  DoPrintROCmSearchDirs();
+  return ROCmSearchDirs;
+}
   }
 
   // Try to find relative to the compiler binary.
@@ -247,6 +253,28 @@
 
   ROCmSearchDirs.emplace_back(D.SysRoot + "/opt/rocm",
   /*StrictChecking=*/true);
+
+  // Find the latest /opt/rocm-{release} directory.
+  std::error_code EC;
+  std::string LatestROCm;
+  for (llvm::vfs::directory_iterator
+   File = D.getVFS().dir_begin(D.SysRoot + "/opt", EC),
+   FileEnd;
+   File != FileEnd && !EC; File.increment(EC)) {
+llvm::StringRef FileName = llvm::sys::path::filename(File->path());
+if (!FileName.startswith("rocm-"))
+  continue;
+if (LatestROCm.empty()) {
+  LatestROCm = FileName.str();
+  continue;
+}
+if (LatestROCm < FileName)
+  LatestROCm = FileName.str();
+  }
+  if (!LatestROCm.empty())
+ROCmSearchDirs.emplace_back(D.SysRoot + "/opt/" + LatestROCm,
+/*StrictChecking=*/true);
+
   DoPrintROCmSearchDirs();
   return ROCmSearchDirs;
 }


Index: clang/test/Driver/rocm-detect.hip
===
--- clang/test/Driver/rocm-detect.hip
+++ clang/test/Driver/rocm-detect.hip
@@ -21,6 +21,21 @@
 // RUN:   --rocm-path=%S/Inputs/rocm %s 2>&1 \
 // RUN:   | FileCheck -check-prefixes=COMMON,NODEFAULTLIBS %s
 
+// Test environment variable ROCM_PATH.
+// RUN: env ROCM_PATH=%S/Inputs/rocm %clang -### -target x86_64-linux-gnu \
+// RUN:   --print-rocm-search-dirs %s 2>&1 \
+// RUN:   | FileCheck -check-prefixes=ROCM-ENV %s
+
+// Test detecting latest /opt/rocm-{release} directory.
+// RUN: rm -rf %T/opt/rocm-4.0.0
+// RUN: rm -rf %T/opt/rocm-4.2.0-6566
+// RUN: mkdir -p %T/opt
+// RUN: cp -r %S/Inputs/rocm %T/opt/rocm-4.0.0
+// RUN: cp -r %S/Inputs/rocm %T/opt/rocm-4.1.0
+// RUN: %clang -### -target x86_64-linux-gnu --sysroot=%T \
+// RUN:   --print-rocm-search-dirs %s 2>&1 \
+// RUN:   | FileCheck -check-prefixes=ROCM-REL %s
+
 // Test ROCm installation built by SPACK by invoke clang at %T/rocm-spack/llvm-amdgpu-*
 // directory through a soft link.
 
@@ -60,6 +75,11 @@
 
 // COMMON: "-triple" "amdgcn-amd-amdhsa"
 
+// ROCM-ENV: ROCm installation search path: {{.*}}/Inputs/rocm
+
+// ROCM-REL: ROCm installation search path: {{.*}}/opt/rocm
+// ROCM-REL: ROCm installation search path: {{.*}}/opt/rocm-4.1.0
+
 // SPACK: ROCm installation search path (Spack 4.0.0): [[DIR:.*]]
 // SPACK: ROCm installation search path: [[CLANG:.*]]
 // SPACK: ROCm installation search path: [[CLANG]]/lib/clang/{{[

[PATCH] D98864: [SystemZ][z/OS] Set maximum value to truncate attribute aligned to for static variables on z/OS target

2021-03-18 Thread Fanbo Meng via Phabricator via cfe-commits
fanbo-meng updated this revision to Diff 331559.
fanbo-meng added a comment.

remove accidentally included diff patch file


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

https://reviews.llvm.org/D98864

Files:
  clang/include/clang/Basic/TargetInfo.h
  clang/lib/AST/ASTContext.cpp
  clang/lib/Basic/TargetInfo.cpp
  clang/lib/Basic/Targets/OSTargets.h
  clang/test/CodeGen/SystemZ/zos-alignment.c


Index: clang/test/CodeGen/SystemZ/zos-alignment.c
===
--- clang/test/CodeGen/SystemZ/zos-alignment.c
+++ clang/test/CodeGen/SystemZ/zos-alignment.c
@@ -1,4 +1,16 @@
-// RUN: %clang_cc1 -emit-llvm-only -triple s390x-none-zos 
-fdump-record-layouts %s | FileCheck %s
+// RUN: %clang_cc1 -emit-llvm-only -triple s390x-none-zos 
-fdump-record-layouts %s | FileCheck %s --check-prefix=CHECK
+// RUN: %clang_cc1 -emit-llvm -triple s390x-none-zos %s -o - | FileCheck %s 
--check-prefix=DECL
+
+static int __attribute__((aligned(32))) v0;
+int __attribute__((aligned(32))) v1;
+typedef int __attribute__((aligned(32))) int32;
+static int32 v2;
+int32 v3;
+int f0() { return v0 + v1 + v2 + v3; }
+// DECL:  @v0 {{.*}} align 16
+// DECL-NEXT: @v1 {{.*}} align 32
+// DECL-NEXT: @v2 {{.*}} align 16
+// DECL-NEXT: @v3 {{.*}} align 32
 
 struct s0 {
   short a:3;
Index: clang/lib/Basic/Targets/OSTargets.h
===
--- clang/lib/Basic/Targets/OSTargets.h
+++ clang/lib/Basic/Targets/OSTargets.h
@@ -788,6 +788,7 @@
   ZOSTargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts)
   : OSTargetInfo(Triple, Opts) {
 this->WCharType = TargetInfo::UnsignedInt;
+this->MaxAlignedAttribute = 128;
 this->UseBitFieldTypeAlignment = false;
 this->UseZeroLengthBitfieldAlignment = true;
 this->ZeroLengthBitfieldBoundary = 32;
Index: clang/lib/Basic/TargetInfo.cpp
===
--- clang/lib/Basic/TargetInfo.cpp
+++ clang/lib/Basic/TargetInfo.cpp
@@ -106,6 +106,7 @@
   UseZeroLengthBitfieldAlignment = false;
   UseExplicitBitFieldAlignment = true;
   ZeroLengthBitfieldBoundary = 0;
+  MaxAlignedAttribute = 0;
   HalfFormat = &llvm::APFloat::IEEEhalf();
   FloatFormat = &llvm::APFloat::IEEEsingle();
   DoubleFormat = &llvm::APFloat::IEEEdouble();
Index: clang/lib/AST/ASTContext.cpp
===
--- clang/lib/AST/ASTContext.cpp
+++ clang/lib/AST/ASTContext.cpp
@@ -1783,6 +1783,13 @@
 }
   }
 
+  // Some targets have hard limitation on the maximum requestable alignment in
+  // aligned attribute for static variables.
+  const unsigned MaxAlignedAttr = getTargetInfo().getMaxAlignedAttribute();
+  const auto *VD = dyn_cast(D);
+  if (MaxAlignedAttr && VD && VD->getStorageClass() == SC_Static)
+Align = std::min(Align, MaxAlignedAttr);
+
   return toCharUnitsFromBits(Align);
 }
 
Index: clang/include/clang/Basic/TargetInfo.h
===
--- clang/include/clang/Basic/TargetInfo.h
+++ clang/include/clang/Basic/TargetInfo.h
@@ -161,6 +161,10 @@
   /// If non-zero, specifies a fixed alignment value for bitfields that follow
   /// zero length bitfield, regardless of the zero length bitfield type.
   unsigned ZeroLengthBitfieldBoundary;
+
+  /// If non-zero, specifies a maximum alignment to truncate alignment
+  /// specified in the aligned attribute of a static variable to this value.
+  unsigned MaxAlignedAttribute;
 };
 
 /// OpenCL type kinds.
@@ -774,6 +778,10 @@
 return ZeroLengthBitfieldBoundary;
   }
 
+  /// Get the maximum alignment in bits for a static variable with
+  /// aligned attribute.
+  unsigned getMaxAlignedAttribute() const { return MaxAlignedAttribute; }
+
   /// Check whether explicit bitfield alignment attributes should be
   //  honored, as in "__attribute__((aligned(2))) int b : 1;".
   bool useExplicitBitFieldAlignment() const {


Index: clang/test/CodeGen/SystemZ/zos-alignment.c
===
--- clang/test/CodeGen/SystemZ/zos-alignment.c
+++ clang/test/CodeGen/SystemZ/zos-alignment.c
@@ -1,4 +1,16 @@
-// RUN: %clang_cc1 -emit-llvm-only -triple s390x-none-zos -fdump-record-layouts %s | FileCheck %s
+// RUN: %clang_cc1 -emit-llvm-only -triple s390x-none-zos -fdump-record-layouts %s | FileCheck %s --check-prefix=CHECK
+// RUN: %clang_cc1 -emit-llvm -triple s390x-none-zos %s -o - | FileCheck %s --check-prefix=DECL
+
+static int __attribute__((aligned(32))) v0;
+int __attribute__((aligned(32))) v1;
+typedef int __attribute__((aligned(32))) int32;
+static int32 v2;
+int32 v3;
+int f0() { return v0 + v1 + v2 + v3; }
+// DECL:  @v0 {{.*}} align 16
+// DECL-NEXT: @v1 {{.*}} align 32
+// DECL-NEXT: @v2 {{.*}} align 16
+// DECL-NEXT: @v3 {{.*}} align 32
 
 struct s0 {
   short a:3;
Index: clang/lib/Basic/Targets/OSTargets.h
==

[PATCH] D98868: [Driver] Add -print-runtime-dir

2021-03-18 Thread Markus Böck via Phabricator via cfe-commits
zero9178 created this revision.
zero9178 added reviewers: rnk, phosek, MaskRay.
Herald added subscribers: jansvoboda11, dang.
zero9178 requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

This patch adds a new command line option to clang which outputs the directory 
containing clangs runtime libraries to stdout.

The primary use case for this command line flag is for build systems using 
clang-cl. Build systems when using clang-cl invoke the linker, that is either 
link or lld-link in this case, directly instead of invoking the compiler for 
the linking process as is common with the other drivers. This leads to issues 
when runtime libraries of clang, such as sanitizers or profiling, have to be 
linked in as the compiler cannot communicate the link directory to the linker.

Using this flag, build systems would be capable of getting the directory 
containing all of clang's runtime libraries and add it to the linker path.

One such implementation is in LLVM's CMake scripts which currently gets the 
path to the builtins library and uses the containing directory. This also has 
issues however when the builtins library does not exist, which AFAIK is not a 
prerequisite to using clang-cl. More info here: https://reviews.llvm.org/D98786


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D98868

Files:
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/Driver.cpp
  clang/test/Driver/Inputs/resource_dir/lib/windows/clang_rt.builtins-x86_64.lib
  
clang/test/Driver/Inputs/resource_dir_with_per_target_subdir/lib/x86_64-pc-windows-msvc/clang_rt.builtins.lib
  clang/test/Driver/immediate-options.c


Index: clang/test/Driver/immediate-options.c
===
--- clang/test/Driver/immediate-options.c
+++ clang/test/Driver/immediate-options.c
@@ -17,3 +17,15 @@
 // Allow unspecified output because the value of CLANG_RESOURCE_DIR is unknown.
 // RUN: %clang -print-resource-dir | FileCheck %s 
-check-prefix=PRINT-RESOURCE-DIR
 // PRINT-RESOURCE-DIR: {{.+}}
+
+// Default resource-dir layout
+// RUN: %clang -print-runtime-dir --target=x86_64-pc-windows-msvc \
+// RUN:-resource-dir=%S/Inputs/resource_dir \
+// RUN:  | FileCheck --check-prefix=PRINT-RUNTIME-DIR %s
+// PRINT-RUNTIME-DIR: lib{{/|\\}}windows
+
+// Per target dir layout
+// RUN: %clang -print-runtime-dir --target=x86_64-pc-windows-msvc \
+// RUN:-resource-dir=%S/Inputs/resource_dir_with_per_target_subdir \
+// RUN:  | FileCheck --check-prefix=PRINT-RUNTIME-DIR-PER-TARGET %s
+// PRINT-RUNTIME-DIR-PER-TARGET: lib{{/|\\}}x86_64-pc-windows-msvc
Index: clang/lib/Driver/Driver.cpp
===
--- clang/lib/Driver/Driver.cpp
+++ clang/lib/Driver/Driver.cpp
@@ -1824,6 +1824,15 @@
 return false;
   }
 
+  if (C.getArgs().hasArg(options::OPT_print_runtime_dir)) {
+if (auto RuntimePath = TC.getRuntimePath()) {
+  llvm::outs() << *RuntimePath << '\n';
+  return false;
+}
+llvm::outs() << TC.getCompilerRTPath() << '\n';
+return false;
+  }
+
   // FIXME: The following handlers should use a callback mechanism, we don't
   // know what the client would like to do.
   if (Arg *A = C.getArgs().getLastArg(options::OPT_print_file_name_EQ)) {
Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -3567,6 +3567,8 @@
   HelpText<"Print the registered targets">;
 def print_rocm_search_dirs : Flag<["-", "--"], "print-rocm-search-dirs">,
   HelpText<"Print the paths used for finding ROCm installation">;
+def print_runtime_dir : Flag<["-", "--"], "print-runtime-dir">,
+  HelpText<"Print the directory pathname containing clangs runtime libraries">;
 def private__bundle : Flag<["-"], "private_bundle">;
 def pthreads : Flag<["-"], "pthreads">;
 defm pthread : BoolOption<"", "pthread",


Index: clang/test/Driver/immediate-options.c
===
--- clang/test/Driver/immediate-options.c
+++ clang/test/Driver/immediate-options.c
@@ -17,3 +17,15 @@
 // Allow unspecified output because the value of CLANG_RESOURCE_DIR is unknown.
 // RUN: %clang -print-resource-dir | FileCheck %s -check-prefix=PRINT-RESOURCE-DIR
 // PRINT-RESOURCE-DIR: {{.+}}
+
+// Default resource-dir layout
+// RUN: %clang -print-runtime-dir --target=x86_64-pc-windows-msvc \
+// RUN:-resource-dir=%S/Inputs/resource_dir \
+// RUN:  | FileCheck --check-prefix=PRINT-RUNTIME-DIR %s
+// PRINT-RUNTIME-DIR: lib{{/|\\}}windows
+
+// Per target dir layout
+// RUN: %clang -print-runtime-dir --target=x86_64-pc-windows-msvc \
+// RUN:-resource-dir=%S/Inputs/resource_dir_with_per_target_subdir \
+// RUN:  | FileCheck --check-prefix=PRINT-RUNTIME-DIR-PER-TARGET %s
+// PRINT-RUNTIME-DIR-PER

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

2021-03-18 Thread Vassil Vassilev via Phabricator via cfe-commits
v.g.vassilev added a comment.

In D96033#2632848 , @rjmccall wrote:

> In D96033#2630978 , @v.g.vassilev 
> wrote:
>
 I'm nervous in general about the looming idea of declaration unloading, 
 but the fact that it's been working in Cling for a long time gives me some 
 confidence that we can do that in a way that's not prohibitively expensive 
 and invasive.
>>>
>>> I don't really know the jargon here.
>>
>> "Code unloading" is mentioned here 
>> https://reviews.llvm.org/D96033?id=323531#inline-911819
>
> I see.  So you want to be able to sort of "roll back" Sema to a previous 
> version of the semantic state, and yet you also need IRGen to *not* be rolled 
> back because of lazy emission.

The state should match the state of Sema (at least that's the current case for 
cling).

That seems... tough.  I don't think we're really architected to support that 
goal — frankly, I'm not sure C and C++ are architected to support that goal — 
and I'm concerned that it might require a ton of extra complexity and risk for 
us.  I say this not to be dismissive, but to clarify how I see our various 
responsibilities here.  Clang's primary mission is to be a static compiler, and 
it's been architected with that in mind, and it's acceptable for us to put that 
mission above other goals if we think they're in conflict.  So as I see it, 
your responsibility here is to persuade us of one of the following:

> - that you can achieve your goals without introducing major problems for 
> Clang's primary mission,
> - that the changes you'll need to make will ultimately have substantial 
> benefits for Clang's primary mission, or
> - that we should change how we think about Clang's primary mission.

We have, over the years, deliberately have taken a very conservative stance and 
we have tried to achieve that goal without major modifications in clang in 
general. Cling has been ou-of-tree so clang design changes were not on the 
table then and now. In my opinion, we have managed to go long way using this 
set of changes 
 in 
clang which in my view is fairly minimal considering the case we enable. My 
understanding of clang is limited so I cannot really judge if the approach we 
took is sustainable but over the years we have mostly suffered from having to 
selectively reset CodeGen state across incremental inputs. Plus some state in 
Sema which comes from another feature which requires recursive parsing but I 
would not consider that feature central for this particular discussion.

> We probably need to talk about it.

+1. Do you use discord/slack/skype?

In D96033#2633479 , @rjmccall wrote:

> To be clear, what I'm trying to say is that — absent consensus that it's a 
> major architecture shift is appropriate — we need to consider what 
> functionality is reasonably achievable without it.  I'm sure that covers most 
> of what you're trying to do; it just may not include everything.

I understand and would like to thank you for bringing this up! I concur with 
that preference.

> One of the fortunate things about working in a REPL is that many ABI 
> considerations go completely out the window.  The most important of those is 
> the abstract need for symbol-matching; that is, there's practically no reason 
> why a C REPL needs to use the simple C symbol mangling, because nobody 
> expects code written outside the REPL to link up with user-entered 
> declarations.  So we can be quite aggressive about how we emit declarations 
> "behind the scenes"; C mode really just means C's user-level semantics, 
> calling convention, and type layout, but not any of C's ordinary 
> interoperation/compatibility requirements.

I have never thought about ABI being a bi-directional problem, and indeed we 
can probably define away one direction. Do I understand that correctly? If I 
do, that would mean we can still embed the C REPL into third party code and be 
able to call compiled code from libraries?


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

https://reviews.llvm.org/D96033

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


[PATCH] D20689: [clang-tidy] Add 'readability-suspicious-call-argument' check

2021-03-18 Thread Whisperity via Phabricator via cfe-commits
whisperity updated this revision to Diff 331560.
whisperity marked 2 inline comments as done.
whisperity added a comment.

- **NFC** Fixed some nits
- Added a new check option, //`MinimumIdentifierNameLength`// instead of a 
hardcoded `3` value. Defaults to `3`.
- Fixed an issue with heuristics matching only in one direction but not in the 
other direction silenced a warning that clearly should have been there.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D20689

Files:
  clang-tools-extra/clang-tidy/readability/CMakeLists.txt
  clang-tools-extra/clang-tidy/readability/ReadabilityTidyModule.cpp
  clang-tools-extra/clang-tidy/readability/SuspiciousCallArgumentCheck.cpp
  clang-tools-extra/clang-tidy/readability/SuspiciousCallArgumentCheck.h
  clang-tools-extra/docs/ReleaseNotes.rst
  clang-tools-extra/docs/clang-tidy/checks/list.rst
  
clang-tools-extra/docs/clang-tidy/checks/readability-suspicious-call-argument.rst
  
clang-tools-extra/test/clang-tidy/checkers/readability-suspicious-call-argument.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/readability-suspicious-call-argument.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/readability-suspicious-call-argument.cpp
@@ -0,0 +1,477 @@
+// RUN: %check_clang_tidy %s readability-suspicious-call-argument %t -- -- -std=c++11
+
+void foo_1(int aa, int bb) {}
+
+void foo_2(int source, int aa) {}
+
+void foo_3(int valToRet, int aa) {}
+
+void foo_4(int pointer, int aa) {}
+
+void foo_5(int aa, int bb, int cc, ...) {}
+
+void foo_6(const int dd, bool &ee) {}
+
+void foo_7(int aa, int bb, int cc, int ff = 7) {}
+
+void foo_8(int frobble1, int frobble2) {}
+
+// Test functions for convertible argument--parameter types.
+void fun(const int &m);
+void fun2() {
+  int m = 3;
+  fun(m);
+}
+
+// Test cases for parameters of const reference and value.
+void value_const_reference(int ll, const int &kk);
+
+void const_ref_value_swapped() {
+  const int &kk = 42;
+  const int &ll = 42;
+  value_const_reference(kk, ll);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: 1st argument 'kk' (passed to 'll') looks like it might be swapped with the 2nd, 'll' (passed to 'kk') [readability-suspicious-call-argument]
+  // CHECK-MESSAGES: :[[@LINE-7]]:6: note: in the call to 'value_const_reference', declared here
+}
+
+// Const, non const references.
+void const_nonconst_parameters(const int &mm, int &nn);
+
+void const_nonconst_swap1() {
+  const int &nn = 42;
+  int mm;
+  // Do not check, because non-const reference parameter cannot bind to const reference argument.
+  const_nonconst_parameters(nn, mm);
+}
+
+void const_nonconst_swap3() {
+  const int nn = 42;
+  int m = 42;
+  int &mm = m;
+  // Do not check, const int does not bind to non const reference.
+  const_nonconst_parameters(nn, mm);
+}
+
+void const_nonconst_swap2() {
+  int nn;
+  int mm;
+  // Check for swapped arguments. (Both arguments are non-const.)
+  const_nonconst_parameters(nn, mm);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: 1st argument 'nn' (passed to 'mm') looks like it might be swapped with the 2nd, 'mm' (passed to 'nn')
+}
+
+void const_nonconst_pointers(const int *mm, int *nn);
+void const_nonconst_pointers2(const int *mm, const int *nn);
+
+void const_nonconst_pointers_swapped() {
+  int *mm;
+  const int *nn;
+  const_nonconst_pointers(nn, mm);
+}
+
+void const_nonconst_pointers_swapped2() {
+  const int *mm;
+  int *nn;
+  const_nonconst_pointers2(nn, mm);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: 1st argument 'nn' (passed to 'mm') looks like it might be swapped with the 2nd, 'mm' (passed to 'nn')
+}
+
+// Test cases for pointers and arrays.
+void pointer_array_parameters(
+int *pp, int qq[4]);
+
+void pointer_array_swap() {
+  int qq[5];
+  int *pp;
+  // Check for swapped arguments. An array implicitly converts to a pointer.
+  pointer_array_parameters(qq, pp);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: 1st argument 'qq' (passed to 'pp') looks like it might be swapped with the 2nd, 'pp' (passed to 'qq')
+}
+
+// Test cases for multilevel pointers.
+void multilevel_pointer_parameters(int *const **pp,
+   const int *const *volatile const *qq);
+void multilevel_pointer_parameters2(
+char *nn, char *volatile *const *const *const *const &mm);
+
+typedef float T;
+typedef T *S;
+typedef S *const volatile R;
+typedef R *Q;
+typedef Q *P;
+typedef P *O;
+void multilevel_pointer_parameters3(float **const volatile ***rr, O &ss);
+
+void multilevel_pointer_swap() {
+  int *const **qq;
+  

[clang] c539be1 - [Hexagon] Add support for named registers cs0 and cs1

2021-03-18 Thread Sid Manning via cfe-commits

Author: Sid Manning
Date: 2021-03-18T09:53:22-05:00
New Revision: c539be1dcbcf88530cfaf1728b077feb564b72ec

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

LOG: [Hexagon] Add support for named registers cs0 and cs1

Allow inline assembly code to referece cs0 and cs1.

Added: 


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

Removed: 




diff  --git a/clang/lib/Basic/Targets/Hexagon.cpp 
b/clang/lib/Basic/Targets/Hexagon.cpp
index ba10459e9690..d1613fb22930 100644
--- a/clang/lib/Basic/Targets/Hexagon.cpp
+++ b/clang/lib/Basic/Targets/Hexagon.cpp
@@ -136,7 +136,7 @@ const char *const HexagonTargetInfo::GCCRegNames[] = {
 "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"

diff  --git a/llvm/lib/Target/Hexagon/HexagonISelLowering.cpp 
b/llvm/lib/Target/Hexagon/HexagonISelLowering.cpp
index 30c3d3d4f570..a7e9ed34bfcb 100644
--- a/llvm/lib/Target/Hexagon/HexagonISelLowering.cpp
+++ b/llvm/lib/Target/Hexagon/HexagonISelLowering.cpp
@@ -308,6 +308,8 @@ Register HexagonTargetLowering::getRegisterByName(
  .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;

diff  --git a/llvm/test/CodeGen/Hexagon/namedreg.ll 
b/llvm/test/CodeGen/Hexagon/namedreg.ll
index 72ca50868828..a905332b2dee 100644
--- a/llvm/test/CodeGen/Hexagon/namedreg.ll
+++ b/llvm/test/CodeGen/Hexagon/namedreg.ll
@@ -4,10 +4,29 @@ entry:
   %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



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


[PATCH] D78652: [clang-tidy] Suppress reports to similarly used parameters in 'bugprone-easily-swappable-parameters'

2021-03-18 Thread Whisperity via Phabricator via cfe-commits
whisperity updated this revision to Diff 331564.
whisperity marked 4 inline comments as done.
whisperity added a comment.

**NFC** Turned some `Optional` into just `T`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D78652

Files:
  clang-tools-extra/clang-tidy/bugprone/EasilySwappableParametersCheck.cpp
  clang-tools-extra/clang-tidy/bugprone/EasilySwappableParametersCheck.h
  
clang-tools-extra/docs/clang-tidy/checks/bugprone-easily-swappable-parameters.rst
  
clang-tools-extra/test/clang-tidy/checkers/bugprone-easily-swappable-parameters-ignore.cpp
  
clang-tools-extra/test/clang-tidy/checkers/bugprone-easily-swappable-parameters-len2.cpp
  
clang-tools-extra/test/clang-tidy/checkers/bugprone-easily-swappable-parameters-len3.cpp
  
clang-tools-extra/test/clang-tidy/checkers/bugprone-easily-swappable-parameters-relatedness.c
  
clang-tools-extra/test/clang-tidy/checkers/bugprone-easily-swappable-parameters-relatedness.cpp
  
clang-tools-extra/test/clang-tidy/checkers/bugprone-easily-swappable-parameters.c

Index: clang-tools-extra/test/clang-tidy/checkers/bugprone-easily-swappable-parameters.c
===
--- clang-tools-extra/test/clang-tidy/checkers/bugprone-easily-swappable-parameters.c
+++ clang-tools-extra/test/clang-tidy/checkers/bugprone-easily-swappable-parameters.c
@@ -2,7 +2,8 @@
 // RUN:   -config='{CheckOptions: [ \
 // RUN: {key: bugprone-easily-swappable-parameters.MinimumLength, value: 2}, \
 // RUN: {key: bugprone-easily-swappable-parameters.IgnoredParameterNames, value: ""}, \
-// RUN: {key: bugprone-easily-swappable-parameters.IgnoredParameterTypeSuffixes, value: "bool;MyBool;struct U;MAKE_LOGICAL_TYPE(int)"} \
+// RUN: {key: bugprone-easily-swappable-parameters.IgnoredParameterTypeSuffixes, value: "bool;MyBool;struct U;MAKE_LOGICAL_TYPE(int)"}, \
+// RUN: {key: bugprone-easily-swappable-parameters.SuppressParametersUsedTogether, value: 0} \
 // RUN:  ]}' -- -x c
 
 #define bool _Bool
Index: clang-tools-extra/test/clang-tidy/checkers/bugprone-easily-swappable-parameters-relatedness.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/bugprone-easily-swappable-parameters-relatedness.cpp
@@ -0,0 +1,229 @@
+// RUN: %check_clang_tidy %s bugprone-easily-swappable-parameters %t \
+// RUN:   -config='{CheckOptions: [ \
+// RUN: {key: bugprone-easily-swappable-parameters.MinimumLength, value: 2}, \
+// RUN: {key: bugprone-easily-swappable-parameters.IgnoredParameterNames, value: ""}, \
+// RUN: {key: bugprone-easily-swappable-parameters.IgnoredParameterTypeSuffixes, value: ""}, \
+// RUN: {key: bugprone-easily-swappable-parameters.SuppressParametersUsedTogether, value: 1} \
+// RUN:  ]}' --
+
+namespace std {
+template 
+T max(const T &A, const T &B);
+} // namespace std
+
+bool coin();
+void f(int);
+void g(int);
+void h(int, int);
+void i(int, bool);
+void i(int, char);
+
+struct Tmp {
+  int f(int);
+  int g(int, int);
+};
+
+struct Int {
+  int I;
+};
+
+void compare(int Left, int Right) {}
+// CHECK-MESSAGES: :[[@LINE-1]]:14: warning: 2 adjacent parameters of 'compare' of similar type ('int')
+// CHECK-MESSAGES: :[[@LINE-2]]:18: note: the first parameter in the range is 'Left'
+// CHECK-MESSAGES: :[[@LINE-3]]:28: note: the last parameter in the range is 'Right'
+
+int decideSequence(int A, int B) {
+  if (A)
+return 1;
+  if (B)
+return 2;
+  return 3;
+}
+// CHECK-MESSAGES: :[[@LINE-7]]:20: warning: 2 adjacent parameters of 'decideSequence' of similar type ('int')
+// CHECK-MESSAGES: :[[@LINE-8]]:24: note: the first parameter in the range is 'A'
+// CHECK-MESSAGES: :[[@LINE-9]]:31: note: the last parameter in the range is 'B'
+
+int myMax(int A, int B) { // NO-WARN: Appears in same expression.
+  return A < B ? A : B;
+}
+
+int myMax2(int A, int B) { // NO-WARN: Appears in same expression.
+  if (A < B)
+return A;
+  return B;
+}
+
+int myMax3(int A, int B) { // NO-WARN: Appears in same expression.
+  return std::max(A, B);
+}
+
+int binaryToUnary(int A, int) {
+  return A;
+}
+// CHECK-MESSAGES: :[[@LINE-3]]:19: warning: 2 adjacent parameters of 'binaryToUnary' of similar type ('int')
+// CHECK-MESSAGES: :[[@LINE-4]]:23: note: the first parameter in the range is 'A'
+// CHECK-MESSAGES: :[[@LINE-5]]:29: note: the last parameter in the range is ''
+
+int randomReturn1(int A, int B) { // NO-WARN: Appears in same expression.
+  return coin() ? A : B;
+}
+
+int randomReturn2(int A, int B) { // NO-WARN: Both parameters returned.
+  if (coin())
+return A;
+  return B;
+}
+
+int randomReturn3(int A, int B) { // NO-WARN: Both parameters returned.
+  bool Flip = coin();
+  if (Flip)
+return A;
+  Flip = coin();
+  if (Flip)
+return B;
+  Flip = coin();
+  if (!Flip)
+return 0;
+  return -1;
+}
+
+void passthrough1(int

[PATCH] D78652: [clang-tidy] Suppress reports to similarly used parameters in 'bugprone-easily-swappable-parameters'

2021-03-18 Thread Whisperity via Phabricator via cfe-commits
whisperity added inline comments.



Comment at: 
clang-tools-extra/clang-tidy/bugprone/EasilySwappableParametersCheck.cpp:529
+/// ReturnStmts return them from the function.
+class Returned {
+  llvm::SmallVector 
ReturnedParams;

aaron.ballman wrote:
> whisperity wrote:
> > whisperity wrote:
> > > aaron.ballman wrote:
> > > > Question: would it make sense to (someday, not now) consider output 
> > > > parameters similar to return statements? e.g.,
> > > > ```
> > > > void int_swap(int &foo, int &bar) {
> > > >   int temp = foo;
> > > >   foo = bar;
> > > >   bar = temp;
> > > > }
> > > > ```
> > > > As a question for today: should `co_return` should be handled similarly 
> > > > as `return`?
> > > 1. Maybe. Unfortunately, one needs to be careful with that. Originally I 
> > > did implement a "5th" heuristic that dealt with ignoring parameters that 
> > > had the same builtin operator used on them. However, while it silenced a 
> > > few false positives, it started creating **massive** amounts of false 
> > > negatives.
> > > (In the concrete example, I think `foo = bar` will silence them because 
> > > //"appears in the same expression"//.)
> > > 
> > > 2. I don't know. It would require a deeper understanding of Coroutines 
> > > themselves, and how people use them.
> > If you don't mind me posting images, I can show a direct example. Things 
> > where the inability to track data flow really bites us in the backside.
> > 
> > Examples from Apache Xerces:
> > 
> > Here's a false positive that would be silenced by the logic of //"using the 
> > same operateur on the two params"//.
> > {F15891567}
> > 
> > And here is a false negative from the exact same logic.
> > {F15891568}
> > 
> > Maybe it could be //some// solace that we're restricting to 
> > non-const-lvalue-references (and pointers-to-non-const ??) and only 
> > assignment (**only** assignment?!))...
> Ah, point #1 is an excellent point. As for #2, I think we can handle it in a 
> follow-up, but I believe `co_return` follows the same usage patterns as 
> `return`, generally.
Added a TODO for `co_return`, so we don't forget.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D78652

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


[PATCH] D72235: [clang-tidy] new altera unroll loops check

2021-03-18 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman accepted this revision.
aaron.ballman added a comment.
This revision is now accepted and ready to land.

Mostly just nits for the check, otherwise this LGTM.




Comment at: clang-tools-extra/clang-tidy/altera/UnrollLoopsCheck.cpp:65
+}
+if (isa(Loop) || isa(Loop)) {
+  diag(Loop->getBeginLoc(),





Comment at: clang-tools-extra/clang-tidy/altera/UnrollLoopsCheck.cpp:83-84
+UnrollLoopsCheck::unrollType(const Stmt *Statement, ASTContext *Context) {
+  const clang::DynTypedNodeList Parents = 
Context->getParents(*Statement);
+  for (const clang::DynTypedNode &Parent : Parents) {
+const auto *ParentStmt = Parent.get();

Pretty sure you don't need to use a qualified name here.



Comment at: clang-tools-extra/clang-tidy/altera/UnrollLoopsCheck.cpp:116-120
+  if (isa(Statement)) {
+if (CXXLoopBound)
+  return true;
+return false;
+  }





Comment at: clang-tools-extra/clang-tidy/altera/UnrollLoopsCheck.cpp:123
+  // unrolling for these.
+  if (isa(Statement) || isa(Statement))
+return false;





Comment at: clang-tools-extra/clang-tidy/altera/UnrollLoopsCheck.cpp:176-177
+  if (isa(Statement)) {
+const auto *LoopBoundExpr = dyn_cast(CXXLoopBound);
+return exprHasLargeNumIterations(LoopBoundExpr, Context);
+  }

The cast isn't necessary (`IntergerLiteral` is already an `Expr`). You should 
probably assert that `CXXLoopBound` isn't null here though.



Comment at: clang-tools-extra/clang-tidy/altera/UnrollLoopsCheck.cpp:180-181
+  const auto *ForLoop = dyn_cast(Statement);
+  if (!ForLoop)
+llvm_unreachable("Unknown loop");
+  const Stmt *Initializer = ForLoop->getInit();





Comment at: clang-tools-extra/clang-tidy/altera/UnrollLoopsCheck.cpp:196-197
+  }
+  if (!isa(Conditional))
+llvm_unreachable("Conditional is not a binary operator");
+  int EndValue;




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

https://reviews.llvm.org/D72235

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


[PATCH] D95736: [clang-tidy] Extend 'bugprone-easily-swappable-parameters' with `typedef` and `const &` diagnostics

2021-03-18 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman accepted this revision.
aaron.ballman added a comment.
This revision is now accepted and ready to land.

LGTM!


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

https://reviews.llvm.org/D95736

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


[PATCH] D98747: Thread safety analysis: Don't warn about managed locks on join points

2021-03-18 Thread Aaron Puchert via Phabricator via cfe-commits
aaronpuchert updated this revision to Diff 331567.
aaronpuchert added a comment.

Negative capabilities don't need to be considered as managed.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98747

Files:
  clang/lib/Analysis/ThreadSafety.cpp
  clang/test/SemaCXX/warn-thread-safety-analysis.cpp


Index: clang/test/SemaCXX/warn-thread-safety-analysis.cpp
===
--- clang/test/SemaCXX/warn-thread-safety-analysis.cpp
+++ clang/test/SemaCXX/warn-thread-safety-analysis.cpp
@@ -2595,6 +2595,7 @@
   if (c) {// test join point -- held/not held during release
 rlock.Release();
   }
+  // No warning on join point because the lock will be released by the scope 
object anyway.
 }
 
 void Foo::test3() {
@@ -2615,7 +2616,7 @@
   if (c) {
 rlock.Release();
   }
-  // no warning on join point for managed lock.
+  // No warning on join point because the lock will be released by the scope 
object anyway.
   rlock.Release();  // expected-warning {{releasing mutex 'mu_' that was not 
held}}
 }
 
@@ -2659,6 +2660,7 @@
 
 Mutex mu;
 int x GUARDED_BY(mu);
+bool b;
 
 void print(int);
 
@@ -2740,6 +2742,23 @@
   scope.Lock(); // expected-warning {{acquiring mutex 'mu' that is already 
held}}
 }
 
+void lockJoin() {
+  RelockableMutexLock scope(&mu, DeferTraits{});
+  if (b)
+scope.Lock();
+  // No warning on join point because the lock will be released by the scope 
object anyway.
+  x = 2; // expected-warning {{writing variable 'x' requires holding mutex 
'mu' exclusively}}
+}
+
+void unlockJoin() {
+  RelockableMutexLock scope(&mu, DeferTraits{});
+  scope.Lock();
+  if (b)
+scope.Unlock();
+  // No warning on join point because the lock will be released by the scope 
object anyway.
+  x = 2; // expected-warning {{writing variable 'x' requires holding mutex 
'mu' exclusively}}
+}
+
 void directUnlock() {
   RelockableExclusiveMutexLock scope(&mu);
   mu.Unlock();
@@ -2871,10 +2890,9 @@
 
 void join() EXCLUSIVE_LOCKS_REQUIRED(mu) {
   MutexUnlock scope(&mu);
-  if (c) {
-scope.Lock(); // expected-note{{mutex acquired here}}
-  }
-  // expected-warning@+1{{mutex 'mu' is not held on every path through here}}
+  if (c)
+scope.Lock();
+  // No warning on join point because the lock will be released by the scope 
object anyway.
   scope.Lock();
 }
 
Index: clang/lib/Analysis/ThreadSafety.cpp
===
--- clang/lib/Analysis/ThreadSafety.cpp
+++ clang/lib/Analysis/ThreadSafety.cpp
@@ -983,7 +983,7 @@
 } else {
   FSet.removeLock(FactMan, !Cp);
   FSet.addLock(FactMan,
-   std::make_unique(Cp, kind, loc));
+   std::make_unique(Cp, kind, loc, true));
 }
   }
 


Index: clang/test/SemaCXX/warn-thread-safety-analysis.cpp
===
--- clang/test/SemaCXX/warn-thread-safety-analysis.cpp
+++ clang/test/SemaCXX/warn-thread-safety-analysis.cpp
@@ -2595,6 +2595,7 @@
   if (c) {// test join point -- held/not held during release
 rlock.Release();
   }
+  // No warning on join point because the lock will be released by the scope object anyway.
 }
 
 void Foo::test3() {
@@ -2615,7 +2616,7 @@
   if (c) {
 rlock.Release();
   }
-  // no warning on join point for managed lock.
+  // No warning on join point because the lock will be released by the scope object anyway.
   rlock.Release();  // expected-warning {{releasing mutex 'mu_' that was not held}}
 }
 
@@ -2659,6 +2660,7 @@
 
 Mutex mu;
 int x GUARDED_BY(mu);
+bool b;
 
 void print(int);
 
@@ -2740,6 +2742,23 @@
   scope.Lock(); // expected-warning {{acquiring mutex 'mu' that is already held}}
 }
 
+void lockJoin() {
+  RelockableMutexLock scope(&mu, DeferTraits{});
+  if (b)
+scope.Lock();
+  // No warning on join point because the lock will be released by the scope object anyway.
+  x = 2; // expected-warning {{writing variable 'x' requires holding mutex 'mu' exclusively}}
+}
+
+void unlockJoin() {
+  RelockableMutexLock scope(&mu, DeferTraits{});
+  scope.Lock();
+  if (b)
+scope.Unlock();
+  // No warning on join point because the lock will be released by the scope object anyway.
+  x = 2; // expected-warning {{writing variable 'x' requires holding mutex 'mu' exclusively}}
+}
+
 void directUnlock() {
   RelockableExclusiveMutexLock scope(&mu);
   mu.Unlock();
@@ -2871,10 +2890,9 @@
 
 void join() EXCLUSIVE_LOCKS_REQUIRED(mu) {
   MutexUnlock scope(&mu);
-  if (c) {
-scope.Lock(); // expected-note{{mutex acquired here}}
-  }
-  // expected-warning@+1{{mutex 'mu' is not held on every path through here}}
+  if (c)
+scope.Lock();
+  // No warning on join point because the lock will be released by the scope object anyway.
   scope.Lock();
 }
 
Index: clang/lib/Analysis/ThreadSafety.cpp
=

[PATCH] D98855: [OpenCL] Support template parameters for as_type

2021-03-18 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia accepted this revision.
Anastasia added inline comments.
This revision is now accepted and ready to land.



Comment at: clang/test/SemaOpenCLCXX/template-astype.cl:5
+auto templated_astype(T x) {
+  return as_int2(x);
+  // expected-error@-1{{invalid reinterpretation: sizes of 'int2' (vector of 2 
'int' values) and '__private int' must match}}

could we also add another template with use of `__builtin_astype` directly?

In case we change as_type implementation one day the clang builtin will still 
be tested too. :)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98855

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


[PATCH] D98824: [Tooling] Handle compilation databases containing commands with double dashes

2021-03-18 Thread Janusz Nykiel via Phabricator via cfe-commits
jnykiel updated this revision to Diff 331570.
jnykiel retitled this revision from "[Tooling] Handle compilation databases 
with clang-cl commands generated by CMake 3.19+" to "[Tooling] Handle 
compilation databases containing commands with double dashes".
jnykiel edited the summary of this revision.
jnykiel added a comment.

I have addressed some of your comments. The second revision is good enough to 
get the tests to pass - the `injectResourceDir` change was necessary for the 
one clang-tidy test that started failing after leaving the `--` in. I don't 
feel familiar enough with clangd specifically to attempt comprehensive fixes 
there. The clangd issue report specifically mentions `-fsyntax-only` and 
`-resource-dir` as well - so while not comprehensive, the fix may be good for 
that too.


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

https://reviews.llvm.org/D98824

Files:
  clang/lib/Tooling/ArgumentsAdjusters.cpp
  clang/lib/Tooling/InterpolatingCompilationDatabase.cpp
  clang/lib/Tooling/Tooling.cpp
  clang/unittests/Tooling/CompilationDatabaseTest.cpp

Index: clang/unittests/Tooling/CompilationDatabaseTest.cpp
===
--- clang/unittests/Tooling/CompilationDatabaseTest.cpp
+++ clang/unittests/Tooling/CompilationDatabaseTest.cpp
@@ -812,6 +812,16 @@
   EXPECT_EQ(getCommand("dir/bar.cpp"), "clang -D dir/foo.cpp -Wall");
 }
 
+TEST_F(InterpolateTest, StripDoubleDash) {
+  add("dir/foo.cpp", "-o foo.o -std=c++14 -Wall -- dir/foo.cpp");
+  // input file and output option are removed
+  // -Wall flag isn't
+  // -std option gets re-added as the last argument before --
+  // new input file gets added after --
+  EXPECT_EQ(getCommand("dir/bar.cpp"),
+"clang -D dir/foo.cpp -Wall -std=c++14 --");
+}
+
 TEST_F(InterpolateTest, Case) {
   add("FOO/BAR/BAZ/SHOUT.cc");
   add("foo/bar/baz/quiet.cc");
Index: clang/lib/Tooling/Tooling.cpp
===
--- clang/lib/Tooling/Tooling.cpp
+++ clang/lib/Tooling/Tooling.cpp
@@ -435,13 +435,18 @@
 static void injectResourceDir(CommandLineArguments &Args, const char *Argv0,
   void *MainAddr) {
   // Allow users to override the resource dir.
-  for (StringRef Arg : Args)
+  for (StringRef Arg : Args) {
+if (Arg == "--")
+  break;
 if (Arg.startswith("-resource-dir"))
   return;
+  }
 
   // If there's no override in place add our resource dir.
-  Args.push_back("-resource-dir=" +
- CompilerInvocation::GetResourcesPath(Argv0, MainAddr));
+  std::string resourceDir = "-resource-dir=";
+  resourceDir.append(CompilerInvocation::GetResourcesPath(Argv0, MainAddr));
+  getInsertArgumentAdjuster(CommandLineArguments(1, resourceDir),
+ArgumentInsertPosition::END)(Args, "");
 }
 
 int ClangTool::run(ToolAction *Action) {
Index: clang/lib/Tooling/InterpolatingCompilationDatabase.cpp
===
--- clang/lib/Tooling/InterpolatingCompilationDatabase.cpp
+++ clang/lib/Tooling/InterpolatingCompilationDatabase.cpp
@@ -132,6 +132,8 @@
   LangStandard::Kind Std = LangStandard::lang_unspecified;
   // Whether the command line is for the cl-compatible driver.
   bool ClangCLMode;
+  // Whether to insert a double dash before the input file(s).
+  bool InsertDoubleDash = false;
 
   TransferableCommand(CompileCommand C)
   : Cmd(std::move(C)), Type(guessType(Cmd.Filename)),
@@ -177,6 +179,13 @@
Opt.matches(OPT__SLASH_Fo
 continue;
 
+  // ...including when the inputs are passed after --.
+  // If that is the case, record it.
+  if (Opt.matches(OPT__DASH_DASH)) {
+InsertDoubleDash = true;
+break;
+  }
+
   // Strip -x, but record the overridden language.
   if (const auto GivenType = tryParseTypeArg(*Arg)) {
 Type = *GivenType;
@@ -235,6 +244,8 @@
   llvm::Twine(ClangCLMode ? "/std:" : "-std=") +
   LangStandard::getLangStandardForKind(Std).getName()).str());
 }
+if (InsertDoubleDash)
+  Result.CommandLine.push_back("--");
 Result.CommandLine.push_back(std::string(Filename));
 return Result;
   }
Index: clang/lib/Tooling/ArgumentsAdjusters.cpp
===
--- clang/lib/Tooling/ArgumentsAdjusters.cpp
+++ clang/lib/Tooling/ArgumentsAdjusters.cpp
@@ -41,8 +41,13 @@
 "-save-temps",
 "--save-temps",
 };
-for (size_t i = 0, e = Args.size(); i < e; ++i) {
+size_t i = 0;
+for (size_t e = Args.size(); i < e; ++i) {
   StringRef Arg = Args[i];
+
+  if (Arg == "--")
+break;
+
   // Skip output commands.
   if (llvm::any_of(OutputCommands, [&Arg](llvm::StringRef OutputCommand) {
 return Arg.startswith(OutputCommand);
@@ -63,6 +68,8 @@
 }
 if (!HasSyntaxOnly)
 

[PATCH] D98873: Document -fcrash-diagnostics-dir

2021-03-18 Thread Paul Robinson via Phabricator via cfe-commits
probinson created this revision.
probinson added a reviewer: hans.
Herald added subscribers: jansvoboda11, dang.
probinson requested review of this revision.
Herald added a project: clang.

This was added in LLVM 7.0 but without help text or other docs.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D98873

Files:
  clang/docs/UsersManual.rst
  clang/include/clang/Driver/Options.td


Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -1277,7 +1277,9 @@
 Group;
 def fno_crash_diagnostics : Flag<["-"], "fno-crash-diagnostics">, 
Group, Flags<[NoArgumentUnused, CoreOption]>,
   HelpText<"Disable auto-generation of preprocessed source files and a script 
for reproduction during a clang crash">;
-def fcrash_diagnostics_dir : Joined<["-"], "fcrash-diagnostics-dir=">, 
Group, Flags<[NoArgumentUnused, CoreOption]>;
+def fcrash_diagnostics_dir : Joined<["-"], "fcrash-diagnostics-dir=">,
+  Group, Flags<[NoArgumentUnused, CoreOption]>,
+  HelpText<"Put crash-report files in ">, MetaVarName<"">;
 def fcreate_profile : Flag<["-"], "fcreate-profile">, Group;
 defm cxx_exceptions: BoolFOption<"cxx-exceptions",
   LangOpts<"CXXExceptions">, DefaultFalse,
Index: clang/docs/UsersManual.rst
===
--- clang/docs/UsersManual.rst
+++ clang/docs/UsersManual.rst
@@ -674,6 +674,11 @@
 The -fno-crash-diagnostics flag can be helpful for speeding the process
 of generating a delta reduced test case.
 
+.. option:: -fcrash-diagnostics-dir=
+
+  Specify where to write the crash diagnostics files; defaults to the
+  usual location for temporary files.
+
 Clang is also capable of generating preprocessed source file(s) and associated
 run script(s) even without a crash. This is specially useful when trying to
 generate a reproducer for warnings or errors while using modules.
@@ -3629,6 +3634,8 @@
   -fcomplete-member-pointers
   Require member pointer base types to be complete 
if they would be significant under the Microsoft ABI
   -fcoverage-mapping  Generate coverage mapping to enable code 
coverage analysis
+  -fcrash-diagnostics-dir=
+  Put crash-report files in 
   -fdebug-macro   Emit macro debug information
   -fdelayed-template-parsing
   Parse templated function definitions at the end 
of the translation unit


Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -1277,7 +1277,9 @@
 Group;
 def fno_crash_diagnostics : Flag<["-"], "fno-crash-diagnostics">, Group, Flags<[NoArgumentUnused, CoreOption]>,
   HelpText<"Disable auto-generation of preprocessed source files and a script for reproduction during a clang crash">;
-def fcrash_diagnostics_dir : Joined<["-"], "fcrash-diagnostics-dir=">, Group, Flags<[NoArgumentUnused, CoreOption]>;
+def fcrash_diagnostics_dir : Joined<["-"], "fcrash-diagnostics-dir=">,
+  Group, Flags<[NoArgumentUnused, CoreOption]>,
+  HelpText<"Put crash-report files in ">, MetaVarName<"">;
 def fcreate_profile : Flag<["-"], "fcreate-profile">, Group;
 defm cxx_exceptions: BoolFOption<"cxx-exceptions",
   LangOpts<"CXXExceptions">, DefaultFalse,
Index: clang/docs/UsersManual.rst
===
--- clang/docs/UsersManual.rst
+++ clang/docs/UsersManual.rst
@@ -674,6 +674,11 @@
 The -fno-crash-diagnostics flag can be helpful for speeding the process
 of generating a delta reduced test case.
 
+.. option:: -fcrash-diagnostics-dir=
+
+  Specify where to write the crash diagnostics files; defaults to the
+  usual location for temporary files.
+
 Clang is also capable of generating preprocessed source file(s) and associated
 run script(s) even without a crash. This is specially useful when trying to
 generate a reproducer for warnings or errors while using modules.
@@ -3629,6 +3634,8 @@
   -fcomplete-member-pointers
   Require member pointer base types to be complete if they would be significant under the Microsoft ABI
   -fcoverage-mapping  Generate coverage mapping to enable code coverage analysis
+  -fcrash-diagnostics-dir=
+  Put crash-report files in 
   -fdebug-macro   Emit macro debug information
   -fdelayed-template-parsing
   Parse templated function definitions at the end of the translation unit
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D98862: [clang] Update unit-tests after linker selection fix for *-msvc targets

2021-03-18 Thread Maxim Kuvyrkov via Phabricator via cfe-commits
maxim-kuvyrkov added a comment.

@SureYeaah , does this fix your internal buildbot?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98862

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


[PATCH] D98113: [Driver] Also search FilePaths for compiler-rt before falling back

2021-03-18 Thread Luís Marques via Phabricator via cfe-commits
luismarques added a comment.

I just looked at this again and I don't have the full context in my mind right 
now but won't the test just exercise the BareMetal toolchain and not your 
changes?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98113

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


[PATCH] D75041: [clang-tidy] Extend 'bugprone-easily-swappable-parameters' with mixability because of implicit conversions

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



Comment at: 
clang-tools-extra/clang-tidy/bugprone/EasilySwappableParametersCheck.cpp:377
+
+  bool indicatesMixability() const { return Flags > MIX_None; }
+

Should this be `MIX_WorkaroundDisableCanonicalEquivalence` instead of 
`MIX_None`?



Comment at: 
clang-tools-extra/clang-tidy/bugprone/EasilySwappableParametersCheck.cpp:486-487
+static MixData
+approximateImplicitConversion(const TheCheck &Check, const QualType LType,
+  const QualType RType, const ASTContext &Ctx,
+  ImplicitConversionModellingMode ImplicitMode);





Comment at: 
clang-tools-extra/clang-tidy/bugprone/EasilySwappableParametersCheck.cpp:500-501
+static MixData
+calculateMixability(const TheCheck &Check, const QualType LType,
+const QualType RType, const ASTContext &Ctx,
+ImplicitConversionModellingMode ImplicitMode) {





Comment at: 
clang-tools-extra/clang-tidy/bugprone/EasilySwappableParametersCheck.cpp:520
   // user to understand.
-  if (isa(LType.getTypePtr())) {
-LLVM_DEBUG(llvm::dbgs() << "--- calculateMixability. LHS is ParenType.\n");
+  if (isa(LType.getTypePtr())) {
+LLVM_DEBUG(llvm::dbgs()

What about a `DecayedType`?



Comment at: 
clang-tools-extra/clang-tidy/bugprone/EasilySwappableParametersCheck.cpp:657-667
+  // Certain kinds unfortunately need to be side-stepped for canonical type
+  // matching.
+  if (LType->getAs() || RType->getAs()) {
+// Unfortunately, the canonical type of a function pointer becomes the
+// same even if exactly one is "noexcept" and the other isn't, making us
+// give a false positive report irrespective of implicit conversions.
+LLVM_DEBUG(llvm::dbgs()

whisperity wrote:
> @aaron.ballman Getting ahead of the curve here. I understand this is ugly. 
> Unfortunately, no matter how much I read the standard, I don't get anything 
> of "canonical type" mentioned, it seems to me this concept is something 
> inherent to the model of Clang.
> 
> Basically why this is here: imagine a `void (*)() noexcept` and a `void 
> (*)()`. One's `noexcept`, the other isn't. Inside the AST, this is a 
> `ParenType` of a `PointerType` to a `FunctionProtoType`. There exists a 
> //one-way// implicit conversion from the `noexcept` to the non-noexcept 
> ("noexceptness can be discarded", similarly to how "constness can be gained")
> Unfortunately, because this is a one-way implicit conversion, it won't return 
> on the code path earlier for implicit conversions.
> 
> Now because of this, the recursive descent in our code will reach the point 
> when the two innermost `FunctionProtoType`s are in our hands. As a fallback 
> case, we simply ask Clang "Hey, do //you// think these two are the same?". 
> And for some weird reason, Clang will say "Yes."... While one of them is a 
> `noexcept` function and the other one isn't.
> 
> I do not know the innards of the AST well enough to even have a glimpse of 
> whether or not this is a bug. So that's the reason why I went ahead and 
> implemented this side-stepping logic. Basically, as the comment says, it'lll 
> **force** the information of "No matter what you do, do NOT consider these 
> mixable!" back up the recursion chain, and handle it appropriately later.
> Unfortunately, no matter how much I read the standard, I don't get anything 
> of "canonical type" mentioned, it seems to me this concept is something 
> inherent to the model of Clang.

It is more of a Clang-centric concept. Basically, a canonical type is one 
that's had all of the typedefs stripped off it.

> Now because of this, the recursive descent in our code will reach the point 
> when the two innermost FunctionProtoTypes are in our hands. As a fallback 
> case, we simply ask Clang "Hey, do you think these two are the same?". And 
> for some weird reason, Clang will say "Yes."... While one of them is a 
> noexcept function and the other one isn't.

I think a confounding factor in this area is that `noexcept` did not used to be 
part of the function type until one day it started being a part of the function 
type. So my guess is that this is fallout from this sort of thing: 
https://godbolt.org/z/EYfj8z (which may be worth keeping in mind when working 
on the check).



Comment at: 
clang-tools-extra/clang-tidy/bugprone/EasilySwappableParametersCheck.cpp:758
+approximateStandardConversionSequence(const TheCheck &Check,
+  const QualType From, const QualType To,
+  const ASTContext &Ctx) {




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

https://reviews.llvm.org/D75041

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
h

[PATCH] D98113: [Driver] Also search FilePaths for compiler-rt before falling back

2021-03-18 Thread Jessica Clarke via Phabricator via cfe-commits
jrtc27 added a comment.

In D98113#2634758 , @luismarques wrote:

> I just looked at this again and I don't have the full context in my mind 
> right now but won't the test just exercise the BareMetal toolchain and not 
> your changes?

I've since lost my recollection of all the details, but 
BareMetal::AddLinkRuntimeLib is hard-coding -lclang_rt.builtins-$ARCH so I 
think we already do search in the sysroot for the library if it doesn't exist 
in the resources directory. What this tests is -print-libgcc-file-name 
(implemented in the common Driver.cpp) which is the thing that is currently 
"broken" for bare-metal toolchains as it will currently neglect to search the 
sysroot as the linker would, since it calls getCompilerRT directly (which 
BareMetal doesn't override).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98113

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


[PATCH] D98745: [clang] Add fixit for Wreorder-ctor

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

Fix formatting issues


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98745

Files:
  clang/test/SemaCXX/constructor-initializer.cpp
  clang/test/SemaCXX/warn-reorder-ctor-initialization.cpp


Index: clang/test/SemaCXX/warn-reorder-ctor-initialization.cpp
===
--- clang/test/SemaCXX/warn-reorder-ctor-initialization.cpp
+++ clang/test/SemaCXX/warn-reorder-ctor-initialization.cpp
@@ -5,14 +5,13 @@
 struct BB1 {};
 
 class complex : public BB, BB1 { 
-public: 
+public:
   complex()
-: s2(1), // expected-warning {{some initializers aren't given in the 
correct order}} expected-note {{field 's2' will be initialized after field 
's1'}}
-  s1(1),
-  s3(3), // expected-note {{field 's3' will be initialized after base 
'BB1'}} 
-  BB1(), // expected-note {{base class 'BB1' will be initialized after 
base 'BB'}}
-  BB()
-  {}
+  : s2(1), // expected-warning {{some initializers aren't given in the 
correct order}} expected-note {{field 's2' will be initialized after field 
's1'}}
+s1(1),
+s3(3), // expected-note {{field 's3' will be initialized after base 
'BB1'}}
+BB1(), // expected-note {{base class 'BB1' will be initialized after 
base 'BB'}}
+BB() {}
   int s1;
   int s2;
   int s3;
Index: clang/test/SemaCXX/constructor-initializer.cpp
===
--- clang/test/SemaCXX/constructor-initializer.cpp
+++ clang/test/SemaCXX/constructor-initializer.cpp
@@ -94,11 +94,11 @@
   Current() : Derived(1), ::Derived(), // expected-warning {{some initializers 
aren't given in the correct order}} \
// expected-note {{field 'Derived' will 
be initialized after base '::Derived'}} \
// expected-note {{base class 
'::Derived' will be initialized after base 'Derived::V'}}
-  ::Derived::Base(), // expected-error {{type 
'::Derived::Base' is not a direct or virtual base of 'Current'}}
-   Derived::Base1(), // expected-error {{type 
'Derived::Base1' is not a direct or virtual base of 'Current'}}
-   Derived::V(),
-   ::NonExisting(), // expected-error {{member 
initializer 'NonExisting' does not name a non-static data member or}}
-   INT::NonExisting()  {} // expected-error {{'INT' 
(aka 'int') is not a class, namespace, or enumeration}} \
+  ::Derived::Base(),   // expected-error {{type 
'::Derived::Base' is not a direct or virtual base of 'Current'}}
+  Derived::Base1(),// expected-error {{type 
'Derived::Base1' is not a direct or virtual base of 'Current'}}
+  Derived::V(),
+  ::NonExisting(),  // expected-error {{member initializer 
'NonExisting' does not name a non-static data member or}}
+  INT::NonExisting() {} // expected-error {{'INT' (aka 'int') is 
not a class, namespace, or enumeration}} \
   // expected-error {{member 
initializer 'NonExisting' does not name a non-static data member or}}
 };
 


Index: clang/test/SemaCXX/warn-reorder-ctor-initialization.cpp
===
--- clang/test/SemaCXX/warn-reorder-ctor-initialization.cpp
+++ clang/test/SemaCXX/warn-reorder-ctor-initialization.cpp
@@ -5,14 +5,13 @@
 struct BB1 {};
 
 class complex : public BB, BB1 { 
-public: 
+public:
   complex()
-: s2(1), // expected-warning {{some initializers aren't given in the correct order}} expected-note {{field 's2' will be initialized after field 's1'}}
-  s1(1),
-  s3(3), // expected-note {{field 's3' will be initialized after base 'BB1'}} 
-  BB1(), // expected-note {{base class 'BB1' will be initialized after base 'BB'}}
-  BB()
-  {}
+  : s2(1), // expected-warning {{some initializers aren't given in the correct order}} expected-note {{field 's2' will be initialized after field 's1'}}
+s1(1),
+s3(3), // expected-note {{field 's3' will be initialized after base 'BB1'}}
+BB1(), // expected-note {{base class 'BB1' will be initialized after base 'BB'}}
+BB() {}
   int s1;
   int s2;
   int s3;
Index: clang/test/SemaCXX/constructor-initializer.cpp
===
--- clang/test/SemaCXX/constructor-initializer.cpp
+++ clang/test/SemaCXX/constructor-initializer.cpp
@@ -94,11 +94,11 @@
   Current() : Derived(1), ::Derived(), // expected-warning {{some initializers aren't given in the correct order}} \
// expected-note {{field 'Derived' will be initialized after base '::Derived'}} \

[PATCH] D98745: [clang] Add fixit for Wreorder-ctor

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

Arc got confused


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98745

Files:
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/Sema/SemaDeclCXX.cpp
  clang/test/FixIt/fixit-cxx-init-order.cpp
  clang/test/SemaCXX/constructor-initializer.cpp
  clang/test/SemaCXX/warn-reorder-ctor-initialization.cpp

Index: clang/test/SemaCXX/warn-reorder-ctor-initialization.cpp
===
--- clang/test/SemaCXX/warn-reorder-ctor-initialization.cpp
+++ clang/test/SemaCXX/warn-reorder-ctor-initialization.cpp
@@ -5,14 +5,13 @@
 struct BB1 {};
 
 class complex : public BB, BB1 { 
-public: 
+public:
   complex()
-: s2(1), // expected-warning {{field 's2' will be initialized after field 's1'}}
-  s1(1),
-  s3(3), // expected-warning {{field 's3' will be initialized after base 'BB1'}} 
-  BB1(), // expected-warning {{base class 'BB1' will be initialized after base 'BB'}}
-  BB()
-  {}
+  : s2(1), // expected-warning {{some initializers aren't given in the correct order}} expected-note {{field 's2' will be initialized after field 's1'}}
+s1(1),
+s3(3), // expected-note {{field 's3' will be initialized after base 'BB1'}}
+BB1(), // expected-note {{base class 'BB1' will be initialized after base 'BB'}}
+BB() {}
   int s1;
   int s2;
   int s3;
Index: clang/test/SemaCXX/constructor-initializer.cpp
===
--- clang/test/SemaCXX/constructor-initializer.cpp
+++ clang/test/SemaCXX/constructor-initializer.cpp
@@ -91,13 +91,14 @@
 
 struct Current : Derived {
   int Derived;
-  Current() : Derived(1), ::Derived(), // expected-warning {{field 'Derived' will be initialized after base '::Derived'}} \
-   // expected-warning {{base class '::Derived' will be initialized after base 'Derived::V'}}
-  ::Derived::Base(), // expected-error {{type '::Derived::Base' is not a direct or virtual base of 'Current'}}
-   Derived::Base1(), // expected-error {{type 'Derived::Base1' is not a direct or virtual base of 'Current'}}
-   Derived::V(),
-   ::NonExisting(), // expected-error {{member initializer 'NonExisting' does not name a non-static data member or}}
-   INT::NonExisting()  {} // expected-error {{'INT' (aka 'int') is not a class, namespace, or enumeration}} \
+  Current() : Derived(1), ::Derived(), // expected-warning {{some initializers aren't given in the correct order}} \
+   // expected-note {{field 'Derived' will be initialized after base '::Derived'}} \
+   // expected-note {{base class '::Derived' will be initialized after base 'Derived::V'}}
+  ::Derived::Base(),   // expected-error {{type '::Derived::Base' is not a direct or virtual base of 'Current'}}
+  Derived::Base1(),// expected-error {{type 'Derived::Base1' is not a direct or virtual base of 'Current'}}
+  Derived::V(),
+  ::NonExisting(),  // expected-error {{member initializer 'NonExisting' does not name a non-static data member or}}
+  INT::NonExisting() {} // expected-error {{'INT' (aka 'int') is not a class, namespace, or enumeration}} \
   // expected-error {{member initializer 'NonExisting' does not name a non-static data member or}}
 };
 
Index: clang/test/FixIt/fixit-cxx-init-order.cpp
===
--- /dev/null
+++ clang/test/FixIt/fixit-cxx-init-order.cpp
@@ -0,0 +1,22 @@
+// Due to the fix having multiple edits we can't use
+// '-fdiagnostics-parseable-fixits' to determine if fixes are correct. However,
+// running fixit recompile with 'Werror' should fail if the fixes are invalid.
+
+// RUN: %clang_cc1 %s -Werror=reorder-ctor -fixit-recompile -fixit-to-temporary
+// RUN: %clang_cc1 %s -Wreorder-ctor -verify -verify-ignore-unexpected=note
+
+struct Foo {
+  int A, B, C;
+
+  Foo() : A(1), B(3), C(2) {}
+  Foo(int) : A(1), C(2), B(3) {}  // expected-warning {{field 'C' will be initialized after field 'B'}}
+  Foo(unsigned) : C(2), B(3), A(1) {} // expected-warning {{some initializers aren't given in the correct order}}
+};
+
+struct Bar : Foo {
+  int D, E, F;
+
+  Bar() : Foo(), D(1), E(2), F(3) {}
+  Bar(int) : D(1), E(2), F(3), Foo(4) {}  // expected-warning {{field 'F' will be initialized after base 'Foo'}}
+  Bar(unsigned) : F(3), E(2), D(1), Foo(4) {} // expected-warning {{some initializers aren't given in the correct order}}
+};
Index: clang/lib/Sema/SemaDeclCXX.cpp

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

2021-03-18 Thread Maxim Kuvyrkov via Phabricator via cfe-commits
maxim-kuvyrkov closed this revision.
maxim-kuvyrkov added a comment.

This is merged to release/12.x branch.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98415

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


[clang] c2f8e15 - [OPENMP51]Support for the 'destroy' clause with interop variable.

2021-03-18 Thread Mike Rice via cfe-commits

Author: Mike Rice
Date: 2021-03-18T09:12:56-07:00
New Revision: c2f8e158f57c173298ac39db8fd44211604ed003

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

LOG: [OPENMP51]Support for the 'destroy' clause with interop variable.

Added basic parsing/sema/serialization support to extend the
existing 'destroy' clause for use with the 'interop' directive.

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

Added: 


Modified: 
clang/include/clang/AST/OpenMPClause.h
clang/include/clang/AST/RecursiveASTVisitor.h
clang/include/clang/Sema/Sema.h
clang/lib/AST/OpenMPClause.cpp
clang/lib/AST/StmtProfile.cpp
clang/lib/Parse/ParseOpenMP.cpp
clang/lib/Sema/SemaOpenMP.cpp
clang/lib/Sema/TreeTransform.h
clang/lib/Serialization/ASTReader.cpp
clang/lib/Serialization/ASTWriter.cpp
clang/test/OpenMP/interop_ast_print.cpp
clang/test/OpenMP/interop_messages.cpp
clang/tools/libclang/CIndex.cpp
llvm/include/llvm/Frontend/OpenMP/OMP.td

Removed: 




diff  --git a/clang/include/clang/AST/OpenMPClause.h 
b/clang/include/clang/AST/OpenMPClause.h
index b342ffb93256..f71eb15feea2 100644
--- a/clang/include/clang/AST/OpenMPClause.h
+++ b/clang/include/clang/AST/OpenMPClause.h
@@ -7561,14 +7561,49 @@ class OMPUseClause final : public OMPClause {
 };
 
 /// This represents 'destroy' clause in the '#pragma omp depobj'
-/// directive.
+/// directive or the '#pragma omp interop' directive..
 ///
 /// \code
 /// #pragma omp depobj(a) destroy
+/// #pragma omp interop destroy(obj)
 /// \endcode
-/// In this example directive '#pragma omp depobj' has 'destroy' clause.
+/// In these examples directive '#pragma omp depobj' and '#pragma omp interop'
+/// have a 'destroy' clause. The 'interop' directive includes an object.
 class OMPDestroyClause final : public OMPClause {
+  friend class OMPClauseReader;
+
+  /// Location of '('.
+  SourceLocation LParenLoc;
+
+  /// Location of interop variable.
+  SourceLocation VarLoc;
+
+  /// The interop variable.
+  Stmt *InteropVar = nullptr;
+
+  /// Set the interop variable.
+  void setInteropVar(Expr *E) { InteropVar = E; }
+
+  /// Sets the location of '('.
+  void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; }
+
+  /// Sets the location of the interop variable.
+  void setVarLoc(SourceLocation Loc) { VarLoc = Loc; }
+
 public:
+  /// Build 'destroy' clause with an interop variable expression \a InteropVar.
+  ///
+  /// \param InteropVar The interop variable.
+  /// \param StartLoc Starting location of the clause.
+  /// \param LParenLoc Location of '('.
+  /// \param VarLoc Location of the interop variable.
+  /// \param EndLoc Ending location of the clause.
+  OMPDestroyClause(Expr *InteropVar, SourceLocation StartLoc,
+   SourceLocation LParenLoc, SourceLocation VarLoc,
+   SourceLocation EndLoc)
+  : OMPClause(llvm::omp::OMPC_destroy, StartLoc, EndLoc),
+LParenLoc(LParenLoc), VarLoc(VarLoc), InteropVar(InteropVar) {}
+
   /// Build 'destroy' clause.
   ///
   /// \param StartLoc Starting location of the clause.
@@ -7581,11 +7616,24 @@ class OMPDestroyClause final : public OMPClause {
   : OMPClause(llvm::omp::OMPC_destroy, SourceLocation(), SourceLocation()) 
{
   }
 
+  /// Returns the location of '('.
+  SourceLocation getLParenLoc() const { return LParenLoc; }
+
+  /// Returns the location of the interop variable.
+  SourceLocation getVarLoc() const { return VarLoc; }
+
+  /// Returns the interop variable.
+  Expr *getInteropVar() const { return cast_or_null(InteropVar); }
+
   child_range children() {
+if (InteropVar)
+  return child_range(&InteropVar, &InteropVar + 1);
 return child_range(child_iterator(), child_iterator());
   }
 
   const_child_range children() const {
+if (InteropVar)
+  return const_child_range(&InteropVar, &InteropVar + 1);
 return const_child_range(const_child_iterator(), const_child_iterator());
   }
 

diff  --git a/clang/include/clang/AST/RecursiveASTVisitor.h 
b/clang/include/clang/AST/RecursiveASTVisitor.h
index 4a7c234e374b..256f73338bd2 100644
--- a/clang/include/clang/AST/RecursiveASTVisitor.h
+++ b/clang/include/clang/AST/RecursiveASTVisitor.h
@@ -3210,7 +3210,8 @@ bool 
RecursiveASTVisitor::VisitOMPUseClause(OMPUseClause *C) {
 }
 
 template 
-bool RecursiveASTVisitor::VisitOMPDestroyClause(OMPDestroyClause *) {
+bool RecursiveASTVisitor::VisitOMPDestroyClause(OMPDestroyClause *C) {
+  TRY_TO(TraverseStmt(C->getInteropVar()));
   return true;
 }
 

diff  --git a/clang/include/clang/Sema/Sema.h b/clang/include/clang/Sema/Sema.h
index 978c5de57646..b144587650eb 100644
--- a/clang/include/clang/Sema/Sema.h
+++ b/clang/include/clang/Sema/Sema.h
@@ -10998,8 +10998,11 @@ class Sema final {

[PATCH] D98834: [OPENMP51]Support for the 'destroy' clause with interop variable

2021-03-18 Thread Mike Rice via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGc2f8e158f57c: [OPENMP51]Support for the 'destroy' 
clause with interop variable. (authored by mikerice).
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98834

Files:
  clang/include/clang/AST/OpenMPClause.h
  clang/include/clang/AST/RecursiveASTVisitor.h
  clang/include/clang/Sema/Sema.h
  clang/lib/AST/OpenMPClause.cpp
  clang/lib/AST/StmtProfile.cpp
  clang/lib/Parse/ParseOpenMP.cpp
  clang/lib/Sema/SemaOpenMP.cpp
  clang/lib/Sema/TreeTransform.h
  clang/lib/Serialization/ASTReader.cpp
  clang/lib/Serialization/ASTWriter.cpp
  clang/test/OpenMP/interop_ast_print.cpp
  clang/test/OpenMP/interop_messages.cpp
  clang/tools/libclang/CIndex.cpp
  llvm/include/llvm/Frontend/OpenMP/OMP.td

Index: llvm/include/llvm/Frontend/OpenMP/OMP.td
===
--- llvm/include/llvm/Frontend/OpenMP/OMP.td
+++ llvm/include/llvm/Frontend/OpenMP/OMP.td
@@ -1650,6 +1650,7 @@
   let allowedClauses = [
 VersionedClause,
 VersionedClause,
+VersionedClause,
 VersionedClause,
 VersionedClause,
 VersionedClause,
Index: clang/tools/libclang/CIndex.cpp
===
--- clang/tools/libclang/CIndex.cpp
+++ clang/tools/libclang/CIndex.cpp
@@ -2286,7 +2286,10 @@
   Visitor->AddStmt(C->getInteropVar());
 }
 
-void OMPClauseEnqueue::VisitOMPDestroyClause(const OMPDestroyClause *) {}
+void OMPClauseEnqueue::VisitOMPDestroyClause(const OMPDestroyClause *C) {
+  if (C->getInteropVar())
+Visitor->AddStmt(C->getInteropVar());
+}
 
 void OMPClauseEnqueue::VisitOMPUnifiedAddressClause(
 const OMPUnifiedAddressClause *) {}
Index: clang/test/OpenMP/interop_messages.cpp
===
--- clang/test/OpenMP/interop_messages.cpp
+++ clang/test/OpenMP/interop_messages.cpp
@@ -17,6 +17,9 @@
   //expected-error@+1 {{use of undeclared identifier 'NoDeclVar'}}
   #pragma omp interop use(NoDeclVar) use(Another)
 
+  //expected-error@+1 {{use of undeclared identifier 'NoDeclVar'}}
+  #pragma omp interop destroy(NoDeclVar) destroy(Another)
+
   //expected-error@+2 {{expected interop type: 'target' and/or 'targetsync'}}
   //expected-error@+1 {{expected expression}}
   #pragma omp interop init(InteropVar) init(target:Another)
@@ -38,6 +41,9 @@
   //expected-error@+1 {{interop variable must be of type 'omp_interop_t'}}
   #pragma omp interop use(IntVar) use(Another)
 
+  //expected-error@+1 {{interop variable must be of type 'omp_interop_t'}}
+  #pragma omp interop destroy(IntVar) destroy(Another)
+
   //expected-error@+1 {{interop variable must be of type 'omp_interop_t'}}
   #pragma omp interop init(prefer_type(1,"sycl",3),target:SVar) \
   init(target:Another)
@@ -45,6 +51,9 @@
   //expected-error@+1 {{interop variable must be of type 'omp_interop_t'}}
   #pragma omp interop use(SVar) use(Another)
 
+  //expected-error@+1 {{interop variable must be of type 'omp_interop_t'}}
+  #pragma omp interop destroy(SVar) destroy(Another)
+
   int a, b;
   //expected-error@+1 {{expected variable of type 'omp_interop_t'}}
   #pragma omp interop init(target:a+b) init(target:Another)
@@ -52,10 +61,16 @@
   //expected-error@+1 {{expected variable of type 'omp_interop_t'}}
   #pragma omp interop use(a+b) use(Another)
 
+  //expected-error@+1 {{expected variable of type 'omp_interop_t'}}
+  #pragma omp interop destroy(a+b) destroy(Another)
+
   const omp_interop_t C = (omp_interop_t)5;
   //expected-error@+1 {{expected non-const variable of type 'omp_interop_t'}}
   #pragma omp interop init(target:C) init(target:Another)
 
+  //expected-error@+1 {{expected non-const variable of type 'omp_interop_t'}}
+  #pragma omp interop destroy(C) destroy(Another)
+
   //expected-error@+1 {{prefer_list item must be a string literal or constant integral expression}}
   #pragma omp interop init(prefer_type(1.0),target:InteropVar) \
   init(target:Another)
@@ -79,9 +94,18 @@
   //expected-error@+1 {{interop variable 'InteropVar' used in multiple action clauses}}
   #pragma omp interop use(InteropVar) use(InteropVar)
 
+  //expected-error@+1 {{interop variable 'InteropVar' used in multiple action clauses}}
+  #pragma omp interop destroy(InteropVar) destroy(InteropVar)
+
   //expected-error@+1 {{interop variable 'InteropVar' used in multiple action clauses}}
   #pragma omp interop init(target:InteropVar) use(InteropVar)
 
+  //expected-error@+1 {{interop variable 'InteropVar' used in multiple action clauses}}
+  #pragma omp interop init(target:InteropVar) destroy(InteropVar)
+
+  //expected-error@+1 {{interop variable 'InteropVar' used in multiple action clauses}}
+  #pragma omp interop use(InteropVar) destroy(InteropVar

[PATCH] D75041: [clang-tidy] Extend 'bugprone-easily-swappable-parameters' with mixability because of implicit conversions

2021-03-18 Thread Whisperity via Phabricator via cfe-commits
whisperity marked 5 inline comments as done.
whisperity added inline comments.



Comment at: 
clang-tools-extra/clang-tidy/bugprone/EasilySwappableParametersCheck.cpp:377
+
+  bool indicatesMixability() const { return Flags > MIX_None; }
+

aaron.ballman wrote:
> Should this be `MIX_WorkaroundDisableCanonicalEquivalence` instead of 
> `MIX_None`?
In this patch I changed the value of `None` to be `2`, and `Workaround...` 
became `1`. So everything above `None` means it's a valid mixability (somehow), 
of course only after `sanitize()` so `Workaround... | CanonicalType` becomes 
`None`.


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

https://reviews.llvm.org/D75041

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


[PATCH] D95460: [flang][driver] Add forced form flags and -ffixed-line-length

2021-03-18 Thread Joachim Protze via Phabricator via cfe-commits
protze.joachim added a comment.

Hi Andrzej,

thanks for the detailed insights. I think I really misunderstood, what the -W 
flags can do here. I also was not up-to-date regarding the state of the flang 
implementation.

I just found, that compiling Spec OMP 2012 with clang-12 worked fine with my 
configuration, but compiling with current HEAD failed. Bisecting brought me to 
this patch.
What my build configuration basically does is to use gfortran to compile 
Fortran source to object files. Then I use clang/clang++ to link all the object 
files, basically:

  gfortran -c foo.f
  clang -lgfortran --gcc-toolchain=$(dirname $(dirname $(which gcc))) foo.o

In the build configuration, I can set FPORTABILITY flags for specific apps, but 
these flags are unfortunately passed to both the compile and the link step. 
Setting FLD to clang used to work, and now it broke.

One of my reasons for linking with clang is to make sure, that as much LLVM 
libraries as possible are linked. Especially, I want to pick up the LLVM 
version of the ThreadSanitizer runtime.

I tried to change my build configuration to use flang. After fixing some of the 
code (removing save keyword from variables, when having a global save), I could 
successfully compile one of the codes. Since flang under the hood uses gfortran 
for linking, this configuration picks up the GNU version of the ThreadSanitizer 
runtime. The GNU runtime is typically built as a dynamic library and comes with 
~30-40% performance penalty. So, even when compiling with flang, I would prefer 
to link using clang.

I have no idea about the compiler internals, but would it be possible to mark 
the flang flags as known to the compiler tool-chain, but not used in case of 
clang? Finally, this would result in a `-Wunused-command-line-argument` warning.

Best
Joachim


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95460

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


[clang] 92ccc6c - Reapply "[NPM][CGSCC] FunctionAnalysisManagerCGSCCProxy: do not clear immutable function passes"

2021-03-18 Thread Mircea Trofin via cfe-commits

Author: Mircea Trofin
Date: 2021-03-18T09:44:34-07:00
New Revision: 92ccc6cb17a4fd1b9506bac51f2eb1a96f4cd345

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

LOG: Reapply "[NPM][CGSCC] FunctionAnalysisManagerCGSCCProxy: do not clear 
immutable function passes"

This reverts commit 11b70b9e3a7458b5b78c30020b56e8ca563a4801.

The bot failure was due to ArgumentPromotion deleting functions
without deleting their analyses. This was separately fixed in 4b1c807.

Added: 


Modified: 
clang/test/CodeGen/thinlto-distributed-newpm.ll
llvm/lib/Analysis/CGSCCPassManager.cpp
llvm/unittests/Analysis/CGSCCPassManagerTest.cpp

Removed: 




diff  --git a/clang/test/CodeGen/thinlto-distributed-newpm.ll 
b/clang/test/CodeGen/thinlto-distributed-newpm.ll
index 867203417754..1e9d5d4d2629 100644
--- a/clang/test/CodeGen/thinlto-distributed-newpm.ll
+++ b/clang/test/CodeGen/thinlto-distributed-newpm.ll
@@ -12,7 +12,7 @@
 ; RUN: %clang -target x86_64-grtev4-linux-gnu \
 ; RUN:   -O2 -fexperimental-new-pass-manager -Xclang -fdebug-pass-manager \
 ; RUN:   -c -fthinlto-index=%t.o.thinlto.bc \
-; RUN:   -o %t.native.o -x ir %t.o 2>&1 | FileCheck 
-check-prefixes=CHECK-O,CHECK-O2 %s --dump-input=fail
+; RUN:   -o %t.native.o -x ir %t.o 2>&1 | FileCheck -check-prefix=CHECK-O %s 
--dump-input=fail
 
 ; RUN: %clang -target x86_64-grtev4-linux-gnu \
 ; RUN:   -O3 -fexperimental-new-pass-manager -Xclang -fdebug-pass-manager \
@@ -70,24 +70,19 @@
 ; CHECK-O: Starting CGSCC pass manager run.
 ; CHECK-O: Running pass: InlinerPass on (main)
 ; CHECK-O: Running pass: PostOrderFunctionAttrsPass on (main)
-; CHECK-O: Clearing all analysis results for: main
+; CHECK-O: Invalidating analysis: DominatorTreeAnalysis on main
+; CHECK-O: Invalidating analysis: BasicAA on main
+; CHECK-O: Invalidating analysis: AAManager on main
 ; CHECK-O3: Running pass: ArgumentPromotionPass on (main)
-; CHECK-O3: Running analysis: TargetIRAnalysis on main
 ; CHECK-O: Starting {{.*}}Function pass manager run.
 ; CHECK-O: Running pass: SROA on main
 ; These next two can appear in any order since they are accessed as parameters
 ; on the same call to SROA::runImpl
 ; CHECK-O-DAG: Running analysis: DominatorTreeAnalysis on main
-; CHECK-O-DAG: Running analysis: AssumptionAnalysis on main
 ; CHECK-O: Running pass: EarlyCSEPass on main
-; CHECK-O: Running analysis: TargetLibraryAnalysis on main
-; CHECK-O2: Running analysis: TargetIRAnalysis on main
 ; CHECK-O: Running analysis: MemorySSAAnalysis on main
 ; CHECK-O: Running analysis: AAManager on main
 ; CHECK-O: Running analysis: BasicAA on main
-; CHECK-O: Running analysis: ScopedNoAliasAA on main
-; CHECK-O: Running analysis: TypeBasedAA on main
-; CHECK-O: Running analysis: OuterAnalysisManagerProxy
 ; CHECK-O: Running pass: SpeculativeExecutionPass on main
 ; CHECK-O: Running pass: JumpThreadingPass on main
 ; CHECK-O: Running analysis: LazyValueAnalysis on main
@@ -96,7 +91,6 @@
 ; CHECK-O: Running pass: SimplifyCFGPass on main
 ; CHECK-O3: Running pass: AggressiveInstCombinePass on main
 ; CHECK-O: Running pass: InstCombinePass on main
-; CHECK-O: Running analysis: OptimizationRemarkEmitterAnalysis on main
 ; CHECK-O: Running pass: LibCallsShrinkWrapPass on main
 ; CHECK-O: Running pass: TailCallElimPass on main
 ; CHECK-O: Running pass: SimplifyCFGPass on main

diff  --git a/llvm/lib/Analysis/CGSCCPassManager.cpp 
b/llvm/lib/Analysis/CGSCCPassManager.cpp
index 9dc62b877ae2..eaaa3d09a7f2 100644
--- a/llvm/lib/Analysis/CGSCCPassManager.cpp
+++ b/llvm/lib/Analysis/CGSCCPassManager.cpp
@@ -720,7 +720,7 @@ bool FunctionAnalysisManagerCGSCCProxy::Result::invalidate(
   auto PAC = PA.getChecker();
   if (!PAC.preserved() && 
!PAC.preservedSet>()) {
 for (LazyCallGraph::Node &N : C)
-  FAM->clear(N.getFunction(), N.getFunction().getName());
+  FAM->invalidate(N.getFunction(), PA);
 
 return false;
   }

diff  --git a/llvm/unittests/Analysis/CGSCCPassManagerTest.cpp 
b/llvm/unittests/Analysis/CGSCCPassManagerTest.cpp
index 59ff97d0fc1a..ceaeaaf83e5d 100644
--- a/llvm/unittests/Analysis/CGSCCPassManagerTest.cpp
+++ b/llvm/unittests/Analysis/CGSCCPassManagerTest.cpp
@@ -1942,5 +1942,30 @@ TEST_F(CGSCCPassManagerTest, 
TestInsertionOfNewNonTrivialCallEdge) {
   ASSERT_TRUE(Ran);
 }
 
+TEST_F(CGSCCPassManagerTest, TestFunctionPassesAreQueriedForInvalidation) {
+  std::unique_ptr M = parseIR("define void @f() { ret void }");
+  CGSCCPassManager CGPM;
+  bool SCCCalled = false;
+  FunctionPassManager FPM;
+  int ImmRuns = 0;
+  FAM.registerPass([&] { return TestImmutableFunctionAnalysis(ImmRuns); });
+  FPM.addPass(RequireAnalysisPass());
+  CGPM.addPass(
+  LambdaSCCPass([&](LazyCallGraph::SCC &C, CGSCCAnalysisManager &AM,
+LazyCallGraph &CG, CGS

[PATCH] D98864: [SystemZ][z/OS] Set maximum value to truncate attribute aligned to for static variables on z/OS target

2021-03-18 Thread Abhina Sree via Phabricator via cfe-commits
abhina.sreeskantharajan accepted this revision.
abhina.sreeskantharajan added a comment.
This revision is now accepted and ready to land.

LGTM


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

https://reviews.llvm.org/D98864

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


[PATCH] D98745: [clang] Add fixit for Wreorder-ctor

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



Comment at: clang/include/clang/Basic/DiagnosticSemaKinds.td:8611
+def warn_some_initializers_out_of_order : Warning<
+  "some initializers aren't given in the correct order">,
+  InGroup, DefaultIgnore;

Hmmm, how about `initializer order does not match the declaration order` or 
something along those lines? The "some" and "in the correct order" feel a bit 
hand-wavy for a warning.



Comment at: clang/lib/Sema/SemaDeclCXX.cpp:5242
+  if (Previous->isAnyMemberInitializer())
+Diag << 0 << Previous->getAnyMember()->getDeclName();
+  else





Comment at: clang/lib/Sema/SemaDeclCXX.cpp:5247
+  if (Current->isAnyMemberInitializer())
+Diag << 0 << Current->getAnyMember()->getDeclName();
+  else





Comment at: clang/lib/Sema/SemaDeclCXX.cpp:5304
+  SmallVector WarnIndexes;
+  // Correllates the index of an initializer in the init-list to the index of
+  // the field/base in the class.




Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98745

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


[PATCH] D98876: [clang][ASTImporter] Add import support for SourceLocExpr.

2021-03-18 Thread Balázs Kéri via Phabricator via cfe-commits
balazske created this revision.
Herald added subscribers: martong, teemperor, gamesh411, Szelethus, dkrupp.
Herald added a reviewer: a.sidorin.
Herald added a reviewer: shafik.
balazske requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

It is possible that imported SourceLocExpr
can cause not expected behavior (if __builtin_LINE() is used
together with __LINE__ for example) but still it may be worth
to import these because some projects use it.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D98876

Files:
  clang/lib/AST/ASTImporter.cpp
  clang/unittests/AST/ASTImporterTest.cpp


Index: clang/unittests/AST/ASTImporterTest.cpp
===
--- clang/unittests/AST/ASTImporterTest.cpp
+++ clang/unittests/AST/ASTImporterTest.cpp
@@ -246,6 +246,24 @@
   EXPECT_FALSE(path.hasCycleAtBack());
 }
 
+const internal::VariadicDynCastAllOfMatcher sourceLocExpr;
+
+AST_MATCHER_P(SourceLocExpr, hasBuiltinStr, StringRef, Str) {
+  return Node.getBuiltinStr() == Str;
+}
+
+TEST_P(ImportExpr, ImportSourceLocExpr) {
+  MatchVerifier Verifier;
+  testImport("void declToImport() { (void)__builtin_FILE(); }", Lang_CXX03, "",
+ Lang_CXX03, Verifier,
+ functionDecl(hasDescendant(
+ sourceLocExpr(hasBuiltinStr("__builtin_FILE");
+  testImport("void declToImport() { (void)__builtin_COLUMN(); }", Lang_CXX03,
+ "", Lang_CXX03, Verifier,
+ functionDecl(hasDescendant(
+ sourceLocExpr(hasBuiltinStr("__builtin_COLUMN");
+}
+
 TEST_P(ImportExpr, ImportStringLiteral) {
   MatchVerifier Verifier;
   testImport("void declToImport() { (void)\"foo\"; }", Lang_CXX03, "",
Index: clang/lib/AST/ASTImporter.cpp
===
--- clang/lib/AST/ASTImporter.cpp
+++ clang/lib/AST/ASTImporter.cpp
@@ -574,6 +574,7 @@
 
 // Importing expressions
 ExpectedStmt VisitExpr(Expr *E);
+ExpectedStmt VisitSourceLocExpr(SourceLocExpr *E);
 ExpectedStmt VisitVAArgExpr(VAArgExpr *E);
 ExpectedStmt VisitChooseExpr(ChooseExpr *E);
 ExpectedStmt VisitGNUNullExpr(GNUNullExpr *E);
@@ -6482,6 +6483,21 @@
   return make_error(ImportError::UnsupportedConstruct);
 }
 
+ExpectedStmt ASTNodeImporter::VisitSourceLocExpr(SourceLocExpr *E) {
+  Error Err = Error::success();
+  auto BLoc = importChecked(Err, E->getBeginLoc());
+  auto RParenLoc = importChecked(Err, E->getEndLoc());
+  if (Err)
+return std::move(Err);
+  auto ParentContextOrErr = Importer.ImportContext(E->getParentContext());
+  if (!ParentContextOrErr)
+return ParentContextOrErr.takeError();
+
+  return new (Importer.getToContext())
+  SourceLocExpr(Importer.getToContext(), E->getIdentKind(), BLoc, 
RParenLoc,
+*ParentContextOrErr);
+}
+
 ExpectedStmt ASTNodeImporter::VisitVAArgExpr(VAArgExpr *E) {
 
   Error Err = Error::success();


Index: clang/unittests/AST/ASTImporterTest.cpp
===
--- clang/unittests/AST/ASTImporterTest.cpp
+++ clang/unittests/AST/ASTImporterTest.cpp
@@ -246,6 +246,24 @@
   EXPECT_FALSE(path.hasCycleAtBack());
 }
 
+const internal::VariadicDynCastAllOfMatcher sourceLocExpr;
+
+AST_MATCHER_P(SourceLocExpr, hasBuiltinStr, StringRef, Str) {
+  return Node.getBuiltinStr() == Str;
+}
+
+TEST_P(ImportExpr, ImportSourceLocExpr) {
+  MatchVerifier Verifier;
+  testImport("void declToImport() { (void)__builtin_FILE(); }", Lang_CXX03, "",
+ Lang_CXX03, Verifier,
+ functionDecl(hasDescendant(
+ sourceLocExpr(hasBuiltinStr("__builtin_FILE");
+  testImport("void declToImport() { (void)__builtin_COLUMN(); }", Lang_CXX03,
+ "", Lang_CXX03, Verifier,
+ functionDecl(hasDescendant(
+ sourceLocExpr(hasBuiltinStr("__builtin_COLUMN");
+}
+
 TEST_P(ImportExpr, ImportStringLiteral) {
   MatchVerifier Verifier;
   testImport("void declToImport() { (void)\"foo\"; }", Lang_CXX03, "",
Index: clang/lib/AST/ASTImporter.cpp
===
--- clang/lib/AST/ASTImporter.cpp
+++ clang/lib/AST/ASTImporter.cpp
@@ -574,6 +574,7 @@
 
 // Importing expressions
 ExpectedStmt VisitExpr(Expr *E);
+ExpectedStmt VisitSourceLocExpr(SourceLocExpr *E);
 ExpectedStmt VisitVAArgExpr(VAArgExpr *E);
 ExpectedStmt VisitChooseExpr(ChooseExpr *E);
 ExpectedStmt VisitGNUNullExpr(GNUNullExpr *E);
@@ -6482,6 +6483,21 @@
   return make_error(ImportError::UnsupportedConstruct);
 }
 
+ExpectedStmt ASTNodeImporter::VisitSourceLocExpr(SourceLocExpr *E) {
+  Error Err = Error::success();
+  auto BLoc = importChecked(Err, E->getBeginLoc());
+  auto RParenLoc = importChecked(Err, E->getEndLoc());
+  if (Err)
+return std::move(Err);
+  auto ParentContextOrErr = Importer.ImportContext(E->getParentContext());

[PATCH] D98824: [Tooling] Handle compilation databases containing commands with double dashes

2021-03-18 Thread Janusz Nykiel via Phabricator via cfe-commits
jnykiel updated this revision to Diff 331605.
jnykiel added a comment.

Fixed logic error in `injectResourceDir` causing a test failure on the build 
machine.


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

https://reviews.llvm.org/D98824

Files:
  clang/lib/Tooling/ArgumentsAdjusters.cpp
  clang/lib/Tooling/InterpolatingCompilationDatabase.cpp
  clang/lib/Tooling/Tooling.cpp
  clang/unittests/Tooling/CompilationDatabaseTest.cpp

Index: clang/unittests/Tooling/CompilationDatabaseTest.cpp
===
--- clang/unittests/Tooling/CompilationDatabaseTest.cpp
+++ clang/unittests/Tooling/CompilationDatabaseTest.cpp
@@ -812,6 +812,16 @@
   EXPECT_EQ(getCommand("dir/bar.cpp"), "clang -D dir/foo.cpp -Wall");
 }
 
+TEST_F(InterpolateTest, StripDoubleDash) {
+  add("dir/foo.cpp", "-o foo.o -std=c++14 -Wall -- dir/foo.cpp");
+  // input file and output option are removed
+  // -Wall flag isn't
+  // -std option gets re-added as the last argument before --
+  // new input file gets added after --
+  EXPECT_EQ(getCommand("dir/bar.cpp"),
+"clang -D dir/foo.cpp -Wall -std=c++14 --");
+}
+
 TEST_F(InterpolateTest, Case) {
   add("FOO/BAR/BAZ/SHOUT.cc");
   add("foo/bar/baz/quiet.cc");
Index: clang/lib/Tooling/Tooling.cpp
===
--- clang/lib/Tooling/Tooling.cpp
+++ clang/lib/Tooling/Tooling.cpp
@@ -435,13 +435,18 @@
 static void injectResourceDir(CommandLineArguments &Args, const char *Argv0,
   void *MainAddr) {
   // Allow users to override the resource dir.
-  for (StringRef Arg : Args)
+  for (StringRef Arg : Args) {
+if (Arg == "--")
+  break;
 if (Arg.startswith("-resource-dir"))
   return;
+  }
 
   // If there's no override in place add our resource dir.
-  Args.push_back("-resource-dir=" +
- CompilerInvocation::GetResourcesPath(Argv0, MainAddr));
+  std::string resourceDir = "-resource-dir=";
+  resourceDir.append(CompilerInvocation::GetResourcesPath(Argv0, MainAddr));
+  Args = getInsertArgumentAdjuster(CommandLineArguments(1, resourceDir),
+   ArgumentInsertPosition::END)(Args, "");
 }
 
 int ClangTool::run(ToolAction *Action) {
Index: clang/lib/Tooling/InterpolatingCompilationDatabase.cpp
===
--- clang/lib/Tooling/InterpolatingCompilationDatabase.cpp
+++ clang/lib/Tooling/InterpolatingCompilationDatabase.cpp
@@ -132,6 +132,8 @@
   LangStandard::Kind Std = LangStandard::lang_unspecified;
   // Whether the command line is for the cl-compatible driver.
   bool ClangCLMode;
+  // Whether to insert a double dash before the input file(s).
+  bool InsertDoubleDash = false;
 
   TransferableCommand(CompileCommand C)
   : Cmd(std::move(C)), Type(guessType(Cmd.Filename)),
@@ -177,6 +179,13 @@
Opt.matches(OPT__SLASH_Fo
 continue;
 
+  // ...including when the inputs are passed after --.
+  // If that is the case, record it.
+  if (Opt.matches(OPT__DASH_DASH)) {
+InsertDoubleDash = true;
+break;
+  }
+
   // Strip -x, but record the overridden language.
   if (const auto GivenType = tryParseTypeArg(*Arg)) {
 Type = *GivenType;
@@ -235,6 +244,8 @@
   llvm::Twine(ClangCLMode ? "/std:" : "-std=") +
   LangStandard::getLangStandardForKind(Std).getName()).str());
 }
+if (InsertDoubleDash)
+  Result.CommandLine.push_back("--");
 Result.CommandLine.push_back(std::string(Filename));
 return Result;
   }
Index: clang/lib/Tooling/ArgumentsAdjusters.cpp
===
--- clang/lib/Tooling/ArgumentsAdjusters.cpp
+++ clang/lib/Tooling/ArgumentsAdjusters.cpp
@@ -41,8 +41,13 @@
 "-save-temps",
 "--save-temps",
 };
-for (size_t i = 0, e = Args.size(); i < e; ++i) {
+size_t i = 0;
+for (size_t e = Args.size(); i < e; ++i) {
   StringRef Arg = Args[i];
+
+  if (Arg == "--")
+break;
+
   // Skip output commands.
   if (llvm::any_of(OutputCommands, [&Arg](llvm::StringRef OutputCommand) {
 return Arg.startswith(OutputCommand);
@@ -63,6 +68,8 @@
 }
 if (!HasSyntaxOnly)
   AdjustedArgs.push_back("-fsyntax-only");
+for (size_t e = Args.size(); i < e; ++i)
+  AdjustedArgs.push_back(Args[i]);
 return AdjustedArgs;
   };
 }
@@ -137,7 +144,7 @@
 
 CommandLineArguments::iterator I;
 if (Pos == ArgumentInsertPosition::END) {
-  I = Return.end();
+  I = std::find(Return.begin(), Return.end(), "--");
 } else {
   I = Return.begin();
   ++I; // To leave the program name in place
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D98855: [OpenCL] Support template parameters for as_type

2021-03-18 Thread Sven van Haastregt via Phabricator via cfe-commits
svenvh added inline comments.
Herald added a subscriber: ldrumm.



Comment at: clang/test/SemaOpenCLCXX/template-astype.cl:5
+auto templated_astype(T x) {
+  return as_int2(x);
+  // expected-error@-1{{invalid reinterpretation: sizes of 'int2' (vector of 2 
'int' values) and '__private int' must match}}

Anastasia wrote:
> could we also add another template with use of `__builtin_astype` directly?
> 
> In case we change as_type implementation one day the clang builtin will still 
> be tested too. :)
Sure, I can add extend this test with the following before committing, if that 
is okay with you?

```// Test __builtin_astype.
template 
auto templated_builtin_astype(T x) {
  return __builtin_astype(x, int2);
}

auto test_builtin(char8 x) { return templated_builtin_astype(x); }```


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98855

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


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

2021-03-18 Thread Aaron Enye Shi via Phabricator via cfe-commits
ashi1 added a comment.

In D98278#2618936 , @zero9178 wrote:

> In D98278#2616932 , @mstorsjo wrote:
>
>> In D98278#2616916 , @zero9178 wrote:
>>
>>> Add GetErrcMessages.cmake, which contains a cmake function to automatically 
>>> get the error messages of various posix error codes needed by lit by 
>>> running a small C++ program.
>>> Currently ENOENT, EISDIR, EINVAL and EACCES are supplied. 
>>> These error messages are then currently supplied to clang, llvm and lld as 
>>> the errc_messages config parameter.
>>>
>>> Regarding Cross compiling: the function uses try_run which when cross 
>>> compiling may use the CMAKE_CROSSCOMPILING_EMULATOR to run the code.
>>
>> How does it behave if such a thing isn't hooked up? Ideally it'd fall back 
>> silently and these parts of tests would just fail, but not block things 
>> overall.
>
> It will fall back to using Python's strerror, potentially failing if pythons 
> strerror would not return the same strings (only the case for MSVC I believe).

Hi, this patch is causing a failure when cmake runs `try_run()` with a 
`CMAKE_TOOLCHAIN_FILE` defined. It seems related to having a fall back if the 
try_run fails.
Here is the error, and the build uses MSVC. What do you think we could do about 
this? Thanks.

  [06:48:06][Step 1/4] CMake Error: TRY_RUN() invoked in cross-compiling mode, 
please set the following cache variables appropriately:
  [06:48:06][Step 1/4]errc_exit_code (advanced)
  [06:48:06][Step 1/4]errc_exit_code__TRYRUN_OUTPUT (advanced)
  [06:48:06][Step 1/4] For details see /TryRunResults.cmake


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98278

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


[PATCH] D98812: [OPENMP]Map data field with l-value reference types.

2021-03-18 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev updated this revision to Diff 331623.
ABataev added a comment.

Rebase + fixes for references to complex data structures mapping


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98812

Files:
  clang/lib/CodeGen/CGOpenMPRuntime.cpp
  clang/test/OpenMP/target_map_codegen_28.cpp
  clang/test/OpenMP/target_map_codegen_35.cpp
  openmp/libomptarget/test/mapping/data_member_ref.cpp

Index: openmp/libomptarget/test/mapping/data_member_ref.cpp
===
--- /dev/null
+++ openmp/libomptarget/test/mapping/data_member_ref.cpp
@@ -0,0 +1,69 @@
+// RUN: %libomptarget-compilexx-run-and-check-aarch64-unknown-linux-gnu
+// RUN: %libomptarget-compilexx-run-and-check-powerpc64-ibm-linux-gnu
+// RUN: %libomptarget-compilexx-run-and-check-powerpc64le-ibm-linux-gnu
+// RUN: %libomptarget-compilexx-run-and-check-x86_64-pc-linux-gnu
+// RUN: %libomptarget-compilexx-run-and-check-nvptx64-nvidia-cuda
+
+#include 
+
+struct View {
+  int Data;
+};
+
+struct ViewPtr {
+  int *Data;
+};
+
+template  struct Foo {
+  Foo(T &V) : VRef(V) {}
+  T &VRef;
+};
+
+int main() {
+  View V;
+  V.Data = 123456;
+  Foo Bar(V);
+  ViewPtr V1;
+  int Data = 123456;
+  V1.Data = &Data;
+  Foo Baz(V1);
+
+  // CHECK: Host 123456.
+  printf("Host %d.\n", Bar.VRef.Data);
+#pragma omp target map(Bar.VRef)
+  {
+// CHECK: Device 123456.
+printf("Device %d.\n", Bar.VRef.Data);
+V.Data = 654321;
+// CHECK: Device 654321.
+printf("Device %d.\n", Bar.VRef.Data);
+  }
+  // CHECK: Host 654321 654321.
+  printf("Host %d %d.\n", Bar.VRef.Data, V.Data);
+  V.Data = 123456;
+  // CHECK: Host 123456.
+  printf("Host %d.\n", Bar.VRef.Data);
+#pragma omp target map(Bar) map(Bar.VRef)
+  {
+// CHECK: Device 123456.
+printf("Device %d.\n", Bar.VRef.Data);
+V.Data = 654321;
+// CHECK: Device 654321.
+printf("Device %d.\n", Bar.VRef.Data);
+  }
+  // CHECK: Host 654321 654321.
+  printf("Host %d %d.\n", Bar.VRef.Data, V.Data);
+  // CHECK: Host 123456.
+  printf("Host %d.\n", *Baz.VRef.Data);
+#pragma omp target map(*Baz.VRef.Data)
+  {
+// CHECK: Device 123456.
+printf("Device %d.\n", *Baz.VRef.Data);
+*V1.Data = 654321;
+// CHECK: Device 654321.
+printf("Device %d.\n", *Baz.VRef.Data);
+  }
+  // CHECK: Host 654321 654321 654321.
+  printf("Host %d %d %d.\n", *Baz.VRef.Data, *V1.Data, Data);
+  return 0;
+}
Index: clang/test/OpenMP/target_map_codegen_35.cpp
===
--- /dev/null
+++ clang/test/OpenMP/target_map_codegen_35.cpp
@@ -0,0 +1,182 @@
+// expected-no-diagnostics
+#ifndef HEADER
+#define HEADER
+
+///==///
+// RUN: %clang_cc1 -DCK35 -verify -fopenmp -fopenmp-version=50 -fopenmp-targets=powerpc64le-ibm-linux-gnu -x c++ -triple powerpc64le-unknown-unknown -emit-llvm %s -o - | FileCheck %s --check-prefix CK35 --check-prefix CK35-64
+// RUN: %clang_cc1 -DCK35 -fopenmp -fopenmp-version=50 -fopenmp-targets=powerpc64le-ibm-linux-gnu -x c++ -std=c++11 -triple powerpc64le-unknown-unknown -emit-pch -o %t %s
+// RUN: %clang_cc1 -fopenmp -fopenmp-version=50 -fopenmp-targets=powerpc64le-ibm-linux-gnu -x c++ -triple powerpc64le-unknown-unknown -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s  --check-prefix CK35 --check-prefix CK35-64
+// RUN: %clang_cc1 -DCK35 -verify -fopenmp -fopenmp-version=50 -fopenmp-targets=i386-pc-linux-gnu -x c++ -triple i386-unknown-unknown -emit-llvm %s -o - | FileCheck %s  --check-prefix CK35 --check-prefix CK35-32
+// RUN: %clang_cc1 -DCK35 -fopenmp -fopenmp-version=50 -fopenmp-targets=i386-pc-linux-gnu -x c++ -std=c++11 -triple i386-unknown-unknown -emit-pch -o %t %s
+// RUN: %clang_cc1 -fopenmp -fopenmp-version=50 -fopenmp-targets=i386-pc-linux-gnu -x c++ -triple i386-unknown-unknown -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s  --check-prefix CK35 --check-prefix CK35-32
+
+// RUN: %clang_cc1 -DCK35 -verify -fopenmp-simd -fopenmp-version=50 -fopenmp-targets=powerpc64le-ibm-linux-gnu -x c++ -triple powerpc64le-unknown-unknown -emit-llvm %s -o - | FileCheck --check-prefix SIMD-ONLY32 %s
+// RUN: %clang_cc1 -DCK35 -fopenmp-simd -fopenmp-version=50 -fopenmp-targets=powerpc64le-ibm-linux-gnu -x c++ -std=c++11 -triple powerpc64le-unknown-unknown -emit-pch -o %t %s
+// RUN: %clang_cc1 -fopenmp-simd -fopenmp-version=50 -fopenmp-targets=powerpc64le-ibm-linux-gnu -x c++ -triple powerpc64le-unknown-unknown -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck --check-prefix SIMD-ONLY32 %s
+// RUN: %clang_cc1 -DCK35 -verify -fopenmp-simd -fopenmp-version=50 -fopenmp-targets=i386-pc-linux-gnu -x c++ -triple i386-unknown-unknown -emit-llvm %s -o - | FileCheck --check-prefix SIMD-ONLY32 %s
+// RUN: %clang_cc1 -DCK35 -fopenmp-simd -fopenmp-version=50 -fopenmp-targets=

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

2021-03-18 Thread Markus Böck via Phabricator via cfe-commits
zero9178 added a comment.

In D98278#2635190 , @ashi1 wrote:

> In D98278#2618936 , @zero9178 wrote:
>
>> In D98278#2616932 , @mstorsjo wrote:
>>
>>> In D98278#2616916 , @zero9178 
>>> wrote:
>>>
 Add GetErrcMessages.cmake, which contains a cmake function to 
 automatically get the error messages of various posix error codes needed 
 by lit by running a small C++ program.
 Currently ENOENT, EISDIR, EINVAL and EACCES are supplied. 
 These error messages are then currently supplied to clang, llvm and lld as 
 the errc_messages config parameter.

 Regarding Cross compiling: the function uses try_run which when cross 
 compiling may use the CMAKE_CROSSCOMPILING_EMULATOR to run the code.
>>>
>>> How does it behave if such a thing isn't hooked up? Ideally it'd fall back 
>>> silently and these parts of tests would just fail, but not block things 
>>> overall.
>>
>> It will fall back to using Python's strerror, potentially failing if pythons 
>> strerror would not return the same strings (only the case for MSVC I 
>> believe).
>
> Hi, this patch is causing a failure when cmake runs `try_run()` with a 
> `CMAKE_TOOLCHAIN_FILE` defined. It seems related to having a fall back if the 
> try_run fails.
> Here is the error, and the build uses MSVC. What do you think we could do 
> about this? Thanks.
>
>   [06:48:06][Step 1/4] CMake Error: TRY_RUN() invoked in cross-compiling 
> mode, please set the following cache variables appropriately:
>   [06:48:06][Step 1/4]errc_exit_code (advanced)
>   [06:48:06][Step 1/4]errc_exit_code__TRYRUN_OUTPUT (advanced)
>   [06:48:06][Step 1/4] For details see /TryRunResults.cmake

Hello! There is actually an ongoing discussion about this here 
https://reviews.llvm.org/D98861. For the time being you have two options if you 
have a cross compiling setup that can't natively run Windows programs.

1. Set CMAKE_CROSSCOMPILING_EMULATOR to an emulator that could execute the 
Windows program on your host. Wine comes to my mind as an example
2. You should be able to set the variables `errc_exit_code` to the value 0 and 
then set `errc_exit_code__TRYRUN_OUTPUT` to the stdout of the Windows program 
(alternatively leave it empty, but a few tests will fail)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98278

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


[PATCH] D98867: [HIP] Fix ROCm detection

2021-03-18 Thread Artem Belevich via Phabricator via cfe-commits
tra added inline comments.



Comment at: clang/lib/Driver/ToolChains/AMDGPU.cpp:271
+}
+if (LatestROCm < FileName)
+  LatestROCm = FileName.str();

This will rank `rocm-3.9` higher than `rocm-3.10`. I think you do need to 
extract and compare the version.


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

https://reviews.llvm.org/D98867

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


[PATCH] D98745: [clang] Add fixit for Wreorder-ctor

2021-03-18 Thread Nathan James via Phabricator via cfe-commits
njames93 marked 4 inline comments as done.
njames93 added inline comments.



Comment at: clang/lib/Sema/SemaDeclCXX.cpp:5242
+  if (Previous->isAnyMemberInitializer())
+Diag << 0 << Previous->getAnyMember()->getDeclName();
+  else

aaron.ballman wrote:
> 
This was copied from the old impl, Not sure it this is going to change 
behaviour though.
No tests needed to be updated though,


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98745

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


[PATCH] D98745: [clang] Add fixit for Wreorder-ctor

2021-03-18 Thread Nathan James via Phabricator via cfe-commits
njames93 updated this revision to Diff 331635.
njames93 marked an inline comment as done.
njames93 added a comment.

Address nits.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98745

Files:
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/Sema/SemaDeclCXX.cpp
  clang/test/FixIt/fixit-cxx-init-order.cpp
  clang/test/SemaCXX/constructor-initializer.cpp
  clang/test/SemaCXX/warn-reorder-ctor-initialization.cpp

Index: clang/test/SemaCXX/warn-reorder-ctor-initialization.cpp
===
--- clang/test/SemaCXX/warn-reorder-ctor-initialization.cpp
+++ clang/test/SemaCXX/warn-reorder-ctor-initialization.cpp
@@ -4,15 +4,14 @@
 
 struct BB1 {};
 
-class complex : public BB, BB1 { 
-public: 
+class complex : public BB, BB1 {
+public:
   complex()
-: s2(1), // expected-warning {{field 's2' will be initialized after field 's1'}}
-  s1(1),
-  s3(3), // expected-warning {{field 's3' will be initialized after base 'BB1'}} 
-  BB1(), // expected-warning {{base class 'BB1' will be initialized after base 'BB'}}
-  BB()
-  {}
+  : s2(1), // expected-warning {{initializer order does not match the declaration order}} expected-note {{field 's2' will be initialized after field 's1'}}
+s1(1),
+s3(3), // expected-note {{field 's3' will be initialized after base 'BB1'}}
+BB1(), // expected-note {{base class 'BB1' will be initialized after base 'BB'}}
+BB() {}
   int s1;
   int s2;
   int s3;
Index: clang/test/SemaCXX/constructor-initializer.cpp
===
--- clang/test/SemaCXX/constructor-initializer.cpp
+++ clang/test/SemaCXX/constructor-initializer.cpp
@@ -91,13 +91,14 @@
 
 struct Current : Derived {
   int Derived;
-  Current() : Derived(1), ::Derived(), // expected-warning {{field 'Derived' will be initialized after base '::Derived'}} \
-   // expected-warning {{base class '::Derived' will be initialized after base 'Derived::V'}}
-  ::Derived::Base(), // expected-error {{type '::Derived::Base' is not a direct or virtual base of 'Current'}}
-   Derived::Base1(), // expected-error {{type 'Derived::Base1' is not a direct or virtual base of 'Current'}}
-   Derived::V(),
-   ::NonExisting(), // expected-error {{member initializer 'NonExisting' does not name a non-static data member or}}
-   INT::NonExisting()  {} // expected-error {{'INT' (aka 'int') is not a class, namespace, or enumeration}} \
+  Current() : Derived(1), ::Derived(), // expected-warning {{initializer order does not match the declaration order}} \
+   // expected-note {{field 'Derived' will be initialized after base '::Derived'}} \
+   // expected-note {{base class '::Derived' will be initialized after base 'Derived::V'}}
+  ::Derived::Base(),   // expected-error {{type '::Derived::Base' is not a direct or virtual base of 'Current'}}
+  Derived::Base1(),// expected-error {{type 'Derived::Base1' is not a direct or virtual base of 'Current'}}
+  Derived::V(),
+  ::NonExisting(),  // expected-error {{member initializer 'NonExisting' does not name a non-static data member or}}
+  INT::NonExisting() {} // expected-error {{'INT' (aka 'int') is not a class, namespace, or enumeration}} \
   // expected-error {{member initializer 'NonExisting' does not name a non-static data member or}}
 };
 
Index: clang/test/FixIt/fixit-cxx-init-order.cpp
===
--- /dev/null
+++ clang/test/FixIt/fixit-cxx-init-order.cpp
@@ -0,0 +1,22 @@
+// Due to the fix having multiple edits we can't use
+// '-fdiagnostics-parseable-fixits' to determine if fixes are correct. However,
+// running fixit recompile with 'Werror' should fail if the fixes are invalid.
+
+// RUN: %clang_cc1 %s -Werror=reorder-ctor -fixit-recompile -fixit-to-temporary
+// RUN: %clang_cc1 %s -Wreorder-ctor -verify -verify-ignore-unexpected=note
+
+struct Foo {
+  int A, B, C;
+
+  Foo() : A(1), B(3), C(2) {}
+  Foo(int) : A(1), C(2), B(3) {}  // expected-warning {{field 'C' will be initialized after field 'B'}}
+  Foo(unsigned) : C(2), B(3), A(1) {} // expected-warning {{initializer order does not match the declaration order}}
+};
+
+struct Bar : Foo {
+  int D, E, F;
+
+  Bar() : Foo(), D(1), E(2), F(3) {}
+  Bar(int) : D(1), E(2), F(3), Foo(4) {}  // expected-warning {{field 'F' will be initialized after base 'Foo'}}
+  Bar(unsigned) : F(3), E(2), D(1), Foo(4) {} // expected-warning {{initializer order does not match the declaration order}}
+};
In

[clang] 2f2ae08 - [WebAssembly] Remove experimental SIMD instructions

2021-03-18 Thread Thomas Lively via cfe-commits

Author: Thomas Lively
Date: 2021-03-18T11:21:24-07:00
New Revision: 2f2ae08da91dc5c188d5bb4d8b0b096d0a120a4a

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

LOG: [WebAssembly] Remove experimental SIMD instructions

Removes the instruction definitions, intrinsics, and builtins for qfma/qfms,
signselect, and prefetch instructions, which were not included in the final
WebAssembly SIMD spec.

Depends on D98457.

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

Added: 


Modified: 
clang/include/clang/Basic/BuiltinsWebAssembly.def
clang/lib/CodeGen/CGBuiltin.cpp
clang/test/CodeGen/builtins-wasm.c
llvm/include/llvm/IR/IntrinsicsWebAssembly.td
llvm/lib/Target/WebAssembly/MCTargetDesc/WebAssemblyMCTargetDesc.h
llvm/lib/Target/WebAssembly/WebAssemblyISelLowering.cpp
llvm/lib/Target/WebAssembly/WebAssemblyInstrSIMD.td
llvm/test/CodeGen/WebAssembly/simd-intrinsics.ll
llvm/test/MC/WebAssembly/simd-encodings.s

Removed: 
llvm/test/CodeGen/WebAssembly/simd-prefetch-offset.ll



diff  --git a/clang/include/clang/Basic/BuiltinsWebAssembly.def 
b/clang/include/clang/Basic/BuiltinsWebAssembly.def
index 38de66587cba..2f51376ba15a 100644
--- a/clang/include/clang/Basic/BuiltinsWebAssembly.def
+++ b/clang/include/clang/Basic/BuiltinsWebAssembly.def
@@ -141,11 +141,6 @@ 
TARGET_BUILTIN(__builtin_wasm_extadd_pairwise_i16x8_u_i32x4, "V4UiV8Us", "nc", "
 
 TARGET_BUILTIN(__builtin_wasm_bitselect, "V4iV4iV4iV4i", "nc", "simd128")
 
-TARGET_BUILTIN(__builtin_wasm_signselect_i8x16, "V16ScV16ScV16ScV16Sc", "nc", 
"simd128")
-TARGET_BUILTIN(__builtin_wasm_signselect_i16x8, "V8sV8sV8sV8s", "nc", 
"simd128")
-TARGET_BUILTIN(__builtin_wasm_signselect_i32x4, "V4iV4iV4iV4i", "nc", 
"simd128")
-TARGET_BUILTIN(__builtin_wasm_signselect_i64x2, "V2LLiV2LLiV2LLiV2LLi", "nc", 
"simd128")
-
 TARGET_BUILTIN(__builtin_wasm_shuffle_v8x16, 
"V16ScV16ScV16ScIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIi", "nc", "simd128")
 
 TARGET_BUILTIN(__builtin_wasm_any_true_i8x16, "iV16Sc", "nc", "simd128")
@@ -188,11 +183,6 @@ TARGET_BUILTIN(__builtin_wasm_dot_s_i32x4_i16x8, 
"V4iV8sV8s", "nc", "simd128")
 TARGET_BUILTIN(__builtin_wasm_sqrt_f32x4, "V4fV4f", "nc", "simd128")
 TARGET_BUILTIN(__builtin_wasm_sqrt_f64x2, "V2dV2d", "nc", "simd128")
 
-TARGET_BUILTIN(__builtin_wasm_qfma_f32x4, "V4fV4fV4fV4f", "nc", "simd128")
-TARGET_BUILTIN(__builtin_wasm_qfms_f32x4, "V4fV4fV4fV4f", "nc", "simd128")
-TARGET_BUILTIN(__builtin_wasm_qfma_f64x2, "V2dV2dV2dV2d", "nc", "simd128")
-TARGET_BUILTIN(__builtin_wasm_qfms_f64x2, "V2dV2dV2dV2d", "nc", "simd128")
-
 TARGET_BUILTIN(__builtin_wasm_trunc_saturate_s_i32x4_f32x4, "V4iV4f", "nc", 
"simd128")
 TARGET_BUILTIN(__builtin_wasm_trunc_saturate_u_i32x4_f32x4, "V4iV4f", "nc", 
"simd128")
 
@@ -206,9 +196,6 @@ TARGET_BUILTIN(__builtin_wasm_widen_high_s_i32x4_i64x2, 
"V2LLiV4i", "nc", "simd1
 TARGET_BUILTIN(__builtin_wasm_widen_low_u_i32x4_i64x2, "V2LLUiV4Ui", "nc", 
"simd128")
 TARGET_BUILTIN(__builtin_wasm_widen_high_u_i32x4_i64x2, "V2LLUiV4Ui", "nc", 
"simd128")
 
-TARGET_BUILTIN(__builtin_wasm_widen_s_i8x16_i32x4, "V4iV16ScIi", "nc", 
"simd128")
-TARGET_BUILTIN(__builtin_wasm_widen_u_i8x16_i32x4, "V4UiV16UcIi", "nc", 
"simd128")
-
 TARGET_BUILTIN(__builtin_wasm_convert_low_s_i32x4_f64x2, "V2dV4i", "nc", 
"simd128")
 TARGET_BUILTIN(__builtin_wasm_convert_low_u_i32x4_f64x2, "V2dV4Ui", "nc", 
"simd128")
 TARGET_BUILTIN(__builtin_wasm_trunc_saturate_zero_s_f64x2_i32x4, "V4iV2d", 
"nc", "simd128")
@@ -230,8 +217,5 @@ TARGET_BUILTIN(__builtin_wasm_store64_lane, "vLLi*V2LLiIi", 
"n", "simd128")
 
 TARGET_BUILTIN(__builtin_wasm_eq_i64x2, "V2LLiV2LLiV2LLi", "nc", "simd128")
 
-TARGET_BUILTIN(__builtin_wasm_prefetch_t, "vv*", "n", "simd128")
-TARGET_BUILTIN(__builtin_wasm_prefetch_nt, "vv*", "n", "simd128")
-
 #undef BUILTIN
 #undef TARGET_BUILTIN

diff  --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp
index 8d1d3c50870c..96df7b0d6222 100644
--- a/clang/lib/CodeGen/CGBuiltin.cpp
+++ b/clang/lib/CodeGen/CGBuiltin.cpp
@@ -17366,17 +17366,6 @@ Value 
*CodeGenFunction::EmitWebAssemblyBuiltinExpr(unsigned BuiltinID,
 CGM.getIntrinsic(Intrinsic::wasm_bitselect, ConvertType(E->getType()));
 return Builder.CreateCall(Callee, {V1, V2, C});
   }
-  case WebAssembly::BI__builtin_wasm_signselect_i8x16:
-  case WebAssembly::BI__builtin_wasm_signselect_i16x8:
-  case WebAssembly::BI__builtin_wasm_signselect_i32x4:
-  case WebAssembly::BI__builtin_wasm_signselect_i64x2: {
-Value *V1 = EmitScalarExpr(E->getArg(0));
-Value *V2 = EmitScalarExpr(E->getArg(1));
-Value *C = EmitScalarExpr(E->getArg(2));
-Function *Callee =
-CGM.getIntrinsic(Intrinsic::wasm_signselect, 
ConvertType(E->getType()));
-return Builder.CreateCall(Callee, {V1, V2, 

[PATCH] D98466: [WebAssembly] Remove experimental SIMD instructions

2021-03-18 Thread Thomas Lively 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 rG2f2ae08da91d: [WebAssembly] Remove experimental SIMD 
instructions (authored by tlively).

Changed prior to commit:
  https://reviews.llvm.org/D98466?vs=330116&id=331638#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98466

Files:
  clang/include/clang/Basic/BuiltinsWebAssembly.def
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/test/CodeGen/builtins-wasm.c
  llvm/include/llvm/IR/IntrinsicsWebAssembly.td
  llvm/lib/Target/WebAssembly/MCTargetDesc/WebAssemblyMCTargetDesc.h
  llvm/lib/Target/WebAssembly/WebAssemblyISelLowering.cpp
  llvm/lib/Target/WebAssembly/WebAssemblyInstrSIMD.td
  llvm/test/CodeGen/WebAssembly/simd-intrinsics.ll
  llvm/test/CodeGen/WebAssembly/simd-prefetch-offset.ll
  llvm/test/MC/WebAssembly/simd-encodings.s

Index: llvm/test/MC/WebAssembly/simd-encodings.s
===
--- llvm/test/MC/WebAssembly/simd-encodings.s
+++ llvm/test/MC/WebAssembly/simd-encodings.s
@@ -664,18 +664,6 @@
 # CHECK: v128.load64_zero 32 # encoding: [0xfd,0xfd,0x01,0x03,0x20]
 v128.load64_zero 32
 
-# CHECK: f32x4.qfma # encoding: [0xfd,0xb4,0x01]
-f32x4.qfma
-
-# CHECK: f32x4.qfms # encoding: [0xfd,0xd4,0x01]
-f32x4.qfms
-
-# CHECK: f64x2.qfma # encoding: [0xfd,0xfe,0x01]
-f64x2.qfma
-
-# CHECK: f64x2.qfms # encoding: [0xfd,0xff,0x01]
-f64x2.qfms
-
 # CHECK: i16x8.extmul_low_i8x16_s # encoding: [0xfd,0x9a,0x01]
 i16x8.extmul_low_i8x16_s
 
@@ -712,18 +700,6 @@
 # CHECK: i64x2.extmul_high_i32x4_u # encoding: [0xfd,0xd7,0x01]
 i64x2.extmul_high_i32x4_u
 
-# CHECK: i8x16.signselect # encoding: [0xfd,0x7d]
-i8x16.signselect
-
-# CHECK: i16x8.signselect # encoding: [0xfd,0x7e]
-i16x8.signselect
-
-# CHECK: i32x4.signselect # encoding: [0xfd,0x7f]
-i32x4.signselect
-
-# CHECK: i64x2.signselect # encoding: [0xfd,0x94,0x01]
-i64x2.signselect
-
 # CHECK: i16x8.extadd_pairwise_i8x16_s # encoding: [0xfd,0xc2,0x01]
 i16x8.extadd_pairwise_i8x16_s
 
@@ -736,12 +712,6 @@
 # CHECK: i32x4.extadd_pairwise_i16x8_u # encoding: [0xfd,0xa6,0x01]
 i32x4.extadd_pairwise_i16x8_u
 
-# CHECK: prefetch.t 16 # encoding: [0xfd,0xc5,0x01,0x00,0x10]
-prefetch.t 16
-
-# CHECK: prefetch.nt 16 # encoding: [0xfd,0xc6,0x01,0x00,0x10]
-prefetch.nt 16
-
 # CHECK: f64x2.convert_low_i32x4_s # encoding: [0xfd,0x53]
 f64x2.convert_low_i32x4_s
 
@@ -760,10 +730,4 @@
 # CHECK: f64x2.promote_low_f32x4 # encoding: [0xfd,0x69]
 f64x2.promote_low_f32x4
 
-# CHECK: i32x4.widen_i8x16_s 3 # encoding: [0xfd,0x67,0x03]
-i32x4.widen_i8x16_s 3
-
-# CHECK: i32x4.widen_i8x16_u 3 # encoding: [0xfd,0x68,0x03]
-i32x4.widen_i8x16_u 3
-
 end_function
Index: llvm/test/CodeGen/WebAssembly/simd-prefetch-offset.ll
===
--- llvm/test/CodeGen/WebAssembly/simd-prefetch-offset.ll
+++ /dev/null
@@ -1,235 +0,0 @@
-; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
-; RUN: llc < %s -verify-machineinstrs -mattr=+simd128 | FileCheck %s
-
-; Test experimental prefetch instructions
-
-target datalayout = "e-m:e-p:32:32-i64:64-n32:64-S128"
-target triple = "wasm32-unknown-unknown"
-
-declare void @llvm.wasm.prefetch.t(i8*)
-declare void @llvm.wasm.prefetch.nt(i8*)
-@gv = global i8 0
-
-;===
-; prefetch.t
-;===
-
-define void @prefetch_t_no_offset(i8* %p) {
-; CHECK-LABEL: prefetch_t_no_offset:
-; CHECK: .functype prefetch_t_no_offset (i32) -> ()
-; CHECK-NEXT:  # %bb.0:
-; CHECK-NEXT:local.get 0
-; CHECK-NEXT:prefetch.t 0
-; CHECK-NEXT:# fallthrough-return
-  tail call void @llvm.wasm.prefetch.t(i8* %p)
-  ret void
-}
-
-define void @prefetch_t_with_folded_offset(i8* %p) {
-; CHECK-LABEL: prefetch_t_with_folded_offset:
-; CHECK: .functype prefetch_t_with_folded_offset (i32) -> ()
-; CHECK-NEXT:  # %bb.0:
-; CHECK-NEXT:local.get 0
-; CHECK-NEXT:i32.const 24
-; CHECK-NEXT:i32.add
-; CHECK-NEXT:prefetch.t 0
-; CHECK-NEXT:# fallthrough-return
-  %q = ptrtoint i8* %p to i32
-  %r = add nuw i32 %q, 24
-  %s = inttoptr i32 %r to i8*
-  tail call void @llvm.wasm.prefetch.t(i8* %s)
-  ret void
-}
-
-define void @prefetch_t_with_folded_gep_offset(i8* %p) {
-; CHECK-LABEL: prefetch_t_with_folded_gep_offset:
-; CHECK: .functype prefetch_t_with_folded_gep_offset (i32) -> ()
-; CHECK-NEXT:  # %bb.0:
-; CHECK-NEXT:local.get 0
-; CHECK-NEXT:i32.const 6
-; CHECK-NEXT:i32.add
-; CHECK-NEXT:prefetch.t 0
-; CHECK-NEXT:# fallthrough-return
-  %s = getelementptr in

[clang] f5764a8 - [WebAssembly] Finalize SIMD names and opcodes

2021-03-18 Thread Thomas Lively via cfe-commits

Author: Thomas Lively
Date: 2021-03-18T11:21:25-07:00
New Revision: f5764a8654e3caa6ca5dab3a89238c165062228f

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

LOG: [WebAssembly] Finalize SIMD names and opcodes

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

Depends on D98466.

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

Added: 
llvm/test/CodeGen/WebAssembly/simd-extending.ll

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

Removed: 
llvm/test/CodeGen/WebAssembly/simd-widening.ll



diff  --git a/clang/include/clang/Basic/BuiltinsWebAssembly.def 
b/clang/include/clang/Basic/BuiltinsWebAssembly.def
index 2f51376ba15a..6ea59026cd02 100644
--- a/clang/include/clang/Basic/BuiltinsWebAssembly.def
+++ b/clang/include/clang/Basic/BuiltinsWebAssembly.def
@@ -84,15 +84,15 @@ TARGET_BUILTIN(__builtin_wasm_replace_lane_i64x2, 
"V2LLiV2LLiIiLLi", "nc", "simd
 TARGET_BUILTIN(__builtin_wasm_replace_lane_f32x4, "V4fV4fIif", "nc", "simd128")
 TARGET_BUILTIN(__builtin_wasm_replace_lane_f64x2, "V2dV2dIid", "nc", "simd128")
 
-TARGET_BUILTIN(__builtin_wasm_add_saturate_s_i8x16, "V16ScV16ScV16Sc", "nc", 
"simd128")
-TARGET_BUILTIN(__builtin_wasm_add_saturate_u_i8x16, "V16UcV16UcV16Uc", "nc", 
"simd128")
-TARGET_BUILTIN(__builtin_wasm_add_saturate_s_i16x8, "V8sV8sV8s", "nc", 
"simd128")
-TARGET_BUILTIN(__builtin_wasm_add_saturate_u_i16x8, "V8UsV8UsV8Us", "nc", 
"simd128")
+TARGET_BUILTIN(__builtin_wasm_add_sat_s_i8x16, "V16ScV16ScV16Sc", "nc", 
"simd128")
+TARGET_BUILTIN(__builtin_wasm_add_sat_u_i8x16, "V16UcV16UcV16Uc", "nc", 
"simd128")
+TARGET_BUILTIN(__builtin_wasm_add_sat_s_i16x8, "V8sV8sV8s", "nc", "simd128")
+TARGET_BUILTIN(__builtin_wasm_add_sat_u_i16x8, "V8UsV8UsV8Us", "nc", "simd128")
 
-TARGET_BUILTIN(__builtin_wasm_sub_saturate_s_i8x16, "V16ScV16ScV16Sc", "nc", 
"simd128")
-TARGET_BUILTIN(__builtin_wasm_sub_saturate_u_i8x16, "V16UcV16UcV16Uc", "nc", 
"simd128")
-TARGET_BUILTIN(__builtin_wasm_sub_saturate_s_i16x8, "V8sV8sV8s", "nc", 
"simd128")
-TARGET_BUILTIN(__builtin_wasm_sub_saturate_u_i16x8, "V8UsV8UsV8Us", "nc", 
"simd128")
+TARGET_BUILTIN(__builtin_wasm_sub_sat_s_i8x16, "V16ScV16ScV16Sc", "nc", 
"simd128")
+TARGET_BUILTIN(__builtin_wasm_sub_sat_u_i8x16, "V16UcV16UcV16Uc", "nc", 
"simd128")
+TARGET_BUILTIN(__builtin_wasm_sub_sat_s_i16x8, "V8sV8sV8s", "nc", "simd128")
+TARGET_BUILTIN(__builtin_wasm_sub_sat_u_i16x8, "V8UsV8UsV8Us", "nc", "simd128")
 
 TARGET_BUILTIN(__builtin_wasm_abs_i8x16, "V16ScV16Sc", "nc", "simd128")
 TARGET_BUILTIN(__builtin_wasm_abs_i16x8, "V8sV8s", "nc", "simd128")
@@ -116,7 +116,7 @@ TARGET_BUILTIN(__builtin_wasm_avgr_u_i16x8, "V8UsV8UsV8Us", 
"nc", "simd128")
 
 TARGET_BUILTIN(__builtin_wasm_popcnt_i8x16, "V16ScV16Sc", "nc", "simd128")
 
-TARGET_BUILTIN(__builtin_wasm_q15mulr_saturate_s_i16x8, "V8sV8sV8s", "nc", 
"simd128")
+TARGET_BUILTIN(__builtin_wasm_q15mulr_sat_s_i16x8, "V8sV8sV8s", "nc", 
"simd128")
 
 TARGET_BUILTIN(__builtin_wasm_extmul_low_i8x16_s_i16x8, "V8sV16ScV16Sc", "nc", 
"simd128")
 TARGET_BUILTIN(__builtin_wasm_extmul_high_i8x16_s_i16x8, "V8sV16ScV16Sc", 
"nc", "simd128")
@@ -191,15 +191,15 @@ TARGET_BUILTIN(__builtin_wasm_narrow_u_i8x16_i16x8, 
"V16UcV8UsV8Us", "nc", "simd
 TARGET_BUILTIN(__builtin_wasm_narrow_s_i16x8_i32x4, "V8sV4iV4i", "nc", 
"simd128")
 TARGET_BUILTIN(__builtin_wasm_narrow_u_i16x8_i32x4, "V8UsV4UiV4Ui", "nc", 
"simd128")
 
-TARGET_BUILTIN(__builtin_wasm_widen_low_s_i32x4_i64x2, "V2LLiV4i", "nc", 
"simd128")
-TARGET_BUILTIN(__builtin_wasm_widen_high_s_i32x4_i64x2, "V2LLiV4i", "nc", 
"simd128")
-TARGET_BUILTIN(__builtin_wasm_widen_low_u_i32x4_i64x2, "V2LLUiV4Ui", "nc", 
"simd128")
-TARGET_BUILTIN(__builtin_wasm_widen_high_u_i32x4_i64x2, "V2LLUiV4Ui", "nc", 
"simd128")
+TARGET_BUILTIN(__builtin_wasm_extend_low_s_i32x4_i64x2, "V2LLiV4i", "nc", 
"simd128")
+TARGET_BUILTIN(__builtin_wasm_extend_high_s_i32x4_i64x2, "V2LLiV4i", "nc", 
"simd128")
+TARGET_BUILTIN(__builtin_wasm_extend_low_u_i32x4_i64x2, "V2LLUiV4Ui", "nc", 
"simd128")
+TARGET_BUILTIN(__builtin_wasm_extend_high_u_i32x4_i64x2, "V2LLUiV4Ui", "nc", 
"simd128")
 
 TARGET_BUILTIN(__builtin_wasm_convert_low_s_i32x4_f64x2, "V2dV4i", "nc", 
"simd

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

2021-03-18 Thread Thomas Lively 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 rGf5764a8654e3: [WebAssembly] Finalize SIMD names and opcodes 
(authored by tlively).

Changed prior to commit:
  https://reviews.llvm.org/D98676?vs=330859&id=331639#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98676

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

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

[PATCH] D98827: [AST] Ensure that an empty json file is generated if compile errors

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

Are there any tests that ensure something is always outputted?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98827

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


  1   2   >