[PATCH] D120610: [DebugInfo] Include DW_TAG_skeleton_unit when looking for parent UnitDie

2022-03-11 Thread Wenlei He via Phabricator via cfe-commits
wenlei updated this revision to Diff 414606.
wenlei added a comment.

update test case


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D120610

Files:
  llvm/lib/CodeGen/AsmPrinter/DIE.cpp
  llvm/test/DebugInfo/X86/fission-template.ll


Index: llvm/test/DebugInfo/X86/fission-template.ll
===
--- /dev/null
+++ llvm/test/DebugInfo/X86/fission-template.ll
@@ -0,0 +1,58 @@
+; Check that we handle template types for split-dwarf-inlining without ICE.
+; RUN: llc -split-dwarf-file=%t.dwo -O2 -dwarf-version=5 
-mtriple=x86_64-unknown-linux-gnu -filetype=obj -o %t.o < %s
+;
+; The test case is generated from the following code
+; clang -cc1 -emit-llvm -fdebug-info-for-profiling -fsplit-dwarf-inlining 
-debug-info-kind=constructor -dwarf-version=5 -split-dwarf-file temp.dwo -O2
+;
+; void f1();
+;
+; template 
+; void f2() {
+;   f1();
+; }
+;
+; void f3() {
+;   f2();
+; }
+
+; ModuleID = 'split-debug-inlining-template.cpp'
+source_filename = 
"llvm-project/clang/test/CodeGen/split-debug-inlining-template.cpp"
+target datalayout = 
"e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
+target triple = "x86_64-redhat-linux-gnu"
+
+; Function Attrs: mustprogress nounwind
+define dso_local void @_Z2f3v() local_unnamed_addr #0 !dbg !6 {
+entry:
+  tail call void @_Z2f1v() #2, !dbg !11
+  ret void, !dbg !17
+}
+
+declare !dbg !18 void @_Z2f1v() local_unnamed_addr #1
+
+attributes #0 = { mustprogress nounwind "frame-pointer"="none" 
"min-legal-vector-width"="0" "no-trapping-math"="true" 
"stack-protector-buffer-size"="8" "target-features"="+cx8,+mmx,+sse,+sse2,+x87" 
}
+attributes #1 = { "frame-pointer"="none" "no-trapping-math"="true" 
"stack-protector-buffer-size"="8" "target-features"="+cx8,+mmx,+sse,+sse2,+x87" 
}
+attributes #2 = { nounwind }
+
+!llvm.dbg.cu = !{!0}
+!llvm.module.flags = !{!2, !3, !4}
+!llvm.ident = !{!5}
+
+!0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus_14, file: !1, 
producer: "clang version 15.0.0 (https://github.com/llvm/llvm-project.git 
8b2b9c3fa91ebe583f8c634482885a669b82a1f0)", isOptimized: true, runtimeVersion: 
0, splitDebugFilename: "split-debug-inlining-template.c.tmp.dwo", emissionKind: 
FullDebug, debugInfoForProfiling: true, nameTableKind: None)
+!1 = !DIFile(filename: "llvm-project/clang/test/CodeGen/", directory: 
"build-debug", checksumkind: CSK_MD5, checksum: 
"0fb39b3bb5a60928b5d9c251b2d91b2c")
+!2 = !{i32 7, !"Dwarf Version", i32 5}
+!3 = !{i32 2, !"Debug Info Version", i32 3}
+!4 = !{i32 1, !"wchar_size", i32 4}
+!5 = !{!"clang version 15.0.0 (https://github.com/llvm/llvm-project.git 
8b2b9c3fa91ebe583f8c634482885a669b82a1f0)"}
+!6 = distinct !DISubprogram(name: "f3", linkageName: "_Z2f3v", scope: !7, 
file: !7, line: 11, type: !8, scopeLine: 11, flags: DIFlagPrototyped | 
DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: 
!0, retainedNodes: !10)
+!7 = !DIFile(filename: 
"llvm-project/clang/test/CodeGen/split-debug-inlining-template.cpp", directory: 
"", checksumkind: CSK_MD5, checksum: "0fb39b3bb5a60928b5d9c251b2d91b2c")
+!8 = !DISubroutineType(types: !9)
+!9 = !{null}
+!10 = !{}
+!11 = !DILocation(line: 8, column: 3, scope: !12, inlinedAt: !16)
+!12 = distinct !DISubprogram(name: "f2", linkageName: "_Z2f2IiEvv", 
scope: !7, file: !7, line: 7, type: !8, scopeLine: 7, flags: DIFlagPrototyped | 
DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: 
!0, templateParams: !13, retainedNodes: !10)
+!13 = !{!14}
+!14 = !DITemplateTypeParameter(name: "T", type: !15)
+!15 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
+!16 = distinct !DILocation(line: 12, column: 3, scope: !6)
+!17 = !DILocation(line: 13, column: 1, scope: !6)
+!18 = !DISubprogram(name: "f1", linkageName: "_Z2f1v", scope: !7, file: !7, 
line: 4, type: !8, flags: DIFlagPrototyped, spFlags: DISPFlagOptimized, 
retainedNodes: !10)
Index: llvm/lib/CodeGen/AsmPrinter/DIE.cpp
===
--- llvm/lib/CodeGen/AsmPrinter/DIE.cpp
+++ llvm/lib/CodeGen/AsmPrinter/DIE.cpp
@@ -204,6 +204,7 @@
   const DIE *p = this;
   while (p) {
 if (p->getTag() == dwarf::DW_TAG_compile_unit ||
+p->getTag() == dwarf::DW_TAG_skeleton_unit ||
 p->getTag() == dwarf::DW_TAG_type_unit)
   return p;
 p = p->getParent();


Index: llvm/test/DebugInfo/X86/fission-template.ll
===
--- /dev/null
+++ llvm/test/DebugInfo/X86/fission-template.ll
@@ -0,0 +1,58 @@
+; Check that we handle template types for split-dwarf-inlining without ICE.
+; RUN: llc -split-dwarf-file=%t.dwo -O2 -dwarf-version=5 -mtriple=x86_64-unknown-linux-gnu -filetype=obj -o %t.o < %s
+;
+; The test case is generated from the following code
+; clang -cc1 -emit-llvm -fdebug-info-for-profiling -fsplit-

[PATCH] D120610: [DebugInfo] Include DW_TAG_skeleton_unit when looking for parent UnitDie

2022-03-11 Thread Wenlei He via Phabricator via cfe-commits
wenlei added a comment.

In D120610#3373042 , @dblaikie wrote:

> Fixes in LLVM require tests in LLVM - probably taking the clang test and 
> compiling that to llvm IR (include the original C++ source in a comment in 
> the IR test case) and then testing it in LLVM instead of clang.
>
> Also looks like the test could be simplified a bit more:
>
>   void f1();
>   
>   template 
>   void f2() {
> f1();
>   }
>   
>   void f3() {
> f2();
>   }

Done, thanks.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D120610

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


[PATCH] D121410: Have cpu-specific variants set 'tune-cpu' as an optimization hint

2022-03-11 Thread Phoebe Wang via Phabricator via cfe-commits
pengfei added a comment.

Typos in `wiht different feature lists` and `In the even that`.




Comment at: clang/lib/CodeGen/CodeGenModule.cpp:2067
+  // favor this processor.
+  TuneCPU = SD->getCPUName(GD.getMultiVersionIndex())->getName();
+}

erichkeane wrote:
> andrew.w.kaylor wrote:
> > Unfortunately, I don't think it's this easy. The list of names used for 
> > cpu_specific doesn't come from the same place as the list of names used by 
> > "tune-cpu". For one thing, the cpu_specific names can't contain the '-' 
> > character, so we have names like "skylake_avx512" in cpu_specific that 
> > would need to be translated to "skylake-avx512" for "tune-cpu". I believe 
> > the list of valid names for "tune-cpu" comes from here: 
> > https://github.com/llvm/llvm-project/blob/26cd258420c774254cc48330b1f4d23d353baf05/llvm/lib/Support/X86TargetParser.cpp#L294
> > 
> > Also, some of the aliases supported by cpu_specific don't have any 
> > corresponding "tune-cpu" name. You happen to have picked one of these for 
> > the test. I believe "core_4th_gen_avx" should map to "haswell".
> Hmm... this is unfortunate.  I wonder if we add some 'translation' type field 
> to the X86TargetParser.def entries?  Any idea who the right one to populate 
> said list would be?
> I believe the list of valid names for "tune-cpu" comes from ...

I think it's here 
https://github.com/llvm/llvm-project/blob/26cd258420c774254cc48330b1f4d23d353baf05/llvm/lib/Target/X86/X86.td#L1408

So back to Andy's problems, where we consume the cpu_specific names in compiler 
previously, e.g., mapping to different targets? Or it is done by external 
libraries like compiler-rt?

I think I have the same requirments that mapping `-` and `_` for "tune-cpu" in 
https://github.com/llvm/llvm-project/issues/50125 where the preprocessor 
defines use `_` as well.


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

https://reviews.llvm.org/D121410

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


[PATCH] D121450: [clang-format] Handle attributes before case label.

2022-03-11 Thread Marek Kurdej via Phabricator via cfe-commits
curdeius created this revision.
curdeius added reviewers: MyDeveloperDay, HazardyKnusperkeks, owenpan.
Herald added a project: All.
curdeius requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Fixes https://github.com/llvm/llvm-project/issues/53110.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D121450

Files:
  clang/lib/Format/UnwrappedLineParser.cpp
  clang/lib/Format/UnwrappedLineParser.h
  clang/unittests/Format/FormatTest.cpp

Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -2602,6 +2602,52 @@
"}",
getLLVMStyleWithColumns(34));
 
+  verifyFormat("switch (a) {\n"
+   "[[likely]] case 1:\n"
+   "  return;\n"
+   "}");
+  verifyFormat("switch (a) {\n"
+   "[[likely]] [[other::likely]] case 1:\n"
+   "  return;\n"
+   "}");
+  verifyFormat("switch (x) {\n"
+   "case 1:\n"
+   "  return;\n"
+   "[[likely]] case 2:\n"
+   "  return;\n"
+   "}");
+  verifyFormat("switch (a) {\n"
+   "case 1:\n"
+   "[[likely]] case 2:\n"
+   "  return;\n"
+   "}");
+  FormatStyle Attributes = getLLVMStyle();
+  Attributes.AttributeMacros.push_back("LIKELY");
+  Attributes.AttributeMacros.push_back("OTHER_LIKELY");
+  verifyFormat("switch (a) {\n"
+   "LIKELY case b:\n"
+   "  return;\n"
+   "}",
+   Attributes);
+  verifyFormat("switch (a) {\n"
+   "LIKELY OTHER_LIKELY() case b:\n"
+   "  return;\n"
+   "}",
+   Attributes);
+  verifyFormat("switch (a) {\n"
+   "case 1:\n"
+   "  return;\n"
+   "LIKELY case 2:\n"
+   "  return;\n"
+   "}",
+   Attributes);
+  verifyFormat("switch (a) {\n"
+   "case 1:\n"
+   "LIKELY case 2:\n"
+   "  return;\n"
+   "}",
+   Attributes);
+
   FormatStyle Style = getLLVMStyle();
   Style.IndentCaseLabels = true;
   Style.AllowShortBlocksOnASingleLine = FormatStyle::SBS_Never;
Index: clang/lib/Format/UnwrappedLineParser.h
===
--- clang/lib/Format/UnwrappedLineParser.h
+++ clang/lib/Format/UnwrappedLineParser.h
@@ -122,6 +122,8 @@
   void keepAncestorBraces();
   void parseUnbracedBody(bool CheckEOF = false);
   FormatToken *parseIfThenElse(IfStmtKind *IfKind, bool KeepBraces = false);
+  void handleAttributes();
+  bool handleCppAttributes();
   void parseTryCatch();
   void parseForOrWhileLoop();
   void parseDoWhile();
Index: clang/lib/Format/UnwrappedLineParser.cpp
===
--- clang/lib/Format/UnwrappedLineParser.cpp
+++ clang/lib/Format/UnwrappedLineParser.cpp
@@ -480,6 +480,10 @@
   unsigned StatementCount = 0;
   bool SwitchLabelEncountered = false;
   do {
+if (FormatTok->getType() == TT_AttributeMacro) {
+  nextToken();
+  continue;
+}
 tok::TokenKind kind = FormatTok->Tok.getKind();
 if (FormatTok->getType() == TT_MacroBlockBegin)
   kind = tok::l_brace;
@@ -569,6 +573,9 @@
 parseCSharpAttribute();
 break;
   }
+  if (handleCppAttributes())
+break;
+
   LLVM_FALLTHROUGH;
 default:
   ParseDefault();
@@ -1390,9 +1397,11 @@
 // e.g. "default void f() {}" in a Java interface.
 break;
   case tok::kw_case:
-if (Style.isJavaScript() && Line->MustBeDeclaration)
+if (Style.isJavaScript() && Line->MustBeDeclaration) {
   // 'case: string' field declaration.
+  nextToken();
   break;
+}
 parseCaseLabel();
 return;
   case tok::kw_try:
@@ -1813,6 +1822,12 @@
 case tok::kw_new:
   parseNew();
   break;
+case tok::kw_case:
+  if (Style.isJavaScript() && Line->MustBeDeclaration)
+// 'case: string' field declaration.
+break;
+  parseCaseLabel();
+  break;
 default:
   nextToken();
   break;
@@ -2376,17 +2391,24 @@
   RightBrace->Optional = true;
 }
 
+void UnwrappedLineParser::handleAttributes() {
+  // Handle AttributeMacro, e.g. `if (x) UNLIKELY`.
+  if (FormatTok->is(TT_AttributeMacro))
+nextToken();
+  handleCppAttributes();
+}
+
+bool UnwrappedLineParser::handleCppAttributes() {
+  // Handle [[likely]] / [[unlikely]] attributes.
+  if (FormatTok->is(tok::l_square) && tryToParseSimpleAttribute()) {
+parseSquare();
+return true;
+  }
+  return false;
+}
+
 FormatToken *UnwrappedLineParser::parseIfThenElse(IfStmtKind *IfKind,
   bool KeepBraces) {
-  auto HandleAttributes = [this]() {
-// Hand

[clang] 788e0f7 - [clang-repl] Add an accessor to our underlying execution engine

2022-03-11 Thread Vassil Vassilev via cfe-commits

Author: Vassil Vassilev
Date: 2022-03-11T09:24:47Z
New Revision: 788e0f7f3e96a9d61c2412e452c4589e2693b79a

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

LOG: [clang-repl] Add an accessor to our underlying execution engine

This patch will allow better incremental adoption of these changes in downstream
cling and other users which want to experiment by customizing the execution
engine.

Added: 


Modified: 
clang/include/clang/Interpreter/Interpreter.h
clang/lib/Interpreter/IncrementalExecutor.h
clang/lib/Interpreter/Interpreter.cpp

Removed: 




diff  --git a/clang/include/clang/Interpreter/Interpreter.h 
b/clang/include/clang/Interpreter/Interpreter.h
index 721a649deb43b..f2fdb90f5ba48 100644
--- a/clang/include/clang/Interpreter/Interpreter.h
+++ b/clang/include/clang/Interpreter/Interpreter.h
@@ -26,6 +26,7 @@
 
 namespace llvm {
 namespace orc {
+class LLJIT;
 class ThreadSafeContext;
 }
 } // namespace llvm
@@ -56,6 +57,7 @@ class Interpreter {
   static llvm::Expected>
   create(std::unique_ptr CI);
   const CompilerInstance *getCompilerInstance() const;
+  const llvm::orc::LLJIT *getExecutionEngine() const;
   llvm::Expected Parse(llvm::StringRef Code);
   llvm::Error Execute(PartialTranslationUnit &T);
   llvm::Error ParseAndExecute(llvm::StringRef Code) {

diff  --git a/clang/lib/Interpreter/IncrementalExecutor.h 
b/clang/lib/Interpreter/IncrementalExecutor.h
index 24447994d5f1d..51b4d83d10b1c 100644
--- a/clang/lib/Interpreter/IncrementalExecutor.h
+++ b/clang/lib/Interpreter/IncrementalExecutor.h
@@ -45,6 +45,7 @@ class IncrementalExecutor {
   llvm::Error runCtors() const;
   llvm::Expected
   getSymbolAddress(llvm::StringRef Name, SymbolNameKind NameKind) const;
+  llvm::orc::LLJIT *getExecutionEngine() const { return Jit.get(); }
 };
 
 } // end namespace clang

diff  --git a/clang/lib/Interpreter/Interpreter.cpp 
b/clang/lib/Interpreter/Interpreter.cpp
index b2e7727be39a0..470c9c289a749 100644
--- a/clang/lib/Interpreter/Interpreter.cpp
+++ b/clang/lib/Interpreter/Interpreter.cpp
@@ -196,6 +196,12 @@ const CompilerInstance *Interpreter::getCompilerInstance() 
const {
   return IncrParser->getCI();
 }
 
+const llvm::orc::LLJIT *Interpreter::getExecutionEngine() const {
+  if (IncrExecutor)
+return IncrExecutor->getExecutionEngine();
+  return nullptr;
+}
+
 llvm::Expected
 Interpreter::Parse(llvm::StringRef Code) {
   return IncrParser->Parse(Code);



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


[PATCH] D120465: [clang][deps] Disable implicit module maps

2022-03-11 Thread Jan Svoboda via Phabricator via cfe-commits
jansvoboda11 added inline comments.



Comment at: clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp:269-273
+  // However, some module maps loaded implicitly during the dependency scan can
+  // describe anti-dependencies. That happens when the current module is marked
+  // as '[no_undeclared_includes]', doesn't 'use' module from such module map,
+  // but tries to import it anyway. We need to tell the explicit build about
+  // such module map for it to have the same semantics as the implicit build.

dexonsmith wrote:
> jansvoboda11 wrote:
> > dexonsmith wrote:
> > > Is there another long-term solution to this that could be pointed at with 
> > > a FIXME? E.g., could the module map be encoded redundantly here? If so, 
> > > what else would need to change to make that okay?
> > I'm not sure I understand why this would warrant "long-term solution" or a 
> > FIXME. This code handles an existing feature that just happens to be a 
> > corner case from the dependency scanning point of view. (You can read up on 
> > the feature [[ https://clang.llvm.org/docs/Modules.html | here ]].)
> > 
> > What do you mean by encoding the module map redundantly?
> Yes, I know the feature.
> 
> ... but I was probably wrong about how it affects the logic here.
> 
> I also now have two guesses at the scenario being handled here (previously I 
> assumed (1)):
> 
> 1. A textual include from a module that is not marked as used. I wasn't sure 
> what you meant by "tries to import", but I guess I thought it was just "loads 
> the module map and finds the textual header listed there". IIUC, there's no 
> actual attempt to import a module when the only thing referenced from it is a 
> textual header, but I could see how parsing the module map could affect the 
> state anyway.
> 
> 2. A modular include from a module that is not marked as used. Something like 
> a `__has_include`, or a `#include` that fails but there's another search path 
> with the same header. In this case, there'd be an actual import attempt, 
> which would fail. And that could also affect state.
> 
> Can you clarify which scenario you need to handle? Or is it a 3rd?
> 
> > I'm not sure I understand why this would warrant "long-term solution" or a 
> > FIXME.
> 
> This smells like a workaround to me. IIUC, sending in module maps that aren't 
> actually "needed" except to reproduce side effects of failed queries.
> 
> My intuition is that the right long-term fix would involve isolate the failed 
> queries from the compiler state in the scanning phase so that they don't have 
> side effects. Then there would be no side effects to reproduce in the 
> explicit build.
> 
> > What do you mean by encoding the module map redundantly?
> 
> I think I was confused about scanning vs building, thinking that a module 
> using a textual include (1) could be copied into each module PCM that 
> directly imports it. (I know that this wouldn't scale right now for various 
> reasons, but I wondered if there was some way to get there... but regardless, 
> seems like it's totally unrelated)
The scenario being handled is the following:

3. Modular `#include` of B from module A, where A is marked 
`[no_undeclared_includes]` and doesn't `use B`. Typically, that `#include` 
would be guarded by `__has_include`.

With implicit module maps disabled, the presence of module map B allows us to 
evaluate the `__has_include` the same way as with them enabled. This is the 
only reason we need module map B. There are no side effects from failed 
queries. The query failure itself is the behavior we need to reproduce.

I'm not even thinking about "another search path with the same header" in this 
patch.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D120465

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


[PATCH] D121451: [clang-format] Add space to comments starting with '#'.

2022-03-11 Thread Marek Kurdej via Phabricator via cfe-commits
curdeius created this revision.
curdeius added reviewers: MyDeveloperDay, HazardyKnusperkeks, owenpan.
Herald added a project: All.
curdeius requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Fixes https://github.com/llvm/llvm-project/issues/35116.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D121451

Files:
  clang/lib/Format/BreakableToken.cpp
  clang/unittests/Format/FormatTestComments.cpp


Index: clang/unittests/Format/FormatTestComments.cpp
===
--- clang/unittests/Format/FormatTestComments.cpp
+++ clang/unittests/Format/FormatTestComments.cpp
@@ -91,6 +91,9 @@
"// line 2\n"
"void f() {}\n");
 
+  EXPECT_EQ("// comment\n", format("//comment\n"));
+  EXPECT_EQ("// #comment\n", format("//#comment\n"));
+
   EXPECT_EQ("// comment\n"
 "// clang-format on\n",
 format("//comment\n"
Index: clang/lib/Format/BreakableToken.cpp
===
--- clang/lib/Format/BreakableToken.cpp
+++ clang/lib/Format/BreakableToken.cpp
@@ -779,11 +779,14 @@
 const char FirstCommentChar = Lines[i][IndentPrefix.size()];
 const unsigned FirstCharByteSize =
 encoding::getCodePointNumBytes(FirstCommentChar, Encoding);
-return encoding::columnWidth(
-   Lines[i].substr(IndentPrefix.size(), FirstCharByteSize),
-   Encoding) == 1 &&
-   (FirstCommentChar == '\\' || isPunctuation(FirstCommentChar) ||
-isHorizontalWhitespace(FirstCommentChar));
+if (encoding::columnWidth(
+Lines[i].substr(IndentPrefix.size(), FirstCharByteSize),
+Encoding) != 1)
+  return false;
+if (FirstCommentChar == '#')
+  return false;
+return FirstCommentChar == '\\' || isPunctuation(FirstCommentChar) ||
+   isHorizontalWhitespace(FirstCommentChar);
   };
 
   // On the first line of the comment section we calculate how many spaces


Index: clang/unittests/Format/FormatTestComments.cpp
===
--- clang/unittests/Format/FormatTestComments.cpp
+++ clang/unittests/Format/FormatTestComments.cpp
@@ -91,6 +91,9 @@
"// line 2\n"
"void f() {}\n");
 
+  EXPECT_EQ("// comment\n", format("//comment\n"));
+  EXPECT_EQ("// #comment\n", format("//#comment\n"));
+
   EXPECT_EQ("// comment\n"
 "// clang-format on\n",
 format("//comment\n"
Index: clang/lib/Format/BreakableToken.cpp
===
--- clang/lib/Format/BreakableToken.cpp
+++ clang/lib/Format/BreakableToken.cpp
@@ -779,11 +779,14 @@
 const char FirstCommentChar = Lines[i][IndentPrefix.size()];
 const unsigned FirstCharByteSize =
 encoding::getCodePointNumBytes(FirstCommentChar, Encoding);
-return encoding::columnWidth(
-   Lines[i].substr(IndentPrefix.size(), FirstCharByteSize),
-   Encoding) == 1 &&
-   (FirstCommentChar == '\\' || isPunctuation(FirstCommentChar) ||
-isHorizontalWhitespace(FirstCommentChar));
+if (encoding::columnWidth(
+Lines[i].substr(IndentPrefix.size(), FirstCharByteSize),
+Encoding) != 1)
+  return false;
+if (FirstCommentChar == '#')
+  return false;
+return FirstCommentChar == '\\' || isPunctuation(FirstCommentChar) ||
+   isHorizontalWhitespace(FirstCommentChar);
   };
 
   // On the first line of the comment section we calculate how many spaces
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D121451: [clang-format] Add space to comments starting with '#'.

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

I'm not sure whether we should consider this a breaking change, there were no 
tests at all verifying this behaviour.
I think that not adding a space in comments starting with a punctuation is a 
mistake unless for some special comments like `///`, `//!` etc. (which are 
handled separately anyway).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D121451

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


[PATCH] D121445: [Clang][CSKY] Add the CSKY target and compiler driver

2022-03-11 Thread Renato Golin via Phabricator via cfe-commits
rengolin added a comment.

I don't know enough about your toolchain requirements, but this looks good to 
me.

Please check the clang-format warnings. If you did pass clang-format, perhaps 
you need to upgrade to a newer one?

I won't approve just yet, to let other people review it also.




Comment at: clang/test/Driver/csky-arch.c:26
+
+// RUN: %clang -target csky-unknown-elf -march=csky -### %s \
+// RUN: -fsyntax-only 2>&1 | FileCheck -check-prefix=CSKY %s

I don't think this is doing what you expect it to do.

Depending on the output, you can still match all CHECK lines and not have the 
output you want.

To avoid issues, we usually separate tests that must pass (positive tests) like 
the lines above 24, from tests that must fail (negative tests) like the lines 
below.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D121445

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


[PATCH] D121076: [MLIR][Python] Add SCFIfOp Python binding

2022-03-11 Thread Alex Zinenko via Phabricator via cfe-commits
ftynse accepted this revision.
ftynse added a comment.

Thanks! Let me know if you need help landing this.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D121076

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


[PATCH] D107141: [Inline-asm] Add diagnosts for unsupported inline assembly arguments

2022-03-11 Thread Phoebe Wang via Phabricator via cfe-commits
pengfei updated this revision to Diff 414614.
pengfei added a comment.

Address review comments.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D107141

Files:
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/CodeGen/CGStmt.cpp
  clang/lib/Sema/SemaStmtAsm.cpp
  clang/test/Sema/asm.c

Index: clang/test/Sema/asm.c
===
--- clang/test/Sema/asm.c
+++ clang/test/Sema/asm.c
@@ -313,3 +313,51 @@
   asm ("jne %l0":::);
   asm goto ("jne %l0"lab);
 }
+
+typedef struct _st_size64 {
+  int a;
+  char b;
+} st_size64;
+
+typedef struct _st_size96 {
+  int a;
+  int b;
+  int c;
+} st_size96;
+
+typedef struct _st_size16 {
+  char a;
+  char b;
+} st_size16;
+
+typedef struct _st_size32 {
+  char a;
+  char b;
+  char c;
+  char d;
+} st_size32;
+
+typedef struct _st_size128 {
+  int a;
+  int b;
+  int c;
+  int d;
+} st_size128;
+
+void test19(long long x)
+{
+  st_size64 a;
+  st_size96 b;
+  st_size16 c;
+  st_size32 d;
+  st_size128 e;
+  asm ("" : "=rm" (a): "0" (1)); // no-error
+  asm ("" : "=rm" (d): "0" (1)); // no-error
+  asm ("" : "=rm" (c): "0" (x)); // no-error
+  asm ("" : "=rm" (x): "0" (a)); // no-error
+  asm ("" : "=rm" (a): "0" (d)); // no-error
+  // Check the output size is pow of 2
+  asm ("" : "=rm" (b): "0" (1)); // expected-error {{impossible constraint in asm: can't store value into a register}}
+  asm ("" : "=rm" (e): "0" (1)); // no-error
+  asm ("" : "=rm" (x): "0" (e)); // no-error
+}
Index: clang/lib/Sema/SemaStmtAsm.cpp
===
--- clang/lib/Sema/SemaStmtAsm.cpp
+++ clang/lib/Sema/SemaStmtAsm.cpp
@@ -618,14 +618,16 @@
   AD_Int, AD_FP, AD_Other
 } InputDomain, OutputDomain;
 
-if (InTy->isIntegerType() || InTy->isPointerType())
+if (InTy->isIntegerType() || InTy->isPointerType() ||
+InTy->isStructureType())
   InputDomain = AD_Int;
 else if (InTy->isRealFloatingType())
   InputDomain = AD_FP;
 else
   InputDomain = AD_Other;
 
-if (OutTy->isIntegerType() || OutTy->isPointerType())
+if (OutTy->isIntegerType() || OutTy->isPointerType() ||
+OutTy->isStructureType())
   OutputDomain = AD_Int;
 else if (OutTy->isRealFloatingType())
   OutputDomain = AD_FP;
@@ -667,8 +669,17 @@
 // output was a register, just extend the shorter one to the size of the
 // larger one.
 if (!SmallerValueMentioned && InputDomain != AD_Other &&
-OutputConstraintInfos[TiedTo].allowsRegister())
+OutputConstraintInfos[TiedTo].allowsRegister()) {
+  // FIXME: GCC supports the OutSize to be 128 at maximum. Currently codegen
+  // crash when the size larger than the register size. So we limit it here.
+  if (OutputDomain == AD_Int &&
+  Context.getIntTypeForBitwidth(OutSize, /*Signed*/ false).isNull()) {
+targetDiag(OutputExpr->getExprLoc(), diag::err_store_value_to_reg);
+return NS;
+  }
+
   continue;
+}
 
 // Either both of the operands were mentioned or the smaller one was
 // mentioned.  One more special case that we'll allow: if the tied input is
Index: clang/lib/CodeGen/CGStmt.cpp
===
--- clang/lib/CodeGen/CGStmt.cpp
+++ clang/lib/CodeGen/CGStmt.cpp
@@ -2725,9 +2725,8 @@
   QualType Ty = getContext().getIntTypeForBitwidth(Size, /*Signed*/ false);
   if (Ty.isNull()) {
 const Expr *OutExpr = S.getOutputExpr(i);
-CGM.Error(
-OutExpr->getExprLoc(),
-"impossible constraint in asm: can't store value into a register");
+CGM.getDiags().Report(OutExpr->getExprLoc(),
+  diag::err_store_value_to_reg);
 return;
   }
   Dest = MakeAddrLValue(A, Ty);
Index: clang/include/clang/Basic/DiagnosticSemaKinds.td
===
--- clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -8763,6 +8763,8 @@
 " in asm %select{input|output}1 with a memory constraint '%2'">;
   def err_asm_input_duplicate_match : Error<
 "more than one input constraint matches the same output '%0'">;
+  def err_store_value_to_reg : Error<
+"impossible constraint in asm: can't store value into a register">;
 
   def warn_asm_label_on_auto_decl : Warning<
 "ignored asm label '%0' on automatic variable">;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D107141: [Inline-asm] Add diagnosts for unsupported inline assembly arguments

2022-03-11 Thread Phoebe Wang via Phabricator via cfe-commits
pengfei added inline comments.



Comment at: clang/lib/Sema/SemaStmtAsm.cpp:622
+if (InTy->isIntegerType() || InTy->isPointerType() ||
+InTy->isStructureType() || InTy->isConstantArrayType())
   InputDomain = AD_Int;

jyu2 wrote:
> Are you sure you want to change the Input/output Domain?  Since you changed 
> this, could you add both codegen and sema check tests for  struct type(you 
> already has sema check for struct type, but I don't see any array type) and 
> array type.  
> 
> Thanks.
> Jennifer
The input / output domain are just for sema check here. I don't think it 
changes codegen behavior.



Comment at: clang/lib/Sema/SemaStmtAsm.cpp:677
+  Context.getIntTypeForBitwidth(OutSize, /*Signed*/ false).isNull())
+targetDiag(OutputExpr->getExprLoc(), diag::err_store_value_to_reg);
+

jyu2 wrote:
> Do you need return NS after diagnostic?
Good catch!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D107141

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


[PATCH] D121387: [analyzer] ClangSA should tablegen doc urls refering to the main doc page

2022-03-11 Thread Kristóf Umann via Phabricator via cfe-commits
Szelethus accepted this revision.
Szelethus added a comment.
This revision is now accepted and ready to land.

Nice!




Comment at: clang/utils/TableGen/ClangSACheckersEmitter.cpp:27
 
-static std::string getPackageFullName(const Record *R);
+static std::string getPackageFullName(const Record *R, StringRef Sep = ".");
 

~~Do you foresee a change in the default separator? I think an eventual shift 
away from packages is more likely (see 
https://discourse.llvm.org/t/analyzer-refactoring-analyzeroptions/50160/5). ~~

~~I this an unnecessary complexity, but its not a hill I will die on.~~

edit: I just realized that you need this for the url, so never mind. I grave 
dug a 3 yr old topic on discourse because of it :^) Oops.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D121387

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


[PATCH] D121445: [Clang][CSKY] Add the CSKY target and compiler driver

2022-03-11 Thread David Spickett via Phabricator via cfe-commits
DavidSpickett added inline comments.



Comment at: clang/lib/Basic/Targets/CSKY.cpp:43
+  Builder.defineMacro("__CSKYABI__", ABI == "abiv2" ? "2" : "1");
+  Builder.defineMacro("__cskyabi__", ABI == "abiv2" ? "2" : "1");
+

Any need to handle when ABI is not avbiv2 or abiv1 or will it always be one of 
the two?



Comment at: clang/lib/Driver/ToolChains/Linux.cpp:373
+
+std::string Path = (GCCInstallation.getInstallPath() + "/../../../../" +
+GCCInstallation.getTriple().str() + "/libc").str();

Can you comment what all the `..` are going to/from. I assume from some deep 
folder back up, down into the sysroot but an example in a comment would be good 
to document it.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D121445

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


[clang] 6c5da88 - [AArch64][SVE][Clang] Fix crash for incorrect svptrue and svcnt parameters

2022-03-11 Thread Matt Devereau via cfe-commits

Author: Matt Devereau
Date: 2022-03-11T11:19:53Z
New Revision: 6c5da880e03cafc49008612eb687910f3f805057

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

LOG: [AArch64][SVE][Clang] Fix crash for incorrect svptrue and svcnt parameters

Giving an int parameter to SVE intrinsics svptrue and svcnt caused Clang
to crash on compilation. Changing their parameter types to void instead of
omitting args results in a diagnostic error message instead.

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

Added: 
clang/test/CodeGen/aarch64-sve-intrinsics/negative/acle_sve_svcnt.c
clang/test/CodeGen/aarch64-sve-intrinsics/negative/acle_sve_svptrue.c

Modified: 
clang/include/clang/Basic/arm_sve.td

Removed: 




diff  --git a/clang/include/clang/Basic/arm_sve.td 
b/clang/include/clang/Basic/arm_sve.td
index 5e9d1c96558b9..220b830c368fe 100644
--- a/clang/include/clang/Basic/arm_sve.td
+++ b/clang/include/clang/Basic/arm_sve.td
@@ -1263,10 +1263,10 @@ def SVZIP2_B  : SInst<"svzip2_{d}", "PPP",  
"PcPsPiPl", MergeNone, "aarch64_
 

 // Predicate creation
 
-def SVPFALSE : SInst<"svpfalse[_b]", "P", "", MergeNone, "", [IsOverloadNone]>;
+def SVPFALSE : SInst<"svpfalse[_b]", "Pv", "", MergeNone, "", 
[IsOverloadNone]>;
 
 def SVPTRUE_PAT : SInst<"svptrue_pat_{d}", "PI", "PcPsPiPl", MergeNone, 
"aarch64_sve_ptrue">;
-def SVPTRUE : SInst<"svptrue_{d}", "P",  "PcPsPiPl", MergeNone, 
"aarch64_sve_ptrue", [IsAppendSVALL]>;
+def SVPTRUE : SInst<"svptrue_{d}", "Pv",  "PcPsPiPl", MergeNone, 
"aarch64_sve_ptrue", [IsAppendSVALL]>;
 
 def SVDUPQ_B8  : SInst<"svdupq[_n]_{d}",  "P",  "Pc", 
MergeNone>;
 def SVDUPQ_B16 : SInst<"svdupq[_n]_{d}", "P",  "Ps", MergeNone>;
@@ -1309,9 +1309,9 @@ def SVPTEST_LAST  : SInst<"svptest_last",  "sPP", "Pc", 
MergeNone, "aarch64_sve_
 

 // FFR manipulation
 
-def SVRDFFR   : SInst<"svrdffr",   "P",  "Pc", MergeNone, "", 
[IsOverloadNone]>;
+def SVRDFFR   : SInst<"svrdffr",   "Pv",  "Pc", MergeNone, "", 
[IsOverloadNone]>;
 def SVRDFFR_Z : SInst<"svrdffr_z", "PP", "Pc", MergeNone, "", 
[IsOverloadNone]>;
-def SVSETFFR  : SInst<"svsetffr",  "v",  "",   MergeNone, "", 
[IsOverloadNone]>;
+def SVSETFFR  : SInst<"svsetffr",  "vv",  "",   MergeNone, "", 
[IsOverloadNone]>;
 def SVWRFFR   : SInst<"svwrffr",   "vP", "Pc", MergeNone, "", 
[IsOverloadNone]>;
 
 

@@ -1322,10 +1322,10 @@ def SVCNTH_PAT : SInst<"svcnth_pat", "nI", "", 
MergeNone, "aarch64_sve_cnth", [I
 def SVCNTW_PAT : SInst<"svcntw_pat", "nI", "", MergeNone, "aarch64_sve_cntw", 
[IsOverloadNone]>;
 def SVCNTD_PAT : SInst<"svcntd_pat", "nI", "", MergeNone, "aarch64_sve_cntd", 
[IsOverloadNone]>;
 
-def SVCNTB : SInst<"svcntb", "n", "", MergeNone, "aarch64_sve_cntb", 
[IsAppendSVALL, IsOverloadNone]>;
-def SVCNTH : SInst<"svcnth", "n", "", MergeNone, "aarch64_sve_cnth", 
[IsAppendSVALL, IsOverloadNone]>;
-def SVCNTW : SInst<"svcntw", "n", "", MergeNone, "aarch64_sve_cntw", 
[IsAppendSVALL, IsOverloadNone]>;
-def SVCNTD : SInst<"svcntd", "n", "", MergeNone, "aarch64_sve_cntd", 
[IsAppendSVALL, IsOverloadNone]>;
+def SVCNTB : SInst<"svcntb", "nv", "", MergeNone, "aarch64_sve_cntb", 
[IsAppendSVALL, IsOverloadNone]>;
+def SVCNTH : SInst<"svcnth", "nv", "", MergeNone, "aarch64_sve_cnth", 
[IsAppendSVALL, IsOverloadNone]>;
+def SVCNTW : SInst<"svcntw", "nv", "", MergeNone, "aarch64_sve_cntw", 
[IsAppendSVALL, IsOverloadNone]>;
+def SVCNTD : SInst<"svcntd", "nv", "", MergeNone, "aarch64_sve_cntd", 
[IsAppendSVALL, IsOverloadNone]>;
 
 def SVCNTP : SInst<"svcntp_{d}",  "nPP", "PcPsPiPl",MergeNone, 
"aarch64_sve_cntp">;
 def SVLEN  : SInst<"svlen[_{d}]", "nd",  "csilUcUsUiUlhfd", MergeNone>;
@@ -1435,20 +1435,20 @@ def SVZIP2Q_BF16  : SInst<"svzip2q[_{d}]", 
"ddd",  "b", MergeNone, "aarc
 
 

 // Vector creation
-def SVUNDEF_1 : SInst<"svundef_{d}",  "d", "csilUcUsUiUlhfd", MergeNone, "", 
[IsUndef]>;
-def SVUNDEF_2 : SInst<"svundef2_{d}", "2", "csilUcUsUiUlhfd", MergeNone, "", 
[IsUndef]>;
-def SVUNDEF_3 : SInst<"svundef3_{d}", "3", "csilUcUsUiUlhfd", MergeNone, "", 
[IsUndef]>;
-def SVUNDEF_4 : SInst<"svundef4_{d}", "4", "csilUcUsUiUlhfd", MergeNone, "", 
[IsUndef]>;
+def SVUNDEF_1 : SInst<"svundef_{d}",  "dv", "csilUcUsUiUlhfd", MergeNone, "", 
[IsUndef]>;
+def SVUNDEF_2 : SInst<"svundef2_{d}", "2v", "csilUcUsUiUlhfd", MergeNone, "", 
[IsUndef]>;
+def SVUNDEF_3 : SInst<"svundef3_{d}", "3v", "csilUcUsUiUlhfd", MergeNone, "", 
[IsUnde

[PATCH] D121294: [AArch64][SVE][Clang] Fix crash for incorrect svptrue and svcnt parameters

2022-03-11 Thread Matt Devereau via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG6c5da880e03c: [AArch64][SVE][Clang] Fix crash for incorrect 
svptrue and svcnt parameters (authored by MattDevereau).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D121294

Files:
  clang/include/clang/Basic/arm_sve.td
  clang/test/CodeGen/aarch64-sve-intrinsics/negative/acle_sve_svcnt.c
  clang/test/CodeGen/aarch64-sve-intrinsics/negative/acle_sve_svptrue.c

Index: clang/test/CodeGen/aarch64-sve-intrinsics/negative/acle_sve_svptrue.c
===
--- /dev/null
+++ clang/test/CodeGen/aarch64-sve-intrinsics/negative/acle_sve_svptrue.c
@@ -0,0 +1,33 @@
+// REQUIRES: aarch64-registered-target
+
+// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve -fallow-half-arguments-and-returns -fsyntax-only -verify %s
+// RUN: %clang_cc1 -DSVE_OVERLOADED_FORMS -triple aarch64-none-linux-gnu -target-feature +sve -fallow-half-arguments-and-returns -fsyntax-only -verify %s
+
+#ifdef SVE_OVERLOADED_FORMS
+// A simple used,unused... macro, long enough to represent any SVE builtin.
+#define SVE_ACLE_FUNC(A1, A2_UNUSED, A3, A4_UNUSED) A1##A3
+#else
+#define SVE_ACLE_FUNC(A1, A2, A3, A4) A1##A2##A3##A4
+#endif
+
+#include 
+
+svbool_t test_svptrue_b8() {
+  // expected-error-re@+1 {{too many arguments to function call, expected {{0}}, have {{1
+  return SVE_ACLE_FUNC(svptrue, , _b8, )(1);
+}
+
+svbool_t test_svptrue_b32() {
+  // expected-error-re@+1 {{too many arguments to function call, expected {{0}}, have {{1
+  return SVE_ACLE_FUNC(svptrue, , _b32, )(2);
+}
+
+svbool_t test_svptrue_b64() {
+  // expected-error-re@+1 {{too many arguments to function call, expected {{0}}, have {{1
+  return SVE_ACLE_FUNC(svptrue, , _b64, )(3);
+}
+
+svbool_t test_svptrue_b16() {
+  // expected-error-re@+1 {{too many arguments to function call, expected {{0}}, have {{1
+  return SVE_ACLE_FUNC(svptrue, , _b16, )(4);
+}
Index: clang/test/CodeGen/aarch64-sve-intrinsics/negative/acle_sve_svcnt.c
===
--- /dev/null
+++ clang/test/CodeGen/aarch64-sve-intrinsics/negative/acle_sve_svcnt.c
@@ -0,0 +1,33 @@
+// REQUIRES: aarch64-registered-target
+
+// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve -fallow-half-arguments-and-returns -fsyntax-only -verify %s
+// RUN: %clang_cc1 -DSVE_OVERLOADED_FORMS -triple aarch64-none-linux-gnu -target-feature +sve -fallow-half-arguments-and-returns -fsyntax-only -verify %s
+
+#ifdef SVE_OVERLOADED_FORMS
+// A simple used,unused... macro, long enough to represent any SVE builtin.
+#define SVE_ACLE_FUNC(A1, A2_UNUSED, A3, A4_UNUSED) A1##A3
+#else
+#define SVE_ACLE_FUNC(A1, A2, A3, A4) A1##A2##A3##A4
+#endif
+
+#include 
+
+uint64_t test_svcntb() {
+  // expected-error-re@+1 {{too many arguments to function call, expected {{0}}, have {{1
+  return SVE_ACLE_FUNC(svcnt, , b, )(1);
+}
+
+uint64_t test_svcnth() {
+  // expected-error-re@+1 {{too many arguments to function call, expected {{0}}, have {{1
+  return SVE_ACLE_FUNC(svcnt, , h, )(2);
+}
+
+uint64_t test_svcntw() {
+  // expected-error-re@+1 {{too many arguments to function call, expected {{0}}, have {{1
+  return SVE_ACLE_FUNC(svcnt, , w, )(3);
+}
+
+uint64_t test_svcntd() {
+  // expected-error-re@+1 {{too many arguments to function call, expected {{0}}, have {{1
+  return SVE_ACLE_FUNC(svcnt, , d, )(4);
+}
Index: clang/include/clang/Basic/arm_sve.td
===
--- clang/include/clang/Basic/arm_sve.td
+++ clang/include/clang/Basic/arm_sve.td
@@ -1263,10 +1263,10 @@
 
 // Predicate creation
 
-def SVPFALSE : SInst<"svpfalse[_b]", "P", "", MergeNone, "", [IsOverloadNone]>;
+def SVPFALSE : SInst<"svpfalse[_b]", "Pv", "", MergeNone, "", [IsOverloadNone]>;
 
 def SVPTRUE_PAT : SInst<"svptrue_pat_{d}", "PI", "PcPsPiPl", MergeNone, "aarch64_sve_ptrue">;
-def SVPTRUE : SInst<"svptrue_{d}", "P",  "PcPsPiPl", MergeNone, "aarch64_sve_ptrue", [IsAppendSVALL]>;
+def SVPTRUE : SInst<"svptrue_{d}", "Pv",  "PcPsPiPl", MergeNone, "aarch64_sve_ptrue", [IsAppendSVALL]>;
 
 def SVDUPQ_B8  : SInst<"svdupq[_n]_{d}",  "P",  "Pc", MergeNone>;
 def SVDUPQ_B16 : SInst<"svdupq[_n]_{d}", "P",  "Ps", MergeNone>;
@@ -1309,9 +1309,9 @@
 
 // FFR manipulation
 
-def SVRDFFR   : SInst<"svrdffr",   "P",  "Pc", MergeNone, "", [IsOverloadNone]>;
+def SVRDFFR   : SInst<"svrdffr",   "Pv",  "Pc", MergeNone, "", [IsOverloadNone]>;
 def SVRDFFR_Z : SInst<"svrdffr_z", "PP", "Pc", MergeNone, "", [IsOverloadNone]>;
-def SVSETFFR  : SInst<"svsetffr",  "v",  "",   MergeNone, "", [IsOverl

[PATCH] D121455: [clang][dataflow] Add support for nested composite bool expressions

2022-03-11 Thread Stanislav Gatev via Phabricator via cfe-commits
sgatev created this revision.
sgatev added reviewers: ymandel, xazax.hun, gribozavr2.
Herald added subscribers: tschuett, steakhal, rnkovacs.
Herald added a project: All.
sgatev requested review of this revision.
Herald added a project: clang.

This is part of the implementation of the dataflow analysis framework.
See "[RFC] A dataflow analysis framework for Clang AST" on cfe-dev.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D121455

Files:
  clang/lib/Analysis/FlowSensitive/Transfer.cpp
  clang/unittests/Analysis/FlowSensitive/TransferTest.cpp

Index: clang/unittests/Analysis/FlowSensitive/TransferTest.cpp
===
--- clang/unittests/Analysis/FlowSensitive/TransferTest.cpp
+++ clang/unittests/Analysis/FlowSensitive/TransferTest.cpp
@@ -2060,86 +2060,109 @@
   });
 }
 
-TEST_F(TransferTest, AssignFromBoolConjunction) {
-  std::string Code = R"(
-void target(bool Foo, bool Bar) {
-  bool Baz = (Foo) && (Bar);
+TEST_F(TransferTest, AssignFromCompositeBoolExpression) {
+  {
+std::string Code = R"(
+void target(bool Foo, bool Bar, bool Qux) {
+  bool Baz = (Foo) && (Bar || Qux);
   // [[p]]
 }
   )";
-  runDataflow(
-  Code, [](llvm::ArrayRef<
-   std::pair>>
-   Results,
-   ASTContext &ASTCtx) {
-ASSERT_THAT(Results, ElementsAre(Pair("p", _)));
-const Environment &Env = Results[0].second.Env;
+runDataflow(
+Code, [](llvm::ArrayRef<
+ std::pair>>
+ Results,
+ ASTContext &ASTCtx) {
+  ASSERT_THAT(Results, ElementsAre(Pair("p", _)));
+  const Environment &Env = Results[0].second.Env;
 
-const ValueDecl *FooDecl = findValueDecl(ASTCtx, "Foo");
-ASSERT_THAT(FooDecl, NotNull());
+  const ValueDecl *FooDecl = findValueDecl(ASTCtx, "Foo");
+  ASSERT_THAT(FooDecl, NotNull());
 
-const auto *FooVal =
-dyn_cast_or_null(Env.getValue(*FooDecl, SkipPast::None));
-ASSERT_THAT(FooVal, NotNull());
+  const auto *FooVal = dyn_cast_or_null(
+  Env.getValue(*FooDecl, SkipPast::None));
+  ASSERT_THAT(FooVal, NotNull());
 
-const ValueDecl *BarDecl = findValueDecl(ASTCtx, "Bar");
-ASSERT_THAT(BarDecl, NotNull());
+  const ValueDecl *BarDecl = findValueDecl(ASTCtx, "Bar");
+  ASSERT_THAT(BarDecl, NotNull());
 
-const auto *BarVal =
-dyn_cast_or_null(Env.getValue(*BarDecl, SkipPast::None));
-ASSERT_THAT(BarVal, NotNull());
+  const auto *BarVal = dyn_cast_or_null(
+  Env.getValue(*BarDecl, SkipPast::None));
+  ASSERT_THAT(BarVal, NotNull());
 
-const ValueDecl *BazDecl = findValueDecl(ASTCtx, "Baz");
-ASSERT_THAT(BazDecl, NotNull());
+  const ValueDecl *QuxDecl = findValueDecl(ASTCtx, "Qux");
+  ASSERT_THAT(QuxDecl, NotNull());
 
-const auto *BazVal = dyn_cast_or_null(
-Env.getValue(*BazDecl, SkipPast::None));
-ASSERT_THAT(BazVal, NotNull());
+  const auto *QuxVal = dyn_cast_or_null(
+  Env.getValue(*QuxDecl, SkipPast::None));
+  ASSERT_THAT(QuxVal, NotNull());
 
-EXPECT_EQ(&BazVal->getLeftSubValue(), FooVal);
-EXPECT_EQ(&BazVal->getRightSubValue(), BarVal);
-  });
-}
+  const ValueDecl *BazDecl = findValueDecl(ASTCtx, "Baz");
+  ASSERT_THAT(BazDecl, NotNull());
 
-TEST_F(TransferTest, AssignFromBoolDisjunction) {
-  std::string Code = R"(
-void target(bool Foo, bool Bar) {
-  bool Baz = (Foo) || (Bar);
+  const auto *BazVal = dyn_cast_or_null(
+  Env.getValue(*BazDecl, SkipPast::None));
+  ASSERT_THAT(BazVal, NotNull());
+  EXPECT_EQ(&BazVal->getLeftSubValue(), FooVal);
+
+  const auto *BazRightSubValVal =
+  cast(&BazVal->getRightSubValue());
+  EXPECT_EQ(&BazRightSubValVal->getLeftSubValue(), BarVal);
+  EXPECT_EQ(&BazRightSubValVal->getRightSubValue(), QuxVal);
+});
+  }
+
+  {
+std::string Code = R"(
+void target(bool Foo, bool Bar, bool Qux) {
+  bool Baz = (Foo && Qux) || (Bar);
   // [[p]]
 }
   )";
-  runDataflow(
-  Code, [](llvm::ArrayRef<
-   std::pair>>
-   Results,
-   ASTContext &ASTCtx) {
-ASSERT_THAT(Results, ElementsAre(Pair("p", _)));
-const Environment &Env = Results[0].second.Env;
+runDataflow(
+Code, [](llvm::ArrayRef<
+ std::pair>>
+ Results,
+ ASTContext &ASTCtx) {
+  ASSERT_THAT(Results, ElementsAre(Pair("p", _)));
+  const Environment &Env = Results[0].second.Env;
 
-const ValueDecl *FooDecl = findValueDecl(ASTCtx, "Foo");
-ASSERT_THAT(FooDecl, NotNull());
+  const ValueDec

[PATCH] D121122: Set FLT_EVAL_METHOD to -1 when fast-math is enabled.

2022-03-11 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: clang/test/CodeGen/eval-method-fast-math.c:83
+#pragma float_control(pop)
+
+int getFPEvalMethod() {

zahiraam wrote:
> aaron.ballman wrote:
> > What should happen in a case like this?
> > ```
> > int whatever(float a, float b, float c) {
> >   #pragma float_control(precise, off)
> >   res = a + b + c;
> >   int val = __FLT_EVAL_METHOD__;
> >   #pragma float_control(precise, on)
> >   return __FLT_EVAL_METHOD__;
> > }
> > ```
> > I would expect that `int val` would hold `-1` and the return statement 
> > would return `0`?
> This test case is failing with this error (at the second pragma):
> 
>   t1.cpp:9:11: error: '#pragma float_control' can only appear at file scope 
> or at
>   the start of a compound statement
>   #pragma float_control(precise, off)
>   ^
>   1 error generated.
> 
> Tried this:
> 
>   int whatever(float a, float b, float c) {
>   #pragma float_control(precise, off)
>   res = a + b + c;
>   int val =__FLT_EVAL_METHOD__;
>   {
>   #pragma float_control(precise, on)
>   return __FLT_EVAL_METHOD__;
>   }
> }
> 
> This generated these last IR instructions:
>   store float %add1, float* @"?res@@3MA", align 4
>   store i32 -1, i32* %val, align 4
>   ret i32 -1
> 
> Not sure if this is correct. I guess the first pragma (off) didn't popped, so 
> it's still on?  But inside the scope of the second pragma the first pragma 
> shouldn't be visible? Not sure what should happen here. 
> Not sure if this is correct.

It looks incorrect to me. What I'd expect is:
```
int whatever(float a, float b, float c) {
  #pragma float_control(precise, off)
  res = a + b + c;
  int val =__FLT_EVAL_METHOD__; // Expect -1
  {
#pragma float_control(precise, on)
return __FLT_EVAL_METHOD__; // Expect 0
  }
  return __FLT_EVAL_METHOD__; // Expect -1
}
```
I forgot about the function scope restrictions, but the file scope still has an 
interesting case worth testing:
```
float a = 1.0f, b = 2.0f, c = 3.0f;
#pragma float_control(precise, off)
float res = a + b + c;
int off =__FLT_EVAL_METHOD__; // Expect -1
#pragma float_control(precise, on)
float other_res = a + b + c;
int on = __FLT_EVAL_METHOD__; // Expect 0
```
Both of these are based on the idea that the float control pragma sets the flag 
until it's either popped (by leaving a compound statement) or it's changed to 
something else (by another pragma).


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

https://reviews.llvm.org/D121122

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


[clang] b44eb20 - [clang-format] Refactor condition in AnnotatingParser::modifyContext(). NFC.

2022-03-11 Thread Marek Kurdej via cfe-commits

Author: Marek Kurdej
Date: 2022-03-11T13:12:43+01:00
New Revision: b44eb207e96a5e20aecbb6084147ae97e3eabd22

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

LOG: [clang-format] Refactor condition in AnnotatingParser::modifyContext(). 
NFC.

Added: 


Modified: 
clang/lib/Format/TokenAnnotator.cpp

Removed: 




diff  --git a/clang/lib/Format/TokenAnnotator.cpp 
b/clang/lib/Format/TokenAnnotator.cpp
index 8f5f4e0f43362..1c662c9a909c9 100644
--- a/clang/lib/Format/TokenAnnotator.cpp
+++ b/clang/lib/Format/TokenAnnotator.cpp
@@ -1506,15 +1506,24 @@ class AnnotatingParser {
   };
 
   void modifyContext(const FormatToken &Current) {
-if (Current.getPrecedence() == prec::Assignment &&
-!Line.First->isOneOf(tok::kw_template, tok::kw_using, tok::kw_return) 
&&
-// Type aliases use `type X = ...;` in TypeScript and can be exported
-// using `export type ...`.
-!(Style.isJavaScript() &&
+auto AssignmentStartsExpression = [&]() {
+  if (Current.getPrecedence() != prec::Assignment)
+return false;
+
+  if (Line.First->isOneOf(tok::kw_template, tok::kw_using, tok::kw_return))
+return false;
+
+  // Type aliases use `type X = ...;` in TypeScript and can be exported
+  // using `export type ...`.
+  if (Style.isJavaScript() &&
   (Line.startsWith(Keywords.kw_type, tok::identifier) ||
-   Line.startsWith(tok::kw_export, Keywords.kw_type,
-   tok::identifier))) &&
-(!Current.Previous || Current.Previous->isNot(tok::kw_operator))) {
+   Line.startsWith(tok::kw_export, Keywords.kw_type, tok::identifier)))
+return false;
+
+  return !Current.Previous || Current.Previous->isNot(tok::kw_operator);
+};
+
+if (AssignmentStartsExpression()) {
   Contexts.back().IsExpression = true;
   if (!Line.startsWith(TT_UnaryOperator)) {
 for (FormatToken *Previous = Current.Previous;



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


[PATCH] D121410: Have cpu-specific variants set 'tune-cpu' as an optimization hint

2022-03-11 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a reviewer: arsenm.
aaron.ballman added a subscriber: arsenm.
aaron.ballman added a comment.
Herald added a subscriber: wdng.

Adding @arsenm because of this bit:

> Note that the 'valid' list of processors for x86 is in 
> llvm/include/llvm/Support/X86TargetParser.def. At the moment, this list 
> contains only Intel processors, but other vendors may wish to add their own 
> entries as 'alias'es (or wiht different feature lists!).


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

https://reviews.llvm.org/D121410

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


[PATCH] D121456: [clang-format] Correctly format variable templates.

2022-03-11 Thread Marek Kurdej via Phabricator via cfe-commits
curdeius created this revision.
curdeius added reviewers: MyDeveloperDay, HazardyKnusperkeks, owenpan, cjdb.
Herald added a project: All.
curdeius requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Fixes https://github.com/llvm/llvm-project/issues/54257.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D121456

Files:
  clang/lib/Format/TokenAnnotator.cpp
  clang/unittests/Format/FormatTest.cpp
  clang/unittests/Format/TokenAnnotatorTest.cpp


Index: clang/unittests/Format/TokenAnnotatorTest.cpp
===
--- clang/unittests/Format/TokenAnnotatorTest.cpp
+++ clang/unittests/Format/TokenAnnotatorTest.cpp
@@ -117,6 +117,31 @@
   EXPECT_TOKEN(Tokens[2], tok::l_brace, TT_EnumLBrace);
 }
 
+TEST_F(TokenAnnotatorTest, UnderstandsDefaultedAndDeletedFunctions) {
+  auto Tokens = annotate("auto operator<=>(const T &) const & = default;");
+  EXPECT_EQ(Tokens.size(), 14u) << Tokens;
+  EXPECT_TOKEN(Tokens[9], tok::amp, TT_PointerOrReference);
+
+  Tokens = annotate("template  void F(T) && = delete;");
+  EXPECT_EQ(Tokens.size(), 15u) << Tokens;
+  EXPECT_TOKEN(Tokens[10], tok::ampamp, TT_PointerOrReference);
+}
+
+TEST_F(TokenAnnotatorTest, UnderstandsVariables) {
+  auto Tokens =
+  annotate("inline bool var = is_integral_v && is_signed_v;");
+  EXPECT_EQ(Tokens.size(), 15u) << Tokens;
+  EXPECT_TOKEN(Tokens[8], tok::ampamp, TT_BinaryOperator);
+}
+
+TEST_F(TokenAnnotatorTest, UnderstandsVariableTemplates) {
+  auto Tokens =
+  annotate("template  "
+   "inline bool var = is_integral_v && is_signed_v;");
+  EXPECT_EQ(Tokens.size(), 20u) << Tokens;
+  EXPECT_TOKEN(Tokens[13], tok::ampamp, TT_BinaryOperator);
+}
+
 TEST_F(TokenAnnotatorTest, UnderstandsLBracesInMacroDefinition) {
   auto Tokens = annotate("#define BEGIN NS {");
   EXPECT_EQ(Tokens.size(), 6u) << Tokens;
Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -25335,6 +25335,12 @@
   verifyFormat("#define A x%:%:y");
 }
 
+TEST_F(FormatTest, FormatsVariableTemplates) {
+  verifyFormat("inline bool var = is_integral_v && is_signed_v;");
+  verifyFormat("template  "
+   "inline bool var = is_integral_v && is_signed_v;");
+}
+
 } // namespace
 } // namespace format
 } // namespace clang
Index: clang/lib/Format/TokenAnnotator.cpp
===
--- clang/lib/Format/TokenAnnotator.cpp
+++ clang/lib/Format/TokenAnnotator.cpp
@@ -1510,8 +1510,30 @@
   if (Current.getPrecedence() != prec::Assignment)
 return false;
 
-  if (Line.First->isOneOf(tok::kw_template, tok::kw_using, tok::kw_return))
+  if (Line.First->isOneOf(tok::kw_using, tok::kw_return))
 return false;
+  if (Line.First->is(tok::kw_template)) {
+// `template` keyword can start a variable template.
+const FormatToken *Tok = Line.First->getNextNonComment();
+assert(Tok); // Current token is on the same line.
+if (Tok->isNot(TT_TemplateOpener)) {
+  // Explicit template instantiations do not have `<>`.
+  return false;
+}
+
+Tok = Tok->MatchingParen;
+if (!Tok)
+  return false;
+Tok = Tok->getNextNonComment();
+if (!Tok)
+  return false;
+
+if (Tok->isOneOf(tok::kw_class, tok::kw_enum, tok::kw_concept,
+ tok::kw_struct, tok::kw_using))
+  return false;
+
+return true;
+  }
 
   // Type aliases use `type X = ...;` in TypeScript and can be exported
   // using `export type ...`.


Index: clang/unittests/Format/TokenAnnotatorTest.cpp
===
--- clang/unittests/Format/TokenAnnotatorTest.cpp
+++ clang/unittests/Format/TokenAnnotatorTest.cpp
@@ -117,6 +117,31 @@
   EXPECT_TOKEN(Tokens[2], tok::l_brace, TT_EnumLBrace);
 }
 
+TEST_F(TokenAnnotatorTest, UnderstandsDefaultedAndDeletedFunctions) {
+  auto Tokens = annotate("auto operator<=>(const T &) const & = default;");
+  EXPECT_EQ(Tokens.size(), 14u) << Tokens;
+  EXPECT_TOKEN(Tokens[9], tok::amp, TT_PointerOrReference);
+
+  Tokens = annotate("template  void F(T) && = delete;");
+  EXPECT_EQ(Tokens.size(), 15u) << Tokens;
+  EXPECT_TOKEN(Tokens[10], tok::ampamp, TT_PointerOrReference);
+}
+
+TEST_F(TokenAnnotatorTest, UnderstandsVariables) {
+  auto Tokens =
+  annotate("inline bool var = is_integral_v && is_signed_v;");
+  EXPECT_EQ(Tokens.size(), 15u) << Tokens;
+  EXPECT_TOKEN(Tokens[8], tok::ampamp, TT_BinaryOperator);
+}
+
+TEST_F(TokenAnnotatorTest, UnderstandsVariableTemplates) {
+  auto Tokens =
+  annotate("template  "
+   "inline bool var = is_integral_v && is_signed_v;");
+  EXPECT_EQ(Tokens.size(), 20u) << Tokens;
+  

[PATCH] D121206: [AARCH64] ssbs should be enabled by default for cortex-x1c

2022-03-11 Thread Ties Stuij via Phabricator via cfe-commits
stuij updated this revision to Diff 414635.
stuij added a comment.

addressed review comments


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D121206

Files:
  clang/test/Driver/aarch64-ssbs.c
  clang/test/Preprocessor/aarch64-target-features.c
  llvm/lib/Support/AArch64TargetParser.cpp
  llvm/lib/Target/AArch64/AArch64.td


Index: llvm/lib/Target/AArch64/AArch64.td
===
--- llvm/lib/Target/AArch64/AArch64.td
+++ llvm/lib/Target/AArch64/AArch64.td
@@ -957,7 +957,7 @@
  FeatureRCPC, FeatureSSBS, FeaturePerfMon];
   list A77  = [HasV8_2aOps, FeatureCrypto, FeatureFPARMv8,
  FeatureNEON, FeatureFullFP16, FeatureDotProd,
- FeatureRCPC, FeaturePerfMon];
+ FeatureRCPC, FeaturePerfMon, FeatureSSBS];
   list A78  = [HasV8_2aOps, FeatureCrypto, FeatureFPARMv8,
  FeatureNEON, FeatureFullFP16, FeatureDotProd,
  FeatureRCPC, FeaturePerfMon, FeatureSPE,
@@ -975,11 +975,12 @@
  FeatureSB];
   list X1   = [HasV8_2aOps, FeatureCrypto, FeatureFPARMv8,
  FeatureNEON, FeatureRCPC, FeaturePerfMon,
- FeatureSPE, FeatureFullFP16, FeatureDotProd];
+ FeatureSPE, FeatureFullFP16, FeatureDotProd,
+ FeatureSSBS];
   list X1C  = [HasV8_2aOps, FeatureCrypto, FeatureFPARMv8,
  FeatureNEON, FeatureRCPC, FeaturePerfMon,
  FeatureSPE, FeatureFullFP16, FeatureDotProd,
- FeaturePAuth];
+ FeaturePAuth, FeatureSSBS];
   list X2   = [HasV9_0aOps, FeatureNEON, FeaturePerfMon,
  FeatureMatMulInt8, FeatureBF16, FeatureAM,
  FeatureMTE, FeatureETE, FeatureSVE2BitPerm,
Index: llvm/lib/Support/AArch64TargetParser.cpp
===
--- llvm/lib/Support/AArch64TargetParser.cpp
+++ llvm/lib/Support/AArch64TargetParser.cpp
@@ -120,6 +120,8 @@
 Features.push_back("+mops");
   if (Extensions & AArch64::AEK_PERFMON)
 Features.push_back("+perfmon");
+  if (Extensions & AArch64::AEK_SSBS)
+Features.push_back("+ssbs");
 
   return true;
 }
Index: clang/test/Preprocessor/aarch64-target-features.c
===
--- clang/test/Preprocessor/aarch64-target-features.c
+++ clang/test/Preprocessor/aarch64-target-features.c
@@ -285,7 +285,7 @@
 // CHECK-MCPU-A57: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-feature" 
"+v8a" "-target-feature" "+fp-armv8" "-target-feature" "+neon" 
"-target-feature" "+crc" "-target-feature" "+crypto"
 // CHECK-MCPU-A72: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-feature" 
"+v8a" "-target-feature" "+fp-armv8" "-target-feature" "+neon" 
"-target-feature" "+crc" "-target-feature" "+crypto"
 // CHECK-MCPU-CORTEX-A73: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" 
"-target-feature" "+v8a" "-target-feature" "+fp-armv8" "-target-feature" 
"+neon" "-target-feature" "+crc" "-target-feature" "+crypto"
-// CHECK-MCPU-CORTEX-R82: "-cc1"{{.*}} "-triple" "aarch64{{.*}}"  
"-target-feature" "+v8r" "-target-feature" "+fp-armv8" "-target-feature" 
"+neon" "-target-feature" "+crc" "-target-feature" "+dotprod" "-target-feature" 
"+fp16fml" "-target-feature" "+ras" "-target-feature" "+lse" "-target-feature" 
"+rdm" "-target-feature" "+rcpc" "-target-feature" "+fullfp16"
+// CHECK-MCPU-CORTEX-R82: "-cc1"{{.*}} "-triple" "aarch64{{.*}}"  
"-target-feature" "+v8r" "-target-feature" "+fp-armv8" "-target-feature" 
"+neon" "-target-feature" "+crc" "-target-feature" "+dotprod" "-target-feature" 
"+fp16fml" "-target-feature" "+ras" "-target-feature" "+lse" "-target-feature" 
"+rdm" "-target-feature" "+rcpc" "-target-feature" "+ssbs" "-target-feature" 
"+fullfp16"
 // CHECK-MCPU-M3: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-feature" 
"+v8a" "-target-feature" "+fp-armv8" "-target-feature" "+neon" 
"-target-feature" "+crc" "-target-feature" "+crypto"
 // CHECK-MCPU-M4: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-feature" 
"+neon" "-target-feature" "+crc" "-target-feature" "+crypto" "-target-feature" 
"+dotprod" "-target-feature" "+fullfp16"
 // CHECK-MCPU-KRYO: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-feature" 
"+v8a" "-target-feature" "+fp-armv8" "-target-feature" "+neon" 
"-target-feature" "+crc" "-target-feature" "+crypto"
Index: clang/test/Driver/aarch64-ssbs.c
===
--- clang/test/Driver/aarch64-ssbs.c
+++ clang/test/Driver/aarch64-ssbs.c
@@ -1,7 +1,11 @@
 // RUN: %clang -### -target aar

[PATCH] D121206: [AARCH64] ssbs should be enabled by default for cortex-x1, cortex-x1c, cortex-a77

2022-03-11 Thread Ties Stuij via Phabricator via cfe-commits
stuij marked 2 inline comments as done.
stuij added inline comments.



Comment at: clang/test/Preprocessor/aarch64-target-features.c:288
 // CHECK-MCPU-CORTEX-A73: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" 
"-target-feature" "+v8a" "-target-feature" "+fp-armv8" "-target-feature" 
"+neon" "-target-feature" "+crc" "-target-feature" "+crypto"
-// CHECK-MCPU-CORTEX-R82: "-cc1"{{.*}} "-triple" "aarch64{{.*}}"  
"-target-feature" "+v8r" "-target-feature" "+fp-armv8" "-target-feature" 
"+neon" "-target-feature" "+crc" "-target-feature" "+dotprod" "-target-feature" 
"+fp16fml" "-target-feature" "+ras" "-target-feature" "+lse" "-target-feature" 
"+rdm" "-target-feature" "+rcpc" "-target-feature" "+fullfp16"
+// CHECK-MCPU-CORTEX-R82: "-cc1"{{.*}} "-triple" "aarch64{{.*}}"  
"-target-feature" "+v8r" "-target-feature" "+fp-armv8" "-target-feature" 
"+neon" "-target-feature" "+crc" "-target-feature" "+dotprod" "-target-feature" 
"+fp16fml" "-target-feature" "+ras" "-target-feature" "+lse" "-target-feature" 
"+rdm" "-target-feature" "+rcpc" "-target-feature" "+ssbs" "-target-feature" 
"+fullfp16"
 // CHECK-MCPU-M3: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-feature" 
"+v8a" "-target-feature" "+fp-armv8" "-target-feature" "+neon" 
"-target-feature" "+crc" "-target-feature" "+crypto"

DavidSpickett wrote:
> Why did this change, was it just not correct before or is r82 some equivalent 
> of the x1c?
yes, not correct. ssbs was enabled by default for cortex-r82, but we're now 
making sure we're passing +ssbs to the backend, like we do with other 
extensions.



Comment at: llvm/lib/Target/AArch64/AArch64.td:978
  FeatureNEON, FeatureRCPC, FeaturePerfMon,
  FeatureSPE, FeatureFullFP16, FeatureDotProd];
   list X1C  = [HasV8_2aOps, FeatureCrypto, FeatureFPARMv8,

dmgreen wrote:
> X1 and A77 missing SSBS too. Should they be added at the same time?
Yes they should. Thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D121206

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


[PATCH] D121457: Clamp negative coverage counters to zero.

2022-03-11 Thread Hiral via Phabricator via cfe-commits
Hiralo created this revision.
Hiralo added a reviewer: vsk.
Hiralo added projects: clang, LLVM.
Herald added subscribers: dexonsmith, wenlei, dang, kbarton, nemanjai.
Herald added a project: All.
Hiralo requested review of this revision.
Herald added subscribers: llvm-commits, cfe-commits.

commit 60009ab7a6491095b99acd1445dfe0fc5418cb3f
Author: Hiral Oza 
Date:   Fri Mar 11 10:19:51 2022 +0530

  Clamp negative coverage counters to zero.
  
  Because there is no locking on counter updates, race conditions may
  cause counters to become negative. Clamp them to zero when exporting
  LCOV reports.
  
  Optionally remove blank lines from coverage
  
  Added -omit-blank-lines option to add Skip regions to the coverage map
  for lines of source code that are blank.
  
  Author: thom.h...@netapp.com


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D121457

Files:
  clang/include/clang/Basic/CodeGenOptions.def
  clang/include/clang/Driver/Options.td
  clang/include/clang/Lex/PPCallbacks.h
  clang/include/clang/Lex/Preprocessor.h
  clang/lib/CodeGen/CodeGenPGO.cpp
  clang/lib/CodeGen/CoverageMappingGen.cpp
  clang/lib/CodeGen/CoverageMappingGen.h
  clang/lib/Lex/Preprocessor.cpp
  llvm/tools/llvm-cov/CoverageExporterLcov.cpp

Index: llvm/tools/llvm-cov/CoverageExporterLcov.cpp
===
--- llvm/tools/llvm-cov/CoverageExporterLcov.cpp
+++ llvm/tools/llvm-cov/CoverageExporterLcov.cpp
@@ -70,7 +70,10 @@
   for (; LCI != LCIEnd; ++LCI) {
 const coverage::LineCoverageStats &LCS = *LCI;
 if (LCS.isMapped()) {
-  OS << "DA:" << LCS.getLine() << ',' << LCS.getExecutionCount() << '\n';
+  OS << "DA:" << LCS.getLine() << ','
+ << ((LCS.getExecutionCount() & (1ULL << 63)) ? 0
+  : LCS.getExecutionCount())
+ << '\n';
 }
   }
 }
Index: clang/lib/Lex/Preprocessor.cpp
===
--- clang/lib/Lex/Preprocessor.cpp
+++ clang/lib/Lex/Preprocessor.cpp
@@ -964,6 +964,31 @@
 }
   }

+  if (Callbacks) {
+SourceLocation TokenLoc = Result.getLocation();
+if (TokenLoc.isFileID() &&
+!SourceMgr.isInSystemHeader(SourceMgr.getSpellingLoc(TokenLoc))) {
+  bool Invalid = false;
+  unsigned LineNumber = SourceMgr.getSpellingLineNumber(TokenLoc, &Invalid);
+  if (!Invalid) {
+FileID FID = SourceMgr.getFileID(TokenLoc);
+HighestLineNumberMap::iterator fi = HighestLineNumbers.find(FID);
+unsigned HighestLineNumber =
+fi == HighestLineNumbers.end() ? 0 : fi->second;
+if (LineNumber > HighestLineNumber + 1) {
+  SourceLocation BlankStart =
+  SourceMgr.translateLineCol(FID, HighestLineNumber + 1, 1);
+  SourceLocation BlankEnd =
+  SourceMgr.translateLineCol(FID, LineNumber - 1, 1);
+  Callbacks->BlankLines(SourceRange(BlankStart, BlankEnd));
+}
+if (LineNumber > HighestLineNumber) {
+  HighestLineNumbers[FID] = LineNumber;
+}
+  }
+}
+  }
+
   LastTokenWasAt = Result.is(tok::at);
   --LexLevel;

Index: clang/lib/CodeGen/CoverageMappingGen.h
===
--- clang/lib/CodeGen/CoverageMappingGen.h
+++ clang/lib/CodeGen/CoverageMappingGen.h
@@ -23,6 +23,7 @@

 namespace clang {

+class CodeGenOptions;
 class LangOptions;
 class SourceManager;
 class FileEntry;
@@ -50,6 +51,7 @@
public EmptylineHandler {
   // A vector of skipped source ranges and PrevTokLoc with NextTokLoc.
   std::vector SkippedRanges;
+  std::vector BlankLineRanges;

   SourceManager &SourceMgr;

@@ -61,8 +63,10 @@
   CoverageSourceInfo(SourceManager &SourceMgr) : SourceMgr(SourceMgr) {}

   std::vector &getSkippedRanges() { return SkippedRanges; }
+  ArrayRef getBlankLines() const { return BlankLineRanges; }

   void AddSkippedRange(SourceRange Range);
+  void BlankLines(SourceRange Range) override;

   void SourceRangeSkipped(SourceRange Range, SourceLocation EndifLoc) override;

@@ -135,18 +139,23 @@
 class CoverageMappingGen {
   CoverageMappingModuleGen &CVM;
   SourceManager &SM;
+  const CodeGenOptions &CodeGenOpts;
   const LangOptions &LangOpts;
   llvm::DenseMap *CounterMap;

 public:
   CoverageMappingGen(CoverageMappingModuleGen &CVM, SourceManager &SM,
+ const CodeGenOptions &CodeGenOpts,
  const LangOptions &LangOpts)
-  : CVM(CVM), SM(SM), LangOpts(LangOpts), CounterMap(nullptr) {}
+  : CVM(CVM), SM(SM), CodeGenOpts(CodeGenOpts), LangOpts(LangOpts),
+CounterMap(nullptr) {}

   CoverageMappingGen(CoverageMappingModuleGen &CVM, SourceManager &SM,
+ const CodeGenOptions &CodeGenOpts,
  const LangOptions &LangOpts,
  llvm::DenseMap *CounterMap)
-  : CVM(CVM), SM(SM), LangOpts(LangOpts), CounterM

[PATCH] D121457: Clamp negative coverage counters to zero.

2022-03-11 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri added a comment.

Wouldn't it be best to instead fix the non-thread-safety of the coverage 
counters?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D121457

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


[PATCH] D121457: Clamp negative coverage counters to zero.

2022-03-11 Thread Hiral via Phabricator via cfe-commits
Hiralo added a comment.

In D121457#3375039 , @lebedev.ri 
wrote:

> Wouldn't it be best to instead fix the non-thread-safety of the coverage 
> counters?

Can you please elaborate or point me to code? Thanks


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D121457

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


[PATCH] D121459: [analyzer] Remove HasAlphaDocumentation tablegen enum value

2022-03-11 Thread Balázs Benics via Phabricator via cfe-commits
steakhal created this revision.
steakhal added reviewers: aaron.ballman, NoQ, Szelethus, martong.
Herald added subscribers: manas, ASDenysPetrov, dkrupp, donat.nagy, 
mikhail.ramalho, a.sidorin, rnkovacs, szepet, baloghadamsoftware, xazax.hun.
Herald added a project: All.
steakhal requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

D121387  simplified the doc url generation 
process, so we no longer need
the HasAlphaDocumentation enum entry. This patch removes that.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D121459

Files:
  clang/include/clang/StaticAnalyzer/Checkers/CheckerBase.td
  clang/include/clang/StaticAnalyzer/Checkers/Checkers.td

Index: clang/include/clang/StaticAnalyzer/Checkers/Checkers.td
===
--- clang/include/clang/StaticAnalyzer/Checkers/Checkers.td
+++ clang/include/clang/StaticAnalyzer/Checkers/Checkers.td
@@ -236,57 +236,57 @@
 
 def BoolAssignmentChecker : Checker<"BoolAssignment">,
   HelpText<"Warn about assigning non-{0,1} values to Boolean variables">,
-  Documentation;
+  Documentation;
 
 def CastSizeChecker : Checker<"CastSize">,
   HelpText<"Check when casting a malloc'ed type T, whether the size is a "
"multiple of the size of T">,
-  Documentation;
+  Documentation;
 
 def CastToStructChecker : Checker<"CastToStruct">,
   HelpText<"Check for cast from non-struct pointer to struct pointer">,
-  Documentation;
+  Documentation;
 
 def ConversionChecker : Checker<"Conversion">,
   HelpText<"Loss of sign/precision in implicit conversions">,
-  Documentation;
+  Documentation;
 
 def IdenticalExprChecker : Checker<"IdenticalExpr">,
   HelpText<"Warn about unintended use of identical expressions in operators">,
-  Documentation;
+  Documentation;
 
 def FixedAddressChecker : Checker<"FixedAddr">,
   HelpText<"Check for assignment of a fixed address to a pointer">,
-  Documentation;
+  Documentation;
 
 def PointerArithChecker : Checker<"PointerArithm">,
   HelpText<"Check for pointer arithmetic on locations other than array "
"elements">,
-  Documentation;
+  Documentation;
 
 def PointerSubChecker : Checker<"PointerSub">,
   HelpText<"Check for pointer subtractions on two pointers pointing to "
"different memory chunks">,
-  Documentation;
+  Documentation;
 
 def SizeofPointerChecker : Checker<"SizeofPtr">,
   HelpText<"Warn about unintended use of sizeof() on pointer expressions">,
-  Documentation;
+  Documentation;
 
 def TestAfterDivZeroChecker : Checker<"TestAfterDivZero">,
   HelpText<"Check for division by variable that is later compared against 0. "
"Either the comparison is useless or there is division by zero.">,
-  Documentation;
+  Documentation;
 
 def DynamicTypeChecker : Checker<"DynamicTypeChecker">,
   HelpText<"Check for cases where the dynamic and the static type of an object "
"are unrelated.">,
-  Documentation;
+  Documentation;
 
 def StackAddrAsyncEscapeChecker : Checker<"StackAddressAsyncEscape">,
   HelpText<"Check that addresses to stack memory do not escape the function">,
   Dependencies<[StackAddrEscapeBase]>,
-  Documentation;
+  Documentation;
 
 def PthreadLockBase : Checker<"PthreadLockBase">,
   HelpText<"Helper registering multiple checks.">,
@@ -296,7 +296,7 @@
 def C11LockChecker : Checker<"C11Lock">,
   HelpText<"Simple lock -> unlock checker">,
   Dependencies<[PthreadLockBase]>,
-  Documentation;
+  Documentation;
 
 } // end "alpha.core"
 
@@ -464,22 +464,22 @@
 def CStringOutOfBounds : Checker<"OutOfBounds">,
   HelpText<"Check for out-of-bounds access in string functions">,
   Dependencies<[CStringModeling]>,
-  Documentation;
+  Documentation;
 
 def CStringBufferOverlap : Checker<"BufferOverlap">,
   HelpText<"Checks for overlap in two buffer arguments">,
   Dependencies<[CStringModeling]>,
-  Documentation;
+  Documentation;
 
 def CStringNotNullTerm : Checker<"NotNullTerminated">,
   HelpText<"Check for arguments which are not null-terminating strings">,
   Dependencies<[CStringModeling]>,
-  Documentation;
+  Documentation;
  
 def CStringUninitializedRead : Checker<"UninitializedRead">,
   HelpText<"Checks if the string manipulation function would read uninitialized bytes">,
   Dependencies<[CStringModeling]>,
-  Documentation;
+  Documentation;
   
 } // end "alpha.unix.cstring"
 
@@ -541,24 +541,24 @@
 
 def ChrootChecker : Checker<"Chroot">,
   HelpText<"Check improper use of chroot">,
-  Documentation;
+  Documentation;
 
 def PthreadLockChecker : Checker<"PthreadLock">,
   HelpText<"Simple lock -> unlock checker">,
   Dependencies<[PthreadLockBase]>,
-  Documentation;
+  Documentation;
 
 def StreamChecker : Checker<"Stream">,
   HelpText<"Check stream handling functions">,
-  Documentation;
+  Documentation;
 
 def SimpleStreamChecker : Checker<"SimpleStream">,
   HelpText<"Check for misuses o

[PATCH] D121410: Have cpu-specific variants set 'tune-cpu' as an optimization hint

2022-03-11 Thread Erich Keane via Phabricator via cfe-commits
erichkeane added a comment.

Thanks all!  I'll do some work on populating a list of 'converted names', but 
I'll definitely need @pengfei and @andrew.w.kaylor help checking the 
list/filling in what I miss.


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

https://reviews.llvm.org/D121410

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


[PATCH] D120824: [clang][ASTImporter] Fix a bug when importing CXXDefaultInitExpr.

2022-03-11 Thread Balázs Kéri via Phabricator via cfe-commits
balazske updated this revision to Diff 414642.
balazske added a comment.

Added unit tests.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D120824

Files:
  clang/lib/AST/ASTImporter.cpp
  clang/test/Analysis/Inputs/ctu-cxxdefaultinitexpr-import.cpp
  
clang/test/Analysis/Inputs/ctu-cxxdefaultinitexpr-import.cpp.externalDefMap.ast-dump.txt
  clang/test/Analysis/ctu-cxxdefaultinitexpr.cpp
  clang/unittests/AST/ASTImporterTest.cpp

Index: clang/unittests/AST/ASTImporterTest.cpp
===
--- clang/unittests/AST/ASTImporterTest.cpp
+++ clang/unittests/AST/ASTImporterTest.cpp
@@ -530,6 +530,21 @@
has(floatLiteral(equals(1.0);
 }
 
+const internal::VariadicDynCastAllOfMatcher
+cxxDefaultInitExpr;
+
+TEST_P(ImportExpr, ImportCXXDefaultInitExpr) {
+  MatchVerifier Verifier;
+  testImport("class declToImport { int DefInit = 5; }; declToImport X;",
+ Lang_CXX11, "", Lang_CXX11, Verifier,
+ cxxRecordDecl(hasDescendant(cxxConstructorDecl(
+ hasAnyConstructorInitializer(cxxCtorInitializer(
+ withInitializer(cxxDefaultInitExpr(;
+  testImport(
+  "struct X { int A = 5; }; X declToImport{};", Lang_CXX17, "", Lang_CXX17,
+  Verifier,
+  varDecl(hasInitializer(initListExpr(hasInit(0, cxxDefaultInitExpr());
+}
 
 const internal::VariadicDynCastAllOfMatcher vaArgExpr;
 
@@ -7527,6 +7542,92 @@
   EXPECT_TRUE(ToA->isCompleteDefinition());
 }
 
+TEST_P(ASTImporterOptionSpecificTestBase, ImportInClassInitializerFromField) {
+  // Encounter import of a field when the field already exists but has the
+  // in-class initializer expression not yet set. Such case can occur in the AST
+  // of generated template specializations.
+  // The first code forces to create a template specialization of
+  // `A` but without implicit constructors.
+  // The second ("From") code contains a variable of type `A`, this
+  // results in a template specialization that has constructors and
+  // CXXDefaultInitExpr nodes.
+  Decl *ToTU = getToTuDecl(
+  R"(
+  void f();
+  template struct A { int X = 1; };
+  struct B { A Y; };
+  )",
+  Lang_CXX11);
+  auto *ToX = FirstDeclMatcher().match(
+  ToTU,
+  fieldDecl(hasName("X"), hasParent(classTemplateSpecializationDecl(;
+  ASSERT_TRUE(ToX->hasInClassInitializer());
+  ASSERT_FALSE(ToX->getInClassInitializer());
+
+  Decl *FromTU = getTuDecl(
+  R"(
+  void f();
+  template struct A { int X = 1; };
+  struct B { A Y; };
+  //
+  A Z;
+  )",
+  Lang_CXX11, "input1.cc");
+  auto *FromX = FirstDeclMatcher().match(
+  FromTU,
+  fieldDecl(hasName("X"), hasParent(classTemplateSpecializationDecl(;
+
+  auto *ToXImported = Import(FromX, Lang_CXX11);
+  EXPECT_EQ(ToXImported, ToX);
+  EXPECT_TRUE(ToX->getInClassInitializer());
+}
+
+TEST_P(ASTImporterOptionSpecificTestBase,
+   ImportInClassInitializerFromCXXDefaultInitExpr) {
+  // Encounter AST import of a CXXDefaultInitExpr where the "to-field"
+  // of it exists but has the in-class initializer not set yet.
+  Decl *ToTU = getToTuDecl(
+  R"(
+  namespace N {
+template int b;
+struct X;
+  }
+  template struct A { N::X *X = nullptr; };
+  struct B { A Y; };
+  )",
+  Lang_CXX14);
+  auto *ToX = FirstDeclMatcher().match(
+  ToTU,
+  fieldDecl(hasName("X"), hasParent(classTemplateSpecializationDecl(;
+  ASSERT_TRUE(ToX->hasInClassInitializer());
+  ASSERT_FALSE(ToX->getInClassInitializer());
+
+  Decl *FromTU = getTuDecl(
+  R"(
+  namespace N {
+template int b;
+struct X;
+  }
+  template struct A { N::X *X = nullptr; };
+  struct B { A Y; };
+  //
+  void f() {
+(void)A{};
+  }
+  struct C {
+C(): attr(new A{}){}
+A *attr;
+const int value = N::b;
+  };
+  )",
+  Lang_CXX14, "input1.cc");
+  auto *FromF = FirstDeclMatcher().match(
+  FromTU, functionDecl(hasName("f"), isDefinition()));
+  auto *ToF = Import(FromF, Lang_CXX11);
+  EXPECT_TRUE(ToF);
+  EXPECT_TRUE(ToX->getInClassInitializer());
+}
+
 INSTANTIATE_TEST_SUITE_P(ParameterizedTests, ASTImporterLookupTableTest,
  DefaultTestValuesForRunOptions);
 
Index: clang/test/Analysis/ctu-cxxdefaultinitexpr.cpp
===
--- /dev/null
+++ clang/test/Analysis/ctu-cxxdefaultinitexpr.cpp
@@ -0,0 +1,35 @@
+// RUN: rm -rf %t && mkdir %t
+// RUN: mkdir -p %t/ctudir
+// RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -std=c++17 \
+// RUN:   -emit-pch -o %t/ctudir/ctu-cxxdefaultinitexpr-import.cpp.ast %S/Inputs/ctu-cxxdefaultinitexpr-import.cpp
+// RUN: cp %S/Inputs/ctu-cxxdefaultinitexpr-import.cpp.externalDefMap.ast-dump.txt %t/ctudir/exte

[PATCH] D120824: [clang][ASTImporter] Fix a bug when importing CXXDefaultInitExpr.

2022-03-11 Thread Balázs Kéri via Phabricator via cfe-commits
balazske added a comment.

The last unit test is not much different from the lit test, I could not find 
more simple code to get the wanted result. Is it still good to have the lit 
test too?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D120824

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


[PATCH] D121374: [flang][driver] Add support for `-mllvm`

2022-03-11 Thread Andrzej Warzynski via Phabricator via cfe-commits
awarzynski updated this revision to Diff 414648.
awarzynski added a comment.

Fix option spelling in test


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D121374

Files:
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/ToolChains/Flang.cpp
  flang/include/flang/Frontend/FrontendOptions.h
  flang/lib/Frontend/CompilerInvocation.cpp
  flang/lib/FrontendTool/ExecuteCompilerInvocation.cpp
  flang/test/Driver/driver-help-hidden.f90
  flang/test/Driver/driver-help.f90
  flang/test/Driver/mllvm.f90

Index: flang/test/Driver/mllvm.f90
===
--- /dev/null
+++ flang/test/Driver/mllvm.f90
@@ -0,0 +1,32 @@
+! Test the `-mllvm` option
+
+!
+! RUN COMMAND
+!
+! 1. Test typical usage.
+! RUN: %flang -S -mllvm -print-before-all %s -o - 2>&1 | FileCheck %s --check-prefix=OUTPUT
+! RUN: %flang_fc1 -S -mllvm -print-before-all %s -o - 2>&1 | FileCheck %s --check-prefix=OUTPUT
+
+! 2. Does the option forwarding from `flang-new` to `flang-new -fc1` work?
+! RUN: %flang -### -S -mllvm -print-before-all %s -o - 2>&1 | FileCheck %s --check-prefix=OPTION_FORWARDING
+
+! 3. Test invalid usage (`-print-before` requires an argument)
+! RUN: not %flang -S -mllvm -print-before %s -o - 2>&1 | FileCheck %s --check-prefix=INVALID_USAGE
+
+!
+! EXPECTED OUTPUT
+!
+! OUTPUT: *** IR Dump Before Pre-ISel Intrinsic Lowering (pre-isel-intrinsic-lowering) ***
+! OUTPUT-NEXT: ; ModuleID = 'FIRModule'
+! OUTPUT-NEXT: source_filename = "FIRModule"
+
+! Verify that `-mllvm ` is forwarded to flang -fc1
+! OPTION_FORWARDING: flang-new" "-fc1"
+! OPTION_FORWARDING-SAME: "-mllvm" "-print-before-all"
+
+! INVALID_USAGE: flang (LLVM option parsing): for the --print-before option: requires a value!
+
+!--
+! INPUT
+!--
+end program
Index: flang/test/Driver/driver-help.f90
===
--- flang/test/Driver/driver-help.f90
+++ flang/test/Driver/driver-help.f90
@@ -47,6 +47,7 @@
 ! HELP-NEXT: -fxor-operator Enable .XOR. as a synonym of .NEQV.
 ! HELP-NEXT: -help  Display available options
 ! HELP-NEXT: -IAdd directory to the end of the list of include search paths
+! HELP-NEXT: -mllvm  Additional arguments to forward to LLVM's option processing
 ! HELP-NEXT: -module-dir   Put MODULE files in 
 ! HELP-NEXT: -nocpp Disable predefined and command line preprocessor macros
 ! HELP-NEXT: -o   Write output to 
@@ -121,6 +122,7 @@
 ! HELP-FC1-NEXT: -init-only Only execute frontend initialization
 ! HELP-FC1-NEXT: -IAdd directory to the end of the list of include search paths
 ! HELP-FC1-NEXT: -load Load the named plugin (dynamic shared object)
+! HELP-FC1-NEXT: -mllvm  Additional arguments to forward to LLVM's option processing
 ! HELP-FC1-NEXT: -module-dir   Put MODULE files in 
 ! HELP-FC1-NEXT: -module-suffix  Use  as the suffix for module files (the default value is `.mod`)
 ! HELP-FC1-NEXT: -nocpp Disable predefined and command line preprocessor macros
Index: flang/test/Driver/driver-help-hidden.f90
===
--- flang/test/Driver/driver-help-hidden.f90
+++ flang/test/Driver/driver-help-hidden.f90
@@ -47,6 +47,7 @@
 ! CHECK-NEXT: -fxor-operator Enable .XOR. as a synonym of .NEQV.
 ! CHECK-NEXT: -help Display available options
 ! CHECK-NEXT: -IAdd directory to the end of the list of include search paths
+! CHECK-NEXT: -mllvm  Additional arguments to forward to LLVM's option processing
 ! CHECK-NEXT: -module-dir   Put MODULE files in 
 ! CHECK-NEXT: -nocpp Disable predefined and command line preprocessor macros
 ! CHECK-NEXT: -o  Write output to 
Index: flang/lib/FrontendTool/ExecuteCompilerInvocation.cpp
===
--- flang/lib/FrontendTool/ExecuteCompilerInvocation.cpp
+++ flang/lib/FrontendTool/ExecuteCompilerInvocation.cpp
@@ -135,6 +135,19 @@
 }
   }
 
+  // Honor -mllvm. This should happen AFTER plugins have been loaded!
+  if (!flang->frontendOpts().llvmArgs.empty()) {
+unsigned numArgs = flang->frontendOpts().llvmArgs.size();
+auto args = std::make_unique(numArgs + 2);
+args[0] = "flang (LLVM option parsing)";
+
+for (unsigned i = 0; i != numArgs; ++i)
+  args[i + 1] = flang->frontendOpts().llvmArgs[i].c_str();
+
+args[numArgs + 1] = nullptr;
+llvm::cl::ParseCommandLineOptions(numArgs + 1, args.get());
+  }
+
   // If there were errors in processing arguments, don't do anything else.
   if (flang->diagnostics().hasErrorOccurred()) {
 return false;
Index: flang/lib/Frontend/CompilerInvocation.cpp
=

[PATCH] D121410: Have cpu-specific variants set 'tune-cpu' as an optimization hint

2022-03-11 Thread Erich Keane via Phabricator via cfe-commits
erichkeane updated this revision to Diff 414650.
erichkeane added a comment.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

add a 'translation' feature to the x86 target so that we can get the 'tune cpu' 
name from the list.  Note that there are 9 with blanks that I was unable to 
figure out the corresponding name (I have an email out to @andrew.w.kaylor  and 
@pengfei to tell me what it should be). In the meantime, these will result in 
NO tune-cpu.

Also note that I intentionally added this conversion from the 'alias' as well.  
This gives us the power to use an alias to change the 'tune' if we care to.  
Typically I'd consider this unimportant, but it means that previously mentioned 
VendorA (@arsenm) could simply add their processors as aliases and get the tune 
feature more easily.


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

https://reviews.llvm.org/D121410

Files:
  clang/include/clang/Basic/TargetInfo.h
  clang/lib/Basic/Targets/X86.cpp
  clang/lib/Basic/Targets/X86.h
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/test/CodeGen/attr-cpuspecific-avx-abi.c
  clang/test/CodeGen/attr-cpuspecific.c
  llvm/include/llvm/Support/X86TargetParser.def

Index: llvm/include/llvm/Support/X86TargetParser.def
===
--- llvm/include/llvm/Support/X86TargetParser.def
+++ llvm/include/llvm/Support/X86TargetParser.def
@@ -211,47 +211,47 @@
 #undef X86_FEATURE
 
 #ifndef CPU_SPECIFIC
-#define CPU_SPECIFIC(NAME, MANGLING, FEATURES)
+#define CPU_SPECIFIC(NAME, TUNE_NAME, MANGLING, FEATURES)
 #endif
 
 #ifndef CPU_SPECIFIC_ALIAS
-#define CPU_SPECIFIC_ALIAS(NEW_NAME, NAME)
+#define CPU_SPECIFIC_ALIAS(NEW_NAME, TUNE_NAME, NAME)
 #endif
 
-CPU_SPECIFIC("generic", 'A', "")
-CPU_SPECIFIC("pentium", 'B', "")
-CPU_SPECIFIC("pentium_pro", 'C', "+cmov")
-CPU_SPECIFIC("pentium_mmx", 'D', "+mmx")
-CPU_SPECIFIC("pentium_ii", 'E', "+cmov,+mmx")
-CPU_SPECIFIC("pentium_iii", 'H', "+cmov,+mmx,+sse")
-CPU_SPECIFIC_ALIAS("pentium_iii_no_xmm_regs", "pentium_iii")
-CPU_SPECIFIC("pentium_4", 'J', "+cmov,+mmx,+sse,+sse2")
-CPU_SPECIFIC("pentium_m", 'K', "+cmov,+mmx,+sse,+sse2")
-CPU_SPECIFIC("pentium_4_sse3", 'L', "+cmov,+mmx,+sse,+sse2,+sse3")
-CPU_SPECIFIC("core_2_duo_ssse3", 'M', "+cmov,+mmx,+sse,+sse2,+sse3,+ssse3")
-CPU_SPECIFIC("core_2_duo_sse4_1", 'N', "+cmov,+mmx,+sse,+sse2,+sse3,+ssse3,+sse4.1")
-CPU_SPECIFIC("atom", 'O', "+cmov,+mmx,+sse,+sse2,+sse3,+ssse3,+movbe")
-CPU_SPECIFIC("atom_sse4_2", 'c', "+cmov,+mmx,+sse,+sse2,+sse3,+ssse3,+sse4.1,+sse4.2,+popcnt")
-CPU_SPECIFIC("core_i7_sse4_2", 'P', "+cmov,+mmx,+sse,+sse2,+sse3,+ssse3,+sse4.1,+sse4.2,+popcnt")
-CPU_SPECIFIC("core_aes_pclmulqdq", 'Q', "+cmov,+mmx,+sse,+sse2,+sse3,+ssse3,+sse4.1,+sse4.2,+popcnt")
-CPU_SPECIFIC("atom_sse4_2_movbe", 'd', "+cmov,+mmx,+sse,+sse2,+sse3,+ssse3,+sse4.1,+sse4.2,+movbe,+popcnt")
-CPU_SPECIFIC("goldmont", 'i', "+cmov,+mmx,+sse,+sse2,+sse3,+ssse3,+sse4.1,+sse4.2,+movbe,+popcnt")
-CPU_SPECIFIC("sandybridge", 'R', "+cmov,+mmx,+sse,+sse2,+sse3,+ssse3,+sse4.1,+sse4.2,+popcnt,+avx")
-CPU_SPECIFIC_ALIAS("core_2nd_gen_avx", "sandybridge")
-CPU_SPECIFIC("ivybridge", 'S', "+cmov,+mmx,+sse,+sse2,+sse3,+ssse3,+sse4.1,+sse4.2,+popcnt,+f16c,+avx")
-CPU_SPECIFIC_ALIAS("core_3rd_gen_avx", "ivybridge")
-CPU_SPECIFIC("haswell", 'V', "+cmov,+mmx,+sse,+sse2,+sse3,+ssse3,+sse4.1,+sse4.2,+movbe,+popcnt,+f16c,+avx,+fma,+bmi,+lzcnt,+avx2")
-CPU_SPECIFIC_ALIAS("core_4th_gen_avx", "haswell")
-CPU_SPECIFIC("core_4th_gen_avx_tsx", 'W', "+cmov,+mmx,+sse,+sse2,+sse3,+ssse3,+sse4.1,+sse4.2,+movbe,+popcnt,+f16c,+avx,+fma,+bmi,+lzcnt,+avx2")
-CPU_SPECIFIC("broadwell", 'X', "+cmov,+mmx,+sse,+sse2,+sse3,+ssse3,+sse4.1,+sse4.2,+movbe,+popcnt,+f16c,+avx,+fma,+bmi,+lzcnt,+avx2,+adx")
-CPU_SPECIFIC_ALIAS("core_5th_gen_avx", "broadwell")
-CPU_SPECIFIC("core_5th_gen_avx_tsx", 'Y', "+cmov,+mmx,+sse,+sse2,+sse3,+ssse3,+sse4.1,+sse4.2,+movbe,+popcnt,+f16c,+avx,+fma,+bmi,+lzcnt,+avx2,+adx")
-CPU_SPECIFIC("knl", 'Z', "+cmov,+mmx,+sse,+sse2,+sse3,+ssse3,+sse4.1,+sse4.2,+movbe,+popcnt,+f16c,+avx,+fma,+bmi,+lzcnt,+avx2,+avx512f,+adx,+avx512er,+avx512pf,+avx512cd")
-CPU_SPECIFIC_ALIAS("mic_avx512", "knl")
-CPU_SPECIFIC("skylake", 'b', "+cmov,+mmx,+sse,+sse2,+sse3,+ssse3,+sse4.1,+sse4.2,+movbe,+popcnt,+f16c,+avx,+fma,+bmi,+lzcnt,+avx2,+adx,+mpx")
-CPU_SPECIFIC( "skylake_avx512", 'a', "+cmov,+mmx,+sse,+sse2,+sse3,+ssse3,+sse4.1,+sse4.2,+movbe,+popcnt,+f16c,+avx,+fma,+bmi,+lzcnt,+avx2,+avx512dq,+avx512f,+adx,+avx512cd,+avx512bw,+avx512vl,+clwb")
-CPU_SPECIFIC("cannonlake", 'e', "+cmov,+mmx,+sse,+sse2,+sse3,+ssse3,+sse4.1,+sse4.2,+movbe,+popcnt,+f16c,+avx,+fma,+bmi,+lzcnt,+avx2,+avx512dq,+avx512f,+adx,+avx512ifma,+avx512cd,+avx512bw,+avx512vl,+avx512vbmi")
-CPU_SPECIFIC("knm", 'j', "+cmov,+mmx,+sse,+sse2,+sse3,+ssse3,+sse4.1,+sse4.2,+movbe,+popcnt,+f16c,+avx,+fma,+bmi,+lzcnt,+avx2,+avx512f,+adx,+avx512er,+avx512pf,+avx512cd,+avx5124fmaps,+avx5124vnniw,+avx512vpopcntdq")
+CPU_SPECIFIC("generic", "

[PATCH] D121410: Have cpu-specific variants set 'tune-cpu' as an optimization hint

2022-03-11 Thread Erich Keane via Phabricator via cfe-commits
erichkeane added inline comments.



Comment at: llvm/include/llvm/Support/X86TargetParser.def:230
+CPU_SPECIFIC("pentium_m", "pentium-m", 'K', "+cmov,+mmx,+sse,+sse2")
+CPU_SPECIFIC("pentium_4_sse3", "", 'L', "+cmov,+mmx,+sse,+sse2,+sse3")
+CPU_SPECIFIC("core_2_duo_ssse3", "", 'M', "+cmov,+mmx,+sse,+sse2,+sse3,+ssse3")

Note the blanks on 230-232, 234-237, 245, and 248.  Otherwise, a double-check 
would be really appreciated from everyone familiar with the x86 naming.


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

https://reviews.llvm.org/D121410

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


[PATCH] D121245: [clang][parser] Allow GNU attributes before namespace identifier

2022-03-11 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

Oh wow, GCC has supported this for a long time; I wasn't aware of that. Thanks 
for this patch!




Comment at: clang/lib/Parse/ParseDeclCXX.cpp:79
+
+  auto ReadLabelAttrubutes = [&] {
+// Read label attributes, if present.

However, I don't think there's a reason we need this lambda -- it seems we can 
call `MaybeParseGNUAttributes()` instead, and get the attribute location from 
the `ParsedAttributesWithRange` object passed in.



Comment at: clang/test/Parser/namespace-attributes.cpp:3
+
+namespace __attribute__((visibility("hidden"))) A
+{

Another test case that I think we need is to test attribute parsing order 
between the different syntaxes. e.g.,
```
namespace __attribute__(()) [[]] A
{
}

namespace [[]] __attribute__(()) B
{
}
```
It's not clear to me that we want to match how GCC handles this case: 
https://godbolt.org/z/e1bjcEje6 but instead handle it more like how Clang 
handles it in structure declarations: https://godbolt.org/z/drGhb65ET.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D121245

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


[clang] 3aca0ff - [clang][SVE] Add support for arithmetic operators on SVE types

2022-03-11 Thread David Truby via cfe-commits

Author: David Truby
Date: 2022-03-11T15:39:44Z
New Revision: 3aca0ffd5092e37590bbee7e0fcd2b1b5780024c

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

LOG: [clang][SVE] Add support for arithmetic operators on SVE types

This patch implements support for the +, -, *, / and % operators on sizeless SVE
types. Support for these operators on svbool_t is excluded.

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

Added: 
clang/test/CodeGen/aarch64-sve-vector-ops.c
clang/test/Sema/aarch64-sve-vector-ops.c

Modified: 
clang/include/clang/AST/Type.h
clang/include/clang/Sema/Sema.h
clang/lib/AST/Type.cpp
clang/lib/Sema/SemaExpr.cpp
clang/test/Sema/sizeless-1.c
clang/test/SemaCXX/sizeless-1.cpp

Removed: 




diff  --git a/clang/include/clang/AST/Type.h b/clang/include/clang/AST/Type.h
index 3c71cbbb9c8f3..76e4474b1b303 100644
--- a/clang/include/clang/AST/Type.h
+++ b/clang/include/clang/AST/Type.h
@@ -2557,6 +2557,8 @@ class BuiltinType : public Type {
 return getKind() >= Half && getKind() <= Ibm128;
   }
 
+  bool isSVEBool() const { return getKind() == Kind::SveBool; }
+
   /// Determines whether the given kind corresponds to a placeholder type.
   static bool isPlaceholderTypeKind(Kind K) {
 return K >= Overload;

diff  --git a/clang/include/clang/Sema/Sema.h b/clang/include/clang/Sema/Sema.h
index d072cf9223f7d..4c5666f290141 100644
--- a/clang/include/clang/Sema/Sema.h
+++ b/clang/include/clang/Sema/Sema.h
@@ -11940,6 +11940,10 @@ class Sema final {
   QualType CheckVectorLogicalOperands(ExprResult &LHS, ExprResult &RHS,
   SourceLocation Loc);
 
+  // type checking for sizeless vector binary operators.
+  QualType CheckSizelessVectorOperands(ExprResult &LHS, ExprResult &RHS,
+   SourceLocation Loc);
+
   /// Type checking for matrix binary operators.
   QualType CheckMatrixElementwiseOperands(ExprResult &LHS, ExprResult &RHS,
   SourceLocation Loc,

diff  --git a/clang/lib/AST/Type.cpp b/clang/lib/AST/Type.cpp
index 1c7499c3c237e..8579d697868fd 100644
--- a/clang/lib/AST/Type.cpp
+++ b/clang/lib/AST/Type.cpp
@@ -2105,6 +2105,11 @@ bool Type::hasUnsignedIntegerRepresentation() const {
 return VT->getElementType()->isUnsignedIntegerOrEnumerationType();
   if (const auto *VT = dyn_cast(CanonicalType))
 return VT->getElementType()->isUnsignedIntegerOrEnumerationType();
+  if (CanonicalType->isVLSTBuiltinType()) {
+const auto *VT = cast(CanonicalType);
+return VT->getKind() >= BuiltinType::SveUint8 &&
+   VT->getKind() <= BuiltinType::SveUint64;
+  }
   return isUnsignedIntegerOrEnumerationType();
 }
 

diff  --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp
index ca5e206f8933d..96471f6c5fb1f 100644
--- a/clang/lib/Sema/SemaExpr.cpp
+++ b/clang/lib/Sema/SemaExpr.cpp
@@ -10403,6 +10403,29 @@ QualType Sema::CheckVectorOperands(ExprResult &LHS, 
ExprResult &RHS,
   return QualType();
 }
 
+QualType Sema::CheckSizelessVectorOperands(ExprResult &LHS, ExprResult &RHS,
+   SourceLocation Loc) {
+  QualType LHSType = LHS.get()->getType().getUnqualifiedType();
+  QualType RHSType = RHS.get()->getType().getUnqualifiedType();
+
+  const BuiltinType *LHSVecType = LHSType->getAs();
+  const BuiltinType *RHSVecType = RHSType->getAs();
+
+  unsigned DiagID = diag::err_typecheck_invalid_operands;
+  if (LHSVecType->isSVEBool() || RHSVecType->isSVEBool()) {
+Diag(Loc, DiagID) << LHSType << RHSType << LHS.get()->getSourceRange()
+  << RHS.get()->getSourceRange();
+return QualType();
+  }
+
+  if (Context.hasSameType(LHSType, RHSType))
+return LHSType;
+
+  Diag(Loc, DiagID) << LHSType << RHSType << LHS.get()->getSourceRange()
+<< RHS.get()->getSourceRange();
+  return QualType();
+}
+
 // checkArithmeticNull - Detect when a NULL constant is used improperly in an
 // expression.  These are mainly cases where the null pointer is used as an
 // integer instead of a pointer.
@@ -10512,8 +10535,10 @@ QualType Sema::CheckMultiplyDivideOperands(ExprResult 
&LHS, ExprResult &RHS,
   QualType RHSTy = RHS.get()->getType();
   if (LHSTy->isVectorType() || RHSTy->isVectorType())
 return CheckVectorOperands(LHS, RHS, Loc, IsCompAssign,
-   /*AllowBothBool*/getLangOpts().AltiVec,
-   /*AllowBoolConversions*/false);
+   /*AllowBothBool*/ getLangOpts().AltiVec,
+   /*AllowBoolConversions*/ false);
+  if (LHSTy->isVLSTBuiltinType() || RHSTy->isVLSTBuiltinType())
+return CheckSizelessVectorOperands(LHS, RHS, Loc);
   if (!

[PATCH] D120323: [clang][SVE] Add support for arithmetic operators on SVE types

2022-03-11 Thread David Truby via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG3aca0ffd5092: [clang][SVE] Add support for arithmetic 
operators on SVE types (authored by DavidTruby).

Changed prior to commit:
  https://reviews.llvm.org/D120323?vs=413470&id=414656#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D120323

Files:
  clang/include/clang/AST/Type.h
  clang/include/clang/Sema/Sema.h
  clang/lib/AST/Type.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/test/CodeGen/aarch64-sve-vector-ops.c
  clang/test/Sema/aarch64-sve-vector-ops.c
  clang/test/Sema/sizeless-1.c
  clang/test/SemaCXX/sizeless-1.cpp

Index: clang/test/SemaCXX/sizeless-1.cpp
===
--- clang/test/SemaCXX/sizeless-1.cpp
+++ clang/test/SemaCXX/sizeless-1.cpp
@@ -211,11 +211,6 @@
   __real init_int8; // expected-error {{invalid type 'svint8_t'}}
   __imag init_int8; // expected-error {{invalid type 'svint8_t'}}
 
-  local_int8 + init_int8;  // expected-error {{invalid operands to binary expression}}
-  local_int8 - init_int8;  // expected-error {{invalid operands to binary expression}}
-  local_int8 *init_int8;   // expected-error {{invalid operands to binary expression}}
-  local_int8 / init_int8;  // expected-error {{invalid operands to binary expression}}
-  local_int8 % init_int8;  // expected-error {{invalid operands to binary expression}}
   local_int8 &init_int8;   // expected-error {{invalid operands to binary expression}}
   local_int8 | init_int8;  // expected-error {{invalid operands to binary expression}}
   local_int8 ^ init_int8;  // expected-error {{invalid operands to binary expression}}
@@ -230,11 +225,6 @@
   local_int8 &&init_int8;  // expected-error {{invalid operands to binary expression}} expected-error {{not contextually convertible}}
   local_int8 || init_int8; // expected-error {{invalid operands to binary expression}} expected-error {{not contextually convertible}}
 
-  local_int8 += init_int8;  // expected-error {{invalid operands to binary expression}}
-  local_int8 -= init_int8;  // expected-error {{invalid operands to binary expression}}
-  local_int8 *= init_int8;  // expected-error {{invalid operands to binary expression}}
-  local_int8 /= init_int8;  // expected-error {{invalid operands to binary expression}}
-  local_int8 %= init_int8;  // expected-error {{invalid operands to binary expression}}
   local_int8 &= init_int8;  // expected-error {{invalid operands to binary expression}}
   local_int8 |= init_int8;  // expected-error {{invalid operands to binary expression}}
   local_int8 ^= init_int8;  // expected-error {{invalid operands to binary expression}}
Index: clang/test/Sema/sizeless-1.c
===
--- clang/test/Sema/sizeless-1.c
+++ clang/test/Sema/sizeless-1.c
@@ -199,11 +199,6 @@
   __real init_int8; // expected-error {{invalid type 'svint8_t'}}
   __imag init_int8; // expected-error {{invalid type 'svint8_t'}}
 
-  local_int8 + init_int8;  // expected-error {{invalid operands to binary expression}}
-  local_int8 - init_int8;  // expected-error {{invalid operands to binary expression}}
-  local_int8 *init_int8;   // expected-error {{invalid operands to binary expression}}
-  local_int8 / init_int8;  // expected-error {{invalid operands to binary expression}}
-  local_int8 % init_int8;  // expected-error {{invalid operands to binary expression}}
   local_int8 &init_int8;   // expected-error {{invalid operands to binary expression}}
   local_int8 | init_int8;  // expected-error {{invalid operands to binary expression}}
   local_int8 ^ init_int8;  // expected-error {{invalid operands to binary expression}}
@@ -218,11 +213,6 @@
   local_int8 &&init_int8;  // expected-error {{invalid operands to binary expression}}
   local_int8 || init_int8; // expected-error {{invalid operands to binary expression}}
 
-  local_int8 += init_int8;  // expected-error {{invalid operands to binary expression}}
-  local_int8 -= init_int8;  // expected-error {{invalid operands to binary expression}}
-  local_int8 *= init_int8;  // expected-error {{invalid operands to binary expression}}
-  local_int8 /= init_int8;  // expected-error {{invalid operands to binary expression}}
-  local_int8 %= init_int8;  // expected-error {{invalid operands to binary expression}}
   local_int8 &= init_int8;  // expected-error {{invalid operands to binary expression}}
   local_int8 |= init_int8;  // expected-error {{invalid operands to binary expression}}
   local_int8 ^= init_int8;  // expected-error {{invalid operands to binary expression}}
Index: clang/test/Sema/aarch64-sve-vector-ops.c
===
--- /dev/null
+++ clang/test/Sema/aarch64-sve-vector-ops.c
@@ -0,0 +1,645 @@
+// RUN: %clang_cc1 -verify -triple aarch64-none-linux-gnu -target-feature +sve -fallow-half-arguments

[PATCH] D121451: [clang-format] Add space to comments starting with '#'.

2022-03-11 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay added a comment.

Is this conforming to `SpacesInLineCommentPrefix`


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D121451

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


[PATCH] D121465: WIP: [clang][modules] Do not report declarations without linkage as ambiguous

2022-03-11 Thread Jan Svoboda via Phabricator via cfe-commits
jansvoboda11 created this revision.
jansvoboda11 added reviewers: Bigcheese, vsapsai.
Herald added a project: All.
jansvoboda11 requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

When finalizing the result of name lookup that encountered ambiguity, we check 
equivalence for declarations with internal linkage. If the declarations are 
equivalent, we just produce a warning instead of ambiguous result.

In `Sema::isEquivalentInternalLinkageDeclaration` that implements the check, we 
have a special case for constants of anonymous enums. However, it only kicks in 
for C++ anonymous enums (since they have `NoLinkage`, meaning they are not 
externally visible).

In (Objective)C, constants of anonymous enums are `VisibleNoLinkage`, meaning 
they _are_ externally visible, so the special case doesn't apply for them.

This patch renames the function to `isEquivalentNonExternalLinkageDeclaration` 
(its documentation already says it handles declarations with "internal/no 
linkage") and makes it so that even `VisibleNoLinkage` declarations are not 
marked as ambiguous. This is achieved by using `hasExternalFormalLinkage` 
instead of `isExternallyVisible` in one of the equivalence checks. Later on, we 
don't even emit the warning for such declarations, since they are considered 
the same entity.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D121465

Files:
  clang/include/clang/Sema/Sema.h
  clang/lib/Sema/SemaDeclCXX.cpp
  clang/lib/Sema/SemaLookup.cpp
  clang/lib/Sema/SemaOverload.cpp
  clang/test/Modules/ambiguous-anonymous-enum-lookup.m.cpp

Index: clang/test/Modules/ambiguous-anonymous-enum-lookup.m.cpp
===
--- /dev/null
+++ clang/test/Modules/ambiguous-anonymous-enum-lookup.m.cpp
@@ -0,0 +1,40 @@
+// RUN: rm -rf %t
+// RUN: split-file %s %t
+// RUN: %clang_cc1 -fsyntax-only -fmodules -fimplicit-module-maps -fmodules-cache-path=%t/modules.cache -I %t/include %t/test.cpp -verify
+// RUN: %clang_cc1 -fsyntax-only -fmodules -fimplicit-module-maps -fmodules-cache-path=%t/modules.cache -I %t/include %t/test.m   -verify
+
+//--- include/textual.h
+#ifndef TEXTUAL_H
+#define TEXTUAL_H
+enum { kAnonymousEnumValue = 0 };
+#endif
+
+//--- include/empty.h
+//--- include/initially_hidden.h
+#include "textual.h"
+
+//--- include/module.modulemap
+module Piecewise {
+  module Empty   { header "empty.h"}
+  module InitiallyHidden { header "initially_hidden.h" }
+}
+
+//--- test.cpp
+#include "empty.h"
+#include "textual.h"
+#include "initially_hidden.h"
+
+int testReferencingAnonymousEnumConstant() {
+  return kAnonymousEnumValue; // expected-warning {{ambiguous use of internal linkage declaration 'kAnonymousEnumValue' defined in multiple modules}}
+  // expected-note@textual.h:3 {{declared here}}
+  // expected-note@textual.h:3 {{declared here in module 'Piecewise.InitiallyHidden'}}
+}
+
+//--- test.m
+#include "empty.h"
+#include "textual.h"
+#include "initially_hidden.h"
+
+int testReferencingAnonymousEnumConstant() {
+  return kAnonymousEnumValue; // expected-no-diagnostics
+}
Index: clang/lib/Sema/SemaOverload.cpp
===
--- clang/lib/Sema/SemaOverload.cpp
+++ clang/lib/Sema/SemaOverload.cpp
@@ -9955,19 +9955,19 @@
 /// declare the same entity, but we also don't want lookups with both
 /// declarations visible to be ambiguous in some cases (this happens when using
 /// a modularized libstdc++).
-bool Sema::isEquivalentInternalLinkageDeclaration(const NamedDecl *A,
-  const NamedDecl *B) {
+bool Sema::isEquivalentNonExternalLinkageDeclaration(const NamedDecl *A,
+ const NamedDecl *B) {
   auto *VA = dyn_cast_or_null(A);
   auto *VB = dyn_cast_or_null(B);
   if (!VA || !VB)
 return false;
 
-  // The declarations must be declaring the same name as an internal linkage
+  // The declarations must be declaring the same name as an internal/no linkage
   // entity in different modules.
   if (!VA->getDeclContext()->getRedeclContext()->Equals(
   VB->getDeclContext()->getRedeclContext()) ||
   getOwningModule(VA) == getOwningModule(VB) ||
-  VA->isExternallyVisible() || VB->isExternallyVisible())
+  VA->hasExternalFormalLinkage() || VB->hasExternalFormalLinkage())
 return false;
 
   // Check that the declarations appear to be equivalent.
@@ -10093,8 +10093,8 @@
 PendingBest.push_back(Cand);
 Cand->Best = true;
 
-if (S.isEquivalentInternalLinkageDeclaration(Cand->Function,
- Curr->Function))
+if (S.isEquivalentNonExternalLinkageDeclaration(Cand->Function,
+Curr->Function))
   EquivalentCand

[PATCH] D121466: [OpenMP] Replace math headers with OpenMP wrapper calls

2022-03-11 Thread Joseph Huber via Phabricator via cfe-commits
jhuber6 created this revision.
jhuber6 added reviewers: JonChesterfield, tianshilei1992, jdoerfert, 
ggeorgakoudis.
Herald added subscribers: asavonic, dang, guansong, yaxunl, mgorny.
Herald added a project: All.
jhuber6 requested review of this revision.
Herald added subscribers: cfe-commits, sstefan1.
Herald added a project: clang.

This patch replaces the math functions when called on the device with an
`__omp_` variant that we can use. This will later be turned back into
the regular math call so we can avoid the problems with including math.h
on the device. This patch introduces the `-fopenmp-device-libm` flag
which enables the new math wrappers by defining __MATH_WRAPPERS__ in the
header.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D121466

Files:
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Headers/CMakeLists.txt
  clang/lib/Headers/openmp_wrappers/__clang_openmp_math.h
  clang/lib/Headers/openmp_wrappers/__clang_openmp_math_forward_declares.h
  clang/lib/Headers/openmp_wrappers/math.h
  clang/test/Headers/nvptx_device_cmath_functions.c
  clang/test/Headers/nvptx_device_cmath_functions.cpp
  clang/test/Headers/nvptx_device_cmath_functions_cxx17.cpp
  clang/test/Headers/nvptx_device_math_functions.c
  clang/test/Headers/nvptx_device_math_functions.cpp
  clang/test/Headers/nvptx_device_math_functions_cxx17.cpp

Index: clang/test/Headers/nvptx_device_math_functions_cxx17.cpp
===
--- clang/test/Headers/nvptx_device_math_functions_cxx17.cpp
+++ clang/test/Headers/nvptx_device_math_functions_cxx17.cpp
@@ -5,6 +5,7 @@
 
 // RUN: %clang_cc1 -internal-isystem %S/Inputs/include -x c++ -fopenmp -triple powerpc64le-unknown-unknown -fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm-bc %s -o %t-ppc-host.bc -std=c++17
 // RUN: %clang_cc1 -internal-isystem %S/../../lib/Headers/openmp_wrappers -include __clang_openmp_device_functions.h -internal-isystem %S/../../lib/Headers/openmp_wrappers -internal-isystem %S/Inputs/include -x c++ -fopenmp -triple nvptx64-nvidia-cuda -aux-triple powerpc64le-unknown-unknown -fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm %s -fopenmp-is-device -fopenmp-host-ir-file-path %t-ppc-host.bc -std=c++17 -o - | FileCheck -check-prefix CHECK-YES %s
+// RUN: %clang_cc1 -internal-isystem %S/../../lib/Headers/openmp_wrappers -include __clang_openmp_device_functions.h -internal-isystem %S/../../lib/Headers/openmp_wrappers -internal-isystem %S/Inputs/include -x c++ -fopenmp -triple nvptx64-nvidia-cuda -aux-triple powerpc64le-unknown-unknown -fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm %s -fopenmp-is-device -fopenmp-host-ir-file-path %t-ppc-host.bc -std=c++17 -D__MATH_WRAPPERS__ -o - | FileCheck -check-prefix CHECK-LIBM %s
 
 #include 
 #include 
@@ -13,14 +14,19 @@
   #pragma omp target
   {
 // CHECK-YES: call double @__nv_sqrt(double
+// CHECK-LIBM: call double @__omp_sqrt(double
 double l1 = sqrt(a1);
 // CHECK-YES: call double @__nv_pow(double
+// CHECK-LIBM: call double @__omp_pow(double
 double l2 = pow(a1, a1);
 // CHECK-YES: call double @__nv_modf(double
+// CHECK-LIBM: call double @__omp_modf(double
 double l3 = modf(a1 + 3.5, &a1);
 // CHECK-YES: call double @__nv_fabs(double
+// CHECK-LIBM: call double @__omp_fabs(double
 double l4 = fabs(a1);
 // CHECK-YES: call i32 @__nv_abs(i32
+// CHECK-LIBM: call i32 @__omp_abs(i32
 double l5 = abs((int)a1);
   }
 }
Index: clang/test/Headers/nvptx_device_math_functions.cpp
===
--- clang/test/Headers/nvptx_device_math_functions.cpp
+++ clang/test/Headers/nvptx_device_math_functions.cpp
@@ -13,14 +13,19 @@
   #pragma omp target
   {
 // CHECK-YES: call double @__nv_sqrt(double
+// CHECK-LIBM: call double @__omp_sqrt(double
 double l1 = sqrt(a1);
 // CHECK-YES: call double @__nv_pow(double
+// CHECK-LIBM: call double @__omp_pow(double
 double l2 = pow(a1, a1);
 // CHECK-YES: call double @__nv_modf(double
+// CHECK-LIBM: call double @__omp_modf(double
 double l3 = modf(a1 + 3.5, &a1);
 // CHECK-YES: call double @__nv_fabs(double
+// CHECK-LIBM: call double @__omp_fabs(double
 double l4 = fabs(a1);
 // CHECK-YES: call i32 @__nv_abs(i32
+// CHECK-LIBM: call i32 @__omp_abs(i32
 double l5 = abs((int)a1);
   }
 }
Index: clang/test/Headers/nvptx_device_math_functions.c
===
--- clang/test/Headers/nvptx_device_math_functions.c
+++ clang/test/Headers/nvptx_device_math_functions.c
@@ -5,8 +5,10 @@
 
 // RUN: %clang_cc1 -x c -internal-isystem %S/Inputs/include -fopenmp -triple powerpc64le-unknown-unknown -fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm-bc %s -o %t-ppc-host.bc
 // RUN: %clang_cc1 -x c -internal-isystem %S/../../lib/Headers/openmp_wrappers -include __clang_openmp_device_functio

[PATCH] D121468: [OpenMP] Add linking of OpenMP math library

2022-03-11 Thread Joseph Huber via Phabricator via cfe-commits
jhuber6 created this revision.
jhuber6 added reviewers: JonChesterfield, tianshilei1992, jdoerfert, 
ggeorgakoudis.
Herald added subscribers: asavonic, dang, kerbowa, guansong, yaxunl, jvesely.
Herald added a project: All.
jhuber6 requested review of this revision.
Herald added subscribers: cfe-commits, sstefan1.
Herald added a project: clang.

This patch adds support for linking in the OpenMP math wrappers library.
The math library first replaces all math calls with an OpenMP wrapper
call. This wrapper call is linked early with a library that associates
the wrapper call to the original math function. This is necessary to
have access to the math function symbols without including the math
header which includes incompatible code with the GPU. These wrapper
functions have another library which maps them to the device library
version late when doing LTO. Linking libdevice must be done after this
library and done late when doing LTO. Unfortunately doing LTO with
libdevice is very slow right now.

Depends on D121467 


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D121468

Files:
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/ToolChains/AMDGPUOpenMP.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Driver/ToolChains/CommonArgs.cpp
  clang/lib/Driver/ToolChains/CommonArgs.h
  clang/lib/Driver/ToolChains/Cuda.cpp
  clang/test/Driver/Inputs/libomptarget/libomptarget-nvptx-math.bc
  clang/test/Driver/Inputs/libomptarget/libomptarget-nvptx-wrapper.bc
  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
@@ -346,3 +346,13 @@
 // RUN:   | FileCheck -check-prefix=NEW_DRIVER_EMBEDDING %s
 
 // NEW_DRIVER_EMBEDDING: -fembed-offload-object=[[CUBIN:.*\.cubin]],nvptx64-nvidia-cuda.sm_70
+
+// RUN:   %clang -### -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda -Xopenmp-target=nvptx64-nvida-cuda -march=sm_70 \
+// RUN:  --libomptarget-nvptx-wrapper-bc-path=%S/Inputs/libomptarget/libomptarget-nvptx-wrapper.bc \
+// RUN:  --libomptarget-nvptx-math-bc-path=%S/Inputs/libomptarget/libomptarget-nvptx-math.bc \
+// RUN:  --libomptarget-nvptx-bc-path=%S/Inputs/libomptarget/libomptarget-new-nvptx-test.bc \
+// RUN:  -foffload-lto -fopenmp-device-libm -fopenmp-new-driver -no-canonical-prefixes %s -o openmp-offload-gpu 2>&1 \
+// RUN:   | FileCheck -check-prefix=DEVICE_LIBM %s
+
+// DEVICE_LIBM: clang{{.*}}"-mlink-builtin-bitcode" "{{.*}}/Inputs/libomptarget/libomptarget-nvptx-wrapper.bc"
+// DEVICE_LIBM: clang-linker-wrapper{{.*}}"-target-library=nvptx64-nvidia-cuda-sm_70={{.*}}/Inputs/libomptarget/libomptarget-new-nvptx-test.bc" "-target-library=nvptx64-nvidia-cuda-sm_70={{.*}}/Inputs/libomptarget/libomptarget-nvptx-math.bc"
Index: clang/lib/Driver/ToolChains/Cuda.cpp
===
--- clang/lib/Driver/ToolChains/Cuda.cpp
+++ clang/lib/Driver/ToolChains/Cuda.cpp
@@ -696,9 +696,6 @@
 return;
   }
 
-  CC1Args.push_back("-mlink-builtin-bitcode");
-  CC1Args.push_back(DriverArgs.MakeArgString(LibDeviceFile));
-
   clang::CudaVersion CudaInstallationVersion = CudaInstallation.version();
 
   // New CUDA versions often introduce new instructions that are only supported
@@ -744,12 +741,19 @@
   return;
 }
 
+if (DriverArgs.hasArg(options::OPT_fopenmp_device_libm))
+  addOpenMPMathRTL(getDriver(), DriverArgs, CC1Args, getTriple());
+
 // Link the bitcode library late if we're using device LTO.
 if (getDriver().isUsingLTO(/* IsOffload */ true))
   return;
 
 addOpenMPDeviceRTL(getDriver(), DriverArgs, CC1Args, GpuArch.str(),
getTriple());
+
+CC1Args.push_back("-mlink-builtin-bitcode");
+CC1Args.push_back(DriverArgs.MakeArgString(LibDeviceFile));
+
 AddStaticDeviceLibsPostLinking(getDriver(), DriverArgs, CC1Args, "nvptx",
GpuArch, /*isBitCodeSDL=*/true,
/*postClangLink=*/true);
Index: clang/lib/Driver/ToolChains/CommonArgs.h
===
--- clang/lib/Driver/ToolChains/CommonArgs.h
+++ clang/lib/Driver/ToolChains/CommonArgs.h
@@ -189,6 +189,10 @@
 llvm::opt::ArgStringList &CmdArgs,
 const llvm::Triple &Triple, bool IsLTO);
 
+void addOpenMPMathRTL(const Driver &D, const llvm::opt::ArgList &DriverArgs,
+  llvm::opt::ArgStringList &CC1Args,
+  const llvm::Triple &Triple, bool IncludeLibm = false);
+
 void addOpenMPDeviceRTL(const Driver &D, const llvm::opt::ArgList &DriverArgs,
 llvm::opt::ArgStringList &CC1Args,
 StringRef BitcodeSuffix, const llvm::Triple &Triple);

[clang] 058c92f - [clang][SVE] Add aarch64-registered-target to sve vector op tests

2022-03-11 Thread David Truby via cfe-commits

Author: David Truby
Date: 2022-03-11T16:01:00Z
New Revision: 058c92f2a4e865d478b29035c207ec0744229d6a

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

LOG: [clang][SVE] Add aarch64-registered-target to sve vector op tests

This fixes failing tests where aarch64 isn't available.

Added: 


Modified: 
clang/test/CodeGen/aarch64-sve-vector-ops.c

Removed: 




diff  --git a/clang/test/CodeGen/aarch64-sve-vector-ops.c 
b/clang/test/CodeGen/aarch64-sve-vector-ops.c
index 15a05e940d981..7fb307cb497b0 100644
--- a/clang/test/CodeGen/aarch64-sve-vector-ops.c
+++ b/clang/test/CodeGen/aarch64-sve-vector-ops.c
@@ -2,6 +2,8 @@
 // RUN: -fallow-half-arguments-and-returns \
 // RUN:  -O1 -emit-llvm -o - %s 2>&1 | FileCheck %s
 
+// REQUIRES: aarch64-registered-target
+
 #include 
 
 // ADDITION



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


[PATCH] D121201: [clang] Merge the SourceRange into ParsedAttributes

2022-03-11 Thread Erich Keane via Phabricator via cfe-commits
erichkeane added a comment.

Just a couple of questions/comments.  Otherwise this seems pretty ok.




Comment at: clang/lib/Parse/ParseCXXInlineMethods.cpp:745
 
-  ParseGNUAttributeArgs(&LA.AttrName, LA.AttrNameLoc, Attrs, &endLoc,
+  ParseGNUAttributeArgs(&LA.AttrName, LA.AttrNameLoc, Attrs, nullptr,
 nullptr, SourceLocation(), ParsedAttr::AS_GNU,

This change is concerning, shouldn't ParseGNUAttributeArgs just be losing its 
'EndLoc' pointer instead?



Comment at: clang/lib/Parse/ParseDecl.cpp:1424
+IdentifierInfo &ObjCBridgeRelated, SourceLocation ObjCBridgeRelatedLoc,
+ParsedAttributes &attrs, SourceLocation *endLoc, IdentifierInfo *ScopeName,
+SourceLocation ScopeLoc, ParsedAttr::Syntax Syntax) {

Could we lose the endLoc here as well?



Comment at: clang/lib/Parse/ParseDeclCXX.cpp:3207
+  if (Tok.is(tok::kw___attribute)) {
+ParsedAttributes Attrs(AttrFactory);
 MaybeParseGNUAttributes(Attrs);

This seems like a particularly strange change, What is the reasoning for this?  
Is it just that the Attrs are unused?



Comment at: clang/lib/Parse/ParseDeclCXX.cpp:4361
 
-/// ParseCXX11AttributeSpecifier - Parse a C++11 or C2x attribute-specifier.
+/// ParseCXX11AttributeSpecifierInternal - Parse a C++11 or C2x
+/// attribute-specifier.

I believe we aren't supposed to be putting the 'name' of the function in the 
comments anymore, can you just remove it instead of updating it?



Comment at: clang/lib/Sema/SemaType.cpp:8129
+
+  state.setParsedNoDeref(false);
+  if (attrs.empty())

What is the justification for this set of changes?  Is it simply to 'early 
exit' rather than make the unnecessary copy?


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

https://reviews.llvm.org/D121201

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


[PATCH] D121201: [clang] Merge the SourceRange into ParsedAttributes

2022-03-11 Thread Erich Keane via Phabricator via cfe-commits
erichkeane added inline comments.



Comment at: clang/include/clang/Sema/ParsedAttr.h:920
 
   void clearListOnly() { AttrList.clear(); }
 

Also, this function is now strange/likely needs a rename, since it likely needs 
to reset the range as well.  I believe the point of this being a separate 
function is to not clear the 'pool'.



Comment at: clang/include/clang/Sema/ParsedAttr.h:1105
   void clearListOnly() {
 ParsedAttributesView::clearListOnly();
 Range = SourceRange();

This is... oh boy.  I'm hopeful you can remove this type as well.



Comment at: clang/test/SemaOpenCL/address-spaces.cl:261
   typedef __private int private_int_t;
-  __private __attribute__((opencl_global)) int var1;   // expected-error 
{{multiple address spaces specified for type}} \
+  __attribute__((opencl_global)) __private int var1;   // expected-error 
{{multiple address spaces specified for type}} \
// expected-error 
{{function scope variable cannot be declared in global address space}}

tbaeder wrote:
> This is a peculiar ordering problem...
can you debug this to see what the problem is?  I wouldn't expect the ordering 
to matter here.


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

https://reviews.llvm.org/D121201

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


[PATCH] D121201: [clang] Merge the SourceRange into ParsedAttributes

2022-03-11 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a reviewer: erichkeane.
aaron.ballman added a comment.

> I wasn't 100% whether to add the range to ParsedAttributes or even 
> ParsedAttributesView.

I think `ParsedAttributesView` is the correct level for this -- I want to see 
us tracking the source range for all the parsed attributes (we need the 
information for diagnostics more often than not), and this ensures we always 
have access to that information.

> There's still a ParsedAttributesViewWithRange which basically used once in 
> ParseDeclCXX.cpp.

Any idea why we can't get rid of that one? (Maybe it'll become more clear to me 
as I review more.)




Comment at: clang/include/clang/Parse/Parser.h:1583-1591
+  DeclGroupPtrTy ParseExternalDeclaration(ParsedAttributes &attrs,
   ParsingDeclSpec *DS = nullptr);
   bool isDeclarationAfterDeclarator();
   bool isStartOfFunctionDefinition(const ParsingDeclarator &Declarator);
-  DeclGroupPtrTy ParseDeclarationOrFunctionDefinition(
-  ParsedAttributesWithRange 
&attrs,
-  ParsingDeclSpec *DS = 
nullptr,
-  AccessSpecifier AS = 
AS_none);
-  DeclGroupPtrTy ParseDeclOrFunctionDefInternal(ParsedAttributesWithRange 
&attrs,
+  DeclGroupPtrTy
+  ParseDeclarationOrFunctionDefinition(ParsedAttributes &attrs,
+   ParsingDeclSpec *DS = nullptr,





Comment at: clang/include/clang/Parse/Parser.h:2071
   StmtResult ParseExprStatement(ParsedStmtContext StmtCtx);
-  StmtResult ParseLabeledStatement(ParsedAttributesWithRange &attrs,
+  StmtResult ParseLabeledStatement(ParsedAttributes &attrs,
ParsedStmtContext StmtCtx);





Comment at: clang/include/clang/Parse/Parser.h:2310
   SourceLocation &DeclEnd,
-  ParsedAttributesWithRange &attrs,
+  ParsedAttributes &attrs,
   SourceLocation *DeclSpecStart = nullptr);





Comment at: clang/include/clang/Parse/Parser.h:2314
   ParseSimpleDeclaration(DeclaratorContext Context, SourceLocation &DeclEnd,
- ParsedAttributesWithRange &attrs, bool RequireSemi,
+ ParsedAttributes &attrs, bool RequireSemi,
  ForRangeInit *FRI = nullptr,

I'll stop commenting on these -- if you see a function signature where the 
parsed attribute parameter identifier uses the wrong coding style *and* the 
rest of the parameters already use the right style, might as well hit those 
identifiers. No need to fix all naming issues with the touched functions 
(unless you feel like doing an NFC commit to change them).



Comment at: clang/lib/Parse/ParseDecl.cpp:500
 /// a C++11 attribute in "gnu" namespace.
-void Parser::ParseGNUAttributeArgs(IdentifierInfo *AttrName,
-   SourceLocation AttrNameLoc,
-   ParsedAttributes &Attrs,
-   SourceLocation *EndLoc,
-   IdentifierInfo *ScopeName,
-   SourceLocation ScopeLoc,
-   ParsedAttr::Syntax Syntax,
-   Declarator *D) {
+void Parser::ParseGNUAttributeArgs(
+IdentifierInfo *AttrName, SourceLocation AttrNameLoc,

It looks like some unrelated formatting changes snuck in? I'm not opposed, but 
it's a bit easier to review if this was an NFC commit (before or after landing 
this patch) because it makes for a smaller diff here. (I noticed this in a few 
spots, only commenting about it here.)



Comment at: clang/test/SemaOpenCL/address-spaces.cl:261
   typedef __private int private_int_t;
-  __private __attribute__((opencl_global)) int var1;   // expected-error 
{{multiple address spaces specified for type}} \
+  __attribute__((opencl_global)) __private int var1;   // expected-error 
{{multiple address spaces specified for type}} \
// expected-error 
{{function scope variable cannot be declared in global address space}}

tbaeder wrote:
> This is a peculiar ordering problem...
I think we need to ensure that we still diagnose both ways, otherwise we'll 
start to accept invalid code: https://godbolt.org/z/h7473Ehc5

Or does the behavior change here in other ways?


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

https://reviews.llvm.org/D121201

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


[PATCH] D121201: [clang] Merge the SourceRange into ParsedAttributes

2022-03-11 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: clang/include/clang/Sema/ParsedAttr.h:1105
   void clearListOnly() {
 ParsedAttributesView::clearListOnly();
 Range = SourceRange();

erichkeane wrote:
> This is... oh boy.  I'm hopeful you can remove this type as well.
+1, it'd be fantastic if we could, otherwise we're storing the range twice for 
this type (and it's named `Range` both times).



Comment at: clang/lib/Parse/ParseDeclCXX.cpp:3207
+  if (Tok.is(tok::kw___attribute)) {
+ParsedAttributes Attrs(AttrFactory);
 MaybeParseGNUAttributes(Attrs);

erichkeane wrote:
> This seems like a particularly strange change, What is the reasoning for 
> this?  Is it just that the Attrs are unused?
The comment above is that we parse and discard any trailing attributes, so this 
change is scoping the `ParsedAttributes` object more tightly to the only scope 
it's needed, but otherwise not changing behavior.


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

https://reviews.llvm.org/D121201

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


[PATCH] D121451: [clang-format] Add space to comments starting with '#'.

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

Add tests for SpacesInLineCommentPrefix.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D121451

Files:
  clang/lib/Format/BreakableToken.cpp
  clang/unittests/Format/FormatTestComments.cpp


Index: clang/unittests/Format/FormatTestComments.cpp
===
--- clang/unittests/Format/FormatTestComments.cpp
+++ clang/unittests/Format/FormatTestComments.cpp
@@ -91,6 +91,9 @@
"// line 2\n"
"void f() {}\n");
 
+  EXPECT_EQ("// comment\n", format("//comment\n"));
+  EXPECT_EQ("// #comment\n", format("//#comment\n"));
+
   EXPECT_EQ("// comment\n"
 "// clang-format on\n",
 format("//comment\n"
@@ -3302,6 +3305,7 @@
 format(NoTextInComment, Style));
 
   Style.SpacesInLineCommentPrefix.Minimum = 0;
+  EXPECT_EQ("//#comment", format("//#comment", Style));
   EXPECT_EQ("//\n"
 "\n"
 "void foo() { //\n"
@@ -3310,6 +3314,7 @@
 format(NoTextInComment, Style));
 
   Style.SpacesInLineCommentPrefix.Minimum = 5;
+  EXPECT_EQ("// #comment", format("//#comment", Style));
   EXPECT_EQ("//\n"
 "\n"
 "void foo() { //\n"
@@ -3463,6 +3468,7 @@
 format(Code, Style));
 
   Style.SpacesInLineCommentPrefix = {0, 0};
+  EXPECT_EQ("//#comment", format("//   #comment", Style));
   EXPECT_EQ("//Free comment without space\n"
 "\n"
 "//Free comment with 3 spaces\n"
Index: clang/lib/Format/BreakableToken.cpp
===
--- clang/lib/Format/BreakableToken.cpp
+++ clang/lib/Format/BreakableToken.cpp
@@ -779,11 +779,14 @@
 const char FirstCommentChar = Lines[i][IndentPrefix.size()];
 const unsigned FirstCharByteSize =
 encoding::getCodePointNumBytes(FirstCommentChar, Encoding);
-return encoding::columnWidth(
-   Lines[i].substr(IndentPrefix.size(), FirstCharByteSize),
-   Encoding) == 1 &&
-   (FirstCommentChar == '\\' || isPunctuation(FirstCommentChar) ||
-isHorizontalWhitespace(FirstCommentChar));
+if (encoding::columnWidth(
+Lines[i].substr(IndentPrefix.size(), FirstCharByteSize),
+Encoding) != 1)
+  return false;
+if (FirstCommentChar == '#')
+  return false;
+return FirstCommentChar == '\\' || isPunctuation(FirstCommentChar) ||
+   isHorizontalWhitespace(FirstCommentChar);
   };
 
   // On the first line of the comment section we calculate how many spaces


Index: clang/unittests/Format/FormatTestComments.cpp
===
--- clang/unittests/Format/FormatTestComments.cpp
+++ clang/unittests/Format/FormatTestComments.cpp
@@ -91,6 +91,9 @@
"// line 2\n"
"void f() {}\n");
 
+  EXPECT_EQ("// comment\n", format("//comment\n"));
+  EXPECT_EQ("// #comment\n", format("//#comment\n"));
+
   EXPECT_EQ("// comment\n"
 "// clang-format on\n",
 format("//comment\n"
@@ -3302,6 +3305,7 @@
 format(NoTextInComment, Style));
 
   Style.SpacesInLineCommentPrefix.Minimum = 0;
+  EXPECT_EQ("//#comment", format("//#comment", Style));
   EXPECT_EQ("//\n"
 "\n"
 "void foo() { //\n"
@@ -3310,6 +3314,7 @@
 format(NoTextInComment, Style));
 
   Style.SpacesInLineCommentPrefix.Minimum = 5;
+  EXPECT_EQ("// #comment", format("//#comment", Style));
   EXPECT_EQ("//\n"
 "\n"
 "void foo() { //\n"
@@ -3463,6 +3468,7 @@
 format(Code, Style));
 
   Style.SpacesInLineCommentPrefix = {0, 0};
+  EXPECT_EQ("//#comment", format("//   #comment", Style));
   EXPECT_EQ("//Free comment without space\n"
 "\n"
 "//Free comment with 3 spaces\n"
Index: clang/lib/Format/BreakableToken.cpp
===
--- clang/lib/Format/BreakableToken.cpp
+++ clang/lib/Format/BreakableToken.cpp
@@ -779,11 +779,14 @@
 const char FirstCommentChar = Lines[i][IndentPrefix.size()];
 const unsigned FirstCharByteSize =
 encoding::getCodePointNumBytes(FirstCommentChar, Encoding);
-return encoding::columnWidth(
-   Lines[i].substr(IndentPrefix.size(), FirstCharByteSize),
-   Encoding) == 1 &&
-   (FirstCommentChar == '\\' || isPunctuation(FirstCommentChar) ||
-isHorizontalWhitespace(FirstCommentChar));
+if (encoding::columnWidth(
+Lines[i].substr(IndentPrefix.size(), FirstCharByteSize),
+Encoding) != 1)
+  return false;
+if (FirstCommentChar == '#')
+  return fal

[PATCH] D121451: [clang-format] Add space to comments starting with '#'.

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

In D121451#3375229 , @MyDeveloperDay 
wrote:

> Is this conforming to `SpacesInLineCommentPrefix`

Yes it is, nothing changed in this regard, I added tests anyway.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D121451

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


[PATCH] D121466: [OpenMP] Replace math headers with OpenMP wrapper calls

2022-03-11 Thread Shilei Tian via Phabricator via cfe-commits
tianshilei1992 accepted this revision.
tianshilei1992 added a comment.
This revision is now accepted and ready to land.

LGTM. Support the header file is actually generated automatically. :-)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D121466

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


[PATCH] D111400: [Clang] Implement P2242R3

2022-03-11 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.
Herald added a project: All.

In D111400#985 , @cor3ntin wrote:

> @hubert.reinterpretcast Gentle ping in case you didn't see Aaron's message - 
> there isn't too much urgency though

Another ping on this since a few weeks have passed.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D111400

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


[PATCH] D121466: [OpenMP] Replace math headers with OpenMP wrapper calls

2022-03-11 Thread Jon Chesterfield via Phabricator via cfe-commits
JonChesterfield added a comment.

We've got quite a lot of debt in this area and seem at risk of taking on more. 
Ideally the cuda and hip and openmp headers would be closer to a single header 
containing:

double acosh(double);
INSTANTIATE(acosh, cuda_acosh, amdgpu_acosh, intel_acosh);




Comment at: clang/lib/Headers/openmp_wrappers/__clang_openmp_math.h:43
+
+__DEVICE__ int abs(int __a) { return __omp_abs(__a); }
+__DEVICE__ double fabs(double __a) { return __omp_fabs(__a); }

This is not totally good. Can we do something with macros or code generators 
instead, even in the first instance?

Also wonder if what we actually want to do is map these things onto 
`__gpu_acosh` or `__llvm_gpu_acosh` or similar, there's nothing openmp specific 
about this and it would be really nice to not end up spinning another copy of 
this for some other gpu language.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D121466

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


[PATCH] D121455: [clang][dataflow] Add support for nested composite bool expressions

2022-03-11 Thread Gábor Horváth via Phabricator via cfe-commits
xazax.hun added inline comments.



Comment at: clang/lib/Analysis/FlowSensitive/Transfer.cpp:516
+// assigned to it.
+Visit(&SubExpr);
+if (auto *Val = dyn_cast_or_null(

Could you elaborate on when would this happen? I'd expect the traversal to 
always visit the predecessor basic blocks first and within a basic block always 
visit subexpressions first. So I'd be quite surprised if there is a 
subexpression we did not visit.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D121455

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


[clang] aa4ea0e - [NFC][Clang][OpaquePtr] Remove calls to Address::deprecated in a couple

2022-03-11 Thread Akira Hatanaka via cfe-commits

Author: Akira Hatanaka
Date: 2022-03-11T09:30:31-08:00
New Revision: aa4ea0ee54411d12d17dd6261f64726913f15e16

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

LOG: [NFC][Clang][OpaquePtr] Remove calls to Address::deprecated in a couple
more files

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

Added: 


Modified: 
clang/lib/CodeGen/CGNonTrivialStruct.cpp
clang/lib/CodeGen/CGObjC.cpp
clang/lib/CodeGen/CGObjCGNU.cpp
clang/lib/CodeGen/CGObjCMac.cpp
clang/lib/CodeGen/CGObjCRuntime.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/CGNonTrivialStruct.cpp 
b/clang/lib/CodeGen/CGNonTrivialStruct.cpp
index eff768ead9580..9b1ae12964aca 100644
--- a/clang/lib/CodeGen/CGNonTrivialStruct.cpp
+++ b/clang/lib/CodeGen/CGNonTrivialStruct.cpp
@@ -326,9 +326,9 @@ static std::array 
getParamAddrs(std::index_sequence IntSeq,
 std::array 
Alignments,
 FunctionArgList Args,
 CodeGenFunction *CGF) {
-  return std::array{{Address::deprecated(
-  CGF->Builder.CreateLoad(CGF->GetAddrOfLocalVar(Args[Ints])),
-  Alignments[Ints])...}};
+  return std::array{
+  {Address(CGF->Builder.CreateLoad(CGF->GetAddrOfLocalVar(Args[Ints])),
+   CGF->VoidPtrTy, Alignments[Ints])...}};
 }
 
 // Template classes that are used as bases for classes that emit special

diff  --git a/clang/lib/CodeGen/CGObjC.cpp b/clang/lib/CodeGen/CGObjC.cpp
index 51343ca3dbe30..77aa1f5b53d40 100644
--- a/clang/lib/CodeGen/CGObjC.cpp
+++ b/clang/lib/CodeGen/CGObjC.cpp
@@ -3849,7 +3849,7 @@ 
CodeGenFunction::GenerateObjCAtomicGetterCopyHelperFunction(
   getContext().getTypeAlignInChars(TheCXXConstructExpr->getType());
   EmitAggExpr(TheCXXConstructExpr,
   AggValueSlot::forAddr(
-  Address::deprecated(DV.getScalarVal(), Alignment),
+  Address(DV.getScalarVal(), ConvertTypeForMem(Ty), Alignment),
   Qualifiers(), AggValueSlot::IsDestructed,
   AggValueSlot::DoesNotNeedGCBarriers,
   AggValueSlot::IsNotAliased, AggValueSlot::DoesNotOverlap));

diff  --git a/clang/lib/CodeGen/CGObjCGNU.cpp b/clang/lib/CodeGen/CGObjCGNU.cpp
index a0f9e32d4f81d..210bbf36d7bdf 100644
--- a/clang/lib/CodeGen/CGObjCGNU.cpp
+++ b/clang/lib/CodeGen/CGObjCGNU.cpp
@@ -1265,7 +1265,7 @@ class CGObjCGNUstep2 : public CGObjCGNUstep {
  const std::string &Name,
  bool isWeak) override {
 return CGF.Builder.CreateLoad(
-Address::deprecated(GetClassVar(Name, isWeak), CGM.getPointerAlign()));
+Address(GetClassVar(Name, isWeak), IdTy, CGM.getPointerAlign()));
   }
   int32_t FlagsForOwnership(Qualifiers::ObjCLifetime Ownership) {
 // typedef enum {

diff  --git a/clang/lib/CodeGen/CGObjCMac.cpp b/clang/lib/CodeGen/CGObjCMac.cpp
index 7e4176e63ecd0..cbd7e82e60bd2 100644
--- a/clang/lib/CodeGen/CGObjCMac.cpp
+++ b/clang/lib/CodeGen/CGObjCMac.cpp
@@ -5272,7 +5272,7 @@ Address CGObjCMac::EmitSelectorAddr(Selector Sel) {
 Entry->setExternallyInitialized(true);
   }
 
-  return Address::deprecated(Entry, Align);
+  return Address(Entry, ObjCTypes.SelectorPtrTy, Align);
 }
 
 llvm::Constant *CGObjCCommonMac::GetClassName(StringRef RuntimeName) {
@@ -7643,7 +7643,7 @@ Address CGObjCNonFragileABIMac::EmitSelectorAddr(Selector 
Sel) {
 CGM.addCompilerUsedGlobal(Entry);
   }
 
-  return Address::deprecated(Entry, Align);
+  return Address(Entry, ObjCTypes.SelectorPtrTy, Align);
 }
 
 /// EmitObjCIvarAssign - Code gen for assigning to a __strong object.

diff  --git a/clang/lib/CodeGen/CGObjCRuntime.cpp 
b/clang/lib/CodeGen/CGObjCRuntime.cpp
index 80cabbe930017..550fd3d70bdcc 100644
--- a/clang/lib/CodeGen/CGObjCRuntime.cpp
+++ b/clang/lib/CodeGen/CGObjCRuntime.cpp
@@ -106,7 +106,7 @@ LValue 
CGObjCRuntime::EmitValueForIvarAtOffset(CodeGen::CodeGenFunction &CGF,
  CGF.CGM.getContext().toBits(StorageSize),
  CharUnits::fromQuantity(0)));
 
-  Address Addr = Address::deprecated(V, Alignment);
+  Address Addr = Address(V, CGF.Int8Ty, Alignment);
   Addr = CGF.Builder.CreateElementBitCast(Addr,
llvm::Type::getIntNTy(CGF.getLLVMContext(),
  Info->StorageSize));



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


[PATCH] D121135: [NFC][Clang][OpaquePtr] Remove calls to Address::deprecated in a couple more files

2022-03-11 Thread Akira Hatanaka via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGaa4ea0ee5441: [NFC][Clang][OpaquePtr] Remove calls to 
Address::deprecated in a couple (authored by ahatanak).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D121135

Files:
  clang/lib/CodeGen/CGNonTrivialStruct.cpp
  clang/lib/CodeGen/CGObjC.cpp
  clang/lib/CodeGen/CGObjCGNU.cpp
  clang/lib/CodeGen/CGObjCMac.cpp
  clang/lib/CodeGen/CGObjCRuntime.cpp


Index: clang/lib/CodeGen/CGObjCRuntime.cpp
===
--- clang/lib/CodeGen/CGObjCRuntime.cpp
+++ clang/lib/CodeGen/CGObjCRuntime.cpp
@@ -106,7 +106,7 @@
  CGF.CGM.getContext().toBits(StorageSize),
  CharUnits::fromQuantity(0)));
 
-  Address Addr = Address::deprecated(V, Alignment);
+  Address Addr = Address(V, CGF.Int8Ty, Alignment);
   Addr = CGF.Builder.CreateElementBitCast(Addr,
llvm::Type::getIntNTy(CGF.getLLVMContext(),
  Info->StorageSize));
Index: clang/lib/CodeGen/CGObjCMac.cpp
===
--- clang/lib/CodeGen/CGObjCMac.cpp
+++ clang/lib/CodeGen/CGObjCMac.cpp
@@ -5272,7 +5272,7 @@
 Entry->setExternallyInitialized(true);
   }
 
-  return Address::deprecated(Entry, Align);
+  return Address(Entry, ObjCTypes.SelectorPtrTy, Align);
 }
 
 llvm::Constant *CGObjCCommonMac::GetClassName(StringRef RuntimeName) {
@@ -7643,7 +7643,7 @@
 CGM.addCompilerUsedGlobal(Entry);
   }
 
-  return Address::deprecated(Entry, Align);
+  return Address(Entry, ObjCTypes.SelectorPtrTy, Align);
 }
 
 /// EmitObjCIvarAssign - Code gen for assigning to a __strong object.
Index: clang/lib/CodeGen/CGObjCGNU.cpp
===
--- clang/lib/CodeGen/CGObjCGNU.cpp
+++ clang/lib/CodeGen/CGObjCGNU.cpp
@@ -1265,7 +1265,7 @@
  const std::string &Name,
  bool isWeak) override {
 return CGF.Builder.CreateLoad(
-Address::deprecated(GetClassVar(Name, isWeak), CGM.getPointerAlign()));
+Address(GetClassVar(Name, isWeak), IdTy, CGM.getPointerAlign()));
   }
   int32_t FlagsForOwnership(Qualifiers::ObjCLifetime Ownership) {
 // typedef enum {
Index: clang/lib/CodeGen/CGObjC.cpp
===
--- clang/lib/CodeGen/CGObjC.cpp
+++ clang/lib/CodeGen/CGObjC.cpp
@@ -3849,7 +3849,7 @@
   getContext().getTypeAlignInChars(TheCXXConstructExpr->getType());
   EmitAggExpr(TheCXXConstructExpr,
   AggValueSlot::forAddr(
-  Address::deprecated(DV.getScalarVal(), Alignment),
+  Address(DV.getScalarVal(), ConvertTypeForMem(Ty), Alignment),
   Qualifiers(), AggValueSlot::IsDestructed,
   AggValueSlot::DoesNotNeedGCBarriers,
   AggValueSlot::IsNotAliased, AggValueSlot::DoesNotOverlap));
Index: clang/lib/CodeGen/CGNonTrivialStruct.cpp
===
--- clang/lib/CodeGen/CGNonTrivialStruct.cpp
+++ clang/lib/CodeGen/CGNonTrivialStruct.cpp
@@ -326,9 +326,9 @@
 std::array 
Alignments,
 FunctionArgList Args,
 CodeGenFunction *CGF) {
-  return std::array{{Address::deprecated(
-  CGF->Builder.CreateLoad(CGF->GetAddrOfLocalVar(Args[Ints])),
-  Alignments[Ints])...}};
+  return std::array{
+  {Address(CGF->Builder.CreateLoad(CGF->GetAddrOfLocalVar(Args[Ints])),
+   CGF->VoidPtrTy, Alignments[Ints])...}};
 }
 
 // Template classes that are used as bases for classes that emit special


Index: clang/lib/CodeGen/CGObjCRuntime.cpp
===
--- clang/lib/CodeGen/CGObjCRuntime.cpp
+++ clang/lib/CodeGen/CGObjCRuntime.cpp
@@ -106,7 +106,7 @@
  CGF.CGM.getContext().toBits(StorageSize),
  CharUnits::fromQuantity(0)));
 
-  Address Addr = Address::deprecated(V, Alignment);
+  Address Addr = Address(V, CGF.Int8Ty, Alignment);
   Addr = CGF.Builder.CreateElementBitCast(Addr,
llvm::Type::getIntNTy(CGF.getLLVMContext(),
  Info->StorageSize));
Index: clang/lib/CodeGen/CGObjCMac.cpp
===
--- clang/lib/CodeGen/CGObjCMac.cpp
+++ clang/lib/CodeGen/CGObjCMac.cpp
@@ -5272,7 +5272,7 @@
 Entry->setExternallyInitialized(true);
   }
 
-  return Address::deprecated(Entry, Align);
+  return Address(Entry, ObjCTypes.SelectorPtrTy, Align);
 }
 
 llvm::Constant 

[PATCH] D120296: [Attr] Fix a btf_type_tag AST generation bug

2022-03-11 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: clang/include/clang/AST/TypeLoc.h:923
+  void initializeLocal(ASTContext &Context, SourceLocation loc) {}
+
+  QualType getInnerType() const { return getTypePtr()->getWrappedType(); }

Do we also need something like this? 
https://github.com/llvm/llvm-project/blob/main/clang/include/clang/AST/TypeLoc.h#L1187



Comment at: clang/lib/CodeGen/CGDebugInfo.cpp:1144
+  SmallVector Annots;
+  auto BTFTagAttrTy = dyn_cast(PointeeTy);
+  while (BTFTagAttrTy) {

aaron.ballman wrote:
> 
This one may have been missed.



Comment at: clang/test/Sema/attr-btf_type_tag.c:31-37
+// The btf_type_tag attribute will be ignored during overloadable type matching
+void __attribute__((overloadable)) bar1(int __tag1 *a);
+void __attribute__((overloadable)) bar2(int *a);
+void foo2(int *a, int __tag1 *b) {
+  bar1(a);
+  bar2(b);
+}

This test looks confused -- those functions have different names, so they're 
not overloading one another. Even if they were named with the same identifier, 
it wouldn't be sufficient to test which gets called (you can redeclare 
overloads as in https://godbolt.org/z/aebMbY1aM).

I think this case needs a codegen test to see which function is actually 
dispatched to.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D120296

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


[PATCH] D121475: [Clang][Sema] Avoid crashing for `__builtin_memcpy_inline` with an array argument

2022-03-11 Thread Egor Zhdan via Phabricator via cfe-commits
egorzhdan created this revision.
egorzhdan added a reviewer: gchatelet.
Herald added a project: All.
egorzhdan requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

This change teaches the Sema logic for `__builtin_memcpy_inline` to implicitly 
convert arrays passed as arguments to pointers, similarly to regular `memcpy`.

This code will no longer cause a compiler crash:

  void f(char *p) {
  char s[1] = {0};
  __builtin_memcpy_inline(p, s, 1);
  }

rdar://88147527


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D121475

Files:
  clang/lib/Sema/SemaChecking.cpp
  clang/test/Sema/builtins-memcpy-inline.cpp


Index: clang/test/Sema/builtins-memcpy-inline.cpp
===
--- clang/test/Sema/builtins-memcpy-inline.cpp
+++ clang/test/Sema/builtins-memcpy-inline.cpp
@@ -36,3 +36,9 @@
   // we do not try to evaluate size in non intantiated templates.
   __builtin_memcpy_inline(dst, src, size);
 }
+
+void test_memcpy_inline_implicit_conversion(void *ptr) {
+  char a[5];
+  __builtin_memcpy_inline(ptr, a, 5);
+  __builtin_memcpy_inline(a, ptr, 5);
+}
Index: clang/lib/Sema/SemaChecking.cpp
===
--- clang/lib/Sema/SemaChecking.cpp
+++ clang/lib/Sema/SemaChecking.cpp
@@ -1943,6 +1943,17 @@
   case Builtin::BI__builtin_nontemporal_store:
 return SemaBuiltinNontemporalOverloaded(TheCallResult);
   case Builtin::BI__builtin_memcpy_inline: {
+auto ArgArrayConversion = [&](unsigned Arg) {
+  ExprResult ArgExpr =
+  DefaultFunctionArrayLvalueConversion(TheCall->getArg(Arg));
+  if (ArgExpr.isInvalid())
+return true;
+  TheCall->setArg(Arg, ArgExpr.get());
+  return false;
+};
+
+if (ArgArrayConversion(0) || ArgArrayConversion(1))
+  return true;
 clang::Expr *SizeOp = TheCall->getArg(2);
 // We warn about copying to or from `nullptr` pointers when `size` is
 // greater than 0. When `size` is value dependent we cannot evaluate its


Index: clang/test/Sema/builtins-memcpy-inline.cpp
===
--- clang/test/Sema/builtins-memcpy-inline.cpp
+++ clang/test/Sema/builtins-memcpy-inline.cpp
@@ -36,3 +36,9 @@
   // we do not try to evaluate size in non intantiated templates.
   __builtin_memcpy_inline(dst, src, size);
 }
+
+void test_memcpy_inline_implicit_conversion(void *ptr) {
+  char a[5];
+  __builtin_memcpy_inline(ptr, a, 5);
+  __builtin_memcpy_inline(a, ptr, 5);
+}
Index: clang/lib/Sema/SemaChecking.cpp
===
--- clang/lib/Sema/SemaChecking.cpp
+++ clang/lib/Sema/SemaChecking.cpp
@@ -1943,6 +1943,17 @@
   case Builtin::BI__builtin_nontemporal_store:
 return SemaBuiltinNontemporalOverloaded(TheCallResult);
   case Builtin::BI__builtin_memcpy_inline: {
+auto ArgArrayConversion = [&](unsigned Arg) {
+  ExprResult ArgExpr =
+  DefaultFunctionArrayLvalueConversion(TheCall->getArg(Arg));
+  if (ArgExpr.isInvalid())
+return true;
+  TheCall->setArg(Arg, ArgExpr.get());
+  return false;
+};
+
+if (ArgArrayConversion(0) || ArgArrayConversion(1))
+  return true;
 clang::Expr *SizeOp = TheCall->getArg(2);
 // We warn about copying to or from `nullptr` pointers when `size` is
 // greater than 0. When `size` is value dependent we cannot evaluate its
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D120187: [clang-tidy] Allow newline characters as separators for checks in Clang-Tidy configurations

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

LGTM, but please wait a day or two before landing in case @njames93 has further 
concerns.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D120187

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


[PATCH] D121466: [OpenMP] Replace math headers with OpenMP wrapper calls

2022-03-11 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert added a comment.

We want one copy of this, yes. s/omp/llvm_gpu/, sure, though gpu might also not 
the best name. Generators, macros, etc. I'm not sold. Even if we want to do 
this, let's not conflate that.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D121466

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


[PATCH] D121468: [OpenMP] Add linking of OpenMP math library

2022-03-11 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert added inline comments.



Comment at: clang/include/clang/Driver/Options.td:1056
+def libomptarget_nvptx_math_bc_path_EQ : Joined<["--"], 
"libomptarget-nvptx-math-bc-path=">,
+  Group, HelpText<"Path to libomptarget-nvptx math bitcode library">;
 def dD : Flag<["-"], "dD">, Group, Flags<[CC1Option]>,

FWIW, I don't believe this amdgpu/nvpxt separation is actually improving 
things, on the contrary.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D121468

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


[PATCH] D121468: [OpenMP] Add linking of OpenMP math library

2022-03-11 Thread Jon Chesterfield via Phabricator via cfe-commits
JonChesterfield added inline comments.



Comment at: clang/include/clang/Driver/Options.td:1056
+def libomptarget_nvptx_math_bc_path_EQ : Joined<["--"], 
"libomptarget-nvptx-math-bc-path=">,
+  Group, HelpText<"Path to libomptarget-nvptx math bitcode library">;
 def dD : Flag<["-"], "dD">, Group, Flags<[CC1Option]>,

jdoerfert wrote:
> FWIW, I don't believe this amdgpu/nvpxt separation is actually improving 
> things, on the contrary.
libomptarget_gpu? Definitely simplifies clang which is a win. I think it's an 
artefact of the previous device runtime layout.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D121468

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


[PATCH] D121468: [OpenMP] Add linking of OpenMP math library

2022-03-11 Thread Joseph Huber via Phabricator via cfe-commits
jhuber6 added inline comments.



Comment at: clang/include/clang/Driver/Options.td:1056
+def libomptarget_nvptx_math_bc_path_EQ : Joined<["--"], 
"libomptarget-nvptx-math-bc-path=">,
+  Group, HelpText<"Path to libomptarget-nvptx math bitcode library">;
 def dD : Flag<["-"], "dD">, Group, Flags<[CC1Option]>,

JonChesterfield wrote:
> jdoerfert wrote:
> > FWIW, I don't believe this amdgpu/nvpxt separation is actually improving 
> > things, on the contrary.
> libomptarget_gpu? Definitely simplifies clang which is a win. I think it's an 
> artefact of the previous device runtime layout.
The device library has different triples so we don't get errors when linking, 
not sure if it's possible to compile to generic IR that doesn't care about the 
triple. And I thought the same but wasn't too concerned with addressing it in 
the off chance someone wants to compile for amdgpu and nvptx64 at the same time 
and also specify the libraries.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D121468

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


[PATCH] D88905: [Clang] Allow "ext_vector_type" applied to Booleans

2022-03-11 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

In D88905#3362347 , @kaz7 wrote:

> At the beginning, this implementation extends `vector_type` attribute which 
> is GCC's attribute.  So, this may cause future conflicts with GCC when they 
> extend it.  But, now this patch uses it's own `ext_vector_type` attribute.  
> So, basically this modification is safe against to the C/C++ future extension 
> and the GCC future extension, in my honest opinion.
>
> Is it OK to accept this patch?  Or is there anything we need to consider?  I 
> understand that this is a language extension, so it not easy to say OK...  
> But, this patch spent 1 year and a half almost.

At a minimum, I think the patch needs to be rebased onto the current trunk. 
However, I don't know of a reason why this patch cannot proceed.

I'd be curious whether the codegen for ext_vector_type of N bools is the same 
as for N `unsigned _BitInt(1)` (naively, I'd expect them to be equivalent).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D88905

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


[PATCH] D121410: Have cpu-specific variants set 'tune-cpu' as an optimization hint

2022-03-11 Thread Erich Keane via Phabricator via cfe-commits
erichkeane updated this revision to Diff 414699.
erichkeane added a comment.

Corrected the last few processor names thanks to @andrew.w.kaylor  and @pengfei


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

https://reviews.llvm.org/D121410

Files:
  clang/include/clang/Basic/TargetInfo.h
  clang/lib/Basic/Targets/X86.cpp
  clang/lib/Basic/Targets/X86.h
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/test/CodeGen/attr-cpuspecific-avx-abi.c
  clang/test/CodeGen/attr-cpuspecific.c
  llvm/include/llvm/Support/X86TargetParser.def

Index: llvm/include/llvm/Support/X86TargetParser.def
===
--- llvm/include/llvm/Support/X86TargetParser.def
+++ llvm/include/llvm/Support/X86TargetParser.def
@@ -211,47 +211,47 @@
 #undef X86_FEATURE
 
 #ifndef CPU_SPECIFIC
-#define CPU_SPECIFIC(NAME, MANGLING, FEATURES)
+#define CPU_SPECIFIC(NAME, TUNE_NAME, MANGLING, FEATURES)
 #endif
 
 #ifndef CPU_SPECIFIC_ALIAS
-#define CPU_SPECIFIC_ALIAS(NEW_NAME, NAME)
+#define CPU_SPECIFIC_ALIAS(NEW_NAME, TUNE_NAME, NAME)
 #endif
 
-CPU_SPECIFIC("generic", 'A', "")
-CPU_SPECIFIC("pentium", 'B', "")
-CPU_SPECIFIC("pentium_pro", 'C', "+cmov")
-CPU_SPECIFIC("pentium_mmx", 'D', "+mmx")
-CPU_SPECIFIC("pentium_ii", 'E', "+cmov,+mmx")
-CPU_SPECIFIC("pentium_iii", 'H', "+cmov,+mmx,+sse")
-CPU_SPECIFIC_ALIAS("pentium_iii_no_xmm_regs", "pentium_iii")
-CPU_SPECIFIC("pentium_4", 'J', "+cmov,+mmx,+sse,+sse2")
-CPU_SPECIFIC("pentium_m", 'K', "+cmov,+mmx,+sse,+sse2")
-CPU_SPECIFIC("pentium_4_sse3", 'L', "+cmov,+mmx,+sse,+sse2,+sse3")
-CPU_SPECIFIC("core_2_duo_ssse3", 'M', "+cmov,+mmx,+sse,+sse2,+sse3,+ssse3")
-CPU_SPECIFIC("core_2_duo_sse4_1", 'N', "+cmov,+mmx,+sse,+sse2,+sse3,+ssse3,+sse4.1")
-CPU_SPECIFIC("atom", 'O', "+cmov,+mmx,+sse,+sse2,+sse3,+ssse3,+movbe")
-CPU_SPECIFIC("atom_sse4_2", 'c', "+cmov,+mmx,+sse,+sse2,+sse3,+ssse3,+sse4.1,+sse4.2,+popcnt")
-CPU_SPECIFIC("core_i7_sse4_2", 'P', "+cmov,+mmx,+sse,+sse2,+sse3,+ssse3,+sse4.1,+sse4.2,+popcnt")
-CPU_SPECIFIC("core_aes_pclmulqdq", 'Q', "+cmov,+mmx,+sse,+sse2,+sse3,+ssse3,+sse4.1,+sse4.2,+popcnt")
-CPU_SPECIFIC("atom_sse4_2_movbe", 'd', "+cmov,+mmx,+sse,+sse2,+sse3,+ssse3,+sse4.1,+sse4.2,+movbe,+popcnt")
-CPU_SPECIFIC("goldmont", 'i', "+cmov,+mmx,+sse,+sse2,+sse3,+ssse3,+sse4.1,+sse4.2,+movbe,+popcnt")
-CPU_SPECIFIC("sandybridge", 'R', "+cmov,+mmx,+sse,+sse2,+sse3,+ssse3,+sse4.1,+sse4.2,+popcnt,+avx")
-CPU_SPECIFIC_ALIAS("core_2nd_gen_avx", "sandybridge")
-CPU_SPECIFIC("ivybridge", 'S', "+cmov,+mmx,+sse,+sse2,+sse3,+ssse3,+sse4.1,+sse4.2,+popcnt,+f16c,+avx")
-CPU_SPECIFIC_ALIAS("core_3rd_gen_avx", "ivybridge")
-CPU_SPECIFIC("haswell", 'V', "+cmov,+mmx,+sse,+sse2,+sse3,+ssse3,+sse4.1,+sse4.2,+movbe,+popcnt,+f16c,+avx,+fma,+bmi,+lzcnt,+avx2")
-CPU_SPECIFIC_ALIAS("core_4th_gen_avx", "haswell")
-CPU_SPECIFIC("core_4th_gen_avx_tsx", 'W', "+cmov,+mmx,+sse,+sse2,+sse3,+ssse3,+sse4.1,+sse4.2,+movbe,+popcnt,+f16c,+avx,+fma,+bmi,+lzcnt,+avx2")
-CPU_SPECIFIC("broadwell", 'X', "+cmov,+mmx,+sse,+sse2,+sse3,+ssse3,+sse4.1,+sse4.2,+movbe,+popcnt,+f16c,+avx,+fma,+bmi,+lzcnt,+avx2,+adx")
-CPU_SPECIFIC_ALIAS("core_5th_gen_avx", "broadwell")
-CPU_SPECIFIC("core_5th_gen_avx_tsx", 'Y', "+cmov,+mmx,+sse,+sse2,+sse3,+ssse3,+sse4.1,+sse4.2,+movbe,+popcnt,+f16c,+avx,+fma,+bmi,+lzcnt,+avx2,+adx")
-CPU_SPECIFIC("knl", 'Z', "+cmov,+mmx,+sse,+sse2,+sse3,+ssse3,+sse4.1,+sse4.2,+movbe,+popcnt,+f16c,+avx,+fma,+bmi,+lzcnt,+avx2,+avx512f,+adx,+avx512er,+avx512pf,+avx512cd")
-CPU_SPECIFIC_ALIAS("mic_avx512", "knl")
-CPU_SPECIFIC("skylake", 'b', "+cmov,+mmx,+sse,+sse2,+sse3,+ssse3,+sse4.1,+sse4.2,+movbe,+popcnt,+f16c,+avx,+fma,+bmi,+lzcnt,+avx2,+adx,+mpx")
-CPU_SPECIFIC( "skylake_avx512", 'a', "+cmov,+mmx,+sse,+sse2,+sse3,+ssse3,+sse4.1,+sse4.2,+movbe,+popcnt,+f16c,+avx,+fma,+bmi,+lzcnt,+avx2,+avx512dq,+avx512f,+adx,+avx512cd,+avx512bw,+avx512vl,+clwb")
-CPU_SPECIFIC("cannonlake", 'e', "+cmov,+mmx,+sse,+sse2,+sse3,+ssse3,+sse4.1,+sse4.2,+movbe,+popcnt,+f16c,+avx,+fma,+bmi,+lzcnt,+avx2,+avx512dq,+avx512f,+adx,+avx512ifma,+avx512cd,+avx512bw,+avx512vl,+avx512vbmi")
-CPU_SPECIFIC("knm", 'j', "+cmov,+mmx,+sse,+sse2,+sse3,+ssse3,+sse4.1,+sse4.2,+movbe,+popcnt,+f16c,+avx,+fma,+bmi,+lzcnt,+avx2,+avx512f,+adx,+avx512er,+avx512pf,+avx512cd,+avx5124fmaps,+avx5124vnniw,+avx512vpopcntdq")
+CPU_SPECIFIC("generic", "generic", 'A', "")
+CPU_SPECIFIC("pentium", "pentium", 'B', "")
+CPU_SPECIFIC("pentium_pro", "pentiumpro", 'C', "+cmov")
+CPU_SPECIFIC("pentium_mmx", "pentium-mmx", 'D', "+mmx")
+CPU_SPECIFIC("pentium_ii", "pentium2", 'E', "+cmov,+mmx")
+CPU_SPECIFIC("pentium_iii", "pentium3", 'H', "+cmov,+mmx,+sse")
+CPU_SPECIFIC_ALIAS("pentium_iii_no_xmm_regs", "pentium3", "pentium_iii")
+CPU_SPECIFIC("pentium_4", "pentium4", 'J', "+cmov,+mmx,+sse,+sse2")
+CPU_SPECIFIC("pentium_m", "pentium-m", 'K', "+cmov,+mmx,+sse,+sse2")
+CPU_SPECIFIC("pentium_4_sse3", "prescott", 'L', "+cmov,+mmx,+sse,+sse2,+sse3")
+CPU_SPECIFIC("core_2_duo_ssse3", "core2", 'M', "+cmov,+mmx,+sse,+sse2

[PATCH] D121410: Have cpu-specific variants set 'tune-cpu' as an optimization hint

2022-03-11 Thread Andy Kaylor via Phabricator via cfe-commits
andrew.w.kaylor accepted this revision.
andrew.w.kaylor added a comment.
This revision is now accepted and ready to land.

This looks good to me. Thanks for the patch!


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

https://reviews.llvm.org/D121410

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


[PATCH] D121410: Have cpu-specific variants set 'tune-cpu' as an optimization hint

2022-03-11 Thread Craig Topper via Phabricator via cfe-commits
craig.topper added inline comments.



Comment at: llvm/include/llvm/Support/X86TargetParser.def:236
+CPU_SPECIFIC("core_i7_sse4_2", "nehalem", 'P', 
"+cmov,+mmx,+sse,+sse2,+sse3,+ssse3,+sse4.1,+sse4.2,+popcnt")
+CPU_SPECIFIC("core_aes_pclmulqdq", "icelake-client", 'Q', 
"+cmov,+mmx,+sse,+sse2,+sse3,+ssse3,+sse4.1,+sse4.2,+popcnt")
+CPU_SPECIFIC("atom_sse4_2_movbe", "silvermont, 'd', 
"+cmov,+mmx,+sse,+sse2,+sse3,+ssse3,+sse4.1,+sse4.2,+movbe,+popcnt")

core_aes_pclmulqdq is westmere


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

https://reviews.llvm.org/D121410

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


[PATCH] D121410: Have cpu-specific variants set 'tune-cpu' as an optimization hint

2022-03-11 Thread Erich Keane via Phabricator via cfe-commits
erichkeane updated this revision to Diff 414709.
erichkeane added a comment.

Update the `core_aes_pclmulqdq` to be `westmere`


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

https://reviews.llvm.org/D121410

Files:
  clang/include/clang/Basic/TargetInfo.h
  clang/lib/Basic/Targets/X86.cpp
  clang/lib/Basic/Targets/X86.h
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/test/CodeGen/attr-cpuspecific-avx-abi.c
  clang/test/CodeGen/attr-cpuspecific.c
  llvm/include/llvm/Support/X86TargetParser.def

Index: llvm/include/llvm/Support/X86TargetParser.def
===
--- llvm/include/llvm/Support/X86TargetParser.def
+++ llvm/include/llvm/Support/X86TargetParser.def
@@ -211,47 +211,47 @@
 #undef X86_FEATURE
 
 #ifndef CPU_SPECIFIC
-#define CPU_SPECIFIC(NAME, MANGLING, FEATURES)
+#define CPU_SPECIFIC(NAME, TUNE_NAME, MANGLING, FEATURES)
 #endif
 
 #ifndef CPU_SPECIFIC_ALIAS
-#define CPU_SPECIFIC_ALIAS(NEW_NAME, NAME)
+#define CPU_SPECIFIC_ALIAS(NEW_NAME, TUNE_NAME, NAME)
 #endif
 
-CPU_SPECIFIC("generic", 'A', "")
-CPU_SPECIFIC("pentium", 'B', "")
-CPU_SPECIFIC("pentium_pro", 'C', "+cmov")
-CPU_SPECIFIC("pentium_mmx", 'D', "+mmx")
-CPU_SPECIFIC("pentium_ii", 'E', "+cmov,+mmx")
-CPU_SPECIFIC("pentium_iii", 'H', "+cmov,+mmx,+sse")
-CPU_SPECIFIC_ALIAS("pentium_iii_no_xmm_regs", "pentium_iii")
-CPU_SPECIFIC("pentium_4", 'J', "+cmov,+mmx,+sse,+sse2")
-CPU_SPECIFIC("pentium_m", 'K', "+cmov,+mmx,+sse,+sse2")
-CPU_SPECIFIC("pentium_4_sse3", 'L', "+cmov,+mmx,+sse,+sse2,+sse3")
-CPU_SPECIFIC("core_2_duo_ssse3", 'M', "+cmov,+mmx,+sse,+sse2,+sse3,+ssse3")
-CPU_SPECIFIC("core_2_duo_sse4_1", 'N', "+cmov,+mmx,+sse,+sse2,+sse3,+ssse3,+sse4.1")
-CPU_SPECIFIC("atom", 'O', "+cmov,+mmx,+sse,+sse2,+sse3,+ssse3,+movbe")
-CPU_SPECIFIC("atom_sse4_2", 'c', "+cmov,+mmx,+sse,+sse2,+sse3,+ssse3,+sse4.1,+sse4.2,+popcnt")
-CPU_SPECIFIC("core_i7_sse4_2", 'P', "+cmov,+mmx,+sse,+sse2,+sse3,+ssse3,+sse4.1,+sse4.2,+popcnt")
-CPU_SPECIFIC("core_aes_pclmulqdq", 'Q', "+cmov,+mmx,+sse,+sse2,+sse3,+ssse3,+sse4.1,+sse4.2,+popcnt")
-CPU_SPECIFIC("atom_sse4_2_movbe", 'd', "+cmov,+mmx,+sse,+sse2,+sse3,+ssse3,+sse4.1,+sse4.2,+movbe,+popcnt")
-CPU_SPECIFIC("goldmont", 'i', "+cmov,+mmx,+sse,+sse2,+sse3,+ssse3,+sse4.1,+sse4.2,+movbe,+popcnt")
-CPU_SPECIFIC("sandybridge", 'R', "+cmov,+mmx,+sse,+sse2,+sse3,+ssse3,+sse4.1,+sse4.2,+popcnt,+avx")
-CPU_SPECIFIC_ALIAS("core_2nd_gen_avx", "sandybridge")
-CPU_SPECIFIC("ivybridge", 'S', "+cmov,+mmx,+sse,+sse2,+sse3,+ssse3,+sse4.1,+sse4.2,+popcnt,+f16c,+avx")
-CPU_SPECIFIC_ALIAS("core_3rd_gen_avx", "ivybridge")
-CPU_SPECIFIC("haswell", 'V', "+cmov,+mmx,+sse,+sse2,+sse3,+ssse3,+sse4.1,+sse4.2,+movbe,+popcnt,+f16c,+avx,+fma,+bmi,+lzcnt,+avx2")
-CPU_SPECIFIC_ALIAS("core_4th_gen_avx", "haswell")
-CPU_SPECIFIC("core_4th_gen_avx_tsx", 'W', "+cmov,+mmx,+sse,+sse2,+sse3,+ssse3,+sse4.1,+sse4.2,+movbe,+popcnt,+f16c,+avx,+fma,+bmi,+lzcnt,+avx2")
-CPU_SPECIFIC("broadwell", 'X', "+cmov,+mmx,+sse,+sse2,+sse3,+ssse3,+sse4.1,+sse4.2,+movbe,+popcnt,+f16c,+avx,+fma,+bmi,+lzcnt,+avx2,+adx")
-CPU_SPECIFIC_ALIAS("core_5th_gen_avx", "broadwell")
-CPU_SPECIFIC("core_5th_gen_avx_tsx", 'Y', "+cmov,+mmx,+sse,+sse2,+sse3,+ssse3,+sse4.1,+sse4.2,+movbe,+popcnt,+f16c,+avx,+fma,+bmi,+lzcnt,+avx2,+adx")
-CPU_SPECIFIC("knl", 'Z', "+cmov,+mmx,+sse,+sse2,+sse3,+ssse3,+sse4.1,+sse4.2,+movbe,+popcnt,+f16c,+avx,+fma,+bmi,+lzcnt,+avx2,+avx512f,+adx,+avx512er,+avx512pf,+avx512cd")
-CPU_SPECIFIC_ALIAS("mic_avx512", "knl")
-CPU_SPECIFIC("skylake", 'b', "+cmov,+mmx,+sse,+sse2,+sse3,+ssse3,+sse4.1,+sse4.2,+movbe,+popcnt,+f16c,+avx,+fma,+bmi,+lzcnt,+avx2,+adx,+mpx")
-CPU_SPECIFIC( "skylake_avx512", 'a', "+cmov,+mmx,+sse,+sse2,+sse3,+ssse3,+sse4.1,+sse4.2,+movbe,+popcnt,+f16c,+avx,+fma,+bmi,+lzcnt,+avx2,+avx512dq,+avx512f,+adx,+avx512cd,+avx512bw,+avx512vl,+clwb")
-CPU_SPECIFIC("cannonlake", 'e', "+cmov,+mmx,+sse,+sse2,+sse3,+ssse3,+sse4.1,+sse4.2,+movbe,+popcnt,+f16c,+avx,+fma,+bmi,+lzcnt,+avx2,+avx512dq,+avx512f,+adx,+avx512ifma,+avx512cd,+avx512bw,+avx512vl,+avx512vbmi")
-CPU_SPECIFIC("knm", 'j', "+cmov,+mmx,+sse,+sse2,+sse3,+ssse3,+sse4.1,+sse4.2,+movbe,+popcnt,+f16c,+avx,+fma,+bmi,+lzcnt,+avx2,+avx512f,+adx,+avx512er,+avx512pf,+avx512cd,+avx5124fmaps,+avx5124vnniw,+avx512vpopcntdq")
+CPU_SPECIFIC("generic", "generic", 'A', "")
+CPU_SPECIFIC("pentium", "pentium", 'B', "")
+CPU_SPECIFIC("pentium_pro", "pentiumpro", 'C', "+cmov")
+CPU_SPECIFIC("pentium_mmx", "pentium-mmx", 'D', "+mmx")
+CPU_SPECIFIC("pentium_ii", "pentium2", 'E', "+cmov,+mmx")
+CPU_SPECIFIC("pentium_iii", "pentium3", 'H', "+cmov,+mmx,+sse")
+CPU_SPECIFIC_ALIAS("pentium_iii_no_xmm_regs", "pentium3", "pentium_iii")
+CPU_SPECIFIC("pentium_4", "pentium4", 'J', "+cmov,+mmx,+sse,+sse2")
+CPU_SPECIFIC("pentium_m", "pentium-m", 'K', "+cmov,+mmx,+sse,+sse2")
+CPU_SPECIFIC("pentium_4_sse3", "prescott", 'L', "+cmov,+mmx,+sse,+sse2,+sse3")
+CPU_SPECIFIC("core_2_duo_ssse3", "core2", 'M', "+cmov,+mmx,+sse,+sse2,+sse3,+ssse3")
+CPU_SPECIFIC("

[PATCH] D121410: Have cpu-specific variants set 'tune-cpu' as an optimization hint

2022-03-11 Thread Erich Keane via Phabricator via cfe-commits
erichkeane marked 4 inline comments as done.
erichkeane added inline comments.



Comment at: llvm/include/llvm/Support/X86TargetParser.def:236
+CPU_SPECIFIC("core_i7_sse4_2", "nehalem", 'P', 
"+cmov,+mmx,+sse,+sse2,+sse3,+ssse3,+sse4.1,+sse4.2,+popcnt")
+CPU_SPECIFIC("core_aes_pclmulqdq", "icelake-client", 'Q', 
"+cmov,+mmx,+sse,+sse2,+sse3,+ssse3,+sse4.1,+sse4.2,+popcnt")
+CPU_SPECIFIC("atom_sse4_2_movbe", "silvermont, 'd', 
"+cmov,+mmx,+sse,+sse2,+sse3,+ssse3,+sse4.1,+sse4.2,+movbe,+popcnt")

craig.topper wrote:
> core_aes_pclmulqdq is westmere
Thanks!


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

https://reviews.llvm.org/D121410

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


[PATCH] D121410: Have cpu-specific variants set 'tune-cpu' as an optimization hint

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

LGTM, though I'm not qualified to review the CPU specific bits in the .def file.


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

https://reviews.llvm.org/D121410

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


[PATCH] D121283: [Clang] Support multiple attributes in a single pragma

2022-03-11 Thread Egor Zhdan via Phabricator via cfe-commits
egorzhdan added a comment.

In D121283#3373560 , @aaron.ballman 
wrote:

> why do we support multiple attribute *specifiers* in the same pragma? I would 
> not expect to be able to mix attribute styles in the same pragma given that 
> all of the individual styles allow you to specify multiple attributes within 
> a single specifier

I don't think I have a strong use case for this. It seemed consistent with the 
way multiple attributes can be added for individual declarations, e.g. 
`__attribute__((cdecl)) __declspec(dllexport) [[noreturn]] void f()`. But we 
can prohibit multiple specifiers within a single pragma if you think that this 
is not a good construct to support.

In D121283#3373560 , @aaron.ballman 
wrote:

> why is whitespace the correct separator as opposed to a comma-delimited list?

My motivation for this was also consistency with the syntax for attributes in 
individual declarations. Given that attribute specifiers are delimited by space 
for individual declarations (`__attribute__((cdecl)) __attribute__((noreturn)) 
void f()`), I think it would be unintuitive to require commas for attribute 
specifiers in pragmas when we could instead reuse the existing syntax of 
space-delimited attribute specifiers.

In D121283#3373560 , @aaron.ballman 
wrote:

> Also, I'd expect there to be some documentation changes along with this patch 
> and a release note.

Good point, thanks, I will add those to this patch.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D121283

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


[PATCH] D121426: [VFS] Update uses of getVFSFromYAML to use the new getVFSFromYAMLs API

2022-03-11 Thread Ben Barham via Phabricator via cfe-commits
bnbarham updated this revision to Diff 414718.
bnbarham added a comment.

Handle empty overlay file in clang tidy


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D121426

Files:
  clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/test/VFS/Inputs/vfsroot.yaml
  clang/test/VFS/directory.c
  clang/test/VFS/multiple-overlays.c
  clang/test/VFS/vfsroot-with-overlay.c
  lldb/source/Commands/CommandObjectReproducer.cpp
  llvm/include/llvm/Support/Error.h
  llvm/tools/dsymutil/Reproducer.cpp
  llvm/tools/dsymutil/Reproducer.h

Index: llvm/tools/dsymutil/Reproducer.h
===
--- llvm/tools/dsymutil/Reproducer.h
+++ llvm/tools/dsymutil/Reproducer.h
@@ -59,8 +59,7 @@
 };
 
 /// Reproducer instance used to use an existing reproducer. The VFS returned by
-/// this instance is a RedirectingFileSystem that remaps paths to their
-/// counterpart in the reproducer.
+/// this instance remaps paths to their counterpart in the reproducer.
 class ReproducerUse : public Reproducer {
 public:
   ReproducerUse(StringRef Root, std::error_code &EC);
Index: llvm/tools/dsymutil/Reproducer.cpp
===
--- llvm/tools/dsymutil/Reproducer.cpp
+++ llvm/tools/dsymutil/Reproducer.cpp
@@ -48,15 +48,15 @@
 ReproducerUse::ReproducerUse(StringRef Root, std::error_code &EC) {
   SmallString<128> Mapping(Root);
   sys::path::append(Mapping, "mapping.yaml");
-  ErrorOr> Buffer =
-  vfs::getRealFileSystem()->getBufferForFile(Mapping.str());
 
-  if (!Buffer) {
-EC = Buffer.getError();
+  auto OverlayFS = llvm::vfs::getVFSFromYAMLs(Mapping.str());
+  if (auto Err = OverlayFS.takeError()) {
+llvm::handleAllErrors(std::move(Err), [&](const llvm::ErrorInfoBase &E) {
+  EC = E.convertToErrorCode();
+});
 return;
   }
-
-  VFS = llvm::vfs::getVFSFromYAML(std::move(Buffer.get()), nullptr, Mapping);
+  VFS = std::move(*OverlayFS);
 }
 
 llvm::Expected>
Index: llvm/include/llvm/Support/Error.h
===
--- llvm/include/llvm/Support/Error.h
+++ llvm/include/llvm/Support/Error.h
@@ -1281,7 +1281,7 @@
 return OS.str();
   }
 
-  StringRef getFileName() { return FileName; }
+  StringRef getFileName() const { return FileName; }
 
   Error takeError() { return Error(std::move(Err)); }
 
Index: lldb/source/Commands/CommandObjectReproducer.cpp
===
--- lldb/source/Commands/CommandObjectReproducer.cpp
+++ lldb/source/Commands/CommandObjectReproducer.cpp
@@ -409,23 +409,19 @@
 switch (m_options.provider) {
 case eReproducerProviderFiles: {
   FileSpec vfs_mapping = loader->GetFile();
+  std::string overlay_path = vfs_mapping.GetPath();
 
-  // Read the VFS mapping.
-  ErrorOr> buffer =
-  vfs::getRealFileSystem()->getBufferForFile(vfs_mapping.GetPath());
-  if (!buffer) {
-SetError(result, errorCodeToError(buffer.getError()));
+  Expected> vfs =
+  vfs::getVFSFromYAMLs(StringRef(overlay_path));
+  if (auto err = vfs.takeError()) {
+SetError(result, std::move(err));
 return false;
   }
 
-  // Initialize a VFS from the given mapping.
-  IntrusiveRefCntPtr vfs = vfs::getVFSFromYAML(
-  std::move(buffer.get()), nullptr, vfs_mapping.GetPath());
-
   // Dump the VFS to a buffer.
   std::string str;
   raw_string_ostream os(str);
-  static_cast(*vfs).dump(os);
+  (*vfs)->dump(os);
   os.flush();
 
   // Return the string.
Index: clang/test/VFS/vfsroot-with-overlay.c
===
--- clang/test/VFS/vfsroot-with-overlay.c
+++ clang/test/VFS/vfsroot-with-overlay.c
@@ -1,7 +1,7 @@
 // RUN: rm -rf %t
 // RUN: mkdir -p %t
 // RUN: sed -e "s@TEST_DIR@%{/S:regex_replacement}@g" -e "s@OUT_DIR@%{/t:regex_replacement}@g" %S/Inputs/vfsroot.yaml > %t.yaml
-// RUN: sed -e "s@INPUT_DIR@/indirect-vfs-root-files@g" -e "s@OUT_DIR@/overlay-dir@g" %S/Inputs/vfsoverlay.yaml > %t/vfsoverlay.yaml
+// RUN: sed -e "s@INPUT_DIR@%{/S:regex_replacement}/Inputs@g" -e "s@OUT_DIR@/overlay-dir@g" %S/Inputs/vfsoverlay.yaml > %t/vfsoverlay.yaml
 // RUN: %clang_cc1 -Werror -ivfsoverlay %t.yaml -ivfsoverlay /direct-vfs-root-files/vfsoverlay.yaml -I /overlay-dir -fsyntax-only /tests/vfsroot-with-overlay.c
 
 #include "not_real.h"
Index: clang/test/VFS/multiple-overlays.c
===
--- /dev/null
+++ clang/test/VFS/multiple-overlays.c
@@ -0,0 +1,39 @@
+// RUN: rm -rf %t
+// RUN: split-file %s %t
+// RUN: sed -e "s@EXTERNAL_DIR@%{/t:regex_replacement}/B@g" -e "s@NAME_DIR@%{/t:regex_replacement}/A@g" %t/vfs/base.yaml > %t/vfs/a-b.yaml
+// RUN: sed -e "s@EXTERNAL_DIR@%{/t:regex_re

[PATCH] D121373: [clang-tidy][docs] Fix wrong url in DontModifyStdNamespaceCheck

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

LGTM!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D121373

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


[PATCH] D121176: [ASTStructuralEquivalence] Add support for comparing ObjCCategoryDecl.

2022-03-11 Thread Volodymyr Sapsai via Phabricator via cfe-commits
vsapsai updated this revision to Diff 414724.
vsapsai added a comment.

Fix clang-format error.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D121176

Files:
  clang/include/clang/Testing/CommandLineArgs.h
  clang/lib/AST/ASTStructuralEquivalence.cpp
  clang/lib/Testing/CommandLineArgs.cpp
  clang/unittests/AST/MatchVerifier.h
  clang/unittests/AST/StructuralEquivalenceTest.cpp

Index: clang/unittests/AST/StructuralEquivalenceTest.cpp
===
--- clang/unittests/AST/StructuralEquivalenceTest.cpp
+++ clang/unittests/AST/StructuralEquivalenceTest.cpp
@@ -1120,6 +1120,187 @@
   EXPECT_FALSE(testStructuralMatch(t));
 }
 
+struct StructuralEquivalenceObjCCategoryTest : StructuralEquivalenceTest {};
+
+TEST_F(StructuralEquivalenceObjCCategoryTest, MatchinCategoryNames) {
+  auto t = makeDecls("@interface A @end @interface A(X) @end",
+   "@interface A @end @interface A(X) @end",
+   Lang_OBJC, objcCategoryDecl());
+  EXPECT_TRUE(testStructuralMatch(t));
+}
+
+TEST_F(StructuralEquivalenceObjCCategoryTest, CategoriesForDifferentClasses) {
+  auto t = makeDecls("@interface A @end @interface A(X) @end",
+   "@interface B @end @interface B(X) @end",
+   Lang_OBJC, objcCategoryDecl());
+  EXPECT_FALSE(testStructuralMatch(t));
+}
+
+TEST_F(StructuralEquivalenceObjCCategoryTest, CategoriesWithDifferentNames) {
+  auto t = makeDecls("@interface A @end @interface A(X) @end",
+   "@interface A @end @interface A(Y) @end",
+   Lang_OBJC, objcCategoryDecl());
+  EXPECT_FALSE(testStructuralMatch(t));
+}
+
+TEST_F(StructuralEquivalenceObjCCategoryTest, CategoryAndExtension) {
+  auto t = makeDecls("@interface A @end @interface A(X) @end",
+   "@interface A @end @interface A() @end",
+   Lang_OBJC, objcCategoryDecl());
+  EXPECT_FALSE(testStructuralMatch(t));
+}
+
+TEST_F(StructuralEquivalenceObjCCategoryTest, MatchingProtocols) {
+  auto t = makeDecls(
+  "@protocol P @end @interface A @end @interface A(X) @end",
+  "@protocol P @end @interface A @end @interface A(X) @end", Lang_OBJC,
+  objcCategoryDecl());
+  EXPECT_TRUE(testStructuralMatch(t));
+}
+
+TEST_F(StructuralEquivalenceObjCCategoryTest, DifferentProtocols) {
+  auto t = makeDecls(
+  "@protocol P @end @interface A @end @interface A(X) @end",
+  "@protocol Q @end @interface A @end @interface A(X) @end", Lang_OBJC,
+  objcCategoryDecl());
+  EXPECT_FALSE(testStructuralMatch(t));
+}
+
+TEST_F(StructuralEquivalenceObjCCategoryTest, DifferentProtocolsOrder) {
+  auto t = makeDecls(
+  "@protocol P @end @protocol Q @end @interface A @end @interface A(X) @end",
+  "@protocol P @end @protocol Q @end @interface A @end @interface A(X) @end",
+  Lang_OBJC, objcCategoryDecl());
+  EXPECT_FALSE(testStructuralMatch(t));
+}
+
+TEST_F(StructuralEquivalenceObjCCategoryTest, MatchingIvars) {
+  auto t = makeDecls(
+  "@interface A @end @interface A() { int x; } @end",
+  "@interface A @end @interface A() { int x; } @end", Lang_OBJC,
+  objcCategoryDecl());
+  EXPECT_TRUE(testStructuralMatch(t));
+}
+
+TEST_F(StructuralEquivalenceObjCCategoryTest, DifferentIvarName) {
+  auto t = makeDecls(
+  "@interface A @end @interface A() { int x; } @end",
+  "@interface A @end @interface A() { int y; } @end", Lang_OBJC,
+  objcCategoryDecl());
+  EXPECT_FALSE(testStructuralMatch(t));
+}
+
+TEST_F(StructuralEquivalenceObjCCategoryTest, DifferentIvarType) {
+  auto t = makeDecls(
+  "@interface A @end @interface A() { int x; } @end",
+  "@interface A @end @interface A() { float x; } @end", Lang_OBJC,
+  objcCategoryDecl());
+  EXPECT_FALSE(testStructuralMatch(t));
+}
+
+TEST_F(StructuralEquivalenceObjCCategoryTest, DifferentIvarBitfieldWidth) {
+  auto t = makeDecls(
+  "@interface A @end @interface A() { int x: 1; } @end",
+  "@interface A @end @interface A() { int x: 2; } @end", Lang_OBJC,
+  objcCategoryDecl());
+  EXPECT_FALSE(testStructuralMatch(t));
+}
+
+TEST_F(StructuralEquivalenceObjCCategoryTest, DifferentIvarVisibility) {
+  auto t = makeDecls(
+  "@interface A @end @interface A() { @public int x; } @end",
+  "@interface A @end @interface A() { @protected int x; } @end", Lang_OBJC,
+  objcCategoryDecl());
+  EXPECT_FALSE(testStructuralMatch(t));
+}
+
+TEST_F(StructuralEquivalenceObjCCategoryTest, DifferentIvarNumber) {
+  auto t = makeDecls(
+  "@interface A @end @interface A() { int x; } @end",
+  "@interface A @end @interface A() {} @end", Lang_OBJC,
+  objcCategoryDecl());
+  EXPECT_FALSE(testStructuralMatch(t));
+}
+
+TEST_F(StructuralEquivalenceObjC

[PATCH] D120465: [clang][deps] Disable implicit module maps

2022-03-11 Thread Duncan P. N. Exon Smith via Phabricator via cfe-commits
dexonsmith accepted this revision.
dexonsmith added a comment.
This revision is now accepted and ready to land.

LGTM, with a suggested change for the text of the comment.




Comment at: clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp:269-273
+  // However, some module maps loaded implicitly during the dependency scan can
+  // describe anti-dependencies. That happens when the current module is marked
+  // as '[no_undeclared_includes]', doesn't 'use' module from such module map,
+  // but tries to import it anyway. We need to tell the explicit build about
+  // such module map for it to have the same semantics as the implicit build.

jansvoboda11 wrote:
> dexonsmith wrote:
> > jansvoboda11 wrote:
> > > dexonsmith wrote:
> > > > Is there another long-term solution to this that could be pointed at 
> > > > with a FIXME? E.g., could the module map be encoded redundantly here? 
> > > > If so, what else would need to change to make that okay?
> > > I'm not sure I understand why this would warrant "long-term solution" or 
> > > a FIXME. This code handles an existing feature that just happens to be a 
> > > corner case from the dependency scanning point of view. (You can read up 
> > > on the feature [[ https://clang.llvm.org/docs/Modules.html | here ]].)
> > > 
> > > What do you mean by encoding the module map redundantly?
> > Yes, I know the feature.
> > 
> > ... but I was probably wrong about how it affects the logic here.
> > 
> > I also now have two guesses at the scenario being handled here (previously 
> > I assumed (1)):
> > 
> > 1. A textual include from a module that is not marked as used. I wasn't 
> > sure what you meant by "tries to import", but I guess I thought it was just 
> > "loads the module map and finds the textual header listed there". IIUC, 
> > there's no actual attempt to import a module when the only thing referenced 
> > from it is a textual header, but I could see how parsing the module map 
> > could affect the state anyway.
> > 
> > 2. A modular include from a module that is not marked as used. Something 
> > like a `__has_include`, or a `#include` that fails but there's another 
> > search path with the same header. In this case, there'd be an actual import 
> > attempt, which would fail. And that could also affect state.
> > 
> > Can you clarify which scenario you need to handle? Or is it a 3rd?
> > 
> > > I'm not sure I understand why this would warrant "long-term solution" or 
> > > a FIXME.
> > 
> > This smells like a workaround to me. IIUC, sending in module maps that 
> > aren't actually "needed" except to reproduce side effects of failed queries.
> > 
> > My intuition is that the right long-term fix would involve isolate the 
> > failed queries from the compiler state in the scanning phase so that they 
> > don't have side effects. Then there would be no side effects to reproduce 
> > in the explicit build.
> > 
> > > What do you mean by encoding the module map redundantly?
> > 
> > I think I was confused about scanning vs building, thinking that a module 
> > using a textual include (1) could be copied into each module PCM that 
> > directly imports it. (I know that this wouldn't scale right now for various 
> > reasons, but I wondered if there was some way to get there... but 
> > regardless, seems like it's totally unrelated)
> The scenario being handled is the following:
> 
> 3. Modular `#include` of B from module A, where A is marked 
> `[no_undeclared_includes]` and doesn't `use B`. Typically, that `#include` 
> would be guarded by `__has_include`.
> 
> With implicit module maps disabled, the presence of module map B allows us to 
> evaluate the `__has_include` the same way as with them enabled. This is the 
> only reason we need module map B. There are no side effects from failed 
> queries. The query failure itself is the behavior we need to reproduce.
> 
> I'm not even thinking about "another search path with the same header" in 
> this patch.
Thanks! I was making things way too complicated!

IIUC:
- Without the module map, a `__has_include` would succeed because it'd be 
textually included.
- With the module map, a `__has_include` would fail because the module map 
would block textual inclusion and `[no_undeclared_includes]` would block 
modular inclusion.

Here's some text that I'd suggest:
```
  // We usually don't need to list the module map files of our dependencies when
  // building a module explicitly: their semantics will be deserialized from PCM
  // files.
  //
  // However, some module maps loaded implicitly during the dependency scan can
  // describe anti-dependencies. That happens when this module, let's call it 
M1,
  // is marked as '[no_undeclared_includes]' and tries to access a header 
"M2/M2.h"
  // from another module, M2, but doesn't have a 'use M2;' declaration. The 
explicit
  // build needs the module map for M2 so that it knows that textually including
  // "M2/M2.h" is not allowed. E.g., '__has

[PATCH] D121372: [clang-tidy][docs][NFC] Update URL and docs of PostfixOperatorCheck

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

LGTM!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D121372

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


[PATCH] D121122: Set FLT_EVAL_METHOD to -1 when fast-math is enabled.

2022-03-11 Thread Zahira Ammarguellat via Phabricator via cfe-commits
zahiraam updated this revision to Diff 414729.
zahiraam marked an inline comment as done.

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

https://reviews.llvm.org/D121122

Files:
  clang/include/clang/Lex/Preprocessor.h
  clang/lib/Lex/PPMacroExpansion.cpp
  clang/lib/Sema/Sema.cpp
  clang/lib/Sema/SemaAttr.cpp
  clang/test/CodeGen/eval-method-fast-math.c

Index: clang/test/CodeGen/eval-method-fast-math.c
===
--- /dev/null
+++ clang/test/CodeGen/eval-method-fast-math.c
@@ -0,0 +1,117 @@
+// RUN: %clang_cc1 -fexperimental-strict-floating-point  \
+// RUN: -triple x86_64-linux-gnu -emit-llvm -o - %s  \
+// RUN: | FileCheck %s -check-prefixes=CHECK
+
+// RUN: %clang_cc1 -triple i386--linux -emit-llvm -o - %s \
+// RUN: | FileCheck %s -check-prefixes=CHECK-EXT
+
+// RUN: %clang_cc1 -fexperimental-strict-floating-point  \
+// RUN: -mreassociate -freciprocal-math -ffp-contract=fast \
+// RUN: -ffast-math -triple x86_64-linux-gnu \
+// RUN: -emit-llvm -o - %s \
+// RUN: | FileCheck %s -check-prefixes=CHECK-FAST
+
+// RUN: %clang_cc1 -triple i386--linux -mreassociate -freciprocal-math \
+// RUN: -ffp-contract=fast -ffast-math -emit-llvm -o - %s \
+// RUN: | FileCheck %s -check-prefixes=CHECK-FAST
+
+float a = 1.0f, b = 2.0f, c = 3.0f;
+#pragma float_control(precise, off)
+float res2 = a + b + c;
+int val3 = __FLT_EVAL_METHOD__;
+#pragma float_control(precise, on)
+float res3 = a + b + c;
+int val4 = __FLT_EVAL_METHOD__;
+
+// CHECK: @val3 = global i32 -1
+// CHECK: @val4 = global i32 0
+
+// CHECK-EXT: @val3 = global i32 -1
+// CHECK-EXT: @val4 = global i32 2
+
+// CHECK-FAST: @val3 = global i32 -1
+// CHECK-FAST: @val4 = global i32 -1
+
+float res;
+int add(float a, float b, float c) {
+  // CHECK: fadd float
+  // CHECK: load float, float*
+  // CHECK: fadd float
+  // CHECK: store float
+  // CHECK: ret i32 0
+  res = a + b + c;
+  return __FLT_EVAL_METHOD__;
+}
+
+int add_precise(float a, float b, float c) {
+#pragma float_control(precise, on)
+  // CHECK: fadd float
+  // CHECK: load float, float*
+  // CHECK: fadd float
+  // CHECK: store float
+  // CHECK: ret i32 0
+  res = a + b + c;
+  return __FLT_EVAL_METHOD__;
+}
+
+#pragma float_control(push)
+#pragma float_control(precise, on)
+int add_precise_1(float a, float b, float c) {
+  // CHECK: fadd float
+  // CHECK: load float, float*
+  // CHECK: fadd float
+  // CHECK: store float
+  // CHECK: ret i32 0
+  res = a + b + c;
+  return __FLT_EVAL_METHOD__;
+}
+#pragma float_control(pop)
+
+int add_not_precise(float a, float b, float c) {
+  // Fast-math is enabled with this pragma.
+#pragma float_control(precise, off)
+  // CHECK: fadd fast float
+  // CHECK: load float, float*
+  // CHECK: fadd fast float
+  // CHECK: float {{.*}}, float*
+  // CHECK: ret i32 -1
+  res = a + b + c;
+  return __FLT_EVAL_METHOD__;
+}
+
+#pragma float_control(push)
+// Fast-math is enabled with this pragma.
+#pragma float_control(precise, off)
+int add_not_precise_1(float a, float b, float c) {
+  // CHECK: fadd fast float
+  // CHECK: load float, float*
+  // CHECK: fadd fast float
+  // CHECK: float {{.*}}, float*
+  // CHECK: ret i32 -1
+  res = a + b + c;
+  return __FLT_EVAL_METHOD__;
+}
+#pragma float_control(pop)
+
+int getFPEvalMethod() {
+  // CHECK: ret i32 0
+  return __FLT_EVAL_METHOD__;
+}
+
+float res1;
+int whatever(float a, float b, float c) {
+#pragma float_control(precise, off)
+  // CHECK: load float, float*
+  // CHECK: fadd fast float
+  // CHECK: store float {{.*}}, float*
+  // CHECK: store i32 -1
+  // CHECK: store i32 0
+  // CHECK: ret i32 -1
+  res1 = a + b + c;
+  int val1 = __FLT_EVAL_METHOD__;
+  {
+#pragma float_control(precise, on)
+int val2 = __FLT_EVAL_METHOD__;
+  }
+  return __FLT_EVAL_METHOD__;
+}
Index: clang/lib/Sema/SemaAttr.cpp
===
--- clang/lib/Sema/SemaAttr.cpp
+++ clang/lib/Sema/SemaAttr.cpp
@@ -508,6 +508,13 @@
   case PFC_Precise:
 NewFPFeatures.setFPPreciseEnabled(true);
 FpPragmaStack.Act(Loc, Action, StringRef(), NewFPFeatures);
+if (PP.getCurrentFPEvalMethod() ==
+LangOptions::FPEvalMethodKind::FEM_Indeterminable &&
+PP.getLastFPEvalPragmaLocation().isValid())
+// A preceding `pragma float_control(precise,off)` has changed
+// the value of the evaluation method.
+// Set it back to its old value.
+  PP.setCurrentFPEvalMethod(SourceLocation(), PP.getLastFPEvalMethod());
 break;
   case PFC_NoPrecise:
 if (CurFPFeatures.getFPExceptionMode() == LangOptions::FPE_Strict)
@@ -517,6 +524,10 @@
 else
   NewFPFeatures.setFPPreciseEnabled(false);
 FpPragmaStack.Act(Loc, Action, StringRef(), NewFPFeatures);
+PP.setLastFPEvalMethod(PP.getCurrentFPEvalMethod());
+// `AllowFPReassoc` or `AllowReciprocal` option is enabled.
+PP.setCurrentFPEvalMethod(
+Loc, LangOptions::FPEvalMethodKind::FEM_Indete

[PATCH] D121076: [MLIR][Python] Add SCFIfOp Python binding

2022-03-11 Thread Hongzheng Chen via Phabricator via cfe-commits
chhzh123 added a comment.

@ftynse Thanks for reviewing! Could you help land the PR? Seems I do not have 
access rights to push to the main repository.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D121076

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


[PATCH] D121214: [clang-tidy][docs][NFC] Refer to the CERT rule in bugprone-shared-ptr-array-mismatch docs

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

LGTM, I think this is a good incremental improvement until the check covers 
more of MEM51-CPP.


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

https://reviews.llvm.org/D121214

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


[PATCH] D120610: [DebugInfo] Include DW_TAG_skeleton_unit when looking for parent UnitDie

2022-03-11 Thread David Blaikie via Phabricator via cfe-commits
dblaikie added a comment.

It'd be good to include some testing beyond "does not crash" - like what was 
the specific debug info we were trying to create when the crash was hit? 
Perhaps we should be testing that (since the crash demonstrates we weren't 
testing that anywhere else)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D120610

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


[PATCH] D117522: [clang-tidy] Add modernize-macro-to-enum check

2022-03-11 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

In D117522#3364387 , 
@LegalizeAdulthood wrote:

> Ping.  Another week waiting for reviews...

Thanks for the ping! FWIW, it's also not uncommon for there to be week delays 
(reviewers go on vacation, have other obligations, etc), so hopefully the 
delays are not too frustrating. We do our best to review in a timely manner.

Overall, I think this is a really neat new check. One thing I think we should 
do is entirely ignore macros that are defined in system headers. We don't 
diagnose in system headers by default, but there's no reason to even do the 
processing work within a system header because those macros can't be changed 
(not only can the user not change them because it's a system header, but it's 
also likely that the macro is required for standards conformance). I think we 
can get some good compile-time performance wins from bailing on system headers, 
but this is speculative.




Comment at: clang-tools-extra/clang-tidy/modernize/MacroToEnumCheck.cpp:47
+CRLF,
+CRLFCR,
+  };

I'm a bit confused by this one as this is not a valid line ending (it's either 
three valid line endings or two valid line endings, depending on how you look 
at it). Can you explain why this is needed?



Comment at: clang-tools-extra/clang-tidy/modernize/MacroToEnumCheck.cpp:83-84
+  const char *End = Begin + Token.getLength();
+  return std::none_of(
+  Begin, End, [](char C) { return C == '.' || std::toupper(C) == 'E'; });
+}

Won't this cause a problem for hex literals like `0xE`?



Comment at: clang-tools-extra/clang-tidy/modernize/MacroToEnumCheck.cpp:106
+  int ConditionScopes;
+  unsigned int LastLine;
+  IncludeGuard GuardScanner;

Maybe not worth worrying about, but should this be a `uint64_t` to handle 
massive source files?



Comment at: clang-tools-extra/clang-tidy/modernize/MacroToEnumCheck.cpp:315
+  if (Info->isFunctionLike() || Info->isBuiltinMacro() ||
+  Info->tokens().empty() || Info->tokens().size() > 2)
+return;

We don't seem to have any tests for literal suffixes and I *think* those will 
show up here as additional tokens after the literal. e.g., `#define FOO +1ULL`, 
so I think the size check here may be a problem.



Comment at: clang-tools-extra/clang-tidy/modernize/MacroToEnumCheck.cpp:318
+
+  // It can be +Lit, -Lit or just Lit.
+  Token Tok = Info->tokens().front();

It's worth pointing out that both of these are expressions that operate on a 
literal, and if we're going to allow expressions that operator on a literal, 
why only these two? e.g. why not allow `#define FOO ~0U` or `#define BAR FOO + 
1`? Someday (not today), it would be nice for this to work on any expression 
that's a valid constant expression.



Comment at: clang-tools-extra/clang-tidy/modernize/MacroToEnumCheck.cpp:418
+  Check->diag(Macro.Directive->getLocation(),
+  "Macro '%0' defines an integral constant; prefer an enum 
instead")
+  << Macro.Name.getIdentifierInfo()->getName();

Diagnostics in clang-tidy don't start with a capital letter or have trailing 
punctuation.



Comment at: clang-tools-extra/clang-tidy/modernize/MacroToEnumCheck.cpp:419
+  "Macro '%0' defines an integral constant; prefer an enum 
instead")
+  << Macro.Name.getIdentifierInfo()->getName();
+}

I *think* you don't need to call `getName()` here because the diagnostics 
engine already knows how to handle an `IdentifierInfo *` (but I could be 
remembering wrong)



Comment at: clang-tools-extra/clang-tidy/modernize/MacroToEnumCheck.cpp:428
+  DiagnosticBuilder Diagnostic =
+  Check->diag(Begin, "Replace macro with enum")
+  << FixItHint::CreateInsertion(Begin, "enum {\n");





Comment at: clang-tools-extra/clang-tidy/modernize/ModernizeTidyModule.cpp:88-92
+CheckFactories.registerCheck(
+"modernize-use-equals-default");
 CheckFactories.registerCheck(
 "modernize-use-equals-delete");
+CheckFactories.registerCheck("modernize-use-nodiscard");

Unrelated formatting changes? (Feel free to land separately)



Comment at: 
clang-tools-extra/test/clang-tidy/checkers/modernize-macro-to-enum.cpp:67-68
+
+// Undefining a macro invalidates adjacent macros
+// from being considered as an enum.
+#define REMOVED1 1

What about an #undef that's not adjacent to any macros? e.g.,
```
#define FOO 1
#define BAR 2
#define BAZ 3

int i = 12;

#if defined(FROBBLE)
#undef FOO
#endif
```
I'm worried that perhaps other code elsewhere will be checking `defined(FOO)` 
perhaps in cases conditionally compiled away, and switching `FOO` to be an enum 
constant will break other configurations. To be honest

[PATCH] D121122: Set FLT_EVAL_METHOD to -1 when fast-math is enabled.

2022-03-11 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

It looks like there are some clang-format issues to handle as well.




Comment at: clang/test/CodeGen/eval-method-fast-math.c:113-116
+#pragma float_control(precise, on)
+int val2 = __FLT_EVAL_METHOD__;
+  }
+  return __FLT_EVAL_METHOD__;

Shouldn't there be CHECK lines for these?


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

https://reviews.llvm.org/D121122

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


[PATCH] D120610: [DebugInfo] Include DW_TAG_skeleton_unit when looking for parent UnitDie

2022-03-11 Thread Wenlei He via Phabricator via cfe-commits
wenlei updated this revision to Diff 414737.
wenlei added a comment.

Add test check for template type parameters


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D120610

Files:
  llvm/lib/CodeGen/AsmPrinter/DIE.cpp
  llvm/test/DebugInfo/X86/fission-template.ll


Index: llvm/test/DebugInfo/X86/fission-template.ll
===
--- /dev/null
+++ llvm/test/DebugInfo/X86/fission-template.ll
@@ -0,0 +1,75 @@
+; Check that we handle template types for split-dwarf-inlining correctly.
+; RUN: llc -split-dwarf-file=%t.dwo -O2 < %s -dwarf-version=5 
-mtriple=x86_64-unknown-linux-gnu -filetype=obj -o -  | llvm-dwarfdump - | 
FileCheck %s
+;
+; The test case is generated from the following code
+; clang -cc1 -emit-llvm -fdebug-info-for-profiling -fsplit-dwarf-inlining 
-debug-info-kind=constructor -dwarf-version=5 -split-dwarf-file temp.dwo -O2
+;
+; void f1();
+;
+; template 
+; void f2() {
+;   f1();
+; }
+;
+; void f3() {
+;   f2();
+; }
+
+; CHECK:  .debug_info contents:
+; CHECK:DW_TAG_skeleton_unit
+; CHECK:  DW_TAG_subprogram
+; CHECK-NEXT: DW_AT_linkage_name   ("_Z2f2IiEvv")
+; CHECK-NEXT: DW_AT_name   ("f2")
+; CHECK:  DW_TAG_template_type_parameter
+; CHECK-NEXT:   DW_AT_type (0x{{.*}} "int")
+; CHECK-NEXT:   DW_AT_name ("T")
+; CHECK:  .debug_info.dwo contents:
+; CHECK:DW_TAG_compile_unit
+; CHECK:  DW_TAG_subprogram
+; CHECK-NEXT: DW_AT_linkage_name   ("_Z2f2IiEvv")
+; CHECK-NEXT: DW_AT_name   ("f2")
+; CHECK:  DW_TAG_template_type_parameter
+; CHECK-NEXT:   DW_AT_type (0x{{.*}} "int")
+; CHECK-NEXT:   DW_AT_name ("T")
+
+; ModuleID = 'split-debug-inlining-template.cpp'
+source_filename = 
"llvm-project/clang/test/CodeGen/split-debug-inlining-template.cpp"
+target datalayout = 
"e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
+target triple = "x86_64-redhat-linux-gnu"
+
+; Function Attrs: mustprogress nounwind
+define dso_local void @_Z2f3v() local_unnamed_addr #0 !dbg !6 {
+entry:
+  tail call void @_Z2f1v() #2, !dbg !11
+  ret void, !dbg !17
+}
+
+declare !dbg !18 void @_Z2f1v() local_unnamed_addr #1
+
+attributes #0 = { mustprogress nounwind "frame-pointer"="none" 
"min-legal-vector-width"="0" "no-trapping-math"="true" 
"stack-protector-buffer-size"="8" "target-features"="+cx8,+mmx,+sse,+sse2,+x87" 
}
+attributes #1 = { "frame-pointer"="none" "no-trapping-math"="true" 
"stack-protector-buffer-size"="8" "target-features"="+cx8,+mmx,+sse,+sse2,+x87" 
}
+attributes #2 = { nounwind }
+
+!llvm.dbg.cu = !{!0}
+!llvm.module.flags = !{!2, !3, !4}
+!llvm.ident = !{!5}
+
+!0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus_14, file: !1, 
producer: "clang version 15.0.0 (https://github.com/llvm/llvm-project.git 
8b2b9c3fa91ebe583f8c634482885a669b82a1f0)", isOptimized: true, runtimeVersion: 
0, splitDebugFilename: "split-debug-inlining-template.c.tmp.dwo", emissionKind: 
FullDebug, debugInfoForProfiling: true, nameTableKind: None)
+!1 = !DIFile(filename: "llvm-project/clang/test/CodeGen/", directory: 
"build-debug", checksumkind: CSK_MD5, checksum: 
"0fb39b3bb5a60928b5d9c251b2d91b2c")
+!2 = !{i32 7, !"Dwarf Version", i32 5}
+!3 = !{i32 2, !"Debug Info Version", i32 3}
+!4 = !{i32 1, !"wchar_size", i32 4}
+!5 = !{!"clang version 15.0.0 (https://github.com/llvm/llvm-project.git 
8b2b9c3fa91ebe583f8c634482885a669b82a1f0)"}
+!6 = distinct !DISubprogram(name: "f3", linkageName: "_Z2f3v", scope: !7, 
file: !7, line: 11, type: !8, scopeLine: 11, flags: DIFlagPrototyped | 
DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: 
!0, retainedNodes: !10)
+!7 = !DIFile(filename: 
"llvm-project/clang/test/CodeGen/split-debug-inlining-template.cpp", directory: 
"", checksumkind: CSK_MD5, checksum: "0fb39b3bb5a60928b5d9c251b2d91b2c")
+!8 = !DISubroutineType(types: !9)
+!9 = !{null}
+!10 = !{}
+!11 = !DILocation(line: 8, column: 3, scope: !12, inlinedAt: !16)
+!12 = distinct !DISubprogram(name: "f2", linkageName: "_Z2f2IiEvv", 
scope: !7, file: !7, line: 7, type: !8, scopeLine: 7, flags: DIFlagPrototyped | 
DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: 
!0, templateParams: !13, retainedNodes: !10)
+!13 = !{!14}
+!14 = !DITemplateTypeParameter(name: "T", type: !15)
+!15 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
+!16 = distinct !DILocation(line: 12, column: 3, scope: !6)
+!17 = !DILocation(line: 13, column: 1, scope: !6)
+!18 = !DISubprogram(name: "f1", linkageName: "_Z2f1v", scope: !7, file: !7, 
line: 4, type: !8, flags: DIFlagPrototyped, spFlags: DISPFlagOptimized, 
retainedNodes: !10)
Index: llvm/lib/CodeGen/AsmPrinter/DIE.cpp
===
--- llvm/lib/CodeGen/AsmPrinter/DIE.cpp
+++ llvm/lib/CodeGen/AsmPrinter/DIE.cpp
@@ -204,6 +204,7 @@
   

[PATCH] D120610: [DebugInfo] Include DW_TAG_skeleton_unit when looking for parent UnitDie

2022-03-11 Thread Wenlei He via Phabricator via cfe-commits
wenlei added a comment.

In D120610#3376002 , @dblaikie wrote:

> It'd be good to include some testing beyond "does not crash" - like what was 
> the specific debug info we were trying to create when the crash was hit? 
> Perhaps we should be testing that (since the crash demonstrates we weren't 
> testing that anywhere else)

Sure, added a few checks around `DW_TAG_template_type_parameter` for both 
`DW_TAG_skeleton_unit` and `DW_TAG_skeleton_unit`. Let me know whether what I 
have here aligns with the convention of similar tests.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D120610

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


[PATCH] D121076: [MLIR][Python] Add SCFIfOp Python binding

2022-03-11 Thread Mehdi AMINI via Phabricator via cfe-commits
mehdi_amini added a comment.

Can you rebase? Your patch does not apply apparently


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D121076

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


[PATCH] D121122: Set FLT_EVAL_METHOD to -1 when fast-math is enabled.

2022-03-11 Thread Zahira Ammarguellat via Phabricator via cfe-commits
zahiraam added inline comments.



Comment at: clang/test/CodeGen/eval-method-fast-math.c:113-116
+#pragma float_control(precise, on)
+int val2 = __FLT_EVAL_METHOD__;
+  }
+  return __FLT_EVAL_METHOD__;

aaron.ballman wrote:
> Shouldn't there be CHECK lines for these?
These are the ones:
 // CHECK: store i32 0
  // CHECK: ret i32 -1

they are truncated.  They are in reality these:
  store i32 -1, i32* %val1, align 4
  store i32 0, i32* %val2, align 4
Is that what you mean?


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

https://reviews.llvm.org/D121122

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


[PATCH] D111400: [Clang] Implement P2242R3

2022-03-11 Thread Hubert Tong via Phabricator via cfe-commits
hubert.reinterpretcast added a comment.

@aaron.ballman, I haven't had a chance to look at the code in detail yet, but I 
would like to get on the same page about the error/warning behaviour.

In the older modes, we stay conforming either

- by producing the warning (when we know the user said they wanted the function 
to be `constexpr`) and letting the code through or
- by doing what the older document says because a warning is inappropriate at 
the point of the check and we have no mechanism developed (including for other 
similar cases) for producing the warning only when semantically significant 
later.

In C++2b, the `-Wc++20-compat` warning is produced for the places where we warn 
above and is not produced for the places where we don't warn above.

Considering that the warning would be something like "this function is not 
implicitly constexpr in C++20 but is so in C++23", and we probably will have a 
lot of such cases for other reasons, I can buy that people are not interested 
in such a warning.




Comment at: clang/test/CXX/basic/basic.types/p10.cpp:23
 extern BeingDefined beingdefined;
-struct BeingDefined { 
+struct BeingDefined {
   static constexpr BeingDefined& t = beingdefined;

Seems like the only change in this file is drive-by NFC. Can this be pulled out 
of this patch?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D111400

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


[PATCH] D121122: Set FLT_EVAL_METHOD to -1 when fast-math is enabled.

2022-03-11 Thread Zahira Ammarguellat via Phabricator via cfe-commits
zahiraam updated this revision to Diff 414739.

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

https://reviews.llvm.org/D121122

Files:
  clang/include/clang/Lex/Preprocessor.h
  clang/lib/Lex/PPMacroExpansion.cpp
  clang/lib/Sema/Sema.cpp
  clang/lib/Sema/SemaAttr.cpp
  clang/test/CodeGen/eval-method-fast-math.cpp

Index: clang/test/CodeGen/eval-method-fast-math.cpp
===
--- /dev/null
+++ clang/test/CodeGen/eval-method-fast-math.cpp
@@ -0,0 +1,117 @@
+// RUN: %clang_cc1 -fexperimental-strict-floating-point  \
+// RUN: -triple x86_64-linux-gnu -emit-llvm -o - %s  \
+// RUN: | FileCheck %s -check-prefixes=CHECK
+
+// RUN: %clang_cc1 -triple i386--linux -emit-llvm -o - %s \
+// RUN: | FileCheck %s -check-prefixes=CHECK-EXT
+
+// RUN: %clang_cc1 -fexperimental-strict-floating-point  \
+// RUN: -mreassociate -freciprocal-math -ffp-contract=fast \
+// RUN: -ffast-math -triple x86_64-linux-gnu \
+// RUN: -emit-llvm -o - %s \
+// RUN: | FileCheck %s -check-prefixes=CHECK-FAST
+
+// RUN: %clang_cc1 -triple i386--linux -mreassociate -freciprocal-math \
+// RUN: -ffp-contract=fast -ffast-math -emit-llvm -o - %s \
+// RUN: | FileCheck %s -check-prefixes=CHECK-FAST
+
+float a = 1.0f, b = 2.0f, c = 3.0f;
+#pragma float_control(precise, off)
+float res2 = a + b + c;
+int val3 = __FLT_EVAL_METHOD__;
+#pragma float_control(precise, on)
+float res3 = a + b + c;
+int val4 = __FLT_EVAL_METHOD__;
+
+// CHECK: @val3 = global i32 -1
+// CHECK: @val4 = global i32 0
+
+// CHECK-EXT: @val3 = global i32 -1
+// CHECK-EXT: @val4 = global i32 2
+
+// CHECK-FAST: @val3 = global i32 -1
+// CHECK-FAST: @val4 = global i32 -1
+
+float res;
+int add(float a, float b, float c) {
+  // CHECK: fadd float
+  // CHECK: load float, float*
+  // CHECK: fadd float
+  // CHECK: store float
+  // CHECK: ret i32 0
+  res = a + b + c;
+  return __FLT_EVAL_METHOD__;
+}
+
+int add_precise(float a, float b, float c) {
+#pragma float_control(precise, on)
+  // CHECK: fadd float
+  // CHECK: load float, float*
+  // CHECK: fadd float
+  // CHECK: store float
+  // CHECK: ret i32 0
+  res = a + b + c;
+  return __FLT_EVAL_METHOD__;
+}
+
+#pragma float_control(push)
+#pragma float_control(precise, on)
+int add_precise_1(float a, float b, float c) {
+  // CHECK: fadd float
+  // CHECK: load float, float*
+  // CHECK: fadd float
+  // CHECK: store float
+  // CHECK: ret i32 0
+  res = a + b + c;
+  return __FLT_EVAL_METHOD__;
+}
+#pragma float_control(pop)
+
+int add_not_precise(float a, float b, float c) {
+  // Fast-math is enabled with this pragma.
+#pragma float_control(precise, off)
+  // CHECK: fadd fast float
+  // CHECK: load float, float*
+  // CHECK: fadd fast float
+  // CHECK: float {{.*}}, float*
+  // CHECK: ret i32 -1
+  res = a + b + c;
+  return __FLT_EVAL_METHOD__;
+}
+
+#pragma float_control(push)
+// Fast-math is enabled with this pragma.
+#pragma float_control(precise, off)
+int add_not_precise_1(float a, float b, float c) {
+  // CHECK: fadd fast float
+  // CHECK: load float, float*
+  // CHECK: fadd fast float
+  // CHECK: float {{.*}}, float*
+  // CHECK: ret i32 -1
+  res = a + b + c;
+  return __FLT_EVAL_METHOD__;
+}
+#pragma float_control(pop)
+
+int getFPEvalMethod() {
+  // CHECK: ret i32 0
+  return __FLT_EVAL_METHOD__;
+}
+
+float res1;
+int whatever(float a, float b, float c) {
+#pragma float_control(precise, off)
+  // CHECK: load float, float*
+  // CHECK: fadd fast float
+  // CHECK: store float {{.*}}, float*
+  // CHECK: store i32 -1
+  // CHECK: store i32 0
+  // CHECK: ret i32 -1
+  res1 = a + b + c;
+  int val1 = __FLT_EVAL_METHOD__;
+  {
+#pragma float_control(precise, on)
+int val2 = __FLT_EVAL_METHOD__;
+  }
+  return __FLT_EVAL_METHOD__;
+}
Index: clang/lib/Sema/SemaAttr.cpp
===
--- clang/lib/Sema/SemaAttr.cpp
+++ clang/lib/Sema/SemaAttr.cpp
@@ -508,6 +508,13 @@
   case PFC_Precise:
 NewFPFeatures.setFPPreciseEnabled(true);
 FpPragmaStack.Act(Loc, Action, StringRef(), NewFPFeatures);
+if (PP.getCurrentFPEvalMethod() ==
+LangOptions::FPEvalMethodKind::FEM_Indeterminable &&
+PP.getLastFPEvalPragmaLocation().isValid())
+  // A preceding `pragma float_control(precise,off)` has changed
+  // the value of the evaluation method.
+  // Set it back to its old value.
+  PP.setCurrentFPEvalMethod(SourceLocation(), PP.getLastFPEvalMethod());
 break;
   case PFC_NoPrecise:
 if (CurFPFeatures.getFPExceptionMode() == LangOptions::FPE_Strict)
@@ -517,6 +524,10 @@
 else
   NewFPFeatures.setFPPreciseEnabled(false);
 FpPragmaStack.Act(Loc, Action, StringRef(), NewFPFeatures);
+PP.setLastFPEvalMethod(PP.getCurrentFPEvalMethod());
+// `AllowFPReassoc` or `AllowReciprocal` option is enabled.
+PP.setCurrentFPEvalMethod(
+Loc, LangOptions::FPEvalMethodKind::FEM_Indeterminable);
 break;
   case PFC_Except:

[PATCH] D111400: [Clang] Implement P2242R3

2022-03-11 Thread Hubert Tong via Phabricator via cfe-commits
hubert.reinterpretcast added a comment.

In D111400#3376070 , 
@hubert.reinterpretcast wrote:

> In C++2b, the `-Wc++20-compat` warning is produced for the places where we 
> warn above and is not produced for the places where we don't warn above.

I'm not seeing any tests looking for these "incompatible with" messages.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D111400

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


[PATCH] D109701: [clang] Emit SARIF Diagnostics: Create `clang::SarifDocumentWriter` interface

2022-03-11 Thread Vaibhav Yenamandra via Phabricator via cfe-commits
vaibhav.y updated this revision to Diff 414743.
vaibhav.y marked 15 inline comments as done.
vaibhav.y added a comment.
Herald added a project: All.

Fixup comments
Mark clang::FullSourceRange as returning const & to its locs
rebase on upstream main


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109701

Files:
  clang/include/clang/Basic/Sarif.h
  clang/include/clang/Basic/SourceLocation.h
  clang/lib/Basic/CMakeLists.txt
  clang/lib/Basic/Sarif.cpp
  clang/lib/Basic/SourceLocation.cpp
  clang/unittests/Basic/CMakeLists.txt
  clang/unittests/Basic/SarifTest.cpp

Index: clang/unittests/Basic/SarifTest.cpp
===
--- /dev/null
+++ clang/unittests/Basic/SarifTest.cpp
@@ -0,0 +1,138 @@
+//===- unittests/Basic/SarifTest.cpp - Test writing SARIF documents ---===//
+//
+// 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 "clang/Basic/Sarif.h"
+#include "llvm/ADT/StringRef.h"
+#include "llvm/Support/JSON.h"
+#include 
+
+#include "gmock/gmock.h"
+#include "gtest/gtest-death-test.h"
+#include "gtest/gtest.h"
+
+using namespace clang;
+using namespace llvm;
+
+namespace {
+
+TEST(SarifDocumentWriterTest, createEmptyDocument) {
+  // GIVEN:
+  SarifDocumentWriter writer;
+
+  // WHEN:
+  const json::Object &emptyDocument = writer.createDocument();
+  std::vector keys(emptyDocument.size());
+  std::transform(emptyDocument.begin(), emptyDocument.end(), keys.begin(),
+ [](auto item) { return item.getFirst(); });
+
+  // THEN:
+  ASSERT_THAT(keys, testing::UnorderedElementsAre("$schema", "version"));
+}
+
+// Test that a newly inserted run will associate correct tool names
+TEST(SarifDocumentWriterTest, documentWithARun) {
+  // GIVEN:
+  SarifDocumentWriter writer;
+  const char *shortName = "sariftest";
+  const char *longName = "sarif writer test";
+
+  // WHEN:
+  writer.createRun(shortName, longName);
+  writer.endRun();
+  const json::Object &document = writer.createDocument();
+  const json::Array *runs = document.getArray("runs");
+
+  // THEN:
+  // A run was created
+  ASSERT_THAT(runs, testing::NotNull());
+
+  // It is the only run
+  ASSERT_EQ(runs->size(), 1UL);
+
+  // The tool associated with the run was the tool
+  const json::Object *driver =
+  runs->begin()->getAsObject()->getObject("tool")->getObject("driver");
+  ASSERT_THAT(driver, testing::NotNull());
+
+  ASSERT_TRUE(driver->getString("name").hasValue());
+  ASSERT_TRUE(driver->getString("fullName").hasValue());
+  ASSERT_TRUE(driver->getString("language").hasValue());
+
+  EXPECT_EQ(driver->getString("name").getValue(), shortName);
+  EXPECT_EQ(driver->getString("fullName").getValue(), longName);
+  EXPECT_EQ(driver->getString("language").getValue(), "en-US");
+}
+
+// Test adding result without a run causes a crash
+TEST(SarifDocumentWriterTest, addingResultsWillCrashIfThereIsNoRun) {
+  // GIVEN:
+  SarifDocumentWriter writer;
+
+  // WHEN:
+  //  A SarifDocumentWriter::createRun(...) was not called prior to
+  //  SarifDocumentWriter::appendResult(...)
+  // But a rule exists
+  auto ruleIdx = writer.createRule(SarifRule::create());
+  SarifResult &&emptyResult = SarifResult::create(ruleIdx);
+
+  // THEN:
+  ASSERT_DEATH({ writer.appendResult(emptyResult); }, ".*create a run first.*");
+}
+
+// Test adding rule and result shows up in the final document
+TEST(SarifDocumentWriterTest, addResultWithValidRuleIsOk) {
+  // GIVEN:
+  SarifDocumentWriter writer;
+  const SarifRule &rule =
+  SarifRule::create()
+  .setRuleId("clang.unittest")
+  .setDescription("Example rule created during unit tests")
+  .setName("clang unit test");
+
+  // WHEN:
+  writer.createRun("sarif test", "sarif test runner");
+  unsigned ruleIdx = writer.createRule(rule);
+  const SarifResult &result = SarifResult::create(ruleIdx);
+
+  writer.appendResult(result);
+  const json::Object &document = writer.createDocument();
+
+  // THEN:
+  // A document with a valid schema and version exists
+  ASSERT_THAT(document.get("$schema"), ::testing::NotNull());
+  ASSERT_THAT(document.get("version"), ::testing::NotNull());
+  const json::Array *runs = document.getArray("runs");
+
+  // A run exists on this document
+  ASSERT_THAT(runs, ::testing::NotNull());
+  ASSERT_EQ(runs->size(), 1UL);
+  const json::Object *theRun = runs->back().getAsObject();
+
+  // The run has slots for tools, results, rules and artifacts
+  ASSERT_THAT(theRun->get("tool"), ::testing::NotNull());
+  ASSERT_THAT(theRun->get("results"), ::testing::NotNull());
+  ASSERT_THAT(theRun->get("artifacts"), ::testing::NotNull());
+  const json::Object *driver = theRun->getO

[PATCH] D109701: [clang] Emit SARIF Diagnostics: Create `clang::SarifDocumentWriter` interface

2022-03-11 Thread Vaibhav Yenamandra via Phabricator via cfe-commits
vaibhav.y added a comment.

Hi,

Apologies for the long delay! I was on a short break to focus to other 
projects. I have some changes in mind such as:

- Creating the `SarifLog` object to represent the top-level document. Currently 
we store this as a JSON object which ends up rather mucky. Having a separate 
structure can release internal state in `SarifDocumentWriter`. That way the 
writer will end up only dealing with the serialization of a `SarifLog`.

Regarding how to validate documents, I think having a `SarifLog::validate()` 
that checks everything underneath is the way to go. Ideally I'd prefer handling 
on the interface level, but I'm uncertain what would be a good approach. What 
do you think?

I'll comb through the previous comments again to make sure I'm not missing 
punctuations, will signal when this is ready for review again.

Thanks!




Comment at: clang/include/clang/Basic/Sarif.h:112
+
+  explicit SarifArtifact(const SarifArtifactLocation &Loc) : Location(Loc) {}
+

aaron.ballman wrote:
> Should we delete the default ctor?
Agreed, there's no reason for it to be callable. Will do the same for 
`SarifArtifactLocation`.



Comment at: clang/include/clang/Basic/Sarif.h:340
+  /// Create a new empty SARIF document
+  SarifDocumentWriter() : Closed(true){};
+

aaron.ballman wrote:
> Once you use the default ctor, there's no way to associate language options 
> with the document writer. Is it wise to expose this constructor? (If we 
> didn't, then we could store the `LangOptions` as a const reference instead of 
> making a copy in the other constructor. Given that we never mutate the 
> options, I think that's a win.)
That's a good observation, I will delete this constructor and expose 
`SarifDocumentWriter(const LangOptions &LangOpts)` instead. 



Comment at: clang/lib/Basic/Sarif.cpp:248
+void SarifDocumentWriter::endRun() {
+  // Exit early if trying to close a closed Document
+  if (Closed) {

aaron.ballman wrote:
> (At this point, I'll stop commenting on these -- can you go through the patch 
> and make sure that all comments have appropriate terminating punctuation?)
Ack, sincere apologies again!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109701

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


[clang-tools-extra] 602ea53 - [clang-tidy] Refactor: Prefer single quoted strings over double quoted strings [NFC]

2022-03-11 Thread via cfe-commits

Author: Richard
Date: 2022-03-11T15:08:24-07:00
New Revision: 602ea53cb7e7119f7ba33239ca8ead377f2fcbd4

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

LOG: [clang-tidy] Refactor: Prefer single quoted strings over double quoted 
strings [NFC]

Added: 


Modified: 
clang-tools-extra/clang-tidy/add_new_check.py

Removed: 




diff  --git a/clang-tools-extra/clang-tidy/add_new_check.py 
b/clang-tools-extra/clang-tidy/add_new_check.py
old mode 100755
new mode 100644
index 50a220b3f9750..fc83974486314
--- a/clang-tools-extra/clang-tidy/add_new_check.py
+++ b/clang-tools-extra/clang-tidy/add_new_check.py
@@ -297,7 +297,7 @@ def write_test(module_path, module, check_name, 
test_extension):
 
 def get_actual_filename(dirname, filename):
   if not os.path.isdir(dirname): 
-return ""
+return ''
   name = os.path.join(dirname, filename)
   if (os.path.isfile(name)):
 return name
@@ -305,7 +305,7 @@ def get_actual_filename(dirname, filename):
   for file in os.listdir(dirname):
 if (file.lower() == caselessname):
   return os.path.join(dirname, file)
-  return ""
+  return ''
 
 
 # Recreates the list of checks in the docs/clang-tidy/checks directory.
@@ -321,7 +321,7 @@ def update_checks_list(clang_tidy_path):
   doc_files.sort()
 
   def has_auto_fix(check_name):
-dirname, _, check_name = check_name.partition("-")
+dirname, _, check_name = check_name.partition('-')
 
 checker_code = get_actual_filename(os.path.join(clang_tidy_path, dirname),
get_camel_check_name(check_name) + 
'.cpp')
@@ -338,7 +338,7 @@ def has_auto_fix(check_name):
 if needle in code:
   # Some simple heuristics to figure out if a checker has an autofix 
or not.
   return ' "Yes"'
-return ""
+return ''
 
   def process_doc(doc_file):
 check_name = doc_file.replace('.rst', '')
@@ -389,7 +389,7 @@ def format_link_alias(doc_file):
   with io.open(filename, 'w', encoding='utf8', newline='\n') as f:
 for line in lines:
   f.write(line)
-  if line.strip() == ".. csv-table::":
+  if line.strip() == '.. csv-table::':
 # We dump the checkers
 f.write('   :header: "Name", "Offers fixes"\n\n')
 f.writelines(checks)



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


[clang] 9f616a4 - [clang-format][NFC] Group QualifierAlignment with other C++ passes

2022-03-11 Thread via cfe-commits

Author: owenca
Date: 2022-03-11T14:18:00-08:00
New Revision: 9f616a467fc710f084b7e57812a2ed64c214c2c6

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

LOG: [clang-format][NFC] Group QualifierAlignment with other C++ passes

Also increases the initial size of Passes to 8 and move the
definition of BracesInserter up.

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

Added: 


Modified: 
clang/lib/Format/Format.cpp

Removed: 




diff  --git a/clang/lib/Format/Format.cpp b/clang/lib/Format/Format.cpp
index 9e3eaf72e121e..4f9320f2b34e5 100644
--- a/clang/lib/Format/Format.cpp
+++ b/clang/lib/Format/Format.cpp
@@ -1784,9 +1784,9 @@ FormatStyle::GetLanguageStyle(FormatStyle::LanguageKind 
Language) const {
 
 namespace {
 
-class BracesRemover : public TokenAnalyzer {
+class BracesInserter : public TokenAnalyzer {
 public:
-  BracesRemover(const Environment &Env, const FormatStyle &Style)
+  BracesInserter(const Environment &Env, const FormatStyle &Style)
   : TokenAnalyzer(Env, Style) {}
 
   std::pair
@@ -1795,40 +1795,40 @@ class BracesRemover : public TokenAnalyzer {
   FormatTokenLexer &Tokens) override {
 AffectedRangeMgr.computeAffectedLines(AnnotatedLines);
 tooling::Replacements Result;
-removeBraces(AnnotatedLines, Result);
+insertBraces(AnnotatedLines, Result);
 return {Result, 0};
   }
 
 private:
-  void removeBraces(SmallVectorImpl &Lines,
+  void insertBraces(SmallVectorImpl &Lines,
 tooling::Replacements &Result) {
 const auto &SourceMgr = Env.getSourceManager();
 for (AnnotatedLine *Line : Lines) {
-  removeBraces(Line->Children, Result);
+  insertBraces(Line->Children, Result);
   if (!Line->Affected)
 continue;
   for (FormatToken *Token = Line->First; Token && !Token->Finalized;
Token = Token->Next) {
-if (!Token->Optional)
+if (Token->BraceCount == 0)
   continue;
-assert(Token->isOneOf(tok::l_brace, tok::r_brace));
-assert(Token->Next || Token == Line->Last);
-const auto Start =
-Token == Line->Last || (Token->Next->is(tok::kw_else) &&
-Token->Next->NewlinesBefore > 0)
-? Token->WhitespaceRange.getBegin()
-: Token->Tok.getLocation();
-const auto Range =
-CharSourceRange::getCharRange(Start, Token->Tok.getEndLoc());
-cantFail(Result.add(tooling::Replacement(SourceMgr, Range, "")));
+std::string Brace;
+if (Token->BraceCount < 0) {
+  assert(Token->BraceCount == -1);
+  Brace = '{';
+} else {
+  Brace = '\n' + std::string(Token->BraceCount, '}');
+}
+Token->BraceCount = 0;
+const auto Start = Token->Tok.getEndLoc();
+cantFail(Result.add(tooling::Replacement(SourceMgr, Start, 0, Brace)));
   }
 }
   }
 };
 
-class BracesInserter : public TokenAnalyzer {
+class BracesRemover : public TokenAnalyzer {
 public:
-  BracesInserter(const Environment &Env, const FormatStyle &Style)
+  BracesRemover(const Environment &Env, const FormatStyle &Style)
   : TokenAnalyzer(Env, Style) {}
 
   std::pair
@@ -1837,32 +1837,32 @@ class BracesInserter : public TokenAnalyzer {
   FormatTokenLexer &Tokens) override {
 AffectedRangeMgr.computeAffectedLines(AnnotatedLines);
 tooling::Replacements Result;
-insertBraces(AnnotatedLines, Result);
+removeBraces(AnnotatedLines, Result);
 return {Result, 0};
   }
 
 private:
-  void insertBraces(SmallVectorImpl &Lines,
+  void removeBraces(SmallVectorImpl &Lines,
 tooling::Replacements &Result) {
 const auto &SourceMgr = Env.getSourceManager();
 for (AnnotatedLine *Line : Lines) {
-  insertBraces(Line->Children, Result);
+  removeBraces(Line->Children, Result);
   if (!Line->Affected)
 continue;
   for (FormatToken *Token = Line->First; Token && !Token->Finalized;
Token = Token->Next) {
-if (Token->BraceCount == 0)
+if (!Token->Optional)
   continue;
-std::string Brace;
-if (Token->BraceCount < 0) {
-  assert(Token->BraceCount == -1);
-  Brace = '{';
-} else {
-  Brace = '\n' + std::string(Token->BraceCount, '}');
-}
-Token->BraceCount = 0;
-const auto Start = Token->Tok.getEndLoc();
-cantFail(Result.add(tooling::Replacement(SourceMgr, Start, 0, Brace)));
+assert(Token->isOneOf(tok::l_brace, tok::r_brace));
+assert(Token->Next || Token == Line->Last);
+const auto Start =
+Token == Line->Last || (Token->Next->is(tok::kw_else) &&
+Token->

[PATCH] D121434: [clang-format][NFC] Group QualifierAlignment with other C++ passes

2022-03-11 Thread Owen Pan via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG9f616a467fc7: [clang-format][NFC] Group QualifierAlignment 
with other C++ passes (authored by owenpan).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D121434

Files:
  clang/lib/Format/Format.cpp

Index: clang/lib/Format/Format.cpp
===
--- clang/lib/Format/Format.cpp
+++ clang/lib/Format/Format.cpp
@@ -1784,9 +1784,9 @@
 
 namespace {
 
-class BracesRemover : public TokenAnalyzer {
+class BracesInserter : public TokenAnalyzer {
 public:
-  BracesRemover(const Environment &Env, const FormatStyle &Style)
+  BracesInserter(const Environment &Env, const FormatStyle &Style)
   : TokenAnalyzer(Env, Style) {}
 
   std::pair
@@ -1795,40 +1795,40 @@
   FormatTokenLexer &Tokens) override {
 AffectedRangeMgr.computeAffectedLines(AnnotatedLines);
 tooling::Replacements Result;
-removeBraces(AnnotatedLines, Result);
+insertBraces(AnnotatedLines, Result);
 return {Result, 0};
   }
 
 private:
-  void removeBraces(SmallVectorImpl &Lines,
+  void insertBraces(SmallVectorImpl &Lines,
 tooling::Replacements &Result) {
 const auto &SourceMgr = Env.getSourceManager();
 for (AnnotatedLine *Line : Lines) {
-  removeBraces(Line->Children, Result);
+  insertBraces(Line->Children, Result);
   if (!Line->Affected)
 continue;
   for (FormatToken *Token = Line->First; Token && !Token->Finalized;
Token = Token->Next) {
-if (!Token->Optional)
+if (Token->BraceCount == 0)
   continue;
-assert(Token->isOneOf(tok::l_brace, tok::r_brace));
-assert(Token->Next || Token == Line->Last);
-const auto Start =
-Token == Line->Last || (Token->Next->is(tok::kw_else) &&
-Token->Next->NewlinesBefore > 0)
-? Token->WhitespaceRange.getBegin()
-: Token->Tok.getLocation();
-const auto Range =
-CharSourceRange::getCharRange(Start, Token->Tok.getEndLoc());
-cantFail(Result.add(tooling::Replacement(SourceMgr, Range, "")));
+std::string Brace;
+if (Token->BraceCount < 0) {
+  assert(Token->BraceCount == -1);
+  Brace = '{';
+} else {
+  Brace = '\n' + std::string(Token->BraceCount, '}');
+}
+Token->BraceCount = 0;
+const auto Start = Token->Tok.getEndLoc();
+cantFail(Result.add(tooling::Replacement(SourceMgr, Start, 0, Brace)));
   }
 }
   }
 };
 
-class BracesInserter : public TokenAnalyzer {
+class BracesRemover : public TokenAnalyzer {
 public:
-  BracesInserter(const Environment &Env, const FormatStyle &Style)
+  BracesRemover(const Environment &Env, const FormatStyle &Style)
   : TokenAnalyzer(Env, Style) {}
 
   std::pair
@@ -1837,32 +1837,32 @@
   FormatTokenLexer &Tokens) override {
 AffectedRangeMgr.computeAffectedLines(AnnotatedLines);
 tooling::Replacements Result;
-insertBraces(AnnotatedLines, Result);
+removeBraces(AnnotatedLines, Result);
 return {Result, 0};
   }
 
 private:
-  void insertBraces(SmallVectorImpl &Lines,
+  void removeBraces(SmallVectorImpl &Lines,
 tooling::Replacements &Result) {
 const auto &SourceMgr = Env.getSourceManager();
 for (AnnotatedLine *Line : Lines) {
-  insertBraces(Line->Children, Result);
+  removeBraces(Line->Children, Result);
   if (!Line->Affected)
 continue;
   for (FormatToken *Token = Line->First; Token && !Token->Finalized;
Token = Token->Next) {
-if (Token->BraceCount == 0)
+if (!Token->Optional)
   continue;
-std::string Brace;
-if (Token->BraceCount < 0) {
-  assert(Token->BraceCount == -1);
-  Brace = '{';
-} else {
-  Brace = '\n' + std::string(Token->BraceCount, '}');
-}
-Token->BraceCount = 0;
-const auto Start = Token->Tok.getEndLoc();
-cantFail(Result.add(tooling::Replacement(SourceMgr, Start, 0, Brace)));
+assert(Token->isOneOf(tok::l_brace, tok::r_brace));
+assert(Token->Next || Token == Line->Last);
+const auto Start =
+Token == Line->Last || (Token->Next->is(tok::kw_else) &&
+Token->Next->NewlinesBefore > 0)
+? Token->WhitespaceRange.getBegin()
+: Token->Tok.getLocation();
+const auto Range =
+CharSourceRange::getCharRange(Start, Token->Tok.getEndLoc());
+cantFail(Result.add(tooling::Replacement(SourceMgr, Range, "")));
   }
 }
   }
@@ -3169,18 +3169,18 @@
   typedef std::function(
   const Environment &)>
   AnalyzerPass;
-  SmallVector Passes;
-
-  if (Style.isCpp() && Style

[PATCH] D121426: [VFS] Update uses of getVFSFromYAML to use the new getVFSFromYAMLs API

2022-03-11 Thread Ben Barham via Phabricator via cfe-commits
bnbarham updated this revision to Diff 414751.
bnbarham edited the summary of this revision.
bnbarham added a comment.

Update to single review dependency


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D121426

Files:
  clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/test/VFS/Inputs/vfsroot.yaml
  clang/test/VFS/directory.c
  clang/test/VFS/multiple-overlays.c
  clang/test/VFS/vfsroot-with-overlay.c
  lldb/source/Commands/CommandObjectReproducer.cpp
  llvm/include/llvm/Support/Error.h
  llvm/tools/dsymutil/Reproducer.cpp
  llvm/tools/dsymutil/Reproducer.h

Index: llvm/tools/dsymutil/Reproducer.h
===
--- llvm/tools/dsymutil/Reproducer.h
+++ llvm/tools/dsymutil/Reproducer.h
@@ -59,8 +59,7 @@
 };
 
 /// Reproducer instance used to use an existing reproducer. The VFS returned by
-/// this instance is a RedirectingFileSystem that remaps paths to their
-/// counterpart in the reproducer.
+/// this instance remaps paths to their counterpart in the reproducer.
 class ReproducerUse : public Reproducer {
 public:
   ReproducerUse(StringRef Root, std::error_code &EC);
Index: llvm/tools/dsymutil/Reproducer.cpp
===
--- llvm/tools/dsymutil/Reproducer.cpp
+++ llvm/tools/dsymutil/Reproducer.cpp
@@ -48,15 +48,15 @@
 ReproducerUse::ReproducerUse(StringRef Root, std::error_code &EC) {
   SmallString<128> Mapping(Root);
   sys::path::append(Mapping, "mapping.yaml");
-  ErrorOr> Buffer =
-  vfs::getRealFileSystem()->getBufferForFile(Mapping.str());
 
-  if (!Buffer) {
-EC = Buffer.getError();
+  auto OverlayFS = llvm::vfs::getVFSFromYAMLs(Mapping.str());
+  if (auto Err = OverlayFS.takeError()) {
+llvm::handleAllErrors(std::move(Err), [&](const llvm::ErrorInfoBase &E) {
+  EC = E.convertToErrorCode();
+});
 return;
   }
-
-  VFS = llvm::vfs::getVFSFromYAML(std::move(Buffer.get()), nullptr, Mapping);
+  VFS = std::move(*OverlayFS);
 }
 
 llvm::Expected>
Index: llvm/include/llvm/Support/Error.h
===
--- llvm/include/llvm/Support/Error.h
+++ llvm/include/llvm/Support/Error.h
@@ -1281,7 +1281,7 @@
 return OS.str();
   }
 
-  StringRef getFileName() { return FileName; }
+  StringRef getFileName() const { return FileName; }
 
   Error takeError() { return Error(std::move(Err)); }
 
Index: lldb/source/Commands/CommandObjectReproducer.cpp
===
--- lldb/source/Commands/CommandObjectReproducer.cpp
+++ lldb/source/Commands/CommandObjectReproducer.cpp
@@ -409,23 +409,19 @@
 switch (m_options.provider) {
 case eReproducerProviderFiles: {
   FileSpec vfs_mapping = loader->GetFile();
+  std::string overlay_path = vfs_mapping.GetPath();
 
-  // Read the VFS mapping.
-  ErrorOr> buffer =
-  vfs::getRealFileSystem()->getBufferForFile(vfs_mapping.GetPath());
-  if (!buffer) {
-SetError(result, errorCodeToError(buffer.getError()));
+  Expected> vfs =
+  vfs::getVFSFromYAMLs(StringRef(overlay_path));
+  if (auto err = vfs.takeError()) {
+SetError(result, std::move(err));
 return false;
   }
 
-  // Initialize a VFS from the given mapping.
-  IntrusiveRefCntPtr vfs = vfs::getVFSFromYAML(
-  std::move(buffer.get()), nullptr, vfs_mapping.GetPath());
-
   // Dump the VFS to a buffer.
   std::string str;
   raw_string_ostream os(str);
-  static_cast(*vfs).dump(os);
+  (*vfs)->dump(os);
   os.flush();
 
   // Return the string.
Index: clang/test/VFS/vfsroot-with-overlay.c
===
--- clang/test/VFS/vfsroot-with-overlay.c
+++ clang/test/VFS/vfsroot-with-overlay.c
@@ -1,7 +1,7 @@
 // RUN: rm -rf %t
 // RUN: mkdir -p %t
 // RUN: sed -e "s@TEST_DIR@%{/S:regex_replacement}@g" -e "s@OUT_DIR@%{/t:regex_replacement}@g" %S/Inputs/vfsroot.yaml > %t.yaml
-// RUN: sed -e "s@INPUT_DIR@/indirect-vfs-root-files@g" -e "s@OUT_DIR@/overlay-dir@g" %S/Inputs/vfsoverlay.yaml > %t/vfsoverlay.yaml
+// RUN: sed -e "s@INPUT_DIR@%{/S:regex_replacement}/Inputs@g" -e "s@OUT_DIR@/overlay-dir@g" %S/Inputs/vfsoverlay.yaml > %t/vfsoverlay.yaml
 // RUN: %clang_cc1 -Werror -ivfsoverlay %t.yaml -ivfsoverlay /direct-vfs-root-files/vfsoverlay.yaml -I /overlay-dir -fsyntax-only /tests/vfsroot-with-overlay.c
 
 #include "not_real.h"
Index: clang/test/VFS/multiple-overlays.c
===
--- /dev/null
+++ clang/test/VFS/multiple-overlays.c
@@ -0,0 +1,39 @@
+// RUN: rm -rf %t
+// RUN: split-file %s %t
+// RUN: sed -e "s@EXTERNAL_DIR@%{/t:regex_replacement}/B@g" -e "s@NAME_DIR@%{/t:regex_replacement}/A@g" %t/vfs/base.yaml > %t/vfs/a-b.yaml
+// 

[PATCH] D121450: [clang-format] Handle attributes before case label.

2022-03-11 Thread Owen Pan via Phabricator via cfe-commits
owenpan accepted this revision.
owenpan added inline comments.



Comment at: clang/lib/Format/UnwrappedLineParser.cpp:578
+break;
+
   LLVM_FALLTHROUGH;

Can we remove this empty line?



Comment at: clang/lib/Format/UnwrappedLineParser.h:125-126
   FormatToken *parseIfThenElse(IfStmtKind *IfKind, bool KeepBraces = false);
+  void handleAttributes();
+  bool handleCppAttributes();
   void parseTryCatch();

Can we move them 1 line up so that the order of the declarations here will be 
the same as that of the definitions in the .cpp file?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D121450

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


[clang] 46626bc - [NFC] Improve comment and rename test file

2022-03-11 Thread Julian Lettner via cfe-commits

Author: Julian Lettner
Date: 2022-03-11T14:47:54-08:00
New Revision: 46626bc87382cad7a0c5ba497b3454337c45faa8

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

LOG: [NFC] Improve comment and rename test file

Added: 
clang/test/Driver/darwin-asan-destructor.c

Modified: 
llvm/include/llvm/ADT/Triple.h

Removed: 
clang/test/Driver/darwin-asan-mkernel-kext.c



diff  --git a/clang/test/Driver/darwin-asan-mkernel-kext.c 
b/clang/test/Driver/darwin-asan-destructor.c
similarity index 100%
rename from clang/test/Driver/darwin-asan-mkernel-kext.c
rename to clang/test/Driver/darwin-asan-destructor.c

diff  --git a/llvm/include/llvm/ADT/Triple.h b/llvm/include/llvm/ADT/Triple.h
index 14b66cbcc2129..a5f74df92209e 100644
--- a/llvm/include/llvm/ADT/Triple.h
+++ b/llvm/include/llvm/ADT/Triple.h
@@ -473,7 +473,7 @@ class Triple {
 
   bool isOSzOS() const { return getOS() == Triple::ZOS; }
 
-  /// Is this a "Darwin" OS (macOS, iOS, tvOS or watchOS).
+  /// Is this a "Darwin" OS (macOS, iOS, tvOS, watchOS, or DriverKit).
   bool isOSDarwin() const {
 return isMacOSX() || isiOS() || isWatchOS() || isDriverKit();
   }



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


[PATCH] D121497: Lex: add support for `{,u}i128` Microsoft extension

2022-03-11 Thread Saleem Abdulrasool via Phabricator via cfe-commits
compnerd created this revision.
compnerd added a reviewer: aaron.ballman.
compnerd added a project: clang.
Herald added a project: All.
compnerd requested review of this revision.
Herald added a subscriber: cfe-commits.

The Windows SDK has occurrences of the `i128` and `ui128` suffix (at
least in the 10.0.22000.0 SDK, see `intsafe.h`).  This adds support for
the extension to properly lex the literal.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D121497

Files:
  clang/include/clang/Lex/LiteralSupport.h
  clang/lib/AST/StmtPrinter.cpp
  clang/lib/Lex/LiteralSupport.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/test/Lexer/ms-extensions.c
  clang/unittests/AST/StmtPrinterTest.cpp

Index: clang/unittests/AST/StmtPrinterTest.cpp
===
--- clang/unittests/AST/StmtPrinterTest.cpp
+++ clang/unittests/AST/StmtPrinterTest.cpp
@@ -44,7 +44,7 @@
   PrintingPolicy Policy = Context->getPrintingPolicy();
   if (PolicyAdjuster)
 PolicyAdjuster(Policy);
-  S->printPretty(Out, /*Helper*/ nullptr, Policy);
+  S->printPretty(Out, /*Helper*/ nullptr, Policy, 0, "\n", Context);
 }
 
 template 
@@ -128,13 +128,15 @@
 "  1i8, -1i8, 1ui8, "
 "  1i16, -1i16, 1ui16, "
 "  1i32, -1i32, 1ui32, "
-"  1i64, -1i64, 1ui64;"
+"  1i64, -1i64, 1ui64, "
+"  1i128, -1i128, 1ui128;"
 "}",
 FunctionBodyMatcher("A"),
 "1i8 , -1i8 , 1Ui8 , "
 "1i16 , -1i16 , 1Ui16 , "
 "1 , -1 , 1U , "
-"1LL , -1LL , 1ULL"));
+"1LL , -1LL , 1ULL , "
+"1i128 , -1i128 , 1ui128"));
 // Should be: with semicolon
 }
 
Index: clang/test/Lexer/ms-extensions.c
===
--- clang/test/Lexer/ms-extensions.c
+++ clang/test/Lexer/ms-extensions.c
@@ -23,6 +23,9 @@
 #define USHORT 0xui16
 #define UCHAR 0xffui8
 
+#define INT128_MAX  170141183460469231731687303715884105727i128
+#define UINT128_MAX 0xui128
+
 void a(void) {
 	unsigned long long m = ULLONG_MAX;
 	unsigned int n = UINT;
Index: clang/lib/Sema/SemaExpr.cpp
===
--- clang/lib/Sema/SemaExpr.cpp
+++ clang/lib/Sema/SemaExpr.cpp
@@ -3924,6 +3924,11 @@
 
 // Get the value in the widest-possible width.
 unsigned MaxWidth = Context.getTargetInfo().getIntMaxTWidth();
+// Microsoft extensions allow a maximal integer greater than `intmax_t` via
+// the `i128` suffix, creating a 128-bit integeral value with a 64-bit
+// maximum integer type.
+if (Literal.MicrosoftInteger)
+  MaxWidth = Literal.MicrosoftInteger;
 llvm::APInt ResultVal(MaxWidth, 0);
 
 if (Literal.GetIntegerValue(ResultVal)) {
Index: clang/lib/Lex/LiteralSupport.cpp
===
--- clang/lib/Lex/LiteralSupport.cpp
+++ clang/lib/Lex/LiteralSupport.cpp
@@ -849,7 +849,7 @@
 case 'i':
 case 'I':
   if (LangOpts.MicrosoftExt && !isFPConstant) {
-// Allow i8, i16, i32, and i64. First, look ahead and check if
+// Allow i8, i16, i32, i64, and i128. First, look ahead and check if
 // suffixes are Microsoft integers and not the imaginary unit.
 uint8_t Bits = 0;
 size_t ToSkip = 0;
@@ -859,7 +859,10 @@
   ToSkip = 2;
   break;
 case '1':
-  if (s[2] == '6') { // i16 suffix
+  if (s[2] == '2' && s[3] == '8') {
+Bits = 128;
+ToSkip = 4;
+  } else if (s[2] == '6') { // i16 suffix
 Bits = 16;
 ToSkip = 3;
   }
Index: clang/lib/AST/StmtPrinter.cpp
===
--- clang/lib/AST/StmtPrinter.cpp
+++ clang/lib/AST/StmtPrinter.cpp
@@ -1168,9 +1168,13 @@
   case BuiltinType::LongLong:  OS << "LL"; break;
   case BuiltinType::ULongLong: OS << "ULL"; break;
   case BuiltinType::Int128:
-break; // no suffix.
+if (Context && Context->getLangOpts().MicrosoftExt)
+  OS << "i128";
+break;
   case BuiltinType::UInt128:
-break; // no suffix.
+if (Context && Context->getLangOpts().MicrosoftExt)
+  OS << "ui128";
+break;
   }
 }
 
Index: clang/include/clang/Lex/LiteralSupport.h
===
--- clang/include/clang/Lex/LiteralSupport.h
+++ clang/include/clang/Lex/LiteralSupport.h
@@ -69,8 +69,8 @@
   bool isImaginary : 1; // 1.0i
   bool isFloat16 : 1;   // 1.0f16
   bool isFloat128 : 1;  // 1.0q
-  uint8_t MicrosoftInteger; // Microsoft suffix extension i8, i16, i32, or i64.
-
+  uint8_t MicrosoftInteger; // Microsoft suffix extension i8, i16, i32, i64, or
+// i128.
   bool isFract : 1; // 1.0hr/r/lr/uhr/ur/ulr
   bool isAccum : 1; // 1.0hk/k/lk/uhk/uk/ulk
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http

[PATCH] D121498: let EST_Uninstantiated in FunctionProtoType::canThrow return CT_Dependent

2022-03-11 Thread zhouyizhou via Phabricator via cfe-commits
zhouyizhou created this revision.
zhouyizhou added reviewers: rsmith, erichkeane, CornedBee.
Herald added a project: All.
zhouyizhou requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

When compile following code without -std=c++17, clang will abort by 
llvm_unreachable:

- code begin ---

template
void foo() noexcept(T::value);

struct S {

  static const bool value;

};

const bool S::value = 0;

template
constexpr bool is_noexcept_function(void(Args...) noexcept(is_noexcept)) {

  return is_noexcept;

}

void fn()
{

  is_noexcept_function(foo);

}

- code end ---

So, my solution is to let EST_Uninstantiated in FunctionProtoType::canThrow 
return CT_Dependent

Thanks
Zhouyi Zhou 


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D121498

Files:
  clang/lib/AST/Type.cpp


Index: clang/lib/AST/Type.cpp
===
--- clang/lib/AST/Type.cpp
+++ clang/lib/AST/Type.cpp
@@ -3320,8 +3320,9 @@
   switch (getExceptionSpecType()) {
   case EST_Unparsed:
   case EST_Unevaluated:
-  case EST_Uninstantiated:
 llvm_unreachable("should not call this with unresolved exception specs");
+  case EST_Uninstantiated:
+return CT_Dependent;
 
   case EST_DynamicNone:
   case EST_BasicNoexcept:


Index: clang/lib/AST/Type.cpp
===
--- clang/lib/AST/Type.cpp
+++ clang/lib/AST/Type.cpp
@@ -3320,8 +3320,9 @@
   switch (getExceptionSpecType()) {
   case EST_Unparsed:
   case EST_Unevaluated:
-  case EST_Uninstantiated:
 llvm_unreachable("should not call this with unresolved exception specs");
+  case EST_Uninstantiated:
+return CT_Dependent;
 
   case EST_DynamicNone:
   case EST_BasicNoexcept:
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D119918: [CMake] Rename TARGET_TRIPLE to LLVM_TARGET_TRIPLE

2022-03-11 Thread Petr Hosek 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 rG0c0f6cfb7b9f: [CMake] Rename TARGET_TRIPLE to 
LLVM_TARGET_TRIPLE (authored by phosek).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D119918

Files:
  bolt/test/Unit/lit.site.cfg.py.in
  bolt/test/lit.site.cfg.py.in
  clang-tools-extra/clangd/test/lit.site.cfg.py.in
  clang-tools-extra/test/Unit/lit.site.cfg.py.in
  clang-tools-extra/test/lit.site.cfg.py.in
  clang/test/Unit/lit.site.cfg.py.in
  clang/test/lit.site.cfg.py.in
  clang/utils/perf-training/lit.site.cfg.in
  clang/utils/perf-training/order-files.lit.site.cfg.in
  compiler-rt/cmake/Modules/AddCompilerRT.cmake
  compiler-rt/cmake/Modules/CompilerRTMockLLVMCMakeConfig.cmake
  compiler-rt/cmake/Modules/CompilerRTUtils.cmake
  compiler-rt/test/fuzzer/lit.site.cfg.py.in
  compiler-rt/unittests/lit.common.unit.configured.in
  cross-project-tests/lit.site.cfg.py.in
  flang/test/NonGtestUnit/lit.site.cfg.py.in
  flang/test/Unit/lit.site.cfg.py.in
  lld/test/Unit/lit.site.cfg.py.in
  lld/test/lit.site.cfg.py.in
  lldb/test/API/lit.site.cfg.py.in
  lldb/test/CMakeLists.txt
  lldb/test/Shell/lit.site.cfg.py.in
  lldb/test/Unit/lit.site.cfg.py.in
  lldb/test/lit.site.cfg.py.in
  llvm/CMakeLists.txt
  llvm/cmake/modules/AddLLVM.cmake
  llvm/cmake/modules/CrossCompile.cmake
  llvm/cmake/modules/LLVMConfig.cmake.in
  llvm/runtimes/CMakeLists.txt
  llvm/test/lit.site.cfg.py.in
  llvm/utils/gn/secondary/clang-tools-extra/clangd/test/BUILD.gn
  llvm/utils/gn/secondary/clang-tools-extra/test/BUILD.gn
  llvm/utils/gn/secondary/clang/test/BUILD.gn
  llvm/utils/gn/secondary/lld/test/BUILD.gn
  llvm/utils/gn/secondary/lldb/test/BUILD.gn
  llvm/utils/gn/secondary/llvm/test/BUILD.gn
  mlir/examples/standalone/test/lit.site.cfg.py.in
  mlir/test/lit.site.cfg.py.in
  polly/test/Unit/lit.site.cfg.in
  polly/test/lit.site.cfg.in

Index: polly/test/lit.site.cfg.in
===
--- polly/test/lit.site.cfg.in
+++ polly/test/lit.site.cfg.in
@@ -6,7 +6,7 @@
 config.llvm_libs_dir = "@LLVM_LIBS_DIR@"
 config.polly_obj_root = "@POLLY_BINARY_DIR@"
 config.polly_lib_dir = "@POLLY_LIB_DIR@"
-config.target_triple = "@TARGET_TRIPLE@"
+config.target_triple = "@LLVM_TARGET_TRIPLE@"
 config.enable_gpgpu_codegen = "@GPU_CODEGEN@"
 config.llvm_polly_link_into_tools = "@LLVM_POLLY_LINK_INTO_TOOLS@"
 config.targets_to_build = "@TARGETS_TO_BUILD@"
@@ -15,7 +15,7 @@
 ## Check the current platform with regex
 import re
 EAT_ERR_ON_X86 = ' '
-if (re.match(r'^x86_64*', '@TARGET_TRIPLE@') == None) :
+if (re.match(r'^x86_64*', '@LLVM_TARGET_TRIPLE@') == None) :
   EAT_ERR_ON_X86 = '|| echo \"error is eaten\"'
 
 for arch in config.targets_to_build.split():
Index: polly/test/Unit/lit.site.cfg.in
===
--- polly/test/Unit/lit.site.cfg.in
+++ polly/test/Unit/lit.site.cfg.in
@@ -11,7 +11,7 @@
 config.polly_lib_dir = "@POLLY_LIB_DIR@"
 config.enable_shared = @ENABLE_SHARED@
 config.shlibdir = "@SHLIBDIR@"
-config.target_triple = "@TARGET_TRIPLE@"
+config.target_triple = "@LLVM_TARGET_TRIPLE@"
 config.enable_gpgpu_codegen = "@GPU_CODEGEN@"
 config.llvm_polly_link_into_tools = "@LLVM_POLLY_LINK_INTO_TOOLS@"
 config.has_unittests = @POLLY_GTEST_AVAIL@
Index: mlir/test/lit.site.cfg.py.in
===
--- mlir/test/lit.site.cfg.py.in
+++ mlir/test/lit.site.cfg.py.in
@@ -3,7 +3,7 @@
 import sys
 
 config.host_triple = "@LLVM_HOST_TRIPLE@"
-config.target_triple = "@TARGET_TRIPLE@"
+config.target_triple = "@LLVM_TARGET_TRIPLE@"
 config.llvm_src_root = "@LLVM_SOURCE_DIR@"
 config.llvm_obj_root = "@LLVM_BINARY_DIR@"
 config.llvm_tools_dir = "@LLVM_TOOLS_DIR@"
Index: mlir/examples/standalone/test/lit.site.cfg.py.in
===
--- mlir/examples/standalone/test/lit.site.cfg.py.in
+++ mlir/examples/standalone/test/lit.site.cfg.py.in
@@ -3,7 +3,7 @@
 import sys
 
 config.host_triple = "@LLVM_HOST_TRIPLE@"
-config.target_triple = "@TARGET_TRIPLE@"
+config.target_triple = "@LLVM_TARGET_TRIPLE@"
 config.llvm_src_root = "@LLVM_SOURCE_DIR@"
 config.llvm_obj_root = "@LLVM_BINARY_DIR@"
 config.llvm_tools_dir = "@LLVM_TOOLS_DIR@"
Index: llvm/utils/gn/secondary/llvm/test/BUILD.gn
===
--- llvm/utils/gn/secondary/llvm/test/BUILD.gn
+++ llvm/utils/gn/secondary/llvm/test/BUILD.gn
@@ -72,7 +72,7 @@
 "LLVM_VERSION_SUFFIX=git",
 "Python3_EXECUTABLE=$python_path",
 "TARGETS_TO_BUILD=$llvm_targets_to_build_string",
-"TARGET_TRIPLE=$llvm_target_triple",
+"LLVM_TARGET_TRIPLE=$llvm_target_triple",
 
 "LLVM_LIBCXX_USED=0",
 
Index: llvm/utils/gn/secondary/lldb/test/BUILD.gn
=

[clang-tools-extra] 0c0f6cf - [CMake] Rename TARGET_TRIPLE to LLVM_TARGET_TRIPLE

2022-03-11 Thread Petr Hosek via cfe-commits

Author: Petr Hosek
Date: 2022-03-11T15:43:01-08:00
New Revision: 0c0f6cfb7b9fab0ee69ef67ed95c194698c9d794

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

LOG: [CMake] Rename TARGET_TRIPLE to LLVM_TARGET_TRIPLE

This clarifies that this is an LLVM specific variable and avoids
potential conflicts with other projects.

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

Added: 


Modified: 
bolt/test/Unit/lit.site.cfg.py.in
bolt/test/lit.site.cfg.py.in
clang-tools-extra/clangd/test/lit.site.cfg.py.in
clang-tools-extra/test/Unit/lit.site.cfg.py.in
clang-tools-extra/test/lit.site.cfg.py.in
clang/test/Unit/lit.site.cfg.py.in
clang/test/lit.site.cfg.py.in
clang/utils/perf-training/lit.site.cfg.in
clang/utils/perf-training/order-files.lit.site.cfg.in
compiler-rt/cmake/Modules/AddCompilerRT.cmake
compiler-rt/cmake/Modules/CompilerRTMockLLVMCMakeConfig.cmake
compiler-rt/cmake/Modules/CompilerRTUtils.cmake
compiler-rt/test/fuzzer/lit.site.cfg.py.in
compiler-rt/unittests/lit.common.unit.configured.in
cross-project-tests/lit.site.cfg.py.in
flang/test/NonGtestUnit/lit.site.cfg.py.in
flang/test/Unit/lit.site.cfg.py.in
lld/test/Unit/lit.site.cfg.py.in
lld/test/lit.site.cfg.py.in
lldb/test/API/lit.site.cfg.py.in
lldb/test/CMakeLists.txt
lldb/test/Shell/lit.site.cfg.py.in
lldb/test/Unit/lit.site.cfg.py.in
lldb/test/lit.site.cfg.py.in
llvm/CMakeLists.txt
llvm/cmake/modules/AddLLVM.cmake
llvm/cmake/modules/CrossCompile.cmake
llvm/cmake/modules/LLVMConfig.cmake.in
llvm/runtimes/CMakeLists.txt
llvm/test/lit.site.cfg.py.in
llvm/utils/gn/secondary/clang-tools-extra/clangd/test/BUILD.gn
llvm/utils/gn/secondary/clang-tools-extra/test/BUILD.gn
llvm/utils/gn/secondary/clang/test/BUILD.gn
llvm/utils/gn/secondary/lld/test/BUILD.gn
llvm/utils/gn/secondary/lldb/test/BUILD.gn
llvm/utils/gn/secondary/llvm/test/BUILD.gn
mlir/examples/standalone/test/lit.site.cfg.py.in
mlir/test/lit.site.cfg.py.in
polly/test/Unit/lit.site.cfg.in
polly/test/lit.site.cfg.in

Removed: 




diff  --git a/bolt/test/Unit/lit.site.cfg.py.in 
b/bolt/test/Unit/lit.site.cfg.py.in
index 92f9c91104766..45a36c58923fb 100644
--- a/bolt/test/Unit/lit.site.cfg.py.in
+++ b/bolt/test/Unit/lit.site.cfg.py.in
@@ -8,7 +8,7 @@ config.llvm_build_mode = "@LLVM_BUILD_MODE@"
 config.lit_tools_dir = "@LLVM_LIT_TOOLS_DIR@"
 config.bolt_obj_root = "@BOLT_BINARY_DIR@"
 config.bolt_src_root = "@BOLT_SOURCE_DIR@"
-config.target_triple = "@TARGET_TRIPLE@"
+config.target_triple = "@LLVM_TARGET_TRIPLE@"
 config.python_executable = "@Python3_EXECUTABLE@"
 
 # Support substitution of the tools and libs dirs with user parameters. This is

diff  --git a/bolt/test/lit.site.cfg.py.in b/bolt/test/lit.site.cfg.py.in
index e2691e3933d96..8c94a5609a9d0 100644
--- a/bolt/test/lit.site.cfg.py.in
+++ b/bolt/test/lit.site.cfg.py.in
@@ -12,7 +12,7 @@ config.llvm_shlib_dir = "@SHLIBDIR@"
 config.llvm_plugin_ext = "@LLVM_PLUGIN_EXT@"
 config.lit_tools_dir = "@LLVM_LIT_TOOLS_DIR@"
 config.host_triple = "@LLVM_HOST_TRIPLE@"
-config.target_triple = "@TARGET_TRIPLE@"
+config.target_triple = "@LLVM_TARGET_TRIPLE@"
 config.llvm_use_sanitizer = "@LLVM_USE_SANITIZER@"
 config.enable_shared = @ENABLE_SHARED@
 config.enable_backtrace = @ENABLE_BACKTRACES@

diff  --git a/clang-tools-extra/clangd/test/lit.site.cfg.py.in 
b/clang-tools-extra/clangd/test/lit.site.cfg.py.in
index 853a3bf24a072..2b294eaa5ae5a 100644
--- a/clang-tools-extra/clangd/test/lit.site.cfg.py.in
+++ b/clang-tools-extra/clangd/test/lit.site.cfg.py.in
@@ -6,7 +6,7 @@ config.clang_tools_dir = "@CLANG_TOOLS_DIR@"
 config.llvm_tools_dir = "@LLVM_TOOLS_DIR@"
 config.clang_libs_dir = "@CLANG_LIBS_DIR@"
 config.llvm_libs_dir = "@LLVM_LIBS_DIR@"
-config.target_triple = "@TARGET_TRIPLE@"
+config.target_triple = "@LLVM_TARGET_TRIPLE@"
 config.host_triple = "@LLVM_HOST_TRIPLE@"
 config.python_executable = "@Python3_EXECUTABLE@"
 

diff  --git a/clang-tools-extra/test/Unit/lit.site.cfg.py.in 
b/clang-tools-extra/test/Unit/lit.site.cfg.py.in
index dc7ee330d13a0..6086f00dfc681 100644
--- a/clang-tools-extra/test/Unit/lit.site.cfg.py.in
+++ b/clang-tools-extra/test/Unit/lit.site.cfg.py.in
@@ -4,6 +4,6 @@ config.extra_tools_obj_dir = 
"@CLANG_TOOLS_BINARY_DIR@/unittests"
 config.extra_tools_src_dir = "@CLANG_TOOLS_SOURCE_DIR@/unittests"
 config.llvm_libs_dir = "@LLVM_LIBS_DIR@"
 config.shlibdir = "@SHLIBDIR@"
-config.target_triple = "@TARGET_TRIPLE@"
+config.target_triple = "@LLVM_TARGET_TRIPLE@"
 
 lit_config.load_config(config, "@CLANG_TOOLS_SOURCE_DIR@/test/Unit/lit.cfg.py")

diff  --git a/clang-tools-extra/test/lit.site.cfg.py.in 
b/clang-tools-extra/test/lit.site.cfg.py.in

[clang] 0c0f6cf - [CMake] Rename TARGET_TRIPLE to LLVM_TARGET_TRIPLE

2022-03-11 Thread Petr Hosek via cfe-commits

Author: Petr Hosek
Date: 2022-03-11T15:43:01-08:00
New Revision: 0c0f6cfb7b9fab0ee69ef67ed95c194698c9d794

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

LOG: [CMake] Rename TARGET_TRIPLE to LLVM_TARGET_TRIPLE

This clarifies that this is an LLVM specific variable and avoids
potential conflicts with other projects.

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

Added: 


Modified: 
bolt/test/Unit/lit.site.cfg.py.in
bolt/test/lit.site.cfg.py.in
clang-tools-extra/clangd/test/lit.site.cfg.py.in
clang-tools-extra/test/Unit/lit.site.cfg.py.in
clang-tools-extra/test/lit.site.cfg.py.in
clang/test/Unit/lit.site.cfg.py.in
clang/test/lit.site.cfg.py.in
clang/utils/perf-training/lit.site.cfg.in
clang/utils/perf-training/order-files.lit.site.cfg.in
compiler-rt/cmake/Modules/AddCompilerRT.cmake
compiler-rt/cmake/Modules/CompilerRTMockLLVMCMakeConfig.cmake
compiler-rt/cmake/Modules/CompilerRTUtils.cmake
compiler-rt/test/fuzzer/lit.site.cfg.py.in
compiler-rt/unittests/lit.common.unit.configured.in
cross-project-tests/lit.site.cfg.py.in
flang/test/NonGtestUnit/lit.site.cfg.py.in
flang/test/Unit/lit.site.cfg.py.in
lld/test/Unit/lit.site.cfg.py.in
lld/test/lit.site.cfg.py.in
lldb/test/API/lit.site.cfg.py.in
lldb/test/CMakeLists.txt
lldb/test/Shell/lit.site.cfg.py.in
lldb/test/Unit/lit.site.cfg.py.in
lldb/test/lit.site.cfg.py.in
llvm/CMakeLists.txt
llvm/cmake/modules/AddLLVM.cmake
llvm/cmake/modules/CrossCompile.cmake
llvm/cmake/modules/LLVMConfig.cmake.in
llvm/runtimes/CMakeLists.txt
llvm/test/lit.site.cfg.py.in
llvm/utils/gn/secondary/clang-tools-extra/clangd/test/BUILD.gn
llvm/utils/gn/secondary/clang-tools-extra/test/BUILD.gn
llvm/utils/gn/secondary/clang/test/BUILD.gn
llvm/utils/gn/secondary/lld/test/BUILD.gn
llvm/utils/gn/secondary/lldb/test/BUILD.gn
llvm/utils/gn/secondary/llvm/test/BUILD.gn
mlir/examples/standalone/test/lit.site.cfg.py.in
mlir/test/lit.site.cfg.py.in
polly/test/Unit/lit.site.cfg.in
polly/test/lit.site.cfg.in

Removed: 




diff  --git a/bolt/test/Unit/lit.site.cfg.py.in 
b/bolt/test/Unit/lit.site.cfg.py.in
index 92f9c91104766..45a36c58923fb 100644
--- a/bolt/test/Unit/lit.site.cfg.py.in
+++ b/bolt/test/Unit/lit.site.cfg.py.in
@@ -8,7 +8,7 @@ config.llvm_build_mode = "@LLVM_BUILD_MODE@"
 config.lit_tools_dir = "@LLVM_LIT_TOOLS_DIR@"
 config.bolt_obj_root = "@BOLT_BINARY_DIR@"
 config.bolt_src_root = "@BOLT_SOURCE_DIR@"
-config.target_triple = "@TARGET_TRIPLE@"
+config.target_triple = "@LLVM_TARGET_TRIPLE@"
 config.python_executable = "@Python3_EXECUTABLE@"
 
 # Support substitution of the tools and libs dirs with user parameters. This is

diff  --git a/bolt/test/lit.site.cfg.py.in b/bolt/test/lit.site.cfg.py.in
index e2691e3933d96..8c94a5609a9d0 100644
--- a/bolt/test/lit.site.cfg.py.in
+++ b/bolt/test/lit.site.cfg.py.in
@@ -12,7 +12,7 @@ config.llvm_shlib_dir = "@SHLIBDIR@"
 config.llvm_plugin_ext = "@LLVM_PLUGIN_EXT@"
 config.lit_tools_dir = "@LLVM_LIT_TOOLS_DIR@"
 config.host_triple = "@LLVM_HOST_TRIPLE@"
-config.target_triple = "@TARGET_TRIPLE@"
+config.target_triple = "@LLVM_TARGET_TRIPLE@"
 config.llvm_use_sanitizer = "@LLVM_USE_SANITIZER@"
 config.enable_shared = @ENABLE_SHARED@
 config.enable_backtrace = @ENABLE_BACKTRACES@

diff  --git a/clang-tools-extra/clangd/test/lit.site.cfg.py.in 
b/clang-tools-extra/clangd/test/lit.site.cfg.py.in
index 853a3bf24a072..2b294eaa5ae5a 100644
--- a/clang-tools-extra/clangd/test/lit.site.cfg.py.in
+++ b/clang-tools-extra/clangd/test/lit.site.cfg.py.in
@@ -6,7 +6,7 @@ config.clang_tools_dir = "@CLANG_TOOLS_DIR@"
 config.llvm_tools_dir = "@LLVM_TOOLS_DIR@"
 config.clang_libs_dir = "@CLANG_LIBS_DIR@"
 config.llvm_libs_dir = "@LLVM_LIBS_DIR@"
-config.target_triple = "@TARGET_TRIPLE@"
+config.target_triple = "@LLVM_TARGET_TRIPLE@"
 config.host_triple = "@LLVM_HOST_TRIPLE@"
 config.python_executable = "@Python3_EXECUTABLE@"
 

diff  --git a/clang-tools-extra/test/Unit/lit.site.cfg.py.in 
b/clang-tools-extra/test/Unit/lit.site.cfg.py.in
index dc7ee330d13a0..6086f00dfc681 100644
--- a/clang-tools-extra/test/Unit/lit.site.cfg.py.in
+++ b/clang-tools-extra/test/Unit/lit.site.cfg.py.in
@@ -4,6 +4,6 @@ config.extra_tools_obj_dir = 
"@CLANG_TOOLS_BINARY_DIR@/unittests"
 config.extra_tools_src_dir = "@CLANG_TOOLS_SOURCE_DIR@/unittests"
 config.llvm_libs_dir = "@LLVM_LIBS_DIR@"
 config.shlibdir = "@SHLIBDIR@"
-config.target_triple = "@TARGET_TRIPLE@"
+config.target_triple = "@LLVM_TARGET_TRIPLE@"
 
 lit_config.load_config(config, "@CLANG_TOOLS_SOURCE_DIR@/test/Unit/lit.cfg.py")

diff  --git a/clang-tools-extra/test/lit.site.cfg.py.in 
b/clang-tools-extra/test/lit.site.cfg.py.in

[PATCH] D37624: add support for -fno-instrument-functions and -finstrument-functions-exclude-{file,function}-list= to match gcc options.

2022-03-11 Thread Aditya Kumar via Phabricator via cfe-commits
hiraditya added a comment.
Herald added a project: All.

Is there a plan to revive this? this is quite necessary for one of my use cases.
can we at least have '-fno-instrument-functions'?


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

https://reviews.llvm.org/D37624

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


  1   2   >