[PATCH] D102213: [ASTMatchers] Add forCallable(), a generalization of forFunction().

2021-05-13 Thread Valeriy Savchenko via Phabricator via cfe-commits
vsavchenko added a comment.

In D102213#2755963 , @NoQ wrote:

> I totally agree that changing forFunction() to work correctly is the right 
> solution but backwards compatibility breakage is very real because 
> forFunction() accepts a Matcher whereas forCallable() accepts 
> Matcher

Yeah, I see now, it's not that straightforward.
Parameter type difference can be combated even keeping backward compatibility 
(so to speak). You can do `AST_MATCHER_P_OVERLOAD` (like it's done for 
`hasPrefix`, for example) to have two overloads of `forFunction`: one for 
`Matcher` (aka old implementation) and one for `Matcher` 
for new implementation.  I didn't check it, but it probably should work.  It is 
not elegant though and I'm not pushing it.

> The breakage is loud; the code will no longer compile when the intermediate 
> decl() (or namedDecl(), or whatever) is not present. The more annoying part 
> is that when you add namedDecl() back (or if you had it spelled out this way 
> from the start, which doesn't make much sense but is valid and shorter than 
> spelling out functionDecl()), your Node.get() in the match 
> callback will silently start returning null (on anything that isn't a 
> functionDecl()) which may lead to unexpected crashes (previously there was no 
> match at all, now there's a match but the node isn't of the expected type). 
> So a relatively distant piece of code will require manual audit in order to 
> address the potential breakage.

The breakage example has a bit weird precondition IMO.  In that scenario, the 
user had to use `decl` or `namedDecl` where they actually meant `functionDecl` 
AND they should run their matchers on code with blocks.  And even if it does 
happen to someone, I think it's not going to be very painful because a simple 
dump of the node will show what's going on.

> Additionally, forCallable(functionDecl()) is not equivalent to forFunction() 
> (the former silently matches less stuff).

I'm not sure I understand this one.  Can you please show an example where one 
matches something that the other doesn't?


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

https://reviews.llvm.org/D102213

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


[clang] 3f4c518 - [clang-repl] Add exhaustive list of libInterpreter dependencies.

2021-05-13 Thread Vassil Vassilev via cfe-commits

Author: Vassil Vassilev
Date: 2021-05-13T07:18:01Z
New Revision: 3f4c5185926ad2a07a642b8b0b7a4accffeb7e36

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

LOG: [clang-repl] Add exhaustive list of libInterpreter dependencies.

This patch should appease the bots building with -DBUILD_SHARED_LIBS=On,
resolving the regression introduced in 92f9852fc99b.

Added: 


Modified: 
clang/lib/Interpreter/CMakeLists.txt

Removed: 




diff  --git a/clang/lib/Interpreter/CMakeLists.txt 
b/clang/lib/Interpreter/CMakeLists.txt
index f1d7aa95afd1..e08779945b5f 100644
--- a/clang/lib/Interpreter/CMakeLists.txt
+++ b/clang/lib/Interpreter/CMakeLists.txt
@@ -1,6 +1,7 @@
 set(LLVM_LINK_COMPONENTS
core
native
+   Option
OrcJit
Support
Target
@@ -15,9 +16,13 @@ add_clang_library(clangInterpreter
   clangAST
   clangAnalysis
   clangBasic
+  clangDriver
   clangEdit
+  clangFrontend
   clangLex
+  clangParse
   clangSema
+  clangSerialization
   clangCodeGen
   clangFrontendTool
   )



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


[clang] 6045cb8 - Use an allow list on reserved macro identifiers

2021-05-13 Thread via cfe-commits

Author: serge-sans-paille
Date: 2021-05-13T09:23:47+02:00
New Revision: 6045cb89e5e8223eea4d7f9c3a3e0d8d25ff909f

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

LOG: Use an allow list on reserved macro identifiers

The allow list is based on various official sources (see in-code comment).

This fixes https://bugs.llvm.org/show_bug.cgi?id=50248

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

Added: 


Modified: 
clang/lib/Lex/PPDirectives.cpp
clang/test/Preprocessor/macro-reserved.c

Removed: 




diff  --git a/clang/lib/Lex/PPDirectives.cpp b/clang/lib/Lex/PPDirectives.cpp
index 469c4e48525cc..a74b42a883fec 100644
--- a/clang/lib/Lex/PPDirectives.cpp
+++ b/clang/lib/Lex/PPDirectives.cpp
@@ -121,8 +121,49 @@ static bool isForModuleBuilding(Module *M, StringRef 
CurrentModule,
 
 static MacroDiag shouldWarnOnMacroDef(Preprocessor &PP, IdentifierInfo *II) {
   const LangOptions &Lang = PP.getLangOpts();
-  if (II->isReserved(Lang) != ReservedIdentifierStatus::NotReserved)
+  if (II->isReserved(Lang) != ReservedIdentifierStatus::NotReserved) {
+// list from:
+// - https://gcc.gnu.org/onlinedocs/libstdc++/manual/using_macros.html
+// - 
https://docs.microsoft.com/en-us/cpp/c-runtime-library/security-features-in-the-crt?view=msvc-160
+// - man 7 feature_test_macros
+// The list must be sorted for correct binary search.
+static constexpr StringRef ReservedMacro[] = {
+"_ATFILE_SOURCE",
+"_BSD_SOURCE",
+"_CRT_NONSTDC_NO_WARNINGS",
+"_CRT_SECURE_CPP_OVERLOAD_STANDARD_NAMES",
+"_CRT_SECURE_NO_WARNINGS",
+"_FILE_OFFSET_BITS",
+"_FORTIFY_SOURCE",
+"_GLIBCXX_ASSERTIONS",
+"_GLIBCXX_CONCEPT_CHECKS",
+"_GLIBCXX_DEBUG",
+"_GLIBCXX_DEBUG_PEDANTIC",
+"_GLIBCXX_PARALLEL",
+"_GLIBCXX_PARALLEL_ASSERTIONS",
+"_GLIBCXX_SANITIZE_VECTOR",
+"_GLIBCXX_USE_CXX11_ABI",
+"_GLIBCXX_USE_DEPRECATED",
+"_GNU_SOURCE",
+"_ISOC11_SOURCE",
+"_ISOC95_SOURCE",
+"_ISOC99_SOURCE",
+"_LARGEFILE64_SOURCE",
+"_POSIX_C_SOURCE",
+"_REENTRANT",
+"_SVID_SOURCE",
+"_THREAD_SAFE",
+"_XOPEN_SOURCE",
+"_XOPEN_SOURCE_EXTENDED",
+"__STDCPP_WANT_MATH_SPEC_FUNCS__",
+"__STDC_FORMAT_MACROS",
+};
+if (std::binary_search(std::begin(ReservedMacro), std::end(ReservedMacro),
+   II->getName()))
+  return MD_NoWarn;
+
 return MD_ReservedMacro;
+  }
   StringRef Text = II->getName();
   if (II->isKeyword(Lang))
 return MD_KeywordDef;

diff  --git a/clang/test/Preprocessor/macro-reserved.c 
b/clang/test/Preprocessor/macro-reserved.c
index 899074e799aff..f7bec04c73bf8 100644
--- a/clang/test/Preprocessor/macro-reserved.c
+++ b/clang/test/Preprocessor/macro-reserved.c
@@ -62,3 +62,6 @@
 #undef X__Y
 
 int x;
+
+#define _GNU_SOURCE  // no-warning
+#define __STDC_FORMAT_MACROS // no-warning



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


[PATCH] D102168: Use an allow list on reserved macro identifiers

2021-05-13 Thread serge 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 rG6045cb89e5e8: Use an allow list on reserved macro 
identifiers (authored by serge-sans-paille).
Herald added a project: clang.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D102168

Files:
  clang/lib/Lex/PPDirectives.cpp
  clang/test/Preprocessor/macro-reserved.c


Index: clang/test/Preprocessor/macro-reserved.c
===
--- clang/test/Preprocessor/macro-reserved.c
+++ clang/test/Preprocessor/macro-reserved.c
@@ -62,3 +62,6 @@
 #undef X__Y
 
 int x;
+
+#define _GNU_SOURCE  // no-warning
+#define __STDC_FORMAT_MACROS // no-warning
Index: clang/lib/Lex/PPDirectives.cpp
===
--- clang/lib/Lex/PPDirectives.cpp
+++ clang/lib/Lex/PPDirectives.cpp
@@ -121,8 +121,49 @@
 
 static MacroDiag shouldWarnOnMacroDef(Preprocessor &PP, IdentifierInfo *II) {
   const LangOptions &Lang = PP.getLangOpts();
-  if (II->isReserved(Lang) != ReservedIdentifierStatus::NotReserved)
+  if (II->isReserved(Lang) != ReservedIdentifierStatus::NotReserved) {
+// list from:
+// - https://gcc.gnu.org/onlinedocs/libstdc++/manual/using_macros.html
+// - 
https://docs.microsoft.com/en-us/cpp/c-runtime-library/security-features-in-the-crt?view=msvc-160
+// - man 7 feature_test_macros
+// The list must be sorted for correct binary search.
+static constexpr StringRef ReservedMacro[] = {
+"_ATFILE_SOURCE",
+"_BSD_SOURCE",
+"_CRT_NONSTDC_NO_WARNINGS",
+"_CRT_SECURE_CPP_OVERLOAD_STANDARD_NAMES",
+"_CRT_SECURE_NO_WARNINGS",
+"_FILE_OFFSET_BITS",
+"_FORTIFY_SOURCE",
+"_GLIBCXX_ASSERTIONS",
+"_GLIBCXX_CONCEPT_CHECKS",
+"_GLIBCXX_DEBUG",
+"_GLIBCXX_DEBUG_PEDANTIC",
+"_GLIBCXX_PARALLEL",
+"_GLIBCXX_PARALLEL_ASSERTIONS",
+"_GLIBCXX_SANITIZE_VECTOR",
+"_GLIBCXX_USE_CXX11_ABI",
+"_GLIBCXX_USE_DEPRECATED",
+"_GNU_SOURCE",
+"_ISOC11_SOURCE",
+"_ISOC95_SOURCE",
+"_ISOC99_SOURCE",
+"_LARGEFILE64_SOURCE",
+"_POSIX_C_SOURCE",
+"_REENTRANT",
+"_SVID_SOURCE",
+"_THREAD_SAFE",
+"_XOPEN_SOURCE",
+"_XOPEN_SOURCE_EXTENDED",
+"__STDCPP_WANT_MATH_SPEC_FUNCS__",
+"__STDC_FORMAT_MACROS",
+};
+if (std::binary_search(std::begin(ReservedMacro), std::end(ReservedMacro),
+   II->getName()))
+  return MD_NoWarn;
+
 return MD_ReservedMacro;
+  }
   StringRef Text = II->getName();
   if (II->isKeyword(Lang))
 return MD_KeywordDef;


Index: clang/test/Preprocessor/macro-reserved.c
===
--- clang/test/Preprocessor/macro-reserved.c
+++ clang/test/Preprocessor/macro-reserved.c
@@ -62,3 +62,6 @@
 #undef X__Y
 
 int x;
+
+#define _GNU_SOURCE  // no-warning
+#define __STDC_FORMAT_MACROS // no-warning
Index: clang/lib/Lex/PPDirectives.cpp
===
--- clang/lib/Lex/PPDirectives.cpp
+++ clang/lib/Lex/PPDirectives.cpp
@@ -121,8 +121,49 @@
 
 static MacroDiag shouldWarnOnMacroDef(Preprocessor &PP, IdentifierInfo *II) {
   const LangOptions &Lang = PP.getLangOpts();
-  if (II->isReserved(Lang) != ReservedIdentifierStatus::NotReserved)
+  if (II->isReserved(Lang) != ReservedIdentifierStatus::NotReserved) {
+// list from:
+// - https://gcc.gnu.org/onlinedocs/libstdc++/manual/using_macros.html
+// - https://docs.microsoft.com/en-us/cpp/c-runtime-library/security-features-in-the-crt?view=msvc-160
+// - man 7 feature_test_macros
+// The list must be sorted for correct binary search.
+static constexpr StringRef ReservedMacro[] = {
+"_ATFILE_SOURCE",
+"_BSD_SOURCE",
+"_CRT_NONSTDC_NO_WARNINGS",
+"_CRT_SECURE_CPP_OVERLOAD_STANDARD_NAMES",
+"_CRT_SECURE_NO_WARNINGS",
+"_FILE_OFFSET_BITS",
+"_FORTIFY_SOURCE",
+"_GLIBCXX_ASSERTIONS",
+"_GLIBCXX_CONCEPT_CHECKS",
+"_GLIBCXX_DEBUG",
+"_GLIBCXX_DEBUG_PEDANTIC",
+"_GLIBCXX_PARALLEL",
+"_GLIBCXX_PARALLEL_ASSERTIONS",
+"_GLIBCXX_SANITIZE_VECTOR",
+"_GLIBCXX_USE_CXX11_ABI",
+"_GLIBCXX_USE_DEPRECATED",
+"_GNU_SOURCE",
+"_ISOC11_SOURCE",
+"_ISOC95_SOURCE",
+"_ISOC99_SOURCE",
+"_LARGEFILE64_SOURCE",
+"_POSIX_C_SOURCE",
+"_REENTRANT",
+"_SVID_SOURCE",
+"_THREAD_SAFE",
+"_XOPEN_SOURCE",
+"_XOPEN_SOURCE_EXTENDED",
+"__STDCPP_WANT_MATH_SPEC_FUNCS__",
+"__STDC_FORMAT_MACROS",
+};
+if (std::binary_search(std::begin(ReservedMacro),

[PATCH] D99160: [X86][FastISEL] Support DW_TAG_call_site_parameter with FastISEL

2021-05-13 Thread Alok Kumar Sharma via Phabricator via cfe-commits
alok added a comment.

In D99160#2700326 , @alok wrote:

> In D99160#2699038 , @dblaikie wrote:
>
>> In D99160#2698980 , @alok wrote:
>>
>>> In D99160#2671899 , @dblaikie 
>>> wrote:
>>>
 In D99160#2670460 , @djtodoro 
 wrote:

> In D99160#2669576 , @dblaikie 
> wrote:
>
>> In D99160#2668977 , @djtodoro 
>> wrote:
>>
>>> I think that the Debug Entry Values feature should not be enabled by 
>>> default for non optimized code, so the 
>>> `TargetOptions::ShouldEmitDebugEntryValues()` should be patched with 
>>> checking of optimization level (it should be > 0).
>>
>> That's currently intended to be already handled by the frontend, right? 
>> (clang only sets `EnableDebugEntryValues` (which 
>> `ShouldEmitDebugEntryValues` checks (hmm, it checks under 'or', not 
>> 'and', so I'm not sure where the "only above -O0" is implemented, but it 
>> is implemented somewhere?) if optimizations are enabled, yeah?)
>>
>> Oh, is entry_values actually not conditionalized? It's only the 
>> call_site support that's currently conditionalized on "above -O0"?
>
> Looks like there is no explicit check of optimization level (above 
> "-O0"), neither on frontend nor backend for entry-values generation. I 
> think it is the situation since there should not be any optimization (at 
> least that I am aware of, in the case of C/C++) that would cause the 
> entry-values generation...
>
>> Hmm - If that's the case, and we currently have some cases where 
>> entry_values are emitted at -O0, I'm not sure /not/ emitting those is 
>> the right call either. If we believe/have data to show that there are so 
>> few useful uses of entry_value at -O0 that it's not worth the DWARF size 
>> growth to put call_sites in at -O0, then I think it might still be worth 
>> leaving the entry_values in (unless they take up a bunch of extra space) 
>> for the cases of mixed optimization compilation (-O0 some code you're 
>> debugging, but building the rest with optimizations).
>
> Yeah... That is valuable example... I am thinking in that direction as 
> well, and I am closer to the enabling it for -O0 case if that is useful 
> (and there is no dramatic cost in terms of DWARF size).

 Does anyone have this example (where DW_OP_entry_value is used at -O0)? 
 It'd be great to look at it & see if it's a case of unnecessarily losing 
 the location, or legitimately losing it and using entry_value for 
 best-effort recovery (& then a question of whether the loss is appropriate 
 at -O0, or if we want to pessimize -O0 further to avoid the loss).
>>
>> I think this ^ still needs understanding/investigation. Do you have an 
>> example with OP_entry_value at -O0?
>>
 I'd worry about turning on call_sites at -O0 - there'd be a lot more calls 
 (especially for C++ code with lots of implicit operations), but numbers 
 will be needed in any case, so not worth much speculation.
>>>
>>> Sorry for late response.
>>> I tried building  
>>> https://github.com/flang-compiler/classic-flang-llvm-project.git (branch 
>>> release_11x) with compiler (current patch (https://reviews.llvm.org/D99160) 
>>> and https://reviews.llvm.org/D99238) with -O0 -g . 
>>> Interestingly there was no difference.
>>> Reason: https://reviews.llvm.org/D99238 is not sufficient for clang/clang++ 
>>> to enable call-site generation with FastISel though it is sufficient for 
>>> Flang compiler.
>>> Below additional patch is needed to generate call-sites
>>>
>>>   `
>>>
>>> diff --git a/clang/lib/CodeGen/CGDebugInfo.cpp 
>>> b/clang/lib/CodeGen/CGDebugInfo.cpp
>>> index a77f52bd235b..8d4e11faa018 100644
>>>
>>> - a/clang/lib/CodeGen/CGDebugInfo.cpp
>>>
>>> +++ b/clang/lib/CodeGen/CGDebugInfo.cpp
>>> @@ -5149,9 +5149,9 @@ llvm::DebugLoc 
>>> CGDebugInfo::SourceLocToDebugLoc(SourceLocation Loc) {
>>>  }
>>>
>>> llvm::DINode::DIFlags CGDebugInfo::getCallSiteRelatedAttrs() const {
>>>
>>> - // Call site-related attributes are only useful in optimized programs, and
>>> - // when there's a possibility of debugging backtraces.
>>> - if (!CGM.getLangOpts().Optimize || DebugKind == 
>>> codegenoptions::NoDebugInfo ||
>>>
>>> +  // Call site-related attributes are useful when there's a possibility of
>>> +  // debugging backtraces.
>>> +  if (DebugKind == codegenoptions::NoDebugInfo ||
>>>
>>> DebugKind == codegenoptions::LocTrackingOnly)
>>>   return llvm::DINode::FlagZero;
>>>
>>>   `
>>>
>>> With this patch Clang/Clang++ turn on LLVM IR flag 
>>> "DIFlagAllCal

[clang] b2186a6 - [clang-repl] Add final set of missing library dependencies.

2021-05-13 Thread Vassil Vassilev via cfe-commits

Author: Vassil Vassilev
Date: 2021-05-13T08:06:58Z
New Revision: b2186a69c169c7e39c2a769ba859f656aa4cef1b

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

LOG: [clang-repl] Add final set of missing library dependencies.

Added: 


Modified: 
clang/tools/clang-repl/CMakeLists.txt

Removed: 




diff  --git a/clang/tools/clang-repl/CMakeLists.txt 
b/clang/tools/clang-repl/CMakeLists.txt
index 773f46d64af4..106af3f1939b 100644
--- a/clang/tools/clang-repl/CMakeLists.txt
+++ b/clang/tools/clang-repl/CMakeLists.txt
@@ -1,6 +1,8 @@
 set( LLVM_LINK_COMPONENTS
   ${LLVM_TARGETS_TO_BUILD}
+  Core
   Option
+  OrcJIT
   Support
   )
 
@@ -10,6 +12,7 @@ add_clang_executable(clang-repl
   )
 
 target_link_libraries(clang-repl PUBLIC
+  clangBasic
   clangInterpreter
   clangTooling
   LLVMLineEditor



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


[PATCH] D102244: [llvm][AsmPrinter] Restore source location to register clobber warning

2021-05-13 Thread David Spickett via Phabricator via cfe-commits
DavidSpickett updated this revision to Diff 345073.
DavidSpickett added a comment.

- Use diagnose instead of adding methods to LLVMContext
- clang-format the test file


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D102244

Files:
  clang/test/Misc/inline-asm-clobber-warning.c
  llvm/lib/CodeGen/AsmPrinter/AsmPrinterInlineAsm.cpp


Index: llvm/lib/CodeGen/AsmPrinter/AsmPrinterInlineAsm.cpp
===
--- llvm/lib/CodeGen/AsmPrinter/AsmPrinterInlineAsm.cpp
+++ llvm/lib/CodeGen/AsmPrinter/AsmPrinterInlineAsm.cpp
@@ -21,6 +21,7 @@
 #include "llvm/CodeGen/TargetRegisterInfo.h"
 #include "llvm/IR/Constants.h"
 #include "llvm/IR/DataLayout.h"
+#include "llvm/IR/DiagnosticInfo.h"
 #include "llvm/IR/InlineAsm.h"
 #include "llvm/IR/LLVMContext.h"
 #include "llvm/IR/Module.h"
@@ -527,11 +528,6 @@
   }
 
   if (!RestrRegs.empty()) {
-unsigned BufNum = addInlineAsmDiagBuffer(OS.str(), LocMD);
-auto &SrcMgr = *MMI->getContext().getInlineSourceManager();
-SMLoc Loc = SMLoc::getFromPointer(
-SrcMgr.getMemoryBuffer(BufNum)->getBuffer().begin());
-
 std::string Msg = "inline asm clobber list contains reserved registers: ";
 ListSeparator LS;
 for (const Register &RR : RestrRegs) {
@@ -542,8 +538,10 @@
 "Reserved registers on the clobber list may not be "
 "preserved across the asm statement, and clobbering them may "
 "lead to undefined behaviour.";
-SrcMgr.PrintMessage(Loc, SourceMgr::DK_Warning, Msg);
-SrcMgr.PrintMessage(Loc, SourceMgr::DK_Note, Note);
+MMI->getModule()->getContext().diagnose(DiagnosticInfoInlineAsm(
+LocCookie, Msg.c_str(), DiagnosticSeverity::DS_Warning));
+MMI->getModule()->getContext().diagnose(
+DiagnosticInfoInlineAsm(LocCookie, Note, DiagnosticSeverity::DS_Note));
   }
 
   emitInlineAsm(OS.str(), getSubtargetInfo(), TM.Options.MCOptions, LocMD,
Index: clang/test/Misc/inline-asm-clobber-warning.c
===
--- /dev/null
+++ clang/test/Misc/inline-asm-clobber-warning.c
@@ -0,0 +1,21 @@
+/// This test checks that the warning includes the location in the C source
+/// file that contains the inline asm. Instead of saying  for both.
+/// Although this warning is emitted in llvm it cannot be tested from IR as
+/// it does not have that location information at that stage.
+
+// RUN: %clang -target arm-arm-none-eabi -march=armv7-m -c %s -o /dev/null \
+// RUN:   2>&1 | FileCheck %s
+
+// REQUIRES: arm-registered-target
+
+void bar(void) {
+  __asm__ __volatile__("nop"
+   :
+   :
+   : "sp");
+}
+
+// CHECK:  inline-asm-clobber-warning.c:12:24: warning: inline asm clobber 
list contains reserved registers: SP [-Winline-asm]
+// CHECK-NEXT: __asm__ __volatile__("nop"
+// CHECK-NEXT:  ^
+// CHECK-NEXT: inline-asm-clobber-warning.c:12:24: note: Reserved registers on 
the clobber list may not be preserved across the asm statement, and clobbering 
them may lead to undefined behaviour.


Index: llvm/lib/CodeGen/AsmPrinter/AsmPrinterInlineAsm.cpp
===
--- llvm/lib/CodeGen/AsmPrinter/AsmPrinterInlineAsm.cpp
+++ llvm/lib/CodeGen/AsmPrinter/AsmPrinterInlineAsm.cpp
@@ -21,6 +21,7 @@
 #include "llvm/CodeGen/TargetRegisterInfo.h"
 #include "llvm/IR/Constants.h"
 #include "llvm/IR/DataLayout.h"
+#include "llvm/IR/DiagnosticInfo.h"
 #include "llvm/IR/InlineAsm.h"
 #include "llvm/IR/LLVMContext.h"
 #include "llvm/IR/Module.h"
@@ -527,11 +528,6 @@
   }
 
   if (!RestrRegs.empty()) {
-unsigned BufNum = addInlineAsmDiagBuffer(OS.str(), LocMD);
-auto &SrcMgr = *MMI->getContext().getInlineSourceManager();
-SMLoc Loc = SMLoc::getFromPointer(
-SrcMgr.getMemoryBuffer(BufNum)->getBuffer().begin());
-
 std::string Msg = "inline asm clobber list contains reserved registers: ";
 ListSeparator LS;
 for (const Register &RR : RestrRegs) {
@@ -542,8 +538,10 @@
 "Reserved registers on the clobber list may not be "
 "preserved across the asm statement, and clobbering them may "
 "lead to undefined behaviour.";
-SrcMgr.PrintMessage(Loc, SourceMgr::DK_Warning, Msg);
-SrcMgr.PrintMessage(Loc, SourceMgr::DK_Note, Note);
+MMI->getModule()->getContext().diagnose(DiagnosticInfoInlineAsm(
+LocCookie, Msg.c_str(), DiagnosticSeverity::DS_Warning));
+MMI->getModule()->getContext().diagnose(
+DiagnosticInfoInlineAsm(LocCookie, Note, DiagnosticSeverity::DS_Note));
   }
 
   emitInlineAsm(OS.str(), getSubtargetInfo(), TM.Options.MCOptions, LocMD,
Index: clang/test/Misc/inline-asm-clobber-warning.c
===
--- /dev/null
+++ clang/test/Misc/inline-asm-clobber-warning.c
@@

[PATCH] D93626: [clang-format] PR48535 clang-format Incorrectly Removes Space After C Style Cast When Type Is Not a Pointer

2021-05-13 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay added a comment.

This fix seems to cause a regression. 
(https://bugs.llvm.org/show_bug.cgi?id=50326) causing ColumLimit to not be 
observed in the following example

  size_t foo = (*(function))(
  F, Bar, F, Ba, FoLong, BaLong,
  FoLong);

becomes

size_t foo = (*(
function))(F, Bar, F, Ba, FoLong, 
Barr
  rrLong, FoLong);

after this change


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93626

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


[clang] 39e4676 - [PowerPC] Provide doubleword vector predicate form comparisons on Power7

2021-05-13 Thread Nemanja Ivanovic via cfe-commits

Author: Nemanja Ivanovic
Date: 2021-05-13T04:56:56-05:00
New Revision: 39e4676ca798d9aba58823515ac9d48eb64863be

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

LOG: [PowerPC] Provide doubleword vector predicate form comparisons on Power7

There are two reasons this shouldn't be restricted to Power8 and up:
1. For XL compatibility
2. Because clang will expand comparison operators to these intrinsics*

*Without this patch, the following causes a selection error:

int test(vector signed long a, vector signed long b) {
  return a < b;
}

This patch provides the handling for the intrinsics in the back
end and removes the Power8 guards from the predicate functions
(vec_{all|any}_{eq|ne|gt|ge|lt|le}).

Added: 
llvm/test/CodeGen/PowerPC/vec_cmpd_p7.ll

Modified: 
clang/lib/Headers/altivec.h
clang/test/CodeGen/builtins-ppc-p8vector.c
clang/test/CodeGen/builtins-ppc-vsx.c
llvm/lib/Target/PowerPC/PPCISelLowering.cpp
llvm/lib/Target/PowerPC/PPCInstrVSX.td

Removed: 




diff  --git a/clang/lib/Headers/altivec.h b/clang/lib/Headers/altivec.h
index e28d234880fbb..25c1b1de998df 100644
--- a/clang/lib/Headers/altivec.h
+++ b/clang/lib/Headers/altivec.h
@@ -14790,7 +14790,7 @@ static __inline__ int __ATTRS_o_ai vec_all_eq(vector 
bool int __a,
   (vector int)__b);
 }
 
-#ifdef __POWER8_VECTOR__
+#ifdef __VSX__
 static __inline__ int __ATTRS_o_ai vec_all_eq(vector signed long long __a,
   vector signed long long __b) {
   return __builtin_altivec_vcmpequd_p(__CR6_LT, __a, __b);
@@ -14974,7 +14974,7 @@ static __inline__ int __ATTRS_o_ai vec_all_ge(vector 
bool int __a,
   (vector unsigned int)__a);
 }
 
-#ifdef __POWER8_VECTOR__
+#ifdef __VSX__
 static __inline__ int __ATTRS_o_ai vec_all_ge(vector signed long long __a,
   vector signed long long __b) {
   return __builtin_altivec_vcmpgtsd_p(__CR6_EQ, __b, __a);
@@ -15157,7 +15157,7 @@ static __inline__ int __ATTRS_o_ai vec_all_gt(vector 
bool int __a,
   (vector unsigned int)__b);
 }
 
-#ifdef __POWER8_VECTOR__
+#ifdef __VSX__
 static __inline__ int __ATTRS_o_ai vec_all_gt(vector signed long long __a,
   vector signed long long __b) {
   return __builtin_altivec_vcmpgtsd_p(__CR6_LT, __a, __b);
@@ -15347,7 +15347,7 @@ static __inline__ int __ATTRS_o_ai vec_all_le(vector 
bool int __a,
   (vector unsigned int)__b);
 }
 
-#ifdef __POWER8_VECTOR__
+#ifdef __VSX__
 static __inline__ int __ATTRS_o_ai vec_all_le(vector signed long long __a,
   vector signed long long __b) {
   return __builtin_altivec_vcmpgtsd_p(__CR6_EQ, __a, __b);
@@ -15531,7 +15531,7 @@ static __inline__ int __ATTRS_o_ai vec_all_lt(vector 
bool int __a,
   (vector unsigned int)__a);
 }
 
-#ifdef __POWER8_VECTOR__
+#ifdef __VSX__
 static __inline__ int __ATTRS_o_ai vec_all_lt(vector signed long long __a,
   vector signed long long __b) {
   return __builtin_altivec_vcmpgtsd_p(__CR6_LT, __b, __a);
@@ -15746,7 +15746,7 @@ static __inline__ int __ATTRS_o_ai vec_all_ne(vector 
bool int __a,
   (vector int)__b);
 }
 
-#ifdef __POWER8_VECTOR__
+#ifdef __VSX__
 static __inline__ int __ATTRS_o_ai vec_all_ne(vector signed long long __a,
   vector signed long long __b) {
   return __builtin_altivec_vcmpequd_p(__CR6_EQ, __a, __b);
@@ -16035,7 +16035,7 @@ static __inline__ int __ATTRS_o_ai vec_any_eq(vector 
bool int __a,
   (vector int)__b);
 }
 
-#ifdef __POWER8_VECTOR__
+#ifdef __VSX__
 static __inline__ int __ATTRS_o_ai vec_any_eq(vector signed long long __a,
   vector signed long long __b) {
   return __builtin_altivec_vcmpequd_p(__CR6_EQ_REV, __a, __b);
@@ -16225,7 +16225,7 @@ static __inline__ int __ATTRS_o_ai vec_any_ge(vector 
bool int __a,
   (vector unsigned int)__a);
 }
 
-#ifdef __POWER8_VECTOR__
+#ifdef __VSX__
 static __inline__ int __ATTRS_o_ai vec_any_ge(vector signed long long __a,
   vector signed long long __b) {
   return __builtin_altivec_vcmpgtsd_p(__CR6_LT_REV, __b, __a);
@@ -16416,7 +16416,7 @@ static __inline__ int __ATTRS_o_ai vec_any_gt(vector 
bool int __a,
   (vector unsigned int)__b);
 }
 
-#ifdef __POWER8_VECTOR__
+#ifdef __VSX__
 static __inline__ int __ATTRS_o_ai vec_any_gt(vector s

[clang] 4624412 - [clang-repl] Fix ClangReplInterpreterTests unittest dependency.

2021-05-13 Thread Vassil Vassilev via cfe-commits

Author: Vassil Vassilev
Date: 2021-05-13T10:32:08Z
New Revision: 4624412367f9b591fe90ecec8feed7209cd222ac

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

LOG: [clang-repl] Fix ClangReplInterpreterTests unittest dependency.

Added: 


Modified: 
clang/unittests/Interpreter/CMakeLists.txt

Removed: 




diff  --git a/clang/unittests/Interpreter/CMakeLists.txt 
b/clang/unittests/Interpreter/CMakeLists.txt
index b0def94382a6c..ec5e62b989ccf 100644
--- a/clang/unittests/Interpreter/CMakeLists.txt
+++ b/clang/unittests/Interpreter/CMakeLists.txt
@@ -1,4 +1,5 @@
 set(LLVM_LINK_COMPONENTS
+  Core
   )
 
 add_clang_unittest(ClangReplInterpreterTests
@@ -6,6 +7,8 @@ add_clang_unittest(ClangReplInterpreterTests
   InterpreterTest.cpp
   )
 target_link_libraries(ClangReplInterpreterTests PUBLIC
+  clangAST
+  clangBasic
   clangInterpreter
   clangFrontend
   )



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


[PATCH] D102392: [clang-format] PR50326 AlignAfterOpenBracket AlwaysBreak does not keep to the ColumnLimit

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

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

D93626: [clang-format] PR48535 clang-format Incorrectly Removes Space After C 
Style Cast When Type Is Not a Pointer  caused 
a regression in terms of formatting a function ptr, incorrectly thinking it was 
a C-Style cast.

This cased a formatter regression between clang-format-11 and clang-format-12

  void bar()
  {
  size_t foo = function(F, Bar, F, Ba, FoLong);
  
  size_t foo = function(
  F, Bar, F, Ba, FoLong, BaLong,
  FoLong);
  
  size_t foo = (*(function))(F, Bar, F, FoLong);
  
  size_t foo = (*(
  function))(F, Bar, F, Ba, FoLong,
  BaLong, FoLong);
  }

became

  void bar()
  {
  size_t foo1 = function(F, Bar, F, Ba, FoLong);
  
  size_t foo2 = function(
  F, Bar, F, Ba, FoLong, BaLong,
  FoLong);
  
  size_t foo3 = (*(function))(F, Bar, F, FoLong);
  
  size_t foo4 = (*(
  function))(F, Bar, F, Ba, FoLong, 
BaLong, FoLong);
  }

This fixes this issue by simplify the clause to be specific about what is 
wanted rather than what is not.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D102392

Files:
  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
@@ -13298,6 +13298,7 @@
   verifyFormat("size_t idx = (a->*foo)(a - 1);", Spaces);
   verifyFormat("size_t idx = (a->foo)(a - 1);", Spaces);
   verifyFormat("size_t idx = (*foo)(a - 1);", Spaces);
+  verifyFormat("size_t idx = (*(foo))(a - 1);", Spaces);
   Spaces.SpaceAfterCStyleCast = false;
   verifyFormat("size_t idx = (size_t)(ptr - ((char *)file));", Spaces);
   verifyFormat("size_t idx = (size_t)a;", Spaces);
@@ -13305,6 +13306,7 @@
   verifyFormat("size_t idx = (a->*foo)(a - 1);", Spaces);
   verifyFormat("size_t idx = (a->foo)(a - 1);", Spaces);
   verifyFormat("size_t idx = (*foo)(a - 1);", Spaces);
+  verifyFormat("size_t idx = (*(foo))(a - 1);", Spaces);
 }
 
 TEST_F(FormatTest, ConfigurableSpacesInSquareBrackets) {
Index: clang/lib/Format/TokenAnnotator.cpp
===
--- clang/lib/Format/TokenAnnotator.cpp
+++ clang/lib/Format/TokenAnnotator.cpp
@@ -1907,12 +1907,12 @@
 if (Tok.Next->isOneOf(tok::identifier, tok::kw_this))
   return true;
 
-if (Tok.Next->is(tok::l_paren) &&
-!(Tok.Previous && Tok.Previous->is(tok::identifier) &&
-  Tok.Previous->Previous &&
-  Tok.Previous->Previous->isOneOf(tok::arrowstar, tok::arrow,
-  tok::star)))
-  return true;
+// Look for a cast `( x ) (`.
+if (Tok.Next->is(tok::l_paren) && Tok.Previous && Tok.Previous->Previous) {
+  if (Tok.Previous->is(tok::identifier) &&
+  Tok.Previous->Previous->is(tok::l_paren))
+return true;
+}
 
 if (!Tok.Next->Next)
   return false;


Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -13298,6 +13298,7 @@
   verifyFormat("size_t idx = (a->*foo)(a - 1);", Spaces);
   verifyFormat("size_t idx = (a->foo)(a - 1);", Spaces);
   verifyFormat("size_t idx = (*foo)(a - 1);", Spaces);
+  verifyFormat("size_t idx = (*(foo))(a - 1);", Spaces);
   Spaces.SpaceAfterCStyleCast = false;
   verifyFormat("size_t idx = (size_t)(ptr - ((char *)file));", Spaces);
   verifyFormat("size_t idx = (size_t)a;", Spaces);
@@ -13305,6 +13306,7 @@
   verifyFormat("size_t idx = (a->*foo)(a - 1);", Spaces);
   verifyFormat("size_t idx = (a->foo)(a - 1);", Spaces);
   verifyFormat("size_t idx = (*foo)(a - 1);", Spaces);
+  verifyFormat("size_t idx = (*(foo))(a - 1);", Spaces);
 }
 
 TEST_F(FormatTest, ConfigurableSpacesInSquareBrackets) {
Index: clang/lib/Format/TokenAnnotator.cpp
===
--- clang/lib/Format/TokenAnnotator.cpp
+++ clang/lib/Format/TokenAnnotator.cpp
@@ -1907,12 +1907,12 @@
 if (Tok.Next->isOneOf(tok::identifier, tok::kw_this))
   return true;
 
-if (Tok.Next->is(tok::l_paren) &&
-!(Tok.Previous && Tok.Previous->is(tok::identifier) &&
-  Tok.Previous->Previous &&
-  

[PATCH] D101921: [MC] Make it possible for targets to define their own MCObjectFileInfo

2021-05-13 Thread Philipp Krones via Phabricator via cfe-commits
flip1995 updated this revision to Diff 344849.
flip1995 added a comment.
Herald added subscribers: lldb-commits, atanasyan, jrtc27.
Herald added a project: LLDB.

rebased and addressed review comments:

- [MC] Remove MOFI argument from MCContext constructor
- [MC] Remove getTextSectionAlignment function from MCObjectFileInfo


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101921

Files:
  clang/lib/Parse/ParseStmtAsm.cpp
  clang/tools/driver/cc1as_main.cpp
  lldb/source/Plugins/Disassembler/LLVMC/DisassemblerLLVMC.cpp
  lldb/source/Plugins/Instruction/MIPS/EmulateInstructionMIPS.cpp
  lldb/source/Plugins/Instruction/MIPS64/EmulateInstructionMIPS64.cpp
  llvm/include/llvm/MC/MCContext.h
  llvm/include/llvm/Support/TargetRegistry.h
  llvm/lib/CodeGen/MachineModuleInfo.cpp
  llvm/lib/DWARFLinker/DWARFStreamer.cpp
  llvm/lib/MC/MCContext.cpp
  llvm/lib/MC/MCDisassembler/Disassembler.cpp
  llvm/lib/Object/ModuleSymbolTable.cpp
  llvm/tools/llvm-cfi-verify/lib/FileAnalysis.cpp
  llvm/tools/llvm-cfi-verify/lib/FileAnalysis.h
  llvm/tools/llvm-dwp/llvm-dwp.cpp
  llvm/tools/llvm-exegesis/lib/Analysis.cpp
  llvm/tools/llvm-exegesis/lib/Analysis.h
  llvm/tools/llvm-exegesis/lib/LlvmState.cpp
  llvm/tools/llvm-exegesis/lib/SnippetFile.cpp
  llvm/tools/llvm-jitlink/llvm-jitlink.cpp
  llvm/tools/llvm-mc-assemble-fuzzer/llvm-mc-assemble-fuzzer.cpp
  llvm/tools/llvm-mc/llvm-mc.cpp
  llvm/tools/llvm-mca/llvm-mca.cpp
  llvm/tools/llvm-ml/Disassembler.cpp
  llvm/tools/llvm-ml/llvm-ml.cpp
  llvm/tools/llvm-objdump/MachODump.cpp
  llvm/tools/llvm-objdump/llvm-objdump.cpp
  llvm/tools/llvm-profgen/ProfiledBinary.cpp
  llvm/tools/llvm-rtdyld/llvm-rtdyld.cpp
  llvm/tools/sancov/sancov.cpp
  llvm/unittests/CodeGen/MachineInstrTest.cpp
  llvm/unittests/CodeGen/MachineOperandTest.cpp
  llvm/unittests/CodeGen/TestAsmPrinter.cpp
  llvm/unittests/DebugInfo/DWARF/DwarfGenerator.cpp
  llvm/unittests/MC/DwarfLineTables.cpp
  llvm/unittests/MC/SystemZ/SystemZAsmLexerTest.cpp
  mlir/lib/Dialect/GPU/Transforms/SerializeToHsaco.cpp

Index: mlir/lib/Dialect/GPU/Transforms/SerializeToHsaco.cpp
===
--- mlir/lib/Dialect/GPU/Transforms/SerializeToHsaco.cpp
+++ mlir/lib/Dialect/GPU/Transforms/SerializeToHsaco.cpp
@@ -168,9 +168,10 @@
   target->createMCAsmInfo(*mri, this->triple, mcOptions));
   mai->setRelaxELFRelocations(true);
 
-  llvm::MCObjectFileInfo mofi;
-  llvm::MCContext ctx(triple, mai.get(), mri.get(), &mofi, &srcMgr, &mcOptions);
-  mofi.initMCObjectFileInfo(ctx, /*PIC=*/false, /*LargeCodeModel=*/false);
+  llvm::MCContext ctx(triple, mai.get(), mri.get(), &srcMgr, &mcOptions);
+  std::unique_ptr mofi(target->createMCObjectFileInfo(
+  ctx, /*PIC=*/false, /*LargeCodeModel=*/false));
+  ctx.setObjectFileInfo(mofi.get());
 
   SmallString<128> cwd;
   if (!llvm::sys::fs::current_path(cwd))
Index: llvm/unittests/MC/SystemZ/SystemZAsmLexerTest.cpp
===
--- llvm/unittests/MC/SystemZ/SystemZAsmLexerTest.cpp
+++ llvm/unittests/MC/SystemZ/SystemZAsmLexerTest.cpp
@@ -62,6 +62,7 @@
   std::unique_ptr MRI;
   std::unique_ptr MUPMAI;
   std::unique_ptr MII;
+  std::unique_ptr MOFI;
   std::unique_ptr Str;
   std::unique_ptr Parser;
   std::unique_ptr Ctx;
@@ -74,7 +75,6 @@
   const Target *TheTarget;
 
   const MCTargetOptions MCOptions;
-  MCObjectFileInfo MOFI;
 
   SystemZAsmLexerTest() {
 // We will use the SystemZ triple, because of missing
@@ -112,9 +112,11 @@
 SrcMgr.AddNewSourceBuffer(std::move(Buffer), SMLoc());
 EXPECT_EQ(Buffer, nullptr);
 
-Ctx.reset(new MCContext(Triple, MUPMAI.get(), MRI.get(), &MOFI, STI.get(),
-&SrcMgr, &MCOptions));
-MOFI.initMCObjectFileInfo(*Ctx, /*PIC=*/false, /*LargeCodeModel=*/false);
+Ctx.reset(new MCContext(Triple, MUPMAI.get(), MRI.get(), STI.get(), &SrcMgr,
+&MCOptions));
+MOFI.reset(TheTarget->createMCObjectFileInfo(*Ctx, /*PIC=*/false,
+ /*LargeCodeModel=*/false));
+Ctx->setObjectFileInfo(MOFI.get());
 
 Str.reset(TheTarget->createNullStreamer(*Ctx));
 
Index: llvm/unittests/MC/DwarfLineTables.cpp
===
--- llvm/unittests/MC/DwarfLineTables.cpp
+++ llvm/unittests/MC/DwarfLineTables.cpp
@@ -41,7 +41,7 @@
 MCTargetOptions MCOptions;
 MAI.reset(TheTarget->createMCAsmInfo(*MRI, TripleName, MCOptions));
 Ctx = std::make_unique(Triple(TripleName), MAI.get(), MRI.get(),
-  /*MOFI=*/nullptr, /*MSTI=*/nullptr);
+  /*MSTI=*/nullptr);
   }
 
   operator bool() { return Ctx.get(); }
Index: llvm/unittests/DebugInfo/DWARF/DwarfGenerator.cpp
===
--- llvm/un

[PATCH] D101921: [MC] Make it possible for targets to define their own MCObjectFileInfo

2021-05-13 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added a comment.

Can `createMCObjectFileInfo` return `MCObjectFileInfo` instead of 
`std::unique_ptr`?




Comment at: clang/lib/Parse/ParseStmtAsm.cpp:590
+
   if (!MAI || !MII || !MOFI || !STI) {
 Diag(AsmLoc, diag::err_msasm_unable_to_create_target)

Can `MOFI` be null? (i.e. can createMCObjectFileInfo guarantee no-null return 
value?)

Consider moving the construction below the checks.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101921

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


[PATCH] D100630: [Debug-Info][DBX] DW_TAG_rvalue_reference_type should not be generated when dwarf version is smaller than 4

2021-05-13 Thread Adrian Prantl via Phabricator via cfe-commits
aprantl added a comment.

Doing this in the backend SGTM, assuming all of @dblaikie's comments are 
addressed.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100630

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


[PATCH] D100630: [Debug-Info][DBX] DW_TAG_rvalue_reference_type should not be generated when dwarf version is smaller than 4

2021-05-13 Thread David Blaikie via Phabricator via cfe-commits
dblaikie added a comment.

In D100630#2755936 , @aprantl wrote:

> Doing this in the backend SGTM, assuming all of @dblaikie's comments are 
> addressed.

The complication is that if we naively lower DW_TAG_rvalue_reference to 
DW_TAG_reference, then we'll end up with two DW_TAG_reference DIEs in the 
output (one from the rvalue_reference, one from the reference) - which seems 
not ideal. I don't have /great/ ideas about how to address that, but think it 
might be worth figuring out - but doing it in the frontend is pretty simple (& 
CodeView's certainly got precedent for changing the DI metadata in the frontend 
- not sure if we have cases where we change the DI metadata based on DWARF 
version or anything like that - do you know of any?).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100630

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


[PATCH] D100826: [Debug-Info][NFC] add -gstrict-dwarf support in backend

2021-05-13 Thread ChenZheng via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGa0ca4c46ca35: [Debug-Info] add -gstrict-dwarf support in 
backend (authored by shchenz).

Changed prior to commit:
  https://reviews.llvm.org/D100826?vs=339840&id=345022#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100826

Files:
  clang/lib/CodeGen/BackendUtil.cpp
  llvm/include/llvm/CodeGen/CommandFlags.h
  llvm/include/llvm/Target/TargetOptions.h
  llvm/lib/CodeGen/CommandFlags.cpp
  llvm/test/DebugInfo/PowerPC/strict-dwarf.ll

Index: llvm/test/DebugInfo/PowerPC/strict-dwarf.ll
===
--- /dev/null
+++ llvm/test/DebugInfo/PowerPC/strict-dwarf.ll
@@ -0,0 +1,60 @@
+; RUN: llc -filetype=obj -mtriple=powerpc64le-unknown-linux-gnu < %s | \
+; RUN:   llvm-dwarfdump -debug-info - | FileCheck %s
+; RUN: llc -filetype=obj -mtriple=powerpc64le-unknown-linux-gnu \
+; RUN:   -strict-dwarf=true < %s | llvm-dwarfdump -debug-info - | \
+; RUN:   FileCheck %s
+
+; FIXME: when -strict-dwarf=true is specified, we should check "STRICT" to tell
+; that with DWARF 4, we should not generate DWARF 5 attribute DW_AT_noreturn and
+; DW_AT_alignment.
+
+; CHECK: DW_AT_alignment
+; CHECK: DW_AT_noreturn
+; STRICT-NOT: DW_AT_noreturn
+; STRICT-NOT: DW_AT_alignment
+
+@_ZL3var = internal global i32 0, align 16, !dbg !0
+
+; Function Attrs: noinline noreturn optnone uwtable mustprogress
+define dso_local void @_Z1fv() #0 !dbg !12 {
+entry:
+  call void @_Z4exitv(), !dbg !15
+  ret void, !dbg !16
+}
+
+declare void @_Z4exitv()
+
+; Function Attrs: noinline nounwind optnone uwtable mustprogress
+define dso_local signext i32 @_Z3foov() !dbg !17 {
+entry:
+  %0 = load i32, i32* @_ZL3var, align 16, !dbg !21
+  ret i32 %0, !dbg !22
+}
+
+!llvm.dbg.cu = !{!2}
+!llvm.module.flags = !{!7, !8, !9, !10}
+!llvm.ident = !{!11}
+
+!0 = !DIGlobalVariableExpression(var: !1, expr: !DIExpression())
+!1 = distinct !DIGlobalVariable(name: "var", linkageName: "_ZL3var", scope: !2, file: !3, line: 2, type: !6, isLocal: true, isDefinition: true, align: 128)
+!2 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !3, producer: "clang version 13.0.0", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !4, globals: !5, splitDebugInlining: false, nameTableKind: None)
+!3 = !DIFile(filename: "t.cpp", directory: "./")
+!4 = !{}
+!5 = !{!0}
+!6 = !DIBasicType(name: "unsigned int", size: 32, encoding: DW_ATE_unsigned)
+!7 = !{i32 7, !"Dwarf Version", i32 4}
+!8 = !{i32 2, !"Debug Info Version", i32 3}
+!9 = !{i32 1, !"wchar_size", i32 4}
+!10 = !{i32 7, !"uwtable", i32 1}
+!11 = !{!"clang version 13.0.0"}
+!12 = distinct !DISubprogram(name: "f", linkageName: "_Z1fv", scope: !3, file: !3, line: 4, type: !13, scopeLine: 4, flags: DIFlagPrototyped | DIFlagNoReturn, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !4)
+!13 = !DISubroutineType(types: !14)
+!14 = !{null}
+!15 = !DILocation(line: 5, column: 1, scope: !12)
+!16 = !DILocation(line: 7, column: 1, scope: !12)
+!17 = distinct !DISubprogram(name: "foo", linkageName: "_Z3foov", scope: !3, file: !3, line: 10, type: !18, scopeLine: 11, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !4)
+!18 = !DISubroutineType(types: !19)
+!19 = !{!20}
+!20 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
+!21 = !DILocation(line: 12, column: 18, scope: !17)
+!22 = !DILocation(line: 12, column: 11, scope: !17)
Index: llvm/lib/CodeGen/CommandFlags.cpp
===
--- llvm/lib/CodeGen/CommandFlags.cpp
+++ llvm/lib/CodeGen/CommandFlags.cpp
@@ -97,6 +97,7 @@
 CGOPT(bool, ValueTrackingVariableLocations)
 CGOPT(bool, ForceDwarfFrameSection)
 CGOPT(bool, XRayOmitFunctionIndex)
+CGOPT(bool, DebugStrictDwarf)
 
 codegen::RegisterCodeGenFlags::RegisterCodeGenFlags() {
 #define CGBINDOPT(NAME)\
@@ -471,6 +472,10 @@
   cl::init(false));
   CGBINDOPT(XRayOmitFunctionIndex);
 
+  static cl::opt DebugStrictDwarf(
+  "strict-dwarf", cl::desc("use strict dwarf"), cl::init(false));
+  CGBINDOPT(DebugStrictDwarf);
+
 #undef CGBINDOPT
 
   mc::RegisterMCTargetOptionsFlags();
@@ -567,6 +572,7 @@
   Options.ValueTrackingVariableLocations = getValueTrackingVariableLocations();
   Options.ForceDwarfFrameSection = getForceDwarfFrameSection();
   Options.XRayOmitFunctionIndex = getXRayOmitFunctionIndex();
+  Options.DebugStrictDwarf = getDebugStrictDwarf();
 
   Options.MCOptions = mc::InitMCTargetOptionsFromFlags();
 
Index: llvm/include/llvm/Target/TargetOptions.h
===
--- llvm/include/llvm/Target/TargetOptions.h
+++ llvm/include/llvm/Target/TargetOptions.h
@@ -137,6 +137,7 @@
   SupportsDebugEntryValues(false), EnableDebugEntryValues(false),
 

[PATCH] D101921: [MC] Make it possible for targets to define their own MCObjectFileInfo

2021-05-13 Thread Philipp Krones via Phabricator via cfe-commits
flip1995 added a comment.

In D101921#2754426 , @MaskRay wrote:

> Can `createMCObjectFileInfo` return `MCObjectFileInfo` instead of 
> `std::unique_ptr`?

`createMCObjectfileInfo` returns a `MCObjectFileInfo *` similar to every other 
`create*` function in `TargetRegistry.h`.




Comment at: clang/lib/Parse/ParseStmtAsm.cpp:590
+
   if (!MAI || !MII || !MOFI || !STI) {
 Diag(AsmLoc, diag::err_msasm_unable_to_create_target)

MaskRay wrote:
> Can `MOFI` be null? (i.e. can createMCObjectFileInfo guarantee no-null return 
> value?)
> 
> Consider moving the construction below the checks.
You're right. The `createMCObjectFileInfo` always returns a no-null value. I'll 
move the construction and remove the check for `MOFI`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101921

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


[PATCH] D99439: Update @llvm.powi to handle different int sizes for the exponent

2021-05-13 Thread Bjorn Pettersson via Phabricator via cfe-commits
bjope added inline comments.



Comment at: llvm/lib/CodeGen/SelectionDAG/LegalizeFloatTypes.cpp:581
RTLIB::POWI_F128,
RTLIB::POWI_PPCF128);
   if (!TLI.getLibcallName(LC)) {

efriedma wrote:
> This is missing a diagnostic for the exponent.  We don't want to silently 
> miscompile if someone uses an exponent that isn't supported by the target.
Not sure exactly what you suggest. Is that a general comment for all places in 
SelectionDAG where we may emit calls to RTLIB::POWI or what makes this 
SoftenFloatRes special?

If we end up using mismatching types in the call, wouldn't that being detected 
as ICE elsewhere? Only reason I made changes to this function in the first 
place was due to the historical assert above regarding the type of the exponent 
in FPOWI. Maybe I should just drop that assert instead? This is the only place 
where that is checked, but I figure that the SoftenFloatRes legalization is 
just one out of many places where FPOWI is legalized and lowered into libcalls 
to RTLIB::POWI.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99439

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


[PATCH] D102369: [ASTMatchers][NFC] Remove runtime checks where compile time is sufficient

2021-05-13 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

I'm not opposed, but I don't know that this is really an improvement. We've 
gone from a pretty simple code pattern to needing to spell out the type twice 
with a type_trait, and all that we save is a call to `isa<>` within the casting 
operation. While I agree this is strictly executing less code, it's morally the 
same as the usual antipattern of "isa followed by cast should be a dyn_cast". 
Is there evidence that this is a big performance win?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D102369

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


[PATCH] D101139: Create install targets for scan-build-py.

2021-05-13 Thread Anders Waldenborg via Phabricator via cfe-commits
wanders added a comment.

In D101139#2743346 , @aabbaabb wrote:

> Renamed lib to libexec and add custom rules to copy files to build output.

That rename was a bit too fast I think.
I would expect the libraries (libear & libscanbuild) to be in lib/.
The internal wrappers analyze-c++,analyze-cc,intercept-c++,intercept-cc to be 
installed in libexec.
And finally analyze-build, intercept-build, scan-build which are the commands 
user can execute to be installed in bin/

(I have picked up this patch in our internal toolchain as it gives us a way to 
generate compilation databases out of the box. It works fine here)


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

https://reviews.llvm.org/D101139

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


[PATCH] D102369: [ASTMatchers][NFC] Remove runtime checks where compile time is sufficient

2021-05-13 Thread Nathan James via Phabricator via cfe-commits
njames93 added a comment.

In D102369#2756493 , @aaron.ballman 
wrote:

> I'm not opposed, but I don't know that this is really an improvement. We've 
> gone from a pretty simple code pattern to needing to spell out the type twice 
> with a type_trait, and all that we save is a call to `isa<>` within the 
> casting operation. While I agree this is strictly executing less code, it's 
> morally the same as the usual antipattern of "isa followed by cast should be 
> a dyn_cast". Is there evidence that this is a big performance win?



In D102369#2756493 , @aaron.ballman 
wrote:

> I'm not opposed, but I don't know that this is really an improvement. We've 
> gone from a pretty simple code pattern to needing to spell out the type twice 
> with a type_trait, and all that we save is a call to `isa<>` within the 
> casting operation. While I agree this is strictly executing less code, it's 
> morally the same as the usual antipattern of "isa followed by cast should be 
> a dyn_cast". Is there evidence that this is a big performance win?

To be honest, it would be much nicer if we could specialise `isa` to return 
false if there is From type is not a base class of the To type. However I'm not 
sure if that would break anything else.
It's all part of the "Don't do at runtime whats known at compile time


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D102369

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


[PATCH] D102369: [ASTMatchers][NFC] Remove runtime checks where compile time is sufficient

2021-05-13 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

In D102369#2756516 , @njames93 wrote:

> In D102369#2756493 , @aaron.ballman 
> wrote:
>
>> I'm not opposed, but I don't know that this is really an improvement. We've 
>> gone from a pretty simple code pattern to needing to spell out the type 
>> twice with a type_trait, and all that we save is a call to `isa<>` within 
>> the casting operation. While I agree this is strictly executing less code, 
>> it's morally the same as the usual antipattern of "isa followed by cast 
>> should be a dyn_cast". Is there evidence that this is a big performance win?
>
> To be honest, it would be much nicer if we could specialise `isa` to return 
> false if the `From` type is not a base class of the `To` type. However I'm 
> not sure if that would break anything else.

That might be interesting to explore.

> It's all part of the "Don't do at runtime whats known at compile time" idiom. 
> Any performance change would be negligible in this case.

If that's the sole reason for the change, I'm not convinced it carries its 
weight. It's more code, it's more complicated to read, violates the DRY 
principle, and has negligible performance benefit. However, perhaps @klimek has 
different opinions as code owner.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D102369

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


[PATCH] D101640: [clang][patch] Add support for option -fextend-arguments={32,64}: widen integer arguments to int64 in unprototyped function calls

2021-05-13 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: clang/test/CodeGen/extend-arg-64.c:19
+
+int vararg(int, ...);
+

mibintc wrote:
> aaron.ballman wrote:
> > Can you also add a test for K&R C functions? e.g., `int knr();` `sum = 
> > knr(sum, u32, s32, u16, s16, u8, s8);`
> > 
> > Also, can you show what happens when passing a `long long` and an `_ExtInt`
> Yes I can add those tests.  BTW the _ExtInt types are not "promotable" 
> therefore the UsualUnaryConversions have no effect. 
> Yes I can add those tests. BTW the _ExtInt types are not "promotable" 
> therefore the UsualUnaryConversions have no effect.

Thanks! And yeah -- I figured that would be a good test to ensure that this 
flag doesn't impact types that wouldn't typically go through default argument 
promotion. Come to think of it, it may be good to have a test for float and 
double to show that those aren't impacted despite being promotable (with some 
comments explaining why).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101640

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


[PATCH] D102026: Thread safety analysis: Allow exlusive/shared joins for managed and asserted capabilities

2021-05-13 Thread Aaron Puchert via Phabricator via cfe-commits
aaronpuchert added a comment.

Ping @aaron.ballman, also for the parent change.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D102026

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


[PATCH] D102025: Thread safety analysis: Factor out function for merging locks (NFC)

2021-05-13 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: clang/lib/Analysis/ThreadSafety.cpp:2199
+// Take the exclusive capability to reduce further warnings.
+return B.kind() == LK_Exclusive;
+  } else {

The old code was looking at `LDat1.kind() != LK_Exclusive` -- any reason this 
isn't `A.kind() != LK_Exclusive` as well?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D102025

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


[PATCH] D102090: [CMake][ELF] Add -fno-semantic-interposition and -Bsymbolic-functions

2021-05-13 Thread Mark de Wever via Phabricator via cfe-commits
Mordante added a comment.

I tried to build the libc++ benchmarks locally and the benchmark with target 
`to_chars_libcxx` fails to properly execute. Bi-section let to this commit. Can 
the change in the linker flags affect libc++? I also see the scheduled builds 
of libc++ fail at Buildkite https://buildkite.com/llvm-project/libcxx-ci.
Can you have a look at the issue?


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] D102026: Thread safety analysis: Allow exlusive/shared joins for managed and asserted capabilities

2021-05-13 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

In general, I think this makes sense, but I'd like to hear from @delesley as 
well.




Comment at: clang/lib/Analysis/ThreadSafety.cpp:2198
+// For managed capabilities, the destructor should unlock in the right mode
+// anyway. For asserted capabilities no unlocking is needed.
+if ((A.managed() || A.asserted()) && (B.managed() || B.asserted())) {




Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D102026

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


[clang-tools-extra] e07753c - [clang-tidy] Fix test that requires Windows platofrm

2021-05-13 Thread Georgy Komarov via cfe-commits

Author: Georgy Komarov
Date: 2021-05-13T15:51:53+03:00
New Revision: e07753c8814dba100dcae44e2b47947b340ad0e8

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

LOG: [clang-tidy] Fix test that requires Windows platofrm

This commit fixes the cppcoreguidelines-pro-type-vararg test when it
runs on a Windows host, but the toolchain is targeted a non-Windows
platform.

Reviewed By: njames93

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

Added: 


Modified: 

clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-pro-type-vararg-ms.cpp

Removed: 




diff  --git 
a/clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-pro-type-vararg-ms.cpp
 
b/clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-pro-type-vararg-ms.cpp
index 9cb82497a3ae..2a4051599f54 100644
--- 
a/clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-pro-type-vararg-ms.cpp
+++ 
b/clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-pro-type-vararg-ms.cpp
@@ -2,9 +2,7 @@
 // Ensure that the 'cppcoreguidelines-pro-type-vararg' check works with the
 // built-in va_list on Windows systems.
 
-// REQUIRES: system-windows
-
-// RUN: %check_clang_tidy %s cppcoreguidelines-pro-type-vararg %t
+// RUN: %check_clang_tidy %s cppcoreguidelines-pro-type-vararg %t -- 
--extra-arg=--target=x86_64-windows
 
 void test_ms_va_list(int a, ...) {
   __builtin_ms_va_list ap;



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


[PATCH] D102337: [clang-tidy] Fix test that requires Windows platofrm

2021-05-13 Thread Georgy Komarov via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGe07753c8814d: [clang-tidy] Fix test that requires Windows 
platofrm (authored by jubnzv).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D102337

Files:
  
clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-pro-type-vararg-ms.cpp


Index: 
clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-pro-type-vararg-ms.cpp
===
--- 
clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-pro-type-vararg-ms.cpp
+++ 
clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-pro-type-vararg-ms.cpp
@@ -2,9 +2,7 @@
 // Ensure that the 'cppcoreguidelines-pro-type-vararg' check works with the
 // built-in va_list on Windows systems.
 
-// REQUIRES: system-windows
-
-// RUN: %check_clang_tidy %s cppcoreguidelines-pro-type-vararg %t
+// RUN: %check_clang_tidy %s cppcoreguidelines-pro-type-vararg %t -- 
--extra-arg=--target=x86_64-windows
 
 void test_ms_va_list(int a, ...) {
   __builtin_ms_va_list ap;


Index: clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-pro-type-vararg-ms.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-pro-type-vararg-ms.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-pro-type-vararg-ms.cpp
@@ -2,9 +2,7 @@
 // Ensure that the 'cppcoreguidelines-pro-type-vararg' check works with the
 // built-in va_list on Windows systems.
 
-// REQUIRES: system-windows
-
-// RUN: %check_clang_tidy %s cppcoreguidelines-pro-type-vararg %t
+// RUN: %check_clang_tidy %s cppcoreguidelines-pro-type-vararg %t -- --extra-arg=--target=x86_64-windows
 
 void test_ms_va_list(int a, ...) {
   __builtin_ms_va_list ap;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D102397: [AArch64] Lower bitreverse in ISel

2021-05-13 Thread Irina Dobrescu via Phabricator via cfe-commits
Rin created this revision.
Herald added subscribers: dexonsmith, danielkiss, hiraditya, kristof.beyls.
Rin requested review of this revision.
Herald added projects: clang, LLVM.
Herald added subscribers: llvm-commits, cfe-commits.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D102397

Files:
  clang/test/CodeGen/aarch64-neon-misc.c
  llvm/lib/IR/AutoUpgrade.cpp
  llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
  llvm/lib/Target/AArch64/AArch64InstrInfo.td
  llvm/test/CodeGen/AArch64/arm64-vbitwise.ll
  llvm/test/CodeGen/AArch64/bitreverse.ll

Index: llvm/test/CodeGen/AArch64/bitreverse.ll
===
--- llvm/test/CodeGen/AArch64/bitreverse.ll
+++ llvm/test/CodeGen/AArch64/bitreverse.ll
@@ -31,30 +31,8 @@
 declare <8 x i8> @llvm.bitreverse.v8i8(<8 x i8>) readnone
 
 define <8 x i8> @g_vec(<8 x i8> %a) {
-; CHECK-DAG: movi [[M1:v.*]], #15
-; CHECK-DAG: movi [[M2:v.*]], #240
-; CHECK: and  [[A1:v.*]], v0.8b, [[M1]]
-; CHECK: and  [[A2:v.*]], v0.8b, [[M2]]
-; CHECK-DAG: shl  [[L4:v.*]], [[A1]], #4
-; CHECK-DAG: ushr [[R4:v.*]], [[A2]], #4
-; CHECK-DAG: orr  [[V4:v.*]], [[R4]], [[L4]]
-
-; CHECK-DAG: movi [[M3:v.*]], #51
-; CHECK-DAG: movi [[M4:v.*]], #204
-; CHECK: and  [[A3:v.*]], [[V4]], [[M3]]
-; CHECK: and  [[A4:v.*]], [[V4]], [[M4]]
-; CHECK-DAG: shl  [[L2:v.*]], [[A3]], #2
-; CHECK-DAG: ushr [[R2:v.*]], [[A4]], #2
-; CHECK-DAG: orr  [[V2:v.*]], [[R2]], [[L2]]
-
-; CHECK-DAG: movi [[M5:v.*]], #85
-; CHECK-DAG: movi [[M6:v.*]], #170
-; CHECK: and  [[A5:v.*]], [[V2]], [[M5]]
-; CHECK: and  [[A6:v.*]], [[V2]], [[M6]]
-; CHECK-DAG: shl  [[L1:v.*]], [[A5]], #1
-; CHECK-DAG: ushr [[R1:v.*]], [[A6]], #1
-; CHECK: orr  [[V1:v.*]], [[R1]], [[L1]]
-
+;CHECK-LABEL: g_vec:
+;rbit	v0.8b, v0.8b
 ; CHECK: ret
   %b = call <8 x i8> @llvm.bitreverse.v8i8(<8 x i8> %a)
   ret <8 x i8> %b
Index: llvm/test/CodeGen/AArch64/arm64-vbitwise.ll
===
--- llvm/test/CodeGen/AArch64/arm64-vbitwise.ll
+++ llvm/test/CodeGen/AArch64/arm64-vbitwise.ll
@@ -4,7 +4,7 @@
 ;CHECK-LABEL: rbit_8b:
 ;CHECK: rbit.8b
 	%tmp1 = load <8 x i8>, <8 x i8>* %A
-	%tmp3 = call <8 x i8> @llvm.aarch64.neon.rbit.v8i8(<8 x i8> %tmp1)
+	%tmp3 = call <8 x i8> @llvm.bitreverse.v8i8(<8 x i8> %tmp1)
 	ret <8 x i8> %tmp3
 }
 
@@ -12,12 +12,12 @@
 ;CHECK-LABEL: rbit_16b:
 ;CHECK: rbit.16b
 	%tmp1 = load <16 x i8>, <16 x i8>* %A
-	%tmp3 = call <16 x i8> @llvm.aarch64.neon.rbit.v16i8(<16 x i8> %tmp1)
+	%tmp3 = call <16 x i8> @llvm.bitreverse.v16i8(<16 x i8> %tmp1)
 	ret <16 x i8> %tmp3
 }
 
-declare <8 x i8> @llvm.aarch64.neon.rbit.v8i8(<8 x i8>) nounwind readnone
-declare <16 x i8> @llvm.aarch64.neon.rbit.v16i8(<16 x i8>) nounwind readnone
+declare <8 x i8> @llvm.bitreverse.v8i8(<8 x i8>) nounwind readnone
+declare <16 x i8> @llvm.bitreverse.v16i8(<16 x i8>) nounwind readnone
 
 define <8 x i16> @sxtl8h(<8 x i8>* %A) nounwind {
 ;CHECK-LABEL: sxtl8h:
Index: llvm/lib/Target/AArch64/AArch64InstrInfo.td
===
--- llvm/lib/Target/AArch64/AArch64InstrInfo.td
+++ llvm/lib/Target/AArch64/AArch64InstrInfo.td
@@ -4131,7 +4131,8 @@
 def : Pat<(vnot (v1i64 V64:$Rn)),  (NOTv8i8  V64:$Rn)>;
 def : Pat<(vnot (v2i64 V128:$Rn)), (NOTv16i8 V128:$Rn)>;
 
-defm RBIT   : SIMDTwoVectorB<1, 0b01, 0b00101, "rbit", int_aarch64_neon_rbit>;
+//defm RBIT   : SIMDTwoVectorB<1, 0b01, 0b00101, "rbit", int_aarch64_neon_rbit>;
+defm RBIT   : SIMDTwoVectorB<1, 0b01, 0b00101, "rbit", bitreverse>;
 defm REV16  : SIMDTwoVectorB<0, 0b00, 0b1, "rev16", AArch64rev16>;
 defm REV32  : SIMDTwoVectorBH<1, 0b0, "rev32", AArch64rev32>;
 defm REV64  : SIMDTwoVectorBHS<0, 0b0, "rev64", AArch64rev64>;
Index: llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
===
--- llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
+++ llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
@@ -378,6 +378,8 @@
   setOperationAction(ISD::STRICT_FSETCCS, MVT::f64, Custom);
   setOperationAction(ISD::BITREVERSE, MVT::i32, Legal);
   setOperationAction(ISD::BITREVERSE, MVT::i64, Legal);
+  setOperationAction(ISD::BITREVERSE, MVT::v8i8, Legal);
+  setOperationAction(ISD::BITREVERSE, MVT::v16i8, Legal);
   setOperationAction(ISD::BRCOND, MVT::Other, Expand);
   setOperationAction(ISD::BR_CC, MVT::i32, Custom);
   setOperationAction(ISD::BR_CC, MVT::i64, Custom);
Index: llvm/lib/IR/AutoUpgrade.cpp
===
--- llvm/lib/IR/AutoUpgrade.cpp
+++ llvm/lib/IR/AutoUpgrade.cpp
@@ -553,6 +553,11 @@
 F->arg_begin()->getType());
   return true;
 }
+if (Name.startswith("aarch64.neon.rbit")) {
+  NewFn = Intrinsic::getDeclaration(F->getParent(), Intrinsic::bitreverse,
+F->arg_begin()->getType());
+  retur

[PATCH] D102397: [AArch64] Lower bitreverse in ISel

2021-05-13 Thread Dave Green via Phabricator via cfe-commits
dmgreen added a comment.

Sounds good.




Comment at: llvm/lib/Target/AArch64/AArch64InstrInfo.td:4134
 
-defm RBIT   : SIMDTwoVectorB<1, 0b01, 0b00101, "rbit", int_aarch64_neon_rbit>;
+//defm RBIT   : SIMDTwoVectorB<1, 0b01, 0b00101, "rbit", 
int_aarch64_neon_rbit>;
+defm RBIT   : SIMDTwoVectorB<1, 0b01, 0b00101, "rbit", bitreverse>;

We can remove this. And Can we remove the definition on int_aarch64_neon_rbit 
now too?



Comment at: llvm/test/CodeGen/AArch64/bitreverse.ll:33
 
 define <8 x i8> @g_vec(<8 x i8> %a) {
+;CHECK-LABEL: g_vec:

Can we add tests for all these types:
 v8i8 v16i8
 v4i16 v8i16
 v2i32 v4i32
 v1i64 v2i64
Then use update_llc_test_checks to generate the check lines. Also i32 and i64 
would be good to have in here.

Bonus points for pre-committing with the old codegen, to just show changes here.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D102397

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


[PATCH] D102339: [clang] On Windows, ignore case and separators when discarding duplicate dependency file paths.

2021-05-13 Thread Alexandre Ganea via Phabricator via cfe-commits
aganea added a comment.

In D102339#2755867 , @thakis wrote:

> We share obj files built on linux and on windows. So that's a goal for us.

Hello @thakis, I believe you don't use this codepath to generate the cache key, 
do you? I thought you had a custom python script to extract the dependencies?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D102339

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


[PATCH] D102090: [CMake][ELF] Add -fno-semantic-interposition and -Bsymbolic-functions

2021-05-13 Thread Oliver Stannard (Linaro) via Phabricator via cfe-commits
ostannard added a comment.

There is also a test failure on the aarch64 2-stage bot 
(https://lab.llvm.org/buildbot/#/builders/7/builds/2720) which I've bisected to 
this change, so I'll revert it for now.


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


[clang] 92260d7 - Revert "[CMake][ELF] Add -fno-semantic-interposition and -Bsymbolic-functions"

2021-05-13 Thread Oliver Stannard via cfe-commits

Author: Oliver Stannard
Date: 2021-05-13T14:31:17+01:00
New Revision: 92260d7a186425510e96b7036b467a6889d08d97

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

LOG: Revert "[CMake][ELF] Add -fno-semantic-interposition and 
-Bsymbolic-functions"

This reverts commit 3bf1acab5b454ad7fb2074b34663108b53620695.

This is causing the test `gcov-shared-flush.c' to fail on the 2-stage
aarch64 buildbots (https://lab.llvm.org/buildbot/#/builders/7/builds/2720).

Added: 


Modified: 
clang/tools/clang-shlib/CMakeLists.txt
llvm/cmake/modules/HandleLLVMOptions.cmake
llvm/tools/llvm-shlib/CMakeLists.txt

Removed: 




diff  --git a/clang/tools/clang-shlib/CMakeLists.txt 
b/clang/tools/clang-shlib/CMakeLists.txt
index 73e806c49555..5949223fc8e3 100644
--- a/clang/tools/clang-shlib/CMakeLists.txt
+++ b/clang/tools/clang-shlib/CMakeLists.txt
@@ -48,8 +48,3 @@ add_clang_library(clang-cpp
   ${_OBJECTS}
   LINK_LIBS
   ${_DEPS})
-# Optimize function calls and global variable access for default visibility
-# definitions to avoid PLT and reduce dynamic relocations.
-if (NOT APPLE)
-  target_link_options(clang-cpp PRIVATE LINKER:-Bsymbolic-functions)
-endif()

diff  --git a/llvm/cmake/modules/HandleLLVMOptions.cmake 
b/llvm/cmake/modules/HandleLLVMOptions.cmake
index 81f46cf116cf..a64644a08e59 100644
--- a/llvm/cmake/modules/HandleLLVMOptions.cmake
+++ b/llvm/cmake/modules/HandleLLVMOptions.cmake
@@ -305,7 +305,6 @@ if( LLVM_ENABLE_PIC )
 # On Windows all code is PIC. MinGW warns if -fPIC is used.
   else()
 add_flag_or_print_warning("-fPIC" FPIC)
-add_flag_if_supported("-fno-semantic-interposition" 
FNO_SEMANTIC_INTERPOSITION)
   endif()
   # GCC for MIPS can miscompile LLVM due to PR37701.
   if(CMAKE_COMPILER_IS_GNUCXX AND LLVM_NATIVE_ARCH STREQUAL "Mips" AND

diff  --git a/llvm/tools/llvm-shlib/CMakeLists.txt 
b/llvm/tools/llvm-shlib/CMakeLists.txt
index 7259ba263658..b0ee19049e6f 100644
--- a/llvm/tools/llvm-shlib/CMakeLists.txt
+++ b/llvm/tools/llvm-shlib/CMakeLists.txt
@@ -50,9 +50,6 @@ if(LLVM_BUILD_LLVM_DYLIB)
   # Solaris ld does not accept global: *; so there is no way to version 
*all* global symbols
   set(LIB_NAMES 
-Wl,--version-script,${LLVM_LIBRARY_DIR}/tools/llvm-shlib/simple_version_script.map
 ${LIB_NAMES})
 endif()
-# Optimize function calls and global variable access for default visibility
-# definitions to avoid PLT and reduce dynamic relocations.
-target_link_options(LLVM PRIVATE LINKER:-Bsymbolic-functions)
   elseif("${CMAKE_SYSTEM_NAME}" STREQUAL "Darwin")
 set(LIB_NAMES -Wl,-all_load ${LIB_NAMES})
   endif()



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


[PATCH] D102392: [clang-format] PR50326 AlignAfterOpenBracket AlwaysBreak does not keep to the ColumnLimit

2021-05-13 Thread Marek Kurdej via Phabricator via cfe-commits
curdeius accepted this revision.
curdeius added a comment.
This revision is now accepted and ready to land.

LGTM. Not blocking, but I'd add foo4 example from the description as a test 
case (with a link to the bug maybe).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D102392

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


[PATCH] D102191: [PowerPC] Add clang option -m[no-]prefixed

2021-05-13 Thread Nemanja Ivanovic via Phabricator via cfe-commits
nemanjai accepted this revision.
nemanjai added a comment.
This revision is now accepted and ready to land.

LGTM. Thanks.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D102191

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


[PATCH] D102339: [clang] On Windows, ignore case and separators when discarding duplicate dependency file paths.

2021-05-13 Thread Sylvain Audi via Phabricator via cfe-commits
saudi updated this revision to Diff 344947.
saudi added a comment.

Updated for comments from @rnk, except for the canonicalization part.

Are you suggesting that the `DependencyCollector` should be called with the 
already canonicalized paths?

There are a few code paths leading to the `DependencyCollector::addDependency`, 
for some of them the access to the FS are not trivial to me, but I might just 
not have found the right angle to tackle this.


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

https://reviews.llvm.org/D102339

Files:
  clang/lib/Frontend/DependencyFile.cpp
  clang/test/Frontend/dependency-gen-windows-duplicates.c


Index: clang/test/Frontend/dependency-gen-windows-duplicates.c
===
--- /dev/null
+++ clang/test/Frontend/dependency-gen-windows-duplicates.c
@@ -0,0 +1,27 @@
+// REQUIRES: system-windows
+
+// RUN: rm -rf %t.dir
+// RUN: mkdir -p %t.dir/subdir
+// RUN: echo > %t.dir/subdir/x.h
+// RUN: cp %s %t.dir/test.c
+// RUN: cd %t.dir
+
+// RUN: %clang -MD -MF - %t.dir/test.c -fsyntax-only -I %t.dir/subdir | 
FileCheck %s
+// CHECK: test.o:
+// CHECK-NEXT: \test.c
+// CHECK-NEXT: \SubDir\X.h
+// File x.h must appear only once (case insensitive check).
+// CHECK-NOT: {{\\|/}}{{x|X}}.{{h|H}}
+
+// Include x.h several times, with different casing and separators.
+// Since all paths are passed to clang as absolute, all dependencies are 
absolute paths.
+// We expect the output dependencies to contain only one line for file x.h
+
+// Test case sensitivity.
+#include "SubDir/X.h"
+#include "subdir/x.h"
+
+// Test separator sensitivity:
+// clang internally concatenates x.h using the Windows native separator.
+#include 
+
Index: clang/lib/Frontend/DependencyFile.cpp
===
--- clang/lib/Frontend/DependencyFile.cpp
+++ clang/lib/Frontend/DependencyFile.cpp
@@ -141,7 +141,18 @@
 }
 
 bool DependencyCollector::addDependency(StringRef Filename) {
-  if (Seen.insert(Filename).second) {
+  StringRef SearchPath;
+#ifdef _WIN32
+  // Make the search insensitive to case and separators.
+  llvm::SmallString<256> TmpPath = Filename;
+  llvm::sys::path::native(TmpPath);
+  std::transform(TmpPath.begin(), TmpPath.end(), TmpPath.begin(), ::tolower);
+  SearchPath = TmpPath.str();
+#else
+  SearchPath = Filename;
+#endif
+
+  if (Seen.insert(SearchPath).second) {
 Dependencies.push_back(std::string(Filename));
 return true;
   }


Index: clang/test/Frontend/dependency-gen-windows-duplicates.c
===
--- /dev/null
+++ clang/test/Frontend/dependency-gen-windows-duplicates.c
@@ -0,0 +1,27 @@
+// REQUIRES: system-windows
+
+// RUN: rm -rf %t.dir
+// RUN: mkdir -p %t.dir/subdir
+// RUN: echo > %t.dir/subdir/x.h
+// RUN: cp %s %t.dir/test.c
+// RUN: cd %t.dir
+
+// RUN: %clang -MD -MF - %t.dir/test.c -fsyntax-only -I %t.dir/subdir | FileCheck %s
+// CHECK: test.o:
+// CHECK-NEXT: \test.c
+// CHECK-NEXT: \SubDir\X.h
+// File x.h must appear only once (case insensitive check).
+// CHECK-NOT: {{\\|/}}{{x|X}}.{{h|H}}
+
+// Include x.h several times, with different casing and separators.
+// Since all paths are passed to clang as absolute, all dependencies are absolute paths.
+// We expect the output dependencies to contain only one line for file x.h
+
+// Test case sensitivity.
+#include "SubDir/X.h"
+#include "subdir/x.h"
+
+// Test separator sensitivity:
+// clang internally concatenates x.h using the Windows native separator.
+#include 
+
Index: clang/lib/Frontend/DependencyFile.cpp
===
--- clang/lib/Frontend/DependencyFile.cpp
+++ clang/lib/Frontend/DependencyFile.cpp
@@ -141,7 +141,18 @@
 }
 
 bool DependencyCollector::addDependency(StringRef Filename) {
-  if (Seen.insert(Filename).second) {
+  StringRef SearchPath;
+#ifdef _WIN32
+  // Make the search insensitive to case and separators.
+  llvm::SmallString<256> TmpPath = Filename;
+  llvm::sys::path::native(TmpPath);
+  std::transform(TmpPath.begin(), TmpPath.end(), TmpPath.begin(), ::tolower);
+  SearchPath = TmpPath.str();
+#else
+  SearchPath = Filename;
+#endif
+
+  if (Seen.insert(SearchPath).second) {
 Dependencies.push_back(std::string(Filename));
 return true;
   }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 395607a - Reapply [ConstantFold] Fold more operations to poison

2021-05-13 Thread Nikita Popov via cfe-commits

Author: Juneyoung Lee
Date: 2021-05-13T16:04:12+02:00
New Revision: 395607af3cb80f25ee05420ea5ae0ad0be948533

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

LOG: Reapply [ConstantFold] Fold more operations to poison

This was reverted to mitigate mitigate miscompiles caused by
the logical and/or to bitwise and/or fold. Reapply it now that
the underlying issue has been fixed by D101191.

-

This patch folds more operations to poison.

Alive2 proof: https://alive2.llvm.org/ce/z/mxcb9G (it does not contain tests 
about div/rem because they fold to poison when raising UB)

Reviewed By: nikic

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

Added: 


Modified: 
clang/test/Frontend/fixed_point_unary.c
llvm/lib/IR/ConstantFold.cpp
llvm/test/CodeGen/AMDGPU/amdgpu-codegenprepare-fold-binop-select.ll
llvm/test/Transforms/InstCombine/apint-shift.ll
llvm/test/Transforms/InstCombine/canonicalize-ashr-shl-to-masking.ll
llvm/test/Transforms/InstCombine/canonicalize-lshr-shl-to-masking.ll
llvm/test/Transforms/InstCombine/canonicalize-shl-lshr-to-masking.ll
llvm/test/Transforms/InstCombine/icmp.ll

llvm/test/Transforms/InstCombine/partally-redundant-left-shift-input-masking-after-truncation-variant-a.ll

llvm/test/Transforms/InstCombine/partally-redundant-left-shift-input-masking-after-truncation-variant-b.ll

llvm/test/Transforms/InstCombine/partally-redundant-left-shift-input-masking-after-truncation-variant-c.ll

llvm/test/Transforms/InstCombine/partally-redundant-left-shift-input-masking-after-truncation-variant-d.ll

llvm/test/Transforms/InstCombine/partally-redundant-left-shift-input-masking-after-truncation-variant-e.ll

llvm/test/Transforms/InstCombine/partally-redundant-left-shift-input-masking-variant-a.ll

llvm/test/Transforms/InstCombine/partally-redundant-left-shift-input-masking-variant-b.ll

llvm/test/Transforms/InstCombine/partally-redundant-left-shift-input-masking-variant-c.ll

llvm/test/Transforms/InstCombine/partally-redundant-left-shift-input-masking-variant-d.ll

llvm/test/Transforms/InstCombine/partally-redundant-left-shift-input-masking-variant-e.ll
llvm/test/Transforms/InstCombine/select-of-bittest.ll
llvm/test/Transforms/InstCombine/shift-add-inseltpoison.ll
llvm/test/Transforms/InstCombine/shift-add.ll
llvm/test/Transforms/InstSimplify/ConstProp/InsertElement-inseltpoison.ll
llvm/test/Transforms/InstSimplify/ConstProp/InsertElement.ll
llvm/test/Transforms/InstSimplify/ConstProp/cast.ll
llvm/test/Transforms/InstSimplify/ConstProp/poison.ll
llvm/test/Transforms/InstSimplify/ConstProp/shift.ll

llvm/test/Transforms/InstSimplify/ConstProp/vector-undef-elts-inseltpoison.ll
llvm/test/Transforms/InstSimplify/ConstProp/vector-undef-elts.ll
llvm/test/Transforms/InstSimplify/ConstProp/vscale-inseltpoison.ll
llvm/test/Transforms/InstSimplify/ConstProp/vscale.ll
llvm/test/Transforms/InstSimplify/div.ll
llvm/test/Transforms/InstSimplify/rem.ll
llvm/test/Transforms/InstSimplify/undef.ll
llvm/test/Transforms/SROA/phi-gep.ll
llvm/test/Transforms/SROA/select-gep.ll
llvm/test/Transforms/VectorCombine/X86/insert-binop-inseltpoison.ll
llvm/test/Transforms/VectorCombine/X86/insert-binop-with-constant.ll
llvm/test/Transforms/VectorCombine/X86/insert-binop.ll
llvm/unittests/IR/ConstantsTest.cpp

Removed: 




diff  --git a/clang/test/Frontend/fixed_point_unary.c 
b/clang/test/Frontend/fixed_point_unary.c
index 849e38a94bc4..6ce760daba11 100644
--- a/clang/test/Frontend/fixed_point_unary.c
+++ b/clang/test/Frontend/fixed_point_unary.c
@@ -90,7 +90,7 @@ void inc_usa() {
 // SIGNED-LABEL: @inc_uf(
 // SIGNED-NEXT:  entry:
 // SIGNED-NEXT:[[TMP0:%.*]] = load i16, i16* @uf, align 2
-// SIGNED-NEXT:[[TMP1:%.*]] = add i16 [[TMP0]], undef
+// SIGNED-NEXT:[[TMP1:%.*]] = add i16 [[TMP0]], poison
 // SIGNED-NEXT:store i16 [[TMP1]], i16* @uf, align 2
 // SIGNED-NEXT:ret void
 //
@@ -271,7 +271,7 @@ void dec_usa() {
 // SIGNED-LABEL: @dec_uf(
 // SIGNED-NEXT:  entry:
 // SIGNED-NEXT:[[TMP0:%.*]] = load i16, i16* @uf, align 2
-// SIGNED-NEXT:[[TMP1:%.*]] = sub i16 [[TMP0]], undef
+// SIGNED-NEXT:[[TMP1:%.*]] = sub i16 [[TMP0]], poison
 // SIGNED-NEXT:store i16 [[TMP1]], i16* @uf, align 2
 // SIGNED-NEXT:ret void
 //

diff  --git a/llvm/lib/IR/ConstantFold.cpp b/llvm/lib/IR/ConstantFold.cpp
index 37017697f4e1..84e773aafefa 100644
--- a/llvm/lib/IR/ConstantFold.cpp
+++ b/llvm/lib/IR/ConstantFold.cpp
@@ -652,7 +652,7 @@ Constant *llvm::ConstantFoldCastInstruction(unsigned opc, 
Constant *V,
   V.convertToInteger(IntVal, APFloat::rmTowardZero, &ignored)) {
 // Undefined behavior invoked - t

[PATCH] D102025: Thread safety analysis: Factor out function for merging locks (NFC)

2021-05-13 Thread Aaron Puchert via Phabricator via cfe-commits
aaronpuchert added inline comments.



Comment at: clang/lib/Analysis/ThreadSafety.cpp:2199
+// Take the exclusive capability to reduce further warnings.
+return B.kind() == LK_Exclusive;
+  } else {

aaron.ballman wrote:
> The old code was looking at `LDat1.kind() != LK_Exclusive` -- any reason this 
> isn't `A.kind() != LK_Exclusive` as well?
Given that both should be equivalent (knowing `A.kind() != B.kind()` and that 
there are just two kinds), I thought this condition fits better to the comment: 
we select the lock that's exclusive, instead of not selecting the lock that's 
not exclusive.

But I don't have a problem with `A.kind() != LK_Exclusive` if that sounds more 
natural to you.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D102025

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


[PATCH] D86671: [clang-tidy] Add new case type to check variables with Hungarian notation

2021-05-13 Thread Douglas Chen via Phabricator via cfe-commits
dougpuob added a comment.

In D86671#2754542 , @njames93 wrote:

> In D86671#2750957 , @dougpuob wrote:
>
>> Hi @njames93:
>> Could you do me a favor? Because it is my first patch, something I'm not 
>> sure. I'm confused about can I land this patch now? I read the "LLVM 
>> Code-Review Policy and Practices" document, it said patches can be landed if 
>> received a LGTM, but seems you are still reviewing.
>
> If you have made significant changes (excluding what a reviewer asks when 
> giving an LGTM) Its best to get those further changes also reviewed.

Thank you for your reply and suggestion in code, I will try it.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86671

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


[PATCH] D102025: Thread safety analysis: Factor out function for merging locks (NFC)

2021-05-13 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!




Comment at: clang/lib/Analysis/ThreadSafety.cpp:2199
+// Take the exclusive capability to reduce further warnings.
+return B.kind() == LK_Exclusive;
+  } else {

aaronpuchert wrote:
> aaron.ballman wrote:
> > The old code was looking at `LDat1.kind() != LK_Exclusive` -- any reason 
> > this isn't `A.kind() != LK_Exclusive` as well?
> Given that both should be equivalent (knowing `A.kind() != B.kind()` and that 
> there are just two kinds), I thought this condition fits better to the 
> comment: we select the lock that's exclusive, instead of not selecting the 
> lock that's not exclusive.
> 
> But I don't have a problem with `A.kind() != LK_Exclusive` if that sounds 
> more natural to you.
Oo, derp. I was forgetting that there were only two kinds. This looks fine 
to me, thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D102025

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


[PATCH] D102392: [clang-format] PR50326 AlignAfterOpenBracket AlwaysBreak does not keep to the ColumnLimit

2021-05-13 Thread Björn Schäpers via Phabricator via cfe-commits
HazardyKnusperkeks accepted this revision.
HazardyKnusperkeks added a comment.

I second that ColumnLimit breaking test case. :)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D102392

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


[PATCH] D102064: Parse vector bool when stdbool.h and altivec.h are included

2021-05-13 Thread Neumann Hon via Phabricator via cfe-commits
Everybody0523 added a comment.

Expected Z behavior LGTM


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D102064

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


[PATCH] D102339: [clang] On Windows, ignore case and separators when discarding duplicate dependency file paths.

2021-05-13 Thread Nico Weber via Phabricator via cfe-commits
thakis added a comment.

In D102339#2756726 , @aganea wrote:

> In D102339#2755867 , @thakis wrote:
>
>> We share obj files built on linux and on windows. So that's a goal for us.
>
> Hello @thakis, I believe you don't use this codepath to generate the cache 
> key, do you? I thought you had a custom python script to extract the 
> dependencies?

Oh, is this only used for `-MD` / `-MMD`? If so, yes, we don't use this on 
Windows atm. But someone's working on setting a win->linux cross build, and 
that would use this code path I think.


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

https://reviews.llvm.org/D102339

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


[PATCH] D102240: [analyzer][solver] Prevent use of a null state

2021-05-13 Thread Valeriy Savchenko via Phabricator via cfe-commits
vsavchenko updated this revision to Diff 345145.
vsavchenko added a comment.

Modify test


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D102240

Files:
  clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
  clang/test/Analysis/PR50268.c


Index: clang/test/Analysis/PR50268.c
===
--- /dev/null
+++ clang/test/Analysis/PR50268.c
@@ -0,0 +1,12 @@
+// RUN: %clang_analyze_cc1 -w -analyzer-checker=core -verify %s \
+// RUN:-analyzer-config eagerly-assume=true
+
+// expected-no-diagnostics
+
+
+int test(unsigned long a, unsigned long c, int b) {
+  c -= a;
+  if (0 >= b) {}
+  c == b;
+  return c ? 0 : 2; // no-crash
+}
Index: clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
===
--- clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
+++ clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
@@ -1487,15 +1487,18 @@
   // This is an infeasible assumption.
   return nullptr;
 
-ProgramStateRef NewState = setConstraint(State, Sym, NewConstraint);
-if (auto Equality = EqualityInfo::extract(Sym, Int, Adjustment)) {
-  // If the original assumption is not Sym + Adjustment !=/ Int,
-  // we should invert IsEquality flag.
-  Equality->IsEquality = Equality->IsEquality != EQ;
-  return track(NewState, *Equality);
+if (ProgramStateRef NewState = setConstraint(State, Sym, NewConstraint)) {
+  if (auto Equality = EqualityInfo::extract(Sym, Int, Adjustment)) {
+// If the original assumption is not Sym + Adjustment !=/ Int,
+// we should invert IsEquality flag.
+Equality->IsEquality = Equality->IsEquality != EQ;
+return track(NewState, *Equality);
+  }
+
+  return NewState;
 }
 
-return NewState;
+return nullptr;
   }
 
   ProgramStateRef track(ProgramStateRef State, EqualityInfo ToTrack) {


Index: clang/test/Analysis/PR50268.c
===
--- /dev/null
+++ clang/test/Analysis/PR50268.c
@@ -0,0 +1,12 @@
+// RUN: %clang_analyze_cc1 -w -analyzer-checker=core -verify %s \
+// RUN:-analyzer-config eagerly-assume=true
+
+// expected-no-diagnostics
+
+
+int test(unsigned long a, unsigned long c, int b) {
+  c -= a;
+  if (0 >= b) {}
+  c == b;
+  return c ? 0 : 2; // no-crash
+}
Index: clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
===
--- clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
+++ clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
@@ -1487,15 +1487,18 @@
   // This is an infeasible assumption.
   return nullptr;
 
-ProgramStateRef NewState = setConstraint(State, Sym, NewConstraint);
-if (auto Equality = EqualityInfo::extract(Sym, Int, Adjustment)) {
-  // If the original assumption is not Sym + Adjustment !=/ Int,
-  // we should invert IsEquality flag.
-  Equality->IsEquality = Equality->IsEquality != EQ;
-  return track(NewState, *Equality);
+if (ProgramStateRef NewState = setConstraint(State, Sym, NewConstraint)) {
+  if (auto Equality = EqualityInfo::extract(Sym, Int, Adjustment)) {
+// If the original assumption is not Sym + Adjustment !=/ Int,
+// we should invert IsEquality flag.
+Equality->IsEquality = Equality->IsEquality != EQ;
+return track(NewState, *Equality);
+  }
+
+  return NewState;
 }
 
-return NewState;
+return nullptr;
   }
 
   ProgramStateRef track(ProgramStateRef State, EqualityInfo ToTrack) {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D101640: [clang][patch] Add support for option -fextend-arguments={32,64}: widen integer arguments to int64 in unprototyped function calls

2021-05-13 Thread Melanie Blower via Phabricator via cfe-commits
mibintc updated this revision to Diff 345154.
mibintc added a comment.

I responded to most all @aaron.ballman 's review comments, may need a little 
more wordsmithing


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101640

Files:
  clang/include/clang/Basic/LangOptions.def
  clang/include/clang/Basic/LangOptions.h
  clang/include/clang/Basic/TargetInfo.h
  clang/include/clang/Driver/Options.td
  clang/lib/Basic/Targets/X86.h
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/test/CodeGen/extend-arg-64.c
  clang/test/Driver/fextend-args.c

Index: clang/test/Driver/fextend-args.c
===
--- /dev/null
+++ clang/test/Driver/fextend-args.c
@@ -0,0 +1,17 @@
+// Options for intel arch
+// RUN: %clang -### -target x86_64-apple-darwin -fextend-arguments=32 %s 2>&1 \
+// RUN: | FileCheck --implicit-check-not "-fextend-arguments=32"  %s
+// RUN: %clang -### -target x86_64-apple-darwin -fextend-arguments=64 %s 2>&1 \
+// RUN: | FileCheck -check-prefix=CHECK-64 %s
+
+// Unsupported target
+// RUN: not %clang -target aarch64-unknown-windows-msvc -fextend-arguments=32 %s 2>&1 \
+// RUN: | FileCheck -check-prefix=UNSUPPORTED-TARGET %s
+
+// Invalid option value
+// RUN: not %clang -target x86_64-apple-darwin -fextend-arguments=0 %s 2>&1 \
+// RUN: | FileCheck -check-prefix=INVALID-VALUE %s
+
+// CHECK-64: "-cc1" {{.*}}"-fextend-arguments=64"
+// UNSUPPORTED-TARGET: error: unsupported option
+// INVALID-VALUE: error: invalid argument '0' to -fextend-arguments
Index: clang/test/CodeGen/extend-arg-64.c
===
--- /dev/null
+++ clang/test/CodeGen/extend-arg-64.c
@@ -0,0 +1,99 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin -fextend-arguments=64  \
+// RUN:%s -emit-llvm -o - | FileCheck %s -check-prefix=CHECKEXT
+
+// When the option isn't selected, no effect
+// RUN: %clang_cc1 -triple x86_64-apple-darwin  \
+// RUN: %s -emit-llvm -o - | FileCheck %s \
+// RUN:--implicit-check-not "ext {{.*}}to i64"
+
+// The option isn't supported on x86, no effect
+// RUN: %clang_cc1 -triple i386-pc-linux-gnu -fextend-arguments=64 \
+// RUN: %s -emit-llvm -o - | FileCheck %s \
+// RUN:--implicit-check-not "ext {{.*}}to i64"
+
+// The option isn't supported on ppc, no effect
+// RUN: %clang_cc1 -triple ppc64le -fextend-arguments=64 \
+// RUN: %s -emit-llvm -o - | FileCheck %s \
+// RUN:--implicit-check-not "ext {{.*}}to i64"
+
+int vararg(int, ...);
+void knr();
+
+unsigned int u32;
+int s32;
+unsigned short u16;
+short s16;
+unsigned char u8;
+signed char s8;
+long long ll;
+_ExtInt(23) ei23;
+float ff;
+double dd;
+__int128 i128;
+
+int test() {
+  // CHECK: define{{.*}} i32 @test{{.*}}
+
+  // CHECKEXT:  [[TAG_u32:%.*]] = load i32, i32* @u32{{.*}}
+  // CHECKEXT: [[CONV_u32:%.*]] = zext i32 [[TAG_u32]] to i64
+
+  // CHECKEXT:  [[TAG_s32:%.*]] = load i32, i32* @s32
+  // CHECKEXT: [[CONV_s32:%.*]] = sext i32 [[TAG_s32]] to i64
+
+  // CHECKEXT:  [[TAG_u16:%.*]] = load i16, i16* @u16
+  // CHECKEXT: [[CONV_u16:%.*]] = zext i16 [[TAG_u16]] to i64
+
+  // CHECKEXT:  [[TAG_s16:%.*]] = load i16, i16* @s16
+  // CHECKEXT: [[CONV_s16:%.*]] = sext i16 [[TAG_s16]] to i64
+
+  // CHECKEXT:  [[TAG_u8:%.*]] = load i8, i8* @u8
+  // CHECKEXT: [[CONV_u8:%.*]] = zext i8 [[TAG_u8]] to i64
+
+  // CHECKEXT:  [[TAG_s8:%.*]] = load i8, i8* @s8
+  // CHECKEXT: [[CONV_s8:%.*]] = sext i8 [[TAG_s8]] to i64
+  // CHECKEXT: call{{.*}} @vararg(i32 %0, i64 [[CONV_u32]], i64 [[CONV_s32]], i64 [[CONV_u16]], i64 [[CONV_s16]], i64 [[CONV_u8]], i64 [[CONV_s8]]
+
+  int sum = 0;
+  sum = vararg(sum, u32, s32, u16, s16, u8, s8);
+  knr(ll);
+  // CHECKEXT: load i64, i64* @ll
+  // CHECKEXT-NEXT: call void (i64, ...) bitcast {{.*}} @knr
+
+  knr(ei23);
+  // CHECKEXT: load i23, i23* @ei23
+  // CHECKEXT-NEXT: call void (i23, ...) bitcast{{.*}} @knr
+
+  knr(ff);
+  // CHECKEXT: load float
+  // CHECKEXT-NEXT: fpext float {{.*}} to double
+  // CHECKEXT-NEXT: call{{.*}} void (double, ...) bitcast{{.*}} @knr
+
+  knr(dd);
+  // CHECKEXT: load double
+  // CHECKEXT-NEXT: call{{.*}} void (double, ...) bitcast{{.*}} @knr
+
+  knr(i128);
+  // CHECKEXT: load i128
+  // CHECKEXT: call{{.*}} void (i64, i64, ...) bitcast{{.*}} @knr
+
+  knr(u32, s32, u16, s16, u8, s8);
+  // CHECKEXT:  [[TAg_u32:%.*]] = load i32, i32* @u32{{.*}}
+  // CHECKEXT: [[CONv_u32:%.*]] = zext i32 [[TAg_u32]] to i64
+
+  // CHECKEXT:  [[TAg_s32:%.*]] = load i32, i32* @s32
+  // CHECKEXT: [[CONv_s32:%.*]] = sext i32 [[TAg_s32]] to i64
+
+  // CHECKEXT:  [[TAg_u16:%.*]] = load i16, i16* @u16
+  // CHECKEXT: [[CONv_u16:%.*]] = zext i16 [[TAg_u16]] to i64
+
+  // CHECKEXT:  [[TAg_s16:%.*]] = load i16, i16* @s16
+  // CHECKEXT: [[CONv_s16:%.*]] = sext i16 [[TAg_s16]] to i64
+
+  // CHECKEXT:  [[

[PATCH] D102240: [analyzer][solver] Prevent use of a null state

2021-05-13 Thread Valeriy Savchenko via Phabricator via cfe-commits
vsavchenko added a comment.

In D102240#2750976 , @steakhal wrote:

> Dam, we will be always haunted by these.

Yep, it was one place where we didn't expect a null state, but after one of the 
later patches, it became possible. 🤞it's the final one.

> Looks good btw.
> The test looks somewhat artificial - like a raw `creduce` result.
>
> Do you think It worth the effort to make it look like it was written by a 
> human?

OK, I tried. and surprisingly I couldn't transform `c == b` into a condition, 
so it crashes.  While it's interesting why exactly this happens, I don't think 
that it's worth it (in this particular case).

> I also somewhy prefer function parameters to globals for this specific 
> use-case.

✅

> This seems to depend on the `-analyzer-config eagerly-assume=true`. We should 
> probably add this option explicitly, just in case.

✅


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D102240

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


[PATCH] D102406: [ARM][AArch64] Correct __ARM_FEATURE_CRYPTO macro and crypto feature

2021-05-13 Thread David Candler via Phabricator via cfe-commits
dcandler created this revision.
dcandler added reviewers: t.p.northover, lenary.
Herald added subscribers: danielkiss, kristof.beyls.
dcandler requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

This patch contains a couple of minor corrections to my previous
crypto patch:

Since both AArch32 and AArch64 are now correctly setting the aes and
sha2 features individually, it is not necessary to continue to check
the crypto feature when defining feature macros.

In the AArch32 driver, the feature vector is only modified when the
crypto feature is actually in the vector. If crypto is not present,
there is no need to split it and explicitly define crypto/sha2/aes.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D102406

Files:
  clang/lib/Basic/Targets/AArch64.cpp
  clang/lib/Basic/Targets/ARM.cpp
  clang/lib/Driver/ToolChains/Arch/ARM.cpp


Index: clang/lib/Driver/ToolChains/Arch/ARM.cpp
===
--- clang/lib/Driver/ToolChains/Arch/ARM.cpp
+++ clang/lib/Driver/ToolChains/Arch/ARM.cpp
@@ -636,6 +636,10 @@
   // FIXME: this needs reimplementation after the TargetParser rewrite
   bool HasSHA2 = false;
   bool HasAES = false;
+  const auto ItCrypto =
+  llvm::find_if(llvm::reverse(Features), [](const StringRef F) {
+return F.contains("crypto");
+  });
   const auto ItSHA2 =
   llvm::find_if(llvm::reverse(Features), [](const StringRef F) {
 return F.contains("crypto") || F.contains("sha2");
@@ -650,7 +654,7 @@
 HasSHA2 = ItSHA2->take_front() == "+";
   if (FoundAES)
 HasAES = ItAES->take_front() == "+";
-  if (FoundSHA2 || FoundAES) {
+  if (ItCrypto != Features.rend()) {
 if (HasSHA2 && HasAES)
   Features.push_back("+crypto");
 else
Index: clang/lib/Basic/Targets/ARM.cpp
===
--- clang/lib/Basic/Targets/ARM.cpp
+++ clang/lib/Basic/Targets/ARM.cpp
@@ -649,7 +649,7 @@
 // ACLE 6.5.7 Crypto Extension
 // The __ARM_FEATURE_CRYPTO is deprecated in favor of finer grained
 // feature macros for AES and SHA2
-if (Crypto || (SHA2 && AES))
+if (SHA2 && AES)
   Builder.defineMacro("__ARM_FEATURE_CRYPTO", "1");
 if (SHA2)
   Builder.defineMacro("__ARM_FEATURE_SHA2", "1");
Index: clang/lib/Basic/Targets/AArch64.cpp
===
--- clang/lib/Basic/Targets/AArch64.cpp
+++ clang/lib/Basic/Targets/AArch64.cpp
@@ -289,7 +289,7 @@
 
   // The __ARM_FEATURE_CRYPTO is deprecated in favor of finer grained feature
   // macros for AES, SHA2, SHA3 and SM4
-  if (HasCrypto || (HasAES && HasSHA2))
+  if (HasAES && HasSHA2)
 Builder.defineMacro("__ARM_FEATURE_CRYPTO", "1");
 
   if (HasAES)


Index: clang/lib/Driver/ToolChains/Arch/ARM.cpp
===
--- clang/lib/Driver/ToolChains/Arch/ARM.cpp
+++ clang/lib/Driver/ToolChains/Arch/ARM.cpp
@@ -636,6 +636,10 @@
   // FIXME: this needs reimplementation after the TargetParser rewrite
   bool HasSHA2 = false;
   bool HasAES = false;
+  const auto ItCrypto =
+  llvm::find_if(llvm::reverse(Features), [](const StringRef F) {
+return F.contains("crypto");
+  });
   const auto ItSHA2 =
   llvm::find_if(llvm::reverse(Features), [](const StringRef F) {
 return F.contains("crypto") || F.contains("sha2");
@@ -650,7 +654,7 @@
 HasSHA2 = ItSHA2->take_front() == "+";
   if (FoundAES)
 HasAES = ItAES->take_front() == "+";
-  if (FoundSHA2 || FoundAES) {
+  if (ItCrypto != Features.rend()) {
 if (HasSHA2 && HasAES)
   Features.push_back("+crypto");
 else
Index: clang/lib/Basic/Targets/ARM.cpp
===
--- clang/lib/Basic/Targets/ARM.cpp
+++ clang/lib/Basic/Targets/ARM.cpp
@@ -649,7 +649,7 @@
 // ACLE 6.5.7 Crypto Extension
 // The __ARM_FEATURE_CRYPTO is deprecated in favor of finer grained
 // feature macros for AES and SHA2
-if (Crypto || (SHA2 && AES))
+if (SHA2 && AES)
   Builder.defineMacro("__ARM_FEATURE_CRYPTO", "1");
 if (SHA2)
   Builder.defineMacro("__ARM_FEATURE_SHA2", "1");
Index: clang/lib/Basic/Targets/AArch64.cpp
===
--- clang/lib/Basic/Targets/AArch64.cpp
+++ clang/lib/Basic/Targets/AArch64.cpp
@@ -289,7 +289,7 @@
 
   // The __ARM_FEATURE_CRYPTO is deprecated in favor of finer grained feature
   // macros for AES, SHA2, SHA3 and SM4
-  if (HasCrypto || (HasAES && HasSHA2))
+  if (HasAES && HasSHA2)
 Builder.defineMacro("__ARM_FEATURE_CRYPTO", "1");
 
   if (HasAES)
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D101640: [clang][patch] Add support for option -fextend-arguments={32,64}: widen integer arguments to int64 in unprototyped function calls

2021-05-13 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

Thanks! The last remaining question to me is whether this should be a 
target-specific option or whether it makes sense to allow it as an option for 
any target.




Comment at: clang/include/clang/Basic/LangOptions.def:418-419
+ENUM_LANGOPT(ExtendIntArgs, ExtendArgsKind, 1, ExtendArgsKind::ExtendTo32, 
+ "Controls how scalar integer arguments are extended in calls"
+ " to unprototyped and varargs functions")
+

I missed this one last time.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101640

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


[clang] 8fa168f - Parse vector bool when stdbool.h and altivec.h are included

2021-05-13 Thread Zarko Todorovski via cfe-commits

Author: Zarko Todorovski
Date: 2021-05-13T11:48:32-04:00
New Revision: 8fa168fc50ba4f63b79773c947ef5b3e43d5c02f

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

LOG: Parse vector bool when stdbool.h and altivec.h are included

Currently when including stdbool.h and altivec.h declaration of `vector bool` 
leads to
errors due to `bool` being expanded to '_Bool`. This patch allows the parser
to recognize `_Bool`.

Reviewed By: hubert.reinterpretcast, Everybody0523

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

Added: 
clang/test/Parser/altivec-zvector-bool.c

Modified: 
clang/include/clang/Parse/Parser.h
clang/lib/Parse/ParseDecl.cpp
clang/lib/Parse/Parser.cpp

Removed: 




diff  --git a/clang/include/clang/Parse/Parser.h 
b/clang/include/clang/Parse/Parser.h
index b5d6212e2dd41..213f7fb3dc56f 100644
--- a/clang/include/clang/Parse/Parser.h
+++ b/clang/include/clang/Parse/Parser.h
@@ -118,10 +118,12 @@ class Parser : public CodeCompletionHandler {
   /// Ident_super - IdentifierInfo for "super", to support fast
   /// comparison.
   IdentifierInfo *Ident_super;
-  /// Ident_vector, Ident_bool - cached IdentifierInfos for "vector" and
-  /// "bool" fast comparison.  Only present if AltiVec or ZVector are enabled.
+  /// Ident_vector, Ident_bool, Ident_Bool - cached IdentifierInfos for 
"vector"
+  /// and "bool" fast comparison.  Only present if AltiVec or ZVector are
+  /// enabled.
   IdentifierInfo *Ident_vector;
   IdentifierInfo *Ident_bool;
+  IdentifierInfo *Ident_Bool;
   /// Ident_pixel - cached IdentifierInfos for "pixel" fast comparison.
   /// Only present if AltiVec enabled.
   IdentifierInfo *Ident_pixel;
@@ -879,6 +881,7 @@ class Parser : public CodeCompletionHandler {
 
 if (Tok.getIdentifierInfo() != Ident_vector &&
 Tok.getIdentifierInfo() != Ident_bool &&
+Tok.getIdentifierInfo() != Ident_Bool &&
 (!getLangOpts().AltiVec || Tok.getIdentifierInfo() != Ident_pixel))
   return false;
 

diff  --git a/clang/lib/Parse/ParseDecl.cpp b/clang/lib/Parse/ParseDecl.cpp
index 928ef33bc9f20..fda427508c056 100644
--- a/clang/lib/Parse/ParseDecl.cpp
+++ b/clang/lib/Parse/ParseDecl.cpp
@@ -7334,6 +7334,7 @@ bool Parser::TryAltiVecVectorTokenOutOfLine() {
   case tok::kw_float:
   case tok::kw_double:
   case tok::kw_bool:
+  case tok::kw__Bool:
   case tok::kw___bool:
   case tok::kw___pixel:
 Tok.setKind(tok::kw___vector);
@@ -7343,7 +7344,8 @@ bool Parser::TryAltiVecVectorTokenOutOfLine() {
   Tok.setKind(tok::kw___vector);
   return true;
 }
-if (Next.getIdentifierInfo() == Ident_bool) {
+if (Next.getIdentifierInfo() == Ident_bool ||
+Next.getIdentifierInfo() == Ident_Bool) {
   Tok.setKind(tok::kw___vector);
   return true;
 }
@@ -7368,6 +7370,7 @@ bool Parser::TryAltiVecTokenOutOfLine(DeclSpec &DS, 
SourceLocation Loc,
 case tok::kw_float:
 case tok::kw_double:
 case tok::kw_bool:
+case tok::kw__Bool:
 case tok::kw___bool:
 case tok::kw___pixel:
   isInvalid = DS.SetTypeAltiVecVector(true, Loc, PrevSpec, DiagID, Policy);
@@ -7377,8 +7380,10 @@ bool Parser::TryAltiVecTokenOutOfLine(DeclSpec &DS, 
SourceLocation Loc,
 isInvalid = DS.SetTypeAltiVecVector(true, Loc, PrevSpec, 
DiagID,Policy);
 return true;
   }
-  if (Next.getIdentifierInfo() == Ident_bool) {
-isInvalid = DS.SetTypeAltiVecVector(true, Loc, PrevSpec, 
DiagID,Policy);
+  if (Next.getIdentifierInfo() == Ident_bool ||
+  Next.getIdentifierInfo() == Ident_Bool) {
+isInvalid =
+DS.SetTypeAltiVecVector(true, Loc, PrevSpec, DiagID, Policy);
 return true;
   }
   break;

diff  --git a/clang/lib/Parse/Parser.cpp b/clang/lib/Parse/Parser.cpp
index b178b56e967c6..1ae3ed4ff0d39 100644
--- a/clang/lib/Parse/Parser.cpp
+++ b/clang/lib/Parse/Parser.cpp
@@ -503,10 +503,12 @@ void Parser::Initialize() {
 
   Ident_vector = nullptr;
   Ident_bool = nullptr;
+  Ident_Bool = nullptr;
   Ident_pixel = nullptr;
   if (getLangOpts().AltiVec || getLangOpts().ZVector) {
 Ident_vector = &PP.getIdentifierTable().get("vector");
 Ident_bool = &PP.getIdentifierTable().get("bool");
+Ident_Bool = &PP.getIdentifierTable().get("_Bool");
   }
   if (getLangOpts().AltiVec)
 Ident_pixel = &PP.getIdentifierTable().get("pixel");

diff  --git a/clang/test/Parser/altivec-zvector-bool.c 
b/clang/test/Parser/altivec-zvector-bool.c
new file mode 100644
index 0..6765d26e2df48
--- /dev/null
+++ b/clang/test/Parser/altivec-zvector-bool.c
@@ -0,0 +1,23 @@
+// RUN: %clang_cc1 -triple=powerpc64-unknown-linux-gnu \
+// RUN:-target-feature +altivec -fsyntax-only %s
+// RUN: %clang_cc1 -triple=powerpc64le-unknown-linux-gnu 

[PATCH] D102064: Parse vector bool when stdbool.h and altivec.h are included

2021-05-13 Thread Zarko Todorovski 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 rG8fa168fc50ba: Parse vector bool when stdbool.h and altivec.h 
are included (authored by ZarkoCA).

Changed prior to commit:
  https://reviews.llvm.org/D102064?vs=344785&id=345157#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D102064

Files:
  clang/include/clang/Parse/Parser.h
  clang/lib/Parse/ParseDecl.cpp
  clang/lib/Parse/Parser.cpp
  clang/test/Parser/altivec-zvector-bool.c

Index: clang/test/Parser/altivec-zvector-bool.c
===
--- /dev/null
+++ clang/test/Parser/altivec-zvector-bool.c
@@ -0,0 +1,23 @@
+// RUN: %clang_cc1 -triple=powerpc64-unknown-linux-gnu \
+// RUN:-target-feature +altivec -fsyntax-only %s
+// RUN: %clang_cc1 -triple=powerpc64le-unknown-linux-gnu \
+// RUN:-target-feature +altivec -fsyntax-only %s
+// RUN: %clang_cc1 -triple=powerpc64-ibm-aix-xcoff \
+// RUN:-target-feature +altivec -fsyntax-only %s
+// RUN: %clang_cc1 -triple=powerpc-ibm-aix-xcoff \
+// RUN:-target-feature +altivec -fsyntax-only %s
+// RUN: %clang_cc1 -triple=powerpc-unknown-linux-gnu \
+// RUN:-target-feature +altivec -fsyntax-only %s
+// RUN: %clang_cc1 -triple=s390x-linux-gnu -target-cpu arch11 \
+// RUN:-fzvector -fsyntax-only %s
+// RUN: %clang_cc1 -triple=s390x-ibm-zos -target-cpu arch11 \
+// RUN:-fzvector -fsyntax-only %s
+
+__vector bool char bc;
+__vector bool short bsh;
+__vector bool short int bshi;
+__vector bool int bi;
+__vector _Bool char bc;
+__vector _Bool short bsh;
+__vector _Bool short int bshi;
+__vector _Bool int bi;
Index: clang/lib/Parse/Parser.cpp
===
--- clang/lib/Parse/Parser.cpp
+++ clang/lib/Parse/Parser.cpp
@@ -503,10 +503,12 @@
 
   Ident_vector = nullptr;
   Ident_bool = nullptr;
+  Ident_Bool = nullptr;
   Ident_pixel = nullptr;
   if (getLangOpts().AltiVec || getLangOpts().ZVector) {
 Ident_vector = &PP.getIdentifierTable().get("vector");
 Ident_bool = &PP.getIdentifierTable().get("bool");
+Ident_Bool = &PP.getIdentifierTable().get("_Bool");
   }
   if (getLangOpts().AltiVec)
 Ident_pixel = &PP.getIdentifierTable().get("pixel");
Index: clang/lib/Parse/ParseDecl.cpp
===
--- clang/lib/Parse/ParseDecl.cpp
+++ clang/lib/Parse/ParseDecl.cpp
@@ -7334,6 +7334,7 @@
   case tok::kw_float:
   case tok::kw_double:
   case tok::kw_bool:
+  case tok::kw__Bool:
   case tok::kw___bool:
   case tok::kw___pixel:
 Tok.setKind(tok::kw___vector);
@@ -7343,7 +7344,8 @@
   Tok.setKind(tok::kw___vector);
   return true;
 }
-if (Next.getIdentifierInfo() == Ident_bool) {
+if (Next.getIdentifierInfo() == Ident_bool ||
+Next.getIdentifierInfo() == Ident_Bool) {
   Tok.setKind(tok::kw___vector);
   return true;
 }
@@ -7368,6 +7370,7 @@
 case tok::kw_float:
 case tok::kw_double:
 case tok::kw_bool:
+case tok::kw__Bool:
 case tok::kw___bool:
 case tok::kw___pixel:
   isInvalid = DS.SetTypeAltiVecVector(true, Loc, PrevSpec, DiagID, Policy);
@@ -7377,8 +7380,10 @@
 isInvalid = DS.SetTypeAltiVecVector(true, Loc, PrevSpec, DiagID,Policy);
 return true;
   }
-  if (Next.getIdentifierInfo() == Ident_bool) {
-isInvalid = DS.SetTypeAltiVecVector(true, Loc, PrevSpec, DiagID,Policy);
+  if (Next.getIdentifierInfo() == Ident_bool ||
+  Next.getIdentifierInfo() == Ident_Bool) {
+isInvalid =
+DS.SetTypeAltiVecVector(true, Loc, PrevSpec, DiagID, Policy);
 return true;
   }
   break;
Index: clang/include/clang/Parse/Parser.h
===
--- clang/include/clang/Parse/Parser.h
+++ clang/include/clang/Parse/Parser.h
@@ -118,10 +118,12 @@
   /// Ident_super - IdentifierInfo for "super", to support fast
   /// comparison.
   IdentifierInfo *Ident_super;
-  /// Ident_vector, Ident_bool - cached IdentifierInfos for "vector" and
-  /// "bool" fast comparison.  Only present if AltiVec or ZVector are enabled.
+  /// Ident_vector, Ident_bool, Ident_Bool - cached IdentifierInfos for "vector"
+  /// and "bool" fast comparison.  Only present if AltiVec or ZVector are
+  /// enabled.
   IdentifierInfo *Ident_vector;
   IdentifierInfo *Ident_bool;
+  IdentifierInfo *Ident_Bool;
   /// Ident_pixel - cached IdentifierInfos for "pixel" fast comparison.
   /// Only present if AltiVec enabled.
   IdentifierInfo *Ident_pixel;
@@ -879,6 +881,7 @@
 
 if (Tok.getIdentifierInfo() != Ident_vector &&
 Tok.getIdentifierInfo() != Ident_bool &&
+Tok.getIdentifierInfo() != Ident_Bool &&
 (!getLangOpts().Al

[clang] 6a67e05 - [HIP] Add __builtin_amdgcn_groupstaticsize

2021-05-13 Thread Aaron En Ye Shi via cfe-commits

Author: Aaron En Ye Shi
Date: 2021-05-13T15:50:08Z
New Revision: 6a67e05a26eb5f58665bd6d063b9f389e7dd28a7

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

LOG: [HIP] Add __builtin_amdgcn_groupstaticsize

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

Added: 


Modified: 
clang/include/clang/Basic/BuiltinsAMDGPU.def
clang/test/CodeGenOpenCL/builtins-amdgcn-ci.cl
clang/test/CodeGenOpenCL/builtins-amdgcn-gfx10.cl
clang/test/CodeGenOpenCL/builtins-amdgcn-gfx9.cl
clang/test/CodeGenOpenCL/builtins-amdgcn-vi.cl

Removed: 




diff  --git a/clang/include/clang/Basic/BuiltinsAMDGPU.def 
b/clang/include/clang/Basic/BuiltinsAMDGPU.def
index 7dcbf9a096961..e3782fc403bdd 100644
--- a/clang/include/clang/Basic/BuiltinsAMDGPU.def
+++ b/clang/include/clang/Basic/BuiltinsAMDGPU.def
@@ -65,6 +65,7 @@ BUILTIN(__builtin_amdgcn_ds_gws_sema_v, "vUi", "n")
 BUILTIN(__builtin_amdgcn_ds_gws_sema_br, "vUiUi", "n")
 BUILTIN(__builtin_amdgcn_ds_gws_sema_p, "vUi", "n")
 BUILTIN(__builtin_amdgcn_fence, "vUicC*", "n")
+BUILTIN(__builtin_amdgcn_groupstaticsize, "Ui", "n")
 
 BUILTIN(__builtin_amdgcn_atomic_inc32, "UZiUZiD*UZiUicC*", "n")
 BUILTIN(__builtin_amdgcn_atomic_inc64, "UWiUWiD*UWiUicC*", "n")

diff  --git a/clang/test/CodeGenOpenCL/builtins-amdgcn-ci.cl 
b/clang/test/CodeGenOpenCL/builtins-amdgcn-ci.cl
index 56da7eceb6deb..15ddd17316a71 100644
--- a/clang/test/CodeGenOpenCL/builtins-amdgcn-ci.cl
+++ b/clang/test/CodeGenOpenCL/builtins-amdgcn-ci.cl
@@ -62,3 +62,9 @@ int test_is_shared_global(const global int* ptr) {
 int test_is_private_global(const global int* ptr) {
   return __builtin_amdgcn_is_private(ptr);
 }
+
+// CHECK-LABEL: @test_groupstaticsize
+// CHECK: call i32 @llvm.amdgcn.groupstaticsize()
+void test_groupstaticsize(global uint* out) {
+  *out = __builtin_amdgcn_groupstaticsize();
+}

diff  --git a/clang/test/CodeGenOpenCL/builtins-amdgcn-gfx10.cl 
b/clang/test/CodeGenOpenCL/builtins-amdgcn-gfx10.cl
index a9bbaa9c3f54f..3b21d41659bbd 100644
--- a/clang/test/CodeGenOpenCL/builtins-amdgcn-gfx10.cl
+++ b/clang/test/CodeGenOpenCL/builtins-amdgcn-gfx10.cl
@@ -30,3 +30,10 @@ void test_s_memtime(global ulong* out)
 {
   *out = __builtin_amdgcn_s_memtime();
 }
+
+// CHECK-LABEL: @test_groupstaticsize
+// CHECK: call i32 @llvm.amdgcn.groupstaticsize()
+void test_groupstaticsize(global uint* out)
+{
+  *out = __builtin_amdgcn_groupstaticsize();
+}

diff  --git a/clang/test/CodeGenOpenCL/builtins-amdgcn-gfx9.cl 
b/clang/test/CodeGenOpenCL/builtins-amdgcn-gfx9.cl
index 420506ec083c1..3bc1811a35b71 100644
--- a/clang/test/CodeGenOpenCL/builtins-amdgcn-gfx9.cl
+++ b/clang/test/CodeGenOpenCL/builtins-amdgcn-gfx9.cl
@@ -3,6 +3,7 @@
 // RUN: %clang_cc1 -triple amdgcn-unknown-unknown -target-cpu gfx1010 -S 
-emit-llvm -o - %s | FileCheck %s
 
 #pragma OPENCL EXTENSION cl_khr_fp16 : enable
+typedef unsigned int uint;
 typedef unsigned long ulong;
 
 // CHECK-LABEL: @test_fmed3_f16
@@ -18,3 +19,10 @@ void test_s_memtime(global ulong* out)
 {
   *out = __builtin_amdgcn_s_memtime();
 }
+
+// CHECK-LABEL: @test_groupstaticsize
+// CHECK: call i32 @llvm.amdgcn.groupstaticsize()
+void test_groupstaticsize(global uint* out)
+{
+  *out = __builtin_amdgcn_groupstaticsize();
+}

diff  --git a/clang/test/CodeGenOpenCL/builtins-amdgcn-vi.cl 
b/clang/test/CodeGenOpenCL/builtins-amdgcn-vi.cl
index be594585fad6d..fe2c1692fbcc4 100644
--- a/clang/test/CodeGenOpenCL/builtins-amdgcn-vi.cl
+++ b/clang/test/CodeGenOpenCL/builtins-amdgcn-vi.cl
@@ -145,3 +145,10 @@ void test_perm(global uint* out, uint a, uint b, uint s)
 {
   *out = __builtin_amdgcn_perm(a, b, s);
 }
+
+// CHECK-LABEL: @test_groupstaticsize
+// CHECK: call i32 @llvm.amdgcn.groupstaticsize()
+void test_groupstaticsize(global uint* out)
+{
+  *out = __builtin_amdgcn_groupstaticsize();
+}



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


[PATCH] D102403: [HIP] Add __builtin_amdgcn_groupstaticsize

2021-05-13 Thread Aaron Enye Shi 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 rG6a67e05a26eb: [HIP] Add __builtin_amdgcn_groupstaticsize 
(authored by ashi1).
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D102403

Files:
  clang/include/clang/Basic/BuiltinsAMDGPU.def
  clang/test/CodeGenOpenCL/builtins-amdgcn-ci.cl
  clang/test/CodeGenOpenCL/builtins-amdgcn-gfx10.cl
  clang/test/CodeGenOpenCL/builtins-amdgcn-gfx9.cl
  clang/test/CodeGenOpenCL/builtins-amdgcn-vi.cl


Index: clang/test/CodeGenOpenCL/builtins-amdgcn-vi.cl
===
--- clang/test/CodeGenOpenCL/builtins-amdgcn-vi.cl
+++ clang/test/CodeGenOpenCL/builtins-amdgcn-vi.cl
@@ -145,3 +145,10 @@
 {
   *out = __builtin_amdgcn_perm(a, b, s);
 }
+
+// CHECK-LABEL: @test_groupstaticsize
+// CHECK: call i32 @llvm.amdgcn.groupstaticsize()
+void test_groupstaticsize(global uint* out)
+{
+  *out = __builtin_amdgcn_groupstaticsize();
+}
Index: clang/test/CodeGenOpenCL/builtins-amdgcn-gfx9.cl
===
--- clang/test/CodeGenOpenCL/builtins-amdgcn-gfx9.cl
+++ clang/test/CodeGenOpenCL/builtins-amdgcn-gfx9.cl
@@ -3,6 +3,7 @@
 // RUN: %clang_cc1 -triple amdgcn-unknown-unknown -target-cpu gfx1010 -S 
-emit-llvm -o - %s | FileCheck %s
 
 #pragma OPENCL EXTENSION cl_khr_fp16 : enable
+typedef unsigned int uint;
 typedef unsigned long ulong;
 
 // CHECK-LABEL: @test_fmed3_f16
@@ -18,3 +19,10 @@
 {
   *out = __builtin_amdgcn_s_memtime();
 }
+
+// CHECK-LABEL: @test_groupstaticsize
+// CHECK: call i32 @llvm.amdgcn.groupstaticsize()
+void test_groupstaticsize(global uint* out)
+{
+  *out = __builtin_amdgcn_groupstaticsize();
+}
Index: clang/test/CodeGenOpenCL/builtins-amdgcn-gfx10.cl
===
--- clang/test/CodeGenOpenCL/builtins-amdgcn-gfx10.cl
+++ clang/test/CodeGenOpenCL/builtins-amdgcn-gfx10.cl
@@ -30,3 +30,10 @@
 {
   *out = __builtin_amdgcn_s_memtime();
 }
+
+// CHECK-LABEL: @test_groupstaticsize
+// CHECK: call i32 @llvm.amdgcn.groupstaticsize()
+void test_groupstaticsize(global uint* out)
+{
+  *out = __builtin_amdgcn_groupstaticsize();
+}
Index: clang/test/CodeGenOpenCL/builtins-amdgcn-ci.cl
===
--- clang/test/CodeGenOpenCL/builtins-amdgcn-ci.cl
+++ clang/test/CodeGenOpenCL/builtins-amdgcn-ci.cl
@@ -62,3 +62,9 @@
 int test_is_private_global(const global int* ptr) {
   return __builtin_amdgcn_is_private(ptr);
 }
+
+// CHECK-LABEL: @test_groupstaticsize
+// CHECK: call i32 @llvm.amdgcn.groupstaticsize()
+void test_groupstaticsize(global uint* out) {
+  *out = __builtin_amdgcn_groupstaticsize();
+}
Index: clang/include/clang/Basic/BuiltinsAMDGPU.def
===
--- clang/include/clang/Basic/BuiltinsAMDGPU.def
+++ clang/include/clang/Basic/BuiltinsAMDGPU.def
@@ -65,6 +65,7 @@
 BUILTIN(__builtin_amdgcn_ds_gws_sema_br, "vUiUi", "n")
 BUILTIN(__builtin_amdgcn_ds_gws_sema_p, "vUi", "n")
 BUILTIN(__builtin_amdgcn_fence, "vUicC*", "n")
+BUILTIN(__builtin_amdgcn_groupstaticsize, "Ui", "n")
 
 BUILTIN(__builtin_amdgcn_atomic_inc32, "UZiUZiD*UZiUicC*", "n")
 BUILTIN(__builtin_amdgcn_atomic_inc64, "UWiUWiD*UWiUicC*", "n")


Index: clang/test/CodeGenOpenCL/builtins-amdgcn-vi.cl
===
--- clang/test/CodeGenOpenCL/builtins-amdgcn-vi.cl
+++ clang/test/CodeGenOpenCL/builtins-amdgcn-vi.cl
@@ -145,3 +145,10 @@
 {
   *out = __builtin_amdgcn_perm(a, b, s);
 }
+
+// CHECK-LABEL: @test_groupstaticsize
+// CHECK: call i32 @llvm.amdgcn.groupstaticsize()
+void test_groupstaticsize(global uint* out)
+{
+  *out = __builtin_amdgcn_groupstaticsize();
+}
Index: clang/test/CodeGenOpenCL/builtins-amdgcn-gfx9.cl
===
--- clang/test/CodeGenOpenCL/builtins-amdgcn-gfx9.cl
+++ clang/test/CodeGenOpenCL/builtins-amdgcn-gfx9.cl
@@ -3,6 +3,7 @@
 // RUN: %clang_cc1 -triple amdgcn-unknown-unknown -target-cpu gfx1010 -S -emit-llvm -o - %s | FileCheck %s
 
 #pragma OPENCL EXTENSION cl_khr_fp16 : enable
+typedef unsigned int uint;
 typedef unsigned long ulong;
 
 // CHECK-LABEL: @test_fmed3_f16
@@ -18,3 +19,10 @@
 {
   *out = __builtin_amdgcn_s_memtime();
 }
+
+// CHECK-LABEL: @test_groupstaticsize
+// CHECK: call i32 @llvm.amdgcn.groupstaticsize()
+void test_groupstaticsize(global uint* out)
+{
+  *out = __builtin_amdgcn_groupstaticsize();
+}
Index: clang/test/CodeGenOpenCL/builtins-amdgcn-gfx10.cl
===
--- clang/test/CodeGenOpenCL/builtins-amdgcn-gfx10.cl
+++ clang/test/CodeGenOpenCL/builtins-amdgcn-gfx10.cl
@@ -30

[PATCH] D96033: [clang-repl] Land initial infrastructure for incremental parsing

2021-05-13 Thread Hubert Tong via Phabricator via cfe-commits
hubert.reinterpretcast added a comment.

@v.g.vassilev, the test does not appear to be appropriately set up for builds 
that default to a non-native target:
https://lab.llvm.org/staging/#/builders/126/builds/371/steps/5/logs/FAIL__Clang__execute_cpp

Can you fix or revert until there is a fix?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D96033

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


[PATCH] D96033: [clang-repl] Land initial infrastructure for incremental parsing

2021-05-13 Thread Vassil Vassilev via Phabricator via cfe-commits
v.g.vassilev added a comment.

In D96033#2757077 , 
@hubert.reinterpretcast wrote:

> @v.g.vassilev, the test does not appear to be appropriately set up for builds 
> that default to a non-native target:
> https://lab.llvm.org/staging/#/builders/126/builds/371/steps/5/logs/FAIL__Clang__execute_cpp
>
> Can you fix or revert until there is a fix?

Apologies. Do you know if `REQUIRES: native` is sufficient to fix (trying to 
avoid churn)?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D96033

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


[clang] 2ed7db0 - [InstSimplify] Remove redundant {insert,extract}_vector intrinsic chains

2021-05-13 Thread Joe Ellis via cfe-commits

Author: Joe Ellis
Date: 2021-05-13T16:09:50Z
New Revision: 2ed7db0d206b6af2fffa4cb2704264b76ca61266

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

LOG: [InstSimplify] Remove redundant {insert,extract}_vector intrinsic chains

This commit removes some redundant {insert,extract}_vector intrinsic
chains by implementing the following patterns as instsimplifies:

   (insert_vector _, (extract_vector X, 0), 0) -> X
   (extract_vector (insert_vector _, X, 0), 0) -> X

Reviewed By: peterwaller-arm

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

Added: 
llvm/test/Transforms/InstSimplify/extract-vector.ll
llvm/test/Transforms/InstSimplify/insert-vector.ll

Modified: 
clang/test/CodeGen/attr-arm-sve-vector-bits-call.c
clang/test/CodeGen/attr-arm-sve-vector-bits-cast.c
llvm/lib/Analysis/InstructionSimplify.cpp

Removed: 




diff  --git a/clang/test/CodeGen/attr-arm-sve-vector-bits-call.c 
b/clang/test/CodeGen/attr-arm-sve-vector-bits-call.c
index f988d54bacd4f..edc307745a2aa 100644
--- a/clang/test/CodeGen/attr-arm-sve-vector-bits-call.c
+++ b/clang/test/CodeGen/attr-arm-sve-vector-bits-call.c
@@ -24,11 +24,7 @@ svint32_t sizeless_callee(svint32_t x) {
 
 // CHECK-LABEL: @fixed_caller(
 // CHECK-NEXT:  entry:
-// CHECK-NEXT:[[X:%.*]] = call <16 x i32> 
@llvm.experimental.vector.extract.v16i32.nxv4i32( 
[[X_COERCE:%.*]], i64 0)
-// CHECK-NEXT:[[CASTSCALABLESVE:%.*]] = call  
@llvm.experimental.vector.insert.nxv4i32.v16i32( undef, <16 x 
i32> [[X]], i64 0)
-// CHECK-NEXT:[[CASTFIXEDSVE:%.*]] = call <16 x i32> 
@llvm.experimental.vector.extract.v16i32.nxv4i32( 
[[CASTSCALABLESVE]], i64 0)
-// CHECK-NEXT:[[CASTSCALABLESVE1:%.*]] = call  
@llvm.experimental.vector.insert.nxv4i32.v16i32( undef, <16 x 
i32> [[CASTFIXEDSVE]], i64 0)
-// CHECK-NEXT:ret  [[CASTSCALABLESVE1]]
+// CHECK-NEXT:ret  [[X_COERCE:%.*]]
 //
 fixed_int32_t fixed_caller(fixed_int32_t x) {
   return sizeless_callee(x);
@@ -36,9 +32,7 @@ fixed_int32_t fixed_caller(fixed_int32_t x) {
 
 // CHECK-LABEL: @fixed_callee(
 // CHECK-NEXT:  entry:
-// CHECK-NEXT:[[X:%.*]] = call <16 x i32> 
@llvm.experimental.vector.extract.v16i32.nxv4i32( 
[[X_COERCE:%.*]], i64 0)
-// CHECK-NEXT:[[CASTSCALABLESVE:%.*]] = call  
@llvm.experimental.vector.insert.nxv4i32.v16i32( undef, <16 x 
i32> [[X]], i64 0)
-// CHECK-NEXT:ret  [[CASTSCALABLESVE]]
+// CHECK-NEXT:ret  [[X_COERCE:%.*]]
 //
 fixed_int32_t fixed_callee(fixed_int32_t x) {
   return x;
@@ -47,12 +41,9 @@ fixed_int32_t fixed_callee(fixed_int32_t x) {
 // CHECK-LABEL: @sizeless_caller(
 // CHECK-NEXT:  entry:
 // CHECK-NEXT:[[COERCE1:%.*]] = alloca <16 x i32>, align 16
-// CHECK-NEXT:[[CASTFIXEDSVE:%.*]] = call <16 x i32> 
@llvm.experimental.vector.extract.v16i32.nxv4i32( [[X:%.*]], 
i64 0)
-// CHECK-NEXT:[[CASTSCALABLESVE:%.*]] = call  
@llvm.experimental.vector.insert.nxv4i32.v16i32( undef, <16 x 
i32> [[CASTFIXEDSVE]], i64 0)
-// CHECK-NEXT:[[CALL:%.*]] = call  @fixed_callee( [[CASTSCALABLESVE]])
 // CHECK-NEXT:[[TMP0:%.*]] = bitcast <16 x i32>* [[COERCE1]] to *
-// CHECK-NEXT:store  [[CALL]], * 
[[TMP0]], align 16
-// CHECK-NEXT:[[TMP1:%.*]] = load <16 x i32>, <16 x i32>* [[COERCE1]], 
align 16, [[TBAA6:!tbaa !.*]]
+// CHECK-NEXT:store  [[X:%.*]], * 
[[TMP0]], align 16
+// CHECK-NEXT:[[TMP1:%.*]] = load <16 x i32>, <16 x i32>* [[COERCE1]], 
align 16, !tbaa [[TBAA6:![0-9]+]]
 // CHECK-NEXT:[[CASTSCALABLESVE2:%.*]] = call  
@llvm.experimental.vector.insert.nxv4i32.v16i32( undef, <16 x 
i32> [[TMP1]], i64 0)
 // CHECK-NEXT:ret  [[CASTSCALABLESVE2]]
 //
@@ -66,15 +57,9 @@ svint32_t sizeless_caller(svint32_t x) {
 
 // CHECK-LABEL: @call_int32_ff(
 // CHECK-NEXT:  entry:
-// CHECK-NEXT:[[OP1:%.*]] = call <16 x i32> 
@llvm.experimental.vector.extract.v16i32.nxv4i32( 
[[OP1_COERCE:%.*]], i64 0)
-// CHECK-NEXT:[[OP2:%.*]] = call <16 x i32> 
@llvm.experimental.vector.extract.v16i32.nxv4i32( 
[[OP2_COERCE:%.*]], i64 0)
-// CHECK-NEXT:[[CASTSCALABLESVE:%.*]] = call  
@llvm.experimental.vector.insert.nxv4i32.v16i32( undef, <16 x 
i32> [[OP1]], i64 0)
-// CHECK-NEXT:[[CASTSCALABLESVE2:%.*]] = call  
@llvm.experimental.vector.insert.nxv4i32.v16i32( undef, <16 x 
i32> [[OP2]], i64 0)
 // CHECK-NEXT:[[TMP0:%.*]] = call  
@llvm.aarch64.sve.convert.from.svbool.nxv4i1( [[PG:%.*]])
-// CHECK-NEXT:[[TMP1:%.*]] = call  
@llvm.aarch64.sve.sel.nxv4i32( [[TMP0]],  
[[CASTSCALABLESVE]],  [[CASTSCALABLESVE2]])
-// CHECK-NEXT:[[CASTFIXEDSVE:%.*]] = call <16 x i32> 
@llvm.experimental.vector.extract.v16i32.nxv4i32( [[TMP1]], 
i64 0)
-// CHECK-NEXT:[[CASTSCALABLESVE3:%.*]] = call  
@llvm.experimental.vector.insert.nxv4i32.v16i32( undef, <16 x 
i32> [[CASTFIXEDSVE]], i64 0)
-// CH

[PATCH] D101986: [InstSimplify] Remove redundant {insert,extract}_vector intrinsic chains

2021-05-13 Thread Joe Ellis 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 rG2ed7db0d206b: [InstSimplify] Remove redundant 
{insert,extract}_vector intrinsic chains (authored by joechrisellis).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101986

Files:
  clang/test/CodeGen/attr-arm-sve-vector-bits-call.c
  clang/test/CodeGen/attr-arm-sve-vector-bits-cast.c
  llvm/lib/Analysis/InstructionSimplify.cpp
  llvm/test/Transforms/InstSimplify/extract-vector.ll
  llvm/test/Transforms/InstSimplify/insert-vector.ll

Index: llvm/test/Transforms/InstSimplify/insert-vector.ll
===
--- /dev/null
+++ llvm/test/Transforms/InstSimplify/insert-vector.ll
@@ -0,0 +1,26 @@
+; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
+; RUN: opt < %s -instsimplify -S | FileCheck %s
+
+define  @redundant_extract_insert_chain( %pg,  %x) {
+; CHECK-LABEL: @redundant_extract_insert_chain(
+; CHECK-NEXT:ret  [[X:%.*]]
+;
+  %extracted = call <32 x i8> @llvm.experimental.vector.extract.v32i8.nxv16i8( %x, i64 0)
+  %inserted = call  @llvm.experimental.vector.insert.nxv16i8.v32i8( undef, <32 x i8> %extracted, i64 0)
+  ret  %inserted
+}
+
+define  @non_redundant_extract_insert_chain( %pg,  %x) {
+; CHECK-LABEL: @non_redundant_extract_insert_chain(
+; CHECK-NEXT:[[EXTRACTED:%.*]] = call <32 x i8> @llvm.experimental.vector.extract.v32i8.nxv32i8( [[X:%.*]], i64 0)
+; CHECK-NEXT:[[INSERTED:%.*]] = call  @llvm.experimental.vector.insert.nxv16i8.v32i8( undef, <32 x i8> [[EXTRACTED]], i64 0)
+; CHECK-NEXT:ret  [[INSERTED]]
+;
+  %extracted = call <32 x i8> @llvm.experimental.vector.extract.v32i8.nxv32i8( %x, i64 0)
+  %inserted = call  @llvm.experimental.vector.insert.nxv16i8.v32i8( undef, <32 x i8> %extracted, i64 0)
+  ret  %inserted
+}
+
+declare <32 x i8> @llvm.experimental.vector.extract.v32i8.nxv16i8(, i64)
+declare <32 x i8> @llvm.experimental.vector.extract.v32i8.nxv32i8(, i64)
+declare  @llvm.experimental.vector.insert.nxv16i8.v32i8(, <32 x i8>, i64)
Index: llvm/test/Transforms/InstSimplify/extract-vector.ll
===
--- /dev/null
+++ llvm/test/Transforms/InstSimplify/extract-vector.ll
@@ -0,0 +1,26 @@
+; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
+; RUN: opt < %s -instsimplify -S | FileCheck %s
+
+define <16 x i8> @redundant_insert_extract_chain(<16 x i8> %x) {
+; CHECK-LABEL: @redundant_insert_extract_chain(
+; CHECK-NEXT:ret <16 x i8> [[X:%.*]]
+;
+  %inserted = call  @llvm.experimental.vector.insert.nxv32i8.v16i8( undef, <16 x i8> %x, i64 0)
+  %extracted = call <16 x i8> @llvm.experimental.vector.extract.v16i8.nxv32i8( %inserted, i64 0)
+  ret <16 x i8> %extracted
+}
+
+define <8 x i8> @non_redundant_insert_extract_chain(<16 x i8> %x) {
+; CHECK-LABEL: @non_redundant_insert_extract_chain(
+; CHECK-NEXT:[[INSERTED:%.*]] = call  @llvm.experimental.vector.insert.nxv32i8.v16i8( undef, <16 x i8> [[X:%.*]], i64 0)
+; CHECK-NEXT:[[EXTRACTED:%.*]] = call <8 x i8> @llvm.experimental.vector.extract.v8i8.nxv32i8( [[INSERTED]], i64 0)
+; CHECK-NEXT:ret <8 x i8> [[EXTRACTED]]
+;
+  %inserted = call  @llvm.experimental.vector.insert.nxv32i8.v16i8( undef, <16 x i8> %x, i64 0)
+  %extracted = call <8 x i8> @llvm.experimental.vector.extract.v8i8.nxv32i8( %inserted, i64 0)
+  ret <8 x i8> %extracted
+}
+
+declare <16 x i8> @llvm.experimental.vector.extract.v16i8.nxv32i8(, i64)
+declare <8 x i8> @llvm.experimental.vector.extract.v8i8.nxv32i8(, i64)
+declare  @llvm.experimental.vector.insert.nxv32i8.v16i8(, <16 x i8>, i64)
Index: llvm/lib/Analysis/InstructionSimplify.cpp
===
--- llvm/lib/Analysis/InstructionSimplify.cpp
+++ llvm/lib/Analysis/InstructionSimplify.cpp
@@ -5625,6 +5625,19 @@
 
 break;
   }
+  case Intrinsic::experimental_vector_extract: {
+Type *ReturnType = F->getReturnType();
+
+// (extract_vector (insert_vector _, X, 0), 0) -> X
+unsigned IdxN = cast(Op1)->getZExtValue();
+Value *X = nullptr;
+if (match(Op0, m_Intrinsic(
+   m_Value(), m_Value(X), m_Zero())) &&
+IdxN == 0 && X->getType() == ReturnType)
+  return X;
+
+break;
+  }
   default:
 break;
   }
@@ -5720,6 +5733,21 @@
 
 return nullptr;
   }
+  case Intrinsic::experimental_vector_insert: {
+Value *SubVec = Call->getArgOperand(1);
+Value *Idx = Call->getArgOperand(2);
+Type *ReturnType = F->getReturnType();
+
+// (insert_vector _, (extract_vector X, 0), 0) -> X
+unsigned IdxN = cast(Idx)->getZExtValue();
+Value *X = nullptr;
+if (match(SubVec, m_Intrinsic(
+  m_Value(X), m_Zero())) &&
+IdxN == 0 && X->getType() == ReturnType)
+  ret

[PATCH] D96163: [analyzer] Add 12.0.0. release notes

2021-05-13 Thread Kristóf Umann via Phabricator via cfe-commits
Szelethus closed this revision.
Szelethus added a comment.

Pushed this to the 12.0.0 release branch, just forgot to close it!


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

https://reviews.llvm.org/D96163

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


[PATCH] D97085: [OpenMP] libomp: implement OpenMP 5.1 inoutset task dependence type

2021-05-13 Thread Andrey Churbanov via Phabricator via cfe-commits
AndreyChurbanov updated this revision to Diff 345173.
AndreyChurbanov added a comment.

Fixed one more codegen test.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97085

Files:
  clang/lib/CodeGen/CGOpenMPRuntime.cpp
  clang/test/OpenMP/depobj_codegen.cpp
  clang/test/OpenMP/target_enter_data_depend_codegen.cpp
  clang/test/OpenMP/target_exit_data_depend_codegen.cpp
  clang/test/OpenMP/target_update_depend_codegen.cpp
  clang/test/OpenMP/task_codegen.c
  clang/test/OpenMP/task_codegen.cpp
  clang/test/OpenMP/task_if_codegen.cpp
  openmp/runtime/src/kmp.h
  openmp/runtime/src/kmp_taskdeps.cpp
  openmp/runtime/src/kmp_taskdeps.h
  openmp/runtime/test/tasking/bug_nested_proxy_task.c
  openmp/runtime/test/tasking/bug_proxy_task_dep_waiting.c
  openmp/runtime/test/tasking/hidden_helper_task/common.h
  openmp/runtime/test/tasking/hidden_helper_task/depend.cpp
  openmp/runtime/test/tasking/hidden_helper_task/gtid.cpp
  openmp/runtime/test/tasking/omp51_task_dep_inoutset.c

Index: openmp/runtime/test/tasking/omp51_task_dep_inoutset.c
===
--- /dev/null
+++ openmp/runtime/test/tasking/omp51_task_dep_inoutset.c
@@ -0,0 +1,258 @@
+// RUN: %libomp-compile-and-run
+// RUN: %libomp-cxx-compile-and-run
+// UNSUPPORTED: gcc
+
+// Tests OMP 5.0 task dependences "mutexinoutset" and 5.1 "inoutset",
+// emulates compiler codegen for new dep kinds
+// Mutually exclusive tasks get same input dependency info array
+//
+// Task tree created:
+//  task0 - task1 (in)
+// \
+//task2 - task3 (inoutset)
+// /
+//  task3 - task4 (in)
+//   /
+//  task6 <-->task7  (mutexinoutset)
+//   \/
+//   task8 (in)
+//
+#include 
+#include 
+
+#ifdef _WIN32
+#include 
+#define mysleep(n) Sleep(n)
+#else
+#include 
+#define mysleep(n) usleep((n)*1000)
+#endif
+
+// to check the # of concurrent tasks (must be 1 for MTX, <3 for other kinds)
+static int volatile checker = 0;
+static int err = 0;
+#ifndef DELAY
+#define DELAY 100
+#endif
+
+// ---
+// internal data to emulate compiler codegen
+typedef struct DEP {
+  size_t addr;
+  size_t len;
+  int flags;
+} dep;
+typedef struct task {
+  void** shareds;
+  void* entry;
+  int part_id;
+  void* destr_thunk;
+  int priority;
+  long long device_id;
+  int f_priv;
+} task_t;
+#define TIED 1
+typedef int(*entry_t)(int, task_t*);
+typedef struct ID {
+  int reserved_1;
+  int flags;
+  int reserved_2;
+  int reserved_3;
+  char *psource;
+} id;
+// thunk routine for tasks with MTX dependency
+int thunk_m(int gtid, task_t* ptask) {
+  int th = omp_get_thread_num();
+  #pragma omp atomic
+++checker;
+  printf("task _%d, th %d\n", ptask->f_priv, th);
+  if (checker != 1) { // no more than 1 task at a time
+err++;
+printf("Error1, checker %d != 1\n", checker);
+  }
+  mysleep(DELAY);
+  if (checker != 1) { // no more than 1 task at a time
+err++;
+printf("Error2, checker %d != 1\n", checker);
+  }
+  #pragma omp atomic
+--checker;
+  return 0;
+}
+// thunk routine for tasks with inoutset dependency
+int thunk_s(int gtid, task_t* ptask) {
+  int th = omp_get_thread_num();
+  #pragma omp atomic
+++checker;
+  printf("task _%d, th %d\n", ptask->f_priv, th);
+  if (checker > 2) { // no more than 2 tasks concurrently
+err++;
+printf("Error1, checker %d > 2\n", checker);
+  }
+  mysleep(DELAY);
+  if (checker > 2) { // no more than 2 tasks concurrently
+err++;
+printf("Error2, checker %d > 2\n", checker);
+  }
+  #pragma omp atomic
+--checker;
+  return 0;
+}
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+int __kmpc_global_thread_num(id*);
+extern task_t* __kmpc_omp_task_alloc(id *loc, int gtid, int flags,
+ size_t sz, size_t shar, entry_t rtn);
+int
+__kmpc_omp_task_with_deps(id *loc, int gtid, task_t *task, int nd, dep *dep_lst,
+  int nd_noalias, dep *noalias_dep_lst);
+static id loc = {0, 2, 0, 0, ";file;func;0;0;;"};
+#ifdef __cplusplus
+} // extern "C"
+#endif
+// End of internal data
+// ---
+
+int main()
+{
+  int i1,i2,i3;
+  omp_set_num_threads(4);
+  omp_set_dynamic(0);
+  #pragma omp parallel
+  {
+#pragma omp single nowait
+{
+  dep sdep[2];
+  task_t *ptr;
+  int gtid = __kmpc_global_thread_num(&loc);
+  int t = omp_get_thread_num();
+  #pragma omp task depend(in: i1, i2)
+  { int th = omp_get_thread_num();
+printf("task 0_%d, th %d\n", t, th);
+#pragma omp atomic
+  ++checker;
+if (checker > 2) { // no more than 2 tasks concurrently
+  err++;
+  printf("Error1, checker %d > 2\n", checker);
+}
+mysleep(DELAY);
+if (checker > 2) { // no more than

[PATCH] D101640: [clang][patch] Add support for option -fextend-arguments={32,64}: widen integer arguments to int64 in unprototyped function calls

2021-05-13 Thread Melanie Blower via Phabricator via cfe-commits
mibintc added a comment.

In D101640#2757039 , @aaron.ballman 
wrote:

> Thanks! The last remaining question to me is whether this should be a 
> target-specific option or whether it makes sense to allow it as an option for 
> any target.

I thought the patch may be more acceptable to the community if we restricted it.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101640

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


[PATCH] D96033: [clang-repl] Land initial infrastructure for incremental parsing

2021-05-13 Thread Vassil Vassilev via Phabricator via cfe-commits
v.g.vassilev added a comment.

In D96033#2757107 , @v.g.vassilev 
wrote:

> In D96033#2757077 , 
> @hubert.reinterpretcast wrote:
>
>> @v.g.vassilev, the test does not appear to be appropriately set up for 
>> builds that default to a non-native target:
>> https://lab.llvm.org/staging/#/builders/126/builds/371/steps/5/logs/FAIL__Clang__execute_cpp
>>
>> Can you fix or revert until there is a fix?
>
> Apologies. Do you know if `REQUIRES: native` is sufficient to fix (trying to 
> avoid churn)?

@lhames and I are working on a patch. We do not have easy access to such 
machines. Would you mind testing it on the bot?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D96033

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


[PATCH] D96033: [clang-repl] Land initial infrastructure for incremental parsing

2021-05-13 Thread Hubert Tong via Phabricator via cfe-commits
hubert.reinterpretcast added a comment.

In D96033#2757179 , @v.g.vassilev 
wrote:

> In D96033#2757107 , @v.g.vassilev 
> wrote:
>
>> In D96033#2757077 , 
>> @hubert.reinterpretcast wrote:
>>
>>> @v.g.vassilev, the test does not appear to be appropriately set up for 
>>> builds that default to a non-native target:
>>> https://lab.llvm.org/staging/#/builders/126/builds/371/steps/5/logs/FAIL__Clang__execute_cpp
>>>
>>> Can you fix or revert until there is a fix?
>>
>> Apologies. Do you know if `REQUIRES: native` is sufficient to fix (trying to 
>> avoid churn)?

A speculative application of the above probably helps and would be harmless (I 
think).

> @lhames and I are working on a patch. We do not have easy access to such 
> machines. Would you mind testing it on the bot?

I have a local build I can apply a patch to.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D96033

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


[PATCH] D102240: [analyzer][solver] Prevent use of a null state

2021-05-13 Thread Balázs Benics via Phabricator via cfe-commits
steakhal accepted this revision.
steakhal added a comment.
This revision is now accepted and ready to land.

In D102240#2756967 , @vsavchenko 
wrote:

> I couldn't transform `c == b` into a condition, so it crashes.

Well, that's interesting. It might worth investigating. @NoQ ?
Regardless, it's an improvement, let's land it :D


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D102240

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


[PATCH] D100124: [Clang][NVPTX] Add NVPTX intrinsics and builtins for CUDA PTX redux.sync instructions

2021-05-13 Thread Steffen Larsen via Phabricator via cfe-commits
steffenlarsen added a comment.

@tra Thanks a ton for the review! This is my first LLVM patch so I only know as 
much as the Code Review documentation tells me. Is there a process for chasing 
up additional reviews?


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

https://reviews.llvm.org/D100124

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


[PATCH] D102213: [ASTMatchers] Add forCallable(), a generalization of forFunction().

2021-05-13 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added a comment.

In D102213#2756254 , @vsavchenko 
wrote:

>> Additionally, forCallable(functionDecl()) is not equivalent to forFunction() 
>> (the former silently matches less stuff).
>
> I'm not sure I understand this one.  Can you please show an example where one 
> matches something that the other doesn't?



  void foo() {
^{
  int x = 1;
}
  }

Here `declStmt(forCallable(functionDecl()))` doesn't match because the callable 
the variable belongs to isn't a `FunctionDecl` but `declStmt(forFunction())` 
matches 'x' for 'foo'.


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

https://reviews.llvm.org/D102213

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


[PATCH] D102213: [ASTMatchers] Add forCallable(), a generalization of forFunction().

2021-05-13 Thread Valeriy Savchenko via Phabricator via cfe-commits
vsavchenko added a comment.

In D102213#2757253 , @NoQ wrote:

> In D102213#2756254 , @vsavchenko 
> wrote:
>
>>> Additionally, forCallable(functionDecl()) is not equivalent to 
>>> forFunction() (the former silently matches less stuff).
>>
>> I'm not sure I understand this one.  Can you please show an example where 
>> one matches something that the other doesn't?
>
>
>
>   void foo() {
> ^{
>   int x = 1;
> }
>   }
>
> Here `declStmt(forCallable(functionDecl()))` doesn't match because the 
> callable the variable belongs to isn't a `FunctionDecl` but 
> `declStmt(forFunction())` matches 'x' for 'foo'.

Ahhh, right! Thanks!


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

https://reviews.llvm.org/D102213

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


[PATCH] D100124: [Clang][NVPTX] Add NVPTX intrinsics and builtins for CUDA PTX redux.sync instructions

2021-05-13 Thread Artem Belevich via Phabricator via cfe-commits
tra added a comment.

In D100124#2757251 , @steffenlarsen 
wrote:

> @tra Thanks a ton for the review! This is my first LLVM patch so I only know 
> as much as the Code Review documentation tells me. Is there a process for 
> chasing up additional reviews?

Generally, you don't need approvals from *all* the reviewers on the list. My 
rule of thumb is to give the patch few days, and wait for the LGTM from someone 
who owns the code (this is hard to establish sometimes) or from someone 
familiar with the code.
In this case my LGTM is sufficient and the patch has been out long enough for 
the interested parties to raise concerns if there were any.

Do you have ability to commit to LLVM? If not, I can land the patch on your 
behalf.


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

https://reviews.llvm.org/D100124

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


[PATCH] D102418: [clangd] Always default to raw pch format

2021-05-13 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet created this revision.
kadircet added a reviewer: adamcz.
Herald added subscribers: usaxena95, arphaman.
kadircet requested review of this revision.
Herald added subscribers: cfe-commits, MaskRay, ilya-biryukov.
Herald added a project: clang-tools-extra.

Clang would emit a fatal error when it encounters an unregistered PCH
format. This change ensures clangd will always use raw format no matter what
user specifies.

As side effects:

- serializing an AST in an unknown format might throw off build

systems. I suppose this would only be an issue when build system and clangd are
racing for same PCM modules, hopefully this should be rare and both clangd or
the build system should recover on the next run.

- whenever clang reads a serialized AST it seems to be checking for file

signature and emitting non-fatal errors. so this should be fine again.

The only other valid module format in clang is `obj` but it is part of codegen,
i don't think it is worth the dependency. Hence chosing to not register it, at
least yet.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D102418

Files:
  clang-tools-extra/clangd/Compiler.cpp
  clang-tools-extra/clangd/unittests/ModulesTests.cpp


Index: clang-tools-extra/clangd/unittests/ModulesTests.cpp
===
--- clang-tools-extra/clangd/unittests/ModulesTests.cpp
+++ clang-tools-extra/clangd/unittests/ModulesTests.cpp
@@ -92,6 +92,24 @@
   TU.build();
 }
 
+// Unknown module formats are a fatal failure for clang. Ensure we don't crash.
+TEST(Modules, UnknownFormat) {
+  TestTU TU = TestTU::withCode(R"(#include "modular.h")");
+  TU.OverlayRealFileSystemForModules = true;
+  TU.ExtraArgs.push_back("-Xclang");
+  TU.ExtraArgs.push_back("-fmodule-format=obj");
+  TU.ExtraArgs.push_back("-fmodule-map-file=" + testPath("m.modulemap"));
+  TU.ExtraArgs.push_back("-fmodules");
+  TU.ExtraArgs.push_back("-fimplicit-modules");
+  TU.AdditionalFiles["modular.h"] = "";
+  TU.AdditionalFiles["m.modulemap"] = R"modulemap(
+module M {
+  header "modular.h"
+})modulemap";
+
+  // Test that we do not crash.
+  TU.build();
+}
 } // namespace
 } // namespace clangd
 } // namespace clang
Index: clang-tools-extra/clangd/Compiler.cpp
===
--- clang-tools-extra/clangd/Compiler.cpp
+++ clang-tools-extra/clangd/Compiler.cpp
@@ -85,6 +85,11 @@
   // Don't crash on `#pragma clang __debug parser_crash`
   CI->getPreprocessorOpts().DisablePragmaDebugCrash = true;
 
+  // Always default to raw container format as clangd doesn't registry any 
other
+  // and clang dies when faced with unknown formats.
+  CI->getHeaderSearchOpts().ModuleFormat =
+  PCHContainerOperations().getRawReader().getFormat().str();
+
   return CI;
 }
 


Index: clang-tools-extra/clangd/unittests/ModulesTests.cpp
===
--- clang-tools-extra/clangd/unittests/ModulesTests.cpp
+++ clang-tools-extra/clangd/unittests/ModulesTests.cpp
@@ -92,6 +92,24 @@
   TU.build();
 }
 
+// Unknown module formats are a fatal failure for clang. Ensure we don't crash.
+TEST(Modules, UnknownFormat) {
+  TestTU TU = TestTU::withCode(R"(#include "modular.h")");
+  TU.OverlayRealFileSystemForModules = true;
+  TU.ExtraArgs.push_back("-Xclang");
+  TU.ExtraArgs.push_back("-fmodule-format=obj");
+  TU.ExtraArgs.push_back("-fmodule-map-file=" + testPath("m.modulemap"));
+  TU.ExtraArgs.push_back("-fmodules");
+  TU.ExtraArgs.push_back("-fimplicit-modules");
+  TU.AdditionalFiles["modular.h"] = "";
+  TU.AdditionalFiles["m.modulemap"] = R"modulemap(
+module M {
+  header "modular.h"
+})modulemap";
+
+  // Test that we do not crash.
+  TU.build();
+}
 } // namespace
 } // namespace clangd
 } // namespace clang
Index: clang-tools-extra/clangd/Compiler.cpp
===
--- clang-tools-extra/clangd/Compiler.cpp
+++ clang-tools-extra/clangd/Compiler.cpp
@@ -85,6 +85,11 @@
   // Don't crash on `#pragma clang __debug parser_crash`
   CI->getPreprocessorOpts().DisablePragmaDebugCrash = true;
 
+  // Always default to raw container format as clangd doesn't registry any other
+  // and clang dies when faced with unknown formats.
+  CI->getHeaderSearchOpts().ModuleFormat =
+  PCHContainerOperations().getRawReader().getFormat().str();
+
   return CI;
 }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D101640: [clang][patch] Add support for option -fextend-arguments={32,64}: widen integer arguments to int64 in unprototyped function calls

2021-05-13 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

In D101640#2757178 , @mibintc wrote:

> In D101640#2757039 , @aaron.ballman 
> wrote:
>
>> Thanks! The last remaining question to me is whether this should be a 
>> target-specific option or whether it makes sense to allow it as an option 
>> for any target.
>
> I thought the patch may be more acceptable to the community if we restricted 
> it.

I think we usually prefer more general solutions to target-specific ones, 
typically. Given that the functionality is generally useful for easing porting 
projects from 32- to 64-bits and that the code is simpler without the 
target-specific bits, my preference is to go with the general solution unless 
someone else has objections.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101640

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


[clang] 9469ff1 - [PowerPC] Add clang option -m[no-]prefixed

2021-05-13 Thread Lei Huang via cfe-commits

Author: Lei Huang
Date: 2021-05-13T12:02:10-05:00
New Revision: 9469ff15b77905245e26fe7f166fc127d813a0c0

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

LOG: [PowerPC] Add clang option -m[no-]prefixed

Add user-facing front end option to turn off power10 prefixed instructions.

Reviewed By: nemanjai

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

Added: 
clang/test/Driver/ppc-prefixed.cpp

Modified: 
clang/include/clang/Driver/Options.td
clang/lib/Basic/Targets/PPC.cpp
clang/lib/Basic/Targets/PPC.h

Removed: 




diff  --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index 78cc0a4e53a5f..1fda2dac0f76f 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -3254,6 +3254,8 @@ def maltivec : Flag<["-"], "maltivec">, 
Group;
 def mno_altivec : Flag<["-"], "mno-altivec">, Group;
 def mpcrel: Flag<["-"], "mpcrel">, Group;
 def mno_pcrel: Flag<["-"], "mno-pcrel">, Group;
+def mprefixed: Flag<["-"], "mprefixed">, Group;
+def mno_prefixed: Flag<["-"], "mno-prefixed">, Group;
 def mspe : Flag<["-"], "mspe">, Group;
 def mno_spe : Flag<["-"], "mno-spe">, Group;
 def mefpu2 : Flag<["-"], "mefpu2">, Group;

diff  --git a/clang/lib/Basic/Targets/PPC.cpp b/clang/lib/Basic/Targets/PPC.cpp
index cd8cc1aed39ea..cc16934292203 100644
--- a/clang/lib/Basic/Targets/PPC.cpp
+++ b/clang/lib/Basic/Targets/PPC.cpp
@@ -56,6 +56,8 @@ bool 
PPCTargetInfo::handleTargetFeatures(std::vector &Features,
   HasP10Vector = true;
 } else if (Feature == "+pcrelative-memops") {
   HasPCRelativeMemops = true;
+} else if (Feature == "+prefix-instrs") {
+  HasPrefixInstrs = true;
 } else if (Feature == "+spe" || Feature == "+efpu2") {
   HasSPE = true;
   LongDoubleWidth = LongDoubleAlign = 64;
@@ -394,6 +396,7 @@ void PPCTargetInfo::addP10SpecificFeatures(
   Features["mma"] = true;
   Features["power10-vector"] = true;
   Features["pcrelative-memops"] = true;
+  Features["prefix-instrs"] = true;
   return;
 }
 
@@ -419,6 +422,7 @@ bool PPCTargetInfo::hasFeature(StringRef Feature) const {
   .Case("paired-vector-memops", PairedVectorMemops)
   .Case("power10-vector", HasP10Vector)
   .Case("pcrelative-memops", HasPCRelativeMemops)
+  .Case("prefix-instrs", HasPrefixInstrs)
   .Case("spe", HasSPE)
   .Case("mma", HasMMA)
   .Case("rop-protect", HasROPProtect)
@@ -451,6 +455,8 @@ void PPCTargetInfo::setFeatureEnabled(llvm::StringMap 
&Features,
   Features["power8-vector"] = Features["power9-vector"] = true;
 if (Name == "pcrel")
   Features["pcrelative-memops"] = true;
+else if (Name == "prefixed")
+  Features["prefix-instrs"] = true;
 else
   Features[Name] = true;
   } else {
@@ -471,6 +477,8 @@ void PPCTargetInfo::setFeatureEnabled(llvm::StringMap 
&Features,
   Features["power10-vector"] = false;
 if (Name == "pcrel")
   Features["pcrelative-memops"] = false;
+else if (Name == "prefixed")
+  Features["prefix-instrs"] = false;
 else
   Features[Name] = false;
   }

diff  --git a/clang/lib/Basic/Targets/PPC.h b/clang/lib/Basic/Targets/PPC.h
index 3feee82d6ccd0..554f2174fee00 100644
--- a/clang/lib/Basic/Targets/PPC.h
+++ b/clang/lib/Basic/Targets/PPC.h
@@ -73,6 +73,7 @@ class LLVM_LIBRARY_VISIBILITY PPCTargetInfo : public 
TargetInfo {
   bool PairedVectorMemops = false;
   bool HasP10Vector = false;
   bool HasPCRelativeMemops = false;
+  bool HasPrefixInstrs = false;
 
 protected:
   std::string ABI;

diff  --git a/clang/test/Driver/ppc-prefixed.cpp 
b/clang/test/Driver/ppc-prefixed.cpp
new file mode 100644
index 0..3d6a13f83d0b2
--- /dev/null
+++ b/clang/test/Driver/ppc-prefixed.cpp
@@ -0,0 +1,12 @@
+// RUN: %clang -target powerpc64-unknown-linux-gnu %s -### -mcpu=pwr10 
-mprefixed -o %t.o 2>&1 | FileCheck -check-prefix=CHECK-PREFIXED %s
+// RUN: %clang -target powerpc64-unknown-linux-gnu %s -### -mcpu=pwr10 
-mno-prefixed -o %t.o 2>&1 | FileCheck -check-prefix=CHECK-NOPREFIXED %s
+// CHECK-NOPREFIXED: "-target-feature" "-prefixed"
+// CHECK-PREFIXED: "-target-feature" "+prefixed"
+
+// RUN: %clang -target powerpc64-unknown-linux-gnu -mcpu=pwr10 -emit-llvm -S 
%s -o - | grep "attributes.*+prefix-instrs"
+// RUN: %clang -target powerpc64-unknown-linux-gnu -mcpu=pwr10 -mprefixed 
-emit-llvm -S %s -o - | grep "attributes.*+prefix-instrs"
+// RUN: %clang -target powerpc64-unknown-linux-gnu -mcpu=pwr10 -mno-prefixed 
-emit-llvm -S %s -o - | grep "attributes.*\-prefix-instrs"
+
+int main(int argc, char *argv[]) {
+  return 0;
+}



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

[PATCH] D102191: [PowerPC] Add clang option -m[no-]prefixed

2021-05-13 Thread Lei Huang 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 rG9469ff15b779: [PowerPC] Add clang option -m[no-]prefixed 
(authored by lei).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D102191

Files:
  clang/include/clang/Driver/Options.td
  clang/lib/Basic/Targets/PPC.cpp
  clang/lib/Basic/Targets/PPC.h
  clang/test/Driver/ppc-prefixed.cpp


Index: clang/test/Driver/ppc-prefixed.cpp
===
--- /dev/null
+++ clang/test/Driver/ppc-prefixed.cpp
@@ -0,0 +1,12 @@
+// RUN: %clang -target powerpc64-unknown-linux-gnu %s -### -mcpu=pwr10 
-mprefixed -o %t.o 2>&1 | FileCheck -check-prefix=CHECK-PREFIXED %s
+// RUN: %clang -target powerpc64-unknown-linux-gnu %s -### -mcpu=pwr10 
-mno-prefixed -o %t.o 2>&1 | FileCheck -check-prefix=CHECK-NOPREFIXED %s
+// CHECK-NOPREFIXED: "-target-feature" "-prefixed"
+// CHECK-PREFIXED: "-target-feature" "+prefixed"
+
+// RUN: %clang -target powerpc64-unknown-linux-gnu -mcpu=pwr10 -emit-llvm -S 
%s -o - | grep "attributes.*+prefix-instrs"
+// RUN: %clang -target powerpc64-unknown-linux-gnu -mcpu=pwr10 -mprefixed 
-emit-llvm -S %s -o - | grep "attributes.*+prefix-instrs"
+// RUN: %clang -target powerpc64-unknown-linux-gnu -mcpu=pwr10 -mno-prefixed 
-emit-llvm -S %s -o - | grep "attributes.*\-prefix-instrs"
+
+int main(int argc, char *argv[]) {
+  return 0;
+}
Index: clang/lib/Basic/Targets/PPC.h
===
--- clang/lib/Basic/Targets/PPC.h
+++ clang/lib/Basic/Targets/PPC.h
@@ -73,6 +73,7 @@
   bool PairedVectorMemops = false;
   bool HasP10Vector = false;
   bool HasPCRelativeMemops = false;
+  bool HasPrefixInstrs = false;
 
 protected:
   std::string ABI;
Index: clang/lib/Basic/Targets/PPC.cpp
===
--- clang/lib/Basic/Targets/PPC.cpp
+++ clang/lib/Basic/Targets/PPC.cpp
@@ -56,6 +56,8 @@
   HasP10Vector = true;
 } else if (Feature == "+pcrelative-memops") {
   HasPCRelativeMemops = true;
+} else if (Feature == "+prefix-instrs") {
+  HasPrefixInstrs = true;
 } else if (Feature == "+spe" || Feature == "+efpu2") {
   HasSPE = true;
   LongDoubleWidth = LongDoubleAlign = 64;
@@ -394,6 +396,7 @@
   Features["mma"] = true;
   Features["power10-vector"] = true;
   Features["pcrelative-memops"] = true;
+  Features["prefix-instrs"] = true;
   return;
 }
 
@@ -419,6 +422,7 @@
   .Case("paired-vector-memops", PairedVectorMemops)
   .Case("power10-vector", HasP10Vector)
   .Case("pcrelative-memops", HasPCRelativeMemops)
+  .Case("prefix-instrs", HasPrefixInstrs)
   .Case("spe", HasSPE)
   .Case("mma", HasMMA)
   .Case("rop-protect", HasROPProtect)
@@ -451,6 +455,8 @@
   Features["power8-vector"] = Features["power9-vector"] = true;
 if (Name == "pcrel")
   Features["pcrelative-memops"] = true;
+else if (Name == "prefixed")
+  Features["prefix-instrs"] = true;
 else
   Features[Name] = true;
   } else {
@@ -471,6 +477,8 @@
   Features["power10-vector"] = false;
 if (Name == "pcrel")
   Features["pcrelative-memops"] = false;
+else if (Name == "prefixed")
+  Features["prefix-instrs"] = false;
 else
   Features[Name] = false;
   }
Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -3254,6 +3254,8 @@
 def mno_altivec : Flag<["-"], "mno-altivec">, Group;
 def mpcrel: Flag<["-"], "mpcrel">, Group;
 def mno_pcrel: Flag<["-"], "mno-pcrel">, Group;
+def mprefixed: Flag<["-"], "mprefixed">, Group;
+def mno_prefixed: Flag<["-"], "mno-prefixed">, Group;
 def mspe : Flag<["-"], "mspe">, Group;
 def mno_spe : Flag<["-"], "mno-spe">, Group;
 def mefpu2 : Flag<["-"], "mefpu2">, Group;


Index: clang/test/Driver/ppc-prefixed.cpp
===
--- /dev/null
+++ clang/test/Driver/ppc-prefixed.cpp
@@ -0,0 +1,12 @@
+// RUN: %clang -target powerpc64-unknown-linux-gnu %s -### -mcpu=pwr10 -mprefixed -o %t.o 2>&1 | FileCheck -check-prefix=CHECK-PREFIXED %s
+// RUN: %clang -target powerpc64-unknown-linux-gnu %s -### -mcpu=pwr10 -mno-prefixed -o %t.o 2>&1 | FileCheck -check-prefix=CHECK-NOPREFIXED %s
+// CHECK-NOPREFIXED: "-target-feature" "-prefixed"
+// CHECK-PREFIXED: "-target-feature" "+prefixed"
+
+// RUN: %clang -target powerpc64-unknown-linux-gnu -mcpu=pwr10 -emit-llvm -S %s -o - | grep "attributes.*+prefix-instrs"
+// RUN: %clang -target powerpc64-unknown-linux-gnu -mcpu=pwr10 -mprefixed -emit-llvm -S %s -o - | grep "attributes.*+prefix-instrs"
+// RUN: %clang -target powerpc64-unknown-linux-gnu -mcpu=pwr10 -mno-prefixed -emit-llvm -S %s -o - | grep

[PATCH] D102244: [llvm][AsmPrinter] Restore source location to register clobber warning

2021-05-13 Thread Yuanfang Chen via Phabricator via cfe-commits
ychen accepted this revision.
ychen added a comment.
This revision is now accepted and ready to land.

LGTM. Thanks.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D102244

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


[PATCH] D102213: [ASTMatchers] Add forCallable(), a generalization of forFunction().

2021-05-13 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

In D102213#2755064 , @NoQ wrote:

> I'm also mildly worried that Function is not the technically correct term. 
> Maybe we should mark the old matcher as deprecated instead?

Thank you for the explanations as to why there's a separate matcher. I think 
using a separate matcher is the safer approach to introduce the functionality. 
I'd be fine if we marked the old matcher as deprecated in the documentation for 
it. (I don't believe that we've added any louder deprecation markings yet aside 
from comments.)




Comment at: clang/include/clang/ASTMatchers/ASTMatchers.h:7601
+  llvm::SmallVector Stack(Parents.begin(), Parents.end());
+  while(!Stack.empty()) {
+const auto &CurNode = Stack.back();

Might as well fix this clang-format warning.



Comment at: clang/include/clang/ASTMatchers/ASTMatchers.h:7597
+///   but does not match 'int y = 2'.
+AST_MATCHER_P(Stmt, forCallable, internal::Matcher, InnerMatcher) {
+  const auto &Parents = Finder->getASTContext().getParents(Node);

NoQ wrote:
> aaron.ballman wrote:
> > You should also update Registry.cpp to expose this via the dynamic matchers.
> Uh-oh, i knew i was forgetting something!
> 
> Do we have a checklist? (Do we want to?)
I don't think we have a checklist, but the mental checklist I use is:

* If there's a change to doc comments in ASTMatchers.h, did the HTML file get 
regenerated?
* If there's a new matcher added, did Registry.cpp get updated for it?
* If there are changes to the list in Registry.cpp, is the list still 
alphabetical?
* Testcases?


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

https://reviews.llvm.org/D102213

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


[PATCH] D96033: [clang-repl] Land initial infrastructure for incremental parsing

2021-05-13 Thread Lang Hames via Phabricator via cfe-commits
lhames added a comment.

In D96033#2757222 , 
@hubert.reinterpretcast wrote:

> ... 
> I have a local build I can apply a patch to.

Hi Hubert,

Could you apply the following patch and let me know the output from the failing 
test? I'm trying to work out whether the JIT is getting the triple or the data 
layout wrong.

  diff --git a/clang/tools/clang-repl/ClangRepl.cpp 
b/clang/tools/clang-repl/ClangRepl.cpp
  index b5b5bf6e0c6b..cbf67f0e163e 100644
  --- a/clang/tools/clang-repl/ClangRepl.cpp
  +++ b/clang/tools/clang-repl/ClangRepl.cpp
  @@ -57,6 +57,12 @@ int main(int argc, const char **argv) {
 llvm::InitializeNativeTarget();
 llvm::InitializeNativeTargetAsmPrinter();
   
  +  auto JTMB = ExitOnErr(llvm::orc::JITTargetMachineBuilder::detectHost());
  +  llvm::errs() << "triple: " << JTMB.getTargetTriple().str() << "\n";
  +  llvm::errs() << "datalayout: "
  +   << ExitOnErr(JTMB.getDefaultDataLayoutForTarget())
  +  .getStringRepresentation()
  +   << "\n";
 if (OptHostSupportsJit) {
   auto J = llvm::orc::LLJITBuilder().create();
   if (J)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D96033

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


[PATCH] D100124: [Clang][NVPTX] Add NVPTX intrinsics and builtins for CUDA PTX redux.sync instructions

2021-05-13 Thread Steffen Larsen via Phabricator via cfe-commits
steffenlarsen added a comment.

In D100124#2757306 , @tra wrote:

> Do you have ability to commit to LLVM? If not, I can land the patch on your 
> behalf.

Not to my knowledge, so please do. Thanks again!

https://reviews.llvm.org/D100394 is from my colleagues and it also looks ready. 
Would you mind landing that one as well? 😄


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

https://reviews.llvm.org/D100124

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


[clang] 7c2afd5 - Modules: Remove ModuleLoader::OtherUncachedFailure, NFC

2021-05-13 Thread Duncan P. N. Exon Smith via cfe-commits

Author: Duncan P. N. Exon Smith
Date: 2021-05-13T10:10:46-07:00
New Revision: 7c2afd5899df876eaf5ffb485194dc58e92daf89

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

LOG: Modules: Remove ModuleLoader::OtherUncachedFailure, NFC

5cca622310c10fdf6f921b6cce26f91d9f14c762 refactored
CompilerInstance::loadModule, splitting out
findOrCompileModuleAndReadAST, but was careful to avoid making any
functional changes. It added ModuleLoader::OtherUncachedFailure to
facilitate this and left behind FIXMEs asking why certain failures
weren't cached.

After a closer look, I think we can just remove this and simplify the
code. This changes the behaviour of the following (simplified) code from
CompilerInstance::loadModule, causing a failure to be cached more often:

```
  if (auto MaybeModule = MM.getCachedModuleLoad(*Path[0].first))
return *MaybeModule;
  if (ModuleName == getLangOpts().CurrentModule)
return MM.cacheModuleLoad(PP.lookupModule(...));
  ModuleLoadResult Result = findOrCompileModuleAndReadAST(...);
  if (Result.isNormal()) // This will be 'true' more often.
return MM.cacheModuleLoad(..., Module);
  return Result;
```

`MM` here is a ModuleMap owned by the Preprocessor. Here are the cases
where `findOrCompileModuleAndReadAST` starts returning a "normal" failed
result:
- Emitted `diag::err_module_not_found`, where there's no module map
  found.
- Emitted `diag::err_module_build_disabled`, where implicitly building
  modules is disabled.
- Emitted `diag::err_module_cycle`, which detects module cycles in the
  implicit modules build system.
- Emitted `diag::err_module_not_built`, which avoids building a module
  in this CompilerInstance if another one tried and failed already.
- `compileModuleAndReadAST()` was called and failed to build.

The four errors are all fatal, and last item also reports a fatal error,
so it this extra caching has no functionality change... but even if it
did, it seems fine to cache these failed results within a ModuleMap
instance (note that each CompilerInstance has its own Preprocessor and
ModuleMap).

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

Added: 


Modified: 
clang/include/clang/Lex/ModuleLoader.h
clang/lib/Frontend/CompilerInstance.cpp

Removed: 




diff  --git a/clang/include/clang/Lex/ModuleLoader.h 
b/clang/include/clang/Lex/ModuleLoader.h
index c1f7f068c0f1d..bf044e0e5f506 100644
--- a/clang/include/clang/Lex/ModuleLoader.h
+++ b/clang/include/clang/Lex/ModuleLoader.h
@@ -45,9 +45,6 @@ class ModuleLoadResult {
 
 // The module exists but cannot be imported due to a configuration 
mismatch.
 ConfigMismatch,
-
-// We failed to load the module, but we shouldn't cache the failure.
-OtherUncachedFailure,
   };
   llvm::PointerIntPair Storage;
 

diff  --git a/clang/lib/Frontend/CompilerInstance.cpp 
b/clang/lib/Frontend/CompilerInstance.cpp
index bcf9f9694f885..695c7e335fb40 100644
--- a/clang/lib/Frontend/CompilerInstance.cpp
+++ b/clang/lib/Frontend/CompilerInstance.cpp
@@ -1684,8 +1684,7 @@ ModuleLoadResult 
CompilerInstance::findOrCompileModuleAndReadAST(
 getDiagnostics().Report(ModuleNameLoc, diag::err_module_not_found)
 << ModuleName << SourceRange(ImportLoc, ModuleNameLoc);
 ModuleBuildFailed = true;
-// FIXME: Why is this not cached?
-return ModuleLoadResult::OtherUncachedFailure;
+return nullptr;
   }
   if (ModuleFilename.empty()) {
 if (M && M->HasIncompatibleModuleFile) {
@@ -1697,8 +1696,7 @@ ModuleLoadResult 
CompilerInstance::findOrCompileModuleAndReadAST(
 getDiagnostics().Report(ModuleNameLoc, diag::err_module_build_disabled)
 << ModuleName;
 ModuleBuildFailed = true;
-// FIXME: Why is this not cached?
-return ModuleLoadResult::OtherUncachedFailure;
+return nullptr;
   }
 
   // Create an ASTReader on demand.
@@ -1809,8 +1807,7 @@ ModuleLoadResult 
CompilerInstance::findOrCompileModuleAndReadAST(
 getDiagnostics().Report(ModuleNameLoc, diag::err_module_cycle)
 << ModuleName << CyclePath;
 // FIXME: Should this set ModuleBuildFailed = true?
-// FIXME: Why is this not cached?
-return ModuleLoadResult::OtherUncachedFailure;
+return nullptr;
   }
 
   // Check whether we have already attempted to build this module (but
@@ -1820,8 +1817,7 @@ ModuleLoadResult 
CompilerInstance::findOrCompileModuleAndReadAST(
 getDiagnostics().Report(ModuleNameLoc, diag::err_module_not_built)
 << ModuleName << SourceRange(ImportLoc, ModuleNameLoc);
 ModuleBuildFailed = true;
-// FIXME: Why is this not cached?
-return ModuleLoadResult::OtherUncachedFailure;
+return nullptr;
   }
 
   // Try to compile and then read the AST.
@@ -1832,8 +1828,7 @@ ModuleLoadResult 
CompilerInstance::findOrCompileMo

[PATCH] D101667: Modules: Remove ModuleLoader::OtherUncachedFailure, NFC

2021-05-13 Thread Duncan P. N. Exon Smith 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 rG7c2afd5899df: Modules: Remove 
ModuleLoader::OtherUncachedFailure, NFC (authored by dexonsmith).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101667

Files:
  clang/include/clang/Lex/ModuleLoader.h
  clang/lib/Frontend/CompilerInstance.cpp


Index: clang/lib/Frontend/CompilerInstance.cpp
===
--- clang/lib/Frontend/CompilerInstance.cpp
+++ clang/lib/Frontend/CompilerInstance.cpp
@@ -1684,8 +1684,7 @@
 getDiagnostics().Report(ModuleNameLoc, diag::err_module_not_found)
 << ModuleName << SourceRange(ImportLoc, ModuleNameLoc);
 ModuleBuildFailed = true;
-// FIXME: Why is this not cached?
-return ModuleLoadResult::OtherUncachedFailure;
+return nullptr;
   }
   if (ModuleFilename.empty()) {
 if (M && M->HasIncompatibleModuleFile) {
@@ -1697,8 +1696,7 @@
 getDiagnostics().Report(ModuleNameLoc, diag::err_module_build_disabled)
 << ModuleName;
 ModuleBuildFailed = true;
-// FIXME: Why is this not cached?
-return ModuleLoadResult::OtherUncachedFailure;
+return nullptr;
   }
 
   // Create an ASTReader on demand.
@@ -1809,8 +1807,7 @@
 getDiagnostics().Report(ModuleNameLoc, diag::err_module_cycle)
 << ModuleName << CyclePath;
 // FIXME: Should this set ModuleBuildFailed = true?
-// FIXME: Why is this not cached?
-return ModuleLoadResult::OtherUncachedFailure;
+return nullptr;
   }
 
   // Check whether we have already attempted to build this module (but
@@ -1820,8 +1817,7 @@
 getDiagnostics().Report(ModuleNameLoc, diag::err_module_not_built)
 << ModuleName << SourceRange(ImportLoc, ModuleNameLoc);
 ModuleBuildFailed = true;
-// FIXME: Why is this not cached?
-return ModuleLoadResult::OtherUncachedFailure;
+return nullptr;
   }
 
   // Try to compile and then read the AST.
@@ -1832,8 +1828,7 @@
 if (getPreprocessorOpts().FailedModules)
   getPreprocessorOpts().FailedModules->addFailed(ModuleName);
 ModuleBuildFailed = true;
-// FIXME: Why is this not cached?
-return ModuleLoadResult::OtherUncachedFailure;
+return nullptr;
   }
 
   // Okay, we've rebuilt and now loaded the module.
Index: clang/include/clang/Lex/ModuleLoader.h
===
--- clang/include/clang/Lex/ModuleLoader.h
+++ clang/include/clang/Lex/ModuleLoader.h
@@ -45,9 +45,6 @@
 
 // The module exists but cannot be imported due to a configuration 
mismatch.
 ConfigMismatch,
-
-// We failed to load the module, but we shouldn't cache the failure.
-OtherUncachedFailure,
   };
   llvm::PointerIntPair Storage;
 


Index: clang/lib/Frontend/CompilerInstance.cpp
===
--- clang/lib/Frontend/CompilerInstance.cpp
+++ clang/lib/Frontend/CompilerInstance.cpp
@@ -1684,8 +1684,7 @@
 getDiagnostics().Report(ModuleNameLoc, diag::err_module_not_found)
 << ModuleName << SourceRange(ImportLoc, ModuleNameLoc);
 ModuleBuildFailed = true;
-// FIXME: Why is this not cached?
-return ModuleLoadResult::OtherUncachedFailure;
+return nullptr;
   }
   if (ModuleFilename.empty()) {
 if (M && M->HasIncompatibleModuleFile) {
@@ -1697,8 +1696,7 @@
 getDiagnostics().Report(ModuleNameLoc, diag::err_module_build_disabled)
 << ModuleName;
 ModuleBuildFailed = true;
-// FIXME: Why is this not cached?
-return ModuleLoadResult::OtherUncachedFailure;
+return nullptr;
   }
 
   // Create an ASTReader on demand.
@@ -1809,8 +1807,7 @@
 getDiagnostics().Report(ModuleNameLoc, diag::err_module_cycle)
 << ModuleName << CyclePath;
 // FIXME: Should this set ModuleBuildFailed = true?
-// FIXME: Why is this not cached?
-return ModuleLoadResult::OtherUncachedFailure;
+return nullptr;
   }
 
   // Check whether we have already attempted to build this module (but
@@ -1820,8 +1817,7 @@
 getDiagnostics().Report(ModuleNameLoc, diag::err_module_not_built)
 << ModuleName << SourceRange(ImportLoc, ModuleNameLoc);
 ModuleBuildFailed = true;
-// FIXME: Why is this not cached?
-return ModuleLoadResult::OtherUncachedFailure;
+return nullptr;
   }
 
   // Try to compile and then read the AST.
@@ -1832,8 +1828,7 @@
 if (getPreprocessorOpts().FailedModules)
   getPreprocessorOpts().FailedModules->addFailed(ModuleName);
 ModuleBuildFailed = true;
-// FIXME: Why is this not cached?
-return ModuleLoadResult::OtherUncachedFailure;
+return nullptr;
   }
 
   // Okay, we've rebuilt and now loaded the module.
Index: clang/include/clang/Lex/ModuleLoader.h
===
--- cl

[PATCH] D102090: [CMake][ELF] Add -fno-semantic-interposition and -Bsymbolic-functions

2021-05-13 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added a subscriber: marco-c.
MaskRay added a comment.

In D102090#2756605 , @Mordante wrote:

> I tried to build the libc++ benchmarks locally and the benchmark with target 
> `to_chars_libcxx` fails to properly execute. Bi-section let to this commit. 
> Can the change in the linker flags affect libc++? I also see the scheduled 
> builds of libc++ fail at Buildkite 
> https://buildkite.com/llvm-project/libcxx-ci.
> Can you have a look at the issue?

I suspect `-fno-semantic-interposition` added here affects libc++abi as well 
and libc++abi may rely on interposition somewhere (unsure).

In D102090#2756758 , @ostannard wrote:

> There is also a test failure on the aarch64 2-stage bot 
> (https://lab.llvm.org/buildbot/#/builders/7/builds/2720) which I've bisected 
> to this change, so I'll revert it for now.

The way @marco-c  made `compiler-rt/test/profile/Posix/gcov-shared-flush.c` 
work on Linux in rL336678  is to use 
interposition of the global variables `writeout_fn_list`/etc.
This doesn't work on Darwin, thus https://bugs.llvm.org/show_bug.cgi?id=38134

I think -fno-semantic-interposition should be specific to llvm/clang for now. 
libc++abi/compiler-rt should not use the option.


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] D102240: [analyzer][solver] Prevent use of a null state

2021-05-13 Thread Valeriy Savchenko via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG45212dec01b9: [analyzer][solver] Prevent use of a null state 
(authored by vsavchenko).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D102240

Files:
  clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
  clang/test/Analysis/PR50268.c


Index: clang/test/Analysis/PR50268.c
===
--- /dev/null
+++ clang/test/Analysis/PR50268.c
@@ -0,0 +1,12 @@
+// RUN: %clang_analyze_cc1 -w -analyzer-checker=core -verify %s \
+// RUN:-analyzer-config eagerly-assume=true
+
+// expected-no-diagnostics
+
+
+int test(unsigned long a, unsigned long c, int b) {
+  c -= a;
+  if (0 >= b) {}
+  c == b;
+  return c ? 0 : 2; // no-crash
+}
Index: clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
===
--- clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
+++ clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
@@ -1487,15 +1487,18 @@
   // This is an infeasible assumption.
   return nullptr;
 
-ProgramStateRef NewState = setConstraint(State, Sym, NewConstraint);
-if (auto Equality = EqualityInfo::extract(Sym, Int, Adjustment)) {
-  // If the original assumption is not Sym + Adjustment !=/ Int,
-  // we should invert IsEquality flag.
-  Equality->IsEquality = Equality->IsEquality != EQ;
-  return track(NewState, *Equality);
+if (ProgramStateRef NewState = setConstraint(State, Sym, NewConstraint)) {
+  if (auto Equality = EqualityInfo::extract(Sym, Int, Adjustment)) {
+// If the original assumption is not Sym + Adjustment !=/ Int,
+// we should invert IsEquality flag.
+Equality->IsEquality = Equality->IsEquality != EQ;
+return track(NewState, *Equality);
+  }
+
+  return NewState;
 }
 
-return NewState;
+return nullptr;
   }
 
   ProgramStateRef track(ProgramStateRef State, EqualityInfo ToTrack) {


Index: clang/test/Analysis/PR50268.c
===
--- /dev/null
+++ clang/test/Analysis/PR50268.c
@@ -0,0 +1,12 @@
+// RUN: %clang_analyze_cc1 -w -analyzer-checker=core -verify %s \
+// RUN:-analyzer-config eagerly-assume=true
+
+// expected-no-diagnostics
+
+
+int test(unsigned long a, unsigned long c, int b) {
+  c -= a;
+  if (0 >= b) {}
+  c == b;
+  return c ? 0 : 2; // no-crash
+}
Index: clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
===
--- clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
+++ clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
@@ -1487,15 +1487,18 @@
   // This is an infeasible assumption.
   return nullptr;
 
-ProgramStateRef NewState = setConstraint(State, Sym, NewConstraint);
-if (auto Equality = EqualityInfo::extract(Sym, Int, Adjustment)) {
-  // If the original assumption is not Sym + Adjustment !=/ Int,
-  // we should invert IsEquality flag.
-  Equality->IsEquality = Equality->IsEquality != EQ;
-  return track(NewState, *Equality);
+if (ProgramStateRef NewState = setConstraint(State, Sym, NewConstraint)) {
+  if (auto Equality = EqualityInfo::extract(Sym, Int, Adjustment)) {
+// If the original assumption is not Sym + Adjustment !=/ Int,
+// we should invert IsEquality flag.
+Equality->IsEquality = Equality->IsEquality != EQ;
+return track(NewState, *Equality);
+  }
+
+  return NewState;
 }
 
-return NewState;
+return nullptr;
   }
 
   ProgramStateRef track(ProgramStateRef State, EqualityInfo ToTrack) {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 45212de - [analyzer][solver] Prevent use of a null state

2021-05-13 Thread Valeriy Savchenko via cfe-commits

Author: Valeriy Savchenko
Date: 2021-05-13T20:16:29+03:00
New Revision: 45212dec01b9be90596d8d6fa7586ce8c84e2622

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

LOG: [analyzer][solver] Prevent use of a null state

rdar://77686137

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

Added: 
clang/test/Analysis/PR50268.c

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

Removed: 




diff  --git a/clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp 
b/clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
index 974535952d0f0..e54b9c13b9355 100644
--- a/clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
+++ b/clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
@@ -1487,15 +1487,18 @@ class RangeConstraintManager : public 
RangedConstraintManager {
   // This is an infeasible assumption.
   return nullptr;
 
-ProgramStateRef NewState = setConstraint(State, Sym, NewConstraint);
-if (auto Equality = EqualityInfo::extract(Sym, Int, Adjustment)) {
-  // If the original assumption is not Sym + Adjustment !=/ Int,
-  // we should invert IsEquality flag.
-  Equality->IsEquality = Equality->IsEquality != EQ;
-  return track(NewState, *Equality);
+if (ProgramStateRef NewState = setConstraint(State, Sym, NewConstraint)) {
+  if (auto Equality = EqualityInfo::extract(Sym, Int, Adjustment)) {
+// If the original assumption is not Sym + Adjustment !=/ Int,
+// we should invert IsEquality flag.
+Equality->IsEquality = Equality->IsEquality != EQ;
+return track(NewState, *Equality);
+  }
+
+  return NewState;
 }
 
-return NewState;
+return nullptr;
   }
 
   ProgramStateRef track(ProgramStateRef State, EqualityInfo ToTrack) {

diff  --git a/clang/test/Analysis/PR50268.c b/clang/test/Analysis/PR50268.c
new file mode 100644
index 0..6e3536b7c23c5
--- /dev/null
+++ b/clang/test/Analysis/PR50268.c
@@ -0,0 +1,12 @@
+// RUN: %clang_analyze_cc1 -w -analyzer-checker=core -verify %s \
+// RUN:-analyzer-config eagerly-assume=true
+
+// expected-no-diagnostics
+
+
+int test(unsigned long a, unsigned long c, int b) {
+  c -= a;
+  if (0 >= b) {}
+  c == b;
+  return c ? 0 : 2; // no-crash
+}



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


[clang] 23e9146 - Modules: Rename ModuleBuildFailed => DisableGeneratingGlobalModuleIndex, NFC

2021-05-13 Thread Duncan P. N. Exon Smith via cfe-commits

Author: Duncan P. N. Exon Smith
Date: 2021-05-13T10:22:40-07:00
New Revision: 23e9146fba298d38142337b615e17067fb8ccb91

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

LOG: Modules: Rename ModuleBuildFailed => DisableGeneratingGlobalModuleIndex, 
NFC

Rename CompilerInstance's ModuleBuildFailed field to
DisableGeneratingGlobalModuleIndex, which more precisely describes its
role. Otherwise, it's hard to suss out how it's different from
ModuleLoader::HadFatalFailure, and what sort of code simplifications are
safe.

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

Added: 


Modified: 
clang/include/clang/Frontend/CompilerInstance.h
clang/lib/Frontend/CompilerInstance.cpp

Removed: 




diff  --git a/clang/include/clang/Frontend/CompilerInstance.h 
b/clang/include/clang/Frontend/CompilerInstance.h
index 54d57019fa548..7778924fc452f 100644
--- a/clang/include/clang/Frontend/CompilerInstance.h
+++ b/clang/include/clang/Frontend/CompilerInstance.h
@@ -150,7 +150,7 @@ class CompilerInstance : public ModuleLoader {
   bool HaveFullGlobalModuleIndex = false;
 
   /// One or more modules failed to build.
-  bool ModuleBuildFailed = false;
+  bool DisableGeneratingGlobalModuleIndex = false;
 
   /// The stream for verbose output if owned, otherwise nullptr.
   std::unique_ptr OwnedVerboseOutputStream;

diff  --git a/clang/lib/Frontend/CompilerInstance.cpp 
b/clang/lib/Frontend/CompilerInstance.cpp
index 695c7e335fb40..54917b3fb0fbe 100644
--- a/clang/lib/Frontend/CompilerInstance.cpp
+++ b/clang/lib/Frontend/CompilerInstance.cpp
@@ -77,7 +77,7 @@ bool CompilerInstance::shouldBuildGlobalModuleIndex() const {
   return (BuildGlobalModuleIndex ||
   (TheASTReader && TheASTReader->isGlobalIndexUnavailable() &&
getFrontendOpts().GenerateGlobalModuleIndex)) &&
- !ModuleBuildFailed;
+ !DisableGeneratingGlobalModuleIndex;
 }
 
 void CompilerInstance::setDiagnostics(DiagnosticsEngine *Value) {
@@ -1683,7 +1683,7 @@ ModuleLoadResult 
CompilerInstance::findOrCompileModuleAndReadAST(
 // We can't find a module, error out here.
 getDiagnostics().Report(ModuleNameLoc, diag::err_module_not_found)
 << ModuleName << SourceRange(ImportLoc, ModuleNameLoc);
-ModuleBuildFailed = true;
+DisableGeneratingGlobalModuleIndex = true;
 return nullptr;
   }
   if (ModuleFilename.empty()) {
@@ -1695,7 +1695,7 @@ ModuleLoadResult 
CompilerInstance::findOrCompileModuleAndReadAST(
 
 getDiagnostics().Report(ModuleNameLoc, diag::err_module_build_disabled)
 << ModuleName;
-ModuleBuildFailed = true;
+DisableGeneratingGlobalModuleIndex = true;
 return nullptr;
   }
 
@@ -1742,7 +1742,7 @@ ModuleLoadResult 
CompilerInstance::findOrCompileModuleAndReadAST(
 if (*ModuleFile == M->getASTFile())
   return M;
 
-ModuleBuildFailed = true;
+DisableGeneratingGlobalModuleIndex = true;
 getDiagnostics().Report(ModuleNameLoc, diag::err_module_prebuilt)
 << ModuleName;
 return ModuleLoadResult();
@@ -1764,14 +1764,14 @@ ModuleLoadResult 
CompilerInstance::findOrCompileModuleAndReadAST(
 LLVM_FALLTHROUGH;
   case ASTReader::VersionMismatch:
   case ASTReader::HadErrors:
-// FIXME: Should this set ModuleBuildFailed = true?
+// FIXME: Should this set DisableGeneratingGlobalModuleIndex = true?
 ModuleLoader::HadFatalFailure = true;
 // FIXME: The ASTReader will already have complained, but can we shoehorn
 // that diagnostic information into a more useful form?
 return ModuleLoadResult();
 
   case ASTReader::Failure:
-// FIXME: Should this set ModuleBuildFailed = true?
+// FIXME: Should this set DisableGeneratingGlobalModuleIndex = true?
 ModuleLoader::HadFatalFailure = true;
 return ModuleLoadResult();
   }
@@ -1781,7 +1781,7 @@ ModuleLoadResult 
CompilerInstance::findOrCompileModuleAndReadAST(
 // We don't know the desired configuration for this module and don't
 // necessarily even have a module map. Since ReadAST already produces
 // diagnostics for these two cases, we simply error out here.
-ModuleBuildFailed = true;
+DisableGeneratingGlobalModuleIndex = true;
 return ModuleLoadResult();
   }
 
@@ -1806,7 +1806,7 @@ ModuleLoadResult 
CompilerInstance::findOrCompileModuleAndReadAST(
 
 getDiagnostics().Report(ModuleNameLoc, diag::err_module_cycle)
 << ModuleName << CyclePath;
-// FIXME: Should this set ModuleBuildFailed = true?
+// FIXME: Should this set DisableGeneratingGlobalModuleIndex = true?
 return nullptr;
   }
 
@@ -1816,7 +1816,7 @@ ModuleLoadResult 
CompilerInstance::findOrCompileModuleAndReadAST(
   getPreprocessorOpts().FailedModules->hasAlreadyFailed(ModuleName)) {
 getDiagnostics().Repor

[PATCH] D101670: Modules: Rename ModuleBuildFailed => DisableGeneratingGlobalModuleIndex, NFC

2021-05-13 Thread Duncan P. N. Exon Smith 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 rG23e9146fba29: Modules: Rename ModuleBuildFailed => 
DisableGeneratingGlobalModuleIndex, NFC (authored by dexonsmith).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101670

Files:
  clang/include/clang/Frontend/CompilerInstance.h
  clang/lib/Frontend/CompilerInstance.cpp

Index: clang/lib/Frontend/CompilerInstance.cpp
===
--- clang/lib/Frontend/CompilerInstance.cpp
+++ clang/lib/Frontend/CompilerInstance.cpp
@@ -77,7 +77,7 @@
   return (BuildGlobalModuleIndex ||
   (TheASTReader && TheASTReader->isGlobalIndexUnavailable() &&
getFrontendOpts().GenerateGlobalModuleIndex)) &&
- !ModuleBuildFailed;
+ !DisableGeneratingGlobalModuleIndex;
 }
 
 void CompilerInstance::setDiagnostics(DiagnosticsEngine *Value) {
@@ -1683,7 +1683,7 @@
 // We can't find a module, error out here.
 getDiagnostics().Report(ModuleNameLoc, diag::err_module_not_found)
 << ModuleName << SourceRange(ImportLoc, ModuleNameLoc);
-ModuleBuildFailed = true;
+DisableGeneratingGlobalModuleIndex = true;
 return nullptr;
   }
   if (ModuleFilename.empty()) {
@@ -1695,7 +1695,7 @@
 
 getDiagnostics().Report(ModuleNameLoc, diag::err_module_build_disabled)
 << ModuleName;
-ModuleBuildFailed = true;
+DisableGeneratingGlobalModuleIndex = true;
 return nullptr;
   }
 
@@ -1742,7 +1742,7 @@
 if (*ModuleFile == M->getASTFile())
   return M;
 
-ModuleBuildFailed = true;
+DisableGeneratingGlobalModuleIndex = true;
 getDiagnostics().Report(ModuleNameLoc, diag::err_module_prebuilt)
 << ModuleName;
 return ModuleLoadResult();
@@ -1764,14 +1764,14 @@
 LLVM_FALLTHROUGH;
   case ASTReader::VersionMismatch:
   case ASTReader::HadErrors:
-// FIXME: Should this set ModuleBuildFailed = true?
+// FIXME: Should this set DisableGeneratingGlobalModuleIndex = true?
 ModuleLoader::HadFatalFailure = true;
 // FIXME: The ASTReader will already have complained, but can we shoehorn
 // that diagnostic information into a more useful form?
 return ModuleLoadResult();
 
   case ASTReader::Failure:
-// FIXME: Should this set ModuleBuildFailed = true?
+// FIXME: Should this set DisableGeneratingGlobalModuleIndex = true?
 ModuleLoader::HadFatalFailure = true;
 return ModuleLoadResult();
   }
@@ -1781,7 +1781,7 @@
 // We don't know the desired configuration for this module and don't
 // necessarily even have a module map. Since ReadAST already produces
 // diagnostics for these two cases, we simply error out here.
-ModuleBuildFailed = true;
+DisableGeneratingGlobalModuleIndex = true;
 return ModuleLoadResult();
   }
 
@@ -1806,7 +1806,7 @@
 
 getDiagnostics().Report(ModuleNameLoc, diag::err_module_cycle)
 << ModuleName << CyclePath;
-// FIXME: Should this set ModuleBuildFailed = true?
+// FIXME: Should this set DisableGeneratingGlobalModuleIndex = true?
 return nullptr;
   }
 
@@ -1816,7 +1816,7 @@
   getPreprocessorOpts().FailedModules->hasAlreadyFailed(ModuleName)) {
 getDiagnostics().Report(ModuleNameLoc, diag::err_module_not_built)
 << ModuleName << SourceRange(ImportLoc, ModuleNameLoc);
-ModuleBuildFailed = true;
+DisableGeneratingGlobalModuleIndex = true;
 return nullptr;
   }
 
@@ -1827,7 +1827,7 @@
"undiagnosed error in compileModuleAndReadAST");
 if (getPreprocessorOpts().FailedModules)
   getPreprocessorOpts().FailedModules->addFailed(ModuleName);
-ModuleBuildFailed = true;
+DisableGeneratingGlobalModuleIndex = true;
 return nullptr;
   }
 
@@ -1871,16 +1871,16 @@
 //if (Module == nullptr) {
 //  getDiagnostics().Report(ModuleNameLoc, diag::err_module_not_found)
 //<< ModuleName;
-//  ModuleBuildFailed = true;
+//  DisableGeneratingGlobalModuleIndex = true;
 //  return ModuleLoadResult();
 //}
 MM.cacheModuleLoad(*Path[0].first, Module);
   } else {
 ModuleLoadResult Result = findOrCompileModuleAndReadAST(
 ModuleName, ImportLoc, ModuleNameLoc, IsInclusionDirective);
-// FIXME: Can we pull 'ModuleBuildFailed = true' out of the return
-// sequences for findOrCompileModuleAndReadAST and do it here (as long as
-// the result is not a config mismatch)?  See FIXMEs there.
+// FIXME: Can we pull 'DisableGeneratingGlobalModuleIndex = true' out of
+// the return sequences for findOrCompileModuleAndReadAST and do it here
+// (as long as the result is not a config mismatch)?  See FIXMEs there.
 if (!Result.isNormal())
   return Result;
 Module = Result;
Index: clang/include/clang/Frontend/CompilerInstance.h
=

[PATCH] D102213: [ASTMatchers] Add forCallable(), a generalization of forFunction().

2021-05-13 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ updated this revision to Diff 345208.
NoQ marked 2 inline comments as done.
NoQ added a comment.

Address review comments. Add a deprecation notice to `forFunction()`.


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

https://reviews.llvm.org/D102213

Files:
  clang/docs/LibASTMatchersReference.html
  clang/include/clang/ASTMatchers/ASTMatchers.h
  clang/lib/ASTMatchers/Dynamic/Registry.cpp
  clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp

Index: clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
===
--- clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
+++ clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
@@ -5524,6 +5524,83 @@
   EXPECT_TRUE(notMatches(CppString2, returnStmt(forFunction(hasName("F");
 }
 
+TEST(StatementMatcher, ForCallable) {
+  // These tests are copied over from the forFunction() test above.
+  StringRef CppString1 = "struct PosVec {"
+ "  PosVec& operator=(const PosVec&) {"
+ "auto x = [] { return 1; };"
+ "return *this;"
+ "  }"
+ "};";
+  StringRef CppString2 = "void F() {"
+ "  struct S {"
+ "void F2() {"
+ "   return;"
+ "}"
+ "  };"
+ "}";
+
+  EXPECT_TRUE(
+matches(
+  CppString1,
+  returnStmt(forCallable(functionDecl(hasName("operator="))),
+ has(unaryOperator(hasOperatorName("*"));
+  EXPECT_TRUE(
+notMatches(
+  CppString1,
+  returnStmt(forCallable(functionDecl(hasName("operator="))),
+ has(integerLiteral();
+  EXPECT_TRUE(
+matches(
+  CppString1,
+  returnStmt(forCallable(functionDecl(hasName("operator()"))),
+ has(integerLiteral();
+  EXPECT_TRUE(matches(CppString2,
+  returnStmt(forCallable(functionDecl(hasName("F2"));
+  EXPECT_TRUE(notMatches(CppString2,
+ returnStmt(forCallable(functionDecl(hasName("F"));
+
+  // These tests are specific to forCallable().
+  StringRef ObjCString1 = "@interface I"
+  "-(void) foo;"
+  "@end"
+  "@implementation I"
+  "-(void) foo {"
+  "  void (^block)() = ^{ 0x2b | ~0x2b; };"
+  "}"
+  "@end";
+
+  EXPECT_TRUE(
+matchesObjC(
+  ObjCString1,
+  binaryOperator(forCallable(blockDecl();
+
+  EXPECT_TRUE(
+notMatchesObjC(
+  ObjCString1,
+  binaryOperator(forCallable(objcMethodDecl();
+
+  StringRef ObjCString2 = "@interface I"
+  "-(void) foo;"
+  "@end"
+  "@implementation I"
+  "-(void) foo {"
+  "  0x2b | ~0x2b;"
+  "  void (^block)() = ^{};"
+  "}"
+  "@end";
+
+  EXPECT_TRUE(
+matchesObjC(
+  ObjCString2,
+  binaryOperator(forCallable(objcMethodDecl();
+
+  EXPECT_TRUE(
+notMatchesObjC(
+  ObjCString2,
+  binaryOperator(forCallable(blockDecl();
+}
+
 TEST(Matcher, ForEachOverriden) {
   const auto ForEachOverriddenInClass = [](const char *ClassName) {
 return cxxMethodDecl(ofClass(hasName(ClassName)), isVirtual(),
Index: clang/lib/ASTMatchers/Dynamic/Registry.cpp
===
--- clang/lib/ASTMatchers/Dynamic/Registry.cpp
+++ clang/lib/ASTMatchers/Dynamic/Registry.cpp
@@ -236,6 +236,7 @@
   REGISTER_MATCHER(fieldDecl);
   REGISTER_MATCHER(fixedPointLiteral);
   REGISTER_MATCHER(floatLiteral);
+  REGISTER_MATCHER(forCallable);
   REGISTER_MATCHER(forDecomposition);
   REGISTER_MATCHER(forEach);
   REGISTER_MATCHER(forEachArgumentWithParam);
Index: clang/include/clang/ASTMatchers/ASTMatchers.h
===
--- clang/include/clang/ASTMatchers/ASTMatchers.h
+++ clang/include/clang/ASTMatchers/ASTMatchers.h
@@ -7545,6 +7545,11 @@
 
 /// Matches declaration of the function the statement belongs to.
 ///
+/// Deprecated. Use forCallable() to correctly handle the situation when
+/// the declaration is not a function (but a Block or an Objective-C method).
+/// forFunction() not only fails to take non-functions into account but also
+/// may match the wrong declaration in their presence.
+///
 /// Given:
 /// \code
 /// F& operator=(const F& o) {
@@ -7580,6 +7585,51 @@
   return false;
 }
 
+/// Matches declaration of the function, method, or block the statement
+/// belongs to.
+///
+/// Given:
+/// \code
+/// -(void) foo {
+///   int x = 1;
+///   dispatch_sync(queue, 

[PATCH] D102213: [ASTMatchers] Add forCallable(), a generalization of forFunction().

2021-05-13 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added inline comments.



Comment at: clang/include/clang/ASTMatchers/ASTMatchers.h:7597
+///   but does not match 'int y = 2'.
+AST_MATCHER_P(Stmt, forCallable, internal::Matcher, InnerMatcher) {
+  const auto &Parents = Finder->getASTContext().getParents(Node);

aaron.ballman wrote:
> NoQ wrote:
> > aaron.ballman wrote:
> > > You should also update Registry.cpp to expose this via the dynamic 
> > > matchers.
> > Uh-oh, i knew i was forgetting something!
> > 
> > Do we have a checklist? (Do we want to?)
> I don't think we have a checklist, but the mental checklist I use is:
> 
> * If there's a change to doc comments in ASTMatchers.h, did the HTML file get 
> regenerated?
> * If there's a new matcher added, did Registry.cpp get updated for it?
> * If there are changes to the list in Registry.cpp, is the list still 
> alphabetical?
> * Testcases?
Wait, it's autogenerated? I updated it by hand :D
Fxd.


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

https://reviews.llvm.org/D102213

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


[PATCH] D102213: [ASTMatchers] Add forCallable(), a generalization of forFunction().

2021-05-13 Thread Valeriy Savchenko via Phabricator via cfe-commits
vsavchenko accepted this revision.
vsavchenko added a comment.
This revision is now accepted and ready to land.

OK, I agree with Aaron that having a separate matcher is reasonable.  Thanks 
for the patient explanation :)
LGTM from my side then.


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

https://reviews.llvm.org/D102213

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


[clang] 70aa462 - [NFC][Clang][Codegen] Add tests with wrong attributes on this/return of thunks

2021-05-13 Thread Roman Lebedev via cfe-commits

Author: Roman Lebedev
Date: 2021-05-13T20:32:40+03:00
New Revision: 70aa4623de9fe2f609eab8969d7ef76b4c80084b

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

LOG: [NFC][Clang][Codegen] Add tests with wrong attributes on this/return of 
thunks

>From https://reviews.llvm.org/D100388

Added: 
clang/test/CodeGenCXX/thunk-wrong-return-type.cpp
clang/test/CodeGenCXX/thunk-wrong-this.cpp

Modified: 


Removed: 




diff  --git a/clang/test/CodeGenCXX/thunk-wrong-return-type.cpp 
b/clang/test/CodeGenCXX/thunk-wrong-return-type.cpp
new file mode 100644
index 0..f6d662c8cb7a9
--- /dev/null
+++ b/clang/test/CodeGenCXX/thunk-wrong-return-type.cpp
@@ -0,0 +1,26 @@
+// RUN: %clang_cc1 -emit-llvm-only -triple %itanium_abi_triple %s -emit-llvm 
-o - %s | FileCheck %s
+
+struct A {};
+struct alignas(32) B : virtual A {
+  char c[32];
+};
+struct Pad {
+  char c[7];
+};
+struct C : B, Pad, virtual A {};
+
+struct X {
+  virtual A &f();
+};
+struct U {
+  virtual ~U();
+};
+C c;
+struct Y : U, X {
+  virtual B &f() override { return c; }
+};
+
+Y y;
+
+// FIXME: The return type should be  align 1 dereferenceable(1) %struct.A.8*
+// CHECK: define linkonce_odr nonnull align 32 dereferenceable(40) 
%struct.B.1* @_ZTchn8_v0_n24_N1Y1fEv(%struct.Y.5* nonnull dereferenceable(16) 
%this) unnamed_addr #1 comdat align 2 {

diff  --git a/clang/test/CodeGenCXX/thunk-wrong-this.cpp 
b/clang/test/CodeGenCXX/thunk-wrong-this.cpp
new file mode 100644
index 0..664163a3b9da5
--- /dev/null
+++ b/clang/test/CodeGenCXX/thunk-wrong-this.cpp
@@ -0,0 +1,25 @@
+// RUN: %clang_cc1 -emit-llvm-only -triple %itanium_abi_triple %s -emit-llvm 
-o - %s | FileCheck %s
+
+class Base1 {
+  virtual void Foo1();
+};
+
+class Base2 {
+  virtual void Foo2();
+};
+
+class alignas(16) Obj : public Base1, public Base2 {
+  void Foo1() override;
+  void Foo2() override;
+  ~Obj();
+};
+
+void Obj::Foo1() {}
+void Obj::Foo2() {}
+
+// CHECK: define dso_local void @_ZN3Obj4Foo2Ev(%class.Obj.0* nonnull 
dereferenceable(16) %this) unnamed_addr #0 align 2 {
+
+// FIXME: the argument should be  %class.Base2.2* nonnull dereferenceable(8) 
%this
+// CHECK: define dso_local void @_ZThn8_N3Obj4Foo2Ev(%class.Obj.0* nonnull 
dereferenceable(16) %this) unnamed_addr #1 align 2 {
+
+// CHECK: tail call void @_ZN3Obj4Foo2Ev(%class.Obj.0* nonnull 
dereferenceable(16) %2)



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


[clang] a624cec - [Clang][Codegen] Do not annotate thunk's this/return types with align/deref/nonnull attrs

2021-05-13 Thread Roman Lebedev via cfe-commits

Author: Roman Lebedev
Date: 2021-05-13T20:33:08+03:00
New Revision: a624cec56d4bf61c1f3cb7daf2d27dac59c56fa4

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

LOG: [Clang][Codegen] Do not annotate thunk's this/return types with 
align/deref/nonnull attrs

As it was discovered in post-commit feedback
for 0aa0458f1429372038ca6a4edc7e94c96cd9a753,
we handle thunks incorrectly, and end up annotating
their this/return with attributes that are valid
for their callees, not for thunks themselves.

While it would be good to fix this properly,
and keep annotating them on thunks,
i've tried doing that in https://reviews.llvm.org/D100388
with little success, and the patch is stuck for a month now.

So for now, as a stopgap measure, subj.

Added: 


Modified: 
clang/lib/CodeGen/CGBlocks.cpp
clang/lib/CodeGen/CGBuiltin.cpp
clang/lib/CodeGen/CGCall.cpp
clang/lib/CodeGen/CGExpr.cpp
clang/lib/CodeGen/CGNonTrivialStruct.cpp
clang/lib/CodeGen/CGObjC.cpp
clang/lib/CodeGen/CGVTables.cpp
clang/lib/CodeGen/CodeGenModule.cpp
clang/lib/CodeGen/CodeGenModule.h
clang/lib/CodeGen/ItaniumCXXABI.cpp
clang/lib/CodeGen/MicrosoftCXXABI.cpp
clang/test/CodeGenCXX/constructor-destructor-return-this.cpp
clang/test/CodeGenCXX/microsoft-abi-byval-thunks.cpp
clang/test/CodeGenCXX/microsoft-abi-structors.cpp
clang/test/CodeGenCXX/microsoft-abi-thunks.cpp
clang/test/CodeGenCXX/thunk-returning-memptr.cpp
clang/test/CodeGenCXX/thunk-wrong-return-type.cpp
clang/test/CodeGenCXX/thunk-wrong-this.cpp
clang/test/CodeGenCXX/thunks-ehspec.cpp
clang/test/CodeGenCXX/thunks.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/CGBlocks.cpp b/clang/lib/CodeGen/CGBlocks.cpp
index 5ecd88e7a14c9..cc9be87961e7d 100644
--- a/clang/lib/CodeGen/CGBlocks.cpp
+++ b/clang/lib/CodeGen/CGBlocks.cpp
@@ -1902,7 +1902,7 @@ static void setBlockHelperAttributesVisibility(bool 
CapturesNonExternalType,
   } else {
 Fn->setVisibility(llvm::GlobalValue::HiddenVisibility);
 Fn->setUnnamedAddr(llvm::GlobalValue::UnnamedAddr::Global);
-CGM.SetLLVMFunctionAttributes(GlobalDecl(), FI, Fn);
+CGM.SetLLVMFunctionAttributes(GlobalDecl(), FI, Fn, /*IsThunk=*/false);
 CGM.SetLLVMFunctionAttributesForDefinition(nullptr, Fn);
   }
 }

diff  --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp
index 1c56089974d35..147b4c90d8d32 100644
--- a/clang/lib/CodeGen/CGBuiltin.cpp
+++ b/clang/lib/CodeGen/CGBuiltin.cpp
@@ -1692,7 +1692,7 @@ llvm::Function 
*CodeGenFunction::generateBuiltinOSLogHelperFunction(
   llvm::Function *Fn = llvm::Function::Create(
   FuncTy, llvm::GlobalValue::LinkOnceODRLinkage, Name, &CGM.getModule());
   Fn->setVisibility(llvm::GlobalValue::HiddenVisibility);
-  CGM.SetLLVMFunctionAttributes(GlobalDecl(), FI, Fn);
+  CGM.SetLLVMFunctionAttributes(GlobalDecl(), FI, Fn, /*IsThunk=*/false);
   CGM.SetLLVMFunctionAttributesForDefinition(nullptr, Fn);
   Fn->setDoesNotThrow();
 

diff  --git a/clang/lib/CodeGen/CGCall.cpp b/clang/lib/CodeGen/CGCall.cpp
index 6c77f1889fb52..946772fc9c1e4 100644
--- a/clang/lib/CodeGen/CGCall.cpp
+++ b/clang/lib/CodeGen/CGCall.cpp
@@ -1982,9 +1982,12 @@ static bool DetermineNoUndef(QualType QTy, CodeGenTypes 
&Types,
 /// attributes that restrict how the frontend generates code must be
 /// added here rather than getDefaultFunctionAttributes.
 ///
-void CodeGenModule::ConstructAttributeList(
-StringRef Name, const CGFunctionInfo &FI, CGCalleeInfo CalleeInfo,
-llvm::AttributeList &AttrList, unsigned &CallingConv, bool AttrOnCallSite) 
{
+void CodeGenModule::ConstructAttributeList(StringRef Name,
+   const CGFunctionInfo &FI,
+   CGCalleeInfo CalleeInfo,
+   llvm::AttributeList &AttrList,
+   unsigned &CallingConv,
+   bool AttrOnCallSite, bool IsThunk) {
   llvm::AttrBuilder FuncAttrs;
   llvm::AttrBuilder RetAttrs;
 
@@ -2275,18 +2278,21 @@ void CodeGenModule::ConstructAttributeList(
 llvm_unreachable("Invalid ABI kind for return argument");
   }
 
-  if (const auto *RefTy = RetTy->getAs()) {
-QualType PTy = RefTy->getPointeeType();
-if (!PTy->isIncompleteType() && PTy->isConstantSizeType())
-  RetAttrs.addDereferenceableAttr(
-  getMinimumObjectSize(PTy).getQuantity());
-if (getContext().getTargetAddressSpace(PTy) == 0 &&
-!CodeGenOpts.NullPointerIsValid)
-  RetAttrs.addAttribute(llvm::Attribute::NonNull);
-if (PTy->isObjectType()) {
-  llvm::Align Alignment =
-  getNaturalPointeeTypeAlignment(RetTy).getAsAlign();
-  RetAttrs.addAli

[PATCH] D102288: [HWASan] Add -fsanitize=lam flag and enable HWASan to use it.

2021-05-13 Thread Matt Morehouse via Phabricator via cfe-commits
morehouse updated this revision to Diff 345210.
morehouse marked 4 inline comments as done.
morehouse added a comment.
Herald added a subscriber: dang.

- Use -mlam option instead of -fsanitize=lam.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D102288

Files:
  clang/include/clang/Driver/Options.td
  clang/include/clang/Driver/SanitizerArgs.h
  clang/lib/Driver/SanitizerArgs.cpp
  clang/lib/Driver/ToolChains/CommonArgs.cpp
  compiler-rt/test/hwasan/CMakeLists.txt
  compiler-rt/test/hwasan/TestCases/Linux/vfork.c
  compiler-rt/test/hwasan/lit.cfg.py
  compiler-rt/test/hwasan/lit.site.cfg.py.in

Index: compiler-rt/test/hwasan/lit.site.cfg.py.in
===
--- compiler-rt/test/hwasan/lit.site.cfg.py.in
+++ compiler-rt/test/hwasan/lit.site.cfg.py.in
@@ -6,6 +6,9 @@
 config.target_arch = "@HWASAN_TEST_TARGET_ARCH@"
 config.android_files_to_push = @HWASAN_ANDROID_FILES_TO_PUSH@
 
+# Whether to use -mlam or not.
+config.enable_lam = lit_config.params.get("ENABLE_LAM", "@ENABLE_LAM@")
+
 # Load common config for all compiler-rt lit tests.
 lit_config.load_config(config, "@COMPILER_RT_BINARY_DIR@/test/lit.common.configured")
 
Index: compiler-rt/test/hwasan/lit.cfg.py
===
--- compiler-rt/test/hwasan/lit.cfg.py
+++ compiler-rt/test/hwasan/lit.cfg.py
@@ -12,6 +12,11 @@
 clang_cflags = [config.target_cflags] + config.debug_info_flags
 clang_cxxflags = config.cxx_mode_flags + clang_cflags
 clang_hwasan_common_cflags = clang_cflags + ["-fsanitize=hwaddress", "-fuse-ld=lld"]
+
+if config.enable_lam == '1':
+  clang_hwasan_common_cflags += ["-mlam"]
+if config.target_arch != 'x86_64' or config.enable_lam == '1':
+  config.available_features.add('pointer-tagging')
 if config.target_arch == 'x86_64':
   # This does basically the same thing as tagged-globals on aarch64. Because
   # the x86_64 implementation is for testing purposes only there is no
Index: compiler-rt/test/hwasan/TestCases/Linux/vfork.c
===
--- compiler-rt/test/hwasan/TestCases/Linux/vfork.c
+++ compiler-rt/test/hwasan/TestCases/Linux/vfork.c
@@ -2,9 +2,7 @@
 // RUN: %clang_hwasan -O0 %s -o %t && %run %t 2>&1
 
 // REQUIRES: aarch64-target-arch || x86_64-target-arch
-
-// Aliasing mode does not support stack tagging.
-// XFAIL: x86_64
+// REQUIRES: pointer-tagging
 
 #include 
 #include 
Index: compiler-rt/test/hwasan/CMakeLists.txt
===
--- compiler-rt/test/hwasan/CMakeLists.txt
+++ compiler-rt/test/hwasan/CMakeLists.txt
@@ -33,5 +33,15 @@
 add_lit_testsuite(check-hwasan "Running the HWAddressSanitizer tests"
   ${HWASAN_TESTSUITES}
   DEPENDS ${HWASAN_TEST_DEPS}
+  PARAMS "ENABLE_LAM=0"
   )
 set_target_properties(check-hwasan PROPERTIES FOLDER "Compiler-RT Misc")
+
+add_lit_testsuite(check-hwasan-lam
+  "Running the HWAddressSanitizer tests with Intel LAM"
+  ${HWASAN_TESTSUITES}
+  DEPENDS ${HWASAN_TEST_DEPS}
+  PARAMS "ENABLE_LAM=1"
+  EXCLUDE_FROM_CHECK_ALL
+  )
+set_target_properties(check-hwasan-lam PROPERTIES FOLDER "Compiler-RT Misc")
Index: clang/lib/Driver/ToolChains/CommonArgs.cpp
===
--- clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -816,8 +816,12 @@
 }
 if (SanArgs.needsTsanRt() && SanArgs.linkRuntimes())
   SharedRuntimes.push_back("tsan");
-if (SanArgs.needsHwasanRt() && SanArgs.linkRuntimes())
-  SharedRuntimes.push_back("hwasan");
+if (SanArgs.needsHwasanRt() && SanArgs.linkRuntimes()) {
+  if (SanArgs.needsHwasanLamRt())
+SharedRuntimes.push_back("hwasan_lam");
+  else
+SharedRuntimes.push_back("hwasan");
+}
   }
 
   // The stats_client library is also statically linked into DSOs.
@@ -847,9 +851,15 @@
   }
 
   if (!SanArgs.needsSharedRt() && SanArgs.needsHwasanRt() && SanArgs.linkRuntimes()) {
-StaticRuntimes.push_back("hwasan");
-if (SanArgs.linkCXXRuntimes())
-  StaticRuntimes.push_back("hwasan_cxx");
+if (SanArgs.needsHwasanLamRt()) {
+  StaticRuntimes.push_back("hwasan_lam");
+  if (SanArgs.linkCXXRuntimes())
+StaticRuntimes.push_back("hwasan_lam_cxx");
+} else {
+  StaticRuntimes.push_back("hwasan");
+  if (SanArgs.linkCXXRuntimes())
+StaticRuntimes.push_back("hwasan_cxx");
+}
   }
   if (SanArgs.needsDfsanRt() && SanArgs.linkRuntimes())
 StaticRuntimes.push_back("dfsan");
Index: clang/lib/Driver/SanitizerArgs.cpp
===
--- clang/lib/Driver/SanitizerArgs.cpp
+++ clang/lib/Driver/SanitizerArgs.cpp
@@ -865,6 +865,8 @@
 } else {
   HwasanAbi = "interceptor";
 }
+if (TC.getTriple().getArch() == llvm::Triple::x86

[PATCH] D99790: [CGCall] Annotate `this` argument with alignment

2021-05-13 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri abandoned this revision.
lebedev.ri added a comment.

Oh, i forgot that this review was here.

I've just relanded this in rG16d03818412415c56efcd482d18c0cbdf712524c 
,
after workarounding the thunk issue in 
rGa624cec56d4bf61c1f3cb7daf2d27dac59c56fa4 
.

It would be good to fix it properly via D100388 
, but well,
a month with little progress..


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99790

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


[clang] 7c57a9b - Modules: Simplify how DisableGeneratingGlobalModuleIndex is set, likely NFC

2021-05-13 Thread Duncan P. N. Exon Smith via cfe-commits

Author: Duncan P. N. Exon Smith
Date: 2021-05-13T10:39:40-07:00
New Revision: 7c57a9bd7d4c976b7a824472c427433359200e02

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

LOG: Modules: Simplify how DisableGeneratingGlobalModuleIndex is set, likely NFC

DisableGeneratingGlobalModuleIndex was being set by
CompilerInstance::findOrCompileModuleAndReadAST most of (but not all of)
the times it returned `nullptr` as a "normal" failure. Pull that up to
the caller, CompilerInstance::loadModule, to simplify the code. This
resolves a number of FIXMEs added during the refactoring in
5cca622310c10fdf6f921b6cce26f91d9f14c762.

The extra cases where this is set are all some version of a fatal error,
and the only client of the field, shouldBuildGlobalModuleIndex, seems
to be unreachable in that case. Even if there is some corner case where
this has an effect, it seems like the right/consistent behaviour.

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

Added: 


Modified: 
clang/lib/Frontend/CompilerInstance.cpp

Removed: 




diff  --git a/clang/lib/Frontend/CompilerInstance.cpp 
b/clang/lib/Frontend/CompilerInstance.cpp
index 54917b3fb0fb..a623580bac7f 100644
--- a/clang/lib/Frontend/CompilerInstance.cpp
+++ b/clang/lib/Frontend/CompilerInstance.cpp
@@ -1683,7 +1683,6 @@ ModuleLoadResult 
CompilerInstance::findOrCompileModuleAndReadAST(
 // We can't find a module, error out here.
 getDiagnostics().Report(ModuleNameLoc, diag::err_module_not_found)
 << ModuleName << SourceRange(ImportLoc, ModuleNameLoc);
-DisableGeneratingGlobalModuleIndex = true;
 return nullptr;
   }
   if (ModuleFilename.empty()) {
@@ -1695,7 +1694,6 @@ ModuleLoadResult 
CompilerInstance::findOrCompileModuleAndReadAST(
 
 getDiagnostics().Report(ModuleNameLoc, diag::err_module_build_disabled)
 << ModuleName;
-DisableGeneratingGlobalModuleIndex = true;
 return nullptr;
   }
 
@@ -1742,7 +1740,6 @@ ModuleLoadResult 
CompilerInstance::findOrCompileModuleAndReadAST(
 if (*ModuleFile == M->getASTFile())
   return M;
 
-DisableGeneratingGlobalModuleIndex = true;
 getDiagnostics().Report(ModuleNameLoc, diag::err_module_prebuilt)
 << ModuleName;
 return ModuleLoadResult();
@@ -1764,14 +1761,12 @@ ModuleLoadResult 
CompilerInstance::findOrCompileModuleAndReadAST(
 LLVM_FALLTHROUGH;
   case ASTReader::VersionMismatch:
   case ASTReader::HadErrors:
-// FIXME: Should this set DisableGeneratingGlobalModuleIndex = true?
 ModuleLoader::HadFatalFailure = true;
 // FIXME: The ASTReader will already have complained, but can we shoehorn
 // that diagnostic information into a more useful form?
 return ModuleLoadResult();
 
   case ASTReader::Failure:
-// FIXME: Should this set DisableGeneratingGlobalModuleIndex = true?
 ModuleLoader::HadFatalFailure = true;
 return ModuleLoadResult();
   }
@@ -1781,7 +1776,6 @@ ModuleLoadResult 
CompilerInstance::findOrCompileModuleAndReadAST(
 // We don't know the desired configuration for this module and don't
 // necessarily even have a module map. Since ReadAST already produces
 // diagnostics for these two cases, we simply error out here.
-DisableGeneratingGlobalModuleIndex = true;
 return ModuleLoadResult();
   }
 
@@ -1806,7 +1800,6 @@ ModuleLoadResult 
CompilerInstance::findOrCompileModuleAndReadAST(
 
 getDiagnostics().Report(ModuleNameLoc, diag::err_module_cycle)
 << ModuleName << CyclePath;
-// FIXME: Should this set DisableGeneratingGlobalModuleIndex = true?
 return nullptr;
   }
 
@@ -1816,7 +1809,6 @@ ModuleLoadResult 
CompilerInstance::findOrCompileModuleAndReadAST(
   getPreprocessorOpts().FailedModules->hasAlreadyFailed(ModuleName)) {
 getDiagnostics().Report(ModuleNameLoc, diag::err_module_not_built)
 << ModuleName << SourceRange(ImportLoc, ModuleNameLoc);
-DisableGeneratingGlobalModuleIndex = true;
 return nullptr;
   }
 
@@ -1827,7 +1819,6 @@ ModuleLoadResult 
CompilerInstance::findOrCompileModuleAndReadAST(
"undiagnosed error in compileModuleAndReadAST");
 if (getPreprocessorOpts().FailedModules)
   getPreprocessorOpts().FailedModules->addFailed(ModuleName);
-DisableGeneratingGlobalModuleIndex = true;
 return nullptr;
   }
 
@@ -1878,11 +1869,10 @@ CompilerInstance::loadModule(SourceLocation ImportLoc,
   } else {
 ModuleLoadResult Result = findOrCompileModuleAndReadAST(
 ModuleName, ImportLoc, ModuleNameLoc, IsInclusionDirective);
-// FIXME: Can we pull 'DisableGeneratingGlobalModuleIndex = true' out of
-// the return sequences for findOrCompileModuleAndReadAST and do it here
-// (as long as the result is not a config mismatch)?  See FIXMEs there.
 i

[PATCH] D101672: Modules: Simplify how DisableGeneratingGlobalModuleIndex is set, likely NFC

2021-05-13 Thread Duncan P. N. Exon Smith 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 rG7c57a9bd7d4c: Modules: Simplify how 
DisableGeneratingGlobalModuleIndex is set, likely NFC (authored by dexonsmith).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101672

Files:
  clang/lib/Frontend/CompilerInstance.cpp


Index: clang/lib/Frontend/CompilerInstance.cpp
===
--- clang/lib/Frontend/CompilerInstance.cpp
+++ clang/lib/Frontend/CompilerInstance.cpp
@@ -1683,7 +1683,6 @@
 // We can't find a module, error out here.
 getDiagnostics().Report(ModuleNameLoc, diag::err_module_not_found)
 << ModuleName << SourceRange(ImportLoc, ModuleNameLoc);
-DisableGeneratingGlobalModuleIndex = true;
 return nullptr;
   }
   if (ModuleFilename.empty()) {
@@ -1695,7 +1694,6 @@
 
 getDiagnostics().Report(ModuleNameLoc, diag::err_module_build_disabled)
 << ModuleName;
-DisableGeneratingGlobalModuleIndex = true;
 return nullptr;
   }
 
@@ -1742,7 +1740,6 @@
 if (*ModuleFile == M->getASTFile())
   return M;
 
-DisableGeneratingGlobalModuleIndex = true;
 getDiagnostics().Report(ModuleNameLoc, diag::err_module_prebuilt)
 << ModuleName;
 return ModuleLoadResult();
@@ -1764,14 +1761,12 @@
 LLVM_FALLTHROUGH;
   case ASTReader::VersionMismatch:
   case ASTReader::HadErrors:
-// FIXME: Should this set DisableGeneratingGlobalModuleIndex = true?
 ModuleLoader::HadFatalFailure = true;
 // FIXME: The ASTReader will already have complained, but can we shoehorn
 // that diagnostic information into a more useful form?
 return ModuleLoadResult();
 
   case ASTReader::Failure:
-// FIXME: Should this set DisableGeneratingGlobalModuleIndex = true?
 ModuleLoader::HadFatalFailure = true;
 return ModuleLoadResult();
   }
@@ -1781,7 +1776,6 @@
 // We don't know the desired configuration for this module and don't
 // necessarily even have a module map. Since ReadAST already produces
 // diagnostics for these two cases, we simply error out here.
-DisableGeneratingGlobalModuleIndex = true;
 return ModuleLoadResult();
   }
 
@@ -1806,7 +1800,6 @@
 
 getDiagnostics().Report(ModuleNameLoc, diag::err_module_cycle)
 << ModuleName << CyclePath;
-// FIXME: Should this set DisableGeneratingGlobalModuleIndex = true?
 return nullptr;
   }
 
@@ -1816,7 +1809,6 @@
   getPreprocessorOpts().FailedModules->hasAlreadyFailed(ModuleName)) {
 getDiagnostics().Report(ModuleNameLoc, diag::err_module_not_built)
 << ModuleName << SourceRange(ImportLoc, ModuleNameLoc);
-DisableGeneratingGlobalModuleIndex = true;
 return nullptr;
   }
 
@@ -1827,7 +1819,6 @@
"undiagnosed error in compileModuleAndReadAST");
 if (getPreprocessorOpts().FailedModules)
   getPreprocessorOpts().FailedModules->addFailed(ModuleName);
-DisableGeneratingGlobalModuleIndex = true;
 return nullptr;
   }
 
@@ -1878,11 +1869,10 @@
   } else {
 ModuleLoadResult Result = findOrCompileModuleAndReadAST(
 ModuleName, ImportLoc, ModuleNameLoc, IsInclusionDirective);
-// FIXME: Can we pull 'DisableGeneratingGlobalModuleIndex = true' out of
-// the return sequences for findOrCompileModuleAndReadAST and do it here
-// (as long as the result is not a config mismatch)?  See FIXMEs there.
 if (!Result.isNormal())
   return Result;
+if (!Result)
+  DisableGeneratingGlobalModuleIndex = true;
 Module = Result;
 MM.cacheModuleLoad(*Path[0].first, Module);
   }


Index: clang/lib/Frontend/CompilerInstance.cpp
===
--- clang/lib/Frontend/CompilerInstance.cpp
+++ clang/lib/Frontend/CompilerInstance.cpp
@@ -1683,7 +1683,6 @@
 // We can't find a module, error out here.
 getDiagnostics().Report(ModuleNameLoc, diag::err_module_not_found)
 << ModuleName << SourceRange(ImportLoc, ModuleNameLoc);
-DisableGeneratingGlobalModuleIndex = true;
 return nullptr;
   }
   if (ModuleFilename.empty()) {
@@ -1695,7 +1694,6 @@
 
 getDiagnostics().Report(ModuleNameLoc, diag::err_module_build_disabled)
 << ModuleName;
-DisableGeneratingGlobalModuleIndex = true;
 return nullptr;
   }
 
@@ -1742,7 +1740,6 @@
 if (*ModuleFile == M->getASTFile())
   return M;
 
-DisableGeneratingGlobalModuleIndex = true;
 getDiagnostics().Report(ModuleNameLoc, diag::err_module_prebuilt)
 << ModuleName;
 return ModuleLoadResult();
@@ -1764,14 +1761,12 @@
 LLVM_FALLTHROUGH;
   case ASTReader::VersionMismatch:
   case ASTReader::HadErrors:
-// FIXME: Should this set DisableGeneratingGlobalModuleIndex = true?
 ModuleLoader::HadFatalFailure = true;
 // FIXME: The AST

[PATCH] D102214: [clang-tidy] bugprone-infinite-loop: forFunction() -> forCallable().

2021-05-13 Thread Valeriy Savchenko via Phabricator via cfe-commits
vsavchenko accepted this revision.
vsavchenko added a comment.
This revision is now accepted and ready to land.

Now, when we are done with `forCallable`, let's get to this one.
It looks great to me, thanks for fixing it!


Repository:
  rCTE Clang Tools Extra

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

https://reviews.llvm.org/D102214

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


[PATCH] D102213: [ASTMatchers] Add forCallable(), a generalization of forFunction().

2021-05-13 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman accepted this revision.
aaron.ballman added a comment.

LGTM, thank you!


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

https://reviews.llvm.org/D102213

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


[PATCH] D100991: Fix parsing of vector keyword in presence of conflicting uses.

2021-05-13 Thread Zarko Todorovski via Phabricator via cfe-commits
ZarkoCA added inline comments.



Comment at: clang/test/Parser/altivec-non-type-vector.c:1
+// RUN: %clang_cc1 -triple powerpc64-unknown-aix-xcoff -target-feature 
+altivec -fsyntax-only %s
+

Can you add tests for 64bit BE/LE linux and 32bit AIX/BE linux in this the 
subsequent test cases? 


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

https://reviews.llvm.org/D100991

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


[PATCH] D102240: [analyzer][solver] Prevent use of a null state

2021-05-13 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added a comment.

Thx for the fix!

In D102240#2757223 , @steakhal wrote:

> In D102240#2756967 , @vsavchenko 
> wrote:
>
>> I couldn't transform `c == b` into a condition, so it crashes.
>
> Well, that's interesting. It might worth investigating. @NoQ ?
> Regardless, it's an improvement, let's land it :D

At a glance it looks like this has something to do with liveness. When `c == b` 
is surrounded by an if-statement, the CFG starts having more blocks and live 
variables analysis becomes more fine-grained and constraints for 'b' get 
cleaned up more quickly. Which is bad because this means that we're cleaning up 
constraints that are still useful.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D102240

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


[PATCH] D95745: Support unwinding from inline assembly

2021-05-13 Thread Paul via Phabricator via cfe-commits
cynecx added a comment.

I would be great if someone with commit rights could push this through since I 
don't have commit rights :)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95745

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


[PATCH] D102213: [ASTMatchers] Add forCallable(), a generalization of forFunction().

2021-05-13 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ updated this revision to Diff 345220.
NoQ added a comment.

Make examples for `forCallable()` more relatable given that the original 
matcher is now deprecated.


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

https://reviews.llvm.org/D102213

Files:
  clang/docs/LibASTMatchersReference.html
  clang/include/clang/ASTMatchers/ASTMatchers.h
  clang/lib/ASTMatchers/Dynamic/Registry.cpp
  clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp

Index: clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
===
--- clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
+++ clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
@@ -5524,6 +5524,83 @@
   EXPECT_TRUE(notMatches(CppString2, returnStmt(forFunction(hasName("F");
 }
 
+TEST(StatementMatcher, ForCallable) {
+  // These tests are copied over from the forFunction() test above.
+  StringRef CppString1 = "struct PosVec {"
+ "  PosVec& operator=(const PosVec&) {"
+ "auto x = [] { return 1; };"
+ "return *this;"
+ "  }"
+ "};";
+  StringRef CppString2 = "void F() {"
+ "  struct S {"
+ "void F2() {"
+ "   return;"
+ "}"
+ "  };"
+ "}";
+
+  EXPECT_TRUE(
+matches(
+  CppString1,
+  returnStmt(forCallable(functionDecl(hasName("operator="))),
+ has(unaryOperator(hasOperatorName("*"));
+  EXPECT_TRUE(
+notMatches(
+  CppString1,
+  returnStmt(forCallable(functionDecl(hasName("operator="))),
+ has(integerLiteral();
+  EXPECT_TRUE(
+matches(
+  CppString1,
+  returnStmt(forCallable(functionDecl(hasName("operator()"))),
+ has(integerLiteral();
+  EXPECT_TRUE(matches(CppString2,
+  returnStmt(forCallable(functionDecl(hasName("F2"));
+  EXPECT_TRUE(notMatches(CppString2,
+ returnStmt(forCallable(functionDecl(hasName("F"));
+
+  // These tests are specific to forCallable().
+  StringRef ObjCString1 = "@interface I"
+  "-(void) foo;"
+  "@end"
+  "@implementation I"
+  "-(void) foo {"
+  "  void (^block)() = ^{ 0x2b | ~0x2b; };"
+  "}"
+  "@end";
+
+  EXPECT_TRUE(
+matchesObjC(
+  ObjCString1,
+  binaryOperator(forCallable(blockDecl();
+
+  EXPECT_TRUE(
+notMatchesObjC(
+  ObjCString1,
+  binaryOperator(forCallable(objcMethodDecl();
+
+  StringRef ObjCString2 = "@interface I"
+  "-(void) foo;"
+  "@end"
+  "@implementation I"
+  "-(void) foo {"
+  "  0x2b | ~0x2b;"
+  "  void (^block)() = ^{};"
+  "}"
+  "@end";
+
+  EXPECT_TRUE(
+matchesObjC(
+  ObjCString2,
+  binaryOperator(forCallable(objcMethodDecl();
+
+  EXPECT_TRUE(
+notMatchesObjC(
+  ObjCString2,
+  binaryOperator(forCallable(blockDecl();
+}
+
 TEST(Matcher, ForEachOverriden) {
   const auto ForEachOverriddenInClass = [](const char *ClassName) {
 return cxxMethodDecl(ofClass(hasName(ClassName)), isVirtual(),
Index: clang/lib/ASTMatchers/Dynamic/Registry.cpp
===
--- clang/lib/ASTMatchers/Dynamic/Registry.cpp
+++ clang/lib/ASTMatchers/Dynamic/Registry.cpp
@@ -236,6 +236,7 @@
   REGISTER_MATCHER(fieldDecl);
   REGISTER_MATCHER(fixedPointLiteral);
   REGISTER_MATCHER(floatLiteral);
+  REGISTER_MATCHER(forCallable);
   REGISTER_MATCHER(forDecomposition);
   REGISTER_MATCHER(forEach);
   REGISTER_MATCHER(forEachArgumentWithParam);
Index: clang/include/clang/ASTMatchers/ASTMatchers.h
===
--- clang/include/clang/ASTMatchers/ASTMatchers.h
+++ clang/include/clang/ASTMatchers/ASTMatchers.h
@@ -7545,6 +7545,11 @@
 
 /// Matches declaration of the function the statement belongs to.
 ///
+/// Deprecated. Use forCallable() to correctly handle the situation when
+/// the declaration is not a function (but a block or an Objective-C method).
+/// forFunction() not only fails to take non-functions into account but also
+/// may match the wrong declaration in their presence.
+///
 /// Given:
 /// \code
 /// F& operator=(const F& o) {
@@ -7580,6 +7585,65 @@
   return false;
 }
 
+/// Matches declaration of the function, method, or block the statement
+/// belongs to.
+///
+/// Given:
+/// \code
+/// F& operator=(const F& o) {
+///   std::copy_if(o.begin(), o.end(), 

[PATCH] D102213: [ASTMatchers] Add forCallable(), a generalization of forFunction().

2021-05-13 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ updated this revision to Diff 345221.
NoQ added a comment.

Fix typo in documentation.


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

https://reviews.llvm.org/D102213

Files:
  clang/docs/LibASTMatchersReference.html
  clang/include/clang/ASTMatchers/ASTMatchers.h
  clang/lib/ASTMatchers/Dynamic/Registry.cpp
  clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp

Index: clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
===
--- clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
+++ clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
@@ -5524,6 +5524,83 @@
   EXPECT_TRUE(notMatches(CppString2, returnStmt(forFunction(hasName("F");
 }
 
+TEST(StatementMatcher, ForCallable) {
+  // These tests are copied over from the forFunction() test above.
+  StringRef CppString1 = "struct PosVec {"
+ "  PosVec& operator=(const PosVec&) {"
+ "auto x = [] { return 1; };"
+ "return *this;"
+ "  }"
+ "};";
+  StringRef CppString2 = "void F() {"
+ "  struct S {"
+ "void F2() {"
+ "   return;"
+ "}"
+ "  };"
+ "}";
+
+  EXPECT_TRUE(
+matches(
+  CppString1,
+  returnStmt(forCallable(functionDecl(hasName("operator="))),
+ has(unaryOperator(hasOperatorName("*"));
+  EXPECT_TRUE(
+notMatches(
+  CppString1,
+  returnStmt(forCallable(functionDecl(hasName("operator="))),
+ has(integerLiteral();
+  EXPECT_TRUE(
+matches(
+  CppString1,
+  returnStmt(forCallable(functionDecl(hasName("operator()"))),
+ has(integerLiteral();
+  EXPECT_TRUE(matches(CppString2,
+  returnStmt(forCallable(functionDecl(hasName("F2"));
+  EXPECT_TRUE(notMatches(CppString2,
+ returnStmt(forCallable(functionDecl(hasName("F"));
+
+  // These tests are specific to forCallable().
+  StringRef ObjCString1 = "@interface I"
+  "-(void) foo;"
+  "@end"
+  "@implementation I"
+  "-(void) foo {"
+  "  void (^block)() = ^{ 0x2b | ~0x2b; };"
+  "}"
+  "@end";
+
+  EXPECT_TRUE(
+matchesObjC(
+  ObjCString1,
+  binaryOperator(forCallable(blockDecl();
+
+  EXPECT_TRUE(
+notMatchesObjC(
+  ObjCString1,
+  binaryOperator(forCallable(objcMethodDecl();
+
+  StringRef ObjCString2 = "@interface I"
+  "-(void) foo;"
+  "@end"
+  "@implementation I"
+  "-(void) foo {"
+  "  0x2b | ~0x2b;"
+  "  void (^block)() = ^{};"
+  "}"
+  "@end";
+
+  EXPECT_TRUE(
+matchesObjC(
+  ObjCString2,
+  binaryOperator(forCallable(objcMethodDecl();
+
+  EXPECT_TRUE(
+notMatchesObjC(
+  ObjCString2,
+  binaryOperator(forCallable(blockDecl();
+}
+
 TEST(Matcher, ForEachOverriden) {
   const auto ForEachOverriddenInClass = [](const char *ClassName) {
 return cxxMethodDecl(ofClass(hasName(ClassName)), isVirtual(),
Index: clang/lib/ASTMatchers/Dynamic/Registry.cpp
===
--- clang/lib/ASTMatchers/Dynamic/Registry.cpp
+++ clang/lib/ASTMatchers/Dynamic/Registry.cpp
@@ -236,6 +236,7 @@
   REGISTER_MATCHER(fieldDecl);
   REGISTER_MATCHER(fixedPointLiteral);
   REGISTER_MATCHER(floatLiteral);
+  REGISTER_MATCHER(forCallable);
   REGISTER_MATCHER(forDecomposition);
   REGISTER_MATCHER(forEach);
   REGISTER_MATCHER(forEachArgumentWithParam);
Index: clang/include/clang/ASTMatchers/ASTMatchers.h
===
--- clang/include/clang/ASTMatchers/ASTMatchers.h
+++ clang/include/clang/ASTMatchers/ASTMatchers.h
@@ -7545,6 +7545,11 @@
 
 /// Matches declaration of the function the statement belongs to.
 ///
+/// Deprecated. Use forCallable() to correctly handle the situation when
+/// the declaration is not a function (but a block or an Objective-C method).
+/// forFunction() not only fails to take non-functions into account but also
+/// may match the wrong declaration in their presence.
+///
 /// Given:
 /// \code
 /// F& operator=(const F& o) {
@@ -7580,6 +7585,65 @@
   return false;
 }
 
+/// Matches declaration of the function, method, or block the statement
+/// belongs to.
+///
+/// Given:
+/// \code
+/// F& operator=(const F& o) {
+///   std::copy_if(o.begin(), o.end(), begin(), [](V v) { return v > 0; });
+///   return *this;
+/// }
+/// \end

[PATCH] D101793: [clang][AST] Improve AST Reader/Writer memory footprint

2021-05-13 Thread Wei Wang via Phabricator via cfe-commits
weiwang added a comment.

Finally dealt with the other issues I need to take care. Let's resume the 
discussion.

I printed out the decls that are duplicated. The list of very long, but the top 
ones all seem from glibc headers. For example (the number after 'c:' is the 
duplication count),

  static inline __uint16_t __bswap_16(__uint16_t __bsx) {
  return ((__uint16_t)__bsx) >> 8) & 255) | (((__bsx) & 255) << 8)));
  }
  c:8581627
  static inline __uint16_t __bswap_16(__uint16_t __bsx)
  c:8581627
  static inline __uint32_t __bswap_32(__uint32_t __bsx) {
  return __bsx) & 4278190080U) >> 24) | (((__bsx) & 16711680U) >> 8) | 
(((__bsx) & 65280U) << 8) | (((__bsx) & 255U) << 24));
  }
  c:8581627
  static inline __uint32_t __bswap_32(__uint32_t __bsx)
  c:8581627
  static inline __uint64_t __bswap_64(__uint64_t __bsx) {
  return __bsx) & 18374686479671623680ULL) >> 56) | (((__bsx) & 
71776119061217280ULL) >> 40) | (((__bsx) & 280375465082880ULL) >> 24) |   
(((__bsx) & 1095216660480ULL) >> 8) | (((__bsx) & 4278190080ULL) << 8) | 
(((__bsx) & 16711680ULL) << 24) | (((__bsx) & 65280ULL) << 40) |   
(((__bsx) & 255ULL) << 56));
  }
  c:8581627
  static inline __uint64_t __bswap_64(__uint64_t __bsx)
  c:8581627
  static inline __uint16_t __uint16_identity(__uint16_t __x) {
  return __x;
  }
  c:8581627
  static inline __uint32_t __uint32_identity(__uint32_t __x) {
  return __x;
  }
  c:8581627
  static inline __uint64_t __uint64_identity(__uint64_t __x) {
  return __x;
  }
  c:8581627
  inline int iscanonical(float __val) {
  return ((void)(typeof (__val))(__val) , 1);
  }
  c:8581627
  inline int iscanonical(double __val) {
  return ((void)(typeof (__val))(__val) , 1);
  }
  c:8581627
  inline int iscanonical(long double __val) {
  return __iscanonicall(__val);
  }
  c:8581627
  inline int issignaling(float __val) {
  return __issignalingf(__val);
  }
  c:8581627
  inline int issignaling(double __val) {
  return __issignaling(__val);
  }
  c:8581627
  inline int issignaling(long double __val) {
  return __issignalingl(__val);
  }
  c:8581627
  static int __call(float __x, float __y) throw() {
  return __iseqsigf(__x, __y);
  }
  c:8581627
  static int __call(double __x, double __y) throw() {
  return __iseqsig(__x, __y);
  }
  c:8581627
  static int __call(long double __x, long double __y) throw() {
  return __iseqsigl(__x, __y);
  }
  c:8581627

I think the source codebase is a mix of conventional headers and modules, I 
don't know if that makes any difference.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101793

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


[PATCH] D96033: [clang-repl] Land initial infrastructure for incremental parsing

2021-05-13 Thread Hubert Tong via Phabricator via cfe-commits
hubert.reinterpretcast added a comment.

In D96033#2757342 , @lhames wrote:

> Hi Hubert,
>
> Could you apply the following patch and let me know the output from the 
> failing test? I'm trying to work out whether the JIT is getting the triple or 
> the data layout wrong.

I've started the build. My tree was a bit stale, so it might not be the fastest.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D96033

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


  1   2   >