[PATCH] D103796: [Clang][RISCV] Implement vlsseg.

2021-07-12 Thread Hsiangkai Wang via Phabricator via cfe-commits
HsiangKai added a comment.

Ping.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D103796

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


[PATCH] D103809: [Clang][RISCV] Implement vloxseg and vluxseg.

2021-07-12 Thread Hsiangkai Wang via Phabricator via cfe-commits
HsiangKai added a comment.

Ping.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D103809

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


[PATCH] D103871: [Clang][RISCV] Implement vsseg.

2021-07-12 Thread Hsiangkai Wang via Phabricator via cfe-commits
HsiangKai added a comment.

Ping.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D103871

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


[PATCH] D103872: [Clang][RISCV] Implement vssseg.

2021-07-12 Thread Hsiangkai Wang via Phabricator via cfe-commits
HsiangKai added a comment.

Ping.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D103872

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


[PATCH] D103873: [Clang][RISCV] Implement vsoxseg and vsuxseg.

2021-07-12 Thread Hsiangkai Wang via Phabricator via cfe-commits
HsiangKai added a comment.

Ping.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D103873

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


[PATCH] D105001: [Clang][RISCV] Support half-precision floating point for RVV intrinsics.

2021-07-12 Thread Hsiangkai Wang via Phabricator via cfe-commits
HsiangKai added a comment.

Ping.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105001

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


[PATCH] D95168: [clang-format] Add InsertBraces option

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

could you add tests showing the impact of using `[[likely]]` and `[[unlikely]]`


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95168

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


[PATCH] D104854: Introduce intrinsic llvm.isnan

2021-07-12 Thread Serge Pavlov via Phabricator via cfe-commits
sepavloff updated this revision to Diff 357857.
sepavloff added a comment.

Rebased


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D104854

Files:
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/test/CodeGen/X86/strictfp_builtins.c
  clang/test/CodeGen/aarch64-strictfp-builtins.c
  clang/test/CodeGen/strictfp_builtins.c
  llvm/docs/LangRef.rst
  llvm/include/llvm/CodeGen/ISDOpcodes.h
  llvm/include/llvm/CodeGen/TargetLowering.h
  llvm/include/llvm/IR/Intrinsics.td
  llvm/lib/Analysis/ConstantFolding.cpp
  llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp
  llvm/lib/CodeGen/SelectionDAG/LegalizeIntegerTypes.cpp
  llvm/lib/CodeGen/SelectionDAG/LegalizeTypes.h
  llvm/lib/CodeGen/SelectionDAG/LegalizeVectorTypes.cpp
  llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
  llvm/lib/CodeGen/SelectionDAG/SelectionDAGDumper.cpp
  llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp
  llvm/lib/CodeGen/TargetLoweringBase.cpp
  llvm/lib/Target/X86/X86ISelLowering.cpp
  llvm/test/CodeGen/AArch64/aarch64-fpclass.ll
  llvm/test/CodeGen/PowerPC/ppc-fpclass.ll
  llvm/test/CodeGen/X86/x86-fpclass.ll
  llvm/test/Transforms/InstSimplify/ConstProp/fpclassify.ll

Index: llvm/test/Transforms/InstSimplify/ConstProp/fpclassify.ll
===
--- /dev/null
+++ llvm/test/Transforms/InstSimplify/ConstProp/fpclassify.ll
@@ -0,0 +1,28 @@
+; RUN: opt < %s -instsimplify -S | FileCheck %s
+
+define i1 @isnan_01() {
+entry:
+  %0 = tail call i1 @llvm.isnan.f32(float 0x7FF8)
+  ret i1 %0
+}
+; CHECK-LABEL: isnan_01
+; CHECK:   ret i1 true 
+
+define i1 @isnan_02() {
+entry:
+  %0 = tail call i1 @llvm.isnan.f32(float 0x7FF0)
+  ret i1 %0
+}
+; CHECK-LABEL: isnan_02
+; CHECK:   ret i1 false 
+
+define <4 x i1> @isnan_03() {
+entry:
+  %0 = tail call <4 x i1> @llvm.isnan.v4f32(<4 x float>)
+  ret <4 x i1> %0
+}
+; CHECK-LABEL: isnan_03
+; CHECK:   ret <4 x i1> 
+
+declare i1 @llvm.isnan.f32(float)
+declare <4 x i1> @llvm.isnan.v4f32(<4 x float>)
Index: llvm/test/CodeGen/X86/x86-fpclass.ll
===
--- /dev/null
+++ llvm/test/CodeGen/X86/x86-fpclass.ll
@@ -0,0 +1,655 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
+; RUN: llc < %s -mtriple=i686 | FileCheck %s -check-prefix=CHECK-32
+; RUN: llc < %s -mtriple=x86_64 | FileCheck %s -check-prefix=CHECK-64
+
+define i1 @isnan_float(float %x) {
+; CHECK-32-LABEL: isnan_float:
+; CHECK-32:   # %bb.0: # %entry
+; CHECK-32-NEXT:flds {{[0-9]+}}(%esp)
+; CHECK-32-NEXT:fucomp %st(0)
+; CHECK-32-NEXT:fnstsw %ax
+; CHECK-32-NEXT:# kill: def $ah killed $ah killed $ax
+; CHECK-32-NEXT:sahf
+; CHECK-32-NEXT:setp %al
+; CHECK-32-NEXT:retl
+;
+; CHECK-64-LABEL: isnan_float:
+; CHECK-64:   # %bb.0: # %entry
+; CHECK-64-NEXT:ucomiss %xmm0, %xmm0
+; CHECK-64-NEXT:setp %al
+; CHECK-64-NEXT:retq
+; NOSSE-32-LABEL: isnan_float:
+entry:
+  %0 = tail call i1 @llvm.isnan.f32(float %x)
+  ret i1 %0
+}
+
+define i1 @isnan_double(double %x) {
+; CHECK-32-LABEL: isnan_double:
+; CHECK-32:   # %bb.0: # %entry
+; CHECK-32-NEXT:fldl {{[0-9]+}}(%esp)
+; CHECK-32-NEXT:fucomp %st(0)
+; CHECK-32-NEXT:fnstsw %ax
+; CHECK-32-NEXT:# kill: def $ah killed $ah killed $ax
+; CHECK-32-NEXT:sahf
+; CHECK-32-NEXT:setp %al
+; CHECK-32-NEXT:retl
+;
+; CHECK-64-LABEL: isnan_double:
+; CHECK-64:   # %bb.0: # %entry
+; CHECK-64-NEXT:ucomisd %xmm0, %xmm0
+; CHECK-64-NEXT:setp %al
+; CHECK-64-NEXT:retq
+entry:
+  %0 = tail call i1 @llvm.isnan.f64(double %x)
+  ret i1 %0
+}
+
+define i1 @isnan_ldouble(x86_fp80 %x) {
+; CHECK-32-LABEL: isnan_ldouble:
+; CHECK-32:   # %bb.0: # %entry
+; CHECK-32-NEXT:fldt {{[0-9]+}}(%esp)
+; CHECK-32-NEXT:fxam
+; CHECK-32-NEXT:fstp %st(0)
+; CHECK-32-NEXT:fnstsw %ax
+; CHECK-32-NEXT:andb $69, %ah
+; CHECK-32-NEXT:cmpb $1, %ah
+; CHECK-32-NEXT:sete %al
+; CHECK-32-NEXT:retl
+;
+; CHECK-64-LABEL: isnan_ldouble:
+; CHECK-64:   # %bb.0: # %entry
+; CHECK-64-NEXT:fldt {{[0-9]+}}(%rsp)
+; CHECK-64-NEXT:fxam
+; CHECK-64-NEXT:fstp %st(0)
+; CHECK-64-NEXT:fnstsw %ax
+; CHECK-64-NEXT:andb $69, %ah
+; CHECK-64-NEXT:cmpb $1, %ah
+; CHECK-64-NEXT:sete %al
+; CHECK-64-NEXT:retq
+entry:
+  %0 = tail call i1 @llvm.isnan.f80(x86_fp80 %x)
+  ret i1 %0
+}
+
+define i1 @isnan_float_strictfp(float %x) strictfp {
+; CHECK-32-LABEL: isnan_float_strictfp:
+; CHECK-32:   # %bb.0: # %entry
+; CHECK-32-NEXT:movl $2147483647, %eax # imm = 0x7FFF
+; CHECK-32-NEXT:andl {{[0-9]+}}(%esp), %eax
+; CHECK-32-NEXT:cmpl $2139095040, %eax # imm = 0x7F80
+; CHECK-32-NEXT:setne %al
+; CHECK-32-NEXT:retl
+;
+; CHECK-64-LABEL: isnan_float_strictfp:
+; CHECK-64:   # %bb.0: # %entry
+; CHECK-64-NEXT:movd

[PATCH] D104536: WIP: [clang][deps] Avoid minimizing PCH input files

2021-07-12 Thread Jan Svoboda via Phabricator via cfe-commits
jansvoboda11 updated this revision to Diff 357862.
jansvoboda11 added reviewers: Bigcheese, dexonsmith, arphaman.
jansvoboda11 added a comment.

Handle system input files.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D104536

Files:
  clang/lib/Tooling/DependencyScanning/DependencyScanningWorker.cpp
  clang/test/ClangScanDeps/modules-pch.c

Index: clang/test/ClangScanDeps/modules-pch.c
===
--- clang/test/ClangScanDeps/modules-pch.c
+++ clang/test/ClangScanDeps/modules-pch.c
@@ -6,7 +6,7 @@
 // RUN: sed "s|DIR|%/t|g" %S/Inputs/modules-pch/cdb_pch.json > %t/cdb.json
 // RUN: echo -%t > %t/result_pch.json
 // RUN: clang-scan-deps -compilation-database %t/cdb.json -format experimental-full \
-// RUN:   -generate-modules-path-args -module-files-dir %t/build -mode preprocess >> %t/result_pch.json
+// RUN:   -generate-modules-path-args -module-files-dir %t/build >> %t/result_pch.json
 // RUN: cat %t/result_pch.json | sed 's:\?:/:g' | FileCheck %s -check-prefix=CHECK-PCH
 //
 // Check we didn't build the PCH during dependency scanning.
@@ -127,9 +127,8 @@
 //
 // RUN: sed "s|DIR|%/t|g" %S/Inputs/modules-pch/cdb_tu.json > %t/cdb.json
 // RUN: echo -%t > %t/result_tu.json
-// FIXME: Make this work with '-mode preprocess-minimized-sources'.
 // RUN: clang-scan-deps -compilation-database %t/cdb.json -format experimental-full \
-// RUN:   -generate-modules-path-args -module-files-dir %t/build -mode preprocess >> %t/result_tu.json
+// RUN:   -generate-modules-path-args -module-files-dir %t/build >> %t/result_tu.json
 // RUN: cat %t/result_tu.json | sed 's:\?:/:g' | FileCheck %s -check-prefix=CHECK-TU
 //
 // CHECK-TU:  -[[PREFIX:.*]]
@@ -193,7 +192,7 @@
 // RUN: sed "s|DIR|%/t|g" %S/Inputs/modules-pch/cdb_tu_with_common.json > %t/cdb.json
 // RUN: echo -%t > %t/result_tu_with_common.json
 // RUN: clang-scan-deps -compilation-database %t/cdb.json -format experimental-full \
-// RUN:   -generate-modules-path-args -module-files-dir %t/build -mode preprocess >> %t/result_tu_with_common.json
+// RUN:   -generate-modules-path-args -module-files-dir %t/build >> %t/result_tu_with_common.json
 // RUN: cat %t/result_tu_with_common.json | sed 's:\?:/:g' | FileCheck %s -check-prefix=CHECK-TU-WITH-COMMON
 //
 // CHECK-TU-WITH-COMMON:  -[[PREFIX:.*]]
Index: clang/lib/Tooling/DependencyScanning/DependencyScanningWorker.cpp
===
--- clang/lib/Tooling/DependencyScanning/DependencyScanningWorker.cpp
+++ clang/lib/Tooling/DependencyScanning/DependencyScanningWorker.cpp
@@ -46,25 +46,75 @@
   DependencyConsumer &C;
 };
 
-/// A listener that collects the names and paths to imported modules.
-class ImportCollectingListener : public ASTReaderListener {
-  using PrebuiltModuleFilesT =
-  decltype(HeaderSearchOptions::PrebuiltModuleFiles);
-
+/// A listener that collects the imported modules and optionally the input
+/// files.
+class PrebuiltModuleListener : public ASTReaderListener {
 public:
-  ImportCollectingListener(PrebuiltModuleFilesT &PrebuiltModuleFiles)
-  : PrebuiltModuleFiles(PrebuiltModuleFiles) {}
+  PrebuiltModuleListener(llvm::StringMap &PrebuiltModuleFiles,
+ llvm::StringSet<> &InputFiles, bool VisitInputFiles)
+  : PrebuiltModuleFiles(PrebuiltModuleFiles), InputFiles(InputFiles),
+VisitInputFiles(VisitInputFiles) {}
 
   bool needsImportVisitation() const override { return true; }
+  bool needsInputFileVisitation() override { return VisitInputFiles; }
+  bool needsSystemInputFileVisitation() override { return VisitInputFiles; }
 
   void visitImport(StringRef ModuleName, StringRef Filename) override {
-PrebuiltModuleFiles[std::string(ModuleName)] = std::string(Filename);
+PrebuiltModuleFiles.insert({ModuleName, Filename.str()});
+  }
+
+  bool visitInputFile(StringRef Filename, bool isSystem, bool isOverridden,
+  bool isExplicitModule) override {
+InputFiles.insert(Filename);
+return true;
   }
 
 private:
-  PrebuiltModuleFilesT &PrebuiltModuleFiles;
+  llvm::StringMap &PrebuiltModuleFiles;
+  llvm::StringSet<> &InputFiles;
+  bool VisitInputFiles;
 };
 
+using PrebuiltModuleFilesT = decltype(HeaderSearchOptions::PrebuiltModuleFiles);
+
+/// If the compiler invocation is configured with a PCH file, collect all of the
+/// (transitively) imported module files and contributing input files.
+static void visitPrebuiltModules(CompilerInstance &Compiler,
+ PrebuiltModuleFilesT &ModuleFiles,
+ llvm::StringSet<> &InputFiles,
+ bool VisitInputFiles) {
+  if (Compiler.getPreprocessorOpts().ImplicitPCHInclude.empty())
+return;
+
+  // Maps the names of modules that weren't yet visited to their PCM path.
+  llvm::StringMap Modu

[PATCH] D104918: [clang-repl] Implement partial translation units and error recovery.

2021-07-12 Thread Raphael Isemann via Phabricator via cfe-commits
teemperor added a comment.

@v.g.vassilev For LLDB you need to change the 
`TypeSystemClang::SetExternalSource` function to this (it just moves the 
`setHasExternalLexicalStorage` one line up. You can just add that change and 
the compilation fix to this commit.

  void TypeSystemClang::SetExternalSource(
  llvm::IntrusiveRefCntPtr &ast_source_up) {
ASTContext &ast = getASTContext();
ast.getTranslationUnitDecl()->setHasExternalLexicalStorage(true);
ast.setExternalSource(ast_source_up);
  }

The problem is that a few ASTs in LLDB change the ExternalSource that is 
originally set, but the LazyGenerationalUpdatePtr remembers the initial 
ExternalSource and tries to access it to complete the redecl chain (but the 
original ExternalSource just got replaced and deleted). The better fix is to 
not even create that original ExternalSource, but I can fix that in a follow up 
as that seems out of scope for this patch.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D104918

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


[PATCH] D105692: [analyzer][solver][NFC] Introduce ConstraintAssignor

2021-07-12 Thread Gabor Marton via Phabricator via cfe-commits
martong added a comment.

Uhh, what the hell happened with the `Stack`?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105692

___
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-12 Thread Sam McCall via Phabricator via cfe-commits
sammccall added inline comments.



Comment at: clang-tools-extra/clang-tidy/ClangTidy.cpp:310
+struct DeclFilter {
+  DeclFilter(ClangTidyContext &Ctx, SourceManager &SM)
+  : Context(Ctx), Sources(SM) {

chh wrote:
> sammccall wrote:
> > Ctx is ultimately unused, just take the regex instead?
> Context is used in skipFileID.
> 
Oops, I did miss this. Since we extract the header regex, can we also pull out 
the one boolean that we check later into a field? This would make it clearer 
how the context is used, since it's a large object.



Comment at: clang-tools-extra/clang-tidy/ClangTidy.cpp:514
+  for (auto &Consumer : Consumers) {
+if (hasFilter() && Consumer.get() == FinderASTConsumerPtr) {
+  // Modify AST before calling the Finder's ASTConsumer.

chh wrote:
> sammccall wrote:
> > This adds significant conceptual complexity and possible runtime costs to 
> > guard against the possibility that the static analyzer would not be 
> > compatible with simply setting the traversal scope.
> > 
> > Please do not do this. It may appear that you're cheaply eliminating a 
> > class of bugs, but complexity is not cheap, and in the long run can also 
> > introduce bugs. Instead investigate whether this is a real problem and why.
> > 
> > If it's not then `Context.setTraversalScope()` + 
> > `MultiplexingASTConsumer::HandleTranslationUnit` is enough here, and 
> > `FinderASTConsumerPtr` can go away.
> For this first step implementation of skip-headers, could we limit the risk 
> and impact to only AST MatchFinder based checks? If it works fine, we can add 
> more performance improvements, handle PPCallback-based checks, and static 
> analyzer checks. We can turn skip-headers to default or revert any follow up 
> step.
> 
> At this time, we only know that PPCallback-based checks can save some more 
> time with skip-headers, but do not know if any static analyzer check can 
> benefit from skip-headers easily. In other words, we are sure to deliver big 
> saving of runtime for clang-tidy users that do not enable static analyzer 
> checks, but not sure about static analyzer check users.
> 
> The overhead and complexity of set/getTraversalScope and checking filters 
> will be on the users of skip-header, but not on the static analyzer checkers.
> 
> If we apply the same change to AST for all consumers, the saving of code 
> complexity is smaller than the risk of impact to static analyzer checks, and 
> the saving of runtime is also much smaller than the already saved time in 
> MatchFinder.
> 
OK, fair enough. However you seem to both be saying "let's do this for now" and 
"if traversal scope is unimportant for static-analyzer performance, we need 
never change this".
The main point of applying traversal scope uniformly is to avoid complexity and 
special cases, not to improve performance.

If we want to have this fairly unusual mechanism and require maintainers to 
understand it, then needs to be mitigated by a significant comment somewhere 
explaining:
 - what is being done (wrapping HandleTranslationUnitDecl in traversalscope 
load/restore logic for one consumer only)
 - how it's being done (keep an extra pointer to the "special" consumer so we 
can identify it)
 - why it's being done (ideally concrete problems in applying the scope 
everywhere, but at least why we don't expect this to be safe)

Coming up with a good answer to the "why" question is part of this change.



Comment at: clang-tools-extra/clang-tidy/ClangTidyOptions.cpp:99
 IO.mapOptional("InheritParentConfig", Options.InheritParentConfig);
 IO.mapOptional("UseColor", Options.UseColor);
   }

chh wrote:
> sammccall wrote:
> > Maybe an explicit comment that ShowAllHeaders, SkipHeaders are 
> > runtime/optimization options that are configured at the command-line only, 
> > and therefore not mapped here
> Why SystemHeaders is not mapped?
> I agree that ShowAllWarnings is not important here,
> but SkipHeaders seems as important to be included here as HeaderFilterRegex 
> and SystemHeaders.
> 
> Why SystemHeaders is not mapped?

No idea, sorry.

> but SkipHeaders seems as important to be included here as HeaderFilterRegex 
> and SystemHeaders.

I don't think so.

HeaderFilterRegex and SystemHeaders control policy, and it's reasonable for 
that to depend on the specific code (and therefore be dynamically configurable).
SkipHeaders only controls the mechanism/implementation strategy - why do we 
need to support different strategies for different files in the same clang-tidy 
invocation, rather than just rolling it out with a flag?

Moreover, the plan AIUI is for SkipHeaders to become the default and for the 
option to go away. We should try to avoid supporting it in config files if 
that's the case.



Comment at: clang-tools-extra/clang-tidy/ClangTidyOptions.h:84
+  /// and system files when --system-headers is used.
+  llvm::Option

[PATCH] D105637: [clang][Analyzer] Add symbol uninterestingness to bug report.

2021-07-12 Thread Balázs Kéri via Phabricator via cfe-commits
balazske updated this revision to Diff 357872.
balazske added a comment.
Herald added a subscriber: mgorny.

Added the unit test.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105637

Files:
  clang/include/clang/StaticAnalyzer/Core/BugReporter/BugReporter.h
  clang/lib/StaticAnalyzer/Core/BugReporter.cpp
  clang/unittests/StaticAnalyzer/BugReportInterestingnessTest.cpp
  clang/unittests/StaticAnalyzer/CMakeLists.txt
  clang/unittests/StaticAnalyzer/Reusables.h

Index: clang/unittests/StaticAnalyzer/Reusables.h
===
--- clang/unittests/StaticAnalyzer/Reusables.h
+++ clang/unittests/StaticAnalyzer/Reusables.h
@@ -10,9 +10,10 @@
 #define LLVM_CLANG_UNITTESTS_STATICANALYZER_REUSABLES_H
 
 #include "clang/ASTMatchers/ASTMatchFinder.h"
-#include "clang/Frontend/CompilerInstance.h"
 #include "clang/CrossTU/CrossTranslationUnit.h"
+#include "clang/Frontend/CompilerInstance.h"
 #include "clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h"
+#include "gtest/gtest.h"
 
 namespace clang {
 namespace ento {
@@ -66,6 +67,87 @@
 Eng(CTU, AMgr, &VisitedCallees, &FS, ExprEngine::Inline_Regular) {}
 };
 
+struct ExpectedLocationTy {
+  unsigned Line;
+  unsigned Column;
+
+  void testEquality(SourceLocation L, SourceManager &SM) const {
+EXPECT_EQ(SM.getSpellingLineNumber(L), Line);
+EXPECT_EQ(SM.getSpellingColumnNumber(L), Column);
+  }
+};
+
+struct ExpectedRangeTy {
+  ExpectedLocationTy Begin;
+  ExpectedLocationTy End;
+
+  void testEquality(SourceRange R, SourceManager &SM) const {
+Begin.testEquality(R.getBegin(), SM);
+End.testEquality(R.getEnd(), SM);
+  }
+};
+
+struct ExpectedPieceTy {
+  ExpectedLocationTy Loc;
+  std::string Text;
+  std::vector Ranges;
+
+  void testEquality(const PathDiagnosticPiece &Piece, SourceManager &SM) {
+Loc.testEquality(Piece.getLocation().asLocation(), SM);
+EXPECT_EQ(Piece.getString(), Text);
+EXPECT_EQ(Ranges.size(), Piece.getRanges().size());
+for (const auto &RangeItem : llvm::enumerate(Piece.getRanges()))
+  Ranges[RangeItem.index()].testEquality(RangeItem.value(), SM);
+  }
+};
+
+struct ExpectedDiagTy {
+  ExpectedLocationTy Loc;
+  std::string VerboseDescription;
+  std::string ShortDescription;
+  std::string CheckerName;
+  std::string BugType;
+  std::string Category;
+  std::vector Path;
+
+  void testEquality(const PathDiagnostic &Diag, SourceManager &SM) {
+Loc.testEquality(Diag.getLocation().asLocation(), SM);
+EXPECT_EQ(Diag.getVerboseDescription(), VerboseDescription);
+EXPECT_EQ(Diag.getShortDescription(), ShortDescription);
+EXPECT_EQ(Diag.getCheckerName(), CheckerName);
+EXPECT_EQ(Diag.getBugType(), BugType);
+EXPECT_EQ(Diag.getCategory(), Category);
+
+EXPECT_EQ(Path.size(), Diag.path.size());
+for (const auto &PieceItem : llvm::enumerate(Diag.path)) {
+  if (PieceItem.index() < Path.size())
+Path[PieceItem.index()].testEquality(*PieceItem.value(), SM);
+}
+  }
+};
+
+using ExpectedDiagsTy = std::vector;
+
+// A consumer to verify the generated diagnostics.
+class DiagnosticVerifyConsumer : public PathDiagnosticConsumer {
+  ExpectedDiagsTy ExpectedDiags;
+  SourceManager &SM;
+
+public:
+  DiagnosticVerifyConsumer(ExpectedDiagsTy &&ExpectedDiags, SourceManager &SM)
+  : ExpectedDiags(ExpectedDiags), SM(SM) {}
+
+  StringRef getName() const override { return "verify test diagnostics"; }
+
+  void FlushDiagnosticsImpl(std::vector &Diags,
+FilesMade *filesMade) override {
+EXPECT_EQ(Diags.size(), ExpectedDiags.size());
+for (const auto &Item : llvm::enumerate(Diags))
+  if (Item.index() < ExpectedDiags.size())
+ExpectedDiags[Item.index()].testEquality(*Item.value(), SM);
+  }
+};
+
 } // namespace ento
 } // namespace clang
 
Index: clang/unittests/StaticAnalyzer/CMakeLists.txt
===
--- clang/unittests/StaticAnalyzer/CMakeLists.txt
+++ clang/unittests/StaticAnalyzer/CMakeLists.txt
@@ -5,6 +5,7 @@
 
 add_clang_unittest(StaticAnalysisTests
   AnalyzerOptionsTest.cpp
+  BugReportInterestingnessTest.cpp
   CallDescriptionTest.cpp
   CallEventTest.cpp
   FalsePositiveRefutationBRVisitorTest.cpp
Index: clang/unittests/StaticAnalyzer/BugReportInterestingnessTest.cpp
===
--- /dev/null
+++ clang/unittests/StaticAnalyzer/BugReportInterestingnessTest.cpp
@@ -0,0 +1,357 @@
+//===--===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "Reusa

[PATCH] D105637: [clang][Analyzer] Add symbol uninterestingness to bug report.

2021-07-12 Thread Balázs Kéri via Phabricator via cfe-commits
balazske updated this revision to Diff 357873.
balazske added a comment.

Removed "garbage" from end of test file.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105637

Files:
  clang/include/clang/StaticAnalyzer/Core/BugReporter/BugReporter.h
  clang/lib/StaticAnalyzer/Core/BugReporter.cpp
  clang/unittests/StaticAnalyzer/BugReportInterestingnessTest.cpp
  clang/unittests/StaticAnalyzer/CMakeLists.txt
  clang/unittests/StaticAnalyzer/Reusables.h

Index: clang/unittests/StaticAnalyzer/Reusables.h
===
--- clang/unittests/StaticAnalyzer/Reusables.h
+++ clang/unittests/StaticAnalyzer/Reusables.h
@@ -10,9 +10,10 @@
 #define LLVM_CLANG_UNITTESTS_STATICANALYZER_REUSABLES_H
 
 #include "clang/ASTMatchers/ASTMatchFinder.h"
-#include "clang/Frontend/CompilerInstance.h"
 #include "clang/CrossTU/CrossTranslationUnit.h"
+#include "clang/Frontend/CompilerInstance.h"
 #include "clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h"
+#include "gtest/gtest.h"
 
 namespace clang {
 namespace ento {
@@ -66,6 +67,87 @@
 Eng(CTU, AMgr, &VisitedCallees, &FS, ExprEngine::Inline_Regular) {}
 };
 
+struct ExpectedLocationTy {
+  unsigned Line;
+  unsigned Column;
+
+  void testEquality(SourceLocation L, SourceManager &SM) const {
+EXPECT_EQ(SM.getSpellingLineNumber(L), Line);
+EXPECT_EQ(SM.getSpellingColumnNumber(L), Column);
+  }
+};
+
+struct ExpectedRangeTy {
+  ExpectedLocationTy Begin;
+  ExpectedLocationTy End;
+
+  void testEquality(SourceRange R, SourceManager &SM) const {
+Begin.testEquality(R.getBegin(), SM);
+End.testEquality(R.getEnd(), SM);
+  }
+};
+
+struct ExpectedPieceTy {
+  ExpectedLocationTy Loc;
+  std::string Text;
+  std::vector Ranges;
+
+  void testEquality(const PathDiagnosticPiece &Piece, SourceManager &SM) {
+Loc.testEquality(Piece.getLocation().asLocation(), SM);
+EXPECT_EQ(Piece.getString(), Text);
+EXPECT_EQ(Ranges.size(), Piece.getRanges().size());
+for (const auto &RangeItem : llvm::enumerate(Piece.getRanges()))
+  Ranges[RangeItem.index()].testEquality(RangeItem.value(), SM);
+  }
+};
+
+struct ExpectedDiagTy {
+  ExpectedLocationTy Loc;
+  std::string VerboseDescription;
+  std::string ShortDescription;
+  std::string CheckerName;
+  std::string BugType;
+  std::string Category;
+  std::vector Path;
+
+  void testEquality(const PathDiagnostic &Diag, SourceManager &SM) {
+Loc.testEquality(Diag.getLocation().asLocation(), SM);
+EXPECT_EQ(Diag.getVerboseDescription(), VerboseDescription);
+EXPECT_EQ(Diag.getShortDescription(), ShortDescription);
+EXPECT_EQ(Diag.getCheckerName(), CheckerName);
+EXPECT_EQ(Diag.getBugType(), BugType);
+EXPECT_EQ(Diag.getCategory(), Category);
+
+EXPECT_EQ(Path.size(), Diag.path.size());
+for (const auto &PieceItem : llvm::enumerate(Diag.path)) {
+  if (PieceItem.index() < Path.size())
+Path[PieceItem.index()].testEquality(*PieceItem.value(), SM);
+}
+  }
+};
+
+using ExpectedDiagsTy = std::vector;
+
+// A consumer to verify the generated diagnostics.
+class DiagnosticVerifyConsumer : public PathDiagnosticConsumer {
+  ExpectedDiagsTy ExpectedDiags;
+  SourceManager &SM;
+
+public:
+  DiagnosticVerifyConsumer(ExpectedDiagsTy &&ExpectedDiags, SourceManager &SM)
+  : ExpectedDiags(ExpectedDiags), SM(SM) {}
+
+  StringRef getName() const override { return "verify test diagnostics"; }
+
+  void FlushDiagnosticsImpl(std::vector &Diags,
+FilesMade *filesMade) override {
+EXPECT_EQ(Diags.size(), ExpectedDiags.size());
+for (const auto &Item : llvm::enumerate(Diags))
+  if (Item.index() < ExpectedDiags.size())
+ExpectedDiags[Item.index()].testEquality(*Item.value(), SM);
+  }
+};
+
 } // namespace ento
 } // namespace clang
 
Index: clang/unittests/StaticAnalyzer/CMakeLists.txt
===
--- clang/unittests/StaticAnalyzer/CMakeLists.txt
+++ clang/unittests/StaticAnalyzer/CMakeLists.txt
@@ -5,6 +5,7 @@
 
 add_clang_unittest(StaticAnalysisTests
   AnalyzerOptionsTest.cpp
+  BugReportInterestingnessTest.cpp
   CallDescriptionTest.cpp
   CallEventTest.cpp
   FalsePositiveRefutationBRVisitorTest.cpp
Index: clang/unittests/StaticAnalyzer/BugReportInterestingnessTest.cpp
===
--- /dev/null
+++ clang/unittests/StaticAnalyzer/BugReportInterestingnessTest.cpp
@@ -0,0 +1,162 @@
+//===--===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "Reusables.h"
+#inclu

[clang] 41ce5ec - [PowerPC] Remove unnecessary 64-bit guards from altivec.h

2021-07-12 Thread Nemanja Ivanovic via cfe-commits

Author: Nemanja Ivanovic
Date: 2021-07-12T04:59:00-05:00
New Revision: 41ce5ec5f6f3a03d70e0010e3a140fe129800637

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

LOG: [PowerPC] Remove unnecessary 64-bit guards from altivec.h

A number of functions in the header have guards for 64-bit only
that were presumably added as some of the functions in the blocks
use vector __int128 which is only available in 64-bit mode.
A more appropriate guard (__SIZEOF_INT128__) has been added for
those functions since, making the 64-bit guards redundant.
This patch removes those guards as they inadvertently guard code
that uses vector long long which does not actually require 64-bit
mode.

Added: 
clang/test/CodeGen/builtins-ppc-32bit-vec-ll.c

Modified: 
clang/lib/Headers/altivec.h
clang/test/CodeGen/builtins-ppc-quadword-noi128.c

Removed: 




diff  --git a/clang/lib/Headers/altivec.h b/clang/lib/Headers/altivec.h
index 3517da798547a..c916017fad6af 100644
--- a/clang/lib/Headers/altivec.h
+++ b/clang/lib/Headers/altivec.h
@@ -124,7 +124,7 @@ vec_abs(vector signed int __a) {
   return __builtin_altivec_vmaxsw(__a, -__a);
 }
 
-#if defined(__POWER8_VECTOR__) && defined(__powerpc64__)
+#ifdef __POWER8_VECTOR__
 static __inline__ vector signed long long __ATTRS_o_ai
 vec_abs(vector signed long long __a) {
   return __builtin_altivec_vmaxsd(__a, -__a);
@@ -282,7 +282,7 @@ vec_add(vector unsigned int __a, vector bool int __b) {
   return __a + (vector unsigned int)__b;
 }
 
-#if defined(__POWER8_VECTOR__) && defined(__powerpc64__)
+#ifdef __POWER8_VECTOR__
 static __inline__ vector signed long long __ATTRS_o_ai
 vec_add(vector signed long long __a, vector signed long long __b) {
   return __a + __b;
@@ -333,7 +333,7 @@ vec_add(vector unsigned long long __a, vector unsigned long 
long __b) {
   return (vector unsigned long long)vec_add((vector signed long long)__a,
 (vector signed long long)__b);
 }
-#endif // defined(__POWER8_VECTOR__) && defined(__powerpc64__)
+#endif // __POWER8_VECTOR__
 
 static __inline__ vector float __ATTRS_o_ai vec_add(vector float __a,
 vector float __b) {
@@ -349,7 +349,7 @@ static __inline__ vector double __ATTRS_o_ai vec_add(vector 
double __a,
 
 /* vec_adde */
 
-#if defined(__POWER8_VECTOR__) && defined(__powerpc64__)
+#ifdef __POWER8_VECTOR__
 #ifdef __SIZEOF_INT128__
 static __inline__ vector signed __int128 __ATTRS_o_ai
 vec_adde(vector signed __int128 __a, vector signed __int128 __b,
@@ -389,7 +389,7 @@ vec_adde(vector unsigned int __a, vector unsigned int __b,
 
 /* vec_addec */
 
-#if defined(__POWER8_VECTOR__) && defined(__powerpc64__)
+#ifdef __POWER8_VECTOR__
 #ifdef __SIZEOF_INT128__
 static __inline__ vector signed __int128 __ATTRS_o_ai
 vec_addec(vector signed __int128 __a, vector signed __int128 __b,
@@ -410,6 +410,7 @@ vec_addec_u128(vector unsigned char __a, vector unsigned 
char __b,
   return (vector unsigned char)__builtin_altivec_vaddecuq(__a, __b, __c);
 }
 
+#ifdef __powerpc64__
 static __inline__ vector signed int __ATTRS_o_ai
 vec_addec(vector signed int __a, vector signed int __b,
   vector signed int __c) {
@@ -452,8 +453,8 @@ vec_addec(vector unsigned int __a, vector unsigned int __b,
   vector unsigned int ret = { __result[0], __result[1], __result[2], 
__result[3] };
   return ret;
 }
-
-#endif
+#endif // __powerpc64__
+#endif // __POWER8_VECTOR__
 
 /* vec_vaddubm */
 
@@ -579,7 +580,7 @@ vec_addc(vector unsigned int __a, vector unsigned int __b) {
   return __builtin_altivec_vaddcuw(__a, __b);
 }
 
-#if defined(__POWER8_VECTOR__) && defined(__powerpc64__)
+#ifdef __POWER8_VECTOR__
 #ifdef __SIZEOF_INT128__
 static __inline__ vector signed __int128 __ATTRS_o_ai
 vec_addc(vector signed __int128 __a, vector signed __int128 __b) {
@@ -12026,7 +12027,7 @@ vec_subc(vector unsigned int __a, vector unsigned int 
__b) {
   return __builtin_altivec_vsubcuw(__a, __b);
 }
 
-#if defined(__POWER8_VECTOR__) && defined(__powerpc64__)
+#ifdef __POWER8_VECTOR__
 #ifdef __SIZEOF_INT128__
 static __inline__ vector unsigned __int128 __ATTRS_o_ai
 vec_subc(vector unsigned __int128 __a, vector unsigned __int128 __b) {
@@ -12043,7 +12044,7 @@ static __inline__ vector unsigned char 
__attribute__((__always_inline__))
 vec_subc_u128(vector unsigned char __a, vector unsigned char __b) {
   return (vector unsigned char)__builtin_altivec_vsubcuq(__a, __b);
 }
-#endif // defined(__POWER8_VECTOR__) && defined(__powerpc64__)
+#endif // __POWER8_VECTOR__
 
 /* vec_vsubcuw */
 
@@ -12246,7 +12247,7 @@ vec_vsubuws(vector unsigned int __a, vector bool int 
__b) {
   return __builtin_altivec_vsubuws(__a, (vector unsigned int)__b);
 }
 
-#if defined(__POWER8_VECTOR__) && 

[PATCH] D105703: [hwasan] Use stack safety analysis.

2021-07-12 Thread Florian Mayer via Phabricator via cfe-commits
fmayer created this revision.
Herald added subscribers: ormris, hiraditya.
fmayer updated this revision to Diff 357514.
fmayer added a comment.
fmayer edited the summary of this revision.
fmayer updated this revision to Diff 357544.
fmayer edited the summary of this revision.
fmayer updated this revision to Diff 357881.
fmayer edited the summary of this revision.
fmayer published this revision for review.
fmayer added a reviewer: eugenis.
Herald added projects: clang, LLVM.
Herald added subscribers: llvm-commits, cfe-commits.

Change commit message.


fmayer added a comment.

Formatting again.


fmayer added a comment.

Formatting.


This avoids unnecessary instrumentation.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D105703

Files:
  clang/lib/CodeGen/BackendUtil.cpp
  clang/test/CodeGen/hwasan-stack-safety-analysis-asm.c
  clang/test/CodeGen/hwasan-stack-safety-analysis.c
  llvm/include/llvm/Transforms/Instrumentation/HWAddressSanitizer.h
  llvm/lib/Transforms/Instrumentation/HWAddressSanitizer.cpp

Index: llvm/lib/Transforms/Instrumentation/HWAddressSanitizer.cpp
===
--- llvm/lib/Transforms/Instrumentation/HWAddressSanitizer.cpp
+++ llvm/lib/Transforms/Instrumentation/HWAddressSanitizer.cpp
@@ -17,6 +17,7 @@
 #include "llvm/ADT/StringExtras.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/ADT/Triple.h"
+#include "llvm/Analysis/StackSafetyAnalysis.h"
 #include "llvm/BinaryFormat/ELF.h"
 #include "llvm/IR/Attributes.h"
 #include "llvm/IR/BasicBlock.h"
@@ -109,6 +110,10 @@
cl::desc("instrument stack (allocas)"),
cl::Hidden, cl::init(true));
 
+static cl::opt
+ClUseStackSafety("hwasan-use-stack-safety", cl::Hidden, cl::init(true),
+ cl::Hidden, cl::desc("Use Stack Safety analysis results"));
+
 static cl::opt ClUARRetagToZero(
 "hwasan-uar-retag-to-zero",
 cl::desc("Clear alloca tags before returning from the function to allow "
@@ -192,13 +197,31 @@
 
 namespace {
 
+bool shouldUsePageAliases(const Triple &TargetTriple) {
+  return ClUsePageAliases && TargetTriple.getArch() == Triple::x86_64;
+// No one should use the option directly.
+#pragma GCC poison ClUsePageAliases
+}
+
+bool shouldInstrumentStack(const Triple &TargetTriple) {
+  return shouldUsePageAliases(TargetTriple) ? false : ClInstrumentStack;
+// No one should use the option directly.
+#pragma GCC poison ClInstrumentStack
+}
+
+bool shouldUseStackSafetyAnalysis(const Triple &TargetTriple) {
+  return shouldInstrumentStack(TargetTriple) && ClUseStackSafety;
+// No one should use the option directly.
+#pragma GCC poison ClUseStackSafety
+}
 /// An instrumentation pass implementing detection of addressability bugs
 /// using tagged pointers.
 class HWAddressSanitizer {
 public:
   explicit HWAddressSanitizer(Module &M, bool CompileKernel = false,
-  bool Recover = false)
-  : M(M) {
+  bool Recover = false,
+  const StackSafetyGlobalInfo *SSI = nullptr)
+  : M(M), SSI(SSI) {
 this->Recover = ClRecover.getNumOccurrences() > 0 ? ClRecover : Recover;
 this->CompileKernel = ClEnableKhwasan.getNumOccurrences() > 0
   ? ClEnableKhwasan
@@ -207,6 +230,8 @@
 initializeModule();
   }
 
+  void setSSI(const StackSafetyGlobalInfo *S) { SSI = S; }
+
   bool sanitizeFunction(Function &F);
   void initializeModule();
   void createHwasanCtorComdat();
@@ -259,6 +284,7 @@
 private:
   LLVMContext *C;
   Module &M;
+  const StackSafetyGlobalInfo *SSI;
   Triple TargetTriple;
   FunctionCallee HWAsanMemmove, HWAsanMemcpy, HWAsanMemset;
   FunctionCallee HWAsanHandleVfork;
@@ -329,8 +355,10 @@
   static char ID;
 
   explicit HWAddressSanitizerLegacyPass(bool CompileKernel = false,
-bool Recover = false)
-  : FunctionPass(ID), CompileKernel(CompileKernel), Recover(Recover) {
+bool Recover = false,
+Triple TargetTriple = {})
+  : FunctionPass(ID), CompileKernel(CompileKernel), Recover(Recover),
+TargetTriple(TargetTriple) {
 initializeHWAddressSanitizerLegacyPassPass(
 *PassRegistry::getPassRegistry());
   }
@@ -338,11 +366,18 @@
   StringRef getPassName() const override { return "HWAddressSanitizer"; }
 
   bool doInitialization(Module &M) override {
-HWASan = std::make_unique(M, CompileKernel, Recover);
+HWASan = std::make_unique(M, CompileKernel, Recover,
+  /*SSI=*/nullptr);
 return true;
   }
 
   bool runOnFunction(Function &F) override {
+if (shouldUseStackSafetyAnalysis(TargetTriple)) {
+  // We cannot call getAnalysis in doInitialization, that would cause a
+  // crash as the required analyses are not initialized y

[PATCH] D104536: WIP: [clang][deps] Avoid minimizing PCH input files

2021-07-12 Thread Jan Svoboda via Phabricator via cfe-commits
jansvoboda11 added a comment.

I run a quick benchmark where an empty TU is configured with an explicitly 
built PCH that imports Cocoa. Dependency scanning without minimization takes 
226 ms, with this patch 303 ms and 325 ms when padding minimized files to the 
original size. Since we'll eventually switch to a more sound implementation, 
I'm fine with this in the meantime.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D104536

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


[PATCH] D105754: [PowerPC] Fix L[D|W]ARX Implementation

2021-07-12 Thread Albion Fung via Phabricator via cfe-commits
Conanap updated this revision to Diff 357832.
Conanap marked 6 inline comments as done.
Conanap added a comment.
Herald added subscribers: frasercrmck, luismarques, apazos, sameer.abuasal, 
s.egerton, Jim, jocewei, PkmX, the_o, brucehoult, MartinMosbeck, rogfer01, 
edward-jones, zzheng, MaskRay, jrtc27, niosHD, sabuasal, simoncook, johnrusso, 
rbar, asb.

Moved implementation to a more appropriate function,
updated test cases.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105754

Files:
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vadd.c
  clang/test/CodeGen/builtins-ppc-xlcompat-LoadReseve-StoreCond-64bit-only.c
  clang/test/CodeGen/builtins-ppc-xlcompat-LoadReseve-StoreCond.c
  llvm/include/llvm/IR/IntrinsicsPowerPC.td
  llvm/lib/Target/PowerPC/PPCInstr64Bit.td
  llvm/lib/Target/PowerPC/PPCInstrInfo.td
  
llvm/test/CodeGen/PowerPC/builtins-ppc-xlcompat-LoadReserve-StoreCond-64bit-only.ll
  llvm/test/CodeGen/PowerPC/builtins-ppc-xlcompat-LoadReserve-StoreCond.ll

Index: llvm/test/CodeGen/PowerPC/builtins-ppc-xlcompat-LoadReserve-StoreCond.ll
===
--- llvm/test/CodeGen/PowerPC/builtins-ppc-xlcompat-LoadReserve-StoreCond.ll
+++ llvm/test/CodeGen/PowerPC/builtins-ppc-xlcompat-LoadReserve-StoreCond.ll
@@ -12,18 +12,21 @@
 define dso_local signext i32 @test_lwarx(i32* readnone %a) {
 ; CHECK-64-LABEL: test_lwarx:
 ; CHECK-64:   # %bb.0: # %entry
+; CHECK-64-NEXT:#APP
 ; CHECK-64-NEXT:lwarx 3, 0, 3
+; CHECK-64-NEXT:#NO_APP
 ; CHECK-64-NEXT:extsw 3, 3
 ; CHECK-64-NEXT:blr
 ;
 ; CHECK-32-LABEL: test_lwarx:
 ; CHECK-32:   # %bb.0: # %entry
+; CHECK-32-NEXT:#APP
 ; CHECK-32-NEXT:lwarx 3, 0, 3
+; CHECK-32-NEXT:#NO_APP
 ; CHECK-32-NEXT:blr
 entry:
-  %0 = bitcast i32* %a to i8*
-  %1 = tail call i32 @llvm.ppc.lwarx(i8* %0)
-  ret i32 %1
+  %0 = call i32 asm sideeffect "lwarx $0, $1", "=r,*Z,~{memory}"(i32* %a)
+  ret i32 %0
 }
 
 declare i32 @llvm.ppc.stwcx(i8*, i32)
Index: llvm/test/CodeGen/PowerPC/builtins-ppc-xlcompat-LoadReserve-StoreCond-64bit-only.ll
===
--- llvm/test/CodeGen/PowerPC/builtins-ppc-xlcompat-LoadReserve-StoreCond-64bit-only.ll
+++ llvm/test/CodeGen/PowerPC/builtins-ppc-xlcompat-LoadReserve-StoreCond-64bit-only.ll
@@ -10,17 +10,18 @@
 define dso_local i64 @test_ldarx(i64* readnone %a) {
 ; CHECK-LABEL: test_ldarx:
 ; CHECK:   # %bb.0: # %entry
+; CHECK-NEXT:#APP
 ; CHECK-NEXT:ldarx 3, 0, 3
+; CHECK-NEXT:#NO_APP
 ; CHECK-NEXT:blr
 entry:
-  %0 = bitcast i64* %a to i8*
-  %1 = tail call i64 @llvm.ppc.ldarx(i8* %0)
-  ret i64 %1
+  %0 = call i64 asm sideeffect "ldarx $0, $1", "=r,*Z,~{memory}"(i64* %a)
+  ret i64 %0
 }
 
 declare i32 @llvm.ppc.stdcx(i8*, i64)
-define dso_local i64 @test(i64* %a, i64 %b) {
-; CHECK-LABEL: test:
+define dso_local i64 @test_stdcx(i64* %a, i64 %b) {
+; CHECK-LABEL: test_stdcx:
 ; CHECK:   # %bb.0: # %entry
 ; CHECK-NEXT:stdcx. 4, 0, 3
 ; CHECK-NEXT:mfocrf 3, 128
Index: llvm/lib/Target/PowerPC/PPCInstrInfo.td
===
--- llvm/lib/Target/PowerPC/PPCInstrInfo.td
+++ llvm/lib/Target/PowerPC/PPCInstrInfo.td
@@ -5412,7 +5412,5 @@
 def : Pat<(i64 (bitreverse i64:$A)),
   (OR8 (RLDICR DWBytes7654.DWord, 32, 31), DWBytes3210.DWord)>;
 
-def : Pat<(int_ppc_lwarx ForceXForm:$dst),
-  (LWARX ForceXForm:$dst)>;
 def : Pat<(int_ppc_stwcx ForceXForm:$dst, gprc:$A),
   (STWCX gprc:$A, ForceXForm:$dst)>;
Index: llvm/lib/Target/PowerPC/PPCInstr64Bit.td
===
--- llvm/lib/Target/PowerPC/PPCInstr64Bit.td
+++ llvm/lib/Target/PowerPC/PPCInstr64Bit.td
@@ -1723,5 +1723,3 @@
 
 def : Pat<(int_ppc_stdcx ForceXForm:$dst, g8rc:$A),
   (STDCX g8rc:$A, ForceXForm:$dst)>;
-def : Pat<(int_ppc_ldarx ForceXForm:$dst),
-  (LDARX ForceXForm:$dst)>;
Index: llvm/include/llvm/IR/IntrinsicsPowerPC.td
===
--- llvm/include/llvm/IR/IntrinsicsPowerPC.td
+++ llvm/include/llvm/IR/IntrinsicsPowerPC.td
@@ -1529,9 +1529,5 @@
   def int_ppc_stwcx : GCCBuiltin<"__builtin_ppc_stwcx">,
   Intrinsic<[llvm_i32_ty], [llvm_ptr_ty, llvm_i32_ty],
 [IntrWriteMem]>;
-  def int_ppc_lwarx : GCCBuiltin<"__builtin_ppc_lwarx">,
-  Intrinsic<[llvm_i32_ty], [llvm_ptr_ty], [IntrNoMem]>;
-  def int_ppc_ldarx : GCCBuiltin<"__builtin_ppc_ldarx">,
-  Intrinsic<[llvm_i64_ty], [llvm_ptr_ty], [IntrNoMem]>;
 }
 
Index: clang/test/CodeGen/builtins-ppc-xlcompat-LoadReseve-StoreCond.c
===
--- clang/test/CodeGen/builtins-ppc-xlcompat-LoadReseve-StoreCond.c
+

[PATCH] D105754: [PowerPC] Fix L[D|W]ARX Implementation

2021-07-12 Thread Albion Fung via Phabricator via cfe-commits
Conanap updated this revision to Diff 357833.
Conanap added a comment.

Removed unintended change


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105754

Files:
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/test/CodeGen/builtins-ppc-xlcompat-LoadReseve-StoreCond-64bit-only.c
  clang/test/CodeGen/builtins-ppc-xlcompat-LoadReseve-StoreCond.c
  llvm/include/llvm/IR/IntrinsicsPowerPC.td
  llvm/lib/Target/PowerPC/PPCInstr64Bit.td
  llvm/lib/Target/PowerPC/PPCInstrInfo.td
  
llvm/test/CodeGen/PowerPC/builtins-ppc-xlcompat-LoadReserve-StoreCond-64bit-only.ll
  llvm/test/CodeGen/PowerPC/builtins-ppc-xlcompat-LoadReserve-StoreCond.ll

Index: llvm/test/CodeGen/PowerPC/builtins-ppc-xlcompat-LoadReserve-StoreCond.ll
===
--- llvm/test/CodeGen/PowerPC/builtins-ppc-xlcompat-LoadReserve-StoreCond.ll
+++ llvm/test/CodeGen/PowerPC/builtins-ppc-xlcompat-LoadReserve-StoreCond.ll
@@ -12,18 +12,21 @@
 define dso_local signext i32 @test_lwarx(i32* readnone %a) {
 ; CHECK-64-LABEL: test_lwarx:
 ; CHECK-64:   # %bb.0: # %entry
+; CHECK-64-NEXT:#APP
 ; CHECK-64-NEXT:lwarx 3, 0, 3
+; CHECK-64-NEXT:#NO_APP
 ; CHECK-64-NEXT:extsw 3, 3
 ; CHECK-64-NEXT:blr
 ;
 ; CHECK-32-LABEL: test_lwarx:
 ; CHECK-32:   # %bb.0: # %entry
+; CHECK-32-NEXT:#APP
 ; CHECK-32-NEXT:lwarx 3, 0, 3
+; CHECK-32-NEXT:#NO_APP
 ; CHECK-32-NEXT:blr
 entry:
-  %0 = bitcast i32* %a to i8*
-  %1 = tail call i32 @llvm.ppc.lwarx(i8* %0)
-  ret i32 %1
+  %0 = call i32 asm sideeffect "lwarx $0, $1", "=r,*Z,~{memory}"(i32* %a)
+  ret i32 %0
 }
 
 declare i32 @llvm.ppc.stwcx(i8*, i32)
Index: llvm/test/CodeGen/PowerPC/builtins-ppc-xlcompat-LoadReserve-StoreCond-64bit-only.ll
===
--- llvm/test/CodeGen/PowerPC/builtins-ppc-xlcompat-LoadReserve-StoreCond-64bit-only.ll
+++ llvm/test/CodeGen/PowerPC/builtins-ppc-xlcompat-LoadReserve-StoreCond-64bit-only.ll
@@ -10,17 +10,18 @@
 define dso_local i64 @test_ldarx(i64* readnone %a) {
 ; CHECK-LABEL: test_ldarx:
 ; CHECK:   # %bb.0: # %entry
+; CHECK-NEXT:#APP
 ; CHECK-NEXT:ldarx 3, 0, 3
+; CHECK-NEXT:#NO_APP
 ; CHECK-NEXT:blr
 entry:
-  %0 = bitcast i64* %a to i8*
-  %1 = tail call i64 @llvm.ppc.ldarx(i8* %0)
-  ret i64 %1
+  %0 = call i64 asm sideeffect "ldarx $0, $1", "=r,*Z,~{memory}"(i64* %a)
+  ret i64 %0
 }
 
 declare i32 @llvm.ppc.stdcx(i8*, i64)
-define dso_local i64 @test(i64* %a, i64 %b) {
-; CHECK-LABEL: test:
+define dso_local i64 @test_stdcx(i64* %a, i64 %b) {
+; CHECK-LABEL: test_stdcx:
 ; CHECK:   # %bb.0: # %entry
 ; CHECK-NEXT:stdcx. 4, 0, 3
 ; CHECK-NEXT:mfocrf 3, 128
Index: llvm/lib/Target/PowerPC/PPCInstrInfo.td
===
--- llvm/lib/Target/PowerPC/PPCInstrInfo.td
+++ llvm/lib/Target/PowerPC/PPCInstrInfo.td
@@ -5412,7 +5412,5 @@
 def : Pat<(i64 (bitreverse i64:$A)),
   (OR8 (RLDICR DWBytes7654.DWord, 32, 31), DWBytes3210.DWord)>;
 
-def : Pat<(int_ppc_lwarx ForceXForm:$dst),
-  (LWARX ForceXForm:$dst)>;
 def : Pat<(int_ppc_stwcx ForceXForm:$dst, gprc:$A),
   (STWCX gprc:$A, ForceXForm:$dst)>;
Index: llvm/lib/Target/PowerPC/PPCInstr64Bit.td
===
--- llvm/lib/Target/PowerPC/PPCInstr64Bit.td
+++ llvm/lib/Target/PowerPC/PPCInstr64Bit.td
@@ -1723,5 +1723,3 @@
 
 def : Pat<(int_ppc_stdcx ForceXForm:$dst, g8rc:$A),
   (STDCX g8rc:$A, ForceXForm:$dst)>;
-def : Pat<(int_ppc_ldarx ForceXForm:$dst),
-  (LDARX ForceXForm:$dst)>;
Index: llvm/include/llvm/IR/IntrinsicsPowerPC.td
===
--- llvm/include/llvm/IR/IntrinsicsPowerPC.td
+++ llvm/include/llvm/IR/IntrinsicsPowerPC.td
@@ -1529,9 +1529,5 @@
   def int_ppc_stwcx : GCCBuiltin<"__builtin_ppc_stwcx">,
   Intrinsic<[llvm_i32_ty], [llvm_ptr_ty, llvm_i32_ty],
 [IntrWriteMem]>;
-  def int_ppc_lwarx : GCCBuiltin<"__builtin_ppc_lwarx">,
-  Intrinsic<[llvm_i32_ty], [llvm_ptr_ty], [IntrNoMem]>;
-  def int_ppc_ldarx : GCCBuiltin<"__builtin_ppc_ldarx">,
-  Intrinsic<[llvm_i64_ty], [llvm_ptr_ty], [IntrNoMem]>;
 }
 
Index: clang/test/CodeGen/builtins-ppc-xlcompat-LoadReseve-StoreCond.c
===
--- clang/test/CodeGen/builtins-ppc-xlcompat-LoadReseve-StoreCond.c
+++ clang/test/CodeGen/builtins-ppc-xlcompat-LoadReseve-StoreCond.c
@@ -1,22 +1,20 @@
-// RUN: %clang_cc1 -triple=powerpc-unknown-aix -emit-llvm %s -o - | \
+// RUN: %clang_cc1 -O2 -triple=powerpc-unknown-aix -emit-llvm %s -o - | \
 // RUN: FileCheck %s
-// RUN: %clang_cc1 -triple=powerpc64-unknown-aix -emit-llvm %s -o - | \
+// RUN: %clang_cc1 -O2 -triple=powerpc64-unknown-aix -emit-llvm %s

[clang] de59f56 - [OpenMP] Support OpenMP 5.1 attributes

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

Author: Aaron Ballman
Date: 2021-07-12T06:51:19-04:00
New Revision: de59f564400de1b0fe30ae07f3c800562a025e27

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

LOG: [OpenMP] Support OpenMP 5.1 attributes

OpenMP 5.1 added support for writing OpenMP directives using [[]]
syntax in addition to using #pragma and this introduces support for the
new syntax.

In OpenMP, the attributes take one of two forms:
[[omp::directive(...)]] or [[omp::sequence(...)]]. A directive
attribute contains an OpenMP directive clause that is identical to the
analogous #pragma syntax. A sequence attribute can contain either
sequence or directive arguments and is used to ensure that the
attributes are processed sequentially for situations where the order of
the attributes matter (remember:
https://eel.is/c++draft/dcl.attr.grammar#4.sentence-4).

The approach taken here is somewhat novel and deserves mention. We
could refactor much of the OpenMP parsing logic to work for either
pragma annotation tokens or for attribute clauses. It would be a fair
amount of effort to share the logic for both, but it's certainly
doable. However, the semantic attribute system is not designed to
handle the arbitrarily complex arguments that OpenMP directives
contain. Adding support to thread the novel parsed information until we
can produce a semantic attribute would be considerably more effort.
What's more, existing OpenMP constructs are not (often) represented as
semantic attributes. So doing this through Attr.td would be a massive
undertaking that would likely only benefit OpenMP and comes with
additional risks. Rather than walk down that path, I am taking
advantage of the fact that the syntax of the directives within the
directive clause is identical to that of the #pragma form. Once the
parser recognizes that we're processing an OpenMP attribute, it caches
all of the directive argument tokens and then replays them as though
the user wrote a pragma. This reuses the same OpenMP parsing and
semantic logic directly, but does come with a risk if the OpenMP
committee decides to purposefully diverge their pragma and attribute
syntaxes. So, despite this being a novel approach that does token
replay, I think it's actually a better approach than trying to do this
through the declarative syntax in Attr.td.

Added: 
clang/test/OpenMP/allocate_codegen_attr.cpp
clang/test/OpenMP/assumes_messages_attr.c
clang/test/OpenMP/critical_codegen_attr.cpp
clang/test/OpenMP/masked_messages_attr.cpp
clang/test/OpenMP/openmp_attribute.cpp
clang/test/OpenMP/openmp_attribute_compat.cpp
clang/test/OpenMP/openmp_attribute_parsing.cpp
clang/test/OpenMP/target_map_names_attr.cpp
clang/test/OpenMP/taskloop_reduction_messages_attr.cpp

clang/test/OpenMP/teams_distribute_parallel_for_simd_num_teams_messages_attr.cpp
clang/test/OpenMP/unroll_codegen_unroll_for_attr.cpp

Modified: 
clang/docs/OpenMPSupport.rst
clang/include/clang/Basic/DiagnosticGroups.td
clang/include/clang/Basic/DiagnosticParseKinds.td
clang/include/clang/Basic/TokenKinds.def
clang/include/clang/Parse/Parser.h
clang/lib/Basic/Attributes.cpp
clang/lib/Parse/ParseCXXInlineMethods.cpp
clang/lib/Parse/ParseDecl.cpp
clang/lib/Parse/ParseDeclCXX.cpp
clang/lib/Parse/ParseOpenMP.cpp
clang/lib/Parse/ParseStmt.cpp
clang/lib/Parse/Parser.cpp

Removed: 




diff  --git a/clang/docs/OpenMPSupport.rst b/clang/docs/OpenMPSupport.rst
index 3bd1a0c211486..88d3107c21e7a 100644
--- a/clang/docs/OpenMPSupport.rst
+++ b/clang/docs/OpenMPSupport.rst
@@ -268,7 +268,7 @@ want to help with the implementation.
 
+--+--+--+---+
 | atomic extension | 'fail' clause on atomic construct 
   | :none:`unclaimed`| 
  |
 
+--+--+--+---+
-| base language| C++ attribute specifier syntax
   | :part:`worked on`| 
  |
+| base language| C++ attribute specifier syntax
   | :good:`done` | D105648 
  |
 
+--+--+--+--

[PATCH] D105648: [OpenMP] Support OpenMP 5.1 attributes

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

Thank you for the reviews, everyone. I've commit in 
de59f564400de1b0fe30ae07f3c800562a025e27 
.


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

https://reviews.llvm.org/D105648

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


[PATCH] D105629: [TSan] Add SystemZ support

2021-07-12 Thread Ilya Leoshkevich via Phabricator via cfe-commits
iii updated this revision to Diff 357889.
iii added a comment.

- Fix a local variable naming issue CheckAndProtect().


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105629

Files:
  clang/lib/Driver/ToolChains/Linux.cpp
  compiler-rt/cmake/config-ix.cmake
  compiler-rt/lib/sanitizer_common/sanitizer_common_interceptors.inc
  compiler-rt/lib/sanitizer_common/sanitizer_linux.cpp
  compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.h
  compiler-rt/lib/tsan/CMakeLists.txt
  compiler-rt/lib/tsan/rtl/tsan_interceptors_posix.cpp
  compiler-rt/lib/tsan/rtl/tsan_interface.h
  compiler-rt/lib/tsan/rtl/tsan_platform.h
  compiler-rt/lib/tsan/rtl/tsan_platform_linux.cpp
  compiler-rt/lib/tsan/rtl/tsan_platform_posix.cpp
  compiler-rt/lib/tsan/rtl/tsan_rtl_s390x.S
  compiler-rt/test/tsan/ignore_lib0.cpp
  compiler-rt/test/tsan/ignore_lib1.cpp
  compiler-rt/test/tsan/ignore_lib5.cpp
  compiler-rt/test/tsan/map32bit.cpp
  compiler-rt/test/tsan/mmap_large.cpp
  llvm/lib/Transforms/Instrumentation/ThreadSanitizer.cpp
  llvm/utils/gn/secondary/compiler-rt/lib/tsan/BUILD.gn

Index: llvm/utils/gn/secondary/compiler-rt/lib/tsan/BUILD.gn
===
--- llvm/utils/gn/secondary/compiler-rt/lib/tsan/BUILD.gn
+++ llvm/utils/gn/secondary/compiler-rt/lib/tsan/BUILD.gn
@@ -125,6 +125,8 @@
 sources += [ "rtl/tsan_rtl_ppc64.S" ]
   } else if (target_cpu == "mips64") {
 sources += [ "rtl/tsan_rtl_mips64.S" ]
+  } else if (target_cpu == "s390x") {
+sources += [ "rtl/tsan_rtl_s390x.S" ]
   }
 
   # To be able to include sanitizer_common.
Index: llvm/lib/Transforms/Instrumentation/ThreadSanitizer.cpp
===
--- llvm/lib/Transforms/Instrumentation/ThreadSanitizer.cpp
+++ llvm/lib/Transforms/Instrumentation/ThreadSanitizer.cpp
@@ -311,12 +311,21 @@
 Type *Ty = Type::getIntNTy(M.getContext(), BitSize);
 Type *PtrTy = Ty->getPointerTo();
 SmallString<32> AtomicLoadName("__tsan_atomic" + BitSizeStr + "_load");
-TsanAtomicLoad[i] =
-M.getOrInsertFunction(AtomicLoadName, Attr, Ty, PtrTy, OrdTy);
+{
+  AttributeList AL = Attr;
+  AL = AL.addParamAttribute(M.getContext(), 1, Attribute::ZExt);
+  TsanAtomicLoad[i] =
+  M.getOrInsertFunction(AtomicLoadName, AL, Ty, PtrTy, OrdTy);
+}
 
 SmallString<32> AtomicStoreName("__tsan_atomic" + BitSizeStr + "_store");
-TsanAtomicStore[i] = M.getOrInsertFunction(
-AtomicStoreName, Attr, IRB.getVoidTy(), PtrTy, Ty, OrdTy);
+{
+  AttributeList AL = Attr;
+  AL = AL.addParamAttribute(M.getContext(), 1, Attribute::ZExt);
+  AL = AL.addParamAttribute(M.getContext(), 2, Attribute::ZExt);
+  TsanAtomicStore[i] = M.getOrInsertFunction(
+  AtomicStoreName, AL, IRB.getVoidTy(), PtrTy, Ty, OrdTy);
+}
 
 for (unsigned Op = AtomicRMWInst::FIRST_BINOP;
  Op <= AtomicRMWInst::LAST_BINOP; ++Op) {
@@ -339,24 +348,44 @@
   else
 continue;
   SmallString<32> RMWName("__tsan_atomic" + itostr(BitSize) + NamePart);
-  TsanAtomicRMW[Op][i] =
-  M.getOrInsertFunction(RMWName, Attr, Ty, PtrTy, Ty, OrdTy);
+  {
+AttributeList AL = Attr;
+AL = AL.addParamAttribute(M.getContext(), 1, Attribute::ZExt);
+AL = AL.addParamAttribute(M.getContext(), 2, Attribute::ZExt);
+TsanAtomicRMW[Op][i] =
+M.getOrInsertFunction(RMWName, AL, Ty, PtrTy, Ty, OrdTy);
+  }
 }
 
 SmallString<32> AtomicCASName("__tsan_atomic" + BitSizeStr +
   "_compare_exchange_val");
-TsanAtomicCAS[i] = M.getOrInsertFunction(AtomicCASName, Attr, Ty, PtrTy, Ty,
- Ty, OrdTy, OrdTy);
+{
+  AttributeList AL = Attr;
+  AL = AL.addParamAttribute(M.getContext(), 1, Attribute::ZExt);
+  AL = AL.addParamAttribute(M.getContext(), 2, Attribute::ZExt);
+  AL = AL.addParamAttribute(M.getContext(), 3, Attribute::ZExt);
+  AL = AL.addParamAttribute(M.getContext(), 4, Attribute::ZExt);
+  TsanAtomicCAS[i] = M.getOrInsertFunction(AtomicCASName, AL, Ty, PtrTy, Ty,
+   Ty, OrdTy, OrdTy);
+}
   }
   TsanVptrUpdate =
   M.getOrInsertFunction("__tsan_vptr_update", Attr, IRB.getVoidTy(),
 IRB.getInt8PtrTy(), IRB.getInt8PtrTy());
   TsanVptrLoad = M.getOrInsertFunction("__tsan_vptr_read", Attr,
IRB.getVoidTy(), IRB.getInt8PtrTy());
-  TsanAtomicThreadFence = M.getOrInsertFunction("__tsan_atomic_thread_fence",
-Attr, IRB.getVoidTy(), OrdTy);
-  TsanAtomicSignalFence = M.getOrInsertFunction("__tsan_atomic_signal_fence",
-Attr, IRB.getVoidTy(), OrdTy);
+  {
+At

[PATCH] D105629: [TSan] Add SystemZ support

2021-07-12 Thread Ilya Leoshkevich via Phabricator via cfe-commits
iii marked an inline comment as done.
iii added inline comments.



Comment at: compiler-rt/lib/tsan/rtl/tsan_interceptors_posix.cpp:781
+  // TSAN. Act as if we ran out of memory.
+  internal_munmap(res, sz);
+  errno = errno_ENOMEM;

dvyukov wrote:
> TSan runtime is supposed to mprotect all ranges that are inaccessible to the 
> application. How does it happen that kernel still returns such an address? Do 
> we fail to mprotect all ranges on s390? If so should that be fixed instead?
> I am concerned that if kernel can return unsupported addresses, it probably 
> can returns them very early before exhausting all supported addresses (e.g. 
> always return unsupported from the start).
> Or is it that we mprotect everything, but kernel still somehow stomps on it? 
> If so can this address overlap with, say, tsan shadow? If yes, them the 
> munmap will unmap our shadow which is not good.
The common code in CheckAndProtect() didn't mprotect the address space "tail" - 
I've added a special case for that.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105629

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


[PATCH] D105526: opencl-c.h: CL3.0 generic address space

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

In D105526#2863386 , @airlied wrote:

> I've dropped the __SPIR__ change in the base header until things are resolved 
> for library SPIR users to disable extension defines.

Makes sense! But this is not a full diff again. Would it be possible to 
reupload it?


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

https://reviews.llvm.org/D105526

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


[PATCH] D105601: opencl-c.h: reorder atomic operations

2021-07-12 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia accepted this revision.
Anastasia added a comment.
This revision is now accepted and ready to land.

LGTM! Thanks


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105601

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


[PATCH] D105601: opencl-c.h: reorder atomic operations

2021-07-12 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia added subscribers: azabaznov, svenvh.
Anastasia added a comment.

CC to @svenvh and @azabaznov.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105601

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


[clang] 84e4296 - [PowerPC] Fix rounding mode for vec_round in altivec.h

2021-07-12 Thread Nemanja Ivanovic via cfe-commits

Author: Nemanja Ivanovic
Date: 2021-07-12T06:11:27-05:00
New Revision: 84e429693fe5f225fe68b9dd54043cddb9c4cd4c

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

LOG: [PowerPC] Fix rounding mode for vec_round in altivec.h

The function is supposed to be the equivalent of rint() (as in
round to nearest, ties to even) rather than round() (round to
nearest, ties away from zero). In fact, the instruction we emit
without VSX is vrfin which is correct. However, with VSX we emit
xvrspi which is the equivalent of round() and therefore incorrect.
Since there is no equivalent VSX instruction, simply use vrfin
regardless of availability of VSX.

Added: 


Modified: 
clang/lib/Headers/altivec.h
clang/test/CodeGen/builtins-ppc-vsx.c

Removed: 




diff  --git a/clang/lib/Headers/altivec.h b/clang/lib/Headers/altivec.h
index c916017fad6a..35dde8203b7f 100644
--- a/clang/lib/Headers/altivec.h
+++ b/clang/lib/Headers/altivec.h
@@ -8386,11 +8386,7 @@ vec_vrlw(vector unsigned int __a, vector unsigned int 
__b) {
 /* vec_round */
 
 static __inline__ vector float __ATTRS_o_ai vec_round(vector float __a) {
-#ifdef __VSX__
-  return __builtin_vsx_xvrspi(__a);
-#else
   return __builtin_altivec_vrfin(__a);
-#endif
 }
 
 #ifdef __VSX__

diff  --git a/clang/test/CodeGen/builtins-ppc-vsx.c 
b/clang/test/CodeGen/builtins-ppc-vsx.c
index b5ddd03722ad..e1341dc589c5 100644
--- a/clang/test/CodeGen/builtins-ppc-vsx.c
+++ b/clang/test/CodeGen/builtins-ppc-vsx.c
@@ -407,8 +407,8 @@ void test1() {
 // CHECK-LE: call <4 x i32> @llvm.ppc.altivec.vperm(<4 x i32> [[T1]], <4 x 
i32> [[T2]], <16 x i8>
 
   res_vf = vec_round(vf);
-// CHECK: call <4 x float> @llvm.round.v4f32(<4 x float>
-// CHECK-LE: call <4 x float> @llvm.round.v4f32(<4 x float>
+// CHECK: call <4 x float> @llvm.ppc.altivec.vrfin(<4 x float>
+// CHECK-LE: call <4 x float> @llvm.ppc.altivec.vrfin(<4 x float>
 
   res_vd = vec_round(vd);
 // CHECK: call <2 x double> @llvm.round.v2f64(<2 x double>



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


[PATCH] D104915: [OpenCL] Add support of __opencl_c_read_write_images feature macro

2021-07-12 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia accepted this revision.
Anastasia added a comment.
This revision is now accepted and ready to land.

LGTM! Thanks


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D104915

___
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-12 Thread Steffen Larsen via Phabricator via cfe-commits
steffenlarsen added a comment.

Sorry for the late response. Looks like you have handled the issues and more in 
your patch. Thank you for fixing my blunders. 😄




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))

tra wrote:
> 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. :-) 
Haha, I didn't think of that one. Sadly we don't have any plans to work on 
extending support for PTX 7.1+ in the next couple of months, but it looks like 
your new patch (D105384) takes care of it anyway. 😆 



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:
> 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.
> 
> 
> 
Yeah, it was definitely confusing to write. I think the current state is the 
best solution, as it prioritizes consistency within the sub-projects. Not a big 
fan of the inconsistency though, but if we want to follow CUDA's example I 
suppose we're stuck with this.



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"]))

tra wrote:
> 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.
You are absolutely right. That's a mistake on my part. Looks like you've got it 
under control in your patch. Thanks!


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] D103401: [OpenCL] Add support of __opencl_c_generic_address_space feature macro

2021-07-12 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia accepted this revision.
Anastasia added a comment.
This revision is now accepted and ready to land.

LGTM! Thanks


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D103401

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


[clang] f042e0a - Fix the Clang documentation builder; NFC.

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

Author: Aaron Ballman
Date: 2021-07-12T07:59:18-04:00
New Revision: f042e0a0f88391c611002e55afec5c37604b5819

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

LOG: Fix the Clang documentation builder; NFC.

It was broken three days ago by the changes in D95561.

Added: 


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

Removed: 




diff  --git a/clang/include/clang/Basic/AttrDocs.td 
b/clang/include/clang/Basic/AttrDocs.td
index 0a665fee7686..c265a877e3b1 100644
--- a/clang/include/clang/Basic/AttrDocs.td
+++ b/clang/include/clang/Basic/AttrDocs.td
@@ -4550,11 +4550,14 @@ provided it declares the right formal arguments.
 
 In most respects, this is similar to the ``swiftcall`` attribute, except for
 the following:
+
 - A parameter may be marked ``swift_async_context``, ``swift_context``
   or ``swift_indirect_result`` (with the same restrictions on parameter
   ordering as ``swiftcall``) but the parameter attribute
   ``swift_error_result`` is not permitted.
+
 - A ``swiftasynccall`` function must have return type ``void``.
+
 - Within a ``swiftasynccall`` function, a call to a ``swiftasynccall``
   function that is the immediate operand of a ``return`` statement is
   guaranteed to be performed as a tail call. This syntax is allowed even



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


[PATCH] D104975: Implement P1949

2021-07-12 Thread Corentin Jabot via Phabricator via cfe-commits
cor3ntin added inline comments.



Comment at: clang/lib/Lex/UnicodeCharSets.h:229
+static const llvm::sys::UnicodeCharRange XIDContinueRanges[] = {
+{0x0030, 0x0039},   {0x005F, 0x005F},   {0x00B7, 0x00B7},
+{0x0300, 0x036F},   {0x0387, 0x0387},   {0x0483, 0x0487},

Quuxplusone wrote:
> Ah, here we go. `0x005F` is underscore. It should be in the XIDStart table 
> instead.
These tables should match the Unicode spec exactly.
Unicode does not consider `_` to be valid at the start of an identifier.
C++ does, for obvious reasons, but these tables do not represent the C++ 
grammar, but the Unicode Spec.
(Hence the names, `XIDContinue`)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D104975

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


[clang] 8747234 - Partially implement P1401R5 (Narrowing contextual conversions to bool)

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

Author: Corentin Jabot
Date: 2021-07-12T08:06:27-04:00
New Revision: 8747234032c9c6270a6198ab3cca14ce2bd18721

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

LOG: Partially implement P1401R5 (Narrowing contextual conversions to bool)

Support Narrowing conversions to bool in if constexpr condition
under C++23 language mode.

Only if constexpr is implemented as the behavior of static_assert
is already conforming. Still need to work on explicit(bool) to
complete support.

Added: 


Modified: 
clang/include/clang/Basic/DiagnosticSemaKinds.td
clang/include/clang/Sema/Sema.h
clang/lib/Sema/SemaExprCXX.cpp
clang/lib/Sema/SemaOverload.cpp
clang/test/CXX/stmt.stmt/stmt.select/stmt.if/p2.cpp
clang/test/SemaCXX/static-assert.cpp
clang/www/cxx_status.html

Removed: 




diff  --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td 
b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index c8d848b41d353..21b9ce2d9ff2a 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -82,11 +82,11 @@ def err_typecheck_converted_constant_expression_indirect : 
Error<
   "bind reference to a temporary">;
 def err_expr_not_cce : Error<
   "%select{case value|enumerator value|non-type template argument|"
-  "array size|constexpr if condition|explicit specifier argument}0 "
+  "array size|explicit specifier argument}0 "
   "is not a constant expression">;
 def ext_cce_narrowing : ExtWarn<
   "%select{case value|enumerator value|non-type template argument|"
-  "array size|constexpr if condition|explicit specifier argument}0 "
+  "array size|explicit specifier argument}0 "
   "%select{cannot be narrowed from type %2 to %3|"
   "evaluates to %2, which cannot be narrowed to type %3}1">,
   InGroup, DefaultError, SFINAEFailure;
@@ -1487,6 +1487,8 @@ def err_messaging_class_with_direct_method : Error<
 // C++ declarations
 def err_static_assert_expression_is_not_constant : Error<
   "static_assert expression is not an integral constant expression">;
+def err_constexpr_if_condition_expression_is_not_constant : Error<
+  "constexpr if condition is not a constant expression">;
 def err_static_assert_failed : Error<"static_assert failed%select{ %1|}0">;
 def err_static_assert_requirement_failed : Error<
   "static_assert failed due to requirement '%0'%select{ %2|}1">;

diff  --git a/clang/include/clang/Sema/Sema.h b/clang/include/clang/Sema/Sema.h
index ad987dffac03a..e1dac7db1b4ce 100644
--- a/clang/include/clang/Sema/Sema.h
+++ b/clang/include/clang/Sema/Sema.h
@@ -3503,7 +3503,6 @@ class Sema final {
 CCEK_Enumerator,  ///< Enumerator value with fixed underlying type.
 CCEK_TemplateArg, ///< Value of a non-type template parameter.
 CCEK_ArrayBound,  ///< Array bound in array declarator or new-expression.
-CCEK_ConstexprIf, ///< Condition in a constexpr if statement.
 CCEK_ExplicitBool ///< Condition in an explicit(bool) specifier.
   };
   ExprResult CheckConvertedConstantExpression(Expr *From, QualType T,

diff  --git a/clang/lib/Sema/SemaExprCXX.cpp b/clang/lib/Sema/SemaExprCXX.cpp
index e6bf5c6a7ad86..bf0b8b71d9315 100644
--- a/clang/lib/Sema/SemaExprCXX.cpp
+++ b/clang/lib/Sema/SemaExprCXX.cpp
@@ -3911,7 +3911,7 @@ ExprResult Sema::CheckConditionVariable(VarDecl 
*ConditionVar,
 
 /// CheckCXXBooleanCondition - Returns true if a conversion to bool is invalid.
 ExprResult Sema::CheckCXXBooleanCondition(Expr *CondExpr, bool IsConstexpr) {
-  // C++ 6.4p4:
+  // C++11 6.4p4:
   // The value of a condition that is an initialized declaration in a statement
   // other than a switch statement is the value of the declared variable
   // implicitly converted to type bool. If that conversion is ill-formed, the
@@ -3919,12 +3919,22 @@ ExprResult Sema::CheckCXXBooleanCondition(Expr 
*CondExpr, bool IsConstexpr) {
   // The value of a condition that is an expression is the value of the
   // expression, implicitly converted to bool.
   //
+  // C++2b 8.5.2p2
+  // If the if statement is of the form if constexpr, the value of the 
condition
+  // is contextually converted to bool and the converted expression shall be
+  // a constant expression.
+  //
+
+  ExprResult E = PerformContextuallyConvertToBool(CondExpr);
+  if (!IsConstexpr || E.isInvalid() || E.get()->isValueDependent())
+return E;
+
   // FIXME: Return this value to the caller so they don't need to recompute it.
-  llvm::APSInt Value(/*BitWidth*/1);
-  return (IsConstexpr && !CondExpr->isValueDependent())
- ? CheckConvertedConstantExpression(CondExpr, Context.BoolTy, 
Value,
-CCEK_ConstexprIf)
- : PerformContextuallyConvertToBool(CondExpr);
+  llvm::APSInt Cond;
+  E = VerifyI

[PATCH] D105127: Implement P1401R5

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

Thanks for the patch! I've committed on your behalf in 
8747234032c9c6270a6198ab3cca14ce2bd18721 
.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105127

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


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

2021-07-12 Thread Steffen Larsen via Phabricator via cfe-commits
steffenlarsen requested changes to this revision.
steffenlarsen added a comment.
This revision now requires changes to proceed.

Good stuff! Thanks for adding this and adjusting the test generator. I have 
requested some minor changes, though nothing critical. Are the test failures 
related to these changes?




Comment at: clang/test/CodeGen/builtins-nvptx-mma.py:35-38
+def make_mma_ops(geoms, types_a, types_b, types_c, types_d, b1ops=None):
   ops = []
+  if b1ops is None:
+b1ops = [""]





Comment at: clang/test/CodeGen/builtins-nvptx-mma.py:84
+  # It uses __mma_tf32_m16n16k8_ld_c but __mma_m16n16k8_st_c_f32.
+  make_ldst_ops(["m16n16k8"], ["a", "b", "c", "d"], ["tf32", "f32"]))
 

The following changes would remove the need for the `m16n16k8` cases in 
`is_ldst_variant_supported`.



Comment at: clang/test/CodeGen/builtins-nvptx-mma.py:265
 min_ptx = get_required_ptx(frag)
+# TF32 uses t32 for loads.
+if frag.geom == "m16n16k8" and frag.frag =="c":




Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105384

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


[PATCH] D105629: [TSan] Add SystemZ support

2021-07-12 Thread Ilya Leoshkevich via Phabricator via cfe-commits
iii marked an inline comment as done.
iii added a comment.

Regarding the openmp test failures: I tried check-openmp on a x86_64 machine, 
and they occur both with and without this patch series, so must be unrelated.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105629

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


[PATCH] D105734: [clang-tidy] performance-unnecessary-copy-initialization: Do not remove comments on new lines.

2021-07-12 Thread Yitzhak Mandelbaum via Phabricator via cfe-commits
ymandel added a comment.

Given that you're removing a declaration, consider using 
`tooling::getAssociatedRange` 
https://source.corp.google.com/piper///depot/google3/third_party/llvm/llvm-project/clang/include/clang/Tooling/Transformer/SourceCode.h;l=44
  It does have a different semantics than the simpler logic that you have here, 
but, its based on code in a dead-code removal tool, so it may still be what you 
want.




Comment at: 
clang-tools-extra/clang-tidy/performance/UnnecessaryCopyInitialization.cpp:51
+  if (Tok && !Invalid) {
+size_t Offset = std::strcspn(TextAfter, "\n");
+auto PastNewLine = Stmt.getEndLoc().getLocWithOffset(Offset + 1);

what happens for the last line in the file? I think the `Offset + 1` below will 
be sketchy (because PastNewLine will be invalid). It might work, but seems best 
avoided.



Comment at: 
clang-tools-extra/clang-tidy/performance/UnnecessaryCopyInitialization.cpp:56
+// ever comes first.
+auto End = std::min(PastNewLine, BeforeFirstTokenAfterComment);
+Diagnostic << FixItHint::CreateRemoval(

I suspect this could get tripped up by macros and other expansions. Instead of 
`std::min`, consider using `SourceManager::isBeforeInTranslationUnit`
(clang/include/clang/Basic/SourceManager.h;l=1616)? Alternatively, check that 
both locations are file ids before calling `std::min`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105734

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


[PATCH] D105421: [analyzer] Handle << operator for std::unique_ptr

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



Comment at: clang/lib/StaticAnalyzer/Checkers/SmartPtrModeling.cpp:87
+static bool hasStdClassWithName(const CXXRecordDecl *RD,
+const ArrayRef &Names) {
+  if (!RD || !RD->getDeclContext()->isStdNamespace())

`ArrayRef` is already a ref (and it says it in its name), so you should remove 
it there.



Comment at: clang/lib/StaticAnalyzer/Checkers/SmartPtrModeling.cpp:103
+static bool isStdSmartPtr(const CXXRecordDecl *RD) {
+  return hasStdClassWithName(RD, {STD_PTR_NAMES, 3});
+}

`ArrayRef` has an implicit constructor from C-arrays, putting size here is 
unnecessary.
And the reason why you were not able to do this is **type mismatch**.  
`STD_PTR_NAMES` is array of `llvm::StringLiteral`, but you chose 
`ArrayRef` as the type of the argument.



Comment at: clang/lib/StaticAnalyzer/Checkers/SmartPtrModeling.cpp:195
 
+const SmallVector BasicOstreamName = {"basic_ostream"};
+

RedDocMD wrote:
> vsavchenko wrote:
> > Same here + don't call it "Name" (singular).  It is a) an array and b) in 
> > the future, we might add more things to it, so we shouldn't need to rename 
> > it everywhere.
> Well, we won't have to rename but we will still have to change the array 
> length everywhere if more names are added.
No, we don't have to do that.  See the reason in the other comment.
Whenever you need to explicitly hardcode size for a stack-allocated array, you 
are doing something wrong.  Stack-allocated everything (VLAs aside) is required 
to have a fixed size.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105421

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


[PATCH] D104918: [clang-repl] Implement partial translation units and error recovery.

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

In D104918#2870582 , @teemperor wrote:

> @v.g.vassilev For LLDB you need to change the 
> `TypeSystemClang::SetExternalSource` function to this (it just moves the 
> `setHasExternalLexicalStorage` one line up. You can just add that change and 
> the compilation fix to this commit.
>
>   void TypeSystemClang::SetExternalSource(
>   llvm::IntrusiveRefCntPtr &ast_source_up) {
> ASTContext &ast = getASTContext();
> ast.getTranslationUnitDecl()->setHasExternalLexicalStorage(true);
> ast.setExternalSource(ast_source_up);
>   }
>
> The problem is that a few ASTs in LLDB change the ExternalSource that is 
> originally set, but the LazyGenerationalUpdatePtr remembers the initial 
> ExternalSource and tries to access it to complete the redecl chain (but the 
> original ExternalSource just got replaced and deleted). The better fix is to 
> not even create that original ExternalSource, but I can fix that in a follow 
> up as that seems out of scope for this patch.

Thanks @teemperor! I will add your suggestion and recommit.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D104918

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


[clang-tools-extra] 187e050 - [clang-tidy] performance-unnecessary-copy-initialization: Disable structured bindings.

2021-07-12 Thread Felix Berger via cfe-commits

Author: Felix Berger
Date: 2021-07-12T09:55:27-04:00
New Revision: 187e050b33bbee1ef210c83f5595c283ba671909

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

LOG: [clang-tidy] performance-unnecessary-copy-initialization: Disable 
structured bindings.

Structured bindings can currently trigger the check and lead to a wrong
fix. Because the DecompositionDecl itself is not used and the check does not
iterate through its the decl's bindings to verify whether the bindings' holding
vars are used this leads to the whole statement to be deleted.

To support structured bindings properly 3 cases would need to be considered.

  1. All holding vars are not used -> The statement can be deleted.
  2. All holding vars are used as const or not used -> auto can be converted to 
const auto&.
  3. Neither case is true -> leave unchanged.

In the check we'll have to separate the logic that determines this from the code
that produces the diagnostic and fixes and first determine which of the cases
we're dealing with before creating fixes.

Since this is a bigger refactoring we'll disable structured bindings for now to
prevent incorrect fixes.

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

Reviewed-by: ymandel

Added: 


Modified: 
clang-tools-extra/clang-tidy/performance/UnnecessaryCopyInitialization.cpp

clang-tools-extra/test/clang-tidy/checkers/performance-unnecessary-copy-initialization.cpp

Removed: 




diff  --git 
a/clang-tools-extra/clang-tidy/performance/UnnecessaryCopyInitialization.cpp 
b/clang-tools-extra/clang-tidy/performance/UnnecessaryCopyInitialization.cpp
index f75a3a901ecd5..f69a2079e4ba1 100644
--- a/clang-tools-extra/clang-tidy/performance/UnnecessaryCopyInitialization.cpp
+++ b/clang-tools-extra/clang-tidy/performance/UnnecessaryCopyInitialization.cpp
@@ -147,6 +147,7 @@ void 
UnnecessaryCopyInitialization::registerMatchers(MatchFinder *Finder) {
 return compoundStmt(
forEachDescendant(
declStmt(
+   unless(has(decompositionDecl())),
has(varDecl(hasLocalStorage(),
hasType(qualType(
hasCanonicalType(allOf(

diff  --git 
a/clang-tools-extra/test/clang-tidy/checkers/performance-unnecessary-copy-initialization.cpp
 
b/clang-tools-extra/test/clang-tidy/checkers/performance-unnecessary-copy-initialization.cpp
index c2b3d8f9c7395..b66a88e5cf81f 100644
--- 
a/clang-tools-extra/test/clang-tidy/checkers/performance-unnecessary-copy-initialization.cpp
+++ 
b/clang-tools-extra/test/clang-tidy/checkers/performance-unnecessary-copy-initialization.cpp
@@ -1,4 +1,4 @@
-// RUN: %check_clang_tidy %s performance-unnecessary-copy-initialization %t
+// RUN: %check_clang_tidy -std=c++17 %s 
performance-unnecessary-copy-initialization %t
 
 template 
 struct Iterator {
@@ -637,3 +637,18 @@ void negativeReferenceIsInitializedOutsideOfBlock() {
 }
   };
 }
+
+void negativeStructuredBinding() {
+  // Structured bindings are not yet supported but can trigger false positives
+  // since the DecompositionDecl itself is unused and the check doesn't 
traverse
+  // VarDecls of the BindingDecls.
+  struct Pair {
+ExpensiveToCopyType first;
+ExpensiveToCopyType second;
+  };
+
+  Pair P;
+  const auto [C, D] = P;
+  C.constMethod();
+  D.constMethod();
+}



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


[PATCH] D105727: [clang-tidy] performance-unnecessary-copy-initialization: Disable structured bindings.

2021-07-12 Thread Felix Berger via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG187e050b33bb: [clang-tidy] 
performance-unnecessary-copy-initialization: Disable structured… (authored by 
flx).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105727

Files:
  clang-tools-extra/clang-tidy/performance/UnnecessaryCopyInitialization.cpp
  
clang-tools-extra/test/clang-tidy/checkers/performance-unnecessary-copy-initialization.cpp


Index: 
clang-tools-extra/test/clang-tidy/checkers/performance-unnecessary-copy-initialization.cpp
===
--- 
clang-tools-extra/test/clang-tidy/checkers/performance-unnecessary-copy-initialization.cpp
+++ 
clang-tools-extra/test/clang-tidy/checkers/performance-unnecessary-copy-initialization.cpp
@@ -1,4 +1,4 @@
-// RUN: %check_clang_tidy %s performance-unnecessary-copy-initialization %t
+// RUN: %check_clang_tidy -std=c++17 %s 
performance-unnecessary-copy-initialization %t
 
 template 
 struct Iterator {
@@ -637,3 +637,18 @@
 }
   };
 }
+
+void negativeStructuredBinding() {
+  // Structured bindings are not yet supported but can trigger false positives
+  // since the DecompositionDecl itself is unused and the check doesn't 
traverse
+  // VarDecls of the BindingDecls.
+  struct Pair {
+ExpensiveToCopyType first;
+ExpensiveToCopyType second;
+  };
+
+  Pair P;
+  const auto [C, D] = P;
+  C.constMethod();
+  D.constMethod();
+}
Index: 
clang-tools-extra/clang-tidy/performance/UnnecessaryCopyInitialization.cpp
===
--- clang-tools-extra/clang-tidy/performance/UnnecessaryCopyInitialization.cpp
+++ clang-tools-extra/clang-tidy/performance/UnnecessaryCopyInitialization.cpp
@@ -147,6 +147,7 @@
 return compoundStmt(
forEachDescendant(
declStmt(
+   unless(has(decompositionDecl())),
has(varDecl(hasLocalStorage(),
hasType(qualType(
hasCanonicalType(allOf(


Index: clang-tools-extra/test/clang-tidy/checkers/performance-unnecessary-copy-initialization.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/performance-unnecessary-copy-initialization.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/performance-unnecessary-copy-initialization.cpp
@@ -1,4 +1,4 @@
-// RUN: %check_clang_tidy %s performance-unnecessary-copy-initialization %t
+// RUN: %check_clang_tidy -std=c++17 %s performance-unnecessary-copy-initialization %t
 
 template 
 struct Iterator {
@@ -637,3 +637,18 @@
 }
   };
 }
+
+void negativeStructuredBinding() {
+  // Structured bindings are not yet supported but can trigger false positives
+  // since the DecompositionDecl itself is unused and the check doesn't traverse
+  // VarDecls of the BindingDecls.
+  struct Pair {
+ExpensiveToCopyType first;
+ExpensiveToCopyType second;
+  };
+
+  Pair P;
+  const auto [C, D] = P;
+  C.constMethod();
+  D.constMethod();
+}
Index: clang-tools-extra/clang-tidy/performance/UnnecessaryCopyInitialization.cpp
===
--- clang-tools-extra/clang-tidy/performance/UnnecessaryCopyInitialization.cpp
+++ clang-tools-extra/clang-tidy/performance/UnnecessaryCopyInitialization.cpp
@@ -147,6 +147,7 @@
 return compoundStmt(
forEachDescendant(
declStmt(
+   unless(has(decompositionDecl())),
has(varDecl(hasLocalStorage(),
hasType(qualType(
hasCanonicalType(allOf(
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 1af97c9 - [analyzer] LoopUnrolling: fix crash when a loop counter is captured in a lambda by reference

2021-07-12 Thread Valeriy Savchenko via cfe-commits

Author: Abbas Sabra
Date: 2021-07-12T17:06:07+03:00
New Revision: 1af97c9d0b02002586473b4b9845b0c390504a27

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

LOG: [analyzer] LoopUnrolling: fix crash when a loop counter is captured in a 
lambda by reference

Reviewed By: vsavchenko

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

Added: 


Modified: 
clang/lib/StaticAnalyzer/Core/LoopUnrolling.cpp
clang/test/Analysis/loop-unrolling.cpp

Removed: 




diff  --git a/clang/lib/StaticAnalyzer/Core/LoopUnrolling.cpp 
b/clang/lib/StaticAnalyzer/Core/LoopUnrolling.cpp
index dc268e562237f..e5f4e9ea30c97 100644
--- a/clang/lib/StaticAnalyzer/Core/LoopUnrolling.cpp
+++ b/clang/lib/StaticAnalyzer/Core/LoopUnrolling.cpp
@@ -79,14 +79,17 @@ ProgramStateRef processLoopEnd(const Stmt *LoopStmt, 
ProgramStateRef State) {
   return State;
 }
 
-static internal::Matcher simpleCondition(StringRef BindName) {
-  return binaryOperator(anyOf(hasOperatorName("<"), hasOperatorName(">"),
-  hasOperatorName("<="), hasOperatorName(">="),
-  hasOperatorName("!=")),
-hasEitherOperand(ignoringParenImpCasts(declRefExpr(
-
to(varDecl(hasType(isInteger())).bind(BindName),
-hasEitherOperand(ignoringParenImpCasts(
-integerLiteral().bind("boundNum"
+static internal::Matcher simpleCondition(StringRef BindName,
+   StringRef RefName) {
+  return binaryOperator(
+ anyOf(hasOperatorName("<"), hasOperatorName(">"),
+   hasOperatorName("<="), hasOperatorName(">="),
+   hasOperatorName("!=")),
+ hasEitherOperand(ignoringParenImpCasts(
+ declRefExpr(to(varDecl(hasType(isInteger())).bind(BindName)))
+ .bind(RefName))),
+ hasEitherOperand(
+ ignoringParenImpCasts(integerLiteral().bind("boundNum"
   .bind("conditionOperator");
 }
 
@@ -138,7 +141,7 @@ static internal::Matcher hasSuspiciousStmt(StringRef 
NodeName) {
 
 static internal::Matcher forLoopMatcher() {
   return forStmt(
- hasCondition(simpleCondition("initVarName")),
+ hasCondition(simpleCondition("initVarName", "initVarRef")),
  // Initialization should match the form: 'int i = 6' or 'i = 42'.
  hasLoopInit(
  anyOf(declStmt(hasSingleDecl(
@@ -156,17 +159,52 @@ static internal::Matcher forLoopMatcher() {
  hasUnaryOperand(declRefExpr(
  to(varDecl(allOf(equalsBoundNode("initVarName"),
   hasType(isInteger(),
- 
unless(hasBody(hasSuspiciousStmt("initVarName".bind("forLoop");
+ unless(hasBody(hasSuspiciousStmt("initVarName"
+  .bind("forLoop");
 }
 
-static bool isPossiblyEscaped(const VarDecl *VD, ExplodedNode *N) {
-  // Global variables assumed as escaped variables.
+static bool isCapturedByReference(ExplodedNode *N, const DeclRefExpr *DR) {
+
+  // Get the lambda CXXRecordDecl
+  assert(DR->refersToEnclosingVariableOrCapture());
+  const LocationContext *LocCtxt = N->getLocationContext();
+  const Decl *D = LocCtxt->getDecl();
+  const auto *MD = cast(D);
+  assert(MD && MD->getParent()->isLambda() &&
+ "Captured variable should only be seen while evaluating a lambda");
+  const CXXRecordDecl *LambdaCXXRec = MD->getParent();
+
+  // Lookup the fields of the lambda
+  llvm::DenseMap LambdaCaptureFields;
+  FieldDecl *LambdaThisCaptureField;
+  LambdaCXXRec->getCaptureFields(LambdaCaptureFields, LambdaThisCaptureField);
+
+  // Check if the counter is captured by reference
+  const VarDecl *VD = cast(DR->getDecl()->getCanonicalDecl());
+  assert(VD);
+  const FieldDecl *FD = LambdaCaptureFields[VD];
+  assert(FD && "Captured variable without a corresponding field");
+  return FD->getType()->isReferenceType();
+}
+
+// A loop counter is considered escaped if:
+// case 1: It is a global variable.
+// case 2: It is a reference parameter or a reference capture.
+// case 3: It is assigned to a non-const reference variable or parameter.
+// case 4: Has its address taken.
+static bool isPossiblyEscaped(ExplodedNode *N, const DeclRefExpr *DR) {
+  const VarDecl *VD = cast(DR->getDecl()->getCanonicalDecl());
+  assert(VD);
+  // Case 1:
   if (VD->hasGlobalStorage())
 return true;
 
-  const bool isParm = isa(VD);
-  // Reference parameters are assumed as escaped variables.
-  if (isParm && VD->getType()->isReferenceType())
+  const bool IsRefParamOrCapture =
+  isa(VD) || DR->refersToEnclosingVariableOrCapture();
+  // Case 2:
+  if 

[PATCH] D102273: [analyzer] LoopUnrolling: fix crash when a loop counter is captured in a lambda by reference

2021-07-12 Thread Valeriy Savchenko 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 rG1af97c9d0b02: [analyzer] LoopUnrolling: fix crash when a 
loop counter is captured in a lambda… (authored by AbbasSabra, committed by 
vsavchenko).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D102273

Files:
  clang/lib/StaticAnalyzer/Core/LoopUnrolling.cpp
  clang/test/Analysis/loop-unrolling.cpp

Index: clang/test/Analysis/loop-unrolling.cpp
===
--- clang/test/Analysis/loop-unrolling.cpp
+++ clang/test/Analysis/loop-unrolling.cpp
@@ -1,5 +1,5 @@
-// RUN: %clang_analyze_cc1 -analyzer-checker=core,debug.ExprInspection -analyzer-config unroll-loops=true,cfg-loopexit=true -verify -std=c++11 -analyzer-config exploration_strategy=unexplored_first_queue %s
-// RUN: %clang_analyze_cc1 -analyzer-checker=core,debug.ExprInspection -analyzer-config unroll-loops=true,cfg-loopexit=true,exploration_strategy=dfs -verify -std=c++11 -DDFS=1 %s
+// RUN: %clang_analyze_cc1 -analyzer-checker=core,debug.ExprInspection -analyzer-config unroll-loops=true,cfg-loopexit=true -verify -std=c++14 -analyzer-config exploration_strategy=unexplored_first_queue %s
+// RUN: %clang_analyze_cc1 -analyzer-checker=core,debug.ExprInspection -analyzer-config unroll-loops=true,cfg-loopexit=true,exploration_strategy=dfs -verify -std=c++14 -DDFS=1 %s
 
 void clang_analyzer_numTimesReached();
 void clang_analyzer_warnIfReached();
@@ -511,3 +511,39 @@
 clang_analyzer_numTimesReached(); // expected-warning {{4}}
   }
 }
+
+void capture_by_value_as_loop_counter() {
+  int out = 0;
+  auto l = [i = out]() mutable {
+for (i = 0; i < 10; ++i) {
+  clang_analyzer_numTimesReached(); // expected-warning {{10}}
+}
+  };
+}
+
+void capture_by_ref_as_loop_counter() {
+  int out = 0;
+  auto l = [&i = out]() {
+for (i = 0; i < 10; ++i) {
+  clang_analyzer_numTimesReached(); // expected-warning {{4}}
+}
+  };
+}
+
+void capture_implicitly_by_value_as_loop_counter() {
+  int i = 0;
+  auto l = [=]() mutable {
+for (i = 0; i < 10; ++i) {
+  clang_analyzer_numTimesReached(); // expected-warning {{10}}
+}
+  };
+}
+
+void capture_implicitly_by_ref_as_loop_counter() {
+  int i = 0;
+  auto l = [&]() mutable {
+for (i = 0; i < 10; ++i) {
+  clang_analyzer_numTimesReached(); // expected-warning {{4}}
+}
+  };
+}
Index: clang/lib/StaticAnalyzer/Core/LoopUnrolling.cpp
===
--- clang/lib/StaticAnalyzer/Core/LoopUnrolling.cpp
+++ clang/lib/StaticAnalyzer/Core/LoopUnrolling.cpp
@@ -79,14 +79,17 @@
   return State;
 }
 
-static internal::Matcher simpleCondition(StringRef BindName) {
-  return binaryOperator(anyOf(hasOperatorName("<"), hasOperatorName(">"),
-  hasOperatorName("<="), hasOperatorName(">="),
-  hasOperatorName("!=")),
-hasEitherOperand(ignoringParenImpCasts(declRefExpr(
-to(varDecl(hasType(isInteger())).bind(BindName),
-hasEitherOperand(ignoringParenImpCasts(
-integerLiteral().bind("boundNum"
+static internal::Matcher simpleCondition(StringRef BindName,
+   StringRef RefName) {
+  return binaryOperator(
+ anyOf(hasOperatorName("<"), hasOperatorName(">"),
+   hasOperatorName("<="), hasOperatorName(">="),
+   hasOperatorName("!=")),
+ hasEitherOperand(ignoringParenImpCasts(
+ declRefExpr(to(varDecl(hasType(isInteger())).bind(BindName)))
+ .bind(RefName))),
+ hasEitherOperand(
+ ignoringParenImpCasts(integerLiteral().bind("boundNum"
   .bind("conditionOperator");
 }
 
@@ -138,7 +141,7 @@
 
 static internal::Matcher forLoopMatcher() {
   return forStmt(
- hasCondition(simpleCondition("initVarName")),
+ hasCondition(simpleCondition("initVarName", "initVarRef")),
  // Initialization should match the form: 'int i = 6' or 'i = 42'.
  hasLoopInit(
  anyOf(declStmt(hasSingleDecl(
@@ -156,17 +159,52 @@
  hasUnaryOperand(declRefExpr(
  to(varDecl(allOf(equalsBoundNode("initVarName"),
   hasType(isInteger(),
- unless(hasBody(hasSuspiciousStmt("initVarName".bind("forLoop");
+ unless(hasBody(hasSuspiciousStmt("initVarName"
+  .bind("forLoop");
 }
 
-static bool isPossiblyEscaped(const VarDecl *VD, ExplodedNode *N) {
-  // Global variables assumed as escaped variables.
+static bool isCapturedByReference(ExplodedNode *N, const DeclRefExpr *DR) {
+
+  // Get the 

[clang] e49985b - Remove unused parameter from parseMSInlineAsm.

2021-07-12 Thread Simon Tatham via cfe-commits

Author: Simon Tatham
Date: 2021-07-12T15:07:03+01:00
New Revision: e49985bb6065d4f5ea69fe578e326ec6d43a6b24

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

LOG: Remove unused parameter from parseMSInlineAsm.

No implementation uses the `LocCookie` parameter at all. Errors are
reported from inside that function by `llvm::SourceMgr`, and the
instance of that at the clang call site arranges to pass the error
messages back to a `ClangAsmParserCallback`, which is where the clang
SourceLocation for the error is computed.

(This is part of a patch series working towards the ability to make
SourceLocation into a 64-bit type to handle larger translation units.
But this particular change seems beneficial in its own right.)

Reviewed By: miyuki

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

Added: 


Modified: 
clang/lib/Parse/ParseStmtAsm.cpp
llvm/include/llvm/MC/MCParser/MCAsmParser.h
llvm/lib/MC/MCParser/AsmParser.cpp
llvm/lib/MC/MCParser/MasmParser.cpp

Removed: 




diff  --git a/clang/lib/Parse/ParseStmtAsm.cpp 
b/clang/lib/Parse/ParseStmtAsm.cpp
index 9037895a3bbfc..e520151dcad76 100644
--- a/clang/lib/Parse/ParseStmtAsm.cpp
+++ b/clang/lib/Parse/ParseStmtAsm.cpp
@@ -633,9 +633,9 @@ StmtResult 
Parser::ParseMicrosoftAsmStatement(SourceLocation AsmLoc) {
   SmallVector, 4> OpExprs;
   SmallVector Constraints;
   SmallVector Clobbers;
-  if (Parser->parseMSInlineAsm(AsmLoc.getPtrEncoding(), AsmStringIR, 
NumOutputs,
-   NumInputs, OpExprs, Constraints, Clobbers,
-   MII.get(), IP.get(), Callback))
+  if (Parser->parseMSInlineAsm(AsmStringIR, NumOutputs, NumInputs, OpExprs,
+   Constraints, Clobbers, MII.get(), IP.get(),
+   Callback))
 return StmtError();
 
   // Filter out "fpsw" and "mxcsr". They aren't valid GCC asm clobber

diff  --git a/llvm/include/llvm/MC/MCParser/MCAsmParser.h 
b/llvm/include/llvm/MC/MCParser/MCAsmParser.h
index 56188b7ebaec7..c9b3ab3256da8 100644
--- a/llvm/include/llvm/MC/MCParser/MCAsmParser.h
+++ b/llvm/include/llvm/MC/MCParser/MCAsmParser.h
@@ -202,8 +202,8 @@ class MCAsmParser {
 
   /// Parse MS-style inline assembly.
   virtual bool parseMSInlineAsm(
-  void *AsmLoc, std::string &AsmString, unsigned &NumOutputs,
-  unsigned &NumInputs, SmallVectorImpl> &OpDecls,
+  std::string &AsmString, unsigned &NumOutputs, unsigned &NumInputs,
+  SmallVectorImpl> &OpDecls,
   SmallVectorImpl &Constraints,
   SmallVectorImpl &Clobbers, const MCInstrInfo *MII,
   const MCInstPrinter *IP, MCAsmParserSemaCallback &SI) = 0;

diff  --git a/llvm/lib/MC/MCParser/AsmParser.cpp 
b/llvm/lib/MC/MCParser/AsmParser.cpp
index 3bc668e699cbc..45e6dfee4ca4b 100644
--- a/llvm/lib/MC/MCParser/AsmParser.cpp
+++ b/llvm/lib/MC/MCParser/AsmParser.cpp
@@ -258,9 +258,9 @@ class AsmParser : public MCAsmParser {
 return LTODiscardSymbols.contains(Name);
   }
 
-  bool parseMSInlineAsm(void *AsmLoc, std::string &AsmString,
-unsigned &NumOutputs, unsigned &NumInputs,
-SmallVectorImpl> &OpDecls,
+  bool parseMSInlineAsm(std::string &AsmString, unsigned &NumOutputs,
+unsigned &NumInputs,
+SmallVectorImpl> &OpDecls,
 SmallVectorImpl &Constraints,
 SmallVectorImpl &Clobbers,
 const MCInstrInfo *MII, const MCInstPrinter *IP,
@@ -5927,8 +5927,8 @@ static int rewritesSort(const AsmRewrite *AsmRewriteA,
 }
 
 bool AsmParser::parseMSInlineAsm(
-void *AsmLoc, std::string &AsmString, unsigned &NumOutputs,
-unsigned &NumInputs, SmallVectorImpl> &OpDecls,
+std::string &AsmString, unsigned &NumOutputs, unsigned &NumInputs,
+SmallVectorImpl> &OpDecls,
 SmallVectorImpl &Constraints,
 SmallVectorImpl &Clobbers, const MCInstrInfo *MII,
 const MCInstPrinter *IP, MCAsmParserSemaCallback &SI) {

diff  --git a/llvm/lib/MC/MCParser/MasmParser.cpp 
b/llvm/lib/MC/MCParser/MasmParser.cpp
index a91623770116a..a5a48d4b1e9d8 100644
--- a/llvm/lib/MC/MCParser/MasmParser.cpp
+++ b/llvm/lib/MC/MCParser/MasmParser.cpp
@@ -514,9 +514,9 @@ class MasmParser : public MCAsmParser {
 
   bool lookUpType(StringRef Name, AsmTypeInfo &Info) const override;
 
-  bool parseMSInlineAsm(void *AsmLoc, std::string &AsmString,
-unsigned &NumOutputs, unsigned &NumInputs,
-SmallVectorImpl> &OpDecls,
+  bool parseMSInlineAsm(std::string &AsmString, unsigned &NumOutputs,
+unsigned &NumInputs,
+SmallVectorImpl> &OpDecls,
 SmallVectorImpl &Constraints,
   

[PATCH] D105490: Remove unused parameter from parseMSInlineAsm.

2021-07-12 Thread Simon Tatham 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 rGe49985bb6065: Remove unused parameter from parseMSInlineAsm. 
(authored by simon_tatham).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105490

Files:
  clang/lib/Parse/ParseStmtAsm.cpp
  llvm/include/llvm/MC/MCParser/MCAsmParser.h
  llvm/lib/MC/MCParser/AsmParser.cpp
  llvm/lib/MC/MCParser/MasmParser.cpp


Index: llvm/lib/MC/MCParser/MasmParser.cpp
===
--- llvm/lib/MC/MCParser/MasmParser.cpp
+++ llvm/lib/MC/MCParser/MasmParser.cpp
@@ -514,9 +514,9 @@
 
   bool lookUpType(StringRef Name, AsmTypeInfo &Info) const override;
 
-  bool parseMSInlineAsm(void *AsmLoc, std::string &AsmString,
-unsigned &NumOutputs, unsigned &NumInputs,
-SmallVectorImpl> &OpDecls,
+  bool parseMSInlineAsm(std::string &AsmString, unsigned &NumOutputs,
+unsigned &NumInputs,
+SmallVectorImpl> &OpDecls,
 SmallVectorImpl &Constraints,
 SmallVectorImpl &Clobbers,
 const MCInstrInfo *MII, const MCInstPrinter *IP,
@@ -7257,8 +7257,8 @@
 }
 
 bool MasmParser::parseMSInlineAsm(
-void *AsmLoc, std::string &AsmString, unsigned &NumOutputs,
-unsigned &NumInputs, SmallVectorImpl> &OpDecls,
+std::string &AsmString, unsigned &NumOutputs, unsigned &NumInputs,
+SmallVectorImpl> &OpDecls,
 SmallVectorImpl &Constraints,
 SmallVectorImpl &Clobbers, const MCInstrInfo *MII,
 const MCInstPrinter *IP, MCAsmParserSemaCallback &SI) {
Index: llvm/lib/MC/MCParser/AsmParser.cpp
===
--- llvm/lib/MC/MCParser/AsmParser.cpp
+++ llvm/lib/MC/MCParser/AsmParser.cpp
@@ -258,9 +258,9 @@
 return LTODiscardSymbols.contains(Name);
   }
 
-  bool parseMSInlineAsm(void *AsmLoc, std::string &AsmString,
-unsigned &NumOutputs, unsigned &NumInputs,
-SmallVectorImpl> &OpDecls,
+  bool parseMSInlineAsm(std::string &AsmString, unsigned &NumOutputs,
+unsigned &NumInputs,
+SmallVectorImpl> &OpDecls,
 SmallVectorImpl &Constraints,
 SmallVectorImpl &Clobbers,
 const MCInstrInfo *MII, const MCInstPrinter *IP,
@@ -5927,8 +5927,8 @@
 }
 
 bool AsmParser::parseMSInlineAsm(
-void *AsmLoc, std::string &AsmString, unsigned &NumOutputs,
-unsigned &NumInputs, SmallVectorImpl> &OpDecls,
+std::string &AsmString, unsigned &NumOutputs, unsigned &NumInputs,
+SmallVectorImpl> &OpDecls,
 SmallVectorImpl &Constraints,
 SmallVectorImpl &Clobbers, const MCInstrInfo *MII,
 const MCInstPrinter *IP, MCAsmParserSemaCallback &SI) {
Index: llvm/include/llvm/MC/MCParser/MCAsmParser.h
===
--- llvm/include/llvm/MC/MCParser/MCAsmParser.h
+++ llvm/include/llvm/MC/MCParser/MCAsmParser.h
@@ -202,8 +202,8 @@
 
   /// Parse MS-style inline assembly.
   virtual bool parseMSInlineAsm(
-  void *AsmLoc, std::string &AsmString, unsigned &NumOutputs,
-  unsigned &NumInputs, SmallVectorImpl> &OpDecls,
+  std::string &AsmString, unsigned &NumOutputs, unsigned &NumInputs,
+  SmallVectorImpl> &OpDecls,
   SmallVectorImpl &Constraints,
   SmallVectorImpl &Clobbers, const MCInstrInfo *MII,
   const MCInstPrinter *IP, MCAsmParserSemaCallback &SI) = 0;
Index: clang/lib/Parse/ParseStmtAsm.cpp
===
--- clang/lib/Parse/ParseStmtAsm.cpp
+++ clang/lib/Parse/ParseStmtAsm.cpp
@@ -633,9 +633,9 @@
   SmallVector, 4> OpExprs;
   SmallVector Constraints;
   SmallVector Clobbers;
-  if (Parser->parseMSInlineAsm(AsmLoc.getPtrEncoding(), AsmStringIR, 
NumOutputs,
-   NumInputs, OpExprs, Constraints, Clobbers,
-   MII.get(), IP.get(), Callback))
+  if (Parser->parseMSInlineAsm(AsmStringIR, NumOutputs, NumInputs, OpExprs,
+   Constraints, Clobbers, MII.get(), IP.get(),
+   Callback))
 return StmtError();
 
   // Filter out "fpsw" and "mxcsr". They aren't valid GCC asm clobber


Index: llvm/lib/MC/MCParser/MasmParser.cpp
===
--- llvm/lib/MC/MCParser/MasmParser.cpp
+++ llvm/lib/MC/MCParser/MasmParser.cpp
@@ -514,9 +514,9 @@
 
   bool lookUpType(StringRef Name, AsmTypeInfo &Info) const override;
 
-  bool parseMSInlineAsm(void *AsmLoc, std::string &AsmString,
-unsigned &NumOutputs, unsigned &NumInputs,
-SmallVectorImpl> &OpDecls,

[PATCH] D105501: [PowerPC] Power ISA features for Semachecking

2021-07-12 Thread Quinn Pham via Phabricator via cfe-commits
quinnp updated this revision to Diff 357942.
quinnp added a comment.

Addressing some review comments.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105501

Files:
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/Basic/Targets/PPC.cpp
  clang/lib/Basic/Targets/PPC.h
  clang/lib/Sema/SemaChecking.cpp
  llvm/lib/Target/PowerPC/PPC.td
  llvm/lib/Target/PowerPC/PPCInstrInfo.td
  llvm/lib/Target/PowerPC/PPCSubtarget.cpp
  llvm/lib/Target/PowerPC/PPCSubtarget.h

Index: llvm/lib/Target/PowerPC/PPCSubtarget.h
===
--- llvm/lib/Target/PowerPC/PPCSubtarget.h
+++ llvm/lib/Target/PowerPC/PPCSubtarget.h
@@ -146,6 +146,7 @@
   bool HasStoreFusion;
   bool HasAddiLoadFusion;
   bool HasAddisLoadFusion;
+  bool IsISA2_07;
   bool IsISA3_0;
   bool IsISA3_1;
   bool UseLongCalls;
@@ -319,6 +320,7 @@
 
   bool hasHTM() const { return HasHTM; }
   bool hasFloat128() const { return HasFloat128; }
+  bool isISA2_07() const { return IsISA2_07; }
   bool isISA3_0() const { return IsISA3_0; }
   bool isISA3_1() const { return IsISA3_1; }
   bool useLongCalls() const { return UseLongCalls; }
Index: llvm/lib/Target/PowerPC/PPCSubtarget.cpp
===
--- llvm/lib/Target/PowerPC/PPCSubtarget.cpp
+++ llvm/lib/Target/PowerPC/PPCSubtarget.cpp
@@ -126,6 +126,7 @@
   HasStoreFusion = false;
   HasAddiLoadFusion = false;
   HasAddisLoadFusion = false;
+  IsISA2_07 = false;
   IsISA3_0 = false;
   IsISA3_1 = false;
   UseLongCalls = false;
Index: llvm/lib/Target/PowerPC/PPCInstrInfo.td
===
--- llvm/lib/Target/PowerPC/PPCInstrInfo.td
+++ llvm/lib/Target/PowerPC/PPCInstrInfo.td
@@ -1176,6 +1176,7 @@
 : Predicate<"!Subtarget->getTargetMachine().Options.NoNaNsFPMath">;
 def HasBPERMD : Predicate<"Subtarget->hasBPERMD()">;
 def HasExtDiv : Predicate<"Subtarget->hasExtDiv()">;
+def IsISA2_07 : Predicate<"Subtarget->isISA2_07()">;
 def IsISA3_0 : Predicate<"Subtarget->isISA3_0()">;
 def HasFPU : Predicate<"Subtarget->hasFPU()">;
 def PCRelativeMemops : Predicate<"Subtarget->hasPCRelativeMemops()">;
Index: llvm/lib/Target/PowerPC/PPC.td
===
--- llvm/lib/Target/PowerPC/PPC.td
+++ llvm/lib/Target/PowerPC/PPC.td
@@ -210,9 +210,13 @@
 def DeprecatedDST: SubtargetFeature<"", "DeprecatedDST", "true",
   "Treat vector data stream cache control instructions as deprecated">;
 
+def FeatureISA2_07 : SubtargetFeature<"isa-v207-instructions", "IsISA2_07",
+  "true",
+  "Enable instructions in ISA 2.07.">;
 def FeatureISA3_0 : SubtargetFeature<"isa-v30-instructions", "IsISA3_0",
  "true",
- "Enable instructions in ISA 3.0.">;
+ "Enable instructions in ISA 3.0.",
+ [FeatureISA2_07]>;
 def FeatureISA3_1 : SubtargetFeature<"isa-v31-instructions", "IsISA3_1",
  "true",
  "Enable instructions in ISA 3.1.",
Index: clang/lib/Sema/SemaChecking.cpp
===
--- clang/lib/Sema/SemaChecking.cpp
+++ clang/lib/Sema/SemaChecking.cpp
@@ -3273,9 +3273,17 @@
 }
 
 static bool SemaFeatureCheck(Sema &S, CallExpr *TheCall,
- StringRef FeatureToCheck, unsigned DiagID) {
-  if (!S.Context.getTargetInfo().hasFeature(FeatureToCheck))
-return S.Diag(TheCall->getBeginLoc(), DiagID) << TheCall->getSourceRange();
+ StringRef FeatureToCheck, unsigned DiagID,
+ StringRef DiagArg = "") {
+  if (!S.Context.getTargetInfo().hasFeature(FeatureToCheck)) {
+if (!DiagArg.empty()) {
+  S.Diag(TheCall->getBeginLoc(), DiagID)
+  << DiagArg << TheCall->getSourceRange();
+} else {
+  S.Diag(TheCall->getBeginLoc(), DiagID) << TheCall->getSourceRange();
+}
+return true;
+  }
   return false;
 }
 
@@ -3318,17 +3326,17 @@
   case PPC::BI__builtin_divde:
   case PPC::BI__builtin_divdeu:
 return SemaFeatureCheck(*this, TheCall, "extdiv",
-diag::err_ppc_builtin_only_on_pwr7);
+diag::err_ppc_builtin_only_on_arch, "7");
   case PPC::BI__builtin_bpermd:
 return SemaFeatureCheck(*this, TheCall, "bpermd",
-diag::err_ppc_builtin_only_on_pwr7);
+diag::err_ppc_builtin_only_on_arch, "7");
   case PPC::BI__builtin_unpack_vector_int128:
 return SemaFeatureCheck(*this, TheCall, "vsx",
-diag::err_ppc_builtin_only_on_pwr7) ||
+diag::err_

[PATCH] D77491: [Sema] Introduce BuiltinAttr, per-declaration builtin-ness

2021-07-12 Thread Raul Tambre via Phabricator via cfe-commits
tambre added a comment.

In D77491#2870291 , @jdoerfert wrote:

> First:
> Do I assume right this this feature was simply disabled without any plan to:
>
> - inform the authors (me)
> - update the documentation
> - re-enable support eventually or provide alternatives
>
> XFAILing a test and calling it a day seems inadequate IMHO.
>
> Second:
> Would an approach like this still work: https://reviews.llvm.org/D58531 ?

Informing you would've probably been appropriate in hindsight.
I'm not aware of any relevant documentation that would've been appropriate to 
update.

Re-enabling the support depends on someone taking up the work to correctly 
implement the prototype recognition, which seems to be done in D58531 
 and would work as-is.
However, at the time it seemed to me that the whole builtin declaration 
recognition could use a rewrite to be able to this support this case without 
hacks and require less manual C++ type juggling.
I considered that work beyond my experience with the codebase and the benefits 
of this work easily seemed to outweigh the lack of additional annotations for 
this single function. I received no further feedback on the disabling of that 
test after explaining the reason.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77491

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


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

2021-07-12 Thread Balázs Kéri via Phabricator via cfe-commits
balazske updated this revision to Diff 357947.
balazske added a comment.

Using the new symbol "uninterestingness" feature.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D104925

Files:
  clang/lib/StaticAnalyzer/Checkers/StreamChecker.cpp
  clang/test/Analysis/stream-note.c

Index: clang/test/Analysis/stream-note.c
===
--- clang/test/Analysis/stream-note.c
+++ clang/test/Analysis/stream-note.c
@@ -88,3 +88,60 @@
   fclose(F); // expected-warning {{Stream pointer might be NULL}}
   // expected-note@-1 {{Stream pointer might be NULL}}
 }
+
+void check_eof_notes_feof_after_feof() {
+  FILE *F;
+  char Buf[10];
+  F = fopen("foo1.c", "r");
+  if (F == NULL) { // expected-note {{Taking false branch}} expected-note {{'F' is not equal to NULL}}
+return;
+  }
+  fread(Buf, 1, 1, F);
+  if (feof(F)) { // expected-note {{Taking true branch}}
+clearerr(F);
+fread(Buf, 1, 1, F);   // expected-note {{Assuming that stream reaches end-of-file here}}
+if (feof(F)) { // expected-note {{Taking true branch}}
+  fread(Buf, 1, 1, F); // expected-warning {{Read function called when stream is in EOF state. Function has no effect}}
+  // expected-note@-1 {{Read function called when stream is in EOF state. Function has no effect}}
+}
+  }
+  fclose(F);
+}
+
+void check_eof_notes_feof_after_no_feof() {
+  FILE *F;
+  char Buf[10];
+  F = fopen("foo1.c", "r");
+  if (F == NULL) { // expected-note {{Taking false branch}} expected-note {{'F' is not equal to NULL}}
+return;
+  }
+  fread(Buf, 1, 1, F);
+  if (feof(F)) { // expected-note {{Taking false branch}}
+fclose(F);
+return;
+  } else if (ferror(F)) { // expected-note {{Taking false branch}}
+fclose(F);
+return;
+  }
+  fread(Buf, 1, 1, F);   // expected-note {{Assuming that stream reaches end-of-file here}}
+  if (feof(F)) { // expected-note {{Taking true branch}}
+fread(Buf, 1, 1, F); // expected-warning {{Read function called when stream is in EOF state. Function has no effect}}
+// expected-note@-1 {{Read function called when stream is in EOF state. Function has no effect}}
+  }
+  fclose(F);
+}
+
+void check_eof_notes_feof_or_no_error() {
+  FILE *F;
+  char Buf[10];
+  F = fopen("foo1.c", "r");
+  if (F == NULL) // expected-note {{Taking false branch}} expected-note {{'F' is not equal to NULL}}
+return;
+  int RRet = fread(Buf, 1, 1, F); // expected-note {{Assuming that stream reaches end-of-file here}}
+  if (ferror(F)) {// expected-note {{Taking false branch}}
+  } else {
+fread(Buf, 1, 1, F); // expected-warning {{Read function called when stream is in EOF state. Function has no effect}}
+// expected-note@-1 {{Read function called when stream is in EOF state. Function has no effect}}
+  }
+  fclose(F);
+}
Index: clang/lib/StaticAnalyzer/Checkers/StreamChecker.cpp
===
--- clang/lib/StaticAnalyzer/Checkers/StreamChecker.cpp
+++ clang/lib/StaticAnalyzer/Checkers/StreamChecker.cpp
@@ -25,8 +25,15 @@
 using namespace ento;
 using namespace std::placeholders;
 
+//===--===//
+// Definition of state data structures.
+//===--===//
+
 namespace {
 
+const char *Desc_StreamEof = "Stream already in EOF";
+const char *Desc_ResourceLeak = "Resource leak";
+
 struct FnDescription;
 
 /// State of the stream error flags.
@@ -146,6 +153,14 @@
   }
 };
 
+} // namespace
+
+//===--===//
+// StreamChecker class and utility functions.
+//===--===//
+
+namespace {
+
 class StreamChecker;
 using FnCheck = std::function;
@@ -203,11 +218,18 @@
"Stream handling error"};
   BugType BT_IllegalWhence{this, "Illegal whence argument",
"Stream handling error"};
-  BugType BT_StreamEof{this, "Stream already in EOF", "Stream handling error"};
-  BugType BT_ResourceLeak{this, "Resource leak", "Stream handling error",
+  BugType BT_StreamEof{this, Desc_StreamEof, "Stream handling error"};
+  BugType BT_ResourceLeak{this, Desc_ResourceLeak, "Stream handling error",
   /*SuppressOnSink =*/true};
 
 public:
+  static const StreamChecker *Instance;
+
+  static const BugType *getBT_StreamEof() { return &Instance->BT_StreamEof; }
+  static const BugType *getBT_ResourceLeak() {
+return &Instance->BT_ResourceLeak;
+  }
+
   void checkPreCall(const CallEvent &Call, CheckerContext &C) const;
   bool evalCall(const CallEvent &Call, CheckerContext &C) const;
   void checkDeadSymbols(SymbolReaper &SymReaper, CheckerContext &C) const;
@@ -337,7 +359,8 

[clang] 11b47c1 - Reland "[clang-repl] Implement partial translation units and error recovery."

2021-07-12 Thread Vassil Vassilev via cfe-commits

Author: Vassil Vassilev
Date: 2021-07-12T15:21:22Z
New Revision: 11b47c103a36371576711cae1f7527c26f78efb5

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

LOG: Reland "[clang-repl] Implement partial translation units and error 
recovery."

Original commit message:

[clang-repl] Implement partial translation units and error recovery.

https://reviews.llvm.org/D96033 contained a discussion regarding efficient
modeling of error recovery. @rjmccall has outlined the key ideas:

Conceptually, we can split the translation unit into a sequence of partial
translation units (PTUs). Every declaration will be associated with a unique PTU
that owns it.

The first key insight here is that the owning PTU isn't always the "active"
(most recent) PTU, and it isn't always the PTU that the declaration
"comes from". A new declaration (that isn't a redeclaration or specialization of
anything) does belong to the active PTU. A template specialization, however,
belongs to the most recent PTU of all the declarations in its signature - mostly
that means that it can be pulled into a more recent PTU by its template
arguments.

The second key insight is that processing a PTU might extend an earlier PTU.
Rolling back the later PTU shouldn't throw that extension away. For example, if
the second PTU defines a template, and the third PTU requires that template to
be instantiated at float, that template specialization is still part of the
second PTU. Similarly, if the fifth PTU uses an inline function belonging to the
fourth, that definition still belongs to the fourth. When we go to emit code in
a new PTU, we map each declaration we have to emit back to its owning PTU and
emit it in a new module for just the extensions to that PTU. We keep track of
all the modules we've emitted for a PTU so that we can unload them all if we
decide to roll it back.

Most declarations/definitions will only refer to entities from the same or
earlier PTUs. However, it is possible (primarily by defining a
previously-declared entity, but also through templates or ADL) for an entity
that belongs to one PTU to refer to something from a later PTU. We will have to
keep track of this and prevent unwinding to later PTU when we recognize it.
Fortunately, this should be very rare; and crucially, we don't have to do the
bookkeeping for this if we've only got one PTU, e.g. in normal compilation.
Otherwise, PTUs after the first just need to record enough metadata to be able
to revert any changes they've made to declarations belonging to earlier PTUs,
e.g. to redeclaration chains or template specialization lists.

It should even eventually be possible for PTUs to provide their own slab
allocators which can be thrown away as part of rolling back the PTU. We can
maintain a notion of the active allocator and allocate things like Stmt/Expr
nodes in it, temporarily changing it to the appropriate PTU whenever we go to do
something like instantiate a function template. More care will be required when
allocating declarations and types, though.

We would want the PTU to be efficiently recoverable from a Decl; I'm not sure
how best to do that. An easy option that would cover most declarations would be
to make multiple TranslationUnitDecls and parent the declarations appropriately,
but I don't think that's good enough for things like member function templates,
since an instantiation of that would still be parented by its original class.
Maybe we can work this into the DC chain somehow, like how lexical DCs are.

We add a different kind of translation unit `TU_Incremental` which is a
complete translation unit that we might nonetheless incrementally extend later.
Because it is complete (and we might want to generate code for it), we do
perform template instantiation, but because it might be extended later, we don't
warn if it declares or uses undefined internal-linkage symbols.

This patch teaches clang-repl how to recover from errors by disconnecting the
most recent PTU and update the primary PTU lookup tables. For instance:

```./clang-repl
clang-repl> int i = 12; error;
In file included from <<< inputs >>>:1:
input_line_0:1:13: error: C++ requires a type specifier for all declarations
int i = 12; error;
^
error: Parsing failed.
clang-repl> int i = 13; extern "C" int printf(const char*,...);
clang-repl> auto r1 = printf("i=%d\n", i);
i=13
clang-repl> quit
```

Differential revision: https://reviews.llvm.org/D104918

Added: 
clang/include/clang/Interpreter/PartialTranslationUnit.h

Modified: 
clang/include/clang/AST/ASTContext.h
clang/include/clang/AST/Decl.h
clang/include/clang/AST/Redeclarable.h
clang/include/clang/Basic/LangOptions.h
clang/include/clang/Interpreter/Interpreter.h
clang/include/clang/Lex/Preprocessor.h
clang/include/clang/Sema/Sema.h
clang/lib/AST/ASTContext.cpp
clang/lib/AST/D

[PATCH] D105819: [analyzer] MallocChecker: Add a visitor to leave a note on functions that could have, but did not change ownership on leaked memory

2021-07-12 Thread Kristóf Umann via Phabricator via cfe-commits
Szelethus created this revision.
Szelethus added reviewers: NoQ, vsavchenko, steakhal, martong, ASDenysPetrov.
Szelethus added a project: clang.
Herald added subscribers: manas, gamesh411, dkrupp, donat.nagy, 
mikhail.ramalho, a.sidorin, rnkovacs, szepet, baloghadamsoftware, xazax.hun, 
whisperity, yaxunl.
Szelethus requested review of this revision.
Herald added subscribers: cfe-commits, aheejin.

This is a rather common feedback we get from out leak checkers: bug reports are 
really short, and are contain barely any usable information on what the 
analyzer did to conclude that a leak actually happened.

This happens because of our bug report minimizing effort. We construct bug 
reports by inspecting the `ExplodedNode`s that lead to the error from the 
bottom up (from the error node all the way to the root of the exploded graph), 
and mark entities that were the cause of a bug, or have interacted with it as 
interesting. In order to make the bug report a bit less verbose, whenever we 
find an entire function call (from `CallEnter` to `CallExitEnd`) that didn't 
talk about any interesting entity, we prune it (click here 
 for more info on 
bug report generation). Even if the event to highlight is exactly this lack of 
interaction with interesting entities.

D105553  generalized the visitor that creates 
notes for these cases. This patch adds a new kind of `NoStateChangeVisitor` 
that leaves notes in functions that took a piece of dynamically allocated 
memory that later leaked as parameter, and didn't change its ownership status.

While there is some code to talk over in MallocChecker.cpp, the main thing to 
discuss in my mind are the test cases, where I display where I want to see this 
visitor end up. I hope to be able to reach a point sometime soon when I can run 
on this on some real projects and post screenshots about it!


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D105819

Files:
  clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp
  clang/test/Analysis/NewDeleteLeaks.cpp
  clang/test/Analysis/self-assign.cpp

Index: clang/test/Analysis/self-assign.cpp
===
--- clang/test/Analysis/self-assign.cpp
+++ clang/test/Analysis/self-assign.cpp
@@ -1,4 +1,9 @@
-// RUN: %clang_analyze_cc1 -std=c++11 -analyzer-checker=core,cplusplus,unix.Malloc,debug.ExprInspection -analyzer-config eagerly-assume=false %s -verify -analyzer-output=text
+// RUN: %clang_analyze_cc1 -std=c++11 %s -verify -analyzer-output=text \
+// RUN:   -analyzer-checker=core \
+// RUN:   -analyzer-checker=cplusplus \
+// RUN:   -analyzer-checker=unix.Malloc \
+// RUN:   -analyzer-checker=debug.ExprInspection \
+// RUN:   -analyzer-config eagerly-assume=false
 
 extern "C" char *strdup(const char* s);
 extern "C" void free(void* ptr);
@@ -28,18 +33,31 @@
   free(str);
 }
 
-StringUsed& StringUsed::operator=(const StringUsed &rhs) { // expected-note{{Assuming rhs == *this}} expected-note{{Assuming rhs == *this}} expected-note{{Assuming rhs != *this}}
-  clang_analyzer_eval(*this == rhs); // expected-warning{{TRUE}} expected-warning{{UNKNOWN}} expected-note{{TRUE}} expected-note{{UNKNOWN}}
+StringUsed &StringUsed::operator=(const StringUsed &rhs) {
+  // expected-note@-1{{Assuming rhs == *this}}
+  // expected-note@-2{{Assuming rhs == *this}}
+  // expected-note@-3{{Assuming rhs != *this}}
+  clang_analyzer_eval(*this == rhs); // expected-warning{{TRUE}}
+ // expected-warning@-1{{UNKNOWN}}
+ // expected-note@-2{{TRUE}}
+ // expected-note@-3{{UNKNOWN}}
   free(str); // expected-note{{Memory is released}}
-  str = strdup(rhs.str); // expected-warning{{Use of memory after it is freed}}  expected-note{{Use of memory after it is freed}}
-// expected-note@-1{{Memory is allocated}}
+  str = strdup(rhs.str); // expected-warning{{Use of memory after it is freed}}
+ // expected-note@-1{{Use of memory after it is freed}}
+ // expected-note@-2{{Memory is allocated}}
   return *this;
 }
 
-StringUsed& StringUsed::operator=(StringUsed &&rhs) { // expected-note{{Assuming rhs == *this}} expected-note{{Assuming rhs != *this}}
-  clang_analyzer_eval(*this == rhs); // expected-warning{{TRUE}} expected-warning{{UNKNOWN}} expected-note{{TRUE}} expected-note{{UNKNOWN}}
+StringUsed &StringUsed::operator=(StringUsed &&rhs) {
+  // expected-note@-1{{Assuming rhs == *this}}
+  // expected-note@-2{{Assuming rhs != *this}}
+  clang_analyzer_eval(*this == rhs); // expected-warning{{TRUE}}
+ // expected-warning@-1{{UNKNOWN}}
+ // expected-note@-2{{TRUE}}
+ // expected-note@-3{{UNKNOWN}}
   str = rhs.str;
-  rhs.str = nullptr; // expected-war

[PATCH] D105254: [RISCV] Support machine constraint "S"

2021-07-12 Thread Luís Marques via Phabricator via cfe-commits
luismarques accepted this revision.
luismarques added a comment.
This revision is now accepted and ready to land.

In D105254#2852489 , @luismarques 
wrote:

> Makes sense. Let's wait for the GCC Bugzilla feedback.

With 'S' now documented on the GNU side, I think this can be merged.

Would we keep this constraint forever regardless of how discussions of [1] 
might evolve?

[1] https://github.com/riscv/riscv-elf-psabi-doc/issues/197


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105254

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


[PATCH] D105821: [analyzer] [WIP] Model destructor for std::unique_ptr

2021-07-12 Thread Deep Majumder via Phabricator via cfe-commits
RedDocMD created this revision.
RedDocMD added reviewers: NoQ, vsavchenko, xazax.hun, teemperor.
Herald added subscribers: manas, steakhal, ASDenysPetrov, martong, dkrupp, 
donat.nagy, Szelethus, mikhail.ramalho, a.sidorin, rnkovacs, szepet, 
baloghadamsoftware.
RedDocMD requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

This is probably a "throw-away" patch which attempts
to model automatic implicit destructor calls.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D105821

Files:
  clang/include/clang/Analysis/ProgramPoint.h
  clang/lib/StaticAnalyzer/Checkers/SmartPtrModeling.cpp
  clang/lib/StaticAnalyzer/Core/CheckerManager.cpp
  clang/lib/StaticAnalyzer/Core/CoreEngine.cpp
  clang/lib/StaticAnalyzer/Core/ExprEngineCXX.cpp

Index: clang/lib/StaticAnalyzer/Core/ExprEngineCXX.cpp
===
--- clang/lib/StaticAnalyzer/Core/ExprEngineCXX.cpp
+++ clang/lib/StaticAnalyzer/Core/ExprEngineCXX.cpp
@@ -19,6 +19,7 @@
 #include "clang/StaticAnalyzer/Core/CheckerManager.h"
 #include "clang/StaticAnalyzer/Core/PathSensitive/AnalysisManager.h"
 #include "clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h"
+#include "llvm/Support/raw_ostream.h"
 
 using namespace clang;
 using namespace ento;
@@ -757,6 +758,7 @@
   for (ExplodedNodeSet::iterator I = DstPreCall.begin(), E = DstPreCall.end();
I != E; ++I)
 defaultEvalCall(Bldr, *I, *Call, CallOpts);
+  // getCheckerManager().runCheckersForEvalCall(DstInvalidated, DstPreCall, *Call, *this, CallOpts);
 
   getCheckerManager().runCheckersForPostCall(Dst, DstInvalidated,
  *Call, *this);
Index: clang/lib/StaticAnalyzer/Core/CoreEngine.cpp
===
--- clang/lib/StaticAnalyzer/Core/CoreEngine.cpp
+++ clang/lib/StaticAnalyzer/Core/CoreEngine.cpp
@@ -181,6 +181,10 @@
   dispatchWorkItem(Pred, PNode->getLocation(), WU);
   break;
 }
+case ProgramPoint::DestructorCallKind:
+  // Literally do nothing, since there is no real statement
+  // So there is nothing to be done.
+  break;
 default:
   assert(Loc.getAs() ||
  Loc.getAs() ||
Index: clang/lib/StaticAnalyzer/Core/CheckerManager.cpp
===
--- clang/lib/StaticAnalyzer/Core/CheckerManager.cpp
+++ clang/lib/StaticAnalyzer/Core/CheckerManager.cpp
@@ -664,14 +664,20 @@
 for (const auto &EvalCallChecker : EvalCallCheckers) {
   // TODO: Support the situation when the call doesn't correspond
   // to any Expr.
-  ProgramPoint L = ProgramPoint::getProgramPoint(
-  Call.getOriginExpr(), ProgramPoint::PostStmtKind,
+  llvm::Optional LOpt;
+  const Expr *OriginExpr = Call.getOriginExpr();
+  if (OriginExpr) {
+LOpt = ProgramPoint::getProgramPoint(
+  OriginExpr, ProgramPoint::PostStmtKind,
   Pred->getLocationContext(), EvalCallChecker.Checker);
+  } else {
+LOpt = DestructorCallPoint(Pred->getLocationContext(), EvalCallChecker.Checker);
+  }
   bool evaluated = false;
   { // CheckerContext generates transitions(populates checkDest) on
 // destruction, so introduce the scope to make sure it gets properly
 // populated.
-CheckerContext C(B, Eng, Pred, L);
+CheckerContext C(B, Eng, Pred, *LOpt);
 evaluated = EvalCallChecker(Call, C);
   }
   assert(!(evaluated && anyEvaluated)
Index: clang/lib/StaticAnalyzer/Checkers/SmartPtrModeling.cpp
===
--- clang/lib/StaticAnalyzer/Checkers/SmartPtrModeling.cpp
+++ clang/lib/StaticAnalyzer/Checkers/SmartPtrModeling.cpp
@@ -29,6 +29,7 @@
 #include "clang/StaticAnalyzer/Core/PathSensitive/SVals.h"
 #include "clang/StaticAnalyzer/Core/PathSensitive/SymExpr.h"
 #include "clang/StaticAnalyzer/Core/PathSensitive/SymbolManager.h"
+#include "llvm/Support/raw_ostream.h"
 #include 
 
 using namespace clang;
@@ -177,7 +178,9 @@
 
 bool SmartPtrModeling::evalCall(const CallEvent &Call,
 CheckerContext &C) const {
+
   ProgramStateRef State = C.getState();
+  Call.dump();
   if (!smartptr::isStdSmartPtrCall(Call))
 return false;
 
@@ -261,6 +264,11 @@
 return true;
   }
 
+  if (const auto *DC = dyn_cast(&Call)) {
+llvm::errs() << "Wohoo\n";
+return true;
+  }
+
   if (handleAssignOp(Call, C))
 return true;
 
Index: clang/include/clang/Analysis/ProgramPoint.h
===
--- clang/include/clang/Analysis/ProgramPoint.h
+++ clang/include/clang/Analysis/ProgramPoint.h
@@ -84,7 +84,8 @@
   MinImplicitCallKind = PreImplicitCallKind,
   MaxImplicitCallKind = PostImplicitCallKind,
   LoopExitKind,
-  EpsilonKind};
+  

[clang] 2071ce9 - [Altivec] Use signed comparison for vec_all_* and vec_any_* interfaces

2021-07-12 Thread Bardia Mahjour via cfe-commits

Author: Bardia Mahjour
Date: 2021-07-12T11:41:16-04:00
New Revision: 2071ce9d4559d444a065d78248a7381bf121b766

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

LOG: [Altivec] Use signed comparison for vec_all_* and vec_any_* interfaces

We are currently being inconsistent in using signed vs unsigned comparisons for
vec_all_* and vec_any_* interfaces that use vector bool types. For example we
use signed comparison for vec_all_ge(vector signed char, vector bool char) but
unsigned comparison for when the arguments are swapped. GCC and XL use signed
comparison instead. This patch makes clang consistent with itself and with XL
and GCC.

Reviewed By: nemanjai

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

Added: 


Modified: 
clang/lib/Headers/altivec.h
clang/test/CodeGen/builtins-ppc-altivec.c
clang/test/CodeGen/builtins-ppc-vsx.c

Removed: 




diff  --git a/clang/lib/Headers/altivec.h b/clang/lib/Headers/altivec.h
index 35dde8203b7f..862ec290e1c9 100644
--- a/clang/lib/Headers/altivec.h
+++ b/clang/lib/Headers/altivec.h
@@ -14894,8 +14894,7 @@ static __inline__ int __ATTRS_o_ai vec_all_ge(vector 
unsigned char __a,
 
 static __inline__ int __ATTRS_o_ai vec_all_ge(vector bool char __a,
   vector signed char __b) {
-  return __builtin_altivec_vcmpgtub_p(__CR6_EQ, (vector unsigned char)__b,
-  (vector unsigned char)__a);
+  return __builtin_altivec_vcmpgtsb_p(__CR6_EQ, __b, (vector signed char)__a);
 }
 
 static __inline__ int __ATTRS_o_ai vec_all_ge(vector bool char __a,
@@ -14932,8 +14931,7 @@ static __inline__ int __ATTRS_o_ai vec_all_ge(vector 
unsigned short __a,
 
 static __inline__ int __ATTRS_o_ai vec_all_ge(vector bool short __a,
   vector short __b) {
-  return __builtin_altivec_vcmpgtuh_p(__CR6_EQ, (vector unsigned short)__b,
-  (vector unsigned short)__a);
+  return __builtin_altivec_vcmpgtsh_p(__CR6_EQ, __b, (vector signed short)__a);
 }
 
 static __inline__ int __ATTRS_o_ai vec_all_ge(vector bool short __a,
@@ -14969,8 +14967,7 @@ static __inline__ int __ATTRS_o_ai vec_all_ge(vector 
unsigned int __a,
 
 static __inline__ int __ATTRS_o_ai vec_all_ge(vector bool int __a,
   vector int __b) {
-  return __builtin_altivec_vcmpgtuw_p(__CR6_EQ, (vector unsigned int)__b,
-  (vector unsigned int)__a);
+  return __builtin_altivec_vcmpgtsw_p(__CR6_EQ, __b, (vector signed int)__a);
 }
 
 static __inline__ int __ATTRS_o_ai vec_all_ge(vector bool int __a,
@@ -15008,8 +15005,8 @@ static __inline__ int __ATTRS_o_ai vec_all_ge(vector 
unsigned long long __a,
 
 static __inline__ int __ATTRS_o_ai vec_all_ge(vector bool long long __a,
   vector signed long long __b) {
-  return __builtin_altivec_vcmpgtud_p(__CR6_EQ, (vector unsigned long long)__b,
-  (vector unsigned long long)__a);
+  return __builtin_altivec_vcmpgtsd_p(__CR6_EQ, __b,
+  (vector signed long long)__a);
 }
 
 static __inline__ int __ATTRS_o_ai vec_all_ge(vector bool long long __a,
@@ -15077,8 +15074,7 @@ static __inline__ int __ATTRS_o_ai vec_all_gt(vector 
unsigned char __a,
 
 static __inline__ int __ATTRS_o_ai vec_all_gt(vector bool char __a,
   vector signed char __b) {
-  return __builtin_altivec_vcmpgtub_p(__CR6_LT, (vector unsigned char)__a,
-  (vector unsigned char)__b);
+  return __builtin_altivec_vcmpgtsb_p(__CR6_LT, (vector signed char)__a, __b);
 }
 
 static __inline__ int __ATTRS_o_ai vec_all_gt(vector bool char __a,
@@ -15115,8 +15111,7 @@ static __inline__ int __ATTRS_o_ai vec_all_gt(vector 
unsigned short __a,
 
 static __inline__ int __ATTRS_o_ai vec_all_gt(vector bool short __a,
   vector short __b) {
-  return __builtin_altivec_vcmpgtuh_p(__CR6_LT, (vector unsigned short)__a,
-  (vector unsigned short)__b);
+  return __builtin_altivec_vcmpgtsh_p(__CR6_LT, (vector signed short)__a, __b);
 }
 
 static __inline__ int __ATTRS_o_ai vec_all_gt(vector bool short __a,
@@ -15152,8 +15147,7 @@ static __inline__ int __ATTRS_o_ai vec_all_gt(vector 
unsigned int __a,
 
 static __inline__ int __ATTRS_o_ai vec_all_gt(vector bool int __a,
   vector int __b) {
-  return __builtin_altivec_vcmpgtuw_p(__CR6_LT, (vector unsigned int)__a,
-  (vector unsigned int)__b);
+  return __builtin_altivec_vcmpgtsw_p(__CR6_LT, (vect

[PATCH] D105666: [PowerPC] [Altivec] Use signed comparison for vec_all_* and vec_any_* interfaces that compare vector bool types with vector signed types

2021-07-12 Thread Bardia Mahjour 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 rG2071ce9d4559: [Altivec] Use signed comparison for vec_all_* 
and vec_any_* interfaces (authored by bmahjour).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105666

Files:
  clang/lib/Headers/altivec.h
  clang/test/CodeGen/builtins-ppc-altivec.c
  clang/test/CodeGen/builtins-ppc-vsx.c

Index: clang/test/CodeGen/builtins-ppc-vsx.c
===
--- clang/test/CodeGen/builtins-ppc-vsx.c
+++ clang/test/CodeGen/builtins-ppc-vsx.c
@@ -2724,8 +2724,8 @@
   // CHECK-LE: @llvm.ppc.altivec.vcmpgtud.p
 
   res_i = vec_all_ge(vbll, vsll);
-  // CHECK: @llvm.ppc.altivec.vcmpgtud.p
-  // CHECK-LE: @llvm.ppc.altivec.vcmpgtud.p
+  // CHECK: @llvm.ppc.altivec.vcmpgtsd.p
+  // CHECK-LE: @llvm.ppc.altivec.vcmpgtsd.p
 
   res_i = vec_all_ge(vbll, vull);
   // CHECK: @llvm.ppc.altivec.vcmpgtud.p
@@ -2753,8 +2753,8 @@
   // CHECK-LE: @llvm.ppc.altivec.vcmpgtud.p
 
   res_i = vec_all_gt(vbll, vsll);
-  // CHECK: @llvm.ppc.altivec.vcmpgtud.p
-  // CHECK-LE: @llvm.ppc.altivec.vcmpgtud.p
+  // CHECK: @llvm.ppc.altivec.vcmpgtsd.p
+  // CHECK-LE: @llvm.ppc.altivec.vcmpgtsd.p
 
   res_i = vec_all_gt(vbll, vull);
   // CHECK: @llvm.ppc.altivec.vcmpgtud.p
@@ -2782,8 +2782,8 @@
   // CHECK-LE: @llvm.ppc.altivec.vcmpgtud.p
 
   res_i = vec_all_le(vbll, vsll);
-  // CHECK: @llvm.ppc.altivec.vcmpgtud.p
-  // CHECK-LE: @llvm.ppc.altivec.vcmpgtud.p
+  // CHECK: @llvm.ppc.altivec.vcmpgtsd.p
+  // CHECK-LE: @llvm.ppc.altivec.vcmpgtsd.p
 
   res_i = vec_all_le(vbll, vull);
   // CHECK: @llvm.ppc.altivec.vcmpgtud.p
@@ -2811,8 +2811,8 @@
   // CHECK-LE: @llvm.ppc.altivec.vcmpgtud.p
 
   res_i = vec_all_lt(vbll, vsll);
-  // CHECK: @llvm.ppc.altivec.vcmpgtud.p
-  // CHECK-LE: @llvm.ppc.altivec.vcmpgtud.p
+  // CHECK: @llvm.ppc.altivec.vcmpgtsd.p
+  // CHECK-LE: @llvm.ppc.altivec.vcmpgtsd.p
 
   res_i = vec_all_lt(vbll, vull);
   // CHECK: @llvm.ppc.altivec.vcmpgtud.p
@@ -2840,8 +2840,8 @@
   // CHECK-LE: @llvm.ppc.altivec.vcmpgtud.p
 
   res_i = vec_any_ge(vbll, vsll);
-  // CHECK: @llvm.ppc.altivec.vcmpgtud.p
-  // CHECK-LE: @llvm.ppc.altivec.vcmpgtud.p
+  // CHECK: @llvm.ppc.altivec.vcmpgtsd.p
+  // CHECK-LE: @llvm.ppc.altivec.vcmpgtsd.p
 
   res_i = vec_any_ge(vbll, vull);
   // CHECK: @llvm.ppc.altivec.vcmpgtud.p
@@ -2869,8 +2869,8 @@
   // CHECK-LE: @llvm.ppc.altivec.vcmpgtud.p
 
   res_i = vec_any_gt(vbll, vsll);
-  // CHECK: @llvm.ppc.altivec.vcmpgtud.p
-  // CHECK-LE: @llvm.ppc.altivec.vcmpgtud.p
+  // CHECK: @llvm.ppc.altivec.vcmpgtsd.p
+  // CHECK-LE: @llvm.ppc.altivec.vcmpgtsd.p
 
   res_i = vec_any_gt(vbll, vull);
   // CHECK: @llvm.ppc.altivec.vcmpgtud.p
@@ -2898,8 +2898,8 @@
   // CHECK-LE: @llvm.ppc.altivec.vcmpgtud.p
 
   res_i = vec_any_le(vbll, vsll);
-  // CHECK: @llvm.ppc.altivec.vcmpgtud.p
-  // CHECK-LE: @llvm.ppc.altivec.vcmpgtud.p
+  // CHECK: @llvm.ppc.altivec.vcmpgtsd.p
+  // CHECK-LE: @llvm.ppc.altivec.vcmpgtsd.p
 
   res_i = vec_any_le(vbll, vull);
   // CHECK: @llvm.ppc.altivec.vcmpgtud.p
@@ -2927,8 +2927,8 @@
   // CHECK-LE: @llvm.ppc.altivec.vcmpgtud.p
 
   res_i = vec_any_lt(vbll, vsll);
-  // CHECK: @llvm.ppc.altivec.vcmpgtud.p
-  // CHECK-LE: @llvm.ppc.altivec.vcmpgtud.p
+  // CHECK: @llvm.ppc.altivec.vcmpgtsd.p
+  // CHECK-LE: @llvm.ppc.altivec.vcmpgtsd.p
 
   res_i = vec_any_lt(vbll, vull);
   // CHECK: @llvm.ppc.altivec.vcmpgtud.p
Index: clang/test/CodeGen/builtins-ppc-altivec.c
===
--- clang/test/CodeGen/builtins-ppc-altivec.c
+++ clang/test/CodeGen/builtins-ppc-altivec.c
@@ -8097,8 +8097,8 @@
 // CHECK-LE: @llvm.ppc.altivec.vcmpgtub.p
 
   res_i = vec_all_ge(vbc, vsc);
-// CHECK: @llvm.ppc.altivec.vcmpgtub.p
-// CHECK-LE: @llvm.ppc.altivec.vcmpgtub.p
+// CHECK: @llvm.ppc.altivec.vcmpgtsb.p
+// CHECK-LE: @llvm.ppc.altivec.vcmpgtsb.p
 
   res_i = vec_all_ge(vbc, vuc);
 // CHECK: @llvm.ppc.altivec.vcmpgtub.p
@@ -8125,8 +8125,8 @@
 // CHECK-LE: @llvm.ppc.altivec.vcmpgtuh.p
 
   res_i = vec_all_ge(vbs, vs);
-// CHECK: @llvm.ppc.altivec.vcmpgtuh.p
-// CHECK-LE: @llvm.ppc.altivec.vcmpgtuh.p
+// CHECK: @llvm.ppc.altivec.vcmpgtsh.p
+// CHECK-LE: @llvm.ppc.altivec.vcmpgtsh.p
 
   res_i = vec_all_ge(vbs, vus);
 // CHECK: @llvm.ppc.altivec.vcmpgtuh.p
@@ -8153,8 +8153,8 @@
 // CHECK-LE: @llvm.ppc.altivec.vcmpgtuw.p
 
   res_i = vec_all_ge(vbi, vi);
-// CHECK: @llvm.ppc.altivec.vcmpgtuw.p
-// CHECK-LE: @llvm.ppc.altivec.vcmpgtuw.p
+// CHECK: @llvm.ppc.altivec.vcmpgtsw.p
+// CHECK-LE: @llvm.ppc.altivec.vcmpgtsw.p
 
   res_i = vec_all_ge(vbi, vui);
 // CHECK: @llvm.ppc.altivec.vcmpgtuw.p
@@ -8186,8 +8186,8 @@
 // CHECK-LE: @llvm.ppc.altivec.vcmpgtub.p
 
   res_i = vec_all_gt(vbc, vsc);
-// CHECK: @llvm.ppc.altivec.vcmpgtub.p
-// CHECK-LE: @llvm.ppc.altivec.vcmpgtub.p
+// CHECK: 

[PATCH] D105439: [clang] protects users from relying on libc++ detail headers

2021-07-12 Thread Christopher Di Bella via Phabricator via cfe-commits
cjdb added a comment.

Ping @aaron.ballman and @ldionne


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105439

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


[clang] ef49d92 - [PowerPC] Implement trap and conversion builtins for XL compatibility

2021-07-12 Thread Albion Fung via cfe-commits

Author: Albion Fung
Date: 2021-07-12T11:04:17-05:00
New Revision: ef49d925e2a788248473b847a0e51835c6ca854f

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

LOG: [PowerPC] Implement trap and conversion builtins for XL compatibility

This patch implements trap and FP to and from double conversions. The builtins
generate code that mirror what is generated from the XL compiler. Intrinsics
are named conventionally with builtin_ppc, but are aliased to provide the same
builtin names as the XL compiler.

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

Added: 
clang/test/CodeGen/builtins-ppc-xlcompat-conversionfunc.c
clang/test/CodeGen/builtins-ppc-xlcompat-error.c
clang/test/CodeGen/builtins-ppc-xlcompat-trap-64bit-only.c
clang/test/CodeGen/builtins-ppc-xlcompat-trap.c
llvm/test/CodeGen/PowerPC/builtins-ppc-xlcompat-conversionfunc.ll
llvm/test/CodeGen/PowerPC/builtins-ppc-xlcompat-trap-64bit-only.ll
llvm/test/CodeGen/PowerPC/builtins-ppc-xlcompat-trap.ll

Modified: 
clang/include/clang/Basic/BuiltinsPPC.def
clang/lib/Basic/Targets/PPC.cpp
clang/lib/Sema/SemaChecking.cpp
llvm/include/llvm/IR/IntrinsicsPowerPC.td
llvm/lib/Target/PowerPC/PPCInstr64Bit.td
llvm/lib/Target/PowerPC/PPCInstrInfo.td

Removed: 




diff  --git a/clang/include/clang/Basic/BuiltinsPPC.def 
b/clang/include/clang/Basic/BuiltinsPPC.def
index baaf5db9d1453..6a72cc089df7e 100644
--- a/clang/include/clang/Basic/BuiltinsPPC.def
+++ b/clang/include/clang/Basic/BuiltinsPPC.def
@@ -59,6 +59,18 @@ BUILTIN(__builtin_ppc_ldarx, "LiLiD*", "")
 BUILTIN(__builtin_ppc_lwarx, "iiD*", "")
 BUILTIN(__builtin_ppc_stdcx, "iLiD*Li", "")
 BUILTIN(__builtin_ppc_stwcx, "iiD*i", "")
+BUILTIN(__builtin_ppc_tdw, "vLLiLLiIUi", "")
+BUILTIN(__builtin_ppc_tw, "viiIUi", "")
+BUILTIN(__builtin_ppc_trap, "vi", "")
+BUILTIN(__builtin_ppc_trapd, "vLi", "")
+BUILTIN(__builtin_ppc_fcfid, "dd", "")
+BUILTIN(__builtin_ppc_fcfud, "dd", "")
+BUILTIN(__builtin_ppc_fctid, "dd", "")
+BUILTIN(__builtin_ppc_fctidz, "dd", "")
+BUILTIN(__builtin_ppc_fctiw, "dd", "")
+BUILTIN(__builtin_ppc_fctiwz, "dd", "")
+BUILTIN(__builtin_ppc_fctudz, "dd", "")
+BUILTIN(__builtin_ppc_fctuwz, "dd", "")
 
 BUILTIN(__builtin_ppc_get_timebase, "ULLi", "n")
 

diff  --git a/clang/lib/Basic/Targets/PPC.cpp b/clang/lib/Basic/Targets/PPC.cpp
index e3c77b2e4450b..b77b4a38bc46f 100644
--- a/clang/lib/Basic/Targets/PPC.cpp
+++ b/clang/lib/Basic/Targets/PPC.cpp
@@ -112,6 +112,18 @@ static void defineXLCompatMacros(MacroBuilder &Builder) {
   Builder.defineMacro("__lwarx", "__builtin_ppc_lwarx");
   Builder.defineMacro("__stdcx", "__builtin_ppc_stdcx");
   Builder.defineMacro("__stwcx", "__builtin_ppc_stwcx");
+  Builder.defineMacro("__tdw", "__builtin_ppc_tdw");
+  Builder.defineMacro("__tw", "__builtin_ppc_tw");
+  Builder.defineMacro("__trap", "__builtin_ppc_trap");
+  Builder.defineMacro("__trapd", "__builtin_ppc_trapd");
+  Builder.defineMacro("__fcfid", "__builtin_ppc_fcfid");
+  Builder.defineMacro("__fcfud", "__builtin_ppc_fcfud");
+  Builder.defineMacro("__fctid", "__builtin_ppc_fctid");
+  Builder.defineMacro("__fctidz", "__builtin_ppc_fctidz");
+  Builder.defineMacro("__fctiw", "__builtin_ppc_fctiw");
+  Builder.defineMacro("__fctiwz", "__builtin_ppc_fctiwz");
+  Builder.defineMacro("__fctudz", "__builtin_ppc_fctudz");
+  Builder.defineMacro("__fctuwz", "__builtin_ppc_fctuwz");
 }
 
 /// PPCTargetInfo::getTargetDefines - Return a set of the PowerPC-specific

diff  --git a/clang/lib/Sema/SemaChecking.cpp b/clang/lib/Sema/SemaChecking.cpp
index 64d838d2cd74f..99621a226dea6 100644
--- a/clang/lib/Sema/SemaChecking.cpp
+++ b/clang/lib/Sema/SemaChecking.cpp
@@ -3267,6 +3267,8 @@ static bool isPPC_64Builtin(unsigned BuiltinID) {
   case PPC::BI__builtin_bpermd:
   case PPC::BI__builtin_ppc_ldarx:
   case PPC::BI__builtin_ppc_stdcx:
+  case PPC::BI__builtin_ppc_tdw:
+  case PPC::BI__builtin_ppc_trapd:
 return true;
   }
   return false;
@@ -3347,6 +3349,9 @@ bool Sema::CheckPPCBuiltinFunctionCall(const TargetInfo 
&TI, unsigned BuiltinID,
  return SemaBuiltinConstantArgRange(TheCall, 2, 0, 7);
   case PPC::BI__builtin_vsx_xxpermx:
  return SemaBuiltinConstantArgRange(TheCall, 3, 0, 7);
+  case PPC::BI__builtin_ppc_tw:
+  case PPC::BI__builtin_ppc_tdw:
+return SemaBuiltinConstantArgRange(TheCall, 2, 0, 31);
 #define CUSTOM_BUILTIN(Name, Intr, Types, Acc) \
   case PPC::BI__builtin_##Name: \
 return SemaBuiltinPPCMMACall(TheCall, Types);

diff  --git a/clang/test/CodeGen/builtins-ppc-xlcompat-conversionfunc.c 
b/clang/test/CodeGen/builtins-ppc-xlcompat-conversionfunc.c
new file mode 100644
index 0..babc16fcd3a7e
--- /dev/null
+++ b/clang/test/CodeGen/builtins-ppc-xlcompat-conversionfunc.c
@@ -0,0 +1,121 

[PATCH] D103668: [PowerPC] Implement trap and conversion builtins for XL compatibility

2021-07-12 Thread Albion Fung via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGef49d925e2a7: [PowerPC] Implement trap and conversion 
builtins for XL compatibility (authored by Conanap).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D103668

Files:
  clang/include/clang/Basic/BuiltinsPPC.def
  clang/lib/Basic/Targets/PPC.cpp
  clang/lib/Sema/SemaChecking.cpp
  clang/test/CodeGen/builtins-ppc-xlcompat-conversionfunc.c
  clang/test/CodeGen/builtins-ppc-xlcompat-error.c
  clang/test/CodeGen/builtins-ppc-xlcompat-trap-64bit-only.c
  clang/test/CodeGen/builtins-ppc-xlcompat-trap.c
  llvm/include/llvm/IR/IntrinsicsPowerPC.td
  llvm/lib/Target/PowerPC/PPCInstr64Bit.td
  llvm/lib/Target/PowerPC/PPCInstrInfo.td
  llvm/test/CodeGen/PowerPC/builtins-ppc-xlcompat-conversionfunc.ll
  llvm/test/CodeGen/PowerPC/builtins-ppc-xlcompat-trap-64bit-only.ll
  llvm/test/CodeGen/PowerPC/builtins-ppc-xlcompat-trap.ll

Index: llvm/test/CodeGen/PowerPC/builtins-ppc-xlcompat-trap.ll
===
--- /dev/null
+++ llvm/test/CodeGen/PowerPC/builtins-ppc-xlcompat-trap.ll
@@ -0,0 +1,139 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
+; 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=pwr7 < %s | FileCheck %s
+; RUN: llc -verify-machineinstrs -mtriple=powerpc-unknown-aix \
+; RUN:   -mcpu=pwr8 < %s | FileCheck %s
+; RUN: llc -verify-machineinstrs -mtriple=powerpc64-unknown-aix \
+; RUN:   -mcpu=pwr8 < %s | FileCheck %s
+
+; tw
+declare void @llvm.ppc.tw(i32 %a, i32 %b, i32 %c)
+define dso_local void @test__twlgt(i32 %a, i32 %b) {
+; CHECK-LABEL: test__twlgt:
+; CHECK:   # %bb.0:
+; CHECK-NEXT:twlgt 3, 4
+; CHECK-NEXT:blr
+  call void @llvm.ppc.tw(i32 %a, i32 %b, i32 1)
+  ret void
+}
+
+define dso_local void @test__twllt(i32 %a, i32 %b) {
+; CHECK-LABEL: test__twllt:
+; CHECK:   # %bb.0:
+; CHECK-NEXT:twllt 3, 4
+; CHECK-NEXT:blr
+  call void @llvm.ppc.tw(i32 %a, i32 %b, i32 2)
+  ret void
+}
+
+define dso_local void @test__tw3(i32 %a, i32 %b) {
+; CHECK-LABEL: test__tw3:
+; CHECK:   # %bb.0:
+; CHECK-NEXT:tw 3, 3, 4
+; CHECK-NEXT:blr
+  call void @llvm.ppc.tw(i32 %a, i32 %b, i32 3)
+  ret void
+}
+
+define dso_local void @test__tweq(i32 %a, i32 %b) {
+; CHECK-LABEL: test__tweq:
+; CHECK:   # %bb.0:
+; CHECK-NEXT:tweq 3, 4
+; CHECK-NEXT:blr
+  call void @llvm.ppc.tw(i32 %a, i32 %b, i32 4)
+  ret void
+}
+
+define dso_local void @test__twlge(i32 %a, i32 %b) {
+; CHECK-LABEL: test__twlge:
+; CHECK:   # %bb.0:
+; CHECK-NEXT:tw 5, 3, 4
+; CHECK-NEXT:blr
+  call void @llvm.ppc.tw(i32 %a, i32 %b, i32 5)
+  ret void
+}
+
+define dso_local void @test__twlle(i32 %a, i32 %b) {
+; CHECK-LABEL: test__twlle:
+; CHECK:   # %bb.0:
+; CHECK-NEXT:tw 6, 3, 4
+; CHECK-NEXT:blr
+  call void @llvm.ppc.tw(i32 %a, i32 %b, i32 6)
+  ret void
+}
+
+define dso_local void @test__twgt(i32 %a, i32 %b) {
+; CHECK-LABEL: test__twgt:
+; CHECK:   # %bb.0:
+; CHECK-NEXT:twgt 3, 4
+; CHECK-NEXT:blr
+  call void @llvm.ppc.tw(i32 %a, i32 %b, i32 8)
+  ret void
+}
+
+define dso_local void @test__twge(i32 %a, i32 %b) {
+; CHECK-LABEL: test__twge:
+; CHECK:   # %bb.0:
+; CHECK-NEXT:tw 12, 3, 4
+; CHECK-NEXT:blr
+  call void @llvm.ppc.tw(i32 %a, i32 %b, i32 12)
+  ret void
+}
+
+define dso_local void @test__twlt(i32 %a, i32 %b) {
+; CHECK-LABEL: test__twlt:
+; CHECK:   # %bb.0:
+; CHECK-NEXT:twlt 3, 4
+; CHECK-NEXT:blr
+  call void @llvm.ppc.tw(i32 %a, i32 %b, i32 16)
+  ret void
+}
+
+define dso_local void @test__twle(i32 %a, i32 %b) {
+; CHECK-LABEL: test__twle:
+; CHECK:   # %bb.0:
+; CHECK-NEXT:tw 20, 3, 4
+; CHECK-NEXT:blr
+  call void @llvm.ppc.tw(i32 %a, i32 %b, i32 20)
+  ret void
+}
+
+define dso_local void @test__twne24(i32 %a, i32 %b) {
+; CHECK-LABEL: test__twne24:
+; CHECK:   # %bb.0:
+; CHECK-NEXT:twne 3, 4
+; CHECK-NEXT:blr
+  call void @llvm.ppc.tw(i32 %a, i32 %b, i32 24)
+  ret void
+}
+
+define dso_local void @test__twu(i32 %a, i32 %b) {
+; CHECK-LABEL: test__twu:
+; CHECK:   # %bb.0:
+; CHECK-NEXT:twu 3, 4
+; CHECK-NEXT:blr
+  call void @llvm.ppc.tw(i32 %a, i32 %b, i32 31)
+  ret void
+}
+
+define dso_local void @test__tw_no_match(i32 %a, i32 %b) {
+; CHECK-LABEL: test__tw_no_match:
+; CHECK:   # %bb.0:
+; CHECK-NEXT:tw 13, 3, 4
+; CHECK-NEXT:blr
+  call void @llvm.ppc.tw(i32 %a, i32 %b, i32 13)
+  ret void
+}
+
+; trap
+declare void @llvm.ppc.trap(i32 %a)
+define dso_local void @test__trap(i32 %a) {
+; CHECK-LABEL: test__trap:
+; CHECK:   # %bb.0:
+; CHECK-NEXT:twnei 3, 0
+; CHECK-NEXT:blr
+  call void @llvm.ppc.trap(i32 %a)
+  ret void
+}
Index: llvm/test/

[PATCH] D105439: [clang] protects users from relying on libc++ detail headers

2021-07-12 Thread Arthur O'Dwyer via Phabricator via cfe-commits
Quuxplusone added a comment.

Given that the goal is to get `include-what-you-use` to stop suggesting that 
users `#include <__detail/fooimpl.h>` when what they want is spelled ``, 
I think what's desired here (if anything) would be a pragma targeted at 
`include-what-you-use` (and other tools). Basically

  // in __detail/fooimpl.h
  #pragma clang public_header "foo.h"

This pragma can mostly be ignored by Clang; it's just up to those other tools 
to consume these pragmas and report the correct public header.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105439

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


[PATCH] D105439: [clang] protects users from relying on libc++ detail headers

2021-07-12 Thread Christopher Di Bella via Phabricator via cfe-commits
cjdb added a comment.

In D105439#2871429 , @Quuxplusone 
wrote:

> Given that the goal is to get `include-what-you-use` to stop suggesting that 
> users `#include <__detail/fooimpl.h>` when what they want is spelled 
> ``, I think what's desired here (if anything) would be a pragma 
> targeted at `include-what-you-use` (and other tools). Basically
>
>   // in __detail/fooimpl.h
>   #pragma clang public_header "foo.h"
>
> This pragma can mostly be ignored by Clang; it's just up to those other tools 
> to consume these pragmas and report the correct public header.

Thank you for your opinion. That is not the purpose of this patch.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105439

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


[PATCH] D103096: [analyzer] Implement cast for ranges of symbolic integers.

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

@vsavchenko I've updated the summary. I hope, I addressed your question. 
Currently, this patch has some issues and may not fully reflect the summary. 
I'll update it soon(not without your suggestions). Thanks.


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

https://reviews.llvm.org/D103096

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


[PATCH] D105765: Prepare Compiler-RT for GnuInstallDirs, matching libcxx, document all

2021-07-12 Thread John Ericson via Phabricator via cfe-commits
Ericson2314 marked an inline comment as done.
Ericson2314 added inline comments.



Comment at: compiler-rt/cmake/base-config-ix.cmake:97
+  else()
+set(temp_path "${temp_path}/${current_segment}")
+  endif()

phosek wrote:
> This isn't set before so it should be always empty in which case you'll end 
> up with an absolute path (that is `/${current_segment}`) right? Isn't that a 
> bug?
Eek! that's embarrassing. Turns out that testing with `-D` is more fraught than 
I thought, and I wasn't hitting that case. Fixed the bug and documented the 
`-D` subtlety too.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105765

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


[PATCH] D105765: Prepare Compiler-RT for GnuInstallDirs, matching libcxx

2021-07-12 Thread John Ericson via Phabricator via cfe-commits
Ericson2314 updated this revision to Diff 357969.
Ericson2314 added a comment.
Herald added projects: clang, libc++, libc++abi, libunwind.
Herald added subscribers: libcxx-commits, cfe-commits.
Herald added a reviewer: libc++.
Herald added a reviewer: libc++abi.
Herald added a reviewer: libunwind.

Fix bugs, add lots of docs


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105765

Files:
  clang/runtime/CMakeLists.txt
  compiler-rt/cmake/Modules/AddCompilerRT.cmake
  compiler-rt/cmake/Modules/CompilerRTDarwinUtils.cmake
  compiler-rt/cmake/Modules/CompilerRTUtils.cmake
  compiler-rt/cmake/base-config-ix.cmake
  compiler-rt/docs/BuildingCompilerRT.rst
  compiler-rt/include/CMakeLists.txt
  compiler-rt/lib/dfsan/CMakeLists.txt
  libcxx/CMakeLists.txt
  libcxx/docs/BuildingLibcxx.rst
  libcxxabi/CMakeLists.txt
  libunwind/CMakeLists.txt
  libunwind/docs/BuildingLibunwind.rst

Index: libunwind/docs/BuildingLibunwind.rst
===
--- libunwind/docs/BuildingLibunwind.rst
+++ libunwind/docs/BuildingLibunwind.rst
@@ -159,3 +159,10 @@
 .. option:: LIBUNWIND_SYSROOT
 
   Sysroot for cross compiling
+
+.. option:: LIBUNWIND_INSTALL_LIBRARY_DIR:PATH
+
+  **Default**: ``lib${LIBUNWIND_LIBDIR_SUFFIX}``
+
+  Path where built libunwind libraries should be installed. If a relative path,
+  relative to ``CMAKE_INSTALL_PREFIX``.
Index: libunwind/CMakeLists.txt
===
--- libunwind/CMakeLists.txt
+++ libunwind/CMakeLists.txt
@@ -116,17 +116,20 @@
 
 if(LLVM_ENABLE_PER_TARGET_RUNTIME_DIR AND NOT APPLE)
   set(LIBUNWIND_LIBRARY_DIR ${LLVM_LIBRARY_OUTPUT_INTDIR}/${LLVM_DEFAULT_TARGET_TRIPLE})
-  set(LIBUNWIND_INSTALL_LIBRARY_DIR lib${LLVM_LIBDIR_SUFFIX}/${LLVM_DEFAULT_TARGET_TRIPLE})
+  set(LIBUNWIND_INSTALL_LIBRARY_DIR lib${LLVM_LIBDIR_SUFFIX}/${LLVM_DEFAULT_TARGET_TRIPLE} CACHE PATH
+  "Path where built libunwind libraries should be installed.")
   if(LIBCXX_LIBDIR_SUBDIR)
 string(APPEND LIBUNWIND_LIBRARY_DIR /${LIBUNWIND_LIBDIR_SUBDIR})
 string(APPEND LIBUNWIND_INSTALL_LIBRARY_DIR /${LIBUNWIND_LIBDIR_SUBDIR})
   endif()
 elseif(LLVM_LIBRARY_OUTPUT_INTDIR)
   set(LIBUNWIND_LIBRARY_DIR ${LLVM_LIBRARY_OUTPUT_INTDIR})
-  set(LIBUNWIND_INSTALL_LIBRARY_DIR lib${LIBUNWIND_LIBDIR_SUFFIX})
+  set(LIBUNWIND_INSTALL_LIBRARY_DIR lib${LIBUNWIND_LIBDIR_SUFFIX} CACHE PATH
+  "Path where built libunwind libraries should be installed.")
 else()
   set(LIBUNWIND_LIBRARY_DIR ${CMAKE_BINARY_DIR}/lib${LIBUNWIND_LIBDIR_SUFFIX})
-  set(LIBUNWIND_INSTALL_LIBRARY_DIR lib${LIBUNWIND_LIBDIR_SUFFIX})
+  set(LIBUNWIND_INSTALL_LIBRARY_DIR lib${LIBUNWIND_LIBDIR_SUFFIX} CACHE PATH
+  "Path where built libunwind libraries should be installed.")
 endif()
 
 set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${LIBUNWIND_LIBRARY_DIR})
Index: libcxxabi/CMakeLists.txt
===
--- libcxxabi/CMakeLists.txt
+++ libcxxabi/CMakeLists.txt
@@ -195,7 +195,8 @@
 if(LLVM_ENABLE_PER_TARGET_RUNTIME_DIR AND NOT APPLE)
   set(LIBCXXABI_HEADER_DIR ${LLVM_BINARY_DIR})
   set(LIBCXXABI_LIBRARY_DIR ${LLVM_LIBRARY_OUTPUT_INTDIR}/${LLVM_DEFAULT_TARGET_TRIPLE})
-  set(LIBCXXABI_INSTALL_LIBRARY_DIR lib${LLVM_LIBDIR_SUFFIX}/${LLVM_DEFAULT_TARGET_TRIPLE})
+  set(LIBCXXABI_INSTALL_LIBRARY_DIR lib${LLVM_LIBDIR_SUFFIX}/${LLVM_DEFAULT_TARGET_TRIPLE} CACHE PATH
+  "Path where built libc++abi libraries should be installed.")
   if(LIBCXX_LIBDIR_SUBDIR)
 string(APPEND LIBCXXABI_LIBRARY_DIR /${LIBCXXABI_LIBDIR_SUBDIR})
 string(APPEND LIBCXXABI_INSTALL_LIBRARY_DIR /${LIBCXXABI_LIBDIR_SUBDIR})
@@ -203,11 +204,13 @@
 elseif(LLVM_LIBRARY_OUTPUT_INTDIR)
   set(LIBCXXABI_HEADER_DIR ${LLVM_BINARY_DIR})
   set(LIBCXXABI_LIBRARY_DIR ${LLVM_LIBRARY_OUTPUT_INTDIR})
-  set(LIBCXXABI_INSTALL_LIBRARY_DIR lib${LIBCXXABI_LIBDIR_SUFFIX})
+  set(LIBCXXABI_INSTALL_LIBRARY_DIR lib${LIBCXXABI_LIBDIR_SUFFIX} CACHE PATH
+  "Path where built libc++abi libraries should be installed.")
 else()
   set(LIBCXXABI_HEADER_DIR ${CMAKE_BINARY_DIR})
   set(LIBCXXABI_LIBRARY_DIR ${CMAKE_BINARY_DIR}/lib${LIBCXXABI_LIBDIR_SUFFIX})
-  set(LIBCXXABI_INSTALL_LIBRARY_DIR lib${LIBCXXABI_LIBDIR_SUFFIX})
+  set(LIBCXXABI_INSTALL_LIBRARY_DIR lib${LIBCXXABI_LIBDIR_SUFFIX} CACHE PATH
+  "Path where built libc++abi libraries should be installed.")
 endif()
 
 set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${LIBCXXABI_LIBRARY_DIR})
Index: libcxx/docs/BuildingLibcxx.rst
===
--- libcxx/docs/BuildingLibcxx.rst
+++ libcxx/docs/BuildingLibcxx.rst
@@ -251,6 +251,28 @@
This option can be used to enable or disable the filesystem components on
platforms that may not support them. For example on Windows.
 
+.. option:: LIBCXX_INSTALL_LIBRARY_DIR:PATH
+
+  **Default**: ``lib${LIBCXX_LIBDIR_SUFFIX}``
+
+  Path w

[PATCH] D105765: Prepare Compiler-RT for GnuInstallDirs, matching libcxx, document all

2021-07-12 Thread John Ericson via Phabricator via cfe-commits
Ericson2314 marked an inline comment as done.
Ericson2314 added inline comments.



Comment at: compiler-rt/docs/BuildingCompilerRT.rst:12-22
+The instructions on this page are aimed at vendors who ship Compiler-RT as 
part of an
+operating system distribution, a toolchain or similar shipping vehicules. If 
you
+are a user merely trying to use Compiler-RT in your program, you most likely 
want to
+refer to your vendor's documentation, or to the general documentation for using
+Compiler-RT :ref:`here `.
+
+.. warning::

Modeled this file off libc++'s, including taking these two paragraphs. They 
seem appropriate enough here.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105765

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


[PATCH] D104420: thread_local support for AIX

2021-07-12 Thread Jamie Schmeiser via Phabricator via cfe-commits
jamieschmeiser updated this revision to Diff 357970.
jamieschmeiser added a comment.

Respond to review comments:  Update to tests to create common LINUX/AIX 
portions.


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

https://reviews.llvm.org/D104420

Files:
  clang/lib/CodeGen/ItaniumCXXABI.cpp
  clang/test/CodeGenCXX/cxx11-thread-local-reference.cpp
  clang/test/CodeGenCXX/cxx11-thread-local-visibility.cpp
  clang/test/CodeGenCXX/cxx11-thread-local.cpp

Index: clang/test/CodeGenCXX/cxx11-thread-local.cpp
===
--- clang/test/CodeGenCXX/cxx11-thread-local.cpp
+++ clang/test/CodeGenCXX/cxx11-thread-local.cpp
@@ -1,19 +1,20 @@
-// RUN: %clang_cc1 -std=c++11 -emit-llvm %s -o - -triple x86_64-linux-gnu | FileCheck --check-prefix=CHECK --check-prefix=LINUX %s
-// RUN: %clang_cc1 -std=c++11 -emit-llvm %s -O2 -disable-llvm-passes -o - -triple x86_64-linux-gnu | FileCheck --check-prefix=CHECK --check-prefix=LINUX --check-prefix=CHECK-OPT %s
+// RUN: %clang_cc1 -std=c++11 -emit-llvm %s -o - -triple x86_64-linux-gnu | FileCheck --check-prefixes=CHECK,LINUX,LINUX_AIX %s
+// RUN: %clang_cc1 -std=c++11 -emit-llvm %s -O2 -disable-llvm-passes -o - -triple x86_64-linux-gnu | FileCheck --check-prefixes=CHECK,LINUX,LINUX_AIX,CHECK-OPT %s
 // RUN: %clang_cc1 -std=c++11 -femulated-tls -emit-llvm %s -o - \
-// RUN: -triple x86_64-linux-gnu 2>&1 | FileCheck --check-prefix=CHECK --check-prefix=LINUX %s
+// RUN: -triple x86_64-linux-gnu 2>&1 | FileCheck --check-prefixes=CHECK,LINUX,LINUX_AIX %s
 // RUN: %clang_cc1 -std=c++11 -emit-llvm %s -o - -triple x86_64-apple-darwin12 | FileCheck --check-prefix=CHECK --check-prefix=DARWIN %s
+// RUN: %clang_cc1 -std=c++11 -emit-llvm %s -o - -triple powerpc64-unknown-aix-xcoff | FileCheck --check-prefixes=CHECK,AIX,LINUX_AIX %s
 
-// RUN: %clang_cc1 -std=c++11 -fno-use-cxa-atexit -emit-llvm %s -o - -triple x86_64-linux-gnu | FileCheck --check-prefix=CHECK --check-prefix=LINUX %s
-// RUN: %clang_cc1 -std=c++11 -fno-use-cxa-atexit -emit-llvm %s -O2 -disable-llvm-passes -o - -triple x86_64-linux-gnu | FileCheck --check-prefix=CHECK --check-prefix=LINUX --check-prefix=CHECK-OPT %s
+// RUN: %clang_cc1 -std=c++11 -fno-use-cxa-atexit -emit-llvm %s -o - -triple x86_64-linux-gnu | FileCheck --check-prefixes=CHECK,LINUX,LINUX_AIX %s
+// RUN: %clang_cc1 -std=c++11 -fno-use-cxa-atexit -emit-llvm %s -O2 -disable-llvm-passes -o - -triple x86_64-linux-gnu | FileCheck --check-prefixes=CHECK,LINUX,LINUX_AIX,CHECK-OPT %s
 // RUN: %clang_cc1 -std=c++11 -fno-use-cxa-atexit -femulated-tls -emit-llvm %s -o - \
-// RUN: -triple x86_64-linux-gnu 2>&1 | FileCheck --check-prefix=CHECK --check-prefix=LINUX %s
+// RUN: -triple x86_64-linux-gnu 2>&1 | FileCheck --check-prefixes=CHECK,LINUX,LINUX_AIX %s
 // RUN: %clang_cc1 -std=c++11 -fno-use-cxa-atexit -emit-llvm %s -o - -triple x86_64-apple-darwin12 | FileCheck --check-prefix=CHECK --check-prefix=DARWIN %s
 
 int f();
 int g();
 
-// LINUX-DAG: @a ={{.*}} thread_local global i32 0
+// LINUX_AIX-DAG: @a ={{.*}} thread_local global i32 0
 // DARWIN-DAG: @a = internal thread_local global i32 0
 thread_local int a = f();
 extern thread_local int b;
@@ -23,7 +24,7 @@
 static thread_local int d = g();
 
 struct U { static thread_local int m; };
-// LINUX-DAG: @_ZN1U1mE ={{.*}} thread_local global i32 0
+// LINUX_AIX-DAG: @_ZN1U1mE ={{.*}} thread_local global i32 0
 // DARWIN-DAG: @_ZN1U1mE = internal thread_local global i32 0
 thread_local int U::m = f();
 
@@ -89,9 +90,9 @@
 
 // CHECK-DAG: @llvm.global_ctors = appending global {{.*}} @[[GLOBAL_INIT:[^ ]*]]
 
-// LINUX-DAG: @_ZTH1a ={{.*}} alias void (), void ()* @__tls_init
+// LINUX_AIX-DAG: @_ZTH1a ={{.*}} alias void (), void ()* @__tls_init
 // DARWIN-DAG: @_ZTH1a = internal alias void (), void ()* @__tls_init
-// LINUX-DAG: @_ZTHN1U1mE ={{.*}} alias void (), void ()* @__tls_init
+// LINUX_AIX-DAG: @_ZTHN1U1mE ={{.*}} alias void (), void ()* @__tls_init
 // DARWIN-DAG: @_ZTHN1U1mE = internal alias void (), void ()* @__tls_init
 // CHECK-DAG: @_ZTHN1VIiE1mE = linkonce_odr alias void (), void ()* @[[V_M_INIT:[^, ]*]]
 // CHECK-DAG: @_ZTHN1XIiE1mE = linkonce_odr alias void (), void ()* @[[X_M_INIT:[^, ]*]]
@@ -106,16 +107,16 @@
 // Individual variable initialization functions:
 
 // CHECK: define {{.*}} @[[A_INIT:.*]]()
-// CHECK: call i32 @_Z1fv()
+// CHECK: call{{.*}} i32 @_Z1fv()
 // CHECK-NEXT: store i32 {{.*}}, i32* @a, align 4
 
 // CHECK-LABEL: define{{.*}} i32 @_Z1fv()
 int f() {
   // CHECK: %[[GUARD:.*]] = load i8, i8* @_ZGVZ1fvE1n, align 1
   // CHECK: %[[NEED_INIT:.*]] = icmp eq i8 %[[GUARD]], 0
-  // CHECK: br i1 %[[NEED_INIT]]
+  // CHECK: br i1 %[[NEED_INIT]]{{.*}}
 
-  // CHECK: %[[CALL:.*]] = call i32 @_Z1gv()
+  // CHECK: %[[CALL:.*]] = call{{.*}} i32 @_Z1gv()
   // CHECK: store i32 %[[CALL]], i32* @_ZZ1fvE1n, align 4
   // CHECK: store i8 1, i8* @_ZGVZ1fvE1n
   // CHECK: br label
@@ -126,55 +127,57 @@
 }
 
 

[PATCH] D104381: [analyzer] Added a test case for PR46264

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

@NoQ Just a ping


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D104381

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


[PATCH] D105254: [RISCV] Support machine constraint "S"

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

In D105254#2871278 , @luismarques 
wrote:

> In D105254#2852489 , @luismarques 
> wrote:
>
>> Makes sense. Let's wait for the GCC Bugzilla feedback.
>
> With 'S' now documented on the GNU side, I think this can be merged.
>
> Would we keep this constraint forever regardless of how discussions of [1] 
> might evolve?
>
> [1] https://github.com/riscv/riscv-elf-psabi-doc/issues/197

'S' will be kept forever, independent of issue/197. 'S' is useful on its own, 
for explicitly specifying the access modes by inline asm (I can image that the 
Linux kernel will use 'S' someday).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105254

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


[PATCH] D105755: [WebAssembly] Custom combines for f32x4.demote_zero_f64x2

2021-07-12 Thread Thomas Lively via Phabricator via cfe-commits
tlively updated this revision to Diff 357983.
tlively added a comment.

- Check types of splats as well


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105755

Files:
  clang/include/clang/Basic/BuiltinsWebAssembly.def
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/lib/Headers/wasm_simd128.h
  clang/test/CodeGen/builtins-wasm.c
  clang/test/Headers/wasm.c
  llvm/include/llvm/IR/IntrinsicsWebAssembly.td
  llvm/lib/Target/WebAssembly/WebAssemblyISD.def
  llvm/lib/Target/WebAssembly/WebAssemblyISelLowering.cpp
  llvm/lib/Target/WebAssembly/WebAssemblyInstrSIMD.td
  llvm/test/CodeGen/WebAssembly/simd-conversions.ll
  llvm/test/CodeGen/WebAssembly/simd-intrinsics.ll

Index: llvm/test/CodeGen/WebAssembly/simd-intrinsics.ll
===
--- llvm/test/CodeGen/WebAssembly/simd-intrinsics.ll
+++ llvm/test/CodeGen/WebAssembly/simd-intrinsics.ll
@@ -1,4 +1,4 @@
-; RUN: llc < %s -asm-verbose=false -verify-machineinstrs -disable-wasm-fallthrough-return-opt -wasm-disable-explicit-locals -wasm-keep-registers -mattr=+simd128 | FileCheck %s
+; RUN: llc < %s -asm-verbose=false -verify-machineinstrs -disable-wasm-fallthrough-return-opt -wasm-disable-explicit-locals -wasm-keep-registers -mattr=+simd128 | FileCheck %s --check-prefixes=CHECK,SLOW
 ; RUN: llc < %s -asm-verbose=false -verify-machineinstrs -disable-wasm-fallthrough-return-opt -wasm-disable-explicit-locals -wasm-keep-registers -mattr=+simd128 -fast-isel | FileCheck %s
 
 ; Test that SIMD128 intrinsics lower as expected. These intrinsics are
@@ -542,6 +542,18 @@
   ret <4 x i32> %a
 }
 
+; CHECK-LABEL: trunc_sat_zero_s_v4i32_2:
+; CHECK-NEXT: .functype trunc_sat_zero_s_v4i32_2 (v128) -> (v128){{$}}
+; SLOW-NEXT: i32x4.trunc_sat_zero_f64x2_s $push[[R:[0-9]+]]=, $0{{$}}
+; SLOW-NEXT: return $pop[[R]]{{$}}
+declare <4 x i32> @llvm.fptosi.sat.v4i32.v4f64(<4 x double>)
+define <4 x i32> @trunc_sat_zero_s_v4i32_2(<2 x double> %x) {
+  %v = shufflevector <2 x double> %x, <2 x double> zeroinitializer,
+   <4 x i32> 
+  %a = call <4 x i32> @llvm.fptosi.sat.v4i32.v4f64(<4 x double> %v)
+  ret <4 x i32> %a
+}
+
 ; CHECK-LABEL: trunc_sat_zero_u_v4i32:
 ; CHECK-NEXT: .functype trunc_sat_zero_u_v4i32 (v128) -> (v128){{$}}
 ; CHECK-NEXT: i32x4.trunc_sat_zero_f64x2_u $push[[R:[0-9]+]]=, $0{{$}}
@@ -554,6 +566,18 @@
   ret <4 x i32> %a
 }
 
+; CHECK-LABEL: trunc_sat_zero_u_v4i32_2:
+; CHECK-NEXT: .functype trunc_sat_zero_u_v4i32_2 (v128) -> (v128){{$}}
+; SLOW-NEXT: i32x4.trunc_sat_zero_f64x2_u $push[[R:[0-9]+]]=, $0{{$}}
+; SLOW-NEXT: return $pop[[R]]{{$}}
+declare <4 x i32> @llvm.fptoui.sat.v4i32.v4f64(<4 x double>)
+define <4 x i32> @trunc_sat_zero_u_v4i32_2(<2 x double> %x) {
+  %v = shufflevector <2 x double> %x, <2 x double> zeroinitializer,
+   <4 x i32> 
+  %a = call <4 x i32> @llvm.fptoui.sat.v4i32.v4f64(<4 x double> %v)
+  ret <4 x i32> %a
+}
+
 ; ==
 ; 2 x i64
 ; ==
@@ -722,16 +746,6 @@
   ret <4 x float> %v
 }
 
-; CHECK-LABEL: demote_zero_v4f32:
-; CHECK-NEXT: .functype demote_zero_v4f32 (v128) -> (v128){{$}}
-; CHECK-NEXT: f32x4.demote_zero_f64x2 $push[[R:[0-9]+]]=, $0{{$}}
-; CHECK-NEXT: return $pop[[R]]{{$}}
-declare <4 x float> @llvm.wasm.demote.zero(<2 x double>)
-define <4 x float> @demote_zero_v4f32(<2 x double> %a) {
-  %v = call <4 x float> @llvm.wasm.demote.zero(<2 x double> %a)
-  ret <4 x float> %v
-}
-
 ; ==
 ; 2 x f64
 ; ==
Index: llvm/test/CodeGen/WebAssembly/simd-conversions.ll
===
--- llvm/test/CodeGen/WebAssembly/simd-conversions.ll
+++ llvm/test/CodeGen/WebAssembly/simd-conversions.ll
@@ -82,6 +82,30 @@
   ret <2 x i64> %a
 }
 
+; CHECK-LABEL: demote_zero_v4f32:
+; NO-SIMD128-NOT: f32x4
+; SIMD128-NEXT: .functype demote_zero_v4f32 (v128) -> (v128){{$}}
+; SIMD128-NEXT: f32x4.demote_zero_f64x2 $push[[R:[0-9]+]]=, $0
+; SIMD128-NEXT: return $pop[[R]]
+define <4 x float> @demote_zero_v4f32(<2 x double> %x) {
+  %v = shufflevector <2 x double> %x, <2 x double> zeroinitializer,
+ <4 x i32> 
+  %a = fptrunc <4 x double> %v to <4 x float>
+  ret <4 x float> %a
+}
+
+; CHECK-LABEL: demote_zero_v4f32_2:
+; NO-SIMD128-NOT: f32x4
+; SIMD128-NEXT: .functype demote_zero_v4f32_2 (v128) -> (v128){{$}}
+; SIMD128-NEXT: f32x4.demote_zero_f64x2 $push[[R:[0-9]+]]=, $0
+; SIMD128-NEXT: return $pop[[R]]
+define <4 x float> @demote_zero_v4f32_2(<2 x double> %x) {
+  %v = fptrunc <2 x double> %x to <2 x float>
+  %a = shufflevector <2 x float> %v, <2 x float> zeroinitializer,
+ <4 x i32> 
+  ret <4 x float> %a
+}
+
 ; CHECK-LABEL: convert_low_s_v2f6

[PATCH] D105755: [WebAssembly] Custom combines for f32x4.demote_zero_f64x2

2021-07-12 Thread Thomas Lively via Phabricator via cfe-commits
tlively added inline comments.



Comment at: clang/include/clang/Basic/BuiltinsWebAssembly.def:192-193
 
 TARGET_BUILTIN(__builtin_wasm_trunc_sat_zero_s_f64x2_i32x4, "V4iV2d", "nc", 
"simd128")
 TARGET_BUILTIN(__builtin_wasm_trunc_sat_zero_u_f64x2_i32x4, "V4UiV2d", "nc", 
"simd128")
-TARGET_BUILTIN(__builtin_wasm_demote_zero_f64x2_f32x4, "V4fV2d", "nc", 
"simd128")

aheejin wrote:
> If these share the same pattern, do we need these builtins?
Hmm, good point. Maybe not. I'll investigate that in a follow up.



Comment at: llvm/lib/Target/WebAssembly/WebAssemblyISelLowering.cpp:2367
+
+if (!IsZeroSplat(N->getOperand(1)))
+  return SDValue();

aheejin wrote:
> Do we not need to check if `N->getOpernad(1)` is a specific type, such as 
> `v2f32` or `v2i32`?
I think that the concat_vectors node ensures that the two sides have the same 
type, but I'll explicitly check to be safe.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105755

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


[PATCH] D105755: [WebAssembly] Custom combines for f32x4.demote_zero_f64x2

2021-07-12 Thread Thomas Lively 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 rGcbabfc63b1be: [WebAssembly] Custom combines for 
f32x4.demote_zero_f64x2 (authored by tlively).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105755

Files:
  clang/include/clang/Basic/BuiltinsWebAssembly.def
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/lib/Headers/wasm_simd128.h
  clang/test/CodeGen/builtins-wasm.c
  clang/test/Headers/wasm.c
  llvm/include/llvm/IR/IntrinsicsWebAssembly.td
  llvm/lib/Target/WebAssembly/WebAssemblyISD.def
  llvm/lib/Target/WebAssembly/WebAssemblyISelLowering.cpp
  llvm/lib/Target/WebAssembly/WebAssemblyInstrSIMD.td
  llvm/test/CodeGen/WebAssembly/simd-conversions.ll
  llvm/test/CodeGen/WebAssembly/simd-intrinsics.ll

Index: llvm/test/CodeGen/WebAssembly/simd-intrinsics.ll
===
--- llvm/test/CodeGen/WebAssembly/simd-intrinsics.ll
+++ llvm/test/CodeGen/WebAssembly/simd-intrinsics.ll
@@ -1,4 +1,4 @@
-; RUN: llc < %s -asm-verbose=false -verify-machineinstrs -disable-wasm-fallthrough-return-opt -wasm-disable-explicit-locals -wasm-keep-registers -mattr=+simd128 | FileCheck %s
+; RUN: llc < %s -asm-verbose=false -verify-machineinstrs -disable-wasm-fallthrough-return-opt -wasm-disable-explicit-locals -wasm-keep-registers -mattr=+simd128 | FileCheck %s --check-prefixes=CHECK,SLOW
 ; RUN: llc < %s -asm-verbose=false -verify-machineinstrs -disable-wasm-fallthrough-return-opt -wasm-disable-explicit-locals -wasm-keep-registers -mattr=+simd128 -fast-isel | FileCheck %s
 
 ; Test that SIMD128 intrinsics lower as expected. These intrinsics are
@@ -542,6 +542,18 @@
   ret <4 x i32> %a
 }
 
+; CHECK-LABEL: trunc_sat_zero_s_v4i32_2:
+; CHECK-NEXT: .functype trunc_sat_zero_s_v4i32_2 (v128) -> (v128){{$}}
+; SLOW-NEXT: i32x4.trunc_sat_zero_f64x2_s $push[[R:[0-9]+]]=, $0{{$}}
+; SLOW-NEXT: return $pop[[R]]{{$}}
+declare <4 x i32> @llvm.fptosi.sat.v4i32.v4f64(<4 x double>)
+define <4 x i32> @trunc_sat_zero_s_v4i32_2(<2 x double> %x) {
+  %v = shufflevector <2 x double> %x, <2 x double> zeroinitializer,
+   <4 x i32> 
+  %a = call <4 x i32> @llvm.fptosi.sat.v4i32.v4f64(<4 x double> %v)
+  ret <4 x i32> %a
+}
+
 ; CHECK-LABEL: trunc_sat_zero_u_v4i32:
 ; CHECK-NEXT: .functype trunc_sat_zero_u_v4i32 (v128) -> (v128){{$}}
 ; CHECK-NEXT: i32x4.trunc_sat_zero_f64x2_u $push[[R:[0-9]+]]=, $0{{$}}
@@ -554,6 +566,18 @@
   ret <4 x i32> %a
 }
 
+; CHECK-LABEL: trunc_sat_zero_u_v4i32_2:
+; CHECK-NEXT: .functype trunc_sat_zero_u_v4i32_2 (v128) -> (v128){{$}}
+; SLOW-NEXT: i32x4.trunc_sat_zero_f64x2_u $push[[R:[0-9]+]]=, $0{{$}}
+; SLOW-NEXT: return $pop[[R]]{{$}}
+declare <4 x i32> @llvm.fptoui.sat.v4i32.v4f64(<4 x double>)
+define <4 x i32> @trunc_sat_zero_u_v4i32_2(<2 x double> %x) {
+  %v = shufflevector <2 x double> %x, <2 x double> zeroinitializer,
+   <4 x i32> 
+  %a = call <4 x i32> @llvm.fptoui.sat.v4i32.v4f64(<4 x double> %v)
+  ret <4 x i32> %a
+}
+
 ; ==
 ; 2 x i64
 ; ==
@@ -722,16 +746,6 @@
   ret <4 x float> %v
 }
 
-; CHECK-LABEL: demote_zero_v4f32:
-; CHECK-NEXT: .functype demote_zero_v4f32 (v128) -> (v128){{$}}
-; CHECK-NEXT: f32x4.demote_zero_f64x2 $push[[R:[0-9]+]]=, $0{{$}}
-; CHECK-NEXT: return $pop[[R]]{{$}}
-declare <4 x float> @llvm.wasm.demote.zero(<2 x double>)
-define <4 x float> @demote_zero_v4f32(<2 x double> %a) {
-  %v = call <4 x float> @llvm.wasm.demote.zero(<2 x double> %a)
-  ret <4 x float> %v
-}
-
 ; ==
 ; 2 x f64
 ; ==
Index: llvm/test/CodeGen/WebAssembly/simd-conversions.ll
===
--- llvm/test/CodeGen/WebAssembly/simd-conversions.ll
+++ llvm/test/CodeGen/WebAssembly/simd-conversions.ll
@@ -82,6 +82,30 @@
   ret <2 x i64> %a
 }
 
+; CHECK-LABEL: demote_zero_v4f32:
+; NO-SIMD128-NOT: f32x4
+; SIMD128-NEXT: .functype demote_zero_v4f32 (v128) -> (v128){{$}}
+; SIMD128-NEXT: f32x4.demote_zero_f64x2 $push[[R:[0-9]+]]=, $0
+; SIMD128-NEXT: return $pop[[R]]
+define <4 x float> @demote_zero_v4f32(<2 x double> %x) {
+  %v = shufflevector <2 x double> %x, <2 x double> zeroinitializer,
+ <4 x i32> 
+  %a = fptrunc <4 x double> %v to <4 x float>
+  ret <4 x float> %a
+}
+
+; CHECK-LABEL: demote_zero_v4f32_2:
+; NO-SIMD128-NOT: f32x4
+; SIMD128-NEXT: .functype demote_zero_v4f32_2 (v128) -> (v128){{$}}
+; SIMD128-NEXT: f32x4.demote_zero_f64x2 $push[[R:[0-9]+]]=, $0
+; SIMD128-NEXT: return $pop[[R]]
+define <4 x float> @demote_zero_v4f32_2(<2 x double> %x) {
+  %v = fptrunc <2 x double> %x to <2 x float>
+  %a = s

[clang] cbabfc6 - [WebAssembly] Custom combines for f32x4.demote_zero_f64x2

2021-07-12 Thread Thomas Lively via cfe-commits

Author: Thomas Lively
Date: 2021-07-12T10:32:18-07:00
New Revision: cbabfc63b1be274316552d3eaaf7b2ad88c4c073

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

LOG: [WebAssembly] Custom combines for f32x4.demote_zero_f64x2

Replace the clang builtin function and LLVM intrinsic for
f32x4.demote_zero_f64x2 with combines from normal SDNodes. Also add missing
combines for i32x4.trunc_sat_zero_f64x2_{s,u}, which share the same pattern.

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

Added: 


Modified: 
clang/include/clang/Basic/BuiltinsWebAssembly.def
clang/lib/CodeGen/CGBuiltin.cpp
clang/lib/Headers/wasm_simd128.h
clang/test/CodeGen/builtins-wasm.c
clang/test/Headers/wasm.c
llvm/include/llvm/IR/IntrinsicsWebAssembly.td
llvm/lib/Target/WebAssembly/WebAssemblyISD.def
llvm/lib/Target/WebAssembly/WebAssemblyISelLowering.cpp
llvm/lib/Target/WebAssembly/WebAssemblyInstrSIMD.td
llvm/test/CodeGen/WebAssembly/simd-conversions.ll
llvm/test/CodeGen/WebAssembly/simd-intrinsics.ll

Removed: 




diff  --git a/clang/include/clang/Basic/BuiltinsWebAssembly.def 
b/clang/include/clang/Basic/BuiltinsWebAssembly.def
index cdaaa5d81f6df..58d10ea1012e1 100644
--- a/clang/include/clang/Basic/BuiltinsWebAssembly.def
+++ b/clang/include/clang/Basic/BuiltinsWebAssembly.def
@@ -191,7 +191,6 @@ TARGET_BUILTIN(__builtin_wasm_narrow_u_i16x8_i32x4, 
"V8UsV4iV4i", "nc", "simd128
 
 TARGET_BUILTIN(__builtin_wasm_trunc_sat_zero_s_f64x2_i32x4, "V4iV2d", "nc", 
"simd128")
 TARGET_BUILTIN(__builtin_wasm_trunc_sat_zero_u_f64x2_i32x4, "V4UiV2d", "nc", 
"simd128")
-TARGET_BUILTIN(__builtin_wasm_demote_zero_f64x2_f32x4, "V4fV2d", "nc", 
"simd128")
 
 TARGET_BUILTIN(__builtin_wasm_load32_zero, "V4iiC*", "n", "simd128")
 TARGET_BUILTIN(__builtin_wasm_load64_zero, "V2LLiLLiC*", "n", "simd128")

diff  --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp
index 41ea2bf5f43a2..355ed8ffbfea1 100644
--- a/clang/lib/CodeGen/CGBuiltin.cpp
+++ b/clang/lib/CodeGen/CGBuiltin.cpp
@@ -17723,11 +17723,6 @@ Value 
*CodeGenFunction::EmitWebAssemblyBuiltinExpr(unsigned BuiltinID,
Builder.getInt32(2), Builder.getInt32(3)});
 return Builder.CreateShuffleVector(Trunc, Splat, ConcatMask);
   }
-  case WebAssembly::BI__builtin_wasm_demote_zero_f64x2_f32x4: {
-Value *Vec = EmitScalarExpr(E->getArg(0));
-Function *Callee = CGM.getIntrinsic(Intrinsic::wasm_demote_zero);
-return Builder.CreateCall(Callee, Vec);
-  }
   case WebAssembly::BI__builtin_wasm_load32_zero: {
 Value *Ptr = EmitScalarExpr(E->getArg(0));
 Function *Callee = CGM.getIntrinsic(Intrinsic::wasm_load32_zero);

diff  --git a/clang/lib/Headers/wasm_simd128.h 
b/clang/lib/Headers/wasm_simd128.h
index 4869f7de6c7f3..dc54bb91e135b 100644
--- a/clang/lib/Headers/wasm_simd128.h
+++ b/clang/lib/Headers/wasm_simd128.h
@@ -1151,7 +1151,9 @@ wasm_u32x4_trunc_sat_f64x2_zero(v128_t __a) {
 
 static __inline__ v128_t __DEFAULT_FN_ATTRS
 wasm_f32x4_demote_f64x2_zero(v128_t __a) {
-  return (v128_t)__builtin_wasm_demote_zero_f64x2_f32x4((__f64x2)__a);
+  return (v128_t) __builtin_convertvector(
+  __builtin_shufflevector((__f64x2)__a, (__f64x2){0, 0}, 0, 1, 2, 3),
+  __f32x4);
 }
 
 static __inline__ v128_t __DEFAULT_FN_ATTRS

diff  --git a/clang/test/CodeGen/builtins-wasm.c 
b/clang/test/CodeGen/builtins-wasm.c
index 61130922241cd..8999d391fdeba 100644
--- a/clang/test/CodeGen/builtins-wasm.c
+++ b/clang/test/CodeGen/builtins-wasm.c
@@ -892,12 +892,6 @@ u32x4 trunc_sat_zero_u_f64x2_i32x4(f64x2 x) {
   // WEBASSEMBLY: ret <4 x i32> %1
 }
 
-f32x4 wasm_demote_zero_f64x2_f32x4(f64x2 x) {
-  return __builtin_wasm_demote_zero_f64x2_f32x4(x);
-  // WEBASSEMBLY: call <4 x float> @llvm.wasm.demote.zero(<2 x double> %x)
-  // WEBASSEMBLY: ret
-}
-
 i32x4 load32_zero(const int *p) {
   return __builtin_wasm_load32_zero(p);
   // WEBASSEMBLY: call <4 x i32> @llvm.wasm.load32.zero(i32* %p)

diff  --git a/clang/test/Headers/wasm.c b/clang/test/Headers/wasm.c
index 1cf87b4bb786a..cc2f2b65ca126 100644
--- a/clang/test/Headers/wasm.c
+++ b/clang/test/Headers/wasm.c
@@ -2465,9 +2465,10 @@ v128_t test_u32x4_trunc_sat_f64x2_zero(v128_t a) {
 // CHECK-LABEL: @test_f32x4_demote_f64x2_zero(
 // CHECK-NEXT:  entry:
 // CHECK-NEXT:[[TMP0:%.*]] = bitcast <4 x i32> [[A:%.*]] to <2 x double>
-// CHECK-NEXT:[[TMP1:%.*]] = tail call <4 x float> 
@llvm.wasm.demote.zero(<2 x double> [[TMP0]]) #[[ATTR10]]
-// CHECK-NEXT:[[TMP2:%.*]] = bitcast <4 x float> [[TMP1]] to <4 x i32>
-// CHECK-NEXT:ret <4 x i32> [[TMP2]]
+// CHECK-NEXT:[[SHUFFLE_I:%.*]] = shufflevector <2 x double> [[TMP0]], <2 
x double> zeroinitializer, <4 x i32> 
+// CHECK-NEXT:[[CONV_I:%.*]] = fptrunc <4 

[PATCH] D103395: PR45879: Keep evaluated expression in LValue object

2021-07-12 Thread Serge Pavlov via Phabricator via cfe-commits
sepavloff updated this revision to Diff 357988.
sepavloff added a comment.

Rebased patch


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D103395

Files:
  clang/lib/AST/ExprConstant.cpp
  clang/test/SemaCXX/constant-expression-cxx2a.cpp


Index: clang/test/SemaCXX/constant-expression-cxx2a.cpp
===
--- clang/test/SemaCXX/constant-expression-cxx2a.cpp
+++ clang/test/SemaCXX/constant-expression-cxx2a.cpp
@@ -1447,3 +1447,11 @@
   constexpr bool b = [a = S(), b = S()] { return a.p == b.p; }();
   static_assert(!b);
 }
+
+namespace PR45879 {
+struct Base {
+  int m;
+};
+struct Derived : Base {};
+constexpr int k = ((Base{} = Derived{}), 0);
+} // namespace PR45879
Index: clang/lib/AST/ExprConstant.cpp
===
--- clang/lib/AST/ExprConstant.cpp
+++ clang/lib/AST/ExprConstant.cpp
@@ -1534,6 +1534,7 @@
 APValue::LValueBase Base;
 CharUnits Offset;
 SubobjectDesignator Designator;
+const Expr *LExpr = nullptr;
 bool IsNullPtr : 1;
 bool InvalidBase : 1;
 
@@ -1542,6 +1543,7 @@
 const CharUnits &getLValueOffset() const { return Offset; }
 SubobjectDesignator &getLValueDesignator() { return Designator; }
 const SubobjectDesignator &getLValueDesignator() const { return 
Designator;}
+const Expr *getExpr() const { return LExpr; }
 bool isNullPointer() const { return IsNullPtr;}
 
 unsigned getLValueCallIndex() const { return Base.getCallIndex(); }
@@ -1579,6 +1581,8 @@
   Offset = CharUnits::fromQuantity(0);
   InvalidBase = BInvalid;
   Designator = SubobjectDesignator(getType(B));
+  if (!LExpr)
+LExpr = B.dyn_cast();
   IsNullPtr = false;
 }
 
@@ -6077,8 +6081,11 @@
 if (!handleTrivialCopy(Info, MD->getParamDecl(0), Args[0], RHSValue,
MD->getParent()->isUnion()))
   return false;
+const Expr *LHS = This->getExpr();
+if (!LHS)
+  return false;
 if (Info.getLangOpts().CPlusPlus20 && MD->isTrivial() &&
-!HandleUnionActiveMemberChange(Info, Args[0], *This))
+!HandleUnionActiveMemberChange(Info, LHS, *This))
   return false;
 if (!handleAssignment(Info, Args[0], *This, MD->getThisType(),
   RHSValue))
@@ -8039,6 +8046,11 @@
   LValueExprEvaluator(EvalInfo &Info, LValue &Result, bool InvalidBaseOK) :
 LValueExprEvaluatorBaseTy(Info, Result, InvalidBaseOK) {}
 
+  bool evaluate(const Expr *E) {
+Result.LExpr = E;
+return Visit(E);
+  }
+
   bool VisitVarDecl(const Expr *E, const VarDecl *VD);
   bool VisitUnaryPreIncDec(const UnaryOperator *UO);
 
@@ -8100,7 +8112,7 @@
   assert(!E->isValueDependent());
   assert(E->isGLValue() || E->getType()->isFunctionType() ||
  E->getType()->isVoidType() || isa(E));
-  return LValueExprEvaluator(Info, Result, InvalidBaseOK).Visit(E);
+  return LValueExprEvaluator(Info, Result, InvalidBaseOK).evaluate(E);
 }
 
 bool LValueExprEvaluator::VisitDeclRefExpr(const DeclRefExpr *E) {
@@ -8571,6 +8583,8 @@
   : ExprEvaluatorBaseTy(info), Result(Result),
 InvalidBaseOK(InvalidBaseOK) {}
 
+  bool evaluate(const Expr *E) { return Visit(E); }
+
   bool Success(const APValue &V, const Expr *E) {
 Result.setFrom(Info.Ctx, V);
 return true;
@@ -8680,7 +8694,7 @@
 bool InvalidBaseOK) {
   assert(!E->isValueDependent());
   assert(E->isPRValue() && E->getType()->hasPointerRepresentation());
-  return PointerExprEvaluator(Info, Result, InvalidBaseOK).Visit(E);
+  return PointerExprEvaluator(Info, Result, InvalidBaseOK).evaluate(E);
 }
 
 bool PointerExprEvaluator::VisitBinaryOperator(const BinaryOperator *E) {


Index: clang/test/SemaCXX/constant-expression-cxx2a.cpp
===
--- clang/test/SemaCXX/constant-expression-cxx2a.cpp
+++ clang/test/SemaCXX/constant-expression-cxx2a.cpp
@@ -1447,3 +1447,11 @@
   constexpr bool b = [a = S(), b = S()] { return a.p == b.p; }();
   static_assert(!b);
 }
+
+namespace PR45879 {
+struct Base {
+  int m;
+};
+struct Derived : Base {};
+constexpr int k = ((Base{} = Derived{}), 0);
+} // namespace PR45879
Index: clang/lib/AST/ExprConstant.cpp
===
--- clang/lib/AST/ExprConstant.cpp
+++ clang/lib/AST/ExprConstant.cpp
@@ -1534,6 +1534,7 @@
 APValue::LValueBase Base;
 CharUnits Offset;
 SubobjectDesignator Designator;
+const Expr *LExpr = nullptr;
 bool IsNullPtr : 1;
 bool InvalidBase : 1;
 
@@ -1542,6 +1543,7 @@
 const CharUnits &getLValueOffset() const { return Offset; }
 SubobjectDesignator &getLValueDesignator() { return Designator; }
 const SubobjectDesignator &getLValueDesignator() const { return Designator;}
+const Expr *getExpr() const { return LExpr; }

[PATCH] D105734: [clang-tidy] performance-unnecessary-copy-initialization: Do not remove comments on new lines.

2021-07-12 Thread Felix Berger via Phabricator via cfe-commits
flx updated this revision to Diff 357993.
flx added a comment.

Make offset operations safer.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105734

Files:
  clang-tools-extra/clang-tidy/performance/UnnecessaryCopyInitialization.cpp
  
clang-tools-extra/test/clang-tidy/checkers/performance-unnecessary-copy-initialization.cpp


Index: 
clang-tools-extra/test/clang-tidy/checkers/performance-unnecessary-copy-initialization.cpp
===
--- 
clang-tools-extra/test/clang-tidy/checkers/performance-unnecessary-copy-initialization.cpp
+++ 
clang-tools-extra/test/clang-tidy/checkers/performance-unnecessary-copy-initialization.cpp
@@ -596,8 +596,15 @@
   // CHECK-FIXES: int i = 0; // Foo bar.
   auto TrailingCommentRemoved = ExpensiveTypeReference(); // Trailing comment.
   // CHECK-MESSAGES: [[@LINE-1]]:8: warning: the variable 
'TrailingCommentRemoved' is copy-constructed from a const reference but is 
never used;
-  // CHECK-FIXES-NOT: auto TrailingCommentRemoved = ExpensiveTypeReference(); 
// Trailing comment.
+  // CHECK-FIXES-NOT: auto TrailingCommentRemoved = ExpensiveTypeReference();
+  // CHECK-FIXES-NOT: // Trailing comment.
   // clang-format on
+
+  auto UnusedAndUnnecessary = ExpensiveTypeReference();
+  // Comments on a new line should not be deleted.
+  // CHECK-MESSAGES: [[@LINE-2]]:8: warning: the variable 
'UnusedAndUnnecessary' is copy-constructed
+  // CHECK-FIXES-NOT: auto UnusedAndUnnecessary = ExpensiveTypeReference();
+  // CHECK-FIXES: // Comments on a new line should not be deleted.
 }
 
 void negativeloopedOverObjectIsModified() {
Index: 
clang-tools-extra/clang-tidy/performance/UnnecessaryCopyInitialization.cpp
===
--- clang-tools-extra/clang-tidy/performance/UnnecessaryCopyInitialization.cpp
+++ clang-tools-extra/clang-tidy/performance/UnnecessaryCopyInitialization.cpp
@@ -39,14 +39,35 @@
   }
 }
 
+llvm::Optional firstLocAfterNewLine(SourceLocation Loc,
+SourceManager &SM) {
+  bool Invalid;
+  const char *TextAfter = SM.getCharacterData(Loc, &Invalid);
+  if (Invalid) {
+return llvm::None;
+  }
+  size_t Offset = std::strcspn(TextAfter, "\n");
+  return Loc.getLocWithOffset(TextAfter[Offset] != '\0' ? Offset + 1 : Offset);
+}
+
 void recordRemoval(const DeclStmt &Stmt, ASTContext &Context,
DiagnosticBuilder &Diagnostic) {
-  // Attempt to remove the whole line until the next non-comment token.
-  auto Tok = utils::lexer::findNextTokenSkippingComments(
-  Stmt.getEndLoc(), Context.getSourceManager(), Context.getLangOpts());
-  if (Tok) {
-Diagnostic << FixItHint::CreateRemoval(SourceRange(
-Stmt.getBeginLoc(), Tok->getLocation().getLocWithOffset(-1)));
+  auto &SM = Context.getSourceManager();
+  // Attempt to remove trailing comments as well.
+  auto Tok = utils::lexer::findNextTokenSkippingComments(Stmt.getEndLoc(), SM,
+ 
Context.getLangOpts());
+  llvm::Optional PastNewLine =
+  firstLocAfterNewLine(Stmt.getEndLoc(), SM);
+  if (Tok && PastNewLine) {
+auto BeforeFirstTokenAfterComment = 
Tok->getLocation().getLocWithOffset(-1);
+// Remove until the end of the line or the end of a trailing comment which
+// ever comes first.
+auto End =
+SM.isBeforeInTranslationUnit(*PastNewLine, 
BeforeFirstTokenAfterComment)
+? *PastNewLine
+: BeforeFirstTokenAfterComment;
+Diagnostic << FixItHint::CreateRemoval(
+SourceRange(Stmt.getBeginLoc(), End));
   } else {
 Diagnostic << FixItHint::CreateRemoval(Stmt.getSourceRange());
   }


Index: clang-tools-extra/test/clang-tidy/checkers/performance-unnecessary-copy-initialization.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/performance-unnecessary-copy-initialization.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/performance-unnecessary-copy-initialization.cpp
@@ -596,8 +596,15 @@
   // CHECK-FIXES: int i = 0; // Foo bar.
   auto TrailingCommentRemoved = ExpensiveTypeReference(); // Trailing comment.
   // CHECK-MESSAGES: [[@LINE-1]]:8: warning: the variable 'TrailingCommentRemoved' is copy-constructed from a const reference but is never used;
-  // CHECK-FIXES-NOT: auto TrailingCommentRemoved = ExpensiveTypeReference(); // Trailing comment.
+  // CHECK-FIXES-NOT: auto TrailingCommentRemoved = ExpensiveTypeReference();
+  // CHECK-FIXES-NOT: // Trailing comment.
   // clang-format on
+
+  auto UnusedAndUnnecessary = ExpensiveTypeReference();
+  // Comments on a new line should not be deleted.
+  // CHECK-MESSAGES: [[@LINE-2]]:8: warning: the variable 'UnusedAndUnnecessary' is copy-constructed
+  // CHECK-FIXES-NOT: auto UnusedAndUnnecessary = ExpensiveTypeR

[PATCH] D105734: [clang-tidy] performance-unnecessary-copy-initialization: Do not remove comments on new lines.

2021-07-12 Thread Felix Berger via Phabricator via cfe-commits
flx marked 2 inline comments as done.
flx added a comment.

Thanks for the review!




Comment at: 
clang-tools-extra/clang-tidy/performance/UnnecessaryCopyInitialization.cpp:51
+  if (Tok && !Invalid) {
+size_t Offset = std::strcspn(TextAfter, "\n");
+auto PastNewLine = Stmt.getEndLoc().getLocWithOffset(Offset + 1);

ymandel wrote:
> what happens for the last line in the file? I think the `Offset + 1` below 
> will be sketchy (because PastNewLine will be invalid). It might work, but 
> seems best avoided.
I added a check to not go past the end of the string. 



Comment at: 
clang-tools-extra/clang-tidy/performance/UnnecessaryCopyInitialization.cpp:56
+// ever comes first.
+auto End = std::min(PastNewLine, BeforeFirstTokenAfterComment);
+Diagnostic << FixItHint::CreateRemoval(

ymandel wrote:
> I suspect this could get tripped up by macros and other expansions. Instead 
> of `std::min`, consider using `SourceManager::isBeforeInTranslationUnit`
> (clang/include/clang/Basic/SourceManager.h;l=1616)? Alternatively, check that 
> both locations are file ids before calling `std::min`.
We don't apply any fixes when the decl statement is inside of a macro, but 
switched to using SourceManager::isBeforeInTranslationUnit.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105734

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


[PATCH] D105734: [clang-tidy] performance-unnecessary-copy-initialization: Do not remove comments on new lines.

2021-07-12 Thread Yitzhak Mandelbaum via Phabricator via cfe-commits
ymandel accepted this revision.
ymandel added inline comments.
This revision is now accepted and ready to land.



Comment at: 
clang-tools-extra/clang-tidy/performance/UnnecessaryCopyInitialization.cpp:50
+  size_t Offset = std::strcspn(TextAfter, "\n");
+  return Loc.getLocWithOffset(TextAfter[Offset] != '\0' ? Offset + 1 : Offset);
+}

optional nit: invert the condition and the branches. i just find it a little 
easier to read positive predicates. So, when i have both branches, I try for 
the condition to be positive (or, in other words, I try not to not the 
condition. ;) )


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105734

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


[PATCH] D105501: [PowerPC] Power ISA features for Semachecking

2021-07-12 Thread Quinn Pham via Phabricator via cfe-commits
quinnp updated this revision to Diff 358004.
quinnp added a comment.

Adding tests for each of the features


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105501

Files:
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/Basic/Targets/PPC.cpp
  clang/lib/Basic/Targets/PPC.h
  clang/lib/Sema/SemaChecking.cpp
  clang/test/Driver/ppc-isa207-instructions.cpp
  clang/test/Driver/ppc-isa30-instructions.cpp
  clang/test/Driver/ppc-isa31-instructions.cpp
  llvm/lib/Target/PowerPC/PPC.td
  llvm/lib/Target/PowerPC/PPCInstrInfo.td
  llvm/lib/Target/PowerPC/PPCSubtarget.cpp
  llvm/lib/Target/PowerPC/PPCSubtarget.h

Index: llvm/lib/Target/PowerPC/PPCSubtarget.h
===
--- llvm/lib/Target/PowerPC/PPCSubtarget.h
+++ llvm/lib/Target/PowerPC/PPCSubtarget.h
@@ -146,6 +146,7 @@
   bool HasStoreFusion;
   bool HasAddiLoadFusion;
   bool HasAddisLoadFusion;
+  bool IsISA2_07;
   bool IsISA3_0;
   bool IsISA3_1;
   bool UseLongCalls;
@@ -319,6 +320,7 @@
 
   bool hasHTM() const { return HasHTM; }
   bool hasFloat128() const { return HasFloat128; }
+  bool isISA2_07() const { return IsISA2_07; }
   bool isISA3_0() const { return IsISA3_0; }
   bool isISA3_1() const { return IsISA3_1; }
   bool useLongCalls() const { return UseLongCalls; }
Index: llvm/lib/Target/PowerPC/PPCSubtarget.cpp
===
--- llvm/lib/Target/PowerPC/PPCSubtarget.cpp
+++ llvm/lib/Target/PowerPC/PPCSubtarget.cpp
@@ -126,6 +126,7 @@
   HasStoreFusion = false;
   HasAddiLoadFusion = false;
   HasAddisLoadFusion = false;
+  IsISA2_07 = false;
   IsISA3_0 = false;
   IsISA3_1 = false;
   UseLongCalls = false;
Index: llvm/lib/Target/PowerPC/PPCInstrInfo.td
===
--- llvm/lib/Target/PowerPC/PPCInstrInfo.td
+++ llvm/lib/Target/PowerPC/PPCInstrInfo.td
@@ -1176,6 +1176,7 @@
 : Predicate<"!Subtarget->getTargetMachine().Options.NoNaNsFPMath">;
 def HasBPERMD : Predicate<"Subtarget->hasBPERMD()">;
 def HasExtDiv : Predicate<"Subtarget->hasExtDiv()">;
+def IsISA2_07 : Predicate<"Subtarget->isISA2_07()">;
 def IsISA3_0 : Predicate<"Subtarget->isISA3_0()">;
 def HasFPU : Predicate<"Subtarget->hasFPU()">;
 def PCRelativeMemops : Predicate<"Subtarget->hasPCRelativeMemops()">;
Index: llvm/lib/Target/PowerPC/PPC.td
===
--- llvm/lib/Target/PowerPC/PPC.td
+++ llvm/lib/Target/PowerPC/PPC.td
@@ -210,9 +210,13 @@
 def DeprecatedDST: SubtargetFeature<"", "DeprecatedDST", "true",
   "Treat vector data stream cache control instructions as deprecated">;
 
+def FeatureISA2_07 : SubtargetFeature<"isa-v207-instructions", "IsISA2_07",
+  "true",
+  "Enable instructions in ISA 2.07.">;
 def FeatureISA3_0 : SubtargetFeature<"isa-v30-instructions", "IsISA3_0",
  "true",
- "Enable instructions in ISA 3.0.">;
+ "Enable instructions in ISA 3.0.",
+ [FeatureISA2_07]>;
 def FeatureISA3_1 : SubtargetFeature<"isa-v31-instructions", "IsISA3_1",
  "true",
  "Enable instructions in ISA 3.1.",
Index: clang/test/Driver/ppc-isa31-instructions.cpp
===
--- /dev/null
+++ clang/test/Driver/ppc-isa31-instructions.cpp
@@ -0,0 +1,10 @@
+// RUN: %clang -target powerpc64-unknown-unknown -mcpu=pwr10 -S -emit-llvm %s -o - | FileCheck %s -check-prefix=CHECK-ISA31
+// RUN: %clang -target powerpc64le-unknown-unknown -mcpu=pwr10 -S -emit-llvm %s -o - | FileCheck %s -check-prefix=CHECK-ISA31
+// RUN: %clang -target powerpc64-unknown-aix -mcpu=pwr10 -S -emit-llvm %s -o - | FileCheck %s -check-prefix=CHECK-ISA31
+// RUN: %clang -target powerpc-unknown-aix -mcpu=pwr10 -S -emit-llvm %s -o - | FileCheck %s -check-prefix=CHECK-ISA31
+
+// CHECK-ISA31: +isa-v31-instructions
+
+int main(int argc, char *argv[]) {
+  return 0;
+}
Index: clang/test/Driver/ppc-isa30-instructions.cpp
===
--- /dev/null
+++ clang/test/Driver/ppc-isa30-instructions.cpp
@@ -0,0 +1,22 @@
+// RUN: %clang -target powerpc64-unknown-unknown -mcpu=pwr7 -S -emit-llvm %s -o - | FileCheck %s -check-prefix=CHECK-NOISA30
+// RUN: %clang -target powerpc64-unknown-unknown -mcpu=pwr8 -S -emit-llvm %s -o - | FileCheck %s -check-prefix=CHECK-NOISA30
+// RUN: %clang -target powerpc64-unknown-unknown -mcpu=pwr9 -S -emit-llvm %s -o - | FileCheck %s -check-prefix=CHECK-ISA30
+// RUN: %clang -target powerpc64-unknown-unknown -mcpu=pwr10 -S -emit-llvm %s -o - | FileCheck %s -check-prefix=CHECK-ISA30
+// RUN: %clang -targe

[PATCH] D105564: Fix for DWARF parsing to better handle auto return type for member functions

2021-07-12 Thread Raphael Isemann via Phabricator via cfe-commits
teemperor requested changes to this revision.
teemperor added a comment.
This revision now requires changes to proceed.

I think this looks good, thanks for fixing this! I believe there should be a 
few more tests for all the corner cases we can run into here (those tests can 
all be just Python API tests, no need for having them all in assembly format). 
Also I think lambdas where triggering the original issue, so that would also be 
nice to have in a test.

I started writing some example tests but this is crashing for me with:

  Unexpected undeduced type!
  UNREACHABLE executed at 
/home/teemperor/work/ci/llvm-project/clang/lib/CodeGen/CodeGenTypes.cpp:624!
  PLEASE submit a bug report to https://bugs.llvm.org/ and include the crash 
backtrace.
  Stack dump:
  0.Program arguments: ./bin/lldb 
././lldb-test-build.noindex/lang/cpp/auto_return/TestCppAutoReturn.test_dwarf/a.out
   #0 0x55f540b5e611 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) 
(./bin/lldb+0x34611)
   #1 0x55f540b5c6b0 llvm::sys::RunSignalHandlers() (./bin/lldb+0x326b0)
   #2 0x55f540b5efb6 SignalHandler(int) (./bin/lldb+0x34fb6)
   #3 0x7fe3c3484870 __restore_rt (/usr/lib/libpthread.so.0+0x13870)
   #4 0x7fe3bd2e3d22 raise (/usr/lib/libc.so.6+0x3cd22)
   #5 0x7fe3bd2cd862 abort (/usr/lib/libc.so.6+0x26862)
   #6 0x7fe3becf0df1 
(/home/teemperor/work/ci/build/bin/../lib/liblldb.so.13git+0x146adf1)
   #7 0x7fe3bf7cbdda 
clang::CodeGen::CodeGenTypes::ConvertType(clang::QualType) 
(/home/teemperor/work/ci/build/bin/../lib/liblldb.so.13git+0x1f45dda)
   #8 0x7fe3bf7caf7e 
clang::CodeGen::CodeGenTypes::ConvertTypeForMem(clang::QualType, bool) 
(/home/teemperor/work/ci/build/bin/../lib/liblldb.so.13git+0x1f44f7e)
   #9 0x7fe3bf951dd8 
clang::CodeGen::CodeGenModule::getOrCreateStaticVarDecl(clang::VarDecl const&, 
llvm::GlobalValue::LinkageTypes) 
(/home/teemperor/work/ci/build/bin/../lib/liblldb.so.13git+0x20cbdd8)
  #10 0x7fe3bf950b10 
clang::CodeGen::CodeGenFunction::EmitStaticVarDecl(clang::VarDecl const&, 
llvm::GlobalValue::LinkageTypes) 
(/home/teemperor/work/ci/build/bin/../lib/liblldb.so.13git+0x20cab10)
  #11 0x7fe3bf9508f3 
clang::CodeGen::CodeGenFunction::EmitVarDecl(clang::VarDecl const&) 
(/home/teemperor/work/ci/build/bin/../lib/liblldb.so.13git+0x20ca8f3)
  #12 0x7fe3bf950458 clang::CodeGen::CodeGenFunction::EmitDecl(clang::Decl 
const&) (/home/teemperor/work/ci/build/bin/../lib/liblldb.so.13git+0x20ca458)
  #13 0x7fe3bf6f887c 
clang::CodeGen::CodeGenFunction::EmitDeclStmt(clang::DeclStmt const&) 
(/home/teemperor/work/ci/build/bin/../lib/liblldb.so.13git+0x1e7287c)
  #14 0x7fe3bf6ee2d8 
clang::CodeGen::CodeGenFunction::EmitSimpleStmt(clang::Stmt const*, 
llvm::ArrayRef) 
(/home/teemperor/work/ci/build/bin/../lib/liblldb.so.13git+0x1e682d8)
  #15 0x7fe3bf6eda89 clang::CodeGen::CodeGenFunction::EmitStmt(clang::Stmt 
const*, llvm::ArrayRef) 
(/home/teemperor/work/ci/build/bin/../lib/liblldb.so.13git+0x1e67a89)
  #16 0x7fe3bf6f96b0 
clang::CodeGen::CodeGenFunction::EmitCompoundStmtWithoutScope(clang::CompoundStmt
 const&, bool, clang::CodeGen::AggValueSlot) 
(/home/teemperor/work/ci/build/bin/../lib/liblldb.so.13git+0x1e736b0)
  #17 0x7fe3bf7585b4 
clang::CodeGen::CodeGenFunction::EmitFunctionBody(clang::Stmt const*) 
(/home/teemperor/work/ci/build/bin/../lib/liblldb.so.13git+0x1ed25b4)
  #18 0x7fe3bf7591de 
clang::CodeGen::CodeGenFunction::GenerateCode(clang::GlobalDecl, 
llvm::Function*, clang::CodeGen::CGFunctionInfo const&) 
(/home/teemperor/work/ci/build/bin/../lib/liblldb.so.13git+0x1ed31de)
  #19 0x7fe3bf77a51f 
clang::CodeGen::CodeGenModule::EmitGlobalFunctionDefinition(clang::GlobalDecl, 
llvm::GlobalValue*) 
(/home/teemperor/work/ci/build/bin/../lib/liblldb.so.13git+0x1ef451f)
  #20 0x7fe3bf77222d 
clang::CodeGen::CodeGenModule::EmitGlobalDefinition(clang::GlobalDecl, 
llvm::GlobalValue*) 
(/home/teemperor/work/ci/build/bin/../lib/liblldb.so.13git+0x1eec22d)
  #21 0x7fe3bf7773bb 
clang::CodeGen::CodeGenModule::EmitGlobal(clang::GlobalDecl) 
(/home/teemperor/work/ci/build/bin/../lib/liblldb.so.13git+0x1ef13bb)
  #22 0x7fe3bf77e039 
clang::CodeGen::CodeGenModule::EmitTopLevelDecl(clang::Decl*) 
(/home/teemperor/work/ci/build/bin/../lib/liblldb.so.13git+0x1ef8039)
  #23 0x7fe3bf6ab280 (anonymous 
namespace)::CodeGeneratorImpl::HandleTopLevelDecl(clang::DeclGroupRef) 
(/home/teemperor/work/ci/build/bin/../lib/liblldb.so.13git+0x1e25280)
  #24 0x7fe3bf549632 
lldb_private::ASTResultSynthesizer::HandleTopLevelDecl(clang::DeclGroupRef) 
(/home/teemperor/work/ci/build/bin/../lib/liblldb.so.13git+0x1cc3632)
  #25 0x7fe3c018a558 clang::ParseAST(clang::Sema&, bool, bool) 
(/home/teemperor/work/ci/build/bin/../lib/liblldb.so.13git+0x2904558)
  #26 0x7fe3bf55d493 
lldb_private::ClangExpressionParser::ParseInternal(lldb_private::DiagnosticManager&,
 clang::CodeCompleteConsumer*, unsigned int, unsigned int) 
(/home/teemper

[PATCH] D105526: opencl-c.h: CL3.0 generic address space

2021-07-12 Thread Dave Airlie via Phabricator via cfe-commits
airlied updated this revision to Diff 358005.
airlied added a comment.

full diff.


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

https://reviews.llvm.org/D105526

Files:
  clang/lib/Headers/opencl-c.h

Index: clang/lib/Headers/opencl-c.h
===
--- clang/lib/Headers/opencl-c.h
+++ clang/lib/Headers/opencl-c.h
@@ -7259,7 +7259,7 @@
  * Returns fmin(x - floor (x), 0x1.fep-1f ).
  * floor(x) is returned in iptr.
  */
-#if defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= CL_VERSION_2_0)
+#if defined(__opencl_c_generic_address_space)
 float __ovld fract(float x, float *iptr);
 float2 __ovld fract(float2 x, float2 *iptr);
 float3 __ovld fract(float3 x, float3 *iptr);
@@ -7341,7 +7341,7 @@
 half8 __ovld fract(half8 x, __private half8 *iptr);
 half16 __ovld fract(half16 x, __private half16 *iptr);
 #endif //cl_khr_fp16
-#endif //defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= CL_VERSION_2_0)
+#endif //defined(__opencl_c_generic_address_space)
 
 /**
  * Extract mantissa and exponent from x. For each
@@ -7349,7 +7349,7 @@
  * magnitude in the interval [1/2, 1) or 0. Each
  * component of x equals mantissa returned * 2^exp.
  */
-#if defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= CL_VERSION_2_0)
+#if defined(__opencl_c_generic_address_space)
 float __ovld frexp(float x, int *exp);
 float2 __ovld frexp(float2 x, int2 *exp);
 float3 __ovld frexp(float3 x, int3 *exp);
@@ -7431,7 +7431,7 @@
 half8 __ovld frexp(half8 x, __private int8 *exp);
 half16 __ovld frexp(half16 x, __private int16 *exp);
 #endif //cl_khr_fp16
-#endif //defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= CL_VERSION_2_0)
+#endif //defined(__opencl_c_generic_address_space)
 
 /**
  * Compute the value of the square root of x^2 + y^2
@@ -7556,7 +7556,7 @@
 half16 __ovld __cnfn lgamma(half16 x);
 #endif //cl_khr_fp16
 
-#if defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= CL_VERSION_2_0)
+#if defined(__opencl_c_generic_address_space)
 float __ovld lgamma_r(float x, int *signp);
 float2 __ovld lgamma_r(float2 x, int2 *signp);
 float3 __ovld lgamma_r(float3 x, int3 *signp);
@@ -7638,7 +7638,7 @@
 half8 __ovld lgamma_r(half8 x, __private int8 *signp);
 half16 __ovld lgamma_r(half16 x, __private int16 *signp);
 #endif //cl_khr_fp16
-#endif //defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= CL_VERSION_2_0)
+#endif //defined(__opencl_c_generic_address_space)
 
 /**
  * Compute natural logarithm.
@@ -7862,7 +7862,7 @@
  * the argument. It stores the integral part in the object
  * pointed to by iptr.
  */
-#if defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= CL_VERSION_2_0)
+#if defined(__opencl_c_generic_address_space)
 float __ovld modf(float x, float *iptr);
 float2 __ovld modf(float2 x, float2 *iptr);
 float3 __ovld modf(float3 x, float3 *iptr);
@@ -7944,7 +7944,7 @@
 half8 __ovld modf(half8 x, __private half8 *iptr);
 half16 __ovld modf(half16 x, __private half16 *iptr);
 #endif //cl_khr_fp16
-#endif //defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= CL_VERSION_2_0)
+#endif //defined(__opencl_c_generic_address_space)
 
 /**
  * Returns a quiet NaN. The nancode may be placed
@@ -8122,7 +8122,7 @@
  * sign as x/y. It stores this signed value in the object
  * pointed to by quo.
  */
-#if defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= CL_VERSION_2_0)
+#if defined(__opencl_c_generic_address_space)
 float __ovld remquo(float x, float y, int *quo);
 float2 __ovld remquo(float2 x, float2 y, int2 *quo);
 float3 __ovld remquo(float3 x, float3 y, int3 *quo);
@@ -8205,7 +8205,7 @@
 half8 __ovld remquo(half8 x, half8 y, __private int8 *quo);
 half16 __ovld remquo(half16 x, half16 y, __private int16 *quo);
 #endif //cl_khr_fp16
-#endif //defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= CL_VERSION_2_0)
+#endif //defined(__opencl_c_generic_address_space)
 /**
  * Round to integral value (using round to nearest
  * even rounding mode) in floating-point format.
@@ -8346,7 +8346,7 @@
  * is the return value and computed cosine is returned
  * in cosval.
  */
-#if defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= CL_VERSION_2_0)
+#if defined(__opencl_c_generic_address_space)
 float __ovld sincos(float x, float *cosval);
 float2 __ovld sincos(float2 x, float2 *cosval);
 float3 __ovld sincos(float3 x, float3 *cosval);
@@ -8428,7 +8428,7 @@
 half8 __ovld sincos(half8 x, __private half8 *cosval);
 half16 __ovld sincos(half16 x, __private half16 *cosval);
 #endif //cl_khr_fp16
-#endif //defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= CL_VERSION_2_0)
+#endif //defined(__opencl_c_generic_address_space)
 
 /**
  * Compute hyperbolic sine.
@@ -11249,7 +11249,7 @@
 half16 __ovld vload16(size_t offset, const __constant half *p);
 #endif //cl_khr_fp16
 
-#if defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= CL_VERSION_2_0)
+#if defined(__opencl_c_generic_ad

[PATCH] D105501: [PowerPC] Power ISA features for Semachecking

2021-07-12 Thread Lei Huang via Phabricator via cfe-commits
lei added inline comments.



Comment at: clang/lib/Sema/SemaChecking.cpp:3278
+ StringRef DiagArg = "") {
+  if (!S.Context.getTargetInfo().hasFeature(FeatureToCheck)) {
+if (!DiagArg.empty()) {

may I suggest early exit instead?

```
if (S.Context.getTargetInfo().hasFeature(FeatureToCheck))
  return false;

if (DiagArg.empty()) 
  S.Diag(TheCall->getBeginLoc(), DiagID) << TheCall->getSourceRange();
else
  S.Diag(TheCall->getBeginLoc(), DiagID) << DiagArg << 
TheCall->getSourceRange();

return true;
```


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105501

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


[PATCH] D105755: [WebAssembly] Custom combines for f32x4.demote_zero_f64x2

2021-07-12 Thread Thomas Lively via Phabricator via cfe-commits
tlively added inline comments.



Comment at: clang/include/clang/Basic/BuiltinsWebAssembly.def:192-193
 
 TARGET_BUILTIN(__builtin_wasm_trunc_sat_zero_s_f64x2_i32x4, "V4iV2d", "nc", 
"simd128")
 TARGET_BUILTIN(__builtin_wasm_trunc_sat_zero_u_f64x2_i32x4, "V4UiV2d", "nc", 
"simd128")
-TARGET_BUILTIN(__builtin_wasm_demote_zero_f64x2_f32x4, "V4fV2d", "nc", 
"simd128")

tlively wrote:
> aheejin wrote:
> > If these share the same pattern, do we need these builtins?
> Hmm, good point. Maybe not. I'll investigate that in a follow up.
Ah, the reason we can't remove these builtins is because there is no good 
target-independent way to represent the saturating behavior of the float-to-int 
conversion.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105755

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


[PATCH] D105734: [clang-tidy] performance-unnecessary-copy-initialization: Do not remove comments on new lines.

2021-07-12 Thread Felix Berger via Phabricator via cfe-commits
flx updated this revision to Diff 358010.
flx marked 2 inline comments as done.
flx added a comment.

Invert end of string logic.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105734

Files:
  clang-tools-extra/clang-tidy/performance/UnnecessaryCopyInitialization.cpp
  
clang-tools-extra/test/clang-tidy/checkers/performance-unnecessary-copy-initialization.cpp


Index: 
clang-tools-extra/test/clang-tidy/checkers/performance-unnecessary-copy-initialization.cpp
===
--- 
clang-tools-extra/test/clang-tidy/checkers/performance-unnecessary-copy-initialization.cpp
+++ 
clang-tools-extra/test/clang-tidy/checkers/performance-unnecessary-copy-initialization.cpp
@@ -596,8 +596,15 @@
   // CHECK-FIXES: int i = 0; // Foo bar.
   auto TrailingCommentRemoved = ExpensiveTypeReference(); // Trailing comment.
   // CHECK-MESSAGES: [[@LINE-1]]:8: warning: the variable 
'TrailingCommentRemoved' is copy-constructed from a const reference but is 
never used;
-  // CHECK-FIXES-NOT: auto TrailingCommentRemoved = ExpensiveTypeReference(); 
// Trailing comment.
+  // CHECK-FIXES-NOT: auto TrailingCommentRemoved = ExpensiveTypeReference();
+  // CHECK-FIXES-NOT: // Trailing comment.
   // clang-format on
+
+  auto UnusedAndUnnecessary = ExpensiveTypeReference();
+  // Comments on a new line should not be deleted.
+  // CHECK-MESSAGES: [[@LINE-2]]:8: warning: the variable 
'UnusedAndUnnecessary' is copy-constructed
+  // CHECK-FIXES-NOT: auto UnusedAndUnnecessary = ExpensiveTypeReference();
+  // CHECK-FIXES: // Comments on a new line should not be deleted.
 }
 
 void negativeloopedOverObjectIsModified() {
Index: 
clang-tools-extra/clang-tidy/performance/UnnecessaryCopyInitialization.cpp
===
--- clang-tools-extra/clang-tidy/performance/UnnecessaryCopyInitialization.cpp
+++ clang-tools-extra/clang-tidy/performance/UnnecessaryCopyInitialization.cpp
@@ -39,14 +39,35 @@
   }
 }
 
+llvm::Optional firstLocAfterNewLine(SourceLocation Loc,
+SourceManager &SM) {
+  bool Invalid;
+  const char *TextAfter = SM.getCharacterData(Loc, &Invalid);
+  if (Invalid) {
+return llvm::None;
+  }
+  size_t Offset = std::strcspn(TextAfter, "\n");
+  return Loc.getLocWithOffset(TextAfter[Offset] == '\0' ? Offset : Offset + 1);
+}
+
 void recordRemoval(const DeclStmt &Stmt, ASTContext &Context,
DiagnosticBuilder &Diagnostic) {
-  // Attempt to remove the whole line until the next non-comment token.
-  auto Tok = utils::lexer::findNextTokenSkippingComments(
-  Stmt.getEndLoc(), Context.getSourceManager(), Context.getLangOpts());
-  if (Tok) {
-Diagnostic << FixItHint::CreateRemoval(SourceRange(
-Stmt.getBeginLoc(), Tok->getLocation().getLocWithOffset(-1)));
+  auto &SM = Context.getSourceManager();
+  // Attempt to remove trailing comments as well.
+  auto Tok = utils::lexer::findNextTokenSkippingComments(Stmt.getEndLoc(), SM,
+ 
Context.getLangOpts());
+  llvm::Optional PastNewLine =
+  firstLocAfterNewLine(Stmt.getEndLoc(), SM);
+  if (Tok && PastNewLine) {
+auto BeforeFirstTokenAfterComment = 
Tok->getLocation().getLocWithOffset(-1);
+// Remove until the end of the line or the end of a trailing comment which
+// ever comes first.
+auto End =
+SM.isBeforeInTranslationUnit(*PastNewLine, 
BeforeFirstTokenAfterComment)
+? *PastNewLine
+: BeforeFirstTokenAfterComment;
+Diagnostic << FixItHint::CreateRemoval(
+SourceRange(Stmt.getBeginLoc(), End));
   } else {
 Diagnostic << FixItHint::CreateRemoval(Stmt.getSourceRange());
   }


Index: clang-tools-extra/test/clang-tidy/checkers/performance-unnecessary-copy-initialization.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/performance-unnecessary-copy-initialization.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/performance-unnecessary-copy-initialization.cpp
@@ -596,8 +596,15 @@
   // CHECK-FIXES: int i = 0; // Foo bar.
   auto TrailingCommentRemoved = ExpensiveTypeReference(); // Trailing comment.
   // CHECK-MESSAGES: [[@LINE-1]]:8: warning: the variable 'TrailingCommentRemoved' is copy-constructed from a const reference but is never used;
-  // CHECK-FIXES-NOT: auto TrailingCommentRemoved = ExpensiveTypeReference(); // Trailing comment.
+  // CHECK-FIXES-NOT: auto TrailingCommentRemoved = ExpensiveTypeReference();
+  // CHECK-FIXES-NOT: // Trailing comment.
   // clang-format on
+
+  auto UnusedAndUnnecessary = ExpensiveTypeReference();
+  // Comments on a new line should not be deleted.
+  // CHECK-MESSAGES: [[@LINE-2]]:8: warning: the variable 'UnusedAndUnnecessary' is copy-constructed
+  // CHECK-FIXES-NOT: auto U

[PATCH] D105834: [PowerPC] Semachecking for XL compat builtin icbt

2021-07-12 Thread Quinn Pham via Phabricator via cfe-commits
quinnp created this revision.
Herald added subscribers: shchenz, kbarton, nemanjai.
quinnp requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

This patch is in a series of patches to provide builtins for compatibility with 
the XL compiler. This patch adds semachecking for an already implemented 
builtin, __icbt. __icbt is only valid fore Power8 and up.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D105834

Files:
  clang/lib/Sema/SemaChecking.cpp
  clang/test/CodeGen/builtins-ppc-xlcompat-pwr8.c


Index: clang/test/CodeGen/builtins-ppc-xlcompat-pwr8.c
===
--- /dev/null
+++ clang/test/CodeGen/builtins-ppc-xlcompat-pwr8.c
@@ -0,0 +1,32 @@
+// RUN: %clang_cc1 -triple powerpc64-unknown-unknown -emit-llvm %s \
+// RUN:   -target-cpu pwr8 -o - | FileCheck %s -check-prefix=CHECK-PWR8
+// RUN: %clang_cc1 -triple powerpc64le-unknown-unknown -emit-llvm %s \
+// RUN:   -target-cpu pwr8 -o - | FileCheck %s -check-prefix=CHECK-PWR8
+// RUN: %clang_cc1 -triple powerpc64-unknown-aix -emit-llvm %s \
+// RUN:   -target-cpu pwr8 -o - | FileCheck %s -check-prefix=CHECK-PWR8
+// RUN: %clang_cc1 -triple powerpc-unknown-aix %s -emit-llvm %s \
+// RUN:   -target-cpu pwr8 -o - | FileCheck %s -check-prefix=CHECK-PWR8
+// RUN: not %clang_cc1 -triple powerpc64-unknown-unknown -emit-llvm %s \
+// RUN:   -target-cpu pwr7 2>&1 | FileCheck %s -check-prefix=CHECK-NOPWR8
+// RUN: not %clang_cc1 -triple powerpc64-unknown-aix -emit-llvm %s \
+// RUN:   -target-cpu pwr7 2>&1 | FileCheck %s -check-prefix=CHECK-NOPWR8
+// RUN: not %clang_cc1 -triple powerpc-unknown-aix %s -emit-llvm %s \
+// RUN:   -target-cpu pwr7 2>&1 | FileCheck %s -check-prefix=CHECK-NOPWR8
+
+extern void *a;
+
+void test_icbt() {
+// CHECK-LABEL: @test_icbt(
+
+  __icbt(a);
+// CHECK-PWR8: call void @llvm.ppc.icbt(i8* %0)
+// CHECK-NOPWR8: error: this builtin is only valid on POWER8 or later CPUs
+}
+
+void test_builtin_ppc_icbt() {
+// CHECK-LABEL: @test_builtin_ppc_icbt(
+
+  __builtin_ppc_icbt(a);
+// CHECK-PWR8: call void @llvm.ppc.icbt(i8* %0)
+// CHECK-NOPWR8: error: this builtin is only valid on POWER8 or later CPUs
+}
Index: clang/lib/Sema/SemaChecking.cpp
===
--- clang/lib/Sema/SemaChecking.cpp
+++ clang/lib/Sema/SemaChecking.cpp
@@ -3355,6 +3355,9 @@
  return SemaBuiltinConstantArgRange(TheCall, 2, 0, 7);
   case PPC::BI__builtin_vsx_xxpermx:
  return SemaBuiltinConstantArgRange(TheCall, 3, 0, 7);
+  case PPC::BI__builtin_ppc_icbt:
+return SemaFeatureCheck(*this, TheCall, "isa-v207-instructions",
+diag::err_ppc_builtin_only_on_arch, "8");
 #define CUSTOM_BUILTIN(Name, Intr, Types, Acc) \
   case PPC::BI__builtin_##Name: \
 return SemaBuiltinPPCMMACall(TheCall, Types);


Index: clang/test/CodeGen/builtins-ppc-xlcompat-pwr8.c
===
--- /dev/null
+++ clang/test/CodeGen/builtins-ppc-xlcompat-pwr8.c
@@ -0,0 +1,32 @@
+// RUN: %clang_cc1 -triple powerpc64-unknown-unknown -emit-llvm %s \
+// RUN:   -target-cpu pwr8 -o - | FileCheck %s -check-prefix=CHECK-PWR8
+// RUN: %clang_cc1 -triple powerpc64le-unknown-unknown -emit-llvm %s \
+// RUN:   -target-cpu pwr8 -o - | FileCheck %s -check-prefix=CHECK-PWR8
+// RUN: %clang_cc1 -triple powerpc64-unknown-aix -emit-llvm %s \
+// RUN:   -target-cpu pwr8 -o - | FileCheck %s -check-prefix=CHECK-PWR8
+// RUN: %clang_cc1 -triple powerpc-unknown-aix %s -emit-llvm %s \
+// RUN:   -target-cpu pwr8 -o - | FileCheck %s -check-prefix=CHECK-PWR8
+// RUN: not %clang_cc1 -triple powerpc64-unknown-unknown -emit-llvm %s \
+// RUN:   -target-cpu pwr7 2>&1 | FileCheck %s -check-prefix=CHECK-NOPWR8
+// RUN: not %clang_cc1 -triple powerpc64-unknown-aix -emit-llvm %s \
+// RUN:   -target-cpu pwr7 2>&1 | FileCheck %s -check-prefix=CHECK-NOPWR8
+// RUN: not %clang_cc1 -triple powerpc-unknown-aix %s -emit-llvm %s \
+// RUN:   -target-cpu pwr7 2>&1 | FileCheck %s -check-prefix=CHECK-NOPWR8
+
+extern void *a;
+
+void test_icbt() {
+// CHECK-LABEL: @test_icbt(
+
+  __icbt(a);
+// CHECK-PWR8: call void @llvm.ppc.icbt(i8* %0)
+// CHECK-NOPWR8: error: this builtin is only valid on POWER8 or later CPUs
+}
+
+void test_builtin_ppc_icbt() {
+// CHECK-LABEL: @test_builtin_ppc_icbt(
+
+  __builtin_ppc_icbt(a);
+// CHECK-PWR8: call void @llvm.ppc.icbt(i8* %0)
+// CHECK-NOPWR8: error: this builtin is only valid on POWER8 or later CPUs
+}
Index: clang/lib/Sema/SemaChecking.cpp
===
--- clang/lib/Sema/SemaChecking.cpp
+++ clang/lib/Sema/SemaChecking.cpp
@@ -3355,6 +3355,9 @@
  return SemaBuiltinConstantArgRange(TheCall, 2, 0, 7);
   case PPC::BI__builtin_vsx_xxpermx:
  return SemaBuiltinConstantArgRange(TheCall, 3, 0, 7);
+  case PPC::BI__builtin_ppc_icbt:
+return SemaFeatureCheck(*this, T

[PATCH] D105501: [PowerPC] Power ISA features for Semachecking

2021-07-12 Thread Nemanja Ivanovic via Phabricator via cfe-commits
nemanjai added a comment.

The testing is a bit overkill. A single test case with run lines for 
`-mcpu=pwr7-10` and a single prefix for each should suffice. For each prefix, 
just check for `+/-` for all the features you expect. The triples can be 
randomly distributed across the 4 run lines.
And yes, please use early exit as Lei pointed out.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105501

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


[PATCH] D105835: [Driver] Let -fno-integrated-as -gdwarf-5 use -fdwarf-directory-asm

2021-07-12 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay created this revision.
MaskRay added reviewers: debug-info, dblaikie, osandov.
MaskRay requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

While GNU as only allows the directory form of the .file directive for DWARF v5,
the integrated prefers the directory form on all DWARF versions 
(-fdwarf-directory-asm).

We currently set -fno-dwarf-directory-asm for -fno-integrated-as -gdwarf-5
which will cause the directory entry 0 and the filename entry 0 to be incorrect
(see D105662 ). This patch makes 
-fno-integrated-as -gdwarf-5 use -fdwarf-directory-asm as well.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D105835

Files:
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/test/Driver/debug-options.c


Index: clang/test/Driver/debug-options.c
===
--- clang/test/Driver/debug-options.c
+++ clang/test/Driver/debug-options.c
@@ -424,3 +424,14 @@
 // GDWARF64_VER:  error: invalid argument '-gdwarf64' only allowed with 
'DWARFv3 or greater'
 // GDWARF64_32ARCH: error: invalid argument '-gdwarf64' only allowed with '64 
bit architecture'
 // GDWARF64_ELF: error: invalid argument '-gdwarf64' only allowed with 'ELF 
platforms'
+
+/// Default to -fno-dwarf-directory-asm for -fno-integrated-as before DWARF v5.
+// RUN: %clang -### -target x86_64 -c -gdwarf-2 %s 2>&1 | FileCheck 
--check-prefix=DIRECTORY %s
+// RUN: %clang -### -target x86_64 -c -gdwarf-5 %s 2>&1 | FileCheck 
--check-prefix=DIRECTORY %s
+// RUN: %clang -### -target x86_64 -c -gdwarf-4 -fno-integrated-as %s 2>&1 | 
FileCheck --check-prefix=NODIRECTORY %s
+// RUN: %clang -### -target x86_64 -c -gdwarf-5 -fno-integrated-as %s 2>&1 | 
FileCheck --check-prefix=DIRECTORY %s
+
+// RUN: %clang -### -target x86_64 -c -gdwarf-4 -fno-dwarf-directory-asm %s 
2>&1 | FileCheck --check-prefix=NODIRECTORY %s
+
+// DIRECTORY-NOT: "-fno-dwarf-directory-asm"
+// NODIRECTORY: "-fno-dwarf-directory-asm"
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -490,14 +490,6 @@
   Default);
 }
 
-static bool ShouldDisableDwarfDirectory(const ArgList &Args,
-const ToolChain &TC) {
-  bool UseDwarfDirectory =
-  Args.hasFlag(options::OPT_fdwarf_directory_asm,
-   options::OPT_fno_dwarf_directory_asm, TC.useIntegratedAs());
-  return !UseDwarfDirectory;
-}
-
 // Convert an arg of the form "-gN" or "-ggdbN" or one of their aliases
 // to the corresponding DebugInfoKind.
 static codegenoptions::DebugInfoKind DebugLevelToInfoKind(const Arg &A) {
@@ -4175,6 +4167,14 @@
 }
   }
 
+  // To avoid join/split of directory+filename, the integrated assembler 
prefers
+  // the directory form of .file on all DWARF versions. GNU as doesn't allow 
the
+  // form before DWARF v5.
+  if (!Args.hasFlag(options::OPT_fdwarf_directory_asm,
+options::OPT_fno_dwarf_directory_asm,
+TC.useIntegratedAs() || EffectiveDWARFVersion >= 5))
+CmdArgs.push_back("-fno-dwarf-directory-asm");
+
   // Decide how to render forward declarations of template instantiations.
   // SCE wants full descriptions, others just get them in the name.
   if (DebuggerTuning == llvm::DebuggerKind::SCE)
@@ -5506,9 +5506,6 @@
   CmdArgs.push_back("-fno-gnu-keywords");
   }
 
-  if (ShouldDisableDwarfDirectory(Args, TC))
-CmdArgs.push_back("-fno-dwarf-directory-asm");
-
   if (!ShouldEnableAutolink(Args, TC, JA))
 CmdArgs.push_back("-fno-autolink");
 


Index: clang/test/Driver/debug-options.c
===
--- clang/test/Driver/debug-options.c
+++ clang/test/Driver/debug-options.c
@@ -424,3 +424,14 @@
 // GDWARF64_VER:  error: invalid argument '-gdwarf64' only allowed with 'DWARFv3 or greater'
 // GDWARF64_32ARCH: error: invalid argument '-gdwarf64' only allowed with '64 bit architecture'
 // GDWARF64_ELF: error: invalid argument '-gdwarf64' only allowed with 'ELF platforms'
+
+/// Default to -fno-dwarf-directory-asm for -fno-integrated-as before DWARF v5.
+// RUN: %clang -### -target x86_64 -c -gdwarf-2 %s 2>&1 | FileCheck --check-prefix=DIRECTORY %s
+// RUN: %clang -### -target x86_64 -c -gdwarf-5 %s 2>&1 | FileCheck --check-prefix=DIRECTORY %s
+// RUN: %clang -### -target x86_64 -c -gdwarf-4 -fno-integrated-as %s 2>&1 | FileCheck --check-prefix=NODIRECTORY %s
+// RUN: %clang -### -target x86_64 -c -gdwarf-5 -fno-integrated-as %s 2>&1 | FileCheck --check-prefix=DIRECTORY %s
+
+// RUN: %clang -### -target x86_64 -c -gdwarf-4 -fno-dwarf-directory-asm %s 2>&1 | FileCheck --check-prefix=NODIRECTORY %s
+
+// DIRECTORY-NOT: "-fno-dwarf-directory-asm"
+// NODIRECTORY: "-fno-dwarf-directory-asm"
Index: clang/lib/Driver/ToolChains/Clan

[PATCH] D104420: thread_local support for AIX

2021-07-12 Thread Hubert Tong via Phabricator via cfe-commits
hubert.reinterpretcast added inline comments.



Comment at: clang/lib/CodeGen/ItaniumCXXABI.cpp:4790
+llvm::Value *Arg2 = llvm::ConstantExpr::getBitCast(
+cast(dtor.getCallee()), FpTy);
+CGF.EmitNounwindRuntimeCall(AtExit, {Arg1, Arg2});

The function registered needs to be something more like what `createAtExitStub` 
stub creates. Otherwise, the destructor will not be able to reference `*this` 
correctly.

As it is, the registered function is currently just the destructor itself:
```
$ clang++ -target powerpc64-ibm-aix -emit-llvm -S -o - -xc++ -<<<$'struct A { 
~A(); }; thread_local A a;' | grep -C2 __pt_atexit_np
define internal void @__cxx_global_var_init() #0 {
entry:
  %0 = call i32 (i32, i32 (i32, ...)*, ...) @__pt_atexit_np(i32 0, i32 (i32, 
...)* bitcast (void (%struct.A*)* @_ZN1AD1Ev to i32 (i32, ...)*)) #3
  ret void
}
--
declare void @_ZN1AD1Ev(%struct.A* nonnull align 1 dereferenceable(1)) 
unnamed_addr #1

declare i32 @__pt_atexit_np(i32, i32 (i32, ...)*, ...)

; Function Attrs: noinline
Return:  0x00:0   Mon Jul 12 15:24:15 2021 EDT
```


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

https://reviews.llvm.org/D104420

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


[clang] 798fe3c - [PowerPC][AIX] Fix Zero-width bit fields wrt MaxFieldAlign.

2021-07-12 Thread Steven Wan via cfe-commits

Author: Steven Wan
Date: 2021-07-12T15:31:15-04:00
New Revision: 798fe3c774a1af75c8735933ded749fa62f39594

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

LOG: [PowerPC][AIX] Fix Zero-width bit fields wrt MaxFieldAlign.

On AIX when there is a pragma pack, or pragma align in effect then zero-width 
bitfields should pad out to the end of the bitfield container but not increase 
the alignment requirements of the struct greater then the max field align.

Reviewed By: ZarkoCA

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

Added: 
clang/test/Layout/aix-packed-bitfields.c

Modified: 
clang/lib/AST/RecordLayoutBuilder.cpp
clang/test/Layout/aix-bitfield-alignment.c

Removed: 




diff  --git a/clang/lib/AST/RecordLayoutBuilder.cpp 
b/clang/lib/AST/RecordLayoutBuilder.cpp
index 6ee4178248b92..972690becf9ec 100644
--- a/clang/lib/AST/RecordLayoutBuilder.cpp
+++ b/clang/lib/AST/RecordLayoutBuilder.cpp
@@ -1775,6 +1775,12 @@ void ItaniumRecordLayoutBuilder::LayoutBitField(const 
FieldDecl *D) {
   !D->getIdentifier())
 FieldAlign = UnpackedFieldAlign = 1;
 
+  // On AIX, zero-width bitfields pad out to the alignment boundary, but then
+  // do not affect overall record alignment if there is a pragma pack or
+  // pragma align(packed).
+  if (isAIXLayout(Context) && !MaxFieldAlignment.isZero() && !FieldSize)
+FieldAlign = std::min(FieldAlign, MaxFieldAlignmentInBits);
+
   // Diagnose 
diff erences in layout due to padding or packing.
   if (!UseExternalLayout)
 CheckFieldPadding(FieldOffset, UnpaddedFieldOffset, UnpackedFieldOffset,

diff  --git a/clang/test/Layout/aix-bitfield-alignment.c 
b/clang/test/Layout/aix-bitfield-alignment.c
index a736695cc6030..d47b3d7a0c7d8 100644
--- a/clang/test/Layout/aix-bitfield-alignment.c
+++ b/clang/test/Layout/aix-bitfield-alignment.c
@@ -232,3 +232,37 @@ int s = sizeof(G);
 // CHECK-NEXT:  0 | struct G
 // CHECK-NEXT: 0:0-44 |   long long ll
 // CHECK-NEXT:   sizeof=8, {{(dsize=8, )?}}align=8, 
preferredalign=8
+
+#pragma align(packed)
+struct H {
+   char c;
+   int : 0;
+   int i;
+} H;
+#pragma align(reset)
+
+int h = sizeof(H);
+
+// CHECK:  *** Dumping AST Record Layout
+// CHECK-NEXT:  0 | struct H
+// CHECK-NEXT:  0 |   char c
+// CHECK-NEXT:4:- |   int
+// CHECK-NEXT:  4 |   int i
+// CHECK-NEXT:  sizeof=8, {{(dsize=8, )?}}align=1, preferredalign=1
+
+#pragma pack(2)
+struct I {
+   char c;
+   int : 0;
+   int i;
+} I;
+#pragma pack(pop)
+
+int i = sizeof(I);
+
+// CHECK:  *** Dumping AST Record Layout
+// CHECK-NEXT:  0 | struct I
+// CHECK-NEXT:  0 |   char c
+// CHECK-NEXT:4:- |   int
+// CHECK-NEXT:  4 |   int i
+// CHECK-NEXT:  sizeof=8, {{(dsize=8, )?}}align=2, preferredalign=2

diff  --git a/clang/test/Layout/aix-packed-bitfields.c 
b/clang/test/Layout/aix-packed-bitfields.c
new file mode 100644
index 0..9bc907af0f596
--- /dev/null
+++ b/clang/test/Layout/aix-packed-bitfields.c
@@ -0,0 +1,77 @@
+// RUN: %clang_cc1 -triple powerpc-ibm-aix-xcoff -fdump-record-layouts \
+// RUN: -fsyntax-only -fxl-pragma-pack -x c %s | FileCheck  %s
+
+// RUN: %clang_cc1 -triple powerpc-ibm-aix-xcoff -fdump-record-layouts \
+// RUN: -fsyntax-only -fxl-pragma-pack -x c++ %s | FileCheck %s
+//
+// RUN: %clang_cc1 -triple powerpc64-ibm-aix-xcoff -fdump-record-layouts \
+// RUN: -fsyntax-only -fxl-pragma-pack -x c %s | FileCheck  %s
+//
+// RUN: %clang_cc1 -triple powerpc64-ibm-aix-xcoff -fdump-record-layouts \
+// RUN: -fsyntax-only -fxl-pragma-pack -x c++ %s | FileCheck %s
+
+struct A {
+  int a1 : 30;
+  int a2 : 30;
+  int a3 : 4;
+};
+
+int a = sizeof(struct A);
+
+// CHECK:  *** Dumping AST Record Layout
+// CHECK-NEXT:  0 | struct A
+// CHECK-NEXT: 0:0-29 |   int a1
+// CHECK-NEXT: 4:0-29 |   int a2
+// CHECK-NEXT:  8:0-3 |   int a3
+// CHECK-NEXT:  sizeof=12, {{(dsize=12, )?}}align=4, preferredalign=4
+
+#pragma align(packed)
+struct AlignPacked {
+  int a1 : 30;
+  int a2 : 30;
+  int a3 : 4;
+};
+#pragma align(reset)
+
+int b = sizeof(struct AlignPacked);
+
+// CHECK:  *** Dumping AST Record Layout
+// CHECK-NEXT:  0 | struct AlignPacked
+// CHECK-NEXT: 0:0-29 |   int a1
+// CHECK-NEXT: 3:6-35 |   int a2
+// CHECK-NEXT:  7:4-7 |   int a3
+// CHECK-NEXT:  sizeof=8, {{(dsize=8, )?}}align=1, preferredalign=1
+
+#pragma pack(1)
+struct Pack1 {
+  int a1 : 30;
+  int a2 : 30;
+  int a3 : 4;
+};
+#pragma pack(pop)
+
+int c = sizeof(struct Pack1);
+
+// CHECK:  *** Dumping AST Record Layout
+// CHECK-NEXT:  0 | struct Pack1
+// CHECK-NEXT: 0:0-29 |   int a1
+// CHECK-NEXT: 3:6-35 |   int a2
+// CHECK-NEXT:  7:4-7 |   int a3
+// CHECK-NEXT: 

[PATCH] D105635: [PowerPC][AIX] Fix Zero-width bit fields wrt MaxFieldAlign.

2021-07-12 Thread Steven Wan via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG798fe3c774a1: [PowerPC][AIX] Fix Zero-width bit fields wrt 
MaxFieldAlign. (authored by stevewan).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105635

Files:
  clang/lib/AST/RecordLayoutBuilder.cpp
  clang/test/Layout/aix-bitfield-alignment.c
  clang/test/Layout/aix-packed-bitfields.c

Index: clang/test/Layout/aix-packed-bitfields.c
===
--- /dev/null
+++ clang/test/Layout/aix-packed-bitfields.c
@@ -0,0 +1,77 @@
+// RUN: %clang_cc1 -triple powerpc-ibm-aix-xcoff -fdump-record-layouts \
+// RUN: -fsyntax-only -fxl-pragma-pack -x c %s | FileCheck  %s
+
+// RUN: %clang_cc1 -triple powerpc-ibm-aix-xcoff -fdump-record-layouts \
+// RUN: -fsyntax-only -fxl-pragma-pack -x c++ %s | FileCheck %s
+//
+// RUN: %clang_cc1 -triple powerpc64-ibm-aix-xcoff -fdump-record-layouts \
+// RUN: -fsyntax-only -fxl-pragma-pack -x c %s | FileCheck  %s
+//
+// RUN: %clang_cc1 -triple powerpc64-ibm-aix-xcoff -fdump-record-layouts \
+// RUN: -fsyntax-only -fxl-pragma-pack -x c++ %s | FileCheck %s
+
+struct A {
+  int a1 : 30;
+  int a2 : 30;
+  int a3 : 4;
+};
+
+int a = sizeof(struct A);
+
+// CHECK:  *** Dumping AST Record Layout
+// CHECK-NEXT:  0 | struct A
+// CHECK-NEXT: 0:0-29 |   int a1
+// CHECK-NEXT: 4:0-29 |   int a2
+// CHECK-NEXT:  8:0-3 |   int a3
+// CHECK-NEXT:  sizeof=12, {{(dsize=12, )?}}align=4, preferredalign=4
+
+#pragma align(packed)
+struct AlignPacked {
+  int a1 : 30;
+  int a2 : 30;
+  int a3 : 4;
+};
+#pragma align(reset)
+
+int b = sizeof(struct AlignPacked);
+
+// CHECK:  *** Dumping AST Record Layout
+// CHECK-NEXT:  0 | struct AlignPacked
+// CHECK-NEXT: 0:0-29 |   int a1
+// CHECK-NEXT: 3:6-35 |   int a2
+// CHECK-NEXT:  7:4-7 |   int a3
+// CHECK-NEXT:  sizeof=8, {{(dsize=8, )?}}align=1, preferredalign=1
+
+#pragma pack(1)
+struct Pack1 {
+  int a1 : 30;
+  int a2 : 30;
+  int a3 : 4;
+};
+#pragma pack(pop)
+
+int c = sizeof(struct Pack1);
+
+// CHECK:  *** Dumping AST Record Layout
+// CHECK-NEXT:  0 | struct Pack1
+// CHECK-NEXT: 0:0-29 |   int a1
+// CHECK-NEXT: 3:6-35 |   int a2
+// CHECK-NEXT:  7:4-7 |   int a3
+// CHECK-NEXT:  sizeof=8, {{(dsize=8, )?}}align=1, preferredalign=1
+
+#pragma pack(2)
+struct Pack2 {
+  int a1 : 30;
+  int a2 : 30;
+  int a3 : 4;
+};
+#pragma pack(pop)
+
+int d = sizeof(struct Pack2);
+
+// CHECK:  *** Dumping AST Record Layout
+// CHECK-NEXT:  0 | struct Pack2
+// CHECK-NEXT: 0:0-29 |   int a1
+// CHECK-NEXT: 3:6-35 |   int a2
+// CHECK-NEXT:  7:4-7 |   int a3
+// CHECK-NEXT:  sizeof=8, {{(dsize=8, )?}}align=2, preferredalign=2
Index: clang/test/Layout/aix-bitfield-alignment.c
===
--- clang/test/Layout/aix-bitfield-alignment.c
+++ clang/test/Layout/aix-bitfield-alignment.c
@@ -232,3 +232,37 @@
 // CHECK-NEXT:  0 | struct G
 // CHECK-NEXT: 0:0-44 |   long long ll
 // CHECK-NEXT:   sizeof=8, {{(dsize=8, )?}}align=8, preferredalign=8
+
+#pragma align(packed)
+struct H {
+   char c;
+   int : 0;
+   int i;
+} H;
+#pragma align(reset)
+
+int h = sizeof(H);
+
+// CHECK:  *** Dumping AST Record Layout
+// CHECK-NEXT:  0 | struct H
+// CHECK-NEXT:  0 |   char c
+// CHECK-NEXT:4:- |   int
+// CHECK-NEXT:  4 |   int i
+// CHECK-NEXT:  sizeof=8, {{(dsize=8, )?}}align=1, preferredalign=1
+
+#pragma pack(2)
+struct I {
+   char c;
+   int : 0;
+   int i;
+} I;
+#pragma pack(pop)
+
+int i = sizeof(I);
+
+// CHECK:  *** Dumping AST Record Layout
+// CHECK-NEXT:  0 | struct I
+// CHECK-NEXT:  0 |   char c
+// CHECK-NEXT:4:- |   int
+// CHECK-NEXT:  4 |   int i
+// CHECK-NEXT:  sizeof=8, {{(dsize=8, )?}}align=2, preferredalign=2
Index: clang/lib/AST/RecordLayoutBuilder.cpp
===
--- clang/lib/AST/RecordLayoutBuilder.cpp
+++ clang/lib/AST/RecordLayoutBuilder.cpp
@@ -1775,6 +1775,12 @@
   !D->getIdentifier())
 FieldAlign = UnpackedFieldAlign = 1;
 
+  // On AIX, zero-width bitfields pad out to the alignment boundary, but then
+  // do not affect overall record alignment if there is a pragma pack or
+  // pragma align(packed).
+  if (isAIXLayout(Context) && !MaxFieldAlignment.isZero() && !FieldSize)
+FieldAlign = std::min(FieldAlign, MaxFieldAlignmentInBits);
+
   // Diagnose differences in layout due to padding or packing.
   if (!UseExternalLayout)
 CheckFieldPadding(FieldOffset, UnpaddedFieldOffset, UnpackedFieldOffset,
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D102875: [PowerPC] Add PowerPC compare and multiply related builtins and instrinsics for XL compatibility

2021-07-12 Thread Victor Huang via Phabricator via cfe-commits
NeHuang added a comment.

Need to merge with https://reviews.llvm.org/D105501 changes once approved for 
pwr9 (or later processor) only sema checking.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D102875

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


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

2021-07-12 Thread Artem Belevich via Phabricator via cfe-commits
tra updated this revision to Diff 358041.
tra marked an inline comment as done.
tra edited the summary of this revision.
tra added a comment.

Addressed review comments.


Repository:
  rG LLVM Github Monorepo

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

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${aligned}.${geom}.${alayout}.${blayout}${satf}.${ptx_signature}${b1op}"
 
   generated_items=[]
 
@@ -700,22 +708,23 @@
 if not is_mma_variant_supported(op, alayout, blayout, satf):
   continue
 
-params = {
-"aligned" : ".aligned" if ptx_version >= 63 else "",

[PATCH] D102875: [PowerPC] Add PowerPC compare and multiply related builtins and instrinsics for XL compatibility

2021-07-12 Thread Victor Huang via Phabricator via cfe-commits
NeHuang added inline comments.



Comment at: llvm/test/CodeGen/PowerPC/builtins-ppc-xlcompat-multiply.ll:9
+; RUN: llc -verify-machineinstrs -mtriple=powerpc64-unknown-aix \
+; RUN:   -mcpu=pwr9 < %s | FileCheck %s --check-prefix=CHECK-64
+

amyk wrote:
> Does it make sense to add pre-P9 for these instructions that existed prior to 
> P9?
Will merge in Power ISA features Sema checking patch 
https://reviews.llvm.org/D105501 for pwr9+ only sema checking once approved.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D102875

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


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

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



Comment at: clang/test/CodeGen/builtins-nvptx-mma.py:35-38
+def make_mma_ops(geoms, types_a, types_b, types_c, types_d, b1ops=None):
   ops = []
+  if b1ops is None:
+b1ops = [""]

steffenlarsen wrote:
> 
Default initializers that use objects in python are one of the common gotchas.
https://docs.python-guide.org/writing/gotchas/#mutable-default-arguments

It probably does not make much of a difference in this case as we do not modify 
it, but I'd prefer to avoid it nevertheless.



Comment at: clang/test/CodeGen/builtins-nvptx-mma.py:84
+  # It uses __mma_tf32_m16n16k8_ld_c but __mma_m16n16k8_st_c_f32.
+  make_ldst_ops(["m16n16k8"], ["a", "b", "c", "d"], ["tf32", "f32"]))
 

steffenlarsen wrote:
> The following changes would remove the need for the `m16n16k8` cases in 
> `is_ldst_variant_supported`.
This was done deliberately. I did have that in an earlier variant of the patch, 
but eventually settled on the current version.

My thinking is that `make_ldst_ops(m16n16k8)` would create whatever is 
necessary for `m16n16k8`, and we'd keep the decision of what to produce in one 
place in `is_ldst_variant_supported`. Splitting one make_ldst_ops into two here 
makes this decision implicit which would need additional explanations. Code 
that needs less explanations  wins. :-)



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105384

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


[PATCH] D105703: [hwasan] Use stack safety analysis.

2021-07-12 Thread Florian Mayer via Phabricator via cfe-commits
fmayer updated this revision to Diff 358043.
fmayer added a comment.

update


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105703

Files:
  clang/lib/CodeGen/BackendUtil.cpp
  clang/test/CodeGen/hwasan-stack-safety-analysis-asm.c
  clang/test/CodeGen/hwasan-stack-safety-analysis.c
  llvm/include/llvm/Transforms/Instrumentation/HWAddressSanitizer.h
  llvm/lib/Transforms/Instrumentation/HWAddressSanitizer.cpp

Index: llvm/lib/Transforms/Instrumentation/HWAddressSanitizer.cpp
===
--- llvm/lib/Transforms/Instrumentation/HWAddressSanitizer.cpp
+++ llvm/lib/Transforms/Instrumentation/HWAddressSanitizer.cpp
@@ -17,6 +17,7 @@
 #include "llvm/ADT/StringExtras.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/ADT/Triple.h"
+#include "llvm/Analysis/StackSafetyAnalysis.h"
 #include "llvm/BinaryFormat/ELF.h"
 #include "llvm/IR/Attributes.h"
 #include "llvm/IR/BasicBlock.h"
@@ -109,6 +110,10 @@
cl::desc("instrument stack (allocas)"),
cl::Hidden, cl::init(true));
 
+static cl::opt
+ClUseStackSafety("hwasan-use-stack-safety", cl::Hidden, cl::init(true),
+ cl::Hidden, cl::desc("Use Stack Safety analysis results"));
+
 static cl::opt ClUARRetagToZero(
 "hwasan-uar-retag-to-zero",
 cl::desc("Clear alloca tags before returning from the function to allow "
@@ -192,13 +197,31 @@
 
 namespace {
 
+bool shouldUsePageAliases(const Triple &TargetTriple) {
+  return ClUsePageAliases && TargetTriple.getArch() == Triple::x86_64;
+// No one should use the option directly.
+#pragma GCC poison ClUsePageAliases
+}
+
+bool shouldInstrumentStack(const Triple &TargetTriple) {
+  return shouldUsePageAliases(TargetTriple) ? false : ClInstrumentStack;
+// No one should use the option directly.
+#pragma GCC poison ClInstrumentStack
+}
+
+bool shouldUseStackSafetyAnalysis(const Triple &TargetTriple) {
+  return shouldInstrumentStack(TargetTriple) && ClUseStackSafety;
+// No one should use the option directly.
+#pragma GCC poison ClUseStackSafety
+}
 /// An instrumentation pass implementing detection of addressability bugs
 /// using tagged pointers.
 class HWAddressSanitizer {
 public:
   explicit HWAddressSanitizer(Module &M, bool CompileKernel = false,
-  bool Recover = false)
-  : M(M) {
+  bool Recover = false,
+  const StackSafetyGlobalInfo *SSI = nullptr)
+  : M(M), SSI(SSI) {
 this->Recover = ClRecover.getNumOccurrences() > 0 ? ClRecover : Recover;
 this->CompileKernel = ClEnableKhwasan.getNumOccurrences() > 0
   ? ClEnableKhwasan
@@ -207,6 +230,8 @@
 initializeModule();
   }
 
+  void setSSI(const StackSafetyGlobalInfo *S) { SSI = S; }
+
   bool sanitizeFunction(Function &F);
   void initializeModule();
   void createHwasanCtorComdat();
@@ -259,6 +284,7 @@
 private:
   LLVMContext *C;
   Module &M;
+  const StackSafetyGlobalInfo *SSI;
   Triple TargetTriple;
   FunctionCallee HWAsanMemmove, HWAsanMemcpy, HWAsanMemset;
   FunctionCallee HWAsanHandleVfork;
@@ -329,8 +355,10 @@
   static char ID;
 
   explicit HWAddressSanitizerLegacyPass(bool CompileKernel = false,
-bool Recover = false)
-  : FunctionPass(ID), CompileKernel(CompileKernel), Recover(Recover) {
+bool Recover = false,
+Triple TargetTriple = {})
+  : FunctionPass(ID), CompileKernel(CompileKernel), Recover(Recover),
+TargetTriple(TargetTriple) {
 initializeHWAddressSanitizerLegacyPassPass(
 *PassRegistry::getPassRegistry());
   }
@@ -338,11 +366,18 @@
   StringRef getPassName() const override { return "HWAddressSanitizer"; }
 
   bool doInitialization(Module &M) override {
-HWASan = std::make_unique(M, CompileKernel, Recover);
+HWASan = std::make_unique(M, CompileKernel, Recover,
+  /*SSI=*/nullptr);
 return true;
   }
 
   bool runOnFunction(Function &F) override {
+if (shouldUseStackSafetyAnalysis(TargetTriple)) {
+  // We cannot call getAnalysis in doInitialization, that would cause a
+  // crash as the required analyses are not initialized yet.
+  HWASan->setSSI(
+  &getAnalysis().getResult());
+}
 return HWASan->sanitizeFunction(F);
   }
 
@@ -351,10 +386,17 @@
 return false;
   }
 
+  void getAnalysisUsage(AnalysisUsage &AU) const override {
+if (shouldUseStackSafetyAnalysis(TargetTriple)) {
+  AU.addRequired();
+}
+  }
+
 private:
   std::unique_ptr HWASan;
   bool CompileKernel;
   bool Recover;
+  Triple TargetTriple;
 };
 
 } // end anonymous namespace
@@ -370,18 +412,25 @@
 "HWAddressSanitizer: detect memory bugs using tagg

[PATCH] D98113: [Driver] Also search FilePaths for compiler-rt before falling back

2021-07-12 Thread Jon Roelofs via Phabricator via cfe-commits
jroelofs added a comment.

Why do you want to ship the builtins as part of your sysroot?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98113

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


[PATCH] D98113: [Driver] Also search FilePaths for compiler-rt before falling back

2021-07-12 Thread Jon Roelofs via Phabricator via cfe-commits
jroelofs added a comment.

> compiler-rt depends on a libc, typically newlib, which then depends on your 
> compiler

The builtins should only depend on compiler-provided headers, and not on the 
rest of libc. Agreed re: the rest of compiler-rt.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98113

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


[PATCH] D105501: [PowerPC] Power ISA features for Semachecking

2021-07-12 Thread Quinn Pham via Phabricator via cfe-commits
quinnp updated this revision to Diff 358049.
quinnp added a comment.

Addressing review comments.

Using an early exit for SemaFeatureCheck and combining the 3 test cases into 1.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105501

Files:
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/Basic/Targets/PPC.cpp
  clang/lib/Basic/Targets/PPC.h
  clang/lib/Sema/SemaChecking.cpp
  clang/test/Driver/ppc-isa-features.cpp
  llvm/lib/Target/PowerPC/PPC.td
  llvm/lib/Target/PowerPC/PPCInstrInfo.td
  llvm/lib/Target/PowerPC/PPCSubtarget.cpp
  llvm/lib/Target/PowerPC/PPCSubtarget.h

Index: llvm/lib/Target/PowerPC/PPCSubtarget.h
===
--- llvm/lib/Target/PowerPC/PPCSubtarget.h
+++ llvm/lib/Target/PowerPC/PPCSubtarget.h
@@ -146,6 +146,7 @@
   bool HasStoreFusion;
   bool HasAddiLoadFusion;
   bool HasAddisLoadFusion;
+  bool IsISA2_07;
   bool IsISA3_0;
   bool IsISA3_1;
   bool UseLongCalls;
@@ -319,6 +320,7 @@
 
   bool hasHTM() const { return HasHTM; }
   bool hasFloat128() const { return HasFloat128; }
+  bool isISA2_07() const { return IsISA2_07; }
   bool isISA3_0() const { return IsISA3_0; }
   bool isISA3_1() const { return IsISA3_1; }
   bool useLongCalls() const { return UseLongCalls; }
Index: llvm/lib/Target/PowerPC/PPCSubtarget.cpp
===
--- llvm/lib/Target/PowerPC/PPCSubtarget.cpp
+++ llvm/lib/Target/PowerPC/PPCSubtarget.cpp
@@ -126,6 +126,7 @@
   HasStoreFusion = false;
   HasAddiLoadFusion = false;
   HasAddisLoadFusion = false;
+  IsISA2_07 = false;
   IsISA3_0 = false;
   IsISA3_1 = false;
   UseLongCalls = false;
Index: llvm/lib/Target/PowerPC/PPCInstrInfo.td
===
--- llvm/lib/Target/PowerPC/PPCInstrInfo.td
+++ llvm/lib/Target/PowerPC/PPCInstrInfo.td
@@ -1176,6 +1176,7 @@
 : Predicate<"!Subtarget->getTargetMachine().Options.NoNaNsFPMath">;
 def HasBPERMD : Predicate<"Subtarget->hasBPERMD()">;
 def HasExtDiv : Predicate<"Subtarget->hasExtDiv()">;
+def IsISA2_07 : Predicate<"Subtarget->isISA2_07()">;
 def IsISA3_0 : Predicate<"Subtarget->isISA3_0()">;
 def HasFPU : Predicate<"Subtarget->hasFPU()">;
 def PCRelativeMemops : Predicate<"Subtarget->hasPCRelativeMemops()">;
Index: llvm/lib/Target/PowerPC/PPC.td
===
--- llvm/lib/Target/PowerPC/PPC.td
+++ llvm/lib/Target/PowerPC/PPC.td
@@ -210,9 +210,13 @@
 def DeprecatedDST: SubtargetFeature<"", "DeprecatedDST", "true",
   "Treat vector data stream cache control instructions as deprecated">;
 
+def FeatureISA2_07 : SubtargetFeature<"isa-v207-instructions", "IsISA2_07",
+  "true",
+  "Enable instructions in ISA 2.07.">;
 def FeatureISA3_0 : SubtargetFeature<"isa-v30-instructions", "IsISA3_0",
  "true",
- "Enable instructions in ISA 3.0.">;
+ "Enable instructions in ISA 3.0.",
+ [FeatureISA2_07]>;
 def FeatureISA3_1 : SubtargetFeature<"isa-v31-instructions", "IsISA3_1",
  "true",
  "Enable instructions in ISA 3.1.",
Index: clang/test/Driver/ppc-isa-features.cpp
===
--- /dev/null
+++ clang/test/Driver/ppc-isa-features.cpp
@@ -0,0 +1,21 @@
+// RUN: %clang -target powerpc64-unknown-unknown -mcpu=pwr7 -S -emit-llvm %s -o - | FileCheck %s -check-prefix=CHECK-PWR7
+// RUN: %clang -target powerpc64le-unknown-unknown -mcpu=pwr8 -S -emit-llvm %s -o - | FileCheck %s -check-prefix=CHECK-PWR8
+// RUN: %clang -target powerpc64-unknown-aix -mcpu=pwr9 -S -emit-llvm %s -o - | FileCheck %s -check-prefix=CHECK-PWR9
+// RUN: %clang -target powerpc-unknown-aix -mcpu=pwr10 -S -emit-llvm %s -o - | FileCheck %s -check-prefix=CHECK-PWR10
+
+// CHECK-PWR7: -isa-v207-instructions
+// CHECK-PWR7: -isa-v30-instructions
+
+// CHECK-PWR8: +isa-v207-instructions
+// CHECK-PWR8: -isa-v30-instructions
+
+// CHECK-PWR9: +isa-v207-instructions
+// CHECK-PWR9: +isa-v30-instructions
+
+// CHECK-PWR10: +isa-v207-instructions
+// CHECK-PWR10: +isa-v30-instructions
+// CHECK-PWR10: +isa-v31-instructions
+
+int main(int argc, char *argv[]) {
+  return 0;
+}
Index: clang/lib/Sema/SemaChecking.cpp
===
--- clang/lib/Sema/SemaChecking.cpp
+++ clang/lib/Sema/SemaChecking.cpp
@@ -3273,10 +3273,18 @@
 }
 
 static bool SemaFeatureCheck(Sema &S, CallExpr *TheCall,
- StringRef FeatureToCheck, unsigned DiagID) {
-  if (!S.Context.getTargetInfo().hasFeature(FeatureToCheck))
-return S.Diag(TheCall->getBeginLoc(), DiagID) <

[clang-tools-extra] 0ec8120 - [clang-tidy] performance-unnecessary-copy-initialization: Do not remove comments on new lines.

2021-07-12 Thread Felix Berger via cfe-commits

Author: Felix Berger
Date: 2021-07-12T16:23:04-04:00
New Revision: 0ec812023b43992810499b04222348fdbdb41ef2

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

LOG: [clang-tidy] performance-unnecessary-copy-initialization: Do not remove 
comments on new lines.

When deleting the copy assignment statement because copied variable is not used
only remove trailing comments on the same line.

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

Reviewed-by: ymandel

Added: 


Modified: 
clang-tools-extra/clang-tidy/performance/UnnecessaryCopyInitialization.cpp

clang-tools-extra/test/clang-tidy/checkers/performance-unnecessary-copy-initialization.cpp

Removed: 




diff  --git 
a/clang-tools-extra/clang-tidy/performance/UnnecessaryCopyInitialization.cpp 
b/clang-tools-extra/clang-tidy/performance/UnnecessaryCopyInitialization.cpp
index f69a2079e4ba1..f6b8e44785b5f 100644
--- a/clang-tools-extra/clang-tidy/performance/UnnecessaryCopyInitialization.cpp
+++ b/clang-tools-extra/clang-tidy/performance/UnnecessaryCopyInitialization.cpp
@@ -39,14 +39,35 @@ void recordFixes(const VarDecl &Var, ASTContext &Context,
   }
 }
 
+llvm::Optional firstLocAfterNewLine(SourceLocation Loc,
+SourceManager &SM) {
+  bool Invalid;
+  const char *TextAfter = SM.getCharacterData(Loc, &Invalid);
+  if (Invalid) {
+return llvm::None;
+  }
+  size_t Offset = std::strcspn(TextAfter, "\n");
+  return Loc.getLocWithOffset(TextAfter[Offset] == '\0' ? Offset : Offset + 1);
+}
+
 void recordRemoval(const DeclStmt &Stmt, ASTContext &Context,
DiagnosticBuilder &Diagnostic) {
-  // Attempt to remove the whole line until the next non-comment token.
-  auto Tok = utils::lexer::findNextTokenSkippingComments(
-  Stmt.getEndLoc(), Context.getSourceManager(), Context.getLangOpts());
-  if (Tok) {
-Diagnostic << FixItHint::CreateRemoval(SourceRange(
-Stmt.getBeginLoc(), Tok->getLocation().getLocWithOffset(-1)));
+  auto &SM = Context.getSourceManager();
+  // Attempt to remove trailing comments as well.
+  auto Tok = utils::lexer::findNextTokenSkippingComments(Stmt.getEndLoc(), SM,
+ 
Context.getLangOpts());
+  llvm::Optional PastNewLine =
+  firstLocAfterNewLine(Stmt.getEndLoc(), SM);
+  if (Tok && PastNewLine) {
+auto BeforeFirstTokenAfterComment = 
Tok->getLocation().getLocWithOffset(-1);
+// Remove until the end of the line or the end of a trailing comment which
+// ever comes first.
+auto End =
+SM.isBeforeInTranslationUnit(*PastNewLine, 
BeforeFirstTokenAfterComment)
+? *PastNewLine
+: BeforeFirstTokenAfterComment;
+Diagnostic << FixItHint::CreateRemoval(
+SourceRange(Stmt.getBeginLoc(), End));
   } else {
 Diagnostic << FixItHint::CreateRemoval(Stmt.getSourceRange());
   }

diff  --git 
a/clang-tools-extra/test/clang-tidy/checkers/performance-unnecessary-copy-initialization.cpp
 
b/clang-tools-extra/test/clang-tidy/checkers/performance-unnecessary-copy-initialization.cpp
index b66a88e5cf81f..3ce151035d5be 100644
--- 
a/clang-tools-extra/test/clang-tidy/checkers/performance-unnecessary-copy-initialization.cpp
+++ 
b/clang-tools-extra/test/clang-tidy/checkers/performance-unnecessary-copy-initialization.cpp
@@ -596,8 +596,15 @@ void positiveUnusedReferenceIsRemoved() {
   // CHECK-FIXES: int i = 0; // Foo bar.
   auto TrailingCommentRemoved = ExpensiveTypeReference(); // Trailing comment.
   // CHECK-MESSAGES: [[@LINE-1]]:8: warning: the variable 
'TrailingCommentRemoved' is copy-constructed from a const reference but is 
never used;
-  // CHECK-FIXES-NOT: auto TrailingCommentRemoved = ExpensiveTypeReference(); 
// Trailing comment.
+  // CHECK-FIXES-NOT: auto TrailingCommentRemoved = ExpensiveTypeReference();
+  // CHECK-FIXES-NOT: // Trailing comment.
   // clang-format on
+
+  auto UnusedAndUnnecessary = ExpensiveTypeReference();
+  // Comments on a new line should not be deleted.
+  // CHECK-MESSAGES: [[@LINE-2]]:8: warning: the variable 
'UnusedAndUnnecessary' is copy-constructed
+  // CHECK-FIXES-NOT: auto UnusedAndUnnecessary = ExpensiveTypeReference();
+  // CHECK-FIXES: // Comments on a new line should not be deleted.
 }
 
 void negativeloopedOverObjectIsModified() {



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


[PATCH] D105734: [clang-tidy] performance-unnecessary-copy-initialization: Do not remove comments on new lines.

2021-07-12 Thread Felix Berger via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG0ec812023b43: [clang-tidy] 
performance-unnecessary-copy-initialization: Do not remove… (authored by flx).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105734

Files:
  clang-tools-extra/clang-tidy/performance/UnnecessaryCopyInitialization.cpp
  
clang-tools-extra/test/clang-tidy/checkers/performance-unnecessary-copy-initialization.cpp


Index: 
clang-tools-extra/test/clang-tidy/checkers/performance-unnecessary-copy-initialization.cpp
===
--- 
clang-tools-extra/test/clang-tidy/checkers/performance-unnecessary-copy-initialization.cpp
+++ 
clang-tools-extra/test/clang-tidy/checkers/performance-unnecessary-copy-initialization.cpp
@@ -596,8 +596,15 @@
   // CHECK-FIXES: int i = 0; // Foo bar.
   auto TrailingCommentRemoved = ExpensiveTypeReference(); // Trailing comment.
   // CHECK-MESSAGES: [[@LINE-1]]:8: warning: the variable 
'TrailingCommentRemoved' is copy-constructed from a const reference but is 
never used;
-  // CHECK-FIXES-NOT: auto TrailingCommentRemoved = ExpensiveTypeReference(); 
// Trailing comment.
+  // CHECK-FIXES-NOT: auto TrailingCommentRemoved = ExpensiveTypeReference();
+  // CHECK-FIXES-NOT: // Trailing comment.
   // clang-format on
+
+  auto UnusedAndUnnecessary = ExpensiveTypeReference();
+  // Comments on a new line should not be deleted.
+  // CHECK-MESSAGES: [[@LINE-2]]:8: warning: the variable 
'UnusedAndUnnecessary' is copy-constructed
+  // CHECK-FIXES-NOT: auto UnusedAndUnnecessary = ExpensiveTypeReference();
+  // CHECK-FIXES: // Comments on a new line should not be deleted.
 }
 
 void negativeloopedOverObjectIsModified() {
Index: 
clang-tools-extra/clang-tidy/performance/UnnecessaryCopyInitialization.cpp
===
--- clang-tools-extra/clang-tidy/performance/UnnecessaryCopyInitialization.cpp
+++ clang-tools-extra/clang-tidy/performance/UnnecessaryCopyInitialization.cpp
@@ -39,14 +39,35 @@
   }
 }
 
+llvm::Optional firstLocAfterNewLine(SourceLocation Loc,
+SourceManager &SM) {
+  bool Invalid;
+  const char *TextAfter = SM.getCharacterData(Loc, &Invalid);
+  if (Invalid) {
+return llvm::None;
+  }
+  size_t Offset = std::strcspn(TextAfter, "\n");
+  return Loc.getLocWithOffset(TextAfter[Offset] == '\0' ? Offset : Offset + 1);
+}
+
 void recordRemoval(const DeclStmt &Stmt, ASTContext &Context,
DiagnosticBuilder &Diagnostic) {
-  // Attempt to remove the whole line until the next non-comment token.
-  auto Tok = utils::lexer::findNextTokenSkippingComments(
-  Stmt.getEndLoc(), Context.getSourceManager(), Context.getLangOpts());
-  if (Tok) {
-Diagnostic << FixItHint::CreateRemoval(SourceRange(
-Stmt.getBeginLoc(), Tok->getLocation().getLocWithOffset(-1)));
+  auto &SM = Context.getSourceManager();
+  // Attempt to remove trailing comments as well.
+  auto Tok = utils::lexer::findNextTokenSkippingComments(Stmt.getEndLoc(), SM,
+ 
Context.getLangOpts());
+  llvm::Optional PastNewLine =
+  firstLocAfterNewLine(Stmt.getEndLoc(), SM);
+  if (Tok && PastNewLine) {
+auto BeforeFirstTokenAfterComment = 
Tok->getLocation().getLocWithOffset(-1);
+// Remove until the end of the line or the end of a trailing comment which
+// ever comes first.
+auto End =
+SM.isBeforeInTranslationUnit(*PastNewLine, 
BeforeFirstTokenAfterComment)
+? *PastNewLine
+: BeforeFirstTokenAfterComment;
+Diagnostic << FixItHint::CreateRemoval(
+SourceRange(Stmt.getBeginLoc(), End));
   } else {
 Diagnostic << FixItHint::CreateRemoval(Stmt.getSourceRange());
   }


Index: clang-tools-extra/test/clang-tidy/checkers/performance-unnecessary-copy-initialization.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/performance-unnecessary-copy-initialization.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/performance-unnecessary-copy-initialization.cpp
@@ -596,8 +596,15 @@
   // CHECK-FIXES: int i = 0; // Foo bar.
   auto TrailingCommentRemoved = ExpensiveTypeReference(); // Trailing comment.
   // CHECK-MESSAGES: [[@LINE-1]]:8: warning: the variable 'TrailingCommentRemoved' is copy-constructed from a const reference but is never used;
-  // CHECK-FIXES-NOT: auto TrailingCommentRemoved = ExpensiveTypeReference(); // Trailing comment.
+  // CHECK-FIXES-NOT: auto TrailingCommentRemoved = ExpensiveTypeReference();
+  // CHECK-FIXES-NOT: // Trailing comment.
   // clang-format on
+
+  auto UnusedAndUnnecessary = ExpensiveTypeReference();
+  // Comments on a new line should not be deleted.
+  // CHECK-MESSAGES: [[@LINE-2]]:8: warning: the variable 'Un

[PATCH] D98798: Produce warning for performing pointer arithmetic on a null pointer.

2021-07-12 Thread Jamie Schmeiser via Phabricator via cfe-commits
jamieschmeiser added a comment.

ping


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

https://reviews.llvm.org/D98798

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


[PATCH] D105703: [hwasan] Use stack safety analysis.

2021-07-12 Thread Evgenii Stepanov via Phabricator via cfe-commits
eugenis added a comment.

The analysis should not run at -O0.
Otherwise, LGTM.
What kind of code size improvement do you see?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105703

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


[PATCH] D105564: Fix for DWARF parsing to better handle auto return type for member functions

2021-07-12 Thread Greg Clayton via Phabricator via cfe-commits
clayborg requested changes to this revision.
clayborg added inline comments.



Comment at: lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp:1305
+
+  // If a function has an auto return type we need to find the defintion since
+  // that will have the deduced return type and adjust the FunctionDecl to

s/defintion/definition/



Comment at: lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp:2677
+
+  Symbol *defintion_class_symbol = nullptr;
+  if (m_objfile_sp) {

type



Comment at: lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp:2689
+  DWARFUnit *unit = die.GetCU();
+  DWARFCompileUnit *dcu = llvm::cast_or_null(unit);
+  DWARFDIE other_die =

check dcu to ensure it isn't NULL


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

https://reviews.llvm.org/D105564

___
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-12 Thread Yitzhak Mandelbaum via Phabricator via cfe-commits
ymandel added a comment.

Gentle ping...


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105365

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


  1   2   >