[PATCH] D108449: [clang][NFC] Tighten up code for GetGlobalVarAddressSpace

2021-08-20 Thread Andy Wingo via Phabricator via cfe-commits
wingo created this revision.
Herald added a subscriber: Anastasia.
wingo requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

The LangAS local is only used in the OpenCL case; move its decl
inwards.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D108449

Files:
  clang/lib/CodeGen/CodeGenModule.cpp


Index: clang/lib/CodeGen/CodeGenModule.cpp
===
--- clang/lib/CodeGen/CodeGenModule.cpp
+++ clang/lib/CodeGen/CodeGenModule.cpp
@@ -4148,16 +4148,15 @@
 }
 
 LangAS CodeGenModule::GetGlobalVarAddressSpace(const VarDecl *D) {
-  LangAS AddrSpace = LangAS::Default;
   if (LangOpts.OpenCL) {
-AddrSpace = D ? D->getType().getAddressSpace() : LangAS::opencl_global;
-assert(AddrSpace == LangAS::opencl_global ||
-   AddrSpace == LangAS::opencl_global_device ||
-   AddrSpace == LangAS::opencl_global_host ||
-   AddrSpace == LangAS::opencl_constant ||
-   AddrSpace == LangAS::opencl_local ||
-   AddrSpace >= LangAS::FirstTargetAddressSpace);
-return AddrSpace;
+LangAS AS = D ? D->getType().getAddressSpace() : LangAS::opencl_global;
+assert(AS == LangAS::opencl_global ||
+   AS == LangAS::opencl_global_device ||
+   AS == LangAS::opencl_global_host ||
+   AS == LangAS::opencl_constant ||
+   AS == LangAS::opencl_local ||
+   AS >= LangAS::FirstTargetAddressSpace);
+return AS;
   }
 
   if (LangOpts.SYCLIsDevice &&


Index: clang/lib/CodeGen/CodeGenModule.cpp
===
--- clang/lib/CodeGen/CodeGenModule.cpp
+++ clang/lib/CodeGen/CodeGenModule.cpp
@@ -4148,16 +4148,15 @@
 }
 
 LangAS CodeGenModule::GetGlobalVarAddressSpace(const VarDecl *D) {
-  LangAS AddrSpace = LangAS::Default;
   if (LangOpts.OpenCL) {
-AddrSpace = D ? D->getType().getAddressSpace() : LangAS::opencl_global;
-assert(AddrSpace == LangAS::opencl_global ||
-   AddrSpace == LangAS::opencl_global_device ||
-   AddrSpace == LangAS::opencl_global_host ||
-   AddrSpace == LangAS::opencl_constant ||
-   AddrSpace == LangAS::opencl_local ||
-   AddrSpace >= LangAS::FirstTargetAddressSpace);
-return AddrSpace;
+LangAS AS = D ? D->getType().getAddressSpace() : LangAS::opencl_global;
+assert(AS == LangAS::opencl_global ||
+   AS == LangAS::opencl_global_device ||
+   AS == LangAS::opencl_global_host ||
+   AS == LangAS::opencl_constant ||
+   AS == LangAS::opencl_local ||
+   AS >= LangAS::FirstTargetAddressSpace);
+return AS;
   }
 
   if (LangOpts.SYCLIsDevice &&
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D108449: [clang][NFC] Tighten up code for GetGlobalVarAddressSpace

2021-08-20 Thread Andy Wingo via Phabricator via cfe-commits
wingo added a reviewer: rjmccall.
wingo added a comment.

Just a drive-by cleanup while poking other address-space-related things.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108449

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


[clang] 9ae9262 - [OpenCL] Fix version reporting of C++ for OpenCL 2021

2021-08-20 Thread Justas Janickas via cfe-commits

Author: Justas Janickas
Date: 2021-08-20T08:58:12+01:00
New Revision: 9ae9262857a1e7aadc385a68a00755896440f6b1

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

LOG: [OpenCL] Fix version reporting of C++ for OpenCL 2021

C++ for OpenCL version 2021 and later are expected to consist of a
major version number only. Therefore, a different constructor for
`VersionTuple` needs to be called when reporting language version.

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

Added: 


Modified: 
clang/lib/Basic/LangOptions.cpp

Removed: 




diff  --git a/clang/lib/Basic/LangOptions.cpp b/clang/lib/Basic/LangOptions.cpp
index 169b67949038..3e3e7fe3dc15 100644
--- a/clang/lib/Basic/LangOptions.cpp
+++ b/clang/lib/Basic/LangOptions.cpp
@@ -47,6 +47,8 @@ bool LangOptions::isNoBuiltinFunc(StringRef FuncName) const {
 
 VersionTuple LangOptions::getOpenCLVersionTuple() const {
   const int Ver = OpenCLCPlusPlus ? OpenCLCPlusPlusVersion : OpenCLVersion;
+  if (OpenCLCPlusPlus && Ver != 100)
+return VersionTuple(Ver / 100);
   return VersionTuple(Ver / 100, (Ver % 100) / 10);
 }
 



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


[PATCH] D108379: [OpenCL] Fix version reporting of C++ for OpenCL 2021

2021-08-20 Thread Justas Janickas via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG9ae9262857a1: [OpenCL] Fix version reporting of C++ for 
OpenCL 2021 (authored by Topotuna).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108379

Files:
  clang/lib/Basic/LangOptions.cpp


Index: clang/lib/Basic/LangOptions.cpp
===
--- clang/lib/Basic/LangOptions.cpp
+++ clang/lib/Basic/LangOptions.cpp
@@ -47,6 +47,8 @@
 
 VersionTuple LangOptions::getOpenCLVersionTuple() const {
   const int Ver = OpenCLCPlusPlus ? OpenCLCPlusPlusVersion : OpenCLVersion;
+  if (OpenCLCPlusPlus && Ver != 100)
+return VersionTuple(Ver / 100);
   return VersionTuple(Ver / 100, (Ver % 100) / 10);
 }
 


Index: clang/lib/Basic/LangOptions.cpp
===
--- clang/lib/Basic/LangOptions.cpp
+++ clang/lib/Basic/LangOptions.cpp
@@ -47,6 +47,8 @@
 
 VersionTuple LangOptions::getOpenCLVersionTuple() const {
   const int Ver = OpenCLCPlusPlus ? OpenCLCPlusPlusVersion : OpenCLVersion;
+  if (OpenCLCPlusPlus && Ver != 100)
+return VersionTuple(Ver / 100);
   return VersionTuple(Ver / 100, (Ver % 100) / 10);
 }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D108450: [clang][CodeGen] GetDefaultAlignTempAlloca uses preferred alignment

2021-08-20 Thread Andy Wingo via Phabricator via cfe-commits
wingo created this revision.
wingo added a reviewer: rjmccall.
wingo requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

This function was defaulting to use the ABI alignment for the LLVM
type.  Here we change to use the preferred alignment.  This will allow
unification with GetTempAlloca, which if alignment isn't specified, uses
the preferred alignment.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D108450

Files:
  clang/lib/CodeGen/CGExpr.cpp


Index: clang/lib/CodeGen/CGExpr.cpp
===
--- clang/lib/CodeGen/CGExpr.cpp
+++ clang/lib/CodeGen/CGExpr.cpp
@@ -122,7 +122,7 @@
 Address CodeGenFunction::CreateDefaultAlignTempAlloca(llvm::Type *Ty,
   const Twine &Name) {
   CharUnits Align =
-CharUnits::fromQuantity(CGM.getDataLayout().getABITypeAlignment(Ty));
+  CharUnits::fromQuantity(CGM.getDataLayout().getPrefTypeAlignment(Ty));
   return CreateTempAlloca(Ty, Align, Name);
 }
 


Index: clang/lib/CodeGen/CGExpr.cpp
===
--- clang/lib/CodeGen/CGExpr.cpp
+++ clang/lib/CodeGen/CGExpr.cpp
@@ -122,7 +122,7 @@
 Address CodeGenFunction::CreateDefaultAlignTempAlloca(llvm::Type *Ty,
   const Twine &Name) {
   CharUnits Align =
-CharUnits::fromQuantity(CGM.getDataLayout().getABITypeAlignment(Ty));
+  CharUnits::fromQuantity(CGM.getDataLayout().getPrefTypeAlignment(Ty));
   return CreateTempAlloca(Ty, Align, Name);
 }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D108451: [Sema] Avoid crash in CheckEnumConstant with contains-error expressions

2021-08-20 Thread Sam McCall via Phabricator via cfe-commits
sammccall created this revision.
sammccall added reviewers: hokein, guopeilin.
sammccall requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Fixes https://bugs.llvm.org/show_bug.cgi?id=51554


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D108451

Files:
  clang/lib/Sema/SemaDecl.cpp
  clang/test/Sema/enum.cpp


Index: clang/test/Sema/enum.cpp
===
--- /dev/null
+++ clang/test/Sema/enum.cpp
@@ -0,0 +1,9 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+enum Circular { // expected-note 2 {{not complete until the closing '}'}}
+  Circular_A = Circular(1), // expected-error {{'Circular' is an incomplete 
type}}
+  Circular_B = Circular(1)  // expected-error {{'Circular' is an incomplete 
type}}
+};
+// When initializers contain errors, enumerators are non-type-dependent zeros.
+static_assert(Circular_A != 0, ""); // expected-error {{static_assert failed}}
+static_assert(Circular_B != 0, ""); // expected-error {{static_assert failed}}
Index: clang/lib/Sema/SemaDecl.cpp
===
--- clang/lib/Sema/SemaDecl.cpp
+++ clang/lib/Sema/SemaDecl.cpp
@@ -17748,7 +17748,8 @@
 Val = DefaultLvalueConversion(Val).get();
 
   if (Val) {
-if (Enum->isDependentType() || Val->isTypeDependent())
+if (Enum->isDependentType() || Val->isTypeDependent() ||
+Val->containsErrors())
   EltTy = Context.DependentTy;
 else {
   // FIXME: We don't allow folding in C++11 mode for an enum with a fixed


Index: clang/test/Sema/enum.cpp
===
--- /dev/null
+++ clang/test/Sema/enum.cpp
@@ -0,0 +1,9 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+enum Circular { // expected-note 2 {{not complete until the closing '}'}}
+  Circular_A = Circular(1), // expected-error {{'Circular' is an incomplete type}}
+  Circular_B = Circular(1)  // expected-error {{'Circular' is an incomplete type}}
+};
+// When initializers contain errors, enumerators are non-type-dependent zeros.
+static_assert(Circular_A != 0, ""); // expected-error {{static_assert failed}}
+static_assert(Circular_B != 0, ""); // expected-error {{static_assert failed}}
Index: clang/lib/Sema/SemaDecl.cpp
===
--- clang/lib/Sema/SemaDecl.cpp
+++ clang/lib/Sema/SemaDecl.cpp
@@ -17748,7 +17748,8 @@
 Val = DefaultLvalueConversion(Val).get();
 
   if (Val) {
-if (Enum->isDependentType() || Val->isTypeDependent())
+if (Enum->isDependentType() || Val->isTypeDependent() ||
+Val->containsErrors())
   EltTy = Context.DependentTy;
 else {
   // FIXME: We don't allow folding in C++11 mode for an enum with a fixed
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D82657: [AST][RecoveryAST] Preserve the type by default for recovery expression.

2021-08-20 Thread Sam McCall via Phabricator via cfe-commits
sammccall added a comment.

In D82657#2956751 , @guopeilin wrote:

> Hi @hokein , I encounter a bug when clang parses enum and I have been 
> recorded in https://bugs.llvm.org/show_bug.cgi?id=51554.

I added a comment on the bug and sent https://reviews.llvm.org/D108451

This is a "rough edge" between erroneous and well-formed code and I'm not 
totally sure it's the perfect fix, but it does seem to be robust against 
crashes which is definitely he biggest thing.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82657

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


[PATCH] D108450: [clang][CodeGen] GetDefaultAlignTempAlloca uses preferred alignment

2021-08-20 Thread Andy Wingo via Phabricator via cfe-commits
wingo added a comment.

I tested by building with all targets enabled and there was no change in test 
results, running clang, llvm, and lld tests.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108450

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


[PATCH] D105177: [clangd] Implemented indexing of standard library

2021-08-20 Thread Christian Kühnel via Phabricator via cfe-commits
kuhnel marked an inline comment as done.
kuhnel added inline comments.



Comment at: clang-tools-extra/clangd/unittests/StdLibIndexTests.cpp:51
+  Req.AnyScope = true;
+  EXPECT_THAT(match(*Index, Req),
+  UnorderedElementsAre(llvm::StringRef("myfunc"),

nridge wrote:
> kuhnel wrote:
> > @sammccall I seem to be running into a use-after-free problem here. 
> > Debugging the whole thing shows that `Index` is pointing to an invalid 
> > address. So the problem is somewhere between returning the `unique_ptr` 
> > from `indexUmbrellaHeaders(...)` and assigning it to the `Index` variable.
> > 
> > Can you please take a look and give me a hint how to fix this?
> I think your issue may be that `Dex` doesn't actually take ownership of the 
> slabs that get passed to it; the slabs [need to outlive 
> it](https://searchfox.org/llvm/rev/cab7c52acdf508f73186dfe49b8cb012bb9129b2/clang-tools-extra/clangd/index/dex/Dex.h#39).
> 
> `Dex` has another constructor which allows it to also take ownership, and a 
> [Dex::build()](https://searchfox.org/llvm/rev/cab7c52acdf508f73186dfe49b8cb012bb9129b2/clang-tools-extra/clangd/index/dex/Dex.cpp#26)
>  helper function to call it -- you probably want to be using that.
Awesome, thx @nridge ! That fixed the use-after-free!
I was searching in the wrong place the whole time...


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105177

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


[PATCH] D106804: [test-suite] Add tests for FP classification intrinsics

2021-08-20 Thread Simon Pilgrim via Phabricator via cfe-commits
RKSimon added a comment.

Something I noticed is that we don't have much test coverage in 
clang/test/codegen for the fpclass intrinsics - including no constexpr testing 
afaict (although I don't think __builtin_fpclassify is constexpr yet) - is that 
something you'd be willing to take a look at?




Comment at: SingleSource/UnitTests/Float/classify.cpp:89
+assert(!__builtin_isnormal(*FPtr));
+assert(__builtin_fpclassify(0, 1, 2, 3, 4, *FPtr) == 0);
+  }

are asserts the best way to do this? most other unit tests print out something 
to help isolate diffs


Repository:
  rT test-suite

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

https://reviews.llvm.org/D106804

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


[PATCH] D105177: [clangd] Implemented indexing of standard library

2021-08-20 Thread Christian Kühnel via Phabricator via cfe-commits
kuhnel updated this revision to Diff 367737.
kuhnel marked an inline comment as done.
kuhnel added a comment.

addressed code review comments

also fixed use-after-free


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105177

Files:
  clang-tools-extra/clangd/CMakeLists.txt
  clang-tools-extra/clangd/ClangdServer.cpp
  clang-tools-extra/clangd/FS.cpp
  clang-tools-extra/clangd/FS.h
  clang-tools-extra/clangd/index/StdLib.cpp
  clang-tools-extra/clangd/index/StdLib.h
  clang-tools-extra/clangd/unittests/CMakeLists.txt
  clang-tools-extra/clangd/unittests/StdLibIndexTests.cpp

Index: clang-tools-extra/clangd/unittests/StdLibIndexTests.cpp
===
--- /dev/null
+++ clang-tools-extra/clangd/unittests/StdLibIndexTests.cpp
@@ -0,0 +1,60 @@
+//===-- StdLibIndexTests.cpp *- 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 "FuzzyMatch.h"
+#include "TestFS.h"
+#include "TestIndex.h"
+#include "index/StdLib.h"
+#include "support/Logger.h"
+#include "llvm/Support/Error.h"
+#include "llvm/Testing/Support/Error.h"
+#include "gmock/gmock.h"
+#include "gtest/gtest.h"
+#include 
+
+using namespace testing;
+
+namespace clang {
+namespace clangd {
+
+/// check that the generated header sources contains some usual standard library
+/// headers
+TEST(StdLibIndexTests, generateUmbrellaHeader) {
+  MockFS FS;
+  auto UmbrellaHeader = generateUmbrellaHeaders(StandardLibrarVariant::CXX14);
+
+  EXPECT_THAT(UmbrellaHeader, HasSubstr("#include "));
+  EXPECT_THAT(UmbrellaHeader, HasSubstr("#include "));
+  EXPECT_THAT(UmbrellaHeader, HasSubstr("#include "));
+}
+
+/// build the index and check if it contains the right symbols
+TEST(StdLibIndexTests, buildIndex) {
+  MockFS FS;
+  // TODO: maybe find a way to use a local libcxx for testing if that is
+  //   available on the machine
+  std::string HeaderMock = R"CPP(
+int myfunc(int a);
+bool otherfunc(int a, int b);
+  )CPP";
+  auto Index =
+  indexUmbrellaHeaders(HeaderMock, FS, StandardLibrarVariant::CXX14);
+  ASSERT_TRUE(Index != nullptr);
+
+  FuzzyFindRequest Req;
+  Req.AnyScope = true;
+  EXPECT_THAT(match(*Index, Req),
+  UnorderedElementsAre(llvm::StringRef("myfunc"),
+   llvm::StringRef("otherfunc")));
+}
+
+// TODO: add tests for indexStandardLibrary()
+// TODO: test with different library versions
+
+} // namespace clangd
+} // namespace clang
Index: clang-tools-extra/clangd/unittests/CMakeLists.txt
===
--- clang-tools-extra/clangd/unittests/CMakeLists.txt
+++ clang-tools-extra/clangd/unittests/CMakeLists.txt
@@ -79,6 +79,7 @@
   SemanticSelectionTests.cpp
   SerializationTests.cpp
   SourceCodeTests.cpp
+  StdLibIndexTests.cpp
   SymbolCollectorTests.cpp
   SymbolInfoTests.cpp
   SyncAPI.cpp
Index: clang-tools-extra/clangd/index/StdLib.h
===
--- /dev/null
+++ clang-tools-extra/clangd/index/StdLib.h
@@ -0,0 +1,55 @@
+//===--- StdLib.h *- 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
+//
+//===--===//
+// Clangd indexer for the C++ standard library.
+//
+// The index only contains symbols that are part of the translation unit. So
+// if your translation unit does not yet #include , you do not get
+// auto completion for std::string. However we expect that many users would
+// like to use the the standard library anyway, so we could index that by
+// default an offer e.g. code completion without requiring #includes.
+//===--===//
+
+#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANGD_INDEX_STDLIB_H
+#define LLVM_CLANG_TOOLS_EXTRA_CLANGD_INDEX_STDLIB_H
+
+#include "FS.h"
+#include "index/Index.h"
+#include "index/MemIndex.h"
+#include "support/ThreadsafeFS.h"
+#include "clang/AST/Expr.h"
+#include "llvm/ADT/StringRef.h"
+#include 
+
+namespace clang {
+namespace clangd {
+
+// Enumeration of supported Standard Library versions.
+// FIXME: support muiltiple languages (e.g. C and C++) and versions (e.g. 11,
+// 14, 17) of the standard library.
+// FIXME: add heuristic to detect this version somehow (magically).
+enum class StandardLibrarVariant { CXX14 = 0 };
+
+/// Generate a index of the standard library in

[PATCH] D108119: Wiring of standard library indexing into clangd.

2021-08-20 Thread Christian Kühnel via Phabricator via cfe-commits
kuhnel updated this revision to Diff 367738.
kuhnel added a comment.

addressed some review comments

question of integration with main functionality still open.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108119

Files:
  clang-tools-extra/clangd/ClangdServer.cpp
  clang-tools-extra/clangd/ClangdServer.h
  clang-tools-extra/clangd/tool/ClangdMain.cpp


Index: clang-tools-extra/clangd/tool/ClangdMain.cpp
===
--- clang-tools-extra/clangd/tool/ClangdMain.cpp
+++ clang-tools-extra/clangd/tool/ClangdMain.cpp
@@ -484,6 +484,18 @@
 init(true),
 };
 
+opt IndexStandardLibrary{
+"index-standard-library",
+cat(Features),
+desc("Background index should always include the STL headers even if \n"
+ "not used at the moment. This will enable code completion and \n"
+ "include fixer."
+ "WARNING: This option is experimental only, and will be removed "
+ "eventually. Don't rely on it"),
+init(false),
+Hidden,
+};
+
 std::function getMemoryCleanupFunction() {
   if (!EnableMallocTrim)
 return nullptr;
@@ -912,6 +924,7 @@
   if (ForceOffsetEncoding != OffsetEncoding::UnsupportedEncoding)
 Opts.Encoding = ForceOffsetEncoding;
 
+  Opts.IndexStandardLibrary = IndexStandardLibrary;
   if (CheckFile.getNumOccurrences()) {
 llvm::SmallString<256> Path;
 if (auto Error =
Index: clang-tools-extra/clangd/ClangdServer.h
===
--- clang-tools-extra/clangd/ClangdServer.h
+++ clang-tools-extra/clangd/ClangdServer.h
@@ -24,6 +24,7 @@
 #include "index/Background.h"
 #include "index/FileIndex.h"
 #include "index/Index.h"
+#include "index/StdLib.h"
 #include "refactor/Rename.h"
 #include "refactor/Tweak.h"
 #include "support/Cancellation.h"
@@ -167,7 +168,11 @@
 FeatureModuleSet *FeatureModules = nullptr;
 
 explicit operator TUScheduler::Options() const;
+
+// Automatically index the standard library - experimental feature
+bool IndexStandardLibrary = false;
   };
+
   // Sensible default options for use in tests.
   // Features like indexing must be enabled if desired.
   static Options optsForTest();
@@ -403,6 +408,8 @@
   std::unique_ptr BackgroundIdx;
   // Storage for merged views of the various indexes.
   std::vector> MergedIdx;
+  // If present, the index of the standard library.
+  std::unique_ptr StandardLibraryIdx;
 
   // When set, provides clang-tidy options for a specific file.
   TidyProviderRef ClangTidyProvider;
Index: clang-tools-extra/clangd/ClangdServer.cpp
===
--- clang-tools-extra/clangd/ClangdServer.cpp
+++ clang-tools-extra/clangd/ClangdServer.cpp
@@ -27,6 +27,7 @@
 #include "index/CanonicalIncludes.h"
 #include "index/FileIndex.h"
 #include "index/Merge.h"
+#include "index/StdLib.h"
 #include "refactor/Rename.h"
 #include "refactor/Tweak.h"
 #include "support/Logger.h"
@@ -175,6 +176,14 @@
   this->Index = Idx;
 }
   };
+  if (Opts.IndexStandardLibrary) {
+StandardLibraryIdx = indexStandardLibrary(TFS);
+if (!StandardLibraryIdx) {
+  elog("Unable to build standard library index. Not using it.");
+} else {
+  AddIndex(StandardLibraryIdx.get());
+}
+  }
   if (Opts.StaticIndex)
 AddIndex(Opts.StaticIndex);
   if (Opts.BackgroundIndex) {


Index: clang-tools-extra/clangd/tool/ClangdMain.cpp
===
--- clang-tools-extra/clangd/tool/ClangdMain.cpp
+++ clang-tools-extra/clangd/tool/ClangdMain.cpp
@@ -484,6 +484,18 @@
 init(true),
 };
 
+opt IndexStandardLibrary{
+"index-standard-library",
+cat(Features),
+desc("Background index should always include the STL headers even if \n"
+ "not used at the moment. This will enable code completion and \n"
+ "include fixer."
+ "WARNING: This option is experimental only, and will be removed "
+ "eventually. Don't rely on it"),
+init(false),
+Hidden,
+};
+
 std::function getMemoryCleanupFunction() {
   if (!EnableMallocTrim)
 return nullptr;
@@ -912,6 +924,7 @@
   if (ForceOffsetEncoding != OffsetEncoding::UnsupportedEncoding)
 Opts.Encoding = ForceOffsetEncoding;
 
+  Opts.IndexStandardLibrary = IndexStandardLibrary;
   if (CheckFile.getNumOccurrences()) {
 llvm::SmallString<256> Path;
 if (auto Error =
Index: clang-tools-extra/clangd/ClangdServer.h
===
--- clang-tools-extra/clangd/ClangdServer.h
+++ clang-tools-extra/clangd/ClangdServer.h
@@ -24,6 +24,7 @@
 #include "index/Background.h"
 #include "index/FileIndex.h"
 #include "index/Index.h"
+#include "index/StdLib.h"
 #include "refactor/Rename.h"
 #include "refactor/Tweak.h"
 #include "support/Cancellation.h"
@@ -167,7 +168,11 @@
 Feature

[PATCH] D108301: [MSP430][Clang] Update hard-coded MCU data

2021-08-20 Thread Jozef Lawrynowicz via Phabricator via cfe-commits
jozefl updated this revision to Diff 367739.
jozefl added a comment.

Here's an updated patch that stores the HWMult and CPU data for each MCU as
strings instead of enums. This simplifies the patch as string conversions to
and from enums are no longer required.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108301

Files:
  clang/include/clang/Basic/MSP430Target.def
  clang/lib/Driver/ToolChains/MSP430.cpp
  clang/test/Driver/msp430-hwmult.c
  clang/test/Driver/msp430-mmcu.c
  clang/test/Driver/msp430-toolchain.c

Index: clang/test/Driver/msp430-toolchain.c
===
--- clang/test/Driver/msp430-toolchain.c
+++ clang/test/Driver/msp430-toolchain.c
@@ -253,6 +253,10 @@
 // RUN:   | FileCheck -check-prefix=HWMult-32BIT %s
 // HWMult-32BIT: "--start-group" "-lmul_32"
 
+// RUN: %clang %s -### -no-canonical-prefixes -target msp430 -mmcu=msp430fr5969 --sysroot="" 2>&1 \
+// RUN:   | FileCheck -check-prefix=HWMult-F5 %s
+// RUN: %clang %s -### -no-canonical-prefixes -target msp430 -mmcu=msp430fr5969 -mhwmult=auto --sysroot="" 2>&1 \
+// RUN:   | FileCheck -check-prefix=HWMult-F5 %s
 // RUN: %clang %s -### -no-canonical-prefixes -target msp430 -mhwmult=f5series --sysroot="" 2>&1 \
 // RUN:   | FileCheck -check-prefix=HWMult-F5 %s
 // HWMult-F5: "--start-group" "-lmul_f5"
@@ -261,4 +265,10 @@
 // RUN:   | FileCheck -check-prefix=HWMult-NONE %s
 // RUN: %clang %s -### -no-canonical-prefixes -target msp430 -mhwmult=none -mmcu=msp430f4783 --sysroot="" 2>&1 \
 // RUN:   | FileCheck -check-prefix=HWMult-NONE %s
+// RUN: %clang %s -### -no-canonical-prefixes -target msp430 -mhwmult=auto -mmcu=msp430 --sysroot="" 2>&1 \
+// RUN:   | FileCheck -check-prefix=HWMult-NONE %s
+// RUN: %clang %s -### -no-canonical-prefixes -target msp430 -mhwmult=auto -mmcu=msp430x --sysroot="" 2>&1 \
+// RUN:   | FileCheck -check-prefix=HWMult-NONE %s
+// RUN: %clang %s -### -no-canonical-prefixes -target msp430 -mmcu=msp430xv2 --sysroot="" 2>&1 \
+// RUN:   | FileCheck -check-prefix=HWMult-NONE %s
 // HWMult-NONE: "--start-group" "-lmul_none"
Index: clang/test/Driver/msp430-mmcu.c
===
--- clang/test/Driver/msp430-mmcu.c
+++ clang/test/Driver/msp430-mmcu.c
@@ -1,15 +1,62 @@
+// This file tests that various different values passed to -mmcu= select the
+// correct target features and linker scripts, and create MCU-specific defines.
+
+// Test the lexicographic ordering of MCUs in MSP430Target.def.
+//
+// The MCU "msp430f110" should appear before "msp430f1101" when the data has
+// been sorted lexicographically. Some sorts will put "msp430f110" *after*
+// "msp430f1101", so when this happens, Clang will not be able to find this MCU.
+
+// RUN: %clang %s -### -no-canonical-prefixes -target msp430 -mmcu=msp430f110 2>&1 \
+// RUN:   | FileCheck %s
+
+// RUN: %clang %s -### -no-canonical-prefixes -target msp430 -mmcu=msp430f1101 2>&1 \
+// RUN:   | FileCheck %s
+
+// RUN: %clang %s -### -no-canonical-prefixes -target msp430 -mmcu=msp430f1101a 2>&1 \
+// RUN:   | FileCheck %s
+
+// CHECK-NOT: error: the clang compiler does not support
+
+// Test the symbol definitions, linker scripts and hardware multiply features
+// selected for different MCUs.
+
 // RUN: %clang %s -### -no-canonical-prefixes -target msp430 -mmcu=msp430c111 2>&1 \
 // RUN:   | FileCheck -check-prefix=MSP430-C111 %s
 
 // MSP430-C111: clang{{.*}} "-cc1" {{.*}} "-D__MSP430C111__"
+// MSP430-C111-NOT: "-target-feature" "+hwmult16"
+// MSP430-C111-NOT: "-target-feature" "+hwmult32"
+// MSP430-C111-NOT: "-target-feature" "+hwmultf5"
 // MSP430-C111: msp430-elf-ld{{.*}} "-Tmsp430c111.ld"
 
 // RUN: %clang %s -### -no-canonical-prefixes -target msp430 -mmcu=msp430i2020 2>&1 \
 // RUN:   | FileCheck -check-prefix=MSP430-I2020 %s
 
 // MSP430-I2020: clang{{.*}} "-cc1" {{.*}} "-D__MSP430i2020__"
+// MSP430-I2020: "-target-feature" "+hwmult16"
 // MSP430-I2020: msp430-elf-ld{{.*}} "-Tmsp430i2020.ld"
 
+// RUN: %clang %s -### -no-canonical-prefixes -target msp430 -mmcu=msp430f47126 2>&1 \
+// RUN:   | FileCheck -check-prefix=MSP430-F47126 %s
+
+// MSP430-F47126: clang{{.*}} "-cc1" {{.*}} "-D__MSP430F47126__"
+// MSP430-F47126: "-target-feature" "+hwmult32"
+// MSP430-F47126: msp430-elf-ld{{.*}} "-Tmsp430f47126.ld"
+
+// RAN: %clang %s -### -no-canonical-prefixes -target msp430 -mmcu=msp430fr5969 2>&1 \
+// RAN:   | FileCheck -check-prefix=MSP430-FR5969 %s
+
+// MSP430-FR5969: clang{{.*}} "-cc1" {{.*}} "-D__MSP430FR5969__"
+// MSP430-FR5969: "-target-feature" "+hwmultf5"
+// MSP430-FR5969: msp430-elf-ld{{.*}} "-Tmsp430fr5969.ld"
+
+// Test for the error message emitted when an invalid MCU is selected.
+//
+// Note that if this test is ever modified because the expected error message is
+// changed, the check prefixes at the top of this file, used to validate the
+// ordering of the hard-c

[PATCH] D108119: Wiring of standard library indexing into clangd.

2021-08-20 Thread Sam McCall via Phabricator via cfe-commits
sammccall accepted this revision.
sammccall added a comment.
This revision is now accepted and ready to land.

LG with the understanding that we'll have to move this to be more sophisticated 
later later, but it's useful to have the simple version now.
Similarly I think it's OK to add the tests later too as this version is 
experimental & safe.




Comment at: clang-tools-extra/clangd/ClangdServer.cpp:180
+  if (Opts.IndexStandardLibrary) {
+StandardLibraryIdx = indexStandardLibrary(TFS);
+if (!StandardLibraryIdx) {

add a FIXME that this happens synchronously, and can't respond to langopts or 
config and I think we're good to go as an experimental feature



Comment at: clang-tools-extra/clangd/ClangdServer.h:412
+  // If present, the index of the standard library.
+  std::unique_ptr StandardLibraryIdx;
 

You can push this into MergedIdx for storage. The reason for DynamicIdx and 
BackgroundIdx having dedicated variables is that they have special APIs we need 
to access.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108119

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


[PATCH] D105177: [clangd] Implemented indexing of standard library

2021-08-20 Thread Sam McCall via Phabricator via cfe-commits
sammccall accepted this revision.
sammccall added a comment.
This revision is now accepted and ready to land.

Remainder is just nits, looks good!




Comment at: clang-tools-extra/clangd/FS.cpp:126
+  // safely assume to exist is "/".
+  return "/";
+#endif

"/virtual/"



Comment at: clang-tools-extra/clangd/index/StdLib.cpp:79
+  // FIXME: add flags more language variants
+  if (LibraryVariant == StandardLibrarVariant::CXX14) {
+Inputs.CompileCommand.CommandLine.push_back("-xc++-header");

nit: the unhandled case can't dynamically happen. This should probably be a 
switch, and the `default:` case should be llvm_unreachable("Unhandled language 
variant")



Comment at: clang-tools-extra/clangd/index/StdLib.cpp:104
+  if (!Clang) {
+elog("tandard Library Index: Couldn't build compiler instance");
+return nullptr;

tandard -> Standard



Comment at: clang-tools-extra/clangd/index/StdLib.cpp:117
+  if (!Action->BeginSourceFile(*Clang, Input)) {
+elog("Standard Library Index:BeginSourceFile() failed");
+return nullptr;

missing space after colon



Comment at: clang-tools-extra/clangd/index/StdLib.cpp:122
+  if (llvm::Error Err = Action->Execute()) {
+elog(toString(std::move(Err)).c_str());
+return nullptr;

elog("Standard Library Index: {0}", std::move(Err));



Comment at: clang-tools-extra/clangd/index/StdLib.h:34
+// 14, 17) of the standard library.
+// FIXME: add heuristic to detect this version somehow (magically).
+enum class StandardLibrarVariant { CXX14 = 0 };

The somehow/magically is by looking at the clang::LangOptions of the file being 
parsed :-)
This can happen if/when we move the triggering into TUScheduler which obtains 
and parses the command line flags.

Concretely I'd expect to resolve this FIXME by adding some function like 
`Optional chooseStandardLibrary(const LangOptions&)`

If this makes sense to you, you might want to make the comment a bit less 
hand-wavy



Comment at: clang-tools-extra/clangd/index/StdLib.h:35
+// FIXME: add heuristic to detect this version somehow (magically).
+enum class StandardLibrarVariant { CXX14 = 0 };
+

librarVariant ->libraryVariant



Comment at: clang-tools-extra/clangd/index/StdLib.h:38
+/// Generate a index of the standard library index for a given variant of
+/// the standard library. This index can be included if the translation unit
+/// does not (yet) contain any standard library headers.

I'd say rather "this index allows completion of standard library symbols whose 
headers have not been included yet".

The current text implies that we'd turn this off once we see `#include 
`, thus breaking completion of e.g `unordered_map`. I don't think we 
want to.



Comment at: clang-tools-extra/clangd/index/StdLib.h:40
+/// does not (yet) contain any standard library headers.
+std::unique_ptr indexStandardLibrary(const ThreadsafeFS &TFS);
+

Sorry, I think I wasn't clear: the language variant should still be a parameter 
here, it just shouldn't have a default value. Instead the caller should pass it 
explicitly, this makes it obvious at the callsite that there's an imperfect 
assumption being made.



Comment at: clang-tools-extra/clangd/index/StdLib.h:45
+std::unique_ptr
+indexUmbrellaHeaders(llvm::StringRef HeaderSources, const ThreadsafeFS &TFS,
+ const StandardLibrarVariant &LibraryVariant);

nit: umbrellaHeader singular. (The umbrella is the file mapped to 
HeaderSources, the headers it includes are not umbrella headers for our 
purposes)



Comment at: clang-tools-extra/clangd/index/StdLib.h:46
+indexUmbrellaHeaders(llvm::StringRef HeaderSources, const ThreadsafeFS &TFS,
+ const StandardLibrarVariant &LibraryVariant);
+

enums are passed by value, not const reference
(and below)



Comment at: clang-tools-extra/clangd/index/StdLib.h:48
+
+/// generate header containing #includes for all standard library headers
+llvm::StringRef

nit: capitalization


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105177

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


[PATCH] D105169: [Clang/Test]: Enable enable_noundef_analysis as default

2021-08-20 Thread Hyeongyu Kim via Phabricator via cfe-commits
hyeongyukim updated this revision to Diff 367746.
hyeongyukim added a comment.
Herald added subscribers: cfe-commits, dexonsmith.

Changed `disable_noundef_args` flag to `enable_noundef_args` to enable emitting 
`noundef` attributes on IR call arguments and return values by default.
Changed test codes will be attached at another PR.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105169

Files:
  clang/include/clang/Basic/CodeGenOptions.def
  clang/include/clang/Driver/Options.td
  clang/lib/CodeGen/CGCall.cpp


Index: clang/lib/CodeGen/CGCall.cpp
===
--- clang/lib/CodeGen/CGCall.cpp
+++ clang/lib/CodeGen/CGCall.cpp
@@ -2258,7 +2258,7 @@
  getLangOpts().Sanitize.has(SanitizerKind::Return);
 
   // Determine if the return type could be partially undef
-  if (CodeGenOpts.EnableNoundefAttrs && HasStrictReturn) {
+  if (!CodeGenOpts.DisableNoundefAttrs && HasStrictReturn) {
 if (!RetTy->isVoidType() && RetAI.getKind() != ABIArgInfo::Indirect &&
 DetermineNoUndef(RetTy, getTypes(), DL, RetAI))
   RetAttrs.addAttribute(llvm::Attribute::NoUndef);
@@ -2393,7 +2393,7 @@
 
 // Decide whether the argument we're handling could be partially undef
 bool ArgNoUndef = DetermineNoUndef(ParamType, getTypes(), DL, AI);
-if (CodeGenOpts.EnableNoundefAttrs && ArgNoUndef)
+if (!CodeGenOpts.DisableNoundefAttrs && ArgNoUndef)
   Attrs.addAttribute(llvm::Attribute::NoUndef);
 
 // 'restrict' -> 'noalias' is done in EmitFunctionProlog when we
Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -5260,9 +5260,9 @@
 def disable_free : Flag<["-"], "disable-free">,
   HelpText<"Disable freeing of memory on exit">,
   MarshallingInfoFlag>;
-def enable_noundef_analysis : Flag<["-"], "enable-noundef-analysis">, 
Group,
-  HelpText<"Enable analyzing function argument and return types for mandatory 
definedness">,
-  MarshallingInfoFlag>;
+def disable_noundef_analysis : Flag<["-"], "disable-noundef-args">, 
Group,
+  HelpText<"Disable analyzing function argument and return types for mandatory 
definedness">,
+  MarshallingInfoFlag>;
 def discard_value_names : Flag<["-"], "discard-value-names">,
   HelpText<"Discard value names in LLVM IR">,
   MarshallingInfoFlag>;
Index: clang/include/clang/Basic/CodeGenOptions.def
===
--- clang/include/clang/Basic/CodeGenOptions.def
+++ clang/include/clang/Basic/CodeGenOptions.def
@@ -63,7 +63,7 @@
 CODEGENOPT(DisableO0ImplyOptNone , 1, 0) ///< Don't annonate function with 
optnone at O0
 CODEGENOPT(ExperimentalStrictFloatingPoint, 1, 0) ///< Enables the new, 
experimental
   ///< strict floating point.
-CODEGENOPT(EnableNoundefAttrs, 1, 0) ///< Enable emitting `noundef` attributes 
on IR call arguments and return values
+CODEGENOPT(DisableNoundefAttrs, 1, 0) ///< Disable emitting `noundef` 
attributes on IR call arguments and return values
 CODEGENOPT(LegacyPassManager, 1, 0) ///< Use the legacy pass manager.
 CODEGENOPT(DebugPassManager, 1, 0) ///< Prints debug information for the new
///< pass manager.


Index: clang/lib/CodeGen/CGCall.cpp
===
--- clang/lib/CodeGen/CGCall.cpp
+++ clang/lib/CodeGen/CGCall.cpp
@@ -2258,7 +2258,7 @@
  getLangOpts().Sanitize.has(SanitizerKind::Return);
 
   // Determine if the return type could be partially undef
-  if (CodeGenOpts.EnableNoundefAttrs && HasStrictReturn) {
+  if (!CodeGenOpts.DisableNoundefAttrs && HasStrictReturn) {
 if (!RetTy->isVoidType() && RetAI.getKind() != ABIArgInfo::Indirect &&
 DetermineNoUndef(RetTy, getTypes(), DL, RetAI))
   RetAttrs.addAttribute(llvm::Attribute::NoUndef);
@@ -2393,7 +2393,7 @@
 
 // Decide whether the argument we're handling could be partially undef
 bool ArgNoUndef = DetermineNoUndef(ParamType, getTypes(), DL, AI);
-if (CodeGenOpts.EnableNoundefAttrs && ArgNoUndef)
+if (!CodeGenOpts.DisableNoundefAttrs && ArgNoUndef)
   Attrs.addAttribute(llvm::Attribute::NoUndef);
 
 // 'restrict' -> 'noalias' is done in EmitFunctionProlog when we
Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -5260,9 +5260,9 @@
 def disable_free : Flag<["-"], "disable-free">,
   HelpText<"Disable freeing of memory on exit">,
   MarshallingInfoFlag>;
-def enable_noundef_analysis : Flag<["-"], "enable-noundef-analysis">, Group,
-  HelpText<"Enable analyzing function argument and return types

[PATCH] D108150: [Remarks] [AMDGPU] Emit optimization remarks for atomics generating hardware instructions

2021-08-20 Thread Anshil Gandhi via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG508b06699a39: [Remarks] [AMDGPU] Emit optimization remarks 
for atomics generating hardware… (authored by gandhi21299).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108150

Files:
  clang/test/CodeGenOpenCL/atomics-cas-remarks-gfx90a.cl
  clang/test/CodeGenOpenCL/atomics-remarks-gfx90a.cl
  clang/test/CodeGenOpenCL/atomics-unsafe-hw-remarks-gfx90a.cl
  llvm/lib/CodeGen/AtomicExpandPass.cpp
  llvm/lib/Target/AMDGPU/SIISelLowering.cpp
  llvm/test/CodeGen/AMDGPU/atomics-cas-remarks-gfx90a.ll
  llvm/test/CodeGen/AMDGPU/atomics-hw-remarks-gfx90a.ll
  llvm/test/CodeGen/AMDGPU/atomics-remarks-gfx90a.ll

Index: llvm/test/CodeGen/AMDGPU/atomics-hw-remarks-gfx90a.ll
===
--- /dev/null
+++ llvm/test/CodeGen/AMDGPU/atomics-hw-remarks-gfx90a.ll
@@ -0,0 +1,95 @@
+; RUN: llc -march=amdgcn -mcpu=gfx90a -verify-machineinstrs --pass-remarks=si-lower \
+; RUN:  %s -o - 2>&1 | FileCheck %s --check-prefix=GFX90A-HW
+
+; GFX90A-HW: Hardware instruction generated for atomic fadd operation at memory scope system due to an unsafe request.
+; GFX90A-HW: Hardware instruction generated for atomic fadd operation at memory scope agent due to an unsafe request.
+; GFX90A-HW: Hardware instruction generated for atomic fadd operation at memory scope workgroup due to an unsafe request.
+; GFX90A-HW: Hardware instruction generated for atomic fadd operation at memory scope wavefront due to an unsafe request.
+; GFX90A-HW: Hardware instruction generated for atomic fadd operation at memory scope singlethread due to an unsafe request.
+; GFX90A-HW: Hardware instruction generated for atomic fadd operation at memory scope agent-one-as due to an unsafe request.
+; GFX90A-HW: Hardware instruction generated for atomic fadd operation at memory scope workgroup-one-as due to an unsafe request.
+; GFX90A-HW: Hardware instruction generated for atomic fadd operation at memory scope wavefront-one-as due to an unsafe request.
+; GFX90A-HW: Hardware instruction generated for atomic fadd operation at memory scope singlethread-one-as due to an unsafe request.
+
+; GFX90A-HW-LABEL: atomic_add_unsafe_hw:
+; GFX90A-HW:ds_add_f64 v2, v[0:1]
+; GFX90A-HW:s_endpgm
+define amdgpu_kernel void @atomic_add_unsafe_hw(double addrspace(3)* %ptr) #0 {
+main_body:
+  %ret = atomicrmw fadd double addrspace(3)* %ptr, double 4.0 seq_cst
+  ret void
+}
+
+; GFX90A-HW-LABEL: atomic_add_unsafe_hw_agent:
+; GFX90A-HW:global_atomic_add_f32 v0, v1, s[2:3]
+; GFX90A-HW:s_endpgm
+define amdgpu_kernel void @atomic_add_unsafe_hw_agent(float addrspace(1)* %ptr, float %val) #0 {
+main_body:
+  %ret = atomicrmw fadd float addrspace(1)* %ptr, float %val syncscope("agent") monotonic, align 4
+  ret void
+}
+
+; GFX90A-HW-LABEL: atomic_add_unsafe_hw_wg:
+; GFX90A-HW:global_atomic_add_f32 v0, v1, s[2:3]
+; GFX90A-HW:s_endpgm
+define amdgpu_kernel void @atomic_add_unsafe_hw_wg(float addrspace(1)* %ptr, float %val) #0 {
+main_body:
+  %ret = atomicrmw fadd float addrspace(1)* %ptr, float %val syncscope("workgroup") monotonic, align 4
+  ret void
+}
+
+; GFX90A-HW-LABEL: atomic_add_unsafe_hw_wavefront:
+; GFX90A-HW:global_atomic_add_f32 v0, v1, s[2:3]
+; GFX90A-HW:s_endpgm
+define amdgpu_kernel void @atomic_add_unsafe_hw_wavefront(float addrspace(1)* %ptr, float %val) #0 {
+main_body:
+  %ret = atomicrmw fadd float addrspace(1)* %ptr, float %val syncscope("wavefront") monotonic, align 4
+  ret void
+}
+
+; GFX90A-HW-LABEL: atomic_add_unsafe_hw_single_thread:
+; GFX90A-HW:global_atomic_add_f32 v0, v1, s[2:3]
+; GFX90A-HW:s_endpgm
+define amdgpu_kernel void @atomic_add_unsafe_hw_single_thread(float addrspace(1)* %ptr, float %val) #0 {
+main_body:
+  %ret = atomicrmw fadd float addrspace(1)* %ptr, float %val syncscope("singlethread") monotonic, align 4
+  ret void
+}
+
+; GFX90A-HW-LABEL: atomic_add_unsafe_hw_aoa:
+; GFX90A-HW:global_atomic_add_f32 v0, v1, s[2:3]
+; GFX90A-HW:s_endpgm
+define amdgpu_kernel void @atomic_add_unsafe_hw_aoa(float addrspace(1)* %ptr, float %val) #0 {
+main_body:
+  %ret = atomicrmw fadd float addrspace(1)* %ptr, float %val syncscope("agent-one-as") monotonic, align 4
+  ret void
+}
+
+; GFX90A-HW-LABEL: atomic_add_unsafe_hw_wgoa:
+; GFX90A-HW:global_atomic_add_f32 v0, v1, s[2:3]
+; GFX90A-HW:s_endpgm
+define amdgpu_kernel void @atomic_add_unsafe_hw_wgoa(float addrspace(1)* %ptr, float %val) #0 {
+main_body:
+  %ret = atomicrmw fadd float addrspace(1)* %ptr, float %val syncscope("workgroup-one-as") monotonic, align 4
+  ret void
+}
+
+; GFX90A-HW-LABEL: atomic_add_unsafe_hw_wfoa:
+; GFX90A-HW:global_atomic_add_f32 v0, v1, s[2:3]
+; GFX90A-HW:s_endpgm
+define amdgpu_kernel void @atomic_add_unsafe_hw_wfoa(float addrspace(1)* %ptr, float %val) #0 {
+main_body:
+  %ret = 

[PATCH] D108453: [Clang/Test]: Enable enable_noundef_analysis as default(2)

2021-08-20 Thread Hyeongyu Kim via Phabricator via cfe-commits
hyeongyukim created this revision.
Herald added subscribers: mstorsjo, frasercrmck, lxfind, jdoerfert, kerbowa, 
luismarques, apazos, sameer.abuasal, pengfei, s.egerton, Jim, jocewei, PkmX, 
jfb, arphaman, the_o, brucehoult, MartinMosbeck, rogfer01, atanasyan, 
edward-jones, zzheng, jrtc27, delcypher, niosHD, sabuasal, simoncook, 
johnrusso, rbar, asb, fedor.sergeev, kbarton, jgravelle-google, sbc100, 
nhaehnle, jvesely, nemanjai, dylanmckay, jyknight, dschuff.
hyeongyukim requested review of this revision.
Herald added subscribers: llvm-commits, cfe-commits, sstefan1, MaskRay, aheejin.
Herald added a reviewer: jdoerfert.
Herald added projects: clang, LLVM.

This patch contains changed test files made by D105169 
.
Autogenerated test codes are changed by `utils/update_cc_test_checks.py,` and 
non-autogenerated test codes are changed manually.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D108453

Files:
  clang/test/CXX/except/except.spec/p14-ir.cpp
  clang/test/CXX/expr/expr.prim/expr.prim.lambda/blocks-irgen.mm
  clang/test/CodeGen/2006-05-19-SingleEltReturn.c
  clang/test/CodeGen/2007-06-18-SextAttrAggregate.c
  clang/test/CodeGen/2009-02-13-zerosize-union-field.c
  clang/test/CodeGen/2009-05-04-EnumInreg.c
  clang/test/CodeGen/64bit-swiftcall.c
  clang/test/CodeGen/RISCV/riscv-inline-asm.c
  clang/test/CodeGen/RISCV/riscv32-ilp32-abi.c
  clang/test/CodeGen/RISCV/riscv32-ilp32-ilp32f-abi.c
  clang/test/CodeGen/RISCV/riscv32-ilp32-ilp32f-ilp32d-abi.c
  clang/test/CodeGen/RISCV/riscv32-ilp32d-abi.c
  clang/test/CodeGen/RISCV/riscv32-ilp32f-abi.c
  clang/test/CodeGen/RISCV/riscv32-ilp32f-ilp32d-abi.c
  clang/test/CodeGen/RISCV/riscv64-lp64-abi.c
  clang/test/CodeGen/RISCV/riscv64-lp64-lp64f-abi.c
  clang/test/CodeGen/RISCV/riscv64-lp64-lp64f-lp64d-abi.c
  clang/test/CodeGen/RISCV/riscv64-lp64d-abi.c
  clang/test/CodeGen/RISCV/riscv64-lp64f-lp64d-abi.c
  clang/test/CodeGen/SystemZ/systemz-abi-vector.c
  clang/test/CodeGen/SystemZ/systemz-abi.c
  clang/test/CodeGen/SystemZ/systemz-inline-asm.c
  clang/test/CodeGen/WebAssembly/wasm-arguments.c
  clang/test/CodeGen/WebAssembly/wasm-main_argc_argv.c
  clang/test/CodeGen/X86/avx-union.c
  clang/test/CodeGen/X86/avx512fp16-complex-abi.c
  clang/test/CodeGen/X86/ms-x86-intrinsics.c
  clang/test/CodeGen/X86/strictfp_builtins.c
  clang/test/CodeGen/X86/x86-atomic-long_double.c
  clang/test/CodeGen/X86/x86-inline-asm-min-vector-width.c
  clang/test/CodeGen/X86/x86-long-double.cpp
  clang/test/CodeGen/X86/x86-soft-float.c
  clang/test/CodeGen/X86/x86-vec-i128.c
  clang/test/CodeGen/X86/x86_32-arguments-darwin.c
  clang/test/CodeGen/X86/x86_32-arguments-iamcu.c
  clang/test/CodeGen/X86/x86_32-arguments-linux.c
  clang/test/CodeGen/X86/x86_32-arguments-nommx.c
  clang/test/CodeGen/X86/x86_32-arguments-realign.c
  clang/test/CodeGen/X86/x86_32-arguments-win32.c
  clang/test/CodeGen/X86/x86_64-arguments-nacl.c
  clang/test/CodeGen/X86/x86_64-arguments-win32.c
  clang/test/CodeGen/X86/x86_64-arguments.c
  clang/test/CodeGen/X86/x86_64-longdouble.c
  clang/test/CodeGen/aapcs-align.cpp
  clang/test/CodeGen/aapcs64-align.cpp
  clang/test/CodeGen/aarch64-args.cpp
  clang/test/CodeGen/aarch64-byval-temp.c
  clang/test/CodeGen/aarch64-neon-3v.c
  clang/test/CodeGen/aarch64-neon-across.c
  clang/test/CodeGen/aarch64-neon-dot-product.c
  clang/test/CodeGen/aarch64-neon-extract.c
  clang/test/CodeGen/aarch64-neon-fcvt-intrinsics.c
  clang/test/CodeGen/aarch64-neon-fma.c
  clang/test/CodeGen/aarch64-neon-ldst-one.c
  clang/test/CodeGen/aarch64-neon-scalar-copy.c
  clang/test/CodeGen/aarch64-neon-scalar-x-indexed-elem.c
  clang/test/CodeGen/aarch64-neon-tbl.c
  clang/test/CodeGen/aarch64-neon-vcombine.c
  clang/test/CodeGen/aarch64-neon-vget-hilo.c
  clang/test/CodeGen/aarch64-neon-vget.c
  clang/test/CodeGen/aarch64-poly128.c
  clang/test/CodeGen/aarch64-poly64.c
  clang/test/CodeGen/aarch64-strictfp-builtins.c
  clang/test/CodeGen/aarch64-sve-acle-__ARM_FEATURE_SVE_VECTOR_OPERATORS.c
  clang/test/CodeGen/aarch64-sve-acle-__ARM_FEATURE_SVE_VECTOR_OPERATORS.cpp
  clang/test/CodeGen/aarch64-varargs.c
  clang/test/CodeGen/address-space-field1.c
  clang/test/CodeGen/address-space.c
  clang/test/CodeGen/aix-alignment.c
  clang/test/CodeGen/aix-altivec.c
  clang/test/CodeGen/aix-ignore-xcoff-visibility.cpp
  clang/test/CodeGen/aix-return.c
  clang/test/CodeGen/aix-struct-arg.c
  clang/test/CodeGen/aix-vaargs.c
  clang/test/CodeGen/alias.c
  clang/test/CodeGen/align_value.cpp
  clang/test/CodeGen/alloc-align-attr.c
  clang/test/CodeGen/alloc-size-fnptr.c
  clang/test/CodeGen/arc/arguments.c
  clang/test/CodeGen/arithmetic-fence-builtin.c
  clang/test/CodeGen/arm-aapcs-vfp.c
  clang/test/CodeGen/arm-abi-vector.c
  clang/test/CodeGen/arm-arguments.c
  clang/test/CodeGen/arm-bf16-params-returns.c
  clang/test/CodeGen/arm-byval-align.c
  clang/test/CodeGen/arm-cmse-attr.c
  clang/test/CodeGen/arm-cmse-call.c
  clang/test/CodeGen/arm-float-h

[PATCH] D108453: [Clang/Test]: Enable enable_noundef_analysis as default(2)

2021-08-20 Thread Hyeongyu Kim via Phabricator via cfe-commits
hyeongyukim added a comment.

This and D105169  are renewed version of the 
old patch (D82317 ).
When pushing to the main branch, I'll commit this and D105169 
 as a single commit to avoid CI failure.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108453

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


[PATCH] D108403: Fix assertion when generating diagnostic for inline namespaces

2021-08-20 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

In D108403#2955651 , @erichkeane 
wrote:

> This whole function seems a little suspect, but I don't have a good example 
> of a place it would break.  Is there no cases where a lookup could result in 
> the same COUNT but different declaration set? I guess it is more the question 
> of whether a transparent context can 'lose' a name lookup (perhaps a case of 
> conflicting names?), then have it added by the local namespace.

I don't believe transparent contexts can lose a name lookup -- they're 
transparent, so the declarations aren't owned by that context, they're owned by 
the first non-transparent context they run into (as I understand it, anyway). 
However, the important bit on this patch is: `lookup()` asserts that you're not 
trying to call it on a transparent context, so that tells me that we should 
walk until we find a non-transparent context rather than the current approach 
of assuming the parent is not transparent.




Comment at: clang/include/clang/AST/Decl.h:620
+const DeclContext *Parent = getParent();
+while (Parent->isTransparentContext())
+  Parent = Parent->getParent();

erichkeane wrote:
> This loop seems useful enough to be its own function in DeclContext?  I think 
> I remember seeing us do this for a different patch, right?
This pattern does appear in the code base a few places; I could add a new 
helper method.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108403

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


[PATCH] D108029: [clang][Codegen] Introduce the disable_sanitizer_instrumentation attribute

2021-08-20 Thread Alexander Potapenko via Phabricator via cfe-commits
glider updated this revision to Diff 367759.
glider added a comment.

Updated LangRef.rst


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108029

Files:
  clang/include/clang/Basic/Attr.td
  clang/include/clang/Basic/AttrDocs.td
  clang/lib/CodeGen/CodeGenFunction.cpp
  clang/lib/CodeGen/CodeGenFunction.h
  clang/test/CodeGen/attr-disable-sanitizer-instrumentation.c
  clang/test/Misc/pragma-attribute-supported-attributes-list.test
  llvm/docs/BitCodeFormat.rst
  llvm/docs/LangRef.rst
  llvm/include/llvm/AsmParser/LLToken.h
  llvm/include/llvm/Bitcode/LLVMBitCodes.h
  llvm/include/llvm/IR/Attributes.td
  llvm/lib/AsmParser/LLLexer.cpp
  llvm/lib/Bitcode/Reader/BitcodeReader.cpp
  llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
  llvm/lib/Transforms/Utils/CodeExtractor.cpp
  llvm/test/Bitcode/attributes.ll
  llvm/test/Bitcode/compatibility.ll

Index: llvm/test/Bitcode/compatibility.ll
===
--- llvm/test/Bitcode/compatibility.ll
+++ llvm/test/Bitcode/compatibility.ll
@@ -1510,7 +1510,7 @@
   ; CHECK: select <2 x i1> , <2 x i8> , <2 x i8> 
 
   call void @f.nobuiltin() builtin
-  ; CHECK: call void @f.nobuiltin() #45
+  ; CHECK: call void @f.nobuiltin() #46
 
   call fastcc noalias i32* @f.noalias() noinline
   ; CHECK: call fastcc noalias i32* @f.noalias() #12
@@ -1907,6 +1907,9 @@
 declare void @f.nosanitize_coverage() nosanitize_coverage
 ; CHECK: declare void @f.nosanitize_coverage() #44
 
+declare void @f.disable_sanitizer_instrumentation() disable_sanitizer_instrumentation
+; CHECK: declare void @f.disable_sanitizer_instrumentation() #45
+
 ; immarg attribute
 declare void @llvm.test.immarg.intrinsic(i32 immarg)
 ; CHECK: declare void @llvm.test.immarg.intrinsic(i32 immarg)
@@ -1965,7 +1968,8 @@
 ; CHECK: attributes #42 = { speculatable }
 ; CHECK: attributes #43 = { strictfp }
 ; CHECK: attributes #44 = { nosanitize_coverage }
-; CHECK: attributes #45 = { builtin }
+; CHECK: attributes #45 = { disable_sanitizer_instrumentation }
+; CHECK: attributes #46 = { builtin }
 
 ;; Metadata
 
Index: llvm/test/Bitcode/attributes.ll
===
--- llvm/test/Bitcode/attributes.ll
+++ llvm/test/Bitcode/attributes.ll
@@ -472,6 +472,12 @@
   ret void
 }
 
+; CHECK: define void @f80() #50
+define void @f80() disable_sanitizer_instrumentation
+{
+ret void;
+}
+
 ; CHECK: attributes #0 = { noreturn }
 ; CHECK: attributes #1 = { nounwind }
 ; CHECK: attributes #2 = { readnone }
@@ -522,4 +528,5 @@
 ; CHECK: attributes #47 = { vscale_range(1,0) }
 ; CHECK: attributes #48 = { nosanitize_coverage }
 ; CHECK: attributes #49 = { noprofile }
+; CHECK: attributes #50 = { disable_sanitizer_instrumentation }
 ; CHECK: attributes #[[NOBUILTIN]] = { nobuiltin }
Index: llvm/lib/Transforms/Utils/CodeExtractor.cpp
===
--- llvm/lib/Transforms/Utils/CodeExtractor.cpp
+++ llvm/lib/Transforms/Utils/CodeExtractor.cpp
@@ -943,6 +943,7 @@
   // Those attributes should be safe to propagate to the extracted function.
   case Attribute::AlwaysInline:
   case Attribute::Cold:
+  case Attribute::DisableSanitizerInstrumentation:
   case Attribute::Hot:
   case Attribute::NoRecurse:
   case Attribute::InlineHint:
Index: llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
===
--- llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
+++ llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
@@ -626,6 +626,8 @@
 return bitc::ATTR_KIND_IN_ALLOCA;
   case Attribute::Cold:
 return bitc::ATTR_KIND_COLD;
+  case Attribute::DisableSanitizerInstrumentation:
+return bitc::ATTR_KIND_DISABLE_SANITIZER_INSTRUMENTATION;
   case Attribute::Hot:
 return bitc::ATTR_KIND_HOT;
   case Attribute::ElementType:
Index: llvm/lib/Bitcode/Reader/BitcodeReader.cpp
===
--- llvm/lib/Bitcode/Reader/BitcodeReader.cpp
+++ llvm/lib/Bitcode/Reader/BitcodeReader.cpp
@@ -1388,6 +1388,8 @@
 return Attribute::Cold;
   case bitc::ATTR_KIND_CONVERGENT:
 return Attribute::Convergent;
+  case bitc::ATTR_KIND_DISABLE_SANITIZER_INSTRUMENTATION:
+return Attribute::DisableSanitizerInstrumentation;
   case bitc::ATTR_KIND_ELEMENTTYPE:
 return Attribute::ElementType;
   case bitc::ATTR_KIND_INACCESSIBLEMEM_ONLY:
Index: llvm/lib/AsmParser/LLLexer.cpp
===
--- llvm/lib/AsmParser/LLLexer.cpp
+++ llvm/lib/AsmParser/LLLexer.cpp
@@ -643,6 +643,7 @@
   KEYWORD(convergent);
   KEYWORD(dereferenceable);
   KEYWORD(dereferenceable_or_null);
+  KEYWORD(disable_sanitizer_instrumentation);
   KEYWORD(elementtype);
   KEYWORD(inaccessiblememonly);
   KEYWORD(inaccessiblemem_or_argmemonly);
Index: llvm/include/llvm/IR/Attributes.td

[PATCH] D108029: [clang][Codegen] Introduce the disable_sanitizer_instrumentation attribute

2021-08-20 Thread Alexander Potapenko via Phabricator via cfe-commits
glider added a comment.

In D108029#2954604 , @glider wrote:

> In D108029#2954566 , @melver wrote:
>
>> llvm/docs/LangRef.rst also needs a corresponding change.
>
> Right, will do. I thought LangRef was missing the sanitizer bits as well, and 
> was planning to add them together, but apparently I was just looking for the 
> wrong attributes.

I've added the function attribute description to LangRef. Looks like global 
attributes aren't listed explicitly.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108029

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


[clang] 62f4c90 - [Sema] Remove dead return immediately after another return. NFC.

2021-08-20 Thread Simon Pilgrim via cfe-commits

Author: Simon Pilgrim
Date: 2021-08-20T12:11:23+01:00
New Revision: 62f4c90aaf1eb418f69e73cbbf170264a02c2688

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

LOG: [Sema] Remove dead return immediately after another return. NFC.

Added: 


Modified: 
clang/lib/Sema/SemaExpr.cpp

Removed: 




diff  --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp
index 5bde87d02877..daf924b1b199 100644
--- a/clang/lib/Sema/SemaExpr.cpp
+++ b/clang/lib/Sema/SemaExpr.cpp
@@ -18350,7 +18350,6 @@ static ExprResult 
rebuildPotentialResultsAsNonOdrUsed(Sema &S, Expr *E,
 ME->getQualifierLoc(), ME->getTemplateKeywordLoc(), 
ME->getMemberDecl(),
 ME->getFoundDecl(), ME->getMemberNameInfo(), CopiedTemplateArgs(ME),
 ME->getType(), ME->getValueKind(), ME->getObjectKind(), NOUR);
-return ExprEmpty();
   }
 
   case Expr::BinaryOperatorClass: {



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


[clang] 5b72fb8 - [AST] getDeclLocForCommentSearch - remove dead return. NFC.

2021-08-20 Thread Simon Pilgrim via cfe-commits

Author: Simon Pilgrim
Date: 2021-08-20T12:32:29+01:00
New Revision: 5b72fb866c16d63a3403848f0a4f04f522da8ba3

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

LOG: [AST] getDeclLocForCommentSearch - remove dead return. NFC.

Don't use an else-block as the previous if-block always returns, and remove the 
(now more obvious) dead return {}.

Added: 


Modified: 
clang/lib/AST/ASTContext.cpp

Removed: 




diff  --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp
index 4c9dc42c5b5dd..cf5be0c3219a6 100644
--- a/clang/lib/AST/ASTContext.cpp
+++ b/clang/lib/AST/ASTContext.cpp
@@ -172,29 +172,28 @@ static SourceLocation getDeclLocForCommentSearch(const 
Decl *D,
   // Allow association with Y across {} in `typedef struct X {} Y`.
   isa(D))
 return D->getBeginLoc();
-  else {
-const SourceLocation DeclLoc = D->getLocation();
-if (DeclLoc.isMacroID()) {
-  if (isa(D)) {
-// If location of the typedef name is in a macro, it is because being
-// declared via a macro. Try using declaration's starting location as
-// the "declaration location".
-return D->getBeginLoc();
-  } else if (const auto *TD = dyn_cast(D)) {
-// If location of the tag decl is inside a macro, but the spelling of
-// the tag name comes from a macro argument, it looks like a special
-// macro like NS_ENUM is being used to define the tag decl.  In that
-// case, adjust the source location to the expansion loc so that we can
-// attach the comment to the tag decl.
-if (SourceMgr.isMacroArgExpansion(DeclLoc) &&
-TD->isCompleteDefinition())
-  return SourceMgr.getExpansionLoc(DeclLoc);
-  }
+
+  const SourceLocation DeclLoc = D->getLocation();
+  if (DeclLoc.isMacroID()) {
+if (isa(D)) {
+  // If location of the typedef name is in a macro, it is because being
+  // declared via a macro. Try using declaration's starting location as
+  // the "declaration location".
+  return D->getBeginLoc();
+}
+
+if (const auto *TD = dyn_cast(D)) {
+  // If location of the tag decl is inside a macro, but the spelling of
+  // the tag name comes from a macro argument, it looks like a special
+  // macro like NS_ENUM is being used to define the tag decl.  In that
+  // case, adjust the source location to the expansion loc so that we can
+  // attach the comment to the tag decl.
+  if (SourceMgr.isMacroArgExpansion(DeclLoc) && TD->isCompleteDefinition())
+return SourceMgr.getExpansionLoc(DeclLoc);
 }
-return DeclLoc;
   }
 
-  return {};
+  return DeclLoc;
 }
 
 RawComment *ASTContext::getRawCommentForDeclNoCacheImpl(



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


[PATCH] D108456: [CUDA] Fix static device variables with -fgpu-rdc

2021-08-20 Thread Jonas Hahnfeld via Phabricator via cfe-commits
Hahnfeld created this revision.
Hahnfeld added reviewers: tra, yaxunl.
Hahnfeld requested review of this revision.
Herald added a reviewer: jdoerfert.
Herald added subscribers: cfe-commits, sstefan1.
Herald added a project: clang.

NVPTX does not allow dots in the identifier, so ptxas errors out with

  fatal   : Parsing error near '.static': syntax error

because it parses .static as a directive. Avoid this problem by using
two underscores, similar to what OpenMP does for outlined functions.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D108456

Files:
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/test/CodeGenCUDA/device-var-linkage.cu
  clang/test/CodeGenCUDA/managed-var.cu
  clang/test/CodeGenCUDA/static-device-var-rdc.cu


Index: clang/test/CodeGenCUDA/static-device-var-rdc.cu
===
--- clang/test/CodeGenCUDA/static-device-var-rdc.cu
+++ clang/test/CodeGenCUDA/static-device-var-rdc.cu
@@ -55,11 +55,11 @@
 // INT-HOST-DAG: @[[DEVNAMEX:[0-9]+]] = {{.*}}c"_ZL1x\00"
 
 // Test externalized static device variables
-// EXT-DEV-DAG: @_ZL1x.static.[[HASH:.*]] = addrspace(1) 
externally_initialized global i32 0
-// EXT-HOST-DAG: @[[DEVNAMEX:[0-9]+]] = {{.*}}c"_ZL1x.static.[[HASH:.*]]\00"
+// EXT-DEV-DAG: @_ZL1x__static__[[HASH:.*]] = addrspace(1) 
externally_initialized global i32 0
+// EXT-HOST-DAG: @[[DEVNAMEX:[0-9]+]] = {{.*}}c"_ZL1x__static__[[HASH:.*]]\00"
 
-// POSTFIX: @_ZL1x.static.[[HASH:.*]] = addrspace(1) externally_initialized 
global i32 0
-// POSTFIX: @[[DEVNAMEX:[0-9]+]] = {{.*}}c"_ZL1x.static.[[HASH]]\00"
+// POSTFIX: @_ZL1x__static__[[HASH:.*]] = addrspace(1) externally_initialized 
global i32 0
+// POSTFIX: @[[DEVNAMEX:[0-9]+]] = {{.*}}c"_ZL1x__static__[[HASH]]\00"
 
 static __device__ int x;
 
@@ -73,8 +73,8 @@
 // INT-HOST-DAG: @[[DEVNAMEY:[0-9]+]] = {{.*}}c"_ZL1y\00"
 
 // Test externalized static device variables
-// EXT-DEV-DAG: @_ZL1y.static.[[HASH]] = addrspace(4) externally_initialized 
global i32 0
-// EXT-HOST-DAG: @[[DEVNAMEY:[0-9]+]] = {{.*}}c"_ZL1y.static.[[HASH]]\00"
+// EXT-DEV-DAG: @_ZL1y__static__[[HASH]] = addrspace(4) externally_initialized 
global i32 0
+// EXT-HOST-DAG: @[[DEVNAMEY:[0-9]+]] = {{.*}}c"_ZL1y__static__[[HASH]]\00"
 
 static __constant__ int y;
 
Index: clang/test/CodeGenCUDA/managed-var.cu
===
--- clang/test/CodeGenCUDA/managed-var.cu
+++ clang/test/CodeGenCUDA/managed-var.cu
@@ -52,15 +52,15 @@
 
 // NORDC-D-DAG: @_ZL2sx.managed = addrspace(1) externally_initialized global 
i32 1, align 4
 // NORDC-D-DAG: @_ZL2sx = addrspace(1) externally_initialized global i32 
addrspace(1)* null
-// RDC-D-DAG: @_ZL2sx.static.[[HASH:.*]].managed = addrspace(1) 
externally_initialized global i32 1, align 4
-// RDC-D-DAG: @_ZL2sx.static.[[HASH]] = addrspace(1) externally_initialized 
global i32 addrspace(1)* null
+// RDC-D-DAG: @_ZL2sx__static__[[HASH:.*]].managed = addrspace(1) 
externally_initialized global i32 1, align 4
+// RDC-D-DAG: @_ZL2sx__static__[[HASH]] = addrspace(1) externally_initialized 
global i32 addrspace(1)* null
 // HOST-DAG: @_ZL2sx.managed = internal global i32 1
 // HOST-DAG: @_ZL2sx = internal externally_initialized global i32* null
 // NORDC-DAG: @[[DEVNAMESX:[0-9]+]] = {{.*}}c"_ZL2sx\00"
-// RDC-DAG: @[[DEVNAMESX:[0-9]+]] = {{.*}}c"_ZL2sx.static.[[HASH:.*]]\00"
+// RDC-DAG: @[[DEVNAMESX:[0-9]+]] = {{.*}}c"_ZL2sx__static__[[HASH:.*]]\00"
 
-// POSTFIX:  @_ZL2sx.static.[[HASH:.*]] = addrspace(1) externally_initialized 
global i32 addrspace(1)* null
-// POSTFIX: @[[DEVNAMESX:[0-9]+]] = {{.*}}c"_ZL2sx.static.[[HASH]]\00"
+// POSTFIX:  @_ZL2sx__static__[[HASH:.*]] = addrspace(1) 
externally_initialized global i32 addrspace(1)* null
+// POSTFIX: @[[DEVNAMESX:[0-9]+]] = {{.*}}c"_ZL2sx__static__[[HASH]]\00"
 static __managed__ int sx = 1;
 
 // DEV-DAG: @llvm.compiler.used
Index: clang/test/CodeGenCUDA/device-var-linkage.cu
===
--- clang/test/CodeGenCUDA/device-var-linkage.cu
+++ clang/test/CodeGenCUDA/device-var-linkage.cu
@@ -37,15 +37,15 @@
 extern __managed__ int ev3;
 
 // NORDC-DAG: @_ZL3sv1 = addrspace(1) externally_initialized global i32 0
-// RDC-DAG: @_ZL3sv1.static.[[HASH:.*]] = addrspace(1) externally_initialized 
global i32 0
+// RDC-DAG: @_ZL3sv1__static__[[HASH:.*]] = addrspace(1) 
externally_initialized global i32 0
 // HOST-DAG: @_ZL3sv1 = internal global i32 undef
 static __device__ int sv1;
 // NORDC-DAG: @_ZL3sv2 = addrspace(4) externally_initialized global i32 0
-// RDC-DAG: @_ZL3sv2.static.[[HASH]] = addrspace(4) externally_initialized 
global i32 0
+// RDC-DAG: @_ZL3sv2__static__[[HASH]] = addrspace(4) externally_initialized 
global i32 0
 // HOST-DAG: @_ZL3sv2 = internal global i32 undef
 static __constant__ int sv2;
 // NORDC-DAG: @_ZL3sv3 = addrspace(1) externally_initialized global i32 
addrspace(1)* null
-// RDC-DAG: @_ZL3sv

[PATCH] D85223: [CUDA][HIP] Support accessing static device variable in host code for -fgpu-rdc

2021-08-20 Thread Jonas Hahnfeld via Phabricator via cfe-commits
Hahnfeld added inline comments.



Comment at: clang/lib/CodeGen/CodeGenModule.cpp:6265-6268
+void CodeGenModule::printPostfixForExternalizedStaticVar(
+llvm::raw_ostream &OS) const {
+  OS << ".static." << getContext().getCUIDHash();
+}

I've tried to use this with CUDA, but it errors out because `.` is not allowed 
in identifiers. Could you check if https://reviews.llvm.org/D108456 also works 
for HIP?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D85223

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


[clang-tools-extra] b2aa470 - [clangd] detectClangPath() - remove (dead) return. NFC.

2021-08-20 Thread Simon Pilgrim via cfe-commits

Author: Simon Pilgrim
Date: 2021-08-20T12:41:38+01:00
New Revision: b2aa470faeb7aaedfa63cb192a710fbe086f15c1

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

LOG: [clangd] detectClangPath() - remove (dead) return. NFC.

Added: 


Modified: 
clang-tools-extra/clangd/CompileCommands.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/CompileCommands.cpp 
b/clang-tools-extra/clangd/CompileCommands.cpp
index 57933169f9119..f9e283beca64c 100644
--- a/clang-tools-extra/clangd/CompileCommands.cpp
+++ b/clang-tools-extra/clangd/CompileCommands.cpp
@@ -127,7 +127,6 @@ const llvm::Optional detectSysroot() {
   if (::getenv("SDKROOT"))
 return llvm::None;
   return queryXcrun({"xcrun", "--show-sdk-path"});
-  return llvm::None;
 }
 
 std::string detectStandardResourceDir() {



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


[PATCH] D108458: [clang][CodeGen] Add default constructor for Address. NFC.

2021-08-20 Thread Andy Wingo via Phabricator via cfe-commits
wingo created this revision.
wingo added a reviewer: rjmccall.
wingo requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

This allows a declaration of an Address to be invalid by default,
allowing it to be added to e.g. a DenseMap.  Will followup with a
cleanup.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D108458

Files:
  clang/lib/CodeGen/Address.h


Index: clang/lib/CodeGen/Address.h
===
--- clang/lib/CodeGen/Address.h
+++ clang/lib/CodeGen/Address.h
@@ -22,16 +22,17 @@
 
 /// An aligned address.
 class Address {
-  llvm::Value *Pointer;
+  llvm::Value *Pointer = nullptr;
   CharUnits Alignment;
 public:
+  Address() { assert(!isValid()); }
   Address(llvm::Value *pointer, CharUnits alignment)
   : Pointer(pointer), Alignment(alignment) {
 assert((!alignment.isZero() || pointer == nullptr) &&
"creating valid address with invalid alignment");
   }
 
-  static Address invalid() { return Address(nullptr, CharUnits()); }
+  static Address invalid() { return Address(); }
   bool isValid() const { return Pointer != nullptr; }
 
   llvm::Value *getPointer() const {


Index: clang/lib/CodeGen/Address.h
===
--- clang/lib/CodeGen/Address.h
+++ clang/lib/CodeGen/Address.h
@@ -22,16 +22,17 @@
 
 /// An aligned address.
 class Address {
-  llvm::Value *Pointer;
+  llvm::Value *Pointer = nullptr;
   CharUnits Alignment;
 public:
+  Address() { assert(!isValid()); }
   Address(llvm::Value *pointer, CharUnits alignment)
   : Pointer(pointer), Alignment(alignment) {
 assert((!alignment.isZero() || pointer == nullptr) &&
"creating valid address with invalid alignment");
   }
 
-  static Address invalid() { return Address(nullptr, CharUnits()); }
+  static Address invalid() { return Address(); }
   bool isValid() const { return Pointer != nullptr; }
 
   llvm::Value *getPointer() const {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D108458: [clang][CodeGen] Add default constructor for Address. NFC.

2021-08-20 Thread Andy Wingo via Phabricator via cfe-commits
wingo added inline comments.



Comment at: clang/lib/CodeGen/Address.h:31
   : Pointer(pointer), Alignment(alignment) {
 assert((!alignment.isZero() || pointer == nullptr) &&
"creating valid address with invalid alignment");

It would be nice to assert(isValid()) here but that's not how Address is used; 
you can pass in a nullptr as the first argument.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108458

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


[clang] b0391df - [clang][Codegen] Introduce the disable_sanitizer_instrumentation attribute

2021-08-20 Thread Alexander Potapenko via cfe-commits

Author: Alexander Potapenko
Date: 2021-08-20T14:01:06+02:00
New Revision: b0391dfc737ede147e128fe877045f61fc5e4905

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

LOG: [clang][Codegen] Introduce the disable_sanitizer_instrumentation attribute

The purpose of __attribute__((disable_sanitizer_instrumentation)) is to
prevent all kinds of sanitizer instrumentation applied to a certain
function, Objective-C method, or global variable.

The no_sanitize(...) attribute drops instrumentation checks, but may
still insert code preventing false positive reports. In some cases
though (e.g. when building Linux kernel with -fsanitize=kernel-memory
or -fsanitize=thread) the users may want to avoid any kind of
instrumentation.

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

Added: 
clang/test/CodeGen/attr-disable-sanitizer-instrumentation.c

Modified: 
clang/include/clang/Basic/Attr.td
clang/include/clang/Basic/AttrDocs.td
clang/lib/CodeGen/CodeGenFunction.cpp
clang/lib/CodeGen/CodeGenFunction.h
clang/test/Misc/pragma-attribute-supported-attributes-list.test
llvm/docs/BitCodeFormat.rst
llvm/docs/LangRef.rst
llvm/include/llvm/AsmParser/LLToken.h
llvm/include/llvm/Bitcode/LLVMBitCodes.h
llvm/include/llvm/IR/Attributes.td
llvm/lib/AsmParser/LLLexer.cpp
llvm/lib/Bitcode/Reader/BitcodeReader.cpp
llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
llvm/lib/Transforms/Utils/CodeExtractor.cpp
llvm/test/Bitcode/attributes.ll
llvm/test/Bitcode/compatibility.ll

Removed: 




diff  --git a/clang/include/clang/Basic/Attr.td 
b/clang/include/clang/Basic/Attr.td
index 13d8c15001c92..f9ae1b8d86281 100644
--- a/clang/include/clang/Basic/Attr.td
+++ b/clang/include/clang/Basic/Attr.td
@@ -2948,6 +2948,13 @@ def NoSanitizeSpecific : InheritableAttr {
   let ASTNode = 0;
 }
 
+def DisableSanitizerInstrumentation : InheritableAttr {
+  let Spellings = [Clang<"disable_sanitizer_instrumentation">];
+  let Subjects = SubjectList<[Function, ObjCMethod, GlobalVar]>;
+  let Documentation = [DisableSanitizerInstrumentationDocs];
+  let SimpleHandler = 1;
+}
+
 def CFICanonicalJumpTable : InheritableAttr {
   let Spellings = [Clang<"cfi_canonical_jump_table">];
   let Subjects = SubjectList<[Function], ErrorDiag>;

diff  --git a/clang/include/clang/Basic/AttrDocs.td 
b/clang/include/clang/Basic/AttrDocs.td
index a1206347ae454..5c63c8440ad80 100644
--- a/clang/include/clang/Basic/AttrDocs.td
+++ b/clang/include/clang/Basic/AttrDocs.td
@@ -2602,6 +2602,18 @@ full list of supported sanitizer flags.
   }];
 }
 
+def DisableSanitizerInstrumentationDocs : Documentation {
+  let Category = DocCatFunction;
+  let Content = [{
+Use the ``disable_sanitizer_instrumentation`` attribute on a function,
+Objective-C method, or global variable, to specify that no sanitizer
+instrumentation should be applied.
+
+This is not the same as ``__attribute__((no_sanitize(...)))``, which depending
+on the tool may still insert instrumentation to prevent false positive reports.
+  }];
+}
+
 def NoSanitizeAddressDocs : Documentation {
   let Category = DocCatFunction;
   // This function has multiple distinct spellings, and so it requires a custom

diff  --git a/clang/lib/CodeGen/CodeGenFunction.cpp 
b/clang/lib/CodeGen/CodeGenFunction.cpp
index dca42045325df..e3a66318c086c 100644
--- a/clang/lib/CodeGen/CodeGenFunction.cpp
+++ b/clang/lib/CodeGen/CodeGenFunction.cpp
@@ -381,6 +381,9 @@ void CodeGenFunction::FinishFunction(SourceLocation EndLoc) 
{
"__cyg_profile_func_exit");
   }
 
+  if (ShouldSkipSanitizerInstrumentation())
+CurFn->addFnAttr(llvm::Attribute::DisableSanitizerInstrumentation);
+
   // Emit debug descriptor for function end.
   if (CGDebugInfo *DI = getDebugInfo())
 DI->EmitFunctionEnd(Builder, CurFn);
@@ -519,6 +522,12 @@ bool CodeGenFunction::ShouldInstrumentFunction() {
   return true;
 }
 
+bool CodeGenFunction::ShouldSkipSanitizerInstrumentation() {
+  if (!CurFuncDecl)
+return false;
+  return CurFuncDecl->hasAttr();
+}
+
 /// ShouldXRayInstrument - Return true if the current function should be
 /// instrumented with XRay nop sleds.
 bool CodeGenFunction::ShouldXRayInstrumentFunction() const {

diff  --git a/clang/lib/CodeGen/CodeGenFunction.h 
b/clang/lib/CodeGen/CodeGenFunction.h
index 0baa45e6b9f27..f74bff91f007c 100644
--- a/clang/lib/CodeGen/CodeGenFunction.h
+++ b/clang/lib/CodeGen/CodeGenFunction.h
@@ -2286,6 +2286,10 @@ class CodeGenFunction : public CodeGenTypeCache {
   /// instrumented with __cyg_profile_func_* calls
   bool ShouldInstrumentFunction();
 
+  /// ShouldSkipSanitizerInstrumentation - Return true if the current function
+  /// should not be instrumented with sanitizers.
+  bool ShouldSkipSanitizerInstrumen

[PATCH] D108029: [clang][Codegen] Introduce the disable_sanitizer_instrumentation attribute

2021-08-20 Thread Alexander Potapenko 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 rGb0391dfc737e: [clang][Codegen] Introduce the 
disable_sanitizer_instrumentation attribute (authored by glider).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108029

Files:
  clang/include/clang/Basic/Attr.td
  clang/include/clang/Basic/AttrDocs.td
  clang/lib/CodeGen/CodeGenFunction.cpp
  clang/lib/CodeGen/CodeGenFunction.h
  clang/test/CodeGen/attr-disable-sanitizer-instrumentation.c
  clang/test/Misc/pragma-attribute-supported-attributes-list.test
  llvm/docs/BitCodeFormat.rst
  llvm/docs/LangRef.rst
  llvm/include/llvm/AsmParser/LLToken.h
  llvm/include/llvm/Bitcode/LLVMBitCodes.h
  llvm/include/llvm/IR/Attributes.td
  llvm/lib/AsmParser/LLLexer.cpp
  llvm/lib/Bitcode/Reader/BitcodeReader.cpp
  llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
  llvm/lib/Transforms/Utils/CodeExtractor.cpp
  llvm/test/Bitcode/attributes.ll
  llvm/test/Bitcode/compatibility.ll

Index: llvm/test/Bitcode/compatibility.ll
===
--- llvm/test/Bitcode/compatibility.ll
+++ llvm/test/Bitcode/compatibility.ll
@@ -1510,7 +1510,7 @@
   ; CHECK: select <2 x i1> , <2 x i8> , <2 x i8> 
 
   call void @f.nobuiltin() builtin
-  ; CHECK: call void @f.nobuiltin() #45
+  ; CHECK: call void @f.nobuiltin() #46
 
   call fastcc noalias i32* @f.noalias() noinline
   ; CHECK: call fastcc noalias i32* @f.noalias() #12
@@ -1907,6 +1907,9 @@
 declare void @f.nosanitize_coverage() nosanitize_coverage
 ; CHECK: declare void @f.nosanitize_coverage() #44
 
+declare void @f.disable_sanitizer_instrumentation() disable_sanitizer_instrumentation
+; CHECK: declare void @f.disable_sanitizer_instrumentation() #45
+
 ; immarg attribute
 declare void @llvm.test.immarg.intrinsic(i32 immarg)
 ; CHECK: declare void @llvm.test.immarg.intrinsic(i32 immarg)
@@ -1965,7 +1968,8 @@
 ; CHECK: attributes #42 = { speculatable }
 ; CHECK: attributes #43 = { strictfp }
 ; CHECK: attributes #44 = { nosanitize_coverage }
-; CHECK: attributes #45 = { builtin }
+; CHECK: attributes #45 = { disable_sanitizer_instrumentation }
+; CHECK: attributes #46 = { builtin }
 
 ;; Metadata
 
Index: llvm/test/Bitcode/attributes.ll
===
--- llvm/test/Bitcode/attributes.ll
+++ llvm/test/Bitcode/attributes.ll
@@ -472,6 +472,12 @@
   ret void
 }
 
+; CHECK: define void @f80() #50
+define void @f80() disable_sanitizer_instrumentation
+{
+ret void;
+}
+
 ; CHECK: attributes #0 = { noreturn }
 ; CHECK: attributes #1 = { nounwind }
 ; CHECK: attributes #2 = { readnone }
@@ -522,4 +528,5 @@
 ; CHECK: attributes #47 = { vscale_range(1,0) }
 ; CHECK: attributes #48 = { nosanitize_coverage }
 ; CHECK: attributes #49 = { noprofile }
+; CHECK: attributes #50 = { disable_sanitizer_instrumentation }
 ; CHECK: attributes #[[NOBUILTIN]] = { nobuiltin }
Index: llvm/lib/Transforms/Utils/CodeExtractor.cpp
===
--- llvm/lib/Transforms/Utils/CodeExtractor.cpp
+++ llvm/lib/Transforms/Utils/CodeExtractor.cpp
@@ -943,6 +943,7 @@
   // Those attributes should be safe to propagate to the extracted function.
   case Attribute::AlwaysInline:
   case Attribute::Cold:
+  case Attribute::DisableSanitizerInstrumentation:
   case Attribute::Hot:
   case Attribute::NoRecurse:
   case Attribute::InlineHint:
Index: llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
===
--- llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
+++ llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
@@ -626,6 +626,8 @@
 return bitc::ATTR_KIND_IN_ALLOCA;
   case Attribute::Cold:
 return bitc::ATTR_KIND_COLD;
+  case Attribute::DisableSanitizerInstrumentation:
+return bitc::ATTR_KIND_DISABLE_SANITIZER_INSTRUMENTATION;
   case Attribute::Hot:
 return bitc::ATTR_KIND_HOT;
   case Attribute::ElementType:
Index: llvm/lib/Bitcode/Reader/BitcodeReader.cpp
===
--- llvm/lib/Bitcode/Reader/BitcodeReader.cpp
+++ llvm/lib/Bitcode/Reader/BitcodeReader.cpp
@@ -1388,6 +1388,8 @@
 return Attribute::Cold;
   case bitc::ATTR_KIND_CONVERGENT:
 return Attribute::Convergent;
+  case bitc::ATTR_KIND_DISABLE_SANITIZER_INSTRUMENTATION:
+return Attribute::DisableSanitizerInstrumentation;
   case bitc::ATTR_KIND_ELEMENTTYPE:
 return Attribute::ElementType;
   case bitc::ATTR_KIND_INACCESSIBLEMEM_ONLY:
Index: llvm/lib/AsmParser/LLLexer.cpp
===
--- llvm/lib/AsmParser/LLLexer.cpp
+++ llvm/lib/AsmParser/LLLexer.cpp
@@ -643,6 +643,7 @@
   KEYWORD(convergent);
   KEYWORD(dereferenceable);
   KEYWORD(dereferenceable_or_null);
+  KEYWORD(disable_s

[PATCH] D108421: Mark openmp internal global dso_local

2021-08-20 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev added inline comments.



Comment at: clang/lib/CodeGen/CGOpenMPRuntime.cpp:2182-2189
+  llvm::GlobalVariable *GV = new llvm::GlobalVariable(
+  CGM.getModule(), Ty, /*IsConstant*/ false,
+  llvm::GlobalValue::CommonLinkage, llvm::Constant::getNullValue(Ty),
+  Elem.first(), /*InsertBefore=*/nullptr, 
llvm::GlobalValue::NotThreadLocal,
+  AddressSpace);
+  GV->setDSOLocal(true);
+  Elem.second = GV;

I would not do it here since the linkage is changing in some places. Better to 
make this kind of change explicitly where required + need to add tests.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108421

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


[PATCH] D108403: Fix assertion when generating diagnostic for inline namespaces

2021-08-20 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman updated this revision to Diff 367765.
aaron.ballman added a comment.

Updating based on review comments.


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

https://reviews.llvm.org/D108403

Files:
  clang/include/clang/AST/Decl.h
  clang/include/clang/AST/DeclBase.h
  clang/lib/AST/DeclBase.cpp
  clang/test/Misc/diag-inline-namespace.cpp


Index: clang/test/Misc/diag-inline-namespace.cpp
===
--- clang/test/Misc/diag-inline-namespace.cpp
+++ clang/test/Misc/diag-inline-namespace.cpp
@@ -48,3 +48,14 @@
   T t4; // expected-error {{implicit instantiation of 
undefined template 'N::T'}}
   T t5; // expected-error {{implicit instantiation of 
undefined template 'N::T'}}
 }
+
+namespace dont_crash {
+// A malformed lookup involving inline namespaces in a linkage specification
+// would previous cause an assertion due to the way diagnostics are emitted.
+extern "C++" inline namespace {
+namespace a {
+  a : b // expected-error {{unexpected ':' in nested name specifier; did you 
mean '::'?}} \
+// expected-error {{no type named 'b' in namespace 'dont_crash::a'}}
+} // expected-error {{expected unqualified-id}}
+} // inline namespace
+} // dont_crash
Index: clang/lib/AST/DeclBase.cpp
===
--- clang/lib/AST/DeclBase.cpp
+++ clang/lib/AST/DeclBase.cpp
@@ -1217,6 +1217,13 @@
   return false;
 }
 
+DeclContext *DeclContext::getNonTransparentContext() {
+  DeclContext *DC = this;
+  while (DC && DC->isTransparentContext())
+DC = DC->getParent();
+  return DC;
+}
+
 DeclContext *DeclContext::getPrimaryContext() {
   switch (getDeclKind()) {
   case Decl::ExternCContext:
Index: clang/include/clang/AST/DeclBase.h
===
--- clang/include/clang/AST/DeclBase.h
+++ clang/include/clang/AST/DeclBase.h
@@ -1997,6 +1997,12 @@
 return const_cast(this)->getNonClosureAncestor();
   }
 
+  // Retrieve the nearest context that is not a transparent context.
+  DeclContext *getNonTransparentContext();
+  const DeclContext* getNonTransparentContext() const {
+return const_cast(this)->getNonTransparentContext();
+  }
+
   /// getPrimaryContext - There may be many different
   /// declarations of the same entity (including forward declarations
   /// of classes, multiple definitions of namespaces, etc.), each with
Index: clang/include/clang/AST/Decl.h
===
--- clang/include/clang/AST/Decl.h
+++ clang/include/clang/AST/Decl.h
@@ -614,7 +614,9 @@
 if (!isInline())
   return false;
 auto X = lookup(Name);
-auto Y = getParent()->lookup(Name);
+// We should not perform a lookup within a transparent context, so find a
+// non-transparent parent context.
+auto Y = getParent()->getNonTransparentContext()->lookup(Name);
 return std::distance(X.begin(), X.end()) ==
   std::distance(Y.begin(), Y.end());
   }


Index: clang/test/Misc/diag-inline-namespace.cpp
===
--- clang/test/Misc/diag-inline-namespace.cpp
+++ clang/test/Misc/diag-inline-namespace.cpp
@@ -48,3 +48,14 @@
   T t4; // expected-error {{implicit instantiation of undefined template 'N::T'}}
   T t5; // expected-error {{implicit instantiation of undefined template 'N::T'}}
 }
+
+namespace dont_crash {
+// A malformed lookup involving inline namespaces in a linkage specification
+// would previous cause an assertion due to the way diagnostics are emitted.
+extern "C++" inline namespace {
+namespace a {
+  a : b // expected-error {{unexpected ':' in nested name specifier; did you mean '::'?}} \
+// expected-error {{no type named 'b' in namespace 'dont_crash::a'}}
+} // expected-error {{expected unqualified-id}}
+} // inline namespace
+} // dont_crash
Index: clang/lib/AST/DeclBase.cpp
===
--- clang/lib/AST/DeclBase.cpp
+++ clang/lib/AST/DeclBase.cpp
@@ -1217,6 +1217,13 @@
   return false;
 }
 
+DeclContext *DeclContext::getNonTransparentContext() {
+  DeclContext *DC = this;
+  while (DC && DC->isTransparentContext())
+DC = DC->getParent();
+  return DC;
+}
+
 DeclContext *DeclContext::getPrimaryContext() {
   switch (getDeclKind()) {
   case Decl::ExternCContext:
Index: clang/include/clang/AST/DeclBase.h
===
--- clang/include/clang/AST/DeclBase.h
+++ clang/include/clang/AST/DeclBase.h
@@ -1997,6 +1997,12 @@
 return const_cast(this)->getNonClosureAncestor();
   }
 
+  // Retrieve the nearest context that is not a transparent context.
+  DeclContext *getNonTransparentContext();
+  const DeclContext* getNonTransparentContext() const {
+return const_cast(this)->getNonTransparentContext();
+  }
+
   /// getPrimaryContext - There may be many different
   //

[PATCH] D108459: [clang][CodeGen] Rely on implicitly invalid Address. NFC.

2021-08-20 Thread Andy Wingo via Phabricator via cfe-commits
wingo created this revision.
Herald added a subscriber: lxfind.
wingo requested review of this revision.
Herald added a reviewer: jdoerfert.
Herald added subscribers: cfe-commits, sstefan1.
Herald added a project: clang.

Remove explicit uses of Address::invalid in initializers; the default
constructor makes an invalid address.

Depends on D108458 .


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D108459

Files:
  clang/lib/CodeGen/CGAtomic.cpp
  clang/lib/CodeGen/CGBlocks.cpp
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/lib/CodeGen/CGCall.cpp
  clang/lib/CodeGen/CGCall.h
  clang/lib/CodeGen/CGCoroutine.cpp
  clang/lib/CodeGen/CGDecl.cpp
  clang/lib/CodeGen/CGException.cpp
  clang/lib/CodeGen/CGExpr.cpp
  clang/lib/CodeGen/CGExprAgg.cpp
  clang/lib/CodeGen/CGExprCXX.cpp
  clang/lib/CodeGen/CGExprComplex.cpp
  clang/lib/CodeGen/CGExprScalar.cpp
  clang/lib/CodeGen/CGObjC.cpp
  clang/lib/CodeGen/CGObjCMac.cpp
  clang/lib/CodeGen/CGOpenMPRuntime.cpp
  clang/lib/CodeGen/CGOpenMPRuntime.h
  clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp
  clang/lib/CodeGen/CGOpenMPRuntimeGPU.h
  clang/lib/CodeGen/CGStmt.cpp
  clang/lib/CodeGen/CGStmtOpenMP.cpp
  clang/lib/CodeGen/CodeGenFunction.h
  clang/lib/CodeGen/TargetInfo.cpp

Index: clang/lib/CodeGen/TargetInfo.cpp
===
--- clang/lib/CodeGen/TargetInfo.cpp
+++ clang/lib/CodeGen/TargetInfo.cpp
@@ -321,7 +321,7 @@
   llvm::Value *Ptr = CGF.Builder.CreateLoad(VAListAddr, "argp.cur");
 
   // If the CC aligns values higher than the slot size, do so if needed.
-  Address Addr = Address::invalid();
+  Address Addr;
   if (AllowHigherAlign && DirectAlign > SlotSize) {
 Addr = Address(emitRoundPointerUpToAlignment(CGF, Ptr, DirectAlign),
  DirectAlign);
@@ -4064,7 +4064,7 @@
   // register save space).
 
   llvm::Value *InRegs = nullptr;
-  Address gp_offset_p = Address::invalid(), fp_offset_p = Address::invalid();
+  Address gp_offset_p, fp_offset_p;
   llvm::Value *gp_offset = nullptr, *fp_offset = nullptr;
   if (neededInt) {
 gp_offset_p = CGF.Builder.CreateStructGEP(VAListAddr, 0, "gp_offset_p");
@@ -4105,7 +4105,7 @@
   llvm::Value *RegSaveArea = CGF.Builder.CreateLoad(
   CGF.Builder.CreateStructGEP(VAListAddr, 3), "reg_save_area");
 
-  Address RegAddr = Address::invalid();
+  Address RegAddr;
   if (neededInt && neededSSE) {
 // FIXME: Cleanup.
 assert(AI.isDirect() && "Unexpected ABI info for mixed regs");
@@ -4787,7 +4787,7 @@
   CGBuilderTy &Builder = CGF.Builder;
 
   // The calling convention either uses 1-2 GPRs or 1 FPR.
-  Address NumRegsAddr = Address::invalid();
+  Address NumRegsAddr;
   if (isInt || IsSoftFloatABI) {
 NumRegsAddr = Builder.CreateStructGEP(VAList, 0, "gpr");
   } else {
@@ -4815,7 +4815,7 @@
   if (isIndirect) DirectTy = DirectTy->getPointerTo(0);
 
   // Case 1: consume registers.
-  Address RegAddr = Address::invalid();
+  Address RegAddr;
   {
 CGF.EmitBlock(UsingRegs);
 
@@ -4850,7 +4850,7 @@
   }
 
   // Case 2: consume space in the overflow area.
-  Address MemAddr = Address::invalid();
+  Address MemAddr;
   {
 CGF.EmitBlock(UsingOverflow);
 
@@ -5982,7 +5982,7 @@
   CharUnits TySize = getContext().getTypeSizeInChars(Ty);
   CharUnits TyAlign = getContext().getTypeUnadjustedAlignInChars(Ty);
 
-  Address reg_offs_p = Address::invalid();
+  Address reg_offs_p;
   llvm::Value *reg_offs = nullptr;
   int reg_top_index;
   int RegSize = IsIndirect ? 8 : TySize.getQuantity();
@@ -6063,7 +6063,7 @@
   reg_top = CGF.Builder.CreateLoad(reg_top_p, "reg_top");
   Address BaseAddr(CGF.Builder.CreateInBoundsGEP(CGF.Int8Ty, reg_top, reg_offs),
CharUnits::fromQuantity(IsFPR ? 16 : 8));
-  Address RegAddr = Address::invalid();
+  Address RegAddr;
   llvm::Type *MemTy = CGF.ConvertTypeForMem(Ty);
 
   if (IsIndirect) {
@@ -9636,7 +9636,7 @@
 
   auto TypeInfo = getContext().getTypeInfoInChars(Ty);
 
-  Address ArgAddr = Address::invalid();
+  Address ArgAddr;
   CharUnits Stride;
   switch (AI.getKind()) {
   case ABIArgInfo::Expand:
@@ -10006,7 +10006,7 @@
 AI.setCoerceToType(ArgTy);
   llvm::Type *ArgPtrTy = llvm::PointerType::getUnqual(ArgTy);
 
-  Address Val = Address::invalid();
+  Address Val;
   CharUnits ArgSize = CharUnits::Zero();
   switch (AI.getKind()) {
   case ABIArgInfo::Expand:
Index: clang/lib/CodeGen/CodeGenFunction.h
===
--- clang/lib/CodeGen/CodeGenFunction.h
+++ clang/lib/CodeGen/CodeGenFunction.h
@@ -354,11 +354,11 @@
 
   /// ReturnValue - The temporary alloca to hold the return
   /// value. This is invalid iff the function has no return value.
-  Address ReturnValue = Address::invalid();
+  Address ReturnValue;
 
   /// ReturnValuePointer - The temporary alloca to hold a pointer to sret.
   /// This is invalid if sret is not in use.
-  Address ReturnValueP

[PATCH] D108199: [msan] Add support for disable_sanitizer_instrumentation attribute

2021-08-20 Thread Alexander Potapenko via Phabricator via cfe-commits
glider updated this revision to Diff 367767.
glider added a comment.

Updated after landing the disable_sanitizer_instrumentation to LLVM


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108199

Files:
  clang/docs/MemorySanitizer.rst
  clang/test/CodeGen/sanitize-memory-disable.c
  llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp


Index: llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp
===
--- llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp
+++ llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp
@@ -5330,6 +5330,9 @@
   if (!CompileKernel && F.getName() == kMsanModuleCtorName)
 return false;
 
+  if (F.hasFnAttribute(Attribute::DisableSanitizerInstrumentation))
+return false;
+
   MemorySanitizerVisitor Visitor(F, *this, TLI);
 
   // Clear out readonly/readnone attributes.
Index: clang/test/CodeGen/sanitize-memory-disable.c
===
--- /dev/null
+++ clang/test/CodeGen/sanitize-memory-disable.c
@@ -0,0 +1,60 @@
+// RUN: %clang_cc1 -emit-llvm -o - %s | FileCheck -check-prefixes 
CHECK,WITHOUT %s
+// RUN: %clang_cc1 -emit-llvm -o - %s -fsanitize=memory | FileCheck 
-check-prefixes CHECK,MSAN %s
+// RUN: %clang_cc1 -emit-llvm -o - %s -fsanitize=kernel-memory | FileCheck 
-check-prefixes CHECK,KMSAN %s
+
+// Instrumented function.
+// MSan uses memset(addr, -1, size) to poison allocas and stores shadow of the 
return value in
+// __msan_retval_tls. KMSAN uses __msan_poison_alloca() to poison allocas and 
calls
+// __msan_get_context_state() at function prologue to access the task context 
struct (including the
+// shadow of the return value).
+//
+// CHECK: @instrumented1
+// KMSAN: __msan_get_context_state
+// WITHOUT-NOT: __msan_poison_alloca
+// WITHOUT-NOT: @llvm.memset
+// MSAN: @llvm.memset{{.*}}({{.*}}, i8 -1
+// KMSAN: __msan_poison_alloca
+// WITHOUT-NOT: __msan_retval_tls
+// MSAN: __msan_retval_tls
+// CHECK: ret i32
+int instrumented1(int *a) {
+  volatile char buf[8];
+  return *a;
+}
+
+// Function with no_sanitize("memory")/no_sanitize("kernel-memory"): no shadow 
propagation, but
+// unpoisons memory to prevent false positives.
+// MSan uses memset(addr, 0, size) to unpoison locals, KMSAN uses 
__msan_unpoison_alloca(). Both
+// tools still access the retval shadow to write 0 to it.
+//
+// CHECK: @no_false_positives1
+// KMSAN: __msan_get_context_state
+// WITHOUT-NOT: __msan_unpoison_alloca
+// WITHOUT-NOT: @llvm.memset
+// MSAN: @llvm.memset{{.*}}({{.*}}, i8 0
+// KMSAN: __msan_unpoison_alloca
+// WITHOUT-NOT: __msan_retval_tls
+// MSAN: __msan_retval_tls
+// CHECK: ret i32
+__attribute__((no_sanitize("memory")))
+__attribute__((no_sanitize("kernel-memory"))) int
+no_false_positives1(int *a) {
+  volatile char buf[8];
+  return *a;
+}
+
+// Function with disable_sanitizer_instrumentation: no instrumentation at all.
+//
+// CHECK: @no_instrumentation1
+// KMSAN-NOT: __msan_get_context_state
+// WITHOUT-NOT: __msan_poison_alloca
+// WITHOUT-NOT: @llvm.memset
+// MSAN-NOT: @llvm.memset{{.*}}({{.*}}, i8 0
+// KMSAN-NOT: __msan_unpoison_alloca
+// WITHOUT-NOT: __msan_retval_tls
+// MSAN-NOT: __msan_retval_tls
+// CHECK: ret i32
+__attribute__((disable_sanitizer_instrumentation)) int no_instrumentation1(int 
*a) {
+  volatile char buf[8];
+  return *a;
+}
Index: clang/docs/MemorySanitizer.rst
===
--- clang/docs/MemorySanitizer.rst
+++ clang/docs/MemorySanitizer.rst
@@ -85,6 +85,15 @@
 avoid false positives.  This attribute may not be supported by other compilers,
 so we suggest to use it together with ``__has_feature(memory_sanitizer)``.
 
+``__attribute__((disable_sanitizer_instrumentation))``
+
+
+The ``disable_sanitizer_instrumentation`` attribute can be applied to a certain
+function to prevent all kinds of instrumentation. This attribute overrides
+``no_sanitize("memory")`` and may introduce false positives, so it should
+be used with care, e.g. when the user wants to ensure critical code does not
+have unexpected side effects.
+
 Ignorelist
 --
 


Index: llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp
===
--- llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp
+++ llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp
@@ -5330,6 +5330,9 @@
   if (!CompileKernel && F.getName() == kMsanModuleCtorName)
 return false;
 
+  if (F.hasFnAttribute(Attribute::DisableSanitizerInstrumentation))
+return false;
+
   MemorySanitizerVisitor Visitor(F, *this, TLI);
 
   // Clear out readonly/readnone attributes.
Index: clang/test/CodeGen/sanitize-memory-disable.c
===
--- /dev/null
+++ clang/tes

[PATCH] D108370: [clang-tidy] Fix wrong FixIt about union in cppcoreguidelines-pro-type-member-init

2021-08-20 Thread gehry via Phabricator via cfe-commits
Sockke added a comment.

Any thoughts? : )




Comment at: 
clang-tools-extra/clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.cpp:49
+void forEachFieldWithFilter(const RecordDecl &Record, const T &Fields,
+bool &AnyMemberHasInitPerUnion, Func &&Fn) {
+  for (const FieldDecl *F : Fields) {

MTC wrote:
> Can it be modified to the following form? Or further abstract `filter` into a 
> parameter to make this function more general.
> 
> 
> ```
> template 
> void forEachFieldWithFilter(const RecordDecl &Record, const T &Fields,
> bool &AnyMemberHasInitPerUnion, Func &&Fn) {
>   forEachField(Record, Fields, Fn);
>   if (Record.isUnion() && AnyMemberHasInitPerUnion)
> break;
> }
> ```
> Can it be modified to the following form? Or further abstract `filter` into a 
> parameter to make this function more general.
> 
> 
> ```
> template 
> void forEachFieldWithFilter(const RecordDecl &Record, const T &Fields,
> bool &AnyMemberHasInitPerUnion, Func &&Fn) {
>   forEachField(Record, Fields, Fn);
>   if (Record.isUnion() && AnyMemberHasInitPerUnion)
> break;
> }
> ```

This does not seem to work, because the "AnyMemberHasInitPerUnion" needs to be 
passed along the call stack.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108370

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


[PATCH] D102325: [clang-tidy] cppcoreguidelines-virtual-base-class-destructor: a new check

2021-08-20 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.

In D102325#2816919 , @mgartmann wrote:

> I assume that these destructors are private by on purpose. Please correct me 
> if I am wrong.

As best I can tell, these look purposeful to me.

> A programmer working on the LLVM project would therefore see seven warnings 
> for private destructors over the whole project.

Well not quite; because these are in header files, they'd see a lot more 
than just seven warnings.

> Is this number of private destructors which are flagged acceptable to you?

To be honest, I think this signals that we wouldn't be able to enable this 
guideline for our codebase because it's too chatty with no value. Based on the 
results, it's only pointing out false positives and no true positives. So from 
that perspective, it's not super acceptable. However, I've come to the 
conclusion that automated checking for the C++ Core Guidelines (in general, not 
just with your patch!) is not particularly useful for existing code bases 
because of the lack of consideration put into existing code by the guideline 
authors. From that perspective, I think this check is fine.

LGTM, thank you for your patience while I pondered this!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D102325

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


[PATCH] D108461: [OpenCL] Supports optional generic address space in C++ for OpenCL 2021

2021-08-20 Thread Justas Janickas via Phabricator via cfe-commits
Topotuna created this revision.
Topotuna added a reviewer: Anastasia.
Herald added subscribers: ldrumm, yaxunl.
Topotuna requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Adds support for a feature macro `__opencl_c_generic_address_space`
in C++ for OpenCL 2021 enabling a respective optional core feature
from OpenCL 3.0.

This change aims to achieve compatibility between C++ for OpenCL
2021 and OpenCL 3.0.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D108461

Files:
  clang/lib/Basic/TargetInfo.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/lib/Headers/opencl-c-base.h
  clang/test/CodeGenOpenCL/overload.cl
  clang/test/Headers/opencl-c-header.cl
  clang/test/SemaOpenCL/address-spaces-conversions-cl2.0.cl
  clang/test/SemaOpenCL/address-spaces.cl
  clang/test/SemaOpenCL/extension-version.cl

Index: clang/test/SemaOpenCL/extension-version.cl
===
--- clang/test/SemaOpenCL/extension-version.cl
+++ clang/test/SemaOpenCL/extension-version.cl
@@ -2,14 +2,16 @@
 // RUN: %clang_cc1 -x cl -cl-std=CL1.1 %s -verify -triple spir-unknown-unknown
 // RUN: %clang_cc1 -x cl -cl-std=CL1.2 %s -verify -triple spir-unknown-unknown
 // RUN: %clang_cc1 -x cl -cl-std=CL2.0 %s -verify -triple spir-unknown-unknown
-// RUN: %clang_cc1 -x cl -cl-std=clc++ %s -verify -triple spir-unknown-unknown
+// RUN: %clang_cc1 -x cl -cl-std=clc++1.0 %s -verify -triple spir-unknown-unknown
 // RUN: %clang_cc1 -x cl -cl-std=CL3.0 %s -verify -triple spir-unknown-unknown
+// RUN: %clang_cc1 -x cl -cl-std=clc++2021 %s -verify -triple spir-unknown-unknown
 // RUN: %clang_cc1 -x cl -cl-std=CL %s -verify -triple spir-unknown-unknown -Wpedantic-core-features -DTEST_CORE_FEATURES
 // RUN: %clang_cc1 -x cl -cl-std=CL1.1 %s -verify -triple spir-unknown-unknown -Wpedantic-core-features -DTEST_CORE_FEATURES
 // RUN: %clang_cc1 -x cl -cl-std=CL1.2 %s -verify -triple spir-unknown-unknown -Wpedantic-core-features -DTEST_CORE_FEATURES
 // RUN: %clang_cc1 -x cl -cl-std=CL2.0 %s -verify -triple spir-unknown-unknown -Wpedantic-core-features -DTEST_CORE_FEATURES
-// RUN: %clang_cc1 -x cl -cl-std=clc++ %s -verify -triple spir-unknown-unknown -Wpedantic-core-features -DTEST_CORE_FEATURES
+// RUN: %clang_cc1 -x cl -cl-std=clc++1.0 %s -verify -triple spir-unknown-unknown -Wpedantic-core-features -DTEST_CORE_FEATURES
 // RUN: %clang_cc1 -x cl -cl-std=CL3.0 %s -verify -triple spir-unknown-unknown -Wpedantic-core-features -DTEST_CORE_FEATURES
+// RUN: %clang_cc1 -x cl -cl-std=clc++2021 %s -verify -triple spir-unknown-unknown -Wpedantic-core-features -DTEST_CORE_FEATURES
 
 // Extensions in all versions
 #ifndef cl_clang_storage_class_specifiers
Index: clang/test/SemaOpenCL/address-spaces.cl
===
--- clang/test/SemaOpenCL/address-spaces.cl
+++ clang/test/SemaOpenCL/address-spaces.cl
@@ -1,7 +1,8 @@
 // RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only
 // RUN: %clang_cc1 %s -cl-std=CL2.0 -verify -pedantic -fsyntax-only
 // RUN: %clang_cc1 %s -cl-std=CL3.0 -cl-ext=+__opencl_c_generic_address_space -verify -pedantic -fsyntax-only
-// RUN: %clang_cc1 %s -cl-std=clc++ -verify -pedantic -fsyntax-only
+// RUN: %clang_cc1 %s -cl-std=clc++1.0 -verify -pedantic -fsyntax-only
+// RUN: %clang_cc1 %s -cl-std=clc++2021 -cl-ext=+__opencl_c_generic_address_space -verify -pedantic -fsyntax-only
 
 __constant int ci = 1;
 
Index: clang/test/SemaOpenCL/address-spaces-conversions-cl2.0.cl
===
--- clang/test/SemaOpenCL/address-spaces-conversions-cl2.0.cl
+++ clang/test/SemaOpenCL/address-spaces-conversions-cl2.0.cl
@@ -1,12 +1,15 @@
 // RUN: %clang_cc1 %s -ffake-address-space-map -verify -pedantic -fsyntax-only -DCONSTANT -cl-std=CL2.0
 // RUN: %clang_cc1 %s -ffake-address-space-map -verify -pedantic -fsyntax-only -DGLOBAL -cl-std=CL2.0
 // RUN: %clang_cc1 %s -ffake-address-space-map -verify -pedantic -fsyntax-only -DGENERIC -cl-std=CL2.0
-// RUN: %clang_cc1 %s -ffake-address-space-map -verify -pedantic -fsyntax-only -DCONSTANT -cl-std=clc++
-// RUN: %clang_cc1 %s -ffake-address-space-map -verify -pedantic -fsyntax-only -DGLOBAL -cl-std=clc++
-// RUN: %clang_cc1 %s -ffake-address-space-map -verify -pedantic -fsyntax-only -DGENERIC -cl-std=clc++
+// RUN: %clang_cc1 %s -ffake-address-space-map -verify -pedantic -fsyntax-only -DCONSTANT -cl-std=clc++1.0
+// RUN: %clang_cc1 %s -ffake-address-space-map -verify -pedantic -fsyntax-only -DGLOBAL -cl-std=clc++1.0
+// RUN: %clang_cc1 %s -ffake-address-space-map -verify -pedantic -fsyntax-only -DGENERIC -cl-std=clc++1.0
 // RUN: %clang_cc1 %s -ffake-address-space-map -verify -pedantic -fsyntax-only -DCONSTANT -cl-std=CL3.0 -cl-ext=+__opencl_c_generic_address_space
 // RUN: %clang_cc1 %s -ffake-address-space-map -verify -pedantic -fsyntax-only -DGLOBAL -cl-std=CL3.0 -cl-ext=+__opencl

[PATCH] D108370: [clang-tidy] Fix wrong FixIt about union in cppcoreguidelines-pro-type-member-init

2021-08-20 Thread gehry via Phabricator via cfe-commits
Sockke added a comment.

Any thoughts? : )


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108370

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


[PATCH] D107450: [clang-tidy] Fix wrong FIxIt in performance-move-const-arg

2021-08-20 Thread gehry via Phabricator via cfe-commits
Sockke added a comment.

Any thoughts? : )




Comment at: 
clang-tools-extra/test/clang-tidy/checkers/performance-move-const-arg.cpp:263
+  forwardToShowInt(std::move(a));
+  // CHECK-MESSAGES: :[[@LINE-1]]:20: warning: std::move of the variable 'a' 
of the trivially-copyable type 'int' has no effect; consider changing 
forwardToShowInt's parameter from 'int'&& to 'int'&
+}

Quuxplusone wrote:
> `forwardToShowInt` takes `T&&`, not `int&&`, and so it can't be changed in 
> the way the diagnostic is suggesting. I think the right answer here is not to 
> emit the diagnostic at all, when the offending function is a template.
> 
> (Relatively minor nits, all moot because this diagnostic should not be 
> emitted at all: `'int'&&` should be `'int&&'`, `trivially copyable` should 
> not be hyphenated, and `int&` is a strictly worse suggestion than either 
> `const int&` or plain `int`.  IMVHO it would be reasonable to land a very 
> trivial patch to remove the hyphen from `trivially copyable` and update the 
> tests, and then rebase this PR on top of that.)
Keep the original diagnostic behavior, but without "remove std::move" message.



Comment at: 
clang-tools-extra/test/clang-tidy/checkers/performance-move-const-arg.cpp:263
+  forwardToShowInt(std::move(a));
+  // CHECK-MESSAGES: :[[@LINE-1]]:20: warning: std::move of the variable 'a' 
of the trivially-copyable type 'int' has no effect; consider changing 
forwardToShowInt's parameter from 'int'&& to 'int'&
+}

Quuxplusone wrote:
> Sockke wrote:
> > Quuxplusone wrote:
> > > `forwardToShowInt` takes `T&&`, not `int&&`, and so it can't be changed 
> > > in the way the diagnostic is suggesting. I think the right answer here is 
> > > not to emit the diagnostic at all, when the offending function is a 
> > > template.
> > > 
> > > (Relatively minor nits, all moot because this diagnostic should not be 
> > > emitted at all: `'int'&&` should be `'int&&'`, `trivially copyable` 
> > > should not be hyphenated, and `int&` is a strictly worse suggestion than 
> > > either `const int&` or plain `int`.  IMVHO it would be reasonable to land 
> > > a very trivial patch to remove the hyphen from `trivially copyable` and 
> > > update the tests, and then rebase this PR on top of that.)
> > Keep the original diagnostic behavior, but without "remove std::move" 
> > message.
> Okay, I have no //complaints// about the diagnostics being tested by these 
> tests anymore.
> I am //puzzled// about why the tool is suggesting to rewrite `int&&` as 
> `int`, but not suggesting to rewrite `Tmp&&` as `Tmp`; those cases should be 
> exactly isomorphic, right?
> But the goal of this PR is now to //eliminate wrong fixits//, and I believe 
> you've succeeded at that.
> Btw, I'm not qualified to review the actual code change in 
> `MoveConstArgCheck.cpp`; I'll let someone else do that.
Thank you for your reply! Yes, they should be exactly isomorphic when Tmp is a 
trivially copyable type.


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

https://reviews.llvm.org/D107450

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


[PATCH] D107450: [clang-tidy] Fix wrong FIxIt in performance-move-const-arg

2021-08-20 Thread gehry via Phabricator via cfe-commits
Sockke added a comment.

Any thoughts? : )


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

https://reviews.llvm.org/D107450

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


[PATCH] D108422: [NFC][clang] Move remaining part of X86Target.def to llvm/Support/X86TargetParser.def

2021-08-20 Thread Erich Keane via Phabricator via cfe-commits
erichkeane added a comment.

I'm unopposed here.  Craig, what do you think?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108422

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


[PATCH] D108199: [msan] Add support for disable_sanitizer_instrumentation attribute

2021-08-20 Thread Alexander Potapenko via Phabricator via cfe-commits
glider updated this revision to Diff 367774.
glider marked 2 inline comments as done.
glider added a comment.

Addressed Marco's comments


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108199

Files:
  clang/docs/MemorySanitizer.rst
  clang/test/CodeGen/sanitize-memory-disable.c
  llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp


Index: llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp
===
--- llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp
+++ llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp
@@ -5330,6 +5330,9 @@
   if (!CompileKernel && F.getName() == kMsanModuleCtorName)
 return false;
 
+  if (F.hasFnAttribute(Attribute::DisableSanitizerInstrumentation))
+return false;
+
   MemorySanitizerVisitor Visitor(F, *this, TLI);
 
   // Clear out readonly/readnone attributes.
Index: clang/test/CodeGen/sanitize-memory-disable.c
===
--- /dev/null
+++ clang/test/CodeGen/sanitize-memory-disable.c
@@ -0,0 +1,58 @@
+// RUN: %clang_cc1 -emit-llvm -o - %s | FileCheck -check-prefixes 
CHECK,WITHOUT %s
+// RUN: %clang_cc1 -emit-llvm -o - %s -fsanitize=memory | FileCheck 
-check-prefixes CHECK,MSAN %s
+// RUN: %clang_cc1 -emit-llvm -o - %s -fsanitize=kernel-memory | FileCheck 
-check-prefixes CHECK,KMSAN %s
+
+// Instrumented function.
+// MSan uses memset(addr, -1, size) to poison allocas and stores shadow of the 
return value in
+// __msan_retval_tls. KMSAN uses __msan_poison_alloca() to poison allocas and 
calls
+// __msan_get_context_state() at function prologue to access the task context 
struct (including the
+// shadow of the return value).
+//
+// CHECK-LABEL: i32 @instrumented1
+// KMSAN: __msan_get_context_state
+// WITHOUT-NOT: __msan_poison_alloca
+// WITHOUT-NOT: @llvm.memset
+// MSAN: @llvm.memset{{.*}}({{.*}}, i8 -1
+// KMSAN: __msan_poison_alloca
+// WITHOUT-NOT: __msan_retval_tls
+// MSAN: __msan_retval_tls
+// CHECK: ret i32
+int instrumented1(int *a) {
+  volatile char buf[8];
+  return *a;
+}
+
+// Function with no_sanitize("memory")/no_sanitize("kernel-memory"): no shadow 
propagation, but
+// unpoisons memory to prevent false positives.
+// MSan uses memset(addr, 0, size) to unpoison locals, KMSAN uses 
__msan_unpoison_alloca(). Both
+// tools still access the retval shadow to write 0 to it.
+//
+// CHECK-LABEL: i32 @no_false_positives1
+// KMSAN: __msan_get_context_state
+// WITHOUT-NOT: __msan_unpoison_alloca
+// WITHOUT-NOT: @llvm.memset
+// MSAN: @llvm.memset{{.*}}({{.*}}, i8 0
+// KMSAN: __msan_unpoison_alloca
+// WITHOUT-NOT: __msan_retval_tls
+// MSAN: __msan_retval_tls
+// CHECK: ret i32
+__attribute__((no_sanitize("memory"))) 
__attribute__((no_sanitize("kernel-memory"))) int no_false_positives1(int *a) {
+  volatile char buf[8];
+  return *a;
+}
+
+// Function with disable_sanitizer_instrumentation: no instrumentation at all.
+//
+// CHECK-LABEL: i32 @no_instrumentation1
+// KMSAN-NOT: __msan_get_context_state
+// WITHOUT-NOT: __msan_poison_alloca
+// WITHOUT-NOT: @llvm.memset
+// MSAN-NOT: @llvm.memset{{.*}}({{.*}}, i8 0
+// KMSAN-NOT: __msan_unpoison_alloca
+// WITHOUT-NOT: __msan_retval_tls
+// MSAN-NOT: __msan_retval_tls
+// CHECK: ret i32
+__attribute__((disable_sanitizer_instrumentation)) int no_instrumentation1(int 
*a) {
+  volatile char buf[8];
+  return *a;
+}
Index: clang/docs/MemorySanitizer.rst
===
--- clang/docs/MemorySanitizer.rst
+++ clang/docs/MemorySanitizer.rst
@@ -85,6 +85,15 @@
 avoid false positives.  This attribute may not be supported by other compilers,
 so we suggest to use it together with ``__has_feature(memory_sanitizer)``.
 
+``__attribute__((disable_sanitizer_instrumentation))``
+
+
+The ``disable_sanitizer_instrumentation`` attribute can be applied to functions
+to prevent all kinds of instrumentation. As a result, it may introduce false
+positives and therefore should be used with care, and only if absolutely
+required; for example for certain code that cannot tolerate any instrumentation
+and resulting side-effects. This attribute overrides ``no_sanitize("memory")``.
+
 Ignorelist
 --
 


Index: llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp
===
--- llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp
+++ llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp
@@ -5330,6 +5330,9 @@
   if (!CompileKernel && F.getName() == kMsanModuleCtorName)
 return false;
 
+  if (F.hasFnAttribute(Attribute::DisableSanitizerInstrumentation))
+return false;
+
   MemorySanitizerVisitor Visitor(F, *this, TLI);
 
   // Clear out readonly/readnone attributes.
Index: clang/test/CodeGen/sanitize-memory-disable.c

[PATCH] D108464: [clang][CodeGen] Refactor CreateTempAlloca function nest. NFC.

2021-08-20 Thread Andy Wingo via Phabricator via cfe-commits
wingo created this revision.
wingo added a reviewer: rjmccall.
Herald added subscribers: lxfind, sunfish, dschuff.
wingo requested review of this revision.
Herald added subscribers: cfe-commits, sstefan1, aheejin.
Herald added a reviewer: jdoerfert.
Herald added a project: clang.

It used to be that there were three layers to create temp alloca
instructions in CodeGenFunction.  The lowest level was named
CreateTempAlloca and returned an LLVM instruction (1):

  llvm::AllocaInst* CreateTempAlloca(llvm::Type *Ty);

(Leaving off the name argument and array size from the prototype, for
brevity.)

The next level applied frontend-specified alignment to the alloca and
returned an address, but left the value in the alloca address space (2):

  Address
  CreateTempAllocaWithoutCast(llvm::Type *Ty, CharUnits Align);

Finally the normal function returns an Address, but also makes sure that
the result is in LangAS::Default (3):

  Address
  CreateTempAlloca(QualType Ty, CharUnits Align);

This is a bit confusing since functions (1) and (3) share a name but
have different behavior, and function (2) has a funny name.
Furthermore, the implementation of function (2) actually calls
function (1), making it seem to the reader like there is a loop in the
call graph.

This patch refactors to remove function (1) and replace code that uses
it with calls to function (2), returning an Address instead of an IR
instruction.  This also removes some places in which the frontend wasn't
specifying the alignment of its allocas.

This patch also changes function (2) to explicitly take an address space
argument, which should generally be the alloca address space.  There is
usually one target-specified alloca address space, but in the future,
the WebAssembly target may alloca variables in multiple address spaces.
The function name is changed from CreateTempAllocaWithoutCast to
CreateTempAllocaInAS, indicating that the result is left in the given
AS.

Finally, we also replace uses of the somewhat-deprecated
CreateDefaultAlignTempAlloca with CreateTempAllocaInAS, passing the
result of calling the new CodeGenFunction::PreferredAlignmentForIRType
method as the alignnment.

As a result of this patch, a number of llvm::Value* variables are
changed to be Address instead.  This allows a more simplified codegen,
as the IR builder doesn't need to take an additional alignment argument.

Depends on D108459 .


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D108464

Files:
  clang/lib/CodeGen/CGBuilder.h
  clang/lib/CodeGen/CGCall.cpp
  clang/lib/CodeGen/CGCleanup.cpp
  clang/lib/CodeGen/CGCoroutine.cpp
  clang/lib/CodeGen/CGDecl.cpp
  clang/lib/CodeGen/CGException.cpp
  clang/lib/CodeGen/CGExpr.cpp
  clang/lib/CodeGen/CGExprCXX.cpp
  clang/lib/CodeGen/CGExprScalar.cpp
  clang/lib/CodeGen/CGGPUBuiltin.cpp
  clang/lib/CodeGen/CGOpenMPRuntime.cpp
  clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp
  clang/lib/CodeGen/CGStmt.cpp
  clang/lib/CodeGen/CodeGenFunction.cpp
  clang/lib/CodeGen/CodeGenFunction.h

Index: clang/lib/CodeGen/CodeGenFunction.h
===
--- clang/lib/CodeGen/CodeGenFunction.h
+++ clang/lib/CodeGen/CodeGenFunction.h
@@ -576,7 +576,7 @@
 
   /// A mapping from NRVO variables to the flags used to indicate
   /// when the NRVO has been applied to this variable.
-  llvm::DenseMap NRVOFlags;
+  llvm::DenseMap NRVOFlags;
 
   EHScopeStack EHStack;
   llvm::SmallVector LifetimeExtendedCleanupStack;
@@ -623,11 +623,11 @@
 
   /// The exception slot.  All landing pads write the current exception pointer
   /// into this alloca.
-  llvm::Value *ExceptionSlot = nullptr;
+  Address ExceptionSlot;
 
   /// The selector slot.  Under the MandatoryCleanup model, all landing pads
   /// write the current selector value into this alloca.
-  llvm::AllocaInst *EHSelectorSlot = nullptr;
+  Address EHSelectorSlot;
 
   /// A stack of exception code slots. Entering an __except block pushes a slot
   /// on the stack and leaving pops one. The __exception_code() intrinsic loads
@@ -704,11 +704,11 @@
 
 /// An i1 variable indicating whether or not the @finally is
 /// running for an exception.
-llvm::AllocaInst *ForEHVar;
+Address ForEHVar;
 
 /// An i8* variable into which the exception pointer to rethrow
 /// has been saved.
-llvm::AllocaInst *SavedExnVar;
+Address SavedExnVar;
 
   public:
 void enter(CodeGenFunction &CGF, const Stmt *Finally,
@@ -2470,54 +2470,58 @@
 TBAAAccessInfo *TBAAInfo = nullptr);
   LValue EmitLoadOfPointerLValue(Address Ptr, const PointerType *PtrTy);
 
-  /// CreateTempAlloca - This creates an alloca and inserts it into the entry
-  /// block if \p ArraySize is nullptr, otherwise inserts it at the current
-  /// insertion point of the builder. The caller is responsible for setting an
-  /// appropriate alignment on
-  /// the alloca.
+  /// CreateTempAllocaInAS - Create 

[PATCH] D108199: [msan] Add support for disable_sanitizer_instrumentation attribute

2021-08-20 Thread Alexander Potapenko via Phabricator via cfe-commits
glider added inline comments.



Comment at: clang/docs/MemorySanitizer.rst:91
+
+The ``disable_sanitizer_instrumentation`` attribute can be applied to a certain
+function to prevent all kinds of instrumentation. This attribute overrides

melver wrote:
> Could apply a similar wording to what I suggested on 
> https://reviews.llvm.org/D108202 to deter people from using it.
There's no difference in stack traces (MSan doesn't instrument function 
entries/exits). Apart from that, done.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108199

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


[PATCH] D108464: [clang][CodeGen] Refactor CreateTempAlloca function nest. NFC.

2021-08-20 Thread Andy Wingo via Phabricator via cfe-commits
wingo added a comment.

So... besides the refactor, this is getting closer to where I'm going in 
https://lists.llvm.org/pipermail/cfe-dev/2021-July/068559.html, though still 
NFC.  I think you can see where I would replace `getASTAllocaAddressSpace` with 
`getAllocaAddressSpace(QualType Ty)`, and possibly (depending on the source 
language) avoid casting the resulting alloca to `LangAS::Default`.  WDYT, is 
this sort of thing OK?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108464

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


[PATCH] D108464: [clang][CodeGen] Refactor CreateTempAlloca function nest. NFC.

2021-08-20 Thread Andy Wingo via Phabricator via cfe-commits
wingo added inline comments.



Comment at: clang/lib/CodeGen/CGBuilder.h:115
 
-  /// Emit a load from an i1 flag variable.
-  llvm::LoadInst *CreateFlagLoad(llvm::Value *Addr,

it's the change to always return an `Address` from `CreateTempAlloca` that 
makes these methods unnecessary.



Comment at: clang/lib/CodeGen/CGGPUBuiltin.cpp:116
   llvm::Value *Arg = Args[I].getRValue(*this).getScalarVal();
-  Builder.CreateAlignedStore(Arg, P, DL.getPrefTypeAlign(Arg->getType()));
+  // FIXME: Changing the following line to Builder.CreateStore(Arg, P)
+  // results in a test failure in OpenMP/nvptx_target_printf_codegen, in

this is an open question -- there could be a bug here in the existing code.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108464

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


[clang] 8dc7dcd - [msan] Add support for disable_sanitizer_instrumentation attribute

2021-08-20 Thread Alexander Potapenko via cfe-commits

Author: Alexander Potapenko
Date: 2021-08-20T15:11:26+02:00
New Revision: 8dc7dcdca1e0d0ce4e39305272c8021a1aed07ed

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

LOG: [msan] Add support for disable_sanitizer_instrumentation attribute

Unlike __attribute__((no_sanitize("memory"))), this one will cause MSan
to skip the entire function during instrumentation.

Depends on https://reviews.llvm.org/D108029

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

Added: 
clang/test/CodeGen/sanitize-memory-disable.c

Modified: 
clang/docs/MemorySanitizer.rst
llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp

Removed: 




diff  --git a/clang/docs/MemorySanitizer.rst b/clang/docs/MemorySanitizer.rst
index 3ba5ce5bed3e..c6fc9407ea15 100644
--- a/clang/docs/MemorySanitizer.rst
+++ b/clang/docs/MemorySanitizer.rst
@@ -85,6 +85,15 @@ particular function.  MemorySanitizer may still instrument 
such functions to
 avoid false positives.  This attribute may not be supported by other compilers,
 so we suggest to use it together with ``__has_feature(memory_sanitizer)``.
 
+``__attribute__((disable_sanitizer_instrumentation))``
+
+
+The ``disable_sanitizer_instrumentation`` attribute can be applied to functions
+to prevent all kinds of instrumentation. As a result, it may introduce false
+positives and therefore should be used with care, and only if absolutely
+required; for example for certain code that cannot tolerate any instrumentation
+and resulting side-effects. This attribute overrides ``no_sanitize("memory")``.
+
 Ignorelist
 --
 

diff  --git a/clang/test/CodeGen/sanitize-memory-disable.c 
b/clang/test/CodeGen/sanitize-memory-disable.c
new file mode 100644
index ..5bf4dc9c185e
--- /dev/null
+++ b/clang/test/CodeGen/sanitize-memory-disable.c
@@ -0,0 +1,58 @@
+// RUN: %clang_cc1 -emit-llvm -o - %s | FileCheck -check-prefixes 
CHECK,WITHOUT %s
+// RUN: %clang_cc1 -emit-llvm -o - %s -fsanitize=memory | FileCheck 
-check-prefixes CHECK,MSAN %s
+// RUN: %clang_cc1 -emit-llvm -o - %s -fsanitize=kernel-memory | FileCheck 
-check-prefixes CHECK,KMSAN %s
+
+// Instrumented function.
+// MSan uses memset(addr, -1, size) to poison allocas and stores shadow of the 
return value in
+// __msan_retval_tls. KMSAN uses __msan_poison_alloca() to poison allocas and 
calls
+// __msan_get_context_state() at function prologue to access the task context 
struct (including the
+// shadow of the return value).
+//
+// CHECK-LABEL: i32 @instrumented1
+// KMSAN: __msan_get_context_state
+// WITHOUT-NOT: __msan_poison_alloca
+// WITHOUT-NOT: @llvm.memset
+// MSAN: @llvm.memset{{.*}}({{.*}}, i8 -1
+// KMSAN: __msan_poison_alloca
+// WITHOUT-NOT: __msan_retval_tls
+// MSAN: __msan_retval_tls
+// CHECK: ret i32
+int instrumented1(int *a) {
+  volatile char buf[8];
+  return *a;
+}
+
+// Function with no_sanitize("memory")/no_sanitize("kernel-memory"): no shadow 
propagation, but
+// unpoisons memory to prevent false positives.
+// MSan uses memset(addr, 0, size) to unpoison locals, KMSAN uses 
__msan_unpoison_alloca(). Both
+// tools still access the retval shadow to write 0 to it.
+//
+// CHECK-LABEL: i32 @no_false_positives1
+// KMSAN: __msan_get_context_state
+// WITHOUT-NOT: __msan_unpoison_alloca
+// WITHOUT-NOT: @llvm.memset
+// MSAN: @llvm.memset{{.*}}({{.*}}, i8 0
+// KMSAN: __msan_unpoison_alloca
+// WITHOUT-NOT: __msan_retval_tls
+// MSAN: __msan_retval_tls
+// CHECK: ret i32
+__attribute__((no_sanitize("memory"))) 
__attribute__((no_sanitize("kernel-memory"))) int no_false_positives1(int *a) {
+  volatile char buf[8];
+  return *a;
+}
+
+// Function with disable_sanitizer_instrumentation: no instrumentation at all.
+//
+// CHECK-LABEL: i32 @no_instrumentation1
+// KMSAN-NOT: __msan_get_context_state
+// WITHOUT-NOT: __msan_poison_alloca
+// WITHOUT-NOT: @llvm.memset
+// MSAN-NOT: @llvm.memset{{.*}}({{.*}}, i8 0
+// KMSAN-NOT: __msan_unpoison_alloca
+// WITHOUT-NOT: __msan_retval_tls
+// MSAN-NOT: __msan_retval_tls
+// CHECK: ret i32
+__attribute__((disable_sanitizer_instrumentation)) int no_instrumentation1(int 
*a) {
+  volatile char buf[8];
+  return *a;
+}

diff  --git a/llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp 
b/llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp
index 7e6709be4bbf..9b4cc9c46f45 100644
--- a/llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp
+++ b/llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp
@@ -5330,6 +5330,9 @@ bool MemorySanitizer::sanitizeFunction(Function &F, 
TargetLibraryInfo &TLI) {
   if (!CompileKernel && F.getName() == kMsanModuleCtorName)
 return false;
 
+  if (F.hasFnAttribute(Attribute::DisableSanitizerInstrumentation))
+return false;
+
   Me

[PATCH] D108199: [msan] Add support for disable_sanitizer_instrumentation attribute

2021-08-20 Thread Alexander Potapenko 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 rG8dc7dcdca1e0: [msan] Add support for 
disable_sanitizer_instrumentation attribute (authored by glider).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108199

Files:
  clang/docs/MemorySanitizer.rst
  clang/test/CodeGen/sanitize-memory-disable.c
  llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp


Index: llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp
===
--- llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp
+++ llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp
@@ -5330,6 +5330,9 @@
   if (!CompileKernel && F.getName() == kMsanModuleCtorName)
 return false;
 
+  if (F.hasFnAttribute(Attribute::DisableSanitizerInstrumentation))
+return false;
+
   MemorySanitizerVisitor Visitor(F, *this, TLI);
 
   // Clear out readonly/readnone attributes.
Index: clang/test/CodeGen/sanitize-memory-disable.c
===
--- /dev/null
+++ clang/test/CodeGen/sanitize-memory-disable.c
@@ -0,0 +1,58 @@
+// RUN: %clang_cc1 -emit-llvm -o - %s | FileCheck -check-prefixes 
CHECK,WITHOUT %s
+// RUN: %clang_cc1 -emit-llvm -o - %s -fsanitize=memory | FileCheck 
-check-prefixes CHECK,MSAN %s
+// RUN: %clang_cc1 -emit-llvm -o - %s -fsanitize=kernel-memory | FileCheck 
-check-prefixes CHECK,KMSAN %s
+
+// Instrumented function.
+// MSan uses memset(addr, -1, size) to poison allocas and stores shadow of the 
return value in
+// __msan_retval_tls. KMSAN uses __msan_poison_alloca() to poison allocas and 
calls
+// __msan_get_context_state() at function prologue to access the task context 
struct (including the
+// shadow of the return value).
+//
+// CHECK-LABEL: i32 @instrumented1
+// KMSAN: __msan_get_context_state
+// WITHOUT-NOT: __msan_poison_alloca
+// WITHOUT-NOT: @llvm.memset
+// MSAN: @llvm.memset{{.*}}({{.*}}, i8 -1
+// KMSAN: __msan_poison_alloca
+// WITHOUT-NOT: __msan_retval_tls
+// MSAN: __msan_retval_tls
+// CHECK: ret i32
+int instrumented1(int *a) {
+  volatile char buf[8];
+  return *a;
+}
+
+// Function with no_sanitize("memory")/no_sanitize("kernel-memory"): no shadow 
propagation, but
+// unpoisons memory to prevent false positives.
+// MSan uses memset(addr, 0, size) to unpoison locals, KMSAN uses 
__msan_unpoison_alloca(). Both
+// tools still access the retval shadow to write 0 to it.
+//
+// CHECK-LABEL: i32 @no_false_positives1
+// KMSAN: __msan_get_context_state
+// WITHOUT-NOT: __msan_unpoison_alloca
+// WITHOUT-NOT: @llvm.memset
+// MSAN: @llvm.memset{{.*}}({{.*}}, i8 0
+// KMSAN: __msan_unpoison_alloca
+// WITHOUT-NOT: __msan_retval_tls
+// MSAN: __msan_retval_tls
+// CHECK: ret i32
+__attribute__((no_sanitize("memory"))) 
__attribute__((no_sanitize("kernel-memory"))) int no_false_positives1(int *a) {
+  volatile char buf[8];
+  return *a;
+}
+
+// Function with disable_sanitizer_instrumentation: no instrumentation at all.
+//
+// CHECK-LABEL: i32 @no_instrumentation1
+// KMSAN-NOT: __msan_get_context_state
+// WITHOUT-NOT: __msan_poison_alloca
+// WITHOUT-NOT: @llvm.memset
+// MSAN-NOT: @llvm.memset{{.*}}({{.*}}, i8 0
+// KMSAN-NOT: __msan_unpoison_alloca
+// WITHOUT-NOT: __msan_retval_tls
+// MSAN-NOT: __msan_retval_tls
+// CHECK: ret i32
+__attribute__((disable_sanitizer_instrumentation)) int no_instrumentation1(int 
*a) {
+  volatile char buf[8];
+  return *a;
+}
Index: clang/docs/MemorySanitizer.rst
===
--- clang/docs/MemorySanitizer.rst
+++ clang/docs/MemorySanitizer.rst
@@ -85,6 +85,15 @@
 avoid false positives.  This attribute may not be supported by other compilers,
 so we suggest to use it together with ``__has_feature(memory_sanitizer)``.
 
+``__attribute__((disable_sanitizer_instrumentation))``
+
+
+The ``disable_sanitizer_instrumentation`` attribute can be applied to functions
+to prevent all kinds of instrumentation. As a result, it may introduce false
+positives and therefore should be used with care, and only if absolutely
+required; for example for certain code that cannot tolerate any instrumentation
+and resulting side-effects. This attribute overrides ``no_sanitize("memory")``.
+
 Ignorelist
 --
 


Index: llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp
===
--- llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp
+++ llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp
@@ -5330,6 +5330,9 @@
   if (!CompileKernel && F.getName() == kMsanModuleCtorName)
 return false;
 
+  if (F.hasFnAttribute(Attribute::DisableSanitizerInstrumentation))
+return false;
+
   MemorySanitizerVisitor Visitor(F, *this, TLI)

[PATCH] D108403: Fix assertion when generating diagnostic for inline namespaces

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

In D108403#2957084 , @aaron.ballman 
wrote:

> In D108403#2955651 , @erichkeane 
> wrote:
>
>> This whole function seems a little suspect, but I don't have a good example 
>> of a place it would break.  Is there no cases where a lookup could result in 
>> the same COUNT but different declaration set? I guess it is more the 
>> question of whether a transparent context can 'lose' a name lookup (perhaps 
>> a case of conflicting names?), then have it added by the local namespace.
>
> I don't believe transparent contexts can lose a name lookup -- they're 
> transparent, so the declarations aren't owned by that context, they're owned 
> by the first non-transparent context they run into (as I understand it, 
> anyway). However, the important bit on this patch is: `lookup()` asserts that 
> you're not trying to call it on a transparent context, so that tells me that 
> we should walk until we find a non-transparent context rather than the 
> current approach of assuming the parent is not transparent.

Right... you're probably right here, the mechanism with 'lookup' just feels 1/2 
too clever.  Anyway, I think I believe that is a battle for another day.  See 
the clang-format warning above, otherwise LGTM.


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

https://reviews.llvm.org/D108403

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


[clang] c94f4a9 - ClangOffloadBundler - getCompatibleOffloadTargets - Fix unknown parameter Wdocumentation warnings. NFC.

2021-08-20 Thread Simon Pilgrim via cfe-commits

Author: Simon Pilgrim
Date: 2021-08-20T14:31:11+01:00
New Revision: c94f4a9c5d8ca826986c9490e668ba66afad3419

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

LOG: ClangOffloadBundler - getCompatibleOffloadTargets - Fix unknown parameter 
Wdocumentation warnings. NFC.

Added: 


Modified: 
clang/tools/clang-offload-bundler/ClangOffloadBundler.cpp

Removed: 




diff  --git a/clang/tools/clang-offload-bundler/ClangOffloadBundler.cpp 
b/clang/tools/clang-offload-bundler/ClangOffloadBundler.cpp
index 43f7091c97f3..49275ec198c2 100644
--- a/clang/tools/clang-offload-bundler/ClangOffloadBundler.cpp
+++ b/clang/tools/clang-offload-bundler/ClangOffloadBundler.cpp
@@ -1099,8 +1099,8 @@ bool isCodeObjectCompatible(OffloadTargetInfo 
&CodeObjectInfo,
 
 /// @brief Computes a list of targets among all given targets which are
 /// compatible with this code object
-/// @param [in] Code Object \p CodeObject
-/// @param [out] List of all compatible targets \p CompatibleTargets among all
+/// @param [in] CodeObjectInfo Code Object
+/// @param [out] CompatibleTargets List of all compatible targets among all
 /// given targets
 /// @return false, if no compatible target is found.
 static bool



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


[PATCH] D108451: [Sema] Avoid crash in CheckEnumConstant with contains-error expressions

2021-08-20 Thread Haojian Wu via Phabricator via cfe-commits
hokein accepted this revision.
hokein added a comment.
This revision is now accepted and ready to land.

Thanks!




Comment at: clang/lib/Sema/SemaDecl.cpp:17752
+if (Enum->isDependentType() || Val->isTypeDependent() ||
+Val->containsErrors())
   EltTy = Context.DependentTy;

What's happening during the crash:

- the EltTy is an enum type which points to an incomplete enum decl 
- the EnumDecl::getIntegerType() returns a null type
- ASTContext.getIntWidth crashes on a null type

As discussed, an alternative is to add a guard for incomplete-type EltTy (and 
assert that we only see this case for recovery-expr case), a disadvantage is 
that this might be narrow...

The current solution also seems fine to me.



Comment at: clang/test/Sema/enum.cpp:1
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+

I'd put the test case in `clang/test/SemaCXX/recovery-expr-type.cpp`


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108451

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


[PATCH] D104601: [Preprocessor] Implement -fminimize-whitespace.

2021-08-20 Thread Simon Pilgrim via Phabricator via cfe-commits
RKSimon added inline comments.



Comment at: clang/lib/Frontend/PrintPreprocessedOutput.cpp:680
+if (RequireSpace || (!MinimizeWhitespace && Tok.hasLeadingSpace()) ||
+((EmittedTokensOnThisLine || EmittedTokensOnThisLine) &&
+ AvoidConcat(PrevPrevTok, PrevTok, Tok)))

@Meinersbur Static analysis is warning that these are both the same - should 
one be EmittedDirectiveOnThisLine ?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D104601

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


[clang] 48f73ee - Fix assertion when generating diagnostic for inline namespaces

2021-08-20 Thread Aaron Ballman via cfe-commits

Author: Aaron Ballman
Date: 2021-08-20T09:50:24-04:00
New Revision: 48f73ee666a264d23716ff6bb671cad836b65ccf

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

LOG: Fix assertion when generating diagnostic for inline namespaces

When calculating the name to display for inline namespaces, we have
custom logic to try to hide redundant inline namespaces from the
diagnostic. Calculating these redundancies requires performing a lookup
in the parent declaration context, but that lookup should not try to
look through transparent declaration contexts, like linkage
specifications. Instead, loop up the declaration context chain until we
find a non-transparent context and use that instead.

This fixes PR49954.

Added: 


Modified: 
clang/include/clang/AST/Decl.h
clang/include/clang/AST/DeclBase.h
clang/lib/AST/DeclBase.cpp
clang/test/Misc/diag-inline-namespace.cpp

Removed: 




diff  --git a/clang/include/clang/AST/Decl.h b/clang/include/clang/AST/Decl.h
index 30923a4fa05c..d124ed282bb1 100644
--- a/clang/include/clang/AST/Decl.h
+++ b/clang/include/clang/AST/Decl.h
@@ -614,7 +614,9 @@ class NamespaceDecl : public NamedDecl, public DeclContext,
 if (!isInline())
   return false;
 auto X = lookup(Name);
-auto Y = getParent()->lookup(Name);
+// We should not perform a lookup within a transparent context, so find a
+// non-transparent parent context.
+auto Y = getParent()->getNonTransparentContext()->lookup(Name);
 return std::distance(X.begin(), X.end()) ==
   std::distance(Y.begin(), Y.end());
   }

diff  --git a/clang/include/clang/AST/DeclBase.h 
b/clang/include/clang/AST/DeclBase.h
index 482d2889a25a..18468c8ca1c4 100644
--- a/clang/include/clang/AST/DeclBase.h
+++ b/clang/include/clang/AST/DeclBase.h
@@ -1997,6 +1997,12 @@ class DeclContext {
 return const_cast(this)->getNonClosureAncestor();
   }
 
+  // Retrieve the nearest context that is not a transparent context.
+  DeclContext *getNonTransparentContext();
+  const DeclContext *getNonTransparentContext() const {
+return const_cast(this)->getNonTransparentContext();
+  }
+
   /// getPrimaryContext - There may be many 
diff erent
   /// declarations of the same entity (including forward declarations
   /// of classes, multiple definitions of namespaces, etc.), each with

diff  --git a/clang/lib/AST/DeclBase.cpp b/clang/lib/AST/DeclBase.cpp
index 3467da2b549e..53dd2ae3cbd3 100644
--- a/clang/lib/AST/DeclBase.cpp
+++ b/clang/lib/AST/DeclBase.cpp
@@ -1217,6 +1217,13 @@ bool DeclContext::Encloses(const DeclContext *DC) const {
   return false;
 }
 
+DeclContext *DeclContext::getNonTransparentContext() {
+  DeclContext *DC = this;
+  while (DC && DC->isTransparentContext())
+DC = DC->getParent();
+  return DC;
+}
+
 DeclContext *DeclContext::getPrimaryContext() {
   switch (getDeclKind()) {
   case Decl::ExternCContext:

diff  --git a/clang/test/Misc/diag-inline-namespace.cpp 
b/clang/test/Misc/diag-inline-namespace.cpp
index 74bdeed68d21..34d549bc1cc0 100644
--- a/clang/test/Misc/diag-inline-namespace.cpp
+++ b/clang/test/Misc/diag-inline-namespace.cpp
@@ -48,3 +48,14 @@ namespace N {
   T t4; // expected-error {{implicit instantiation of 
undefined template 'N::T'}}
   T t5; // expected-error {{implicit instantiation of 
undefined template 'N::T'}}
 }
+
+namespace dont_crash {
+// A malformed lookup involving inline namespaces in a linkage specification
+// would previous cause an assertion due to the way diagnostics are emitted.
+extern "C++" inline namespace {
+namespace a {
+  a : b // expected-error {{unexpected ':' in nested name specifier; did you 
mean '::'?}} \
+// expected-error {{no type named 'b' in namespace 'dont_crash::a'}}
+} // expected-error {{expected unqualified-id}}
+} // inline namespace
+} // dont_crash



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


[PATCH] D108465: [msan] Hotfix clang/test/CodeGen/sanitize-memory-disable.c

2021-08-20 Thread Alexander Potapenko via Phabricator via cfe-commits
glider created this revision.
glider added reviewers: eugenis, melver.
Herald added a subscriber: pengfei.
glider requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Because KMSAN is not supported on many architectures, explicitly build
the test with -target x86_64-linux-gnu.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D108465

Files:
  clang/test/CodeGen/sanitize-memory-disable.c


Index: clang/test/CodeGen/sanitize-memory-disable.c
===
--- clang/test/CodeGen/sanitize-memory-disable.c
+++ clang/test/CodeGen/sanitize-memory-disable.c
@@ -1,6 +1,6 @@
-// RUN: %clang_cc1 -emit-llvm -o - %s | FileCheck -check-prefixes 
CHECK,WITHOUT %s
-// RUN: %clang_cc1 -emit-llvm -o - %s -fsanitize=memory | FileCheck 
-check-prefixes CHECK,MSAN %s
-// RUN: %clang_cc1 -emit-llvm -o - %s -fsanitize=kernel-memory | FileCheck 
-check-prefixes CHECK,KMSAN %s
+// RUN: %clang -target x86_64-linux-gnu -S -emit-llvm -o - %s | FileCheck 
-check-prefixes CHECK,WITHOUT %s
+// RUN: %clang -target x86_64-linux-gnu -S -emit-llvm -o - %s 
-fsanitize=memory | FileCheck -check-prefixes CHECK,MSAN %s
+// RUN: %clang -target x86_64-linux-gnu -S -emit-llvm -o - %s 
-fsanitize=kernel-memory | FileCheck -check-prefixes CHECK,KMSAN %s
 
 // Instrumented function.
 // MSan uses memset(addr, -1, size) to poison allocas and stores shadow of the 
return value in


Index: clang/test/CodeGen/sanitize-memory-disable.c
===
--- clang/test/CodeGen/sanitize-memory-disable.c
+++ clang/test/CodeGen/sanitize-memory-disable.c
@@ -1,6 +1,6 @@
-// RUN: %clang_cc1 -emit-llvm -o - %s | FileCheck -check-prefixes CHECK,WITHOUT %s
-// RUN: %clang_cc1 -emit-llvm -o - %s -fsanitize=memory | FileCheck -check-prefixes CHECK,MSAN %s
-// RUN: %clang_cc1 -emit-llvm -o - %s -fsanitize=kernel-memory | FileCheck -check-prefixes CHECK,KMSAN %s
+// RUN: %clang -target x86_64-linux-gnu -S -emit-llvm -o - %s | FileCheck -check-prefixes CHECK,WITHOUT %s
+// RUN: %clang -target x86_64-linux-gnu -S -emit-llvm -o - %s -fsanitize=memory | FileCheck -check-prefixes CHECK,MSAN %s
+// RUN: %clang -target x86_64-linux-gnu -S -emit-llvm -o - %s -fsanitize=kernel-memory | FileCheck -check-prefixes CHECK,KMSAN %s
 
 // Instrumented function.
 // MSan uses memset(addr, -1, size) to poison allocas and stores shadow of the return value in
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D108465: [msan] Hotfix clang/test/CodeGen/sanitize-memory-disable.c

2021-08-20 Thread Alexander Potapenko via Phabricator via cfe-commits
glider added a comment.

TBR


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108465

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


[PATCH] D108465: [msan] Hotfix clang/test/CodeGen/sanitize-memory-disable.c

2021-08-20 Thread Marco Elver via Phabricator via cfe-commits
melver accepted this revision.
melver added a comment.
This revision is now accepted and ready to land.

Who reported the issue? Might be worth mentioning in commit message, otherwise 
it appears to come out of nowhere (although it's semi-obvious given x86-64 is 
only supported).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108465

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


[PATCH] D108403: Fix assertion when generating diagnostic for inline namespaces

2021-08-20 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman closed this revision.
aaron.ballman marked an inline comment as done.
aaron.ballman added a comment.

Thanks for the reviews! I've committed (with the formatting fix) in 
48f73ee666a264d23716ff6bb671cad836b65ccf 
.


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

https://reviews.llvm.org/D108403

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


[PATCH] D108465: [msan] Hotfix clang/test/CodeGen/sanitize-memory-disable.c

2021-08-20 Thread Alexander Potapenko via Phabricator via cfe-commits
glider updated this revision to Diff 367783.
glider added a comment.

Updated patch description with links to bot failures.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108465

Files:
  clang/test/CodeGen/sanitize-memory-disable.c


Index: clang/test/CodeGen/sanitize-memory-disable.c
===
--- clang/test/CodeGen/sanitize-memory-disable.c
+++ clang/test/CodeGen/sanitize-memory-disable.c
@@ -1,6 +1,6 @@
-// RUN: %clang_cc1 -emit-llvm -o - %s | FileCheck -check-prefixes 
CHECK,WITHOUT %s
-// RUN: %clang_cc1 -emit-llvm -o - %s -fsanitize=memory | FileCheck 
-check-prefixes CHECK,MSAN %s
-// RUN: %clang_cc1 -emit-llvm -o - %s -fsanitize=kernel-memory | FileCheck 
-check-prefixes CHECK,KMSAN %s
+// RUN: %clang -target x86_64-linux-gnu -S -emit-llvm -o - %s | FileCheck 
-check-prefixes CHECK,WITHOUT %s
+// RUN: %clang -target x86_64-linux-gnu -S -emit-llvm -o - %s 
-fsanitize=memory | FileCheck -check-prefixes CHECK,MSAN %s
+// RUN: %clang -target x86_64-linux-gnu -S -emit-llvm -o - %s 
-fsanitize=kernel-memory | FileCheck -check-prefixes CHECK,KMSAN %s
 
 // Instrumented function.
 // MSan uses memset(addr, -1, size) to poison allocas and stores shadow of the 
return value in


Index: clang/test/CodeGen/sanitize-memory-disable.c
===
--- clang/test/CodeGen/sanitize-memory-disable.c
+++ clang/test/CodeGen/sanitize-memory-disable.c
@@ -1,6 +1,6 @@
-// RUN: %clang_cc1 -emit-llvm -o - %s | FileCheck -check-prefixes CHECK,WITHOUT %s
-// RUN: %clang_cc1 -emit-llvm -o - %s -fsanitize=memory | FileCheck -check-prefixes CHECK,MSAN %s
-// RUN: %clang_cc1 -emit-llvm -o - %s -fsanitize=kernel-memory | FileCheck -check-prefixes CHECK,KMSAN %s
+// RUN: %clang -target x86_64-linux-gnu -S -emit-llvm -o - %s | FileCheck -check-prefixes CHECK,WITHOUT %s
+// RUN: %clang -target x86_64-linux-gnu -S -emit-llvm -o - %s -fsanitize=memory | FileCheck -check-prefixes CHECK,MSAN %s
+// RUN: %clang -target x86_64-linux-gnu -S -emit-llvm -o - %s -fsanitize=kernel-memory | FileCheck -check-prefixes CHECK,KMSAN %s
 
 // Instrumented function.
 // MSan uses memset(addr, -1, size) to poison allocas and stores shadow of the return value in
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D108465: [msan] Hotfix clang/test/CodeGen/sanitize-memory-disable.c

2021-08-20 Thread Alexander Potapenko via Phabricator via cfe-commits
glider added a comment.

In D108465#2957355 , @melver wrote:

> Who reported the issue? Might be worth mentioning in commit message, 
> otherwise it appears to come out of nowhere (although it's semi-obvious given 
> x86-64 is only supported).

Right. Added the links to the bot failures.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108465

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


[clang] 417a49e - [msan] Hotfix clang/test/CodeGen/sanitize-memory-disable.c

2021-08-20 Thread Alexander Potapenko via cfe-commits

Author: Alexander Potapenko
Date: 2021-08-20T16:00:25+02:00
New Revision: 417a49e78e730c964c60840110455c29fb562ee0

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

LOG: [msan] Hotfix clang/test/CodeGen/sanitize-memory-disable.c

Because KMSAN is not supported on many architectures, explicitly build
the test with -target x86_64-linux-gnu.

Fixes the 'unsupported architecture' and 'unsupported operating system'
errors reported by the clang-armv7-quick 
(https://lab.llvm.org/buildbot#builders/171/builds/2595)
and llvm-clang-x86_64-sie-ubuntu-fast 
(https://lab.llvm.org/buildbot#builders/139/builds/9079)
builders.

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

Added: 


Modified: 
clang/test/CodeGen/sanitize-memory-disable.c

Removed: 




diff  --git a/clang/test/CodeGen/sanitize-memory-disable.c 
b/clang/test/CodeGen/sanitize-memory-disable.c
index 5bf4dc9c185e..da3593ac973b 100644
--- a/clang/test/CodeGen/sanitize-memory-disable.c
+++ b/clang/test/CodeGen/sanitize-memory-disable.c
@@ -1,6 +1,6 @@
-// RUN: %clang_cc1 -emit-llvm -o - %s | FileCheck -check-prefixes 
CHECK,WITHOUT %s
-// RUN: %clang_cc1 -emit-llvm -o - %s -fsanitize=memory | FileCheck 
-check-prefixes CHECK,MSAN %s
-// RUN: %clang_cc1 -emit-llvm -o - %s -fsanitize=kernel-memory | FileCheck 
-check-prefixes CHECK,KMSAN %s
+// RUN: %clang -target x86_64-linux-gnu -S -emit-llvm -o - %s | FileCheck 
-check-prefixes CHECK,WITHOUT %s
+// RUN: %clang -target x86_64-linux-gnu -S -emit-llvm -o - %s 
-fsanitize=memory | FileCheck -check-prefixes CHECK,MSAN %s
+// RUN: %clang -target x86_64-linux-gnu -S -emit-llvm -o - %s 
-fsanitize=kernel-memory | FileCheck -check-prefixes CHECK,KMSAN %s
 
 // Instrumented function.
 // MSan uses memset(addr, -1, size) to poison allocas and stores shadow of the 
return value in



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


[PATCH] D108465: [msan] Hotfix clang/test/CodeGen/sanitize-memory-disable.c

2021-08-20 Thread Alexander Potapenko 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 rG417a49e78e73: [msan] Hotfix 
clang/test/CodeGen/sanitize-memory-disable.c (authored by glider).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108465

Files:
  clang/test/CodeGen/sanitize-memory-disable.c


Index: clang/test/CodeGen/sanitize-memory-disable.c
===
--- clang/test/CodeGen/sanitize-memory-disable.c
+++ clang/test/CodeGen/sanitize-memory-disable.c
@@ -1,6 +1,6 @@
-// RUN: %clang_cc1 -emit-llvm -o - %s | FileCheck -check-prefixes 
CHECK,WITHOUT %s
-// RUN: %clang_cc1 -emit-llvm -o - %s -fsanitize=memory | FileCheck 
-check-prefixes CHECK,MSAN %s
-// RUN: %clang_cc1 -emit-llvm -o - %s -fsanitize=kernel-memory | FileCheck 
-check-prefixes CHECK,KMSAN %s
+// RUN: %clang -target x86_64-linux-gnu -S -emit-llvm -o - %s | FileCheck 
-check-prefixes CHECK,WITHOUT %s
+// RUN: %clang -target x86_64-linux-gnu -S -emit-llvm -o - %s 
-fsanitize=memory | FileCheck -check-prefixes CHECK,MSAN %s
+// RUN: %clang -target x86_64-linux-gnu -S -emit-llvm -o - %s 
-fsanitize=kernel-memory | FileCheck -check-prefixes CHECK,KMSAN %s
 
 // Instrumented function.
 // MSan uses memset(addr, -1, size) to poison allocas and stores shadow of the 
return value in


Index: clang/test/CodeGen/sanitize-memory-disable.c
===
--- clang/test/CodeGen/sanitize-memory-disable.c
+++ clang/test/CodeGen/sanitize-memory-disable.c
@@ -1,6 +1,6 @@
-// RUN: %clang_cc1 -emit-llvm -o - %s | FileCheck -check-prefixes CHECK,WITHOUT %s
-// RUN: %clang_cc1 -emit-llvm -o - %s -fsanitize=memory | FileCheck -check-prefixes CHECK,MSAN %s
-// RUN: %clang_cc1 -emit-llvm -o - %s -fsanitize=kernel-memory | FileCheck -check-prefixes CHECK,KMSAN %s
+// RUN: %clang -target x86_64-linux-gnu -S -emit-llvm -o - %s | FileCheck -check-prefixes CHECK,WITHOUT %s
+// RUN: %clang -target x86_64-linux-gnu -S -emit-llvm -o - %s -fsanitize=memory | FileCheck -check-prefixes CHECK,MSAN %s
+// RUN: %clang -target x86_64-linux-gnu -S -emit-llvm -o - %s -fsanitize=kernel-memory | FileCheck -check-prefixes CHECK,KMSAN %s
 
 // Instrumented function.
 // MSan uses memset(addr, -1, size) to poison allocas and stores shadow of the return value in
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D105177: [clangd] Implemented indexing of standard library

2021-08-20 Thread Christian Kühnel via Phabricator via cfe-commits
kuhnel updated this revision to Diff 367787.
kuhnel added a comment.

fixing windows build


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105177

Files:
  clang-tools-extra/clangd/CMakeLists.txt
  clang-tools-extra/clangd/ClangdServer.cpp
  clang-tools-extra/clangd/FS.cpp
  clang-tools-extra/clangd/FS.h
  clang-tools-extra/clangd/index/StdLib.cpp
  clang-tools-extra/clangd/index/StdLib.h
  clang-tools-extra/clangd/unittests/CMakeLists.txt
  clang-tools-extra/clangd/unittests/StdLibIndexTests.cpp

Index: clang-tools-extra/clangd/unittests/StdLibIndexTests.cpp
===
--- /dev/null
+++ clang-tools-extra/clangd/unittests/StdLibIndexTests.cpp
@@ -0,0 +1,61 @@
+//===-- StdLibIndexTests.cpp *- 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 "FuzzyMatch.h"
+#include "TestFS.h"
+#include "TestIndex.h"
+#include "index/StdLib.h"
+#include "support/Logger.h"
+#include "llvm/Support/Error.h"
+#include "llvm/Testing/Support/Error.h"
+#include "gmock/gmock.h"
+#include "gtest/gtest.h"
+#include 
+
+using namespace testing;
+
+namespace clang {
+namespace clangd {
+
+/// check that the generated header sources contains some usual standard library
+/// headers
+TEST(StdLibIndexTests, generateUmbrellaHeader) {
+  MockFS FS;
+  auto UmbrellaHeader =
+  generateUmbrellaHeaders(StandardLibrarVariant::CXX14).str();
+
+  EXPECT_THAT(UmbrellaHeader, HasSubstr("#include "));
+  EXPECT_THAT(UmbrellaHeader, HasSubstr("#include "));
+  EXPECT_THAT(UmbrellaHeader, HasSubstr("#include "));
+}
+
+/// build the index and check if it contains the right symbols
+TEST(StdLibIndexTests, buildIndex) {
+  MockFS FS;
+  // TODO: maybe find a way to use a local libcxx for testing if that is
+  //   available on the machine
+  std::string HeaderMock = R"CPP(
+int myfunc(int a);
+bool otherfunc(int a, int b);
+  )CPP";
+  auto Index =
+  indexUmbrellaHeaders(HeaderMock, FS, StandardLibrarVariant::CXX14);
+  ASSERT_TRUE(Index != nullptr);
+
+  FuzzyFindRequest Req;
+  Req.AnyScope = true;
+  EXPECT_THAT(match(*Index, Req),
+  UnorderedElementsAre(llvm::StringRef("myfunc"),
+   llvm::StringRef("otherfunc")));
+}
+
+// TODO: add tests for indexStandardLibrary()
+// TODO: test with different library versions
+
+} // namespace clangd
+} // namespace clang
Index: clang-tools-extra/clangd/unittests/CMakeLists.txt
===
--- clang-tools-extra/clangd/unittests/CMakeLists.txt
+++ clang-tools-extra/clangd/unittests/CMakeLists.txt
@@ -79,6 +79,7 @@
   SemanticSelectionTests.cpp
   SerializationTests.cpp
   SourceCodeTests.cpp
+  StdLibIndexTests.cpp
   SymbolCollectorTests.cpp
   SymbolInfoTests.cpp
   SyncAPI.cpp
Index: clang-tools-extra/clangd/index/StdLib.h
===
--- /dev/null
+++ clang-tools-extra/clangd/index/StdLib.h
@@ -0,0 +1,55 @@
+//===--- StdLib.h *- 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
+//
+//===--===//
+// Clangd indexer for the C++ standard library.
+//
+// The index only contains symbols that are part of the translation unit. So
+// if your translation unit does not yet #include , you do not get
+// auto completion for std::string. However we expect that many users would
+// like to use the the standard library anyway, so we could index that by
+// default an offer e.g. code completion without requiring #includes.
+//===--===//
+
+#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANGD_INDEX_STDLIB_H
+#define LLVM_CLANG_TOOLS_EXTRA_CLANGD_INDEX_STDLIB_H
+
+#include "FS.h"
+#include "index/Index.h"
+#include "index/MemIndex.h"
+#include "support/ThreadsafeFS.h"
+#include "clang/AST/Expr.h"
+#include "llvm/ADT/StringRef.h"
+#include 
+
+namespace clang {
+namespace clangd {
+
+// Enumeration of supported Standard Library versions.
+// FIXME: support muiltiple languages (e.g. C and C++) and versions (e.g. 11,
+// 14, 17) of the standard library.
+// FIXME: add heuristic to detect this version somehow (magically).
+enum class StandardLibrarVariant { CXX14 = 0 };
+
+/// Generate a index of the standard library index for a given variant of
+/// the standard library. This index 

[PATCH] D93110: [analyzer] Implement fine-grained suppressions via attributes

2021-08-20 Thread Valeriy Savchenko via Phabricator via cfe-commits
vsavchenko updated this revision to Diff 367788.
vsavchenko added a comment.
Herald added a subscriber: manas.

Join 'suppress' and 'analyzer_suppress' attributes.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93110

Files:
  clang/include/clang/Basic/Attr.td
  clang/include/clang/Basic/AttrDocs.td
  clang/include/clang/StaticAnalyzer/Core/BugReporter/BugReporter.h
  clang/include/clang/StaticAnalyzer/Core/BugReporter/BugSuppression.h
  clang/lib/Sema/SemaDeclAttr.cpp
  clang/lib/Sema/SemaStmtAttr.cpp
  clang/lib/StaticAnalyzer/Core/BugReporter.cpp
  clang/lib/StaticAnalyzer/Core/BugSuppression.cpp
  clang/lib/StaticAnalyzer/Core/CMakeLists.txt
  clang/test/Analysis/suppression-attr.m
  clang/test/SemaCXX/attr-suppress.cpp
  clang/test/SemaCXX/suppress.cpp
  clang/test/SemaObjC/attr-suppress.m

Index: clang/test/SemaObjC/attr-suppress.m
===
--- /dev/null
+++ clang/test/SemaObjC/attr-suppress.m
@@ -0,0 +1,50 @@
+// RUN: %clang_cc1 -fsyntax-only -fblocks %s -verify
+
+#define SUPPRESS1 __attribute__((suppress))
+#define SUPPRESS2(...) __attribute__((suppress(__VA_ARGS__)))
+
+SUPPRESS1 int global = 42;
+
+SUPPRESS1 void foo() {
+  // expected-error@-1 {{'suppress' attribute only applies to variables and statements}}
+  SUPPRESS1 int *p;
+
+  SUPPRESS1 int a = 0; // no-warning
+  SUPPRESS2()
+  int b = 1; // no-warning
+  SUPPRESS2("a")
+  int c = a + b; // no-warning
+  SUPPRESS2("a", "b") { b = c - a; } // no-warning
+
+  SUPPRESS2("a", "b")
+  if (b == 10)
+a += 4;  // no-warning
+  SUPPRESS1 while (1) {} // no-warning
+  SUPPRESS1 switch (a) { // no-warning
+  default:
+c -= 10;
+  }
+
+  // GNU-style attributes and C++11 attributes apply to different things when
+  // written like this.  GNU  attribute gets attached to the declaration, while
+  // C++11 attribute ends up on the type.
+  int SUPPRESS2("r") z;
+  SUPPRESS2(foo)
+  float f;
+  // expected-error@-2 {{'suppress' attribute requires a string}}
+}
+
+union SUPPRESS2("type.1") U {
+  // expected-error@-1 {{'suppress' attribute only applies to variables and statements}}
+  int i;
+  float f;
+};
+
+SUPPRESS1 @interface Test {
+  // expected-error@-1 {{'suppress' attribute only applies to variables and statements}}
+}
+@property SUPPRESS2("prop") int *prop;
+// expected-error@-1 {{'suppress' attribute only applies to variables and statements}}
+- (void)bar:(int)x SUPPRESS1;
+// expected-error@-1 {{'suppress' attribute only applies to variables and statements}}
+@end
Index: clang/test/SemaCXX/suppress.cpp
===
--- clang/test/SemaCXX/suppress.cpp
+++ /dev/null
@@ -1,25 +0,0 @@
-// RUN: %clang_cc1 -std=c++11 -fsyntax-only %s -verify
-
-[[gsl::suppress("globally")]];
-
-namespace N {
-  [[gsl::suppress("in-a-namespace")]];
-}
-
-[[gsl::suppress("readability-identifier-naming")]]
-void f_() {
-  int *p;
-  [[gsl::suppress("type", "bounds")]] {
-p = reinterpret_cast(7);
-  }
-
-  [[gsl::suppress]] int x; // expected-error {{'suppress' attribute takes at least 1 argument}}
-  [[gsl::suppress()]] int y; // expected-error {{'suppress' attribute takes at least 1 argument}}
-  int [[gsl::suppress("r")]] z; // expected-error {{'suppress' attribute cannot be applied to types}}
-  [[gsl::suppress(f_)]] float f; // expected-error {{'suppress' attribute requires a string}}
-}
-
-union [[gsl::suppress("type.1")]] U {
-  int i;
-  float f;
-};
Index: clang/test/SemaCXX/attr-suppress.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/attr-suppress.cpp
@@ -0,0 +1,62 @@
+// RUN: %clang_cc1 -std=c++11 -fsyntax-only %s -verify
+
+[[gsl::suppress("globally")]];
+
+namespace N {
+[[gsl::suppress("in-a-namespace")]];
+}
+
+[[gsl::suppress("readability-identifier-naming")]] void f_() {
+  int *p;
+  [[gsl::suppress("type", "bounds")]] {
+p = reinterpret_cast(7);
+  }
+
+  [[gsl::suppress]] int x;   // expected-error {{'suppress' attribute takes at least 1 argument}}
+  [[gsl::suppress()]] int y; // expected-error {{'suppress' attribute takes at least 1 argument}}
+  int [[gsl::suppress("r")]] z;  // expected-error {{'suppress' attribute cannot be applied to types}}
+  [[gsl::suppress(f_)]] float f; // expected-error {{'suppress' attribute requires a string}}
+}
+
+union [[gsl::suppress("type.1")]] U {
+  int i;
+  float f;
+};
+
+[[clang::suppress]];
+// expected-error@-1 {{'suppress' attribute only applies to variables and statements}}
+
+namespace N {
+[[clang::suppress("in-a-namespace")]];
+// expected-error@-1 {{'suppress' attribute only applies to variables and statements}}
+} // namespace N
+
+[[clang::suppress]] int global = 42;
+
+[[clang::suppress]] void foo() {
+  // expected-error@-1 {{'suppress' attribute only applies to variables and statem

[PATCH] D93110: [analyzer] Implement fine-grained suppressions via attributes

2021-08-20 Thread Valeriy Savchenko via Phabricator via cfe-commits
vsavchenko added a comment.

Finally I had a chance to come back to this patch.
@aaron.ballman what do you think about it?  I tried to address your notes and 
implemented both features under one attribute.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93110

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


[PATCH] D108422: [NFC][clang] Move remaining part of X86Target.def to llvm/Support/X86TargetParser.def

2021-08-20 Thread Simon Pilgrim via Phabricator via cfe-commits
RKSimon added inline comments.



Comment at: llvm/include/llvm/Support/X86TargetParser.def:220
+
+// FIXME: When commented out features are supported in LLVM, enable them here.
+CPU_SPECIFIC("generic", 'A', "")

what commented out features?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108422

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


[PATCH] D104854: Introduce intrinsic llvm.isnan

2021-08-20 Thread Sanjay Patel via Phabricator via cfe-commits
spatel added a comment.

Is it intentional that we are not canonicalizing the intrinsic call back to 
`fcmp uno` in the default FP environment?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D104854

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


[PATCH] D108422: [NFC][clang] Move remaining part of X86Target.def to llvm/Support/X86TargetParser.def

2021-08-20 Thread Erich Keane via Phabricator via cfe-commits
erichkeane added inline comments.



Comment at: llvm/include/llvm/Support/X86TargetParser.def:220
+
+// FIXME: When commented out features are supported in LLVM, enable them here.
+CPU_SPECIFIC("generic", 'A', "")

RKSimon wrote:
> what commented out features?
So this is copy/pasted from: 
https://github.com/llvm/llvm-project/blob/main/clang/include/clang/Basic/X86Target.def#L70
 (where it will probably be removed in a future patch?).

That comment came from here: https://reviews.llvm.org/D47474

If you look at the 'diff' here: 
https://reviews.llvm.org/D47474?vs=148894&id=156484#toc (1st patch vs last)  
You can see that the original used a bitmask to create the values rather than 
the string list (as suggested by @craig.topper in the review).  That version 
had some commented out in the bitmasks.

However, I never removed the comment!  So this comment likely should just be 
deleted.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108422

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


[clang] c7aacce - Use DeclContext::getNonTransparentContext(); NFC

2021-08-20 Thread Aaron Ballman via cfe-commits

Author: Aaron Ballman
Date: 2021-08-20T11:08:58-04:00
New Revision: c7aacce3046985cedd9c15d69dc52a68850b1659

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

LOG: Use DeclContext::getNonTransparentContext(); NFC

Added: 


Modified: 
clang/lib/Sema/SemaDeclCXX.cpp
clang/lib/Sema/SemaExprMember.cpp

Removed: 




diff  --git a/clang/lib/Sema/SemaDeclCXX.cpp b/clang/lib/Sema/SemaDeclCXX.cpp
index a00a72982bac..4827f6b3bb34 100644
--- a/clang/lib/Sema/SemaDeclCXX.cpp
+++ b/clang/lib/Sema/SemaDeclCXX.cpp
@@ -16836,10 +16836,7 @@ NamedDecl *Sema::ActOnFriendFunctionDecl(Scope *S, 
Declarator &D,
 while (DC->isRecord())
   DC = DC->getParent();
 
-DeclContext *LookupDC = DC;
-while (LookupDC->isTransparentContext())
-  LookupDC = LookupDC->getParent();
-
+DeclContext *LookupDC = DC->getNonTransparentContext();
 while (true) {
   LookupQualifiedName(Previous, LookupDC);
 

diff  --git a/clang/lib/Sema/SemaExprMember.cpp 
b/clang/lib/Sema/SemaExprMember.cpp
index af2aa49c0103..92b7464cd0bb 100644
--- a/clang/lib/Sema/SemaExprMember.cpp
+++ b/clang/lib/Sema/SemaExprMember.cpp
@@ -564,10 +564,7 @@ bool Sema::CheckQualifiedMemberReference(Expr *BaseExpr,
   return false;
 
 // Note that we use the DC of the decl, not the underlying decl.
-DeclContext *DC = (*I)->getDeclContext();
-while (DC->isTransparentContext())
-  DC = DC->getParent();
-
+DeclContext *DC = (*I)->getDeclContext()->getNonTransparentContext();
 if (!DC->isRecord())
   continue;
 



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


[PATCH] D108380: [openmp][nfc] Refactor GridValues

2021-08-20 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert accepted this revision.
jdoerfert added a comment.
This revision is now accepted and ready to land.

LG


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108380

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


[clang] bdeda95 - Make wide multi-character character literals ill-formed

2021-08-20 Thread Aaron Ballman via cfe-commits

Author: Corentin Jabot
Date: 2021-08-20T11:10:53-04:00
New Revision: bdeda959abd74c88a6cfc34b10c1b665cb45cb8d

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

LOG: Make wide multi-character character literals ill-formed

This implements P2362, which has not yet been approved by the
C++ committee, but because wide-multi character literals are
implementation defined, clang might not have to wait for WG21.

This change is also being applied in C mode as the behavior is
implementation-defined in C as well and there's no benefit to
having different rules between the languages.

The other part of P2362, making non-representable character
literals ill-formed, is already implemented by clang

Added: 


Modified: 
clang/docs/ReleaseNotes.rst
clang/include/clang/Basic/DiagnosticLexKinds.td
clang/lib/Lex/LiteralSupport.cpp
clang/test/CodeGen/char-literal.c
clang/test/CodeGen/string-literal-short-wstring.c
clang/test/Lexer/char-literal.cpp
clang/test/Lexer/wchar.c
clang/test/Misc/warning-flags.c
clang/test/Preprocessor/Weverything_pragma.c

Removed: 




diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 7604df7482c7..f728f5b4fcfc 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -100,7 +100,9 @@ Windows Support
 C Language Changes in Clang
 ---
 
-- ...
+- Wide multi-characters literals such as ``L'ab'`` that would previously be 
interpreted as ``L'b'``
+  are now ill-formed in all language modes. The motivation for this change is 
outlined in
+  `P2362 `_.
 
 C++ Language Changes in Clang
 -

diff  --git a/clang/include/clang/Basic/DiagnosticLexKinds.td 
b/clang/include/clang/Basic/DiagnosticLexKinds.td
index 45a5b62af461..c19adf104db1 100644
--- a/clang/include/clang/Basic/DiagnosticLexKinds.td
+++ b/clang/include/clang/Basic/DiagnosticLexKinds.td
@@ -183,12 +183,10 @@ def warn_c2x_compat_digit_separator : Warning<
   InGroup, DefaultIgnore;
 def err_digit_separator_not_between_digits : Error<
   "digit separator cannot appear at %select{start|end}0 of digit sequence">;
-def warn_extraneous_char_constant : Warning<
-  "extraneous characters in character constant ignored">;
 def warn_char_constant_too_large : Warning<
   "character constant too long for its type">;
-def err_multichar_utf_character_literal : Error<
-  "Unicode character literals may not contain multiple characters">;
+def err_multichar_character_literal : Error<
+  "%select{wide|Unicode}0 character literals may not contain multiple 
characters">;
 def err_exponent_has_no_digits : Error<"exponent has no digits">;
 def err_hex_constant_requires : Error<
   "hexadecimal floating %select{constant|literal}0 requires "

diff  --git a/clang/lib/Lex/LiteralSupport.cpp 
b/clang/lib/Lex/LiteralSupport.cpp
index 85d826ce9c6f..f012fb72580e 100644
--- a/clang/lib/Lex/LiteralSupport.cpp
+++ b/clang/lib/Lex/LiteralSupport.cpp
@@ -1390,14 +1390,14 @@ CharLiteralParser::CharLiteralParser(const char *begin, 
const char *end,
   unsigned NumCharsSoFar = buffer_begin - &codepoint_buffer.front();
 
   if (NumCharsSoFar > 1) {
-if (isWide())
-  PP.Diag(Loc, diag::warn_extraneous_char_constant);
-else if (isAscii() && NumCharsSoFar == 4)
+if (isAscii() && NumCharsSoFar == 4)
   PP.Diag(Loc, diag::warn_four_char_character_literal);
 else if (isAscii())
   PP.Diag(Loc, diag::warn_multichar_character_literal);
-else
-  PP.Diag(Loc, diag::err_multichar_utf_character_literal);
+else {
+  PP.Diag(Loc, diag::err_multichar_character_literal) << (isWide() ? 0 : 
1);
+  HadError = true;
+}
 IsMultiChar = true;
   } else {
 IsMultiChar = false;

diff  --git a/clang/test/CodeGen/char-literal.c 
b/clang/test/CodeGen/char-literal.c
index 6fdf8b7c02b1..c7a2a7bee471 100644
--- a/clang/test/CodeGen/char-literal.c
+++ b/clang/test/CodeGen/char-literal.c
@@ -1,5 +1,4 @@
 // RUN: %clang_cc1 -triple i386-unknown-unknown -emit-llvm %s -o - | FileCheck 
-check-prefix=CHECK-C %s
-// RUN: %clang_cc1 -x c++ -triple i386-unknown-unknown -emit-llvm %s -o - | 
FileCheck -check-prefix=CHECK-C %s
 // RUN: %clang_cc1 -x c++ -std=c++11 -triple i386-unknown-unknown -emit-llvm 
%s -o - | FileCheck -check-prefix=CHECK-CPP0X %s
 
 #include 
@@ -33,11 +32,6 @@ int main() {
   // CHECK-CPP0X: store i32 97
   wchar_t wa = L'a';
 
-  // Should pick second character.
-  // CHECK-C: store i32 98
-  // CHECK-CPP0X: store i32 98
-  wchar_t wb = L'ab';
-
 #if __cplusplus >= 201103L
   // CHECK-CPP0X: store i16 97
   char16_t ua = u'a';
@@ -83,8 +77,4 @@ int main() {
   char32_t Ud = U'\U0010F00B';
 #endif
 
-  // Should pick second character.
-  // CHECK-C: store i32 1110027
-  // CHECK-CPP0X:

[PATCH] D106215: Make wide multi-character character literals ill-formed

2021-08-20 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman closed this revision.
aaron.ballman added a comment.

Thanks! I've landed in bdeda959abd74c88a6cfc34b10c1b665cb45cb8d 



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D106215

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


[PATCH] D107290: [PoC][RISCV] Add support for the vscale_range attribute

2021-08-20 Thread Fraser Cormack via Phabricator via cfe-commits
frasercrmck added a comment.

Ah no, my mistake. This would be a drop in functionality if `getMaxVScale` is 
removed, since its replacement only checks the IR attribute and will not be 
affected by our backend flags.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D107290

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


[PATCH] D104854: Introduce intrinsic llvm.isnan

2021-08-20 Thread Serge Pavlov via Phabricator via cfe-commits
sepavloff added a comment.

In D104854#2957423 , @spatel wrote:

> Is it intentional that we are not canonicalizing the intrinsic call back to 
> `fcmp uno` in the default FP environment?

It is lowered to unordered comparison by default. Changing `llvm.isnan` to  
`fcmp uno` somewhere in IR would make it possible to optimize out the latter if 
fast-math mode is on. Preserving semantics of `isnan` when fast-math is in 
effect was one of the goals of this change.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D104854

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


[clang] 2a47a84 - [openmp][nfc] Refactor GridValues

2021-08-20 Thread Jon Chesterfield via cfe-commits

Author: Jon Chesterfield
Date: 2021-08-20T16:41:26+01:00
New Revision: 2a47a84b40115b01e03e4d89c1d47ba74beb7bf3

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

LOG: [openmp][nfc] Refactor GridValues

Remove redundant fields and replace pointer with virtual function

Of fourteen fields, three are dead and four can be computed from the
remainder. This leaves a couple of currently dead fields in place as
they are expected to be used from the deviceRTL shortly. Two of the
fields that can be computed are only used from codegen and require a
log2() implementation so are inlined into codegen instead.

This change leaves the new methods in the same location in the struct
as the previous fields for convenience at review.

Reviewed By: jdoerfert

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

Added: 


Modified: 
clang/include/clang/Basic/TargetInfo.h
clang/lib/Basic/Targets/AMDGPU.cpp
clang/lib/Basic/Targets/AMDGPU.h
clang/lib/Basic/Targets/NVPTX.cpp
clang/lib/Basic/Targets/NVPTX.h
clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp
llvm/include/llvm/Frontend/OpenMP/OMPGridValues.h

Removed: 




diff  --git a/clang/include/clang/Basic/TargetInfo.h 
b/clang/include/clang/Basic/TargetInfo.h
index ab855948b447..fe6f67d40b53 100644
--- a/clang/include/clang/Basic/TargetInfo.h
+++ b/clang/include/clang/Basic/TargetInfo.h
@@ -210,9 +210,6 @@ class TargetInfo : public virtual TransferrableTargetInfo,
   unsigned char RegParmMax, SSERegParmMax;
   TargetCXXABI TheCXXABI;
   const LangASMap *AddrSpaceMap;
-  const llvm::omp::GV *GridValues =
-  nullptr; // target-specific GPU grid values that must be
-   // consistent between host RTL (plugin), device RTL, and clang.
 
   mutable StringRef PlatformName;
   mutable VersionTuple PlatformMinVersion;
@@ -1410,10 +1407,10 @@ class TargetInfo : public virtual 
TransferrableTargetInfo,
 return LangAS::Default;
   }
 
-  /// Return a target-specific GPU grid values
-  const llvm::omp::GV &getGridValue() const {
-assert(GridValues != nullptr && "GridValues not initialized");
-return *GridValues;
+  // access target-specific GPU grid values that must be consistent between
+  // host RTL (plugin), deviceRTL and clang.
+  virtual const llvm::omp::GV &getGridValue() const {
+llvm_unreachable("getGridValue not implemented on this target");
   }
 
   /// Retrieve the name of the platform as it is used in the

diff  --git a/clang/lib/Basic/Targets/AMDGPU.cpp 
b/clang/lib/Basic/Targets/AMDGPU.cpp
index cebb19e7ccab..ba7ffa34c73e 100644
--- a/clang/lib/Basic/Targets/AMDGPU.cpp
+++ b/clang/lib/Basic/Targets/AMDGPU.cpp
@@ -17,7 +17,6 @@
 #include "clang/Basic/MacroBuilder.h"
 #include "clang/Basic/TargetBuiltins.h"
 #include "llvm/ADT/StringSwitch.h"
-#include "llvm/Frontend/OpenMP/OMPGridValues.h"
 
 using namespace clang;
 using namespace clang::targets;
@@ -335,7 +334,6 @@ AMDGPUTargetInfo::AMDGPUTargetInfo(const llvm::Triple 
&Triple,
   llvm::AMDGPU::getArchAttrR600(GPUKind)) {
   resetDataLayout(isAMDGCN(getTriple()) ? DataLayoutStringAMDGCN
 : DataLayoutStringR600);
-  GridValues = &llvm::omp::AMDGPUGridValues;
 
   setAddressSpaceMap(Triple.getOS() == llvm::Triple::Mesa3D ||
  !isAMDGCN(Triple));

diff  --git a/clang/lib/Basic/Targets/AMDGPU.h 
b/clang/lib/Basic/Targets/AMDGPU.h
index 77c2c5fd5014..e791a83f38ae 100644
--- a/clang/lib/Basic/Targets/AMDGPU.h
+++ b/clang/lib/Basic/Targets/AMDGPU.h
@@ -370,6 +370,10 @@ class LLVM_LIBRARY_VISIBILITY AMDGPUTargetInfo final : 
public TargetInfo {
 return getLangASFromTargetAS(Constant);
   }
 
+  const llvm::omp::GV &getGridValue() const override {
+return llvm::omp::AMDGPUGridValues;
+  }
+
   /// \returns Target specific vtbl ptr address space.
   unsigned getVtblPtrAddressSpace() const override {
 return static_cast(Constant);

diff  --git a/clang/lib/Basic/Targets/NVPTX.cpp 
b/clang/lib/Basic/Targets/NVPTX.cpp
index d1a34e4a81c5..c245753c93f4 100644
--- a/clang/lib/Basic/Targets/NVPTX.cpp
+++ b/clang/lib/Basic/Targets/NVPTX.cpp
@@ -16,7 +16,6 @@
 #include "clang/Basic/MacroBuilder.h"
 #include "clang/Basic/TargetBuiltins.h"
 #include "llvm/ADT/StringSwitch.h"
-#include "llvm/Frontend/OpenMP/OMPGridValues.h"
 
 using namespace clang;
 using namespace clang::targets;
@@ -65,7 +64,6 @@ NVPTXTargetInfo::NVPTXTargetInfo(const llvm::Triple &Triple,
   TLSSupported = false;
   VLASupported = false;
   AddrSpaceMap = &NVPTXAddrSpaceMap;
-  GridValues = &llvm::omp::NVPTXGridValues;
   UseAddrSpaceMapMangling = true;
 
   // Define available target features

diff  --git a/clang/lib/Basic/Targets/NVPTX.h b/clang/lib/Basic/Targets/NVPTX.h
index c7db3cdaaf10..ef751b8e1a8d 100644

[PATCH] D108380: [openmp][nfc] Refactor GridValues

2021-08-20 Thread Jon Chesterfield 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 rG2a47a84b4011: [openmp][nfc] Refactor GridValues (authored by 
JonChesterfield).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108380

Files:
  clang/include/clang/Basic/TargetInfo.h
  clang/lib/Basic/Targets/AMDGPU.cpp
  clang/lib/Basic/Targets/AMDGPU.h
  clang/lib/Basic/Targets/NVPTX.cpp
  clang/lib/Basic/Targets/NVPTX.h
  clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp
  llvm/include/llvm/Frontend/OpenMP/OMPGridValues.h

Index: llvm/include/llvm/Frontend/OpenMP/OMPGridValues.h
===
--- llvm/include/llvm/Frontend/OpenMP/OMPGridValues.h
+++ llvm/include/llvm/Frontend/OpenMP/OMPGridValues.h
@@ -62,19 +62,13 @@
   const unsigned GV_Slot_Size;
   /// The default value of maximum number of threads in a worker warp.
   const unsigned GV_Warp_Size;
-  /// Alternate warp size for some AMDGCN architectures. Same as GV_Warp_Size
-  /// for NVPTX.
-  const unsigned GV_Warp_Size_32;
-  /// The number of bits required to represent the max number of threads in warp
-  const unsigned GV_Warp_Size_Log2;
-  /// GV_Warp_Size * GV_Slot_Size,
-  const unsigned GV_Warp_Slot_Size;
+
+  constexpr unsigned warpSlotSize() const {
+return GV_Warp_Size * GV_Slot_Size;
+  }
+
   /// the maximum number of teams.
   const unsigned GV_Max_Teams;
-  /// Global Memory Alignment
-  const unsigned GV_Mem_Align;
-  /// (~0u >> (GV_Warp_Size - GV_Warp_Size_Log2))
-  const unsigned GV_Warp_Size_Log2_Mask;
   // An alternative to the heavy data sharing infrastructure that uses global
   // memory is one that uses device __shared__ memory.  The amount of such space
   // (in bytes) reserved by the OpenMP runtime is noted here.
@@ -83,47 +77,32 @@
   const unsigned GV_Max_WG_Size;
   // The default maximum team size for a working group
   const unsigned GV_Default_WG_Size;
-  // This is GV_Max_WG_Size / GV_WarpSize. 32 for NVPTX and 16 for AMDGCN.
-  const unsigned GV_Max_Warp_Number;
-  /// The slot size that should be reserved for a working warp.
-  /// (~0u >> (GV_Warp_Size - GV_Warp_Size_Log2))
-  const unsigned GV_Warp_Size_Log2_MaskL;
+
+  constexpr unsigned maxWarpNumber() const {
+return GV_Max_WG_Size / GV_Warp_Size;
+  }
 };
 
 /// For AMDGPU GPUs
 static constexpr GV AMDGPUGridValues = {
-448,   // GV_Threads
-256,   // GV_Slot_Size
-64,// GV_Warp_Size
-32,// GV_Warp_Size_32
-6, // GV_Warp_Size_Log2
-64 * 256,  // GV_Warp_Slot_Size
-128,   // GV_Max_Teams
-256,   // GV_Mem_Align
-63,// GV_Warp_Size_Log2_Mask
-896,   // GV_SimpleBufferSize
-1024,  // GV_Max_WG_Size,
-256,   // GV_Defaut_WG_Size
-1024 / 64, // GV_Max_WG_Size / GV_WarpSize
-63 // GV_Warp_Size_Log2_MaskL
+448,  // GV_Threads
+256,  // GV_Slot_Size
+64,   // GV_Warp_Size
+128,  // GV_Max_Teams
+896,  // GV_SimpleBufferSize
+1024, // GV_Max_WG_Size,
+256,  // GV_Default_WG_Size
 };
 
 /// For Nvidia GPUs
 static constexpr GV NVPTXGridValues = {
-992,   // GV_Threads
-256,   // GV_Slot_Size
-32,// GV_Warp_Size
-32,// GV_Warp_Size_32
-5, // GV_Warp_Size_Log2
-32 * 256,  // GV_Warp_Slot_Size
-1024,  // GV_Max_Teams
-256,   // GV_Mem_Align
-(~0u >> (32 - 5)), // GV_Warp_Size_Log2_Mask
-896,   // GV_SimpleBufferSize
-1024,  // GV_Max_WG_Size
-128,   // GV_Defaut_WG_Size
-1024 / 32, // GV_Max_WG_Size / GV_WarpSize
-31 // GV_Warp_Size_Log2_MaskL
+992,  // GV_Threads
+256,  // GV_Slot_Size
+32,   // GV_Warp_Size
+1024, // GV_Max_Teams
+896,  // GV_SimpleBufferSize
+1024, // GV_Max_WG_Size
+128,  // GV_Default_WG_Size
 };
 
 } // namespace omp
Index: clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp
===
--- clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp
+++ clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp
@@ -22,6 +22,7 @@
 #include "llvm/ADT/SmallPtrSet.h"
 #include "llvm/Frontend/OpenMP/OMPGridValues.h"
 #include "llvm/IR/IntrinsicsNVPTX.h"
+#include "llvm/Support/MathExtras.h"
 
 using namespace clang;
 using namespace CodeGen;
@@ -106,8 +107,7 @@
 /// is the same for all known NVPTX architectures.
 enum MachineConfiguration : unsigned {
   /// See "llvm/Frontend/OpenMP/OMPGridValues.h" for various related target
-  /// specific Grid Values like GV_Warp_Size, GV_Warp_Size_Log2,
-  /// and GV_Warp_Size_Log2_Mask.
+  /// specific Grid Values like GV_Warp_Size, GV_Slot_Size
 
   /// Global memory alignment for performance.
   GlobalMemoryAlignment = 128,
@

[PATCH] D104854: Introduce intrinsic llvm.isnan

2021-08-20 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri added a comment.

In D104854#2957471 , @sepavloff wrote:

> In D104854#2957423 , @spatel wrote:
>
>> Is it intentional that we are not canonicalizing the intrinsic call back to 
>> `fcmp uno` in the default FP environment?
>
> It is lowered to unordered comparison by default. Changing `llvm.isnan` to  
> `fcmp uno` somewhere in IR would make it possible to optimize out the latter 
> if fast-math mode is on. Preserving semantics of `isnan` when fast-math is in 
> effect was one of the goals of this change.

Eeek. Was there an RFC about this?
This does not sound good to me at all,
much like "let's not apply fast-math flags to x86 vector intrinsics".


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D104854

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


[PATCH] D108403: Fix assertion when generating diagnostic for inline namespaces

2021-08-20 Thread Corentin Jabot via Phabricator via cfe-commits
cor3ntin added inline comments.



Comment at: clang/lib/AST/DeclBase.cpp:1222
+  DeclContext *DC = this;
+  while (DC && DC->isTransparentContext())
+DC = DC->getParent();

Can getParent() be null? If it cam, then this function can return null which 
you don't check when you call that function. Or it can't and your test is not 
doing anything.


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

https://reviews.llvm.org/D108403

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


[PATCH] D108403: Fix assertion when generating diagnostic for inline namespaces

2021-08-20 Thread Erich Keane via Phabricator via cfe-commits
erichkeane added inline comments.



Comment at: clang/lib/AST/DeclBase.cpp:1222
+  DeclContext *DC = this;
+  while (DC && DC->isTransparentContext())
+DC = DC->getParent();

cor3ntin wrote:
> Can getParent() be null? If it cam, then this function can return null which 
> you don't check when you call that function. Or it can't and your test is not 
> doing anything.
I don't think it can ever be null, a DC of transparent-context type is always 
going to have at least a TranslationUnit as a parent.

I might think an assertion here to replace the `DC &&` part might be worth it.


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

https://reviews.llvm.org/D108403

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


[PATCH] D106616: [Clang][LLVM] generate btf_tag annotations for DIDerived types

2021-08-20 Thread Yonghong Song via Phabricator via cfe-commits
yonghong-song updated this revision to Diff 367797.
yonghong-song added a comment.

- fix clang-format warnings


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D106616

Files:
  clang/lib/CodeGen/CGDebugInfo.cpp
  clang/lib/CodeGen/CGDebugInfo.h
  clang/test/CodeGen/attr-btf_tag-field.c
  llvm/include/llvm/IR/DIBuilder.h
  llvm/include/llvm/IR/DebugInfoMetadata.h
  llvm/lib/AsmParser/LLParser.cpp
  llvm/lib/Bitcode/Reader/MetadataLoader.cpp
  llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
  llvm/lib/IR/AsmWriter.cpp
  llvm/lib/IR/DIBuilder.cpp
  llvm/lib/IR/DebugInfoMetadata.cpp
  llvm/lib/IR/LLVMContextImpl.h
  llvm/test/Bitcode/attr-btf_tag-field.ll

Index: llvm/test/Bitcode/attr-btf_tag-field.ll
===
--- /dev/null
+++ llvm/test/Bitcode/attr-btf_tag-field.ll
@@ -0,0 +1,91 @@
+; REQUIRES: x86-registered-target
+; RUN: llvm-as < %s | llvm-dis | FileCheck %s
+
+%struct.t1 = type { i32 }
+%struct.t2 = type { i8, [3 x i8] }
+
+; Function Attrs: noinline nounwind optnone uwtable
+define dso_local i32 @foo(%struct.t1* %arg) #0 !dbg !9 {
+entry:
+  %arg.addr = alloca %struct.t1*, align 8
+  store %struct.t1* %arg, %struct.t1** %arg.addr, align 8
+  call void @llvm.dbg.declare(metadata %struct.t1** %arg.addr, metadata !20, metadata !DIExpression()), !dbg !21
+  %0 = load %struct.t1*, %struct.t1** %arg.addr, align 8, !dbg !22
+  %a = getelementptr inbounds %struct.t1, %struct.t1* %0, i32 0, i32 0, !dbg !23
+  %1 = load i32, i32* %a, align 4, !dbg !23
+  ret i32 %1, !dbg !24
+}
+
+; Function Attrs: nofree nosync nounwind readnone speculatable willreturn
+declare void @llvm.dbg.declare(metadata, metadata, metadata) #1
+
+; Function Attrs: noinline nounwind optnone uwtable
+define dso_local i32 @foo2(%struct.t2* %arg) #0 !dbg !25 {
+entry:
+  %arg.addr = alloca %struct.t2*, align 8
+  store %struct.t2* %arg, %struct.t2** %arg.addr, align 8
+  call void @llvm.dbg.declare(metadata %struct.t2** %arg.addr, metadata !32, metadata !DIExpression()), !dbg !33
+  %0 = load %struct.t2*, %struct.t2** %arg.addr, align 8, !dbg !34
+  %1 = bitcast %struct.t2* %0 to i8*, !dbg !35
+  %bf.load = load i8, i8* %1, align 4, !dbg !35
+  %bf.shl = shl i8 %bf.load, 7, !dbg !35
+  %bf.ashr = ashr i8 %bf.shl, 7, !dbg !35
+  %bf.cast = sext i8 %bf.ashr to i32, !dbg !35
+  ret i32 %bf.cast, !dbg !36
+}
+
+attributes #0 = { noinline nounwind optnone uwtable "frame-pointer"="all" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
+attributes #1 = { nofree nosync nounwind readnone speculatable willreturn }
+
+!llvm.dbg.cu = !{!0}
+!llvm.module.flags = !{!3, !4, !5, !6, !7}
+!llvm.ident = !{!8}
+
+!0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "clang version 14.0.0 (https://github.com/llvm/llvm-project.git 4cbaee98885ead226304e8836090069db6596965)", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, splitDebugInlining: false, nameTableKind: None)
+!1 = !DIFile(filename: "attr-btf_tag-field.c", directory: "/home/yhs/work/tests/llvm/btf_tag")
+!2 = !{}
+!3 = !{i32 7, !"Dwarf Version", i32 4}
+!4 = !{i32 2, !"Debug Info Version", i32 3}
+!5 = !{i32 1, !"wchar_size", i32 4}
+!6 = !{i32 7, !"uwtable", i32 1}
+!7 = !{i32 7, !"frame-pointer", i32 2}
+!8 = !{!"clang version 14.0.0 (https://github.com/llvm/llvm-project.git 4cbaee98885ead226304e8836090069db6596965)"}
+!9 = distinct !DISubprogram(name: "foo", scope: !1, file: !1, line: 11, type: !10, scopeLine: 11, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !0, retainedNodes: !2)
+!10 = !DISubroutineType(types: !11)
+!11 = !{!12, !13}
+!12 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
+!13 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !14, size: 64)
+!14 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "t1", file: !1, line: 7, size: 32, elements: !15)
+!15 = !{!16}
+!16 = !DIDerivedType(tag: DW_TAG_member, name: "a", scope: !14, file: !1, line: 8, baseType: !12, size: 32, annotations: !17)
+!17 = !{!18, !19}
+!18 = !{!"btf_tag", !"tag1"}
+!19 = !{!"btf_tag", !"tag2"}
+
+; CHECK:!DIDerivedType(tag: DW_TAG_member, name: "a"
+; CHECK-SAME:   annotations: ![[ANNOT:[0-9]+]]
+; CHECK:![[ANNOT]] = !{![[TAG1:[0-9]+]], ![[TAG2:[0-9]+]]}
+; CHECK:![[TAG1]] = !{!"btf_tag", !"tag1"}
+; CHECK:![[TAG2]] = !{!"btf_tag", !"tag2"}
+
+!20 = !DILocalVariable(name: "arg", arg: 1, scope: !9, file: !1, line: 11, type: !13)
+!21 = !DILocation(line: 11, column: 20, scope: !9)
+!22 = !DILocation(line: 12, column: 10, scope: !9)
+!23 = !DILocation(line: 12, column: 15, scope: !9)
+!24 = !DILocation(line: 12, column: 3, scope: !9)
+!25 = distinct !DISubprogram(name: "foo2", scope: !1, file: !1, line: 19, type: !26, scopeLine: 19,

[clang] 2456e11 - [WebAssembly] Add SIMD intrinsics using unsigned integers

2021-08-20 Thread Thomas Lively via cfe-commits

Author: Thomas Lively
Date: 2021-08-20T08:56:51-07:00
New Revision: 2456e11614c10a2e648005e27e3213c77b7ab7a4

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

LOG: [WebAssembly] Add SIMD intrinsics using unsigned integers

For each SIMD intrinsic function that takes or returns a scalar signed integer
value, ensure there is a corresponding intrinsic that returns or an
unsigned value. This is a convenience for users who use -Wsign-conversion so
they don't have to insert explicit casts, especially when the intrinsic
arguments are integer literals that fit into the unsigned integer type but not
the signed type.

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

Added: 


Modified: 
clang/lib/Headers/wasm_simd128.h
clang/test/Headers/wasm.c

Removed: 




diff  --git a/clang/lib/Headers/wasm_simd128.h 
b/clang/lib/Headers/wasm_simd128.h
index e43c31a36e77..498898acaf8a 100644
--- a/clang/lib/Headers/wasm_simd128.h
+++ b/clang/lib/Headers/wasm_simd128.h
@@ -276,12 +276,28 @@ wasm_i8x16_make(int8_t __c0, int8_t __c1, int8_t __c2, 
int8_t __c3, int8_t __c4,
__c12, __c13, __c14, __c15};
 }
 
+static __inline__ v128_t __DEFAULT_FN_ATTRS
+wasm_u8x16_make(uint8_t __c0, uint8_t __c1, uint8_t __c2, uint8_t __c3,
+uint8_t __c4, uint8_t __c5, uint8_t __c6, uint8_t __c7,
+uint8_t __c8, uint8_t __c9, uint8_t __c10, uint8_t __c11,
+uint8_t __c12, uint8_t __c13, uint8_t __c14, uint8_t __c15) {
+  return (v128_t)(__u8x16){__c0,  __c1,  __c2,  __c3, __c4,  __c5,
+   __c6,  __c7,  __c8,  __c9, __c10, __c11,
+   __c12, __c13, __c14, __c15};
+}
+
 static __inline__ v128_t __DEFAULT_FN_ATTRS
 wasm_i16x8_make(int16_t __c0, int16_t __c1, int16_t __c2, int16_t __c3,
 int16_t __c4, int16_t __c5, int16_t __c6, int16_t __c7) {
   return (v128_t)(__i16x8){__c0, __c1, __c2, __c3, __c4, __c5, __c6, __c7};
 }
 
+static __inline__ v128_t __DEFAULT_FN_ATTRS
+wasm_u16x8_make(uint16_t __c0, uint16_t __c1, uint16_t __c2, uint16_t __c3,
+uint16_t __c4, uint16_t __c5, uint16_t __c6, uint16_t __c7) {
+  return (v128_t)(__u16x8){__c0, __c1, __c2, __c3, __c4, __c5, __c6, __c7};
+}
+
 static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_i32x4_make(int32_t __c0,
 int32_t __c1,
 int32_t __c2,
@@ -289,11 +305,23 @@ static __inline__ v128_t __DEFAULT_FN_ATTRS 
wasm_i32x4_make(int32_t __c0,
   return (v128_t)(__i32x4){__c0, __c1, __c2, __c3};
 }
 
+static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_u32x4_make(uint32_t __c0,
+uint32_t __c1,
+uint32_t __c2,
+uint32_t __c3) {
+  return (v128_t)(__u32x4){__c0, __c1, __c2, __c3};
+}
+
 static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_i64x2_make(int64_t __c0,
 int64_t __c1) {
   return (v128_t)(__i64x2){__c0, __c1};
 }
 
+static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_u64x2_make(uint64_t __c0,
+uint64_t __c1) {
+  return (v128_t)(__u64x2){__c0, __c1};
+}
+
 static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_f32x4_make(float __c0,
 float __c1,
 float __c2,
@@ -324,6 +352,24 @@ wasm_i8x16_const(int8_t __c0, int8_t __c1, int8_t __c2, 
int8_t __c3,
__c12, __c13, __c14, __c15};
 }
 
+static __inline__ v128_t __DEFAULT_FN_ATTRS
+wasm_u8x16_const(uint8_t __c0, uint8_t __c1, uint8_t __c2, uint8_t __c3,
+ uint8_t __c4, uint8_t __c5, uint8_t __c6, uint8_t __c7,
+ uint8_t __c8, uint8_t __c9, uint8_t __c10, uint8_t __c11,
+ uint8_t __c12, uint8_t __c13, uint8_t __c14, uint8_t __c15)
+__REQUIRE_CONSTANT(__c0) __REQUIRE_CONSTANT(__c1) __REQUIRE_CONSTANT(__c2)
+__REQUIRE_CONSTANT(__c3) __REQUIRE_CONSTANT(__c4)
+__REQUIRE_CONSTANT(__c5) __REQUIRE_CONSTANT(__c6)
+__REQUIRE_CONSTANT(__c7) __REQUIRE_CONSTANT(__c8)
+__REQUIRE_CONSTANT(__c9) __REQUIRE_CONSTANT(__c10)
+__REQUIRE_CONSTANT(__c11) __REQUIRE_CONSTANT(__c12)
+__REQUIRE_CONSTANT(__c13) __REQUIRE_CONSTANT(__c14)
+__REQUIRE_CONSTANT(__c15) {
+  return (v128_t)(__u8x16){__c0,  __c1,  __c2,  __c3, __c4,  __c5,
+   __c6,  _

[PATCH] D108412: [WebAssembly] Add SIMD intrinsics using unsigned integers

2021-08-20 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 rG2456e11614c1: [WebAssembly] Add SIMD intrinsics using 
unsigned integers (authored by tlively).

Changed prior to commit:
  https://reviews.llvm.org/D108412?vs=367622&id=367798#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108412

Files:
  clang/lib/Headers/wasm_simd128.h
  clang/test/Headers/wasm.c

Index: clang/test/Headers/wasm.c
===
--- clang/test/Headers/wasm.c
+++ clang/test/Headers/wasm.c
@@ -3,7 +3,7 @@
 
 // FIXME: This should not be using -O2 and implicitly testing the entire IR opt pipeline.
 
-// RUN: %clang %s -O2 -emit-llvm -S -o - -target wasm32-unknown-unknown -msimd128 -Wcast-qual -fno-lax-vector-conversions -Werror | FileCheck %s
+// RUN: %clang %s -O2 -emit-llvm -S -o - -target wasm32-unknown-unknown -msimd128 -Wall -Weverything -Wno-missing-prototypes -fno-lax-vector-conversions -Werror | FileCheck %s
 
 #include 
 
@@ -213,7 +213,7 @@
 // CHECK-NEXT:ret void
 //
 void test_v128_store(void *mem, v128_t a) {
-  return wasm_v128_store(mem, a);
+  wasm_v128_store(mem, a);
 }
 
 // CHECK-LABEL: @test_v128_store8_lane(
@@ -224,7 +224,7 @@
 // CHECK-NEXT:ret void
 //
 void test_v128_store8_lane(uint8_t *ptr, v128_t vec) {
-  return wasm_v128_store8_lane(ptr, vec, 15);
+  wasm_v128_store8_lane(ptr, vec, 15);
 }
 
 // CHECK-LABEL: @test_v128_store16_lane(
@@ -235,7 +235,7 @@
 // CHECK-NEXT:ret void
 //
 void test_v128_store16_lane(uint16_t *ptr, v128_t vec) {
-  return wasm_v128_store16_lane(ptr, vec, 7);
+  wasm_v128_store16_lane(ptr, vec, 7);
 }
 
 // CHECK-LABEL: @test_v128_store32_lane(
@@ -245,7 +245,7 @@
 // CHECK-NEXT:ret void
 //
 void test_v128_store32_lane(uint32_t *ptr, v128_t vec) {
-  return wasm_v128_store32_lane(ptr, vec, 3);
+  wasm_v128_store32_lane(ptr, vec, 3);
 }
 
 // CHECK-LABEL: @test_v128_store64_lane(
@@ -256,7 +256,7 @@
 // CHECK-NEXT:ret void
 //
 void test_v128_store64_lane(uint64_t *ptr, v128_t vec) {
-  return wasm_v128_store64_lane(ptr, vec, 1);
+  wasm_v128_store64_lane(ptr, vec, 1);
 }
 
 // CHECK-LABEL: @test_i8x16_make(
@@ -284,6 +284,31 @@
   return wasm_i8x16_make(c0, c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13, c14, c15);
 }
 
+// CHECK-LABEL: @test_u8x16_make(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[VECINIT_I:%.*]] = insertelement <16 x i8> undef, i8 [[C0:%.*]], i32 0
+// CHECK-NEXT:[[VECINIT1_I:%.*]] = insertelement <16 x i8> [[VECINIT_I]], i8 [[C1:%.*]], i32 1
+// CHECK-NEXT:[[VECINIT2_I:%.*]] = insertelement <16 x i8> [[VECINIT1_I]], i8 [[C2:%.*]], i32 2
+// CHECK-NEXT:[[VECINIT3_I:%.*]] = insertelement <16 x i8> [[VECINIT2_I]], i8 [[C3:%.*]], i32 3
+// CHECK-NEXT:[[VECINIT4_I:%.*]] = insertelement <16 x i8> [[VECINIT3_I]], i8 [[C4:%.*]], i32 4
+// CHECK-NEXT:[[VECINIT5_I:%.*]] = insertelement <16 x i8> [[VECINIT4_I]], i8 [[C5:%.*]], i32 5
+// CHECK-NEXT:[[VECINIT6_I:%.*]] = insertelement <16 x i8> [[VECINIT5_I]], i8 [[C6:%.*]], i32 6
+// CHECK-NEXT:[[VECINIT7_I:%.*]] = insertelement <16 x i8> [[VECINIT6_I]], i8 [[C7:%.*]], i32 7
+// CHECK-NEXT:[[VECINIT8_I:%.*]] = insertelement <16 x i8> [[VECINIT7_I]], i8 [[C8:%.*]], i32 8
+// CHECK-NEXT:[[VECINIT9_I:%.*]] = insertelement <16 x i8> [[VECINIT8_I]], i8 [[C9:%.*]], i32 9
+// CHECK-NEXT:[[VECINIT10_I:%.*]] = insertelement <16 x i8> [[VECINIT9_I]], i8 [[C10:%.*]], i32 10
+// CHECK-NEXT:[[VECINIT11_I:%.*]] = insertelement <16 x i8> [[VECINIT10_I]], i8 [[C11:%.*]], i32 11
+// CHECK-NEXT:[[VECINIT12_I:%.*]] = insertelement <16 x i8> [[VECINIT11_I]], i8 [[C12:%.*]], i32 12
+// CHECK-NEXT:[[VECINIT13_I:%.*]] = insertelement <16 x i8> [[VECINIT12_I]], i8 [[C13:%.*]], i32 13
+// CHECK-NEXT:[[VECINIT14_I:%.*]] = insertelement <16 x i8> [[VECINIT13_I]], i8 [[C14:%.*]], i32 14
+// CHECK-NEXT:[[VECINIT15_I:%.*]] = insertelement <16 x i8> [[VECINIT14_I]], i8 [[C15:%.*]], i32 15
+// CHECK-NEXT:[[TMP0:%.*]] = bitcast <16 x i8> [[VECINIT15_I]] to <4 x i32>
+// CHECK-NEXT:ret <4 x i32> [[TMP0]]
+//
+v128_t test_u8x16_make(uint8_t c0, uint8_t c1, uint8_t c2, uint8_t c3, uint8_t c4, uint8_t c5, uint8_t c6, uint8_t c7, uint8_t c8, uint8_t c9, uint8_t c10, uint8_t c11, uint8_t c12, uint8_t c13, uint8_t c14, uint8_t c15) {
+  return wasm_u8x16_make(c0, c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13, c14, c15);
+}
+
 // CHECK-LABEL: @test_i16x8_make(
 // CHECK-NEXT:  entry:
 // CHECK-NEXT:[[VECINIT_I:%.*]] = insertelement <8 x i16> undef, i16 [[C0:%.*]], i32 0
@@ -301,6 +326,23 @@
   return wasm_i16x8_make(c0, c1, c2, c3, c4, c5, c6, c7);
 }
 
+// CHECK-LABEL: @test_u16x8_make(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[VECINIT_I:%.*]] = insertelement <8 x i16> undef, i16 [[C0:%.*]], i32 0
+// CHECK-NEXT:[[VEC

[PATCH] D106616: [Clang][LLVM] generate btf_tag annotations for DIDerived types

2021-08-20 Thread Yonghong Song via Phabricator via cfe-commits
yonghong-song added a comment.

@dblaikie could you take a look at this patch? The same as previous DIComposite 
patch (D106615 ), if the patch is accepted, I 
will break into llvm part and clang part and commit them separately.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D106616

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


[PATCH] D108422: [NFC][clang] Move remaining part of X86Target.def to llvm/Support/X86TargetParser.def

2021-08-20 Thread Craig Topper via Phabricator via cfe-commits
craig.topper added a comment.

I'm not opposed either.




Comment at: llvm/include/llvm/Support/X86TargetParser.def:220
+
+// FIXME: When commented out features are supported in LLVM, enable them here.
+CPU_SPECIFIC("generic", 'A', "")

erichkeane wrote:
> RKSimon wrote:
> > what commented out features?
> So this is copy/pasted from: 
> https://github.com/llvm/llvm-project/blob/main/clang/include/clang/Basic/X86Target.def#L70
>  (where it will probably be removed in a future patch?).
> 
> That comment came from here: https://reviews.llvm.org/D47474
> 
> If you look at the 'diff' here: 
> https://reviews.llvm.org/D47474?vs=148894&id=156484#toc (1st patch vs last)  
> You can see that the original used a bitmask to create the values rather than 
> the string list (as suggested by @craig.topper in the review).  That version 
> had some commented out in the bitmasks.
> 
> However, I never removed the comment!  So this comment likely should just be 
> deleted.
I'm not sure the commented out features made it over. For example, FEATURE_TSX 
was one of the commented out values, but +tsx doesn't appear in these strings.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108422

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


[clang] 65bcdea - Replace an unnecessary null check with an assert; NFC

2021-08-20 Thread Aaron Ballman via cfe-commits

Author: Aaron Ballman
Date: 2021-08-20T12:04:46-04:00
New Revision: 65bcdeaa15b729dae40190c6a990cd67c12e9f10

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

LOG: Replace an unnecessary null check with an assert; NFC

Added: 


Modified: 
clang/lib/AST/DeclBase.cpp

Removed: 




diff  --git a/clang/lib/AST/DeclBase.cpp b/clang/lib/AST/DeclBase.cpp
index 53dd2ae3cbd3..e042ae8dae4a 100644
--- a/clang/lib/AST/DeclBase.cpp
+++ b/clang/lib/AST/DeclBase.cpp
@@ -1219,8 +1219,10 @@ bool DeclContext::Encloses(const DeclContext *DC) const {
 
 DeclContext *DeclContext::getNonTransparentContext() {
   DeclContext *DC = this;
-  while (DC && DC->isTransparentContext())
+  while (DC->isTransparentContext()) {
 DC = DC->getParent();
+assert(DC && "All transparent contexts should have a parent!");
+  }
   return DC;
 }
 



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


[PATCH] D108403: Fix assertion when generating diagnostic for inline namespaces

2021-08-20 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: clang/lib/AST/DeclBase.cpp:1222
+  DeclContext *DC = this;
+  while (DC && DC->isTransparentContext())
+DC = DC->getParent();

erichkeane wrote:
> cor3ntin wrote:
> > Can getParent() be null? If it cam, then this function can return null 
> > which you don't check when you call that function. Or it can't and your 
> > test is not doing anything.
> I don't think it can ever be null, a DC of transparent-context type is always 
> going to have at least a TranslationUnit as a parent.
> 
> I might think an assertion here to replace the `DC &&` part might be worth it.
Thanks for the suggestions! I switched to an assert in 
65bcdeaa15b729dae40190c6a990cd67c12e9f10.


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

https://reviews.llvm.org/D108403

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


[PATCH] D108422: [NFC][clang] Move remaining part of X86Target.def to llvm/Support/X86TargetParser.def

2021-08-20 Thread Simon Pilgrim via Phabricator via cfe-commits
RKSimon added a comment.

There's nothing later than CannonLake here - does Intel need to at least 
reference up to Tiger/Rocketlake?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108422

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


[PATCH] D104854: Introduce intrinsic llvm.isnan

2021-08-20 Thread Sanjay Patel via Phabricator via cfe-commits
spatel added a comment.

In D104854#2957471 , @sepavloff wrote:

> In D104854#2957423 , @spatel wrote:
>
>> Is it intentional that we are not canonicalizing the intrinsic call back to 
>> `fcmp uno` in the default FP environment?
>
> It is lowered to unordered comparison by default. Changing `llvm.isnan` to  
> `fcmp uno` somewhere in IR would make it possible to optimize out the latter 
> if fast-math mode is on. Preserving semantics of `isnan` when fast-math is in 
> effect was one of the goals of this change.

I understand that the codegen was supposed to be no worse, but the difference 
in IR causes optimizer regressions like: 
https://llvm.org/PR51556

If we want this intrinsic (and its siblings that haven't been created yet) to 
survive through IR, then we have to enhance IR passes to recognize the new 
patterns. 
It would be easier to do this in steps: (1) create the intrinsic only if not in 
the default FP env, (2) update IR analysis/passes to recognize the intrinsic, 
(3) create the intrinsic in the default FP env with no FMF, (4) create the 
intrinsic always.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D104854

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


[PATCH] D108469: Improve handling of static assert messages. Instead of dumping the string literal (which quotes it and escape every non-ascii symbol), we can use the content of the string (which we

2021-08-20 Thread Corentin Jabot via Phabricator via cfe-commits
cor3ntin created this revision.
Herald added a subscriber: martong.
cor3ntin requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

...g).

`FormatDiagnostic` is modified to escape
non printable characters and invalid UTF-8.

This ensures that unicode characters, spaces and new
lines are properly rendered in static messages.
This make clang more consistent with other implementation
and fixes this tweet
https://twitter.com/jfbastien/status/1298307325443231744 :)

Of note, `PaddingChecker` did print out new lines that were 
later remove by the diagnostic printing code.
To be consistent with its tests, the new lines are removed
from the diagnostic.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D108469

Files:
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/Basic/Diagnostic.cpp
  clang/lib/Sema/SemaDeclCXX.cpp
  clang/lib/StaticAnalyzer/Checkers/PaddingChecker.cpp
  clang/test/CXX/expr/expr.prim/expr.prim.id/p3.cpp
  clang/test/Lexer/null-character-in-literal.c
  clang/test/Misc/diag-special-chars.c
  clang/test/PCH/cxx-static_assert.cpp
  clang/test/Sema/static-assert.c
  clang/test/SemaCXX/int-ptr-cast-SFINAE.cpp
  clang/test/SemaCXX/static-assert.cpp

Index: clang/test/SemaCXX/static-assert.cpp
===
--- clang/test/SemaCXX/static-assert.cpp
+++ clang/test/SemaCXX/static-assert.cpp
@@ -4,25 +4,25 @@
 
 static_assert(f(), "f"); // expected-error {{static_assert expression is not an integral constant expression}} expected-note {{non-constexpr function 'f' cannot be used in a constant expression}}
 static_assert(true, "true is not false");
-static_assert(false, "false is false"); // expected-error {{static_assert failed "false is false"}}
+static_assert(false, "false is false"); // expected-error {{static_assert failed: false is false}}
 
 void g() {
-static_assert(false, "false is false"); // expected-error {{static_assert failed "false is false"}}
+static_assert(false, "false is false"); // expected-error {{static_assert failed: false is false}}
 }
 
 class C {
-static_assert(false, "false is false"); // expected-error {{static_assert failed "false is false"}}
+static_assert(false, "false is false"); // expected-error {{static_assert failed: false is false}}
 };
 
 template struct T {
-static_assert(N == 2, "N is not 2!"); // expected-error {{static_assert failed due to requirement '1 == 2' "N is not 2!"}}
+static_assert(N == 2, "N is not 2!"); // expected-error {{static_assert failed due to requirement '1 == 2': N is not 2!}}
 };
 
 T<1> t1; // expected-note {{in instantiation of template class 'T<1>' requested here}}
 T<2> t2;
 
 template struct S {
-static_assert(sizeof(T) > sizeof(char), "Type not big enough!"); // expected-error {{static_assert failed due to requirement 'sizeof(char) > sizeof(char)' "Type not big enough!"}}
+static_assert(sizeof(T) > sizeof(char), "Type not big enough!"); // expected-error {{static_assert failed due to requirement 'sizeof(char) > sizeof(char)': Type not big enough!}}
 };
 
 S s1; // expected-note {{in instantiation of template class 'S' requested here}}
@@ -67,7 +67,7 @@
   static const bool value = false;
 };
 
-static_assert(first_trait::value && second_trait::value, "message"); // expected-error{{static_assert failed due to requirement 'second_trait::value' "message"}}
+static_assert(first_trait::value && second_trait::value, "message"); // expected-error{{static_assert failed due to requirement 'second_trait::value': message}}
 
 namespace std {
 
@@ -111,29 +111,29 @@
 };
 
 static_assert(std::is_same::value, "message");
-// expected-error@-1{{static_assert failed due to requirement 'std::is_same::value' "message"}}
+// expected-error@-1{{static_assert failed due to requirement 'std::is_same::value': message}}
 static_assert(std::is_const::value, "message");
-// expected-error@-1{{static_assert failed due to requirement 'std::is_const::value' "message"}}
+// expected-error@-1{{static_assert failed due to requirement 'std::is_const::value': message}}
 static_assert(!std::is_const::value, "message");
-// expected-error@-1{{static_assert failed due to requirement '!std::is_const::value' "message"}}
+// expected-error@-1{{static_assert failed due to requirement '!std::is_const::value': message}}
 static_assert(!(std::is_const::value), "message");
-// expected-error@-1{{static_assert failed due to requirement '!(std::is_const::value)' "message"}}
+// expected-error@-1{{static_assert failed due to requirement '!(std::is_const::value)': message}}
 static_assert(std::is_const::value == false, "message");
-// expected-error@-1{{static_assert failed due to requirement 'std::is_const::value == false' "message"}}
+// expected-error@-1{{static_assert failed due to requirement 'std::is_const::value == false': message}}
 static_assert(!(std::is_const::value == true), "message");
-// expected-error@-1{{s

[PATCH] D108422: [NFC][clang] Move remaining part of X86Target.def to llvm/Support/X86TargetParser.def

2021-08-20 Thread Erich Keane via Phabricator via cfe-commits
erichkeane added a subscriber: LuoYuanke.
erichkeane added a comment.

In D108422#2957528 , @RKSimon wrote:

> There's nothing later than CannonLake here - does Intel need to at least 
> reference up to Tiger/Rocketlake?

@LuoYuanke ^^


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108422

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


[PATCH] D108469: Improve handling of static assert messages.

2021-08-20 Thread Corentin Jabot via Phabricator via cfe-commits
cor3ntin updated this revision to Diff 367802.
cor3ntin retitled this revision from "Improve handling of static assert 
messages.

Instead of dumping the string literal (which
quotes it and escape every non-ascii symbol),
we can use the content of the string
(which we know is valid UTF-8 by virtue if being a
unevaluated string)." to "Improve handling of static assert messages.".
cor3ntin edited the summary of this revision.
cor3ntin added a comment.

Fix avaibility attribute diagnostics


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108469

Files:
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/Basic/Diagnostic.cpp
  clang/lib/Sema/SemaDeclCXX.cpp
  clang/lib/StaticAnalyzer/Checkers/PaddingChecker.cpp
  clang/test/CXX/expr/expr.prim/expr.prim.id/p3.cpp
  clang/test/Lexer/null-character-in-literal.c
  clang/test/Misc/diag-special-chars.c
  clang/test/PCH/cxx-static_assert.cpp
  clang/test/Sema/static-assert.c
  clang/test/SemaCXX/int-ptr-cast-SFINAE.cpp
  clang/test/SemaCXX/static-assert.cpp

Index: clang/test/SemaCXX/static-assert.cpp
===
--- clang/test/SemaCXX/static-assert.cpp
+++ clang/test/SemaCXX/static-assert.cpp
@@ -4,25 +4,25 @@
 
 static_assert(f(), "f"); // expected-error {{static_assert expression is not an integral constant expression}} expected-note {{non-constexpr function 'f' cannot be used in a constant expression}}
 static_assert(true, "true is not false");
-static_assert(false, "false is false"); // expected-error {{static_assert failed "false is false"}}
+static_assert(false, "false is false"); // expected-error {{static_assert failed: false is false}}
 
 void g() {
-static_assert(false, "false is false"); // expected-error {{static_assert failed "false is false"}}
+static_assert(false, "false is false"); // expected-error {{static_assert failed: false is false}}
 }
 
 class C {
-static_assert(false, "false is false"); // expected-error {{static_assert failed "false is false"}}
+static_assert(false, "false is false"); // expected-error {{static_assert failed: false is false}}
 };
 
 template struct T {
-static_assert(N == 2, "N is not 2!"); // expected-error {{static_assert failed due to requirement '1 == 2' "N is not 2!"}}
+static_assert(N == 2, "N is not 2!"); // expected-error {{static_assert failed due to requirement '1 == 2': N is not 2!}}
 };
 
 T<1> t1; // expected-note {{in instantiation of template class 'T<1>' requested here}}
 T<2> t2;
 
 template struct S {
-static_assert(sizeof(T) > sizeof(char), "Type not big enough!"); // expected-error {{static_assert failed due to requirement 'sizeof(char) > sizeof(char)' "Type not big enough!"}}
+static_assert(sizeof(T) > sizeof(char), "Type not big enough!"); // expected-error {{static_assert failed due to requirement 'sizeof(char) > sizeof(char)': Type not big enough!}}
 };
 
 S s1; // expected-note {{in instantiation of template class 'S' requested here}}
@@ -67,7 +67,7 @@
   static const bool value = false;
 };
 
-static_assert(first_trait::value && second_trait::value, "message"); // expected-error{{static_assert failed due to requirement 'second_trait::value' "message"}}
+static_assert(first_trait::value && second_trait::value, "message"); // expected-error{{static_assert failed due to requirement 'second_trait::value': message}}
 
 namespace std {
 
@@ -111,29 +111,29 @@
 };
 
 static_assert(std::is_same::value, "message");
-// expected-error@-1{{static_assert failed due to requirement 'std::is_same::value' "message"}}
+// expected-error@-1{{static_assert failed due to requirement 'std::is_same::value': message}}
 static_assert(std::is_const::value, "message");
-// expected-error@-1{{static_assert failed due to requirement 'std::is_const::value' "message"}}
+// expected-error@-1{{static_assert failed due to requirement 'std::is_const::value': message}}
 static_assert(!std::is_const::value, "message");
-// expected-error@-1{{static_assert failed due to requirement '!std::is_const::value' "message"}}
+// expected-error@-1{{static_assert failed due to requirement '!std::is_const::value': message}}
 static_assert(!(std::is_const::value), "message");
-// expected-error@-1{{static_assert failed due to requirement '!(std::is_const::value)' "message"}}
+// expected-error@-1{{static_assert failed due to requirement '!(std::is_const::value)': message}}
 static_assert(std::is_const::value == false, "message");
-// expected-error@-1{{static_assert failed due to requirement 'std::is_const::value == false' "message"}}
+// expected-error@-1{{static_assert failed due to requirement 'std::is_const::value == false': message}}
 static_assert(!(std::is_const::value == true), "message");
-// expected-error@-1{{static_assert failed due to requirement '!(std::is_const::value == true)' "message"}}
+// expected-error@-1{{static_assert failed due to requirement

[clang] 64a9957 - [WebAssembly] Make shift values unsigned in wasm_simd128.h

2021-08-20 Thread Thomas Lively via cfe-commits

Author: Thomas Lively
Date: 2021-08-20T09:10:37-07:00
New Revision: 64a9957bf7b65a0d10819918ac2a565d69e9c4bb

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

LOG: [WebAssembly] Make shift values unsigned in wasm_simd128.h

On some platforms, negative shift values mean to shift in the opposite
direction, but this is not true with WebAssembly. To avoid confusion, make the
shift values in the shift intrinsics unsigned.

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

Added: 


Modified: 
clang/lib/Headers/wasm_simd128.h
clang/test/Headers/wasm.c

Removed: 




diff  --git a/clang/lib/Headers/wasm_simd128.h 
b/clang/lib/Headers/wasm_simd128.h
index 498898acaf8a..438a54526b33 100644
--- a/clang/lib/Headers/wasm_simd128.h
+++ b/clang/lib/Headers/wasm_simd128.h
@@ -960,17 +960,17 @@ static __inline__ v128_t __DEFAULT_FN_ATTRS 
wasm_i8x16_popcnt(v128_t __a) {
 }
 
 static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_i8x16_shl(v128_t __a,
-   int32_t __b) {
+   uint32_t __b) {
   return (v128_t)((__i8x16)__a << __b);
 }
 
 static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_i8x16_shr(v128_t __a,
-   int32_t __b) {
+   uint32_t __b) {
   return (v128_t)((__i8x16)__a >> __b);
 }
 
 static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_u8x16_shr(v128_t __a,
-   int32_t __b) {
+   uint32_t __b) {
   return (v128_t)((__u8x16)__a >> __b);
 }
 
@@ -1046,17 +1046,17 @@ static __inline__ uint32_t __DEFAULT_FN_ATTRS 
wasm_i16x8_bitmask(v128_t __a) {
 }
 
 static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_i16x8_shl(v128_t __a,
-   int32_t __b) {
+   uint32_t __b) {
   return (v128_t)((__i16x8)__a << __b);
 }
 
 static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_i16x8_shr(v128_t __a,
-   int32_t __b) {
+   uint32_t __b) {
   return (v128_t)((__i16x8)__a >> __b);
 }
 
 static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_u16x8_shr(v128_t __a,
-   int32_t __b) {
+   uint32_t __b) {
   return (v128_t)((__u16x8)__a >> __b);
 }
 
@@ -1137,17 +1137,17 @@ static __inline__ uint32_t __DEFAULT_FN_ATTRS 
wasm_i32x4_bitmask(v128_t __a) {
 }
 
 static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_i32x4_shl(v128_t __a,
-   int32_t __b) {
+   uint32_t __b) {
   return (v128_t)((__i32x4)__a << __b);
 }
 
 static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_i32x4_shr(v128_t __a,
-   int32_t __b) {
+   uint32_t __b) {
   return (v128_t)((__i32x4)__a >> __b);
 }
 
 static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_u32x4_shr(v128_t __a,
-   int32_t __b) {
+   uint32_t __b) {
   return (v128_t)((__u32x4)__a >> __b);
 }
 
@@ -1208,17 +1208,17 @@ static __inline__ uint32_t __DEFAULT_FN_ATTRS 
wasm_i64x2_bitmask(v128_t __a) {
 }
 
 static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_i64x2_shl(v128_t __a,
-   int32_t __b) {
+   uint32_t __b) {
   return (v128_t)((__i64x2)__a << (int64_t)__b);
 }
 
 static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_i64x2_shr(v128_t __a,
-   int32_t __b) {
+   uint32_t __b) {
   return (v128_t)((__i64x2)__a >> (int64_t)__b);
 }
 
 static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_u64x2_shr(v128_t __a,
-   int32_t __b) {
+   uint32_t __b) {
   return (v128_t)((__u64x2)__a >> (int64_t)__b);
 }
 

diff  --git a/clang/test/Headers/wasm.c b/clang/test/Headers/wasm.c
index 72f20b1520fd..ba7d3dc71f2b 100644
--- a/clang/test/Headers/wasm.c
+++ b/clang/test/Headers/wasm.c
@@ -1603,7 +1603,7 @@ v128_t test_i8x16_popcnt(v128_t a) {
 // CHECK-NEXT:[[TMP3:%.*]] = bitcast <16 x i8> [[SHL_I]] to <4 x

[PATCH] D108415: [WebAssembly] Make shift values unsigned in wasm_simd128.h

2021-08-20 Thread Thomas Lively via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG64a9957bf7b6: [WebAssembly] Make shift values unsigned in 
wasm_simd128.h (authored by tlively).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108415

Files:
  clang/lib/Headers/wasm_simd128.h
  clang/test/Headers/wasm.c

Index: clang/test/Headers/wasm.c
===
--- clang/test/Headers/wasm.c
+++ clang/test/Headers/wasm.c
@@ -1603,7 +1603,7 @@
 // CHECK-NEXT:[[TMP3:%.*]] = bitcast <16 x i8> [[SHL_I]] to <4 x i32>
 // CHECK-NEXT:ret <4 x i32> [[TMP3]]
 //
-v128_t test_i8x16_shl(v128_t a, int32_t b) {
+v128_t test_i8x16_shl(v128_t a, uint32_t b) {
   return wasm_i8x16_shl(a, b);
 }
 
@@ -1617,7 +1617,7 @@
 // CHECK-NEXT:[[TMP3:%.*]] = bitcast <16 x i8> [[SHR_I]] to <4 x i32>
 // CHECK-NEXT:ret <4 x i32> [[TMP3]]
 //
-v128_t test_i8x16_shr(v128_t a, int32_t b) {
+v128_t test_i8x16_shr(v128_t a, uint32_t b) {
   return wasm_i8x16_shr(a, b);
 }
 
@@ -1631,7 +1631,7 @@
 // CHECK-NEXT:[[TMP3:%.*]] = bitcast <16 x i8> [[SHR_I]] to <4 x i32>
 // CHECK-NEXT:ret <4 x i32> [[TMP3]]
 //
-v128_t test_u8x16_shr(v128_t a, int32_t b) {
+v128_t test_u8x16_shr(v128_t a, uint32_t b) {
   return wasm_u8x16_shr(a, b);
 }
 
@@ -1824,7 +1824,7 @@
 // CHECK-NEXT:[[TMP3:%.*]] = bitcast <8 x i16> [[SHL_I]] to <4 x i32>
 // CHECK-NEXT:ret <4 x i32> [[TMP3]]
 //
-v128_t test_i16x8_shl(v128_t a, int32_t b) {
+v128_t test_i16x8_shl(v128_t a, uint32_t b) {
   return wasm_i16x8_shl(a, b);
 }
 
@@ -1838,7 +1838,7 @@
 // CHECK-NEXT:[[TMP3:%.*]] = bitcast <8 x i16> [[SHR_I]] to <4 x i32>
 // CHECK-NEXT:ret <4 x i32> [[TMP3]]
 //
-v128_t test_i16x8_shr(v128_t a, int32_t b) {
+v128_t test_i16x8_shr(v128_t a, uint32_t b) {
   return wasm_i16x8_shr(a, b);
 }
 
@@ -1852,7 +1852,7 @@
 // CHECK-NEXT:[[TMP3:%.*]] = bitcast <8 x i16> [[SHR_I]] to <4 x i32>
 // CHECK-NEXT:ret <4 x i32> [[TMP3]]
 //
-v128_t test_u16x8_shr(v128_t a, int32_t b) {
+v128_t test_u16x8_shr(v128_t a, uint32_t b) {
   return wasm_u16x8_shr(a, b);
 }
 
@@ -2048,7 +2048,7 @@
 // CHECK-NEXT:[[SHL_I:%.*]] = shl <4 x i32> [[A:%.*]], [[SPLAT_SPLAT_I]]
 // CHECK-NEXT:ret <4 x i32> [[SHL_I]]
 //
-v128_t test_i32x4_shl(v128_t a, int32_t b) {
+v128_t test_i32x4_shl(v128_t a, uint32_t b) {
   return wasm_i32x4_shl(a, b);
 }
 
@@ -2059,7 +2059,7 @@
 // CHECK-NEXT:[[SHR_I:%.*]] = ashr <4 x i32> [[A:%.*]], [[SPLAT_SPLAT_I]]
 // CHECK-NEXT:ret <4 x i32> [[SHR_I]]
 //
-v128_t test_i32x4_shr(v128_t a, int32_t b) {
+v128_t test_i32x4_shr(v128_t a, uint32_t b) {
   return wasm_i32x4_shr(a, b);
 }
 
@@ -2070,7 +2070,7 @@
 // CHECK-NEXT:[[SHR_I:%.*]] = lshr <4 x i32> [[A:%.*]], [[SPLAT_SPLAT_I]]
 // CHECK-NEXT:ret <4 x i32> [[SHR_I]]
 //
-v128_t test_u32x4_shr(v128_t a, int32_t b) {
+v128_t test_u32x4_shr(v128_t a, uint32_t b) {
   return wasm_u32x4_shr(a, b);
 }
 
@@ -2198,42 +2198,42 @@
 // CHECK-LABEL: @test_i64x2_shl(
 // CHECK-NEXT:  entry:
 // CHECK-NEXT:[[TMP0:%.*]] = bitcast <4 x i32> [[A:%.*]] to <2 x i64>
-// CHECK-NEXT:[[CONV_I:%.*]] = sext i32 [[B:%.*]] to i64
+// CHECK-NEXT:[[CONV_I:%.*]] = zext i32 [[B:%.*]] to i64
 // CHECK-NEXT:[[SPLAT_SPLATINSERT_I:%.*]] = insertelement <2 x i64> poison, i64 [[CONV_I]], i32 0
 // CHECK-NEXT:[[SPLAT_SPLAT_I:%.*]] = shufflevector <2 x i64> [[SPLAT_SPLATINSERT_I]], <2 x i64> poison, <2 x i32> zeroinitializer
 // CHECK-NEXT:[[SHL_I:%.*]] = shl <2 x i64> [[TMP0]], [[SPLAT_SPLAT_I]]
 // CHECK-NEXT:[[TMP1:%.*]] = bitcast <2 x i64> [[SHL_I]] to <4 x i32>
 // CHECK-NEXT:ret <4 x i32> [[TMP1]]
 //
-v128_t test_i64x2_shl(v128_t a, int32_t b) {
+v128_t test_i64x2_shl(v128_t a, uint32_t b) {
   return wasm_i64x2_shl(a, b);
 }
 
 // CHECK-LABEL: @test_i64x2_shr(
 // CHECK-NEXT:  entry:
 // CHECK-NEXT:[[TMP0:%.*]] = bitcast <4 x i32> [[A:%.*]] to <2 x i64>
-// CHECK-NEXT:[[CONV_I:%.*]] = sext i32 [[B:%.*]] to i64
+// CHECK-NEXT:[[CONV_I:%.*]] = zext i32 [[B:%.*]] to i64
 // CHECK-NEXT:[[SPLAT_SPLATINSERT_I:%.*]] = insertelement <2 x i64> poison, i64 [[CONV_I]], i32 0
 // CHECK-NEXT:[[SPLAT_SPLAT_I:%.*]] = shufflevector <2 x i64> [[SPLAT_SPLATINSERT_I]], <2 x i64> poison, <2 x i32> zeroinitializer
 // CHECK-NEXT:[[SHR_I:%.*]] = ashr <2 x i64> [[TMP0]], [[SPLAT_SPLAT_I]]
 // CHECK-NEXT:[[TMP1:%.*]] = bitcast <2 x i64> [[SHR_I]] to <4 x i32>
 // CHECK-NEXT:ret <4 x i32> [[TMP1]]
 //
-v128_t test_i64x2_shr(v128_t a, int32_t b) {
+v128_t test_i64x2_shr(v128_t a, uint32_t b) {
   return wasm_i64x2_shr(a, b);
 }
 
 // CHECK-LABEL: @test_u64x2_shr(
 // CHECK-NEXT:  entry:
 // CHECK-NEXT:[[TMP0:%.*]] = bitcast <4 x i32> [[A:%.*]] to <2 x i64>
-// CHECK-NEXT:[[CONV_I:%.*]] = sext i32 [[B:%.*]] to i64
+// CHECK-NEXT:[[CONV_I:%.*]] = zext i32 [[B:%.*]] to i64
 // CHECK-NEXT:[[SPLAT_SPLATINS

[PATCH] D104854: Introduce intrinsic llvm.isnan

2021-08-20 Thread Dávid Bolvanský via Phabricator via cfe-commits
xbolva00 added a comment.

In D104854#2957529 , @spatel wrote:

> In D104854#2957471 , @sepavloff 
> wrote:
>
>> In D104854#2957423 , @spatel wrote:
>>
>>> Is it intentional that we are not canonicalizing the intrinsic call back to 
>>> `fcmp uno` in the default FP environment?
>>
>> It is lowered to unordered comparison by default. Changing `llvm.isnan` to  
>> `fcmp uno` somewhere in IR would make it possible to optimize out the latter 
>> if fast-math mode is on. Preserving semantics of `isnan` when fast-math is 
>> in effect was one of the goals of this change.
>
> I understand that the codegen was supposed to be no worse, but the difference 
> in IR causes optimizer regressions like: 
> https://llvm.org/PR51556
>
> If we want this intrinsic (and its siblings that haven't been created yet) to 
> survive through IR, then we have to enhance IR passes to recognize the new 
> patterns. 
> It would be easier to do this in steps: (1) create the intrinsic only if not 
> in the default FP env, (2) update IR analysis/passes to recognize the 
> intrinsic, (3) create the intrinsic in the default FP env with no FMF, (4) 
> create the intrinsic always.

Meanwhile this should be reverted..


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D104854

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


[PATCH] D108470: [OpenCL] Fix as_type3 invalid store creation

2021-08-20 Thread Sven van Haastregt via Phabricator via cfe-commits
svenvh created this revision.
svenvh added reviewers: Anastasia, jaykang10.
svenvh added a project: clang.
Herald added subscribers: ldrumm, yaxunl.
svenvh requested review of this revision.
Herald added a subscriber: cfe-commits.

With -fpreserve-vec3-type enabled, a cast was not created when
converting from a non-vec3 type to a vec3 type, even though a
conversion to vec3 was performed.  This resulted in creation of
invalid store instructions.

Related to D107963 , but now for the to-vec3 
case.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D108470

Files:
  clang/lib/CodeGen/CGExprScalar.cpp
  clang/test/CodeGenOpenCL/preserve_vec3.cl


Index: clang/test/CodeGenOpenCL/preserve_vec3.cl
===
--- clang/test/CodeGenOpenCL/preserve_vec3.cl
+++ clang/test/CodeGenOpenCL/preserve_vec3.cl
@@ -53,3 +53,11 @@
   // CHECK: store <4 x i16> %[[ASTYPE]], <4 x i16> addrspace(1)* %[[OUT_BC]]
   *out = __builtin_astype(a, long);
 }
+
+void to_char3(int a, global char3 *out) {
+  // CHECK-LABEL: void @to_char3
+  // CHECK: %[[IN_BC:.*]] = bitcast i32 %a to <4 x i8>
+  // CHECK: %[[ASTYPE:.*]] = shufflevector <4 x i8> %[[IN_BC]], <4 x i8> 
poison, <3 x i32> 
+  // CHECK: store <3 x i8> %[[ASTYPE]], <3 x i8> addrspace(1)* %out
+  *out = __builtin_astype(a, char3);
+}
Index: clang/lib/CodeGen/CGExprScalar.cpp
===
--- clang/lib/CodeGen/CGExprScalar.cpp
+++ clang/lib/CodeGen/CGExprScalar.cpp
@@ -4796,12 +4796,10 @@
   // to vec4 if the original type is not vec4, then a shuffle vector to
   // get a vec3.
   if (NumElementsSrc != 3 && NumElementsDst == 3) {
-if (!CGF.CGM.getCodeGenOpts().PreserveVec3Type) {
-  auto *Vec4Ty = llvm::FixedVectorType::get(
-  cast(DstTy)->getElementType(), 4);
-  Src = createCastsForTypeOfSameSize(Builder, CGF.CGM.getDataLayout(), Src,
- Vec4Ty);
-}
+auto *Vec4Ty = llvm::FixedVectorType::get(
+cast(DstTy)->getElementType(), 4);
+Src = createCastsForTypeOfSameSize(Builder, CGF.CGM.getDataLayout(), Src,
+   Vec4Ty);
 
 Src = ConvertVec3AndVec4(Builder, CGF, Src, 3);
 Src->setName("astype");


Index: clang/test/CodeGenOpenCL/preserve_vec3.cl
===
--- clang/test/CodeGenOpenCL/preserve_vec3.cl
+++ clang/test/CodeGenOpenCL/preserve_vec3.cl
@@ -53,3 +53,11 @@
   // CHECK: store <4 x i16> %[[ASTYPE]], <4 x i16> addrspace(1)* %[[OUT_BC]]
   *out = __builtin_astype(a, long);
 }
+
+void to_char3(int a, global char3 *out) {
+  // CHECK-LABEL: void @to_char3
+  // CHECK: %[[IN_BC:.*]] = bitcast i32 %a to <4 x i8>
+  // CHECK: %[[ASTYPE:.*]] = shufflevector <4 x i8> %[[IN_BC]], <4 x i8> poison, <3 x i32> 
+  // CHECK: store <3 x i8> %[[ASTYPE]], <3 x i8> addrspace(1)* %out
+  *out = __builtin_astype(a, char3);
+}
Index: clang/lib/CodeGen/CGExprScalar.cpp
===
--- clang/lib/CodeGen/CGExprScalar.cpp
+++ clang/lib/CodeGen/CGExprScalar.cpp
@@ -4796,12 +4796,10 @@
   // to vec4 if the original type is not vec4, then a shuffle vector to
   // get a vec3.
   if (NumElementsSrc != 3 && NumElementsDst == 3) {
-if (!CGF.CGM.getCodeGenOpts().PreserveVec3Type) {
-  auto *Vec4Ty = llvm::FixedVectorType::get(
-  cast(DstTy)->getElementType(), 4);
-  Src = createCastsForTypeOfSameSize(Builder, CGF.CGM.getDataLayout(), Src,
- Vec4Ty);
-}
+auto *Vec4Ty = llvm::FixedVectorType::get(
+cast(DstTy)->getElementType(), 4);
+Src = createCastsForTypeOfSameSize(Builder, CGF.CGM.getDataLayout(), Src,
+   Vec4Ty);
 
 Src = ConvertVec3AndVec4(Builder, CGF, Src, 3);
 Src->setName("astype");
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D108301: [MSP430][Clang] Update hard-coded MCU data

2021-08-20 Thread Jozef Lawrynowicz via Phabricator via cfe-commits
jozefl updated this revision to Diff 367805.
jozefl added a comment.

Here's an updated patch to fix the win64 failure.

MSVC can't handle the conversion from a ForwardIterator to a const pointer when
the container being searched with std::lower_bound is a std::array. Meanwhile
clang-tidy warns when the type assigned to with the return value of
std::lower_bound is not a pointer, so I can't just change the type declaration
to a lone "auto", and surpressing the clang-tidy warning for this warning
doesn't seem like the best option either.

So I've changed the data type used to store the MCUData to a C-style array, and
also moved its definition into loadMCUData.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108301

Files:
  clang/include/clang/Basic/MSP430Target.def
  clang/lib/Driver/ToolChains/MSP430.cpp
  clang/test/Driver/msp430-hwmult.c
  clang/test/Driver/msp430-mmcu.c
  clang/test/Driver/msp430-toolchain.c

Index: clang/test/Driver/msp430-toolchain.c
===
--- clang/test/Driver/msp430-toolchain.c
+++ clang/test/Driver/msp430-toolchain.c
@@ -253,6 +253,10 @@
 // RUN:   | FileCheck -check-prefix=HWMult-32BIT %s
 // HWMult-32BIT: "--start-group" "-lmul_32"
 
+// RUN: %clang %s -### -no-canonical-prefixes -target msp430 -mmcu=msp430fr5969 --sysroot="" 2>&1 \
+// RUN:   | FileCheck -check-prefix=HWMult-F5 %s
+// RUN: %clang %s -### -no-canonical-prefixes -target msp430 -mmcu=msp430fr5969 -mhwmult=auto --sysroot="" 2>&1 \
+// RUN:   | FileCheck -check-prefix=HWMult-F5 %s
 // RUN: %clang %s -### -no-canonical-prefixes -target msp430 -mhwmult=f5series --sysroot="" 2>&1 \
 // RUN:   | FileCheck -check-prefix=HWMult-F5 %s
 // HWMult-F5: "--start-group" "-lmul_f5"
@@ -261,4 +265,10 @@
 // RUN:   | FileCheck -check-prefix=HWMult-NONE %s
 // RUN: %clang %s -### -no-canonical-prefixes -target msp430 -mhwmult=none -mmcu=msp430f4783 --sysroot="" 2>&1 \
 // RUN:   | FileCheck -check-prefix=HWMult-NONE %s
+// RUN: %clang %s -### -no-canonical-prefixes -target msp430 -mhwmult=auto -mmcu=msp430 --sysroot="" 2>&1 \
+// RUN:   | FileCheck -check-prefix=HWMult-NONE %s
+// RUN: %clang %s -### -no-canonical-prefixes -target msp430 -mhwmult=auto -mmcu=msp430x --sysroot="" 2>&1 \
+// RUN:   | FileCheck -check-prefix=HWMult-NONE %s
+// RUN: %clang %s -### -no-canonical-prefixes -target msp430 -mmcu=msp430xv2 --sysroot="" 2>&1 \
+// RUN:   | FileCheck -check-prefix=HWMult-NONE %s
 // HWMult-NONE: "--start-group" "-lmul_none"
Index: clang/test/Driver/msp430-mmcu.c
===
--- clang/test/Driver/msp430-mmcu.c
+++ clang/test/Driver/msp430-mmcu.c
@@ -1,15 +1,62 @@
+// This file tests that various different values passed to -mmcu= select the
+// correct target features and linker scripts, and create MCU-specific defines.
+
+// Test the lexicographic ordering of MCUs in MSP430Target.def.
+//
+// The MCU "msp430f110" should appear before "msp430f1101" when the data has
+// been sorted lexicographically. Some sorts will put "msp430f110" *after*
+// "msp430f1101", so when this happens, Clang will not be able to find this MCU.
+
+// RUN: %clang %s -### -no-canonical-prefixes -target msp430 -mmcu=msp430f110 2>&1 \
+// RUN:   | FileCheck %s
+
+// RUN: %clang %s -### -no-canonical-prefixes -target msp430 -mmcu=msp430f1101 2>&1 \
+// RUN:   | FileCheck %s
+
+// RUN: %clang %s -### -no-canonical-prefixes -target msp430 -mmcu=msp430f1101a 2>&1 \
+// RUN:   | FileCheck %s
+
+// CHECK-NOT: error: the clang compiler does not support
+
+// Test the symbol definitions, linker scripts and hardware multiply features
+// selected for different MCUs.
+
 // RUN: %clang %s -### -no-canonical-prefixes -target msp430 -mmcu=msp430c111 2>&1 \
 // RUN:   | FileCheck -check-prefix=MSP430-C111 %s
 
 // MSP430-C111: clang{{.*}} "-cc1" {{.*}} "-D__MSP430C111__"
+// MSP430-C111-NOT: "-target-feature" "+hwmult16"
+// MSP430-C111-NOT: "-target-feature" "+hwmult32"
+// MSP430-C111-NOT: "-target-feature" "+hwmultf5"
 // MSP430-C111: msp430-elf-ld{{.*}} "-Tmsp430c111.ld"
 
 // RUN: %clang %s -### -no-canonical-prefixes -target msp430 -mmcu=msp430i2020 2>&1 \
 // RUN:   | FileCheck -check-prefix=MSP430-I2020 %s
 
 // MSP430-I2020: clang{{.*}} "-cc1" {{.*}} "-D__MSP430i2020__"
+// MSP430-I2020: "-target-feature" "+hwmult16"
 // MSP430-I2020: msp430-elf-ld{{.*}} "-Tmsp430i2020.ld"
 
+// RUN: %clang %s -### -no-canonical-prefixes -target msp430 -mmcu=msp430f47126 2>&1 \
+// RUN:   | FileCheck -check-prefix=MSP430-F47126 %s
+
+// MSP430-F47126: clang{{.*}} "-cc1" {{.*}} "-D__MSP430F47126__"
+// MSP430-F47126: "-target-feature" "+hwmult32"
+// MSP430-F47126: msp430-elf-ld{{.*}} "-Tmsp430f47126.ld"
+
+// RAN: %clang %s -### -no-canonical-prefixes -target msp430 -mmcu=msp430fr5969 2>&1 \
+// RAN:   | FileCheck -check-prefix=MSP430-FR5969 %s
+
+// MSP430-FR5969: clang{{.*}} "-

[PATCH] D104854: Introduce intrinsic llvm.isnan

2021-08-20 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri added a comment.

In D104854#2957529 , @spatel wrote:

> In D104854#2957471 , @sepavloff 
> wrote:
>
>> In D104854#2957423 , @spatel wrote:
>>
>>> Is it intentional that we are not canonicalizing the intrinsic call back to 
>>> `fcmp uno` in the default FP environment?
>>
>> It is lowered to unordered comparison by default. Changing `llvm.isnan` to  
>> `fcmp uno` somewhere in IR would make it possible to optimize out the latter 
>> if fast-math mode is on. Preserving semantics of `isnan` when fast-math is 
>> in effect was one of the goals of this change.
>
> I understand that the codegen was supposed to be no worse, but the difference 
> in IR causes optimizer regressions like: 
> https://llvm.org/PR51556
>
> If we want this intrinsic (and its siblings that haven't been created yet) to 
> survive through IR, then we have to enhance IR passes to recognize the new 
> patterns. 
> It would be easier to do this in steps: (1) create the intrinsic only if not 
> in the default FP env, (2) update IR analysis/passes to recognize the 
> intrinsic, (3) create the intrinsic in the default FP env with no FMF, (4) 
> create the intrinsic always.

+1, but right now i'm not sold on the behavior of not optimizing away NaN 
checks in no-NaN's mode.
At least that part should be reconciled now. It *might* be an improvement, but 
it caters to expectations
of one group while catering away from the documentation and existing 
expectations of other groups.
This shouldn't be decided in a review, it should be driven by an RFC.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D104854

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


[clang] 88962ce - [WebAssembly] Restore builtins and intrinsics for pmin/pmax

2021-08-20 Thread Thomas Lively via cfe-commits

Author: Thomas Lively
Date: 2021-08-20T09:21:31-07:00
New Revision: 88962cea46805dbcc60524f7107030c986833052

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

LOG: [WebAssembly] Restore builtins and intrinsics for pmin/pmax

Partially reverts 85157c007903, which had removed these builtins and intrinsics
in favor of normal codegen patterns. It turns out that it is possible for the
patterns to be split over multiple basic blocks, however, which means that DAG
ISel is not able to select them to the pmin/pmax instructions. To make sure the
SIMD intrinsics generate the correct instructions in these cases, reintroduce
the clang builtins and corresponding LLVM intrinsics, but also keep the normal
pattern matching as well.

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

Added: 


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

Removed: 




diff  --git a/clang/include/clang/Basic/BuiltinsWebAssembly.def 
b/clang/include/clang/Basic/BuiltinsWebAssembly.def
index 51a819efdee0..f5120b23f811 100644
--- a/clang/include/clang/Basic/BuiltinsWebAssembly.def
+++ b/clang/include/clang/Basic/BuiltinsWebAssembly.def
@@ -129,8 +129,12 @@ TARGET_BUILTIN(__builtin_wasm_abs_f64x2, "V2dV2d", "nc", 
"simd128")
 
 TARGET_BUILTIN(__builtin_wasm_min_f32x4, "V4fV4fV4f", "nc", "simd128")
 TARGET_BUILTIN(__builtin_wasm_max_f32x4, "V4fV4fV4f", "nc", "simd128")
+TARGET_BUILTIN(__builtin_wasm_pmin_f32x4, "V4fV4fV4f", "nc", "simd128")
+TARGET_BUILTIN(__builtin_wasm_pmax_f32x4, "V4fV4fV4f", "nc", "simd128")
 TARGET_BUILTIN(__builtin_wasm_min_f64x2, "V2dV2dV2d", "nc", "simd128")
 TARGET_BUILTIN(__builtin_wasm_max_f64x2, "V2dV2dV2d", "nc", "simd128")
+TARGET_BUILTIN(__builtin_wasm_pmin_f64x2, "V2dV2dV2d", "nc", "simd128")
+TARGET_BUILTIN(__builtin_wasm_pmax_f64x2, "V2dV2dV2d", "nc", "simd128")
 
 TARGET_BUILTIN(__builtin_wasm_ceil_f32x4, "V4fV4f", "nc", "simd128")
 TARGET_BUILTIN(__builtin_wasm_floor_f32x4, "V4fV4f", "nc", "simd128")

diff  --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp
index d74209ae27a4..89b773fc5f97 100644
--- a/clang/lib/CodeGen/CGBuiltin.cpp
+++ b/clang/lib/CodeGen/CGBuiltin.cpp
@@ -17822,6 +17822,22 @@ Value 
*CodeGenFunction::EmitWebAssemblyBuiltinExpr(unsigned BuiltinID,
 CGM.getIntrinsic(Intrinsic::maximum, ConvertType(E->getType()));
 return Builder.CreateCall(Callee, {LHS, RHS});
   }
+  case WebAssembly::BI__builtin_wasm_pmin_f32x4:
+  case WebAssembly::BI__builtin_wasm_pmin_f64x2: {
+Value *LHS = EmitScalarExpr(E->getArg(0));
+Value *RHS = EmitScalarExpr(E->getArg(1));
+Function *Callee =
+CGM.getIntrinsic(Intrinsic::wasm_pmin, ConvertType(E->getType()));
+return Builder.CreateCall(Callee, {LHS, RHS});
+  }
+  case WebAssembly::BI__builtin_wasm_pmax_f32x4:
+  case WebAssembly::BI__builtin_wasm_pmax_f64x2: {
+Value *LHS = EmitScalarExpr(E->getArg(0));
+Value *RHS = EmitScalarExpr(E->getArg(1));
+Function *Callee =
+CGM.getIntrinsic(Intrinsic::wasm_pmax, ConvertType(E->getType()));
+return Builder.CreateCall(Callee, {LHS, RHS});
+  }
   case WebAssembly::BI__builtin_wasm_ceil_f32x4:
   case WebAssembly::BI__builtin_wasm_floor_f32x4:
   case WebAssembly::BI__builtin_wasm_trunc_f32x4:

diff  --git a/clang/lib/Headers/wasm_simd128.h 
b/clang/lib/Headers/wasm_simd128.h
index 438a54526b33..3889a2769faf 100644
--- a/clang/lib/Headers/wasm_simd128.h
+++ b/clang/lib/Headers/wasm_simd128.h
@@ -1297,14 +1297,12 @@ static __inline__ v128_t __DEFAULT_FN_ATTRS 
wasm_f32x4_max(v128_t __a,
 
 static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_f32x4_pmin(v128_t __a,
 v128_t __b) {
-  __i32x4 __mask = (__i32x4)((__f32x4)__b < (__f32x4)__a);
-  return (v128_t)__i32x4)__b) & __mask) | (((__i32x4)__a) & ~__mask));
+  return (v128_t)__builtin_wasm_pmin_f32x4((__f32x4)__a, (__f32x4)__b);
 }
 
 static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_f32x4_pmax(v128_t __a,
 v128_t __b) {
-  __i32x4 __mask = (__i32x4)((__f32x4)__a < (__f32x4)__b);
-  return (v128_t)__i32x4)__b) & __mask) | (((__i32x4)__a) & ~__mask));
+  return (v128_t)__builtin_wasm_pmax_f32x4((__f32x4)__a, (__f32x4)__b);
 }
 
 static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_f64x2_abs(v128_t __a) {
@@ -1367,14 +1365,12 @@ static __inline__ v128_t __DEFAULT_FN_ATTRS 
wasm_f64x2_max(v128_t __a,
 
 static __inline__ v128_t __D

[PATCH] D108387: [WebAssembly] Restore builtins and intrinsics for pmin/pmax

2021-08-20 Thread Thomas Lively via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG88962cea4680: [WebAssembly] Restore builtins and intrinsics 
for pmin/pmax (authored by tlively).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108387

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

Index: llvm/test/CodeGen/WebAssembly/simd-intrinsics.ll
===
--- llvm/test/CodeGen/WebAssembly/simd-intrinsics.ll
+++ llvm/test/CodeGen/WebAssembly/simd-intrinsics.ll
@@ -540,6 +540,26 @@
   ret <4 x float> %a
 }
 
+; CHECK-LABEL: pmin_v4f32:
+; CHECK-NEXT: .functype pmin_v4f32 (v128, v128) -> (v128){{$}}
+; CHECK-NEXT: f32x4.pmin $push[[R:[0-9]+]]=, $0, $1{{$}}
+; CHECK-NEXT: return $pop[[R]]{{$}}
+declare <4 x float> @llvm.wasm.pmin.v4f32(<4 x float>, <4 x float>)
+define <4 x float> @pmin_v4f32(<4 x float> %a, <4 x float> %b) {
+  %v = call <4 x float> @llvm.wasm.pmin.v4f32(<4 x float> %a, <4 x float> %b)
+  ret <4 x float> %v
+}
+
+; CHECK-LABEL: pmax_v4f32:
+; CHECK-NEXT: .functype pmax_v4f32 (v128, v128) -> (v128){{$}}
+; CHECK-NEXT: f32x4.pmax $push[[R:[0-9]+]]=, $0, $1{{$}}
+; CHECK-NEXT: return $pop[[R]]{{$}}
+declare <4 x float> @llvm.wasm.pmax.v4f32(<4 x float>, <4 x float>)
+define <4 x float> @pmax_v4f32(<4 x float> %a, <4 x float> %b) {
+  %v = call <4 x float> @llvm.wasm.pmax.v4f32(<4 x float> %a, <4 x float> %b)
+  ret <4 x float> %v
+}
+
 ; CHECK-LABEL: ceil_v4f32:
 ; CHECK-NEXT: .functype ceil_v4f32 (v128) -> (v128){{$}}
 ; CHECK-NEXT: f32x4.ceil $push[[R:[0-9]+]]=, $0{{$}}
@@ -595,6 +615,26 @@
   ret <2 x double> %a
 }
 
+; CHECK-LABEL: pmin_v2f64:
+; CHECK-NEXT: .functype pmin_v2f64 (v128, v128) -> (v128){{$}}
+; CHECK-NEXT: f64x2.pmin $push[[R:[0-9]+]]=, $0, $1{{$}}
+; CHECK-NEXT: return $pop[[R]]{{$}}
+declare <2 x double> @llvm.wasm.pmin.v2f64(<2 x double>, <2 x double>)
+define <2 x double> @pmin_v2f64(<2 x double> %a, <2 x double> %b) {
+  %v = call <2 x double> @llvm.wasm.pmin.v2f64(<2 x double> %a, <2 x double> %b)
+  ret <2 x double> %v
+}
+
+; CHECK-LABEL: pmax_v2f64:
+; CHECK-NEXT: .functype pmax_v2f64 (v128, v128) -> (v128){{$}}
+; CHECK-NEXT: f64x2.pmax $push[[R:[0-9]+]]=, $0, $1{{$}}
+; CHECK-NEXT: return $pop[[R]]{{$}}
+declare <2 x double> @llvm.wasm.pmax.v2f64(<2 x double>, <2 x double>)
+define <2 x double> @pmax_v2f64(<2 x double> %a, <2 x double> %b) {
+  %v = call <2 x double> @llvm.wasm.pmax.v2f64(<2 x double> %a, <2 x double> %b)
+  ret <2 x double> %v
+}
+
 ; CHECK-LABEL: ceil_v2f64:
 ; CHECK-NEXT: .functype ceil_v2f64 (v128) -> (v128){{$}}
 ; CHECK-NEXT: f64x2.ceil $push[[R:[0-9]+]]=, $0{{$}}
Index: llvm/lib/Target/WebAssembly/WebAssemblyInstrSIMD.td
===
--- llvm/lib/Target/WebAssembly/WebAssemblyInstrSIMD.td
+++ llvm/lib/Target/WebAssembly/WebAssemblyInstrSIMD.td
@@ -1175,6 +1175,16 @@
   (pmax $lhs, $rhs)>;
 }
 
+// And match the pmin/pmax LLVM intrinsics as well
+def : Pat<(v4f32 (int_wasm_pmin (v4f32 V128:$lhs), (v4f32 V128:$rhs))),
+  (PMIN_F32x4 V128:$lhs, V128:$rhs)>;
+def : Pat<(v4f32 (int_wasm_pmax (v4f32 V128:$lhs), (v4f32 V128:$rhs))),
+  (PMAX_F32x4 V128:$lhs, V128:$rhs)>;
+def : Pat<(v2f64 (int_wasm_pmin (v2f64 V128:$lhs), (v2f64 V128:$rhs))),
+  (PMIN_F64x2 V128:$lhs, V128:$rhs)>;
+def : Pat<(v2f64 (int_wasm_pmax (v2f64 V128:$lhs), (v2f64 V128:$rhs))),
+  (PMAX_F64x2 V128:$lhs, V128:$rhs)>;
+
 //===--===//
 // Conversions
 //===--===//
Index: llvm/include/llvm/IR/IntrinsicsWebAssembly.td
===
--- llvm/include/llvm/IR/IntrinsicsWebAssembly.td
+++ llvm/include/llvm/IR/IntrinsicsWebAssembly.td
@@ -164,6 +164,15 @@
 [llvm_v8i16_ty, llvm_v8i16_ty],
 [IntrNoMem, IntrSpeculatable]>;
 
+def int_wasm_pmin :
+  Intrinsic<[llvm_anyvector_ty],
+[LLVMMatchType<0>, LLVMMatchType<0>],
+[IntrNoMem, IntrSpeculatable]>;
+def int_wasm_pmax :
+  Intrinsic<[llvm_anyvector_ty],
+[LLVMMatchType<0>, LLVMMatchType<0>],
+[IntrNoMem, IntrSpeculatable]>;
+
 def int_wasm_extadd_pairwise_signed :
   Intrinsic<[llvm_anyvector_ty],
 [LLVMSubdivide2VectorType<0>],
Index: clang/test/Headers/wasm.c
===
--- clang/test/Headers/wasm.c
+++ clang/test/Headers/wasm.c
@@ -2424,11 +2424,11 @@
 
 // CHECK-LABEL: @test_f32x

[PATCH] D105759: [WIP] Implement P2361 Unevaluated string literals

2021-08-20 Thread Corentin Jabot via Phabricator via cfe-commits
cor3ntin updated this revision to Diff 367811.
cor3ntin added a comment.

Fix diagnostic for avaibility attributes


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105759

Files:
  clang-tools-extra/test/clang-tidy/checkers/modernize-unary-static-assert.cpp
  clang/include/clang/AST/Expr.h
  clang/include/clang/Basic/DiagnosticLexKinds.td
  clang/include/clang/Basic/DiagnosticParseKinds.td
  clang/include/clang/Lex/LiteralSupport.h
  clang/include/clang/Parse/Parser.h
  clang/include/clang/Sema/Sema.h
  clang/lib/AST/Expr.cpp
  clang/lib/Frontend/FrontendAction.cpp
  clang/lib/Lex/LiteralSupport.cpp
  clang/lib/Lex/PPDirectives.cpp
  clang/lib/Lex/PPMacroExpansion.cpp
  clang/lib/Lex/Pragma.cpp
  clang/lib/Parse/ParseDecl.cpp
  clang/lib/Parse/ParseDeclCXX.cpp
  clang/lib/Parse/ParseExpr.cpp
  clang/lib/Parse/Parser.cpp
  clang/lib/Sema/SemaDeclAttr.cpp
  clang/lib/Sema/SemaDeclCXX.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/lib/Sema/SemaExprCXX.cpp
  clang/lib/Sema/SemaInit.cpp
  clang/lib/Sema/SemaStmtAsm.cpp
  clang/test/CXX/dcl.dcl/dcl.link/p2.cpp
  clang/test/CXX/dcl.dcl/p4-0x.cpp
  clang/test/FixIt/fixit-static-assert.cpp
  clang/test/Parser/asm.c
  clang/test/Parser/asm.cpp
  clang/test/Parser/attr-availability-xcore.c
  clang/test/Parser/attr-availability.c
  clang/test/Sema/asm.c
  clang/test/SemaCXX/static-assert.cpp

Index: clang/test/SemaCXX/static-assert.cpp
===
--- clang/test/SemaCXX/static-assert.cpp
+++ clang/test/SemaCXX/static-assert.cpp
@@ -28,12 +28,12 @@
 S s1; // expected-note {{in instantiation of template class 'S' requested here}}
 S s2;
 
-static_assert(false, L"\x"); // expected-error {{static_assert failed L"\x"}}
-static_assert(false, u"\U000317FF"); // expected-error {{static_assert failed u"\U000317FF"}}
+static_assert(false, L"\x"); // expected-error {{an unevaluated string literal cannot have an encoding prefix}} expected-error {{hex escape sequence out of range}}
+static_assert(false, u"\U000317FF"); // expected-error {{an unevaluated string literal cannot have an encoding prefix}}
 // FIXME: render this as u8"\u03A9"
-static_assert(false, u8"Ω"); // expected-error {{static_assert failed u8"\316\251"}}
-static_assert(false, L"\u1234"); // expected-error {{static_assert failed L"\x1234"}}
-static_assert(false, L"\x1ff" "0\x123" "fx\xf" "goop"); // expected-error {{static_assert failed L"\x1FF""0\x123""fx\xFgoop"}}
+static_assert(false, u8"Ω"); // expected-error {{an unevaluated string literal cannot have an encoding prefix}}
+static_assert(false, L"\u1234"); // expected-error {{an unevaluated string literal cannot have an encoding prefix}}
+static_assert(false, L"\x1ff" "0\x123" "fx\xf" "goop"); // expected-error {{an unevaluated string literal cannot have an encoding prefix}} expected-error 3{{hex escape sequence out of range}}
 
 template struct AlwaysFails {
   // Only give one error here.
Index: clang/test/Sema/asm.c
===
--- clang/test/Sema/asm.c
+++ clang/test/Sema/asm.c
@@ -37,14 +37,17 @@
   asm ("nop" : "=c" (a) : "r" (no_clobber_conflict) : "%rcx"); // expected-error {{asm-specifier for input or output variable conflicts with asm clobber list}}
   asm ("nop" : "=r" (no_clobber_conflict) : "c" (c) : "%rcx"); // expected-error {{asm-specifier for input or output variable conflicts with asm clobber list}}
   asm ("nop" : "=r" (clobber_conflict) : "c" (c) : "%rcx"); // expected-error {{asm-specifier for input or output variable conflicts with asm clobber list}}
-  asm ("nop" : "=a" (a) : "b" (b) : "%rcx", "%rbx"); // expected-error {{asm-specifier for input or output variable conflicts with asm clobber list}} 
+  asm("nop"
+  : "=a"(a)
+  : "b"(b)
+  : "%rcx", "%rbx"); // expected-error {{asm-specifier for input or output variable conflicts with asm clobber list}}
 }
 
 // rdar://6094010
 void test3() {
   int x;
-  asm(L"foo" : "=r"(x)); // expected-error {{wide string}}
-  asm("foo" : L"=r"(x)); // expected-error {{wide string}}
+  asm(L"foo" : "=r"(x)); // expected-error {{an unevaluated string literal cannot have an encoding prefix}}
+  asm("foo" : L"=r"(x)); // expected-error {{an unevaluated string literal cannot have an encoding prefix}}
 }
 
 // 
Index: clang/test/Parser/attr-availability.c
===
--- clang/test/Parser/attr-availability.c
+++ clang/test/Parser/attr-availability.c
@@ -18,21 +18,25 @@
 
 void f6() __attribute__((availability(macosx,unavailable,introduced=10.5))); // expected-warning{{'unavailable' availability overrides all other availability information}}
 
-void f7() __attribute__((availability(macosx,message=L"wide"))); // expected-error {{expected string literal for optional message in 'availability' attribute}}
+void f7()

  1   2   >