[PATCH] D114396: [Driver] Default to current FreeBSD profiling behaviour

2021-11-22 Thread Dimitry Andric via Phabricator via cfe-commits
dim accepted this revision.
dim added a comment.
This revision is now accepted and ready to land.

LGTM


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

https://reviews.llvm.org/D114396

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


[PATCH] D114320: [clang-format] Extend AllowShortBlocksOnASingleLine for else blocks

2021-11-22 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay added a comment.

Ok now I'm a little puzzled, shouldn't this be covered by 
`AllowShortIfStatementsOnASingleLine`?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D114320

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


[PATCH] D113107: Support of expression granularity for _Float16.

2021-11-22 Thread John McCall via Phabricator via cfe-commits
rjmccall added a comment.

For that example, yes, approach #3 would result in that exact same IR on 
targets that lack direct hardware support for `_Float16` operations.  But 
getting that behavior right in general requires a different implementation than 
is provided by this patch, which is implementing approach #4 and 
inappropriately changing the formal types of expressions.

In contrast, approach #1 would produce IR like this:

  define dso_local arm_aapcscc half @foo(half %a, half %b, half %c) #0 {
  entry:
%a.addr = alloca half, align 2
%b.addr = alloca half, align 2
%c.addr = alloca half, align 2
store half %a, half* %a.addr, align 2
store half %b, half* %b.addr, align 2
store half %c, half* %c.addr, align 2
%0 = load half, half* %a.addr, align 2
%conv = fpext half %0 to float
%1 = load half, half* %b.addr, align 2
%conv1 = fpext half %1 to float
%add = fadd float %conv, %conv1
%trunc = fptrunc float %add to half
%ext = fpext half %trunc to float
%2 = load half, half* %c.addr, align 2
%conv2 = fpext half %2 to float
%add3 = fadd float %ext, %conv2
%3 = fptrunc float %add3 to half
ret half %3
  }

I was under the impression that `-fexcess-precision` had some sort of strict 
mode that forces this pattern, but apparently not, and the choices are just 
between `standard` (truncation is only forced at casts and assignments) and 
`fast` (optimizer has free rein to remove truncations).


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

https://reviews.llvm.org/D113107

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


[PATCH] D113107: Support of expression granularity for _Float16.

2021-11-22 Thread Phoebe Wang via Phabricator via cfe-commits
pengfei added inline comments.



Comment at: clang/test/CodeGen/X86/Float16-aritmetic.c:8-9
+  // CHECK: alloca half
+  // CHECK: store half {{.*}}, half*
+  // CHECK: store half {{.*}}, half*
+  // CHECK: load half, half*

zahiraam wrote:
> pengfei wrote:
> > This isn't correct without the ABI code change. I did some work in D107082. 
> > I plan to refactor (if I have enough time)
> If this the output we want to generate, should the changes D107082 happen 
> before the changes in this patch?
I think I made a mistake. This is correct, though if probably crashes in 
backend without D107082.


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

https://reviews.llvm.org/D113107

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


[PATCH] D113107: Support of expression granularity for _Float16.

2021-11-22 Thread Phoebe Wang via Phabricator via cfe-commits
pengfei added a comment.

> Should also generate this same IR right?

For `a + b + c`, yes, they are the same. For `a + b`, no. That's the difference 
between approaches #3 and #4, which I didn't emphasize before :) 
https://godbolt.org/z/onbGeqdYv


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

https://reviews.llvm.org/D113107

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


[PATCH] D114082: [WIP] Normalize String Attributes

2021-11-22 Thread Mehdi AMINI via Phabricator via cfe-commits
mehdi_amini added a comment.

The patch is pretty large, any chance you could split in two? First the change 
introducing the AttributeKey and changing the API, and then updating all the 
callees separately as a follow up?




Comment at: llvm/include/llvm/IR/Attributes.h:84
+  }
+};
 

This whole code deserves documentation I think.



Comment at: llvm/lib/IR/Attributes.cpp:125
   FoldingSetNodeID ID;
-  ID.AddString(Kind);
+  ID.AddString(Kind.value());
   if (!Val.empty()) ID.AddString(Val);

Seems like this method does not use anything than the `StringRef` inside the 
Kind, why change it to take an `AttributeKey`? Won't you eagerly compute the 
hash even if not needed?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D114082

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


[PATCH] D22505: [clang-format] Access Modifier Use Normal Indent

2021-11-22 Thread Björn Schäpers via Phabricator via cfe-commits
HazardyKnusperkeks added a comment.

In D22505#3147501 , @MyDeveloperDay 
wrote:

> I think so, it came to the top because someone subscribed to it, I was 
> wondering if this was something that is still needed or if our existing 
> options cover this.
>
> I recently came across a style like this. I don't know if there is still 
> interest.

I definitely think there is interest, but is there someone willing to implement 
it? :)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D22505

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


[PATCH] D114379: [OMPIRBuilder] Add support for simd (loop) directive.

2021-11-22 Thread Michael Kruse via Phabricator via cfe-commits
Meinersbur requested changes to this revision.
Meinersbur added a comment.
This revision now requires changes to proceed.

Thanks for helping to complete the OpenMPIRBuilder implementation!




Comment at: clang/lib/CodeGen/CGStmtOpenMP.cpp:2586-2587
 void CodeGenFunction::EmitOMPSimdDirective(const OMPSimdDirective &S) {
+
+  bool UseOMPIRBuilder = CGM.getLangOpts().OpenMPIRBuilder;
+  if (UseOMPIRBuilder) {

[nit] Unnecessary whitespace



Comment at: clang/lib/CodeGen/CGStmtOpenMP.cpp:2587
+
+  bool UseOMPIRBuilder = CGM.getLangOpts().OpenMPIRBuilder;
+  if (UseOMPIRBuilder) {

Did you consider adding a check whether OpenMPIRBuilder actually implements all 
features requested before using it? See `isSupportedByOpenMPIRBuilder`.



Comment at: clang/lib/CodeGen/CGStmtOpenMP.cpp:2594
+// Emit the associated statement and get its loop representation.
+auto DL = SourceLocToDebugLoc(S.getBeginLoc());
+const Stmt *Inner = S.getRawStmt();

[style] According to the [[ 
https://llvm.org/docs/CodingStandards.html#use-auto-type-deduction-to-make-code-more-readable
 | LLVM coding standard ]], `auto` is only used in specific cases.



Comment at: clang/test/OpenMP/simd_codegen_irbuilder.cpp:16
+// CHECK-NEXT: call void @__captured_stmt.1(i32* %i, i32 %omp_loop.iv, 
%struct.anon.0* %agg.captured1)
+// CHECK-NEXT: %3 = load float*, float** %b.addr, align 8, 
!llvm.access.group !3
+// CHECK-NEXT: %4 = load i32, i32* %i, align 4, !llvm.access.group !3

Could you use regexes to match the virtual register names? The script 
`update_cc_checks.py` may help with this, see the other tests.

The naming scheme for files testing the OpenMPIRBiulder is usually 
`irbuilder_`



Comment at: llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h:524
+  /// \param Loop The loop to simd-ise.
+  void createSIMDLoop(DebugLoc DL, CanonicalLoopInfo *Loop);
+

Capitalizing SIMD leads to long runs of capital letters. While not an LLVM 
coding style rule, it is still common to title-case acronyms in identifiers if 
the acronym is ~4 letters or more, such as `OMPSimdDirective` instead of 
`OMPSIMDDirective`.

For methods transformation `CanonicalLoopInfo`, we don't use `createXYZ` naming 
scheme which is reserved for inserting something new. Suggestions: `applySimd`, 
`vectorizeLoop`, or `simdizeLoop`.



Comment at: llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp:2120
+/// Attach metadata access.group to the load and store instructions of \p block
+static void addSIMDMetadata(BasicBlock *block,
+ArrayRef Properties) {

The LLVM coding style still capitalizes parameters and variables.



Comment at: llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp:2123
+  for (auto &I : *block) {
+if (isa(&I) || isa(&I)) {
+  Instruction *instr = dyn_cast(&I);

The property also applies to any memory access, e.g. `memset`. You could use 
`mayWriteToMemory()` and `mayReadFromMemory()`.



Comment at: llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp:2126
+  LLVMContext &C = instr->getContext();
+  MDNode *N = MDNode::get(C, MDString::get(C, ""));
+  instr->setMetadata("llvm.access.group", N);

[serious] The access group must be unique only to the loop being accessed.



Comment at: llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp:2157-2168
+  addSIMDMetadata(header,
+  {
+  MDNode::get(Ctx, MDString::get(Ctx, 
"llvm.access.group")),
+  });
+  addSIMDMetadata(cond,
+  {
+  MDNode::get(Ctx, MDString::get(Ctx, 
"llvm.access.group")),

[serious] header and cond don't contain any memory accesses. `body` may consist 
of multiple basic blocks, of which this only applies to the first one. 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D114379

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


[PATCH] D114408: Fold a lot of ffixed_x if judgments

2021-11-22 Thread Shao-Ce SUN via Phabricator via cfe-commits
achieveartificialintelligence updated this revision to Diff 389091.
achieveartificialintelligence added a comment.

Fix


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D114408

Files:
  clang/lib/Driver/ToolChains/Arch/RISCV.cpp


Index: clang/lib/Driver/ToolChains/Arch/RISCV.cpp
===
--- clang/lib/Driver/ToolChains/Arch/RISCV.cpp
+++ clang/lib/Driver/ToolChains/Arch/RISCV.cpp
@@ -73,68 +73,12 @@
 getRISCFeaturesFromMcpu(D, Triple, Args, A, A->getValue(), Features);
 
   // Handle features corresponding to "-ffixed-X" options
-  if (Args.hasArg(options::OPT_ffixed_x1))
-Features.push_back("+reserve-x1");
-  if (Args.hasArg(options::OPT_ffixed_x2))
-Features.push_back("+reserve-x2");
-  if (Args.hasArg(options::OPT_ffixed_x3))
-Features.push_back("+reserve-x3");
-  if (Args.hasArg(options::OPT_ffixed_x4))
-Features.push_back("+reserve-x4");
-  if (Args.hasArg(options::OPT_ffixed_x5))
-Features.push_back("+reserve-x5");
-  if (Args.hasArg(options::OPT_ffixed_x6))
-Features.push_back("+reserve-x6");
-  if (Args.hasArg(options::OPT_ffixed_x7))
-Features.push_back("+reserve-x7");
-  if (Args.hasArg(options::OPT_ffixed_x8))
-Features.push_back("+reserve-x8");
-  if (Args.hasArg(options::OPT_ffixed_x9))
-Features.push_back("+reserve-x9");
-  if (Args.hasArg(options::OPT_ffixed_x10))
-Features.push_back("+reserve-x10");
-  if (Args.hasArg(options::OPT_ffixed_x11))
-Features.push_back("+reserve-x11");
-  if (Args.hasArg(options::OPT_ffixed_x12))
-Features.push_back("+reserve-x12");
-  if (Args.hasArg(options::OPT_ffixed_x13))
-Features.push_back("+reserve-x13");
-  if (Args.hasArg(options::OPT_ffixed_x14))
-Features.push_back("+reserve-x14");
-  if (Args.hasArg(options::OPT_ffixed_x15))
-Features.push_back("+reserve-x15");
-  if (Args.hasArg(options::OPT_ffixed_x16))
-Features.push_back("+reserve-x16");
-  if (Args.hasArg(options::OPT_ffixed_x17))
-Features.push_back("+reserve-x17");
-  if (Args.hasArg(options::OPT_ffixed_x18))
-Features.push_back("+reserve-x18");
-  if (Args.hasArg(options::OPT_ffixed_x19))
-Features.push_back("+reserve-x19");
-  if (Args.hasArg(options::OPT_ffixed_x20))
-Features.push_back("+reserve-x20");
-  if (Args.hasArg(options::OPT_ffixed_x21))
-Features.push_back("+reserve-x21");
-  if (Args.hasArg(options::OPT_ffixed_x22))
-Features.push_back("+reserve-x22");
-  if (Args.hasArg(options::OPT_ffixed_x23))
-Features.push_back("+reserve-x23");
-  if (Args.hasArg(options::OPT_ffixed_x24))
-Features.push_back("+reserve-x24");
-  if (Args.hasArg(options::OPT_ffixed_x25))
-Features.push_back("+reserve-x25");
-  if (Args.hasArg(options::OPT_ffixed_x26))
-Features.push_back("+reserve-x26");
-  if (Args.hasArg(options::OPT_ffixed_x27))
-Features.push_back("+reserve-x27");
-  if (Args.hasArg(options::OPT_ffixed_x28))
-Features.push_back("+reserve-x28");
-  if (Args.hasArg(options::OPT_ffixed_x29))
-Features.push_back("+reserve-x29");
-  if (Args.hasArg(options::OPT_ffixed_x30))
-Features.push_back("+reserve-x30");
-  if (Args.hasArg(options::OPT_ffixed_x31))
-Features.push_back("+reserve-x31");
+#define HAS_FFIXED_X(I)
\
+  (if (Args.hasArg(options::OPT_ffixed_x(I)))  
\
+   Features.push_back("+reserve-x(I)"))
+
+  for (int I = 1; I <= 31; ++I)
+HAS_FFIXED_X(I);
 
   // -mrelax is default, unless -mno-relax is specified.
   if (Args.hasFlag(options::OPT_mrelax, options::OPT_mno_relax, true))


Index: clang/lib/Driver/ToolChains/Arch/RISCV.cpp
===
--- clang/lib/Driver/ToolChains/Arch/RISCV.cpp
+++ clang/lib/Driver/ToolChains/Arch/RISCV.cpp
@@ -73,68 +73,12 @@
 getRISCFeaturesFromMcpu(D, Triple, Args, A, A->getValue(), Features);
 
   // Handle features corresponding to "-ffixed-X" options
-  if (Args.hasArg(options::OPT_ffixed_x1))
-Features.push_back("+reserve-x1");
-  if (Args.hasArg(options::OPT_ffixed_x2))
-Features.push_back("+reserve-x2");
-  if (Args.hasArg(options::OPT_ffixed_x3))
-Features.push_back("+reserve-x3");
-  if (Args.hasArg(options::OPT_ffixed_x4))
-Features.push_back("+reserve-x4");
-  if (Args.hasArg(options::OPT_ffixed_x5))
-Features.push_back("+reserve-x5");
-  if (Args.hasArg(options::OPT_ffixed_x6))
-Features.push_back("+reserve-x6");
-  if (Args.hasArg(options::OPT_ffixed_x7))
-Features.push_back("+reserve-x7");
-  if (Args.hasArg(options::OPT_ffixed_x8))
-Features.push_back("+reserve-x8");
-  if (Args.hasArg(options::OPT_ffixed_x9))
-Features.push_back("+reserve-x9");
-  if (Args.hasArg(options::OPT_ffixed_x10))
-Features.push_back("+reserve-x10");
-  if (Args.hasArg(options::OPT_ffixed_x11))
-Featu

[PATCH] D114411: [WIP][modules] Avoid deserializing Decls from hidden (sub)modules.

2021-11-22 Thread Volodymyr Sapsai via Phabricator via cfe-commits
vsapsai created this revision.
Herald added a subscriber: ributzka.
vsapsai requested review of this revision.
Herald added a project: clang.

The test case is for Objective-C but it is likely other languages like
C++ are affected as well, just haven't created appropriate test cases.

The test case fails with the following error

  clang/test/Modules/Output/ambiguous-enum-lookup.m.tmp/test.m:7:11: error: 
reference to 'kEnumValue' is ambiguous
  s.x = kEnumValue;
^
  
clang/test/Modules/Output/ambiguous-enum-lookup.m.tmp/Frameworks/NonModular.framework/Headers/NonModular.h:8:5:
 note: candidate found by name lookup is 'kEnumValue'
  kEnumValue = 1,
  ^
  
clang/test/Modules/Output/ambiguous-enum-lookup.m.tmp/Frameworks/NonModular.framework/Headers/NonModular.h:8:5:
 note: candidate found by name lookup is 'kEnumValue'
  kEnumValue = 1,
  ^

It happens because we have 2 EnumConstantDecl for 'kEnumValue' - one from
PiecewiseVisible module, another non-modular. And the the name lookup is
ambiguous because these decls have different canonical decls.
Non-modular decl believes it is the canonical decl because that's the
behavior for Mergeable and in the source code non-modular decl comes
before other EnumConstantDecl. Modular EnumConstantDecl has no intention
of being canonical decl but it is deserialized *before* non-modular decl
is created, so as the only decl it becomes the canonical decl.

The idea for the fix is to skip deserialization of decls from hidden
(sub)modules, thus allowing to establish correct canonical decl. This is
a proof of concept, the implementation isn't optimal, and there are
failing tests. I mostly wanted to share the approach to discuss it.

Another high-level approach I've considered is to enhance handling decls
from hidden modules and to delay connecting them with redecl chains and
canonical decls till the moment they become visible. I've decided to go
with "avoid deserialization" approach because this way we should be
doing less work and it seems less error-prone compared to juggling with
existing decls.

rdar://82908206


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D114411

Files:
  clang/lib/Serialization/ASTReader.cpp
  clang/lib/Serialization/ASTReaderDecl.cpp
  clang/lib/Serialization/ASTWriterDecl.cpp
  clang/test/Modules/ambiguous-enum-lookup.m

Index: clang/test/Modules/ambiguous-enum-lookup.m
===
--- /dev/null
+++ clang/test/Modules/ambiguous-enum-lookup.m
@@ -0,0 +1,42 @@
+// RUN: rm -rf %t
+// RUN: split-file %s %t
+// RUN: %clang_cc1 -fsyntax-only -fmodules -fimplicit-module-maps -fmodules-cache-path=%t/modules.cache -F %t/Frameworks %t/test.m
+
+//--- Frameworks/NonModular.framework/Headers/NonModular.h
+#ifndef NonModular_NonModular_h
+#define NonModular_NonModular_h
+struct SomeStruct {
+int x;
+};
+
+enum SomeEnum {
+kEnumValue = 1,
+};
+#endif
+
+//--- Frameworks/PiecewiseVisible.framework/Headers/InitiallyVisible.h
+// empty
+
+//--- Frameworks/PiecewiseVisible.framework/Headers/InitiallyHidden.h
+#include 
+
+//--- Frameworks/PiecewiseVisible.framework/Modules/module.modulemap
+framework module PiecewiseVisible {
+  header "InitiallyVisible.h"
+  export *
+
+  explicit module HiddenPiece {
+header "InitiallyHidden.h"
+export *
+  }
+}
+
+//--- test.m
+#include 
+#include 
+#include 
+
+void test() {
+struct SomeStruct s;
+s.x = kEnumValue;
+}
Index: clang/lib/Serialization/ASTWriterDecl.cpp
===
--- clang/lib/Serialization/ASTWriterDecl.cpp
+++ clang/lib/Serialization/ASTWriterDecl.cpp
@@ -269,6 +269,7 @@
 }
 
 void ASTDeclWriter::Visit(Decl *D) {
+  Record.push_back(Writer.getSubmoduleID(D->getOwningModule()));
   DeclVisitor::Visit(D);
 
   // Source locations require array (variable-length) abbreviations.  The
@@ -1911,6 +1912,7 @@
   // Abbreviation for DECL_FIELD
   Abv = std::make_shared();
   Abv->Add(BitCodeAbbrevOp(serialization::DECL_FIELD));
+  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // SubmoduleID
   // Decl
   Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // DeclContext
   Abv->Add(BitCodeAbbrevOp(0));   // LexicalDeclContext
@@ -1944,6 +1946,7 @@
   // Abbreviation for DECL_OBJC_IVAR
   Abv = std::make_shared();
   Abv->Add(BitCodeAbbrevOp(serialization::DECL_OBJC_IVAR));
+  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // SubmoduleID
   // Decl
   Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // DeclContext
   Abv->Add(BitCodeAbbrevOp(0));   // LexicalDeclContext
@@ -1980,6 +1983,7 @@
   // Abbreviation for DECL_ENUM
   Abv = std::make_shared();
   Abv->Add(BitCodeAbbrevOp(serialization::DECL_ENUM));
+  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // SubmoduleID
   // Redeclarable
   Abv->Add(BitCodeAbbrevOp(0));   // No redeclaration
   // Decl
@@ -2030,6

[PATCH] D114320: [clang-format] Extend AllowShortBlocksOnASingleLine for else blocks

2021-11-22 Thread Owen Pan via Phabricator via cfe-commits
owenpan accepted this revision.
owenpan added a comment.

Should we add an if-else example to the documentation?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D114320

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


[PATCH] D114082: [WIP] Normalize String Attributes

2021-11-22 Thread Yilong Guo via Phabricator via cfe-commits
Nuu added a comment.

Thanks for this. I planned something similar to turn string literal typo errors 
into compile errors as well.
The typos are really hard to identify :-P

Some suggestions on using tablegen.




Comment at: llvm/include/llvm/IR/Attributes.h:977-1133
+constexpr llvm::AttributeKey
+AmdgpuFlatWorkGroupSizeAttr("amdgpu-flat-work-group-size");
+constexpr llvm::AttributeKey AmdgpuIeeeAttr("amdgpu-ieee");
+constexpr llvm::AttributeKey
+AmdgpuImplicitargNumBytesAttr("amdgpu-implicitarg-num-bytes");
+constexpr llvm::AttributeKey AmdgpuNumSgprAttr("amdgpu-num-sgpr");
+constexpr llvm::AttributeKey AmdgpuNumVgprAttr("amdgpu-num-vgpr");

I think we can simplify these definitions via "Attributes.inc", by adding one 
more class tablegen class and defining the symbolic -> display name mapping in 
"Attributes.td".


```
// llvm/utils/TableGen/Attributes.cpp emitTargetsIndependentNames()
Emit({"EnumAttr", "TypeAttr", "IntAttr"}, "ATTRIBUTE_ENUM");
Emit({"StrBoolAttr"}, "ATTRIBUTE_STRBOOL");
Emit({"StrKeyAttr"}, "ATTRIBUTE_KEY");
```



Comment at: llvm/include/llvm/IR/Attributes.td:43
 class StrBoolAttr : Attr;
 
 /// Target-independent enum attributes.

Define a dedicated tablegen class for AttributeKey generation.



Comment at: llvm/include/llvm/IR/Attributes.td:303
 def UseSampleProfile : StrBoolAttr<"use-sample-profile">;
 
 class CompatRule {

Map symbolic names with string literals.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D114082

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


[PATCH] D114408: Fold a lot of ffixed_x if judgments

2021-11-22 Thread Shao-Ce SUN via Phabricator via cfe-commits
achieveartificialintelligence created this revision.
achieveartificialintelligence added reviewers: simoncook, asb, lenary, 
luismarques.
Herald added subscribers: frasercrmck, apazos, sameer.abuasal, s.egerton, Jim, 
jocewei, PkmX, the_o, brucehoult, MartinMosbeck, rogfer01, edward-jones, 
zzheng, jrtc27, niosHD, sabuasal, johnrusso, rbar.
achieveartificialintelligence requested review of this revision.
Herald added subscribers: cfe-commits, MaskRay.
Herald added a project: clang.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D114408

Files:
  clang/lib/Driver/ToolChains/Arch/RISCV.cpp


Index: clang/lib/Driver/ToolChains/Arch/RISCV.cpp
===
--- clang/lib/Driver/ToolChains/Arch/RISCV.cpp
+++ clang/lib/Driver/ToolChains/Arch/RISCV.cpp
@@ -73,68 +73,12 @@
 getRISCFeaturesFromMcpu(D, Triple, Args, A, A->getValue(), Features);
 
   // Handle features corresponding to "-ffixed-X" options
-  if (Args.hasArg(options::OPT_ffixed_x1))
-Features.push_back("+reserve-x1");
-  if (Args.hasArg(options::OPT_ffixed_x2))
-Features.push_back("+reserve-x2");
-  if (Args.hasArg(options::OPT_ffixed_x3))
-Features.push_back("+reserve-x3");
-  if (Args.hasArg(options::OPT_ffixed_x4))
-Features.push_back("+reserve-x4");
-  if (Args.hasArg(options::OPT_ffixed_x5))
-Features.push_back("+reserve-x5");
-  if (Args.hasArg(options::OPT_ffixed_x6))
-Features.push_back("+reserve-x6");
-  if (Args.hasArg(options::OPT_ffixed_x7))
-Features.push_back("+reserve-x7");
-  if (Args.hasArg(options::OPT_ffixed_x8))
-Features.push_back("+reserve-x8");
-  if (Args.hasArg(options::OPT_ffixed_x9))
-Features.push_back("+reserve-x9");
-  if (Args.hasArg(options::OPT_ffixed_x10))
-Features.push_back("+reserve-x10");
-  if (Args.hasArg(options::OPT_ffixed_x11))
-Features.push_back("+reserve-x11");
-  if (Args.hasArg(options::OPT_ffixed_x12))
-Features.push_back("+reserve-x12");
-  if (Args.hasArg(options::OPT_ffixed_x13))
-Features.push_back("+reserve-x13");
-  if (Args.hasArg(options::OPT_ffixed_x14))
-Features.push_back("+reserve-x14");
-  if (Args.hasArg(options::OPT_ffixed_x15))
-Features.push_back("+reserve-x15");
-  if (Args.hasArg(options::OPT_ffixed_x16))
-Features.push_back("+reserve-x16");
-  if (Args.hasArg(options::OPT_ffixed_x17))
-Features.push_back("+reserve-x17");
-  if (Args.hasArg(options::OPT_ffixed_x18))
-Features.push_back("+reserve-x18");
-  if (Args.hasArg(options::OPT_ffixed_x19))
-Features.push_back("+reserve-x19");
-  if (Args.hasArg(options::OPT_ffixed_x20))
-Features.push_back("+reserve-x20");
-  if (Args.hasArg(options::OPT_ffixed_x21))
-Features.push_back("+reserve-x21");
-  if (Args.hasArg(options::OPT_ffixed_x22))
-Features.push_back("+reserve-x22");
-  if (Args.hasArg(options::OPT_ffixed_x23))
-Features.push_back("+reserve-x23");
-  if (Args.hasArg(options::OPT_ffixed_x24))
-Features.push_back("+reserve-x24");
-  if (Args.hasArg(options::OPT_ffixed_x25))
-Features.push_back("+reserve-x25");
-  if (Args.hasArg(options::OPT_ffixed_x26))
-Features.push_back("+reserve-x26");
-  if (Args.hasArg(options::OPT_ffixed_x27))
-Features.push_back("+reserve-x27");
-  if (Args.hasArg(options::OPT_ffixed_x28))
-Features.push_back("+reserve-x28");
-  if (Args.hasArg(options::OPT_ffixed_x29))
-Features.push_back("+reserve-x29");
-  if (Args.hasArg(options::OPT_ffixed_x30))
-Features.push_back("+reserve-x30");
-  if (Args.hasArg(options::OPT_ffixed_x31))
-Features.push_back("+reserve-x31");
+#define HAS_FFIXED_X(I)
\
+  (if (Args.hasArg(options::OPT_ffixed_x(I)))  
\
+   Features.push_back("+reserve-x(I)"))
+
+  for (int i = 1; i <= 31; ++i)
+HAS_FFIXED_X(i);
 
   // -mrelax is default, unless -mno-relax is specified.
   if (Args.hasFlag(options::OPT_mrelax, options::OPT_mno_relax, true))


Index: clang/lib/Driver/ToolChains/Arch/RISCV.cpp
===
--- clang/lib/Driver/ToolChains/Arch/RISCV.cpp
+++ clang/lib/Driver/ToolChains/Arch/RISCV.cpp
@@ -73,68 +73,12 @@
 getRISCFeaturesFromMcpu(D, Triple, Args, A, A->getValue(), Features);
 
   // Handle features corresponding to "-ffixed-X" options
-  if (Args.hasArg(options::OPT_ffixed_x1))
-Features.push_back("+reserve-x1");
-  if (Args.hasArg(options::OPT_ffixed_x2))
-Features.push_back("+reserve-x2");
-  if (Args.hasArg(options::OPT_ffixed_x3))
-Features.push_back("+reserve-x3");
-  if (Args.hasArg(options::OPT_ffixed_x4))
-Features.push_back("+reserve-x4");
-  if (Args.hasArg(options::OPT_ffixed_x5))
-Features.push_back("+reserve-x5");
-  if (Args.hasArg(options::OPT_ffixed_x6))
-Features.push_back("+reserve-x6");
-  if (Args.hasArg(options::OPT_ffixed_x7))
-Features.push_back("+reserve-x7");
-  if (Arg

[PATCH] D114407: [CUDA][SPIRV] Use OpenCLKernel CC for CUDA -> SPIRV

2021-11-22 Thread Daniele Castagna via Phabricator via cfe-commits
dcastagna created this revision.
Herald added subscribers: carlosgalvezp, Naghasan, ldrumm, ThomasRaoux, 
Anastasia, yaxunl.
dcastagna requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Select the OpenCLKernel calling convention for kernels when compiling
CUDA targeting SPIR-V.

In this way the generated LLVM IR will have a spir_kernel calling
convention that will be translated to an OpEntryPoint when converting
to SPIRV.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D114407

Files:
  clang/lib/Sema/SemaType.cpp
  clang/test/CodeGenCUDASPIRV/kernel-cc.cu


Index: clang/test/CodeGenCUDASPIRV/kernel-cc.cu
===
--- /dev/null
+++ clang/test/CodeGenCUDASPIRV/kernel-cc.cu
@@ -0,0 +1,9 @@
+// RUN: %clang_cc1 -fcuda-is-device -triple spirv32 -o - -emit-llvm -x cuda %s 
 | FileCheck %s
+// RUN: %clang_cc1 -fcuda-is-device -triple spirv64 -o - -emit-llvm -x cuda %s 
 | FileCheck %s
+
+// Verifies that building CUDA targeting SPIR-V {32,64} generates LLVM IR with
+// spir_kernel attributes for kernel functions.
+
+// CHECK: define spir_kernel void @_Z6kernelv()
+
+__attribute__((global)) void kernel() { return; }
Index: clang/lib/Sema/SemaType.cpp
===
--- clang/lib/Sema/SemaType.cpp
+++ clang/lib/Sema/SemaType.cpp
@@ -3941,6 +3941,20 @@
 break;
   }
 }
+  } else if (S.getLangOpts().CUDA) {
+// If we're compiling CUDA/HIP code and targeting SPIR-V we need to make
+// sure the kernels will be marked with the right calling convention so 
that
+// they will be visible by the APIs that ingest SPIR-V.
+llvm::Triple Triple = S.Context.getTargetInfo().getTriple();
+if (Triple.getArch() == llvm::Triple::spirv32 ||
+Triple.getArch() == llvm::Triple::spirv64) {
+  for (const ParsedAttr &AL : D.getDeclSpec().getAttributes()) {
+if (AL.getKind() == ParsedAttr::AT_CUDAGlobal) {
+  CC = CC_OpenCLKernel;
+  break;
+}
+  }
+}
   }
 
   return CC;


Index: clang/test/CodeGenCUDASPIRV/kernel-cc.cu
===
--- /dev/null
+++ clang/test/CodeGenCUDASPIRV/kernel-cc.cu
@@ -0,0 +1,9 @@
+// RUN: %clang_cc1 -fcuda-is-device -triple spirv32 -o - -emit-llvm -x cuda %s  | FileCheck %s
+// RUN: %clang_cc1 -fcuda-is-device -triple spirv64 -o - -emit-llvm -x cuda %s  | FileCheck %s
+
+// Verifies that building CUDA targeting SPIR-V {32,64} generates LLVM IR with
+// spir_kernel attributes for kernel functions.
+
+// CHECK: define spir_kernel void @_Z6kernelv()
+
+__attribute__((global)) void kernel() { return; }
Index: clang/lib/Sema/SemaType.cpp
===
--- clang/lib/Sema/SemaType.cpp
+++ clang/lib/Sema/SemaType.cpp
@@ -3941,6 +3941,20 @@
 break;
   }
 }
+  } else if (S.getLangOpts().CUDA) {
+// If we're compiling CUDA/HIP code and targeting SPIR-V we need to make
+// sure the kernels will be marked with the right calling convention so that
+// they will be visible by the APIs that ingest SPIR-V.
+llvm::Triple Triple = S.Context.getTargetInfo().getTriple();
+if (Triple.getArch() == llvm::Triple::spirv32 ||
+Triple.getArch() == llvm::Triple::spirv64) {
+  for (const ParsedAttr &AL : D.getDeclSpec().getAttributes()) {
+if (AL.getKind() == ParsedAttr::AT_CUDAGlobal) {
+  CC = CC_OpenCLKernel;
+  break;
+}
+  }
+}
   }
 
   return CC;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[Diffusion] rGc93f93b2e3f2: Revert "Revert "Recommit "Revert "[CVP] processSwitch: Remove default case when…

2021-11-22 Thread Kai Luo via Phabricator via cfe-commits
lkail added a comment.

Looks a more general way should be implemented in tailduplicator to avoid 
adding quadratic edges in CFGs.


BRANCHES
  EmptyLineAfterFunctionDefinition, fix_asan, main

Users:
  junparser (Author)

https://reviews.llvm.org/rGc93f93b2e3f2

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


[PATCH] D114381: [AIX] Disable unsupported offloading gpu tests

2021-11-22 Thread Steven Wan via Phabricator via cfe-commits
stevewan added a comment.

LGTM. Thanks.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D114381

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


[PATCH] D110549: [HIPSPV][1/4] Refactor HIP tool chain

2021-11-22 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl added inline comments.



Comment at: clang/lib/Driver/ToolChains/HIPUtility.cpp:119-133
+  // Add MC directives to embed target binaries. We ensure that each
+  // section and image is 16-byte aligned. This is not mandatory, but
+  // increases the likelihood of data to be aligned with a cache block
+  // in several main host machines.
+  ObjStream << "#   HIP Object Generator\n";
+  ObjStream << "# *** Automatically generated by Clang ***\n";
+  ObjStream << "  .protected __hip_fatbin\n";

echristo wrote:
> tra wrote:
> > Using MC for just wrapping a blob into an object file strikes me as 
> > something MC is not intended for.
> > 
> > @echristo -- is it OK to use MC as a tool in the standard compilation 
> > pipeline? I vaguely recall we had a conversaion about using objcopy for 
> > similar purposes during early days of CUDA and the conclusion was that we 
> > generally don't want that. I might be wrong, too, it's been too long ago.
> Using llvm-mc the binary? No. That's definitely not something that should be 
> done. And as far as objcopy we spent quite a bit of time pulling it out for 
> split dwarf and, if possible, it shouldn't be used there either.
HIP toolchain has used llvm-mc to embed fat binary in a host object for a long 
time.

This is for supporting -fgpu-rdc since separated compilation/link will result 
in host object and device bit code. After device bit code are linked and fat 
binary are generated, fat binary needs to be embedded in some host object and 
linked with other host objects.

In the beginning, we used linker script. That works until we need to support 
windows. Then we adopted this suggestion 
(https://reviews.llvm.org/D46472#inline-412796) and use llvm-mc to generate a 
host object containing the fat binary, which works for both Linux and Windows.

I am wondering what is wrong with this approach and what is a better approach.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D110549

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


[PATCH] D113250: [clang][driver] Add -fplugin-arg- to pass arguments to plugins

2021-11-22 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay accepted this revision.
MaskRay added inline comments.
This revision is now accepted and ready to land.



Comment at: clang/examples/CallSuperAttribute/CallSuperAttrInfo.cpp:150
+  if (args[0] == "help") {
+llvm::errs() << "Help for the CallSuperAttr plugin goes here\n";
+  }

https://llvm.org/docs/CodingStandards.html#do-not-use-braced-initializer-lists-to-call-a-constructor



Comment at: clang/include/clang/Basic/DiagnosticDriverKinds.td:193
+def warn_drv_missing_plugin_name : Warning<
+  "Missing plugin name in %0">;
+def warn_drv_missing_plugin_arg : Warning<

don't capitalize messages. See other diagnostics and 
https://llvm.org/docs/CodingStandards.html#error-and-warning-messages



Comment at: clang/lib/Driver/ToolChains/Clang.cpp:6678
+A->claim();
+if (FirstDashIndex == StringRef::npos || Arg == "") {
+  if (PluginName == "") {

empty()



Comment at: clang/lib/Driver/ToolChains/Clang.cpp:6679
+if (FirstDashIndex == StringRef::npos || Arg == "") {
+  if (PluginName == "") {
+D.Diag(diag::warn_drv_missing_plugin_name) << A->getAsString(Args);





Comment at: clang/test/Driver/plugin-driver-args.cpp:1
+// Test passing args to plugins via the clang driver and -fplugin-arg
+// RUN: %clang -fplugin=%llvmshlibdir/CallSuperAttr%pluginext 
-fplugin-arg-call_super_plugin-help -fsyntax-only -### %s 2>&1 | FileCheck %s

I usually use `///` for non-RUN non-CHECK lines to make comments stand out (in 
some editors the highlight will even be different). That is a rule in some 
directories (llvm/test/tools lld/test) but not so consistent in other 
directories.



Comment at: clang/test/Driver/plugin-driver-args.cpp:11
+// Dashes cannot be part of the plugin name here
+// RUN: %clang -fplugin=%llvmshlibdir/CallSuperAttr%pluginext 
-fplugin-arg-call_super_plugin-help-long -fsyntax-only %s 2>&1 -### | FileCheck 
%s --check-prefix=CHECK-CMD
+// CHECK-CMD: "-plugin-arg-call_super_plugin" "help-long"

I assume that you have checked `// REQUIRES: plugins, examples` is not needed, 
i.e. the test still passes if -DLLVM_ENABLE_PLUGINS=off


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

https://reviews.llvm.org/D113250

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


[PATCH] D114213: Compilation Database: Point Bazel users to a solution

2021-11-22 Thread Christopher Sauer via Phabricator via cfe-commits
cpsauer added a comment.

Good call, @nridge. Will do as soon as we land this one.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D114213

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


[Diffusion] rGc93f93b2e3f2: Revert "Revert "Recommit "Revert "[CVP] processSwitch: Remove default case when…

2021-11-22 Thread Alexander Kornienko via Phabricator via cfe-commits
alexfh added a comment.

Reduced the problematic file to this: F20567816: test2.cc 


  $ time ./clang-before -O3 -c test2.cc
  
  real 0m0.242s
  user 0m0.178s
  sys 0m0.064s
  $ time ./clang-after -O3 -c test2.cc
  
  real 0m41.063s
  user 0m40.971s
  sys 0m0.090s

I'm observing this on x86-64, linux.


BRANCHES
  EmptyLineAfterFunctionDefinition, fix_asan, main

Users:
  junparser (Author)

https://reviews.llvm.org/rGc93f93b2e3f2

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


[PATCH] D114151: [clang-format] [C++20] [Module] clang-format couldn't recognize partitions

2021-11-22 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay added inline comments.



Comment at: clang/lib/Format/UnwrappedLineParser.cpp:1055-1077
+  while (FormatTok) {
+if (FormatTok->is(tok::colon)) {
+  FormatTok->setType(TT_ModulePartitionColon);
+}
+// Handle import  as we would an include statement
+else if (FormatTok->is(tok::less)) {
+  nextToken();

MyDeveloperDay wrote:
> owenpan wrote:
> > Possible infinite loops if the `import` statement is the last line and not 
> > terminated by a `;`?
> won't FormatTok become null at eof?
ok I see this..


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

https://reviews.llvm.org/D114151

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


[PATCH] D114151: [clang-format] [C++20] [Module] clang-format couldn't recognize partitions

2021-11-22 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay marked an inline comment as done.
MyDeveloperDay added inline comments.



Comment at: clang/lib/Format/UnwrappedLineParser.cpp:1055-1077
+  while (FormatTok) {
+if (FormatTok->is(tok::colon)) {
+  FormatTok->setType(TT_ModulePartitionColon);
+}
+// Handle import  as we would an include statement
+else if (FormatTok->is(tok::less)) {
+  nextToken();

owenpan wrote:
> Possible infinite loops if the `import` statement is the last line and not 
> terminated by a `;`?
won't FormatTok become null at eof?


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

https://reviews.llvm.org/D114151

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


[PATCH] D114320: [clang-format] Extend AllowShortBlocksOnASingleLine for else blocks

2021-11-22 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay accepted this revision.
MyDeveloperDay added a comment.

I agree I think this LGTM


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D114320

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


[PATCH] D80528: [clang-format][WIP] Run more stability FormatTests

2021-11-22 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay added a comment.

@JakeMerdichAMD  are you still interested in landing this, if not I'm happy to 
NFC it in over the next couple of weeks, if others agree


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80528

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


[PATCH] D22505: [clang-format] Access Modifier Use Normal Indent

2021-11-22 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay added a comment.

I think so, it came to the top because someone subscribed to it, I was 
wondering if this was something that is still needed or if our existing options 
cover this.

I recently came across a style like this. I don't know if there is still 
interest.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D22505

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


[PATCH] D114229: [clang][driver] Always add LTO options when using GNU toolchain

2021-11-22 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay requested changes to this revision.
MaskRay added a comment.
This revision now requires changes to proceed.

Request changes according to the outstanding comment "But in general I'm not in 
favor of adding a dependence on having the LTO plugin available to all non-lld 
links by default."

Agree with tejohnson that this looks weird.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D114229

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


[PATCH] D114396: [Driver] Default to current FreeBSD profiling behaviour

2021-11-22 Thread Ed Maste via Phabricator via cfe-commits
emaste added a subscriber: myfreeweb.
emaste added a comment.

Similar idea to D6  (libc++ default if 
major not specified)


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

https://reviews.llvm.org/D114396

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


[PATCH] D114396: [Driver] Default to current FreeBSD profiling behaviour

2021-11-22 Thread Ed Maste via Phabricator via cfe-commits
emaste created this revision.
emaste added a reviewer: dim.
Herald added subscribers: krytarowski, arichardson.
emaste requested review of this revision.

FreeBSD provided special _p.a libraries for use with -pg prior to FreeBSD 14.  
They are no longer used or provided.  If the target does not specify a major 
version (e.g. amd64-unknown-freebsd, rather than amd64-unknown-freebsd12) use 
the new behaviour.


https://reviews.llvm.org/D114396

Files:
  clang/lib/Driver/ToolChains/FreeBSD.cpp
  clang/test/Driver/freebsd.cpp


Index: clang/test/Driver/freebsd.cpp
===
--- clang/test/Driver/freebsd.cpp
+++ clang/test/Driver/freebsd.cpp
@@ -16,7 +16,7 @@
 // RUN:   | FileCheck --check-prefix=CHECK-PG-TEN %s
 // RUN: %clangxx %s -### -pg -o %t.o -target amd64-unknown-freebsd9.2 
-stdlib=platform 2>&1 \
 // RUN:   | FileCheck --check-prefix=CHECK-PG-NINE %s
-// CHECK-PG-DEFAULT: "-lc++_p" "-lm_p"
+// CHECK-PG-DEFAULT: "-lc++" "-lm"
 // CHECK-PG-FOURTEEN: "-lc++" "-lm"
 // CHECK-PG-TEN: "-lc++_p" "-lm_p"
 // CHECK-PG-NINE: "-lstdc++_p" "-lm_p"
Index: clang/lib/Driver/ToolChains/FreeBSD.cpp
===
--- clang/lib/Driver/ToolChains/FreeBSD.cpp
+++ clang/lib/Driver/ToolChains/FreeBSD.cpp
@@ -293,8 +293,8 @@
   addLinkerCompressDebugSectionsOption(ToolChain, Args, CmdArgs);
   AddLinkerInputs(ToolChain, Inputs, Args, CmdArgs, JA);
 
-  bool Profiling = Args.hasArg(options::OPT_pg) &&
-   ToolChain.getTriple().getOSMajorVersion() < 14;
+  unsigned Major = ToolChain.getTriple().getOSMajorVersion();
+  bool Profiling = Args.hasArg(options::OPT_pg) && Major != 0 && Major < 14;
   if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nodefaultlibs)) {
 // Use the static OpenMP runtime with -static-openmp
 bool StaticOpenMP = Args.hasArg(options::OPT_static_openmp) &&
@@ -419,8 +419,8 @@
 void FreeBSD::AddCXXStdlibLibArgs(const ArgList &Args,
   ArgStringList &CmdArgs) const {
   CXXStdlibType Type = GetCXXStdlibType(Args);
-  bool Profiling =
-  Args.hasArg(options::OPT_pg) && getTriple().getOSMajorVersion() < 14;
+  unsigned Major = getTriple().getOSMajorVersion();
+  bool Profiling = Args.hasArg(options::OPT_pg) && Major != 0 && Major < 14;
 
   switch (Type) {
   case ToolChain::CST_Libcxx:


Index: clang/test/Driver/freebsd.cpp
===
--- clang/test/Driver/freebsd.cpp
+++ clang/test/Driver/freebsd.cpp
@@ -16,7 +16,7 @@
 // RUN:   | FileCheck --check-prefix=CHECK-PG-TEN %s
 // RUN: %clangxx %s -### -pg -o %t.o -target amd64-unknown-freebsd9.2 -stdlib=platform 2>&1 \
 // RUN:   | FileCheck --check-prefix=CHECK-PG-NINE %s
-// CHECK-PG-DEFAULT: "-lc++_p" "-lm_p"
+// CHECK-PG-DEFAULT: "-lc++" "-lm"
 // CHECK-PG-FOURTEEN: "-lc++" "-lm"
 // CHECK-PG-TEN: "-lc++_p" "-lm_p"
 // CHECK-PG-NINE: "-lstdc++_p" "-lm_p"
Index: clang/lib/Driver/ToolChains/FreeBSD.cpp
===
--- clang/lib/Driver/ToolChains/FreeBSD.cpp
+++ clang/lib/Driver/ToolChains/FreeBSD.cpp
@@ -293,8 +293,8 @@
   addLinkerCompressDebugSectionsOption(ToolChain, Args, CmdArgs);
   AddLinkerInputs(ToolChain, Inputs, Args, CmdArgs, JA);
 
-  bool Profiling = Args.hasArg(options::OPT_pg) &&
-   ToolChain.getTriple().getOSMajorVersion() < 14;
+  unsigned Major = ToolChain.getTriple().getOSMajorVersion();
+  bool Profiling = Args.hasArg(options::OPT_pg) && Major != 0 && Major < 14;
   if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nodefaultlibs)) {
 // Use the static OpenMP runtime with -static-openmp
 bool StaticOpenMP = Args.hasArg(options::OPT_static_openmp) &&
@@ -419,8 +419,8 @@
 void FreeBSD::AddCXXStdlibLibArgs(const ArgList &Args,
   ArgStringList &CmdArgs) const {
   CXXStdlibType Type = GetCXXStdlibType(Args);
-  bool Profiling =
-  Args.hasArg(options::OPT_pg) && getTriple().getOSMajorVersion() < 14;
+  unsigned Major = getTriple().getOSMajorVersion();
+  bool Profiling = Args.hasArg(options::OPT_pg) && Major != 0 && Major < 14;
 
   switch (Type) {
   case ToolChain::CST_Libcxx:
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D110549: [HIPSPV][1/4] Refactor HIP tool chain

2021-11-22 Thread Eric Christopher via Phabricator via cfe-commits
echristo added inline comments.



Comment at: clang/lib/Driver/ToolChains/HIPUtility.cpp:119-133
+  // Add MC directives to embed target binaries. We ensure that each
+  // section and image is 16-byte aligned. This is not mandatory, but
+  // increases the likelihood of data to be aligned with a cache block
+  // in several main host machines.
+  ObjStream << "#   HIP Object Generator\n";
+  ObjStream << "# *** Automatically generated by Clang ***\n";
+  ObjStream << "  .protected __hip_fatbin\n";

tra wrote:
> Using MC for just wrapping a blob into an object file strikes me as something 
> MC is not intended for.
> 
> @echristo -- is it OK to use MC as a tool in the standard compilation 
> pipeline? I vaguely recall we had a conversaion about using objcopy for 
> similar purposes during early days of CUDA and the conclusion was that we 
> generally don't want that. I might be wrong, too, it's been too long ago.
Using llvm-mc the binary? No. That's definitely not something that should be 
done. And as far as objcopy we spent quite a bit of time pulling it out for 
split dwarf and, if possible, it shouldn't be used there either.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D110549

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


[PATCH] D77776: [Driver] Default to libc++ on FreeBSD

2021-11-22 Thread Ed Maste 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 rG2dec2aa3ad08: [Driver] Default to libc++ on FreeBSD 
(authored by jbeich, committed by emaste).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D6

Files:
  clang/lib/Driver/ToolChains/FreeBSD.cpp
  clang/test/Driver/freebsd.cpp


Index: clang/test/Driver/freebsd.cpp
===
--- clang/test/Driver/freebsd.cpp
+++ clang/test/Driver/freebsd.cpp
@@ -1,16 +1,22 @@
+// RUN: %clangxx %s -### -o %t.o -target amd64-unknown-freebsd 
-stdlib=platform 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-DEFAULT %s
 // RUN: %clangxx %s -### -o %t.o -target amd64-unknown-freebsd10.0 
-stdlib=platform 2>&1 \
 // RUN:   | FileCheck --check-prefix=CHECK-TEN %s
 // RUN: %clangxx %s -### -o %t.o -target amd64-unknown-freebsd9.2 
-stdlib=platform 2>&1 \
 // RUN:   | FileCheck --check-prefix=CHECK-NINE %s
+// CHECK-DEFAULT: "-lc++" "-lm"
 // CHECK-TEN: "-lc++" "-lm"
 // CHECK-NINE: "-lstdc++" "-lm"
 
+// RUN: %clangxx %s -### -pg -o %t.o -target amd64-unknown-freebsd 
-stdlib=platform 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-PG-DEFAULT %s
 // RUN: %clangxx %s -### -pg -o %t.o -target amd64-unknown-freebsd14.0 
-stdlib=platform 2>&1 \
 // RUN:   | FileCheck --check-prefix=CHECK-PG-FOURTEEN %s
 // RUN: %clangxx %s -### -pg -o %t.o -target amd64-unknown-freebsd10.0 
-stdlib=platform 2>&1 \
 // RUN:   | FileCheck --check-prefix=CHECK-PG-TEN %s
 // RUN: %clangxx %s -### -pg -o %t.o -target amd64-unknown-freebsd9.2 
-stdlib=platform 2>&1 \
 // RUN:   | FileCheck --check-prefix=CHECK-PG-NINE %s
+// CHECK-PG-DEFAULT: "-lc++_p" "-lm_p"
 // CHECK-PG-FOURTEEN: "-lc++" "-lm"
 // CHECK-PG-TEN: "-lc++_p" "-lm_p"
 // CHECK-PG-NINE: "-lstdc++_p" "-lm_p"
Index: clang/lib/Driver/ToolChains/FreeBSD.cpp
===
--- clang/lib/Driver/ToolChains/FreeBSD.cpp
+++ clang/lib/Driver/ToolChains/FreeBSD.cpp
@@ -391,7 +391,8 @@
 }
 
 ToolChain::CXXStdlibType FreeBSD::GetDefaultCXXStdlibType() const {
-  if (getTriple().getOSMajorVersion() >= 10)
+  unsigned Major = getTriple().getOSMajorVersion();
+  if (Major >= 10 || Major == 0)
 return ToolChain::CST_Libcxx;
   return ToolChain::CST_Libstdcxx;
 }


Index: clang/test/Driver/freebsd.cpp
===
--- clang/test/Driver/freebsd.cpp
+++ clang/test/Driver/freebsd.cpp
@@ -1,16 +1,22 @@
+// RUN: %clangxx %s -### -o %t.o -target amd64-unknown-freebsd -stdlib=platform 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-DEFAULT %s
 // RUN: %clangxx %s -### -o %t.o -target amd64-unknown-freebsd10.0 -stdlib=platform 2>&1 \
 // RUN:   | FileCheck --check-prefix=CHECK-TEN %s
 // RUN: %clangxx %s -### -o %t.o -target amd64-unknown-freebsd9.2 -stdlib=platform 2>&1 \
 // RUN:   | FileCheck --check-prefix=CHECK-NINE %s
+// CHECK-DEFAULT: "-lc++" "-lm"
 // CHECK-TEN: "-lc++" "-lm"
 // CHECK-NINE: "-lstdc++" "-lm"
 
+// RUN: %clangxx %s -### -pg -o %t.o -target amd64-unknown-freebsd -stdlib=platform 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-PG-DEFAULT %s
 // RUN: %clangxx %s -### -pg -o %t.o -target amd64-unknown-freebsd14.0 -stdlib=platform 2>&1 \
 // RUN:   | FileCheck --check-prefix=CHECK-PG-FOURTEEN %s
 // RUN: %clangxx %s -### -pg -o %t.o -target amd64-unknown-freebsd10.0 -stdlib=platform 2>&1 \
 // RUN:   | FileCheck --check-prefix=CHECK-PG-TEN %s
 // RUN: %clangxx %s -### -pg -o %t.o -target amd64-unknown-freebsd9.2 -stdlib=platform 2>&1 \
 // RUN:   | FileCheck --check-prefix=CHECK-PG-NINE %s
+// CHECK-PG-DEFAULT: "-lc++_p" "-lm_p"
 // CHECK-PG-FOURTEEN: "-lc++" "-lm"
 // CHECK-PG-TEN: "-lc++_p" "-lm_p"
 // CHECK-PG-NINE: "-lstdc++_p" "-lm_p"
Index: clang/lib/Driver/ToolChains/FreeBSD.cpp
===
--- clang/lib/Driver/ToolChains/FreeBSD.cpp
+++ clang/lib/Driver/ToolChains/FreeBSD.cpp
@@ -391,7 +391,8 @@
 }
 
 ToolChain::CXXStdlibType FreeBSD::GetDefaultCXXStdlibType() const {
-  if (getTriple().getOSMajorVersion() >= 10)
+  unsigned Major = getTriple().getOSMajorVersion();
+  if (Major >= 10 || Major == 0)
 return ToolChain::CST_Libcxx;
   return ToolChain::CST_Libstdcxx;
 }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 2dec2aa - [Driver] Default to libc++ on FreeBSD

2021-11-22 Thread Ed Maste via cfe-commits

Author: Jan Beich
Date: 2021-11-22T16:47:03-05:00
New Revision: 2dec2aa3ad083dbde838809f0e8c7ae31110e111

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

LOG: [Driver] Default to libc++ on FreeBSD

All supported FreeBSD releases use libc++, so default to it if the
target's major version is not specified.

Reviewed by:dim, emaste
Differential Revision:  https://reviews.llvm.org/D6

Added: 


Modified: 
clang/lib/Driver/ToolChains/FreeBSD.cpp
clang/test/Driver/freebsd.cpp

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/FreeBSD.cpp 
b/clang/lib/Driver/ToolChains/FreeBSD.cpp
index dc05f9893465..d08ea282f6df 100644
--- a/clang/lib/Driver/ToolChains/FreeBSD.cpp
+++ b/clang/lib/Driver/ToolChains/FreeBSD.cpp
@@ -391,7 +391,8 @@ FreeBSD::FreeBSD(const Driver &D, const llvm::Triple 
&Triple,
 }
 
 ToolChain::CXXStdlibType FreeBSD::GetDefaultCXXStdlibType() const {
-  if (getTriple().getOSMajorVersion() >= 10)
+  unsigned Major = getTriple().getOSMajorVersion();
+  if (Major >= 10 || Major == 0)
 return ToolChain::CST_Libcxx;
   return ToolChain::CST_Libstdcxx;
 }

diff  --git a/clang/test/Driver/freebsd.cpp b/clang/test/Driver/freebsd.cpp
index d199f6e2367a..512d29eeb64a 100644
--- a/clang/test/Driver/freebsd.cpp
+++ b/clang/test/Driver/freebsd.cpp
@@ -1,16 +1,22 @@
+// RUN: %clangxx %s -### -o %t.o -target amd64-unknown-freebsd 
-stdlib=platform 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-DEFAULT %s
 // RUN: %clangxx %s -### -o %t.o -target amd64-unknown-freebsd10.0 
-stdlib=platform 2>&1 \
 // RUN:   | FileCheck --check-prefix=CHECK-TEN %s
 // RUN: %clangxx %s -### -o %t.o -target amd64-unknown-freebsd9.2 
-stdlib=platform 2>&1 \
 // RUN:   | FileCheck --check-prefix=CHECK-NINE %s
+// CHECK-DEFAULT: "-lc++" "-lm"
 // CHECK-TEN: "-lc++" "-lm"
 // CHECK-NINE: "-lstdc++" "-lm"
 
+// RUN: %clangxx %s -### -pg -o %t.o -target amd64-unknown-freebsd 
-stdlib=platform 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-PG-DEFAULT %s
 // RUN: %clangxx %s -### -pg -o %t.o -target amd64-unknown-freebsd14.0 
-stdlib=platform 2>&1 \
 // RUN:   | FileCheck --check-prefix=CHECK-PG-FOURTEEN %s
 // RUN: %clangxx %s -### -pg -o %t.o -target amd64-unknown-freebsd10.0 
-stdlib=platform 2>&1 \
 // RUN:   | FileCheck --check-prefix=CHECK-PG-TEN %s
 // RUN: %clangxx %s -### -pg -o %t.o -target amd64-unknown-freebsd9.2 
-stdlib=platform 2>&1 \
 // RUN:   | FileCheck --check-prefix=CHECK-PG-NINE %s
+// CHECK-PG-DEFAULT: "-lc++_p" "-lm_p"
 // CHECK-PG-FOURTEEN: "-lc++" "-lm"
 // CHECK-PG-TEN: "-lc++_p" "-lm_p"
 // CHECK-PG-NINE: "-lstdc++_p" "-lm_p"



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


[PATCH] D80528: [clang-format][WIP] Run more stability FormatTests

2021-11-22 Thread Björn Schäpers via Phabricator via cfe-commits
HazardyKnusperkeks added a comment.

It says tests are failing. But generally this seems to be a good idea. So one 
should take the tests one by one. I would do it, but currently I'm trying to 
wrap my head around some of the internals, to get my requires clauses correctly 
formatted. ;)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80528

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


[PATCH] D114394: Compile-time computation of string attribute hashes

2021-11-22 Thread serge via Phabricator via cfe-commits
serge-sans-paille created this revision.
serge-sans-paille added reviewers: dblaikie, nikic.
Herald added subscribers: ormris, dexonsmith, wenlei, okura, jdoerfert, kuter, 
haicheng, hiraditya, eraman.
serge-sans-paille requested review of this revision.
Herald added a reviewer: jdoerfert.
Herald added a reviewer: sstefan1.
Herald added a reviewer: baziotis.
Herald added projects: clang, LLVM.
Herald added subscribers: llvm-commits, cfe-commits.

This is a simplified —and hopefully easier to review— version of 
https://reviews.llvm.org/D114082 with a focus on the performance aspect

Basically, this change forces usage of an AttributeKey object instead of plain 
string as Attribute key for free-forms attributes. As these object cash their 
hash value and this value can be computed at compile time for the common case 
where we check / retrieve an attribute value, this speeds up attribute lookup.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D114394

Files:
  clang/lib/CodeGen/CGCall.cpp
  clang/lib/CodeGen/CGOpenMPRuntime.cpp
  clang/lib/CodeGen/CodeGenFunction.cpp
  llvm/include/llvm/Analysis/TargetLibraryInfo.h
  llvm/include/llvm/Analysis/VectorUtils.h
  llvm/include/llvm/CodeGen/CommandFlags.h
  llvm/include/llvm/IR/Assumptions.h
  llvm/include/llvm/IR/Attributes.h
  llvm/include/llvm/IR/Function.h
  llvm/include/llvm/IR/GlobalVariable.h
  llvm/include/llvm/IR/InstrTypes.h
  llvm/include/llvm/ProfileData/SampleProf.h
  llvm/lib/Analysis/InlineCost.cpp
  llvm/lib/AsmParser/LLParser.cpp
  llvm/lib/Bitcode/Reader/BitcodeReader.cpp
  llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
  llvm/lib/CodeGen/CommandFlags.cpp
  llvm/lib/IR/AttributeImpl.h
  llvm/lib/IR/Attributes.cpp
  llvm/lib/IR/Core.cpp
  llvm/lib/IR/DiagnosticInfo.cpp
  llvm/lib/IR/Function.cpp
  llvm/lib/IR/Instructions.cpp
  llvm/lib/IR/Verifier.cpp
  llvm/lib/Transforms/IPO/Attributor.cpp
  llvm/lib/Transforms/IPO/OpenMPOpt.cpp
  llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp
  llvm/lib/Transforms/Scalar/RewriteStatepointsForGC.cpp
  llvm/lib/Transforms/Utils/CodeExtractor.cpp
  llvm/lib/Transforms/Utils/EntryExitInstrumenter.cpp

Index: llvm/lib/Transforms/Utils/EntryExitInstrumenter.cpp
===
--- llvm/lib/Transforms/Utils/EntryExitInstrumenter.cpp
+++ llvm/lib/Transforms/Utils/EntryExitInstrumenter.cpp
@@ -67,11 +67,13 @@
 }
 
 static bool runOnFunction(Function &F, bool PostInlining) {
-  StringRef EntryAttr = PostInlining ? "instrument-function-entry-inlined"
- : "instrument-function-entry";
+  AttributeKey EntryAttr =
+  PostInlining ? AttributeKey("instrument-function-entry-inlined")
+   : AttributeKey("instrument-function-entry");
 
-  StringRef ExitAttr = PostInlining ? "instrument-function-exit-inlined"
-: "instrument-function-exit";
+  AttributeKey ExitAttr = PostInlining
+  ? AttributeKey("instrument-function-exit-inlined")
+  : AttributeKey("instrument-function-exit");
 
   StringRef EntryFunc = F.getFnAttribute(EntryAttr).getValueAsString();
   StringRef ExitFunc = F.getFnAttribute(ExitAttr).getValueAsString();
Index: llvm/lib/Transforms/Utils/CodeExtractor.cpp
===
--- llvm/lib/Transforms/Utils/CodeExtractor.cpp
+++ llvm/lib/Transforms/Utils/CodeExtractor.cpp
@@ -888,7 +888,7 @@
   //   attribute can not be inherited.
   for (const auto &Attr : oldFunction->getAttributes().getFnAttrs()) {
 if (Attr.isStringAttribute()) {
-  if (Attr.getKindAsString() == "thunk")
+  if (Attr.getKindAsKey() == "thunk")
 continue;
 } else
   switch (Attr.getKindAsEnum()) {
Index: llvm/lib/Transforms/Scalar/RewriteStatepointsForGC.cpp
===
--- llvm/lib/Transforms/Scalar/RewriteStatepointsForGC.cpp
+++ llvm/lib/Transforms/Scalar/RewriteStatepointsForGC.cpp
@@ -1528,7 +1528,7 @@
 } // end anonymous namespace
 
 static StringRef getDeoptLowering(CallBase *Call) {
-  const char *DeoptLowering = "deopt-lowering";
+  const char DeoptLowering[] = "deopt-lowering";
   if (Call->hasFnAttr(DeoptLowering)) {
 // FIXME: Calls have a *really* confusing interface around attributes
 // with values.
Index: llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp
===
--- llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp
+++ llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp
@@ -4194,14 +4194,9 @@
 MemorySanitizerVisitor &MSV)
   : F(F), MS(MS), MSV(MSV) {
 AMD64FpEndOffset = AMD64FpEndOffsetSSE;
-for (const auto &Attr : F.getAttributes().getFnAttrs()) {
-  if (Attr.isStringAttribute() &&
-  (Attr.getKindAsString() == "target-features")) {
-if (Attr.

[PATCH] D22505: [clang-format] Access Modifier Use Normal Indent

2021-11-22 Thread Björn Schäpers via Phabricator via cfe-commits
HazardyKnusperkeks added a comment.

This is dead, isn't it?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D22505

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


[PATCH] D110549: [HIPSPV][1/4] Refactor HIP tool chain

2021-11-22 Thread Artem Belevich via Phabricator via cfe-commits
tra added a subscriber: echristo.
tra added inline comments.



Comment at: clang/lib/Driver/ToolChains/HIPUtility.cpp:119-133
+  // Add MC directives to embed target binaries. We ensure that each
+  // section and image is 16-byte aligned. This is not mandatory, but
+  // increases the likelihood of data to be aligned with a cache block
+  // in several main host machines.
+  ObjStream << "#   HIP Object Generator\n";
+  ObjStream << "# *** Automatically generated by Clang ***\n";
+  ObjStream << "  .protected __hip_fatbin\n";

Using MC for just wrapping a blob into an object file strikes me as something 
MC is not intended for.

@echristo -- is it OK to use MC as a tool in the standard compilation pipeline? 
I vaguely recall we had a conversaion about using objcopy for similar purposes 
during early days of CUDA and the conclusion was that we generally don't want 
that. I might be wrong, too, it's been too long ago.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D110549

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


[PATCH] D110618: [HIPSPV][2/4] Add HIPSPV tool chain

2021-11-22 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 in general, modulo push_back/append nits.




Comment at: clang/include/clang/Driver/Options.td:3701
   " do not include the default CUDA/HIP wrapper headers">;
+def nohipwrapperinc : Flag<["-"], "nohipwrapperinc">,
+  HelpText<"Do not include the default HIP wrapper headers">;

linjamaki wrote:
> tra wrote:
> > Is the idea to still add relevant include paths to the wrappers and SDK 
> > headers, but not `-include` the wrapper?
> > 
> > If that's the case, it should probably be generalized into 
> > `-nogpuwrapperinc` and apply to both CUDA and HIP.
> > 
> > Is the idea to still add relevant include paths to the wrappers and SDK 
> > headers, but not `-include` the wrapper?
> > 
> Include paths are meant to be excluded too. I’ll fix the option description.
> 
> > If that's the case, it should probably be generalized into 
> > `-nogpuwrapperinc` and apply to both CUDA and HIP.
> > 
> I don’t see an immediate need to generalize the option as I don’t think there 
> will be a need for it in the CUDA path. The option could be generalized later 
> if the need comes (add generalized option, set -nohipwrapperinc to be alias 
> to it).
> 
Fair enough. Indeed, without the wrappers, we will not be able to parse CUDA 
SDK headers.



Comment at: clang/lib/Driver/ToolChains/HIPSPV.cpp:145
+
+  CC1Args.push_back("-fcuda-allow-variadic-functions");
+

Nit: combine with `-fcuda-is-device` into `append({})`



Comment at: clang/lib/Driver/ToolChains/HIPSPV.cpp:151-152
+ options::OPT_fvisibility_ms_compat)) {
+CC1Args.append({"-fvisibility", "hidden"});
+CC1Args.push_back("-fapply-global-visibility-to-externs");
+  }

Nit: Combine all unconditional `push_back()` calls  into `append()`;



Comment at: clang/lib/Driver/ToolChains/HIPSPV.cpp:164-165
+  // TODO: Allow autovectorization when SPIR-V backend arrives.
+  CC1Args.append({"-mllvm", "-vectorize-loops=false"});
+  CC1Args.append({"-mllvm", "-vectorize-slp=false"});
+}

Nit: combine into single `append`.



Comment at: clang/lib/Driver/ToolChains/HIPSPV.cpp:209-210
+  llvm::sys::path::append(P, "include");
+  CC1Args.push_back("-isystem");
+  CC1Args.push_back(DriverArgs.MakeArgString(P));
+}

-> `append({})`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D110618

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


[PATCH] D113451: [PowerPC] [Clang] Enable Intel intrinsics support on FreeBSD

2021-11-22 Thread Jinsong Ji via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG8e2fd879e6f9: [PowerPC] [Clang] Enable Intel intrinsics 
support on FreeBSD (authored by adalava, committed by jsji).

Changed prior to commit:
  https://reviews.llvm.org/D113451?vs=385985&id=389001#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D113451

Files:
  clang/lib/Driver/CMakeLists.txt
  clang/lib/Driver/Driver.cpp
  clang/lib/Driver/ToolChains/PPCFreeBSD.cpp
  clang/lib/Driver/ToolChains/PPCFreeBSD.h
  clang/lib/Headers/ppc_wrappers/emmintrin.h
  clang/lib/Headers/ppc_wrappers/mm_malloc.h
  clang/lib/Headers/ppc_wrappers/mmintrin.h
  clang/lib/Headers/ppc_wrappers/pmmintrin.h
  clang/lib/Headers/ppc_wrappers/smmintrin.h
  clang/lib/Headers/ppc_wrappers/tmmintrin.h
  clang/lib/Headers/ppc_wrappers/xmmintrin.h
  clang/test/CodeGen/ppc-mm-malloc.c
  clang/test/CodeGen/ppc-mmintrin.c
  clang/test/CodeGen/ppc-pmmintrin.c
  clang/test/CodeGen/ppc-smmintrin.c
  clang/test/CodeGen/ppc-tmmintrin.c
  clang/test/CodeGen/ppc-xmmintrin.c

Index: clang/test/CodeGen/ppc-xmmintrin.c
===
--- clang/test/CodeGen/ppc-xmmintrin.c
+++ clang/test/CodeGen/ppc-xmmintrin.c
@@ -10,6 +10,15 @@
 // RUN: %clang -x c++ -fsyntax-only -target powerpc64le-unknown-linux-gnu -mcpu=pwr8 -ffreestanding -DNO_WARN_X86_INTRINSICS %s \
 // RUN:   -fno-discard-value-names -mllvm -disable-llvm-optzns
 
+// RUN: %clang -S -emit-llvm -target powerpc64-unknown-freebsd13.0 -mcpu=pwr8 -ffreestanding -DNO_WARN_X86_INTRINSICS %s \
+// RUN:   -fno-discard-value-names -mllvm -disable-llvm-optzns -o - | llvm-cxxfilt -n | FileCheck %s --check-prefixes=CHECK,CHECK-BE
+// RUN: %clang -x c++ -fsyntax-only -target powerpc64-unknown-freebsd13.0 -mcpu=pwr8 -ffreestanding -DNO_WARN_X86_INTRINSICS %s \
+// RUN:   -fno-discard-value-names -mllvm -disable-llvm-optzns
+// RUN: %clang -S -emit-llvm -target powerpc64le-unknown-freebsd13.0 -mcpu=pwr8 -ffreestanding -DNO_WARN_X86_INTRINSICS %s \
+// RUN:   -fno-discard-value-names -mllvm -disable-llvm-optzns -o - | llvm-cxxfilt -n | FileCheck %s --check-prefixes=CHECK,CHECK-LE
+// RUN: %clang -x c++ -fsyntax-only -target powerpc64le-unknown-freebsd13.0 -mcpu=pwr8 -ffreestanding -DNO_WARN_X86_INTRINSICS %s \
+// RUN:   -fno-discard-value-names -mllvm -disable-llvm-optzns
+
 #include 
 
 __m128 res, m1, m2;
Index: clang/test/CodeGen/ppc-tmmintrin.c
===
--- clang/test/CodeGen/ppc-tmmintrin.c
+++ clang/test/CodeGen/ppc-tmmintrin.c
@@ -6,6 +6,11 @@
 // RUN: %clang -S -emit-llvm -target powerpc64le-gnu-linux -mcpu=pwr8 -ffreestanding -DNO_WARN_X86_INTRINSICS %s \
 // RUN:   -fno-discard-value-names -mllvm -disable-llvm-optzns -o - | llvm-cxxfilt -n | FileCheck %s --check-prefixes=CHECK,CHECK-LE
 
+// RUN: %clang -S -emit-llvm -target powerpc64-unknown-freebsd13.0 -mcpu=pwr8 -ffreestanding -DNO_WARN_X86_INTRINSICS %s \
+// RUN:   -fno-discard-value-names -mllvm -disable-llvm-optzns -o - | llvm-cxxfilt -n | FileCheck %s --check-prefixes=CHECK,CHECK-BE
+// RUN: %clang -S -emit-llvm -target powerpc64le-unknown-freebsd13.0 -mcpu=pwr8 -ffreestanding -DNO_WARN_X86_INTRINSICS %s \
+// RUN:   -fno-discard-value-names -mllvm -disable-llvm-optzns -o - | llvm-cxxfilt -n | FileCheck %s --check-prefixes=CHECK,CHECK-LE
+
 #include 
 
 __m64 res, m1, m2;
Index: clang/test/CodeGen/ppc-smmintrin.c
===
--- clang/test/CodeGen/ppc-smmintrin.c
+++ clang/test/CodeGen/ppc-smmintrin.c
@@ -6,6 +6,11 @@
 // RUN: %clang -S -emit-llvm -target powerpc64-unknown-linux-gnu -mcpu=pwr8 -ffreestanding -DNO_WARN_X86_INTRINSICS %s \
 // RUN:   -fno-discard-value-names -mllvm -disable-llvm-optzns -o - | llvm-cxxfilt -n | FileCheck %s
 
+// RUN: %clang -S -emit-llvm -target powerpc64le-unknown-freebsd13.0 -mcpu=pwr8 -ffreestanding -DNO_WARN_X86_INTRINSICS %s \
+// RUN:   -fno-discard-value-names -mllvm -disable-llvm-optzns -o - | llvm-cxxfilt -n | FileCheck %s
+// RUN: %clang -S -emit-llvm -target powerpc64-unknown-freebsd13.0 -mcpu=pwr8 -ffreestanding -DNO_WARN_X86_INTRINSICS %s \
+// RUN:   -fno-discard-value-names -mllvm -disable-llvm-optzns -o - | llvm-cxxfilt -n | FileCheck %s
+
 #include 
 
 __m128i mi, m1, m2;
Index: clang/test/CodeGen/ppc-pmmintrin.c
===
--- clang/test/CodeGen/ppc-pmmintrin.c
+++ clang/test/CodeGen/ppc-pmmintrin.c
@@ -6,6 +6,11 @@
 // RUN: %clang -S -emit-llvm -target powerpc64le-gnu-linux -mcpu=pwr8 -DNO_MM_MALLOC -ffreestanding -DNO_WARN_X86_INTRINSICS %s \
 // RUN:   -fno-discard-value-names -mllvm -disable-llvm-optzns -o - | llvm-cxxfilt -n | FileCheck %s
 
+// RUN: %clang -S -emit-llvm -target powerpc64-unknown-freebsd13.0 -mcpu=pwr8 -DNO_MM_MALLOC -ffreestanding -DNO_WARN_X86_INTRINSICS %s \
+// RUN

[clang] 8e2fd87 - [PowerPC] [Clang] Enable Intel intrinsics support on FreeBSD

2021-11-22 Thread Jinsong Ji via cfe-commits

Author: Alfredo Dal'\''Ava Junior
Date: 2021-11-22T20:42:10Z
New Revision: 8e2fd879e6f91b1e4fdf6217a667079aaeaece99

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

LOG: [PowerPC] [Clang] Enable Intel intrinsics support on FreeBSD

This enables Intel intrinsics support on FreeBSD.

Thanks to @pkubaj who noticed this feature was missing

Reviewed By: jsji

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

Added: 
clang/lib/Driver/ToolChains/PPCFreeBSD.cpp
clang/lib/Driver/ToolChains/PPCFreeBSD.h

Modified: 
clang/lib/Driver/CMakeLists.txt
clang/lib/Driver/Driver.cpp
clang/lib/Headers/ppc_wrappers/emmintrin.h
clang/lib/Headers/ppc_wrappers/mm_malloc.h
clang/lib/Headers/ppc_wrappers/mmintrin.h
clang/lib/Headers/ppc_wrappers/pmmintrin.h
clang/lib/Headers/ppc_wrappers/smmintrin.h
clang/lib/Headers/ppc_wrappers/tmmintrin.h
clang/lib/Headers/ppc_wrappers/xmmintrin.h
clang/test/CodeGen/ppc-mm-malloc.c
clang/test/CodeGen/ppc-mmintrin.c
clang/test/CodeGen/ppc-pmmintrin.c
clang/test/CodeGen/ppc-smmintrin.c
clang/test/CodeGen/ppc-tmmintrin.c
clang/test/CodeGen/ppc-xmmintrin.c

Removed: 




diff  --git a/clang/lib/Driver/CMakeLists.txt b/clang/lib/Driver/CMakeLists.txt
index 31e357b67361d..580355ba7e121 100644
--- a/clang/lib/Driver/CMakeLists.txt
+++ b/clang/lib/Driver/CMakeLists.txt
@@ -75,6 +75,7 @@ add_clang_library(clangDriver
   ToolChains/WebAssembly.cpp
   ToolChains/XCore.cpp
   ToolChains/PPCLinux.cpp
+  ToolChains/PPCFreeBSD.cpp
   ToolChains/InterfaceStubs.cpp
   ToolChains/ZOS.cpp
   Types.cpp

diff  --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp
index 8023d03013a16..d501bd0262199 100644
--- a/clang/lib/Driver/Driver.cpp
+++ b/clang/lib/Driver/Driver.cpp
@@ -38,6 +38,7 @@
 #include "ToolChains/NaCl.h"
 #include "ToolChains/NetBSD.h"
 #include "ToolChains/OpenBSD.h"
+#include "ToolChains/PPCFreeBSD.h"
 #include "ToolChains/PPCLinux.h"
 #include "ToolChains/PS4CPU.h"
 #include "ToolChains/RISCVToolchain.h"
@@ -5302,7 +5303,11 @@ const ToolChain &Driver::getToolChain(const ArgList 
&Args,
   TC = std::make_unique(*this, Target, Args);
   break;
 case llvm::Triple::FreeBSD:
-  TC = std::make_unique(*this, Target, Args);
+  if (Target.isPPC())
+TC = std::make_unique(*this, Target,
+   Args);
+  else
+TC = std::make_unique(*this, Target, Args);
   break;
 case llvm::Triple::Minix:
   TC = std::make_unique(*this, Target, Args);

diff  --git a/clang/lib/Driver/ToolChains/PPCFreeBSD.cpp 
b/clang/lib/Driver/ToolChains/PPCFreeBSD.cpp
new file mode 100644
index 0..8d381c4f14371
--- /dev/null
+++ b/clang/lib/Driver/ToolChains/PPCFreeBSD.cpp
@@ -0,0 +1,28 @@
+//===-- PPCFreeBSD.cpp - PowerPC ToolChain Implementations --*- C++ 
-*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "PPCFreeBSD.h"
+#include "clang/Driver/Driver.h"
+#include "clang/Driver/Options.h"
+#include "llvm/Support/Path.h"
+
+using namespace clang::driver::toolchains;
+using namespace llvm::opt;
+
+void PPCFreeBSDToolChain::AddClangSystemIncludeArgs(
+const ArgList &DriverArgs, ArgStringList &CC1Args) const {
+  if (!DriverArgs.hasArg(clang::driver::options::OPT_nostdinc) &&
+  !DriverArgs.hasArg(options::OPT_nobuiltininc)) {
+const Driver &D = getDriver();
+SmallString<128> P(D.ResourceDir);
+llvm::sys::path::append(P, "include", "ppc_wrappers");
+addSystemInclude(DriverArgs, CC1Args, P);
+  }
+
+  FreeBSD::AddClangSystemIncludeArgs(DriverArgs, CC1Args);
+}

diff  --git a/clang/lib/Driver/ToolChains/PPCFreeBSD.h 
b/clang/lib/Driver/ToolChains/PPCFreeBSD.h
new file mode 100644
index 0..d5d9cf4e83a06
--- /dev/null
+++ b/clang/lib/Driver/ToolChains/PPCFreeBSD.h
@@ -0,0 +1,33 @@
+//===--- PPCFreeBSD.h - PowerPC ToolChain Implementations ---*- C++ 
-*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#ifndef LLVM_CLANG_LIB_DRIVER_TOOLCHAINS_PPC_FREEBSD_H
+#define LLVM_CLANG_LIB_DRIVER_TOOLCHAINS_PPC_FREEBSD_H
+
+#include "FreeBSD.h"
+
+namespace clang {
+namespace driver {
+namespace toolchains {
+
+class LLVM_LIBRARY_VISIBILITY PPCFreeBSDToolChain : public FreeBSD {

[PATCH] D113451: [PowerPC] [Clang] Enable Intel intrinsics support on FreeBSD

2021-11-22 Thread Jinsong Ji via Phabricator via cfe-commits
jsji added inline comments.



Comment at: clang/test/CodeGen/ppc-mm-malloc-le.c:10
 // RUN: %clang -target powerpc64le-unknown-linux-gnu -S -emit-llvm %s 
-fno-discard-value-names -mllvm -disable-llvm-optzns -o - | llvm-cxxfilt | 
FileCheck %s
+// RUN: %clang -target powerpc64le-unknown-freebsd13.0 -S -emit-llvm %s 
-fno-discard-value-names -mllvm -disable-llvm-optzns -o - | llvm-cxxfilt | 
FileCheck %s
 

This will cause problem when building on Linux.

```
In file included from 
/home/jji/llvm-git/llvm-project/clang/test/CodeGen/ppc-mm-malloc-le.c:12:
In file included from 
/home/jji/llvm-git/build/lib/clang/14.0.0/include/ppc_wrappers/mm_malloc.h:15:
/usr/include/stdlib.h:25:10: fatal error: 'bits/libc-header-start.h' file not 
found
#include 
 ^~
1 error generated.
FileCheck error: '' is empty.
FileCheck command line:  /home/jji/llvm-git/build/bin/FileCheck 
/home/jji/llvm-git/llvm-project/clang/test/CodeGen/ppc-mm-malloc-le.c

```


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D113451

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


[PATCH] D112913: Misleading bidirectional detection

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

Gentle ping @MaskRay and/or @rsmith


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

https://reviews.llvm.org/D112913

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


[PATCH] D114229: [clang][driver] Always add LTO options when using GNU toolchain

2021-11-22 Thread serge via Phabricator via cfe-commits
serge-sans-paille added subscribers: rsmith, serge-sans-paille.
serge-sans-paille added a comment.

Gentle ping @MaskRay and/or @rsmith


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D114229

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


[PATCH] D114326: Update the list of CUDA versions up to 11.5

2021-11-22 Thread Artem Belevich via Phabricator via cfe-commits
tra added inline comments.



Comment at: clang/lib/Driver/ToolChains/Cuda.cpp:131
+  std::initializer_list Versions = {
+  "11.5", "11.4", "11.3", "11.2", "11.1", "11.0", "10.2", "10.1",
+  "10.0", "9.2",  "9.1",  "9.0",  "8.0",  "7.5",  "7.0"};

mojca wrote:
> kadircet wrote:
> > looks like the list is getting big and hard to maintain. considering that 
> > this is done only once per compiler invocation (and we check for existence 
> > of directories down in the loop anyway). what about throwing in an extra 
> > directory listing to base-directories mentioned down below and populate 
> > `Candidates` while preserving the newest-version-first order?
> I totally agree with the sentiment, and that was my initial thought as well, 
> but with zero experience I was too scared to make any more significant 
> changes.
> 
> I can try to come up with a new patch (that doesn't need further maintenance 
> whenever a new CUDA version gets released) if that's what you are suggesting. 
> I would nevertheless merge this one, and prepare a new more advanced patch 
> separately, but that's finally your call.
> 
> What's your suggestion about D.SysRoot + "Program Files/..."? At the time 
> when this function gets called it looks like D.SysRoot is empty (or at least 
> my debugger says so) and in my case it resolves to D: while the CUDA support 
> is installed under C:.
> 
> Is there any special LLVM-specific/preferrable way to iterate through 
> directories?
> 
> (What I also miss a bit in the whole process in an option to simply say "I 
> want CUDA 11.1" without the need to explicitly spell out the full path.)
> 
> If you provide me give some general guidelines, I'll prepare another, 
> hopefully more future-proof patch.
> 
> (Side note: I'm not sure if I'm calling clang-format correctly, but if I call 
> it, it keeps reformatting the rest of this file.)
This whole list may no longer be particularly useful. The most common use case 
on Linux, AFAICT, is to install only one CUDA version using system-provided 
package manager.
E.g. https://packages.ubuntu.com/focal/amd64/nvidia-cuda-toolkit/filelist

TBH, I'm tempted to limit autodetection to only that one system-default version 
and require user to use --cuda-path if they need something else.



Comment at: clang/lib/Driver/ToolChains/Cuda.cpp:132
+  "11.5", "11.4", "11.3", "11.2", "11.1", "11.0", "10.2", "10.1",
+  "10.0", "9.2",  "9.1",  "9.0",  "8.0",  "7.5",  "7.0"};
   auto &FS = D.getVFS();

I think these can be dropped altogether.  Maybe 9,x too.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D114326

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


[PATCH] D114108: [NFC][clang] Inclusive language: rename master variable to controller in debug-info tests

2021-11-22 Thread Quinn Pham 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 rGad501054f1b5: [NFC][clang] Inclusive language: rename master 
variable to controller in debug… (authored by quinnp).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D114108

Files:
  clang/test/CodeGenObjC/debug-info-block-helper.m
  cross-project-tests/debuginfo-tests/llgdb-tests/blocks.m


Index: cross-project-tests/debuginfo-tests/llgdb-tests/blocks.m
===
--- cross-project-tests/debuginfo-tests/llgdb-tests/blocks.m
+++ cross-project-tests/debuginfo-tests/llgdb-tests/blocks.m
@@ -11,7 +11,7 @@
 // CHECK: ${{[0-9]}} = 1
 // DEBUGGER: p dbTransaction
 // CHECK: ${{[0-9]}} = 0
-// DEBUGGER: p master
+// DEBUGGER: p controller
 // CHECK: ${{[0-9]}} = 0
 
 #include 
@@ -21,16 +21,16 @@
 @interface A:NSObject @end
 @implementation A
 - (void) helper {
- int master = 0;
+ int controller = 0;
  __block int m2 = 0;
  __block int dbTransaction = 0;
  int (^x)(void) = ^(void) { (void) self; 
-   (void) master; 
+   (void) controller; 
(void) dbTransaction; 
m2++;
return m2;
};
-  master = x();
+  controller = x();
 }
 @end
 
Index: clang/test/CodeGenObjC/debug-info-block-helper.m
===
--- clang/test/CodeGenObjC/debug-info-block-helper.m
+++ clang/test/CodeGenObjC/debug-info-block-helper.m
@@ -12,17 +12,17 @@
 @interface A:NSObject @end
 @implementation A
 - (void) helper {
- int master = 0;
+ int controller = 0;
  __block int m2 = 0;
  __block int dbTransaction = 0;
  int (^x)(void) = ^(void) { (void) self; 
-   (void) master; 
+   (void) controller; 
(void) dbTransaction; 
m2++;
return m2;
 
};
-  master = x();
+  controller = x();
 }
 @end
 


Index: cross-project-tests/debuginfo-tests/llgdb-tests/blocks.m
===
--- cross-project-tests/debuginfo-tests/llgdb-tests/blocks.m
+++ cross-project-tests/debuginfo-tests/llgdb-tests/blocks.m
@@ -11,7 +11,7 @@
 // CHECK: ${{[0-9]}} = 1
 // DEBUGGER: p dbTransaction
 // CHECK: ${{[0-9]}} = 0
-// DEBUGGER: p master
+// DEBUGGER: p controller
 // CHECK: ${{[0-9]}} = 0
 
 #include 
@@ -21,16 +21,16 @@
 @interface A:NSObject @end
 @implementation A
 - (void) helper {
- int master = 0;
+ int controller = 0;
  __block int m2 = 0;
  __block int dbTransaction = 0;
  int (^x)(void) = ^(void) { (void) self; 
-	(void) master; 
+	(void) controller; 
 	(void) dbTransaction; 
 	m2++;
 	return m2;
 	};
-  master = x();
+  controller = x();
 }
 @end
 
Index: clang/test/CodeGenObjC/debug-info-block-helper.m
===
--- clang/test/CodeGenObjC/debug-info-block-helper.m
+++ clang/test/CodeGenObjC/debug-info-block-helper.m
@@ -12,17 +12,17 @@
 @interface A:NSObject @end
 @implementation A
 - (void) helper {
- int master = 0;
+ int controller = 0;
  __block int m2 = 0;
  __block int dbTransaction = 0;
  int (^x)(void) = ^(void) { (void) self; 
-	(void) master; 
+	(void) controller; 
 	(void) dbTransaction; 
 	m2++;
 	return m2;
 
 	};
-  master = x();
+  controller = x();
 }
 @end
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] ad50105 - [NFC][clang] Inclusive language: rename master variable to controller in debug-info tests

2021-11-22 Thread Quinn Pham via cfe-commits

Author: Quinn Pham
Date: 2021-11-22T14:02:54-06:00
New Revision: ad501054f1b5ce0aca47c931aa03a22706e4ff8d

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

LOG: [NFC][clang] Inclusive language: rename master variable to controller in 
debug-info tests

[NFC] As part of using inclusive language within the llvm project, this patch
replaces master with controller in these tests.

Reviewed By: rjmccall

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

Added: 


Modified: 
clang/test/CodeGenObjC/debug-info-block-helper.m
cross-project-tests/debuginfo-tests/llgdb-tests/blocks.m

Removed: 




diff  --git a/clang/test/CodeGenObjC/debug-info-block-helper.m 
b/clang/test/CodeGenObjC/debug-info-block-helper.m
index 914962897fd4a..ac4ba39976b7e 100644
--- a/clang/test/CodeGenObjC/debug-info-block-helper.m
+++ b/clang/test/CodeGenObjC/debug-info-block-helper.m
@@ -12,17 +12,17 @@ @interface NSObject {
 @interface A:NSObject @end
 @implementation A
 - (void) helper {
- int master = 0;
+ int controller = 0;
  __block int m2 = 0;
  __block int dbTransaction = 0;
  int (^x)(void) = ^(void) { (void) self; 
-   (void) master; 
+   (void) controller; 
(void) dbTransaction; 
m2++;
return m2;
 
};
-  master = x();
+  controller = x();
 }
 @end
 

diff  --git a/cross-project-tests/debuginfo-tests/llgdb-tests/blocks.m 
b/cross-project-tests/debuginfo-tests/llgdb-tests/blocks.m
index 8e5a21213200d..79ec6fd271e8a 100644
--- a/cross-project-tests/debuginfo-tests/llgdb-tests/blocks.m
+++ b/cross-project-tests/debuginfo-tests/llgdb-tests/blocks.m
@@ -11,7 +11,7 @@
 // CHECK: ${{[0-9]}} = 1
 // DEBUGGER: p dbTransaction
 // CHECK: ${{[0-9]}} = 0
-// DEBUGGER: p master
+// DEBUGGER: p controller
 // CHECK: ${{[0-9]}} = 0
 
 #include 
@@ -21,16 +21,16 @@
 @interface A:NSObject @end
 @implementation A
 - (void) helper {
- int master = 0;
+ int controller = 0;
  __block int m2 = 0;
  __block int dbTransaction = 0;
  int (^x)(void) = ^(void) { (void) self; 
-   (void) master; 
+   (void) controller; 
(void) dbTransaction; 
m2++;
return m2;
};
-  master = x();
+  controller = x();
 }
 @end
 



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


[PATCH] D113245: [Sema] Mark explicit specialization declaration in a friend invalid

2021-11-22 Thread Yuanfang Chen via Phabricator via cfe-commits
ychen added a comment.

ping?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D113245

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


Re: [PATCH] D100879: [Clang] Propagate guaranteed alignment for malloc and others

2021-11-22 Thread John McCall via cfe-commits
On Mon, Nov 22, 2021 at 2:28 PM John McCall  wrote:

> On Mon, Nov 22, 2021 at 1:08 PM David Goldblatt via Phabricator <
> revi...@reviews.llvm.org> wrote:
>
>> and related projects avoid relying on alignment guarantees (e.g.
>> libstdc++ at one point considered assuming that 8-byte allocs were 16-byte
>> aligned, and decided not to). At least one Linux distribution using clang
>> (Alpine) uses musl, which is a weak-alignment implementation (contrary to
>> what I claimed in N2293; I screwed up my background research).
>>
>
> If Alpine Linux wants to provide a weaker alignment guarantee than the
> "standard" Linux platform, they're entitled to.
>

I guess I should add that this would very arguably be ABI-incompatible and
could lead to problems running binaries built for Linux on other platforms
unless they statically link libc, but, well, that's an argument for Alpine
Linux to have with people interested in ensuring that there's a common
Linux platform.  Compilers are probably best off treating different Linux
distributions as independent platforms that happen to have a large amount
in common, similar to the BSDs except more so.

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


[clang] a40dcd0 - [Driver] correct typo in FreeBSD 14 test

2021-11-22 Thread Ed Maste via cfe-commits

Author: Ed Maste
Date: 2021-11-22T14:37:27-05:00
New Revision: a40dcd060e9d374d68df53b881d62e4de2bc310a

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

LOG: [Driver] correct typo in FreeBSD 14 test

The test specified amd64-unknown-freebsd40.0 rather than 14.0.  Since
40 is greater than 14 the test (for behaviour new in FreeBSD 14) worked
despite the typo.

Fixes:  699d47472c3f
Reviewed by:dim (in D6)

Added: 


Modified: 
clang/test/Driver/freebsd.cpp

Removed: 




diff  --git a/clang/test/Driver/freebsd.cpp b/clang/test/Driver/freebsd.cpp
index fde888902e12c..d199f6e2367ab 100644
--- a/clang/test/Driver/freebsd.cpp
+++ b/clang/test/Driver/freebsd.cpp
@@ -5,7 +5,7 @@
 // CHECK-TEN: "-lc++" "-lm"
 // CHECK-NINE: "-lstdc++" "-lm"
 
-// RUN: %clangxx %s -### -pg -o %t.o -target amd64-unknown-freebsd40.0 
-stdlib=platform 2>&1 \
+// RUN: %clangxx %s -### -pg -o %t.o -target amd64-unknown-freebsd14.0 
-stdlib=platform 2>&1 \
 // RUN:   | FileCheck --check-prefix=CHECK-PG-FOURTEEN %s
 // RUN: %clangxx %s -### -pg -o %t.o -target amd64-unknown-freebsd10.0 
-stdlib=platform 2>&1 \
 // RUN:   | FileCheck --check-prefix=CHECK-PG-TEN %s



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


[PATCH] D112287: [clang] Implement CFG construction for @try and @catch

2021-11-22 Thread Constantin Manea via Phabricator via cfe-commits
comanea added a comment.

I believe there is an issue that this change introduced. It is described here. 
https://bugs.llvm.org/show_bug.cgi?id=52473
If anyone could provide some insight, it would be much appreciated.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112287

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


[PATCH] D111457: [clang][test] Add lit helper for windows paths

2021-11-22 Thread Reid Kleckner via Phabricator via cfe-commits
rnk added a comment.

These seem like generic substitutions that would be useful to anyone writing 
lit tests. We already have `%{pathsep}`:
https://llvm.org/docs/CommandGuide/lit.html#substitutions

These should live there as well, and be documented similarly, I think.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D111457

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


Re: [PATCH] D100879: [Clang] Propagate guaranteed alignment for malloc and others

2021-11-22 Thread John McCall via cfe-commits
On Mon, Nov 22, 2021 at 1:08 PM David Goldblatt via Phabricator <
revi...@reviews.llvm.org> wrote:

> davidtgoldblatt added a comment.
>
> (For background: I'm a jemalloc maintainer and wrote N2293).
>
> In D100879#3145361 , @rjmccall
> wrote:
>
> > Platforms are permitted to make stronger guarantees than the C standard
> requires, and it is totally reasonable for compilers to assume that
> `malloc` meets the target platform's documented guarantees.  Arguably,
> libraries should not be replacing `malloc` if they fail to meet the
> platform's documented guarantees.
>
> I agree generally that assuming platform guarantees is reasonable for the
> compiler in targeting that platform, but I don't think I agree that the
> dlmalloc alignment is one of them.


Well, IIRC it's documented in the platform manual for `malloc`.  I suppose
one could argue that it's an implementation property which is only
guaranteed for unreplaced `malloc`s, but that's not what I would naturally
assume from reading the manual, and you'd think there would be a warning
that library code can only assume a weaker alignment.  I suppose you could
also argue that the manual itself is implementation-specific, but platform
guarantees have to be documented *somewhere*, and conventionally that's the
standard manual.

Still, if you can get glibc to confirm that the intent is that replacement
`malloc`s aren't required to provide the documented alignment, then I would
agree that Clang should not be assuming this alignment.

Supporting malloc replacement is a first-class feature for glibc malloc,


Again, this in itself doesn't mean much.  You are allowed to replace
`malloc`; you are not allowed to replace `malloc` with an incorrect
implementation.  Presumably we can agree that a replacement that only
provided 1-byte alignment would be wrong.  The standard for correctness is
defined by the platform.  If you replaced `malloc` with something that
returned 8-byte alignment on Darwin, you would definitely be wrong.  So
what you need here is a statement from the platform maintainers that it's
legal to replace `malloc` with something that provides less alignment than
is documented in `man malloc`.

Obviously, if you don't actually replace `malloc` and just provide a
`jemalloc` symbol, you can do whatever you want.


> and related projects avoid relying on alignment guarantees (e.g. libstdc++
> at one point considered assuming that 8-byte allocs were 16-byte aligned,
> and decided not to). At least one Linux distribution using clang (Alpine)
> uses musl, which is a weak-alignment implementation (contrary to what I
> claimed in N2293; I screwed up my background research).
>

If Alpine Linux wants to provide a weaker alignment guarantee than the
"standard" Linux platform, they're entitled to.

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


[PATCH] D113372: [Driver] Add CLANG_DEFAULT_PIE to emulate GCC --enable-default-pie

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

Ping


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D113372

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


[PATCH] D110663: [Driver] Support Debian multiarch style lib/clang/14.0.0/x86_64-linux-gnu runtime path and include/x86_64-linux-gnu/c++/v1 libc++ path

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

Ping


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D110663

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


[PATCH] D113107: Support of expression granularity for _Float16.

2021-11-22 Thread Zahira Ammarguellat via Phabricator via cfe-commits
zahiraam added a comment.

Question about this comment:

3. “ Approaches #1 and #2 require a lot of intermediate conversions when 
hardware isn't available. In our example, a + b + c has to be calculated as 
(_Float16) ((float) (_Float16) ((float) a + (float) b) + (float) c), where the 
result of one addition is converted down and then converted back again. You can 
avoid this by specifically recognizing this pattern and eliminating the 
conversion from sub-operations that happen to be of type float, so that in our 
example, a + b + c would be calculated as (_Float16) ((float) a + (float) b + 
(float) c). This is actually allowed by the C standard by default as a form of 
FP contraction; in fact, I believe C's rules for FP contraction were originally 
designed for exactly this kind of situation, except that it was emulating float 
with double on hardware that only provided arithmetic on the latter. Obviously, 
this can change results.”

Without any changes to clang this test case:
// RUN: %clang_cc1 -triple x86_64-linux  -emit-llvm  < %s
_Float16 foo (_Float16 a, _Float16 b, _Float16 c) {

  return (_Float16) ((float) a + (float) b + (float) c);

}
Generates this IR:
target triple = "x86_64-unknown-linux"

; Function Attrs: noinline nounwind optnone
define dso_local half @foo(half %a, half %b, half %c) #0 {
entry:

  %a.addr = alloca half, align 2
  %b.addr = alloca half, align 2
  %c.addr = alloca half, align 2
  store half %a, half* %a.addr, align 2
  store half %b, half* %b.addr, align 2
  store half %c, half* %c.addr, align 2
  %0 = load half, half* %a.addr, align 2
  %conv = fpext half %0 to float
  %1 = load half, half* %b.addr, align 2
  %conv1 = fpext half %1 to float
  %add = fadd float %conv, %conv1
  %2 = load half, half* %c.addr, align 2
  %conv2 = fpext half %2 to float
  %add3 = fadd float %add, %conv2
  %conv4 = fptrunc float %add3 to half
  ret half %conv4

}

And this case:
__fp16 foo (__fp16 a, __fp16 b, __fp16 c) {

  return a + b + c;

}
Compiled with these options:

-c -Xclang "-triple" -Xclang "armv7a-linux-gnu" -target arm -emit-llvm -S
Generates this IR:
target triple = "armv7a-unknown-linux-gnu"

; Function Attrs: noinline nounwind optnone
define dso_local arm_aapcscc half @foo(half %a, half %b, half %c) #0 {
entry:

  %a.addr = alloca half, align 2
  %b.addr = alloca half, align 2
  %c.addr = alloca half, align 2
  store half %a, half* %a.addr, align 2
  store half %b, half* %b.addr, align 2
  store half %c, half* %c.addr, align 2
  %0 = load half, half* %a.addr, align 2
  %conv = fpext half %0 to float
  %1 = load half, half* %b.addr, align 2
  %conv1 = fpext half %1 to float
  %add = fadd float %conv, %conv1
  %2 = load half, half* %c.addr, align 2
  %conv2 = fpext half %2 to float
  %add3 = fadd float %add, %conv2
  %3 = fptrunc float %add3 to half
  ret half %3

}

I see no difference in the IR generated.
So this:
// RUN: %clang_cc1 -triple x86_64-linux  -emit-llvm  < %s
_Float16 foo (_Float16 a, _Float16 b, _Float16 c) {

  return a + b + c;

}

Should also generate this same IR right?




Comment at: clang/test/CodeGen/X86/Float16-aritmetic.c:8-9
+  // CHECK: alloca half
+  // CHECK: store half {{.*}}, half*
+  // CHECK: store half {{.*}}, half*
+  // CHECK: load half, half*

pengfei wrote:
> This isn't correct without the ABI code change. I did some work in D107082. I 
> plan to refactor (if I have enough time)
If this the output we want to generate, should the changes D107082 happen 
before the changes in this patch?


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

https://reviews.llvm.org/D113107

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


[PATCH] D113451: [PowerPC] [Clang] Enable Intel intrinsics support on FreeBSD

2021-11-22 Thread Alfredo Dal'Ava Júnior via Phabricator via cfe-commits
adalava added a comment.

In D113451#3124461 , @jsji wrote:

> LGTM. Thanks for enabling this for FreeBSD.

Thanks for reviewing it.

If you and others with merge permissions think it's ready, please merge it (I 
don't have the permissions)

Thanks!!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D113451

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


[PATCH] D113148: Add new clang-tidy check for string_view(nullptr)

2021-11-22 Thread CJ Johnson via Phabricator via cfe-commits
CJ-Johnson added a comment.

Thank you all for the feedback! Would it be ok to proceed with removing the 
`nullptr` checking for `basic_string_view` in `bugprone-string-constructor`, as 
Alex indicated?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D113148

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


[PATCH] D113148: Add new clang-tidy check for string_view(nullptr)

2021-11-22 Thread CJ Johnson via Phabricator via cfe-commits
CJ-Johnson updated this revision to Diff 388973.
CJ-Johnson added a comment.

Rebase on head


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D113148

Files:
  clang-tools-extra/clang-tidy/bugprone/BugproneTidyModule.cpp
  clang-tools-extra/clang-tidy/bugprone/CMakeLists.txt
  clang-tools-extra/clang-tidy/bugprone/StringviewNullptrCheck.cpp
  clang-tools-extra/clang-tidy/bugprone/StringviewNullptrCheck.h
  clang-tools-extra/docs/ReleaseNotes.rst
  clang-tools-extra/docs/clang-tidy/checks/bugprone-stringview-nullptr.rst
  clang-tools-extra/docs/clang-tidy/checks/list.rst
  clang-tools-extra/test/clang-tidy/checkers/bugprone-stringview-nullptr.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/bugprone-stringview-nullptr.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/bugprone-stringview-nullptr.cpp
@@ -0,0 +1,1417 @@
+// RUN: %check_clang_tidy %s bugprone-stringview-nullptr -std=c++17 %t
+
+namespace std {
+
+using nullptr_t = decltype(nullptr);
+
+template 
+T &&declval();
+
+template 
+struct type_identity { using type = T; };
+template 
+using type_identity_t = typename type_identity::type;
+
+template 
+class basic_string_view {
+public:
+  basic_string_view();
+  basic_string_view(const C *);
+  basic_string_view(const basic_string_view &);
+  basic_string_view &operator=(const basic_string_view &);
+};
+
+template 
+bool operator<(basic_string_view, basic_string_view);
+template 
+bool operator<(type_identity_t>, basic_string_view);
+template 
+bool operator<(basic_string_view, type_identity_t>);
+
+template 
+bool operator<=(basic_string_view, basic_string_view);
+template 
+bool operator<=(type_identity_t>, basic_string_view);
+template 
+bool operator<=(basic_string_view, type_identity_t>);
+
+template 
+bool operator>(basic_string_view, basic_string_view);
+template 
+bool operator>(type_identity_t>, basic_string_view);
+template 
+bool operator>(basic_string_view, type_identity_t>);
+
+template 
+bool operator>=(basic_string_view, basic_string_view);
+template 
+bool operator>=(type_identity_t>, basic_string_view);
+template 
+bool operator>=(basic_string_view, type_identity_t>);
+
+template 
+bool operator==(basic_string_view, basic_string_view);
+template 
+bool operator==(type_identity_t>, basic_string_view);
+template 
+bool operator==(basic_string_view, type_identity_t>);
+
+template 
+bool operator!=(basic_string_view, basic_string_view);
+template 
+bool operator!=(type_identity_t>, basic_string_view);
+template 
+bool operator!=(basic_string_view, type_identity_t>);
+
+using string_view = basic_string_view;
+
+} // namespace std
+
+void function(std::string_view);
+void function(std::string_view, std::string_view);
+
+void temporary_construction() /* a */ {
+  // Functional Cast
+  {
+(void)(std::string_view(nullptr)) /* a1 */;
+// CHECK-MESSAGES: :[[@LINE-1]]:29: warning: constructing basic_string_view from null is undefined; replace with the default constructor
+// CHECK-FIXES: {{^}}(void)(std::string_view()) /* a1 */;
+
+(void)(std::string_view((nullptr))) /* a2 */;
+// CHECK-MESSAGES: :[[@LINE-1]]:29: warning: constructing{{.*}}default
+// CHECK-FIXES: {{^}}(void)(std::string_view()) /* a2 */;
+
+(void)(std::string_view({nullptr})) /* a3 */;
+// CHECK-MESSAGES: :[[@LINE-1]]:29: warning: constructing{{.*}}default
+// CHECK-FIXES: {{^}}(void)(std::string_view()) /* a3 */;
+
+(void)(std::string_view({(nullptr)})) /* a4 */;
+// CHECK-MESSAGES: :[[@LINE-1]]:29: warning: constructing{{.*}}default
+// CHECK-FIXES: {{^}}(void)(std::string_view()) /* a4 */;
+
+(void)(std::string_view({})) /* a5 */; // Default `const CharT*`
+// CHECK-MESSAGES: :[[@LINE-1]]:29: warning: constructing{{.*}}default
+// CHECK-FIXES: {{^}}(void)(std::string_view()) /* a5 */;
+
+// (void)(const std::string_view(nullptr)) /* a6 */;
+// CV qualifiers do not compile in this context
+
+// (void)(const std::string_view((nullptr))) /* a7 */;
+// CV qualifiers do not compile in this context
+
+// (void)(const std::string_view({nullptr})) /* a8 */;
+// CV qualifiers do not compile in this context
+
+// (void)(const std::string_view({(nullptr)})) /* a9 */;
+// CV qualifiers do not compile in this context
+
+// (void)(const std::string_view({})) /* a10 */; // Default `const CharT*`
+// CV qualifiers do not compile in this context
+  }
+
+  // Temporary Object
+  {
+(void)(std::string_view{nullptr}) /* a11 */;
+// CHECK-MESSAGES: :[[@LINE-1]]:29: warning: constructing{{.*}}default
+// CHECK-FIXES: {{^}}(void)(std::string_view{}) /* a11 */;
+
+(void)(std::string_view{(nullptr)}) /* a12 */;
+// CHECK-MESSAGES: :[[@LINE-1]]:29: warning: constructing{{.*}}default
+// CHECK-FIXES: {{^}}(void)(std::string_view{}) /

[PATCH] D113148: Add new clang-tidy check for string_view(nullptr)

2021-11-22 Thread CJ Johnson via Phabricator via cfe-commits
CJ-Johnson updated this revision to Diff 388972.
CJ-Johnson marked 6 inline comments as done.
CJ-Johnson added a comment.

Address reviewer comments


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D113148

Files:
  clang-tools-extra/clang-tidy/bugprone/BugproneTidyModule.cpp
  clang-tools-extra/clang-tidy/bugprone/CMakeLists.txt
  clang-tools-extra/clang-tidy/bugprone/StringviewNullptrCheck.cpp
  clang-tools-extra/clang-tidy/bugprone/StringviewNullptrCheck.h
  clang-tools-extra/docs/ReleaseNotes.rst
  clang-tools-extra/docs/clang-tidy/checks/bugprone-stringview-nullptr.rst
  clang-tools-extra/docs/clang-tidy/checks/list.rst
  clang-tools-extra/test/clang-tidy/checkers/bugprone-stringview-nullptr.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/bugprone-stringview-nullptr.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/bugprone-stringview-nullptr.cpp
@@ -0,0 +1,1417 @@
+// RUN: %check_clang_tidy %s bugprone-stringview-nullptr -std=c++17 %t
+
+namespace std {
+
+using nullptr_t = decltype(nullptr);
+
+template 
+T &&declval();
+
+template 
+struct type_identity { using type = T; };
+template 
+using type_identity_t = typename type_identity::type;
+
+template 
+class basic_string_view {
+public:
+  basic_string_view();
+  basic_string_view(const C *);
+  basic_string_view(const basic_string_view &);
+  basic_string_view &operator=(const basic_string_view &);
+};
+
+template 
+bool operator<(basic_string_view, basic_string_view);
+template 
+bool operator<(type_identity_t>, basic_string_view);
+template 
+bool operator<(basic_string_view, type_identity_t>);
+
+template 
+bool operator<=(basic_string_view, basic_string_view);
+template 
+bool operator<=(type_identity_t>, basic_string_view);
+template 
+bool operator<=(basic_string_view, type_identity_t>);
+
+template 
+bool operator>(basic_string_view, basic_string_view);
+template 
+bool operator>(type_identity_t>, basic_string_view);
+template 
+bool operator>(basic_string_view, type_identity_t>);
+
+template 
+bool operator>=(basic_string_view, basic_string_view);
+template 
+bool operator>=(type_identity_t>, basic_string_view);
+template 
+bool operator>=(basic_string_view, type_identity_t>);
+
+template 
+bool operator==(basic_string_view, basic_string_view);
+template 
+bool operator==(type_identity_t>, basic_string_view);
+template 
+bool operator==(basic_string_view, type_identity_t>);
+
+template 
+bool operator!=(basic_string_view, basic_string_view);
+template 
+bool operator!=(type_identity_t>, basic_string_view);
+template 
+bool operator!=(basic_string_view, type_identity_t>);
+
+using string_view = basic_string_view;
+
+} // namespace std
+
+void function(std::string_view);
+void function(std::string_view, std::string_view);
+
+void temporary_construction() /* a */ {
+  // Functional Cast
+  {
+(void)(std::string_view(nullptr)) /* a1 */;
+// CHECK-MESSAGES: :[[@LINE-1]]:29: warning: constructing basic_string_view from null is undefined; replace with the default constructor
+// CHECK-FIXES: {{^}}(void)(std::string_view()) /* a1 */;
+
+(void)(std::string_view((nullptr))) /* a2 */;
+// CHECK-MESSAGES: :[[@LINE-1]]:29: warning: constructing{{.*}}default
+// CHECK-FIXES: {{^}}(void)(std::string_view()) /* a2 */;
+
+(void)(std::string_view({nullptr})) /* a3 */;
+// CHECK-MESSAGES: :[[@LINE-1]]:29: warning: constructing{{.*}}default
+// CHECK-FIXES: {{^}}(void)(std::string_view()) /* a3 */;
+
+(void)(std::string_view({(nullptr)})) /* a4 */;
+// CHECK-MESSAGES: :[[@LINE-1]]:29: warning: constructing{{.*}}default
+// CHECK-FIXES: {{^}}(void)(std::string_view()) /* a4 */;
+
+(void)(std::string_view({})) /* a5 */; // Default `const CharT*`
+// CHECK-MESSAGES: :[[@LINE-1]]:29: warning: constructing{{.*}}default
+// CHECK-FIXES: {{^}}(void)(std::string_view()) /* a5 */;
+
+// (void)(const std::string_view(nullptr)) /* a6 */;
+// CV qualifiers do not compile in this context
+
+// (void)(const std::string_view((nullptr))) /* a7 */;
+// CV qualifiers do not compile in this context
+
+// (void)(const std::string_view({nullptr})) /* a8 */;
+// CV qualifiers do not compile in this context
+
+// (void)(const std::string_view({(nullptr)})) /* a9 */;
+// CV qualifiers do not compile in this context
+
+// (void)(const std::string_view({})) /* a10 */; // Default `const CharT*`
+// CV qualifiers do not compile in this context
+  }
+
+  // Temporary Object
+  {
+(void)(std::string_view{nullptr}) /* a11 */;
+// CHECK-MESSAGES: :[[@LINE-1]]:29: warning: constructing{{.*}}default
+// CHECK-FIXES: {{^}}(void)(std::string_view{}) /* a11 */;
+
+(void)(std::string_view{(nullptr)}) /* a12 */;
+// CHECK-MESSAGES: :[[@LINE-1]]:29: warning: constructing{{.*}}default
+ 

[PATCH] D114312: libfuzzer: Disable broken tests for arm

2021-11-22 Thread Manoj Gupta via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG2e67276d984d: libfuzzer: Disable broken tests for arm 
(authored by manojgupta).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D114312

Files:
  compiler-rt/test/fuzzer/acquire-crash-state.test
  compiler-rt/test/fuzzer/compressed.test
  compiler-rt/test/fuzzer/msan-custom-mutator.test
  compiler-rt/test/fuzzer/msan-param-unpoison.test
  compiler-rt/test/fuzzer/msan.test
  compiler-rt/test/fuzzer/sigint.test
  compiler-rt/test/fuzzer/value-profile-div.test


Index: compiler-rt/test/fuzzer/value-profile-div.test
===
--- compiler-rt/test/fuzzer/value-profile-div.test
+++ compiler-rt/test/fuzzer/value-profile-div.test
@@ -1,5 +1,5 @@
 UNSUPPORTED: ios
-UNSUPPORTED: aarch64
+UNSUPPORTED: arm, aarch64
 CHECK: AddressSanitizer: {{FPE|int-divide-by-zero}}
 RUN: %cpp_compiler %S/DivTest.cpp -fsanitize-coverage=trace-div -o %t-DivTest
 RUN: not %run %t-DivTest -seed=1 -use_value_profile=1 -runs=1000 2>&1 | 
FileCheck %s
Index: compiler-rt/test/fuzzer/sigint.test
===
--- compiler-rt/test/fuzzer/sigint.test
+++ compiler-rt/test/fuzzer/sigint.test
@@ -1,4 +1,5 @@
 REQUIRES: msan
+UNSUPPORTED: arm
 
 # Check that libFuzzer exits gracefully under SIGINT with MSan.
 RUN: rm -rf %t
Index: compiler-rt/test/fuzzer/msan.test
===
--- compiler-rt/test/fuzzer/msan.test
+++ compiler-rt/test/fuzzer/msan.test
@@ -1,4 +1,5 @@
 REQUIRES: msan
+UNSUPPORTED: arm
 RUN: %msan_compiler %S/SimpleTestStdio.cpp -o %t
 RUN: not %run %t -seed=1 -runs=1000 2>&1 | FileCheck %s 
--check-prefix=NO-REPORT
 
Index: compiler-rt/test/fuzzer/msan-param-unpoison.test
===
--- compiler-rt/test/fuzzer/msan-param-unpoison.test
+++ compiler-rt/test/fuzzer/msan-param-unpoison.test
@@ -1,4 +1,5 @@
 REQUIRES: msan
+UNSUPPORTED: arm
 RUN: %msan_compiler %S/MsanParamUnpoison.cpp -o %t
 RUN: %run %t -seed=1 -runs=1000 2>&1 | FileCheck %s
 
Index: compiler-rt/test/fuzzer/msan-custom-mutator.test
===
--- compiler-rt/test/fuzzer/msan-custom-mutator.test
+++ compiler-rt/test/fuzzer/msan-custom-mutator.test
@@ -1,4 +1,5 @@
 REQUIRES: msan
+UNSUPPORTED: arm
 RUN: %msan_compiler %S/MsanCustomMutator.cpp -o %t
 RUN: %run %t -seed=1 -runs=1000 2>&1 | FileCheck %s
 
Index: compiler-rt/test/fuzzer/compressed.test
===
--- compiler-rt/test/fuzzer/compressed.test
+++ compiler-rt/test/fuzzer/compressed.test
@@ -2,7 +2,7 @@
 REQUIRES: zlib
 # zlib is "supported" on i386 even when only for x86_64, explicitly make i386
 # unsupported by this test.
-UNSUPPORTED: i386
+UNSUPPORTED: i386, arm
 # Custom mutator should find this bug, w/o custom -- no chance.
 RUN: %cpp_compiler %S/CompressedTest.cpp -o %t-CompressedTestCustom 
-DCUSTOM_MUTATOR -lz
 RUN: %cpp_compiler %S/CompressedTest.cpp -o %t-CompressedTestPlain -lz
Index: compiler-rt/test/fuzzer/acquire-crash-state.test
===
--- compiler-rt/test/fuzzer/acquire-crash-state.test
+++ compiler-rt/test/fuzzer/acquire-crash-state.test
@@ -1,3 +1,4 @@
+UNSUPPORTED: arm
 RUN: %cpp_compiler %S/AcquireCrashStateTest.cpp -o %t
 RUN: %run %t 2>&1 | FileCheck %s
 CHECK-NOT: fuzz target exited


Index: compiler-rt/test/fuzzer/value-profile-div.test
===
--- compiler-rt/test/fuzzer/value-profile-div.test
+++ compiler-rt/test/fuzzer/value-profile-div.test
@@ -1,5 +1,5 @@
 UNSUPPORTED: ios
-UNSUPPORTED: aarch64
+UNSUPPORTED: arm, aarch64
 CHECK: AddressSanitizer: {{FPE|int-divide-by-zero}}
 RUN: %cpp_compiler %S/DivTest.cpp -fsanitize-coverage=trace-div -o %t-DivTest
 RUN: not %run %t-DivTest -seed=1 -use_value_profile=1 -runs=1000 2>&1 | FileCheck %s
Index: compiler-rt/test/fuzzer/sigint.test
===
--- compiler-rt/test/fuzzer/sigint.test
+++ compiler-rt/test/fuzzer/sigint.test
@@ -1,4 +1,5 @@
 REQUIRES: msan
+UNSUPPORTED: arm
 
 # Check that libFuzzer exits gracefully under SIGINT with MSan.
 RUN: rm -rf %t
Index: compiler-rt/test/fuzzer/msan.test
===
--- compiler-rt/test/fuzzer/msan.test
+++ compiler-rt/test/fuzzer/msan.test
@@ -1,4 +1,5 @@
 REQUIRES: msan
+UNSUPPORTED: arm
 RUN: %msan_compiler %S/SimpleTestStdio.cpp -o %t
 RUN: not %run %t -seed=1 -runs=1000 2>&1 | FileCheck %s --check-prefix=NO-REPORT
 
Index: compiler-rt/test/fuzzer/msan-param-unpoison.test
===
--- c

[PATCH] D114382: [clang] Fix wrong -Wunused-local-typedef warning within a template function

2021-11-22 Thread Kristina Bessonova via Phabricator via cfe-commits
krisb added inline comments.



Comment at: clang/test/Modules/odr_hash.cpp:4288
 S s;
+// expected-error@first.h:* {{'ParameterTest::S::Foo' has different 
definitions in different modules; definition in module 'FirstModule' first 
difference is 1st parameter with name ''}}
+// expected-note@second.h:* {{but in 'SecondModule' found 1st parameter with 
name 'asdf'}}

I'm not sure what was the original intent of this test (i.e. whether it 
intentionally tests the fact that there is no error on an uninstantiated static 
member function). As well as it doesn't clear to me what is the role of the 
unused typedef here, but it starts triggering the error because of redecls() 
call on isReferenced() added by this patch.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D114382

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


[PATCH] D114382: [clang] Fix wrong -Wunused-local-typedef warning within a template function

2021-11-22 Thread Kristina Bessonova via Phabricator via cfe-commits
krisb created this revision.
krisb added reviewers: thakis, rtrieu, rsmith.
krisb requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Partially fixes PR24883.

The patch sets Reference bit while instantiating a typedef if it
previously was found referenced.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D114382

Files:
  clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
  clang/test/AST/ast-dump-openmp-begin-declare-variant_reference.cpp
  clang/test/Modules/odr_hash.cpp
  clang/test/SemaCXX/warn-unused-local-typedef.cpp


Index: clang/test/SemaCXX/warn-unused-local-typedef.cpp
===
--- clang/test/SemaCXX/warn-unused-local-typedef.cpp
+++ clang/test/SemaCXX/warn-unused-local-typedef.cpp
@@ -238,5 +238,22 @@
   a->~A_t2();
 }
 
+namespace TypedefInLocalClassOfAMemberOfTemplateClass {
+template struct A {
+  void foo() {
+struct Inner {
+  typedef int Int; // no-diag
+  typedef char Char; // expected-warning {{unused typedef 'Char'}}
+  Int m;
+} b;
+  }
+};
+
+void foo() {
+  A x;
+  x.foo();
+}
+} // TypedefInLocalClassOfTemplateClassMember
+
 // This should not disable any warnings:
 #pragma clang diagnostic ignored "-Wunused-local-typedef"
Index: clang/test/Modules/odr_hash.cpp
===
--- clang/test/Modules/odr_hash.cpp
+++ clang/test/Modules/odr_hash.cpp
@@ -4285,6 +4285,8 @@
 G* S::Foo(const G* asdf, int*) {}
 #else
 S s;
+// expected-error@first.h:* {{'ParameterTest::S::Foo' has different 
definitions in different modules; definition in module 'FirstModule' first 
difference is 1st parameter with name ''}}
+// expected-note@second.h:* {{but in 'SecondModule' found 1st parameter with 
name 'asdf'}}
 #endif
 }  // ParameterTest
 
Index: clang/test/AST/ast-dump-openmp-begin-declare-variant_reference.cpp
===
--- clang/test/AST/ast-dump-openmp-begin-declare-variant_reference.cpp
+++ clang/test/AST/ast-dump-openmp-begin-declare-variant_reference.cpp
@@ -193,7 +193,7 @@
 // CHECK-NEXT: | | |-ParmVarDecl [[ADDR_43:0x[a-z0-9]*]]  
col:12 used __t 'float &'
 // CHECK-NEXT: | | `-CompoundStmt [[ADDR_44:0x[a-z0-9]*]] 
 // CHECK-NEXT: | |   |-DeclStmt [[ADDR_45:0x[a-z0-9]*]] 
-// CHECK-NEXT: | |   | `-TypedefDecl [[ADDR_46:0x[a-z0-9]*]]  
col:48 _Up 'typename remove_reference::type':'float'
+// CHECK-NEXT: | |   | `-TypedefDecl [[ADDR_46:0x[a-z0-9]*]]  
col:48 referenced _Up 'typename remove_reference::type':'float'
 // CHECK-NEXT: | |   |   `-ElaboratedType [[ADDR_47:0x[a-z0-9]*]] 'typename 
remove_reference::type' sugar
 // CHECK-NEXT: | |   | `-TypedefType [[ADDR_48:0x[a-z0-9]*]] 
'remove_reference::type' sugar
 // CHECK-NEXT: | |   |   |-Typedef [[ADDR_10]] 'type'
@@ -211,7 +211,7 @@
 // CHECK-NEXT: |   |-ParmVarDecl [[ADDR_53:0x[a-z0-9]*]]  
col:12 used __t 'short &'
 // CHECK-NEXT: |   `-CompoundStmt [[ADDR_54:0x[a-z0-9]*]] 
 // CHECK-NEXT: | |-DeclStmt [[ADDR_55:0x[a-z0-9]*]] 
-// CHECK-NEXT: | | `-TypedefDecl [[ADDR_56:0x[a-z0-9]*]]  
col:48 _Up 'typename remove_reference::type':'short'
+// CHECK-NEXT: | | `-TypedefDecl [[ADDR_56:0x[a-z0-9]*]]  
col:48 referenced _Up 'typename remove_reference::type':'short'
 // CHECK-NEXT: | |   `-ElaboratedType [[ADDR_57:0x[a-z0-9]*]] 'typename 
remove_reference::type' sugar
 // CHECK-NEXT: | | `-TypedefType [[ADDR_58:0x[a-z0-9]*]] 
'remove_reference::type' sugar
 // CHECK-NEXT: | |   |-Typedef [[ADDR_18]] 'type'
Index: clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
===
--- clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
+++ clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
@@ -953,6 +953,7 @@
 SemaRef.inferGslPointerAttribute(Typedef);
 
   Typedef->setAccess(D->getAccess());
+  Typedef->setReferenced(D->isReferenced());
 
   return Typedef;
 }


Index: clang/test/SemaCXX/warn-unused-local-typedef.cpp
===
--- clang/test/SemaCXX/warn-unused-local-typedef.cpp
+++ clang/test/SemaCXX/warn-unused-local-typedef.cpp
@@ -238,5 +238,22 @@
   a->~A_t2();
 }
 
+namespace TypedefInLocalClassOfAMemberOfTemplateClass {
+template struct A {
+  void foo() {
+struct Inner {
+  typedef int Int; // no-diag
+  typedef char Char; // expected-warning {{unused typedef 'Char'}}
+  Int m;
+} b;
+  }
+};
+
+void foo() {
+  A x;
+  x.foo();
+}
+} // TypedefInLocalClassOfTemplateClassMember
+
 // This should not disable any warnings:
 #pragma clang diagnostic ignored "-Wunused-local-typedef"
Index: clang/test/Modules/odr_hash.cpp
===
--- clang/test/Modules/odr_hash.cpp
+++ clang/test/Modules/odr_hash.cpp
@@ -4285,6 +4285,8 @@
 G* S::Foo(const G* asdf, int*) {}
 #else
 S s;

[PATCH] D114381: [AIX] Disable unsupported offloading gpu tests

2021-11-22 Thread Jake Egan via Phabricator via cfe-commits
Jake-Egan created this revision.
Jake-Egan requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D114381

Files:
  clang/test/Driver/clang-offload-bundler-asserts-on.c
  clang/test/Driver/clang-offload-bundler.c
  clang/test/Driver/openmp-offload-gpu.c


Index: clang/test/Driver/openmp-offload-gpu.c
===
--- clang/test/Driver/openmp-offload-gpu.c
+++ clang/test/Driver/openmp-offload-gpu.c
@@ -8,6 +8,8 @@
 // REQUIRES: nvptx-registered-target
 // REQUIRES: amdgpu-registered-target
 
+// UNSUPPORTED: aix
+
 /// ###
 
 /// Check -Xopenmp-target uses one of the archs provided when several archs 
are used.
Index: clang/test/Driver/clang-offload-bundler.c
===
--- clang/test/Driver/clang-offload-bundler.c
+++ clang/test/Driver/clang-offload-bundler.c
@@ -1,6 +1,6 @@
 // REQUIRES: x86-registered-target
 // REQUIRES: powerpc-registered-target
-// UNSUPPORTED: darwin
+// UNSUPPORTED: darwin, aix
 
 //
 // Generate all the types of files we can bundle.
Index: clang/test/Driver/clang-offload-bundler-asserts-on.c
===
--- clang/test/Driver/clang-offload-bundler-asserts-on.c
+++ clang/test/Driver/clang-offload-bundler-asserts-on.c
@@ -1,6 +1,6 @@
 // REQUIRES: x86-registered-target
 // REQUIRES: asserts
-// UNSUPPORTED: darwin
+// UNSUPPORTED: darwin, aix
 
 // Generate the file we can bundle.
 // RUN: %clang -O0 -target %itanium_abi_triple %s -c -o %t.o


Index: clang/test/Driver/openmp-offload-gpu.c
===
--- clang/test/Driver/openmp-offload-gpu.c
+++ clang/test/Driver/openmp-offload-gpu.c
@@ -8,6 +8,8 @@
 // REQUIRES: nvptx-registered-target
 // REQUIRES: amdgpu-registered-target
 
+// UNSUPPORTED: aix
+
 /// ###
 
 /// Check -Xopenmp-target uses one of the archs provided when several archs are used.
Index: clang/test/Driver/clang-offload-bundler.c
===
--- clang/test/Driver/clang-offload-bundler.c
+++ clang/test/Driver/clang-offload-bundler.c
@@ -1,6 +1,6 @@
 // REQUIRES: x86-registered-target
 // REQUIRES: powerpc-registered-target
-// UNSUPPORTED: darwin
+// UNSUPPORTED: darwin, aix
 
 //
 // Generate all the types of files we can bundle.
Index: clang/test/Driver/clang-offload-bundler-asserts-on.c
===
--- clang/test/Driver/clang-offload-bundler-asserts-on.c
+++ clang/test/Driver/clang-offload-bundler-asserts-on.c
@@ -1,6 +1,6 @@
 // REQUIRES: x86-registered-target
 // REQUIRES: asserts
-// UNSUPPORTED: darwin
+// UNSUPPORTED: darwin, aix
 
 // Generate the file we can bundle.
 // RUN: %clang -O0 -target %itanium_abi_triple %s -c -o %t.o
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D114320: [clang-format] Extend AllowShortBlocksOnASingleLine for else blocks

2021-11-22 Thread Jesses Gott via Phabricator via cfe-commits
jessesna updated this revision to Diff 388961.
jessesna added a comment.

use the more dense "verifyFormat(after,Style)" calls


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D114320

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


Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -5394,6 +5394,27 @@
   EXPECT_EQ("void f() { }", format("void f() {}", Style));
   Style.AllowShortBlocksOnASingleLine = FormatStyle::SBS_Empty;
   EXPECT_EQ("while (true) { }", format("while (true) {}", Style));
+  Style.BreakBeforeBraces = FormatStyle::BS_Custom;
+  Style.BraceWrapping.BeforeElse = false;
+  Style.BraceWrapping.AfterControlStatement = FormatStyle::BWACS_Always;
+  verifyFormat("if (a)\n"
+   "{\n"
+   "} else if (b)\n"
+   "{\n"
+   "} else\n"
+   "{ }",
+   Style);
+  Style.BraceWrapping.AfterControlStatement = FormatStyle::BWACS_Never;
+  verifyFormat("if (a) {\n"
+   "} else if (b) {\n"
+   "} else {\n"
+   "}",
+   Style);
+  Style.BraceWrapping.BeforeElse = true;
+  verifyFormat("if (a) { }\n"
+   "else if (b) { }\n"
+   "else { }",
+   Style);
 }
 
 TEST_F(FormatTest, FormatBeginBlockEndMacros) {
Index: clang/lib/Format/UnwrappedLineFormatter.cpp
===
--- clang/lib/Format/UnwrappedLineFormatter.cpp
+++ clang/lib/Format/UnwrappedLineFormatter.cpp
@@ -320,9 +320,9 @@
 }
 // Try to merge a control statement block with left brace wrapped
 if (I[1]->First->is(tok::l_brace) &&
-(TheLine->First->isOneOf(tok::kw_if, tok::kw_while, tok::kw_for,
- tok::kw_switch, tok::kw_try, tok::kw_do,
- TT_ForEachMacro) ||
+(TheLine->First->isOneOf(tok::kw_if, tok::kw_else, tok::kw_while,
+ tok::kw_for, tok::kw_switch, tok::kw_try,
+ tok::kw_do, TT_ForEachMacro) ||
  (TheLine->First->is(tok::r_brace) && TheLine->First->Next &&
   TheLine->First->Next->isOneOf(tok::kw_else, tok::kw_catch))) &&
 Style.BraceWrapping.AfterControlStatement ==
@@ -335,7 +335,7 @@
  ? 1
  : 0;
 } else if (I[1]->First->is(tok::l_brace) &&
-   TheLine->First->isOneOf(tok::kw_if, tok::kw_while,
+   TheLine->First->isOneOf(tok::kw_if, tok::kw_else, tok::kw_while,
tok::kw_for)) {
   return (Style.BraceWrapping.AfterControlStatement ==
   FormatStyle::BWACS_Always)
@@ -569,7 +569,7 @@
 
 // Check that the current line allows merging. This depends on whether we
 // are in a control flow statements as well as several style flags.
-if (Line.First->isOneOf(tok::kw_else, tok::kw_case) ||
+if (Line.First->is(tok::kw_case) ||
 (Line.First->Next && Line.First->Next->is(tok::kw_else)))
   return 0;
 // default: in switch statement
@@ -578,20 +578,21 @@
   if (Tok && Tok->is(tok::colon))
 return 0;
 }
-if (Line.First->isOneOf(tok::kw_if, tok::kw_while, tok::kw_do, tok::kw_try,
-tok::kw___try, tok::kw_catch, tok::kw___finally,
-tok::kw_for, tok::r_brace, Keywords.kw___except)) {
+if (Line.First->isOneOf(tok::kw_if, tok::kw_else, tok::kw_while, 
tok::kw_do,
+tok::kw_try, tok::kw___try, tok::kw_catch,
+tok::kw___finally, tok::kw_for, tok::r_brace,
+Keywords.kw___except)) {
   if (Style.AllowShortBlocksOnASingleLine == FormatStyle::SBS_Never)
 return 0;
   // Don't merge when we can't except the case when
   // the control statement block is empty
   if (!Style.AllowShortIfStatementsOnASingleLine &&
-  Line.startsWith(tok::kw_if) &&
+  Line.First->isOneOf(tok::kw_if, tok::kw_else) &&
   !Style.BraceWrapping.AfterControlStatement &&
   !I[1]->First->is(tok::r_brace))
 return 0;
   if (!Style.AllowShortIfStatementsOnASingleLine &&
-  Line.startsWith(tok::kw_if) &&
+  Line.First->isOneOf(tok::kw_if, tok::kw_else) &&
   Style.BraceWrapping.AfterControlStatement ==
   FormatStyle::BWACS_Always &&
   I + 2 != E && !I[2]->First->is(tok::r_brace))


Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -5394,6 +5394,27 @@
   EXPECT_EQ("void f() { }", fo

[PATCH] D100879: [Clang] Propagate guaranteed alignment for malloc and others

2021-11-22 Thread David Goldblatt via Phabricator via cfe-commits
davidtgoldblatt added a comment.

(For background: I'm a jemalloc maintainer and wrote N2293).

In D100879#3145361 , @rjmccall wrote:

> Platforms are permitted to make stronger guarantees than the C standard 
> requires, and it is totally reasonable for compilers to assume that `malloc` 
> meets the target platform's documented guarantees.  Arguably, libraries 
> should not be replacing `malloc` if they fail to meet the platform's 
> documented guarantees.

I agree generally that assuming platform guarantees is reasonable for the 
compiler in targeting that platform, but I don't think I agree that the 
dlmalloc alignment is one of them. Supporting malloc replacement is a 
first-class feature for glibc malloc, and related projects avoid relying on 
alignment guarantees (e.g. libstdc++ at one point considered assuming that 
8-byte allocs were 16-byte aligned, and decided not to). At least one Linux 
distribution using clang (Alpine) uses musl, which is a weak-alignment 
implementation (contrary to what I claimed in N2293; I screwed up my background 
research).

> With that said, it's probably not unreasonable for Clang to provide an option 
> that controls its assumptions about `malloc`.  We should think somewhat 
> carefully about whether there are other behaviors we'd want to include in 
> that, though.

This makes sense to me; this is broadly how clang handles `operator new` 
alignment as well.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100879

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


[PATCH] D114209: [flang] Add -fno-automatic, refine IsSaved()

2021-11-22 Thread Peter Klausler 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 rG996ef895cd3d: [flang] Add -fno-automatic, refine IsSaved() 
(authored by klausler).
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D114209

Files:
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/ToolChains/Flang.cpp
  flang/include/flang/Common/Fortran-features.h
  flang/include/flang/Evaluate/tools.h
  flang/include/flang/Semantics/tools.h
  flang/lib/Evaluate/tools.cpp
  flang/lib/Frontend/CompilerInvocation.cpp
  flang/lib/Semantics/resolve-names-utils.cpp
  flang/lib/Semantics/runtime-type-info.cpp
  flang/lib/Semantics/tools.cpp
  flang/test/Driver/driver-help-hidden.f90
  flang/test/Driver/driver-help.f90
  flang/test/Semantics/entry01.f90
  flang/test/Semantics/save01.f90
  flang/test/Semantics/save02.f90

Index: flang/test/Semantics/save02.f90
===
--- /dev/null
+++ flang/test/Semantics/save02.f90
@@ -0,0 +1,9 @@
+! RUN: %flang_fc1 -fsyntax-only -fno-automatic %s 2>&1 | FileCheck %s --allow-empty
+! Checks that -fno-automatic implies the SAVE attribute.
+! This same subroutine appears in test save01.f90 where it is an
+! error case due to the absence of both SAVE and -fno-automatic.
+subroutine foo
+  integer, target :: t
+  !CHECK-NOT: error:
+  integer, pointer :: p => t
+end
Index: flang/test/Semantics/save01.f90
===
--- flang/test/Semantics/save01.f90
+++ flang/test/Semantics/save01.f90
@@ -17,5 +17,13 @@
INTEGER :: mc
 END FUNCTION
 
+! This same subroutine appears in test save02.f90 where it is not an
+! error due to -fno-automatic.
+SUBROUTINE foo
+  INTEGER, TARGET :: t
+  !ERROR: An initial data target may not be a reference to an object 't' that lacks the SAVE attribute
+  INTEGER, POINTER :: p => t
+end
+
 END MODULE
 
Index: flang/test/Semantics/entry01.f90
===
--- flang/test/Semantics/entry01.f90
+++ flang/test/Semantics/entry01.f90
@@ -55,7 +55,6 @@
   common /badarg3/ x
   namelist /badarg4/ x
   !ERROR: A dummy argument must not be initialized
-  !ERROR: A dummy argument may not have the SAVE attribute
   integer :: badarg5 = 2
   entry okargs(goodarg1, goodarg2)
   !ERROR: RESULT(br1) may appear only in a function
Index: flang/test/Driver/driver-help.f90
===
--- flang/test/Driver/driver-help.f90
+++ flang/test/Driver/driver-help.f90
@@ -39,6 +39,7 @@
 ! HELP-NEXT:Specify where to find the compiled intrinsic modules
 ! HELP-NEXT: -flarge-sizes  Use INTEGER(KIND=8) for the result type in size-related intrinsics
 ! HELP-NEXT: -flogical-abbreviations Enable logical abbreviations
+! HELP-NEXT: -fno-automatic Implies the SAVE attribute for non-automatic local objects in subprograms unless RECURSIVE
 ! HELP-NEXT: -fno-color-diagnostics  Disable colors in diagnostics
 ! HELP-NEXT: -fopenacc  Enable OpenACC
 ! HELP-NEXT: -fopenmp   Parse OpenMP pragmas and generate parallel code.
@@ -103,6 +104,7 @@
 ! HELP-FC1-NEXT: -flogical-abbreviations Enable logical abbreviations
 ! HELP-FC1-NEXT: -fno-analyzed-objects-for-unparse
 ! HELP-FC1-NEXT:Do not use the analyzed objects when unparsing
+! HELP-FC1-NEXT: -fno-automatic Implies the SAVE attribute for non-automatic local objects in subprograms unless RECURSIVE
 ! HELP-FC1-NEXT: -fno-reformat  Dump the cooked character stream in -E mode
 ! HELP-FC1-NEXT: -fopenacc  Enable OpenACC
 ! HELP-FC1-NEXT: -fopenmp   Parse OpenMP pragmas and generate parallel code.
Index: flang/test/Driver/driver-help-hidden.f90
===
--- flang/test/Driver/driver-help-hidden.f90
+++ flang/test/Driver/driver-help-hidden.f90
@@ -39,6 +39,7 @@
 ! CHECK-NEXT:Specify where to find the compiled intrinsic modules
 ! CHECK-NEXT: -flarge-sizes  Use INTEGER(KIND=8) for the result type in size-related intrinsics
 ! CHECK-NEXT: -flogical-abbreviations Enable logical abbreviations
+! CHECK-NEXT: -fno-automatic Implies the SAVE attribute for non-automatic local objects in subprograms unless RECURSIVE
 ! CHECK-NEXT: -fno-color-diagnostics  Disable colors in diagnostics
 ! CHECK-NEXT: -fopenacc  Enable OpenACC
 ! CHECK-NEXT: -fopenmp   Parse OpenMP pragmas and generate parallel code.
Index: flang/lib/Semantics/tools.cpp
===
--- flang/lib/Semantics/tools.cpp
+++ flang/lib/Semantics/tools.cpp
@@ -626,49 +626,6 @@
 

[clang] 996ef89 - [flang] Add -fno-automatic, refine IsSaved()

2021-11-22 Thread Peter Klausler via cfe-commits

Author: Peter Klausler
Date: 2021-11-22T10:06:38-08:00
New Revision: 996ef895cd3d1313665a42fc8e20d1d4e1cf2a28

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

LOG: [flang] Add -fno-automatic, refine IsSaved()

This legacy option (available in other Fortran compilers with various
spellings) implies the SAVE attribute for local variables on subprograms
that are not explicitly RECURSIVE.  The SAVE attribute essentially implies
static rather than stack storage.  This was the default setting in Fortran
until surprisingly recently, so explicit SAVE statements & attributes
could be and often were omitted from older codes.  Note that initialized
objects already have an implied SAVE attribute, and objects in COMMON
effectively do too, as data overlays are extinct; and since objects that are
expected to survive from one invocation of a procedure to the next in static
storage should probably be explicit initialized in the first place, so the
use cases for this option are somewhat rare, and all of them could be
handled with explicit SAVE statements or attributes.

This implicit SAVE attribute must not apply to automatic (in the Fortran sense)
local objects, whose sizes cannot be known at compilation time.  To get the
semantics of IsSaved() right, the IsAutomatic() predicate was moved into
Evaluate/tools.cpp to allow for dynamic linking of the compiler.  The
redundant predicate IsAutomatic() was noticed, removed, and its uses replaced.

GNU Fortran's spelling of the option (-fno-automatic) was added to
the clang-based driver and used for basic sanity testing.

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

Added: 
flang/test/Semantics/save02.f90

Modified: 
clang/include/clang/Driver/Options.td
clang/lib/Driver/ToolChains/Flang.cpp
flang/include/flang/Common/Fortran-features.h
flang/include/flang/Evaluate/tools.h
flang/include/flang/Semantics/tools.h
flang/lib/Evaluate/tools.cpp
flang/lib/Frontend/CompilerInvocation.cpp
flang/lib/Semantics/resolve-names-utils.cpp
flang/lib/Semantics/runtime-type-info.cpp
flang/lib/Semantics/tools.cpp
flang/test/Driver/driver-help-hidden.f90
flang/test/Driver/driver-help.f90
flang/test/Semantics/entry01.f90
flang/test/Semantics/save01.f90

Removed: 




diff  --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index 9bde64cf49fd7..7730b7d1915e4 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -4519,7 +4519,7 @@ def frecord_marker_EQ : Joined<["-"], "frecord-marker=">, 
Group;
 defm aggressive_function_elimination : 
BooleanFFlag<"aggressive-function-elimination">, Group;
 defm align_commons : BooleanFFlag<"align-commons">, Group;
 defm all_intrinsics : BooleanFFlag<"all-intrinsics">, Group;
-defm automatic : BooleanFFlag<"automatic">, Group;
+def fautomatic : Flag<["-"], "fautomatic">; // -fno-automatic is significant
 defm backtrace : BooleanFFlag<"backtrace">, Group;
 defm bounds_check : BooleanFFlag<"bounds-check">, Group;
 defm check_array_temporaries : BooleanFFlag<"check-array-temporaries">, 
Group;
@@ -4616,6 +4616,9 @@ defm backslash : OptInFC1FFlag<"backslash", "Specify that 
backslash in string in
 defm xor_operator : OptInFC1FFlag<"xor-operator", "Enable .XOR. as a synonym 
of .NEQV.">;
 defm logical_abbreviations : OptInFC1FFlag<"logical-abbreviations", "Enable 
logical abbreviations">;
 defm implicit_none : OptInFC1FFlag<"implicit-none", "No implicit typing 
allowed unless overridden by IMPLICIT statements">;
+
+def fno_automatic : Flag<["-"], "fno-automatic">, Group,
+  HelpText<"Implies the SAVE attribute for non-automatic local objects in 
subprograms unless RECURSIVE">;
 }
 
 def J : JoinedOrSeparate<["-"], "J">,

diff  --git a/clang/lib/Driver/ToolChains/Flang.cpp 
b/clang/lib/Driver/ToolChains/Flang.cpp
index b82c5d7600df2..c169e3d457938 100644
--- a/clang/lib/Driver/ToolChains/Flang.cpp
+++ b/clang/lib/Driver/ToolChains/Flang.cpp
@@ -32,7 +32,8 @@ void Flang::AddFortranDialectOptions(const ArgList &Args,
 options::OPT_fxor_operator, options::OPT_fno_xor_operator,
 options::OPT_falternative_parameter_statement,
 options::OPT_fdefault_real_8, options::OPT_fdefault_integer_8,
-options::OPT_fdefault_double_8, options::OPT_flarge_sizes});
+options::OPT_fdefault_double_8, options::OPT_flarge_sizes,
+options::OPT_fno_automatic});
 }
 
 void Flang::AddPreprocessingOptions(const ArgList &Args,

diff  --git a/flang/include/flang/Common/Fortran-features.h 
b/flang/include/flang/Common/Fortran-features.h
index ddce794056320..f5fe2b5de475e 100644
--- a/flang/include/flang/Common/Fortran-features.h
+++ b/flang/inc

[PATCH] D80528: [clang-format][WIP] Run more stability FormatTests

2021-11-22 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay added subscribers: HazardyKnusperkeks, owenpan, curdeius.
MyDeveloperDay added a comment.

@HazardyKnusperkeks, @curdeius, @owenpan I feel we should try and get this 
committed, people tend to follow the adjacent style of the unit tests, and I 
sort of feel we keep having to ask people to use verifyFormat. maybe if we got 
rid of the unnecessary EXPECT_EQ we could reduce that, (I also like the way it 
messes up the code and checks its stable)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80528

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


[PATCH] D114379: [OMPIRBuilder] Add support for simd (loop) directive.

2021-11-22 Thread Thorsten via Phabricator via cfe-commits
tschuett added inline comments.



Comment at: llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp:2121
+static void addSIMDMetadata(BasicBlock *block,
+ArrayRef Properties) {
+  for (auto &I : *block) {

Properties is unused in the function?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D114379

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


[PATCH] D114320: [clang-format] Extend AllowShortBlocksOnASingleLine for else blocks

2021-11-22 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay added inline comments.



Comment at: clang/unittests/Format/FormatTest.cpp:5406
+   "{ }",
+   format("if(a){}else if(b){}else{}", Style), Style);
+  Style.BraceWrapping.AfterControlStatement = FormatStyle::BWACS_Never;

you can remove the "format(" here now..."

when its 2 arguments to `verifyFormat` its a kind of 
`verifyFormat(after,before,Style)`

alternatively you can use:

`verifyFormat(after,Style)`

it will deliberately `messUp` the the text and ensure it resets itself back to 
the desired after



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D114320

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


[PATCH] D114379: [OMPIRBuilder] Add support for simd (loop) directive.

2021-11-22 Thread Thorsten via Phabricator via cfe-commits
tschuett added inline comments.



Comment at: llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h:520
 
+  /// Add metadata to simd-ise a loop.
+  ///

I believe LLVM uses American English.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D114379

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


[PATCH] D114379: [OMPIRBuilder] Add support for simd (loop) directive.

2021-11-22 Thread Arnamoy B via Phabricator via cfe-commits
arnamoy10 created this revision.
arnamoy10 added reviewers: kiranchandramohan, peixin, bryanpkc, Meinersbur.
Herald added a subscriber: hiraditya.
arnamoy10 requested review of this revision.
Herald added a reviewer: jdoerfert.
Herald added subscribers: llvm-commits, cfe-commits, sstefan1.
Herald added projects: clang, LLVM.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D114379

Files:
  clang/lib/CodeGen/CGStmtOpenMP.cpp
  clang/test/OpenMP/simd_codegen_irbuilder.cpp
  llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h
  llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp

Index: llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
===
--- llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
+++ llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
@@ -2116,6 +2116,19 @@
   Latch->getTerminator()->setMetadata(LLVMContext::MD_loop, LoopID);
 }
 
+/// Attach metadata access.group to the load and store instructions of \p block
+static void addSIMDMetadata(BasicBlock *block,
+ArrayRef Properties) {
+  for (auto &I : *block) {
+if (isa(&I) || isa(&I)) {
+  Instruction *instr = dyn_cast(&I);
+  LLVMContext &C = instr->getContext();
+  MDNode *N = MDNode::get(C, MDString::get(C, ""));
+  instr->setMetadata("llvm.access.group", N);
+}
+  }
+}
+
 void OpenMPIRBuilder::unrollLoopFull(DebugLoc, CanonicalLoopInfo *Loop) {
   LLVMContext &Ctx = Builder.getContext();
   addLoopMetadata(
@@ -2131,6 +2144,30 @@
 });
 }
 
+void OpenMPIRBuilder::createSIMDLoop(DebugLoc, CanonicalLoopInfo *Loop) {
+  LLVMContext &Ctx = Builder.getContext();
+  addLoopMetadata(
+  Loop,
+  {MDNode::get(Ctx, MDString::get(Ctx, "llvm.loop.parallel_accesses")),
+   MDNode::get(Ctx, MDString::get(Ctx, "llvm.loop.vectorize.enable"))});
+  BasicBlock *header = Loop->getHeader();
+  BasicBlock *cond = Loop->getCond();
+  BasicBlock *body = Loop->getBody();
+
+  addSIMDMetadata(header,
+  {
+  MDNode::get(Ctx, MDString::get(Ctx, "llvm.access.group")),
+  });
+  addSIMDMetadata(cond,
+  {
+  MDNode::get(Ctx, MDString::get(Ctx, "llvm.access.group")),
+  });
+  addSIMDMetadata(body,
+  {
+  MDNode::get(Ctx, MDString::get(Ctx, "llvm.access.group")),
+  });
+}
+
 /// Create the TargetMachine object to query the backend for optimization
 /// preferences.
 ///
Index: llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h
===
--- llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h
+++ llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h
@@ -517,6 +517,12 @@
   void unrollLoopPartial(DebugLoc DL, CanonicalLoopInfo *Loop, int32_t Factor,
  CanonicalLoopInfo **UnrolledCLI);
 
+  /// Add metadata to simd-ise a loop.
+  ///
+  /// \param DL   Debug location for instructions added by unrolling.
+  /// \param Loop The loop to simd-ise.
+  void createSIMDLoop(DebugLoc DL, CanonicalLoopInfo *Loop);
+
   /// Generator for '#omp flush'
   ///
   /// \param Loc The location where the flush directive was encountered
Index: clang/test/OpenMP/simd_codegen_irbuilder.cpp
===
--- /dev/null
+++ clang/test/OpenMP/simd_codegen_irbuilder.cpp
@@ -0,0 +1,43 @@
+// RUN: %clang_cc1 -fopenmp-enable-irbuilder -verify -fopenmp -fopenmp-version=45 -x c++ -triple x86_64-unknown-unknown -emit-llvm %s -o - | FileCheck %s
+// expected-no-diagnostics
+
+struct S {
+  int a, b;
+};
+
+void simple(float *a, float *b) {
+  S s, *p;
+  int j = 0;
+#pragma omp simd
+  for (int i = 3; i < 32; i += 5) {
+// llvm.access.group test
+// CHECK: omp_loop.body:; preds = %omp_loop.cond
+// CHECK-NEXT: call void @__captured_stmt.1(i32* %i, i32 %omp_loop.iv, %struct.anon.0* %agg.captured1)
+// CHECK-NEXT: %3 = load float*, float** %b.addr, align 8, !llvm.access.group !3
+// CHECK-NEXT: %4 = load i32, i32* %i, align 4, !llvm.access.group !3
+// CHECK-NEXT: %idxprom = sext i32 %4 to i64
+// CHECK-NEXT: %arrayidx = getelementptr inbounds float, float* %3, i64 %idxprom
+// CHECK-NEXT: %5 = load float, float* %arrayidx, align 4, !llvm.access.group !3
+// CHECK-NEXT: %a2 = getelementptr inbounds %struct.S, %struct.S* %s, i32 0, i32 0
+// CHECK-NEXT: %6 = load i32, i32* %a2, align 4, !llvm.access.group !3
+// CHECK-NEXT: %conv = sitofp i32 %6 to float
+// CHECK-NEXT: %add = fadd float %5, %conv
+// CHECK-NEXT: %7 = load %struct.S*, %struct.S** %p, align 8, !llvm.access.group !3
+// CHECK-NEXT: %a3 = getelementptr inbounds %struct.S, %struct.S* %7, i32 0, i32 0
+// CHECK-NEXT: %8 = load i32, i32* %a3, align 4, !llvm.access.group !3
+// CHECK-NEXT: %conv4 = sitofp i32 %8 to float
+// CHECK-NEXT: %add5 = fadd float

[PATCH] D114088: [PowerPC] Add BCD add/sub/cmp builtins

2021-11-22 Thread Nemanja Ivanovic via Phabricator via cfe-commits
nemanjai added inline comments.



Comment at: clang/lib/Headers/altivec.h:19050
+}
+
+static __inline__ long __bcdcmpeq(vector unsigned char __a,

NeHuang wrote:
> Do we need to add a case for "__CR6_SO_REV"? It is defined in line 25 but not 
> used.
I added it for completeness, but there is currently no need to use it for any 
builtin.



Comment at: llvm/lib/Target/PowerPC/PPCISelDAGToDAG.cpp:5096
+SubReg = PPC::sub_un;
+ShiftVal = 0;
+break;

NeHuang wrote:
> can we remove this as default is 0?
Sounds good.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D114088

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


[PATCH] D114326: Update the list of CUDA versions up to 11.5

2021-11-22 Thread Mojca Miklavec via Phabricator via cfe-commits
mojca added inline comments.



Comment at: clang/lib/Driver/ToolChains/Cuda.cpp:131
+  std::initializer_list Versions = {
+  "11.5", "11.4", "11.3", "11.2", "11.1", "11.0", "10.2", "10.1",
+  "10.0", "9.2",  "9.1",  "9.0",  "8.0",  "7.5",  "7.0"};

kadircet wrote:
> looks like the list is getting big and hard to maintain. considering that 
> this is done only once per compiler invocation (and we check for existence of 
> directories down in the loop anyway). what about throwing in an extra 
> directory listing to base-directories mentioned down below and populate 
> `Candidates` while preserving the newest-version-first order?
I totally agree with the sentiment, and that was my initial thought as well, 
but with zero experience I was too scared to make any more significant changes.

I can try to come up with a new patch (that doesn't need further maintenance 
whenever a new CUDA version gets released) if that's what you are suggesting. I 
would nevertheless merge this one, and prepare a new more advanced patch 
separately, but that's finally your call.

What's your suggestion about D.SysRoot + "Program Files/..."? At the time when 
this function gets called it looks like D.SysRoot is empty (or at least my 
debugger says so) and in my case it resolves to D: while the CUDA support is 
installed under C:.

Is there any special LLVM-specific/preferrable way to iterate through 
directories?

(What I also miss a bit in the whole process in an option to simply say "I want 
CUDA 11.1" without the need to explicitly spell out the full path.)

If you provide me give some general guidelines, I'll prepare another, hopefully 
more future-proof patch.

(Side note: I'm not sure if I'm calling clang-format correctly, but if I call 
it, it keeps reformatting the rest of this file.)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D114326

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


[Diffusion] rGc93f93b2e3f2: Revert "Revert "Recommit "Revert "[CVP] processSwitch: Remove default case when…

2021-11-22 Thread Alexander Kornienko via Phabricator via cfe-commits
alexfh added a comment.

In rGc93f93b2e3f28997f794265089fb8138dd5b5f13#1039669 
, 
@bgraur wrote:

> Early heads up that this revision causes a large regression in compilation 
> time for some of our internal source files: we are seeing an almost 20x 
> increase in compilation times for some files (from 42s to 728s).
>
> I'm working on a reproducer which I'm going to upload when ready.

We're still reducing it, but the test case is a different one as the one I 
posted in https://reviews.llvm.org/D106056#3023708. Similar to 
https://reviews.llvm.org/D106056, adding `-mllvm -disable-early-taildup=true` 
reduces the compilation time to normal.

`perf record --call-graph lbr clang -xc++ -std=gnu++17 -c -O3 test.ii` results 
in the profile below:

  -   99.28% 0.00%  clangclang   [.] 
llvm::FPPassManager::runOnFunction  
◆
 - 99.27% llvm::FPPassManager::runOnFunction

 ▒
- 99.24% llvm::MachineFunctionPass::runOnFunction   

 ▒
   - 97.51% (anonymous 
namespace)::MachineBlockPlacement::runOnMachineFunction 

  ▒
  - 97.51% (anonymous 
namespace)::MachineBlockPlacement::buildCFGChains   

   ▒
 - 97.45% (anonymous 
namespace)::MachineBlockPlacement::buildChain   

▒
- 96.82% (anonymous 
namespace)::MachineBlockPlacement::canTailDuplicateUnplacedPreds

 ▒
 94.66% hasSameSuccessors   

 ▒

Hope this helps finding out the cause of the problem.

It would be helpful, if you could revert the commit while you're investigating.


BRANCHES
  fix_asan, main

Users:
  junparser (Author)

https://reviews.llvm.org/rGc93f93b2e3f2

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


[Diffusion] rGc93f93b2e3f2: Revert "Revert "Recommit "Revert "[CVP] processSwitch: Remove default case when…

2021-11-22 Thread Alexander Kornienko via Phabricator via cfe-commits
alexfh added a subscriber: junparser.

BRANCHES
  fix_asan, main

Users:
  junparser (Author)

https://reviews.llvm.org/rGc93f93b2e3f2

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


[PATCH] D77776: [Driver] Default to libc++ on FreeBSD

2021-11-22 Thread Dimitry Andric via Phabricator via cfe-commits
dim accepted this revision.
dim added a comment.
This revision is now accepted and ready to land.

LGTM


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

https://reviews.llvm.org/D6

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


[PATCH] D77776: [Driver] Default to libc++ on FreeBSD

2021-11-22 Thread Ed Maste via Phabricator via cfe-commits
emaste added inline comments.



Comment at: clang/test/Driver/freebsd.cpp:13-14
+// RUN:   | FileCheck --check-prefix=CHECK-PG-DEFAULT %s
 // RUN: %clangxx %s -### -pg -o %t.o -target amd64-unknown-freebsd14.0 
-stdlib=platform 2>&1 \
 // RUN:   | FileCheck --check-prefix=CHECK-PG-FOURTEEN %s
 // RUN: %clangxx %s -### -pg -o %t.o -target amd64-unknown-freebsd10.0 
-stdlib=platform 2>&1 \

In main this is `amd64-unknown-freebsd14.0`, I have a fix for that staged 
before this diff

```
commit d99411fe6e0375041b80ba4f397a139218a3754d
Author: Ed Maste 
Date:   Mon Nov 22 11:26:55 2021 -0500

[Driver] correct typo in FreeBSD 14 test

The test specified amd64-unknown-freebsd40.0 rather than 14.0.  Since
40 is greater than 14 the test (for behaviour new in FreeBSD 14) worked
despite the typo.

Fixes:  699d47472c3f

diff --git a/clang/test/Driver/freebsd.cpp b/clang/test/Driver/freebsd.cpp
index fde888902e12..d199f6e2367a 100644
--- a/clang/test/Driver/freebsd.cpp
+++ b/clang/test/Driver/freebsd.cpp
@@ -5,7 +5,7 @@
 // CHECK-TEN: "-lc++" "-lm"
 // CHECK-NINE: "-lstdc++" "-lm"
 
-// RUN: %clangxx %s -### -pg -o %t.o -target amd64-unknown-freebsd40.0 
-stdlib=platform 2>&1 \
+// RUN: %clangxx %s -### -pg -o %t.o -target amd64-unknown-freebsd14.0 
-stdlib=platform 2>&1 \
 // RUN:   | FileCheck --check-prefix=CHECK-PG-FOURTEEN %s
 // RUN: %clangxx %s -### -pg -o %t.o -target amd64-unknown-freebsd10.0 
-stdlib=platform 2>&1 \
 // RUN:   | FileCheck --check-prefix=CHECK-PG-TEN %s

```


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

https://reviews.llvm.org/D6

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


[PATCH] D77776: [Driver] Default to libc++ on FreeBSD

2021-11-22 Thread Ed Maste via Phabricator via cfe-commits
emaste updated this revision to Diff 388931.
emaste added a comment.

rebase tests


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

https://reviews.llvm.org/D6

Files:
  clang/lib/Driver/ToolChains/FreeBSD.cpp
  clang/test/Driver/freebsd.cpp


Index: clang/test/Driver/freebsd.cpp
===
--- clang/test/Driver/freebsd.cpp
+++ clang/test/Driver/freebsd.cpp
@@ -1,16 +1,22 @@
+// RUN: %clangxx %s -### -o %t.o -target amd64-unknown-freebsd 
-stdlib=platform 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-DEFAULT %s
 // RUN: %clangxx %s -### -o %t.o -target amd64-unknown-freebsd10.0 
-stdlib=platform 2>&1 \
 // RUN:   | FileCheck --check-prefix=CHECK-TEN %s
 // RUN: %clangxx %s -### -o %t.o -target amd64-unknown-freebsd9.2 
-stdlib=platform 2>&1 \
 // RUN:   | FileCheck --check-prefix=CHECK-NINE %s
+// CHECK-DEFAULT: "-lc++" "-lm"
 // CHECK-TEN: "-lc++" "-lm"
 // CHECK-NINE: "-lstdc++" "-lm"
 
+// RUN: %clangxx %s -### -pg -o %t.o -target amd64-unknown-freebsd 
-stdlib=platform 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-PG-DEFAULT %s
 // RUN: %clangxx %s -### -pg -o %t.o -target amd64-unknown-freebsd14.0 
-stdlib=platform 2>&1 \
 // RUN:   | FileCheck --check-prefix=CHECK-PG-FOURTEEN %s
 // RUN: %clangxx %s -### -pg -o %t.o -target amd64-unknown-freebsd10.0 
-stdlib=platform 2>&1 \
 // RUN:   | FileCheck --check-prefix=CHECK-PG-TEN %s
 // RUN: %clangxx %s -### -pg -o %t.o -target amd64-unknown-freebsd9.2 
-stdlib=platform 2>&1 \
 // RUN:   | FileCheck --check-prefix=CHECK-PG-NINE %s
+// CHECK-PG-DEFAULT: "-lc++_p" "-lm_p"
 // CHECK-PG-FOURTEEN: "-lc++" "-lm"
 // CHECK-PG-TEN: "-lc++_p" "-lm_p"
 // CHECK-PG-NINE: "-lstdc++_p" "-lm_p"
Index: clang/lib/Driver/ToolChains/FreeBSD.cpp
===
--- clang/lib/Driver/ToolChains/FreeBSD.cpp
+++ clang/lib/Driver/ToolChains/FreeBSD.cpp
@@ -391,7 +391,8 @@
 }
 
 ToolChain::CXXStdlibType FreeBSD::GetDefaultCXXStdlibType() const {
-  if (getTriple().getOSMajorVersion() >= 10)
+  unsigned Major = getTriple().getOSMajorVersion();
+  if (Major >= 10 || Major == 0)
 return ToolChain::CST_Libcxx;
   return ToolChain::CST_Libstdcxx;
 }


Index: clang/test/Driver/freebsd.cpp
===
--- clang/test/Driver/freebsd.cpp
+++ clang/test/Driver/freebsd.cpp
@@ -1,16 +1,22 @@
+// RUN: %clangxx %s -### -o %t.o -target amd64-unknown-freebsd -stdlib=platform 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-DEFAULT %s
 // RUN: %clangxx %s -### -o %t.o -target amd64-unknown-freebsd10.0 -stdlib=platform 2>&1 \
 // RUN:   | FileCheck --check-prefix=CHECK-TEN %s
 // RUN: %clangxx %s -### -o %t.o -target amd64-unknown-freebsd9.2 -stdlib=platform 2>&1 \
 // RUN:   | FileCheck --check-prefix=CHECK-NINE %s
+// CHECK-DEFAULT: "-lc++" "-lm"
 // CHECK-TEN: "-lc++" "-lm"
 // CHECK-NINE: "-lstdc++" "-lm"
 
+// RUN: %clangxx %s -### -pg -o %t.o -target amd64-unknown-freebsd -stdlib=platform 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-PG-DEFAULT %s
 // RUN: %clangxx %s -### -pg -o %t.o -target amd64-unknown-freebsd14.0 -stdlib=platform 2>&1 \
 // RUN:   | FileCheck --check-prefix=CHECK-PG-FOURTEEN %s
 // RUN: %clangxx %s -### -pg -o %t.o -target amd64-unknown-freebsd10.0 -stdlib=platform 2>&1 \
 // RUN:   | FileCheck --check-prefix=CHECK-PG-TEN %s
 // RUN: %clangxx %s -### -pg -o %t.o -target amd64-unknown-freebsd9.2 -stdlib=platform 2>&1 \
 // RUN:   | FileCheck --check-prefix=CHECK-PG-NINE %s
+// CHECK-PG-DEFAULT: "-lc++_p" "-lm_p"
 // CHECK-PG-FOURTEEN: "-lc++" "-lm"
 // CHECK-PG-TEN: "-lc++_p" "-lm_p"
 // CHECK-PG-NINE: "-lstdc++_p" "-lm_p"
Index: clang/lib/Driver/ToolChains/FreeBSD.cpp
===
--- clang/lib/Driver/ToolChains/FreeBSD.cpp
+++ clang/lib/Driver/ToolChains/FreeBSD.cpp
@@ -391,7 +391,8 @@
 }
 
 ToolChain::CXXStdlibType FreeBSD::GetDefaultCXXStdlibType() const {
-  if (getTriple().getOSMajorVersion() >= 10)
+  unsigned Major = getTriple().getOSMajorVersion();
+  if (Major >= 10 || Major == 0)
 return ToolChain::CST_Libcxx;
   return ToolChain::CST_Libstdcxx;
 }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D113754: [Analyzer][Core] Simplify IntSym in SValBuilder

2021-11-22 Thread Gabor Marton via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGffc32efd1cd6: [Analyzer][Core] Simplify IntSym in 
SValBuilder (authored by martong).

Changed prior to commit:
  https://reviews.llvm.org/D113754?vs=386800&id=388927#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D113754

Files:
  clang/lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp
  clang/test/Analysis/svalbuilder-simplify-intsym.cpp


Index: clang/test/Analysis/svalbuilder-simplify-intsym.cpp
===
--- /dev/null
+++ clang/test/Analysis/svalbuilder-simplify-intsym.cpp
@@ -0,0 +1,20 @@
+// RUN: %clang_analyze_cc1 %s \
+// RUN:   -analyzer-checker=core \
+// RUN:   -analyzer-checker=debug.ExprInspection \
+// RUN:   -analyzer-config eagerly-assume=false \
+// RUN:   -verify
+
+// Here we test whether the SValBuilder is capable to simplify existing
+// IntSym expressions based on a newly added constraint on the sub-expression.
+
+void clang_analyzer_eval(bool);
+
+void test_SValBuilder_simplifies_IntSym(int x, int y) {
+  // Most IntSym BinOps are transformed to SymInt in SimpleSValBuilder.
+  // Division is one exception.
+  x = 77 / y;
+  if (y != 1)
+return;
+  clang_analyzer_eval(x == 77); // expected-warning{{TRUE}}
+  (void)(x * y);
+}
Index: clang/lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp
===
--- clang/lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp
+++ clang/lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp
@@ -1183,6 +1183,19 @@
   S, SVB.evalBinOp(State, S->getOpcode(), LHS, RHS, S->getType()));
 }
 
+SVal VisitIntSymExpr(const IntSymExpr *S) {
+  auto I = Cached.find(S);
+  if (I != Cached.end())
+return I->second;
+
+  SVal RHS = Visit(S->getRHS());
+  if (isUnchanged(S->getRHS(), RHS))
+return skip(S);
+  SVal LHS = SVB.makeIntVal(S->getLHS());
+  return cache(
+  S, SVB.evalBinOp(State, S->getOpcode(), LHS, RHS, S->getType()));
+}
+
 SVal VisitSymSymExpr(const SymSymExpr *S) {
   auto I = Cached.find(S);
   if (I != Cached.end())


Index: clang/test/Analysis/svalbuilder-simplify-intsym.cpp
===
--- /dev/null
+++ clang/test/Analysis/svalbuilder-simplify-intsym.cpp
@@ -0,0 +1,20 @@
+// RUN: %clang_analyze_cc1 %s \
+// RUN:   -analyzer-checker=core \
+// RUN:   -analyzer-checker=debug.ExprInspection \
+// RUN:   -analyzer-config eagerly-assume=false \
+// RUN:   -verify
+
+// Here we test whether the SValBuilder is capable to simplify existing
+// IntSym expressions based on a newly added constraint on the sub-expression.
+
+void clang_analyzer_eval(bool);
+
+void test_SValBuilder_simplifies_IntSym(int x, int y) {
+  // Most IntSym BinOps are transformed to SymInt in SimpleSValBuilder.
+  // Division is one exception.
+  x = 77 / y;
+  if (y != 1)
+return;
+  clang_analyzer_eval(x == 77); // expected-warning{{TRUE}}
+  (void)(x * y);
+}
Index: clang/lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp
===
--- clang/lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp
+++ clang/lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp
@@ -1183,6 +1183,19 @@
   S, SVB.evalBinOp(State, S->getOpcode(), LHS, RHS, S->getType()));
 }
 
+SVal VisitIntSymExpr(const IntSymExpr *S) {
+  auto I = Cached.find(S);
+  if (I != Cached.end())
+return I->second;
+
+  SVal RHS = Visit(S->getRHS());
+  if (isUnchanged(S->getRHS(), RHS))
+return skip(S);
+  SVal LHS = SVB.makeIntVal(S->getLHS());
+  return cache(
+  S, SVB.evalBinOp(State, S->getOpcode(), LHS, RHS, S->getType()));
+}
+
 SVal VisitSymSymExpr(const SymSymExpr *S) {
   auto I = Cached.find(S);
   if (I != Cached.end())
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] ffc32ef - [Analyzer][Core] Simplify IntSym in SValBuilder

2021-11-22 Thread Gabor Marton via cfe-commits

Author: Gabor Marton
Date: 2021-11-22T17:33:43+01:00
New Revision: ffc32efd1cd6a34659e2c559e9ba6ee923b1637a

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

LOG: [Analyzer][Core] Simplify IntSym in SValBuilder

Make the SimpleSValBuilder capable to simplify existing IntSym
expressions based on a newly added constraint on the sub-expression.

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

Added: 
clang/test/Analysis/svalbuilder-simplify-intsym.cpp

Modified: 
clang/lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp

Removed: 




diff  --git a/clang/lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp 
b/clang/lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp
index 681a1f64eadc..54a2386fc2ff 100644
--- a/clang/lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp
+++ b/clang/lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp
@@ -1183,6 +1183,19 @@ SVal SimpleSValBuilder::simplifySVal(ProgramStateRef 
State, SVal V) {
   S, SVB.evalBinOp(State, S->getOpcode(), LHS, RHS, S->getType()));
 }
 
+SVal VisitIntSymExpr(const IntSymExpr *S) {
+  auto I = Cached.find(S);
+  if (I != Cached.end())
+return I->second;
+
+  SVal RHS = Visit(S->getRHS());
+  if (isUnchanged(S->getRHS(), RHS))
+return skip(S);
+  SVal LHS = SVB.makeIntVal(S->getLHS());
+  return cache(
+  S, SVB.evalBinOp(State, S->getOpcode(), LHS, RHS, S->getType()));
+}
+
 SVal VisitSymSymExpr(const SymSymExpr *S) {
   auto I = Cached.find(S);
   if (I != Cached.end())

diff  --git a/clang/test/Analysis/svalbuilder-simplify-intsym.cpp 
b/clang/test/Analysis/svalbuilder-simplify-intsym.cpp
new file mode 100644
index ..8a58b797c86e
--- /dev/null
+++ b/clang/test/Analysis/svalbuilder-simplify-intsym.cpp
@@ -0,0 +1,20 @@
+// RUN: %clang_analyze_cc1 %s \
+// RUN:   -analyzer-checker=core \
+// RUN:   -analyzer-checker=debug.ExprInspection \
+// RUN:   -analyzer-config eagerly-assume=false \
+// RUN:   -verify
+
+// Here we test whether the SValBuilder is capable to simplify existing
+// IntSym expressions based on a newly added constraint on the sub-expression.
+
+void clang_analyzer_eval(bool);
+
+void test_SValBuilder_simplifies_IntSym(int x, int y) {
+  // Most IntSym BinOps are transformed to SymInt in SimpleSValBuilder.
+  // Division is one exception.
+  x = 77 / y;
+  if (y != 1)
+return;
+  clang_analyzer_eval(x == 77); // expected-warning{{TRUE}}
+  (void)(x * y);
+}



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


[clang] bf20a3b - Use std::string::substr (NFC)

2021-11-22 Thread Kazu Hirata via cfe-commits

Author: Kazu Hirata
Date: 2021-11-22T08:21:09-08:00
New Revision: bf20a3b9b94a5b6fc97fdba4546391c30ad26a22

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

LOG: Use std::string::substr (NFC)

Added: 


Modified: 
clang/lib/Frontend/Rewrite/RewriteModernObjC.cpp
clang/lib/Frontend/Rewrite/RewriteObjC.cpp
llvm/utils/TableGen/AsmWriterInst.cpp
llvm/utils/TableGen/CodeGenTarget.cpp

Removed: 




diff  --git a/clang/lib/Frontend/Rewrite/RewriteModernObjC.cpp 
b/clang/lib/Frontend/Rewrite/RewriteModernObjC.cpp
index 626ec4d71ccdd..b4487f0047155 100644
--- a/clang/lib/Frontend/Rewrite/RewriteModernObjC.cpp
+++ b/clang/lib/Frontend/Rewrite/RewriteModernObjC.cpp
@@ -633,7 +633,7 @@ static bool IsHeaderFile(const std::string &Filename) {
 return false;
   }
 
-  std::string Ext = std::string(Filename.begin()+DotPos+1, Filename.end());
+  std::string Ext = Filename.substr(DotPos + 1);
   // C header: .h
   // C++ header: .hh or .H;
   return Ext == "h" || Ext == "hh" || Ext == "H";

diff  --git a/clang/lib/Frontend/Rewrite/RewriteObjC.cpp 
b/clang/lib/Frontend/Rewrite/RewriteObjC.cpp
index 0750d36b02ac2..b2ecb42c43dd2 100644
--- a/clang/lib/Frontend/Rewrite/RewriteObjC.cpp
+++ b/clang/lib/Frontend/Rewrite/RewriteObjC.cpp
@@ -569,7 +569,7 @@ static bool IsHeaderFile(const std::string &Filename) {
 return false;
   }
 
-  std::string Ext = std::string(Filename.begin()+DotPos+1, Filename.end());
+  std::string Ext = Filename.substr(DotPos + 1);
   // C header: .h
   // C++ header: .hh or .H;
   return Ext == "h" || Ext == "hh" || Ext == "H";

diff  --git a/llvm/utils/TableGen/AsmWriterInst.cpp 
b/llvm/utils/TableGen/AsmWriterInst.cpp
index cf24f79334cad..887abbac9d3b4 100644
--- a/llvm/utils/TableGen/AsmWriterInst.cpp
+++ b/llvm/utils/TableGen/AsmWriterInst.cpp
@@ -147,8 +147,7 @@ AsmWriterInst::AsmWriterInst(const CodeGenInstruction &CGI, 
unsigned CGIIndex,
   std::string::size_type ModifierStart = VarEnd;
   while (VarEnd < AsmString.size() && isIdentChar(AsmString[VarEnd]))
 ++VarEnd;
-  Modifier = std::string(AsmString.begin()+ModifierStart,
- AsmString.begin()+VarEnd);
+  Modifier = AsmString.substr(ModifierStart, VarEnd - ModifierStart);
   if (Modifier.empty())
 PrintFatalError(CGI.TheDef->getLoc(),
 "Bad operand modifier name in '" +

diff  --git a/llvm/utils/TableGen/CodeGenTarget.cpp 
b/llvm/utils/TableGen/CodeGenTarget.cpp
index 137f99078faf6..d3beaf61989eb 100644
--- a/llvm/utils/TableGen/CodeGenTarget.cpp
+++ b/llvm/utils/TableGen/CodeGenTarget.cpp
@@ -676,12 +676,11 @@ CodeGenIntrinsic::CodeGenIntrinsic(Record *R,
   isSpeculatable = false;
   hasSideEffects = false;
 
-  if (DefName.size() <= 4 ||
-  std::string(DefName.begin(), DefName.begin() + 4) != "int_")
+  if (DefName.size() <= 4 || DefName.substr(0, 4) != "int_")
 PrintFatalError(DefLoc,
 "Intrinsic '" + DefName + "' does not start with 'int_'!");
 
-  EnumName = std::string(DefName.begin()+4, DefName.end());
+  EnumName = DefName.substr(4);
 
   if (R->getValue("GCCBuiltinName"))  // Ignore a missing GCCBuiltinName field.
 GCCBuiltinName = std::string(R->getValueAsString("GCCBuiltinName"));
@@ -699,8 +698,7 @@ CodeGenIntrinsic::CodeGenIntrinsic(Record *R,
   Name += (EnumName[i] == '_') ? '.' : EnumName[i];
   } else {
 // Verify it starts with "llvm.".
-if (Name.size() <= 5 ||
-std::string(Name.begin(), Name.begin() + 5) != "llvm.")
+if (Name.size() <= 5 || Name.substr(0, 5) != "llvm.")
   PrintFatalError(DefLoc, "Intrinsic '" + DefName +
   "'s name does not start with 'llvm.'!");
   }
@@ -709,8 +707,7 @@ CodeGenIntrinsic::CodeGenIntrinsic(Record *R,
   // "llvm..".
   if (!TargetPrefix.empty()) {
 if (Name.size() < 6+TargetPrefix.size() ||
-std::string(Name.begin() + 5, Name.begin() + 6 + TargetPrefix.size())
-!= (TargetPrefix + "."))
+Name.substr(5, 1 + TargetPrefix.size()) != (TargetPrefix + "."))
   PrintFatalError(DefLoc, "Intrinsic '" + DefName +
   "' does not start with 'llvm." +
   TargetPrefix + ".'!");



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


[PATCH] D114320: [clang-format] Extend AllowShortBlocksOnASingleLine for else blocks

2021-11-22 Thread Jesses Gott via Phabricator via cfe-commits
jessesna updated this revision to Diff 388924.
jessesna added a comment.

use verifyFormat instead of EXPECT_EQ (as this does some extra stuff to ensure 
its stable)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D114320

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


Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -5394,6 +5394,27 @@
   EXPECT_EQ("void f() { }", format("void f() {}", Style));
   Style.AllowShortBlocksOnASingleLine = FormatStyle::SBS_Empty;
   EXPECT_EQ("while (true) { }", format("while (true) {}", Style));
+  Style.BreakBeforeBraces = FormatStyle::BS_Custom;
+  Style.BraceWrapping.BeforeElse = false;
+  Style.BraceWrapping.AfterControlStatement = FormatStyle::BWACS_Always;
+  verifyFormat("if (a)\n"
+   "{\n"
+   "} else if (b)\n"
+   "{\n"
+   "} else\n"
+   "{ }",
+   format("if(a){}else if(b){}else{}", Style), Style);
+  Style.BraceWrapping.AfterControlStatement = FormatStyle::BWACS_Never;
+  verifyFormat("if (a) {\n"
+   "} else if (b) {\n"
+   "} else {\n"
+   "}",
+   format("if(a){}else if(b){}else{}", Style), Style);
+  Style.BraceWrapping.BeforeElse = true;
+  verifyFormat("if (a) { }\n"
+   "else if (b) { }\n"
+   "else { }",
+   format("if(a){}else if(b){}else{}", Style), Style);
 }
 
 TEST_F(FormatTest, FormatBeginBlockEndMacros) {
Index: clang/lib/Format/UnwrappedLineFormatter.cpp
===
--- clang/lib/Format/UnwrappedLineFormatter.cpp
+++ clang/lib/Format/UnwrappedLineFormatter.cpp
@@ -320,9 +320,9 @@
 }
 // Try to merge a control statement block with left brace wrapped
 if (I[1]->First->is(tok::l_brace) &&
-(TheLine->First->isOneOf(tok::kw_if, tok::kw_while, tok::kw_for,
- tok::kw_switch, tok::kw_try, tok::kw_do,
- TT_ForEachMacro) ||
+(TheLine->First->isOneOf(tok::kw_if, tok::kw_else, tok::kw_while,
+ tok::kw_for, tok::kw_switch, tok::kw_try,
+ tok::kw_do, TT_ForEachMacro) ||
  (TheLine->First->is(tok::r_brace) && TheLine->First->Next &&
   TheLine->First->Next->isOneOf(tok::kw_else, tok::kw_catch))) &&
 Style.BraceWrapping.AfterControlStatement ==
@@ -335,7 +335,7 @@
  ? 1
  : 0;
 } else if (I[1]->First->is(tok::l_brace) &&
-   TheLine->First->isOneOf(tok::kw_if, tok::kw_while,
+   TheLine->First->isOneOf(tok::kw_if, tok::kw_else, tok::kw_while,
tok::kw_for)) {
   return (Style.BraceWrapping.AfterControlStatement ==
   FormatStyle::BWACS_Always)
@@ -569,7 +569,7 @@
 
 // Check that the current line allows merging. This depends on whether we
 // are in a control flow statements as well as several style flags.
-if (Line.First->isOneOf(tok::kw_else, tok::kw_case) ||
+if (Line.First->is(tok::kw_case) ||
 (Line.First->Next && Line.First->Next->is(tok::kw_else)))
   return 0;
 // default: in switch statement
@@ -578,20 +578,21 @@
   if (Tok && Tok->is(tok::colon))
 return 0;
 }
-if (Line.First->isOneOf(tok::kw_if, tok::kw_while, tok::kw_do, tok::kw_try,
-tok::kw___try, tok::kw_catch, tok::kw___finally,
-tok::kw_for, tok::r_brace, Keywords.kw___except)) {
+if (Line.First->isOneOf(tok::kw_if, tok::kw_else, tok::kw_while, 
tok::kw_do,
+tok::kw_try, tok::kw___try, tok::kw_catch,
+tok::kw___finally, tok::kw_for, tok::r_brace,
+Keywords.kw___except)) {
   if (Style.AllowShortBlocksOnASingleLine == FormatStyle::SBS_Never)
 return 0;
   // Don't merge when we can't except the case when
   // the control statement block is empty
   if (!Style.AllowShortIfStatementsOnASingleLine &&
-  Line.startsWith(tok::kw_if) &&
+  Line.First->isOneOf(tok::kw_if, tok::kw_else) &&
   !Style.BraceWrapping.AfterControlStatement &&
   !I[1]->First->is(tok::r_brace))
 return 0;
   if (!Style.AllowShortIfStatementsOnASingleLine &&
-  Line.startsWith(tok::kw_if) &&
+  Line.First->isOneOf(tok::kw_if, tok::kw_else) &&
   Style.BraceWrapping.AfterControlStatement ==
   FormatStyle::BWACS_Always &&
   I + 2 != E && !I[2]->First->is(tok::r_brace))


Index: clang/unittests/Format/FormatTest.cpp
===

[PATCH] D114151: [clang-format] [C++20] [Module] clang-format couldn't recognize partitions

2021-11-22 Thread Owen Pan via Phabricator via cfe-commits
owenpan added inline comments.



Comment at: clang/lib/Format/UnwrappedLineParser.cpp:1055-1077
+  while (FormatTok) {
+if (FormatTok->is(tok::colon)) {
+  FormatTok->setType(TT_ModulePartitionColon);
+}
+// Handle import  as we would an include statement
+else if (FormatTok->is(tok::less)) {
+  nextToken();

Possible infinite loops if the `import` statement is the last line and not 
terminated by a `;`?


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

https://reviews.llvm.org/D114151

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


[PATCH] D113490: [NFC] Let Microsoft mangler accept GlobalDecl

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

lgtm




Comment at: clang/lib/AST/MicrosoftMangle.cpp:47
+  if (auto *CD = dyn_cast(DC))
+GD = GlobalDecl(CD, Ctor_Complete);
+  else if (auto *DD = dyn_cast(DC))

yaxunl wrote:
> rnk wrote:
> > I would prefer if you passed Ctor_Base and Dtor_Base here. I believe MSVC 
> > models the variants as separate compiler-generated functions. I believe the 
> > user code is always emitted into the "base" variant. That's consistent with 
> > what the user can observe in `__FUNCDNAME__`, see here:
> > https://github.com/llvm/llvm-project/blob/main/clang/lib/AST/Expr.cpp#L635
> It seems Microsoft C++ ABI does not have ctor variants 
> (https://github.com/llvm/llvm-project/blob/b2a2c38349a18b89b04d342632d5ea02f86dfdd6/clang/lib/CodeGen/CGClass.cpp#L1298).
>  Clang currently assumes Ctor_Complete in such situation 
> (https://github.com/llvm/llvm-project/blob/b2a2c38349a18b89b04d342632d5ea02f86dfdd6/clang/lib/CodeGen/CodeGenModule.cpp#L1356).
Hah, you're right, I forgot.


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

https://reviews.llvm.org/D113490

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


[PATCH] D114370: [clangd] IncludeCleaner: Attribute symbols from non self-contained headers to their parents

2021-11-22 Thread Kirill Bobyrev via Phabricator via cfe-commits
kbobyrev created this revision.
kbobyrev added a reviewer: kadircet.
Herald added subscribers: usaxena95, arphaman.
kbobyrev requested review of this revision.
Herald added subscribers: cfe-commits, MaskRay, ilya-biryukov.
Herald added a project: clang-tools-extra.

When a symbol comes from the non self-contained header, we recursively uplift
the file we consider used to the first includer that has a header guard. We
need to do this while we still have FileIDs because every time a non
self-contained header is included, it gets a new FileID but is later
deduplicated by HeaderID and it's not possible to understand where it was
included from.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D114370

Files:
  clang-tools-extra/clangd/IncludeCleaner.cpp
  clang-tools-extra/clangd/IncludeCleaner.h
  clang-tools-extra/clangd/unittests/IncludeCleanerTests.cpp

Index: clang-tools-extra/clangd/unittests/IncludeCleanerTests.cpp
===
--- clang-tools-extra/clangd/unittests/IncludeCleanerTests.cpp
+++ clang-tools-extra/clangd/unittests/IncludeCleanerTests.cpp
@@ -281,7 +281,8 @@
   auto &SM = AST.getSourceManager();
   auto &Includes = AST.getIncludeStructure();
 
-  auto ReferencedFiles = findReferencedFiles(findReferencedLocations(AST), SM);
+  auto ReferencedFiles = findReferencedFiles(findReferencedLocations(AST), SM,
+ AST.getPreprocessor());
   llvm::StringSet<> ReferencedFileNames;
   for (FileID FID : ReferencedFiles)
 ReferencedFileNames.insert(
@@ -303,6 +304,60 @@
   EXPECT_THAT(getUnused(AST, ReferencedHeaders), ::testing::IsEmpty());
 }
 
+TEST(IncludeCleaner, NonSelfContainedHeaders) {
+  TestTU TU;
+  TU.Code = R"cpp(
+#include "bar.h"
+#include "foo.h"
+
+int LocalFoo = foo::Variable,
+LocalBar = bar::Variable;
+)cpp";
+  TU.AdditionalFiles["bar.h"] = R"cpp(
+#pragma once
+namespace bar {
+#include "indirection.h"
+}
+)cpp";
+  TU.AdditionalFiles["foo.h"] = R"cpp(
+#pragma once
+namespace foo {
+#include "unguarded.h"
+}
+)cpp";
+  TU.AdditionalFiles["indirection.h"] = R"cpp(
+#include "unguarded.h"
+)cpp";
+  TU.AdditionalFiles["unguarded.h"] = R"cpp(
+constexpr int Variable = 42;
+)cpp";
+
+  ParsedAST AST = TU.build();
+  auto &SM = AST.getSourceManager();
+  auto &Includes = AST.getIncludeStructure();
+
+  auto ReferencedFiles = findReferencedFiles(findReferencedLocations(AST), SM,
+ AST.getPreprocessor());
+  llvm::StringSet<> ReferencedFileNames;
+  for (FileID FID : ReferencedFiles)
+ReferencedFileNames.insert(
+SM.getPresumedLoc(SM.getLocForStartOfFile(FID)).getFilename());
+  // Note that we have uplifted the referenced files from non self-contained
+  // headers to header-guarded ones.
+  EXPECT_THAT(ReferencedFileNames.keys(),
+  UnorderedElementsAre(testPath("bar.h"), testPath("foo.h")));
+
+  auto ReferencedHeaders = translateToHeaderIDs(ReferencedFiles, Includes, SM);
+  std::vector ReferencedHeaderNames;
+  for (IncludeStructure::HeaderID HID : ReferencedHeaders)
+ReferencedHeaderNames.push_back(Includes.getRealPath(HID));
+  EXPECT_THAT(ReferencedHeaderNames,
+  ElementsAre(testPath("bar.h"), testPath("foo.h")));
+
+  // Sanity check.
+  EXPECT_THAT(getUnused(AST, ReferencedHeaders), ::testing::IsEmpty());
+}
+
 } // namespace
 } // namespace clangd
 } // namespace clang
Index: clang-tools-extra/clangd/IncludeCleaner.h
===
--- clang-tools-extra/clangd/IncludeCleaner.h
+++ clang-tools-extra/clangd/IncludeCleaner.h
@@ -52,7 +52,8 @@
 /// The output only includes things SourceManager sees as files (not macro IDs).
 /// This can include ,  etc that are not true files.
 llvm::DenseSet findReferencedFiles(const ReferencedLocations &Locs,
-   const SourceManager &SM);
+   const SourceManager &SM,
+   const Preprocessor &PP);
 
 /// Maps FileIDs to the internal IncludeStructure representation (HeaderIDs).
 /// FileIDs that are not true files ( etc) are dropped.
Index: clang-tools-extra/clangd/IncludeCleaner.cpp
===
--- clang-tools-extra/clangd/IncludeCleaner.cpp
+++ clang-tools-extra/clangd/IncludeCleaner.cpp
@@ -16,6 +16,7 @@
 #include "clang/AST/ExprCXX.h"
 #include "clang/AST/RecursiveASTVisitor.h"
 #include "clang/Basic/SourceLocation.h"
+#include "clang/Basic/SourceManager.h"
 #include "clang/Lex/HeaderSearch.h"
 #include "clang/Lex/Preprocessor.h"
 #include "clang/Tooling/Syntax/Tokens.h"
@@ -137,23 +138,49 @@
   llvm::DenseSet Macros;
   const SourceManager &SM;
 
-  void add(SourceLocation Loc) { add(SM.getFileID(Loc), Loc); }
+  // Attributes the locations f

[PATCH] D100879: [Clang] Propagate guaranteed alignment for malloc and others

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

I think this patch was wrong -- we should not be assuming 16-byte alignment for 
an allocation smaller than 16 bytes.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100879

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


[PATCH] D114320: [clang-format] Extend AllowShortBlocksOnASingleLine for else blocks

2021-11-22 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay added a comment.

Nothing majorly wrong here, its looks pretty good.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D114320

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


[PATCH] D114320: [clang-format] Extend AllowShortBlocksOnASingleLine for else blocks

2021-11-22 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay added a comment.

Could you add the case  where the else is not empty.




Comment at: clang/unittests/Format/FormatTest.cpp:5400
+  Style.BraceWrapping.AfterControlStatement = FormatStyle::BWACS_Always;
+  EXPECT_EQ("if (a)\n"
+"{\n"

Can you please use verifyFormat  (as this does some extra stuff to ensure its 
stable)



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D114320

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


[PATCH] D113490: [NFC] Let Microsoft mangler accept GlobalDecl

2021-11-22 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl marked 2 inline comments as done.
yaxunl added inline comments.



Comment at: clang/lib/AST/MicrosoftMangle.cpp:47
+  if (auto *CD = dyn_cast(DC))
+GD = GlobalDecl(CD, Ctor_Complete);
+  else if (auto *DD = dyn_cast(DC))

rnk wrote:
> I would prefer if you passed Ctor_Base and Dtor_Base here. I believe MSVC 
> models the variants as separate compiler-generated functions. I believe the 
> user code is always emitted into the "base" variant. That's consistent with 
> what the user can observe in `__FUNCDNAME__`, see here:
> https://github.com/llvm/llvm-project/blob/main/clang/lib/AST/Expr.cpp#L635
It seems Microsoft C++ ABI does not have ctor variants 
(https://github.com/llvm/llvm-project/blob/b2a2c38349a18b89b04d342632d5ea02f86dfdd6/clang/lib/CodeGen/CGClass.cpp#L1298).
 Clang currently assumes Ctor_Complete in such situation 
(https://github.com/llvm/llvm-project/blob/b2a2c38349a18b89b04d342632d5ea02f86dfdd6/clang/lib/CodeGen/CodeGenModule.cpp#L1356).


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

https://reviews.llvm.org/D113490

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


[PATCH] D114312: libfuzzer: Disable broken tests for arm

2021-11-22 Thread Matt Morehouse via Phabricator via cfe-commits
morehouse accepted this revision.
morehouse added a comment.
This revision is now accepted and ready to land.

LGTM


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D114312

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


[PATCH] D112427: [ARM] Implement setjmp BTI placement for PACBTI-M

2021-11-22 Thread Ties Stuij via Phabricator via cfe-commits
stuij updated this revision to Diff 388891.
stuij added a comment.
Herald added subscribers: cfe-commits, dang.
Herald added a project: clang.

addressed review comments, namely adding a commandline argument, 
`-mno-bti-at-return-twice`, to not place a bti instruction after a setjmp call.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112427

Files:
  clang/docs/ClangCommandLineReference.rst
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/ToolChains/Arch/ARM.cpp
  clang/test/Driver/arm-bti-return-twice.c
  llvm/lib/Target/ARM/ARM.td
  llvm/lib/Target/ARM/ARMExpandPseudoInsts.cpp
  llvm/lib/Target/ARM/ARMISelLowering.cpp
  llvm/lib/Target/ARM/ARMISelLowering.h
  llvm/lib/Target/ARM/ARMInstrThumb2.td
  llvm/lib/Target/ARM/ARMSubtarget.h
  llvm/test/CodeGen/ARM/setjmp-bti-basic.ll
  llvm/test/CodeGen/ARM/setjmp-bti-outliner.ll

Index: llvm/test/CodeGen/ARM/setjmp-bti-outliner.ll
===
--- /dev/null
+++ llvm/test/CodeGen/ARM/setjmp-bti-outliner.ll
@@ -0,0 +1,92 @@
+; RUN: llc -mtriple=thumbv8.1m.main-arm-none-eabi -enable-machine-outliner < %s | \
+; RUN: FileCheck %s --check-prefix=BTI
+; RUN: llc -mtriple=thumbv8.1m.main-arm-none-eabi -enable-machine-outliner -mattr=+no-bti-at-return-twice < %s | FileCheck %s --check-prefix=NOBTI
+
+; C source
+; 
+; jmp_buf buf;
+;
+; extern void h(int a, int b, int *c);
+;
+; int f(int a, int b, int c, int d) {
+;   if (setjmp(buf) != 0)
+; return -1;
+;   h(a, b, &a);
+;   return 2 + a * (a + b) / (c + d);
+; }
+;
+; int g(int a, int b, int c, int d) {
+;   if (setjmp(buf) != 0)
+; return -1;
+;   h(a, b, &a);
+;   return 1 + a * (a + b) / (c + d);
+; }
+
+@buf = global [20 x i64] zeroinitializer, align 8
+
+define i32 @f(i32 %a, i32 %b, i32 %c, i32 %d) {
+; BTI-LABEL: f:
+; BTI:   bl OUTLINED_FUNCTION_0
+; BTI-NEXT:  bti
+; NOBTI-LABEL: f:
+; NOBTI:   bl OUTLINED_FUNCTION_0
+; NOBTI-NEXT:   cbz	r0, .LBB0_2
+entry:
+  %a.addr = alloca i32, align 4
+  store i32 %a, i32* %a.addr, align 4
+  %call = call i32 @setjmp(i64* getelementptr inbounds ([20 x i64], [20 x i64]* @buf, i32 0, i32 0)) #0
+  %cmp.not = icmp eq i32 %call, 0
+  br i1 %cmp.not, label %if.end, label %return
+
+if.end:   ; preds = %entry
+  call void @h(i32 %a, i32 %b, i32* nonnull %a.addr)
+  %0 = load i32, i32* %a.addr, align 4
+  %add = add nsw i32 %0, %b
+  %mul = mul nsw i32 %add, %0
+  %add1 = add nsw i32 %d, %c
+  %div = sdiv i32 %mul, %add1
+  %add2 = add nsw i32 %div, 2
+  br label %return
+
+return:   ; preds = %entry, %if.end
+  %retval.0 = phi i32 [ %add2, %if.end ], [ -1, %entry ]
+  ret i32 %retval.0
+}
+
+define i32 @g(i32 %a, i32 %b, i32 %c, i32 %d) {
+; BTI-LABEL: g:
+; BTI:   bl OUTLINED_FUNCTION_0
+; BTI-NEXT:  bti
+; NOBTI-LABEL: g:
+; NOBTI:   bl OUTLINED_FUNCTION_0
+; NOBTI-NEXT:  cbz	r0, .LBB1_2
+entry:
+  %a.addr = alloca i32, align 4
+  store i32 %a, i32* %a.addr, align 4
+  %call = call i32 @setjmp(i64* getelementptr inbounds ([20 x i64], [20 x i64]* @buf, i32 0, i32 0)) #0
+  %cmp.not = icmp eq i32 %call, 0
+  br i1 %cmp.not, label %if.end, label %return
+
+if.end:   ; preds = %entry
+  call void @h(i32 %a, i32 %b, i32* nonnull %a.addr)
+  %0 = load i32, i32* %a.addr, align 4
+  %add = add nsw i32 %0, %b
+  %mul = mul nsw i32 %add, %0
+  %add1 = add nsw i32 %d, %c
+  %div = sdiv i32 %mul, %add1
+  %add2 = add nsw i32 %div, 1
+  br label %return
+
+return:   ; preds = %entry, %if.end
+  %retval.0 = phi i32 [ %add2, %if.end ], [ -1, %entry ]
+  ret i32 %retval.0
+}
+
+declare void @h(i32, i32, i32*)
+declare i32 @setjmp(i64*) #0
+
+attributes #0 = { returns_twice }
+
+!llvm.module.flags = !{!0}
+
+!0 = !{i32 1, !"branch-target-enforcement", i32 1}
Index: llvm/test/CodeGen/ARM/setjmp-bti-basic.ll
===
--- /dev/null
+++ llvm/test/CodeGen/ARM/setjmp-bti-basic.ll
@@ -0,0 +1,50 @@
+; RUN: llc -mtriple=thumbv8.1m.main-arm-none-eabi < %s | FileCheck %s --check-prefix=BTI
+; RUN: llc -mtriple=thumbv8.1m.main-arm-none-eabi -mattr=+no-bti-at-return-twice < %s | \
+; RUN: FileCheck %s --check-prefix=NOBTI
+
+; C source
+; 
+; jmp_buf buf;
+;
+; extern void bar(int x);
+;
+; int foo(int x) {
+;   if (setjmp(buf))
+; x = 0;
+;   else
+; bar(x);
+;   return x;
+; }
+
+@buf = global [20 x i64] zeroinitializer, align 8
+
+define i32 @foo(i32 %x) {
+; BTI-LABEL: foo:
+; BTI:   bl setjmp
+; BTI-NEXT:  bti
+; NOBTI-LABEL: foo:
+; NOBTI:   bl setjmp
+; NOBTI-NOT:   bti
+
+entry:
+  %call = call i32 @setjmp(i64* getelementptr inbounds ([20 x i64], [20 x i64]* @buf, i32 0, i32 0)) #0
+  %tobool.not = icmp eq i32 %call, 0
+  br i1 %tobool.not, label %if.else, label %if.end
+
+i

[PATCH] D111617: [RISCV] Lazily add RVV C intrinsics.

2021-11-22 Thread Hsiangkai Wang via Phabricator via cfe-commits
HsiangKai updated this revision to Diff 31.
HsiangKai added a comment.

Update the implementation of getMangledName().


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D111617

Files:
  clang/include/clang/Basic/CMakeLists.txt
  clang/include/clang/Basic/TokenKinds.def
  clang/include/clang/Parse/Parser.h
  clang/lib/Parse/ParsePragma.cpp
  clang/lib/Sema/SemaLookup.cpp
  clang/utils/TableGen/RISCVVEmitter.cpp
  clang/utils/TableGen/TableGen.cpp
  clang/utils/TableGen/TableGenBackends.h
  llvm/docs/CommandGuide/tblgen.rst

Index: llvm/docs/CommandGuide/tblgen.rst
===
--- llvm/docs/CommandGuide/tblgen.rst
+++ llvm/docs/CommandGuide/tblgen.rst
@@ -348,6 +348,10 @@
 
   Generate ``riscv_vector_builtin_cg.inc`` for Clang.
 
+.. option:: -gen-riscv-vector-builtin-sema
+
+  Generate ``riscv_vector_builtin_sema.inc`` for Clang.
+
 .. option:: -gen-attr-docs
 
   Generate attribute documentation.
Index: clang/utils/TableGen/TableGenBackends.h
===
--- clang/utils/TableGen/TableGenBackends.h
+++ clang/utils/TableGen/TableGenBackends.h
@@ -110,6 +110,7 @@
 void EmitRVVHeader(llvm::RecordKeeper &Records, llvm::raw_ostream &OS);
 void EmitRVVBuiltins(llvm::RecordKeeper &Records, llvm::raw_ostream &OS);
 void EmitRVVBuiltinCG(llvm::RecordKeeper &Records, llvm::raw_ostream &OS);
+void EmitRVVBuiltinSema(llvm::RecordKeeper &Records, llvm::raw_ostream &OS);
 
 void EmitCdeHeader(llvm::RecordKeeper &Records, llvm::raw_ostream &OS);
 void EmitCdeBuiltinDef(llvm::RecordKeeper &Records, llvm::raw_ostream &OS);
Index: clang/utils/TableGen/TableGen.cpp
===
--- clang/utils/TableGen/TableGen.cpp
+++ clang/utils/TableGen/TableGen.cpp
@@ -88,6 +88,7 @@
   GenRISCVVectorHeader,
   GenRISCVVectorBuiltins,
   GenRISCVVectorBuiltinCG,
+  GenRISCVVectorBuiltinSema,
   GenAttrDocs,
   GenDiagDocs,
   GenOptDocs,
@@ -243,6 +244,8 @@
"Generate riscv_vector_builtins.inc for clang"),
 clEnumValN(GenRISCVVectorBuiltinCG, "gen-riscv-vector-builtin-codegen",
"Generate riscv_vector_builtin_cg.inc for clang"),
+clEnumValN(GenRISCVVectorBuiltinSema, "gen-riscv-vector-builtin-sema",
+   "Generate riscv_vector_builtin_sema.inc for clang"),
 clEnumValN(GenAttrDocs, "gen-attr-docs",
"Generate attribute documentation"),
 clEnumValN(GenDiagDocs, "gen-diag-docs",
@@ -458,6 +461,9 @@
   case GenRISCVVectorBuiltinCG:
 EmitRVVBuiltinCG(Records, OS);
 break;
+  case GenRISCVVectorBuiltinSema:
+EmitRVVBuiltinSema(Records, OS);
+break;
   case GenAttrDocs:
 EmitClangAttrDocs(Records, OS);
 break;
Index: clang/utils/TableGen/RISCVVEmitter.cpp
===
--- clang/utils/TableGen/RISCVVEmitter.cpp
+++ clang/utils/TableGen/RISCVVEmitter.cpp
@@ -15,6 +15,7 @@
 //===--===//
 
 #include "llvm/ADT/ArrayRef.h"
+#include "llvm/ADT/MapVector.h"
 #include "llvm/ADT/SmallSet.h"
 #include "llvm/ADT/StringExtras.h"
 #include "llvm/ADT/StringMap.h"
@@ -22,6 +23,8 @@
 #include "llvm/ADT/Twine.h"
 #include "llvm/TableGen/Error.h"
 #include "llvm/TableGen/Record.h"
+#include "llvm/TableGen/StringMatcher.h"
+#include "llvm/TableGen/TableGenBackend.h"
 #include 
 
 using namespace llvm;
@@ -55,7 +58,6 @@
 Float,
 Invalid,
   };
-  BasicType BT;
   ScalarTypeKind ScalarType = Invalid;
   LMULType LMUL;
   bool IsPointer = false;
@@ -71,11 +73,30 @@
   std::string ClangBuiltinStr;
   std::string Str;
   std::string ShortStr;
+  std::string QualExpr;
+  std::string MangledStr;
 
 public:
   RVVType() : RVVType(BasicType(), 0, StringRef()) {}
   RVVType(BasicType BT, int Log2LMUL, StringRef prototype);
 
+  StringRef getMangledStr() {
+if (MangledStr.empty()) {
+  if (!Valid)
+MangledStr = "invalid";
+  else {
+MangledStr =
+(Twine(ScalarType) + Twine(IsPointer) + Twine(IsImmediate) +
+ Twine(IsConstant) + Twine(ElementBitwidth))
+.str();
+if (!isScalar())
+  MangledStr += (Twine(Scale.getValue()) + LMUL.str()).str();
+  }
+}
+
+return MangledStr;
+  }
+
   // Return the string representation of a type, which is an encoded string for
   // passing to the BUILTIN() macro in Builtins.def.
   const std::string &getBuiltinStr() const { return BuiltinStr; }
@@ -97,6 +118,8 @@
 return ShortStr;
   }
 
+  const std::string &getQualExpr() { return QualExpr; }
+
   bool isValid() const { return Valid; }
   bool isScalar() const { return Scale.hasValue() && Scale.getValue() == 0; }
   bool isVector() const { return Scale.hasValue() && Scale.getValue() != 0; }
@@ 

[PATCH] D113268: [clangd] Fix tests with forward slash as separator on windows

2021-11-22 Thread Martin Storsjö via Phabricator via cfe-commits
mstorsjo added a comment.

Sorry for taking so long to get back to you on this matter...

In D113268#3112026 , @sammccall wrote:

>> For someone unfamiliar with the tool, is there a simple "smoke test 
>> procedure" I could try out with it to kick the tyres?
>
> There's `clangd --check=some_file.cc` which simulates opening up a file in an 
> editor and clicking around in it.
> It does require a `compile_command.json` in a parent directory to know about 
> build flags.
> To try it out for real you need to connect an editor to it with a plugin 
> (like vscode-clangd).

Thanks! I tested both `clangd --check=some_file.cc` and vscode-clangd with a 
build of clangd set to prefer forward slashes, and it all worked fine so far. I 
didn't do any exhaustive use of it in vscode, but at least regular use seemed 
just fine.

> But realistic problems with paths tend to come from interactions with 
> external sources.
> For example, we had a bug that involved:
>
> - vscode sending paths like `file://c:/test.cc` (lowercase C), which made its 
> way into our AST cache
> - cmake creating `compile_commands.json` like `C:\test.cc` (uppercase C), 
> which made its way into our index
> - when renaming a symbol, results from the two weren't deduplicated against 
> each other so the edit was applied twice

Yup - I've seen lots of similar issues in other clang tests too. The best way 
forward to fix those would probably be to add some helper to `llvm::sys::path` 
for doing path comparisons, which would ignore case differences (on windows and 
macos) and/or separator style differences (on windows). But

Anyway, this change (and a build that prefers generating paths with forward 
slashes) seems to work as expected with regards to that - and I updated the 
patch with what was requested.

The whole setup for this mode isn't settled, so there's no buildbot for this 
mode (yet), we'll see if we end up setting one up. In any case, most of this 
change shouldn't be too intrusive I hope.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D113268

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


[PATCH] D113268: [clangd] Fix tests with forward slash as separator on windows

2021-11-22 Thread Martin Storsjö via Phabricator via cfe-commits
mstorsjo updated this revision to Diff 388857.
mstorsjo added a comment.

Added a comment about the surprising change where the order of append and 
native is switched. Made the modification to `testRoot()` less hacky.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D113268

Files:
  clang-tools-extra/clangd/tool/ClangdMain.cpp
  clang-tools-extra/clangd/unittests/TestFS.cpp
  clang-tools-extra/clangd/unittests/TestFS.h
  clang-tools-extra/clangd/unittests/URITests.cpp


Index: clang-tools-extra/clangd/unittests/URITests.cpp
===
--- clang-tools-extra/clangd/unittests/URITests.cpp
+++ clang-tools-extra/clangd/unittests/URITests.cpp
@@ -133,8 +133,10 @@
 
 TEST(URITest, Resolve) {
 #ifdef _WIN32
-  EXPECT_THAT(resolveOrDie(parseOrDie("file:///c%3a/x/y/z")), "c:\\x\\y\\z");
-  EXPECT_THAT(resolveOrDie(parseOrDie("file:///c:/x/y/z")), "c:\\x\\y\\z");
+  llvm::SmallString<16> Ref("c:\\x\\y\\z");
+  llvm::sys::path::native(Ref);
+  EXPECT_THAT(resolveOrDie(parseOrDie("file:///c%3a/x/y/z")), Ref);
+  EXPECT_THAT(resolveOrDie(parseOrDie("file:///c:/x/y/z")), Ref);
 #else
   EXPECT_EQ(resolveOrDie(parseOrDie("file:/a/b/c")), "/a/b/c");
   EXPECT_EQ(resolveOrDie(parseOrDie("file://auth/a/b/c")), "//auth/a/b/c");
@@ -148,13 +150,17 @@
 
 TEST(URITest, ResolveUNC) {
 #ifdef _WIN32
+  llvm::SmallString<32> RefExample("example.com\\x\\y\\z");
+  llvm::sys::path::native(RefExample);
+  llvm::SmallString<16> RefLocalhost("127.0.0.1\\x\\y\\z");
+  llvm::sys::path::native(RefLocalhost);
   EXPECT_THAT(resolveOrDie(parseOrDie("file://example.com/x/y/z")),
-  "example.com\\x\\y\\z");
+  RefExample);
   EXPECT_THAT(resolveOrDie(parseOrDie("file://127.0.0.1/x/y/z")),
-  "127.0.0.1\\x\\y\\z");
+  RefLocalhost);
   // Ensure non-traditional file URI still resolves to correct UNC path.
   EXPECT_THAT(resolveOrDie(parseOrDie("file:127.0.0.1/x/y/z")),
-  "127.0.0.1\\x\\y\\z");
+  RefLocalhost);
 #else
   EXPECT_THAT(resolveOrDie(parseOrDie("file://example.com/x/y/z")),
   "//example.com/x/y/z");
Index: clang-tools-extra/clangd/unittests/TestFS.h
===
--- clang-tools-extra/clangd/unittests/TestFS.h
+++ clang-tools-extra/clangd/unittests/TestFS.h
@@ -75,7 +75,7 @@
 };
 
 // Returns an absolute (fake) test directory for this OS.
-const char *testRoot();
+std::string testRoot();
 
 // Returns a suitable absolute path for this OS.
 std::string testPath(PathRef File,
Index: clang-tools-extra/clangd/unittests/TestFS.cpp
===
--- clang-tools-extra/clangd/unittests/TestFS.cpp
+++ clang-tools-extra/clangd/unittests/TestFS.cpp
@@ -71,9 +71,11 @@
   FileName, std::move(CommandLine), "")};
 }
 
-const char *testRoot() {
+std::string testRoot() {
 #ifdef _WIN32
-  return "C:\\clangd-test";
+  llvm::SmallString<16> NativeRoot("C:\\clangd-test");
+  llvm::sys::path::native(NativeRoot);
+  return std::string(NativeRoot);
 #else
   return "/clangd-test";
 #endif
Index: clang-tools-extra/clangd/tool/ClangdMain.cpp
===
--- clang-tools-extra/clangd/tool/ClangdMain.cpp
+++ clang-tools-extra/clangd/tool/ClangdMain.cpp
@@ -541,15 +541,20 @@
   Body);
 Body = Body.ltrim('/');
 llvm::SmallString<16> Path(Body);
-path::native(Path);
 fs::make_absolute(TestScheme::TestDir, Path);
+// Convert the whole path to native separators after concatenating with
+// TestDir; TestDir might contain separators other than the preferred
+// on Windows if forward slashes are preferred.
+path::native(Path);
 return std::string(Path);
   }
 
   llvm::Expected
   uriFromAbsolutePath(llvm::StringRef AbsolutePath) const override {
 llvm::StringRef Body = AbsolutePath;
-if (!Body.consume_front(TestScheme::TestDir))
+llvm::SmallString<16> NativeTestDir(TestDir);
+llvm::sys::path::native(NativeTestDir);
+if (!Body.consume_front(NativeTestDir))
   return error("Path {0} doesn't start with root {1}", AbsolutePath,
TestDir);
 


Index: clang-tools-extra/clangd/unittests/URITests.cpp
===
--- clang-tools-extra/clangd/unittests/URITests.cpp
+++ clang-tools-extra/clangd/unittests/URITests.cpp
@@ -133,8 +133,10 @@
 
 TEST(URITest, Resolve) {
 #ifdef _WIN32
-  EXPECT_THAT(resolveOrDie(parseOrDie("file:///c%3a/x/y/z")), "c:\\x\\y\\z");
-  EXPECT_THAT(resolveOrDie(parseOrDie("file:///c:/x/y/z")), "c:\\x\\y\\z");
+  llvm::SmallString<16> Ref("c:\\x\\y\\z");
+  llvm::sys::path::native(Ref);
+  EXPECT_THAT(resolveOrDie(parseOrDie("file:///c%3a/x/y/z")), Ref);
+  EXPECT_THAT(resol

[PATCH] D113250: [clang][driver] Add -fplugin-arg- to pass arguments to plugins

2021-11-22 Thread Timm Bäder via Phabricator via cfe-commits
tbaeder updated this revision to Diff 388853.
tbaeder added a comment.

Added two new warning types and used them for diagnosing malformed 
`-fplugin-arg` options. Also added tests for that.


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

https://reviews.llvm.org/D113250

Files:
  clang/docs/ClangPlugins.rst
  clang/docs/ReleaseNotes.rst
  clang/examples/CallSuperAttribute/CallSuperAttrInfo.cpp
  clang/include/clang/Basic/DiagnosticDriverKinds.td
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/test/Driver/plugin-driver-args.cpp
  clang/test/Frontend/plugin-call-super.cpp

Index: clang/test/Frontend/plugin-call-super.cpp
===
--- clang/test/Frontend/plugin-call-super.cpp
+++ clang/test/Frontend/plugin-call-super.cpp
@@ -1,5 +1,5 @@
-// RUN: %clang -fplugin=%llvmshlibdir/CallSuperAttr%pluginext -fsyntax-only -Xclang -verify=callsuper %s
-// RUN: %clang -fplugin=%llvmshlibdir/CallSuperAttr%pluginext -DBAD_CALLSUPER -fsyntax-only -Xclang -verify=badcallsuper %s
+// RUN: %clang_cc1 -load %llvmshlibdir/CallSuperAttr%pluginext -fsyntax-only -verify=callsuper %s
+// RUN: %clang_cc1 -load %llvmshlibdir/CallSuperAttr%pluginext -DBAD_CALLSUPER -fsyntax-only -verify=badcallsuper %s
 // REQUIRES: plugins, examples
 
 // callsuper-no-diagnostics
Index: clang/test/Driver/plugin-driver-args.cpp
===
--- /dev/null
+++ clang/test/Driver/plugin-driver-args.cpp
@@ -0,0 +1,22 @@
+// Test passing args to plugins via the clang driver and -fplugin-arg
+// RUN: %clang -fplugin=%llvmshlibdir/CallSuperAttr%pluginext -fplugin-arg-call_super_plugin-help -fsyntax-only -### %s 2>&1 | FileCheck %s
+
+// CHECK: "-load"
+// CHECK-SAME: CallSuperAttr
+// CHECK-SAME: "-plugin-arg-call_super_plugin"
+// CHECK-SAME: "help"
+
+// Check that dashed-args get forwarded like this to the plugin.
+// Dashes cannot be part of the plugin name here
+// RUN: %clang -fplugin=%llvmshlibdir/CallSuperAttr%pluginext -fplugin-arg-call_super_plugin-help-long -fsyntax-only %s 2>&1 -### | FileCheck %s --check-prefix=CHECK-CMD
+// CHECK-CMD: "-plugin-arg-call_super_plugin" "help-long"
+
+// Error handling for -fplugin-arg-
+// RUN: %clang -fplugin=%llvmshlibdir/CallSuperAttr%pluginext -fplugin-arg- -fsyntax-only %s 2>&1 | FileCheck %s --check-prefix=CHECK-NO-PLUGIN-NAME
+// CHECK-NO-PLUGIN-NAME: Missing plugin name in -fplugin-arg-
+
+// RUN: %clang -fplugin=%llvmshlibdir/CallSuperAttr%pluginext -fplugin-arg-testname -fsyntax-only %s 2>&1 | FileCheck %s --check-prefix=CHECK-NO-PLUGIN-ARG1
+// CHECK-NO-PLUGIN-ARG1: Missing plugin argument for plugin testname in -fplugin-arg-testname
+
+// RUN: %clang -fplugin=%llvmshlibdir/CallSuperAttr%pluginext -fplugin-arg-testname- -fsyntax-only %s 2>&1 | FileCheck %s --check-prefix=CHECK-NO-PLUGIN-ARG2
+// CHECK-NO-PLUGIN-ARG2: Missing plugin argument for plugin testname in -fplugin-arg-testname-
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -6660,6 +6660,35 @@
 A->claim();
   }
 
+  // Turn -fplugin-arg-pluginname-key=value into
+  // -plugin-arg-pluginname key=value
+  // GCC has an actual plugin_argument struct with key/value pairs that it
+  // passes to its plugins, but we don't, so just pass it on as-is.
+  //
+  // The syntax for -fplugin-arg- is ambiguous if both plugin name and
+  // argument key are allowed to contain dashes. GCC therefore only
+  // allows dashes in the key. We do the same.
+  for (const Arg *A : Args.filtered(options::OPT_fplugin_arg)) {
+auto ArgValue = StringRef(A->getValue());
+auto FirstDashIndex = ArgValue.find('-');
+StringRef PluginName = ArgValue.substr(0, FirstDashIndex);
+StringRef Arg = ArgValue.substr(FirstDashIndex + 1);
+
+A->claim();
+if (FirstDashIndex == StringRef::npos || Arg == "") {
+  if (PluginName == "") {
+D.Diag(diag::warn_drv_missing_plugin_name) << A->getAsString(Args);
+  } else {
+D.Diag(diag::warn_drv_missing_plugin_arg)
+<< PluginName << A->getAsString(Args);
+  }
+  continue;
+}
+
+CmdArgs.push_back(Args.MakeArgString(Twine("-plugin-arg-") + PluginName));
+CmdArgs.push_back(Args.MakeArgString(Arg));
+  }
+
   // Forward -fpass-plugin=name.so to -cc1.
   for (const Arg *A : Args.filtered(options::OPT_fpass_plugin_EQ)) {
 CmdArgs.push_back(
Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -2504,6 +2504,9 @@
   NegFlag>;
 def fplugin_EQ : Joined<["-"], "fplugin=">, Group, Flags<[NoXarchOption]>, MetaVarName<"">,
   HelpText<"Load the named plugin (dynamic shared object)">;
+def fplugin_arg : Joined<["

[PATCH] D114254: [libtooling][clang-tidy] Fix crashing on rendering invalid SourceRanges

2021-11-22 Thread Balázs Benics via Phabricator via cfe-commits
steakhal updated this revision to Diff 388850.
steakhal marked an inline comment as done.
steakhal added a comment.

- prefer `empty()` over `size() == 0`


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

https://reviews.llvm.org/D114254

Files:
  clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp
  clang-tools-extra/test/clang-tidy/infrastructure/export-diagnostics.cpp
  clang-tools-extra/unittests/clang-tidy/ClangTidyDiagnosticConsumerTest.cpp

Index: clang-tools-extra/unittests/clang-tidy/ClangTidyDiagnosticConsumerTest.cpp
===
--- clang-tools-extra/unittests/clang-tidy/ClangTidyDiagnosticConsumerTest.cpp
+++ clang-tools-extra/unittests/clang-tidy/ClangTidyDiagnosticConsumerTest.cpp
@@ -37,6 +37,33 @@
   }
 };
 
+class InvalidRangeTestCheck : public ClangTidyCheck {
+public:
+  InvalidRangeTestCheck(StringRef Name, ClangTidyContext *Context)
+  : ClangTidyCheck(Name, Context) {}
+  void registerMatchers(ast_matchers::MatchFinder *Finder) override {
+Finder->addMatcher(ast_matchers::varDecl().bind("var"), this);
+  }
+  void check(const ast_matchers::MatchFinder::MatchResult &Result) override {
+const auto *Var = Result.Nodes.getNodeAs("var");
+SourceLocation ValidBeginLoc = Var->getBeginLoc();
+SourceLocation ValidEndLoc = Var->getEndLoc();
+SourceLocation InvalidLoc;
+ASSERT_TRUE(ValidBeginLoc.isValid());
+ASSERT_TRUE(ValidEndLoc.isValid());
+ASSERT_TRUE(InvalidLoc.isInvalid());
+
+diag(ValidBeginLoc, "valid->valid")
+<< SourceRange(ValidBeginLoc, ValidEndLoc);
+diag(ValidBeginLoc, "valid->invalid")
+<< SourceRange(ValidBeginLoc, InvalidLoc);
+diag(ValidBeginLoc, "invalid->valid")
+<< SourceRange(InvalidLoc, ValidEndLoc);
+diag(ValidBeginLoc, "invalid->invalid")
+<< SourceRange(InvalidLoc, InvalidLoc);
+  }
+};
+
 } // namespace
 
 TEST(ClangTidyDiagnosticConsumer, SortsErrors) {
@@ -66,6 +93,24 @@
   EXPECT_EQ(7ul, Errors[0].Message.Ranges[0].Length);
 }
 
+TEST(ClangTidyDiagnosticConsumer, InvalidSourceLocationRangesIgnored) {
+  std::vector Errors;
+  runCheckOnCode("int x;", &Errors);
+  EXPECT_EQ(4ul, Errors.size());
+
+  EXPECT_EQ("invalid->invalid", Errors[0].Message.Message);
+  EXPECT_TRUE(Errors[0].Message.Ranges.empty());
+
+  EXPECT_EQ("invalid->valid", Errors[1].Message.Message);
+  EXPECT_TRUE(Errors[1].Message.Ranges.empty());
+
+  EXPECT_EQ("valid->invalid", Errors[2].Message.Message);
+  EXPECT_TRUE(Errors[2].Message.Ranges.empty());
+
+  EXPECT_EQ("valid->valid", Errors[3].Message.Message);
+  EXPECT_EQ(1ul, Errors[3].Message.Ranges.size());
+}
+
 } // namespace test
 } // namespace tidy
 } // namespace clang
Index: clang-tools-extra/test/clang-tidy/infrastructure/export-diagnostics.cpp
===
--- clang-tools-extra/test/clang-tidy/infrastructure/export-diagnostics.cpp
+++ clang-tools-extra/test/clang-tidy/infrastructure/export-diagnostics.cpp
@@ -7,6 +7,11 @@
 int a[-1];
 int b[0];
 
+void test(x);
+struct Foo {
+  member;
+};
+
 // CHECK-MESSAGES: -input.cpp:2:1: warning: no previous prototype for function 'ff' [clang-diagnostic-missing-prototypes]
 // CHECK-MESSAGES: -input.cpp:1:19: note: expanded from macro 'X'
 // CHECK-MESSAGES: {{^}}note: expanded from here{{$}}
@@ -14,6 +19,8 @@
 // CHECK-MESSAGES: -input.cpp:1:14: note: expanded from macro 'X'
 // CHECK-MESSAGES: -input.cpp:3:7: error: 'a' declared as an array with a negative size [clang-diagnostic-error]
 // CHECK-MESSAGES: -input.cpp:4:7: warning: zero size arrays are an extension [clang-diagnostic-zero-length-array]
+// CHECK-MESSAGES: -input.cpp:6:11: error: unknown type name 'x' [clang-diagnostic-error]
+// CHECK-MESSAGES: -input.cpp:8:3: error: C++ requires a type specifier for all declarations [clang-diagnostic-error]
 
 // CHECK-YAML: ---
 // CHECK-YAML-NEXT: MainSourceFile:  '{{.*}}-input.cpp'
@@ -71,4 +78,20 @@
 // CHECK-YAML-NEXT:  Length:  1
 // CHECK-YAML-NEXT: Level:   Warning
 // CHECK-YAML-NEXT: BuildDirectory:  '{{.*}}'
+// CHECK-YAML-NEXT:   - DiagnosticName:  clang-diagnostic-error
+// CHECK-YAML-NEXT: DiagnosticMessage:
+// CHECK-YAML-NEXT:   Message: 'unknown type name ''x'''
+// CHECK-YAML-NEXT:   FilePath:'{{.*}}-input.cpp'
+// CHECK-YAML-NEXT:   FileOffset:  67
+// CHECK-YAML-NEXT:   Replacements:[]
+// CHECK-YAML-NEXT: Level:   Error
+// CHECK-YAML-NEXT: BuildDirectory:  '{{.*}}'
+// CHECK-YAML-NEXT:   - DiagnosticName:  clang-diagnostic-error
+// CHECK-YAML-NEXT: DiagnosticMessage:
+// CHECK-YAML-NEXT:   Message: 'C++ requires a type specifier for all declarations'
+// CHECK-YAML-NEXT:   FilePath:'{{.*}}-input.cpp'
+// CHECK-YAML-NEXT:   FileOffset:  86
+// CHECK-YAML-NEXT:   Replacements:[]
+// CHECK-YAML-NEXT: Level:   

[PATCH] D114326: Update the list of CUDA versions up to 11.5

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



Comment at: clang/lib/Driver/ToolChains/Cuda.cpp:131
+  std::initializer_list Versions = {
+  "11.5", "11.4", "11.3", "11.2", "11.1", "11.0", "10.2", "10.1",
+  "10.0", "9.2",  "9.1",  "9.0",  "8.0",  "7.5",  "7.0"};

looks like the list is getting big and hard to maintain. considering that this 
is done only once per compiler invocation (and we check for existence of 
directories down in the loop anyway). what about throwing in an extra directory 
listing to base-directories mentioned down below and populate `Candidates` 
while preserving the newest-version-first order?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D114326

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


[clang] 84bf5e3 - Fix various problems found by fuzzing.

2021-11-22 Thread Manuel Klimek via cfe-commits

Author: Manuel Klimek
Date: 2021-11-22T11:08:38+01:00
New Revision: 84bf5e328664db2e744c4651c52d2460b1733d09

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

LOG: Fix various problems found by fuzzing.

1. IndexTokenSource::getNextToken cannot return nullptr; some code was
still written assuming it can; make getNextToken more resilient against
incorrect input and fix its call-sites.

2. Change various asserts that can happen due to user provided input to
conditionals in the code.

Added: 


Modified: 
clang/lib/Format/ContinuationIndenter.cpp
clang/lib/Format/TokenAnnotator.cpp
clang/lib/Format/UnwrappedLineParser.cpp
clang/lib/Format/WhitespaceManager.cpp

Removed: 




diff  --git a/clang/lib/Format/ContinuationIndenter.cpp 
b/clang/lib/Format/ContinuationIndenter.cpp
index 1e4f5690ef241..f56b7c70d18e7 100644
--- a/clang/lib/Format/ContinuationIndenter.cpp
+++ b/clang/lib/Format/ContinuationIndenter.cpp
@@ -1986,7 +1986,9 @@ ContinuationIndenter::createBreakableToken(const 
FormatToken &Current,
   Current.Previous->isNot(TT_ImplicitStringLiteral))) {
 if (!Style.ReflowComments ||
 CommentPragmasRegex.match(Current.TokenText.substr(2)) ||
-switchesFormatting(Current))
+switchesFormatting(Current) ||
+!(Current.TokenText.startswith("//") ||
+  Current.TokenText.startswith("#")))
   return nullptr;
 return std::make_unique(
 Current, StartColumn, /*InPPDirective=*/false, Encoding, Style);
@@ -2195,11 +2197,10 @@ ContinuationIndenter::breakProtrudingToken(const 
FormatToken &Current,
   // When breaking before a tab character, it may be moved by a few 
columns,
   // but will still be expanded to the next tab stop, so we don't save any
   // columns.
-  if (NewRemainingTokenColumns == RemainingTokenColumns) {
+  if (NewRemainingTokenColumns >= RemainingTokenColumns) {
 // FIXME: Do we need to adjust the penalty?
 break;
   }
-  assert(NewRemainingTokenColumns < RemainingTokenColumns);
 
   LLVM_DEBUG(llvm::dbgs() << "Breaking at: " << TailOffset + 
Split.first
   << ", " << Split.second << "\n");

diff  --git a/clang/lib/Format/TokenAnnotator.cpp 
b/clang/lib/Format/TokenAnnotator.cpp
index 3897241cb8589..f3f63b4cad234 100644
--- a/clang/lib/Format/TokenAnnotator.cpp
+++ b/clang/lib/Format/TokenAnnotator.cpp
@@ -946,11 +946,15 @@ class AnnotatingParser {
  !Line.First->isOneOf(tok::kw_enum, tok::kw_case,
   tok::kw_default)) {
 FormatToken *Prev = Tok->getPreviousNonComment();
+if (!Prev)
+  break;
 if (Prev->isOneOf(tok::r_paren, tok::kw_noexcept))
   Tok->setType(TT_CtorInitializerColon);
 else if (Prev->is(tok::kw_try)) {
   // Member initializer list within function try block.
   FormatToken *PrevPrev = Prev->getPreviousNonComment();
+  if (!PrevPrev)
+break;
   if (PrevPrev && PrevPrev->isOneOf(tok::r_paren, tok::kw_noexcept))
 Tok->setType(TT_CtorInitializerColon);
 } else
@@ -1578,6 +1582,8 @@ class AnnotatingParser {
 if (TemplateCloser->is(tok::l_paren)) {
   // No Matching Paren yet so skip to matching paren
   TemplateCloser = untilMatchingParen(TemplateCloser);
+  if (!TemplateCloser)
+break;
 }
 if (TemplateCloser->is(tok::less))
   NestingLevel++;
@@ -2639,8 +2645,8 @@ void 
TokenAnnotator::calculateFormattingInformation(AnnotatedLine &Line) {
 if (Current->Role)
   Current->Role->precomputeFormattingInfos(Current);
 if (Current->MatchingParen &&
-Current->MatchingParen->opensBlockOrBlockTypeList(Style)) {
-  assert(IndentLevel > 0);
+Current->MatchingParen->opensBlockOrBlockTypeList(Style) &&
+IndentLevel > 0) {
   --IndentLevel;
 }
 Current->IndentLevel = IndentLevel;

diff  --git a/clang/lib/Format/UnwrappedLineParser.cpp 
b/clang/lib/Format/UnwrappedLineParser.cpp
index 28d925858f776..c12c7c6ecfa69 100644
--- a/clang/lib/Format/UnwrappedLineParser.cpp
+++ b/clang/lib/Format/UnwrappedLineParser.cpp
@@ -199,6 +199,8 @@ class IndexedTokenSource : public FormatTokenSource {
   : Tokens(Tokens), Position(-1) {}
 
   FormatToken *getNextToken() override {
+if (Position >= 0 && Tokens[Position]->is(tok::eof))
+  return Tokens[Position];
 ++Position;
 return Tokens[Position];
   }
@@ -399,7 +401,7 @@ void UnwrappedLineParser::parseLevel(bool HasOpeningBrace) {
   FormatToken *Next;
   do {
 Next = Tokens->getNextToken();
-  } while (Next && Next->is(tok::comment));
+  } while (Next->is

[PATCH] D114249: [clang-tidy] performance-unnecessary-copy-initialization: Fix false negative.

2021-11-22 Thread Clement Courbet via Phabricator via cfe-commits
courbet updated this revision to Diff 388821.
courbet added a comment.

rebase


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D114249

Files:
  clang-tools-extra/clang-tidy/performance/UnnecessaryCopyInitialization.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
@@ -24,6 +24,11 @@
   operator int() const; // Implicit conversion to int.
 };
 
+struct ExpensiveToCopyContainer {
+  const ExpensiveToCopyType &operator[](int) const;
+  const ExpensiveToCopyType &operator[](int);
+};
+
 struct TrivialToCopyType {
   const TrivialToCopyType &reference() const;
 };
@@ -138,6 +143,50 @@
   VarCopyConstructed.constMethod();
 }
 
+void PositiveOperatorCallConstReferenceParam(const ExpensiveToCopyContainer 
&C) {
+  const auto AutoAssigned = C[42];
+  // CHECK-MESSAGES: [[@LINE-1]]:14: warning: the const qualified variable 
'AutoAssigned'
+  // CHECK-FIXES: const auto& AutoAssigned = C[42];
+  AutoAssigned.constMethod();
+
+  const auto AutoCopyConstructed(C[42]);
+  // CHECK-MESSAGES: [[@LINE-1]]:14: warning: the const qualified variable 
'AutoCopyConstructed'
+  // CHECK-FIXES: const auto& AutoCopyConstructed(C[42]);
+  AutoCopyConstructed.constMethod();
+
+  const ExpensiveToCopyType VarAssigned = C[42];
+  // CHECK-MESSAGES: [[@LINE-1]]:29: warning: the const qualified variable 
'VarAssigned'
+  // CHECK-FIXES: const ExpensiveToCopyType& VarAssigned = C[42];
+  VarAssigned.constMethod();
+
+  const ExpensiveToCopyType VarCopyConstructed(C[42]);
+  // CHECK-MESSAGES: [[@LINE-1]]:29: warning: the const qualified variable 
'VarCopyConstructed'
+  // CHECK-FIXES: const ExpensiveToCopyType& VarCopyConstructed(C[42]);
+  VarCopyConstructed.constMethod();
+}
+
+void PositiveOperatorCallConstValueParam(const ExpensiveToCopyContainer C) {
+  const auto AutoAssigned = C[42];
+  // CHECK-MESSAGES: [[@LINE-1]]:14: warning: the const qualified variable 
'AutoAssigned'
+  // CHECK-FIXES: const auto& AutoAssigned = C[42];
+  AutoAssigned.constMethod();
+
+  const auto AutoCopyConstructed(C[42]);
+  // CHECK-MESSAGES: [[@LINE-1]]:14: warning: the const qualified variable 
'AutoCopyConstructed'
+  // CHECK-FIXES: const auto& AutoCopyConstructed(C[42]);
+  AutoCopyConstructed.constMethod();
+
+  const ExpensiveToCopyType VarAssigned = C[42];
+  // CHECK-MESSAGES: [[@LINE-1]]:29: warning: the const qualified variable 
'VarAssigned'
+  // CHECK-FIXES: const ExpensiveToCopyType& VarAssigned = C[42];
+  VarAssigned.constMethod();
+
+  const ExpensiveToCopyType VarCopyConstructed(C[42]);
+  // CHECK-MESSAGES: [[@LINE-1]]:29: warning: the const qualified variable 
'VarCopyConstructed'
+  // CHECK-FIXES: const ExpensiveToCopyType& VarCopyConstructed(C[42]);
+  VarCopyConstructed.constMethod();
+}
+
 void PositiveLocalConstValue() {
   const ExpensiveToCopyType Obj;
   const auto UnnecessaryCopy = Obj.reference();
Index: 
clang-tools-extra/clang-tidy/performance/UnnecessaryCopyInitialization.cpp
===
--- clang-tools-extra/clang-tidy/performance/UnnecessaryCopyInitialization.cpp
+++ clang-tools-extra/clang-tidy/performance/UnnecessaryCopyInitialization.cpp
@@ -83,13 +83,19 @@
   // variable being declared. The assumption is that the const reference being
   // returned either points to a global static variable or to a member of the
   // called object.
-  return cxxMemberCallExpr(
-  callee(cxxMethodDecl(
- returns(hasCanonicalType(matchers::isReferenceToConst(
- .bind(MethodDeclId)),
-  on(declRefExpr(to(varDecl().bind(ObjectArgId,
-  thisPointerType(namedDecl(
-  unless(matchers::matchesAnyListedName(ExcludedContainerTypes);
+  const auto MethodDecl =
+  cxxMethodDecl(returns(hasCanonicalType(matchers::isReferenceToConst(
+  .bind(MethodDeclId);
+  const auto ReceiverExpr = declRefExpr(to(varDecl().bind(ObjectArgId)));
+  const auto ReceiverTypeDecl =
+  
namedDecl(unless(matchers::matchesAnyListedName(ExcludedContainerTypes)));
+
+  return expr(anyOf(
+  cxxMemberCallExpr(callee(MethodDecl), on(ReceiverExpr),
+thisPointerType(ReceiverTypeDecl)),
+  cxxOperatorCallExpr(callee(MethodDecl), hasArgument(0, ReceiverExpr),
+  hasArgument(0, hasType(recordType(hasDeclaration(
+ ReceiverTypeDecl)));
 }
 
 AST_MATCHER_FUNCTION(StatementMatcher, isConstRefReturningFunctionCall) {


Index: clang-tools-extra/test/cl

[PATCH] D114249: [clang-tidy] performance-unnecessary-copy-initialization: Fix false negative.

2021-11-22 Thread Clement Courbet via Phabricator via cfe-commits
courbet added inline comments.



Comment at: 
clang-tools-extra/clang-tidy/performance/UnnecessaryCopyInitialization.cpp:97
+  cxxOperatorCallExpr(callee(MethodDecl), hasArgument(0, ReceiverExpr),
+  hasArgument(0, hasType(recordType(hasDeclaration(
+ ReceiverTypeDecl)));

flx wrote:
> Does this work if if the object argument is a pointer or a type alias? Could 
> you add a test to confirm?
It does not work with a pointer. I plan to make it work in a separate cl, but 
first I need to fix `isOnlyUsedAsConst` to make more general (specifically, 
handle unary `*`).



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D114249

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


[clang-tools-extra] a82942d - Add missing clang-tidy args in index.rst (NFC)

2021-11-22 Thread Salman Javed via cfe-commits

Author: Salman Javed
Date: 2021-11-22T22:50:05+13:00
New Revision: a82942dd07ea652081f8f293b73801323a4dbbe9

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

LOG: Add missing clang-tidy args in index.rst (NFC)

The RST docs have gone out of sync with the command-line args that the
clang-tidy program actually supports.

Added: 


Modified: 
clang-tools-extra/docs/clang-tidy/index.rst

Removed: 




diff  --git a/clang-tools-extra/docs/clang-tidy/index.rst 
b/clang-tools-extra/docs/clang-tidy/index.rst
index fa44dab2c76f2..3231b1528efc1 100644
--- a/clang-tools-extra/docs/clang-tidy/index.rst
+++ b/clang-tools-extra/docs/clang-tidy/index.rst
@@ -140,6 +140,12 @@ An overview of all the command-line options:
  When the value is empty, clang-tidy will
  attempt to find a file named .clang-tidy 
for
  each source file in its parent 
directories.
+--config-file= - 
+Specify the path of .clang-tidy or custom 
config file:
+  e.g. 
--config-file=/some/path/myTidyConfigFile
+This option internally works exactly the 
same way as
+  --config option after reading specified 
config file.
+Use either --config-file or --config, not 
both.
 --dump-config  -
  Dumps configuration in the YAML format to
  stdout. This option can be used along 
with a
@@ -160,9 +166,9 @@ An overview of all the command-line options:
  YAML file to store suggested fixes in. The
  stored fixes can be applied to the input 
source
  code with clang-apply-replacements.
---extra-arg=   - Additional argument to append to the 
compiler command line
+--extra-arg=   - Additional argument to append to the 
compiler command line.
  Can be used several times.
---extra-arg-before=- Additional argument to prepend to the 
compiler command line
+--extra-arg-before=- Additional argument to prepend to the 
compiler command line.
  Can be used several times.
 --fix  -
  Apply suggested fixes. Without -fix-errors
@@ -223,6 +229,12 @@ An overview of all the command-line options:
  format to stderr. When this option is 
passed,
  these per-TU profiles are instead stored 
as JSON.
 --system-headers   - Display the errors from system headers.
+--use-color- 
+Use colors in diagnostics. If not set, 
colors
+will be used if the terminal connected to
+standard output supports colors.
+This option overrides the 'UseColor' 
option in
+.clang-tidy file, if any.
 --vfsoverlay=-
  Overlay the virtual filesystem described 
by file
  over the real file system.



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


  1   2   >