[PATCH] D85474: Add -fbinutils-version= to gate ELF features on the specified binutils version

2020-11-16 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added a comment.

Sent https://lists.llvm.org/pipermail/llvm-dev/2020-November/146676.html "Add 
-fbinutils-version=" (cross posted to cfe-dev) so that more folks can notice it.

About "generate code and don't care about GNU as/ld compatibility/limitation", 
I am open for suggestions. Currently I like `-fbinutils-version=none` the most 
(after considering `future` and `latest` and `99` (assuming GNU binutils 99 
implements everything we need...))


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D85474

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


[PATCH] D91590: [NVPTX] Efficently support dynamic index on CUDA kernel aggregate parameters.

2020-11-16 Thread Michael Liao via Phabricator via cfe-commits
hliao added a comment.

This's an experimental or demo-only patch in my spare time on eliminating 
private memory usage in https://godbolt.org/z/EPPn6h. The attachment F14026286: 
sample.tar.xz  includes both the reference 
and new IR, PTX, and SASS (sm_60) output. For the new code, that aggregate 
argument is loaded through `LDC` instruction in SASS instead of `MOV` due to 
the non-static address. I don't have sm_60 to verify that. Could you try that 
on the real hardware?

BTW, from PTX ISA document, parameter space is read-only for input parameters 
and write-only for output parameters. If that's right, even non-kernel function 
may also require a similar change as the semantic is different from the 
language model, where the argument variable could be modified in the function 
body.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91590

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


[PATCH] D91590: [NVPTX] Efficently support dynamic index on CUDA kernel aggregate parameters.

2020-11-16 Thread Michael Liao via Phabricator via cfe-commits
hliao created this revision.
hliao added a reviewer: tra.
Herald added subscribers: llvm-commits, cfe-commits, arphaman, hiraditya, 
yaxunl, mgorny, jholewinski.
Herald added projects: clang, LLVM.
hliao requested review of this revision.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D91590

Files:
  clang/lib/CodeGen/TargetInfo.cpp
  clang/test/CodeGen/nvptx-abi.c
  clang/test/CodeGenCUDA/kernel-args-alignment.cu
  clang/test/CodeGenCUDA/kernel-args.cu
  clang/test/OpenMP/nvptx_unsupported_type_codegen.cpp
  llvm/lib/Target/NVPTX/CMakeLists.txt
  llvm/lib/Target/NVPTX/NVPTX.h
  llvm/lib/Target/NVPTX/NVPTXAA.cpp
  llvm/lib/Target/NVPTX/NVPTXAsmPrinter.cpp
  llvm/lib/Target/NVPTX/NVPTXISelLowering.cpp
  llvm/lib/Target/NVPTX/NVPTXTargetMachine.cpp

Index: llvm/lib/Target/NVPTX/NVPTXTargetMachine.cpp
===
--- llvm/lib/Target/NVPTX/NVPTXTargetMachine.cpp
+++ llvm/lib/Target/NVPTX/NVPTXTargetMachine.cpp
@@ -198,11 +198,19 @@
 
 void NVPTXTargetMachine::adjustPassManager(PassManagerBuilder ) {
   Builder.addExtension(
-PassManagerBuilder::EP_EarlyAsPossible,
-[&](const PassManagerBuilder &, legacy::PassManagerBase ) {
-  PM.add(createNVVMReflectPass(Subtarget.getSmVersion()));
-  PM.add(createNVVMIntrRangePass(Subtarget.getSmVersion()));
-});
+  PassManagerBuilder::EP_EarlyAsPossible,
+  [&](const PassManagerBuilder &, legacy::PassManagerBase ) {
+PM.add(createNVPTXAAWrapperPass());
+PM.add(createNVPTXExternalAAWrapperPass());
+PM.add(createNVVMReflectPass(Subtarget.getSmVersion()));
+PM.add(createNVVMIntrRangePass(Subtarget.getSmVersion()));
+  });
+  Builder.addExtension(
+  PassManagerBuilder::EP_ModuleOptimizerEarly,
+  [&](const PassManagerBuilder &, legacy::PassManagerBase ) {
+PM.add(createNVPTXAAWrapperPass());
+PM.add(createNVPTXExternalAAWrapperPass());
+  });
 }
 
 TargetTransformInfo
@@ -279,6 +287,9 @@
 addStraightLineScalarOptimizationPasses();
   }
 
+  addPass(createNVPTXAAWrapperPass());
+  addPass(createNVPTXExternalAAWrapperPass());
+
   // === LSR and other generic IR passes ===
   TargetPassConfig::addIRPasses();
   // EarlyCSE is not always strong enough to clean up what LSR produces. For
Index: llvm/lib/Target/NVPTX/NVPTXISelLowering.cpp
===
--- llvm/lib/Target/NVPTX/NVPTXISelLowering.cpp
+++ llvm/lib/Target/NVPTX/NVPTXISelLowering.cpp
@@ -2531,7 +2531,8 @@
 // to newly created nodes. The SDNodes for params have to
 // appear in the same order as their order of appearance
 // in the original function. "idx+1" holds that order.
-if (!PAL.hasParamAttribute(i, Attribute::ByVal)) {
+if (!PAL.hasParamAttribute(i, Attribute::ByVal) &&
+!PAL.hasParamAttribute(i, Attribute::ByRef)) {
   bool aggregateIsPacked = false;
   if (StructType *STy = dyn_cast(Ty))
 aggregateIsPacked = STy->isPacked();
Index: llvm/lib/Target/NVPTX/NVPTXAsmPrinter.cpp
===
--- llvm/lib/Target/NVPTX/NVPTXAsmPrinter.cpp
+++ llvm/lib/Target/NVPTX/NVPTXAsmPrinter.cpp
@@ -1457,7 +1457,8 @@
   }
 }
 
-if (!PAL.hasParamAttribute(paramIndex, Attribute::ByVal)) {
+if (!PAL.hasParamAttribute(paramIndex, Attribute::ByVal) &&
+!PAL.hasParamAttribute(paramIndex, Attribute::ByRef)) {
   if (Ty->isAggregateType() || Ty->isVectorTy() || Ty->isIntegerTy(128)) {
 // Just print .param .align  .b8 .param[size];
 //  = PAL.getparamalignment
Index: llvm/lib/Target/NVPTX/NVPTXAA.cpp
===
--- /dev/null
+++ llvm/lib/Target/NVPTX/NVPTXAA.cpp
@@ -0,0 +1,131 @@
+#include "MCTargetDesc/NVPTXBaseInfo.h"
+#include "NVPTX.h"
+#include "llvm/ADT/Triple.h"
+#include "llvm/Analysis/AliasAnalysis.h"
+#include "llvm/Analysis/ValueTracking.h"
+#include "llvm/IR/Module.h"
+
+namespace llvm {
+void initializeNVPTXAAWrapperPass(PassRegistry &);
+void initializeNVPTXExternalAAWrapperPass(PassRegistry &);
+} // namespace llvm
+
+#define DEBUG_TYPE "nvptx-aa"
+
+using namespace llvm;
+
+namespace {
+
+class NVPTXAAResult : public AAResultBase {
+  friend AAResultBase;
+
+public:
+  explicit NVPTXAAResult() : AAResultBase() {}
+  NVPTXAAResult(NVPTXAAResult &) : AAResultBase(std::move(Arg)) {}
+
+  bool invalidate(Function , const PreservedAnalyses ,
+  FunctionAnalysisManager::Invalidator );
+
+  AliasResult alias(const MemoryLocation , const MemoryLocation ,
+AAQueryInfo ) {
+MemoryLocation L1 = LocA;
+MemoryLocation L2 = LocB;
+unsigned AS1 = L1.Ptr->getType()->getPointerAddressSpace();
+unsigned AS2 = L2.Ptr->getType()->getPointerAddressSpace();
+if (AS1 != ADDRESS_SPACE_GENERIC) {
+  std::swap(L1, L2);
+  std::swap(AS1, AS2);
+}
+if (AS1 == 

[PATCH] D88410: [clang][AVR] Improve avr-ld command line options

2020-11-16 Thread Dylan McKay via Phabricator via cfe-commits
dylanmckay accepted this revision.
dylanmckay added a comment.
This revision is now accepted and ready to land.

Looks good to me, thanks for the patch @benshi001

NOTE: It looks like you will need to rebase this one prior to merge.


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

https://reviews.llvm.org/D88410

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


[PATCH] D91009: [clang-tidy] Include std::basic_string_view in readability-redundant-string-init.

2020-11-16 Thread Chris Kennelly via Phabricator via cfe-commits
ckennelly added a comment.

Ping


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91009

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


[PATCH] D91015: [clang-tidy] Extend bugprone-string-constructor-check to std::string_view.

2020-11-16 Thread Chris Kennelly via Phabricator via cfe-commits
ckennelly added inline comments.



Comment at: clang-tools-extra/clang-tidy/bugprone/StringConstructorCheck.cpp:65
+  const auto hasStringCtorName =
+  hasAnyNameStdString(removeNamespaces(StringNames));
+

aaron.ballman wrote:
> It took me a while to realize that this functionality is really about trying 
> to get to the name of the constructor for a given type -- perhaps this should 
> be a single function called `getCtorNameFromType()` or something?
> 
> Actually, given that this is a narrowing matcher from a `CXXConstructExpr`, 
> can't you look at `CXXConstructExpr::getConstructor()` to get the 
> `CXXConstructorDecl` and check the name from there? That seems cleaner than 
> trying to identify the constructor name through string matching.
I applied ymandel's suggestion, which I think simplified things a bit.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91015

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


[PATCH] D91015: [clang-tidy] Extend bugprone-string-constructor-check to std::string_view.

2020-11-16 Thread Chris Kennelly via Phabricator via cfe-commits
ckennelly updated this revision to Diff 305652.
ckennelly marked 5 inline comments as done.
ckennelly added a comment.

Applied review comments


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91015

Files:
  clang-tools-extra/clang-tidy/bugprone/StringConstructorCheck.cpp
  clang-tools-extra/clang-tidy/bugprone/StringConstructorCheck.h
  clang-tools-extra/docs/clang-tidy/checks/bugprone-string-constructor.rst
  clang-tools-extra/test/clang-tidy/checkers/bugprone-string-constructor.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/bugprone-string-constructor.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/bugprone-string-constructor.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/bugprone-string-constructor.cpp
@@ -14,6 +14,15 @@
 };
 typedef basic_string string;
 typedef basic_string wstring;
+
+template >
+struct basic_string_view {
+  basic_string_view();
+  basic_string_view(const C *, unsigned int size);
+  basic_string_view(const C *);
+};
+typedef basic_string_view string_view;
+typedef basic_string_view wstring_view;
 }
 
 const char* kText = "";
@@ -52,11 +61,35 @@
   // CHECK-MESSAGES: [[@LINE-1]]:20: warning: constructing string from nullptr is undefined behaviour
 }
 
+void TestView() {
+  std::string_view q0("test", 0);
+  // CHECK-MESSAGES: [[@LINE-1]]:20: warning: constructor creating an empty string
+  std::string_view q1(kText, -4);
+  // CHECK-MESSAGES: [[@LINE-1]]:20: warning: negative value used as length parameter
+  std::string_view q2("test", 200);
+  // CHECK-MESSAGES: [[@LINE-1]]:20: warning: length is bigger than string literal size
+  std::string_view q3(kText, 200);
+  // CHECK-MESSAGES: [[@LINE-1]]:20: warning: length is bigger than string literal size
+  std::string_view q4(kText2, 200);
+  // CHECK-MESSAGES: [[@LINE-1]]:20: warning: length is bigger than string literal size
+  std::string_view q5(kText3, 0x100);
+  // CHECK-MESSAGES: [[@LINE-1]]:20: warning: suspicious large length parameter
+  std::string_view q6(nullptr);
+  // CHECK-MESSAGES: [[@LINE-1]]:20: warning: constructing string from nullptr is undefined behaviour
+  std::string_view q7 = 0;
+  // CHECK-MESSAGES: [[@LINE-1]]:25: warning: constructing string from nullptr is undefined behaviour
+}
+
 std::string StringFromZero() {
   return 0;
   // CHECK-MESSAGES: [[@LINE-1]]:10: warning: constructing string from nullptr is undefined behaviour
 }
 
+std::string_view StringViewFromZero() {
+  return 0;
+  // CHECK-MESSAGES: [[@LINE-1]]:10: warning: constructing string from nullptr is undefined behaviour
+}
+
 void Valid() {
   std::string empty();
   std::string str(4, 'x');
@@ -64,6 +97,11 @@
   std::string s1("test", 4);
   std::string s2("test", 3);
   std::string s3("test");
+
+  std::string_view emptyv();
+  std::string_view sv1("test", 4);
+  std::string_view sv2("test", 3);
+  std::string_view sv3("test");
 }
 
 namespace instantiation_dependent_exprs {
@@ -71,5 +109,6 @@
 struct S {
   bool x;
   std::string f() { return x ? "a" : "b"; }
+  std::string_view g() { return x ? "a" : "b"; }
 };
 }
Index: clang-tools-extra/docs/clang-tidy/checks/bugprone-string-constructor.rst
===
--- clang-tools-extra/docs/clang-tidy/checks/bugprone-string-constructor.rst
+++ clang-tools-extra/docs/clang-tidy/checks/bugprone-string-constructor.rst
@@ -21,6 +21,7 @@
 .. code-block:: c++
 
   std::string("test", 200);   // Will include random characters after "test".
+  std::string_view("test", 200);
 
 Creating an empty string from constructors with parameters is considered
 suspicious. The programmer should use the empty constructor instead.
@@ -30,6 +31,7 @@
 .. code-block:: c++
 
   std::string("test", 0);   // Creation of an empty string.
+  std::string_view("test", 0);
 
 Options
 ---
@@ -42,3 +44,12 @@
 .. option::  LargeLengthThreshold
 
An integer specifying the large length threshold. Default is `0x80`.
+
+.. option:: StringNames
+
+Default is `::std::basic_string;::std::basic_string_view`.
+
+Semicolon-delimited list of class names to apply this check to.
+By default `::std::basic_string` applies to ``std::string`` and
+``std::wstring``. Set to e.g. `::std::basic_string;llvm::StringRef;QString`
+to perform this check on custom classes.
Index: clang-tools-extra/clang-tidy/bugprone/StringConstructorCheck.h
===
--- clang-tools-extra/clang-tidy/bugprone/StringConstructorCheck.h
+++ clang-tools-extra/clang-tidy/bugprone/StringConstructorCheck.h
@@ -32,6 +32,7 @@
 private:
   const bool WarnOnLargeLength;
   const unsigned int LargeLengthThreshold;
+  std::vector StringNames;
 };
 
 } // namespace bugprone
Index: clang-tools-extra/clang-tidy/bugprone/StringConstructorCheck.cpp

[PATCH] D91015: [clang-tidy] Extend bugprone-string-constructor-check to std::string_view.

2020-11-16 Thread Chris Kennelly via Phabricator via cfe-commits
ckennelly updated this revision to Diff 305649.
ckennelly added a comment.

Applied review feedback


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91015

Files:
  clang-tools-extra/clang-tidy/bugprone/StringConstructorCheck.cpp
  clang-tools-extra/clang-tidy/bugprone/StringConstructorCheck.h
  clang-tools-extra/docs/clang-tidy/checks/bugprone-string-constructor.rst
  clang-tools-extra/test/clang-tidy/checkers/bugprone-string-constructor.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/bugprone-string-constructor.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/bugprone-string-constructor.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/bugprone-string-constructor.cpp
@@ -14,6 +14,15 @@
 };
 typedef basic_string string;
 typedef basic_string wstring;
+
+template >
+struct basic_string_view {
+  basic_string_view();
+  basic_string_view(const C *, unsigned int size);
+  basic_string_view(const C *);
+};
+typedef basic_string_view string_view;
+typedef basic_string_view wstring_view;
 }
 
 const char* kText = "";
@@ -52,11 +61,35 @@
   // CHECK-MESSAGES: [[@LINE-1]]:20: warning: constructing string from nullptr is undefined behaviour
 }
 
+void TestView() {
+  std::string_view q0("test", 0);
+  // CHECK-MESSAGES: [[@LINE-1]]:20: warning: constructor creating an empty string
+  std::string_view q1(kText, -4);
+  // CHECK-MESSAGES: [[@LINE-1]]:20: warning: negative value used as length parameter
+  std::string_view q2("test", 200);
+  // CHECK-MESSAGES: [[@LINE-1]]:20: warning: length is bigger than string literal size
+  std::string_view q3(kText, 200);
+  // CHECK-MESSAGES: [[@LINE-1]]:20: warning: length is bigger than string literal size
+  std::string_view q4(kText2, 200);
+  // CHECK-MESSAGES: [[@LINE-1]]:20: warning: length is bigger than string literal size
+  std::string_view q5(kText3, 0x100);
+  // CHECK-MESSAGES: [[@LINE-1]]:20: warning: suspicious large length parameter
+  std::string_view q6(nullptr);
+  // CHECK-MESSAGES: [[@LINE-1]]:20: warning: constructing string from nullptr is undefined behaviour
+  std::string_view q7 = 0;
+  // CHECK-MESSAGES: [[@LINE-1]]:25: warning: constructing string from nullptr is undefined behaviour
+}
+
 std::string StringFromZero() {
   return 0;
   // CHECK-MESSAGES: [[@LINE-1]]:10: warning: constructing string from nullptr is undefined behaviour
 }
 
+std::string_view StringViewFromZero() {
+  return 0;
+  // CHECK-MESSAGES: [[@LINE-1]]:10: warning: constructing string from nullptr is undefined behaviour
+}
+
 void Valid() {
   std::string empty();
   std::string str(4, 'x');
@@ -64,6 +97,11 @@
   std::string s1("test", 4);
   std::string s2("test", 3);
   std::string s3("test");
+
+  std::string_view emptyv();
+  std::string_view sv1("test", 4);
+  std::string_view sv2("test", 3);
+  std::string_view sv3("test");
 }
 
 namespace instantiation_dependent_exprs {
@@ -71,5 +109,6 @@
 struct S {
   bool x;
   std::string f() { return x ? "a" : "b"; }
+  std::string_view g() { return x ? "a" : "b"; }
 };
 }
Index: clang-tools-extra/docs/clang-tidy/checks/bugprone-string-constructor.rst
===
--- clang-tools-extra/docs/clang-tidy/checks/bugprone-string-constructor.rst
+++ clang-tools-extra/docs/clang-tidy/checks/bugprone-string-constructor.rst
@@ -21,6 +21,7 @@
 .. code-block:: c++
 
   std::string("test", 200);   // Will include random characters after "test".
+  std::string_view("test", 200);
 
 Creating an empty string from constructors with parameters is considered
 suspicious. The programmer should use the empty constructor instead.
@@ -30,6 +31,7 @@
 .. code-block:: c++
 
   std::string("test", 0);   // Creation of an empty string.
+  std::string_view("test", 0);
 
 Options
 ---
@@ -42,3 +44,12 @@
 .. option::  LargeLengthThreshold
 
An integer specifying the large length threshold. Default is `0x80`.
+
+.. option:: StringNames
+
+Default is `::std::basic_string;::std::basic_string_view`.
+
+Semicolon-delimited list of class names to apply this check to.
+By default `::std::basic_string` applies to ``std::string`` and
+``std::wstring``. Set to e.g. `::std::basic_string;llvm::StringRef;QString`
+to perform this check on custom classes.
Index: clang-tools-extra/clang-tidy/bugprone/StringConstructorCheck.h
===
--- clang-tools-extra/clang-tidy/bugprone/StringConstructorCheck.h
+++ clang-tools-extra/clang-tidy/bugprone/StringConstructorCheck.h
@@ -32,6 +32,7 @@
 private:
   const bool WarnOnLargeLength;
   const unsigned int LargeLengthThreshold;
+  std::vector StringNames;
 };
 
 } // namespace bugprone
Index: clang-tools-extra/clang-tidy/bugprone/StringConstructorCheck.cpp
===
--- 

[PATCH] D91585: [NPM] Move more O0 pass building into PassBuilder

2020-11-16 Thread Arthur Eubanks via Phabricator via cfe-commits
aeubanks created this revision.
aeubanks added reviewers: ychen, asbirlea, tejohnson.
Herald added subscribers: llvm-commits, cfe-commits, wenlei, lxfind, steven_wu, 
modocache, JDevlieghere, hiraditya.
Herald added projects: clang, LLVM.
aeubanks requested review of this revision.

This moves handling of alwaysinline, coroutines, matrix lowering, PGO,
and LTO-required passes into PassBuilder. Much of this is replicated
between Clang and opt. Other out-of-tree users also replicate some of
this, such as Rust [1] replicating the alwaysinline, LTO, and PGO
passes.

The LTO passes are also now run in
build(Thin)LTOPreLinkDefaultPipeline() since they are semantically
required for (Thin)LTO.

[1]: 
https://github.com/rust-lang/rust/blob/f5230fbf76bafd86ee4376a0e26e551df8d17fec/compiler/rustc_llvm/llvm-wrapper/PassWrapper.cpp#L896


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D91585

Files:
  clang/lib/CodeGen/BackendUtil.cpp
  llvm/include/llvm/Passes/PassBuilder.h
  llvm/lib/Passes/PassBuilder.cpp
  llvm/test/Other/new-pass-manager.ll
  llvm/test/Other/new-pm-defaults.ll
  llvm/test/Other/new-pm-thinlto-defaults.ll
  llvm/test/Other/new-pm-thinlto-prelink-pgo-defaults.ll
  llvm/test/Other/new-pm-thinlto-prelink-samplepgo-defaults.ll
  llvm/test/Transforms/CanonicalizeAliases/canonicalize.ll
  llvm/test/Transforms/NameAnonGlobals/rename.ll

Index: llvm/test/Transforms/NameAnonGlobals/rename.ll
===
--- llvm/test/Transforms/NameAnonGlobals/rename.ll
+++ llvm/test/Transforms/NameAnonGlobals/rename.ll
@@ -1,5 +1,6 @@
 ; RUN: opt -S -name-anon-globals < %s | FileCheck %s
-; RUN: opt -prepare-for-thinlto -O0 -module-summary -o %t.bc < %s
+; RUN: opt -prepare-for-thinlto -O0 -module-summary -o %t.bc -enable-new-pm=0 < %s
+; RUN: opt -passes='thinlto-pre-link,require' -o %t.bc < %s
 
 
 ; foo contribute to the unique hash for the module
Index: llvm/test/Transforms/CanonicalizeAliases/canonicalize.ll
===
--- llvm/test/Transforms/CanonicalizeAliases/canonicalize.ll
+++ llvm/test/Transforms/CanonicalizeAliases/canonicalize.ll
@@ -1,6 +1,7 @@
 ; RUN: opt -S -canonicalize-aliases < %s | FileCheck %s
-; RUN: opt -prepare-for-thinlto -O0 -module-summary -o - < %s | llvm-dis -o - | FileCheck %s
 ; RUN: opt -S -passes=canonicalize-aliases < %s | FileCheck %s
+; RUN: opt -prepare-for-thinlto -O0 -module-summary -o - < %s -enable-new-pm=0 | llvm-dis -o - | FileCheck %s
+; RUN: opt -passes='thinlto-pre-link,require' -o - < %s | llvm-dis -o - | FileCheck %s
 
 target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
 target triple = "x86_64-unknown-linux-gnu"
Index: llvm/test/Other/new-pm-thinlto-prelink-samplepgo-defaults.ll
===
--- llvm/test/Other/new-pm-thinlto-prelink-samplepgo-defaults.ll
+++ llvm/test/Other/new-pm-thinlto-prelink-samplepgo-defaults.ll
@@ -2,27 +2,27 @@
 ;
 ; RUN: opt -disable-verify -debug-pass-manager \
 ; RUN: -pgo-kind=pgo-sample-use-pipeline -profile-file='%S/Inputs/new-pm-thinlto-samplepgo-defaults.prof' \
-; RUN: -passes='thinlto-pre-link,name-anon-globals' -S %s 2>&1 \
+; RUN: -passes='thinlto-pre-link' -S %s 2>&1 \
 ; RUN: | FileCheck %s --check-prefixes=CHECK-O,CHECK-O1
 ; RUN: opt -disable-verify -debug-pass-manager \
 ; RUN: -pgo-kind=pgo-sample-use-pipeline -profile-file='%S/Inputs/new-pm-thinlto-samplepgo-defaults.prof' \
-; RUN: -passes='thinlto-pre-link,name-anon-globals' -S  %s 2>&1 \
+; RUN: -passes='thinlto-pre-link' -S  %s 2>&1 \
 ; RUN: | FileCheck %s --check-prefixes=CHECK-O,CHECK-O2,CHECK-O23SZ
 ; RUN: opt -disable-verify -debug-pass-manager \
 ; RUN: -pgo-kind=pgo-sample-use-pipeline -profile-file='%S/Inputs/new-pm-thinlto-samplepgo-defaults.prof' \
-; RUN: -passes='thinlto-pre-link,name-anon-globals' -S -passes-ep-pipeline-start='no-op-module' %s 2>&1 \
+; RUN: -passes='thinlto-pre-link' -S -passes-ep-pipeline-start='no-op-module' %s 2>&1 \
 ; RUN: | FileCheck %s --check-prefixes=CHECK-O,CHECK-O3,CHECK-O23SZ,CHECK-EP-PIPELINE-START
 ; RUN: opt -disable-verify -debug-pass-manager \
 ; RUN: -pgo-kind=pgo-sample-use-pipeline -profile-file='%S/Inputs/new-pm-thinlto-samplepgo-defaults.prof' \
-; RUN: -passes='thinlto-pre-link,name-anon-globals' -S %s 2>&1 \
+; RUN: -passes='thinlto-pre-link' -S %s 2>&1 \
 ; RUN: | FileCheck %s --check-prefixes=CHECK-O,CHECK-Os,CHECK-O23SZ
 ; RUN: opt -disable-verify -debug-pass-manager \
 ; RUN: -pgo-kind=pgo-sample-use-pipeline -profile-file='%S/Inputs/new-pm-thinlto-samplepgo-defaults.prof' \
-; RUN: -passes='thinlto-pre-link,name-anon-globals' -S %s 2>&1 \
+; RUN: -passes='thinlto-pre-link' -S %s 2>&1 \
 ; RUN: | FileCheck %s --check-prefixes=CHECK-O,CHECK-Oz,CHECK-O23SZ
 ; RUN: opt -disable-verify -debug-pass-manager -new-pm-debug-info-for-profiling \
 ; RUN: 

[PATCH] D90507: Adding DWARF64 clang flag

2020-11-16 Thread Igor Kudrin via Phabricator via cfe-commits
ikudrin added a comment.

It looks like `lld/test/COFF/lto-new-pass-manager.ll.obj` was added to the 
patch by accident and should be removed.




Comment at: clang/include/clang/Basic/CodeGenOptions.def:35
 CODEGENOPT(AsmVerbose, 1, 0) ///< -dA, -fverbose-asm.
+CODEGENOPT(Dwarf64   , 1, 0) ///< -gdwarf64.
 CODEGENOPT(PreserveAsmComments, 1, 1) ///< -dA, -fno-preserve-as-comments.

dblaikie wrote:
> Is there any precedent to draw from for this flag name? (Does GCC support 
> DWARF64? Does it support it under this flag name or some other? (similarly 
> with other gcc-like compilers (Intel's? Whoever else... )))
It looks like we are pioneering in that area. To me, the proposed name looks 
consonant with other debug-related switches.



Comment at: clang/lib/Driver/ToolChains/Clang.cpp:4025
+  << A->getAsString(Args) << "64 bit architecutre";
+else
+  CmdArgs.push_back("-gdwarf64");

We also should check that the output format is ELF.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D90507

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


[PATCH] D91567: [llvm][inliner] Reuse the inliner pass to implement 'always inliner'

2020-11-16 Thread Mircea Trofin via Phabricator via cfe-commits
mtrofin added a comment.

In D91567#2398623 , @dblaikie wrote:

> In D91567#2398461 , @mtrofin wrote:
>
>> In D91567#2398440 , @dblaikie wrote:
>>
 Performing the mandatory inlinings first simplifies the problem the full 
 inliner needs to solve
>>>
>>> That confuses me a bit - is that suggesting that we don't run the 
>>> AlwaysInliner when we are running the Inliner (ie: we only run the 
>>> AlwaysInliner at -O0, and use the Inliner at higher optimization levels and 
>>> let the Inliner do always inlining too)?
>>> & sounds like this is suggesting that would change? That we would now 
>>> perform always inlining separately from inlining? Maybe that's an 
>>> orthogonal/separate change from one implementing the always inlining using 
>>> the Inliner being run in a separate mode?
>>
>> In the NPM, we didn't run the AlwaysInliner until D86988 
>> . See also the discussion there. The normal 
>> inliner pass was, and still is, taking care of the mandatory inlinings if it 
>> finds them. Of course, if we completely upfronted those (which this patch 
>> can do), then the normal inliner wouldn't need to. I'm not suggesting 
>> changing that - meaning, it's straightforward for the normal inliner to take 
>> care of mandatory and policy-driven inlinings. The idea, though, is that if 
>> we upfront the mandatory inlinings, the shape of the call graph the inliner 
>> operates over is simpler and the effects of inlining probably more easy to 
>> glean by the decision making policy. There are trade-offs, though - we can 
>> increase that "ease of gleaning" by performing more function simplification 
>> passes between the mandatory inlinings and the full inliner.
>
> OK, so if I understand correctly with the old Pass Manager there were two 
> separate passes (always inliner and inliner - they share some code though, 
> yeah?)

AlwaysInlinerLegacyPass does, yes. The NPM variant doesn't.

> and they were run in the pass pipeline but potentially (definitely?) not 
> adjacent?

From what I can see, the legacy one was used only in the O0/O1 
 cases, see 
clang/lib/CodeGen/BackendUtil,cpp:643. The full inliner isn't.

New pass manager survived for quite a while with only one inlining pass, that 
included a mandatorily strong preference for inlining always-inline functions? 
But still missed some recursive cases. So D86988 
 made the always inliner run right next 
to/before the inliner in the NPM.

> Now there's tihs patch, to implement the AlwaysInliner using the inliner - 
> but is also changing the order of passes to improve optimization 
> opportunities by doing some cleanup after always inlining?

It doesn't quite change the order D86988  
introduced. Specifically, D86988  ran 
AlwaysInliner (a module pass) first, then let the Inliner and function 
optimizations happen.
This patch keeps the order between doing mandatory inlinings and inlinings. 
But, in addition, if in the future we want to also perform some of the function 
passes that happen in the inliner case, to help the full inliner, we can more 
easily do so.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91567

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


Re: [clang] e7f3e21 - Suppress printing template arguments that match default template

2020-11-16 Thread David Blaikie via cfe-commits
On Mon, Nov 16, 2020 at 7:24 PM Richard Smith  wrote:
>
> On Mon, 16 Nov 2020 at 18:49, David Blaikie  wrote:
>>
>> On Wed, Nov 11, 2020 at 3:08 PM Richard Smith via cfe-commits
>>  wrote:
>> >
>> >
>> > Author: Richard Smith
>> > Date: 2020-11-11T15:05:51-08:00
>> > New Revision: e7f3e2103cdb567dda4fd52f81bf4bc07179f5a8
>> >
>> > URL: 
>> > https://github.com/llvm/llvm-project/commit/e7f3e2103cdb567dda4fd52f81bf4bc07179f5a8
>> > DIFF: 
>> > https://github.com/llvm/llvm-project/commit/e7f3e2103cdb567dda4fd52f81bf4bc07179f5a8.diff
>> >
>> > LOG: Suppress printing template arguments that match default template
>> > arguments of types by default.
>> >
>> > This somewhat improves the worst-case printing of types like
>> > std::string, std::vector, etc., where many irrelevant default arguments
>> > can be included in the type as printed if we've lost the type sugar.
>>
>> "somewhat" - are there still some remaining challenges here? (I'd have
>> thought this would be a significant improvement in these worst cases
>> of lost type sugar)
>
>
> For std::vector, std::map, etc. we now print these types as-expected. But...
>
> std::string is now printed as std::basic_string, which, while an 
> improvement, is still not the type name that we know a user would really want 
> to see (similarly for std::string_view, and really any of the typedefs for 
> std::basic_*). https://reviews.llvm.org/D91311 has a fix for that, but we're 
> still in discussion as to whether that's the right interface for that 
> functionality.

Ah, fair point for sure! thanks for the details and pointer to the
review/discussion.

>> > Added:
>> > clang/test/Misc/diag-template.cpp
>> >
>> > Modified:
>> > clang/include/clang/AST/PrettyPrinter.h
>> > clang/include/clang/AST/Type.h
>> > clang/lib/AST/DeclTemplate.cpp
>> > clang/lib/AST/TypePrinter.cpp
>> > clang/lib/Frontend/FrontendActions.cpp
>> > clang/test/SemaCXX/cxx14-compat.cpp
>> > clang/test/SemaCXX/generic-selection.cpp
>> > clang/test/SemaTemplate/class-template-id.cpp
>> > clang/test/SemaTemplate/class-template-spec.cpp
>> > clang/test/SemaTemplate/instantiation-default-1.cpp
>> >
>> > Removed:
>> >
>> >
>> >
>> > 
>> > diff  --git a/clang/include/clang/AST/PrettyPrinter.h 
>> > b/clang/include/clang/AST/PrettyPrinter.h
>> > index dfd5851bb30d..50e2142e2ef0 100644
>> > --- a/clang/include/clang/AST/PrettyPrinter.h
>> > +++ b/clang/include/clang/AST/PrettyPrinter.h
>> > @@ -55,7 +55,8 @@ struct PrintingPolicy {
>> >  SuppressInitializers(false), ConstantArraySizeAsWritten(false),
>> >  AnonymousTagLocations(true), SuppressStrongLifetime(false),
>> >  SuppressLifetimeQualifiers(false),
>> > -SuppressTemplateArgsInCXXConstructors(false), Bool(LO.Bool),
>> > +SuppressTemplateArgsInCXXConstructors(false),
>> > +SuppressDefaultTemplateArgs(true), Bool(LO.Bool),
>> >  Nullptr(LO.CPlusPlus11), Restrict(LO.C99), 
>> > Alignof(LO.CPlusPlus11),
>> >  UnderscoreAlignof(LO.C11), UseVoidForZeroParams(!LO.CPlusPlus),
>> >  SplitTemplateClosers(!LO.CPlusPlus11), TerseOutput(false),
>> > @@ -167,6 +168,10 @@ struct PrintingPolicy {
>> >/// constructors.
>> >unsigned SuppressTemplateArgsInCXXConstructors : 1;
>> >
>> > +  /// When true, attempt to suppress template arguments that match the 
>> > default
>> > +  /// argument for the parameter.
>> > +  unsigned SuppressDefaultTemplateArgs : 1;
>> > +
>> >/// Whether we can use 'bool' rather than '_Bool' (even if the language
>> >/// doesn't actually have 'bool', because, e.g., it is defined as a 
>> > macro).
>> >unsigned Bool : 1;
>> >
>> > diff  --git a/clang/include/clang/AST/Type.h 
>> > b/clang/include/clang/AST/Type.h
>> > index 1442bc740620..6dedd097ff89 100644
>> > --- a/clang/include/clang/AST/Type.h
>> > +++ b/clang/include/clang/AST/Type.h
>> > @@ -61,6 +61,7 @@ class ExtQuals;
>> >  class QualType;
>> >  class ConceptDecl;
>> >  class TagDecl;
>> > +class TemplateParameterList;
>> >  class Type;
>> >
>> >  enum {
>> > @@ -5196,15 +5197,18 @@ class alignas(8) TemplateSpecializationType
>> >  /// enclosing the template arguments.
>> >  void printTemplateArgumentList(raw_ostream ,
>> > ArrayRef Args,
>> > -   const PrintingPolicy );
>> > +   const PrintingPolicy ,
>> > +   const TemplateParameterList *TPL = 
>> > nullptr);
>> >
>> >  void printTemplateArgumentList(raw_ostream ,
>> > ArrayRef Args,
>> > -   const PrintingPolicy );
>> > +   const PrintingPolicy ,
>> > +   const TemplateParameterList *TPL = 
>> > nullptr);
>> >
>> >  void printTemplateArgumentList(raw_ostream ,
>> >   

[PATCH] D91567: [llvm][inliner] Reuse the inliner pass to implement 'always inliner'

2020-11-16 Thread David Blaikie via Phabricator via cfe-commits
dblaikie added a comment.

In D91567#2398461 , @mtrofin wrote:

> In D91567#2398440 , @dblaikie wrote:
>
>>> Performing the mandatory inlinings first simplifies the problem the full 
>>> inliner needs to solve
>>
>> That confuses me a bit - is that suggesting that we don't run the 
>> AlwaysInliner when we are running the Inliner (ie: we only run the 
>> AlwaysInliner at -O0, and use the Inliner at higher optimization levels and 
>> let the Inliner do always inlining too)?
>> & sounds like this is suggesting that would change? That we would now 
>> perform always inlining separately from inlining? Maybe that's an 
>> orthogonal/separate change from one implementing the always inlining using 
>> the Inliner being run in a separate mode?
>
> In the NPM, we didn't run the AlwaysInliner until D86988 
> . See also the discussion there. The normal 
> inliner pass was, and still is, taking care of the mandatory inlinings if it 
> finds them. Of course, if we completely upfronted those (which this patch can 
> do), then the normal inliner wouldn't need to. I'm not suggesting changing 
> that - meaning, it's straightforward for the normal inliner to take care of 
> mandatory and policy-driven inlinings. The idea, though, is that if we 
> upfront the mandatory inlinings, the shape of the call graph the inliner 
> operates over is simpler and the effects of inlining probably more easy to 
> glean by the decision making policy. There are trade-offs, though - we can 
> increase that "ease of gleaning" by performing more function simplification 
> passes between the mandatory inlinings and the full inliner.

OK, so if I understand correctly with the old Pass Manager there were two 
separate passes (always inliner and inliner - they share some code though, 
yeah?) and they were run in the pass pipeline but potentially (definitely?) not 
adjacent? New pass manager survived for quite a while with only one inlining 
pass, that included a mandatorily strong preference for inlining always-inline 
functions? But still missed some recursive cases. So D86988 
 made the always inliner run right next 
to/before the inliner in the NPM.

Now there's tihs patch, to implement the AlwaysInliner using the inliner - but 
is also changing the order of passes to improve optimization opportunities by 
doing some cleanup after always inlining?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91567

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


[PATCH] D90507: Adding DWARF64 clang flag

2020-11-16 Thread David Blaikie via Phabricator via cfe-commits
dblaikie added inline comments.



Comment at: clang/include/clang/Basic/CodeGenOptions.def:35
 CODEGENOPT(AsmVerbose, 1, 0) ///< -dA, -fverbose-asm.
+CODEGENOPT(Dwarf64   , 1, 0) ///< -gdwarf64.
 CODEGENOPT(PreserveAsmComments, 1, 1) ///< -dA, -fno-preserve-as-comments.

Is there any precedent to draw from for this flag name? (Does GCC support 
DWARF64? Does it support it under this flag name or some other? (similarly with 
other gcc-like compilers (Intel's? Whoever else... )))


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D90507

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


Re: [clang] e7f3e21 - Suppress printing template arguments that match default template

2020-11-16 Thread Richard Smith via cfe-commits
On Mon, 16 Nov 2020 at 18:49, David Blaikie  wrote:

> On Wed, Nov 11, 2020 at 3:08 PM Richard Smith via cfe-commits
>  wrote:
> >
> >
> > Author: Richard Smith
> > Date: 2020-11-11T15:05:51-08:00
> > New Revision: e7f3e2103cdb567dda4fd52f81bf4bc07179f5a8
> >
> > URL:
> https://github.com/llvm/llvm-project/commit/e7f3e2103cdb567dda4fd52f81bf4bc07179f5a8
> > DIFF:
> https://github.com/llvm/llvm-project/commit/e7f3e2103cdb567dda4fd52f81bf4bc07179f5a8.diff
> >
> > LOG: Suppress printing template arguments that match default template
> > arguments of types by default.
> >
> > This somewhat improves the worst-case printing of types like
> > std::string, std::vector, etc., where many irrelevant default arguments
> > can be included in the type as printed if we've lost the type sugar.
>
> "somewhat" - are there still some remaining challenges here? (I'd have
> thought this would be a significant improvement in these worst cases
> of lost type sugar)
>

For std::vector, std::map, etc. we now print these types as-expected. But...

std::string is now printed as std::basic_string, which, while an
improvement, is still not the type name that we know a user would really
want to see (similarly for std::string_view, and really any of the typedefs
for std::basic_*). https://reviews.llvm.org/D91311 has a fix for that, but
we're still in discussion as to whether that's the right interface for that
functionality.


> >
> > Added:
> > clang/test/Misc/diag-template.cpp
> >
> > Modified:
> > clang/include/clang/AST/PrettyPrinter.h
> > clang/include/clang/AST/Type.h
> > clang/lib/AST/DeclTemplate.cpp
> > clang/lib/AST/TypePrinter.cpp
> > clang/lib/Frontend/FrontendActions.cpp
> > clang/test/SemaCXX/cxx14-compat.cpp
> > clang/test/SemaCXX/generic-selection.cpp
> > clang/test/SemaTemplate/class-template-id.cpp
> > clang/test/SemaTemplate/class-template-spec.cpp
> > clang/test/SemaTemplate/instantiation-default-1.cpp
> >
> > Removed:
> >
> >
> >
> >
> 
> > diff  --git a/clang/include/clang/AST/PrettyPrinter.h
> b/clang/include/clang/AST/PrettyPrinter.h
> > index dfd5851bb30d..50e2142e2ef0 100644
> > --- a/clang/include/clang/AST/PrettyPrinter.h
> > +++ b/clang/include/clang/AST/PrettyPrinter.h
> > @@ -55,7 +55,8 @@ struct PrintingPolicy {
> >  SuppressInitializers(false), ConstantArraySizeAsWritten(false),
> >  AnonymousTagLocations(true), SuppressStrongLifetime(false),
> >  SuppressLifetimeQualifiers(false),
> > -SuppressTemplateArgsInCXXConstructors(false), Bool(LO.Bool),
> > +SuppressTemplateArgsInCXXConstructors(false),
> > +SuppressDefaultTemplateArgs(true), Bool(LO.Bool),
> >  Nullptr(LO.CPlusPlus11), Restrict(LO.C99),
> Alignof(LO.CPlusPlus11),
> >  UnderscoreAlignof(LO.C11), UseVoidForZeroParams(!LO.CPlusPlus),
> >  SplitTemplateClosers(!LO.CPlusPlus11), TerseOutput(false),
> > @@ -167,6 +168,10 @@ struct PrintingPolicy {
> >/// constructors.
> >unsigned SuppressTemplateArgsInCXXConstructors : 1;
> >
> > +  /// When true, attempt to suppress template arguments that match the
> default
> > +  /// argument for the parameter.
> > +  unsigned SuppressDefaultTemplateArgs : 1;
> > +
> >/// Whether we can use 'bool' rather than '_Bool' (even if the
> language
> >/// doesn't actually have 'bool', because, e.g., it is defined as a
> macro).
> >unsigned Bool : 1;
> >
> > diff  --git a/clang/include/clang/AST/Type.h
> b/clang/include/clang/AST/Type.h
> > index 1442bc740620..6dedd097ff89 100644
> > --- a/clang/include/clang/AST/Type.h
> > +++ b/clang/include/clang/AST/Type.h
> > @@ -61,6 +61,7 @@ class ExtQuals;
> >  class QualType;
> >  class ConceptDecl;
> >  class TagDecl;
> > +class TemplateParameterList;
> >  class Type;
> >
> >  enum {
> > @@ -5196,15 +5197,18 @@ class alignas(8) TemplateSpecializationType
> >  /// enclosing the template arguments.
> >  void printTemplateArgumentList(raw_ostream ,
> > ArrayRef Args,
> > -   const PrintingPolicy );
> > +   const PrintingPolicy ,
> > +   const TemplateParameterList *TPL =
> nullptr);
> >
> >  void printTemplateArgumentList(raw_ostream ,
> > ArrayRef Args,
> > -   const PrintingPolicy );
> > +   const PrintingPolicy ,
> > +   const TemplateParameterList *TPL =
> nullptr);
> >
> >  void printTemplateArgumentList(raw_ostream ,
> > const TemplateArgumentListInfo ,
> > -   const PrintingPolicy );
> > +   const PrintingPolicy ,
> > +   const TemplateParameterList *TPL =
> nullptr);
> >
> >  /// The injected class name of a C++ class 

[PATCH] D91546: [AMDGPU] Add option -munsafe-fp-atomics

2020-11-16 Thread Yaxun Liu via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
yaxunl marked an inline comment as done.
Closed by commit rG3f4b5893efed: [AMDGPU] Add option -munsafe-fp-atomics 
(authored by yaxunl).
Herald added a project: clang.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91546

Files:
  clang/include/clang/Basic/TargetInfo.h
  clang/include/clang/Basic/TargetOptions.h
  clang/include/clang/Driver/Options.td
  clang/lib/Basic/TargetInfo.cpp
  clang/lib/Basic/Targets/AMDGPU.cpp
  clang/lib/CodeGen/TargetInfo.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/test/CodeGenCUDA/amdgpu-func-attrs.cu
  clang/test/Driver/hip-options.hip

Index: clang/test/Driver/hip-options.hip
===
--- clang/test/Driver/hip-options.hip
+++ clang/test/Driver/hip-options.hip
@@ -31,3 +31,7 @@
 // HOST-NOT: clang{{.*}} "-fcuda-is-device" {{.*}} "-debug-info-kind={{.*}}"
 // HOST-NOT: clang{{.*}} "-fcuda-is-device" {{.*}} "-debug-info-kind={{.*}}"
 // HOST: clang{{.*}} "-debug-info-kind={{.*}}"
+
+// RUN: %clang -### -nogpuinc -nogpulib -munsafe-fp-atomics \
+// RUN:   --cuda-gpu-arch=gfx906  %s 2>&1 | FileCheck -check-prefix=UNSAFE-FP-ATOMICS %s
+// UNSAFE-FP-ATOMICS: clang{{.*}} "-triple" "amdgcn-amd-amdhsa" {{.*}} "-munsafe-fp-atomics"
Index: clang/test/CodeGenCUDA/amdgpu-func-attrs.cu
===
--- /dev/null
+++ clang/test/CodeGenCUDA/amdgpu-func-attrs.cu
@@ -0,0 +1,22 @@
+// RUN: %clang_cc1 -triple amdgcn-amd-amdhsa \
+// RUN: -fcuda-is-device -emit-llvm -o - -x hip %s \
+// RUN: | FileCheck -check-prefixes=NO-UNSAFE-FP-ATOMICS %s
+// RUN: %clang_cc1 -triple amdgcn-amd-amdhsa \
+// RUN: -fcuda-is-device -emit-llvm -o - -x hip %s \
+// RUN: -munsafe-fp-atomics \
+// RUN: | FileCheck -check-prefixes=UNSAFE-FP-ATOMICS %s
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -emit-llvm \
+// RUN: -o - -x hip %s -munsafe-fp-atomics \
+// RUN: | FileCheck -check-prefix=NO-UNSAFE-FP-ATOMICS %s
+
+#include "Inputs/cuda.h"
+
+__device__ void test() {
+// UNSAFE-FP-ATOMICS: define void @_Z4testv() [[ATTR:#[0-9]+]]
+}
+
+
+// Make sure this is silently accepted on other targets.
+// NO-UNSAFE-FP-ATOMICS-NOT: "amdgpu-unsafe-fp-atomics"
+
+// UNSAFE-FP-ATOMICS-DAG: attributes [[ATTR]] = {{.*}}"amdgpu-unsafe-fp-atomics"="true"
Index: clang/lib/Frontend/CompilerInvocation.cpp
===
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -3747,6 +3747,9 @@
   Opts.ForceEnableInt128 = Args.hasArg(OPT_fforce_enable_int128);
   Opts.NVPTXUseShortPointers = Args.hasFlag(
   options::OPT_fcuda_short_ptr, options::OPT_fno_cuda_short_ptr, false);
+  Opts.AllowAMDGPUUnsafeFPAtomics =
+  Args.hasFlag(options::OPT_munsafe_fp_atomics,
+   options::OPT_mno_unsafe_fp_atomics, false);
   if (Arg *A = Args.getLastArg(options::OPT_target_sdk_version_EQ)) {
 llvm::VersionTuple Version;
 if (Version.tryParse(A->getValue()))
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -6217,6 +6217,11 @@
   }
 
   HandleAmdgcnLegacyOptions(D, Args, CmdArgs);
+  if (Triple.isAMDGPU()) {
+if (Args.hasFlag(options::OPT_munsafe_fp_atomics,
+ options::OPT_mno_unsafe_fp_atomics))
+  CmdArgs.push_back("-munsafe-fp-atomics");
+  }
 
   // For all the host OpenMP offloading compile jobs we need to pass the targets
   // information using -fopenmp-targets= option.
Index: clang/lib/CodeGen/TargetInfo.cpp
===
--- clang/lib/CodeGen/TargetInfo.cpp
+++ clang/lib/CodeGen/TargetInfo.cpp
@@ -9080,6 +9080,9 @@
 if (NumVGPR != 0)
   F->addFnAttr("amdgpu-num-vgpr", llvm::utostr(NumVGPR));
   }
+
+  if (M.getContext().getTargetInfo().allowAMDGPUUnsafeFPAtomics())
+F->addFnAttr("amdgpu-unsafe-fp-atomics", "true");
 }
 
 unsigned AMDGPUTargetCodeGenInfo::getOpenCLKernelCallingConv() const {
Index: clang/lib/Basic/Targets/AMDGPU.cpp
===
--- clang/lib/Basic/Targets/AMDGPU.cpp
+++ clang/lib/Basic/Targets/AMDGPU.cpp
@@ -323,6 +323,7 @@
   HasLegalHalfType = true;
   HasFloat16 = true;
   WavefrontSize = GPUFeatures & llvm::AMDGPU::FEATURE_WAVE32 ? 32 : 64;
+  AllowAMDGPUUnsafeFPAtomics = Opts.AllowAMDGPUUnsafeFPAtomics;
 
   // Set pointer width and alignment for target address space 0.
   PointerWidth = PointerAlign = DataLayout->getPointerSizeInBits();
Index: clang/lib/Basic/TargetInfo.cpp
===
--- 

[clang] 3f4b589 - [AMDGPU] Add option -munsafe-fp-atomics

2020-11-16 Thread Yaxun Liu via cfe-commits

Author: Yaxun (Sam) Liu
Date: 2020-11-16T21:52:12-05:00
New Revision: 3f4b5893efed620d93015896d79eb276628286f8

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

LOG: [AMDGPU] Add option -munsafe-fp-atomics

Add an option -munsafe-fp-atomics for AMDGPU target.

When enabled, clang adds function attribute "amdgpu-unsafe-fp-atomics"
to any functions for amdgpu target. This allows amdgpu backend to use
unsafe fp atomic instructions in these functions.

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

Added: 
clang/test/CodeGenCUDA/amdgpu-func-attrs.cu

Modified: 
clang/include/clang/Basic/TargetInfo.h
clang/include/clang/Basic/TargetOptions.h
clang/include/clang/Driver/Options.td
clang/lib/Basic/TargetInfo.cpp
clang/lib/Basic/Targets/AMDGPU.cpp
clang/lib/CodeGen/TargetInfo.cpp
clang/lib/Driver/ToolChains/Clang.cpp
clang/lib/Frontend/CompilerInvocation.cpp
clang/test/Driver/hip-options.hip

Removed: 




diff  --git a/clang/include/clang/Basic/TargetInfo.h 
b/clang/include/clang/Basic/TargetInfo.h
index 26dc6eacb204..698964b94ee2 100644
--- a/clang/include/clang/Basic/TargetInfo.h
+++ b/clang/include/clang/Basic/TargetInfo.h
@@ -218,6 +218,8 @@ class TargetInfo : public virtual TransferrableTargetInfo,
 
   unsigned HasAArch64SVETypes : 1;
 
+  unsigned AllowAMDGPUUnsafeFPAtomics : 1;
+
   unsigned ARMCDECoprocMask : 8;
 
   unsigned MaxOpenCLWorkGroupSize;
@@ -857,6 +859,10 @@ class TargetInfo : public virtual TransferrableTargetInfo,
   /// available on this target.
   bool hasAArch64SVETypes() const { return HasAArch64SVETypes; }
 
+  /// Returns whether or not the AMDGPU unsafe floating point atomics are
+  /// allowed.
+  bool allowAMDGPUUnsafeFPAtomics() const { return AllowAMDGPUUnsafeFPAtomics; 
}
+
   /// For ARM targets returns a mask defining which coprocessors are configured
   /// as Custom Datapath.
   uint32_t getARMCDECoprocMask() const { return ARMCDECoprocMask; }

diff  --git a/clang/include/clang/Basic/TargetOptions.h 
b/clang/include/clang/Basic/TargetOptions.h
index d1cc024957da..f81c150b7d0a 100644
--- a/clang/include/clang/Basic/TargetOptions.h
+++ b/clang/include/clang/Basic/TargetOptions.h
@@ -75,6 +75,9 @@ class TargetOptions {
   /// address space.
   bool NVPTXUseShortPointers = false;
 
+  /// \brief If enabled, allow AMDGPU unsafe floating point atomics.
+  bool AllowAMDGPUUnsafeFPAtomics = false;
+
   // The code model to be used as specified by the user. Corresponds to
   // CodeModel::Model enum defined in include/llvm/Support/CodeGen.h, plus
   // "default" for the case when the user has not explicitly specified a

diff  --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index ec86c5e07ab6..0168d7000737 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -2546,6 +2546,11 @@ def mxnack : Flag<["-"], "mxnack">, 
Group,
   HelpText<"Specify XNACK mode (AMDGPU only)">;
 def mno_xnack : Flag<["-"], "mno-xnack">, Group;
 
+def munsafe_fp_atomics : Flag<["-"], "munsafe-fp-atomics">, Group,
+  HelpText<"Enable unsafe floating point atomic instructions (AMDGPU only)">,
+  Flags<[CC1Option]>;
+def mno_unsafe_fp_atomics : Flag<["-"], "mno-unsafe-fp-atomics">, 
Group;
+
 def faltivec : Flag<["-"], "faltivec">, Group, Flags<[NoXarchOption]>;
 def fno_altivec : Flag<["-"], "fno-altivec">, Group, 
Flags<[NoXarchOption]>;
 def maltivec : Flag<["-"], "maltivec">, Group;

diff  --git a/clang/lib/Basic/TargetInfo.cpp b/clang/lib/Basic/TargetInfo.cpp
index eccdc21d724a..642ee753d224 100644
--- a/clang/lib/Basic/TargetInfo.cpp
+++ b/clang/lib/Basic/TargetInfo.cpp
@@ -115,6 +115,7 @@ TargetInfo::TargetInfo(const llvm::Triple ) : 
TargetOpts(), Triple(T) {
   HasBuiltinMSVaList = false;
   IsRenderScriptTarget = false;
   HasAArch64SVETypes = false;
+  AllowAMDGPUUnsafeFPAtomics = false;
   ARMCDECoprocMask = 0;
 
   // Default to no types using fpret.

diff  --git a/clang/lib/Basic/Targets/AMDGPU.cpp 
b/clang/lib/Basic/Targets/AMDGPU.cpp
index 4d6a9a5e0b51..9b88dff7c4af 100644
--- a/clang/lib/Basic/Targets/AMDGPU.cpp
+++ b/clang/lib/Basic/Targets/AMDGPU.cpp
@@ -323,6 +323,7 @@ AMDGPUTargetInfo::AMDGPUTargetInfo(const llvm::Triple 
,
   HasLegalHalfType = true;
   HasFloat16 = true;
   WavefrontSize = GPUFeatures & llvm::AMDGPU::FEATURE_WAVE32 ? 32 : 64;
+  AllowAMDGPUUnsafeFPAtomics = Opts.AllowAMDGPUUnsafeFPAtomics;
 
   // Set pointer width and alignment for target address space 0.
   PointerWidth = PointerAlign = DataLayout->getPointerSizeInBits();

diff  --git a/clang/lib/CodeGen/TargetInfo.cpp 
b/clang/lib/CodeGen/TargetInfo.cpp
index 1e5920322ecd..a98e4095b074 100644
--- a/clang/lib/CodeGen/TargetInfo.cpp
+++ b/clang/lib/CodeGen/TargetInfo.cpp

Re: [clang] e7f3e21 - Suppress printing template arguments that match default template

2020-11-16 Thread David Blaikie via cfe-commits
On Wed, Nov 11, 2020 at 3:08 PM Richard Smith via cfe-commits
 wrote:
>
>
> Author: Richard Smith
> Date: 2020-11-11T15:05:51-08:00
> New Revision: e7f3e2103cdb567dda4fd52f81bf4bc07179f5a8
>
> URL: 
> https://github.com/llvm/llvm-project/commit/e7f3e2103cdb567dda4fd52f81bf4bc07179f5a8
> DIFF: 
> https://github.com/llvm/llvm-project/commit/e7f3e2103cdb567dda4fd52f81bf4bc07179f5a8.diff
>
> LOG: Suppress printing template arguments that match default template
> arguments of types by default.
>
> This somewhat improves the worst-case printing of types like
> std::string, std::vector, etc., where many irrelevant default arguments
> can be included in the type as printed if we've lost the type sugar.

"somewhat" - are there still some remaining challenges here? (I'd have
thought this would be a significant improvement in these worst cases
of lost type sugar)

>
> Added:
> clang/test/Misc/diag-template.cpp
>
> Modified:
> clang/include/clang/AST/PrettyPrinter.h
> clang/include/clang/AST/Type.h
> clang/lib/AST/DeclTemplate.cpp
> clang/lib/AST/TypePrinter.cpp
> clang/lib/Frontend/FrontendActions.cpp
> clang/test/SemaCXX/cxx14-compat.cpp
> clang/test/SemaCXX/generic-selection.cpp
> clang/test/SemaTemplate/class-template-id.cpp
> clang/test/SemaTemplate/class-template-spec.cpp
> clang/test/SemaTemplate/instantiation-default-1.cpp
>
> Removed:
>
>
>
> 
> diff  --git a/clang/include/clang/AST/PrettyPrinter.h 
> b/clang/include/clang/AST/PrettyPrinter.h
> index dfd5851bb30d..50e2142e2ef0 100644
> --- a/clang/include/clang/AST/PrettyPrinter.h
> +++ b/clang/include/clang/AST/PrettyPrinter.h
> @@ -55,7 +55,8 @@ struct PrintingPolicy {
>  SuppressInitializers(false), ConstantArraySizeAsWritten(false),
>  AnonymousTagLocations(true), SuppressStrongLifetime(false),
>  SuppressLifetimeQualifiers(false),
> -SuppressTemplateArgsInCXXConstructors(false), Bool(LO.Bool),
> +SuppressTemplateArgsInCXXConstructors(false),
> +SuppressDefaultTemplateArgs(true), Bool(LO.Bool),
>  Nullptr(LO.CPlusPlus11), Restrict(LO.C99), Alignof(LO.CPlusPlus11),
>  UnderscoreAlignof(LO.C11), UseVoidForZeroParams(!LO.CPlusPlus),
>  SplitTemplateClosers(!LO.CPlusPlus11), TerseOutput(false),
> @@ -167,6 +168,10 @@ struct PrintingPolicy {
>/// constructors.
>unsigned SuppressTemplateArgsInCXXConstructors : 1;
>
> +  /// When true, attempt to suppress template arguments that match the 
> default
> +  /// argument for the parameter.
> +  unsigned SuppressDefaultTemplateArgs : 1;
> +
>/// Whether we can use 'bool' rather than '_Bool' (even if the language
>/// doesn't actually have 'bool', because, e.g., it is defined as a macro).
>unsigned Bool : 1;
>
> diff  --git a/clang/include/clang/AST/Type.h b/clang/include/clang/AST/Type.h
> index 1442bc740620..6dedd097ff89 100644
> --- a/clang/include/clang/AST/Type.h
> +++ b/clang/include/clang/AST/Type.h
> @@ -61,6 +61,7 @@ class ExtQuals;
>  class QualType;
>  class ConceptDecl;
>  class TagDecl;
> +class TemplateParameterList;
>  class Type;
>
>  enum {
> @@ -5196,15 +5197,18 @@ class alignas(8) TemplateSpecializationType
>  /// enclosing the template arguments.
>  void printTemplateArgumentList(raw_ostream ,
> ArrayRef Args,
> -   const PrintingPolicy );
> +   const PrintingPolicy ,
> +   const TemplateParameterList *TPL = nullptr);
>
>  void printTemplateArgumentList(raw_ostream ,
> ArrayRef Args,
> -   const PrintingPolicy );
> +   const PrintingPolicy ,
> +   const TemplateParameterList *TPL = nullptr);
>
>  void printTemplateArgumentList(raw_ostream ,
> const TemplateArgumentListInfo ,
> -   const PrintingPolicy );
> +   const PrintingPolicy ,
> +   const TemplateParameterList *TPL = nullptr);
>
>  /// The injected class name of a C++ class template or class
>  /// template partial specialization.  Used to record that a type was
>
> diff  --git a/clang/lib/AST/DeclTemplate.cpp b/clang/lib/AST/DeclTemplate.cpp
> index 9918377070c3..328ceaa63df3 100644
> --- a/clang/lib/AST/DeclTemplate.cpp
> +++ b/clang/lib/AST/DeclTemplate.cpp
> @@ -914,10 +914,14 @@ void 
> ClassTemplateSpecializationDecl::getNameForDiagnostic(
>const auto *PS = dyn_cast(this);
>if (const ASTTemplateArgumentListInfo *ArgsAsWritten =
>PS ? PS->getTemplateArgsAsWritten() : nullptr) {
> -printTemplateArgumentList(OS, ArgsAsWritten->arguments(), Policy);
> +printTemplateArgumentList(
> +OS, ArgsAsWritten->arguments(), Policy,
> +

Re: [clang] 5f12f4f - Suppress printing of inline namespace names in diagnostics by default,

2020-11-16 Thread David Blaikie via cfe-commits
Neat!

On Wed, Nov 11, 2020 at 3:08 PM Richard Smith via cfe-commits
 wrote:
>
>
> Author: Richard Smith
> Date: 2020-11-11T15:05:51-08:00
> New Revision: 5f12f4ff9078455cad9d4806da01f570553a5bf9
>
> URL: 
> https://github.com/llvm/llvm-project/commit/5f12f4ff9078455cad9d4806da01f570553a5bf9
> DIFF: 
> https://github.com/llvm/llvm-project/commit/5f12f4ff9078455cad9d4806da01f570553a5bf9.diff
>
> LOG: Suppress printing of inline namespace names in diagnostics by default,
> except where they are necessary to disambiguate the target.
>
> This substantially improves diagnostics from the standard library,
> which are otherwise full of `::__1::` noise.
>
> Added:
> clang/test/Misc/diag-inline-namespace.cpp
>
> Modified:
> clang/include/clang/AST/PrettyPrinter.h
> clang/lib/AST/Decl.cpp
> clang/lib/AST/TypePrinter.cpp
> clang/lib/ASTMatchers/ASTMatchersInternal.cpp
> clang/lib/CodeGen/CodeGenTypes.cpp
> clang/test/CXX/dcl.dcl/basic.namespace/namespace.def/p8.cpp
>
> Removed:
>
>
>
> 
> diff  --git a/clang/include/clang/AST/PrettyPrinter.h 
> b/clang/include/clang/AST/PrettyPrinter.h
> index 50e2142e2ef0..e06b3b8843ce 100644
> --- a/clang/include/clang/AST/PrettyPrinter.h
> +++ b/clang/include/clang/AST/PrettyPrinter.h
> @@ -52,9 +52,9 @@ struct PrintingPolicy {
>: Indentation(2), SuppressSpecifiers(false),
>  SuppressTagKeyword(LO.CPlusPlus), IncludeTagDefinition(false),
>  SuppressScope(false), SuppressUnwrittenScope(false),
> -SuppressInitializers(false), ConstantArraySizeAsWritten(false),
> -AnonymousTagLocations(true), SuppressStrongLifetime(false),
> -SuppressLifetimeQualifiers(false),
> +SuppressInlineNamespace(true), SuppressInitializers(false),
> +ConstantArraySizeAsWritten(false), AnonymousTagLocations(true),
> +SuppressStrongLifetime(false), SuppressLifetimeQualifiers(false),
>  SuppressTemplateArgsInCXXConstructors(false),
>  SuppressDefaultTemplateArgs(true), Bool(LO.Bool),
>  Nullptr(LO.CPlusPlus11), Restrict(LO.C99), Alignof(LO.CPlusPlus11),
> @@ -118,10 +118,15 @@ struct PrintingPolicy {
>/// Suppresses printing of scope specifiers.
>unsigned SuppressScope : 1;
>
> -  /// Suppress printing parts of scope specifiers that don't need
> -  /// to be written, e.g., for inline or anonymous namespaces.
> +  /// Suppress printing parts of scope specifiers that are never
> +  /// written, e.g., for anonymous namespaces.
>unsigned SuppressUnwrittenScope : 1;
>
> +  /// Suppress printing parts of scope specifiers that correspond
> +  /// to inline namespaces, where the name is unambiguous with the specifier
> +  /// removed.
> +  unsigned SuppressInlineNamespace : 1;
> +
>/// Suppress printing of variable initializers.
>///
>/// This flag is used when printing the loop variable in a for-range
>
> diff  --git a/clang/lib/AST/Decl.cpp b/clang/lib/AST/Decl.cpp
> index 5055c6359d1c..88878466 100644
> --- a/clang/lib/AST/Decl.cpp
> +++ b/clang/lib/AST/Decl.cpp
> @@ -1600,21 +1600,35 @@ void NamedDecl::printNestedNameSpecifier(raw_ostream 
> ,
>ContextsTy Contexts;
>
>// Collect named contexts.
> -  while (Ctx) {
> -if (isa(Ctx))
> -  Contexts.push_back(Ctx);
> -Ctx = Ctx->getParent();
> +  DeclarationName NameInScope = getDeclName();
> +  for (; Ctx; Ctx = Ctx->getParent()) {
> +// Suppress anonymous namespace if requested.
> +if (P.SuppressUnwrittenScope && isa(Ctx) &&
> +cast(Ctx)->isAnonymousNamespace())
> +  continue;
> +
> +// Suppress inline namespace if it doesn't make the result ambiguous.
> +if (P.SuppressInlineNamespace && Ctx->isInlineNamespace() && NameInScope 
> &&
> +Ctx->lookup(NameInScope).size() ==
> +Ctx->getParent()->lookup(NameInScope).size())
> +  continue;
> +
> +// Skip non-named contexts such as linkage specifications and 
> ExportDecls.
> +const NamedDecl *ND = dyn_cast(Ctx);
> +if (!ND)
> +  continue;
> +
> +Contexts.push_back(Ctx);
> +NameInScope = ND->getDeclName();
>}
>
> -  for (const DeclContext *DC : llvm::reverse(Contexts)) {
> +  for (unsigned I = Contexts.size(); I != 0; --I) {
> +const DeclContext *DC = Contexts[I - 1];
>  if (const auto *Spec = dyn_cast(DC)) {
>OS << Spec->getName();
>const TemplateArgumentList  = Spec->getTemplateArgs();
>printTemplateArgumentList(OS, TemplateArgs.asArray(), P);
>  } else if (const auto *ND = dyn_cast(DC)) {
> -  if (P.SuppressUnwrittenScope &&
> -  (ND->isAnonymousNamespace() || ND->isInline()))
> -continue;
>if (ND->isAnonymousNamespace()) {
>  OS << (P.MSVCFormatting ? "`anonymous namespace\'"
>  : "(anonymous namespace)");
>
> diff  --git a/clang/lib/AST/TypePrinter.cpp b/clang/lib/AST/TypePrinter.cpp
> index 

[PATCH] D67112: [Sema] Introduce function reference conversion, NFC

2020-11-16 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith accepted this revision.
rsmith added a comment.
This revision is now accepted and ready to land.

Looks fine as far as it goes, but it looks like we're also missing a cast in 
function pointer initialization via function conversion:

  void f() noexcept;
  void (*p)() = f; 

results in

  |-VarDecl 0x105143e8  col:8 p 'void (*)()' cinit
  | `-ImplicitCastExpr 0x10514498  'void (*)() noexcept' 

  |   `-DeclRefExpr 0x10514450  'void () noexcept' lvalue Function 
0x10514240 'f' 'void () noexcept'


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D67112

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


[PATCH] D17993: [CodeGen] Apply 'nonnull' and 'dereferenceable(N)' to 'this' pointer arguments.

2020-11-16 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG69cd776e1ee7: [CodeGen] Apply nonnull and 
dereferenceable(N) to this pointer (authored by 
CJ-Johnson, committed by rsmith).
Herald added a project: clang.

Changed prior to commit:
  https://reviews.llvm.org/D17993?vs=305603=305632#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D17993

Files:
  clang/docs/ReleaseNotes.rst
  clang/lib/CodeGen/CGCall.cpp
  clang/test/CXX/except/except.spec/p14-ir.cpp
  clang/test/CodeGen/aix-ignore-xcoff-visibility.cpp
  clang/test/CodeGen/arm64-microsoft-arguments.cpp
  clang/test/CodeGen/attr-nomerge.cpp
  clang/test/CodeGen/no-builtin.cpp
  clang/test/CodeGen/temporary-lifetime.cpp
  clang/test/CodeGenCUDA/device-var-init.cu
  clang/test/CodeGenCXX/2011-12-19-init-list-ctor.cpp
  
clang/test/CodeGenCXX/RelativeVTablesABI/child-inheritted-from-parent-in-comdat.cpp
  clang/test/CodeGenCXX/RelativeVTablesABI/child-vtable-in-comdat.cpp
  clang/test/CodeGenCXX/RelativeVTablesABI/cross-translation-unit-1.cpp
  clang/test/CodeGenCXX/RelativeVTablesABI/cross-translation-unit-2.cpp
  clang/test/CodeGenCXX/RelativeVTablesABI/diamond-virtual-inheritance.cpp
  clang/test/CodeGenCXX/RelativeVTablesABI/member-function-pointer.cpp
  clang/test/CodeGenCXX/RelativeVTablesABI/multiple-inheritance.cpp
  clang/test/CodeGenCXX/RelativeVTablesABI/parent-and-child-in-comdats.cpp
  clang/test/CodeGenCXX/RelativeVTablesABI/parent-vtable-in-comdat.cpp
  clang/test/CodeGenCXX/RelativeVTablesABI/pass-byval-attributes.cpp
  clang/test/CodeGenCXX/RelativeVTablesABI/simple-vtable-definition.cpp
  clang/test/CodeGenCXX/RelativeVTablesABI/vbase-offset.cpp
  clang/test/CodeGenCXX/RelativeVTablesABI/virtual-function-call.cpp
  clang/test/CodeGenCXX/aix-static-init-debug-info.cpp
  clang/test/CodeGenCXX/aix-static-init-temp-spec-and-inline-var.cpp
  clang/test/CodeGenCXX/aix-static-init.cpp
  clang/test/CodeGenCXX/amdgcn-automatic-variable.cpp
  clang/test/CodeGenCXX/amdgcn-func-arg.cpp
  clang/test/CodeGenCXX/apple-kext-indirect-call.cpp
  clang/test/CodeGenCXX/apple-kext-indirect-virtual-dtor-call.cpp
  clang/test/CodeGenCXX/apple-kext.cpp
  clang/test/CodeGenCXX/arm.cpp
  clang/test/CodeGenCXX/arm64-constructor-return.cpp
  clang/test/CodeGenCXX/array-default-argument.cpp
  clang/test/CodeGenCXX/atomicinit.cpp
  clang/test/CodeGenCXX/attr-disable-tail-calls.cpp
  clang/test/CodeGenCXX/attr-target-mv-member-funcs.cpp
  clang/test/CodeGenCXX/attr-target-mv-out-of-line-defs.cpp
  clang/test/CodeGenCXX/attr.cpp
  clang/test/CodeGenCXX/auto-variable-template.cpp
  clang/test/CodeGenCXX/blocks-cxx11.cpp
  clang/test/CodeGenCXX/blocks.cpp
  clang/test/CodeGenCXX/builtin-source-location.cpp
  clang/test/CodeGenCXX/builtin_LINE.cpp
  clang/test/CodeGenCXX/catch-undef-behavior.cpp
  clang/test/CodeGenCXX/cfi-cross-dso.cpp
  clang/test/CodeGenCXX/conditional-gnu-ext.cpp
  clang/test/CodeGenCXX/const-init-cxx11.cpp
  clang/test/CodeGenCXX/constructor-destructor-return-this.cpp
  clang/test/CodeGenCXX/constructor-direct-call.cpp
  clang/test/CodeGenCXX/constructor-init.cpp
  clang/test/CodeGenCXX/constructors.cpp
  clang/test/CodeGenCXX/copy-constructor-elim-2.cpp
  clang/test/CodeGenCXX/copy-constructor-synthesis.cpp
  clang/test/CodeGenCXX/cxx0x-delegating-ctors.cpp
  clang/test/CodeGenCXX/cxx0x-initializer-constructors.cpp
  clang/test/CodeGenCXX/cxx0x-initializer-stdinitializerlist.cpp
  clang/test/CodeGenCXX/cxx11-initializer-aggregate.cpp
  clang/test/CodeGenCXX/cxx11-initializer-array-new.cpp
  clang/test/CodeGenCXX/cxx11-thread-local.cpp
  clang/test/CodeGenCXX/cxx1y-init-captures.cpp
  clang/test/CodeGenCXX/cxx1y-sized-deallocation.cpp
  clang/test/CodeGenCXX/cxx1z-copy-omission.cpp
  clang/test/CodeGenCXX/cxx1z-decomposition.cpp
  clang/test/CodeGenCXX/cxx1z-initializer-aggregate.cpp
  clang/test/CodeGenCXX/cxx1z-lambda-star-this.cpp
  clang/test/CodeGenCXX/cxx2a-destroying-delete.cpp
  clang/test/CodeGenCXX/debug-info-class.cpp
  clang/test/CodeGenCXX/debug-info-destroy-helper.cpp
  clang/test/CodeGenCXX/debug-info-ms-dtor-thunks.cpp
  clang/test/CodeGenCXX/default-arg-temps.cpp
  clang/test/CodeGenCXX/default-arguments.cpp
  clang/test/CodeGenCXX/delete.cpp
  clang/test/CodeGenCXX/derived-to-base-conv.cpp
  clang/test/CodeGenCXX/destructors.cpp
  clang/test/CodeGenCXX/devirtualize-virtual-function-calls-final.cpp
  clang/test/CodeGenCXX/devirtualize-virtual-function-calls.cpp
  clang/test/CodeGenCXX/dllexport-ctor-closure.cpp
  clang/test/CodeGenCXX/dllexport-members.cpp
  clang/test/CodeGenCXX/dllexport.cpp
  clang/test/CodeGenCXX/dllimport-dtor-thunks.cpp
  clang/test/CodeGenCXX/dllimport-members.cpp
  clang/test/CodeGenCXX/dllimport.cpp
  clang/test/CodeGenCXX/duplicate-mangled-name.cpp
  clang/test/CodeGenCXX/eh.cpp
  clang/test/CodeGenCXX/empty-nontrivially-copyable.cpp
  

[PATCH] D91311: Add new 'preferred_name' attribute.

2020-11-16 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith marked an inline comment as done.
rsmith added a comment.

In D91311#2398144 , @ldionne wrote:

> What the attribute achieves is great, however I must say I'm really with 
> Arthur's original comment regarding the ergonomics of it.

I do agree, the ergonomics aren't good. Due to the way that instantiations of 
attributes on templates work, we end up needing to see the attribute no later 
than on the definition of the template, which forces the template to be 
declared at least twice, and similarly the typedef needs to be named at least 
twice (once to declare it, and once to annotate it on the template). It would 
certainly be more convenient to attach the attribute to the typedef.

> IMO, it makes a lot more sense to permit the typedef author to pick how their 
> typedef is going to be "named" by the compiler.

Well, this attribute doesn't affect how the typedef is named -- if we know the 
type was named via a typedef, we'll use that typedef-name to describe the type 
regardless of this attribute. For example, if you have `using Name = 
std::basic_string;` and then use the type `Name`, we're going to call the 
type `Name` everywhere we have tracked enough information to know that you used 
a typedef. Rather, the attribute affects how a template specialization is named 
in the case where we can't track it back to a typedef or other type sugar -- 
for example, if in a use of `Name` we lose the association back to the typedef 
`Name` and only know that it's `std::basic_string`, we'll call it 
`std::string` instead. So this really changes a property of the template (or 
more accurately, a specialization of the template), not a property of the 
typedef.

I think allowing the attribute on a typedef would be misleading: people would, 
quite reasonably, expect that they can specify the attribute on an arbitrary 
typedef and that typedef name would be preferred when printing that type in 
general. We could in principle support such a generalized attribute on 
typedefs, but I don't think that would be a good idea. Such an attribute would 
be very complex to support (primarily due to lazy loading of module files), and 
I'd expect it to be heavily abused, with people "renaming" built-in types, 
pointer types, etc. in ways that are unhelpful to users of their code.

> If they pick something crazy or misleading, it's really their problem.

I don't entirely agree with this part -- such misuse would be a problem for 
anyone who uses the header containing the typedef and now sees type names in 
diagnostics that have nothing to do with the code in question. Nonetheless, 
misuse is the problem of the people misusing the attribute and their users; 
it's not necessarily our problem, and we don't necessarily need to design an 
attribute that can't be misused.

> I think that the fact we need to re declare everything shows how the 
> ergonomics would be better if we could just add the attribute to the typedef. 
> See for example how we're re-declaring a bunch of stuff in ``. How 
> bad of an idea is it to try putting the attribute on typedefs instead, and 
> how strongly are you opposed to it? Because from a naive user perspective, 
> having to redeclare the class with a closed set of preferred names feels 
> awkward (IMO, of course).

How much should we concern ourselves with ergonomics in this instance? Most of 
the intended uses of this attribute (at least by how often they'll affect 
diagnostics) are included in this patch, and are in code that we don't expect 
many people to look at most of the time, that is maintained by domain experts, 
and that is generally optimized for other properties than readability. However, 
this is certainly intended to be used by third-party library authors; otherwise 
we could just add a hard-coded table to Clang itself. So I think ergonomics do 
matter a little, but that other factors are probably more important.

We could allow the attribute on typedefs, and internally reverse the sense of 
it and attach it to the template specialization instead, but that would be 
incredibly messy -- in order to maintain AST invariants and source fidelity, 
we'd need to synthesize a new declaration of the template specialization to 
attach the attribute to, or something similar. We'd still need the attribute to 
appear before the template definition, though -- unless we rework how attribute 
instantiation is done -- so that's not really a general solution to the 
ergonomics issue. Or we could store a side-table, which would also bring with 
it a lot of complexity, particularly when we come to lazily load such 
information from module files. In my view, the added implementation complexity 
from attaching the attribute to a typedef outweighs the ergonomic benefit.

There's another design approach we could follow, that would keep the attribute 
on the template but avoid the awkwardness of requiring the typedef to appear 
first: we could completely divorce this 

[PATCH] D90507: Adding DWARF64 clang flag

2020-11-16 Thread Alexander Yermolovich via Phabricator via cfe-commits
ayermolo added a comment.

In D90507#2394109 , @wenlei wrote:

> This change covers non-LTO cases. For LTO, I think we would need to pass it 
> from driver to LTO. Something like this: tools::addLTOOptions -> lld -> 
> lto::Config (Config->TargetOptions->MCTargetOptions) ->LTO Backend.

Good point. Maybe part of a different diff, since lld needs to be modified also.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D90507

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


[PATCH] D90507: Adding DWARF64 clang flag

2020-11-16 Thread Alexander Yermolovich via Phabricator via cfe-commits
ayermolo added a comment.

In D90507#2393434 , @jansvoboda11 
wrote:

> Hi @ayermolo, do you think this might be triggered by D82756 
> ? (my only upstream patch ATM)

Oh, no. Sorry I wasn't clear. I was just looking for people to review this 
patch, and saw you recently reviewed another patch.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D90507

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


[PATCH] D17922: [clang-format] Don't add a space before Obj-C selector methods that are also clang-format keywords

2020-11-16 Thread Keith Smiley via Phabricator via cfe-commits
keith commandeered this revision.
keith added a reviewer: ksuther.
keith added a comment.

Note the test case shown here passes on master, so we can drop this


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

https://reviews.llvm.org/D17922

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


[PATCH] D87956: [IR] add fn attr for no_stack_protector; prevent inlining on mismatch

2020-11-16 Thread Arthur Eubanks via Phabricator via cfe-commits
aeubanks added inline comments.



Comment at: llvm/test/Transforms/Inline/inline_nossp.ll:3
+; RUN: opt -passes='cgscc(inline)' %s -S | FileCheck %s
+; RUN: opt -always-inline -o - -S %s | FileCheck %s
+

nickdesaulniers wrote:
> aeubanks wrote:
> > This test fails with the NPM,
> > `opt -passes=always-inline ...`
> > 
> > Does `llvm::isInlineViable()` need to be updated?
> Thanks for the report.  Is there a Cmake configuration I need to explicitly 
> set to reproduce? `LLVM_USE_NEWPM`?
Just a new RUN line: `RUN: opt -passes=always-inline -o - -S %s | FileCheck %s`


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87956

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


[PATCH] D91567: [llvm][inliner] Reuse the inliner pass to implement 'always inliner'

2020-11-16 Thread Mircea Trofin via Phabricator via cfe-commits
mtrofin added a comment.

In D91567#2398440 , @dblaikie wrote:

>> Performing the mandatory inlinings first simplifies the problem the full 
>> inliner needs to solve
>
> That confuses me a bit - is that suggesting that we don't run the 
> AlwaysInliner when we are running the Inliner (ie: we only run the 
> AlwaysInliner at -O0, and use the Inliner at higher optimization levels and 
> let the Inliner do always inlining too)?
> & sounds like this is suggesting that would change? That we would now perform 
> always inlining separately from inlining? Maybe that's an orthogonal/separate 
> change from one implementing the always inlining using the Inliner being run 
> in a separate mode?

In the NPM, we didn't run the AlwaysInliner until D86988 
. See also the discussion there. The normal 
inliner pass was, and still is, taking care of the mandatory inlinings if it 
finds them. Of course, if we completely upfronted those (which this patch can 
do), then the normal inliner wouldn't need to. I'm not suggesting changing that 
- meaning, it's straightforward for the normal inliner to take care of 
mandatory and policy-driven inlinings. The idea, though, is that if we upfront 
the mandatory inlinings, the shape of the call graph the inliner operates over 
is simpler and the effects of inlining probably more easy to glean by the 
decision making policy. There are trade-offs, though - we can increase that 
"ease of gleaning" by performing more function simplification passes between 
the mandatory inlinings and the full inliner.

In D91567#2398440 , @dblaikie wrote:

>> Performing the mandatory inlinings first simplifies the problem the full 
>> inliner needs to solve
>
> That confuses me a bit - is that suggesting that we don't run the 
> AlwaysInliner when we are running the Inliner (ie: we only run the 
> AlwaysInliner at -O0, and use the Inliner at higher optimization levels and 
> let the Inliner do always inlining too)?
> & sounds like this is suggesting that would change? That we would now perform 
> always inlining separately from inlining? Maybe that's an orthogonal/separate 
> change from one implementing the always inlining using the Inliner being run 
> in a separate mode?




Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91567

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


[PATCH] D91580: [Frontend] Add flag to allow PCM generation despite compiler errors

2020-11-16 Thread Ben Barham via Phabricator via cfe-commits
bnbarham updated this revision to Diff 305622.
bnbarham added a comment.

Noticed I had left in the `-fdisable-module-hash` flags in the test, removed 
now.


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

https://reviews.llvm.org/D91580

Files:
  clang/include/clang/Driver/Options.td
  clang/include/clang/Frontend/ASTUnit.h
  clang/include/clang/Frontend/FrontendActions.h
  clang/include/clang/Frontend/FrontendOptions.h
  clang/lib/Frontend/ASTUnit.cpp
  clang/lib/Frontend/CompilerInstance.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/lib/Frontend/FrontendActions.cpp
  clang/test/Modules/Inputs/error.h
  clang/test/Modules/Inputs/module.map
  clang/test/Modules/load-module-with-errors.m
  clang/tools/c-index-test/core_main.cpp
  clang/tools/libclang/CIndex.cpp

Index: clang/tools/libclang/CIndex.cpp
===
--- clang/tools/libclang/CIndex.cpp
+++ clang/tools/libclang/CIndex.cpp
@@ -3476,7 +3476,7 @@
   ast_filename, CXXIdx->getPCHContainerOperations()->getRawReader(),
   ASTUnit::LoadEverything, Diags, FileSystemOpts, /*UseDebugInfo=*/false,
   CXXIdx->getOnlyLocalDecls(), None, CaptureDiagsKind::All,
-  /*AllowPCHWithCompilerErrors=*/true,
+  /*AllowASTWithCompilerErrors=*/true,
   /*UserFilesAreVolatile=*/true);
   *out_TU = MakeCXTranslationUnit(CXXIdx, std::move(AU));
   return *out_TU ? CXError_Success : CXError_Failure;
Index: clang/tools/c-index-test/core_main.cpp
===
--- clang/tools/c-index-test/core_main.cpp
+++ clang/tools/c-index-test/core_main.cpp
@@ -263,7 +263,7 @@
   std::string(modulePath), *pchRdr, ASTUnit::LoadASTOnly, Diags,
   FileSystemOpts, /*UseDebugInfo=*/false,
   /*OnlyLocalDecls=*/true, None, CaptureDiagsKind::None,
-  /*AllowPCHWithCompilerErrors=*/true,
+  /*AllowASTWithCompilerErrors=*/true,
   /*UserFilesAreVolatile=*/false);
   if (!AU) {
 errs() << "failed to create TU for: " << modulePath << '\n';
Index: clang/test/Modules/load-module-with-errors.m
===
--- /dev/null
+++ clang/test/Modules/load-module-with-errors.m
@@ -0,0 +1,14 @@
+// RUN: rm -rf %t
+
+// RUN: %clang_cc1 -fmodules -fallow-pcm-with-compiler-errors -fmodules-cache-path=%t -emit-module -x objective-c -fmodule-name=error %S/Inputs/module.map
+// RUN: %clang_cc1 -fmodules -fimplicit-module-maps -fallow-pcm-with-compiler-errors -ast-print -x objective-c -fmodules-cache-path=%t -I %S/Inputs %s | FileCheck -check-prefix=CHECK-PRINT %s
+
+@import error;
+
+void test(id x) {
+  [x method];
+}
+
+// CHECK-PRINT: @interface Error
+// CHECK-PRINT-NEXT: - (int)method;
+// CHECK-PRINT: void test(id x)
Index: clang/test/Modules/Inputs/module.map
===
--- clang/test/Modules/Inputs/module.map
+++ clang/test/Modules/Inputs/module.map
@@ -483,3 +483,4 @@
   header "template-nontrivial1.h"
   export *
 }
+module error { header "error.h" }
Index: clang/test/Modules/Inputs/error.h
===
--- /dev/null
+++ clang/test/Modules/Inputs/error.h
@@ -0,0 +1,8 @@
+@import undefined
+
+@interface Error
+- (int)method;
+undefined
+@end
+
+undefined
Index: clang/lib/Frontend/FrontendActions.cpp
===
--- clang/lib/Frontend/FrontendActions.cpp
+++ clang/lib/Frontend/FrontendActions.cpp
@@ -177,7 +177,8 @@
   Consumers.push_back(std::make_unique(
   CI.getPreprocessor(), CI.getModuleCache(), OutputFile, Sysroot, Buffer,
   CI.getFrontendOpts().ModuleFileExtensions,
-  /*AllowASTWithErrors=*/false,
+  /*AllowASTWithErrors=*/
+  +CI.getFrontendOpts().AllowPCMWithCompilerErrors,
   /*IncludeTimestamps=*/
   +CI.getFrontendOpts().BuildingImplicitModule,
   /*ShouldCacheASTInMemory=*/
@@ -187,6 +188,11 @@
   return std::make_unique(std::move(Consumers));
 }
 
+bool GenerateModuleAction::shouldEraseOutputFiles() {
+  return !getCompilerInstance().getFrontendOpts().AllowPCMWithCompilerErrors &&
+ ASTFrontendAction::shouldEraseOutputFiles();
+}
+
 bool GenerateModuleFromModuleMapAction::BeginSourceFileAction(
 CompilerInstance ) {
   if (!CI.getLangOpts().Modules) {
@@ -339,7 +345,7 @@
   CI.getPCHContainerReader(), CI.getFrontendOpts().ModuleFileExtensions,
   Sysroot.empty() ? "" : Sysroot.c_str(),
   /*DisableValidation*/ false,
-  /*AllowPCHWithCompilerErrors*/ false,
+  /*AllowASTWithCompilerErrors*/ false,
   /*AllowConfigurationMismatch*/ true,
   /*ValidateSystemInputs*/ true));
 
Index: clang/lib/Frontend/CompilerInvocation.cpp
===
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -2027,6 +2027,7 @@
   

[PATCH] D91580: [Frontend] Add flag to allow PCM generation despite compiler errors

2020-11-16 Thread Ben Barham via Phabricator via cfe-commits
bnbarham created this revision.
bnbarham added a reviewer: akyrtzi.
Herald added subscribers: cfe-commits, dang, arphaman.
Herald added a project: clang.
bnbarham requested review of this revision.

As with precompiled headers, it's useful for indexers to be able to
continue through compiler errors in dependent modules.

Resolves rdar://69816264


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D91580

Files:
  clang/include/clang/Driver/Options.td
  clang/include/clang/Frontend/ASTUnit.h
  clang/include/clang/Frontend/FrontendActions.h
  clang/include/clang/Frontend/FrontendOptions.h
  clang/lib/Frontend/ASTUnit.cpp
  clang/lib/Frontend/CompilerInstance.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/lib/Frontend/FrontendActions.cpp
  clang/test/Modules/Inputs/error.h
  clang/test/Modules/Inputs/module.map
  clang/test/Modules/load-module-with-errors.m
  clang/tools/c-index-test/core_main.cpp
  clang/tools/libclang/CIndex.cpp

Index: clang/tools/libclang/CIndex.cpp
===
--- clang/tools/libclang/CIndex.cpp
+++ clang/tools/libclang/CIndex.cpp
@@ -3476,7 +3476,7 @@
   ast_filename, CXXIdx->getPCHContainerOperations()->getRawReader(),
   ASTUnit::LoadEverything, Diags, FileSystemOpts, /*UseDebugInfo=*/false,
   CXXIdx->getOnlyLocalDecls(), None, CaptureDiagsKind::All,
-  /*AllowPCHWithCompilerErrors=*/true,
+  /*AllowASTWithCompilerErrors=*/true,
   /*UserFilesAreVolatile=*/true);
   *out_TU = MakeCXTranslationUnit(CXXIdx, std::move(AU));
   return *out_TU ? CXError_Success : CXError_Failure;
Index: clang/tools/c-index-test/core_main.cpp
===
--- clang/tools/c-index-test/core_main.cpp
+++ clang/tools/c-index-test/core_main.cpp
@@ -263,7 +263,7 @@
   std::string(modulePath), *pchRdr, ASTUnit::LoadASTOnly, Diags,
   FileSystemOpts, /*UseDebugInfo=*/false,
   /*OnlyLocalDecls=*/true, None, CaptureDiagsKind::None,
-  /*AllowPCHWithCompilerErrors=*/true,
+  /*AllowASTWithCompilerErrors=*/true,
   /*UserFilesAreVolatile=*/false);
   if (!AU) {
 errs() << "failed to create TU for: " << modulePath << '\n';
Index: clang/test/Modules/load-module-with-errors.m
===
--- /dev/null
+++ clang/test/Modules/load-module-with-errors.m
@@ -0,0 +1,14 @@
+// RUN: rm -rf %t
+
+// RUN: %clang_cc1 -fmodules -fdisable-module-hash -fallow-pcm-with-compiler-errors -fmodules-cache-path=%t -emit-module -x objective-c -fmodule-name=error %S/Inputs/module.map
+// RUN: %clang_cc1 -fmodules -fdisable-module-hash -fimplicit-module-maps -fallow-pcm-with-compiler-errors -ast-print -x objective-c -fmodules-cache-path=%t -I %S/Inputs %s | FileCheck -check-prefix=CHECK-PRINT %s
+
+@import error;
+
+void test(id x) {
+  [x method];
+}
+
+// CHECK-PRINT: @interface Error
+// CHECK-PRINT-NEXT: - (int)method;
+// CHECK-PRINT: void test(id x)
Index: clang/test/Modules/Inputs/module.map
===
--- clang/test/Modules/Inputs/module.map
+++ clang/test/Modules/Inputs/module.map
@@ -483,3 +483,4 @@
   header "template-nontrivial1.h"
   export *
 }
+module error { header "error.h" }
Index: clang/test/Modules/Inputs/error.h
===
--- /dev/null
+++ clang/test/Modules/Inputs/error.h
@@ -0,0 +1,8 @@
+@import undefined
+
+@interface Error
+- (int)method;
+undefined
+@end
+
+undefined
Index: clang/lib/Frontend/FrontendActions.cpp
===
--- clang/lib/Frontend/FrontendActions.cpp
+++ clang/lib/Frontend/FrontendActions.cpp
@@ -177,7 +177,8 @@
   Consumers.push_back(std::make_unique(
   CI.getPreprocessor(), CI.getModuleCache(), OutputFile, Sysroot, Buffer,
   CI.getFrontendOpts().ModuleFileExtensions,
-  /*AllowASTWithErrors=*/false,
+  /*AllowASTWithErrors=*/
+  +CI.getFrontendOpts().AllowPCMWithCompilerErrors,
   /*IncludeTimestamps=*/
   +CI.getFrontendOpts().BuildingImplicitModule,
   /*ShouldCacheASTInMemory=*/
@@ -187,6 +188,11 @@
   return std::make_unique(std::move(Consumers));
 }
 
+bool GenerateModuleAction::shouldEraseOutputFiles() {
+  return !getCompilerInstance().getFrontendOpts().AllowPCMWithCompilerErrors &&
+ ASTFrontendAction::shouldEraseOutputFiles();
+}
+
 bool GenerateModuleFromModuleMapAction::BeginSourceFileAction(
 CompilerInstance ) {
   if (!CI.getLangOpts().Modules) {
@@ -339,7 +345,7 @@
   CI.getPCHContainerReader(), CI.getFrontendOpts().ModuleFileExtensions,
   Sysroot.empty() ? "" : Sysroot.c_str(),
   /*DisableValidation*/ false,
-  /*AllowPCHWithCompilerErrors*/ false,
+  /*AllowASTWithCompilerErrors*/ false,
   /*AllowConfigurationMismatch*/ true,
   /*ValidateSystemInputs*/ true));
 
Index: 

[PATCH] D91567: [llvm][inliner] Reuse the inliner pass to implement 'always inliner'

2020-11-16 Thread David Blaikie via Phabricator via cfe-commits
dblaikie added a comment.

> Performing the mandatory inlinings first simplifies the problem the full 
> inliner needs to solve

That confuses me a bit - is that suggesting that we don't run the AlwaysInliner 
when we are running the Inliner (ie: we only run the AlwaysInliner at -O0, and 
use the Inliner at higher optimization levels and let the Inliner do always 
inlining too)?
& sounds like this is suggesting that would change? That we would now perform 
always inlining separately from inlining? Maybe that's an orthogonal/separate 
change from one implementing the always inlining using the Inliner being run in 
a separate mode?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91567

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


[PATCH] D17993: [CodeGen] Apply 'nonnull' and 'dereferenceable(N)' to 'this' pointer arguments.

2020-11-16 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert accepted this revision.
jdoerfert added a comment.

LGTM, thx!


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

https://reviews.llvm.org/D17993

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


[PATCH] D87956: [IR] add fn attr for no_stack_protector; prevent inlining on mismatch

2020-11-16 Thread Nick Desaulniers via Phabricator via cfe-commits
nickdesaulniers added inline comments.



Comment at: llvm/test/Transforms/Inline/inline_nossp.ll:3
+; RUN: opt -passes='cgscc(inline)' %s -S | FileCheck %s
+; RUN: opt -always-inline -o - -S %s | FileCheck %s
+

aeubanks wrote:
> This test fails with the NPM,
> `opt -passes=always-inline ...`
> 
> Does `llvm::isInlineViable()` need to be updated?
Thanks for the report.  Is there a Cmake configuration I need to explicitly set 
to reproduce? `LLVM_USE_NEWPM`?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87956

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


[PATCH] D17993: [CodeGen] Apply 'nonnull' and 'dereferenceable(N)' to 'this' pointer arguments.

2020-11-16 Thread CJ Johnson via Phabricator via cfe-commits
CJ-Johnson added a comment.

In D17993#2398337 , @jdoerfert wrote:

> Please modify the commit subject and add a proper message.

Thank you for the reminder! It slipped my mind.

Fixed :)


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

https://reviews.llvm.org/D17993

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


[PATCH] D17993: [CodeGen] Apply 'nonnull' to 'this' pointer arguments.

2020-11-16 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert added a comment.

Please modify the commit subject and add a proper message.


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

https://reviews.llvm.org/D17993

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


[clang] 499bce3 - Revert "Revert "[analyzer] NFC: Separate PathDiagnosticConsumer options from AnalyzerOptions.""

2020-11-16 Thread Artem Dergachev via cfe-commits

Author: Artem Dergachev
Date: 2020-11-16T14:37:50-08:00
New Revision: 499bce3abab8a362b9b4197944bd40b826c736c4

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

LOG: Revert "Revert "[analyzer] NFC: Separate PathDiagnosticConsumer options 
from AnalyzerOptions.""

This reverts commit 10f1ca99b498347186ec74b01046ad292bde9a4c.

(cherry picked from commit c599fc738a70e482976c6cc0ea31bef561641279)

Added: 


Modified: 
clang/include/clang/Analysis/PathDiagnostic.h
clang/include/clang/StaticAnalyzer/Core/AnalyzerOptions.h
clang/include/clang/StaticAnalyzer/Core/PathDiagnosticConsumers.h
clang/lib/StaticAnalyzer/Core/HTMLDiagnostics.cpp
clang/lib/StaticAnalyzer/Core/PlistDiagnostics.cpp
clang/lib/StaticAnalyzer/Core/SarifDiagnostics.cpp
clang/lib/StaticAnalyzer/Core/TextDiagnostics.cpp
clang/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp

Removed: 




diff  --git a/clang/include/clang/Analysis/PathDiagnostic.h 
b/clang/include/clang/Analysis/PathDiagnostic.h
index c4b042a51bb5..544e9f4662d3 100644
--- a/clang/include/clang/Analysis/PathDiagnostic.h
+++ b/clang/include/clang/Analysis/PathDiagnostic.h
@@ -58,6 +58,47 @@ namespace ento {
 
 class PathDiagnostic;
 
+/// These options tweak the behavior of path diangostic consumers.
+/// Most of these options are currently supported by very few consumers.
+struct PathDiagnosticConsumerOptions {
+  /// Run-line of the tool that produced the diagnostic.
+  /// It can be included with the diagnostic for debugging purposes.
+  std::string ToolInvocation;
+
+  /// Whether to include additional information about macro expansions
+  /// with the diagnostics, because otherwise they can be hard to obtain
+  /// without re-compiling the program under analysis.
+  bool ShouldDisplayMacroExpansions;
+
+  /// Whether to include LLVM statistics of the process in the diagnostic.
+  /// Useful for profiling the tool on large real-world codebases.
+  bool ShouldSerializeStats;
+
+  /// If the consumer intends to produce multiple output files, should it
+  /// use randomly generated file names for these files (with the tiny risk of
+  /// having random collisions) or deterministic human-readable file names
+  /// (with a larger risk of deterministic collisions or invalid characters
+  /// in the file name). We should not really give this choice to the users
+  /// because deterministic mode is always superior when done right, but
+  /// for some consumers this mode is experimental and needs to be
+  /// off by default.
+  bool ShouldWriteStableReportFilename;
+
+  /// Whether the consumer should treat consumed diagnostics as hard errors.
+  /// Useful for breaking your build when issues are found.
+  bool ShouldDisplayWarningsAsErrors;
+
+  /// Whether the consumer should attempt to rewrite the source file
+  /// with fix-it hints attached to the diagnostics it consumes.
+  bool ShouldApplyFixIts;
+
+  /// Whether the consumer should present the name of the entity that emitted
+  /// the diagnostic (eg., a checker) so that the user knew how to disable it.
+  bool ShouldDisplayDiagnosticName;
+
+  PathDiagnosticConsumerOptions() = delete;
+};
+
 class PathDiagnosticConsumer {
 public:
   class PDFileEntry : public llvm::FoldingSetNode {

diff  --git a/clang/include/clang/StaticAnalyzer/Core/AnalyzerOptions.h 
b/clang/include/clang/StaticAnalyzer/Core/AnalyzerOptions.h
index 4907b0757a8a..e1093772e02c 100644
--- a/clang/include/clang/StaticAnalyzer/Core/AnalyzerOptions.h
+++ b/clang/include/clang/StaticAnalyzer/Core/AnalyzerOptions.h
@@ -14,6 +14,7 @@
 #ifndef LLVM_CLANG_STATICANALYZER_CORE_ANALYZEROPTIONS_H
 #define LLVM_CLANG_STATICANALYZER_CORE_ANALYZEROPTIONS_H
 
+#include "clang/Analysis/PathDiagnostic.h"
 #include "clang/Basic/LLVM.h"
 #include "llvm/ADT/IntrusiveRefCntPtr.h"
 #include "llvm/ADT/Optional.h"
@@ -255,7 +256,7 @@ class AnalyzerOptions : public 
RefCountedBase {
   unsigned NoRetryExhausted : 1;
 
   /// Emit analyzer warnings as errors.
-  unsigned AnalyzerWerror : 1;
+  bool AnalyzerWerror : 1;
 
   /// The inlining stack depth limit.
   // Cap the stack depth at 4 calls (5 stack frames, base + 4 calls).
@@ -390,6 +391,16 @@ class AnalyzerOptions : public 
RefCountedBase {
   ///
   /// \sa CXXMemberInliningMode
   bool mayInlineCXXMemberFunction(CXXInlineableMemberKind K) const;
+
+  ento::PathDiagnosticConsumerOptions getDiagOpts() const {
+return {FullCompilerInvocation,
+ShouldDisplayMacroExpansions,
+ShouldSerializeStats,
+ShouldWriteStableReportFilename,
+AnalyzerWerror,
+ShouldApplyFixIts,
+ShouldDisplayCheckerNameForText};
+  }
 };
 
 using AnalyzerOptionsRef = IntrusiveRefCntPtr;

diff  --git 

[PATCH] D17993: [CodeGen] Apply 'nonnull' to 'this' pointer arguments.

2020-11-16 Thread CJ Johnson via Phabricator via cfe-commits
CJ-Johnson updated this revision to Diff 305603.
Herald added a subscriber: lxfind.

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

https://reviews.llvm.org/D17993

Files:
  clang/docs/ReleaseNotes.rst
  clang/lib/CodeGen/CGCall.cpp
  clang/test/CXX/except/except.spec/p14-ir.cpp
  clang/test/CodeGen/aix-ignore-xcoff-visibility.cpp
  clang/test/CodeGen/arm64-microsoft-arguments.cpp
  clang/test/CodeGen/attr-nomerge.cpp
  clang/test/CodeGen/no-builtin.cpp
  clang/test/CodeGen/temporary-lifetime.cpp
  clang/test/CodeGenCUDA/device-var-init.cu
  clang/test/CodeGenCXX/2011-12-19-init-list-ctor.cpp
  
clang/test/CodeGenCXX/RelativeVTablesABI/child-inheritted-from-parent-in-comdat.cpp
  clang/test/CodeGenCXX/RelativeVTablesABI/child-vtable-in-comdat.cpp
  clang/test/CodeGenCXX/RelativeVTablesABI/cross-translation-unit-1.cpp
  clang/test/CodeGenCXX/RelativeVTablesABI/cross-translation-unit-2.cpp
  clang/test/CodeGenCXX/RelativeVTablesABI/diamond-virtual-inheritance.cpp
  clang/test/CodeGenCXX/RelativeVTablesABI/member-function-pointer.cpp
  clang/test/CodeGenCXX/RelativeVTablesABI/multiple-inheritance.cpp
  clang/test/CodeGenCXX/RelativeVTablesABI/parent-and-child-in-comdats.cpp
  clang/test/CodeGenCXX/RelativeVTablesABI/parent-vtable-in-comdat.cpp
  clang/test/CodeGenCXX/RelativeVTablesABI/pass-byval-attributes.cpp
  clang/test/CodeGenCXX/RelativeVTablesABI/simple-vtable-definition.cpp
  clang/test/CodeGenCXX/RelativeVTablesABI/vbase-offset.cpp
  clang/test/CodeGenCXX/RelativeVTablesABI/virtual-function-call.cpp
  clang/test/CodeGenCXX/aix-static-init-debug-info.cpp
  clang/test/CodeGenCXX/aix-static-init-temp-spec-and-inline-var.cpp
  clang/test/CodeGenCXX/aix-static-init.cpp
  clang/test/CodeGenCXX/amdgcn-automatic-variable.cpp
  clang/test/CodeGenCXX/amdgcn-func-arg.cpp
  clang/test/CodeGenCXX/apple-kext-indirect-call.cpp
  clang/test/CodeGenCXX/apple-kext-indirect-virtual-dtor-call.cpp
  clang/test/CodeGenCXX/apple-kext.cpp
  clang/test/CodeGenCXX/arm.cpp
  clang/test/CodeGenCXX/arm64-constructor-return.cpp
  clang/test/CodeGenCXX/array-default-argument.cpp
  clang/test/CodeGenCXX/atomicinit.cpp
  clang/test/CodeGenCXX/attr-disable-tail-calls.cpp
  clang/test/CodeGenCXX/attr-target-mv-member-funcs.cpp
  clang/test/CodeGenCXX/attr-target-mv-out-of-line-defs.cpp
  clang/test/CodeGenCXX/attr.cpp
  clang/test/CodeGenCXX/auto-variable-template.cpp
  clang/test/CodeGenCXX/blocks-cxx11.cpp
  clang/test/CodeGenCXX/blocks.cpp
  clang/test/CodeGenCXX/builtin-source-location.cpp
  clang/test/CodeGenCXX/builtin_LINE.cpp
  clang/test/CodeGenCXX/catch-undef-behavior.cpp
  clang/test/CodeGenCXX/cfi-cross-dso.cpp
  clang/test/CodeGenCXX/conditional-gnu-ext.cpp
  clang/test/CodeGenCXX/const-init-cxx11.cpp
  clang/test/CodeGenCXX/constructor-destructor-return-this.cpp
  clang/test/CodeGenCXX/constructor-direct-call.cpp
  clang/test/CodeGenCXX/constructor-init.cpp
  clang/test/CodeGenCXX/constructors.cpp
  clang/test/CodeGenCXX/copy-constructor-elim-2.cpp
  clang/test/CodeGenCXX/copy-constructor-synthesis.cpp
  clang/test/CodeGenCXX/cxx0x-delegating-ctors.cpp
  clang/test/CodeGenCXX/cxx0x-initializer-constructors.cpp
  clang/test/CodeGenCXX/cxx0x-initializer-stdinitializerlist.cpp
  clang/test/CodeGenCXX/cxx11-initializer-aggregate.cpp
  clang/test/CodeGenCXX/cxx11-initializer-array-new.cpp
  clang/test/CodeGenCXX/cxx11-thread-local.cpp
  clang/test/CodeGenCXX/cxx1y-init-captures.cpp
  clang/test/CodeGenCXX/cxx1y-sized-deallocation.cpp
  clang/test/CodeGenCXX/cxx1z-copy-omission.cpp
  clang/test/CodeGenCXX/cxx1z-decomposition.cpp
  clang/test/CodeGenCXX/cxx1z-initializer-aggregate.cpp
  clang/test/CodeGenCXX/cxx1z-lambda-star-this.cpp
  clang/test/CodeGenCXX/cxx2a-destroying-delete.cpp
  clang/test/CodeGenCXX/debug-info-class.cpp
  clang/test/CodeGenCXX/debug-info-destroy-helper.cpp
  clang/test/CodeGenCXX/debug-info-ms-dtor-thunks.cpp
  clang/test/CodeGenCXX/default-arg-temps.cpp
  clang/test/CodeGenCXX/default-arguments.cpp
  clang/test/CodeGenCXX/delete.cpp
  clang/test/CodeGenCXX/derived-to-base-conv.cpp
  clang/test/CodeGenCXX/destructors.cpp
  clang/test/CodeGenCXX/devirtualize-virtual-function-calls-final.cpp
  clang/test/CodeGenCXX/devirtualize-virtual-function-calls.cpp
  clang/test/CodeGenCXX/dllexport-ctor-closure.cpp
  clang/test/CodeGenCXX/dllexport-members.cpp
  clang/test/CodeGenCXX/dllexport.cpp
  clang/test/CodeGenCXX/dllimport-dtor-thunks.cpp
  clang/test/CodeGenCXX/dllimport-members.cpp
  clang/test/CodeGenCXX/dllimport.cpp
  clang/test/CodeGenCXX/duplicate-mangled-name.cpp
  clang/test/CodeGenCXX/eh.cpp
  clang/test/CodeGenCXX/empty-nontrivially-copyable.cpp
  clang/test/CodeGenCXX/exceptions-seh-filter-captures.cpp
  clang/test/CodeGenCXX/exceptions-seh.cpp
  clang/test/CodeGenCXX/exceptions.cpp
  clang/test/CodeGenCXX/ext-int.cpp
  clang/test/CodeGenCXX/float128-declarations.cpp
  clang/test/CodeGenCXX/float16-declarations.cpp
  clang/test/CodeGenCXX/global-dtor-no-atexit.cpp
  

[PATCH] D91567: [llvm][inliner] Reuse the inliner pass to implement 'always inliner'

2020-11-16 Thread Mircea Trofin via Phabricator via cfe-commits
mtrofin added a comment.

Please note: the patch isn't 100% ready, there are those tests that check how 
the pipeline is composed, which are unpleasant to fix, so I want to defer them 
to after we get agreement over the larger points this patch brings (i.e. 
pre-performing always inlinings, value in further exploring cleanups before 
full inlining, etc)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91567

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


[PATCH] D91567: [llvm][inliner] Reuse the inliner pass to implement 'always inliner'

2020-11-16 Thread Mircea Trofin via Phabricator via cfe-commits
mtrofin created this revision.
mtrofin added reviewers: aeubanks, jdoerfert, davidxl, eraman.
Herald added subscribers: llvm-commits, cfe-commits, hiraditya.
Herald added projects: clang, LLVM.
mtrofin requested review of this revision.

Enable performing mandatory inlinings upfront, by reusing the same logic
as the full inliner, instead of the AlwaysInliner. This has the
following benefits:

- reduce code duplication - one inliner codebase
- open the opportunity to help the full inliner by performing additional

function passes after the mandatory inlinings, but before th full
inliner. Performing the mandatory inlinings first simplifies the problem
the full inliner needs to solve: less call sites, more contextualization, and,
depending on the additional function optimization passes run between the
2 inliners, higher accuracy of cost models / decision policies.

Note that this patch does not yet enable much in terms of post-always
inline function optimization.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D91567

Files:
  clang/test/Frontend/optimization-remark-line-directive.c
  llvm/include/llvm/Analysis/InlineAdvisor.h
  llvm/include/llvm/Passes/PassBuilder.h
  llvm/lib/Analysis/InlineAdvisor.cpp
  llvm/lib/Analysis/MLInlineAdvisor.cpp
  llvm/lib/Passes/PassBuilder.cpp
  llvm/lib/Passes/PassRegistry.def
  llvm/lib/Transforms/IPO/Inliner.cpp
  llvm/test/Transforms/Inline/ML/bounds-checks-rewards.ll
  llvm/test/Transforms/Inline/ML/bounds-checks.ll
  llvm/test/Transforms/Inline/inline_stats.ll

Index: llvm/test/Transforms/Inline/inline_stats.ll
===
--- llvm/test/Transforms/Inline/inline_stats.ll
+++ llvm/test/Transforms/Inline/inline_stats.ll
@@ -6,8 +6,11 @@
 ; RUN: opt -S -passes=inline -inliner-function-import-stats=basic < %s 2>&1 | FileCheck %s -check-prefix=CHECK-BASIC -check-prefix=CHECK
 ; RUN: opt -S -passes=inline -inliner-function-import-stats=verbose < %s 2>&1 | FileCheck %s -check-prefix="CHECK-VERBOSE" -check-prefix=CHECK
 
-; RUN: opt -S -passes=inliner-wrapper -inliner-function-import-stats=basic < %s 2>&1 | FileCheck %s -check-prefix=WRAPPER-BASIC -check-prefix=WRAPPER
-; RUN: opt -S -passes=inliner-wrapper -inliner-function-import-stats=verbose < %s 2>&1 | FileCheck %s -check-prefix=WRAPPER-VERBOSE -check-prefix=WRAPPER
+; RUN: opt -S -passes=inliner-wrapper -inliner-function-import-stats=basic < %s 2>&1 | FileCheck %s -check-prefix=CHECK-BASIC -check-prefix=CHECK
+; RUN: opt -S -passes=inliner-wrapper -inliner-function-import-stats=verbose < %s 2>&1 | FileCheck %s -check-prefix="CHECK-VERBOSE" -check-prefix=CHECK
+
+; RUN: opt -S -passes=always-inliner-wrapper,inliner-wrapper -inliner-function-import-stats=basic < %s 2>&1 | FileCheck %s -check-prefix=WRAPPER-BASIC -check-prefix=WRAPPER
+; RUN: opt -S -passes=always-inliner-wrapper,inliner-wrapper -inliner-function-import-stats=verbose < %s 2>&1 | FileCheck %s -check-prefix=WRAPPER-VERBOSE -check-prefix=WRAPPER
 
 ; CHECK: --- Dumping inliner stats for [] ---
 ; CHECK-BASIC-NOT: -- List of inlined functions:
Index: llvm/test/Transforms/Inline/ML/bounds-checks.ll
===
--- llvm/test/Transforms/Inline/ML/bounds-checks.ll
+++ llvm/test/Transforms/Inline/ML/bounds-checks.ll
@@ -4,7 +4,7 @@
 ; factor, we don't inline anymore.
 ; REQUIRES: have_tf_aot
 ; RUN: opt -passes=scc-oz-module-inliner -enable-ml-inliner=release -ml-advisor-size-increase-threshold=10.0 -S < %s 2>&1 | FileCheck %s --check-prefix=CHECK --check-prefix=NOBOUNDS
-; RUN: opt -passes=scc-oz-module-inliner -enable-ml-inliner=release -ml-advisor-size-increase-threshold=1.0 -disable-always-inliner-in-module-wrapper -S < %s 2>&1 | FileCheck %s --check-prefix=CHECK --check-prefix=BOUNDS
+; RUN: opt -passes=scc-oz-module-inliner -enable-ml-inliner=release -ml-advisor-size-increase-threshold=1.0 -S < %s 2>&1 | FileCheck %s --check-prefix=CHECK --check-prefix=BOUNDS
 
 target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
 target triple = "x86_64-grtev4-linux-gnu"
Index: llvm/test/Transforms/Inline/ML/bounds-checks-rewards.ll
===
--- llvm/test/Transforms/Inline/ML/bounds-checks-rewards.ll
+++ llvm/test/Transforms/Inline/ML/bounds-checks-rewards.ll
@@ -7,18 +7,18 @@
 ; REQUIRES: have_tf_api
 ;
 ; When the bounds are very wide ("no bounds"), all inlinings happen.
-; RUN: opt -passes=scc-oz-module-inliner -ml-inliner-ir2native-model=%S/../../../../unittests/Analysis/Inputs/ir2native_x86_64_model -ml-inliner-model-under-training=%S/../../../../lib/Analysis/models/inliner -training-log=- -enable-ml-inliner=development -ml-advisor-size-increase-threshold=10.0 -disable-always-inliner-in-module-wrapper -S < %s 2>&1 | FileCheck %s --check-prefix=CHECK --check-prefix=NOBOUNDS
+; RUN: opt -passes=scc-oz-module-inliner 

[PATCH] D91121: [InferAddrSpace] Teach to handle assumed address space.

2020-11-16 Thread Michael Liao via Phabricator via cfe-commits
hliao added inline comments.



Comment at: llvm/lib/Transforms/Scalar/InferAddressSpaces.cpp:483
+// Skip values with an assumed address space.
+if (TTI->getAssumedAddrSpace(TopVal) == UninitializedAddressSpace) {
+  for (Value *PtrOperand : getPointerOperands(*TopVal, *DL, TTI)) {

arsenm wrote:
> Checking this here looks strange, since it is also catching values that 
> weren't processed as assumed address space
It stops tracking through instructions generating pointers with assumed AS. 
It's not necessary to check their operands as the result is assumed. For 
instructions without assumed AS results, we need to track them through their 
operands.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91121

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


[PATCH] D91311: Add new 'preferred_name' attribute.

2020-11-16 Thread Louis Dionne via Phabricator via cfe-commits
ldionne added a comment.

What the attribute achieves is great, however I must say I'm really with 
Arthur's original comment regarding the ergonomics of it.

IMO, it makes a lot more sense to permit the typedef author to pick how their 
typedef is going to be "named" by the compiler. If they pick something crazy or 
misleading, it's really their problem.

I think that the fact we need to re declare everything shows how the ergonomics 
would be better if we could just add the attribute to the typedef. See for 
example how we're re-declaring a bunch of stuff in ``. How bad of an 
idea is it to try putting the attribute on typedefs instead, and how strongly 
are you opposed to it? Because from a naive user perspective, having to 
redeclare the class with a closed set of preferred names feels awkward (IMO, of 
course).




Comment at: libcxx/include/__config:1343
+#if __has_attribute(__preferred_name__)
+#define _LIBCPP_PREFERRED_NAME(x) __attribute__((__preferred_name__(x)))
+#else

Can you please indent inside the `#if`?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91311

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


[clang-tools-extra] ace9653 - [clang-tidy] performance-unnecessary-copy-initialization: Check for const reference arguments that are replaced template parameter type.

2020-11-16 Thread Felix Berger via cfe-commits

Author: Felix Berger
Date: 2020-11-16T17:08:18-05:00
New Revision: ace9653c11c6308401dcda2e8b26bf97e6e66e30

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

LOG: [clang-tidy] performance-unnecessary-copy-initialization: Check for const 
reference arguments that are replaced template parameter type.

This fixes false positive cases where a non-const reference is passed to a
std::function but interpreted as a const reference.

Fix the definition of the fake std::function added in the test to match
std::function and make the bug reproducible.

Reviewed-by: aaron.ballman

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

Added: 


Modified: 
clang-tools-extra/clang-tidy/utils/DeclRefExprUtils.cpp

clang-tools-extra/test/clang-tidy/checkers/performance-unnecessary-copy-initialization.cpp

Removed: 




diff  --git a/clang-tools-extra/clang-tidy/utils/DeclRefExprUtils.cpp 
b/clang-tools-extra/clang-tidy/utils/DeclRefExprUtils.cpp
index c4bc1835057b..d0933f0860c8 100644
--- a/clang-tools-extra/clang-tidy/utils/DeclRefExprUtils.cpp
+++ b/clang-tools-extra/clang-tidy/utils/DeclRefExprUtils.cpp
@@ -59,9 +59,13 @@ constReferenceDeclRefExprs(const VarDecl , const 
Stmt ,
   extractNodesByIdTo(Matches, "declRef", DeclRefs);
   auto ConstReferenceOrValue =
   qualType(anyOf(referenceType(pointee(qualType(isConstQualified(,
- unless(anyOf(referenceType(), pointerType();
+ unless(anyOf(referenceType(), pointerType(),
+  substTemplateTypeParmType();
+  auto ConstReferenceOrValueOrReplaced = qualType(anyOf(
+  ConstReferenceOrValue,
+  substTemplateTypeParmType(hasReplacementType(ConstReferenceOrValue;
   auto UsedAsConstRefOrValueArg = forEachArgumentWithParam(
-  DeclRefToVar, parmVarDecl(hasType(ConstReferenceOrValue)));
+  DeclRefToVar, parmVarDecl(hasType(ConstReferenceOrValueOrReplaced)));
   Matches = match(findAll(callExpr(UsedAsConstRefOrValueArg)), Stmt, Context);
   extractNodesByIdTo(Matches, "declRef", DeclRefs);
   Matches =

diff  --git 
a/clang-tools-extra/test/clang-tidy/checkers/performance-unnecessary-copy-initialization.cpp
 
b/clang-tools-extra/test/clang-tidy/checkers/performance-unnecessary-copy-initialization.cpp
index 9055529c7a3f..120902d0eade 100644
--- 
a/clang-tools-extra/test/clang-tidy/checkers/performance-unnecessary-copy-initialization.cpp
+++ 
b/clang-tools-extra/test/clang-tidy/checkers/performance-unnecessary-copy-initialization.cpp
@@ -411,12 +411,12 @@ inline namespace __1 {
 
 template 
 class function;
-template 
-class function {
+template 
+class function {
 public:
   function();
-  function(const function );
-  R operator()(Args &&...args) const;
+  function(const function );
+  R operator()(ArgTypes... Args) const;
 };
 
 } // namespace __1
@@ -460,3 +460,19 @@ void positiveFakeStdFunction(std::function F) {
 }
 
 } // namespace fake
+
+void positiveInvokedOnStdFunction(
+std::function Update,
+const ExpensiveToCopyType Orig) {
+  auto Copy = Orig.reference();
+  // CHECK-MESSAGES: [[@LINE-1]]:8: warning: the variable 'Copy' is 
copy-constructed from a const reference
+  // CHECK-FIXES: const auto& Copy = Orig.reference();
+  Update(Copy);
+}
+
+void negativeInvokedOnStdFunction(
+std::function Update,
+const ExpensiveToCopyType Orig) {
+  auto Copy = Orig.reference();
+  Update(Copy);
+}



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


[PATCH] D90042: [clang-tidy] performance-unnecessary-copy-initialization: Check for const reference arguments that are replaced template parameter type.

2020-11-16 Thread Felix Berger via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGace9653c11c6: [clang-tidy] 
performance-unnecessary-copy-initialization: Check for constā€¦ (authored by flx).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D90042

Files:
  clang-tools-extra/clang-tidy/utils/DeclRefExprUtils.cpp
  
clang-tools-extra/test/clang-tidy/checkers/performance-unnecessary-copy-initialization.cpp


Index: 
clang-tools-extra/test/clang-tidy/checkers/performance-unnecessary-copy-initialization.cpp
===
--- 
clang-tools-extra/test/clang-tidy/checkers/performance-unnecessary-copy-initialization.cpp
+++ 
clang-tools-extra/test/clang-tidy/checkers/performance-unnecessary-copy-initialization.cpp
@@ -411,12 +411,12 @@
 
 template 
 class function;
-template 
-class function {
+template 
+class function {
 public:
   function();
-  function(const function );
-  R operator()(Args &&...args) const;
+  function(const function );
+  R operator()(ArgTypes... Args) const;
 };
 
 } // namespace __1
@@ -460,3 +460,19 @@
 }
 
 } // namespace fake
+
+void positiveInvokedOnStdFunction(
+std::function Update,
+const ExpensiveToCopyType Orig) {
+  auto Copy = Orig.reference();
+  // CHECK-MESSAGES: [[@LINE-1]]:8: warning: the variable 'Copy' is 
copy-constructed from a const reference
+  // CHECK-FIXES: const auto& Copy = Orig.reference();
+  Update(Copy);
+}
+
+void negativeInvokedOnStdFunction(
+std::function Update,
+const ExpensiveToCopyType Orig) {
+  auto Copy = Orig.reference();
+  Update(Copy);
+}
Index: clang-tools-extra/clang-tidy/utils/DeclRefExprUtils.cpp
===
--- clang-tools-extra/clang-tidy/utils/DeclRefExprUtils.cpp
+++ clang-tools-extra/clang-tidy/utils/DeclRefExprUtils.cpp
@@ -59,9 +59,13 @@
   extractNodesByIdTo(Matches, "declRef", DeclRefs);
   auto ConstReferenceOrValue =
   qualType(anyOf(referenceType(pointee(qualType(isConstQualified(,
- unless(anyOf(referenceType(), pointerType();
+ unless(anyOf(referenceType(), pointerType(),
+  substTemplateTypeParmType();
+  auto ConstReferenceOrValueOrReplaced = qualType(anyOf(
+  ConstReferenceOrValue,
+  substTemplateTypeParmType(hasReplacementType(ConstReferenceOrValue;
   auto UsedAsConstRefOrValueArg = forEachArgumentWithParam(
-  DeclRefToVar, parmVarDecl(hasType(ConstReferenceOrValue)));
+  DeclRefToVar, parmVarDecl(hasType(ConstReferenceOrValueOrReplaced)));
   Matches = match(findAll(callExpr(UsedAsConstRefOrValueArg)), Stmt, Context);
   extractNodesByIdTo(Matches, "declRef", DeclRefs);
   Matches =


Index: clang-tools-extra/test/clang-tidy/checkers/performance-unnecessary-copy-initialization.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/performance-unnecessary-copy-initialization.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/performance-unnecessary-copy-initialization.cpp
@@ -411,12 +411,12 @@
 
 template 
 class function;
-template 
-class function {
+template 
+class function {
 public:
   function();
-  function(const function );
-  R operator()(Args &&...args) const;
+  function(const function );
+  R operator()(ArgTypes... Args) const;
 };
 
 } // namespace __1
@@ -460,3 +460,19 @@
 }
 
 } // namespace fake
+
+void positiveInvokedOnStdFunction(
+std::function Update,
+const ExpensiveToCopyType Orig) {
+  auto Copy = Orig.reference();
+  // CHECK-MESSAGES: [[@LINE-1]]:8: warning: the variable 'Copy' is copy-constructed from a const reference
+  // CHECK-FIXES: const auto& Copy = Orig.reference();
+  Update(Copy);
+}
+
+void negativeInvokedOnStdFunction(
+std::function Update,
+const ExpensiveToCopyType Orig) {
+  auto Copy = Orig.reference();
+  Update(Copy);
+}
Index: clang-tools-extra/clang-tidy/utils/DeclRefExprUtils.cpp
===
--- clang-tools-extra/clang-tidy/utils/DeclRefExprUtils.cpp
+++ clang-tools-extra/clang-tidy/utils/DeclRefExprUtils.cpp
@@ -59,9 +59,13 @@
   extractNodesByIdTo(Matches, "declRef", DeclRefs);
   auto ConstReferenceOrValue =
   qualType(anyOf(referenceType(pointee(qualType(isConstQualified(,
- unless(anyOf(referenceType(), pointerType();
+ unless(anyOf(referenceType(), pointerType(),
+  substTemplateTypeParmType();
+  auto ConstReferenceOrValueOrReplaced = qualType(anyOf(
+  ConstReferenceOrValue,
+  substTemplateTypeParmType(hasReplacementType(ConstReferenceOrValue;
   auto UsedAsConstRefOrValueArg = forEachArgumentWithParam(
-  DeclRefToVar, parmVarDecl(hasType(ConstReferenceOrValue)));
+  DeclRefToVar, 

[PATCH] D91121: [InferAddrSpace] Teach to handle assumed address space.

2020-11-16 Thread Michael Liao 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 rGf375885ab86d: [InferAddrSpace] Teach to handle assumed 
address space. (authored by hliao).

Changed prior to commit:
  https://reviews.llvm.org/D91121?vs=305250=305592#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91121

Files:
  clang/test/CodeGenCUDA/amdgpu-kernel-arg-pointer-type.cu
  llvm/docs/AMDGPUUsage.rst
  llvm/include/llvm/Analysis/TargetTransformInfo.h
  llvm/include/llvm/Analysis/TargetTransformInfoImpl.h
  llvm/include/llvm/CodeGen/BasicTTIImpl.h
  llvm/include/llvm/Target/TargetMachine.h
  llvm/lib/Analysis/TargetTransformInfo.cpp
  llvm/lib/Target/AMDGPU/AMDGPUTargetMachine.cpp
  llvm/lib/Target/AMDGPU/AMDGPUTargetMachine.h
  llvm/lib/Transforms/Scalar/InferAddressSpaces.cpp
  llvm/test/CodeGen/AMDGPU/GlobalISel/divergent-control-flow.ll
  llvm/test/Transforms/InferAddressSpaces/AMDGPU/assumed-addrspace.ll

Index: llvm/test/Transforms/InferAddressSpaces/AMDGPU/assumed-addrspace.ll
===
--- /dev/null
+++ llvm/test/Transforms/InferAddressSpaces/AMDGPU/assumed-addrspace.ll
@@ -0,0 +1,31 @@
+; RUN: opt -S -mtriple=amdgcn-amd-amdhsa -infer-address-spaces -o - %s | FileCheck %s
+
+@c0 = addrspace(4) global float* undef
+
+; CHECK-LABEL: @generic_ptr_from_constant
+; CHECK: addrspacecast float* %p to float addrspace(1)*
+; CHECK-NEXT: load float, float addrspace(1)*
+define float @generic_ptr_from_constant() {
+  %p = load float*, float* addrspace(4)* @c0
+  %v = load float, float* %p
+  ret float %v
+}
+
+%struct.S = type { i32*, float* }
+
+; CHECK-LABEL: @generic_ptr_from_aggregate_argument
+; CHECK: addrspacecast i32* %p0 to i32 addrspace(1)*
+; CHECK: addrspacecast float* %p1 to float addrspace(1)*
+; CHECK: load i32, i32 addrspace(1)*
+; CHECK: store float %v1, float addrspace(1)*
+; CHECK: ret
+define amdgpu_kernel void @generic_ptr_from_aggregate_argument(%struct.S addrspace(4)* byref(%struct.S) align 8 %0) {
+  %f0 = getelementptr inbounds %struct.S, %struct.S addrspace(4)* %0, i64 0, i32 0
+  %p0 = load i32*, i32* addrspace(4)* %f0
+  %f1 = getelementptr inbounds %struct.S, %struct.S addrspace(4)* %0, i64 0, i32 1
+  %p1 = load float*, float* addrspace(4)* %f1
+  %v0 = load i32, i32* %p0
+  %v1 = sitofp i32 %v0 to float
+  store float %v1, float* %p1
+  ret void
+}
Index: llvm/test/CodeGen/AMDGPU/GlobalISel/divergent-control-flow.ll
===
--- llvm/test/CodeGen/AMDGPU/GlobalISel/divergent-control-flow.ll
+++ llvm/test/CodeGen/AMDGPU/GlobalISel/divergent-control-flow.ll
@@ -138,35 +138,34 @@
 ; CHECK-NEXT:s_cselect_b32 s4, 1, 0
 ; CHECK-NEXT:s_and_b32 s4, s4, 1
 ; CHECK-NEXT:s_cmp_lg_u32 s4, 0
-; CHECK-NEXT:s_cbranch_scc1 BB4_6
+; CHECK-NEXT:s_cbranch_scc1 BB4_4
 ; CHECK-NEXT:  ; %bb.1: ; %bb2
 ; CHECK-NEXT:s_getpc_b64 s[6:7]
 ; CHECK-NEXT:s_add_u32 s6, s6, const.ptr@gotpcrel32@lo+4
 ; CHECK-NEXT:s_addc_u32 s7, s7, const.ptr@gotpcrel32@hi+12
 ; CHECK-NEXT:s_load_dwordx2 s[6:7], s[6:7], 0x0
+; CHECK-NEXT:v_mov_b32_e32 v0, 0
 ; CHECK-NEXT:s_mov_b32 s4, -1
 ; CHECK-NEXT:s_waitcnt lgkmcnt(0)
 ; CHECK-NEXT:s_load_dwordx2 s[6:7], s[6:7], 0x0
 ; CHECK-NEXT:s_waitcnt lgkmcnt(0)
-; CHECK-NEXT:v_mov_b32_e32 v0, s6
-; CHECK-NEXT:v_mov_b32_e32 v1, s7
-; CHECK-NEXT:flat_load_dword v0, v[0:1]
-; CHECK-NEXT:s_waitcnt vmcnt(0) lgkmcnt(0)
-; CHECK-NEXT:v_cmp_ngt_f32_e32 vcc, 1.0, v0
-; CHECK-NEXT:s_and_saveexec_b64 s[6:7], vcc
+; CHECK-NEXT:global_load_dword v0, v0, s[6:7]
+; CHECK-NEXT:s_waitcnt vmcnt(0)
+; CHECK-NEXT:v_cmp_gt_f32_e32 vcc, 1.0, v0
+; CHECK-NEXT:s_cbranch_vccnz BB4_3
 ; CHECK-NEXT:  ; %bb.2: ; %bb7
 ; CHECK-NEXT:s_mov_b32 s4, 0
-; CHECK-NEXT:  ; %bb.3: ; %bb8
-; CHECK-NEXT:s_or_b64 exec, exec, s[6:7]
-; CHECK-NEXT:v_cmp_eq_u32_e64 s[6:7], s4, 0
-; CHECK-NEXT:s_and_saveexec_b64 s[4:5], s[6:7]
-; CHECK-NEXT:s_cbranch_execz BB4_5
-; CHECK-NEXT:  ; %bb.4: ; %bb11
+; CHECK-NEXT:  BB4_3: ; %bb8
+; CHECK-NEXT:s_cmp_lg_u32 s4, 0
+; CHECK-NEXT:s_cselect_b32 s4, 1, 0
+; CHECK-NEXT:s_and_b32 s4, s4, 1
+; CHECK-NEXT:s_cmp_lg_u32 s4, 0
+; CHECK-NEXT:s_cbranch_scc0 BB4_5
+; CHECK-NEXT:  BB4_4: ; %bb12
+; CHECK-NEXT:s_setpc_b64 s[30:31]
+; CHECK-NEXT:  BB4_5: ; %bb11
 ; CHECK-NEXT:v_mov_b32_e32 v0, 4.0
 ; CHECK-NEXT:buffer_store_dword v0, v0, s[0:3], 0 offen
-; CHECK-NEXT:  BB4_5: ; %Flow
-; CHECK-NEXT:s_or_b64 exec, exec, s[4:5]
-; CHECK-NEXT:  BB4_6: ; %bb12
 ; CHECK-NEXT:s_waitcnt vmcnt(0)
 ; CHECK-NEXT:s_setpc_b64 s[30:31]
 bb:
Index: llvm/lib/Transforms/Scalar/InferAddressSpaces.cpp
===
--- 

[clang] f375885 - [InferAddrSpace] Teach to handle assumed address space.

2020-11-16 Thread Michael Liao via cfe-commits

Author: Michael Liao
Date: 2020-11-16T17:06:33-05:00
New Revision: f375885ab86d1b3e82269725c8e9aa49f347b4a7

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

LOG: [InferAddrSpace] Teach to handle assumed address space.

- In certain cases, a generic pointer could be assumed as a pointer to
  the global memory space or other spaces. With a dedicated target hook
  to query that address space from a given value, infer-address-space
  pass could infer and propagate that to all its users.

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

Added: 
llvm/test/Transforms/InferAddressSpaces/AMDGPU/assumed-addrspace.ll

Modified: 
clang/test/CodeGenCUDA/amdgpu-kernel-arg-pointer-type.cu
llvm/docs/AMDGPUUsage.rst
llvm/include/llvm/Analysis/TargetTransformInfo.h
llvm/include/llvm/Analysis/TargetTransformInfoImpl.h
llvm/include/llvm/CodeGen/BasicTTIImpl.h
llvm/include/llvm/Target/TargetMachine.h
llvm/lib/Analysis/TargetTransformInfo.cpp
llvm/lib/Target/AMDGPU/AMDGPUTargetMachine.cpp
llvm/lib/Target/AMDGPU/AMDGPUTargetMachine.h
llvm/lib/Transforms/Scalar/InferAddressSpaces.cpp
llvm/test/CodeGen/AMDGPU/GlobalISel/divergent-control-flow.ll

Removed: 




diff  --git a/clang/test/CodeGenCUDA/amdgpu-kernel-arg-pointer-type.cu 
b/clang/test/CodeGenCUDA/amdgpu-kernel-arg-pointer-type.cu
index dc4659856026..da1f4b65f719 100644
--- a/clang/test/CodeGenCUDA/amdgpu-kernel-arg-pointer-type.cu
+++ b/clang/test/CodeGenCUDA/amdgpu-kernel-arg-pointer-type.cu
@@ -56,20 +56,24 @@ struct S {
   int *x;
   float *y;
 };
-// `by-val` struct will be coerced into a similar struct with all generic
-// pointers lowerd into global ones.
+// `by-val` struct is passed by-indirect-alias (a mix of by-ref and indirect
+// by-val). However, the enhanced address inferring pass should be able to
+// assume they are global pointers.
+//
 // HOST: define void @_Z22__device_stub__kernel41S(i32* %s.coerce0, float* 
%s.coerce1)
 // COMMON-LABEL: define amdgpu_kernel void @_Z7kernel41S(%struct.S 
addrspace(4)*{{.*}} byref(%struct.S) align 8 %0)
 // OPT: [[R0:%.*]] = getelementptr inbounds %struct.S, %struct.S addrspace(4)* 
%0, i64 0, i32 0
 // OPT: [[P0:%.*]] = load i32*, i32* addrspace(4)* [[R0]], align 8
+// OPT: [[G0:%.*]] = addrspacecast i32* [[P0]] to i32 addrspace(1)*
 // OPT: [[R1:%.*]] = getelementptr inbounds %struct.S, %struct.S addrspace(4)* 
%0, i64 0, i32 1
 // OPT: [[P1:%.*]] = load float*, float* addrspace(4)* [[R1]], align 8
-// OPT: [[V0:%.*]] = load i32, i32* [[P0]], align 4
+// OPT: [[G1:%.*]] = addrspacecast float* [[P1]] to float addrspace(1)*
+// OPT: [[V0:%.*]] = load i32, i32 addrspace(1)* [[G0]], align 4
 // OPT: [[INC:%.*]] = add nsw i32 [[V0]], 1
-// OPT: store i32 [[INC]], i32* [[P0]], align 4
-// OPT: [[V1:%.*]] = load float, float* [[P1]], align 4
+// OPT: store i32 [[INC]], i32 addrspace(1)* [[G0]], align 4
+// OPT: [[V1:%.*]] = load float, float addrspace(1)* [[G1]], align 4
 // OPT: [[ADD:%.*]] = fadd contract float [[V1]], 1.00e+00
-// OPT: store float [[ADD]], float* [[P1]], align 4
+// OPT: store float [[ADD]], float addrspace(1)* [[G1]], align 4
 // OPT: ret void
 __global__ void kernel4(struct S s) {
   s.x[0]++;
@@ -87,19 +91,24 @@ __global__ void kernel5(struct S *s) {
 struct T {
   float *x[2];
 };
-// `by-val` array is also coerced.
+// `by-val` array is passed by-indirect-alias (a mix of by-ref and indirect
+// by-val). However, the enhanced address inferring pass should be able to
+// assume they are global pointers.
+//
 // HOST: define void @_Z22__device_stub__kernel61T(float* %t.coerce0, float* 
%t.coerce1)
 // COMMON-LABEL: define amdgpu_kernel void @_Z7kernel61T(%struct.T 
addrspace(4)*{{.*}} byref(%struct.T) align 8 %0)
 // OPT: [[R0:%.*]] = getelementptr inbounds %struct.T, %struct.T addrspace(4)* 
%0, i64 0, i32 0, i64 0
 // OPT: [[P0:%.*]] = load float*, float* addrspace(4)* [[R0]], align 8
+// OPT: [[G0:%.*]] = addrspacecast float* [[P0]] to float addrspace(1)*
 // OPT: [[R1:%.*]] = getelementptr inbounds %struct.T, %struct.T addrspace(4)* 
%0, i64 0, i32 0, i64 1
 // OPT: [[P1:%.*]] = load float*, float* addrspace(4)* [[R1]], align 8
-// OPT: [[V0:%.*]] = load float, float* [[P0]], align 4
+// OPT: [[G1:%.*]] = addrspacecast float* [[P1]] to float addrspace(1)*
+// OPT: [[V0:%.*]] = load float, float addrspace(1)* [[G0]], align 4
 // OPT: [[ADD0:%.*]] = fadd contract float [[V0]], 1.00e+00
-// OPT: store float [[ADD0]], float* [[P0]], align 4
-// OPT: [[V1:%.*]] = load float, float* [[P1]], align 4
+// OPT: store float [[ADD0]], float addrspace(1)* [[G0]], align 4
+// OPT: [[V1:%.*]] = load float, float addrspace(1)* [[G1]], align 4
 // OPT: [[ADD1:%.*]] = fadd contract float [[V1]], 2.00e+00
-// OPT: store float 

[PATCH] D91121: [InferAddrSpace] Teach to handle assumed address space.

2020-11-16 Thread Matt Arsenault via Phabricator via cfe-commits
arsenm added inline comments.



Comment at: llvm/lib/Transforms/Scalar/InferAddressSpaces.cpp:483
+// Skip values with an assumed address space.
+if (TTI->getAssumedAddrSpace(TopVal) == UninitializedAddressSpace) {
+  for (Value *PtrOperand : getPointerOperands(*TopVal, *DL, TTI)) {

Checking this here looks strange, since it is also catching values that weren't 
processed as assumed address space


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91121

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


[PATCH] D91121: [InferAddrSpace] Teach to handle assumed address space.

2020-11-16 Thread Matt Arsenault via Phabricator via cfe-commits
arsenm accepted this revision.
arsenm added a comment.
This revision is now accepted and ready to land.

LGTM with nits




Comment at: llvm/lib/Target/AMDGPU/AMDGPUTargetMachine.cpp:533
+  if (!LD)
+return -1;
+

hliao wrote:
> tra wrote:
> > Is there a suitable constant for `don't know` result?
> I would say all generic pointers loaded from the constant memory are safe to 
> be assumed as global ones (for AMDGPU). I explained the reason in the usage 
> document. The constant memory could be modified by the host, where only 
> global memory objects are visible.
AMDGPUAS::UNKNOWN_ADDRESS_SPACE



Comment at: llvm/lib/Target/AMDGPU/AMDGPUTargetMachine.cpp:540
+  const auto *Ptr = LD->getPointerOperand();
+  if (Ptr->getType()->getPointerAddressSpace() != AMDGPUAS::CONSTANT_ADDRESS)
+return -1;

This could be a bit broader but is fine for now



Comment at: llvm/lib/Target/AMDGPU/AMDGPUTargetMachine.cpp:541
+  if (Ptr->getType()->getPointerAddressSpace() != AMDGPUAS::CONSTANT_ADDRESS)
+return -1;
+  // For a generic pointer loaded from the constant memory, it could be assumed

Ditto


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91121

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


[PATCH] D67112: [Sema] Introduce function reference conversion, NFC

2020-11-16 Thread Aaron Puchert via Phabricator via cfe-commits
aaronpuchert added a comment.

Ping.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D67112

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


[PATCH] D90042: [clang-tidy] performance-unnecessary-copy-initialization: Check for const reference arguments that are replaced template parameter type.

2020-11-16 Thread Felix Berger via Phabricator via cfe-commits
flx added a comment.

In D90042#2397885 , @aaron.ballman 
wrote:

> LGTM, thank you for the fix!

Thanks for helping track down the difference in our definition of std::function 
:)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D90042

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


[PATCH] D91442: [clang][Driver] Handle risvc in Baremetal.cpp.

2020-11-16 Thread Jessica Clarke via Phabricator via cfe-commits
jrtc27 added inline comments.



Comment at: clang/test/Driver/riscv64-toolchain.c:5
+// RUN: %clang %s -### -no-canonical-prefixes -target riscv64 \
+// RUN: --gcc-toolchain=%S/Inputs/basic_riscv64_tree 2>&1 | FileCheck 
-check-prefix=CC1 %s
 // CC1: clang{{.*}} "-cc1" "-triple" "riscv64"

(repeated below and in riscv32-toolchain.c)


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

https://reviews.llvm.org/D91442

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


[PATCH] D91442: [clang][Driver] Handle risvc in Baremetal.cpp.

2020-11-16 Thread Hafiz Abid Qadeer via Phabricator via cfe-commits
abidh marked an inline comment as done.
abidh added a comment.

In D91442#2394501 , @jroelofs wrote:

> Seems reasonable.
>
> I could see someone wanting to use `--gcc-toolchain` to point at the 
> baremetal toolchain for their target, but that's unlikely to work out of the 
> box anyway. I'd love to know where the Generic_GCC toolchain is used in 
> practice, since that's always seemed quite fragile to me.

Thanks for the review. I have handled the comment in updated diff. I will give 
it a few more days in case anyone else wants to comment before landing.


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

https://reviews.llvm.org/D91442

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


[PATCH] D91559: Add sysroot/lib to library search path of baremetal toolchain.

2020-11-16 Thread Jon Roelofs via Phabricator via cfe-commits
jroelofs accepted this revision.
jroelofs added inline comments.
This revision is now accepted and ready to land.



Comment at: clang/lib/Driver/ToolChains/BareMetal.cpp:39
+llvm::sys::path::append(SysRoot, "lib");
+getFilePaths().push_back(std::string(SysRoot.str()));
+  }

Is the explicit `std::string` ctor call necessary here? Since `SmallString` has 
an `operator std::string() const`, I think this can just be:

```
getFilePaths().push_back(SysRoot);
```


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91559

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


[PATCH] D90173: [PowerPC] Exploit splat instruction xxsplti32dx in Power10

2020-11-16 Thread Albion Fung via Phabricator via cfe-commits
Conanap updated this revision to Diff 305575.
Conanap added a comment.

clang format


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D90173

Files:
  llvm/lib/Target/PowerPC/PPCISelLowering.cpp
  llvm/lib/Target/PowerPC/PPCInstrPrefix.td
  llvm/test/CodeGen/PowerPC/p10-splatImm-CPload-pcrel.ll
  llvm/test/CodeGen/PowerPC/p10-splatImm32.ll

Index: llvm/test/CodeGen/PowerPC/p10-splatImm32.ll
===
--- llvm/test/CodeGen/PowerPC/p10-splatImm32.ll
+++ llvm/test/CodeGen/PowerPC/p10-splatImm32.ll
@@ -118,3 +118,25 @@
   %vecins1 = shufflevector <4 x i32> , <4 x i32> %a, <4 x i32> 
   ret <4 x i32> %vecins1
 }
+
+define dso_local <2 x double> @test_xxsplti32dx_8() {
+; CHECK-LABEL: test_xxsplti32dx_8
+; CHECK-LE: xxlxor vs34, vs34, vs34
+; CHECK-LE: xxsplti32dx vs34, 1, 1082660167
+; CHECK-BE: xxlxor vs34, vs34, vs34
+; CHECK-BE: xxsplti32dx vs34, 0, 1082660167
+; CHECK: blr
+entry:
+  ret <2 x double> 
+}
+
+define dso_local <8 x i16> @test_xxsplti32dx_9() {
+; CHECK-LABEL: test_xxsplti32dx_9
+; CHECK-LE: xxlxor vs34, vs34, vs34
+; CHECK-LE: xxsplti32dx vs34, 1, 23855277
+; CHECK-BE: xxlxor vs34, vs34, vs34
+; CHECK-BE: xxsplti32dx vs34, 0, 19070977
+; CHECK: blr
+entry:
+  ret <8 x i16> 
+}
Index: llvm/test/CodeGen/PowerPC/p10-splatImm-CPload-pcrel.ll
===
--- llvm/test/CodeGen/PowerPC/p10-splatImm-CPload-pcrel.ll
+++ llvm/test/CodeGen/PowerPC/p10-splatImm-CPload-pcrel.ll
@@ -1,27 +1,29 @@
 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
 ; RUN: llc -verify-machineinstrs -mtriple=powerpc64le-unknown-linux-gnu -O2 \
-; RUN: -ppc-asm-full-reg-names -mcpu=pwr10 < %s | FileCheck %s
+; RUN: -ppc-asm-full-reg-names -mcpu=pwr10 < %s | FileCheck %s --check-prefixes=CHECK,CHECK-LE
 ; RUN: llc -verify-machineinstrs -mtriple=powerpc64-unknown-linux-gnu -O2 \
 ; RUN: -ppc-asm-full-reg-names -mcpu=pwr10 < %s | FileCheck %s \
-; RUN: --check-prefix=CHECK-NOPCREL
+; RUN: --check-prefixes=CHECK-NOPCREL-BE,CHECK-NOPCREL
 ; RUN: llc -verify-machineinstrs -mtriple=powerpc64le-unknown-linux-gnu -O2 \
 ; RUN: -mattr=-pcrelative-memops -ppc-asm-full-reg-names -mcpu=pwr10 < %s | \
-; RUN: FileCheck %s --check-prefix=CHECK-NOPCREL
+; RUN: FileCheck %s --check-prefixes=CHECK-NOPCREL-LE,CHECK-NOPCREL
 ; RUN: llc -verify-machineinstrs -mtriple=powerpc64-unknown-linux-gnu -O2 \
 ; RUN: -ppc-asm-full-reg-names -target-abi=elfv2 -mcpu=pwr10 < %s | \
-; RUN: FileCheck %s
+; RUN: FileCheck %s --check-prefixes=CHECK,CHECK-BE
 
 define dso_local <2 x double> @testDoubleToDoubleFail() local_unnamed_addr {
 ; CHECK-LABEL: testDoubleToDoubleFail:
 ; CHECK:   # %bb.0: # %entry
-; CHECK-NEXT:plxv vs34, .LCPI0_0@PCREL(0), 1
+; CHECK-NEXT:xxlxor vs34, vs34, vs34
+; CHECK-LE-NEXT:xxsplti32dx vs34, 1, 1081435463
+; CHECK-BE-NEXT: xxsplti32dx vs34, 0, 1081435463
 ; CHECK-NEXT:blr
 ;
 ; CHECK-NOPCREL-LABEL: testDoubleToDoubleFail:
 ; CHECK-NOPCREL:   # %bb.0: # %entry
-; CHECK-NOPCREL-NEXT:addis r3, r2, .LCPI0_0@toc@ha
-; CHECK-NOPCREL-NEXT:addi r3, r3, .LCPI0_0@toc@l
-; CHECK-NOPCREL-NEXT:lxvx vs34, 0, r3
+; CHECK-NOPCREL-NEXT:xxlxor vs34, vs34, vs34
+; CHECK-NOPCREL-LE-NEXT: xxsplti32dx vs34, 1, 1081435463
+; CHECK-NOPCREL-BE-NEXT: xxsplti32dx vs34, 0, 1081435463
 ; CHECK-NOPCREL-NEXT:blr
 
 entry:
@@ -31,14 +33,16 @@
 define dso_local <2 x double> @testFloatDenormToDouble() local_unnamed_addr {
 ; CHECK-LABEL: testFloatDenormToDouble:
 ; CHECK:   # %bb.0: # %entry
-; CHECK-NEXT:plxv vs34, .LCPI1_0@PCREL(0), 1
+; CHECK-NEXT:xxlxor vs34, vs34, vs34
+; CHECK-LE-NEXT: xxsplti32dx vs34, 1, 940259579
+; CHECK-BE-NEXT: xxsplti32dx vs34, 0, 940259579
 ; CHECK-NEXT:blr
 ;
 ; CHECK-NOPCREL-LABEL: testFloatDenormToDouble:
 ; CHECK-NOPCREL:   # %bb.0: # %entry
-; CHECK-NOPCREL-NEXT:addis r3, r2, .LCPI1_0@toc@ha
-; CHECK-NOPCREL-NEXT:addi r3, r3, .LCPI1_0@toc@l
-; CHECK-NOPCREL-NEXT:lxvx vs34, 0, r3
+; CHECK-NOPCREL-NEXT:xxlxor vs34, vs34, vs34
+; CHECK-NOPCREL-LE-NEXT:xxsplti32dx vs34, 1, 940259579
+; CHECK-NOPCREL-BE-NEXT:xxsplti32dx vs34, 0, 940259579
 ; CHECK-NOPCREL-NEXT:blr
 
 entry:
@@ -48,14 +52,16 @@
 define dso_local <2 x double> @testDoubleToDoubleNaNFail() local_unnamed_addr {
 ; CHECK-LABEL: testDoubleToDoubleNaNFail:
 ; CHECK:   # %bb.0: # %entry
-; CHECK-NEXT:plxv vs34, .LCPI2_0@PCREL(0), 1
+; CHECK-NEXT:xxlxor vs34, vs34, vs34
+; CHECK-LE-NEXT:xxsplti32dx vs34, 1, -1
+; CHECK-BE-NEXT:xxsplti32dx vs34, 0, -1
 ; CHECK-NEXT:blr
 ;
 ; CHECK-NOPCREL-LABEL: testDoubleToDoubleNaNFail:
 ; CHECK-NOPCREL:   # %bb.0: # %entry
-; CHECK-NOPCREL-NEXT:addis r3, r2, .LCPI2_0@toc@ha
-; CHECK-NOPCREL-NEXT:addi r3, r3, .LCPI2_0@toc@l
-; CHECK-NOPCREL-NEXT:lxvx 

[PATCH] D91442: [clang][Driver] Handle risvc in Baremetal.cpp.

2020-11-16 Thread Hafiz Abid Qadeer via Phabricator via cfe-commits
abidh updated this revision to Diff 305573.
abidh added a comment.

Made the condition consistent in both places where Baremetal toolchain is 
instantiated as suggested in review.


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

https://reviews.llvm.org/D91442

Files:
  clang/lib/Driver/Driver.cpp
  clang/lib/Driver/ToolChains/BareMetal.cpp
  clang/test/Driver/baremetal.cpp
  clang/test/Driver/riscv-gnutools.c
  clang/test/Driver/riscv32-toolchain.c
  clang/test/Driver/riscv64-toolchain.c

Index: clang/test/Driver/riscv64-toolchain.c
===
--- clang/test/Driver/riscv64-toolchain.c
+++ clang/test/Driver/riscv64-toolchain.c
@@ -1,11 +1,13 @@
 // A basic clang -cc1 command-line, and simple environment check.
 // REQUIRES: platform-linker
 
-// RUN: %clang %s -### -no-canonical-prefixes -target riscv64 2>&1 | FileCheck -check-prefix=CC1 %s
+// RUN: %clang %s -### -no-canonical-prefixes -target riscv64 \
+// RUN: --gcc-toolchain=%S/Inputs/basic_riscv64_tree 2>&1 | FileCheck -check-prefix=CC1 %s
 // CC1: clang{{.*}} "-cc1" "-triple" "riscv64"
 
 // Test interaction with -fuse-ld=lld, if lld is available.
-// RUN: %clang %s -### -no-canonical-prefixes -target riscv32 -fuse-ld=lld 2>&1 | FileCheck -check-prefix=LLD %s
+// RUN: %clang %s -### -no-canonical-prefixes -target riscv32 -fuse-ld=lld \
+// RUN: --gcc-toolchain=%S/Inputs/basic_riscv64_tree 2>&1 | FileCheck -check-prefix=LLD %s
 // LLD: {{(error: invalid linker name in argument '-fuse-ld=lld')|(ld.lld)}}
 
 // In the below tests, --rtlib=platform is used so that the driver ignores
@@ -133,6 +135,7 @@
 
 // Check that --rtlib can be used to override the used runtime library
 // RUN: %clang %s -### -no-canonical-prefixes \
+// RUN:   --gcc-toolchain=%S/Inputs/multilib_riscv_elf_sdk \
 // RUN:   -target riscv64-unknown-elf --rtlib=libgcc 2>&1 \
 // RUN:   | FileCheck -check-prefix=C-RV64-RTLIB-LIBGCC-LP64 %s
 // C-RV64-RTLIB-LIBGCC-LP64: "{{.*}}crt0.o"
@@ -141,6 +144,7 @@
 // C-RV64-RTLIB-LIBGCC-LP64: "{{.*}}crtend.o"
 
 // RUN: %clang %s -### -no-canonical-prefixes \
+// RUN:   --gcc-toolchain=%S/Inputs/multilib_riscv_elf_sdk \
 // RUN:   -target riscv64-unknown-elf --rtlib=compiler-rt 2>&1 \
 // RUN:   | FileCheck -check-prefix=C-RV64-RTLIB-COMPILERRT-LP64 %s
 // C-RV64-RTLIB-COMPILERRT-LP64: "{{.*}}crt0.o"
Index: clang/test/Driver/riscv32-toolchain.c
===
--- clang/test/Driver/riscv32-toolchain.c
+++ clang/test/Driver/riscv32-toolchain.c
@@ -1,11 +1,13 @@
 // A basic clang -cc1 command-line, and simple environment check.
 // REQUIRES: platform-linker
 
-// RUN: %clang %s -### -no-canonical-prefixes -target riscv32 2>&1 | FileCheck -check-prefix=CC1 %s
+// RUN: %clang %s -### -no-canonical-prefixes -target riscv32 \
+// RUN: --gcc-toolchain=%S/Inputs/basic_riscv32_tree 2>&1 | FileCheck -check-prefix=CC1 %s
 // CC1: clang{{.*}} "-cc1" "-triple" "riscv32"
 
 // Test interaction with -fuse-ld=lld, if lld is available.
-// RUN: %clang %s -### -no-canonical-prefixes -target riscv32 -fuse-ld=lld 2>&1 | FileCheck -check-prefix=LLD %s
+// RUN: %clang %s -### -no-canonical-prefixes -target riscv32 \
+// RUN: --gcc-toolchain=%S/Inputs/basic_riscv32_tree -fuse-ld=lld 2>&1 | FileCheck -check-prefix=LLD %s
 // LLD: {{(error: invalid linker name in argument '-fuse-ld=lld')|(ld.lld)}}
 
 // In the below tests, --rtlib=platform is used so that the driver ignores
@@ -177,6 +179,7 @@
 
 // Check that --rtlib can be used to override the used runtime library
 // RUN: %clang %s -### -no-canonical-prefixes \
+// RUN:   --gcc-toolchain=%S/Inputs/multilib_riscv_elf_sdk \
 // RUN:   -target riscv32-unknown-elf --rtlib=libgcc 2>&1 \
 // RUN:   | FileCheck -check-prefix=C-RV32-RTLIB-LIBGCC-ILP32 %s
 // C-RV32-RTLIB-LIBGCC-ILP32: "{{.*}}crt0.o"
@@ -185,6 +188,7 @@
 // C-RV32-RTLIB-LIBGCC-ILP32: "{{.*}}crtend.o"
 
 // RUN: %clang %s -### -no-canonical-prefixes \
+// RUN:   --gcc-toolchain=%S/Inputs/multilib_riscv_elf_sdk \
 // RUN:   -target riscv32-unknown-elf --rtlib=compiler-rt 2>&1 \
 // RUN:   | FileCheck -check-prefix=C-RV32-RTLIB-COMPILERRT-ILP32 %s
 // C-RV32-RTLIB-COMPILERRT-ILP32: "{{.*}}crt0.o"
Index: clang/test/Driver/riscv-gnutools.c
===
--- clang/test/Driver/riscv-gnutools.c
+++ clang/test/Driver/riscv-gnutools.c
@@ -5,15 +5,15 @@
 // 32-bit checks
 
 // Check default on riscv32-unknown-elf
-// RUN: %clang -target riscv32-unknown-elf -fno-integrated-as %s -### -c \
+// RUN: %clang -target riscv32-unknown-elf --gcc-toolchain=%S/Inputs/basic_riscv32_tree -fno-integrated-as %s -### -c \
 // RUN: 2>&1 | FileCheck -check-prefix=CHECK-RV32IMAC-ILP32 %s
 
 // Check default on riscv32-unknown-linux-gnu
-// RUN: %clang -target riscv32-unknown-linux-gnu -fno-integrated-as %s -### -c \
+// RUN: %clang -target riscv32-unknown-linux-gnu --gcc-toolchain=%S/Inputs/basic_riscv32_tree 

[PATCH] D91559: Add sysroot/lib to library search path of baremetal toolchain.

2020-11-16 Thread Hafiz Abid Qadeer via Phabricator via cfe-commits
abidh created this revision.
abidh added reviewers: jroelofs, clang.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.
abidh requested review of this revision.

Baremetal toolchain is not adding sysroot/lib to the library
search path. This is forcing the user to do it manually. This commit
fixes this shortcoming by adding the sysroot/lib to library search path
if sysroot is not empty.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D91559

Files:
  clang/lib/Driver/ToolChains/BareMetal.cpp
  clang/test/Driver/baremetal.cpp


Index: clang/test/Driver/baremetal.cpp
===
--- clang/test/Driver/baremetal.cpp
+++ clang/test/Driver/baremetal.cpp
@@ -12,6 +12,7 @@
 // CHECK-V6M-C-SAME: "-x" "c++" "{{.*}}baremetal.cpp"
 // CHECK-V6M-C-NEXT: "{{[^"]*}}ld{{(\.(lld|bfd|gold))?}}{{(\.exe)?}}" 
"{{.*}}.o" "-Bstatic"
 // CHECK-V6M-C-SAME: "-L[[RESOURCE_DIR:[^"]+]]{{[/\\]+}}lib{{[/\\]+}}baremetal"
+// CHECK-V6M-C-SAME: "-L[[SYSROOT:[^"]+]]{{[/\\]+}}lib"
 // CHECK-V6M-C-SAME: "-T" "semihosted.lds" 
"-Lsome{{[/\\]+}}directory{{[/\\]+}}user{{[/\\]+}}asked{{[/\\]+}}for"
 // CHECK-V6M-C-SAME: "-lc" "-lm" "-lclang_rt.builtins-armv6m"
 // CHECK-V6M-C-SAME: "-o" "{{.*}}.o"
@@ -34,6 +35,7 @@
 // RUN:   | FileCheck --check-prefix=CHECK-V6M-DEFAULTCXX %s
 // CHECK-V6M-DEFAULTCXX: "{{[^"]*}}ld{{(\.(lld|bfd|gold))?}}{{(\.exe)?}}" 
"{{.*}}.o" "-Bstatic"
 // CHECK-V6M-DEFAULTCXX-SAME: 
"-L{{[^"]*}}{{[/\\]+}}lib{{(64)?}}{{[/\\]+}}clang{{[/\\]+}}{{.*}}{{[/\\]+}}lib{{[/\\]+}}baremetal"
+// CHECK-V6M-DEFAULTCXX-SAME: 
"-L{{[^"]*}}{{[/\\]+}}Inputs{{[/\\]+}}baremetal_arm{{[/\\]+}}lib"
 // CHECK-V6M-DEFAULTCXX-SAME: "-lc++" "-lc++abi" "-lunwind"
 // CHECK-V6M-DEFAULTCXX-SAME: "-lc" "-lm" "-lclang_rt.builtins-armv6m"
 // CHECK-V6M-DEFAULTCXX-SAME: "-o" "{{.*}}.o"
@@ -47,6 +49,7 @@
 // CHECK-V6M-LIBCXX: "-internal-isystem" 
"{{[^"]+}}{{[/\\]+}}include{{[/\\]+}}c++{{[/\\]+}}v1"
 // CHECK-V6M-LIBCXX: "{{[^"]*}}ld{{(\.(lld|bfd|gold))?}}{{(\.exe)?}}" 
"{{.*}}.o" "-Bstatic"
 // CHECK-V6M-LIBCXX-SAME: 
"-L{{[^"]*}}{{[/\\]+}}lib{{(64)?}}{{[/\\]+}}clang{{[/\\]+}}{{.*}}{{[/\\]+}}lib{{[/\\]+}}baremetal"
+// CHECK-V6M-LIBCXX-SAME: 
"-L{{[^"]*}}{{[/\\]+}}Inputs{{[/\\]+}}baremetal_arm{{[/\\]+}}lib"
 // CHECK-V6M-LIBCXX-SAME: "-lc++" "-lc++abi" "-lunwind"
 // CHECK-V6M-LIBCXX-SAME: "-lc" "-lm" "-lclang_rt.builtins-armv6m"
 // CHECK-V6M-LIBCXX-SAME: "-o" "{{.*}}.o"
@@ -60,6 +63,7 @@
 // CHECK-V6M-LIBSTDCXX: "-internal-isystem" 
"{{[^"]+}}{{[/\\]+}}include{{[/\\]+}}c++{{[/\\]+}}6.0.0"
 // CHECK-V6M-LIBSTDCXX: "{{[^"]*}}ld{{(\.(lld|bfd|gold))?}}{{(\.exe)?}}" 
"{{.*}}.o" "-Bstatic"
 // CHECK-V6M-LIBSTDCXX-SAME: 
"-L{{[^"]*}}{{[/\\]+}}lib{{(64)?}}{{[/\\]+}}clang{{[/\\]+}}{{.*}}{{[/\\]+}}lib{{[/\\]+}}baremetal"
+// CHECK-V6M-LIBSTDCXX-SAME: 
"-L{{[^"]*}}{{[/\\]+}}Inputs{{[/\\]+}}baremetal_arm{{[/\\]+}}lib"
 // CHECK-V6M-LIBSTDCXX-SAME: "-lstdc++" "-lsupc++" "-lunwind"
 // CHECK-V6M-LIBSTDCXX-SAME: "-lc" "-lm" "-lclang_rt.builtins-armv6m"
 // CHECK-V6M-LIBSTDCXX-SAME: "-o" "{{.*}}.o"
@@ -70,7 +74,8 @@
 // RUN: -nodefaultlibs \
 // RUN:   | FileCheck --check-prefix=CHECK-V6M-NDL %s
 // CHECK-V6M-NDL: "{{[^"]*}}ld{{(\.(lld|bfd|gold))?}}{{(\.exe)?}}" "{{.*}}.o" 
"-Bstatic"
-// CHECK-V6M-NDL-SAME: 
"-L{{[^"]*}}{{[/\\]+}}lib{{(64)?}}{{[/\\]+}}clang{{[/\\]+}}{{.*}}{{[/\\]+}}lib{{[/\\]+}}baremetal"
 "-o" "{{.*}}.o"
+// CHECK-V6M-NDL-SAME: 
"-L{{[^"]*}}{{[/\\]+}}lib{{(64)?}}{{[/\\]+}}clang{{[/\\]+}}{{.*}}{{[/\\]+}}lib{{[/\\]+}}baremetal"
+// CHECK-V6M-NDL-SAME: 
"-L{{[^"]*}}{{[/\\]+}}Inputs{{[/\\]+}}baremetal_arm{{[/\\]+}}lib" "-o" 
"{{.*}}.o"
 
 // RUN: %clangxx -target arm-none-eabi -v 2>&1 \
 // RUN:   | FileCheck %s --check-prefix=CHECK-THREAD-MODEL
Index: clang/lib/Driver/ToolChains/BareMetal.cpp
===
--- clang/lib/Driver/ToolChains/BareMetal.cpp
+++ clang/lib/Driver/ToolChains/BareMetal.cpp
@@ -33,6 +33,11 @@
   getProgramPaths().push_back(getDriver().getInstalledDir());
   if (getDriver().getInstalledDir() != getDriver().Dir)
 getProgramPaths().push_back(getDriver().Dir);
+  SmallString<128> SysRoot(getDriver().SysRoot);
+  if (!SysRoot.empty()) {
+llvm::sys::path::append(SysRoot, "lib");
+getFilePaths().push_back(std::string(SysRoot.str()));
+  }
 }
 
 /// Is the triple {arm,thumb}-none-none-{eabi,eabihf} ?
@@ -189,6 +194,7 @@
 
   CmdArgs.push_back(Args.MakeArgString("-L" + TC.getRuntimesDir()));
 
+  TC.AddFilePathLibArgs(Args, CmdArgs);
   Args.AddAllArgs(CmdArgs, {options::OPT_L, options::OPT_T_Group,
 options::OPT_e, options::OPT_s, options::OPT_t,
 options::OPT_Z_Flag, options::OPT_r});


Index: clang/test/Driver/baremetal.cpp
===
--- clang/test/Driver/baremetal.cpp
+++ clang/test/Driver/baremetal.cpp
@@ -12,6 +12,7 @@
 // CHECK-V6M-C-SAME: "-x" "c++" 

[PATCH] D90982: Ignore implicit nodes in IgnoreUnlessSpelledInSource mode

2020-11-16 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

Thank you for this, I think it's mostly looking good!




Comment at: clang/include/clang/AST/ASTNodeTraverser.h:88
   void Visit(const Decl *D) {
+if (Traversal != TK_AsIs && D->isImplicit())
+  return;

Similar to the feedback on D90984, I think this will do the wrong thing for the 
weird traversal mode for ignoring parens and implicit casts. It should probably 
be checking for `Traversal == TK_IgnoreUnlessSpelledInSource` here.



Comment at: clang/include/clang/AST/ASTNodeTraverser.h:192
   void Visit(const CXXCtorInitializer *Init) {
+if (Traversal != TK_AsIs && !Init->isWritten())
+  return;

Same issue here.



Comment at: clang/include/clang/AST/ASTNodeTraverser.h:410
 
+if (Traversal != TK_AsIs && D->isDefaulted())
+  return;

Same here. I'll stop calling these out -- can you double check all the uses of 
`Traversal != TK_AsIs`?



Comment at: clang/include/clang/AST/ASTNodeTraverser.h:733
+  void VisitCXXForRangeStmt(const CXXForRangeStmt *Node) {
+if (Traversal != TK_AsIs) {
+  Visit(Node->getInit());

If we're in AsIs mode, don't we still want to match on some parts of the 
range-based for loop because they are spelled in source (like the body of the 
loop or the range-expression, etc)? 

The test behavior looks reasonable around this, so I suspect I'm just 
misunderstanding this change.



Comment at: clang/include/clang/AST/ASTNodeTraverser.h:742
+  void VisitCallExpr(const CallExpr *Node) {
+for (auto Child :
+ make_filter_range(Node->children(), [this](const Stmt *Child) {

This be `const auto *` or at least `auto *`.



Comment at: clang/lib/ASTMatchers/ASTMatchFinder.cpp:152
+
+if (DeclNode && DeclNode->isImplicit() && !Finder->isTraversalAsIs())
+  return baseTraverse(*DeclNode);

Similar issue here about traversal mode.



Comment at: clang/lib/ASTMatchers/ASTMatchFinder.cpp:1083
+
+  auto ScopedTraversal =
+  TraversingASTNodeNotSpelledInSource || DeclNode->isImplicit();

Spelling this as `bool` would not be amiss (same below, given how trivial it is 
to spell the type out).



Comment at: clang/lib/ASTMatchers/ASTMatchFinder.cpp:1108
   }
+  auto ScopedTraversal = TraversingASTNodeNotSpelledInSource ||
+ TraversingASTChildrenNotSpelledInSource;

`bool` here as well, please.



Comment at: clang/lib/ASTMatchers/ASTMatchFinder.cpp:1157
 
+  auto ScopedTraversal = TraversingASTNodeNotSpelledInSource ||
+ TraversingASTChildrenNotSpelledInSource;

Here too.



Comment at: clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp:2503
+EXPECT_TRUE(matches(Code, traverse(TK_IgnoreUnlessSpelledInSource, M)));
+  }
+

Can you add one more test for the body like 
`cxxForRangeStmt(hasBody(compoundStmt()))` which should match in both modes?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D90982

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


[PATCH] D91507: [clang-format] Add option for case sensitive regexes for sorted includes

2020-11-16 Thread Bjƶrn SchƤpers via Phabricator via cfe-commits
HazardyKnusperkeks added a comment.

Do I have to do something? For me it doesn't look like the build failure is due 
to my changes. 
Locally I've only build and run the FormatTests target.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91507

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


[PATCH] D91552: [OPENMP]Fix PR48076: mapping of data member pointer.

2020-11-16 Thread Joseph Huber via Phabricator via cfe-commits
jhuber6 accepted this revision.
jhuber6 added a comment.
This revision is now accepted and ready to land.

LGTM, fixed the problem on my machine and passes the unit tests.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91552

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


[PATCH] D90042: [clang-tidy] performance-unnecessary-copy-initialization: Check for const reference arguments that are replaced template parameter type.

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

LGTM, thank you for the fix!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D90042

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


[clang] 41b65f1 - Convert ConstexprKind from Specifiers.h to a scoped enum; NFC

2020-11-16 Thread Aaron Ballman via cfe-commits

Author: Thorsten
Date: 2020-11-16T14:10:19-05:00
New Revision: 41b65f166b51760f77d0f9e465b3858f46e101f0

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

LOG: Convert ConstexprKind from Specifiers.h to a scoped enum; NFC

Added: 


Modified: 
clang/include/clang/AST/Decl.h
clang/include/clang/AST/DeclCXX.h
clang/include/clang/Basic/Specifiers.h
clang/include/clang/Sema/DeclSpec.h
clang/lib/AST/Decl.cpp
clang/lib/AST/DeclCXX.cpp
clang/lib/Parse/ParseDecl.cpp
clang/lib/Parse/ParseExprCXX.cpp
clang/lib/Sema/DeclSpec.cpp
clang/lib/Sema/SemaDecl.cpp
clang/lib/Sema/SemaDeclAttr.cpp
clang/lib/Sema/SemaDeclCXX.cpp
clang/lib/Sema/SemaExpr.cpp
clang/lib/Sema/SemaLambda.cpp
clang/lib/Sema/SemaOpenMP.cpp
clang/lib/Sema/SemaType.cpp
clang/lib/Serialization/ASTWriterDecl.cpp

Removed: 




diff  --git a/clang/include/clang/AST/Decl.h b/clang/include/clang/AST/Decl.h
index 71896c0db086..7f6f143aa866 100644
--- a/clang/include/clang/AST/Decl.h
+++ b/clang/include/clang/AST/Decl.h
@@ -1978,7 +1978,7 @@ class FunctionDecl : public DeclaratorDecl,
  SourceLocation NLoc, DeclarationName N, QualType T,
  TypeSourceInfo *TInfo, StorageClass SC, bool isInlineSpecified = 
false,
  bool hasWrittenPrototype = true,
- ConstexprSpecKind ConstexprKind = CSK_unspecified,
+ ConstexprSpecKind ConstexprKind = ConstexprSpecKind::Unspecified,
  Expr *TrailingRequiresClause = nullptr) {
 DeclarationNameInfo NameInfo(N, NLoc);
 return FunctionDecl::Create(C, DC, StartLoc, NameInfo, T, TInfo, SC,
@@ -2230,19 +2230,19 @@ class FunctionDecl : public DeclaratorDecl,
 
   /// Whether this is a (C++11) constexpr function or constexpr constructor.
   bool isConstexpr() const {
-return FunctionDeclBits.ConstexprKind != CSK_unspecified;
+return getConstexprKind() != ConstexprSpecKind::Unspecified;
   }
   void setConstexprKind(ConstexprSpecKind CSK) {
-FunctionDeclBits.ConstexprKind = CSK;
+FunctionDeclBits.ConstexprKind = static_cast(CSK);
   }
   ConstexprSpecKind getConstexprKind() const {
 return static_cast(FunctionDeclBits.ConstexprKind);
   }
   bool isConstexprSpecified() const {
-return FunctionDeclBits.ConstexprKind == CSK_constexpr;
+return getConstexprKind() == ConstexprSpecKind::Constexpr;
   }
   bool isConsteval() const {
-return FunctionDeclBits.ConstexprKind == CSK_consteval;
+return getConstexprKind() == ConstexprSpecKind::Consteval;
   }
 
   /// Whether the instantiation of this function is pending.

diff  --git a/clang/include/clang/AST/DeclCXX.h 
b/clang/include/clang/AST/DeclCXX.h
index 496caf871a91..36f42c06a300 100644
--- a/clang/include/clang/AST/DeclCXX.h
+++ b/clang/include/clang/AST/DeclCXX.h
@@ -1887,7 +1887,7 @@ class CXXDeductionGuideDecl : public FunctionDecl {
 const DeclarationNameInfo , QualType T,
 TypeSourceInfo *TInfo, SourceLocation EndLocation)
   : FunctionDecl(CXXDeductionGuide, C, DC, StartLoc, NameInfo, T, TInfo,
- SC_None, false, CSK_unspecified),
+ SC_None, false, ConstexprSpecKind::Unspecified),
 ExplicitSpec(ES) {
 if (EndLocation.isValid())
   setRangeEnd(EndLocation);

diff  --git a/clang/include/clang/Basic/Specifiers.h 
b/clang/include/clang/Basic/Specifiers.h
index 41537672283d..03de6ea6a434 100644
--- a/clang/include/clang/Basic/Specifiers.h
+++ b/clang/include/clang/Basic/Specifiers.h
@@ -29,12 +29,7 @@ namespace clang {
   };
 
   /// Define the kind of constexpr specifier.
-  enum ConstexprSpecKind {
-CSK_unspecified,
-CSK_constexpr,
-CSK_consteval,
-CSK_constinit
-  };
+  enum class ConstexprSpecKind { Unspecified, Constexpr, Consteval, Constinit 
};
 
   /// Specifies the width of a type, e.g., short, long, or long long.
   enum class TypeSpecifierWidth { Unspecified, Short, Long, LongLong };

diff  --git a/clang/include/clang/Sema/DeclSpec.h 
b/clang/include/clang/Sema/DeclSpec.h
index 6a961bc026b0..d2acafc2e4b3 100644
--- a/clang/include/clang/Sema/DeclSpec.h
+++ b/clang/include/clang/Sema/DeclSpec.h
@@ -431,8 +431,10 @@ class DeclSpec {
 TypeQualifiers(TQ_unspecified), FS_inline_specified(false),
 FS_forceinline_specified(false), FS_virtual_specified(false),
 FS_noreturn_specified(false), Friend_specified(false),
-ConstexprSpecifier(CSK_unspecified), FS_explicit_specifier(),
-Attrs(attrFactory), writtenBS(), ObjCQualifiers(nullptr) {}
+ConstexprSpecifier(
+static_cast(ConstexprSpecKind::Unspecified)),
+FS_explicit_specifier(), Attrs(attrFactory), writtenBS(),
+ObjCQualifiers(nullptr) {}
 
   // 

[PATCH] D78903: [Driver] Add option -fproc-stat-report

2020-11-16 Thread Thorsten via Phabricator via cfe-commits
tschuett added a comment.

Could you add quotation marks around the executable name to make the CSV file 
easier to parse?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D78903

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


[PATCH] D88138: [NPM] Add target specific hook to add passes for New Pass Manager

2020-11-16 Thread Jameson Nash via Phabricator via cfe-commits
vtjnash added a comment.

I think this, and similar recent commits, are causing the shared library builds 
to fail some tests if this code gets linked into libLLVM.so: 
https://bugs.llvm.org/show_bug.cgi?id=48181. I assume it might actually a bug 
in ld (GNU Binutils for Ubuntu 2.34), as I don't understand the linker behavior 
there?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D88138

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


[PATCH] D91546: [AMDGPU] Add option -munsafe-fp-atomics

2020-11-16 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl marked an inline comment as done.
yaxunl added inline comments.



Comment at: clang/include/clang/Basic/TargetOptions.h:78
 
+  /// \brief If enabled, allow AMDGPU unsafe floating point atomics.
+  bool AllowAMDGPUUnsafeFPAtomics = false;

tra wrote:
> I'm curious -- what does `unsafe` mean here?
unsafe means it does not follow requirements of other floating point options, 
e.g. it may flush denormals even if other fp options requires denormals not 
flushed. This allows user to relax fp restrictions on fp atomic instructions 
without relaxing fp requirements on other instructions.


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

https://reviews.llvm.org/D91546

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


[PATCH] D91121: [InferAddrSpace] Teach to handle assumed address space.

2020-11-16 Thread Michael Liao via Phabricator via cfe-commits
hliao added inline comments.



Comment at: llvm/lib/Target/AMDGPU/AMDGPUTargetMachine.cpp:533
+  if (!LD)
+return -1;
+

tra wrote:
> Is there a suitable constant for `don't know` result?
I would say all generic pointers loaded from the constant memory are safe to be 
assumed as global ones (for AMDGPU). I explained the reason in the usage 
document. The constant memory could be modified by the host, where only global 
memory objects are visible.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91121

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


[PATCH] D88394: [Driver][M68k] (Patch 8/8) Add driver support for M68k

2020-11-16 Thread Simon Pilgrim via Phabricator via cfe-commits
RKSimon added a comment.

Some very minor nits - the 68060 omission is the biggest one (apple might not 
have used it but commodore did!)




Comment at: clang/include/clang/Driver/Options.td:155
+def m_m68k_Features_Group: OptionGroup<"">,
+ Group, DocName<"M68k">;
 def m_ppc_Features_Group : OptionGroup<"">,

(sorting) put this before mips?



Comment at: clang/lib/Driver/ToolChains/Arch/M68k.cpp:44
+
+llvm::Regex CPUPattern("m?680([01234]{1})0");
+llvm::SmallVector Matches;

Why no 68060 ?



Comment at: clang/lib/Driver/ToolChains/Arch/M68k.cpp:64
+return "M68040";
+  }
+

(style) remove unnecessary braces?



Comment at: clang/lib/Driver/ToolChains/Arch/M68k.cpp:72
+ const ArgList ,
+ std::vector ) {
+

(clang-format) indentation?



Comment at: clang/lib/Driver/ToolChains/Arch/M68k.cpp:94
+ABI = m68k::FloatABI::Hard;
+  }
+

remove braces



Comment at: clang/lib/Driver/ToolChains/Arch/M68k.h:35
+ const llvm::opt::ArgList ,
+ std::vector );
+

(clang-format) indentation?



Comment at: clang/lib/Driver/ToolChains/Arch/M68k.h:38
+} // end namespace m68k
+} // namespace tools
+} // end namespace driver

(clang-tidy) end namespace tools




Comment at: clang/lib/Driver/ToolChains/Clang.cpp:380
+m68k::getM68kTargetFeatures(D, Triple, Args, Features);
+break;
   }

(sorting) move before msp430 ?



Comment at: clang/lib/Driver/ToolChains/CommonArgs.cpp:297
+  case llvm::Triple::m68k:
+return m68k::getM68kTargetCPU(Args);
+

(sorting) move down to before mips ?


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

https://reviews.llvm.org/D88394

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


[PATCH] D72184: [BPF] support atomic instructions

2020-11-16 Thread Yonghong Song via Phabricator via cfe-commits
yonghong-song added inline comments.



Comment at: llvm/lib/Target/BPF/BPFInstrInfo.td:666
+def XADDD : XADD;
+  }
+}

jackmanb wrote:
> FYI - I just spotted some stray `\t` in here (is it helpful to point this 
> out? If not let me know, I will ignore in future)
\t is not allowed. I will run clang-format next time to catch such violations. 
Thanks for letting me know.



Comment at: llvm/lib/Target/BPF/BPFInstrInfo.td:684
+  let Inst{47-32} = addr{15-0}; // offset
+  let Inst{11-8} = val;
+  let Inst{7-4} = Opc.Value;

jackmanb wrote:
> jackmanb wrote:
> > jackmanb wrote:
> > > Sorry I'm a beginner with the LLVM code, could you explain what `val` 
> > > does? I didn't notice this when I looked through here before.
> > > 
> > > To try and get a clue I tried just removing this line and then compiling 
> > > the following code:
> > > 
> > > ```C
> > > // SPDX-License-Identifier: GPL-2.0
> > > #include 
> > > 
> > > #include 
> > > #include 
> > > #include 
> > > 
> > > __u64 test_data_64 = 0;
> > > __u64 test1_result = 0;
> > > 
> > > SEC("fentry/bpf_fentry_test1")
> > > int BPF_PROG(test1, int a)
> > > {
> > > /* atomic_fetch_add(_data_64, 1); */
> > > test1_result = __sync_fetch_and_add(_data_64, 1);
> > > return 0;
> > > }
> > > ```
> > > 
> > > And I was able to load and run the program, with the kernel on my WIP 
> > > branch: https://github.com/bjackman/linux-bpf/tree/wips/bpf-atomics-v0
> > > 
> > > The result looks like this:
> > > 
> > > ```shell
> > > $ llvm-objdump -d atomics_test.o
> > > 
> > > atomics_test.o: file format elf64-bpf
> > > 
> > > 
> > > Disassembly of section fentry/bpf_fentry_test1:
> > > 
> > >  :
> > >0:   b7 01 00 00 01 00 00 00 r1 = 1
> > >1:   18 02 00 00 00 00 00 00 00 00 00 00 00 00 00 00 r2 = 0 ll
> > >3:   db 12 00 00 01 00 00 00 r1 = atomic_fetch_add((u64 *)(r2 
> > > + 0), PLEASE submit a bug report to https://bugs.llvm.org/ and include 
> > > the crash backtrace.
> > > Stack dump:
> > > 0.  Program arguments: llvm-objdump -d atomics_test.o 
> > > Segmentation fault
> > > ```
> > > 
> > > Aside from the fact that llvm-objdump crashed, the encoding `db 12 00 00 
> > > 01 00 00 00` seems correct to me. If I add the `let Inst{11-8} = val` 
> > > back in I get `db 12 00 00 01 01 00 00` which I don't understand.
> > Ah wait, I guess this is adding a 3rd operand register? In my example it's 
> > unclear because it is R1 which is also the dst operand. I was envisaging we 
> > just have semantics like `src = atomic_fetch_add(dst+off, src)` but you are 
> > instead proposing `dst = atomic_fetch_add(dst+off, val)`?
> Sorry I mean `dst = atomic_fetch_add(src+off, val)`
> Sorry I'm a beginner with the LLVM code, could you explain what `val` does? I 
> didn't notice this when I looked through here before.

For the below statement:
  test1_result = __sync_fetch_and_add(_data_64, 1);

'val' represents the register which holds the value '1'.

bit 4-7 is also used in compare-and-exchange insn as you need a memory 
location, in-register old/new values.

> 
> To try and get a clue I tried just removing this line and then compiling the 
> following code:
> 
> ```C
> // SPDX-License-Identifier: GPL-2.0
> #include 
> 
> #include 
> #include 
> #include 
> 
> __u64 test_data_64 = 0;
> __u64 test1_result = 0;
> 
> SEC("fentry/bpf_fentry_test1")
> int BPF_PROG(test1, int a)
> {
> /* atomic_fetch_add(_data_64, 1); */
> test1_result = __sync_fetch_and_add(_data_64, 1);
> return 0;
> }
> ```
> 
> And I was able to load and run the program, with the kernel on my WIP branch: 
> https://github.com/bjackman/linux-bpf/tree/wips/bpf-atomics-v0
> 
> The result looks like this:
> 
> ```shell
> $ llvm-objdump -d atomics_test.o
> 
> atomics_test.o: file format elf64-bpf
> 
> 
> Disassembly of section fentry/bpf_fentry_test1:
> 
>  :
>0:   b7 01 00 00 01 00 00 00 r1 = 1
>1:   18 02 00 00 00 00 00 00 00 00 00 00 00 00 00 00 r2 = 0 ll
>3:   db 12 00 00 01 00 00 00 r1 = atomic_fetch_add((u64 *)(r2 + 
> 0), PLEASE submit a bug report to https://bugs.llvm.org/ and include the 
> crash backtrace.
> Stack dump:
> 0.  Program arguments: llvm-objdump -d atomics_test.o 
> Segmentation fault
> ```
> 

the crash may come from that the 'val' is not encoded properly. I will double 
check.

> Aside from the fact that llvm-objdump crashed, the encoding `db 12 00 00 01 
> 00 00 00` seems correct to me. If I add the `let Inst{11-8} = val` back in I 
> get `db 12 00 00 01 01 00 00` which I don't understand.

in this particular case, yes, as final asm code looks like
   r1 = atomic_fetch_add((u64 *)(r2 + 0), r1)
where the value "r1" and the result "r1" shared the same register. A little bit 
compiler work is need to enforce "val" register and result register always the 
same.

My current design allows:

[PATCH] D72184: [BPF] support atomic instructions

2020-11-16 Thread Brendan Jackman via Phabricator via cfe-commits
jackmanb added inline comments.



Comment at: llvm/lib/Target/BPF/BPFInstrInfo.td:684
+  let Inst{47-32} = addr{15-0}; // offset
+  let Inst{11-8} = val;
+  let Inst{7-4} = Opc.Value;

jackmanb wrote:
> jackmanb wrote:
> > Sorry I'm a beginner with the LLVM code, could you explain what `val` does? 
> > I didn't notice this when I looked through here before.
> > 
> > To try and get a clue I tried just removing this line and then compiling 
> > the following code:
> > 
> > ```C
> > // SPDX-License-Identifier: GPL-2.0
> > #include 
> > 
> > #include 
> > #include 
> > #include 
> > 
> > __u64 test_data_64 = 0;
> > __u64 test1_result = 0;
> > 
> > SEC("fentry/bpf_fentry_test1")
> > int BPF_PROG(test1, int a)
> > {
> > /* atomic_fetch_add(_data_64, 1); */
> > test1_result = __sync_fetch_and_add(_data_64, 1);
> > return 0;
> > }
> > ```
> > 
> > And I was able to load and run the program, with the kernel on my WIP 
> > branch: https://github.com/bjackman/linux-bpf/tree/wips/bpf-atomics-v0
> > 
> > The result looks like this:
> > 
> > ```shell
> > $ llvm-objdump -d atomics_test.o
> > 
> > atomics_test.o: file format elf64-bpf
> > 
> > 
> > Disassembly of section fentry/bpf_fentry_test1:
> > 
> >  :
> >0:   b7 01 00 00 01 00 00 00 r1 = 1
> >1:   18 02 00 00 00 00 00 00 00 00 00 00 00 00 00 00 r2 = 0 ll
> >3:   db 12 00 00 01 00 00 00 r1 = atomic_fetch_add((u64 *)(r2 + 
> > 0), PLEASE submit a bug report to https://bugs.llvm.org/ and include the 
> > crash backtrace.
> > Stack dump:
> > 0.  Program arguments: llvm-objdump -d atomics_test.o 
> > Segmentation fault
> > ```
> > 
> > Aside from the fact that llvm-objdump crashed, the encoding `db 12 00 00 01 
> > 00 00 00` seems correct to me. If I add the `let Inst{11-8} = val` back in 
> > I get `db 12 00 00 01 01 00 00` which I don't understand.
> Ah wait, I guess this is adding a 3rd operand register? In my example it's 
> unclear because it is R1 which is also the dst operand. I was envisaging we 
> just have semantics like `src = atomic_fetch_add(dst+off, src)` but you are 
> instead proposing `dst = atomic_fetch_add(dst+off, val)`?
Sorry I mean `dst = atomic_fetch_add(src+off, val)`


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72184

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


[PATCH] D72184: [BPF] support atomic instructions

2020-11-16 Thread Brendan Jackman via Phabricator via cfe-commits
jackmanb added inline comments.



Comment at: llvm/lib/Target/BPF/BPFInstrInfo.td:684
+  let Inst{47-32} = addr{15-0}; // offset
+  let Inst{11-8} = val;
+  let Inst{7-4} = Opc.Value;

jackmanb wrote:
> Sorry I'm a beginner with the LLVM code, could you explain what `val` does? I 
> didn't notice this when I looked through here before.
> 
> To try and get a clue I tried just removing this line and then compiling the 
> following code:
> 
> ```C
> // SPDX-License-Identifier: GPL-2.0
> #include 
> 
> #include 
> #include 
> #include 
> 
> __u64 test_data_64 = 0;
> __u64 test1_result = 0;
> 
> SEC("fentry/bpf_fentry_test1")
> int BPF_PROG(test1, int a)
> {
> /* atomic_fetch_add(_data_64, 1); */
> test1_result = __sync_fetch_and_add(_data_64, 1);
> return 0;
> }
> ```
> 
> And I was able to load and run the program, with the kernel on my WIP branch: 
> https://github.com/bjackman/linux-bpf/tree/wips/bpf-atomics-v0
> 
> The result looks like this:
> 
> ```shell
> $ llvm-objdump -d atomics_test.o
> 
> atomics_test.o: file format elf64-bpf
> 
> 
> Disassembly of section fentry/bpf_fentry_test1:
> 
>  :
>0:   b7 01 00 00 01 00 00 00 r1 = 1
>1:   18 02 00 00 00 00 00 00 00 00 00 00 00 00 00 00 r2 = 0 ll
>3:   db 12 00 00 01 00 00 00 r1 = atomic_fetch_add((u64 *)(r2 + 
> 0), PLEASE submit a bug report to https://bugs.llvm.org/ and include the 
> crash backtrace.
> Stack dump:
> 0.  Program arguments: llvm-objdump -d atomics_test.o 
> Segmentation fault
> ```
> 
> Aside from the fact that llvm-objdump crashed, the encoding `db 12 00 00 01 
> 00 00 00` seems correct to me. If I add the `let Inst{11-8} = val` back in I 
> get `db 12 00 00 01 01 00 00` which I don't understand.
Ah wait, I guess this is adding a 3rd operand register? In my example it's 
unclear because it is R1 which is also the dst operand. I was envisaging we 
just have semantics like `src = atomic_fetch_add(dst+off, src)` but you are 
instead proposing `dst = atomic_fetch_add(dst+off, val)`?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72184

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


[PATCH] D91546: [AMDGPU] Add option -munsafe-fp-atomics

2020-11-16 Thread Artem Belevich via Phabricator via cfe-commits
tra accepted this revision.
tra added a comment.
This revision is now accepted and ready to land.

LGTM.

Patch description could use a pointer to more details about the unsafe atomics.




Comment at: clang/include/clang/Basic/TargetOptions.h:78
 
+  /// \brief If enabled, allow AMDGPU unsafe floating point atomics.
+  bool AllowAMDGPUUnsafeFPAtomics = false;

I'm curious -- what does `unsafe` mean here?


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

https://reviews.llvm.org/D91546

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


[PATCH] D91121: [InferAddrSpace] Teach to handle assumed address space.

2020-11-16 Thread Artem Belevich via Phabricator via cfe-commits
tra added inline comments.



Comment at: llvm/lib/Target/AMDGPU/AMDGPUTargetMachine.cpp:533
+  if (!LD)
+return -1;
+

Is there a suitable constant for `don't know` result?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91121

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


[PATCH] D72184: [BPF] support atomic instructions

2020-11-16 Thread Brendan Jackman via Phabricator via cfe-commits
jackmanb added a comment.

Sorry I was disrupted and not able to work on this last week! I've just got 
started trying to integrate this with my kernel patches.




Comment at: llvm/lib/Target/BPF/BPFInstrInfo.td:666
+def XADDD : XADD;
+  }
+}

FYI - I just spotted some stray `\t` in here (is it helpful to point this out? 
If not let me know, I will ignore in future)



Comment at: llvm/lib/Target/BPF/BPFInstrInfo.td:684
+  let Inst{47-32} = addr{15-0}; // offset
+  let Inst{11-8} = val;
+  let Inst{7-4} = Opc.Value;

Sorry I'm a beginner with the LLVM code, could you explain what `val` does? I 
didn't notice this when I looked through here before.

To try and get a clue I tried just removing this line and then compiling the 
following code:

```C
// SPDX-License-Identifier: GPL-2.0
#include 

#include 
#include 
#include 

__u64 test_data_64 = 0;
__u64 test1_result = 0;

SEC("fentry/bpf_fentry_test1")
int BPF_PROG(test1, int a)
{
/* atomic_fetch_add(_data_64, 1); */
test1_result = __sync_fetch_and_add(_data_64, 1);
return 0;
}
```

And I was able to load and run the program, with the kernel on my WIP branch: 
https://github.com/bjackman/linux-bpf/tree/wips/bpf-atomics-v0

The result looks like this:

```shell
$ llvm-objdump -d atomics_test.o

atomics_test.o: file format elf64-bpf


Disassembly of section fentry/bpf_fentry_test1:

 :
   0:   b7 01 00 00 01 00 00 00 r1 = 1
   1:   18 02 00 00 00 00 00 00 00 00 00 00 00 00 00 00 r2 = 0 ll
   3:   db 12 00 00 01 00 00 00 r1 = atomic_fetch_add((u64 *)(r2 + 0), 
PLEASE submit a bug report to https://bugs.llvm.org/ and include the crash 
backtrace.
Stack dump:
0.  Program arguments: llvm-objdump -d atomics_test.o 
Segmentation fault
```

Aside from the fact that llvm-objdump crashed, the encoding `db 12 00 00 01 00 
00 00` seems correct to me. If I add the `let Inst{11-8} = val` back in I get 
`db 12 00 00 01 01 00 00` which I don't understand.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72184

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


[PATCH] D90984: Update matchers to be traverse-aware

2020-11-16 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: clang/include/clang/ASTMatchers/ASTMatchers.h:3115
+
+  if (!Finder->isTraversalAsIs() && (*MatchIt)->isImplicit())
+return false;

steveire wrote:
> aaron.ballman wrote:
> > If the traversal is not `AsIs`, that doesn't mean it's 
> > `IgnoreUnlessSpelledInSource` -- it could be 
> > `IgnoreImplicitCastsAndParentheses`, right? So I think the logic for some 
> > of these AST matchers is incorrect when in 
> > `IgnoreImplicitCastsAndParentheses` traversal mode and should be 
> > double-checked. We should probably add some extra test coverage for that 
> > mode.
> As far as I know, the problem of implicit nodes has been known for a long 
> time. Adding calls to `IgnoreParenImpCasts()` in certain places like 
> `hasArgument` was one attempt at making the implicit nodes less convenient 
> for users. As far as I know, `IgnoreImplicitCastsAndParentheses` was just 
> another attempt at the same thing. I must have discovered that by reading 
> code history at some point. Both previous attempts didn't go far enough to 
> actually solve the problem, but `IgnoreUnlessSpelledInSource` does go all the 
> way, and `traverse` puts control in the hands of the user. D20801 at least 
> seems to have been an attempt to put control back in the hands of the user. 
> And it was a follow-up to D18243.
> 
> So, once this and D90982 are merged, I think it makes sense to start to 
> remove `IgnoreImplicitCastsAndParentheses` entirely. It is legacy, 
> incompletely useful and just causes some mess in the code. 
> 
> Two modes aught to be enough for anybody.
> As far as I know, IgnoreImplicitCastsAndParentheses was just another attempt 
> at the same thing. I must have discovered that by reading code history at 
> some point. 

I don't recall the history of this traversal mode, but I think you're correct.

> So, once this and D90982 are merged, I think it makes sense to start to 
> remove IgnoreImplicitCastsAndParentheses entirely. It is legacy, incompletely 
> useful and just causes some mess in the code.

I agree. I see at least two ways to proceed:

1) Change this patch to handle three modes so that we can land it without 
incorrect behavior, then do a follow-up patch to rip out the 
`IgnoreImplicitCastsAndParentheses` mode.
2) Rip out `IgnoreImplicitCastsAndParentheses` first and then land this patch 
as-is.

My preference is for #1 so that we don't land this patch in an awkward state 
(in case the removal of the other mode gets delayed for some reason). Given 
what I mention below, that shouldn't result in any undue churn, I'd hope.

> Two modes aught to be enough for anybody.

Heh, I would like to think that, but given that this enumeration is used for 
generic traversal of ASTs, I'm less convinced that two modes will be all we 
ever want to support. I think it's a bit more future-proof to add a helper 
method along the lines of `isTraversalIgnoringImplicitNodes()` rather than 
using `!isTraversalAsIs()`.



Comment at: clang/include/clang/ASTMatchers/ASTMatchers.h:4054
   unsigned, N) {
-  return Node.getNumArgs() == N;
+  auto NumArgs = Node.getNumArgs();
+  if (Finder->isTraversalAsIs())

`auto` -> `unsigned` please



Comment at: clang/include/clang/ASTMatchers/ASTMatchers.h:4058
+  while (NumArgs) {
+const auto *Arg = Node.getArg(NumArgs - 1);
+if (!isa(Arg))

`auto` -> `const Expr *`  or just get rid of the local variable entirely by 
sinking the initialization into the `isa<>`.



Comment at: clang/include/clang/ASTMatchers/ASTMatchers.h:4081
+return false;
+  const auto *Arg = Node.getArg(N);
+  if (!Finder->isTraversalAsIs() && isa(Arg))

`const auto *` -> `const Expr *`



Comment at: clang/include/clang/ASTMatchers/ASTMatchers.h:4084
+return false;
+  return InnerMatcher.matches(*Arg->IgnoreParenImpCasts(), Finder, Builder);
 }

steveire wrote:
> aaron.ballman wrote:
> > Huh, I never noticed that we implicitly are ignoring parens and implicit 
> > casts for this (without checking the traversal mode or documenting the 
> > behavior!). That seems less-than-ideal in some ways. (No change required, I 
> > only noticed it because it made me think through whether we need it on the 
> > `isa<>` check above, which we don't.)
> Yes, I think calls to `ignore*` like this within matcher implementations 
> should be removed, giving the user control instead.
I agree. I'm a little bit worried about what will break when we make the 
change, but I think that model is the more defensible one. (It looks like there 
are a handful of similar cases in ASTMatchers.h, so we should try to hit them 
all).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D90984

___

[PATCH] D91121: [InferAddrSpace] Teach to handle assumed address space.

2020-11-16 Thread Michael Liao via Phabricator via cfe-commits
hliao marked 3 inline comments as done.
hliao added a comment.

Kindly ping for review.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91121

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


[PATCH] D90892: [AIX][FE] Support constructor/destructor attribute

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

Update testcases;


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

https://reviews.llvm.org/D90892

Files:
  clang/lib/CodeGen/CGDeclCXX.cpp
  clang/lib/CodeGen/CodeGenFunction.h
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/lib/CodeGen/CodeGenModule.h
  clang/lib/CodeGen/ItaniumCXXABI.cpp
  clang/lib/Sema/SemaDeclAttr.cpp
  clang/test/CodeGen/aix-constructor-attribute.c
  clang/test/CodeGen/aix-constructor-attribute.cpp
  clang/test/CodeGen/aix-destructor-attribute.c
  clang/test/CodeGen/aix-destructor-attribute.cpp
  clang/test/CodeGenCXX/aix-constructor-attribute.cpp
  clang/test/CodeGenCXX/aix-destructor-attribute.cpp
  clang/test/CodeGenCXX/aix-sinit-register-global-dtors-with-atexit.cpp

Index: clang/test/CodeGenCXX/aix-sinit-register-global-dtors-with-atexit.cpp
===
--- clang/test/CodeGenCXX/aix-sinit-register-global-dtors-with-atexit.cpp
+++ /dev/null
@@ -1,14 +0,0 @@
-// RUN: not %clang_cc1 -triple powerpc-ibm-aix-xcoff -S -emit-llvm -x c++ \
-// RUN: -fregister-global-dtors-with-atexit < %s 2>&1 | \
-// RUN:   FileCheck %s
-
-// RUN: not %clang_cc1 -triple powerpc64-ibm-aix-xcoff -S -emit-llvm -x c++ \
-// RUN: -fregister-global-dtors-with-atexit < %s 2>&1 | \
-// RUN:   FileCheck %s
-
-struct T {
-  T();
-  ~T();
-} t;
-
-// CHECK: error in backend: register global dtors with atexit() is not supported yet
Index: clang/test/CodeGenCXX/aix-destructor-attribute.cpp
===
--- /dev/null
+++ clang/test/CodeGenCXX/aix-destructor-attribute.cpp
@@ -0,0 +1,90 @@
+// RUN: %clang_cc1 -triple powerpc-ibm-aix-xcoff -x c++ -emit-llvm \
+// RUN: -fno-use-cxa-atexit < %s | \
+// RUN:   FileCheck --check-prefix=NO-REGISTER %s
+// RUN: %clang_cc1 -triple powerpc64-ibm-aix-xcoff -x c++ -emit-llvm \
+// RUN: -fno-use-cxa-atexit < %s | \
+// RUN:   FileCheck --check-prefix=NO-REGISTER %s
+
+// RUN: %clang_cc1 -triple powerpc-ibm-aix-xcoff -x c++ -emit-llvm \
+// RUN: -fno-use-cxa-atexit -fregister-global-dtors-with-atexit < %s | \
+// RUN:   FileCheck --check-prefix=REGISTER %s
+// RUN: %clang_cc1 -triple powerpc64-ibm-aix-xcoff -x c++ -emit-llvm \
+// RUN: -fno-use-cxa-atexit -fregister-global-dtors-with-atexit < %s | \
+// RUN:   FileCheck --check-prefix=REGISTER %s
+
+struct test {
+  test();
+  ~test();
+} t;
+
+int bar() __attribute__((destructor(100)));
+int bar2() __attribute__((destructor(65535)));
+int bar3(int) __attribute__((destructor(65535)));
+
+int bar() {
+  return 1;
+}
+
+int bar2() {
+  return 2;
+}
+
+int bar3(int a) {
+  return a;
+}
+
+// NO-REGISTER: @llvm.global_ctors = appending global [1 x { i32, void ()*, i8* }] [{ i32, void ()*, i8* } { i32 65535, void ()* @_GLOBAL__sub_I__, i8* null }]
+// NO-REGISTER: @llvm.global_dtors = appending global [4 x { i32, void ()*, i8* }] [{ i32, void ()*, i8* } { i32 100, void ()* bitcast (i32 ()* @_Z3barv to void ()*), i8* null }, { i32, void ()*, i8* } { i32 65535, void ()* bitcast (i32 ()* @_Z4bar2v to void ()*), i8* null }, { i32, void ()*, i8* } { i32 65535, void ()* bitcast (i32 (i32)* @_Z4bar3i to void ()*), i8* null }, { i32, void ()*, i8* } { i32 65535, void ()* @_GLOBAL__D_a, i8* null }]
+
+// REGISTER: @llvm.global_ctors = appending global [3 x { i32, void ()*, i8* }] [{ i32, void ()*, i8* } { i32 65535, void ()* @_GLOBAL__sub_I__, i8* null }, { i32, void ()*, i8* } { i32 100, void ()* @__GLOBAL_init_100, i8* null }, { i32, void ()*, i8* } { i32 65535, void ()* @__GLOBAL_init_65535, i8* null }]
+// REGISTER: @llvm.global_dtors = appending global [3 x { i32, void ()*, i8* }] [{ i32, void ()*, i8* } { i32 65535, void ()* @_GLOBAL__D_a, i8* null }, { i32, void ()*, i8* } { i32 100, void ()* @__GLOBAL_cleanup_100, i8* null }, { i32, void ()*, i8* } { i32 65535, void ()* @__GLOBAL_cleanup_65535, i8* null }]
+
+// REGISTER: define internal void @__GLOBAL_init_100() [[ATTR:#[0-9]+]] {
+// REGISTER: entry:
+// REGISTER:   %0 = call i32 @atexit(void ()* bitcast (i32 ()* @_Z3barv to void ()*))
+// REGISTER:   ret void
+// REGISTER: }
+
+// REGISTER: define internal void @__GLOBAL_init_65535() [[ATTR:#[0-9]+]] {
+// REGISTER: entry:
+// REGISTER:   %0 = call i32 @atexit(void ()* bitcast (i32 ()* @_Z4bar2v to void ()*))
+// REGISTER:   %1 = call i32 @atexit(void ()* bitcast (i32 (i32)* @_Z4bar3i to void ()*))
+// REGISTER:   ret void
+// REGISTER: }
+
+// REGISTER: define internal void @__GLOBAL_cleanup_100() [[ATTR:#[0-9]+]] {
+// REGISTER: entry:
+// REGISTER:   %0 = call i32 @unatexit(void ()* bitcast (i32 ()* @_Z3barv to void ()*))
+// REGISTER:   %needs_destruct = icmp eq i32 %0, 0
+// REGISTER:   br i1 %needs_destruct, label %destruct.call, label %destruct.end
+
+// REGISTER: destruct.call:
+// REGISTER:   call void bitcast (i32 ()* @_Z3barv to void ()*)()
+// 

[PATCH] D91428: Add support for multiple program address spaces

2020-11-16 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert added a subscriber: tianshilei1992.
jdoerfert requested changes to this revision.
jdoerfert added a comment.
This revision now requires changes to proceed.

I'll be on the lookout for the RFC. There, and in an updated commit message, 
you have to provide more details.

http://lists.llvm.org/pipermail/llvm-dev/2020-July/143808.html is related as 
well.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91428

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


[PATCH] D91104: APINotes: add property models for YAML attributes

2020-11-16 Thread Saleem Abdulrasool via Phabricator via cfe-commits
compnerd added a comment.

Ping; I'd let to get this sorted out so I can continue to make progress towards 
serialization and deserialization.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91104

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


[PATCH] D90892: [AIX][FE] Support constructor/destructor attribute

2020-11-16 Thread Xiangling Liao via Phabricator via cfe-commits
Xiangling_L marked 5 inline comments as done.
Xiangling_L added inline comments.



Comment at: clang/test/CodeGen/aix-constructor-attribute.cpp:8
 
-int foo() __attribute__((constructor(180)));
+// CHECK: @llvm.global_ctors = appending global [3 x { i32, void ()*, i8* }] 
[{ i32, void ()*, i8* } { i32 65535, void ()* bitcast (i32 ()* @foo3 to void 
()*), i8* null }, { i32, void ()*, i8* } { i32 180, void ()* bitcast (i32 ()* 
@foo2 to void ()*), i8* null }, { i32, void ()*, i8* } { i32 180, void ()* 
bitcast (i32 ()* @foo to void ()*), i8* null }]
 

sfertile wrote:
> Did you mean for this test to be a C or C++ test? If it is meant to be C++ it 
> needs to mangle the function names, but considering the director it is in and 
> the fact we have the same test in CodeGenCXX directory I expect this was 
> meant to be C in which case it needs a `.c` extension and lose the `-x c++` 
> in the run steps.
Thanks for pointing this out to me, I should've changed the file extension when 
I copied this testcase from CXX testcases.



Comment at: clang/test/CodeGenCXX/aix-destructor-attribute.cpp:1
+// RUN: %clang_cc1 -triple powerpc-ibm-aix-xcoff -x c++ -emit-llvm \
+// RUN: -fno-use-cxa-atexit < %s | \

sfertile wrote:
> Can I ask why this is added as a new file? Its the same test as 
> `aix-sinit-register-global-dtors-with-atexit.cpp` but without using 
> `-fregister-global-dtors-with-atexit`. I suggest combining the 2.
Agree, it makes more sense to combine two. I tried to make testcases look 
cleaner by splitting them.


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

https://reviews.llvm.org/D90892

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


[PATCH] D91546: [AMDGPU] Add option -munsafe-fp-atomics

2020-11-16 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl created this revision.
yaxunl added reviewers: tra, rjmccall, arsenm.
Herald added subscribers: dang, kerbowa, jfb, t-tye, tpr, dstuttard, nhaehnle, 
jvesely, kzhuravl.
yaxunl requested review of this revision.
Herald added a subscriber: wdng.

Add an option -munsafe-fp-atomics for AMDGPU target.

When enabled, clang adds function attribute "amdgpu-unsafe-fp-atomics"
to any functions for amdgpu target. This allows amdgpu backend to use
unsafe fp atomic instructions in these functions.


https://reviews.llvm.org/D91546

Files:
  clang/include/clang/Basic/TargetInfo.h
  clang/include/clang/Basic/TargetOptions.h
  clang/include/clang/Driver/Options.td
  clang/lib/Basic/TargetInfo.cpp
  clang/lib/Basic/Targets/AMDGPU.cpp
  clang/lib/CodeGen/TargetInfo.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/test/CodeGenCUDA/amdgpu-func-attrs.cu
  clang/test/Driver/hip-options.hip

Index: clang/test/Driver/hip-options.hip
===
--- clang/test/Driver/hip-options.hip
+++ clang/test/Driver/hip-options.hip
@@ -31,3 +31,7 @@
 // HOST-NOT: clang{{.*}} "-fcuda-is-device" {{.*}} "-debug-info-kind={{.*}}"
 // HOST-NOT: clang{{.*}} "-fcuda-is-device" {{.*}} "-debug-info-kind={{.*}}"
 // HOST: clang{{.*}} "-debug-info-kind={{.*}}"
+
+// RUN: %clang -### -nogpuinc -nogpulib -munsafe-fp-atomics \
+// RUN:   --cuda-gpu-arch=gfx906  %s 2>&1 | FileCheck -check-prefix=UNSAFE-FP-ATOMICS %s
+// UNSAFE-FP-ATOMICS: clang{{.*}} "-triple" "amdgcn-amd-amdhsa" {{.*}} "-munsafe-fp-atomics"
Index: clang/test/CodeGenCUDA/amdgpu-func-attrs.cu
===
--- /dev/null
+++ clang/test/CodeGenCUDA/amdgpu-func-attrs.cu
@@ -0,0 +1,22 @@
+// RUN: %clang_cc1 -triple amdgcn-amd-amdhsa \
+// RUN: -fcuda-is-device -emit-llvm -o - -x hip %s \
+// RUN: | FileCheck -check-prefixes=NO-UNSAFE-FP-ATOMICS %s
+// RUN: %clang_cc1 -triple amdgcn-amd-amdhsa \
+// RUN: -fcuda-is-device -emit-llvm -o - -x hip %s \
+// RUN: -munsafe-fp-atomics \
+// RUN: | FileCheck -check-prefixes=UNSAFE-FP-ATOMICS %s
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -emit-llvm \
+// RUN: -o - -x hip %s -munsafe-fp-atomics \
+// RUN: | FileCheck -check-prefix=NO-UNSAFE-FP-ATOMICS %s
+
+#include "Inputs/cuda.h"
+
+__device__ void test() {
+// UNSAFE-FP-ATOMICS: define void @_Z4testv() [[ATTR:#[0-9]+]]
+}
+
+
+// Make sure this is silently accepted on other targets.
+// NO-UNSAFE-FP-ATOMICS-NOT: "amdgpu-unsafe-fp-atomics"
+
+// UNSAFE-FP-ATOMICS-DAG: attributes [[ATTR]] = {{.*}}"amdgpu-unsafe-fp-atomics"="true"
Index: clang/lib/Frontend/CompilerInvocation.cpp
===
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -3719,6 +3719,9 @@
   Opts.ForceEnableInt128 = Args.hasArg(OPT_fforce_enable_int128);
   Opts.NVPTXUseShortPointers = Args.hasFlag(
   options::OPT_fcuda_short_ptr, options::OPT_fno_cuda_short_ptr, false);
+  Opts.AllowAMDGPUUnsafeFPAtomics =
+  Args.hasFlag(options::OPT_munsafe_fp_atomics,
+   options::OPT_mno_unsafe_fp_atomics, false);
   if (Arg *A = Args.getLastArg(options::OPT_target_sdk_version_EQ)) {
 llvm::VersionTuple Version;
 if (Version.tryParse(A->getValue()))
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -6217,6 +6217,11 @@
   }
 
   HandleAmdgcnLegacyOptions(D, Args, CmdArgs);
+  if (Triple.isAMDGPU()) {
+if (Args.hasFlag(options::OPT_munsafe_fp_atomics,
+ options::OPT_mno_unsafe_fp_atomics))
+  CmdArgs.push_back("-munsafe-fp-atomics");
+  }
 
   // For all the host OpenMP offloading compile jobs we need to pass the targets
   // information using -fopenmp-targets= option.
Index: clang/lib/CodeGen/TargetInfo.cpp
===
--- clang/lib/CodeGen/TargetInfo.cpp
+++ clang/lib/CodeGen/TargetInfo.cpp
@@ -9080,6 +9080,9 @@
 if (NumVGPR != 0)
   F->addFnAttr("amdgpu-num-vgpr", llvm::utostr(NumVGPR));
   }
+
+  if (M.getContext().getTargetInfo().allowAMDGPUUnsafeFPAtomics())
+F->addFnAttr("amdgpu-unsafe-fp-atomics", "true");
 }
 
 unsigned AMDGPUTargetCodeGenInfo::getOpenCLKernelCallingConv() const {
Index: clang/lib/Basic/Targets/AMDGPU.cpp
===
--- clang/lib/Basic/Targets/AMDGPU.cpp
+++ clang/lib/Basic/Targets/AMDGPU.cpp
@@ -323,6 +323,7 @@
   HasLegalHalfType = true;
   HasFloat16 = true;
   WavefrontSize = GPUFeatures & llvm::AMDGPU::FEATURE_WAVE32 ? 32 : 64;
+  AllowAMDGPUUnsafeFPAtomics = Opts.AllowAMDGPUUnsafeFPAtomics;
 
   // Set pointer width and alignment for target address space 0.
   PointerWidth = PointerAlign = 

[PATCH] D91428: Add support for multiple program address spaces

2020-11-16 Thread Paulo Matos via Phabricator via cfe-commits
pmatos updated this revision to Diff 305521.
pmatos added a comment.

Fix type check.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91428

Files:
  clang/lib/CodeGen/CGException.cpp
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/lib/CodeGen/CodeGenTypes.cpp
  llvm/docs/LangRef.rst
  llvm/include/llvm/CodeGen/TargetLowering.h
  llvm/include/llvm/IR/DataLayout.h
  llvm/include/llvm/Target/TargetMachine.h
  llvm/lib/AsmParser/LLParser.cpp
  llvm/lib/AsmParser/LLParser.h
  llvm/lib/Bitcode/Reader/BitcodeReader.cpp
  llvm/lib/IR/AsmWriter.cpp
  llvm/lib/IR/DataLayout.cpp
  llvm/lib/IR/Function.cpp
  llvm/lib/IR/Module.cpp
  llvm/lib/IR/Verifier.cpp
  llvm/lib/Transforms/IPO/LowerTypeTests.cpp
  llvm/lib/Transforms/IPO/WholeProgramDevirt.cpp
  llvm/test/Assembler/function-address_spaces.ll

Index: llvm/test/Assembler/function-address_spaces.ll
===
--- /dev/null
+++ llvm/test/Assembler/function-address_spaces.ll
@@ -0,0 +1,30 @@
+; RUN: llvm-as < %s | llvm-dis | FileCheck  %s
+
+; specifying explicitly P:0 (although it's the default)
+; P:1 specifies an extra address space for code where funcrefs live
+target datalayout = "e-m:e-p:32:32-i64:64-n32:64-S128-ni:1-P0-P1"
+
+; square and double_square are in addrspace(0)
+define i32 @square(i32 %0) {
+; CHECK: define i32 @square(i32 %0) addrspace(0) {
+   %2 = mul nsw i32 %0, %0
+   ret i32 %2
+}
+
+define i32 @double_square(i32 %0) {
+; CHECK: define i32 @double_square(i32 %0) addrspace(0) {
+   %2 = shl i32 %0, 1
+   %3 = mul i32 %2, %0
+   ret i32 %3
+}
+
+; funcref is a pointer to a function in addrspace(1)
+; called in call_funcref
+%func = type void ()
+%funcref = type %func addrspace(1)*
+
+define void @call_funcref(%funcref %ref) {
+; CHECK: define void @call_funcref(void () addrspace(1)* %ref) addrspace(0) {
+   call void %ref()
+   ret void
+}
Index: llvm/lib/Transforms/IPO/WholeProgramDevirt.cpp
===
--- llvm/lib/Transforms/IPO/WholeProgramDevirt.cpp
+++ llvm/lib/Transforms/IPO/WholeProgramDevirt.cpp
@@ -1220,12 +1220,12 @@
   Function *JT;
   if (isa(Slot.TypeID)) {
 JT = Function::Create(FT, Function::ExternalLinkage,
-  M.getDataLayout().getProgramAddressSpace(),
+  M.getDataLayout().getDefaultProgramAddressSpace(),
   getGlobalName(Slot, {}, "branch_funnel"), );
 JT->setVisibility(GlobalValue::HiddenVisibility);
   } else {
 JT = Function::Create(FT, Function::InternalLinkage,
-  M.getDataLayout().getProgramAddressSpace(),
+  M.getDataLayout().getDefaultProgramAddressSpace(),
   "branch_funnel", );
   }
   JT->addAttribute(1, Attribute::Nest);
Index: llvm/lib/Transforms/IPO/LowerTypeTests.cpp
===
--- llvm/lib/Transforms/IPO/LowerTypeTests.cpp
+++ llvm/lib/Transforms/IPO/LowerTypeTests.cpp
@@ -1276,12 +1276,12 @@
 void LowerTypeTestsModule::moveInitializerToModuleConstructor(
 GlobalVariable *GV) {
   if (WeakInitializerFn == nullptr) {
-WeakInitializerFn = Function::Create(
-FunctionType::get(Type::getVoidTy(M.getContext()),
-  /* IsVarArg */ false),
-GlobalValue::InternalLinkage,
-M.getDataLayout().getProgramAddressSpace(),
-"__cfi_global_var_init", );
+WeakInitializerFn =
+Function::Create(FunctionType::get(Type::getVoidTy(M.getContext()),
+   /* IsVarArg */ false),
+ GlobalValue::InternalLinkage,
+ M.getDataLayout().getDefaultProgramAddressSpace(),
+ "__cfi_global_var_init", );
 BasicBlock *BB =
 BasicBlock::Create(M.getContext(), "entry", WeakInitializerFn);
 ReturnInst::Create(M.getContext(), BB);
@@ -1517,12 +1517,11 @@
   for (unsigned I = 0; I != Functions.size(); ++I)
 GlobalLayout[Functions[I]] = I * EntrySize;
 
-  Function *JumpTableFn =
-  Function::Create(FunctionType::get(Type::getVoidTy(M.getContext()),
- /* IsVarArg */ false),
-   GlobalValue::PrivateLinkage,
-   M.getDataLayout().getProgramAddressSpace(),
-   ".cfi.jumptable", );
+  Function *JumpTableFn = Function::Create(
+  FunctionType::get(Type::getVoidTy(M.getContext()),
+/* IsVarArg */ false),
+  GlobalValue::PrivateLinkage,
+  M.getDataLayout().getDefaultProgramAddressSpace(), ".cfi.jumptable", );
   ArrayType *JumpTableType =
   ArrayType::get(getJumpTableEntryType(), Functions.size());
   auto JumpTable =
@@ -1962,7 +1961,8 @@
   F = Function::Create(
   

[PATCH] D91544: [clang-tidy] Allow `TransformerClangTidyCheck` clients to set the rule directly.

2020-11-16 Thread Yitzhak Mandelbaum via Phabricator via cfe-commits
ymandel created this revision.
ymandel added a reviewer: gribozavr2.
Herald added a subscriber: xazax.hun.
Herald added a project: clang.
ymandel requested review of this revision.

Adds support for setting the `Rule` field. In the process, refactors the code 
that accesses that field and adds a constructor that doesn't require a rule 
argument.

This feature is needed by checks that must set the rule *after* the check class
is constructed. For example, any check that maintains state to be accessed from
the rule needs this support. Since the object's fields are not initialized when
the superclass constructor is called, they can't be (safely) captured by a rule
passed to the existing constructor.  This patch allows constructing the check
superclass fully before setting the rule.

As a driveby fix, removed the "optional" from the rule, since rules are just a
set of cases, so empty rules are evident.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D91544

Files:
  clang-tools-extra/clang-tidy/utils/TransformerClangTidyCheck.cpp
  clang-tools-extra/clang-tidy/utils/TransformerClangTidyCheck.h

Index: clang-tools-extra/clang-tidy/utils/TransformerClangTidyCheck.h
===
--- clang-tools-extra/clang-tidy/utils/TransformerClangTidyCheck.h
+++ clang-tools-extra/clang-tidy/utils/TransformerClangTidyCheck.h
@@ -38,6 +38,8 @@
 //  includes.
 class TransformerClangTidyCheck : public ClangTidyCheck {
 public:
+  TransformerClangTidyCheck(StringRef Name, ClangTidyContext *Context);
+
   // \p MakeRule generates the rewrite rule to be used by the check, based on
   // the given language and clang-tidy options. It can return \c None to handle
   // cases where the options disable the check.
@@ -68,8 +70,11 @@
   /// the overridden method.
   void storeOptions(ClangTidyOptions::OptionMap ) override;
 
+  /// Set the rule that this check implements.
+  void setRule(transformer::RewriteRule R);
+
 private:
-  Optional Rule;
+  transformer::RewriteRule Rule;
   IncludeInserter Inserter;
 };
 
Index: clang-tools-extra/clang-tidy/utils/TransformerClangTidyCheck.cpp
===
--- clang-tools-extra/clang-tidy/utils/TransformerClangTidyCheck.cpp
+++ clang-tools-extra/clang-tidy/utils/TransformerClangTidyCheck.cpp
@@ -21,6 +21,18 @@
 }
 #endif
 
+static void verifyRule(const RewriteRule ) {
+  assert(llvm::all_of(Rule.Cases, hasExplanation) &&
+ "clang-tidy checks must have an explanation by default;"
+ " explicitly provide an empty explanation if none is desired");
+}
+
+TransformerClangTidyCheck::TransformerClangTidyCheck(StringRef Name,
+ ClangTidyContext *Context)
+: ClangTidyCheck(Name, Context),
+  Inserter(
+  Options.getLocalOrGlobal("IncludeStyle", IncludeSorter::IS_LLVM)) {}
+
 // This constructor cannot dispatch to the simpler one (below), because, in
 // order to get meaningful results from `getLangOpts` and `Options`, we need the
 // `ClangTidyCheck()` constructor to have been called. If we were to dispatch,
@@ -31,24 +43,21 @@
 const OptionsView &)>
 MakeRule,
 StringRef Name, ClangTidyContext *Context)
-: ClangTidyCheck(Name, Context), Rule(MakeRule(getLangOpts(), Options)),
-  Inserter(
-  Options.getLocalOrGlobal("IncludeStyle", IncludeSorter::IS_LLVM)) {
-  if (Rule)
-assert(llvm::all_of(Rule->Cases, hasExplanation) &&
-   "clang-tidy checks must have an explanation by default;"
-   " explicitly provide an empty explanation if none is desired");
+: TransformerClangTidyCheck(Name, Context) {
+  if (Optional R = MakeRule(getLangOpts(), Options))
+setRule(std::move(*R));
 }
 
 TransformerClangTidyCheck::TransformerClangTidyCheck(RewriteRule R,
  StringRef Name,
  ClangTidyContext *Context)
-: ClangTidyCheck(Name, Context), Rule(std::move(R)),
-  Inserter(
-  Options.getLocalOrGlobal("IncludeStyle", IncludeSorter::IS_LLVM)) {
-  assert(llvm::all_of(Rule->Cases, hasExplanation) &&
- "clang-tidy checks must have an explanation by default;"
- " explicitly provide an empty explanation if none is desired");
+: TransformerClangTidyCheck(Name, Context) {
+  setRule(std::move(R));
+}
+
+void TransformerClangTidyCheck::setRule(transformer::RewriteRule R) {
+  verifyRule(R);
+  Rule = std::move(R);
 }
 
 void TransformerClangTidyCheck::registerPPCallbacks(
@@ -58,8 +67,8 @@
 
 void TransformerClangTidyCheck::registerMatchers(
 ast_matchers::MatchFinder *Finder) {
-  if (Rule)
-for (auto  : transformer::detail::buildMatchers(*Rule))
+  if (!Rule.Cases.empty())
+for (auto  : transformer::detail::buildMatchers(Rule))
   Finder->addDynamicMatcher(Matcher, this);
 

[PATCH] D90188: Add support for attribute 'using_if_exists'

2020-11-16 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

In D90188#2394361 , @erik.pilkington 
wrote:

> Add support for C++11-style attributes on using-declarations.

FWIW, it'd be a bit easier if those changes were split off into their own 
patch, as they're orthogonal to `using_if_exists`.




Comment at: clang/include/clang/Basic/AttrDocs.td:5351
+the availability of those declarations is difficult or impossible to detect at
+compile time with the preprocessor.
+  }];

Do you think the docs should call out that using the C++ spelling on a `using` 
declaration is currently a Clang extension? It's a bit of an odd place to put 
that information, but I don't know of where else to mention that this attribute 
is nonportable in a few different ways.



Comment at: clang/include/clang/Basic/DiagnosticParseKinds.td:689
 def err_attributes_not_allowed : Error<"an attribute list cannot appear here">;
+def ext_cxx11_attr_placement : Extension<
+  "C++ does not allow an attribute list to appear here">,

I'm not certain what @rsmith thinks, but I think this should be `ExtWarn` and 
have the `DefaultIgnore` removed -- this is a conforming extension of something 
that's nonportable even in the absence of any attributes in the attribute list. 
e.g., `[[]] using foo::bar;``` is not portable to parse.



Comment at: clang/include/clang/Basic/DiagnosticParseKinds.td:690
+def ext_cxx11_attr_placement : Extension<
+  "C++ does not allow an attribute list to appear here">,
+  InGroup>, DefaultIgnore;

I think that should say `ISO C++` instead of just `C++` to make it clear that 
this is a standards thing, not a C++-as-it-really-is thing.



Comment at: clang/include/clang/Serialization/ASTBitCodes.h:1364
+  /// An UnresolvedUsingIfExistsDecl record.
+  DECL_UNRESOLVED_USING_IF_EXISTS,
+

Does this mean you need to bump `VERSION_MAJOR` as well?



Comment at: clang/test/Parser/cxx0x-attributes.cpp:160
 template using U [[]] = T;
-using ns::i [[]]; // expected-error {{an attribute list cannot appear here}}
+using ns::i [[]];
 using [[]] ns::i; // expected-error {{an attribute list cannot appear here}}

Can you also add a test for `using foo [[]], bar []]];` syntax?



Comment at: clang/test/SemaCXX/using-if-exists-attr.cpp:9-17
+using NS::x [[clang::using_if_exists]]; // expected-warning{{C++ does not 
allow an attribute list to appear here}}
+
+[[clang::using_if_exists]] // expected-warning{{C++ does not allow an 
attribute list to appear here}}
+using NS::not_there, NS::not_there2;
+
+using NS::not_there3, // expected-error {{no member named 'not_there3' in 
namespace 'NS'}}
+  NS::not_there4 [[clang::using_if_exists]]; // expected-warning{{C++ does 
not allow an attribute list to appear here}}

These test cases look like they belong in a `Parser` test not a `SemaCXX` test.


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

https://reviews.llvm.org/D90188

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


[PATCH] D90984: Update matchers to be traverse-aware

2020-11-16 Thread Stephen Kelly via Phabricator via cfe-commits
steveire added inline comments.



Comment at: clang/include/clang/ASTMatchers/ASTMatchers.h:3115
+
+  if (!Finder->isTraversalAsIs() && (*MatchIt)->isImplicit())
+return false;

aaron.ballman wrote:
> If the traversal is not `AsIs`, that doesn't mean it's 
> `IgnoreUnlessSpelledInSource` -- it could be 
> `IgnoreImplicitCastsAndParentheses`, right? So I think the logic for some of 
> these AST matchers is incorrect when in `IgnoreImplicitCastsAndParentheses` 
> traversal mode and should be double-checked. We should probably add some 
> extra test coverage for that mode.
As far as I know, the problem of implicit nodes has been known for a long time. 
Adding calls to `IgnoreParenImpCasts()` in certain places like `hasArgument` 
was one attempt at making the implicit nodes less convenient for users. As far 
as I know, `IgnoreImplicitCastsAndParentheses` was just another attempt at the 
same thing. I must have discovered that by reading code history at some point. 
Both previous attempts didn't go far enough to actually solve the problem, but 
`IgnoreUnlessSpelledInSource` does go all the way, and `traverse` puts control 
in the hands of the user. D20801 at least seems to have been an attempt to put 
control back in the hands of the user. And it was a follow-up to D18243.

So, once this and D90982 are merged, I think it makes sense to start to remove 
`IgnoreImplicitCastsAndParentheses` entirely. It is legacy, incompletely useful 
and just causes some mess in the code. 

Two modes aught to be enough for anybody.



Comment at: clang/include/clang/ASTMatchers/ASTMatchers.h:4084
+return false;
+  return InnerMatcher.matches(*Arg->IgnoreParenImpCasts(), Finder, Builder);
 }

aaron.ballman wrote:
> Huh, I never noticed that we implicitly are ignoring parens and implicit 
> casts for this (without checking the traversal mode or documenting the 
> behavior!). That seems less-than-ideal in some ways. (No change required, I 
> only noticed it because it made me think through whether we need it on the 
> `isa<>` check above, which we don't.)
Yes, I think calls to `ignore*` like this within matcher implementations should 
be removed, giving the user control instead.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D90984

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


[PATCH] D91543: [clang-tidy] Improving bugprone-sizeof-expr check.

2020-11-16 Thread BalƔzs KƩri via Phabricator via cfe-commits
balazske created this revision.
Herald added subscribers: cfe-commits, martong, gamesh411, Szelethus, dkrupp, 
xazax.hun, whisperity.
Herald added a project: clang.
balazske requested review of this revision.

Do not warn for "pointer to aggregate" in a `sizeof(A) / sizeof(A[0])`
expression if `A` is an array of pointers. This is the usual way of
calculating the array length even if the array is of pointers.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D91543

Files:
  clang-tools-extra/clang-tidy/bugprone/SizeofExpressionCheck.cpp
  clang-tools-extra/test/clang-tidy/checkers/bugprone-sizeof-expression.cpp


Index: clang-tools-extra/test/clang-tidy/checkers/bugprone-sizeof-expression.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/bugprone-sizeof-expression.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/bugprone-sizeof-expression.cpp
@@ -276,6 +276,10 @@
   int A[] = {1, 2, 3, 4};
   static const char str[] = "hello";
   static const char* ptr[] { "aaa", "bbb", "ccc" };
+  typedef C *CA10[10];
+  C *PtrArray[10];
+  CA10 PtrArray1;
+
   int sum = 0;
   if (sizeof(A) < 10)
 sum += sizeof(A);
@@ -293,5 +297,7 @@
   sum += sizeof(str) / sizeof(str[0]);
   sum += sizeof(ptr) / sizeof(ptr[0]);
   sum += sizeof(ptr) / sizeof(*(ptr));
+  sum += sizeof(PtrArray) / sizeof(PtrArray[0]);
+  sum += sizeof(PtrArray) / sizeof(PtrArray1[0]);
   return sum;
 }
Index: clang-tools-extra/clang-tidy/bugprone/SizeofExpressionCheck.cpp
===
--- clang-tools-extra/clang-tidy/bugprone/SizeofExpressionCheck.cpp
+++ clang-tools-extra/clang-tidy/bugprone/SizeofExpressionCheck.cpp
@@ -132,6 +132,7 @@
  this);
 
   // Detect sizeof(ptr) where ptr points to an aggregate (i.e. sizeof()).
+  // Do not find it if RHS of a 'sizeof(arr) / sizeof(arr[0])' expression.
   const auto ArrayExpr = expr(ignoringParenImpCasts(
   expr(hasType(qualType(hasCanonicalType(arrayType()));
   const auto ArrayCastExpr = expr(anyOf(
@@ -151,13 +152,31 @@
   hasType(qualType(hasCanonicalType(PointerToStructType))),
   unless(cxxThisExpr();
 
-  Finder->addMatcher(
-  expr(anyOf(sizeOfExpr(has(expr(ignoringParenImpCasts(
-   anyOf(ArrayCastExpr, PointerToArrayExpr, StructAddrOfExpr,
- PointerToStructExpr),
-sizeOfExpr(has(PointerToStructType
-  .bind("sizeof-pointer-to-aggregate"),
-  this);
+  const auto ArrayOfPointersExpr = expr(ignoringParenImpCasts(expr(hasType(
+  qualType(hasCanonicalType(arrayType(hasElementType(pointerType()))
+.bind("type-of-array-of-pointers")));
+  const auto ArrayOfSamePointersExpr =
+  expr(ignoringParenImpCasts(expr(hasType(qualType(hasCanonicalType(
+  arrayType(equalsBoundNode("type-of-array-of-pointers";
+  const auto ZeroLiteral =
+  expr(ignoringParenImpCasts(integerLiteral(equals(0;
+  const auto ArrayOfSamePointersZeroSubscriptExpr =
+  expr(ignoringParenImpCasts(arraySubscriptExpr(
+  hasBase(ArrayOfSamePointersExpr), hasIndex(ZeroLiteral;
+  const auto ArrayLengthExprDenom =
+  expr(hasParent(expr(ignoringParenImpCasts(
+   binaryOperator(hasOperatorName("/"),
+  hasLHS(expr(ignoringParenImpCasts(expr(
+  sizeOfExpr(has(ArrayOfPointersExpr)),
+   sizeOfExpr(has(ArrayOfSamePointersZeroSubscriptExpr)));
+
+  
Finder->addMatcher(expr(anyOf(sizeOfExpr(has(expr(ignoringParenImpCasts(anyOf(
+ArrayCastExpr, PointerToArrayExpr,
+StructAddrOfExpr, PointerToStructExpr),
+sizeOfExpr(has(PointerToStructType))),
+  unless(ArrayLengthExprDenom))
+ .bind("sizeof-pointer-to-aggregate"),
+ this);
 
   // Detect expression like: sizeof(epxr) <= k for a suspicious constant 'k'.
   if (WarnOnSizeOfCompareToConstant) {


Index: clang-tools-extra/test/clang-tidy/checkers/bugprone-sizeof-expression.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/bugprone-sizeof-expression.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/bugprone-sizeof-expression.cpp
@@ -276,6 +276,10 @@
   int A[] = {1, 2, 3, 4};
   static const char str[] = "hello";
   static const char* ptr[] { "aaa", "bbb", "ccc" };
+  typedef C *CA10[10];
+  C *PtrArray[10];
+  CA10 PtrArray1;
+
   int sum = 0;
   if (sizeof(A) < 10)
 sum += sizeof(A);
@@ -293,5 +297,7 @@
   sum += sizeof(str) / sizeof(str[0]);
   sum += sizeof(ptr) / sizeof(ptr[0]);
   sum += sizeof(ptr) / sizeof(*(ptr));
+  sum += sizeof(PtrArray) / sizeof(PtrArray[0]);
+  sum += sizeof(PtrArray) / 

[PATCH] D90871: [Sema] Fold VLAs to constant arrays in a few more contexts

2020-11-16 Thread Erik Pilkington via Phabricator via cfe-commits
erik.pilkington updated this revision to Diff 305506.
erik.pilkington added a comment.

Use a bit on Declarator instead of an ad-hoc bool parameter.


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

https://reviews.llvm.org/D90871

Files:
  clang/include/clang/Sema/DeclSpec.h
  clang/lib/Parse/ParseDecl.cpp
  clang/lib/Sema/SemaDecl.cpp
  clang/test/Sema/decl-in-prototype.c
  clang/test/Sema/vla.c
  clang/test/SemaObjC/variable-size-ivar.m

Index: clang/test/SemaObjC/variable-size-ivar.m
===
--- /dev/null
+++ clang/test/SemaObjC/variable-size-ivar.m
@@ -0,0 +1,12 @@
+// RUN: %clang_cc1 -fsyntax-only %s -verify
+
+const int ksize = 42;
+int size = 42;
+
+@interface X
+{
+  int arr1[ksize]; // expected-warning{{variable length array folded to constant array}}
+  int arr2[size]; // expected-error{{instance variables must have a constant size}}
+  int arr3[ksize-43]; // expected-error{{array size is negative}}
+}
+@end
Index: clang/test/Sema/vla.c
===
--- clang/test/Sema/vla.c
+++ clang/test/Sema/vla.c
@@ -100,3 +100,29 @@
 typedef struct {
   char c[pr44406_a]; // expected-warning {{folded to constant array as an extension}}
 } pr44406_s;
+
+void test_fold_to_constant_array() {
+  const int ksize = 4;
+
+  goto jump_over_a1; // expected-error{{cannot jump from this goto statement to its label}}
+  char a1[ksize]; // expected-note{{variable length array}}
+ jump_over_a1:;
+
+  char a2[ksize] = "foo"; // expected-warning{{variable length array folded to constant array as an extension}}
+
+  char a3[ksize] = {}; // expected-warning {{variable length array folded to constant array as an extension}} expected-warning{{use of GNU empty initializer}}
+
+  goto jump_over_a4; // expected-error{{cannot jump from this goto statement to its label}}
+  char a4[ksize][2]; // expected-note{{variable length array}}
+ jump_over_a4:;
+
+  char a5[ksize][2] = {}; // expected-warning {{variable length array folded to constant array as an extension}} expected-warning{{use of GNU empty initializer}}
+
+  int a6[ksize] = {1,2,3,4}; // expected-warning{{variable length array folded to constant array as an extension}}
+
+  // expected-warning@+1{{variable length array folded to constant array as an extension}}
+  int a7[ksize] __attribute__((annotate("foo"))) = {1,2,3,4};
+
+  // expected-warning@+1{{variable length array folded to constant array as an extension}}
+  char a8[2][ksize] = {{1,2,3,4},{4,3,2,1}};
+}
Index: clang/test/Sema/decl-in-prototype.c
===
--- clang/test/Sema/decl-in-prototype.c
+++ clang/test/Sema/decl-in-prototype.c
@@ -49,7 +49,7 @@
 // function.
 enum { BB = 0 };
 void enum_in_fun_in_fun(void (*fp)(enum { AA, BB } e)) { // expected-warning {{will not be visible}}
-  SA(1, AA == 5); // expected-error {{variable-sized object may not be initialized}}
+  SA(1, AA == 5); // expected-warning{{variable length array folded to constant array as an extension}}
   SA(2, BB == 0);
 }
 
Index: clang/lib/Sema/SemaDecl.cpp
===
--- clang/lib/Sema/SemaDecl.cpp
+++ clang/lib/Sema/SemaDecl.cpp
@@ -6023,6 +6023,31 @@
   return FixedTInfo;
 }
 
+/// Attempt to fold a variable-sized type to a constant-sized type, returning
+/// true if it we were successful.
+static bool tryToFixVariablyModifiedVarType(Sema , TypeSourceInfo *,
+QualType , SourceLocation Loc,
+unsigned FailedFoldDiagID) {
+  bool SizeIsNegative;
+  llvm::APSInt Oversized;
+  TypeSourceInfo *FixedTInfo = TryToFixInvalidVariablyModifiedTypeSourceInfo(
+  TInfo, S.Context, SizeIsNegative, Oversized);
+  if (FixedTInfo) {
+S.Diag(Loc, diag::ext_vla_folded_to_constant);
+TInfo = FixedTInfo;
+T = FixedTInfo->getType();
+return true;
+  }
+
+  if (SizeIsNegative)
+S.Diag(Loc, diag::err_typecheck_negative_array_size);
+  else if (Oversized.getBoolValue())
+S.Diag(Loc, diag::err_array_too_large) << Oversized.toString(10);
+  else if (FailedFoldDiagID)
+S.Diag(Loc, FailedFoldDiagID);
+  return false;
+}
+
 /// Register the given locally-scoped extern "C" declaration so
 /// that it can be found later for redeclarations. We include any extern "C"
 /// declaration that is not visible in the translation unit here, not just
@@ -6871,6 +6896,10 @@
   VarTemplateDecl *NewTemplate = nullptr;
   TemplateParameterList *TemplateParams = nullptr;
   if (!getLangOpts().CPlusPlus) {
+if (D.hasInitializer() && R->isVariablyModifiedType())
+  tryToFixVariablyModifiedVarType(*this, TInfo, R, D.getIdentifierLoc(),
+  /*DiagID=*/0);
+
 NewVD = VarDecl::Create(Context, DC, D.getBeginLoc(), D.getIdentifierLoc(),
 II, R, TInfo, SC);
 

[PATCH] D91438: [AArch64] Define __ARM_FEATURE_{CRC32,ATOMICS}

2020-11-16 Thread Andre Vieira via Phabricator via cfe-commits
avieira updated this revision to Diff 305504.
avieira added a comment.

Rebased on top of trunk.


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

https://reviews.llvm.org/D91438

Files:
  clang/lib/Basic/Targets/AArch64.cpp
  clang/lib/Basic/Targets/AArch64.h
  clang/test/Preprocessor/aarch64-target-features.c


Index: clang/test/Preprocessor/aarch64-target-features.c
===
--- clang/test/Preprocessor/aarch64-target-features.c
+++ clang/test/Preprocessor/aarch64-target-features.c
@@ -62,6 +62,8 @@
 // RUN: %clang -target arm64-none-linux-gnu -mcrc -x c -E -dM %s -o - | 
FileCheck --check-prefix=CHECK-CRC32 %s
 // RUN: %clang -target aarch64-none-linux-gnu -march=armv8-a+crc -x c -E -dM 
%s -o - | FileCheck --check-prefix=CHECK-CRC32 %s
 // RUN: %clang -target arm64-none-linux-gnu -march=armv8-a+crc -x c -E -dM %s 
-o - | FileCheck --check-prefix=CHECK-CRC32 %s
+// RUN: %clang -target aarch64-none-linux-gnu -march=armv8.1-a -x c -E -dM %s 
-o - | FileCheck --check-prefix=CHECK-CRC32 %s
+// RUN: %clang -target arm64-none-linux-gnu -march=armv8.1-a -x c -E -dM %s -o 
- | FileCheck --check-prefix=CHECK-CRC32 %s
 // CHECK-CRC32: __ARM_FEATURE_CRC32 1
 
 // RUN: %clang -target aarch64-none-linux-gnu -fno-math-errno 
-fno-signed-zeros\
@@ -451,3 +453,10 @@
 // CHECK-SVE-VECTOR-BITS-512: __ARM_FEATURE_SVE_BITS 512
 // CHECK-SVE-VECTOR-BITS-1024: __ARM_FEATURE_SVE_BITS 1024
 // CHECK-SVE-VECTOR-BITS-2048: __ARM_FEATURE_SVE_BITS 2048
+
+// == Check Largse System Extensions (LSE)
+// RUN: %clang -target aarch64-none-linux-gnu -march=armv8-a+lse -x c -E -dM 
%s -o - | FileCheck --check-prefix=CHECK-LSE %s
+// RUN: %clang -target arm64-none-linux-gnu -march=armv8-a+lse -x c -E -dM %s 
-o - | FileCheck --check-prefix=CHECK-LSE %s
+// RUN: %clang -target aarch64-none-linux-gnu -march=armv8.1-a -x c -E -dM %s 
-o - | FileCheck --check-prefix=CHECK-LSE %s
+// RUN: %clang -target arm64-none-linux-gnu -march=armv8.1-a -x c -E -dM %s -o 
- | FileCheck --check-prefix=CHECK-LSE %s
+// CHECK-LSE: __ARM_FEATURE_ATOMICS 1
Index: clang/lib/Basic/Targets/AArch64.h
===
--- clang/lib/Basic/Targets/AArch64.h
+++ clang/lib/Basic/Targets/AArch64.h
@@ -44,6 +44,7 @@
   bool HasSVE2BitPerm;
   bool HasMatmulFP64;
   bool HasMatmulFP32;
+  bool HasLSE;
 
   llvm::AArch64::ArchKind ArchKind;
 
Index: clang/lib/Basic/Targets/AArch64.cpp
===
--- clang/lib/Basic/Targets/AArch64.cpp
+++ clang/lib/Basic/Targets/AArch64.cpp
@@ -155,8 +155,9 @@
 
 void AArch64TargetInfo::getTargetDefinesARMV81A(const LangOptions ,
 MacroBuilder ) const {
-  // FIXME: Armv8.1 makes __ARM_FEATURE_CRC32 mandatory. Handle it here.
   Builder.defineMacro("__ARM_FEATURE_QRDMX", "1");
+  Builder.defineMacro("__ARM_FEATURE_ATOMICS", "1");
+  Builder.defineMacro("__ARM_FEATURE_CRC32", "1");
 }
 
 void AArch64TargetInfo::getTargetDefinesARMV82A(const LangOptions ,
@@ -176,8 +177,6 @@
 void AArch64TargetInfo::getTargetDefinesARMV84A(const LangOptions ,
 MacroBuilder ) const {
   // Also include the Armv8.3 defines
-  // FIXME: Armv8.4 makes __ARM_FEATURE_ATOMICS, defined in GCC, mandatory.
-  // Add and handle it here.
   getTargetDefinesARMV83A(Opts, Builder);
 }
 
@@ -304,6 +303,9 @@
   if (HasMatMul)
 Builder.defineMacro("__ARM_FEATURE_MATMUL_INT8", "1");
 
+  if (HasLSE)
+Builder.defineMacro("__ARM_FEATURE_ATOMICS", "1");
+
   if (HasBFloat16) {
 Builder.defineMacro("__ARM_FEATURE_BF16", "1");
 Builder.defineMacro("__ARM_FEATURE_BF16_VECTOR_ARITHMETIC", "1");
@@ -416,6 +418,7 @@
   HasSVE2BitPerm = false;
   HasMatmulFP64 = false;
   HasMatmulFP32 = false;
+  HasLSE = false;
 
   ArchKind = llvm::AArch64::ArchKind::ARMV8A;
 
@@ -497,6 +500,8 @@
   HasMatMul = true;
 if (Feature == "+bf16")
   HasBFloat16 = true;
+if (Feature == "+lse")
+  HasLSE = true;
   }
 
   setDataLayout();


Index: clang/test/Preprocessor/aarch64-target-features.c
===
--- clang/test/Preprocessor/aarch64-target-features.c
+++ clang/test/Preprocessor/aarch64-target-features.c
@@ -62,6 +62,8 @@
 // RUN: %clang -target arm64-none-linux-gnu -mcrc -x c -E -dM %s -o - | FileCheck --check-prefix=CHECK-CRC32 %s
 // RUN: %clang -target aarch64-none-linux-gnu -march=armv8-a+crc -x c -E -dM %s -o - | FileCheck --check-prefix=CHECK-CRC32 %s
 // RUN: %clang -target arm64-none-linux-gnu -march=armv8-a+crc -x c -E -dM %s -o - | FileCheck --check-prefix=CHECK-CRC32 %s
+// RUN: %clang -target aarch64-none-linux-gnu -march=armv8.1-a -x c -E -dM %s -o - | FileCheck --check-prefix=CHECK-CRC32 %s
+// RUN: %clang -target arm64-none-linux-gnu -march=armv8.1-a -x c -E -dM %s -o - | FileCheck 

[PATCH] D91195: Add Annotation2MD pass to add !annotate metadata from llvm.global.annotations

2020-11-16 Thread Florian Hahn via Phabricator via cfe-commits
fhahn marked an inline comment as done.
fhahn added a comment.

Thanks Jessica & Francis! I committed the initial version, with a small change 
to only run if the `!annotation` remarks are enabled.




Comment at: llvm/include/llvm/Transforms/IPO/Annotation2Metadata.h:1
+//===- SCCP.h - Sparse Conditional Constant Propagation -*- C++ 
-*-===//
+//

paquette wrote:
> Fix filename in comment?
Done in the final version, thanks!



Comment at: llvm/include/llvm/Transforms/IPO/Annotation2Metadata.h:20
+
+/// Pass to perform interprocedural constant propagation.
+class Annotation2MetadataPass : public PassInfoMixin {

paquette wrote:
> Fix comment
Done in the final version, thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91195

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


[clang] 4369223 - BPF: make __builtin_btf_type_id() return 64bit int

2020-11-16 Thread Yonghong Song via cfe-commits

Author: Yonghong Song
Date: 2020-11-16T07:08:41-08:00
New Revision: 4369223ea73c4b8a3fa9a8a84533125c7d0eea98

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

LOG: BPF: make __builtin_btf_type_id() return 64bit int

Linux kernel recently added support for kernel modules
  https://lore.kernel.org/bpf/20201110011932.3201430-5-and...@kernel.org/

In such cases, a type id in the kernel needs to be presented
as (btf id for modules, btf type id for this module).
Change __builtin_btf_type_id() to return 64bit value
so libbpf can do the above encoding.

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

Added: 


Modified: 
clang/include/clang/Basic/BuiltinsBPF.def
clang/lib/Sema/SemaChecking.cpp
clang/test/CodeGen/builtin-bpf-btf-type-id.c
llvm/include/llvm/IR/IntrinsicsBPF.td
llvm/lib/Target/BPF/BPFPreserveDIType.cpp
llvm/lib/Target/BPF/BTFDebug.cpp
llvm/test/CodeGen/BPF/BTF/builtin-btf-type-id.ll
llvm/test/CodeGen/BPF/CORE/btf-id-duplicate.ll
llvm/test/CodeGen/BPF/optnone-2.ll

Removed: 




diff  --git a/clang/include/clang/Basic/BuiltinsBPF.def 
b/clang/include/clang/Basic/BuiltinsBPF.def
index 04b45a52cbe7..190062645ec4 100644
--- a/clang/include/clang/Basic/BuiltinsBPF.def
+++ b/clang/include/clang/Basic/BuiltinsBPF.def
@@ -21,7 +21,7 @@
 TARGET_BUILTIN(__builtin_preserve_field_info, "Ui.", "t", "")
 
 // Get BTF type id.
-TARGET_BUILTIN(__builtin_btf_type_id, "Ui.", "t", "")
+TARGET_BUILTIN(__builtin_btf_type_id, "LUi.", "t", "")
 
 // Get type information.
 TARGET_BUILTIN(__builtin_preserve_type_info, "Ui.", "t", "")

diff  --git a/clang/lib/Sema/SemaChecking.cpp b/clang/lib/Sema/SemaChecking.cpp
index eacf00c93015..8d4c90c7812f 100644
--- a/clang/lib/Sema/SemaChecking.cpp
+++ b/clang/lib/Sema/SemaChecking.cpp
@@ -2696,6 +2696,8 @@ bool Sema::CheckBPFBuiltinFunctionCall(unsigned BuiltinID,
   kind = diag::err_preserve_enum_value_invalid;
 }
 ReturnUnsignedInt = false;
+  } else if (BuiltinID == BPF::BI__builtin_btf_type_id) {
+ReturnUnsignedInt = false;
   }
 
   if (InvalidArg) {

diff  --git a/clang/test/CodeGen/builtin-bpf-btf-type-id.c 
b/clang/test/CodeGen/builtin-bpf-btf-type-id.c
index bbfbbb877aa7..c8f29ee5fe4a 100644
--- a/clang/test/CodeGen/builtin-bpf-btf-type-id.c
+++ b/clang/test/CodeGen/builtin-bpf-btf-type-id.c
@@ -12,12 +12,12 @@ unsigned test3() {
 }
 
 // CHECK: define dso_local i32 @test1
-// CHECK: call i32 @llvm.bpf.btf.type.id(i32 0, i64 0), !dbg !{{[0-9]+}}, 
!llvm.preserve.access.index ![[INT:[0-9]+]]
+// CHECK: call i64 @llvm.bpf.btf.type.id(i32 0, i64 0), !dbg !{{[0-9]+}}, 
!llvm.preserve.access.index ![[INT:[0-9]+]]
 // CHECK: define dso_local i32 @test2
-// CHECK: call i32 @llvm.bpf.btf.type.id(i32 1, i64 0), !dbg !{{[0-9]+}}, 
!llvm.preserve.access.index ![[INT_POINTER:[0-9]+]]
+// CHECK: call i64 @llvm.bpf.btf.type.id(i32 1, i64 0), !dbg !{{[0-9]+}}, 
!llvm.preserve.access.index ![[INT_POINTER:[0-9]+]]
 // CHECK: define dso_local i32 @test3
-// CHECK: call i32 @llvm.bpf.btf.type.id(i32 2, i64 1), !dbg !{{[0-9]+}}, 
!llvm.preserve.access.index ![[STRUCT_T1:[0-9]+]]
-// CHECK: call i32 @llvm.bpf.btf.type.id(i32 3, i64 1), !dbg !{{[0-9]+}}, 
!llvm.preserve.access.index ![[TYPEDEF_T1:[0-9]+]]
+// CHECK: call i64 @llvm.bpf.btf.type.id(i32 2, i64 1), !dbg !{{[0-9]+}}, 
!llvm.preserve.access.index ![[STRUCT_T1:[0-9]+]]
+// CHECK: call i64 @llvm.bpf.btf.type.id(i32 3, i64 1), !dbg !{{[0-9]+}}, 
!llvm.preserve.access.index ![[TYPEDEF_T1:[0-9]+]]
 //
 // CHECK: ![[INT]] = !DIBasicType(name: "int", size: 32, encoding: 
DW_ATE_signed
 // CHECK: ![[INT_POINTER]] = !DIDerivedType(tag: DW_TAG_pointer_type, 
baseType: ![[INT]], size: 64

diff  --git a/llvm/include/llvm/IR/IntrinsicsBPF.td 
b/llvm/include/llvm/IR/IntrinsicsBPF.td
index 651b28748cd3..4b4dd94b1599 100644
--- a/llvm/include/llvm/IR/IntrinsicsBPF.td
+++ b/llvm/include/llvm/IR/IntrinsicsBPF.td
@@ -24,7 +24,7 @@ let TargetPrefix = "bpf" in {  // All intrinsics start with 
"llvm.bpf."
   Intrinsic<[llvm_i32_ty], [llvm_anyptr_ty, llvm_i64_ty],
   [IntrNoMem, ImmArg>]>;
   def int_bpf_btf_type_id : GCCBuiltin<"__builtin_bpf_btf_type_id">,
-  Intrinsic<[llvm_i32_ty], [llvm_i32_ty, llvm_i64_ty],
+  Intrinsic<[llvm_i64_ty], [llvm_i32_ty, llvm_i64_ty],
   [IntrNoMem]>;
   def int_bpf_preserve_type_info : 
GCCBuiltin<"__builtin_bpf_preserve_type_info">,
   Intrinsic<[llvm_i32_ty], [llvm_i32_ty, llvm_i64_ty],

diff  --git a/llvm/lib/Target/BPF/BPFPreserveDIType.cpp 
b/llvm/lib/Target/BPF/BPFPreserveDIType.cpp
index 75febbe4b138..18a4f60c171a 100644
--- a/llvm/lib/Target/BPF/BPFPreserveDIType.cpp
+++ b/llvm/lib/Target/BPF/BPFPreserveDIType.cpp
@@ -90,7 +90,7 @@ static bool 

[PATCH] D91489: BPF: make __builtin_btf_type_id() return 64bit int

2020-11-16 Thread Yonghong Song 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 rG4369223ea73c: BPF: make __builtin_btf_type_id() return 64bit 
int (authored by yonghong-song).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91489

Files:
  clang/include/clang/Basic/BuiltinsBPF.def
  clang/lib/Sema/SemaChecking.cpp
  clang/test/CodeGen/builtin-bpf-btf-type-id.c
  llvm/include/llvm/IR/IntrinsicsBPF.td
  llvm/lib/Target/BPF/BPFPreserveDIType.cpp
  llvm/lib/Target/BPF/BTFDebug.cpp
  llvm/test/CodeGen/BPF/BTF/builtin-btf-type-id.ll
  llvm/test/CodeGen/BPF/CORE/btf-id-duplicate.ll
  llvm/test/CodeGen/BPF/optnone-2.ll

Index: llvm/test/CodeGen/BPF/optnone-2.ll
===
--- llvm/test/CodeGen/BPF/optnone-2.ll
+++ llvm/test/CodeGen/BPF/optnone-2.ll
@@ -12,14 +12,16 @@
 ; Function Attrs: noinline nounwind optnone
 define dso_local i32 @foo() #0 !dbg !9 {
 entry:
-  %0 = call i32 @llvm.bpf.btf.type.id(i32 0, i64 0), !dbg !12, !llvm.preserve.access.index !4
-  %1 = call i32 @llvm.bpf.preserve.type.info(i32 1, i64 0), !dbg !13, !llvm.preserve.access.index !14
-  %add = add i32 %0, %1, !dbg !17
-  ret i32 %add, !dbg !18
+  %0 = call i64 @llvm.bpf.btf.type.id(i32 0, i64 0), !dbg !11, !llvm.preserve.access.index !4
+  %1 = call i32 @llvm.bpf.preserve.type.info(i32 1, i64 0), !dbg !12, !llvm.preserve.access.index !13
+  %conv = zext i32 %1 to i64, !dbg !12
+  %add = add i64 %0, %conv, !dbg !16
+  %conv1 = trunc i64 %add to i32, !dbg !11
+  ret i32 %conv1, !dbg !17
 }
 
 ; Function Attrs: nounwind readnone
-declare i32 @llvm.bpf.btf.type.id(i32, i64) #1
+declare i64 @llvm.bpf.btf.type.id(i32, i64) #1
 
 ; Function Attrs: nounwind readnone
 declare i32 @llvm.bpf.preserve.type.info(i32, i64) #1
@@ -40,13 +42,12 @@
 !6 = !{i32 2, !"Debug Info Version", i32 3}
 !7 = !{i32 1, !"wchar_size", i32 4}
 !8 = !{!"clang version 12.0.0"}
-!9 = distinct !DISubprogram(name: "foo", scope: !10, file: !10, line: 2, type: !11, scopeLine: 2, spFlags: DISPFlagDefinition, unit: !0, retainedNodes: !2)
-!10 = !DIFile(filename: "C:/src/tmp/a.c", directory: "")
-!11 = !DISubroutineType(types: !3)
-!12 = !DILocation(line: 2, column: 21, scope: !9)
-!13 = !DILocation(line: 2, column: 51, scope: !9)
-!14 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "ss", file: !10, line: 1, size: 32, elements: !15)
-!15 = !{!16}
-!16 = !DIDerivedType(tag: DW_TAG_member, name: "a", scope: !14, file: !10, line: 1, baseType: !4, size: 32)
-!17 = !DILocation(line: 2, column: 49, scope: !9)
-!18 = !DILocation(line: 2, column: 14, scope: !9)
+!9 = distinct !DISubprogram(name: "foo", scope: !1, file: !1, line: 2, type: !10, scopeLine: 2, spFlags: DISPFlagDefinition, unit: !0, retainedNodes: !2)
+!10 = !DISubroutineType(types: !3)
+!11 = !DILocation(line: 2, column: 20, scope: !9)
+!12 = !DILocation(line: 2, column: 50, scope: !9)
+!13 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "ss", file: !1, line: 1, size: 32, elements: !14)
+!14 = !{!15}
+!15 = !DIDerivedType(tag: DW_TAG_member, name: "a", scope: !13, file: !1, line: 1, baseType: !4, size: 32)
+!16 = !DILocation(line: 2, column: 48, scope: !9)
+!17 = !DILocation(line: 2, column: 13, scope: !9)
Index: llvm/test/CodeGen/BPF/CORE/btf-id-duplicate.ll
===
--- llvm/test/CodeGen/BPF/CORE/btf-id-duplicate.ll
+++ llvm/test/CodeGen/BPF/CORE/btf-id-duplicate.ll
@@ -18,15 +18,16 @@
   %arg.addr = alloca %struct.s1*, align 8
   store %struct.s1* %arg, %struct.s1** %arg.addr, align 8, !tbaa !18
   call void @llvm.dbg.declare(metadata %struct.s1** %arg.addr, metadata !17, metadata !DIExpression()), !dbg !22
-  %0 = call i32 @llvm.bpf.btf.type.id(i32 0, i64 0), !dbg !23, !llvm.preserve.access.index !12
-  ret i32 %0, !dbg !24
+  %0 = call i64 @llvm.bpf.btf.type.id(i32 0, i64 0), !dbg !23, !llvm.preserve.access.index !12
+  %conv = trunc i64 %0 to i32, !dbg !23
+  ret i32 %conv, !dbg !24
 }
 
-; Function Attrs: nounwind readnone speculatable willreturn
+; Function Attrs: nofree nosync nounwind readnone speculatable willreturn
 declare void @llvm.dbg.declare(metadata, metadata, metadata) #1
 
 ; Function Attrs: nounwind readnone
-declare i32 @llvm.bpf.btf.type.id(i32, i64) #2
+declare i64 @llvm.bpf.btf.type.id(i32, i64) #2
 
 ; Function Attrs: nounwind
 define dso_local i32 @bar(%struct.s1* %arg) #0 !dbg !25 {
@@ -34,8 +35,9 @@
   %arg.addr = alloca %struct.s1*, align 8
   store %struct.s1* %arg, %struct.s1** %arg.addr, align 8, !tbaa !18
   call void @llvm.dbg.declare(metadata %struct.s1** %arg.addr, metadata !27, metadata !DIExpression()), !dbg !28
-  %0 = call i32 @llvm.bpf.btf.type.id(i32 1, i64 0), !dbg !29, !llvm.preserve.access.index !12
-  ret i32 %0, !dbg !30
+  %0 = call i64 @llvm.bpf.btf.type.id(i32 1, i64 0), !dbg !29, 

[PATCH] D91361: [AIX][driver] Include crti[_64].o and -bcdtors also for C language link invocations by default

2020-11-16 Thread Xiangling Liao via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG9e407afd9bd3: [AIX][driver] Include crti[_64].o and -bcdtors 
also for C language linkā€¦ (authored by Xiangling_L).

Changed prior to commit:
  https://reviews.llvm.org/D91361?vs=305160=305501#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91361

Files:
  clang/lib/Driver/ToolChains/AIX.cpp
  clang/test/Driver/aix-ld.c

Index: clang/test/Driver/aix-ld.c
===
--- clang/test/Driver/aix-ld.c
+++ clang/test/Driver/aix-ld.c
@@ -16,7 +16,7 @@
 // CHECK-LD32: "-b32"
 // CHECK-LD32: "-bpT:0x1000" "-bpD:0x2000"
 // CHECK-LD32: "[[SYSROOT]]/usr/lib{{/|}}crt0.o"
-// CHECK-LD32-NOT: "[[SYSROOT]]/usr/lib{{/|}}crti.o"
+// CHECK-LD32: "[[SYSROOT]]/usr/lib{{/|}}crti.o"
 // CHECK-LD32: "-L[[SYSROOT]]/usr/lib"
 // CHECK-LD32-NOT: "-lc++"
 // CHECK-LD32: "[[RESOURCE_DIR]]{{/|}}lib{{/|}}aix{{/|}}libclang_rt.builtins-powerpc.a"
@@ -38,7 +38,7 @@
 // CHECK-LD64: "-b64"
 // CHECK-LD64: "-bpT:0x1" "-bpD:0x11000"
 // CHECK-LD64: "[[SYSROOT]]/usr/lib{{/|}}crt0_64.o"
-// CHECK-LD64-NOT: "[[SYSROOT]]/usr/lib{{/|}}crti_64.o"
+// CHECK-LD64: "[[SYSROOT]]/usr/lib{{/|}}crti_64.o"
 // CHECK-LD64: "-L[[SYSROOT]]/usr/lib"
 // CHECK-LD64-NOT: "-lc++"
 // CHECK-LD64: "[[RESOURCE_DIR]]{{/|}}lib{{/|}}aix{{/|}}libclang_rt.builtins-powerpc64.a"
@@ -61,7 +61,7 @@
 // CHECK-LD32-PTHREAD: "-b32"
 // CHECK-LD32-PTHREAD: "-bpT:0x1000" "-bpD:0x2000"
 // CHECK-LD32-PTHREAD: "[[SYSROOT]]/usr/lib{{/|}}crt0.o"
-// CHECK-LD32-PTHREAD-NOT: "[[SYSROOT]]/usr/lib{{/|}}crti.o"
+// CHECK-LD32-PTHREAD: "[[SYSROOT]]/usr/lib{{/|}}crti.o"
 // CHECK-LD32-PTHREAD: "-L[[SYSROOT]]/usr/lib"
 // CHECK-LD32-PTHREAD-NOT: "-lc++"
 // CHECK-LD32-PTHREAD: "[[RESOURCE_DIR]]{{/|}}lib{{/|}}aix{{/|}}libclang_rt.builtins-powerpc.a"
@@ -85,7 +85,7 @@
 // CHECK-LD64-PTHREAD: "-b64"
 // CHECK-LD64-PTHREAD: "-bpT:0x1" "-bpD:0x11000"
 // CHECK-LD64-PTHREAD: "[[SYSROOT]]/usr/lib{{/|}}crt0_64.o"
-// CHECK-LD64-PTHREAD-NOT: "[[SYSROOT]]/usr/lib{{/|}}crti_64.o"
+// CHECK-LD64-PTHREAD: "[[SYSROOT]]/usr/lib{{/|}}crti_64.o"
 // CHECK-LD64-PTHREAD: "-L[[SYSROOT]]/usr/lib"
 // CHECK-LD64-PTHREAD-NOT: "-lc++"
 // CHECK-LD64-PTHREAD: "[[RESOURCE_DIR]]{{/|}}lib{{/|}}aix{{/|}}libclang_rt.builtins-powerpc64.a"
@@ -109,7 +109,7 @@
 // CHECK-LD32-PROF: "-b32"
 // CHECK-LD32-PROF: "-bpT:0x1000" "-bpD:0x2000"
 // CHECK-LD32-PROF: "[[SYSROOT]]/usr/lib{{/|}}mcrt0.o"
-// CHECK-LD32-PROF-NOT: "[[SYSROOT]]/usr/lib{{/|}}crti.o"
+// CHECK-LD32-PROF: "[[SYSROOT]]/usr/lib{{/|}}crti.o"
 // CHECK-LD32-PROF: "-L[[SYSROOT]]/usr/lib"
 // CHECK-LD32-PROF-NOT: "-lc++"
 // CHECK-LD32-PROF: "[[RESOURCE_DIR]]{{/|}}lib{{/|}}aix{{/|}}libclang_rt.builtins-powerpc.a"
@@ -132,7 +132,7 @@
 // CHECK-LD64-GPROF: "-b64"
 // CHECK-LD64-GPROF: "-bpT:0x1" "-bpD:0x11000"
 // CHECK-LD64-GPROF: "[[SYSROOT]]/usr/lib{{/|}}gcrt0_64.o"
-// CHECK-LD64-GPROF-NOT: "[[SYSROOT]]/usr/lib{{/|}}crti_64.o"
+// CHECK-LD64-GPROF: "[[SYSROOT]]/usr/lib{{/|}}crti_64.o"
 // CHECK-LD64-GPROF: "-L[[SYSROOT]]/usr/lib"
 // CHECK-LD64-GPROF-NOT: "-lc++"
 // CHECK-LD64-GPROF: "[[RESOURCE_DIR]]{{/|}}lib{{/|}}aix{{/|}}libclang_rt.builtins-powerpc64.a"
@@ -155,7 +155,7 @@
 // CHECK-LD32-STATIC: "-b32"
 // CHECK-LD32-STATIC: "-bpT:0x1000" "-bpD:0x2000"
 // CHECK-LD32-STATIC: "[[SYSROOT]]/usr/lib{{/|}}crt0.o"
-// CHECK-LD32-STATIC-NOT: "[[SYSROOT]]/usr/lib{{/|}}crti.o"
+// CHECK-LD32-STATIC: "[[SYSROOT]]/usr/lib{{/|}}crti.o"
 // CHECK-LD32-STATIC: "-L[[SYSROOT]]/usr/lib"
 // CHECK-LD32-STATIC-NOT: "-lc++"
 // CHECK-LD32-STATIC: "[[RESOURCE_DIR]]{{/|}}lib{{/|}}aix{{/|}}libclang_rt.builtins-powerpc.a"
@@ -178,7 +178,7 @@
 // CHECK-LD32-LIBP: "-b32"
 // CHECK-LD32-LIBP: "-bpT:0x1000" "-bpD:0x2000"
 // CHECK-LD32-LIBP: "[[SYSROOT]]/usr/lib{{/|}}crt0.o"
-// CHECK-LD32-LIBP-NOT: "[[SYSROOT]]/usr/lib{{/|}}crti.o"
+// CHECK-LD32-LIBP: "[[SYSROOT]]/usr/lib{{/|}}crti.o"
 // CHECK-LD32-LIBP: "-L[[SYSROOT]]/powerpc-ibm-aix7.1.0.0"
 // CHECK-LD32-LIBP: "-L[[SYSROOT]]/usr/lib"
 // CHECK-LD32-LIBP-NOT: "-lc++"
@@ -228,7 +228,7 @@
 // CHECK-LD64-NO-DEFAULT-LIBS: "-b64"
 // CHECK-LD64-NO-DEFAULT-LIBS: "-bpT:0x1" "-bpD:0x11000"
 // CHECK-LD64-NO-DEFAULT-LIBS: "[[SYSROOT]]/usr/lib{{/|}}crt0_64.o"
-// CHECK-LD64-NO-DEFAULT-LIBS-NOT: "[[SYSROOT]]/usr/lib{{/|}}crti_64.o"
+// CHECK-LD64-NO-DEFAULT-LIBS: "[[SYSROOT]]/usr/lib{{/|}}crti_64.o"
 // CHECK-LD64-NO-DEFAULT-LIBS:  

[clang] 9e407af - [AIX][driver] Include crti[_64].o and -bcdtors also for C language link invocations by default

2020-11-16 Thread Xiangling Liao via cfe-commits

Author: Xiangling Liao
Date: 2020-11-16T10:07:57-05:00
New Revision: 9e407afd9bd3b5181db24b08f78cb43344bd8292

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

LOG: [AIX][driver] Include crti[_64].o and -bcdtors also for C language link 
invocations by default

In order to support attribute((constructor)) and attribute((destructor)),
which is used by various LLVM non-C++ runtime components, AIX will include
crti[_64].o and -bcdtors for C language link invocations by default.

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

Added: 


Modified: 
clang/lib/Driver/ToolChains/AIX.cpp
clang/test/Driver/aix-ld.c

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/AIX.cpp 
b/clang/lib/Driver/ToolChains/AIX.cpp
index 47ce99a7c625..7b5d7da8c873 100644
--- a/clang/lib/Driver/ToolChains/AIX.cpp
+++ b/clang/lib/Driver/ToolChains/AIX.cpp
@@ -134,16 +134,15 @@ void aix::Linker::ConstructJob(Compilation , const 
JobAction ,
 CmdArgs.push_back(
 Args.MakeArgString(ToolChain.GetFilePath(getCrt0Basename(;
 
-if (D.CCCIsCXX())
-  CmdArgs.push_back(Args.MakeArgString(
-  ToolChain.GetFilePath(IsArch32Bit ? "crti.o" : "crti_64.o")));
+CmdArgs.push_back(Args.MakeArgString(
+ToolChain.GetFilePath(IsArch32Bit ? "crti.o" : "crti_64.o")));
   }
 
-  // Collect all static constructor and destructor functions in CXX mode. This
-  // has to come before AddLinkerInputs as the implied option needs to precede
-  // any other '-bcdtors' settings or '-bnocdtors' that '-Wl' might forward.
-  if (D.CCCIsCXX())
-CmdArgs.push_back("-bcdtors:all:0:s");
+  // Collect all static constructor and destructor functions in both C and CXX
+  // language link invocations. This has to come before AddLinkerInputs as the
+  // implied option needs to precede any other '-bcdtors' settings or
+  // '-bnocdtors' that '-Wl' might forward.
+  CmdArgs.push_back("-bcdtors:all:0:s");
 
   // Specify linker input file(s).
   AddLinkerInputs(ToolChain, Inputs, Args, CmdArgs, JA);

diff  --git a/clang/test/Driver/aix-ld.c b/clang/test/Driver/aix-ld.c
index 89959d851b93..6abfa10c92f6 100644
--- a/clang/test/Driver/aix-ld.c
+++ b/clang/test/Driver/aix-ld.c
@@ -16,7 +16,7 @@
 // CHECK-LD32: "-b32"
 // CHECK-LD32: "-bpT:0x1000" "-bpD:0x2000"
 // CHECK-LD32: "[[SYSROOT]]/usr/lib{{/|}}crt0.o"
-// CHECK-LD32-NOT: "[[SYSROOT]]/usr/lib{{/|}}crti.o"
+// CHECK-LD32: "[[SYSROOT]]/usr/lib{{/|}}crti.o"
 // CHECK-LD32: "-L[[SYSROOT]]/usr/lib"
 // CHECK-LD32-NOT: "-lc++"
 // CHECK-LD32: 
"[[RESOURCE_DIR]]{{/|}}lib{{/|}}aix{{/|}}libclang_rt.builtins-powerpc.a"
@@ -38,7 +38,7 @@
 // CHECK-LD64: "-b64"
 // CHECK-LD64: "-bpT:0x1" "-bpD:0x11000"
 // CHECK-LD64: "[[SYSROOT]]/usr/lib{{/|}}crt0_64.o"
-// CHECK-LD64-NOT: "[[SYSROOT]]/usr/lib{{/|}}crti_64.o"
+// CHECK-LD64: "[[SYSROOT]]/usr/lib{{/|}}crti_64.o"
 // CHECK-LD64: "-L[[SYSROOT]]/usr/lib"
 // CHECK-LD64-NOT: "-lc++"
 // CHECK-LD64: 
"[[RESOURCE_DIR]]{{/|}}lib{{/|}}aix{{/|}}libclang_rt.builtins-powerpc64.a"
@@ -61,7 +61,7 @@
 // CHECK-LD32-PTHREAD: "-b32"
 // CHECK-LD32-PTHREAD: "-bpT:0x1000" "-bpD:0x2000"
 // CHECK-LD32-PTHREAD: "[[SYSROOT]]/usr/lib{{/|}}crt0.o"
-// CHECK-LD32-PTHREAD-NOT: "[[SYSROOT]]/usr/lib{{/|}}crti.o"
+// CHECK-LD32-PTHREAD: "[[SYSROOT]]/usr/lib{{/|}}crti.o"
 // CHECK-LD32-PTHREAD: "-L[[SYSROOT]]/usr/lib"
 // CHECK-LD32-PTHREAD-NOT: "-lc++"
 // CHECK-LD32-PTHREAD: 
"[[RESOURCE_DIR]]{{/|}}lib{{/|}}aix{{/|}}libclang_rt.builtins-powerpc.a"
@@ -85,7 +85,7 @@
 // CHECK-LD64-PTHREAD: "-b64"
 // CHECK-LD64-PTHREAD: "-bpT:0x1" "-bpD:0x11000"
 // CHECK-LD64-PTHREAD: "[[SYSROOT]]/usr/lib{{/|}}crt0_64.o"
-// CHECK-LD64-PTHREAD-NOT: "[[SYSROOT]]/usr/lib{{/|}}crti_64.o"
+// CHECK-LD64-PTHREAD: "[[SYSROOT]]/usr/lib{{/|}}crti_64.o"
 // CHECK-LD64-PTHREAD: "-L[[SYSROOT]]/usr/lib"
 // CHECK-LD64-PTHREAD-NOT: "-lc++"
 // CHECK-LD64-PTHREAD: 
"[[RESOURCE_DIR]]{{/|}}lib{{/|}}aix{{/|}}libclang_rt.builtins-powerpc64.a"
@@ -109,7 +109,7 @@
 // CHECK-LD32-PROF: "-b32"
 // CHECK-LD32-PROF: "-bpT:0x1000" "-bpD:0x2000"
 // CHECK-LD32-PROF: "[[SYSROOT]]/usr/lib{{/|}}mcrt0.o"
-// CHECK-LD32-PROF-NOT: "[[SYSROOT]]/usr/lib{{/|}}crti.o"
+// CHECK-LD32-PROF: "[[SYSROOT]]/usr/lib{{/|}}crti.o"
 // CHECK-LD32-PROF: "-L[[SYSROOT]]/usr/lib"
 // CHECK-LD32-PROF-NOT: "-lc++"
 // CHECK-LD32-PROF: 
"[[RESOURCE_DIR]]{{/|}}lib{{/|}}aix{{/|}}libclang_rt.builtins-powerpc.a"
@@ -132,7 +132,7 @@
 // CHECK-LD64-GPROF: "-b64"
 // CHECK-LD64-GPROF: "-bpT:0x1" 

[PATCH] D91195: Add Annotation2MD pass to add !annotate metadata from llvm.global.annotations

2020-11-16 Thread Florian Hahn 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 rG8dbe44cb2936: Add pass to add !annotate metadata from 
@llvm.global.annotations. (authored by fhahn).
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Changed prior to commit:
  https://reviews.llvm.org/D91195?vs=304277=305499#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91195

Files:
  clang/test/CodeGen/code-coverage.c
  llvm/include/llvm/Analysis/OptimizationRemarkEmitter.h
  llvm/include/llvm/InitializePasses.h
  llvm/include/llvm/Transforms/IPO.h
  llvm/include/llvm/Transforms/IPO/Annotation2Metadata.h
  llvm/lib/Passes/PassBuilder.cpp
  llvm/lib/Passes/PassRegistry.def
  llvm/lib/Transforms/IPO/Annotation2Metadata.cpp
  llvm/lib/Transforms/IPO/CMakeLists.txt
  llvm/lib/Transforms/IPO/IPO.cpp
  llvm/lib/Transforms/IPO/PassManagerBuilder.cpp
  llvm/test/CodeGen/AMDGPU/opt-pipeline.ll
  llvm/test/Other/new-pm-defaults.ll
  llvm/test/Other/new-pm-lto-defaults.ll
  llvm/test/Other/new-pm-thinlto-defaults.ll
  llvm/test/Other/new-pm-thinlto-postlink-pgo-defaults.ll
  llvm/test/Other/new-pm-thinlto-postlink-samplepgo-defaults.ll
  llvm/test/Other/new-pm-thinlto-prelink-pgo-defaults.ll
  llvm/test/Other/new-pm-thinlto-prelink-samplepgo-defaults.ll
  llvm/test/Other/opt-O0-pipeline.ll
  llvm/test/Other/opt-O2-pipeline.ll
  llvm/test/Other/opt-O3-pipeline-enable-matrix.ll
  llvm/test/Other/opt-O3-pipeline.ll
  llvm/test/Other/opt-Os-pipeline.ll
  llvm/test/Transforms/Util/annotation2metadata.ll

Index: llvm/test/Transforms/Util/annotation2metadata.ll
===
--- /dev/null
+++ llvm/test/Transforms/Util/annotation2metadata.ll
@@ -0,0 +1,61 @@
+; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
+; RUN: opt -annotation2metadata -pass-remarks-analysis='annotation-remarks' -S %s | FileCheck %s
+; RUN: opt -passes='annotation2metadata' -pass-remarks-analysis='annotation-remarks' -S %s | FileCheck %s
+
+@.str = private unnamed_addr constant [10 x i8] c"_remarks1\00", section "llvm.metadata"
+@.str.1 = private unnamed_addr constant [6 x i8] c"ann.c\00", section "llvm.metadata"
+@.str.2 = private unnamed_addr constant [10 x i8] c"_remarks2\00", section "llvm.metadata"
+@llvm.global.annotations = appending global [8 x { i8*, i8*, i8*, i32 }] [
+{ i8*, i8*, i8*, i32 } { i8* bitcast (void (float*)* @test1 to i8*), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i32 0, i32 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i32 0, i32 0), i32 2 },
+{ i8*, i8*, i8*, i32 } { i8* bitcast (void (float*)* @test1 to i8*), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i32 0, i32 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i32 0, i32 0), i32 2 },
+{ i8*, i8*, i8*, i32 } { i8* bitcast (void (float*)* @test3 to i8*), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i32 0, i32 0), i8* undef, i32 4 }, ; Invalid entry, make sure we do not crash.
+{ i8*, i8*, i8*, i32 } { i8* bitcast (void (float*)* @test3 to i8*), i8* undef, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i32 0, i32 0), i32 4 }, ; Invalid entry, make sure we do not crash.
+{ i8*, i8*, i8*, i32 } { i8* undef, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i32 0, i32 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i32 0, i32 0), i32 4 }, ; Invalid entry, make sure we do not crash.
+{ i8*, i8*, i8*, i32 } { i8* bitcast (void (float*)* undef to i8*), i8* undef, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i32 0, i32 0), i32 4 }, ; Invalid entry, make sure we do not crash.
+{ i8*, i8*, i8*, i32 } { i8* undef, i8* undef, i8* undef, i32 300 },  ; Invalid entry, make sure we do not crash.
+{ i8*, i8*, i8*, i32 } { i8* bitcast (void (float*)* @test3 to i8*), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i32 0, i32 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i32 0, i32 0), i32 4 }
+], section "llvm.metadata"
+
+
+
+define void @test1(float* %a) {
+; CHECK-LABEL: @test1(
+; CHECK-NEXT:  entry:
+; CHECK-NEXT:[[A_ADDR:%.*]] = alloca float*, align 8, !annotation [[GROUP1:!.+]]
+; CHECK-NEXT:store float* [[A:%.*]], float** [[A_ADDR]], align 8, !annotation [[GROUP1]]
+; CHECK-NEXT:ret void, !annotation [[GROUP1]]
+;
+entry:
+  %a.addr = alloca float*, align 8
+  store float* %a, float** %a.addr, align 8
+  ret void
+}
+
+define void @test2(float* %a) {
+; CHECK-LABEL: @test2(
+; CHECK-NEXT:  entry:
+; CHECK-NEXT:[[A_ADDR:%.*]] = alloca float*, align 8
+; CHECK-NEXT:store float* [[A:%.*]], float** [[A_ADDR]], align 8
+; CHECK-NEXT:ret void
+;
+entry:
+  %a.addr = alloca float*, align 8
+  store float* %a, float** %a.addr, align 8
+  ret void
+}
+
+define void 

[clang] 8dbe44c - Add pass to add !annotate metadata from @llvm.global.annotations.

2020-11-16 Thread Florian Hahn via cfe-commits

Author: Florian Hahn
Date: 2020-11-16T14:57:11Z
New Revision: 8dbe44cb2936ecafea4b26ef16d1727371ad203f

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

LOG: Add pass to add !annotate metadata from @llvm.global.annotations.

This patch adds a new pass to add !annotation metadata for entries in
@llvm.global.anotations, which is generated  using
__attribute__((annotate("_name"))) on functions in Clang.

This has been discussed on llvm-dev as part of
RFC: Combining Annotation Metadata and Remarks
http://lists.llvm.org/pipermail/llvm-dev/2020-November/146393.html

Reviewed By: thegameg

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

Added: 
llvm/include/llvm/Transforms/IPO/Annotation2Metadata.h
llvm/lib/Transforms/IPO/Annotation2Metadata.cpp
llvm/test/Transforms/Util/annotation2metadata.ll

Modified: 
clang/test/CodeGen/code-coverage.c
llvm/include/llvm/Analysis/OptimizationRemarkEmitter.h
llvm/include/llvm/InitializePasses.h
llvm/include/llvm/Transforms/IPO.h
llvm/lib/Passes/PassBuilder.cpp
llvm/lib/Passes/PassRegistry.def
llvm/lib/Transforms/IPO/CMakeLists.txt
llvm/lib/Transforms/IPO/IPO.cpp
llvm/lib/Transforms/IPO/PassManagerBuilder.cpp
llvm/test/CodeGen/AMDGPU/opt-pipeline.ll
llvm/test/Other/new-pm-defaults.ll
llvm/test/Other/new-pm-lto-defaults.ll
llvm/test/Other/new-pm-thinlto-defaults.ll
llvm/test/Other/new-pm-thinlto-postlink-pgo-defaults.ll
llvm/test/Other/new-pm-thinlto-postlink-samplepgo-defaults.ll
llvm/test/Other/new-pm-thinlto-prelink-pgo-defaults.ll
llvm/test/Other/new-pm-thinlto-prelink-samplepgo-defaults.ll
llvm/test/Other/opt-O0-pipeline.ll
llvm/test/Other/opt-O2-pipeline.ll
llvm/test/Other/opt-O3-pipeline-enable-matrix.ll
llvm/test/Other/opt-O3-pipeline.ll
llvm/test/Other/opt-Os-pipeline.ll

Removed: 




diff  --git a/clang/test/CodeGen/code-coverage.c 
b/clang/test/CodeGen/code-coverage.c
index 200f3650b752..02e9482d4b4a 100644
--- a/clang/test/CodeGen/code-coverage.c
+++ b/clang/test/CodeGen/code-coverage.c
@@ -18,10 +18,10 @@
 // NEWPM: Running pass: GCOVProfilerPass
 
 // NEWPM-O3-NOT: Running pass
+// NEWPM-O3: Running pass: Annotation2MetadataPass
 // NEWPM-O3: Running pass: ForceFunctionAttrsPass
 // NEWPM-O3: Running pass: GCOVProfilerPass
 
-
 int test1(int a) {
   switch (a % 2) {
   case 0:

diff  --git a/llvm/include/llvm/Analysis/OptimizationRemarkEmitter.h 
b/llvm/include/llvm/Analysis/OptimizationRemarkEmitter.h
index 4ac8eb8be906..9815dd05cd1c 100644
--- a/llvm/include/llvm/Analysis/OptimizationRemarkEmitter.h
+++ b/llvm/include/llvm/Analysis/OptimizationRemarkEmitter.h
@@ -90,10 +90,12 @@ class OptimizationRemarkEmitter {
   bool allowExtraAnalysis(StringRef PassName) const {
 return OptimizationRemarkEmitter::allowExtraAnalysis(*F, PassName);
   }
-
   static bool allowExtraAnalysis(const Function , StringRef PassName) {
-return F.getContext().getLLVMRemarkStreamer() ||
-   F.getContext().getDiagHandlerPtr()->isAnyRemarkEnabled(PassName);
+return allowExtraAnalysis(F.getContext(), PassName);
+  }
+  static bool allowExtraAnalysis(LLVMContext , StringRef PassName) {
+return Ctx.getLLVMRemarkStreamer() ||
+   Ctx.getDiagHandlerPtr()->isAnyRemarkEnabled(PassName);
   }
 
 private:

diff  --git a/llvm/include/llvm/InitializePasses.h 
b/llvm/include/llvm/InitializePasses.h
index 139c4a84d9ef..0d0eaf0bca83 100644
--- a/llvm/include/llvm/InitializePasses.h
+++ b/llvm/include/llvm/InitializePasses.h
@@ -73,6 +73,7 @@ void initializeAlignmentFromAssumptionsPass(PassRegistry&);
 void initializeAlwaysInlinerLegacyPassPass(PassRegistry&);
 void initializeAssumeSimplifyPassLegacyPassPass(PassRegistry &);
 void initializeAssumeBuilderPassLegacyPassPass(PassRegistry &);
+void initializeAnnotation2MetadataLegacyPass(PassRegistry &);
 void initializeAnnotationRemarksLegacyPass(PassRegistry &);
 void initializeOpenMPOptLegacyPassPass(PassRegistry &);
 void initializeArgPromotionPass(PassRegistry&);

diff  --git a/llvm/include/llvm/Transforms/IPO.h 
b/llvm/include/llvm/Transforms/IPO.h
index 7b73eeaf8e45..1918ad76a270 100644
--- a/llvm/include/llvm/Transforms/IPO.h
+++ b/llvm/include/llvm/Transforms/IPO.h
@@ -29,6 +29,13 @@ class BasicBlock;
 class GlobalValue;
 class raw_ostream;
 
+//===--===//
+//
+// This pass adds !annotation metadata to entries in the
+// @llvm.global.annotations global constant.
+//
+ModulePass *createAnnotation2MetadataLegacyPass();
+
 
//===--===//
 //
 // These functions removes symbols from functions and modules.  If 
OnlyDebugInfo

diff  --git 

[PATCH] D91047: Add a call super attribute plugin example

2020-11-16 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: clang/docs/ClangPlugins.rst:117
+Defining CallSuperAttr
+===
+

psionic12 wrote:
> aaron.ballman wrote:
> > psionic12 wrote:
> > > aaron.ballman wrote:
> > > > aaron.ballman wrote:
> > > > > The number of underlines here looks off -- can you verify it's 
> > > > > correct?
> > > > This still appears to be incorrect and will cause build errors for the 
> > > > documentation.
> > > Do you mean that there's a command to build the documentation and 
> > > currently my patch will cause a failure on it?
> > > 
> > > I thought this ClangPlugins.rst is only an documentation with markdown, 
> > > but seems that it's not what I thought?
> > > 
> > > Currently I will make sure there's no build error on the plugin itself 
> > > and the regression test case, and make sure the
> > > regression test will pass. Seems that's not enough, right?
> > > Do you mean that there's a command to build the documentation and 
> > > currently my patch will cause a failure on it?
> > 
> > Yes, we have a bot that builds docs: http://lab.llvm.org:8011/#/builders/92
> > 
> > > I thought this ClangPlugins.rst is only an documentation with markdown, 
> > > but seems that it's not what I thought?
> > 
> > It is a documentation file with markdown, but the markdown bots will 
> > complain if a markdown file cannot be built (they treat markdown warnings 
> > as errors).
> > 
> > > Currently I will make sure there's no build error on the plugin itself 
> > > and the regression test case, and make sure the regression test will 
> > > pass. Seems that's not enough, right?
> > 
> > Most of the time that's enough because the markdown usage is pretty trivial 
> > and can be inspected by sight for obvious issues (so people don't typically 
> > have to set up their build environments to generate documentation and test 
> > it with every patch).
> > 
> > In this case, the issue is with the underlines under the title. The number 
> > of underlines needs to match the number of characters in the title, but in 
> > this case there are 20 `=` characters but 23 title characters.
> It seems that only a committee member can trigger this bot, any way I can 
> test on my own environment? So that I can make sure the doc will compile 
> successfully before uploading patches?
> 
> As I mentioned before, using `make doxygen-clang` will succeed even the `=` 
> characters are not match with title characters, so it seems that the bot 
> doesn't use this way.
You can test in your own environment (if a build bot can do it, so can anyone 
else). I don't typically build docs locally so my instructions are untested, 
but I think you need to set the following cmake variables:

```
LLVM_BUILD_DOCS=YES ' enables building docs
LLVM_ENABLE_SPHINX=YES ' enable building sphinx docs (.rst files)
```
You also have to have Sphinx installed (you can do this using `pip install -U 
Sphinx`) and on the PATH before you configure cmake for Clang.

Doxygen is a different documentation format than Sphinx. Doxygen handles 
building the docs from comments in the source files. Sphinx is what turns these 
.rst files into HTML. If you enable Sphinx builds from cmake there should be a 
target added that lets you build those docs.



Comment at: clang/test/Frontend/plugin-call-super.cpp:5
+
+// expected-no-diagnostics
+struct Base1 { [[clang::call_super]] virtual void Test() {} };

Hmm, this seems wrong to me -- we do expect diagnostics from this file.



Comment at: clang/test/Frontend/plugin-call-super.cpp:18-19
+struct Derive2 : public Base1, public Base2 { void Test() override {  
Base1::Test();  Base2::Test();}};
+// BADCALLSUPER: warning: virtual function 'Base2::Test' is marked as 
'call_super' but this overriding method does not call the base version
+// BADCALLSUPER: note: function marked 'call_super' here
+#endif

These warnings and notes (and the warning a few lines up) are ones I would have 
expected to catch using `// expected-warning {{virtual function 'Base2::Test' 
is marked as 'call_super' but this overriding method does not call the base 
version}}` style checks instead of needing to use FileCheck.

Do plugin-based diagnostics not get caught by `-verify`? I expect this test 
file to fail as currently written because of the `expected-no-diagnostics`, but 
I've not done a whole lot of testing of plugins before.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91047

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


[PATCH] D91311: Add new 'preferred_name' attribute.

2020-11-16 Thread Arthur O'Dwyer via Phabricator via cfe-commits
Quuxplusone added inline comments.



Comment at: libcxx/include/regex:2520
+_LIBCPP_PREFERRED_NAME(wregex)
+basic_regex
 {

aaron.ballman wrote:
> rsmith wrote:
> > Quuxplusone wrote:
> > > Why does this attribute go on the class template? Shouldn't it be an 
> > > attribute on the typedef, so that you don't have to repeat yourself? I 
> > > mean, I'd much rather see
> > > 
> > > template class BasicFoo { };
> > > using [[preferred]] Foo = BasicFoo;
> > > using [[preferred]] WFoo = BasicFoo;
> > > 
> > > than
> > > 
> > > template class BasicFoo;
> > > using Foo = BasicFoo;
> > > using WFoo = BasicFoo;
> > > template class [[preferred(Foo, WFoo)]] BasicFoo { };
> > > 
> > > The latter repeats every identifier one extra time, compared to the 
> > > former.
> > > 
> > > And then, in fact, couldn't you go one step further and say that typedefs 
> > > in the same scope as the class template itself should //always// 
> > > implicitly have this attribute? Even if the attribute doesn't appear in 
> > > the source code, we still want to print `basic_regex` as `regex`, 
> > > right? It shouldn't cost any additional work for the compiler to figure 
> > > that out.
> > I don't think we want arbitrary typedefs to be able to declare themselves 
> > to be names for the class template after the fact: this is a decision that 
> > the (author of the) template itself should be making, not a decision for 
> > the (author of the) typedef. Also, we need the information when looking at 
> > the class template, not when looking at the typedef, so attaching it to the 
> > typedef would require us to internally attach it to the class template 
> > instead anyway, and generally it's undesirable and problematic to mutate an 
> > existing declaration -- it's much cleaner to introduce new properties of a 
> > declaration by redeclaring it. It's certainly not ideal that this results 
> > in extra forward declarations in some cases, but given that this attribute 
> > is only expected to be written a few dozen times in total, it doesn't seem 
> > worth worrying about too much.
> > 
> > I don't think we want typedefs to automatically get this behavior, even if 
> > they're in the same namespace. I think it would be problematic if, for 
> > example:
> > 
> > ```
> > namespace absl {
> >   template struct basic_string_view;
> >   using format_arg = basic_string_view;
> >   std::string format(format_arg, ...);
> > }
> > ```
> > 
> > ... resulted in `absl::string_view` sometimes displaying as the (to a user) 
> > unrelated type `absl::format_arg` depending on (presumably) `#include` 
> > order, and I don't think we want to be in the business of inventing 
> > heuristics to pick the "right" typedef.
> > I don't think we want arbitrary typedefs to be able to declare themselves 
> > to be names for the class template after the fact: this is a decision that 
> > the (author of the) template itself should be making, not a decision for 
> > the (author of the) typedef. 
> 
> +1
> 
> 
> generally it's undesirable and problematic to mutate an existing declaration 
> -- it's much cleaner to introduce new properties of a declaration by 
> redeclaring it

Well, I can't argue with that one. :)

I see your point about the author of the typedef vs. the author of the 
template, but actually I'm ambivalent about your `format_arg` example. I could 
vaguely imagine that someone might want to see `absl::format_arg` in an error 
message, in the context of a call to `absl::format`, at least. But, I can see 
the point that hypotheticals aren't relevant; this attribute is specifically 
tailored for the STL's idiom of "class template with a bunch of closely 
associated typedefs," and the STL is monolithic enough that the class template 
always knows the exact names of those typedefs (I mean, in the STL, it's 
reasonable for a human to say that `basic_string_view` //is// `string_view`, in 
a way that it //is// not `format_arg`)... plus what you said above about 
Clang's internal implementation; so that's a good reason to stick with putting 
the attribute on the template.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91311

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


[PATCH] D91333: [clang][SveEmitter] Fix enum declarations. [NFCI]

2020-11-16 Thread Francesco Petrogalli 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 rG02bdbdc76021: [clang][SveEmitter] Fix enum declarations. 
[NFCI] (authored by fpetrogalli).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91333

Files:
  clang/test/Sema/aarch64-sve-enums.c
  clang/utils/TableGen/SveEmitter.cpp


Index: clang/utils/TableGen/SveEmitter.cpp
===
--- clang/utils/TableGen/SveEmitter.cpp
+++ clang/utils/TableGen/SveEmitter.cpp
@@ -416,10 +416,10 @@
 
 std::string SVEType::str() const {
   if (isPredicatePattern())
-return "sv_pattern";
+return "enum svpattern";
 
   if (isPrefetchOp())
-return "sv_prfop";
+return "enum svprfop";
 
   std::string S;
   if (Void)
@@ -1163,7 +1163,7 @@
   OS << "typedef __clang_svbfloat16x4_t svbfloat16x4_t;\n";
   OS << "#endif\n";
 
-  OS << "typedef enum\n";
+  OS << "enum svpattern\n";
   OS << "{\n";
   OS << "  SV_POW2 = 0,\n";
   OS << "  SV_VL1 = 1,\n";
@@ -1182,9 +1182,9 @@
   OS << "  SV_MUL4 = 29,\n";
   OS << "  SV_MUL3 = 30,\n";
   OS << "  SV_ALL = 31\n";
-  OS << "} sv_pattern;\n\n";
+  OS << "};\n\n";
 
-  OS << "typedef enum\n";
+  OS << "enum svprfop\n";
   OS << "{\n";
   OS << "  SV_PLDL1KEEP = 0,\n";
   OS << "  SV_PLDL1STRM = 1,\n";
@@ -1198,7 +1198,7 @@
   OS << "  SV_PSTL2STRM = 11,\n";
   OS << "  SV_PSTL3KEEP = 12,\n";
   OS << "  SV_PSTL3STRM = 13\n";
-  OS << "} sv_prfop;\n\n";
+  OS << "};\n\n";
 
   OS << "/* Function attributes */\n";
   OS << "#define __aio static inline __attribute__((__always_inline__, "
Index: clang/test/Sema/aarch64-sve-enums.c
===
--- /dev/null
+++ clang/test/Sema/aarch64-sve-enums.c
@@ -0,0 +1,19 @@
+// REQUIRES: aarch64-registered-target
+// RUN: %clang_cc1 %s -triple aarch64-none-linux-gnu -target-feature +sve 
-fallow-half-arguments-and-returns  -fsyntax-only -verify
+// expected-no-diagnostics
+
+// This test makes sure that the enum declarations in section "5. Enum
+// declarations" of the SVE ACLE [1] are not presented as typedefs in
+// `arm_sve.h`. It does so by creating a typedef'd struct with the
+// same identifier as the one defined in `arm_sve.h`, then checking that
+// it does not overload the enum defined in `arm_sve.h`.
+//
+// [1] https://developer.arm.com/documentation/100987/latest version 00bet6
+
+typedef struct { float f; } svpattern;
+typedef struct { float f; } svprfop;
+#include 
+enum svpattern a1 = SV_ALL;
+svpattern b1 = {1.0f};
+enum svprfop a2 = SV_PLDL1KEEP;
+svprfop b2 = {1.0f};


Index: clang/utils/TableGen/SveEmitter.cpp
===
--- clang/utils/TableGen/SveEmitter.cpp
+++ clang/utils/TableGen/SveEmitter.cpp
@@ -416,10 +416,10 @@
 
 std::string SVEType::str() const {
   if (isPredicatePattern())
-return "sv_pattern";
+return "enum svpattern";
 
   if (isPrefetchOp())
-return "sv_prfop";
+return "enum svprfop";
 
   std::string S;
   if (Void)
@@ -1163,7 +1163,7 @@
   OS << "typedef __clang_svbfloat16x4_t svbfloat16x4_t;\n";
   OS << "#endif\n";
 
-  OS << "typedef enum\n";
+  OS << "enum svpattern\n";
   OS << "{\n";
   OS << "  SV_POW2 = 0,\n";
   OS << "  SV_VL1 = 1,\n";
@@ -1182,9 +1182,9 @@
   OS << "  SV_MUL4 = 29,\n";
   OS << "  SV_MUL3 = 30,\n";
   OS << "  SV_ALL = 31\n";
-  OS << "} sv_pattern;\n\n";
+  OS << "};\n\n";
 
-  OS << "typedef enum\n";
+  OS << "enum svprfop\n";
   OS << "{\n";
   OS << "  SV_PLDL1KEEP = 0,\n";
   OS << "  SV_PLDL1STRM = 1,\n";
@@ -1198,7 +1198,7 @@
   OS << "  SV_PSTL2STRM = 11,\n";
   OS << "  SV_PSTL3KEEP = 12,\n";
   OS << "  SV_PSTL3STRM = 13\n";
-  OS << "} sv_prfop;\n\n";
+  OS << "};\n\n";
 
   OS << "/* Function attributes */\n";
   OS << "#define __aio static inline __attribute__((__always_inline__, "
Index: clang/test/Sema/aarch64-sve-enums.c
===
--- /dev/null
+++ clang/test/Sema/aarch64-sve-enums.c
@@ -0,0 +1,19 @@
+// REQUIRES: aarch64-registered-target
+// RUN: %clang_cc1 %s -triple aarch64-none-linux-gnu -target-feature +sve -fallow-half-arguments-and-returns  -fsyntax-only -verify
+// expected-no-diagnostics
+
+// This test makes sure that the enum declarations in section "5. Enum
+// declarations" of the SVE ACLE [1] are not presented as typedefs in
+// `arm_sve.h`. It does so by creating a typedef'd struct with the
+// same identifier as the one defined in `arm_sve.h`, then checking that
+// it does not overload the enum defined in `arm_sve.h`.
+//
+// [1] https://developer.arm.com/documentation/100987/latest version 00bet6
+
+typedef struct { float f; } svpattern;
+typedef struct { float f; } svprfop;
+#include 
+enum svpattern a1 = SV_ALL;
+svpattern b1 = {1.0f};
+enum svprfop a2 = 

[clang] 02bdbdc - [clang][SveEmitter] Fix enum declarations. [NFCI]

2020-11-16 Thread Francesco Petrogalli via cfe-commits

Author: Francesco Petrogalli
Date: 2020-11-16T14:49:45Z
New Revision: 02bdbdc76021fcfb8cae465363b362cb889406d2

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

LOG: [clang][SveEmitter] Fix enum declarations. [NFCI]

Adapt the declarations of `svpattern` and `svprfop` to the most recent
one defined in section "5. Enum declarations" of the SVE ACLE
specifications [1].

The signature of the intrinsics using these enums have been changed
accordingly.

A test has been added to make sure that `svpattern` and `svprfop` are
not typedefs.

[1] https://developer.arm.com/documentation/100987/latest, version
00bet6

Reviewed By: joechrisellis

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

Added: 
clang/test/Sema/aarch64-sve-enums.c

Modified: 
clang/utils/TableGen/SveEmitter.cpp

Removed: 




diff  --git a/clang/test/Sema/aarch64-sve-enums.c 
b/clang/test/Sema/aarch64-sve-enums.c
new file mode 100644
index ..01b110645f1f
--- /dev/null
+++ b/clang/test/Sema/aarch64-sve-enums.c
@@ -0,0 +1,19 @@
+// REQUIRES: aarch64-registered-target
+// RUN: %clang_cc1 %s -triple aarch64-none-linux-gnu -target-feature +sve 
-fallow-half-arguments-and-returns  -fsyntax-only -verify
+// expected-no-diagnostics
+
+// This test makes sure that the enum declarations in section "5. Enum
+// declarations" of the SVE ACLE [1] are not presented as typedefs in
+// `arm_sve.h`. It does so by creating a typedef'd struct with the
+// same identifier as the one defined in `arm_sve.h`, then checking that
+// it does not overload the enum defined in `arm_sve.h`.
+//
+// [1] https://developer.arm.com/documentation/100987/latest version 00bet6
+
+typedef struct { float f; } svpattern;
+typedef struct { float f; } svprfop;
+#include 
+enum svpattern a1 = SV_ALL;
+svpattern b1 = {1.0f};
+enum svprfop a2 = SV_PLDL1KEEP;
+svprfop b2 = {1.0f};

diff  --git a/clang/utils/TableGen/SveEmitter.cpp 
b/clang/utils/TableGen/SveEmitter.cpp
index 1d42edd8a94a..8a705bc4b5b8 100644
--- a/clang/utils/TableGen/SveEmitter.cpp
+++ b/clang/utils/TableGen/SveEmitter.cpp
@@ -416,10 +416,10 @@ std::string SVEType::builtin_str() const {
 
 std::string SVEType::str() const {
   if (isPredicatePattern())
-return "sv_pattern";
+return "enum svpattern";
 
   if (isPrefetchOp())
-return "sv_prfop";
+return "enum svprfop";
 
   std::string S;
   if (Void)
@@ -1163,7 +1163,7 @@ void SVEEmitter::createHeader(raw_ostream ) {
   OS << "typedef __clang_svbfloat16x4_t svbfloat16x4_t;\n";
   OS << "#endif\n";
 
-  OS << "typedef enum\n";
+  OS << "enum svpattern\n";
   OS << "{\n";
   OS << "  SV_POW2 = 0,\n";
   OS << "  SV_VL1 = 1,\n";
@@ -1182,9 +1182,9 @@ void SVEEmitter::createHeader(raw_ostream ) {
   OS << "  SV_MUL4 = 29,\n";
   OS << "  SV_MUL3 = 30,\n";
   OS << "  SV_ALL = 31\n";
-  OS << "} sv_pattern;\n\n";
+  OS << "};\n\n";
 
-  OS << "typedef enum\n";
+  OS << "enum svprfop\n";
   OS << "{\n";
   OS << "  SV_PLDL1KEEP = 0,\n";
   OS << "  SV_PLDL1STRM = 1,\n";
@@ -1198,7 +1198,7 @@ void SVEEmitter::createHeader(raw_ostream ) {
   OS << "  SV_PSTL2STRM = 11,\n";
   OS << "  SV_PSTL3KEEP = 12,\n";
   OS << "  SV_PSTL3STRM = 13\n";
-  OS << "} sv_prfop;\n\n";
+  OS << "};\n\n";
 
   OS << "/* Function attributes */\n";
   OS << "#define __aio static inline __attribute__((__always_inline__, "



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


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

2020-11-16 Thread Wei Xiao via Phabricator via cfe-commits
wxiao3 added a comment.

Please add register allocation code owner: "qcolombet" to the reviewer list.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87981

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


[PATCH] D91067: [AArch64][SVE] Support implicit lax vector conversions for SVE types

2020-11-16 Thread Joe Ellis via Phabricator via cfe-commits
joechrisellis updated this revision to Diff 305494.
joechrisellis added a comment.

Remove failing test; it was checking that a conversion _failed_, although the 
conversion should now _pass_ given the changes in this patch.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91067

Files:
  clang/include/clang/AST/ASTContext.h
  clang/lib/AST/ASTContext.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/lib/Sema/SemaOverload.cpp
  clang/test/Sema/aarch64-sve-lax-vector-conversions.c
  clang/test/Sema/attr-arm-sve-vector-bits.c
  clang/test/SemaCXX/aarch64-sve-lax-vector-conversions.cpp

Index: clang/test/SemaCXX/aarch64-sve-lax-vector-conversions.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/aarch64-sve-lax-vector-conversions.cpp
@@ -0,0 +1,34 @@
+// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve -msve-vector-bits=512 -flax-vector-conversions=none -fallow-half-arguments-and-returns -ffreestanding -fsyntax-only -verify=lax-vector-none %s
+// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve -msve-vector-bits=512 -flax-vector-conversions=integer -fallow-half-arguments-and-returns -ffreestanding -fsyntax-only -verify=lax-vector-integer %s
+// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve -msve-vector-bits=512 -flax-vector-conversions=all -fallow-half-arguments-and-returns -ffreestanding -fsyntax-only -verify=lax-vector-all %s
+
+// lax-vector-all-no-diagnostics
+
+#include 
+
+#define N __ARM_FEATURE_SVE_BITS
+#define FIXED_ATTR __attribute__((arm_sve_vector_bits(N)))
+
+typedef svfloat32_t fixed_float32_t FIXED_ATTR;
+typedef svint32_t fixed_int32_t FIXED_ATTR;
+
+void allowed_with_integer_lax_conversions() {
+  fixed_int32_t fi32;
+  svint64_t si64;
+
+  // The implicit cast here should fail if -flax-vector-conversions=none, but pass if
+  // -flax-vector-conversions={integer,all}.
+  fi32 = si64;
+  // lax-vector-none-error@-1 {{assigning to 'fixed_int32_t' (vector of 16 'int' values) from incompatible type}}
+}
+
+void allowed_with_all_lax_conversions() {
+  fixed_float32_t ff32;
+  svfloat64_t sf64;
+
+  // The implicit cast here should fail if -flax-vector-conversions={none,integer}, but pass if
+  // -flax-vector-conversions=all.
+  ff32 = sf64;
+  // lax-vector-none-error@-1 {{assigning to 'fixed_float32_t' (vector of 16 'float' values) from incompatible type}}
+  // lax-vector-integer-error@-2 {{assigning to 'fixed_float32_t' (vector of 16 'float' values) from incompatible type}}
+}
Index: clang/test/Sema/attr-arm-sve-vector-bits.c
===
--- clang/test/Sema/attr-arm-sve-vector-bits.c
+++ clang/test/Sema/attr-arm-sve-vector-bits.c
@@ -270,7 +270,6 @@
 TEST_CAST_COMMON(bool)
 
 // Test the implicit conversion only applies to valid types
-fixed_int8_t to_fixed_int8_t__from_svuint8_t(svuint8_t x) { return x; } // expected-error-re {{returning 'svuint8_t' (aka '__SVUint8_t') from a function with incompatible result type 'fixed_int8_t' (vector of {{[0-9]+}} 'signed char' values)}}
 fixed_bool_t to_fixed_bool_t__from_svint32_t(svint32_t x) { return x; } // expected-error-re {{returning 'svint32_t' (aka '__SVInt32_t') from a function with incompatible result type 'fixed_bool_t' (vector of {{[0-9]+}} 'unsigned char' values)}}
 
 svint64_t to_svint64_t__from_gnu_int32_t(gnu_int32_t x) { return x; } // expected-error-re {{returning 'gnu_int32_t' (vector of {{[0-9]+}} 'int32_t' values) from a function with incompatible result type 'svint64_t' (aka '__SVInt64_t')}}
Index: clang/test/Sema/aarch64-sve-lax-vector-conversions.c
===
--- /dev/null
+++ clang/test/Sema/aarch64-sve-lax-vector-conversions.c
@@ -0,0 +1,34 @@
+// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve -msve-vector-bits=512 -flax-vector-conversions=none -fallow-half-arguments-and-returns -ffreestanding -fsyntax-only -verify=lax-vector-none %s
+// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve -msve-vector-bits=512 -flax-vector-conversions=integer -fallow-half-arguments-and-returns -ffreestanding -fsyntax-only -verify=lax-vector-integer %s
+// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve -msve-vector-bits=512 -flax-vector-conversions=all -fallow-half-arguments-and-returns -ffreestanding -fsyntax-only -verify=lax-vector-all %s
+
+// lax-vector-all-no-diagnostics
+
+#include 
+
+#define N __ARM_FEATURE_SVE_BITS
+#define FIXED_ATTR __attribute__((arm_sve_vector_bits(N)))
+
+typedef svfloat32_t fixed_float32_t FIXED_ATTR;
+typedef svint32_t fixed_int32_t FIXED_ATTR;
+
+void allowed_with_integer_lax_conversions() {
+  fixed_int32_t fi32;
+  svint64_t si64;
+
+  // The implicit cast here should fail if -flax-vector-conversions=none, but pass if
+  // 

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

2020-11-16 Thread Wei Xiao via Phabricator via cfe-commits
wxiao3 added inline comments.



Comment at: llvm/include/llvm/CodeGen/LiveRegMatrix.h:44
   VirtRegMap *VRM;
+  MachineRegisterInfo *MRI;
 

what's the purpose of this member?



Comment at: llvm/lib/Target/X86/X86RegisterInfo.cpp:917
+  }
+  for (MCPhysReg PhysReg : Order) {
+if (!MRI->isReserved(PhysReg))

Don't need to add PhysReg again if PhysReg is already in Hints.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87981

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


[PATCH] D91519: [AST][Mach0] Fix unused-variable warnings

2020-11-16 Thread Matt Arsenault via Phabricator via cfe-commits
arsenm added inline comments.



Comment at: lld/MachO/SymbolTable.cpp:137
 // error message.
-if (auto *defined = dyn_cast(s))
+if (dyn_cast(s))
   error("found defined symbol with illegal name " + DSOHandle::name);

Should use isa


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91519

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


[PATCH] D91311: Add new 'preferred_name' attribute.

2020-11-16 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: libcxx/include/regex:2520
+_LIBCPP_PREFERRED_NAME(wregex)
+basic_regex
 {

rsmith wrote:
> Quuxplusone wrote:
> > Why does this attribute go on the class template? Shouldn't it be an 
> > attribute on the typedef, so that you don't have to repeat yourself? I 
> > mean, I'd much rather see
> > 
> > template class BasicFoo { };
> > using [[preferred]] Foo = BasicFoo;
> > using [[preferred]] WFoo = BasicFoo;
> > 
> > than
> > 
> > template class BasicFoo;
> > using Foo = BasicFoo;
> > using WFoo = BasicFoo;
> > template class [[preferred(Foo, WFoo)]] BasicFoo { };
> > 
> > The latter repeats every identifier one extra time, compared to the former.
> > 
> > And then, in fact, couldn't you go one step further and say that typedefs 
> > in the same scope as the class template itself should //always// implicitly 
> > have this attribute? Even if the attribute doesn't appear in the source 
> > code, we still want to print `basic_regex` as `regex`, right? It 
> > shouldn't cost any additional work for the compiler to figure that out.
> I don't think we want arbitrary typedefs to be able to declare themselves to 
> be names for the class template after the fact: this is a decision that the 
> (author of the) template itself should be making, not a decision for the 
> (author of the) typedef. Also, we need the information when looking at the 
> class template, not when looking at the typedef, so attaching it to the 
> typedef would require us to internally attach it to the class template 
> instead anyway, and generally it's undesirable and problematic to mutate an 
> existing declaration -- it's much cleaner to introduce new properties of a 
> declaration by redeclaring it. It's certainly not ideal that this results in 
> extra forward declarations in some cases, but given that this attribute is 
> only expected to be written a few dozen times in total, it doesn't seem worth 
> worrying about too much.
> 
> I don't think we want typedefs to automatically get this behavior, even if 
> they're in the same namespace. I think it would be problematic if, for 
> example:
> 
> ```
> namespace absl {
>   template struct basic_string_view;
>   using format_arg = basic_string_view;
>   std::string format(format_arg, ...);
> }
> ```
> 
> ... resulted in `absl::string_view` sometimes displaying as the (to a user) 
> unrelated type `absl::format_arg` depending on (presumably) `#include` order, 
> and I don't think we want to be in the business of inventing heuristics to 
> pick the "right" typedef.
> I don't think we want arbitrary typedefs to be able to declare themselves to 
> be names for the class template after the fact: this is a decision that the 
> (author of the) template itself should be making, not a decision for the 
> (author of the) typedef. 

+1




Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91311

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


  1   2   >