[PATCH] D102090: [CMake][ELF] Link libLLVM.so and libclang-cpp.so with -Bsymbolic-functions

2021-12-06 Thread Evgeniy via Phabricator via cfe-commits
ebrevnov added a comment.

In D102090#3169726 , @rnk wrote:

> In D102090#3169439 , @ebrevnov 
> wrote:
>
>> While -Bsymbolic-funtions brings nice performance improvements it also 
>> changes symbol resolution order. That means we effectively disabled  
>> preemption for functions and all references from inside libLLVM*.so will be 
>> resolved locally.  But references to global data can still be interposed by 
>> external definitions. Do I understand correctly that main argument against 
>> using -Bsymbolic is potential issue with equality comparison of address of 
>> global? Or anything else?
>
> I think it has less to do with the uniqueness of the addresses and more to do 
> with the deduplication of the global storage. If you have an inline C++ 
> global variable present in LLVM's headers (think a static data member of a 
> class template instantiation), things go wrong quickly if there are two 
> copies of this global, one in LLVM, and the other in the user's binary. 
> Updates from one DSO will not be visible in the other.

I don't see what's wrong here (maybe you have specific example). IMHO, quite 
opposite, LLVM will consistently use it's own instance while user's binary it's 
own as if  there were two globals with different names in the first place. I 
have exactly that real life case where LLVM's function (coming from libLLVM*.so 
since functions are not interposed) refers to a global from the user's binary 
with the same name by completely different semantics.

> If you arrange the same situation with functions, they are usually 
> functionally equivalent even if there are minor code differences.

I don't think it is safe to assume that. Maybe in most cases, but not always.

> Generally, users are not trying to preempt LLVM's own function definitions. 
> The typical use cases are to override C library functionality such as malloc. 
> The performance benefit of -Bsymbolic-functions is worth making LLVM's own 
> functions non-interposable.

I don't think this is really relevant to the subject since performance is 
outside of the scope of my question. The question is if -Bsymbolic can protect 
us from unintentional preemption by user defined globals.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D102090

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


[PATCH] D113749: [Clang] Fix nesting of discarded and immediate contexts.

2021-12-06 Thread Paul Hollinsky via Phabricator via cfe-commits
hollinsky added a comment.

This change breaks return value deduction of template instantiations that first 
occur within a discarded context.

  template
  class Foo {
  public:
constexpr Foo(const char str[S]) : buf(str[0]) {}
char get() const { return buf; }
char buf;
  };
  
  template
  static constexpr auto make(const char(&str)[S]) {
return Foo{str};
  }
  
  int main() {
if constexpr(false) {
return make("used to be Foo<29>, now void").get();
}
return 0;
  }

This code now fails to compile with

  regression.cpp:16:46: error: member reference base type 'void' is not a 
structure or union
  return make("used to be Foo<29>, now void").get();
 ^~~~

The only return statement in the `make()` function template is not being 
considered anymore, making the resulting instantiation

  template<>
  static constexpr void make(const char(&str)[29]) {
return Foo<29>{str};
  }

Intuitively, I wouldn't think that the "discarded return statements are not 
considered when deducing a return type" rule should continue into new function 
scopes, though I'm not sure exactly how the spec backs that up.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D113749

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


[PATCH] D70401: [WIP][RISCV] Implement ilp32e ABI

2021-12-06 Thread Zakk Chen via Phabricator via cfe-commits
khchen added a comment.

In D70401#3172457 , @zixuan-wu wrote:

> Hi, all. Why is it not continued?

Sorry, I have to work on other tasks so stop the rv32e implementation work.
Are you interest to finish it? I could share my patches to you.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70401

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


[PATCH] D102669: [analyzer][ctu] Fix wrong 'multiple definitions' errors caused by space characters in lookup names when parsing the ctu index file

2021-12-06 Thread Balázs Benics via Phabricator via cfe-commits
steakhal added inline comments.



Comment at: clang/lib/CrossTU/CrossTranslationUnit.cpp:154-172
+  // Find the length delimiter.
+  const size_t LengthDelimiter = LineRef.find(':');
+  if (StringRef::npos == LengthDelimiter)
+return false;
+
+  // Parse the length of LookupName as USRLength.
+  size_t USRLength = 0;

OikawaKirie wrote:
> steakhal wrote:
> > 
> The source of lookup name of the function being imported is function 
> `CrossTranslationUnitContext::getLookupName`. Keeping the length in the 
> mapping can avoid parsing the lookup name during importing.
Okay; you can copy the original StringRef to have that. But by consuming it on 
one path makes the code much more readable.




Comment at: clang/lib/CrossTU/CrossTranslationUnit.cpp:183
+/// Check whether the input lookup name is in format ":" by
+/// appending a space charactor and parse with parseCrossTUIndexItem.
+bool isCTUIndexKeyValid(StringRef N) {

charactor  -> character



Comment at: clang/lib/CrossTU/CrossTranslationUnit.cpp:184-188
+bool isCTUIndexKeyValid(StringRef N) {
+  std::string FN = N.str() + ' ';
+  StringRef LN, FP;
+  return parseCrossTUIndexItem(FN, LN, FP) && N == LN && FP.empty();
+}

You should probably use more elaborative names, I wouldn't know what this does 
if I hadn't reviewed this patch.



Comment at: clang/lib/CrossTU/CrossTranslationUnit.cpp:463
 bool DisplayCTUProgress) {
+  // Make sure the input lookup name is in format ":".
+  assert(isCTUIndexKeyValid(FunctionName) &&

The assertion speaks for itself. It rarely needs additional documentation.



Comment at: clang/test/Analysis/Inputs/ctu-lookup-name-with-space.cpp:7-8
+// CHECK-NOT: multiple definitions are found for the same key in index
+f([](char) -> int { return 42; });
+f([](char) -> bool { return true; });
+  }

I would rather put these into the `importee()`



Comment at: clang/test/Analysis/Inputs/ctu-lookup-name-with-space.cpp:13
+int importee(int X) {
+  return 1 / X;
+}

Why do you need to have a div by zero warning?


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

https://reviews.llvm.org/D102669

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


[PATCH] D102090: [CMake][ELF] Link libLLVM.so and libclang-cpp.so with -Bsymbolic-functions

2021-12-06 Thread Evgeniy via Phabricator via cfe-commits
ebrevnov added a comment.

In D102090#3172538 , @MaskRay wrote:

> To add on rnk's comment (deduplication of vague linkage data which may be 
> included in multiple shared objects), another big reason is -Bsymbolic data 
> does not work with copy relocations. -fno-pic programs generally cannot avoid 
> copy relocations (except mips; mips did this thing correctly).

Do you (by "doesn't work") mean if executable refers to a global defined in 
LLVM.*so then each of them will use their own copy?

> GCC 5 x86-64 has a regression 
>  that -fpie code can have 
> copy relocations, too.

Looks like the bug itself is still opened. I guess you meant to refer to the 
the following change:  After "x86-64: Optimize access to globals in PIE with 
copy reloc", GCC x86-64 asks the assembler to produce an R_X86_64_PC32 for an 
external data access." Looks like intended change ... why do you call it a 
regression?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D102090

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


[PATCH] D115050: [clang-format] PR48916 PointerAlignment not working when using C++20 init-statement in for loop

2021-12-06 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay updated this revision to Diff 391990.
MyDeveloperDay added a comment.

This fix has to go super specific to range for loops or we start manipulating 
pointer alignment all over the place in places perhaps we don't want to


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

https://reviews.llvm.org/D115050

Files:
  clang/lib/Format/FormatToken.cpp
  clang/lib/Format/FormatToken.h
  clang/lib/Format/TokenAnnotator.cpp


Index: clang/lib/Format/TokenAnnotator.cpp
===
--- clang/lib/Format/TokenAnnotator.cpp
+++ clang/lib/Format/TokenAnnotator.cpp
@@ -3024,8 +3024,14 @@
  Style.SpaceAroundPointerQualifiers == FormatStyle::SAPQ_Both) &&
 (Left.is(TT_AttributeParen) || 
Left.canBePointerOrReferenceQualifier()))
   return true;
+if (Left.Tok.isLiteral())
+  return true;
+// for (auto a = 0, b = 0; const auto & c : {1, 2, 3})
+if (Left.isTypeOrIdentifier() && Right.Next && Right.Next->Next &&
+Right.Next->Next->is(TT_RangeBasedForLoopColon))
+  return getTokenPointerOrReferenceAlignment(Right) !=
+ FormatStyle::PAS_Left;
 return (
-Left.Tok.isLiteral() ||
 (!Left.isOneOf(TT_PointerOrReference, tok::l_paren) &&
  (getTokenPointerOrReferenceAlignment(Right) != FormatStyle::PAS_Left 
||
   (Line.IsMultiVariableDeclStmt &&
@@ -3044,18 +3050,31 @@
  Style.SpaceAroundPointerQualifiers == FormatStyle::SAPQ_Both) &&
 Right.canBePointerOrReferenceQualifier())
   return true;
-return Right.Tok.isLiteral() || Right.is(TT_BlockComment) ||
-   (Right.isOneOf(Keywords.kw_override, Keywords.kw_final) &&
-!Right.is(TT_StartOfName)) ||
-   (Right.is(tok::l_brace) && Right.is(BK_Block)) ||
-   (!Right.isOneOf(TT_PointerOrReference, TT_ArraySubscriptLSquare,
-   tok::l_paren) &&
-(getTokenPointerOrReferenceAlignment(Left) !=
- FormatStyle::PAS_Right &&
- !Line.IsMultiVariableDeclStmt) &&
-Left.Previous &&
-!Left.Previous->isOneOf(tok::l_paren, tok::coloncolon,
-tok::l_square));
+// & 1
+if (Right.Tok.isLiteral())
+  return true;
+// & // comment
+if (Right.is(TT_BlockComment))
+  return true;
+// foo() -> const Bar * override/final
+if (Right.isOneOf(Keywords.kw_override, Keywords.kw_final) &&
+!Right.is(TT_StartOfName))
+  return true;
+// & {
+if (Right.is(tok::l_brace) && Right.is(BK_Block))
+  return true;
+// for (auto a = 0, b = 0; const auto& c : {1, 2, 3})
+if (Left.Previous && Left.Previous->isTypeOrIdentifier() && Right.Next &&
+Right.Next->is(TT_RangeBasedForLoopColon))
+  return getTokenPointerOrReferenceAlignment(Left) !=
+ FormatStyle::PAS_Right;
+return (
+!Right.isOneOf(TT_PointerOrReference, TT_ArraySubscriptLSquare,
+   tok::l_paren) &&
+(getTokenPointerOrReferenceAlignment(Left) != FormatStyle::PAS_Right &&
+ !Line.IsMultiVariableDeclStmt) &&
+Left.Previous &&
+!Left.Previous->isOneOf(tok::l_paren, tok::coloncolon, tok::l_square));
   }
   // Ensure right pointer alignment with ellipsis e.g. int *...P
   if (Left.is(tok::ellipsis) && Left.Previous &&
Index: clang/lib/Format/FormatToken.h
===
--- clang/lib/Format/FormatToken.h
+++ clang/lib/Format/FormatToken.h
@@ -521,7 +521,9 @@
   }
 
   /// Determine whether the token is a simple-type-specifier.
-  bool isSimpleTypeSpecifier() const;
+  LLVM_NODISCARD bool isSimpleTypeSpecifier() const;
+
+  LLVM_NODISCARD bool isTypeOrIdentifier() const;
 
   bool isObjCAccessSpecifier() const {
 return is(tok::at) && Next &&
Index: clang/lib/Format/FormatToken.cpp
===
--- clang/lib/Format/FormatToken.cpp
+++ clang/lib/Format/FormatToken.cpp
@@ -70,6 +70,10 @@
   }
 }
 
+bool FormatToken::isTypeOrIdentifier() const {
+  return isSimpleTypeSpecifier() || Tok.isOneOf(tok::kw_auto, tok::identifier);
+}
+
 TokenRole::~TokenRole() {}
 
 void TokenRole::precomputeFormattingInfos(const FormatToken *Token) {}


Index: clang/lib/Format/TokenAnnotator.cpp
===
--- clang/lib/Format/TokenAnnotator.cpp
+++ clang/lib/Format/TokenAnnotator.cpp
@@ -3024,8 +3024,14 @@
  Style.SpaceAroundPointerQualifiers == FormatStyle::SAPQ_Both) &&
 (Left.is(TT_AttributeParen) || Left.canBePointerOrReferenceQualifier()))
   return true;
+if (Left.Tok.isLiteral())
+  return true;
+// for (auto a = 0, b = 0; const auto & c : {1, 2, 3})
+if (Left.isTypeOrIdentifier() && Right.Next && Right.Next->Next &&
+Right.Next->Next->is(TT_RangeBasedForLoopColon))
+ 

[PATCH] D114510: [analyzer] Ignore flex generated files

2021-12-06 Thread Balázs Benics via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG9873ef409c4a: [analyzer] Ignore flex generated files 
(authored by steakhal).
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D114510

Files:
  clang/include/clang/StaticAnalyzer/Core/AnalyzerOptions.def
  clang/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp
  clang/test/Analysis/analyzer-config.c
  clang/test/Analysis/flexignore.c
  clang/test/Analysis/yaccignore.c

Index: clang/test/Analysis/yaccignore.c
===
--- clang/test/Analysis/yaccignore.c
+++ clang/test/Analysis/yaccignore.c
@@ -1,13 +1,14 @@
-/* A Bison parser, made by GNU Bison 1.875.  */
-
-// RUN: rm -rf %t.plist
-// RUN: %clang_analyze_cc1 -analyzer-checker=core -analyzer-output=plist -o %t.plist -verify %s
-// RUN: FileCheck --input-file=%t.plist %s
+// RUN: %clang_analyze_cc1 -analyzer-checker=core,debug.ExprInspection -verify -DEXPECT_NO_DIAGNOSTICS %s
+// RUN: %clang_analyze_cc1 -analyzer-checker=core,debug.ExprInspection -verify=conditional %s \
+// RUN:-analyzer-config ignore-bison-generated-files=false
 
+#ifdef EXPECT_NO_DIAGNOSTICS
 // expected-no-diagnostics
-int foo() {
-  int *x = 0;
-  return *x; // no-warning
-}
+#endif
 
-// CHECK:   diagnostics
+/* A Bison parser, made by GNU Bison 1.875.  */
+
+void clang_analyzer_warnIfReached();
+void foo() {
+  clang_analyzer_warnIfReached(); // conditional-warning {{REACHABLE}}
+}
Index: clang/test/Analysis/flexignore.c
===
--- /dev/null
+++ clang/test/Analysis/flexignore.c
@@ -0,0 +1,14 @@
+// RUN: %clang_analyze_cc1 -analyzer-checker=core,debug.ExprInspection -verify -DEXPECT_NO_DIAGNOSTICS %s
+// RUN: %clang_analyze_cc1 -analyzer-checker=core,debug.ExprInspection -verify=conditional %s \
+// RUN:-analyzer-config ignore-flex-generated-files=false
+
+#ifdef EXPECT_NO_DIAGNOSTICS
+// expected-no-diagnostics
+#endif
+
+/* A lexical scanner generated by flex */
+
+void clang_analyzer_warnIfReached();
+void foo() {
+  clang_analyzer_warnIfReached(); // conditional-warning {{REACHABLE}}
+}
Index: clang/test/Analysis/analyzer-config.c
===
--- clang/test/Analysis/analyzer-config.c
+++ clang/test/Analysis/analyzer-config.c
@@ -83,6 +83,8 @@
 // CHECK-NEXT: exploration_strategy = unexplored_first_queue
 // CHECK-NEXT: faux-bodies = true
 // CHECK-NEXT: graph-trim-interval = 1000
+// CHECK-NEXT: ignore-bison-generated-files = true
+// CHECK-NEXT: ignore-flex-generated-files = true
 // CHECK-NEXT: inline-lambdas = true
 // CHECK-NEXT: ipa = dynamic-bifurcate
 // CHECK-NEXT: ipa-always-inline-size = 3
Index: clang/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp
===
--- clang/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp
+++ clang/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp
@@ -35,6 +35,7 @@
 #include "clang/StaticAnalyzer/Core/PathSensitive/AnalysisManager.h"
 #include "clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h"
 #include "llvm/ADT/PostOrderIterator.h"
+#include "llvm/ADT/ScopeExit.h"
 #include "llvm/ADT/Statistic.h"
 #include "llvm/Support/FileSystem.h"
 #include "llvm/Support/Path.h"
@@ -493,13 +494,11 @@
   }
 }
 
-static bool isBisonFile(ASTContext &C) {
+static bool fileContainsString(StringRef Substring, ASTContext &C) {
   const SourceManager &SM = C.getSourceManager();
   FileID FID = SM.getMainFileID();
   StringRef Buffer = SM.getBufferOrFake(FID).getBuffer();
-  if (Buffer.startswith("/* A Bison parser, made by"))
-return true;
-  return false;
+  return Buffer.contains(Substring);
 }
 
 void AnalysisConsumer::runAnalysisOnTranslationUnit(ASTContext &C) {
@@ -546,38 +545,48 @@
 }
 
 void AnalysisConsumer::HandleTranslationUnit(ASTContext &C) {
-
   // Don't run the actions if an error has occurred with parsing the file.
   DiagnosticsEngine &Diags = PP.getDiagnostics();
   if (Diags.hasErrorOccurred() || Diags.hasFatalErrorOccurred())
 return;
 
-  if (isBisonFile(C)) {
+  // Explicitly destroy the PathDiagnosticConsumer.  This will flush its output.
+  // FIXME: This should be replaced with something that doesn't rely on
+  // side-effects in PathDiagnosticConsumer's destructor. This is required when
+  // used with option -disable-free.
+  const auto DiagFlusherScopeExit =
+  llvm::make_scope_exit([this] { Mgr.reset(); });
+
+  if (Opts->ShouldIgnoreBisonGeneratedFiles &&
+  fileContainsString("/* A Bison parser, made by", C)) {
 reportAnalyzerProgress("Skipping bison-generated file\n");
-  } else if (Opts->DisableAllCheckers) {
+return;
+  }
 
-// Don't analyze if the user explicitly asked for no checks to be performed
-// on this 

[clang] 9873ef4 - [analyzer] Ignore flex generated files

2021-12-06 Thread Balazs Benics via cfe-commits

Author: Balazs Benics
Date: 2021-12-06T10:20:17+01:00
New Revision: 9873ef409c4a937c566e20e7a88af049d212ce03

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

LOG: [analyzer] Ignore flex generated files

Some projects [1,2,3] have flex-generated files besides bison-generated
ones.
Unfortunately, the comment `"/* A lexical scanner generated by flex */"`
generated by the tools is not necessarily at the beginning of the file,
thus we need to quickly skim through the file for this needle string.

Luckily, StringRef can do this operation in an efficient way.

That being said, now the bison comment is not required to be at the very
beginning of the file. This allows us to detect a couple more cases
[4,5,6].

Alternatively, we could say that we only allow whitespace characters
before matching the bison/flex header comment. That would prevent the
(probably) unnecessary string search in the buffer. However, I could not
verify that these tools would actually respect this assumption.

Additionally to this, e.g. the Twin project [1] has other non-whitespace
characters (some preprocessor directives) before the flex-generated
header comment. So the heuristic in the previous paragraph won't work
with that.
Thus, I would advocate the current implementation.

According to my measurement, this patch won't introduce measurable
performance degradation, even though we will do 2 linear scans.

I introduce the ignore-bison-generated-files and
ignore-flex-generated-files to disable skipping these files.
Both of these options are true by default.

[1]: https://github.com/cosmos72/twin/blob/master/server/rcparse_lex.cpp#L7
[2]: 
https://github.com/marcauresoar/make-examples/blob/22362cdcf9dd7c597b5049ce7f176621e2e9ac7a/sandbox/count-words/lexer.c#L6
[3]: 
https://github.com/vladcmanea/2nd-faculty-year-Formal-Languages---Automata-assignments/blob/11abdf64629d9eb741438ba69f04636769d5a374/lab1/lex.yy.c#L6

[4]: 
https://github.com/KritikaChoudhary/System-Software-Lab/blob/47f5b2cfe2a2738fd54eae9f8439817f6a22034e/B_yacc/1/y1.tab.h#L2
[5]: 
https://github.com/VirtualMonitor/VirtualMonitor/blob/71d1bf9b1e7b392a7bd0c73dc217138dc5865651/src/VBox/Additions/x11/x11include/xorg-server-1.8.0/parser.h#L2
[6]: 
https://github.com/bspaulding/DrawTest/blob/3f773ceb13de14275429036b9cbc5aa19e29bab9/Framework/OpenEars.framework/Versions/A/Headers/jsgf_parser.h#L2

Reviewed By: xazax.hun

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

Added: 
clang/test/Analysis/flexignore.c

Modified: 
clang/include/clang/StaticAnalyzer/Core/AnalyzerOptions.def
clang/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp
clang/test/Analysis/analyzer-config.c
clang/test/Analysis/yaccignore.c

Removed: 




diff  --git a/clang/include/clang/StaticAnalyzer/Core/AnalyzerOptions.def 
b/clang/include/clang/StaticAnalyzer/Core/AnalyzerOptions.def
index aab8e1284bf6..c0cade46d614 100644
--- a/clang/include/clang/StaticAnalyzer/Core/AnalyzerOptions.def
+++ b/clang/include/clang/StaticAnalyzer/Core/AnalyzerOptions.def
@@ -336,6 +336,18 @@ ANALYZER_OPTION(
 "might be modeled by the analyzer to never return NULL.",
 false)
 
+ANALYZER_OPTION(
+bool, ShouldIgnoreBisonGeneratedFiles, "ignore-bison-generated-files",
+"If enabled, any files containing the \"/* A Bison parser, made by\" "
+"won't be analyzed.",
+true)
+
+ANALYZER_OPTION(
+bool, ShouldIgnoreFlexGeneratedFiles, "ignore-flex-generated-files",
+"If enabled, any files containing the \"/* A lexical scanner generated by "
+"flex\" won't be analyzed.",
+true)
+
 
//===--===//
 // Unsigned analyzer options.
 
//===--===//

diff  --git a/clang/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp 
b/clang/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp
index f692c68045ee..f6ddcb763f9d 100644
--- a/clang/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp
+++ b/clang/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp
@@ -35,6 +35,7 @@
 #include "clang/StaticAnalyzer/Core/PathSensitive/AnalysisManager.h"
 #include "clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h"
 #include "llvm/ADT/PostOrderIterator.h"
+#include "llvm/ADT/ScopeExit.h"
 #include "llvm/ADT/Statistic.h"
 #include "llvm/Support/FileSystem.h"
 #include "llvm/Support/Path.h"
@@ -493,13 +494,11 @@ void AnalysisConsumer::HandleDeclsCallGraph(const 
unsigned LocalTUDeclsSize) {
   }
 }
 
-static bool isBisonFile(ASTContext &C) {
+static bool fileContainsString(StringRef Substring, ASTContext &C) {
   const SourceManager &SM = C.getSourceManager();
   FileID FID = SM.getMainFileID();
   StringRef Buffer = SM.getBufferOrFake(FID).getBuffer();
-  if (Buffer.st

[PATCH] D115050: [clang-format] PR48916 PointerAlignment not working when using C++20 init-statement in for loop

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

You have reverted some of your changes. Including all the tests.


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

https://reviews.llvm.org/D115050

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


[PATCH] D115050: [clang-format] PR48916 PointerAlignment not working when using C++20 init-statement in for loop

2021-12-06 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay updated this revision to Diff 391993.
MyDeveloperDay marked an inline comment as done.
MyDeveloperDay added a comment.

Fix the merge and add the tests back (which missed the patch)


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

https://reviews.llvm.org/D115050

Files:
  clang/lib/Format/FormatToken.cpp
  clang/lib/Format/FormatToken.h
  clang/lib/Format/TokenAnnotator.cpp
  clang/unittests/Format/FormatTest.cpp

Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -1924,6 +1924,10 @@
   verifyFormat("int *a = f1();", Style);
   verifyFormat("int &b = f2();", Style);
   verifyFormat("int &&c = f3();", Style);
+  verifyFormat("for (auto a = 0, b = 0; const auto &c : {1, 2, 3})", Style);
+  verifyFormat("for (auto a = 0, b = 0; const int &c : {1, 2, 3})", Style);
+  verifyFormat("for (auto a = 0, b = 0; const Foo &c : {1, 2, 3})", Style);
+  verifyFormat("for (auto a = 0, b = 0; const Foo *c : {1, 2, 3})", Style);
 
   Style.AlignConsecutiveDeclarations = FormatStyle::ACS_Consecutive;
   verifyFormat("Const unsigned int *c;\n"
@@ -1943,6 +1947,10 @@
   verifyFormat("int* a = f1();", Style);
   verifyFormat("int& b = f2();", Style);
   verifyFormat("int&& c = f3();", Style);
+  verifyFormat("for (auto a = 0, b = 0; const auto& c : {1, 2, 3})", Style);
+  verifyFormat("for (auto a = 0, b = 0; const int& c : {1, 2, 3})", Style);
+  verifyFormat("for (auto a = 0, b = 0; const Foo& c : {1, 2, 3})", Style);
+  verifyFormat("for (auto a = 0, b = 0; const Foo* c : {1, 2, 3})", Style);
 
   Style.AlignConsecutiveDeclarations = FormatStyle::ACS_Consecutive;
   verifyFormat("Const unsigned int* c;\n"
@@ -1961,6 +1969,7 @@
   verifyFormat("int *a = f1();", Style);
   verifyFormat("int& b = f2();", Style);
   verifyFormat("int&& c = f3();", Style);
+  verifyFormat("for (auto a = 0, b = 0; const Foo *c : {1, 2, 3})", Style);
 
   Style.AlignConsecutiveDeclarations = FormatStyle::ACS_Consecutive;
   verifyFormat("Const unsigned int *c;\n"
@@ -1979,6 +1988,10 @@
   verifyFormat("int* a = f1();", Style);
   verifyFormat("int & b = f2();", Style);
   verifyFormat("int && c = f3();", Style);
+  verifyFormat("for (auto a = 0, b = 0; const auto & c : {1, 2, 3})", Style);
+  verifyFormat("for (auto a = 0, b = 0; const int & c : {1, 2, 3})", Style);
+  verifyFormat("for (auto a = 0, b = 0; const Foo & c : {1, 2, 3})", Style);
+  verifyFormat("for (auto a = 0, b = 0; const Foo* c : {1, 2, 3})", Style);
 
   Style.AlignConsecutiveDeclarations = FormatStyle::ACS_Consecutive;
   verifyFormat("Const unsigned int*  c;\n"
@@ -1997,6 +2010,7 @@
   verifyFormat("int * a = f1();", Style);
   verifyFormat("int &b = f2();", Style);
   verifyFormat("int &&c = f3();", Style);
+  verifyFormat("for (auto a = 0, b = 0; const Foo * c : {1, 2, 3})", Style);
 
   // FIXME: we don't handle this yet, so output may be arbitrary until it's
   // specifically handled
Index: clang/lib/Format/TokenAnnotator.cpp
===
--- clang/lib/Format/TokenAnnotator.cpp
+++ clang/lib/Format/TokenAnnotator.cpp
@@ -3024,8 +3024,14 @@
  Style.SpaceAroundPointerQualifiers == FormatStyle::SAPQ_Both) &&
 (Left.is(TT_AttributeParen) || Left.canBePointerOrReferenceQualifier()))
   return true;
+if (Left.Tok.isLiteral())
+  return true;
+// for (auto a = 0, b = 0; const auto & c : {1, 2, 3})
+if (Left.isTypeOrIdentifier() && Right.Next && Right.Next->Next &&
+Right.Next->Next->is(TT_RangeBasedForLoopColon))
+  return getTokenPointerOrReferenceAlignment(Right) !=
+ FormatStyle::PAS_Left;
 return (
-Left.Tok.isLiteral() ||
 (!Left.isOneOf(TT_PointerOrReference, tok::l_paren) &&
  (getTokenPointerOrReferenceAlignment(Right) != FormatStyle::PAS_Left ||
   (Line.IsMultiVariableDeclStmt &&
@@ -3044,18 +3050,32 @@
  Style.SpaceAroundPointerQualifiers == FormatStyle::SAPQ_Both) &&
 Right.canBePointerOrReferenceQualifier())
   return true;
-return Right.Tok.isLiteral() || Right.is(TT_BlockComment) ||
-   (Right.isOneOf(Keywords.kw_override, Keywords.kw_final) &&
-!Right.is(TT_StartOfName)) ||
-   (Right.is(tok::l_brace) && Right.is(BK_Block)) ||
-   (!Right.isOneOf(TT_PointerOrReference, TT_ArraySubscriptLSquare,
-   tok::l_paren) &&
-(getTokenPointerOrReferenceAlignment(Left) !=
- FormatStyle::PAS_Right &&
- !Line.IsMultiVariableDeclStmt) &&
-Left.Previous &&
-!Left.Previous->isOneOf(tok::l_paren, tok::coloncolon,
-tok::l_square));
+// & 1
+if (Right.Tok.isLiteral())
+  return true;
+// & /* comment
+if (Right.is(TT_BlockComment))
+  return true;
+

[PATCH] D115050: [clang-format] PR48916 PointerAlignment not working when using C++20 init-statement in for loop

2021-12-06 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay added a comment.

In D115050#3172842 , 
@HazardyKnusperkeks wrote:

> You have reverted some of your changes. Including all the tests.

Yes oops!


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

https://reviews.llvm.org/D115050

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


[PATCH] D115064: [clang-format][NFC] Replace deque with vector

2021-12-06 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay added a comment.

Even if you choose a number, beyond that number it behaves like a vector (just 
without the data being on the stack), its really good for small vectors but its 
not bad for large ones. I'm not sure what the default N is if you don't specify 
a number? (0?)


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

https://reviews.llvm.org/D115064

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


[PATCH] D115064: [clang-format][NFC] Replace deque with vector

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

In D115064#3172860 , @MyDeveloperDay 
wrote:

> Even if you choose a number, beyond that number it behaves like a vector 
> (just without the data being on the stack), its really good for small vectors 
> but its not bad for large ones. I'm not sure what the default N is if you 
> don't specify a number? (0?)

Yeah I know what this is. On the link ownpan provided it says it chooses a good 
number for the stack.

My initial take on it was since I don't know how many states we mostly have, I 
don't try to guess and waste space on the stack if there is a chance we always 
go to the heap anyway.


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

https://reviews.llvm.org/D115064

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


[PATCH] D114418: [clang][ASTImporter] Update lookup table correctly at deduction guides.

2021-12-06 Thread Gabor Marton via Phabricator via cfe-commits
martong accepted this revision.
martong added a comment.
This revision is now accepted and ready to land.

LGTM! Thanks for the update!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D114418

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


[PATCH] D115103: Leak Sanitizer port to Windows

2021-12-06 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay added inline comments.



Comment at: compiler-rt/lib/lsan/lsan.h:20
+#elif SANITIZER_WINDOWS
+#  include "lsan_win.h"
 #endif

clang-format?



Comment at: compiler-rt/lib/lsan/lsan_common.h:48
+#elif SANITIZER_NETBSD || SANITIZER_FUCHSIA || SANITIZER_WINDOWS
+#  define CAN_SANITIZE_LEAKS 1
 #else

you probably don't want to change this do you?


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

https://reviews.llvm.org/D115103

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


[PATCH] D115103: Leak Sanitizer port to Windows

2021-12-06 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay added a comment.

You need to add some reviewers to this revision. check out the CODE_OWNERS.txt 
or what I sometimes do is to `git log` one of the files you are changing and 
see who is a major contributor.


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

https://reviews.llvm.org/D115103

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


[PATCH] D113294: [IR] Remove unbounded as possible value for vscale_range minimum

2021-12-06 Thread Cullen Rhodes via Phabricator via cfe-commits
c-rhodes added inline comments.



Comment at: clang/lib/Basic/Targets/AArch64.cpp:476-484
+  assert(LangOpts.VScaleMin && "vscale min must be greater than 0!");
+
+  if (LangOpts.VScaleMax)
 return std::pair(LangOpts.VScaleMin,
  LangOpts.VScaleMax);
+
   if (hasFeature("sve"))

paulwalker-arm wrote:
> c-rhodes wrote:
> > paulwalker-arm wrote:
> > > This looks like a change of behaviour to me.  Previously the command line 
> > > flags would override the "sve" default but now that only happens when the 
> > > user specifies a maximum value.  That means the interface can no longer 
> > > be used to force truly width agnostic values.
> > > This looks like a change of behaviour to me.  Previously the command line 
> > > flags would override the "sve" default but now that only happens when the 
> > > user specifies a maximum value.  That means the interface can no longer 
> > > be used to force truly width agnostic values.
> > 
> > I think the issue here is the default of 1 for min would always trigger `if 
> > (LangOpts.VScaleMin || LangOpts.VScaleMax)` overriding the SVE default. 
> > Perhaps the default can be removed from the driver option and handled here, 
> > i.e.
> > 
> > ```
> > if (LangOpts.VScaleMin || LangOpts.VScaleMax)
> > return std::pair(LangOpts.VScaleMin ? 
> > LangOpts.VScaleMin : 1,
> >  LangOpts.VScaleMax);
> > ```
> > 
> > 
> Is this enough?  I'm not sure it'll work because `LangOpts.VScaleMin` 
> defaults to 1 and thus you'll always end up passing the first check, unless 
> the user specifically uses `-mvscale-min=0` which they cannot because that'll 
> result in `diag::err_cc1_unbounded_vscale_min`.
> 
> Do we need to link the LangOpt defaults to the attribute defaults?  I'm think 
> that having the LangOpts default to zero is a good way to represent "value is 
> unspecified" with regards to the `LangOpts.VScaleMin`.
> Is this enough?  I'm not sure it'll work because `LangOpts.VScaleMin` 
> defaults to 1 and thus you'll always end up passing the first check, unless 
> the user specifically uses `-mvscale-min=0` which they cannot because that'll 
> result in `diag::err_cc1_unbounded_vscale_min`.

It works, I removed the default from the driver option:

```diff --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index 3b85b15739d4..3ec90d42d6ab 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -3338,7 +3338,7 @@ def msve_vector_bits_EQ : Joined<["-"], 
"msve-vector-bits=">, Group,
-  MarshallingInfoInt, "1">;
+  MarshallingInfoInt>;```

and updated `clang/test/CodeGen/arm-sve-vector-bits-vscale-range.c`.

> Do we need to link the LangOpt defaults to the attribute defaults?  I'm think 
> that having the LangOpts default to zero is a good way to represent "value is 
> unspecified" with regards to the `LangOpts.VScaleMin`.

I'm not sure the LangOpt.VScaleMin default is having any affect, if it were the 
last CHECK-NONE test in `clang/test/CodeGen/arm-sve-vector-bits-vscale-range.c` 
wouldn't pass. I'll revert it back to zero anyway.


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

https://reviews.llvm.org/D113294

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


[PATCH] D114124: [clang][ARM] only check -mtp=cp15 for non-asm sources

2021-12-06 Thread Peter Smith via Phabricator via cfe-commits
peter.smith added a comment.

LGTM too.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D114124

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


[PATCH] D115045: [Clang] Ignore CLANG_DEFAULT_LINKER for custom-linker toolchains

2021-12-06 Thread Simon Moll via Phabricator via cfe-commits
simoll updated this revision to Diff 391998.
simoll marked an inline comment as done.
simoll added a comment.

Simplified empty-string check as suggested


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D115045

Files:
  clang/include/clang/Driver/ToolChain.h
  clang/lib/Driver/ToolChain.cpp
  clang/test/Driver/ve-toolchain.c
  clang/test/Driver/ve-toolchain.cpp


Index: clang/test/Driver/ve-toolchain.cpp
===
--- clang/test/Driver/ve-toolchain.cpp
+++ clang/test/Driver/ve-toolchain.cpp
@@ -92,10 +92,10 @@
 /// Checking -fintegrated-as
 
 // RUN: %clangxx -### -target ve \
-// RUN:-x assembler -fuse-ld=ld %s 2>&1 | \
+// RUN:-x assembler %s 2>&1 | \
 // RUN:FileCheck -check-prefix=AS %s
 // RUN: %clangxx -### -target ve \
-// RUN:-fno-integrated-as -x assembler -fuse-ld=ld %s 2>&1 | \
+// RUN:-fno-integrated-as -x assembler %s 2>&1 | \
 // RUN:FileCheck -check-prefix=NAS %s
 
 // AS: clang{{.*}} "-cc1as"
@@ -113,7 +113,6 @@
 
 // RUN: %clangxx -### -target ve-unknown-linux-gnu \
 // RUN: --sysroot %S/Inputs/basic_ve_tree \
-// RUN: -fuse-ld=ld \
 // RUN: -resource-dir=%S/Inputs/basic_ve_tree/resource_dir \
 // RUN: --stdlib=c++ %s 2>&1 | FileCheck -check-prefix=DEF %s
 
Index: clang/test/Driver/ve-toolchain.c
===
--- clang/test/Driver/ve-toolchain.c
+++ clang/test/Driver/ve-toolchain.c
@@ -61,10 +61,10 @@
 /// Checking -fintegrated-as
 
 // RUN: %clang -### -target ve \
-// RUN:-x assembler -fuse-ld=ld %s 2>&1 | \
+// RUN:-x assembler %s 2>&1 | \
 // RUN:FileCheck -check-prefix=AS %s
 // RUN: %clang -### -target ve \
-// RUN:-fno-integrated-as -fuse-ld=ld -x assembler %s 2>&1 | \
+// RUN:-fno-integrated-as -x assembler %s 2>&1 | \
 // RUN:FileCheck -check-prefix=NAS %s
 
 // AS: clang{{.*}} "-cc1as"
@@ -83,7 +83,6 @@
 // RUN: %clang -### -target ve-unknown-linux-gnu \
 // RUN: --sysroot %S/Inputs/basic_ve_tree \
 // RUN: -resource-dir=%S/Inputs/basic_ve_tree/resource_dir \
-// RUN: -fuse-ld=ld \
 // RUN: %s 2>&1 | FileCheck -check-prefix=DEF %s
 
 // DEF:  clang{{.*}}" "-cc1"
Index: clang/lib/Driver/ToolChain.cpp
===
--- clang/lib/Driver/ToolChain.cpp
+++ clang/lib/Driver/ToolChain.cpp
@@ -541,6 +541,12 @@
   return D.GetProgramPath(Name, *this);
 }
 
+const char *ToolChain::getDefaultLinker() const {
+  if (CLANG_DEFAULT_LINKER[0] == '\0')
+return "ld";
+  return CLANG_DEFAULT_LINKER;
+}
+
 std::string ToolChain::GetLinkerPath(bool *LinkerIsLLD) const {
   if (LinkerIsLLD)
 *LinkerIsLLD = false;
@@ -548,7 +554,7 @@
   // Get -fuse-ld= first to prevent -Wunused-command-line-argument. -fuse-ld= 
is
   // considered as the linker flavor, e.g. "bfd", "gold", or "lld".
   const Arg* A = Args.getLastArg(options::OPT_fuse_ld_EQ);
-  StringRef UseLinker = A ? A->getValue() : CLANG_DEFAULT_LINKER;
+  StringRef UseLinker = A ? A->getValue() : "";
 
   // --ld-path= takes precedence over -fuse-ld= and specifies the executable
   // name. -B, COMPILER_PATH and PATH and consulted if the value does not
Index: clang/include/clang/Driver/ToolChain.h
===
--- clang/include/clang/Driver/ToolChain.h
+++ clang/include/clang/Driver/ToolChain.h
@@ -420,7 +420,7 @@
   }
 
   /// GetDefaultLinker - Get the default linker to use.
-  virtual const char *getDefaultLinker() const { return "ld"; }
+  virtual const char *getDefaultLinker() const;
 
   /// GetDefaultRuntimeLibType - Get the default runtime library variant to 
use.
   virtual RuntimeLibType GetDefaultRuntimeLibType() const {


Index: clang/test/Driver/ve-toolchain.cpp
===
--- clang/test/Driver/ve-toolchain.cpp
+++ clang/test/Driver/ve-toolchain.cpp
@@ -92,10 +92,10 @@
 /// Checking -fintegrated-as
 
 // RUN: %clangxx -### -target ve \
-// RUN:-x assembler -fuse-ld=ld %s 2>&1 | \
+// RUN:-x assembler %s 2>&1 | \
 // RUN:FileCheck -check-prefix=AS %s
 // RUN: %clangxx -### -target ve \
-// RUN:-fno-integrated-as -x assembler -fuse-ld=ld %s 2>&1 | \
+// RUN:-fno-integrated-as -x assembler %s 2>&1 | \
 // RUN:FileCheck -check-prefix=NAS %s
 
 // AS: clang{{.*}} "-cc1as"
@@ -113,7 +113,6 @@
 
 // RUN: %clangxx -### -target ve-unknown-linux-gnu \
 // RUN: --sysroot %S/Inputs/basic_ve_tree \
-// RUN: -fuse-ld=ld \
 // RUN: -resource-dir=%S/Inputs/basic_ve_tree/resource_dir \
 // RUN: --stdlib=c++ %s 2>&1 | FileCheck -check-prefix=DEF %s
 
Index: clang/test/Driver/ve-toolchain.c
===
--- clang/test/Driver/ve-toolchain.c
+++ clang/test/Driver/ve-toolchain.c
@@ -61,10 +61,10 @@
 /// Checking -f

[clang] e403f4f - [clang][DebugInfo] Allow function-local statics and types to be scoped within a lexical block

2021-12-06 Thread Kristina Bessonova via cfe-commits

Author: Kristina Bessonova
Date: 2021-12-06T12:19:09+02:00
New Revision: e403f4fdc88322201040f2bee7b328e8a78e2f7f

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

LOG: [clang][DebugInfo] Allow function-local statics and types to be scoped 
within a lexical block

This is almost a reincarnation of https://reviews.llvm.org/D15977 originally
implemented by Amjad Aboud. It was discussed on llvm-dev [0], committed
with its backend counterpart [1], but finally reverted [2].

This patch makes clang to emit debug info for function-local static variables,
records (classes, structs and unions) and typdefs correctly scoped if
those function-local entites defined within a lexical (bracketed) block.

Before this patch, clang emits all those entities directly scoped in
DISubprogram no matter where they were really defined, causing
debug info loss (reported several times in [3], [4], [5]).

[0] https://lists.llvm.org/pipermail/llvm-dev/2015-November/092551.html
[1] https://reviews.llvm.org/rG30e7a8f694a19553f64b3a3a5de81ce317b9ec2f
[2] https://reviews.llvm.org/rGdc4531e552af6c880a69d226d3666756198fbdc8
[3] https://bugs.llvm.org/show_bug.cgi?id=19238
[4] https://bugs.llvm.org/show_bug.cgi?id=23164
[5] https://bugs.llvm.org/show_bug.cgi?id=44695

Reviewed By: dblaikie

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

Added: 
clang/test/CodeGenCXX/debug-info-lexcial-block.cpp

Modified: 
clang/lib/CodeGen/CGDebugInfo.cpp
clang/lib/CodeGen/CGDebugInfo.h
clang/lib/CodeGen/CGDecl.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/CGDebugInfo.cpp 
b/clang/lib/CodeGen/CGDebugInfo.cpp
index af651e6f44b7c..75eec22e4e4e5 100644
--- a/clang/lib/CodeGen/CGDebugInfo.cpp
+++ b/clang/lib/CodeGen/CGDebugInfo.cpp
@@ -227,6 +227,20 @@ llvm::DIScope *CGDebugInfo::getContextDescriptor(const 
Decl *Context,
   return Default;
 }
 
+void CGDebugInfo::recordDeclarationLexicalScope(const Decl &D) {
+  assert(LexicalBlockMap.find(&D) == LexicalBlockMap.end() &&
+ "D is already mapped to a lexical block scope");
+  if (!LexicalBlockStack.empty())
+LexicalBlockMap.insert({&D, LexicalBlockStack.back()});
+}
+
+llvm::DIScope *CGDebugInfo::getDeclarationLexicalScope(const Decl *D) {
+  auto I = LexicalBlockMap.find(D);
+  if (I != LexicalBlockMap.end())
+return I->second;
+  return getDeclContextDescriptor(cast(D));
+}
+
 PrintingPolicy CGDebugInfo::getPrintingPolicy() const {
   PrintingPolicy PP = CGM.getContext().getPrintingPolicy();
 
@@ -1346,13 +1360,13 @@ llvm::DIType *CGDebugInfo::CreateType(const TypedefType 
*Ty,
   // declared.
   SourceLocation Loc = Ty->getDecl()->getLocation();
 
+  llvm::DIScope *TDContext = getDeclarationLexicalScope(Ty->getDecl());
   uint32_t Align = getDeclAlignIfRequired(Ty->getDecl(), CGM.getContext());
   // Typedefs are derived from some other type.
   llvm::DINodeArray Annotations = CollectBTFDeclTagAnnotations(Ty->getDecl());
   return DBuilder.createTypedef(Underlying, Ty->getDecl()->getName(),
 getOrCreateFile(Loc), getLineNumber(Loc),
-getDeclContextDescriptor(Ty->getDecl()), Align,
-Annotations);
+TDContext, Align, Annotations);
 }
 
 static unsigned getDwarfCC(CallingConv CC) {
@@ -3251,7 +3265,7 @@ llvm::DIType *CGDebugInfo::CreateEnumType(const EnumType 
*Ty) {
 // entered into the ReplaceMap: finalize() will replace the first
 // FwdDecl with the second and then replace the second with
 // complete type.
-llvm::DIScope *EDContext = getDeclContextDescriptor(ED);
+llvm::DIScope *EDContext = getDeclarationLexicalScope(ED);
 llvm::DIFile *DefUnit = getOrCreateFile(ED->getLocation());
 llvm::TempDIScope TmpContext(DBuilder.createReplaceableCompositeType(
 llvm::dwarf::DW_TAG_enumeration_type, "", TheCU, DefUnit, 0));
@@ -3294,7 +3308,7 @@ llvm::DIType *CGDebugInfo::CreateTypeDefinition(const 
EnumType *Ty) {
 
   llvm::DIFile *DefUnit = getOrCreateFile(ED->getLocation());
   unsigned Line = getLineNumber(ED->getLocation());
-  llvm::DIScope *EnumContext = getDeclContextDescriptor(ED);
+  llvm::DIScope *EnumContext = getDeclarationLexicalScope(ED);
   llvm::DIType *ClassTy = getOrCreateType(ED->getIntegerType(), DefUnit);
   return DBuilder.createEnumerationType(EnumContext, ED->getName(), DefUnit,
 Line, Size, Align, EltArray, ClassTy,
@@ -3597,7 +3611,7 @@ llvm::DICompositeType 
*CGDebugInfo::CreateLimitedType(const RecordType *Ty) {
 Line = getLineNumber(Loc);
   }
 
-  llvm::DIScope *RDContext = getDeclContextDescriptor(RD);
+  llvm::DIScope *RDContext = getDeclarationLexicalScope(RD);
 
   // If we ended up creating the type during the co

[PATCH] D113743: [RFC][clang][DebugInfo] Allow function-local statics and types to be scoped within a lexical block

2021-12-06 Thread Kristina Bessonova via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGe403f4fdc883: [clang][DebugInfo] Allow function-local 
statics and types to be scoped within a… (authored by krisb).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D113743

Files:
  clang/lib/CodeGen/CGDebugInfo.cpp
  clang/lib/CodeGen/CGDebugInfo.h
  clang/lib/CodeGen/CGDecl.cpp
  clang/test/CodeGenCXX/debug-info-lexcial-block.cpp

Index: clang/test/CodeGenCXX/debug-info-lexcial-block.cpp
===
--- /dev/null
+++ clang/test/CodeGenCXX/debug-info-lexcial-block.cpp
@@ -0,0 +1,27 @@
+// RUN: %clang_cc1 -triple x86_64-none-linux-gnu -emit-llvm -debug-info-kind=limited %s -o - | FileCheck %s
+
+void foo() {
+  static int bar = 1;
+  {
+struct X {};
+typedef char Y;
+static int bar = 0;
+// The following basic block is intended, in order to check the case where
+// types "X", "Y" are defined in a different scope than where they are used.
+// They should have the scope they are defined at as their parent scope.
+{
+  X a;
+  Y b;
+}
+  }
+}
+
+// CHECK: !{{[0-9]+}} = distinct !DIGlobalVariable(name: "bar", scope: [[FSCOPE:![0-9]+]]
+// CHECK: [[FSCOPE]] = distinct !DISubprogram(name: "foo"
+// CHECK: !{{[0-9]+}} = distinct !DIGlobalVariable(name: "bar", scope: [[LBSCOPE:![0-9]+]]
+// CHECK: [[LBSCOPE]] = distinct !DILexicalBlock(scope: [[FSCOPE]]
+// CHECK: !{{[0-9]+}} = !DILocalVariable(name: "a", scope: [[LBSCOPE2:![0-9]+]], {{.*}} type: [[STRUCT:![0-9]+]]
+// CHECK: [[LBSCOPE2]] = distinct !DILexicalBlock(scope: [[LBSCOPE]]
+// CHECK: [[STRUCT]] = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "X", scope: [[LBSCOPE]]
+// CHECK: !{{[0-9]+}} = !DILocalVariable(name: "b", scope: [[LBSCOPE2]], {{.*}} type: [[TYPEDEF:![0-9]+]]
+// CHECK: [[TYPEDEF]] = !DIDerivedType(tag: DW_TAG_typedef, name: "Y", scope: [[LBSCOPE]]
Index: clang/lib/CodeGen/CGDecl.cpp
===
--- clang/lib/CodeGen/CGDecl.cpp
+++ clang/lib/CodeGen/CGDecl.cpp
@@ -103,17 +103,21 @@
 llvm_unreachable("Declaration should not be in declstmts!");
   case Decl::Record:// struct/union/class X;
   case Decl::CXXRecord: // struct/union/class X; [C++]
-if (CGDebugInfo *DI = getDebugInfo())
+if (CGDebugInfo *DI = getDebugInfo()) {
+  DI->recordDeclarationLexicalScope(D);
   if (cast(D).getDefinition())
 DI->EmitAndRetainType(getContext().getRecordType(cast(&D)));
+}
 return;
   case Decl::Enum:  // enum X;
-if (CGDebugInfo *DI = getDebugInfo())
+if (CGDebugInfo *DI = getDebugInfo()) {
+  DI->recordDeclarationLexicalScope(D);
   if (cast(D).getDefinition())
 DI->EmitAndRetainType(getContext().getEnumType(cast(&D)));
+}
 return;
-  case Decl::Function: // void X();
   case Decl::EnumConstant: // enum ? { X = ? }
+  case Decl::Function: // void X();
   case Decl::StaticAssert: // static_assert(X, ""); [C++0x]
   case Decl::Label:// __label__ x;
   case Decl::Import:
@@ -132,11 +136,11 @@
 
   case Decl::NamespaceAlias:
 if (CGDebugInfo *DI = getDebugInfo())
-DI->EmitNamespaceAlias(cast(D));
+  DI->EmitNamespaceAlias(cast(D));
 return;
   case Decl::Using:  // using X; [C++]
 if (CGDebugInfo *DI = getDebugInfo())
-DI->EmitUsingDecl(cast(D));
+  DI->EmitUsingDecl(cast(D));
 return;
   case Decl::UsingEnum: // using enum X; [C++]
 if (CGDebugInfo *DI = getDebugInfo())
@@ -172,8 +176,10 @@
   case Decl::Typedef:  // typedef int X;
   case Decl::TypeAlias: {  // using X = int; [C++0x]
 QualType Ty = cast(D).getUnderlyingType();
-if (CGDebugInfo *DI = getDebugInfo())
+if (CGDebugInfo *DI = getDebugInfo()) {
+  DI->recordDeclarationLexicalScope(D);
   DI->EmitAndRetainType(Ty);
+}
 if (Ty->isVariablyModifiedType())
   EmitVariablyModifiedType(Ty);
 return;
Index: clang/lib/CodeGen/CGDebugInfo.h
===
--- clang/lib/CodeGen/CGDebugInfo.h
+++ clang/lib/CodeGen/CGDebugInfo.h
@@ -139,6 +139,11 @@
 
   /// Keep track of our current nested lexical block.
   std::vector> LexicalBlockStack;
+
+  /// Map of AST declaration to its lexical block scope.
+  llvm::DenseMap>
+  LexicalBlockMap;
+
   llvm::DenseMap RegionMap;
   /// Keep track of LexicalBlockStack counter at the beginning of a
   /// function. This is used to pop unbalanced regions at the end of a
@@ -543,6 +548,12 @@
   /// Emit an Objective-C interface type standalone debug info.
   llvm::DIType *getOrCreateInterfaceType(QualType Ty, SourceLocation Loc);
 
+  /// Map AST declaration to its lexical block scope if available.
+  void recordDeclarationLexicalScope(const Decl &D);
+
+  /// Get lexical scope of AST declaration.
+  ll

[PATCH] D115106: [clang-tidy] Fix `readability-static-accessed-through-instance` false negative for static methods

2021-12-06 Thread Simon Giesecke via Phabricator via cfe-commits
simon.giesecke added a comment.

Thanks a lot for addressing this issue! I am just trying it on our codebase.

> The problem actually has nothing to do with the out-of-line definition being 
> inline; the problem is that hasDeclaration() of the memberExpr() will match 
> the out-of-line definition, which obviously isn't marked static, so 
> isStaticStorageClass() won't match.

Hm, an out-of-line definition *cannot* have the `static` keyword. I wonder if 
it's actually a bug (in the AST? or just the matcher?) that 
`isStaticStorageClass` doesn't match here? I guess that other checks that use 
`isStaticStorageClass` might be affected by this too?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D115106

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


[PATCH] D110215: [C++2a] [Module] Support extern C/C++ semantics

2021-12-06 Thread Chuanqi Xu via Phabricator via cfe-commits
ChuanqiXu added a comment.

@aaron.ballman @urnathan @rsmith ping. Might you take a look?


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

https://reviews.llvm.org/D110215

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


[PATCH] D114527: [VE] Support multiple architectures installation

2021-12-06 Thread Simon Moll via Phabricator via cfe-commits
simoll accepted this revision.
simoll added a comment.
This revision is now accepted and ready to land.

I will configure the `clang-ve-staging` bot to start testing libcxx/libcxxabi


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D114527

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


[PATCH] D113294: [IR] Remove unbounded as possible value for vscale_range minimum

2021-12-06 Thread Cullen Rhodes via Phabricator via cfe-commits
c-rhodes updated this revision to Diff 392002.
c-rhodes added a comment.

Revert `LangOpt.VScaleMin` default to 0.


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

https://reviews.llvm.org/D113294

Files:
  clang/include/clang/Basic/DiagnosticDriverKinds.td
  clang/include/clang/Driver/Options.td
  clang/lib/Basic/Targets/AArch64.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/test/CodeGen/arm-sve-vector-bits-vscale-range.c
  clang/test/Frontend/aarch64-vscale-min.c
  llvm/docs/LangRef.rst
  llvm/include/llvm/IR/Attributes.h
  llvm/lib/IR/Attributes.cpp
  llvm/lib/IR/Verifier.cpp
  llvm/test/Analysis/CostModel/AArch64/sve-gather.ll
  llvm/test/Analysis/CostModel/AArch64/sve-scatter.ll
  llvm/test/Bitcode/attributes.ll
  llvm/test/Transforms/InstCombine/icmp-vscale.ll
  llvm/test/Transforms/InstCombine/vscale_sext_and_zext.ll
  llvm/test/Transforms/InstCombine/vscale_trunc.ll
  llvm/test/Transforms/LoopVectorize/AArch64/first-order-recurrence.ll
  llvm/test/Transforms/LoopVectorize/AArch64/scalable-strict-fadd.ll
  llvm/test/Transforms/LoopVectorize/AArch64/scalable-vectorization.ll
  llvm/test/Transforms/LoopVectorize/AArch64/scalable-vf-hint.ll
  llvm/test/Transforms/LoopVectorize/AArch64/sve-cond-inv-loads.ll
  llvm/test/Transforms/LoopVectorize/AArch64/sve-gather-scatter.ll
  llvm/test/Transforms/LoopVectorize/AArch64/sve-inv-store.ll
  llvm/test/Transforms/LoopVectorize/AArch64/sve-large-strides.ll
  llvm/test/Transforms/LoopVectorize/AArch64/sve-strict-fadd-cost.ll
  llvm/test/Transforms/LoopVectorize/AArch64/sve-widen-phi.ll
  llvm/test/Verifier/vscale_range.ll

Index: llvm/test/Verifier/vscale_range.ll
===
--- llvm/test/Verifier/vscale_range.ll
+++ llvm/test/Verifier/vscale_range.ll
@@ -1,4 +1,7 @@
 ; RUN: not llvm-as %s -o /dev/null 2>&1 | FileCheck %s
 
+; CHECK: 'vscale_range' minimum must be greater than 0
+declare i8* @a(i32*) vscale_range(0, 1)
+
 ; CHECK: 'vscale_range' minimum cannot be greater than maximum
 declare i8* @b(i32*) vscale_range(8, 1)
Index: llvm/test/Transforms/LoopVectorize/AArch64/sve-widen-phi.ll
===
--- llvm/test/Transforms/LoopVectorize/AArch64/sve-widen-phi.ll
+++ llvm/test/Transforms/LoopVectorize/AArch64/sve-widen-phi.ll
@@ -175,7 +175,7 @@
   ret i32 %tmp5
 }
 
-attributes #0 = { vscale_range(0, 16) }
+attributes #0 = { vscale_range(1, 16) }
 !0 = distinct !{!0, !1, !2, !3, !4, !5}
 !1 = !{!"llvm.loop.mustprogress"}
 !2 = !{!"llvm.loop.vectorize.width", i32 4}
Index: llvm/test/Transforms/LoopVectorize/AArch64/sve-strict-fadd-cost.ll
===
--- llvm/test/Transforms/LoopVectorize/AArch64/sve-strict-fadd-cost.ll
+++ llvm/test/Transforms/LoopVectorize/AArch64/sve-strict-fadd-cost.ll
@@ -53,7 +53,7 @@
   ret double %add
 }
 
-attributes #0 = { "target-features"="+sve" vscale_range(0, 16) }
+attributes #0 = { "target-features"="+sve" vscale_range(1, 16) }
 
 !0 = distinct !{!0, !1}
 !1 = !{!"llvm.loop.vectorize.scalable.enable", i1 true}
Index: llvm/test/Transforms/LoopVectorize/AArch64/sve-large-strides.ll
===
--- llvm/test/Transforms/LoopVectorize/AArch64/sve-large-strides.ll
+++ llvm/test/Transforms/LoopVectorize/AArch64/sve-large-strides.ll
@@ -90,7 +90,7 @@
   ret void
 }
 
-attributes #0 = { vscale_range(0, 16) }
+attributes #0 = { vscale_range(1, 16) }
 !0 = distinct !{!0, !1, !2, !3, !4, !5}
 !1 = !{!"llvm.loop.mustprogress"}
 !2 = !{!"llvm.loop.vectorize.width", i32 4}
Index: llvm/test/Transforms/LoopVectorize/AArch64/sve-inv-store.ll
===
--- llvm/test/Transforms/LoopVectorize/AArch64/sve-inv-store.ll
+++ llvm/test/Transforms/LoopVectorize/AArch64/sve-inv-store.ll
@@ -59,7 +59,7 @@
   ret void
 }
 
-attributes #0 = { "target-features"="+neon,+sve" vscale_range(0, 16) }
+attributes #0 = { "target-features"="+neon,+sve" vscale_range(1, 16) }
 
 !0 = distinct !{!0, !1, !2, !3, !4, !5}
 !1 = !{!"llvm.loop.mustprogress"}
Index: llvm/test/Transforms/LoopVectorize/AArch64/sve-gather-scatter.ll
===
--- llvm/test/Transforms/LoopVectorize/AArch64/sve-gather-scatter.ll
+++ llvm/test/Transforms/LoopVectorize/AArch64/sve-gather-scatter.ll
@@ -153,7 +153,7 @@
   ret void
 }
 
-attributes #0 = { vscale_range(0, 16) }
+attributes #0 = { vscale_range(1, 16) }
 
 !0 = distinct !{!0, !1, !2, !3, !4, !5}
 !1 = !{!"llvm.loop.mustprogress"}
Index: llvm/test/Transforms/LoopVectorize/AArch64/sve-cond-inv-loads.ll
===
--- llvm/test/Transforms/LoopVectorize/AArch64/sve-cond-inv-loads.ll
+++ llvm/test/Transforms/LoopVectorize/AArch64/sve-cond-inv-loads.ll
@@ -117,7 +117,7 @@
   ret void
 }
 
-attributes #0 = { vscale_range(0, 16

[PATCH] D102669: [analyzer][ctu] Fix wrong 'multiple definitions' errors caused by space characters in lookup names when parsing the ctu index file

2021-12-06 Thread Ella Ma via Phabricator via cfe-commits
OikawaKirie added inline comments.



Comment at: clang/lib/CrossTU/CrossTranslationUnit.cpp:154-172
+  // Find the length delimiter.
+  const size_t LengthDelimiter = LineRef.find(':');
+  if (StringRef::npos == LengthDelimiter)
+return false;
+
+  // Parse the length of LookupName as USRLength.
+  size_t USRLength = 0;

steakhal wrote:
> OikawaKirie wrote:
> > steakhal wrote:
> > > 
> > The source of lookup name of the function being imported is function 
> > `CrossTranslationUnitContext::getLookupName`. Keeping the length in the 
> > mapping can avoid parsing the lookup name during importing.
> Okay; you can copy the original StringRef to have that. But by consuming it 
> on one path makes the code much more readable.
> 
The `getAsInterger` call can also check whether the content before the first 
colon is an integer. Therefore, a sub-string operation is required here.



Comment at: clang/test/Analysis/Inputs/ctu-lookup-name-with-space.cpp:7-8
+// CHECK-NOT: multiple definitions are found for the same key in index
+f([](char) -> int { return 42; });
+f([](char) -> bool { return true; });
+  }

steakhal wrote:
> I would rather put these into the `importee()`
The lambda exprs will not be included in the CTU index file if they are 
declared in a normal function.



Comment at: clang/test/Analysis/Inputs/ctu-lookup-name-with-space.cpp:13
+int importee(int X) {
+  return 1 / X;
+}

steakhal wrote:
> Why do you need to have a div by zero warning?
I am not sure whether we should test if an external function can be correctly 
imported. Hence, I wrote a div-by-zero bug here. A call to function 
`clang_analyzer_warnIfReached` is also OK here.

As the imported lambda expr will not be called, I think I can only test whether 
CTU works via another normal function.


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

https://reviews.llvm.org/D102669

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


[PATCH] D115140: [ARM][clang] Option b-key must not affect __ARM_FEATURE_PAC_DEFAULT

2021-12-06 Thread Ties Stuij via Phabricator via cfe-commits
stuij created this revision.
Herald added a subscriber: kristof.beyls.
stuij requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

When using -mbranch-protection=pac-ret+b-key, macro __ARM_FEATURE_PAC_DEFAULT
should still have the value corresponding to a-key, because b-key is only valid
for AArch64.

This patch is part of a series that adds support for the PACBTI-M extension of
the Armv8.1-M architecture, as detailed here:

https://community.arm.com/arm-community-blogs/b/architectures-and-processors-blog/posts/armv8-1-m-pointer-authentication-and-branch-target-identification-extension

The PACBTI-M specification can be found in the Armv8-M Architecture Reference
Manual:

https://developer.arm.com/documentation/ddi0553/latest

The following people contributed to this patch:

- Victor Campos


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D115140

Files:
  clang/lib/Basic/Targets/ARM.cpp
  clang/test/Preprocessor/arm-target-features.c


Index: clang/test/Preprocessor/arm-target-features.c
===
--- clang/test/Preprocessor/arm-target-features.c
+++ clang/test/Preprocessor/arm-target-features.c
@@ -881,20 +881,18 @@
 // RUN: %clang -target arm-arm-none-eabi -march=armv8.1-m.main -x c -E -dM %s 
-o - | FileCheck --check-prefixes=CHECK-NOBTI,CHECK-NOPAC %s
 // RUN: %clang -target arm-arm-none-eabi -march=armv8.1-m.main 
-mbranch-protection=bti -x c -E -dM %s -o - | FileCheck 
--check-prefixes=CHECK-BTI,CHECK-NOPAC %s
 // RUN: %clang -target arm-arm-none-eabi -march=armv8.1-m.main 
-mbranch-protection=pac-ret -x c -E -dM %s -o - | FileCheck 
--check-prefixes=CHECK-PAC,CHECK-NOBTI %s
-// RUN: %clang -target arm-arm-none-eabi -march=armv8.1-m.main 
-mbranch-protection=pac-ret+b-key -x c -E -dM %s -o - | FileCheck 
--check-prefixes=CHECK-PAC-BKEY,CHECK-NOBTI %s
+// RUN: %clang -target arm-arm-none-eabi -march=armv8.1-m.main 
-mbranch-protection=pac-ret+b-key -x c -E -dM %s -o - | FileCheck 
--check-prefixes=CHECK-PAC,CHECK-NOBTI %s
 // RUN: %clang -target arm-arm-none-eabi -march=armv8.1-m.main 
-mbranch-protection=pac-ret+leaf -x c -E -dM %s -o - | FileCheck 
--check-prefixes=CHECK-PAC-LEAF,CHECK-NOBTI %s
-// RUN: %clang -target arm-arm-none-eabi -march=armv8.1-m.main 
-mbranch-protection=pac-ret+b-key+leaf -x c -E -dM %s -o - | FileCheck 
--check-prefixes=CHECK-PAC-BKEY-LEAF,CHECK-NOBTI %s
+// RUN: %clang -target arm-arm-none-eabi -march=armv8.1-m.main 
-mbranch-protection=pac-ret+b-key+leaf -x c -E -dM %s -o - | FileCheck 
--check-prefixes=CHECK-PAC-LEAF,CHECK-NOBTI %s
 // RUN: %clang -target arm-arm-none-eabi -march=armv8.1-m.main 
-mbranch-protection=bti+pac-ret -x c -E -dM %s -o - | FileCheck 
--check-prefixes=CHECK-PAC,CHECK-BTI %s
-// RUN: %clang -target arm-arm-none-eabi -march=armv8.1-m.main 
-mbranch-protection=bti+pac-ret+b-key -x c -E -dM %s -o - | FileCheck 
--check-prefixes=CHECK-PAC-BKEY,CHECK-BTI %s
+// RUN: %clang -target arm-arm-none-eabi -march=armv8.1-m.main 
-mbranch-protection=bti+pac-ret+b-key -x c -E -dM %s -o - | FileCheck 
--check-prefixes=CHECK-PAC,CHECK-BTI %s
 // RUN: %clang -target arm-arm-none-eabi -march=armv8.1-m.main 
-mbranch-protection=bti+pac-ret+leaf -x c -E -dM %s -o - | FileCheck 
--check-prefixes=CHECK-PAC-LEAF,CHECK-BTI %s
-// RUN: %clang -target arm-arm-none-eabi -march=armv8.1-m.main 
-mbranch-protection=bti+pac-ret+b-key+leaf -x c -E -dM %s -o - | FileCheck 
--check-prefixes=CHECK-PAC-BKEY-LEAF,CHECK-BTI %s
+// RUN: %clang -target arm-arm-none-eabi -march=armv8.1-m.main 
-mbranch-protection=bti+pac-ret+b-key+leaf -x c -E -dM %s -o - | FileCheck 
--check-prefixes=CHECK-PAC-LEAF,CHECK-BTI %s
 // CHECK-NOBTI-NOT: #define __ARM_FEATURE_BTI_DEFAULT
 // CHECK-NOPAC-NOT: #define __ARM_FEATURE_PAC_DEFAULT
 // CHECK-BTI: #define __ARM_FEATURE_BTI_DEFAULT 1
 // CHECK-PAC: #define __ARM_FEATURE_PAC_DEFAULT 1
-// CHECK-PAC-BKEY: #define __ARM_FEATURE_PAC_DEFAULT 2
 // CHECK-PAC-LEAF: #define __ARM_FEATURE_PAC_DEFAULT 5
-// CHECK-PAC-BKEY-LEAF: #define __ARM_FEATURE_PAC_DEFAULT 6
 
 // RUN: %clang -target arm-arm-none-eabi -march=armv8.1-m.main -x c -E -dM %s 
-o - | FileCheck --check-prefixes=CHECK-NOBTI-EXT,CHECK-NOPAC-EXT %s
 // RUN: %clang -target arm-arm-none-eabi -march=armv7-m+pacbti -x c -E -dM %s 
-o - | FileCheck --check-prefixes=CHECK-PACBTI-EXT %s
Index: clang/lib/Basic/Targets/ARM.cpp
===
--- clang/lib/Basic/Targets/ARM.cpp
+++ clang/lib/Basic/Targets/ARM.cpp
@@ -911,7 +911,7 @@
 Builder.defineMacro("__ARM_FEATURE_BTI_DEFAULT", "1");
 
   if (Opts.hasSignReturnAddress()) {
-unsigned Value = Opts.isSignReturnAddressWithAKey() ? 1 : 2;
+unsigned Value = 1;
 if (Opts.isSignReturnAddressScopeAll())
   Value |= 1 << 2;
 Builder.defineMacro("__ARM_FEATURE_PAC_DEFAULT", Twine(Value));


Index: clang/test/Preprocessor/arm-target-features.c
=

[clang] 83f5725 - [VE] Support multiple architectures installation

2021-12-06 Thread Kazushi Marukawa via cfe-commits

Author: Kazushi (Jam) Marukawa
Date: 2021-12-06T19:56:41+09:00
New Revision: 83f572527e0fcc1cd0be8ee23bc12abf27027daf

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

LOG: [VE] Support multiple architectures installation

Change C++ header files placement to support multiple LLVM_RUNTIME_TARGETS
build.  Also modifies regression test for it.

Reviewed By: simoll

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

Added: 
clang/test/Driver/Inputs/basic_ve_tree/bin/.keep
clang/test/Driver/Inputs/basic_ve_tree/include/c++/v1/.keep

clang/test/Driver/Inputs/basic_ve_tree/include/ve-unknown-linux-gnu/c++/v1/.keep

Modified: 
clang/lib/Driver/ToolChains/VEToolchain.cpp
clang/test/Driver/ve-toolchain.c
clang/test/Driver/ve-toolchain.cpp

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/VEToolchain.cpp 
b/clang/lib/Driver/ToolChains/VEToolchain.cpp
index 1fcc52684baa3..4cdeec7f9d8a9 100644
--- a/clang/lib/Driver/ToolChains/VEToolchain.cpp
+++ b/clang/lib/Driver/ToolChains/VEToolchain.cpp
@@ -28,17 +28,27 @@ VEToolChain::VEToolChain(const Driver &D, const 
llvm::Triple &Triple,
   getProgramPaths().push_back("/opt/nec/ve/bin");
   // ProgramPaths are found via 'PATH' environment variable.
 
-  // default file paths are:
-  //   ${RESOURCEDIR}/lib/linux/ve (== getArchSpecificLibPath)
-  //   /lib/../lib64
-  //   /usr/lib/../lib64
-  //   ${BINPATH}/../lib
-  //   /lib
-  //   /usr/lib
-  //
-  // These are OK for host, but no go for VE.  So, defines them all
-  // from scratch here.
+  // Default library paths are following:
+  //   ${RESOURCEDIR}/lib/ve-unknown-linux-gnu,
+  // These are OK.
+
+  // Default file paths are following:
+  //   ${RESOURCEDIR}/lib/linux/ve, (== getArchSpecificLibPath)
+  //   /lib/../lib64,
+  //   /usr/lib/../lib64,
+  //   ${BINPATH}/../lib,
+  //   /lib,
+  //   /usr/lib,
+  // These are OK for host, but no go for VE.
+
+  // Define file paths from scratch here.
   getFilePaths().clear();
+
+  // Add library directories:
+  //   ${BINPATH}/../lib/ve-unknown-linux-gnu, (== getStdlibPath)
+  //   ${RESOURCEDIR}/lib/linux/ve, (== getArchSpecificLibPath)
+  //   ${SYSROOT}/opt/nec/ve/lib,
+  getFilePaths().push_back(getStdlibPath());
   getFilePaths().push_back(getArchSpecificLibPath());
   getFilePaths().push_back(computeSysRoot() + "/opt/nec/ve/lib");
 }
@@ -115,9 +125,10 @@ void VEToolChain::AddClangCXXStdlibIncludeArgs(const 
ArgList &DriverArgs,
 ArrayRef DirVec(Dirs);
 addSystemIncludes(DriverArgs, CC1Args, DirVec);
   } else {
-SmallString<128> P(getDriver().ResourceDir);
-llvm::sys::path::append(P, "include/c++/v1");
-addSystemInclude(DriverArgs, CC1Args, P);
+// Add following paths for multiple target installation.
+//   ${INSTALLDIR}/include/ve-unknown-linux-gnu/c++/v1,
+//   ${INSTALLDIR}/include/c++/v1,
+addLibCxxIncludePaths(DriverArgs, CC1Args);
   }
 }
 

diff  --git a/clang/test/Driver/Inputs/basic_ve_tree/bin/.keep 
b/clang/test/Driver/Inputs/basic_ve_tree/bin/.keep
new file mode 100644
index 0..e69de29bb2d1d

diff  --git a/clang/test/Driver/Inputs/basic_ve_tree/include/c++/v1/.keep 
b/clang/test/Driver/Inputs/basic_ve_tree/include/c++/v1/.keep
new file mode 100644
index 0..e69de29bb2d1d

diff  --git 
a/clang/test/Driver/Inputs/basic_ve_tree/include/ve-unknown-linux-gnu/c++/v1/.keep
 
b/clang/test/Driver/Inputs/basic_ve_tree/include/ve-unknown-linux-gnu/c++/v1/.keep
new file mode 100644
index 0..e69de29bb2d1d

diff  --git a/clang/test/Driver/ve-toolchain.c 
b/clang/test/Driver/ve-toolchain.c
index fc6a0cf88765c..8878bd8f83cc0 100644
--- a/clang/test/Driver/ve-toolchain.c
+++ b/clang/test/Driver/ve-toolchain.c
@@ -12,7 +12,7 @@
 /// Checking include-path
 
 // RUN: %clang -### -target ve --sysroot %S/Inputs/basic_ve_tree %s \
-// RUN: -resource-dir=%S/Input/basic_ve_tree/resource_dir \
+// RUN: -resource-dir=%S/Inputs/basic_ve_tree/resource_dir \
 // RUN: 2>&1 | FileCheck -check-prefix=DEFINC %s
 // DEFINC: clang{{.*}} "-cc1"
 // DEFINC-SAME: "-nostdsysteminc"
@@ -22,7 +22,7 @@
 // DEFINC-SAME: "-internal-isystem" "[[SYSROOT]]/opt/nec/ve/include"
 
 // RUN: %clang -### -target ve --sysroot %S/Inputs/basic_ve_tree %s \
-// RUN: -resource-dir=%S/Input/basic_ve_tree/resource_dir \
+// RUN: -resource-dir=%S/Inputs/basic_ve_tree/resource_dir \
 // RUN: -nostdlibinc 2>&1 | FileCheck -check-prefix=NOSTDLIBINC %s
 // NOSTDLIBINC: clang{{.*}} "-cc1"
 // NOSTDLIBINC-SAME: "-resource-dir" "[[RESOURCE_DIR:[^"]+]]"
@@ -31,7 +31,7 @@
 // NOSTDLIBINC-NOT: "-internal-isystem" "[[SYSROOT]]/opt/nec/ve/include"
 
 // RUN: %clang -### -target ve --sysroot %S/Inputs/basic_ve_tree %s \
-// RUN: -resource-dir=%S/Input/basic_ve_tree/resour

[PATCH] D114527: [VE] Support multiple architectures installation

2021-12-06 Thread Kazushi Marukawa via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG83f572527e0f: [VE] Support multiple architectures 
installation (authored by kaz7).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D114527

Files:
  clang/lib/Driver/ToolChains/VEToolchain.cpp
  clang/test/Driver/Inputs/basic_ve_tree/bin/.keep
  clang/test/Driver/Inputs/basic_ve_tree/include/c++/v1/.keep
  
clang/test/Driver/Inputs/basic_ve_tree/include/ve-unknown-linux-gnu/c++/v1/.keep
  clang/test/Driver/ve-toolchain.c
  clang/test/Driver/ve-toolchain.cpp

Index: clang/test/Driver/ve-toolchain.cpp
===
--- clang/test/Driver/ve-toolchain.cpp
+++ clang/test/Driver/ve-toolchain.cpp
@@ -5,72 +5,89 @@
 ///-
 /// Checking dwarf-version
 
-// RUN: %clangxx -### -g -target ve %s 2>&1 | FileCheck -check-prefix=DWARF_VER %s
+// RUN: %clangxx -### -g -target ve-unknown-linux-gnu \
+// RUN: %s 2>&1 | FileCheck -check-prefix=DWARF_VER %s
 // DWARF_VER: "-dwarf-version=4"
 
 ///-
 /// Checking include-path
 
-// RUN: %clangxx -### -target ve --sysroot %S/Inputs/basic_ve_tree %s \
-// RUN: -resource-dir=%S/Input/basic_ve_tree/resource_dir \
+// RUN: %clangxx -### -target ve-unknown-linux-gnu \
+// RUN: --sysroot %S/Inputs/basic_ve_tree %s \
+// RUN: -ccc-install-dir %S/Inputs/basic_ve_tree/bin \
+// RUN: -resource-dir=%S/Inputs/basic_ve_tree/resource_dir \
 // RUN: 2>&1 | FileCheck -check-prefix=DEFINC %s
 // DEFINC: clang{{.*}} "-cc1"
 // DEFINC-SAME: "-nostdsysteminc"
 // DEFINC-SAME: "-resource-dir" "[[RESOURCE_DIR:[^"]+]]"
 // DEFINC-SAME: "-isysroot" "[[SYSROOT:[^"]+]]"
-// DEFINC-SAME: "-internal-isystem" "[[RESOURCE_DIR]]/include/c++/v1"
+// DEFINC-SAME: "-internal-isystem" "{{.*}}/bin/../include/ve-unknown-linux-gnu/c++/v1"
+// DEFINC-SAME: "-internal-isystem" "{{.*}}/bin/../include/c++/v1"
 // DEFINC-SAME: "-internal-isystem" "[[RESOURCE_DIR]]/include"
 // DEFINC-SAME: "-internal-isystem" "[[SYSROOT]]/opt/nec/ve/include"
 
-// RUN: %clangxx -### -target ve --sysroot %S/Inputs/basic_ve_tree %s \
-// RUN: -resource-dir=%S/Input/basic_ve_tree/resource_dir \
+// RUN: %clangxx -### -target ve-unknown-linux-gnu \
+// RUN: --sysroot %S/Inputs/basic_ve_tree %s \
+// RUN: -ccc-install-dir %S/Inputs/basic_ve_tree/bin \
+// RUN: -resource-dir=%S/Inputs/basic_ve_tree/resource_dir \
 // RUN: -nostdlibinc 2>&1 | FileCheck -check-prefix=NOSTDLIBINC %s
 // NOSTDLIBINC: clang{{.*}} "-cc1"
 // NOSTDLIBINC-SAME: "-resource-dir" "[[RESOURCE_DIR:[^"]+]]"
 // NOSTDLIBINC-SAME: "-isysroot" "[[SYSROOT:[^"]+]]"
-// NOSTDLIBINC-NOT: "-internal-isystem" "[[RESOURCE_DIR]]/include/c++/v1"
+// NOSTDLIBINC-NOT: "-internal-isystem" "{{.*}}/bin/../include/ve-unknown-linux-gnu/c++/v1"
+// NOSTDLIBINC-NOT: "-internal-isystem" "{{.*}}/bin/../include/c++/v1"
 // NOSTDLIBINC-SAME: "-internal-isystem" "[[RESOURCE_DIR]]/include"
 // NOSTDLIBINC-NOT: "-internal-isystem" "[[SYSROOT]]/opt/nec/ve/include"
 
-// RUN: %clangxx -### -target ve --sysroot %S/Inputs/basic_ve_tree %s \
-// RUN: -resource-dir=%S/Input/basic_ve_tree/resource_dir \
+// RUN: %clangxx -### -target ve-unknown-linux-gnu \
+// RUN: --sysroot %S/Inputs/basic_ve_tree %s \
+// RUN: -ccc-install-dir %S/Inputs/basic_ve_tree/bin \
+// RUN: -resource-dir=%S/Inputs/basic_ve_tree/resource_dir \
 // RUN: -nobuiltininc 2>&1 | FileCheck -check-prefix=NOBUILTININC %s
 // NOBUILTININC: clang{{.*}} "-cc1"
 // NOBUILTININC-SAME: "-nobuiltininc"
 // NOBUILTININC-SAME: "-resource-dir" "[[RESOURCE_DIR:[^"]+]]"
 // NOBUILTININC-SAME: "-isysroot" "[[SYSROOT:[^"]+]]"
-// NOBUILTININC-SAME: "-internal-isystem" "[[RESOURCE_DIR]]/include/c++/v1"
+// NOBUILTININC-SAME: "-internal-isystem" "{{.*}}/bin/../include/ve-unknown-linux-gnu/c++/v1"
+// NOBUILTININC-SAME: "-internal-isystem" "{{.*}}/bin/../include/c++/v1"
 // NOBUILTININC-NOT: "-internal-isystem" "[[RESOURCE_DIR]]/include"
 // NOBUILTININC-SAME: "-internal-isystem" "[[SYSROOT]]/opt/nec/ve/include"
 
-// RUN: %clangxx -### -target ve --sysroot %S/Inputs/basic_ve_tree %s \
-// RUN: -resource-dir=%S/Input/basic_ve_tree/resource_dir \
+// RUN: %clangxx -### -target ve-unknown-linux-gnu \
+// RUN: --sysroot %S/Inputs/basic_ve_tree %s \
+// RUN: -ccc-install-dir %S/Inputs/basic_ve_tree/bin \
+// RUN: -resource-dir=%S/Inputs/basic_ve_tree/resource_dir \
 // RUN: -nostdinc 2>&1 | FileCheck -check-prefix=NOSTDINC %s
 // NOSTDINC: clang{{.*}} "-cc1"
 // NOSTDINC-SAME: "-nobuiltininc"
 // NOSTDINC-SAME: "-resource-dir" "[[RESOURCE_DIR:[^"]+]]"
 // NOSTDINC-SAME: "-isysroot" "[[SYSROOT:[^"]+]]"
-// NOSTDINC-NOT: "-internal-isystem" "[[RESOURCE_DIR]]/include/c++/v1"
+// NOSTDINC-NOT: "-internal-isy

[PATCH] D115141: [ARM][clang] Add back branch protection tests

2021-12-06 Thread Ties Stuij via Phabricator via cfe-commits
stuij created this revision.
Herald added a subscriber: kristof.beyls.
stuij requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

When committing the PACBTI-M frontend support
patch (https://reviews.llvm.org/D112421), the tests in
arm-invalid-branch-protection.c were failing on certain test setups, so it was
removed to make the llvm test suite pass. The fix is to require
arm-registered-target.

This patch is part of a series that adds support for the PACBTI-M extension of
the Armv8.1-M architecture, as detailed here:

https://community.arm.com/arm-community-blogs/b/architectures-and-processors-blog/posts/armv8-1-m-pointer-authentication-and-branch-target-identification-extension

The PACBTI-M specification can be found in the Armv8-M Architecture Reference
Manual:

https://developer.arm.com/documentation/ddi0553/latest


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D115141

Files:
  clang/test/Frontend/arm-invalid-branch-protection.c


Index: clang/test/Frontend/arm-invalid-branch-protection.c
===
--- /dev/null
+++ clang/test/Frontend/arm-invalid-branch-protection.c
@@ -0,0 +1,7 @@
+// REQUIRES: arm-registered-target
+// RUN: %clang -target arm-arm-none-eabi -mbranch-protection=pac-ret+b-key -c 
%s -o /dev/null 2>&1 | FileCheck %s
+// RUN: %clang -target arm-arm-none-eabi 
-mbranch-protection=pac-ret+b-key+leaf -c %s -o /dev/null 2>&1 | FileCheck %s
+// RUN: %clang -target arm-arm-none-eabi -mbranch-protection=bti+pac-ret+b-key 
-c %s -o /dev/null 2>&1 | FileCheck %s
+// RUN: %clang -target arm-arm-none-eabi 
-mbranch-protection=bti+pac-ret+b-key+leaf -c %s -o /dev/null 2>&1 | FileCheck 
%s
+
+// CHECK: warning: invalid branch protection option 'b-key' in 
'-mbranch-protection={{[a-z+-]*}}' [-Wbranch-protection]


Index: clang/test/Frontend/arm-invalid-branch-protection.c
===
--- /dev/null
+++ clang/test/Frontend/arm-invalid-branch-protection.c
@@ -0,0 +1,7 @@
+// REQUIRES: arm-registered-target
+// RUN: %clang -target arm-arm-none-eabi -mbranch-protection=pac-ret+b-key -c %s -o /dev/null 2>&1 | FileCheck %s
+// RUN: %clang -target arm-arm-none-eabi -mbranch-protection=pac-ret+b-key+leaf -c %s -o /dev/null 2>&1 | FileCheck %s
+// RUN: %clang -target arm-arm-none-eabi -mbranch-protection=bti+pac-ret+b-key -c %s -o /dev/null 2>&1 | FileCheck %s
+// RUN: %clang -target arm-arm-none-eabi -mbranch-protection=bti+pac-ret+b-key+leaf -c %s -o /dev/null 2>&1 | FileCheck %s
+
+// CHECK: warning: invalid branch protection option 'b-key' in '-mbranch-protection={{[a-z+-]*}}' [-Wbranch-protection]
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D114231: [clang][docs][dataflow] Added an introduction to dataflow analysis

2021-12-06 Thread Dmitri Gribenko via Phabricator via cfe-commits
gribozavr2 added inline comments.



Comment at: clang/docs/DataFlowAnalysisIntro.md:279
+```
+out = transfer(basic_block, join(in_1, in_2, ..., in_n))
+```

xazax.hun wrote:
> gribozavr2 wrote:
> > xazax.hun wrote:
> > > While I agree that this is the general formula, people sometimes do small 
> > > variations, e.g.:
> > > ```
> > > out =  join(transfer(basic_block,in_1), transfer(basic_block,in_2), ..., 
> > > transfer(basic_block,in_n))
> > > ```
> > > 
> > > This is less efficient as we end up invoking the transfer function more 
> > > often, but it can be more precise. E.g. with some ad-hoc notation:
> > > 
> > > ```
> > > Given the branches: x: {1}, x: {2}, x: {3}, x: {4}
> > > join(in...) : x : {⊤}
> > > transfer("x/2", ...) == x : {⊤}
> > > 
> > > vs.
> > > Given the branches: x: {1}, x: {2}, x: {3}, x: {4}
> > > transfer("x/2", ...) ==x : {0}, x : {1}, x : {1}, x: {2} == outs
> > > join(outs) == x: {0, 1, 2}
> > > ```
> > This section is only attempting to give the readers an intuition of why 
> > dataflow works, hence it must be straightforward, not necessarily 
> > exhaustive or rigorous. I tried to add your suggestion here, but it breaks 
> > the flow. I tried to add it at the end of the section, but it looks out of 
> > place. So, sorry, I couldn't fit it here. If you have a specific wording 
> > suggestion that works here, I would be happy to apply it.
> > 
> > I think one would need to add a section like "variations on dataflow 
> > equations" to properly introduce the idea. It also seems to me that this 
> > specific variation is also a special case of a more general idea of 
> > deferring join operations to improve precision; that is, instead of doing a 
> > join everywhere where classic dataflow prescribes it, we can instead keep 
> > exploring separate paths, and only do a join at some later point in the 
> > CFG. Similarly we can also unroll loops in a precise way up to a certain 
> > number of iterations, and attempt to join/widen only at after that. These 
> > are of course important ideas, but they don't help with what this document 
> > is trying to achieve.
> Agreed, we cannot introduce everything in an introductory document. I mainly 
> wanted to avoid creating the impression that there is one definitive way to 
> data flow analysis and this is it. Maybe one sentence at the end mentioning 
> there are several variations that we do not discuss here could be sufficient. 
Added a long parenthetical:

(Note that there are other ways to write this equation that produce higher
precision analysis results. The trick is to keep exploring the execution paths
separately and delay joining until later. Hoowever, we won't discuss those
variations here.)



Comment at: clang/docs/DataFlowAnalysisIntro.md:478-479
+
+To analyze the function body we can use a lattice which consists of normal
+states and failure states. A normal state describes program points where we are
+sure that no behaviors that block the refactoring have occurred. Normal states

xazax.hun wrote:
> gribozavr2 wrote:
> > xazax.hun wrote:
> > > I wonder if the distinction between normal states and failure states is 
> > > useful. In general, we can combine arbitrary number of lattices and 
> > > propagate all the information in a single pass. I.e., we could have 
> > > multiple "normal" or "failure" states.
> > > 
> > > There are multiple ways to combine lattices, we can put them on top of 
> > > each other, or next to each other introducing new top/bottom values, or 
> > > we can take their products.
> > > I wonder if the distinction between normal states and failure states is 
> > > useful.
> > 
> > I'm not sure I understand -- this distinction is useful in this particular 
> > approach to solve this problem, since it helps solve the problem? Or are 
> > you objecting to the term "failure"?
> > 
> > Of course, in general, an analysis does not need to have failure/normal 
> > states, and like you said, if we track information about multiple candidate 
> > output parameters at the same time, each can be in either a normal or 
> > failure state at every program point independently of other parameters. 
> > However, this document provides an example of a solution for this 
> > particular problem; the goal is not to solve the problem, but to give the 
> > reader an intuition of how dataflow ideas can be applied to solve real 
> > problems.
> Yeah, I found the term `failure` a bit confusing. It is a regular analysis 
> state, the analysis itself did not fail. I think I understand that this is 
> named failure after the fact that it is blocking the transformation. 
> 
> Probably my main problem was that it was not clear whether the document 
> suggested having normal and failure states is a general design principle to 
> all analysis or specific to the problem we want to solve. I think in this 
> particular example the idea of combining lattices in a certain way to build

[clang] 0fbb174 - [ARM] Implement setjmp BTI placement for PACBTI-M

2021-12-06 Thread Ties Stuij via cfe-commits

Author: Ties Stuij
Date: 2021-12-06T11:07:10Z
New Revision: 0fbb17458a01a6b388fc67661ffb92969503e977

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

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

This patch intends to guard indirect branches performed by longjmp
by inserting BTI instructions after calls to setjmp.

Calls with 'returns-twice' are lowered to a new pseudo-instruction
named t2CALL_BTI that is later expanded to a bundle of {tBL,t2BTI}.

This patch is part of a series that adds support for the PACBTI-M extension of
the Armv8.1-M architecture, as detailed here:

https://community.arm.com/arm-community-blogs/b/architectures-and-processors-blog/posts/armv8-1-m-pointer-authentication-and-branch-target-identification-extension

The PACBTI-M specification can be found in the Armv8-M Architecture Reference
Manual:

https://developer.arm.com/documentation/ddi0553/latest

The following people contributed to this patch:

- Alexandros Lamprineas
- Ties Stuij

Reviewed By: labrinea

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

Added: 
clang/test/Driver/arm-bti-return-twice.c
llvm/test/CodeGen/ARM/setjmp-bti-basic.ll
llvm/test/CodeGen/ARM/setjmp-bti-outliner.ll

Modified: 
clang/docs/ClangCommandLineReference.rst
clang/include/clang/Driver/Options.td
clang/lib/Driver/ToolChains/Arch/ARM.cpp
llvm/lib/Target/ARM/ARM.td
llvm/lib/Target/ARM/ARMExpandPseudoInsts.cpp
llvm/lib/Target/ARM/ARMISelLowering.cpp
llvm/lib/Target/ARM/ARMISelLowering.h
llvm/lib/Target/ARM/ARMInstrThumb2.td
llvm/lib/Target/ARM/ARMSubtarget.h

Removed: 




diff  --git a/clang/docs/ClangCommandLineReference.rst 
b/clang/docs/ClangCommandLineReference.rst
index 8d4ffa6a38fc4..97807009fd911 100644
--- a/clang/docs/ClangCommandLineReference.rst
+++ b/clang/docs/ClangCommandLineReference.rst
@@ -3260,6 +3260,11 @@ Thread pointer access method (AArch32/AArch64 only)
 
 Allow memory accesses to be unaligned (AArch32/AArch64 only)
 
+.. option:: -mno-bti-at-return-twice
+
+Do not add a BTI instruction after a setjmp or other return-twice construct 
(Arm
+only)
+
 Hexagon
 ---
 .. option:: -mieee-rnd-near

diff  --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index 4e6dd20503446..7c257e4a474fa 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -3338,6 +3338,11 @@ def mno_fix_cortex_a53_835769 : Flag<["-"], 
"mno-fix-cortex-a53-835769">,
 def mmark_bti_property : Flag<["-"], "mmark-bti-property">,
   Group,
   HelpText<"Add .note.gnu.property with BTI to assembly files (AArch64 only)">;
+def mno_bti_at_return_twice : Flag<["-"], "mno-bti-at-return-twice">,
+  Group,
+  HelpText<"Do not add a BTI instruction after a setjmp or other"
+   " return-twice construct (Arm only)">;
+
 foreach i = {1-31} in
   def ffixed_x#i : Flag<["-"], "ffixed-x"#i>, Group,
 HelpText<"Reserve the x"#i#" register (AArch64/RISC-V only)">;

diff  --git a/clang/lib/Driver/ToolChains/Arch/ARM.cpp 
b/clang/lib/Driver/ToolChains/Arch/ARM.cpp
index 8d5c64d975502..e03bed0a6de64 100644
--- a/clang/lib/Driver/ToolChains/Arch/ARM.cpp
+++ b/clang/lib/Driver/ToolChains/Arch/ARM.cpp
@@ -875,6 +875,8 @@ void arm::getARMTargetFeatures(const Driver &D, const 
llvm::Triple &Triple,
 }
   }
 
+  if (Args.getLastArg(options::OPT_mno_bti_at_return_twice))
+Features.push_back("+no-bti-at-return-twice");
 }
 
 std::string arm::getARMArch(StringRef Arch, const llvm::Triple &Triple) {

diff  --git a/clang/test/Driver/arm-bti-return-twice.c 
b/clang/test/Driver/arm-bti-return-twice.c
new file mode 100644
index 0..c5cd385a34e20
--- /dev/null
+++ b/clang/test/Driver/arm-bti-return-twice.c
@@ -0,0 +1,7 @@
+// RUN: %clang -target arm-arm-none-eabi -march=armv8-m.main 
-mbranch-protection=bti \
+// RUN: -mno-bti-at-return-twice -### %s 2>&1 | FileCheck %s 
--check-prefix=FEAT
+// RUN: %clang -target arm-arm-none-eabi -march=armv8-m.main 
-mbranch-protection=bti \
+// RUN: -### %s 2>&1 | FileCheck %s --check-prefix=NOFEAT
+
+// FEAT: "+no-bti-at-return-twice"
+// NOFEAT-NOT: "+no-bti-at-return-twice"

diff  --git a/llvm/lib/Target/ARM/ARM.td b/llvm/lib/Target/ARM/ARM.td
index e03dd597eb650..8173fe4036a85 100644
--- a/llvm/lib/Target/ARM/ARM.td
+++ b/llvm/lib/Target/ARM/ARM.td
@@ -446,6 +446,11 @@ def FeaturePACBTI : SubtargetFeature<"pacbti", 
"HasPACBTI", "true",
  "Enable Pointer Authentication 
and Branch "
  "Target Identification">;
 
+def FeatureNoBTIAtReturnTwice : SubtargetFeature<"no-bti-at-return-twice",
+ "NoBTIAtReturnTwice", "true",
+   

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

2021-12-06 Thread Ties Stuij 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 rG0fbb17458a01: [ARM] Implement setjmp BTI placement for 
PACBTI-M (authored by stuij).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112427

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

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

[PATCH] D112421: [clang][ARM] PACBTI-M frontend support

2021-12-06 Thread Ties Stuij via Phabricator via cfe-commits
stuij added a comment.

@erichkeane : thanks so much for going through the trouble to see what the 
problem is!
I've put up a fix with your suggested change at https://reviews.llvm.org/D115141


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112421

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


[PATCH] D102669: [analyzer][ctu] Fix wrong 'multiple definitions' errors caused by space characters in lookup names when parsing the ctu index file

2021-12-06 Thread Balázs Benics via Phabricator via cfe-commits
steakhal added a comment.

Please mark comments 'done' if they are done.




Comment at: clang/lib/CrossTU/CrossTranslationUnit.cpp:154-172
+  // Find the length delimiter.
+  const size_t LengthDelimiter = LineRef.find(':');
+  if (StringRef::npos == LengthDelimiter)
+return false;
+
+  // Parse the length of LookupName as USRLength.
+  size_t USRLength = 0;

OikawaKirie wrote:
> steakhal wrote:
> > OikawaKirie wrote:
> > > steakhal wrote:
> > > > 
> > > The source of lookup name of the function being imported is function 
> > > `CrossTranslationUnitContext::getLookupName`. Keeping the length in the 
> > > mapping can avoid parsing the lookup name during importing.
> > Okay; you can copy the original StringRef to have that. But by consuming it 
> > on one path makes the code much more readable.
> > 
> The `getAsInterger` call can also check whether the content before the first 
> colon is an integer. Therefore, a sub-string operation is required here.
I don't doubt that your proposed way of doing this works and is efficient.
What I say is that I think there is room for improvement in the non-functional 
aspects, in the readability. However, it's not really a blocking issue, more of 
a personal taste.



Comment at: clang/test/Analysis/Inputs/ctu-lookup-name-with-space.cpp:7-8
+// CHECK-NOT: multiple definitions are found for the same key in index
+f([](char) -> int { return 42; });
+f([](char) -> bool { return true; });
+  }

OikawaKirie wrote:
> steakhal wrote:
> > I would rather put these into the `importee()`
> The lambda exprs will not be included in the CTU index file if they are 
> declared in a normal function.
I see.



Comment at: clang/test/Analysis/Inputs/ctu-lookup-name-with-space.cpp:13
+int importee(int X) {
+  return 1 / X;
+}

OikawaKirie wrote:
> steakhal wrote:
> > Why do you need to have a div by zero warning?
> I am not sure whether we should test if an external function can be correctly 
> imported. Hence, I wrote a div-by-zero bug here. A call to function 
> `clang_analyzer_warnIfReached` is also OK here.
> 
> As the imported lambda expr will not be called, I think I can only test 
> whether CTU works via another normal function.
AFAIK importing a function and import-related stuff are orthogonal to actually 
emitting bug reports produced by the analyzer. That being said, if the 
`importee()` would have an empty body, the observable behavior would remain the 
same. And this is what I propose now.


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

https://reviews.llvm.org/D102669

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


[PATCH] D115140: [ARM][clang] Option b-key must not affect __ARM_FEATURE_PAC_DEFAULT

2021-12-06 Thread Ties Stuij via Phabricator via cfe-commits
stuij updated this revision to Diff 392013.
stuij added a comment.

tickling the commit so the buildbot picks up the dependency


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D115140

Files:
  clang/lib/Basic/Targets/ARM.cpp
  clang/test/Preprocessor/arm-target-features.c


Index: clang/test/Preprocessor/arm-target-features.c
===
--- clang/test/Preprocessor/arm-target-features.c
+++ clang/test/Preprocessor/arm-target-features.c
@@ -881,20 +881,18 @@
 // RUN: %clang -target arm-arm-none-eabi -march=armv8.1-m.main -x c -E -dM %s 
-o - | FileCheck --check-prefixes=CHECK-NOBTI,CHECK-NOPAC %s
 // RUN: %clang -target arm-arm-none-eabi -march=armv8.1-m.main 
-mbranch-protection=bti -x c -E -dM %s -o - | FileCheck 
--check-prefixes=CHECK-BTI,CHECK-NOPAC %s
 // RUN: %clang -target arm-arm-none-eabi -march=armv8.1-m.main 
-mbranch-protection=pac-ret -x c -E -dM %s -o - | FileCheck 
--check-prefixes=CHECK-PAC,CHECK-NOBTI %s
-// RUN: %clang -target arm-arm-none-eabi -march=armv8.1-m.main 
-mbranch-protection=pac-ret+b-key -x c -E -dM %s -o - | FileCheck 
--check-prefixes=CHECK-PAC-BKEY,CHECK-NOBTI %s
+// RUN: %clang -target arm-arm-none-eabi -march=armv8.1-m.main 
-mbranch-protection=pac-ret+b-key -x c -E -dM %s -o - | FileCheck 
--check-prefixes=CHECK-PAC,CHECK-NOBTI %s
 // RUN: %clang -target arm-arm-none-eabi -march=armv8.1-m.main 
-mbranch-protection=pac-ret+leaf -x c -E -dM %s -o - | FileCheck 
--check-prefixes=CHECK-PAC-LEAF,CHECK-NOBTI %s
-// RUN: %clang -target arm-arm-none-eabi -march=armv8.1-m.main 
-mbranch-protection=pac-ret+b-key+leaf -x c -E -dM %s -o - | FileCheck 
--check-prefixes=CHECK-PAC-BKEY-LEAF,CHECK-NOBTI %s
+// RUN: %clang -target arm-arm-none-eabi -march=armv8.1-m.main 
-mbranch-protection=pac-ret+b-key+leaf -x c -E -dM %s -o - | FileCheck 
--check-prefixes=CHECK-PAC-LEAF,CHECK-NOBTI %s
 // RUN: %clang -target arm-arm-none-eabi -march=armv8.1-m.main 
-mbranch-protection=bti+pac-ret -x c -E -dM %s -o - | FileCheck 
--check-prefixes=CHECK-PAC,CHECK-BTI %s
-// RUN: %clang -target arm-arm-none-eabi -march=armv8.1-m.main 
-mbranch-protection=bti+pac-ret+b-key -x c -E -dM %s -o - | FileCheck 
--check-prefixes=CHECK-PAC-BKEY,CHECK-BTI %s
+// RUN: %clang -target arm-arm-none-eabi -march=armv8.1-m.main 
-mbranch-protection=bti+pac-ret+b-key -x c -E -dM %s -o - | FileCheck 
--check-prefixes=CHECK-PAC,CHECK-BTI %s
 // RUN: %clang -target arm-arm-none-eabi -march=armv8.1-m.main 
-mbranch-protection=bti+pac-ret+leaf -x c -E -dM %s -o - | FileCheck 
--check-prefixes=CHECK-PAC-LEAF,CHECK-BTI %s
-// RUN: %clang -target arm-arm-none-eabi -march=armv8.1-m.main 
-mbranch-protection=bti+pac-ret+b-key+leaf -x c -E -dM %s -o - | FileCheck 
--check-prefixes=CHECK-PAC-BKEY-LEAF,CHECK-BTI %s
+// RUN: %clang -target arm-arm-none-eabi -march=armv8.1-m.main 
-mbranch-protection=bti+pac-ret+b-key+leaf -x c -E -dM %s -o - | FileCheck 
--check-prefixes=CHECK-PAC-LEAF,CHECK-BTI %s
 // CHECK-NOBTI-NOT: #define __ARM_FEATURE_BTI_DEFAULT
 // CHECK-NOPAC-NOT: #define __ARM_FEATURE_PAC_DEFAULT
 // CHECK-BTI: #define __ARM_FEATURE_BTI_DEFAULT 1
 // CHECK-PAC: #define __ARM_FEATURE_PAC_DEFAULT 1
-// CHECK-PAC-BKEY: #define __ARM_FEATURE_PAC_DEFAULT 2
 // CHECK-PAC-LEAF: #define __ARM_FEATURE_PAC_DEFAULT 5
-// CHECK-PAC-BKEY-LEAF: #define __ARM_FEATURE_PAC_DEFAULT 6
 
 // RUN: %clang -target arm-arm-none-eabi -march=armv8.1-m.main -x c -E -dM %s 
-o - | FileCheck --check-prefixes=CHECK-NOBTI-EXT,CHECK-NOPAC-EXT %s
 // RUN: %clang -target arm-arm-none-eabi -march=armv7-m+pacbti -x c -E -dM %s 
-o - | FileCheck --check-prefixes=CHECK-PACBTI-EXT %s
Index: clang/lib/Basic/Targets/ARM.cpp
===
--- clang/lib/Basic/Targets/ARM.cpp
+++ clang/lib/Basic/Targets/ARM.cpp
@@ -911,7 +911,7 @@
 Builder.defineMacro("__ARM_FEATURE_BTI_DEFAULT", "1");
 
   if (Opts.hasSignReturnAddress()) {
-unsigned Value = Opts.isSignReturnAddressWithAKey() ? 1 : 2;
+unsigned Value = 1;
 if (Opts.isSignReturnAddressScopeAll())
   Value |= 1 << 2;
 Builder.defineMacro("__ARM_FEATURE_PAC_DEFAULT", Twine(Value));


Index: clang/test/Preprocessor/arm-target-features.c
===
--- clang/test/Preprocessor/arm-target-features.c
+++ clang/test/Preprocessor/arm-target-features.c
@@ -881,20 +881,18 @@
 // RUN: %clang -target arm-arm-none-eabi -march=armv8.1-m.main -x c -E -dM %s -o - | FileCheck --check-prefixes=CHECK-NOBTI,CHECK-NOPAC %s
 // RUN: %clang -target arm-arm-none-eabi -march=armv8.1-m.main -mbranch-protection=bti -x c -E -dM %s -o - | FileCheck --check-prefixes=CHECK-BTI,CHECK-NOPAC %s
 // RUN: %clang -target arm-arm-none-eabi -march=armv8.1-m.main -mbranch-protection=pac-ret -x c -E -dM %s -o - | FileCheck --check-prefixes=CHECK-PAC,CHECK-NOBTI %s
-// RUN: %clang -target

[PATCH] D114713: [AArch64][SVE][NEON] Add NEON-SVE-Bridge intrinsics

2021-12-06 Thread Matt Devereau via Phabricator via cfe-commits
MattDevereau updated this revision to Diff 392015.
MattDevereau added a comment.

replace numbers in BuiltinsAArch64NeonSVEBridge_cg.def with SVETypeFlags enum 
values


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D114713

Files:
  clang/include/clang/Basic/BuiltinsAArch64NeonSVEBridge.def
  clang/include/clang/Basic/BuiltinsAArch64NeonSVEBridge_cg.def
  clang/include/clang/Basic/BuiltinsSVE.def
  clang/lib/Basic/Targets/AArch64.cpp
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/lib/Headers/CMakeLists.txt
  clang/lib/Headers/arm_neon_sve_bridge.h
  
clang/test/CodeGen/aarch64_neon_sve_bridge_intrinsics/acle_neon_sve_bridge_dup_neonq.c
  
clang/test/CodeGen/aarch64_neon_sve_bridge_intrinsics/acle_neon_sve_bridge_get_neonq.c
  
clang/test/CodeGen/aarch64_neon_sve_bridge_intrinsics/acle_neon_sve_bridge_set_neonq.c

Index: clang/test/CodeGen/aarch64_neon_sve_bridge_intrinsics/acle_neon_sve_bridge_set_neonq.c
===
--- /dev/null
+++ clang/test/CodeGen/aarch64_neon_sve_bridge_intrinsics/acle_neon_sve_bridge_set_neonq.c
@@ -0,0 +1,183 @@
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py
+// REQUIRES: aarch64-registered-target
+// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +neon -target-feature +sve -target-feature +bf16 -fallow-half-arguments-and-returns -S -O1 -Werror -Wall -emit-llvm -o - %s | FileCheck %s
+// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +neon -target-feature +sve -target-feature +bf16 -fallow-half-arguments-and-returns -S -O1 -Werror -Wall -emit-llvm -o - -x c++ %s | FileCheck %s -check-prefix=CPP-CHECK
+// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +neon -target-feature +sve -target-feature +bf16 -fallow-half-arguments-and-returns -S -O1 -Werror -Wall -o /dev/null %s
+// RUN: %clang_cc1 -DSVE_OVERLOADED_FORMS -triple aarch64-none-linux-gnu -target-feature +neon -target-feature +sve -target-feature +bf16 -fallow-half-arguments-and-returns -S -O1 -Werror -Wall -emit-llvm -o - %s | FileCheck %s
+// RUN: %clang_cc1 -DSVE_OVERLOADED_FORMS -triple aarch64-none-linux-gnu -target-feature +neon -target-feature +sve -target-feature +bf16 -fallow-half-arguments-and-returns -S -O1 -Werror -Wall -emit-llvm -o - -x c++ %s | FileCheck %s -check-prefix=CPP-CHECK
+#include 
+
+#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
+
+// CHECK-LABEL: @test_svset_neonq_s8(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[TMP0:%.*]] = call  @llvm.experimental.vector.insert.nxv16i8.v16i8( [[S:%.*]], <16 x i8> [[N:%.*]], i64 0)
+// CHECK-NEXT:ret  [[TMP0]]
+//
+// CPP-CHECK-LABEL: @_Z19test_svset_neonq_s8u10__SVInt8_t11__Int8x16_t(
+// CPP-CHECK-NEXT:  entry:
+// CPP-CHECK-NEXT:[[TMP0:%.*]] = call  @llvm.experimental.vector.insert.nxv16i8.v16i8( [[S:%.*]], <16 x i8> [[N:%.*]], i64 0)
+// CPP-CHECK-NEXT:ret  [[TMP0]]
+//
+svint8_t test_svset_neonq_s8(svint8_t s, int8x16_t n) {
+  return SVE_ACLE_FUNC(svset_neonq, _s8, , )(s, n);
+}
+
+// CHECK-LABEL: @test_svset_neonq_s16(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[TMP0:%.*]] = call  @llvm.experimental.vector.insert.nxv8i16.v8i16( [[S:%.*]], <8 x i16> [[N:%.*]], i64 0)
+// CHECK-NEXT:ret  [[TMP0]]
+//
+// CPP-CHECK-LABEL: @_Z20test_svset_neonq_s16u11__SVInt16_t11__Int16x8_t(
+// CPP-CHECK-NEXT:  entry:
+// CPP-CHECK-NEXT:[[TMP0:%.*]] = call  @llvm.experimental.vector.insert.nxv8i16.v8i16( [[S:%.*]], <8 x i16> [[N:%.*]], i64 0)
+// CPP-CHECK-NEXT:ret  [[TMP0]]
+//
+svint16_t test_svset_neonq_s16(svint16_t s, int16x8_t n) {
+  return SVE_ACLE_FUNC(svset_neonq, _s16, , )(s, n);
+}
+
+// CHECK-LABEL: @test_svset_neonq_s32(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[TMP0:%.*]] = call  @llvm.experimental.vector.insert.nxv4i32.v4i32( [[S:%.*]], <4 x i32> [[N:%.*]], i64 0)
+// CHECK-NEXT:ret  [[TMP0]]
+//
+// CPP-CHECK-LABEL: @_Z20test_svset_neonq_s32u11__SVInt32_t11__Int32x4_t(
+// CPP-CHECK-NEXT:  entry:
+// CPP-CHECK-NEXT:[[TMP0:%.*]] = call  @llvm.experimental.vector.insert.nxv4i32.v4i32( [[S:%.*]], <4 x i32> [[N:%.*]], i64 0)
+// CPP-CHECK-NEXT:ret  [[TMP0]]
+//
+svint32_t test_svset_neonq_s32(svint32_t s, int32x4_t n) {
+  return SVE_ACLE_FUNC(svset_neonq, _s32, , )(s, n);
+}
+
+// CHECK-LABEL: @test_svset_neonq_s64(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[TMP0:%.*]] = call  @llvm.experimental.vector.insert.nxv2i64.v2i64( [[S:%.*]], <2 x i64> [[N:%.*]], i64 0)
+// CHECK-NEXT:ret  [[TMP0]]
+//
+// CPP-CHECK-LABEL: @_Z20test_svset_neonq_s64u11__SVInt64_t11__Int64x2_t(
+// CPP-CHECK-NEXT:  entry:
+// CPP-CHECK-NEXT:[[TMP0:%.*]] = call  @llvm.experimental.vector.insert.nxv2i64.v2i64( [[S:%.*]], <2 x i64> [[N:%.*]], i64 0

[PATCH] D114713: [AArch64][SVE][NEON] Add NEON-SVE-Bridge intrinsics

2021-12-06 Thread Matt Devereau via Phabricator via cfe-commits
MattDevereau marked an inline comment as done.
MattDevereau added a comment.

clang-format is upset about this ordering:

#include "clang/Basic/arm_sve_builtin_cg.inc"
#include "clang/Basic/BuiltinsAArch64NeonSVEBridge_cg.def"

but swapping the order causes all SVE tests to fail. I'm ignoring the 
clang-format error for this




Comment at: clang/include/clang/Basic/BuiltinsAArch64NeonSVEBridge_cg.def:37
+SVEMAP2(svdup_neonq_f64, 3),
+SVEMAP2(svdup_neonq_bf16, 1),
+#endif

peterwaller-arm wrote:
> The second argument is a 'flags' field and these values don't look right.
> 
> Refs:
> 
> * [[ 
> https://github.com/llvm/llvm-project/blob/84b978da3b80b986327a830c01e32f12cefe86b3/clang/utils/TableGen/SveEmitter.cpp#L1339
>  | SVEMAP2 emitted by tablegen ]]
> * [[ 
> https://github.com/llvm/llvm-project/blob/84b978da3b80b986327a830c01e32f12cefe86b3/clang/include/clang/Basic/arm_sve.td#L137-L149
>  | Element types ]]
> * [[ 
> https://github.com/llvm/llvm-project/blob/main/clang/lib/CodeGen/CGBuiltin.cpp#L9070
>  | Flags used in CGBuiltin ]]
> 
> The flags are a generated enum and live in 
> `clang/include/clang/Basic/arm_sve_typeflags.inc` -- I think you'll need to 
> #include this with `LLVM_GET_SVE_ELTTYPES` defined, and then you can write it 
> symbolically rather than using a literal numeric value.
SVETypeFlags enums are already available by this stage so there's no need for 
any includes. I've replaced the numbers with the enums


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D114713

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


[PATCH] D115103: Leak Sanitizer port to Windows

2021-12-06 Thread Clemens Wasser via Phabricator via cfe-commits
clemenswasser updated this revision to Diff 392017.
clemenswasser added a comment.

Remove wrong interceptors


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

https://reviews.llvm.org/D115103

Files:
  clang/lib/Driver/ToolChains/MSVC.cpp
  compiler-rt/cmake/config-ix.cmake
  compiler-rt/lib/lsan/CMakeLists.txt
  compiler-rt/lib/lsan/lsan.h
  compiler-rt/lib/lsan/lsan_allocator.cpp
  compiler-rt/lib/lsan/lsan_common.cpp
  compiler-rt/lib/lsan/lsan_common.h
  compiler-rt/lib/lsan/lsan_common_win.cpp
  compiler-rt/lib/lsan/lsan_interceptors.cpp
  compiler-rt/lib/lsan/lsan_win.cpp
  compiler-rt/lib/lsan/lsan_win.h
  compiler-rt/lib/sanitizer_common/CMakeLists.txt
  compiler-rt/lib/sanitizer_common/sanitizer_stoptheworld_win.cpp
  compiler-rt/test/lsan/lit.common.cfg.py

Index: compiler-rt/test/lsan/lit.common.cfg.py
===
--- compiler-rt/test/lsan/lit.common.cfg.py
+++ compiler-rt/test/lsan/lit.common.cfg.py
@@ -79,7 +79,8 @@
 supported_linux = (not config.android) and config.host_os == 'Linux' and config.host_arch in ['aarch64', 'x86_64', 'ppc64', 'ppc64le', 'mips64', 'riscv64', 'arm', 'armhf', 'armv7l', 's390x']
 supported_darwin = config.host_os == 'Darwin' and config.target_arch in ['x86_64']
 supported_netbsd = config.host_os == 'NetBSD' and config.target_arch in ['x86_64', 'i386']
-if not (supported_android or supported_linux or supported_darwin or supported_netbsd):
+supported_windows = config.host_os == 'Windows'
+if not (supported_android or supported_linux or supported_darwin or supported_netbsd or supported_windows):
   config.unsupported = True
 
 # Don't support Thumb due to broken fast unwinder
Index: compiler-rt/lib/sanitizer_common/sanitizer_stoptheworld_win.cpp
===
--- /dev/null
+++ compiler-rt/lib/sanitizer_common/sanitizer_stoptheworld_win.cpp
@@ -0,0 +1,138 @@
+//===-- sanitizer_stoptheworld_win.cpp ===//
+//
+// 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
+//
+//===--===//
+//
+// See sanitizer_stoptheworld.h for details.
+//
+//===--===//
+
+#include "sanitizer_common.h"
+#include "sanitizer_internal_defs.h"
+#include "sanitizer_platform.h"
+
+#if SANITIZER_WINDOWS
+
+#  define WIN32_LEAN_AND_MEAN
+#  include 
+
+// windows.h needs to be included before tlhelp32.h
+#  include 
+
+#  include "sanitizer_stoptheworld.h"
+
+namespace __sanitizer {
+
+struct SuspendedThreadsListWindows final : public SuspendedThreadsList {
+  InternalMmapVector threadHandles;
+  InternalMmapVector threadIds;
+
+  SuspendedThreadsListWindows() {
+threadIds.reserve(1024);
+threadHandles.reserve(1024);
+  }
+
+  PtraceRegistersStatus GetRegistersAndSP(uptr index,
+  InternalMmapVector *buffer,
+  uptr *sp) const override;
+
+  tid_t GetThreadID(uptr index) const override;
+  uptr ThreadCount() const override;
+};
+
+PtraceRegistersStatus SuspendedThreadsListWindows::GetRegistersAndSP(
+uptr index, InternalMmapVector *buffer, uptr *sp) const {
+  CHECK_LT(index, threadHandles.size());
+
+  CONTEXT thread_context;
+  thread_context.ContextFlags = CONTEXT_ALL;
+  CHECK(GetThreadContext(threadHandles[index], &thread_context));
+
+  buffer->resize(RoundUpTo(sizeof(thread_context), sizeof(uptr)) /
+ sizeof(uptr));
+  internal_memcpy(buffer->data(), &thread_context, sizeof(thread_context));
+
+  *sp = thread_context.Rsp;
+
+  return REGISTERS_AVAILABLE;
+}
+
+tid_t SuspendedThreadsListWindows::GetThreadID(uptr index) const {
+  CHECK_LT(index, threadIds.size());
+  return threadIds[index];
+}
+
+uptr SuspendedThreadsListWindows::ThreadCount() const {
+  return threadIds.size();
+}
+
+struct RunThreadArgs {
+  StopTheWorldCallback callback;
+  void *argument;
+};
+
+DWORD WINAPI RunThread(void *argument) {
+  RunThreadArgs *run_args = (RunThreadArgs *)argument;
+  const HANDLE threads = CreateToolhelp32Snapshot(TH32CS_SNAPTHREAD, 0);
+
+  CHECK(threads != INVALID_HANDLE_VALUE);
+
+  const DWORD this_thread = GetCurrentThreadId();
+  const DWORD this_process = GetCurrentProcessId();
+
+  SuspendedThreadsListWindows suspended_threads_list;
+
+  THREADENTRY32 thread_entry;
+  thread_entry.dwSize = sizeof(thread_entry);
+  if (Thread32First(threads, &thread_entry)) {
+do {
+  if (thread_entry.dwSize >=
+  FIELD_OFFSET(THREADENTRY32, th32OwnerProcessID) +
+  sizeof(thread_entry.th32OwnerProcessID)) {
+if (thread_entry.th32ThreadID == this_thread ||
+thread_entry.th32OwnerProcessID != this_process)
+

[PATCH] D115140: [ARM][clang] Option b-key must not affect __ARM_FEATURE_PAC_DEFAULT

2021-12-06 Thread Ties Stuij via Phabricator via cfe-commits
stuij updated this revision to Diff 392021.
stuij added a comment.

another tickle


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D115140

Files:
  clang/lib/Basic/Targets/ARM.cpp
  clang/test/Preprocessor/arm-target-features.c


Index: clang/test/Preprocessor/arm-target-features.c
===
--- clang/test/Preprocessor/arm-target-features.c
+++ clang/test/Preprocessor/arm-target-features.c
@@ -881,20 +881,18 @@
 // RUN: %clang -target arm-arm-none-eabi -march=armv8.1-m.main -x c -E -dM %s 
-o - | FileCheck --check-prefixes=CHECK-NOBTI,CHECK-NOPAC %s
 // RUN: %clang -target arm-arm-none-eabi -march=armv8.1-m.main 
-mbranch-protection=bti -x c -E -dM %s -o - | FileCheck 
--check-prefixes=CHECK-BTI,CHECK-NOPAC %s
 // RUN: %clang -target arm-arm-none-eabi -march=armv8.1-m.main 
-mbranch-protection=pac-ret -x c -E -dM %s -o - | FileCheck 
--check-prefixes=CHECK-PAC,CHECK-NOBTI %s
-// RUN: %clang -target arm-arm-none-eabi -march=armv8.1-m.main 
-mbranch-protection=pac-ret+b-key -x c -E -dM %s -o - | FileCheck 
--check-prefixes=CHECK-PAC-BKEY,CHECK-NOBTI %s
+// RUN: %clang -target arm-arm-none-eabi -march=armv8.1-m.main 
-mbranch-protection=pac-ret+b-key -x c -E -dM %s -o - | FileCheck 
--check-prefixes=CHECK-PAC,CHECK-NOBTI %s
 // RUN: %clang -target arm-arm-none-eabi -march=armv8.1-m.main 
-mbranch-protection=pac-ret+leaf -x c -E -dM %s -o - | FileCheck 
--check-prefixes=CHECK-PAC-LEAF,CHECK-NOBTI %s
-// RUN: %clang -target arm-arm-none-eabi -march=armv8.1-m.main 
-mbranch-protection=pac-ret+b-key+leaf -x c -E -dM %s -o - | FileCheck 
--check-prefixes=CHECK-PAC-BKEY-LEAF,CHECK-NOBTI %s
+// RUN: %clang -target arm-arm-none-eabi -march=armv8.1-m.main 
-mbranch-protection=pac-ret+b-key+leaf -x c -E -dM %s -o - | FileCheck 
--check-prefixes=CHECK-PAC-LEAF,CHECK-NOBTI %s
 // RUN: %clang -target arm-arm-none-eabi -march=armv8.1-m.main 
-mbranch-protection=bti+pac-ret -x c -E -dM %s -o - | FileCheck 
--check-prefixes=CHECK-PAC,CHECK-BTI %s
-// RUN: %clang -target arm-arm-none-eabi -march=armv8.1-m.main 
-mbranch-protection=bti+pac-ret+b-key -x c -E -dM %s -o - | FileCheck 
--check-prefixes=CHECK-PAC-BKEY,CHECK-BTI %s
+// RUN: %clang -target arm-arm-none-eabi -march=armv8.1-m.main 
-mbranch-protection=bti+pac-ret+b-key -x c -E -dM %s -o - | FileCheck 
--check-prefixes=CHECK-PAC,CHECK-BTI %s
 // RUN: %clang -target arm-arm-none-eabi -march=armv8.1-m.main 
-mbranch-protection=bti+pac-ret+leaf -x c -E -dM %s -o - | FileCheck 
--check-prefixes=CHECK-PAC-LEAF,CHECK-BTI %s
-// RUN: %clang -target arm-arm-none-eabi -march=armv8.1-m.main 
-mbranch-protection=bti+pac-ret+b-key+leaf -x c -E -dM %s -o - | FileCheck 
--check-prefixes=CHECK-PAC-BKEY-LEAF,CHECK-BTI %s
+// RUN: %clang -target arm-arm-none-eabi -march=armv8.1-m.main 
-mbranch-protection=bti+pac-ret+b-key+leaf -x c -E -dM %s -o - | FileCheck 
--check-prefixes=CHECK-PAC-LEAF,CHECK-BTI %s
 // CHECK-NOBTI-NOT: #define __ARM_FEATURE_BTI_DEFAULT
 // CHECK-NOPAC-NOT: #define __ARM_FEATURE_PAC_DEFAULT
 // CHECK-BTI: #define __ARM_FEATURE_BTI_DEFAULT 1
 // CHECK-PAC: #define __ARM_FEATURE_PAC_DEFAULT 1
-// CHECK-PAC-BKEY: #define __ARM_FEATURE_PAC_DEFAULT 2
 // CHECK-PAC-LEAF: #define __ARM_FEATURE_PAC_DEFAULT 5
-// CHECK-PAC-BKEY-LEAF: #define __ARM_FEATURE_PAC_DEFAULT 6
 
 // RUN: %clang -target arm-arm-none-eabi -march=armv8.1-m.main -x c -E -dM %s 
-o - | FileCheck --check-prefixes=CHECK-NOBTI-EXT,CHECK-NOPAC-EXT %s
 // RUN: %clang -target arm-arm-none-eabi -march=armv7-m+pacbti -x c -E -dM %s 
-o - | FileCheck --check-prefixes=CHECK-PACBTI-EXT %s
Index: clang/lib/Basic/Targets/ARM.cpp
===
--- clang/lib/Basic/Targets/ARM.cpp
+++ clang/lib/Basic/Targets/ARM.cpp
@@ -911,7 +911,7 @@
 Builder.defineMacro("__ARM_FEATURE_BTI_DEFAULT", "1");
 
   if (Opts.hasSignReturnAddress()) {
-unsigned Value = Opts.isSignReturnAddressWithAKey() ? 1 : 2;
+unsigned Value = 1;
 if (Opts.isSignReturnAddressScopeAll())
   Value |= 1 << 2;
 Builder.defineMacro("__ARM_FEATURE_PAC_DEFAULT", Twine(Value));


Index: clang/test/Preprocessor/arm-target-features.c
===
--- clang/test/Preprocessor/arm-target-features.c
+++ clang/test/Preprocessor/arm-target-features.c
@@ -881,20 +881,18 @@
 // RUN: %clang -target arm-arm-none-eabi -march=armv8.1-m.main -x c -E -dM %s -o - | FileCheck --check-prefixes=CHECK-NOBTI,CHECK-NOPAC %s
 // RUN: %clang -target arm-arm-none-eabi -march=armv8.1-m.main -mbranch-protection=bti -x c -E -dM %s -o - | FileCheck --check-prefixes=CHECK-BTI,CHECK-NOPAC %s
 // RUN: %clang -target arm-arm-none-eabi -march=armv8.1-m.main -mbranch-protection=pac-ret -x c -E -dM %s -o - | FileCheck --check-prefixes=CHECK-PAC,CHECK-NOBTI %s
-// RUN: %clang -target arm-arm-none-eabi -march=armv8.1-m.main -mbr

[PATCH] D115140: [ARM][clang] Option b-key must not affect __ARM_FEATURE_PAC_DEFAULT

2021-12-06 Thread Daniel Kiss via Phabricator via cfe-commits
danielkiss added a comment.

I think rejecting\warning the `b-key` from the command line maybe a more 
developer friendly way.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D115140

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


[clang] 34a43f2 - [Clang] Ignore CLANG_DEFAULT_LINKER for custom-linker toolchains

2021-12-06 Thread Simon Moll via cfe-commits

Author: Simon Moll
Date: 2021-12-06T13:31:51+01:00
New Revision: 34a43f2115af79f896c889433c57f3b400e9f2c6

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

LOG: [Clang] Ignore CLANG_DEFAULT_LINKER for custom-linker toolchains

Before, the CLANG_DEFAULT_LINKER cmake option was a global override for
the linker that shall be used on all toolchains.  The linker binary
specified that way may not be available on toolchains with custom
linkers. Eg, the only linker for VE is named 'nld' - any other linker
invalidates the toolchain.

This patch removes the hard override and instead lets the generic
toolchain implementation default to CLANG_DEFAULT_LINKER.  Toolchains
can now deviate with a custom linker name or deliberatly default to
CLANG_DEFAULT_LINKER.

Reviewed By: MaskRay, phosek

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

Added: 


Modified: 
clang/include/clang/Driver/ToolChain.h
clang/lib/Driver/ToolChain.cpp
clang/test/Driver/ve-toolchain.c
clang/test/Driver/ve-toolchain.cpp

Removed: 




diff  --git a/clang/include/clang/Driver/ToolChain.h 
b/clang/include/clang/Driver/ToolChain.h
index e7b13eec3fc1..e55f8219feb0 100644
--- a/clang/include/clang/Driver/ToolChain.h
+++ b/clang/include/clang/Driver/ToolChain.h
@@ -420,7 +420,7 @@ class ToolChain {
   }
 
   /// GetDefaultLinker - Get the default linker to use.
-  virtual const char *getDefaultLinker() const { return "ld"; }
+  virtual const char *getDefaultLinker() const;
 
   /// GetDefaultRuntimeLibType - Get the default runtime library variant to 
use.
   virtual RuntimeLibType GetDefaultRuntimeLibType() const {

diff  --git a/clang/lib/Driver/ToolChain.cpp b/clang/lib/Driver/ToolChain.cpp
index ac033dd427c2..d92cbe21960e 100644
--- a/clang/lib/Driver/ToolChain.cpp
+++ b/clang/lib/Driver/ToolChain.cpp
@@ -541,6 +541,12 @@ std::string ToolChain::GetProgramPath(const char *Name) 
const {
   return D.GetProgramPath(Name, *this);
 }
 
+const char *ToolChain::getDefaultLinker() const {
+  if (CLANG_DEFAULT_LINKER[0] == '\0')
+return "ld";
+  return CLANG_DEFAULT_LINKER;
+}
+
 std::string ToolChain::GetLinkerPath(bool *LinkerIsLLD) const {
   if (LinkerIsLLD)
 *LinkerIsLLD = false;
@@ -548,7 +554,7 @@ std::string ToolChain::GetLinkerPath(bool *LinkerIsLLD) 
const {
   // Get -fuse-ld= first to prevent -Wunused-command-line-argument. -fuse-ld= 
is
   // considered as the linker flavor, e.g. "bfd", "gold", or "lld".
   const Arg* A = Args.getLastArg(options::OPT_fuse_ld_EQ);
-  StringRef UseLinker = A ? A->getValue() : CLANG_DEFAULT_LINKER;
+  StringRef UseLinker = A ? A->getValue() : "";
 
   // --ld-path= takes precedence over -fuse-ld= and specifies the executable
   // name. -B, COMPILER_PATH and PATH and consulted if the value does not

diff  --git a/clang/test/Driver/ve-toolchain.c 
b/clang/test/Driver/ve-toolchain.c
index 8878bd8f83cc..2c8f211d143f 100644
--- a/clang/test/Driver/ve-toolchain.c
+++ b/clang/test/Driver/ve-toolchain.c
@@ -61,10 +61,10 @@
 /// Checking -fintegrated-as
 
 // RUN: %clang -### -target ve \
-// RUN:-x assembler -fuse-ld=ld %s 2>&1 | \
+// RUN:-x assembler %s 2>&1 | \
 // RUN:FileCheck -check-prefix=AS %s
 // RUN: %clang -### -target ve \
-// RUN:-fno-integrated-as -fuse-ld=ld -x assembler %s 2>&1 | \
+// RUN:-fno-integrated-as -x assembler %s 2>&1 | \
 // RUN:FileCheck -check-prefix=NAS %s
 
 // AS: clang{{.*}} "-cc1as"
@@ -83,7 +83,6 @@
 // RUN: %clang -### -target ve-unknown-linux-gnu \
 // RUN: --sysroot %S/Inputs/basic_ve_tree \
 // RUN: -resource-dir=%S/Inputs/basic_ve_tree/resource_dir \
-// RUN: -fuse-ld=ld \
 // RUN: %s 2>&1 | FileCheck -check-prefix=DEF %s
 
 // DEF:  clang{{.*}}" "-cc1"

diff  --git a/clang/test/Driver/ve-toolchain.cpp 
b/clang/test/Driver/ve-toolchain.cpp
index 7666cfbfe8b2..2519a5f97dff 100644
--- a/clang/test/Driver/ve-toolchain.cpp
+++ b/clang/test/Driver/ve-toolchain.cpp
@@ -110,10 +110,10 @@
 /// Checking -fintegrated-as
 
 // RUN: %clangxx -### -target ve-unknown-linux-gnu \
-// RUN: -x assembler -fuse-ld=ld %s 2>&1 | \
+// RUN: -x assembler %s 2>&1 | \
 // RUN:FileCheck -check-prefix=AS %s
 // RUN: %clangxx -### -target ve-unknown-linux-gnu \
-// RUN: -fno-integrated-as -x assembler -fuse-ld=ld %s 2>&1 | \
+// RUN: -fno-integrated-as -x assembler %s 2>&1 | \
 // RUN:FileCheck -check-prefix=NAS %s
 
 // AS: clang{{.*}} "-cc1as"
@@ -131,7 +131,6 @@
 
 // RUN: %clangxx -### -target ve-unknown-linux-gnu \
 // RUN: --sysroot %S/Inputs/basic_ve_tree \
-// RUN: -fuse-ld=ld \
 // RUN: -resource-dir=%S/Inputs/basic_ve_tree/resource_dir \
 // RUN: --stdlib=c++ %s 2>&1 | FileCheck -check-prefix=DEF %s
 



___

[PATCH] D115045: [Clang] Ignore CLANG_DEFAULT_LINKER for custom-linker toolchains

2021-12-06 Thread Simon Moll via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG34a43f2115af: [Clang] Ignore CLANG_DEFAULT_LINKER for 
custom-linker toolchains (authored by simoll).

Changed prior to commit:
  https://reviews.llvm.org/D115045?vs=391998&id=392022#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D115045

Files:
  clang/include/clang/Driver/ToolChain.h
  clang/lib/Driver/ToolChain.cpp
  clang/test/Driver/ve-toolchain.c
  clang/test/Driver/ve-toolchain.cpp


Index: clang/test/Driver/ve-toolchain.cpp
===
--- clang/test/Driver/ve-toolchain.cpp
+++ clang/test/Driver/ve-toolchain.cpp
@@ -110,10 +110,10 @@
 /// Checking -fintegrated-as
 
 // RUN: %clangxx -### -target ve-unknown-linux-gnu \
-// RUN: -x assembler -fuse-ld=ld %s 2>&1 | \
+// RUN: -x assembler %s 2>&1 | \
 // RUN:FileCheck -check-prefix=AS %s
 // RUN: %clangxx -### -target ve-unknown-linux-gnu \
-// RUN: -fno-integrated-as -x assembler -fuse-ld=ld %s 2>&1 | \
+// RUN: -fno-integrated-as -x assembler %s 2>&1 | \
 // RUN:FileCheck -check-prefix=NAS %s
 
 // AS: clang{{.*}} "-cc1as"
@@ -131,7 +131,6 @@
 
 // RUN: %clangxx -### -target ve-unknown-linux-gnu \
 // RUN: --sysroot %S/Inputs/basic_ve_tree \
-// RUN: -fuse-ld=ld \
 // RUN: -resource-dir=%S/Inputs/basic_ve_tree/resource_dir \
 // RUN: --stdlib=c++ %s 2>&1 | FileCheck -check-prefix=DEF %s
 
Index: clang/test/Driver/ve-toolchain.c
===
--- clang/test/Driver/ve-toolchain.c
+++ clang/test/Driver/ve-toolchain.c
@@ -61,10 +61,10 @@
 /// Checking -fintegrated-as
 
 // RUN: %clang -### -target ve \
-// RUN:-x assembler -fuse-ld=ld %s 2>&1 | \
+// RUN:-x assembler %s 2>&1 | \
 // RUN:FileCheck -check-prefix=AS %s
 // RUN: %clang -### -target ve \
-// RUN:-fno-integrated-as -fuse-ld=ld -x assembler %s 2>&1 | \
+// RUN:-fno-integrated-as -x assembler %s 2>&1 | \
 // RUN:FileCheck -check-prefix=NAS %s
 
 // AS: clang{{.*}} "-cc1as"
@@ -83,7 +83,6 @@
 // RUN: %clang -### -target ve-unknown-linux-gnu \
 // RUN: --sysroot %S/Inputs/basic_ve_tree \
 // RUN: -resource-dir=%S/Inputs/basic_ve_tree/resource_dir \
-// RUN: -fuse-ld=ld \
 // RUN: %s 2>&1 | FileCheck -check-prefix=DEF %s
 
 // DEF:  clang{{.*}}" "-cc1"
Index: clang/lib/Driver/ToolChain.cpp
===
--- clang/lib/Driver/ToolChain.cpp
+++ clang/lib/Driver/ToolChain.cpp
@@ -541,6 +541,12 @@
   return D.GetProgramPath(Name, *this);
 }
 
+const char *ToolChain::getDefaultLinker() const {
+  if (CLANG_DEFAULT_LINKER[0] == '\0')
+return "ld";
+  return CLANG_DEFAULT_LINKER;
+}
+
 std::string ToolChain::GetLinkerPath(bool *LinkerIsLLD) const {
   if (LinkerIsLLD)
 *LinkerIsLLD = false;
@@ -548,7 +554,7 @@
   // Get -fuse-ld= first to prevent -Wunused-command-line-argument. -fuse-ld= 
is
   // considered as the linker flavor, e.g. "bfd", "gold", or "lld".
   const Arg* A = Args.getLastArg(options::OPT_fuse_ld_EQ);
-  StringRef UseLinker = A ? A->getValue() : CLANG_DEFAULT_LINKER;
+  StringRef UseLinker = A ? A->getValue() : "";
 
   // --ld-path= takes precedence over -fuse-ld= and specifies the executable
   // name. -B, COMPILER_PATH and PATH and consulted if the value does not
Index: clang/include/clang/Driver/ToolChain.h
===
--- clang/include/clang/Driver/ToolChain.h
+++ clang/include/clang/Driver/ToolChain.h
@@ -420,7 +420,7 @@
   }
 
   /// GetDefaultLinker - Get the default linker to use.
-  virtual const char *getDefaultLinker() const { return "ld"; }
+  virtual const char *getDefaultLinker() const;
 
   /// GetDefaultRuntimeLibType - Get the default runtime library variant to 
use.
   virtual RuntimeLibType GetDefaultRuntimeLibType() const {


Index: clang/test/Driver/ve-toolchain.cpp
===
--- clang/test/Driver/ve-toolchain.cpp
+++ clang/test/Driver/ve-toolchain.cpp
@@ -110,10 +110,10 @@
 /// Checking -fintegrated-as
 
 // RUN: %clangxx -### -target ve-unknown-linux-gnu \
-// RUN: -x assembler -fuse-ld=ld %s 2>&1 | \
+// RUN: -x assembler %s 2>&1 | \
 // RUN:FileCheck -check-prefix=AS %s
 // RUN: %clangxx -### -target ve-unknown-linux-gnu \
-// RUN: -fno-integrated-as -x assembler -fuse-ld=ld %s 2>&1 | \
+// RUN: -fno-integrated-as -x assembler %s 2>&1 | \
 // RUN:FileCheck -check-prefix=NAS %s
 
 // AS: clang{{.*}} "-cc1as"
@@ -131,7 +131,6 @@
 
 // RUN: %clangxx -### -target ve-unknown-linux-gnu \
 // RUN: --sysroot %S/Inputs/basic_ve_tree \
-// RUN: -fuse-ld=ld \
 // RUN: -resource-dir=%S/Inputs/basic_ve_tree/resource_dir \
 // RUN: --stdlib=c++ %s 2>&1 | FileCheck -check-prefix=DEF %s
 
Index: cl

[PATCH] D114413: [OpenMPIRBuilder] Implement static-chunked workshare-loop schedules.

2021-12-06 Thread Peixin Qiao via Phabricator via cfe-commits
peixin added a comment.

In D114413#3166979 , @Meinersbur 
wrote:

> In D114413#3160044 , @peixin wrote:
>
>> In D114413#3159095 , @Meinersbur 
>> wrote:
>>
>>> In D114413#3154936 , @peixin 
>>> wrote:
>>>
 
>>
>> `getPreheader()` was in `OMPIRBuilder.cpp` before you rebase in your last 
>> update here. That's why I let you rebase since I failed to git apply your 
>> last patch in main branch. It's not important now. Please forget about that.
>
> D114368  (which this patch depends on) 
> moves `getPreheder()` to the `.cpp` files (because it has become more than a 
> simple getter)

Thanks a lot. Now I get it.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D114413

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


[PATCH] D114080: [SYCL] Diagnose uses of zero length arrays

2021-12-06 Thread Mariya Podchishchaeva via Phabricator via cfe-commits
Fznamznon added a comment.

Ping.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D114080

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


[PATCH] D102669: [analyzer][ctu] Fix wrong 'multiple definitions' errors caused by space characters in lookup names when parsing the ctu index file

2021-12-06 Thread Ella Ma via Phabricator via cfe-commits
OikawaKirie added inline comments.



Comment at: clang/lib/CrossTU/CrossTranslationUnit.cpp:154-172
+  // Find the length delimiter.
+  const size_t LengthDelimiter = LineRef.find(':');
+  if (StringRef::npos == LengthDelimiter)
+return false;
+
+  // Parse the length of LookupName as USRLength.
+  size_t USRLength = 0;

steakhal wrote:
> OikawaKirie wrote:
> > steakhal wrote:
> > > OikawaKirie wrote:
> > > > steakhal wrote:
> > > > > 
> > > > The source of lookup name of the function being imported is function 
> > > > `CrossTranslationUnitContext::getLookupName`. Keeping the length in the 
> > > > mapping can avoid parsing the lookup name during importing.
> > > Okay; you can copy the original StringRef to have that. But by consuming 
> > > it on one path makes the code much more readable.
> > > 
> > The `getAsInterger` call can also check whether the content before the 
> > first colon is an integer. Therefore, a sub-string operation is required 
> > here.
> I don't doubt that your proposed way of doing this works and is efficient.
> What I say is that I think there is room for improvement in the 
> non-functional aspects, in the readability. However, it's not really a 
> blocking issue, more of a personal taste.
I know what you are considering, it is clearer and more readable by consuming 
the length, then the USR. However, to correctly separate the USR and file path, 
the length of `USR-Length` is also required, which makes it impossible to just 
*consume* the length at the beginning.

Another way of solving this problem is to re-create the string with the 
USR-Length and the USR after parsing, but I think it is not a good solution.

BTW, is it necessary to assert the `USR-Length` to be greater than zero? I 
think it is more reasonable to report *invalid format* rather than assert the 
value, as it can be provided by the user.



Comment at: clang/test/Analysis/Inputs/ctu-lookup-name-with-space.cpp:13
+int importee(int X) {
+  return 1 / X;
+}

steakhal wrote:
> OikawaKirie wrote:
> > steakhal wrote:
> > > Why do you need to have a div by zero warning?
> > I am not sure whether we should test if an external function can be 
> > correctly imported. Hence, I wrote a div-by-zero bug here. A call to 
> > function `clang_analyzer_warnIfReached` is also OK here.
> > 
> > As the imported lambda expr will not be called, I think I can only test 
> > whether CTU works via another normal function.
> AFAIK importing a function and import-related stuff are orthogonal to 
> actually emitting bug reports produced by the analyzer. That being said, if 
> the `importee()` would have an empty body, the observable behavior would 
> remain the same. And this is what I propose now.
Sorry, but I am not quite clear about your suggestions on this function.


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

https://reviews.llvm.org/D102669

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


[PATCH] D115147: clang-format: [JS] test case for numeric separators.

2021-12-06 Thread Martin Probst via Phabricator via cfe-commits
mprobst created this revision.
mprobst added a reviewer: krasimir.
mprobst requested review of this revision.
Herald added a project: clang.

ES2021 allows numeric literals using `_` as a separator. This already
works, but had no test.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D115147

Files:
  clang/unittests/Format/FormatTestJS.cpp


Index: clang/unittests/Format/FormatTestJS.cpp
===
--- clang/unittests/Format/FormatTestJS.cpp
+++ clang/unittests/Format/FormatTestJS.cpp
@@ -2692,5 +2692,9 @@
   "}\n");
 }
 
+TEST_F(FormatTestJS, NumericSeparators) {
+  verifyFormat("x = 1_000_000 + 12;", "x = 1_000_000   + 12;");
+}
+
 } // namespace format
 } // end namespace clang


Index: clang/unittests/Format/FormatTestJS.cpp
===
--- clang/unittests/Format/FormatTestJS.cpp
+++ clang/unittests/Format/FormatTestJS.cpp
@@ -2692,5 +2692,9 @@
   "}\n");
 }
 
+TEST_F(FormatTestJS, NumericSeparators) {
+  verifyFormat("x = 1_000_000 + 12;", "x = 1_000_000   + 12;");
+}
+
 } // namespace format
 } // end namespace clang
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D114080: [SYCL] Diagnose uses of zero length arrays

2021-12-06 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

Just a few minor nits from me.




Comment at: clang/include/clang/Basic/DiagnosticSemaKinds.td:11395-11396
   InGroup;
+def err_sycl_zero_array_size : Error<
+  "zero-length arrays are not permitted in SYCL device code">;
 

We should reuse `err_typecheck_zero_array_size` and give it a `%select` for the 
reason the zero-length array is not permitted.



Comment at: clang/lib/Sema/SemaSYCL.cpp:76-82
+if (auto *FD = dyn_cast(D)) {
+  SYCLDiagIfDeviceCode(FD->getLocation(),
+   diag::note_illegal_field_declared_here)
+  << FD->getType()->isPointerType() << FD->getType();
+} else {
+  SYCLDiagIfDeviceCode(D->getLocation(), diag::note_declared_at);
+}

Can elide the braces here per the usual coding conventions.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D114080

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


[PATCH] D102669: [analyzer][ctu] Fix wrong 'multiple definitions' errors caused by space characters in lookup names when parsing the ctu index file

2021-12-06 Thread Balázs Benics via Phabricator via cfe-commits
steakhal added inline comments.



Comment at: clang/lib/CrossTU/CrossTranslationUnit.cpp:154-172
+  // Find the length delimiter.
+  const size_t LengthDelimiter = LineRef.find(':');
+  if (StringRef::npos == LengthDelimiter)
+return false;
+
+  // Parse the length of LookupName as USRLength.
+  size_t USRLength = 0;

OikawaKirie wrote:
> steakhal wrote:
> > OikawaKirie wrote:
> > > steakhal wrote:
> > > > OikawaKirie wrote:
> > > > > steakhal wrote:
> > > > > > 
> > > > > The source of lookup name of the function being imported is function 
> > > > > `CrossTranslationUnitContext::getLookupName`. Keeping the length in 
> > > > > the mapping can avoid parsing the lookup name during importing.
> > > > Okay; you can copy the original StringRef to have that. But by 
> > > > consuming it on one path makes the code much more readable.
> > > > 
> > > The `getAsInterger` call can also check whether the content before the 
> > > first colon is an integer. Therefore, a sub-string operation is required 
> > > here.
> > I don't doubt that your proposed way of doing this works and is efficient.
> > What I say is that I think there is room for improvement in the 
> > non-functional aspects, in the readability. However, it's not really a 
> > blocking issue, more of a personal taste.
> I know what you are considering, it is clearer and more readable by consuming 
> the length, then the USR. However, to correctly separate the USR and file 
> path, the length of `USR-Length` is also required, which makes it impossible 
> to just *consume* the length at the beginning.
> 
> Another way of solving this problem is to re-create the string with the 
> USR-Length and the USR after parsing, but I think it is not a good solution.
> 
> BTW, is it necessary to assert the `USR-Length` to be greater than zero? I 
> think it is more reasonable to report *invalid format* rather than assert the 
> value, as it can be provided by the user.
I think what causes the misunderstanding is the definition of //consume// in 
the context of `StringRef`.
```lang=C++
const StringRef Copy = Line;
Line.consumeInteger(...); // Line advances forward by the number of characters 
that were parsed as an integral value.
// Copy still refers to the unmodified, original characters.
// I can use it however I want.

// `Line` is a suffix of `Copy`, and the `.end()` should be the same, only 
`.begin()` should differ.
```

I hope that caused the miscommunication.

---
> BTW, is it necessary to assert the USR-Length to be greater than zero? I 
> think it is more reasonable to report *invalid format* rather than assert the 
> value, as it can be provided by the user.
Yeah, sure!



Comment at: clang/test/Analysis/Inputs/ctu-lookup-name-with-space.cpp:12-14
+int importee(int X) {
+  return 1 / X;
+}

Also fixup the return type in the declaration within the main TU. Also add the 
`// expected-no-diagnostics` comment to the primary TU.


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

https://reviews.llvm.org/D102669

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


[PATCH] D115147: clang-format: [JS] test case for numeric separators.

2021-12-06 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay accepted this revision.
MyDeveloperDay 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/D115147/new/

https://reviews.llvm.org/D115147

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


[PATCH] D115141: [ARM][clang] Add back branch protection tests

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

I'm quite sure this is the right fix, the 'requires' clause missing is, I 
believe, the problems that caused us to revert this test.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D115141

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


[PATCH] D115153: clang/AMDGPU: Don't set implicit arg attribute to default size

2021-12-06 Thread Matt Arsenault via Phabricator via cfe-commits
arsenm created this revision.
arsenm added reviewers: yaxunl, JonChesterfield.
Herald added subscribers: jdoerfert, kerbowa, t-tye, tpr, dstuttard, nhaehnle, 
jvesely, kzhuravl.
arsenm requested review of this revision.
Herald added subscribers: sstefan1, wdng.
Herald added a reviewer: jdoerfert.

Since 2959e082e1427647e107af0b82770682eaa58fe1 
, we 
conservatively
assume all inputs are enabled by default. This isn't the best
interface for controlling these anyway, since it's not granular and
only allows trimming the last fields.


https://reviews.llvm.org/D115153

Files:
  clang/lib/CodeGen/TargetInfo.cpp
  clang/test/CodeGenCUDA/amdgpu-hip-implicit-kernarg.cu
  clang/test/CodeGenOpenCL/amdgpu-attrs.cl
  clang/test/OpenMP/amdgcn-attributes.cpp

Index: clang/test/OpenMP/amdgcn-attributes.cpp
===
--- clang/test/OpenMP/amdgcn-attributes.cpp
+++ clang/test/OpenMP/amdgcn-attributes.cpp
@@ -32,10 +32,10 @@
   return x + 1;
 }
 
-  // DEFAULT: attributes #0 = { convergent noinline norecurse nounwind optnone "amdgpu-implicitarg-num-bytes"="56" "frame-pointer"="none" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" }
-  // CPU: attributes #0 = { convergent noinline norecurse nounwind optnone "amdgpu-implicitarg-num-bytes"="56" "frame-pointer"="none" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="gfx900" "target-features"="+16-bit-insts,+ci-insts,+dpp,+flat-address-space,+gfx8-insts,+gfx9-insts,+s-memrealtime,+s-memtime-inst" }
-  // NOIEEE: attributes #0 = { convergent noinline norecurse nounwind optnone "amdgpu-ieee"="false" "amdgpu-implicitarg-num-bytes"="56" "frame-pointer"="none" "min-legal-vector-width"="0" "no-nans-fp-math"="true" "no-trapping-math"="true" "stack-protector-buffer-size"="8" }
-  // UNSAFEATOMIC: attributes #0 = { convergent noinline norecurse nounwind optnone "amdgpu-implicitarg-num-bytes"="56" "amdgpu-unsafe-fp-atomics"="true" "frame-pointer"="none" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" }
+  // DEFAULT: attributes #0 = { convergent noinline norecurse nounwind optnone "frame-pointer"="none" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" }
+  // CPU: attributes #0 = { convergent noinline norecurse nounwind optnone "frame-pointer"="none" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="gfx900" "target-features"="+16-bit-insts,+ci-insts,+dpp,+flat-address-space,+gfx8-insts,+gfx9-insts,+s-memrealtime,+s-memtime-inst" }
+  // NOIEEE: attributes #0 = { convergent noinline norecurse nounwind optnone "amdgpu-ieee"="false" "frame-pointer"="none" "min-legal-vector-width"="0" "no-nans-fp-math"="true" "no-trapping-math"="true" "stack-protector-buffer-size"="8" }
+  // UNSAFEATOMIC: attributes #0 = { convergent noinline norecurse nounwind optnone "amdgpu-unsafe-fp-atomics"="true" "frame-pointer"="none" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" }
 
 // DEFAULT: attributes #1 = { convergent mustprogress noinline nounwind optnone "frame-pointer"="none" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" }
 // CPU: attributes #1 = { convergent mustprogress noinline nounwind optnone "frame-pointer"="none" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="gfx900" "target-features"="+16-bit-insts,+ci-insts,+dpp,+flat-address-space,+gfx8-insts,+gfx9-insts,+s-memrealtime,+s-memtime-inst" }
Index: clang/test/CodeGenOpenCL/amdgpu-attrs.cl
===
--- clang/test/CodeGenOpenCL/amdgpu-attrs.cl
+++ clang/test/CodeGenOpenCL/amdgpu-attrs.cl
@@ -153,8 +153,7 @@
 // X86-NOT: "amdgpu-waves-per-eu"
 // X86-NOT: "amdgpu-num-vgpr"
 // X86-NOT: "amdgpu-num-sgpr"
-// X86-NOT: "amdgpu-implicitarg-num-bytes"
-// NONAMDHSA-NOT: "amdgpu-implicitarg-num-bytes"
+// CHECK-NOT: "amdgpu-implicitarg-num-bytes"
 
 // CHECK-NOT: "amdgpu-flat-work-group-size"="0,0"
 // CHECK-NOT: "amdgpu-waves-per-eu"="0"
@@ -162,33 +161,33 @@
 // CHECK-NOT: "amdgpu-num-sgpr"="0"
 // CHECK-NOT: "amdgpu-num-vgpr"="0"
 
-// CHECK-DAG: attributes [[FLAT_WORK_GROUP_SIZE_32_64]] = {{.*}} "amdgpu-flat-work-group-size"="32,64" "amdgpu-implicitarg-num-bytes"="56"
-// CHECK-DAG: attributes [[FLAT_WORK_GROUP_SIZE_64_64]] = {{.*}} "amdgpu-flat-work-group-size"="64,64" "amdgpu-implicitarg-num-bytes"="56"
-// CHECK-DAG: attributes [[FLAT_WORK_GROUP_SIZE_16_128]] = {{.*}} "amdgpu-flat-work-group-size"="16,128" "amdgpu-implicitarg-num-bytes"="56"
+// CHECK-DAG: attributes [[FLAT_WORK_GROUP_SIZE_32_64]] = {{.*}} "amdgpu-flat-work-group-size"="32,64"
+// CHECK-DAG: attributes [[FLAT_WORK_GROUP_SIZE_64_64]] = {{.*}

[PATCH] D115121: Add support for return values in bugprone-stringview-nullptr

2021-12-06 Thread Yitzhak Mandelbaum via Phabricator via cfe-commits
ymandel added inline comments.



Comment at: clang-tools-extra/clang-tidy/bugprone/StringviewNullptrCheck.cpp:75
 
-  auto HandleTemporaryCXXStaticCastExpr = makeRule(
-  cxxStaticCastExpr(
-  hasSourceExpression(StringViewConstructingFromNullExpr)),
-  changeTo(node("null_argument_expr"), cat("\"\"")), construction_warning);
+  auto HandleTemporaryReturnValue = makeRule(
+  returnStmt(

In these cases, what is special about `return`? I'd guess the AST has various 
implicit nodes inserted, but then might it make  more sense to focus on those 
as the pattern? Or, is the edit different based on the return context? Might be 
worth explaining this more in a comment?



Comment at: clang-tools-extra/clang-tidy/bugprone/StringviewNullptrCheck.cpp:77
+  returnStmt(
+  
hasReturnValue(ignoringImpCasts(StringViewConstructingFromNullExpr))),
+  changeTo(node("construct_expr"), cat("{}")), construction_warning);

Is it possible for this rule to overlap with any of the others, but not at the 
`returnStmt` level? Specifically, might the `ignoringImpCasts` overlap with any 
of the other expression patterns above? I think not, but am not quite sure 
where `cxxTemporaryObjectExpr` can show up. 



Comment at: 
clang-tools-extra/test/clang-tidy/checkers/bugprone-stringview-nullptr.cpp:94
+
+// TODO: Handle cases where types, such as Class and Struct below, are
+//   constructed with null arguments.

CJ-Johnson wrote:
> I attempted to address this TODO but it is quite the rabbit hole. If I just 
> add a basic fallback matcher, `applyFirst(...)` does not have the behavior I 
> desire. It was stomping on other, better fixes.




Comment at: 
clang-tools-extra/test/clang-tidy/checkers/bugprone-stringview-nullptr.cpp:94-95
+
+// TODO: Handle cases where types, such as Class and Struct below, are
+//   constructed with null arguments.
+class Class {

ymandel wrote:
> CJ-Johnson wrote:
> > I attempted to address this TODO but it is quite the rabbit hole. If I just 
> > add a basic fallback matcher, `applyFirst(...)` does not have the behavior 
> > I desire. It was stomping on other, better fixes.
> 
I'm not sure I understand the code you're trying to catch. Is it constructions 
of `Class` and `Struct`? If so, can you show me some example code 
snippets/transformations?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D115121

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


[clang] 5032467 - Use VersionTuple for parsing versions in Triple, fixing issues that caused the original change to be reverted. This makes it possible to distinguish between "16" and "16.0" after par

2021-12-06 Thread James Farrell via cfe-commits

Author: James Farrell
Date: 2021-12-06T14:57:47Z
New Revision: 50324670342d9391f62671685f4d6b4880a4ea9a

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

LOG: Use VersionTuple for parsing versions in Triple, fixing issues that caused 
the original change to be reverted. This makes it possible to distinguish 
between "16" and "16.0" after parsing, which previously was not possible.

This reverts commit 40d5eeac6cd89a2360c3ba997cbaa816abca828c.

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

Added: 


Modified: 
clang/lib/ARCMigrate/ARCMT.cpp
clang/lib/Basic/Targets/OSTargets.cpp
clang/lib/Basic/Targets/OSTargets.h
clang/lib/Basic/Targets/X86.h
clang/lib/Driver/ToolChains/Darwin.cpp
clang/lib/Driver/ToolChains/Linux.cpp
clang/lib/Driver/ToolChains/MSVC.cpp
clang/lib/Driver/ToolChains/NetBSD.cpp
clang/test/Sema/attr-availability-android.c
clang/test/Sema/attr-availability.c
clang/test/Sema/availability-guard-format.mm
clang/test/SemaObjC/attr-availability.m
clang/test/SemaObjC/property-deprecated-warning.m
clang/test/SemaObjC/unguarded-availability-maccatalyst.m
clang/test/SemaObjC/unguarded-availability.m
llvm/include/llvm/ADT/Triple.h
llvm/lib/Analysis/TargetLibraryInfo.cpp
llvm/lib/MC/MCStreamer.cpp
llvm/lib/Support/Triple.cpp
llvm/lib/Target/AArch64/AArch64Subtarget.cpp
llvm/lib/Target/AArch64/AArch64Subtarget.h
llvm/lib/Target/X86/X86Subtarget.h
llvm/unittests/ADT/TripleTest.cpp
llvm/unittests/Support/Host.cpp

Removed: 




diff  --git a/clang/lib/ARCMigrate/ARCMT.cpp b/clang/lib/ARCMigrate/ARCMT.cpp
index 4851c434d7652..68ee7c59270e0 100644
--- a/clang/lib/ARCMigrate/ARCMT.cpp
+++ b/clang/lib/ARCMigrate/ARCMT.cpp
@@ -162,9 +162,7 @@ static bool HasARCRuntime(CompilerInvocation &origCI) {
 return triple.getOSMajorVersion() >= 11;
 
   if (triple.getOS() == llvm::Triple::MacOSX) {
-unsigned Major, Minor, Micro;
-triple.getOSVersion(Major, Minor, Micro);
-return Major > 10 || (Major == 10 && Minor >= 7);
+return triple.getOSVersion() >= VersionTuple(10, 7);
   }
 
   return false;

diff  --git a/clang/lib/Basic/Targets/OSTargets.cpp 
b/clang/lib/Basic/Targets/OSTargets.cpp
index 53748bf067cd2..695cbafe36557 100644
--- a/clang/lib/Basic/Targets/OSTargets.cpp
+++ b/clang/lib/Basic/Targets/OSTargets.cpp
@@ -48,12 +48,12 @@ void getDarwinDefines(MacroBuilder &Builder, const 
LangOptions &Opts,
 Builder.defineMacro("_REENTRANT");
 
   // Get the platform type and version number from the triple.
-  unsigned Maj, Min, Rev;
+  VersionTuple OsVersion;
   if (Triple.isMacOSX()) {
-Triple.getMacOSXVersion(Maj, Min, Rev);
+Triple.getMacOSXVersion(OsVersion);
 PlatformName = "macos";
   } else {
-Triple.getOSVersion(Maj, Min, Rev);
+OsVersion = Triple.getOSVersion();
 PlatformName = llvm::Triple::getOSTypeName(Triple.getOS());
 if (PlatformName == "ios" && Triple.isMacCatalystEnvironment())
   PlatformName = "maccatalyst";
@@ -63,29 +63,29 @@ void getDarwinDefines(MacroBuilder &Builder, const 
LangOptions &Opts,
   // generating code for Win32 ABI. No need to emit
   // __ENVIRONMENT_XX_OS_VERSION_MIN_REQUIRED__.
   if (PlatformName == "win32") {
-PlatformMinVersion = VersionTuple(Maj, Min, Rev);
+PlatformMinVersion = OsVersion;
 return;
   }
 
   // Set the appropriate OS version define.
   if (Triple.isiOS()) {
-assert(Maj < 100 && Min < 100 && Rev < 100 && "Invalid version!");
+assert(OsVersion < VersionTuple(100) && "Invalid version!");
 char Str[7];
-if (Maj < 10) {
-  Str[0] = '0' + Maj;
-  Str[1] = '0' + (Min / 10);
-  Str[2] = '0' + (Min % 10);
-  Str[3] = '0' + (Rev / 10);
-  Str[4] = '0' + (Rev % 10);
+if (OsVersion.getMajor() < 10) {
+  Str[0] = '0' + OsVersion.getMajor();
+  Str[1] = '0' + (OsVersion.getMinor().getValueOr(0) / 10);
+  Str[2] = '0' + (OsVersion.getMinor().getValueOr(0) % 10);
+  Str[3] = '0' + (OsVersion.getSubminor().getValueOr(0) / 10);
+  Str[4] = '0' + (OsVersion.getSubminor().getValueOr(0) % 10);
   Str[5] = '\0';
 } else {
   // Handle versions >= 10.
-  Str[0] = '0' + (Maj / 10);
-  Str[1] = '0' + (Maj % 10);
-  Str[2] = '0' + (Min / 10);
-  Str[3] = '0' + (Min % 10);
-  Str[4] = '0' + (Rev / 10);
-  Str[5] = '0' + (Rev % 10);
+  Str[0] = '0' + (OsVersion.getMajor() / 10);
+  Str[1] = '0' + (OsVersion.getMajor() % 10);
+  Str[2] = '0' + (OsVersion.getMinor().getValueOr(0) / 10);
+  Str[3] = '0' + (OsVersion.getMinor().getValueOr(0) % 10);
+  Str[4] = '0' + (OsVersion.getSubminor().getValueOr(0) / 10);
+  Str[5] = '0' + (OsVersion.getSubminor().getValueOr(0) % 10);
  

[PATCH] D114885: Use VersionTuple for parsing versions in Triple, fixing issues that caused the original change to be reverted. This makes it possible to distinguish between "16" and "16.0" after pars

2021-12-06 Thread James Farrell via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG50324670342d: Use VersionTuple for parsing versions in 
Triple, fixing issues that caused the… (authored by jamesfarrell).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D114885

Files:
  clang/lib/ARCMigrate/ARCMT.cpp
  clang/lib/Basic/Targets/OSTargets.cpp
  clang/lib/Basic/Targets/OSTargets.h
  clang/lib/Basic/Targets/X86.h
  clang/lib/Driver/ToolChains/Darwin.cpp
  clang/lib/Driver/ToolChains/Linux.cpp
  clang/lib/Driver/ToolChains/MSVC.cpp
  clang/lib/Driver/ToolChains/NetBSD.cpp
  clang/test/Sema/attr-availability-android.c
  clang/test/Sema/attr-availability.c
  clang/test/Sema/availability-guard-format.mm
  clang/test/SemaObjC/attr-availability.m
  clang/test/SemaObjC/property-deprecated-warning.m
  clang/test/SemaObjC/unguarded-availability-maccatalyst.m
  clang/test/SemaObjC/unguarded-availability.m
  llvm/include/llvm/ADT/Triple.h
  llvm/lib/Analysis/TargetLibraryInfo.cpp
  llvm/lib/MC/MCStreamer.cpp
  llvm/lib/Support/Triple.cpp
  llvm/lib/Target/AArch64/AArch64Subtarget.cpp
  llvm/lib/Target/AArch64/AArch64Subtarget.h
  llvm/lib/Target/X86/X86Subtarget.h
  llvm/unittests/ADT/TripleTest.cpp
  llvm/unittests/Support/Host.cpp

Index: llvm/unittests/Support/Host.cpp
===
--- llvm/unittests/Support/Host.cpp
+++ llvm/unittests/Support/Host.cpp
@@ -366,7 +366,6 @@
   }
 }
 
-#if defined(__APPLE__) || defined(_AIX)
 static bool runAndGetCommandOutput(
 const char *ExePath, ArrayRef argv,
 std::unique_ptr &Buffer, off_t &Size) {
@@ -406,12 +405,9 @@
   // disabled.
   (void) runAndGetCommandOutput;
 }
-#endif
 
-#if defined(__APPLE__)
 TEST_F(HostTest, getMacOSHostVersion) {
-  using namespace llvm::sys;
-  llvm::Triple HostTriple(getProcessTriple());
+  llvm::Triple HostTriple(llvm::sys::getProcessTriple());
   if (!HostTriple.isMacOSX())
 return;
 
@@ -420,34 +416,32 @@
   std::unique_ptr Buffer;
   off_t Size;
   ASSERT_EQ(runAndGetCommandOutput(SwVersPath, argv, Buffer, Size), true);
-  StringRef SystemVersion(Buffer.get(), Size);
+  StringRef SystemVersionStr(Buffer.get(), Size);
 
   // Ensure that the two versions match.
-  unsigned SystemMajor, SystemMinor, SystemMicro;
-  ASSERT_EQ(llvm::Triple((Twine("x86_64-apple-macos") + SystemVersion))
-.getMacOSXVersion(SystemMajor, SystemMinor, SystemMicro),
+  VersionTuple SystemVersion;
+  ASSERT_EQ(llvm::Triple((Twine("x86_64-apple-macos") + SystemVersionStr))
+.getMacOSXVersion(SystemVersion),
 true);
-  unsigned HostMajor, HostMinor, HostMicro;
-  ASSERT_EQ(HostTriple.getMacOSXVersion(HostMajor, HostMinor, HostMicro), true);
+  VersionTuple HostVersion;
+  ASSERT_EQ(HostTriple.getMacOSXVersion(HostVersion), true);
 
-  if (SystemMajor > 10) {
+  if (SystemVersion.getMajor() > 10) {
 // Don't compare the 'Minor' and 'Micro' versions, as they're always '0' for
 // the 'Darwin' triples on 11.x.
-ASSERT_EQ(SystemMajor, HostMajor);
+ASSERT_EQ(SystemVersion.getMajor(), HostVersion.getMajor());
   } else {
 // Don't compare the 'Micro' version, as it's always '0' for the 'Darwin'
 // triples.
-ASSERT_EQ(std::tie(SystemMajor, SystemMinor), std::tie(HostMajor, HostMinor));
+ASSERT_EQ(SystemVersion.getMajor(), HostVersion.getMajor());
+ASSERT_EQ(SystemVersion.getMinor(), HostVersion.getMinor());
   }
 }
-#endif
 
-#if defined(_AIX)
 TEST_F(HostTest, AIXVersionDetect) {
-  using namespace llvm::sys;
-
-  llvm::Triple HostTriple(getProcessTriple());
-  ASSERT_EQ(HostTriple.getOS(), Triple::AIX);
+  llvm::Triple HostTriple(llvm::sys::getProcessTriple());
+  if (HostTriple.getOS() != Triple::AIX)
+return;
 
   llvm::Triple ConfiguredHostTriple(LLVM_HOST_TRIPLE);
   ASSERT_EQ(ConfiguredHostTriple.getOS(), Triple::AIX);
@@ -457,22 +451,21 @@
   std::unique_ptr Buffer;
   off_t Size;
   ASSERT_EQ(runAndGetCommandOutput(ExePath, argv, Buffer, Size), true);
-  StringRef SystemVersion(Buffer.get(), Size);
+  StringRef SystemVersionStr(Buffer.get(), Size);
 
-  unsigned SystemMajor, SystemMinor, SystemMicro;
-  llvm::Triple((Twine("powerpc-ibm-aix") + SystemVersion))
-  .getOSVersion(SystemMajor, SystemMinor, SystemMicro);
+  VersionTuple SystemVersion =
+  llvm::Triple((Twine("powerpc-ibm-aix") + SystemVersionStr))
+  .getOSVersion();
 
   // Ensure that the host triple version (major) and release (minor) numbers,
   // unless explicitly configured, match with those of the current system.
   if (!ConfiguredHostTriple.getOSMajorVersion()) {
-unsigned HostMajor, HostMinor, HostMicro;
-HostTriple.getOSVersion(HostMajor, HostMinor, HostMicro);
-ASSERT_EQ(std::tie(SystemMajor, SystemMinor),
-  std::tie(HostMajor, HostMinor));
+VersionTuple HostVersion = HostTriple.getOSVersion();
+ASSERT_EQ(Syst

[PATCH] D115045: [Clang] Ignore CLANG_DEFAULT_LINKER for custom-linker toolchains

2021-12-06 Thread Ron Lieberman via Phabricator via cfe-commits
ronlieb added a comment.

Hi Simon,
i am seeing a failure in our amdgpu buildbot after this patch . 
https://lab.llvm.org/staging/#/builders/200/builds/1407
we do depend on the cmake flag you removed.
we specify this
 -DCLANG_DEFAULT_LINKER=lld

FAILED: openmp/libomptarget/libomptarget.rtl.x86_64.so
: && /home/rlieberm/mono-repo/llvm-project/build/./bin/clang++ 
--target=x86_64-unknown-linux-gnu -fPIC -fPIC -fno-semantic-interposition 
-fvisibility-inlines-hidden -Werror=date-time 
-Werror=unguarded-availability-new -Wall -Wextra -Wno-unused-parameter 
-Wwrite-strings -Wcast-qual -Wmissing-field-initializers -Wimplicit-fallthrough 
-Wcovered-switch-default -Wno-noexcept-type -Wnon-virtual-dtor 
-Wdelete-non-virtual-dtor -Wsuggest-override -Wno-comment -Wstring-conversion 
-Wmisleading-indentation -fdiagnostics-color -ffunction-sections 
-fdata-sections -Wall -Wcast-qual -Wformat-pedantic -Wimplicit-fallthrough 
-Wsign-compare -Wno-extra -Wno-pedantic -std=c++14 -O3 -DNDEBUG  -Wl,-z,defs 
-Wl,-z,nodelete -Wl,--color-diagnostics -shared 
-Wl,-soname,libomptarget.rtl.x86_64.so -o 
openmp/libomptarget/libomptarget.rtl.x86_64.so 
openmp/libomptarget/plugins/common/elf_common/CMakeFiles/elf_common.dir/elf_common.cpp.o
 
openmp/libomptarget/plugins/x86_64/CMakeFiles/omptarget.rtl.x86_64.dir/__/generic-elf-64bit/src/rtl.cpp.o
  /usr/lib/x86_64-linux-gnu/libffi.so  /usr/lib/x86_64-linux-gnu/libelf.so  
-ldl  -lpthread  
-Wl,--version-script=/home/rlieberm/mono-repo/llvm-project/openmp/libomptarget/plugins/x86_64/../exports
  /home/rlieberm/mono-repo/llvm-project/build/lib/libLLVMObject.a  
/home/rlieberm/mono-repo/llvm-project/build/lib/libLLVMBitReader.a  
/home/rlieberm/mono-repo/llvm-project/build/lib/libLLVMCore.a  
/home/rlieberm/mono-repo/llvm-project/build/lib/libLLVMRemarks.a  
/home/rlieberm/mono-repo/llvm-project/build/lib/libLLVMBitstreamReader.a  
/home/rlieberm/mono-repo/llvm-project/build/lib/libLLVMMCParser.a  
/home/rlieberm/mono-repo/llvm-project/build/lib/libLLVMMC.a  
/home/rlieberm/mono-repo/llvm-project/build/lib/libLLVMDebugInfoCodeView.a  
/home/rlieberm/mono-repo/llvm-project/build/lib/libLLVMTextAPI.a  
/home/rlieberm/mono-repo/llvm-project/build/lib/libLLVMBinaryFormat.a  
/home/rlieberm/mono-repo/llvm-project/build/lib/libLLVMSupport.a  -lrt  -lm  
/usr/lib/x86_64-linux-gnu/libz.so  /usr/lib/x86_64-linux-gnu/libtinfo.so  
/home/rlieberm/mono-repo/llvm-project/build/lib/libLLVMDemangle.a  -ldl  
-lpthread && :
lld is a generic driver.
Invoke ld.lld (Unix), ld64.lld (macOS), lld-link (Windows), wasm-ld 
(WebAssembly) instead
clang-14: error: linker command failed with exit code 1 (use -v to see 
invocation)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D115045

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


[PATCH] D115141: [ARM][clang] Add back branch protection tests

2021-12-06 Thread Ties Stuij via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG53154a83aee0: [ARM][clang] Add back branch protection tests 
(authored by stuij).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D115141

Files:
  clang/test/Frontend/arm-invalid-branch-protection.c


Index: clang/test/Frontend/arm-invalid-branch-protection.c
===
--- /dev/null
+++ clang/test/Frontend/arm-invalid-branch-protection.c
@@ -0,0 +1,7 @@
+// REQUIRES: arm-registered-target
+// RUN: %clang -target arm-arm-none-eabi -mbranch-protection=pac-ret+b-key -c 
%s -o /dev/null 2>&1 | FileCheck %s
+// RUN: %clang -target arm-arm-none-eabi 
-mbranch-protection=pac-ret+b-key+leaf -c %s -o /dev/null 2>&1 | FileCheck %s
+// RUN: %clang -target arm-arm-none-eabi -mbranch-protection=bti+pac-ret+b-key 
-c %s -o /dev/null 2>&1 | FileCheck %s
+// RUN: %clang -target arm-arm-none-eabi 
-mbranch-protection=bti+pac-ret+b-key+leaf -c %s -o /dev/null 2>&1 | FileCheck 
%s
+
+// CHECK: warning: invalid branch protection option 'b-key' in 
'-mbranch-protection={{[a-z+-]*}}' [-Wbranch-protection]


Index: clang/test/Frontend/arm-invalid-branch-protection.c
===
--- /dev/null
+++ clang/test/Frontend/arm-invalid-branch-protection.c
@@ -0,0 +1,7 @@
+// REQUIRES: arm-registered-target
+// RUN: %clang -target arm-arm-none-eabi -mbranch-protection=pac-ret+b-key -c %s -o /dev/null 2>&1 | FileCheck %s
+// RUN: %clang -target arm-arm-none-eabi -mbranch-protection=pac-ret+b-key+leaf -c %s -o /dev/null 2>&1 | FileCheck %s
+// RUN: %clang -target arm-arm-none-eabi -mbranch-protection=bti+pac-ret+b-key -c %s -o /dev/null 2>&1 | FileCheck %s
+// RUN: %clang -target arm-arm-none-eabi -mbranch-protection=bti+pac-ret+b-key+leaf -c %s -o /dev/null 2>&1 | FileCheck %s
+
+// CHECK: warning: invalid branch protection option 'b-key' in '-mbranch-protection={{[a-z+-]*}}' [-Wbranch-protection]
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 53154a8 - [ARM][clang] Add back branch protection tests

2021-12-06 Thread Ties Stuij via cfe-commits

Author: Ties Stuij
Date: 2021-12-06T15:03:33Z
New Revision: 53154a83aee0ce969dc07e7168b3914ca1025030

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

LOG: [ARM][clang] Add back branch protection tests

When committing the PACBTI-M frontend support
patch (https://reviews.llvm.org/D112421), the tests in
arm-invalid-branch-protection.c were failing on certain test setups, so it was
removed to make the llvm test suite pass. The fix is to require
arm-registered-target.

This patch is part of a series that adds support for the PACBTI-M extension of
the Armv8.1-M architecture, as detailed here:

https://community.arm.com/arm-community-blogs/b/architectures-and-processors-blog/posts/armv8-1-m-pointer-authentication-and-branch-target-identification-extension

The PACBTI-M specification can be found in the Armv8-M Architecture Reference
Manual:

https://developer.arm.com/documentation/ddi0553/latest

Reviewed By: erichkeane

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

Added: 
clang/test/Frontend/arm-invalid-branch-protection.c

Modified: 


Removed: 




diff  --git a/clang/test/Frontend/arm-invalid-branch-protection.c 
b/clang/test/Frontend/arm-invalid-branch-protection.c
new file mode 100644
index 0..f7bbd5941b024
--- /dev/null
+++ b/clang/test/Frontend/arm-invalid-branch-protection.c
@@ -0,0 +1,7 @@
+// REQUIRES: arm-registered-target
+// RUN: %clang -target arm-arm-none-eabi -mbranch-protection=pac-ret+b-key -c 
%s -o /dev/null 2>&1 | FileCheck %s
+// RUN: %clang -target arm-arm-none-eabi 
-mbranch-protection=pac-ret+b-key+leaf -c %s -o /dev/null 2>&1 | FileCheck %s
+// RUN: %clang -target arm-arm-none-eabi -mbranch-protection=bti+pac-ret+b-key 
-c %s -o /dev/null 2>&1 | FileCheck %s
+// RUN: %clang -target arm-arm-none-eabi 
-mbranch-protection=bti+pac-ret+b-key+leaf -c %s -o /dev/null 2>&1 | FileCheck 
%s
+
+// CHECK: warning: invalid branch protection option 'b-key' in 
'-mbranch-protection={{[a-z+-]*}}' [-Wbranch-protection]



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


[PATCH] D114235: [clang] Extend ParsedAttr to allow custom handling for type attributes

2021-12-06 Thread Martin Böhme via Phabricator via cfe-commits
mboehme added a comment.

Aaron, have you had any chance to look at this yet?

I added you as a reviewer because you expressed interest in something like this 
in this discussion: 
https://lists.llvm.org/pipermail/cfe-dev/2021-October/069097.html

Is there someone else who would be more appropriate to review this?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D114235

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


[PATCH] D115157: [openmp] Default to new rtl for amdgpu

2021-12-06 Thread Jon Chesterfield via Phabricator via cfe-commits
JonChesterfield created this revision.
JonChesterfield added reviewers: ronlieb, jhuber6, jdoerfert, pdhaliwal.
Herald added subscribers: dang, kerbowa, guansong, t-tye, tpr, dstuttard, 
yaxunl, nhaehnle, jvesely, kzhuravl.
JonChesterfield requested review of this revision.
Herald added subscribers: cfe-commits, sstefan1, wdng.
Herald added a project: clang.

Reverts D114965  as the compiler backend 
appears to be working again


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D115157

Files:
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/ToolChains/AMDGPUOpenMP.cpp
  clang/lib/Driver/ToolChains/Clang.cpp


Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -5904,7 +5904,7 @@
   // runtime.
   if (Args.hasFlag(options::OPT_fopenmp_target_new_runtime,
options::OPT_fno_openmp_target_new_runtime,
-   /*Default=*/!getToolChain().getTriple().isAMDGCN()))
+   /*Default=*/true))
 CmdArgs.push_back("-fopenmp-target-new-runtime");
 
   // When in OpenMP offloading mode, enable debugging on the device.
Index: clang/lib/Driver/ToolChains/AMDGPUOpenMP.cpp
===
--- clang/lib/Driver/ToolChains/AMDGPUOpenMP.cpp
+++ clang/lib/Driver/ToolChains/AMDGPUOpenMP.cpp
@@ -267,7 +267,7 @@
 
   std::string BitcodeSuffix;
   if (DriverArgs.hasFlag(options::OPT_fopenmp_target_new_runtime,
- options::OPT_fno_openmp_target_new_runtime, false))
+ options::OPT_fno_openmp_target_new_runtime, true))
 BitcodeSuffix = "new-amdgpu-" + GPUArch;
   else
 BitcodeSuffix = "amdgcn-" + GPUArch;
Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -2442,7 +2442,7 @@
 def fno_openmp_assume_threads_oversubscription : Flag<["-"], 
"fno-openmp-assume-threads-oversubscription">, 
   Group, Flags<[CC1Option, NoArgumentUnused, HelpHidden]>;
 defm openmp_target_new_runtime: BoolFOption<"openmp-target-new-runtime",
-  LangOpts<"OpenMPTargetNewRuntime">, DefaultFalse,
+  LangOpts<"OpenMPTargetNewRuntime">, DefaultTrue,
   PosFlag,
   NegFlag>;
 defm openmp_optimistic_collapse : BoolFOption<"openmp-optimistic-collapse",


Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -5904,7 +5904,7 @@
   // runtime.
   if (Args.hasFlag(options::OPT_fopenmp_target_new_runtime,
options::OPT_fno_openmp_target_new_runtime,
-   /*Default=*/!getToolChain().getTriple().isAMDGCN()))
+   /*Default=*/true))
 CmdArgs.push_back("-fopenmp-target-new-runtime");
 
   // When in OpenMP offloading mode, enable debugging on the device.
Index: clang/lib/Driver/ToolChains/AMDGPUOpenMP.cpp
===
--- clang/lib/Driver/ToolChains/AMDGPUOpenMP.cpp
+++ clang/lib/Driver/ToolChains/AMDGPUOpenMP.cpp
@@ -267,7 +267,7 @@
 
   std::string BitcodeSuffix;
   if (DriverArgs.hasFlag(options::OPT_fopenmp_target_new_runtime,
- options::OPT_fno_openmp_target_new_runtime, false))
+ options::OPT_fno_openmp_target_new_runtime, true))
 BitcodeSuffix = "new-amdgpu-" + GPUArch;
   else
 BitcodeSuffix = "amdgcn-" + GPUArch;
Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -2442,7 +2442,7 @@
 def fno_openmp_assume_threads_oversubscription : Flag<["-"], "fno-openmp-assume-threads-oversubscription">, 
   Group, Flags<[CC1Option, NoArgumentUnused, HelpHidden]>;
 defm openmp_target_new_runtime: BoolFOption<"openmp-target-new-runtime",
-  LangOpts<"OpenMPTargetNewRuntime">, DefaultFalse,
+  LangOpts<"OpenMPTargetNewRuntime">, DefaultTrue,
   PosFlag,
   NegFlag>;
 defm openmp_optimistic_collapse : BoolFOption<"openmp-optimistic-collapse",
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D115157: [openmp] Default to new rtl for amdgpu

2021-12-06 Thread Joseph Huber via Phabricator via cfe-commits
jhuber6 accepted this revision.
jhuber6 added a comment.
This revision is now accepted and ready to land.

If it works on your end it's good.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D115157

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


[PATCH] D114848: [Analysis] Ignore casts and unary ops for uninitialized values

2021-12-06 Thread Bill Wendling via Phabricator via cfe-commits
void added a comment.

Friendly ping to reviewers. :-)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D114848

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


[PATCH] D115157: [openmp] Default to new rtl for amdgpu

2021-12-06 Thread Jon Chesterfield via Phabricator via cfe-commits
JonChesterfield added a comment.

It's a bit hard to tell. Definitely might work. I'm hoping someone will feed 
this into the internal CI infra. @ronlieb any objection to making this change 
on trunk and reverting it internally if things break there?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D115157

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


[clang] f6ba645 - Revert "[Clang] Ignore CLANG_DEFAULT_LINKER for custom-linker toolchains"

2021-12-06 Thread Simon Moll via cfe-commits

Author: Simon Moll
Date: 2021-12-06T16:44:36+01:00
New Revision: f6ba6450396ce58212f247c72d84a54efd748b38

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

LOG: Revert "[Clang] Ignore CLANG_DEFAULT_LINKER for custom-linker toolchains"

Reverted until all Toolchains are fixed for the new behavior.

This reverts commit 34a43f2115af79f896c889433c57f3b400e9f2c6.

Added: 


Modified: 
clang/include/clang/Driver/ToolChain.h
clang/lib/Driver/ToolChain.cpp
clang/test/Driver/ve-toolchain.c
clang/test/Driver/ve-toolchain.cpp

Removed: 




diff  --git a/clang/include/clang/Driver/ToolChain.h 
b/clang/include/clang/Driver/ToolChain.h
index e55f8219feb08..e7b13eec3fc14 100644
--- a/clang/include/clang/Driver/ToolChain.h
+++ b/clang/include/clang/Driver/ToolChain.h
@@ -420,7 +420,7 @@ class ToolChain {
   }
 
   /// GetDefaultLinker - Get the default linker to use.
-  virtual const char *getDefaultLinker() const;
+  virtual const char *getDefaultLinker() const { return "ld"; }
 
   /// GetDefaultRuntimeLibType - Get the default runtime library variant to 
use.
   virtual RuntimeLibType GetDefaultRuntimeLibType() const {

diff  --git a/clang/lib/Driver/ToolChain.cpp b/clang/lib/Driver/ToolChain.cpp
index d92cbe21960ee..ac033dd427c2d 100644
--- a/clang/lib/Driver/ToolChain.cpp
+++ b/clang/lib/Driver/ToolChain.cpp
@@ -541,12 +541,6 @@ std::string ToolChain::GetProgramPath(const char *Name) 
const {
   return D.GetProgramPath(Name, *this);
 }
 
-const char *ToolChain::getDefaultLinker() const {
-  if (CLANG_DEFAULT_LINKER[0] == '\0')
-return "ld";
-  return CLANG_DEFAULT_LINKER;
-}
-
 std::string ToolChain::GetLinkerPath(bool *LinkerIsLLD) const {
   if (LinkerIsLLD)
 *LinkerIsLLD = false;
@@ -554,7 +548,7 @@ std::string ToolChain::GetLinkerPath(bool *LinkerIsLLD) 
const {
   // Get -fuse-ld= first to prevent -Wunused-command-line-argument. -fuse-ld= 
is
   // considered as the linker flavor, e.g. "bfd", "gold", or "lld".
   const Arg* A = Args.getLastArg(options::OPT_fuse_ld_EQ);
-  StringRef UseLinker = A ? A->getValue() : "";
+  StringRef UseLinker = A ? A->getValue() : CLANG_DEFAULT_LINKER;
 
   // --ld-path= takes precedence over -fuse-ld= and specifies the executable
   // name. -B, COMPILER_PATH and PATH and consulted if the value does not

diff  --git a/clang/test/Driver/ve-toolchain.c 
b/clang/test/Driver/ve-toolchain.c
index 2c8f211d143f6..8878bd8f83cc0 100644
--- a/clang/test/Driver/ve-toolchain.c
+++ b/clang/test/Driver/ve-toolchain.c
@@ -61,10 +61,10 @@
 /// Checking -fintegrated-as
 
 // RUN: %clang -### -target ve \
-// RUN:-x assembler %s 2>&1 | \
+// RUN:-x assembler -fuse-ld=ld %s 2>&1 | \
 // RUN:FileCheck -check-prefix=AS %s
 // RUN: %clang -### -target ve \
-// RUN:-fno-integrated-as -x assembler %s 2>&1 | \
+// RUN:-fno-integrated-as -fuse-ld=ld -x assembler %s 2>&1 | \
 // RUN:FileCheck -check-prefix=NAS %s
 
 // AS: clang{{.*}} "-cc1as"
@@ -83,6 +83,7 @@
 // RUN: %clang -### -target ve-unknown-linux-gnu \
 // RUN: --sysroot %S/Inputs/basic_ve_tree \
 // RUN: -resource-dir=%S/Inputs/basic_ve_tree/resource_dir \
+// RUN: -fuse-ld=ld \
 // RUN: %s 2>&1 | FileCheck -check-prefix=DEF %s
 
 // DEF:  clang{{.*}}" "-cc1"

diff  --git a/clang/test/Driver/ve-toolchain.cpp 
b/clang/test/Driver/ve-toolchain.cpp
index 2519a5f97dff9..7666cfbfe8b27 100644
--- a/clang/test/Driver/ve-toolchain.cpp
+++ b/clang/test/Driver/ve-toolchain.cpp
@@ -110,10 +110,10 @@
 /// Checking -fintegrated-as
 
 // RUN: %clangxx -### -target ve-unknown-linux-gnu \
-// RUN: -x assembler %s 2>&1 | \
+// RUN: -x assembler -fuse-ld=ld %s 2>&1 | \
 // RUN:FileCheck -check-prefix=AS %s
 // RUN: %clangxx -### -target ve-unknown-linux-gnu \
-// RUN: -fno-integrated-as -x assembler %s 2>&1 | \
+// RUN: -fno-integrated-as -x assembler -fuse-ld=ld %s 2>&1 | \
 // RUN:FileCheck -check-prefix=NAS %s
 
 // AS: clang{{.*}} "-cc1as"
@@ -131,6 +131,7 @@
 
 // RUN: %clangxx -### -target ve-unknown-linux-gnu \
 // RUN: --sysroot %S/Inputs/basic_ve_tree \
+// RUN: -fuse-ld=ld \
 // RUN: -resource-dir=%S/Inputs/basic_ve_tree/resource_dir \
 // RUN: --stdlib=c++ %s 2>&1 | FileCheck -check-prefix=DEF %s
 



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


[PATCH] D115045: [Clang] Ignore CLANG_DEFAULT_LINKER for custom-linker toolchains

2021-12-06 Thread Simon Moll via Phabricator via cfe-commits
simoll reopened this revision.
simoll added a comment.
This revision is now accepted and ready to land.

I've reverted the patch for now, this may show up for other toolchains, too.

This patch has pushed down the responsibility for handling 
`-DCLANG_DEFAULT_LINKER` to the toolchains.
However, I did not modify all toolchains to account for that. Pending an 
update..

In D115045#3173520 , @ronlieb wrote:

> Hi Simon,
> i am seeing a failure in our amdgpu buildbot after this patch . 
> https://lab.llvm.org/staging/#/builders/200/builds/1407
> we do depend on the cmake flag you removed.
> we specify this
>  -DCLANG_DEFAULT_LINKER=lld
>
> FAILED: openmp/libomptarget/libomptarget.rtl.x86_64.so
> : && /home/rlieberm/mono-repo/llvm-project/build/./bin/clang++ 
> --target=x86_64-unknown-linux-gnu -fPIC -fPIC -fno-semantic-interposition 
> -fvisibility-inlines-hidden -Werror=date-time 
> -Werror=unguarded-availability-new -Wall -Wextra -Wno-unused-parameter 
> -Wwrite-strings -Wcast-qual -Wmissing-field-initializers 
> -Wimplicit-fallthrough -Wcovered-switch-default -Wno-noexcept-type 
> -Wnon-virtual-dtor -Wdelete-non-virtual-dtor -Wsuggest-override -Wno-comment 
> -Wstring-conversion -Wmisleading-indentation -fdiagnostics-color 
> -ffunction-sections -fdata-sections -Wall -Wcast-qual -Wformat-pedantic 
> -Wimplicit-fallthrough -Wsign-compare -Wno-extra -Wno-pedantic -std=c++14 -O3 
> -DNDEBUG  -Wl,-z,defs -Wl,-z,nodelete -Wl,--color-diagnostics -shared 
> -Wl,-soname,libomptarget.rtl.x86_64.so -o 
> openmp/libomptarget/libomptarget.rtl.x86_64.so 
> openmp/libomptarget/plugins/common/elf_common/CMakeFiles/elf_common.dir/elf_common.cpp.o
>  
> openmp/libomptarget/plugins/x86_64/CMakeFiles/omptarget.rtl.x86_64.dir/__/generic-elf-64bit/src/rtl.cpp.o
>   /usr/lib/x86_64-linux-gnu/libffi.so  /usr/lib/x86_64-linux-gnu/libelf.so  
> -ldl  -lpthread  
> -Wl,--version-script=/home/rlieberm/mono-repo/llvm-project/openmp/libomptarget/plugins/x86_64/../exports
>   /home/rlieberm/mono-repo/llvm-project/build/lib/libLLVMObject.a  
> /home/rlieberm/mono-repo/llvm-project/build/lib/libLLVMBitReader.a  
> /home/rlieberm/mono-repo/llvm-project/build/lib/libLLVMCore.a  
> /home/rlieberm/mono-repo/llvm-project/build/lib/libLLVMRemarks.a  
> /home/rlieberm/mono-repo/llvm-project/build/lib/libLLVMBitstreamReader.a  
> /home/rlieberm/mono-repo/llvm-project/build/lib/libLLVMMCParser.a  
> /home/rlieberm/mono-repo/llvm-project/build/lib/libLLVMMC.a  
> /home/rlieberm/mono-repo/llvm-project/build/lib/libLLVMDebugInfoCodeView.a  
> /home/rlieberm/mono-repo/llvm-project/build/lib/libLLVMTextAPI.a  
> /home/rlieberm/mono-repo/llvm-project/build/lib/libLLVMBinaryFormat.a  
> /home/rlieberm/mono-repo/llvm-project/build/lib/libLLVMSupport.a  -lrt  -lm  
> /usr/lib/x86_64-linux-gnu/libz.so  /usr/lib/x86_64-linux-gnu/libtinfo.so  
> /home/rlieberm/mono-repo/llvm-project/build/lib/libLLVMDemangle.a  -ldl  
> -lpthread && :
> lld is a generic driver.
> Invoke ld.lld (Unix), ld64.lld (macOS), lld-link (Windows), wasm-ld 
> (WebAssembly) instead
> clang-14: error: linker command failed with exit code 1 (use -v to see 
> invocation)




Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D115045

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


[PATCH] D115045: [Clang] Ignore CLANG_DEFAULT_LINKER for custom-linker toolchains

2021-12-06 Thread Ron Lieberman via Phabricator via cfe-commits
ronlieb added a comment.

fyi: if i remove the now 'dead' use of the CMAKE variable from my cmake , then 
i am able to build.  so i see you reverted, thx. i  guess some coordination 
amongst buildbot maintainers who might use this option

checking zorg: the last two are me:  not sure who owns the 1st one
"clang-ppc64le-rhel"
"openmp-offload-amdgpu-runtime"
"openmp-offload-amdgpu-runtime-experimental"


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D115045

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


[PATCH] D113294: [IR] Remove unbounded as possible value for vscale_range minimum

2021-12-06 Thread Paul Walker via Phabricator via cfe-commits
paulwalker-arm accepted this revision.
paulwalker-arm added a comment.
This revision is now accepted and ready to land.

One minor issue but otherwise looks good.




Comment at: clang/lib/Basic/Targets/AArch64.cpp:482
+return std::pair(
+LangOpts.VScaleMin ? LangOpts.VScaleMin : 1, 16);
+

This part is no longer needed because to get here you already know 
`LangOpts.VScaleMin==0 && LangOpts.VScaleMax==0`. 


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

https://reviews.llvm.org/D113294

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


[PATCH] D115045: [Clang] Ignore CLANG_DEFAULT_LINKER for custom-linker toolchains

2021-12-06 Thread Simon Moll via Phabricator via cfe-commits
simoll updated this revision to Diff 392067.
simoll added a comment.
Herald added subscribers: abrachet, kerbowa, ormris, atanasyan, jrtc27, 
aheejin, jgravelle-google, sbc100, nhaehnle, jvesely, sdardis, dschuff.

Use the `-DCLANG_DEFAULT_LINKER` linker in all toolchains but VE. Since 
toolchains are now responsible for this flag, there is a new helper function 
that emulates the old linker selection behavior.
This should unbreak the AMDGPU staging bot.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D115045

Files:
  clang/include/clang/Driver/ToolChain.h
  clang/lib/Driver/ToolChain.cpp
  clang/lib/Driver/ToolChains/AMDGPU.h
  clang/lib/Driver/ToolChains/BareMetal.h
  clang/lib/Driver/ToolChains/Fuchsia.h
  clang/lib/Driver/ToolChains/Hexagon.h
  clang/lib/Driver/ToolChains/MipsLinux.h
  clang/lib/Driver/ToolChains/Solaris.h
  clang/lib/Driver/ToolChains/WebAssembly.h
  clang/test/Driver/ve-toolchain.c
  clang/test/Driver/ve-toolchain.cpp

Index: clang/test/Driver/ve-toolchain.cpp
===
--- clang/test/Driver/ve-toolchain.cpp
+++ clang/test/Driver/ve-toolchain.cpp
@@ -110,10 +110,10 @@
 /// Checking -fintegrated-as
 
 // RUN: %clangxx -### -target ve-unknown-linux-gnu \
-// RUN: -x assembler -fuse-ld=ld %s 2>&1 | \
+// RUN: -x assembler %s 2>&1 | \
 // RUN:FileCheck -check-prefix=AS %s
 // RUN: %clangxx -### -target ve-unknown-linux-gnu \
-// RUN: -fno-integrated-as -x assembler -fuse-ld=ld %s 2>&1 | \
+// RUN: -fno-integrated-as -x assembler %s 2>&1 | \
 // RUN:FileCheck -check-prefix=NAS %s
 
 // AS: clang{{.*}} "-cc1as"
@@ -131,7 +131,6 @@
 
 // RUN: %clangxx -### -target ve-unknown-linux-gnu \
 // RUN: --sysroot %S/Inputs/basic_ve_tree \
-// RUN: -fuse-ld=ld \
 // RUN: -resource-dir=%S/Inputs/basic_ve_tree/resource_dir \
 // RUN: --stdlib=c++ %s 2>&1 | FileCheck -check-prefix=DEF %s
 
Index: clang/test/Driver/ve-toolchain.c
===
--- clang/test/Driver/ve-toolchain.c
+++ clang/test/Driver/ve-toolchain.c
@@ -61,10 +61,10 @@
 /// Checking -fintegrated-as
 
 // RUN: %clang -### -target ve \
-// RUN:-x assembler -fuse-ld=ld %s 2>&1 | \
+// RUN:-x assembler %s 2>&1 | \
 // RUN:FileCheck -check-prefix=AS %s
 // RUN: %clang -### -target ve \
-// RUN:-fno-integrated-as -fuse-ld=ld -x assembler %s 2>&1 | \
+// RUN:-fno-integrated-as -x assembler %s 2>&1 | \
 // RUN:FileCheck -check-prefix=NAS %s
 
 // AS: clang{{.*}} "-cc1as"
@@ -83,7 +83,6 @@
 // RUN: %clang -### -target ve-unknown-linux-gnu \
 // RUN: --sysroot %S/Inputs/basic_ve_tree \
 // RUN: -resource-dir=%S/Inputs/basic_ve_tree/resource_dir \
-// RUN: -fuse-ld=ld \
 // RUN: %s 2>&1 | FileCheck -check-prefix=DEF %s
 
 // DEF:  clang{{.*}}" "-cc1"
Index: clang/lib/Driver/ToolChains/WebAssembly.h
===
--- clang/lib/Driver/ToolChains/WebAssembly.h
+++ clang/lib/Driver/ToolChains/WebAssembly.h
@@ -67,7 +67,9 @@
llvm::opt::ArgStringList &CmdArgs) const override;
   SanitizerMask getSupportedSanitizers() const override;
 
-  const char *getDefaultLinker() const override { return "wasm-ld"; }
+  const char *getDefaultLinker() const override {
+return getConfiguredDefaultLinker("wasm-ld");
+  }
 
   Tool *buildLinker() const override;
 
Index: clang/lib/Driver/ToolChains/Solaris.h
===
--- clang/lib/Driver/ToolChains/Solaris.h
+++ clang/lib/Driver/ToolChains/Solaris.h
@@ -67,7 +67,7 @@
 
   const char *getDefaultLinker() const override {
 // clang currently uses Solaris ld-only options.
-return "/usr/bin/ld";
+return getConfiguredDefaultLinker("/usr/bin/ld");
   }
 
 protected:
Index: clang/lib/Driver/ToolChains/MipsLinux.h
===
--- clang/lib/Driver/ToolChains/MipsLinux.h
+++ clang/lib/Driver/ToolChains/MipsLinux.h
@@ -49,7 +49,7 @@
   }
 
   const char *getDefaultLinker() const override {
-return "ld.lld";
+return getConfiguredDefaultLinker("ld.lld");
   }
 
 private:
Index: clang/lib/Driver/ToolChains/Hexagon.h
===
--- clang/lib/Driver/ToolChains/Hexagon.h
+++ clang/lib/Driver/ToolChains/Hexagon.h
@@ -85,7 +85,8 @@
  llvm::opt::ArgStringList &CC1Args) const override;
 
   const char *getDefaultLinker() const override {
-return getTriple().isMusl() ? "ld.lld" : "hexagon-link";
+return getConfiguredDefaultLinker(getTriple().isMusl() ? "ld.lld"
+   : "hexagon-link");
   }
 
   CXXStdlibType GetCXXStdlibType(const llvm::opt::ArgList &Args) const override;
Index: clang/lib/Driver/ToolChai

[PATCH] D113294: [IR] Remove unbounded as possible value for vscale_range minimum

2021-12-06 Thread Cullen Rhodes via Phabricator via cfe-commits
c-rhodes added inline comments.



Comment at: clang/lib/Basic/Targets/AArch64.cpp:482
+return std::pair(
+LangOpts.VScaleMin ? LangOpts.VScaleMin : 1, 16);
+

paulwalker-arm wrote:
> This part is no longer needed because to get here you already know 
> `LangOpts.VScaleMin==0 && LangOpts.VScaleMax==0`. 
> This part is no longer needed because to get here you already know 
> `LangOpts.VScaleMin==0 && LangOpts.VScaleMax==0`. 

Ah of course, I'll fix before committing, cheers!


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

https://reviews.llvm.org/D113294

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


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

2021-12-06 Thread Jozef Lawrynowicz via Phabricator via cfe-commits
jozefl updated this revision to Diff 392071.
jozefl marked an inline comment as done.
jozefl added a comment.

Thanks, good point, fixed in the attached patch.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108301

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

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

[PATCH] D114235: [clang] Extend ParsedAttr to allow custom handling for type attributes

2021-12-06 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

In D114235#3173549 , @mboehme wrote:

> Aaron, have you had any chance to look at this yet?
>
> I added you as a reviewer because you expressed interest in something like 
> this in this discussion: 
> https://lists.llvm.org/pipermail/cfe-dev/2021-October/069097.html
>
> Is there someone else who would be more appropriate to review this?

I've not had the chance, sorry! My review queue is rather full at the moment, 
so I'm still digging out from under quite a few reviews (around 50 at last 
count) and it may be a bit before I can give this one the attention it 
deserves. This one is more complex because we don't do much of any automatic 
checking for anything about type attributes (tablegen doesn't do much for them 
currently), and touching the type system can have significant (and surprising) 
performance impacts, so we need to be particularly careful here. It's 
definitely on my queue though and I do intend to get to it as soon as I can.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D114235

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


[PATCH] D114080: [SYCL] Diagnose uses of zero length arrays

2021-12-06 Thread Mariya Podchishchaeva via Phabricator via cfe-commits
Fznamznon updated this revision to Diff 392080.
Fznamznon added a comment.

Applied suggestions from Aaron


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D114080

Files:
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Sema/Sema.h
  clang/lib/Sema/Sema.cpp
  clang/lib/Sema/SemaSYCL.cpp
  clang/lib/Sema/SemaType.cpp
  clang/test/SemaSYCL/zero-length-arrays.cpp

Index: clang/test/SemaSYCL/zero-length-arrays.cpp
===
--- /dev/null
+++ clang/test/SemaSYCL/zero-length-arrays.cpp
@@ -0,0 +1,125 @@
+// RUN: %clang_cc1 -fsycl-is-device -triple spir64 -fsyntax-only -verify %s
+//
+// This test checks if compiler reports compilation error on an attempt to use
+// a zero-length array inside device code.
+
+template 
+__attribute__((sycl_kernel)) void kernel(const Func &kernelFunc) {
+  // expected-note@+1 5{{called by 'kernel}}
+  kernelFunc(); // #KernelObjCall
+}
+
+typedef float ZEROARR[0];
+
+struct Wrapper {
+  int A;
+  int BadArray[0]; // expected-note 3{{field of illegal type 'int[0]' declared here}}
+};
+
+struct WrapperOfWrapper { // expected-error 2{{zero-length arrays are not permitted in SYCL device code}}
+  Wrapper F;  // expected-note 2{{within field of type 'Wrapper' declared here}}
+  ZEROARR *Ptr;   //expected-note 5{{field of illegal pointer type 'ZEROARR *' (aka 'float (*)[0]') declared here}}
+};
+
+template  struct InnerTemplated {
+  double Array[Size]; // expected-note 8{{field of illegal type 'double[0]' declared here}}
+};
+
+template  struct Templated {
+  unsigned A;
+  Ty Arr[Size];
+  InnerTemplated Array[Size + 1]; // expected-note 8{{within field of type 'InnerTemplated<0U>[1]' declared here}}
+};
+
+struct KernelSt {
+  int A;
+  int BadArray[0]; // expected-note {{field of illegal type 'int[0]' declared here}}
+  void operator()() const {}
+};
+
+WrapperOfWrapper offendingFoo() {
+  // expected-note@+1 {{called by 'offendingFoo'}}
+  return WrapperOfWrapper{};
+}
+
+template 
+void templatedContext() {
+  Templated Var;
+  // expected-error@#KernelObjCall 2{{zero-length arrays are not permitted in SYCL device code}}
+  // expected-note@#KernelObjCall {{called by 'kernel([=] {
+// expected-note@+1 {{within field of type 'Templated<0U, float>' declared here}}
+(void)Var; // expected-error 2{{zero-length arrays are not permitted in SYCL device code}}
+  });
+  // expected-error@#KernelObjCall {{zero-length arrays are not permitted in SYCL device code}}
+  // expected-note@+2 {{in instantiation of function template specialization}}
+  // expected-note@+1 {{within field of type 'Templated<0U, float>' declared here}}
+  kernel([Var] {
+  });
+}
+
+void foo(const unsigned X) {
+  int Arr[0];  // expected-note 2{{declared here}}
+  ZEROARR TypeDef; // expected-note {{declared here}}
+  ZEROARR *Ptr;// expected-note {{declared here}}
+   // expected-error@#KernelObjCall 3{{zero-length arrays are not permitted in SYCL device code}}
+  // expected-note@+1 {{in instantiation of function template specialization}}
+  kernel([=]() {
+(void)Arr; // expected-error {{zero-length arrays are not permitted in SYCL device code}}
+(void)TypeDef; // expected-error {{zero-length arrays are not permitted in SYCL device code}}
+// expected-note@+1 {{field of illegal pointer type 'ZEROARR *' (aka 'float (*)[0]') declared here}}
+(void)Ptr; // expected-error {{zero-length arrays are not permitted in SYCL device code}}
+  });
+  // expected-error@#KernelObjCall {{zero-length arrays are not permitted in SYCL device code}}
+  // expected-note@+2 {{in instantiation of function template specialization}}
+  // expected-note@+1 {{field of illegal type 'int[0]' declared here}}
+  kernel([Arr] { // expected-error {{zero-length arrays are not permitted in SYCL device code}}
+  });
+  WrapperOfWrapper St;
+  // expected-error@#KernelObjCall 2{{zero-length arrays are not permitted in SYCL device code}}
+  // expected-note@+1 {{in instantiation of function template specialization}}
+  kernel([=] {
+// expected-note@+1 {{within field of type 'WrapperOfWrapper' declared here}}
+(void)St.F.BadArray; // expected-error 4{{zero-length arrays are not permitted in SYCL device code}}
+  });
+  // expected-error@#KernelObjCall 2{{zero-length arrays are not permitted in SYCL device code}}
+  // expected-note@+2 {{in instantiation of function template specialization}}
+  // expected-note@+1 {{within field of type 'WrapperOfWrapper' declared here}}
+  kernel([St] { // expected-error 2{{zero-length arrays are not permitted in SYCL device code}}
+  });
+
+  Templated<1, int> OK;
+  Templated<1 - 1, double> Weirdo;
+  Templated<0, float> Zero;
+  // expected-error@#KernelObjCall 4{{zero-length arrays are not permitted in SYCL device code}}
+  // expected-note@+1 {{in instantiation of functio

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

2021-12-06 Thread Vaibhav Yenamandra via Phabricator via cfe-commits
vaibhav.y added a comment.

ping: This is ready for review now.

Thanks for your patience with the review as well!


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


[PATCH] D114080: [SYCL] Diagnose uses of zero length arrays

2021-12-06 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/D114080/new/

https://reviews.llvm.org/D114080

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


[PATCH] D114439: [Annotation] Allow parameter pack expansions in annotate attribute

2021-12-06 Thread Erich Keane via Phabricator via cfe-commits
erichkeane added inline comments.



Comment at: clang/include/clang/Basic/DiagnosticParseKinds.td:724
+  "attribute %0 does not support pack expansion in the last argument">;
+def err_attribute_parm_pack_last_argument_only : Error<
+  "pack expansion in attributes is restricted to only the last argument">;

I don't really see why this is required?  I would think the 722 would be all 
you would need.



Comment at: clang/lib/Parse/ParseDecl.cpp:450
+  // Pack expansion is only allowed in the last attribute argument.
+  if (ArgExprs.size() + 1 < attributeNumberOfArguments(*AttrName)) {
+Diag(Tok.getLocation(),

I don't think this should be diagnosed here, and I don't think it is 'right'.  
I think the ClangAttrEmitter should ensure that the VariadicExprArgument needs 
to be the 'last' thing, but I think that REALLY means "supports a pack anywhere 
inside of it".

See my test examples below, I don't think this parsing is sufficient for that.



Comment at: clang/test/Parser/cxx0x-attributes.cpp:268
+  void faz [[clang::annotate("B", (Is + ...))]] (); // expected-warning {{pack 
fold expression is a C++17 extension}}
+  void foz [[clang::annotate("C", Is...)]] ();
 }

what about:
void foz [[clang::annotate("D", Is)]] ();

I would expect that to error.

Another test I'd like to see:

void foz[[clang::annotate("E", 1, 2, 3, Is...)]]

Also, I don't see why if THAT works, that:
void foz[[clang::annotate("E", 1, Is..., 2, 3)]]

shouldn't be allowed as well.



Comment at: clang/utils/TableGen/ClangAttrEmitter.cpp:1166
 
   class VariadicExprArgument : public VariadicArgument {
+bool AllowPack = false;

The rule of 'only the last argument is allowed to support a pack' should be in 
the attribute emitter.


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

https://reviews.llvm.org/D114439

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


[clang] 6bb2a4f - [openmp] Default to new rtl for amdgpu

2021-12-06 Thread Jon Chesterfield via cfe-commits

Author: Jon Chesterfield
Date: 2021-12-06T16:56:14Z
New Revision: 6bb2a4f3e6546dc854a6f0dd37d81590e0b2990e

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

LOG: [openmp] Default to new rtl for amdgpu

Reverts D114965 as the compiler backend appears to be working again

Reviewed By: jhuber6

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

Added: 


Modified: 
clang/include/clang/Driver/Options.td
clang/lib/Driver/ToolChains/AMDGPUOpenMP.cpp
clang/lib/Driver/ToolChains/Clang.cpp

Removed: 




diff  --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index 7c257e4a474fa..9d5f021102a5e 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -2442,7 +2442,7 @@ def fno_openmp_assume_teams_oversubscription : 
Flag<["-"], "fno-openmp-assume-te
 def fno_openmp_assume_threads_oversubscription : Flag<["-"], 
"fno-openmp-assume-threads-oversubscription">, 
   Group, Flags<[CC1Option, NoArgumentUnused, HelpHidden]>;
 defm openmp_target_new_runtime: BoolFOption<"openmp-target-new-runtime",
-  LangOpts<"OpenMPTargetNewRuntime">, DefaultFalse,
+  LangOpts<"OpenMPTargetNewRuntime">, DefaultTrue,
   PosFlag,
   NegFlag>;
 defm openmp_optimistic_collapse : BoolFOption<"openmp-optimistic-collapse",

diff  --git a/clang/lib/Driver/ToolChains/AMDGPUOpenMP.cpp 
b/clang/lib/Driver/ToolChains/AMDGPUOpenMP.cpp
index 863e2c597d53a..f282f04b79311 100644
--- a/clang/lib/Driver/ToolChains/AMDGPUOpenMP.cpp
+++ b/clang/lib/Driver/ToolChains/AMDGPUOpenMP.cpp
@@ -267,7 +267,7 @@ void AMDGPUOpenMPToolChain::addClangTargetOptions(
 
   std::string BitcodeSuffix;
   if (DriverArgs.hasFlag(options::OPT_fopenmp_target_new_runtime,
- options::OPT_fno_openmp_target_new_runtime, false))
+ options::OPT_fno_openmp_target_new_runtime, true))
 BitcodeSuffix = "new-amdgpu-" + GPUArch;
   else
 BitcodeSuffix = "amdgcn-" + GPUArch;

diff  --git a/clang/lib/Driver/ToolChains/Clang.cpp 
b/clang/lib/Driver/ToolChains/Clang.cpp
index c5aaa067c4f55..8d92c293d83a4 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -5904,7 +5904,7 @@ void Clang::ConstructJob(Compilation &C, const JobAction 
&JA,
   // runtime.
   if (Args.hasFlag(options::OPT_fopenmp_target_new_runtime,
options::OPT_fno_openmp_target_new_runtime,
-   /*Default=*/!getToolChain().getTriple().isAMDGCN()))
+   /*Default=*/true))
 CmdArgs.push_back("-fopenmp-target-new-runtime");
 
   // When in OpenMP offloading mode, enable debugging on the device.



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


[PATCH] D115157: [openmp] Default to new rtl for amdgpu

2021-12-06 Thread Jon Chesterfield via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG6bb2a4f3e654: [openmp] Default to new rtl for amdgpu 
(authored by JonChesterfield).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D115157

Files:
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/ToolChains/AMDGPUOpenMP.cpp
  clang/lib/Driver/ToolChains/Clang.cpp


Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -5904,7 +5904,7 @@
   // runtime.
   if (Args.hasFlag(options::OPT_fopenmp_target_new_runtime,
options::OPT_fno_openmp_target_new_runtime,
-   /*Default=*/!getToolChain().getTriple().isAMDGCN()))
+   /*Default=*/true))
 CmdArgs.push_back("-fopenmp-target-new-runtime");
 
   // When in OpenMP offloading mode, enable debugging on the device.
Index: clang/lib/Driver/ToolChains/AMDGPUOpenMP.cpp
===
--- clang/lib/Driver/ToolChains/AMDGPUOpenMP.cpp
+++ clang/lib/Driver/ToolChains/AMDGPUOpenMP.cpp
@@ -267,7 +267,7 @@
 
   std::string BitcodeSuffix;
   if (DriverArgs.hasFlag(options::OPT_fopenmp_target_new_runtime,
- options::OPT_fno_openmp_target_new_runtime, false))
+ options::OPT_fno_openmp_target_new_runtime, true))
 BitcodeSuffix = "new-amdgpu-" + GPUArch;
   else
 BitcodeSuffix = "amdgcn-" + GPUArch;
Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -2442,7 +2442,7 @@
 def fno_openmp_assume_threads_oversubscription : Flag<["-"], 
"fno-openmp-assume-threads-oversubscription">, 
   Group, Flags<[CC1Option, NoArgumentUnused, HelpHidden]>;
 defm openmp_target_new_runtime: BoolFOption<"openmp-target-new-runtime",
-  LangOpts<"OpenMPTargetNewRuntime">, DefaultFalse,
+  LangOpts<"OpenMPTargetNewRuntime">, DefaultTrue,
   PosFlag,
   NegFlag>;
 defm openmp_optimistic_collapse : BoolFOption<"openmp-optimistic-collapse",


Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -5904,7 +5904,7 @@
   // runtime.
   if (Args.hasFlag(options::OPT_fopenmp_target_new_runtime,
options::OPT_fno_openmp_target_new_runtime,
-   /*Default=*/!getToolChain().getTriple().isAMDGCN()))
+   /*Default=*/true))
 CmdArgs.push_back("-fopenmp-target-new-runtime");
 
   // When in OpenMP offloading mode, enable debugging on the device.
Index: clang/lib/Driver/ToolChains/AMDGPUOpenMP.cpp
===
--- clang/lib/Driver/ToolChains/AMDGPUOpenMP.cpp
+++ clang/lib/Driver/ToolChains/AMDGPUOpenMP.cpp
@@ -267,7 +267,7 @@
 
   std::string BitcodeSuffix;
   if (DriverArgs.hasFlag(options::OPT_fopenmp_target_new_runtime,
- options::OPT_fno_openmp_target_new_runtime, false))
+ options::OPT_fno_openmp_target_new_runtime, true))
 BitcodeSuffix = "new-amdgpu-" + GPUArch;
   else
 BitcodeSuffix = "amdgcn-" + GPUArch;
Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -2442,7 +2442,7 @@
 def fno_openmp_assume_threads_oversubscription : Flag<["-"], "fno-openmp-assume-threads-oversubscription">, 
   Group, Flags<[CC1Option, NoArgumentUnused, HelpHidden]>;
 defm openmp_target_new_runtime: BoolFOption<"openmp-target-new-runtime",
-  LangOpts<"OpenMPTargetNewRuntime">, DefaultFalse,
+  LangOpts<"OpenMPTargetNewRuntime">, DefaultTrue,
   PosFlag,
   NegFlag>;
 defm openmp_optimistic_collapse : BoolFOption<"openmp-optimistic-collapse",
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D114971: [clang][deps] Handle symlinks in minimizing FS

2021-12-06 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman accepted this revision.
arphaman added a comment.
This revision is now accepted and ready to land.

This looks good to me! I agree, an `enum class` would be cleaner though.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D114971

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


[PATCH] D114966: [clang][deps] Split filesystem caches

2021-12-06 Thread Jan Svoboda via Phabricator via cfe-commits
jansvoboda11 marked 2 inline comments as done.
jansvoboda11 added a comment.

In D114966#3168108 , @dexonsmith 
wrote:

> Thanks for working on this; seems like a great start.

Thanks a lot for the extensive feedback! I'll work through it and create prep 
patches where sensible. It seems like things can be simplified quite a bit.

> At a high-level:
>
> - We should check overhead. It'd be good to benchmark scanning LLVM with 
> `clang-scan-deps` before and after this change.

In my testing, this patch causes ~20% increase in memory usage.

> - The locking is getting harder to track, since the acquisition and release 
> are disconnected. I'd rather use a pattern that kept this simple.

I agree. I think I'll explore the direction you suggested in one of your inline 
comments.

> - Identified a few pre-existing issues that might be exacerbated by (and/or 
> harder to fix after) this refactor.

That makes sense.




Comment at: 
clang/include/clang/Tooling/DependencyScanning/DependencyScanningFilesystem.h:73
+/// The value type for original contents cache.
+using OriginalContents = Contents;
+

dexonsmith wrote:
> This should be the `std::unique_ptr` from disk. There's no 
> reason to `memcpy` it into a new allocation.
Fixed in new prep-patch: D115043.



Comment at: 
clang/include/clang/Tooling/DependencyScanning/DependencyScanningFilesystem.h:131-132
+llvm::StringMap StatCache;
+/// Cache of original file contents. Using \c std::map to ensure references
+/// are not invalidated on insertion. 
+std::map OriginalContentsCache;

dexonsmith wrote:
> You don't need the heavyweight std::map for reference validation. You can 
> just use a `DenseMap>`. That's pretty expensive 
> due to allocation traffic, but it's still cheaper than a `std::map`.
> 
> But you can also avoid the allocation traffic by using a BumpPtrAllocator, 
> the same pattern as the StringMap above. E.g.:
> ```
> lang=c++
> llvm::SpecificBumpPtrAllocator OriginalContentsAlloc;
> llvm::DenseMap 
> OriginalContentsCache;
> 
> // insert into shard:
> OriginalContents &getOriginalContentContainer(...) {
>   std::scoped_lock L(CacheMutex);
>   OriginalContents *&OC = OriginalContents[UID];
>   if (!OC)
> OC = new (OriginalContentsAlloc) OriginalContents;
>   return *OC;
> }
> 
> // get original content:
> StringRef getOriginalContentBuffer(...) {
>   OriginalContents &OC = getOriginalContentContainer(...);
>   if (OC.IsInitialized)
> return OC->Content->getBuffer();
> 
>   // Could put this after the lock I guess...
>   std::unique_ptr Content = readFile(...);
> 
>   // check IsInitialized again after locking in case there's a race
>   std::scoped_lock L(SharedStat.Mutex);
>   if (OC->IsInitialized)
> return OC->Content->getBuffer();
> 
>   OC->Content = std::move(Content);
>   OC->IsInitialized = true;
>   return OC->Content->getBuffer();
> }
> ```
> Same pattern for minimized content cache. Since the locks are only held 
> briefly there's no need to pass them around and lose clarity about how long 
> it's open. Also, IIRC, `std::unique_lock` is more expensive than 
> `std::scoped_lock` (but my memory could be faulty).
> 
> 
I didn't think of using `SpecificBumpPtrAllocator` this way, seems really neat, 
thanks for the suggestion!



Comment at: 
clang/include/clang/Tooling/DependencyScanning/DependencyScanningFilesystem.h:131-132
+llvm::StringMap StatCache;
+/// Cache of original file contents. Using \c std::map to ensure references
+/// are not invalidated on insertion. 
+std::map OriginalContentsCache;

jansvoboda11 wrote:
> dexonsmith wrote:
> > You don't need the heavyweight std::map for reference validation. You can 
> > just use a `DenseMap>`. That's pretty 
> > expensive due to allocation traffic, but it's still cheaper than a 
> > `std::map`.
> > 
> > But you can also avoid the allocation traffic by using a BumpPtrAllocator, 
> > the same pattern as the StringMap above. E.g.:
> > ```
> > lang=c++
> > llvm::SpecificBumpPtrAllocator OriginalContentsAlloc;
> > llvm::DenseMap 
> > OriginalContentsCache;
> > 
> > // insert into shard:
> > OriginalContents &getOriginalContentContainer(...) {
> >   std::scoped_lock L(CacheMutex);
> >   OriginalContents *&OC = OriginalContents[UID];
> >   if (!OC)
> > OC = new (OriginalContentsAlloc) OriginalContents;
> >   return *OC;
> > }
> > 
> > // get original content:
> > StringRef getOriginalContentBuffer(...) {
> >   OriginalContents &OC = getOriginalContentContainer(...);
> >   if (OC.IsInitialized)
> > return OC->Content->getBuffer();
> > 
> >   // Could put this after the lock I guess...
> >   std::unique_ptr Content = readFile(...);
> > 
> >   // check IsInitialized again after locking in case there's a race
> >   std::scoped_lock L(SharedStat.Mutex);
> >   if (OC->IsInitialized)
> > return OC->Content->getBuffer(

[clang] 4cb7929 - Revert "[clang][DebugInfo] Allow function-local statics and types to be scoped within a lexical block"

2021-12-06 Thread Jonas Devlieghere via cfe-commits

Author: Jonas Devlieghere
Date: 2021-12-06T09:34:53-08:00
New Revision: 4cb79294e8df8c91ae15264d1014361815d34a53

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

LOG: Revert "[clang][DebugInfo] Allow function-local statics and types to be 
scoped within a lexical block"

This reverts commit e403f4fdc88322201040f2bee7b328e8a78e2f7f because it
breaks TestSetData.py on GreenDragon:

https://green.lab.llvm.org/green/view/LLDB/job/lldb-cmake/39089/

Added: 


Modified: 
clang/lib/CodeGen/CGDebugInfo.cpp
clang/lib/CodeGen/CGDebugInfo.h
clang/lib/CodeGen/CGDecl.cpp

Removed: 
clang/test/CodeGenCXX/debug-info-lexcial-block.cpp



diff  --git a/clang/lib/CodeGen/CGDebugInfo.cpp 
b/clang/lib/CodeGen/CGDebugInfo.cpp
index 75eec22e4e4e5..af651e6f44b7c 100644
--- a/clang/lib/CodeGen/CGDebugInfo.cpp
+++ b/clang/lib/CodeGen/CGDebugInfo.cpp
@@ -227,20 +227,6 @@ llvm::DIScope *CGDebugInfo::getContextDescriptor(const 
Decl *Context,
   return Default;
 }
 
-void CGDebugInfo::recordDeclarationLexicalScope(const Decl &D) {
-  assert(LexicalBlockMap.find(&D) == LexicalBlockMap.end() &&
- "D is already mapped to a lexical block scope");
-  if (!LexicalBlockStack.empty())
-LexicalBlockMap.insert({&D, LexicalBlockStack.back()});
-}
-
-llvm::DIScope *CGDebugInfo::getDeclarationLexicalScope(const Decl *D) {
-  auto I = LexicalBlockMap.find(D);
-  if (I != LexicalBlockMap.end())
-return I->second;
-  return getDeclContextDescriptor(cast(D));
-}
-
 PrintingPolicy CGDebugInfo::getPrintingPolicy() const {
   PrintingPolicy PP = CGM.getContext().getPrintingPolicy();
 
@@ -1360,13 +1346,13 @@ llvm::DIType *CGDebugInfo::CreateType(const TypedefType 
*Ty,
   // declared.
   SourceLocation Loc = Ty->getDecl()->getLocation();
 
-  llvm::DIScope *TDContext = getDeclarationLexicalScope(Ty->getDecl());
   uint32_t Align = getDeclAlignIfRequired(Ty->getDecl(), CGM.getContext());
   // Typedefs are derived from some other type.
   llvm::DINodeArray Annotations = CollectBTFDeclTagAnnotations(Ty->getDecl());
   return DBuilder.createTypedef(Underlying, Ty->getDecl()->getName(),
 getOrCreateFile(Loc), getLineNumber(Loc),
-TDContext, Align, Annotations);
+getDeclContextDescriptor(Ty->getDecl()), Align,
+Annotations);
 }
 
 static unsigned getDwarfCC(CallingConv CC) {
@@ -3265,7 +3251,7 @@ llvm::DIType *CGDebugInfo::CreateEnumType(const EnumType 
*Ty) {
 // entered into the ReplaceMap: finalize() will replace the first
 // FwdDecl with the second and then replace the second with
 // complete type.
-llvm::DIScope *EDContext = getDeclarationLexicalScope(ED);
+llvm::DIScope *EDContext = getDeclContextDescriptor(ED);
 llvm::DIFile *DefUnit = getOrCreateFile(ED->getLocation());
 llvm::TempDIScope TmpContext(DBuilder.createReplaceableCompositeType(
 llvm::dwarf::DW_TAG_enumeration_type, "", TheCU, DefUnit, 0));
@@ -3308,7 +3294,7 @@ llvm::DIType *CGDebugInfo::CreateTypeDefinition(const 
EnumType *Ty) {
 
   llvm::DIFile *DefUnit = getOrCreateFile(ED->getLocation());
   unsigned Line = getLineNumber(ED->getLocation());
-  llvm::DIScope *EnumContext = getDeclarationLexicalScope(ED);
+  llvm::DIScope *EnumContext = getDeclContextDescriptor(ED);
   llvm::DIType *ClassTy = getOrCreateType(ED->getIntegerType(), DefUnit);
   return DBuilder.createEnumerationType(EnumContext, ED->getName(), DefUnit,
 Line, Size, Align, EltArray, ClassTy,
@@ -3611,7 +3597,7 @@ llvm::DICompositeType 
*CGDebugInfo::CreateLimitedType(const RecordType *Ty) {
 Line = getLineNumber(Loc);
   }
 
-  llvm::DIScope *RDContext = getDeclarationLexicalScope(RD);
+  llvm::DIScope *RDContext = getDeclContextDescriptor(RD);
 
   // If we ended up creating the type during the context chain construction,
   // just return that.
@@ -3804,14 +3790,6 @@ void CGDebugInfo::collectVarDeclProps(const VarDecl *VD, 
llvm::DIFile *&Unit,
 TemplateParameters = nullptr;
   }
 
-  // Get context for static locals (that are technically globals) the same way
-  // we do for "local" locals -- by using current lexical block.
-  if (VD->isStaticLocal()) {
-assert(!LexicalBlockStack.empty() && "Region stack mismatch, stack 
empty!");
-VDContext = LexicalBlockStack.back();
-return;
-  }
-
   // Since we emit declarations (DW_AT_members) for static members, place the
   // definition of those static members in the namespace they were declared in
   // in the source code (the lexical decl context).

diff  --git a/clang/lib/CodeGen/CGDebugInfo.h b/clang/lib/CodeGen/CGDebugInfo.h
index 1350ee6808cc2..a7b72fa5f5a65 100644
--- a/clang/lib/CodeGen/CGDebu

[clang] 63a6348 - Revert "Use VersionTuple for parsing versions in Triple, fixing issues that caused the original change to be reverted. This makes it possible to distinguish between "16" and "16.0" a

2021-12-06 Thread James Farrell via cfe-commits

Author: James Farrell
Date: 2021-12-06T17:35:26Z
New Revision: 63a6348cad6caccf285c1661bc60d8ba5a40c972

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

LOG: Revert "Use VersionTuple for parsing versions in Triple, fixing issues 
that caused the original change to be reverted. This makes it possible to 
distinguish between "16" and "16.0" after parsing, which previously was not 
possible."

This reverts commit 50324670342d9391f62671685f4d6b4880a4ea9a.

Added: 


Modified: 
clang/lib/ARCMigrate/ARCMT.cpp
clang/lib/Basic/Targets/OSTargets.cpp
clang/lib/Basic/Targets/OSTargets.h
clang/lib/Basic/Targets/X86.h
clang/lib/Driver/ToolChains/Darwin.cpp
clang/lib/Driver/ToolChains/Linux.cpp
clang/lib/Driver/ToolChains/MSVC.cpp
clang/lib/Driver/ToolChains/NetBSD.cpp
clang/test/Sema/attr-availability-android.c
clang/test/Sema/attr-availability.c
clang/test/Sema/availability-guard-format.mm
clang/test/SemaObjC/attr-availability.m
clang/test/SemaObjC/property-deprecated-warning.m
clang/test/SemaObjC/unguarded-availability-maccatalyst.m
clang/test/SemaObjC/unguarded-availability.m
llvm/include/llvm/ADT/Triple.h
llvm/lib/Analysis/TargetLibraryInfo.cpp
llvm/lib/MC/MCStreamer.cpp
llvm/lib/Support/Triple.cpp
llvm/lib/Target/AArch64/AArch64Subtarget.cpp
llvm/lib/Target/AArch64/AArch64Subtarget.h
llvm/lib/Target/X86/X86Subtarget.h
llvm/unittests/ADT/TripleTest.cpp
llvm/unittests/Support/Host.cpp

Removed: 




diff  --git a/clang/lib/ARCMigrate/ARCMT.cpp b/clang/lib/ARCMigrate/ARCMT.cpp
index 68ee7c59270e0..4851c434d7652 100644
--- a/clang/lib/ARCMigrate/ARCMT.cpp
+++ b/clang/lib/ARCMigrate/ARCMT.cpp
@@ -162,7 +162,9 @@ static bool HasARCRuntime(CompilerInvocation &origCI) {
 return triple.getOSMajorVersion() >= 11;
 
   if (triple.getOS() == llvm::Triple::MacOSX) {
-return triple.getOSVersion() >= VersionTuple(10, 7);
+unsigned Major, Minor, Micro;
+triple.getOSVersion(Major, Minor, Micro);
+return Major > 10 || (Major == 10 && Minor >= 7);
   }
 
   return false;

diff  --git a/clang/lib/Basic/Targets/OSTargets.cpp 
b/clang/lib/Basic/Targets/OSTargets.cpp
index 695cbafe36557..53748bf067cd2 100644
--- a/clang/lib/Basic/Targets/OSTargets.cpp
+++ b/clang/lib/Basic/Targets/OSTargets.cpp
@@ -48,12 +48,12 @@ void getDarwinDefines(MacroBuilder &Builder, const 
LangOptions &Opts,
 Builder.defineMacro("_REENTRANT");
 
   // Get the platform type and version number from the triple.
-  VersionTuple OsVersion;
+  unsigned Maj, Min, Rev;
   if (Triple.isMacOSX()) {
-Triple.getMacOSXVersion(OsVersion);
+Triple.getMacOSXVersion(Maj, Min, Rev);
 PlatformName = "macos";
   } else {
-OsVersion = Triple.getOSVersion();
+Triple.getOSVersion(Maj, Min, Rev);
 PlatformName = llvm::Triple::getOSTypeName(Triple.getOS());
 if (PlatformName == "ios" && Triple.isMacCatalystEnvironment())
   PlatformName = "maccatalyst";
@@ -63,29 +63,29 @@ void getDarwinDefines(MacroBuilder &Builder, const 
LangOptions &Opts,
   // generating code for Win32 ABI. No need to emit
   // __ENVIRONMENT_XX_OS_VERSION_MIN_REQUIRED__.
   if (PlatformName == "win32") {
-PlatformMinVersion = OsVersion;
+PlatformMinVersion = VersionTuple(Maj, Min, Rev);
 return;
   }
 
   // Set the appropriate OS version define.
   if (Triple.isiOS()) {
-assert(OsVersion < VersionTuple(100) && "Invalid version!");
+assert(Maj < 100 && Min < 100 && Rev < 100 && "Invalid version!");
 char Str[7];
-if (OsVersion.getMajor() < 10) {
-  Str[0] = '0' + OsVersion.getMajor();
-  Str[1] = '0' + (OsVersion.getMinor().getValueOr(0) / 10);
-  Str[2] = '0' + (OsVersion.getMinor().getValueOr(0) % 10);
-  Str[3] = '0' + (OsVersion.getSubminor().getValueOr(0) / 10);
-  Str[4] = '0' + (OsVersion.getSubminor().getValueOr(0) % 10);
+if (Maj < 10) {
+  Str[0] = '0' + Maj;
+  Str[1] = '0' + (Min / 10);
+  Str[2] = '0' + (Min % 10);
+  Str[3] = '0' + (Rev / 10);
+  Str[4] = '0' + (Rev % 10);
   Str[5] = '\0';
 } else {
   // Handle versions >= 10.
-  Str[0] = '0' + (OsVersion.getMajor() / 10);
-  Str[1] = '0' + (OsVersion.getMajor() % 10);
-  Str[2] = '0' + (OsVersion.getMinor().getValueOr(0) / 10);
-  Str[3] = '0' + (OsVersion.getMinor().getValueOr(0) % 10);
-  Str[4] = '0' + (OsVersion.getSubminor().getValueOr(0) / 10);
-  Str[5] = '0' + (OsVersion.getSubminor().getValueOr(0) % 10);
+  Str[0] = '0' + (Maj / 10);
+  Str[1] = '0' + (Maj % 10);
+  Str[2] = '0' + (Min / 10);
+  Str[3] = '0' + (Min % 10);
+  Str[4] = '0' + (Rev / 10);
+  Str[5] = '0' + (Rev % 10);
   Str[6] = '\0';
 }
 if (Triple.isTvOS()

[PATCH] D113743: [RFC][clang][DebugInfo] Allow function-local statics and types to be scoped within a lexical block

2021-12-06 Thread Jonas Devlieghere via Phabricator via cfe-commits
JDevlieghere added a comment.

Hey Kristina, this broke TestSetData.py on GreenDragon: 
https://green.lab.llvm.org/green/view/LLDB/job/lldb-cmake/39089/

Since the bot has been red for several hours I went ahead and reverted your 
change in 4cb79294e8df8c91ae15264d1014361815d34a53 
.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D113743

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


[clang] a6816b9 - [analyzer][solver] Fix assertion on (NonLoc, Op, Loc) expressions

2021-12-06 Thread Balazs Benics via cfe-commits

Author: Balazs Benics
Date: 2021-12-06T18:38:58+01:00
New Revision: a6816b957d28ab7855f2af1277c72a6d65b600b4

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

LOG: [analyzer][solver] Fix assertion on (NonLoc, Op, Loc) expressions

Previously, the `SValBuilder` could not encounter expressions of the
following kind:

  NonLoc OP Loc
  Loc OP NonLoc

Where the `Op` is other than `BO_Add`.

As of now, due to the smarter simplification and the fixedpoint
iteration, it turns out we can.
It can happen if the `Loc` was perfectly constrained to a concrete
value (`nonloc::ConcreteInt`), thus the simplifier can do
constant-folding in these cases as well.

Unfortunately, this could cause assertion failures, since we assumed
that the operator must be `BO_Add`, causing a crash.

---

In the patch, I decided to preserve the original behavior (aka. swap the
operands (if the operator is commutative), but if the `RHS` was a
`loc::ConcreteInt` call `evalBinOpNN()`.

I think this interpretation of the arithmetic expression is closer to
reality.

I also tried naively introducing a separate handler for
`loc::ConcreteInt` RHS, before doing handling the more generic `Loc` RHS
case. However, it broke the `zoo1backwards()` test in the `nullptr.cpp`
file. This highlighted for me the importance to preserve the original
behavior for the `BO_Add` at least.

PS: Sorry for introducing yet another branch into this `evalBinOpXX`
madness. I've got a couple of ideas about refactoring these.
We'll see if I can get to it.

The test file demonstrates the issue and makes sure nothing similar
happens. The `no-crash` annotated lines show, where we crashed before
applying this patch.

Reviewed By: martong

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

Added: 
clang/test/Analysis/symbol-simplification-nonloc-loc.cpp

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

Removed: 




diff  --git a/clang/lib/StaticAnalyzer/Core/SValBuilder.cpp 
b/clang/lib/StaticAnalyzer/Core/SValBuilder.cpp
index 71bfc86ab8f71..8edcef319088a 100644
--- a/clang/lib/StaticAnalyzer/Core/SValBuilder.cpp
+++ b/clang/lib/StaticAnalyzer/Core/SValBuilder.cpp
@@ -459,13 +459,23 @@ SVal SValBuilder::evalBinOp(ProgramStateRef state, 
BinaryOperator::Opcode op,
 return evalBinOpLN(state, op, *LV, rhs.castAs(), type);
   }
 
-  if (Optional RV = rhs.getAs()) {
-// Support pointer arithmetic where the addend is on the left
-// and the pointer on the right.
-assert(op == BO_Add);
+  if (const Optional RV = rhs.getAs()) {
+const auto IsCommutative = [](BinaryOperatorKind Op) {
+  return Op == BO_Mul || Op == BO_Add || Op == BO_And || Op == BO_Xor ||
+ Op == BO_Or;
+};
+
+if (IsCommutative(op)) {
+  // Swap operands.
+  return evalBinOpLN(state, op, *RV, lhs.castAs(), type);
+}
 
-// Commute the operands.
-return evalBinOpLN(state, op, *RV, lhs.castAs(), type);
+// If the right operand is a concrete int location then we have nothing
+// better but to treat it as a simple nonloc.
+if (auto RV = rhs.getAs()) {
+  const nonloc::ConcreteInt RhsAsLoc = makeIntVal(RV->getValue());
+  return evalBinOpNN(state, op, lhs.castAs(), RhsAsLoc, type);
+}
   }
 
   return evalBinOpNN(state, op, lhs.castAs(), rhs.castAs(),

diff  --git a/clang/test/Analysis/symbol-simplification-nonloc-loc.cpp 
b/clang/test/Analysis/symbol-simplification-nonloc-loc.cpp
new file mode 100644
index 0..cd7d7009d5935
--- /dev/null
+++ b/clang/test/Analysis/symbol-simplification-nonloc-loc.cpp
@@ -0,0 +1,77 @@
+// RUN: %clang_analyze_cc1 -analyzer-checker=core %s \
+// RUN:-triple x86_64-pc-linux-gnu -verify
+
+#define BINOP(OP) [](auto x, auto y) { return x OP y; }
+
+template 
+void nonloc_OP_loc(int *p, BinOp op) {
+  long p_as_integer = (long)p;
+  if (op(12, p_as_integer) != 11)
+return;
+
+  // Perfectly constrain 'p', thus 'p_as_integer', and trigger a simplification
+  // of the previously recorded constraint.
+  if (p) {
+// no-crash
+  }
+  if (p == (int *)0x404) {
+// no-crash
+  }
+}
+
+// Same as before, but the operands are swapped.
+template 
+void loc_OP_nonloc(int *p, BinOp op) {
+  long p_as_integer = (long)p;
+  if (op(p_as_integer, 12) != 11)
+return;
+
+  if (p) {
+// no-crash
+  }
+  if (p == (int *)0x404) {
+// no-crash
+  }
+}
+
+void instantiate_tests_for_nonloc_OP_loc(int *p) {
+  // Multiplicative and additive operators:
+  nonloc_OP_loc(p, BINOP(*));
+  nonloc_OP_loc(p, BINOP(/)); // no-crash
+  nonloc_OP_loc(p, BINOP(%)); // no-crash
+  nonloc_OP_loc(p, BINOP(+));
+  nonloc_OP_loc(p, BINOP(-)); // no-crash
+
+  // Bitwise operators:
+  // expected-warning@+2 {{The result of the left shift is undefined due to 
shifting by '1

[PATCH] D115149: [analyzer][solver] Fix assertion on (NonLoc, Op, Loc) expressions

2021-12-06 Thread Balázs Benics via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGa6816b957d28: [analyzer][solver] Fix assertion on (NonLoc, 
Op, Loc) expressions (authored by steakhal).
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D115149

Files:
  clang/lib/StaticAnalyzer/Core/SValBuilder.cpp
  clang/test/Analysis/symbol-simplification-nonloc-loc.cpp

Index: clang/test/Analysis/symbol-simplification-nonloc-loc.cpp
===
--- /dev/null
+++ clang/test/Analysis/symbol-simplification-nonloc-loc.cpp
@@ -0,0 +1,77 @@
+// RUN: %clang_analyze_cc1 -analyzer-checker=core %s \
+// RUN:-triple x86_64-pc-linux-gnu -verify
+
+#define BINOP(OP) [](auto x, auto y) { return x OP y; }
+
+template 
+void nonloc_OP_loc(int *p, BinOp op) {
+  long p_as_integer = (long)p;
+  if (op(12, p_as_integer) != 11)
+return;
+
+  // Perfectly constrain 'p', thus 'p_as_integer', and trigger a simplification
+  // of the previously recorded constraint.
+  if (p) {
+// no-crash
+  }
+  if (p == (int *)0x404) {
+// no-crash
+  }
+}
+
+// Same as before, but the operands are swapped.
+template 
+void loc_OP_nonloc(int *p, BinOp op) {
+  long p_as_integer = (long)p;
+  if (op(p_as_integer, 12) != 11)
+return;
+
+  if (p) {
+// no-crash
+  }
+  if (p == (int *)0x404) {
+// no-crash
+  }
+}
+
+void instantiate_tests_for_nonloc_OP_loc(int *p) {
+  // Multiplicative and additive operators:
+  nonloc_OP_loc(p, BINOP(*));
+  nonloc_OP_loc(p, BINOP(/)); // no-crash
+  nonloc_OP_loc(p, BINOP(%)); // no-crash
+  nonloc_OP_loc(p, BINOP(+));
+  nonloc_OP_loc(p, BINOP(-)); // no-crash
+
+  // Bitwise operators:
+  // expected-warning@+2 {{The result of the left shift is undefined due to shifting by '1028', which is greater or equal to the width of type 'int' [core.UndefinedBinaryOperatorResult]}}
+  // expected-warning@+2 {{The result of the right shift is undefined due to shifting by '1028', which is greater or equal to the width of type 'int' [core.UndefinedBinaryOperatorResult]}}
+  nonloc_OP_loc(p, BINOP(<<)); // no-crash
+  nonloc_OP_loc(p, BINOP(>>)); // no-crash
+  nonloc_OP_loc(p, BINOP(&));
+  nonloc_OP_loc(p, BINOP(^));
+  nonloc_OP_loc(p, BINOP(|));
+}
+
+void instantiate_tests_for_loc_OP_nonloc(int *p) {
+  // Multiplicative and additive operators:
+  loc_OP_nonloc(p, BINOP(*));
+  loc_OP_nonloc(p, BINOP(/));
+  loc_OP_nonloc(p, BINOP(%));
+  loc_OP_nonloc(p, BINOP(+));
+  loc_OP_nonloc(p, BINOP(-));
+
+  // Bitwise operators:
+  loc_OP_nonloc(p, BINOP(<<));
+  loc_OP_nonloc(p, BINOP(>>));
+  loc_OP_nonloc(p, BINOP(&));
+  loc_OP_nonloc(p, BINOP(^));
+  loc_OP_nonloc(p, BINOP(|));
+}
+
+// from: nullptr.cpp
+void zoo1backwards() {
+  char **p = nullptr;
+  // expected-warning@+1 {{Dereference of null pointer [core.NullDereference]}}
+  *(0 + p) = nullptr;  // warn
+  **(0 + p) = 'a'; // no-warning: this should be unreachable
+}
Index: clang/lib/StaticAnalyzer/Core/SValBuilder.cpp
===
--- clang/lib/StaticAnalyzer/Core/SValBuilder.cpp
+++ clang/lib/StaticAnalyzer/Core/SValBuilder.cpp
@@ -459,13 +459,23 @@
 return evalBinOpLN(state, op, *LV, rhs.castAs(), type);
   }
 
-  if (Optional RV = rhs.getAs()) {
-// Support pointer arithmetic where the addend is on the left
-// and the pointer on the right.
-assert(op == BO_Add);
+  if (const Optional RV = rhs.getAs()) {
+const auto IsCommutative = [](BinaryOperatorKind Op) {
+  return Op == BO_Mul || Op == BO_Add || Op == BO_And || Op == BO_Xor ||
+ Op == BO_Or;
+};
+
+if (IsCommutative(op)) {
+  // Swap operands.
+  return evalBinOpLN(state, op, *RV, lhs.castAs(), type);
+}
 
-// Commute the operands.
-return evalBinOpLN(state, op, *RV, lhs.castAs(), type);
+// If the right operand is a concrete int location then we have nothing
+// better but to treat it as a simple nonloc.
+if (auto RV = rhs.getAs()) {
+  const nonloc::ConcreteInt RhsAsLoc = makeIntVal(RV->getValue());
+  return evalBinOpNN(state, op, lhs.castAs(), RhsAsLoc, type);
+}
   }
 
   return evalBinOpNN(state, op, lhs.castAs(), rhs.castAs(),
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D115168: [clang-format] [PR49298] Sort includes pass will sort inside raw strings

2021-12-06 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay created this revision.
MyDeveloperDay added reviewers: HazardyKnusperkeks, curdeius, owenpan, njames93.
MyDeveloperDay added projects: clang, clang-format.
MyDeveloperDay requested review of this revision.

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

clang-format does not respect raw string literals when sorting includes

  const char *RawStr = R"(
  #include "headerB.h"
  #include "headerA.h"
  )";

Running clang-format over with SortIncludes enabled transforms this code to:

  const char *RawStr = R"(
  #include "headerA.h"
  #include "headerB.h"
  )";

The following code tries to minimize this impact during IncludeSorting, by 
treating R"( and )" as equivalent of // clang-format off/on


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D115168

Files:
  clang/lib/Format/Format.cpp
  clang/unittests/Format/SortIncludesTest.cpp


Index: clang/unittests/Format/SortIncludesTest.cpp
===
--- clang/unittests/Format/SortIncludesTest.cpp
+++ clang/unittests/Format/SortIncludesTest.cpp
@@ -1045,6 +1045,37 @@
   EXPECT_EQ(Unsorted, sort(Unsorted, "input.cpp", 0));
 }
 
+TEST_F(SortIncludesTest, DisableRawStringLiteralSorting) {
+
+  EXPECT_EQ("const char *t = R\"(\n"
+"#include \n"
+"#include \n"
+")\";",
+sort("const char *t = R\"(\n"
+ "#include \n"
+ "#include \n"
+ ")\";",
+ "test.cxx", 0));
+
+  EXPECT_EQ("#include \n"
+"#include \n"
+"const char *t = R\"(\n"
+"#include \n"
+"#include \n"
+")\";\n"
+"#include \n"
+"#include ",
+sort("#include \n"
+ "#include \n"
+ "const char *t = R\"(\n"
+ "#include \n"
+ "#include \n"
+ ")\";\n"
+ "#include \n"
+ "#include ",
+ "test.cc", 2));
+}
+
 } // end namespace
 } // end namespace format
 } // end namespace clang
Index: clang/lib/Format/Format.cpp
===
--- clang/lib/Format/Format.cpp
+++ clang/lib/Format/Format.cpp
@@ -2590,8 +2590,18 @@
 auto Pos = Code.find('\n', SearchFrom);
 StringRef Line =
 Code.substr(Prev, (Pos != StringRef::npos ? Pos : Code.size()) - Prev);
-
 StringRef Trimmed = Line.trim();
+
+// #includes inside raw string literals need to be ignored.
+// or we will sort the contents of the string.
+// Skip past until we think we we the rawstring literal close.
+if (Trimmed.contains("R\"(")) {
+  FormattingOff = true;
+}
+if (Trimmed.contains(")\"")) {
+  FormattingOff = false;
+}
+
 if (Trimmed == "// clang-format off" || Trimmed == "/* clang-format off 
*/")
   FormattingOff = true;
 else if (Trimmed == "// clang-format on" ||


Index: clang/unittests/Format/SortIncludesTest.cpp
===
--- clang/unittests/Format/SortIncludesTest.cpp
+++ clang/unittests/Format/SortIncludesTest.cpp
@@ -1045,6 +1045,37 @@
   EXPECT_EQ(Unsorted, sort(Unsorted, "input.cpp", 0));
 }
 
+TEST_F(SortIncludesTest, DisableRawStringLiteralSorting) {
+
+  EXPECT_EQ("const char *t = R\"(\n"
+"#include \n"
+"#include \n"
+")\";",
+sort("const char *t = R\"(\n"
+ "#include \n"
+ "#include \n"
+ ")\";",
+ "test.cxx", 0));
+
+  EXPECT_EQ("#include \n"
+"#include \n"
+"const char *t = R\"(\n"
+"#include \n"
+"#include \n"
+")\";\n"
+"#include \n"
+"#include ",
+sort("#include \n"
+ "#include \n"
+ "const char *t = R\"(\n"
+ "#include \n"
+ "#include \n"
+ ")\";\n"
+ "#include \n"
+ "#include ",
+ "test.cc", 2));
+}
+
 } // end namespace
 } // end namespace format
 } // end namespace clang
Index: clang/lib/Format/Format.cpp
===
--- clang/lib/Format/Format.cpp
+++ clang/lib/Format/Format.cpp
@@ -2590,8 +2590,18 @@
 auto Pos = Code.find('\n', SearchFrom);
 StringRef Line =
 Code.substr(Prev, (Pos != StringRef::npos ? Pos : Code.size()) - Prev);
-
 StringRef Trimmed = Line.trim();
+
+// #includes inside raw string literals need to be ignored.
+// or we will sort the contents of the string.
+// Skip past until we think we we the rawstring literal close.
+if (Trimmed.contains("R\"(")) {
+  FormattingOff = true;
+}
+if (Trimmed.contains(")\"")) {
+  FormattingOff = false;
+}
+
 if (Trimmed == "// clang-format off" || Trimmed == "/* 

[PATCH] D115169: Create a generic ABI document for _BitInt

2021-12-06 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman created this revision.
aaron.ballman added reviewers: rjmccall, erichkeane, rsmith.
Herald added a subscriber: arphaman.
aaron.ballman requested review of this revision.
Herald added a project: clang.

This document describes a generic ABI for targets to opt into if they wish.

It was split off from the discussion started in 
https://reviews.llvm.org/D108643.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D115169

Files:
  clang/docs/BitIntABI.rst
  clang/docs/index.rst

Index: clang/docs/index.rst
===
--- clang/docs/index.rst
+++ clang/docs/index.rst
@@ -97,6 +97,7 @@
ItaniumMangleAbiTags
HardwareAssistedAddressSanitizerDesign.rst
ConstantInterpreter
+   BitIntABI
 
 
 Indices and tables
Index: clang/docs/BitIntABI.rst
===
--- /dev/null
+++ clang/docs/BitIntABI.rst
@@ -0,0 +1,176 @@
+===
+_BitInt Clang ABI Specification
+===
+
+.. contents::
+   :local:
+
+History
+===
+
+* **version 1** 2021/10/11
+
+  * Initial document
+
+This document provides a generic ABI specification for the C23 ``_BitInt``
+feature, expressed in terms of concepts common to low-level platform ABIs. This
+document does not directly constrain any platform, as the ABI used for
+``_BitInt`` on a platform is determined by that platform's ABI specification.
+It is expected that platform ABIs will codify the ABI for the ``_BitInt``
+feature on their platform using this specification, either by reference or by
+copying the text of this specification into the platform ABI specification.
+
+Platform ABIs which include this specification by reference should explicitly
+give a version and the parameters listed below. For example: "The ABI for
+``_BitInt`` types is specified by version 1 of the `_BitInt Clang ABI
+Specification `_, using ``64`` as
+the value for ``MaxFundamentalWidth`` and ``long`` as the type for
+``chunk_t``."
+
+High Level
+==
+
+_BitInt describes a family of related bit-precise integer types standardized in
+C23. The original proposal is
+`WG14 N2763 `_
+A ``_BitInt`` type is parameterized to specify how wide the type is (how many
+bits it occupies), including the sign bit. For example, ``_BitInt(2)`` is a
+signed integer with one sign bit and one value bit, while
+``unsigned _BitInt(2)`` is an unsigned integer with two value bits. A
+``signed _BitInt`` must be at least two bits wide, and an ``unsigned _BitInt``
+must be at least one bit wide, so a `_BitInt` must have at least one value bit.
+There is an implementation-defined limit to the widest width supported,
+specified by the ``BITINT_MAXWIDTH`` macro in .
+
+Unlike other integer types, bit-precise integer types do not undergo default
+integer promotion, including when passed as a variadic argument. This means
+that a ``_BitInt(8)`` does not promote to ``int`` when passed as an argument to
+a function or returned as a value from a function.
+
+``_BitInt`` types are ordinary object types and may be used anywhere an object
+type can be, such as a ``struct`` field, ``union`` field, or array element. In
+addition, they are integer types and may be used as the type of a bit-field.
+Like any other type, a ``_BitInt`` object may require more memory than its
+stated bit width in order to satisfy the requirements of byte (or higher)
+alignment. In other words, the width of a ``_BitInt`` affects the semantics of
+operations on the value; it is not a guarantee that the value will be "packed"
+into exactly that many bits in memory.
+
+ABI Description
+===
+
+The ABI of ``_BitInt`` is expected to vary between architectures, but the
+following is a general ABI outline.
+
+Definitions
+---
+
+This generic ABI is described in terms of the following parameters, which must
+be determined by the platform ABI:
+
+``MaxFundamentalWidth`` is the bit-width of the largest fundamental integer
+type for the target that can be used to represent a ``_BitInt``. Typically,
+this will be the largest integer type supported by the ABI, but a smaller limit
+is also acceptable. Once this limit is chosen for an ABI, it should not be
+modified later even if the ABI adds support for a larger fundamental integer
+type.
+
+``chunk_t`` is the type of the fundamental integer type that the target will
+use to store the components of a ``_BitInt`` that is wider than
+``MaxFundamentalWidth``. This should be a fundamental integer type for which
+the target supports overflow operations and will typically be the full width of
+a general purpose register.
+
+These parameters are used to derive other relevant properties as described
+below.
+
+Object Layout (excluding bit-fields)
+
+
+``ChunkWidth`` is defined as ``sizeo

[PATCH] D114885: Use VersionTuple for parsing versions in Triple, fixing issues that caused the original change to be reverted. This makes it possible to distinguish between "16" and "16.0" after pars

2021-12-06 Thread Nico Weber via Phabricator via cfe-commits
thakis added a comment.

Either this or D115139  broke check-llvm on 
arm macs: http://45.33.8.238/macm1/23120/step_11.txt

getMacOSHostVersion sounds kind of triple-related, so I'm guessing it's this 
one.

Please take a look, and revert for now if it takes a while to fix.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D114885

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


[PATCH] D113743: [RFC][clang][DebugInfo] Allow function-local statics and types to be scoped within a lexical block

2021-12-06 Thread Kristina Bessonova via Phabricator via cfe-commits
krisb added a comment.

In D113743#3173981 , @JDevlieghere 
wrote:

> Hey Kristina, this broke TestSetData.py on GreenDragon: 
> https://green.lab.llvm.org/green/view/LLDB/job/lldb-cmake/39089/
>
> Since the bot has been red for several hours I went ahead and reverted your 
> change in 4cb79294e8df8c91ae15264d1014361815d34a53 
> .

Thank you for taking care of this!
I'm looking at the issue, but it's been taking more time than I expected.

This doesn't seem like a flaw of the patch, but likely is a lack of support of 
records/typedefs scoped within a bracketed block from lldb side.
I see lldb couldn't handle cases like

  int foo(int a) {
{
  typedef int Int;
  Int local = a;
  return local;
}
  }

which produces the same error as for TestSetData.py:

  Process 2487354 stopped
  * thread #1, name = 'a.out', stop reason = step over
  frame #0: 0x0040111d a.out`foo(a=1) at test_lldb.cpp:5:12
 2{
 3  typedef int Int;
 4  Int local = a;
  -> 5  return local;
 6}
 7  }
 8  
  (lldb) p local
  error: expression failed to parse:
  error: :45:31: no member named 'local' in namespace 
'$__lldb_local_vars'
  using $__lldb_local_vars::local;
^
  error: :1:1: use of undeclared identifier 'local'
  local
  ^


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D113743

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


[PATCH] D114885: Use VersionTuple for parsing versions in Triple, fixing issues that caused the original change to be reverted. This makes it possible to distinguish between "16" and "16.0" after pars

2021-12-06 Thread Nico Weber via Phabricator via cfe-commits
thakis added a comment.

Oh, it's already reverted, apologies. We'll know if that fixed that bot in 15 
min or so then. Something to keep in mind for relanding though :)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D114885

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


[PATCH] D108643: Introduce _BitInt, deprecate _ExtInt

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

Thanks all! I've commit the renaming in 
6c75ab5f66b403f7ca67e86aeed3a58abe10570b 
 and have 
started a new review for the generic ABI document in 
https://reviews.llvm.org/D115169.


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

https://reviews.llvm.org/D108643

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


[clang] 327d966 - clang-format: [JS] test case for numeric separators.

2021-12-06 Thread Martin Probst via cfe-commits

Author: Martin Probst
Date: 2021-12-06T19:01:24+01:00
New Revision: 327d966365d7b34abd25a920e1f7b5aecfa5c70f

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

LOG: clang-format: [JS] test case for numeric separators.

ES2021 allows numeric literals using `_` as a separator. This already
works, but had no test.

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

Added: 


Modified: 
clang/unittests/Format/FormatTestJS.cpp

Removed: 




diff  --git a/clang/unittests/Format/FormatTestJS.cpp 
b/clang/unittests/Format/FormatTestJS.cpp
index 0c8329536..069b7b19e316e 100644
--- a/clang/unittests/Format/FormatTestJS.cpp
+++ b/clang/unittests/Format/FormatTestJS.cpp
@@ -2692,5 +2692,9 @@ TEST_F(FormatTestJS, NoBreakAfterAsserts) {
   "}\n");
 }
 
+TEST_F(FormatTestJS, NumericSeparators) {
+  verifyFormat("x = 1_000_000 + 12;", "x = 1_000_000   + 12;");
+}
+
 } // namespace format
 } // end namespace clang



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


[PATCH] D115147: clang-format: [JS] test case for numeric separators.

2021-12-06 Thread Martin Probst via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG327d966365d7: clang-format: [JS] test case for numeric 
separators. (authored by mprobst).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D115147

Files:
  clang/unittests/Format/FormatTestJS.cpp


Index: clang/unittests/Format/FormatTestJS.cpp
===
--- clang/unittests/Format/FormatTestJS.cpp
+++ clang/unittests/Format/FormatTestJS.cpp
@@ -2692,5 +2692,9 @@
   "}\n");
 }
 
+TEST_F(FormatTestJS, NumericSeparators) {
+  verifyFormat("x = 1_000_000 + 12;", "x = 1_000_000   + 12;");
+}
+
 } // namespace format
 } // end namespace clang


Index: clang/unittests/Format/FormatTestJS.cpp
===
--- clang/unittests/Format/FormatTestJS.cpp
+++ clang/unittests/Format/FormatTestJS.cpp
@@ -2692,5 +2692,9 @@
   "}\n");
 }
 
+TEST_F(FormatTestJS, NumericSeparators) {
+  verifyFormat("x = 1_000_000 + 12;", "x = 1_000_000   + 12;");
+}
+
 } // namespace format
 } // end namespace clang
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


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

2021-12-06 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay added a comment.

I recently reviewed this item, but I wonder what the overlap with D94661: 
[clang-format] [PR19056] Add support for access modifiers indentation 
 is


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D22505

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


[clang] 1feb8ab - Update the status of N2412 in C (we do not implement large parts of it)

2021-12-06 Thread Aaron Ballman via cfe-commits

Author: Aaron Ballman
Date: 2021-12-06T13:14:13-05:00
New Revision: 1feb8ab0d350640058ffa764e0aeeda2480d6302

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

LOG: Update the status of N2412 in C (we do not implement large parts of it)

Added: 


Modified: 
clang/www/c_status.html

Removed: 




diff  --git a/clang/www/c_status.html b/clang/www/c_status.html
index 302b75d0b1e7..561f061c6449 100644
--- a/clang/www/c_status.html
+++ b/clang/www/c_status.html
@@ -715,7 +715,11 @@ C2x implementation status
 
   Two's complement sign representation
   http://www.open-std.org/jtc1/sc22/wg14/www/docs/n2412.pdf";>N2412
-  Unknown
+  
+Partial
+  Lacking width macros in limits.h and stdint.h
+
+  
 
 
   Adding the u8 character prefix



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


LLVM build master will be restarted soon

2021-12-06 Thread Galina Kistanova via cfe-commits
Hello,

LLVM build master will be restarted in the nearest hour.

Thank you for understanding.

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


[PATCH] D110622: [HIPSPV][3/4] Enable SPIR-V emission for HIP

2021-12-06 Thread Artem Belevich via Phabricator via cfe-commits
tra accepted this revision.
tra added a comment.
This revision is now accepted and ready to land.

Note to self: don't forget to hit "submit". The comments below have been left 
unsubmitted for two weeks. Sorry about that.

The patch looks OK for the time being. That said, I do have concerns that we 
may be organically growing something that will be troublesome to deal with 
long-term.

TBH, I still can't quite make sense of where/how SPIR-V fits in the offloading 
nomenclature.

Right now we have multiple levels of offloading-related control points.

- offload targets, specified by --offload-arch. Determines the ISA of the GPU 
binary we produce.
- offload mechanism: OpenMP, CUDA runtime, HSA. Determines how we 
compile/pack/launch the GPU binaries.
- front-end: CUDA/HIP/ C/C++ w/ OpenMP.
- Driver: Determines compilation pipeline to glue everything together,

SPIR-V in these patches appears to be wearing multiple hats. 
It changes compilation pipeline, it changes offload mechanism and it changes 
offload targets. To further complicate things, it appears to be a derivative of 
the HIP compilation. I can't tell if it's an implementation detail at the 
moment, or whether it will become a more generic offload mechanism that would 
be expected to be used by other front- and back-ends. E.g. can we potentially 
compile CUDA code to target SPIR-V? Can OpenMP offload to SPIR-V?

So, the question is -- what's the right way to specify something like this in a 
consistent manner? 
`--offload` option proposed here does not seem to be a good fit. It was 
intended as a more flexible way to create a single `-cc1` sub-compilation and 
we're doing quite a bit more here.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D110622

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


[PATCH] D115168: [clang-format] [PR49298] Sort includes pass will sort inside raw strings

2021-12-06 Thread Marek Kurdej via Phabricator via cfe-commits
curdeius added inline comments.



Comment at: clang/lib/Format/Format.cpp:2597
+// or we will sort the contents of the string.
+// Skip past until we think we we the rawstring literal close.
+if (Trimmed.contains("R\"(")) {

"we we"?



Comment at: clang/lib/Format/Format.cpp:2598
+// Skip past until we think we we the rawstring literal close.
+if (Trimmed.contains("R\"(")) {
+  FormattingOff = true;

This won't be enough for raw literals with custom delimiter e.g. 
`R"xyz(...)xyz"`.
But well, without any code parsing, this function will always be easily 
outsmarted I guess.
Maybe we can use regexp here and save the delimiter? (And then check it below)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D115168

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


[clang] 1f257ac - Speculatively fix the LLDB build bots from 6c75ab5f66b403f7ca67e86aeed3a58abe10570b

2021-12-06 Thread Aaron Ballman via cfe-commits

Author: Aaron Ballman
Date: 2021-12-06T13:30:15-05:00
New Revision: 1f257accd713a8e302d3fdd2cac615a303295c42

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

LOG: Speculatively fix the LLDB build bots from 
6c75ab5f66b403f7ca67e86aeed3a58abe10570b

It looks like some renames got missed.

Added: 


Modified: 
clang/lib/Sema/SemaTemplateDeduction.cpp
lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp

Removed: 




diff  --git a/clang/lib/Sema/SemaTemplateDeduction.cpp 
b/clang/lib/Sema/SemaTemplateDeduction.cpp
index d527a379c9836..e9636d2b942e8 100644
--- a/clang/lib/Sema/SemaTemplateDeduction.cpp
+++ b/clang/lib/Sema/SemaTemplateDeduction.cpp
@@ -2144,7 +2144,7 @@ static Sema::TemplateDeductionResult 
DeduceTemplateArgumentsByTypeMatch(
 
   return Sema::TDK_NonDeducedMismatch;
 }
-case Type::DependentExtInt: {
+case Type::DependentBitInt: {
   const auto *IP = P->castAs();
 
   if (const auto *IA = A->getAs()) {

diff  --git a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp 
b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
index b1dbc382ff041..9b6327754f6c5 100644
--- a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
+++ b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
@@ -4088,8 +4088,8 @@ 
TypeSystemClang::GetTypeClass(lldb::opaque_compiler_type_t type) {
 return lldb::eTypeClassVector;
   case clang::Type::Builtin:
   // Ext-Int is just an integer type.
-  case clang::Type::ExtInt:
-  case clang::Type::DependentExtInt:
+  case clang::Type::BitInt:
+  case clang::Type::DependentBitInt:
 return lldb::eTypeClassBuiltin;
   case clang::Type::ObjCObjectPointer:
 return lldb::eTypeClassObjCObjectPointer;
@@ -4744,8 +4744,8 @@ lldb::Encoding 
TypeSystemClang::GetEncoding(lldb::opaque_compiler_type_t type,
 // TODO: Set this to more than one???
 break;
 
-  case clang::Type::ExtInt:
-  case clang::Type::DependentExtInt:
+  case clang::Type::BitInt:
+  case clang::Type::DependentBitInt:
 return qual_type->isUnsignedIntegerType() ? lldb::eEncodingUint
   : lldb::eEncodingSint;
 
@@ -5124,8 +5124,8 @@ lldb::Format 
TypeSystemClang::GetFormat(lldb::opaque_compiler_type_t type) {
   case clang::Type::Vector:
 break;
 
-  case clang::Type::ExtInt:
-  case clang::Type::DependentExtInt:
+  case clang::Type::BitInt:
+  case clang::Type::DependentBitInt:
 return qual_type->isUnsignedIntegerType() ? lldb::eFormatUnsigned
   : lldb::eFormatDecimal;
 



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


[PATCH] D114885: Use VersionTuple for parsing versions in Triple, fixing issues that caused the original change to be reverted. This makes it possible to distinguish between "16" and "16.0" after pars

2021-12-06 Thread James Farrell via Phabricator via cfe-commits
jamesfarrell added a comment.

In D114885#3174074 , @thakis wrote:

> Oh, it's already reverted, apologies. We'll know if that fixed that bot in 15 
> min or so then. Something to keep in mind for relanding though :)

Yeah, I'm currently trying to build and test on my Mac laptop. It's not ARM 
tho, so if the test passes there I'm not sure what my next steps are to land 
this change.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D114885

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


[PATCH] D115039: [HIP] Fix -fgpu-rdc for Windows

2021-12-06 Thread Artem Belevich via Phabricator via cfe-commits
tra added a comment.

> Put __hip_gpubin_handle in comdat when it has linkonce_odr linkage.

I wonder when would this happen? I'm not sure we ever want gpubin handles from 
different TUs merged.  I think it may result in different TUs attempting to 
load/init the same GPU binary multiple times.


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

https://reviews.llvm.org/D115039

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


  1   2   >