[PATCH] D129538: [clang] adds prototype for being able to alternate diagnostic formats

2022-07-11 Thread Christopher Di Bella via Phabricator via cfe-commits
cjdb updated this revision to Diff 443833.
cjdb added a comment.

`arc diff` no longer seems to autoformat


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D129538

Files:
  clang/include/clang/Basic/Diagnostic.h
  clang/include/clang/Sema/Sema.h
  clang/unittests/Basic/SarifTest.cpp

Index: clang/unittests/Basic/SarifTest.cpp
===
--- clang/unittests/Basic/SarifTest.cpp
+++ clang/unittests/Basic/SarifTest.cpp
@@ -317,4 +317,20 @@
   ASSERT_THAT(Output, ::testing::StrEq(ExpectedOutput));
 }
 
+// Check that we can set/get a SarifDocumentWriter from the DiagnosticsEngine
+// Note that there doesn't appear to be any tests for the DiagnosticsEngine, so
+// we test here.
+TEST_F(SarifDocumentWriterTest, checkDiagnosticsEngineSetAndGet) {
+  ASSERT_FALSE(Diags.getSarifWriter());
+
+  // GIVEN:
+  SarifDocumentWriter Writer(SourceMgr);
+
+  // WHEN: the DiagnosticsEngine is set
+  Diags.setSarifWriter();
+
+  // THEN: the DiagnosticsEngine points to the local SarifDocumentWriter
+  EXPECT_TRUE(Diags.getSarifWriter() == );
+}
+
 } // namespace
Index: clang/include/clang/Sema/Sema.h
===
--- clang/include/clang/Sema/Sema.h
+++ clang/include/clang/Sema/Sema.h
@@ -38,6 +38,7 @@
 #include "clang/Basic/BitmaskEnum.h"
 #include "clang/Basic/Builtins.h"
 #include "clang/Basic/DarwinSDKInfo.h"
+#include "clang/Basic/Diagnostic.h"
 #include "clang/Basic/ExpressionTraits.h"
 #include "clang/Basic/Module.h"
 #include "clang/Basic/OpenCLOptions.h"
@@ -1772,6 +1773,14 @@
   return Diag;
 }
 
+const SemaDiagnosticBuilder <<(const BasicDiagnostic ) const {
+  if (SarifDocumentWriter *W = S.Diags.getSarifWriter())
+Diag.EmitSarifDiagnostic(*W);
+  else
+Diag.EmitTraditionalDiagnostic();
+  return *this;
+}
+
 // It is necessary to limit this to rvalue reference to avoid calling this
 // function with a bitfield lvalue argument since non-const reference to
 // bitfield is not allowed.
@@ -13583,7 +13592,6 @@
  PragmaMsStackAction Action,
  llvm::StringRef StackSlotLabel,
  AlignPackInfo Value);
-
 } // end namespace clang
 
 namespace llvm {
Index: clang/include/clang/Basic/Diagnostic.h
===
--- clang/include/clang/Basic/Diagnostic.h
+++ clang/include/clang/Basic/Diagnostic.h
@@ -16,6 +16,7 @@
 
 #include "clang/Basic/DiagnosticIDs.h"
 #include "clang/Basic/DiagnosticOptions.h"
+#include "clang/Basic/Sarif.h"
 #include "clang/Basic/SourceLocation.h"
 #include "clang/Basic/Specifiers.h"
 #include "llvm/ADT/ArrayRef.h"
@@ -183,6 +184,45 @@
   DiagnosticStorage() = default;
 };
 
+/// Abstract interface for all errors, warnings, and remarks. This allows us to
+/// use the visitor pattern. This is something that will be concretely defined
+/// in the short-term, as we experiment, but will be migrated over to TableGen
+/// after a few diagnostics have been implemented.
+class BasicDiagnostic {
+public:
+  virtual ~BasicDiagnostic() = default;
+
+  /// Emits the diagnostic as Clang's original unstructured text format.
+  virtual void EmitTraditionalDiagnostic() const = 0;
+
+  /// Emits the diagnostic as SARIF.
+  virtual void EmitSarifDiagnostic(SarifDocumentWriter &) const = 0;
+
+protected:
+  using DiagID = unsigned;
+
+  explicit BasicDiagnostic(DiagID K) : ID(K) {}
+
+  DiagID getID() const { return ID; }
+
+private:
+  DiagID ID;
+};
+
+/// Abstract interface for diagnostic contexts (traditionally: notes).
+/// A BasicDiagnostic may have as many different contexts as required to provide
+/// users with a complete picture.
+class DiagnosticContext {
+public:
+  virtual ~DiagnosticContext() = default;
+
+  /// Emits the diagnostic as an unstructured text note.
+  virtual void EmitTraditionalNote() const = 0;
+
+  /// Emits the diagnostic as SARIF.
+  virtual void EmitSarifContext(SarifDocumentWriter &) const = 0;
+};
+
 /// Concrete class used by the front-end to report problems and issues.
 ///
 /// This massages the diagnostics (e.g. handling things like "report warnings
@@ -295,6 +335,7 @@
   DiagnosticConsumer *Client = nullptr;
   std::unique_ptr Owner;
   SourceManager *SourceMgr = nullptr;
+  SarifDocumentWriter *SarifWriter = nullptr;
 
   /// Mapping information for diagnostics.
   ///
@@ -979,6 +1020,9 @@
   /// Return the value associated with this diagnostic flag.
   StringRef getFlagValue() const { return FlagValue; }
 
+  void setSarifWriter(SarifDocumentWriter *W) { SarifWriter = W; }
+  SarifDocumentWriter *getSarifWriter() const { return SarifWriter; }
+
 private:
   // This is private state used by DiagnosticBuilder.  We put it here instead of
   

[PATCH] D129538: [clang] adds prototype for being able to alternate diagnostic formats

2022-07-11 Thread Christopher Di Bella via Phabricator via cfe-commits
cjdb created this revision.
cjdb added a reviewer: aaron.ballman.
Herald added a project: All.
cjdb requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

In an effort to move from unstructured text diagnostics to structured
diagnostics, while keeping support for the existing model, we need to
introduce a way to hotswap between the desired modes. The visitor
pattern is a natural ally here because it allows us to defer logic to
handlers that know the specifics of the diagnostic without cluttering
the compiler's logic.

There are two parts to the design: `BasicDiagnostic`, which is used as
an abstract base for errors, warnings, and remarks; and
`DiagnosticContext`, which is used as an abstract base for notes. We've
split diagnostics into these two categories so that it's possible for to
enrich diagnostics with multiple unrelated contexts (notes seem to trail
diagnostics in a detatched and unherded fashion). FixIts are a form of
diagnostic context.

Although parts of `BasicDiagnostic` and `DiagnosticContext` should be
generated via TableGen, we're initially implementing everything manually
so that we can prototype what is necessary: it will be far easier to do
this with a handful of diagnostics than to also figure out how to
integrate this into TableGen at the same time.

**Reviewers should note that testing is currently lacking. Tests for the
diagnostic framework seem to be nonexistent; this should probably
change.**

Depends on: D109701 


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D129538

Files:
  clang/include/clang/Basic/Diagnostic.h
  clang/include/clang/Sema/Sema.h
  clang/unittests/Basic/SarifTest.cpp

Index: clang/unittests/Basic/SarifTest.cpp
===
--- clang/unittests/Basic/SarifTest.cpp
+++ clang/unittests/Basic/SarifTest.cpp
@@ -317,4 +317,20 @@
   ASSERT_THAT(Output, ::testing::StrEq(ExpectedOutput));
 }
 
+// Check that we can set/get a SarifDocumentWriter from the DiagnosticsEngine
+// Note that there doesn't appear to be any tests for the DiagnosticsEngine, so
+// we test here.
+TEST_F(SarifDocumentWriterTest, checkDiagnosticsEngineSetAndGet) {
+  ASSERT_FALSE(Diags.getSarifWriter());
+
+  // GIVEN:
+  SarifDocumentWriter Writer(SourceMgr);
+
+  // WHEN: the DiagnosticsEngine is set
+  Diags.setSarifWriter();
+
+  // THEN: the DiagnosticsEngine points to the local SarifDocumentWriter
+  EXPECT_TRUE(Diags.getSarifWriter() == );
+}
+
 } // namespace
Index: clang/include/clang/Sema/Sema.h
===
--- clang/include/clang/Sema/Sema.h
+++ clang/include/clang/Sema/Sema.h
@@ -38,6 +38,7 @@
 #include "clang/Basic/BitmaskEnum.h"
 #include "clang/Basic/Builtins.h"
 #include "clang/Basic/DarwinSDKInfo.h"
+#include "clang/Basic/Diagnostic.h"
 #include "clang/Basic/ExpressionTraits.h"
 #include "clang/Basic/Module.h"
 #include "clang/Basic/OpenCLOptions.h"
@@ -1772,6 +1773,14 @@
   return Diag;
 }
 
+const SemaDiagnosticBuilder <<(const BasicDiagnostic ) const {
+  if (SarifDocumentWriter *W = S.Diags.getSarifWriter())
+Diag.EmitSarifDiagnostic(*W);
+  else
+Diag.EmitTraditionalDiagnostic();
+  return *this;
+}
+
 // It is necessary to limit this to rvalue reference to avoid calling this
 // function with a bitfield lvalue argument since non-const reference to
 // bitfield is not allowed.
@@ -13584,6 +13593,28 @@
  llvm::StringRef StackSlotLabel,
  AlignPackInfo Value);
 
+class SemaDiagnostic : public BasicDiagnostic {
+protected:
+  SemaDiagnostic(DiagID ID, Sema& S)
+  : BasicDiagnostic(ID)
+  , S()
+  {}
+
+  Sema& getSema() const { return *S; }
+private:
+  Sema* S;
+};
+
+class SemaDiagnosticContext : public DiagnosticContext {
+protected:
+  explicit SemaDiagnosticContext(Sema& S)
+  : S()
+  {}
+
+  Sema& getSema() const { return *S; }
+private:
+  Sema* S;
+};
 } // end namespace clang
 
 namespace llvm {
Index: clang/include/clang/Basic/Diagnostic.h
===
--- clang/include/clang/Basic/Diagnostic.h
+++ clang/include/clang/Basic/Diagnostic.h
@@ -16,6 +16,7 @@
 
 #include "clang/Basic/DiagnosticIDs.h"
 #include "clang/Basic/DiagnosticOptions.h"
+#include "clang/Basic/Sarif.h"
 #include "clang/Basic/SourceLocation.h"
 #include "clang/Basic/Specifiers.h"
 #include "llvm/ADT/ArrayRef.h"
@@ -183,6 +184,45 @@
   DiagnosticStorage() = default;
 };
 
+/// Abstract interface for all errors, warnings, and remarks. This allows us to
+/// use the visitor pattern. This is something that will be concretely defined
+/// in the short-term, as we experiment, but will be migrated over to TableGen
+/// after a few diagnostics have been implemented.
+class BasicDiagnostic {
+public:

[PATCH] D129456: [lldb] Add image dump pcm-info command

2022-07-11 Thread Dave Lee via Phabricator via cfe-commits
kastiglione updated this revision to Diff 443830.
kastiglione added a comment.

added error handling


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D129456

Files:
  clang/include/clang/Frontend/FrontendActions.h
  clang/lib/Frontend/FrontendActions.cpp
  lldb/source/Commands/CommandObjectTarget.cpp
  lldb/test/API/commands/target/dump-pcm-info/Makefile
  lldb/test/API/commands/target/dump-pcm-info/TestDumpPCMInfo.py
  lldb/test/API/commands/target/dump-pcm-info/main.m

Index: lldb/test/API/commands/target/dump-pcm-info/main.m
===
--- /dev/null
+++ lldb/test/API/commands/target/dump-pcm-info/main.m
@@ -0,0 +1 @@
+int main() { return 0; }
Index: lldb/test/API/commands/target/dump-pcm-info/TestDumpPCMInfo.py
===
--- /dev/null
+++ lldb/test/API/commands/target/dump-pcm-info/TestDumpPCMInfo.py
@@ -0,0 +1,40 @@
+"""
+Test 'target modules dump pcm-info'.
+"""
+
+import os
+import shutil
+import glob
+
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+
+
+class TestCase(TestBase):
+@no_debug_info_test
+@skipUnlessDarwin
+def test(self):
+self.build()
+
+lldbutil.run_to_source_breakpoint(
+self, "return", lldb.SBFileSpec("main.m"))
+
+mod_cache = self.getBuildArtifact("private-module-cache")
+if os.path.isdir(mod_cache):
+shutil.rmtree(mod_cache)
+
+self.runCmd(f"settings set symbols.clang-modules-cache-path '{mod_cache}'")
+
+# Cause lldb to generate a Darwin-*.pcm
+self.runCmd("p @import Darwin")
+
+# root//-.pcm
+pcm_paths = glob.glob(os.path.join(mod_cache, '*', 'Darwin-*.pcm'))
+self.assertEqual(len(pcm_paths), 1, "Expected one Darwin pcm")
+pcm_path = pcm_paths[0]
+
+self.expect(
+f"target modules dump pcm-info '{pcm_path}'",
+startstr=f"Information for module file '{pcm_path}'",
+substrs=["Module name: Darwin"])
Index: lldb/test/API/commands/target/dump-pcm-info/Makefile
===
--- /dev/null
+++ lldb/test/API/commands/target/dump-pcm-info/Makefile
@@ -0,0 +1,4 @@
+OBJC_SOURCES := main.m
+USE_PRIVATE_MODULE_CACHE = YES
+include Makefile.rules
+
Index: lldb/source/Commands/CommandObjectTarget.cpp
===
--- lldb/source/Commands/CommandObjectTarget.cpp
+++ lldb/source/Commands/CommandObjectTarget.cpp
@@ -47,12 +47,17 @@
 #include "lldb/Target/Thread.h"
 #include "lldb/Target/ThreadSpec.h"
 #include "lldb/Utility/Args.h"
+#include "lldb/Utility/FileSpec.h"
 #include "lldb/Utility/LLDBLog.h"
 #include "lldb/Utility/State.h"
 #include "lldb/Utility/Timer.h"
 #include "lldb/lldb-enumerations.h"
 #include "lldb/lldb-private-enumerations.h"
 
+#include "clang/CodeGen/ObjectFilePCHContainerOperations.h"
+#include "clang/Frontend/CompilerInstance.h"
+#include "clang/Frontend/CompilerInvocation.h"
+#include "clang/Frontend/FrontendActions.h"
 #include "llvm/ADT/ScopeExit.h"
 #include "llvm/Support/FileSystem.h"
 #include "llvm/Support/FormatAdapters.h"
@@ -2155,6 +2160,63 @@
   }
 };
 
+class CommandObjectTargetModulesDumpClangPCMInfo : public CommandObjectParsed {
+public:
+  CommandObjectTargetModulesDumpClangPCMInfo(CommandInterpreter )
+  : CommandObjectParsed(
+interpreter, "target modules dump pcm-info",
+"Dump information about the given clang module (pcm).") {
+// Take a single file argument.
+CommandArgumentData arg{eArgTypeFilename, eArgRepeatPlain};
+m_arguments.push_back({arg});
+  }
+
+  ~CommandObjectTargetModulesDumpClangPCMInfo() override = default;
+
+protected:
+  bool DoExecute(Args , CommandReturnObject ) override {
+if (command.GetArgumentCount() != 1) {
+  result.AppendErrorWithFormat(
+  "'%s' takes exactly one pcm path argument.\n", m_cmd_name.c_str());
+  return false;
+}
+
+const char *pcm_path = command.GetArgumentAtIndex(0);
+FileSpec file_spec(pcm_path);
+if (!FileSystem::Instance().Exists(FileSpec(pcm_path))) {
+  result.AppendErrorWithFormat("file does not exist");
+  return false;
+}
+
+clang::CompilerInstance compiler;
+
+const char *clang_args[] = {"clang", pcm_path};
+compiler.setInvocation(clang::createInvocation(clang_args));
+
+if (!compiler.hasInvocation()) {
+  result.AppendErrorWithFormat("input is not a pcm file");
+  return false;
+}
+
+auto input_kind = compiler.getFrontendOpts().DashX;
+if (input_kind.getFormat() != clang::InputKind::Format::Precompiled) {
+  result.AppendErrorWithFormat("input is not a pcm file");
+  return false;
+}
+
+clang::DumpModuleInfoAction 

[PATCH] D129498: [analyzer] Add new function `clang_analyzer_value` to ExprInspectionChecker

2022-07-11 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added a comment.

Looks great!

Maybe `clang_analyzer_range()` instead?

Please add documentation to 
https://clang.llvm.org/docs/analyzer/developer-docs/DebugChecks.html




Comment at: clang/test/Analysis/print-ranges.cpp:1
+// RUN: %clang_analyze_cc1 -analyzer-checker=core,debug.ExprInspection 
-analyzer-config eagerly-assume=false -verify %s
+

I suspect this test will crash when clang is built with Z3, because the Z3 
constraint manager doesn't implement your new function yet.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D129498

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


[PATCH] D129068: [AST] Accept identical TypeConstraint referring to other template parameters.

2022-07-11 Thread Chuanqi Xu via Phabricator via cfe-commits
ChuanqiXu marked 2 inline comments as done.
ChuanqiXu added inline comments.



Comment at: clang/lib/AST/ASTContext.cpp:6254
 return false;
   if (TXTC->hasExplicitTemplateArgs() != TYTC->hasExplicitTemplateArgs())
 return false;

ilya-biryukov wrote:
> Do we even want to compare the template argument sizes here?
> Would comparing only `getImmediatelyDeclaredConstraint` produce the same 
> results?
> 
> If that's a performance optimization, we are probably better off moving it 
> inside `isSameConstraintExpr`.
> 
I've moved them into `isSameTypeConstraint`. Now the code looks better.


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

https://reviews.llvm.org/D129068

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


[PATCH] D129068: [AST] Accept identical TypeConstraint referring to other template parameters.

2022-07-11 Thread Chuanqi Xu via Phabricator via cfe-commits
ChuanqiXu updated this revision to Diff 443823.
ChuanqiXu added a comment.

Address comments.


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

https://reviews.llvm.org/D129068

Files:
  clang/include/clang/AST/ASTContext.h
  clang/lib/AST/ASTContext.cpp
  clang/test/Modules/concept.cppm

Index: clang/test/Modules/concept.cppm
===
--- clang/test/Modules/concept.cppm
+++ clang/test/Modules/concept.cppm
@@ -3,6 +3,7 @@
 // RUN: split-file %s %t
 //
 // RUN: %clang_cc1 -std=c++20 %t/A.cppm -emit-module-interface -o %t/A.pcm
+// RUN: %clang_cc1 -std=c++20 -fprebuilt-module-path=%t -I%t -DDIFFERENT %t/B.cppm -verify
 // RUN: %clang_cc1 -std=c++20 -fprebuilt-module-path=%t -I%t %t/B.cppm -verify
 
 //--- foo.h
@@ -18,6 +19,9 @@
 template 
 concept __member_size = requires(_Tp &) { t.size(); };
 
+template 
+concept C = requires(First x, Second y) { x + y; };
+
 struct A {
 public:
   template 
@@ -29,6 +33,29 @@
   constexpr __integer_like auto operator()(_Tp&& __t) const {
 return __t.size();
   }
+
+  template <__integer_like _Tp, C<_Tp> Sentinel>
+  constexpr _Tp operator()(_Tp &&__t, Sentinel &) const {
+return __t;
+  }
+
+  template  class H, class S, C> Sentinel>
+  constexpr H operator()(H &&__s, Sentinel &) const {
+return __s;
+  }
+
+// Tests that we could find different concept definition indeed.
+#ifndef DIFFERENT
+  template <__integer_like _Tp, __integer_like _Up, C<_Tp> Sentinel>
+  constexpr _Tp operator()(_Tp &&__t, _Up _u, Sentinel &) const {
+return __t;
+  }
+#else
+  template <__integer_like _Tp, __integer_like _Up, C<_Up> Sentinel>
+  constexpr _Tp operator()(_Tp &&__t, _Up _u, Sentinel &) const {
+return __t;
+  }
+#endif
 };
 #endif
 
@@ -38,12 +65,23 @@
 export module A;
 
 //--- B.cppm
-// expected-no-diagnostics
 module;
 #include "foo.h"
 export module B;
 import A;
 
+#ifdef DIFFERENT
+// expected-error@foo.h:41 {{'__fn::operator()' from module 'A.' is not present in definition of '__fn' provided earlier}}
+// expected-note@* 1+{{declaration of 'operator()' does not match}}
+#else
+// expected-no-diagnostics
+#endif
+
+template 
+struct U {
+  auto operator+(U) { return 0; }
+};
+
 void foo() {
 A a;
 struct S {
@@ -51,4 +89,8 @@
 auto operator+(S s) { return 0; }
 };
 __fn{}(S());
+__fn{}(S(), S());
+__fn{}(S(), S(), S());
+
+__fn{}(U(), U());
 }
Index: clang/lib/AST/ASTContext.cpp
===
--- clang/lib/AST/ASTContext.cpp
+++ clang/lib/AST/ASTContext.cpp
@@ -6218,6 +6218,57 @@
  getCanonicalTemplateName(Y).getAsVoidPointer();
 }
 
+bool ASTContext::isSameConstraintExpr(const Expr *XCE, const Expr *YCE) const {
+  if (!XCE != !YCE)
+return false;
+
+  if (!XCE)
+return true;
+
+  llvm::FoldingSetNodeID XCEID, YCEID;
+  XCE->Profile(XCEID, *this, /*Canonical=*/true);
+  YCE->Profile(YCEID, *this, /*Canonical=*/true);
+  return XCEID == YCEID;
+}
+
+bool ASTContext::isSameTypeConstraint(const TypeConstraint *XTC,
+  const TypeConstraint *YTC) const {
+  if (!XTC != !YTC)
+return false;
+
+  if (!XTC)
+return true;
+
+  auto *NCX = XTC->getNamedConcept();
+  auto *NCY = YTC->getNamedConcept();
+  if (!NCX || !NCY || !isSameEntity(NCX, NCY))
+return false;
+  if (XTC->hasExplicitTemplateArgs() != YTC->hasExplicitTemplateArgs())
+return false;
+  if (XTC->hasExplicitTemplateArgs())
+if (XTC->getTemplateArgsAsWritten()->NumTemplateArgs !=
+YTC->getTemplateArgsAsWritten()->NumTemplateArgs)
+  return false;
+
+  // Compare slowly by profiling.
+  //
+  // We couldn't compare the profiling result for the template
+  // args here. Consider the following example in different modules:
+  //
+  // template <__integer_like _Tp, C<_Tp> Sentinel>
+  // constexpr _Tp operator()(_Tp &&__t, Sentinel &) const {
+  //   return __t;
+  // }
+  //
+  // When we compare the profiling result for `C<_Tp>` in different
+  // modules, it will compare the type of `_Tp` in different modules.
+  // However, the type of `_Tp` in different modules refer to different
+  // types here naturally. So we couldn't compare the profiling result
+  // for the template args directly.
+  return isSameConstraintExpr(XTC->getImmediatelyDeclaredConstraint(),
+  YTC->getImmediatelyDeclaredConstraint());
+}
+
 bool ASTContext::isSameTemplateParameter(const NamedDecl *X,
  const NamedDecl *Y) const {
   if (X->getKind() != Y->getKind())
@@ -6229,32 +6280,8 @@
   return false;
 if (TX->hasTypeConstraint() != TY->hasTypeConstraint())
   return false;
-const TypeConstraint *TXTC = TX->getTypeConstraint();
-const TypeConstraint *TYTC = TY->getTypeConstraint();
-if (!TXTC != !TYTC)
-  return false;
-if (TXTC && TYTC) {
-  auto *NCX = 

[PATCH] D129536: [CUDA][FIX] Make shfl[_sync] for unsigned long long non-recursive

2022-07-11 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert created this revision.
jdoerfert added a reviewer: tra.
Herald added subscribers: mattd, bollu, yaxunl.
Herald added a project: All.
jdoerfert requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

A copy-paste error caused UB in the definition of the unsigned long long
versions of the shfl intrinsics. Reported and diagnosed by @trws.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D129536

Files:
  clang/lib/Headers/__clang_cuda_intrinsics.h
  clang/test/CodeGenCUDA/shuffle_long_long.cu

Index: clang/test/CodeGenCUDA/shuffle_long_long.cu
===
--- /dev/null
+++ clang/test/CodeGenCUDA/shuffle_long_long.cu
@@ -0,0 +1,61 @@
+// REQUIRES: nvptx-registered-target
+
+// RUN: %clang_cc1 -triple nvptx64-nvidia-cuda -fcuda-is-device -emit-llvm %s -o - | FileCheck %s --check-prefix=NO_SYNC
+// RUN: %clang_cc1 -triple nvptx64-nvidia-cuda -fcuda-is-device -emit-llvm -target-feature +ptx70 -DSYNC -DCUDA_VERSION=9000 %s -o - | FileCheck %s --check-prefixes=NO_SYNC,SYNC
+
+#include "Inputs/cuda.h"
+
+#undef __CUDA_ARCH__
+#define __CUDA_ARCH__ 300
+
+__device__ void *memcpy(void *dest, const void *src, size_t n);
+
+#define warpSize 32
+#include "__clang_cuda_intrinsics.h"
+
+__device__ void use(unsigned long long, long long);
+
+// Test function, 4 shfl calls.
+// NO_SYNC: define{{.*}} @_Z14test_long_longv
+// NO_SYNC: call noundef i64 @_Z6__shflyii(
+// NO_SYNC: call noundef i64 @_Z6__shflxii(
+// SYNC:call noundef i64 @_Z11__shfl_syncjyii(
+// SYNC:call noundef i64 @_Z11__shfl_syncjxii(
+
+// unsigned long long -> long long
+// NO_SYNC: define{{.*}} @_Z6__shflyii
+// NO_SYNC: call noundef i64 @_Z6__shflxii(
+
+// long long -> int + int
+// NO_SYNC: define{{.*}} @_Z6__shflxii
+// NO_SYNC: call noundef i32 @_Z6__shfliii(
+// NO_SYNC: call noundef i32 @_Z6__shfliii(
+
+// unsigned long long -> long long
+// SYNC: _Z11__shfl_syncjyii
+// SYNC: call noundef i64 @_Z11__shfl_syncjxii(
+
+// long long -> int + int
+// SYNC: define{{.*}} @_Z11__shfl_syncjxii
+// SYNC: call noundef i32 @_Z11__shfl_syncjiii(
+// SYNC: call noundef i32 @_Z11__shfl_syncjiii(
+
+// NO_SYNC: define{{.*}} @_Z6__shfliii
+// NO_SYNC:   call i32 @llvm.nvvm.shfl.idx.i32
+
+// SYNC: define{{.*}} @_Z11__shfl_syncjiii
+// SYNC:  call i32 @llvm.nvvm.shfl.sync.idx.i32
+
+__device__ void test_long_long() {
+  unsigned long long ull = 13;
+  long long ll = 17;
+  ull = __shfl(ull, 7, 32);
+  ll = __shfl(ll, 7, 32);
+  use(ull, ll);
+#ifdef SYNC
+  ull = __shfl_sync(0x11, ull, 7, 32);
+  ll = __shfl_sync(0x11, ll, 7, 32);
+  use(ull, ll);
+#endif
+}
+
Index: clang/lib/Headers/__clang_cuda_intrinsics.h
===
--- clang/lib/Headers/__clang_cuda_intrinsics.h
+++ clang/lib/Headers/__clang_cuda_intrinsics.h
@@ -45,7 +45,7 @@
 _Static_assert(sizeof(__val) == sizeof(__Bits));   \
 _Static_assert(sizeof(__Bits) == 2 * sizeof(int)); \
 __Bits __tmp;  \
-memcpy(&__tmp, &__val, sizeof(__val));\
+memcpy(&__tmp, &__val, sizeof(__val)); \
 __tmp.__a = ::__FnName(__tmp.__a, __offset, __width);  \
 __tmp.__b = ::__FnName(__tmp.__b, __offset, __width);  \
 long long __ret;   \
@@ -71,8 +71,8 @@
   }\
   inline __device__ unsigned long long __FnName(   \
   unsigned long long __val, __Type __offset, int __width = warpSize) { \
-return static_cast(::__FnName( \
-static_cast(__val), __offset, __width));   \
+return static_cast(\
+::__FnName(static_cast(__val), __offset, __width)); \
   }\
   inline __device__ double __FnName(double __val, __Type __offset, \
 int __width = warpSize) {  \
@@ -139,8 +139,8 @@
   inline __device__ unsigned long long __FnName(   \
   unsigned int __mask, unsigned long long __val, __Type __offset,  \
   int __width = warpSize) {\
-return static_cast(::__FnName( \
-__mask, static_cast(__val), __offset, __width));   \
+return static_cast(\
+::__FnName(__mask, static_cast(__val), __offset, __width)); \
   }\
   

[PATCH] D129104: [Modules] Add ODR Check for concepts

2022-07-11 Thread Chuanqi Xu via Phabricator via cfe-commits
ChuanqiXu added a comment.

@erichkeane @ilya-biryukov gentle ping~


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

https://reviews.llvm.org/D129104

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


[PATCH] D126907: Deferred Concept Instantiation Implementation Take 2

2022-07-11 Thread Chuanqi Xu via Phabricator via cfe-commits
ChuanqiXu added a comment.

In D126907#3642530 , @erichkeane 
wrote:

> This version passes check-runtimes, so libc++ is fine, and it passes 
> everything I have available.  @ChuanqiXu : Would you be able to do 1 more run 
> over this to make sure it won't break something?  Thanks in advance either 
> way!

I've tested some our internal workloads and all of them looks fine. But it is 
expected since we don't use concept heavily. I had tried to run libcxx before 
but it looks like my previous config is wrong...


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

https://reviews.llvm.org/D126907

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


[PATCH] D129413: [InstrProf] Allow compiler generated functions in SCL

2022-07-11 Thread Ellis Hoag via Phabricator via cfe-commits
ellis planned changes to this revision.
ellis added inline comments.



Comment at: clang/lib/CodeGen/CodeGenModule.cpp:3894-3896
+  if (getCodeGenOpts().getProfileInstr() != CodeGenOptions::ProfileNone)
+if (isProfileInstrExcluded(F, SourceLocation()))
+  F->addFnAttr(llvm::Attribute::NoProfile);

ellis wrote:
> phosek wrote:
> > Do we still need 
> > https://github.com/llvm/llvm-project/blob/759e5e0096f650515799805828f9ac5b7d4a7303/clang/lib/CodeGen/CodeGenFunction.cpp#L856
> >  if we set the attribute here?
> Both are needed. Here the attribute is added in `GetOrCreateLLVMFunction()` 
> which I believe only creates compiler generated functions. Where you linked 
> is called when normal functions are generated.
Oh sorry, I was mistaken. I'd like to figure out how to only have this code in 
one location.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D129413

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


[PATCH] D129530: [coroutine] add nomerge function attribute to `llvm.coro.save`

2022-07-11 Thread Yuanfang Chen via Phabricator via cfe-commits
ychen added a comment.

In D129530#3644094 , @ChuanqiXu wrote:

> In D129530#3644091 , @ychen wrote:
>
>> In D129530#3644074 , @ChuanqiXu 
>> wrote:
>>
>>> This looks good to me basically. I would love to see an example to test the 
>>> two coro.save wouldn't be merged.
>>
>> Yep, `hoist-skip-token.ll` is testing this.
>
> Oh, sorry. I didn't notice that. The current version should be fine.
>
> Personally, I would like to move the test to `Transforms/Coroutine` and add a 
> new test that the two `llvm.coro.suspend` are the same but they couldn't be 
> merged. This is not required.

Sure, sounds good to me. Thanks for the review!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D129530

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


[PATCH] D129530: [coroutine] add nomerge function attribute to `llvm.coro.save`

2022-07-11 Thread Yuanfang Chen via Phabricator via cfe-commits
ychen updated this revision to Diff 443818.
ychen added a comment.

- Address Chuanqi's feedback


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D129530

Files:
  clang/test/CodeGenCoroutines/coro-attributes.cpp
  llvm/docs/Coroutines.rst
  llvm/include/llvm/IR/Intrinsics.td
  llvm/lib/Transforms/Utils/SimplifyCFG.cpp
  llvm/test/Transforms/Coroutines/coro-save-nomerge.ll
  llvm/test/Transforms/SimplifyCFG/hoist-skip-token.ll

Index: llvm/test/Transforms/SimplifyCFG/hoist-skip-token.ll
===
--- llvm/test/Transforms/SimplifyCFG/hoist-skip-token.ll
+++ /dev/null
@@ -1,39 +0,0 @@
-; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
-; RUN: opt < %s -passes='simplifycfg' -S | FileCheck %s
-
-declare token @llvm.coro.save(ptr)
-declare i8 @llvm.coro.suspend(token, i1)
-
-define void @f(i32 %x) {
-; CHECK-LABEL: @f(
-; CHECK-NEXT:  entry:
-; CHECK-NEXT:[[CMP:%.*]] = icmp slt i32 [[X:%.*]], 0
-; CHECK-NEXT:br i1 [[CMP]], label [[AWAIT_SUSPEND:%.*]], label [[FINAL_SUSPEND:%.*]]
-; CHECK:   await.suspend:
-; CHECK-NEXT:[[TMP0:%.*]] = call token @llvm.coro.save(ptr null)
-; CHECK-NEXT:[[TMP1:%.*]] = call i8 @llvm.coro.suspend(token [[TMP0]], i1 false)
-; CHECK-NEXT:br label [[CORO_RET:%.*]]
-; CHECK:   final.suspend:
-; CHECK-NEXT:[[TMP2:%.*]] = call token @llvm.coro.save(ptr null)
-; CHECK-NEXT:[[TMP3:%.*]] = call i8 @llvm.coro.suspend(token [[TMP2]], i1 true)
-; CHECK-NEXT:br label [[CORO_RET]]
-; CHECK:   coro.ret:
-; CHECK-NEXT:ret void
-;
-entry:
-  %cmp = icmp slt i32 %x, 0
-  br i1 %cmp, label %await.suspend, label %final.suspend
-
-await.suspend:
-  %0 = call token @llvm.coro.save(ptr null)
-  %1 = call i8 @llvm.coro.suspend(token %0, i1 false)
-  br label %coro.ret
-
-final.suspend:
-  %2 = call token @llvm.coro.save(ptr null)
-  %3 = call i8 @llvm.coro.suspend(token %2, i1 true)
-  br label %coro.ret
-
-coro.ret:
-  ret void
-}
Index: llvm/test/Transforms/Coroutines/coro-save-nomerge.ll
===
--- /dev/null
+++ llvm/test/Transforms/Coroutines/coro-save-nomerge.ll
@@ -0,0 +1,75 @@
+; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
+; RUN: opt < %s -passes='simplifycfg' -S | FileCheck %s
+
+declare token @llvm.coro.save(ptr) #0
+declare i8 @llvm.coro.suspend(token, i1)
+
+define void @final_nonfinal_suspend(i32 %x) {
+; CHECK-LABEL: @final_nonfinal_suspend(
+; CHECK-NEXT:  entry:
+; CHECK-NEXT:[[CMP:%.*]] = icmp slt i32 [[X:%.*]], 0
+; CHECK-NEXT:br i1 [[CMP]], label [[AWAIT_SUSPEND:%.*]], label [[FINAL_SUSPEND:%.*]]
+; CHECK:   await.suspend:
+; CHECK-NEXT:[[TMP0:%.*]] = call token @llvm.coro.save(ptr null)
+; CHECK-NEXT:[[TMP1:%.*]] = call i8 @llvm.coro.suspend(token [[TMP0]], i1 false)
+; CHECK-NEXT:br label [[CORO_RET:%.*]]
+; CHECK:   final.suspend:
+; CHECK-NEXT:[[TMP2:%.*]] = call token @llvm.coro.save(ptr null)
+; CHECK-NEXT:[[TMP3:%.*]] = call i8 @llvm.coro.suspend(token [[TMP2]], i1 true)
+; CHECK-NEXT:br label [[CORO_RET]]
+; CHECK:   coro.ret:
+; CHECK-NEXT:ret void
+;
+entry:
+  %cmp = icmp slt i32 %x, 0
+  br i1 %cmp, label %await.suspend, label %final.suspend
+
+await.suspend:
+  %0 = call token @llvm.coro.save(ptr null)
+  %1 = call i8 @llvm.coro.suspend(token %0, i1 false)
+  br label %coro.ret
+
+final.suspend:
+  %2 = call token @llvm.coro.save(ptr null)
+  %3 = call i8 @llvm.coro.suspend(token %2, i1 true)
+  br label %coro.ret
+
+coro.ret:
+  ret void
+}
+
+define void @both_nonfinal_suspend(i32 %x) {
+; CHECK-LABEL: @both_nonfinal_suspend(
+; CHECK-NEXT:  entry:
+; CHECK-NEXT:[[CMP:%.*]] = icmp slt i32 [[X:%.*]], 0
+; CHECK-NEXT:br i1 [[CMP]], label [[AWAIT_SUSPEND:%.*]], label [[FINAL_SUSPEND:%.*]]
+; CHECK:   await.suspend:
+; CHECK-NEXT:[[TMP0:%.*]] = call token @llvm.coro.save(ptr null)
+; CHECK-NEXT:[[TMP1:%.*]] = call i8 @llvm.coro.suspend(token [[TMP0]], i1 false)
+; CHECK-NEXT:br label [[CORO_RET:%.*]]
+; CHECK:   final.suspend:
+; CHECK-NEXT:[[TMP2:%.*]] = call token @llvm.coro.save(ptr null)
+; CHECK-NEXT:[[TMP3:%.*]] = call i8 @llvm.coro.suspend(token [[TMP2]], i1 false)
+; CHECK-NEXT:br label [[CORO_RET]]
+; CHECK:   coro.ret:
+; CHECK-NEXT:ret void
+;
+entry:
+  %cmp = icmp slt i32 %x, 0
+  br i1 %cmp, label %await.suspend, label %final.suspend
+
+await.suspend:
+  %0 = call token @llvm.coro.save(ptr null)
+  %1 = call i8 @llvm.coro.suspend(token %0, i1 false)
+  br label %coro.ret
+
+final.suspend:
+  %2 = call token @llvm.coro.save(ptr null)
+  %3 = call i8 @llvm.coro.suspend(token %2, i1 false)
+  br label %coro.ret
+
+coro.ret:
+  ret void
+}
+
+attributes #0 = { nomerge }
Index: llvm/lib/Transforms/Utils/SimplifyCFG.cpp

[PATCH] D129534: [OpenMP] Do not link static library with `-nogpulib`

2022-07-11 Thread Joseph Huber via Phabricator via cfe-commits
jhuber6 created this revision.
jhuber6 added reviewers: jdoerfert, JonChesterfield, tianshilei1992, ABataev.
Herald added subscribers: guansong, yaxunl.
Herald added a project: All.
jhuber6 requested review of this revision.
Herald added subscribers: cfe-commits, sstefan1, MaskRay.
Herald added a project: clang.

Normally we do not link the device libraries if the user passed
`nogpulib` we do this for the standard bitcode library. This behaviour
was not added when using the static library for LTO, causing it to
always be linked in. This patch fixes that.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D129534

Files:
  clang/lib/Driver/ToolChains/CommonArgs.cpp
  clang/test/Driver/openmp-offload-gpu-new.c


Index: clang/test/Driver/openmp-offload-gpu-new.c
===
--- clang/test/Driver/openmp-offload-gpu-new.c
+++ clang/test/Driver/openmp-offload-gpu-new.c
@@ -105,11 +105,16 @@
 // RUN: --offload-device-only -E -nogpulib %s 2>&1 | FileCheck %s 
--check-prefix=CHECK-DEVICE-ONLY-PP
 // CHECK-DEVICE-ONLY-PP: "nvptx64-nvidia-cuda" - "clang", inputs: 
["[[INPUT:.*]]"], output: "-"
 
-// RUN:   %clang -### --target=x86_64-unknown-linux-gnu -fopenmp 
--offload-arch=sm_52 -nogpulib \
+// RUN:   %clang -### --target=x86_64-unknown-linux-gnu -fopenmp 
--offload-arch=sm_52 \
 // RUN: -foffload-lto %s 2>&1 | FileCheck --check-prefix=CHECK-LTO-LIBRARY 
%s
 
 // CHECK-LTO-LIBRARY: {{.*}}-lomptarget{{.*}}-lomptarget.devicertl
 
+// RUN:   %clang -### --target=x86_64-unknown-linux-gnu -fopenmp 
--offload-arch=sm_52 -nogpulib \
+// RUN: -foffload-lto %s 2>&1 | FileCheck --check-prefix=CHECK-NO-LIBRARY 
%s
+
+// CHECK-NO-LIBRARY-NOT: {{.*}}-lomptarget{{.*}}-lomptarget.devicertl
+
 // RUN:   %clang -### --target=x86_64-unknown-linux-gnu -fopenmp 
--offload-arch=sm_52 -nogpulib \
 // RUN: -Xoffload-linker a -Xoffload-linker-nvptx64-nvidia-cuda b 
-Xoffload-linker-nvptx64 c \
 // RUN: %s 2>&1 | FileCheck --check-prefix=CHECK-XLINKER %s
Index: clang/lib/Driver/ToolChains/CommonArgs.cpp
===
--- clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -727,7 +727,8 @@
   if (IsOffloadingHost)
 CmdArgs.push_back("-lomptarget");
 
-  if (IsOffloadingHost && TC.getDriver().isUsingLTO(/* IsOffload */ true))
+  if (IsOffloadingHost && TC.getDriver().isUsingLTO(/* IsOffload */ true) &&
+  !Args.hasArg(options::OPT_nogpulib))
 CmdArgs.push_back("-lomptarget.devicertl");
 
   addArchSpecificRPath(TC, Args, CmdArgs);


Index: clang/test/Driver/openmp-offload-gpu-new.c
===
--- clang/test/Driver/openmp-offload-gpu-new.c
+++ clang/test/Driver/openmp-offload-gpu-new.c
@@ -105,11 +105,16 @@
 // RUN: --offload-device-only -E -nogpulib %s 2>&1 | FileCheck %s --check-prefix=CHECK-DEVICE-ONLY-PP
 // CHECK-DEVICE-ONLY-PP: "nvptx64-nvidia-cuda" - "clang", inputs: ["[[INPUT:.*]]"], output: "-"
 
-// RUN:   %clang -### --target=x86_64-unknown-linux-gnu -fopenmp --offload-arch=sm_52 -nogpulib \
+// RUN:   %clang -### --target=x86_64-unknown-linux-gnu -fopenmp --offload-arch=sm_52 \
 // RUN: -foffload-lto %s 2>&1 | FileCheck --check-prefix=CHECK-LTO-LIBRARY %s
 
 // CHECK-LTO-LIBRARY: {{.*}}-lomptarget{{.*}}-lomptarget.devicertl
 
+// RUN:   %clang -### --target=x86_64-unknown-linux-gnu -fopenmp --offload-arch=sm_52 -nogpulib \
+// RUN: -foffload-lto %s 2>&1 | FileCheck --check-prefix=CHECK-NO-LIBRARY %s
+
+// CHECK-NO-LIBRARY-NOT: {{.*}}-lomptarget{{.*}}-lomptarget.devicertl
+
 // RUN:   %clang -### --target=x86_64-unknown-linux-gnu -fopenmp --offload-arch=sm_52 -nogpulib \
 // RUN: -Xoffload-linker a -Xoffload-linker-nvptx64-nvidia-cuda b -Xoffload-linker-nvptx64 c \
 // RUN: %s 2>&1 | FileCheck --check-prefix=CHECK-XLINKER %s
Index: clang/lib/Driver/ToolChains/CommonArgs.cpp
===
--- clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -727,7 +727,8 @@
   if (IsOffloadingHost)
 CmdArgs.push_back("-lomptarget");
 
-  if (IsOffloadingHost && TC.getDriver().isUsingLTO(/* IsOffload */ true))
+  if (IsOffloadingHost && TC.getDriver().isUsingLTO(/* IsOffload */ true) &&
+  !Args.hasArg(options::OPT_nogpulib))
 CmdArgs.push_back("-lomptarget.devicertl");
 
   addArchSpecificRPath(TC, Args, CmdArgs);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D129346: [X86] [Linux build][Stack Protector] Support for -mstack-protector-guard-symbol

2022-07-11 Thread Xiang Zhang via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGa45dd3d8140e: [X86] Support -mstack-protector-guard-symbol 
(authored by xiangzhangllvm).
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Changed prior to commit:
  https://reviews.llvm.org/D129346?vs=443583=443816#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D129346

Files:
  clang/docs/ClangCommandLineReference.rst
  clang/docs/ReleaseNotes.rst
  clang/include/clang/Basic/CodeGenOptions.h
  clang/include/clang/Driver/Options.td
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/test/Driver/stack-protector-guard.c
  llvm/docs/ReleaseNotes.rst
  llvm/include/llvm/IR/Module.h
  llvm/lib/IR/Module.cpp
  llvm/lib/Target/X86/X86ISelLowering.cpp
  llvm/test/CodeGen/X86/stack-protector-3.ll

Index: llvm/test/CodeGen/X86/stack-protector-3.ll
===
--- llvm/test/CodeGen/X86/stack-protector-3.ll
+++ llvm/test/CodeGen/X86/stack-protector-3.ll
@@ -6,6 +6,8 @@
 ; RUN: cat %t/main.ll %t/e.ll > %t/e2.ll
 ; RUN: cat %t/main.ll %t/f.ll > %t/f2.ll
 ; RUN: cat %t/main.ll %t/g.ll > %t/g2.ll
+; RUN: cat %t/main.ll %t/h.ll > %t/h2.ll
+; RUN: cat %t/existedGV.ll %t/main.ll %t/h.ll > %t/i2.ll
 ; RUN: llc -mtriple=x86_64-pc-linux-gnu -o - < %t/a2.ll | FileCheck --check-prefix=CHECK-TLS-FS-40 %s
 ; RUN: llc -mtriple=x86_64-pc-linux-gnu -o - < %t/b2.ll | FileCheck --check-prefix=CHECK-TLS-FS-40 %s
 ; RUN: llc -mtriple=x86_64-pc-linux-gnu -o - < %t/c2.ll | FileCheck --check-prefix=CHECK-GLOBAL %s
@@ -13,8 +15,8 @@
 ; RUN: llc -mtriple=x86_64-pc-linux-gnu -o - < %t/e2.ll | FileCheck --check-prefix=CHECK-GS %s
 ; RUN: llc -mtriple=x86_64-pc-linux-gnu -o - < %t/f2.ll | FileCheck --check-prefix=CHECK-OFFSET %s
 ; RUN: llc -mtriple=x86_64-pc-linux-gnu -o - < %t/g2.ll | FileCheck --check-prefix=CHECK-NEGATIVE-OFFSET %s
-
-;--- main.ll
+; RUN: llc -mtriple=x86_64-pc-linux-gnu -o - < %t/h2.ll | FileCheck --check-prefix=CHECK-SYM %s
+; RUN: llc -mtriple=x86_64-pc-linux-gnu -o - < %t/i2.ll | FileCheck --check-prefix=CHECK-SYMGV %s
 
 ; CHECK-TLS-FS-40:   movq%fs:40, %rax
 ; CHECK-TLS-FS-40:   movq%fs:40, %rax
@@ -57,7 +59,31 @@
 ; CHECK-GLOBAL-NEXT:  .cfi_def_cfa_offset 32
 ; CHECK-GLOBAL-NEXT:  callq   __stack_chk_fail
 
+; CHECK-SYM: movq__woof@GOTPCREL(%rip), %rax
+; CHECK-SYM-NEXT:movq%fs:(%rax), %rcx
+; CHECK-SYM-NEXT:movq%rcx, 16(%rsp)
+; CHECK-SYM: movq%fs:(%rax), %rax
+; CHECK-SYM-NEXT:cmpq16(%rsp), %rax
+; CHECK-SYM-NEXT:jne .LBB0_2
+; CHECK-SYM: .LBB0_2:
+; CHECK-SYM-NEXT:.cfi_def_cfa_offset 32
+; CHECK-SYM-NEXT:callq   __stack_chk_fai
+
+; CHECK-SYMGV:   movq__woof(%rip), %rax
+; CHECK-SYMGV-NEXT:  movq%rax, 16(%rsp)
+; CHECK-SYMGV:   cmpq16(%rsp), %rax
+; CHECK-SYMGV-NEXT:  jne .LBB0_2
+; CHECK-SYMGV:   .LBB0_2:
+; CHECK-SYMGV-NEXT:  .cfi_def_cfa_offset 32
+; CHECK-SYMGV-NEXT:  callq   __stack_chk_fail
+
 ; ModuleID = 't.c'
+;--- existedGV.ll
+
+@__woof = dso_local local_unnamed_addr global ptr null, align 8
+
+;--- main.ll
+
 @.str = private unnamed_addr constant [14 x i8] c"stackoverflow\00", align 1
 @a = dso_local local_unnamed_addr global ptr null, align 8
 
@@ -104,3 +130,6 @@
 ;--- g.ll
 !llvm.module.flags = !{!1}
 !1 = !{i32 2, !"stack-protector-guard-offset", i32 -20}
+;--- h.ll
+!llvm.module.flags = !{!1}
+!1 = !{i32 2, !"stack-protector-guard-symbol", !"__woof"}
Index: llvm/lib/Target/X86/X86ISelLowering.cpp
===
--- llvm/lib/Target/X86/X86ISelLowering.cpp
+++ llvm/lib/Target/X86/X86ISelLowering.cpp
@@ -2845,6 +2845,21 @@
 AddressSpace = X86AS::FS;
   else if (GuardReg == "gs")
 AddressSpace = X86AS::GS;
+
+  // Use symbol guard if user specify.
+  StringRef GuardSymb = M->getStackProtectorGuardSymbol();
+  if (!GuardSymb.empty()) {
+GlobalVariable *GV = M->getGlobalVariable(GuardSymb);
+if (!GV) {
+  Type *Ty = Subtarget.is64Bit() ? Type::getInt64Ty(M->getContext())
+ : Type::getInt32Ty(M->getContext());
+  GV = new GlobalVariable(*M, Ty, false, GlobalValue::ExternalLinkage,
+  nullptr, GuardSymb, nullptr,
+  GlobalValue::NotThreadLocal, AddressSpace);
+}
+return GV;
+  }
+
   return SegmentOffset(IRB, Offset, AddressSpace);
 }
   }
Index: llvm/lib/IR/Module.cpp
===
--- llvm/lib/IR/Module.cpp
+++ llvm/lib/IR/Module.cpp
@@ -714,6 +714,18 @@
   addModuleFlag(ModFlagBehavior::Error, "stack-protector-guard-reg", ID);
 }
 
+StringRef 

[clang] a45dd3d - [X86] Support -mstack-protector-guard-symbol

2022-07-11 Thread Xiang1 Zhang via cfe-commits

Author: Xiang1 Zhang
Date: 2022-07-12T10:17:00+08:00
New Revision: a45dd3d8140eab78a4554484c2b0435582ee262a

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

LOG: [X86] Support -mstack-protector-guard-symbol

Reviewed By: nickdesaulniers

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

Added: 


Modified: 
clang/docs/ClangCommandLineReference.rst
clang/docs/ReleaseNotes.rst
clang/include/clang/Basic/CodeGenOptions.h
clang/include/clang/Driver/Options.td
clang/lib/CodeGen/CodeGenModule.cpp
clang/lib/Driver/ToolChains/Clang.cpp
clang/test/Driver/stack-protector-guard.c
llvm/docs/ReleaseNotes.rst
llvm/include/llvm/IR/Module.h
llvm/lib/IR/Module.cpp
llvm/lib/Target/X86/X86ISelLowering.cpp
llvm/test/CodeGen/X86/stack-protector-3.ll

Removed: 




diff  --git a/clang/docs/ClangCommandLineReference.rst 
b/clang/docs/ClangCommandLineReference.rst
index ae110df4148d8..129e70d8e3f22 100644
--- a/clang/docs/ClangCommandLineReference.rst
+++ b/clang/docs/ClangCommandLineReference.rst
@@ -3285,6 +3285,10 @@ Use the given offset for addressing the stack-protector 
guard
 
 Use the given reg for addressing the stack-protector guard
 
+.. option:: -mstack-protector-guard-symbol=
+
+Use the given symbol for addressing the stack-protector guard
+
 .. option:: -mstack-protector-guard=
 
 Use the given guard (global, tls) for addressing the stack-protector guard

diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 27ba4f1c6a422..86b9b7ef471bb 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -548,6 +548,8 @@ X86 Support in Clang
 - Added the ``-m[no-]rdpru`` flag to enable/disable the RDPRU instruction
   provided by AMD Zen2 and later processors. Defined intrinsics for using
   this instruction (see rdpruintrin.h).
+- Support ``-mstack-protector-guard-symbol=[SymbolName]`` to use the given
+  symbol for addressing the stack protector guard.
 
 DWARF Support in Clang
 --

diff  --git a/clang/include/clang/Basic/CodeGenOptions.h 
b/clang/include/clang/Basic/CodeGenOptions.h
index 23d76c308d847..cd204e5d7c150 100644
--- a/clang/include/clang/Basic/CodeGenOptions.h
+++ b/clang/include/clang/Basic/CodeGenOptions.h
@@ -389,6 +389,9 @@ class CodeGenOptions : public CodeGenOptionsBase {
   /// On AArch64 this can only be "sp_el0".
   std::string StackProtectorGuardReg;
 
+  /// Specify a symbol to be the guard value.
+  std::string StackProtectorGuardSymbol;
+
   /// Path to ignorelist file specifying which objects
   /// (files, functions) listed for instrumentation by sanitizer
   /// coverage pass should actually not be instrumented.

diff  --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index 8ae9145a271a5..a1329e7532540 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -3771,6 +3771,9 @@ def mstack_protector_guard_EQ : Joined<["-"], 
"mstack-protector-guard=">, Group<
 def mstack_protector_guard_offset_EQ : Joined<["-"], 
"mstack-protector-guard-offset=">, Group, Flags<[CC1Option]>,
   HelpText<"Use the given offset for addressing the stack-protector guard">,
   MarshallingInfoInt, "INT_MAX", 
"int">;
+def mstack_protector_guard_symbol_EQ : Joined<["-"], 
"mstack-protector-guard-symbol=">, Group, Flags<[CC1Option]>,
+  HelpText<"Use the given symbol for addressing the stack-protector guard">,
+  MarshallingInfoString>;
 def mstack_protector_guard_reg_EQ : Joined<["-"], 
"mstack-protector-guard-reg=">, Group, Flags<[CC1Option]>,
   HelpText<"Use the given reg for addressing the stack-protector guard">,
   MarshallingInfoString>;

diff  --git a/clang/lib/CodeGen/CodeGenModule.cpp 
b/clang/lib/CodeGen/CodeGenModule.cpp
index 56ed59d1e3f15..cf954b7b9277e 100644
--- a/clang/lib/CodeGen/CodeGenModule.cpp
+++ b/clang/lib/CodeGen/CodeGenModule.cpp
@@ -900,6 +900,9 @@ void CodeGenModule::Release() {
   if (!getCodeGenOpts().StackProtectorGuardReg.empty())
 getModule().setStackProtectorGuardReg(
 getCodeGenOpts().StackProtectorGuardReg);
+  if (!getCodeGenOpts().StackProtectorGuardSymbol.empty())
+getModule().setStackProtectorGuardSymbol(
+getCodeGenOpts().StackProtectorGuardSymbol);
   if (getCodeGenOpts().StackProtectorGuardOffset != INT_MAX)
 getModule().setStackProtectorGuardOffset(
 getCodeGenOpts().StackProtectorGuardOffset);

diff  --git a/clang/lib/Driver/ToolChains/Clang.cpp 
b/clang/lib/Driver/ToolChains/Clang.cpp
index aae416f19fbd5..ec1a31fa71d55 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -3231,6 +3231,16 @@ static void RenderAnalyzerOptions(const ArgList , 
ArgStringList ,
   

[PATCH] D129530: [coroutine] add nomerge function attribute to `llvm.coro.save`

2022-07-11 Thread Chuanqi Xu via Phabricator via cfe-commits
ChuanqiXu accepted this revision.
ChuanqiXu added a comment.
This revision is now accepted and ready to land.

In D129530#3644091 , @ychen wrote:

> In D129530#3644074 , @ChuanqiXu 
> wrote:
>
>> This looks good to me basically. I would love to see an example to test the 
>> two coro.save wouldn't be merged.
>
> Yep, `hoist-skip-token.ll` is testing this.

Oh, sorry. I didn't notice that. The current version should be fine.

Personally, I would like to move the test to `Transforms/Coroutine` and add a 
new test that the two `llvm.coro.suspend` are the same but they couldn't be 
merged. This is not required.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D129530

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


[clang] 6437862 - Revert "[X86] Support -mstack-protector-guard-symbol"

2022-07-11 Thread Xiang1 Zhang via cfe-commits

Author: Xiang1 Zhang
Date: 2022-07-12T10:14:32+08:00
New Revision: 643786213b34c7bd971c14db63dfbae8bb979997

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

LOG: Revert "[X86] Support -mstack-protector-guard-symbol"

This reverts commit efbaad1c4a526e91b034e56386e98a9268cd87b2.
due to miss adding review info.

Added: 


Modified: 
clang/docs/ClangCommandLineReference.rst
clang/docs/ReleaseNotes.rst
clang/include/clang/Basic/CodeGenOptions.h
clang/include/clang/Driver/Options.td
clang/lib/CodeGen/CodeGenModule.cpp
clang/lib/Driver/ToolChains/Clang.cpp
clang/test/Driver/stack-protector-guard.c
llvm/docs/ReleaseNotes.rst
llvm/include/llvm/IR/Module.h
llvm/lib/IR/Module.cpp
llvm/lib/Target/X86/X86ISelLowering.cpp
llvm/test/CodeGen/X86/stack-protector-3.ll

Removed: 




diff  --git a/clang/docs/ClangCommandLineReference.rst 
b/clang/docs/ClangCommandLineReference.rst
index 129e70d8e3f22..ae110df4148d8 100644
--- a/clang/docs/ClangCommandLineReference.rst
+++ b/clang/docs/ClangCommandLineReference.rst
@@ -3285,10 +3285,6 @@ Use the given offset for addressing the stack-protector 
guard
 
 Use the given reg for addressing the stack-protector guard
 
-.. option:: -mstack-protector-guard-symbol=
-
-Use the given symbol for addressing the stack-protector guard
-
 .. option:: -mstack-protector-guard=
 
 Use the given guard (global, tls) for addressing the stack-protector guard

diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 86b9b7ef471bb..27ba4f1c6a422 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -548,8 +548,6 @@ X86 Support in Clang
 - Added the ``-m[no-]rdpru`` flag to enable/disable the RDPRU instruction
   provided by AMD Zen2 and later processors. Defined intrinsics for using
   this instruction (see rdpruintrin.h).
-- Support ``-mstack-protector-guard-symbol=[SymbolName]`` to use the given
-  symbol for addressing the stack protector guard.
 
 DWARF Support in Clang
 --

diff  --git a/clang/include/clang/Basic/CodeGenOptions.h 
b/clang/include/clang/Basic/CodeGenOptions.h
index cd204e5d7c150..23d76c308d847 100644
--- a/clang/include/clang/Basic/CodeGenOptions.h
+++ b/clang/include/clang/Basic/CodeGenOptions.h
@@ -389,9 +389,6 @@ class CodeGenOptions : public CodeGenOptionsBase {
   /// On AArch64 this can only be "sp_el0".
   std::string StackProtectorGuardReg;
 
-  /// Specify a symbol to be the guard value.
-  std::string StackProtectorGuardSymbol;
-
   /// Path to ignorelist file specifying which objects
   /// (files, functions) listed for instrumentation by sanitizer
   /// coverage pass should actually not be instrumented.

diff  --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index a1329e7532540..8ae9145a271a5 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -3771,9 +3771,6 @@ def mstack_protector_guard_EQ : Joined<["-"], 
"mstack-protector-guard=">, Group<
 def mstack_protector_guard_offset_EQ : Joined<["-"], 
"mstack-protector-guard-offset=">, Group, Flags<[CC1Option]>,
   HelpText<"Use the given offset for addressing the stack-protector guard">,
   MarshallingInfoInt, "INT_MAX", 
"int">;
-def mstack_protector_guard_symbol_EQ : Joined<["-"], 
"mstack-protector-guard-symbol=">, Group, Flags<[CC1Option]>,
-  HelpText<"Use the given symbol for addressing the stack-protector guard">,
-  MarshallingInfoString>;
 def mstack_protector_guard_reg_EQ : Joined<["-"], 
"mstack-protector-guard-reg=">, Group, Flags<[CC1Option]>,
   HelpText<"Use the given reg for addressing the stack-protector guard">,
   MarshallingInfoString>;

diff  --git a/clang/lib/CodeGen/CodeGenModule.cpp 
b/clang/lib/CodeGen/CodeGenModule.cpp
index cf954b7b9277e..56ed59d1e3f15 100644
--- a/clang/lib/CodeGen/CodeGenModule.cpp
+++ b/clang/lib/CodeGen/CodeGenModule.cpp
@@ -900,9 +900,6 @@ void CodeGenModule::Release() {
   if (!getCodeGenOpts().StackProtectorGuardReg.empty())
 getModule().setStackProtectorGuardReg(
 getCodeGenOpts().StackProtectorGuardReg);
-  if (!getCodeGenOpts().StackProtectorGuardSymbol.empty())
-getModule().setStackProtectorGuardSymbol(
-getCodeGenOpts().StackProtectorGuardSymbol);
   if (getCodeGenOpts().StackProtectorGuardOffset != INT_MAX)
 getModule().setStackProtectorGuardOffset(
 getCodeGenOpts().StackProtectorGuardOffset);

diff  --git a/clang/lib/Driver/ToolChains/Clang.cpp 
b/clang/lib/Driver/ToolChains/Clang.cpp
index ec1a31fa71d55..aae416f19fbd5 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -3231,16 +3231,6 @@ static void RenderAnalyzerOptions(const ArgList , 
ArgStringList ,
   

[clang] efbaad1 - [X86] Support -mstack-protector-guard-symbol

2022-07-11 Thread Xiang1 Zhang via cfe-commits

Author: Xiang1 Zhang
Date: 2022-07-12T10:13:48+08:00
New Revision: efbaad1c4a526e91b034e56386e98a9268cd87b2

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

LOG: [X86] Support -mstack-protector-guard-symbol

Added: 


Modified: 
clang/docs/ClangCommandLineReference.rst
clang/docs/ReleaseNotes.rst
clang/include/clang/Basic/CodeGenOptions.h
clang/include/clang/Driver/Options.td
clang/lib/CodeGen/CodeGenModule.cpp
clang/lib/Driver/ToolChains/Clang.cpp
clang/test/Driver/stack-protector-guard.c
llvm/docs/ReleaseNotes.rst
llvm/include/llvm/IR/Module.h
llvm/lib/IR/Module.cpp
llvm/lib/Target/X86/X86ISelLowering.cpp
llvm/test/CodeGen/X86/stack-protector-3.ll

Removed: 




diff  --git a/clang/docs/ClangCommandLineReference.rst 
b/clang/docs/ClangCommandLineReference.rst
index ae110df4148d8..129e70d8e3f22 100644
--- a/clang/docs/ClangCommandLineReference.rst
+++ b/clang/docs/ClangCommandLineReference.rst
@@ -3285,6 +3285,10 @@ Use the given offset for addressing the stack-protector 
guard
 
 Use the given reg for addressing the stack-protector guard
 
+.. option:: -mstack-protector-guard-symbol=
+
+Use the given symbol for addressing the stack-protector guard
+
 .. option:: -mstack-protector-guard=
 
 Use the given guard (global, tls) for addressing the stack-protector guard

diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 27ba4f1c6a422..86b9b7ef471bb 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -548,6 +548,8 @@ X86 Support in Clang
 - Added the ``-m[no-]rdpru`` flag to enable/disable the RDPRU instruction
   provided by AMD Zen2 and later processors. Defined intrinsics for using
   this instruction (see rdpruintrin.h).
+- Support ``-mstack-protector-guard-symbol=[SymbolName]`` to use the given
+  symbol for addressing the stack protector guard.
 
 DWARF Support in Clang
 --

diff  --git a/clang/include/clang/Basic/CodeGenOptions.h 
b/clang/include/clang/Basic/CodeGenOptions.h
index 23d76c308d847..cd204e5d7c150 100644
--- a/clang/include/clang/Basic/CodeGenOptions.h
+++ b/clang/include/clang/Basic/CodeGenOptions.h
@@ -389,6 +389,9 @@ class CodeGenOptions : public CodeGenOptionsBase {
   /// On AArch64 this can only be "sp_el0".
   std::string StackProtectorGuardReg;
 
+  /// Specify a symbol to be the guard value.
+  std::string StackProtectorGuardSymbol;
+
   /// Path to ignorelist file specifying which objects
   /// (files, functions) listed for instrumentation by sanitizer
   /// coverage pass should actually not be instrumented.

diff  --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index 8ae9145a271a5..a1329e7532540 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -3771,6 +3771,9 @@ def mstack_protector_guard_EQ : Joined<["-"], 
"mstack-protector-guard=">, Group<
 def mstack_protector_guard_offset_EQ : Joined<["-"], 
"mstack-protector-guard-offset=">, Group, Flags<[CC1Option]>,
   HelpText<"Use the given offset for addressing the stack-protector guard">,
   MarshallingInfoInt, "INT_MAX", 
"int">;
+def mstack_protector_guard_symbol_EQ : Joined<["-"], 
"mstack-protector-guard-symbol=">, Group, Flags<[CC1Option]>,
+  HelpText<"Use the given symbol for addressing the stack-protector guard">,
+  MarshallingInfoString>;
 def mstack_protector_guard_reg_EQ : Joined<["-"], 
"mstack-protector-guard-reg=">, Group, Flags<[CC1Option]>,
   HelpText<"Use the given reg for addressing the stack-protector guard">,
   MarshallingInfoString>;

diff  --git a/clang/lib/CodeGen/CodeGenModule.cpp 
b/clang/lib/CodeGen/CodeGenModule.cpp
index 56ed59d1e3f15..cf954b7b9277e 100644
--- a/clang/lib/CodeGen/CodeGenModule.cpp
+++ b/clang/lib/CodeGen/CodeGenModule.cpp
@@ -900,6 +900,9 @@ void CodeGenModule::Release() {
   if (!getCodeGenOpts().StackProtectorGuardReg.empty())
 getModule().setStackProtectorGuardReg(
 getCodeGenOpts().StackProtectorGuardReg);
+  if (!getCodeGenOpts().StackProtectorGuardSymbol.empty())
+getModule().setStackProtectorGuardSymbol(
+getCodeGenOpts().StackProtectorGuardSymbol);
   if (getCodeGenOpts().StackProtectorGuardOffset != INT_MAX)
 getModule().setStackProtectorGuardOffset(
 getCodeGenOpts().StackProtectorGuardOffset);

diff  --git a/clang/lib/Driver/ToolChains/Clang.cpp 
b/clang/lib/Driver/ToolChains/Clang.cpp
index aae416f19fbd5..ec1a31fa71d55 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -3231,6 +3231,16 @@ static void RenderAnalyzerOptions(const ArgList , 
ArgStringList ,
   Args.AddAllArgValues(CmdArgs, options::OPT_Xanalyzer);
 }
 
+static bool isValidSymbolName(StringRef S) {
+ 

[PATCH] D129530: [coroutine] add nomerge function attribute to `llvm.coro.save`

2022-07-11 Thread Yuanfang Chen via Phabricator via cfe-commits
ychen added a comment.

In D129530#3644074 , @ChuanqiXu wrote:

> This looks good to me basically. I would love to see an example to test the 
> two coro.save wouldn't be merged.

Yep, `hoist-skip-token.ll` is testing this.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D129530

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


[PATCH] D129530: [coroutine] add nomerge function attribute to `llvm.coro.save`

2022-07-11 Thread Chuanqi Xu via Phabricator via cfe-commits
ChuanqiXu added a comment.

This looks good to me basically. I would love to see an example to test the two 
coro.save wouldn't be merged.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D129530

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


[PATCH] D126189: [C++20][Modules] Build module static initializers per P1874R1.

2022-07-11 Thread David Blaikie via Phabricator via cfe-commits
dblaikie added a comment.

> hmm there seems to be a compiler error, which looks somewhat unrelated to the 
> active patch:
>
>   
> /Users/buildslave/jenkins/workspace/lldb-cmake/llvm-project/cross-project-tests/debuginfo-tests/clang_llvm_roundtrip/simplified_template_names.cpp:125:27:
>  error: no type named 'size_t' in namespace 'std'
> void* operator new(std::size_t, T) {
>~^
>   
> /Users/buildslave/jenkins/workspace/lldb-cmake/llvm-project/cross-project-tests/debuginfo-tests/clang_llvm_roundtrip/simplified_template_names.cpp:132:29:
>  error: no type named 'size_t' in namespace 'std'
> void* operator new[](std::size_t, T) {

Added the missing include here 4ca205855267191ccfd191539cf4b3ed792a4257 



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D126189

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


[PATCH] D125693: [DebugInfo] Support types, imports and static locals declared in a lexical block (3/5)

2022-07-11 Thread David Blaikie via Phabricator via cfe-commits
dblaikie added a subscriber: JDevlieghere.
dblaikie added a comment.

In D125693#3641742 , @krisb wrote:

> @dblaikie, could you please take a look at this and/or D113741 
> ? Do you see any ways to proceed?

My concern with this direction is that anything that adds lists to the IR 
metadata makes it difficult for that data to be dropped when it becomes unused 
(the type graph, apart from the "retained types" on the CU, is structured so 
that if a variable, say, gets optimized away, or a function gets optimized away 
and its parameters along with it, the types get dropped too - similarly with 
function descriptions, they aren't in a list (they used to be) and are instead 
referenced from the `llvm::Function` ensuring that if the function is optimized 
away entirely, the debug info for that goes away too). Admittedly 
function-local things are handled somewhat differently, for instance there is a 
list on the `DISubprogram` of the local variables to ensure they are retained 
through optimizations so name lookup does the right things at function-scope. 
So /maybe/ it's OK to move in that direction here, but it might look more like 
that, add these other function-local things to the `DISubprogram`-scoped list 
(rename the list to generalize over more than just variables), rather than 
adding per-scope lists?

(@aprantl @JDevlieghere @probinson - what do you folks think? Add these things 
to some list (be it on the scope itself, or on a/the existing list on the 
subprogram metadata) or go with the lazy-referenced style already in-place and 
proposed in https://reviews.llvm.org/D113741 though some issues are discussed 
with that. I'm not sure if those are solvable problems?)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D125693

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


[PATCH] D118350: [Clang][Sema][AIX][PowerPC] Emit byval alignment warning only when struct is passed to a function

2022-07-11 Thread Zarko Todorovski via Phabricator via cfe-commits
ZarkoCA updated this revision to Diff 443812.
ZarkoCA added a comment.

- Rebase and add FDecl check before calling checkAIXMemberAlignment()


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D118350

Files:
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Sema/Sema.h
  clang/lib/Sema/SemaChecking.cpp
  clang/lib/Sema/SemaDeclAttr.cpp
  clang/test/Analysis/padding_c.c
  clang/test/Analysis/padding_cpp.cpp
  clang/test/CXX/drs/dr6xx.cpp
  clang/test/Sema/aix-attr-align.c
  clang/test/SemaTemplate/instantiate-attr.cpp

Index: clang/test/SemaTemplate/instantiate-attr.cpp
===
--- clang/test/SemaTemplate/instantiate-attr.cpp
+++ clang/test/SemaTemplate/instantiate-attr.cpp
@@ -1,7 +1,4 @@
-// FIXME -Wno-aix-compat added temporarily while the diagnostic is being
-// refined.
-
-// RUN: %clang_cc1 -fsyntax-only -verify -Wno-aix-compat %s
+// RUN: %clang_cc1 -fsyntax-only -verify %s
 // expected-no-diagnostics
 template 
 struct A {
Index: clang/test/Sema/aix-attr-align.c
===
--- clang/test/Sema/aix-attr-align.c
+++ clang/test/Sema/aix-attr-align.c
@@ -5,18 +5,37 @@
 // RUN: %clang_cc1 -triple powerpc-ibm-aix-xcoff -verify=off -Wno-aix-compat -fsyntax-only %s
 // RUN: %clang_cc1 -triple powerpc64le-unknown-linux -verify=off -fsyntax-only %s
 
-struct S {
-  int a[8] __attribute__((aligned(8))); // no-warning
+// We do not warn on any declaration with a member aligned 16. Only when the struct is passed byval.
+struct R {
+  int b[8] __attribute__((aligned(16))); // no-warning
 };
 
-struct T {
-  int a[4] __attribute__((aligned(16))); // expected-warning {{requesting an alignment of 16 bytes or greater for struct members is not binary compatible with IBM XL C/C++ for AIX 16.1.0 and older}}
+struct S {
+  int a[8] __attribute__((aligned(8)));  // no-warning
+  int b[8] __attribute__((aligned(16))); // expected-warning {{alignment of 16 bytes for a struct member is not binary compatible with IBM XL C/C++ for AIX 16.1.0 or older}}
 };
 
-struct U {
-  int a[2] __attribute__((aligned(32))); // expected-warning {{requesting an alignment of 16 bytes or greater for struct members is not binary compatible with IBM XL C/C++ for AIX 16.1.0 and older}}
+struct T {
+  int a[8] __attribute__((aligned(8))); // no-warning
+  int b[8] __attribute__((aligned(4))); // no-warning
 };
 
 int a[8] __attribute__((aligned(8)));  // no-warning
 int b[4] __attribute__((aligned(16))); // no-warning
-int c[2] __attribute__((aligned(32))); // no-warning
+
+void baz(int a, int b, int *c, int d, int *e, int f, struct S);
+void jaz(int a, int b, int *c, int d, int *e, int f, struct T);
+void vararg_baz(int a,...);
+static void static_baz(int a, int b, int *c, int d, int *e, int f, struct S sp2) {
+  a = *sp2.b + *c + *e;
+}
+
+void foo(int p1, int p2, int p3, int p4, int p5, int p6, int p7, int p8,
+ struct S s, struct T t) {
+
+  baz(p1, p2, s.b, p3, b, p5, s);// expected-note {{passing byval argument 's' with potentially incompatible alignment here}}
+  jaz(p1, p2, a, p3, s.a, p5, t);// no-note
+  jaz(p1, p2, s.b, p3, b, p5, t);// no-note
+  vararg_baz(p1, p2, s.b, p3, b, p5, s); // no-note
+  static_baz(p1, p2, s.b, p3, b, p5, s); // no-note
+}
Index: clang/test/CXX/drs/dr6xx.cpp
===
--- clang/test/CXX/drs/dr6xx.cpp
+++ clang/test/CXX/drs/dr6xx.cpp
@@ -1,10 +1,8 @@
-// FIXME -Wno-aix-compat added temporarily while the diagnostic is being
-// refined.
-// RUN: %clang_cc1 -std=c++98 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors -fno-spell-checking -Wno-aix-compat
-// RUN: %clang_cc1 -std=c++11 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors -fno-spell-checking -Wno-aix-compat
-// RUN: %clang_cc1 -std=c++14 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors -fno-spell-checking -Wno-aix-compat
-// RUN: %clang_cc1 -std=c++17 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors -fno-spell-checking -Wno-aix-compat
-// RUN: %clang_cc1 -std=c++20 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors -fno-spell-checking -Wno-aix-compat
+// RUN: %clang_cc1 -std=c++98 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors -fno-spell-checking
+// RUN: %clang_cc1 -std=c++11 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors -fno-spell-checking
+// RUN: %clang_cc1 -std=c++14 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors -fno-spell-checking
+// RUN: %clang_cc1 -std=c++17 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors -fno-spell-checking
+// RUN: %clang_cc1 -std=c++20 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors -fno-spell-checking
 
 namespace std {
   struct type_info {};
Index: clang/test/Analysis/padding_cpp.cpp

[PATCH] D128914: [HIP] Add support for handling HIP in the linker wrapper

2022-07-11 Thread Joseph Huber via Phabricator via cfe-commits
jhuber6 added a comment.

In D128914#3644022 , @thakis wrote:

> This breaks check-clang on mac: http://45.33.8.238/macm1/39907/step_7.txt
>
> Please take a look and revert for now if it takes a while to fix.

Let me know if rGfe6a391357fc 
 resolved 
the issue.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128914

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


[clang] fe6a391 - [Clang] Fix tests failing due to invalid syntax for host triple

2022-07-11 Thread Joseph Huber via cfe-commits

Author: Joseph Huber
Date: 2022-07-11T21:31:56-04:00
New Revision: fe6a391357fcf0823a97a9a3814572655c3b3b74

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

LOG: [Clang] Fix tests failing due to invalid syntax for host triple

Summary:
We use the `--host-triple=` argument to manually set the target triple.
This was changed to include the `=` previously but was not included in
these additional test cases, causing it for fail on some unsupported
systems.

Added: 


Modified: 
clang/test/Driver/linker-wrapper-image.c
clang/test/Driver/linker-wrapper.c

Removed: 




diff  --git a/clang/test/Driver/linker-wrapper-image.c 
b/clang/test/Driver/linker-wrapper-image.c
index 59f2014e466e8..c1d29b66209d1 100644
--- a/clang/test/Driver/linker-wrapper-image.c
+++ b/clang/test/Driver/linker-wrapper-image.c
@@ -114,7 +114,7 @@
 // RUN: clang-offload-packager -o %t.out 
--image=file=%S/Inputs/dummy-elf.o,kind=hip,triple=amdgcn-amd-amdhsa,arch=gfx908
 // RUN: %clang -cc1 %s -triple x86_64-unknown-linux-gnu -emit-obj -o %t.o \
 // RUN:   -fembed-offload-object=%t.out
-// RUN: clang-linker-wrapper --print-wrapped-module --dry-run --host-triple 
x86_64-unknown-linux-gnu \
+// RUN: clang-linker-wrapper --print-wrapped-module --dry-run 
--host-triple=x86_64-unknown-linux-gnu \
 // RUN:   -linker-path /usr/bin/ld -- %t.o -o a.out 2>&1 | FileCheck %s 
--check-prefix=HIP
 
 //  HIP: @.fatbin_image = internal constant [0 x i8] zeroinitializer, 
section ".hip_fatbin"

diff  --git a/clang/test/Driver/linker-wrapper.c 
b/clang/test/Driver/linker-wrapper.c
index b8ec9efc0b84e..21a811e85a375 100644
--- a/clang/test/Driver/linker-wrapper.c
+++ b/clang/test/Driver/linker-wrapper.c
@@ -97,7 +97,7 @@
 // RUN:   
--image=file=%S/Inputs/dummy-elf.o,kind=hip,triple=amdgcn-amd-amdhsa,arch=gfx908
 // RUN: %clang -cc1 %s -triple x86_64-unknown-linux-gnu -emit-obj -o %t.o \
 // RUN:   -fembed-offload-object=%t.out
-// RUN: clang-linker-wrapper --dry-run --host-triple x86_64-unknown-linux-gnu 
-linker-path \
+// RUN: clang-linker-wrapper --dry-run --host-triple=x86_64-unknown-linux-gnu 
-linker-path \
 // RUN:   /usr/bin/ld -- %t.o -o a.out 2>&1 | FileCheck %s --check-prefix=HIP
 
 // HIP: lld{{.*}}-flavor gnu --no-undefined -shared 
-plugin-opt=-amdgpu-internalize-symbols -plugin-opt=mcpu=gfx908 -o {{.*}}.out 
{{.*}}.o



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


[PATCH] D128914: [HIP] Add support for handling HIP in the linker wrapper

2022-07-11 Thread Joseph Huber via Phabricator via cfe-commits
jhuber6 added a comment.

In D128914#3644022 , @thakis wrote:

> This breaks check-clang on mac: http://45.33.8.238/macm1/39907/step_7.txt
>
> Please take a look and revert for now if it takes a while to fix.

I changed some of the argument formats in a previous patch, probably messed up 
the rebase. I'll try to land a patch real quick.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128914

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


[PATCH] D128914: [HIP] Add support for handling HIP in the linker wrapper

2022-07-11 Thread Nico Weber via Phabricator via cfe-commits
thakis added a comment.

This breaks check-clang on mac: http://45.33.8.238/macm1/39907/step_7.txt

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


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128914

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


[PATCH] D127304: [LinkerWrapper] Embed OffloadBinaries for OpenMP offloading images

2022-07-11 Thread Joseph Huber via Phabricator via cfe-commits
jhuber6 updated this revision to Diff 443810.
jhuber6 added a comment.

Removing `.image` from section name. This was originally done to avoid it 
getting the `SHF_EXCLUDE` flag when it should not be removed by the linker. 
That behaviour was moved to the `!exclude` metadata in a previous patch.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D127304

Files:
  clang/test/Driver/linker-wrapper-image.c
  clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp
  clang/tools/clang-linker-wrapper/OffloadWrapper.cpp


Index: clang/tools/clang-linker-wrapper/OffloadWrapper.cpp
===
--- clang/tools/clang-linker-wrapper/OffloadWrapper.cpp
+++ clang/tools/clang-linker-wrapper/OffloadWrapper.cpp
@@ -14,6 +14,7 @@
 #include "llvm/IR/IRBuilder.h"
 #include "llvm/IR/LLVMContext.h"
 #include "llvm/IR/Module.h"
+#include "llvm/Object/OffloadBinary.h"
 #include "llvm/Support/Error.h"
 #include "llvm/Transforms/Utils/ModuleUtils.h"
 
@@ -184,6 +185,8 @@
  GlobalVariable::InternalLinkage, Data,
  ".omp_offloading.device_image");
 Image->setUnnamedAddr(GlobalValue::UnnamedAddr::Global);
+Image->setSection(".llvm.offloading");
+Image->setAlignment(Align(object::OffloadBinary::getAlignment()));
 
 auto *Size = ConstantInt::get(getSizeTTy(M), Buf.size());
 Constant *ZeroSize[] = {Zero, Size};
Index: clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp
===
--- clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp
+++ clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp
@@ -1161,8 +1161,7 @@
 bundleOpenMP(ArrayRef Images) {
   SmallVector> Buffers;
   for (const OffloadingImage  : Images)
-Buffers.emplace_back(
-MemoryBuffer::getMemBufferCopy(Image.Image->getBuffer()));
+Buffers.emplace_back(OffloadBinary::write(Image));
 
   return std::move(Buffers);
 }
Index: clang/test/Driver/linker-wrapper-image.c
===
--- clang/test/Driver/linker-wrapper-image.c
+++ clang/test/Driver/linker-wrapper-image.c
@@ -11,8 +11,8 @@
 //  OPENMP: @__start_omp_offloading_entries = external hidden constant 
%__tgt_offload_entry
 // OPENMP-NEXT: @__stop_omp_offloading_entries = external hidden constant 
%__tgt_offload_entry
 // OPENMP-NEXT: @__dummy.omp_offloading.entry = hidden constant [0 x 
%__tgt_offload_entry] zeroinitializer, section "omp_offloading_entries"
-// OPENMP-NEXT: @.omp_offloading.device_image = internal unnamed_addr constant 
[0 x i8] zeroinitializer
-// OPENMP-NEXT: @.omp_offloading.device_images = internal unnamed_addr 
constant [1 x %__tgt_device_image] [%__tgt_device_image { ptr 
@.omp_offloading.device_image, ptr @.omp_offloading.device_image, ptr 
@__start_omp_offloading_entries, ptr @__stop_omp_offloading_entries }]
+// OPENMP-NEXT: @.omp_offloading.device_image = internal unnamed_addr constant 
[[[SIZE:[0-9]+]] x i8] c"\10\FF\10\AD{{.*}}"
+// OPENMP-NEXT: @.omp_offloading.device_images = internal unnamed_addr 
constant [1 x %__tgt_device_image] [%__tgt_device_image { ptr 
@.omp_offloading.device_image, ptr getelementptr inbounds ([[[SIZE]] x i8], ptr 
@.omp_offloading.device_image, i64 1, i64 0), ptr 
@__start_omp_offloading_entries, ptr @__stop_omp_offloading_entries }]
 // OPENMP-NEXT: @.omp_offloading.descriptor = internal constant 
%__tgt_bin_desc { i32 1, ptr @.omp_offloading.device_images, ptr 
@__start_omp_offloading_entries, ptr @__stop_omp_offloading_entries }
 // OPENMP-NEXT: @llvm.global_ctors = appending global [1 x { i32, ptr, ptr }] 
[{ i32, ptr, ptr } { i32 1, ptr @.omp_offloading.descriptor_reg, ptr null }]
 // OPENMP-NEXT: @llvm.global_dtors = appending global [1 x { i32, ptr, ptr }] 
[{ i32, ptr, ptr } { i32 1, ptr @.omp_offloading.descriptor_unreg, ptr null }]


Index: clang/tools/clang-linker-wrapper/OffloadWrapper.cpp
===
--- clang/tools/clang-linker-wrapper/OffloadWrapper.cpp
+++ clang/tools/clang-linker-wrapper/OffloadWrapper.cpp
@@ -14,6 +14,7 @@
 #include "llvm/IR/IRBuilder.h"
 #include "llvm/IR/LLVMContext.h"
 #include "llvm/IR/Module.h"
+#include "llvm/Object/OffloadBinary.h"
 #include "llvm/Support/Error.h"
 #include "llvm/Transforms/Utils/ModuleUtils.h"
 
@@ -184,6 +185,8 @@
  GlobalVariable::InternalLinkage, Data,
  ".omp_offloading.device_image");
 Image->setUnnamedAddr(GlobalValue::UnnamedAddr::Global);
+Image->setSection(".llvm.offloading");
+Image->setAlignment(Align(object::OffloadBinary::getAlignment()));
 
 auto *Size = ConstantInt::get(getSizeTTy(M), Buf.size());
 Constant *ZeroSize[] = {Zero, Size};
Index: 

[PATCH] D129530: [coroutine] add nomerge function attribute to `llvm.coro.save`

2022-07-11 Thread Yuanfang Chen via Phabricator via cfe-commits
ychen created this revision.
ychen added reviewers: nikic, ChuanqiXu.
Herald added subscribers: jdoerfert, hiraditya.
Herald added a project: All.
ychen requested review of this revision.
Herald added projects: clang, LLVM.
Herald added subscribers: llvm-commits, cfe-commits.

It is illegal to merge two `llvm.coro.save` calls unless their
`llvm.coro.suspend` users are also merged. Marks it "nomerge" for
the moment.

This reverts D129025 .

Alternative to D129025 , which affects other 
token type users like WinEH.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D129530

Files:
  clang/test/CodeGenCoroutines/coro-attributes.cpp
  llvm/docs/Coroutines.rst
  llvm/include/llvm/IR/Intrinsics.td
  llvm/lib/Transforms/Utils/SimplifyCFG.cpp
  llvm/test/Transforms/SimplifyCFG/hoist-skip-token.ll


Index: llvm/test/Transforms/SimplifyCFG/hoist-skip-token.ll
===
--- llvm/test/Transforms/SimplifyCFG/hoist-skip-token.ll
+++ llvm/test/Transforms/SimplifyCFG/hoist-skip-token.ll
@@ -1,7 +1,7 @@
 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
 ; RUN: opt < %s -passes='simplifycfg' -S | FileCheck %s
 
-declare token @llvm.coro.save(ptr)
+declare token @llvm.coro.save(ptr) #0
 declare i8 @llvm.coro.suspend(token, i1)
 
 define void @f(i32 %x) {
@@ -37,3 +37,5 @@
 coro.ret:
   ret void
 }
+
+attributes #0 = { nomerge }
Index: llvm/lib/Transforms/Utils/SimplifyCFG.cpp
===
--- llvm/lib/Transforms/Utils/SimplifyCFG.cpp
+++ llvm/lib/Transforms/Utils/SimplifyCFG.cpp
@@ -1499,10 +1499,6 @@
 if (I1->isTerminator())
   goto HoistTerminator;
 
-// Hoisting token-returning instructions would obscure the origin.
-if (I1->getType()->isTokenTy())
-  return Changed;
-
 // If we're going to hoist a call, make sure that the two instructions 
we're
 // commoning/hoisting are both marked with musttail, or neither of them is
 // marked as such. Otherwise, we might end up in a situation where we hoist
Index: llvm/include/llvm/IR/Intrinsics.td
===
--- llvm/include/llvm/IR/Intrinsics.td
+++ llvm/include/llvm/IR/Intrinsics.td
@@ -1308,7 +1308,7 @@
 def int_coro_size : Intrinsic<[llvm_anyint_ty], [], [IntrNoMem]>;
 def int_coro_align : Intrinsic<[llvm_anyint_ty], [], [IntrNoMem]>;
 
-def int_coro_save : Intrinsic<[llvm_token_ty], [llvm_ptr_ty], []>;
+def int_coro_save : Intrinsic<[llvm_token_ty], [llvm_ptr_ty], [IntrNoMerge]>;
 def int_coro_suspend : Intrinsic<[llvm_i8_ty], [llvm_token_ty, llvm_i1_ty], 
[]>;
 def int_coro_suspend_retcon : Intrinsic<[llvm_any_ty], [llvm_vararg_ty], []>;
 def int_coro_prepare_retcon : Intrinsic<[llvm_ptr_ty], [llvm_ptr_ty],
Index: llvm/docs/Coroutines.rst
===
--- llvm/docs/Coroutines.rst
+++ llvm/docs/Coroutines.rst
@@ -1555,7 +1555,9 @@
 
 The '``llvm.coro.save``' marks the point where a coroutine need to update its
 state to prepare for resumption to be considered suspended (and thus eligible
-for resumption).
+for resumption). It is illegal to merge two '``llvm.coro.save``' calls unless 
their
+'``llvm.coro.suspend``' users are also merged. So '``llvm.coro.save``' is 
currently
+tagged with the `no_merge` function attribute.
 
 Arguments:
 ""
Index: clang/test/CodeGenCoroutines/coro-attributes.cpp
===
--- clang/test/CodeGenCoroutines/coro-attributes.cpp
+++ clang/test/CodeGenCoroutines/coro-attributes.cpp
@@ -14,7 +14,9 @@
 };
 
 // CHECK: void @_Z3foov() #[[FOO_ATTR_NUM:[0-9]+]]
+// CHECK: declare token @llvm.coro.save(ptr) #[[SAVE_ATTR_NUM:[0-9]+]]
 // CHECK: attributes #[[FOO_ATTR_NUM]] = { {{.*}} presplitcoroutine
+// CHECK: attributes #[[SAVE_ATTR_NUM]] = { {{.*}}nomerge
 coro foo() {
   co_await suspend_always{};
 }


Index: llvm/test/Transforms/SimplifyCFG/hoist-skip-token.ll
===
--- llvm/test/Transforms/SimplifyCFG/hoist-skip-token.ll
+++ llvm/test/Transforms/SimplifyCFG/hoist-skip-token.ll
@@ -1,7 +1,7 @@
 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
 ; RUN: opt < %s -passes='simplifycfg' -S | FileCheck %s
 
-declare token @llvm.coro.save(ptr)
+declare token @llvm.coro.save(ptr) #0
 declare i8 @llvm.coro.suspend(token, i1)
 
 define void @f(i32 %x) {
@@ -37,3 +37,5 @@
 coro.ret:
   ret void
 }
+
+attributes #0 = { nomerge }
Index: llvm/lib/Transforms/Utils/SimplifyCFG.cpp
===
--- llvm/lib/Transforms/Utils/SimplifyCFG.cpp
+++ llvm/lib/Transforms/Utils/SimplifyCFG.cpp
@@ -1499,10 +1499,6 @@
 if (I1->isTerminator())
   goto HoistTerminator;
 
-// Hoisting token-returning 

[PATCH] D112621: [analyzer][solver] Introduce reasoning for not equal to operator

2022-07-11 Thread Manas Gupta via Phabricator via cfe-commits
manas added a comment.

I was busy with other stuff. I will take a look at it now.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112621

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


[PATCH] D105255: [MLIR][OpenMP] Added target data, exit data, and enter data operation definition for MLIR.

2022-07-11 Thread Abid via Phabricator via cfe-commits
abidmalikwaterloo added a comment.

In D105255#3643428 , @clementval 
wrote:

> Why not adding the assembly format directly for these operations like your 
> patch D105584 ?

OK, I will do it!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105255

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


[clang] fe3780f - [DependencyScanningTool.cpp] Use `using namespace` instead of wrapping the `.cpp` file contents in namespaces, NFC

2022-07-11 Thread Argyrios Kyrtzidis via cfe-commits

Author: Argyrios Kyrtzidis
Date: 2022-07-11T17:44:17-07:00
New Revision: fe3780f32ae81187e0700e52bd551cc02c7a63b4

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

LOG: [DependencyScanningTool.cpp] Use `using namespace` instead of wrapping the 
`.cpp` file contents in namespaces, NFC

This makes the file consistent with the coding style of the rest of LLVM.

Added: 


Modified: 
clang/lib/Tooling/DependencyScanning/DependencyScanningTool.cpp

Removed: 




diff  --git a/clang/lib/Tooling/DependencyScanning/DependencyScanningTool.cpp 
b/clang/lib/Tooling/DependencyScanning/DependencyScanningTool.cpp
index 26c2b2b2f394..575aa46bff1b 100644
--- a/clang/lib/Tooling/DependencyScanning/DependencyScanningTool.cpp
+++ b/clang/lib/Tooling/DependencyScanning/DependencyScanningTool.cpp
@@ -9,9 +9,9 @@
 #include "clang/Tooling/DependencyScanning/DependencyScanningTool.h"
 #include "clang/Frontend/Utils.h"
 
-namespace clang {
-namespace tooling {
-namespace dependencies {
+using namespace clang;
+using namespace tooling;
+using namespace dependencies;
 
 std::vector FullDependencies::getCommandLine(
 std::function LookupPCMPath) const {
@@ -192,7 +192,3 @@ DependencyScanningTool::getFullDependencies(
 return std::move(Result);
   return Consumer.getFullDependencies(CommandLine);
 }
-
-} // end namespace dependencies
-} // end namespace tooling
-} // end namespace clang



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


[PATCH] D128914: [HIP] Add support for handling HIP in the linker wrapper

2022-07-11 Thread Joseph Huber via Phabricator via cfe-commits
jhuber6 added a comment.

In D128914#3643802 , @tra wrote:

> For what it's worth, NCCL  is the only 
> nontrivial library that needs RDC compilation that I'm aware of.
> It's also self-contained for RDC purposes we only need to use RDC on the 
> library TUs and do not need to propagate it to all CUDA TUs in the build.
>
> I believe such 'constrained' RDC compilation will likely be the reasonable 
> practical trade-off. It may not become the default compilation mode, but we 
> should be able to control where the "fully linked GPU executable" boundary is 
> and it's not necessarily going to match the fully-linked host executable.

Theoretically we could do this with a relocatable link using the 
linker-wrapper. The only problem with this approach are the `__start/__stop` 
linker defined variables that we use to iterate the globals to be registered as 
these are tied to the section specifically. Potentially, we could move these to 
a unique section so they don't interfere with anything. So it would be 
something like this

  clang-linker-wrapper -r a.o b.o c.o -o registered.o // Contains RTL calls to 
register all globals at section 'cuda_offloading_entries_'
  llvm-strip ---remove-section .llvm.offloading registered.o // Remove embedded 
IR so no other files will link against it
  llvm-objcopy --rename-section 
cuda_offloading_entries=cuda_offloading_entries_ registered.o // Change the 
registration section to something unique

Think this would work?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128914

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


[PATCH] D128048: Add a new clang option "-ftime-trace="

2022-07-11 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added inline comments.



Comment at: clang/include/clang/Driver/Options.td:2831
   MarshallingInfoInt, "500u">;
+def ftime_trace_path : Joined<["-"], "ftime-trace=">, Group,
+  HelpText<"Turn on time profiler. Generates JSON file based on output 
filename. "

`ftime_trace_EQ`



Comment at: clang/tools/driver/cc1_main.cpp:263
+  // replace the suffix to '.json' directly
+  SmallString<128> FileName(llvm::sys::path::filename(Path));
+  SmallString<128> TracePath(Clang->getFrontendOpts().TimeTracePath);

The variable FileName can be removed


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128048

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


[PATCH] D129398: [ASTMatchers] Add a new matcher for callee declarations of Obj-C message expressions

2022-07-11 Thread Ziqing Luo via Phabricator via cfe-commits
ziqingluo-90 added inline comments.



Comment at: clang/include/clang/ASTMatchers/ASTMatchers.h:3853
+/// objcMessageExpr(objcMessageCallee(objcMethodDecl(hasName("foo"
+AST_MATCHER_P(ObjCMessageExpr, objcMessageCallee,
+  internal::Matcher, InnerMatcher) {

ziqingluo-90 wrote:
> aaron.ballman wrote:
> > Is there a reason why we want a separate matcher here instead of 
> > overloading `callee()`?
> This is a good question!  
> 
> `callee` has already been overloaded to accept both `Matcher` and 
> `Matcher` as the parameter.   In my case, I will need `callee` to be 
> polymorphic in returning both `Matcher` and 
> `Matcher` types.   So that will end up in 4 definitions of 
> `callee`, one of which has different return type and parameter type from one 
> of the others.   
> 
> Is this achievable?  I know I can overload parameters or make return types 
> polymorphic, but can I mix them together? 
I figured it out.  I will soon update this patch to simply overload `callee`


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D129398

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


[PATCH] D128712: [clang-format] Handle Verilog modules

2022-07-11 Thread sstwcw via Phabricator via cfe-commits
sstwcw marked 2 inline comments as done.
sstwcw added inline comments.



Comment at: clang/lib/Format/UnwrappedLineParser.cpp:4072
+Keywords.kw_randsequence)) {
+AddLevels += Style.IndentCaseLabels;
+nextToken();

HazardyKnusperkeks wrote:
> Using `bool`s in integer expressions has caused some trouble in code I've 
> seen. I'd prefer to use it as boolean.
I am sorry.  I should have fixed it myself since you had already pointed it out 
several times.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128712

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


[PATCH] D128712: [clang-format] Handle Verilog modules

2022-07-11 Thread sstwcw via Phabricator via cfe-commits
sstwcw updated this revision to Diff 443791.
sstwcw added a comment.

- take out check
- use boolean as boolean


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128712

Files:
  clang/lib/Format/FormatToken.h
  clang/lib/Format/TokenAnnotator.cpp
  clang/lib/Format/TokenAnnotator.h
  clang/lib/Format/UnwrappedLineFormatter.cpp
  clang/lib/Format/UnwrappedLineParser.cpp
  clang/lib/Format/UnwrappedLineParser.h
  clang/unittests/Format/FormatTestVerilog.cpp
  clang/unittests/Format/TokenAnnotatorTest.cpp

Index: clang/unittests/Format/TokenAnnotatorTest.cpp
===
--- clang/unittests/Format/TokenAnnotatorTest.cpp
+++ clang/unittests/Format/TokenAnnotatorTest.cpp
@@ -894,6 +894,13 @@
   ASSERT_EQ(Tokens.size(), 7u);
   EXPECT_TOKEN(Tokens[1], tok::colon, TT_VerilogBlockLabelColon);
   EXPECT_TOKEN(Tokens[4], tok::colon, TT_VerilogBlockLabelColon);
+  // Test that the dimension colon is annotated correctly.
+  Tokens = Annotate("var [1 : 0] x;");
+  ASSERT_EQ(Tokens.size(), 9u) << Tokens;
+  EXPECT_TOKEN(Tokens[3], tok::colon, TT_BitFieldColon);
+  Tokens = Annotate("extern function [1 : 0] x;");
+  ASSERT_EQ(Tokens.size(), 10u) << Tokens;
+  EXPECT_TOKEN(Tokens[4], tok::colon, TT_BitFieldColon);
 }
 
 } // namespace
Index: clang/unittests/Format/FormatTestVerilog.cpp
===
--- clang/unittests/Format/FormatTestVerilog.cpp
+++ clang/unittests/Format/FormatTestVerilog.cpp
@@ -139,6 +139,75 @@
 "x = x;"));
 }
 
+TEST_F(FormatTestVerilog, Hierarchy) {
+  verifyFormat("module x;\n"
+   "endmodule");
+  // Test that the end label is on the same line as the end keyword.
+  verifyFormat("module x;\n"
+   "endmodule : x");
+  // Test that things inside are indented.
+  verifyFormat("module x;\n"
+   "  generate\n"
+   "  endgenerate\n"
+   "endmodule");
+  verifyFormat("program x;\n"
+   "  generate\n"
+   "  endgenerate\n"
+   "endprogram");
+  verifyFormat("interface x;\n"
+   "  generate\n"
+   "  endgenerate\n"
+   "endinterface");
+  verifyFormat("task x;\n"
+   "  generate\n"
+   "  endgenerate\n"
+   "endtask");
+  verifyFormat("function x;\n"
+   "  generate\n"
+   "  endgenerate\n"
+   "endfunction");
+  verifyFormat("class x;\n"
+   "  generate\n"
+   "  endgenerate\n"
+   "endclass");
+  // Test that they nest.
+  verifyFormat("module x;\n"
+   "  program x;\n"
+   "program x;\n"
+   "endprogram\n"
+   "  endprogram\n"
+   "endmodule");
+  // Test that an extern declaration doesn't change the indentation.
+  verifyFormat("extern module x;\n"
+   "x = x;");
+  // Test complex headers
+  verifyFormat("extern module x\n"
+   "import x.x::x::*;\n"
+   "import x;\n"
+   "#(parameter x)\n"
+   "(output x);");
+  verifyFormat("module x\n"
+   "import x.x::x::*;\n"
+   "import x;\n"
+   "#(parameter x)\n"
+   "(output x);\n"
+   "  generate\n"
+   "  endgenerate\n"
+   "endmodule : x");
+  verifyFormat("virtual class x\n"
+   "(x)\n"
+   "extends x(x)\n"
+   "implements x, x, x;\n"
+   "  generate\n"
+   "  endgenerate\n"
+   "endclass : x\n");
+  verifyFormat("function automatic logic [1 : 0] x\n"
+   "(input x);\n"
+   "  generate\n"
+   "  endgenerate\n"
+   "endfunction : x");
+}
+
 TEST_F(FormatTestVerilog, If) {
   verifyFormat("if (x)\n"
"  x = x;");
Index: clang/lib/Format/UnwrappedLineParser.h
===
--- clang/lib/Format/UnwrappedLineParser.h
+++ clang/lib/Format/UnwrappedLineParser.h
@@ -48,6 +48,10 @@
 
   bool MustBeDeclaration;
 
+  /// \c True if this line should be indented by ContinuationIndent in
+  /// addition to the normal indention level.
+  bool IsContinuation = false;
+
   /// If this \c UnwrappedLine closes a block in a sequence of lines,
   /// \c MatchingOpeningBlockLineIndex stores the index of the corresponding
   /// opening line. Otherwise, \c MatchingOpeningBlockLineIndex must be
@@ -173,6 +177,11 @@
   bool tryToParsePropertyAccessor();
   void tryToParseJSFunction();
   bool tryToParseSimpleAttribute();
+  void parseVerilogHierarchyIdentifier();
+  void parseVerilogSensitivityList();
+  // Returns the number of levels of indentation in addition to the normal 1
+  

[PATCH] D129524: [Lex/HeaderSearch] Only lookup `HeaderFileInfo` for a `FileEntry` from `ExternalSource` once

2022-07-11 Thread Argyrios Kyrtzidis via Phabricator via cfe-commits
akyrtzi created this revision.
Herald added a project: All.
akyrtzi requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Without marking the `HeaderFileInfo` as resolved the `FileEntries` of files 
that were not found in `ExternalSource`
are looked up in `ExternalSource` over and over again.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D129524

Files:
  clang/lib/Lex/HeaderSearch.cpp


Index: clang/lib/Lex/HeaderSearch.cpp
===
--- clang/lib/Lex/HeaderSearch.cpp
+++ clang/lib/Lex/HeaderSearch.cpp
@@ -1284,9 +1284,9 @@
   HeaderFileInfo *HFI = [FE->getUID()];
   // FIXME: Use a generation count to check whether this is really up to date.
   if (ExternalSource && !HFI->Resolved) {
+HFI->Resolved = true;
 auto ExternalHFI = ExternalSource->GetHeaderFileInfo(FE);
 if (ExternalHFI.IsValid) {
-  HFI->Resolved = true;
   if (ExternalHFI.External)
 mergeHeaderFileInfo(*HFI, ExternalHFI);
 }
@@ -1316,9 +1316,9 @@
 if (!WantExternal && (!HFI->IsValid || HFI->External))
   return nullptr;
 if (!HFI->Resolved) {
+  HFI->Resolved = true;
   auto ExternalHFI = ExternalSource->GetHeaderFileInfo(FE);
   if (ExternalHFI.IsValid) {
-HFI->Resolved = true;
 if (ExternalHFI.External)
   mergeHeaderFileInfo(*HFI, ExternalHFI);
   }


Index: clang/lib/Lex/HeaderSearch.cpp
===
--- clang/lib/Lex/HeaderSearch.cpp
+++ clang/lib/Lex/HeaderSearch.cpp
@@ -1284,9 +1284,9 @@
   HeaderFileInfo *HFI = [FE->getUID()];
   // FIXME: Use a generation count to check whether this is really up to date.
   if (ExternalSource && !HFI->Resolved) {
+HFI->Resolved = true;
 auto ExternalHFI = ExternalSource->GetHeaderFileInfo(FE);
 if (ExternalHFI.IsValid) {
-  HFI->Resolved = true;
   if (ExternalHFI.External)
 mergeHeaderFileInfo(*HFI, ExternalHFI);
 }
@@ -1316,9 +1316,9 @@
 if (!WantExternal && (!HFI->IsValid || HFI->External))
   return nullptr;
 if (!HFI->Resolved) {
+  HFI->Resolved = true;
   auto ExternalHFI = ExternalSource->GetHeaderFileInfo(FE);
   if (ExternalHFI.IsValid) {
-HFI->Resolved = true;
 if (ExternalHFI.External)
   mergeHeaderFileInfo(*HFI, ExternalHFI);
   }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D128914: [HIP] Add support for handling HIP in the linker wrapper

2022-07-11 Thread Artem Belevich via Phabricator via cfe-commits
tra added a comment.

In D128914#3643495 , @jhuber6 wrote:

> Yes, it's actually pretty difficult to find a CUDA application using 
> `fgpu-rdc`. It seems much more common to just stick everything that's needed 
> in the file.I've considered finding a CUDA / HIP benchmark suite and 
> comparing compile times using the new driver stuff. The benefit of having 
> `fgpu-rdc` be the default is that device code basically behaves exactly like 
> host code and LTO makes `fgpu-rdc` behave like `fno-gpu-rdc` performance 
> wise. The downside, as you mentioned, is compile time.

For what it's worth, NCCL  is the only 
nontrivial library that needs RDC compilation that I'm aware of.
It's also self-contained for RDC purposes we only need to use RDC on the 
library TUs and do not need to propagate it to all CUDA TUs in the build.

I believe such 'constrained' RDC compilation will likely be the reasonable 
practical trade-off. It may not become the default compilation mode, but we 
should be able to control where the "fully linked GPU executable" boundary is 
and it's not necessarily going to match the fully-linked host executable.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128914

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


[PATCH] D128745: [c++] implements DR692, DR1395 and tentatively DR1432, about partial ordering of variadic template partial specialization or function template

2022-07-11 Thread Yuanfang Chen via Phabricator via cfe-commits
ychen added inline comments.



Comment at: clang/lib/Sema/SemaTemplateDeduction.cpp:5184
 
-  // FIXME: This mimics what GCC implements, but doesn't match up with the
-  // proposed resolution for core issue 692. This area needs to be sorted out,

ychen wrote:
> aaron.ballman wrote:
> > ychen wrote:
> > > aaron.ballman wrote:
> > > > aaron.ballman wrote:
> > > > > We tend not to use top-level const on locals in the project as a 
> > > > > matter of style.
> > > > Does GCC still implement it this way?
> > > > 
> > > > One concern I have is that this will be an ABI breaking change, and I'm 
> > > > not certain how disruptive it will be. If GCC already made that change, 
> > > > it may be reasonable for us to also break it without having to add ABI 
> > > > tags or something special. But if these changes diverge us from GCC, 
> > > > that may require some extra effort to mitigate.
> > > Unfortunately, GCC is still using the old/non-conforming behavior. 
> > > https://clang.godbolt.org/z/5K4916W71. What is the usual way to mitigate 
> > > this?
> > You would use the `ClangABI` enumeration to alter behavior between ABI 
> > versions: 
> > https://github.com/llvm/llvm-project/blob/main/clang/include/clang/Basic/LangOptions.h#L174
> >  like done in: 
> > https://github.com/llvm/llvm-project/blob/main/clang/lib/AST/DeclCXX.cpp#L929
> Looking at how `ClangABI` is currently used, it looks like it is for 
> low-level object layout ABI compatibility. For library/language ABI 
> compatibility, maybe we should not use `ClangABI`? Looking at 
> https://reviews.llvm.org/rG86a1b135f0c67a022ef628f092c6691892752876, I guess 
> the practice is just committed and see? If it breaks important or many 
> existing libraries, just revert or add compiler options?
> I guess the practice is just committed and see? If it breaks important or 
> many existing libraries, just revert or add compiler options?

I'm fairly optimistic considering `check-runtimes` passes. 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128745

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


[PATCH] D128745: [c++] implements DR692, DR1395 and tentatively DR1432, about partial ordering of variadic template partial specialization or function template

2022-07-11 Thread Yuanfang Chen via Phabricator via cfe-commits
ychen added inline comments.



Comment at: clang/lib/Sema/SemaTemplateDeduction.cpp:2488
+bool XHasMoreArg = X.pack_size() > Y.pack_size();
+if (!(XHasMoreArg && X.pack_elements().back().isPackExpansion()) &&
+!(!XHasMoreArg && Y.pack_elements().back().isPackExpansion()))

FYI: `isSameTemplateArg` is for class/variable partial ordering deduction. The 
corresponding check for function template deduction is skipped by intention. 
See https://reviews.llvm.org/rG86a1b135f0c67a022ef628f092c6691892752876 and 
https://github.com/llvm/llvm-project/blob/e6f1f062457c928c18a88c612f39d9e168f65a85/clang/lib/Sema/SemaTemplateDeduction.cpp#L5064-L5066.



Comment at: clang/lib/Sema/SemaTemplateDeduction.cpp:5184
 
-  // FIXME: This mimics what GCC implements, but doesn't match up with the
-  // proposed resolution for core issue 692. This area needs to be sorted out,

aaron.ballman wrote:
> ychen wrote:
> > aaron.ballman wrote:
> > > aaron.ballman wrote:
> > > > We tend not to use top-level const on locals in the project as a matter 
> > > > of style.
> > > Does GCC still implement it this way?
> > > 
> > > One concern I have is that this will be an ABI breaking change, and I'm 
> > > not certain how disruptive it will be. If GCC already made that change, 
> > > it may be reasonable for us to also break it without having to add ABI 
> > > tags or something special. But if these changes diverge us from GCC, that 
> > > may require some extra effort to mitigate.
> > Unfortunately, GCC is still using the old/non-conforming behavior. 
> > https://clang.godbolt.org/z/5K4916W71. What is the usual way to mitigate 
> > this?
> You would use the `ClangABI` enumeration to alter behavior between ABI 
> versions: 
> https://github.com/llvm/llvm-project/blob/main/clang/include/clang/Basic/LangOptions.h#L174
>  like done in: 
> https://github.com/llvm/llvm-project/blob/main/clang/lib/AST/DeclCXX.cpp#L929
Looking at how `ClangABI` is currently used, it looks like it is for low-level 
object layout ABI compatibility. For library/language ABI compatibility, maybe 
we should not use `ClangABI`? Looking at 
https://reviews.llvm.org/rG86a1b135f0c67a022ef628f092c6691892752876, I guess 
the practice is just committed and see? If it breaks important or many existing 
libraries, just revert or add compiler options?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128745

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


[PATCH] D129504: [libclang][ObjC] Inherit availability attribute from containing decls or interface decls

2022-07-11 Thread Ben Langmuir via Phabricator via cfe-commits
benlangmuir added inline comments.



Comment at: clang/tools/libclang/CIndex.cpp:8271
+else if (auto *IMD = dyn_cast(D))
+  CD = IMD->getCategoryDecl();
+else if (auto *ID = dyn_cast(DC))

So this goes Impl -> Class, and CategoryImpl -> Category.  Should it also do 
Category -> Class?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D129504

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


[PATCH] D111509: [clang] use getCommonSugar in an assortment of places

2022-07-11 Thread Matheus Izvekov via Phabricator via cfe-commits
mizvekov updated this revision to Diff 443772.
Herald added subscribers: usaxena95, kadircet, arphaman.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D111509

Files:
  clang-tools-extra/clangd/unittests/tweaks/ExtractVariableTests.cpp
  
clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines/narrowing-conversions-ignoreconversionfromtypes-option.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/lib/Sema/SemaExprCXX.cpp
  clang/test/AST/ast-dump-fpfeatures.cpp
  clang/test/CodeGen/compound-assign-overflow.c
  clang/test/Sema/matrix-type-operators.c
  clang/test/Sema/nullability.c
  clang/test/Sema/sugar-common-types.c
  clang/test/SemaCXX/matrix-type-operators.cpp
  clang/test/SemaCXX/sugar-common-types.cpp
  clang/test/SemaCXX/sugared-auto.cpp
  clang/test/SemaObjC/format-strings-objc.m
  compiler-rt/test/ubsan/TestCases/Integer/add-overflow.cpp
  compiler-rt/test/ubsan/TestCases/Integer/no-recover.cpp
  compiler-rt/test/ubsan/TestCases/Integer/sub-overflow.cpp
  compiler-rt/test/ubsan/TestCases/Integer/uadd-overflow.cpp
  compiler-rt/test/ubsan/TestCases/Integer/umul-overflow.cpp
  compiler-rt/test/ubsan/TestCases/Integer/usub-overflow.cpp
  libcxx/DELETE.ME
  lldb/DELETE.ME

Index: lldb/DELETE.ME
===
--- /dev/null
+++ lldb/DELETE.ME
@@ -0,0 +1 @@
+D111509
Index: libcxx/DELETE.ME
===
--- libcxx/DELETE.ME
+++ libcxx/DELETE.ME
@@ -1 +1,2 @@
 D111283
+D111509
Index: compiler-rt/test/ubsan/TestCases/Integer/usub-overflow.cpp
===
--- compiler-rt/test/ubsan/TestCases/Integer/usub-overflow.cpp
+++ compiler-rt/test/ubsan/TestCases/Integer/usub-overflow.cpp
@@ -12,12 +12,12 @@
 
 #ifdef SUB_I32
   (void)(uint32_t(1) - uint32_t(2));
-  // CHECK-SUB_I32: usub-overflow.cpp:[[@LINE-1]]:22: runtime error: unsigned integer overflow: 1 - 2 cannot be represented in type 'unsigned int'
+  // CHECK-SUB_I32: usub-overflow.cpp:[[@LINE-1]]:22: runtime error: unsigned integer overflow: 1 - 2 cannot be represented in type '{{uint32_t|unsigned int}}'
 #endif
 
 #ifdef SUB_I64
   (void)(uint64_t(800ll) - uint64_t(900ll));
-  // CHECK-SUB_I64: 800 - 900 cannot be represented in type 'unsigned {{long( long)?}}'
+  // CHECK-SUB_I64: 800 - 900 cannot be represented in type '{{uint64_t|unsigned long( long)?}}'
 #endif
 
 #ifdef SUB_I128
@@ -26,6 +26,6 @@
 # else
   puts("__int128 not supported\n");
 # endif
-  // CHECK-SUB_I128: {{0x4000 - 0x8000 cannot be represented in type 'unsigned __int128'|__int128 not supported}}
+  // CHECK-SUB_I128: {{0x4000 - 0x8000 cannot be represented in type '__uint128_t'|__int128 not supported}}
 #endif
 }
Index: compiler-rt/test/ubsan/TestCases/Integer/umul-overflow.cpp
===
--- compiler-rt/test/ubsan/TestCases/Integer/umul-overflow.cpp
+++ compiler-rt/test/ubsan/TestCases/Integer/umul-overflow.cpp
@@ -13,7 +13,7 @@
   (void)(uint16_t(0x) * uint16_t(0x8001));
 
   (void)(uint32_t(0x) * uint32_t(0x2));
-  // CHECK: umul-overflow.cpp:15:31: runtime error: unsigned integer overflow: 4294967295 * 2 cannot be represented in type 'unsigned int'
+  // CHECK: umul-overflow.cpp:15:31: runtime error: unsigned integer overflow: 4294967295 * 2 cannot be represented in type '{{uint32_t|unsigned int}}'
 
   return 0;
 }
Index: compiler-rt/test/ubsan/TestCases/Integer/uadd-overflow.cpp
===
--- compiler-rt/test/ubsan/TestCases/Integer/uadd-overflow.cpp
+++ compiler-rt/test/ubsan/TestCases/Integer/uadd-overflow.cpp
@@ -18,7 +18,7 @@
 
 #ifdef ADD_I64
   (void)(uint64_t(1000ull) + uint64_t(900ull));
-  // CHECK-ADD_I64: 1000 + 900 cannot be represented in type 'unsigned {{long( long)?}}'
+  // CHECK-ADD_I64: 1000 + 900 cannot be represented in type '{{uint64_t|unsigned long( long)?}}'
 #endif
 
 #ifdef ADD_I128
@@ -27,6 +27,6 @@
 # else
   puts("__int128 not supported");
 # endif
-  // CHECK-ADD_I128: {{0x8000 \+ 0x8000 cannot be represented in type 'unsigned __int128'|__int128 not supported}}
+  // CHECK-ADD_I128: {{0x8000 \+ 0x8000 cannot be represented in type '__uint128_t'|__int128 not supported}}
 #endif
 }
Index: compiler-rt/test/ubsan/TestCases/Integer/sub-overflow.cpp
===
--- compiler-rt/test/ubsan/TestCases/Integer/sub-overflow.cpp

[PATCH] D128745: [Sema] fix trailing parameter pack handling for function template partial ordering

2022-07-11 Thread Yuanfang Chen via Phabricator via cfe-commits
ychen updated this revision to Diff 443771.
ychen marked an inline comment as done.
ychen added a comment.

- fix a bug
- update comments
- check-all, check-runtimes pass


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128745

Files:
  clang/lib/Sema/SemaTemplateDeduction.cpp
  clang/test/CXX/drs/dr6xx.cpp
  clang/www/cxx_dr_status.html

Index: clang/www/cxx_dr_status.html
===
--- clang/www/cxx_dr_status.html
+++ clang/www/cxx_dr_status.html
@@ -4194,7 +4194,7 @@
 https://wg21.link/cwg692;>692
 C++11
 Partial ordering of variadic class template partial specializations
-No
+Clang 15
   
   
 https://wg21.link/cwg693;>693
@@ -8184,7 +8184,7 @@
 https://wg21.link/cwg1395;>1395
 C++17
 Partial ordering of variadic templates reconsidered
-Unknown
+Clang 15
   
   
 https://wg21.link/cwg1396;>1396
Index: clang/test/CXX/drs/dr6xx.cpp
===
--- clang/test/CXX/drs/dr6xx.cpp
+++ clang/test/CXX/drs/dr6xx.cpp
@@ -1082,19 +1082,18 @@
 }
 
 namespace dr692 { // dr692: no
+  // Also see dr1395.
+
   namespace temp_func_order_example2 {
 template  struct A {};
 template  void f(U, A *p = 0); // expected-note {{candidate}}
 template  int (U, A *p = 0); // expected-note {{candidate}}
-template  void g(T, T = T());
-template  void g(T, U...); // expected-error 0-1{{C++11}}
+template  void g(T, T = T()); // expected-note {{candidate}}
+template  void g(T, U...); // expected-note {{candidate}} expected-error 0-1{{C++11}}
 void h() {
   int  = f(42, (A *)0);
   f(42); // expected-error {{ambiguous}}
-  // FIXME: We should reject this due to ambiguity between the pack and the
-  // default argument. Only parameters with arguments are considered during
-  // partial ordering of function templates.
-  g(42);
+  g(42); // expected-error {{ambiguous}}
 }
   }
 
@@ -1127,20 +1126,16 @@
 template  class S {};
 S s;
 
-// FIXME: This should select the first partial specialization. Deduction of
-// the second from the first should succeed, because we should ignore the
-// trailing pack in A with no corresponding P.
 template struct A; // expected-error 0-1{{C++11}}
-template struct A; // expected-note {{matches}} expected-error 0-1{{C++11}}
-template struct A {}; // expected-note {{matches}}
-template struct A; // expected-error {{ambiguous}}
+template struct A {}; // expected-error 0-1{{C++11}}
+template struct A;
+template struct A;
   }
 
   namespace temp_deduct_type_example3 {
-// FIXME: This should select the first template, as in the case above.
-template void f(T*, U...){} // expected-note {{candidate}} expected-error 0-1{{C++11}}
-template void f(T){} // expected-note {{candidate}}
-template void f(int*); // expected-error {{ambiguous}}
+template void f(T*, U...){} // expected-error 0-1{{C++11}}
+template void f(T){}
+template void f(int*);
   }
 }
 
Index: clang/lib/Sema/SemaTemplateDeduction.cpp
===
--- clang/lib/Sema/SemaTemplateDeduction.cpp
+++ clang/lib/Sema/SemaTemplateDeduction.cpp
@@ -55,6 +55,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 
 namespace clang {
@@ -1100,6 +1101,16 @@
   return Result;
   }
 
+  // DR692, DR1395
+  // C++0x [temp.deduct.type]p10:
+  // If the parameter-declaration corresponding to P_i ...
+  // During partial ordering, if Ai was originally a function parameter pack:
+  // - if P does not contain a function parameter type corresponding to Ai then
+  //   Ai is ignored;
+  if (PartialOrdering && ArgIdx + 1 == NumArgs &&
+  isa(Args[ArgIdx]))
+return Sema::TDK_Success;
+
   // Make sure we don't have any extra arguments.
   if (ArgIdx < NumArgs)
 return Sema::TDK_MiscellaneousDeductionFailure;
@@ -1755,7 +1766,7 @@
   if (auto Result = DeduceTemplateArguments(
   S, TemplateParams, FPP->param_type_begin(), FPP->getNumParams(),
   FPA->param_type_begin(), FPA->getNumParams(), Info, Deduced,
-  TDF & TDF_TopLevelParameterTypeList))
+  TDF & TDF_TopLevelParameterTypeList, PartialOrdering))
 return Result;
 
   if (TDF & TDF_AllowCompatibleFunctionType)
@@ -2422,6 +2433,7 @@
 static bool isSameTemplateArg(ASTContext ,
   TemplateArgument X,
   const TemplateArgument ,
+  bool PartialOrdering,
   bool PackExpansionMatchesPack = false) {
   // If we're checking deduced arguments (X) against original arguments (Y),
   // we will have flattened packs to non-expansions in X.
@@ -2463,16 +2475,30 @@
 }
 
 case TemplateArgument::Pack:
- 

[PATCH] D129377: [lldb/Fuzzer] Add fuzzer for expression evaluator

2022-07-11 Thread Chelsea Cassanova via Phabricator via cfe-commits
cassanova added inline comments.



Comment at: lldb/tools/lldb-fuzzer/lldb-expression-fuzzer/CMakeLists.txt:21
+
+include(ProtobufMutator)
+include_directories(${ProtobufMutator_INCLUDE_DIRS})

Commenting out this line causes the project to generate, but I get file not 
found errors when including the protobuf errors when trying to build the fuzzer.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D129377

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


[PATCH] D111509: [clang] use getCommonSugar in an assortment of places

2022-07-11 Thread Matheus Izvekov via Phabricator via cfe-commits
mizvekov added a comment.
Herald added a subscriber: JDevlieghere.

In D111509#3168178 , @shafik wrote:

> llvm-lit -sv lldb/test --filter TestScalarURem.py
>
>   The change looks expected. 

Thanks for letting me know. Unfortunately that test is not supported on my 
platform (Windows).
I have added a dummy file to lldb dir to try to trigger pre-commit CI there, 
and hopefully see what the error is.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D111509

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


[PATCH] D111509: [clang] use getCommonSugar in an assortment of places

2022-07-11 Thread Matheus Izvekov via Phabricator via cfe-commits
mizvekov edited the summary of this revision.
mizvekov updated this revision to Diff 443769.
Herald added subscribers: lldb-commits, Enna1.
Herald added projects: LLDB, All.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D111509

Files:
  
clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines/narrowing-conversions-ignoreconversionfromtypes-option.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/lib/Sema/SemaExprCXX.cpp
  clang/test/AST/ast-dump-fpfeatures.cpp
  clang/test/CodeGen/compound-assign-overflow.c
  clang/test/Sema/matrix-type-operators.c
  clang/test/Sema/nullability.c
  clang/test/Sema/sugar-common-types.c
  clang/test/SemaCXX/matrix-type-operators.cpp
  clang/test/SemaCXX/sugar-common-types.cpp
  clang/test/SemaCXX/sugared-auto.cpp
  clang/test/SemaObjC/format-strings-objc.m
  compiler-rt/test/ubsan/TestCases/Integer/add-overflow.cpp
  compiler-rt/test/ubsan/TestCases/Integer/no-recover.cpp
  compiler-rt/test/ubsan/TestCases/Integer/sub-overflow.cpp
  compiler-rt/test/ubsan/TestCases/Integer/uadd-overflow.cpp
  compiler-rt/test/ubsan/TestCases/Integer/umul-overflow.cpp
  compiler-rt/test/ubsan/TestCases/Integer/usub-overflow.cpp
  libcxx/DELETE.ME
  lldb/DELETE.ME

Index: lldb/DELETE.ME
===
--- /dev/null
+++ lldb/DELETE.ME
@@ -0,0 +1 @@
+D111509
Index: libcxx/DELETE.ME
===
--- libcxx/DELETE.ME
+++ libcxx/DELETE.ME
@@ -1 +1,2 @@
 D111283
+D111509
Index: compiler-rt/test/ubsan/TestCases/Integer/usub-overflow.cpp
===
--- compiler-rt/test/ubsan/TestCases/Integer/usub-overflow.cpp
+++ compiler-rt/test/ubsan/TestCases/Integer/usub-overflow.cpp
@@ -12,12 +12,12 @@
 
 #ifdef SUB_I32
   (void)(uint32_t(1) - uint32_t(2));
-  // CHECK-SUB_I32: usub-overflow.cpp:[[@LINE-1]]:22: runtime error: unsigned integer overflow: 1 - 2 cannot be represented in type 'unsigned int'
+  // CHECK-SUB_I32: usub-overflow.cpp:[[@LINE-1]]:22: runtime error: unsigned integer overflow: 1 - 2 cannot be represented in type '{{uint32_t|unsigned int}}'
 #endif
 
 #ifdef SUB_I64
   (void)(uint64_t(800ll) - uint64_t(900ll));
-  // CHECK-SUB_I64: 800 - 900 cannot be represented in type 'unsigned {{long( long)?}}'
+  // CHECK-SUB_I64: 800 - 900 cannot be represented in type '{{uint64_t|unsigned long( long)?}}'
 #endif
 
 #ifdef SUB_I128
@@ -26,6 +26,6 @@
 # else
   puts("__int128 not supported\n");
 # endif
-  // CHECK-SUB_I128: {{0x4000 - 0x8000 cannot be represented in type 'unsigned __int128'|__int128 not supported}}
+  // CHECK-SUB_I128: {{0x4000 - 0x8000 cannot be represented in type '__uint128_t'|__int128 not supported}}
 #endif
 }
Index: compiler-rt/test/ubsan/TestCases/Integer/umul-overflow.cpp
===
--- compiler-rt/test/ubsan/TestCases/Integer/umul-overflow.cpp
+++ compiler-rt/test/ubsan/TestCases/Integer/umul-overflow.cpp
@@ -13,7 +13,7 @@
   (void)(uint16_t(0x) * uint16_t(0x8001));
 
   (void)(uint32_t(0x) * uint32_t(0x2));
-  // CHECK: umul-overflow.cpp:15:31: runtime error: unsigned integer overflow: 4294967295 * 2 cannot be represented in type 'unsigned int'
+  // CHECK: umul-overflow.cpp:15:31: runtime error: unsigned integer overflow: 4294967295 * 2 cannot be represented in type '{{uint32_t|unsigned int}}'
 
   return 0;
 }
Index: compiler-rt/test/ubsan/TestCases/Integer/uadd-overflow.cpp
===
--- compiler-rt/test/ubsan/TestCases/Integer/uadd-overflow.cpp
+++ compiler-rt/test/ubsan/TestCases/Integer/uadd-overflow.cpp
@@ -18,7 +18,7 @@
 
 #ifdef ADD_I64
   (void)(uint64_t(1000ull) + uint64_t(900ull));
-  // CHECK-ADD_I64: 1000 + 900 cannot be represented in type 'unsigned {{long( long)?}}'
+  // CHECK-ADD_I64: 1000 + 900 cannot be represented in type '{{uint64_t|unsigned long( long)?}}'
 #endif
 
 #ifdef ADD_I128
@@ -27,6 +27,6 @@
 # else
   puts("__int128 not supported");
 # endif
-  // CHECK-ADD_I128: {{0x8000 \+ 0x8000 cannot be represented in type 'unsigned __int128'|__int128 not supported}}
+  // CHECK-ADD_I128: {{0x8000 \+ 0x8000 cannot be represented in type '__uint128_t'|__int128 not supported}}
 #endif
 }
Index: compiler-rt/test/ubsan/TestCases/Integer/sub-overflow.cpp
===
--- compiler-rt/test/ubsan/TestCases/Integer/sub-overflow.cpp

[PATCH] D129377: [lldb/Fuzzer] Add fuzzer for expression evaluator

2022-07-11 Thread Chelsea Cassanova via Phabricator via cfe-commits
cassanova updated this revision to Diff 443768.
cassanova added a comment.

Shows top-of-tree changes, however CMake generation fails that the 
ProtobufMutator target already exists for clang-fuzzer:

  CMake Error at 
/opt/homebrew/Cellar/cmake/3.23.1_1/share/cmake/Modules/ExternalProject.cmake:3453
 (add_custom_target):
add_custom_target cannot create target "protobuf_mutator" because another
target with the same name already exists.  The existing target is a custom
target created in source directory
"/Users/chelseacassanova/code/llvm-project/clang/tools/clang-fuzzer".


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D129377

Files:
  clang/tools/clang-fuzzer/handle-cxx/CMakeLists.txt
  clang/tools/clang-fuzzer/proto-to-cxx/CMakeLists.txt
  lldb/tools/lldb-fuzzer/CMakeLists.txt
  lldb/tools/lldb-fuzzer/lldb-expression-fuzzer/CMakeLists.txt
  lldb/tools/lldb-fuzzer/lldb-expression-fuzzer/cxx_proto.proto
  lldb/tools/lldb-fuzzer/lldb-expression-fuzzer/lldb-expression-fuzzer.cpp

Index: lldb/tools/lldb-fuzzer/lldb-expression-fuzzer/lldb-expression-fuzzer.cpp
===
--- /dev/null
+++ lldb/tools/lldb-fuzzer/lldb-expression-fuzzer/lldb-expression-fuzzer.cpp
@@ -0,0 +1,73 @@
+//===-- lldb-expression-fuzzer.cpp ---===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===-===//
+//
+// \file
+// This file is a fuzzer for LLDB's expression evaluator. It uses protobufs
+// and the libprotobuf-mutator to create valid C-like inputs for the
+// expression evaluator.
+//
+//===-===//
+
+#include 
+
+#include "cxx_proto.pb.h"
+#include "handle-cxx/handle_cxx.h"
+#include "lldb/API/SBBreakpoint.h"
+#include "lldb/API/SBDebugger.h"
+#include "lldb/API/SBError.h"
+#include "lldb/API/SBLaunchInfo.h"
+#include "lldb/API/SBProcess.h"
+#include "lldb/API/SBTarget.h"
+#include "proto-to-cxx/proto_to_cxx.h"
+#include "src/libfuzzer/libfuzzer_macro.h"
+#include "llvm/ADT/StringRef.h"
+#include "llvm/Support/Error.h"
+
+using namespace lldb;
+using namespace llvm;
+using namespace clang_fuzzer;
+
+char **originalargv;
+
+extern "C" int LLVMFuzzerInitialize(int *argc, char ***argv) {
+  SBDebugger::Initialize();
+
+  // The path for a simple compiled program is needed to create a
+  // target for the debugger and that path is passed in through argv
+  originalargv = *argv;
+  return 0;
+}
+
+DEFINE_BINARY_PROTO_FUZZER(const clang_fuzzer::Function ) {
+  auto S = clang_fuzzer::FunctionToString(input);
+
+  // Get the second argument from argv and strip the '--' from it.
+  // This will be used as the path for the object file to create a target from
+  std::string rawpath = originalargv[2];
+  StringRef objpath = rawpath.erase(0, 2);
+
+  // Create a debugger and a target
+  SBDebugger debugger = SBDebugger::Create(false);
+  SBTarget target = debugger.CreateTarget(objpath.str().c_str());
+
+  // Create a breakpoint on the only line in the program
+  SBBreakpoint bp = target.BreakpointCreateByLocation(objpath.str().c_str(), 1);
+
+  // Create launch info and error for launching the process
+  SBLaunchInfo li = target.GetLaunchInfo();
+  SBError error;
+
+  // Launch the process and evaluate the fuzzer's input data
+  // as an expression
+  SBProcess process = target.Launch(li, error);
+  target.EvaluateExpression(S.c_str());
+
+  debugger.DeleteTarget(target);
+  SBDebugger::Destroy(debugger);
+  SBModule::GarbageCollectAllocatedModules();
+}
Index: lldb/tools/lldb-fuzzer/lldb-expression-fuzzer/cxx_proto.proto
===
--- /dev/null
+++ lldb/tools/lldb-fuzzer/lldb-expression-fuzzer/cxx_proto.proto
@@ -0,0 +1,92 @@
+//===-- cxx_proto.proto - Protobuf description of 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
+//
+//===--===//
+///
+/// \file
+/// This file describes a subset of C++ as a protobuf.  It is used to
+///  more easily find interesting inputs for fuzzing Clang.
+///
+//===--===//
+
+syntax = "proto2";
+
+message VarRef {
+  required int32 varnum = 1;
+}
+
+message Lvalue {
+  required VarRef varref = 1;
+}
+
+message Const {
+  required int32 val = 1;
+}
+
+message BinaryOp {
+  enum Op {
+PLUS = 0;
+MINUS = 1;
+MUL = 2;
+DIV = 3;
+

[PATCH] D129456: [lldb] Add image dump pcm-info command

2022-07-11 Thread Dave Lee via Phabricator via cfe-commits
kastiglione added a comment.

@JDevlieghere I had it as `dump pcm` at first, but switched it to `pcm-info` 
for two reasons

1. it doesn't dump the whole pcm, the actual ast itself is not dumped
2. to match the clang flag `-module-file-info`

I agree that `pcm` is better, but I was worried it would be misunderstood as 
dumping more than it actually does.

I think -info here is more like -metadata but shorter.

One option is to name it back to `pcm`, and update the help description to be 
more descriptive.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D129456

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


[PATCH] D129512: [Driver] Don't use frame pointer on Fuchsia when optimizations are enabled

2022-07-11 Thread Petr Hosek via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG0ed8d8209584: [Driver] Dont use frame pointer on 
Fuchsia when optimizations are enabled (authored by phosek).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D129512

Files:
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/test/Driver/fuchsia.c


Index: clang/test/Driver/fuchsia.c
===
--- clang/test/Driver/fuchsia.c
+++ clang/test/Driver/fuchsia.c
@@ -55,6 +55,18 @@
 // CHECK-NOT: crtend.o
 // CHECK-NOT: crtn.o
 
+// RUN: %clang -### %s --target=x86_64-unknown-fuchsia 2>&1 \
+// RUN: | FileCheck %s -check-prefix=CHECK-FP-ALL
+// RUN: %clang -### %s --target=aarch64-unknown-fuchsia 2>&1 \
+// RUN: | FileCheck %s -check-prefix=CHECK-FP-NONLEAF
+// RUN: %clang -### %s --target=x86_64-unknown-fuchsia -O3 2>&1 \
+// RUN: | FileCheck %s -check-prefix=CHECK-FP-NONE
+// RUN: %clang -### %s --target=aarch64-unknown-fuchsia -O3 2>&1 \
+// RUN: | FileCheck %s -check-prefix=CHECK-FP-NONE
+// CHECK-FP-ALL: "-mframe-pointer=all"
+// CHECK-FP-NONLEAF: "-mframe-pointer=non-leaf"
+// CHECK-FP-NONE: "-mframe-pointer=none"
+
 // RUN: %clang -### %s --target=x86_64-unknown-fuchsia -rtlib=libgcc 
-fuse-ld=lld 2>&1 \
 // RUN: | FileCheck %s -check-prefix=CHECK-RTLIB
 // CHECK-RTLIB: error: invalid runtime library name in argument '-rtlib=libgcc'
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -567,7 +567,7 @@
 break;
   }
 
-  if (Triple.isOSNetBSD()) {
+  if (Triple.isOSFuchsia() || Triple.isOSNetBSD()) {
 return !areOptimizationsEnabled(Args);
   }
 


Index: clang/test/Driver/fuchsia.c
===
--- clang/test/Driver/fuchsia.c
+++ clang/test/Driver/fuchsia.c
@@ -55,6 +55,18 @@
 // CHECK-NOT: crtend.o
 // CHECK-NOT: crtn.o
 
+// RUN: %clang -### %s --target=x86_64-unknown-fuchsia 2>&1 \
+// RUN: | FileCheck %s -check-prefix=CHECK-FP-ALL
+// RUN: %clang -### %s --target=aarch64-unknown-fuchsia 2>&1 \
+// RUN: | FileCheck %s -check-prefix=CHECK-FP-NONLEAF
+// RUN: %clang -### %s --target=x86_64-unknown-fuchsia -O3 2>&1 \
+// RUN: | FileCheck %s -check-prefix=CHECK-FP-NONE
+// RUN: %clang -### %s --target=aarch64-unknown-fuchsia -O3 2>&1 \
+// RUN: | FileCheck %s -check-prefix=CHECK-FP-NONE
+// CHECK-FP-ALL: "-mframe-pointer=all"
+// CHECK-FP-NONLEAF: "-mframe-pointer=non-leaf"
+// CHECK-FP-NONE: "-mframe-pointer=none"
+
 // RUN: %clang -### %s --target=x86_64-unknown-fuchsia -rtlib=libgcc -fuse-ld=lld 2>&1 \
 // RUN: | FileCheck %s -check-prefix=CHECK-RTLIB
 // CHECK-RTLIB: error: invalid runtime library name in argument '-rtlib=libgcc'
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -567,7 +567,7 @@
 break;
   }
 
-  if (Triple.isOSNetBSD()) {
+  if (Triple.isOSFuchsia() || Triple.isOSNetBSD()) {
 return !areOptimizationsEnabled(Args);
   }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 0ed8d82 - [Driver] Don't use frame pointer on Fuchsia when optimizations are enabled

2022-07-11 Thread Petr Hosek via cfe-commits

Author: Petr Hosek
Date: 2022-07-11T21:45:42Z
New Revision: 0ed8d8209584daa5ff30aae51b5396d05d7aa997

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

LOG: [Driver] Don't use frame pointer on Fuchsia when optimizations are enabled

This matches the standard behavior on other platforms.

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

Added: 


Modified: 
clang/lib/Driver/ToolChains/Clang.cpp
clang/test/Driver/fuchsia.c

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/Clang.cpp 
b/clang/lib/Driver/ToolChains/Clang.cpp
index ee445775e7b72..aae416f19fbd5 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -567,7 +567,7 @@ static bool useFramePointerForTargetByDefault(const ArgList 
,
 break;
   }
 
-  if (Triple.isOSNetBSD()) {
+  if (Triple.isOSFuchsia() || Triple.isOSNetBSD()) {
 return !areOptimizationsEnabled(Args);
   }
 

diff  --git a/clang/test/Driver/fuchsia.c b/clang/test/Driver/fuchsia.c
index 99c43f4cecabd..4a76db38612dd 100644
--- a/clang/test/Driver/fuchsia.c
+++ b/clang/test/Driver/fuchsia.c
@@ -55,6 +55,18 @@
 // CHECK-NOT: crtend.o
 // CHECK-NOT: crtn.o
 
+// RUN: %clang -### %s --target=x86_64-unknown-fuchsia 2>&1 \
+// RUN: | FileCheck %s -check-prefix=CHECK-FP-ALL
+// RUN: %clang -### %s --target=aarch64-unknown-fuchsia 2>&1 \
+// RUN: | FileCheck %s -check-prefix=CHECK-FP-NONLEAF
+// RUN: %clang -### %s --target=x86_64-unknown-fuchsia -O3 2>&1 \
+// RUN: | FileCheck %s -check-prefix=CHECK-FP-NONE
+// RUN: %clang -### %s --target=aarch64-unknown-fuchsia -O3 2>&1 \
+// RUN: | FileCheck %s -check-prefix=CHECK-FP-NONE
+// CHECK-FP-ALL: "-mframe-pointer=all"
+// CHECK-FP-NONLEAF: "-mframe-pointer=non-leaf"
+// CHECK-FP-NONE: "-mframe-pointer=none"
+
 // RUN: %clang -### %s --target=x86_64-unknown-fuchsia -rtlib=libgcc 
-fuse-ld=lld 2>&1 \
 // RUN: | FileCheck %s -check-prefix=CHECK-RTLIB
 // CHECK-RTLIB: error: invalid runtime library name in argument '-rtlib=libgcc'



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


[PATCH] D129456: [lldb] Add image dump pcm-info command

2022-07-11 Thread Jonas Devlieghere via Phabricator via cfe-commits
JDevlieghere added a comment.

[bikeshedding] `pcm-info` seems a little odd. Do we have other command that end 
with `-info`? `target modules dump` already sounds like you're about to dump 
some kind of "info". What about just `pcm`? [/bikeshedding]


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D129456

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


[PATCH] D129389: [clang][deps] Override dependency and serialized diag files for modules

2022-07-11 Thread Ben Langmuir via Phabricator via cfe-commits
benlangmuir updated this revision to Diff 443755.
benlangmuir added a comment.

Updates per review

- Switched to a per-output callback
- Removed preserved-args.c test
- Removed error handling that I no longer have a real use for
- Only request .d and .diag paths if they were enabled in the original TU


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

https://reviews.llvm.org/D129389

Files:
  clang/include/clang/Tooling/DependencyScanning/DependencyScanningTool.h
  clang/include/clang/Tooling/DependencyScanning/ModuleDepCollector.h
  clang/lib/Tooling/DependencyScanning/DependencyScanningTool.cpp
  clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp
  clang/test/ClangScanDeps/Inputs/preserved-args/cdb.json.template
  clang/test/ClangScanDeps/Inputs/preserved-args/mod.h
  clang/test/ClangScanDeps/Inputs/preserved-args/module.modulemap
  clang/test/ClangScanDeps/Inputs/preserved-args/tu.c
  clang/test/ClangScanDeps/Inputs/removed-args/cdb.json.template
  clang/test/ClangScanDeps/generate-modules-path-args.c
  clang/test/ClangScanDeps/preserved-args.c
  clang/test/ClangScanDeps/removed-args.c
  clang/tools/clang-scan-deps/ClangScanDeps.cpp

Index: clang/tools/clang-scan-deps/ClangScanDeps.cpp
===
--- clang/tools/clang-scan-deps/ClangScanDeps.cpp
+++ clang/tools/clang-scan-deps/ClangScanDeps.cpp
@@ -288,11 +288,12 @@
   Modules.insert(I, {{MD.ID, InputIndex}, std::move(MD)});
 }
 
-ID.CommandLine = GenerateModulesPathArgs
- ? FD.getCommandLine(
-   [&](ModuleID MID) { return lookupPCMPath(MID); })
- : FD.getCommandLineWithoutModulePaths();
-
+ID.CommandLine =
+GenerateModulesPathArgs
+? FD.getCommandLine([&](const ModuleID , ModuleOutputKind MOK) {
+return lookupModuleOutput(MID, MOK);
+  })
+: FD.getCommandLineWithoutModulePaths();
 Inputs.push_back(std::move(ID));
   }
 
@@ -325,7 +326,9 @@
   {"command-line",
GenerateModulesPathArgs
? MD.getCanonicalCommandLine(
- [&](ModuleID MID) { return lookupPCMPath(MID); })
+ [&](const ModuleID , ModuleOutputKind MOK) {
+   return lookupModuleOutput(MID, MOK);
+ })
: MD.getCanonicalCommandLineWithoutModulePaths()},
   };
   OutModules.push_back(std::move(O));
@@ -352,11 +355,22 @@
   }
 
 private:
-  StringRef lookupPCMPath(ModuleID MID) {
+  std::string lookupModuleOutput(const ModuleID , ModuleOutputKind MOK) {
+// Cache the PCM path, since it will be queried repeatedly for each module.
+// The other outputs are only queried once during getCanonicalCommandLine.
 auto PCMPath = PCMPaths.insert({MID, ""});
 if (PCMPath.second)
   PCMPath.first->second = constructPCMPath(MID);
-return PCMPath.first->second;
+switch (MOK) {
+case ModuleOutputKind::ModuleFile:
+  return PCMPath.first->second;
+case ModuleOutputKind::DependencyFile:
+  return PCMPath.first->second + ".d";
+case ModuleOutputKind::DependencyTargets:
+  return ""; // Will get the default target name.
+case ModuleOutputKind::DiagnosticSerializationFile:
+  return PCMPath.first->second + ".diag";
+}
   }
 
   /// Construct a path for the explicitly built PCM.
Index: clang/test/ClangScanDeps/removed-args.c
===
--- clang/test/ClangScanDeps/removed-args.c
+++ clang/test/ClangScanDeps/removed-args.c
@@ -29,6 +29,9 @@
 // CHECK-NOT:  "-fbuild-session-timestamp=
 // CHECK-NOT:  "-fmodules-prune-interval=
 // CHECK-NOT:  "-fmodules-prune-after=
+// CHECK-NOT:  "-dependency-file"
+// CHECK-NOT:  "-MT"
+// CHECK-NOT:  "-serialize-diagnostic-file"
 // CHECK:],
 // CHECK-NEXT:   "context-hash": "[[HASH_MOD_HEADER:.*]]",
 // CHECK-NEXT:   "file-deps": [
@@ -50,6 +53,9 @@
 // CHECK-NOT:  "-fbuild-session-timestamp=
 // CHECK-NOT:  "-fmodules-prune-interval=
 // CHECK-NOT:  "-fmodules-prune-after=
+// CHECK-NOT:  "-dependency-file"
+// CHECK-NOT:  "-MT"
+// CHECK-NOT:  "-serialize-diagnostic-file"
 // CHECK:],
 // CHECK-NEXT:   "context-hash": "[[HASH_MOD_TU:.*]]",
 // CHECK-NEXT:   "file-deps": [
Index: clang/test/ClangScanDeps/preserved-args.c
===
--- clang/test/ClangScanDeps/preserved-args.c
+++ /dev/null
@@ -1,24 +0,0 @@
-// RUN: rm -rf %t && mkdir %t
-// RUN: cp -r %S/Inputs/preserved-args/* %t
-// RUN: sed -e "s|DIR|%/t|g" %t/cdb.json.template > %t/cdb.json
-
-// RUN: clang-scan-deps -compilation-database %t/cdb.json -format experimental-full > %t/result.json
-// RUN: cat %t/result.json | sed 's:\?:/:g' | 

[PATCH] D128745: [Sema] fix trailing parameter pack handling for function template partial ordering

2022-07-11 Thread Yuanfang Chen via Phabricator via cfe-commits
ychen updated this revision to Diff 443756.
ychen added a comment.

- handle more cases to implement DR692, DR1395
- tentatively implement DR1432 which DR692 needs, otherwise there would be 
regressions


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128745

Files:
  clang/lib/Sema/SemaTemplateDeduction.cpp
  clang/test/CXX/drs/dr6xx.cpp
  clang/www/cxx_dr_status.html

Index: clang/www/cxx_dr_status.html
===
--- clang/www/cxx_dr_status.html
+++ clang/www/cxx_dr_status.html
@@ -4194,7 +4194,7 @@
 https://wg21.link/cwg692;>692
 C++11
 Partial ordering of variadic class template partial specializations
-No
+Clang 15
   
   
 https://wg21.link/cwg693;>693
@@ -8184,7 +8184,7 @@
 https://wg21.link/cwg1395;>1395
 C++17
 Partial ordering of variadic templates reconsidered
-Unknown
+Clang 15
   
   
 https://wg21.link/cwg1396;>1396
Index: clang/test/CXX/drs/dr6xx.cpp
===
--- clang/test/CXX/drs/dr6xx.cpp
+++ clang/test/CXX/drs/dr6xx.cpp
@@ -1082,19 +1082,18 @@
 }
 
 namespace dr692 { // dr692: no
+  // Also see dr1395.
+
   namespace temp_func_order_example2 {
 template  struct A {};
 template  void f(U, A *p = 0); // expected-note {{candidate}}
 template  int (U, A *p = 0); // expected-note {{candidate}}
-template  void g(T, T = T());
-template  void g(T, U...); // expected-error 0-1{{C++11}}
+template  void g(T, T = T()); // expected-note {{candidate}}
+template  void g(T, U...); // expected-note {{candidate}} expected-error 0-1{{C++11}}
 void h() {
   int  = f(42, (A *)0);
   f(42); // expected-error {{ambiguous}}
-  // FIXME: We should reject this due to ambiguity between the pack and the
-  // default argument. Only parameters with arguments are considered during
-  // partial ordering of function templates.
-  g(42);
+  g(42); // expected-error {{ambiguous}}
 }
   }
 
@@ -1127,20 +1126,16 @@
 template  class S {};
 S s;
 
-// FIXME: This should select the first partial specialization. Deduction of
-// the second from the first should succeed, because we should ignore the
-// trailing pack in A with no corresponding P.
 template struct A; // expected-error 0-1{{C++11}}
-template struct A; // expected-note {{matches}} expected-error 0-1{{C++11}}
-template struct A {}; // expected-note {{matches}}
-template struct A; // expected-error {{ambiguous}}
+template struct A {}; // expected-error 0-1{{C++11}}
+template struct A;
+template struct A;
   }
 
   namespace temp_deduct_type_example3 {
-// FIXME: This should select the first template, as in the case above.
-template void f(T*, U...){} // expected-note {{candidate}} expected-error 0-1{{C++11}}
-template void f(T){} // expected-note {{candidate}}
-template void f(int*); // expected-error {{ambiguous}}
+template void f(T*, U...){} // expected-error 0-1{{C++11}}
+template void f(T){}
+template void f(int*);
   }
 }
 
Index: clang/lib/Sema/SemaTemplateDeduction.cpp
===
--- clang/lib/Sema/SemaTemplateDeduction.cpp
+++ clang/lib/Sema/SemaTemplateDeduction.cpp
@@ -55,6 +55,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 
 namespace clang {
@@ -1100,6 +1101,16 @@
   return Result;
   }
 
+  // DR692, DR1395
+  // C++0x [temp.deduct.type]p10:
+  // If the parameter-declaration corresponding to P_i ...
+  // During partial ordering, if Ai was originally a function parameter pack:
+  // - if P does not contain a function parameter type corresponding to Ai then
+  //   Ai is ignored;
+  if (PartialOrdering && ArgIdx + 1 == NumArgs &&
+  isa(Args[ArgIdx]))
+return Sema::TDK_Success;
+
   // Make sure we don't have any extra arguments.
   if (ArgIdx < NumArgs)
 return Sema::TDK_MiscellaneousDeductionFailure;
@@ -2419,9 +2430,9 @@
 }
 
 /// Determine whether two template arguments are the same.
-static bool isSameTemplateArg(ASTContext ,
-  TemplateArgument X,
+static bool isSameTemplateArg(ASTContext , TemplateArgument X,
   const TemplateArgument ,
+  bool PartialOrdering,
   bool PackExpansionMatchesPack = false) {
   // If we're checking deduced arguments (X) against original arguments (Y),
   // we will have flattened packs to non-expansions in X.
@@ -2463,16 +2474,30 @@
 }
 
 case TemplateArgument::Pack:
-  if (X.pack_size() != Y.pack_size())
-return false;
-
-  for (TemplateArgument::pack_iterator XP = X.pack_begin(),
-XPEnd = X.pack_end(),
-   YP = Y.pack_begin();
-  

[PATCH] D126676: [clang] Disallow differences in defines used for creating and using PCH

2022-07-11 Thread Reid Kleckner via Phabricator via cfe-commits
rnk added subscribers: arphaman, dexonsmith.
rnk added a comment.

Seeking additional opinions on the PCH change: @dexonsmith @arphaman

The use case makes sense to me. It seems reasonable to me that the compiler 
shouldn't use the same PCH file with mismatched defines on the command line.




Comment at: clang/lib/Serialization/ASTReader.cpp:640-641
  const LangOptions ,
- bool Validate = true) {
+ bool Validate = true,
+ bool ValidateStrict = false) {
   // Check macro definitions.

These feel like they should be a "validation level" enum. Multiple optional 
boolean parameters in sequence is usually a hazard for future refactorings.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D126676

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


[PATCH] D128411: [syntax] Introduce a BaseToken class.

2022-07-11 Thread Sam McCall via Phabricator via cfe-commits
sammccall added inline comments.



Comment at: clang/lib/Tooling/Syntax/BuildTree.cpp:370
+  TreeBuilder(syntax::Arena )
+  : Arena(Arena), STM(cast(Arena.getTokenManager())),
+Pending(Arena, STM.tokenBuffer()) {

hokein wrote:
> sammccall wrote:
> > need changes to the public API to make this cast valid
> Are you suggesting to change all public APIs where there is such a cast usage?
> 
> If yes, this seems not a trivial change, I think at least we will change all 
> APIs (`buildSyntaxTree`, `createLeaf`, `createTree`, 
> `deepCopyExpandingMacros`) in `BuildTree.h` (by adding a new 
> `TokenBufferTokenManager` parameter). 
> And the `Arena` probably doesn't need to have a `TokenManager` field (it 
> could be simplified as a single `BumpPtrAllocator`), as the TokenManager is 
> passed in parallel with the Arena.
> 
> I'm happy to do the change, but IMO, the current version doesn't seem too bad 
> for me (if we pass an non-SyntaxTokenManager, it will trigger an assertion in 
> debug mode).
> Are you suggesting to change all public APIs where there is such a cast usage?

Yes, at the very least they should document the requirement ("this arena must 
use a TokenBuffer").
An unchecked downcast with no indication on the public API that a specific 
subclass is required just looks like a bug.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128411

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


[PATCH] D129389: [clang][deps] Override dependency and serialized diag files for modules

2022-07-11 Thread Ben Langmuir via Phabricator via cfe-commits
benlangmuir marked an inline comment as done.
benlangmuir added inline comments.



Comment at: 
clang/include/clang/Tooling/DependencyScanning/DependencyScanningTool.h:55
+  getCommandLine(llvm::function_ref<
+ Expected(const ModuleID &)>
+ LookupModuleOutputs) const;

jansvoboda11 wrote:
> I'm curious whether you have encountered situations where being able to 
> return an error from `LookupModuleOutputs` is useful.
I ended up backing this change out: it was motivated by a downstream libclang 
API change that I have now re-evaluated based on your other feedback to use a 
per-output callback instead of a single callback.



Comment at: clang/tools/clang-scan-deps/ClangScanDeps.cpp:297
+? llvm::cantFail(FD.getCommandLine(
+  [&](ModuleID MID) -> const ModuleOutputOptions & {
+return lookupModuleOutputs(MID);

jansvoboda11 wrote:
> Is my understanding correct that this lambda of type `const 
> ModuleOutputOptions &(ModuleID)` gets implicitly converted to 
> `llvm::function_ref(const ModuleID &)>`?
> 
> If so, I think it would be clearer to take the `ModuleID` by const ref here 
> also and wrap the return type with `Expected`, to match the... expected 
> `function_ref` type. WDYT?
This was unintentional, I just missed these couple of places when I changed the 
API from `ModuleID` to `const ModuleID &`.  Will fix, thanks!



Comment at: clang/tools/clang-scan-deps/ClangScanDeps.cpp:397
+for (StringRef Arg : Args) {
+  if (Arg == "-serialize-diagnostics")
+SerializeDiags = true;

jansvoboda11 wrote:
> I think we should be avoiding ad-hoc command line parsing, it can be 
> incorrect in many ways. Could we move this check somewhere where we have a 
> properly constructed `CompilerInvocation`? I think we could do something like 
> this in `ModuleDeps::getCanonicalCommandLine`:
> 
> ```
> if (!CI.getDiagnosticOpts().DiagnosticSerializationFile.empty())
>   CI.getDiagnosticOpts().DiagnosticSerializationFile
> = LookupModuleOutput(ID, 
> ModuleOutputKind::DiagnosticSerializationFile);
> ```
Yeah, we can do that. I originally avoided this due to it "leaking" whether the 
TU used these outputs into the module command-lines (since the set of callbacks 
would differ), but I suspect in practice that doesn't matter since you're 
unlikely to mix compilations that have and don't have serialized diagnostics. 
To be 100% sound, it will require adding the existence of the outputs to the 
module context hash (not the actual path, just whether there was a diag and/or 
d file at all). I will do the context hash change later if you're okay with it 
- there's nowhere to feed the extra info into `getModuleHash` right now, but I 
was already planning to change the hashing which will make it easier to do.  If 
you think it's critical we could add a parameter to `getModuleHash` temporarily 
to handle it.

I liked your idea to make the callback per-output as well.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D129389

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


[PATCH] D111283: [clang] template / auto deduction deduces common sugar

2022-07-11 Thread Matheus Izvekov via Phabricator via cfe-commits
mizvekov updated this revision to Diff 443749.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D111283

Files:
  clang/include/clang/AST/ASTContext.h
  clang/include/clang/AST/Type.h
  clang/include/clang/Sema/Sema.h
  clang/lib/AST/ASTContext.cpp
  clang/lib/Sema/SemaDecl.cpp
  clang/lib/Sema/SemaExprCXX.cpp
  clang/lib/Sema/SemaOverload.cpp
  clang/lib/Sema/SemaStmt.cpp
  clang/lib/Sema/SemaTemplate.cpp
  clang/lib/Sema/SemaTemplateDeduction.cpp
  clang/test/SemaCXX/deduced-return-void.cpp
  clang/test/SemaCXX/sugared-auto.cpp
  clang/test/SemaTemplate/deduction.cpp
  libcxx/DELETE.ME

Index: libcxx/DELETE.ME
===
--- /dev/null
+++ libcxx/DELETE.ME
@@ -0,0 +1 @@
+D111283
Index: clang/test/SemaTemplate/deduction.cpp
===
--- clang/test/SemaTemplate/deduction.cpp
+++ clang/test/SemaTemplate/deduction.cpp
@@ -162,6 +162,15 @@
 
 } // namespace test4
 
+namespace test5 {
+
+template  class a {};
+template  void c(b, b);
+template  void c(a, a);
+void d() { c(a(), a()); }
+
+} // namespace test5
+
 // Verify that we can deduce enum-typed arguments correctly.
 namespace test14 {
   enum E { E0, E1 };
Index: clang/test/SemaCXX/sugared-auto.cpp
===
--- clang/test/SemaCXX/sugared-auto.cpp
+++ clang/test/SemaCXX/sugared-auto.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++20
+// RUN: %clang_cc1 -fsyntax-only -verify -xobjective-c++ %s -std=c++20 -fblocks -fobjc-arc -fobjc-runtime-has-weak -fenable-matrix -Wno-dynamic-exception-spec
 
 enum class N {};
 
@@ -9,6 +9,26 @@
 using Man = Animal;
 using Dog = Animal;
 
+using ManPtr = Man *;
+using DogPtr = Dog *;
+
+using SocratesPtr = ManPtr;
+
+using ConstMan = const Man;
+using ConstDog = const Dog;
+
+using Virus = void;
+using SARS = Virus;
+using Ebola = Virus;
+
+using Bacteria = float;
+using Bacilli = Bacteria;
+using Vibrio = Bacteria;
+
+struct Plant;
+using Gymnosperm = Plant;
+using Angiosperm = Plant;
+
 namespace variable {
 
 auto x1 = Animal();
@@ -41,3 +61,123 @@
 N t3 = x3; // expected-error {{lvalue of type 'Animal' (aka 'int')}}
 
 } // namespace function_basic
+
+namespace function_multiple_basic {
+
+N t1 = [] { // expected-error {{rvalue of type 'Animal' (aka 'int')}}
+  if (true)
+return Man();
+  return Dog();
+}();
+
+N t2 = []() -> decltype(auto) { // expected-error {{rvalue of type 'Animal' (aka 'int')}}
+  if (true)
+return Man();
+  return Dog();
+}();
+
+N t3 = [] { // expected-error {{rvalue of type 'Animal' (aka 'int')}}
+  if (true)
+return Dog();
+  auto x = Man();
+  return x;
+}();
+
+N t4 = [] { // expected-error {{rvalue of type 'int'}}
+  if (true)
+return Dog();
+  return 1;
+}();
+
+N t5 = [] { // expected-error {{rvalue of type 'Virus' (aka 'void')}}
+  if (true)
+return Ebola();
+  return SARS();
+}();
+
+N t6 = [] { // expected-error {{rvalue of type 'void'}}
+  if (true)
+return SARS();
+  return;
+}();
+
+} // namespace function_multiple_basic
+
+#define TEST_AUTO(X, A, B) \
+  auto X(A a, B b) {   \
+if (0) \
+  return a;\
+if (0) \
+  return b;\
+return N();\
+  }
+#define TEST_DAUTO(X, A, B) \
+  decltype(auto) X(A a, B b) {  \
+if (0)  \
+  return static_cast(a); \
+if (0)  \
+  return static_cast(b); \
+return N(); \
+  }
+
+namespace misc {
+
+TEST_AUTO(t1, ManPtr, DogPtr)  // expected-error {{but deduced as 'Animal *' (aka 'int *')}}
+TEST_AUTO(t2, ManPtr, int *)   // expected-error {{but deduced as 'int *'}}
+TEST_AUTO(t3, SocratesPtr, ManPtr) // expected-error {{but deduced as 'ManPtr' (aka 'int *')}}
+
+TEST_AUTO(t4, _Atomic(Man), _Atomic(Dog)) // expected-error {{but deduced as '_Atomic(Animal)'}}
+
+using block_man = void (^)(Man);
+using block_dog = void (^)(Dog);
+TEST_AUTO(t5, block_man, block_dog) // expected-error {{but deduced as 'void (^__strong)(Animal)'}}
+
+using fp1 = SARS (*)(Man, DogPtr) throw(Vibrio);
+using fp2 = Ebola (*)(Dog, ManPtr) throw(Bacilli);
+TEST_AUTO(t6, fp1, fp2); // expected-error {{but deduced as 'Virus (*)(Animal, Animal *) throw(Bacteria)' (aka 'void (*)(int, int *) throw(Bacteria)')}}
+
+using fp3 = SARS (*)() throw(Man);
+using fp4 = Ebola (*)() throw(Vibrio);
+auto t7(fp3 a, fp4 b) {
+  if (false)
+return true ? a : b;
+  if (false)
+return a;
+  return N(); // expected-error {{but deduced as 'SARS (*)() throw(Man, Vibrio)' (aka 'void (*)() throw(Man, Vibrio)')}}
+}
+
+using fp5 = void (*)(const Man);
+using fp6 = void (*)(Dog);
+TEST_AUTO(t8, fp5, fp6); // expected-error {{but deduced as 'void (*)(Animal)' (aka 'void (*)(int)')}}
+
+using fp7 = void (*)(ConstMan);
+using 

[clang] c7fd751 - Revert "[C++20][Modules] Update handling of implicit inlines [P1779R3]"

2022-07-11 Thread Jonas Devlieghere via cfe-commits

Author: Jonas Devlieghere
Date: 2022-07-11T13:59:41-07:00
New Revision: c7fd7512a5c5b133665bfecbe2e9748c0607286e

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

LOG: Revert "[C++20][Modules] Update handling of implicit inlines [P1779R3]"

This reverts commit ef0fa9f0ef3e as a follow up to b19d3ee7120b which
reverted commit ac507102d258. See https://reviews.llvm.org/D126189 for
more details.

Added: 


Modified: 
clang/lib/AST/TextNodeDumper.cpp
clang/lib/Sema/SemaDecl.cpp
clang/test/AST/ast-dump-constant-expr.cpp
clang/test/AST/ast-dump-lambda.cpp

Removed: 
clang/test/CXX/class/class.friend/p7-cxx20.cpp
clang/test/CXX/class/class.mfct/p1-cxx20.cpp



diff  --git a/clang/lib/AST/TextNodeDumper.cpp 
b/clang/lib/AST/TextNodeDumper.cpp
index 22643d4edbecb..79e9fa6ab86fc 100644
--- a/clang/lib/AST/TextNodeDumper.cpp
+++ b/clang/lib/AST/TextNodeDumper.cpp
@@ -1720,9 +1720,6 @@ void TextNodeDumper::VisitFunctionDecl(const FunctionDecl 
*D) {
 }
   }
 
-  if (!D->isInlineSpecified() && D->isInlined()) {
-OS << " implicit-inline";
-  }
   // Since NumParams comes from the FunctionProtoType of the FunctionDecl and
   // the Params are set later, it is possible for a dump during debugging to
   // encounter a FunctionDecl that has been created but hasn't been assigned

diff  --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp
index c5005accc6961..927d81826425b 100644
--- a/clang/lib/Sema/SemaDecl.cpp
+++ b/clang/lib/Sema/SemaDecl.cpp
@@ -9405,25 +9405,15 @@ Sema::ActOnFunctionDeclarator(Scope *S, Declarator , 
DeclContext *DC,
 NewFD->setLocalExternDecl();
 
   if (getLangOpts().CPlusPlus) {
-// The rules for implicit inlines changed in C++20 for methods and friends
-// with an in-class definition (when such a definition is not attached to
-// the global module).  User-specified 'inline' overrides this (set when
-// the function decl is created above).
-bool ImplicitInlineCXX20 = !getLangOpts().CPlusPlus20 ||
-   !NewFD->getOwningModule() ||
-   NewFD->getOwningModule()->isGlobalModule();
 bool isInline = D.getDeclSpec().isInlineSpecified();
 bool isVirtual = D.getDeclSpec().isVirtualSpecified();
 bool hasExplicit = D.getDeclSpec().hasExplicitSpecifier();
 isFriend = D.getDeclSpec().isFriendSpecified();
 if (isFriend && !isInline && D.isFunctionDefinition()) {
-  // Pre-C++20 [class.friend]p5
+  // C++ [class.friend]p5
   //   A function can be defined in a friend declaration of a
   //   class . . . . Such a function is implicitly inline.
-  // Post C++20 [class.friend]p7
-  //   Such a function is implicitly an inline function if it is attached
-  //   to the global module.
-  NewFD->setImplicitlyInline(ImplicitInlineCXX20);
+  NewFD->setImplicitlyInline();
 }
 
 // If this is a method defined in an __interface, and is not a constructor
@@ -9706,14 +9696,11 @@ Sema::ActOnFunctionDeclarator(Scope *S, Declarator , 
DeclContext *DC,
 }
 
 if (isa(NewFD) && DC == CurContext &&
-D.isFunctionDefinition() && !isInline) {
-  // Pre C++20 [class.mfct]p2:
+D.isFunctionDefinition()) {
+  // C++ [class.mfct]p2:
   //   A member function may be defined (8.4) in its class definition, in
   //   which case it is an inline member function (7.1.2)
-  // Post C++20 [class.mfct]p1:
-  //   If a member function is attached to the global module and is defined
-  //   in its class definition, it is inline.
-  NewFD->setImplicitlyInline(ImplicitInlineCXX20);
+  NewFD->setImplicitlyInline();
 }
 
 if (SC == SC_Static && isa(NewFD) &&

diff  --git a/clang/test/AST/ast-dump-constant-expr.cpp 
b/clang/test/AST/ast-dump-constant-expr.cpp
index 302f562eadd96..79cdfc639af5b 100644
--- a/clang/test/AST/ast-dump-constant-expr.cpp
+++ b/clang/test/AST/ast-dump-constant-expr.cpp
@@ -58,7 +58,7 @@ struct Test {
 
 // CHECK:Dumping Test:
 // CHECK-NEXT:CXXRecordDecl {{.*}} <{{.*}}ast-dump-constant-expr.cpp:43:1, 
line:57:1> line:43:8 struct Test definition
-// CHECK:|-CXXMethodDecl {{.*}}  line:44:8 test 'void 
()' implicit-inline
+// CHECK:|-CXXMethodDecl {{.*}}  line:44:8 test 'void ()'
 // CHECK-NEXT:| `-CompoundStmt {{.*}} 
 // CHECK-NEXT:|   |-CStyleCastExpr {{.*}}  'void' 
 // CHECK-NEXT:|   | `-ConstantExpr {{.*}}  'int'
@@ -90,4 +90,4 @@ struct Test {
 // CHECK-NEXT:|   `-CallExpr {{.*}}  '__int128'
 // CHECK-NEXT:| `-ImplicitCastExpr {{.*}}  '__int128 (*)()' 

 // CHECK-NEXT:|   `-DeclRefExpr {{.*}}  '__int128 ()' lvalue 
Function {{.*}} 'test_Int128' '__int128 ()'
-// CHECK-NEXT:`-CXXMethodDecl {{.*}}  col:18 consteval 
consteval_method 'void 

[PATCH] D128914: [HIP] Add support for handling HIP in the linker wrapper

2022-07-11 Thread Joseph Huber via Phabricator via cfe-commits
jhuber6 added a comment.

In D128914#3643451 , @yaxunl wrote:

> If you only unregister fatbin once for the whole program, then it should be 
> safe -fgpu-rdc. I am not sure if that is the case.

it should be here, the generated handle is private to the registration module 
we created We only make one and it's impossible for anyone else to touch it 
even if mixing rdc with non-rdc codes.

> My experience with -fgpu-rdc is that it causes much longer linking time for 
> large applications like PyTorch or TensroFlow, and LTO does not help. This is 
> because the compiler has lots of inter-procedural optimization passes which 
> take more than linear time. Due to that those apps need to be compiled as 
> -fno-gpu-rdc. Actually most CUDA/HIP applications are using -fno-gpu-rdc.

Yes, it's actually pretty difficult to find a CUDA application using 
`fgpu-rdc`. It seems much more common to just stick everything that's needed in 
the file.I've considered finding a CUDA / HIP benchmark suite and comparing 
compile times using the new driver stuff. The benefit of having `fgpu-rdc` be 
the default is that device code basically behaves exactly like host code and 
LTO makes `fgpu-rdc` behave like `fno-gpu-rdc` performance wise. The downside, 
as you mentioned, is compile time.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128914

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


[PATCH] D129514: Thread safety analysis: Support builtin pointer-to-member operators

2022-07-11 Thread Aaron Puchert via Phabricator via cfe-commits
aaronpuchert created this revision.
aaronpuchert added a reviewer: aaron.ballman.
Herald added a reviewer: NoQ.
Herald added a project: All.
aaronpuchert requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

We consider an access to x.*pm as access of the same kind into x, and
an access to px->*pm as access of the same kind into *px. Previously we
missed reads and writes in the .* case, and operations to the pointed-to
data for ->* (we didn't miss accesses to the pointer itself, because
that requires an LValueToRValue cast that we treat independently).

We added support for overloaded operator->* in D124966 
.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D129514

Files:
  clang/lib/Analysis/ThreadSafety.cpp
  clang/test/SemaCXX/warn-thread-safety-analysis.cpp


Index: clang/test/SemaCXX/warn-thread-safety-analysis.cpp
===
--- clang/test/SemaCXX/warn-thread-safety-analysis.cpp
+++ clang/test/SemaCXX/warn-thread-safety-analysis.cpp
@@ -4870,6 +4870,8 @@
   intsa[10] GUARDED_BY(mu1);
   Cell   sc[10] GUARDED_BY(mu1);
 
+  static constexpr int Cell::*pa = ::a;
+
   void test1() {
 mu1.Lock();
 if (a == 0) doSomething();  // OK, we don't dereference.
@@ -4889,9 +4891,11 @@
 
 if (c->a == 0) doSomething();// expected-warning {{reading the value 
pointed to by 'c' requires holding mutex 'mu2'}}
 c->a = 0;// expected-warning {{writing the value 
pointed to by 'c' requires holding mutex 'mu2' exclusively}}
+c->*pa = 0;  // expected-warning {{writing the value 
pointed to by 'c' requires holding mutex 'mu2' exclusively}}
 
 if ((*c).a == 0) doSomething();  // expected-warning {{reading the value 
pointed to by 'c' requires holding mutex 'mu2'}}
 (*c).a = 0;  // expected-warning {{writing the value 
pointed to by 'c' requires holding mutex 'mu2' exclusively}}
+(*c).*pa = 0;// expected-warning {{writing the value 
pointed to by 'c' requires holding mutex 'mu2' exclusively}}
 
 if (a[0] == 42) doSomething(); // expected-warning {{reading the value 
pointed to by 'a' requires holding mutex 'mu2'}}
 a[0] = 57; // expected-warning {{writing the value 
pointed to by 'a' requires holding mutex 'mu2' exclusively}}
@@ -4923,6 +4927,7 @@
 sa[0] = 57; // expected-warning {{writing variable 
'sa' requires holding mutex 'mu1' exclusively}}
 if (sc[0].a == 42) doSomething();   // expected-warning {{reading variable 
'sc' requires holding mutex 'mu1'}}
 sc[0].a = 57;   // expected-warning {{writing variable 
'sc' requires holding mutex 'mu1' exclusively}}
+sc[0].*pa = 57; // expected-warning {{writing variable 
'sc' requires holding mutex 'mu1' exclusively}}
 
 if (*sa == 42) doSomething();   // expected-warning {{reading variable 
'sa' requires holding mutex 'mu1'}}
 *sa = 57;   // expected-warning {{writing variable 
'sa' requires holding mutex 'mu1' exclusively}}
Index: clang/lib/Analysis/ThreadSafety.cpp
===
--- clang/lib/Analysis/ThreadSafety.cpp
+++ clang/lib/Analysis/ThreadSafety.cpp
@@ -1679,6 +1679,17 @@
 return;
   }
 
+  if (const auto *BO = dyn_cast(Exp)) {
+switch (BO->getOpcode()) {
+case BO_PtrMemD: // .*
+  return checkAccess(BO->getLHS(), AK, POK);
+case BO_PtrMemI: // ->*
+  return checkPtAccess(BO->getLHS(), AK, POK);
+default:
+  return;
+}
+  }
+
   if (const auto *AE = dyn_cast(Exp)) {
 checkPtAccess(AE->getLHS(), AK, POK);
 return;


Index: clang/test/SemaCXX/warn-thread-safety-analysis.cpp
===
--- clang/test/SemaCXX/warn-thread-safety-analysis.cpp
+++ clang/test/SemaCXX/warn-thread-safety-analysis.cpp
@@ -4870,6 +4870,8 @@
   intsa[10] GUARDED_BY(mu1);
   Cell   sc[10] GUARDED_BY(mu1);
 
+  static constexpr int Cell::*pa = ::a;
+
   void test1() {
 mu1.Lock();
 if (a == 0) doSomething();  // OK, we don't dereference.
@@ -4889,9 +4891,11 @@
 
 if (c->a == 0) doSomething();// expected-warning {{reading the value pointed to by 'c' requires holding mutex 'mu2'}}
 c->a = 0;// expected-warning {{writing the value pointed to by 'c' requires holding mutex 'mu2' exclusively}}
+c->*pa = 0;  // expected-warning {{writing the value pointed to by 'c' requires holding mutex 'mu2' exclusively}}
 
 if ((*c).a == 0) doSomething();  // expected-warning {{reading the value pointed to by 'c' requires holding mutex 'mu2'}}
 (*c).a = 0;  // expected-warning {{writing the value pointed to by 'c' requires holding mutex 'mu2' 

[PATCH] D128914: [HIP] Add support for handling HIP in the linker wrapper

2022-07-11 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl added a comment.

In D128914#3643270 , @jhuber6 wrote:

>> There is only one fatbin for -fgpu-rdc mode but the fatbin unregister 
>> function is called multiple times in each TU. HIP runtime expects each 
>> fatbin is unregistered only once. The old embedding scheme introduced a weak 
>> symbol to track whether the fabin has been unregistered and to make sure it 
>> is only unregistered once.
>
> I see, this wrapping will only happen in RDC-mode so it's probably safe to 
> ignore here? When I support non-RDC mode in the new driver it will most 
> likely rely on the old code generation. Although it's entirely feasible to 
> make RDC-mode the default. There's no runtime overhead when using LTO.

If you only unregister fatbin once for the whole program, then it should be 
safe -fgpu-rdc. I am not sure if that is the case.

My experience with -fgpu-rdc is that it causes much longer linking time for 
large applications like PyTorch or TensroFlow, and LTO does not help. This is 
because the compiler has lots of inter-procedural optimization passes which 
take more than linear time. Due to that those apps need to be compiled as 
-fno-gpu-rdc. Actually most CUDA/HIP applications are using -fno-gpu-rdc.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128914

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


[PATCH] D129170: [Sema] Add deprecation warnings for some compiler provided __has_* type traits

2022-07-11 Thread Roy Jacobson via Phabricator via cfe-commits
royjacobson added inline comments.



Comment at: clang/lib/Sema/SemaExprCXX.cpp:5400-5401
+SourceLocation KWLoc) {
+  if (!S.getLangOpts().CPlusPlus11)
+return;
+

aaron.ballman wrote:
> royjacobson wrote:
> > aaron.ballman wrote:
> > > erichkeane wrote:
> > > > royjacobson wrote:
> > > > > erichkeane wrote:
> > > > > > royjacobson wrote:
> > > > > > > aaron.ballman wrote:
> > > > > > > > I think we should always warn on these, not just in C++11.
> > > > > > > I'm not convinced we should. My reasoning is that we need a 
> > > > > > > pretty good reason to start issuing warnings for 20 years old 
> > > > > > > code. The usage of those builtins with deleted functions after 
> > > > > > > C++11 is pretty broken which is a pretty good reason, but for 
> > > > > > > earlier language versions they work 'fine' and if people want to 
> > > > > > > use C++03 I prefer leaving them at peace :)
> > > > > > > 
> > > > > > > People on C++03 are also probably using pretty old versions of 
> > > > > > > libstdc++ and/or boost type_traits, so this could have some 
> > > > > > > impact.
> > > > > > > 
> > > > > > > WDYT?
> > > > > > > 
> > > > > > warnings don't get emitted for code in header files, so at least 
> > > > > > that part isn't a concern.  
> > > > > Any header files, or just system headers?
> > > > Sorry, yes, Phab is a mess on a cell phone... in things included as 
> > > > System Headers.
> > > Agreed with Erich -- warnings in system headers (but not regular headers) 
> > > are silenced by default, you need to pass `-Wsystem-headers` to enable 
> > > them.
> > To clarify my position, I think about those builtins as an unofficial part 
> > of the C++03 standard and I think we should support them as long as we 
> > support C++03.
> > 
> > Do you think that's reasonable?
> > 
> > I agree we should update the documentation in this case.
> I still don't see the benefit of undeprecating these in C++03. The 
> replacement interfaces are available for use in C++03 mode, so there's 
> nothing that prevents a user from being pushed to use the supported 
> interfaces instead, right? To me, the older interfaces were not clean/correct 
> and the replacement interfaces are the ones that we want people to use, and 
> that's language mode agnostic.
I think they're 
1. Clean enough under C++03 semantics - without the extra complications of move 
semantics, defaulted/deleted functions etc.
2. Potentially pretty widely used in code that needs C++03, though I have no 
idea how to check that.

But you convinced me that it's probably not that of a big deal to add those 
warnings anyway, so let's add them and think about actual deprecation in a few 
years :)




Comment at: clang/lib/Sema/SemaExprCXX.cpp:5433
+// FIXME: GCC don't implement __is_trivially_destructible: Warning for this
+//   might be too noisy for now.
+// case UTT_HasTrivialDestructor:

aaron.ballman wrote:
> royjacobson wrote:
> > aaron.ballman wrote:
> > > I'd like to know how plausible that "might" is -- Clang flags it as being 
> > > deprecated, so it seems very reasonable to diagnose it as such. These 
> > > diagnostics won't be triggered from system headers by default anyway, so 
> > > I'm not certain if this will be too noisy in practice.
> > It's used in libstdc++'s type_traits and in boost's type_traits (but we 
> > will start warning on boost's type_traits anyway). So it's even if by 
> > default people are not going to see it I think it's used widely enough to 
> > be problematic and we shouldn't warn on this for now.
> > 
> > I added the libstdc++ part to the comment as well.
> My feeling is: if it's deprecated and we don't warn on it, it's not actually 
> deprecated. I'd rather see us warn uniformly on all the deprecated 
> interfaces. System headers are free to keep using these interfaces (system 
> headers are long lived), but any user code using this needs some sort of 
> notification that they're using something we don't want them to use, or we 
> will never be able to get rid of these interfaces (at which point, we should 
> undeprecate them because we need to keep them working).
Ok, added it to the warnings.



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D129170

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


[PATCH] D129170: [Sema] Add deprecation warnings for some compiler provided __has_* type traits

2022-07-11 Thread Roy Jacobson via Phabricator via cfe-commits
royjacobson updated this revision to Diff 443742.
royjacobson added a comment.

Warn on <=C++03 as well, warn on __has_trivial_destructor.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D129170

Files:
  clang/docs/ReleaseNotes.rst
  clang/include/clang/Basic/DiagnosticGroups.td
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/Sema/SemaExprCXX.cpp
  clang/test/CXX/dcl.decl/dcl.init/p5.cpp
  clang/test/CXX/drs/dr18xx.cpp
  clang/test/CXX/drs/dr21xx.cpp
  clang/test/CXX/special/class.copy/p12-0x.cpp
  clang/test/CXX/special/class.copy/p25-0x.cpp
  clang/test/CXX/special/class.ctor/p5-0x.cpp
  clang/test/Modules/cxx-decls.cpp
  clang/test/SemaCXX/cxx0x-defaulted-functions.cpp
  clang/test/SemaCXX/cxx11-crashes.cpp
  clang/test/SemaCXX/deprecated-builtins.cpp
  clang/test/SemaCXX/sizeless-1.cpp
  clang/test/SemaCXX/trivial-constructor.cpp
  clang/test/SemaCXX/trivial-destructor.cpp
  clang/test/SemaCXX/type-traits.cpp
  clang/test/SemaObjCXX/arc-type-traits.mm
  clang/test/SemaObjCXX/objc-weak-type-traits.mm

Index: clang/test/SemaObjCXX/objc-weak-type-traits.mm
===
--- clang/test/SemaObjCXX/objc-weak-type-traits.mm
+++ clang/test/SemaObjCXX/objc-weak-type-traits.mm
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -fobjc-weak -fobjc-runtime-has-weak -verify -std=c++11 %s
+// RUN: %clang_cc1 -fsyntax-only -fobjc-weak -fobjc-runtime-has-weak -verify -std=c++11 %s -Wno-deprecated-builtins
 // expected-no-diagnostics
 
 // Check the results of the various type-trait query functions on
Index: clang/test/SemaObjCXX/arc-type-traits.mm
===
--- clang/test/SemaObjCXX/arc-type-traits.mm
+++ clang/test/SemaObjCXX/arc-type-traits.mm
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -fobjc-arc -fobjc-runtime-has-weak -verify -std=c++11 %s
+// RUN: %clang_cc1 -fsyntax-only -fobjc-arc -fobjc-runtime-has-weak -verify -std=c++11 %s -Wno-deprecated-builtins
 // expected-no-diagnostics
 
 // Check the results of the various type-trait query functions on
Index: clang/test/SemaCXX/type-traits.cpp
===
--- clang/test/SemaCXX/type-traits.cpp
+++ clang/test/SemaCXX/type-traits.cpp
@@ -1,6 +1,6 @@
-// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fsyntax-only -verify -std=gnu++11 -fms-extensions -Wno-microsoft %s
-// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fsyntax-only -verify -std=gnu++14 -fms-extensions -Wno-microsoft %s
-// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fsyntax-only -verify -std=gnu++1z -fms-extensions -Wno-microsoft %s
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fsyntax-only -verify -std=gnu++11 -Wno-deprecated-builtins -fms-extensions -Wno-microsoft %s
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fsyntax-only -verify -std=gnu++14 -Wno-deprecated-builtins -fms-extensions -Wno-microsoft %s
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fsyntax-only -verify -std=gnu++1z -Wno-deprecated-builtins -fms-extensions -Wno-microsoft %s
 
 #define T(b) (b) ? 1 : -1
 #define F(b) (b) ? -1 : 1
Index: clang/test/SemaCXX/trivial-destructor.cpp
===
--- clang/test/SemaCXX/trivial-destructor.cpp
+++ clang/test/SemaCXX/trivial-destructor.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++11
+// RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++11 -Wno-deprecated-builtins
 // expected-no-diagnostics
 struct T1 {
 };
Index: clang/test/SemaCXX/trivial-constructor.cpp
===
--- clang/test/SemaCXX/trivial-constructor.cpp
+++ clang/test/SemaCXX/trivial-constructor.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++11
+// RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++11 -Wno-deprecated-builtins
 // expected-no-diagnostics
 struct T1 {
 };
Index: clang/test/SemaCXX/sizeless-1.cpp
===
--- clang/test/SemaCXX/sizeless-1.cpp
+++ clang/test/SemaCXX/sizeless-1.cpp
@@ -1,7 +1,7 @@
-// RUN: %clang_cc1 -fcxx-exceptions -fsyntax-only -verify -W -Wall -Wno-unused-but-set-variable -Wrange-loop-analysis -triple arm64-linux-gnu -target-feature +sve -std=c++98 %s
-// RUN: %clang_cc1 -fcxx-exceptions -fsyntax-only -verify -W -Wall -Wno-unused-but-set-variable -Wrange-loop-analysis -triple arm64-linux-gnu -target-feature +sve -std=c++11 %s
-// RUN: %clang_cc1 -fcxx-exceptions -fsyntax-only -verify -W -Wall -Wno-unused-but-set-variable -Wrange-loop-analysis -triple arm64-linux-gnu -target-feature +sve -std=c++17 %s
-// RUN: %clang_cc1 -fcxx-exceptions -fsyntax-only -verify -W -Wall -Wno-unused-but-set-variable -Wrange-loop-analysis -triple arm64-linux-gnu -target-feature +sve -std=gnu++17 %s
+// RUN: %clang_cc1 

[PATCH] D105255: [MLIR][OpenMP] Added target data, exit data, and enter data operation definition for MLIR.

2022-07-11 Thread Valentin Clement via Phabricator via cfe-commits
clementval added a comment.

Why not adding the assemblyFormat directly for these operations like your patch 
D105584 ?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105255

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


[PATCH] D105584: [MLIR][OpenMP] Distribute Construct Operation

2022-07-11 Thread Valentin Clement via Phabricator via cfe-commits
clementval added inline comments.



Comment at: mlir/include/mlir/Dialect/OpenMP/OpenMPOps.td:449
  ParentOneOf<["WsLoopOp", "ReductionDeclareOp", 
- "AtomicUpdateOp", "SimdLoopOp"]>]> {
+ "AtomicUpdateOp", "SimdLoopOp","DistributeOp"]>]> {
   let summary = "loop yield and termination operation";




Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105584

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


[PATCH] D128411: [syntax] Introduce a BaseToken class.

2022-07-11 Thread Haojian Wu via Phabricator via cfe-commits
hokein added inline comments.



Comment at: clang/include/clang/Tooling/Syntax/SyntaxTokenManager.h:20
+/// It tracks the underlying token buffers, source manager, etc.
+class SyntaxTokenManager : public TokenManager {
+public:

sammccall wrote:
> I don't think "syntax" in "syntax token manager" is particularly 
> disambiguating here, both TokenBuffer and TokenManager are part of syntax, so 
> it's not clear what it refers to (and it doens't have any obvious 
> plain-english meaning).
> 
> Maybe some combination like `TokenBufferTokenManager` or `BufferTokenManager`.
> In fact I think best is `TokenBuffer::TokenManager`, still defined in a 
> separate header, though I'm not sure if you think that's too weird.
Renamed to TokenBufferTokenManager. 

`BufferTokenManager` name is short, but it has `BufferToken` prefix, which 
seems confusing with `TokenBuffer`. `TokenBuffer::TokenManager` is weird to me, 
and doesn't reflect the layering IMO



Comment at: clang/lib/Tooling/Syntax/BuildTree.cpp:370
+  TreeBuilder(syntax::Arena )
+  : Arena(Arena), STM(cast(Arena.getTokenManager())),
+Pending(Arena, STM.tokenBuffer()) {

sammccall wrote:
> need changes to the public API to make this cast valid
Are you suggesting to change all public APIs where there is such a cast usage?

If yes, this seems not a trivial change, I think at least we will change all 
APIs (`buildSyntaxTree`, `createLeaf`, `createTree`, `deepCopyExpandingMacros`) 
in `BuildTree.h` (by adding a new `TokenBufferTokenManager` parameter). 
And the `Arena` probably doesn't need to have a `TokenManager` field (it could 
be simplified as a single `BumpPtrAllocator`), as the TokenManager is passed in 
parallel with the Arena.

I'm happy to do the change, but IMO, the current version doesn't seem too bad 
for me (if we pass an non-SyntaxTokenManager, it will trigger an assertion in 
debug mode).



Comment at: clang/lib/Tooling/Syntax/ComputeReplacements.cpp:94
 const syntax::TranslationUnit ) {
-  const auto  = A.getTokenBuffer();
-  const auto  = A.getSourceManager();
+  const auto  = llvm::cast(A.getTokenManager());
+  const auto  = STM.tokenBuffer();

sammccall wrote:
> Need a change to the public interface to guarantee this cast will succeed.
> The cleanest would be just to take the SyntaxTokenManager as a param (moving 
> the cast to the call site - I don't think Arena is otherwise used for 
> anything).
> 
> Failing that we at least need to update the contract
Done, this is a trivial change.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128411

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


[PATCH] D128411: [syntax] Introduce a BaseToken class.

2022-07-11 Thread Haojian Wu via Phabricator via cfe-commits
hokein updated this revision to Diff 443737.
hokein added a comment.

more update


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128411

Files:
  clang/include/clang/Tooling/Syntax/Mutations.h
  clang/include/clang/Tooling/Syntax/Nodes.h
  clang/include/clang/Tooling/Syntax/TokenBufferTokenManager.h
  clang/include/clang/Tooling/Syntax/TokenManager.h
  clang/include/clang/Tooling/Syntax/Tokens.h
  clang/include/clang/Tooling/Syntax/Tree.h
  clang/lib/Tooling/Syntax/BuildTree.cpp
  clang/lib/Tooling/Syntax/CMakeLists.txt
  clang/lib/Tooling/Syntax/ComputeReplacements.cpp
  clang/lib/Tooling/Syntax/Synthesis.cpp
  clang/lib/Tooling/Syntax/TokenBufferTokenManager.cpp
  clang/lib/Tooling/Syntax/Tree.cpp
  clang/tools/clang-check/ClangCheck.cpp
  clang/unittests/Tooling/Syntax/BuildTreeTest.cpp
  clang/unittests/Tooling/Syntax/MutationsTest.cpp
  clang/unittests/Tooling/Syntax/SynthesisTest.cpp
  clang/unittests/Tooling/Syntax/TreeTest.cpp
  clang/unittests/Tooling/Syntax/TreeTestBase.cpp
  clang/unittests/Tooling/Syntax/TreeTestBase.h

Index: clang/unittests/Tooling/Syntax/TreeTestBase.h
===
--- clang/unittests/Tooling/Syntax/TreeTestBase.h
+++ clang/unittests/Tooling/Syntax/TreeTestBase.h
@@ -17,6 +17,7 @@
 #include "clang/Frontend/CompilerInvocation.h"
 #include "clang/Testing/TestClangConfig.h"
 #include "clang/Tooling/Syntax/Nodes.h"
+#include "clang/Tooling/Syntax/TokenBufferTokenManager.h"
 #include "clang/Tooling/Syntax/Tokens.h"
 #include "clang/Tooling/Syntax/Tree.h"
 #include "llvm/ADT/StringRef.h"
@@ -51,6 +52,7 @@
   std::shared_ptr Invocation;
   // Set after calling buildTree().
   std::unique_ptr TB;
+  std::unique_ptr TM;
   std::unique_ptr Arena;
 };
 
Index: clang/unittests/Tooling/Syntax/TreeTestBase.cpp
===
--- clang/unittests/Tooling/Syntax/TreeTestBase.cpp
+++ clang/unittests/Tooling/Syntax/TreeTestBase.cpp
@@ -35,13 +35,14 @@
 using namespace clang::syntax;
 
 namespace {
-ArrayRef tokens(syntax::Node *N) {
+ArrayRef tokens(syntax::Node *N,
+   const TokenBufferTokenManager ) {
   assert(N->isOriginal() && "tokens of modified nodes are not well-defined");
   if (auto *L = dyn_cast(N))
-return llvm::makeArrayRef(L->getToken(), 1);
+return llvm::makeArrayRef(STM.getToken(L->getTokenKey()), 1);
   auto *T = cast(N);
-  return llvm::makeArrayRef(T->findFirstLeaf()->getToken(),
-T->findLastLeaf()->getToken() + 1);
+  return llvm::makeArrayRef(STM.getToken(T->findFirstLeaf()->getTokenKey()),
+STM.getToken(T->findLastLeaf()->getTokenKey()) + 1);
 }
 } // namespace
 
@@ -70,23 +71,26 @@
   public:
 BuildSyntaxTree(syntax::TranslationUnit *,
 std::unique_ptr ,
+std::unique_ptr ,
 std::unique_ptr ,
 std::unique_ptr Tokens)
-: Root(Root), TB(TB), Arena(Arena), Tokens(std::move(Tokens)) {
+: Root(Root), TB(TB), TM(TM), Arena(Arena), Tokens(std::move(Tokens)) {
   assert(this->Tokens);
 }
 
 void HandleTranslationUnit(ASTContext ) override {
   TB = std::make_unique(std::move(*Tokens).consume());
   Tokens = nullptr; // make sure we fail if this gets called twice.
-  Arena = std::make_unique(Ctx.getSourceManager(),
-  Ctx.getLangOpts(), *TB);
+  TM = std::make_unique(
+  *TB, Ctx.getLangOpts(), Ctx.getSourceManager());
+  Arena = std::make_unique(*TM);
   Root = syntax::buildSyntaxTree(*Arena, Ctx);
 }
 
   private:
 syntax::TranslationUnit *
 std::unique_ptr 
+std::unique_ptr 
 std::unique_ptr 
 std::unique_ptr Tokens;
   };
@@ -94,21 +98,23 @@
   class BuildSyntaxTreeAction : public ASTFrontendAction {
   public:
 BuildSyntaxTreeAction(syntax::TranslationUnit *,
+  std::unique_ptr ,
   std::unique_ptr ,
   std::unique_ptr )
-: Root(Root), TB(TB), Arena(Arena) {}
+: Root(Root), TM(TM), TB(TB), Arena(Arena) {}
 
 std::unique_ptr CreateASTConsumer(CompilerInstance ,
StringRef InFile) override {
   // We start recording the tokens, ast consumer will take on the result.
   auto Tokens =
   std::make_unique(CI.getPreprocessor());
-  return std::make_unique(Root, TB, Arena,
+  return std::make_unique(Root, TB, TM, Arena,
std::move(Tokens));
 }
 
   private:
 syntax::TranslationUnit *
+std::unique_ptr 
 std::unique_ptr 
 std::unique_ptr 
   };
@@ -149,7 +155,7 @@
   Compiler.setSourceManager(SourceMgr.get());
 
   syntax::TranslationUnit *Root = nullptr;
-  

[PATCH] D128411: [syntax] Introduce a BaseToken class.

2022-07-11 Thread Haojian Wu via Phabricator via cfe-commits
hokein updated this revision to Diff 443736.
hokein marked 7 inline comments as done.
hokein added a comment.

address comments.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128411

Files:
  clang/include/clang/Tooling/Syntax/Mutations.h
  clang/include/clang/Tooling/Syntax/Nodes.h
  clang/include/clang/Tooling/Syntax/TokenBufferTokenManager.h
  clang/include/clang/Tooling/Syntax/TokenManager.h
  clang/include/clang/Tooling/Syntax/Tokens.h
  clang/include/clang/Tooling/Syntax/Tree.h
  clang/lib/Tooling/Syntax/BuildTree.cpp
  clang/lib/Tooling/Syntax/CMakeLists.txt
  clang/lib/Tooling/Syntax/ComputeReplacements.cpp
  clang/lib/Tooling/Syntax/Synthesis.cpp
  clang/lib/Tooling/Syntax/TokenBufferTokenManager.cpp
  clang/lib/Tooling/Syntax/Tree.cpp
  clang/tools/clang-check/ClangCheck.cpp
  clang/unittests/Tooling/Syntax/BuildTreeTest.cpp
  clang/unittests/Tooling/Syntax/MutationsTest.cpp
  clang/unittests/Tooling/Syntax/SynthesisTest.cpp
  clang/unittests/Tooling/Syntax/TreeTest.cpp
  clang/unittests/Tooling/Syntax/TreeTestBase.cpp
  clang/unittests/Tooling/Syntax/TreeTestBase.h

Index: clang/unittests/Tooling/Syntax/TreeTestBase.h
===
--- clang/unittests/Tooling/Syntax/TreeTestBase.h
+++ clang/unittests/Tooling/Syntax/TreeTestBase.h
@@ -17,6 +17,7 @@
 #include "clang/Frontend/CompilerInvocation.h"
 #include "clang/Testing/TestClangConfig.h"
 #include "clang/Tooling/Syntax/Nodes.h"
+#include "clang/Tooling/Syntax/TokenBufferTokenManager.h"
 #include "clang/Tooling/Syntax/Tokens.h"
 #include "clang/Tooling/Syntax/Tree.h"
 #include "llvm/ADT/StringRef.h"
@@ -51,6 +52,7 @@
   std::shared_ptr Invocation;
   // Set after calling buildTree().
   std::unique_ptr TB;
+  std::unique_ptr TM;
   std::unique_ptr Arena;
 };
 
Index: clang/unittests/Tooling/Syntax/TreeTestBase.cpp
===
--- clang/unittests/Tooling/Syntax/TreeTestBase.cpp
+++ clang/unittests/Tooling/Syntax/TreeTestBase.cpp
@@ -35,13 +35,14 @@
 using namespace clang::syntax;
 
 namespace {
-ArrayRef tokens(syntax::Node *N) {
+ArrayRef tokens(syntax::Node *N,
+   const TokenBufferTokenManager ) {
   assert(N->isOriginal() && "tokens of modified nodes are not well-defined");
   if (auto *L = dyn_cast(N))
-return llvm::makeArrayRef(L->getToken(), 1);
+return llvm::makeArrayRef(STM.getToken(L->getTokenKey()), 1);
   auto *T = cast(N);
-  return llvm::makeArrayRef(T->findFirstLeaf()->getToken(),
-T->findLastLeaf()->getToken() + 1);
+  return llvm::makeArrayRef(STM.getToken(T->findFirstLeaf()->getTokenKey()),
+STM.getToken(T->findLastLeaf()->getTokenKey()) + 1);
 }
 } // namespace
 
@@ -70,23 +71,26 @@
   public:
 BuildSyntaxTree(syntax::TranslationUnit *,
 std::unique_ptr ,
+std::unique_ptr ,
 std::unique_ptr ,
 std::unique_ptr Tokens)
-: Root(Root), TB(TB), Arena(Arena), Tokens(std::move(Tokens)) {
+: Root(Root), TB(TB), TM(TM), Arena(Arena), Tokens(std::move(Tokens)) {
   assert(this->Tokens);
 }
 
 void HandleTranslationUnit(ASTContext ) override {
   TB = std::make_unique(std::move(*Tokens).consume());
   Tokens = nullptr; // make sure we fail if this gets called twice.
-  Arena = std::make_unique(Ctx.getSourceManager(),
-  Ctx.getLangOpts(), *TB);
+  TM = std::make_unique(
+  *TB, Ctx.getLangOpts(), Ctx.getSourceManager());
+  Arena = std::make_unique(*TM);
   Root = syntax::buildSyntaxTree(*Arena, Ctx);
 }
 
   private:
 syntax::TranslationUnit *
 std::unique_ptr 
+std::unique_ptr 
 std::unique_ptr 
 std::unique_ptr Tokens;
   };
@@ -94,21 +98,23 @@
   class BuildSyntaxTreeAction : public ASTFrontendAction {
   public:
 BuildSyntaxTreeAction(syntax::TranslationUnit *,
+  std::unique_ptr ,
   std::unique_ptr ,
   std::unique_ptr )
-: Root(Root), TB(TB), Arena(Arena) {}
+: Root(Root), TM(TM), TB(TB), Arena(Arena) {}
 
 std::unique_ptr CreateASTConsumer(CompilerInstance ,
StringRef InFile) override {
   // We start recording the tokens, ast consumer will take on the result.
   auto Tokens =
   std::make_unique(CI.getPreprocessor());
-  return std::make_unique(Root, TB, Arena,
+  return std::make_unique(Root, TB, TM, Arena,
std::move(Tokens));
 }
 
   private:
 syntax::TranslationUnit *
+std::unique_ptr 
 std::unique_ptr 
 std::unique_ptr 
   };
@@ -149,7 +155,7 @@
   Compiler.setSourceManager(SourceMgr.get());
 
   

[PATCH] D129476: [AArch64][SVE] Prefer SIMD variant of clast[ab]

2022-07-11 Thread Eli Friedman via Phabricator via cfe-commits
efriedma added a comment.

Are you saying that it's faster to use clasta targeting a float register, then 
move the result to an integer register, rather than use the integer form 
directly?  Or is the issue just that we want to split the operations in case we 
can simplify the resulting bitcast?

Do we expect SelectionDAG to combine a clasta+bitcast to a single instruction?  
Do we have test coverage for that?


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

https://reviews.llvm.org/D129476

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


[PATCH] D129512: [Driver] Don't use frame pointer on Fuchsia when optimizations are enabled

2022-07-11 Thread Roland McGrath via Phabricator via cfe-commits
mcgrathr accepted this revision.
mcgrathr added a comment.
This revision is now accepted and ready to land.

lgtm but be sure that Fuchsia target users get clear release-notes warning 
about the change.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D129512

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


[PATCH] D111283: [clang] template / auto deduction deduces common sugar

2022-07-11 Thread Matheus Izvekov via Phabricator via cfe-commits
mizvekov updated this revision to Diff 443734.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D111283

Files:
  clang/include/clang/AST/ASTContext.h
  clang/include/clang/AST/Type.h
  clang/include/clang/Sema/Sema.h
  clang/lib/AST/ASTContext.cpp
  clang/lib/Sema/SemaDecl.cpp
  clang/lib/Sema/SemaExprCXX.cpp
  clang/lib/Sema/SemaOverload.cpp
  clang/lib/Sema/SemaStmt.cpp
  clang/lib/Sema/SemaTemplate.cpp
  clang/lib/Sema/SemaTemplateDeduction.cpp
  clang/test/SemaCXX/deduced-return-void.cpp
  clang/test/SemaCXX/sugared-auto.cpp
  clang/test/SemaTemplate/deduction.cpp
  libcxx/DELETE.ME

Index: libcxx/DELETE.ME
===
--- /dev/null
+++ libcxx/DELETE.ME
@@ -0,0 +1 @@
+D111283
Index: clang/test/SemaTemplate/deduction.cpp
===
--- clang/test/SemaTemplate/deduction.cpp
+++ clang/test/SemaTemplate/deduction.cpp
@@ -162,6 +162,15 @@
 
 } // namespace test4
 
+namespace test5 {
+
+template  class a {};
+template  void c(b, b);
+template  void c(a, a);
+void d() { c(a(), a()); }
+
+} // namespace test5
+
 // Verify that we can deduce enum-typed arguments correctly.
 namespace test14 {
   enum E { E0, E1 };
Index: clang/test/SemaCXX/sugared-auto.cpp
===
--- clang/test/SemaCXX/sugared-auto.cpp
+++ clang/test/SemaCXX/sugared-auto.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++20
+// RUN: %clang_cc1 -fsyntax-only -verify -xobjective-c++ %s -std=c++20 -fblocks -fobjc-arc -fobjc-runtime-has-weak -fenable-matrix -Wno-dynamic-exception-spec
 
 enum class N {};
 
@@ -9,6 +9,26 @@
 using Man = Animal;
 using Dog = Animal;
 
+using ManPtr = Man *;
+using DogPtr = Dog *;
+
+using SocratesPtr = ManPtr;
+
+using ConstMan = const Man;
+using ConstDog = const Dog;
+
+using Virus = void;
+using SARS = Virus;
+using Ebola = Virus;
+
+using Bacteria = float;
+using Bacilli = Bacteria;
+using Vibrio = Bacteria;
+
+struct Plant;
+using Gymnosperm = Plant;
+using Angiosperm = Plant;
+
 namespace variable {
 
 auto x1 = Animal();
@@ -41,3 +61,123 @@
 N t3 = x3; // expected-error {{lvalue of type 'Animal' (aka 'int')}}
 
 } // namespace function_basic
+
+namespace function_multiple_basic {
+
+N t1 = [] { // expected-error {{rvalue of type 'Animal' (aka 'int')}}
+  if (true)
+return Man();
+  return Dog();
+}();
+
+N t2 = []() -> decltype(auto) { // expected-error {{rvalue of type 'Animal' (aka 'int')}}
+  if (true)
+return Man();
+  return Dog();
+}();
+
+N t3 = [] { // expected-error {{rvalue of type 'Animal' (aka 'int')}}
+  if (true)
+return Dog();
+  auto x = Man();
+  return x;
+}();
+
+N t4 = [] { // expected-error {{rvalue of type 'int'}}
+  if (true)
+return Dog();
+  return 1;
+}();
+
+N t5 = [] { // expected-error {{rvalue of type 'Virus' (aka 'void')}}
+  if (true)
+return Ebola();
+  return SARS();
+}();
+
+N t6 = [] { // expected-error {{rvalue of type 'void'}}
+  if (true)
+return SARS();
+  return;
+}();
+
+} // namespace function_multiple_basic
+
+#define TEST_AUTO(X, A, B) \
+  auto X(A a, B b) {   \
+if (0) \
+  return a;\
+if (0) \
+  return b;\
+return N();\
+  }
+#define TEST_DAUTO(X, A, B) \
+  decltype(auto) X(A a, B b) {  \
+if (0)  \
+  return static_cast(a); \
+if (0)  \
+  return static_cast(b); \
+return N(); \
+  }
+
+namespace misc {
+
+TEST_AUTO(t1, ManPtr, DogPtr)  // expected-error {{but deduced as 'Animal *' (aka 'int *')}}
+TEST_AUTO(t2, ManPtr, int *)   // expected-error {{but deduced as 'int *'}}
+TEST_AUTO(t3, SocratesPtr, ManPtr) // expected-error {{but deduced as 'ManPtr' (aka 'int *')}}
+
+TEST_AUTO(t4, _Atomic(Man), _Atomic(Dog)) // expected-error {{but deduced as '_Atomic(Animal)'}}
+
+using block_man = void (^)(Man);
+using block_dog = void (^)(Dog);
+TEST_AUTO(t5, block_man, block_dog) // expected-error {{but deduced as 'void (^__strong)(Animal)'}}
+
+using fp1 = SARS (*)(Man, DogPtr) throw(Vibrio);
+using fp2 = Ebola (*)(Dog, ManPtr) throw(Bacilli);
+TEST_AUTO(t6, fp1, fp2); // expected-error {{but deduced as 'Virus (*)(Animal, Animal *) throw(Bacteria)' (aka 'void (*)(int, int *) throw(Bacteria)')}}
+
+using fp3 = SARS (*)() throw(Man);
+using fp4 = Ebola (*)() throw(Vibrio);
+auto t7(fp3 a, fp4 b) {
+  if (false)
+return true ? a : b;
+  if (false)
+return a;
+  return N(); // expected-error {{but deduced as 'SARS (*)() throw(Man, Vibrio)' (aka 'void (*)() throw(Man, Vibrio)')}}
+}
+
+using fp5 = void (*)(const Man);
+using fp6 = void (*)(Dog);
+TEST_AUTO(t8, fp5, fp6); // expected-error {{but deduced as 'void (*)(Animal)' (aka 'void (*)(int)')}}
+
+using fp7 = void (*)(ConstMan);
+using 

[PATCH] D129512: [Driver] Don't use frame pointer on Fuchsia when optimizations are enabled

2022-07-11 Thread Petr Hosek via Phabricator via cfe-commits
phosek created this revision.
phosek added a reviewer: mcgrathr.
Herald added a subscriber: abrachet.
Herald added a project: All.
phosek requested review of this revision.
Herald added subscribers: cfe-commits, MaskRay.
Herald added a project: clang.

This matches the standard behavior on other platforms.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D129512

Files:
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/test/Driver/fuchsia.c


Index: clang/test/Driver/fuchsia.c
===
--- clang/test/Driver/fuchsia.c
+++ clang/test/Driver/fuchsia.c
@@ -55,6 +55,18 @@
 // CHECK-NOT: crtend.o
 // CHECK-NOT: crtn.o
 
+// RUN: %clang -### %s --target=x86_64-unknown-fuchsia 2>&1 \
+// RUN: | FileCheck %s -check-prefix=CHECK-FP-ALL
+// RUN: %clang -### %s --target=aarch64-unknown-fuchsia 2>&1 \
+// RUN: | FileCheck %s -check-prefix=CHECK-FP-NONLEAF
+// RUN: %clang -### %s --target=x86_64-unknown-fuchsia -O3 2>&1 \
+// RUN: | FileCheck %s -check-prefix=CHECK-FP-NONE
+// RUN: %clang -### %s --target=aarch64-unknown-fuchsia -O3 2>&1 \
+// RUN: | FileCheck %s -check-prefix=CHECK-FP-NONE
+// CHECK-FP-ALL: "-mframe-pointer=all"
+// CHECK-FP-NONLEAF: "-mframe-pointer=non-leaf"
+// CHECK-FP-NONE: "-mframe-pointer=none"
+
 // RUN: %clang -### %s --target=x86_64-unknown-fuchsia -rtlib=libgcc 
-fuse-ld=lld 2>&1 \
 // RUN: | FileCheck %s -check-prefix=CHECK-RTLIB
 // CHECK-RTLIB: error: invalid runtime library name in argument '-rtlib=libgcc'
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -567,7 +567,7 @@
 break;
   }
 
-  if (Triple.isOSNetBSD()) {
+  if (Triple.isOSFuchsia() || Triple.isOSNetBSD()) {
 return !areOptimizationsEnabled(Args);
   }
 


Index: clang/test/Driver/fuchsia.c
===
--- clang/test/Driver/fuchsia.c
+++ clang/test/Driver/fuchsia.c
@@ -55,6 +55,18 @@
 // CHECK-NOT: crtend.o
 // CHECK-NOT: crtn.o
 
+// RUN: %clang -### %s --target=x86_64-unknown-fuchsia 2>&1 \
+// RUN: | FileCheck %s -check-prefix=CHECK-FP-ALL
+// RUN: %clang -### %s --target=aarch64-unknown-fuchsia 2>&1 \
+// RUN: | FileCheck %s -check-prefix=CHECK-FP-NONLEAF
+// RUN: %clang -### %s --target=x86_64-unknown-fuchsia -O3 2>&1 \
+// RUN: | FileCheck %s -check-prefix=CHECK-FP-NONE
+// RUN: %clang -### %s --target=aarch64-unknown-fuchsia -O3 2>&1 \
+// RUN: | FileCheck %s -check-prefix=CHECK-FP-NONE
+// CHECK-FP-ALL: "-mframe-pointer=all"
+// CHECK-FP-NONLEAF: "-mframe-pointer=non-leaf"
+// CHECK-FP-NONE: "-mframe-pointer=none"
+
 // RUN: %clang -### %s --target=x86_64-unknown-fuchsia -rtlib=libgcc -fuse-ld=lld 2>&1 \
 // RUN: | FileCheck %s -check-prefix=CHECK-RTLIB
 // CHECK-RTLIB: error: invalid runtime library name in argument '-rtlib=libgcc'
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -567,7 +567,7 @@
 break;
   }
 
-  if (Triple.isOSNetBSD()) {
+  if (Triple.isOSFuchsia() || Triple.isOSNetBSD()) {
 return !areOptimizationsEnabled(Args);
   }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D111283: [clang] template / auto deduction deduces common sugar

2022-07-11 Thread Matheus Izvekov via Phabricator via cfe-commits
mizvekov added inline comments.



Comment at: clang/lib/AST/ASTContext.cpp:11551-11552
+if (Unqualified && !Ctx.hasSameType(X, Y)) {
+  assert(Ctx.hasSameUnqualifiedType(X, Y));
+  auto XQuals = X.getCVRQualifiers(), YQuals = Y.getCVRQualifiers();
+  X.addFastQualifiers(YQuals & ~XQuals);

rsmith wrote:
> What should happen if there's a qualifier difference other than a CVR 
> qualifier? Eg, address space or ObjC lifetime.
I have updated the `ASContext::getCommonSugaredType` to accept an `Unqualified` 
parameter to handle this case.
We will strip qualifiers from each other until the types are the same.



Comment at: clang/lib/AST/ASTContext.cpp:11578
+  default:
+return X;
+  }

rsmith wrote:
> For `TemplateArgument::ArgKind::Declaration`, I think it'd make sense to take 
> the common type of the `getParamTypeForDecl`s.
Yeah, but this has been dead code since we went back to canonical template 
parameter / arguments.
I have removed it and put some unreachables in place.
We will circle back around to add it with this suggestion later.



Comment at: clang/lib/AST/ASTContext.cpp:11790-11801
+if (EPIX.ExceptionSpec.Exceptions.size() ==
+EPIY.ExceptionSpec.Exceptions.size()) {
+  auto E = getCommonTypeArray(Ctx, EPIX.ExceptionSpec.Exceptions,
+  EPIY.ExceptionSpec.Exceptions);
+  EPIX.ExceptionSpec.Exceptions = E;
+  return Ctx.getFunctionType(R, P, EPIX);
+} else {

rsmith wrote:
> This seems a bit suspicious: `getCommonTypeArray` assumes the two arrays 
> contain the same types in the same order, but if the arrays can be different 
> sizes, is it really correct to assume that they contain the same types if 
> they're the same size?
> 
> Can we make this work the same way that the conditional expression handling 
> deals with differing lists of exception types?
Handled this with a new `ASTContext::mergeTypeLists` that does what the 
conditional expression handling did, while getting the common sugar of types 
when they occur in both lists.



Comment at: clang/lib/AST/ASTContext.cpp:11861
+   *IY = cast(Y);
+assert(IX->getDecl() == IY->getDecl());
+return Ctx.getInjectedClassNameType(

rsmith wrote:
> I think this should probably be a `declaresSameEntity` check: we might be 
> comparing injected class names from two different merged modules with two 
> different declarations for the same class definition. The right declaration 
> to use is the one that is chosen to be "the" definition.
Implemented this with a new getCommonDecl function, which for now will just 
fall back to the canonical decl if they differ.

Wonder if there is a cheap way to determine which of the two decls was declared 
earlier. Have to look this up, but would a simple pointer comparison be 
guaranteed to work? Eg would the earliest declaration, since being created 
earlier and allocated earlier, be guaranteed by design to have a lower (or 
greater) pointer value?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D111283

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


[PATCH] D111283: [clang] template / auto deduction deduces common sugar

2022-07-11 Thread Matheus Izvekov via Phabricator via cfe-commits
mizvekov edited the summary of this revision.
mizvekov updated this revision to Diff 443731.
mizvekov marked 2 inline comments as done.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D111283

Files:
  clang/include/clang/AST/ASTContext.h
  clang/include/clang/AST/Type.h
  clang/include/clang/Sema/Sema.h
  clang/lib/AST/ASTContext.cpp
  clang/lib/Sema/SemaDecl.cpp
  clang/lib/Sema/SemaExprCXX.cpp
  clang/lib/Sema/SemaOverload.cpp
  clang/lib/Sema/SemaStmt.cpp
  clang/lib/Sema/SemaTemplate.cpp
  clang/lib/Sema/SemaTemplateDeduction.cpp
  clang/test/SemaCXX/deduced-return-void.cpp
  clang/test/SemaCXX/sugared-auto.cpp
  clang/test/SemaTemplate/deduction.cpp
  libcxx/DELETE.ME

Index: libcxx/DELETE.ME
===
--- /dev/null
+++ libcxx/DELETE.ME
@@ -0,0 +1 @@
+D111283
Index: clang/test/SemaTemplate/deduction.cpp
===
--- clang/test/SemaTemplate/deduction.cpp
+++ clang/test/SemaTemplate/deduction.cpp
@@ -162,6 +162,15 @@
 
 } // namespace test4
 
+namespace test5 {
+
+template  class a {};
+template  void c(b, b);
+template  void c(a, a);
+void d() { c(a(), a()); }
+
+} // namespace test5
+
 // Verify that we can deduce enum-typed arguments correctly.
 namespace test14 {
   enum E { E0, E1 };
Index: clang/test/SemaCXX/sugared-auto.cpp
===
--- clang/test/SemaCXX/sugared-auto.cpp
+++ clang/test/SemaCXX/sugared-auto.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++20
+// RUN: %clang_cc1 -fsyntax-only -verify -xobjective-c++ %s -std=c++20 -fblocks -fobjc-arc -fobjc-runtime-has-weak -fenable-matrix -Wno-dynamic-exception-spec
 
 enum class N {};
 
@@ -9,6 +9,26 @@
 using Man = Animal;
 using Dog = Animal;
 
+using ManPtr = Man *;
+using DogPtr = Dog *;
+
+using SocratesPtr = ManPtr;
+
+using ConstMan = const Man;
+using ConstDog = const Dog;
+
+using Virus = void;
+using SARS = Virus;
+using Ebola = Virus;
+
+using Bacteria = float;
+using Bacilli = Bacteria;
+using Vibrio = Bacteria;
+
+struct Plant;
+using Gymnosperm = Plant;
+using Angiosperm = Plant;
+
 namespace variable {
 
 auto x1 = Animal();
@@ -41,3 +61,123 @@
 N t3 = x3; // expected-error {{lvalue of type 'Animal' (aka 'int')}}
 
 } // namespace function_basic
+
+namespace function_multiple_basic {
+
+N t1 = [] { // expected-error {{rvalue of type 'Animal' (aka 'int')}}
+  if (true)
+return Man();
+  return Dog();
+}();
+
+N t2 = []() -> decltype(auto) { // expected-error {{rvalue of type 'Animal' (aka 'int')}}
+  if (true)
+return Man();
+  return Dog();
+}();
+
+N t3 = [] { // expected-error {{rvalue of type 'Animal' (aka 'int')}}
+  if (true)
+return Dog();
+  auto x = Man();
+  return x;
+}();
+
+N t4 = [] { // expected-error {{rvalue of type 'int'}}
+  if (true)
+return Dog();
+  return 1;
+}();
+
+N t5 = [] { // expected-error {{rvalue of type 'Virus' (aka 'void')}}
+  if (true)
+return Ebola();
+  return SARS();
+}();
+
+N t6 = [] { // expected-error {{rvalue of type 'void'}}
+  if (true)
+return SARS();
+  return;
+}();
+
+} // namespace function_multiple_basic
+
+#define TEST_AUTO(X, A, B) \
+  auto X(A a, B b) {   \
+if (0) \
+  return a;\
+if (0) \
+  return b;\
+return N();\
+  }
+#define TEST_DAUTO(X, A, B) \
+  decltype(auto) X(A a, B b) {  \
+if (0)  \
+  return static_cast(a); \
+if (0)  \
+  return static_cast(b); \
+return N(); \
+  }
+
+namespace misc {
+
+TEST_AUTO(t1, ManPtr, DogPtr)  // expected-error {{but deduced as 'Animal *' (aka 'int *')}}
+TEST_AUTO(t2, ManPtr, int *)   // expected-error {{but deduced as 'int *'}}
+TEST_AUTO(t3, SocratesPtr, ManPtr) // expected-error {{but deduced as 'ManPtr' (aka 'int *')}}
+
+TEST_AUTO(t4, _Atomic(Man), _Atomic(Dog)) // expected-error {{but deduced as '_Atomic(Animal)'}}
+
+using block_man = void (^)(Man);
+using block_dog = void (^)(Dog);
+TEST_AUTO(t5, block_man, block_dog) // expected-error {{but deduced as 'void (^__strong)(Animal)'}}
+
+using fp1 = SARS (*)(Man, DogPtr) throw(Vibrio);
+using fp2 = Ebola (*)(Dog, ManPtr) throw(Bacilli);
+TEST_AUTO(t6, fp1, fp2); // expected-error {{but deduced as 'Virus (*)(Animal, Animal *) throw(Bacteria)' (aka 'void (*)(int, int *) throw(Bacteria)')}}
+
+using fp3 = SARS (*)() throw(Man);
+using fp4 = Ebola (*)() throw(Vibrio);
+auto t7(fp3 a, fp4 b) {
+  if (false)
+return true ? a : b;
+  if (false)
+return a;
+  return N(); // expected-error {{but deduced as 'SARS (*)() throw(Man, Vibrio)' (aka 'void (*)() throw(Man, Vibrio)')}}
+}
+
+using fp5 = void (*)(const Man);
+using fp6 = void (*)(Dog);
+TEST_AUTO(t8, fp5, fp6); // expected-error {{but deduced 

[PATCH] D88299: [clang-format] Add MacroUnexpander.

2022-07-11 Thread Manuel Klimek via Phabricator via cfe-commits
klimek updated this revision to Diff 443729.
klimek added a comment.

Address review comments.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D88299

Files:
  clang/lib/Format/CMakeLists.txt
  clang/lib/Format/FormatToken.h
  clang/lib/Format/MacroCallReconstructor.cpp
  clang/lib/Format/Macros.h
  clang/lib/Format/UnwrappedLineParser.h
  clang/unittests/Format/CMakeLists.txt
  clang/unittests/Format/MacroCallReconstructorTest.cpp

Index: clang/unittests/Format/MacroCallReconstructorTest.cpp
===
--- /dev/null
+++ clang/unittests/Format/MacroCallReconstructorTest.cpp
@@ -0,0 +1,688 @@
+#include "../../lib/Format/Macros.h"
+#include "../../lib/Format/UnwrappedLineParser.h"
+#include "TestLexer.h"
+#include "llvm/ADT/ArrayRef.h"
+#include "llvm/ADT/SmallVector.h"
+#include "llvm/ADT/StringRef.h"
+
+#include "gmock/gmock.h"
+#include "gtest/gtest.h"
+#include 
+#include 
+#include 
+
+namespace clang {
+namespace format {
+namespace {
+
+using UnexpandedMap =
+llvm::DenseMap>;
+
+// Keeps track of a sequence of macro expansions.
+//
+// The expanded tokens are accessible via getTokens(), while a map of macro call
+// identifier token to unexpanded token stream is accessible via
+// getUnexpanded().
+class Expansion {
+public:
+  Expansion(TestLexer , MacroExpander ) : Lex(Lex), Macros(Macros) {}
+
+  // Appends the token stream obtained from expanding the macro Name given
+  // the provided arguments, to be later retrieved with getTokens().
+  // Returns the list of tokens making up the unexpanded macro call.
+  TokenList
+  expand(llvm::StringRef Name,
+ const SmallVector, 1> ) {
+auto *ID = Lex.id(Name);
+auto UnexpandedLine = std::make_unique();
+UnexpandedLine->Tokens.push_back(ID);
+if (!Args.empty()) {
+  UnexpandedLine->Tokens.push_back(Lex.id("("));
+  for (auto I = Args.begin(), E = Args.end(); I != E; ++I) {
+if (I != Args.begin())
+  UnexpandedLine->Tokens.push_back(Lex.id(","));
+UnexpandedLine->Tokens.insert(UnexpandedLine->Tokens.end(), I->begin(),
+  I->end());
+  }
+  UnexpandedLine->Tokens.push_back(Lex.id(")"));
+}
+Unexpanded[ID] = std::move(UnexpandedLine);
+
+auto Expanded = uneof(Macros.expand(ID, Args));
+Tokens.append(Expanded.begin(), Expanded.end());
+
+TokenList UnexpandedTokens;
+for (const UnwrappedLineNode  : Unexpanded[ID]->Tokens) {
+  UnexpandedTokens.push_back(Node.Tok);
+}
+return UnexpandedTokens;
+  }
+
+  TokenList expand(llvm::StringRef Name,
+   const std::vector  = {}) {
+return expand(Name, lexArgs(Args));
+  }
+
+  const UnexpandedMap () const { return Unexpanded; }
+
+  const TokenList () const { return Tokens; }
+
+private:
+  llvm::SmallVector
+  lexArgs(const std::vector ) {
+llvm::SmallVector Result;
+for (const auto  : Args) {
+  Result.push_back(uneof(Lex.lex(Arg)));
+}
+return Result;
+  }
+  llvm::DenseMap> Unexpanded;
+  llvm::SmallVector Tokens;
+  TestLexer 
+  MacroExpander 
+};
+
+struct Chunk {
+  Chunk(llvm::ArrayRef Tokens)
+  : Tokens(Tokens.begin(), Tokens.end()) {}
+  Chunk(llvm::ArrayRef Children)
+  : Children(Children.begin(), Children.end()) {}
+  llvm::SmallVector Tokens;
+  llvm::SmallVector Children;
+};
+
+bool tokenMatches(const FormatToken *Left, const FormatToken *Right) {
+  if (Left->getType() == Right->getType() &&
+  Left->TokenText == Right->TokenText)
+return true;
+  llvm::dbgs() << Left->TokenText << " != " << Right->TokenText << "\n";
+  return false;
+}
+
+// Allows to produce chunks of a token list by typing the code of equal tokens.
+//
+// Created from a list of tokens, users call "consume" to get the next chunk
+// of tokens, checking that they match the written code.
+struct Matcher {
+  Matcher(const TokenList , TestLexer )
+  : Tokens(Tokens), It(this->Tokens.begin()), Lex(Lex) {}
+
+  Chunk consume(StringRef Tokens) {
+TokenList Result;
+for (const FormatToken *Token : uneof(Lex.lex(Tokens))) {
+  assert(tokenMatches(*It, Token));
+  Result.push_back(*It);
+  ++It;
+}
+return Chunk(Result);
+  }
+
+  TokenList Tokens;
+  TokenList::iterator It;
+  TestLexer 
+};
+
+UnexpandedMap mergeUnexpanded(const UnexpandedMap ,
+  const UnexpandedMap ) {
+  UnexpandedMap Result;
+  for (const auto  : M1) {
+Result[KV.first] = std::make_unique(*KV.second);
+  }
+  for (const auto  : M2) {
+Result[KV.first] = std::make_unique(*KV.second);
+  }
+  return Result;
+}
+
+class MacroCallReconstructorTest : public ::testing::Test {
+public:
+  MacroCallReconstructorTest() : Lex(Allocator, Buffers) {}
+
+  std::unique_ptr
+  createExpander(const std::vector ) {
+return std::make_unique(MacroDefinitions,
+   

[PATCH] D129311: [clang-format] Update return code

2022-07-11 Thread Sridhar Gopinath via Phabricator via cfe-commits
sridhar_gopinath updated this revision to Diff 443726.
sridhar_gopinath added a comment.

Replaced subprocess.check_call with subprocess.call since the former crashes 
when the return code is not zero.
+ formatting changes


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D129311

Files:
  clang/tools/clang-format/git-clang-format


Index: clang/tools/clang-format/git-clang-format
===
--- clang/tools/clang-format/git-clang-format
+++ clang/tools/clang-format/git-clang-format
@@ -198,16 +198,16 @@
 return 0
 
   if opts.diff:
-print_diff(old_tree, new_tree)
-  elif opts.diffstat:
-print_diffstat(old_tree, new_tree)
-  else:
-changed_files = apply_changes(old_tree, new_tree, force=opts.force,
-  patch_mode=opts.patch)
-if (opts.verbose >= 0 and not opts.patch) or opts.verbose >= 1:
-  print('changed files:')
-  for filename in changed_files:
-print('%s' % filename)
+return print_diff(old_tree, new_tree)
+  if opts.diffstat:
+return print_diffstat(old_tree, new_tree)
+
+  changed_files = apply_changes(old_tree, new_tree, force=opts.force,
+patch_mode=opts.patch)
+  if (opts.verbose >= 0 and not opts.patch) or opts.verbose >= 1:
+print('changed files:')
+for filename in changed_files:
+  print('%s' % filename)
 
   return 1
 
@@ -536,8 +536,8 @@
   # We also only print modified files since `new_tree` only contains the files
   # that were modified, so unmodified files would show as deleted without the
   # filter.
-  subprocess.check_call(['git', 'diff', '--diff-filter=M', old_tree, new_tree,
- '--'])
+  return subprocess.call(['git', 'diff', '--diff-filter=M',
+  old_tree, new_tree, '--exit-code', '--'])
 
 def print_diffstat(old_tree, new_tree):
   """Print the diffstat between the two trees to stdout."""
@@ -548,8 +548,14 @@
   # We also only print modified files since `new_tree` only contains the files
   # that were modified, so unmodified files would show as deleted without the
   # filter.
-  subprocess.check_call(['git', 'diff', '--diff-filter=M', '--stat', old_tree, 
new_tree,
- '--'])
+  return subprocess.call(['git',
+ 'diff',
+  '--diff-filter=M',
+  '--stat',
+  old_tree,
+  new_tree,
+  '--exit-code',
+  '--'])
 
 def apply_changes(old_tree, new_tree, force=False, patch_mode=False):
   """Apply the changes in `new_tree` to the working directory.


Index: clang/tools/clang-format/git-clang-format
===
--- clang/tools/clang-format/git-clang-format
+++ clang/tools/clang-format/git-clang-format
@@ -198,16 +198,16 @@
 return 0
 
   if opts.diff:
-print_diff(old_tree, new_tree)
-  elif opts.diffstat:
-print_diffstat(old_tree, new_tree)
-  else:
-changed_files = apply_changes(old_tree, new_tree, force=opts.force,
-  patch_mode=opts.patch)
-if (opts.verbose >= 0 and not opts.patch) or opts.verbose >= 1:
-  print('changed files:')
-  for filename in changed_files:
-print('%s' % filename)
+return print_diff(old_tree, new_tree)
+  if opts.diffstat:
+return print_diffstat(old_tree, new_tree)
+
+  changed_files = apply_changes(old_tree, new_tree, force=opts.force,
+patch_mode=opts.patch)
+  if (opts.verbose >= 0 and not opts.patch) or opts.verbose >= 1:
+print('changed files:')
+for filename in changed_files:
+  print('%s' % filename)
 
   return 1
 
@@ -536,8 +536,8 @@
   # We also only print modified files since `new_tree` only contains the files
   # that were modified, so unmodified files would show as deleted without the
   # filter.
-  subprocess.check_call(['git', 'diff', '--diff-filter=M', old_tree, new_tree,
- '--'])
+  return subprocess.call(['git', 'diff', '--diff-filter=M',
+  old_tree, new_tree, '--exit-code', '--'])
 
 def print_diffstat(old_tree, new_tree):
   """Print the diffstat between the two trees to stdout."""
@@ -548,8 +548,14 @@
   # We also only print modified files since `new_tree` only contains the files
   # that were modified, so unmodified files would show as deleted without the
   # filter.
-  subprocess.check_call(['git', 'diff', '--diff-filter=M', '--stat', old_tree, new_tree,
- '--'])
+  return subprocess.call(['git',
+ 'diff',
+  '--diff-filter=M',
+  '--stat',
+  old_tree,
+  new_tree,
+  

[PATCH] D128709: [clang-format] Handle Verilog attributes

2022-07-11 Thread Owen Pan via Phabricator via cfe-commits
owenpan accepted this revision.
owenpan added a comment.

Can you mark D128709#3617654  as done?




Comment at: clang/lib/Format/UnwrappedLineParser.cpp:1466-1471
+  } else if (FormatTok->is(tok::l_paren)) {
+const FormatToken *Next = Tokens->peekNextToken();
+if (Next && Next->is(tok::star))
+  parseParens();
+else
+  break;

owenpan wrote:
> as `peekNextToken()` never returns null.
> as `peekNextToken()` never returns null.




Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128709

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


[PATCH] D128914: [HIP] Add support for handling HIP in the linker wrapper

2022-07-11 Thread Joseph Huber via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGce091eb3b91f: [HIP] Add support for handling HIP in the 
linker wrapper (authored by jhuber6).

Changed prior to commit:
  https://reviews.llvm.org/D128914?vs=442356=443724#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128914

Files:
  clang/test/Driver/linker-wrapper-image.c
  clang/test/Driver/linker-wrapper.c
  clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp
  clang/tools/clang-linker-wrapper/OffloadWrapper.cpp
  clang/tools/clang-linker-wrapper/OffloadWrapper.h

Index: clang/tools/clang-linker-wrapper/OffloadWrapper.h
===
--- clang/tools/clang-linker-wrapper/OffloadWrapper.h
+++ clang/tools/clang-linker-wrapper/OffloadWrapper.h
@@ -21,4 +21,8 @@
 /// registers the images with the CUDA runtime.
 llvm::Error wrapCudaBinary(llvm::Module , llvm::ArrayRef Images);
 
+/// Wraps the input bundled image into the module \p M as global symbols and
+/// registers the images with the HIP runtime.
+llvm::Error wrapHIPBinary(llvm::Module , llvm::ArrayRef Images);
+
 #endif
Index: clang/tools/clang-linker-wrapper/OffloadWrapper.cpp
===
--- clang/tools/clang-linker-wrapper/OffloadWrapper.cpp
+++ clang/tools/clang-linker-wrapper/OffloadWrapper.cpp
@@ -22,6 +22,7 @@
 namespace {
 /// Magic number that begins the section containing the CUDA fatbinary.
 constexpr unsigned CudaFatMagic = 0x466243b1;
+constexpr unsigned HIPFatMagic = 0x48495046;
 
 /// Copied from clang/CGCudaRuntime.h.
 enum OffloadEntryKindFlag : uint32_t {
@@ -288,14 +289,15 @@
 
 /// Embed the image \p Image into the module \p M so it can be found by the
 /// runtime.
-GlobalVariable *createFatbinDesc(Module , ArrayRef Image) {
+GlobalVariable *createFatbinDesc(Module , ArrayRef Image, bool IsHIP) {
   LLVMContext  = M.getContext();
   llvm::Type *Int8PtrTy = Type::getInt8PtrTy(C);
   llvm::Triple Triple = llvm::Triple(M.getTargetTriple());
 
   // Create the global string containing the fatbinary.
   StringRef FatbinConstantSection =
-  Triple.isMacOSX() ? "__NV_CUDA,__nv_fatbin" : ".nv_fatbin";
+  IsHIP ? ".hip_fatbin"
+: (Triple.isMacOSX() ? "__NV_CUDA,__nv_fatbin" : ".nv_fatbin");
   auto *Data = ConstantDataArray::get(C, Image);
   auto *Fatbin = new GlobalVariable(M, Data->getType(), /*isConstant*/ true,
 GlobalVariable::InternalLinkage, Data,
@@ -303,10 +305,11 @@
   Fatbin->setSection(FatbinConstantSection);
 
   // Create the fatbinary wrapper
-  StringRef FatbinWrapperSection =
-  Triple.isMacOSX() ? "__NV_CUDA,__fatbin" : ".nvFatBinSegment";
+  StringRef FatbinWrapperSection = IsHIP   ? ".hipFatBinSegment"
+   : Triple.isMacOSX() ? "__NV_CUDA,__fatbin"
+   : ".nvFatBinSegment";
   Constant *FatbinWrapper[] = {
-  ConstantInt::get(Type::getInt32Ty(C), CudaFatMagic),
+  ConstantInt::get(Type::getInt32Ty(C), IsHIP ? HIPFatMagic : CudaFatMagic),
   ConstantInt::get(Type::getInt32Ty(C), 1),
   ConstantExpr::getPointerBitCastOrAddrSpaceCast(Fatbin, Int8PtrTy),
   ConstantPointerNull::get(Type::getInt8PtrTy(C))};
@@ -328,9 +331,10 @@
   ConstantAggregateZero::get(ArrayType::get(getEntryTy(M), 0u));
   auto *DummyEntry = new GlobalVariable(
   M, DummyInit->getType(), true, GlobalVariable::ExternalLinkage, DummyInit,
-  "__dummy.cuda_offloading.entry");
-  DummyEntry->setSection("cuda_offloading_entries");
+  IsHIP ? "__dummy.hip_offloading.entry" : "__dummy.cuda_offloading.entry");
   DummyEntry->setVisibility(GlobalValue::HiddenVisibility);
+  DummyEntry->setSection(IsHIP ? "hip_offloading_entries"
+   : "cuda_offloading_entries");
 
   return FatbinDesc;
 }
@@ -358,7 +362,7 @@
 /// 0, entry->size, 0, 0);
 ///   }
 /// }
-Function *createRegisterGlobalsFunction(Module ) {
+Function *createRegisterGlobalsFunction(Module , bool IsHIP) {
   LLVMContext  = M.getContext();
   // Get the __cudaRegisterFunction function declaration.
   auto *RegFuncTy = FunctionType::get(
@@ -368,8 +372,8 @@
Type::getInt8PtrTy(C), Type::getInt8PtrTy(C), Type::getInt8PtrTy(C),
Type::getInt8PtrTy(C), Type::getInt32PtrTy(C)},
   /*isVarArg*/ false);
-  FunctionCallee RegFunc =
-  M.getOrInsertFunction("__cudaRegisterFunction", RegFuncTy);
+  FunctionCallee RegFunc = M.getOrInsertFunction(
+  IsHIP ? "__hipRegisterFunction" : "__cudaRegisterFunction", RegFuncTy);
 
   // Get the __cudaRegisterVar function declaration.
   auto *RegVarTy = FunctionType::get(
@@ -378,25 +382,31 @@
Type::getInt8PtrTy(C), Type::getInt8PtrTy(C), 

[PATCH] D128850: [HIP] Generate offloading entries for HIP with the new driver.

2022-07-11 Thread Joseph Huber via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGe88d53d25f3b: [HIP] Generate offloading entries for HIP with 
the new driver. (authored by jhuber6).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128850

Files:
  clang/lib/CodeGen/CGCUDANV.cpp
  clang/test/CodeGenCUDA/offloading-entries.cu


Index: clang/test/CodeGenCUDA/offloading-entries.cu
===
--- clang/test/CodeGenCUDA/offloading-entries.cu
+++ clang/test/CodeGenCUDA/offloading-entries.cu
@@ -1,33 +1,57 @@
-// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py 
UTC_ARGS: --check-globals
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py 
UTC_ARGS: --check-globals --global-value-regex ".omp_offloading.entry.*"
 // RUN: %clang_cc1 -std=c++11 -triple x86_64-unknown-linux-gnu \
 // RUN:   --offload-new-driver -emit-llvm -o - -x cuda  %s | FileCheck \
-// RUN:   --check-prefix=HOST %s
+// RUN:   --check-prefix=CUDA %s
+// RUN: %clang_cc1 -std=c++11 -triple x86_64-unknown-linux-gnu \
+// RUN:   --offload-new-driver -emit-llvm -o - -x hip  %s | FileCheck \
+// RUN:   --check-prefix=HIP %s
 
 #include "Inputs/cuda.h"
 
 //.
-// HOST: @x = internal global i32 undef, align 4
-// HOST: @.omp_offloading.entry_name = internal unnamed_addr constant [8 x i8] 
c"_Z3foov\00"
-// HOST: @.omp_offloading.entry._Z3foov = weak constant 
%struct.__tgt_offload_entry { ptr @_Z18__device_stub__foov, ptr 
@.omp_offloading.entry_name, i64 0, i32 0, i32 0 }, section 
"cuda_offloading_entries", align 1
-// HOST: @.omp_offloading.entry_name.1 = internal unnamed_addr constant [8 x 
i8] c"_Z3barv\00"
-// HOST: @.omp_offloading.entry._Z3barv = weak constant 
%struct.__tgt_offload_entry { ptr @_Z18__device_stub__barv, ptr 
@.omp_offloading.entry_name.1, i64 0, i32 0, i32 0 }, section 
"cuda_offloading_entries", align 1
-// HOST: @.omp_offloading.entry_name.2 = internal unnamed_addr constant [2 x 
i8] c"x\00"
-// HOST: @.omp_offloading.entry.x = weak constant %struct.__tgt_offload_entry 
{ ptr @x, ptr @.omp_offloading.entry_name.2, i64 4, i32 0, i32 0 }, section 
"cuda_offloading_entries", align 1
+// CUDA: @.omp_offloading.entry_name = internal unnamed_addr constant [8 x i8] 
c"_Z3foov\00"
+// CUDA: @.omp_offloading.entry._Z3foov = weak constant 
%struct.__tgt_offload_entry { ptr @_Z18__device_stub__foov, ptr 
@.omp_offloading.entry_name, i64 0, i32 0, i32 0 }, section 
"cuda_offloading_entries", align 1
+// CUDA: @.omp_offloading.entry_name.1 = internal unnamed_addr constant [8 x 
i8] c"_Z3barv\00"
+// CUDA: @.omp_offloading.entry._Z3barv = weak constant 
%struct.__tgt_offload_entry { ptr @_Z18__device_stub__barv, ptr 
@.omp_offloading.entry_name.1, i64 0, i32 0, i32 0 }, section 
"cuda_offloading_entries", align 1
+// CUDA: @.omp_offloading.entry_name.2 = internal unnamed_addr constant [2 x 
i8] c"x\00"
+// CUDA: @.omp_offloading.entry.x = weak constant %struct.__tgt_offload_entry 
{ ptr @x, ptr @.omp_offloading.entry_name.2, i64 4, i32 0, i32 0 }, section 
"cuda_offloading_entries", align 1
+//.
+// HIP: @.omp_offloading.entry_name = internal unnamed_addr constant [8 x i8] 
c"_Z3foov\00"
+// HIP: @.omp_offloading.entry._Z3foov = weak constant 
%struct.__tgt_offload_entry { ptr @_Z3foov, ptr @.omp_offloading.entry_name, 
i64 0, i32 0, i32 0 }, section "hip_offloading_entries", align 1
+// HIP: @.omp_offloading.entry_name.1 = internal unnamed_addr constant [8 x 
i8] c"_Z3barv\00"
+// HIP: @.omp_offloading.entry._Z3barv = weak constant 
%struct.__tgt_offload_entry { ptr @_Z3barv, ptr @.omp_offloading.entry_name.1, 
i64 0, i32 0, i32 0 }, section "hip_offloading_entries", align 1
+// HIP: @.omp_offloading.entry_name.2 = internal unnamed_addr constant [2 x 
i8] c"x\00"
+// HIP: @.omp_offloading.entry.x = weak constant %struct.__tgt_offload_entry { 
ptr @x, ptr @.omp_offloading.entry_name.2, i64 4, i32 0, i32 0 }, section 
"hip_offloading_entries", align 1
 //.
-// HOST-LABEL: @_Z18__device_stub__foov(
-// HOST-NEXT:  entry:
-// HOST-NEXT:[[TMP0:%.*]] = call i32 @cudaLaunch(ptr 
@_Z18__device_stub__foov)
-// HOST-NEXT:br label [[SETUP_END:%.*]]
-// HOST:   setup.end:
-// HOST-NEXT:ret void
+// CUDA-LABEL: @_Z18__device_stub__foov(
+// CUDA-NEXT:  entry:
+// CUDA-NEXT:[[TMP0:%.*]] = call i32 @cudaLaunch(ptr 
@_Z18__device_stub__foov)
+// CUDA-NEXT:br label [[SETUP_END:%.*]]
+// CUDA:   setup.end:
+// CUDA-NEXT:ret void
+//
+// HIP-LABEL: @_Z18__device_stub__foov(
+// HIP-NEXT:  entry:
+// HIP-NEXT:[[TMP0:%.*]] = call i32 @hipLaunchByPtr(ptr @_Z3foov)
+// HIP-NEXT:br label [[SETUP_END:%.*]]
+// HIP:   setup.end:
+// HIP-NEXT:ret void
 //
 __global__ void foo() {}
-// HOST-LABEL: @_Z18__device_stub__barv(
-// HOST-NEXT:  entry:
-// HOST-NEXT:[[TMP0:%.*]] = call i32 @cudaLaunch(ptr 

[clang] ce091eb - [HIP] Add support for handling HIP in the linker wrapper

2022-07-11 Thread Joseph Huber via cfe-commits

Author: Joseph Huber
Date: 2022-07-11T15:49:23-04:00
New Revision: ce091eb3b91fc683513f47a565d68cf2799804c9

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

LOG: [HIP] Add support for handling HIP in the linker wrapper

This patch adds the necessary changes required to bundle and wrap HIP
files. The bundling is done using `clang-offload-bundler` currently to
mimic `fatbinary` and the wrapping is done using very similar runtime
calls to CUDA. This still does not support managed / surface / texture
variables, that would require some additional information in the entry.

One difference in the codegeneration with AMD is that I don't check if
the handle is null before destructing it, I'm not sure if that's
required.

With this we should be able to support HIP with the new driver.

Depends on D128850

Reviewed By: JonChesterfield

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

Added: 


Modified: 
clang/test/Driver/linker-wrapper-image.c
clang/test/Driver/linker-wrapper.c
clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp
clang/tools/clang-linker-wrapper/OffloadWrapper.cpp
clang/tools/clang-linker-wrapper/OffloadWrapper.h

Removed: 




diff  --git a/clang/test/Driver/linker-wrapper-image.c 
b/clang/test/Driver/linker-wrapper-image.c
index 51904e1839cdd..59f2014e466e8 100644
--- a/clang/test/Driver/linker-wrapper-image.c
+++ b/clang/test/Driver/linker-wrapper-image.c
@@ -77,7 +77,6 @@
 // CUDA-NEXT:  %5 = icmp eq i64 %size, 0
 // CUDA-NEXT:  br i1 %5, label %if.then, label %if.else
 
-
 //  CUDA: if.then:
 // CUDA-NEXT:   %6 = call i32 @__cudaRegisterFunction(ptr %0, ptr %addr, ptr 
%name, ptr %name, i32 -1, ptr null, ptr null, ptr null, ptr null, ptr null)
 // CUDA-NEXT:   br label %if.end
@@ -111,3 +110,84 @@
 //  CUDA: while.end:
 // CUDA-NEXT:   ret void
 // CUDA-NEXT: }
+
+// RUN: clang-offload-packager -o %t.out 
--image=file=%S/Inputs/dummy-elf.o,kind=hip,triple=amdgcn-amd-amdhsa,arch=gfx908
+// RUN: %clang -cc1 %s -triple x86_64-unknown-linux-gnu -emit-obj -o %t.o \
+// RUN:   -fembed-offload-object=%t.out
+// RUN: clang-linker-wrapper --print-wrapped-module --dry-run --host-triple 
x86_64-unknown-linux-gnu \
+// RUN:   -linker-path /usr/bin/ld -- %t.o -o a.out 2>&1 | FileCheck %s 
--check-prefix=HIP
+
+//  HIP: @.fatbin_image = internal constant [0 x i8] zeroinitializer, 
section ".hip_fatbin"
+// HIP-NEXT: @.fatbin_wrapper = internal constant %fatbin_wrapper { i32 
1212764230, i32 1, ptr @.fatbin_image, ptr null }, section ".hipFatBinSegment", 
align 8
+// HIP-NEXT: @__dummy.hip_offloading.entry = hidden constant [0 x 
%__tgt_offload_entry] zeroinitializer, section "hip_offloading_entries"
+// HIP-NEXT: @.hip.binary_handle = internal global ptr null
+// HIP-NEXT: @__start_hip_offloading_entries = external hidden constant [0 x 
%__tgt_offload_entry]
+// HIP-NEXT: @__stop_hip_offloading_entries = external hidden constant [0 x 
%__tgt_offload_entry]
+// HIP-NEXT: @llvm.global_ctors = appending global [1 x { i32, ptr, ptr }] [{ 
i32, ptr, ptr } { i32 1, ptr @.hip.fatbin_reg, ptr null }]
+
+//  HIP: define internal void @.hip.fatbin_reg() section ".text.startup" {
+// HIP-NEXT: entry:
+// HIP-NEXT:   %0 = call ptr @__hipRegisterFatBinary(ptr @.fatbin_wrapper)
+// HIP-NEXT:   store ptr %0, ptr @.hip.binary_handle, align 8
+// HIP-NEXT:   call void @.hip.globals_reg(ptr %0)
+// HIP-NEXT:   %1 = call i32 @atexit(ptr @.hip.fatbin_unreg)
+// HIP-NEXT:   ret void
+// HIP-NEXT: }
+
+//  HIP: define internal void @.hip.fatbin_unreg() section ".text.startup" 
{
+// HIP-NEXT: entry:
+// HIP-NEXT:   %0 = load ptr, ptr @.hip.binary_handle, align 8
+// HIP-NEXT:   call void @__hipUnregisterFatBinary(ptr %0)
+// HIP-NEXT:   ret void
+// HIP-NEXT: }
+
+//  HIP: define internal void @.hip.globals_reg(ptr %0) section 
".text.startup" {
+// HIP-NEXT: entry:
+// HIP-NEXT:   br i1 icmp ne (ptr @__start_hip_offloading_entries, ptr 
@__stop_hip_offloading_entries), label %while.entry, label %while.end
+
+//  HIP: while.entry:
+// HIP-NEXT:   %entry1 = phi ptr [ @__start_hip_offloading_entries, %entry ], 
[ %7, %if.end ]
+// HIP-NEXT:   %1 = getelementptr inbounds %__tgt_offload_entry, ptr %entry1, 
i64 0, i32 0
+// HIP-NEXT:   %addr = load ptr, ptr %1, align 8
+// HIP-NEXT:   %2 = getelementptr inbounds %__tgt_offload_entry, ptr %entry1, 
i64 0, i32 1
+// HIP-NEXT:   %name = load ptr, ptr %2, align 8
+// HIP-NEXT:   %3 = getelementptr inbounds %__tgt_offload_entry, ptr %entry1, 
i64 0, i32 2
+// HIP-NEXT:   %size = load i64, ptr %3, align 4
+// HIP-NEXT:   %4 = getelementptr inbounds %__tgt_offload_entry, ptr %entry1, 
i64 0, i32 3
+// HIP-NEXT:   %flag = load i32, ptr %4, align 4
+// HIP-NEXT:   %5 = icmp eq i64 %size, 0
+// HIP-NEXT:   br 

[clang] e88d53d - [HIP] Generate offloading entries for HIP with the new driver.

2022-07-11 Thread Joseph Huber via cfe-commits

Author: Joseph Huber
Date: 2022-07-11T15:49:21-04:00
New Revision: e88d53d25f3b48204615195615da35e575081903

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

LOG: [HIP] Generate offloading entries for HIP with the new driver.

This patch adds the small change required to output offloading entried
for HIP instead of CUDA. These should be placed in different sections so
because they need to be distinct to the offloading toolchain, otherwise
we'd have HIP trying to register CUDA kernels or vice-versa. This patch will
precede support for HIP in the linker wrapper.

Reviewed By: yaxunl, tra

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

Added: 


Modified: 
clang/lib/CodeGen/CGCUDANV.cpp
clang/test/CodeGenCUDA/offloading-entries.cu

Removed: 




diff  --git a/clang/lib/CodeGen/CGCUDANV.cpp b/clang/lib/CodeGen/CGCUDANV.cpp
index 6f2679cb15e4c..6a185c29d3cec 100644
--- a/clang/lib/CodeGen/CGCUDANV.cpp
+++ b/clang/lib/CodeGen/CGCUDANV.cpp
@@ -1116,7 +1116,8 @@ void CGNVCUDARuntime::createOffloadingEntries() {
   llvm::OpenMPIRBuilder OMPBuilder(CGM.getModule());
   OMPBuilder.initialize();
 
-  StringRef Section = "cuda_offloading_entries";
+  StringRef Section = CGM.getLangOpts().HIP ? "hip_offloading_entries"
+: "cuda_offloading_entries";
   for (KernelInfo  : EmittedKernels)
 OMPBuilder.emitOffloadingEntry(KernelHandles[I.Kernel],
getDeviceSideName(cast(I.D)), 0,

diff  --git a/clang/test/CodeGenCUDA/offloading-entries.cu 
b/clang/test/CodeGenCUDA/offloading-entries.cu
index f243028d84267..544dcec45dcb3 100644
--- a/clang/test/CodeGenCUDA/offloading-entries.cu
+++ b/clang/test/CodeGenCUDA/offloading-entries.cu
@@ -1,33 +1,57 @@
-// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py 
UTC_ARGS: --check-globals
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py 
UTC_ARGS: --check-globals --global-value-regex ".omp_offloading.entry.*"
 // RUN: %clang_cc1 -std=c++11 -triple x86_64-unknown-linux-gnu \
 // RUN:   --offload-new-driver -emit-llvm -o - -x cuda  %s | FileCheck \
-// RUN:   --check-prefix=HOST %s
+// RUN:   --check-prefix=CUDA %s
+// RUN: %clang_cc1 -std=c++11 -triple x86_64-unknown-linux-gnu \
+// RUN:   --offload-new-driver -emit-llvm -o - -x hip  %s | FileCheck \
+// RUN:   --check-prefix=HIP %s
 
 #include "Inputs/cuda.h"
 
 //.
-// HOST: @x = internal global i32 undef, align 4
-// HOST: @.omp_offloading.entry_name = internal unnamed_addr constant [8 x i8] 
c"_Z3foov\00"
-// HOST: @.omp_offloading.entry._Z3foov = weak constant 
%struct.__tgt_offload_entry { ptr @_Z18__device_stub__foov, ptr 
@.omp_offloading.entry_name, i64 0, i32 0, i32 0 }, section 
"cuda_offloading_entries", align 1
-// HOST: @.omp_offloading.entry_name.1 = internal unnamed_addr constant [8 x 
i8] c"_Z3barv\00"
-// HOST: @.omp_offloading.entry._Z3barv = weak constant 
%struct.__tgt_offload_entry { ptr @_Z18__device_stub__barv, ptr 
@.omp_offloading.entry_name.1, i64 0, i32 0, i32 0 }, section 
"cuda_offloading_entries", align 1
-// HOST: @.omp_offloading.entry_name.2 = internal unnamed_addr constant [2 x 
i8] c"x\00"
-// HOST: @.omp_offloading.entry.x = weak constant %struct.__tgt_offload_entry 
{ ptr @x, ptr @.omp_offloading.entry_name.2, i64 4, i32 0, i32 0 }, section 
"cuda_offloading_entries", align 1
+// CUDA: @.omp_offloading.entry_name = internal unnamed_addr constant [8 x i8] 
c"_Z3foov\00"
+// CUDA: @.omp_offloading.entry._Z3foov = weak constant 
%struct.__tgt_offload_entry { ptr @_Z18__device_stub__foov, ptr 
@.omp_offloading.entry_name, i64 0, i32 0, i32 0 }, section 
"cuda_offloading_entries", align 1
+// CUDA: @.omp_offloading.entry_name.1 = internal unnamed_addr constant [8 x 
i8] c"_Z3barv\00"
+// CUDA: @.omp_offloading.entry._Z3barv = weak constant 
%struct.__tgt_offload_entry { ptr @_Z18__device_stub__barv, ptr 
@.omp_offloading.entry_name.1, i64 0, i32 0, i32 0 }, section 
"cuda_offloading_entries", align 1
+// CUDA: @.omp_offloading.entry_name.2 = internal unnamed_addr constant [2 x 
i8] c"x\00"
+// CUDA: @.omp_offloading.entry.x = weak constant %struct.__tgt_offload_entry 
{ ptr @x, ptr @.omp_offloading.entry_name.2, i64 4, i32 0, i32 0 }, section 
"cuda_offloading_entries", align 1
+//.
+// HIP: @.omp_offloading.entry_name = internal unnamed_addr constant [8 x i8] 
c"_Z3foov\00"
+// HIP: @.omp_offloading.entry._Z3foov = weak constant 
%struct.__tgt_offload_entry { ptr @_Z3foov, ptr @.omp_offloading.entry_name, 
i64 0, i32 0, i32 0 }, section "hip_offloading_entries", align 1
+// HIP: @.omp_offloading.entry_name.1 = internal unnamed_addr constant [8 x 
i8] c"_Z3barv\00"
+// HIP: @.omp_offloading.entry._Z3barv = weak constant 

[PATCH] D88299: [clang-format] Add MacroUnexpander.

2022-07-11 Thread Manuel Klimek via Phabricator via cfe-commits
klimek marked 7 inline comments as done.
klimek added inline comments.



Comment at: clang/lib/Format/Macros.h:201
+  /// Generally, this line tries to have the same structure as the expanded,
+  /// formatted unwrapped lines handed in via \c addLine(), with the exception
+  /// that for multiple top-level lines, each subsequent line will be the

sammccall wrote:
> you could give this a name like "tail form", and then refer to it in docs of 
> MacroCallReconstructor::Result, in MacroCallReconstructor.cpp:482, etc.
> 
> Up to you.
I'm somewhat unhappy with the term "tail form"; happy to do this in a 
subsequent change if we find a better name.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D88299

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


[PATCH] D128712: [clang-format] Handle Verilog modules

2022-07-11 Thread Björn Schäpers via Phabricator via cfe-commits
HazardyKnusperkeks added inline comments.



Comment at: clang/lib/Format/UnwrappedLineParser.cpp:4040
+void UnwrappedLineParser::parseVerilogSensitivityList() {
+  if (!FormatTok->is(tok::at))
+return;

I prefer to make such checks before calling the function.
But others have a different opinion.

No blocker for me.



Comment at: clang/lib/Format/UnwrappedLineParser.cpp:4072
+Keywords.kw_randsequence)) {
+AddLevels += Style.IndentCaseLabels;
+nextToken();

Using `bool`s in integer expressions has caused some trouble in code I've seen. 
I'd prefer to use it as boolean.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128712

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


[PATCH] D129435: [Clang] Parse toolchain-specific offloading arguments directly

2022-07-11 Thread Joseph Huber via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG359e4a824731: [Clang] Parse toolchain-specific offloading 
arguments directly (authored by jhuber6).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D129435

Files:
  clang/lib/Driver/Driver.cpp


Index: clang/lib/Driver/Driver.cpp
===
--- clang/lib/Driver/Driver.cpp
+++ clang/lib/Driver/Driver.cpp
@@ -4355,7 +4355,17 @@
 return KnownArchs.lookup(TC);
 
   llvm::DenseSet Archs;
-  for (auto  : Args) {
+  for (auto *Arg : Args) {
+// Extract any '--[no-]offload-arch' arguments intended for this toolchain.
+std::unique_ptr ExtractedArg = nullptr;
+if (Arg->getOption().matches(options::OPT_Xopenmp_target_EQ) &&
+ToolChain::getOpenMPTriple(Arg->getValue(0)) == TC->getTriple()) {
+  Arg->claim();
+  unsigned Index = Args.getBaseArgs().MakeIndex(Arg->getValue(1));
+  ExtractedArg = getOpts().ParseOneArg(Args, Index);
+  Arg = ExtractedArg.get();
+}
+
 if (Arg->getOption().matches(options::OPT_offload_arch_EQ)) {
   for (StringRef Arch : llvm::split(Arg->getValue(), ","))
 Archs.insert(getCanonicalArchString(C, Args, Arch, TC->getTriple()));
@@ -4425,8 +4435,7 @@
 // Get the product of all bound architectures and toolchains.
 SmallVector> TCAndArchs;
 for (const ToolChain *TC : ToolChains)
-  for (StringRef Arch : getOffloadArchs(
-   C, C.getArgsForToolChain(TC, "generic", Kind), Kind, TC))
+  for (StringRef Arch : getOffloadArchs(C, Args, Kind, TC))
 TCAndArchs.push_back(std::make_pair(TC, Arch));
 
 for (unsigned I = 0, E = TCAndArchs.size(); I != E; ++I)


Index: clang/lib/Driver/Driver.cpp
===
--- clang/lib/Driver/Driver.cpp
+++ clang/lib/Driver/Driver.cpp
@@ -4355,7 +4355,17 @@
 return KnownArchs.lookup(TC);
 
   llvm::DenseSet Archs;
-  for (auto  : Args) {
+  for (auto *Arg : Args) {
+// Extract any '--[no-]offload-arch' arguments intended for this toolchain.
+std::unique_ptr ExtractedArg = nullptr;
+if (Arg->getOption().matches(options::OPT_Xopenmp_target_EQ) &&
+ToolChain::getOpenMPTriple(Arg->getValue(0)) == TC->getTriple()) {
+  Arg->claim();
+  unsigned Index = Args.getBaseArgs().MakeIndex(Arg->getValue(1));
+  ExtractedArg = getOpts().ParseOneArg(Args, Index);
+  Arg = ExtractedArg.get();
+}
+
 if (Arg->getOption().matches(options::OPT_offload_arch_EQ)) {
   for (StringRef Arch : llvm::split(Arg->getValue(), ","))
 Archs.insert(getCanonicalArchString(C, Args, Arch, TC->getTriple()));
@@ -4425,8 +4435,7 @@
 // Get the product of all bound architectures and toolchains.
 SmallVector> TCAndArchs;
 for (const ToolChain *TC : ToolChains)
-  for (StringRef Arch : getOffloadArchs(
-   C, C.getArgsForToolChain(TC, "generic", Kind), Kind, TC))
+  for (StringRef Arch : getOffloadArchs(C, Args, Kind, TC))
 TCAndArchs.push_back(std::make_pair(TC, Arch));
 
 for (unsigned I = 0, E = TCAndArchs.size(); I != E; ++I)
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 359e4a8 - [Clang] Parse toolchain-specific offloading arguments directly

2022-07-11 Thread Joseph Huber via cfe-commits

Author: Joseph Huber
Date: 2022-07-11T15:37:50-04:00
New Revision: 359e4a8247316c2f0c21072919836fd9fd4cf0f1

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

LOG: [Clang] Parse toolchain-specific offloading arguments directly

OpenMP supports multiple offloading toolchains and architectures. In
order to support this we originally used `getArgsForToolchain` to get
the arguments only intended for each toolchain. This allowed users to
manually specify if an `--offload-arch=` argument was intended for which
toolchain using `-Xopenmp-target=` or other methods. For example,

```
clang input.c -fopenmp -fopenmp-targets=nvptx64,amdgcn -Xopenmp-target=nvptx64 
--offload-arch=sm_70 -Xopenmp-target=amdgcn --offload-arch=gfx908
```

However, this was causing problems with the AMDGPU toolchain. This is
because the AMDGPU toolchain for OpenMP uses an `amdgpu` arch to determine the
architecture. If this tool is not availible the compiler will exit with an error
even when manually specifying the architecture. This patch pulls out the logic 
in
`getArgsForToolchain` and specializes it for extracting `--offload-arch`
arguments to avoid this.

Reviewed By: JonChesterfield, yaxunl

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

Added: 


Modified: 
clang/lib/Driver/Driver.cpp

Removed: 




diff  --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp
index 0da32dae2ef60..80fa3c158abc2 100644
--- a/clang/lib/Driver/Driver.cpp
+++ b/clang/lib/Driver/Driver.cpp
@@ -4355,7 +4355,17 @@ Driver::getOffloadArchs(Compilation , const 
llvm::opt::DerivedArgList ,
 return KnownArchs.lookup(TC);
 
   llvm::DenseSet Archs;
-  for (auto  : Args) {
+  for (auto *Arg : Args) {
+// Extract any '--[no-]offload-arch' arguments intended for this toolchain.
+std::unique_ptr ExtractedArg = nullptr;
+if (Arg->getOption().matches(options::OPT_Xopenmp_target_EQ) &&
+ToolChain::getOpenMPTriple(Arg->getValue(0)) == TC->getTriple()) {
+  Arg->claim();
+  unsigned Index = Args.getBaseArgs().MakeIndex(Arg->getValue(1));
+  ExtractedArg = getOpts().ParseOneArg(Args, Index);
+  Arg = ExtractedArg.get();
+}
+
 if (Arg->getOption().matches(options::OPT_offload_arch_EQ)) {
   for (StringRef Arch : llvm::split(Arg->getValue(), ","))
 Archs.insert(getCanonicalArchString(C, Args, Arch, TC->getTriple()));
@@ -4425,8 +4435,7 @@ Action *Driver::BuildOffloadingActions(Compilation ,
 // Get the product of all bound architectures and toolchains.
 SmallVector> TCAndArchs;
 for (const ToolChain *TC : ToolChains)
-  for (StringRef Arch : getOffloadArchs(
-   C, C.getArgsForToolChain(TC, "generic", Kind), Kind, TC))
+  for (StringRef Arch : getOffloadArchs(C, Args, Kind, TC))
 TCAndArchs.push_back(std::make_pair(TC, Arch));
 
 for (unsigned I = 0, E = TCAndArchs.size(); I != E; ++I)



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


[PATCH] D129443: [clang-format] Add option for aligning requires clause body

2022-07-11 Thread Björn Schäpers via Phabricator via cfe-commits
HazardyKnusperkeks added a comment.

Thanks for the patch. Please add the full context for the next revision: 
https://llvm.org/docs/Phabricator.html#requesting-a-review-via-the-web-interface


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D129443

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


[PATCH] D128914: [HIP] Add support for handling HIP in the linker wrapper

2022-07-11 Thread Joseph Huber via Phabricator via cfe-commits
jhuber6 added a comment.

In D128914#3642869 , @yaxunl wrote:

> In D128914#3642567 , @jhuber6 wrote:
>
>> In D128914#3642558 , 
>> @JonChesterfield wrote:
>>
>>> Code looks good to me. It's hard to be sure whether it works without 
>>> running a bunch of hip test cases through it, have you already done so? If 
>>> it doesn't work out of the box it should be close enough to fix up post 
>>> commit, e.g. when trying to move hip over to this by default.
>>
>> Thanks for the review, I ran a couple mini-apps with HIP versions (XSBench, 
>> RSBench, SU3Bench) using this method and they passed without issue. The only 
>> thing I was unsure about what whether or not the handle needed to be checked 
>> for null, because my testing suggested it's unnecessary. I was hoping one of 
>> the HIP developers would let me know. We can think about making this the 
>> default approach when I make the new driver work for `non-rdc` mode 
>> compilations.
>
> There is only one fatbin for -fgpu-rdc mode but the fatbin unregister 
> function is called multiple times in each TU. HIP runtime expects each fatbin 
> is unregistered only once. The old embedding scheme introduced a weak symbol 
> to track whether the fabin has been unregistered and to make sure it is only 
> unregistered once.

I see, this wrapping will only happen in RDC-mode so it's probably safe to 
ignore here? When I support non-RDC mode in the new driver it will most likely 
rely on the old code generation. Although it's entirely feasible to make 
RDC-mode the default. There's no runtime overhead when using LTO.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128914

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


[PATCH] D129404: Change default C dialect for PS5 to gnu17/gnu18.

2022-07-11 Thread Paul Robinson via Phabricator via cfe-commits
probinson accepted this revision.
probinson 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/D129404/new/

https://reviews.llvm.org/D129404

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


[PATCH] D128672: Update DynInit generation for ASan globals.

2022-07-11 Thread Mitch Phillips via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGf18de7619e5d: Update DynInit generation for ASan globals. 
(authored by hctim).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128672

Files:
  clang/lib/CodeGen/SanitizerMetadata.cpp


Index: clang/lib/CodeGen/SanitizerMetadata.cpp
===
--- clang/lib/CodeGen/SanitizerMetadata.cpp
+++ clang/lib/CodeGen/SanitizerMetadata.cpp
@@ -64,13 +64,11 @@
   Meta.NoMemtag |= CGM.isInNoSanitizeList(
   FsanitizeArgument.Mask & SanitizerKind::MemTag, GV, Loc, Ty);
 
-  if (FsanitizeArgument.has(SanitizerKind::Address)) {
-// TODO(hctim): Make this conditional when we migrate off 
llvm.asan.globals.
-IsDynInit &= !CGM.isInNoSanitizeList(SanitizerKind::Address |
- SanitizerKind::KernelAddress,
- GV, Loc, Ty, "init");
-Meta.IsDynInit = IsDynInit;
-  }
+  Meta.IsDynInit = IsDynInit && !Meta.NoAddress &&
+   FsanitizeArgument.has(SanitizerKind::Address) &&
+   !CGM.isInNoSanitizeList(SanitizerKind::Address |
+   SanitizerKind::KernelAddress,
+   GV, Loc, Ty, "init");
 
   GV->setSanitizerMetadata(Meta);
 }


Index: clang/lib/CodeGen/SanitizerMetadata.cpp
===
--- clang/lib/CodeGen/SanitizerMetadata.cpp
+++ clang/lib/CodeGen/SanitizerMetadata.cpp
@@ -64,13 +64,11 @@
   Meta.NoMemtag |= CGM.isInNoSanitizeList(
   FsanitizeArgument.Mask & SanitizerKind::MemTag, GV, Loc, Ty);
 
-  if (FsanitizeArgument.has(SanitizerKind::Address)) {
-// TODO(hctim): Make this conditional when we migrate off llvm.asan.globals.
-IsDynInit &= !CGM.isInNoSanitizeList(SanitizerKind::Address |
- SanitizerKind::KernelAddress,
- GV, Loc, Ty, "init");
-Meta.IsDynInit = IsDynInit;
-  }
+  Meta.IsDynInit = IsDynInit && !Meta.NoAddress &&
+   FsanitizeArgument.has(SanitizerKind::Address) &&
+   !CGM.isInNoSanitizeList(SanitizerKind::Address |
+   SanitizerKind::KernelAddress,
+   GV, Loc, Ty, "init");
 
   GV->setSanitizerMetadata(Meta);
 }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] f18de76 - Update DynInit generation for ASan globals.

2022-07-11 Thread Mitch Phillips via cfe-commits

Author: Mitch Phillips
Date: 2022-07-11T12:23:37-07:00
New Revision: f18de7619e5d5dde301d8d4f6f3ec0f8260be710

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

LOG: Update DynInit generation for ASan globals.

Address a follow-up TODO for Sanitizer Metadata.

Reviewed By: vitalybuka

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

Added: 


Modified: 
clang/lib/CodeGen/SanitizerMetadata.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/SanitizerMetadata.cpp 
b/clang/lib/CodeGen/SanitizerMetadata.cpp
index 5f4eb9be981f..0c752304b13d 100644
--- a/clang/lib/CodeGen/SanitizerMetadata.cpp
+++ b/clang/lib/CodeGen/SanitizerMetadata.cpp
@@ -64,13 +64,11 @@ void SanitizerMetadata::reportGlobal(llvm::GlobalVariable 
*GV,
   Meta.NoMemtag |= CGM.isInNoSanitizeList(
   FsanitizeArgument.Mask & SanitizerKind::MemTag, GV, Loc, Ty);
 
-  if (FsanitizeArgument.has(SanitizerKind::Address)) {
-// TODO(hctim): Make this conditional when we migrate off 
llvm.asan.globals.
-IsDynInit &= !CGM.isInNoSanitizeList(SanitizerKind::Address |
- SanitizerKind::KernelAddress,
- GV, Loc, Ty, "init");
-Meta.IsDynInit = IsDynInit;
-  }
+  Meta.IsDynInit = IsDynInit && !Meta.NoAddress &&
+   FsanitizeArgument.has(SanitizerKind::Address) &&
+   !CGM.isInNoSanitizeList(SanitizerKind::Address |
+   SanitizerKind::KernelAddress,
+   GV, Loc, Ty, "init");
 
   GV->setSanitizerMetadata(Meta);
 }



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


[PATCH] D105255: [MLIR][OpenMP] Added target data, exit data, and enter data operation definition for MLIR.

2022-07-11 Thread Abid via Phabricator via cfe-commits
abidmalikwaterloo updated this revision to Diff 443708.
abidmalikwaterloo added a comment.

Update ops.mlir test cases. llvm-lit is working and all tests are passing


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105255

Files:
  mlir/include/mlir/Dialect/OpenMP/OpenMPOps.td
  mlir/test/Dialect/OpenMP/ops.mlir

Index: mlir/test/Dialect/OpenMP/ops.mlir
===
--- mlir/test/Dialect/OpenMP/ops.mlir
+++ mlir/test/Dialect/OpenMP/ops.mlir
@@ -377,6 +377,26 @@
 return
 }
 
+// CHECK-LABEL: omp_target_data
+func @omp_target_data (%if_cond : i1, %device : si32,  %data1: memref, %data2: memref) -> () {
+
+// CHECK: omp.target_data
+"omp.target_data"(%if_cond, %device, %data1, %data2) ({
+   
+}) {operand_segment_sizes = dense<[1,1,1,1,0,0,0,0,0,0,0,0]>: vector<12xi32> } : ( i1, si32, memref, memref ) -> ()
+
+// CHECK: omp.target_enter_data	
+"omp.target_enter_data"(%if_cond, %device)  {operand_segment_sizes = dense<[1,1,0,0,0,0,0,0,0,0]>: vector<10xi32>, nowait } : ( i1, si32 ) -> ()
+   
+// CHECK: omp.target_exit_data
+"omp.target_exit_data"(%if_cond, %device) {operand_segment_sizes = dense<[1,1,0,0,0,0,0,0,0,0]>: vector<10xi32>, nowait } : ( i1, si32 ) -> ()
+   
+// CHECK: omp.barrier
+omp.barrier
+
+   return
+}
+
 // CHECK: omp.reduction.declare
 // CHECK-LABEL: @add_f32
 // CHECK: : f32
Index: mlir/include/mlir/Dialect/OpenMP/OpenMPOps.td
===
--- mlir/include/mlir/Dialect/OpenMP/OpenMPOps.td
+++ mlir/include/mlir/Dialect/OpenMP/OpenMPOps.td
@@ -562,6 +562,189 @@
   let assemblyFormat = "attr-dict";
 }
 
+//===-===//
+// 2.12.2 target data Construct 
+//===-===//
+
+def Target_Data: OpenMP_Op<"target_data", [AttrSizedOperandSegments]>{
+  let summary = "target data construct";
+  let description = [{
+Map variables to a device data environment for the extent of the region.
+
+The omp target data directive maps variables to a device data 
+environment, and defines the lexical scope of the data environment 
+that is created. The omp target data directive can reduce data copies 
+to and from the offloading device when multiple target regions are using 
+the same data.
+
+The optional $if_expr parameter specifies a boolean result of a
+conditional check. If this value is 1 or is not provided then the target
+region runs on a device, if it is 0 then the target region is executed 
+on the host device.
+
+The optional $device parameter specifies the device number for the target 
+region.
+
+The optional $use_device_ptr specifies the device pointers to the 
+corresponding list items in the device data environment
+	
+The optional $use_device_addr specifies the adress of the objects in the 
+device data enviornment
+
+The $map_operands specifies operands with no map type
+
+The $map_to_operands specifies operands with  map type "to"
+
+The $map_from_operands specifies operands with map type "from"
+
+The $map_to_from_operands specifies operands with map type "tofrom"
+
+The $map_alloc_operands specifies operands with map type "alloc"
+
+The $map_release_operands specifies operands with map type "release"
+
+The $map_delete_operands specifies operands with map type "delete"
+
+The $map_type_modifier vector specifies the modifier for each map type 
+operand
+
+/// map_type_modifier can be always, close, and mapper
+  }];
+
+  let arguments = (ins Optional:$if_expr,
+ Optional:$device,
+ Variadic:$use_device_ptr,
+ Variadic:$use_device_addr,
+ Variadic:$map_operands,
+ Variadic:$map_to_operands,
+ Variadic:$map_from_operands,
+ Variadic:$map_to_from_operands,
+ Variadic:$map_alloc_operands,
+ Variadic:$map_release_operands,
+ Variadic:$map_delete_operands,
+ VectorOf<[AnyInteger]>:$map_type_modifier);
+
+  let regions = (region AnyRegion:$region);
+}
+
+//===-===//
+// 2.12.3 target enter data Construct
+//===-===//
+
+def Target_EnterDataOp: OpenMP_Op<"target_enter_data", 
+ [AttrSizedOperandSegments]>{
+  let  summary = "target enter data construct";
+  let description = [{
+The target enter data directive specifies that variables are mapped to 
+a device data environment. The target enter data directive is a 
+stand-alone directive.
+	
+The optional $if_expr parameter specifies a boolean result of 

[PATCH] D126189: [C++20][Modules] Build module static initializers per P1874R1.

2022-07-11 Thread Iain Sandoe via Phabricator via cfe-commits
iains added a comment.

I need to do some more builds to be able to reproduce this - my guess (at 
present) is that this is a manifestation of '-fcxx-modules -std=c++20' being 
almost, but not exactly, the same as C++20 standardised modules.  It is 
possible that the -gmodules flag interacts with that (although one might have 
expected more than one fail if that were so).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D126189

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


[PATCH] D129298: Add denormal-fp-math attribute for f16

2022-07-11 Thread Matt Arsenault via Phabricator via cfe-commits
arsenm added a comment.

In D129298#3638759 , @dcandler wrote:

> There are currently no Arm specific changes, this is just being able to more 
> accurately describe the floating point environment via attributes in the case 
> where singles and doubles should be flushed, but not halves.

But presumably this corresponds with a directive in the assembly output needed 
to get a consistent FP mode at start. e.g. ARMAsmPrinter has checks for 
denormal-fp-math and emits something from it. I would expect a similar check 
and corresponding test if you can change these separately


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D129298

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


[clang] b19d3ee - Revert "[C++20][Modules] Build module static initializers per P1874R1."

2022-07-11 Thread Iain Sandoe via cfe-commits

Author: Iain Sandoe
Date: 2022-07-11T19:50:31+01:00
New Revision: b19d3ee7120bff4a84db7c9fa8f86c9b6ec3b1cf

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

LOG: Revert "[C++20][Modules] Build module static initializers per P1874R1."

This reverts commit ac507102d258b6fc0cb57eb60c9dfabd57ff562f.

reverting while we figuere out why one of the green dragon lldb test fails.

Added: 


Modified: 
clang/include/clang/AST/ASTContext.h
clang/include/clang/Basic/Module.h
clang/include/clang/Sema/Sema.h
clang/lib/CodeGen/CGDeclCXX.cpp
clang/lib/CodeGen/CodeGenModule.cpp
clang/lib/CodeGen/CodeGenModule.h
clang/lib/Parse/ParseAST.cpp
clang/lib/Sema/SemaModule.cpp

Removed: 
clang/test/CodeGen/module-intializer-pmf.cpp
clang/test/CodeGen/module-intializer.cpp



diff  --git a/clang/include/clang/AST/ASTContext.h 
b/clang/include/clang/AST/ASTContext.h
index db7ae9a0b55c9..87b5a6053f1f2 100644
--- a/clang/include/clang/AST/ASTContext.h
+++ b/clang/include/clang/AST/ASTContext.h
@@ -472,9 +472,6 @@ class ASTContext : public RefCountedBase {
   };
   llvm::DenseMap ModuleInitializers;
 
-  /// For module code-gen cases, this is the top-level module we are building.
-  Module *TopLevelModule = nullptr;
-
   static constexpr unsigned ConstantArrayTypesLog2InitSize = 8;
   static constexpr unsigned GeneralTypesLog2InitSize = 9;
   static constexpr unsigned FunctionProtoTypesLog2InitSize = 12;
@@ -1078,12 +1075,6 @@ class ASTContext : public RefCountedBase {
   /// Get the initializations to perform when importing a module, if any.
   ArrayRef getModuleInitializers(Module *M);
 
-  /// Set the (C++20) module we are building.
-  void setModuleForCodeGen(Module *M) { TopLevelModule = M; }
-
-  /// Get module under construction, nullptr if this is not a C++20 module.
-  Module *getModuleForCodeGen() const { return TopLevelModule; }
-
   TranslationUnitDecl *getTranslationUnitDecl() const {
 return TUDecl->getMostRecentDecl();
   }

diff  --git a/clang/include/clang/Basic/Module.h 
b/clang/include/clang/Basic/Module.h
index 47d736a3b4557..a1778baa04530 100644
--- a/clang/include/clang/Basic/Module.h
+++ b/clang/include/clang/Basic/Module.h
@@ -665,18 +665,6 @@ class Module {
   Module *findSubmodule(StringRef Name) const;
   Module *findOrInferSubmodule(StringRef Name);
 
-  /// Get the Global Module Fragment (sub-module) for this module, it there is
-  /// one.
-  ///
-  /// \returns The GMF sub-module if found, or NULL otherwise.
-  Module *getGlobalModuleFragment() { return findSubmodule(""); }
-
-  /// Get the Private Module Fragment (sub-module) for this module, it there is
-  /// one.
-  ///
-  /// \returns The PMF sub-module if found, or NULL otherwise.
-  Module *getPrivateModuleFragment() { return findSubmodule(""); }
-
   /// Determine whether the specified module would be visible to
   /// a lookup at the end of this module.
   ///

diff  --git a/clang/include/clang/Sema/Sema.h b/clang/include/clang/Sema/Sema.h
index 7dafb1b84af07..75a2e7eb31d19 100644
--- a/clang/include/clang/Sema/Sema.h
+++ b/clang/include/clang/Sema/Sema.h
@@ -2281,11 +2281,6 @@ class Sema final {
 return ModuleScopes.empty() ? nullptr : ModuleScopes.back().Module;
   }
 
-  /// Is the module scope we are an interface?
-  bool currentModuleIsInterface() const {
-return ModuleScopes.empty() ? false : ModuleScopes.back().ModuleInterface;
-  }
-
   /// Get the module owning an entity.
   Module *getOwningModule(const Decl *Entity) {
 return Entity->getOwningModule();

diff  --git a/clang/lib/CodeGen/CGDeclCXX.cpp b/clang/lib/CodeGen/CGDeclCXX.cpp
index 98b630617f26f..de5cb913220a0 100644
--- a/clang/lib/CodeGen/CGDeclCXX.cpp
+++ b/clang/lib/CodeGen/CGDeclCXX.cpp
@@ -618,127 +618,6 @@ void CodeGenModule::EmitCXXThreadLocalInitFunc() {
   CXXThreadLocals.clear();
 }
 
-/* Build the initializer for a C++20 module:
-   This is arranged to be run only once regardless of how many times the module
-   might be included transitively.  This arranged by using a control variable.
-
-   First we call any initializers for imported modules.
-   We then call initializers for the Global Module Fragment (if present)
-   We then call initializers for the current module.
-   We then call initializers for the Private Module Fragment (if present)
-*/
-
-void CodeGenModule::EmitCXXModuleInitFunc(Module *Primary) {
-  while (!CXXGlobalInits.empty() && !CXXGlobalInits.back())
-CXXGlobalInits.pop_back();
-
-  // We create the function, even if it is empty, since an importer of this
-  // module will refer to it unconditionally (for the current implementation
-  // there is no way for the importer to know that an importee does not need
-  // an initializer to be run).
-
-  // Module initializers 

[clang] e7c8ded - Revert "[C++20][Modules] Fix two tests for CTORs that return pointers [NFC]."

2022-07-11 Thread Iain Sandoe via cfe-commits

Author: Iain Sandoe
Date: 2022-07-11T19:49:48+01:00
New Revision: e7c8ded6df6d38b019a1de268535d2dd73e7adaf

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

LOG: Revert "[C++20][Modules] Fix two tests for CTORs that return pointers 
[NFC]."

This reverts commit 4328b960176f4394416093e640ad4265bde65ad7.

reverting while we figure out why one of the Greendragon lldb tests fails.

Added: 


Modified: 
clang/test/CodeGen/module-intializer-pmf.cpp
clang/test/CodeGen/module-intializer.cpp

Removed: 




diff  --git a/clang/test/CodeGen/module-intializer-pmf.cpp 
b/clang/test/CodeGen/module-intializer-pmf.cpp
index e513b280b0a75..082dda19fea09 100644
--- a/clang/test/CodeGen/module-intializer-pmf.cpp
+++ b/clang/test/CodeGen/module-intializer-pmf.cpp
@@ -29,11 +29,11 @@ struct InPMF {
 InPMF P;
 
 // CHECK: define internal void @__cxx_global_var_init
-// CHECK: call {{.*}} @_ZN4GlobC1Ev
+// CHECK: call void @_ZN4GlobC1Ev
 // CHECK: define internal void @__cxx_global_var_init
-// CHECK: call {{.*}} @_ZNW6HasPMF5InPMFC1Ev
+// CHECK: call void @_ZNW6HasPMF5InPMFC1Ev
 // CHECK: define internal void @__cxx_global_var_init
-// CHECK: call {{.*}} @_ZNW6HasPMF5InModC1Ev
+// CHECK: call void @_ZNW6HasPMF5InModC1Ev
 // CHECK: define void @_ZGIW6HasPMF
 // CHECK: store i8 1, ptr @_ZGIW6HasPMF__in_chrg
 // CHECK: call void @__cxx_global_var_init

diff  --git a/clang/test/CodeGen/module-intializer.cpp 
b/clang/test/CodeGen/module-intializer.cpp
index 0b48e87f9ea7c..df2f0a5d17da6 100644
--- a/clang/test/CodeGen/module-intializer.cpp
+++ b/clang/test/CodeGen/module-intializer.cpp
@@ -53,9 +53,9 @@ export struct Quack {
 export Quack Duck;
 
 // CHECK-N: define internal void @__cxx_global_var_init
-// CHECK-N: call {{.*}} @_ZN4OinkC1Ev
+// CHECK-N: call void @_ZN4OinkC1Ev
 // CHECK-N: define internal void @__cxx_global_var_init
-// CHECK-N: call {{.*}} @_ZNW1N5QuackC1Ev
+// CHECK-N: call void @_ZNW1N5QuackC1Ev
 // CHECK-N: define void @_ZGIW1N
 // CHECK-N: store i8 1, ptr @_ZGIW1N__in_chrg
 // CHECK-N: call void @__cxx_global_var_init
@@ -83,9 +83,9 @@ export struct Bark {
 export Bark Dog;
 
 // CHECK-O: define internal void @__cxx_global_var_init
-// CHECK-O: call {{.*}} @_ZN4MeowC2Ev
+// CHECK-O: call void @_ZN4MeowC2Ev
 // CHECK-O: define internal void @__cxx_global_var_init
-// CHECK-O: call {{.*}} @_ZNW1O4BarkC1Ev
+// CHECK-O: call void @_ZNW1O4BarkC1Ev
 // CHECK-O: define void @_ZGIW1O
 // CHECK-O: store i8 1, ptr @_ZGIW1O__in_chrg
 // CHECK-O: call void @__cxx_global_var_init
@@ -113,9 +113,9 @@ struct Squawk {
 Squawk parrot;
 
 // CHECK-P: define internal void @__cxx_global_var_init
-// CHECK-P: call {{.*}} @_ZN5CroakC1Ev
+// CHECK-P: call void @_ZN5CroakC1Ev
 // CHECK-P: define internal void @__cxx_global_var_init
-// CHECK-P: call {{.*}} @_ZNW1M6SquawkC1Ev
+// CHECK-P: call void @_ZNW1M6SquawkC1Ev
 // CHECK-P: define void @_ZGIW1MWP4Part
 // CHECK-P: store i8 1, ptr @_ZGIW1MWP4Part__in_chrg
 // CHECK-P: call void @__cxx_global_var_init
@@ -149,9 +149,9 @@ export struct Baa {
 export Baa Sheep(10);
 
 // CHECK-M: define internal void @__cxx_global_var_init
-// CHECK-M: call {{.*}} @_ZN3MooC1Ev
+// CHECK-M: call void @_ZN3MooC1Ev
 // CHECK-M: define internal void @__cxx_global_var_init
-// CHECK-M: call {{.*}} @_ZNW1M3BaaC1Ei
+// CHECK-M: call void @_ZNW1M3BaaC1Ei
 // CHECK-M: declare void @_ZGIW1O()
 // CHECK-M: declare void @_ZGIW1N()
 // CHECK-M: declare void @_ZGIW1MWP4Part()



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


[PATCH] D126864: [clang] Introduce -fstrict-flex-arrays= for stricter handling of flexible arrays

2022-07-11 Thread Kees Cook via Phabricator via cfe-commits
kees added inline comments.



Comment at: clang/lib/CodeGen/CGExpr.cpp:906
   // member, only a T[0] or T[] member gets that treatment.
+  // Under StrictFlexArraysLevel, obey c99+ that disallows FAM in union, 
see
+  // C11 6.7.2.1 §18

jyknight wrote:
> serge-sans-paille wrote:
> > jyknight wrote:
> > > I believe this bit is incorrect -- it should just go back to 'return 
> > > true;'. The StrictFlexArraysLevel check above already eliminates the 
> > > cases we want to eliminate (size==1 in strictness-level 2.)
> > Well, if we are in strictness-level 2, with an undefined size or size = 0, 
> > we can still reach that path, and don't want to return 'true' because FAM 
> > in union are in invalid per the standard.
> Yes, we can reach this path, which is why the change is incorrect. We should 
> not be changing the FAMness of undefined size, or size == 0, in any of the 
> modes. To be more specific -- 
> 
> `union X { int x[0]; };` should still be a FAM in all strictness modes. (if 
> you don't want zero-length-arrays, use `-Werror=zero-length-array`).
> 
> For `union X { int x[]; };`: this ought to be a compiler error. It's likely 
> just an oversight that we currently accept it;  I'd be OK with a (separate) 
> patch to fix that. (GCC emits an error, so there's unlikely to be 
> compatibility issues with such a change.)
> `union X { int x[0]; };` should still be a FAM in all strictness modes. (if 
> you don't want zero-length-arrays, use `-Werror=zero-length-array`).

The Linux kernel cannot use `-Wzero-length-array` because we have cases of 
userspace APIs being stuck with them. (i.e. they are part of the struct 
declaration, even though the kernel code doesn't use them.) For example:

```
In file included from ../kernel/bounds.c:13:
In file included from ../include/linux/log2.h:12:
In file included from ../include/linux/bitops.h:9:
In file included from ../include/uapi/linux/kernel.h:5:
../include/uapi/linux/sysinfo.h:22:10: error: zero size arrays are an extension 
[-Werror,-Wzero-length-array]
char _f[20-2*sizeof(__kernel_ulong_t)-sizeof(__u32)];   /* Padding: 
libc5 uses this.. */
^~~
```



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D126864

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


[PATCH] D128672: Update DynInit generation for ASan globals.

2022-07-11 Thread Mitch Phillips via Phabricator via cfe-commits
hctim updated this revision to Diff 443702.
hctim marked an inline comment as done.
hctim added a comment.

Integrate Vitaly's suggestion.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128672

Files:
  clang/lib/CodeGen/SanitizerMetadata.cpp


Index: clang/lib/CodeGen/SanitizerMetadata.cpp
===
--- clang/lib/CodeGen/SanitizerMetadata.cpp
+++ clang/lib/CodeGen/SanitizerMetadata.cpp
@@ -64,13 +64,11 @@
   Meta.NoMemtag |= CGM.isInNoSanitizeList(
   FsanitizeArgument.Mask & SanitizerKind::MemTag, GV, Loc, Ty);
 
-  if (FsanitizeArgument.has(SanitizerKind::Address)) {
-// TODO(hctim): Make this conditional when we migrate off 
llvm.asan.globals.
-IsDynInit &= !CGM.isInNoSanitizeList(SanitizerKind::Address |
- SanitizerKind::KernelAddress,
- GV, Loc, Ty, "init");
-Meta.IsDynInit = IsDynInit;
-  }
+  Meta.IsDynInit = IsDynInit && !Meta.NoAddress &&
+   FsanitizeArgument.has(SanitizerKind::Address) &&
+   !CGM.isInNoSanitizeList(SanitizerKind::Address |
+   SanitizerKind::KernelAddress,
+   GV, Loc, Ty, "init");
 
   GV->setSanitizerMetadata(Meta);
 }


Index: clang/lib/CodeGen/SanitizerMetadata.cpp
===
--- clang/lib/CodeGen/SanitizerMetadata.cpp
+++ clang/lib/CodeGen/SanitizerMetadata.cpp
@@ -64,13 +64,11 @@
   Meta.NoMemtag |= CGM.isInNoSanitizeList(
   FsanitizeArgument.Mask & SanitizerKind::MemTag, GV, Loc, Ty);
 
-  if (FsanitizeArgument.has(SanitizerKind::Address)) {
-// TODO(hctim): Make this conditional when we migrate off llvm.asan.globals.
-IsDynInit &= !CGM.isInNoSanitizeList(SanitizerKind::Address |
- SanitizerKind::KernelAddress,
- GV, Loc, Ty, "init");
-Meta.IsDynInit = IsDynInit;
-  }
+  Meta.IsDynInit = IsDynInit && !Meta.NoAddress &&
+   FsanitizeArgument.has(SanitizerKind::Address) &&
+   !CGM.isInNoSanitizeList(SanitizerKind::Address |
+   SanitizerKind::KernelAddress,
+   GV, Loc, Ty, "init");
 
   GV->setSanitizerMetadata(Meta);
 }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D129398: [ASTMatchers] Add a new matcher for callee declarations of Obj-C message expressions

2022-07-11 Thread Ziqing Luo via Phabricator via cfe-commits
ziqingluo-90 added inline comments.



Comment at: clang/include/clang/ASTMatchers/ASTMatchers.h:3853
+/// objcMessageExpr(objcMessageCallee(objcMethodDecl(hasName("foo"
+AST_MATCHER_P(ObjCMessageExpr, objcMessageCallee,
+  internal::Matcher, InnerMatcher) {

aaron.ballman wrote:
> Is there a reason why we want a separate matcher here instead of overloading 
> `callee()`?
This is a good question!  

`callee` has already been overloaded to accept both `Matcher` and 
`Matcher` as the parameter.   In my case, I will need `callee` to be 
polymorphic in returning both `Matcher` and 
`Matcher` types.   So that will end up in 4 definitions of 
`callee`, one of which has different return type and parameter type from one of 
the others.   

Is this achievable?  I know I can overload parameters or make return types 
polymorphic, but can I mix them together? 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D129398

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


[PATCH] D126189: [C++20][Modules] Build module static initializers per P1874R1.

2022-07-11 Thread Jonas Devlieghere via Phabricator via cfe-commits
JDevlieghere added a comment.

In D126189#3643045 , @iains wrote:

> In D126189#3643021 , @JDevlieghere 
> wrote:
>
>> In D126189#3643001 , @iains wrote:
>>
>>> In D126189#3642992 , 
>>> @JDevlieghere wrote:
>>>
 In D126189#3642820 , @iains 
 wrote:

> JFTR, I did not get any notification from green dragon (which is odd, 
> AFAIR it's sent email before) or I would have looked right away  - kicked 
> off a build will take a look as soon as that's done.

 Yes, the bot was already red because of a different issue.

 FWIW I tried reverting ac507102d258b6fc0cb57eb60c9dfabd57ff562f 
  and 
 4328b960176f4394416093e640ad4265bde65ad7 
  
 locally and I'm still getting a linker error about missing symbols:
>>>
>>> those refs come up as 'bad object' for me .. can you identify the upstream 
>>> changes?
>>
>> That's odd, both Github and Phab think those are the canonical hashes:
>>
>> https://github.com/llvm/llvm-project/commit/ac507102d258b6fc0cb57eb60c9dfabd57ff562f
>> https://github.com/llvm/llvm-project/commit/4328b960176f4394416093e640ad4265bde65ad7
>
> pilot error (pasto...)
>
   Undefined symbols for architecture arm64:
 "vtable for std::__1::format_error", referenced from:
 std::__1::format_error::format_error(char const*) in main.o
 std::__1::format_error::format_error(std::__1::basic_string>>> std::__1::char_traits, std::__1::allocator > const&) in main.o
>>>
>>> That seems also unrelated to the modules code, but I could always be 
>>> surprised :)
>
> OK - so if I cannot figure out what is happening in the next couple or hours, 
> I can revert those two commits (that's 9PM for me so I probably cannot do 
> much more today).

Thanks, if the bot reproduces the other issue I mentioned I'll bisect it down 
to see if there's another commit that's causing issues. I should've mentioned 
that that failures only happens when building with `-gmodules`, so it does 
sound somewhat related.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D126189

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


  1   2   >