[PATCH] D98710: [clang-tidy] Add --skip-headers, part 1 (use setTraversalScope)

2021-07-02 Thread Chih-Hung Hsieh via Phabricator via cfe-commits
chh updated this revision to Diff 356321.
chh added a comment.

fix clang-format coding style issue


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

https://reviews.llvm.org/D98710

Files:
  clang-tools-extra/clang-tidy/ClangTidy.cpp
  clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp
  clang-tools-extra/clang-tidy/ClangTidyOptions.cpp
  clang-tools-extra/clang-tidy/ClangTidyOptions.h
  clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp
  clang-tools-extra/test/clang-tidy/checkers/Inputs/skip-headers/my_header1.h
  clang-tools-extra/test/clang-tidy/checkers/Inputs/skip-headers/my_header2.h
  
clang-tools-extra/test/clang-tidy/checkers/bugprone-forward-declaration-namespace.cpp
  clang-tools-extra/test/clang-tidy/checkers/bugprone-reserved-identifier.cpp
  clang-tools-extra/test/clang-tidy/checkers/bugprone-suspicious-include.cpp
  
clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-interfaces-global-init.cpp
  clang-tools-extra/test/clang-tidy/checkers/google-namespaces.cpp
  clang-tools-extra/test/clang-tidy/checkers/google-objc-function-naming.m
  clang-tools-extra/test/clang-tidy/checkers/llvm-include-order.cpp
  
clang-tools-extra/test/clang-tidy/checkers/llvm-prefer-register-over-unsigned.cpp
  
clang-tools-extra/test/clang-tidy/checkers/llvmlibc-implementation-in-namespace.cpp
  
clang-tools-extra/test/clang-tidy/checkers/llvmlibc-restrict-system-libc-headers.cpp
  clang-tools-extra/test/clang-tidy/checkers/misc-no-recursion.cpp
  
clang-tools-extra/test/clang-tidy/checkers/modernize-deprecated-headers-cxx03.cpp
  
clang-tools-extra/test/clang-tidy/checkers/modernize-deprecated-headers-cxx11.cpp
  clang-tools-extra/test/clang-tidy/checkers/modernize-pass-by-value-header.cpp
  
clang-tools-extra/test/clang-tidy/checkers/portability-restrict-system-includes-allow.cpp
  
clang-tools-extra/test/clang-tidy/checkers/portability-restrict-system-includes-disallow.cpp
  
clang-tools-extra/test/clang-tidy/checkers/readability-simplify-bool-expr-chained-conditional-assignment.cpp
  
clang-tools-extra/test/clang-tidy/checkers/readability-simplify-bool-expr-chained-conditional-return.cpp
  
clang-tools-extra/test/clang-tidy/checkers/readability-simplify-bool-expr-members.cpp
  clang-tools-extra/test/clang-tidy/checkers/readability-simplify-bool-expr.cpp
  clang-tools-extra/test/clang-tidy/checkers/skip-headers.cpp
  clang/include/clang/ASTMatchers/ASTMatchFinder.h

Index: clang/include/clang/ASTMatchers/ASTMatchFinder.h
===
--- clang/include/clang/ASTMatchers/ASTMatchFinder.h
+++ clang/include/clang/ASTMatchers/ASTMatchFinder.h
@@ -141,7 +141,7 @@
   };
 
   MatchFinder(MatchFinderOptions Options = MatchFinderOptions());
-  ~MatchFinder();
+  virtual ~MatchFinder();
 
   /// Adds a matcher to execute when running over the AST.
   ///
@@ -196,7 +196,7 @@
   /// @}
 
   /// Finds all matches in the given AST.
-  void matchAST(ASTContext &Context);
+  virtual void matchAST(ASTContext &Context);
 
   /// Registers a callback to notify the end of parsing.
   ///
Index: clang-tools-extra/test/clang-tidy/checkers/skip-headers.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/skip-headers.cpp
@@ -0,0 +1,54 @@
+// Test --skip-headers, --show-all-warnings, and --header-filter.
+// TODO: when skip-headers implementation is complete, add back
+//  -implicit-check-not="{{warning|error}}:"
+// and use no_hint instead of hint
+//
+// Default shows no warning in .h files, and give HINT to use --header-filter
+// RUN: clang-tidy %s -checks='*' -- \
+// RUN: 2>&1 | FileCheck %s -check-prefixes WARN,MAIN,HINT
+// later:-implicit-check-not="{{warning|error}}:"
+//
+// --skip-headers skips included files; finds only warnings in the main file.
+// RUN: clang-tidy %s -checks='*' --skip-headers -- \
+// RUN: 2>&1 | FileCheck %s -check-prefixes WARN,MAIN,HINT
+// later:no_hint -implicit-check-not="{{warning|error}}:"
+//
+// --show-all-warnings reports all warnings, even without --header-filters
+// RUN: clang-tidy %s -checks='*' --show-all-warnings -- \
+// RUN: 2>&1 | FileCheck %s -check-prefixes WARN,WARN_BOTH,MAIN,NO_HINT
+//
+// --header-filter='.*' is like --show-all-warnings
+// RUN: clang-tidy %s -checks='*' --header-filter='.*' -- \
+// RUN: 2>&1 | FileCheck %s -check-prefixes WARN,WARN_BOTH,MAIN,NO_HINT
+//
+// --header-filter='header1.h' shows only warnings in header1.h
+// RUN: clang-tidy %s -checks='*' --header-filter='header1.h' -- \
+// RUN: 2>&1 | FileCheck %s -check-prefixes WARN,WARN1,MAIN,HINT
+// later:-implicit-check-not="{{warning|error}}:"
+//
+// The main purpose of --show-all-warnings is to debug --skip-headers.
+// When used together, no warnings should be reported from header files.
+// RUN: clang-tidy %s -checks='*' --skip-headers --show-all-warnings -- \
+// RUN: 2>&1 | FileCheck %s -check-prefixes WARN,MAIN,

[PATCH] D98710: [clang-tidy] Add --skip-headers, part 1 (use setTraversalScope)

2021-07-02 Thread Chih-Hung Hsieh via Phabricator via cfe-commits
chh updated this revision to Diff 356319.
chh marked an inline comment as done.
chh added a comment.

fix clang-format name style issue


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

https://reviews.llvm.org/D98710

Files:
  clang-tools-extra/clang-tidy/ClangTidy.cpp
  clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp
  clang-tools-extra/clang-tidy/ClangTidyOptions.cpp
  clang-tools-extra/clang-tidy/ClangTidyOptions.h
  clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp
  clang-tools-extra/test/clang-tidy/checkers/Inputs/skip-headers/my_header1.h
  clang-tools-extra/test/clang-tidy/checkers/Inputs/skip-headers/my_header2.h
  
clang-tools-extra/test/clang-tidy/checkers/bugprone-forward-declaration-namespace.cpp
  clang-tools-extra/test/clang-tidy/checkers/bugprone-reserved-identifier.cpp
  clang-tools-extra/test/clang-tidy/checkers/bugprone-suspicious-include.cpp
  
clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-interfaces-global-init.cpp
  clang-tools-extra/test/clang-tidy/checkers/google-namespaces.cpp
  clang-tools-extra/test/clang-tidy/checkers/google-objc-function-naming.m
  clang-tools-extra/test/clang-tidy/checkers/llvm-include-order.cpp
  
clang-tools-extra/test/clang-tidy/checkers/llvm-prefer-register-over-unsigned.cpp
  
clang-tools-extra/test/clang-tidy/checkers/llvmlibc-implementation-in-namespace.cpp
  
clang-tools-extra/test/clang-tidy/checkers/llvmlibc-restrict-system-libc-headers.cpp
  clang-tools-extra/test/clang-tidy/checkers/misc-no-recursion.cpp
  
clang-tools-extra/test/clang-tidy/checkers/modernize-deprecated-headers-cxx03.cpp
  
clang-tools-extra/test/clang-tidy/checkers/modernize-deprecated-headers-cxx11.cpp
  clang-tools-extra/test/clang-tidy/checkers/modernize-pass-by-value-header.cpp
  
clang-tools-extra/test/clang-tidy/checkers/portability-restrict-system-includes-allow.cpp
  
clang-tools-extra/test/clang-tidy/checkers/portability-restrict-system-includes-disallow.cpp
  
clang-tools-extra/test/clang-tidy/checkers/readability-simplify-bool-expr-chained-conditional-assignment.cpp
  
clang-tools-extra/test/clang-tidy/checkers/readability-simplify-bool-expr-chained-conditional-return.cpp
  
clang-tools-extra/test/clang-tidy/checkers/readability-simplify-bool-expr-members.cpp
  clang-tools-extra/test/clang-tidy/checkers/readability-simplify-bool-expr.cpp
  clang-tools-extra/test/clang-tidy/checkers/skip-headers.cpp
  clang/include/clang/ASTMatchers/ASTMatchFinder.h

Index: clang/include/clang/ASTMatchers/ASTMatchFinder.h
===
--- clang/include/clang/ASTMatchers/ASTMatchFinder.h
+++ clang/include/clang/ASTMatchers/ASTMatchFinder.h
@@ -141,7 +141,7 @@
   };
 
   MatchFinder(MatchFinderOptions Options = MatchFinderOptions());
-  ~MatchFinder();
+  virtual ~MatchFinder();
 
   /// Adds a matcher to execute when running over the AST.
   ///
@@ -196,7 +196,7 @@
   /// @}
 
   /// Finds all matches in the given AST.
-  void matchAST(ASTContext &Context);
+  virtual void matchAST(ASTContext &Context);
 
   /// Registers a callback to notify the end of parsing.
   ///
Index: clang-tools-extra/test/clang-tidy/checkers/skip-headers.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/skip-headers.cpp
@@ -0,0 +1,54 @@
+// Test --skip-headers, --show-all-warnings, and --header-filter.
+// TODO: when skip-headers implementation is complete, add back
+//  -implicit-check-not="{{warning|error}}:"
+// and use no_hint instead of hint
+//
+// Default shows no warning in .h files, and give HINT to use --header-filter
+// RUN: clang-tidy %s -checks='*' -- \
+// RUN: 2>&1 | FileCheck %s -check-prefixes WARN,MAIN,HINT
+// later:-implicit-check-not="{{warning|error}}:"
+//
+// --skip-headers skips included files; finds only warnings in the main file.
+// RUN: clang-tidy %s -checks='*' --skip-headers -- \
+// RUN: 2>&1 | FileCheck %s -check-prefixes WARN,MAIN,HINT
+// later:no_hint -implicit-check-not="{{warning|error}}:"
+//
+// --show-all-warnings reports all warnings, even without --header-filters
+// RUN: clang-tidy %s -checks='*' --show-all-warnings -- \
+// RUN: 2>&1 | FileCheck %s -check-prefixes WARN,WARN_BOTH,MAIN,NO_HINT
+//
+// --header-filter='.*' is like --show-all-warnings
+// RUN: clang-tidy %s -checks='*' --header-filter='.*' -- \
+// RUN: 2>&1 | FileCheck %s -check-prefixes WARN,WARN_BOTH,MAIN,NO_HINT
+//
+// --header-filter='header1.h' shows only warnings in header1.h
+// RUN: clang-tidy %s -checks='*' --header-filter='header1.h' -- \
+// RUN: 2>&1 | FileCheck %s -check-prefixes WARN,WARN1,MAIN,HINT
+// later:-implicit-check-not="{{warning|error}}:"
+//
+// The main purpose of --show-all-warnings is to debug --skip-headers.
+// When used together, no warnings should be reported from header files.
+// RUN: clang-tidy %s -checks='*' --skip-headers --show-all-warnings -- \
+// RUN: 2>&1 | Fil

[PATCH] D102782: Add support for Warning Flag "-Wstack-usage="

2021-07-02 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added a comment.

In GCC -Wstack-usage= is more powerful. It can check `warning: stack usage 
might be unbounded`.

If this is currently just an alias, does it address some application pain? If 
we don't actually implement the -Wstack-usage= functionality, I'd hope that 
applications know this and gracefully degrade to -Wframe-larger-than= instead.
Having this functionality could give false impression that we have implemented 
the powerful detection usage.
And I expect that -Wstack-usage= is rarely used.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D102782

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


[PATCH] D98710: [clang-tidy] Add --skip-headers, part 1 (use setTraversalScope)

2021-07-02 Thread Chih-Hung Hsieh via Phabricator via cfe-commits
chh marked an inline comment as done and an inline comment as not done.
chh added a comment.

Last build tests were green. Let's see if the new updated diff still passes all 
the tests.

Looks like all choices have some risk/overhead in future maintenance and we 
need to pick one with the least cost.
I think cloning classes is most expensive and risky to keep future 
compatibility.
Adding a new subclass or optional members into existing class are more 
conventional solutions.




Comment at: clang-tools-extra/clang-tidy/ClangTidy.cpp:473
+MatchFinder::matchAST(Context);
+Context.setTraversalScope(SavedScope);
+  } else {

sammccall wrote:
> Is restoring the traversal scope strictly needed by the static analyzer? I 
> would expect not, but I might be wrong.
I think it is safer to assume low or acceptable overhead in 
get/setTraversalScope and keep the impact only to the MatchFinder consumer, 
rather than depending on static analyzer working now or in the future with the 
changed AST.




Comment at: clang/include/clang/ASTMatchers/ASTMatchFinder.h:144
   MatchFinder(MatchFinderOptions Options = MatchFinderOptions());
-  ~MatchFinder();
+  virtual ~MatchFinder();
+

sammccall wrote:
> Matchfinder specifically says "not intended to be subclassed".
Do you know the reason it cannot have subclass?
All our current implementation choices need to change its matchAST behavior, 
either by overriding it, or changing the AST before it, or skip Decl in the 
recursive walk of AST.
For any reason not to have subclass, changing AST outside matchAST seems 
riskier than changing inside matchAST in a child class.




Comment at: clang/include/clang/ASTMatchers/ASTMatchFinder.h:147
+  /// Inside a MatchASTConsumer, handles all top level Decl.
+  virtual bool HandleTopLevelDecl(DeclGroupRef DG);
 

sammccall wrote:
> This function doesn't make sense at this layer - calling it does nothing and 
> the class is intended to be used directly, not to be subclassed. And 
> MatchFinder itself doesn't "consume" top-level decls - that's an ASTConsumer 
> concern.
> 
> I understand you use it here as a hook to listen for decls seen by the 
> MatchFinder::newASTConsumer().
> Better would be to pass a HandleTopLevelDecl callback to newASTConsumer() 
> instead.
> But given that MatchFinderASTConsumer is completely trivial and can be built 
> on the public MatchFinder API, better still would just be to reimplement it 
> with the unusual functionality ClangTidy needs.
Please review the updated diff. Now HandleTopLevelDecl is all in clang-tidy.
For both the MultiplexConsumer and MatchFinder, I think it is more feasible to 
resolve all subclass issues now and maintain the inheritance relation than 
making clone implementations and trying to maintain the same behavior in the 
future.



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

https://reviews.llvm.org/D98710

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


[PATCH] D98710: [clang-tidy] Add --skip-headers, part 1 (use setTraversalScope)

2021-07-02 Thread Chih-Hung Hsieh via Phabricator via cfe-commits
chh updated this revision to Diff 356307.
chh marked an inline comment as done.
chh edited the summary of this revision.

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

https://reviews.llvm.org/D98710

Files:
  clang-tools-extra/clang-tidy/ClangTidy.cpp
  clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp
  clang-tools-extra/clang-tidy/ClangTidyOptions.cpp
  clang-tools-extra/clang-tidy/ClangTidyOptions.h
  clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp
  clang-tools-extra/test/clang-tidy/checkers/Inputs/skip-headers/my_header1.h
  clang-tools-extra/test/clang-tidy/checkers/Inputs/skip-headers/my_header2.h
  
clang-tools-extra/test/clang-tidy/checkers/bugprone-forward-declaration-namespace.cpp
  clang-tools-extra/test/clang-tidy/checkers/bugprone-reserved-identifier.cpp
  clang-tools-extra/test/clang-tidy/checkers/bugprone-suspicious-include.cpp
  
clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-interfaces-global-init.cpp
  clang-tools-extra/test/clang-tidy/checkers/google-namespaces.cpp
  clang-tools-extra/test/clang-tidy/checkers/google-objc-function-naming.m
  clang-tools-extra/test/clang-tidy/checkers/llvm-include-order.cpp
  
clang-tools-extra/test/clang-tidy/checkers/llvm-prefer-register-over-unsigned.cpp
  
clang-tools-extra/test/clang-tidy/checkers/llvmlibc-implementation-in-namespace.cpp
  
clang-tools-extra/test/clang-tidy/checkers/llvmlibc-restrict-system-libc-headers.cpp
  clang-tools-extra/test/clang-tidy/checkers/misc-no-recursion.cpp
  
clang-tools-extra/test/clang-tidy/checkers/modernize-deprecated-headers-cxx03.cpp
  
clang-tools-extra/test/clang-tidy/checkers/modernize-deprecated-headers-cxx11.cpp
  clang-tools-extra/test/clang-tidy/checkers/modernize-pass-by-value-header.cpp
  
clang-tools-extra/test/clang-tidy/checkers/portability-restrict-system-includes-allow.cpp
  
clang-tools-extra/test/clang-tidy/checkers/portability-restrict-system-includes-disallow.cpp
  
clang-tools-extra/test/clang-tidy/checkers/readability-simplify-bool-expr-chained-conditional-assignment.cpp
  
clang-tools-extra/test/clang-tidy/checkers/readability-simplify-bool-expr-chained-conditional-return.cpp
  
clang-tools-extra/test/clang-tidy/checkers/readability-simplify-bool-expr-members.cpp
  clang-tools-extra/test/clang-tidy/checkers/readability-simplify-bool-expr.cpp
  clang-tools-extra/test/clang-tidy/checkers/skip-headers.cpp
  clang/include/clang/ASTMatchers/ASTMatchFinder.h

Index: clang/include/clang/ASTMatchers/ASTMatchFinder.h
===
--- clang/include/clang/ASTMatchers/ASTMatchFinder.h
+++ clang/include/clang/ASTMatchers/ASTMatchFinder.h
@@ -141,7 +141,7 @@
   };
 
   MatchFinder(MatchFinderOptions Options = MatchFinderOptions());
-  ~MatchFinder();
+  virtual ~MatchFinder();
 
   /// Adds a matcher to execute when running over the AST.
   ///
@@ -196,7 +196,7 @@
   /// @}
 
   /// Finds all matches in the given AST.
-  void matchAST(ASTContext &Context);
+  virtual void matchAST(ASTContext &Context);
 
   /// Registers a callback to notify the end of parsing.
   ///
Index: clang-tools-extra/test/clang-tidy/checkers/skip-headers.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/skip-headers.cpp
@@ -0,0 +1,54 @@
+// Test --skip-headers, --show-all-warnings, and --header-filter.
+// TODO: when skip-headers implementation is complete, add back
+//  -implicit-check-not="{{warning|error}}:"
+// and use no_hint instead of hint
+//
+// Default shows no warning in .h files, and give HINT to use --header-filter
+// RUN: clang-tidy %s -checks='*' -- \
+// RUN: 2>&1 | FileCheck %s -check-prefixes WARN,MAIN,HINT
+// later:-implicit-check-not="{{warning|error}}:"
+//
+// --skip-headers skips included files; finds only warnings in the main file.
+// RUN: clang-tidy %s -checks='*' --skip-headers -- \
+// RUN: 2>&1 | FileCheck %s -check-prefixes WARN,MAIN,HINT
+// later:no_hint -implicit-check-not="{{warning|error}}:"
+//
+// --show-all-warnings reports all warnings, even without --header-filters
+// RUN: clang-tidy %s -checks='*' --show-all-warnings -- \
+// RUN: 2>&1 | FileCheck %s -check-prefixes WARN,WARN_BOTH,MAIN,NO_HINT
+//
+// --header-filter='.*' is like --show-all-warnings
+// RUN: clang-tidy %s -checks='*' --header-filter='.*' -- \
+// RUN: 2>&1 | FileCheck %s -check-prefixes WARN,WARN_BOTH,MAIN,NO_HINT
+//
+// --header-filter='header1.h' shows only warnings in header1.h
+// RUN: clang-tidy %s -checks='*' --header-filter='header1.h' -- \
+// RUN: 2>&1 | FileCheck %s -check-prefixes WARN,WARN1,MAIN,HINT
+// later:-implicit-check-not="{{warning|error}}:"
+//
+// The main purpose of --show-all-warnings is to debug --skip-headers.
+// When used together, no warnings should be reported from header files.
+// RUN: clang-tidy %s -checks='*' --skip-headers --show-all-warnings -- \
+// RUN: 2>&1 | FileCheck %s -check

[PATCH] D105384: [NVPTX, CUDA] Add .and.popc variant of the b1 MMA instruction.

2021-07-02 Thread Artem Belevich via Phabricator via cfe-commits
tra created this revision.
tra added a reviewer: steffenlarsen.
Herald added subscribers: bixia, hiraditya, yaxunl, jholewinski.
tra requested review of this revision.
Herald added a subscriber: jdoerfert.
Herald added projects: clang, LLVM.

Extends the changes in D104847  and adds 
another MMA instruction variant and corresponding intrinsics & builtins.

That should allow clang to compile mma.h from CUDA-11.3.

Didn't test it much yet. There may still be some sharp corners.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D105384

Files:
  clang/include/clang/Basic/BuiltinsNVPTX.def
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/test/CodeGen/builtins-nvptx-mma.cu
  clang/test/CodeGen/builtins-nvptx-mma.py
  llvm/include/llvm/IR/IntrinsicsNVVM.td
  llvm/lib/Target/NVPTX/NVPTXInstrInfo.td
  llvm/lib/Target/NVPTX/NVPTXIntrinsics.td
  llvm/test/CodeGen/NVPTX/wmma.py

Index: llvm/test/CodeGen/NVPTX/wmma.py
===
--- llvm/test/CodeGen/NVPTX/wmma.py
+++ llvm/test/CodeGen/NVPTX/wmma.py
@@ -55,14 +55,14 @@
 # RUN: llc < %t-ptx65-sm_75.ll -march=nvptx64 -mcpu=sm_75 -mattr=+ptx65 \
 # RUN:   | FileCheck %t-ptx65-sm_75.ll
 
-# Check all variants of instructions supported by PTX70 on SM80+
-# RUN: python %s --ptx=70 --gpu-arch=80 > %t-ptx70-sm_80.ll
-# RUN: FileCheck %t-ptx70-sm_80.ll < %t-ptx70-sm_80.ll \
-# RUN:   --check-prefixes=INTRINSICS,M16N16,EXTGEOM,INT,SUBINT,MMA,ALTFLOAT,DOUBLE,PTX65MMA,PTX70MMA
-# RUN: FileCheck %t-ptx70-sm_80.ll < %t-ptx70-sm_80.ll \
+# Check all variants of instructions supported by PTX71 on SM80+
+# RUN: python %s --ptx=71 --gpu-arch=80 > %t-ptx71-sm_80.ll
+# RUN: FileCheck %t-ptx71-sm_80.ll < %t-ptx71-sm_80.ll \
+# RUN:   --check-prefixes=INTRINSICS,M16N16,EXTGEOM,INT,SUBINT,MMA,ALTFLOAT,DOUBLE,PTX65MMA,PTX71MMA
+# RUN: FileCheck %t-ptx71-sm_80.ll < %t-ptx71-sm_80.ll \
 # RUN:   --check-prefixes=INTRINSICS
-# RUN: llc < %t-ptx70-sm_80.ll -march=nvptx64 -mcpu=sm_80 -mattr=+ptx70 \
-# RUN:   | FileCheck %t-ptx70-sm_80.ll
+# RUN: llc < %t-ptx71-sm_80.ll -march=nvptx64 -mcpu=sm_80 -mattr=+ptx71 \
+# RUN:   | FileCheck %t-ptx71-sm_80.ll
 
 from __future__ import print_function
 
@@ -649,9 +649,16 @@
   print(Template(mma_template).substitute(test_params))
   return (test_params["intrinsic"], test_params["instruction"])
 
+def get_b1_ops(ptx_type):
+  if ptx_type != "b1":
+return [""]
+  if ptx_version >= 71:
+return [".xor.popc", ".and.popc"]
+  return [".xor.popc"]
+
 def gen_wmma_mma_tests():
-  wmma_intrinsic_template = "llvm.nvvm.wmma.${geom}.mma.${alayout}.${blayout}${rnd}.${intrinsic_signature}${satf}"
-  wmma_instruction_template = "wmma.mma${mma_variant}.sync${aligned}.${alayout}.${blayout}.${geom}${rnd}.${ptx_signature}${satf}"
+  wmma_intrinsic_template = "llvm.nvvm.wmma.${geom}.mma${b1op}.${alayout}.${blayout}${rnd}.${intrinsic_signature}${satf}"
+  wmma_instruction_template = "wmma.mma${b1op}.sync${aligned}.${alayout}.${blayout}.${geom}${rnd}.${ptx_signature}${satf}"
 
   generated_items=[]
 
@@ -665,29 +672,30 @@
 if not is_wmma_variant_supported(op, alayout, blayout, rnd, satf):
   continue
 
-params = {
-"aligned" : ".aligned" if ptx_version >= 63 else "",
-"alayout" : alayout,
-"blayout" : blayout,
-"intrinsic_signature" : wmma_signature(op),
-"ptx_signature" : wmma_ptx_signature(op),
-"satf"  : satf,
-"rnd"   : rnd,
-"geom"  : op.a.geom,
-"mma_variant" : ".xor.popc" if op.a.mma_type.ptx_type == "b1" else "",
-}
+for b1op in get_b1_ops(op.a.mma_type.ptx_type):
+  params = {
+  "aligned" : ".aligned" if ptx_version >= 63 else "",
+  "alayout" : alayout,
+  "blayout" : blayout,
+  "intrinsic_signature" : wmma_signature(op),
+  "ptx_signature" : wmma_ptx_signature(op),
+  "satf"  : satf,
+  "rnd"   : rnd,
+  "geom"  : op.a.geom,
+  "b1op" : b1op
+  }
 
-intrinsic_template = wmma_intrinsic_template
-instruction_template = wmma_instruction_template
+  intrinsic_template = wmma_intrinsic_template
+  instruction_template = wmma_instruction_template
 
-generated_items.append(common_mma_test_gen(params, op,
-  intrinsic_template, instruction_template))
+  generated_items.append(common_mma_test_gen(params, op,
+ intrinsic_template, instruction_template))
 
   return generated_items
 
 def gen_mma_tests():
-  mma_intrinsic_template = "llvm.nvvm.mma.${geom}.${alayout}.${blayout}${satf}.${intrinsic_signature}"
-  mma_instruction_template = "mma.sync${aligned}.${geom}.${alayout}.${blayout}${satf}.${ptx_signature}${mma_variant}"
+  mma_intrinsic_template = "llvm.nvvm.mma${b1op}.${geom}.${alayout}.${blayout}${satf}.${intrinsic_signature}"
+  mma_instruction_template = "mma.sync${aligne

[PATCH] D104847: [Clang][NVPTX] Add NVPTX intrinsics and builtins for CUDA PTX 6.5 and 7.0 WMMA and MMA instructions

2021-07-02 Thread Artem Belevich via Phabricator via cfe-commits
tra added inline comments.



Comment at: clang/test/CodeGen/builtins-nvptx-mma.cu:781-786
+  // CHECK_PTX70_SM80: call {{.*}} 
@llvm.nvvm.wmma.m16n16k8.load.c.col.stride.f32
+  // expected-error-re@+1 {{'__mma_tf32_m16n16k8_ld_c' needs target feature 
(sm_80{{.*}},(ptx70{{.*
+  __mma_tf32_m16n16k8_ld_c(fdst, fsrc, ldm, 1);
+  // CHECK_PTX70_SM80: call {{.*}} 
@llvm.nvvm.wmma.m16n16k8.load.c.row.stride.f32
+  // expected-error-re@+1 {{'__mma_tf32_m16n16k8_ld_c' needs target feature 
(sm_80{{.*}},(ptx70{{.*
+  __mma_tf32_m16n16k8_ld_c(fdst, fsrc, ldm, 0);

tra wrote:
> This looks rather odd. We're calling a `tf32` builtin, but expect to see and 
> `f32` load intrinsic. Is that expected ? 
> 
> 
Never mind. I think I understand what's going on now.
CUDA headers use  __mma_tf32 builtins. `A` and `B` operate on opaque integer 
types. `C` and `D` operate on floats.
However, on the PTX front we have `wmma.load.{a,b}...tf32` but 
`wmma.load.c...f32`.

I guess it does make sense to keep LLVM intrinsic names close to the 
instructions they produce.





Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D104847

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


[PATCH] D99696: [clang] NRVO: Improvements and handling of more cases.

2021-07-02 Thread Matheus Izvekov via Phabricator via cfe-commits
mizvekov added a comment.

@anhtuyen

I pushed a DR with a preliminary fix for it: https://reviews.llvm.org/D105380

This is not ready to merge, still have to add test cases and also decide 
between a pointed fix like this, or improving the ergonomics of `getDeclAlign` 
by returning possible failure.

But it does fix your repro.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99696

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


[PATCH] D105380: DRAFT: [clang] fixes named return of variables with dependent alignment

2021-07-02 Thread Matheus Izvekov via Phabricator via cfe-commits
mizvekov created this revision.
mizvekov requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Signed-off-by: Matheus Izvekov 


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D105380

Files:
  clang/lib/Sema/SemaStmt.cpp


Index: clang/lib/Sema/SemaStmt.cpp
===
--- clang/lib/Sema/SemaStmt.cpp
+++ clang/lib/Sema/SemaStmt.cpp
@@ -3393,9 +3393,17 @@
 return NamedReturnInfo();
   }
 
+  auto isAlignmentDependent = [](const VarDecl *VD) {
+for (auto *I : VD->specific_attrs())
+  if (I->isAlignmentDependent())
+return true;
+return false;
+  };
+
   // Variables with higher required alignment than their type's ABI
   // alignment cannot use NRVO.
   if (!VDType->isDependentType() && VD->hasAttr() &&
+  !isAlignmentDependent(VD) &&
   Context.getDeclAlign(VD) > Context.getTypeAlignInChars(VDType))
 Info.S = NamedReturnInfo::MoveEligible;
 


Index: clang/lib/Sema/SemaStmt.cpp
===
--- clang/lib/Sema/SemaStmt.cpp
+++ clang/lib/Sema/SemaStmt.cpp
@@ -3393,9 +3393,17 @@
 return NamedReturnInfo();
   }
 
+  auto isAlignmentDependent = [](const VarDecl *VD) {
+for (auto *I : VD->specific_attrs())
+  if (I->isAlignmentDependent())
+return true;
+return false;
+  };
+
   // Variables with higher required alignment than their type's ABI
   // alignment cannot use NRVO.
   if (!VDType->isDependentType() && VD->hasAttr() &&
+  !isAlignmentDependent(VD) &&
   Context.getDeclAlign(VD) > Context.getTypeAlignInChars(VDType))
 Info.S = NamedReturnInfo::MoveEligible;
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D105368: Lex: add a callback for `#pragma mark`

2021-07-02 Thread 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 rG24f4c3ebef63: Lex: add a callback for `#pragma mark` 
(authored by compnerd, committed by Saleem Abdulrasool 
).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105368

Files:
  clang/include/clang/Lex/PPCallbacks.h
  clang/include/clang/Lex/Preprocessor.h
  clang/lib/Lex/Pragma.cpp
  clang/unittests/Lex/PPCallbacksTest.cpp

Index: clang/unittests/Lex/PPCallbacksTest.cpp
===
--- clang/unittests/Lex/PPCallbacksTest.cpp
+++ clang/unittests/Lex/PPCallbacksTest.cpp
@@ -112,6 +112,20 @@
   unsigned State;
 };
 
+class PragmaMarkCallbacks : public PPCallbacks {
+public:
+  struct Mark {
+SourceLocation Location;
+std::string Trivia;
+  };
+
+  std::vector Marks;
+
+  void PragmaMark(SourceLocation Loc, StringRef Trivia) override {
+Marks.emplace_back(Mark{Loc, Trivia.str()});
+  }
+};
+
 // PPCallbacks test fixture.
 class PPCallbacksTest : public ::testing::Test {
 protected:
@@ -256,6 +270,36 @@
 return Callbacks->Results;
   }
 
+  std::vector
+  PragmaMarkCall(const char *SourceText) {
+std::unique_ptr SourceBuf =
+llvm::MemoryBuffer::getMemBuffer(SourceText, "test.c");
+SourceMgr.setMainFileID(SourceMgr.createFileID(std::move(SourceBuf)));
+
+HeaderSearch HeaderInfo(std::make_shared(), SourceMgr,
+Diags, LangOpts, Target.get());
+TrivialModuleLoader ModLoader;
+
+Preprocessor PP(std::make_shared(), Diags, LangOpts,
+SourceMgr, HeaderInfo, ModLoader, /*IILookup=*/nullptr,
+/*OwnsHeaderSearch=*/false);
+PP.Initialize(*Target);
+
+auto *Callbacks = new PragmaMarkCallbacks;
+PP.addPPCallbacks(std::unique_ptr(Callbacks));
+
+// Lex source text.
+PP.EnterMainSourceFile();
+while (true) {
+  Token Tok;
+  PP.Lex(Tok);
+  if (Tok.is(tok::eof))
+break;
+}
+
+return Callbacks->Marks;
+  }
+
   PragmaOpenCLExtensionCallbacks::CallbackParameters
   PragmaOpenCLExtensionCall(const char *SourceText) {
 LangOptions OpenCLLangOpts;
@@ -424,6 +468,24 @@
   ASSERT_EQ(ExpectedState, Parameters.State);
 }
 
+TEST_F(PPCallbacksTest, CollectMarks) {
+  const char *Source =
+"#pragma mark\n"
+"#pragma mark\r\n"
+"#pragma mark - trivia\n"
+"#pragma mark - trivia\r\n";
+
+  auto Marks = PragmaMarkCall(Source);
+
+  ASSERT_EQ(4u, Marks.size());
+  ASSERT_TRUE(Marks[0].Trivia.empty());
+  ASSERT_TRUE(Marks[1].Trivia.empty());
+  ASSERT_FALSE(Marks[2].Trivia.empty());
+  ASSERT_FALSE(Marks[3].Trivia.empty());
+  ASSERT_EQ(" - trivia", Marks[2].Trivia);
+  ASSERT_EQ(" - trivia", Marks[3].Trivia);
+}
+
 TEST_F(PPCallbacksTest, DirectiveExprRanges) {
   const auto &Results1 = DirectiveExprRange("#if FLUZZY_FLOOF\n#endif\n");
   EXPECT_EQ(Results1.size(), 1U);
Index: clang/lib/Lex/Pragma.cpp
===
--- clang/lib/Lex/Pragma.cpp
+++ clang/lib/Lex/Pragma.cpp
@@ -412,9 +412,13 @@
   HeaderInfo.MarkFileIncludeOnce(getCurrentFileLexer()->getFileEntry());
 }
 
-void Preprocessor::HandlePragmaMark() {
+void Preprocessor::HandlePragmaMark(Token &MarkTok) {
   assert(CurPPLexer && "No current lexer?");
-  CurLexer->ReadToEndOfLine();
+
+  SmallString<64> Buffer;
+  CurLexer->ReadToEndOfLine(&Buffer);
+  if (Callbacks)
+Callbacks->PragmaMark(MarkTok.getLocation(), Buffer);
 }
 
 /// HandlePragmaPoison - Handle \#pragma GCC poison.  PoisonTok is the 'poison'.
@@ -992,7 +996,7 @@
 
   void HandlePragma(Preprocessor &PP, PragmaIntroducer Introducer,
 Token &MarkTok) override {
-PP.HandlePragmaMark();
+PP.HandlePragmaMark(MarkTok);
   }
 };
 
Index: clang/include/clang/Lex/Preprocessor.h
===
--- clang/include/clang/Lex/Preprocessor.h
+++ clang/include/clang/Lex/Preprocessor.h
@@ -2365,7 +2365,7 @@
 
 public:
   void HandlePragmaOnce(Token &OnceTok);
-  void HandlePragmaMark();
+  void HandlePragmaMark(Token &MarkTok);
   void HandlePragmaPoison();
   void HandlePragmaSystemHeader(Token &SysHeaderTok);
   void HandlePragmaDependency(Token &DependencyTok);
Index: clang/include/clang/Lex/PPCallbacks.h
===
--- clang/include/clang/Lex/PPCallbacks.h
+++ clang/include/clang/Lex/PPCallbacks.h
@@ -191,6 +191,10 @@
  StringRef Str) {
   }
 
+  /// Callback invoked when a \#pragma mark comment is read.
+  virtual void PragmaMark(SourceLocation Loc, StringRef Trivia) {
+  }
+
   /// Callback invoked when a \#pragma detect_mismatch directive is
   /// read.
   virtual void PragmaDetectMismatch(SourceLocation Loc, StringRef Name,

[clang] 24f4c3e - Lex: add a callback for `#pragma mark`

2021-07-02 Thread Saleem Abdulrasool via cfe-commits

Author: Saleem Abdulrasool
Date: 2021-07-02T15:44:01-07:00
New Revision: 24f4c3ebef63c7d2553132d7d9d75ea19338bcb7

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

LOG: Lex: add a callback for `#pragma mark`

Allow a preprocessor observer to be notified of mark pragmas.  Although
this does not impact code generation in any way, it is useful for other
clients, such as clangd, to be able to identify any marked regions.

Reviewed By: dgoldman

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

Added: 


Modified: 
clang/include/clang/Lex/PPCallbacks.h
clang/include/clang/Lex/Preprocessor.h
clang/lib/Lex/Pragma.cpp
clang/unittests/Lex/PPCallbacksTest.cpp

Removed: 




diff  --git a/clang/include/clang/Lex/PPCallbacks.h 
b/clang/include/clang/Lex/PPCallbacks.h
index d57be1990caf..bcf49c577735 100644
--- a/clang/include/clang/Lex/PPCallbacks.h
+++ b/clang/include/clang/Lex/PPCallbacks.h
@@ -191,6 +191,10 @@ class PPCallbacks {
  StringRef Str) {
   }
 
+  /// Callback invoked when a \#pragma mark comment is read.
+  virtual void PragmaMark(SourceLocation Loc, StringRef Trivia) {
+  }
+
   /// Callback invoked when a \#pragma detect_mismatch directive is
   /// read.
   virtual void PragmaDetectMismatch(SourceLocation Loc, StringRef Name,

diff  --git a/clang/include/clang/Lex/Preprocessor.h 
b/clang/include/clang/Lex/Preprocessor.h
index 16fbf5ea5a5b..2d6335471383 100644
--- a/clang/include/clang/Lex/Preprocessor.h
+++ b/clang/include/clang/Lex/Preprocessor.h
@@ -2365,7 +2365,7 @@ class Preprocessor {
 
 public:
   void HandlePragmaOnce(Token &OnceTok);
-  void HandlePragmaMark();
+  void HandlePragmaMark(Token &MarkTok);
   void HandlePragmaPoison();
   void HandlePragmaSystemHeader(Token &SysHeaderTok);
   void HandlePragmaDependency(Token &DependencyTok);

diff  --git a/clang/lib/Lex/Pragma.cpp b/clang/lib/Lex/Pragma.cpp
index 081b92ac21d9..c89061ba6d02 100644
--- a/clang/lib/Lex/Pragma.cpp
+++ b/clang/lib/Lex/Pragma.cpp
@@ -412,9 +412,13 @@ void Preprocessor::HandlePragmaOnce(Token &OnceTok) {
   HeaderInfo.MarkFileIncludeOnce(getCurrentFileLexer()->getFileEntry());
 }
 
-void Preprocessor::HandlePragmaMark() {
+void Preprocessor::HandlePragmaMark(Token &MarkTok) {
   assert(CurPPLexer && "No current lexer?");
-  CurLexer->ReadToEndOfLine();
+
+  SmallString<64> Buffer;
+  CurLexer->ReadToEndOfLine(&Buffer);
+  if (Callbacks)
+Callbacks->PragmaMark(MarkTok.getLocation(), Buffer);
 }
 
 /// HandlePragmaPoison - Handle \#pragma GCC poison.  PoisonTok is the 
'poison'.
@@ -992,7 +996,7 @@ struct PragmaMarkHandler : public PragmaHandler {
 
   void HandlePragma(Preprocessor &PP, PragmaIntroducer Introducer,
 Token &MarkTok) override {
-PP.HandlePragmaMark();
+PP.HandlePragmaMark(MarkTok);
   }
 };
 

diff  --git a/clang/unittests/Lex/PPCallbacksTest.cpp 
b/clang/unittests/Lex/PPCallbacksTest.cpp
index 5581f9fb82f3..f92587af8dc5 100644
--- a/clang/unittests/Lex/PPCallbacksTest.cpp
+++ b/clang/unittests/Lex/PPCallbacksTest.cpp
@@ -112,6 +112,20 @@ class PragmaOpenCLExtensionCallbacks : public PPCallbacks {
   unsigned State;
 };
 
+class PragmaMarkCallbacks : public PPCallbacks {
+public:
+  struct Mark {
+SourceLocation Location;
+std::string Trivia;
+  };
+
+  std::vector Marks;
+
+  void PragmaMark(SourceLocation Loc, StringRef Trivia) override {
+Marks.emplace_back(Mark{Loc, Trivia.str()});
+  }
+};
+
 // PPCallbacks test fixture.
 class PPCallbacksTest : public ::testing::Test {
 protected:
@@ -256,6 +270,36 @@ class PPCallbacksTest : public ::testing::Test {
 return Callbacks->Results;
   }
 
+  std::vector
+  PragmaMarkCall(const char *SourceText) {
+std::unique_ptr SourceBuf =
+llvm::MemoryBuffer::getMemBuffer(SourceText, "test.c");
+SourceMgr.setMainFileID(SourceMgr.createFileID(std::move(SourceBuf)));
+
+HeaderSearch HeaderInfo(std::make_shared(), SourceMgr,
+Diags, LangOpts, Target.get());
+TrivialModuleLoader ModLoader;
+
+Preprocessor PP(std::make_shared(), Diags, LangOpts,
+SourceMgr, HeaderInfo, ModLoader, /*IILookup=*/nullptr,
+/*OwnsHeaderSearch=*/false);
+PP.Initialize(*Target);
+
+auto *Callbacks = new PragmaMarkCallbacks;
+PP.addPPCallbacks(std::unique_ptr(Callbacks));
+
+// Lex source text.
+PP.EnterMainSourceFile();
+while (true) {
+  Token Tok;
+  PP.Lex(Tok);
+  if (Tok.is(tok::eof))
+break;
+}
+
+return Callbacks->Marks;
+  }
+
   PragmaOpenCLExtensionCallbacks::CallbackParameters
   PragmaOpenCLExtensionCall(const char *SourceText) {
 LangOptions OpenCLLangOpts;
@@ -424,6 +468,24 @@ TEST_F(PPCallbacksTest, OpenCLExten

[PATCH] D99696: [clang] NRVO: Improvements and handling of more cases.

2021-07-02 Thread Matheus Izvekov via Phabricator via cfe-commits
mizvekov added a comment.

In D99696#2856285 , @anhtuyen wrote:

> Hi Matheus @mizvekov,
> The commit 12c90e2e25dfd1d38250055efc21acb42d158912 
>  from 
> this patch seems to cause a regression, where an assertion failure starts to 
> occur with testcases such as

Hi Anh, thanks for reporting this problem!

I confirm it, can reproduce locally.
I will be working on a solution.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99696

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


[PATCH] D104847: [Clang][NVPTX] Add NVPTX intrinsics and builtins for CUDA PTX 6.5 and 7.0 WMMA and MMA instructions

2021-07-02 Thread Artem Belevich via Phabricator via cfe-commits
tra added inline comments.



Comment at: clang/test/CodeGen/builtins-nvptx-mma.cu:781-786
+  // CHECK_PTX70_SM80: call {{.*}} 
@llvm.nvvm.wmma.m16n16k8.load.c.col.stride.f32
+  // expected-error-re@+1 {{'__mma_tf32_m16n16k8_ld_c' needs target feature 
(sm_80{{.*}},(ptx70{{.*
+  __mma_tf32_m16n16k8_ld_c(fdst, fsrc, ldm, 1);
+  // CHECK_PTX70_SM80: call {{.*}} 
@llvm.nvvm.wmma.m16n16k8.load.c.row.stride.f32
+  // expected-error-re@+1 {{'__mma_tf32_m16n16k8_ld_c' needs target feature 
(sm_80{{.*}},(ptx70{{.*
+  __mma_tf32_m16n16k8_ld_c(fdst, fsrc, ldm, 0);

This looks rather odd. We're calling a `tf32` builtin, but expect to see and 
`f32` load intrinsic. Is that expected ? 





Comment at: clang/test/CodeGen/builtins-nvptx-mma.py:74
+  make_ldst_ops(["m8n8k4"], ["a", "b", "c", "d"], ["f64"]) +
+  make_ldst_ops(["m16n16k8"], ["a", "b"], ["tf32"]) +
+  make_ldst_ops(["m16n16k8"], ["c", "d"], ["f32"]))

This does not seem to match the generated `builtins-nvptx-mma.cu` which does 
have `__mma_tf32_m16n16k8_ld_c`
If I regenrate the test I see a somewhat different set of tests, possibly 
related to the oddity I've pointed in the generated test changes in this patch.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D104847

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


[PATCH] D105378: [dfsan][NFC] Add Origin Tracking into doc

2021-07-02 Thread stephan.yichao.zhao via Phabricator via cfe-commits
stephan.yichao.zhao created this revision.
stephan.yichao.zhao added a reviewer: morehouse.
stephan.yichao.zhao requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D105378

Files:
  clang/docs/DataFlowSanitizer.rst


Index: clang/docs/DataFlowSanitizer.rst
===
--- clang/docs/DataFlowSanitizer.rst
+++ clang/docs/DataFlowSanitizer.rst
@@ -191,6 +191,44 @@
 return 0;
   }
 
+Origin Tracking
+===
+
+DataFlowSanitizer can track origins of labeled values. This feature is enabled 
by
+``-mllvm -dfsan-track-origins=1``. For example,
+
+.. code-block:: console
+
+% cat test.cc
+#include 
+#include 
+
+int main(int argc, char** argv) {
+  int i = 0;
+  dfsan_set_label(i_label, &i, sizeof(i));
+  int j = i + 1;
+  dfsan_print_origin_trace(&j, "A flow from i to j");
+  return 0;
+}
+
+% clang -fsanitize=dataflow -mllvm -dfsan-track-origins=1 
-fno-omit-frame-pointer -g -O2 test.cc
+% ./a.out
+Taint value 0x1 (at 0x7ffd42bf415c) origin tracking (A flow from i to j)
+Origin value: 0x1391, Taint value was stored to memory at
+  #0 0x55676db85a62 in main test.cc:7:7
+  #1 0x7f0083611bbc in __libc_start_main libc-start.c:285
+
+Origin value: 0x9e1, Taint value was created at
+  #0 0x55676db85a08 in main test.cc:6:3
+  #1 0x7f0083611bbc in __libc_start_main libc-start.c:285
+
+By ``-mllvm -dfsan-track-origins=1`` DataFlowSanitizer collects only
+intermediate stores a labeled value went through. Origin tracking slows down
+program execution by a factor of 2x on top of the usual DataFlowSanitizer
+slowdown and increases memory overhead by 1x. By ``-mllvm 
-dfsan-track-origins=2``
+DataFlowSanitizer also collects intermediate loads a labeled value went 
through.
+This mode slows down program execution by a factor of 4x.
+
 Current status
 ==
 


Index: clang/docs/DataFlowSanitizer.rst
===
--- clang/docs/DataFlowSanitizer.rst
+++ clang/docs/DataFlowSanitizer.rst
@@ -191,6 +191,44 @@
 return 0;
   }
 
+Origin Tracking
+===
+
+DataFlowSanitizer can track origins of labeled values. This feature is enabled by
+``-mllvm -dfsan-track-origins=1``. For example,
+
+.. code-block:: console
+
+% cat test.cc
+#include 
+#include 
+
+int main(int argc, char** argv) {
+  int i = 0;
+  dfsan_set_label(i_label, &i, sizeof(i));
+  int j = i + 1;
+  dfsan_print_origin_trace(&j, "A flow from i to j");
+  return 0;
+}
+
+% clang -fsanitize=dataflow -mllvm -dfsan-track-origins=1 -fno-omit-frame-pointer -g -O2 test.cc
+% ./a.out
+Taint value 0x1 (at 0x7ffd42bf415c) origin tracking (A flow from i to j)
+Origin value: 0x1391, Taint value was stored to memory at
+  #0 0x55676db85a62 in main test.cc:7:7
+  #1 0x7f0083611bbc in __libc_start_main libc-start.c:285
+
+Origin value: 0x9e1, Taint value was created at
+  #0 0x55676db85a08 in main test.cc:6:3
+  #1 0x7f0083611bbc in __libc_start_main libc-start.c:285
+
+By ``-mllvm -dfsan-track-origins=1`` DataFlowSanitizer collects only
+intermediate stores a labeled value went through. Origin tracking slows down
+program execution by a factor of 2x on top of the usual DataFlowSanitizer
+slowdown and increases memory overhead by 1x. By ``-mllvm -dfsan-track-origins=2``
+DataFlowSanitizer also collects intermediate loads a labeled value went through.
+This mode slows down program execution by a factor of 4x.
+
 Current status
 ==
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D99696: [clang] NRVO: Improvements and handling of more cases.

2021-07-02 Thread Anh Tuyen Tran via Phabricator via cfe-commits
anhtuyen added a comment.

Hi Mathew @mizvekov,
The commit 12c90e2e25dfd1d38250055efc21acb42d158912 
 from this 
patch seems to cause a regression, where an assertion failure starts to occur 
with testcases such as

  template  int foo() {
int a alignas(A) = 0;
return a;
  }

To reproduce the issue, please try:

1. Reset the HEAD of your branch to commit 
12c90e2e25dfd1d38250055efc21acb42d158912 
, which 
was just before yours:

  git reset --hard 12c90e2e25dfd1d38250055efc21acb42d158912

2. Build llvm/clamg
3. Compile the above reduced testcase (let's call it test.cpp)

  bin/clang -std=c++11 -c test.cpp

4. There should be no warning nor error

5. Now, please pull in commit 12c90e2e25dfd1d38250055efc21acb42d158912 


  git pull origin 12c90e2e25dfd1d38250055efc21acb42d158912



6. Rebuild and rerun the above compilation command, you will see the following 
assertion failure

  clang: tools/clang/include/clang/AST/AttrImpl.inc:1750: unsigned int 
clang::AlignedAttr::getAlignment(clang::ASTContext &) const: Assertion 
`!isAlignmentDependent()' failed.

GCC does not have that assertion, either.

Can you have a look, please!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99696

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


[PATCH] D104556: [InstrProfiling] Make CountersPtr in __profd_ relative

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

I'm happy with this.




Comment at: compiler-rt/include/profile/InstrProfData.inc:79
+INSTR_PROF_DATA(const IntPtrT, IntPtrTy, CounterPtr,
+ConstantExpr::getSub(ConstantExpr::getPtrToInt(CounterPtr,
+   IntPtrTy),

I'd suggest moving this into a local variable in the instrumentation code. The 
less code there is in this header, the better.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D104556

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


[PATCH] D105368: Lex: add a callback for `#pragma mark`

2021-07-02 Thread Saleem Abdulrasool via Phabricator via cfe-commits
compnerd updated this revision to Diff 356273.
compnerd added a comment.

Correct lifetime of data in the tests.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105368

Files:
  clang/include/clang/Lex/PPCallbacks.h
  clang/include/clang/Lex/Preprocessor.h
  clang/lib/Lex/Pragma.cpp
  clang/unittests/Lex/PPCallbacksTest.cpp

Index: clang/unittests/Lex/PPCallbacksTest.cpp
===
--- clang/unittests/Lex/PPCallbacksTest.cpp
+++ clang/unittests/Lex/PPCallbacksTest.cpp
@@ -112,6 +112,20 @@
   unsigned State;
 };
 
+class PragmaMarkCallbacks : public PPCallbacks {
+public:
+  struct Mark {
+SourceLocation Location;
+std::string Trivia;
+  };
+
+  std::vector Marks;
+
+  void PragmaMark(SourceLocation Loc, StringRef Trivia) override {
+Marks.emplace_back(Mark{Loc, Trivia.str()});
+  }
+};
+
 // PPCallbacks test fixture.
 class PPCallbacksTest : public ::testing::Test {
 protected:
@@ -256,6 +270,36 @@
 return Callbacks->Results;
   }
 
+  std::vector
+  PragmaMarkCall(const char *SourceText) {
+std::unique_ptr SourceBuf =
+llvm::MemoryBuffer::getMemBuffer(SourceText, "test.c");
+SourceMgr.setMainFileID(SourceMgr.createFileID(std::move(SourceBuf)));
+
+HeaderSearch HeaderInfo(std::make_shared(), SourceMgr,
+Diags, LangOpts, Target.get());
+TrivialModuleLoader ModLoader;
+
+Preprocessor PP(std::make_shared(), Diags, LangOpts,
+SourceMgr, HeaderInfo, ModLoader, /*IILookup=*/nullptr,
+/*OwnsHeaderSearch=*/false);
+PP.Initialize(*Target);
+
+auto *Callbacks = new PragmaMarkCallbacks;
+PP.addPPCallbacks(std::unique_ptr(Callbacks));
+
+// Lex source text.
+PP.EnterMainSourceFile();
+while (true) {
+  Token Tok;
+  PP.Lex(Tok);
+  if (Tok.is(tok::eof))
+break;
+}
+
+return Callbacks->Marks;
+  }
+
   PragmaOpenCLExtensionCallbacks::CallbackParameters
   PragmaOpenCLExtensionCall(const char *SourceText) {
 LangOptions OpenCLLangOpts;
@@ -424,6 +468,24 @@
   ASSERT_EQ(ExpectedState, Parameters.State);
 }
 
+TEST_F(PPCallbacksTest, CollectMarks) {
+  const char *Source =
+"#pragma mark\n"
+"#pragma mark\r\n"
+"#pragma mark - trivia\n"
+"#pragma mark - trivia\r\n";
+
+  auto Marks = PragmaMarkCall(Source);
+
+  ASSERT_EQ(4u, Marks.size());
+  ASSERT_TRUE(Marks[0].Trivia.empty());
+  ASSERT_TRUE(Marks[1].Trivia.empty());
+  ASSERT_FALSE(Marks[2].Trivia.empty());
+  ASSERT_FALSE(Marks[3].Trivia.empty());
+  ASSERT_EQ(" - trivia", Marks[2].Trivia);
+  ASSERT_EQ(" - trivia", Marks[3].Trivia);
+}
+
 TEST_F(PPCallbacksTest, DirectiveExprRanges) {
   const auto &Results1 = DirectiveExprRange("#if FLUZZY_FLOOF\n#endif\n");
   EXPECT_EQ(Results1.size(), 1U);
Index: clang/lib/Lex/Pragma.cpp
===
--- clang/lib/Lex/Pragma.cpp
+++ clang/lib/Lex/Pragma.cpp
@@ -412,9 +412,13 @@
   HeaderInfo.MarkFileIncludeOnce(getCurrentFileLexer()->getFileEntry());
 }
 
-void Preprocessor::HandlePragmaMark() {
+void Preprocessor::HandlePragmaMark(Token &MarkTok) {
   assert(CurPPLexer && "No current lexer?");
-  CurLexer->ReadToEndOfLine();
+
+  SmallString<64> Buffer;
+  CurLexer->ReadToEndOfLine(&Buffer);
+  if (Callbacks)
+Callbacks->PragmaMark(MarkTok.getLocation(), Buffer);
 }
 
 /// HandlePragmaPoison - Handle \#pragma GCC poison.  PoisonTok is the 'poison'.
@@ -992,7 +996,7 @@
 
   void HandlePragma(Preprocessor &PP, PragmaIntroducer Introducer,
 Token &MarkTok) override {
-PP.HandlePragmaMark();
+PP.HandlePragmaMark(MarkTok);
   }
 };
 
Index: clang/include/clang/Lex/Preprocessor.h
===
--- clang/include/clang/Lex/Preprocessor.h
+++ clang/include/clang/Lex/Preprocessor.h
@@ -2365,7 +2365,7 @@
 
 public:
   void HandlePragmaOnce(Token &OnceTok);
-  void HandlePragmaMark();
+  void HandlePragmaMark(Token &MarkTok);
   void HandlePragmaPoison();
   void HandlePragmaSystemHeader(Token &SysHeaderTok);
   void HandlePragmaDependency(Token &DependencyTok);
Index: clang/include/clang/Lex/PPCallbacks.h
===
--- clang/include/clang/Lex/PPCallbacks.h
+++ clang/include/clang/Lex/PPCallbacks.h
@@ -191,6 +191,10 @@
  StringRef Str) {
   }
 
+  /// Callback invoked when a \#pragma mark comment is read.
+  virtual void PragmaMark(SourceLocation Loc, StringRef Trivia) {
+  }
+
   /// Callback invoked when a \#pragma detect_mismatch directive is
   /// read.
   virtual void PragmaDetectMismatch(SourceLocation Loc, StringRef Name,
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D105368: Lex: add a callback for `#pragma mark`

2021-07-02 Thread David Goldman via Phabricator via cfe-commits
dgoldman added inline comments.



Comment at: clang/unittests/Lex/PPCallbacksTest.cpp:119
+SourceLocation Location;
+StringRef Trivia;
+  };

should this be an std::string? not sure of the lifetime guarantees here


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105368

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


[PATCH] D103986: [PowerPC] Floating Point Builtins for XL Compat.

2021-07-02 Thread Quinn Pham via Phabricator via cfe-commits
quinnp updated this revision to Diff 356272.
quinnp marked 4 inline comments as done.
quinnp added a comment.

Fixing a typo and the format of a test.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D103986

Files:
  clang/include/clang/Basic/BuiltinsPPC.def
  clang/lib/Basic/Targets/PPC.h
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/test/CodeGen/builtins-ppc-xlcompat-fp.c
  llvm/include/llvm/IR/IntrinsicsPowerPC.td
  llvm/lib/Target/PowerPC/PPCISelDAGToDAG.cpp
  llvm/lib/Target/PowerPC/PPCInstrInfo.td
  llvm/lib/Target/PowerPC/PPCInstrVSX.td
  llvm/test/CodeGen/builtins-ppc-xlcompat-fp.ll

Index: llvm/test/CodeGen/builtins-ppc-xlcompat-fp.ll
===
--- /dev/null
+++ llvm/test/CodeGen/builtins-ppc-xlcompat-fp.ll
@@ -0,0 +1,92 @@
+; RUN: llc -verify-machineinstrs -mtriple=powerpc64-unknown-unknown \
+; RUN: -mcpu=pwr7 < %s | FileCheck %s --check-prefix=CHECK-PWR7
+; RUN: llc -verify-machineinstrs -mtriple=powerpc64le-unknown-unknown \
+; RUN: -mcpu=pwr8 < %s | FileCheck %s --check-prefix=CHECK-PWR8
+; RUN: llc -verify-machineinstrs -mtriple=powerpc64-unknown-aix \
+; RUN: -mcpu=pwr7 < %s | FileCheck %s --check-prefix=CHECK-PWR7
+; RUN: llc -verify-machineinstrs -mtriple=powerpc-unknown-aix \
+; RUN: -mcpu=pwr7 < %s | FileCheck %s --check-prefix=CHECK-PWR7
+; RUN: llc -verify-machineinstrs -mtriple=powerpc64-unknown-unknown \
+; RUN: -mattr=-vsx -mcpu=pwr7 < %s | FileCheck %s --check-prefix=CHECK-NOVSX
+; RUN: llc -verify-machineinstrs -mtriple=powerpc64le-unknown-unknown \
+; RUN: -mattr=-vsx -mcpu=pwr8 < %s | FileCheck %s --check-prefix=CHECK-NOVSX
+; RUN: llc -verify-machineinstrs -mtriple=powerpc64-unknown-aix \
+; RUN: -mattr=-vsx -mcpu=pwr7 < %s | FileCheck %s --check-prefix=CHECK-NOVSX
+; RUN: llc -verify-machineinstrs -mtriple=powerpc-unknown-aix \
+; RUN: -mattr=-vsx -mcpu=pwr7 < %s | FileCheck %s --check-prefix=CHECK-NOVSX
+
+define dso_local double @test_fsel(double %a, double %b, double %c) local_unnamed_addr {
+; CHECK-PWR7-LABEL: test_fsel 
+; CHECK-PWR8-LABEL: test_fsel
+; CHECK-NOVSX-LABEL: test_fsel
+
+entry:
+  %0 = tail call double @llvm.ppc.fsel(double %a, double %b, double %c)
+; CHECK-PWR7: fsel 1, 1, 2, 3
+; CHECK-PWR8: fsel 1, 1, 2, 3
+; CHECK-NOVSX: fsel 1, 1, 2, 3
+
+  ret double %0
+; CHECK-PWR7: blr
+; CHECK-PWR8: blr
+; CHECK-NOVSX: blr
+}
+
+declare double @llvm.ppc.fsel(double, double, double)
+
+define dso_local float @test_fsels(float %a, float %b, float %c) local_unnamed_addr {
+; CHECK-PWR7-LABEL: test_fsels
+; CHECK-PWR8-LABEL: test_fsels
+; CHECK-NOVSX-LABEL: test_fsels
+
+entry:
+  %0 = tail call float @llvm.ppc.fsels(float %a, float %b, float %c)
+; CHECK-PWR7: fsel 1, 1, 2, 3
+; CHECK-PWR8: fsel 1, 1, 2, 3
+; CHECK-NOVSX: fsel 1, 1, 2, 3
+
+  ret float %0
+; CHECK-PWR7: blr
+; CHECK-PWR8: blr
+; CHECK-NOVSX: blr
+}
+
+declare float @llvm.ppc.fsels(float, float, float)
+
+define dso_local double @test_frsqrte(double %a) local_unnamed_addr {
+; CHECK-PWR7-LABEL: test_frsqrte
+; CHECK-PWR8-LABEL: test_frsqrte
+; CHECK-NOVSX-LABEL: test_frsqrte
+
+entry:
+  %0 = tail call double @llvm.ppc.frsqrte(double %a)
+; CHECK-PWR7: xsrsqrtedp 1, 1
+; CHECK-PWR8: xsrsqrtedp 1, 1
+; CHECK-NOVSX: frsqrte 1, 1
+
+  ret double %0
+; CHECK-PWR7: blr
+; CHECK-PWR8: blr
+; CHECK-NOVSX: blr
+}
+
+declare double @llvm.ppc.frsqrte(double)
+
+define dso_local float @test_frsqrtes(float %a) local_unnamed_addr {
+; CHECK-PWR7-LABEL: test_frsqrtes
+; CHECK-PWR8-LABEL: test_frsqrtes
+; CHECK-NOVSX-LABEL: test_frsqrtes
+
+entry:
+  %0 = tail call float @llvm.ppc.frsqrtes(float %a)
+; CHECK-PWR7: frsqrtes 1, 1
+; CHECK-PWR8: xsrsqrtesp 1, 1
+; CHECK-NOVSX: frsqrtes 1, 1 
+
+  ret float %0
+; CHECK-PWR7: blr
+; CHECK-PWR8: blr
+; CHECK-NOVSX: blr
+}
+
+declare float @llvm.ppc.frsqrtes(float)
Index: llvm/lib/Target/PowerPC/PPCInstrVSX.td
===
--- llvm/lib/Target/PowerPC/PPCInstrVSX.td
+++ llvm/lib/Target/PowerPC/PPCInstrVSX.td
@@ -2850,6 +2850,8 @@
 def : Pat<(v2i64 (PPCvcmp_rec v2i64:$vA, v2i64:$vB, 199)),
   (VCMPGTUB_rec DblwdCmp.MRGEQ, (v2i64 (XXLXORz)))>;
 } // AddedComplexity = 0
+
+def : Pat<(int_ppc_frsqrte vsfrc:$XB), (XSRSQRTEDP $XB)>;
 } // HasVSX
 
 // Any big endian VSX subtarget.
@@ -3240,6 +3242,8 @@
   (v8i16 (COPY_TO_REGCLASS(XXLEQVOnes), VSRC))>;
 def : Pat<(v16i8 (bitconvert (v16i8 immAllOnesV))),
   (v16i8 (COPY_TO_REGCLASS(XXLEQVOnes), VSRC))>;
+
+def : Pat<(int_ppc_frsqrtes vssrc:$XB), (XSRSQRTESP $XB)>;
 } // HasVSX, HasP8Vector
 
 // Any big endian Power8 VSX subtarget.
Index: llvm/lib/Target/PowerPC/PPCInstrInfo.td
===
--- llvm/lib/Target/PowerPC/PPCInstrInfo.td
+++ llvm/lib/Target/PowerPC/PPCInstrInfo.td
@@ -4382,6 +4382,10 @@
 def : Pat<(i1 (not (trunc i64:$in))),
(ANDI_rec_1

[PATCH] D105375: [OPENMP]Remove const firstprivate allocation as a variable in a constant space.

2021-07-02 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev created this revision.
ABataev added reviewers: jdoerfert, vzakharin, mikerice.
Herald added subscribers: guansong, yaxunl.
ABataev requested review of this revision.
Herald added a subscriber: sstefan1.
Herald added a project: clang.

Current implementation is not compatible with asynchronous target
regions, need to remove it.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D105375

Files:
  clang/lib/CodeGen/CGOpenMPRuntime.cpp
  clang/lib/CodeGen/CGOpenMPRuntime.h
  clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp
  clang/lib/CodeGen/CGOpenMPRuntimeGPU.h
  clang/lib/CodeGen/CGStmtOpenMP.cpp
  clang/test/OpenMP/nvptx_target_firstprivate_codegen.cpp
  clang/test/OpenMP/target_firstprivate_codegen.cpp

Index: clang/test/OpenMP/target_firstprivate_codegen.cpp
===
--- clang/test/OpenMP/target_firstprivate_codegen.cpp
+++ clang/test/OpenMP/target_firstprivate_codegen.cpp
@@ -55,12 +55,11 @@
 // TCHECK-DAG:  [[TTII:%.+]] = type { i32, i32 }
 // TCHECK-DAG:  [[S1:%.+]] = type { double }
 
-// CHECK-DAG:  [[FP_E:@__omp_offloading_firstprivate_.+_e_l79]] = internal global [[TTII]] zeroinitializer
 // CHECK-DAG:  [[SIZET:@.+]] = private unnamed_addr constant [3 x i{{32|64}}] [i[[SZ:32|64]] 4, i{{64|32}} {{8|4}}, i[[SZ:32|64]] 4]
 // CHECK-DAG:  [[MAPT:@.+]] = private unnamed_addr constant [3 x i64] [i64 288, i64 49, i64 288]
 // CHECK-DAG:  [[MAPT2:@.+]] = private unnamed_addr constant [9 x i64] [i64 288, i64 161, i64 800, i64 161, i64 161, i64 800, i64 800, i64 161, i64 161]
 // CHECK-DAG:  [[SIZET3:@.+]] = private unnamed_addr constant [2 x i{{32|64}}] [i{{32|64}} 0, i{{32|64}} 8]
-// CHECK-DAG:  [[MAPT3:@.+]] = private unnamed_addr constant [2 x i64] [i64 32, i64 37]
+// CHECK-DAG:  [[MAPT3:@.+]] = private unnamed_addr constant [2 x i64] [i64 32, i64 161]
 // CHECK-DAG:  [[MAPT4:@.+]] = private unnamed_addr constant [5 x i64] [i64 547, i64 288, i64 800, i64 800, i64 161]
 // CHECK-DAG:  [[SIZET5:@.+]] = private unnamed_addr constant [3 x i{{32|64}}] [i[[SZ]] 4, i[[SZ]] 1, i[[SZ]] 40]
 // CHECK-DAG:  [[MAPT5:@.+]] = private unnamed_addr constant [3 x i64] [i64 288, i64 288, i64 161]
@@ -92,6 +91,7 @@
   // CHECK:  [[SSTACK:%.+]] = alloca i8*,
   // CHECK:  [[C:%.+]] = alloca [5 x [10 x double]],
   // CHECK:  [[D:%.+]] = alloca [[TT]],
+  // CHECK:  [[FP_E:%.+]] = alloca [[TTII]],
   // CHECK:  [[P:%.+]] = alloca i32*, align 64
   // CHECK:  [[ACAST:%.+]] = alloca i{{[0-9]+}},
   // CHECK:  [[BASE_PTR_ARR:%.+]] = alloca [3 x i8*],
@@ -347,8 +347,6 @@
   }
   // CHECK:  [[PTR_ADDR_REF:%.+]] = load double*, double** [[PTR_ADDR]],
 
-  // CHECK:  [[E_BC:%.+]] = bitcast [[TTII]]* [[E:%.+]] to i8*
-  // CHECK:  call void @llvm.memcpy.p0i8.p0i8.i{{64|32}}(i8* {{.*}} bitcast ([[TTII]]* [[FP_E]] to i8*), i8* {{.*}} [[E_BC]], i{{64|32}} 8, i1 false)
   // CHECK:  [[BASE_PTR_GEP3_0:%.+]] = getelementptr inbounds [2 x i8*], [2 x i8*]* [[BASE_PTR_ARR3]], i{{[0-9]+}} 0, i{{[0-9]+}} 0
   // CHECK:  [[BCAST_TOPTR:%.+]] = bitcast i8** [[BASE_PTR_GEP3_0]] to double**
   // CHECK:  store double* [[PTR_ADDR_REF]], double** [[BCAST_TOPTR]],
@@ -367,9 +365,8 @@
   // CHECK: {{.+}} = call i32 @__tgt_target_mapper(%struct.ident_t* @{{.+}}, i64 -1, {{.+}}, i32 2, i8** [[BASE_PTR_GEP_ARG3]], i8** [[PTR_GEP_ARG3]], i[[SZ]]* getelementptr inbounds ([2 x i[[SZ]]], [2 x i[[SZ]]]* [[SIZET3]], i32 0, i32 0), i64* getelementptr inbounds ([2 x i64], [2 x i64]* [[MAPT3]], i32 0, i32 0), i8** null, i8** null)
 
   // TCHECK:  define weak void @__omp_offloading_{{.+}}(double* [[PTR_IN:%.+]], [[TTII]]* nonnull align {{[0-9]+}} dereferenceable({{[0-9]+}}) [[E:%.+]])
-  // TCHECK-NOT: alloca [[TTII]],
   // TCHECK:  [[PTR_ADDR:%.+]] = alloca double*,
-  // TCHECK-NOT: alloca [[TTII]],
+  // TCHECK: alloca [[TTII]],
   // TCHECK-NOT: alloca double*,
   // TCHECK:  store double* [[PTR_IN]], double** [[PTR_ADDR]],
   // TCHECK-NOT: store double* %
Index: clang/test/OpenMP/nvptx_target_firstprivate_codegen.cpp
===
--- clang/test/OpenMP/nvptx_target_firstprivate_codegen.cpp
+++ clang/test/OpenMP/nvptx_target_firstprivate_codegen.cpp
@@ -18,9 +18,6 @@
 // TCHECK-DAG:  [[TT:%.+]] = type { i64, i8 }
 // TCHECK-DAG:  [[S1:%.+]] = type { double }
 
-// TCHECK: @__omp_offloading_firstprivate__{{.+}}_e_l30 = internal addrspace(4) global [[TTII]] zeroinitializer
-// TCHECK: @__omp_offloading_firstprivate__{{.+}}_ZTSK2TTIiiE_t_l143 = internal addrspace(4) global [[TTII]] zeroinitializer
-// TCHECK: @__omp_offloading_firstprivate__{{.+}}_ZTSK2TTIccE_t_l143 = internal addrspace(4) global [[TTIC]] zeroinitializer
 int foo(int n, double *ptr) {
   int a = 0;
   short aa = 0;
@@ -37,11 +34,9 @@
   }
 
   // TCHECK:  define {{.*}}void @__omp_offloading_{{.+}}([10 x float] addrspace(1)* noalias [[B_IN:%.+]], i{{[0-9]+}} [[A_IN:%.+]], [[TTII]]* noalias [[E_IN:%.+]])
-  // TCHECK-NOT: alloca [[TTII]],
   // TCHECK:  [[A_ADDR:%.+]

[PATCH] D103986: [PowerPC] Floating Point Builtins for XL Compat.

2021-07-02 Thread Quinn Pham via Phabricator via cfe-commits
quinnp updated this revision to Diff 356264.
quinnp marked an inline comment as done.
quinnp added a comment.

Addressing review comments.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D103986

Files:
  clang/include/clang/Basic/BuiltinsPPC.def
  clang/lib/Basic/Targets/PPC.h
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/test/CodeGen/builtins-ppc-xlcompat-fp.c
  llvm/include/llvm/IR/IntrinsicsPowerPC.td
  llvm/lib/Target/PowerPC/PPCISelDAGToDAG.cpp
  llvm/lib/Target/PowerPC/PPCInstrInfo.td
  llvm/lib/Target/PowerPC/PPCInstrVSX.td
  llvm/test/CodeGen/builtins-ppc-xlcompat-fp.ll

Index: llvm/test/CodeGen/builtins-ppc-xlcompat-fp.ll
===
--- /dev/null
+++ llvm/test/CodeGen/builtins-ppc-xlcompat-fp.ll
@@ -0,0 +1,92 @@
+; RUN: llc -verify-machineinstrs -mtriple=powerpc64-unknown-unknown \
+; RUN: -mcpu=pwr7 < %s | FileCheck %s --check-prefix=CHECK-PWR7
+; RUN: llc -verify-machineinstrs -mtriple=powerpc64le-unknown-unknown \
+; RUN: -mcpu=pwr8 < %s | FileCheck %s --check-prefix=CHECK-PWR8
+; RUN: llc -verify-machineinstrs -mtriple=powerpc64-unknown-aix \
+; RUN: -mcpu=pwr7 < %s | FileCheck %s --check-prefix=CHECK-PWR7
+; RUN: llc -verify-machineinstrs -mtriple=powerpc-unknown-aix \
+; RUN: -mcpu=pwr7 < %s | FileCheck %s --check-prefix=CHECK-PWR7
+; RUN: llc -verify-machineinstrs -mtriple=powerpc64-unknown-unknown \
+; RUN: -mattr=-vsx -mcpu=pwr7 < %s | FileCheck %s --check-prefix=CHECK-NOVSX
+; RUN: llc -verify-machineinstrs -mtriple=powerpc64le-unknown-unknown \
+; RUN: -mattr=-vsx -mcpu=pwr8 < %s | FileCheck %s --check-prefix=CHECK-NOVSX
+; RUN: llc -verify-machineinstrs -mtriple=powerpc64-unknown-aix \
+; RUN: -mattr=-vsx -mcpu=pwr7 < %s | FileCheck %s --check-prefix=CHECK-NOVSX
+; RUN: llc -verify-machineinstrs -mtriple=powerpc-unknown-aix \
+; RUN: -mattr=-vsx -mcpu=pwr7 < %s | FileCheck %s --check-prefix=CHECK-NOVSX
+
+define dso_local double @test_fsel(double %a, double %b, double %c) local_unnamed_addr {
+; CHECK-PWR7-LABEL: test_fsel 
+; CHECK-PWR8-LABEL: test_fsel
+; CHECK-NOVSX-LABEL: test_fsel
+
+entry:
+  %0 = tail call double @llvm.ppc.fsel(double %a, double %b, double %c)
+; CHECK-PWR7: fsel 1, 1, 2, 3
+; CHECK-PWR8: fsel 1, 1, 2, 3
+; CHECK-NOVSX: fsel 1, 1, 2, 3
+
+  ret double %0
+; CHECK-PWR7: blr
+; CHECK-PWR8: blr
+; CHECK-NOVSX: blr
+}
+
+declare double @llvm.ppc.fsel(double, double, double)
+
+define dso_local float @test_fsels(float %a, float %b, float %c) local_unnamed_addr {
+; CHECK-PWR7-LABEL: test_fsels
+; CHECK-PWR8-LABEL: test_fsels
+; CHECK-NOVSX-LABEL: test_fsels
+
+entry:
+  %0 = tail call float @llvm.ppc.fsels(float %a, float %b, float %c)
+; CHECK-PWR7: fsel 1, 1, 2, 3
+; CHECK-PWR8: fsel 1, 1, 2, 3
+; CHECK-NOVSX: fsel 1, 1, 2, 3
+
+  ret float %0
+; CHECK-PWR7: blr
+; CHECK-PWR8: blr
+; CHECK-NOVSX: blr
+}
+
+declare float @llvm.ppc.fsels(float, float, float)
+
+define dso_local double @test_frsqrte(double %a) local_unnamed_addr {
+; CHECK-PWR7-LABEL: test_frsqrte
+; CHECK-PWR8-LABEL: test_frsqrte
+; CHECK-NOVSX-LABEL: test_frsqrte
+
+entry:
+  %0 = tail call double @llvm.ppc.frsqrte(double %a)
+; CHECK-PWR7: xsrsqrtedp 1, 1
+; CHECK-PWR8: xsrsqrtedp 1, 1
+; CHECK-NOVSX: frsqrte 1, 1
+
+  ret double %0
+; CHECK-PWR7: blr
+; CHECK-PWR8: blr
+; CHECK-NOVSX: blr
+}
+
+declare double @llvm.ppc.frsqrte(double)
+
+define dso_local float @test_frsqrtes(float %a) local_unnamed_addr {
+; CHECK-PWR7-LABEL: test_frsqrtes
+; CHECK-PWR8-LABEL: test_frsqrtes
+; CHECK-NOVSX-LABEL: test_frsqrtes
+
+entry:
+  %0 = tail call float @llvm.ppc.frsqrtes(float %a)
+; CHECK-PWR7: frsqrtes 1, 1
+; CHECK-PWR8: xsrsqrtesp 1, 1
+; CHECK-NOVSX: frsqrtes 1, 1 
+
+  ret float %0
+; CHECK-PWR7: blr
+; CHECK-PWR8: blr
+; CHECK-NOVSX: blr
+}
+
+declare float @llvm.ppc.frsqrtes(float)
Index: llvm/lib/Target/PowerPC/PPCInstrVSX.td
===
--- llvm/lib/Target/PowerPC/PPCInstrVSX.td
+++ llvm/lib/Target/PowerPC/PPCInstrVSX.td
@@ -2850,6 +2850,8 @@
 def : Pat<(v2i64 (PPCvcmp_rec v2i64:$vA, v2i64:$vB, 199)),
   (VCMPGTUB_rec DblwdCmp.MRGEQ, (v2i64 (XXLXORz)))>;
 } // AddedComplexity = 0
+
+def : Pat<(int_ppc_frsqrte vsfrc:$XB), (XSRSQRTEDP $XB)>;
 } // HasVSX
 
 // Any big endian VSX subtarget.
@@ -3240,6 +3242,8 @@
   (v8i16 (COPY_TO_REGCLASS(XXLEQVOnes), VSRC))>;
 def : Pat<(v16i8 (bitconvert (v16i8 immAllOnesV))),
   (v16i8 (COPY_TO_REGCLASS(XXLEQVOnes), VSRC))>;
+
+def : Pat<(int_ppc_frsqrtes vssrc:$XB), (XSRSQRTESP $XB)>;
 } // HasVSX, HasP8Vector
 
 // Any big endian Power8 VSX subtarget.
Index: llvm/lib/Target/PowerPC/PPCInstrInfo.td
===
--- llvm/lib/Target/PowerPC/PPCInstrInfo.td
+++ llvm/lib/Target/PowerPC/PPCInstrInfo.td
@@ -4382,6 +4382,10 @@
 def : Pat<(i1 (not (trunc i64:$in))),
(ANDI_rec_1_EQ_BIT8 $in

[PATCH] D103440: [WIP][analyzer] Introduce range-based reasoning for addition operator

2021-07-02 Thread Manas Gupta via Phabricator via cfe-commits
manas updated this revision to Diff 356256.
manas added a comment.

Rebase


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D103440

Files:
  clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
  clang/test/Analysis/constant-folding.c

Index: clang/test/Analysis/constant-folding.c
===
--- clang/test/Analysis/constant-folding.c
+++ clang/test/Analysis/constant-folding.c
@@ -251,3 +251,104 @@
 clang_analyzer_eval((b % a) < x + 10); // expected-warning{{TRUE}}
   }
 }
+
+void testAdditionRules(unsigned int a, unsigned int b, int c, int d) {
+  if (a == 0) {
+clang_analyzer_eval((a + 0) == 0); // expected-warning{{TRUE}}
+  }
+
+  // Overflows on both ends
+  if (a >= 5 && a <= UINT_MAX - 5 && b <= 10) {
+clang_analyzer_eval((a + b) >= UINT_MAX >> 1); // expected-warning{{UNKNOWN}}
+clang_analyzer_eval((a + b) <= UINT_MAX >> 1); // expected-warning{{UNKNOWN}}
+  }
+
+  if (c >= INT_MIN + 5 && c <= INT_MAX - 5 && d >= -10 && d <= 10) {
+clang_analyzer_eval((c + d) <= 0); // expected-warning{{UNKNOWN}}
+clang_analyzer_eval((c + d) >= 0); // expected-warning{{UNKNOWN}}
+  }
+
+  // Checks for unsigned operands
+  clang_analyzer_eval((a + b) < 0); // expected-warning{{FALSE}}
+  clang_analyzer_eval((a + b) <= UINT_MAX); // expected-warning{{TRUE}}
+
+  if (a == UINT_MAX && b == UINT_MAX) {
+clang_analyzer_eval((a + b) == UINT_MAX - 1); // expected-warning{{TRUE}}
+  }
+
+  // Checks for inclusive ranges for unsigned integers
+  if (a <= 10 && b <= 20) {
+clang_analyzer_eval((a + b) >= 0); // expected-warning{{TRUE}}
+clang_analyzer_eval((a + b) > 30); // expected-warning{{FALSE}}
+  }
+
+  // Checks for negative signed integers
+  if (c < 0 && d < 0) {
+clang_analyzer_eval((c + d) != -1); // expected-warning{{TRUE}}
+  }
+
+  if (c < 0 && c != INT_MIN && d < 0) {
+clang_analyzer_eval((c + d) == -1); // expected-warning{{FALSE}}
+clang_analyzer_eval((c + d) == 0); // expected-warning{{FALSE}}
+clang_analyzer_eval((c + d) <= -2); // expected-warning{{UNKNOWN}}
+clang_analyzer_eval((c + d) >= 1); // expected-warning{{UNKNOWN}}
+  }
+
+  if (c == INT_MIN && d == INT_MIN) {
+clang_analyzer_eval((c + d) == 0); // expected-warning{{TRUE}}
+  }
+
+  if (c == INT_MIN && d < 0 && d != INT_MIN) {
+clang_analyzer_eval((c + d) > 0); // expected-warning{{TRUE}}
+  }
+
+  if (c < 0 && c >= -20 && d < 0 && d >= -40) {
+clang_analyzer_eval((c + d) < -1); // expected-warning{{TRUE}}
+clang_analyzer_eval((c + d) >= -60); // expected-warning{{TRUE}}
+  }
+
+  // Checks for integers with different sign bits
+  if (c < 0 && d > 0) {
+if (c >= -20 && d <= 10) {
+  clang_analyzer_eval((c + d) > -20); // expected-warning{{TRUE}}
+  clang_analyzer_eval((c + d) < 10); // expected-warning{{TRUE}}
+}
+  }
+
+  // Checks for overlapping signed integers ranges
+  if (c >= -20 && c <= 20 && d >= -10 && d <= 10) {
+clang_analyzer_eval((c + d) >= -30); // expected-warning{{TRUE}}
+clang_analyzer_eval((c + d) <= 30); // expected-warning{{TRUE}}
+  }
+
+  // Checks for positive signed integers
+  if (c > 0 && d > 0) {
+clang_analyzer_eval((c + d) == 1); // expected-warning{{FALSE}}
+clang_analyzer_eval((c + d) == 0); // expected-warning{{FALSE}}
+clang_analyzer_eval((c + d) == -1); // expected-warning{{FALSE}}
+  }
+
+  // Check when Max overflows from positive-side
+  if (c >= 10 && d >= 0 && d <= 10) {
+clang_analyzer_eval((c + d) == INT_MIN + 10); // expected-warning{{FALSE}}
+clang_analyzer_eval((c + d) == -1); // expected-warning{{FALSE}}
+  }
+
+  // Checks when Min overflows from negative side
+  if (c <= 10 && d >= -10 && d <= 0) {
+clang_analyzer_eval((c + d) == 11); // expected-warning{{FALSE}}
+clang_analyzer_eval((c + d) == INT_MAX - 10); // expected-warning{{FALSE}}
+  }
+
+  // Checks producing overflowing range with different signs
+  int HALF_INT_MAX = INT_MAX / 2;
+  if (c >= HALF_INT_MAX - 10 && c <= HALF_INT_MAX + 10 &&
+  d >= HALF_INT_MAX - 10 && d <= HALF_INT_MAX + 10) {
+// The resulting range for (c + d) will be:
+//   [INT_MIN, INT_MIN + 18] U [INT_MAX - 21, INT_MAX]
+clang_analyzer_eval((c + d) <= INT_MIN + 18); // expected-warning{{UNKNOWN}}
+clang_analyzer_eval((c + d) >= INT_MAX - 21); // expected-warning{{UNKNOWN}}
+clang_analyzer_eval((c + d) == INT_MIN + 19); // expected-warning{{FALSE}}
+clang_analyzer_eval((c + d) == INT_MAX - 22); // expected-warning{{FALSE}}
+  }
+}
Index: clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
===
--- clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
+++ clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
@@ -17,6 +17,7 @@
 #include "clang/StaticAnalyzer/Core/PathSensitive/ProgramStateTrait.h"
 #include "

[PATCH] D105368: Lex: add a callback for `#pragma mark`

2021-07-02 Thread Saleem Abdulrasool via Phabricator via cfe-commits
compnerd created this revision.
compnerd added reviewers: dgoldman, rsmith, aaron.ballman.
Herald added subscribers: usaxena95, kadircet, kbarton, nemanjai.
compnerd requested review of this revision.
Herald added a subscriber: ilya-biryukov.
Herald added a project: clang.

Allow a preprocessor observer to be notified of mark pragmas.  Although
this does not impact code generation in any way, it is useful for other
clients, such as clangd, to be able to identify any marked regions.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D105368

Files:
  clang/include/clang/Lex/PPCallbacks.h
  clang/include/clang/Lex/Preprocessor.h
  clang/lib/Lex/Pragma.cpp
  clang/unittests/Lex/PPCallbacksTest.cpp

Index: clang/unittests/Lex/PPCallbacksTest.cpp
===
--- clang/unittests/Lex/PPCallbacksTest.cpp
+++ clang/unittests/Lex/PPCallbacksTest.cpp
@@ -112,6 +112,20 @@
   unsigned State;
 };
 
+class PragmaMarkCallbacks : public PPCallbacks {
+public:
+  struct Mark {
+SourceLocation Location;
+StringRef Trivia;
+  };
+
+  std::vector Marks;
+
+  void PragmaMark(SourceLocation Loc, StringRef Trivia) override {
+Marks.emplace_back(Mark{Loc, Trivia});
+  }
+};
+
 // PPCallbacks test fixture.
 class PPCallbacksTest : public ::testing::Test {
 protected:
@@ -256,6 +270,36 @@
 return Callbacks->Results;
   }
 
+  std::vector
+  PragmaMarkCall(const char *SourceText) {
+std::unique_ptr SourceBuf =
+llvm::MemoryBuffer::getMemBuffer(SourceText, "test.c");
+SourceMgr.setMainFileID(SourceMgr.createFileID(std::move(SourceBuf)));
+
+HeaderSearch HeaderInfo(std::make_shared(), SourceMgr,
+Diags, LangOpts, Target.get());
+TrivialModuleLoader ModLoader;
+
+Preprocessor PP(std::make_shared(), Diags, LangOpts,
+SourceMgr, HeaderInfo, ModLoader, /*IILookup=*/nullptr,
+/*OwnsHeaderSearch=*/false);
+PP.Initialize(*Target);
+
+auto *Callbacks = new PragmaMarkCallbacks;
+PP.addPPCallbacks(std::unique_ptr(Callbacks));
+
+// Lex source text.
+PP.EnterMainSourceFile();
+while (true) {
+  Token Tok;
+  PP.Lex(Tok);
+  if (Tok.is(tok::eof))
+break;
+}
+
+return Callbacks->Marks;
+  }
+
   PragmaOpenCLExtensionCallbacks::CallbackParameters
   PragmaOpenCLExtensionCall(const char *SourceText) {
 LangOptions OpenCLLangOpts;
@@ -424,6 +468,24 @@
   ASSERT_EQ(ExpectedState, Parameters.State);
 }
 
+TEST_F(PPCallbacksTest, CollectMarks) {
+  const char *Source =
+"#pragma mark\n"
+"#pragma mark\r\n"
+"#pragma mark - trivia\n"
+"#pragma mark - trivia\r\n";
+
+  auto Marks = PragmaMarkCall(Source);
+
+  ASSERT_EQ(4u, Marks.size());
+  ASSERT_TRUE(Marks[0].Trivia.empty());
+  ASSERT_TRUE(Marks[1].Trivia.empty());
+  ASSERT_FALSE(Marks[2].Trivia.empty());
+  ASSERT_FALSE(Marks[3].Trivia.empty());
+  ASSERT_EQ(" - trivia", Marks[2].Trivia);
+  ASSERT_EQ(" - trivia", Marks[3].Trivia);
+}
+
 TEST_F(PPCallbacksTest, DirectiveExprRanges) {
   const auto &Results1 = DirectiveExprRange("#if FLUZZY_FLOOF\n#endif\n");
   EXPECT_EQ(Results1.size(), 1U);
Index: clang/lib/Lex/Pragma.cpp
===
--- clang/lib/Lex/Pragma.cpp
+++ clang/lib/Lex/Pragma.cpp
@@ -412,9 +412,13 @@
   HeaderInfo.MarkFileIncludeOnce(getCurrentFileLexer()->getFileEntry());
 }
 
-void Preprocessor::HandlePragmaMark() {
+void Preprocessor::HandlePragmaMark(Token &MarkTok) {
   assert(CurPPLexer && "No current lexer?");
-  CurLexer->ReadToEndOfLine();
+
+  SmallString<64> Buffer;
+  CurLexer->ReadToEndOfLine(&Buffer);
+  if (Callbacks)
+Callbacks->PragmaMark(MarkTok.getLocation(), Buffer);
 }
 
 /// HandlePragmaPoison - Handle \#pragma GCC poison.  PoisonTok is the 'poison'.
@@ -992,7 +996,7 @@
 
   void HandlePragma(Preprocessor &PP, PragmaIntroducer Introducer,
 Token &MarkTok) override {
-PP.HandlePragmaMark();
+PP.HandlePragmaMark(MarkTok);
   }
 };
 
Index: clang/include/clang/Lex/Preprocessor.h
===
--- clang/include/clang/Lex/Preprocessor.h
+++ clang/include/clang/Lex/Preprocessor.h
@@ -2365,7 +2365,7 @@
 
 public:
   void HandlePragmaOnce(Token &OnceTok);
-  void HandlePragmaMark();
+  void HandlePragmaMark(Token &MarkTok);
   void HandlePragmaPoison();
   void HandlePragmaSystemHeader(Token &SysHeaderTok);
   void HandlePragmaDependency(Token &DependencyTok);
Index: clang/include/clang/Lex/PPCallbacks.h
===
--- clang/include/clang/Lex/PPCallbacks.h
+++ clang/include/clang/Lex/PPCallbacks.h
@@ -191,6 +191,10 @@
  StringRef Str) {
   }
 
+  /// Callback invoked when a \#pragma mark comment is read.
+  virtual void PragmaMark(SourceLocation Loc, StringRef Trivia) {
+  }
+
   /// Callback invoked 

[clang] 5d689cf - [NFC][CUDA] Fix order of round(f) definition in __clang_cuda_math.h for non-LP64.

2021-07-02 Thread Joachim Meyer via cfe-commits

Author: Joachim Meyer
Date: 2021-07-02T21:55:48+02:00
New Revision: 5d689cf2a667d8dc51768400455e0ecc55d19eaf

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

LOG: [NFC][CUDA] Fix order of round(f) definition in __clang_cuda_math.h for 
non-LP64.

This broke ARM builds e.g.: 
https://lab.llvm.org/buildbot/#/builders/187/builds/212

Added: 


Modified: 
clang/lib/Headers/__clang_cuda_math.h

Removed: 




diff  --git a/clang/lib/Headers/__clang_cuda_math.h 
b/clang/lib/Headers/__clang_cuda_math.h
index acb26ad345d59..538556f394da4 100644
--- a/clang/lib/Headers/__clang_cuda_math.h
+++ b/clang/lib/Headers/__clang_cuda_math.h
@@ -166,6 +166,8 @@ __DEVICE__ long long llrint(double __a) { return 
__nv_llrint(__a); }
 __DEVICE__ long long llrintf(float __a) { return __nv_llrintf(__a); }
 __DEVICE__ long long llround(double __a) { return __nv_llround(__a); }
 __DEVICE__ long long llroundf(float __a) { return __nv_llroundf(__a); }
+__DEVICE__ double round(double __a) { return __nv_round(__a); }
+__DEVICE__ float roundf(float __a) { return __nv_roundf(__a); }
 __DEVICE__ double log(double __a) { return __nv_log(__a); }
 __DEVICE__ double log10(double __a) { return __nv_log10(__a); }
 __DEVICE__ float log10f(float __a) { return __nv_log10f(__a); }
@@ -270,8 +272,6 @@ __DEVICE__ float rnorm4df(float __a, float __b, float __c, 
float __d) {
 __DEVICE__ float rnormf(int __dim, const float *__t) {
   return __nv_rnormf(__dim, __t);
 }
-__DEVICE__ double round(double __a) { return __nv_round(__a); }
-__DEVICE__ float roundf(float __a) { return __nv_roundf(__a); }
 __DEVICE__ double rsqrt(double __a) { return __nv_rsqrt(__a); }
 __DEVICE__ float rsqrtf(float __a) { return __nv_rsqrtf(__a); }
 __DEVICE__ double scalbn(double __a, int __b) { return __nv_scalbn(__a, __b); }



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


[PATCH] D103440: [WIP][analyzer] Introduce range-based reasoning for addition operator

2021-07-02 Thread Manas Gupta via Phabricator via cfe-commits
manas updated this revision to Diff 356250.
manas added a comment.

Replace literal-value 0 with APSInt Zero


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D103440

Files:
  clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
  clang/test/Analysis/constant-folding.c

Index: clang/test/Analysis/constant-folding.c
===
--- clang/test/Analysis/constant-folding.c
+++ clang/test/Analysis/constant-folding.c
@@ -251,3 +251,104 @@
 clang_analyzer_eval((b % a) < x + 10); // expected-warning{{TRUE}}
   }
 }
+
+void testAdditionRules(unsigned int a, unsigned int b, int c, int d) {
+  if (a == 0) {
+clang_analyzer_eval((a + 0) == 0); // expected-warning{{TRUE}}
+  }
+
+  // Overflows on both ends
+  if (a >= 5 && a <= UINT_MAX - 5 && b <= 10) {
+clang_analyzer_eval((a + b) >= UINT_MAX >> 1); // expected-warning{{UNKNOWN}}
+clang_analyzer_eval((a + b) <= UINT_MAX >> 1); // expected-warning{{UNKNOWN}}
+  }
+
+  if (c >= INT_MIN + 5 && c <= INT_MAX - 5 && d >= -10 && d <= 10) {
+clang_analyzer_eval((c + d) <= 0); // expected-warning{{UNKNOWN}}
+clang_analyzer_eval((c + d) >= 0); // expected-warning{{UNKNOWN}}
+  }
+
+  // Checks for unsigned operands
+  clang_analyzer_eval((a + b) < 0); // expected-warning{{FALSE}}
+  clang_analyzer_eval((a + b) <= UINT_MAX); // expected-warning{{TRUE}}
+
+  if (a == UINT_MAX && b == UINT_MAX) {
+clang_analyzer_eval((a + b) == UINT_MAX - 1); // expected-warning{{TRUE}}
+  }
+
+  // Checks for inclusive ranges for unsigned integers
+  if (a <= 10 && b <= 20) {
+clang_analyzer_eval((a + b) >= 0); // expected-warning{{TRUE}}
+clang_analyzer_eval((a + b) > 30); // expected-warning{{FALSE}}
+  }
+
+  // Checks for negative signed integers
+  if (c < 0 && d < 0) {
+clang_analyzer_eval((c + d) != -1); // expected-warning{{TRUE}}
+  }
+
+  if (c < 0 && c != INT_MIN && d < 0) {
+clang_analyzer_eval((c + d) == -1); // expected-warning{{FALSE}}
+clang_analyzer_eval((c + d) == 0); // expected-warning{{FALSE}}
+clang_analyzer_eval((c + d) <= -2); // expected-warning{{UNKNOWN}}
+clang_analyzer_eval((c + d) >= 1); // expected-warning{{UNKNOWN}}
+  }
+
+  if (c == INT_MIN && d == INT_MIN) {
+clang_analyzer_eval((c + d) == 0); // expected-warning{{TRUE}}
+  }
+
+  if (c == INT_MIN && d < 0 && d != INT_MIN) {
+clang_analyzer_eval((c + d) > 0); // expected-warning{{TRUE}}
+  }
+
+  if (c < 0 && c >= -20 && d < 0 && d >= -40) {
+clang_analyzer_eval((c + d) < -1); // expected-warning{{TRUE}}
+clang_analyzer_eval((c + d) >= -60); // expected-warning{{TRUE}}
+  }
+
+  // Checks for integers with different sign bits
+  if (c < 0 && d > 0) {
+if (c >= -20 && d <= 10) {
+  clang_analyzer_eval((c + d) > -20); // expected-warning{{TRUE}}
+  clang_analyzer_eval((c + d) < 10); // expected-warning{{TRUE}}
+}
+  }
+
+  // Checks for overlapping signed integers ranges
+  if (c >= -20 && c <= 20 && d >= -10 && d <= 10) {
+clang_analyzer_eval((c + d) >= -30); // expected-warning{{TRUE}}
+clang_analyzer_eval((c + d) <= 30); // expected-warning{{TRUE}}
+  }
+
+  // Checks for positive signed integers
+  if (c > 0 && d > 0) {
+clang_analyzer_eval((c + d) == 1); // expected-warning{{FALSE}}
+clang_analyzer_eval((c + d) == 0); // expected-warning{{FALSE}}
+clang_analyzer_eval((c + d) == -1); // expected-warning{{FALSE}}
+  }
+
+  // Check when Max overflows from positive-side
+  if (c >= 10 && d >= 0 && d <= 10) {
+clang_analyzer_eval((c + d) == INT_MIN + 10); // expected-warning{{FALSE}}
+clang_analyzer_eval((c + d) == -1); // expected-warning{{FALSE}}
+  }
+
+  // Checks when Min overflows from negative side
+  if (c <= 10 && d >= -10 && d <= 0) {
+clang_analyzer_eval((c + d) == 11); // expected-warning{{FALSE}}
+clang_analyzer_eval((c + d) == INT_MAX - 10); // expected-warning{{FALSE}}
+  }
+
+  // Checks producing overflowing range with different signs
+  int HALF_INT_MAX = INT_MAX / 2;
+  if (c >= HALF_INT_MAX - 10 && c <= HALF_INT_MAX + 10 &&
+  d >= HALF_INT_MAX - 10 && d <= HALF_INT_MAX + 10) {
+// The resulting range for (c + d) will be:
+//   [INT_MIN, INT_MIN + 18] U [INT_MAX - 21, INT_MAX]
+clang_analyzer_eval((c + d) <= INT_MIN + 18); // expected-warning{{UNKNOWN}}
+clang_analyzer_eval((c + d) >= INT_MAX - 21); // expected-warning{{UNKNOWN}}
+clang_analyzer_eval((c + d) == INT_MIN + 19); // expected-warning{{FALSE}}
+clang_analyzer_eval((c + d) == INT_MAX - 22); // expected-warning{{FALSE}}
+  }
+}
Index: clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
===
--- clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
+++ clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
@@ -17,6 +17,7 @@
 #include "clang/StaticAnalyzer/Core/PathSensitiv

[PATCH] D105273: [analyzer] Introduce range-based reasoning for subtraction operator

2021-07-02 Thread Manas Gupta via Phabricator via cfe-commits
manas updated this revision to Diff 356249.
manas added a comment.

Remove redundant getAPSIntType calls


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105273

Files:
  clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
  clang/test/Analysis/constant-folding.c

Index: clang/test/Analysis/constant-folding.c
===
--- clang/test/Analysis/constant-folding.c
+++ clang/test/Analysis/constant-folding.c
@@ -352,3 +352,86 @@
 clang_analyzer_eval((c + d) == INT_MAX - 22); // expected-warning{{FALSE}}
   }
 }
+
+void testSubtractionRules(unsigned int a, unsigned int b, int c, int d) {
+  // Checks when Max overflows but encompasses entire rangeset
+  if (c <= 0 && d <= 0) {
+// (c - d) = [INT_MIN, INT_MAX]
+clang_analyzer_eval((c - d) <= 0); // expected-warning{{UNKNOWN}}
+clang_analyzer_eval((c - d) >= 0); // expected-warning{{UNKNOWN}}
+  }
+
+  // Checks when both limits overflow from the opposite ends
+  if (c >= INT_MIN + 40 && c <= INT_MAX - 40 && d >= -50 && d <= 50) {
+// (c - d) = [INT_MIN, INT_MAX]
+clang_analyzer_eval((c - d) <= 0); // expected-warning{{UNKNOWN}}
+clang_analyzer_eval((c - d) >= 0); // expected-warning{{UNKNOWN}}
+  }
+
+  // Checks for non-overflowing ranges
+  if (a >= 10 && a <= 40 && b >= 5 && b <= 10) {
+// (a - b) = [0, 35]
+clang_analyzer_eval((a - b) <= 35); // expected-warning{{TRUE}}
+  }
+
+  if (c >= -10 && c <= 10 && d >= -20 && d <= 20) {
+// (c - d) = [-30, 30]
+clang_analyzer_eval((c - d) >= -30); // expected-warning{{TRUE}}
+clang_analyzer_eval((c - d) <= 30); // expected-warning{{TRUE}}
+  }
+
+  // Check when Min overflows from lower bounded side
+  if (a <= 10 && b <= 10) {
+// (a - b) = [0, 10] U [UINT_MAX - 9, UINT_MAX]
+clang_analyzer_eval((a - b) != 11); // expected-warning{{TRUE}}
+clang_analyzer_eval((a - b) != UINT_MAX - 10); // expected-warning{{TRUE}}
+  }
+
+  if (c <= 10 && d >= -30 && d <= 30) {
+// (c - d) = [INT_MIN, 40] U [INT_MAX - 29, INT_MAX]
+clang_analyzer_eval((c - d) != INT_MAX - 30); // expected-warning{{TRUE}}
+clang_analyzer_eval((c - d) != 41); // expected-warning{{TRUE}}
+  }
+
+  // Checks when Max overflows from the upper bound side
+  if (a >= UINT_MAX - 10 && b >= UINT_MAX - 5) {
+// (a - b) = [0, 5] U [UINT_MAX - 9, UINT_MAX]
+clang_analyzer_eval((a - b) != 6); // expected-warning{{TRUE}}
+clang_analyzer_eval((a - b) != UINT_MAX - 10); // expected-warning{{TRUE}}
+clang_analyzer_eval((a - b) <= 5); // expected-warning{{UNKNOWN}}
+clang_analyzer_eval((a - b) >= UINT_MAX - 9); // expected-warning{{UNKNOWN}}
+clang_analyzer_eval((a - b) > 5 && (a - b) < UINT_MAX - 9); // expected-warning{{FALSE}}
+  }
+
+  if (c >= INT_MAX - 50 && d >= -50 && d <= 50) {
+// (c - d) = [INT_MIN, INT_MIN + 49] U [INT_MAX - 100, INT_MAX]
+clang_analyzer_eval((c - d) >= INT_MAX - 100); // expected-warning{{UNKNOWN}}
+clang_analyzer_eval((c - d) <= INT_MIN + 49); // expected-warning{{UNKNOWN}}
+  }
+
+  // Check when both overflow from the same side
+  if (c >= INT_MAX - 5 && d >= INT_MAX - 5) {
+// (c - d) = [-5, 5]
+clang_analyzer_eval((c - d) < -5 ); // expected-warning{{FALSE}}
+clang_analyzer_eval((c - d) > 5 ); // expected-warning{{FALSE}}
+  }
+
+  // Checks for Min and Max overflowing from same end
+  if (a <= 50 && b >= 60 && b <= 100) {
+// (a - b) = [UINT_MAX - 99, UINT_MAX - 9]
+clang_analyzer_eval((a - b) > UINT_MAX - 9); // expected-warning{{FALSE}}
+clang_analyzer_eval((a - b) < UINT_MAX - 99); // expected-warning{{FALSE}}
+  }
+
+  if (c <= INT_MIN + 50 && d >= INT_MIN + 60 && d <= INT_MIN + 100) {
+// (c - d) = [-100, -10]
+clang_analyzer_eval((c - d) > -10); // expected-warning{{FALSE}}
+clang_analyzer_eval((c - d) < -100); // expected-warning{{FALSE}}
+  }
+
+  if (c >= INT_MAX - 50 && d >= INT_MIN + 70 && d <= INT_MIN + 90) {
+// (c - d) = [-141, -71]
+clang_analyzer_eval((c - d) < -141); // expected-warning{{FALSE}}
+clang_analyzer_eval((c - d) > -71); // expected-warning{{FALSE}}
+  }
+}
Index: clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
===
--- clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
+++ clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
@@ -958,6 +958,8 @@
   return VisitBinaryOperator(LHS, RHS, T);
 case BO_Add:
   return VisitBinaryOperator(LHS, RHS, T);
+case BO_Sub:
+  return VisitBinaryOperator(LHS, RHS, T);
 default:
   return infer(T);
 }
@@ -1429,6 +1431,72 @@
   return {RangeFactory, Tmin, Tmax};
 }
 
+template <>
+RangeSet SymbolicRangeInferrer::VisitBinaryOperator(Range LHS,
+Range RHS,
+ 

[PATCH] D105273: [analyzer] Introduce range-based reasoning for subtraction operator

2021-07-02 Thread Manas Gupta via Phabricator via cfe-commits
manas updated this revision to Diff 356245.
manas added a comment.

Replace literal-value 0 with APSInt Zero


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105273

Files:
  clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
  clang/test/Analysis/constant-folding.c

Index: clang/test/Analysis/constant-folding.c
===
--- clang/test/Analysis/constant-folding.c
+++ clang/test/Analysis/constant-folding.c
@@ -352,3 +352,86 @@
 clang_analyzer_eval((c + d) == INT_MAX - 22); // expected-warning{{FALSE}}
   }
 }
+
+void testSubtractionRules(unsigned int a, unsigned int b, int c, int d) {
+  // Checks when Max overflows but encompasses entire rangeset
+  if (c <= 0 && d <= 0) {
+// (c - d) = [INT_MIN, INT_MAX]
+clang_analyzer_eval((c - d) <= 0); // expected-warning{{UNKNOWN}}
+clang_analyzer_eval((c - d) >= 0); // expected-warning{{UNKNOWN}}
+  }
+
+  // Checks when both limits overflow from the opposite ends
+  if (c >= INT_MIN + 40 && c <= INT_MAX - 40 && d >= -50 && d <= 50) {
+// (c - d) = [INT_MIN, INT_MAX]
+clang_analyzer_eval((c - d) <= 0); // expected-warning{{UNKNOWN}}
+clang_analyzer_eval((c - d) >= 0); // expected-warning{{UNKNOWN}}
+  }
+
+  // Checks for non-overflowing ranges
+  if (a >= 10 && a <= 40 && b >= 5 && b <= 10) {
+// (a - b) = [0, 35]
+clang_analyzer_eval((a - b) <= 35); // expected-warning{{TRUE}}
+  }
+
+  if (c >= -10 && c <= 10 && d >= -20 && d <= 20) {
+// (c - d) = [-30, 30]
+clang_analyzer_eval((c - d) >= -30); // expected-warning{{TRUE}}
+clang_analyzer_eval((c - d) <= 30); // expected-warning{{TRUE}}
+  }
+
+  // Check when Min overflows from lower bounded side
+  if (a <= 10 && b <= 10) {
+// (a - b) = [0, 10] U [UINT_MAX - 9, UINT_MAX]
+clang_analyzer_eval((a - b) != 11); // expected-warning{{TRUE}}
+clang_analyzer_eval((a - b) != UINT_MAX - 10); // expected-warning{{TRUE}}
+  }
+
+  if (c <= 10 && d >= -30 && d <= 30) {
+// (c - d) = [INT_MIN, 40] U [INT_MAX - 29, INT_MAX]
+clang_analyzer_eval((c - d) != INT_MAX - 30); // expected-warning{{TRUE}}
+clang_analyzer_eval((c - d) != 41); // expected-warning{{TRUE}}
+  }
+
+  // Checks when Max overflows from the upper bound side
+  if (a >= UINT_MAX - 10 && b >= UINT_MAX - 5) {
+// (a - b) = [0, 5] U [UINT_MAX - 9, UINT_MAX]
+clang_analyzer_eval((a - b) != 6); // expected-warning{{TRUE}}
+clang_analyzer_eval((a - b) != UINT_MAX - 10); // expected-warning{{TRUE}}
+clang_analyzer_eval((a - b) <= 5); // expected-warning{{UNKNOWN}}
+clang_analyzer_eval((a - b) >= UINT_MAX - 9); // expected-warning{{UNKNOWN}}
+clang_analyzer_eval((a - b) > 5 && (a - b) < UINT_MAX - 9); // expected-warning{{FALSE}}
+  }
+
+  if (c >= INT_MAX - 50 && d >= -50 && d <= 50) {
+// (c - d) = [INT_MIN, INT_MIN + 49] U [INT_MAX - 100, INT_MAX]
+clang_analyzer_eval((c - d) >= INT_MAX - 100); // expected-warning{{UNKNOWN}}
+clang_analyzer_eval((c - d) <= INT_MIN + 49); // expected-warning{{UNKNOWN}}
+  }
+
+  // Check when both overflow from the same side
+  if (c >= INT_MAX - 5 && d >= INT_MAX - 5) {
+// (c - d) = [-5, 5]
+clang_analyzer_eval((c - d) < -5 ); // expected-warning{{FALSE}}
+clang_analyzer_eval((c - d) > 5 ); // expected-warning{{FALSE}}
+  }
+
+  // Checks for Min and Max overflowing from same end
+  if (a <= 50 && b >= 60 && b <= 100) {
+// (a - b) = [UINT_MAX - 99, UINT_MAX - 9]
+clang_analyzer_eval((a - b) > UINT_MAX - 9); // expected-warning{{FALSE}}
+clang_analyzer_eval((a - b) < UINT_MAX - 99); // expected-warning{{FALSE}}
+  }
+
+  if (c <= INT_MIN + 50 && d >= INT_MIN + 60 && d <= INT_MIN + 100) {
+// (c - d) = [-100, -10]
+clang_analyzer_eval((c - d) > -10); // expected-warning{{FALSE}}
+clang_analyzer_eval((c - d) < -100); // expected-warning{{FALSE}}
+  }
+
+  if (c >= INT_MAX - 50 && d >= INT_MIN + 70 && d <= INT_MIN + 90) {
+// (c - d) = [-141, -71]
+clang_analyzer_eval((c - d) < -141); // expected-warning{{FALSE}}
+clang_analyzer_eval((c - d) > -71); // expected-warning{{FALSE}}
+  }
+}
Index: clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
===
--- clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
+++ clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
@@ -958,6 +958,8 @@
   return VisitBinaryOperator(LHS, RHS, T);
 case BO_Add:
   return VisitBinaryOperator(LHS, RHS, T);
+case BO_Sub:
+  return VisitBinaryOperator(LHS, RHS, T);
 default:
   return infer(T);
 }
@@ -1429,6 +1431,72 @@
   return {RangeFactory, Tmin, Tmax};
 }
 
+template <>
+RangeSet SymbolicRangeInferrer::VisitBinaryOperator(Range LHS,
+Range RHS,
+ 

[PATCH] D105273: [analyzer] Introduce range-based reasoning for subtraction operator

2021-07-02 Thread Valeriy Savchenko via Phabricator via cfe-commits
vsavchenko added inline comments.



Comment at: clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp:1485
+  if (ResultType.isUnsigned() ||
+  ((LHS.From() >= 0 && RHS.From() < 0) &&
+   (LHS.To() >= 0 && RHS.To() < 0)) ||

manas wrote:
> @vsavchenko one thing crossed my mind is that, shouldn't I compare `From` and 
> `To` values with  `llvm::APSInt Zero = 
> ValueFactory.getAPSIntType(T).getZeroValue()` instead of literal `0`?
Yes!  Thanks for noticing this (the same goes to the other patch as well)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105273

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


[PATCH] D105365: [Lexer] Fix bug in `makeFileCharRange` called on split tokens.

2021-07-02 Thread Yitzhak Mandelbaum via Phabricator via cfe-commits
ymandel created this revision.
ymandel added a reviewer: sammccall.
ymandel requested review of this revision.
Herald added a project: clang.

When the end loc of the specified range is a split token, `makeFileCharRange`
does not process it correctly.  This patch adds proper support for split tokens.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D105365

Files:
  clang/lib/Lex/Lexer.cpp
  clang/unittests/Lex/LexerTest.cpp

Index: clang/unittests/Lex/LexerTest.cpp
===
--- clang/unittests/Lex/LexerTest.cpp
+++ clang/unittests/Lex/LexerTest.cpp
@@ -25,6 +25,7 @@
 #include "clang/Lex/PreprocessorOptions.h"
 #include "gmock/gmock.h"
 #include "gtest/gtest.h"
+#include 
 #include 
 
 namespace {
@@ -65,7 +66,7 @@
 
   std::vector Lex(StringRef Source) {
 TrivialModuleLoader ModLoader;
-auto PP = CreatePP(Source, ModLoader);
+PP = CreatePP(Source, ModLoader);
 
 std::vector toks;
 while (1) {
@@ -109,6 +110,7 @@
   LangOptions LangOpts;
   std::shared_ptr TargetOpts;
   IntrusiveRefCntPtr Target;
+  std::unique_ptr PP;
 };
 
 TEST_F(LexerTest, GetSourceTextExpandsToMaximumInMacroArgument) {
@@ -264,12 +266,14 @@
 
 TEST_F(LexerTest, LexAPI) {
   std::vector ExpectedTokens;
+  // Line 1 (after the #defines)
   ExpectedTokens.push_back(tok::l_square);
   ExpectedTokens.push_back(tok::identifier);
   ExpectedTokens.push_back(tok::r_square);
   ExpectedTokens.push_back(tok::l_square);
   ExpectedTokens.push_back(tok::identifier);
   ExpectedTokens.push_back(tok::r_square);
+  // Line 2
   ExpectedTokens.push_back(tok::identifier);
   ExpectedTokens.push_back(tok::identifier);
   ExpectedTokens.push_back(tok::identifier);
@@ -357,6 +361,65 @@
   EXPECT_EQ("N", Lexer::getImmediateMacroName(idLoc4, SourceMgr, LangOpts));
 }
 
+TEST_F(LexerTest, HandlesSplitTokens) {
+  std::vector ExpectedTokens;
+  // Line 1 (after the #defines)
+  ExpectedTokens.push_back(tok::identifier);
+  ExpectedTokens.push_back(tok::less);
+  ExpectedTokens.push_back(tok::identifier);
+  ExpectedTokens.push_back(tok::less);
+  ExpectedTokens.push_back(tok::greatergreater);
+  // Line 2
+  ExpectedTokens.push_back(tok::identifier);
+  ExpectedTokens.push_back(tok::less);
+  ExpectedTokens.push_back(tok::identifier);
+  ExpectedTokens.push_back(tok::less);
+  ExpectedTokens.push_back(tok::greatergreater);
+
+  std::vector toks = CheckLex("#define TY ty\n"
+ "#define RANGLE ty>\n"
+ "TY>\n"
+ "RANGLE",
+ ExpectedTokens);
+
+  SourceLocation outerTyLoc = toks[0].getLocation();
+  SourceLocation innerTyLoc = toks[2].getLocation();
+  SourceLocation gtgtLoc = toks[4].getLocation();
+  // Split the token to simulate the action of the parser and force creation of
+  // an `ExpansionTokenRange`.
+  SourceLocation rangleLoc = PP->SplitToken(gtgtLoc, 1);
+
+  // Verify that it only captures the first greater-then and not the second one.
+  CharSourceRange range = Lexer::makeFileCharRange(
+  CharSourceRange::getTokenRange(innerTyLoc, rangleLoc), SourceMgr,
+  LangOpts);
+  EXPECT_TRUE(range.isCharRange());
+  EXPECT_EQ(range.getAsRange(),
+SourceRange(innerTyLoc, gtgtLoc.getLocWithOffset(1)));
+
+  // Verify case where range begins in a macro expansion.
+  range = Lexer::makeFileCharRange(
+  CharSourceRange::getTokenRange(outerTyLoc, rangleLoc), SourceMgr,
+  LangOpts);
+  EXPECT_TRUE(range.isCharRange());
+  EXPECT_EQ(range.getAsRange(),
+SourceRange(SourceMgr.getExpansionLoc(outerTyLoc),
+gtgtLoc.getLocWithOffset(1)));
+
+  SourceLocation macroInnerTyLoc = toks[7].getLocation();
+  SourceLocation macroGtgtLoc = toks[9].getLocation();
+  // Split the token to simulate the action of the parser and force creation of
+  // an `ExpansionTokenRange`.
+  SourceLocation macroRAngleLoc = PP->SplitToken(macroGtgtLoc, 1);
+
+  // Verify that it fails (because it only captures the first greater-then and
+  // not the second one, so it doesn't span the entire macro expansion).
+  range = Lexer::makeFileCharRange(
+  CharSourceRange::getTokenRange(macroInnerTyLoc, macroRAngleLoc),
+  SourceMgr, LangOpts);
+  EXPECT_TRUE(range.isInvalid());
+}
+
 TEST_F(LexerTest, DontMergeMacroArgsFromDifferentMacroFiles) {
   std::vector toks =
   Lex("#define helper1 0\n"
Index: clang/lib/Lex/Lexer.cpp
===
--- clang/lib/Lex/Lexer.cpp
+++ clang/lib/Lex/Lexer.cpp
@@ -877,6 +877,14 @@
   return CharSourceRange::getCharRange(Begin, End);
 }
 
+// Assumes that `Loc` is in an expansion.
+static bool isInExpansionTokenRange(const SourceLocation Loc,
+const SourceManager &SM) {
+  return SM.getSLocEntry(SM.getFileID(Loc))
+  .getExpansion()
+  .isExpansionTokenRange

[PATCH] D105273: [analyzer] Introduce range-based reasoning for subtraction operator

2021-07-02 Thread Manas Gupta via Phabricator via cfe-commits
manas added inline comments.



Comment at: clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp:1485
+  if (ResultType.isUnsigned() ||
+  ((LHS.From() >= 0 && RHS.From() < 0) &&
+   (LHS.To() >= 0 && RHS.To() < 0)) ||

@vsavchenko one thing crossed my mind is that, shouldn't I compare `From` and 
`To` values with  `llvm::APSInt Zero = 
ValueFactory.getAPSIntType(T).getZeroValue()` instead of literal `0`?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105273

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


[PATCH] D105273: [analyzer] Introduce range-based reasoning for subtraction operator

2021-07-02 Thread Manas Gupta via Phabricator via cfe-commits
manas updated this revision to Diff 356235.
manas marked 3 inline comments as done.
manas added a comment.

Merge conditionals with similar block and add test for one overflow on Tmax-side


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105273

Files:
  clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
  clang/test/Analysis/constant-folding.c

Index: clang/test/Analysis/constant-folding.c
===
--- clang/test/Analysis/constant-folding.c
+++ clang/test/Analysis/constant-folding.c
@@ -352,3 +352,86 @@
 clang_analyzer_eval((c + d) == INT_MAX - 22); // expected-warning{{FALSE}}
   }
 }
+
+void testSubtractionRules(unsigned int a, unsigned int b, int c, int d) {
+  // Checks when Max overflows but encompasses entire rangeset
+  if (c <= 0 && d <= 0) {
+// (c - d) = [INT_MIN, INT_MAX]
+clang_analyzer_eval((c - d) <= 0); // expected-warning{{UNKNOWN}}
+clang_analyzer_eval((c - d) >= 0); // expected-warning{{UNKNOWN}}
+  }
+
+  // Checks when both limits overflow from the opposite ends
+  if (c >= INT_MIN + 40 && c <= INT_MAX - 40 && d >= -50 && d <= 50) {
+// (c - d) = [INT_MIN, INT_MAX]
+clang_analyzer_eval((c - d) <= 0); // expected-warning{{UNKNOWN}}
+clang_analyzer_eval((c - d) >= 0); // expected-warning{{UNKNOWN}}
+  }
+
+  // Checks for non-overflowing ranges
+  if (a >= 10 && a <= 40 && b >= 5 && b <= 10) {
+// (a - b) = [0, 35]
+clang_analyzer_eval((a - b) <= 35); // expected-warning{{TRUE}}
+  }
+
+  if (c >= -10 && c <= 10 && d >= -20 && d <= 20) {
+// (c - d) = [-30, 30]
+clang_analyzer_eval((c - d) >= -30); // expected-warning{{TRUE}}
+clang_analyzer_eval((c - d) <= 30); // expected-warning{{TRUE}}
+  }
+
+  // Check when Min overflows from lower bounded side
+  if (a <= 10 && b <= 10) {
+// (a - b) = [0, 10] U [UINT_MAX - 9, UINT_MAX]
+clang_analyzer_eval((a - b) != 11); // expected-warning{{TRUE}}
+clang_analyzer_eval((a - b) != UINT_MAX - 10); // expected-warning{{TRUE}}
+  }
+
+  if (c <= 10 && d >= -30 && d <= 30) {
+// (c - d) = [INT_MIN, 40] U [INT_MAX - 29, INT_MAX]
+clang_analyzer_eval((c - d) != INT_MAX - 30); // expected-warning{{TRUE}}
+clang_analyzer_eval((c - d) != 41); // expected-warning{{TRUE}}
+  }
+
+  // Checks when Max overflows from the upper bound side
+  if (a >= UINT_MAX - 10 && b >= UINT_MAX - 5) {
+// (a - b) = [0, 5] U [UINT_MAX - 9, UINT_MAX]
+clang_analyzer_eval((a - b) != 6); // expected-warning{{TRUE}}
+clang_analyzer_eval((a - b) != UINT_MAX - 10); // expected-warning{{TRUE}}
+clang_analyzer_eval((a - b) <= 5); // expected-warning{{UNKNOWN}}
+clang_analyzer_eval((a - b) >= UINT_MAX - 9); // expected-warning{{UNKNOWN}}
+clang_analyzer_eval((a - b) > 5 && (a - b) < UINT_MAX - 9); // expected-warning{{FALSE}}
+  }
+
+  if (c >= INT_MAX - 50 && d >= -50 && d <= 50) {
+// (c - d) = [INT_MIN, INT_MIN + 49] U [INT_MAX - 100, INT_MAX]
+clang_analyzer_eval((c - d) >= INT_MAX - 100); // expected-warning{{UNKNOWN}}
+clang_analyzer_eval((c - d) <= INT_MIN + 49); // expected-warning{{UNKNOWN}}
+  }
+
+  // Check when both overflow from the same side
+  if (c >= INT_MAX - 5 && d >= INT_MAX - 5) {
+// (c - d) = [-5, 5]
+clang_analyzer_eval((c - d) < -5 ); // expected-warning{{FALSE}}
+clang_analyzer_eval((c - d) > 5 ); // expected-warning{{FALSE}}
+  }
+
+  // Checks for Min and Max overflowing from same end
+  if (a <= 50 && b >= 60 && b <= 100) {
+// (a - b) = [UINT_MAX - 99, UINT_MAX - 9]
+clang_analyzer_eval((a - b) > UINT_MAX - 9); // expected-warning{{FALSE}}
+clang_analyzer_eval((a - b) < UINT_MAX - 99); // expected-warning{{FALSE}}
+  }
+
+  if (c <= INT_MIN + 50 && d >= INT_MIN + 60 && d <= INT_MIN + 100) {
+// (c - d) = [-100, -10]
+clang_analyzer_eval((c - d) > -10); // expected-warning{{FALSE}}
+clang_analyzer_eval((c - d) < -100); // expected-warning{{FALSE}}
+  }
+
+  if (c >= INT_MAX - 50 && d >= INT_MIN + 70 && d <= INT_MIN + 90) {
+// (c - d) = [-141, -71]
+clang_analyzer_eval((c - d) < -141); // expected-warning{{FALSE}}
+clang_analyzer_eval((c - d) > -71); // expected-warning{{FALSE}}
+  }
+}
Index: clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
===
--- clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
+++ clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
@@ -958,6 +958,8 @@
   return VisitBinaryOperator(LHS, RHS, T);
 case BO_Add:
   return VisitBinaryOperator(LHS, RHS, T);
+case BO_Sub:
+  return VisitBinaryOperator(LHS, RHS, T);
 default:
   return infer(T);
 }
@@ -1429,6 +1431,71 @@
   return {RangeFactory, Tmin, Tmax};
 }
 
+template <>
+RangeSet SymbolicRangeInferrer::VisitBinaryOperator(Range LHS,
+ 

[PATCH] D105273: [analyzer] Introduce range-based reasoning for subtraction operator

2021-07-02 Thread Manas Gupta via Phabricator via cfe-commits
manas marked 3 inline comments as done.
manas added a comment.

Thanks Valeriy.




Comment at: clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp:1490
+  // the resulting range should be [Min, Max].
+  if (ResultType.isUnsigned()) {
+return {RangeFactory, ValueFactory.getValue(Min),

vsavchenko wrote:
> Maybe you can include this as yet another condition in the next `if` 
> statement?  Their bodies are identical.
True. I wanted to optimize the following `if` condition as it looks quite ugly 
right now! Although, I will concatenate these conditions for now and work on 
the optimization later.



Comment at: clang/test/Analysis/constant-folding.c:399
+// (a - b) = [0, 5] U [UINT_MAX - 9, UINT_MAX]
+clang_analyzer_eval((a - b) != 6); // expected-warning{{TRUE}}
+clang_analyzer_eval((a - b) != UINT_MAX - 10); // expected-warning{{TRUE}}

vsavchenko wrote:
> Maybe you can check `(a - b) > 5 && (a - b) < UINT_MAX - 9` to cover the 
> whole range?
That's true! I never thought of putting them together. Makes more sense.



Comment at: clang/test/Analysis/constant-folding.c:405
+
+  if (c >= INT_MAX - 5 && d >= INT_MAX - 5) {
+// (c - d) = [-5, 5]

vsavchenko wrote:
> This is also Min and Max overflowing on the positive side.
I missed it! I will add another case for only Max overflowing on positive side 
and will keep this test as well.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105273

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


[PATCH] D104847: [Clang][NVPTX] Add NVPTX intrinsics and builtins for CUDA PTX 6.5 and 7.0 WMMA and MMA instructions

2021-07-02 Thread Artem Belevich via Phabricator via cfe-commits
tra added inline comments.



Comment at: clang/include/clang/Basic/BuiltinsNVPTX.def:727
 TARGET_BUILTIN(__bmma_m8n8k128_ld_c, "vi*iC*UiIi", "", AND(SM_75,PTX63))
 TARGET_BUILTIN(__bmma_m8n8k128_mma_xor_popc_b1, "vi*iC*iC*iC*Ii", "", 
AND(SM_75,PTX63))
 TARGET_BUILTIN(__bmma_m8n8k128_st_c_i32, "vi*iC*UiIi", "", AND(SM_75,PTX63))

Bummer. mma.h in CUDA-11.3 still does not compile for Ampere.

We appear to be missing the new `__bmma_m8n8k128_mma_and_popc_b1` builtin for 
the `.and` variant of 1-bit `mma` introduced in PTX 7.1 and not included in 
this patch.

https://docs.nvidia.com/cuda/parallel-thread-execution/index.html#warp-level-matrix-instructions-wmma-mma

Do you, by any chance, have upcoming patch for PTX7.1, too. :-) 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D104847

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


[PATCH] D104616: [analyzer] Model comparision methods of std::unique_ptr

2021-07-02 Thread Deep Majumder via Phabricator via cfe-commits
RedDocMD updated this revision to Diff 356226.
RedDocMD added a comment.

Simplify SVal on state split, other refactors


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D104616

Files:
  clang/lib/StaticAnalyzer/Checkers/SmartPtr.h
  clang/lib/StaticAnalyzer/Checkers/SmartPtrModeling.cpp
  clang/test/Analysis/Inputs/system-header-simulator-cxx.h
  clang/test/Analysis/smart-ptr.cpp

Index: clang/test/Analysis/smart-ptr.cpp
===
--- clang/test/Analysis/smart-ptr.cpp
+++ clang/test/Analysis/smart-ptr.cpp
@@ -457,3 +457,36 @@
 P->foo(); // expected-warning {{Dereference of null smart pointer 'P' [alpha.cplusplus.SmartPtr]}}
   }
 }
+
+// The following is a silly function,
+// but serves to test if we are picking out
+// standard comparision functions from custom ones.
+template 
+bool operator<(std::unique_ptr &x, double d);
+
+void uniquePtrComparision(std::unique_ptr unknownPtr) {
+  auto ptr = std::unique_ptr(new int(13));
+  auto nullPtr = std::unique_ptr();
+  auto otherPtr = std::unique_ptr(new int(29));
+
+  clang_analyzer_eval(ptr == ptr); // expected-warning{{TRUE}}
+  clang_analyzer_eval(ptr > ptr);  // expected-warning{{FALSE}}
+  clang_analyzer_eval(ptr <= ptr); // expected-warning{{TRUE}}
+
+  clang_analyzer_eval(nullPtr <= unknownPtr); // expected-warning{{TRUE}}
+  clang_analyzer_eval(unknownPtr >= nullPtr); // expected-warning{{TRUE}}
+
+  clang_analyzer_eval(ptr != otherPtr); // expected-warning{{TRUE}}
+  clang_analyzer_eval(ptr > nullPtr);   // expected-warning{{TRUE}}
+
+  clang_analyzer_eval(ptr != nullptr);// expected-warning{{TRUE}}
+  clang_analyzer_eval(nullPtr != nullptr);// expected-warning{{FALSE}}
+  clang_analyzer_eval(nullptr <= unknownPtr); // expected-warning{{TRUE}}
+}
+
+void uniquePtrComparisionStateSplitting(std::unique_ptr unknownPtr) {
+  auto ptr = std::unique_ptr(new int(13));
+
+  clang_analyzer_eval(ptr > unknownPtr); // expected-warning{{TRUE}}
+  // expected-warning@-1{{FALSE}}
+}
Index: clang/test/Analysis/Inputs/system-header-simulator-cxx.h
===
--- clang/test/Analysis/Inputs/system-header-simulator-cxx.h
+++ clang/test/Analysis/Inputs/system-header-simulator-cxx.h
@@ -978,6 +978,61 @@
 void swap(unique_ptr &x, unique_ptr &y) noexcept {
   x.swap(y);
 }
+
+template 
+bool operator==(const unique_ptr &x, const unique_ptr &y);
+
+template 
+bool operator!=(const unique_ptr &x, const unique_ptr &y);
+
+template 
+bool operator<(const unique_ptr &x, const unique_ptr &y);
+
+template 
+bool operator>(const unique_ptr &x, const unique_ptr &y);
+
+template 
+bool operator<=(const unique_ptr &x, const unique_ptr &y);
+
+template 
+bool operator>=(const unique_ptr &x, const unique_ptr &y);
+
+template 
+bool operator==(const unique_ptr &x, nullptr_t y);
+
+template 
+bool operator!=(const unique_ptr &x, nullptr_t y);
+
+template 
+bool operator<(const unique_ptr &x, nullptr_t y);
+
+template 
+bool operator>(const unique_ptr &x, nullptr_t y);
+
+template 
+bool operator<=(const unique_ptr &x, nullptr_t y);
+
+template 
+bool operator>=(const unique_ptr &x, nullptr_t y);
+
+template 
+bool operator==(nullptr_t x, const unique_ptr &y);
+
+template 
+bool operator!=(nullptr_t x, const unique_ptr &y);
+
+template 
+bool operator>(nullptr_t x, const unique_ptr &y);
+
+template 
+bool operator<(nullptr_t x, const unique_ptr &y);
+
+template 
+bool operator>=(nullptr_t x, const unique_ptr &y);
+
+template 
+bool operator<=(nullptr_t x, const unique_ptr &y);
+
 } // namespace std
 #endif
 
Index: clang/lib/StaticAnalyzer/Checkers/SmartPtrModeling.cpp
===
--- clang/lib/StaticAnalyzer/Checkers/SmartPtrModeling.cpp
+++ clang/lib/StaticAnalyzer/Checkers/SmartPtrModeling.cpp
@@ -29,7 +29,10 @@
 #include "clang/StaticAnalyzer/Core/PathSensitive/SVals.h"
 #include "clang/StaticAnalyzer/Core/PathSensitive/SymExpr.h"
 #include "clang/StaticAnalyzer/Core/PathSensitive/SymbolManager.h"
+#include "llvm/ADT/StringMap.h"
+#include "llvm/Support/ErrorHandling.h"
 #include 
+#include 
 
 using namespace clang;
 using namespace ento;
@@ -68,6 +71,10 @@
   bool updateMovedSmartPointers(CheckerContext &C, const MemRegion *ThisRegion,
 const MemRegion *OtherSmartPtrRegion) const;
   void handleBoolConversion(const CallEvent &Call, CheckerContext &C) const;
+  bool handleComparisionOp(const CallEvent &Call, CheckerContext &C) const;
+  std::pair
+  retrieveOrConjureInnerPtrVal(const MemRegion *ThisRegion, const Expr *E,
+   QualType Type, CheckerContext &C) const;
 
   using SmartPtrMethodHandlerFn =
   void (SmartPtrModeling::*)(const CallEvent &Call, CheckerContext &) const;
@@ -89,18 +96,24 @@
   const auto *MethodDecl = dyn_cast_or_null(Call.getDecl

[PATCH] D104616: [analyzer] Model comparision methods of std::unique_ptr

2021-07-02 Thread Deep Majumder via Phabricator via cfe-commits
RedDocMD marked 3 inline comments as done.
RedDocMD added inline comments.



Comment at: clang/test/Analysis/smart-ptr.cpp:484
+  clang_analyzer_eval(nullPtr != nullptr);// expected-warning{{FALSE}}
+  clang_analyzer_eval(nullptr <= unknownPtr); // expected-warning{{TRUE}}
+}

xazax.hun wrote:
> I do not see test cases where the path is actually split. Would you add some?
Oops! I removed two tests emitting UNKNOWN and forgot to put them back in.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D104616

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


[PATCH] D104898: [clang-repl] Allow passing in code as positional arguments.

2021-07-02 Thread Mitch Phillips via Phabricator via cfe-commits
hctim added a comment.

Hi, looks like this change caused a regression on the sanitizer buildbots 
(https://lab.llvm.org/buildbot/#/builders/169/builds/1290/steps/25/logs/stdio). 
Error copied below for your convenience.

Can be repro'd using the bot instructions at 
https://github.com/google/sanitizers/wiki/SanitizerBotReproduceBuild, or 
(should be possible) by using `cmake -DLLVM_USE_SANITIZER=Address -GNinja && 
ninja check-clang`.

   TEST 'Clang :: Interpreter/execute.cpp' FAILED 

  Script:
  --
  : 'RUN: at line 1';   
/b/sanitizer-x86_64-linux-fast/build/llvm_build_asan/bin/clang-repl "int i = 
10;" 'extern "C" int printf(const char*,...);' 'auto r1 = printf("i 
= %d\n", i);' | 
/b/sanitizer-x86_64-linux-fast/build/llvm_build_asan/bin/FileCheck 
--check-prefix=CHECK-DRIVER 
/b/sanitizer-x86_64-linux-fast/build/llvm-project/clang/test/Interpreter/execute.cpp
  : 'RUN: at line 8';   cat 
/b/sanitizer-x86_64-linux-fast/build/llvm-project/clang/test/Interpreter/execute.cpp
 | /b/sanitizer-x86_64-linux-fast/build/llvm_build_asan/bin/clang-repl | 
/b/sanitizer-x86_64-linux-fast/build/llvm_build_asan/bin/FileCheck 
/b/sanitizer-x86_64-linux-fast/build/llvm-project/clang/test/Interpreter/execute.cpp
  --
  Exit Code: 1
  Command Output (stderr):
  --
  =
  ==67042==ERROR: LeakSanitizer: detected memory leaks
  Direct leak of 3384 byte(s) in 3 object(s) allocated from:
  #0 0x44fbefd in operator new(unsigned long) 
/b/s/w/ir/cache/builder/src/third_party/llvm/compiler-rt/lib/asan/asan_new_delete.cpp:95:3
  #1 0x4bb65ad in 
llvm::RegisterTargetMachine::Allocator(llvm::Target 
const&, llvm::Triple const&, llvm::StringRef, llvm::StringRef, 
llvm::TargetOptions const&, llvm::Optional, 
llvm::Optional, llvm::CodeGenOpt::Level, bool) 
/b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/include/llvm/Support/TargetRegistry.h:1209:12
  #2 0x6acad7f in createTargetMachine 
/b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/include/llvm/Support/TargetRegistry.h:429:12
  #3 0x6acad7f in (anonymous 
namespace)::EmitAssemblyHelper::CreateTargetMachine(bool) 
/b/sanitizer-x86_64-linux-fast/build/llvm-project/clang/lib/CodeGen/BackendUtil.cpp:907:23
  #4 0x6ab5a43 in (anonymous 
namespace)::EmitAssemblyHelper::EmitAssemblyWithNewPassManager(clang::BackendAction,
 std::__1::unique_ptr >) 
/b/sanitizer-x86_64-linux-fast/build/llvm-project/clang/lib/CodeGen/BackendUtil.cpp:1195:3
  #5 0x6aac51b in clang::EmitBackendOutput(clang::DiagnosticsEngine&, 
clang::HeaderSearchOptions const&, clang::CodeGenOptions const&, 
clang::TargetOptions const&, clang::LangOptions const&, llvm::StringRef, 
llvm::Module*, clang::BackendAction, 
std::__1::unique_ptr >) 
/b/sanitizer-x86_64-linux-fast/build/llvm-project/clang/lib/CodeGen/BackendUtil.cpp:1654:15
  #6 0x6aa0610 in 
clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&) 
/b/sanitizer-x86_64-linux-fast/build/llvm-project/clang/lib/CodeGen/CodeGenAction.cpp:334:7
  #7 0x59ba3bf in clang::IncrementalParser::ParseOrWrapTopLevelDecl() 
/b/sanitizer-x86_64-linux-fast/build/llvm-project/clang/lib/Interpreter/IncrementalParser.cpp:177:13
  #8 0x59bc084 in clang::IncrementalParser::Parse(llvm::StringRef) 
/b/sanitizer-x86_64-linux-fast/build/llvm-project/clang/lib/Interpreter/IncrementalParser.cpp:227:27
  #9 0x585dd64 in clang::Interpreter::Parse(llvm::StringRef) 
/b/sanitizer-x86_64-linux-fast/build/llvm-project/clang/lib/Interpreter/Interpreter.cpp:202:22
  #10 0x4501f45 in clang::Interpreter::ParseAndExecute(llvm::StringRef) 
/b/sanitizer-x86_64-linux-fast/build/llvm-project/clang/include/clang/Interpreter/Interpreter.h:61:29
  #11 0x4500605 in main 
/b/sanitizer-x86_64-linux-fast/build/llvm-project/clang/tools/clang-repl/ClangRepl.cpp:95:30
  #12 0x7f625d26909a in __libc_start_main 
(/lib/x86_64-linux-gnu/libc.so.6+0x2409a)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D104898

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


[PATCH] D104808: [clang][emscripten] Reduce alignof long double from 16 to 8 bytes

2021-07-02 Thread Sam Clegg 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 rGd1a96e906cc0: [clang][emscripten] Reduce alignof long double 
from 16 to 8 bytes (authored by sbc100).

Changed prior to commit:
  https://reviews.llvm.org/D104808?vs=354048&id=356223#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D104808

Files:
  clang/lib/Basic/Targets/OSTargets.h


Index: clang/lib/Basic/Targets/OSTargets.h
===
--- clang/lib/Basic/Targets/OSTargets.h
+++ clang/lib/Basic/Targets/OSTargets.h
@@ -948,8 +948,16 @@
   }
 
 public:
-  explicit EmscriptenTargetInfo(const llvm::Triple &Triple, const 
TargetOptions &Opts)
-  : WebAssemblyOSTargetInfo(Triple, Opts) {}
+  explicit EmscriptenTargetInfo(const llvm::Triple &Triple,
+const TargetOptions &Opts)
+  : WebAssemblyOSTargetInfo(Triple, Opts) {
+// Keeping the alignment of long double to 8 bytes even though its size is
+// 16 bytes allows emscripten to have an 8-byte-aligned max_align_t which
+// in turn gives is a 8-byte aligned malloc.
+// Emscripten's ABI is unstable and we may change this back to 128 to match
+// the WebAssembly default in the future.
+this->LongDoubleAlign = 64;
+  }
 };
 
 } // namespace targets


Index: clang/lib/Basic/Targets/OSTargets.h
===
--- clang/lib/Basic/Targets/OSTargets.h
+++ clang/lib/Basic/Targets/OSTargets.h
@@ -948,8 +948,16 @@
   }
 
 public:
-  explicit EmscriptenTargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts)
-  : WebAssemblyOSTargetInfo(Triple, Opts) {}
+  explicit EmscriptenTargetInfo(const llvm::Triple &Triple,
+const TargetOptions &Opts)
+  : WebAssemblyOSTargetInfo(Triple, Opts) {
+// Keeping the alignment of long double to 8 bytes even though its size is
+// 16 bytes allows emscripten to have an 8-byte-aligned max_align_t which
+// in turn gives is a 8-byte aligned malloc.
+// Emscripten's ABI is unstable and we may change this back to 128 to match
+// the WebAssembly default in the future.
+this->LongDoubleAlign = 64;
+  }
 };
 
 } // namespace targets
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] d1a96e9 - [clang][emscripten] Reduce alignof long double from 16 to 8 bytes

2021-07-02 Thread Sam Clegg via cfe-commits

Author: Sam Clegg
Date: 2021-07-02T11:05:40-07:00
New Revision: d1a96e906cc03a95cfd41a1f22bdda92651250c7

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

LOG: [clang][emscripten] Reduce alignof long double from 16 to 8 bytes

This means `max_align_t` is 8 bytes which also sets the alignment
malloc.  Since this is technically and ABI breaking change we have
limited to just the emscripten OS target.  It is also relatively low
import breakage since it will only effect the alignement of struct that
contai `long double`s (extremerly rare I imagine).

Emscripten's malloc implementation already use 8 byte alignement
(dlmalloc uses and alignement of 2*sizeof(void*) == 8 rather than
checking max_align_t) so will not be effected by this change.  By
bringing the ABI in line with the current malloc code this will fix
several issue we have seen in the wild.

See: https://github.com/emscripten-core/emscripten/pull/14456

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

Added: 


Modified: 
clang/lib/Basic/Targets/OSTargets.h

Removed: 




diff  --git a/clang/lib/Basic/Targets/OSTargets.h 
b/clang/lib/Basic/Targets/OSTargets.h
index ce56b4f1f005e..335ca5635642c 100644
--- a/clang/lib/Basic/Targets/OSTargets.h
+++ b/clang/lib/Basic/Targets/OSTargets.h
@@ -948,8 +948,16 @@ class LLVM_LIBRARY_VISIBILITY EmscriptenTargetInfo
   }
 
 public:
-  explicit EmscriptenTargetInfo(const llvm::Triple &Triple, const 
TargetOptions &Opts)
-  : WebAssemblyOSTargetInfo(Triple, Opts) {}
+  explicit EmscriptenTargetInfo(const llvm::Triple &Triple,
+const TargetOptions &Opts)
+  : WebAssemblyOSTargetInfo(Triple, Opts) {
+// Keeping the alignment of long double to 8 bytes even though its size is
+// 16 bytes allows emscripten to have an 8-byte-aligned max_align_t which
+// in turn gives is a 8-byte aligned malloc.
+// Emscripten's ABI is unstable and we may change this back to 128 to match
+// the WebAssembly default in the future.
+this->LongDoubleAlign = 64;
+  }
 };
 
 } // namespace targets



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


[clang] 3ec88ca - Revert "[clang-repl] Allow passing in code as positional arguments."

2021-07-02 Thread Mitch Phillips via cfe-commits

Author: Mitch Phillips
Date: 2021-07-02T11:04:28-07:00
New Revision: 3ec88ca60b24418b2216de88fad1da4f269f6b8c

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

LOG: Revert "[clang-repl] Allow passing in code as positional arguments."

This reverts commit e386871e1d21cf206a1287356e88c5853563fc77.

Reason: Broke the ASan buildbots
(https://lab.llvm.org/buildbot/#/builders/5/builds/9291). See comments
on https://reviews.llvm.org/D104898 for more information.

Added: 


Modified: 
clang/test/Interpreter/execute.cpp
clang/tools/clang-repl/ClangRepl.cpp

Removed: 




diff  --git a/clang/test/Interpreter/execute.cpp 
b/clang/test/Interpreter/execute.cpp
index 730796bd4016a..108b79b23a59d 100644
--- a/clang/test/Interpreter/execute.cpp
+++ b/clang/test/Interpreter/execute.cpp
@@ -1,12 +1,7 @@
-// RUN: clang-repl "int i = 10;" 'extern "C" int printf(const char*,...);' \
-// RUN:'auto r1 = printf("i = %d\n", i);' | FileCheck 
--check-prefix=CHECK-DRIVER %s
+// RUN: cat %s | clang-repl | FileCheck %s
 // REQUIRES: host-supports-jit
 // UNSUPPORTED: system-aix
 
-// CHECK-DRIVER: i = 10
-
-// RUN: cat %s | clang-repl | FileCheck %s
-
 extern "C" int printf(const char *, ...);
 int i = 42;
 auto r1 = printf("i = %d\n", i);

diff  --git a/clang/tools/clang-repl/ClangRepl.cpp 
b/clang/tools/clang-repl/ClangRepl.cpp
index ba6bb11abc867..b5b5bf6e0c6bb 100644
--- a/clang/tools/clang-repl/ClangRepl.cpp
+++ b/clang/tools/clang-repl/ClangRepl.cpp
@@ -28,9 +28,6 @@ static llvm::cl::list
   llvm::cl::CommaSeparated);
 static llvm::cl::opt OptHostSupportsJit("host-supports-jit",
   llvm::cl::Hidden);
-static llvm::cl::list OptInputs(llvm::cl::Positional,
- llvm::cl::ZeroOrMore,
- llvm::cl::desc("[code to run]"));
 
 static void LLVMErrorHandler(void *UserData, const std::string &Message,
  bool GenCrashDiag) {
@@ -81,22 +78,15 @@ int main(int argc, const char **argv) {
 static_cast(&CI->getDiagnostics()));
 
   auto Interp = ExitOnErr(clang::Interpreter::create(std::move(CI)));
-  for (const std::string &input : OptInputs) {
-if (auto Err = Interp->ParseAndExecute(input))
+  llvm::LineEditor LE("clang-repl");
+  // FIXME: Add LE.setListCompleter
+  while (llvm::Optional Line = LE.readLine()) {
+if (*Line == "quit")
+  break;
+if (auto Err = Interp->ParseAndExecute(*Line))
   llvm::logAllUnhandledErrors(std::move(Err), llvm::errs(), "error: ");
   }
 
-  if (OptInputs.empty()) {
-llvm::LineEditor LE("clang-repl");
-// FIXME: Add LE.setListCompleter
-while (llvm::Optional Line = LE.readLine()) {
-  if (*Line == "quit")
-break;
-  if (auto Err = Interp->ParseAndExecute(*Line))
-llvm::logAllUnhandledErrors(std::move(Err), llvm::errs(), "error: ");
-}
-  }
-
   // Our error handler depends on the Diagnostics object, which we're
   // potentially about to delete. Uninstall the handler now so that any
   // later errors use the default handling behavior instead.



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


[PATCH] D104616: [analyzer] Model comparision methods of std::unique_ptr

2021-07-02 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added inline comments.



Comment at: clang/lib/StaticAnalyzer/Checkers/SmartPtrModeling.cpp:431
+  State, BOK, FirstPtrVal, SecondPtrVal, Call.getResultType());
+  State = State->BindExpr(Call.getOriginExpr(), C.getLocationContext(), 
RetVal);
+

Now that we've made a state split, it makes sense to bind a concrete true value 
or a concrete false value (depending on the state) instead of a symbolic value. 
This produces simpler symbolic equations for our constraint solver to handle.

I.e., something like
```lang=c++
std::tie(TrueState, FalseState) = State->assume(...);
if (TrueState)
  C.addTransition(TrueState->BindExpr(E, LCtx, SVB.makeTruthVal(true));
if (FalseState)
  C.addTransition(FalseState->BindExpr(E, LCtx, SVB.makeTruthVal(false));
```



Comment at: clang/lib/StaticAnalyzer/Checkers/SmartPtrModeling.cpp:435
+ProgramStateRef TrueState, FalseState;
+std::tie(TrueState, FalseState) =
+State->assume(*RetVal.getAs());

xazax.hun wrote:
> `assume` might not return a state (when the analyzer is smart enough to 
> figure out one path is infeasible). While your code would probably work as 
> is, as far as I remember we usually try to not call addTransition with `null` 
> states. 
Yeah I have a lot of anxiety about passing nulls there as well, have to look up 
the source code of these functions every time :/


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D104616

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


[PATCH] D104808: [clang][emscripten] Reduce alignof long double from 16 to 8 bytes

2021-07-02 Thread Alon Zakai via Phabricator via cfe-commits
kripken accepted this revision.
kripken added a comment.
This revision is now accepted and ready to land.

I believe we have all agreed that this is the right path forward, and so this 
can land?

Doing this change now in emscripten does not prevent us from changing the 
emscripten ABI again later, as the ABI is unstable (which is why we can make 
this change itself). We definitely should in the future consider unifying the 
emscripten triple with WASI, but for now, this change will be a strict 
improvement in emscripten.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D104808

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


[PATCH] D92004: [OpenCL] add CL 3.0 optional feature support to opencl-c.h

2021-07-02 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia added a comment.

@airlied I think this patch is outdated as some features have been committed in 
the meantime. Are you still interested in working on this change? It might help 
splitting into smaller independent chunks. It is usually faster to review and 
test.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D92004

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


[PATCH] D105360: [PowerPC] Fix popcntb XL Compat Builtin for 32bit

2021-07-02 Thread Quinn Pham via Phabricator via cfe-commits
quinnp created this revision.
Herald added subscribers: shchenz, kbarton, hiraditya, nemanjai.
quinnp 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/D105360

Files:
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/test/CodeGen/builtins-ppc-xlcompat-sync.c
  llvm/include/llvm/IR/IntrinsicsPowerPC.td
  llvm/lib/Target/PowerPC/P9InstrResources.td
  llvm/lib/Target/PowerPC/PPCInstr64Bit.td
  llvm/lib/Target/PowerPC/PPCInstrInfo.td
  llvm/test/CodeGen/PowerPC/builtins-ppc-xlcompat-msync.ll
  llvm/test/CodeGen/PowerPC/builtins-ppc-xlcompat-sync-32.ll
  llvm/test/CodeGen/PowerPC/builtins-ppc-xlcompat-sync-64.ll
  llvm/test/CodeGen/PowerPC/builtins-ppc-xlcompat-sync.ll

Index: llvm/test/CodeGen/PowerPC/builtins-ppc-xlcompat-sync.ll
===
--- llvm/test/CodeGen/PowerPC/builtins-ppc-xlcompat-sync.ll
+++ /dev/null
@@ -1,74 +0,0 @@
-; RUN: llc -verify-machineinstrs -mtriple=powerpcle-unknown-linux-gnu \
-; RUN: -mcpu=pwr8 < %s | FileCheck %s
-; RUN: llc -verify-machineinstrs -mtriple=powerpc-unknown-linux-gnu \
-; RUN: -mcpu=pwr8 < %s | FileCheck %s
-; RUN: llc -verify-machineinstrs -mtriple=powerpc64le-unknown-linux-gnu \
-; RUN: -mcpu=pwr8 < %s | FileCheck %s
-; RUN: llc -verify-machineinstrs -mtriple=powerpc64-unknown-linux-gnu \
-; RUN: -mcpu=pwr8 < %s | FileCheck %s
-
-define dso_local void @test_builtin_ppc_eieio() #0 {
-; CHECK-LABEL: test_builtin_ppc_eieio
-
-entry:
-  call void @llvm.ppc.eieio()
-; CHECK: ori 2, 2, 0
-; CHECK-NEXT: ori 2, 2, 0
-; CHECK-NEXT: eieio
- 
-  ret void
-}
-
-declare void @llvm.ppc.eieio() #2
-
-define dso_local void @test_builtin_ppc_iospace_eieio() #0 {
-; CHECK-LABEL: test_builtin_ppc_iospace_eieio
-
-entry:
-  call void @llvm.ppc.iospace.eieio()
-; CHECK: ori 2, 2, 0
-; CHECK-NEXT: ori 2, 2, 0
-; CHECK-NEXT: eieio
- 
-  ret void
-}
-
-declare void @llvm.ppc.iospace.eieio() #2
-
-define dso_local void @test_builtin_ppc_iospace_lwsync() #0 {
-; CHECK-LABEL: test_builtin_ppc_iospace_lwsync
-
-entry:
-  call void @llvm.ppc.iospace.lwsync()
-; CHECK: lwsync
-
-  ret void
-}
-
-declare void @llvm.ppc.iospace.lwsync() #2
-
-define dso_local void @test_builtin_ppc_iospace_sync() #0 {
-; CHECK-LABEL: test_builtin_ppc_iospace_sync
-
-entry:
-  call void @llvm.ppc.iospace.sync()
-; CHECK: sync
-
-  ret void
-}
-
-declare void @llvm.ppc.iospace.sync() #2
-
-define dso_local void @test_builtin_ppc_icbt() #0 {
-; CHECK-LABEL: test_builtin_ppc_icbt
-
-entry:
-  %a = alloca i8*, align 8
-  %0 = load i8*, i8** %a, align 8
-  call void @llvm.ppc.icbt(i8* %0)
-; CHECK: icbt 0, 0, 3
-
-  ret void
-}
-
-declare void @llvm.ppc.icbt(i8*) #2
Index: llvm/test/CodeGen/PowerPC/builtins-ppc-xlcompat-sync-64.ll
===
--- /dev/null
+++ llvm/test/CodeGen/PowerPC/builtins-ppc-xlcompat-sync-64.ll
@@ -0,0 +1,90 @@
+; RUN: llc -verify-machineinstrs -mtriple=powerpc64-unknown-unknown \
+; RUN: -mcpu=pwr7 < %s | FileCheck %s
+; RUN: llc -verify-machineinstrs -mtriple=powerpc64le-unknown-unknown \
+; RUN: -mcpu=pwr8 < %s | FileCheck %s
+; RUN: llc -verify-machineinstrs -mtriple=powerpc64-unknown-aix \
+; RUN: -mcpu=pwr7 < %s | FileCheck %s
+
+define dso_local i64 @test_builtin_ppc_popcntb_i64(i64 %a) local_unnamed_addr {
+; CHECK-LABEL: test_builtin_ppc_popcntb_i64
+
+entry:
+  %popcntb = tail call i64 @llvm.ppc.popcntb.i64.i64(i64 %a)
+; CHECK: popcntb 3, 3
+
+  ret i64 %popcntb
+; CHECK: blr
+}
+
+declare i64 @llvm.ppc.popcntb.i64.i64(i64)
+
+define dso_local void @test_builtin_ppc_eieio() {
+; CHECK-LABEL: test_builtin_ppc_eieio
+
+entry:
+  call void @llvm.ppc.eieio()
+; CHECK: ori 2, 2, 0
+; CHECK-NEXT: ori 2, 2, 0
+; CHECK-NEXT: eieio
+ 
+  ret void
+; CHECK: blr
+}
+
+declare void @llvm.ppc.eieio()
+
+define dso_local void @test_builtin_ppc_iospace_eieio() {
+; CHECK-LABEL: test_builtin_ppc_iospace_eieio
+
+entry:
+  call void @llvm.ppc.iospace.eieio()
+; CHECK: ori 2, 2, 0
+; CHECK-NEXT: ori 2, 2, 0
+; CHECK-NEXT: eieio
+ 
+  ret void
+; CHECK: blr
+}
+
+declare void @llvm.ppc.iospace.eieio()
+
+define dso_local void @test_builtin_ppc_iospace_lwsync() {
+; CHECK-LABEL: test_builtin_ppc_iospace_lwsync
+
+entry:
+  call void @llvm.ppc.iospace.lwsync()
+; CHECK: lwsync
+
+  ret void
+; CHECK: blr
+}
+
+declare void @llvm.ppc.iospace.lwsync()
+
+define dso_local void @test_builtin_ppc_iospace_sync() {
+; CHECK-LABEL: test_builtin_ppc_iospace_sync
+
+entry:
+  call void @llvm.ppc.iospace.sync()
+; CHECK: sync
+
+  ret void
+; CHECK: blr
+}
+
+declare void @llvm.ppc.iospace.sync()
+
+define dso_local void @test_builtin_ppc_icbt() {
+; CHECK-LABEL: test_builtin_ppc_icbt
+
+entry:
+  %a = alloca i8*, align 8
+  %0 = load i8*, i8** %a, align 8
+  call void @llvm.ppc.icbt(i8* %0)
+; CHECK: icbt 0, 0, 3
+
+  ret void
+; CHECK: blr
+}
+
+declare void @llvm.ppc.icbt(i8

[PATCH] D105322: [NFC][OpenMP][CUDA] Add test for using `-x cuda -fopenmp`

2021-07-02 Thread Joachim Meyer via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG75e941b05c78: [NFC][OpenMP][CUDA] Add test for using `-x 
cuda -fopenmp` (authored by fodinabor).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105322

Files:
  clang/test/Headers/Inputs/include/crt/device_double_functions.hpp
  clang/test/Headers/Inputs/include/crt/device_functions.hpp
  clang/test/Headers/Inputs/include/crt/device_runtime.h
  clang/test/Headers/Inputs/include/crt/host_runtime.h
  clang/test/Headers/Inputs/include/crt/math_functions.hpp
  clang/test/Headers/Inputs/include/crt/sm_70_rt.hpp
  clang/test/Headers/Inputs/include/cstdlib
  clang/test/Headers/Inputs/include/cuda.h
  clang/test/Headers/Inputs/include/cuda_runtime.h
  clang/test/Headers/Inputs/include/curand_mtgp32_kernel.h
  clang/test/Headers/Inputs/include/device_atomic_functions.h
  clang/test/Headers/Inputs/include/device_atomic_functions.hpp
  clang/test/Headers/Inputs/include/device_double_functions.h
  clang/test/Headers/Inputs/include/driver_types.h
  clang/test/Headers/Inputs/include/host_config.h
  clang/test/Headers/Inputs/include/host_defines.h
  clang/test/Headers/Inputs/include/math_functions_dbl_ptx3.hpp
  clang/test/Headers/Inputs/include/new
  clang/test/Headers/Inputs/include/sm_20_atomic_functions.hpp
  clang/test/Headers/Inputs/include/sm_20_intrinsics.hpp
  clang/test/Headers/Inputs/include/sm_32_atomic_functions.hpp
  clang/test/Headers/Inputs/include/sm_60_atomic_functions.hpp
  clang/test/Headers/Inputs/include/sm_61_intrinsics.hpp
  clang/test/Headers/Inputs/include/string.h
  clang/test/Headers/Inputs/include/texture_indirect_functions.h
  clang/test/Headers/cuda_with_openmp.cu

Index: clang/test/Headers/cuda_with_openmp.cu
===
--- /dev/null
+++ clang/test/Headers/cuda_with_openmp.cu
@@ -0,0 +1,8 @@
+// Test using -x cuda -fopenmp does not clash integrated headers.
+// Reported in https://bugs.llvm.org/show_bug.cgi?id=48014
+///==///
+
+// REQUIRES: nvptx-registered-target
+
+// RUN: %clang -x cuda -fopenmp -c %s -o - --cuda-path=%S/../Driver/Inputs/CUDA/usr/local/cuda -nocudalib -isystem %S/Inputs/include -isystem %S/../../lib/Headers -fsyntax-only
+
Index: clang/test/Headers/Inputs/include/texture_indirect_functions.h
===
--- /dev/null
+++ clang/test/Headers/Inputs/include/texture_indirect_functions.h
@@ -0,0 +1,2 @@
+// required for __clang_cuda_runtime_wrapper.h tests
+#pragma once
Index: clang/test/Headers/Inputs/include/string.h
===
--- /dev/null
+++ clang/test/Headers/Inputs/include/string.h
@@ -0,0 +1,3 @@
+// required for __clang_cuda_runtime_wrapper.h tests
+#pragma once
+void* memcpy(void* dst, const void* src, size_t num);
Index: clang/test/Headers/Inputs/include/sm_61_intrinsics.hpp
===
--- /dev/null
+++ clang/test/Headers/Inputs/include/sm_61_intrinsics.hpp
@@ -0,0 +1,2 @@
+// required for __clang_cuda_runtime_wrapper.h tests
+#pragma once
Index: clang/test/Headers/Inputs/include/sm_60_atomic_functions.hpp
===
--- /dev/null
+++ clang/test/Headers/Inputs/include/sm_60_atomic_functions.hpp
@@ -0,0 +1,2 @@
+// required for __clang_cuda_runtime_wrapper.h tests
+#pragma once
Index: clang/test/Headers/Inputs/include/sm_32_atomic_functions.hpp
===
--- /dev/null
+++ clang/test/Headers/Inputs/include/sm_32_atomic_functions.hpp
@@ -0,0 +1,2 @@
+// required for __clang_cuda_runtime_wrapper.h tests
+#pragma once
Index: clang/test/Headers/Inputs/include/sm_20_intrinsics.hpp
===
--- /dev/null
+++ clang/test/Headers/Inputs/include/sm_20_intrinsics.hpp
@@ -0,0 +1,2 @@
+// required for __clang_cuda_runtime_wrapper.h tests
+#pragma once
Index: clang/test/Headers/Inputs/include/sm_20_atomic_functions.hpp
===
--- /dev/null
+++ clang/test/Headers/Inputs/include/sm_20_atomic_functions.hpp
@@ -0,0 +1,2 @@
+// required for __clang_cuda_runtime_wrapper.h tests
+#pragma once
Index: clang/test/Headers/Inputs/include/new
===
--- clang/test/Headers/Inputs/include/new
+++ clang/test/Headers/Inputs/include/new
@@ -1,3 +1,4 @@
+#pragma once
 
 namespace std
 {
Index: clang/test/Headers/Inputs/include/math_functions_dbl_ptx3.hpp
===
--- /dev/null
+++ clang/test/Headers/Inputs/include/math_functions_dbl_ptx3.hpp
@@ -0,0 +1,2 @@
+// required for __cl

[clang] 75e941b - [NFC][OpenMP][CUDA] Add test for using `-x cuda -fopenmp`

2021-07-02 Thread Joachim Meyer via cfe-commits

Author: Joachim Meyer
Date: 2021-07-02T19:03:15+02:00
New Revision: 75e941b05c78e19c51e5c960c925f334b08109bb

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

LOG: [NFC][OpenMP][CUDA] Add test for using `-x cuda -fopenmp`

This adds a very basic test in `cuda_with_openmp.cu` that just checks whether 
the CUDA & OpenMP integrated headers do compile, when a CUDA file is compiled 
with OpenMP (CPU) enabled.
Thus this basically adds the missing test for https://reviews.llvm.org/D90415.

Reviewed By: jdoerfert

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

Added: 
clang/test/Headers/Inputs/include/crt/device_double_functions.hpp
clang/test/Headers/Inputs/include/crt/device_functions.hpp
clang/test/Headers/Inputs/include/crt/device_runtime.h
clang/test/Headers/Inputs/include/crt/host_runtime.h
clang/test/Headers/Inputs/include/crt/math_functions.hpp
clang/test/Headers/Inputs/include/crt/sm_70_rt.hpp
clang/test/Headers/Inputs/include/cuda.h
clang/test/Headers/Inputs/include/cuda_runtime.h
clang/test/Headers/Inputs/include/curand_mtgp32_kernel.h
clang/test/Headers/Inputs/include/device_atomic_functions.h
clang/test/Headers/Inputs/include/device_atomic_functions.hpp
clang/test/Headers/Inputs/include/device_double_functions.h
clang/test/Headers/Inputs/include/driver_types.h
clang/test/Headers/Inputs/include/host_config.h
clang/test/Headers/Inputs/include/host_defines.h
clang/test/Headers/Inputs/include/math_functions_dbl_ptx3.hpp
clang/test/Headers/Inputs/include/sm_20_atomic_functions.hpp
clang/test/Headers/Inputs/include/sm_20_intrinsics.hpp
clang/test/Headers/Inputs/include/sm_32_atomic_functions.hpp
clang/test/Headers/Inputs/include/sm_60_atomic_functions.hpp
clang/test/Headers/Inputs/include/sm_61_intrinsics.hpp
clang/test/Headers/Inputs/include/string.h
clang/test/Headers/Inputs/include/texture_indirect_functions.h
clang/test/Headers/cuda_with_openmp.cu

Modified: 
clang/test/Headers/Inputs/include/cstdlib
clang/test/Headers/Inputs/include/new

Removed: 




diff  --git a/clang/test/Headers/Inputs/include/crt/device_double_functions.hpp 
b/clang/test/Headers/Inputs/include/crt/device_double_functions.hpp
new file mode 100644
index 0..bffa775cb2822
--- /dev/null
+++ b/clang/test/Headers/Inputs/include/crt/device_double_functions.hpp
@@ -0,0 +1,2 @@
+// required for __clang_cuda_runtime_wrapper.h tests
+#pragma once

diff  --git a/clang/test/Headers/Inputs/include/crt/device_functions.hpp 
b/clang/test/Headers/Inputs/include/crt/device_functions.hpp
new file mode 100644
index 0..41dc8722fe643
--- /dev/null
+++ b/clang/test/Headers/Inputs/include/crt/device_functions.hpp
@@ -0,0 +1,3 @@
+// required for __clang_cuda_runtime_wrapper.h tests
+#pragma once
+__device__ void   __brkpt();

diff  --git a/clang/test/Headers/Inputs/include/crt/device_runtime.h 
b/clang/test/Headers/Inputs/include/crt/device_runtime.h
new file mode 100644
index 0..bffa775cb2822
--- /dev/null
+++ b/clang/test/Headers/Inputs/include/crt/device_runtime.h
@@ -0,0 +1,2 @@
+// required for __clang_cuda_runtime_wrapper.h tests
+#pragma once

diff  --git a/clang/test/Headers/Inputs/include/crt/host_runtime.h 
b/clang/test/Headers/Inputs/include/crt/host_runtime.h
new file mode 100644
index 0..bffa775cb2822
--- /dev/null
+++ b/clang/test/Headers/Inputs/include/crt/host_runtime.h
@@ -0,0 +1,2 @@
+// required for __clang_cuda_runtime_wrapper.h tests
+#pragma once

diff  --git a/clang/test/Headers/Inputs/include/crt/math_functions.hpp 
b/clang/test/Headers/Inputs/include/crt/math_functions.hpp
new file mode 100644
index 0..fbd2bb52fa842
--- /dev/null
+++ b/clang/test/Headers/Inputs/include/crt/math_functions.hpp
@@ -0,0 +1,12 @@
+// required for __clang_cuda_runtime_wrapper.h tests
+#pragma once
+__device__ int__isinff(float);
+__device__ int__isinf(double);
+__device__ int__finitef(float);
+__device__ int__isfinited(double);
+__device__ int__isnanf(float);
+__device__ int__isnan(double);
+__device__ int__signbitf(float);
+__device__ int__signbitd(double);
+__device__ double max(double, double);
+__device__ float  max(float, float);

diff  --git a/clang/test/Headers/Inputs/include/crt/sm_70_rt.hpp 
b/clang/test/Headers/Inputs/include/crt/sm_70_rt.hpp
new file mode 100644
index 0..bffa775cb2822
--- /dev/null
+++ b/clang/test/Headers/Inputs/include/crt/sm_70_rt.hpp
@@ -0,0 +1,2 @@
+// required for __clang_cuda_runtime_wrapper.h tests
+#pragma on

[PATCH] D105340: [analyzer] Produce SymbolCast symbols for integral types in SValBuilder::evalCast

2021-07-02 Thread Denys Petrov via Phabricator via cfe-commits
ASDenysPetrov added a comment.

In D105340#2855387 , @vsavchenko 
wrote:

> Also, although the test is very extensive, it is pretty lopsided at the same 
> time.  C-style cast is only one case out of the myriad of all explicit and, 
> more importantly, implicit casts.

I agree in a part of size, but these C-style casts generates the same AST tree 
as all other ex/implicit forms of casts . Though, casts can look completely 
differently but at a low level they are very similar.
Here is an example:

  void test(long x) {
(llong)(short)(char)x; 
  }
  
  FunctionDecl 0xbc306b8  line:1:6 test 'void (long)'
|-ParmVarDecl 0xbc305f0  col:16 used x 'long'
`-CompoundStmt 0xbc9f4b0 
  `-CStyleCastExpr 0xbc9f488  'long long' 
`-ImplicitCastExpr 0xbc9f470  'long long' 
 part_of_explicit_cast
  `-CStyleCastExpr 0xbc9f430  'short' 
`-ImplicitCastExpr 0xbc9f418  'short' 
 part_of_explicit_cast
  `-CStyleCastExpr 0xbc9f3d8  'char' 
`-ImplicitCastExpr 0xbc9f3c0  'char'  
part_of_explicit_cast
  `-ImplicitCastExpr 0xbc9f3a8  'long'  
part_of_explicit_cast
`-DeclRefExpr 0xbc9f378  'long' lvalue ParmVar 
0xbc305f0 'x' 'long'

and

  void test(long x) {  
char c = x;
if(static_cast(c) == -1ll);
  }
  
  `-FunctionDecl 0xbc606b8  line:1:6 test 'void (long)'
|-ParmVarDecl 0xbc605f0  col:16 used x 'long'
`-CompoundStmt 0xbcd0598 
  |-DeclStmt 0xbcd0450 
  | `-VarDecl 0xbcd0398  col:8 used c 'char' cinit
  |   `-ImplicitCastExpr 0xbcd0438  'char' 
  | `-ImplicitCastExpr 0xbcd0420  'long' 
  |   `-DeclRefExpr 0xbcd0400  'long' lvalue ParmVar 0xbc605f0 
'x' 'long'
  `-IfStmt 0xbcd0578 
|-BinaryOperator 0xbcd0550  'bool' '=='
| |-ImplicitCastExpr 0xbcd0538  'long long' 

| | `-CXXStaticCastExpr 0xbcd04d0  'short' 
static_cast 
| |   `-ImplicitCastExpr 0xbcd04b8  'short'  
part_of_explicit_cast
| | `-ImplicitCastExpr 0xbcd04a0  'char'  
part_of_explicit_cast
| |   `-DeclRefExpr 0xbcd0468  'char' lvalue Var 0xbcd0398 
'c' 'char'
| `-UnaryOperator 0xbcd0520  'long long' prefix '-'
|   `-IntegerLiteral 0xbcd0500  'long long' 1
`-NullStmt 0xbcd0570 

We can see similar `IntegralCast` for both variants. I was aiming to generate 
all the cases of `IntegralCast` and C-style cast is enough for me.




Comment at: clang/include/clang/StaticAnalyzer/Core/AnalyzerOptions.def:318
+ANALYZER_OPTION(bool, ShouldHandleIntegralCastForRanges,
+"handle-integral-cast-for-ranges",
+"Handle truncations, promotions and conversions for ranges of "

vsavchenko wrote:
> BTW, mb it should be less specific?  Something like 
> `ShouldSupportSymbolicIntegerCasts`?
> BTW 2, do you even plan on supporting symbolic casts in other cases?
> ShouldSupportSymbolicIntegerCasts?
Thanks. I thought about an appropriate name but failed to come up. That's what 
we need!
> BTW 2, do you even plan on supporting symbolic casts in other cases?
I think about adding //bool-int//, //int-bool//, //ptr-int//, //int-ptr// to 
the list.


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

https://reviews.llvm.org/D105340

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


[PATCH] D105322: [NFC][OpenMP][CUDA] Add test for using `-x cuda -fopenmp`

2021-07-02 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert accepted this revision.
jdoerfert added a comment.
This revision is now accepted and ready to land.

Wow, thanks for the CUDA stubs!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105322

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


[PATCH] D105221: [openmp][nfc] Simplify macros guarding math complex headers

2021-07-02 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert requested changes to this revision.
jdoerfert added a comment.

We need a macro for OPENMP and one for OPENMP_OFFLOAD, we can use a single one 
for the latter and avoid _NVPTX, _AMDGCN, ... but we need both as described by 
@fodinabor.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105221

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


[PATCH] D105263: [X86] AVX512FP16 instructions enabling 1/6

2021-07-02 Thread Simon Pilgrim via Phabricator via cfe-commits
RKSimon added inline comments.



Comment at: clang/lib/Headers/avx512fp16intrin.h:38
+
+static __inline__ _Float16 __DEFAULT_FN_ATTRS512 _mm512_cvtsh_h(__m512h __a) {
+  return __a[0];

pengfei wrote:
> RKSimon wrote:
> > I realize its a lot of work, but is there any chance that we could get 
> > doxygen comments to document these intrinsics?
> I'm hesitating not only for the work but also the effect. We have about 1K 
> new intrinsics and more than 5K LOC in total in the two header files. Adding 
> the doxygen comments will make the readability worse and increase the 
> difficulty in review. It's also a burden in maintaining the correctness.
> Do you think it's feasible to only add a link to intrinsic guide? We have 
> decided to only using link that points intrinsic guide in our product 
> compiler. Using one source is friendly to maintainess. And I think intrinsic 
> guide is also easy to use that doxygen.
I completely understand where you're coming from. What we do lose is the 
ability for code editors to display the doxygen when using the intrinsic (or 
mouseover the code). Are there any particular intrinsics that we could do with 
having comments closer at hand - ones that take rounding modes that its tricky 
to remember the enum/defines for or implicit load/store alignments come to mind?

I'm not sure about the idea of linking to external docs for specs - do we have 
a style guide policy on this?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105263

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


[PATCH] D105263: [X86] AVX512FP16 instructions enabling 1/6

2021-07-02 Thread Craig Topper via Phabricator via cfe-commits
craig.topper added inline comments.



Comment at: llvm/lib/Target/X86/X86Subtarget.h:748
   bool hasVLX() const { return HasVLX; }
+  bool hasFP16() const { return HasFP16; }
   bool hasPKU() const { return HasPKU; }

pengfei wrote:
> RKSimon wrote:
> > I'm a little worried this might get confused with hasF16C - am I just being 
> > over cautious?
> Make sense. How about `hasAVX512FP16`? I can update the name as a followup 
> patch once these patches merged.
That sounds good to me. We should maybe go back and update some of the others. 
Especially VNNI since we also have AVXVNNI.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105263

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


[PATCH] D105263: [X86] AVX512FP16 instructions enabling 1/6

2021-07-02 Thread Pengfei Wang via Phabricator via cfe-commits
pengfei added inline comments.



Comment at: clang/lib/Headers/avx512fp16intrin.h:38
+
+static __inline__ _Float16 __DEFAULT_FN_ATTRS512 _mm512_cvtsh_h(__m512h __a) {
+  return __a[0];

RKSimon wrote:
> I realize its a lot of work, but is there any chance that we could get 
> doxygen comments to document these intrinsics?
I'm hesitating not only for the work but also the effect. We have about 1K new 
intrinsics and more than 5K LOC in total in the two header files. Adding the 
doxygen comments will make the readability worse and increase the difficulty in 
review. It's also a burden in maintaining the correctness.
Do you think it's feasible to only add a link to intrinsic guide? We have 
decided to only using link that points intrinsic guide in our product compiler. 
Using one source is friendly to maintainess. And I think intrinsic guide is 
also easy to use that doxygen.



Comment at: llvm/lib/Target/X86/X86Subtarget.h:748
   bool hasVLX() const { return HasVLX; }
+  bool hasFP16() const { return HasFP16; }
   bool hasPKU() const { return HasPKU; }

RKSimon wrote:
> I'm a little worried this might get confused with hasF16C - am I just being 
> over cautious?
Make sense. How about `hasAVX512FP16`? I can update the name as a followup 
patch once these patches merged.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105263

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


[PATCH] D105354: [clang][AST] Add support for DecompositionDecl to ASTImporter.

2021-07-02 Thread Balázs Kéri via Phabricator via cfe-commits
balazske created this revision.
Herald added subscribers: whisperity, martong, teemperor, gamesh411, Szelethus, 
dkrupp.
Herald added a reviewer: a.sidorin.
Herald added a reviewer: shafik.
balazske requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

BindingDecl was added recently but the related DecompositionDecl is needed
to make C++17 structured bindings importable.
Import of BindingDecl was changed to avoid infinite import loop.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D105354

Files:
  clang/lib/AST/ASTImporter.cpp
  clang/unittests/AST/ASTImporterTest.cpp


Index: clang/unittests/AST/ASTImporterTest.cpp
===
--- clang/unittests/AST/ASTImporterTest.cpp
+++ clang/unittests/AST/ASTImporterTest.cpp
@@ -3725,6 +3725,32 @@
   VerifyImport("y3");
 }
 
+TEST_P(ImportVariables, ImportDecompositionDeclArray) {
+  Decl *From, *To;
+  std::tie(From, To) = getImportedDecl(
+  R"(
+  void declToImport() {
+int a[2] = {1,2};
+auto [x1,y1] = a;
+  };
+  )",
+  Lang_CXX17, "", Lang_CXX17);
+
+  TranslationUnitDecl *FromTU = From->getTranslationUnitDecl();
+  auto *FromDecomp =
+  FirstDeclMatcher().match(FromTU, decompositionDecl());
+  auto *ToDecomp = Import(FromDecomp, Lang_CXX17);
+  EXPECT_TRUE(ToDecomp);
+
+  ArrayRef FromB = FromDecomp->bindings();
+  ArrayRef ToB = ToDecomp->bindings();
+  EXPECT_EQ(FromB.size(), ToB.size());
+  for (unsigned int I = 0; I < FromB.size(); ++I) {
+auto *ToBI = Import(FromB[I], Lang_CXX17);
+EXPECT_EQ(ToBI, ToB[I]);
+  }
+}
+
 struct ImportClasses : ASTImporterOptionSpecificTestBase {};
 
 TEST_P(ImportClasses, ImportDefinitionWhenProtoIsInNestedToContext) {
Index: clang/lib/AST/ASTImporter.cpp
===
--- clang/lib/AST/ASTImporter.cpp
+++ clang/lib/AST/ASTImporter.cpp
@@ -2302,6 +2302,11 @@
   if (ToND)
 return ToND;
 
+  BindingDecl *ToD;
+  if (GetImportedOrCreateDecl(ToD, D, Importer.getToContext(), DC, Loc,
+  Name.getAsIdentifierInfo()))
+return ToD;
+
   Error Err = Error::success();
   QualType ToType = importChecked(Err, D->getType());
   Expr *ToBinding = importChecked(Err, D->getBinding());
@@ -2309,11 +2314,6 @@
   if (Err)
 return std::move(Err);
 
-  BindingDecl *ToD;
-  if (GetImportedOrCreateDecl(ToD, D, Importer.getToContext(), DC, Loc,
-  Name.getAsIdentifierInfo()))
-return ToD;
-
   ToD->setBinding(ToType, ToBinding);
   ToD->setDecomposedDecl(ToDecomposedDecl);
   addDeclToContexts(D, ToD);
@@ -4098,14 +4098,26 @@
   if (Err)
 return std::move(Err);
 
-  // Create the imported variable.
   VarDecl *ToVar;
-  if (GetImportedOrCreateDecl(ToVar, D, Importer.getToContext(), DC,
-  ToInnerLocStart, Loc,
-  Name.getAsIdentifierInfo(),
-  ToType, ToTypeSourceInfo,
-  D->getStorageClass()))
-return ToVar;
+  if (auto *FromDecomp = dyn_cast(D)) {
+SmallVector Bindings(FromDecomp->bindings().size());
+if (Error Err =
+ImportArrayChecked(FromDecomp->bindings(), Bindings.begin()))
+  return std::move(Err);
+DecompositionDecl *ToDecomp;
+if (GetImportedOrCreateDecl(
+ToDecomp, FromDecomp, Importer.getToContext(), DC, ToInnerLocStart,
+Loc, ToType, ToTypeSourceInfo, D->getStorageClass(), Bindings))
+  return ToDecomp;
+ToVar = ToDecomp;
+  } else {
+// Create the imported variable.
+if (GetImportedOrCreateDecl(ToVar, D, Importer.getToContext(), DC,
+ToInnerLocStart, Loc,
+Name.getAsIdentifierInfo(), ToType,
+ToTypeSourceInfo, D->getStorageClass()))
+  return ToVar;
+  }
 
   ToVar->setTSCSpec(D->getTSCSpec());
   ToVar->setQualifierInfo(ToQualifierLoc);


Index: clang/unittests/AST/ASTImporterTest.cpp
===
--- clang/unittests/AST/ASTImporterTest.cpp
+++ clang/unittests/AST/ASTImporterTest.cpp
@@ -3725,6 +3725,32 @@
   VerifyImport("y3");
 }
 
+TEST_P(ImportVariables, ImportDecompositionDeclArray) {
+  Decl *From, *To;
+  std::tie(From, To) = getImportedDecl(
+  R"(
+  void declToImport() {
+int a[2] = {1,2};
+auto [x1,y1] = a;
+  };
+  )",
+  Lang_CXX17, "", Lang_CXX17);
+
+  TranslationUnitDecl *FromTU = From->getTranslationUnitDecl();
+  auto *FromDecomp =
+  FirstDeclMatcher().match(FromTU, decompositionDecl());
+  auto *ToDecomp = Import(FromDecomp, Lang_CXX17);
+  EXPECT_TRUE(ToDecomp);
+
+  ArrayRef FromB = FromDecomp->bindings();
+  ArrayRef ToB = ToDecomp->bindings();
+  EXPECT_EQ(FromB.size(), ToB.size());
+  for (unsigned int I = 0; I < FromB.size(); ++I) {

[PATCH] D104616: [analyzer] Model comparision methods of std::unique_ptr

2021-07-02 Thread Gábor Horváth via Phabricator via cfe-commits
xazax.hun added inline comments.



Comment at: clang/lib/StaticAnalyzer/Checkers/SmartPtrModeling.cpp:408
+  auto makeSValFor = [&C, &State, this](const Expr *E, SVal S) -> SVal {
+if (S.isZeroConstant()) {
+  return C.getSValBuilder().makeZeroVal(E->getType());

Do we want to create a new SVal in this case? Why returning `S` is insufficient?



Comment at: clang/lib/StaticAnalyzer/Checkers/SmartPtrModeling.cpp:416
+QualType Type = getInnerPointerType(C, E->getType()->getAsCXXRecordDecl());
+std::tie(Val, State) = retrieveOrConjureInnerPtrVal(Reg, E, Type, C);
+return Val;

While this is smart (overwriting the state here), I think this is hard to 
follow. I'd prefer this lambda returning a pair.



Comment at: clang/lib/StaticAnalyzer/Checkers/SmartPtrModeling.cpp:435
+ProgramStateRef TrueState, FalseState;
+std::tie(TrueState, FalseState) =
+State->assume(*RetVal.getAs());

`assume` might not return a state (when the analyzer is smart enough to figure 
out one path is infeasible). While your code would probably work as is, as far 
as I remember we usually try to not call addTransition with `null` states. 



Comment at: clang/test/Analysis/smart-ptr.cpp:484
+  clang_analyzer_eval(nullPtr != nullptr);// expected-warning{{FALSE}}
+  clang_analyzer_eval(nullptr <= unknownPtr); // expected-warning{{TRUE}}
+}

I do not see test cases where the path is actually split. Would you add some?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D104616

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


[PATCH] D105340: [analyzer] Produce SymbolCast symbols for integral types in SValBuilder::evalCast

2021-07-02 Thread Valeriy Savchenko via Phabricator via cfe-commits
vsavchenko added inline comments.



Comment at: clang/include/clang/StaticAnalyzer/Core/AnalyzerOptions.def:318
+ANALYZER_OPTION(bool, ShouldHandleIntegralCastForRanges,
+"handle-integral-cast-for-ranges",
+"Handle truncations, promotions and conversions for ranges of "

BTW, mb it should be less specific?  Something like 
`ShouldSupportSymbolicIntegerCasts`?
BTW 2, do you even plan on supporting symbolic casts in other cases?


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

https://reviews.llvm.org/D105340

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


[PATCH] D105340: [analyzer] Produce SymbolCast symbols for integral types in SValBuilder::evalCast

2021-07-02 Thread Valeriy Savchenko via Phabricator via cfe-commits
vsavchenko added a comment.

Also, even though the test is very extensive it is pretty lopsided at the same 
time.  C-style cast is only one case out of the myriad of all explicit and, 
more importantly, implicit casts.


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

https://reviews.llvm.org/D105340

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


[PATCH] D105273: [analyzer] Introduce range-based reasoning for subtraction operator

2021-07-02 Thread Valeriy Savchenko via Phabricator via cfe-commits
vsavchenko added a comment.

Hey Manas!  Great job, you put this together real quick!




Comment at: clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp:1490
+  // the resulting range should be [Min, Max].
+  if (ResultType.isUnsigned()) {
+return {RangeFactory, ValueFactory.getValue(Min),

Maybe you can include this as yet another condition in the next `if` statement? 
 Their bodies are identical.



Comment at: clang/test/Analysis/constant-folding.c:399
+// (a - b) = [0, 5] U [UINT_MAX - 9, UINT_MAX]
+clang_analyzer_eval((a - b) != 6); // expected-warning{{TRUE}}
+clang_analyzer_eval((a - b) != UINT_MAX - 10); // expected-warning{{TRUE}}

Maybe you can check `(a - b) > 5 && (a - b) < UINT_MAX - 9` to cover the whole 
range?



Comment at: clang/test/Analysis/constant-folding.c:405
+
+  if (c >= INT_MAX - 5 && d >= INT_MAX - 5) {
+// (c - d) = [-5, 5]

This is also Min and Max overflowing on the positive side.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105273

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


[PATCH] D105083: [clangd] Ensure Ref::Container refers to an indexed symbol

2021-07-02 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet added inline comments.



Comment at: clang-tools-extra/clangd/index/SymbolCollector.cpp:334
 
+const Decl *SymbolCollector::getRefContainer(const Decl *Enclosing) {
+  const NamedDecl *ND = dyn_cast_or_null(Enclosing);

why do we need to expose this function in the class interface? ASTCtx is 
reachable from Decl, and we can just pass in Opts.

Also I believe we should take in a declcontext as an input parameter, and make 
use of `ASTNode.ParentDC` for starting the traversal.

This also requires some comments explaining that it'll return the first context 
that is known by index.



Comment at: clang-tools-extra/clangd/index/SymbolCollector.cpp:335
+const Decl *SymbolCollector::getRefContainer(const Decl *Enclosing) {
+  const NamedDecl *ND = dyn_cast_or_null(Enclosing);
+  while (ND && !shouldCollectSymbol(*ND, *ASTCtx, Opts, true)) {

in theory enclosing namespace can also be unnamed, something like a `BlockDecl`.

I think we should enforce the return value to be a named decl, but I don't 
think we should enforce any intermediate parents to be named decls.



Comment at: clang-tools-extra/clangd/index/SymbolCollector.cpp:489
 DeclRefs[ND].push_back(
-SymbolRef{SM.getFileLoc(Loc), Roles, ASTNode.Parent});
+SymbolRef{SM.getFileLoc(Loc), Roles, getRefContainer(ASTNode.Parent)});
   // Don't continue indexing if this is a mere reference.

as mentioned above I think we should start the traversal from 
`ASTNode.ParentDC`. any downsides to doing that ? I don't see a case where this 
container we return is **not** a `DeclContext`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105083

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


[PATCH] D104797: [WebAssembly] Implementation of global.get/set for reftypes in LLVM IR

2021-07-02 Thread Paulo Matos via Phabricator via cfe-commits
pmatos added a comment.

In D104797#2855322 , @pmatos wrote:

> After @arsenm 's commit 
> https://github.com/llvm/llvm-project/commit/990278d026d680942c859be70836ad34a9a716f7,
>  MachineOperands store LLT for size instead of uint64_t and the constructor 
> called from `SelectionDAG::getLoad`, calls `MachineMemOperand` which does:
>
>   : MachineMemOperand(ptrinfo, f,
>   s == ~UINT64_C(0) ? LLT() : LLT::scalar(8 * s), a,
>   AAInfo, Ranges, SSID, Ordering, FailureOrdering) {}
>
> Because `s` is zero for reference types, `LLT::scalar(0)` is called, which 
> asserts because scalar LLTs cannot have zero size. Why do we have the check 
> `s == ~UINT64_C(0)`, instead of `ss == UINT64_C(0)` given opaque types and 
> therefore reference types are zero sized?

OK, sort of replying to myself `~UINT64_T(0)` is the size for invalid types. I 
think at this point we need `LLT` support for opaque types. Maybe we couldn't 
have opaque types stored in memory but we now can with reference types in 
WebAssembly.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D104797

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


[PATCH] D105340: [analyzer] Produce SymbolCast symbols for integral types in SValBuilder::evalCast

2021-07-02 Thread Denys Petrov via Phabricator via cfe-commits
ASDenysPetrov added inline comments.



Comment at: clang/test/Analysis/produce-symbolcast.cpp:1
+// RUN: %clang_analyze_cc1 -analyzer-checker=debug.ExprInspection 
-analyzer-config handle-integral-cast-for-ranges=true -verify %s
+

steakhal wrote:
> vsavchenko wrote:
> > ASDenysPetrov wrote:
> > > vsavchenko wrote:
> > > > This test is failing on my desktop, when I downloaded your patch:
> > > > ```
> > > > error: 'warning' diagnostics expected but not seen: 
> > > >   File .../produce-symbolcast.cpp Line 67: (long) (reg_$0)
> > > >   File .../produce-symbolcast.cpp Line 79: (long long) ((unsigned long) 
> > > > (reg_$0))
> > > >   File .../produce-symbolcast.cpp Line 122: (unsigned long) 
> > > > (reg_$0)
> > > >   File .../produce-symbolcast.cpp Line 134: (unsigned long long) 
> > > > ((unsigned long) (reg_$0))
> > > >   File .../produce-symbolcast.cpp Line 192: (long) (reg_$0)
> > > >   File .../produce-symbolcast.cpp Line 204: (long long) ((unsigned 
> > > > long) (reg_$0))
> > > >   File .../produce-symbolcast.cpp Line 247: (unsigned long) 
> > > > (reg_$0)
> > > >   File .../produce-symbolcast.cpp Line 259: (unsigned long long) 
> > > > ((unsigned long) (reg_$0))
> > > >   File .../produce-symbolcast.cpp Line 317: (long) (reg_$0)
> > > >   File .../produce-symbolcast.cpp Line 329: (long long) ((unsigned 
> > > > long) (reg_$0))
> > > >   File .../produce-symbolcast.cpp Line 372: (unsigned long) (reg_$0 > > > x>)
> > > >   File .../produce-symbolcast.cpp Line 384: (unsigned long long) 
> > > > ((unsigned long) (reg_$0))
> > > >   File .../produce-symbolcast.cpp Line 448: (long long) (reg_$0)
> > > >   File .../produce-symbolcast.cpp Line 454: (long long) ((unsigned 
> > > > long) (reg_$0))
> > > >   File .../produce-symbolcast.cpp Line 492: (unsigned long) 
> > > > (reg_$0)
> > > >   File .../produce-symbolcast.cpp Line 497: (unsigned long) 
> > > > (reg_$0)
> > > >   File .../produce-symbolcast.cpp Line 503: (unsigned long long) 
> > > > (reg_$0)
> > > >   File .../produce-symbolcast.cpp Line 509: (unsigned long long) 
> > > > ((unsigned long) (reg_$0))
> > > >   File .../produce-symbolcast.cpp Line 562: (long) (reg_$0)
> > > >   File .../produce-symbolcast.cpp Line 567: (long) (reg_$0)
> > > >   File .../produce-symbolcast.cpp Line 574: (long) (reg_$0)
> > > >   File .../produce-symbolcast.cpp Line 579: (unsigned long) 
> > > > (reg_$0)
> > > >   File .../produce-symbolcast.cpp Line 617: (unsigned long) 
> > > > (reg_$0)
> > > >   File .../produce-symbolcast.cpp Line 622: (unsigned long) 
> > > > (reg_$0)
> > > >   File .../produce-symbolcast.cpp Line 629: (unsigned long long) 
> > > > ((long) (reg_$0))
> > > >   File .../produce-symbolcast.cpp Line 634: (unsigned long long) 
> > > > ((unsigned long) (reg_$0))
> > > >   File .../produce-symbolcast.cpp Line 937: (long) (reg_$0)
> > > >   File .../produce-symbolcast.cpp Line 949: (long long) ((long) 
> > > > (reg_$0))
> > > >   File .../produce-symbolcast.cpp Line 992: (unsigned long) 
> > > > (reg_$0)
> > > >   File .../produce-symbolcast.cpp Line 1004: (unsigned long long) 
> > > > ((long) (reg_$0))
> > > >   File .../produce-symbolcast.cpp Line 1062: (long) (reg_$0)
> > > >   File .../produce-symbolcast.cpp Line 1067: (long) (reg_$0)
> > > >   File .../produce-symbolcast.cpp Line 1074: (long long) ((long) 
> > > > (reg_$0))
> > > >   File .../produce-symbolcast.cpp Line 1078: (long long) (reg_$0 > > > x>)
> > > >   File .../produce-symbolcast.cpp Line 1129: (unsigned long long) 
> > > > ((long) (reg_$0))
> > > >   File .../produce-symbolcast.cpp Line 1133: (unsigned long long) 
> > > > (reg_$0)
> > > >   File .../produce-symbolcast.cpp Line 1187: (long) (reg_$0)
> > > >   File .../produce-symbolcast.cpp Line 1192: (long) (reg_$0)
> > > >   File .../produce-symbolcast.cpp Line 1199: (long long) ((long) 
> > > > (reg_$0))
> > > >   File .../produce-symbolcast.cpp Line 1204: (long long) ((unsigned 
> > > > long) (reg_$0))
> > > >   File .../produce-symbolcast.cpp Line 1242: (unsigned long) 
> > > > (reg_$0)
> > > >   File .../produce-symbolcast.cpp Line 1247: (unsigned long) 
> > > > (reg_$0)
> > > >   File .../produce-symbolcast.cpp Line 1254: (unsigned long long) 
> > > > ((long) (reg_$0))
> > > >   File .../produce-symbolcast.cpp Line 1259: (unsigned long long) 
> > > > ((unsigned long) (reg_$0))
> > > > error: 'warning' diagnostics seen but not expected: 
> > > >   File .../produce-symbolcast.cpp Line 67: (long) ((unsigned int) 
> > > > (reg_$0)) [debug.ExprInspection]
> > > >   File .../produce-symbolcast.cpp Line 79: (long long) (reg_$0) 
> > > > [debug.ExprInspection]
> > > >   File .../produce-symbolcast.cpp Line 122: (unsigned long) ((unsigned 
> > > > int) (reg_$0)) [debug.ExprInspection]
> > > >   File .../produce-symbolcast.cpp Line 134: (unsigned long long) 
> > > > (reg_$0) [debug.ExprInspection]
> > > >   File .../produce-symbolcast.cpp Line 192: (long) ((unsigned int) 
> > > > (reg_$0)) [debug.ExprInspe

[PATCH] D104797: [WebAssembly] Implementation of global.get/set for reftypes in LLVM IR

2021-07-02 Thread Paulo Matos via Phabricator via cfe-commits
pmatos added a comment.

After @arsenm 's commit 
https://github.com/llvm/llvm-project/commit/990278d026d680942c859be70836ad34a9a716f7,
 MachineOperands store LLT for size instead of uint64_t and the constructor 
called from `SelectionDAG::getLoad`, calls `MachineMemOperand` which does:

  : MachineMemOperand(ptrinfo, f,
  s == ~UINT64_C(0) ? LLT() : LLT::scalar(8 * s), a,
  AAInfo, Ranges, SSID, Ordering, FailureOrdering) {}

Because `s` is zero for reference types, `LLT::scalar(0)` is called, which 
asserts because scalar LLTs cannot have zero size. Why do we have the check `s 
== ~UINT64_C(0)`, instead of `ss == UINT64_C(0)` given opaque types and 
therefore reference types are zero sized.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D104797

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


[clang-tools-extra] e42bb5e - Reapply [clangd] Fix possible assertion fail in TUScheduler

2021-07-02 Thread Sam McCall via cfe-commits

Author: Sam McCall
Date: 2021-07-02T16:32:13+02:00
New Revision: e42bb5e35a88c6a163934080883d4c5bc1f32cfc

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

LOG: Reapply [clangd] Fix possible assertion fail in TUScheduler

This reverts commit fff966b6855aee6fc0d0d4cd401cdd525a838572.

Seems I managed to delete a critical ! after running the tests :-\

Added: 


Modified: 
clang-tools-extra/clangd/TUScheduler.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/TUScheduler.cpp 
b/clang-tools-extra/clangd/TUScheduler.cpp
index 09c68a3a250b..700d8264555f 100644
--- a/clang-tools-extra/clangd/TUScheduler.cpp
+++ b/clang-tools-extra/clangd/TUScheduler.cpp
@@ -1380,11 +1380,13 @@ bool ASTWorker::blockUntilIdle(Deadline Timeout) const {
   };
   // Make sure ASTWorker has processed all requests, which might issue new
   // updates to PreamblePeer.
-  WaitUntilASTWorkerIsIdle();
+  if (!WaitUntilASTWorkerIsIdle())
+return false;
   // Now that ASTWorker processed all requests, ensure PreamblePeer has served
   // all update requests. This might create new PreambleRequests for the
   // ASTWorker.
-  PreamblePeer.blockUntilIdle(Timeout);
+  if (!PreamblePeer.blockUntilIdle(Timeout))
+return false;
   assert(Requests.empty() &&
  "No new normal tasks can be scheduled concurrently with "
  "blockUntilIdle(): ASTWorker isn't threadsafe");



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


[clang-tools-extra] 33ff807 - Revert "[clangd] Unbreak mac build differently 0c96a92d8666b8"

2021-07-02 Thread Sam McCall via cfe-commits

Author: Sam McCall
Date: 2021-07-02T16:29:48+02:00
New Revision: 33ff8078ff744cb317ec8806c990a52d33310834

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

LOG: Revert "[clangd] Unbreak mac build differently 0c96a92d8666b8"

This reverts commit 2f79acb7b701c41494abff588b5f03a74ea2e11d.

Should no longer be needed after 26e1553a107f52667be879e99739a4153f8799d8

Added: 


Modified: 
clang-tools-extra/clangd/Transport.h
clang-tools-extra/clangd/tool/ClangdMain.cpp
llvm/utils/gn/secondary/clang-tools-extra/clangd/xpc/BUILD.gn

Removed: 




diff  --git a/clang-tools-extra/clangd/Transport.h 
b/clang-tools-extra/clangd/Transport.h
index ae6da722d91b1..b3db4eba85f93 100644
--- a/clang-tools-extra/clangd/Transport.h
+++ b/clang-tools-extra/clangd/Transport.h
@@ -18,6 +18,7 @@
 #ifndef LLVM_CLANG_TOOLS_EXTRA_CLANGD_TRANSPORT_H_
 #define LLVM_CLANG_TOOLS_EXTRA_CLANGD_TRANSPORT_H_
 
+#include "Features.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/Support/JSON.h"
 #include "llvm/Support/raw_ostream.h"

diff  --git a/clang-tools-extra/clangd/tool/ClangdMain.cpp 
b/clang-tools-extra/clangd/tool/ClangdMain.cpp
index c03dd927970d4..8db52c65061c8 100644
--- a/clang-tools-extra/clangd/tool/ClangdMain.cpp
+++ b/clang-tools-extra/clangd/tool/ClangdMain.cpp
@@ -6,13 +6,11 @@
 //
 
//===--===//
 
-// Must be before Transport.h include.
-#include "Features.h"
-
 #include "ClangdLSPServer.h"
 #include "CodeComplete.h"
 #include "Config.h"
 #include "ConfigProvider.h"
+#include "Features.h"
 #include "PathMapping.h"
 #include "Protocol.h"
 #include "TidyProvider.h"

diff  --git a/llvm/utils/gn/secondary/clang-tools-extra/clangd/xpc/BUILD.gn 
b/llvm/utils/gn/secondary/clang-tools-extra/clangd/xpc/BUILD.gn
index 0d375392ae257..921e0dbedeb54 100644
--- a/llvm/utils/gn/secondary/clang-tools-extra/clangd/xpc/BUILD.gn
+++ b/llvm/utils/gn/secondary/clang-tools-extra/clangd/xpc/BUILD.gn
@@ -16,6 +16,7 @@ static_library("transport") {
   deps = [
 ":conversions",
 "//clang-tools-extra/clangd",
+"//clang-tools-extra/clangd:features",
 "//clang-tools-extra/clangd/support",
 "//llvm/lib/Support",
   ]



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


[PATCH] D105340: [analyzer] Produce SymbolCast symbols for integral types in SValBuilder::evalCast

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



Comment at: clang/test/Analysis/produce-symbolcast.cpp:1
+// RUN: %clang_analyze_cc1 -analyzer-checker=debug.ExprInspection 
-analyzer-config handle-integral-cast-for-ranges=true -verify %s
+

vsavchenko wrote:
> ASDenysPetrov wrote:
> > vsavchenko wrote:
> > > This test is failing on my desktop, when I downloaded your patch:
> > > ```
> > > error: 'warning' diagnostics expected but not seen: 
> > >   File .../produce-symbolcast.cpp Line 67: (long) (reg_$0)
> > >   File .../produce-symbolcast.cpp Line 79: (long long) ((unsigned long) 
> > > (reg_$0))
> > >   File .../produce-symbolcast.cpp Line 122: (unsigned long) (reg_$0 > > x>)
> > >   File .../produce-symbolcast.cpp Line 134: (unsigned long long) 
> > > ((unsigned long) (reg_$0))
> > >   File .../produce-symbolcast.cpp Line 192: (long) (reg_$0)
> > >   File .../produce-symbolcast.cpp Line 204: (long long) ((unsigned long) 
> > > (reg_$0))
> > >   File .../produce-symbolcast.cpp Line 247: (unsigned long) (reg_$0 > > x>)
> > >   File .../produce-symbolcast.cpp Line 259: (unsigned long long) 
> > > ((unsigned long) (reg_$0))
> > >   File .../produce-symbolcast.cpp Line 317: (long) (reg_$0)
> > >   File .../produce-symbolcast.cpp Line 329: (long long) ((unsigned long) 
> > > (reg_$0))
> > >   File .../produce-symbolcast.cpp Line 372: (unsigned long) (reg_$0 > > x>)
> > >   File .../produce-symbolcast.cpp Line 384: (unsigned long long) 
> > > ((unsigned long) (reg_$0))
> > >   File .../produce-symbolcast.cpp Line 448: (long long) (reg_$0)
> > >   File .../produce-symbolcast.cpp Line 454: (long long) ((unsigned long) 
> > > (reg_$0))
> > >   File .../produce-symbolcast.cpp Line 492: (unsigned long) (reg_$0 > > x>)
> > >   File .../produce-symbolcast.cpp Line 497: (unsigned long) (reg_$0 > > x>)
> > >   File .../produce-symbolcast.cpp Line 503: (unsigned long long) 
> > > (reg_$0)
> > >   File .../produce-symbolcast.cpp Line 509: (unsigned long long) 
> > > ((unsigned long) (reg_$0))
> > >   File .../produce-symbolcast.cpp Line 562: (long) (reg_$0)
> > >   File .../produce-symbolcast.cpp Line 567: (long) (reg_$0)
> > >   File .../produce-symbolcast.cpp Line 574: (long) (reg_$0)
> > >   File .../produce-symbolcast.cpp Line 579: (unsigned long) (reg_$0 > > x>)
> > >   File .../produce-symbolcast.cpp Line 617: (unsigned long) (reg_$0 > > x>)
> > >   File .../produce-symbolcast.cpp Line 622: (unsigned long) (reg_$0 > > x>)
> > >   File .../produce-symbolcast.cpp Line 629: (unsigned long long) ((long) 
> > > (reg_$0))
> > >   File .../produce-symbolcast.cpp Line 634: (unsigned long long) 
> > > ((unsigned long) (reg_$0))
> > >   File .../produce-symbolcast.cpp Line 937: (long) (reg_$0)
> > >   File .../produce-symbolcast.cpp Line 949: (long long) ((long) 
> > > (reg_$0))
> > >   File .../produce-symbolcast.cpp Line 992: (unsigned long) (reg_$0 > > x>)
> > >   File .../produce-symbolcast.cpp Line 1004: (unsigned long long) ((long) 
> > > (reg_$0))
> > >   File .../produce-symbolcast.cpp Line 1062: (long) (reg_$0)
> > >   File .../produce-symbolcast.cpp Line 1067: (long) (reg_$0)
> > >   File .../produce-symbolcast.cpp Line 1074: (long long) ((long) 
> > > (reg_$0))
> > >   File .../produce-symbolcast.cpp Line 1078: (long long) (reg_$0)
> > >   File .../produce-symbolcast.cpp Line 1129: (unsigned long long) ((long) 
> > > (reg_$0))
> > >   File .../produce-symbolcast.cpp Line 1133: (unsigned long long) 
> > > (reg_$0)
> > >   File .../produce-symbolcast.cpp Line 1187: (long) (reg_$0)
> > >   File .../produce-symbolcast.cpp Line 1192: (long) (reg_$0)
> > >   File .../produce-symbolcast.cpp Line 1199: (long long) ((long) 
> > > (reg_$0))
> > >   File .../produce-symbolcast.cpp Line 1204: (long long) ((unsigned long) 
> > > (reg_$0))
> > >   File .../produce-symbolcast.cpp Line 1242: (unsigned long) 
> > > (reg_$0)
> > >   File .../produce-symbolcast.cpp Line 1247: (unsigned long) 
> > > (reg_$0)
> > >   File .../produce-symbolcast.cpp Line 1254: (unsigned long long) ((long) 
> > > (reg_$0))
> > >   File .../produce-symbolcast.cpp Line 1259: (unsigned long long) 
> > > ((unsigned long) (reg_$0))
> > > error: 'warning' diagnostics seen but not expected: 
> > >   File .../produce-symbolcast.cpp Line 67: (long) ((unsigned int) 
> > > (reg_$0)) [debug.ExprInspection]
> > >   File .../produce-symbolcast.cpp Line 79: (long long) (reg_$0) 
> > > [debug.ExprInspection]
> > >   File .../produce-symbolcast.cpp Line 122: (unsigned long) ((unsigned 
> > > int) (reg_$0)) [debug.ExprInspection]
> > >   File .../produce-symbolcast.cpp Line 134: (unsigned long long) 
> > > (reg_$0) [debug.ExprInspection]
> > >   File .../produce-symbolcast.cpp Line 192: (long) ((unsigned int) 
> > > (reg_$0)) [debug.ExprInspection]
> > >   File .../produce-symbolcast.cpp Line 204: (long long) (reg_$0) 
> > > [debug.ExprInspection]
> > >   File .../produce-symbolcast.cpp Line 247: (unsigned long) ((unsigned 
> > > int) (reg_$0)) [debug.

[clang-tools-extra] fff966b - Revert "[clangd] Fix possible assertion fail in TUScheduler"

2021-07-02 Thread Sam McCall via cfe-commits

Author: Sam McCall
Date: 2021-07-02T16:07:11+02:00
New Revision: fff966b6855aee6fc0d0d4cd401cdd525a838572

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

LOG: Revert "[clangd] Fix possible assertion fail in TUScheduler"

This reverts commit 50566947e98ea845030cfa3b4c199fb9a2052d53.

Added: 


Modified: 
clang-tools-extra/clangd/TUScheduler.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/TUScheduler.cpp 
b/clang-tools-extra/clangd/TUScheduler.cpp
index 05ce4f9c8272..09c68a3a250b 100644
--- a/clang-tools-extra/clangd/TUScheduler.cpp
+++ b/clang-tools-extra/clangd/TUScheduler.cpp
@@ -1380,13 +1380,11 @@ bool ASTWorker::blockUntilIdle(Deadline Timeout) const {
   };
   // Make sure ASTWorker has processed all requests, which might issue new
   // updates to PreamblePeer.
-  if (WaitUntilASTWorkerIsIdle())
-return false;
+  WaitUntilASTWorkerIsIdle();
   // Now that ASTWorker processed all requests, ensure PreamblePeer has served
   // all update requests. This might create new PreambleRequests for the
   // ASTWorker.
-  if (!PreamblePeer.blockUntilIdle(Timeout))
-return false;
+  PreamblePeer.blockUntilIdle(Timeout);
   assert(Requests.empty() &&
  "No new normal tasks can be scheduled concurrently with "
  "blockUntilIdle(): ASTWorker isn't threadsafe");



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


[PATCH] D104797: [WebAssembly] Implementation of global.get/set for reftypes in LLVM IR

2021-07-02 Thread Paulo Matos via Phabricator via cfe-commits
pmatos added a comment.

In D104797#2854939 , @lebedev.ri 
wrote:

> Reverted again
>
>   
>   FAIL: LLVM :: CodeGen/WebAssembly/funcref-call.ll (44466 of 44468)
>    TEST 'LLVM :: CodeGen/WebAssembly/funcref-call.ll' 
> FAILED 
>   Script:
>   --
>   : 'RUN: at line 1';   /builddirs/llvm-project/build-Clang12/bin/llc < 
> /repositories/llvm-project/llvm/test/CodeGen/WebAssembly/funcref-call.ll 
> --mtriple=wasm32-unknown-unknown -asm-verbose=false -mattr=+reference-types | 
> /builddirs/llvm-project/build-Clang12/bin/FileCheck 
> /repositories/llvm-project/llvm/test/CodeGen/WebAssembly/funcref-call.ll
>   --
>   Exit Code: 2
>   
>   Command Output (stderr):
>   --
>   llc: 
> /repositories/llvm-project/llvm/include/llvm/Support/LowLevelTypeImpl.h:44: 
> static llvm::LLT llvm::LLT::scalar(unsigned int): Assertion `SizeInBits > 0 
> && "invalid scalar size"' failed.
>
> Are you building llvm without assertions?

I am sorry - thanks for reverting.
Last time I tested with `check-all`, nothing was failing. Then I updated to 
`main` to commit but because `check-all` takes a while and I didn't want to 
miss the boat to push, I pushed the commit. 
However, the right procedure would have been probably to maybe run a quick 
`llvm-lit` on the WebAssembly tests. I didn't and between the main commit my 
patch was based on and current main `HEAD` a commit broke my patch again, 
specifically in sha 990278d026 
  (June 
29).

I am now analysing this patch to reland, so I can fix mine once again and 
reland.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D104797

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


[clang-tools-extra] 5056694 - [clangd] Fix possible assertion fail in TUScheduler

2021-07-02 Thread Sam McCall via cfe-commits

Author: Sam McCall
Date: 2021-07-02T15:57:39+02:00
New Revision: 50566947e98ea845030cfa3b4c199fb9a2052d53

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

LOG: [clangd] Fix possible assertion fail in TUScheduler

BlockUntilIdle is supposed to return false if it fails.
If an intermediate step fails to clear the queue, we shouldn't
charge ahead and assert on the state of the queue.

Added: 


Modified: 
clang-tools-extra/clangd/TUScheduler.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/TUScheduler.cpp 
b/clang-tools-extra/clangd/TUScheduler.cpp
index 09c68a3a250b..05ce4f9c8272 100644
--- a/clang-tools-extra/clangd/TUScheduler.cpp
+++ b/clang-tools-extra/clangd/TUScheduler.cpp
@@ -1380,11 +1380,13 @@ bool ASTWorker::blockUntilIdle(Deadline Timeout) const {
   };
   // Make sure ASTWorker has processed all requests, which might issue new
   // updates to PreamblePeer.
-  WaitUntilASTWorkerIsIdle();
+  if (WaitUntilASTWorkerIsIdle())
+return false;
   // Now that ASTWorker processed all requests, ensure PreamblePeer has served
   // all update requests. This might create new PreambleRequests for the
   // ASTWorker.
-  PreamblePeer.blockUntilIdle(Timeout);
+  if (!PreamblePeer.blockUntilIdle(Timeout))
+return false;
   assert(Requests.empty() &&
  "No new normal tasks can be scheduled concurrently with "
  "blockUntilIdle(): ASTWorker isn't threadsafe");



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


[PATCH] D105340: [analyzer] Produce SymbolCast symbols for integral types in SValBuilder::evalCast

2021-07-02 Thread Valeriy Savchenko via Phabricator via cfe-commits
vsavchenko added inline comments.



Comment at: clang/test/Analysis/produce-symbolcast.cpp:1
+// RUN: %clang_analyze_cc1 -analyzer-checker=debug.ExprInspection 
-analyzer-config handle-integral-cast-for-ranges=true -verify %s
+

ASDenysPetrov wrote:
> vsavchenko wrote:
> > This test is failing on my desktop, when I downloaded your patch:
> > ```
> > error: 'warning' diagnostics expected but not seen: 
> >   File .../produce-symbolcast.cpp Line 67: (long) (reg_$0)
> >   File .../produce-symbolcast.cpp Line 79: (long long) ((unsigned long) 
> > (reg_$0))
> >   File .../produce-symbolcast.cpp Line 122: (unsigned long) (reg_$0)
> >   File .../produce-symbolcast.cpp Line 134: (unsigned long long) ((unsigned 
> > long) (reg_$0))
> >   File .../produce-symbolcast.cpp Line 192: (long) (reg_$0)
> >   File .../produce-symbolcast.cpp Line 204: (long long) ((unsigned long) 
> > (reg_$0))
> >   File .../produce-symbolcast.cpp Line 247: (unsigned long) (reg_$0 > x>)
> >   File .../produce-symbolcast.cpp Line 259: (unsigned long long) ((unsigned 
> > long) (reg_$0))
> >   File .../produce-symbolcast.cpp Line 317: (long) (reg_$0)
> >   File .../produce-symbolcast.cpp Line 329: (long long) ((unsigned long) 
> > (reg_$0))
> >   File .../produce-symbolcast.cpp Line 372: (unsigned long) (reg_$0)
> >   File .../produce-symbolcast.cpp Line 384: (unsigned long long) ((unsigned 
> > long) (reg_$0))
> >   File .../produce-symbolcast.cpp Line 448: (long long) (reg_$0)
> >   File .../produce-symbolcast.cpp Line 454: (long long) ((unsigned long) 
> > (reg_$0))
> >   File .../produce-symbolcast.cpp Line 492: (unsigned long) (reg_$0)
> >   File .../produce-symbolcast.cpp Line 497: (unsigned long) (reg_$0)
> >   File .../produce-symbolcast.cpp Line 503: (unsigned long long) 
> > (reg_$0)
> >   File .../produce-symbolcast.cpp Line 509: (unsigned long long) ((unsigned 
> > long) (reg_$0))
> >   File .../produce-symbolcast.cpp Line 562: (long) (reg_$0)
> >   File .../produce-symbolcast.cpp Line 567: (long) (reg_$0)
> >   File .../produce-symbolcast.cpp Line 574: (long) (reg_$0)
> >   File .../produce-symbolcast.cpp Line 579: (unsigned long) (reg_$0 > x>)
> >   File .../produce-symbolcast.cpp Line 617: (unsigned long) (reg_$0 > x>)
> >   File .../produce-symbolcast.cpp Line 622: (unsigned long) (reg_$0 > x>)
> >   File .../produce-symbolcast.cpp Line 629: (unsigned long long) ((long) 
> > (reg_$0))
> >   File .../produce-symbolcast.cpp Line 634: (unsigned long long) ((unsigned 
> > long) (reg_$0))
> >   File .../produce-symbolcast.cpp Line 937: (long) (reg_$0)
> >   File .../produce-symbolcast.cpp Line 949: (long long) ((long) 
> > (reg_$0))
> >   File .../produce-symbolcast.cpp Line 992: (unsigned long) (reg_$0)
> >   File .../produce-symbolcast.cpp Line 1004: (unsigned long long) ((long) 
> > (reg_$0))
> >   File .../produce-symbolcast.cpp Line 1062: (long) (reg_$0)
> >   File .../produce-symbolcast.cpp Line 1067: (long) (reg_$0)
> >   File .../produce-symbolcast.cpp Line 1074: (long long) ((long) 
> > (reg_$0))
> >   File .../produce-symbolcast.cpp Line 1078: (long long) (reg_$0)
> >   File .../produce-symbolcast.cpp Line 1129: (unsigned long long) ((long) 
> > (reg_$0))
> >   File .../produce-symbolcast.cpp Line 1133: (unsigned long long) 
> > (reg_$0)
> >   File .../produce-symbolcast.cpp Line 1187: (long) (reg_$0)
> >   File .../produce-symbolcast.cpp Line 1192: (long) (reg_$0)
> >   File .../produce-symbolcast.cpp Line 1199: (long long) ((long) 
> > (reg_$0))
> >   File .../produce-symbolcast.cpp Line 1204: (long long) ((unsigned long) 
> > (reg_$0))
> >   File .../produce-symbolcast.cpp Line 1242: (unsigned long) (reg_$0 > x>)
> >   File .../produce-symbolcast.cpp Line 1247: (unsigned long) (reg_$0 > x>)
> >   File .../produce-symbolcast.cpp Line 1254: (unsigned long long) ((long) 
> > (reg_$0))
> >   File .../produce-symbolcast.cpp Line 1259: (unsigned long long) 
> > ((unsigned long) (reg_$0))
> > error: 'warning' diagnostics seen but not expected: 
> >   File .../produce-symbolcast.cpp Line 67: (long) ((unsigned int) 
> > (reg_$0)) [debug.ExprInspection]
> >   File .../produce-symbolcast.cpp Line 79: (long long) (reg_$0) 
> > [debug.ExprInspection]
> >   File .../produce-symbolcast.cpp Line 122: (unsigned long) ((unsigned int) 
> > (reg_$0)) [debug.ExprInspection]
> >   File .../produce-symbolcast.cpp Line 134: (unsigned long long) 
> > (reg_$0) [debug.ExprInspection]
> >   File .../produce-symbolcast.cpp Line 192: (long) ((unsigned int) 
> > (reg_$0)) [debug.ExprInspection]
> >   File .../produce-symbolcast.cpp Line 204: (long long) (reg_$0) 
> > [debug.ExprInspection]
> >   File .../produce-symbolcast.cpp Line 247: (unsigned long) ((unsigned int) 
> > (reg_$0)) [debug.ExprInspection]
> >   File .../produce-symbolcast.cpp Line 259: (unsigned long long) 
> > (reg_$0) [debug.ExprInspection]
> >   File .../produce-symbolcast.cpp Line 317: (long) ((unsigned int) 
> > (reg_$0)) [debug.ExprInspection]

[PATCH] D105263: [X86] AVX512FP16 instructions enabling 1/6

2021-07-02 Thread Simon Pilgrim via Phabricator via cfe-commits
RKSimon added inline comments.



Comment at: clang/lib/Headers/avx512fp16intrin.h:38
+
+static __inline__ _Float16 __DEFAULT_FN_ATTRS512 _mm512_cvtsh_h(__m512h __a) {
+  return __a[0];

I realize its a lot of work, but is there any chance that we could get doxygen 
comments to document these intrinsics?



Comment at: llvm/lib/Target/X86/X86Subtarget.h:748
   bool hasVLX() const { return HasVLX; }
+  bool hasFP16() const { return HasFP16; }
   bool hasPKU() const { return HasPKU; }

I'm a little worried this might get confused with hasF16C - am I just being 
over cautious?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105263

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


[PATCH] D105340: [analyzer] Produce SymbolCast symbols for integral types in SValBuilder::evalCast

2021-07-02 Thread Denys Petrov via Phabricator via cfe-commits
ASDenysPetrov added a comment.

I will update the patch soon according to your suggestions.




Comment at: clang/test/Analysis/bool-assignment.c:46-50
 #ifdef ANALYZER_CM_Z3
 BOOL x = y; // expected-warning {{Assignment of a non-Boolean value}}
 #else
-BOOL x = y; // no-warning
+BOOL x = y; // expected-warning {{Assignment of a non-Boolean value}}
 #endif

vsavchenko wrote:
> If Z3 and not Z3 are the same now, we can simply merge two cases and remove 
> preprocessor directive.
+1



Comment at: clang/test/Analysis/produce-symbolcast.cpp:1
+// RUN: %clang_analyze_cc1 -analyzer-checker=debug.ExprInspection 
-analyzer-config handle-integral-cast-for-ranges=true -verify %s
+

vsavchenko wrote:
> This test is failing on my desktop, when I downloaded your patch:
> ```
> error: 'warning' diagnostics expected but not seen: 
>   File .../produce-symbolcast.cpp Line 67: (long) (reg_$0)
>   File .../produce-symbolcast.cpp Line 79: (long long) ((unsigned long) 
> (reg_$0))
>   File .../produce-symbolcast.cpp Line 122: (unsigned long) (reg_$0)
>   File .../produce-symbolcast.cpp Line 134: (unsigned long long) ((unsigned 
> long) (reg_$0))
>   File .../produce-symbolcast.cpp Line 192: (long) (reg_$0)
>   File .../produce-symbolcast.cpp Line 204: (long long) ((unsigned long) 
> (reg_$0))
>   File .../produce-symbolcast.cpp Line 247: (unsigned long) (reg_$0)
>   File .../produce-symbolcast.cpp Line 259: (unsigned long long) ((unsigned 
> long) (reg_$0))
>   File .../produce-symbolcast.cpp Line 317: (long) (reg_$0)
>   File .../produce-symbolcast.cpp Line 329: (long long) ((unsigned long) 
> (reg_$0))
>   File .../produce-symbolcast.cpp Line 372: (unsigned long) (reg_$0)
>   File .../produce-symbolcast.cpp Line 384: (unsigned long long) ((unsigned 
> long) (reg_$0))
>   File .../produce-symbolcast.cpp Line 448: (long long) (reg_$0)
>   File .../produce-symbolcast.cpp Line 454: (long long) ((unsigned long) 
> (reg_$0))
>   File .../produce-symbolcast.cpp Line 492: (unsigned long) (reg_$0)
>   File .../produce-symbolcast.cpp Line 497: (unsigned long) (reg_$0)
>   File .../produce-symbolcast.cpp Line 503: (unsigned long long) (reg_$0 x>)
>   File .../produce-symbolcast.cpp Line 509: (unsigned long long) ((unsigned 
> long) (reg_$0))
>   File .../produce-symbolcast.cpp Line 562: (long) (reg_$0)
>   File .../produce-symbolcast.cpp Line 567: (long) (reg_$0)
>   File .../produce-symbolcast.cpp Line 574: (long) (reg_$0)
>   File .../produce-symbolcast.cpp Line 579: (unsigned long) (reg_$0)
>   File .../produce-symbolcast.cpp Line 617: (unsigned long) (reg_$0)
>   File .../produce-symbolcast.cpp Line 622: (unsigned long) (reg_$0)
>   File .../produce-symbolcast.cpp Line 629: (unsigned long long) ((long) 
> (reg_$0))
>   File .../produce-symbolcast.cpp Line 634: (unsigned long long) ((unsigned 
> long) (reg_$0))
>   File .../produce-symbolcast.cpp Line 937: (long) (reg_$0)
>   File .../produce-symbolcast.cpp Line 949: (long long) ((long) (reg_$0 x>))
>   File .../produce-symbolcast.cpp Line 992: (unsigned long) (reg_$0)
>   File .../produce-symbolcast.cpp Line 1004: (unsigned long long) ((long) 
> (reg_$0))
>   File .../produce-symbolcast.cpp Line 1062: (long) (reg_$0)
>   File .../produce-symbolcast.cpp Line 1067: (long) (reg_$0)
>   File .../produce-symbolcast.cpp Line 1074: (long long) ((long) 
> (reg_$0))
>   File .../produce-symbolcast.cpp Line 1078: (long long) (reg_$0)
>   File .../produce-symbolcast.cpp Line 1129: (unsigned long long) ((long) 
> (reg_$0))
>   File .../produce-symbolcast.cpp Line 1133: (unsigned long long) 
> (reg_$0)
>   File .../produce-symbolcast.cpp Line 1187: (long) (reg_$0)
>   File .../produce-symbolcast.cpp Line 1192: (long) (reg_$0)
>   File .../produce-symbolcast.cpp Line 1199: (long long) ((long) 
> (reg_$0))
>   File .../produce-symbolcast.cpp Line 1204: (long long) ((unsigned long) 
> (reg_$0))
>   File .../produce-symbolcast.cpp Line 1242: (unsigned long) (reg_$0 x>)
>   File .../produce-symbolcast.cpp Line 1247: (unsigned long) (reg_$0 x>)
>   File .../produce-symbolcast.cpp Line 1254: (unsigned long long) ((long) 
> (reg_$0))
>   File .../produce-symbolcast.cpp Line 1259: (unsigned long long) ((unsigned 
> long) (reg_$0))
> error: 'warning' diagnostics seen but not expected: 
>   File .../produce-symbolcast.cpp Line 67: (long) ((unsigned int) 
> (reg_$0)) [debug.ExprInspection]
>   File .../produce-symbolcast.cpp Line 79: (long long) (reg_$0) 
> [debug.ExprInspection]
>   File .../produce-symbolcast.cpp Line 122: (unsigned long) ((unsigned int) 
> (reg_$0)) [debug.ExprInspection]
>   File .../produce-symbolcast.cpp Line 134: (unsigned long long) (reg_$0 x>) [debug.ExprInspection]
>   File .../produce-symbolcast.cpp Line 192: (long) ((unsigned int) 
> (reg_$0)) [debug.ExprInspection]
>   File .../produce-symbolcast.cpp Line 204: (long long) (reg_$0) 
> [debug.ExprInspection]
>   File .../produce-symbolcast.cpp Line 247

[PATCH] D104925: [Analyzer] Improve report of file read at end-of-file condition.

2021-07-02 Thread Gabor Marton via Phabricator via cfe-commits
martong added inline comments.



Comment at: clang/lib/StaticAnalyzer/Checkers/StreamChecker.cpp:429-435
+const ExplodedNode *N = BR.getErrorNode();
+while (N && N != NotePosition) {
+  const StreamState *StreamS = N->getState()->get(StreamSym);
+  if (!StreamS || !StreamS->ErrorState.FEof)
+return "";
+  N = N->getFirstPred();
+}

balazske wrote:
> balazske wrote:
> > NoQ wrote:
> > > This code says "If there exists a state below in the path where the 
> > > stream is not at EOF, drop the note". The report will not be emitted at 
> > > all if the stream is not at EOF at the end, right? Are you trying to 
> > > account for the situation when the stream gets reset into a non-EOF state 
> > > and therefore you don't need to emit the note above that point?
> > > 
> > > In such cases the intended solution is to add another note tag to mark 
> > > the stream uninteresting once it gets reset, because all the history 
> > > before that point is irrelevant to our report entirely (whatever the 
> > > previous position was, its get completely overwritten by the reset).
> > > 
> > > The API for marking objects uninteresting is not yet there but it's 
> > > suggested in D104300. I believe you should rebase your patch on top of it 
> > > and take advantage of it as it lands.
> > It was unknown to me if the visit of `NoteTag`'s happens from the bug path 
> > end to begin or in different way. If it is from end to begin it may be 
> > enough to remove the interestingness in the current `NoteTag` function when 
> > a message is produced, it should find exactly the last place where that EOF 
> > flag is set to true. And `NotePosition` is not needed.
> I tried it out, seems to work. But to continue D104300 should be finished or 
> the "reset of interestingness" must be split to a separate change (or into 
> this patch), is this possible?
> I tried it out, seems to work. But to continue D104300 should be finished or 
> the "reset of interestingness" must be split to a separate change (or into 
> this patch), is this possible?

Yes, I think it would be the logical way forward if we want a smooth 
development with this change. So let's create a parent patch that implements 
solely `markNotInteresting` from D104300. And that new patch should be the 
parent of this patch, also D104300 could be rebased once the new patch of 
`markNotInteresting` is landed.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D104925

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


[PATCH] D105340: [analyzer] Produce SymbolCast symbols for integral types in SValBuilder::evalCast

2021-07-02 Thread Valeriy Savchenko via Phabricator via cfe-commits
vsavchenko added inline comments.



Comment at: clang/test/Analysis/range_casts.c:125-126
   if (index - 1UL == 0L) // Was not reached prior fix.
-clang_analyzer_warnIfReached(); // expected-warning{{REACHABLE}}
+// Tempopary regression in scope of implementing integral cast.
+// This will be restored as soon as all commits are loaded.
+clang_analyzer_warnIfReached(); // no-warning

The main purpose of the new option is exactly to prevent "temporary 
regressions" so that everything works just as it did before


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105340

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


[clang] b77b220 - [NFC] Fix typo in comment

2021-07-02 Thread Sven van Haastregt via cfe-commits

Author: Sven van Haastregt
Date: 2021-07-02T11:39:17+01:00
New Revision: b77b2201dc1f50f10e724c8c0b63963c5d98bf74

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

LOG: [NFC] Fix typo in comment

Reported-by: Marco Cali 

Added: 


Modified: 
clang/lib/Format/TokenAnnotator.cpp

Removed: 




diff  --git a/clang/lib/Format/TokenAnnotator.cpp 
b/clang/lib/Format/TokenAnnotator.cpp
index aa69ff88bd747..2b83ff4f78503 100644
--- a/clang/lib/Format/TokenAnnotator.cpp
+++ b/clang/lib/Format/TokenAnnotator.cpp
@@ -363,7 +363,7 @@ class AnnotatingParser {
 Left->Previous && Left->Previous->is(tok::l_paren)) {
   // Detect the case where macros are used to generate lambdas or
   // function bodies, e.g.:
-  //   auto my_lambda = MARCO((Type *type, int i) { .. body .. });
+  //   auto my_lambda = MACRO((Type *type, int i) { .. body .. });
   for (FormatToken *Tok = Left; Tok != CurrentToken; Tok = Tok->Next) {
 if (Tok->is(TT_BinaryOperator) &&
 Tok->isOneOf(tok::star, tok::amp, tok::ampamp))



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


[PATCH] D105340: [analyzer] Produce SymbolCast symbols for integral types in SValBuilder::evalCast

2021-07-02 Thread Valeriy Savchenko via Phabricator via cfe-commits
vsavchenko added a comment.

Hey, thanks for starting on splitting into more pieces!




Comment at: 
clang/include/clang/StaticAnalyzer/Core/PathSensitive/SValBuilder.h:96
QualType OriginalTy);
+  SVal simplifySymbolCast(nonloc::SymbolVal V, QualType CastTy);
 

What does it do and what should I give it?



Comment at: clang/lib/StaticAnalyzer/Core/SValBuilder.cpp:510-546
-// Handles casts of type CK_IntegralCast.
-// At the moment, this function will redirect to evalCast, except when the 
range
-// of the original value is known to be greater than the max of the target 
type.
-SVal SValBuilder::evalIntegralCast(ProgramStateRef state, SVal val,
-   QualType castTy, QualType originalTy) {
-  // No truncations if target type is big enough.
-  if (getContext().getTypeSize(castTy) >= getContext().getTypeSize(originalTy))

I'd like to see the motivation about why this code is removed.
My main concern is this:
  * If removing `evalIntegralCast` is essential for this feature and is not an 
NFC: it should also obey the new analyzer option.
  * If it is NFC, and we can safely remove this function no matter what the 
value of the option is, it should be a separate patch.



Comment at: clang/test/Analysis/bool-assignment.c:46-50
 #ifdef ANALYZER_CM_Z3
 BOOL x = y; // expected-warning {{Assignment of a non-Boolean value}}
 #else
-BOOL x = y; // no-warning
+BOOL x = y; // expected-warning {{Assignment of a non-Boolean value}}
 #endif

If Z3 and not Z3 are the same now, we can simply merge two cases and remove 
preprocessor directive.



Comment at: clang/test/Analysis/produce-symbolcast.cpp:1
+// RUN: %clang_analyze_cc1 -analyzer-checker=debug.ExprInspection 
-analyzer-config handle-integral-cast-for-ranges=true -verify %s
+

This test is failing on my desktop, when I downloaded your patch:
```
error: 'warning' diagnostics expected but not seen: 
  File .../produce-symbolcast.cpp Line 67: (long) (reg_$0)
  File .../produce-symbolcast.cpp Line 79: (long long) ((unsigned long) 
(reg_$0))
  File .../produce-symbolcast.cpp Line 122: (unsigned long) (reg_$0)
  File .../produce-symbolcast.cpp Line 134: (unsigned long long) ((unsigned 
long) (reg_$0))
  File .../produce-symbolcast.cpp Line 192: (long) (reg_$0)
  File .../produce-symbolcast.cpp Line 204: (long long) ((unsigned long) 
(reg_$0))
  File .../produce-symbolcast.cpp Line 247: (unsigned long) (reg_$0)
  File .../produce-symbolcast.cpp Line 259: (unsigned long long) ((unsigned 
long) (reg_$0))
  File .../produce-symbolcast.cpp Line 317: (long) (reg_$0)
  File .../produce-symbolcast.cpp Line 329: (long long) ((unsigned long) 
(reg_$0))
  File .../produce-symbolcast.cpp Line 372: (unsigned long) (reg_$0)
  File .../produce-symbolcast.cpp Line 384: (unsigned long long) ((unsigned 
long) (reg_$0))
  File .../produce-symbolcast.cpp Line 448: (long long) (reg_$0)
  File .../produce-symbolcast.cpp Line 454: (long long) ((unsigned long) 
(reg_$0))
  File .../produce-symbolcast.cpp Line 492: (unsigned long) (reg_$0)
  File .../produce-symbolcast.cpp Line 497: (unsigned long) (reg_$0)
  File .../produce-symbolcast.cpp Line 503: (unsigned long long) (reg_$0)
  File .../produce-symbolcast.cpp Line 509: (unsigned long long) ((unsigned 
long) (reg_$0))
  File .../produce-symbolcast.cpp Line 562: (long) (reg_$0)
  File .../produce-symbolcast.cpp Line 567: (long) (reg_$0)
  File .../produce-symbolcast.cpp Line 574: (long) (reg_$0)
  File .../produce-symbolcast.cpp Line 579: (unsigned long) (reg_$0)
  File .../produce-symbolcast.cpp Line 617: (unsigned long) (reg_$0)
  File .../produce-symbolcast.cpp Line 622: (unsigned long) (reg_$0)
  File .../produce-symbolcast.cpp Line 629: (unsigned long long) ((long) 
(reg_$0))
  File .../produce-symbolcast.cpp Line 634: (unsigned long long) ((unsigned 
long) (reg_$0))
  File .../produce-symbolcast.cpp Line 937: (long) (reg_$0)
  File .../produce-symbolcast.cpp Line 949: (long long) ((long) (reg_$0))
  File .../produce-symbolcast.cpp Line 992: (unsigned long) (reg_$0)
  File .../produce-symbolcast.cpp Line 1004: (unsigned long long) ((long) 
(reg_$0))
  File .../produce-symbolcast.cpp Line 1062: (long) (reg_$0)
  File .../produce-symbolcast.cpp Line 1067: (long) (reg_$0)
  File .../produce-symbolcast.cpp Line 1074: (long long) ((long) (reg_$0))
  File .../produce-symbolcast.cpp Line 1078: (long long) (reg_$0)
  File .../produce-symbolcast.cpp Line 1129: (unsigned long long) ((long) 
(reg_$0))
  File .../produce-symbolcast.cpp Line 1133: (unsigned long long) (reg_$0)
  File .../produce-symbolcast.cpp Line 1187: (long) (reg_$0)
  File .../produce-symbolcast.cpp Line 1192: (long) (reg_$0)
  File .../produce-symbolcast.cpp Line 1199: (long long) ((long) (reg_$0))
  File .../produce-symbolcast.cpp Line 1204: (long long) ((unsigned long) 
(reg_$0))
  File .

[PATCH] D100161: Redistribute energy for Corpus

2021-07-02 Thread taotao gu via Phabricator via cfe-commits
gtt1995 added a comment.



  I redesigned the algorithm and did a complete long-term evaluation by myself, 
and got very good results. Whether it is -entropic=0 or 1, it performs very 
well, and -fork mode is now better than paralllel fuzzing mode Better 
performance, 
  please move to D105084. There are detailed data. Thanks  a lot.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100161

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


[PATCH] D105331: [CFE][X86] Enable complex _Float16.

2021-07-02 Thread Pengfei Wang via Phabricator via cfe-commits
pengfei added a comment.

In D105331#2854934 , @SjoerdMeijer 
wrote:

> The patch on itself looks reasonable to me. I was just wondering about the 
> _Float16 support on X86 in general because the Clang docs says:
>
>   _Float16 is currently only supported on the following targets, with further 
> targets pending ABI standardization: 
>
> Does X86 support _Float16, and how does that work for Complex _Float16?  
> Either way, does this need a doc update too?

Good point! Yes, X86 is going to support _Float16. This patch is split from 
D105263  and depended on it. I will update 
the doc in that patch. Thanks.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105331

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


[PATCH] D104797: [WebAssembly] Implementation of global.get/set for reftypes in LLVM IR

2021-07-02 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri reopened this revision.
lebedev.ri added a comment.
This revision is now accepted and ready to land.

Reverted again

  
  FAIL: LLVM :: CodeGen/WebAssembly/funcref-call.ll (44466 of 44468)
   TEST 'LLVM :: CodeGen/WebAssembly/funcref-call.ll' 
FAILED 
  Script:
  --
  : 'RUN: at line 1';   /builddirs/llvm-project/build-Clang12/bin/llc < 
/repositories/llvm-project/llvm/test/CodeGen/WebAssembly/funcref-call.ll 
--mtriple=wasm32-unknown-unknown -asm-verbose=false -mattr=+reference-types | 
/builddirs/llvm-project/build-Clang12/bin/FileCheck 
/repositories/llvm-project/llvm/test/CodeGen/WebAssembly/funcref-call.ll
  --
  Exit Code: 2
  
  Command Output (stderr):
  --
  llc: 
/repositories/llvm-project/llvm/include/llvm/Support/LowLevelTypeImpl.h:44: 
static llvm::LLT llvm::LLT::scalar(unsigned int): Assertion `SizeInBits > 0 && 
"invalid scalar size"' failed.

Are you building llvm without assertions?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D104797

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


[clang] c2c0d3e - Revert "[WebAssembly] Implementation of global.get/set for reftypes in LLVM IR"

2021-07-02 Thread Roman Lebedev via cfe-commits

Author: Roman Lebedev
Date: 2021-07-02T11:49:51+03:00
New Revision: c2c0d3ea894328667583155334f0607db0c0a73a

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

LOG: Revert "[WebAssembly] Implementation of global.get/set for reftypes in 
LLVM IR"

This reverts commit 4facbf213c51e4add2e8c19b08d5e58ad71c72de.

```

FAIL: LLVM :: CodeGen/WebAssembly/funcref-call.ll (44466 of 44468)
 TEST 'LLVM :: CodeGen/WebAssembly/funcref-call.ll' FAILED 

Script:
--
: 'RUN: at line 1';   /builddirs/llvm-project/build-Clang12/bin/llc < 
/repositories/llvm-project/llvm/test/CodeGen/WebAssembly/funcref-call.ll 
--mtriple=wasm32-unknown-unknown -asm-verbose=false -mattr=+reference-types | 
/builddirs/llvm-project/build-Clang12/bin/FileCheck 
/repositories/llvm-project/llvm/test/CodeGen/WebAssembly/funcref-call.ll
--
Exit Code: 2

Command Output (stderr):
--
llc: 
/repositories/llvm-project/llvm/include/llvm/Support/LowLevelTypeImpl.h:44: 
static llvm::LLT llvm::LLT::scalar(unsigned int): Assertion `SizeInBits > 0 && 
"invalid scalar size"' failed.

```

Added: 


Modified: 
clang/lib/Basic/Targets/WebAssembly.h
clang/test/CodeGen/target-data.c
llvm/include/llvm/CodeGen/TargetLowering.h
llvm/include/llvm/CodeGen/ValueTypes.h
llvm/lib/CodeGen/CodeGenPrepare.cpp
llvm/lib/CodeGen/MachineOperand.cpp
llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
llvm/lib/CodeGen/TargetLoweringBase.cpp
llvm/lib/CodeGen/ValueTypes.cpp
llvm/lib/Target/WebAssembly/Utils/WebAssemblyUtilities.cpp
llvm/lib/Target/WebAssembly/Utils/WebAssemblyUtilities.h
llvm/lib/Target/WebAssembly/WebAssemblyFastISel.cpp
llvm/lib/Target/WebAssembly/WebAssemblyISD.def
llvm/lib/Target/WebAssembly/WebAssemblyISelDAGToDAG.cpp
llvm/lib/Target/WebAssembly/WebAssemblyISelLowering.cpp
llvm/lib/Target/WebAssembly/WebAssemblyISelLowering.h
llvm/lib/Target/WebAssembly/WebAssemblyInstrTable.td
llvm/lib/Target/WebAssembly/WebAssemblyMCInstLower.cpp
llvm/lib/Target/WebAssembly/WebAssemblyTargetMachine.cpp

Removed: 
llvm/test/CodeGen/WebAssembly/externref-globalget.ll
llvm/test/CodeGen/WebAssembly/externref-globalset.ll
llvm/test/CodeGen/WebAssembly/externref-inttoptr.ll
llvm/test/CodeGen/WebAssembly/externref-ptrtoint.ll
llvm/test/CodeGen/WebAssembly/externref-undef.ll
llvm/test/CodeGen/WebAssembly/externref-unsized-load.ll
llvm/test/CodeGen/WebAssembly/externref-unsized-store.ll
llvm/test/CodeGen/WebAssembly/funcref-call.ll
llvm/test/CodeGen/WebAssembly/funcref-globalget.ll
llvm/test/CodeGen/WebAssembly/funcref-globalset.ll



diff  --git a/clang/lib/Basic/Targets/WebAssembly.h 
b/clang/lib/Basic/Targets/WebAssembly.h
index ed590fe7e3338..b29730c5d706b 100644
--- a/clang/lib/Basic/Targets/WebAssembly.h
+++ b/clang/lib/Basic/Targets/WebAssembly.h
@@ -147,7 +147,7 @@ class LLVM_LIBRARY_VISIBILITY WebAssembly32TargetInfo
   explicit WebAssembly32TargetInfo(const llvm::Triple &T,
const TargetOptions &Opts)
   : WebAssemblyTargetInfo(T, Opts) {
-resetDataLayout("e-m:e-p:32:32-i64:64-n32:64-S128-ni:1:10:20");
+resetDataLayout("e-m:e-p:32:32-i64:64-n32:64-S128-ni:1");
   }
 
 protected:
@@ -166,7 +166,7 @@ class LLVM_LIBRARY_VISIBILITY WebAssembly64TargetInfo
 SizeType = UnsignedLong;
 PtrDiffType = SignedLong;
 IntPtrType = SignedLong;
-resetDataLayout("e-m:e-p:64:64-i64:64-n32:64-S128-ni:1:10:20");
+resetDataLayout("e-m:e-p:64:64-i64:64-n32:64-S128-ni:1");
   }
 
 protected:

diff  --git a/clang/test/CodeGen/target-data.c 
b/clang/test/CodeGen/target-data.c
index 1be01efd16515..1d88984530e5b 100644
--- a/clang/test/CodeGen/target-data.c
+++ b/clang/test/CodeGen/target-data.c
@@ -108,11 +108,11 @@
 
 // RUN: %clang_cc1 -triple wasm32-unknown-unknown -o - -emit-llvm %s | \
 // RUN: FileCheck %s -check-prefix=WEBASSEMBLY32
-// WEBASSEMBLY32: target datalayout = 
"e-m:e-p:32:32-i64:64-n32:64-S128-ni:1:10:20"
+// WEBASSEMBLY32: target datalayout = "e-m:e-p:32:32-i64:64-n32:64-S128-ni:1"
 
 // RUN: %clang_cc1 -triple wasm64-unknown-unknown -o - -emit-llvm %s | \
 // RUN: FileCheck %s -check-prefix=WEBASSEMBLY64
-// WEBASSEMBLY64: target datalayout = 
"e-m:e-p:64:64-i64:64-n32:64-S128-ni:1:10:20"
+// WEBASSEMBLY64: target datalayout = "e-m:e-p:64:64-i64:64-n32:64-S128-ni:1"
 
 // RUN: %clang_cc1 -triple lanai-unknown-unknown -o - -emit-llvm %s | \
 // RUN: FileCheck %s -check-prefix=LANAI

diff  --git a/llvm/include/llvm/CodeGen/TargetLowering.h 
b/llvm/include/llvm/CodeGen/TargetLowering.h
index 75894d15a9693..47d6ca43a5ac3 100644
--- a/llvm/include/llvm/CodeGen/TargetLowering.h
+++ b/llvm/include/llvm/CodeGen/TargetLowering.h
@@ -350,7

[PATCH] D105331: [CFE][X86] Enable complex _Float16.

2021-07-02 Thread Sjoerd Meijer via Phabricator via cfe-commits
SjoerdMeijer added a comment.

The patch on itself looks reasonable to me. I was just wondering about the 
_Float16 support on X86 in general because the Clang docs says:

  _Float16 is currently only supported on the following targets, with further 
targets pending ABI standardization: 

Does X86 support _Float16, and how does that work for Complex _Float16?  
Either way, does this need a doc update too?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105331

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


[PATCH] D104766: [X86] Zero some outputs of Keylocker intrinsics in error case

2021-07-02 Thread Xiang Zhang via Phabricator via cfe-commits
xiangzhangllvm added a comment.

Done at https://reviews.llvm.org/D105336, thanks again!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D104766

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


[PATCH] D104616: [analyzer] Model comparision methods of std::unique_ptr

2021-07-02 Thread Deep Majumder via Phabricator via cfe-commits
RedDocMD updated this revision to Diff 356128.
RedDocMD added a comment.

Performing state split on normal comparision ops


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D104616

Files:
  clang/lib/StaticAnalyzer/Checkers/SmartPtr.h
  clang/lib/StaticAnalyzer/Checkers/SmartPtrModeling.cpp
  clang/test/Analysis/Inputs/system-header-simulator-cxx.h
  clang/test/Analysis/smart-ptr.cpp

Index: clang/test/Analysis/smart-ptr.cpp
===
--- clang/test/Analysis/smart-ptr.cpp
+++ clang/test/Analysis/smart-ptr.cpp
@@ -457,3 +457,29 @@
 P->foo(); // expected-warning {{Dereference of null smart pointer 'P' [alpha.cplusplus.SmartPtr]}}
   }
 }
+
+// The following is a silly function,
+// but serves to test if we are picking out
+// standard comparision functions from custom ones.
+template 
+bool operator<(std::unique_ptr &x, double d);
+
+void uniquePtrComparision(std::unique_ptr unknownPtr) {
+  auto ptr = std::unique_ptr(new int(13));
+  auto nullPtr = std::unique_ptr();
+  auto otherPtr = std::unique_ptr(new int(29));
+
+  clang_analyzer_eval(ptr == ptr); // expected-warning{{TRUE}}
+  clang_analyzer_eval(ptr > ptr);  // expected-warning{{FALSE}}
+  clang_analyzer_eval(ptr <= ptr); // expected-warning{{TRUE}}
+
+  clang_analyzer_eval(nullPtr <= unknownPtr); // expected-warning{{TRUE}}
+  clang_analyzer_eval(unknownPtr >= nullPtr); // expected-warning{{TRUE}}
+
+  clang_analyzer_eval(ptr != otherPtr); // expected-warning{{TRUE}}
+  clang_analyzer_eval(ptr > nullPtr);   // expected-warning{{TRUE}}
+
+  clang_analyzer_eval(ptr != nullptr);// expected-warning{{TRUE}}
+  clang_analyzer_eval(nullPtr != nullptr);// expected-warning{{FALSE}}
+  clang_analyzer_eval(nullptr <= unknownPtr); // expected-warning{{TRUE}}
+}
Index: clang/test/Analysis/Inputs/system-header-simulator-cxx.h
===
--- clang/test/Analysis/Inputs/system-header-simulator-cxx.h
+++ clang/test/Analysis/Inputs/system-header-simulator-cxx.h
@@ -978,6 +978,61 @@
 void swap(unique_ptr &x, unique_ptr &y) noexcept {
   x.swap(y);
 }
+
+template 
+bool operator==(const unique_ptr &x, const unique_ptr &y);
+
+template 
+bool operator!=(const unique_ptr &x, const unique_ptr &y);
+
+template 
+bool operator<(const unique_ptr &x, const unique_ptr &y);
+
+template 
+bool operator>(const unique_ptr &x, const unique_ptr &y);
+
+template 
+bool operator<=(const unique_ptr &x, const unique_ptr &y);
+
+template 
+bool operator>=(const unique_ptr &x, const unique_ptr &y);
+
+template 
+bool operator==(const unique_ptr &x, nullptr_t y);
+
+template 
+bool operator!=(const unique_ptr &x, nullptr_t y);
+
+template 
+bool operator<(const unique_ptr &x, nullptr_t y);
+
+template 
+bool operator>(const unique_ptr &x, nullptr_t y);
+
+template 
+bool operator<=(const unique_ptr &x, nullptr_t y);
+
+template 
+bool operator>=(const unique_ptr &x, nullptr_t y);
+
+template 
+bool operator==(nullptr_t x, const unique_ptr &y);
+
+template 
+bool operator!=(nullptr_t x, const unique_ptr &y);
+
+template 
+bool operator>(nullptr_t x, const unique_ptr &y);
+
+template 
+bool operator<(nullptr_t x, const unique_ptr &y);
+
+template 
+bool operator>=(nullptr_t x, const unique_ptr &y);
+
+template 
+bool operator<=(nullptr_t x, const unique_ptr &y);
+
 } // namespace std
 #endif
 
Index: clang/lib/StaticAnalyzer/Checkers/SmartPtrModeling.cpp
===
--- clang/lib/StaticAnalyzer/Checkers/SmartPtrModeling.cpp
+++ clang/lib/StaticAnalyzer/Checkers/SmartPtrModeling.cpp
@@ -29,7 +29,10 @@
 #include "clang/StaticAnalyzer/Core/PathSensitive/SVals.h"
 #include "clang/StaticAnalyzer/Core/PathSensitive/SymExpr.h"
 #include "clang/StaticAnalyzer/Core/PathSensitive/SymbolManager.h"
+#include "llvm/ADT/StringMap.h"
+#include "llvm/Support/ErrorHandling.h"
 #include 
+#include 
 
 using namespace clang;
 using namespace ento;
@@ -68,6 +71,10 @@
   bool updateMovedSmartPointers(CheckerContext &C, const MemRegion *ThisRegion,
 const MemRegion *OtherSmartPtrRegion) const;
   void handleBoolConversion(const CallEvent &Call, CheckerContext &C) const;
+  bool handleComparisionOp(const CallEvent &Call, CheckerContext &C) const;
+  std::pair
+  retrieveOrConjureInnerPtrVal(const MemRegion *ThisRegion, const Expr *E,
+   QualType Type, CheckerContext &C) const;
 
   using SmartPtrMethodHandlerFn =
   void (SmartPtrModeling::*)(const CallEvent &Call, CheckerContext &) const;
@@ -89,18 +96,24 @@
   const auto *MethodDecl = dyn_cast_or_null(Call.getDecl());
   if (!MethodDecl || !MethodDecl->getParent())
 return false;
+  return isStdSmartPtr(MethodDecl->getParent());
+}
 
-  const auto *RecordDecl = MethodDecl->getParent();
-  if (!RecordDecl || !RecordDecl->getDeclCo

[PATCH] D105221: [openmp][nfc] Simplify macros guarding math complex headers

2021-07-02 Thread Joachim Meyer via Phabricator via cfe-commits
fodinabor added a comment.

I added a pretty simple regression that should make testing this -x cuda 
-fopenmp issue simpler: https://reviews.llvm.org/D105322
I guess a similar test for -x hip -fopenmp could be added, but it hasn't been 
an issue so far as HIP and OpenMP AMDGCN seem to use the same builtins?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105221

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


[PATCH] D100553: [clangd] Log feature configuration (linux+asan+grpc) of the clangd build

2021-07-02 Thread Sam McCall via Phabricator via cfe-commits
sammccall added a comment.

In D100553#2852981 , @thakis wrote:

> I guess now clangd/xpc needs an explicit dep on that .inc generating rule.

I think it's rather missing `-I` for the generated clangd directory.
(The targets in clangd/xpc depend on clangDaemon which requires that generated 
header - not wonderfully explicit but also seems to be the way this is usually 
done at least in CMake)

> Tried again in 2f79acb7b701c41494abff588b5f03a74ea2e11d 
> . If 
> someone wants to figure out how to make xpc see Features.inc in the cmake 
> build, that'd work too.

Sorry, there was a near-identical break in index/remote/ and I didn't spot the 
xpc variant.
The idea is that all files under clang-tools-extra/clangd/ should have clangd/ 
on the include path (both normal and generated files).

Landed a few patches trying to improve this:

- 86c5afa6e601c4a80d46a7a8b892d5c49bcec078 
 is the 
missing include from your log
- 0c53f602d5a9d7207abb13e463f68e9d092f47a7 
 is a few 
more cases i found
- then 26e1553a107f52667be879e99739a4153f8799d8 
 just adds 
the include dirs at the top level (where it's not needed!) since cmake seems to 
inherit this property to subdirectories

Not sure if these changes are things the gn bot is usually able to sync 
automatically, but at least CMake should be good and less fragile now, and 
check-clangd is still passing on the gn bots. I think 
2f79acb7b701c41494abff588b5f03a74ea2e11d 
 is now 
unneccesary (at least for cmake) and may try to revert it, but probably rather 
on monday than break more things today...


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100553

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


[PATCH] D102492: [clang][AST] Add support for BindingDecl to ASTImporter.

2021-07-02 Thread Balázs Kéri 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 rGa27a17f88386: [clang][AST] Add support for BindingDecl to 
ASTImporter. (authored by balazske).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D102492

Files:
  clang/lib/AST/ASTImporter.cpp
  clang/unittests/AST/ASTImporterTest.cpp

Index: clang/unittests/AST/ASTImporterTest.cpp
===
--- clang/unittests/AST/ASTImporterTest.cpp
+++ clang/unittests/AST/ASTImporterTest.cpp
@@ -3679,6 +3679,52 @@
   EXPECT_TRUE(ImportedD->getDefinition());
 }
 
+TEST_P(ImportVariables, ImportBindingDecl) {
+  Decl *From, *To;
+  std::tie(From, To) = getImportedDecl(
+  R"(
+  void declToImport() {
+int a[2] = {1,2};
+auto [x1,y1] = a;
+auto& [x2,y2] = a;
+
+struct S {
+  mutable int x1 : 2;
+  volatile double y1;
+};
+S b;
+const auto [x3, y3] = b;
+  };
+  )",
+  Lang_CXX17, "", Lang_CXX17);
+
+  TranslationUnitDecl *FromTU = From->getTranslationUnitDecl();
+  auto *FromF = FirstDeclMatcher().match(
+  FromTU, functionDecl(hasName("declToImport")));
+  auto *ToF = Import(FromF, Lang_CXX17);
+  EXPECT_TRUE(ToF);
+
+  auto VerifyImport = [&](llvm::StringRef BindName) {
+auto *FromB = FirstDeclMatcher().match(
+FromF, bindingDecl(hasName(BindName)));
+ASSERT_TRUE(FromB);
+auto *ToB = Import(FromB, Lang_CXX17);
+EXPECT_TRUE(ToB);
+EXPECT_EQ(FromB->getBinding() != nullptr, ToB->getBinding() != nullptr);
+EXPECT_EQ(FromB->getDecomposedDecl() != nullptr,
+  ToB->getDecomposedDecl() != nullptr);
+EXPECT_EQ(FromB->getHoldingVar() != nullptr,
+  ToB->getHoldingVar() != nullptr);
+  };
+
+  VerifyImport("x1");
+  VerifyImport("y1");
+  VerifyImport("x2");
+  VerifyImport("y2");
+  VerifyImport("x3");
+  VerifyImport("y3");
+}
+
 struct ImportClasses : ASTImporterOptionSpecificTestBase {};
 
 TEST_P(ImportClasses, ImportDefinitionWhenProtoIsInNestedToContext) {
Index: clang/lib/AST/ASTImporter.cpp
===
--- clang/lib/AST/ASTImporter.cpp
+++ clang/lib/AST/ASTImporter.cpp
@@ -496,6 +496,7 @@
 ExpectedDecl VisitAccessSpecDecl(AccessSpecDecl *D);
 ExpectedDecl VisitStaticAssertDecl(StaticAssertDecl *D);
 ExpectedDecl VisitTranslationUnitDecl(TranslationUnitDecl *D);
+ExpectedDecl VisitBindingDecl(BindingDecl *D);
 ExpectedDecl VisitNamespaceDecl(NamespaceDecl *D);
 ExpectedDecl VisitNamespaceAliasDecl(NamespaceAliasDecl *D);
 ExpectedDecl VisitTypedefNameDecl(TypedefNameDecl *D, bool IsAlias);
@@ -2291,6 +2292,35 @@
   return ToD;
 }
 
+ExpectedDecl ASTNodeImporter::VisitBindingDecl(BindingDecl *D) {
+  DeclContext *DC, *LexicalDC;
+  DeclarationName Name;
+  SourceLocation Loc;
+  NamedDecl *ToND;
+  if (Error Err = ImportDeclParts(D, DC, LexicalDC, Name, ToND, Loc))
+return std::move(Err);
+  if (ToND)
+return ToND;
+
+  Error Err = Error::success();
+  QualType ToType = importChecked(Err, D->getType());
+  Expr *ToBinding = importChecked(Err, D->getBinding());
+  ValueDecl *ToDecomposedDecl = importChecked(Err, D->getDecomposedDecl());
+  if (Err)
+return std::move(Err);
+
+  BindingDecl *ToD;
+  if (GetImportedOrCreateDecl(ToD, D, Importer.getToContext(), DC, Loc,
+  Name.getAsIdentifierInfo()))
+return ToD;
+
+  ToD->setBinding(ToType, ToBinding);
+  ToD->setDecomposedDecl(ToDecomposedDecl);
+  addDeclToContexts(D, ToD);
+
+  return ToD;
+}
+
 ExpectedDecl ASTNodeImporter::VisitAccessSpecDecl(AccessSpecDecl *D) {
   ExpectedSLoc LocOrErr = import(D->getLocation());
   if (!LocOrErr)
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] a27a17f - [clang][AST] Add support for BindingDecl to ASTImporter.

2021-07-02 Thread Balázs Kéri via cfe-commits

Author: Balázs Kéri
Date: 2021-07-02T10:14:50+02:00
New Revision: a27a17f883864c1c44a0ba3fb01bbf1c89110b82

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

LOG: [clang][AST] Add support for BindingDecl to ASTImporter.

Reviewed By: martong

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

Added: 


Modified: 
clang/lib/AST/ASTImporter.cpp
clang/unittests/AST/ASTImporterTest.cpp

Removed: 




diff  --git a/clang/lib/AST/ASTImporter.cpp b/clang/lib/AST/ASTImporter.cpp
index 0d0cabc965566..8fb55488e836a 100644
--- a/clang/lib/AST/ASTImporter.cpp
+++ b/clang/lib/AST/ASTImporter.cpp
@@ -496,6 +496,7 @@ namespace clang {
 ExpectedDecl VisitAccessSpecDecl(AccessSpecDecl *D);
 ExpectedDecl VisitStaticAssertDecl(StaticAssertDecl *D);
 ExpectedDecl VisitTranslationUnitDecl(TranslationUnitDecl *D);
+ExpectedDecl VisitBindingDecl(BindingDecl *D);
 ExpectedDecl VisitNamespaceDecl(NamespaceDecl *D);
 ExpectedDecl VisitNamespaceAliasDecl(NamespaceAliasDecl *D);
 ExpectedDecl VisitTypedefNameDecl(TypedefNameDecl *D, bool IsAlias);
@@ -2291,6 +2292,35 @@ ExpectedDecl 
ASTNodeImporter::VisitTranslationUnitDecl(TranslationUnitDecl *D) {
   return ToD;
 }
 
+ExpectedDecl ASTNodeImporter::VisitBindingDecl(BindingDecl *D) {
+  DeclContext *DC, *LexicalDC;
+  DeclarationName Name;
+  SourceLocation Loc;
+  NamedDecl *ToND;
+  if (Error Err = ImportDeclParts(D, DC, LexicalDC, Name, ToND, Loc))
+return std::move(Err);
+  if (ToND)
+return ToND;
+
+  Error Err = Error::success();
+  QualType ToType = importChecked(Err, D->getType());
+  Expr *ToBinding = importChecked(Err, D->getBinding());
+  ValueDecl *ToDecomposedDecl = importChecked(Err, D->getDecomposedDecl());
+  if (Err)
+return std::move(Err);
+
+  BindingDecl *ToD;
+  if (GetImportedOrCreateDecl(ToD, D, Importer.getToContext(), DC, Loc,
+  Name.getAsIdentifierInfo()))
+return ToD;
+
+  ToD->setBinding(ToType, ToBinding);
+  ToD->setDecomposedDecl(ToDecomposedDecl);
+  addDeclToContexts(D, ToD);
+
+  return ToD;
+}
+
 ExpectedDecl ASTNodeImporter::VisitAccessSpecDecl(AccessSpecDecl *D) {
   ExpectedSLoc LocOrErr = import(D->getLocation());
   if (!LocOrErr)

diff  --git a/clang/unittests/AST/ASTImporterTest.cpp 
b/clang/unittests/AST/ASTImporterTest.cpp
index da4bce16d23b8..3536b1cfcbffc 100644
--- a/clang/unittests/AST/ASTImporterTest.cpp
+++ b/clang/unittests/AST/ASTImporterTest.cpp
@@ -3679,6 +3679,52 @@ TEST_P(ImportVariables, 
InitAndDefinitionAreInTheFromContext) {
   EXPECT_TRUE(ImportedD->getDefinition());
 }
 
+TEST_P(ImportVariables, ImportBindingDecl) {
+  Decl *From, *To;
+  std::tie(From, To) = getImportedDecl(
+  R"(
+  void declToImport() {
+int a[2] = {1,2};
+auto [x1,y1] = a;
+auto& [x2,y2] = a;
+
+struct S {
+  mutable int x1 : 2;
+  volatile double y1;
+};
+S b;
+const auto [x3, y3] = b;
+  };
+  )",
+  Lang_CXX17, "", Lang_CXX17);
+
+  TranslationUnitDecl *FromTU = From->getTranslationUnitDecl();
+  auto *FromF = FirstDeclMatcher().match(
+  FromTU, functionDecl(hasName("declToImport")));
+  auto *ToF = Import(FromF, Lang_CXX17);
+  EXPECT_TRUE(ToF);
+
+  auto VerifyImport = [&](llvm::StringRef BindName) {
+auto *FromB = FirstDeclMatcher().match(
+FromF, bindingDecl(hasName(BindName)));
+ASSERT_TRUE(FromB);
+auto *ToB = Import(FromB, Lang_CXX17);
+EXPECT_TRUE(ToB);
+EXPECT_EQ(FromB->getBinding() != nullptr, ToB->getBinding() != nullptr);
+EXPECT_EQ(FromB->getDecomposedDecl() != nullptr,
+  ToB->getDecomposedDecl() != nullptr);
+EXPECT_EQ(FromB->getHoldingVar() != nullptr,
+  ToB->getHoldingVar() != nullptr);
+  };
+
+  VerifyImport("x1");
+  VerifyImport("y1");
+  VerifyImport("x2");
+  VerifyImport("y2");
+  VerifyImport("x3");
+  VerifyImport("y3");
+}
+
 struct ImportClasses : ASTImporterOptionSpecificTestBase {};
 
 TEST_P(ImportClasses, ImportDefinitionWhenProtoIsInNestedToContext) {



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


[PATCH] D104766: [X86] Zero some outputs of Keylocker intrinsics in error case

2021-07-02 Thread Xiang Zhang via Phabricator via cfe-commits
xiangzhangllvm added inline comments.



Comment at: clang/lib/CodeGen/CGBuiltin.cpp:14834
 
+BasicBlock *NoError = createBasicBlock(StrNoErr, this->CurFn);
+BasicBlock *Error = createBasicBlock(StrErr, this->CurFn);

craig.topper wrote:
> Sorry I'm late here. Instead of having 3 separate strings for each intrinsic 
> can you do something like `createBasicBlock(BaseName + "_no_error"...)` here. 
> I believe createBasicBlock takes a Twine.
Hello Craig! Nice to meet you again :) , Sorry for not noticing you this patch 
before. I planned  not to disturb you if not necessary.

Yes, using Twine will more clear, let me refine it. Thanks a lot!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D104766

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


[clang-tools-extra] 26e1553 - [clangd] CMake: express -Iclangd/ at top level and inherit

2021-07-02 Thread Sam McCall via cfe-commits

Author: Sam McCall
Date: 2021-07-02T09:52:36+02:00
New Revision: 26e1553a107f52667be879e99739a4153f8799d8

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

LOG: [clangd] CMake: express -Iclangd/ at top level and inherit

For files directly under clangd/, -Iclang-tools-extra/clangd (and the
equivalent for generated files) are not required, as CMake/the compiler puts
these directories on the include path by default.

However this means each subdirectory needs to
include_directories(.. ${CMAKE_CURRENT_BINARY_DIR}/..) etc, and this
proved annoying and error-prone to maintain and debug.

Since include_directories is inherited by subdirectories, we just
configure this explicitly at the top level instead.

Added: 


Modified: 
clang-tools-extra/clangd/CMakeLists.txt
clang-tools-extra/clangd/benchmarks/CMakeLists.txt
clang-tools-extra/clangd/benchmarks/CompletionModel/CMakeLists.txt
clang-tools-extra/clangd/fuzzer/CMakeLists.txt
clang-tools-extra/clangd/index/dex/dexp/CMakeLists.txt
clang-tools-extra/clangd/index/remote/CMakeLists.txt
clang-tools-extra/clangd/indexer/CMakeLists.txt
clang-tools-extra/clangd/support/CMakeLists.txt
clang-tools-extra/clangd/tool/CMakeLists.txt
clang-tools-extra/clangd/unittests/CMakeLists.txt
clang-tools-extra/clangd/unittests/xpc/CMakeLists.txt
clang-tools-extra/clangd/xpc/CMakeLists.txt
clang-tools-extra/clangd/xpc/test-client/CMakeLists.txt

Removed: 




diff  --git a/clang-tools-extra/clangd/CMakeLists.txt 
b/clang-tools-extra/clangd/CMakeLists.txt
index b983b71cc90f4..3c2b097e89fd1 100644
--- a/clang-tools-extra/clangd/CMakeLists.txt
+++ b/clang-tools-extra/clangd/CMakeLists.txt
@@ -1,3 +1,7 @@
+# This is a no-op for building files in this dir, but is inherited by subdirs.
+include_directories(${CMAKE_CURRENT_SOURCE_DIR})
+include_directories(${CMAKE_CURRENT_BINARY_DIR})
+
 add_subdirectory(support)
 
 # Configure the Features.inc file.

diff  --git a/clang-tools-extra/clangd/benchmarks/CMakeLists.txt 
b/clang-tools-extra/clangd/benchmarks/CMakeLists.txt
index 7a17637b6c377..b1bd26f2e5599 100644
--- a/clang-tools-extra/clangd/benchmarks/CMakeLists.txt
+++ b/clang-tools-extra/clangd/benchmarks/CMakeLists.txt
@@ -1,6 +1,3 @@
-include_directories(${CMAKE_CURRENT_SOURCE_DIR}/..
-  ${CMAKE_CURRENT_BINARY_DIR}/..)
-
 add_subdirectory(CompletionModel)
 
 add_benchmark(IndexBenchmark IndexBenchmark.cpp)

diff  --git 
a/clang-tools-extra/clangd/benchmarks/CompletionModel/CMakeLists.txt 
b/clang-tools-extra/clangd/benchmarks/CompletionModel/CMakeLists.txt
index 3998aa1225338..4c7cd779eb3e7 100644
--- a/clang-tools-extra/clangd/benchmarks/CompletionModel/CMakeLists.txt
+++ b/clang-tools-extra/clangd/benchmarks/CompletionModel/CMakeLists.txt
@@ -1,5 +1,3 @@
-include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../)
-
 add_benchmark(DecisionForestBenchmark DecisionForestBenchmark.cpp)
 
 target_link_libraries(DecisionForestBenchmark

diff  --git a/clang-tools-extra/clangd/fuzzer/CMakeLists.txt 
b/clang-tools-extra/clangd/fuzzer/CMakeLists.txt
index 18cab4b41e1a0..5600a354decb3 100644
--- a/clang-tools-extra/clangd/fuzzer/CMakeLists.txt
+++ b/clang-tools-extra/clangd/fuzzer/CMakeLists.txt
@@ -1,6 +1,3 @@
-include_directories(${CMAKE_CURRENT_SOURCE_DIR}/..
-  ${CMAKE_CURRENT_BINARY_DIR}/..)
-
 set(LLVM_LINK_COMPONENTS
   FuzzMutate
   Support

diff  --git a/clang-tools-extra/clangd/index/dex/dexp/CMakeLists.txt 
b/clang-tools-extra/clangd/index/dex/dexp/CMakeLists.txt
index 7b4b6e53a4ad0..4fe42cb8786f1 100644
--- a/clang-tools-extra/clangd/index/dex/dexp/CMakeLists.txt
+++ b/clang-tools-extra/clangd/index/dex/dexp/CMakeLists.txt
@@ -1,6 +1,3 @@
-include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../../../)
-include_directories(${CMAKE_CURRENT_BINARY_DIR}/../../../)
-
 set(LLVM_LINK_COMPONENTS
   LineEditor
   Support

diff  --git a/clang-tools-extra/clangd/index/remote/CMakeLists.txt 
b/clang-tools-extra/clangd/index/remote/CMakeLists.txt
index 51db6a7a141ee..5bfc241945437 100644
--- a/clang-tools-extra/clangd/index/remote/CMakeLists.txt
+++ b/clang-tools-extra/clangd/index/remote/CMakeLists.txt
@@ -13,8 +13,6 @@ if (CLANGD_ENABLE_REMOTE)
 MonitoringServiceProto
 )
   include_directories(${CMAKE_CURRENT_BINARY_DIR})
-  include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../../)
-  include_directories(${CMAKE_CURRENT_BINARY_DIR}/../../)
 
   # FIXME(kirillbobyrev): target_compile_definitions is not working with
   # add_clang_library for some reason. Is there any way to make this

diff  --git a/clang-tools-extra/clangd/indexer/CMakeLists.txt 
b/clang-tools-extra/clangd/indexer/CMakeLists.txt
index f6389654b3628..a9438008ea039 100644
--- a/clang-tools-extra/clangd/indexer/CMakeLists.txt
+++ b/clang-tools-extra/clangd/indexe

[PATCH] D104797: [WebAssembly] Implementation of global.get/set for reftypes in LLVM IR

2021-07-02 Thread Paulo Matos 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 rG4facbf213c51: [WebAssembly] Implementation of global.get/set 
for reftypes in LLVM IR (authored by pmatos).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D104797

Files:
  clang/lib/Basic/Targets/WebAssembly.h
  clang/test/CodeGen/target-data.c
  llvm/include/llvm/CodeGen/TargetLowering.h
  llvm/include/llvm/CodeGen/ValueTypes.h
  llvm/lib/CodeGen/CodeGenPrepare.cpp
  llvm/lib/CodeGen/MachineOperand.cpp
  llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
  llvm/lib/CodeGen/TargetLoweringBase.cpp
  llvm/lib/CodeGen/ValueTypes.cpp
  llvm/lib/Target/WebAssembly/Utils/WebAssemblyUtilities.cpp
  llvm/lib/Target/WebAssembly/Utils/WebAssemblyUtilities.h
  llvm/lib/Target/WebAssembly/WebAssemblyFastISel.cpp
  llvm/lib/Target/WebAssembly/WebAssemblyISD.def
  llvm/lib/Target/WebAssembly/WebAssemblyISelDAGToDAG.cpp
  llvm/lib/Target/WebAssembly/WebAssemblyISelLowering.cpp
  llvm/lib/Target/WebAssembly/WebAssemblyISelLowering.h
  llvm/lib/Target/WebAssembly/WebAssemblyInstrTable.td
  llvm/lib/Target/WebAssembly/WebAssemblyMCInstLower.cpp
  llvm/lib/Target/WebAssembly/WebAssemblyTargetMachine.cpp
  llvm/test/CodeGen/WebAssembly/externref-globalget.ll
  llvm/test/CodeGen/WebAssembly/externref-globalset.ll
  llvm/test/CodeGen/WebAssembly/externref-inttoptr.ll
  llvm/test/CodeGen/WebAssembly/externref-ptrtoint.ll
  llvm/test/CodeGen/WebAssembly/externref-undef.ll
  llvm/test/CodeGen/WebAssembly/externref-unsized-load.ll
  llvm/test/CodeGen/WebAssembly/externref-unsized-store.ll
  llvm/test/CodeGen/WebAssembly/funcref-call.ll
  llvm/test/CodeGen/WebAssembly/funcref-globalget.ll
  llvm/test/CodeGen/WebAssembly/funcref-globalset.ll

Index: llvm/test/CodeGen/WebAssembly/funcref-globalset.ll
===
--- /dev/null
+++ llvm/test/CodeGen/WebAssembly/funcref-globalset.ll
@@ -0,0 +1,20 @@
+; RUN: llc < %s --mtriple=wasm32-unknown-unknown -asm-verbose=false -mattr=+reference-types | FileCheck %s
+
+%func = type opaque
+%funcref = type %func addrspace(20)* ;; addrspace 20 is nonintegral
+
+@funcref_global = local_unnamed_addr addrspace(1) global %funcref undef
+
+define void @set_funcref_global(%funcref %g) {
+  ;; this generates a global.set of @funcref_global
+  store %funcref %g, %funcref addrspace(1)* @funcref_global
+  ret void
+}
+
+; CHECK-LABEL: set_funcref_global:
+; CHECK-NEXT: functype   set_funcref_global (funcref) -> ()
+; CHECK-NEXT: local.get  0
+; CHECK-NEXT: global.set funcref_global
+; CHECK-NEXT: end_function
+
+; CHECK: .globl funcref_global
Index: llvm/test/CodeGen/WebAssembly/funcref-globalget.ll
===
--- /dev/null
+++ llvm/test/CodeGen/WebAssembly/funcref-globalget.ll
@@ -0,0 +1,19 @@
+; RUN: llc < %s --mtriple=wasm32-unknown-unknown -asm-verbose=false -mattr=+reference-types | FileCheck %s
+
+%func = type opaque
+%funcref = type %func addrspace(20)* ;; addrspace 20 is nonintegral
+
+@funcref_global = local_unnamed_addr addrspace(1) global %funcref undef
+
+define %funcref @return_funcref_global() {
+  ;; this generates a global.get of @funcref_global
+  %ref = load %funcref, %funcref addrspace(1)* @funcref_global
+  ret %funcref %ref
+}
+
+; CHECK-LABEL: return_funcref_global:
+; CHECK-NEXT: .functype   return_funcref_global () -> (funcref)
+; CHECK-NEXT: global.get funcref_global
+; CHECK-NEXT: end_function
+
+; CHECK: .globl funcref_global
Index: llvm/test/CodeGen/WebAssembly/funcref-call.ll
===
--- /dev/null
+++ llvm/test/CodeGen/WebAssembly/funcref-call.ll
@@ -0,0 +1,23 @@
+; RUN: llc < %s --mtriple=wasm32-unknown-unknown -asm-verbose=false -mattr=+reference-types | FileCheck %s
+
+%func = type void ()
+%funcref = type %func addrspace(20)* ;; addrspace 20 is nonintegral
+
+define void @call_funcref(%funcref %ref) {
+  call addrspace(20) void %ref() 
+  ret void
+}
+
+; CHECK-LABEL: call_funcref:
+; CHECK-NEXT: functype   call_funcref (funcref) -> ()
+; CHECK-NEXT: i32.const 0
+; CHECK-NEXT: local.get 0
+; CHECK-NEXT: table.set __funcref_call_table
+; CHECK-NEXT: local.get 0
+; CHECK-NEXT: call_indirect __funcref_call_table, () -> ()
+; CHECK-NEXT: i32.const 0
+; CHECK-NEXT: ref.null func
+; CHECK-NEXT: table.set __funcref_call_table
+; CHECK-NEXT: end_function
+
+; CHECK: .tabletype __funcref_call_table, funcref
Index: llvm/test/CodeGen/WebAssembly/externref-unsized-store.ll
===
--- /dev/null
+++ llvm/test/CodeGen/WebAssembly/externref-unsized-store.ll
@@ -0,0 +1,11 @@
+; RUN: not llc --mtriple=wasm32-unknown-unknown -asm-verbose=false -mattr=+reference-types < %s 2>&1 | FileCheck %s --check-prefix=CHECK-ERROR
+
+

[clang] 4facbf2 - [WebAssembly] Implementation of global.get/set for reftypes in LLVM IR

2021-07-02 Thread Paulo Matos via cfe-commits

Author: Paulo Matos
Date: 2021-07-02T09:46:28+02:00
New Revision: 4facbf213c51e4add2e8c19b08d5e58ad71c72de

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

LOG: [WebAssembly] Implementation of global.get/set for reftypes in LLVM IR

Reland of 31859f896.

This change implements new DAG notes GLOBAL_GET/GLOBAL_SET, and
lowering methods for load and stores of reference types from IR
globals. Once the lowering creates the new nodes, tablegen pattern
matches those and converts them to Wasm global.get/set.

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

Added: 
llvm/test/CodeGen/WebAssembly/externref-globalget.ll
llvm/test/CodeGen/WebAssembly/externref-globalset.ll
llvm/test/CodeGen/WebAssembly/externref-inttoptr.ll
llvm/test/CodeGen/WebAssembly/externref-ptrtoint.ll
llvm/test/CodeGen/WebAssembly/externref-undef.ll
llvm/test/CodeGen/WebAssembly/externref-unsized-load.ll
llvm/test/CodeGen/WebAssembly/externref-unsized-store.ll
llvm/test/CodeGen/WebAssembly/funcref-call.ll
llvm/test/CodeGen/WebAssembly/funcref-globalget.ll
llvm/test/CodeGen/WebAssembly/funcref-globalset.ll

Modified: 
clang/lib/Basic/Targets/WebAssembly.h
clang/test/CodeGen/target-data.c
llvm/include/llvm/CodeGen/TargetLowering.h
llvm/include/llvm/CodeGen/ValueTypes.h
llvm/lib/CodeGen/CodeGenPrepare.cpp
llvm/lib/CodeGen/MachineOperand.cpp
llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
llvm/lib/CodeGen/TargetLoweringBase.cpp
llvm/lib/CodeGen/ValueTypes.cpp
llvm/lib/Target/WebAssembly/Utils/WebAssemblyUtilities.cpp
llvm/lib/Target/WebAssembly/Utils/WebAssemblyUtilities.h
llvm/lib/Target/WebAssembly/WebAssemblyFastISel.cpp
llvm/lib/Target/WebAssembly/WebAssemblyISD.def
llvm/lib/Target/WebAssembly/WebAssemblyISelDAGToDAG.cpp
llvm/lib/Target/WebAssembly/WebAssemblyISelLowering.cpp
llvm/lib/Target/WebAssembly/WebAssemblyISelLowering.h
llvm/lib/Target/WebAssembly/WebAssemblyInstrTable.td
llvm/lib/Target/WebAssembly/WebAssemblyMCInstLower.cpp
llvm/lib/Target/WebAssembly/WebAssemblyTargetMachine.cpp

Removed: 




diff  --git a/clang/lib/Basic/Targets/WebAssembly.h 
b/clang/lib/Basic/Targets/WebAssembly.h
index b29730c5d706b..ed590fe7e3338 100644
--- a/clang/lib/Basic/Targets/WebAssembly.h
+++ b/clang/lib/Basic/Targets/WebAssembly.h
@@ -147,7 +147,7 @@ class LLVM_LIBRARY_VISIBILITY WebAssembly32TargetInfo
   explicit WebAssembly32TargetInfo(const llvm::Triple &T,
const TargetOptions &Opts)
   : WebAssemblyTargetInfo(T, Opts) {
-resetDataLayout("e-m:e-p:32:32-i64:64-n32:64-S128-ni:1");
+resetDataLayout("e-m:e-p:32:32-i64:64-n32:64-S128-ni:1:10:20");
   }
 
 protected:
@@ -166,7 +166,7 @@ class LLVM_LIBRARY_VISIBILITY WebAssembly64TargetInfo
 SizeType = UnsignedLong;
 PtrDiffType = SignedLong;
 IntPtrType = SignedLong;
-resetDataLayout("e-m:e-p:64:64-i64:64-n32:64-S128-ni:1");
+resetDataLayout("e-m:e-p:64:64-i64:64-n32:64-S128-ni:1:10:20");
   }
 
 protected:

diff  --git a/clang/test/CodeGen/target-data.c 
b/clang/test/CodeGen/target-data.c
index 1d88984530e5b..1be01efd16515 100644
--- a/clang/test/CodeGen/target-data.c
+++ b/clang/test/CodeGen/target-data.c
@@ -108,11 +108,11 @@
 
 // RUN: %clang_cc1 -triple wasm32-unknown-unknown -o - -emit-llvm %s | \
 // RUN: FileCheck %s -check-prefix=WEBASSEMBLY32
-// WEBASSEMBLY32: target datalayout = "e-m:e-p:32:32-i64:64-n32:64-S128-ni:1"
+// WEBASSEMBLY32: target datalayout = 
"e-m:e-p:32:32-i64:64-n32:64-S128-ni:1:10:20"
 
 // RUN: %clang_cc1 -triple wasm64-unknown-unknown -o - -emit-llvm %s | \
 // RUN: FileCheck %s -check-prefix=WEBASSEMBLY64
-// WEBASSEMBLY64: target datalayout = "e-m:e-p:64:64-i64:64-n32:64-S128-ni:1"
+// WEBASSEMBLY64: target datalayout = 
"e-m:e-p:64:64-i64:64-n32:64-S128-ni:1:10:20"
 
 // RUN: %clang_cc1 -triple lanai-unknown-unknown -o - -emit-llvm %s | \
 // RUN: FileCheck %s -check-prefix=LANAI

diff  --git a/llvm/include/llvm/CodeGen/TargetLowering.h 
b/llvm/include/llvm/CodeGen/TargetLowering.h
index 47d6ca43a5ac3..75894d15a9693 100644
--- a/llvm/include/llvm/CodeGen/TargetLowering.h
+++ b/llvm/include/llvm/CodeGen/TargetLowering.h
@@ -350,7 +350,7 @@ class TargetLoweringBase {
   /// Return the in-memory pointer type for the given address space, defaults 
to
   /// the pointer type from the data layout.  FIXME: The default needs to be
   /// removed once all the code is updated.
-  MVT getPointerMemTy(const DataLayout &DL, uint32_t AS = 0) const {
+  virtual MVT getPointerMemTy(const DataLayout &DL, uint32_t AS = 0) const {
 return MVT::getIntegerVT(DL.getPointerSizeInBits(AS));
   }
 

diff  --git a/llvm/include/llvm/CodeGen/ValueTypes.h 
b/llvm/include/llvm/CodeGen/V

[PATCH] D102492: [clang][AST] Add support for BindingDecl to ASTImporter.

2021-07-02 Thread Gabor Marton via Phabricator via cfe-commits
martong accepted this revision.
martong added a comment.

In D102492#2854811 , @balazske wrote:

> Not using `auto` declarations.

Still looks good, thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D102492

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


[clang-tools-extra] 0c53f60 - [clangd] Add some more missing include dirs for completeness

2021-07-02 Thread Sam McCall via cfe-commits

Author: Sam McCall
Date: 2021-07-02T09:04:53+02:00
New Revision: 0c53f602d5a9d7207abb13e463f68e9d092f47a7

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

LOG: [clangd] Add some more missing include dirs for completeness

Added: 


Modified: 
clang-tools-extra/clangd/benchmarks/CMakeLists.txt
clang-tools-extra/clangd/indexer/CMakeLists.txt
clang-tools-extra/clangd/unittests/xpc/CMakeLists.txt

Removed: 




diff  --git a/clang-tools-extra/clangd/benchmarks/CMakeLists.txt 
b/clang-tools-extra/clangd/benchmarks/CMakeLists.txt
index b62ffd7a1ad16..7a17637b6c377 100644
--- a/clang-tools-extra/clangd/benchmarks/CMakeLists.txt
+++ b/clang-tools-extra/clangd/benchmarks/CMakeLists.txt
@@ -1,4 +1,5 @@
-include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../)
+include_directories(${CMAKE_CURRENT_SOURCE_DIR}/..
+  ${CMAKE_CURRENT_BINARY_DIR}/..)
 
 add_subdirectory(CompletionModel)
 

diff  --git a/clang-tools-extra/clangd/indexer/CMakeLists.txt 
b/clang-tools-extra/clangd/indexer/CMakeLists.txt
index ff110693c7066..f6389654b3628 100644
--- a/clang-tools-extra/clangd/indexer/CMakeLists.txt
+++ b/clang-tools-extra/clangd/indexer/CMakeLists.txt
@@ -1,4 +1,5 @@
 include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../)
+include_directories(${CMAKE_CURRENT_BINARY_DIR}/../)
 
 set(LLVM_LINK_COMPONENTS
 Support

diff  --git a/clang-tools-extra/clangd/unittests/xpc/CMakeLists.txt 
b/clang-tools-extra/clangd/unittests/xpc/CMakeLists.txt
index 21a1667b52d37..372528d1e82d3 100644
--- a/clang-tools-extra/clangd/unittests/xpc/CMakeLists.txt
+++ b/clang-tools-extra/clangd/unittests/xpc/CMakeLists.txt
@@ -4,8 +4,11 @@ set(LLVM_LINK_COMPONENTS
 
 get_filename_component(CLANGD_SOURCE_DIR
   ${CMAKE_CURRENT_SOURCE_DIR}/../../clangd REALPATH)
+get_filename_component(CLANGD_BINARY_DIR
+  ${CMAKE_CURRENT_SOURCE_DIR}/../../clangd REALPATH)
 include_directories(
   ${CLANGD_SOURCE_DIR}
+  ${CLANGD_BINARY_DIR}
   )
 
 add_custom_target(ClangdXpcUnitTests)



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