[PATCH] D72829: Implement -fsemantic-interposition

2020-01-29 Thread pre-merge checks [bot] via Phabricator via cfe-commits
merge_guards_bot added a comment.

{icon check-circle color=green} Unit tests: pass. 62325 tests passed, 0 failed 
and 838 were skipped.

{icon check-circle color=green} clang-tidy: pass.

{icon check-circle color=green} clang-format: pass.

Build artifacts 
: 
diff.json 
,
 clang-tidy.txt 
,
 clang-format.patch 
,
 CMakeCache.txt 
,
 console-log.txt 
,
 test-results.xml 


//Pre-merge checks is in beta. Report issue 
.
 Please join beta  or enable 
it for your project 
.//


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72829



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


[PATCH] D72829: Implement -fsemantic-interposition

2020-01-29 Thread serge via Phabricator via cfe-commits
serge-sans-paille updated this revision to Diff 241351.
serge-sans-paille added a comment.

Fix documentation ordering, thank goes to @arichardson for spotting that.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72829

Files:
  clang/docs/ClangCommandLineReference.rst
  clang/include/clang/Basic/LangOptions.def
  clang/include/clang/Driver/Options.td
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/test/CodeGen/semantic-interposition.c
  clang/test/Driver/clang_f_opts.c
  llvm/include/llvm/IR/GlobalValue.h
  llvm/include/llvm/IR/Module.h
  llvm/lib/IR/Globals.cpp
  llvm/lib/IR/Module.cpp
  llvm/lib/IR/Verifier.cpp
  llvm/test/Transforms/Inline/inline-semantic-interposition.ll
  llvm/test/Verifier/module-flags-semantic-interposition.ll

Index: llvm/test/Verifier/module-flags-semantic-interposition.ll
===
--- /dev/null
+++ llvm/test/Verifier/module-flags-semantic-interposition.ll
@@ -0,0 +1,12 @@
+; RUN: not llvm-as < %s -o /dev/null 2>&1 | FileCheck %s
+
+target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
+target triple = "x86_64-unknown-linux-gnu"
+
+@foo = dso_local global i32 1, align 4
+
+!llvm.module.flags = !{!0}
+
+!0 = !{i32 1, !"SemanticInterposition", float 1.}
+
+; CHECK: SemanticInterposition metadata requires constant integer argument
Index: llvm/test/Transforms/Inline/inline-semantic-interposition.ll
===
--- /dev/null
+++ llvm/test/Transforms/Inline/inline-semantic-interposition.ll
@@ -0,0 +1,26 @@
+; Check that @callee1 gets inlined while @callee2 is not, because of
+; SemanticInterposition.
+
+; RUN: opt < %s -inline -S | FileCheck %s
+
+define internal i32 @callee1(i32 %A) {
+  ret i32 %A
+}
+
+define i32 @callee2(i32 %A) {
+  ret i32 %A
+}
+
+; CHECK-LABEL: @caller
+define i32 @caller(i32 %A) {
+; CHECK-NOT: call i32 @callee1(i32 %A)
+  %A1 = call i32 @callee1(i32 %A)
+; CHECK: %A2 = call i32 @callee2(i32 %A)
+  %A2 = call i32 @callee2(i32 %A)
+; CHECK: add i32 %A, %A2
+  %R = add i32 %A1, %A2
+  ret i32 %R
+}
+
+!llvm.module.flags = !{!0}
+!0 = !{i32 1, !"SemanticInterposition", i32 1}
Index: llvm/lib/IR/Verifier.cpp
===
--- llvm/lib/IR/Verifier.cpp
+++ llvm/lib/IR/Verifier.cpp
@@ -1476,6 +1476,13 @@
"'Linker Options' named metadata no longer supported");
   }
 
+  if (ID->getString() == "SemanticInterposition") {
+ConstantInt *Value =
+mdconst::dyn_extract_or_null(Op->getOperand(2));
+Assert(Value,
+   "SemanticInterposition metadata requires constant integer argument");
+  }
+
   if (ID->getString() == "CG Profile") {
 for (const MDOperand &MDO : cast(Op->getOperand(2))->operands())
   visitModuleFlagCGProfileEntry(MDO);
Index: llvm/lib/IR/Module.cpp
===
--- llvm/lib/IR/Module.cpp
+++ llvm/lib/IR/Module.cpp
@@ -554,6 +554,20 @@
: getModuleFlag("ProfileSummary"));
 }
 
+bool Module::getSemanticInterposition() const {
+  Metadata *MF = getModuleFlag("SemanticInterposition");
+
+  auto *Val = cast_or_null(MF);
+  if (!Val)
+return false;
+
+  return cast(Val->getValue())->getZExtValue();
+}
+
+void Module::setSemanticInterposition(bool SI) {
+  addModuleFlag(ModFlagBehavior::Error, "SemanticInterposition", SI);
+}
+
 void Module::setOwnedMemoryBuffer(std::unique_ptr MB) {
   OwnedMemoryBuffer = std::move(MB);
 }
Index: llvm/lib/IR/Globals.cpp
===
--- llvm/lib/IR/Globals.cpp
+++ llvm/lib/IR/Globals.cpp
@@ -94,6 +94,13 @@
   llvm_unreachable("not a global");
 }
 
+bool GlobalValue::isInterposable() const {
+  if (isInterposableLinkage(getLinkage()))
+return true;
+  return getParent() && getParent()->getSemanticInterposition() &&
+ !isDSOLocal();
+}
+
 unsigned GlobalValue::getAlignment() const {
   if (auto *GA = dyn_cast(this)) {
 // In general we cannot compute this at the IR level, but we try.
Index: llvm/include/llvm/IR/Module.h
===
--- llvm/include/llvm/IR/Module.h
+++ llvm/include/llvm/IR/Module.h
@@ -848,6 +848,12 @@
   Metadata *getProfileSummary(bool IsCS);
   /// @}
 
+  /// Returns whether semantic interposition is to be respected.
+  bool getSemanticInterposition() const;
+
+  /// Set whether semantic interposition is to be respected.
+  void setSemanticInterposition(bool);
+
   /// Returns true if PLT should be avoided for RTLib calls.
   bool getRtLibUseGOT() const;
 
Index: llvm/include/llvm/IR/GlobalValue.h
===
--- llvm/include/llvm/IR/GlobalValue.h
+

[PATCH] D69272: Enable '#pragma STDC FENV_ACCESS' in frontend

2020-01-29 Thread Serge Pavlov via Phabricator via cfe-commits
sepavloff updated this revision to Diff 241352.
sepavloff added a comment.

Avoid using custom attribute, use Function::useFPIntrin instead.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69272

Files:
  clang/include/clang/Basic/DiagnosticParseKinds.td
  clang/include/clang/Sema/Sema.h
  clang/lib/CodeGen/CodeGenFunction.cpp
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/lib/CodeGen/CodeGenModule.h
  clang/lib/Parse/ParsePragma.cpp
  clang/lib/Parse/ParseStmt.cpp
  clang/lib/Sema/SemaStmt.cpp
  clang/test/CodeGen/pragma-fenv_access.c
  clang/test/Parser/pragma-fenv_access.c
  clang/test/Preprocessor/pragma_unknown.c

Index: clang/test/Preprocessor/pragma_unknown.c
===
--- clang/test/Preprocessor/pragma_unknown.c
+++ clang/test/Preprocessor/pragma_unknown.c
@@ -16,15 +16,6 @@
 // CHECK: {{^}}#pragma STDC FP_CONTRACT DEFAULT{{$}}
 // CHECK: {{^}}#pragma STDC FP_CONTRACT IN_BETWEEN{{$}}
 
-#pragma STDC FENV_ACCESS ON  // expected-warning {{pragma STDC FENV_ACCESS ON is not supported, ignoring pragma}}
-#pragma STDC FENV_ACCESS OFF
-#pragma STDC FENV_ACCESS DEFAULT
-#pragma STDC FENV_ACCESS IN_BETWEEN   // expected-warning {{expected 'ON' or 'OFF' or 'DEFAULT' in pragma}}
-// CHECK: {{^}}#pragma STDC FENV_ACCESS ON{{$}}
-// CHECK: {{^}}#pragma STDC FENV_ACCESS OFF{{$}}
-// CHECK: {{^}}#pragma STDC FENV_ACCESS DEFAULT{{$}}
-// CHECK: {{^}}#pragma STDC FENV_ACCESS IN_BETWEEN{{$}}
-
 #pragma STDC CX_LIMITED_RANGE ON
 #pragma STDC CX_LIMITED_RANGE OFF
 #pragma STDC CX_LIMITED_RANGE DEFAULT 
Index: clang/test/Parser/pragma-fenv_access.c
===
--- /dev/null
+++ clang/test/Parser/pragma-fenv_access.c
@@ -0,0 +1,12 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+#pragma STDC FENV_ACCESS IN_BETWEEN   // expected-warning {{expected 'ON' or 'OFF' or 'DEFAULT' in pragma}}
+
+#pragma STDC FENV_ACCESS OFF
+
+float func_04(int x, float y) {
+  if (x)
+return y + 2;
+  #pragma STDC FENV_ACCESS ON // expected-error{{'#pragma STDC FENV_ACCESS' can only appear at file scope or at the start of a compound statement}}
+  return x + y;
+}
Index: clang/test/CodeGen/pragma-fenv_access.c
===
--- /dev/null
+++ clang/test/CodeGen/pragma-fenv_access.c
@@ -0,0 +1,62 @@
+// RUN: %clang_cc1 -triple %itanium_abi_triple -emit-llvm %s -o - | FileCheck %s
+
+#pragma STDC FENV_ACCESS ON
+
+float func_01(float x, float y) {
+  return x + y;
+}
+// CHECK-LABEL: @func_01
+// CHECK: call float @llvm.experimental.constrained.fadd.f32(float {{.*}}, float {{.*}}, metadata !"round.dynamic", metadata !"fpexcept.strict")
+
+
+float func_02(float x, float y) {
+  #pragma STDC FENV_ACCESS OFF
+  return x + y;
+}
+// CHECK-LABEL: @func_02
+// CHECK: fadd float {{.*}}
+
+
+float func_03(float x, float y) {
+  return x + y;
+}
+// CHECK-LABEL: @func_03
+// CHECK: call float @llvm.experimental.constrained.fadd.f32(float {{.*}}, float {{.*}}, metadata !"round.dynamic", metadata !"fpexcept.strict")
+
+
+#pragma STDC FENV_ACCESS OFF
+
+float func_04(float x, float y) {
+  return x + y;
+}
+// CHECK-LABEL: @func_04
+// CHECK: fadd float {{.*}}
+
+
+float func_05(float x, float y) {
+  #pragma STDC FENV_ACCESS ON
+  return x + y;
+}
+// CHECK-LABEL: @func_05
+// CHECK: call float @llvm.experimental.constrained.fadd.f32(float {{.*}}, float {{.*}}, metadata !"round.dynamic", metadata !"fpexcept.strict")
+
+
+float func_06(float x, float y) {
+  return x + y;
+}
+// CHECK-LABEL: @func_06
+// CHECK: fadd float {{.*}}
+
+
+float func_07(float x, float y) {
+  x -= y;
+  if (x) {
+#pragma STDC FENV_ACCESS ON
+y *= 2;
+  }
+  return y + 4;
+}
+// CHECK-LABEL: @func_07
+// CHECK: call float @llvm.experimental.constrained.fsub.f32(float {{.*}}, float {{.*}}, metadata !"round.dynamic", metadata !"fpexcept.strict")
+// CHECK: call float @llvm.experimental.constrained.fmul.f32(float {{.*}}, float {{.*}}, metadata !"round.dynamic", metadata !"fpexcept.strict")
+// CHECK: call float @llvm.experimental.constrained.fadd.f32(float {{.*}}, float {{.*}}, metadata !"round.dynamic", metadata !"fpexcept.strict")
Index: clang/lib/Sema/SemaStmt.cpp
===
--- clang/lib/Sema/SemaStmt.cpp
+++ clang/lib/Sema/SemaStmt.cpp
@@ -381,6 +381,13 @@
   PopCompoundScope();
 }
 
+void Sema::ActOnAfterCompoundStatementLeadingPragmas() {
+  if (FPFeatures.allowFEnvAccess()) {
+FunctionDecl *F = getCurFunctionDecl();
+F->setUsesFPIntrin(true);
+  }
+}
+
 sema::CompoundScopeInfo &Sema::getCurCompoundScope() const {
   return getCurFunction()->CompoundScopes.back();
 }
Index: clang/lib/Parse/ParseStmt.cpp
===
--- clang/lib/Parse/ParseStmt.cpp
+++ clang/lib/Parse/ParseStmt.cpp
@@ -365,

[PATCH] D72222: [Driver][CodeGen] Add -fpatchable-function-entry=N[,0]

2020-01-29 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added a comment.

In D7#1847167 , @mrutland wrote:

> In D7#1846796 , @mrutland wrote:
>
> > In D7#1839207 , @MaskRay wrote:
> >
> > > I shall also mention that we are essentially making decisions for x86 
> > > people's endbr32/endbr64. I hope you can engage in x86 maintainers. 
> > > Clang's current layout is recorded at D73071 
> > > .
> >
> >
> > That's a good point w.r.t. x86; I will get in touch with the people working 
> > on ftrace and live-patching there
>
>
> I spoke with Steven Rostedt (ftrace maintainer), and Josh Poimboeuf 
> (livepatching maintainer) in the OFTC/#linux-rt IRC channel. Today x86 uses 
> `-mfentry`, and they have no reason to move to `-fpatchable-function-entry` 
> so long as the `ENDBR32/ENDBR64` instructions compose nicely with `-mfentry`.
>
> Given that, I don't think x86 kernel folk care either way.
>
> On the GCC side I was under the impression that x86 would go the same way as 
> arm64, per https://gcc.gnu.org/bugzilla/show_bug.cgi?id=92424#c4
>
> There's a GCC ticket for x86: 
> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93492
>
> Thanks,
>  Mark.


I created D73680  to place the patch label 
after BTI.

@hans Is there still time to cherry pick the patch to release/10.x? See above, 
Linux developers really want the Clang release to have compatible behavior with 
GCC.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D7



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


[clang] 509e21a - [clang] Replace SmallStr.str().str() with std::string conversion operator.

2020-01-29 Thread Jonas Devlieghere via cfe-commits

Author: Jonas Devlieghere
Date: 2020-01-29T21:27:46-08:00
New Revision: 509e21a1b9debc7fcbfb3eaf56a5dcf57de55e0e

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

LOG: [clang] Replace SmallStr.str().str() with std::string conversion operator.

Use the std::string conversion operator introduced in
d7049213d0fcda691c9e79f9b41e357198d99738.

Added: 


Modified: 
clang/lib/AST/Expr.cpp
clang/lib/CodeGen/CoverageMappingGen.cpp
clang/lib/CrossTU/CrossTranslationUnit.cpp
clang/lib/Driver/Driver.cpp
clang/lib/Lex/HeaderSearch.cpp
clang/lib/StaticAnalyzer/Core/SarifDiagnostics.cpp
clang/tools/clang-refactor/TestSupport.cpp
clang/unittests/Driver/SanitizerArgsTest.cpp
clang/unittests/Frontend/FrontendActionTest.cpp

Removed: 




diff  --git a/clang/lib/AST/Expr.cpp b/clang/lib/AST/Expr.cpp
index a0d11ee9982f..51d29aef3267 100644
--- a/clang/lib/AST/Expr.cpp
+++ b/clang/lib/AST/Expr.cpp
@@ -856,7 +856,7 @@ std::string PredefinedExpr::ComputeName(IdentKind IK, const 
Decl *CurrentDecl) {
 
 Out << Proto;
 
-return Name.str().str();
+return std::string(Name);
   }
   if (const CapturedDecl *CD = dyn_cast(CurrentDecl)) {
 for (const DeclContext *DC = CD->getParent(); DC; DC = DC->getParent())
@@ -887,7 +887,7 @@ std::string PredefinedExpr::ComputeName(IdentKind IK, const 
Decl *CurrentDecl) {
 MD->getSelector().print(Out);
 Out <<  ']';
 
-return Name.str().str();
+return std::string(Name);
   }
   if (isa(CurrentDecl) && IK == PrettyFunction) {
 // __PRETTY_FUNCTION__ -> "top level", the others produce an empty string.

diff  --git a/clang/lib/CodeGen/CoverageMappingGen.cpp 
b/clang/lib/CodeGen/CoverageMappingGen.cpp
index bdecff39c88f..ee85694f043a 100644
--- a/clang/lib/CodeGen/CoverageMappingGen.cpp
+++ b/clang/lib/CodeGen/CoverageMappingGen.cpp
@@ -1282,7 +1282,7 @@ std::string normalizeFilename(StringRef Filename) {
   llvm::SmallString<256> Path(Filename);
   llvm::sys::fs::make_absolute(Path);
   llvm::sys::path::remove_dots(Path, /*remove_dot_dot=*/true);
-  return Path.str().str();
+  return std::string(Path);
 }
 
 } // end anonymous namespace

diff  --git a/clang/lib/CrossTU/CrossTranslationUnit.cpp 
b/clang/lib/CrossTU/CrossTranslationUnit.cpp
index f182f5c2cb4d..d138985c57fd 100644
--- a/clang/lib/CrossTU/CrossTranslationUnit.cpp
+++ b/clang/lib/CrossTU/CrossTranslationUnit.cpp
@@ -149,7 +149,7 @@ parseCrossTUIndex(StringRef IndexPath, StringRef 
CrossTUDir) {
   StringRef FileName = LineRef.substr(Pos + 1);
   SmallString<256> FilePath = CrossTUDir;
   llvm::sys::path::append(FilePath, FileName);
-  Result[LookupName] = FilePath.str().str();
+  Result[LookupName] = std::string(FilePath);
 } else
   return llvm::make_error(
   index_error_code::invalid_index_format, IndexPath.str(), LineNo);

diff  --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp
index 0813146406ad..6db791ab8333 100644
--- a/clang/lib/Driver/Driver.cpp
+++ b/clang/lib/Driver/Driver.cpp
@@ -4650,7 +4650,7 @@ std::string Driver::GetFilePath(StringRef Name, const 
ToolChain &TC) const {
   SmallString<128> P(Dir[0] == '=' ? SysRoot + Dir.substr(1) : Dir);
   llvm::sys::path::append(P, Name);
   if (llvm::sys::fs::exists(Twine(P)))
-return P.str().str();
+return std::string(P);
 }
 return None;
   };

diff  --git a/clang/lib/Lex/HeaderSearch.cpp b/clang/lib/Lex/HeaderSearch.cpp
index ff9272ec3e1a..73c02d7f6e6d 100644
--- a/clang/lib/Lex/HeaderSearch.cpp
+++ b/clang/lib/Lex/HeaderSearch.cpp
@@ -159,7 +159,7 @@ std::string 
HeaderSearch::getPrebuiltModuleFileName(StringRef ModuleName,
 llvm::sys::fs::make_absolute(Result);
 llvm::sys::path::append(Result, ModuleName + ".pcm");
 if (getFileMgr().getFile(Result.str()))
-  return Result.str().str();
+  return std::string(Result);
   }
   return {};
 }

diff  --git a/clang/lib/StaticAnalyzer/Core/SarifDiagnostics.cpp 
b/clang/lib/StaticAnalyzer/Core/SarifDiagnostics.cpp
index fb7758bfbd2a..a415ed32c05a 100644
--- a/clang/lib/StaticAnalyzer/Core/SarifDiagnostics.cpp
+++ b/clang/lib/StaticAnalyzer/Core/SarifDiagnostics.cpp
@@ -106,7 +106,7 @@ static std::string fileNameToURI(StringRef Filename) {
 }
   });
 
-  return Ret.str().str();
+  return std::string(Ret);
 }
 
 static json::Object createArtifactLocation(const FileEntry &FE) {

diff  --git a/clang/tools/clang-refactor/TestSupport.cpp 
b/clang/tools/clang-refactor/TestSupport.cpp
index 617a671d1271..02b816d5235c 100644
--- a/clang/tools/clang-refactor/TestSupport.cpp
+++ b/clang/tools/clang-refactor/TestSupport.cpp
@@ -190,7 +190,7 @@ bool TestRefactoringResultConsumer::handleAllResults() {
   const PartialDiagnosticAt &Diag = 

[PATCH] D72876: Create a clang-tidy check to warn when -dealloc is implemented inside an ObjC class category.

2020-01-29 Thread Stephane Moore via Phabricator via cfe-commits
stephanemoore added a comment.

Looks in good shape 👌 A couple nits and polish ideas.




Comment at: clang-tools-extra/clang-tidy/objc/DeallocInCategoryCheck.cpp:34
+
+void DeallocInCategoryCheck::check(const MatchFinder::MatchResult &Result) {
+  const auto *MatchedDecl = Result.Nodes.getNodeAs("dealloc");

What do you think of making a fixit that deletes the `-dealloc` implementation?



Comment at: clang-tools-extra/clang-tidy/objc/DeallocInCategoryCheck.cpp:36
+  const auto *MatchedDecl = Result.Nodes.getNodeAs("dealloc");
+  if (MatchedDecl) {
+diag(MatchedDecl->getLocation(),

I can't speak authoritatively regarding project convention but I believe that 
it's rare to condition on a nonnull match when matching on a single AST node 
(in other words, `check` would not have been called if `MatchedDecl` were 
null). I //believe// that convention is either to omit the expected condition 
or to assert the expected condition.

Examples:
https://github.com/llvm/llvm-project/blob/master/clang-tools-extra/clang-tidy/objc/MissingHashCheck.cpp#L54
https://github.com/llvm/llvm-project/blob/master/clang-tools-extra/clang-tidy/objc/ForbiddenSubclassingCheck.cpp#L73



Comment at: clang-tools-extra/clang-tidy/objc/DeallocInCategoryCheck.cpp:37-38
+  if (MatchedDecl) {
+diag(MatchedDecl->getLocation(),
+ "method -dealloc should not be implemented in a category");
+  }

What do you think of binding the category implementation declaration and 
including that in the diagnostic message?
```
  Finder->addMatcher(objcMethodDecl(isInstanceMethod(), hasName("dealloc"),

hasDeclContext(objcCategoryImplDecl().bind("impl")))
 .bind("dealloc"),
 this);

  // ...

  const auto *CID = Result.Nodes.getNodeAs("impl");
  diag(MatchedDecl->getLocation(),
   "category %0 should not implement -dealloc") << CID;
```

(admittedly, I don't recall off the top of my head how `ObjCCategoryImplDecl` 
renders in diagnostic messages so some additional tuning could be warranted)



Comment at: 
clang-tools-extra/docs/clang-tidy/checks/objc-dealloc-in-category.rst:7
+Finds implementations of ``-dealloc`` in Objective-C categories. The category
+implementation will override any dealloc in the class implementation,
+potentially causing issues.

``-dealloc``



Comment at: 
clang-tools-extra/docs/clang-tidy/checks/objc-dealloc-in-category.rst:10-11
+
+Classes implement ``-dealloc`` to perform important actions just before an
+object is deallocated, but if a category on the class implements ``-dealloc``
+it will override the class's implementation and those important actions may

Replace "just before an object is deallocated" with "to deallocate an object".

"Deallocates the memory occupied by the receiver."
https://developer.apple.com/documentation/objectivec/nsobject/1571947-dealloc?language=objc



Comment at: 
clang-tools-extra/docs/clang-tidy/checks/objc-dealloc-in-category.rst:11
+Classes implement ``-dealloc`` to perform important actions just before an
+object is deallocated, but if a category on the class implements ``-dealloc``
+it will override the class's implementation and those important actions may

Replace ", but if" with ". If"?



Comment at: 
clang-tools-extra/docs/clang-tidy/checks/objc-dealloc-in-category.rst:11
+Classes implement ``-dealloc`` to perform important actions just before an
+object is deallocated, but if a category on the class implements ``-dealloc``
+it will override the class's implementation and those important actions may

stephanemoore wrote:
> Replace ", but if" with ". If"?
I //think// we should add a comma after ``-dealloc``?



Comment at: 
clang-tools-extra/docs/clang-tidy/checks/objc-dealloc-in-category.rst:12-13
+object is deallocated, but if a category on the class implements ``-dealloc``
+it will override the class's implementation and those important actions may
+not be handled by the overriding ``-dealloc``.

Isn't it a bit more nefarious than that? `-dealloc` in the main implementation 
becomes inaccessible (though the superclass can still be invoked). Perhaps it 
would suffice to say that "unexpected deallocation behavior may occur"?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72876



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


Buildbot numbers for the week of 01/19/2020 - 01/25/2020

2020-01-29 Thread Galina Kistanova via cfe-commits
Hello everyone,

Below are some buildbot numbers for the last week of 01/19/2020 -
01/25/2020.

Please see the same data in attached csv files:

The longest time each builder was red during the week;
"Status change ratio" by active builder (percent of builds that changed the
builder status from greed to red or from red to green);
Count of commits by project;
Number of completed builds, failed builds and average build time for
successful builds per active builder;
Average waiting time for a revision to get build result per active builder
(response time).

Thanks

Galina


The longest time each builder was red during the week:
   buildername|  was_red
--+--
 clang-cmake-armv7-full   | 161:00:26
 clang-cmake-thumbv7-full-sh  | 158:15:41
 sanitizer-x86_64-linux-bootstrap | 132:54:16
 sanitizer-x86_64-linux-fast  | 131:43:08
 clang-cmake-aarch64-full | 113:11:31
 clang-cmake-aarch64-lld  | 113:06:27
 clang-cmake-armv7-selfhost   | 92:58:45
 sanitizer-x86_64-linux-android   | 92:10:14
 clang-cmake-armv8-lld| 90:05:06
 clang-cmake-armv7-selfhost-neon  | 88:36:16
 clang-cmake-armv7-global-isel| 88:16:35
 polly-arm-linux  | 84:45:41
 clang-cmake-armv7-quick  | 83:20:37
 reverse-iteration| 82:45:20
 sanitizer-x86_64-linux   | 69:36:28
 sanitizer-x86_64-linux-bootstrap-ubsan   | 67:39:56
 clang-cmake-aarch64-global-isel  | 52:50:56
 clang-cmake-aarch64-quick| 49:50:11
 llvm-clang-win-x-armv7l  | 46:38:20
 clang-hexagon-elf| 33:54:24
 clang-ppc64be-linux-multistage   | 33:01:17
 clang-ppc64be-linux-lnt  | 32:35:20
 clang-ppc64be-linux  | 32:29:54
 sanitizer-x86_64-linux-bootstrap-msan| 28:44:11
 clang-x64-windows-msvc   | 13:36:42
 lld-x86_64-win7  | 12:20:51
 llvm-clang-x86_64-expensive-checks-win   | 12:20:47
 llvm-clang-win-x-aarch64 | 09:59:50
 sanitizer-ppc64le-linux  | 09:56:57
 ppc64le-lld-multistage-test  | 07:56:40
 clang-native-arm-lnt-perf| 07:10:39
 sanitizer-ppc64be-linux  | 07:02:27
 clang-with-thin-lto-ubuntu   | 06:06:40
 clang-ppc64le-rhel   | 06:02:23
 clang-with-lto-ubuntu| 05:18:47
 clang-s390x-linux-multistage | 04:19:56
 clang-ppc64le-linux-multistage   | 04:16:47
 clang-x86_64-debian-fast | 04:16:07
 clang-x86_64-debian-new-pass-manager-fast| 04:10:02
 llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast | 03:52:54
 clang-ppc64le-linux  | 03:50:14
 clang-ppc64le-linux-lnt  | 03:39:27
 lldb-aarch64-ubuntu  | 03:12:18
 clang-cmake-armv7-lnt| 03:10:05
 lldb-x64-windows-ninja   | 03:08:33
 llvm-clang-x86_64-win-fast   | 03:03:58
 clang-s390x-linux-lnt| 03:00:42
 lldb-x86_64-debian   | 02:59:40
 llvm-clang-lld-x86_64-scei-ps4-ubuntu-fast   | 02:51:23
 clang-cmake-x86_64-avx2-linux| 02:51:17
 clang-s390x-linux| 02:47:08
 llvm-clang-x86_64-expensive-checks-ubuntu| 02:05:10
 clang-cmake-x86_64-sde-avx512-linux  | 02:00:22
 clang-atom-d525-fedora-rel   | 01:58:21
 llvm-clang-x86_64-expensive-checks-debian| 01:57:35
 clang-armv7-linux-build-cache| 01:57:07
 lld-x86_64-darwin13  | 01:38:20
 sanitizer-windows| 01:33:23
 clang-cuda-build | 01:32:32
 openmp-clang-x86_64-linux-debian | 01:24:31
 lld-x86_64-ubuntu-fast   | 01:24:21
 sanitizer-x86_64-linux-autoconf  | 01:12:23
 openmp-gcc-x86_64-linux-debian   | 01:12:15
 lld-perf-testsuite   | 01:09:04
 sanitizer-x86_64-linux-fuzzer| 01:08:12
 clang-aarch64-linux-build-cache  | 00:59:39
 clang-x86_64-linux-abi-test  | 00:41:35
(67 rows)


"Status change ratio" by active builder (percent of builds that changed the
builder status from greed to red or from red to green):
  

Buildbot numbers for the week of 01/12/2020 - 01/18/2020

2020-01-29 Thread Galina Kistanova via cfe-commits
Hello everyone,

Below are some buildbot numbers for the week of 01/12/2020 - 01/18/2020.

Please see the same data in attached csv files:

The longest time each builder was red during the week;
"Status change ratio" by active builder (percent of builds that changed the
builder status from greed to red or from red to green);
Count of commits by project;
Number of completed builds, failed builds and average build time for
successful builds per active builder;
Average waiting time for a revision to get build result per active builder
(response time).

Thanks

Galina


The longest time each builder was red during the week:
   buildername| was_red
--+-
 llvm-clang-x86_64-expensive-checks-win   | 59:29:01
 clang-cmake-aarch64-quick| 52:57:52
 clang-cmake-aarch64-global-isel  | 52:46:03
 llvm-clang-x86_64-expensive-checks-ubuntu| 26:11:10
 llvm-clang-x86_64-expensive-checks-debian| 26:04:20
 sanitizer-x86_64-linux-bootstrap-msan| 24:26:43
 clang-hexagon-elf| 15:45:08
 sanitizer-x86_64-linux-android   | 15:05:34
 lldb-x64-windows-ninja   | 13:53:15
 lldb-x86_64-debian   | 12:29:55
 clang-s390x-linux-multistage | 10:38:00
 clang-x64-windows-msvc   | 10:27:30
 clang-with-lto-ubuntu| 09:01:21
 lld-x86_64-win7  | 07:50:53
 clang-cmake-armv7-selfhost-neon  | 07:39:14
 clang-cmake-armv7-selfhost   | 07:38:48
 clang-ppc64be-linux-lnt  | 07:25:48
 clang-cmake-armv7-quick  | 07:23:47
 sanitizer-x86_64-linux-bootstrap-ubsan   | 07:19:35
 clang-s390x-linux-lnt| 07:19:16
 clang-with-thin-lto-ubuntu   | 07:11:13
 ppc64le-lld-multistage-test  | 06:52:02
 llvm-clang-x86_64-win-fast   | 06:40:34
 clang-cmake-x86_64-sde-avx512-linux  | 06:36:40
 clang-x86_64-debian-fast | 06:35:48
 clang-x86_64-debian-new-pass-manager-fast| 06:34:03
 llvm-clang-lld-x86_64-scei-ps4-ubuntu-fast   | 06:34:01
 lld-x86_64-ubuntu-fast   | 06:33:49
 clang-ppc64be-linux  | 06:33:32
 llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast | 06:30:13
 lld-x86_64-darwin13  | 06:18:38
 clang-ppc64le-linux-lnt  | 06:13:38
 clang-cmake-x86_64-avx2-linux| 06:10:29
 clang-ppc64le-rhel   | 06:04:18
 clang-ppc64le-linux  | 05:57:54
 clang-ppc64be-linux-multistage   | 05:48:08
 clang-s390x-linux| 05:24:05
 clang-atom-d525-fedora-rel   | 05:22:05
 clang-cmake-armv7-global-isel| 05:20:50
 clang-ppc64le-linux-multistage   | 05:02:57
 sanitizer-ppc64le-linux  | 04:21:17
 llvm-clang-win-x-armv7l  | 04:12:57
 clang-cmake-armv8-lld| 04:12:00
 llvm-clang-win-x-aarch64 | 04:02:05
 sanitizer-x86_64-linux   | 03:49:08
 sanitizer-ppc64be-linux  | 03:28:57
 sanitizer-x86_64-linux-autoconf  | 02:54:24
 openmp-gcc-x86_64-linux-debian   | 02:43:37
 lldb-aarch64-ubuntu  | 02:16:09
 llvm-sphinx-docs | 01:41:39
 openmp-clang-x86_64-linux-debian | 01:39:53
 libcxx-libcxxabi-x86_64-linux-ubuntu-cxx03   | 00:46:05
 sanitizer-windows| 00:44:19
 lld-perf-testsuite   | 00:31:29
 clang-x86_64-linux-abi-test  | 00:26:33
 clang-aarch64-linux-build-cache  | 00:21:37
 clang-armv7-linux-build-cache| 00:18:14
(57 rows)


"Status change ratio" by active builder (percent of builds that changed the
builder status from greed to red or from red to green):
   buildername   | builds | changes
| status_change_ratio
-++-+
 clang-ppc64le-linux-multistage  | 39 |  12
|30.8
 clang-hexagon-elf   | 11 |   3
|27.3
 clang-with-lto-ubuntu   | 64 |  14
|21.9
 ppc64le-lld-multistage-test | 79 |  14
|17.7
 sanitizer-x86_64-linux  

[PATCH] D73651: [OpenCL][CUDA][HIP][SYCL] Add norecurse

2020-01-29 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl updated this revision to Diff 241335.
yaxunl added a comment.

Remove the ToDo for CUDA/HIP.


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

https://reviews.llvm.org/D73651

Files:
  clang/lib/CodeGen/CodeGenFunction.cpp
  clang/test/CodeGenCUDA/norecurse.cu
  clang/test/CodeGenOpenCL/norecurse.cl
  clang/test/SemaCUDA/call-kernel-from-kernel.cu


Index: clang/test/SemaCUDA/call-kernel-from-kernel.cu
===
--- /dev/null
+++ clang/test/SemaCUDA/call-kernel-from-kernel.cu
@@ -0,0 +1,9 @@
+// RUN: %clang_cc1 %s --std=c++11 -triple x86_64-unknown-linux -emit-llvm -o - 
\
+// RUN:   -verify -fsyntax-only -verify-ignore-unexpected=note
+
+#include "Inputs/cuda.h"
+
+__global__ void kernel1();
+__global__ void kernel2() {
+  kernel1<<<1,1>>>(); // expected-error {{reference to __global__ function 
'kernel1' in __global__ function}}
+}
Index: clang/test/CodeGenOpenCL/norecurse.cl
===
--- /dev/null
+++ clang/test/CodeGenOpenCL/norecurse.cl
@@ -0,0 +1,6 @@
+// RUN: %clang_cc1 -O0 -emit-llvm -o - %s | FileCheck %s
+
+kernel void kernel1(int a) {}
+// CHECK: define{{.*}}@kernel1{{.*}}#[[ATTR:[0-9]*]]
+
+// CHECK: attributes #[[ATTR]] = {{.*}}norecurse
Index: clang/test/CodeGenCUDA/norecurse.cu
===
--- /dev/null
+++ clang/test/CodeGenCUDA/norecurse.cu
@@ -0,0 +1,15 @@
+// REQUIRES: amdgpu-registered-target
+// REQUIRES: nvptx-registered-target
+
+// RUN: %clang_cc1 -triple nvptx-nvidia-cuda -fcuda-is-device \
+// RUN: -emit-llvm -disable-llvm-passes -o - %s | FileCheck %s
+
+// RUN: %clang_cc1 -triple amdgcn-amd-amdhsa -fcuda-is-device \
+// RUN: -emit-llvm -disable-llvm-passes -o - -x hip %s | FileCheck %s
+
+#include "Inputs/cuda.h"
+
+__global__ void kernel1(int a) {}
+// CHECK: define{{.*}}@_Z7kernel1i{{.*}}#[[ATTR:[0-9]*]]
+
+// CHECK: attributes #[[ATTR]] = {{.*}}norecurse
Index: clang/lib/CodeGen/CodeGenFunction.cpp
===
--- clang/lib/CodeGen/CodeGenFunction.cpp
+++ clang/lib/CodeGen/CodeGenFunction.cpp
@@ -907,10 +907,24 @@
   // If we're in C++ mode and the function name is "main", it is guaranteed
   // to be norecurse by the standard (3.6.1.3 "The function main shall not be
   // used within a program").
-  if (getLangOpts().CPlusPlus)
-if (const FunctionDecl *FD = dyn_cast_or_null(D))
-  if (FD->isMain())
-Fn->addFnAttr(llvm::Attribute::NoRecurse);
+  //
+  // OpenCL C 2.0 v2.2-11 s6.9.i:
+  // Recursion is not supported.
+  //
+  // OpenCL C++ 1.0 v2.1-11 s2.9:
+  // recursive function calls (ISO C++ Section 5.2.2, item 9) unless
+  // they are a compile-time constant expression.
+  //
+  // SYCL v2.2 s2.10:
+  // kernels cannot include RTTI information, exception classes,
+  // recursive code, virtual functions or make use of C++ libraries that
+  // are not compiled for the device.
+  if (const FunctionDecl *FD = dyn_cast_or_null(D)) {
+if ((getLangOpts().CPlusPlus && FD->isMain()) || getLangOpts().OpenCL ||
+getLangOpts().SYCLIsDevice ||
+(getLangOpts().CUDA && FD->hasAttr()))
+  Fn->addFnAttr(llvm::Attribute::NoRecurse);
+  }
 
   if (const FunctionDecl *FD = dyn_cast_or_null(D))
 if (FD->usesFPIntrin())


Index: clang/test/SemaCUDA/call-kernel-from-kernel.cu
===
--- /dev/null
+++ clang/test/SemaCUDA/call-kernel-from-kernel.cu
@@ -0,0 +1,9 @@
+// RUN: %clang_cc1 %s --std=c++11 -triple x86_64-unknown-linux -emit-llvm -o - \
+// RUN:   -verify -fsyntax-only -verify-ignore-unexpected=note
+
+#include "Inputs/cuda.h"
+
+__global__ void kernel1();
+__global__ void kernel2() {
+  kernel1<<<1,1>>>(); // expected-error {{reference to __global__ function 'kernel1' in __global__ function}}
+}
Index: clang/test/CodeGenOpenCL/norecurse.cl
===
--- /dev/null
+++ clang/test/CodeGenOpenCL/norecurse.cl
@@ -0,0 +1,6 @@
+// RUN: %clang_cc1 -O0 -emit-llvm -o - %s | FileCheck %s
+
+kernel void kernel1(int a) {}
+// CHECK: define{{.*}}@kernel1{{.*}}#[[ATTR:[0-9]*]]
+
+// CHECK: attributes #[[ATTR]] = {{.*}}norecurse
Index: clang/test/CodeGenCUDA/norecurse.cu
===
--- /dev/null
+++ clang/test/CodeGenCUDA/norecurse.cu
@@ -0,0 +1,15 @@
+// REQUIRES: amdgpu-registered-target
+// REQUIRES: nvptx-registered-target
+
+// RUN: %clang_cc1 -triple nvptx-nvidia-cuda -fcuda-is-device \
+// RUN: -emit-llvm -disable-llvm-passes -o - %s | FileCheck %s
+
+// RUN: %clang_cc1 -triple amdgcn-amd-amdhsa -fcuda-is-device \
+// RUN: -emit-llvm -disable-llvm-passes -o - -x hip %s | FileCheck %s
+
+#include "Inputs/cuda.h"
+
+__global__ void kernel1(int a) {}
+// CHECK: define{{.*}}@_Z7kernel1i{{.*}}#[[

[PATCH] D69978: Separately track input and output denormal mode

2020-01-29 Thread Andy Kaylor via Phabricator via cfe-commits
andrew.w.kaylor added inline comments.



Comment at: llvm/docs/LangRef.rst:1829
+   operations. The second indicates the handling of denormal inputs to
+   floating point instructions.
+

Based on the changes below, if the second value is omitted the input mode will 
be assumed to be the same as the output mode. That should probably be 
documented. I guess you intend for that not to happen, but the documentation 
here leaves the result ambiguous if it does happen.



Comment at: llvm/docs/LangRef.rst:1848
+   should be converted to 0 as if by ``@llvm.canonicalize`` during
+   lowering.
+

Is this saying that if a backend generates an instruction that doesn't handle 
the hardware daz mode then it must insert instructions to check for normals and 
convert them to zero? If so, do you intend this to apply to all such 
instructions or only instructions that aren't able to accept denormal inputs?


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

https://reviews.llvm.org/D69978



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


[PATCH] D69868: Allow "callbr" to return non-void values

2020-01-29 Thread Bill Wendling via Phabricator via cfe-commits
void added a comment.

In D69868#1848327 , @MaskRay wrote:

> @rnk Thoughts on passing live-in formation (a bit similar to WinEH catchpad) 
> to `callbr` at the SelectionDAG stage?


To help with the review, here are some of the assumptions I'm making about the 
`INLINEASM_BR` and the copy block this patch creates:

1. The two blocks (CallBrBB and CopyBB) are "tightly coupled". I.e., you can't 
split the edge between them (not that you should want to).
2. The CopyBB block will *always* be the fall-through block. This implies that 
`INLINEASM_BR` is the only terminator in CallBrBB.
3. If one block moves, then both must move.

I would be happy to add code in the machine instruction verifier to ensure that 
these assumptions are met if you think it's necessary.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69868



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


[PATCH] D72467: Remove "mask" operand from shufflevector.

2020-01-29 Thread Eli Friedman via Phabricator via cfe-commits
efriedma updated this revision to Diff 241333.
efriedma added a comment.

Address review comments, rebase.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72467

Files:
  clang/lib/CodeGen/CGExpr.cpp
  llvm/include/llvm/ADT/ArrayRef.h
  llvm/include/llvm/Analysis/ConstantFolding.h
  llvm/include/llvm/Analysis/InstructionSimplify.h
  llvm/include/llvm/Analysis/TargetFolder.h
  llvm/include/llvm/IR/ConstantFolder.h
  llvm/include/llvm/IR/Constants.h
  llvm/include/llvm/IR/IRBuilder.h
  llvm/include/llvm/IR/Instructions.h
  llvm/include/llvm/IR/NoFolder.h
  llvm/include/llvm/IR/PatternMatch.h
  llvm/lib/Analysis/ConstantFolding.cpp
  llvm/lib/Analysis/InstructionSimplify.cpp
  llvm/lib/Analysis/TargetTransformInfo.cpp
  llvm/lib/Analysis/ValueTracking.cpp
  llvm/lib/Analysis/VectorUtils.cpp
  llvm/lib/AsmParser/LLParser.cpp
  llvm/lib/Bitcode/Reader/BitcodeReader.cpp
  llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
  llvm/lib/Bitcode/Writer/ValueEnumerator.cpp
  llvm/lib/CodeGen/CodeGenPrepare.cpp
  llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp
  llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
  llvm/lib/ExecutionEngine/Interpreter/Execution.cpp
  llvm/lib/IR/AsmWriter.cpp
  llvm/lib/IR/AutoUpgrade.cpp
  llvm/lib/IR/ConstantFold.cpp
  llvm/lib/IR/ConstantFold.h
  llvm/lib/IR/Constants.cpp
  llvm/lib/IR/ConstantsContext.h
  llvm/lib/IR/Core.cpp
  llvm/lib/IR/Instruction.cpp
  llvm/lib/IR/Instructions.cpp
  llvm/lib/IR/Verifier.cpp
  llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
  llvm/lib/Target/AMDGPU/AMDGPULowerKernelArguments.cpp
  llvm/lib/Target/AMDGPU/AMDGPURewriteOutArguments.cpp
  llvm/lib/Target/ARM/ARMISelLowering.cpp
  llvm/lib/Target/ARM/MVETailPredication.cpp
  llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp
  llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
  llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp
  llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp
  llvm/lib/Transforms/InstCombine/InstructionCombining.cpp
  llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp
  llvm/lib/Transforms/Scalar/GVN.cpp
  llvm/lib/Transforms/Scalar/GVNSink.cpp
  llvm/lib/Transforms/Scalar/NewGVN.cpp
  llvm/lib/Transforms/Scalar/RewriteStatepointsForGC.cpp
  llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
  llvm/unittests/IR/PatternMatch.cpp

Index: llvm/unittests/IR/PatternMatch.cpp
===
--- llvm/unittests/IR/PatternMatch.cpp
+++ llvm/unittests/IR/PatternMatch.cpp
@@ -991,31 +991,31 @@
   EXPECT_TRUE(match(EX3, m_ExtractElement(m_Constant(), m_ConstantInt(;
 
   // Test matching shufflevector
-  EXPECT_TRUE(match(SI1, m_ShuffleVector(m_Value(), m_Undef(), m_Zero(;
-  EXPECT_TRUE(match(SI2, m_ShuffleVector(m_Value(A), m_Value(B), m_Value(C;
+  ArrayRef Mask;
+  EXPECT_TRUE(match(SI1, m_ShuffleVector(m_Value(), m_Undef(), m_ZeroMask(;
+  EXPECT_TRUE(match(SI2, m_ShuffleVector(m_Value(A), m_Value(B), m_Mask(Mask;
   EXPECT_TRUE(A == VI3);
   EXPECT_TRUE(B == VI4);
-  EXPECT_TRUE(C == IdxVec);
   A = B = C = nullptr; // reset
 
   // Test matching the vector splat pattern
   EXPECT_TRUE(match(
   SI1,
   m_ShuffleVector(m_InsertElement(m_Undef(), m_SpecificInt(1), m_Zero()),
-  m_Undef(), m_Zero(;
+  m_Undef(), m_ZeroMask(;
   EXPECT_FALSE(match(
   SI3, m_ShuffleVector(m_InsertElement(m_Undef(), m_Value(), m_Zero()),
-   m_Undef(), m_Zero(;
+   m_Undef(), m_ZeroMask(;
   EXPECT_FALSE(match(
   SI4, m_ShuffleVector(m_InsertElement(m_Undef(), m_Value(), m_Zero()),
-   m_Undef(), m_Zero(;
+   m_Undef(), m_ZeroMask(;
   EXPECT_TRUE(match(
   SP1,
   m_ShuffleVector(m_InsertElement(m_Undef(), m_SpecificInt(2), m_Zero()),
-  m_Undef(), m_Zero(;
+  m_Undef(), m_ZeroMask(;
   EXPECT_TRUE(match(
   SP2, m_ShuffleVector(m_InsertElement(m_Undef(), m_Value(A), m_Zero()),
-   m_Undef(), m_Zero(;
+   m_Undef(), m_ZeroMask(;
   EXPECT_TRUE(A == Val);
 }
 
Index: llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
===
--- llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
+++ llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
@@ -3399,7 +3399,7 @@
 auto *O1 = B.CreateZExtOrTrunc(
 SI->getOperand(1), VectorType::get(ScalarTruncatedTy, Elements1));
 
-NewI = B.CreateShuffleVector(O0, O1, SI->getMask());
+NewI = B.CreateShuffleVector(O0, O1, SI->getShuffleMask());
   } else if (isa(I) || isa(I)) {
 // Don't do anything with the operands, just extend the result.
 continue;
Index: llvm/lib/Transforms/Scalar/RewriteStatepointsForGC.cpp
=

[PATCH] D73675: Avoid many std::tie/tuple instantiations in ASTImporter

2020-01-29 Thread pre-merge checks [bot] via Phabricator via cfe-commits
merge_guards_bot added a comment.

{icon check-circle color=green} Unit tests: pass. 62315 tests passed, 0 failed 
and 838 were skipped.

{icon times-circle color=red} clang-tidy: fail. clang-tidy found 0 errors and 
114 warnings 
.
 0 of them are added as review comments below (why? 
).

{icon times-circle color=red} clang-format: fail. Please format your changes 
with clang-format by running `git-clang-format HEAD^` or applying this patch 
.

Build artifacts 
: 
diff.json 
,
 clang-tidy.txt 
,
 clang-format.patch 
,
 CMakeCache.txt 
,
 console-log.txt 
,
 test-results.xml 


//Pre-merge checks is in beta. Report issue 
.
 Please join beta  or enable 
it for your project 
.//


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73675



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


[PATCH] D72717: [CMake] Disable libc++ filesystem tests in CrossWinToARMLinux cache file

2020-01-29 Thread Louis Dionne via Phabricator via cfe-commits
ldionne added a comment.

It's weird to mix Clang and libc++ test options because they test fundamentally 
different things. But I don't mind about this patch since it doesn't touch 
libc++ directly.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72717



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


[PATCH] D73675: Avoid many std::tie/tuple instantiations in ASTImporter

2020-01-29 Thread Arthur O'Dwyer via Phabricator via cfe-commits
Quuxplusone added inline comments.
Herald added a subscriber: rnkovacs.



Comment at: clang/lib/AST/ASTImporter.cpp:1152
+  if (Error E = importSeq(ToElementType, ToSizeExpr))
+return std::move(E);
 

As the author of [P1155 "More Implicit Move"](https://wg21.link/p1155), I would 
expect that you don't need `return std::move(E)` — `return E` should just as 
well perform "implicit move" in C++11 and later, assuming that 
`llvm::Expected` has a valid constructor from `llvm::Error&&`.

You're not seeing any compiler diagnostic that //suggests// you use `std::move` 
here, are you?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73675



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


[PATCH] D73676: [Remarks] Extend the RemarkStreamer to support other emitters

2020-01-29 Thread Francis Visoiu Mistrih via Phabricator via cfe-commits
thegameg created this revision.
thegameg added reviewers: paquette, anemet, JDevlieghere, hfinkel, fhahn.
thegameg added projects: LLVM, clang.
Herald added subscribers: dang, dexonsmith, steven_wu, hiraditya, mgorny, 
mehdi_amini.

This extends the RemarkStreamer to allow for other emitters (e.g. frontends, 
SIL, etc.) to emit remarks through a common interface.

See changes in llvm/docs/Remarks.rst for motivation and design choices.


https://reviews.llvm.org/D73676

Files:
  clang/lib/CodeGen/CodeGenAction.cpp
  llvm/docs/Remarks.rst
  llvm/include/llvm/Analysis/OptimizationRemarkEmitter.h
  llvm/include/llvm/CodeGen/AsmPrinter.h
  llvm/include/llvm/CodeGen/MachineOptimizationRemarkEmitter.h
  llvm/include/llvm/IR/LLVMContext.h
  llvm/include/llvm/IR/LLVMRemarkStreamer.h
  llvm/include/llvm/IR/RemarkStreamer.h
  llvm/include/llvm/LTO/LTO.h
  llvm/include/llvm/Remarks/RemarkStreamer.h
  llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
  llvm/lib/IR/CMakeLists.txt
  llvm/lib/IR/LLVMContext.cpp
  llvm/lib/IR/LLVMContextImpl.h
  llvm/lib/IR/LLVMRemarkStreamer.cpp
  llvm/lib/IR/RemarkStreamer.cpp
  llvm/lib/LTO/LTO.cpp
  llvm/lib/LTO/LTOBackend.cpp
  llvm/lib/LTO/LTOCodeGenerator.cpp
  llvm/lib/LTO/ThinLTOCodeGenerator.cpp
  llvm/lib/Remarks/CMakeLists.txt
  llvm/lib/Remarks/RemarkStreamer.cpp
  llvm/tools/llc/llc.cpp
  llvm/tools/opt/opt.cpp

Index: llvm/tools/opt/opt.cpp
===
--- llvm/tools/opt/opt.cpp
+++ llvm/tools/opt/opt.cpp
@@ -29,10 +29,10 @@
 #include "llvm/IR/DebugInfo.h"
 #include "llvm/IR/IRPrintingPasses.h"
 #include "llvm/IR/LLVMContext.h"
+#include "llvm/IR/LLVMRemarkStreamer.h"
 #include "llvm/IR/LegacyPassManager.h"
 #include "llvm/IR/LegacyPassNameParser.h"
 #include "llvm/IR/Module.h"
-#include "llvm/IR/RemarkStreamer.h"
 #include "llvm/IR/Verifier.h"
 #include "llvm/IRReader/IRReader.h"
 #include "llvm/InitializePasses.h"
@@ -583,9 +583,9 @@
 Context.enableDebugTypeODRUniquing();
 
   Expected> RemarksFileOrErr =
-  setupOptimizationRemarks(Context, RemarksFilename, RemarksPasses,
-   RemarksFormat, RemarksWithHotness,
-   RemarksHotnessThreshold);
+  setupLLVMOptimizationRemarks(Context, RemarksFilename, RemarksPasses,
+   RemarksFormat, RemarksWithHotness,
+   RemarksHotnessThreshold);
   if (Error E = RemarksFileOrErr.takeError()) {
 errs() << toString(std::move(E)) << '\n';
 return 1;
Index: llvm/tools/llc/llc.cpp
===
--- llvm/tools/llc/llc.cpp
+++ llvm/tools/llc/llc.cpp
@@ -29,9 +29,9 @@
 #include "llvm/IR/DiagnosticPrinter.h"
 #include "llvm/IR/IRPrintingPasses.h"
 #include "llvm/IR/LLVMContext.h"
+#include "llvm/IR/LLVMRemarkStreamer.h"
 #include "llvm/IR/LegacyPassManager.h"
 #include "llvm/IR/Module.h"
-#include "llvm/IR/RemarkStreamer.h"
 #include "llvm/IR/Verifier.h"
 #include "llvm/IRReader/IRReader.h"
 #include "llvm/InitializePasses.h"
@@ -334,9 +334,9 @@
   Context.setInlineAsmDiagnosticHandler(InlineAsmDiagHandler, &HasError);
 
   Expected> RemarksFileOrErr =
-  setupOptimizationRemarks(Context, RemarksFilename, RemarksPasses,
-   RemarksFormat, RemarksWithHotness,
-   RemarksHotnessThreshold);
+  setupLLVMOptimizationRemarks(Context, RemarksFilename, RemarksPasses,
+   RemarksFormat, RemarksWithHotness,
+   RemarksHotnessThreshold);
   if (Error E = RemarksFileOrErr.takeError()) {
 WithColor::error(errs(), argv[0]) << toString(std::move(E)) << '\n';
 return 1;
Index: llvm/lib/Remarks/RemarkStreamer.cpp
===
--- /dev/null
+++ llvm/lib/Remarks/RemarkStreamer.cpp
@@ -0,0 +1,72 @@
+//===- llvm/Remarks/RemarkStreamer.cpp - Remark Streamer -*- C++ *-===//
+//
+// 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
+//
+//===--===//
+//
+// This file contains the implementation of the main remark streamer.
+//
+//===--===//
+
+#include "llvm/Remarks/RemarkStreamer.h"
+#include "llvm/Support/CommandLine.h"
+
+using namespace llvm;
+using namespace llvm::remarks;
+
+static cl::opt EnableRemarksSection(
+"remarks-section",
+cl::desc(
+"Emit a section containing remark diagnostics metadata. By default, "
+"this is enabled for the following formats: yaml-strtab, bitstream."),
+cl::init(cl::BOU_UNSET), cl::Hidden);
+
+RemarkStreamer::RemarkStreamer(
+std::unique_ptr RemarkSerializer,
+Optional FilenameIn)
+

[PATCH] D70099: [libcxx][test] Only call valarray::min and ::max on empty containers when testing libc++

2020-01-29 Thread Casey Carter via Phabricator via cfe-commits
CaseyCarter abandoned this revision.
CaseyCarter added a subscriber: STL_MSFT.
CaseyCarter added a comment.

@STL_MSFT seems to have already fixed this by removing the problem test cases 
in bf7dc572f199007cbe042d5ea41bcf873dcedd8f 
. I'll 
simply abandon this change.


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

https://reviews.llvm.org/D70099



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


[PATCH] D73675: Avoid many std::tie/tuple instantiations in ASTImporter

2020-01-29 Thread Reid Kleckner via Phabricator via cfe-commits
rnk created this revision.
rnk added reviewers: rsmith, aaron.ballman, a_sidorin.
Herald added a reviewer: martong.
Herald added a reviewer: a.sidorin.
Herald added a reviewer: shafik.
Herald added a subscriber: teemperor.
Herald added a project: clang.

Use in-out parameters to avoid making std::tuple values. This change
uses `auto` gratuitously, but I think it actually makes the code more
uniform and more readable. The importer is trying to treat AST nodes in
a uniform way, so I think we can make an exception to the usual coding
standards.

After:

  peak memory: 604.51MB
  real: 0m19.313s
  obj size: 8,404kb

Before:

  peak memory: 954.11MB
  real: 0m26.188s
  obj size: 10,000kb

The speed is not as impressive as I hoped, but the memory use reduction
is impressive, and seems worth it.

Depends on D73667 


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D73675

Files:
  clang/lib/AST/ASTImporter.cpp

Index: clang/lib/AST/ASTImporter.cpp
===
--- clang/lib/AST/ASTImporter.cpp
+++ clang/lib/AST/ASTImporter.cpp
@@ -187,29 +187,25 @@
 }
 
 // Helper for error management in importSeq.
-template  T checkImport(Error &Err, const T &From) {
-  // Don't attempt to import nodes if we hit an error earlier.
-  if (Err)
-return T{};
-  Expected MaybeVal = import(From);
-  if (!MaybeVal) {
-Err = MaybeVal.takeError();
-return T{};
-  }
-  return *MaybeVal;
+template  void importInPlace(Error &E, T &Node) {
+  if (E)
+return;
+  Expected NewNode = import(Node);
+  if (NewNode)
+Node = *NewNode;
+  else
+E = NewNode.takeError();
 }
 
 // Import multiple objects with a single function call.
 // This should work for every type for which a variant of `import` exists.
 // The arguments are processed from left to right and import is stopped on
 // first error.
-template 
-Expected> importSeq(const Args &... args) {
+template  Error importSeq(NodeTys &... Nodes) {
   Error E = Error::success();
-  std::tuple Res{checkImport(E, args)...};
-  if (E)
-return std::move(E);
-  return std::move(Res);
+  char IterNodes[] = {(importInPlace(E, Nodes), '\0')...};
+  (void)IterNodes;
+  return E;
 }
 
 // Wrapper for an overload set.
@@ -1150,12 +1146,10 @@
 
 ExpectedType
 ASTNodeImporter::VisitConstantArrayType(const ConstantArrayType *T) {
-  QualType ToElementType;
-  const Expr *ToSizeExpr;
-  if (auto Imp = importSeq(T->getElementType(), T->getSizeExpr()))
-std::tie(ToElementType, ToSizeExpr) = *Imp;
-  else
-return Imp.takeError();
+  QualType ToElementType = T->getElementType();
+  const Expr *ToSizeExpr = T->getSizeExpr();
+  if (Error E = importSeq(ToElementType, ToSizeExpr))
+return std::move(E);
 
   return Importer.getToContext().getConstantArrayType(
   ToElementType, T->getSize(), ToSizeExpr, T->getSizeModifier(),
@@ -1175,15 +1169,11 @@
 
 ExpectedType
 ASTNodeImporter::VisitVariableArrayType(const VariableArrayType *T) {
-  QualType ToElementType;
-  Expr *ToSizeExpr;
-  SourceRange ToBracketsRange;
-  if (auto Imp = importSeq(
-  T->getElementType(), T->getSizeExpr(), T->getBracketsRange()))
-std::tie(ToElementType, ToSizeExpr, ToBracketsRange) = *Imp;
-  else
-return Imp.takeError();
-
+  QualType ToElementType = T->getElementType();
+  Expr *ToSizeExpr = T->getSizeExpr();
+  SourceRange ToBracketsRange = T->getBracketsRange();
+  if (Error E = importSeq(ToElementType, ToSizeExpr, ToBracketsRange))
+return std::move(E);
   return Importer.getToContext().getVariableArrayType(
   ToElementType, ToSizeExpr, T->getSizeModifier(),
   T->getIndexTypeCVRQualifiers(), ToBracketsRange);
@@ -1191,14 +1181,11 @@
 
 ExpectedType ASTNodeImporter::VisitDependentSizedArrayType(
 const DependentSizedArrayType *T) {
-  QualType ToElementType;
-  Expr *ToSizeExpr;
-  SourceRange ToBracketsRange;
-  if (auto Imp = importSeq(
-  T->getElementType(), T->getSizeExpr(), T->getBracketsRange()))
-std::tie(ToElementType, ToSizeExpr, ToBracketsRange) = *Imp;
-  else
-return Imp.takeError();
+  QualType ToElementType = T->getElementType();
+  Expr *ToSizeExpr = T->getSizeExpr();
+  SourceRange ToBracketsRange = T->getBracketsRange();
+  if (Error E = importSeq(ToElementType, ToSizeExpr, ToBracketsRange))
+return std::move(E);
   // SizeExpr may be null if size is not specified directly.
   // For example, 'int a[]'.
 
@@ -1264,25 +1251,21 @@
 
   FunctionProtoType::ExtProtoInfo FromEPI = T->getExtProtoInfo();
   FunctionProtoType::ExtProtoInfo ToEPI;
-
-  auto Imp = importSeq(
-  FromEPI.ExceptionSpec.NoexceptExpr,
-  FromEPI.ExceptionSpec.SourceDecl,
-  FromEPI.ExceptionSpec.SourceTemplate);
-  if (!Imp)
-return Imp.takeError();
-
   ToEPI.ExtInfo = FromEPI.ExtInfo;
   ToEPI.Variad

[PATCH] D69221: [clang][darwin] Fix search path logic for C_INCLUDE_DIRS

2020-01-29 Thread Louis Dionne via Phabricator via cfe-commits
ldionne accepted this revision.
ldionne added a comment.
This revision is now accepted and ready to land.

Do you have commit access?


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

https://reviews.llvm.org/D69221



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


[PATCH] D70099: [libcxx][test] Only call valarray::min and ::max on empty containers when testing libc++

2020-01-29 Thread Louis Dionne via Phabricator via cfe-commits
ldionne accepted this revision.
ldionne added a comment.
This revision is now accepted and ready to land.

You can go ahead and commit this.




Comment at: 
test/std/numerics/numarray/template.valarray/valarray.members/min.pass.cpp:29
 }
+#ifdef _LIBCPP_VERSION // Not portable: valarray::min requires size() >
 {

typo: `size() > 0`


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

https://reviews.llvm.org/D70099



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


[PATCH] D73357: [ARM,MVE] Add intrinsics for v[id]dupq and v[id]wdupq.

2020-01-29 Thread Dave Green via Phabricator via cfe-commits
dmgreen accepted this revision.
dmgreen added a comment.
This revision is now accepted and ready to land.

Looks good, from what I can tell.




Comment at: llvm/lib/Target/ARM/ARMISelDAGToDAG.cpp:2743
+  uint16_t Opcode;
+  switch (VT.getVectorElementType().getSizeInBits()) {
+  case 8:

VT.getScalarSizeInBits()?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73357



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


[PATCH] D69868: Allow "callbr" to return non-void values

2020-01-29 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added a comment.

@rnk Thoughts on passing live-in formation (a bit similar to WinEH catchpad) to 
`callbr` at the SelectionDAG stage?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69868



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


[PATCH] D73667: Speed up compilation of ASTImporter

2020-01-29 Thread pre-merge checks [bot] via Phabricator via cfe-commits
merge_guards_bot added a comment.

{icon times-circle color=red} Unit tests: fail. 62308 tests passed, 1 failed 
and 838 were skipped.

  failed: libc++.std/thread/futures/futures_async/async.pass.cpp

{icon check-circle color=green} clang-tidy: pass.

{icon check-circle color=green} clang-format: pass.

Build artifacts 
: 
diff.json 
,
 clang-tidy.txt 
,
 clang-format.patch 
,
 CMakeCache.txt 
,
 console-log.txt 
,
 test-results.xml 


//Pre-merge checks is in beta. Report issue 
.
 Please join beta  or enable 
it for your project 
.//


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73667



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


[PATCH] D72906: [X86] Improve X86 cmpps/cmppd/cmpss/cmpsd intrinsics with strictfp

2020-01-29 Thread Craig Topper via Phabricator via cfe-commits
craig.topper marked 2 inline comments as done.
craig.topper added inline comments.



Comment at: clang/lib/CodeGen/CGBuiltin.cpp:12363
+Cmp = Builder.CreateFCmp(Pred, Ops[0], Ops[1]);
   return EmitX86MaskedCompareResult(*this, Cmp, NumElts, Ops[3]);
 }

andrew.w.kaylor wrote:
> How hard would it be to generate a select with known safe values ahead of the 
> compare in the constrained case? 
Ultimately, I think we need target specific masked intrinsics or generic 
predicated compare intrinsics. Most of our X86 specific FP intrinsics are not 
exception correct because we aggressively removed masking when we probably 
shouldn't have.



Comment at: clang/test/CodeGen/avx-builtins-constrained.c:170
+  // CHECK-LABEL: test_mm256_cmp_pd_false_os
+  // CHECK: call <4 x double> @llvm.x86.avx.cmp.pd.256(<4 x double> %{{.*}}, 
<4 x double> %{{.*}}, i8 27)
+  return _mm256_cmp_pd(a, b, _CMP_FALSE_OS);

andrew.w.kaylor wrote:
> Does this have the strictfp attribute here? I don't think we do anything with 
> that, but it will likely be useful when we start handling strictfp for 
> target-specific intrinsics.
I don't think it does. We didn't create it with createConstrainedFPCall so I 
don't think anything would have added it.


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

https://reviews.llvm.org/D72906



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


[PATCH] D73667: Speed up compilation of ASTImporter

2020-01-29 Thread pre-merge checks [bot] via Phabricator via cfe-commits
merge_guards_bot added a comment.

{icon check-circle color=green} Unit tests: pass. 62309 tests passed, 0 failed 
and 838 were skipped.

{icon check-circle color=green} clang-tidy: pass.

{icon check-circle color=green} clang-format: pass.

Build artifacts 
: 
diff.json 
,
 clang-tidy.txt 
,
 clang-format.patch 
,
 CMakeCache.txt 
,
 console-log.txt 
,
 test-results.xml 


//Pre-merge checks is in beta. Report issue 
.
 Please join beta  or enable 
it for your project 
.//


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73667



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


[PATCH] D73651: [OpenCL][CUDA][HIP][SYCL] Add norecurse

2020-01-29 Thread Tony Tye via Phabricator via cfe-commits
t-tye added inline comments.



Comment at: clang/lib/CodeGen/CodeGenFunction.cpp:918
+  //
+  // ToDo: clang does not support CUDA/HIP dynamic parallelism, therefore
+  // CUDA/HIP kernel can be marked with norecurse. This may change in the

tra wrote:
> I believe dynamic parallelism is more like spawning a separate process, not 
> recursion, so we should be OK.
Right, dynamic parallelism is equivalent to spawn a new thread to execute the 
function. Recursion is only about the same thread calling the function. So I 
agree that the TODO about it can be removed.


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

https://reviews.llvm.org/D73651



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


[PATCH] D73667: Speed up compilation of ASTImporter

2020-01-29 Thread Reid Kleckner via Phabricator via cfe-commits
rnk added a comment.

The `Expected>` and `std::tie` instantiations are 
still expensive, and they seem avoidable. We could use this code pattern 
instead:

  ExpectedType
  ASTNodeImporter::VisitVariableArrayType(const VariableArrayType *T) {
QualType ToElementType = T->getElementType();
Expr *ToSizeExpr = T->getSizeExpr();
SourceRange ToBracketsRange = T->getBracketsRange();
if (Error E = importSeq(ToElementType, ToSizeExpr, ToBracketsRange))
  return E;
  
return Importer.getToContext().getVariableArrayType(
ToElementType, ToSizeExpr, T->getSizeModifier(),
T->getIndexTypeCVRQualifiers(), ToBracketsRange);
  }

Compare to the current pattern:
https://github.com/llvm/llvm-project/blob/master/clang/lib/AST/ASTImporter.cpp#L1176

`importSeq` would take its parameters by reference. One by one, it would 
replace them in place, or report an error.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73667



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


[PATCH] D73667: Speed up compilation of ASTImporter

2020-01-29 Thread Reid Kleckner via Phabricator via cfe-commits
rnk updated this revision to Diff 241297.
rnk added a comment.
Herald added a subscriber: rnkovacs.

- remove unintended hack to test MSVC


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73667

Files:
  clang/lib/AST/ASTImporter.cpp


Index: clang/lib/AST/ASTImporter.cpp
===
--- clang/lib/AST/ASTImporter.cpp
+++ clang/lib/AST/ASTImporter.cpp
@@ -186,32 +186,33 @@
   return import(*From);
 }
 
-template 
-Expected>
-importSeq(const T &From) {
-  Expected ToOrErr = import(From);
-  if (!ToOrErr)
-return ToOrErr.takeError();
-  return std::make_tuple(std::move(*ToOrErr));
+// Helper for error management in importSeq.
+template  T checkImport(Error &Err, const T &From) {
+  // Don't attempt to import nodes if we hit an error earlier.
+  if (Err)
+return T{};
+  Expected MaybeVal = import(From);
+  if (!MaybeVal) {
+Err = MaybeVal.takeError();
+return T{};
+  }
+  return *MaybeVal;
 }
 
 // Import multiple objects with a single function call.
 // This should work for every type for which a variant of `import` exists.
 // The arguments are processed from left to right and import is stopped on
 // first error.
-template 
-Expected>
-importSeq(const THead &FromHead, const TTail &...FromTail) {
-  Expected> ToHeadOrErr = importSeq(FromHead);
-  if (!ToHeadOrErr)
-return ToHeadOrErr.takeError();
-  Expected> ToTailOrErr = importSeq(FromTail...);
-  if (!ToTailOrErr)
-return ToTailOrErr.takeError();
-  return std::tuple_cat(*ToHeadOrErr, *ToTailOrErr);
+template 
+Expected> importSeq(const Args &... args) {
+  Error E = Error::success();
+  std::tuple Res{checkImport(E, args)...};
+  if (E)
+return std::move(E);
+  return std::move(Res);
 }
 
-// Wrapper for an overload set.
+// Wrapper for an overload set.
 template  struct CallOverloadedCreateFun {
   template 
   auto operator()(Args &&... args)


Index: clang/lib/AST/ASTImporter.cpp
===
--- clang/lib/AST/ASTImporter.cpp
+++ clang/lib/AST/ASTImporter.cpp
@@ -186,32 +186,33 @@
   return import(*From);
 }
 
-template 
-Expected>
-importSeq(const T &From) {
-  Expected ToOrErr = import(From);
-  if (!ToOrErr)
-return ToOrErr.takeError();
-  return std::make_tuple(std::move(*ToOrErr));
+// Helper for error management in importSeq.
+template  T checkImport(Error &Err, const T &From) {
+  // Don't attempt to import nodes if we hit an error earlier.
+  if (Err)
+return T{};
+  Expected MaybeVal = import(From);
+  if (!MaybeVal) {
+Err = MaybeVal.takeError();
+return T{};
+  }
+  return *MaybeVal;
 }
 
 // Import multiple objects with a single function call.
 // This should work for every type for which a variant of `import` exists.
 // The arguments are processed from left to right and import is stopped on
 // first error.
-template 
-Expected>
-importSeq(const THead &FromHead, const TTail &...FromTail) {
-  Expected> ToHeadOrErr = importSeq(FromHead);
-  if (!ToHeadOrErr)
-return ToHeadOrErr.takeError();
-  Expected> ToTailOrErr = importSeq(FromTail...);
-  if (!ToTailOrErr)
-return ToTailOrErr.takeError();
-  return std::tuple_cat(*ToHeadOrErr, *ToTailOrErr);
+template 
+Expected> importSeq(const Args &... args) {
+  Error E = Error::success();
+  std::tuple Res{checkImport(E, args)...};
+  if (E)
+return std::move(E);
+  return std::move(Res);
 }
 
-// Wrapper for an overload set.
+// Wrapper for an overload set.
 template  struct CallOverloadedCreateFun {
   template 
   auto operator()(Args &&... args)
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D73667: Speed up compilation of ASTImporter

2020-01-29 Thread Reid Kleckner via Phabricator via cfe-commits
rnk created this revision.
rnk added reviewers: rsmith, aaron.ballman.
Herald added a reviewer: martong.
Herald added a reviewer: a.sidorin.
Herald added a reviewer: shafik.
Herald added subscribers: llvm-commits, teemperor.
Herald added projects: clang, LLVM.
rnk updated this revision to Diff 241297.
rnk added a comment.
Herald added a subscriber: rnkovacs.

- remove unintended hack to test MSVC


Avoid recursively instantiating importSeq. Use initializer list
expansion to stamp out a single instantiation of std::tuple of the
deduced sequence of types, and thread the error around that tuple type.
Avoids needlessly instantiating std::tuple N-1 times.

new time to compile: 0m25.985s
old time to compile: 0m35.563s

new obj size: 10,000kb
old obj size: 12,332kb

I found the slow TU by looking at ClangBuildAnalyzer results, and looked
at -ftime-trace for the file in chrome://tracing to find this.

Tested with: clang-cl, MSVC, and GCC.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D73667

Files:
  clang/lib/AST/ASTImporter.cpp


Index: clang/lib/AST/ASTImporter.cpp
===
--- clang/lib/AST/ASTImporter.cpp
+++ clang/lib/AST/ASTImporter.cpp
@@ -186,32 +186,33 @@
   return import(*From);
 }
 
-template 
-Expected>
-importSeq(const T &From) {
-  Expected ToOrErr = import(From);
-  if (!ToOrErr)
-return ToOrErr.takeError();
-  return std::make_tuple(std::move(*ToOrErr));
+// Helper for error management in importSeq.
+template  T checkImport(Error &Err, const T &From) {
+  // Don't attempt to import nodes if we hit an error earlier.
+  if (Err)
+return T{};
+  Expected MaybeVal = import(From);
+  if (!MaybeVal) {
+Err = MaybeVal.takeError();
+return T{};
+  }
+  return *MaybeVal;
 }
 
 // Import multiple objects with a single function call.
 // This should work for every type for which a variant of `import` exists.
 // The arguments are processed from left to right and import is stopped on
 // first error.
-template 
-Expected>
-importSeq(const THead &FromHead, const TTail &...FromTail) {
-  Expected> ToHeadOrErr = importSeq(FromHead);
-  if (!ToHeadOrErr)
-return ToHeadOrErr.takeError();
-  Expected> ToTailOrErr = importSeq(FromTail...);
-  if (!ToTailOrErr)
-return ToTailOrErr.takeError();
-  return std::tuple_cat(*ToHeadOrErr, *ToTailOrErr);
+template 
+Expected> importSeq(const Args &... args) {
+  Error E = Error::success();
+  std::tuple Res{checkImport(E, args)...};
+  if (E)
+return std::move(E);
+  return std::move(Res);
 }
 
-// Wrapper for an overload set.
+// Wrapper for an overload set.
 template  struct CallOverloadedCreateFun {
   template 
   auto operator()(Args &&... args)


Index: clang/lib/AST/ASTImporter.cpp
===
--- clang/lib/AST/ASTImporter.cpp
+++ clang/lib/AST/ASTImporter.cpp
@@ -186,32 +186,33 @@
   return import(*From);
 }
 
-template 
-Expected>
-importSeq(const T &From) {
-  Expected ToOrErr = import(From);
-  if (!ToOrErr)
-return ToOrErr.takeError();
-  return std::make_tuple(std::move(*ToOrErr));
+// Helper for error management in importSeq.
+template  T checkImport(Error &Err, const T &From) {
+  // Don't attempt to import nodes if we hit an error earlier.
+  if (Err)
+return T{};
+  Expected MaybeVal = import(From);
+  if (!MaybeVal) {
+Err = MaybeVal.takeError();
+return T{};
+  }
+  return *MaybeVal;
 }
 
 // Import multiple objects with a single function call.
 // This should work for every type for which a variant of `import` exists.
 // The arguments are processed from left to right and import is stopped on
 // first error.
-template 
-Expected>
-importSeq(const THead &FromHead, const TTail &...FromTail) {
-  Expected> ToHeadOrErr = importSeq(FromHead);
-  if (!ToHeadOrErr)
-return ToHeadOrErr.takeError();
-  Expected> ToTailOrErr = importSeq(FromTail...);
-  if (!ToTailOrErr)
-return ToTailOrErr.takeError();
-  return std::tuple_cat(*ToHeadOrErr, *ToTailOrErr);
+template 
+Expected> importSeq(const Args &... args) {
+  Error E = Error::success();
+  std::tuple Res{checkImport(E, args)...};
+  if (E)
+return std::move(E);
+  return std::move(Res);
 }
 
-// Wrapper for an overload set.
+// Wrapper for an overload set.
 template  struct CallOverloadedCreateFun {
   template 
   auto operator()(Args &&... args)
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D71607: [clang-tidy] Add unsigned subtraction warning, with suggestion to convert to unsigned literals.

2020-01-29 Thread Jeffrey Sorensen via Phabricator via cfe-commits
sorenj added a comment.

My colleague pointed out that -Wsigned-conversion will not detect this very 
frequent mistake

  for (size_t i = 0; i < v.size() - 1; ++i)

It is my contention, and I think it's pretty well substantiated by reviewing 
cases where this detector fails that no coder ever really expects to subtract a 
signed value from an unsigned value.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71607



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


[PATCH] D72811: [WIP][OPENMP5.0] allow lvalue for motion clause

2020-01-29 Thread Chi Chun Chen via Phabricator via cfe-commits
cchen updated this revision to Diff 241293.
cchen added a comment.

Update due to negligence


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72811

Files:
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/CodeGen/CGOpenMPRuntime.cpp
  clang/lib/Sema/SemaOpenMP.cpp
  clang/test/OpenMP/target_map_messages.cpp
  clang/test/OpenMP/target_teams_map_messages.cpp
  clang/test/OpenMP/target_update_codegen.cpp
  clang/test/OpenMP/target_update_from_messages.cpp
  clang/test/OpenMP/target_update_to_messages.cpp

Index: clang/test/OpenMP/target_update_to_messages.cpp
===
--- clang/test/OpenMP/target_update_to_messages.cpp
+++ clang/test/OpenMP/target_update_to_messages.cpp
@@ -1,6 +1,12 @@
-// RUN: %clang_cc1 -verify -fopenmp -ferror-limit 100 %s -Wno-openmp-mapping -Wuninitialized
+// RUN: %clang_cc1 -verify=expected,le45 -fopenmp -ferror-limit 100 %s -Wno-openmp-mapping -Wuninitialized
+// RUN: %clang_cc1 -verify=expected,le45 -fopenmp -fopenmp-version=40 -ferror-limit 100 %s -Wno-openmp-mapping -Wuninitialized
+// RUN: %clang_cc1 -verify=expected,le45 -fopenmp -fopenmp-version=45 -ferror-limit 100 %s -Wno-openmp-mapping -Wuninitialized
+// RUN: %clang_cc1 -verify=expected,le50 -fopenmp -fopenmp-version=50 -ferror-limit 100 %s -Wno-openmp-mapping -Wuninitialized
 
-// RUN: %clang_cc1 -verify -fopenmp-simd -ferror-limit 100 %s -Wno-openmp-mapping -Wuninitialized
+// RUN: %clang_cc1 -verify=expected,le45 -fopenmp-simd -ferror-limit 100 %s -Wno-openmp-mapping -Wuninitialized
+// RUN: %clang_cc1 -verify=expected,le45 -fopenmp-simd -fopenmp-version=40 -ferror-limit 100 %s -Wno-openmp-mapping -Wuninitialized
+// RUN: %clang_cc1 -verify=expected,le45 -fopenmp-simd -fopenmp-version=45 -ferror-limit 100 %s -Wno-openmp-mapping -Wuninitialized
+// RUN: %clang_cc1 -verify=expected,le50 -fopenmp-simd -fopenmp-version=50 -ferror-limit 100 %s -Wno-openmp-mapping -Wuninitialized
 
 void foo() {
 }
@@ -59,6 +65,22 @@
   double *p;
   unsigned bfa : 4;
 };
+struct S8 {
+  int *ptr;
+  int a;
+  struct S7* S;
+  void foo() {
+#pragma omp target update to(*this) // le45-error {{expected expression containing only member accesses and/or array sections based on named variables}} le45-error {{expected at least one 'to' clause or 'from' clause specified to '#pragma omp target update'}}
+{}
+#pragma omp target update to(*(&(*this))) // le45-error {{expected expression containing only member accesses and/or array sections based on named variables}} le45-error {{expected at least one 'to' clause or 'from' clause specified to '#pragma omp target update'}}
+#pragma omp target update to(*(this->ptr)) // le45-error {{expected expression containing only member accesses and/or array sections based on named variables}} le45-error {{expected at least one 'to' clause or 'from' clause specified to '#pragma omp target update'}}
+#pragma omp target update to(*(&(*(this->S->i+this->S->p // le45-error {{expected expression containing only member accesses and/or array sections based on named variables}} le45-error {{expected at least one 'to' clause or 'from' clause specified to '#pragma omp target update'}}
+#pragma omp target update to(*(&(*(this->S->i+this->S->s6[0].pp // le45-error {{expected expression containing only member accesses and/or array sections based on named variables}} le45-error {{expected at least one 'to' clause or 'from' clause specified to '#pragma omp target update'}}
+#pragma omp target update to(*(&(*(a+this->ptr // le45-error {{expected expression containing only member accesses and/or array sections based on named variables}} le45-error {{expected at least one 'to' clause or 'from' clause specified to '#pragma omp target update'}}
+#pragma omp target update to(*(&(*(*(this->ptr)+a+this->ptr // le45-error {{expected expression containing only member accesses and/or array sections based on named variables}} le45-error {{expected at least one 'to' clause or 'from' clause specified to '#pragma omp target update'}}
+{}
+  }
+};
 
 S3 h;
 #pragma omp threadprivate(h) // expected-note 2 {{defined as threadprivate or thread local}}
@@ -89,12 +111,12 @@
 #pragma omp target update to(x)
 #pragma omp target update to(t[:I])
 #pragma omp target update to(T) // expected-error {{'T' does not refer to a value}} expected-error {{expected at least one 'to' clause or 'from' clause specified to '#pragma omp target update'}}
-#pragma omp target update to(I) // expected-error 2 {{expected expression containing only member accesses and/or array sections based on named variables}}
+#pragma omp target update to(I) // le50-error 2 {{expected lvalue with no function call in '#pragma omp target update' and '#pragma omp target map'}} le45-error 2 {{expected expression containing only member accesses and/or array sections based on named variables}}
 #pragma omp target update

[PATCH] D72811: [WIP][OPENMP5.0] allow lvalue for motion clause

2020-01-29 Thread Chi Chun Chen via Phabricator via cfe-commits
cchen updated this revision to Diff 241291.
cchen added a comment.

Fix based on feedback


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72811

Files:
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/CodeGen/CGOpenMPRuntime.cpp
  clang/lib/Sema/SemaOpenMP.cpp
  clang/test/OpenMP/target_map_messages.cpp
  clang/test/OpenMP/target_teams_map_messages.cpp
  clang/test/OpenMP/target_update_codegen.cpp
  clang/test/OpenMP/target_update_from_messages.cpp
  clang/test/OpenMP/target_update_to_messages.cpp

Index: clang/test/OpenMP/target_update_to_messages.cpp
===
--- clang/test/OpenMP/target_update_to_messages.cpp
+++ clang/test/OpenMP/target_update_to_messages.cpp
@@ -1,6 +1,12 @@
-// RUN: %clang_cc1 -verify -fopenmp -ferror-limit 100 %s -Wno-openmp-mapping -Wuninitialized
+// RUN: %clang_cc1 -verify=expected,le45 -fopenmp -ferror-limit 100 %s -Wno-openmp-mapping -Wuninitialized
+// RUN: %clang_cc1 -verify=expected,le45 -fopenmp -fopenmp-version=40 -ferror-limit 100 %s -Wno-openmp-mapping -Wuninitialized
+// RUN: %clang_cc1 -verify=expected,le45 -fopenmp -fopenmp-version=45 -ferror-limit 100 %s -Wno-openmp-mapping -Wuninitialized
+// RUN: %clang_cc1 -verify=expected,le50 -fopenmp -fopenmp-version=50 -ferror-limit 100 %s -Wno-openmp-mapping -Wuninitialized
 
-// RUN: %clang_cc1 -verify -fopenmp-simd -ferror-limit 100 %s -Wno-openmp-mapping -Wuninitialized
+// RUN: %clang_cc1 -verify=expected,le45 -fopenmp-simd -ferror-limit 100 %s -Wno-openmp-mapping -Wuninitialized
+// RUN: %clang_cc1 -verify=expected,le45 -fopenmp-simd -fopenmp-version=40 -ferror-limit 100 %s -Wno-openmp-mapping -Wuninitialized
+// RUN: %clang_cc1 -verify=expected,le45 -fopenmp-simd -fopenmp-version=45 -ferror-limit 100 %s -Wno-openmp-mapping -Wuninitialized
+// RUN: %clang_cc1 -verify=expected,le50 -fopenmp-simd -fopenmp-version=50 -ferror-limit 100 %s -Wno-openmp-mapping -Wuninitialized
 
 void foo() {
 }
@@ -59,6 +65,22 @@
   double *p;
   unsigned bfa : 4;
 };
+struct S8 {
+  int *ptr;
+  int a;
+  struct S7* S;
+  void foo() {
+#pragma omp target update to(*this) // le45-error {{expected expression containing only member accesses and/or array sections based on named variables}} le45-error {{expected at least one 'to' clause or 'from' clause specified to '#pragma omp target update'}}
+{}
+#pragma omp target update to(*(&(*this))) // le45-error {{expected expression containing only member accesses and/or array sections based on named variables}} le45-error {{expected at least one 'to' clause or 'from' clause specified to '#pragma omp target update'}}
+#pragma omp target update to(*(this->ptr)) // le45-error {{expected expression containing only member accesses and/or array sections based on named variables}} le45-error {{expected at least one 'to' clause or 'from' clause specified to '#pragma omp target update'}}
+#pragma omp target update to(*(&(*(this->S->i+this->S->p // le45-error {{expected expression containing only member accesses and/or array sections based on named variables}} le45-error {{expected at least one 'to' clause or 'from' clause specified to '#pragma omp target update'}}
+#pragma omp target update to(*(&(*(this->S->i+this->S->s6[0].pp // le45-error {{expected expression containing only member accesses and/or array sections based on named variables}} le45-error {{expected at least one 'to' clause or 'from' clause specified to '#pragma omp target update'}}
+#pragma omp target update to(*(&(*(a+this->ptr // le45-error {{expected expression containing only member accesses and/or array sections based on named variables}} le45-error {{expected at least one 'to' clause or 'from' clause specified to '#pragma omp target update'}}
+#pragma omp target update to(*(&(*(*(this->ptr)+a+this->ptr // le45-error {{expected expression containing only member accesses and/or array sections based on named variables}} le45-error {{expected at least one 'to' clause or 'from' clause specified to '#pragma omp target update'}}
+{}
+  }
+};
 
 S3 h;
 #pragma omp threadprivate(h) // expected-note 2 {{defined as threadprivate or thread local}}
@@ -89,12 +111,12 @@
 #pragma omp target update to(x)
 #pragma omp target update to(t[:I])
 #pragma omp target update to(T) // expected-error {{'T' does not refer to a value}} expected-error {{expected at least one 'to' clause or 'from' clause specified to '#pragma omp target update'}}
-#pragma omp target update to(I) // expected-error 2 {{expected expression containing only member accesses and/or array sections based on named variables}}
+#pragma omp target update to(I) // le50-error 2 {{expected lvalue with no function call in '#pragma omp target update' and '#pragma omp target map'}} le45-error 2 {{expected expression containing only member accesses and/or array sections based on named variables}}
 #pragma omp target update to

[PATCH] D67847: [Support] make report_fatal_error `abort` instead of `exit`

2020-01-29 Thread Yuanfang Chen via Phabricator via cfe-commits
ychen added a comment.

In D67847#1847757 , @rnk wrote:

> If we can reland this patch, it should fix this new clang bug:
>  https://bugs.llvm.org/show_bug.cgi?id=44705
>
> This was the list of failures you noted on the commit:
>
> In rG647c3f4e47de8a850ffcaa897db68702d8d2459a#885042 
> , 
> @ychen wrote:
>
> > This is going deeper...
> >
> > - Host compiler crash (looks like ppc64be-specific) 
> > http://lab.llvm.org:8011/builders/clang-ppc64be-linux-multistage/builds/23016
> >  http://lab.llvm.org:8011/builders/clang-ppc64be-linux/builds/43016 
> > http://lab.llvm.org:8011/builders/clang-ppc64be-linux-lnt/builds/34286
> > - clang/test/CXX/temp/temp.arg/temp.arg.template/p3-2a.cpp becomes 
> > pass/fail randomly
> > - test timeout 
> > http://lab.llvm.org:8011/builders/openmp-gcc-x86_64-linux-debian/builds/2170/steps/test-openmp/logs/stdio
> > - ThinLTO test failures on Redhat (passes on my ubuntu 18.04) 
> > http://lab.llvm.org:8011/builders/clang-ppc64le-rhel/builds/592
> >
> >   Will investigate.
>
>
> The ppc64be stuff seems like only someone with hardware will be able to debug 
> it.
>  For `clang/test/CXX/temp/temp.arg/temp.arg.template/p3-2a.cpp`, you are 
> saying you can reproduce that locally?
>  The timeout seems like it could be flakiness or something unrelated.
>  The thinlto failures... I'm not sure either, but again it's PPC64, so it 
> could be flakiness.
>
> It seems like it would be best to alert the owners of those bots and reland 
> and get new results, assuming things pass on less exotic bot configurations.


`p3-2a.cpp` random failure is fixed.
Thinlto / PPC issues are OOM related. PPC admin suggested recommit.

I've confirmed locally that failures on sanitier_windows are real (Patches are 
below), but I have no clue about how they are related.
D73329 
D73327 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D67847



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


[PATCH] D72829: Implement -fsemantic-interposition

2020-01-29 Thread Alexander Richardson via Phabricator via cfe-commits
arichardson added a comment.

Thanks documentation looks much better now.




Comment at: clang/docs/ClangCommandLineReference.rst:907
+
+.. option:: -fsemantic-interposition, -fno-semantic-interposition
+

arichardson wrote:
> arichardson wrote:
> > This looks like it should be reordered?
> Sorry I mean that it looks like all other entries are `.. option::` followed 
> by the description but here it's the other way around. It seems like this 
> change will make the documention of -fsanitize-* be `Enable semantic 
> interposition`.
It still looks like the documentation here is for the wrong option. I think it 
should be:

```
.. option:: -fsanitize=,..., -fno-sanitize=,...

Turn on runtime checks for various forms of undefined or suspicious behavior. 
See user manual for available checks

.. option:: -fno-semantic-interposition, -fsemantic-interposition

Enable semantic interposition. Semantic interposition allows for the
interposition of a symbol by another at run time, thus preventing a range of
inter-procedural optimisation.
```




Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72829



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


[PATCH] D73642: [Clang][Bundler] Reduce fat object size

2020-01-29 Thread Sergey Dmitriev via Phabricator via cfe-commits
sdmitriev marked an inline comment as done.
sdmitriev added inline comments.



Comment at: clang/tools/clang-offload-bundler/ClangOffloadBundler.cpp:378
+  // Creates temporary file with given contents.
+  Expected Create(Optional> Contents) {
+SmallString<128u> File;

ABataev wrote:
> I see that Contents is either `None` or just one byte `0`. Maybe, better to 
> use bool flag here instead of `Contents`?
Well, maybe we will need some other contents besides one zero byte in future, 
so I think having optional contents is probably better.


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

https://reviews.llvm.org/D73642



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


[PATCH] D73462: [dwarf-5] Support DebugInfo for Defaulted parameters for C++ templates

2020-01-29 Thread David Blaikie via Phabricator via cfe-commits
dblaikie added inline comments.



Comment at: llvm/lib/AsmParser/LLParser.cpp:4858
 ///   ::= !DITemplateValueParameter(tag: DW_TAG_template_value_parameter,
-/// name: "V", type: !1, value: i32 7)
+/// name: "V", type: !1, defaultValue: "false",
+/// value: i32 7)

dblaikie wrote:
> defaultValue should probably be rendered/encoded as a boolean, rather than a 
> string?
> 
> (& "defaultValue" might be a misleading name (if the DITemplateValueParameter 
> was a boolean non type template parameter, then "defaultValue: true" could 
> look like the default value is true, not that the "value: "parameter is the 
> default value... if that makes sense) - perhaps "defaulted" would read more 
> easily ("defaulted: true" or "defaulted: false"))
> 
> Perhaps just "default" though that still feels a bit ambiguous between "is 
> this the default value itself, or is it specifying that the "value:" field is 
> the default value?".
I see that the actual DWARFv5 feature is "DW_AT_default_value" - so I guess 
sticking with that is good, even though it's not a great name (& indeed 
elsewhere in DWARF this same attribute name is used with a value that 
represents the default value, not a boolean about whether the default value is 
elsewhere... :/)

Perhaps we should push the name further up then - into the API, (IsDefaultValue 
member, maybe make the accessor "isDefaultValue" rather than "getDefaultValue" 
to avoid some of the ambiguity/confusion, etc).


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

https://reviews.llvm.org/D73462



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


[PATCH] D73642: [Clang][Bundler] Reduce fat object size

2020-01-29 Thread Sergey Dmitriev via Phabricator via cfe-commits
sdmitriev updated this revision to Diff 241278.
sdmitriev added a comment.

Addressed review comments.


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

https://reviews.llvm.org/D73642

Files:
  clang/test/Driver/clang-offload-bundler.c
  clang/tools/clang-offload-bundler/ClangOffloadBundler.cpp

Index: clang/tools/clang-offload-bundler/ClangOffloadBundler.cpp
===
--- clang/tools/clang-offload-bundler/ClangOffloadBundler.cpp
+++ clang/tools/clang-offload-bundler/ClangOffloadBundler.cpp
@@ -30,7 +30,6 @@
 #include "llvm/Support/Error.h"
 #include "llvm/Support/ErrorOr.h"
 #include "llvm/Support/FileSystem.h"
-#include "llvm/Support/FileUtilities.h"
 #include "llvm/Support/MemoryBuffer.h"
 #include "llvm/Support/Path.h"
 #include "llvm/Support/Program.h"
@@ -365,6 +364,41 @@
   }
 };
 
+namespace {
+
+// This class implements a list of temporary files that are removed upon
+// object destruction.
+class TempFileHandlerRAII {
+public:
+  ~TempFileHandlerRAII() {
+for (const auto &File : Files)
+  sys::fs::remove(File);
+  }
+
+  // Creates temporary file with given contents.
+  Expected Create(Optional> Contents) {
+SmallString<128u> File;
+if (std::error_code EC =
+sys::fs::createTemporaryFile("clang-offload-bundler", "tmp", File))
+  return createFileError(File, EC);
+Files.push_back(File);
+
+if (Contents) {
+  std::error_code EC;
+  raw_fd_ostream OS(File, EC);
+  if (EC)
+return createFileError(File, EC);
+  OS.write(Contents->data(), Contents->size());
+}
+return Files.back();
+  }
+
+private:
+  SmallVector, 4u> Files;
+};
+
+} // end anonymous namespace
+
 /// Handler for object files. The bundles are organized by sections with a
 /// designated name.
 ///
@@ -433,11 +467,16 @@
   Error ReadBundleEnd(MemoryBuffer &Input) final { return Error::success(); }
 
   Error ReadBundle(raw_fd_ostream &OS, MemoryBuffer &Input) final {
-Expected Content = CurrentSection->getContents();
-if (!Content)
-  return Content.takeError();
+Expected ContentOrErr = CurrentSection->getContents();
+if (!ContentOrErr)
+  return ContentOrErr.takeError();
+StringRef Content = *ContentOrErr;
+
+// Copy fat object contents to the output when extracting host bundle.
+if (Content.size() == 1u && Content.front() == 0)
+  Content = StringRef(Input.getBufferStart(), Input.getBufferSize());
 
-OS.write(Content->data(), Content->size());
+OS.write(Content.data(), Content.size());
 return Error::success();
   }
 
@@ -486,22 +525,37 @@
 // to pass down to llvm-objcopy.
 OS.close();
 
+// Temporary files that need to be removed.
+TempFileHandlerRAII TempFiles;
+
 // Create an intermediate temporary file to save object after the first
 // llvm-objcopy run.
-SmallString<128u> IntermediateObj;
-if (std::error_code EC = sys::fs::createTemporaryFile(
-"clang-offload-bundler", "tmp", IntermediateObj))
-  return createFileError(IntermediateObj, EC);
-FileRemover IntermediateObjRemover(IntermediateObj);
+Expected> IntermediateObjOrErr = TempFiles.Create(None);
+if (!IntermediateObjOrErr)
+  return IntermediateObjOrErr.takeError();
+const SmallString<128u> &IntermediateObj = *IntermediateObjOrErr;
 
 // Compose llvm-objcopy command line for add target objects' sections.
 BumpPtrAllocator Alloc;
 StringSaver SS{Alloc};
 SmallVector ObjcopyArgs{"llvm-objcopy"};
-for (unsigned I = 0; I < NumberOfInputs; ++I)
+for (unsigned I = 0; I < NumberOfInputs; ++I) {
+  StringRef InputFile = InputFileNames[I];
+  if (I == HostInputIndex) {
+// Special handling for the host bundle. We do not need to add a
+// standard bundle for the host object since we are going to use fat
+// object as a host object. Therefore use dummy contents (one zero byte)
+// when creating section for the host bundle.
+Expected TempFileOrErr = TempFiles.Create(ArrayRef(0));
+if (!TempFileOrErr)
+  return TempFileOrErr.takeError();
+InputFile = *TempFileOrErr;
+  }
+
   ObjcopyArgs.push_back(SS.save(Twine("--add-section=") +
 OFFLOAD_BUNDLER_MAGIC_STR + TargetNames[I] +
-"=" + InputFileNames[I]));
+"=" + InputFile));
+}
 ObjcopyArgs.push_back(InputFileNames[HostInputIndex]);
 ObjcopyArgs.push_back(IntermediateObj);
 
Index: clang/test/Driver/clang-offload-bundler.c
===
--- clang/test/Driver/clang-offload-bundler.c
+++ clang/test/Driver/clang-offload-bundler.c
@@ -253,16 +253,16 @@
 
 // RUN: clang-offload-bundler -type=o -targets=host-%itanium_abi_triple,openmp-powerpc64le-ibm-linux-gnu,openmp-x86_64-pc-linux-gnu -inputs=%t.o,%t.tgt1,%t.

[PATCH] D73462: [dwarf-5] Support DebugInfo for Defaulted parameters for C++ templates

2020-01-29 Thread David Blaikie via Phabricator via cfe-commits
dblaikie added inline comments.



Comment at: llvm/include/llvm/IR/DebugInfoMetadata.h:2134
 protected:
+  bool isDefault;
+

Rename this (& the ctor/other parameters) to "IsDefault" to conform to LLVM's 
naming conventions ( 
https://llvm.org/docs/CodingStandards.html#name-types-functions-variables-and-enumerators-properly
 )





Comment at: llvm/lib/AsmParser/LLParser.cpp:4858
 ///   ::= !DITemplateValueParameter(tag: DW_TAG_template_value_parameter,
-/// name: "V", type: !1, value: i32 7)
+/// name: "V", type: !1, defaultValue: "false",
+/// value: i32 7)

defaultValue should probably be rendered/encoded as a boolean, rather than a 
string?

(& "defaultValue" might be a misleading name (if the DITemplateValueParameter 
was a boolean non type template parameter, then "defaultValue: true" could look 
like the default value is true, not that the "value: "parameter is the default 
value... if that makes sense) - perhaps "defaulted" would read more easily 
("defaulted: true" or "defaulted: false"))

Perhaps just "default" though that still feels a bit ambiguous between "is this 
the default value itself, or is it specifying that the "value:" field is the 
default value?".



Comment at: llvm/lib/Bitcode/Writer/BitcodeWriter.cpp:1808-1809
   Record.push_back(VE.getMetadataOrNullID(N->getType()));
+  if (M.getDwarfVersion() >= 5)
+Record.push_back(N->getDefault());
   Record.push_back(VE.getMetadataOrNullID(N->getValue()));

I don't think we should be using the DWARF version to decide on the schema - 
there's no other use of that technique in the parsing/writing code & I can 
think of some ways it might go poorly.

Better to encode it & it can be dropped during actual DWARF emission in the 
backend if the version doesn't support it.



Comment at: llvm/test/DebugInfo/X86/debug-info-template-parameter.ll:1
+; RUN: %llc_dwarf  %s -filetype=obj -o - | llvm-dwarfdump -v - | FileCheck %s
+

An implicit-check-not of DW_TAG and of DW_AT_default_value would probably help 
make the test better constrained/less likely to pass accidentally/in unintended 
ways.

(though the DW_TAG check not might be too much/add too much noise outside the 
types intended to be checked (you'd need to add every DW_TAG produced by the 
test... maybe there's a way to simplify the uses of the types so the usage 
doesn't need to create many more tags... )



Comment at: llvm/test/DebugInfo/X86/debug-info-template-parameter.ll:5
+
+;template 
+;class foo {

Perhaps you could swap one of these defaulted template parameters to be a 
non-type template parameter to broaden the demonstration a bit?

Or, alternatively, does having two parameters here especially broaden the test 
coverage in some way? Or would one be sufficient? 


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

https://reviews.llvm.org/D73462



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


[PATCH] D67847: [Support] make report_fatal_error `abort` instead of `exit`

2020-01-29 Thread Reid Kleckner via Phabricator via cfe-commits
rnk added a comment.

If we can reland this patch, it should fix this new clang bug:
https://bugs.llvm.org/show_bug.cgi?id=44705

This was the list of failures you noted on the commit:

In rG647c3f4e47de8a850ffcaa897db68702d8d2459a#885042 
, 
@ychen wrote:

> This is going deeper...
>
> - Host compiler crash (looks like ppc64be-specific) 
> http://lab.llvm.org:8011/builders/clang-ppc64be-linux-multistage/builds/23016 
> http://lab.llvm.org:8011/builders/clang-ppc64be-linux/builds/43016 
> http://lab.llvm.org:8011/builders/clang-ppc64be-linux-lnt/builds/34286
> - clang/test/CXX/temp/temp.arg/temp.arg.template/p3-2a.cpp becomes pass/fail 
> randomly
> - test timeout 
> http://lab.llvm.org:8011/builders/openmp-gcc-x86_64-linux-debian/builds/2170/steps/test-openmp/logs/stdio
> - ThinLTO test failures on Redhat (passes on my ubuntu 18.04) 
> http://lab.llvm.org:8011/builders/clang-ppc64le-rhel/builds/592
>
>   Will investigate.


The ppc64be stuff seems like only someone with hardware will be able to debug 
it.
For `clang/test/CXX/temp/temp.arg/temp.arg.template/p3-2a.cpp`, you are saying 
you can reproduce that locally?
The timeout seems like it could be flakiness or something unrelated.
The thinlto failures... I'm not sure either, but again it's PPC64, so it could 
be flakiness.

It seems like it would be best to alert the owners of those bots and reland and 
get new results, assuming things pass on less exotic bot configurations.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D67847



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


[PATCH] D73642: [Clang][Bundler] Reduce fat object size

2020-01-29 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev added inline comments.



Comment at: clang/tools/clang-offload-bundler/ClangOffloadBundler.cpp:371
+// object destruction.
+struct TempFileList {
+  ~TempFileList() {

If you have `private` members, it should be a class. Also, seems to me it is a 
RAII class. Better to name it something like `TempFileHandlerRAII` or something 
like this.



Comment at: clang/tools/clang-offload-bundler/ClangOffloadBundler.cpp:378
+  // Creates temporary file with given contents.
+  Expected Create(Optional> Contents) {
+SmallString<128u> File;

I see that Contents is either `None` or just one byte `0`. Maybe, better to use 
bool flag here instead of `Contents`?


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

https://reviews.llvm.org/D73642



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


[PATCH] D72829: Implement -fsemantic-interposition

2020-01-29 Thread pre-merge checks [bot] via Phabricator via cfe-commits
merge_guards_bot added a comment.

{icon check-circle color=green} Unit tests: pass. 62312 tests passed, 0 failed 
and 838 were skipped.

{icon check-circle color=green} clang-tidy: pass.

{icon check-circle color=green} clang-format: pass.

Build artifacts 
: 
diff.json 
,
 clang-tidy.txt 
,
 clang-format.patch 
,
 CMakeCache.txt 
,
 console-log.txt 
,
 test-results.xml 


//Pre-merge checks is in beta. Report issue 
.
 Please join beta  or enable 
it for your project 
.//


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72829



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


[PATCH] D73642: [Clang][Bundler] Reduce fat object size

2020-01-29 Thread Sergey Dmitriev via Phabricator via cfe-commits
sdmitriev updated this revision to Diff 241269.
sdmitriev added a comment.

Addressed review comments.


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

https://reviews.llvm.org/D73642

Files:
  clang/test/Driver/clang-offload-bundler.c
  clang/tools/clang-offload-bundler/ClangOffloadBundler.cpp

Index: clang/tools/clang-offload-bundler/ClangOffloadBundler.cpp
===
--- clang/tools/clang-offload-bundler/ClangOffloadBundler.cpp
+++ clang/tools/clang-offload-bundler/ClangOffloadBundler.cpp
@@ -30,7 +30,6 @@
 #include "llvm/Support/Error.h"
 #include "llvm/Support/ErrorOr.h"
 #include "llvm/Support/FileSystem.h"
-#include "llvm/Support/FileUtilities.h"
 #include "llvm/Support/MemoryBuffer.h"
 #include "llvm/Support/Path.h"
 #include "llvm/Support/Program.h"
@@ -365,6 +364,40 @@
   }
 };
 
+namespace {
+
+// This structure implements a list of temporary files that are removed upon
+// object destruction.
+struct TempFileList {
+  ~TempFileList() {
+for (const auto &File : Files)
+  sys::fs::remove(File);
+  }
+
+  // Creates temporary file with given contents.
+  Expected Create(Optional> Contents) {
+SmallString<128u> File;
+if (std::error_code EC =
+sys::fs::createTemporaryFile("clang-offload-bundler", "tmp", File))
+  return createFileError(File, EC);
+Files.push_back(File);
+
+if (Contents) {
+  std::error_code EC;
+  raw_fd_ostream OS(File, EC);
+  if (EC)
+return createFileError(File, EC);
+  OS.write(Contents->data(), Contents->size());
+}
+return Files.back();
+  }
+
+private:
+  SmallVector, 4u> Files;
+};
+
+} // end anonymous namespace
+
 /// Handler for object files. The bundles are organized by sections with a
 /// designated name.
 ///
@@ -433,11 +466,16 @@
   Error ReadBundleEnd(MemoryBuffer &Input) final { return Error::success(); }
 
   Error ReadBundle(raw_fd_ostream &OS, MemoryBuffer &Input) final {
-Expected Content = CurrentSection->getContents();
-if (!Content)
-  return Content.takeError();
+Expected ContentOrErr = CurrentSection->getContents();
+if (!ContentOrErr)
+  return ContentOrErr.takeError();
+StringRef Content = *ContentOrErr;
+
+// Copy fat object contents to the output when extracting host bundle.
+if (Content.size() == 1u && Content.front() == 0)
+  Content = StringRef(Input.getBufferStart(), Input.getBufferSize());
 
-OS.write(Content->data(), Content->size());
+OS.write(Content.data(), Content.size());
 return Error::success();
   }
 
@@ -486,22 +524,37 @@
 // to pass down to llvm-objcopy.
 OS.close();
 
+// Temporary files that need to be removed.
+TempFileList TempFiles;
+
 // Create an intermediate temporary file to save object after the first
 // llvm-objcopy run.
-SmallString<128u> IntermediateObj;
-if (std::error_code EC = sys::fs::createTemporaryFile(
-"clang-offload-bundler", "tmp", IntermediateObj))
-  return createFileError(IntermediateObj, EC);
-FileRemover IntermediateObjRemover(IntermediateObj);
+Expected> IntermediateObjOrErr = TempFiles.Create(None);
+if (!IntermediateObjOrErr)
+  return IntermediateObjOrErr.takeError();
+const SmallString<128u> &IntermediateObj = *IntermediateObjOrErr;
 
 // Compose llvm-objcopy command line for add target objects' sections.
 BumpPtrAllocator Alloc;
 StringSaver SS{Alloc};
 SmallVector ObjcopyArgs{"llvm-objcopy"};
-for (unsigned I = 0; I < NumberOfInputs; ++I)
+for (unsigned I = 0; I < NumberOfInputs; ++I) {
+  StringRef InputFile = InputFileNames[I];
+  if (I == HostInputIndex) {
+// Special handling for the host bundle. We do not need to add a
+// standard bundle for the host object since we are going to use fat
+// object as a host object. Therefore use dummy contents (one zero byte)
+// when creating section for the host bundle.
+Expected TempFileOrErr = TempFiles.Create(ArrayRef(0));
+if (!TempFileOrErr)
+  return TempFileOrErr.takeError();
+InputFile = *TempFileOrErr;
+  }
+
   ObjcopyArgs.push_back(SS.save(Twine("--add-section=") +
 OFFLOAD_BUNDLER_MAGIC_STR + TargetNames[I] +
-"=" + InputFileNames[I]));
+"=" + InputFile));
+}
 ObjcopyArgs.push_back(InputFileNames[HostInputIndex]);
 ObjcopyArgs.push_back(IntermediateObj);
 
Index: clang/test/Driver/clang-offload-bundler.c
===
--- clang/test/Driver/clang-offload-bundler.c
+++ clang/test/Driver/clang-offload-bundler.c
@@ -253,16 +253,16 @@
 
 // RUN: clang-offload-bundler -type=o -targets=host-%itanium_abi_triple,openmp-powerpc64le-ibm-linux-gnu,openmp-x86_64-pc-linux-gnu -inputs=%t.o,%t.tgt1,%t.tgt2 -outputs=%t.bundle3.

[PATCH] D72906: [X86] Improve X86 cmpps/cmppd/cmpss/cmpsd intrinsics with strictfp

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

lgtm

I have a couple of comments, but nothing that couldn't be addressed in a later 
patch.




Comment at: clang/lib/CodeGen/CGBuiltin.cpp:12363
+Cmp = Builder.CreateFCmp(Pred, Ops[0], Ops[1]);
   return EmitX86MaskedCompareResult(*this, Cmp, NumElts, Ops[3]);
 }

How hard would it be to generate a select with known safe values ahead of the 
compare in the constrained case? 



Comment at: clang/test/CodeGen/avx-builtins-constrained.c:170
+  // CHECK-LABEL: test_mm256_cmp_pd_false_os
+  // CHECK: call <4 x double> @llvm.x86.avx.cmp.pd.256(<4 x double> %{{.*}}, 
<4 x double> %{{.*}}, i8 27)
+  return _mm256_cmp_pd(a, b, _CMP_FALSE_OS);

Does this have the strictfp attribute here? I don't think we do anything with 
that, but it will likely be useful when we start handling strictfp for 
target-specific intrinsics.


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

https://reviews.llvm.org/D72906



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


[PATCH] D73651: [OpenCL][CUDA][HIP][SYCL] Add norecurse

2020-01-29 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl updated this revision to Diff 241265.
yaxunl edited the summary of this revision.
yaxunl added a comment.

revised by Alexey's comments.


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

https://reviews.llvm.org/D73651

Files:
  clang/lib/CodeGen/CodeGenFunction.cpp
  clang/test/CodeGenCUDA/norecurse.cu
  clang/test/CodeGenOpenCL/norecurse.cl
  clang/test/SemaCUDA/call-kernel-from-kernel.cu


Index: clang/test/SemaCUDA/call-kernel-from-kernel.cu
===
--- /dev/null
+++ clang/test/SemaCUDA/call-kernel-from-kernel.cu
@@ -0,0 +1,9 @@
+// RUN: %clang_cc1 %s --std=c++11 -triple x86_64-unknown-linux -emit-llvm -o - 
\
+// RUN:   -verify -fsyntax-only -verify-ignore-unexpected=note
+
+#include "Inputs/cuda.h"
+
+__global__ void kernel1();
+__global__ void kernel2() {
+  kernel1<<<1,1>>>(); // expected-error {{reference to __global__ function 
'kernel1' in __global__ function}}
+}
Index: clang/test/CodeGenOpenCL/norecurse.cl
===
--- /dev/null
+++ clang/test/CodeGenOpenCL/norecurse.cl
@@ -0,0 +1,6 @@
+// RUN: %clang_cc1 -O0 -emit-llvm -o - %s | FileCheck %s
+
+kernel void kernel1(int a) {}
+// CHECK: define{{.*}}@kernel1{{.*}}#[[ATTR:[0-9]*]]
+
+// CHECK: attributes #[[ATTR]] = {{.*}}norecurse
Index: clang/test/CodeGenCUDA/norecurse.cu
===
--- /dev/null
+++ clang/test/CodeGenCUDA/norecurse.cu
@@ -0,0 +1,15 @@
+// REQUIRES: amdgpu-registered-target
+// REQUIRES: nvptx-registered-target
+
+// RUN: %clang_cc1 -triple nvptx-nvidia-cuda -fcuda-is-device \
+// RUN: -emit-llvm -disable-llvm-passes -o - %s | FileCheck %s
+
+// RUN: %clang_cc1 -triple amdgcn-amd-amdhsa -fcuda-is-device \
+// RUN: -emit-llvm -disable-llvm-passes -o - -x hip %s | FileCheck %s
+
+#include "Inputs/cuda.h"
+
+__global__ void kernel1(int a) {}
+// CHECK: define{{.*}}@_Z7kernel1i{{.*}}#[[ATTR:[0-9]*]]
+
+// CHECK: attributes #[[ATTR]] = {{.*}}norecurse
Index: clang/lib/CodeGen/CodeGenFunction.cpp
===
--- clang/lib/CodeGen/CodeGenFunction.cpp
+++ clang/lib/CodeGen/CodeGenFunction.cpp
@@ -907,10 +907,28 @@
   // If we're in C++ mode and the function name is "main", it is guaranteed
   // to be norecurse by the standard (3.6.1.3 "The function main shall not be
   // used within a program").
-  if (getLangOpts().CPlusPlus)
-if (const FunctionDecl *FD = dyn_cast_or_null(D))
-  if (FD->isMain())
-Fn->addFnAttr(llvm::Attribute::NoRecurse);
+  //
+  // OpenCL C 2.0 v2.2-11 s6.9.i:
+  // Recursion is not supported.
+  //
+  // OpenCL C++ 1.0 v2.1-11 s2.9:
+  // recursive function calls (ISO C++ Section 5.2.2, item 9) unless
+  // they are a compile-time constant expression.
+  //
+  // SYCL v2.2 s2.10:
+  // kernels cannot include RTTI information, exception classes,
+  // recursive code, virtual functions or make use of C++ libraries that
+  // are not compiled for the device.
+  //
+  // ToDo: clang does not support CUDA/HIP dynamic parallelism, therefore
+  // CUDA/HIP kernel can be marked with norecurse. This may change in the
+  // future.
+  if (const FunctionDecl *FD = dyn_cast_or_null(D)) {
+if ((getLangOpts().CPlusPlus && FD->isMain()) || getLangOpts().OpenCL ||
+getLangOpts().SYCLIsDevice ||
+(getLangOpts().CUDA && FD->hasAttr()))
+  Fn->addFnAttr(llvm::Attribute::NoRecurse);
+  }
 
   if (const FunctionDecl *FD = dyn_cast_or_null(D))
 if (FD->usesFPIntrin())


Index: clang/test/SemaCUDA/call-kernel-from-kernel.cu
===
--- /dev/null
+++ clang/test/SemaCUDA/call-kernel-from-kernel.cu
@@ -0,0 +1,9 @@
+// RUN: %clang_cc1 %s --std=c++11 -triple x86_64-unknown-linux -emit-llvm -o - \
+// RUN:   -verify -fsyntax-only -verify-ignore-unexpected=note
+
+#include "Inputs/cuda.h"
+
+__global__ void kernel1();
+__global__ void kernel2() {
+  kernel1<<<1,1>>>(); // expected-error {{reference to __global__ function 'kernel1' in __global__ function}}
+}
Index: clang/test/CodeGenOpenCL/norecurse.cl
===
--- /dev/null
+++ clang/test/CodeGenOpenCL/norecurse.cl
@@ -0,0 +1,6 @@
+// RUN: %clang_cc1 -O0 -emit-llvm -o - %s | FileCheck %s
+
+kernel void kernel1(int a) {}
+// CHECK: define{{.*}}@kernel1{{.*}}#[[ATTR:[0-9]*]]
+
+// CHECK: attributes #[[ATTR]] = {{.*}}norecurse
Index: clang/test/CodeGenCUDA/norecurse.cu
===
--- /dev/null
+++ clang/test/CodeGenCUDA/norecurse.cu
@@ -0,0 +1,15 @@
+// REQUIRES: amdgpu-registered-target
+// REQUIRES: nvptx-registered-target
+
+// RUN: %clang_cc1 -triple nvptx-nvidia-cuda -fcuda-is-device \
+// RUN: -emit-llvm -disable-llvm-passes -o - %s | FileCheck %s
+
+// RUN: %clang_cc1 -triple amdgcn-

[PATCH] D73651: [OpenCL][CUDA][HIP][SYCL] Add norecurse

2020-01-29 Thread Alexey Bader via Phabricator via cfe-commits
bader added a comment.

In D73651#1847862 , @yaxunl wrote:

> Added handling of SYCL kernels by Alexey's comments. I cannot add a codegen 
> test for SYCL since I cannot find a way to instantiate a SYCL kernel.


I think SYCL implementation should follow OpenCL logic and apply attribute to 
any function, not only kernels.


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

https://reviews.llvm.org/D73651



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


[PATCH] D73651: [OpenCL][CUDA][HIP][SYCL] Add norecurse

2020-01-29 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl updated this revision to Diff 241256.
yaxunl retitled this revision from "[OpenCL][CUDA][HIP] Add norecurse" to 
"[OpenCL][CUDA][HIP][SYCL] Add norecurse".
yaxunl edited the summary of this revision.
yaxunl added a comment.
Herald added a subscriber: ebevhan.

Added handling of SYCL kernels by Alexey's comments. I cannot add a codegen 
test for SYCL since I cannot find a way to instantiate a SYCL kernel.


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

https://reviews.llvm.org/D73651

Files:
  clang/lib/CodeGen/CodeGenFunction.cpp
  clang/test/CodeGenCUDA/norecurse.cu
  clang/test/CodeGenOpenCL/norecurse.cl
  clang/test/SemaCUDA/call-kernel-from-kernel.cu


Index: clang/test/SemaCUDA/call-kernel-from-kernel.cu
===
--- /dev/null
+++ clang/test/SemaCUDA/call-kernel-from-kernel.cu
@@ -0,0 +1,9 @@
+// RUN: %clang_cc1 %s --std=c++11 -triple x86_64-unknown-linux -emit-llvm -o - 
\
+// RUN:   -verify -fsyntax-only -verify-ignore-unexpected=note
+
+#include "Inputs/cuda.h"
+
+__global__ void kernel1();
+__global__ void kernel2() {
+  kernel1<<<1,1>>>(); // expected-error {{reference to __global__ function 
'kernel1' in __global__ function}}
+}
Index: clang/test/CodeGenOpenCL/norecurse.cl
===
--- /dev/null
+++ clang/test/CodeGenOpenCL/norecurse.cl
@@ -0,0 +1,6 @@
+// RUN: %clang_cc1 -O0 -emit-llvm -o - %s | FileCheck %s
+
+kernel void kernel1(int a) {}
+// CHECK: define{{.*}}@kernel1{{.*}}#[[ATTR:[0-9]*]]
+
+// CHECK: attributes #[[ATTR]] = {{.*}}norecurse
Index: clang/test/CodeGenCUDA/norecurse.cu
===
--- /dev/null
+++ clang/test/CodeGenCUDA/norecurse.cu
@@ -0,0 +1,15 @@
+// REQUIRES: amdgpu-registered-target
+// REQUIRES: nvptx-registered-target
+
+// RUN: %clang_cc1 -triple nvptx-nvidia-cuda -fcuda-is-device \
+// RUN: -emit-llvm -disable-llvm-passes -o - %s | FileCheck %s
+
+// RUN: %clang_cc1 -triple amdgcn-amd-amdhsa -fcuda-is-device \
+// RUN: -emit-llvm -disable-llvm-passes -o - -x hip %s | FileCheck %s
+
+#include "Inputs/cuda.h"
+
+__global__ void kernel1(int a) {}
+// CHECK: define{{.*}}@_Z7kernel1i{{.*}}#[[ATTR:[0-9]*]]
+
+// CHECK: attributes #[[ATTR]] = {{.*}}norecurse
Index: clang/lib/CodeGen/CodeGenFunction.cpp
===
--- clang/lib/CodeGen/CodeGenFunction.cpp
+++ clang/lib/CodeGen/CodeGenFunction.cpp
@@ -907,10 +907,28 @@
   // If we're in C++ mode and the function name is "main", it is guaranteed
   // to be norecurse by the standard (3.6.1.3 "The function main shall not be
   // used within a program").
-  if (getLangOpts().CPlusPlus)
-if (const FunctionDecl *FD = dyn_cast_or_null(D))
-  if (FD->isMain())
-Fn->addFnAttr(llvm::Attribute::NoRecurse);
+  //
+  // OpenCL C 2.0 v2.2-11 s6.9.i:
+  // Recursion is not supported.
+  //
+  // OpenCL C++ 1.0 v2.1-11 s2.9:
+  // recursive function calls (ISO C++ Section 5.2.2, item 9) unless
+  // they are a compile-time constant expression.
+  //
+  // SYCL v2.2 s2.10:
+  // kernels cannot include RTTI information, exception classes,
+  // recursive code, virtual functions or make use of C++ libraries that
+  // are not compiled for the device.
+  //
+  // ToDo: clang does not support CUDA/HIP dynamic parallelism, therefore
+  // CUDA/HIP kernel can be marked with norecurse. This may change in the
+  // future.
+  if (const FunctionDecl *FD = dyn_cast_or_null(D)) {
+if ((getLangOpts().CPlusPlus && FD->isMain()) || getLangOpts().OpenCL ||
+(getLangOpts().SYCLIsDevice && FD->hasAttr()) ||
+(getLangOpts().CUDA && FD->hasAttr()))
+  Fn->addFnAttr(llvm::Attribute::NoRecurse);
+  }
 
   if (const FunctionDecl *FD = dyn_cast_or_null(D))
 if (FD->usesFPIntrin())


Index: clang/test/SemaCUDA/call-kernel-from-kernel.cu
===
--- /dev/null
+++ clang/test/SemaCUDA/call-kernel-from-kernel.cu
@@ -0,0 +1,9 @@
+// RUN: %clang_cc1 %s --std=c++11 -triple x86_64-unknown-linux -emit-llvm -o - \
+// RUN:   -verify -fsyntax-only -verify-ignore-unexpected=note
+
+#include "Inputs/cuda.h"
+
+__global__ void kernel1();
+__global__ void kernel2() {
+  kernel1<<<1,1>>>(); // expected-error {{reference to __global__ function 'kernel1' in __global__ function}}
+}
Index: clang/test/CodeGenOpenCL/norecurse.cl
===
--- /dev/null
+++ clang/test/CodeGenOpenCL/norecurse.cl
@@ -0,0 +1,6 @@
+// RUN: %clang_cc1 -O0 -emit-llvm -o - %s | FileCheck %s
+
+kernel void kernel1(int a) {}
+// CHECK: define{{.*}}@kernel1{{.*}}#[[ATTR:[0-9]*]]
+
+// CHECK: attributes #[[ATTR]] = {{.*}}norecurse
Index: clang/test/CodeGenCUDA/norecurse.cu
===
--- /dev/null
+++ clang/test/C

[PATCH] D72829: Implement -fsemantic-interposition

2020-01-29 Thread serge via Phabricator via cfe-commits
serge-sans-paille updated this revision to Diff 241254.
serge-sans-paille added a comment.

take @sfertile review into account.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72829

Files:
  clang/docs/ClangCommandLineReference.rst
  clang/include/clang/Basic/LangOptions.def
  clang/include/clang/Driver/Options.td
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/test/CodeGen/semantic-interposition.c
  clang/test/Driver/clang_f_opts.c
  llvm/include/llvm/IR/GlobalValue.h
  llvm/include/llvm/IR/Module.h
  llvm/lib/IR/Globals.cpp
  llvm/lib/IR/Module.cpp
  llvm/lib/IR/Verifier.cpp
  llvm/test/Transforms/Inline/inline-semantic-interposition.ll
  llvm/test/Verifier/module-flags-semantic-interposition.ll

Index: llvm/test/Verifier/module-flags-semantic-interposition.ll
===
--- /dev/null
+++ llvm/test/Verifier/module-flags-semantic-interposition.ll
@@ -0,0 +1,12 @@
+; RUN: not llvm-as < %s -o /dev/null 2>&1 | FileCheck %s
+
+target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
+target triple = "x86_64-unknown-linux-gnu"
+
+@foo = dso_local global i32 1, align 4
+
+!llvm.module.flags = !{!0}
+
+!0 = !{i32 1, !"SemanticInterposition", float 1.}
+
+; CHECK: SemanticInterposition metadata requires constant integer argument
Index: llvm/test/Transforms/Inline/inline-semantic-interposition.ll
===
--- /dev/null
+++ llvm/test/Transforms/Inline/inline-semantic-interposition.ll
@@ -0,0 +1,26 @@
+; Check that @callee1 gets inlined while @callee2 is not, because of
+; SemanticInterposition.
+
+; RUN: opt < %s -inline -S | FileCheck %s
+
+define internal i32 @callee1(i32 %A) {
+  ret i32 %A
+}
+
+define i32 @callee2(i32 %A) {
+  ret i32 %A
+}
+
+; CHECK-LABEL: @caller
+define i32 @caller(i32 %A) {
+; CHECK-NOT: call i32 @callee1(i32 %A)
+  %A1 = call i32 @callee1(i32 %A)
+; CHECK: %A2 = call i32 @callee2(i32 %A)
+  %A2 = call i32 @callee2(i32 %A)
+; CHECK: add i32 %A, %A2
+  %R = add i32 %A1, %A2
+  ret i32 %R
+}
+
+!llvm.module.flags = !{!0}
+!0 = !{i32 1, !"SemanticInterposition", i32 1}
Index: llvm/lib/IR/Verifier.cpp
===
--- llvm/lib/IR/Verifier.cpp
+++ llvm/lib/IR/Verifier.cpp
@@ -1476,6 +1476,13 @@
"'Linker Options' named metadata no longer supported");
   }
 
+  if (ID->getString() == "SemanticInterposition") {
+ConstantInt *Value =
+mdconst::dyn_extract_or_null(Op->getOperand(2));
+Assert(Value,
+   "SemanticInterposition metadata requires constant integer argument");
+  }
+
   if (ID->getString() == "CG Profile") {
 for (const MDOperand &MDO : cast(Op->getOperand(2))->operands())
   visitModuleFlagCGProfileEntry(MDO);
Index: llvm/lib/IR/Module.cpp
===
--- llvm/lib/IR/Module.cpp
+++ llvm/lib/IR/Module.cpp
@@ -554,6 +554,20 @@
: getModuleFlag("ProfileSummary"));
 }
 
+bool Module::getSemanticInterposition() const {
+  Metadata *MF = getModuleFlag("SemanticInterposition");
+
+  auto *Val = cast_or_null(MF);
+  if (!Val)
+return false;
+
+  return cast(Val->getValue())->getZExtValue();
+}
+
+void Module::setSemanticInterposition(bool SI) {
+  addModuleFlag(ModFlagBehavior::Error, "SemanticInterposition", SI);
+}
+
 void Module::setOwnedMemoryBuffer(std::unique_ptr MB) {
   OwnedMemoryBuffer = std::move(MB);
 }
Index: llvm/lib/IR/Globals.cpp
===
--- llvm/lib/IR/Globals.cpp
+++ llvm/lib/IR/Globals.cpp
@@ -94,6 +94,13 @@
   llvm_unreachable("not a global");
 }
 
+bool GlobalValue::isInterposable() const {
+  if (isInterposableLinkage(getLinkage()))
+return true;
+  return getParent() && getParent()->getSemanticInterposition() &&
+ !isDSOLocal();
+}
+
 unsigned GlobalValue::getAlignment() const {
   if (auto *GA = dyn_cast(this)) {
 // In general we cannot compute this at the IR level, but we try.
Index: llvm/include/llvm/IR/Module.h
===
--- llvm/include/llvm/IR/Module.h
+++ llvm/include/llvm/IR/Module.h
@@ -848,6 +848,12 @@
   Metadata *getProfileSummary(bool IsCS);
   /// @}
 
+  /// Returns whether semantic interposition is to be respected.
+  bool getSemanticInterposition() const;
+
+  /// Set whether semantic interposition is to be respected.
+  void setSemanticInterposition(bool);
+
   /// Returns true if PLT should be avoided for RTLib calls.
   bool getRtLibUseGOT() const;
 
Index: llvm/include/llvm/IR/GlobalValue.h
===
--- llvm/include/llvm/IR/GlobalValue.h
+++ llvm/include/llvm/IR/GlobalValue.h

[PATCH] D73231: [CUDA] Assume the latest known CUDA version if we've found an unknown one.

2020-01-29 Thread Hans Wennborg via Phabricator via cfe-commits
hans added a comment.

In D73231#1845096 , @tra wrote:

> @hans : that's another candidate for 10.x cherry-pick, if you're OK with it.


Sounds good to me. Cherry-picked in 5777899f146aaa53f598e6978702a7a2725200d7 



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73231



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


[PATCH] D73437: [mlir][spirv] Convert linalg.generic for reduction to SPIR-V ops

2020-01-29 Thread Mahesh Ravishankar via Phabricator via cfe-commits
mravishankar accepted this revision.
mravishankar marked 2 inline comments as done.
mravishankar added inline comments.



Comment at: mlir/lib/Conversion/LinalgToSPIRV/LinalgToSPIRV.cpp:73
+
+  using mlir::matchers::m_Val;
+  auto a = m_Val(block.getArgument(0));

mravishankar wrote:
> antiagainst wrote:
> > mravishankar wrote:
> > > I feel like this is not required. If the linalg.generic operation says 
> > > this is a reduction, we should not be checking the region to verify that 
> > > it is. linalg as a contract is guaranteeing this is a reduction.
> > I'm not sure I get your idea correctly; but this is checking we are doing 
> > the expected kind of reduction (`BinaryOp`). 
> That is what I am not sure we need to do. You have already checked the 
> generic op is a 1D loop with reduction iterator type. So the body of the 
> generic op is assumed to be a reduction right, i.e. a "binaryOp". Here you 
> are checking whether its an operation which takes two operands, but not 
> necessarily a binary operation that can be used for reduction. In some sense 
> you dont need to check that since the generic op description already told you 
> to assume that the region of the op represents a binary op that can be used 
> for reduction (this is based on my understanding of "reduction" loops in 
> linalg, but I need to double check).
> 
Ok, looked into this a little bit more. This is indeed required as of now. 
Ideally we dont need to do this, but that is orthogonal. No issues here.



Comment at: mlir/lib/Conversion/LinalgToSPIRV/LinalgToSPIRV.cpp:182
+  // Perform the group reduction operation.
+  Value groupOperation = rewriter.create(
+  loc, originalInputType.getElementType(), spirv::Scope::Subgroup,

mravishankar wrote:
> antiagainst wrote:
> > mravishankar wrote:
> > > This is hard-wiring to IAdd. We probably need to structure this 
> > > differently. We need to have a pattern to lower the linalg.generic with 
> > > reduction iterator into the kernel generated here, and then lower the 
> > > operations within the region separately.
> > It was intentional to only support IAdd. I've re-structured this a bit so 
> > it's extensible to other binary op kinds.
> The way I see this structured is
> 
> 1) You check the "structure" of the linalg.generic op to see if it is a 1D 
> reduction. You assume that the body of the generic op represents a binary 
> operation that can be used for the reduction.
> 2) You write a separate pattern that converts the operations of the body 
> itself into the spirv::GroupNonUniform*Op.
> 
> The dialect conversion will first convert the generic op, and then it will 
> attempt to convert the body of the op. The way this is strucutred, it can 
> only handle straight-forward binary operations. THere could be more 
> complicated operations in the region of a generic op that implements the 
> reduction, which would be hard to incorporate in this approach.
> 
> With your updated changes, it is easy to extend to other ops, but I think a 
> more general solution is needed where we are not constrained in handling just 
> simple reductions. It might need some more careful design though, which I 
> dont have a full picture of right now. So for now this OK, but please leave a 
> TODO to say something like "handle more general reductions".
Thought about this a little bit more. It will be a more sane strategy to not 
handle cases where the region is "inlined" into the generic op, but rather the 
region is specified as a function using the `fun` attribute of the 
`linalg.generic` op. Then we can split the lowering of the generic op and the 
lowering of the function that does the reduction separately.
This too not needed for this CL. Should revisit this


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73437



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


[PATCH] D73629: [analyzer] vfork checker: allow execve after vfork

2020-01-29 Thread Gábor Horváth via Phabricator via cfe-commits
xazax.hun added inline comments.



Comment at: clang/lib/StaticAnalyzer/Checkers/VforkChecker.cpp:109
   "execvpe",
+  "execve",
   nullptr

Well, this is not the case now, but I wonder if it would also make sense to 
sort this list alphabetically. 


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

https://reviews.llvm.org/D73629



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


[PATCH] D73651: [OpenCL][CUDA][HIP] Add norecurse

2020-01-29 Thread Alexey Bader via Phabricator via cfe-commits
bader added inline comments.



Comment at: clang/lib/CodeGen/CodeGenFunction.cpp:923
+if ((getLangOpts().CPlusPlus && FD->isMain()) || getLangOpts().OpenCL ||
+(getLangOpts().CUDA && FD->hasAttr()))
+  Fn->addFnAttr(llvm::Attribute::NoRecurse);

SYCL doesn't support recursion neither. Does it make sense to add it too?


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

https://reviews.llvm.org/D73651



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


[PATCH] D73629: [analyzer] vfork checker: allow execve after vfork

2020-01-29 Thread Jan Včelák via Phabricator via cfe-commits
janvcelak updated this revision to Diff 241245.
janvcelak added a comment.

Sorry. I missed that step in contribution guidelines. I'm attaching updated 
version with larger context.


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

https://reviews.llvm.org/D73629

Files:
  clang/lib/StaticAnalyzer/Checkers/VforkChecker.cpp


Index: clang/lib/StaticAnalyzer/Checkers/VforkChecker.cpp
===
--- clang/lib/StaticAnalyzer/Checkers/VforkChecker.cpp
+++ clang/lib/StaticAnalyzer/Checkers/VforkChecker.cpp
@@ -106,6 +106,7 @@
   "execv",
   "execvp",
   "execvpe",
+  "execve",
   nullptr
 };
 


Index: clang/lib/StaticAnalyzer/Checkers/VforkChecker.cpp
===
--- clang/lib/StaticAnalyzer/Checkers/VforkChecker.cpp
+++ clang/lib/StaticAnalyzer/Checkers/VforkChecker.cpp
@@ -106,6 +106,7 @@
   "execv",
   "execvp",
   "execvpe",
+  "execve",
   nullptr
 };
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D73629: [analyzer] vfork checker: allow execve after vfork

2020-01-29 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added a comment.

Yup, thanks, nice catch!

We should add a test for this (cf. `test/Analysis/vfork.c`).

Also do you have any immediate opinions on 
https://bugs.llvm.org/show_bug.cgi?id=43871? 'Cause i'm super confused. Like, 
it's trivial to fix but i'm not sure what the correct behavior is.


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

https://reviews.llvm.org/D73629



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


[PATCH] D73642: [Clang][Bundler] Reduce fat object size

2020-01-29 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev added inline comments.



Comment at: clang/tools/clang-offload-bundler/ClangOffloadBundler.cpp:493-518
+// Temporary files that need to be removed.
+struct TempFileList : public SmallVector, 2u> {
+  ~TempFileList() {
+for (const auto &File : *this)
+  sys::fs::remove(File);
+clear();
+  }

We usually don't do this. New types must be declared outside in anonymous 
namespaces. Also, better to use `part-of` inheritance rather than `is-a` here.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73642



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


[PATCH] D73651: [OpenCL][CUDA][HIP] Add norecurse

2020-01-29 Thread Artem Belevich via Phabricator via cfe-commits
tra accepted this revision.
tra added a comment.
This revision is now accepted and ready to land.

LGTM for CUDA.




Comment at: clang/lib/CodeGen/CodeGenFunction.cpp:918
+  //
+  // ToDo: clang does not support CUDA/HIP dynamic parallelism, therefore
+  // CUDA/HIP kernel can be marked with norecurse. This may change in the

I believe dynamic parallelism is more like spawning a separate process, not 
recursion, so we should be OK.


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

https://reviews.llvm.org/D73651



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


[PATCH] D73651: [OpenCL][CUDA][HIP] Add norecurse

2020-01-29 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl created this revision.
yaxunl added reviewers: Anastasia, tra.

norecurse function attr indicates the function is not called recursively 
directly or indirectly.

Add norecurse to OpenCL functions and CUDA/HIP kernels.

Although there is LLVM pass adding norecurse to functions, it only works for 
whole-program compilation. Also FE adding norecurse can make that pass run 
faster since functions with norecurse do not need to be checked again.


https://reviews.llvm.org/D73651

Files:
  clang/lib/CodeGen/CodeGenFunction.cpp
  clang/test/CodeGenCUDA/norecurse.cu
  clang/test/CodeGenOpenCL/norecurse.cl
  clang/test/SemaCUDA/call-kernel-from-kernel.cu


Index: clang/test/SemaCUDA/call-kernel-from-kernel.cu
===
--- /dev/null
+++ clang/test/SemaCUDA/call-kernel-from-kernel.cu
@@ -0,0 +1,9 @@
+// RUN: %clang_cc1 %s --std=c++11 -triple x86_64-unknown-linux -emit-llvm -o - 
\
+// RUN:   -verify -fsyntax-only -verify-ignore-unexpected=note
+
+#include "Inputs/cuda.h"
+
+__global__ void kernel1();
+__global__ void kernel2() {
+  kernel1<<<1,1>>>(); // expected-error {{reference to __global__ function 
'kernel1' in __global__ function}}
+}
Index: clang/test/CodeGenOpenCL/norecurse.cl
===
--- /dev/null
+++ clang/test/CodeGenOpenCL/norecurse.cl
@@ -0,0 +1,6 @@
+// RUN: %clang_cc1 -O0 -emit-llvm -o - %s | FileCheck %s
+
+kernel void kernel1(int a) {}
+// CHECK: define{{.*}}@kernel1{{.*}}#[[ATTR:[0-9]*]]
+
+// CHECK: attributes #[[ATTR]] = {{.*}}norecurse
Index: clang/test/CodeGenCUDA/norecurse.cu
===
--- /dev/null
+++ clang/test/CodeGenCUDA/norecurse.cu
@@ -0,0 +1,15 @@
+// REQUIRES: amdgpu-registered-target
+// REQUIRES: nvptx-registered-target
+
+// RUN: %clang_cc1 -triple nvptx-nvidia-cuda -fcuda-is-device \
+// RUN: -emit-llvm -disable-llvm-passes -o - %s | FileCheck %s
+
+// RUN: %clang_cc1 -triple amdgcn-amd-amdhsa -fcuda-is-device \
+// RUN: -emit-llvm -disable-llvm-passes -o - -x hip %s | FileCheck %s
+
+#include "Inputs/cuda.h"
+
+__global__ void kernel1(int a) {}
+// CHECK: define{{.*}}@_Z7kernel1i{{.*}}#[[ATTR:[0-9]*]]
+
+// CHECK: attributes #[[ATTR]] = {{.*}}norecurse
Index: clang/lib/CodeGen/CodeGenFunction.cpp
===
--- clang/lib/CodeGen/CodeGenFunction.cpp
+++ clang/lib/CodeGen/CodeGenFunction.cpp
@@ -907,10 +907,22 @@
   // If we're in C++ mode and the function name is "main", it is guaranteed
   // to be norecurse by the standard (3.6.1.3 "The function main shall not be
   // used within a program").
-  if (getLangOpts().CPlusPlus)
-if (const FunctionDecl *FD = dyn_cast_or_null(D))
-  if (FD->isMain())
-Fn->addFnAttr(llvm::Attribute::NoRecurse);
+  //
+  // OpenCL C 2.0 v2.2-11 s6.9.i:
+  // Recursion is not supported.
+  //
+  // OpenCL C++ 1.0 v2.1-11 s2.9:
+  // recursive function calls (ISO C++ Section 5.2.2, item 9) unless
+  // they are a compile-time constant expression.
+  //
+  // ToDo: clang does not support CUDA/HIP dynamic parallelism, therefore
+  // CUDA/HIP kernel can be marked with norecurse. This may change in the
+  // future.
+  if (const FunctionDecl *FD = dyn_cast_or_null(D)) {
+if ((getLangOpts().CPlusPlus && FD->isMain()) || getLangOpts().OpenCL ||
+(getLangOpts().CUDA && FD->hasAttr()))
+  Fn->addFnAttr(llvm::Attribute::NoRecurse);
+  }
 
   if (const FunctionDecl *FD = dyn_cast_or_null(D))
 if (FD->usesFPIntrin())


Index: clang/test/SemaCUDA/call-kernel-from-kernel.cu
===
--- /dev/null
+++ clang/test/SemaCUDA/call-kernel-from-kernel.cu
@@ -0,0 +1,9 @@
+// RUN: %clang_cc1 %s --std=c++11 -triple x86_64-unknown-linux -emit-llvm -o - \
+// RUN:   -verify -fsyntax-only -verify-ignore-unexpected=note
+
+#include "Inputs/cuda.h"
+
+__global__ void kernel1();
+__global__ void kernel2() {
+  kernel1<<<1,1>>>(); // expected-error {{reference to __global__ function 'kernel1' in __global__ function}}
+}
Index: clang/test/CodeGenOpenCL/norecurse.cl
===
--- /dev/null
+++ clang/test/CodeGenOpenCL/norecurse.cl
@@ -0,0 +1,6 @@
+// RUN: %clang_cc1 -O0 -emit-llvm -o - %s | FileCheck %s
+
+kernel void kernel1(int a) {}
+// CHECK: define{{.*}}@kernel1{{.*}}#[[ATTR:[0-9]*]]
+
+// CHECK: attributes #[[ATTR]] = {{.*}}norecurse
Index: clang/test/CodeGenCUDA/norecurse.cu
===
--- /dev/null
+++ clang/test/CodeGenCUDA/norecurse.cu
@@ -0,0 +1,15 @@
+// REQUIRES: amdgpu-registered-target
+// REQUIRES: nvptx-registered-target
+
+// RUN: %clang_cc1 -triple nvptx-nvidia-cuda -fcuda-is-device \
+// RUN: -emit-llvm -disable-llvm-passes -o - %s | FileCheck %s
+
+// RUN: %clang_cc1 -triple amdgcn-amd-amdhsa -fcuda

[PATCH] D73649: [CodeComplete] Member completion for concept-constrained types.

2020-01-29 Thread pre-merge checks [bot] via Phabricator via cfe-commits
merge_guards_bot added a comment.

{icon check-circle color=green} Unit tests: pass. 62282 tests passed, 0 failed 
and 827 were skipped.

{icon times-circle color=red} clang-tidy: fail. clang-tidy found 0 errors and 7 
warnings 
.
 0 of them are added as review comments below (why? 
).

{icon times-circle color=red} clang-format: fail. Please format your changes 
with clang-format by running `git-clang-format HEAD^` or applying this patch 
.

Build artifacts 
: 
diff.json 
,
 clang-tidy.txt 
,
 clang-format.patch 
,
 CMakeCache.txt 
,
 console-log.txt 
,
 test-results.xml 


//Pre-merge checks is in beta. Report issue 
.
 Please join beta  or enable 
it for your project 
.//


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73649



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


[PATCH] D73617: [clangd] Don't mmap source files on all platforms --> don't crash on git checkout

2020-01-29 Thread Sam McCall via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGb500c49cd4f8: [clangd] Don't mmap source files on all 
platforms --> don't crash on git… (authored by sammccall).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73617

Files:
  clang-tools-extra/clangd/FSProvider.cpp
  clang-tools-extra/clangd/FSProvider.h


Index: clang-tools-extra/clangd/FSProvider.h
===
--- clang-tools-extra/clangd/FSProvider.h
+++ clang-tools-extra/clangd/FSProvider.h
@@ -30,7 +30,6 @@
 
 class RealFileSystemProvider : public FileSystemProvider {
 public:
-  // FIXME: returns the single real FS instance, which is not threadsafe.
   llvm::IntrusiveRefCntPtr
   getFileSystem() const override;
 };
Index: clang-tools-extra/clangd/FSProvider.cpp
===
--- clang-tools-extra/clangd/FSProvider.cpp
+++ clang-tools-extra/clangd/FSProvider.cpp
@@ -19,7 +19,10 @@
 
 namespace {
 /// Always opens files in the underlying filesystem as "volatile", meaning they
-/// won't be memory-mapped. This avoid locking the files on Windows.
+/// won't be memory-mapped. Memory-mapping isn't desirable for clangd:
+///   - edits to the underlying files change contents MemoryBuffers owned by
+//  SourceManager, breaking its invariants and leading to crashes
+///   - it locks files on windows, preventing edits
 class VolatileFileSystem : public llvm::vfs::ProxyFileSystem {
 public:
   explicit VolatileFileSystem(llvm::IntrusiveRefCntPtr FS)
@@ -34,7 +37,7 @@
 if (!File)
   return File;
 // Try to guess preamble files, they can be memory-mapped even on Windows 
as
-// clangd has exclusive access to those.
+// clangd has exclusive access to those and nothing else should touch them.
 llvm::StringRef FileName = llvm::sys::path::filename(Path);
 if (FileName.startswith("preamble-") && FileName.endswith(".pch"))
   return File;
@@ -70,15 +73,11 @@
 
 llvm::IntrusiveRefCntPtr
 clang::clangd::RealFileSystemProvider::getFileSystem() const {
-// Avoid using memory-mapped files on Windows, they cause file locking issues.
-// FIXME: Try to use a similar approach in Sema instead of relying on
-//propagation of the 'isVolatile' flag through all layers.
-#ifdef _WIN32
+  // Avoid using memory-mapped files.
+  // FIXME: Try to use a similar approach in Sema instead of relying on
+  //propagation of the 'isVolatile' flag through all layers.
   return new VolatileFileSystem(
   llvm::vfs::createPhysicalFileSystem().release());
-#else
-  return llvm::vfs::createPhysicalFileSystem().release();
-#endif
 }
 } // namespace clangd
 } // namespace clang


Index: clang-tools-extra/clangd/FSProvider.h
===
--- clang-tools-extra/clangd/FSProvider.h
+++ clang-tools-extra/clangd/FSProvider.h
@@ -30,7 +30,6 @@
 
 class RealFileSystemProvider : public FileSystemProvider {
 public:
-  // FIXME: returns the single real FS instance, which is not threadsafe.
   llvm::IntrusiveRefCntPtr
   getFileSystem() const override;
 };
Index: clang-tools-extra/clangd/FSProvider.cpp
===
--- clang-tools-extra/clangd/FSProvider.cpp
+++ clang-tools-extra/clangd/FSProvider.cpp
@@ -19,7 +19,10 @@
 
 namespace {
 /// Always opens files in the underlying filesystem as "volatile", meaning they
-/// won't be memory-mapped. This avoid locking the files on Windows.
+/// won't be memory-mapped. Memory-mapping isn't desirable for clangd:
+///   - edits to the underlying files change contents MemoryBuffers owned by
+//  SourceManager, breaking its invariants and leading to crashes
+///   - it locks files on windows, preventing edits
 class VolatileFileSystem : public llvm::vfs::ProxyFileSystem {
 public:
   explicit VolatileFileSystem(llvm::IntrusiveRefCntPtr FS)
@@ -34,7 +37,7 @@
 if (!File)
   return File;
 // Try to guess preamble files, they can be memory-mapped even on Windows as
-// clangd has exclusive access to those.
+// clangd has exclusive access to those and nothing else should touch them.
 llvm::StringRef FileName = llvm::sys::path::filename(Path);
 if (FileName.startswith("preamble-") && FileName.endswith(".pch"))
   return File;
@@ -70,15 +73,11 @@
 
 llvm::IntrusiveRefCntPtr
 clang::clangd::RealFileSystemProvider::getFileSystem() const {
-// Avoid using memory-mapped files on Windows, they cause file locking issues.
-// FIXME: Try to use a similar approach in Sema instead of relying on
-//propagation of the 'isVolatile' flag through all layers.
-#ifdef _WIN32
+  // Avoid using memory-mapped files.
+  // FIXME: Try to use a similar approach in Sema instead of relying on
+  //propagation of the 'isVolatile' flag through all layers.
   r

[PATCH] D73649: [CodeComplete] Member completion for concept-constrained types.

2020-01-29 Thread Sam McCall via Phabricator via cfe-commits
sammccall created this revision.
sammccall added reviewers: nridge, saar.raz.
Herald added subscribers: cfe-commits, mgrang.
Herald added a project: clang.

The basic idea is to walk through the concept definition, looking for
t.foo() where t has the constrained type.

In this patch:

- nested types are recognized and offered after ::
- variable/function members are recognized and offered after the correct 
dot/arrow/colon trigger
- member functions are recognized (anything directly called). parameter types 
are presumed to be the argument types. parameters are unnamed.
- result types are available when a requirement has a type constraint. These 
are printed as constraints, except same_as which prints as T.

Not in this patch:

- support for merging/overloading when two locations describe the same member. 
The last one wins, for any given name. This is probably important...
- support for nested template members (T::x)
- support for completing members of (instantiations of) template template 
parameters


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D73649

Files:
  clang/include/clang/Sema/Scope.h
  clang/lib/Sema/CodeCompleteConsumer.cpp
  clang/lib/Sema/SemaCodeComplete.cpp
  clang/test/CodeCompletion/concepts.cpp

Index: clang/test/CodeCompletion/concepts.cpp
===
--- /dev/null
+++ clang/test/CodeCompletion/concepts.cpp
@@ -0,0 +1,58 @@
+template  concept convertible_to = true;
+template  concept same_as = true;
+template  concept integral = true;
+
+template 
+concept W = requires(A a, B b) {
+  { b.www } noexcept -> integral;
+};
+
+template  concept X = requires(T t) {
+  t.xxx(42);
+  typename T::xxx_t;
+};
+
+template 
+concept Y = requires(T t, U u) { t.yyy(u); };
+
+template 
+concept Z = requires(T t) {
+  { t.zzz() } -> same_as;
+  requires W;
+};
+
+// Concept constraints in all three slots require X, Y, Z, and ad-hoc stuff.
+template 
+requires Y && requires(T *t) { { t->aaa() } -> convertible_to; }
+void foo(T t) requires Z || requires(T &t) { t.bbb(); t->bb(); } {
+  t.x;
+  t->x;
+  T::x;
+
+  // RUN: %clang_cc1 -std=c++2a -code-completion-with-fixits -code-completion-at=%s:28:5 %s \
+  // RUN: | FileCheck %s -check-prefix=DOT -implicit-check-not=xxx_t
+  // DOT: Pattern : [#convertible_to#]aaa()
+  // DOT: Pattern : bb() (requires fix-it: {{.*}} to "->")
+  // DOT: Pattern : bbb()
+  // DOT: Pattern : [#integral#]www
+  // DOT: Pattern : xxx(<#int#>)
+  // FIXME: it would be nice to have int instead of U here.
+  // DOT: Pattern : yyy(<#U#>)
+  // DOT: Pattern : [#int#]zzz()
+
+  // RUN: %clang_cc1 -std=c++2a -code-completion-with-fixits -code-completion-at=%s:29:6 %s \
+  // RUN: | FileCheck %s -check-prefix=ARROW -implicit-check-not=xxx_t
+  // ARROW: Pattern : [#convertible_to#]aaa() (requires fix-it: {{.*}} to ".")
+  // ARROW: Pattern : bb()
+  // ARROW: Pattern : bbb() (requires fix-it
+  // ARROW: Pattern : [#integral#]www (requires fix-it
+  // ARROW: Pattern : xxx(<#int#>) (requires fix-it
+  // ARROW: Pattern : yyy(<#U#>) (requires fix-it
+  // ARROW: Pattern : [#int#]zzz() (requires fix-it
+
+  // RUN: %clang_cc1 -std=c++2a -code-completion-with-fixits -code-completion-at=%s:30:6 %s \
+  // RUN: | FileCheck %s -check-prefix=COLONS -implicit-check-not=yyy
+  // COLONS: COMPLETION: template
+  // COLONS: Pattern : xxx_t
+}
+
Index: clang/lib/Sema/SemaCodeComplete.cpp
===
--- clang/lib/Sema/SemaCodeComplete.cpp
+++ clang/lib/Sema/SemaCodeComplete.cpp
@@ -9,6 +9,7 @@
 //  This file defines the code-completion semantic actions.
 //
 //===--===//
+#include "clang/AST/ASTConcept.h"
 #include "clang/AST/Decl.h"
 #include "clang/AST/DeclBase.h"
 #include "clang/AST/DeclCXX.h"
@@ -16,8 +17,11 @@
 #include "clang/AST/DeclTemplate.h"
 #include "clang/AST/Expr.h"
 #include "clang/AST/ExprCXX.h"
+#include "clang/AST/ExprConcepts.h"
 #include "clang/AST/ExprObjC.h"
+#include "clang/AST/NestedNameSpecifier.h"
 #include "clang/AST/QualTypeNames.h"
+#include "clang/AST/RecursiveASTVisitor.h"
 #include "clang/AST/Type.h"
 #include "clang/Basic/CharInfo.h"
 #include "clang/Basic/Specifiers.h"
@@ -4746,6 +4750,342 @@
   return nullptr;
 }
 
+namespace {
+// Collects completion-relevant information about a concept-constrainted type T.
+// In particular, examines the constraint expressions to find members of T.
+//
+// The design is very simple: we walk down each constraint looking for
+// expressions of the form T.foo().
+// If we're extra lucky, the return type is specified.
+// We don't do any clever handling of && or || in constraint expressions, we
+// take members from both branches.
+//
+// For example, given:
+//   template  concept X = requires (T t, string& s) { t.print(s); };
+//   template  void foo(U u) { u.^ }
+// We want to suggest the inferred member function 'print(string)'

[clang-tools-extra] b500c49 - [clangd] Don't mmap source files on all platforms --> don't crash on git checkout

2020-01-29 Thread Sam McCall via cfe-commits

Author: Sam McCall
Date: 2020-01-29T19:44:14+01:00
New Revision: b500c49cd4f81f067cda721049cb1fd72a5e7bf5

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

LOG: [clangd] Don't mmap source files on all platforms --> don't crash on git 
checkout

Summary:
Previously we mmapped on unix and not on windows: on windows mmap takes
an exclusive lock on the file and prevents the user saving changes!

The failure mode on linux is a bit more subtle: if the file is changed on disk
but the SourceManager sticks around, then subsequent operations on the
SourceManager will fail as invariants are violated (e.g. null-termination).

This commonly manifests as crashes after switching git branches with many files
open in clangd.

Nominally mmap is for performance here, and we should be willing to give some
up to stop crashing. Measurements on my system (linux+desktop+SSD) at least
show no measurable regression on an a fairly IO-heavy workload: drop disk 
caches,
open SemaOverload.cpp, wait for first diagnostics.

for i in `seq 100`; do
  for variant in mmap volatile; do
echo 3 | sudo tee /proc/sys/vm/drop_caches
/usr/bin/time --append --quiet -o ~/timings -f "%C %E" \
bin/clangd.$variant -sync -background-index=0 < /tmp/mirror > /dev/null
  done
done

bin/clangd.mmap -sync -background-index=0 0:07.60
bin/clangd.volatile -sync -background-index=0 0:07.89
bin/clangd.mmap -sync -background-index=0 0:07.44
bin/clangd.volatile -sync -background-index=0 0:07.89
bin/clangd.mmap -sync -background-index=0 0:07.42
bin/clangd.volatile -sync -background-index=0 0:07.50
bin/clangd.mmap -sync -background-index=0 0:07.90
bin/clangd.volatile -sync -background-index=0 0:07.53
bin/clangd.mmap -sync -background-index=0 0:07.64
bin/clangd.volatile -sync -background-index=0 0:07.55
bin/clangd.mmap -sync -background-index=0 0:07.75
bin/clangd.volatile -sync -background-index=0 0:07.47
bin/clangd.mmap -sync -background-index=0 0:07.90
bin/clangd.volatile -sync -background-index=0 0:07.50
bin/clangd.mmap -sync -background-index=0 0:07.81
bin/clangd.volatile -sync -background-index=0 0:07.95
bin/clangd.mmap -sync -background-index=0 0:07.55
bin/clangd.volatile -sync -background-index=0 0:07.65
bin/clangd.mmap -sync -background-index=0 0:08.15
bin/clangd.volatile -sync -background-index=0 0:07.54
bin/clangd.mmap -sync -background-index=0 0:07.78
bin/clangd.volatile -sync -background-index=0 0:07.61
bin/clangd.mmap -sync -background-index=0 0:07.78
bin/clangd.volatile -sync -background-index=0 0:07.55
bin/clangd.mmap -sync -background-index=0 0:07.41
bin/clangd.volatile -sync -background-index=0 0:07.40
bin/clangd.mmap -sync -background-index=0 0:07.54
bin/clangd.volatile -sync -background-index=0 0:07.42
bin/clangd.mmap -sync -background-index=0 0:07.45
bin/clangd.volatile -sync -background-index=0 0:07.49
bin/clangd.mmap -sync -background-index=0 0:07.95
bin/clangd.volatile -sync -background-index=0 0:07.66
bin/clangd.mmap -sync -background-index=0 0:08.04

Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, kadircet, usaxena95, 
cfe-commits

Tags: #clang

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

Added: 


Modified: 
clang-tools-extra/clangd/FSProvider.cpp
clang-tools-extra/clangd/FSProvider.h

Removed: 




diff  --git a/clang-tools-extra/clangd/FSProvider.cpp 
b/clang-tools-extra/clangd/FSProvider.cpp
index 5d1434bf6f0b..80d6be005cc4 100644
--- a/clang-tools-extra/clangd/FSProvider.cpp
+++ b/clang-tools-extra/clangd/FSProvider.cpp
@@ -19,7 +19,10 @@ namespace clangd {
 
 namespace {
 /// Always opens files in the underlying filesystem as "volatile", meaning they
-/// won't be memory-mapped. This avoid locking the files on Windows.
+/// won't be memory-mapped. Memory-mapping isn't desirable for clangd:
+///   - edits to the underlying files change contents MemoryBuffers owned by
+//  SourceManager, breaking its invariants and leading to crashes
+///   - it locks files on windows, preventing edits
 class VolatileFileSystem : public llvm::vfs::ProxyFileSystem {
 public:
   explicit VolatileFileSystem(llvm::IntrusiveRefCntPtr FS)
@@ -34,7 +37,7 @@ class VolatileFileSystem : public llvm::vfs::ProxyFileSystem {
 if (!File)
   return File;
 // Try to guess preamble files, they can be memory-mapped even on Windows 
as
-// clangd has exclusive access to those.
+// clangd has exclusive access to those and nothing else should touch them.
 llvm::StringRef FileName = llvm::sys::path::filename(Path);
 if (FileName.startswith("preamble-") && FileName.endswith(".pch"))
   return File;
@@ -70,15 +73,11 @@ class VolatileFileSystem : public 
llvm::vfs::ProxyFileSystem {
 
 llvm::IntrusiveRefCntPtr
 clang::clangd::RealFileSystemProvider::getFileSystem() const {
-// Avoid

[PATCH] D73644: [Mips] Add intrinsics for 4-byte and 8-byte MSA loads/stores.

2020-01-29 Thread Mirko Brkusanin via Phabricator via cfe-commits
mbrkusanin added a comment.

A few notes/questions:

1. Generated code was tested with Qemu:
  - For mips32r5 Qemu provides p5600
  - For mips64r6 Qemu provides i6400
  - For mips64r5 there is no cpu on Qemu with MSA and it appears that there 
won't be any hardware with Mips64r5 and MSA.
  - For mips32r6 Qemu only provides a cpu called mips32r6-generic which does 
not support MSA. I tested the code for this on mips64r6.

2. Names of the new intrinsics can be explained in the following way:

`__builtin_msa_ldr_d` (load right half)
`__builtin_msa_ldrq_w` (load right quarter)
`__builtin_msa_str_d` (store right half)
`__builtin_msa_strq_w` (store quarter)
Other proposed names are: ld1_d/ld1_w/st1_d/st1_w and ldc1/lwc1/sdc1/swc1. I 
have no strong preference and would not mind changing then if someone thinks 
they would fit better.

3. I did not make any tests for Clang (c/c++ test) since there are no tests for 
other intrinsics. Also should these new intrinsics be documented somewhere? 
Most other are corresponding to some instruction that already exists but these 
are actually pseudos.

4. emitLDRQ_W() and emitLDR_D() could be combined into one function but it 
decreases readability. Same with emitting stores: emitSTRQ_W() and emitSTR_D(). 
I already tried this and have the code ready if this would be more preferable.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73644



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


[PATCH] D73644: [Mips] Add intrinsics for 4-byte and 8-byte MSA loads/stores.

2020-01-29 Thread Mirko Brkusanin via Phabricator via cfe-commits
mbrkusanin created this revision.
mbrkusanin added reviewers: atanasyan, petarj, sdardis, mstojanovic.
mbrkusanin added projects: LLVM, clang.
Herald added subscribers: cfe-commits, jrtc27, hiraditya, arichardson.

New intrinisics are implemented for when we need to port SIMD code from other 
arhitectures and only load or store portions of MSA registers.

Following intriniscs are added which only load/store element 0 of a vector:
v4i32 __builtin_msa_ldrq_w (const void *, imm_n2048_2044);
v2i64 __builtin_msa_ldr_d (const void *, imm_n4096_4088);
void __builtin_msa_strq_w (v4i32, void *, imm_n2048_2044);
void __builtin_msa_str_d (v2i64, void *, imm_n4096_4088);


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D73644

Files:
  clang/include/clang/Basic/BuiltinsMips.def
  clang/lib/Headers/msa.h
  clang/lib/Sema/SemaChecking.cpp
  llvm/include/llvm/IR/IntrinsicsMips.td
  llvm/lib/Target/Mips/MipsISelLowering.cpp
  llvm/lib/Target/Mips/MipsISelLowering.h
  llvm/lib/Target/Mips/MipsMSAInstrInfo.td
  llvm/lib/Target/Mips/MipsSEISelDAGToDAG.cpp
  llvm/test/CodeGen/Mips/msa/ldr_str.ll

Index: llvm/test/CodeGen/Mips/msa/ldr_str.ll
===
--- /dev/null
+++ llvm/test/CodeGen/Mips/msa/ldr_str.ll
@@ -0,0 +1,224 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
+; RUN: llc -march=mips -mcpu=mips32r5 -mattr=+msa,+fp64 -O0 < %s | FileCheck %s --check-prefix=MIPS32R5-EB
+; RUN: llc -march=mipsel   -mcpu=mips32r5 -mattr=+msa,+fp64 -O0 < %s | FileCheck %s --check-prefix=MIPS32R5-EL
+; RUN: llc -march=mips -mcpu=mips32r6 -mattr=+msa,+fp64 -O0 < %s | FileCheck %s --check-prefix=MIPS32R6-EB
+; RUN: llc -march=mipsel   -mcpu=mips32r6 -mattr=+msa,+fp64 -O0 < %s | FileCheck %s --check-prefix=MIPS32R6-EL
+; RUN: llc -march=mips64   -mcpu=mips64r6 -mattr=+msa,+fp64 -O0 < %s | FileCheck %s --check-prefix=MIPS64R6
+; RUN: llc -march=mips64el -mcpu=mips64r6 -mattr=+msa,+fp64 -O0 < %s | FileCheck %s --check-prefix=MIPS64R6
+
+; Test intrinsics for 4-byte and 8-byte MSA load and stores.
+
+define void @llvm_mips_ldr_d_test(<2 x i64>* %val, i8* %ptr) nounwind {
+; MIPS32R5-EB-LABEL: llvm_mips_ldr_d_test:
+; MIPS32R5-EB:   # %bb.0: # %entry
+; MIPS32R5-EB-NEXT:# implicit-def: $at
+; MIPS32R5-EB-NEXT:lwr $1, 23($5)
+; MIPS32R5-EB-NEXT:lwl $1, 20($5)
+; MIPS32R5-EB-NEXT:# implicit-def: $v0
+; MIPS32R5-EB-NEXT:lwr $2, 19($5)
+; MIPS32R5-EB-NEXT:lwl $2, 16($5)
+; MIPS32R5-EB-NEXT:fill.w $w0, $1
+; MIPS32R5-EB-NEXT:insert.w $w0[1], $2
+; MIPS32R5-EB-NEXT:st.d $w0, 0($4)
+; MIPS32R5-EB-NEXT:jr $ra
+; MIPS32R5-EB-NEXT:nop
+;
+; MIPS32R5-EL-LABEL: llvm_mips_ldr_d_test:
+; MIPS32R5-EL:   # %bb.0: # %entry
+; MIPS32R5-EL-NEXT:# implicit-def: $at
+; MIPS32R5-EL-NEXT:lwr $1, 16($5)
+; MIPS32R5-EL-NEXT:lwl $1, 19($5)
+; MIPS32R5-EL-NEXT:# implicit-def: $v0
+; MIPS32R5-EL-NEXT:lwr $2, 20($5)
+; MIPS32R5-EL-NEXT:lwl $2, 23($5)
+; MIPS32R5-EL-NEXT:fill.w $w0, $1
+; MIPS32R5-EL-NEXT:insert.w $w0[1], $2
+; MIPS32R5-EL-NEXT:st.d $w0, 0($4)
+; MIPS32R5-EL-NEXT:jr $ra
+; MIPS32R5-EL-NEXT:nop
+;
+; MIPS32R6-EB-LABEL: llvm_mips_ldr_d_test:
+; MIPS32R6-EB:   # %bb.0: # %entry
+; MIPS32R6-EB-NEXT:lw $1, 20($5)
+; MIPS32R6-EB-NEXT:lw $2, 16($5)
+; MIPS32R6-EB-NEXT:fill.w $w0, $1
+; MIPS32R6-EB-NEXT:insert.w $w0[1], $2
+; MIPS32R6-EB-NEXT:st.d $w0, 0($4)
+; MIPS32R6-EB-NEXT:jrc $ra
+;
+; MIPS32R6-EL-LABEL: llvm_mips_ldr_d_test:
+; MIPS32R6-EL:   # %bb.0: # %entry
+; MIPS32R6-EL-NEXT:lw $1, 16($5)
+; MIPS32R6-EL-NEXT:lw $2, 20($5)
+; MIPS32R6-EL-NEXT:fill.w $w0, $1
+; MIPS32R6-EL-NEXT:insert.w $w0[1], $2
+; MIPS32R6-EL-NEXT:st.d $w0, 0($4)
+; MIPS32R6-EL-NEXT:jrc $ra
+;
+; MIPS64R6-LABEL: llvm_mips_ldr_d_test:
+; MIPS64R6:   # %bb.0: # %entry
+; MIPS64R6-NEXT:ld $1, 16($5)
+; MIPS64R6-NEXT:fill.d $w0, $1
+; MIPS64R6-NEXT:st.d $w0, 0($4)
+; MIPS64R6-NEXT:jrc $ra
+entry:
+  %0 = tail call <2 x i64> @llvm.mips.ldr.d(i8* %ptr, i32 16)
+  store <2 x i64> %0, <2 x i64>* %val
+  ret void
+}
+
+declare <2 x i64> @llvm.mips.ldr.d(i8*, i32) nounwind
+
+define void @llvm_mips_ldrq_w_test(<4 x i32>* %val, i8* %ptr) nounwind {
+; MIPS32R5-EB-LABEL: llvm_mips_ldrq_w_test:
+; MIPS32R5-EB:   # %bb.0: # %entry
+; MIPS32R5-EB-NEXT:# implicit-def: $at
+; MIPS32R5-EB-NEXT:lwr $1, 19($5)
+; MIPS32R5-EB-NEXT:lwl $1, 16($5)
+; MIPS32R5-EB-NEXT:fill.w $w0, $1
+; MIPS32R5-EB-NEXT:st.w $w0, 0($4)
+; MIPS32R5-EB-NEXT:jr $ra
+; MIPS32R5-EB-NEXT:nop
+;
+; MIPS32R5-EL-LABEL: llvm_mips_ldrq_w_test:
+; MIPS32R5-EL:   # %bb.0: # %entry
+; MIPS32R5-EL-NEXT:# implicit-def: $at
+; MIPS32R5-EL-NEXT:lwr $1, 16($5)
+; MIPS32R5-EL-NEXT:lwl $1, 19($5)
+; MIPS32R5-EL-NEXT:fill.w $w0, $1
+; MIPS32R5-EL-NEXT:st.w $w0, 0($4)
+; MIPS32R5-EL-NEXT:jr $ra
+; MIPS32R5-EL-NE

[PATCH] D73642: [Clang][Bundler] Reduce fat object size

2020-01-29 Thread Sergey Dmitriev via Phabricator via cfe-commits
sdmitriev created this revision.
sdmitriev added a reviewer: ABataev.
Herald added a reviewer: alexshap.
Herald added a reviewer: jdoerfert.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Fat object size has significantly increased after D65819 
 which changed bundler tool to add host object 
as a normal bundle to the fat output which almost doubled its size. That patch 
was fixing the following issues

1. Problems associated with the partial linking - global constructors were not 
called for partially linking objects which clearly resulted in incorrect 
behavior.
2. Eliminating "junk" target object sections from the linked binary on the host 
side.

The first problem is no longer relevant because we do not use partial linking 
for creating fat objects anymore. Target objects sections are now inserted into 
the resulting fat object with a help of llvm-objcopy tool.

The second issue, "junk" sections in the linked host binary, has been fixed in 
D73408  by adding "exclude" flag to the fat 
object's sections which contain target objects. This flag tells linker to drop 
section from the inputs when linking executable or shared library, therefore 
these sections will not be propagated in the linked binary.

Since both problems have been solved, we can revert D65819 
 changes to reduce fat object size and this 
patch essentially is doing that.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D73642

Files:
  clang/test/Driver/clang-offload-bundler.c
  clang/tools/clang-offload-bundler/ClangOffloadBundler.cpp

Index: clang/tools/clang-offload-bundler/ClangOffloadBundler.cpp
===
--- clang/tools/clang-offload-bundler/ClangOffloadBundler.cpp
+++ clang/tools/clang-offload-bundler/ClangOffloadBundler.cpp
@@ -30,7 +30,6 @@
 #include "llvm/Support/Error.h"
 #include "llvm/Support/ErrorOr.h"
 #include "llvm/Support/FileSystem.h"
-#include "llvm/Support/FileUtilities.h"
 #include "llvm/Support/MemoryBuffer.h"
 #include "llvm/Support/Path.h"
 #include "llvm/Support/Program.h"
@@ -433,11 +432,16 @@
   Error ReadBundleEnd(MemoryBuffer &Input) final { return Error::success(); }
 
   Error ReadBundle(raw_fd_ostream &OS, MemoryBuffer &Input) final {
-Expected Content = CurrentSection->getContents();
-if (!Content)
-  return Content.takeError();
+Expected ContentOrErr = CurrentSection->getContents();
+if (!ContentOrErr)
+  return ContentOrErr.takeError();
+StringRef Content = *ContentOrErr;
 
-OS.write(Content->data(), Content->size());
+// Copy fat object contents to the output when extracting host bundle.
+if (Content.size() == 1u && Content.front() == 0)
+  Content = StringRef(Input.getBufferStart(), Input.getBufferSize());
+
+OS.write(Content.data(), Content.size());
 return Error::success();
   }
 
@@ -486,22 +490,60 @@
 // to pass down to llvm-objcopy.
 OS.close();
 
+// Temporary files that need to be removed.
+struct TempFileList : public SmallVector, 2u> {
+  ~TempFileList() {
+for (const auto &File : *this)
+  sys::fs::remove(File);
+clear();
+  }
+
+  Expected Create(Optional> Contents) {
+SmallString<128u> FileName;
+if (std::error_code EC = sys::fs::createTemporaryFile(
+"clang-offload-bundler", "tmp", FileName))
+  return createFileError(FileName, EC);
+push_back(FileName);
+
+if (Contents) {
+  std::error_code EC;
+  raw_fd_ostream HostFile(FileName, EC);
+  if (EC)
+return createFileError(FileName, EC);
+  HostFile.write(Contents->data(), Contents->size());
+}
+return back();
+  }
+} TempFiles;
+
 // Create an intermediate temporary file to save object after the first
 // llvm-objcopy run.
-SmallString<128u> IntermediateObj;
-if (std::error_code EC = sys::fs::createTemporaryFile(
-"clang-offload-bundler", "tmp", IntermediateObj))
-  return createFileError(IntermediateObj, EC);
-FileRemover IntermediateObjRemover(IntermediateObj);
+Expected> IntermediateObjOrErr = TempFiles.Create(None);
+if (!IntermediateObjOrErr)
+  return IntermediateObjOrErr.takeError();
+const SmallString<128u> &IntermediateObj = *IntermediateObjOrErr;
 
 // Compose llvm-objcopy command line for add target objects' sections.
 BumpPtrAllocator Alloc;
 StringSaver SS{Alloc};
 SmallVector ObjcopyArgs{"llvm-objcopy"};
-for (unsigned I = 0; I < NumberOfInputs; ++I)
+for (unsigned I = 0; I < NumberOfInputs; ++I) {
+  StringRef InputFile = InputFileNames[I];
+  if (I == HostInputIndex) {
+// Special handling for the host bundle. We do not need to add a
+// standard bundle for the host object since we are going to use fat
+   

[PATCH] D73629: [analyzer] vfork checker: allow execve after vfork

2020-01-29 Thread Csaba Dabis via Phabricator via cfe-commits
Charusso added a reviewer: NoQ.
Charusso added a comment.

Hey, thanks! The patch looks great, but please note that we do the reviews with 
context using `git diff -U99` or uploading with `arc` 
(https://secure.phabricator.com/book/phabricator/article/arcanist/).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73629



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


[PATCH] D73638: [AST] Move dependence computations into a separate file

2020-01-29 Thread pre-merge checks [bot] via Phabricator via cfe-commits
merge_guards_bot added a comment.

{icon question-circle color=gray} Unit tests: unknown.

{icon question-circle color=gray} clang-tidy: unknown.

{icon question-circle color=gray} clang-format: unknown.

Build artifacts 
: 
diff.json 
,
 console-log.txt 


//Pre-merge checks is in beta. Report issue 
.
 Please join beta  or enable 
it for your project 
.//


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73638



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


[clang] 8093d37 - Fix switch covers all cases static analyzer warning. NFCI.

2020-01-29 Thread Simon Pilgrim via cfe-commits

Author: Simon Pilgrim
Date: 2020-01-29T17:26:22Z
New Revision: 8093d37ed2548ff5c8d6d7c51bd0431afbbf4209

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

LOG: Fix switch covers all cases static analyzer warning. NFCI.

Added: 


Modified: 
clang/lib/Format/TokenAnnotator.cpp

Removed: 




diff  --git a/clang/lib/Format/TokenAnnotator.cpp 
b/clang/lib/Format/TokenAnnotator.cpp
index c4798f65592a..3dc88315c352 100644
--- a/clang/lib/Format/TokenAnnotator.cpp
+++ b/clang/lib/Format/TokenAnnotator.cpp
@@ -3160,6 +3160,7 @@ bool TokenAnnotator::mustBreakBefore(const AnnotatedLine 
&Line,
 return (Left.NestingLevel == 0 && Line.Level == 0) &&
!Left.Children.empty();
   }
+  llvm_unreachable("Unknown FormatStyle::ShortLambdaStyle enum");
 }
 
 if (Right.is(tok::r_brace) && Left.is(tok::l_brace) &&



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


[PATCH] D72304: [OpenMP][OMPIRBuilder] Add Directives (master and critical) to OMPBuilder.

2020-01-29 Thread Fady Ghanim via Phabricator via cfe-commits
fghanim added a comment.

Everything is fine!
I just cloned llvm from git hub, added this revision with `arc patch`. then:
`cmake -G"Unix Makefiles" -DLLVM_ENABLE_PROJECTS="clang;openmp" 
-DCMAKE_BUILD_TYPE=Release -DLLVM_OPTIMIZED_TABLEGEN=1 -DLLVM_USE_LINKER=gold 
../llvm-project/llvm`
`make` , `make check-llvm-unittest`, `make check-clang-openmp`

all of it works fine and I got no errors whatsoever. Let me know what you think.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72304



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


[PATCH] D73638: [AST] Move dependence computations into a separate file

2020-01-29 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov added a comment.

@rsmith this does not pass through testing, I've messed up somewhere while 
moving the code.
I'll find what went wrong and fix it tomorrow. Please tell if the approach 
itself LG.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73638



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


[PATCH] D73617: [clangd] Don't mmap source files on all platforms --> don't crash on git checkout

2020-01-29 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov accepted this revision.
ilya-biryukov added a comment.
This revision is now accepted and ready to land.

LGTM!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73617



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


[PATCH] D57054: [MachineOutliner][ARM][RFC] Add Machine Outliner support for ARM

2020-01-29 Thread Yvan Roux via Phabricator via cfe-commits
yroux updated this revision to Diff 241188.
yroux added a comment.

Here is a new version, which disables ARM Low Overhead Loops pass when the 
Machine Outliner is enabled.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D57054

Files:
  clang/lib/Driver/ToolChains/Clang.cpp
  llvm/include/llvm/CodeGen/TargetPassConfig.h
  llvm/lib/CodeGen/MachineOutliner.cpp
  llvm/lib/CodeGen/TargetPassConfig.cpp
  llvm/lib/Target/ARM/ARMBaseInstrInfo.cpp
  llvm/lib/Target/ARM/ARMBaseInstrInfo.h
  llvm/lib/Target/ARM/ARMTargetMachine.cpp
  llvm/test/CodeGen/ARM/O3-pipeline.ll
  llvm/test/CodeGen/ARM/machine-outliner-stack-fixup-arm.mir
  llvm/test/CodeGen/ARM/machine-outliner-stack-fixup-thumb.mir
  llvm/test/CodeGen/ARM/machine-outliner-tail.ll
  llvm/test/CodeGen/ARM/machine-outliner-thunk.ll
  llvm/test/CodeGen/ARM/machine-outliner.ll
  llvm/test/CodeGen/ARM/machine-outliner.mir

Index: llvm/test/CodeGen/ARM/machine-outliner.mir
===
--- /dev/null
+++ llvm/test/CodeGen/ARM/machine-outliner.mir
@@ -0,0 +1,72 @@
+# RUN: llc -mtriple=arm-- -run-pass=machine-outliner -verify-machineinstrs \
+# RUN: %s -o - | FileCheck %s
+# RUN: llc -mtriple=thumbv7-- -run-pass=machine-outliner -verify-machineinstrs \
+# RUN: %s -o - | FileCheck %s
+
+--- |
+  define void @outline_1() #0 { ret void }
+  define void @outline_2() #0 { ret void }
+  define void @outline_3() #0 { ret void }
+  define void @dont_outline() { ret void }
+
+  attributes #0 = { minsize optsize }
+...
+---
+
+name:   outline_1
+tracksRegLiveness: true
+body: |
+  bb.0:
+; CHECK-LABEL: bb.0:
+; CHECK: OUTLINED
+liveins: $r2
+$r2 = MOVi 1, 14, $noreg, $noreg
+$r2 = MOVi 1, 14, $noreg, $noreg
+$r2 = MOVi 1, 14, $noreg, $noreg
+$r2 = MOVi 1, 14, $noreg, $noreg
+BX_RET 14, $noreg
+...
+---
+
+name:   outline_2
+tracksRegLiveness: true
+body: |
+  bb.0:
+; CHECK-LABEL: bb.0:
+; CHECK: OUTLINED
+liveins: $r2
+$r2 = MOVi 1, 14, $noreg, $noreg
+$r2 = MOVi 1, 14, $noreg, $noreg
+$r2 = MOVi 1, 14, $noreg, $noreg
+$r2 = MOVi 1, 14, $noreg, $noreg
+BX_RET 14, $noreg
+...
+---
+
+name:   outline_3
+tracksRegLiveness: true
+body: |
+  bb.0:
+; CHECK-LABEL: bb.0:
+; CHECK: OUTLINED
+liveins: $r2
+$r2 = MOVi 1, 14, $noreg, $noreg
+$r2 = MOVi 1, 14, $noreg, $noreg
+$r2 = MOVi 1, 14, $noreg, $noreg
+$r2 = MOVi 1, 14, $noreg, $noreg
+BX_RET 14, $noreg
+...
+---
+
+name:   dont_outline
+tracksRegLiveness: true
+body: |
+  bb.0:
+; CHECK-LABEL: bb.0:
+; CHECK-NOT: BL
+liveins: $lr, $r2
+$r2 = MOVi 1, 14, $noreg, $noreg
+$r2 = MOVi 1, 14, $noreg, $noreg
+$r2 = MOVi 1, 14, $noreg, $noreg
+$r2 = MOVi 1, 14, $noreg, $noreg
+BX_RET 14, $noreg
Index: llvm/test/CodeGen/ARM/machine-outliner.ll
===
--- /dev/null
+++ llvm/test/CodeGen/ARM/machine-outliner.ll
@@ -0,0 +1,135 @@
+; RUN: llc -verify-machineinstrs -enable-machine-outliner -mtriple=arm-- \
+; RUN: < %s | FileCheck %s --check-prefixes=CHECK,ARM
+; RUN: llc -verify-machineinstrs -enable-machine-outliner -mtriple=thumbv7-- \
+; RUN: < %s | FileCheck %s --check-prefixes=CHECK,THUMB
+; RUN: llc -verify-machineinstrs -enable-machine-outliner \
+; RUN: -enable-linkonceodr-outlining -mtriple=arm-- < %s | FileCheck %s \
+; RUN: --check-prefix=ODR
+; RUN: llc -verify-machineinstrs -enable-machine-outliner \
+; RUN: -enable-linkonceodr-outlining -mtriple=thumbv7-- < %s | FileCheck %s \
+; RUN: --check-prefix=ODR
+; RUN: llc -verify-machineinstrs -enable-machine-outliner -mtriple=arm-- \
+; RUN: -stop-after=machine-outliner < %s | FileCheck %s \
+; RUN: --check-prefix=TARGET_FEATURES
+
+
+; Make sure that we inherit target features from functions and make sure we have
+; the right function attributes.
+; TARGET_FEATURES: define internal void @OUTLINED_FUNCTION_{{[0-9]+}}()
+; TARGET_FEATURES-SAME: #[[ATTR_NUM:[0-9]+]]
+; TARGET_FEATURES-DAG: attributes #[[ATTR_NUM]] = {
+; TARGET_FEATURES-SAME: minsize
+; TARGET_FEATURES-SAME: optsize
+; TARGET_FEATURES-SAME: "target-features"="+neon"
+
+define linkonce_odr void @fish() #0 {
+  ; CHECK-LABEL: fish:
+  ; CHECK-NOT: OUTLINED
+  ; ODR: [[OUTLINED:OUTLINED_FUNCTION_[0-9]+]]
+  %1 = alloca i32, align 4
+  %2 = alloca i32, align 4
+  %3 = alloca i32, align 4
+  %4 = alloca i32, align 4
+  %5 = alloca i32, align 4
+  %6 = alloca i32, align 4
+  store i32 1, i32* %1, align 4
+  store i32 2, i32* %2, align 4
+  store i32 3, i32* %3, align 4
+  store i32 4, i32* %4, align 4
+  store i32 5, i32* %5, align 4
+  store i32 6, i32* %6, align 4
+  ret void
+}
+
+define void @turtle() section "TURTLE,turtle" {
+  ; CHECK-LABEL: turtle:
+  ; ODR-LABEL: turtle:
+  ; CHECK-NOT: OUTLINED
+  %1 = alloca i32,

[PATCH] D73637: Fix handling of OO_Spaceship in DecodeOperatorCall

2020-01-29 Thread Stephan Bergmann via Phabricator via cfe-commits
sberg created this revision.
sberg added reviewers: rsmith, EricWF.
sberg added a project: clang.
Herald added a subscriber: cfe-commits.

This seems to be a leftover from d30b23d6a54b3f0883914f3c2c2318a78edcbe67 
"[c++2a] P0515R3: Support for overloaded operator<=>."  (The corresponding 
llvm_unreachable in clang/lib/Sema/SemaOverload.cpp was e.g. fixed in 
0683c0e68d31d18f6e4fedb270317844a4912882 "[C++2a] Implement operator<=> CodeGen 
and ExprConstant".)
It caused compilation of recent libstdc++ trunk  to crash in -std=c++2a 
mode, hitting the llvm_unreachable.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D73637

Files:
  clang/lib/AST/StmtProfile.cpp


Index: clang/lib/AST/StmtProfile.cpp
===
--- clang/lib/AST/StmtProfile.cpp
+++ clang/lib/AST/StmtProfile.cpp
@@ -1535,8 +1535,8 @@
 return Stmt::BinaryOperatorClass;
 
   case OO_Spaceship:
-// FIXME: Update this once we support <=> expressions.
-llvm_unreachable("<=> expressions not supported yet");
+BinaryOp = BO_Cmp;
+return Stmt::BinaryOperatorClass;
 
   case OO_AmpAmp:
 BinaryOp = BO_LAnd;


Index: clang/lib/AST/StmtProfile.cpp
===
--- clang/lib/AST/StmtProfile.cpp
+++ clang/lib/AST/StmtProfile.cpp
@@ -1535,8 +1535,8 @@
 return Stmt::BinaryOperatorClass;
 
   case OO_Spaceship:
-// FIXME: Update this once we support <=> expressions.
-llvm_unreachable("<=> expressions not supported yet");
+BinaryOp = BO_Cmp;
+return Stmt::BinaryOperatorClass;
 
   case OO_AmpAmp:
 BinaryOp = BO_LAnd;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D73408: [Clang][Bundler] Add 'exclude' flag to target objects sections

2020-01-29 Thread Sergey Dmitriev via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG6e82d0dfd8df: [Clang][Bundler] Add 'exclude' flag 
to target objects sections (authored by sdmitriev).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73408

Files:
  clang/test/Driver/clang-offload-bundler.c
  clang/tools/clang-offload-bundler/ClangOffloadBundler.cpp

Index: clang/tools/clang-offload-bundler/ClangOffloadBundler.cpp
===
--- clang/tools/clang-offload-bundler/ClangOffloadBundler.cpp
+++ clang/tools/clang-offload-bundler/ClangOffloadBundler.cpp
@@ -30,6 +30,7 @@
 #include "llvm/Support/Error.h"
 #include "llvm/Support/ErrorOr.h"
 #include "llvm/Support/FileSystem.h"
+#include "llvm/Support/FileUtilities.h"
 #include "llvm/Support/MemoryBuffer.h"
 #include "llvm/Support/Path.h"
 #include "llvm/Support/Program.h"
@@ -463,6 +464,15 @@
 if (NumberOfProcessedInputs != NumberOfInputs)
   return Error::success();
 
+// We will use llvm-objcopy to add target objects sections to the output
+// fat object. These sections should have 'exclude' flag set which tells
+// link editor to remove them from linker inputs when linking executable or
+// shared library. llvm-objcopy currently does not support adding new
+// section and changing flags for the added section in one invocation, and
+// because of that we have to run it two times. First run adds sections and
+// the second changes flags.
+// TODO: change it to one run once llvm-objcopy starts supporting that.
+
 // Find llvm-objcopy in order to create the bundle binary.
 ErrorOr Objcopy = sys::findProgramByName(
 "llvm-objcopy", sys::path::parent_path(BundlerExecutable));
@@ -476,7 +486,15 @@
 // to pass down to llvm-objcopy.
 OS.close();
 
-// Compose command line for the objcopy tool.
+// Create an intermediate temporary file to save object after the first
+// llvm-objcopy run.
+SmallString<128u> IntermediateObj;
+if (std::error_code EC = sys::fs::createTemporaryFile(
+"clang-offload-bundler", "tmp", IntermediateObj))
+  return createFileError(IntermediateObj, EC);
+FileRemover IntermediateObjRemover(IntermediateObj);
+
+// Compose llvm-objcopy command line for add target objects' sections.
 BumpPtrAllocator Alloc;
 StringSaver SS{Alloc};
 SmallVector ObjcopyArgs{"llvm-objcopy"};
@@ -485,25 +503,44 @@
 OFFLOAD_BUNDLER_MAGIC_STR + TargetNames[I] +
 "=" + InputFileNames[I]));
 ObjcopyArgs.push_back(InputFileNames[HostInputIndex]);
+ObjcopyArgs.push_back(IntermediateObj);
+
+if (Error Err = executeObjcopy(*Objcopy, ObjcopyArgs))
+  return Err;
+
+// And run llvm-objcopy for the second time to update section flags.
+ObjcopyArgs.resize(1);
+for (unsigned I = 0; I < NumberOfInputs; ++I)
+  ObjcopyArgs.push_back(SS.save(Twine("--set-section-flags=") +
+OFFLOAD_BUNDLER_MAGIC_STR + TargetNames[I] +
+"=readonly,exclude"));
+ObjcopyArgs.push_back(IntermediateObj);
 ObjcopyArgs.push_back(OutputFileNames.front());
 
-// If the user asked for the commands to be printed out, we do that instead
-// of executing it.
+if (Error Err = executeObjcopy(*Objcopy, ObjcopyArgs))
+  return Err;
+
+return Error::success();
+  }
+
+  Error WriteBundle(raw_fd_ostream &OS, MemoryBuffer &Input) final {
+return Error::success();
+  }
+
+private:
+  static Error executeObjcopy(StringRef Objcopy, ArrayRef Args) {
+// If the user asked for the commands to be printed out, we do that
+// instead of executing it.
 if (PrintExternalCommands) {
-  errs() << "\"" << *Objcopy << "\"";
-  for (StringRef Arg : drop_begin(ObjcopyArgs, 1))
+  errs() << "\"" << Objcopy << "\"";
+  for (StringRef Arg : drop_begin(Args, 1))
 errs() << " \"" << Arg << "\"";
   errs() << "\n";
 } else {
-  if (sys::ExecuteAndWait(*Objcopy, ObjcopyArgs))
+  if (sys::ExecuteAndWait(Objcopy, Args))
 return createStringError(inconvertibleErrorCode(),
  "'llvm-objcopy' tool failed");
 }
-
-return Error::success();
-  }
-
-  Error WriteBundle(raw_fd_ostream &OS, MemoryBuffer &Input) final {
 return Error::success();
   }
 };
Index: clang/test/Driver/clang-offload-bundler.c
===
--- clang/test/Driver/clang-offload-bundler.c
+++ clang/test/Driver/clang-offload-bundler.c
@@ -253,7 +253,8 @@
 
 // RUN: clang-offload-bundler -type=o -targets=host-%itanium_abi_triple,openmp-powerpc64le-ibm-linux-gnu,openmp-x86_64-pc-linux-gnu -inputs=%t.o,%t.tgt1,%t.tgt2 -outputs=%t.bundle3.o -### 2>&1 \
 // RUN: | FileChec

[clang] 6e82d0d - [Clang][Bundler] Add 'exclude' flag to target objects sections

2020-01-29 Thread Sergey Dmitriev via cfe-commits

Author: Sergey Dmitriev
Date: 2020-01-29T09:00:45-08:00
New Revision: 6e82d0dfd8dfaebc3985e73740a020b273a2dd31

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

LOG: [Clang][Bundler] Add 'exclude' flag to target objects sections

Summary: This flag tells link editor to exclude section from linker inputs when 
linking executable or shared library.

Reviewers: ABataev, alexshap, jdoerfert

Reviewed By: ABataev

Subscribers: cfe-commits

Tags: #clang

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

Added: 


Modified: 
clang/test/Driver/clang-offload-bundler.c
clang/tools/clang-offload-bundler/ClangOffloadBundler.cpp

Removed: 




diff  --git a/clang/test/Driver/clang-offload-bundler.c 
b/clang/test/Driver/clang-offload-bundler.c
index 35c327c56b3b..99d638cb889b 100644
--- a/clang/test/Driver/clang-offload-bundler.c
+++ b/clang/test/Driver/clang-offload-bundler.c
@@ -253,7 +253,8 @@
 
 // RUN: clang-offload-bundler -type=o 
-targets=host-%itanium_abi_triple,openmp-powerpc64le-ibm-linux-gnu,openmp-x86_64-pc-linux-gnu
 -inputs=%t.o,%t.tgt1,%t.tgt2 -outputs=%t.bundle3.o -### 2>&1 \
 // RUN: | FileCheck %s -DHOST=%itanium_abi_triple -DINOBJ1=%t.o 
-DINOBJ2=%t.tgt1 -DINOBJ3=%t.tgt2 -DOUTOBJ=%t.bundle3.o --check-prefix 
CK-OBJ-CMD
-// CK-OBJ-CMD: llvm-objcopy{{(.exe)?}}" 
"--add-section=__CLANG_OFFLOAD_BUNDLE__host-[[HOST]]=[[INOBJ1]]" 
"--add-section=__CLANG_OFFLOAD_BUNDLE__openmp-powerpc64le-ibm-linux-gnu=[[INOBJ2]]"
 "--add-section=__CLANG_OFFLOAD_BUNDLE__openmp-x86_64-pc-linux-gnu=[[INOBJ3]]" 
"[[INOBJ1]]" "[[OUTOBJ]]"
+// CK-OBJ-CMD: llvm-objcopy{{(.exe)?}}" 
"--add-section=__CLANG_OFFLOAD_BUNDLE__host-[[HOST]]=[[INOBJ1]]" 
"--add-section=__CLANG_OFFLOAD_BUNDLE__openmp-powerpc64le-ibm-linux-gnu=[[INOBJ2]]"
 "--add-section=__CLANG_OFFLOAD_BUNDLE__openmp-x86_64-pc-linux-gnu=[[INOBJ3]]" 
"[[INOBJ1]]" "[[TEMPOBJ:.*]]"
+// CK-OBJ-CMD: llvm-objcopy{{(.exe)?}}" 
"--set-section-flags=__CLANG_OFFLOAD_BUNDLE__host-[[HOST]]=readonly,exclude" 
"--set-section-flags=__CLANG_OFFLOAD_BUNDLE__openmp-powerpc64le-ibm-linux-gnu=readonly,exclude"
 
"--set-section-flags=__CLANG_OFFLOAD_BUNDLE__openmp-x86_64-pc-linux-gnu=readonly,exclude"
 "[[TEMPOBJ]]" "[[OUTOBJ]]"
 
 // RUN: clang-offload-bundler -type=o 
-targets=host-%itanium_abi_triple,openmp-powerpc64le-ibm-linux-gnu,openmp-x86_64-pc-linux-gnu
 -inputs=%t.o,%t.tgt1,%t.tgt2 -outputs=%t.bundle3.o
 // RUN: clang-offload-bundler -type=o 
-targets=host-%itanium_abi_triple,openmp-powerpc64le-ibm-linux-gnu,openmp-x86_64-pc-linux-gnu
 -outputs=%t.res.o,%t.res.tgt1,%t.res.tgt2 -inputs=%t.bundle3.o -unbundle

diff  --git a/clang/tools/clang-offload-bundler/ClangOffloadBundler.cpp 
b/clang/tools/clang-offload-bundler/ClangOffloadBundler.cpp
index a75d2a630cf4..c215cff303e7 100644
--- a/clang/tools/clang-offload-bundler/ClangOffloadBundler.cpp
+++ b/clang/tools/clang-offload-bundler/ClangOffloadBundler.cpp
@@ -30,6 +30,7 @@
 #include "llvm/Support/Error.h"
 #include "llvm/Support/ErrorOr.h"
 #include "llvm/Support/FileSystem.h"
+#include "llvm/Support/FileUtilities.h"
 #include "llvm/Support/MemoryBuffer.h"
 #include "llvm/Support/Path.h"
 #include "llvm/Support/Program.h"
@@ -463,6 +464,15 @@ class ObjectFileHandler final : public FileHandler {
 if (NumberOfProcessedInputs != NumberOfInputs)
   return Error::success();
 
+// We will use llvm-objcopy to add target objects sections to the output
+// fat object. These sections should have 'exclude' flag set which tells
+// link editor to remove them from linker inputs when linking executable or
+// shared library. llvm-objcopy currently does not support adding new
+// section and changing flags for the added section in one invocation, and
+// because of that we have to run it two times. First run adds sections and
+// the second changes flags.
+// TODO: change it to one run once llvm-objcopy starts supporting that.
+
 // Find llvm-objcopy in order to create the bundle binary.
 ErrorOr Objcopy = sys::findProgramByName(
 "llvm-objcopy", sys::path::parent_path(BundlerExecutable));
@@ -476,7 +486,15 @@ class ObjectFileHandler final : public FileHandler {
 // to pass down to llvm-objcopy.
 OS.close();
 
-// Compose command line for the objcopy tool.
+// Create an intermediate temporary file to save object after the first
+// llvm-objcopy run.
+SmallString<128u> IntermediateObj;
+if (std::error_code EC = sys::fs::createTemporaryFile(
+"clang-offload-bundler", "tmp", IntermediateObj))
+  return createFileError(IntermediateObj, EC);
+FileRemover IntermediateObjRemover(IntermediateObj);
+
+// Compose llvm-objcopy command line for add target objects' sections.
 BumpPtrAllocator Alloc;
 StringSav

[PATCH] D73636: [AArch64][SVE] SVE2 intrinsics for complex integer arithmetic

2020-01-29 Thread Kerry McLaughlin via Phabricator via cfe-commits
kmclaughlin created this revision.
kmclaughlin added reviewers: sdesmalen, dancgr, efriedma, cameron.mcinally, 
c-rhodes.
Herald added subscribers: psnobl, rkruppe, hiraditya, kristof.beyls, tschuett.
Herald added a reviewer: rengolin.
Herald added a project: LLVM.

Adds the following SVE2 intrinsics:

- cadd & sqcadd
- cmla & sqrdcmlah
- sqdmlalbt & sqdmlalbt
- saddlbt, ssublbt & ssubltb


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D73636

Files:
  llvm/include/llvm/IR/IntrinsicsAArch64.td
  llvm/lib/Target/AArch64/AArch64SVEInstrInfo.td
  llvm/lib/Target/AArch64/SVEInstrFormats.td
  llvm/test/CodeGen/AArch64/sve2-intrinsics-uniform-complex-arith.ll
  llvm/test/CodeGen/AArch64/sve2-intrinsics-widening-complex-int-arith.ll

Index: llvm/test/CodeGen/AArch64/sve2-intrinsics-widening-complex-int-arith.ll
===
--- /dev/null
+++ llvm/test/CodeGen/AArch64/sve2-intrinsics-widening-complex-int-arith.ll
@@ -0,0 +1,182 @@
+; RUN: llc -mtriple=aarch64-linux-gnu -mattr=+sve2 < %s | FileCheck %s
+
+;
+; SADDLBT
+;
+
+define  @saddlbt_b( %a,  %b) {
+; CHECK-LABEL: saddlbt_b:
+; CHECK: saddlbt z0.h, z0.b, z1.b
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.saddlbt.nxv8i16( %a,
+   %b)
+  ret  %out
+}
+
+define  @saddlbt_h( %a,  %b) {
+; CHECK-LABEL: saddlbt_h:
+; CHECK: saddlbt z0.s, z0.h, z1.h
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.saddlbt.nxv4i32( %a,
+   %b)
+  ret  %out
+}
+
+define  @saddlbt_s( %a,  %b) {
+; CHECK-LABEL: saddlbt_s:
+; CHECK: saddlbt z0.d, z0.s, z1.s
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.saddlbt.nxv2i64( %a,
+   %b)
+  ret  %out
+}
+
+;
+; SQDMLALBT
+;
+
+define  @sqdmlalbt_b( %a,  %b,  %c) {
+; CHECK-LABEL: sqdmlalbt_b:
+; CHECK: sqdmlalbt z0.h, z1.b, z2.b
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.sqdmlalbt.nxv8i16( %a,
+ %b,
+ %c)
+  ret  %out
+}
+
+define  @sqdmlalbt_h( %a,  %b,  %c) {
+; CHECK-LABEL: sqdmlalbt_h:
+; CHECK: sqdmlalbt z0.s, z1.h, z2.h
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.sqdmlalbt.nxv4i32( %a,
+ %b,
+ %c)
+  ret  %out
+}
+
+define  @sqdmlalbt_s( %a,  %b,  %c) {
+; CHECK-LABEL: sqdmlalbt_s:
+; CHECK: sqdmlalbt z0.d, z1.s, z2.s
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.sqdmlalbt.nxv2i64( %a,
+ %b,
+ %c)
+  ret  %out
+}
+
+;
+; SQDMLSLBT
+;
+
+define  @sqdmlslbt_b( %a,  %b,  %c) {
+; CHECK-LABEL: sqdmlslbt_b:
+; CHECK: sqdmlslbt z0.h, z1.b, z2.b
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.sqdmlslbt.nxv8i16( %a,
+ %b,
+ %c)
+  ret  %out
+}
+
+define  @sqdmlslbt_h( %a,  %b,  %c) {
+; CHECK-LABEL: sqdmlslbt_h:
+; CHECK: sqdmlslbt z0.s, z1.h, z2.h
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.sqdmlslbt.nxv4i32( %a,
+ %b,
+ %c)
+  ret  %out
+}
+
+define  @sqdmlslbt_s( %a,  %b,  %c) {
+; CHECK-LABEL: sqdmlslbt_s:
+; CHECK: sqdmlslbt z0.d, z1.s, z2.s
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.sqdmlslbt.nxv2i64( %a,
+ %b,
+ %c)
+  ret  %out
+}
+
+;
+; SSUBLBT
+;
+
+define  @ssublbt_b( %a,  %b) {
+; CHECK-LABEL: ssublbt_b:
+; CHECK: ssublbt z0.h, z0.b, z1.b
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.ssublbt.nxv8i16( %a,
+   %b)
+  ret  %out
+}
+
+define  @ssublbt_h( %a,  %b) {
+; CHECK-LABEL: ssublbt_h:
+; CHECK: ssublbt z0.s, z0.h, z1.h
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.ssublbt.nxv4i32( %a,
+   %b)
+  ret  %out
+}
+
+define  @ssublbt_s( %a,  %b) {
+; CHECK-LABEL: ssublbt_s:
+; CHECK: ssublbt z0.d, z0.s, z1.s
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.ssublbt.nxv2i64( %a,
+   %b)
+  ret  %out
+}
+
+;
+; SSUBLTB
+;
+
+define  @ssubltb_b( %a,  %b) {
+; CHECK-LABEL: ssubltb_b:
+; CHECK: ssubltb z0.h, z0.b, z1.b
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.ssubltb.nxv8i16( %a,
+   %b)
+  ret  %out
+}
+
+def

[PATCH] D72222: [Driver][CodeGen] Add -fpatchable-function-entry=N[,0]

2020-01-29 Thread Mark Rutland via Phabricator via cfe-commits
mrutland added a comment.

In D7#1846796 , @mrutland wrote:

> In D7#1839207 , @MaskRay wrote:
>
> > I shall also mention that we are essentially making decisions for x86 
> > people's endbr32/endbr64. I hope you can engage in x86 maintainers. Clang's 
> > current layout is recorded at D73071 .
>
>
> That's a good point w.r.t. x86; I will get in touch with the people working 
> on ftrace and live-patching there


I spoke with Steven Rostedt (ftrace maintainer), and Josh Poimboeuf 
(livepatching maintainer) in the OFTC/#linux-rt IRC channel. Today x86 uses 
`-mfentry`, and they have no reason to move to `-fpatchable-function-entry` so 
long as the `ENDBR32/ENDBR64` instructions compose nicely with `-mfentry`.

Given that, I don't think x86 kernel folk care either way.

On the GCC side I was under the impression that x86 would go the same way as 
arm64, per https://gcc.gnu.org/bugzilla/show_bug.cgi?id=92424#c4

There's a GCC ticket for x86: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93492

Thanks,
Mark.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D7



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


[PATCH] D73628: [clangd] Log directory when a CDB is loaded

2020-01-29 Thread pre-merge checks [bot] via Phabricator via cfe-commits
merge_guards_bot added a comment.

{icon check-circle color=green} Unit tests: pass. 62284 tests passed, 0 failed 
and 831 were skipped.

{icon check-circle color=green} clang-tidy: pass.

{icon check-circle color=green} clang-format: pass.

Build artifacts 
: 
diff.json 
,
 clang-tidy.txt 
,
 clang-format.patch 
,
 CMakeCache.txt 
,
 console-log.txt 
,
 test-results.xml 


//Pre-merge checks is in beta. Report issue 
.
 Please join beta  or enable 
it for your project 
.//


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73628



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


[PATCH] D72829: Implement -fsemantic-interposition

2020-01-29 Thread Sean Fertile via Phabricator via cfe-commits
sfertile added a comment.

In D72829#1846353 , @arichardson wrote:

> As this is user-facing documentation I feel like there should be a slightly 
> longer explaning what the option does.


+1 on this, otherwise LGTM. Thanks for implementing this!




Comment at: llvm/include/llvm/IR/GlobalValue.h:426
   /// Return true if this global's definition can be substituted with an
   /// *arbitrary* definition at link time.  We cannot do any IPO or inlinining
   /// across interposable call edges, since the callee can be replaced with

Minor nit: We have extended this to now determine if a definition can be 
substituted with an arbitrary definition at link time or load time. 

I would suggest changing the first `link time` to `link time or load time`, and 
changing
`since the callee can be replaced with something arbitrary at link time.` to 
`since the callee can be replaced with something arbitrary.`,


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72829



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


[PATCH] D73408: [Clang][Bundler] Add 'exclude' flag to target objects sections

2020-01-29 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev accepted this revision.
ABataev added a comment.
This revision is now accepted and ready to land.

LG


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

https://reviews.llvm.org/D73408



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


[PATCH] D73408: [Clang][Bundler] Add 'exclude' flag to target objects sections

2020-01-29 Thread Sergey Dmitriev via Phabricator via cfe-commits
sdmitriev added a comment.

Any additional comments?


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

https://reviews.llvm.org/D73408



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


[PATCH] D73300: [clang-tidy] Add library for clang-tidy main function

2020-01-29 Thread Dmitry Polukhin via Phabricator via cfe-commits
DmitryPolukhin added a comment.

@thakis I'm sorry sorry if it was not clear. Please let me know if you still 
prefer to have separate directory for clangTidyMain to have only one target per 
CMakeLists.txt.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73300



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


[PATCH] D72829: Implement -fsemantic-interposition

2020-01-29 Thread pre-merge checks [bot] via Phabricator via cfe-commits
merge_guards_bot added a comment.

{icon check-circle color=green} Unit tests: pass. 62300 tests passed, 0 failed 
and 837 were skipped.

{icon check-circle color=green} clang-tidy: pass.

{icon check-circle color=green} clang-format: pass.

Build artifacts 
: 
diff.json 
,
 clang-tidy.txt 
,
 clang-format.patch 
,
 CMakeCache.txt 
,
 console-log.txt 
,
 test-results.xml 


//Pre-merge checks is in beta. Report issue 
.
 Please join beta  or enable 
it for your project 
.//


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72829



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


[PATCH] D73242: [WPD/LowerTypeTests] Delay lowering/removal of type tests until after ICP

2020-01-29 Thread Eugene Leviant via Phabricator via cfe-commits
evgeny777 added a comment.

> This is an enabler for upcoming enhancements to indirect call promotion, for 
> example streamlined promotion guard sequences that compare against vtable 
> address instead of the target function

Can you please describe the whole approach in more detail? At the moment ICP is 
capable to do (a sort of) devirtualization is replacing indirect vtbl call with 
sequence of function address comparisons and direct calls.
Are you going to speedup this by means of comparing vtable pointers instead of 
function pointers (thus eliminating a single load per each vtbl call) or there 
is also something else in mind? If that's true, what's the next
step? Make ICP pass analyze type test intrinsics?




Comment at: llvm/lib/Transforms/IPO/WholeProgramDevirt.cpp:1660
+cast(CI->getArgOperand(1))->getMetadata();
 // If we found any, add them to CallSlots.
 if (!Assumes.empty()) {

This change seems to be unrelated


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73242



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


[PATCH] D73628: [clangd] Log directory when a CDB is loaded

2020-01-29 Thread Sam McCall via Phabricator via cfe-commits
sammccall accepted this revision.
sammccall added inline comments.
This revision is now accepted and ready to land.



Comment at: clang-tools-extra/clangd/GlobalCompilationDatabase.cpp:122
+if (Entry.CDB)
+  vlog("Loaded CDB from {0}", Dir);
   }

consider "Loaded compile commands..." or "Loading compile commands..." or 
"Loaded compilation database...".
People who are only dimly aware of the existence of `compile_commands.json` 
need a bit more context here.



Comment at: clang-tools-extra/clangd/GlobalCompilationDatabase.cpp:122
+if (Entry.CDB)
+  vlog("Loaded CDB from {0}", Dir);
   }

sammccall wrote:
> consider "Loaded compile commands..." or "Loading compile commands..." or 
> "Loaded compilation database...".
> People who are only dimly aware of the existence of `compile_commands.json` 
> need a bit more context here.
this is significant and rare, probably OK to log rather than vlog


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73628



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


[clang-tools-extra] 01213f9 - [clang-tidy] Initialize token before handing it to the lexer

2020-01-29 Thread Benjamin Kramer via cfe-commits

Author: Benjamin Kramer
Date: 2020-01-29T16:48:57+01:00
New Revision: 01213f90700dbb98a0dbcc01da8fdb89f6db5617

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

LOG: [clang-tidy] Initialize token before handing it to the lexer

Found by msan.

Added: 


Modified: 
clang-tools-extra/clang-tidy/modernize/UseTrailingReturnTypeCheck.cpp

Removed: 




diff  --git 
a/clang-tools-extra/clang-tidy/modernize/UseTrailingReturnTypeCheck.cpp 
b/clang-tools-extra/clang-tidy/modernize/UseTrailingReturnTypeCheck.cpp
index 71cb0300ec62..41b7e1739ee0 100644
--- a/clang-tools-extra/clang-tidy/modernize/UseTrailingReturnTypeCheck.cpp
+++ b/clang-tools-extra/clang-tidy/modernize/UseTrailingReturnTypeCheck.cpp
@@ -173,6 +173,7 @@ classifyToken(const FunctionDecl &F, Preprocessor &PP, 
Token Tok) {
   bool ContainsSomethingElse = false;
 
   Token End;
+  End.startToken();
   End.setKind(tok::eof);
   SmallVector Stream{Tok, End};
 



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


[PATCH] D73624: [clangd][vscode] Get rid of the deprecated vscode module in the extension.

2020-01-29 Thread pre-merge checks [bot] via Phabricator via cfe-commits
merge_guards_bot added a comment.

{icon times-circle color=red} Unit tests: fail. 62285 tests passed, 2 failed 
and 831 were skipped.

  failed: 
libc++.std/thread/thread_mutex/thread_mutex_requirements/thread_mutex_requirements_mutex/thread_mutex_recursive/lock.pass.cpp
  failed: 
libc++.std/thread/thread_mutex/thread_mutex_requirements/thread_mutex_requirements_mutex/thread_mutex_recursive/try_lock.pass.cpp

{icon check-circle color=green} clang-tidy: pass.

{icon check-circle color=green} clang-format: pass.

Build artifacts 
: 
diff.json 
,
 clang-tidy.txt 
,
 clang-format.patch 
,
 CMakeCache.txt 
,
 console-log.txt 
,
 test-results.xml 


//Pre-merge checks is in beta. Report issue 
.
 Please join beta  or enable 
it for your project 
.//


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73624



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


[PATCH] D73629: [analyzer] vfork checker: allow execve after vfork

2020-01-29 Thread Jan Včelák via Phabricator via cfe-commits
janvcelak created this revision.
janvcelak added a reviewer: dcoughlin.
Herald added subscribers: cfe-commits, Charusso, dkrupp, donat.nagy, Szelethus, 
mikhail.ramalho, a.sidorin, szepet, baloghadamsoftware, xazax.hun.
Herald added a project: clang.

`execve` is missing in the list of functions that are allowed after `vfork()`. 
As a result, clang analyzer reports the following false positive:

  #include 
  
  int main(int argc, char *argv[])
  {
char *a[] = {"true", NULL};
char *e[] = {NULL};
if (vfork() == 0) {
execve("/bin/true", a, e);
_exit(1);
}
return 0;
  }



  $ scan-build clang -Wall -c repro.c  
  scan-build: Using '/usr/bin/clang-9' for static analysis
  repro.c:7:6: warning: Call to function 'vfork' is insecure as it can lead to 
denial of service situations in the parent process. Replace calls to vfork with 
calls to the safer 'posix_spawn' function
  if (vfork() == 0) {
  ^
  repro.c:8:3: warning: This function call is prohibited after a successful 
vfork
  execve("/bin/true", a, e);
  ^
  2 warnings generated.
  scan-build: 2 bugs found.
  scan-build: Run 'scan-view /tmp/scan-build-2020-01-29-162705-3770808-1' to 
examine bug reports.

The list of exec functions in the code is take from the `exec(3)` man page 
which are just a fronted for `execve(2)`. Quoting the manual page:

> The  exec() family of functions replaces the current process image with a new 
> process image.  The functions escribed in this manual page are front-ends for 
> execve(2).  (See the manual page for execve(2) for further details about the 
> replacement of the current process image.)


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D73629

Files:
  clang/lib/StaticAnalyzer/Checkers/VforkChecker.cpp


Index: clang/lib/StaticAnalyzer/Checkers/VforkChecker.cpp
===
--- clang/lib/StaticAnalyzer/Checkers/VforkChecker.cpp
+++ clang/lib/StaticAnalyzer/Checkers/VforkChecker.cpp
@@ -106,6 +106,7 @@
   "execv",
   "execvp",
   "execvpe",
+  "execve",
   nullptr
 };
 


Index: clang/lib/StaticAnalyzer/Checkers/VforkChecker.cpp
===
--- clang/lib/StaticAnalyzer/Checkers/VforkChecker.cpp
+++ clang/lib/StaticAnalyzer/Checkers/VforkChecker.cpp
@@ -106,6 +106,7 @@
   "execv",
   "execvp",
   "execvpe",
+  "execve",
   nullptr
 };
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D73628: [clangd] Log directory when a CDB is loaded

2020-01-29 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet created this revision.
kadircet added a reviewer: sammccall.
Herald added subscribers: cfe-commits, usaxena95, arphaman, jkorous, MaskRay, 
ilya-biryukov.
Herald added a project: clang.

Fixes https://github.com/clangd/clangd/issues/268


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D73628

Files:
  clang-tools-extra/clangd/GlobalCompilationDatabase.cpp


Index: clang-tools-extra/clangd/GlobalCompilationDatabase.cpp
===
--- clang-tools-extra/clangd/GlobalCompilationDatabase.cpp
+++ clang-tools-extra/clangd/GlobalCompilationDatabase.cpp
@@ -115,9 +115,11 @@
   auto R = CompilationDatabases.try_emplace(Key);
   if (R.second) { // Cache miss, try to load CDB.
 CachedCDB &Entry = R.first->second;
-std::string Error = "";
+std::string Error;
 Entry.CDB = tooling::CompilationDatabase::loadFromDirectory(Dir, Error);
 Entry.Path = std::string(Dir);
+if (Entry.CDB)
+  vlog("Loaded CDB from {0}", Dir);
   }
   return R.first->second;
 }


Index: clang-tools-extra/clangd/GlobalCompilationDatabase.cpp
===
--- clang-tools-extra/clangd/GlobalCompilationDatabase.cpp
+++ clang-tools-extra/clangd/GlobalCompilationDatabase.cpp
@@ -115,9 +115,11 @@
   auto R = CompilationDatabases.try_emplace(Key);
   if (R.second) { // Cache miss, try to load CDB.
 CachedCDB &Entry = R.first->second;
-std::string Error = "";
+std::string Error;
 Entry.CDB = tooling::CompilationDatabase::loadFromDirectory(Dir, Error);
 Entry.Path = std::string(Dir);
+if (Entry.CDB)
+  vlog("Loaded CDB from {0}", Dir);
   }
   return R.first->second;
 }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D73543: [clang] Add support for __builtin_memcpy_inline

2020-01-29 Thread Guillaume Chatelet via Phabricator via cfe-commits
gchatelet added inline comments.



Comment at: clang/docs/LanguageExtensions.rst:2259
+``__builtin_memcpy_inline(dst, src, size)`` is identical to
+``__builtin_memcpy(dst, src, size)`` expect that the generated code is
+guaranteed not to call any external functions. See [LLVM IR 
‘llvm.memcpy.inline’

arichardson wrote:
> Typo: except
Thx :)



Comment at: clang/test/Sema/builtins-memcpy-inline.c:23
+}
+
+void test_memcpy_inline_null_buffer_is_ok_if_size_is_zero(void *ptr) {

arichardson wrote:
> Size can only be a constant right? Should there be a test for the error 
> reported in that case?
Thx it caught a bug indeed :)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73543



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


[PATCH] D72326: [clang-format] Rebased on master: Add option to specify explicit config file

2020-01-29 Thread Thibault North via Phabricator via cfe-commits
tnorth updated this revision to Diff 241155.
tnorth added a comment.

- Add release notes
- Update ClangFormat.rst and ClangFormatStyleOption.rst


Repository:
  rC Clang

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

https://reviews.llvm.org/D72326

Files:
  docs/ClangFormat.rst
  docs/ClangFormatStyleOptions.rst
  docs/ReleaseNotes.rst
  include/clang/Format/Format.h
  lib/Format/Format.cpp
  unittests/Format/FormatTest.cpp

Index: unittests/Format/FormatTest.cpp
===
--- unittests/Format/FormatTest.cpp
+++ unittests/Format/FormatTest.cpp
@@ -14350,6 +14350,61 @@
   auto StyleTd = getStyle("file", "x.td", "llvm", "", &FS);
   ASSERT_TRUE((bool)StyleTd);
   ASSERT_EQ(*StyleTd, getLLVMStyle(FormatStyle::LK_TableGen));
+
+  // Test 9: explicit format file in parent directory.
+  ASSERT_TRUE(
+  FS.addFile("/e/.clang-format", 0,
+ llvm::MemoryBuffer::getMemBuffer("BasedOnStyle: LLVM")));
+  ASSERT_TRUE(
+  FS.addFile("/e/explicit.clang-format", 0,
+ llvm::MemoryBuffer::getMemBuffer("BasedOnStyle: Google")));
+  ASSERT_TRUE(FS.addFile("/e/sub/sub/sub/test.cpp", 0,
+ llvm::MemoryBuffer::getMemBuffer("int i;")));
+  auto Style8 = getStyle("file:/e/explicit.clang-format",
+ "/e/sub/sub/sub/test.cpp", "LLVM", "", &FS);
+  ASSERT_TRUE((bool)Style8);
+  ASSERT_EQ(*Style8, getGoogleStyle());
+
+  // Test 10: relative pah to a format file
+  ASSERT_TRUE(
+  FS.addFile("../../e/explicit.clang-format", 0,
+ llvm::MemoryBuffer::getMemBuffer("BasedOnStyle: Google")));
+  auto Style9 = getStyle("file:../../e/explicit.clang-format",
+ "/e/sub/sub/sub/test.cpp", "LLVM", "", &FS);
+  ASSERT_TRUE((bool)Style9);
+  ASSERT_EQ(*Style9, getGoogleStyle());
+
+  // Test 11: missing explicit format file
+  auto Style10 = getStyle("file:/e/missing.clang-format",
+  "/e/sub/sub/sub/test.cpp", "LLVM", "", &FS);
+  ASSERT_FALSE((bool)Style10);
+  llvm::consumeError(Style10.takeError());
+
+  // Test 12: format file from the filesystem
+  SmallString<128> FormatFilePath;
+  std::error_code ECF = llvm::sys::fs::createTemporaryFile(
+  "FormatFileTest", "tpl", FormatFilePath);
+  EXPECT_FALSE((bool)ECF);
+  llvm::raw_fd_ostream FormatFileTest(FormatFilePath, ECF);
+  EXPECT_FALSE((bool)ECF);
+  FormatFileTest << "BasedOnStyle: Google\n";
+  FormatFileTest.close();
+
+  SmallString<128> TestFilePath;
+  std::error_code ECT =
+  llvm::sys::fs::createTemporaryFile("CodeFileTest", "cc", TestFilePath);
+  EXPECT_FALSE((bool)ECT);
+  llvm::raw_fd_ostream CodeFileTest(TestFilePath, ECT);
+  CodeFileTest << "int i;\n";
+  CodeFileTest.close();
+
+  std::string format_file_arg = std::string("file:") + FormatFilePath.c_str();
+  auto Style11 = getStyle(format_file_arg, TestFilePath, "LLVM", "", nullptr);
+
+  llvm::sys::fs::remove(FormatFilePath.c_str());
+  llvm::sys::fs::remove(TestFilePath.c_str());
+  ASSERT_TRUE((bool)Style11);
+  ASSERT_EQ(*Style11, getGoogleStyle());
 }
 
 TEST_F(ReplacementTest, FormatCodeAfterReplacements) {
Index: lib/Format/Format.cpp
===
--- lib/Format/Format.cpp
+++ lib/Format/Format.cpp
@@ -2519,6 +2519,8 @@
 ".clang-format file located in one of the parent\n"
 "directories of the source file (or current\n"
 "directory for stdin).\n"
+"Use -style=file: to explicitly specify"
+"the configuration file.\n"
 "Use -style=\"{key: value, ...}\" to set specific\n"
 "parameters, e.g.:\n"
 "  -style=\"{BasedOnStyle: llvm, IndentWidth: 8}\"";
@@ -2568,6 +2570,26 @@
 
 const char *DefaultFallbackStyle = "LLVM";
 
+/// Attempts to load a format file
+llvm::Expected LoadConfigFile(StringRef ConfigFile,
+   llvm::vfs::FileSystem *FS) {
+  llvm::ErrorOr> Text =
+  FS->getBufferForFile(ConfigFile.str());
+  std::error_code ReadFileError = Text.getError();
+  if (ReadFileError) {
+return make_string_error("Error reading config file " +
+ ReadFileError.message());
+  }
+  FormatStyle Style = getLLVMStyle();
+  std::error_code ParseFileError =
+  parseConfiguration(Text.get()->getBuffer(), &Style);
+  if (ParseFileError != ParseError::Success) {
+return make_string_error("Error parsing config file " +
+ ParseFileError.message());
+  }
+  return Style;
+}
+
 llvm::Expected getStyle(StringRef StyleName, StringRef FileName,
  StringRef FallbackStyleName,
  StringRef Code,
@@ -2588,6 +2610,12 @@
 return Style;
   }
 
+  // User provided clang-format file using -style=file:/path/to/format/file
+  // Check for explicit config filename
+  if (StyleName.startswith_lower("file:")) {
+return LoadConfigFile(StyleName.substr(

[PATCH] D72326: [clang-format] Rebased on master: Add option to specify explicit config file

2020-01-29 Thread Thibault North via Phabricator via cfe-commits
tnorth added a comment.

In D72326#1845342 , @MyDeveloperDay 
wrote:

> Nit: please add a release note and regenerate the ClangFormatStyleOptions.rst 
> (if there are any changes because you modified Format.h).


Hmm, I tried to run docs/tools/dump_format_style.py, but it fails at two 
locations (once because a comment in Format.h has two slashes instead of 3, one 
because of an empty line). After fixing those, it seems that the generated file 
contains less information than the commited one. This file was probably updated 
manually as well. Therefore I also did in the updated diff... one should 
probably fix this separately.
Release note + ClangFormat.rst files update in the diff as well.


Repository:
  rC Clang

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

https://reviews.llvm.org/D72326



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


[PATCH] D73543: [clang] Add support for __builtin_memcpy_inline

2020-01-29 Thread Guillaume Chatelet via Phabricator via cfe-commits
gchatelet updated this revision to Diff 241158.
gchatelet marked 4 inline comments as done.
gchatelet added a comment.

- Address comments


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73543

Files:
  clang/docs/LanguageExtensions.rst
  clang/include/clang/Basic/Builtins.def
  clang/lib/CodeGen/CGBuilder.h
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/lib/Sema/SemaChecking.cpp
  clang/test/CodeGen/builtins-memcpy-inline.c
  clang/test/Sema/builtins-memcpy-inline.c
  llvm/include/llvm/IR/IRBuilder.h
  llvm/lib/IR/IRBuilder.cpp

Index: llvm/lib/IR/IRBuilder.cpp
===
--- llvm/lib/IR/IRBuilder.cpp
+++ llvm/lib/IR/IRBuilder.cpp
@@ -200,6 +200,30 @@
   return CI;
 }
 
+CallInst *IRBuilderBase::CreateMemCpyInline(Value *Dst, MaybeAlign DstAlign,
+Value *Src, MaybeAlign SrcAlign,
+Value *Size) {
+  Dst = getCastedInt8PtrValue(Dst);
+  Src = getCastedInt8PtrValue(Src);
+  Value *IsVolatile = getInt1(false);
+
+  Value *Ops[] = {Dst, Src, Size, IsVolatile};
+  Type *Tys[] = {Dst->getType(), Src->getType(), Size->getType()};
+  Function *F = BB->getParent();
+  Module *M = F->getParent();
+  Function *TheFn = Intrinsic::getDeclaration(M, Intrinsic::memcpy_inline, Tys);
+
+  CallInst *CI = createCallHelper(TheFn, Ops, this);
+
+  auto *MCI = cast(CI);
+  if (DstAlign)
+MCI->setDestAlignment(*DstAlign);
+  if (SrcAlign)
+MCI->setSourceAlignment(*SrcAlign);
+
+  return CI;
+}
+
 CallInst *IRBuilderBase::CreateElementUnorderedAtomicMemCpy(
 Value *Dst, Align DstAlign, Value *Src, Align SrcAlign, Value *Size,
 uint32_t ElementSize, MDNode *TBAATag, MDNode *TBAAStructTag,
Index: llvm/include/llvm/IR/IRBuilder.h
===
--- llvm/include/llvm/IR/IRBuilder.h
+++ llvm/include/llvm/IR/IRBuilder.h
@@ -560,6 +560,9 @@
  MDNode *ScopeTag = nullptr,
  MDNode *NoAliasTag = nullptr);
 
+  CallInst *CreateMemCpyInline(Value *Dst, MaybeAlign DstAlign, Value *Src,
+   MaybeAlign SrcAlign, Value *Size);
+
   /// Create and insert an element unordered-atomic memcpy between the
   /// specified pointers.
   ///
Index: clang/test/Sema/builtins-memcpy-inline.c
===
--- /dev/null
+++ clang/test/Sema/builtins-memcpy-inline.c
@@ -0,0 +1,32 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+#define NULL ((char *)0)
+
+#if __has_feature(__builtin_memcpy_inline)
+#warning defined as expected
+// expected-warning@-1 {{defined as expected}}
+#endif
+
+void test_memcpy_inline_null_src(void *ptr) {
+  __builtin_memcpy_inline(ptr, NULL, 4); // expected-warning {{null passed to a callee that requires a non-null argument}}
+}
+
+void test_memcpy_inline_null_dst(void *ptr) {
+  __builtin_memcpy_inline(NULL, ptr, 4); // expected-warning {{null passed to a callee that requires a non-null argument}}
+}
+
+void test_memcpy_inline_null_buffers() {
+  __builtin_memcpy_inline(NULL, NULL, 4);
+  // expected-warning@-1 {{null passed to a callee that requires a non-null argument}}
+  // expected-warning@-2 {{null passed to a callee that requires a non-null argument}}
+}
+
+void test_memcpy_inline_null_buffer_is_ok_if_size_is_zero(void *ptr) {
+  __builtin_memcpy_inline(ptr, NULL, /*size */ 0);
+  __builtin_memcpy_inline(NULL, ptr, /*size */ 0);
+  __builtin_memcpy_inline(NULL, NULL, /*size */ 0);
+}
+
+void test_memcpy_inline_non_constant_size(void *dst, const void *src, unsigned size) {
+  __builtin_memcpy_inline(dst, src, size); // expected-error {{expression is not an integer constant expression}}
+}
Index: clang/test/CodeGen/builtins-memcpy-inline.c
===
--- /dev/null
+++ clang/test/CodeGen/builtins-memcpy-inline.c
@@ -0,0 +1,26 @@
+// REQUIRES: x86-registered-target
+// RUN: %clang_cc1 -triple x86_64-unknown-linux -emit-llvm %s -o - | FileCheck %s
+
+// CHECK-LABEL: define void @test_memcpy_inline_0(i8* %dst, i8* %src)
+void test_memcpy_inline_0(void *dst, const void *src) {
+  // CHECK:   call void @llvm.memcpy.inline.p0i8.p0i8.i64(i8* align 1 %0, i8* align 1 %1, i64 0, i1 false)
+  __builtin_memcpy_inline(dst, src, 0);
+}
+
+// CHECK-LABEL: define void @test_memcpy_inline_1(i8* %dst, i8* %src)
+void test_memcpy_inline_1(void *dst, const void *src) {
+  // CHECK:   call void @llvm.memcpy.inline.p0i8.p0i8.i64(i8* align 1 %0, i8* align 1 %1, i64 1, i1 false)
+  __builtin_memcpy_inline(dst, src, 1);
+}
+
+// CHECK-LABEL: define void @test_memcpy_inline_4(i8* %dst, i8* %src)
+void test_memcpy_inline_4(void *dst, const void *src) {
+  // CHECK:   call void @llvm.memcpy.inline.p0i8.p0i8.i64(i8* align 1 %0, i8* align 1 %1, i64 4, i1 false)
+  __builtin_memcpy_inli

[PATCH] D73624: [clangd][vscode] Get rid of the deprecated vscode module in the extension.

2020-01-29 Thread pre-merge checks [bot] via Phabricator via cfe-commits
merge_guards_bot added a comment.

{icon check-circle color=green} Unit tests: pass. 62287 tests passed, 0 failed 
and 831 were skipped.

{icon check-circle color=green} clang-tidy: pass.

{icon check-circle color=green} clang-format: pass.

Build artifacts 
: 
diff.json 
,
 clang-tidy.txt 
,
 clang-format.patch 
,
 CMakeCache.txt 
,
 console-log.txt 
,
 test-results.xml 


//Pre-merge checks is in beta. Report issue 
.
 Please join beta  or enable 
it for your project 
.//


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73624



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


[PATCH] D72829: Implement -fsemantic-interposition

2020-01-29 Thread serge via Phabricator via cfe-commits
serge-sans-paille added a comment.

> As this is user-facing documentation I feel like there should be a slightly 
> longer explaning what the option does.

done!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72829



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


[PATCH] D72829: Implement -fsemantic-interposition

2020-01-29 Thread serge via Phabricator via cfe-commits
serge-sans-paille updated this revision to Diff 241152.
serge-sans-paille added a comment.

Update user-level documentation.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72829

Files:
  clang/docs/ClangCommandLineReference.rst
  clang/include/clang/Basic/LangOptions.def
  clang/include/clang/Driver/Options.td
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/test/CodeGen/semantic-interposition.c
  clang/test/Driver/clang_f_opts.c
  llvm/include/llvm/IR/GlobalValue.h
  llvm/include/llvm/IR/Module.h
  llvm/lib/IR/Globals.cpp
  llvm/lib/IR/Module.cpp
  llvm/lib/IR/Verifier.cpp
  llvm/test/Transforms/Inline/inline-semantic-interposition.ll
  llvm/test/Verifier/module-flags-semantic-interposition.ll

Index: llvm/test/Verifier/module-flags-semantic-interposition.ll
===
--- /dev/null
+++ llvm/test/Verifier/module-flags-semantic-interposition.ll
@@ -0,0 +1,12 @@
+; RUN: not llvm-as < %s -o /dev/null 2>&1 | FileCheck %s
+
+target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
+target triple = "x86_64-unknown-linux-gnu"
+
+@foo = dso_local global i32 1, align 4
+
+!llvm.module.flags = !{!0}
+
+!0 = !{i32 1, !"SemanticInterposition", float 1.}
+
+; CHECK: SemanticInterposition metadata requires constant integer argument
Index: llvm/test/Transforms/Inline/inline-semantic-interposition.ll
===
--- /dev/null
+++ llvm/test/Transforms/Inline/inline-semantic-interposition.ll
@@ -0,0 +1,26 @@
+; Check that @callee1 gets inlined while @callee2 is not, because of
+; SemanticInterposition.
+
+; RUN: opt < %s -inline -S | FileCheck %s
+
+define internal i32 @callee1(i32 %A) {
+  ret i32 %A
+}
+
+define i32 @callee2(i32 %A) {
+  ret i32 %A
+}
+
+; CHECK-LABEL: @caller
+define i32 @caller(i32 %A) {
+; CHECK-NOT: call i32 @callee1(i32 %A)
+  %A1 = call i32 @callee1(i32 %A)
+; CHECK: %A2 = call i32 @callee2(i32 %A)
+  %A2 = call i32 @callee2(i32 %A)
+; CHECK: add i32 %A, %A2
+  %R = add i32 %A1, %A2
+  ret i32 %R
+}
+
+!llvm.module.flags = !{!0}
+!0 = !{i32 1, !"SemanticInterposition", i32 1}
Index: llvm/lib/IR/Verifier.cpp
===
--- llvm/lib/IR/Verifier.cpp
+++ llvm/lib/IR/Verifier.cpp
@@ -1476,6 +1476,13 @@
"'Linker Options' named metadata no longer supported");
   }
 
+  if (ID->getString() == "SemanticInterposition") {
+ConstantInt *Value =
+mdconst::dyn_extract_or_null(Op->getOperand(2));
+Assert(Value,
+   "SemanticInterposition metadata requires constant integer argument");
+  }
+
   if (ID->getString() == "CG Profile") {
 for (const MDOperand &MDO : cast(Op->getOperand(2))->operands())
   visitModuleFlagCGProfileEntry(MDO);
Index: llvm/lib/IR/Module.cpp
===
--- llvm/lib/IR/Module.cpp
+++ llvm/lib/IR/Module.cpp
@@ -554,6 +554,20 @@
: getModuleFlag("ProfileSummary"));
 }
 
+bool Module::getSemanticInterposition() const {
+  Metadata *MF = getModuleFlag("SemanticInterposition");
+
+  auto *Val = cast_or_null(MF);
+  if (!Val)
+return false;
+
+  return cast(Val->getValue())->getZExtValue();
+}
+
+void Module::setSemanticInterposition(bool SI) {
+  addModuleFlag(ModFlagBehavior::Error, "SemanticInterposition", SI);
+}
+
 void Module::setOwnedMemoryBuffer(std::unique_ptr MB) {
   OwnedMemoryBuffer = std::move(MB);
 }
Index: llvm/lib/IR/Globals.cpp
===
--- llvm/lib/IR/Globals.cpp
+++ llvm/lib/IR/Globals.cpp
@@ -94,6 +94,13 @@
   llvm_unreachable("not a global");
 }
 
+bool GlobalValue::isInterposable() const {
+  if (isInterposableLinkage(getLinkage()))
+return true;
+  return getParent() && getParent()->getSemanticInterposition() &&
+ !isDSOLocal();
+}
+
 unsigned GlobalValue::getAlignment() const {
   if (auto *GA = dyn_cast(this)) {
 // In general we cannot compute this at the IR level, but we try.
Index: llvm/include/llvm/IR/Module.h
===
--- llvm/include/llvm/IR/Module.h
+++ llvm/include/llvm/IR/Module.h
@@ -848,6 +848,12 @@
   Metadata *getProfileSummary(bool IsCS);
   /// @}
 
+  /// Returns whether semantic interposition is to be respected.
+  bool getSemanticInterposition() const;
+
+  /// Set whether semantic interposition is to be respected.
+  void setSemanticInterposition(bool);
+
   /// Returns true if PLT should be avoided for RTLib calls.
   bool getRtLibUseGOT() const;
 
Index: llvm/include/llvm/IR/GlobalValue.h
===
--- llvm/include/llvm/IR/GlobalValue.h
+++ llvm/include/llvm/IR/GlobalValue.h
@@ 

[PATCH] D73462: [dwarf-5] Support DebugInfo for Defaulted parameters for C++ templates

2020-01-29 Thread Awanish Pandey via Phabricator via cfe-commits
awpandey updated this revision to Diff 241141.
awpandey added a comment.

Thanks @dblaikie for figuring out the missing feature. I have added support for 
the non-type template parameter too. Please let me know if further 
modifications are required. I will happily address them.


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

https://reviews.llvm.org/D73462

Files:
  clang/lib/CodeGen/CGDebugInfo.cpp
  clang/test/CodeGenCXX/debug-info-template-parameter.cpp
  llvm/include/llvm/IR/DIBuilder.h
  llvm/include/llvm/IR/DebugInfoMetadata.h
  llvm/lib/AsmParser/LLParser.cpp
  llvm/lib/Bitcode/Reader/MetadataLoader.cpp
  llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
  llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp
  llvm/lib/IR/AsmWriter.cpp
  llvm/lib/IR/DIBuilder.cpp
  llvm/lib/IR/DebugInfoMetadata.cpp
  llvm/lib/IR/LLVMContextImpl.h
  llvm/test/DebugInfo/X86/debug-info-template-parameter.ll
  llvm/unittests/IR/MetadataTest.cpp

Index: llvm/unittests/IR/MetadataTest.cpp
===
--- llvm/unittests/IR/MetadataTest.cpp
+++ llvm/unittests/IR/MetadataTest.cpp
@@ -2077,16 +2077,16 @@
   StringRef Name = "template";
   DIType *Type = getBasicType("basic");
 
-  auto *N = DITemplateTypeParameter::get(Context, Name, Type);
+  auto *N = DITemplateTypeParameter::get(Context, Name, Type, false);
 
   EXPECT_EQ(dwarf::DW_TAG_template_type_parameter, N->getTag());
   EXPECT_EQ(Name, N->getName());
   EXPECT_EQ(Type, N->getType());
-  EXPECT_EQ(N, DITemplateTypeParameter::get(Context, Name, Type));
+  EXPECT_EQ(N, DITemplateTypeParameter::get(Context, Name, Type, false));
 
-  EXPECT_NE(N, DITemplateTypeParameter::get(Context, "other", Type));
-  EXPECT_NE(N,
-DITemplateTypeParameter::get(Context, Name, getBasicType("other")));
+  EXPECT_NE(N, DITemplateTypeParameter::get(Context, "other", Type, false));
+  EXPECT_NE(N, DITemplateTypeParameter::get(Context, Name,
+getBasicType("other"), false));
 
   TempDITemplateTypeParameter Temp = N->clone();
   EXPECT_EQ(N, MDNode::replaceWithUniqued(std::move(Temp)));
@@ -2100,21 +2100,23 @@
   DIType *Type = getBasicType("basic");
   Metadata *Value = getConstantAsMetadata();
 
-  auto *N = DITemplateValueParameter::get(Context, Tag, Name, Type, Value);
+  auto *N =
+  DITemplateValueParameter::get(Context, Tag, Name, Type, false, Value);
   EXPECT_EQ(Tag, N->getTag());
   EXPECT_EQ(Name, N->getName());
   EXPECT_EQ(Type, N->getType());
   EXPECT_EQ(Value, N->getValue());
-  EXPECT_EQ(N, DITemplateValueParameter::get(Context, Tag, Name, Type, Value));
+  EXPECT_EQ(
+  N, DITemplateValueParameter::get(Context, Tag, Name, Type, false, Value));
 
   EXPECT_NE(N, DITemplateValueParameter::get(
Context, dwarf::DW_TAG_GNU_template_template_param, Name,
-   Type, Value));
-  EXPECT_NE(N,
-DITemplateValueParameter::get(Context, Tag, "other", Type, Value));
-  EXPECT_NE(N, DITemplateValueParameter::get(Context, Tag, Name,
- getBasicType("other"), Value));
-  EXPECT_NE(N, DITemplateValueParameter::get(Context, Tag, Name, Type,
+   Type, false, Value));
+  EXPECT_NE(N, DITemplateValueParameter::get(Context, Tag, "other", Type, false,
+ Value));
+  EXPECT_NE(N, DITemplateValueParameter::get(
+   Context, Tag, Name, getBasicType("other"), false, Value));
+  EXPECT_NE(N, DITemplateValueParameter::get(Context, Tag, Name, Type, false,
  getConstantAsMetadata()));
 
   TempDITemplateValueParameter Temp = N->clone();
Index: llvm/test/DebugInfo/X86/debug-info-template-parameter.ll
===
--- /dev/null
+++ llvm/test/DebugInfo/X86/debug-info-template-parameter.ll
@@ -0,0 +1,106 @@
+; RUN: %llc_dwarf  %s -filetype=obj -o - | llvm-dwarfdump -v - | FileCheck %s
+
+; C++ source to regenerate:
+
+;template 
+;class foo {
+;};
+;
+;int main() {
+; foo f1;
+; foo f2;
+; foo<> f3;
+; return 0;
+;}
+
+; $ clang++ -O0 -g -gdwarf-5 debug-info-template-align.cpp -c
+
+; CHECK: .debug_abbrev contents:
+; CHECK: DW_AT_default_value DW_FORM_flag_present
+
+; CHECK: DW_AT_name {{.*}} "foo"
+; CHECK: DW_AT_type {{.*}} "int"
+; CHECK-NEXT: DW_AT_name {{.*}} "T"
+; CHECK-NOT: DW_AT_default_value
+; CHECK: DW_AT_type {{.*}} "int"
+; CHECK-NEXT: DW_AT_name {{.*}} "T1"
+; CHECK-NEXT: DW_AT_default_value {{.*}} (true)
+
+; CHECK: DW_AT_name {{.*}} "foo"
+; CHECK: DW_AT_type {{.*}} "float"
+; CHECK-NEXT: DW_AT_name {{.*}} "T"
+; CHECK-NOT: DW_AT_default_value
+; CHECK: DW_AT_type {{.*}} "int"
+; CHECK-NEXT: DW_AT_name {{.*}} "T1"
+; CHECK-NEXT: DW_AT_default_value {{.*}} (true)
+
+; CHECK: DW_AT_name {{.*}} "foo"
+; CHECK: DW_AT_type {{.*}} "char"
+; CHECK-NEXT: DW_AT_name {{.*}} "T"
+; CHECK-NEXT: DW_AT_default_value {{.*}} (

[PATCH] D73624: [clangd][vscode] Get rid of the deprecated vscode module in the extension.

2020-01-29 Thread Haojian Wu via Phabricator via cfe-commits
hokein updated this revision to Diff 241144.
hokein added a comment.

add trailing blank line.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73624

Files:
  clang-tools-extra/clangd/clients/clangd-vscode/package-lock.json
  clang-tools-extra/clangd/clients/clangd-vscode/package.json
  clang-tools-extra/clangd/clients/clangd-vscode/test/index.ts
  clang-tools-extra/clangd/clients/clangd-vscode/test/runTest.ts

Index: clang-tools-extra/clangd/clients/clangd-vscode/test/runTest.ts
===
--- /dev/null
+++ clang-tools-extra/clangd/clients/clangd-vscode/test/runTest.ts
@@ -0,0 +1,23 @@
+import * as path from 'path';
+
+import {runTests} from 'vscode-test';
+
+async function main() {
+  try {
+// The folder containing the Extension Manifest package.json
+// Passed to `--extensionDevelopmentPath`
+const extensionDevelopmentPath = path.resolve(__dirname, '../');
+
+// The path to the extension test script
+// Passed to --extensionTestsPath
+const extensionTestsPath = path.resolve(__dirname, './index');
+
+// Download VS Code, unzip it and run the integration test
+await runTests({extensionDevelopmentPath, extensionTestsPath});
+  } catch (err) {
+console.error('Failed to run tests');
+process.exit(1);
+  }
+}
+
+main();
Index: clang-tools-extra/clangd/clients/clangd-vscode/test/index.ts
===
--- clang-tools-extra/clangd/clients/clangd-vscode/test/index.ts
+++ clang-tools-extra/clangd/clients/clangd-vscode/test/index.ts
@@ -1,25 +1,35 @@
-//
-// PLEASE DO NOT MODIFY / DELETE UNLESS YOU KNOW WHAT YOU ARE DOING
-//
-// This file is providing the test runner to use when running extension tests.
-// By default the test runner in use is Mocha based.
-//
-// You can provide your own test runner if you want to override it by exporting
-// a function run(testRoot: string, clb: (error:Error) => void) that the
-// extension host can call to run the tests. The test runner is expected to use
-// console.log to report the results back to the caller. When the tests are
-// finished, return a possible error to the callback or null if none.
+import * as glob from 'glob';
+import * as Mocha from 'mocha';
+import * as path from 'path';
 
-var testRunner = require('vscode/lib/testrunner');
+export function run(): Promise {
+  // Create the mocha test
+  const mocha = new Mocha({ui : 'tdd'});
+  mocha.useColors(true);
 
-// You can directly control Mocha options by uncommenting the following lines
-// See
-// https://github.com/mochajs/mocha/wiki/Using-mocha-programmatically#set-options
-// for more info
-testRunner.configure({
-  ui : 'tdd', // the TDD UI is being used in extension.test.ts (suite, test,
-  // etc.)
-  useColors : true // colored output from test results
-});
+  const testsRoot = path.resolve(__dirname, '..');
 
-module.exports = testRunner;
\ No newline at end of file
+  return new Promise((c, e) => {
+glob('**/**.test.js', {cwd : testsRoot}, (err, files) => {
+  if (err) {
+return e(err);
+  }
+
+  // Add files to the test suite
+  files.forEach(f => mocha.addFile(path.resolve(testsRoot, f)));
+
+  try {
+// Run the mocha test
+mocha.run(failures => {
+  if (failures > 0) {
+e(new Error(`${failures} tests failed.`));
+  } else {
+c();
+  }
+});
+  } catch (err) {
+e(err);
+  }
+});
+  });
+}
Index: clang-tools-extra/clangd/clients/clangd-vscode/package.json
===
--- clang-tools-extra/clangd/clients/clangd-vscode/package.json
+++ clang-tools-extra/clangd/clients/clangd-vscode/package.json
@@ -32,9 +32,8 @@
 "scripts": {
 "vscode:prepublish": "tsc -p ./",
 "compile": "tsc -watch -p ./",
-"postinstall": "node ./node_modules/vscode/bin/install",
 "format": "clang-format --style=LLVM -i --glob=\"{src,test}/*.ts\"",
-"test": "node ./node_modules/vscode/bin/test",
+"test": "tsc -p ./ && node ./out/test/runTest.js",
 "package": "vsce package --baseImagesUrl https://raw.githubusercontent.com/llvm/llvm-project/master/clang-tools-extra/clangd/clients/clangd-vscode/";,
 "publish": "vsce publish --baseImagesUrl https://raw.githubusercontent.com/llvm/llvm-project/master/clang-tools-extra/clangd/clients/clangd-vscode/";
 },
@@ -45,12 +44,15 @@
 "vscode-languageserver-types": "^3.15.1"
 },
 "devDependencies": {
+"@types/glob": "^7.1.1",
 "@types/mocha": "^2.2.32",
 "@types/node": "^6.0.40",
+"@types/vscode": "^1.41.0",
+"glob": "^7.1.4",
 "clang-format": "1.2.4",
 "mocha": "^5.2.0",
-"typescript": "^2.0.3",
-"vscode": "^1.1.0"
+ 

[PATCH] D73624: [clangd][vscode] Get rid of the deprecated vscode module in the extension.

2020-01-29 Thread Haojian Wu via Phabricator via cfe-commits
hokein created this revision.
hokein added a reviewer: sammccall.
Herald added subscribers: usaxena95, kadircet, arphaman, jkorous, MaskRay, 
ilya-biryukov, dschuff.
Herald added a project: clang.
hokein updated this revision to Diff 241144.
hokein added a comment.

add trailing blank line.


The vscode module has been deprecated, and it doesn't work anymore after
we require the minimal VSCode version 1.41.0, this patch migrate to the
new @type/vscode and vscode-test modules, see
https://code.visualstudio.com/api/working-with-extensions/testing-extension#migrating-from-vscode


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D73624

Files:
  clang-tools-extra/clangd/clients/clangd-vscode/package-lock.json
  clang-tools-extra/clangd/clients/clangd-vscode/package.json
  clang-tools-extra/clangd/clients/clangd-vscode/test/index.ts
  clang-tools-extra/clangd/clients/clangd-vscode/test/runTest.ts

Index: clang-tools-extra/clangd/clients/clangd-vscode/test/runTest.ts
===
--- /dev/null
+++ clang-tools-extra/clangd/clients/clangd-vscode/test/runTest.ts
@@ -0,0 +1,23 @@
+import * as path from 'path';
+
+import {runTests} from 'vscode-test';
+
+async function main() {
+  try {
+// The folder containing the Extension Manifest package.json
+// Passed to `--extensionDevelopmentPath`
+const extensionDevelopmentPath = path.resolve(__dirname, '../');
+
+// The path to the extension test script
+// Passed to --extensionTestsPath
+const extensionTestsPath = path.resolve(__dirname, './index');
+
+// Download VS Code, unzip it and run the integration test
+await runTests({extensionDevelopmentPath, extensionTestsPath});
+  } catch (err) {
+console.error('Failed to run tests');
+process.exit(1);
+  }
+}
+
+main();
Index: clang-tools-extra/clangd/clients/clangd-vscode/test/index.ts
===
--- clang-tools-extra/clangd/clients/clangd-vscode/test/index.ts
+++ clang-tools-extra/clangd/clients/clangd-vscode/test/index.ts
@@ -1,25 +1,35 @@
-//
-// PLEASE DO NOT MODIFY / DELETE UNLESS YOU KNOW WHAT YOU ARE DOING
-//
-// This file is providing the test runner to use when running extension tests.
-// By default the test runner in use is Mocha based.
-//
-// You can provide your own test runner if you want to override it by exporting
-// a function run(testRoot: string, clb: (error:Error) => void) that the
-// extension host can call to run the tests. The test runner is expected to use
-// console.log to report the results back to the caller. When the tests are
-// finished, return a possible error to the callback or null if none.
+import * as glob from 'glob';
+import * as Mocha from 'mocha';
+import * as path from 'path';
 
-var testRunner = require('vscode/lib/testrunner');
+export function run(): Promise {
+  // Create the mocha test
+  const mocha = new Mocha({ui : 'tdd'});
+  mocha.useColors(true);
 
-// You can directly control Mocha options by uncommenting the following lines
-// See
-// https://github.com/mochajs/mocha/wiki/Using-mocha-programmatically#set-options
-// for more info
-testRunner.configure({
-  ui : 'tdd', // the TDD UI is being used in extension.test.ts (suite, test,
-  // etc.)
-  useColors : true // colored output from test results
-});
+  const testsRoot = path.resolve(__dirname, '..');
 
-module.exports = testRunner;
\ No newline at end of file
+  return new Promise((c, e) => {
+glob('**/**.test.js', {cwd : testsRoot}, (err, files) => {
+  if (err) {
+return e(err);
+  }
+
+  // Add files to the test suite
+  files.forEach(f => mocha.addFile(path.resolve(testsRoot, f)));
+
+  try {
+// Run the mocha test
+mocha.run(failures => {
+  if (failures > 0) {
+e(new Error(`${failures} tests failed.`));
+  } else {
+c();
+  }
+});
+  } catch (err) {
+e(err);
+  }
+});
+  });
+}
Index: clang-tools-extra/clangd/clients/clangd-vscode/package.json
===
--- clang-tools-extra/clangd/clients/clangd-vscode/package.json
+++ clang-tools-extra/clangd/clients/clangd-vscode/package.json
@@ -32,9 +32,8 @@
 "scripts": {
 "vscode:prepublish": "tsc -p ./",
 "compile": "tsc -watch -p ./",
-"postinstall": "node ./node_modules/vscode/bin/install",
 "format": "clang-format --style=LLVM -i --glob=\"{src,test}/*.ts\"",
-"test": "node ./node_modules/vscode/bin/test",
+"test": "tsc -p ./ && node ./out/test/runTest.js",
 "package": "vsce package --baseImagesUrl https://raw.githubusercontent.com/llvm/llvm-project/master/clang-tools-extra/clangd/clients/clangd-vscode/";,
 "publish": "vsce publish --baseImagesUrl https://raw.githubusercontent.com/llvm/llvm-project/master/clang-tools-extra/clangd/clients/clang

[PATCH] D72222: [Driver][CodeGen] Add -fpatchable-function-entry=N[,0]

2020-01-29 Thread Mark Rutland via Phabricator via cfe-commits
mrutland added a comment.

In D7#1839207 , @MaskRay wrote:

> When -mbranch-protection=bti is used, due to 
> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=92424 (existing GCC releases 
> have the issue), Linux/arch/arm64 has to make more checks to detect the 
> combination.


As covered in D7#1838988  the plan 
is to detect broken compilers at  build-time and reject the combination of 
options. The Linux patching code will not handle varied behaviours at runtime.

> I changed `nop; nop; bti c` to `bti c; nop; nop` with 2 commits not included 
> in LLVM release/10.x (a72d15e37c5e066f597f13a8ba60aff214ac992d 
>  and 
> 9a24488cb67a90f889529987275c5e411ce01dda 
> ). They 
> make Clang's M!=0 placement (.Lpatch; nop; func: bti c; nop) consistent with 
> GCC.
>  Edit: cherry-picked to release/10.x

That's great; thanks!

> For the M=0 case, Clang does (`func: .Lpatch; bti c; nop; nop`), which is 
> inconsistent with GCC (`func: bti c; .Lpatch: nop; nop`). I'll be happy to 
> try updating the placement of .Lpatch if future M>0 usage does not obsolete 
> M=0 usage (a proof that the proposed GCC layout is indeed superior, not just 
> for simplicity for a not-so-common configuration), otherwise I would feel the 
> clang side is just making changes to appease GCC/Linux compatibility, which 
> would make me sad.

I do not expect future M>0 usage to obsolete M=0 usage, and these will be used 
by distinct configurations of Linux with distinct code paths. I expect that we 
will need M>0 in future to handle very large kernel images and/or live-patching 
where we may need to place PLTs or other metadata close to a function. I expect 
that other cases will continue to use M=0.

I can appreciate the frustration here, but I do think that this is an ABI issue 
if the compilers diverge in behaviour here. Especially as future additions to 
the architecture or PCS could complicate matters, and what could seem benign 
divergence now could turn out to be unreconcilable.

Aligning with the GCC M=0 case here will mean that patching code that works 
with GCC should just work without modification for clang, and I do think that's 
a better position to be in generally.

> (Again: this is our ~5th time adding an option specific to Linux kernel, with 
> a good intention to make it general, but in reality it doesn't 
> https://gcc.gnu.org/ml/gcc/2020-01/msg00067.html) I shall also mention that 
> we are essentially making decisions for x86 people's endbr32/endbr64. I hope 
> you can engage in x86 maintainers. Clang's current layout is recorded at 
> D73071 .

That's a good point w.r.t. x86; I will get in touch with the people working on 
ftrace and live-patching there

Thanks,
Mark.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D7



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


[PATCH] D73285: [OpenMP][OMPIRBuilder][BugFix] Handle Unreachable Finalization blocks in `parallel` generation

2020-01-29 Thread Fady Ghanim via Phabricator via cfe-commits
fghanim marked an inline comment as done.
fghanim added inline comments.



Comment at: llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp:661
+AfterIP = InsertPointTy(ForkBB, ForkBB->end());
+  }
 

jdoerfert wrote:
> fghanim wrote:
> > jdoerfert wrote:
> > > Why do we need all of this? Can't we just *not do it* instead? This is 
> > > code complexity that we should avoid.
> > Depends. 
> > If we want to conform with the way things are done in clang; namely, not 
> > have unreachable blocks, then yes we need to do this. If not, then no, 
> > nothing needs to change. An optimization pass will be executed at some 
> > point later that should clean all that up.
> > 
> > However, we should be careful, for example, The lit test for `critical` 
> > checks that no basic blocks were generated from the rest of the body that 
> > comes after the infinite loop. So if the choice is to not conform with 
> > clang, then we should keep an eye on these lit tests, and disable such 
> > checks for the OMPBuilder.
> > If we want to conform with the way things are done in clang;
> 
> It's not like we introduce much extra code, break anything, or make the final 
> result different.
> 
> 
> >  If not, then no, nothing needs to change. An optimization pass will be 
> > executed at some point later that should clean all that up.
> 
> Let's go with that solution and keep this code here simple, less error prone, 
> and easier to manage.
> 
> 
> > However, we should be careful, for example, The lit test for critical 
> > checks that no basic blocks were generated from the rest of the body that 
> > comes after the infinite loop. So if the choice is to not conform with 
> > clang, then we should keep an eye on these lit tests, and disable such 
> > checks for the OMPBuilder.
> 
> We already do things different and that will only become more evident 
> (TRegions!). For example, to simplify this code we do *not* cache runtime 
> calls (anymore). That is we emit a new get_thread_id call every time. (We 
> know the OpenMPOpt pass will clean it up eventually.) I get that the tests 
> change and for a while we will have clang and OMPBuilder check lines. Though, 
> once the clang CG is gone there is arguably no difference anymore because the 
> OMPBuilder behavior is then the default. As soon as we have the privatization 
> parts properly hooked up we can even start running the OMPBuilder by default 
> and soon after removing clang CG parts. If anything, we should modernize the 
> clang tests as they are a constant critique point that hinders outside 
> involvement. We could start using the llvm/utils/update__checks scripts 
> for example. We could also minimize the check lines and focus on the most 
> important bits only. (I prefer the update scripts with the pending 
> extensions, e.g., D69701)
> 
In that case, This revision is not necessary. The only fix needed is the branch 
erasure/creation change in the body CallBack (a bit more on this later), all 
the rest including the tests is not necessary. The only tests needed are 
already being done by the llvm verifier, which already reports if a BB is used 
by an orphan branch sticking around, or if a BB contains more than one 
terminator.

Regarding the issue of the branch, given that our finalization and body 
callbacks are very similar across different directives (Parallel, master, 
critical), the plan as we discussed on D72304 , is to write helper 
functions/class that we could use instead. So whoever, ends up writing that 
should make sure to include the branch changes, which makes them here redundant.

So, in the interest of everyone's time, my suggestion is to abandon this 
revision entirely for now, and just make sure that the implementation of these 
helper functions takes care of this everywhere.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73285



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


[PATCH] D72829: Implement -fsemantic-interposition

2020-01-29 Thread Sean Fertile via Phabricator via cfe-commits
sfertile added a comment.

Aewsome, thanks for implementing this. I was on vacation for a bit and somehow 
missed this review in my queue when I cam back but having a look at it now.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72829



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


  1   2   >